First submission to Symbian Foundation staging server.
authorTom Sutcliffe <thomas.sutcliffe@accenture.com>
Wed, 23 Jun 2010 15:52:26 +0100
changeset 0 7f656887cf89
child 1 6c055a136ec1
First submission to Symbian Foundation staging server.
build/common/bld.inf
build/common/common.mmh
build/common/fsh_buildsis.mk
build/common/fsh_config.iby
build/common/fsh_makesis_defs.iby
build/common/fsh_manifest_defs.iby
build/common/fsh_rombuild_defs.iby
build/common/fsh_system_include.mmh
build/common/fshell.iby
build/common/readme.txt
build/common/release.src
build/s60/3rd_edition/bld.inf
build/s60/3rd_edition/mbld.txt
build/s60/3rd_edition/platform.mmh
build/s60/5th_edition/bld.inf
build/s60/5th_edition/platform.mmh
build/s60/bld_generic.inf
build/s60/fshell_platform.iby
build/s60/iosrv.ini
build/s60/platform_generic.mmh
build/s60/tb92/bld.inf
build/s60/tb92/platform.mmh
build/s60/vt100btcons_preamble.script
build/sf/2/bld.inf
build/sf/2/platform.mmh
build/sf/3/bld.inf
build/sf/3/platform.mmh
build/sf/bld_shared.inf
build/sf/fshell_platform.iby
build/sf/platform_shared.mmh
build/symtb92/bld.inf
build/symtb92/fshell_platform.iby
build/symtb92/platform.mmh
commands/activeview/activeview.cif
commands/activeview/activeview.cpp
commands/activeview/activeview.mmp
commands/backup/backup.cif
commands/backup/backup.cpp
commands/backup/backup.h
commands/backup/backup.mmp
commands/backup/backup_child.cpp
commands/backup/backup_child.mmp
commands/btrace/btrace.cif
commands/btrace/btrace.cpp
commands/btrace/btrace.h
commands/btrace/btrace.mmp
commands/btraceout/btraceout.cif
commands/btraceout/btraceout.cpp
commands/btraceout/btraceout.mmp
commands/btservices/BtData.h
commands/btservices/BtServiceView.h
commands/btservices/BtServicesEng.cpp
commands/btservices/BtServicesEng.h
commands/btservices/btservices.cif
commands/btservices/btservices.cpp
commands/btservices/btservices.mmp
commands/cat/cat.cif
commands/cat/cat.cpp
commands/cat/cat.h
commands/cat/cat.mmp
commands/cenrep/cenrep.cif
commands/cenrep/cenrep.cpp
commands/cenrep/cenrep.mmp
commands/chkdeps/byte_pair.cpp
commands/chkdeps/chkdeps.cif
commands/chkdeps/chkdeps.cpp
commands/chkdeps/chkdeps.h
commands/chkdeps/chkdeps.mmp
commands/chkdeps/e32huffman.h
commands/chkdeps/sf_decomp.cpp
commands/chkdeps/sf_deflate.h
commands/chkdeps/sf_inflate.cpp
commands/chkdeps/sf_pgcompr.cpp
commands/chkdeps/sf_pgcompr.h
commands/chkdrift/chkdrift.cif
commands/chkdrift/chkdrift.cpp
commands/chkdrift/chkdrift.mmp
commands/clipboard/clipboard.cif
commands/clipboard/clipboard.cpp
commands/clipboard/clipboard.mmp
commands/cloggerconfig/cloggerconfig.cif
commands/cloggerconfig/cloggerconfig.cpp
commands/cloggerconfig/cloggerconfig.mmp
commands/drvinfo/drvinfo.cif
commands/drvinfo/drvinfo.cpp
commands/drvinfo/drvinfo.mmp
commands/ecom/ecom.cif
commands/ecom/ecom.cpp
commands/ecom/ecom.mmp
commands/fcalendar/fcalendar.cif
commands/fcalendar/fcalendar.cpp
commands/fcalendar/fcalendar.mmp
commands/fcontacts/fcontacts.cif
commands/fcontacts/fcontacts.cpp
commands/fcontacts/fcontacts.mmp
commands/fcontacts/fcontacts_support.h
commands/fdb/fdb.cif
commands/fdb/fdb.cpp
commands/fdb/fdb.mmp
commands/fed/group/bld.inf
commands/fed/group/fed.cif
commands/fed/group/fed.mmp
commands/fed/inc/bufferbase.h
commands/fed/inc/cmdwindow.h
commands/fed/inc/common.h
commands/fed/inc/fed.h
commands/fed/inc/filebuffer.h
commands/fed/inc/lrtextview.h
commands/fed/inc/screenmngr.h
commands/fed/inc/textview.h
commands/fed/inc/viewbase.h
commands/fed/src/bufferbase.cpp
commands/fed/src/cmdwindow.cpp
commands/fed/src/fed.cpp
commands/fed/src/filebuffer.cpp
commands/fed/src/lrtextview.cpp
commands/fed/src/main.cpp
commands/fed/src/mainfshell.cpp
commands/fed/src/screenmngr.cpp
commands/fed/src/textview.cpp
commands/ffstrace/ffstrace.cif
commands/ffstrace/ffstrace.cpp
commands/ffstrace/ffstrace.mmp
commands/ffstrace/ffstraceplugin.cpp
commands/ffstrace/ffstraceplugin.mmp
commands/find/find.cif
commands/find/find.cpp
commands/find/find.mmp
commands/focus/focus.cif
commands/focus/focus.cpp
commands/focus/focus.mmp
commands/fzip/fzip.cif
commands/fzip/fzip.cpp
commands/fzip/fzip.h
commands/fzip/fzip.mmp
commands/fzip/fzipup.cpp
commands/fzip/fzipup.h
commands/genbmp/genbmp.cif
commands/genbmp/genbmp.cpp
commands/genbmp/genbmp.mmp
commands/getstack/getstack.cif
commands/getstack/getstack.cpp
commands/getstack/getstack.h
commands/getstack/getstack.mmp
commands/glinfo/glinfo.cif
commands/glinfo/glinfo.cpp
commands/glinfo/glinfo.mmp
commands/grabscreen/grabscreen.cif
commands/grabscreen/grabscreen.cpp
commands/grabscreen/grabscreen.mmp
commands/group/bld.inf
commands/group/fshell_commands.iby
commands/hal/hal.cif
commands/hal/hal.cpp
commands/hal/hal.mmp
commands/hash/hash.cif
commands/hash/hash.cpp
commands/hash/hash.mmp
commands/heaptrace/heaptrace.cif
commands/heaptrace/heaptrace.cpp
commands/heaptrace/heaptrace.mmp
commands/iap/iap.cif
commands/iap/iap.cpp
commands/iap/iap.mmp
commands/icc/icc.cif
commands/icc/icc.cpp
commands/icc/icc.mmp
commands/iniedit/iniedit.cif
commands/iniedit/iniedit.cpp
commands/iniedit/iniedit.mmp
commands/kerninfo/kerninfo.cif
commands/kerninfo/kerninfo.cpp
commands/kerninfo/kerninfo.mmp
commands/lbs/lbs.cif
commands/lbs/lbs.cpp
commands/lbs/lbs.mmp
commands/leak/leak.cif
commands/leak/leak.cpp
commands/leak/leak.h
commands/leak/leak.mmp
commands/listapps/listapps.cif
commands/listapps/listapps.cpp
commands/listapps/listapps.h
commands/listapps/listapps.mmp
commands/load/load.cif
commands/load/load.cpp
commands/load/load.mmp
commands/localdrive/localdrive.cif
commands/localdrive/localdrive.cpp
commands/localdrive/localdrive.mmp
commands/memsampler/memsampler.cif
commands/memsampler/memsampler.cpp
commands/memsampler/memsampler.mmp
commands/memsampler/memsamplerdd.cpp
commands/memsampler/memsamplerdd.h
commands/memsampler/memsamplerdd.mmp
commands/memspy/memspy.cif
commands/memspy/memspy.cpp
commands/memspy/memspy.mmp
commands/mrouter/mrouter.cif
commands/mrouter/mrouter.cpp
commands/mrouter/mrouter.mmp
commands/nitz/nitz.cif
commands/nitz/nitz.cpp
commands/nitz/nitz.mmp
commands/opendoc/opendoc.cif
commands/opendoc/opendoc.cpp
commands/opendoc/opendoc.h
commands/opendoc/opendoc.mmp
commands/paste/paste.cif
commands/paste/paste.cpp
commands/paste/paste.mmp
commands/patchdata/patchdata.cif
commands/patchdata/patchdata.cpp
commands/patchdata/patchdata.mmp
commands/ping/const.h
commands/ping/in_icmp.h
commands/ping/ping.cif
commands/ping/ping.cpp
commands/ping/ping.mmp
commands/ping/ping_misc.h
commands/ping/pingmodel.cpp
commands/ping/pingmodel.h
commands/play/play.cif
commands/play/play.cpp
commands/play/play.h
commands/play/play.mmp
commands/pointer/pointer.cif
commands/pointer/pointer.cpp
commands/pointer/pointer.mmp
commands/pubsub/pubsub.cif
commands/pubsub/pubsub.cpp
commands/pubsub/pubsub.mmp
commands/ramdefrag/ramdefrag.cif
commands/ramdefrag/ramdefrag.cpp
commands/ramdefrag/ramdefrag.mmp
commands/rcomm/rcomm.cif
commands/rcomm/rcomm.cpp
commands/rcomm/rcomm.mmp
commands/rconn/rconn.cif
commands/rconn/rconn.cpp
commands/rconn/rconn.mmp
commands/restore/restore.cif
commands/restore/restore.cpp
commands/restore/restore.h
commands/restore/restore.mmp
commands/rez/rez.cif
commands/rez/rez.cpp
commands/rez/rez.mmp
commands/rsocket/rsocket.cif
commands/rsocket/rsocket.cpp
commands/rsocket/rsocket.mmp
commands/screenmode/screenmode.cif
commands/screenmode/screenmode.cpp
commands/screenmode/screenmode.mmp
commands/setcritical/setcritical.cif
commands/setcritical/setcritical.cpp
commands/setcritical/setcritical.mmp
commands/setpriority/setpriority.cif
commands/setpriority/setpriority.cpp
commands/setpriority/setpriority.mmp
commands/shutapp/shutapp.cif
commands/shutapp/shutapp.cpp
commands/shutapp/shutapp.h
commands/shutapp/shutapp.mmp
commands/sms/sms.cif
commands/sms/sms.cpp
commands/sms/sms.h
commands/sms/sms.mmp
commands/sms/smsevent.cpp
commands/sms/smsevent.h
commands/sms/smssend.cpp
commands/sms/smssend.h
commands/sms/smswatch.cpp
commands/sms/smswatch.h
commands/snake/snake.cif
commands/snake/snake.cpp
commands/snake/snake.mmp
commands/spinlock/spinlock.cif
commands/spinlock/spinlock.cpp
commands/spinlock/spinlock.mmp
commands/sql/sql.cif
commands/sql/sql.cpp
commands/sql/sql.mmp
commands/sql/sqlcmd_open.cpp
commands/sql/sqlcmd_open.h
commands/sql/sqlsrv.cpp
commands/sql/sqlsrv.h
commands/sql/sqlsrv.mmp
commands/startup/startup.cif
commands/startup/startup.cpp
commands/startup/startup.mmp
commands/sudo/sudo.cif
commands/sudo/sudo.cpp
commands/sudo/sudo.mmp
commands/swi/swi.cif
commands/swi/swi.cpp
commands/swi/swi.h
commands/swi/swi.mmp
commands/switchview/switchview.cif
commands/switchview/switchview.cpp
commands/switchview/switchview.mmp
commands/sysinfo/sysinfo.cif
commands/sysinfo/sysinfo.cpp
commands/sysinfo/sysinfo.h
commands/sysinfo/sysinfo.mmp
commands/tail/tail.cif
commands/tail/tail.cpp
commands/tail/tail.h
commands/tail/tail.mmp
commands/tfinfo/tfinfo.cif
commands/tfinfo/tfinfo.cpp
commands/tfinfo/tfinfo.mmp
commands/top/sampler.cpp
commands/top/sampler.h
commands/top/top.cif
commands/top/top.mmp
commands/top/top_sampler.mmp
commands/top/topfshell.cpp
commands/uidinfo/uidinfo.cif
commands/uidinfo/uidinfo.cpp
commands/uidinfo/uidinfo.mmp
commands/uprofiler/uprofiler.cif
commands/uprofiler/uprofiler.cpp
commands/uprofiler/uprofiler.mmp
commands/usb/usb.cif
commands/usb/usb.cpp
commands/usb/usb.mmp
commands/variant/variant.cif
commands/variant/variant.cpp
commands/variant/variant.h
commands/variant/variant.mmp
commands/wget/wget.cif
commands/wget/wget.cpp
commands/wget/wget.h
commands/wget/wget.mmp
commands/wslog/wslog.cif
commands/wslog/wslog.cpp
commands/wslog/wslog.mmp
core/builtins/bg.cif
core/builtins/cd.cif
core/builtins/chunkinfo.cif
core/builtins/clear.cif
core/builtins/compare.cif
core/builtins/console.cif
core/builtins/cp.cif
core/builtins/date.cif
core/builtins/debug.cif
core/builtins/debugport.cif
core/builtins/dialog.cif
core/builtins/disown.cif
core/builtins/driver.cif
core/builtins/dump.cif
core/builtins/e32header.cif
core/builtins/echo.cif
core/builtins/env.cif
core/builtins/error.cif
core/builtins/exists.cif
core/builtins/exit.cif
core/builtins/export.cif
core/builtins/fg.cif
core/builtins/foreach.cif
core/builtins/fsck.cif
core/builtins/fshell.cif
core/builtins/fuser.cif
core/builtins/fuser.cpp
core/builtins/fuser.h
core/builtins/gobble.cif
core/builtins/gobble.cpp
core/builtins/gobble.h
core/builtins/hello.cif
core/builtins/hello.cpp
core/builtins/hello.h
core/builtins/help.cif
core/builtins/infoprint.cif
core/builtins/ioinfo.cif
core/builtins/jit.cif
core/builtins/jobs.cif
core/builtins/kill.cif
core/builtins/kill.cpp
core/builtins/kill.h
core/builtins/ls.cif
core/builtins/match.cif
core/builtins/meminfo.cif
core/builtins/mkdir.cif
core/builtins/more.cif
core/builtins/mv.cif
core/builtins/objinfo.cif
core/builtins/pcons.cif
core/builtins/ps.cif
core/builtins/ps.cpp
core/builtins/ps.h
core/builtins/rdebug.cif
core/builtins/readmem.cif
core/builtins/reattach.cif
core/builtins/reboot.cif
core/builtins/repeat.cif
core/builtins/rm.cif
core/builtins/rmdir.cif
core/builtins/rom.cif
core/builtins/sleep.cif
core/builtins/sort.cif
core/builtins/source.cif
core/builtins/start.cif
core/builtins/svrinfo.cif
core/builtins/tee.cif
core/builtins/tickle.cif
core/builtins/ticks.cif
core/builtins/time.cif
core/builtins/touch.cif
core/builtins/trace.cif
core/builtins/undertaker.cif
core/builtins/undertaker.cpp
core/builtins/undertaker.h
core/builtins/uptime.cif
core/builtins/var.cif
core/builtins/version.cif
core/builtins/version.cpp
core/builtins/version.h
core/builtins/which.cif
core/builtins/xmodem.cif
core/builtins/xmodem.cpp
core/builtins/xmodem.h
core/builtins/ymodem.cif
core/builtins/ymodem.cpp
core/builtins/ymodem.h
core/bwins/sbrec.def
core/docs/commands.index
core/docs/console_options.pod
core/docs/index.pod
core/docs/persistent_consoles.pod
core/eabi/sbrec.def
core/extra/inst/fshell_inst.cpp
core/extra/inst/fshell_inst.mmp
core/extra/inst/fshell_uinst.cpp
core/extra/inst/fshell_uinst.mmp
core/extra/inst/readme.txt
core/extra/launch/fshell_bt.mif
core/extra/launch/fshell_bt.svg
core/extra/launch/fshell_bt.tiny.svg
core/extra/launch/fshell_launch.cpp
core/extra/launch/fshell_launch.mmh
core/extra/launch/fshell_launch_bt.mmp
core/extra/launch/fshell_launch_bt_loc.rss
core/extra/launch/fshell_launch_bt_reg.rss
core/extra/launch/fshell_launch_rcons.mmp
core/extra/launch/fshell_launch_rcons_loc.rss
core/extra/launch/fshell_launch_rcons_reg.rss
core/extra/launch/fshell_launch_serial.mmp
core/extra/launch/fshell_launch_serial.rss
core/extra/launch/fshell_launch_serial_loc.rss
core/extra/launch/fshell_launch_tcp.mmp
core/extra/launch/fshell_launch_tcp_loc.rss
core/extra/launch/fshell_launch_tcp_reg.rss
core/extra/launch/fshell_launch_usb.mmp
core/extra/launch/fshell_launch_usb_loc.rss
core/extra/launch/fshell_launch_usb_reg.rss
core/extra/launch/fshell_local.mif
core/extra/launch/fshell_local.svg
core/extra/launch/fshell_local.tiny.svg
core/extra/launch/fshell_rcons.mif
core/extra/launch/fshell_rcons.svg
core/extra/launch/fshell_rcons.tiny.svg
core/extra/launch/fshell_tcp.mif
core/extra/launch/fshell_tcp.svg
core/extra/launch/fshell_tcp.tiny.svg
core/extra/launch/fshell_usb.mif
core/extra/launch/fshell_usb.svg
core/extra/launch/fshell_usb.tiny.svg
core/extra/launch/readme.txt
core/extra/pipsrun/pipsrun.cpp
core/extra/pipsrun/pipsrun.mmp
core/extra/shebang/102835bf.rss
core/extra/shebang/patchdata.cpp
core/extra/shebang/sbapp.cpp
core/extra/shebang/sbapp.mmp
core/extra/shebang/sbapp.rls
core/extra/shebang/sbapp_loc.rss
core/extra/shebang/sbapp_reg.rss
core/extra/shebang/sbrec.cpp
core/extra/shebang/sbrec.h
core/extra/shebang/sbrec.mmp
core/group/autostart.script
core/group/bld.inf
core/group/comm.script
core/group/fshell.bat
core/group/fshell_core.iby
core/group/fshell_version.mk
core/group/genver.pl
core/src/AppIcon/48x48.bmp
core/src/AppIcon/48x48m.bmp
core/src/AppIcon/fshell_Large.bmp
core/src/AppIcon/fshell_Large_mask.bmp
core/src/AppIcon/fshell_Small.bmp
core/src/AppIcon/fshell_Small_mask.bmp
core/src/AppIcon/fshell_xLarge.bmp
core/src/AppIcon/fshell_xLarge_mask.bmp
core/src/character_converter.cpp
core/src/character_converter.h
core/src/command_constructors.cpp
core/src/command_constructors.h
core/src/command_factory.cpp
core/src/command_factory.h
core/src/command_wrappers.cpp
core/src/command_wrappers.h
core/src/commands.cpp
core/src/commands.h
core/src/console.cpp
core/src/console.h
core/src/error.h
core/src/file_reader.cpp
core/src/file_reader.h
core/src/fshell.cpp
core/src/fshell.h
core/src/fshell.mmp
core/src/fshell.rls
core/src/fshell_loc.rss
core/src/fshell_reg.rss
core/src/job.cpp
core/src/job.h
core/src/lexer.cpp
core/src/lexer.h
core/src/license.h
core/src/line_completer.cpp
core/src/line_completer.h
core/src/line_reader.h
core/src/parser.cpp
core/src/parser.h
core/src/pipe_line.cpp
core/src/pipe_line.h
core/src/script_command.cpp
core/src/script_command.h
core/src/string_utils.cpp
core/src/string_utils.h
core/tsrc/addenv.script
core/tsrc/args.script
core/tsrc/checkargs.script
core/tsrc/errordef.script
core/tsrc/fshell-basic-test.script
core/tsrc/fshell-ccommandbase-test.script
core/tsrc/fshell-last-test.script
core/tsrc/fshell-scriptcif-test.script
core/tsrc/fshell-unicode-test.script
core/tsrc/printerror.script
core/tsrc/setenv.script
core/tsrc/smoketest.script
core/tsrc/tconsole.cpp
core/tsrc/tconsole.mmp
core/tsrc/tenvarguments.cif
core/tsrc/tenvarguments.cpp
core/tsrc/tenvarguments.mmp
core/tsrc/tfshellarguments.cpp
core/tsrc/tfshellarguments.mmp
core/tsrc/tinteger.cpp
core/tsrc/tinteger.mmp
core/tsrc/tlast.cpp
core/tsrc/tlast.mmp
core/tsrc/tlotsofscriptargs.script
core/tsrc/tnoncifenvarguments.mmp
core/tsrc/tscriptargs.script
documentation/bld.inf
documentation/change_history.pod
documentation/cif_syntax.pod
documentation/common_mmh.pod
documentation/documentation-style.css
documentation/fshell_builddocs.mk
documentation/fshell_overview.pptx
documentation/getting_started.pod
documentation/index.pod
documentation/pod-list.txt
documentation/writing_fshell_commands.pod
libraries/btrace_parser/BMARM/btrace_parserU.DEF
libraries/btrace_parser/bwins/btrace_parseru.def
libraries/btrace_parser/eabi/btrace_parseru.def
libraries/btrace_parser/group/bld.inf
libraries/btrace_parser/group/btrace_parser.iby
libraries/btrace_parser/inc/btrace_parser.h
libraries/btrace_parser/inc/btrace_parser_defs.h
libraries/btrace_parser/src/btrace_appresponse.cpp
libraries/btrace_parser/src/btrace_context.cpp
libraries/btrace_parser/src/btrace_cpuusage.cpp
libraries/btrace_parser/src/btrace_domainevent.cpp
libraries/btrace_parser/src/btrace_focuschange.cpp
libraries/btrace_parser/src/btrace_generic.cpp
libraries/btrace_parser/src/btrace_keypress.cpp
libraries/btrace_parser/src/btrace_parser.mmp
libraries/btrace_parser/src/btrace_pubsub.cpp
libraries/btrace_parser/src/btrace_reader.cpp
libraries/btrace_parser/src/btrace_screenupdate.cpp
libraries/btrace_parser/src/btrace_textonscreen.cpp
libraries/btrace_parser/src/btrace_utils.cpp
libraries/btserial/bwins/btserial.def
libraries/btserial/eabi/btserial.def
libraries/btserial/group/BtSerial.mmp
libraries/btserial/group/bld.inf
libraries/btserial/group/btincomingserial.iby
libraries/btserial/inc/btincomingserial.h
libraries/btserial/inc/btserialclient.h
libraries/btserial/inc/btserialclientserver.h
libraries/btserial/src/client/btserialclient.cpp
libraries/btserial/src/connection/btdebug.h
libraries/btserial/src/connection/btincoming.cpp
libraries/btserial/src/connection/btservice.cpp
libraries/btserial/src/connection/btservice.h
libraries/btserial/src/server/btserialserver.cpp
libraries/btserial/src/server/btserialserver.h
libraries/btserial/src/server/btserialsession.cpp
libraries/btserial/src/server/btserialsession.h
libraries/btserial/test/BtSerialTest.cpp
libraries/btserial/test/BtSerialTest.mmp
libraries/btserial/test/BtSerialTest.pkg
libraries/btserial/test/bld.inf
libraries/clogger/BMARM/CDUU.DEF
libraries/clogger/BMARM/cloggerU.DEF
libraries/clogger/BMARM/debugrouter_nopatchdata.def
libraries/clogger/BMARM/floggerU.def
libraries/clogger/BWINS/CDUU.DEF
libraries/clogger/BWINS/FLOGGERU.DEF
libraries/clogger/BWINS/cflogu.def
libraries/clogger/BWINS/cloggerU.DEF
libraries/clogger/BWINS/debugrouter.def
libraries/clogger/BWINS/debugrouter_nopatchdata.def
libraries/clogger/EABI/CDUU.DEF
libraries/clogger/EABI/FLOGGERU.DEF
libraries/clogger/EABI/cflogU.DEF
libraries/clogger/EABI/cloggerU.DEF
libraries/clogger/EABI/debugrouter.def
libraries/clogger/EABI/debugrouter_nopatchdata.def
libraries/clogger/debugRouter/bld.inf
libraries/clogger/debugRouter/debugRouter-kext.h
libraries/clogger/debugRouter/debugRouter.cpp
libraries/clogger/debugRouter/debugRouter.h
libraries/clogger/debugRouter/debugRouter.mmp
libraries/clogger/debugRouter/dobject_compat.cpp
libraries/clogger/debugRouter/dobject_compat.h
libraries/clogger/debugRouter/patchables.cpp
libraries/clogger/docs/clogger.pod
libraries/clogger/group/bld.inf
libraries/clogger/group/cdu.mmp
libraries/clogger/group/cenrep.pkg
libraries/clogger/group/cenrep.txt
libraries/clogger/group/cflog.mmp
libraries/clogger/group/clogger-stub.SIS
libraries/clogger/group/clogger-stub.pkg
libraries/clogger/group/clogger.iby
libraries/clogger/group/clogger.pkg
libraries/clogger/group/flogger.mmp
libraries/clogger/group/lib-buffered.mmp
libraries/clogger/group/lib.mmp
libraries/clogger/group/server.mmp
libraries/clogger/group/tclog.pkg
libraries/clogger/inc/CliServ.h
libraries/clogger/inc/Clogger.h
libraries/clogger/inc/CloggerServer.h
libraries/clogger/inc/SensibleClient.h
libraries/clogger/inc/SensibleClient_internals.h
libraries/clogger/inc/SensibleCompat.h
libraries/clogger/inc/SensibleFormat.h
libraries/clogger/inc/SensibleServer.h
libraries/clogger/inc/SensibleServer_server_specific.h
libraries/clogger/inc/SessionWriter.h
libraries/clogger/inc/common.h
libraries/clogger/pctools/cloggercolour.pl
libraries/clogger/pctools/unhex.pl
libraries/clogger/src/CloggerClient.cpp
libraries/clogger/src/CloggerServer.cpp
libraries/clogger/src/Flogger.cpp
libraries/clogger/src/MiscServer.cpp
libraries/clogger/src/PerformanceCritical.cpp
libraries/clogger/src/SensibleClient.cpp
libraries/clogger/src/SensibleServer.cpp
libraries/clogger/src/SessionWriter.cpp
libraries/clogger/src/cflog.cpp
libraries/clogger/tsrc/tclog.cpp
libraries/clogger/tsrc/tclog.mmp
libraries/extrabtrace/BMARM/extrabtrace.DEF
libraries/extrabtrace/bwins/extrabtrace.def
libraries/extrabtrace/eabi/extrabtrace.def
libraries/extrabtrace/group/bld.inf
libraries/extrabtrace/group/extrabtrace.iby
libraries/extrabtrace/group/extrabtrace.mmp
libraries/extrabtrace/group/extrabtracek.mmp
libraries/extrabtrace/inc/common.h
libraries/extrabtrace/inc/extrabtrace.h
libraries/extrabtrace/inc/extrabtracek.h
libraries/extrabtrace/src/eventhandler.cpp
libraries/extrabtrace/src/eventhandler.h
libraries/extrabtrace/src/extrabtrace.cpp
libraries/extrabtrace/src/extrabtracek.cpp
libraries/extrabtrace/src/sampler.cpp
libraries/extrabtrace/src/sampler.h
libraries/extrabtrace/src/usampler.cia
libraries/extrabtrace/src/usampler_cia.cpp
libraries/iosrv/bmarm/iocliu.def
libraries/iosrv/bwins/iocliu.def
libraries/iosrv/client/client.cpp
libraries/iosrv/client/client_command.cpp
libraries/iosrv/client/command_base.cpp
libraries/iosrv/client/command_base.h
libraries/iosrv/client/command_info_file.cpp
libraries/iosrv/client/env.cpp
libraries/iosrv/client/file_utils.cpp
libraries/iosrv/client/iocons.cpp
libraries/iosrv/client/memoryaccesscmd.cpp
libraries/iosrv/client/pod_formatter.cpp
libraries/iosrv/client/pod_formatter.h
libraries/iosrv/client/pod_lexer.cpp
libraries/iosrv/client/pod_lexer.h
libraries/iosrv/client/server_command.cpp
libraries/iosrv/client/text_formatter.cpp
libraries/iosrv/data/iosrv.idf
libraries/iosrv/data/iosrv.ini.bluetooth
libraries/iosrv/data/iosrv.ini.econs
libraries/iosrv/data/iosrv.ini.econs_fb
libraries/iosrv/data/iosrv.ini.eka1
libraries/iosrv/data/iosrv.ini.eka2
libraries/iosrv/data/iosrv.ini.noautodetect
libraries/iosrv/data/iosrv.ini.remote
libraries/iosrv/eabi/iocliu.def
libraries/iosrv/group/bld.inf
libraries/iosrv/group/iocli.mmp
libraries/iosrv/group/iosrv.mmp
libraries/iosrv/inc/clientserver.h
libraries/iosrv/inc/iocli.h
libraries/iosrv/inc/iocons.h
libraries/iosrv/inc/ioutils.h
libraries/iosrv/inc/ioutils.inl
libraries/iosrv/inc/memoryaccesscmd.h
libraries/iosrv/perl/group/bld.inf
libraries/iosrv/perl/lib/FShell/TextServerClient.pm
libraries/iosrv/server/config.cpp
libraries/iosrv/server/config.h
libraries/iosrv/server/console.cpp
libraries/iosrv/server/console.h
libraries/iosrv/server/endpoint.cpp
libraries/iosrv/server/endpoint.h
libraries/iosrv/server/file.cpp
libraries/iosrv/server/file.h
libraries/iosrv/server/log.cpp
libraries/iosrv/server/log.h
libraries/iosrv/server/null.cpp
libraries/iosrv/server/null.h
libraries/iosrv/server/object.cpp
libraries/iosrv/server/object.h
libraries/iosrv/server/persistentconsole.cpp
libraries/iosrv/server/persistentconsole.h
libraries/iosrv/server/pipe.cpp
libraries/iosrv/server/pipe.h
libraries/iosrv/server/readwrite.cpp
libraries/iosrv/server/readwrite.h
libraries/iosrv/server/server.cpp
libraries/iosrv/server/server.h
libraries/iosrv/server/session.cpp
libraries/iosrv/server/session.h
libraries/iosrv/tsrc/t1_newlineend.txt
libraries/iosrv/tsrc/t2_nonewlineend.txt
libraries/iosrv/tsrc/t3_alloneline.txt
libraries/iosrv/tsrc/t_ioread.cpp
libraries/iosrv/tsrc/t_ioread.mmp
libraries/iosrv/tsrc/t_ioread.script
libraries/lineeditor/bmarm/lineeditorU.def
libraries/lineeditor/bwins/lineeditoru.def
libraries/lineeditor/eabi/lineeditoru.def
libraries/lineeditor/group/bld.inf
libraries/lineeditor/group/lineeditor.iby
libraries/lineeditor/group/lineeditor.mmp
libraries/lineeditor/inc/abstract_console_writer.h
libraries/lineeditor/inc/cconsolebase_writer.h
libraries/lineeditor/inc/iocons_writer.h
libraries/lineeditor/inc/line_editor.h
libraries/lineeditor/inc/line_editor_observer.h
libraries/lineeditor/src/cconsolebase_writer.cpp
libraries/lineeditor/src/iocons_writer.cpp
libraries/lineeditor/src/line_editor.cpp
libraries/ltkutils/BMARM/ltkutils-tcb.DEF
libraries/ltkutils/BMARM/ltkutils.DEF
libraries/ltkutils/bwins/ltkutils-tcb.def
libraries/ltkutils/bwins/ltkutils.def
libraries/ltkutils/eabi/ltkutils-tcb.def
libraries/ltkutils/eabi/ltkutils.def
libraries/ltkutils/group/bld.inf
libraries/ltkutils/group/ltkutils-tcb.mmp
libraries/ltkutils/group/ltkutils.iby
libraries/ltkutils/group/ltkutils.mmp
libraries/ltkutils/inc/bsym.h
libraries/ltkutils/inc/descriptorutils.h
libraries/ltkutils/inc/heaputils.h
libraries/ltkutils/inc/ltkhal.h
libraries/ltkutils/inc/ltkutils.h
libraries/ltkutils/inc/ltkutils.inl
libraries/ltkutils/inc/settings.h
libraries/ltkutils/inc/stringhash.h
libraries/ltkutils/src/breakpoint.cia
libraries/ltkutils/src/breakpoint.cpp
libraries/ltkutils/src/bsym.cpp
libraries/ltkutils/src/bsymtree.cpp
libraries/ltkutils/src/bsymtree.h
libraries/ltkutils/src/clipboard.cpp
libraries/ltkutils/src/descriptorJuggling.cpp
libraries/ltkutils/src/friendlynames.cpp
libraries/ltkutils/src/heaphackery.cpp
libraries/ltkutils/src/hexdump.cpp
libraries/ltkutils/src/keyinject.cpp
libraries/ltkutils/src/ltkhal.cpp
libraries/ltkutils/src/mapfile.cpp
libraries/ltkutils/src/proxyallocatorhelper.cpp
libraries/ltkutils/src/rez.cpp
libraries/ltkutils/src/settings.cpp
libraries/ltkutils/src/symbolics.cpp
libraries/ltkutils/src/w32crack.cpp
libraries/ltkutils/tsrc/Performance.xlsx
libraries/ltkutils/tsrc/catcompare.script
libraries/ltkutils/tsrc/tallochelper.cpp
libraries/ltkutils/tsrc/tallochelper.mmp
libraries/ltkutils/tsrc/test1.idf
libraries/ltkutils/tsrc/test1.ini
libraries/ltkutils/tsrc/test2.idf
libraries/ltkutils/tsrc/test2.ini
libraries/ltkutils/tsrc/test3.ini
libraries/ltkutils/tsrc/test4.ini
libraries/ltkutils/tsrc/test5.ini
libraries/ltkutils/tsrc/test6.ini
libraries/ltkutils/tsrc/tset.script
libraries/ltkutils/tsrc/tsettings.cpp
libraries/ltkutils/tsrc/tsettings.mmp
libraries/ltkutils/tsrc/tstringhash.cpp
libraries/ltkutils/tsrc/tstringhash.mmp
libraries/ltkutils/tsrc/tutf8.cpp
libraries/ltkutils/tsrc/tutf8.mmp
libraries/memoryaccess/DynamicDfcSupport.cpp
libraries/memoryaccess/DynamicDfcSupport.h
libraries/memoryaccess/MemoryAccess.cpp
libraries/memoryaccess/MemoryAccess.iby
libraries/memoryaccess/MemoryAccess.mmp
libraries/memoryaccess/PropertyAccess.cpp
libraries/memoryaccess/PropertyAccess.h
libraries/memoryaccess/TrkNextInstructionAfterPC.cpp
libraries/memoryaccess/bld.inf
libraries/memoryaccess/bmarm/memoryaccess.def
libraries/memoryaccess/bwins/memoryaccess.def
libraries/memoryaccess/dobject.h
libraries/memoryaccess/eabi/memoryaccess.def
libraries/memoryaccess/fdebuggerkernel.cpp
libraries/memoryaccess/fdebuggerkernel.h
libraries/memoryaccess/hwbreak.cia
libraries/memoryaccess/hwbreak_cia.cpp
libraries/memoryaccess/memoryaccess.h
libraries/memoryaccess/objectix.cpp
libraries/qr3/BMARM/LoggingAllocatorU.DEF
libraries/qr3/BMARM/QR3U.DEF
libraries/qr3/bwins/LoggingAllocatorU.DEF
libraries/qr3/bwins/QR3U.DEF
libraries/qr3/eabi/LoggingAllocatorU.DEF
libraries/qr3/eabi/QR3U.DEF
libraries/qr3/group/LoggingAllocator.mmp
libraries/qr3/group/bld.inf
libraries/qr3/group/qr3.iby
libraries/qr3/group/qr3.mmp
libraries/qr3/group/sandbox.mmp
libraries/qr3/inc/KernLbxModel.h
libraries/qr3/inc/LoggingAllocator.h
libraries/qr3/inc/NotifierProxy.h
libraries/qr3/inc/QR3Dll.h
libraries/qr3/inc/QR3ProductPlugin.h
libraries/qr3/inc/QResources3.hrh
libraries/qr3/inc/Utils.h
libraries/qr3/inc/sandbox.h
libraries/qr3/src/KernLbxModel.cpp
libraries/qr3/src/LoggingAllocator.cpp
libraries/qr3/src/NotifierProxy.cpp
libraries/qr3/src/Utils.cpp
libraries/qr3/src/featreglistboxdata.cpp
libraries/qr3/src/halListboxdata.cpp
libraries/qr3/src/heap.cpp
libraries/qr3/src/keycapture.cpp
libraries/qr3/src/msgqlistboxdata.cpp
libraries/qr3/src/mutexlistboxdata.cpp
libraries/qr3/src/objectlist.cpp
libraries/qr3/src/openfilesListboxdata.cpp
libraries/qr3/src/propertywatcher.cpp
libraries/qr3/src/sandbox.cpp
libraries/qr3/src/semaphorelistboxdata.cpp
libraries/qr3/src/serverlistboxdata.cpp
libraries/qr3/src/threadListboxdata.cpp
libraries/qr3/src/timerlistboxdata.cpp
libraries/qr3/src/wglistboxdata.cpp
libraries/spcre/bwins/spcreu.def
libraries/spcre/eabi/spcreu.def
libraries/spcre/grep/Grep.cif
libraries/spcre/grep/Grep.cpp
libraries/spcre/grep/Grep.mmp
libraries/spcre/group/ToDo.txt
libraries/spcre/group/bld.inf
libraries/spcre/group/spcre.iby
libraries/spcre/group/spcre.mmp
libraries/spcre/inc/cregex.h
libraries/spcre/inc/cregex.inl
libraries/spcre/inc/tregexarg.h
libraries/spcre/inc/tregexarg.inl
libraries/spcre/inc/tregexoptions.h
libraries/spcre/inc/tregexoptions.inl
libraries/spcre/libpcre/bwins/libpcreu.def
libraries/spcre/libpcre/eabi/libpcreu.def
libraries/spcre/libpcre/group/bld.inf
libraries/spcre/libpcre/group/libpcre.mmp
libraries/spcre/libpcre/inc/config.h
libraries/spcre/libpcre/inc/pcre.h
libraries/spcre/libpcre/inc/pcre_printint.src
libraries/spcre/libpcre/pcre/132html
libraries/spcre/libpcre/pcre/AUTHORS
libraries/spcre/libpcre/pcre/CMakeLists.txt
libraries/spcre/libpcre/pcre/COPYING
libraries/spcre/libpcre/pcre/ChangeLog
libraries/spcre/libpcre/pcre/CleanTxt
libraries/spcre/libpcre/pcre/Detrail
libraries/spcre/libpcre/pcre/HACKING
libraries/spcre/libpcre/pcre/INSTALL
libraries/spcre/libpcre/pcre/LICENCE
libraries/spcre/libpcre/pcre/Makefile.am
libraries/spcre/libpcre/pcre/Makefile.in
libraries/spcre/libpcre/pcre/NEWS
libraries/spcre/libpcre/pcre/NON-UNIX-USE
libraries/spcre/libpcre/pcre/PrepareRelease
libraries/spcre/libpcre/pcre/README
libraries/spcre/libpcre/pcre/RunGrepTest
libraries/spcre/libpcre/pcre/RunTest
libraries/spcre/libpcre/pcre/RunTest.bat
libraries/spcre/libpcre/pcre/aclocal.m4
libraries/spcre/libpcre/pcre/cmake/COPYING-CMAKE-SCRIPTS
libraries/spcre/libpcre/pcre/cmake/FindPackageHandleStandardArgs.cmake
libraries/spcre/libpcre/pcre/cmake/FindReadline.cmake
libraries/spcre/libpcre/pcre/config-cmake.h.in
libraries/spcre/libpcre/pcre/config.guess
libraries/spcre/libpcre/pcre/config.h.generic
libraries/spcre/libpcre/pcre/config.h.in
libraries/spcre/libpcre/pcre/config.sub
libraries/spcre/libpcre/pcre/configure
libraries/spcre/libpcre/pcre/configure.ac
libraries/spcre/libpcre/pcre/depcomp
libraries/spcre/libpcre/pcre/dftables.c
libraries/spcre/libpcre/pcre/doc/html/index.html
libraries/spcre/libpcre/pcre/doc/html/pcre-config.html
libraries/spcre/libpcre/pcre/doc/html/pcre.html
libraries/spcre/libpcre/pcre/doc/html/pcre_compile.html
libraries/spcre/libpcre/pcre/doc/html/pcre_compile2.html
libraries/spcre/libpcre/pcre/doc/html/pcre_config.html
libraries/spcre/libpcre/pcre/doc/html/pcre_copy_named_substring.html
libraries/spcre/libpcre/pcre/doc/html/pcre_copy_substring.html
libraries/spcre/libpcre/pcre/doc/html/pcre_dfa_exec.html
libraries/spcre/libpcre/pcre/doc/html/pcre_exec.html
libraries/spcre/libpcre/pcre/doc/html/pcre_free_substring.html
libraries/spcre/libpcre/pcre/doc/html/pcre_free_substring_list.html
libraries/spcre/libpcre/pcre/doc/html/pcre_fullinfo.html
libraries/spcre/libpcre/pcre/doc/html/pcre_get_named_substring.html
libraries/spcre/libpcre/pcre/doc/html/pcre_get_stringnumber.html
libraries/spcre/libpcre/pcre/doc/html/pcre_get_stringtable_entries.html
libraries/spcre/libpcre/pcre/doc/html/pcre_get_substring.html
libraries/spcre/libpcre/pcre/doc/html/pcre_get_substring_list.html
libraries/spcre/libpcre/pcre/doc/html/pcre_info.html
libraries/spcre/libpcre/pcre/doc/html/pcre_maketables.html
libraries/spcre/libpcre/pcre/doc/html/pcre_refcount.html
libraries/spcre/libpcre/pcre/doc/html/pcre_study.html
libraries/spcre/libpcre/pcre/doc/html/pcre_version.html
libraries/spcre/libpcre/pcre/doc/html/pcreapi.html
libraries/spcre/libpcre/pcre/doc/html/pcrebuild.html
libraries/spcre/libpcre/pcre/doc/html/pcrecallout.html
libraries/spcre/libpcre/pcre/doc/html/pcrecompat.html
libraries/spcre/libpcre/pcre/doc/html/pcrecpp.html
libraries/spcre/libpcre/pcre/doc/html/pcregrep.html
libraries/spcre/libpcre/pcre/doc/html/pcrematching.html
libraries/spcre/libpcre/pcre/doc/html/pcrepartial.html
libraries/spcre/libpcre/pcre/doc/html/pcrepattern.html
libraries/spcre/libpcre/pcre/doc/html/pcreperform.html
libraries/spcre/libpcre/pcre/doc/html/pcreposix.html
libraries/spcre/libpcre/pcre/doc/html/pcreprecompile.html
libraries/spcre/libpcre/pcre/doc/html/pcresample.html
libraries/spcre/libpcre/pcre/doc/html/pcrestack.html
libraries/spcre/libpcre/pcre/doc/html/pcresyntax.html
libraries/spcre/libpcre/pcre/doc/html/pcretest.html
libraries/spcre/libpcre/pcre/doc/index.html.src
libraries/spcre/libpcre/pcre/doc/pcre-config.1
libraries/spcre/libpcre/pcre/doc/pcre-config.txt
libraries/spcre/libpcre/pcre/doc/pcre.3
libraries/spcre/libpcre/pcre/doc/pcre.txt
libraries/spcre/libpcre/pcre/doc/pcre_compile.3
libraries/spcre/libpcre/pcre/doc/pcre_compile2.3
libraries/spcre/libpcre/pcre/doc/pcre_config.3
libraries/spcre/libpcre/pcre/doc/pcre_copy_named_substring.3
libraries/spcre/libpcre/pcre/doc/pcre_copy_substring.3
libraries/spcre/libpcre/pcre/doc/pcre_dfa_exec.3
libraries/spcre/libpcre/pcre/doc/pcre_exec.3
libraries/spcre/libpcre/pcre/doc/pcre_free_substring.3
libraries/spcre/libpcre/pcre/doc/pcre_free_substring_list.3
libraries/spcre/libpcre/pcre/doc/pcre_fullinfo.3
libraries/spcre/libpcre/pcre/doc/pcre_get_named_substring.3
libraries/spcre/libpcre/pcre/doc/pcre_get_stringnumber.3
libraries/spcre/libpcre/pcre/doc/pcre_get_stringtable_entries.3
libraries/spcre/libpcre/pcre/doc/pcre_get_substring.3
libraries/spcre/libpcre/pcre/doc/pcre_get_substring_list.3
libraries/spcre/libpcre/pcre/doc/pcre_info.3
libraries/spcre/libpcre/pcre/doc/pcre_maketables.3
libraries/spcre/libpcre/pcre/doc/pcre_refcount.3
libraries/spcre/libpcre/pcre/doc/pcre_study.3
libraries/spcre/libpcre/pcre/doc/pcre_version.3
libraries/spcre/libpcre/pcre/doc/pcreapi.3
libraries/spcre/libpcre/pcre/doc/pcrebuild.3
libraries/spcre/libpcre/pcre/doc/pcrecallout.3
libraries/spcre/libpcre/pcre/doc/pcrecompat.3
libraries/spcre/libpcre/pcre/doc/pcrecpp.3
libraries/spcre/libpcre/pcre/doc/pcregrep.1
libraries/spcre/libpcre/pcre/doc/pcregrep.txt
libraries/spcre/libpcre/pcre/doc/pcrematching.3
libraries/spcre/libpcre/pcre/doc/pcrepartial.3
libraries/spcre/libpcre/pcre/doc/pcrepattern.3
libraries/spcre/libpcre/pcre/doc/pcreperform.3
libraries/spcre/libpcre/pcre/doc/pcreposix.3
libraries/spcre/libpcre/pcre/doc/pcreprecompile.3
libraries/spcre/libpcre/pcre/doc/pcresample.3
libraries/spcre/libpcre/pcre/doc/pcrestack.3
libraries/spcre/libpcre/pcre/doc/pcresyntax.3
libraries/spcre/libpcre/pcre/doc/pcretest.1
libraries/spcre/libpcre/pcre/doc/pcretest.txt
libraries/spcre/libpcre/pcre/doc/perltest.txt
libraries/spcre/libpcre/pcre/install-sh
libraries/spcre/libpcre/pcre/libpcre.pc.in
libraries/spcre/libpcre/pcre/libpcrecpp.pc.in
libraries/spcre/libpcre/pcre/ltmain.sh
libraries/spcre/libpcre/pcre/makevp.bat
libraries/spcre/libpcre/pcre/makevp_c.txt
libraries/spcre/libpcre/pcre/makevp_l.txt
libraries/spcre/libpcre/pcre/missing
libraries/spcre/libpcre/pcre/pcre-config.in
libraries/spcre/libpcre/pcre/pcre.h.generic
libraries/spcre/libpcre/pcre/pcre.h.in
libraries/spcre/libpcre/pcre/pcre_chartables.c.dist
libraries/spcre/libpcre/pcre/pcre_compile.c
libraries/spcre/libpcre/pcre/pcre_config.c
libraries/spcre/libpcre/pcre/pcre_dfa_exec.c
libraries/spcre/libpcre/pcre/pcre_exec.c
libraries/spcre/libpcre/pcre/pcre_fullinfo.c
libraries/spcre/libpcre/pcre/pcre_get.c
libraries/spcre/libpcre/pcre/pcre_globals.c
libraries/spcre/libpcre/pcre/pcre_info.c
libraries/spcre/libpcre/pcre/pcre_internal.h
libraries/spcre/libpcre/pcre/pcre_maketables.c
libraries/spcre/libpcre/pcre/pcre_newline.c
libraries/spcre/libpcre/pcre/pcre_ord2utf8.c
libraries/spcre/libpcre/pcre/pcre_printint.src
libraries/spcre/libpcre/pcre/pcre_refcount.c
libraries/spcre/libpcre/pcre/pcre_scanner.cc
libraries/spcre/libpcre/pcre/pcre_scanner.h
libraries/spcre/libpcre/pcre/pcre_scanner_unittest.cc
libraries/spcre/libpcre/pcre/pcre_stringpiece.cc
libraries/spcre/libpcre/pcre/pcre_stringpiece.h.in
libraries/spcre/libpcre/pcre/pcre_stringpiece_unittest.cc
libraries/spcre/libpcre/pcre/pcre_study.c
libraries/spcre/libpcre/pcre/pcre_tables.c
libraries/spcre/libpcre/pcre/pcre_try_flipped.c
libraries/spcre/libpcre/pcre/pcre_ucd.c
libraries/spcre/libpcre/pcre/pcre_valid_utf8.c
libraries/spcre/libpcre/pcre/pcre_version.c
libraries/spcre/libpcre/pcre/pcre_xclass.c
libraries/spcre/libpcre/pcre/pcrecpp.cc
libraries/spcre/libpcre/pcre/pcrecpp.h
libraries/spcre/libpcre/pcre/pcrecpp_internal.h
libraries/spcre/libpcre/pcre/pcrecpp_unittest.cc
libraries/spcre/libpcre/pcre/pcrecpparg.h.in
libraries/spcre/libpcre/pcre/pcredemo.c
libraries/spcre/libpcre/pcre/pcregexp.pas
libraries/spcre/libpcre/pcre/pcregrep.c
libraries/spcre/libpcre/pcre/pcreposix.c
libraries/spcre/libpcre/pcre/pcreposix.h
libraries/spcre/libpcre/pcre/pcretest.c
libraries/spcre/libpcre/pcre/perltest.pl
libraries/spcre/libpcre/pcre/testdata/grepinput
libraries/spcre/libpcre/pcre/testdata/grepinput8
libraries/spcre/libpcre/pcre/testdata/grepinputv
libraries/spcre/libpcre/pcre/testdata/grepinputx
libraries/spcre/libpcre/pcre/testdata/greplist
libraries/spcre/libpcre/pcre/testdata/grepoutput
libraries/spcre/libpcre/pcre/testdata/grepoutput8
libraries/spcre/libpcre/pcre/testdata/grepoutputN
libraries/spcre/libpcre/pcre/testdata/testinput1
libraries/spcre/libpcre/pcre/testdata/testinput10
libraries/spcre/libpcre/pcre/testdata/testinput2
libraries/spcre/libpcre/pcre/testdata/testinput3
libraries/spcre/libpcre/pcre/testdata/testinput4
libraries/spcre/libpcre/pcre/testdata/testinput5
libraries/spcre/libpcre/pcre/testdata/testinput6
libraries/spcre/libpcre/pcre/testdata/testinput7
libraries/spcre/libpcre/pcre/testdata/testinput8
libraries/spcre/libpcre/pcre/testdata/testinput9
libraries/spcre/libpcre/pcre/testdata/testoutput1
libraries/spcre/libpcre/pcre/testdata/testoutput10
libraries/spcre/libpcre/pcre/testdata/testoutput2
libraries/spcre/libpcre/pcre/testdata/testoutput3
libraries/spcre/libpcre/pcre/testdata/testoutput4
libraries/spcre/libpcre/pcre/testdata/testoutput5
libraries/spcre/libpcre/pcre/testdata/testoutput6
libraries/spcre/libpcre/pcre/testdata/testoutput7
libraries/spcre/libpcre/pcre/testdata/testoutput8
libraries/spcre/libpcre/pcre/testdata/testoutput9
libraries/spcre/libpcre/pcre/testdata/wintestinput3
libraries/spcre/libpcre/pcre/testdata/wintestoutput3
libraries/spcre/libpcre/pcre/ucp.h
libraries/spcre/libpcre/src/pcre_chartables.c
libraries/spcre/libpcre/src/pcredllmain.cpp
libraries/spcre/src/cregex.cpp
libraries/spcre/src/tregexarg.cpp
libraries/spcre/src/tregexoptions.cpp
libraries/spcre/test/group/bld.inf
libraries/spcre/test/group/spcreconsole.mmp
libraries/spcre/test/src/spcreconsole.cpp
plugins/consoles/common/bld.inf
plugins/consoles/common/consoleextensions.h
plugins/consoles/common/consoleextensions.inl
plugins/consoles/consoleproxy/BMARM/consoleproxyU.def
plugins/consoles/consoleproxy/bwins/consoleproxyu.def
plugins/consoles/consoleproxy/eabi/consoleproxyu.def
plugins/consoles/consoleproxy/group/bld.inf
plugins/consoles/consoleproxy/group/consoleproxy.iby
plugins/consoles/consoleproxy/group/consoleproxy.mmp
plugins/consoles/consoleproxy/inc/consoleproxy.h
plugins/consoles/consoleproxy/src/client.cpp
plugins/consoles/consoleproxy/src/server.cpp
plugins/consoles/consoleproxy/src/server.h
plugins/consoles/defcons/bmarm/defconsu.def
plugins/consoles/defcons/bwins/defconsu.def
plugins/consoles/defcons/eabi/defconsu.def
plugins/consoles/defcons/group/bld.inf
plugins/consoles/defcons/group/defcons.iby
plugins/consoles/defcons/src/defcons.cpp
plugins/consoles/defcons/src/defcons.mmp
plugins/consoles/docs/consoles.pod
plugins/consoles/guicons/BWINS/guiconsU.DEF
plugins/consoles/guicons/EABI/guiconsU.DEF
plugins/consoles/guicons/data/font_6x10.PNG
plugins/consoles/guicons/data/font_7x13.PNG
plugins/consoles/guicons/doc/guicons_todo.pod
plugins/consoles/guicons/group/bin2lit.pl
plugins/consoles/guicons/group/bld.inf
plugins/consoles/guicons/group/fontchars.txt
plugins/consoles/guicons/group/guicons.iby
plugins/consoles/guicons/group/guicons.mmp
plugins/consoles/guicons/group/guicons_makefont.mk
plugins/consoles/guicons/inc/guicons.h
plugins/consoles/guicons/s60/data/GuiCons.rss
plugins/consoles/guicons/s60/data/GuiCons_reg.rss
plugins/consoles/guicons/s60/data/New_BT_console.txt
plugins/consoles/guicons/s60/data/New_TCP_console.txt
plugins/consoles/guicons/s60/data/New_busdevcomm_console.txt
plugins/consoles/guicons/s60/data/New_serial_console.txt
plugins/consoles/guicons/s60/data/guicons.idf
plugins/consoles/guicons/s60/data/guicons.mif
plugins/consoles/guicons/s60/data/guicons.svg
plugins/consoles/guicons/s60/data/guicons.tiny.svg
plugins/consoles/guicons/s60/data/guiconsbg.png
plugins/consoles/guicons/s60/data/mif.bat
plugins/consoles/guicons/s60/group/bld.inf
plugins/consoles/guicons/s60/group/s60_guicons.iby
plugins/consoles/guicons/s60/group/s60_guicons.mmp
plugins/consoles/guicons/s60/inc/GuiCons.hrh
plugins/consoles/guicons/s60/inc/GuiConsAppUi.h
plugins/consoles/guicons/s60/inc/GuiConsAppView.h
plugins/consoles/guicons/s60/inc/GuiConsApplication.h
plugins/consoles/guicons/s60/inc/GuiConsDocument.h
plugins/consoles/guicons/s60/src/GuiCons.cpp
plugins/consoles/guicons/s60/src/GuiConsAppUi.cpp
plugins/consoles/guicons/s60/src/GuiConsAppView.cpp
plugins/consoles/guicons/s60/src/GuiConsApplication.cpp
plugins/consoles/guicons/s60/src/GuiConsDocument.cpp
plugins/consoles/guicons/src/clientserver.cpp
plugins/consoles/guicons/src/clientserver.h
plugins/consoles/guicons/src/guicons.cpp
plugins/consoles/iocons/bmarm/econs.def
plugins/consoles/iocons/bwins/econs.def
plugins/consoles/iocons/eabi/econs.def
plugins/consoles/iocons/group/bld.inf
plugins/consoles/iocons/group/iocons.mmp
plugins/consoles/iocons/src/co_cli.cpp
plugins/consoles/iocons/src/co_utl.cpp
plugins/consoles/iocons/src/e32twin.h
plugins/consoles/iocons/src/ioconsole.cpp
plugins/consoles/iocons/src/ws_std.h
plugins/consoles/nullcons/BMARM/nullconsU.DEF
plugins/consoles/nullcons/bwins/nullconsu.def
plugins/consoles/nullcons/eabi/nullconsu.def
plugins/consoles/nullcons/group/bld.inf
plugins/consoles/nullcons/group/nullcons.iby
plugins/consoles/nullcons/src/nullcons.cpp
plugins/consoles/nullcons/src/nullcons.mmp
plugins/consoles/rcons/client/bmarm/remote_consoleu.def
plugins/consoles/rcons/client/bwins/remote_consoleu.def
plugins/consoles/rcons/client/data/rcons.idf
plugins/consoles/rcons/client/data/rcons.ini
plugins/consoles/rcons/client/data/rcons.ini.emulator
plugins/consoles/rcons/client/eabi/remote_consoleU.def
plugins/consoles/rcons/client/group/rcons.iby
plugins/consoles/rcons/client/group/remote_console.mmp
plugins/consoles/rcons/client/inc/remote_console.h
plugins/consoles/rcons/client/inc/remote_console_config.h
plugins/consoles/rcons/client/src/remote_console.cpp
plugins/consoles/rcons/client/src/remote_console_config.cpp
plugins/consoles/rcons/documentation/rcons.dll.pod
plugins/consoles/rcons/documentation/rcons.exe.pod
plugins/consoles/rcons/documentation/rcons.pod
plugins/consoles/rcons/group/bld.inf
plugins/consoles/rcons/server/win32/Base.cpp
plugins/consoles/rcons/server/win32/Base.h
plugins/consoles/rcons/server/win32/ClientSocket.cpp
plugins/consoles/rcons/server/win32/ClientSocket.h
plugins/consoles/rcons/server/win32/ConsoleWindow.cpp
plugins/consoles/rcons/server/win32/ConsoleWindow.h
plugins/consoles/rcons/server/win32/DynamicBuffer.cpp
plugins/consoles/rcons/server/win32/DynamicBuffer.h
plugins/consoles/rcons/server/win32/Misc.cpp
plugins/consoles/rcons/server/win32/Misc.h
plugins/consoles/rcons/server/win32/Preferences.cpp
plugins/consoles/rcons/server/win32/Preferences.h
plugins/consoles/rcons/server/win32/RemoteConsole.cpp
plugins/consoles/rcons/server/win32/RemoteConsole.h
plugins/consoles/rcons/server/win32/Server.cpp
plugins/consoles/rcons/server/win32/Server.h
plugins/consoles/rcons/server/win32/ServerSocket.cpp
plugins/consoles/rcons/server/win32/ServerSocket.h
plugins/consoles/rcons/server/win32/Socket.cpp
plugins/consoles/rcons/server/win32/Socket.h
plugins/consoles/rcons/server/win32/SocketCommandHandler.cpp
plugins/consoles/rcons/server/win32/SocketCommandHandler.h
plugins/consoles/rcons/server/win32/StdAfx.cpp
plugins/consoles/rcons/server/win32/StdAfx.h
plugins/consoles/rcons/server/win32/TextBuffer.cpp
plugins/consoles/rcons/server/win32/TextBuffer.h
plugins/consoles/rcons/server/win32/TextView.cpp
plugins/consoles/rcons/server/win32/TextView.h
plugins/consoles/rcons/server/win32/Window.cpp
plugins/consoles/rcons/server/win32/Window.h
plugins/consoles/rcons/server/win32/console_host.aps
plugins/consoles/rcons/server/win32/console_host.clw
plugins/consoles/rcons/server/win32/console_host.cpp
plugins/consoles/rcons/server/win32/console_host.dsp
plugins/consoles/rcons/server/win32/console_host.dsw
plugins/consoles/rcons/server/win32/console_host.h
plugins/consoles/rcons/server/win32/console_host.ico
plugins/consoles/rcons/server/win32/console_host.ncb
plugins/consoles/rcons/server/win32/console_host.opt
plugins/consoles/rcons/server/win32/console_host.plg
plugins/consoles/rcons/server/win32/console_host.rc
plugins/consoles/rcons/server/win32/rcons.exe
plugins/consoles/rcons/server/win32/resource.h
plugins/consoles/rcons/server/win32/small.ico
plugins/consoles/vt100cons/BMARM/vt100U.def
plugins/consoles/vt100cons/BMARM/vt100consU.def
plugins/consoles/vt100cons/bwins/vt100btconsu.def
plugins/consoles/vt100cons/bwins/vt100consu.def
plugins/consoles/vt100cons/bwins/vt100serialu.def
plugins/consoles/vt100cons/bwins/vt100u.def
plugins/consoles/vt100cons/bwins/vt100usbconsu.def
plugins/consoles/vt100cons/doc/vt100cons.pod
plugins/consoles/vt100cons/eabi/vt100btconsu.def
plugins/consoles/vt100cons/eabi/vt100consu.def
plugins/consoles/vt100cons/eabi/vt100serialu.def
plugins/consoles/vt100cons/eabi/vt100u.def
plugins/consoles/vt100cons/eabi/vt100usbconsu.def
plugins/consoles/vt100cons/group/bld.inf
plugins/consoles/vt100cons/group/vt100.iby
plugins/consoles/vt100cons/group/vt100.mmp
plugins/consoles/vt100cons/group/vt100btcons.mmp
plugins/consoles/vt100cons/group/vt100busdevcons.mmp
plugins/consoles/vt100cons/group/vt100cons.iby
plugins/consoles/vt100cons/group/vt100cons.mmp
plugins/consoles/vt100cons/group/vt100debugport.mmp
plugins/consoles/vt100cons/group/vt100serial.mmp
plugins/consoles/vt100cons/group/vt100tcpcons.mmp
plugins/consoles/vt100cons/group/vt100usbcons.mmp
plugins/consoles/vt100cons/inc/vtc_base.h
plugins/consoles/vt100cons/inc/vtc_controller.h
plugins/consoles/vt100cons/inc/vtc_serial.h
plugins/consoles/vt100cons/src/bluetooth/vtc_bt.cpp
plugins/consoles/vt100cons/src/bluetooth/vtc_bt.h
plugins/consoles/vt100cons/src/serial/vtc_main.cpp
plugins/consoles/vt100cons/src/serial/vtc_serial.cpp
plugins/consoles/vt100cons/src/tcp/vtc_tcp.cpp
plugins/consoles/vt100cons/src/usb/vtc_usb.cpp
plugins/consoles/vt100cons/src/usb/vtc_usb.h
plugins/consoles/vt100cons/src/vt100/vt100.idf
plugins/consoles/vt100cons/src/vt100/vt100.ini
plugins/consoles/vt100cons/src/vt100/vt100.ini.noautodetect
plugins/consoles/vt100cons/src/vt100/vtc_base.cpp
plugins/consoles/vt100cons/src/vt100/vtc_controller.cpp
plugins/consoles/vt100cons/src/vt100/vtc_cursor_tracker.cpp
plugins/consoles/vt100cons/src/vt100/vtc_cursor_tracker.h
plugins/consoles/vt100cons/src/vtc_busdevcons.cpp
plugins/consoles/vt100cons/src/vtc_debugport.cpp
plugins/consoles/win32cons/BWINS/win32consU.def
plugins/consoles/win32cons/group/bld.inf
plugins/consoles/win32cons/group/os_ver.mk
plugins/consoles/win32cons/group/os_version_h.PL
plugins/consoles/win32cons/group/win32cons.mmp
plugins/consoles/win32cons/src/console.cpp
plugins/consoles/win32cons/src/console.h
plugins/consoles/win32cons/src/keymappings.cpp
plugins/consoles/win32cons/src/keymappings.h
plugins/consoles/win32cons/src/win32cons.cpp
plugins/consoles/win32cons/src/win32cons.h
plugins/networking/nullnif/BMARM/nullnifU.DEF
plugins/networking/nullnif/bwins/nullnifu.def
plugins/networking/nullnif/eabi/nullnifu.def
plugins/networking/nullnif/group/bld.inf
plugins/networking/nullnif/group/nullnif.mmp
plugins/networking/nullnif/src/nullnif.cpp
plugins/networking/tcpcsy/bwins/tcpcsyu.def
plugins/networking/tcpcsy/doc/tcpcsy.pod
plugins/networking/tcpcsy/eabi/tcpcsyu.def
plugins/networking/tcpcsy/group/bld.inf
plugins/networking/tcpcsy/src/config.cpp
plugins/networking/tcpcsy/src/config.h
plugins/networking/tcpcsy/src/connector.cpp
plugins/networking/tcpcsy/src/connector.h
plugins/networking/tcpcsy/src/listener.cpp
plugins/networking/tcpcsy/src/listener.h
plugins/networking/tcpcsy/src/panic.h
plugins/networking/tcpcsy/src/reader.cpp
plugins/networking/tcpcsy/src/reader.h
plugins/networking/tcpcsy/src/socketuser.cpp
plugins/networking/tcpcsy/src/socketuser.h
plugins/networking/tcpcsy/src/tcpcsy.cpp
plugins/networking/tcpcsy/src/tcpcsy.h
plugins/networking/tcpcsy/src/tcpcsy.mmp
plugins/networking/tcpcsy/src/tcpcsylog.h
plugins/networking/tcpcsy/src/writer.cpp
plugins/networking/tcpcsy/src/writer.h
plugins/networking/tcpcsy/test/listen.pl
plugins/networking/winsockprt/bwins/winsocku.def
plugins/networking/winsockprt/data/dwinsockprt.esk
plugins/networking/winsockprt/data/winsockprt.esk
plugins/networking/winsockprt/docs/winsockprt.pod
plugins/networking/winsockprt/group/bld.inf
plugins/networking/winsockprt/group/release.src
plugins/networking/winsockprt/group/winsockprt.mmp
plugins/networking/winsockprt/inc/_windows.h
plugins/networking/winsockprt/inc/winsockprt.h
plugins/networking/winsockprt/inc/wsp_active.h
plugins/networking/winsockprt/inc/wsp_def.h
plugins/networking/winsockprt/inc/wsp_factory.h
plugins/networking/winsockprt/inc/wsp_log.h
plugins/networking/winsockprt/inc/wsp_panic.h
plugins/networking/winsockprt/inc/wsp_protocol.h
plugins/networking/winsockprt/inc/wsp_protocolfamily.h
plugins/networking/winsockprt/inc/wsp_provider.h
plugins/networking/winsockprt/inc/wsp_request.h
plugins/networking/winsockprt/inc/wsp_resolver.h
plugins/networking/winsockprt/inc/wsp_scheduler.h
plugins/networking/winsockprt/inc/wsp_session.h
plugins/networking/winsockprt/inc/wsp_socket.h
plugins/networking/winsockprt/inc/wsp_subsession.h
plugins/networking/winsockprt/src/wsp_active.cpp
plugins/networking/winsockprt/src/wsp_factory.cpp
plugins/networking/winsockprt/src/wsp_log.cpp
plugins/networking/winsockprt/src/wsp_misc.cpp
plugins/networking/winsockprt/src/wsp_protocol.cpp
plugins/networking/winsockprt/src/wsp_protocolfamily.cpp
plugins/networking/winsockprt/src/wsp_provider.cpp
plugins/networking/winsockprt/src/wsp_request.cpp
plugins/networking/winsockprt/src/wsp_resolver.cpp
plugins/networking/winsockprt/src/wsp_scheduler.cpp
plugins/networking/winsockprt/src/wsp_session.cpp
plugins/networking/winsockprt/src/wsp_socket.cpp
plugins/networking/winsockprt/src/wsp_subsession.cpp
plugins/networking/winsockprt/tools/wsp
plugins/networking/winsockprt/tools/wsp.bat
plugins/networking/winsockprt/tsrc/t_wsp.cpp
plugins/networking/winsockprt/tsrc/t_wsp.mmp
tools/CommandInfoFile.pm
tools/createsrc
tools/createsrc-templates/AsConsole.txt
tools/createsrc-templates/AsConsole/group/SkeletonTemplate.mmp
tools/createsrc-templates/AsConsole/group/bld.inf
tools/createsrc-templates/AsConsole/group/sis/SkeletonTemplate_armv5.pkg
tools/createsrc-templates/AsConsole/group/sis/SkeletonTemplate_gcce.pkg
tools/createsrc-templates/AsConsole/inc/SkeletonTemplate.h
tools/createsrc-templates/AsConsole/inc/SkeletonTemplateUid.h
tools/createsrc-templates/AsConsole/rsc/SkeletonTemplate_loc.rss
tools/createsrc-templates/AsConsole/rsc/SkeletonTemplate_reg.rss
tools/createsrc-templates/AsConsole/src/SkeletonTemplate.cpp
tools/createsrc-templates/FshellCmd.txt
tools/createsrc-templates/FshellCmd/SkeletonTemplate.cif
tools/createsrc-templates/FshellCmd/SkeletonTemplate.cpp
tools/createsrc-templates/FshellCmd/SkeletonTemplate.mmp
tools/createsrc-templates/FshellCmd/bld.inf
tools/createsrc-templates/NonCifFshellCmd.txt
tools/createsrc-templates/NonCifFshellCmd/SkeletonTemplate.cpp
tools/createsrc-templates/NonCifFshellCmd/SkeletonTemplate.mmp
tools/createsrc.bat
tools/export_templates.mk
tools/exportall
tools/exportall.bat
tools/fsh-builddocs
tools/fsh-builddocs.bat
tools/fsh-buildsis
tools/fsh-buildsis.bat
tools/fshell_copyright.pl
tools/fshu.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,60 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "..\..\documentation\bld.inf"
+#include "..\..\commands\group\bld.inf"
+#include "..\..\core\group\bld.inf"
+#include "..\..\libraries\extrabtrace\group\bld.inf"
+#include "..\..\libraries\btrace_parser\group\bld.inf"
+#include "..\..\libraries\btserial\group\bld.inf"
+#include "..\..\libraries\clogger\group\bld.inf"
+#include "..\..\libraries\iosrv\group\bld.inf"
+#include "..\..\libraries\lineeditor\group\bld.inf"
+#include "..\..\libraries\ltkutils\group\bld.inf"
+#include "..\..\libraries\memoryaccess\bld.inf"
+#include "..\..\libraries\qr3\group\bld.inf"
+#ifdef FSHELL_SPCRE_SUPPORT
+#include "..\..\libraries\spcre\group\bld.inf"
+#endif
+#include "..\..\plugins\consoles\common\bld.inf"
+#include "..\..\plugins\consoles\consoleproxy\group\bld.inf"
+#include "..\..\plugins\consoles\defcons\group\bld.inf"
+#include "..\..\plugins\consoles\guicons\group\bld.inf"
+#include "..\..\plugins\consoles\iocons\group\bld.inf"
+#include "..\..\plugins\consoles\nullcons\group\bld.inf"
+#include "..\..\plugins\consoles\rcons\group\bld.inf"
+#include "..\..\plugins\consoles\vt100cons\group\bld.inf"
+#include "..\..\plugins\consoles\win32cons\group\bld.inf"
+#include "..\..\plugins\networking\nullnif\group\bld.inf"
+#include "..\..\plugins\networking\tcpcsy\group\bld.inf"
+#include "..\..\plugins\networking\winsockprt\group\bld.inf"
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(fshell.iby)
+FSHELL_ROM_INCLUDE(fsh_config.iby)
+FSHELL_ROM_INCLUDE(fsh_rombuild_defs.iby)
+FSHELL_ROM_INCLUDE(fsh_makesis_defs.iby)
+FSHELL_ROM_INCLUDE(fsh_manifest_defs.iby)
+
+.\common.mmh              fshell/common.mmh
+.\fsh_system_include.mmh  fshell/fsh_system_include.mmh
+
+// We have to export common.mmh (and platform.mmh) to rom\include as well so IBYs can access them
+FSHELL_ROM_INCLUDE2(common.mmh, fshell\common.mmh)
+
+..\..\tools\createsrc		\epoc32\tools\createsrc
+..\..\tools\createsrc.bat	\epoc32\tools\createsrc.bat
+..\..\tools\exportall		\epoc32\tools\exportall
+
+PRJ_MMPFILES
+
+//TODO figure out why SBS doesn't like this...
+//gnumakefile ..\..\tools\export_templates.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/common.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,657 @@
+// common.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#define FSHELL_COMMON_MMH
+
+// For documentation on these macros, see \epoc32\fshell\documentation\internal\common_mmh.html
+
+#ifndef FSHELL_PLATFORM_MMH
+#include <fshell/platform.mmh>
+#endif
+
+// Mapping negative defines to the positive ones used from here on:
+#ifndef FSHELL_NO_BTRACE_SUPPORT
+#define    FSHELL_BTRACE_SUPPORT
+#endif
+#ifndef FSHELL_NO_PIPS_SUPPORT
+#define    FSHELL_PIPS_SUPPORT
+#endif
+#ifndef FSHELL_NO_PATCHABLE_CONSTANTS_SUPPORT
+#define    FSHELL_PATCHABLE_CONSTANTS_SUPPORT
+#endif
+#ifndef FSHELL_NO_DYNAMICDFC_SUPPORT
+#define   FSHELL_DYNAMICDFC_SUPPORT
+#endif
+#ifndef FSHELL_NO_AUDIO_SUPPORT
+#define    FSHELL_AUDIO_SUPPORT
+#endif
+#ifndef FSHELL_NO_COMMS_SUPPORT
+#define    FSHELL_COMMS_SUPPORT
+#endif
+#if !defined(FSHELL_NO_BLUETOOTH_SUPPORT) && defined (FSHELL_COMMS_SUPPORT)
+#define FSHELL_BLUETOOTH_SUPPORT
+#endif
+#ifndef FSHELL_NO_TELEPHONY_SUPPORT
+#define    FSHELL_TELEPHONY_SUPPORT
+#endif
+#ifndef FSHELL_NO_APPARC_SUPPORT
+#define    FSHELL_APPARC_SUPPORT
+#endif
+#ifndef FSHELL_NO_EZLIB_SUPPORT
+#define    FSHELL_EZLIB_SUPPORT
+#endif
+#ifndef FSHELL_NO_WSERV_SUPPORT
+#define    FSHELL_WSERV_SUPPORT
+#endif
+#ifndef FSHELL_NO_WSERV2_SUPPORT
+#define    FSHELL_WSERV2_SUPPORT
+#endif
+#ifndef FSHELL_NO_RAMDEFRAG_SUPPORT
+#define    FSHELL_RAMDEFRAG_SUPPORT
+#endif
+#ifndef FSHELL_NO_SAMPLINGPROFILER_SUPPORT
+#define    FSHELL_SAMPLINGPROFILER_SUPPORT
+#endif
+#ifndef FSHELL_NO_COPYTOSHADOWMEMORY_SUPPORT
+#define    FSHELL_COPYTOSHADOWMEMORY_SUPPORT
+#endif
+#ifndef FSHELL_NO_LBS_SUPPORT
+#define    FSHELL_LBS_SUPPORT
+#endif
+#ifndef FSHELL_NO_SQL_SUPPORT
+#define    FSHELL_SQL_SUPPORT
+#endif
+#if !defined(FSHELL_NO_EGL_SUPPORT) && defined(FSHELL_WSERV_SUPPORT)
+#define    FSHELL_EGL_SUPPORT
+#endif
+#if !defined(FSHELL_NO_OPENVG_SUPPORT) && defined(FSHELL_WSERV_SUPPORT)
+#define    FSHELL_OPENVG_SUPPORT
+#endif
+#ifndef FSHELL_NO_DOBJECTIX_SUPPORT
+#define FSHELL_DOBJECTIX_SUPPORT
+#endif
+#ifndef FSHELL_NO_CRYPTO_SUPPORT
+#define FSHELL_CRYPTO_SUPPORT
+#endif
+#ifndef FSHELL_NO_SHA2_SUPPORT
+#define FSHELL_SHA2_SUPPORT
+#endif
+#ifndef FSHELL_NO_MD4_SUPPORT
+#define FSHELL_MD4_SUPPORT
+#endif
+
+//
+// PlatSec.
+//
+
+#ifdef FSHELL_CAP_ALL
+
+#define FSHELL_CAP_MMP_MAX all
+
+// System Capabilities
+#define FSHELL_CAP_ALLFILES
+#define FSHELL_CAP_COMMDD
+#define FSHELL_CAP_DISKADMIN
+#define FSHELL_CAP_DRM
+#define FSHELL_CAP_MULTIMEDIADD
+#define FSHELL_CAP_NETWORKCONTROL
+#define FSHELL_CAP_POWERMGMT
+#define FSHELL_CAP_PROTSERV
+#define FSHELL_CAP_READDEVICEDATA
+#define FSHELL_CAP_SURROUNDINGSDD
+#define FSHELL_CAP_SWEVENT
+#define FSHELL_CAP_TRUSTEDUI
+#define FSHELL_CAP_WRITEDEVICEDATA
+
+// User Capabilities
+#define FSHELL_CAP_LOCALSERVICES
+#define FSHELL_CAP_LOCATION
+#define FSHELL_CAP_NETWORKSERVICES
+#define FSHELL_CAP_READUSERDATA
+#define FSHELL_CAP_USERENVIRONMENT
+#define FSHELL_CAP_WRITEUSERDATA
+
+#endif // FSHELL_CAP_ALL
+
+#define FSHELL_CAP_MMP_NORMAL FSHELL_CAP_MMP_MAX -tcb
+
+// Yuk the __GNUC__ checks are needed to support SBS which changed the CPP version that parses bld.infs and mmps...
+#ifndef FSHELL_ROM_INCLUDE
+#if __GNUC__ >= 3
+#define FSHELL_ROM_INCLUDE(_FILE_) _FILE_ /epoc32/rom/include/_FILE_
+#else
+#define FSHELL_ROM_INCLUDE(_FILE_) _FILE_ \epoc32\rom\include\ ## _FILE_
+#endif
+#endif
+#ifndef FSHELL_ROM_INCLUDE2
+#if __GNUC__ >= 3
+#define FSHELL_ROM_INCLUDE2(_SRC_FILE_, _DST_FILE_) _SRC_FILE_ /epoc32/rom/include/_DST_FILE_
+#else
+#define FSHELL_ROM_INCLUDE2(_SRC_FILE_, _DST_FILE_) _SRC_FILE_ \epoc32\rom\include\ ## _DST_FILE_
+#endif
+#endif
+
+
+//
+// memoryaccess.
+//
+
+#ifdef FSHELL_CAP_ALL
+#define FSHELL_MEMORY_ACCESS_SUPPORT
+#endif
+
+//
+// extrabtrace
+//
+
+#ifdef FSHELL_CAP_ALL
+#define FSHELL_EXTRABTRACE_SUPPORT
+#endif
+
+#if !defined(FSHELL_TRACE_SUPPORT) && defined(FSHELL_BTRACE_SUPPORT)
+// FSHELL_TRACE_SUPPORT tells you that the BTraceX() functions are available, either via atrace or btrace,
+// for the situations where you don't care which it is
+#define FSHELL_TRACE_SUPPORT
+#endif
+
+// The FSHELL_TRACE_xyz macros must appear before any other systeminclude/#include/library statements in your MMP.
+#ifndef FSHELL_TRACE_LIBRARY
+#define FSHELL_D32BTRACE_HEADER <d32btrace.h>
+#define FSHELL_TRACE_LIBRARY library btracec.lib
+#define FSHELL_TRACE_CONTROL_LIBRARY library extrabtrace.lib btracec.lib
+#define FSHELL_TRACE_KERNEL_INCLUDE(pathtoroot)
+#endif
+
+//
+// fshell.
+//
+#ifdef FSHELL_WSERV_SUPPORT // Close enough
+#define FSHELL_CORE_SUPPORT_SWI
+#endif
+
+#ifdef FSHELL_PIPS_SUPPORT
+#define FSHELL_CORE_SUPPORT_PIPSRUN
+#endif
+
+#ifdef FSHELL_PATCHABLE_CONSTANTS_SUPPORT
+#define FSHELL_CORE_SUPPORT_PATCHDATA
+#endif
+
+#ifdef FSHELL_BTRACE_SUPPORT
+#define FSHELL_CORE_SUPPORT_BTRACE
+#endif
+
+#ifdef FSHELL_TRACE_SUPPORT
+#define FSHELL_CORE_SUPPORT_BTRACEOUT
+#endif
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+#define FSHELL_CORE_SUPPORT_GETSTACK
+#define FSHELL_CORE_SUPPORT_CHUNKINFO
+#define FSHELL_CORE_SUPPORT_SVRINFO
+#define FSHELL_CORE_SUPPORT_FDB
+#ifndef FSHELL_NO_SUPPORT_BUILTIN_REBOOT
+#define FSHELL_CORE_SUPPORT_BUILTIN_REBOOT
+#endif
+#endif
+
+#ifdef FSHELL_CAP_ALL
+#define FSHELL_CORE_SUPPORT_SUDO
+#define FSHELL_CORE_SUPPORT_CHKDEPS
+#define FSHELL_CORE_SUPPORT_SIS_ECLIPSE
+#define FSHELL_CORE_SUPPORT_LOCALDRIVE
+#define FSHELL_CORE_SUPPORT_TOP
+#endif
+
+#if defined(FSHELL_MEMORY_ACCESS_SUPPORT) && defined(FSHELL_CAP_ALL) && defined(FSHELL_TRACE_SUPPORT)
+#define FSHELL_CORE_SUPPORT_MEMSAMPLER
+#endif
+
+#if defined(FSHELL_CAP_READUSERDATA) && defined(FSHELL_CAP_WRITEUSERDATA) && defined(FSHELL_APPARC_SUPPORT)
+#define FSHELL_CORE_SUPPORT_FCONTACTS
+#ifndef FSHELL_GCC298_SUPPORT // I can't get it to build with gcc2.9...
+#define FSHELL_CORE_SUPPORT_FCALENDAR
+#endif
+#endif
+
+#if defined(FSHELL_CAP_PROTSERV) && defined(FSHELL_APPARC_SUPPORT)
+#define FSHELL_CORE_SUPPORT_SHEBANG
+#endif
+
+#ifdef FSHELL_COMMS_SUPPORT
+// todo: find out what capabilities ping actually requires
+#define FSHELL_CORE_SUPPORT_PING
+#define FSHELL_CORE_SUPPORT_RCOMM
+#define FSHELL_CORE_SUPPORT_RCONN
+#define FSHELL_CORE_SUPPORT_IAP
+#define FSHELL_CORE_SUPPORT_BTSERVICES
+#define FSHELL_CORE_SUPPORT_RSOCKET
+#define FSHELL_CORE_SUPPORT_USB
+#endif
+
+#ifdef FSHELL_PLATFORM_UIQ
+#define FSHELL_CORE_SUPPORT_MROUTER
+#endif
+
+#ifdef FSHELL_EXTRABTRACE_SUPPORT
+#define FSHELL_CORE_SUPPORT_UPROFILER
+#endif
+
+#ifdef FSHELL_APPARC_SUPPORT
+#define FSHELL_CORE_SUPPORT_LISTAPPS
+#define FSHELL_CORE_SUPPORT_SHUTAPP
+#define FSHELL_CORE_SUPPORT_OPENDOC
+#endif
+
+#ifdef FSHELL_WSERV_SUPPORT
+#define FSHELL_CORE_SUPPORT_GRABSCREEN
+#define FSHELL_CORE_SUPPORT_FOCUS
+#define FSHELL_CORE_SUPPORT_SWITCHVIEW
+#define FSHELL_CORE_SUPPORT_ACTIVEVIEW
+#define FSHELL_CORE_SUPPORT_WSLOG
+#endif
+
+#ifdef FSHELL_AUDIO_SUPPORT
+#define FSHELL_CORE_SUPPORT_PLAY
+#endif
+
+#ifdef FSHELL_COMMS_SUPPORT
+#define FSHELL_CORE_SUPPORT_WGET
+#endif
+
+#ifdef FSHELL_EZLIB_SUPPORT
+#define FSHELL_CORE_SUPPORT_FZIP
+#endif
+
+#if defined(FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
+#define FSHELL_CORE_SUPPORT_SYSINFO_WLAN
+#define FSHELL_CORE_SUPPORT_SECURE_TIME
+#endif
+
+#if defined(FSHELL_WSERV_SUPPORT) && defined(FSHELL_CAP_LOCATION) && defined(FSHELL_CAP_READUSERDATA) && defined(FSHELL_CAP_READDEVICEDATA) && defined(FSHELL_CAP_WRITEDEVICEDATA)
+#define FSHELL_CORE_SUPPORT_SCREENMODE
+#endif
+
+#if defined(FSHELL_MEMORY_ACCESS_SUPPORT)
+#define FSHELL_CORE_SUPPORT_HEAPTRACE
+#endif
+
+#ifdef FSHELL_CAP_SWEVENT
+#define FSHELL_CORE_SUPPORT_PASTE
+#endif
+
+#if defined(FSHELL_RAMDEFRAG_SUPPORT) && defined(FSHELL_MEMORY_ACCESS_SUPPORT)
+#define FSHELL_CORE_SUPPORT_RAMDEFRAG
+#endif
+
+#if defined(FSHELL_TELEPHONY_SUPPORT) && defined(FSHELL_CAP_READUSERDATA) && defined(FSHELL_CAP_READDEVICEDATA) && defined(FSHELL_CAP_WRITEUSERDATA)
+#define FSHELL_CORE_SUPPORT_ICC
+#endif
+
+#ifdef FSHELL_WSERV_SUPPORT
+#define FSHELL_CORE_SUPPORT_GENBMP
+#define FSHELL_CORE_SUPPORT_TFINFO
+#endif
+
+#if defined(FSHELL_TELEPHONY_SUPPORT) && defined(FSHELL_CAP_READDEVICEDATA)
+#define FSHELL_CORE_SUPPORT_NITZ
+#endif
+
+#if defined(FSHELL_LBS_SUPPORT) && defined(FSHELL_CAP_LOCATION) && defined(FSHELL_CAP_WRITEDEVICEDATA) && defined(FSHELL_CAP_READDEVICEDATA) && defined(FSHELL_CAP_READUSERDATA)
+#define FSHELL_CORE_SUPPORT_LBS
+#endif
+
+#if defined(FSHELL_SQL_SUPPORT) && defined(FSHELL_CAP_WRITEDEVICEDATA) && defined(FSHELL_CAP_READDEVICEDATA) && defined(FSHELL_CAP_READUSERDATA)
+#define FSHELL_CORE_SUPPORT_SQL
+#endif
+
+#if defined(FSHELL_EGL_SUPPORT) || defined(FSHELL_OPENVG_SUPPORT)
+#define FSHELL_CORE_SUPPORT_GLINFO
+#endif
+
+#if defined(FSHELL_CRYPTO_SUPPORT)
+#define FSHELL_CORE_SUPPORT_HASH
+#endif
+
+#ifdef FSHELL_DYNAMICSTARTUP_SUPPORT
+#define FSHELL_CORE_SUPPORT_STARTUP
+#endif
+
+#ifndef FSHELL_NO_SUPPORT_BUILTIN_VARIANT
+#define FSHELL_CORE_SUPPORT_BUILTIN_VARIANT
+#endif
+
+#ifdef FSHELL_TELEPHONY_SUPPORT
+#define FSHELL_CORE_SUPPORT_SMS
+#endif
+
+
+//
+// qr3.
+//
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+#define FSHELL_QR3_SUPPORT
+
+#ifdef FSHELL_TRACE_SUPPORT
+#define FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR
+#endif
+
+#endif // FSHELL_MEMORY_ACCESS_SUPPORT
+
+
+//
+// clogger.
+//
+
+#ifdef FSHELL_CAP_ALL
+#define FSHELL_CLOGGER_SUPPORT_DEBUG_ROUTER
+#endif
+
+
+//
+// tcpcsy.
+//
+
+#if defined(FSHELL_CAP_COMMDD) && defined(FSHELL_CAP_POWERMGMT) && defined(FSHELL_CAP_READDEVICEDATA) && defined(FSHELL_CAP_WRITEDEVICEDATA) && defined(FSHELL_CAP_TRUSTEDUI) && defined(FSHELL_CAP_PROTSERV) && defined(FSHELL_CAP_NETWORKCONTROL) && defined(FSHELL_CAP_NETWORKSERVICES) && defined(FSHELL_CAP_LOCALSERVICES) && defined(FSHELL_CAP_READUSERDATA) && defined(FSHELL_CAP_WRITEUSERDATA) && defined(FSHELL_COMMS_SUPPORT)
+#define FSHELL_TCPCSY_SUPPORT
+#endif
+
+
+//
+// vt100.
+//
+
+#define FSHELL_VT100_WORK_AROUND_TERATERM_CURSOR_BUG
+
+
+//
+// Misc.
+//
+
+#if defined(FSHELL_WSERV_SUPPORT) && defined(FSHELL_NOT_BUILT_ALONE)
+#define FSHELL_AUTOMETRIC_SUPPORT_EIKPLUGIN
+#endif
+
+
+//
+// UIDs.
+//
+
+#ifdef FSHELL_PROTECTED_UIDS
+
+#define FSHELL_UID_ACTIVEVIEW                 0x102866D2
+#define FSHELL_UID_BACKUP                     0x10285E0D
+#define FSHELL_UID_BACKUP_CHILD               0x10285E0E
+#define FSHELL_UID_SMS                        0x102864BE
+#define FSHELL_UID_BTRACE_PARSER              0x10285E09
+#define FSHELL_UID_TINTERVAL                  0x10285E0A
+#define FSHELL_UID_BTINCOMINGSERIAL           0x10285E04
+#define FSHELL_UID_BTSERIALTEST               0x10285e14
+#define FSHELL_UID_CLOGGERDEBUGROUTER         0x102831C7
+#define FSHELL_UID_COMSDBGUTIL_CLOGGER_STUB   0x10004d0a
+#define FSHELL_UID_FLOGGER_CLOGGER_STUB       0x102866D3
+#define FSHELL_UID_CLOGGERBUFFERED            0x102831CE
+#define FSHELL_UID_CLOGGER                    0x10272EFE
+#define FSHELL_UID_CLOGGERSERVER              0x10272EFD
+#define FSHELL_UID_TCLOG                      0x10272F03
+#define FSHELL_UID_BTRACE                     0x102835B3
+#define FSHELL_UID_CAT                        0x102835B4
+#define FSHELL_UID_CENREP                     0x102831C9
+#define FSHELL_UID_CHKDEPS                    0x10285A17
+#define FSHELL_UID_CHKDRIFT                   0x102836dc
+#define FSHELL_UID_CLIPBOARD                  0x10285BA3
+#define FSHELL_UID_CLOGGERCONFIG              0x102831CA
+#define FSHELL_UID_DRVINFO                    0x102836d3
+#define FSHELL_UID_FOCUS                      0x102836e2
+#define FSHELL_UID_GETHEAP                    0x102835B8
+#define FSHELL_UID_GETSTACK                   0x102835BD
+#define FSHELL_UID_GRABSCREEN                 0x102836d5
+#define FSHELL_UID_LEAK                       0x102835BB
+#define FSHELL_UID_LISTAPPS                   0x102835B9
+#define FSHELL_UID_LOAD                       0x102836e1
+#define FSHELL_UID_MEMSAMPLER                 0x102836d6
+#define FSHELL_UID_MROUTER                    0x102836d2
+#define FSHELL_UID_OPENDOC                    0x102836d0
+#define FSHELL_UID_PATCHDATA                  0x102836de
+#define FSHELL_UID_PLAY                       0x10285C6D
+#define FSHELL_UID_PUBSUB                     0x102831CB
+#define FSHELL_UID_RCOMM                      0x102836d4
+#define FSHELL_UID_RENDEZVOUS                 0x10285A15
+#define FSHELL_UID_RESTORE                    0x10285E0F
+#define FSHELL_UID_SHUTAPP                    0x102835BA
+#define FSHELL_UID_SPINLOCK                   0x10285BA5
+#define FSHELL_UID_SUDO                       0x10285BA0
+#define FSHELL_UID_SWI                        0x102864CE
+#define FSHELL_UID_SWITCHVIEW                 0x102866D1
+#define FSHELL_UID_QOTD                       0x10286b42
+#define FSHELL_UID_TAIL                       0x102835B5
+#define FSHELL_UID_XMODEM                     0x102836d9
+#define FSHELL_UID_MEMSAMPLERDD               0x102866D4
+#define FSHELL_UID_FSHELL_INST                0x102836d1
+#define FSHELL_UID_FSHELL_UINST               0x102835C0
+#define FSHELL_UID_IOSRV                      0x10282343
+#define FSHELL_UID_SBAPP                      0x102836cf
+#define FSHELL_UID_SBREC                      0x102835bf
+#define FSHELL_UID_FSHELL                     0x10282D94
+#define FSHELL_UID_LINEEDITOR                 0x10285C66
+#define FSHELL_UID_MEMORYACCESS               0x10273948
+#define FSHELL_UID_VARIANT                    0x102864CF
+#define FSHELL_UID_QR3SANDBOX                 0x102831C6
+#define FSHELL_UID_LOGGINGALLOCATOR           0x102831C8
+#define FSHELL_UID_KERNINFO                   0x10285BA1
+#define FSHELL_UID_QR3                        0x10282DAB
+#define FSHELL_UID_SETCRITICAL                0x10285BA4
+#define FSHELL_UID_SETPRIORITY                0x10285BA2
+#define FSHELL_UID_TOPSAMPLE                  0x10282DA9
+#define FSHELL_UID_TCPCSY                     0x102866D8
+#define FSHELL_UID_VT100                      0x102836db
+#define FSHELL_UID_WINSOCKPRT                 0x102866D9
+#define FSHELL_UID_IAP                        0x102864CB
+#define FSHELL_UID_WGET                       0x102864CC
+#define FSHELL_UID_FZIP                       0x102864CA
+#define FSHELL_UID_SIS                        0x102866DA
+#define FSHELL_UID_TOP                        0x102869FE
+#define FSHELL_UID_FCONTACTS                  0x102869FF
+#define FSHELL_UID_RUNLIB                     0x102864C6
+#define FSHELL_UID_FED                        0x10286A00
+#define FSHELL_UID_RCONN                      0x102866DD
+#define FSHELL_UID_FSHELL_LAUNCH_TCP          0x102866E0
+#define FSHELL_UID_FSHELL_LAUNCH_BT           0x102866E1
+#define FSHELL_UID_LTKUTILS                   0x10286A06
+#define FSHELL_UID_SNAKE                      0x10287022
+#define FSHELL_UID_PING                       0x10286F52
+#define FSHELL_UID_FCALENDAR                  0x10286F53
+#define FSHELL_UID_FIND                       0x10286F54
+#define FSHELL_UID_UPROFILER                  0x10286F55
+#define FSHELL_UID_BTRACEOUT                  0x10286F56
+#define FSHELL_UID_LTKUTILS_TCB               0x10286F57
+#define FSHELL_UID_BTSERVICES                 0x10286F58
+#define FSHELL_UID_S60_GUICONS                0x10286b46
+#define FSHELL_UID_SYSINFO                    0x10286B6B
+#define FSHELL_UID_CONSOLEPROXY               0x10287198
+#define FSHELL_UID_UIDINFO                    0x10286F5A
+#define FSHELL_UID_REZ                        0x10286A01
+#define FSHELL_UID_WSLOG                      0x10286A05
+#define FSHELL_UID_SCREENMODE                 0x10286B6C
+#define FSHELL_UID_HEAPTRACE                  0x10286F5C
+#define FSHELL_UID_INIEDIT                    0x1028719b
+#define FSHELL_UID_NULLNIF                    0x10286B6D
+#define FSHELL_UID_PASTE                      0x10286B6F
+#define FSHELL_UID_FSHELL_LAUNCH_USB          0x10286B70
+#define FSHELL_UID_FSHELL_LAUNCH_RCONS        0x10286B71
+#define FSHELL_UID_RAMDEFRAG                  0x10286F5D
+#define FSHELL_UID_ICC                        0x10286B73
+#define FSHELL_UID_VTCSERIAL                  0x1028719D
+#define FSHELL_UID_ECOM                       0x10286F60
+#define FSHELL_UID_RSOCKET                    0x10286B74
+#define FSHELL_UID_GENBMP                     0x10286B75
+#define FSHELL_UID_TFINFO                     0x10286B76
+#define FSHELL_UID_FDB                        0x10286F61
+#define FSHELL_UID_NITZ                       0x10286B77
+#define FSHELL_UID_HAL                        0x10286B78
+#define FSHELL_UID_POINTER                    0x10286F62
+#define FSHELL_UID_LBS                        0x10286B79
+#define FSHELL_UID_SQL                        0x10286B7A
+#define FSHELL_UID_SQLSRV                     0x102835BC
+#define FSHELL_UID_GLINFO                     0x10286B7B
+#define FSHELL_UID_FSHELL_LAUNCH_SERIAL       0x10286F63
+#define FSHELL_UID_HASH                       0x10286B7C
+#define FSHELL_UID_SPCRE                      0x10286F66
+#define FSHELL_UID_LIBPCRE                    0x10286F67
+#define FSHELL_UID_GREP                       0x10286F68
+#define FSHELL_UID_STARTUP                    0x10286F69
+#define FSHELL_UID_FFSTRACERPLUGIN            0x10286F6B
+#define FSHELL_UID_FFSTRACE                   0x10286F6C
+#define FSHELL_UID_LOCALDRIVE                 0x10286F6D
+#define FSHELL_UID_PIPSRUN                    0x102866DB
+#define FSHELL_UID_USB                        0x10286F6E
+#define FSHELL_UID_EXTRABTRACE                0x10286F6B
+#define FSHELL_UID_MEMSPY                     0x10286F6C
+#define FSHELL_UID_EXTRABTRACEK               0x10286F6D
+
+#else // Not FSHELL_PROTECTED_UIDS
+
+#define FSHELL_UID_ACTIVEVIEW                 0xE02866D2
+#define FSHELL_UID_BACKUP                     0xE0285E0D
+#define FSHELL_UID_BACKUP_CHILD               0xE0285E0E
+#define FSHELL_UID_SMS                        0xE02864BE
+#define FSHELL_UID_BTRACE_PARSER              0xE0285E09
+#define FSHELL_UID_TINTERVAL                  0xE0285E0A
+#define FSHELL_UID_CLOGGERDEBUGROUTER         0xE02831C7
+#define FSHELL_UID_COMSDBGUTIL_CLOGGER_STUB   0xE0004d0a
+#define FSHELL_UID_FLOGGER_CLOGGER_STUB       0xE02866D3
+#define FSHELL_UID_CLOGGERBUFFERED            0xE02831CE
+#define FSHELL_UID_CLOGGER                    0xE0272EFE
+#define FSHELL_UID_CLOGGERSERVER              0xE0272EFD
+#define FSHELL_UID_TCLOG                      0xE0272F03
+#define FSHELL_UID_BTRACE                     0xE02835B3
+#define FSHELL_UID_CAT                        0xE02835B4
+#define FSHELL_UID_CENREP                     0xE02831C9
+#define FSHELL_UID_CHKDEPS                    0xE0285A17
+#define FSHELL_UID_CHKDRIFT                   0xE02836dc
+#define FSHELL_UID_CLIPBOARD                  0xE0285BA3
+#define FSHELL_UID_CLOGGERCONFIG              0xE02831CA
+#define FSHELL_UID_DRVINFO                    0xE02836d3
+#define FSHELL_UID_FOCUS                      0xE02836e2
+#define FSHELL_UID_GETHEAP                    0xE02835B8
+#define FSHELL_UID_GETSTACK                   0xE02835BD
+#define FSHELL_UID_GRABSCREEN                 0xE02836d5
+#define FSHELL_UID_LEAK                       0xE02835BB
+#define FSHELL_UID_LISTAPPS                   0xE02835B9
+#define FSHELL_UID_LOAD                       0xE02836e1
+#define FSHELL_UID_MEMSAMPLER                 0xE02836d6
+#define FSHELL_UID_MROUTER                    0xE02836d2
+#define FSHELL_UID_OPENDOC                    0xE02836d0
+#define FSHELL_UID_PATCHDATA                  0xE02836de
+#define FSHELL_UID_PLAY                       0xE0285C6D
+#define FSHELL_UID_PUBSUB                     0xE02831CB
+#define FSHELL_UID_RCOMM                      0xE02836d4
+#define FSHELL_UID_RENDEZVOUS                 0xE0285A15
+#define FSHELL_UID_RESTORE                    0xE0285E0F
+#define FSHELL_UID_SHUTAPP                    0xE02835BA
+#define FSHELL_UID_SPINLOCK                   0xE0285BA5
+#define FSHELL_UID_SUDO                       0xE0285BA0
+#define FSHELL_UID_SWI                        0xE02864CE
+#define FSHELL_UID_SWITCHVIEW                 0xE02866D1
+#define FSHELL_UID_QOTD                       0xE0286b42
+#define FSHELL_UID_TAIL                       0xE02835B5
+#define FSHELL_UID_XMODEM                     0xE02836d9
+#define FSHELL_UID_MEMSAMPLERDD               0xE02866D4
+#define FSHELL_UID_FSHELL_INST                0xE02836d1
+#define FSHELL_UID_FSHELL_UINST               0xE02835C0
+#define FSHELL_UID_IOSRV                      0xE0282343
+#define FSHELL_UID_SBAPP                      0xE02836cf
+#define FSHELL_UID_SBREC                      0xE02835bf
+#define FSHELL_UID_FSHELL                     0xE0282D94
+#define FSHELL_UID_LINEEDITOR                 0xE0285C66
+#define FSHELL_UID_MEMORYACCESS               0xE0273948
+#define FSHELL_UID_VARIANT                    0xE02864CF
+#define FSHELL_UID_QR3SANDBOX                 0xE02831C6
+#define FSHELL_UID_LOGGINGALLOCATOR           0xE02831C8
+#define FSHELL_UID_KERNINFO                   0xE0285BA1
+#define FSHELL_UID_QR3                        0xE0282DAB
+#define FSHELL_UID_SETCRITICAL                0xE0285BA4
+#define FSHELL_UID_SETPRIORITY                0xE0285BA2
+#define FSHELL_UID_TOPSAMPLE                  0xE0282DA9
+#define FSHELL_UID_TCPCSY                     0xE02866D8
+#define FSHELL_UID_VT100                      0xE02836db
+#define FSHELL_UID_WINSOCKPRT                 0xE02866D9
+#define FSHELL_UID_IAP                        0xE02864CB
+#define FSHELL_UID_WGET                       0xE02864CC
+#define FSHELL_UID_FZIP                       0xE02864CA
+#define FSHELL_UID_SIS                        0xE02866DA
+#define FSHELL_UID_TOP                        0xE02869FE
+#define FSHELL_UID_FCONTACTS                  0xE02869FF
+#define FSHELL_UID_RUNLIB                     0xE02864C6
+#define FSHELL_UID_FED                        0xE0286A00
+#define FSHELL_UID_RCONN                      0xE02866DD
+#define FSHELL_UID_FSHELL_LAUNCH_TCP          0xE02866E0
+#define FSHELL_UID_FSHELL_LAUNCH_BT           0xE02866E1
+#define FSHELL_UID_LTKUTILS                   0xE0286A06
+#define FSHELL_UID_SNAKE                      0xE0287022
+#define FSHELL_UID_PING                       0xE0286F52
+#define FSHELL_UID_FCALENDAR                  0xE0286F53
+#define FSHELL_UID_FIND                       0xE0286F54
+#define FSHELL_UID_UPROFILER                  0xE0286F55
+#define FSHELL_UID_BTRACEOUT                  0xE0286F56
+#define FSHELL_UID_LTKUTILS_TCB               0xE0286F57
+#define FSHELL_UID_BTSERVICES                 0xE0286F58
+#define FSHELL_UID_S60_GUICONS                0xE0286b46
+#define FSHELL_UID_SYSINFO                    0xE0286B6B
+#define FSHELL_UID_CONSOLEPROXY               0xE0287198
+#define FSHELL_UID_UIDINFO                    0xE0286F5A
+#define FSHELL_UID_REZ                        0xE0286A01
+#define FSHELL_UID_WSLOG                      0xE0286A05
+#define FSHELL_UID_SCREENMODE                 0xE0286B6C
+#define FSHELL_UID_HEAPTRACE                  0xE0286F5C
+#define FSHELL_UID_INIEDIT                    0xE028719b
+#define FSHELL_UID_NULLNIF                    0xE0286B6D
+#define FSHELL_UID_PASTE                      0xE0286B6F
+#define FSHELL_UID_FSHELL_LAUNCH_USB          0xE0286B70
+#define FSHELL_UID_FSHELL_LAUNCH_RCONS        0xE0286B71
+#define FSHELL_UID_RAMDEFRAG                  0xE0286F5D
+#define FSHELL_UID_ICC                        0xE0286B73
+#define FSHELL_UID_VTCSERIAL                  0xE028719D
+#define FSHELL_UID_ECOM                       0xE0286F60
+#define FSHELL_UID_RSOCKET                    0xE0286B74
+#define FSHELL_UID_GENBMP                     0xE0286B75
+#define FSHELL_UID_TFINFO                     0xE0286B76
+#define FSHELL_UID_FDB                        0xE0286F61
+#define FSHELL_UID_NITZ                       0xE0286B77
+#define FSHELL_UID_HAL                        0xE0286B78
+#define FSHELL_UID_POINTER                    0xE0286F62
+#define FSHELL_UID_LBS                        0xE0286B79
+#define FSHELL_UID_SQL                        0xE0286B7A
+#define FSHELL_UID_SQLSRV                     0xE02835BC
+#define FSHELL_UID_GLINFO                     0xE0286B7B
+#define FSHELL_UID_FSHELL_LAUNCH_SERIAL       0xE0286F63
+#define FSHELL_UID_HASH                       0xE0286B7C
+#define FSHELL_UID_SPCRE                      0xE0286F66
+#define FSHELL_UID_LIBPCRE                    0xE0286F67
+#define FSHELL_UID_GREP                       0xE0286F68
+#define FSHELL_UID_STARTUP                    0xE0286F69
+#define FSHELL_UID_FFSTRACERPLUGIN            0xE0286F6B
+#define FSHELL_UID_FFSTRACE                   0xE0286F6C
+#define FSHELL_UID_LOCALDRIVE                 0xE0286F6D
+#define FSHELL_UID_PIPSRUN                    0xE02866DB
+#define FSHELL_UID_USB                        0xE0286F6E
+#define FSHELL_UID_EXTRABTRACE                0xE0286F6B
+#define FSHELL_UID_MEMSPY                     0xE0286F6C
+#define FSHELL_UID_EXTRABTRACEK               0xE0286F6D
+
+#endif // FSHELL_PROTECTED_UIDS
+
+#define FSHELL_UID2_FSHELL_DLL                0x102864C8
+#define FSHELL_UID2_FSHELL_EXE                0x102835BE
+
+#endif // FSHELL_COMMON_MMH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/fsh_buildsis.mk	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+# bldsis.mk
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+FINAL :
+ifneq ($(PLATFORM), WINSCW)
+	..\..\tools\fsh-buildsis -u $(PLATFORM) $(EPOCROOT)epoc32\rom\include\fshell.iby $(EPOCROOT)epoc32\fshell\fshell.sis
+endif
+
+RELEASABLES :
+ifneq ($(PLATFORM), WINSCW)
+	echo $(EPOCROOT)epoc32\fshell\fshell.unsigned.sis
+endif
+
+MAKMAKE BLD FREEZE LIB CLEANLIB RESOURCE CLEAN SAVESPACE : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/fsh_config.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+// fsh_config.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_CONFIG_IBY
+#define FSHELL_CONFIG_IBY
+
+#include <fshell/platform.mmh>
+#include <fshell/common.mmh>
+
+#if !defined(FSHELL_MAKESIS) && !defined(FSHELL_MANIFEST)
+#include <fsh_rombuild_defs.iby>
+#endif
+
+#endif // FSHELL_CONFIG_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/fsh_makesis_defs.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+// fsh_makesis_defs.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef MAKESIS_DEFS_IBY
+#define MAKESIS_DEFS_IBY
+
+#define FSHELL_MAKESIS
+
+#include <fshell/common.mmh>
+
+#ifdef GCCE
+#define ABI gcce
+#else
+#define ABI armv5
+#endif
+
+#define ABI_DIR \epoc32\release\ ## ABI
+#define ABI_FOR(file) ABI_DIR ## \file
+
+#define ZPRIVATE \epoc32\data\z\private
+#define ZSYSTEM \epoc32\data\z\system
+#define ZRESOURCE \epoc32\data\z\resource
+#define BUILD_DIR urel
+#define STRINGIFY(x) #x
+#define HASH #
+
+#define FSHELL_EXECUTABLE_FILE_ABI(fileName, abiPath) STRINGIFY(abiPath) - STRINGIFY(!:\sys\bin\ ## fileName)
+
+#define FSHELL_DATA_FILE(fileNameFrom, fileNameTo) STRINGIFY(fileNameFrom) - STRINGIFY(!:\ ## fileNameTo)
+#define FSHELL_EXECUTABLE_FILE(fileName) FSHELL_EXECUTABLE_FILE_ABI(fileName, ABI_FOR(urel\ ## fileName))
+#define FSHELL_DEBUG_EXECUTABLE_FILE(fileName) FSHELL_EXECUTABLE_FILE_ABI(fileName, ABI_FOR(udeb\ ## fileName))
+#define FSHELL_RENAMED_EXECUTABLE_FILE(fileNameFrom, fileNameTo) FSHELL_EXECUTABLE_FILE_ABI(fileNameTo, ABI_FOR(urel\ ## fileNameFrom))
+#define FSHELL_RENAMED_DEBUG_EXECUTABLE_FILE(fileNameFrom, fileNameTo) FSHELL_EXECUTABLE_FILE_ABI(fileNameTo, ABI_FOR(udeb\ ## fileNameFrom))
+#define FSHELL_KERNEL_EXTENSION(fileName) FSHELL_EXECUTABLE_FILE(fileName)
+#define FSHELL_DEBUG_KERNEL_EXTENSION(fileName) FSHELL_DEBUG_EXECUTABLE_FILE(fileName)
+#define FSHELL_DEVICE_DRIVER(fileName) FSHELL_EXECUTABLE_FILE(fileName)
+#define FSHELL_DEBUG_DEVICE_DRIVER(fileName) FSHELL_DEBUG_EXECUTABLE_FILE(fileName)
+#define FSHELL_ECOM_PLUGIN(dllName, resourceName) FSHELL_EXECUTABLE_FILE_ABI(dllName, ABI_FOR(urel\ ## dllName)) STRINGIFY(\epoc32\data\z\resource\plugins\##resourceName) - STRINGIFY(!:\resource\plugins\##resourceName)
+#define FSHELL_DEBUG_ECOM_PLUGIN(dllName, resourceName) FSHELL_EXECUTABLE_FILE_ABI(dllName, ABI_FOR(udeb\ ## dllName)) STRINGIFY(\epoc32\data\z\resource\plugins\##resourceName) - STRINGIFY(!:\resource\plugins\##resourceName)
+#define FSHELL_COMMAND_INFO_FILE(owner, fileName) STRINGIFY(\epoc32\data\z\resource\cif\##owner##\##fileName) - STRINGIFY(!:\resource\cif\##owner##\##fileName)
+
+#endif // MAKESIS_DEFS_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/fsh_manifest_defs.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+// fsh_manifest_defs.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef MANIFEST_DEFS_IBY
+#define MANIFEST_DEFS_IBY
+
+#define FSHELL_MANIFEST
+
+#include <fshell/common.mmh>
+
+#ifdef GCCE
+#define ABI gcce
+#else
+#define ABI armv5
+#endif
+
+#define ABI_DIR \epoc32\release\ ## ABI
+#define ABI_FOR(file) ABI_DIR ## \file
+
+#define ZPRIVATE \epoc32\data\z\private
+#define ZSYSTEM \epoc32\data\z\system
+#define ZRESOURCE \epoc32\data\z\resource
+#define BUILD_DIR urel
+#define STRINGIFY(x) #x
+#define HASH #
+
+#define FSHELL_EXECUTABLE_FILE_ABI(abiPath) STRINGIFY(abiPath)
+
+#define FSHELL_DATA_FILE(fileNameFrom, fileNameTo) STRINGIFY(fileNameFrom)
+#define FSHELL_EXECUTABLE_FILE(fileName) FSHELL_EXECUTABLE_FILE_ABI(ABI_FOR(urel\ ## fileName))
+#define FSHELL_DEBUG_EXECUTABLE_FILE(fileName) FSHELL_EXECUTABLE_FILE_ABI(ABI_FOR(udeb\ ## fileName))
+#define FSHELL_RENAMED_EXECUTABLE_FILE(fileNameFrom, fileNameTo) FSHELL_EXECUTABLE_FILE_ABI(ABI_FOR(urel\ ## fileNameFrom))
+#define FSHELL_RENAMED_DEBUG_EXECUTABLE_FILE(fileNameFrom, fileNameTo) FSHELL_EXECUTABLE_FILE_ABI(ABI_FOR(udeb\ ## fileNameFrom))
+#define FSHELL_KERNEL_EXTENSION(fileName) FSHELL_EXECUTABLE_FILE(fileName)
+#define FSHELL_DEBUG_KERNEL_EXTENSION(fileName) FSHELL_DEBUG_EXECUTABLE_FILE(fileName)
+#define FSHELL_DEVICE_DRIVER(fileName) FSHELL_EXECUTABLE_FILE(fileName)
+#define FSHELL_DEBUG_DEVICE_DRIVER(fileName) FSHELL_DEBUG_EXECUTABLE_FILE(fileName)
+#define FSHELL_ECOM_PLUGIN(dllName, resourceName) FSHELL_EXECUTABLE_FILE_ABI(ABI_FOR(urel\ ## dllName)) STRINGIFY(\epoc32\data\z\resource\plugins\##resourceName)
+#define FSHELL_DEBUG_ECOM_PLUGIN(dllName, resourceName) FSHELL_EXECUTABLE_FILE_ABI(ABI_FOR(udeb\ ## dllName)) STRINGIFY(\epoc32\data\z\resource\plugins\##resourceName)
+#define FSHELL_COMMAND_INFO_FILE(owner, fileName) STRINGIFY(\epoc32\data\z\resource\cif\##owner##\##fileName)
+
+#endif // MANIFEST_DEFS_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/fsh_rombuild_defs.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,61 @@
+// fsh_rombuild_defs.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef ROMBUILD_DEFS_IBY
+#define ROMBUILD_DEFS_IBY
+
+#ifndef FSHELL_PLATFORM_MMH
+#error "fshell platform.mmh must be included before include fsh_rombuild_defs.iby"
+#endif
+
+#define FSHELL_ROMBUILD
+
+#ifdef FSHELL_BASE_ROM
+
+#define FSHELL_DATA_FILE(fileNameFrom, fileNameTo) data=##fileNameFrom fileNameTo
+#define FSHELL_EXECUTABLE_FILE(fileName) file=\epoc32\release\##MAIN##\##BUILD##\##fileName sys\bin\##fileName
+#define FSHELL_DEBUG_EXECUTABLE_FILE(fileName) file=\epoc32\release\##MAIN##\##BUILD##\##fileName sys\bin\##fileName
+#define FSHELL_RENAMED_EXECUTABLE_FILE(fileNameFrom, fileNameTo) file=\epoc32\release\##MAIN##\##BUILD##\##fileNameFrom sys\bin\##fileNameTo
+#define FSHELL_DEBUG_RENAMED_EXECUTABLE_FILE(fileNameFrom, fileNameTo) file=\epoc32\release\##MAIN##\##BUILD##\##fileNameFrom sys\bin\##fileNameTo
+#define FSHELL_KERNEL_EXTENSION(fileName) extension[VARID]=\epoc32\release\##KMAIN##\##BUILD##\##fileName sys\bin\##fileName
+#define FSHELL_DEBUG_KERNEL_EXTENSION(fileName) extension[VARID]=\epoc32\release\##KMAIN##\##BUILD##\##fileName sys\bin\##fileName
+#define FSHELL_DEVICE_DRIVER(fileName) device[VARID]=\epoc32\release\##KMAIN##\##BUILD##\##fileName sys\bin\##fileName
+#define FSHELL_DEBUG_DEVICE_DRIVER(fileName) device[VARID]=\epoc32\release\##KMAIN##\##BUILD##\##fileName sys\bin\##fileName
+#define FSHELL_ECOM_PLUGIN(dllName, resourceName) ECOM_PLUGIN(dllName, resourceName)
+#define FSHELL_DEBUG_ECOM_PLUGIN(dllName, resourceName) ECOM_PLUGIN_UDEB(dllName, resourceName)
+#define FSHELL_COMMAND_INFO_FILE(owner, fileName) data=ZRESOURCE\cif\##owner##\##fileName resource\cif\##owner##\##fileName
+
+#else
+
+// Some platforms require custom definitions of these (which they supply in their platform.mmh). Most however use normal "extension[VARID]=" syntax.
+#ifndef FSHELL_EXT
+#define FSHELL_EXT extension[VARID]
+#endif
+#ifndef FSHELL_DEV
+#define FSHELL_DEV device[VARID]
+#endif
+
+#define FSHELL_DATA_FILE(fileNameFrom, fileNameTo) data=##fileNameFrom fileNameTo
+#define FSHELL_EXECUTABLE_FILE(fileName) file=##ABI_DIR##\##DEBUG_DIR##\##fileName sys\bin\##fileName
+#define FSHELL_DEBUG_EXECUTABLE_FILE(fileName) file=##ABI_DIR##\##DEBUG_DIR##\##fileName sys\bin\##fileName
+#define FSHELL_RENAMED_EXECUTABLE_FILE(fileNameFrom, fileNameTo) file=##ABI_DIR##\##BUILD_DIR\##fileNameFrom sys\bin\##fileNameTo
+#define FSHELL_DEBUG_RENAMED_EXECUTABLE_FILE(fileNameFrom, fileNameTo) file=##ABI_DIR##\##DEBUG_DIR\##fileNameFrom sys\bin\##fileNameTo
+#define FSHELL_KERNEL_EXTENSION(fileName) ROM_IMAGE[0] FSHELL_EXT=##KERNEL_DIR##\##BUILD_DIR##\##fileName sys\bin\##fileName
+#define FSHELL_DEBUG_KERNEL_EXTENSION(fileName) ROM_IMAGE[0] { FSHELL_EXT=##KERNEL_DIR##\##DEBUG_DIR##\##fileName sys\bin\##fileName }
+#define FSHELL_DEVICE_DRIVER(fileName) ROM_IMAGE[0] FSHELL_DEV=##KERNEL_DIR##\##BUILD_DIR##\##fileName sys\bin\##fileName
+#define FSHELL_DEBUG_DEVICE_DRIVER(fileName) ROM_IMAGE[0] FSHELL_DEV=##KERNEL_DIR##\##DEBUG_DIR##\##fileName sys\bin\##fileName
+#define FSHELL_ECOM_PLUGIN(dllName, resourceName) ECOM_PLUGIN(dllName, resourceName)
+#define FSHELL_DEBUG_ECOM_PLUGIN(dllName, resourceName) ECOM_PLUGIN_UDEB(dllName, resourceName)
+#define FSHELL_COMMAND_INFO_FILE(owner, fileName) data=ZRESOURCE\cif\##owner##\##fileName resource\cif\##owner##\##fileName
+
+#endif // FSHELL_BASEROM_SUPPORT
+
+#endif // ROMBUILD_DEFS_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/fsh_system_include.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+// fsh_system_include.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+#if defined(FSHELL_PLATFORM_FOUNDATION) || defined(FSHELL_PLATFORM_SYMTB)
+#define FSHELL_USING_PLATFORM_PATHS
+#include <platform_paths.hrh>
+#elif FSHELL_PLATFORM_S60 >= 5
+#define FSHELL_USING_PLATFORM_PATHS
+#include <domain/osextensions/platform_paths.hrh>
+#endif
+
+#ifdef FSHELL_USING_PLATFORM_PATHS
+APP_LAYER_SYSTEMINCLUDE
+#else
+systeminclude	\epoc32\include
+#endif
+
+#if !defined(FSHELL_USING_PLATFORM_PATHS) || (FSHELL_PLATFORM_S60 <= 5 && !defined(FSHELL_PLATFORM_SYMTB)) || defined(SYMBIAN_OLD_EXPORT_LOCATION)
+#define FSHELL_NETWORKING_SYSTEMINCLUDE \epoc32\include\networking
+#define FSHELL_HTTP_SYSTEMINCLUDE \epoc32\include\http
+#else
+#define FSHELL_NETWORKING_SYSTEMINCLUDE \epoc32\include\platform\networking
+#define FSHELL_HTTP_SYSTEMINCLUDE \epoc32\include\mw\http
+#endif
+
+#if defined(FSHELL_PLATFORM_FOUNDATION)
+#define FSHELL_LBS_SYSTEMINCLUDE \epoc32\include\lbs
+#elif FSHELL_PLATFORM_S60 == 3
+#define FSHELL_LBS_SYSTEMINCLUDE \epoc32\include\oem
+#else
+// Should be ok with what platformpaths gives us
+#define FSHELL_LBS_SYSTEMINCLUDE
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/fshell.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,47 @@
+// fshell.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_IBY
+#define FSHELL_IBY
+
+#include <fsh_config.iby>
+#include <fshell_platform.iby>
+
+// Generic-ish platform workarounds
+#if defined(FSHELL_ROMBUILD) && defined(FSHELL_BTRACE_SUPPORT)
+#include <btrace.iby>
+#endif
+
+// Core
+#include <fshell_core.iby>
+#include <fshell_commands.iby>
+
+// Libraries
+#include <btrace_parser.iby>
+#include <btincomingserial.iby>
+#include <clogger.iby>
+#include <extrabtrace.iby>
+#include <lineeditor.iby>
+#include <ltkutils.iby>
+#include <memoryaccess-fshell.iby>
+#include <qr3.iby>
+#ifdef FSHELL_SPCRE_SUPPORT
+#include <spcre.iby>
+#endif
+
+// consoles
+#include <vt100cons.iby>
+#include <nullcons.iby>
+#include <guicons.iby>
+#include <defcons.iby>
+#include <consoleproxy.iby>
+
+#endif // FSHELL_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/readme.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,12 @@
+A few words about how and why the tool-kit's UIDs are defined here.
+
+The motivation for centrally defining all the tool-kit's UIDs in one place
+was to allow them all to be changed into the non-protected range, thereby
+allowing the tool-kit to be installed using a self-signed SIS file. Note,
+self-signed SIS files can only be used with UIDs in the non-protected range.
+
+Each platform that the tool-kit supports gets to decide which range of UIDs
+it will use. The platforms (i.e. sub-directories of \fshell/platforms)
+decide which range to use by whether they define FSHELL_PROTECTED_UIDS in their
+platform.mmh. This macro is picked up by common.mmh (which is #included by
+all .mmp files) and any .cpp or .rss (or similar) files that need it.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/common/release.src	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+notesrc_releaser
+Joe Branton (joe.branton@accenture.com) or Tom Sutcliffe (thomas.sutcliffe@accenture.com)
+
+notesrc_release_reason
+See <a href="..\..\fshell/documentation\change_history.html">change history</a> for details of changes in this release.
+
+notesrc_general_comments
+See this <a href="..\..\fshell/documentation\index.html">documentation</a> for installation and howto type information.
+
+notesrc_known_deviations
+None known.
+
+notesrc_bugs_fixed
+
+
+notesrc_bugs_remaining
+None known.
+
+notesrc_other_changes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/3rd_edition/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "../platform_generic.mmh"
+#include "platform.mmh"
+#include "../bld_generic.inf"
+
+PRJ_EXPORTS
+.\platform.mmh       \epoc32\include\fshell\platform.mmh
+FSHELL_ROM_INCLUDE2(platform.mmh, fshell/platform.mmh)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/3rd_edition/mbld.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2 @@
+winscw \fshell\build\s60\3rd_edition winscw udeb
+armv5 \fshell\build\s60\3rd_edition armv5 urel
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/3rd_edition/platform.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+// platform.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_MMH
+#define FSHELL_PLATFORM_MMH
+
+#ifndef FSHELL_PLATFORM_GENERIC_MMH
+#include <fshell/platform_generic.mmh>
+#endif
+
+#define FSHELL_CORE_SUPPORT_USB_ICON "ACM::1"
+
+#define FSHELL_PERL_SUPPORT
+#define FSHELL_NO_BTRACE_SUPPORT
+#define FSHELL_NO_DYNAMICDFC_SUPPORT
+#define FSHELL_NO_PIPS_SUPPORT
+#define FSHELL_NO_WSERV2_SUPPORT
+#define FSHELL_NO_RAMDEFRAG_SUPPORT
+#define FSHELL_NO_COPYTOSHADOWMEMORY_SUPPORT
+#define FSHELL_NO_SQL_SUPPORT
+#define FSHELL_NO_EGL_SUPPORT
+#define FSHELL_NO_OPENVG_SUPPORT
+#define FSHELL_NO_SHA2_SUPPORT
+#define FSHELL_NO_MD4_SUPPORT
+
+#define FSHELL_PLATFORM_S60 3
+
+#endif // FSHELL_PLATFORM_MMH
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/5th_edition/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "../platform_generic.mmh"
+#include "platform.mmh"
+#include "../bld_generic.inf"
+
+PRJ_EXPORTS
+.\platform.mmh       \epoc32\include\fshell\platform.mmh
+FSHELL_ROM_INCLUDE2(platform.mmh, fshell/platform.mmh)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/5th_edition/platform.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,24 @@
+// platform.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_MMH
+#define FSHELL_PLATFORM_MMH
+
+#ifndef FSHELL_PLATFORM_GENERIC_MMH
+#include <fshell/platform_generic.mmh>
+#endif
+
+#define FSHELL_NO_PIPS_SUPPORT // [TomS:] Does 5th ed have pips?
+
+#define FSHELL_PLATFORM_S60 5
+
+#endif // FSHELL_PLATFORM_MMH
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/bld_generic.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// bld_generic.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "../common/common.mmh"
+
+PRJ_PLATFORMS
+WINSCW
+ARMV5
+
+PRJ_EXPORTS
+.\platform_generic.mmh       \epoc32\include\fshell\platform_generic.mmh
+FSHELL_ROM_INCLUDE2(platform_generic.mmh, fshell\platform_generic.mmh)
+FSHELL_ROM_INCLUDE(fshell_platform.iby)
+
+#if FSHELL_PLATFORM_S60 >= 5
+.\vt100btcons_preamble.script z:\system\console\scripts\vt100btcons_preamble.script
+#endif
+
+#include "../common/bld.inf"
+
+PRJ_MMPFILES
+gnumakefile    ..\common\fsh_buildsis.mk
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/fshell_platform.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+// fshell_platform.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_IBY
+#define FSHELL_PLATFORM_IBY
+
+#ifdef FSHELL_MAKESIS
+
+;Unique Vendor Name
+:"Accenture"
+
+;localised vendor names 
+%{"Accenture"}
+
+HASH{"fshell (S60)"},(FSHELL_UID_SIS),FSHELL_VERSION,0,FSHELL_TIMESTAMP,TYPE=SA
+
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+[0x102032BE], 0, 0, 0, {"Series60ProductID"}
+[0x102752AE], 0, 0, 0, {"Series60ProductID"}
+[0x1028315F], 0, 0, 0, {"Series60ProductID"}
+
+#endif
+
+#if FSHELL_PLATFORM_S60 >= 5
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\vt100btcons_preamble.script, system\console\scripts\vt100btcons_preamble.script)
+#endif
+
+#endif // FSHELL_PLATFORM_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/iosrv.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,13 @@
+# iosrv.ini
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+console			econs.dll
+console_size_detect	1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/platform_generic.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// platform_generic.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_GENERIC_MMH
+#define FSHELL_PLATFORM_GENERIC_MMH
+
+#define FSHELL_CAP_ALL
+#define FSHELL_PROTECTED_UIDS
+
+// Note FSHELL_PLATFORM_S60 is defined in the 3rd or 5th ed platform.mmh
+
+#ifdef WINS
+#define FSHELL_CORE_SUPPORT_LOCAL_ICON
+#define FSHELL_CORE_SUPPORT_RCONS_ICON
+#else
+#define FSHELL_CORE_SUPPORT_LOCAL_ICON
+#define FSHELL_CORE_SUPPORT_TCP_ICON
+#define FSHELL_CORE_SUPPORT_BT_ICON
+#endif
+
+// Seems like this should be defined in a variant.hrh file, but it doesn't appear to be...
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+#define SYMBIAN_JAVA_NOT_INCLUDED
+#endif
+
+#define FSHELL_SPCRE_SUPPORT
+
+#endif // FSHELL_PLATFORM_GENERIC_MMH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/tb92/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "../platform_generic.mmh"
+#include "platform.mmh"
+#include "../bld_generic.inf"
+
+PRJ_PLATFORMS
+ARMV5SMP
+
+PRJ_EXPORTS
+.\platform.mmh       \epoc32\include\fshell\platform.mmh
+FSHELL_ROM_INCLUDE2(platform.mmh, fshell/platform.mmh)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/tb92/platform.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// platform.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_MMH
+#define FSHELL_PLATFORM_MMH
+
+#ifndef FSHELL_PLATFORM_GENERIC_MMH
+#include <fshell/platform_generic.mmh>
+#endif
+
+#define FSHELL_PLATFORM_SYMTB 92
+#define FSHELL_PLATFORM_S60 5
+
+#define FSHELL_CORE_SUPPORT_USB_ICON "ACM::1"
+
+#define FSHELL_NO_DOBJECTIX_SUPPORT
+#define FSHELL_NO_EGL_SUPPORT
+#define FSHELL_NO_OPENVG_SUPPORT
+#define FSHELL_FLEXIBLEMM_AWARE
+#define FSHELL_ARM11XX_SUPPORT
+#define FSHELL_DYNAMICSTARTUP_SUPPORT
+
+#endif // FSHELL_PLATFORM_MMH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/s60/vt100btcons_preamble.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+# vt100btcons_preamble.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# S60 has a habit of starting up in flight mode if there's no SIM card, which means BT is switched off too.
+# This script is a convenience to make sure it is enabled if possible before using the bluetooth console.
+
+btservices enable
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/sf/2/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// The macroing here is a little messy to get things included in the right order...
+#define FSHELL_PLATFORM_SHARED_MMH
+#include "platform.mmh"
+#undef FSHELL_PLATFORM_SHARED_MMH
+#include "../platform_shared.mmh"
+#include "../bld_shared.inf"
+
+PRJ_EXPORTS
+.\platform.mmh       \epoc32\include\fshell\platform.mmh
+FSHELL_ROM_INCLUDE2(platform.mmh, fshell\platform.mmh)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/sf/2/platform.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+// platform.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_MMH
+#define FSHELL_PLATFORM_MMH
+
+#define FSHELL_PLATFORM_FOUNDATION 2
+
+#ifndef FSHELL_PLATFORM_SHARED_MMH
+#include <fshell/platform_shared.mmh>
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/sf/3/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// The macroing here is a little messy to get things included in the right order...
+#define FSHELL_PLATFORM_SHARED_MMH
+#include "platform.mmh"
+#undef FSHELL_PLATFORM_SHARED_MMH
+#include "../platform_shared.mmh"
+#include "../bld_shared.inf"
+
+PRJ_EXPORTS
+.\platform.mmh       \epoc32\include\fshell\platform.mmh
+FSHELL_ROM_INCLUDE2(platform.mmh, fshell\platform.mmh)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/sf/3/platform.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+// platform.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_MMH
+#define FSHELL_PLATFORM_MMH
+
+#define FSHELL_PLATFORM_FOUNDATION 3
+
+#ifndef FSHELL_PLATFORM_SHARED_MMH
+#include <fshell/platform_shared.mmh>
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/sf/bld_shared.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// bld_shared.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "platform.mmh"
+#include "../common/common.mmh"
+
+PRJ_PLATFORMS
+WINSCW
+ARMV5
+
+#include "../common/bld.inf"
+
+PRJ_EXPORTS
+.\platform_shared.mmh       \epoc32\include\fshell\platform_shared.mmh
+FSHELL_ROM_INCLUDE2(platform_shared.mmh, fshell\platform_shared.mmh)
+FSHELL_ROM_INCLUDE(fshell_platform.iby)
+
+PRJ_MMPFILES
+gnumakefile    ..\common\fsh_buildsis.mk
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/sf/fshell_platform.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// fshell_platform.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_IBY
+#define FSHELL_PLATFORM_IBY
+
+#ifdef FSHELL_MAKESIS
+
+;Unique Vendor Name
+:"Accenture"
+
+;localised vendor names
+%{"Accenture"}
+
+HASH{"fshell (SF)"},(FSHELL_UID_SIS),FSHELL_VERSION,0,FSHELL_TIMESTAMP,TYPE=SA
+#endif
+
+#endif // FSHELL_PLATFORM_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/sf/platform_shared.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+// platform_shared.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef FSHELL_PLATFORM_SHARED_MMH
+#define FSHELL_PLATFORM_SHARED_MMH
+
+#define FSHELL_CAP_ALL
+#define FSHELL_PROTECTED_UIDS
+
+// FSHELL_PLATFORM_FOUNDATION is defined by .\2\platform.mmh or .\3\platform.mmh
+#define FSHELL_PLATFORM_S60 7 // for ease of macroing, SF 1 is considered S60 6, SF 2 as S60 7, etc
+
+#ifdef WINS
+#define FSHELL_CORE_SUPPORT_LOCAL_ICON
+#define FSHELL_CORE_SUPPORT_RCONS_ICON
+#else
+#define FSHELL_CORE_SUPPORT_LOCAL_ICON
+#define FSHELL_CORE_SUPPORT_TCP_ICON
+#define FSHELL_CORE_SUPPORT_BT_ICON
+#define FSHELL_CORE_SUPPORT_SERIAL_ICON "port=COMM::1, rate=115200"
+#endif
+
+#define FSHELL_NO_SAMPLINGPROFILER_SUPPORT
+#define FSHELL_NO_EGL_SUPPORT // The lib exists but not the dll itself...
+#define FSHELL_NO_OPENVG_SUPPORT // ditto
+
+#if FSHELL_PLATFORM_FOUNDATION >= 3
+#define FSHELL_NO_DOBJECTIX_SUPPORT
+#endif
+
+#endif // FSHELL_PLATFORM_SHARED_MMH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/symtb92/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+PRJ_PLATFORMS
+WINSCW
+ARMV5
+ARMV5SMP
+
+#include "platform.mmh"
+#include "../common/common.mmh"
+
+PRJ_EXPORTS
+.\platform.mmh                /epoc32/include/fshell/platform.mmh
+FSHELL_ROM_INCLUDE2(platform.mmh, fshell\platform.mmh)
+FSHELL_ROM_INCLUDE(fshell_platform.iby)
+
+PRJ_MMPFILES
+gnumakefile    ..\common\fsh_buildsis.mk
+
+#include <../common/bld.inf>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/symtb92/fshell_platform.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// fshell_platform.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_IBY
+#define FSHELL_PLATFORM_IBY
+
+#ifdef FSHELL_MAKESIS
+
+;Unique Vendor Name
+:"Accenture"
+
+;localised vendor names 
+%{"Accenture"}
+
+HASH{"fshell (SymTB92)"},(FSHELL_UID_SIS),FSHELL_VERSION,0,FSHELL_TIMESTAMP,TYPE=SA
+
+#endif
+
+#endif // FSHELL_PLATFORM_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/symtb92/platform.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// platform.mmh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_PLATFORM_MMH
+#define FSHELL_PLATFORM_MMH
+
+#define FSHELL_CAP_ALL
+#define FSHELL_PROTECTED_UIDS
+
+#define FSHELL_PLATFORM_SYMTB 92
+
+#define FSHELL_NO_LBS_SUPPORT
+#define FSHELL_NO_DOBJECTIX_SUPPORT
+#define FSHELL_NO_EGL_SUPPORT
+#define FSHELL_NO_OPENVG_SUPPORT
+#define FSHELL_FLEXIBLEMM_AWARE
+#define FSHELL_DYNAMICSTARTUP_SUPPORT
+#define FSHELL_ARM11XX_SUPPORT
+
+#endif // FSHELL_PLATFORM_MMH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/activeview/activeview.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# activeview.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name activeview
+
+==short-description
+
+Track changes to the currently active view.
+
+==see-also
+
+L<switchview|switchview>, L<focus|focus>
+
+==option bool v verbose
+
+Verbose output. Attempt to map UIDs to exe names.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/activeview/activeview.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,100 @@
+// activeview.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#undef SYMBIAN_ENABLE_SPLIT_HEADERS // Stopgap to handle CVwsSessionWrapper being compiled out of viewcli.h in latest TB92
+#include <fshell/ioutils.h>
+#include <viewcli.h>
+#include <fshell/qr3dll.h>
+
+using namespace IoUtils;
+
+class CCmdActiveView : public CCommandBase,  public MVwsSessionWrapperObserver
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdActiveView();
+private:
+	CCmdActiveView();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From MVwsSessionWrapperObserver.
+	virtual void HandleViewEventL(const TVwsViewEvent& aEvent);
+private:
+	CVwsSessionWrapper* iVws;
+	TBool iVerbose;
+	};
+
+
+CCommandBase* CCmdActiveView::NewLC()
+	{
+	CCmdActiveView* self = new(ELeave) CCmdActiveView();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdActiveView::~CCmdActiveView()
+	{
+	delete iVws;
+	}
+
+CCmdActiveView::CCmdActiveView() : CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdActiveView::Name() const
+	{
+	_LIT(KName, "activeview");	
+	return KName;
+	}
+
+void CCmdActiveView::DoRunL()
+	{
+	iVws = CVwsSessionWrapper::NewL(*this);
+	iVws->NotifyNextActivation();
+	}
+
+void CCmdActiveView::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	}
+
+void CCmdActiveView::HandleViewEventL(const TVwsViewEvent& aEvent)
+	{
+	if (aEvent.iEventType == TVwsViewEvent::EVwsActivationNotification)
+		{
+		if (iVerbose)
+			{
+			RBuf a, b, c, d;
+			ExeNameForSid(aEvent.iViewTwoId.iAppUid.iUid, a);
+			ExeNameForSid(aEvent.iViewTwoId.iViewUid.iUid, b);
+			ExeNameForSid(aEvent.iViewOneId.iAppUid.iUid, c);
+			ExeNameForSid(aEvent.iViewOneId.iViewUid.iUid, d);
+			Printf(_L("View switch: 0x%08x %S 0x%08x %S -> 0x%08x %S 0x%08x %S\r\n"), aEvent.iViewTwoId.iAppUid, &a, aEvent.iViewTwoId.iViewUid, &b, aEvent.iViewOneId.iAppUid, &c, aEvent.iViewOneId.iViewUid, &d);
+			a.Close();
+			b.Close();
+			c.Close();
+			d.Close();
+			}
+		else
+			{
+			Printf(_L("View switch: 0x%08x 0x%08x -> 0x%08x 0x%08x\r\n"), aEvent.iViewTwoId.iAppUid, aEvent.iViewTwoId.iViewUid, aEvent.iViewOneId.iAppUid, aEvent.iViewOneId.iViewUid);
+			}
+		iVws->NotifyNextActivation();
+		}
+	}
+
+
+EXE_BOILER_PLATE(CCmdActiveView)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/activeview/activeview.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// activeview.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          activeview.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_ACTIVEVIEW
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          activeview.cpp
+
+library         euser.lib
+library         iocli.lib
+library         viewcli.lib
+library         qr3.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/backup/backup.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,44 @@
+# backup.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name backup
+
+==short-description
+
+Put the handset into backup mode.
+
+==long-description
+
+A means of requesting backup aware modules to close their file handles. Note, this command does not actually B<perform> a backup, it merely prepares the system for one. It can be useful if you want to copy a file that is normally held open by a running process. Another strategy if this doesn't work (note, not everything is backup aware) is to do something like:
+
+  kill -m some-process && cp some-file .
+
+==see-also
+
+L<restore|restore>
+
+==argument enum operation
+
+The required operation to perform.
+
+==enum-value start
+
+Request that all backup aware modules release their file handles and prepare for a backup.
+
+==enum-value stop
+
+Request that all backup aware modules reclaim their file handles.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/backup/backup.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,205 @@
+// backup.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "backup.h"
+
+_LIT(KBackupOp,		"-b");
+
+//
+// CBackupDriver
+//
+CBackupDriver* CBackupDriver::NewL(MBackupParent& aParent)
+	{
+	CBackupDriver* self = new (ELeave) CBackupDriver(aParent);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBackupDriver::CBackupDriver(MBackupParent& aParent):
+CActive(CActive::EPriorityStandard), iParent(aParent)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CBackupDriver::~CBackupDriver()
+	{
+	Cancel();
+	}
+
+void CBackupDriver::ConstructL()
+	{
+	}
+
+void CBackupDriver::SendInstructionL(MBackupObserver::TFileLockFlags aInstruction)
+	{
+	iInstruction = aInstruction;
+	switch (iInstruction)
+		{
+		case MBackupObserver::EReleaseLockNoAccess:
+			LaunchProcessL();
+		break;
+
+		case MBackupObserver::ETakeLock:
+			TerminateProcessL();
+		break;
+
+		default:
+			User::Leave(KErrNotSupported);
+		break;		
+		};
+	}
+
+//
+// CBackupDriver::ChildProcessExists
+// checks whether the backup_child process
+// is already running
+//
+TBool CBackupDriver::ChildProcessExists()
+	{
+	_LIT(KWildCard, "*");
+	TName woop(KBackupProcessName);
+	woop.Append(KWildCard);
+	TFindProcess check(woop);
+	TFullName name;
+	TInt result = check.Next(name);
+	if (result == KErrNone)
+		return ETrue;	
+	return EFalse;
+	}
+
+//
+// CBackupDriver::LaunchProcessL
+// spawns the backup_child process
+// & waits to rendezvous
+//
+void CBackupDriver::LaunchProcessL()
+	{
+	if (ChildProcessExists())
+		User::Leave(KErrInUse);
+	
+	_LIT(KExeExt, ".exe");
+	TName name(KBackupProcessName);
+	name.Append(KExeExt);
+	User::LeaveIfError(iChild.Create(name, KBackupOp, EOwnerProcess));
+	iChild.Resume();
+	iChild.Rendezvous(iStatus);
+	SetActive();
+	}
+
+//
+// CBackupDriver::TerminateProcessL
+// open the backup_child process & signal it's semaphore
+// that semaphore is the signal to shut itself down cleanly
+//
+void CBackupDriver::TerminateProcessL()
+	{
+	if (!ChildProcessExists())
+		User::Leave(KErrNotFound);
+	
+	// signal the semaphore 
+	RSemaphore sem;
+	User::LeaveIfError(sem.OpenGlobal(KBackupSemaphore, EOwnerProcess));
+	sem.Signal();
+
+	SelfComplete(KErrNone);
+	}
+
+void CBackupDriver::SelfComplete(const TInt aError)
+	{
+	ASSERT(!IsActive());
+	iStatus = KRequestPending;
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete(status, aError);
+	SetActive();
+	}
+
+//
+// CBackupDriver::RunL
+// 
+void CBackupDriver::RunL()
+	{
+	iParent.Finished(iStatus.Int());
+	}
+
+//
+// CBackupDriver::DoCancel
+//
+void CBackupDriver::DoCancel()
+	{
+	ASSERT(EFalse); // not dealing with this!
+	}
+
+
+//
+// CCmdBackup
+//
+CCommandBase* CCmdBackup::NewLC()
+	{
+	CCmdBackup* self = new (ELeave) CCmdBackup();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdBackup::~CCmdBackup()
+	{
+	delete iBackup;
+	}
+
+CCmdBackup::CCmdBackup() : 
+CCommandBase(CCommandBase::EManualComplete)
+	{
+	}
+
+const TDesC& CCmdBackup::Name() const
+	{
+	_LIT(KName, "backup");	
+	return KName;
+	}
+
+void CCmdBackup::DoRunL()
+	{
+	// spawn the stuff I need to do the task
+	iBackup = CBackupDriver::NewL(*this);
+
+	// process the argument
+	MBackupObserver::TFileLockFlags flag = MBackupObserver::EReleaseLockNoAccess;
+	switch (iOperation)
+		{
+	case EStart:
+		flag = MBackupObserver::EReleaseLockNoAccess;
+		break;
+	case EStop:
+		flag = MBackupObserver::ETakeLock;
+		break;
+	default:
+		User::LeaveIfError(KErrArgument);
+		}
+			
+	// send the instruction through
+	iBackup->SendInstructionL(flag);
+	}
+
+void CCmdBackup::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgOperation, "operation");
+	aArguments.AppendEnumL((TInt&)iOperation, KArgOperation);
+	}
+
+void CCmdBackup::Finished(const TInt aError)
+	{
+	Complete(aError);
+	}
+
+EXE_BOILER_PLATE(CCmdBackup)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/backup/backup.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+// backup.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <babackup.h>
+
+using namespace IoUtils;
+
+_LIT(KArgStart, 			"start");
+_LIT(KArgStop,	 			"stop");
+_LIT(KBackupProcessName,	"backup_child");
+_LIT(KBackupSemaphore,		"AutometricBackup");
+
+class MBackupParent
+	{
+public:
+	virtual void Finished(const TInt aError) = 0;	
+	};
+
+class CBackupDriver : public CActive
+	{
+public:
+	static CBackupDriver* NewL(MBackupParent& aParent);
+	~CBackupDriver();
+	void SendInstructionL(MBackupObserver::TFileLockFlags aInstruction);
+private:
+	CBackupDriver(MBackupParent& aParent);
+	void ConstructL();
+	void SelfComplete(const TInt aError);
+	void LaunchProcessL();
+	void TerminateProcessL();
+	TBool ChildProcessExists();
+
+	// from CActive
+	void DoCancel();
+	void RunL();
+private:
+	MBackupParent& iParent;
+	RProcess iChild;
+	MBackupObserver::TFileLockFlags iInstruction;
+	};
+
+class CCmdBackup : public CCommandBase, public MBackupParent
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdBackup();
+private:
+	CCmdBackup();
+
+	// From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+
+	// From MBackupParent
+	virtual void Finished(const TInt aError);
+private:
+	CBackupDriver* iBackup;
+	enum
+		{
+		EStart,
+		EStop
+		} iOperation;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/backup/backup.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// backup.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          backup.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_BACKUP
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+systeminclude   \epoc32\include\fshell
+
+sourcepath      .
+source          backup.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+library         bafl.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/backup/backup_child.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,175 @@
+// backup_child.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32property.h>
+#include <connect/sbdefs.h>
+#include <baBackup.h>
+#include "backup.h"
+
+_LIT(KBackupOp,		"-b");
+_LIT(KRestoreOp,	"-r");
+
+const TInt KIdleTime = 5000000; // microseconds
+
+using namespace conn;
+
+class CBackupAO : public CActive
+	{
+public:
+	static CBackupAO* NewL();
+	~CBackupAO();
+	void Start();
+private:
+	CBackupAO();
+	void ConstructL();
+	void CheckForRestoreFlagL();
+
+	// from CActive
+	void DoCancel();
+	void RunL();
+private:
+	CBaBackupSessionWrapper* iBackupSession;
+	RSemaphore iSem;
+	TBool iRestoreOp;
+	};
+
+
+CBackupAO* CBackupAO::NewL()
+	{
+	CBackupAO* self = new (ELeave) CBackupAO();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBackupAO::CBackupAO():
+CActive(CActive::EPriorityStandard)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CBackupAO::~CBackupAO()
+	{
+	Cancel();
+	delete iBackupSession; // will also issue the ETakeLock to system apps
+	if (iSem.Handle() > 0)
+		iSem.Close();
+	}
+
+void CBackupAO::ConstructL()
+	{
+	iBackupSession = CBaBackupSessionWrapper::NewL();
+	User::LeaveIfError(iSem.CreateGlobal(KBackupSemaphore, 0, EOwnerProcess));
+	CheckForRestoreFlagL();
+	}
+
+void CBackupAO::Start()
+	{
+	iBackupSession->CloseAll(MBackupObserver::EReleaseLockNoAccess, iStatus);
+	SetActive();
+	}
+
+void CBackupAO::RunL()
+	{
+	TInt error = iStatus.Int();
+
+	// check which instruction we must send
+	conn::TBURPartType instruction = conn::EBURBackupFull;
+	if (iRestoreOp)
+		instruction = conn::EBURRestoreFull;
+	
+	// inform subscribed parties of our intentions
+	RProperty bk;
+	if (error == KErrNone)
+		error = bk.Set(KUidSystemCategory, KUidBackupRestoreKey, instruction);
+	
+	// block for a little while to give apps a chance to process the backup instruction
+	User::After(KIdleTime);
+	
+	// inform fshell's backup cmd we've put the system into backup-mode (or not!)
+	RProcess().Rendezvous(error);
+	if (error == KErrNone)
+		{
+		iSem.Wait(); // wait for signal from fshell's backup cmd that we're ok to terminate
+		bk.Set(KUidSystemCategory, KUidBackupRestoreKey, conn::EBURNormal); // ignore the error in this case. what else can I do?
+		}
+
+	// the process has done it's thing
+	CActiveScheduler::Stop();
+	}
+
+void CBackupAO::DoCancel()
+	{
+	ASSERT(iBackupSession);
+	iBackupSession->RestartAll();
+	}
+
+//
+// CBackupAO::CheckForRestoreFlagL
+// determine whether we're issuing a backup or a restore
+//
+void CBackupAO::CheckForRestoreFlagL()
+	{
+	HBufC *buffer = HBufC::NewL(User::CommandLineLength());
+	CleanupStack::PushL(buffer);
+	TPtr cmdline = buffer->Des();
+	User::CommandLine(cmdline);
+	const TInt bPos = cmdline.Find(KBackupOp);
+	const TInt rPos = cmdline.Find(KRestoreOp);
+	CleanupStack::PopAndDestroy(1);
+	if (bPos != KErrNotFound)
+		{
+		if (rPos != KErrNotFound)
+			User::Leave(KErrArgument);
+		iRestoreOp = EFalse;
+		return;
+		}
+	if (rPos != KErrNotFound)
+		{
+		iRestoreOp = ETrue;
+		return;
+		}
+	User::Leave(KErrArgument);
+	}
+
+
+static void RunL()
+	{
+	// Active Scheduler
+	CActiveScheduler* s = new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(s);
+	CActiveScheduler::Install(s);
+
+	CBackupAO* woop = CBackupAO::NewL();
+	CleanupStack::PushL(woop);
+	woop->Start();
+
+	// start the active scheduler
+	CActiveScheduler::Start();
+	CleanupStack::PopAndDestroy(2, s);
+	}
+
+// program entry-point
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	TInt err = KErrNoMemory;
+	if (cleanup)
+		{
+		TRAP(err, RunL());
+		delete cleanup;
+		}
+	__UHEAP_MARKEND;
+	return err;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/backup/backup_child.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// backup_child.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          backup_child.exe
+targettype    	exe
+uid             0 FSHELL_UID_BACKUP_CHILD
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          backup_child.cpp
+
+library         euser.lib
+library			bafl.lib
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btrace/btrace.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,98 @@
+# btrace.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name btrace
+
+==short-description
+
+Configures and fetches data from the btrace buffer.
+
+==long-description
+
+The Symbian OS kernel provides an efficient binary logging mechanism called btrace. This command can be used to configure what data are written to this buffer, and also allows the data to be retrieved. It is functionally similar to the btrace.exe that is released as part of Symbian OS. The main differences are:
+
+=over 5
+
+=item a)
+
+It can repeatedly dump the contents of the buffer each time it gets to a particular percentage full (via the C<-F> and C<-t> options).
+
+=item b)
+
+If run without any arguments or in verbose mode (C<-v>), the current btrace configuration is displayed
+
+=back
+
+When using atrace to configure what is written to the buffer, if any primary filters are specified using the C<-f> option, all filters are disabled, then the buffer is emptied, then the specified filters are switched on (and thus primed). If a mode is specified, it is set before considering filters or filename arguments. Therefore it is a good idea when retrieving data from the buffer (by specifying a filename) to also specify C<-m0> to switch off output, otherwise the writing to file may never complete if atrace data is constantly being written.
+
+The arguments needed to begin profiling are C<-m1 -f3,9,15,18>. Then run C<uprofiler start> as normal. To stop run C<uprofiler stop> (optional), then invoke this command with arguments C<-m0 filename.utf>.
+
+==see-also
+
+L<atrace|atrace>
+
+==argument filename file_name optional
+
+The name of the file to write the current trace buffer contents to.
+
+==option uint f filter multiple
+
+Set a primary filter (for suitable values see C<BTrace::TCategory>, defined in F<\epoc32\include\e32btrace.h>).
+
+==option uint s secondary multiple
+
+Set a secondary filter.
+
+==option uint m mode
+
+Set capture mode (for suitable values see C<RBTrace::TMode>, defined in F<\epoc32\include\d32btrace.h>).
+
+==option uint b buffer
+
+Set the buffer size (in KB).
+
+==option bool d dump
+
+Dump contents of trace buffer to debug port. The data is printed in hexdump format.
+
+==option bool F follow
+
+Monitor the trace buffer and automatically write its contents when it gets to (by default) 50% full.
+
+==option uint t threshold
+
+Set the percentage of data present in the trace buffer that triggers a write. Defaults to 50%. If set to zero, the trace buffer will be flushed every time data is written to it. Intended to be used in conjunction with C<--follow>.
+
+==option bool T timestamp2
+
+Enable the btrace timestamp2 field. This causes each btrace frame to store both the fast counter value and the nano-kernel tick count value (ordinarily only the fast counter value is stored).
+
+==option bool v verbose
+
+Print verbose output.
+
+==option bool e test
+
+Tests that data can be written to and read from btrace successfully.
+
+==option bool r reset
+
+Sets the trace buffer's mode to disabled, discards its current contents and removes all filters.
+
+==option uint c text-trace-mode
+
+Set the kernel text trace mode (C<Kern::SetTextTraceMode>). This is included as a btrace option because the default setting C<ESerialOutDefault> will prevent C<RDebug::Print>s from going to the debugport when btrace is configured to capture rdebug.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btrace/btrace.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,508 @@
+// btrace.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace.h"
+
+#if defined(FSHELL_MEMORY_ACCESS_SUPPORT)
+#define TEXT_TRACE_MODE_SUPPORTED
+#endif
+
+const TInt KMaxCategories = 256;
+const TUint KPrimingStopped = 0x102864BC;
+
+
+
+CCommandBase* CCmdBtrace::NewLC()
+	{
+	CCmdBtrace* self = new(ELeave) CCmdBtrace();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CCmdBtrace::~CCmdBtrace()
+	{
+	iPrimaryFilters.Close();
+	iSecondaryFilters.Close();
+	iBtrace.Close();
+	}
+
+CCmdBtrace::CCmdBtrace()
+	: iThreshold(50)
+	{
+	}
+
+void CCmdBtrace::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CCmdBtrace::Name() const
+	{
+#ifdef BUILDING_ATRACE
+	_LIT(KName, "atrace");
+#else
+	_LIT(KName, "btrace");
+#endif
+	return KName;
+	}
+
+#define CASE_LIT(x) case BTrace:: x : { _LIT(KName, #x); return &KName; }
+#define CASE_REALLY_LIT(x) case x : { _LIT(KName, #x); return &KName; }
+
+const TDesC* BtraceCategoryName(TInt aCategory)
+	{
+	switch (aCategory)
+		{
+		CASE_LIT(ERDebugPrintf)
+		CASE_LIT(EKernPrintf)
+		CASE_LIT(EPlatsecPrintf)
+		CASE_LIT(EThreadIdentification)
+		CASE_LIT(ECpuUsage)
+		CASE_LIT(EKernPerfLog)
+		CASE_LIT(EClientServer)
+		CASE_LIT(ERequests)
+		CASE_LIT(EChunks)
+		CASE_LIT(ECodeSegs)
+		CASE_LIT(EPaging)
+		CASE_LIT(EThreadPriority)
+		CASE_LIT(EPagingMedia)
+		CASE_LIT(EKernelMemory)
+		CASE_LIT(EHeap)
+		CASE_LIT(EMetaTrace)
+		CASE_LIT(ERamAllocator)
+		CASE_LIT(EFastMutex)
+		CASE_LIT(EProfiling)
+		CASE_REALLY_LIT(ExtraBTrace::EPubSub)
+		CASE_REALLY_LIT(ExtraBTrace::EFfsTrace)
+		CASE_LIT(EPlatformSpecificFirst)
+		CASE_LIT(EPlatformSpecificLast)
+		CASE_LIT(ESymbianExtentionsFirst)
+		CASE_LIT(ESymbianExtentionsLast)
+		CASE_LIT(ETest1)
+		CASE_LIT(ETest2)
+		default:
+			{
+			_LIT(KUnknown, "?");
+			return &KUnknown;
+			}
+		}
+	}
+
+void CCmdBtrace::DoRunL()
+	{
+#ifdef TEXT_TRACE_MODE_SUPPORTED
+	if (iOptions.IsPresent(&iTextTraceMode))
+		{
+		LoadMemoryAccessL();
+		const TInt ESerialOutMask = 3; // As per kernel.h
+		TInt err = iMemAccess.SetTextTraceMode(iTextTraceMode, ESerialOutMask);
+		LeaveIfErr(err, _L("Couldn't set text trace mode"));
+		}
+#endif
+
+	TInt i;
+	LeaveIfErr(iBtrace.Open(), _L("Couldn't open RBTrace"));
+
+	if (iOptions.IsPresent(&iReset))
+		{
+		ResetL();
+		}
+
+	if (iOptions.IsPresent(&iBufferSize))
+		{
+		iBtrace.ResizeBuffer(iBufferSize * 1024);
+		}
+
+	if (iOptions.IsPresent(&iMode))
+		{
+		SetMode(iMode);
+		}
+
+	iBtrace.SetTimestamp2Enabled(iEnableTimestamp2);
+
+	const TInt numPrimaryFilters = iPrimaryFilters.Count();
+	if (numPrimaryFilters > 0)
+		{
+		RemovePrimaryFilters();
+		EmptyBuffer();
+
+		// Enable the specified categories.
+		for (i = 0; i < numPrimaryFilters; ++i)
+			{
+			iBtrace.SetFilter(iPrimaryFilters[i], 1);
+			}
+		}
+	if (iTest)
+		{
+		TestL();
+		return;
+		}
+
+	const TInt numSecondaryFilters = iSecondaryFilters.Count();
+	if (numSecondaryFilters > 0)
+		{
+		TUint32* filterArray = new(ELeave) TUint32[iSecondaryFilters.Count()];
+		for (i = 0; i < numSecondaryFilters; ++i)
+			{
+			filterArray[i] = iSecondaryFilters[i];
+			}
+
+		TInt err = iBtrace.SetFilter2(filterArray, numSecondaryFilters);
+		if (err)
+			{
+			PrintError(err, _L("Couldn't set secondary filter"));
+			}
+		else
+			{
+			// Discard old data.
+			EmptyBuffer();
+			}
+
+		delete[] filterArray;
+		}
+
+	if (numPrimaryFilters > 0 || numSecondaryFilters > 0) 
+		{
+		BTrace8(BTrace::EMetaTrace, BTrace::EMetaTraceMeasurementEnd, KPrimingStopped, KPrimingStopped);
+		}
+
+	if (iFileName.Length())
+		{
+		RFile file;
+		User::LeaveIfError(file.Replace(FsL(), iFileName, EFileWrite));
+		file.Close();
+		}
+
+	if (iFileName.Length() || iDumpToRdebug)
+		{
+		if (iFollow)
+			{
+			if (iThreshold > 100)
+				{
+				PrintError(KErrArgument, _L("Invalid threshold percentage"));
+				User::Leave(KErrArgument);
+				}
+			Printf(_L("Hit any key to abort waiting and flush buffer...\r\n"));
+			TInt bytesRequired = (iBtrace.BufferSize() * iThreshold) / 100;
+			TBool finished(EFalse);
+			while (!finished)
+				{
+				TRequestStatus btraceStatus;
+				iBtrace.RequestData(btraceStatus, bytesRequired);
+				TRequestStatus keyStatus;
+				Stdin().WaitForKey(keyStatus);
+				if (iVerbose)
+					{
+					Printf(_L("Waiting for %d bytes in buffer\r\n"), bytesRequired);
+					}
+				User::WaitForRequest(btraceStatus, keyStatus);
+				if (keyStatus == KRequestPending)
+					{
+					Stdin().WaitForKeyCancel();
+					User::WaitForRequest(keyStatus);
+					User::LeaveIfError(btraceStatus.Int());
+					}
+				else
+					{
+					iBtrace.CancelRequestData();
+					User::WaitForRequest(btraceStatus);
+					finished = ETrue;
+					}
+
+				DumpL();
+				}
+			}
+		else
+			{
+			DumpL();
+			}
+		}
+
+	if (iVerbose || (iFileName.Length() == 0))
+		{
+		Printf(_L("Buffer size: %d\r\n"), iBtrace.BufferSize());
+		Printf(_L("Mode: %S (%u)\r\n"), ModeText(iBtrace.Mode()), iBtrace.Mode());
+#ifdef TEXT_TRACE_MODE_SUPPORTED
+		LoadMemoryAccessL();
+		TUint traceMode = 0;
+		TInt err = iMemAccess.SetTextTraceMode(traceMode, 0);
+		if (err)
+			{
+			PrintWarning(_L("Couldn't read text trace mode: err=%d"), err);
+			}
+		else
+			{
+			_LIT(KHuh, "<?>");
+			const TDesC* name = &KHuh;
+#define CASE_LIT2(x, y) case x: { _LIT(KName, #y); name = &KName; break; }
+			switch (traceMode)
+				{
+				CASE_LIT2(0, ESerialOutDefault)
+				CASE_LIT2(1, ESerialOutNever)
+				CASE_LIT2(2, ESerialOutAlways)
+				default:
+					break;
+				}
+			Printf(_L("Text trace mode: %S (%d)\r\n"), name, traceMode);
+			}
+#endif
+		Printf(_L("Primary filters:\r\n"));
+		TBool foundOne(EFalse);
+		for (TInt i = 0; i < KMaxCategories; ++i)
+			{
+			if (iBtrace.Filter(i) == 1)
+				{
+				Printf(_L("\t%d (%S)\r\n"), i, BtraceCategoryName(i));
+				foundOne = ETrue;
+				}
+			}
+		if (!foundOne)
+			{
+			Write(_L("\tnone\r\n"));
+			}
+		Printf(_L("Secondary filters: "));
+		TInt globalFilter;
+		TUint32* uids;
+		TInt ret = iBtrace.Filter2(uids, globalFilter);
+		if (ret >= 0)
+			{
+			if (globalFilter)
+				{
+				Printf(_L("[Secondary filters accept]\r\n"));
+				}
+			else
+				{
+				Printf(_L("[Secondary filters reject]\r\n"));
+				}
+			if (ret > 0)
+				{
+				for (TInt i = 0; i < ret; ++i)
+					{
+					Printf(_L("\t0x%08x\r\n"), uids[i]);
+					}
+				}
+			else
+				{
+				Write(_L("\tnone\r\n"));
+				}
+			delete uids;
+			}
+		else
+			{
+			PrintError(ret, _L("Unable to read secondary filters"));
+			}
+		}
+	}
+
+void CCmdBtrace::DumpL()
+	{
+	RFile file;
+	if (iFileName.Length())
+		{
+		if (iVerbose)
+			{
+			Printf(_L("Opening \"%S\"\r\n"), &iFileName);
+			}
+		User::LeaveIfError(file.Open(FsL(), iFileName, EFileWrite));
+		CleanupClosePushL(file);
+		TInt pos = 0;
+		User::LeaveIfError(file.Seek(ESeekEnd, pos));
+		}
+
+	TUint8* data;
+	TInt size;
+	TInt err = KErrNone;
+	while ((size = iBtrace.GetData(data)) != 0)
+		{
+		if (file.SubSessionHandle() && (err == KErrNone))
+			{
+			if (iVerbose)
+				{
+				Printf(_L("Writing %d bytes to \"%S\"\r\n"), size, &iFileName);
+				}
+			err = file.Write(TPtrC8(data,size));
+			if (err)
+				{
+				PrintError(err, _L("Couldn't write to file"));
+				}
+			}
+
+		if (iDumpToRdebug)
+			{
+			if (iVerbose)
+				{
+				Printf(_L("Writing %d bytes to LtkUtils::HexDumpToRDebug\r\n"), size);
+				}
+			LtkUtils::HexDumpToRDebug(TPtrC8(data, size));
+			}
+
+		iBtrace.DataUsed();
+		}
+
+	User::LeaveIfError(err);
+	if (iFileName.Length())
+		{
+		CleanupStack::PopAndDestroy(&file);
+		}
+	}
+
+void CCmdBtrace::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFiles, "file_name");
+	aArguments.AppendFileNameL(iFileName, KArgFiles);
+	}
+
+void CCmdBtrace::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptPrimaryFilter, "filter");
+	aOptions.AppendUintL(iPrimaryFilters, KOptPrimaryFilter);
+
+	_LIT(KOptSecondaryFilter, "secondary");
+	aOptions.AppendUintL(iSecondaryFilters, KOptSecondaryFilter);
+
+	_LIT(KOptMode, "mode");
+	aOptions.AppendUintL(iMode, KOptMode);
+
+	_LIT(KOptBufferSize, "buffer");
+	aOptions.AppendUintL(iBufferSize, KOptBufferSize);
+
+	_LIT(KOptDump, "dump");
+	aOptions.AppendBoolL(iDumpToRdebug, KOptDump);
+
+	_LIT(KOptFollow, "follow");
+	aOptions.AppendBoolL(iFollow, KOptFollow);
+
+	_LIT(KOptThreshold, "threshold");
+	aOptions.AppendUintL(iThreshold, KOptThreshold);
+
+	_LIT(KOptTimestamp2, "timestamp2");
+	aOptions.AppendBoolL(iEnableTimestamp2, KOptTimestamp2);
+
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptTest, "test");
+	aOptions.AppendBoolL(iTest, KOptTest);
+
+	_LIT(KOptReset, "reset");
+	aOptions.AppendBoolL(iReset, KOptReset);
+
+#ifdef TEXT_TRACE_MODE_SUPPORTED
+	_LIT(KOptTextTraceMode, "text-trace-mode");
+	aOptions.AppendUintL(iTextTraceMode, KOptTextTraceMode);
+#endif
+	}
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdBtrace)
+#endif
+
+void CCmdBtrace::TestL()
+	{
+	SetMode(RBTrace::EEnable);
+	EmptyBuffer();
+	iBtrace.SetFilter(BTrace::ESymbianExtentionsFirst, 1);
+	_LIT8(KHello, "Hello world of btrace!!!");
+	TInt res = BTraceBig(BTrace::ESymbianExtentionsFirst, 0, 0, KHello().Ptr(), KHello().Size());
+	Printf(_L8("Writing text '%S' to btrace returned %d...\r\n"), &KHello, res);
+
+	TUint8* data;
+	TInt size;
+	TInt err = KErrNotFound;
+	while ((size = iBtrace.GetData(data)) != 0 && err == KErrNotFound)
+		{
+		Printf(_L("Read a buffer of size %d\r\n"), size);
+		TPtrC8 ptr(data, size);
+		if (ptr.Find(KHello) >= 0)
+			{
+			Printf(_L("Found text ok.\r\n"));
+			err = KErrNone;
+			}
+		}
+	if (err == KErrNotFound)
+		{
+		Printf(_L("Failed to find the test data\r\n"));
+		}
+	}
+
+void CCmdBtrace::ResetL()
+	{
+	SetMode(0);
+	EmptyBuffer();
+	RemovePrimaryFilters();
+	RemoveSecondaryFiltersL();
+	}
+
+void CCmdBtrace::SetMode(TUint aMode)
+	{
+	if (iVerbose)
+		{
+		Printf(_L("Setting mode to \"%S\" (%u)\r\n"), ModeText(aMode), aMode);
+		}
+
+	iBtrace.SetMode(aMode);
+	}
+
+void CCmdBtrace::EmptyBuffer()
+	{
+	if (iVerbose)
+		{
+		Write(_L("Discarding contents of trace buffer...\r\n"));
+		}
+
+	iBtrace.Empty();
+	}
+
+void CCmdBtrace::RemovePrimaryFilters()
+	{
+	if (iVerbose)
+		{
+		Write(_L("Removing all primary filters...\r\n"));
+		}
+
+	for (TInt i = 0; i < KMaxCategories; ++i)
+		{
+		iBtrace.SetFilter(i, 0);
+		}
+	}
+
+void CCmdBtrace::RemoveSecondaryFiltersL()
+	{
+	if (iVerbose)
+		{
+		Write(_L("Removing all secondary filters...\r\n"));
+		}
+
+	LeaveIfErr(iBtrace.SetFilter2((const TUint32*)NULL, 0), _L("Couldn't remove all secondary filters"));
+	}
+
+const TDesC* CCmdBtrace::ModeText(TUint aMode) const
+	{
+	_LIT(KDisabled, "disabled");
+	_LIT(KEnabled, "enabled");
+	_LIT(KFreeRunning, "enabled and free running");
+	_LIT(KUnknown, "unknown");
+
+	switch (aMode)
+		{
+		case 0:
+			return &KDisabled;
+		case RBTrace::EEnable:
+			return &KEnabled;
+		case RBTrace::EEnable | RBTrace::EFreeRunning:
+			return &KFreeRunning;
+		default:
+			return &KUnknown;
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btrace/btrace.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,60 @@
+// btrace.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+#include <fshell/extrabtrace.h>
+#include FSHELL_D32BTRACE_HEADER
+#include <fshell/iocli.h>
+#include <fshell/ioutils.h>
+#include <fshell/memoryaccesscmd.h>
+#include <fshell/ltkutils.h>
+
+using namespace IoUtils;
+
+class CCmdBtrace : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdBtrace();
+protected:
+	CCmdBtrace();
+	void ConstructL();
+	void DumpL();
+	void TestL();
+	void ResetL();
+	void SetMode(TUint aMode);
+	void EmptyBuffer();
+	void RemovePrimaryFilters();
+	void RemoveSecondaryFiltersL();
+	const TDesC* ModeText(TUint aMode) const;
+protected: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+protected:
+	TFileName2 iFileName;
+	RArray<TUint> iPrimaryFilters;
+	RArray<TUint> iSecondaryFilters;
+	TUint iMode;
+	TUint iBufferSize;
+	TBool iDumpToRdebug;
+	TBool iFollow;
+	TUint iThreshold;
+	TBool iEnableTimestamp2;
+	TBool iVerbose;
+	TBool iTest;
+	TBool iReset;
+	RBTrace iBtrace;
+	TUint iTextTraceMode;
+	TBool iBuildConfig;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btrace/btrace.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// btrace.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_btrace.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_BTRACE
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          btrace.cpp
+
+library         euser.lib
+library         iocli.lib
+library         btracec.lib
+library         efsrv.lib
+library         ltkutils.lib
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btraceout/btraceout.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+# btraceout.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name btraceout
+
+==short-description
+
+Create btrace output either from command-line arguments, or optionally from data read from C<stdin>.
+
+==long-description
+
+Chooses an appropriate C<BTraceXxx> macro based on the supplied arguments and options. When reading data from C<stdin>, uses C<BTraceBig> (which will generate a multipart frame if the data is too large for one frame) unless C<--truncate> is specified (in which case C<BTraceN> is used even if it causes truncation).
+
+==see-also
+
+L<btrace|btrace>, L<atrace|atrace>
+
+==argument uint category
+
+The btrace category to use. Must be 0-255.
+
+==argument uint subcategory
+
+The btrace subcategory to use. Must be 0-255.
+
+==argument uint arg_1 optional
+
+The first btrace argument.
+
+==argument uint arg_2 optional
+
+The second btrace argument.
+
+==argument uint arg_3 optional
+
+The third btrace argument.
+
+==option bool s stdin
+
+Read data from stdin.
+
+==option bool t truncate
+
+Write the data using C<BTraceN> instead of C<BTraceBig>, even if this means the data gets truncated. Can only be used with C<--stdin>.
+
+==option uint f filter
+
+Specify a secondary filter UID on the btrace output.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btraceout/btraceout.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,190 @@
+// btraceout.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/extrabtrace.h>
+
+using namespace IoUtils;
+
+class CCmdBtraceout : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdBtraceout();
+private:
+	CCmdBtraceout();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TUint iCategory;
+	TUint iSubcategory;
+	TUint iArg1;
+	TUint iArg2;
+	TUint iArg3;
+	TBool iStdin;
+	TUint iFilterUid;
+	TBool iTruncate;
+	};
+
+CCommandBase* CCmdBtraceout::NewLC()
+	{
+	CCmdBtraceout* self = new(ELeave) CCmdBtraceout();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdBtraceout::~CCmdBtraceout()
+	{
+	}
+
+CCmdBtraceout::CCmdBtraceout()
+	{
+	}
+
+const TDesC& CCmdBtraceout::Name() const
+	{
+	_LIT(KName, "btraceout");	
+	return KName;
+	}
+
+void CCmdBtraceout::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendUintL(iCategory, _L("category"));
+	aArguments.AppendUintL(iSubcategory, _L("subcategory"));
+	aArguments.AppendUintL(iArg1, _L("arg_1"));
+	aArguments.AppendUintL(iArg2, _L("arg_2"));
+	aArguments.AppendUintL(iArg3, _L("arg_3"));
+	}
+
+void CCmdBtraceout::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iStdin, _L("stdin"));
+	aOptions.AppendBoolL(iTruncate, _L("truncate"));
+	aOptions.AppendUintL(iFilterUid, _L("filter"));
+	}
+
+
+EXE_BOILER_PLATE(CCmdBtraceout)
+
+void CCmdBtraceout::DoRunL()
+	{
+	if (iStdin)
+		{
+		CTextBuffer* buffer = CTextBuffer::NewLC(512);
+		Stdin().SetReadMode(RIoReadHandle::EOneOrMore);
+		TBuf<256> buf;
+		while (Stdin().Read(buf) == KErrNone)
+			{
+			buffer->AppendL(buf);
+			}
+		RBuf8 data;
+		data.CreateL(buffer->Length());
+		data.Copy(buffer->Descriptor()); // This will collapse us back to real 8-bit data
+
+		if (iTruncate)
+			{
+			if (iOptions.IsPresent(&iFilterUid))
+				{
+				if (iArguments.IsPresent(3))
+					{
+					PrintWarning(_L("Ignoring 'arg_2' (%u) and all following arguments"), iArg2);
+					}
+				BTraceFilteredN(iCategory, iSubcategory, iFilterUid, iArg1, data.Ptr(), data.Size());
+				}
+			else
+				{
+				if (iArguments.IsPresent(3))
+					{
+					PrintWarning(_L("Ignoring 'arg_3' (%u)"), iArg3);
+					}
+				BTraceN(iCategory, iSubcategory, iArg1, iArg2, data.Ptr(), data.Size());
+				}
+			}
+		else
+			{
+			if (iOptions.IsPresent(&iFilterUid))
+				{
+				if (iArguments.IsPresent(2))
+					{
+					PrintWarning(_L("Ignoring 'arg_1' (%u) and all following arguments"), iArg1);
+					}
+				BTraceFilteredBig(iCategory, iSubcategory, iFilterUid, data.Ptr(), data.Size());
+				}
+			else
+				{
+				if (iArguments.IsPresent(3))
+					{
+					PrintWarning(_L("Ignoring 'arg_2' (%u) and all following arguments"), iArg2);
+					}
+				BTraceBig(iCategory, iSubcategory, iArg1, data.Ptr(), data.Size());
+				}
+			}
+
+		data.Close();
+		CleanupStack::PopAndDestroy(buffer);
+		}
+	else
+		{
+		if (iArguments.IsPresent(4))
+			{
+			if (iOptions.IsPresent(&iFilterUid))
+				{
+				if (iArguments.IsPresent(3))
+					{
+					PrintWarning(_L("Ignoring 'arg_3' (%u)"), iArg3);
+					}
+				BTraceFiltered12(iCategory, iSubcategory, iFilterUid, iArg1, iArg2);
+				}
+			else
+				{
+				BTrace12(iCategory, iSubcategory, iArg1, iArg2, iArg3);
+				}
+			}
+		else if (iArguments.IsPresent(3))
+			{
+			if (iOptions.IsPresent(&iFilterUid))
+				{
+				BTraceFiltered12(iCategory, iSubcategory, iFilterUid, iArg1, iArg2);
+				}
+			else
+				{
+				BTrace8(iCategory, iSubcategory, iArg1, iArg2);
+				}
+			}
+		else if (iArguments.IsPresent(2))
+			{
+			if (iOptions.IsPresent(&iFilterUid))
+				{
+				BTraceFiltered8(iCategory, iSubcategory, iFilterUid, iArg1);
+				}
+			else
+				{
+				BTrace4(iCategory, iSubcategory, iArg1);
+				}
+			}
+		else
+			{
+			if (iOptions.IsPresent(&iFilterUid))
+				{
+				BTraceFiltered4(iCategory, iSubcategory, iFilterUid);
+				}
+			else
+				{
+				BTrace0(iCategory, iSubcategory);
+				}
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btraceout/btraceout.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// btraceout.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          btraceout.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_BTRACEOUT
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          btraceout.cpp
+
+FSHELL_TRACE_LIBRARY
+library         euser.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btservices/BtData.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,59 @@
+// BtData.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef BTDATA_H_
+#define BTDATA_H_
+
+struct TUUidPair
+	{
+	TUint32 uuid;
+	TPtrC txt;
+	};
+
+const TUUidPair UuidAsArray[] = 
+	{
+			{0x0001,_L("SDP") },
+			{0x0003,_L("RFCOMM") },
+			{0x0005,_L("TCS-BIN") },
+			{0x0100,_L("L2CAP") },
+			{0x0009,_L("IP") },
+			{0x0002,_L("UDP") },
+			{0x0004,_L("TCP") },
+			{0x0006,_L("TCS-AT") },
+			{0x0008,_L("OBEX") },
+			{0x000A,_L("FTP") },
+			{0x000C,_L("HTTP") },
+			{0x000E,_L("WSP") },
+			{0x1000,_L("ServiceDiscoveryServerServiceClassID") },
+			{0x1001,_L("BrowseGroupDescriptorServiceClassID") },
+			{0x1002,_L("PublicBrowseGroup") },
+			{0x1101,_L("SerialPort") },
+			{0x1102,_L("LANAccessUsingPPP") },
+			{0x1103,_L("DialupNetworking") },
+			{0x1104,_L("IrMCSync") },
+			{0x1105,_L("OBEXObjectPush") },
+			{0x1106,_L("OBEXFileTransfer") },
+			{0x1107,_L("IrMCSyncCommand")},
+			{0x1108,_L("Headset")},
+			{0x1109,_L("CordlessTelephony")},
+			{0x1110,_L("Intercom")},
+			{0x1111,_L("Fax")},
+			{0x1112,_L("HeadsetAudioGateway")},
+			{0x1113,_L("WAP")},
+			{0x1114,_L("WAP_CLIENT")},
+			{0x1200,_L("PnPInformation")},
+			{0x1201,_L("GenericNetworking")},
+			{0x1202,_L("GenericFileTransfer")},
+			{0x1203,_L("GenericAudio")},
+			{0x1204,_L("GenericTelephony")}				
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btservices/BtServiceView.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// BtServiceView.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef BTSERVICEVIEW_H_
+#define BTSERVICEVIEW_H_
+
+const TInt KMaxDescriptorLength = 256;
+
+//this class can be used as Interface to receive progress information 
+//from CBtServicesEng
+//
+class CBtServiceView
+	{
+public:
+	CBtServiceView();
+	virtual ~CBtServiceView();
+	
+	virtual void PrintTextMsg(TInt aVerboseLevel, const TDesC& aMsg);
+	virtual void AsyncCompleted();
+	
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btservices/BtServicesEng.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,989 @@
+// BtServicesEng.cpp
+// 
+// Copyright (c) 2003 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+//#include <qbtselectdlg.h>
+
+#include <e32debug.h>
+
+#include <utf.h>
+#include "BtData.h"
+#include "btserviceseng.h"
+#include <btmanclient.h>
+//#include <MQikListBoxData.h>
+
+const TInt KArrayIncrement = 5;
+const TInt KMaxServiceNameLength = 256;
+const TInt KDefaultLanguage = 0x0100;
+const TInt KIndentationFactor = 3;
+
+_LIT(KTextHexPrefix,"0x");
+
+CBtServicesEng::CBtServicesEng()
+	{
+	iSdpAgent = NULL;
+	iSearchPattern = NULL;
+	iAttributeArray = NULL;
+	
+	iView = NULL;
+	
+	iAttributeMatchList = NULL;
+	iAttributeBuilder = NULL;
+	
+	iUUIDFilter = (KL2CAP);
+	}
+
+CBtServicesEng::~CBtServicesEng()
+	{
+	delete iSdpAgent; // no need to Cancel separately
+	delete iSearchPattern;
+	if (iAttributeArray)
+		{
+		iAttributeArray->Reset();
+		delete iAttributeArray;
+		}
+	iRecordArray.ResetAndDestroy();
+	delete iAttributeMatchList;
+	delete iAttributeBuilder;
+
+	iSocketServ.Close();
+	iUUIDs.Close();
+	iUUIDsAsText.ResetAndDestroy();
+	iUUIDsAsText.Close();
+
+	iErrorCodes.Close();
+	iErrorMessages.ResetAndDestroy();
+	iErrorMessages.Close();
+	}
+
+CBtServicesEng* CBtServicesEng::NewL()
+	{
+	CBtServicesEng* self = new(ELeave) CBtServicesEng();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+void CBtServicesEng::ConstructL()
+	{
+	//iEikon = CEikonEnv::Static();
+
+	iSearchPattern = CSdpSearchPattern::NewL();
+	iAttributeArray = new(ELeave) CDesCArrayFlat(KArrayIncrement);
+	iAttributeBuilder = CBtAttributeBuilder::NewL(*this);
+
+	//read the available filter UUID and corresponding text
+	TInt arrayCount = sizeof(UuidAsArray) / sizeof(TUUidPair);
+	RDebug::Printf("CBtServicesEng::ConstructL() arrayCount= %d \r\n", 
+			arrayCount);
+	
+	TInt i;
+	for (i = 0; i < arrayCount; i++)
+		{
+		TUint32 uuid = UuidAsArray[i].uuid;
+		iUUIDs.Append(TUUID(uuid));
+		
+		HBufC* textForm = HBufC::NewL(64);
+		RDebug::Printf("i=%d HBufC* textForm = 0x%08x \r\n", 
+				i, textForm);
+
+		RDebug::Printf("i=%d HBufC* textForm = 0x%08x \r\n", 
+				i, textForm);
+	
+		TPtrC UuidText = UuidAsArray[i].txt;
+		RDebug::Print(_L("UuidText: %S \r\n"), &UuidText);
+
+		*textForm = UuidText;
+				
+		iUUIDsAsText.Append(textForm);
+		}
+
+	//==================================================
+	/*
+	buf = iEikon->AllocReadResourceAsDes8LC(R_BLUETOOTH_ERROR_MESSAGES);
+	res.SetBuffer(buf);
+	arrayCount = res.ReadInt16();
+	for (i = 0; i < arrayCount; i++)
+		{
+		TInt errorCode = res.ReadInt32();
+		iErrorCodes.Append(errorCode);
+		HBufC* message = res.ReadHBufCL();
+		iErrorMessages.Append(message);
+		}
+	CleanupStack::PopAndDestroy(); // buf
+	*/
+
+	User::LeaveIfError(iSocketServ.Connect());
+	}
+
+void CBtServicesEng::ReportMessage(TInt aVerboseLevel, TRefByValue<const TDesC> aFmt, ...)
+	{
+	if (iView)
+		{
+		VA_LIST list;
+		VA_START(list, aFmt);
+		iTextBuf.FormatList(aFmt, list);
+		iView->PrintTextMsg(aVerboseLevel, iTextBuf);
+		}
+	}
+
+//generate a text list of UUID value/string
+void CBtServicesEng::MakeTextUUIDList()
+	{
+	TInt arrayCount = sizeof(UuidAsArray) / sizeof(TUUidPair);
+	TInt i;
+	ReportMessage(0, _L("========================\r\n"));	
+	ReportMessage(0, _L("UUID Value | UUID STRING\r\n"));	
+	ReportMessage(0, _L("========================\r\n"));	
+	for (i = 0; i < arrayCount; i++)
+		{
+		TUint32 uuid = UuidAsArray[i].uuid;
+		TPtrC string = UuidAsArray[i].txt;
+		
+		ReportMessage(0, _L("0x%08x | %S\r\n"), uuid, &string);
+		}
+	}
+
+//This function should only be called after NewDeviceSelectedL() asynchrnously completes; 
+//generate a text list of services found (handle and name)
+//
+void CBtServicesEng::MakeTextServiceList()
+	{
+	TInt i;
+	
+	TPtrC UuidStr = UUIDToString(iUUIDFilter);
+	ReportMessage(0, _L("UUID filter 0x%08x %S\r\n"), iUUIDFilter, &UuidStr);			
+	
+	TInt HandlesCnt = iRecordArray.Count();
+	
+	if (HandlesCnt)
+		{
+		ReportMessage(0, _L("============================\r\n"));		
+		ReportMessage(0, _L("ServiceHandle | Service Name\r\n"));		
+		ReportMessage(0, _L("============================\r\n"));		
+		}
+	
+	for (i=0; i<HandlesCnt; i++)
+		{
+		TSdpServRecordHandle Handle = iRecordArray[i]->iHandle;
+		const TDesC& Name = iRecordArray[i]->iServiceName;
+		
+		ReportMessage(0, _L("0x%08x    | \"%S\"\r\n"), Handle, &Name);
+		
+		}
+		
+	}
+
+//
+void CBtServicesEng::NewDeviceSelectedL(const TBTDevAddr& aAddress,const TBTDeviceName& aDeviceName)
+	{
+	iDeviceName = aDeviceName;
+	iDeviceAddress = aAddress;
+
+	GetDeviceServicesL();
+	}
+
+/**
+This starts the SDP agent searching for services.
+Firstly, the previous (if any) SDP agent is deleted and a
+new one constructed with the address of the new device. The
+record filter is set based on the UUID filter settings.
+The NextRecordRequestL() function begins the search, with the
+results being received via the MSdpAgentNotifier functions.
+*/
+void CBtServicesEng::GetDeviceServicesL()
+	{
+	if (iSdpAgent)
+		{
+		DeleteSdpAgent();
+		}
+	iSdpAgent = CSdpAgent::NewL(*this, iDeviceAddress); // create new SDP Agent for given device address
+
+	iSearchPattern->Reset();
+	iSearchPattern->AddL(iUUIDFilter);
+	iSdpAgent->SetRecordFilterL(*iSearchPattern);
+
+	iRecordArray.ResetAndDestroy();
+//	MQikListBoxModel& model = *this;
+//	model.RemoveAllDataL();
+	//iView->ListBox().HandleItemRemovalL();
+	//iView->ListBox().DrawNow();
+
+	/*
+	TGulAlignment position(EHRightVCenter);
+	_LIT(KMsgFindingServices, "Finding services");
+	iView->GetEikonEnv()->BusyMsgL(KMsgFindingServices, position);
+	iView->DimCancelButton(EFalse);
+	iView->DimRefreshButton(ETrue);
+	 */
+	
+	iSdpAgent->NextRecordRequestL();
+	}
+
+/**
+The Sdp agent initially returns only record handles for each
+service - this function then gets the name attribute for
+each one.
+*/
+void CBtServicesEng::GetServiceNamesL()
+	{
+	if (iHandleCounter < iRecordArray.Count())
+		{
+		TSdpAttributeID attributeID = KSdpAttrIdOffsetServiceName + KDefaultLanguage; // only support default language for SDP
+		iSdpAgent->AttributeRequestL(iRecordArray[iHandleCounter]->iHandle, 
+				attributeID);
+				
+		ReportMessage(1, _L("Query service name for handle 0x%X...\r\n"), 
+				iRecordArray[iHandleCounter]->iHandle );
+		}
+	else
+		{
+		iCurrentAttributeRequest = ENoOutstandingRequests;		
+//		iView->GetEikonEnv()->BusyMsgCancel();
+//		iView->DimCancelButton(ETrue);
+//		iView->DimRefreshButton(EFalse);
+		
+		if (iView)
+			iView->AsyncCompleted();
+		}
+	}
+
+/**
+Begins getting the full attribute list
+for a given service. Because an MSdpElementBuilder
+pointer is passed in AttributeRequestL(), the SDP agent
+calls the builder functions with each result, rather than
+AttributeRequestResult(). 
+*/
+void CBtServicesEng::GetAttributesL(TInt aIndex)
+	{
+	iCurrentAttributeRequest = EGettingAllAttributes;
+	iServiceName.Set(iRecordArray[aIndex]->iServiceName);
+	iAttributeArray->Reset();
+	iAttributeBuilder->Reset();
+	if (iAttributeMatchList)
+		{
+		delete iAttributeMatchList;
+		iAttributeMatchList = NULL;
+		}
+	iAttributeMatchList = CSdpAttrIdMatchList::NewL();
+	iAttributeMatchList->AddL(TAttrRange(0, KMaxTUint16)); // getting all attributes
+	iAttributeBuilder->SetHandle(iRecordArray[aIndex]->iHandle);
+	iSdpAgent->AttributeRequestL(iAttributeBuilder, iRecordArray[aIndex]->iHandle, *iAttributeMatchList);
+	}
+
+/**
+this function is supposed to be called 
+WITHOUT calling "NewDeviceSelectedL()"
+
+Begins getting the full attribute list
+for a given service. Because an MSdpElementBuilder
+pointer is passed in AttributeRequestL(), the SDP agent
+calls the builder functions with each result, rather than
+AttributeRequestResult(). 
+*/
+void CBtServicesEng::GetDeviceAttributesL(const TBTDevAddr& aAddress,const TBTDeviceName& aDeviceName, TSdpServRecordHandle aHandle)
+	{
+	iDeviceName = aDeviceName;
+	iDeviceAddress = aAddress;
+	if (iSdpAgent)
+		{
+		DeleteSdpAgent();
+		}
+	iSdpAgent = CSdpAgent::NewL(*this, iDeviceAddress); // create new SDP Agent for given device address
+		
+	iCurrentAttributeRequest = EGettingAllAttributes;
+	//iServiceName.Set((*iTextArray)[aIndex]);
+	iAttributeArray->Reset();
+	iAttributeBuilder->Reset();
+	if (iAttributeMatchList)
+		{
+		delete iAttributeMatchList;
+		iAttributeMatchList = NULL;
+		}
+	iAttributeMatchList = CSdpAttrIdMatchList::NewL();
+	iAttributeMatchList->AddL(TAttrRange(0, KMaxTUint16)); // getting all attributes
+	iAttributeBuilder->SetHandle(aHandle);
+	iSdpAgent->AttributeRequestL(iAttributeBuilder, aHandle, *iAttributeMatchList);
+	}
+
+
+void CBtServicesEng::CancelSdpAgent()
+	{
+	if (iSdpAgent)
+		{
+		iSdpAgent->Cancel();
+		}
+	}
+
+void CBtServicesEng::DeleteSdpAgent()
+	{
+	delete iSdpAgent;
+	iSdpAgent = NULL;
+	}
+
+void CBtServicesEng::SetUUIDFilterL(TUint32 aUUID)
+	{
+	iUUIDFilter = aUUID;
+	}
+
+void CBtServicesEng::AppendUUIDText(TDes& aBuf, TUUID aUUID) const
+	{
+	if (aUUID == TUUID(0))
+		{
+		aUUID = TUUID(iUUIDFilter);
+		}
+	TInt i = 0;
+	TInt UuidCount = iUUIDs.Count();
+	for (i = 0; i < UuidCount; i++)
+		{
+		if (iUUIDs[i] == aUUID)
+			{
+			aBuf.Append(*(iUUIDsAsText[i]));
+			return;
+			}
+		}
+	_LIT(KTextUUIDHex,"UUID: 0x");
+	aBuf.Append(KTextUUIDHex);
+	
+	const TPtrC8 ptr = aUUID.ShortestForm();
+	TInt ShortestLength = ptr.Length();
+	for (i = 0; i<ShortestLength ; i++) // get shortest form
+		{
+		aBuf.AppendNumFixedWidth(aUUID[i],EHex,2);
+		}
+	}
+
+void CBtServicesEng::DisplayDeviceInfoL()
+	{
+//	iView->DisplayDeviceInfoDialogL(iDeviceName,iDeviceAddress,iDeviceClass);
+	}
+
+//display local BT address, device name and class info
+//
+void CBtServicesEng::DisplayLocalInfoL()
+	{
+	/*
+	RSocket l2CapSock;
+	TInt err = l2CapSock.Open(iSocketServ, KBTAddrFamily, KSockSeqPacket, KL2CAP);
+	if (err != KErrNone)
+		{
+		_LIT(KErrorText,"Not supported");
+		TGulAlignment position(EHRightVTop);
+		iView->GetEikonEnv()->InfoMsgWithAlignmentAndDuration(position,KErrorText,KErrorMsgDuration);
+		return;
+		}
+	CleanupClosePushL(l2CapSock);
+	TRequestStatus stat;
+	
+	TBTDevAddrPckg addrbuf;
+	l2CapSock.Ioctl(KHCILocalAddressIoctl, stat, &addrbuf, KSolBtHCI); // takes a TBTDevAddrPckg (TPckgBuf<TBTDevAddr>) as documented in 7.0 SDK
+	User::WaitForRequest(stat);
+	User::LeaveIfError(stat.Int());
+
+	THCIDeviceClassBuf classbuf;
+	l2CapSock.Ioctl(KHCIReadDeviceClassIoctl, stat, &classbuf, KSolBtHCI); // takes a THCIDeviceClassBuf (TPckgBuf<THCIDeviceClassIoctl>) as documented in 7.0 SDK
+	User::WaitForRequest(stat);
+	User::LeaveIfError(stat.Int());
+	CleanupStack::PopAndDestroy(); // l2CapSock
+
+	RHostResolver hr;
+	User::LeaveIfError(hr.Open(iSocketServ, KBTAddrFamily, KBTLinkManager));
+	CleanupClosePushL(hr);
+	TBTDeviceName deviceName;
+	User::LeaveIfError(hr.GetHostName(deviceName));
+	CleanupStack::PopAndDestroy();
+
+	TBTDevAddr& deviceAddress = addrbuf();
+	TBTDeviceClass deviceClass(classbuf().iMajorServiceClass, classbuf().iMajorDeviceClass,classbuf().iMinorDeviceClass);
+	*/
+
+	RBTRegServ serv;
+	RBTLocalDevice me;
+	User::LeaveIfError(serv.Connect());
+	CleanupClosePushL(serv);
+	User::LeaveIfError(me.Open(serv));
+	CleanupClosePushL(me);
+	TBTLocalDevice dev;
+	User::LeaveIfError(me.Get(dev));
+
+	TBTDeviceName deviceName;
+	deviceName.Copy(dev.DeviceName().Left(deviceName.MaxLength()));
+	TBTDeviceClass deviceClass(dev.DeviceClass());
+	// RBtLocalDevice doesn't seem to return the address
+	//const TBTDevAddr& deviceAddress = dev.Address();
+	TBTDevAddr deviceAddress;
+	TPtr8 ptr(deviceAddress.Des());
+	User::LeaveIfError(RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetLocalDeviceAddress, ptr));
+
+	CleanupStack::PopAndDestroy(2, &serv);
+	
+	TBuf<64> ReadableAddr;
+	deviceAddress.GetReadable(ReadableAddr);
+	ReportMessage(0, _L("BTAddress:0x%S, Name:\"%S\", DeviceClass=0x%08x\r\n"), 
+			&ReadableAddr, &deviceName, deviceClass.DeviceClass());
+
+	/*
+#if 0 //test code, not used	
+	//query further about the services provided by this device
+	RSdp sdp;
+	sdp.Connect();
+	CleanupClosePushL(sdp);
+		
+	RSdpDatabase sdpData;
+	sdpData.Open(sdp);
+	CleanupClosePushL(sdpData);				
+
+	CleanupStack::PopAndDestroy();
+	CleanupStack::PopAndDestroy();
+#endif	
+	*/
+	}
+
+
+void CBtServicesEng::SetView(CBtServiceView* apView)
+	{
+	iView = apView;
+	}
+	
+
+/*
+CDesCArrayFlat* CBtServicesEng::GetTextArray() const
+	{
+	return iTextArray;
+	}
+*/
+
+/**
+Checks whether bluetooth is enabled by opening a host
+resolver and immediately closing it again.
+*/
+TInt CBtServicesEng::BluetoothReady()
+	{
+	RHostResolver hr;
+	TInt err = hr.Open(iSocketServ, KBTAddrFamily, KBTLinkManager); // just to check if bluetooth is enabled
+	hr.Close();
+	return err;
+	}
+
+TBool CBtServicesEng::GettingAllAttributes() const
+	{
+	return (iCurrentAttributeRequest == EGettingAllAttributes);
+	}
+
+void CBtServicesEng::AddAttributeLineL(const TDesC& aDes)
+	{
+	iAttributeArray->AppendL(aDes);
+	}
+
+void CBtServicesEng::AttributeRequestComplete(TSdpServRecordHandle  aHandle, TInt aError)
+	{
+	ReportMessage(1, _L("[AttributeRequestComplete for Handle:0x%X Err:%d]\r\n\r\n"), aHandle, aError);
+	
+	if(aError == KErrNone)
+		{
+		TRAP(aError, DoAttributeRequestCompleteL());
+		}
+	if(aError != KErrNone)
+		{
+		SdpCompletedWithError(aError);
+		}
+	}
+
+void CBtServicesEng::DoAttributeRequestCompleteL()
+	{
+	if (iCurrentAttributeRequest == EGettingNamesOnly)
+		{
+		//there are a lot of handles that needs the name, so 
+		//need to keep issue requests until all handles are processed,
+		//so the whole asynchronous process is not finished yet
+		iHandleCounter++;
+		GetServiceNamesL();
+		}
+	else if (iCurrentAttributeRequest == EGettingAllAttributes)
+		{ // all attributes have been got
+		TInt LineCount = iAttributeArray->Count();
+		
+		for (TInt i=0; i<LineCount; i++)
+			{
+			const TDesC& LineString = (*iAttributeArray)[i];						
+			ReportMessage(0, _L("%S\r\n"), &LineString);
+			}
+		
+//		iView->DisplayAttributeDialogL(iAttributeArray, iDeviceName, iServiceName);
+		iCurrentAttributeRequest = ENoOutstandingRequests;
+		if (iView)
+			iView->AsyncCompleted();
+		}
+	}
+
+void CBtServicesEng::AttributeRequestResult(TSdpServRecordHandle aHandle, TSdpAttributeID /*aAttrID*/, CSdpAttrValue* aAttrValue)
+	{
+	ReportMessage(1, _L("[AttributeRequestResult for Handle:0x%X ]\r\n"), aHandle );
+
+	TRAPD(err,DoAttributeRequestResultL(aAttrValue, aHandle)); // passing ownership
+	if (err != KErrNone)
+		{
+		iSdpAgent->Cancel();
+		}
+	}
+	
+void CBtServicesEng::DoAttributeRequestResultL(CSdpAttrValue* aAttrValue, TSdpServRecordHandle aHandle)
+	{
+	CleanupStack::PushL(aAttrValue); // taken ownership
+	if (iCurrentAttributeRequest == EGettingNamesOnly) 
+		{		 
+		TBuf16<KMaxServiceNameLength> unicode;
+		CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode,aAttrValue->Des());
+		if (unicode[unicode.Length() - 1] == L'\0')
+			{
+			unicode.Delete(unicode.Length() - 1, 1); // remove NULL-termination
+			}
+		//iView->ListBox().HandleItemAdditionL();
+		TBuf<64> string;
+		string.Copy(unicode);
+		
+		//extra check to make sure Handle and Name are paired correctly
+		if (iRecordArray[iHandleCounter]->iHandle != aHandle)
+			User::Panic(_L("Handle not match"), KErrNone);
+		
+		iRecordArray[iHandleCounter]->iServiceName = string;
+		
+		ReportMessage(1, _L("%S \r\n"), &string);		
+/*		
+		MQikListBoxModel& model = *this;
+		model.ModelBeginUpdateLC();
+		MQikListBoxData* data = model.NewDataL(EDataNormal);
+		data->AddTextL(unicode, EQikListBoxSlotText1);
+		data->Close();
+		model.ModelEndUpdateL();
+*/		
+		}
+
+	CleanupStack::PopAndDestroy(aAttrValue);  
+	}
+
+void CBtServicesEng::NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt /* aTotalRecordsCount */)
+	{
+	if ((aError == KErrNone) || (aError == KErrEof))
+		{
+		TRAPD(err, DoNextRecordRequestCompleteL(aHandle, aError));
+		if (err != KErrNone)
+			{
+			aError = err;
+			}
+		}
+	if (aError != KErrNone && aError != KErrEof)
+		{
+//		iView->GetEikonEnv()->BusyMsgCancel();
+		SdpCompletedWithError(aError);
+		}
+	
+	//if aError == KErrEof, that means no more records to read
+	
+	}
+
+void CBtServicesEng::DoNextRecordRequestCompleteL(TSdpServRecordHandle aHandle, TInt aError)
+	{
+	if (aError == KErrNone)    
+		{
+		ReportMessage(1, _L("Record Handle found 0x%X \r\n"), aHandle );
+		
+		CServiceRecordItem* pItem = new CServiceRecordItem;
+		pItem->iHandle = aHandle;		
+		iRecordArray.Append(pItem);
+		iSdpAgent->NextRecordRequestL();
+		}
+	else if (aError == KErrEof)
+		//no more records, now query service name for each record found 
+		{
+		iHandleCounter = 0;
+		iCurrentAttributeRequest = EGettingNamesOnly;
+		
+		//report status
+		TInt RecordCnt = iRecordArray.Count();		
+		ReportMessage(1, _L("%d records found, querying service name...\r\n"), RecordCnt);
+		GetServiceNamesL();
+		}
+	}
+
+void CBtServicesEng::SdpCompletedWithError(const TInt aError)
+	{
+	
+	HBufC* buf = HBufC::NewLC(KMaxDescriptorLength);
+	TPtr errorText = buf->Des();
+	AppendErrorMessage(aError,errorText);
+//	TGulAlignment position(EHRightVTop);
+//	iView->GetEikonEnv()->InfoMsgWithAlignmentAndDuration(position,errorText,KErrorMsgDuration);
+	ReportMessage(0, *buf);
+	
+	CleanupStack::PopAndDestroy();
+	iSdpAgent->Cancel();
+//	iView->DimRefreshButton(EFalse);
+//	iView->DimCancelButton(ETrue);
+	if (iView)
+		iView->AsyncCompleted();
+	
+	}
+
+void CBtServicesEng::AppendErrorMessage(const TInt aError, TDes& aBuf) const
+	{
+	for (TInt i = 0; i < iErrorCodes.Count(); i++)
+		{
+		if (iErrorCodes[i] == aError)
+			{
+			aBuf.Append(*(iErrorMessages[i]));
+			return;
+			}
+		}
+	_LIT(KErrorTextOther, "Error: ");
+	aBuf.Append(KErrorTextOther);
+	aBuf.AppendNum(aError);
+	}
+
+void CBtServicesEng::Panic(TBtPanicCode aPanicCode)
+	{
+	_LIT(KBtPanicText, "BTSU::Panic ");
+	User::Panic(KBtPanicText, aPanicCode);
+	}
+
+void CBtServicesEng::ReleaseModel()
+	{
+	// Do nothing, list box does not own us
+	}
+
+//static
+//search the Uuid value, and return a text string of its name
+TPtrC CBtServicesEng::UUIDToString(TUint32 aUuidValue)
+	{
+	//read the available filter UUID and corresponding text
+	TInt arrayCount = sizeof(UuidAsArray) / sizeof(TUUidPair);
+	TInt i;
+	for (i = 0; i < arrayCount; i++)
+		{
+		TUint32 uuid = UuidAsArray[i].uuid;
+		if (uuid == aUuidValue)
+			return (UuidAsArray[i].txt);
+		}
+	return _L("");
+	}
+
+//static
+//search through the value, and return the UUID value if there is one match
+//aUuidValue: [out] the found result
+TBool CBtServicesEng::StringToUUID(TDesC& aString, TUint32& aUuidValue)
+	{
+	//read the available filter UUID and corresponding text
+	TInt arrayCount = sizeof(UuidAsArray) / sizeof(TUUidPair);
+	TInt i;
+	for (i = 0; i < arrayCount; i++)
+		{
+		TUint32 uuid = UuidAsArray[i].uuid;
+		if (aString == UuidAsArray[i].txt)
+			{
+			aUuidValue = uuid;
+			return ETrue;
+			}			
+		}
+	return EFalse;
+	}
+
+
+///////////////////////////////////////
+// CBtAttributeBuilder functions
+///////////////////////////////////////
+
+CBtAttributeBuilder* CBtAttributeBuilder::NewL(CBtServicesEng& aEngine)
+	{
+	CBtAttributeBuilder* self = new(ELeave) CBtAttributeBuilder(aEngine);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBtAttributeBuilder::CBtAttributeBuilder(CBtServicesEng& aEngine)
+: iEngine(aEngine)
+	{
+	}
+
+void CBtAttributeBuilder::ConstructL()
+	{
+/*	
+	HBufC8* buf = CEikonEnv::Static()->AllocReadResourceAsDes8LC(R_ATTR_ID_MNEMONICS);
+
+	TResourceReader res;
+	res.SetBuffer(buf);
+
+	TInt arrayCount = res.ReadInt16();
+	for (TInt i = 0; i < arrayCount; i++)
+		{
+		TUint attrID = res.ReadUint32();
+		iAttrIDs.Append(attrID);
+		HBufC* mnemonic = res.ReadHBufCL();
+		iAttrMnemonics.Append(mnemonic);
+		}
+	CleanupStack::PopAndDestroy(); // buf
+*/	
+	}
+
+CBtAttributeBuilder::~CBtAttributeBuilder()
+	{
+	iAttrIDs.Close();
+	iAttrMnemonics.ResetAndDestroy();
+	iAttrMnemonics.Close();
+	}
+
+void CBtAttributeBuilder::Reset()
+	{
+	iIndentation = 0;
+	iCurrentLine.Zero();
+	}
+
+void CBtAttributeBuilder::SetHandle(TSdpServRecordHandle aHandle)
+	{
+	iHandle = aHandle;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildUnknownL(TUint8 aType, TUint8 /* aSizeDesc */, const TDesC8& /* aData */)
+	{
+	if (iStatus == EExpectingAttrID)
+		{
+		_LIT(KErrorText,"**Error: Unexpected UNKNOWN");
+		iCurrentLine.Append(KErrorText);
+		}
+	else
+		{
+		_LIT(KTextUnknown,"UNKNOWN");
+		iCurrentLine.Append(KTextUnknown);
+		iCurrentLine.AppendNum((TInt) aType);
+		}		
+	LineFinishedL();
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildNilL()
+	{
+	if (iStatus == EExpectingAttrID)
+		{
+		_LIT(KErrorText,"**Error: Unexpected NIL");
+		iCurrentLine.Append(KErrorText);
+		}
+	else
+		{
+		_LIT(KTextNULL,"NULL");
+		iCurrentLine.Append(KTextNULL);
+		}
+	LineFinishedL();
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildUintL(const TDesC8& aUint)
+	{
+
+	if (iStatus == EExpectingAttrValue)
+		{
+		iCurrentLine.Append(KTextHexPrefix);
+		for (TInt i = 0; i < aUint.Length(); i++)
+			{
+			iCurrentLine.AppendNumFixedWidth(aUint[i], EHex,2);
+			}
+		LineFinishedL();
+		}
+	else if (iStatus == EExpectingAttrID)
+		{
+		TUint value = 0;
+		for (TInt i = 0; i < aUint.Length(); i++)
+			{
+			value <<= 8;
+			value += aUint[i];
+			}
+		AppendAttrMnemonic(iCurrentLine,value);
+		iStatus = EExpectingAttrValue;
+		}
+
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildIntL(const TDesC8& aInt)
+	{
+	if (iStatus == EExpectingAttrID)
+		{
+		_LIT(KErrorText,"**Error: Unexpected Int");
+		iCurrentLine.Append(KErrorText);
+		}
+	else
+		{
+		iCurrentLine.Append(KTextHexPrefix);
+		for (TInt i = 0; i < aInt.Length(); i++)
+			{
+			iCurrentLine.AppendNumFixedWidth(aInt[i], EHex,2);
+			}
+		}
+	LineFinishedL();
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildUUIDL(const TUUID& aUUID)
+	{
+	if (iStatus == EExpectingAttrID)
+		{
+		_LIT(KErrorText,"**Error: Unexpected UUID");
+		iCurrentLine.Append(KErrorText);
+		}
+	else
+		{
+		iEngine.AppendUUIDText(iCurrentLine,aUUID);
+		}
+	LineFinishedL();
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildBooleanL(TBool aBool)
+	{
+	if (iStatus == EExpectingAttrID)
+		{
+		_LIT(KErrorText,"**Error: Unexpected Boolean");
+		iCurrentLine.Append(KErrorText);
+		}
+	else
+		{
+		if (aBool)
+			{
+			_LIT(KTextTrue,"TRUE");
+			iCurrentLine.Append(KTextTrue);
+			}
+		else
+			{
+			_LIT(KTextFalse,"FALSE");
+			iCurrentLine.Append(KTextFalse);
+			}
+		}
+	LineFinishedL();
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildStringL(const TDesC8& aString)
+	{
+	if (iStatus == EExpectingAttrID)
+		{
+		_LIT(KErrorText,"**Error: Unexpected String");
+		iCurrentLine.Append(KErrorText);
+		}
+	else
+		{
+		TBuf16<KMaxDescriptorLength> unicode;
+		CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode,aString);
+		if (unicode[unicode.Length() - 1] == NULL)
+			{
+			unicode.Delete(unicode.Length() - 1, 1); // remove NULL-termination
+			}
+		iCurrentLine.Append(unicode);
+		}
+	LineFinishedL();
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildDESL()
+	{
+	if (iIndentation == 1)
+		{
+		iEngine.AddAttributeLineL(iCurrentLine);
+		}
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildDEAL()
+	{
+	_LIT(KTextDEAL,"Data Element Alternate List");
+	iCurrentLine.Append(KTextDEAL);
+	iEngine.AddAttributeLineL(iCurrentLine);
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::StartListL()
+	{
+	iIndentation++;
+	iCurrentLine.Zero();
+	__ASSERT_ALWAYS(iIndentation > 0, CBtServicesEng::Panic(EBtIndentationZeroInStartList));
+	iCurrentLine.AppendFill(' ', (iIndentation - 1) * KIndentationFactor);
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::EndListL()
+	{
+	_LIT(KTextEndListDashes,"--------");
+	iCurrentLine.Append(KTextEndListDashes);
+	iEngine.AddAttributeLineL(iCurrentLine);
+	iIndentation--;
+	iCurrentLine.Zero();
+	if (iIndentation)
+		{
+		iCurrentLine.AppendFill(' ', (iIndentation - 1) * KIndentationFactor); // in this case indentation has already been checked to be greater than zero
+		}
+	if (iIndentation == 1)
+		{
+		iStatus = EExpectingAttrID;
+		}
+	return this;
+	}
+
+MSdpElementBuilder* CBtAttributeBuilder::BuildURLL(const TDesC8& aURL)
+	{
+	TBuf16<KMaxDescriptorLength> unicode;
+	CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode,aURL);
+	iCurrentLine.Append(unicode);
+	LineFinishedL();
+	return this;
+	}
+
+void CBtAttributeBuilder::AppendAttrMnemonic(TDes& aBuf, TUint aAttrID) const
+	{
+	for (TInt i = 0; i < iAttrIDs.Count(); i++)
+		{
+		if (iAttrIDs[i] == aAttrID)
+			{
+			aBuf.Append(*(iAttrMnemonics[i]));
+			return;
+			}
+		}
+	if (aAttrID == 0x0200 && iHandle == 0)
+		{
+		_LIT(KVersionNoPrefix,"VersionNo.: ");
+		aBuf.Append(KVersionNoPrefix);
+		}
+	else if (aAttrID == 0x0201 && iHandle == 0)
+		{
+		_LIT(KDatabaseStatePrefix,"DatabaseState: ");
+		aBuf.Append(KDatabaseStatePrefix);
+		}
+	else
+		{
+		_LIT(KTextAttrIDHex,"AttrID 0x");
+		aBuf.Append(KTextAttrIDHex);
+		aBuf.AppendNum(aAttrID,EHex);
+		_LIT(KTextColonSpace,": ");
+		aBuf.Append(KTextColonSpace);
+		}
+	}
+
+void CBtAttributeBuilder::LineFinishedL()
+	{
+	iEngine.AddAttributeLineL(iCurrentLine);
+	iCurrentLine.Zero();
+	__ASSERT_ALWAYS(iIndentation > 0, CBtServicesEng::Panic(EBtIndentationZeroInLineFinished));
+	iCurrentLine.AppendFill(' ', (iIndentation - 1) * KIndentationFactor);
+	if (iIndentation == 1)
+		{
+		iStatus = EExpectingAttrID;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btservices/BtServicesEng.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,195 @@
+// BtServicesEng.h
+// 
+// Copyright (c) 2003 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef BTSERVICESENG_H_
+#define BTSERVICESENG_H_
+
+#include <btsdp.h>
+#include <es_sock.h>
+#include <bt_sock.h>
+#include <barsread.h>
+
+#include "btserviceview.h"
+//#include <QikListBoxModel.h>
+
+enum TBtPanicCode
+	{
+	EBtEngineNotCreated = 1,
+	EBtEngineAlreadyExists = 2,
+	EBtIndentationZeroInStartList = 3,
+	EBtIndentationZeroInLineFinished = 4
+	};
+
+class CBtAttributeBuilder;
+
+class CServiceRecordItem
+	{
+public:
+	CServiceRecordItem()
+	{
+	iHandle = 0;
+	iServiceName = _L("");
+	}
+	
+	~CServiceRecordItem(){;}
+	
+	TSdpServRecordHandle iHandle;
+	TBuf<64> iServiceName;
+	
+	};
+
+/**
+This provides the main application functionality, specifically
+setting up the SDP agent and implementing the notifier interface
+to build the results into an array, displayed by the main View
+(CBtServicesListView) in the case of services, or by the attribute
+dialog in the case of attributes for a selected service.
+*/
+class CBtServicesEng : public CBase, public MSdpAgentNotifier  
+	{
+public:
+	static CBtServicesEng* NewL();
+	~CBtServicesEng();
+	void SetView(CBtServiceView* apView);
+	//CDesCArrayFlat* GetTextArray() const;
+
+	// defined in MSdpAgentNotifier
+	void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
+	void AttributeRequestResult(TSdpServRecordHandle aHandle, TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue);
+	void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount);
+
+	/////////////////////////////////////////////////////////
+	void ReportMessage(TInt aVerboseLevel, TRefByValue<const TDesC> aFmt, ...);
+	
+	void MakeTextServiceList();
+	void MakeTextUUIDList();
+	
+	TInt BluetoothReady();
+	void NewDeviceSelectedL(const TBTDevAddr& aAddress,const TBTDeviceName& aDeviceName);
+	void GetDeviceServicesL();
+
+	void GetAttributesL(TInt aIndex);
+	void GetDeviceAttributesL(const TBTDevAddr& aAddress,const TBTDeviceName& aDeviceName, TSdpServRecordHandle aHandle);
+	
+	TBool GettingAllAttributes() const;
+	void AddAttributeLineL(const TDesC& aDes);
+	void SetUUIDFilterL(TUint32 aUUID);
+	void DisplayDeviceInfoL();
+	void DisplayLocalInfoL();
+	void CancelSdpAgent();
+	void DeleteSdpAgent();
+	void AppendUUIDText(TDes& aBuf, TUUID aUUID) const;
+	
+	static void Panic(TBtPanicCode aPanicCode);
+	static TPtrC UUIDToString(TUint32 aUuidValue);
+	static TBool StringToUUID(TDesC& aString, TUint32& aUuidValue);	
+private:
+	CBtServicesEng();
+	void ConstructL();
+	void GetServiceNamesL();
+	void SdpCompletedWithError(const TInt aError);
+	void AppendErrorMessage(const TInt aError, TDes& aBuf) const;
+	void DoAttributeRequestCompleteL();
+	void DoAttributeRequestResultL(CSdpAttrValue* aAttrValue, TSdpServRecordHandle aHandle);
+	void DoNextRecordRequestCompleteL(TSdpServRecordHandle aHandle, TInt aError);
+	void ReleaseModel();
+
+private:
+	// Values of iCurrentAttributeRequest
+	enum TAttributeRequests
+		{
+		ENoOutstandingRequests,
+		EGettingNamesOnly,
+		EGettingAllAttributes
+		};
+
+	CSdpAgent* iSdpAgent;
+	CSdpSearchPattern* iSearchPattern;
+	//CDesCArrayFlat* iTextArray;
+	CDesCArrayFlat* iAttributeArray;
+	RPointerArray <CServiceRecordItem> iRecordArray;
+	CSdpAttrIdMatchList* iAttributeMatchList;
+	CBtAttributeBuilder* iAttributeBuilder;
+
+	CBtServiceView* iView; // iView is not "owned" by this
+	//CEikonEnv* iEikon;
+	
+	TInt iHandleCounter;
+	TAttributeRequests iCurrentAttributeRequest;
+	TBTDeviceName iDeviceName;	//this is taken from the caller and only be used to display
+	TBTDevAddr iDeviceAddress;	//critical for SDP
+	
+	//TBTDeviceClass iDeviceClass;//this is taken from the caller and only be used to display
+	
+	TPtrC iServiceName;
+	TUint32 iUUIDFilter;
+
+	RArray<TUUID> iUUIDs;
+	RPointerArray<HBufC> iUUIDsAsText;
+	RArray<TInt> iErrorCodes;
+	RPointerArray<HBufC> iErrorMessages;
+
+	RSocketServ iSocketServ;
+	
+	TBuf<512> iTextBuf;
+	};
+
+/**
+Receives and parses the results from an SDP Attribute Request, and builds
+them into a table (array for listbox) for displaying in
+the attributes dialog.
+*/
+class CBtAttributeBuilder : public CBase, public MSdpElementBuilder
+	{
+public:
+	static CBtAttributeBuilder* NewL(CBtServicesEng& aEngine);
+	void SetHandle(TSdpServRecordHandle aHandle);
+	void Reset();
+	~CBtAttributeBuilder();
+private:
+	// defined in MSdpElementBuilder
+	MSdpElementBuilder* BuildUnknownL(TUint8 aType, TUint8 aSizeDesc, const TDesC8& aData);
+	MSdpElementBuilder* BuildNilL();
+	MSdpElementBuilder* BuildUintL(const TDesC8& aUint);
+	MSdpElementBuilder* BuildIntL(const TDesC8& aInt);
+	MSdpElementBuilder* BuildUUIDL(const TUUID& aUUID);
+	MSdpElementBuilder* BuildBooleanL(TBool aBool);
+	MSdpElementBuilder* BuildStringL(const TDesC8& aString);
+	MSdpElementBuilder* BuildDESL();  // Must not return NULL
+	MSdpElementBuilder* BuildDEAL();  // ditto
+	MSdpElementBuilder* StartListL(); // ditto
+	MSdpElementBuilder* EndListL();
+	MSdpElementBuilder* BuildURLL(const TDesC8& aURL);
+
+private:
+	CBtAttributeBuilder(CBtServicesEng& aEngine);
+	void AppendAttrMnemonic(TDes& aBuf, TUint aAttrID) const;
+	void LineFinishedL();
+	void ConstructL();
+private:
+	enum TCurrentStatus {
+		EExpectingAttrID,
+		EExpectingAttrValue
+		};
+
+	RArray<TUint> iAttrIDs;
+	RPointerArray<HBufC> iAttrMnemonics;
+
+	CBtServicesEng& iEngine;
+	TBuf<KMaxDescriptorLength> iCurrentLine;
+	TInt iIndentation;
+	TCurrentStatus iStatus;
+	TSdpServRecordHandle iHandle;
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btservices/btservices.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+# btservices.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name btservices
+
+==short-description
+
+Discovers services available on Bluetooth enabled devices in the vicinity.
+
+==argument enum command optional
+
+The command to execute. Defaults to C<devices>.
+
+==enum-value devices
+
+Scan for devices.
+
+==enum-value services
+
+Search for a service. Use C<-a> to specify a device BT address and optionally C<-u> to specify a UUID filter.
+
+==enum-value attributes
+
+Search for an attribute. Use C<-a> to specify a device BT address and C<-r> to specify a service handle (as given by the C<services> command).
+
+==enum-value local
+
+Display information about the local device.
+
+==enum-value uuids
+
+Print a list of UUID strings and their values.
+
+==enum-value status
+
+Prints out the current status of the Bluetooth radio (on or off). (Only available on S60 5th edition or later)
+
+==enum-value enable
+
+Attempts to turn on Bluetooth. (Only available on S60 5th edition or later)
+
+==enum-value disable
+
+Attempts to turn off Bluetooth. (Only available on S60 5th edition or later)
+
+==option string a address
+
+The BT address to use with either the C<services> or C<attributes> commands.
+
+==option string r record
+
+The service record handle to use with the C<attribute> command.
+
+==option string u uuid
+
+Specify a UUID filter when searching the service records. Can be either in name or in hex format e.g. 0x0100 or L2CAP. Use the C<uuid> command to obtain a list of UUID values and names.
+
+==option bool v verbose multiple
+
+Verbose output. Specify twice (i.e. C<-vv>) for even more detail.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btservices/btservices.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,646 @@
+// btservices.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32std.h>
+#include <BTExtNotifiers.h>
+
+#include <fshell/common.mmh>
+#include <fshell/ioutils.h>
+using namespace IoUtils;
+
+#include "BtServicesEng.h"
+#include "BtServiceView.h"
+
+class CBTEngSettings;
+
+#if FSHELL_PLATFORM_S60 >= 5
+// This is an S60-only API
+#define SUPPORT_ONOFF
+#endif
+
+#ifdef SUPPORT_ONOFF
+#include <btengsettings.h>
+#endif
+
+CBtServiceView::CBtServiceView()
+	{
+	}
+
+CBtServiceView::~CBtServiceView()
+	{
+	}
+
+void CBtServiceView::PrintTextMsg(TInt /*aVerboseLevel*/, const TDesC& /*aMsg*/)
+	{
+	}
+
+void CBtServiceView::AsyncCompleted()
+	{
+	}
+
+class CCmdBtsvc : public CCommandBase, public CBtServiceView 
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdBtsvc();
+private:
+	CCmdBtsvc();
+	void DoScanDeviceL();
+	void DoListServiceL();
+	void DoAttributeL();
+	void DoLocalL();
+	void DoListUuidFilterL();
+	void SelectBTDeviceL(TBTDeviceName& aName, TBTDevAddr& aBDAddr, TBTDeviceClass& aDevClass);
+	TBool GetBTDevClassFromRegistryL(TBTDevAddr& aBDAddr, TBTDeviceClass& aDevClass);
+
+#ifdef SUPPORT_ONOFF
+	void SetEnabledL(TBool aEnable);
+	void ShowStatusL();
+	TBool GetPowerStateL();
+#endif
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	
+private:
+	virtual void PrintTextMsg(TInt aVerboseLevel, const TDesC& aMsg);
+	virtual void AsyncCompleted();
+
+private:
+	CBtServicesEng* iEngine; 
+	CActiveSchedulerWait* iActiveWait;
+	RArray<TBool> iVerbose;
+	
+	HBufC* iOptBTAddr;
+	HBufC* iOptSvcHandle;	//service handle
+	HBufC* iOptUuidFilter;	//uuid filter
+	
+	enum TBtSvcCmd
+		{
+		ECmdDevice,
+		ECmdService,
+		ECmdAttribute,
+		ECmdLocal,
+		ECmdUuid,
+		ECmdStatus,
+		ECmdEnable,
+		ECmdDisable,
+		};
+	
+	TBtSvcCmd iCommand;
+
+	CBTEngSettings* iSettings;
+	};
+
+CCommandBase* CCmdBtsvc::NewLC()
+	{
+	CCmdBtsvc* self = new(ELeave) CCmdBtsvc();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdBtsvc::CCmdBtsvc()
+	{
+	iActiveWait = new (ELeave) CActiveSchedulerWait;
+	}
+
+
+CCmdBtsvc::~CCmdBtsvc()
+	{
+#ifdef SUPPORT_ONOFF
+	delete iSettings;
+#endif
+
+	delete iOptBTAddr;
+	delete iOptSvcHandle;
+	delete iOptUuidFilter;
+	delete iActiveWait;
+	delete iEngine;
+	iVerbose.Close();
+	}
+
+void CCmdBtsvc::PrintTextMsg(TInt aVerboseLevel, const TDesC& aMsg)
+	{
+	TInt VerboseLevel = iVerbose.Count();
+	if (aVerboseLevel <= VerboseLevel)
+		Printf(aMsg);
+	}
+
+void CCmdBtsvc::AsyncCompleted()
+	{
+	if (iActiveWait->IsStarted())
+		{
+		iActiveWait->AsyncStop();
+		}
+	}
+
+const TDesC& CCmdBtsvc::Name() const
+	{
+	_LIT(KName, "btservices");
+	return KName;
+	}
+
+void CCmdBtsvc::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgCommand, "command");
+	aArguments.AppendEnumL((TInt&)iCommand, KArgCommand);
+	}
+
+void CCmdBtsvc::OptionsL(RCommandOptionList& aOptions)
+	{		
+	aOptions.AppendStringL(iOptBTAddr, _L("address"));
+	aOptions.AppendStringL(iOptSvcHandle, _L("record"));
+	aOptions.AppendStringL(iOptUuidFilter, _L("uuid"));		
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	}
+
+void CCmdBtsvc::DoRunL()
+	{
+	switch (iCommand)
+		{
+		case ECmdDevice:
+			DoScanDeviceL();
+			break;
+		case ECmdService:
+			DoListServiceL();
+			break;
+		case ECmdAttribute:
+			DoAttributeL();
+			break;
+		case ECmdLocal:
+			DoLocalL();
+			break;
+		case ECmdUuid:
+			DoListUuidFilterL();
+			break;
+#ifdef SUPPORT_ONOFF
+		case ECmdStatus:
+			ShowStatusL();
+			break;
+		case ECmdEnable:
+			SetEnabledL(ETrue);
+			break;
+		case ECmdDisable:
+			SetEnabledL(EFalse);
+			break;
+#endif
+		default:	
+			LeaveIfErr(KErrArgument, _L("Invalid command"));
+		}
+	}
+
+void CCmdBtsvc::DoAttributeL()
+	{
+	TInt err;
+		
+	//if want to query full attribute set of one particular service,
+	//call CBtServicesEng::GetAttributesL()
+	if (iOptSvcHandle && iOptSvcHandle->Length())
+		{
+		iEngine = CBtServicesEng::NewL();
+		iEngine->SetView(this);
+		
+		iEngine->CancelSdpAgent();
+		iEngine->DeleteSdpAgent();
+		
+		err = iEngine->BluetoothReady();
+		LeaveIfErr(err, _L("Bluetooth not ready"));
+				
+		TBTDeviceName Name; 
+		TBTDevAddr BDAddr;
+		TBTDeviceClass DevClass;
+			
+		//iOptSvcHandle should begin with "0x" (hex)
+		if ((iOptSvcHandle->Left(2))==_L("0x"))
+			{
+			TSdpServRecordHandle Handle;
+			TLex lex(*iOptSvcHandle);
+			lex.SkipAndMark(2);
+			err = lex.Val(Handle, EHex);
+			LeaveIfErr(err, _L("Service Handle:\"%S\" is not in valid format"), iOptSvcHandle);
+		
+			SelectBTDeviceL(Name, BDAddr, DevClass);
+			Printf(_L("==============================================\r\n"));
+			
+			iEngine->GetDeviceAttributesL(BDAddr, Name, Handle);
+			
+			//wait for results
+			iActiveWait->Start();
+									
+			}
+		else
+			LeaveIfErr(KErrArgument, _L("Service Handle:\"%S\" is not in valid format"), iOptSvcHandle);		
+		}
+	else
+		LeaveIfErr(KErrArgument, _L("use -r to specify a service record handle"));
+	}
+
+
+//do a BT device scan with RHostResolver,
+//and make a list of BT addresses, device name, and device class
+//
+void CCmdBtsvc::DoScanDeviceL()
+	{
+	TInt err;
+	TInt ItemsFound = 0;
+	TBTDevAddr BDAddr;
+	TBTDeviceName Name;
+	TBTDeviceClass DevClass;
+	
+	Printf(_L("Scanning for BT devices ...\r\n"));
+		
+	RSocketServ SktSrv;
+	CleanupClosePushL(SktSrv);
+	
+	err = SktSrv.Connect();
+	LeaveIfErr(err, _L("Could not connect to socket server"));
+	
+	RHostResolver Host;
+	CleanupClosePushL(Host);
+	RHostResolver HostForName;
+	CleanupClosePushL(HostForName);
+	
+	TProtocolDesc ProtocolInfo;
+	err = SktSrv.FindProtocol(_L("BTLinkManager"), ProtocolInfo);
+	User::LeaveIfError(err);
+	
+	err = Host.Open(SktSrv, ProtocolInfo.iAddrFamily , ProtocolInfo.iProtocol);
+	LeaveIfErr(err, _L("Could not open host resolver"));
+	err = HostForName.Open(SktSrv, ProtocolInfo.iAddrFamily , ProtocolInfo.iProtocol);
+	LeaveIfErr(err, _L("Could not open host resolver"));
+	
+	TInquirySockAddr Inq;	
+	Inq.SetIAC(KGIAC);
+	Inq.SetAction(KHostResInquiry/*|KHostResIgnoreCache*/);
+	
+	
+	TNameEntry Result;
+	err = Host.GetByAddress(Inq, Result);
+	
+	//this is for querying name
+	TInquirySockAddr InqName;	
+	InqName.SetAction(KHostResName);
+	TNameEntry ResultName;
+	
+	Printf(_L("========================================================\r\n"));
+	Printf(_L("BTAddr         | DeviceClass| Name\r\n"));
+	Printf(_L("========================================================\r\n"));
+	
+	while(1)
+		{
+		if (err == KErrNone)
+			{
+			ItemsFound++;
+			TInquirySockAddr& sa = TInquirySockAddr::Cast(Result().iAddr);
+			const TBTDevAddr& bdaddr = sa.BTAddr();
+			BDAddr = bdaddr;
+			Name = Result().iName;
+			
+			TUint16 MajorServiceClass = sa.MajorServiceClass(); 
+			DevClass = TBTDeviceClass(
+					MajorServiceClass, sa.MajorClassOfDevice(), sa.MinorClassOfDevice() );
+			
+			TBuf<128> BTReadAddress;
+			BDAddr.GetReadable(BTReadAddress);
+			
+			//query its name
+			InqName.SetBTAddr(bdaddr);
+			err = HostForName.GetByAddress(InqName, ResultName);			
+			if (err==KErrNone)
+				Name = ResultName().iName;
+			else
+				Name.Format(_L("Unable to get the name, err=%d"), err);
+			
+			Printf(_L("0x%S | 0x%08x | \"%S\" \r\n"), 
+					&BTReadAddress, DevClass.DeviceClass(), &Name);
+								
+			err = Host.Next(Result);
+			}
+		else if (err == KErrEof)
+			{
+			break;
+			}
+		else
+			LeaveIfErr(err, _L("Resolving address failed"));
+		}
+	CleanupStack::PopAndDestroy();
+	CleanupStack::PopAndDestroy();
+	CleanupStack::PopAndDestroy();
+	
+	Printf(_L("%d devices found\r\n"),ItemsFound);
+	}
+
+//NOT TESTED YET, do not use
+//aBDAddr:[in]
+//aDevClass:[out]	
+TBool CCmdBtsvc::GetBTDevClassFromRegistryL(TBTDevAddr& aBDAddr, TBTDeviceClass& aDevClass)
+	{
+	TInt err;
+	
+	TBuf<128> buf;
+	aBDAddr.GetReadable(buf);
+	Printf(_L("Query DeviceClass for BTAddr:0x%S\r\n"), &buf);
+	
+	RBTRegServ Srv;
+	CleanupClosePushL(Srv);
+	err = Srv.Connect();
+	User::LeaveIfError(err);
+	
+	RBTRegistry Reg;
+	CleanupClosePushL(Reg);
+	err = Reg.Open(Srv);
+	User::LeaveIfError(err);
+
+	TBTNamelessDevice Dev;
+	Dev.SetAddress(aBDAddr);
+	
+	TRequestStatus status;
+	Reg.GetDevice(Dev, status);
+	User::WaitForRequest(status);
+	
+	err = status.Int();
+	User::LeaveIfError(err);
+	
+	if (err == KErrNone )
+		{
+		aDevClass = Dev.DeviceClass();		
+		}
+	
+	CleanupStack::PopAndDestroy();	
+	CleanupStack::PopAndDestroy();	
+	
+	return ETrue;
+	}
+
+//select a BT device either from RNotifier, 
+//or using BT address string if it is specified
+//aName: [out]
+//aBDAddr: [out]
+//aDevClass: [out]
+void CCmdBtsvc::SelectBTDeviceL(TBTDeviceName& aName, TBTDevAddr& aBDAddr, TBTDeviceClass& aDevClass)
+	{
+	TInt err;
+	if (iOptBTAddr && iOptBTAddr->Length()>0)
+		//use RHostResolver to get name and device class
+		{
+		Printf(_L("Querying name for \"%S\"...\r\n"), iOptBTAddr);
+			
+		RSocketServ SktSrv;
+		CleanupClosePushL(SktSrv);
+		
+		err = SktSrv.Connect();
+		LeaveIfErr(err, _L("Could not connect to socket server"));
+		
+		RHostResolver Host;
+		CleanupClosePushL(Host);
+		
+		TProtocolDesc ProtocolInfo;
+		err = SktSrv.FindProtocol(_L("BTLinkManager"), ProtocolInfo);
+		User::LeaveIfError(err);
+		
+		err = Host.Open(SktSrv, ProtocolInfo.iAddrFamily , ProtocolInfo.iProtocol);
+		LeaveIfErr(err, _L("Could not open host resolver"));
+		
+		TBTDevAddr Addr;
+		err = Addr.SetReadable(*iOptBTAddr);
+		LeaveIfErr(err, _L("User-input BT address invalid"));
+				
+		TInquirySockAddr Inq;	
+		Inq.SetAction(KHostResName);
+		Inq.SetBTAddr(Addr);	
+		
+		TNameEntry Result;
+		err = Host.GetByAddress(Inq, Result);
+		if (err == KErrNone)
+			{
+			TInquirySockAddr& sa = TInquirySockAddr::Cast(Result().iAddr);
+			const TBTDevAddr& bdaddr = sa.BTAddr();
+			aBDAddr = bdaddr;
+			aName = Result().iName;
+						
+			TUint16 MajorServiceClass = sa.MajorServiceClass(); 
+			aDevClass = TBTDeviceClass(
+					MajorServiceClass, sa.MajorClassOfDevice(), sa.MinorClassOfDevice() );			
+			}
+		else
+			LeaveIfErr(err, _L("Resolving address failed"));		
+		
+		CleanupStack::PopAndDestroy();
+		CleanupStack::PopAndDestroy();
+		
+		TBuf<128> AddressStr;
+		aBDAddr.GetReadable(AddressStr);
+		Printf(_L("Device \"%S\" BTAddr:0x%S\r\n"), 
+				&aName, &AddressStr);		
+		}
+	else
+		//use RNotifier to select a BT device
+		{
+		//about the search device, prompting user about curret status
+		Printf(_L("Searching Bluetooth device through RNotifier,\r\nplease go to main UI screen to select a device...\r\n"));
+		
+		////////////////////////////////////////////
+		RNotifier noti;
+		User::LeaveIfError(noti.Connect());
+
+		// 2. Start the device selection plug-in
+		TBTDeviceSelectionParams selectionFilter;
+		//TUUID targetServiceClass(0x2345);
+		//selectionFilter.SetUUID(targetServiceClass);
+		TBTDeviceSelectionParamsPckg pckg(selectionFilter);
+		TBTDeviceResponseParams result;
+		TBTDeviceResponseParamsPckg resultPckg(result);
+		TRequestStatus status;
+		noti.StartNotifierAndGetResponse(status, KDeviceSelectionNotifierUid, pckg, resultPckg);
+		User::After(2000000);
+
+		// 3. Extract device name if it was returned
+		User::WaitForRequest(status);
+
+		if (status.Int() == KErrNone)
+		    {
+		    if (resultPckg().IsValidDeviceName() &&
+		    	resultPckg().IsValidBDAddr() &&
+		    	resultPckg().IsValidDeviceClass()
+		    	)
+		        {
+		        aName = (resultPckg().DeviceName());	        
+		        aBDAddr = resultPckg().BDAddr();
+		        aDevClass = resultPckg().DeviceClass();
+		        
+		        }
+		    }
+		    
+		    
+		// 4. Clean up
+		noti.CancelNotifier(KDeviceSelectionNotifierUid);
+		noti.Close();		
+		
+		TBuf<128> AddressStr;
+		aBDAddr.GetReadable(AddressStr);
+		Printf(_L("Device \"%S\" BTAddr:0x%S DeviceClass:0x%08X\r\n"), 
+				&aName, &AddressStr, aDevClass.DeviceClass());		
+		
+		}	
+	}
+
+
+//search and make a list of results
+void CCmdBtsvc::DoListServiceL()
+	{
+	TInt VerboseLevel = iVerbose.Count();
+	
+	if (VerboseLevel >= 2)
+		Printf(_L("calling CBtServicesEng::NewL() ...\r\n"));
+	
+	iEngine = CBtServicesEng::NewL();
+	
+	
+	if (VerboseLevel >= 2)
+		Printf(_L("calling CBtServicesEng::SetView()... iEngine=0x%08x\r\n"), 
+				iEngine);
+	
+	iEngine->SetView(this);
+	
+	if (VerboseLevel >= 2)
+		Printf(_L("calling CBtServicesEng::CancelSdpAgent()...\r\n"));
+	iEngine->CancelSdpAgent();
+
+	if (VerboseLevel >= 2)
+		Printf(_L("calling CBtServicesEng::DeleteSdpAgent()...\r\n"));	
+	iEngine->DeleteSdpAgent();
+	
+	TInt err = iEngine->BluetoothReady();
+	LeaveIfErr(err, _L("Bluetooth not ready"));
+
+	TBTDeviceName Name; 
+	TBTDevAddr BDAddr;
+	TBTDeviceClass DevClass;
+	
+	SelectBTDeviceL(Name, BDAddr, DevClass);
+	
+	//see if user has specified a UUID filter
+	if (iOptUuidFilter && iOptUuidFilter->Length())
+		{
+		TUint32 uuid;
+		if ((iOptUuidFilter->Left(2))==_L("0x"))
+			{
+			TLex lex(*iOptUuidFilter);
+			lex.SkipAndMark(2);
+			err = lex.Val(uuid, EHex);
+			if (err==KErrNone)
+				{
+				iEngine->SetUUIDFilterL(uuid);
+				goto QueryService;
+				}
+			}
+		
+			//the UUID could be in string form.
+			TBool Match = iEngine->StringToUUID(*iOptUuidFilter, uuid);
+			if (Match==EFalse)
+				{
+				Printf(_L("UUID filter not recognised. Ignored\r\n"));
+				}
+		}
+		
+QueryService:	
+	iEngine->NewDeviceSelectedL(BDAddr, Name);		
+	iActiveWait->Start();
+	
+	iEngine->MakeTextServiceList();	
+	
+	//test code: just to test if attributes query is OK	
+	//iEngine->GetAttributesL(0);
+	//iActiveWait->Start();
+	
+	}
+
+void CCmdBtsvc::DoLocalL()
+	{
+	TInt err;
+	iEngine = CBtServicesEng::NewL();
+	iEngine->SetView(this);
+	
+	iEngine->CancelSdpAgent();
+	iEngine->DeleteSdpAgent();
+	
+	err = iEngine->BluetoothReady();
+	LeaveIfErr(err, _L("Bluetooth not ready"));
+	
+	iEngine->DisplayLocalInfoL();
+	
+	}
+
+
+//make a list of UUID filters, values and strings  
+void CCmdBtsvc::DoListUuidFilterL()
+	{
+	TInt err;
+	iEngine = CBtServicesEng::NewL();
+	iEngine->SetView(this);
+	
+	iEngine->CancelSdpAgent();
+	iEngine->DeleteSdpAgent();
+	
+	err = iEngine->BluetoothReady();
+	LeaveIfErr(err, _L("Bluetooth not ready"));
+	
+	
+	iEngine->MakeTextUUIDList();
+	}
+
+	
+EXE_BOILER_PLATE(CCmdBtsvc)
+
+#ifdef SUPPORT_ONOFF
+
+TBool CCmdBtsvc::GetPowerStateL()
+	{
+	if (!iSettings)
+		{
+		TRAPL(iSettings = CBTEngSettings::NewL(NULL), _L("Couldn't construct CBTEngSettings"));
+		}
+	TBTPowerStateValue state;
+	LeaveIfErr(iSettings->GetPowerState(state), _L("Couldn't read BT power state"));
+	return state == EBTPowerOn;
+	}
+
+void CCmdBtsvc::ShowStatusL()
+	{
+	if (GetPowerStateL())
+		{
+		Printf(_L("Bluetooth is enabled.\r\n"));
+		}
+	else
+		{
+		Printf(_L("Bluetooth is disabled.\r\n"));
+		}
+	}
+
+void CCmdBtsvc::SetEnabledL(TBool aEnable)
+	{
+	TBool on = GetPowerStateL();
+	if (on && !aEnable)
+		{
+		LeaveIfErr(iSettings->SetPowerState(EBTPowerOff), _L("Couldn't set power state"));
+		}
+	else if (!on && aEnable)
+		{
+		LeaveIfErr(iSettings->SetPowerState(EBTPowerOn), _L("Couldn't set power state"));
+		}
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/btservices/btservices.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// btservices.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+TARGET			fshell_btservices.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_BTSERVICES
+
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	FSHELL_NETWORKING_SYSTEMINCLUDE
+
+sourcepath		.
+source			btservices.cpp BtServicesEng.cpp
+
+library			euser.lib bafl.lib charconv.lib
+library			iocli.lib
+LIBRARY			esock.lib sdpagent.lib sdpdatabase.lib btextnotifiers.lib btmanclient.lib bluetooth.lib btdevice.lib
+
+#if FSHELL_PLATFORM_S60 >= 5
+LIBRARY			btengsettings.lib
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cat/cat.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,66 @@
+# cat.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name cat
+
+==short-description
+
+Concatenate the specified files and write their contents to C<stdout>.
+
+==see-also
+
+L<match|match>, L<tail|tail>
+
+==argument filename file_name optional multiple
+
+The names of the files to be concatenated. May contain wild characters C<*> and C<?>. If none specified, reads from C<stdin>.
+
+==option bool f force
+
+Read the files even if they are open exclusively by another process. Runs a small risk of the data read being corrupt.
+
+==option bool b binary
+
+Legacy option, kept for compatability. Equivalent to C<--encoding binary>.
+
+==option enum e encoding
+
+Encoding to use. If not specified, defaults to 'auto'.
+
+==enum-value auto
+
+Use charconv to try and figure out the encoding (slow and error-prone for anything other than UTF-16 with BOM).
+
+==enum-value binary
+
+Read the files in binary mode and do not perform any character conversion.
+
+==enum-value utf-8
+
+Assume the file is UTF-8 (with or without BOM).
+
+==enum-value latin1
+
+Assume the file is encoded using ISO-8859-1.
+
+==enum-value ltk-utf-8
+
+Assume the file is UTF-8, but use the RLtkBuf16 UTF-8 parser rather than the charconv one (useful for testing).
+
+==option int s block-size
+
+Specify the block size to use for reading the file(s), in bytes. If not specified, defaults to 512 bytes.
+
+==copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cat/cat.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,234 @@
+// cat.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "character_converter.h"
+#include "cat.h"
+
+const TInt KDefaultBlockSize = 512;
+
+
+CCommandBase* CCmdCat::NewLC()
+	{
+	CCmdCat* self = new(ELeave) CCmdCat();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CCmdCat::~CCmdCat()
+	{
+	iFiles.Close();
+	iBuf16.Close();
+	delete iCharacterConverter;
+	delete iFileReader;
+	}
+
+CCmdCat::CCmdCat()
+	: CCommandBase(EManualComplete), iBlockSize(KDefaultBlockSize)
+	{
+	}
+
+void CCmdCat::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+void CCmdCat::ReadNextFile()
+	{
+	if (iFiles.Count() > 0)
+		{
+		iFileReader->Read(iFiles[0], *this);
+		}
+	else
+		{
+		Complete();
+		}
+	}
+
+void CCmdCat::RemoveCurrentFileName()
+	{
+	iFiles.Remove(0);
+	}
+
+void CCmdCat::WriteChunkToConsoleL(const TDesC8& aData, TReadType aType)
+	{
+	if (iEncoding == EBinary)
+		{
+		iBuf16.Copy(aData);
+		Write(iBuf16);
+		if (aType == MFileReaderObserver::ELast)
+			{
+			RemoveCurrentFileName();
+			ReadNextFile();
+			}
+		}
+	else if (iEncoding == ELtkUtf8)
+		{
+		iBuf16.Zero();
+		iBuf16.AppendUtf8L(aData);
+		Write(iBuf16);
+		if (aType == MFileReaderObserver::ELast)
+			{
+			TInt firstBad;
+			iBuf16.FinalizeUtf8(firstBad);
+			if (firstBad != KErrNotFound) PrintWarning(_L("Found bad UTF-8 sequence in %S at byte offset %d"), &iFiles[0], firstBad);
+
+			RemoveCurrentFileName();
+			ReadNextFile();
+			}
+		}
+	else
+		{
+		switch (aType)
+			{
+			case MFileReaderObserver::EFirst:
+				{
+				Write(iCharacterConverter->ConvertChunkL(aData, CCharacterConverter::EFirst));
+				break;
+				}
+			case MFileReaderObserver::EMiddle:
+				{
+				Write(iCharacterConverter->ConvertChunkL(aData, CCharacterConverter::EMiddle));
+				break;
+				}
+			case MFileReaderObserver::ELast:
+				{
+				Write(iCharacterConverter->ConvertChunkL(aData, CCharacterConverter::ELast));
+				RemoveCurrentFileName();
+				ReadNextFile();
+				break;
+				}
+			default:
+				{
+				ASSERT(FALSE);
+				}
+			}
+		}
+	}
+
+const TDesC& CCmdCat::Name() const
+	{
+	_LIT(KName, "cat");
+	return KName;
+	}
+
+void CCmdCat::DoRunL()
+	{
+	if (iBinary)
+		{
+		if (iOptions.IsPresent(&iEncoding))
+			{
+			PrintWarning(_L("--encoding overrides legacy --binary option"));
+			}
+		else
+			{
+			iEncoding = EBinary;
+			}
+		}
+
+	if (iEncoding == EBinary || iEncoding == ELtkUtf8 || iFiles.Count() == 0)
+		{
+		iBuf16.CreateL(iBlockSize);
+		}
+	else
+		{
+		TUint charset;
+		switch (iEncoding)
+			{
+			case EUtf8:
+				charset = KCharacterSetIdentifierUtf8;
+				break;
+			case ELatin1:
+				charset = KCharacterSetIdentifierIso88591;
+				break;
+			case EAuto:
+			default:
+				charset = 0;
+				break;
+
+			}
+		TRAPL(iCharacterConverter = CCharacterConverter::NewL(iBlockSize, FsL(), charset), _L("Couldn't load charconv - try using --binary mode"));
+		}
+	iFileReader = CFileReader::NewL(iBlockSize, FsL(), iForce);
+
+	if (iFiles.Count() > 0)
+		{
+		ReadNextFile();
+		}
+	else
+		{
+		TInt err = KErrNone;
+		while (err == KErrNone)
+			{
+			err = Stdin().Read(iBuf16);
+			if (err == KErrNone)
+				{
+				Write(iBuf16);
+				}
+			}
+		if (err == KErrEof)
+			{
+			err = KErrNone;
+			}
+		Complete(err);
+		}
+	}
+
+void CCmdCat::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptForce, "force");
+	_LIT(KOptBinary, "binary");
+	_LIT(KOptEncoding, "encoding");
+	_LIT(KOptBlockSize, "block-size");
+
+	aOptions.AppendBoolL(iForce, KOptForce);
+	aOptions.AppendEnumL((TInt&)iEncoding, KOptEncoding);
+	aOptions.AppendIntL(iBlockSize, KOptBlockSize);
+	aOptions.AppendBoolL(iBinary, KOptBinary);
+	}
+
+void CCmdCat::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFiles, "file_name");
+	aArguments.AppendFileNameL(iFiles, KArgFiles);
+	}
+
+CCommandBase& CCmdCat::Command()
+	{
+	return *this;
+	}
+
+void CCmdCat::HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue)
+	{
+	aContinue = ETrue;
+	TRAPD(err, WriteChunkToConsoleL(aData, aType));
+	if (err)
+		{
+		aContinue = EFalse;
+		PrintWarning(_L("Problem writing chunk of %S to console: %d"), &iFiles[0], err);
+		RemoveCurrentFileName();
+		ReadNextFile();
+		}
+	}
+
+void CCmdCat::HandleFileReadError(TInt aError)
+	{
+	PrintWarning(_L("Problem reading %S: %d"), &iFiles[0], aError);
+	RemoveCurrentFileName();
+	ReadNextFile();
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdCat)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cat/cat.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,57 @@
+// cat.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include "file_reader.h"
+#include "character_converter.h"
+#include <fshell/descriptorutils.h>
+
+using namespace IoUtils;
+
+class CCmdCat : public CCommandBase, public MFileReaderObserver
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdCat();
+private:
+	CCmdCat();
+	void ConstructL();
+	void ReadNextFile();
+	void RemoveCurrentFileName();
+	void WriteChunkToConsoleL(const TDesC8& aData, TReadType aType);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private: // From MFileReaderObserver.
+	virtual CCommandBase& Command();
+	virtual void HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue);
+	virtual void HandleFileReadError(TInt aError);
+private:
+	RArray<TFileName2> iFiles;
+	CCharacterConverter* iCharacterConverter;
+	CFileReader* iFileReader;
+	TBool iForce;
+	TBool iBinary;
+	LtkUtils::RLtkBuf16 iBuf16;
+	enum TEncoding
+		{
+		EAuto,
+		EBinary,
+		EUtf8,
+		ELatin1,
+		ELtkUtf8,
+		};
+	TEncoding iEncoding;
+	TInt iBlockSize;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cat/cat.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// cat.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+target          fshell_cat.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_CAT
+
+userinclude     .
+userinclude     ..\..\core\src
+#include <fshell/fsh_system_include.mmh>
+capability      FSHELL_CAP_MMP_NORMAL
+
+sourcepath      .
+source          cat.cpp
+
+sourcepath      ..\..\core\src
+source          character_converter.cpp
+source          file_reader.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+library         charconv.lib
+library         ltkutils.lib
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cenrep/cenrep.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,76 @@
+# cenrep.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name cenrep
+
+==short-description
+
+Get and set Central Repository keys.
+
+==long-description
+
+To set integer key zero on repository 0x12345678 to 6 (for example), run:
+
+  cenrep 0x12345678 0 --set-int 6
+
+Note, the Central Repository does not distinguish between 16-bit and 8-bit descriptor values, so if you try listing a key of type string or string8, this tool will display the value in 3 forms:
+
+=over 5
+
+=item *
+
+Interpreted as a 16-bit string.
+
+=item *
+
+Interpreted as an 8-bit string.
+
+=item *
+
+As a hex dump.
+
+=back
+
+It is up to you to figure out which form is appropriate for the key you are looking at. For example, there will be no error if you try and assign a 16-bit string to a key defined in the cenrep data file as string8. It will suceed, but whatever uses this key will almost certainly break.
+
+==argument uint repository_uid optional
+
+The UID of the required repository. If not set, lists all the repositories one uid per line. These can be decoded by for example piping into uidinfo using C<cenrep | uidinfo --stdin>.
+
+==argument uint key optional
+
+The identifier of the required key. If not set, lists all the keys in the repository.
+
+==option int i set-int
+
+Sets the specified key to this integer value.
+
+==option string s set-string
+
+Sets the specified key to this 16-bit descriptor value.
+
+==option bool f force
+
+Attempt to read or set the key while pretending to have the secure ID of the repository creator. Unless the repository is configured to deny access even to its creator (which is rare) this is enough to gain access to otherwise inaccessible repositories.
+
+==option bool d delete
+
+Delete the specified key, or all keys in the repository if no key is specified.
+
+==option bool r reset
+
+Resets the repository. Combined with C<--force>, deletes the actual persists file on disk rather than just calling C<CRepository::Reset>.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cenrep/cenrep.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,434 @@
+// cenrep.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <centralrepository.h>
+#include <fshell/ltkutils.h>
+#include <fshell/descriptorutils.h>
+
+using namespace IoUtils;
+
+class CCmdCenrep : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdCenrep();
+private:
+	CCmdCenrep();
+	void PrintKeyL(TUint aKey, RBuf8& valDes);
+	template <class KEYTYPE>
+	void SetKeyL(const KEYTYPE& aVal);
+	void ListRepositoriesL();
+	void ForceSetKeyL(TInt aVal);
+	void ForceSetKeyL(const TDesC& aVal);
+	void SudoL(TRefByValue<const TDesC> aFmt, ...);
+	void AddFilesL(RArray<TUint>&, const TDesC& aMatch, const TDesC& aDir);
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	// Arguments
+	TUint iRepository;
+	TUint iKey;
+	// Options
+	HBufC* iStringVal;
+	TInt iIntVal;
+	TBool iForce;
+	TBool iDelete;
+	TBool iReset;
+	CRepository* iRep;
+	};
+
+CCommandBase* CCmdCenrep::NewLC()
+	{
+	CCmdCenrep* self = new(ELeave) CCmdCenrep();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdCenrep::~CCmdCenrep()
+	{
+	delete iStringVal;
+	delete iRep;
+	}
+
+CCmdCenrep::CCmdCenrep()
+	{
+	}
+
+const TDesC& CCmdCenrep::Name() const
+	{
+	_LIT(KName, "cenrep");	
+	return KName;
+	}
+
+void CCmdCenrep::DoRunL()
+	{
+	//__DEBUGGER();
+	if (iRepository == 0)
+		{
+		ListRepositoriesL();
+		return;
+		}
+
+	TRAPD(err, iRep = CRepository::NewL(TUid::Uid(iRepository)));
+	if (err && iForce)
+		{
+		// force create a repository?
+		}
+	else
+		{
+		if (err == KErrNotFound)
+			{
+			PrintError(err, _L("Repository 0x%x not found"), iRepository);
+			}
+		User::LeaveIfError(err);
+		}
+
+	if (iDelete)
+		{
+		if (!iArguments.IsPresent(1))
+			{
+			// Delete all
+			if (iForce)
+				{
+				SudoL(_L("--delete"));
+				}
+			else
+				{
+				TUint32 errorKey = 0;
+				err = iRep->Delete(0, 0, errorKey);
+				if (err && errorKey && errorKey != NCentralRepositoryConstants::KUnspecifiedKey)
+					{
+					PrintError(err, _L("Delete failed due to key 0x%x"), errorKey);
+					}
+				}
+			}
+		else
+			{
+			if (iForce)
+				{
+				SudoL(_L("--delete %d"), iKey);
+				}
+			else
+				{
+				err = iRep->Delete(iKey);
+				}
+			}
+		if (err == KErrPermissionDenied)
+			{
+			PrintError(err, _L("Delete failed, retry with --force"));
+			}
+		User::LeaveIfError(err);
+		}
+	else if (iReset)
+		{
+		if (iForce)
+			{
+			delete iRep;
+			iRep = NULL;
+			LtkUtils::RLtkBuf persistsName;
+			CleanupClosePushL(persistsName);
+			persistsName.AppendFormatL(_L("C:\\private\\10202be9\\persists\\%08x.cre"), iRepository);
+			err = FsL().Delete(persistsName);
+			LeaveIfErr(err, _L("Couldn't delete repository file %S"), &persistsName);
+			CleanupStack::PopAndDestroy(&persistsName);
+			}
+		else
+			{
+			User::LeaveIfError(iRep->Reset());
+			}
+		}
+	else if (iOptions.IsPresent(&iIntVal))
+		{
+		// Set int
+		SetKeyL(iIntVal);
+		}
+	else if (iOptions.IsPresent(&iStringVal))
+		{
+		// Set string
+		//TPtrC8 data((TUint8*)iStringVal->Ptr(), iStringVal->Size());
+		//SetKeyL(data);
+		SetKeyL(*iStringVal);
+		}
+	else if (!iArguments.IsPresent(1))
+		{
+		// Get all
+		if (iForce)
+			{
+			SudoL(KNullDesC);
+			}
+		else
+			{
+			RBuf8 valDes;
+			CleanupClosePushL(valDes);
+			valDes.CreateL(NCentralRepositoryConstants::KMaxBinaryLength);
+
+			RArray<TUint32> keys;
+			CleanupClosePushL(keys);
+			iRep->FindL(0, 0, keys);
+			for (TInt i = 0; i < keys.Count(); i++)
+				{
+				PrintKeyL(keys[i], valDes);
+				}
+			CleanupStack::PopAndDestroy(2, &valDes); // keys, valDes
+			}
+		}
+	else
+		{
+		// Get
+		RBuf8 valDes;
+		CleanupClosePushL(valDes);
+		valDes.CreateL(NCentralRepositoryConstants::KMaxBinaryLength * 3); // Because we also use this for hexifying
+		PrintKeyL(iKey, valDes);
+		CleanupStack::PopAndDestroy(&valDes);
+		}
+	}
+
+template <class KEYTYPE>
+void CCmdCenrep::SetKeyL(const KEYTYPE& aVal)
+	{
+	if (!iArguments.IsPresent(1))
+		{
+		LeaveIfErr(KErrArgument, _L("You must specify a key to set"));
+		}
+	if (iForce)
+		{
+		ForceSetKeyL(aVal);
+		}
+	else
+		{
+		TInt err = iRep->Set(iKey, aVal);
+		if (err == KErrArgument)
+			{
+			PrintError(err, _L("Key does not appear to be of the right type"));
+			}
+		User::LeaveIfError(err);
+		}
+	}
+
+void CCmdCenrep::ForceSetKeyL(TInt aVal)
+	{
+	SudoL(_L("%d --set-int %d"), iKey, aVal);
+	}
+
+void CCmdCenrep::ForceSetKeyL(const TDesC& aVal)
+	{
+	SudoL(_L("%d --set-string '%S'"), iKey, &aVal);
+	}
+
+void CCmdCenrep::PrintKeyL(TUint aKey, RBuf8& valDes)
+	{
+	TInt valInt;
+	valDes.Zero();
+	enum TType { EUnknown, EInt, EDes };
+	TType type = EUnknown;
+	TInt reallen = 0;
+
+	TInt err = KErrNotFound;
+
+	if (iForce)
+		{
+		SudoL(_L("%d"), aKey);
+		}
+	else
+		{
+		// Guess the value type
+		// Int?
+		if (type == EUnknown)
+			{
+			err = iRep->Get(aKey, valInt);
+			if (err != KErrArgument)
+				{
+				type = EInt;
+				}
+			}
+		
+		if (type == EUnknown)
+			{
+			// Des?
+			err = iRep->Get(aKey, valDes, reallen);
+			if (err != KErrArgument)
+				{
+				type = EDes;
+				}
+			}
+		}
+
+	switch(err)
+		{
+		case KErrNotFound:
+			PrintError(err, _L("Key not found"));
+			break;
+		case KErrArgument:
+			PrintError(err, _L("Unknown key type, not int, des8 or des16"));
+			break;
+		case KErrPermissionDenied:
+			PrintError(err, _L("Permission denied, retry with --force"));
+			break;
+		/* Won't happen because we now set our buffers to be the max size cenrep can handle
+		case KErrOverflow:
+			valDes16.ReallocL(reallen);
+			valDes8.ReallocL(reallen);
+			if (type == EDes8)
+				{
+				err = rep->Get(iKey, valDes8, reallen); // Better not fail this time!
+				}
+			else
+				{
+				err = rep->Get(iKey, valDes16, reallen); // Better not fail this time!
+				}
+		*/
+		case KErrNone:
+			// do nothing
+			break;
+		default:
+			PrintError(err, _L("Unrecognised error returned from CRepository"));
+			break;
+		}
+
+	if (err == KErrNone)
+		{
+		switch (type)
+			{
+			case EInt:
+				Printf(_L("Key 0x%08x TInt: %d (0x%x)\r\n"), aKey, valInt, valInt);
+				break;
+			/*case EDes8:
+				valDes16.Copy(valDes8);
+				Printf(_L("Key 0x%x TDesC8 length=%d: %S\r\n"), aKey, valDes16.Length(), &valDes16);
+				break;*/
+			case EDes:
+				{
+				TInt len = valDes.Length();
+
+				// Figure out if this string is likely to be 16bit ASCII, 8bit ASCII or just binary data
+				TBool wide = ETrue;
+				TBool ascii = ETrue;
+				if (len&1) wide = EFalse; // Odd number of bytes can't be 16-bit
+				for (TInt i = 0; i < len; i++)
+					{
+					TChar c(valDes[i]);
+					if ((i&1) && valDes[i] != 0) wide = EFalse;
+					if (!(c.IsPrint() && c < 127))
+						{
+						if (!(i&1)) wide = EFalse;
+						ascii = EFalse;
+						}
+					}
+
+				if (wide)
+					{
+					TPtr16 widePtr((TUint16*)valDes.Ptr(), len/2, valDes.MaxLength()/2);
+					Printf(_L("Key 0x%08x TDesC16 length=%d: %S\r\n"), aKey, widePtr.Length(), &widePtr);
+					}
+				else if (ascii)
+					{
+					Printf(_L8("Key 0x%08x TDesC8  length=%d: %S\r\n"), aKey, len, &valDes);
+					}
+				else
+					{
+					Printf(_L("Key 0x%08x TDesC8  hex dump:\r\n"), aKey);
+					LtkUtils::HexDumpToOutput(valDes, Stdout());
+					}
+				}
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+void CCmdCenrep::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendUintL(iRepository, _L("repository_uid"));
+	aArguments.AppendUintL(iKey, _L("key"));
+ 	}
+
+void CCmdCenrep::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendIntL(iIntVal, _L("set-int"));
+	aOptions.AppendStringL(iStringVal, _L("set-string"));
+	aOptions.AppendBoolL(iForce, _L("force"));
+	aOptions.AppendBoolL(iDelete, _L("delete"));
+	aOptions.AppendBoolL(iReset, _L("reset"));
+	}
+
+EXE_BOILER_PLATE(CCmdCenrep)
+
+void CCmdCenrep::ListRepositoriesL()
+	{
+	RArray<TUint> uids;
+	CleanupClosePushL(uids);
+	AddFilesL(uids, _L("*.cre"), _L("Y:\\private\\10202be9\\persists\\"));
+	AddFilesL(uids, _L("*.cre"), _L("Y:\\private\\10202be9\\"));
+	AddFilesL(uids, _L("*.txt"), _L("Y:\\private\\10202be9\\"));
+
+	for (TInt i = 0; i < uids.Count(); i++)
+		{
+		Printf(_L("%08x\r\n"), uids[i]);
+		}
+	CleanupStack::PopAndDestroy(&uids);
+	}
+
+void CCmdCenrep::AddFilesL(RArray<TUint>& aUids, const TDesC& aMatch, const TDesC& aDir)
+	{
+	TFindFile finder(FsL());
+	CDir* files = NULL;
+	TInt err = finder.FindWildByDir(aMatch, aDir, files);
+
+	while (err == KErrNone)
+		{
+		for (TInt i = 0; i < files->Count(); i++)
+			{
+			TUint uid;
+			TLex lex((*files)[i].iName);
+			err = lex.Val(uid, EHex);
+			if (!err)
+				{
+				err = aUids.InsertInOrder(uid);
+				if (err == KErrAlreadyExists) err = KErrNone;
+				}
+			}
+		delete files;
+		files = NULL;
+		err = finder.FindWild(files);
+		}
+
+	if (err && err != KErrNotFound) LeaveIfErr(err, _L("Couldn't read directory %S"), &aDir);
+	}
+
+void CCmdCenrep::SudoL(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	
+	// We use sudo to give ourselves the SID of the repository, in the hope that will confer us more rights to access the data.
+	// Some repos might be configured to deny access even from their own SID; there's nothing we can do in that case
+	TBuf<256> commandLine;
+	commandLine.AppendFormat(_L("--sid 0x%x cenrep.exe 0x%x "), iRepository, iRepository);
+	commandLine.AppendFormatList(aFmt, args);
+	VA_END(args);
+
+	RChildProcess sudo;
+	CleanupClosePushL(sudo);
+	TRAPL(sudo.CreateL(_L("sudo.exe"), commandLine, IoSession(), Stdin(), Stdout(), Stderr()), _L("Couldn't create sudo process"));
+	TRequestStatus logon;
+	sudo.Run(logon);
+	User::WaitForRequest(logon);
+	LeaveIfErr(logon.Int(), _L("Error running sudo %S"), &commandLine);
+	CleanupStack::PopAndDestroy(&sudo);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cenrep/cenrep.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// cenrep.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          cenrep.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_CENREP
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          cenrep.cpp
+
+library         euser.lib
+library         iocli.lib
+library			centralrepository.lib
+library			efsrv.lib
+library			ltkutils.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/byte_pair.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,170 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32\kernel\byte_pair.cpp
+// 
+//
+
+#include <e32cia.h>
+#include "u32std.h"
+
+TInt BytePairDecompress(TUint8* dst, TInt dstSize, TUint8* src, TInt srcSize, TUint8*& srcNext)
+	{
+	TUint8* dstStart = dst;
+	TUint8* dstEnd = dst+dstSize;
+	TUint8* srcEnd = src+srcSize;
+
+	TUint32 LUT[0x100/2];
+	TUint8* LUT0 = (TUint8*)LUT;
+	TUint8* LUT1 = LUT0+0x100;
+
+	TUint8 stack[0x100];
+	TUint8* stackStart = stack+sizeof(stack);
+	TUint8* sp = stackStart;
+
+	TUint32 marker = ~0u;
+	TInt numTokens;
+	TUint32 p1;
+	TUint32 p2;
+
+	TUint32* l = (TUint32*)LUT;
+	TUint32 b = 0x03020100;
+	TUint32 step = 0x04040404;
+	do
+		{
+		*l++ = b;
+		b += step;
+		}
+	while(b>step);
+
+	if(src>=srcEnd)
+		goto error;
+	numTokens = *src++;
+	if(numTokens)
+		{
+		if(src>=srcEnd)
+			goto error;
+		marker = *src++;
+		LUT0[marker] = (TUint8)~marker;
+
+		if(numTokens<32)
+			{
+			TUint8* tokenEnd = src+3*numTokens;
+			if(tokenEnd>srcEnd)
+				goto error;
+			do
+				{
+				TInt b = *src++;
+				TInt p1 = *src++;
+				TInt p2 = *src++;
+				LUT0[b] = (TUint8)p1;
+				LUT1[b] = (TUint8)p2;
+				}
+			while(src<tokenEnd);
+			}
+		else
+			{
+			TUint8* bitMask = src;
+			src += 32;
+			if(src>srcEnd)
+				goto error;
+			TInt b=0;
+			do
+				{
+				TUint8 mask = bitMask[b>>3];
+				if(mask&(1<<(b&7)))
+					{
+					if(src>=srcEnd)
+						goto error;
+					TInt p1 = *src++;
+					if(src>=srcEnd)
+						goto error;
+					TInt p2 = *src++;
+					LUT0[b] = (TUint8)p1;
+					LUT1[b] = (TUint8)p2;		
+					--numTokens;
+					}
+				++b;
+				}
+			while(b<0x100);
+			if(numTokens)
+				goto error;
+			}
+		}
+
+	if(src>=srcEnd)
+		goto error;
+	b = *src++;
+	if(dst>=dstEnd)
+		goto error;
+	p1 = LUT0[b];
+	if(p1!=b)
+		goto not_single;
+next:
+	if(src>=srcEnd)
+		goto done_s;
+	b = *src++;
+	*dst++ = (TUint8)p1;
+	if(dst>=dstEnd)
+		goto done_d;
+	p1 = LUT0[b];
+	if(p1==b)
+		goto next;
+
+not_single:
+	if(b==marker)
+		goto do_marker;
+
+do_pair:
+	p2 = LUT1[b];
+	b = p1;
+	p1 = LUT0[b];
+	if(sp<=stack)
+		goto error;
+	*--sp = (TUint8)p2;
+
+recurse:
+	if(b!=p1)
+		goto do_pair;
+
+	if(sp==stackStart)
+		goto next;
+	b = *sp++;
+	*dst++ = (TUint8)p1;
+	if(dst>=dstEnd)
+		goto error;
+	p1 = LUT0[b];
+	goto recurse;
+
+do_marker:
+	if(src>=srcEnd)
+		goto error;
+	p1 = *src++;
+	goto next;
+
+error:
+	srcNext = 0;
+	return KErrCorrupt;
+
+done_s:
+	*dst++ = (TUint8)p1;
+	srcNext = src;
+	return dst-dstStart;
+
+done_d:
+	--src;
+	srcNext = src;
+	return dst-dstStart;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/chkdeps.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+# chkdeps.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+==name chkdeps
+
+==short-description
+
+Checks the DLL dependancies of a DLL or EXE.
+
+==long-description
+
+Outputs the names of any DLLs that this links against that could not be located. In addition the following criteria are checked to ensure the DLLs would load correctly. This is not an exhaustive list of everything that can cause a DLL to fail to link but it attempts to catch most of the common errors:
+
+=over 5
+
+=item *
+
+The UID3 of the DLL matches what is expected.
+
+=item *
+
+The capabilities are such that the DLL would be allowed to be loaded (only checked if the argument is an EXE).
+
+=item *
+
+The major version of the DLL matches what is expected. (This does not actually appear to be strictly enforced by the loader but it is checked for anyway).
+
+=item *
+
+All the ordinals that are being imported are actually present in the DLL.
+
+=back
+
+==argument filename file_name
+
+The path to a DLL or EXE to check.
+
+==option bool v verbose
+
+Display all linked DLLs, not just missing ones.
+
+==option bool d debug
+
+Enable debug tracing (only useful for debugging chkdeps itself).
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/chkdeps.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,760 @@
+// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+// Accenture - adapted for fshell, much functionality added
+//
+// Description:
+// Based on \SF\OS\KERNELHWSRV\USERLIBANDFILESERVER\FILESERVER\etshell\ts_deps.cpp
+//
+
+#include "chkdeps.h"
+
+CCommandBase* CDllChecker::NewLC()
+	{
+	CDllChecker* self = new(ELeave) CDllChecker();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+const TDesC& CDllChecker::Name() const
+	{
+	_LIT(KName, "chkdeps");
+	return KName;
+	}
+
+void CDllChecker::DoRunL()
+	{
+#ifdef __WINS__
+	PrintWarning(_L("chkdeps only works on E32 (ie ARM) format binaries, not WINS ones"));
+#endif
+	FsL();
+	ConstructL();
+	TBool exists = EFalse;
+		{
+		TEntry e;
+		if (Fs().Entry(iFilename, e) == KErrNone) exists = ETrue;
+		}
+
+	if (!exists)
+		{
+		// Try and resolve
+		iFilename = iFilename.NameAndExt(); // Is this going to work? Assigning to a descriptor a TPtrC that points to itself...?
+		FindDll(iFilename, iFilename, _L("\\sys\\bin\\"));
+		}
+
+	TInt result;
+	iStackBase = &result;
+	iExeInfo = new(ELeave) CDllInfo;
+	iExeInfo->iDllCaps.SetEmpty();
+	iRequiredCaps = &iExeInfo->iDllCaps;
+	TRAP(result, GetImportDataL(iFilename, *iExeInfo));
+	if (result==KErrGeneral)
+		{
+		PrintError(result, _L("%S has no import data"), &iFilename);
+		return;
+		}
+	else if (result)
+		{
+		PrintError(result, _L("Couldn't read %S"), &iFilename);
+		User::Leave(result);
+		}
+	ListArray();	//	Print out the results of DllCheck
+	//Stdin().ReadKey();
+	}
+
+void CDllChecker::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendFileNameL(iFilename, _L("file_name"));
+	}
+
+void CDllChecker::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	aOptions.AppendBoolL(iDebug, _L("debug"));
+	}
+
+EXE_BOILER_PLATE(CDllChecker)
+
+///////////////////////////////////////////////////////////////////////
+
+#define __PRINT(t) { if (iDebug) Printf(t);}
+#define __PRINT1(t,a) { if (iDebug) Printf(t,a);}
+#define __PRINT2(t,a,b) { if (iDebug) Printf(t,a,b);}
+#define __PRINTWAIT(t) { if (iDebug) { Printf(t); Stdin().ReadKey();}}
+
+/*
+  
+CDllChecker::GetImportDataL(aFilename) reads the Image Header, Import Section 
+and all import data for aFilename.  If aFilename is a ROM dll, and thus has no 
+import data, or if the file contains no import data for some other reason the 
+function leaves with KErrGeneral. If a file is compressed, function calls 
+appropriate decompression routine to inflate the import data.
+The function then calls GetDllTableL function which 
+reads the first import block and enters a "for" loop. The Dll's name and Uid3 are obtained 
+from CDllChecker::GetFileNameAndUid().  If the Dll name does not occur in the 
+array of previously checked Dlls, CDllChecker::FindDll() is called.  If the Dll 
+is found,the function then calls CDllChecker::GetImportDataL on the filename acquired by 
+GetFileNameAndUid()(recursive call). 
+
+If the Dll contains no import data or cannot be found, or if the Uid is invalid,
+the next import is checked.
+
+The Uid3 value is checked by calling CDllChecker::CheckUid.  This compares the 
+Uid3 value found in the image header of the file, with that found by 
+GetFileNameAndUid().  If there are any discrepancies,these are noted.
+
+Each potential import is added to the array to 
+indicate its import status.
+
+CDllChecker::ListArray() lists the contents of the array when all imports
+have been checked.
+*/
+
+
+void CDllChecker::ConstructL()
+//
+//	Creates an array to hold DLLs referenced by this executable	
+//
+	{
+	}
+
+CDllChecker::CDllChecker()
+	{
+	}
+
+CDllChecker::~CDllChecker()
+//
+//	Destructor
+//
+	{
+    iDllArray.ResetAndDestroy();
+	delete iExeInfo;
+	}
+
+void FileCleanup(TAny* aPtr)
+	{
+	TFileInput* f=(TFileInput*)aPtr;
+	f->Cancel();
+	delete f;
+	}
+
+void CDllChecker::LoadFileInflateL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile)
+	{
+	TInt pos = aHeader->TotalSize();
+	User::LeaveIfError(iFile.Seek(ESeekStart,pos)); // Start at beginning of compressed data
+
+	TFileInput* file = new (ELeave) TFileInput(iFile);
+	CleanupStack::PushL(TCleanupItem(&FileCleanup,file));
+	CInflater* inflater=CInflater::NewLC(*file);
+	
+	if (aHeader->iCodeSize)
+		{
+		aCode.CreateL(aHeader->iCodeSize);
+		TInt count = inflater->ReadL((TUint8*)aCode.Ptr(), aHeader->iCodeSize, &Mem::Move);
+		if(count != aHeader->iCodeSize)
+			User::Leave(KErrCorrupt);
+		aCode.SetLength(count);
+		}
+	
+	// Compressed executable
+	// iCodeOffset	= header size for format V or above
+	//				= sizeof(E32ImageHeader) for format J
+	TInt restOfFileSize = aHeader->UncompressedFileSize() - aHeader->iCodeOffset - aHeader->iCodeSize; // the size of the exe less header & code
+
+	if (restOfFileSize)
+		{
+		aRestOfFile.CreateL(restOfFileSize);
+		TUint32 count = inflater->ReadL((TUint8*)aRestOfFile.Ptr(), restOfFileSize, &Mem::Move);
+		if(count != restOfFileSize)
+			User::Leave(KErrCorrupt);
+		aRestOfFile.SetLength(count);
+		}
+	CleanupStack::PopAndDestroy(2,file);
+	}
+
+void CDllChecker::LoadFileNoCompressL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile)
+	{
+	TInt codepos = aHeader->TotalSize();
+	if (aHeader->iCodeSize)
+		{
+		aCode.CreateL(aHeader->iCodeSize);
+		User::LeaveIfError(iFile.Read(codepos, aCode, aHeader->iCodeSize));
+		}
+
+	TInt restpos = aHeader->TotalSize() + aHeader->iCodeSize;
+	TInt fileSize;
+	User::LeaveIfError(iFile.Size(fileSize));
+	TInt restOfFileSize = fileSize - aHeader->TotalSize() - aHeader->iCodeSize; // the size of the exe less header & code
+
+	if (restOfFileSize)
+		{
+		aRestOfFile.CreateL(restOfFileSize);
+		User::LeaveIfError(iFile.Read(restpos, aRestOfFile, restOfFileSize));	
+		}
+	}
+
+void CDllChecker::LoadFileBytePairL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile)
+	{
+	TInt pos = aHeader->TotalSize();
+	User::LeaveIfError(iFile.Seek(ESeekStart,pos)); // Start at beginning of compressed data
+
+	CBytePairReader* reader = CBytePairFileReader::NewLC(iFile);
+
+	if (aHeader->iCodeSize)
+		{
+		aCode.CreateL(aHeader->iCodeSize);
+		TUint32 bytes = reader->DecompressPagesL((TUint8*)aCode.Ptr(), aHeader->iCodeSize, &Mem::Move);
+		if((TInt)bytes != aHeader->iCodeSize)
+			User::Leave(KErrCorrupt);
+		aCode.SetLength(bytes);
+		}
+
+	TInt restOfFileSize = ((E32ImageHeaderV*)aHeader)->iUncompressedSize - aHeader->iCodeOffset - aHeader->iCodeSize;
+
+	if (restOfFileSize)
+		{
+		aRestOfFile.CreateL(restOfFileSize);
+		TUint32 count = reader->DecompressPagesL((TUint8*)aRestOfFile.Ptr(), restOfFileSize, &Mem::Move);
+		if(count != restOfFileSize)
+			User::Leave(KErrCorrupt);
+		aRestOfFile.SetLength(count);
+		}
+
+	CleanupStack::PopAndDestroy(reader);
+	}
+
+//function loads file's import information calling decompression routine if needed
+void CDllChecker::LoadFileL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile)
+	{
+	TUint32 aCompression = aHeader->CompressionType();
+
+	if(aCompression==KFormatNotCompressed)
+		{
+		LoadFileNoCompressL(aHeader, aCode, aRestOfFile);
+		}
+	else if(aCompression==KUidCompressionDeflate)
+		{
+		LoadFileInflateL(aHeader, aCode, aRestOfFile);
+		}
+	/*TOMSCI TODO doesn't seem to work...
+	else if (aCompression == KUidCompressionBytePair)
+		{
+		LoadFileBytePairL(aHeader, aCode, aRestOfFile);
+		}*/
+	else
+		{
+		LeaveIfErr(KErrNotSupported, _L("Compression type 0x%x is not supported"), aCompression);
+		}
+	}
+
+
+TBool CDllChecker::CompareDllInfo(const CDllInfo& aDllInfo1, const CDllInfo& aDllInfo2)
+	{
+	return (aDllInfo1.iDllName.CompareF(aDllInfo2.iDllName) == 0);
+	}
+
+								
+//function iterates through the list of libraries the current executable depends on
+//for each dependency in the list the function checks whether the .dll being checked is already added to the array of dependencies
+//if not, the function adds dependency being checked to the array of dependencies and calls GetImportDataL function recursively
+//void CDllChecker::GetDllTableL(TUint8* aImportData, TInt aDllRefTableCount,TUint aFlags)
+//void CDllChecker::GetDllTableL(const TDesC& aFileName, E32ImageHeader* aImageHeader, TUint8* aRestOfFile)
+void CDllChecker::GetDllTableL(const TDesC& aFileName, const E32ImageHeader* aImageHeader, const TUint8* aCode, const TUint8* aImportData)
+	{
+	const TInt aDllRefTableCount = aImageHeader->iDllRefTableCount;
+	const TUint aFlags = aImageHeader->iFlags;
+
+	const E32ImportBlock* block = (const E32ImportBlock*)(aImportData+sizeof(E32ImportSection));
+
+	for (TInt i=0; i<aDllRefTableCount; i++)	
+		{
+		CDllInfo* dllInfo = new(ELeave) CDllInfo;
+		CleanupStack::PushL(dllInfo);
+		dllInfo->iResult = EPending;
+		dllInfo->iNumExports = 0;
+		const TText8* dllName=(aImportData+block->iOffsetOfDllName);
+		TPtrC8 dllNamePtr(dllName, User::StringLength(dllName));
+		GetFileNameAndUid(*dllInfo,dllNamePtr);
+		__PRINT1(_L("Considering \"%S\"...\r\n"),&dllInfo->iDllName);
+		TInt r=iDllArray.Find(dllInfo,TIdentityRelation<CDllInfo>(CompareDllInfo));
+		if (r >= 0)
+			{
+			__PRINT(_L("\tAlready checked\r\n"));
+			CDllInfo* dllInfoPtr = iDllArray[r];
+			if ((dllInfoPtr->iResult!=EPending) && (dllInfoPtr->iUid!=dllInfo->iUid))	
+				{
+				__PRINT2(_L(" Uid3 [%08x] for %S is different from that noted previously\r\n"),dllInfo->iUid,&dllInfo->iDllName);
+				dllInfoPtr->iResult=EUidDifference;
+				}
+			CleanupStack::PopAndDestroy(dllInfo);
+			dllInfo = dllInfoPtr;
+			}
+		else
+			{
+			__PRINT(_L("\tNot previously checked\r\n"));
+			iDllArray.AppendL(dllInfo);
+			CleanupStack::Pop(dllInfo);
+		
+			TFileName fileName;
+			r=FindDll(dllInfo->iDllName,fileName,Env().Pwd());
+			
+			if (r==KErrNotFound)	//	Could not find Dll
+				{
+				dllInfo->iResult=ENotFound;
+				}//	Run to the end of the "for" loop for this i value
+
+			else	//	File was located 
+				{
+				//	Go recursive.  Call GetImportDataL on the new dll, if it imports anything.
+				//	ROM dlls have no import data so this is never called for ROM dlls.
+				//	This *will* terminate.  It is only called on "new" dlls not in the array.
+				iCalls++;
+				
+				TRAP(r,GetImportDataL(fileName, *dllInfo));				
+				switch(r)		
+					{
+					case(KErrGeneral):	//	No import data
+						{
+						dllInfo->iResult=ENoImportData;
+						if (!dllInfo->iDllCaps.HasCapabilities(*iRequiredCaps)) dllInfo->iResult = ERequiredCapabilitiesMissing;
+						break;
+						}
+					case(EUidNotSupported):
+					case(EVersionMismatch):
+						{
+						dllInfo->iResult=(CDllChecker::TResultCheck)r;
+						break;
+						}
+					case(KErrNone):	//	Import data was read
+						{
+						dllInfo->iResult=EFileFoundAndUidSupported;
+						if (!dllInfo->iDllCaps.HasCapabilities(*iRequiredCaps)) dllInfo->iResult = ERequiredCapabilitiesMissing;
+						break;
+						}
+					case(KErrInUse):
+						{
+						__PRINT2(_L("\t\"%S\" is already open\r\n"),&fileName,r);
+						dllInfo->iResult=EAlreadyOpen;
+						break;
+						}
+					case(KErrCorrupt):
+						{
+						__PRINT2(_L("\t\"%S\" has unexpected format\r\n"),&fileName,r);
+						dllInfo->iResult=EAlreadyOpen;
+						break;
+						}
+					default:
+						{
+						__PRINT1(_L("\t\"%S\" could not be opened \r\n"),&fileName);
+						dllInfo->iResult=ECouldNotOpenFile;
+						break;
+						}
+					}	
+				}
+			}
+
+		if (dllInfo->iResult == EFileFoundAndUidSupported)
+			{
+			// Check all the ordinals we import actually exist
+			for (TInt i = 0; i < block->iNumberOfImports; i++)
+				{
+				TInt ordinal = 0;
+				//Printf(_L("we import %d from %S\r\n"), block->Imports()[i], &dllInfo->iDllName);
+				if (aImageHeader->ImportFormat() == KImageImpFmt_ELF)
+					{
+					TUint impd_offset = block->Imports()[i];
+					TUint impd = *(TUint*)(aCode + impd_offset);
+					ordinal = impd & 0xffff;
+					//TUint offset = impd >> 16;
+					}
+				else
+					{
+					ordinal = block->Imports()[i];
+					}
+				//Printf(_L("We import %d (numExports=%d)\r\n"), ordinal, dllInfo->iNumExports);
+				if (ordinal > dllInfo->iNumExports && dllInfo->iResult != ENotFound)
+					{
+					Printf(_L("\tOrdinal %d is missing from \"%S\" (used by \"%S\")\r\n"), ordinal, &dllInfo->iDllName, &aFileName);
+					dllInfo->iResult = EOrdinalMissing;
+					}
+				}
+			}
+		block = (E32ImportBlock*)block->NextBlock(E32ImageHeader::ImpFmtFromFlags(aFlags));
+		}
+	}
+
+
+void CDllChecker::GetImportDataL(const TDesC& aFileName, CDllInfo& aInfo)
+	{
+	TInt cleanupCount=0;
+	//	Check that the file is not a ROM dll.  These have no import data	
+	if (Fs().IsFileInRom(aFileName))
+		{
+		// Still need to fill in caps and export count
+		TRomImageHeader* romHeader = (TRomImageHeader*)Fs().IsFileInRom(aFileName);
+		aInfo.iDllCaps.SetEmpty();
+		SCapabilitySet* caps = &romHeader->iS.iCaps;
+		aInfo.iDllCaps = *(TCapabilitySet*)caps;
+		aInfo.iNumExports = romHeader->iExportDirCount;
+		User::Leave(KErrGeneral);
+		}
+	
+	//open file for reading and push it to autoclose stack
+	TAutoClose<RFile> autoFile;
+	User::LeaveIfError(autoFile.iObj.Open(Fs(),aFileName,EFileShareReadersOnly));
+	autoFile.PushL();
+	cleanupCount++;
+	iFile=autoFile.iObj;
+		
+	//Create a pointer to an Image Header
+	//reserve enough memory for compressed file header because we don't know whether the file is compressed or not 
+	// In fact, allow for a E32ImageHeaderV so we can get the capability info too
+	E32ImageHeaderV* imageHeader=new(ELeave)E32ImageHeaderV;
+	CleanupStack::PushL(imageHeader);
+	cleanupCount++;
+	
+	//read file header
+	TPtr8 ptrToImageHeader((TText8*)(imageHeader),sizeof(E32ImageHeaderV),sizeof(E32ImageHeaderV));
+	User::LeaveIfError(iFile.Read(ptrToImageHeader,sizeof(E32ImageHeaderV)));
+	
+
+	aInfo.iDllCaps.SetEmpty();
+	if (imageHeader->HeaderFormat() >= KImageHdrFmt_V)
+		{
+		SCapabilitySet* caps = &imageHeader->iS.iCaps;
+		aInfo.iDllCaps = *(TCapabilitySet*)caps;
+		}
+	aInfo.iNumExports = imageHeader->iExportDirCount;
+
+	if (imageHeader->iImportOffset==0) // File contains no import data (ROM files never have import data)
+		{	
+		User::Leave(KErrGeneral);
+		}
+
+	RBuf8 code, rest;
+	CleanupClosePushL(code);
+	CleanupClosePushL(rest);
+	cleanupCount += 2;
+	LoadFileL(imageHeader, code, rest); // Read import information in
+			
+	TInt32 uid3=imageHeader->iUid3;
+	if(iCalls!=0)	//	Only check Uid3 of dependencies (ie only after first 
+		{			//	call of recursive function)
+		TInt r=CheckUid3(uid3,aInfo.iUid);
+
+		if (r!=KErrNone) //	Dll's Uid3 is not valid
+			User::Leave(EUidNotSupported);
+
+		TInt version = (imageHeader->iModuleVersion >> 16);
+		if (version != aInfo.iMajorVersion)
+			{
+			Printf(_L("Version mismatch - %S version is %d, expected %d\r\n"), &aFileName, version, aInfo.iMajorVersion);
+			User::Leave(EVersionMismatch);
+			}
+		}
+
+	TInt importOffset = imageHeader->iImportOffset - (imageHeader->iCodeOffset + imageHeader->iCodeSize);
+	if (TInt(importOffset + sizeof(E32ImportSection)) > rest.Size())
+		User::Leave(KErrCorrupt);		
+	//get the table of dependencies
+	//GetDllTableL(restOfFileData+bufferOffset,imageHeader->iDllRefTableCount,imageHeader->iFlags);
+	//GetDllTableL(aFileName, imageHeader, restOfFileData);
+	GetDllTableL(aFileName, imageHeader, code.Ptr(), rest.Ptr() + importOffset);
+
+	CleanupStack::PopAndDestroy(cleanupCount);	
+	}
+
+
+TUint8* CDllChecker::NextBlock(TUint8* aBlock)
+	{
+	E32ImportBlock* block;	
+	//	Advance the pointer to the next block	
+	block=(E32ImportBlock*)aBlock;
+	aBlock=(aBlock+sizeof(E32ImportBlock)+((block->iNumberOfImports)*sizeof(TUint)));		
+	return (aBlock);
+	}
+
+
+TFileNameInfo::TFileNameInfo()
+	{
+	memclr(this, sizeof(TFileNameInfo));
+	}
+
+TInt TFileNameInfo::Set(const TDesC8& aFileName, TUint aFlags)
+	{
+	iUid = 0;
+	iVersion = 0;
+	iPathPos = 0;
+	iName = aFileName.Ptr();
+	iLen = aFileName.Length();
+	iExtPos = aFileName.LocateReverse('.');
+	if (iExtPos<0)
+		iExtPos = iLen;
+	TInt osq = aFileName.LocateReverse('[');
+	TInt csq = aFileName.LocateReverse(']');
+	if (!(aFlags & EAllowUid) && (osq>=0 || csq>=0))
+		{
+		return KErrBadName;
+		}
+	if (osq>=iExtPos || csq>=iExtPos)
+		{
+		return KErrBadName;
+		}
+	TInt p = iExtPos;
+	if ((aFlags & EAllowUid) && p>=10 && iName[p-1]==']' && iName[p-10]=='[')
+		{
+		TPtrC8 uidstr(iName + p - 9, 8);
+		TLex8 uidlex(uidstr);
+		TUint32 uid = 0;
+		TInt r = uidlex.Val(uid, EHex);
+		if (r==KErrNone && uidlex.Eos())
+			iUid = uid, p -= 10;
+		}
+	iUidPos = p;
+	TInt ob = aFileName.LocateReverse('{');
+	TInt cb = aFileName.LocateReverse('}');
+	if (ob>=iUidPos || cb>=iUidPos)
+		{
+		return KErrBadName;
+		}
+	if (ob>=0 && cb>=0 && p-1==cb)
+		{
+		TPtrC8 p8(iName, p);
+		TInt d = p8.LocateReverse('.');
+		TPtrC8 verstr(iName+ob+1, p-ob-2);
+		TLex8 verlex(verstr);
+		if (ob==p-10 && d<ob)
+			{
+			TUint32 ver = 0;
+			TInt r = verlex.Val(ver, EHex);
+			if (r==KErrNone && verlex.Eos())
+				iVersion = ver, p = ob;
+			}
+		else if (d>ob && p-1>d && (aFlags & EAllowDecimalVersion))
+			{
+			TUint32 maj = 0;
+			TUint32 min = 0;
+			TInt r = verlex.Val(maj, EDecimal);
+			TUint c = (TUint)verlex.Get();
+			TInt r2 = verlex.Val(min, EDecimal);
+			if (r==KErrNone && c=='.' && r2==KErrNone && verlex.Eos() && maj<32768 && min<32768)
+				iVersion = (maj << 16) | min, p = ob;
+			}
+		}
+	iVerPos = p;
+	if (iLen>=2 && iName[1]==':')
+		{
+		TUint c = iName[0];
+		if (c!='?' || !(aFlags & EAllowPlaceholder))
+			{
+			c |= 0x20;
+			if (c<'a' || c>'z')
+				{
+				return KErrBadName;
+				}
+			}
+		iPathPos = 2;
+		}
+	TPtrC8 pathp(iName+iPathPos, iVerPos-iPathPos);
+	if (pathp.Locate('[')>=0 || pathp.Locate(']')>=0 || pathp.Locate('{')>=0 || pathp.Locate('}')>=0 || pathp.Locate(':')>=0)
+		{
+		return KErrBadName;
+		}
+	iBasePos = pathp.LocateReverse('\\') + 1 + iPathPos;
+	return KErrNone;
+	}
+
+void TFileNameInfo::GetName(TDes8& aName, TUint aFlags) const
+	{
+	if (aFlags & EIncludeDrive)
+		aName.Append(Drive());
+	if (aFlags & EIncludePath)
+		{
+		if (PathLen() && iName[iPathPos]!='\\')
+			aName.Append('\\');
+		aName.Append(Path());
+		}
+	if (aFlags & EIncludeBase)
+		aName.Append(Base());
+	if ((aFlags & EForceVer) || ((aFlags & EIncludeVer) && VerLen()) )
+		{
+		aName.Append('{');
+		aName.AppendNumFixedWidth(iVersion, EHex, 8);
+		aName.Append('}');		
+		}
+	if ((aFlags & EForceUid) || ((aFlags & EIncludeUid) && UidLen()) )
+		{
+		aName.Append('[');
+		aName.AppendNumFixedWidth(iUid, EHex, 8);
+		aName.Append(']');
+		}
+	if (aFlags & EIncludeExt)
+		aName.Append(Ext());
+	}
+
+
+void CDllChecker::GetFileNameAndUid(CDllInfo &aDllInfo, const TDesC8 &aExportName)
+//	
+//	Gets filename and UID 
+//
+	{	
+	TFileNameInfo filename;
+	filename.Set(aExportName,TFileNameInfo::EAllowUid|TFileNameInfo::EAllowDecimalVersion);
+	TBuf8<KMaxFileName> narrowDllName;
+	filename.GetName(narrowDllName,TFileNameInfo::EIncludeBaseExt);
+	aDllInfo.iDllName.Copy(narrowDllName);
+	aDllInfo.iUid=TUid::Uid(filename.Uid());
+	TUint32 version = filename.Version();
+	aDllInfo.iMajorVersion = version >> 16;
+	aDllInfo.iMinorVersion = version & 0xFFFF;
+	}
+
+
+TInt CDllChecker::CheckUid3(TInt32 aUid3,TUid aUid)
+//
+//	Check that Uid3 is the same in the iDllName and as noted by the Image Header
+//	aUid3 is the value found by the image header
+//	aUid is the value found by parsing the result of block->dllname 
+//	using GetFileNameAndUid()
+	{
+
+	if ((aUid.iUid)==aUid3)
+		{
+
+		__PRINT(_L("\tUid3 is valid\r\n"));
+		return KErrNone;
+		}
+	else
+		{
+
+		__PRINT(_L("\tUid3 value is not supported\r\n"));
+		return (EUidNotSupported);
+		}
+	}
+
+
+
+TInt CDllChecker::FindDll(TDes& aDllName,TFileName& aFileName, const TDesC& aPath)
+//
+// Search for a dll in the following sequence ...
+// 1. Supplied path parameter
+// 2. System directories on all drives
+//
+	{
+	TFindFile findFile(Fs());
+	TInt r=findFile.FindByPath(aDllName,&aPath);
+	if (r==KErrNone)
+		{
+		aFileName=findFile.File();	
+
+		__PRINT1(_L("\t\"%S\" was found (supplied path)\r\n"),&aFileName);
+
+		return(r);
+		}
+
+	r=findFile.FindByDir(aDllName,_L("Y:\\Sys\\Bin\\"));
+	if (r==KErrNone)
+		{
+		aFileName=findFile.File();	
+
+		__PRINT1(_L("\t\"%S\" was found (system directory)\r\n"),&aFileName);
+
+		return(r);
+		}
+	/*
+	if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
+		{
+		r=findFile.FindByDir(aDllName,_L("\\System\\Bin\\"));
+		if (r==KErrNone)
+			{
+			aFileName=findFile.File();	
+
+			__PRINT1(_L("\t\"%S\" was found (system directory)\r\n"),&aFileName);
+
+			return(r);
+			}
+		}
+	*/
+	__PRINT1(_L("\t\"%S\" was not found\r\n"),&aDllName);
+
+	return(KErrNotFound);
+	}
+
+void CDllChecker::ListArray()
+	{
+	const TInt elements=iDllArray.Count();
+	
+	Printf(_L("Number of dependencies checked = %d\r\n"),elements);
+
+	for (TInt i=0;i<elements; i++)
+		{
+		CDllInfo& info = *(iDllArray[i]);
+		TResultCheck res = info.iResult;
+		TBool print = iVerbose || (res != EFileFoundAndUidSupported && res != ENoImportData && res != EAlreadyOpen);
+		if (print) Printf(_L("% 2d: %-15S  Uid3: [%08x] "),(i+1),&info.iDllName,(info.iUid));
+		if (!print) continue;
+		switch(res)
+			{
+		case(ENoImportData):
+			Printf(_L("--- No import data\r\n"));
+			break;
+
+		case(EUidNotSupported):
+			Printf(_L("--- Uid3 is not supported\r\n"));
+			break;
+
+		case(ENotFound):
+			Printf(_L("--- File was not found\r\n"));
+			break;
+
+		case(ECouldNotOpenFile):
+			Printf(_L("--- File could not be opened\r\n"));
+			break;
+
+		case(EUidDifference):
+			Printf(_L("--- File already noted with different Uid\r\n"));
+			break;
+
+		case(EAlreadyOpen):
+			Printf(_L("--- File already open\r\n"));
+			break;
+		
+		case(EFileFoundAndUidSupported):
+			Printf(_L("--- File was found, Uid3 is supported\r\n"));
+			break;
+
+		case ERequiredCapabilitiesMissing:
+			{
+			Printf(_L("--- Dll is missing capabilities:"));
+			for (TInt i = 0; i < ECapability_Limit; i++)
+				{
+				TCapability c = (TCapability)i;
+				if (iRequiredCaps->HasCapability(c) && !info.iDllCaps.HasCapability(c))
+					{
+					Printf(_L8(" %s"), CapabilityNames[i]);
+					}
+				}
+			Printf(_L("\r\n"));
+			break;
+			}
+		case EOrdinalMissing:
+			Printf(_L("--- Required ordinal(s) missing\r\n"));
+			break;
+		case EVersionMismatch:
+			Printf(_L("--- Version mismatch\r\n"));
+			break;
+		default:	//	Will never reach here
+			Printf(_L("--- Undefined\r\n"));
+			break;
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/chkdeps.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,137 @@
+// chkdeps.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#define __INCLUDE_CAPABILITY_NAMES__
+#include <fshell/ioutils.h>
+#include <f32image.h>
+#include "sf_deflate.h"
+#include <e32rom.h>
+#include "sf_pgcompr.h"
+
+using namespace IoUtils;
+
+class CDllChecker : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+
+	// From ts_std.h
+private:
+	enum TResultCheck {EPending,EAlreadyOpen,ECouldNotOpenFile,ENotFound,EUidNotSupported,ENoImportData,EUidDifference,EFileFoundAndUidSupported, /*BEGIN TOMSCI added*/ ERequiredCapabilitiesMissing, EOrdinalMissing, EVersionMismatch };
+	class CDllInfo : public CBase
+		{
+	public:
+		TBuf<KMaxFileName> iDllName;
+		TUid iUid;
+		TResultCheck iResult;
+		TCapabilitySet iDllCaps;
+		TInt iNumExports;
+		TInt16 iMajorVersion;
+		TInt16 iMinorVersion;
+		};
+	
+	RPointerArray<CDllInfo> iDllArray;	//	Array of Imports already checked
+	TInt iCalls;	//	Number of recursive calls of GetImportDataL()
+	
+	RFile iFile;//file object for reading data from phisical file
+	TUint32  iConversionOffset;
+	TAny* iStackBase; // Used in debug only to check stack depth
+private:
+	void GetFileNameAndUid(CDllInfo &aDllInfo, const TDesC8 &aExportName);
+	TInt FindDll(TDes& aDllName,TFileName& aFileName, const TDesC& aPath);
+	TUint8* NextBlock(TUint8* aBlock);
+	
+	void LoadFileInflateL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile);
+	void LoadFileNoCompressL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile);
+	void LoadFileBytePairL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile);
+
+	TInt CheckUid3(TInt32 aUid3,TUid aUid);
+	void LoadFileL(const E32ImageHeaderComp* aHeader, RBuf8& aCode, RBuf8& aRestOfFile);
+	//void GetDllTableL(TUint8* aImportData,TInt aDllRefTableCount,TUint aFlags);
+	//void GetDllTableL(const TDesC& aFileName, E32ImageHeader* aImageHeader, TUint8* aRestOfFile);
+	void GetDllTableL(const TDesC& aFileName, const E32ImageHeader* aImageHeader, const TUint8* aCode, const TUint8* aImportData);
+public:	
+	CDllChecker();
+	~CDllChecker();
+	void ConstructL();	
+	void GetImportDataL(const TDesC& aFileName, CDllInfo& aInfo);	
+	void ListArray();
+	static TInt CompareDllInfo(const CDllInfo& aDllInfo1, const CDllInfo& aDllInfo2);
+private:
+	TBool iVerbose, iDebug;
+	TFileName2 iFilename;
+	CDllInfo* iExeInfo; // Argh I've painted myself into an API corner here... cue quick-and-dirty hack. iRequiredCaps has to point into a CDllInfo::iDllCaps because of refactoring I made without thinking it through. Therefore jump through a few hoops to ensure this is so, to save redoing the code that assumes it. V lazy!
+	TCapabilitySet* iRequiredCaps; // Only relevant if we're checking an exe
+	};
+
+
+
+// Nicked from sf_image.h
+
+class TFileNameInfo
+	{
+public:
+	enum	{
+			EIncludeDrive=1,
+			EIncludePath=2,
+			EIncludeBase=4,
+			EIncludeVer=8,
+			EForceVer=16,
+			EIncludeUid=32,
+			EForceUid=64,
+			EIncludeExt=128,
+			EIncludeDrivePath=EIncludeDrive|EIncludePath,
+			EIncludeBaseExt=EIncludeBase|EIncludeExt,
+			EIncludeDrivePathBaseExt=EIncludeDrive|EIncludePath|EIncludeBase|EIncludeExt,
+			};
+	enum	{
+			EAllowUid=1,
+			EAllowPlaceholder=2,
+			EAllowDecimalVersion=4,
+			};
+public:
+	TFileNameInfo();
+	TInt Set(const TDesC8& aFileName, TUint aFlags);
+	void Dump() const;
+public:
+	inline TInt DriveLen() const {return iPathPos;}
+	inline TInt PathLen() const {return iBasePos-iPathPos;}
+	inline TInt BaseLen() const {return iVerPos-iBasePos;}
+	inline TInt VerLen() const {return iUidPos-iVerPos;}
+	inline TInt UidLen() const {return iExtPos-iUidPos;}
+	inline TInt ExtLen() const {return iLen-iExtPos;}
+	inline TPtrC8 Drive() const {return TPtrC8(iName, iPathPos);}
+	inline TPtrC8 Path() const {return TPtrC8(iName+iPathPos, iBasePos-iPathPos);}
+	inline TPtrC8 DriveAndPath() const {return TPtrC8(iName, iBasePos);}
+	inline TPtrC8 Base() const {return TPtrC8(iName+iBasePos, iVerPos-iBasePos);}
+	inline TPtrC8 VerStr() const {return TPtrC8(iName+iVerPos, iUidPos-iVerPos);}
+	inline TPtrC8 UidStr() const {return TPtrC8(iName+iUidPos, iExtPos-iUidPos);}
+	inline TPtrC8 Ext() const {return TPtrC8(iName+iExtPos, iLen-iExtPos);}
+	inline TUint32 Version() const {return iVersion;}
+	inline TUint32 Uid() const {return iUid;}
+	void GetName(TDes8& aName, TUint aFlags) const;
+public:
+	const TText8* iName;
+	TInt iPathPos;
+	TInt iBasePos;
+	TInt iVerPos;
+	TInt iUidPos;
+	TInt iExtPos;
+	TInt iLen;
+	TUint32 iVersion;
+	TUint32 iUid;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/chkdeps.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// chkdeps.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			chkdeps.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_CHKDEPS
+
+capability		all
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	. // For e32huffman.h
+
+sourcepath		.
+source			chkdeps.cpp
+source			sf_inflate.cpp sf_decomp.cpp
+source			byte_pair.cpp sf_pgcompr.cpp
+
+library			euser.lib efsrv.lib
+library			iocli.lib
+
+epocstacksize 0x14000 // Algorithm is recursive and uses stack heavily, so need lots of it for binaries with complex linkage
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/e32huffman.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,131 @@
+// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32\include\e32huffman.h
+// 
+//
+
+#include <e32std.h>
+
+/** @file
+	@internalTechnology
+*/
+
+/** Bit output stream.
+	Good for writing bit streams for packed, compressed or huffman data algorithms.
+
+	This class must be derived from and OverflowL() reimplemented if the bitstream data
+	cannot be generated into a single memory buffer.
+*/
+class TBitOutput
+	{
+public:
+	IMPORT_C TBitOutput();
+	IMPORT_C TBitOutput(TUint8* aBuf,TInt aSize);
+	inline void Set(TUint8* aBuf,TInt aSize);
+	inline const TUint8* Ptr() const;
+	inline TInt BufferedBits() const;
+//
+	IMPORT_C void WriteL(TUint aValue, TInt aLength);
+	IMPORT_C void HuffmanL(TUint aHuffCode);
+	IMPORT_C void PadL(TUint aPadding);
+private:
+	void DoWriteL(TUint aBits, TInt aSize);
+	virtual void OverflowL();
+private:
+	TUint iCode;		// code in production
+	TInt iBits;
+	TUint8* iPtr;
+	TUint8* iEnd;
+	};
+
+/** Set the memory buffer to use for output
+
+	Data will be written to this buffer until it is full, at which point OverflowL() will
+	be called. This should handle the data and then can Set() again to reset the buffer
+	for further output.
+	
+	@param aBuf The buffer for output
+	@param aSize The size of the buffer in bytes
+*/
+inline void TBitOutput::Set(TUint8* aBuf,TInt aSize)
+	{iPtr=aBuf;iEnd=aBuf+aSize;}
+	
+/** Get the current write position in the output buffer
+
+	In conjunction with the address of the buffer, which should be known to the
+	caller, this describes the data in the bitstream.
+*/
+inline const TUint8* TBitOutput::Ptr() const
+	{return iPtr;}
+	
+/** Get the number of bits that are buffered
+
+	This reports the number of bits that have not yet been written into the
+	output buffer. It will always lie in the range 0..7. Use PadL() to
+	pad the data out to the next byte and write it to the buffer.
+*/
+inline TInt TBitOutput::BufferedBits() const
+	{return iBits+8;}
+
+
+/** Bit input stream. Good for reading bit streams for packed, compressed or huffman
+	data algorithms.
+*/
+class TBitInput
+	{
+public:
+	IMPORT_C TBitInput();
+	IMPORT_C TBitInput(const TUint8* aPtr, TInt aLength, TInt aOffset=0);
+	IMPORT_C void Set(const TUint8* aPtr, TInt aLength, TInt aOffset=0);
+//
+	IMPORT_C TUint ReadL();
+	IMPORT_C TUint ReadL(TInt aSize);
+	IMPORT_C TUint HuffmanL(const TUint32* aTree);
+private:
+	virtual void UnderflowL();
+private:
+	TInt iCount;
+	TUint iBits;
+	TInt iRemain;
+	const TUint32* iPtr;
+	};
+
+/** Huffman code toolkit.
+
+	This class builds a huffman encoding from a frequency table and builds
+	a decoding tree from a code-lengths table
+
+	The encoding generated is based on the rule that given two symbols s1 and s2, with 
+	code length l1 and l2, and huffman codes h1 and h2:
+
+		if l1<l2 then h1<h2 when compared lexicographically
+		if l1==l2 and s1<s2 then h1<h2 ditto
+
+	This allows the encoding to be stored compactly as a table of code lengths
+*/
+class Huffman
+	{
+public:
+	enum {KMaxCodeLength=27};
+	enum {KMetaCodes=KMaxCodeLength+1};
+	enum {KMaxCodes=0x8000};
+public:
+	IMPORT_C static void HuffmanL(const TUint32 aFrequency[],TInt aNumCodes,TUint32 aHuffman[]);
+	IMPORT_C static void Encoding(const TUint32 aHuffman[],TInt aNumCodes,TUint32 aEncodeTable[]);
+	IMPORT_C static void Decoding(const TUint32 aHuffman[],TInt aNumCodes,TUint32 aDecodeTree[],TInt aSymbolBase=0);
+	IMPORT_C static TBool IsValid(const TUint32 aHuffman[],TInt aNumCodes);
+//
+	IMPORT_C static void ExternalizeL(TBitOutput& aOutput,const TUint32 aHuffman[],TInt aNumCodes);
+	IMPORT_C static void InternalizeL(TBitInput& aInput,TUint32 aHuffman[],TInt aNumCodes);
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/sf_decomp.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// f32\sfile\sf_decomp.cpp
+// 
+//
+
+#include "sf_deflate.h"
+#include <f32file.h>
+#include <e32svr.h>
+
+ 
+TFileInput::TFileInput(RFile& aFile)
+	:iFile(aFile),iReadBuf(iBuf1),iPtr(iBuf1,KBufSize)
+	{
+	// issue first read
+	aFile.Read(iPtr,iStat);
+	}
+
+void TFileInput::Cancel()
+	{
+	// absorb signal if outstanding request
+	if (iReadBuf)
+		User::WaitForRequest(iStat);
+	}
+
+void TFileInput::UnderflowL()
+	{
+	TUint8* b=iReadBuf;
+	ASSERT(b!=NULL);
+	User::WaitForRequest(iStat);
+	iReadBuf=0;
+	User::LeaveIfError(iStat.Int());
+	if(iPtr.Length()==0)
+		User::Leave(KErrCorrupt);
+	Set(b,iPtr.Length()*8);
+	// start reading to the next buffer
+	b = b==iBuf1 ? iBuf2 : iBuf1;
+	iPtr.Set(b,0,KBufSize);
+	iFile.Read(iPtr,iStat);
+	iReadBuf=b;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/sf_deflate.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,98 @@
+// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// f32\sfile\sf_deflate.h
+// 
+//
+
+#ifndef __SF_DEFLATE_H__
+#define __SF_DEFLATE_H__
+#include "e32huffman.h"
+#include <e32base.h>
+#include <f32file.h>
+typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength);
+
+#define __CONFIGURABLE_F32_LOADER_INFLATE_WINDOW_SIZE__ 0x8000
+
+// deflation constants
+const TInt KDeflateLengthMag=8;
+const TInt KDeflateDistanceMag=12;
+//
+const TInt KDeflateMinLength=3;
+const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1<<KDeflateLengthMag);
+const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag);
+const TInt KDeflateDistCodeBase=0x200;
+// hashing
+const TUint KDeflateHashMultiplier=0xAC4B9B19u;
+const TInt KDeflateHashShift=24;
+// inflate
+const TInt KInflateWindowSize=__CONFIGURABLE_F32_LOADER_INFLATE_WINDOW_SIZE__ ;
+
+class TEncoding
+	{
+public:
+	enum {ELiterals=256,ELengths=(KDeflateLengthMag-1)*4,ESpecials=1,EDistances=(KDeflateDistanceMag-1)*4};
+	enum {ELitLens=ELiterals+ELengths+ESpecials};
+	enum {EEos=ELiterals+ELengths};
+public:
+	TUint32 iLitLen[ELitLens];
+	TUint32 iDistance[EDistances];
+	};
+
+const TInt KDeflationCodes=TEncoding::ELitLens+TEncoding::EDistances;
+
+NONSHARABLE_CLASS(CInflater) : public CBase
+	{
+public:
+	enum {EBufSize = 0x800, ESafetyZone=8};
+public:
+	static CInflater* NewLC(TBitInput& aInput);
+	~CInflater();
+//
+	TInt ReadL(TUint8* aBuffer,TInt aLength, TMemoryMoveFunction aMemMovefn);
+	TInt SkipL(TInt aLength);
+private:
+	CInflater(TBitInput& aInput);
+	void ConstructL();
+	void InitL();
+	TInt InflateL();
+private:
+	TBitInput* iBits;
+	const TUint8* iRptr;			// partial segment
+	TInt iLen;
+	const TUint8* iAvail;			// available data
+	const TUint8* iLimit;
+	TEncoding* iEncoding;
+	TUint8* iOut;					// circular buffer for distance matches
+	};
+
+void DeflateL(const TUint8* aBuf, TInt aLength, TBitOutput& aOutput);
+
+NONSHARABLE_CLASS(TFileInput) : public TBitInput
+	{
+ 	enum {KBufSize=KInflateWindowSize};
+public:
+	TFileInput(RFile& aFile);
+	void Cancel();
+private:
+	void UnderflowL();
+private:
+	RFile& iFile;
+	TRequestStatus iStat;
+	TUint8* iReadBuf;
+	TPtr8 iPtr;
+	TUint8 iBuf1[KBufSize];
+	TUint8 iBuf2[KBufSize];
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/sf_inflate.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,190 @@
+// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+// Accenture - minor tweaks to build as fshell command
+//
+// Description:
+// f32\sfile\sf_inflate.h
+// 
+//
+
+#include "sf_deflate.h"
+//#include "sf_ldr.h"
+
+//BEGIN fshell patches
+#include <fshell/ioutils.h>
+#define CHECK_FAILURE(x) if (x != 0) { IoUtils::CCommandBase::Static().PrintWarning(_L("sf_inflate check failure at line %d err=%d"), __LINE__, x); }
+#define LEAVE_FAILURE(x) StaticLeaveIfErr(x, _L("sf_inflate error at line %d"), __LINE__)
+//END fshell patches
+
+// Class RInflater
+//
+// The inflation algorithm, complete with huffman decoding
+
+inline CInflater::CInflater(TBitInput& aInput)
+	:iBits(&aInput),iEncoding(0),iOut(0)
+	{}
+
+void CInflater::ConstructL()
+	{
+	iEncoding=new(ELeave) TEncoding;
+	InitL();
+	iLen=0;
+	iOut=new(ELeave) TUint8[KDeflateMaxDistance];
+	iAvail=iLimit=iOut;
+	}
+
+CInflater* CInflater::NewLC(TBitInput& aInput)
+	{
+	CInflater* self=new(ELeave) CInflater(aInput);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CInflater::~CInflater()
+	{
+	delete iEncoding;
+	delete [] iOut;
+	}
+
+TInt CInflater::ReadL(TUint8* aBuffer,TInt aLength, TMemoryMoveFunction aMemMovefn)
+	{
+	TInt tfr=0;
+	for (;;)
+		{
+		TInt len=Min(aLength,iLimit-iAvail);
+		if (len && aBuffer)
+			{
+			aMemMovefn(aBuffer,iAvail,len);
+			aBuffer+=len;
+			}
+		aLength-=len;
+		iAvail+=len;
+		tfr+=len;
+		if (aLength==0)
+			return tfr;
+		len=InflateL();
+		if (len==0)
+			return tfr;
+		iAvail=iOut;
+		iLimit=iAvail+len;
+		}
+	}
+
+TInt CInflater::SkipL(TInt aLength)
+	{
+	return ReadL(0,aLength,Mem::Move);
+	}
+
+void CInflater::InitL()
+	{
+// read the encoding
+	Huffman::InternalizeL(*iBits,iEncoding->iLitLen,KDeflationCodes);
+// validate the encoding
+	if (!Huffman::IsValid(iEncoding->iLitLen,TEncoding::ELitLens) ||
+		!Huffman::IsValid(iEncoding->iDistance,TEncoding::EDistances))
+		LEAVE_FAILURE(KErrCorrupt);
+// convert the length tables into huffman decoding trees
+	Huffman::Decoding(iEncoding->iLitLen,TEncoding::ELitLens,iEncoding->iLitLen);
+	Huffman::Decoding(iEncoding->iDistance,TEncoding::EDistances,iEncoding->iDistance,KDeflateDistCodeBase);
+	}
+
+TInt CInflater::InflateL()
+//
+// consume all data lag in the history buffer, then decode to fill up the output buffer
+// return the number of available bytes in the output buffer. This is only ever less than
+// the buffer size if the end of stream marker has been read
+//
+	{
+// empty the history buffer into the output
+	TUint8* out=iOut;
+	TUint8* const end=out+KDeflateMaxDistance;
+	const TUint32* tree=iEncoding->iLitLen;
+	if (iLen<0)	// EOF
+		return 0;
+	if (iLen>0)
+		goto useHistory;
+//
+	while (out<end)
+		{
+		// get a huffman code
+		{
+		TInt val=iBits->HuffmanL(tree)-TEncoding::ELiterals;
+		if (val<0)
+			{
+			*out++=TUint8(val);
+			continue;			// another literal/length combo
+			}
+		if (val==TEncoding::EEos-TEncoding::ELiterals)
+			{	// eos marker. we're done
+			iLen=-1;
+			break;
+			}
+		// get the extra bits for the code
+		TInt code=val&0xff;
+		if (code>=8)
+			{	// xtra bits
+			TInt xtra=(code>>2)-1;
+			code-=xtra<<2;
+			code<<=xtra;
+			code|=iBits->ReadL(xtra);
+			}
+		if (val<KDeflateDistCodeBase-TEncoding::ELiterals)
+			{
+			// length code... get the code
+			if(TUint(code)>TUint(KDeflateMaxLength-KDeflateMinLength))
+				{
+				CHECK_FAILURE(KErrCorrupt);
+				goto error;
+				}
+			iLen=code+KDeflateMinLength;
+			tree=iEncoding->iDistance;
+			continue;			// read the huffman code
+			}
+		// distance code
+		if(TUint(code)>TUint(KDeflateMaxDistance-1))
+			{
+			CHECK_FAILURE(KErrCorrupt);
+			goto error;
+			}
+		iRptr=out-(code+1);
+		if (iRptr+KDeflateMaxDistance<end)
+			iRptr+=KDeflateMaxDistance;
+		if(!iLen)
+			{
+			CHECK_FAILURE(KErrCorrupt);
+			goto error;
+			}
+		}
+useHistory:
+		{
+		TInt tfr=Min(end-out,iLen);
+		iLen-=tfr;
+		const TUint8* from=iRptr;
+		do
+			{
+			*out++=*from++;
+			if (from==end)
+				from-=KDeflateMaxDistance;
+			} while (--tfr!=0);
+		iRptr=from;
+		tree=iEncoding->iLitLen;
+		}
+
+		};
+	return out-iOut;
+
+error:
+	LEAVE_FAILURE(KErrCorrupt);
+	return 0;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/sf_pgcompr.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,260 @@
+// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+// Accenture - minor tweaks to build in to fshell chkdeps command
+//
+// Description:
+// f32\sfile\sf_pgcompr.cpp
+// 
+//
+
+#include <f32file.h>
+//#include "sf_std.h"
+//#include "sf_ldr.h"
+#include <f32image.h>
+//#include "sf_image.h"
+#include <e32uid.h>
+#include <e32rom.h>
+//#include "sf_cache.h"
+
+#include "sf_pgcompr.h"
+
+extern TInt BytePairDecompress(TUint8* /*dst*/, TInt /*dstSize*/, TUint8* /*src*/, TInt /*srcSize*/, TUint8*& /*srcNext*/);
+
+//BEGIN TOMSCI
+#include <fshell/ioutils.h>
+#define LEAVE_FAILURE(err) StaticLeaveIfErr(err, _L("Byte pair decompress failed at line %d"), __LINE__)
+#define __IF_DEBUG(x)
+//END TOMSCI
+
+
+// CBytePairReader - reading from in-memory buffer
+
+
+CBytePairReader* CBytePairReader::NewLC(TUint8* aBuffer, TUint32 aLength)
+	{
+	CBytePairReader* reader = new (ELeave) CBytePairReader(aBuffer, aLength);
+	CleanupStack::PushL(reader);
+	return reader;
+	}
+
+
+CBytePairReader::CBytePairReader(TUint8* aBuffer, TUint32 aLength)
+	: iNextPage(aBuffer), iBytesLeft(aLength)
+	{
+	}
+
+
+void CBytePairReader::SeekForwardL(TUint aBytes)
+	{
+	if (iBytesLeft < aBytes)
+		LEAVE_FAILURE(KErrCorrupt);
+	iNextPage += aBytes;
+	iBytesLeft -= aBytes;
+	}
+
+
+void CBytePairReader::ReadInTableL()
+	{
+	if (KIndexTableHeaderSize > iBytesLeft)
+		LEAVE_FAILURE(KErrCorrupt);
+	Mem::Copy(&iHeader, iNextPage, KIndexTableHeaderSize);
+	iNextPage += KIndexTableHeaderSize;
+	iBytesLeft -= KIndexTableHeaderSize;
+	
+	__IF_DEBUG(Printf("numberOfPages:%d", iHeader.iNumberOfPages));
+	
+	TUint size = iHeader.iNumberOfPages * sizeof(TUint16);
+	if (size > iBytesLeft)
+		LEAVE_FAILURE(KErrCorrupt);
+	// coverity[buffer_alloc]
+	iIndexTable = new (ELeave) TUint16[size/sizeof(TUint16)];
+	Mem::Copy(iIndexTable, iNextPage, size);
+	iNextPage += size;
+	iBytesLeft -= size;
+	} 
+
+
+void CBytePairReader::ReleaseTable()
+	{
+	delete[] iIndexTable;
+	iIndexTable = NULL;
+	}
+
+
+TUint CBytePairReader::GetPageL(TUint aPageNum, TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn)
+	{
+	if (iIndexTable[aPageNum] > iBytesLeft)
+		LEAVE_FAILURE(KErrCorrupt);
+	iBytesLeft -= iIndexTable[aPageNum];
+	aLength = Min(aLength, KBytePairPageSize);
+
+	TInt size;
+	TUint8* nextPage;
+
+	if (aMemMoveFn)
+		size = BytePairDecompress(iPageBuf, aLength, iNextPage, iIndexTable[aPageNum], nextPage);
+	else
+		size = BytePairDecompress(aTarget, aLength, iNextPage, iIndexTable[aPageNum], nextPage);
+		
+	User::LeaveIfError(size);
+	if (size != aLength)
+		LEAVE_FAILURE(KErrCorrupt);
+	if (iNextPage + iIndexTable[aPageNum] != nextPage)
+		StaticLeaveIfErr(KErrCorrupt, _L("nextPage is %x, expected %x for pagenum %d"), nextPage, iNextPage + iIndexTable[aPageNum], aPageNum);
+//		LEAVE_FAILURE(KErrCorrupt);
+
+//TOMSCI	IoUtils::CCommandBase::Static().Printf(_L("nextPage is 0x%08x, iNextPage+%d\r\n"), nextPage, nextPage - iNextPage);
+
+	// If a memmove() was provided, use that to copy the data to its final target
+	if (aMemMoveFn)
+		aMemMoveFn(aTarget, iPageBuf, size);
+
+	iNextPage = nextPage;
+	return size;
+	}
+
+
+TUint CBytePairReader::DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn)
+	{
+	TUint decompressedSize = 0;
+
+	ReadInTableL();
+	
+	for (TUint curPage = 0; curPage < iHeader.iNumberOfPages; ++curPage)
+		{
+		TUint size = GetPageL(curPage, aTarget, aLength, aMemMoveFn);
+		
+		decompressedSize += size;
+		aTarget += size;
+		aLength -= size;
+		
+		__IF_DEBUG(Printf("decomp page size:%d\n", size ));
+		} 
+	
+	__IF_DEBUG(Printf("decompressedSize:%d", decompressedSize));
+
+	ReleaseTable();
+
+	return decompressedSize;
+	}
+
+
+void CBytePairReader::GetPageOffsetsL(TInt32 aInitialOffset, TInt& aPageCount, TInt32*& aPageOffsets)
+	{
+	ReadInTableL();
+	aPageCount = iHeader.iNumberOfPages;
+	aPageOffsets = new (ELeave) TInt32[aPageCount+1];
+
+	TInt bytes = aInitialOffset + KIndexTableHeaderSize + aPageCount * sizeof(TUint16);
+	for (TInt i = 0; i < aPageCount; ++i)
+		{
+		aPageOffsets[i] = bytes;
+		bytes += iIndexTable[i];
+		}
+	aPageOffsets[aPageCount] = bytes;
+
+	ReleaseTable();
+	}
+
+
+// CBytePairFileReader - reading from file
+
+
+CBytePairFileReader* CBytePairFileReader::NewLC(RFile& aFile)
+	{
+	CBytePairFileReader* reader = new (ELeave) CBytePairFileReader(aFile);
+	CleanupStack::PushL(reader);
+	return reader;
+	}
+
+
+CBytePairFileReader::CBytePairFileReader(RFile& aFile)
+	: CBytePairReader(NULL, 0), iFile(aFile)
+	{
+	}	
+
+
+CBytePairFileReader::~CBytePairFileReader()
+	{
+	ReleaseTable();
+	}
+
+
+void CBytePairFileReader::SeekForwardL(TUint aBytes)
+	{
+	TInt bytes = aBytes;
+	User::LeaveIfError(iFile.Seek(ESeekCurrent, bytes));
+	}
+	
+
+void CBytePairFileReader::ReadInTableL()
+	{
+	TPtr8 header((TUint8*)&iHeader, KIndexTableHeaderSize);
+	User::LeaveIfError(iFile.Read(header, KIndexTableHeaderSize));
+	if (header.Length() != (TInt)KIndexTableHeaderSize)
+		LEAVE_FAILURE(KErrCorrupt);
+	
+	__IF_DEBUG(Printf("numberOfPages:%d", iHeader.iNumberOfPages));
+	
+	TInt size = iHeader.iNumberOfPages * sizeof(TUint16);
+	iIndexTable = new (ELeave) TUint16[size/sizeof(TUint16)];
+	TPtr8 indexTable((TUint8*)iIndexTable, size);
+	User::LeaveIfError(iFile.Read(indexTable, size));
+	if (indexTable.Length() != size)
+		LEAVE_FAILURE(KErrCorrupt);
+	} 
+
+
+TUint CBytePairFileReader::DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn)
+	{
+	TUint decompressedSize = 0;
+
+	ReadInTableL();
+	
+	TUint curPage = 0;
+	while (curPage < iHeader.iNumberOfPages)
+		{
+		TUint bytes = 0;
+		TUint pages = 0;
+		while (curPage + pages < iHeader.iNumberOfPages &&
+			   bytes + iIndexTable[curPage+pages] < sizeof(iBuffer))
+			{
+			bytes += iIndexTable[curPage+pages];
+			++pages;
+			}
+		if(!bytes)
+			LEAVE_FAILURE(KErrCorrupt);
+		TPtr8 data(iBuffer, bytes);
+		User::LeaveIfError(iFile.Read(data, bytes));
+		if (data.Length() != (TInt)bytes)
+			LEAVE_FAILURE(KErrCorrupt);
+		iNextPage = iBuffer;
+		iBytesLeft = bytes;
+
+		for (; pages; ++curPage, --pages)
+			{
+			TUint size = GetPageL(curPage, aTarget, aLength, aMemMoveFn);
+		
+			decompressedSize += size;
+			aTarget += size;
+			aLength -= size;
+		
+			__IF_DEBUG(Printf("decomp page size:%d\n", size ));
+			}
+		} 
+	
+	__IF_DEBUG(Printf("decompressedSize:%d", decompressedSize));
+
+	ReleaseTable();
+
+	return decompressedSize;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdeps/sf_pgcompr.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,89 @@
+// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+// Accenture - minor tweaks to build in to fshell chkdeps command
+//
+// Description:
+// f32\sfile\sf_pgcompr.h
+// 
+//
+
+#ifndef __SF_PGCOMPR_H__
+#define __SF_PGCOMPR_H__
+
+#include <e32base.h>
+#include<f32file.h>
+//#include "sf_std.h"
+#include <f32image.h>
+//#include "sf_image.h"
+#include <e32uid.h>
+#include <e32rom.h>
+//#include "sf_cache.h"
+
+
+const TUint KBytePairPageSize = 4096;
+
+// Buffer sized for at least 8 compressed pages - a noncompressible page is one byte larger
+const TUint KReadNumberOfPages = 8;
+const TUint KPagesBufferSize = (KBytePairPageSize + 1) * KReadNumberOfPages;
+
+typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength); 
+
+struct IndexTableHeader
+	{
+	TInt	iSizeOfData;					// Includes the index and compressed pages
+	TInt	iDecompressedSize;
+	TUint16	iNumberOfPages;
+	};
+
+// sizeof(IndexTableHeader) returns the wrong value due to rounding/padding, so calculate it
+const TUint KIndexTableHeaderSize = sizeof(TInt) + sizeof(TInt) + sizeof(TUint16);
+
+NONSHARABLE_CLASS(CBytePairReader) : public CBase
+	{
+public:
+	static CBytePairReader* NewLC(TUint8* aBuffer, TUint32 aLength);
+	CBytePairReader(TUint8* aBuffer, TUint32 aLength);
+
+	virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn);
+	void GetPageOffsetsL(TInt32 aInitialOffset, TInt& aPageCount, TInt32*& aPageStarts);
+	TUint GetPageL(TUint aPageNum, TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn);		
+	virtual void SeekForwardL(TUint aBytes);
+
+protected:
+	virtual void ReadInTableL();
+	void ReleaseTable();
+
+	IndexTableHeader iHeader;
+	TUint16* iIndexTable;
+	TUint8* iNextPage;
+	TUint iBytesLeft;
+	TUint8 iPageBuf[KBytePairPageSize];
+	};
+
+NONSHARABLE_CLASS(CBytePairFileReader) : public CBytePairReader
+	{
+public:
+	static CBytePairFileReader* NewLC(RFile& aFile);
+	CBytePairFileReader(RFile& aFile);
+	~CBytePairFileReader();
+
+	virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMovefn);
+	virtual void SeekForwardL(TUint aBytes);
+
+protected:
+	virtual void ReadInTableL();
+
+	RFile& iFile;
+	TUint8 iBuffer[KPagesBufferSize];
+	};
+
+#endif // __SF_PGCOMPR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdrift/chkdrift.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# chkdrift.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name chkdrift
+
+==short-description
+
+A tool for checking the drift of the nano-kernel and fast counter tick count.
+
+==long-description
+
+A pair of key presses result in two sets of tick counts being captured and compared. Use an external timer such as http://www.atomic-clock.org.uk to accurately time a long period of time (say 10 minutes or more) and then compare the output displayed.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdrift/chkdrift.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,154 @@
+// chkdrift.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <hal.h>
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdChkdrift : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdChkdrift();
+private:
+	CCmdChkdrift();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	};
+
+
+CCommandBase* CCmdChkdrift::NewLC()
+	{
+	CCmdChkdrift* self = new(ELeave) CCmdChkdrift();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdChkdrift::~CCmdChkdrift()
+	{
+	}
+
+CCmdChkdrift::CCmdChkdrift()
+	{
+	}
+
+const TDesC& CCmdChkdrift::Name() const
+	{
+	_LIT(KName, "chkdrift");	
+
+	return KName;
+	}
+
+TInt NanoTickPeriod()
+	{
+	TInt nanoTickPeriod;
+	if (HAL::Get(HAL::ENanoTickPeriod, nanoTickPeriod) != KErrNone)
+		{
+		nanoTickPeriod = 1000;
+		}
+	return nanoTickPeriod;
+	}
+
+TInt FastCounterFrequency()
+	{
+	TInt fastCounterFrequency;
+	if (HAL::Get(HAL::EFastCounterFrequency, fastCounterFrequency) != KErrNone)
+		{
+		fastCounterFrequency = 1000;
+		}
+	return fastCounterFrequency;
+	}
+
+TBool FastCounterCountsUp()
+	{
+	TBool countsUp;
+	if (HAL::Get(HAL::EFastCounterCountsUp, countsUp) != KErrNone)
+		{
+		countsUp = EFalse;
+		}
+	return countsUp;
+	}
+
+void FormatTime(const TTimeIntervalMicroSeconds& aInterval, TDes& aBuf)
+	{
+	const TInt ms = 1000;
+	const TInt s = ms * ms;
+
+	TBuf<16> format(_L("%.2f "));
+
+	TReal interval = aInterval.Int64();
+	if (interval >= s)
+		{
+		interval /= s;
+		format.Append(_L("s"));
+		}
+	else if (interval >= ms)
+		{
+		interval /= ms;
+		format.Append(_L("ms"));
+		}
+	else
+		{
+		format.Append(_L("us"));
+		}
+
+	aBuf.Format(format, interval);
+	}
+
+void CCmdChkdrift::DoRunL()
+	{
+	TInt nanoTickPeriod = NanoTickPeriod();
+	Printf(_L("NKern tick period: %d\r\n"), nanoTickPeriod);
+	TInt fastCounterFrequency = FastCounterFrequency();
+	Printf(_L("Fast counter frequency: %d\r\n\r\n"), fastCounterFrequency);
+
+	Printf(_L("Press any key to start test\r\n"));
+	TBuf<1> key;
+	ReadL(key);
+	TUint fast1 = User::FastCounter();
+	TUint nano1 = User::NTickCount();
+
+	Printf(_L("Press any key to stop test\r\n"));
+	ReadL(key);
+	TUint fast2 = User::FastCounter();
+	TUint nano2 = User::NTickCount();
+
+	Printf(_L("before: nano: %u, fast: %u\r\n"), nano1, fast1);
+	Printf(_L("after: nano: %u, fast: %u\r\n"), nano2, fast2);
+	TUint64 diffNano = nano2 - nano1;
+	diffNano *= NanoTickPeriod();
+	TUint64 diffFast;
+	
+	if (FastCounterCountsUp())
+		{
+		diffFast = fast2 - fast1;
+		}
+	else
+		{
+		diffFast = fast1 - fast2;
+		}
+
+	TUint64 fastCounterPeriod = 1000000 / FastCounterFrequency();
+	diffFast *= fastCounterPeriod;
+	TBuf<32> timeNano;
+	FormatTime(diffNano, timeNano);
+	TBuf<32> timeFast;
+	FormatTime(diffFast, timeFast);
+	Printf(_L("difference:\r\n\tnano: %u ticks (%Lu us, %S)\r\n\tfast: %u ticks (%Lu us, %S)\r\n"), nano2 - nano1, diffNano, &timeNano, fast2 - fast1, diffFast, &timeFast);
+	}
+
+
+EXE_BOILER_PLATE(CCmdChkdrift)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/chkdrift/chkdrift.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// chkdrift.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          chkdrift.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_CHKDRIFT
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          chkdrift.cpp
+
+library         euser.lib
+library         iocli.lib
+library         hal.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/clipboard/clipboard.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# clipboard.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name clipboard
+
+==short-description
+
+Copies text to or from the clipboard.
+
+==argument string text optional
+
+A string to put on the clipboard. If not specified, prints current clipboard contents.
+
+==option bool s stdin
+
+Read the text from C<stdin> instead of from the command line.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/clipboard/clipboard.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,119 @@
+// clipboard.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/ltkutils.h>
+
+using namespace IoUtils;
+
+class CCmdClipboard : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdClipboard();
+private:
+	CCmdClipboard();
+	void CopyToClipboardL(const TDesC& aBuf);
+	HBufC* GetFromClipboardL();
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	HBufC* iString;
+	TBool iPipe;
+	};
+
+
+CCommandBase* CCmdClipboard::NewLC()
+	{
+	CCmdClipboard* self = new(ELeave) CCmdClipboard();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdClipboard::~CCmdClipboard()
+	{
+	delete iString;
+	}
+
+CCmdClipboard::CCmdClipboard()
+	{
+	}
+
+const TDesC& CCmdClipboard::Name() const
+	{
+	_LIT(KName, "clipboard");	
+	return KName;
+	}
+
+void CCmdClipboard::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg, "text");
+	aArguments.AppendStringL(iString, KArg);
+	}
+
+void CCmdClipboard::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptStdin, "stdin");
+	aOptions.AppendBoolL(iPipe, KOptStdin);
+	}
+
+void CCmdClipboard::DoRunL()
+	{
+	if (iString)
+		{
+		CopyToClipboardL(*iString);
+		}
+	else if (iPipe)
+		{
+		// Copy to clipboard from stdin
+		CTextBuffer* buffer = CTextBuffer::NewLC(0x100);
+		Stdin().SetReadMode(RIoReadHandle::EOneOrMore);
+		TBuf<0x100> buf;
+		while (Stdin().Read(buf) == KErrNone)
+			{
+			buffer->AppendL(buf);
+			}
+
+		CopyToClipboardL(buffer->Descriptor());
+		CleanupStack::PopAndDestroy(buffer);
+		}
+	else
+		{
+		HBufC* res = NULL;
+		TRAPD(err, res = GetFromClipboardL());
+		LeaveIfErr(err, _L("Couldn't read clipboard (clipboard is empty?)"));
+
+		TBool cons = Stdout().AttachedToConsole();
+		if (cons) Printf(_L("Clipboard contents, length=%d:\r\n"), res->Length());
+		Write(*res);
+		if (cons) Write(_L("\r\n"));
+		delete res;
+		}
+	}
+
+void CCmdClipboard::CopyToClipboardL(const TDesC& aBuf)
+	{
+	LtkUtils::CopyToClipboardL(aBuf, &FsL());
+	}
+
+HBufC* CCmdClipboard::GetFromClipboardL()
+	{
+	return LtkUtils::GetFromClipboardL(&FsL());
+	}
+
+EXE_BOILER_PLATE(CCmdClipboard)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/clipboard/clipboard.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// clipboard.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          clipboard.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_CLIPBOARD
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          clipboard.cpp
+
+library         euser.lib
+library         iocli.lib
+library			ltkutils.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cloggerconfig/cloggerconfig.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,104 @@
+# cloggerconfig.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name cloggerconfig
+
+==short-description
+
+Gets and sets the configuration of the Clogger server.
+
+==long-description
+
+If no arguments are given, lists all settings. See F<\epoc32\include\clogger.h> for more information about the C<RClogger> interface, or see L<clogger|clogger> in the fshell documentation. Some of the 'magic numbers' you may wish to use are documented here as well.
+
+Rotate options (for --set-rotate), can be ORed together:
+
+	1  ECopyRotatedToExternalMedia
+	4  EAutoRotateAtStartup
+	8  ECompressRotatedLogs
+
+Global options (for --set-global), can be ORed together:
+
+	1  EBufferLog
+	2  EMirrorToRDebugPrint
+	4  EMirrorToBluetooth
+	8  ERedirectRDebugPrintToClogger
+	16 EDisableFileWriter
+
+==argument string tag_name optional
+
+Specify a particular tag name to get or set.
+
+==argument uint enabled_mask optional
+
+The bitmask to set. If not specified, the curent value is shown instead.
+
+==option uint g set-global
+
+Set global options. See description below.
+
+==option bool p persist
+
+Persist any settings that are changed during this call, by calling C<RClogger::PersistSettings> at the end.
+
+==option bool s reset
+
+Resets all settings, by calling C<RClogger::ResetSettings>.
+
+==option uint o set-rotate
+
+Set rotate options. See description below.
+
+==option bool r rotate
+
+Rotates the log file, for more info see C<RClogger::Rotate>.
+
+==option bool f follow
+
+Displays the logging in the console as it is written. Note that this only shows logging that occurs after the command is invoked. To look at what's already been logged you need to examine the log file F<c:\Logs\clogger.txt> directly. Currently this option has to switch on C<EBufferLog> to function correctly and it dosen't switch it off again at the end.
+
+==option int n num-buffers
+
+Sets the number of buffers to use (if buffered logging is enabled).
+
+==option uint b buffer-size
+
+Sets the buffer size in bytes (if buffered logging is enabled).
+
+==option bool w wipe
+
+Erases everything in F<c:\Logs\clogger.txt>, without rotating.
+
+==option bool d rdebug
+
+Switches on rdebug redirection and prints to console (roughly equivalent to C<--set-global 8 --follow>).
+
+==option bool a backup
+
+Saves the current persisted clogger settings to the removable media.
+
+==option bool e restore
+
+Restores settings saved with C<--backup>.
+
+==option bool D disable-all
+
+Disable all the currently registered tags.
+
+==option bool E enable-all
+
+Enable all the currently registered tags.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cloggerconfig/cloggerconfig.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,433 @@
+// cloggerconfig.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/clogger.h>
+#include <BADESCA.H>
+#include <e32msgqueue.h>
+
+using namespace IoUtils;
+
+class CCmdCloggerConfig : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdCloggerConfig();
+private:
+	CCmdCloggerConfig();
+	void PrintLogL();
+	void GetBackupFileNameL(TFileName& aName);
+	void SetAllL(TBool aEnabled);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RClogger iClogger;
+	RCloggerLogConsumer iLogGetter;
+	TUint iGlobalOptions;
+	TBool iPersist;
+	TBool iReset;
+	HBufC* iTagName;
+	TUint iEnabledMask;
+	TUint iRotateOptions;
+	TBool iRotate;
+	TBool iFollow;
+	TBool iWipe;
+	TInt iNumBuffers;
+	TInt iBufferSize;
+	RBuf iTempBuffer;
+	TBool iRdebug;
+	TBool iBackup;
+	TBool iRestore;
+	TBool iDisableAll;
+	TBool iEnableAll;
+	};
+
+
+CCommandBase* CCmdCloggerConfig::NewLC()
+	{
+	CCmdCloggerConfig* self = new(ELeave) CCmdCloggerConfig();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdCloggerConfig::~CCmdCloggerConfig()
+	{
+	iClogger.Close();
+	iLogGetter.Close();
+	delete iTagName;
+	iTempBuffer.Close();
+	}
+
+CCmdCloggerConfig::CCmdCloggerConfig()
+	{
+	}
+
+const TDesC& CCmdCloggerConfig::Name() const
+	{
+	_LIT(KName, "cloggerconfig");	
+	return KName;
+	}
+
+#define WRITEIF(opt, flag) if (opt & (RClogger :: flag)) { Write(_L(#flag)); Write(_L(" ")); }
+
+void CCmdCloggerConfig::DoRunL()
+	{
+	if (iEnableAll && iDisableAll)
+		{
+		LeaveIfErr(KErrArgument, _L("Can't enable and disable all tags"));
+		}
+
+	User::LeaveIfError(iClogger.Connect());
+
+	TBool listSettings = ETrue;
+	if (iReset)
+		{
+		iClogger.ResetSettings();
+		listSettings = EFalse;
+		}
+	
+	if (iOptions.IsPresent(&iGlobalOptions))
+		{
+		iClogger.SetGlobalOptions(iGlobalOptions);
+		listSettings = EFalse;
+		}
+	if (iOptions.IsPresent(&iRotateOptions))
+		{
+		TInt n;
+		iClogger.GetRotateBehaviour(&n);
+		iClogger.SetRotateBehaviour(n, iRotateOptions);
+		listSettings = EFalse;
+		}
+	if (iNumBuffers || iBufferSize)
+		{
+		if (iNumBuffers == 0)
+			{
+			// Need to read it in as we have to set both at once.  Bad API...
+			iClogger.GetRamBufferSize(&iNumBuffers);
+			}
+		if (iBufferSize == 0)
+			{
+			// Same reason as above
+			iBufferSize = iClogger.GetRamBufferSize(NULL);
+			}
+		iClogger.SetRamBufferSize(iBufferSize, iNumBuffers);
+		listSettings = EFalse;
+		}
+	if (iPersist || iBackup || iRestore)
+		{
+		// We don't do anything here, we take action at the end of this function
+		listSettings = EFalse;
+		}
+	if (iRotate)
+		{
+		TFileName name;
+		TInt err = iClogger.Rotate(name);
+		Printf(_L("Log rotated to %S\r\n"), &name);
+		if (err) PrintError(err, _L("Rotate returned error"));
+		listSettings = EFalse;
+		}
+	else if (iWipe)
+		{
+		TInt oldLogs;
+		TUint rotopt = iClogger.GetRotateBehaviour(&oldLogs);
+		iClogger.SetRotateBehaviour(KMaxTInt, RClogger::EDoNothingSpecial); // Change rotate behaviour temporarily
+		
+		TFileName name;
+		TInt err = iClogger.Rotate(name);
+		//Printf(_L("Log rotated to %S\r\n"), &name);
+		if (err) PrintError(err, _L("Rotate returned error"));
+		else
+			{
+			err = FsL().Delete(name);
+
+			iClogger.SetRotateBehaviour(oldLogs, rotopt); // Restore old behaviour
+			LeaveIfErr(err, _L("Couldn't remove wiped log %S"), &name);
+			}
+
+		listSettings = EFalse;
+		}
+
+	if (iDisableAll)
+		{
+		SetAllL(EFalse);
+		listSettings = EFalse;
+		}
+
+	if (iEnableAll)
+		{
+		SetAllL(ETrue);
+		listSettings = EFalse;
+		}
+
+	if (iRdebug)
+		{
+		TUint opts = iClogger.GetGlobalOptions();
+		opts |= RClogger::ERedirectRDebugPrintToClogger;
+		iClogger.SetGlobalOptions(opts);
+		
+		PrintLogL();
+		}
+
+	if (iFollow)
+		{
+		PrintLogL(); // Does not return
+		}
+
+	if (iArguments.IsPresent(1))
+		{
+		// Set
+		TInt err = iClogger.SetEnabled(*iTagName, iEnabledMask);
+		if (err == KErrNotFound)
+			{
+			PrintError(err, _L("Tag does not exist, couldn't set it. (NOTE: This behaviour will be changed in the future so you can set tags that haven't been created yet!)"));
+			User::Leave(KErrNotFound);
+			}
+		LeaveIfErr(err, _L("Couldn't enable tag."));
+		listSettings = EFalse;
+		}
+	else if (iArguments.IsPresent(0))
+		{
+		// Get
+		TUint32 e = iClogger.IsEnabled(*iTagName);
+		Printf(_L("Tag [%S] enabled: 0x%x\r\n"), iTagName, e);
+		listSettings = EFalse;
+		}
+	
+	if (listSettings)
+		{
+		// List global options
+		TUint globalOptions = iClogger.GetGlobalOptions();
+		Printf(_L("Global options: 0x%x ( "), globalOptions);
+		if (!globalOptions)
+			{
+			Write(_L("None "));
+			}
+		else
+			{
+			WRITEIF(globalOptions, EBufferLog);
+			WRITEIF(globalOptions, EMirrorToRDebugPrint);
+			WRITEIF(globalOptions, EMirrorToBluetooth);
+			WRITEIF(globalOptions, EMirrorToMessageQueue);
+			WRITEIF(globalOptions, ERedirectRDebugPrintToClogger);
+			WRITEIF(globalOptions, EDisableFileWriter);
+			}
+		Write(_L(")\r\n"));
+
+		// List rotate options
+		TInt numLogs = 0;
+		TUint rotateBehaviour = iClogger.GetRotateBehaviour(&numLogs);
+		Printf(_L("Number of rotated logs to keep: %i\r\n"), numLogs);
+		Printf(_L("Rotate behaviour: 0x%x ( "), rotateBehaviour);
+		if (!rotateBehaviour)
+			{
+			Write(_L("EDoNothingSpecial "));
+			}
+		else
+			{
+			WRITEIF(rotateBehaviour, ECopyRotatedToExternalMedia);
+			WRITEIF(rotateBehaviour, EAutoRotateAtStartup);
+			WRITEIF(rotateBehaviour, ECompressRotatedLogs);
+			}
+		Write(_L(")\r\n"));
+
+		// List buffer size
+		TInt numBuffers = 0;
+		TInt bufSize = iClogger.GetRamBufferSize(&numBuffers);
+		Printf(_L("Number of RAM buffers: %i\r\n"), numBuffers);
+		Printf(_L("Size of RAM buffers: %i\r\n"), bufSize);
+
+		// List tags
+		CDesC16Array* tags = NULL;
+		RBuf8 enabled;
+		iClogger.GetTagStatesL(tags, enabled);
+		TInt count = enabled.Size() / 4;
+		if (count) Printf(_L("\r\n"));
+		for (TInt i = 0; i < count; i++)
+			{
+			TPtrC tag = tags->operator[](i);
+			TUint32 e = ((TUint32*)enabled.Ptr())[i];
+			Printf(_L("Tag [%S] enabled: 0x%x\r\n"), &tag, e);
+			}
+		delete tags;
+		enabled.Close();
+		}
+
+	if (iPersist)
+		{
+		iClogger.PersistSettings();
+		}
+
+	if (iBackup)
+		{
+		// Args should be: --exec 'cp -ro C:\Private\10202be9\persists\10272efd.cre E:\Private\10202be9\persists\10272efd.cre'
+		TFileName args;
+		GetBackupFileNameL(args);
+
+		TInt len = args.Length();
+		args.Append(args);
+		args.Append('\'');
+		args[0] = 'C';
+		args.Insert(len, _L(" "));
+		args.Insert(0, _L("--exec 'cp -ro "));
+		
+		RChildProcess shell;
+		shell.CreateL(_L("fshell.exe"), args, IoSession(), Stdin(), Stdout(), Stderr());
+		CleanupClosePushL(shell);
+		TRequestStatus stat;
+		shell.Run(stat);
+		User::WaitForRequest(stat);
+		LeaveIfErr(stat.Int(), _L("Failed to copy cenrep file"));
+		CleanupStack::PopAndDestroy(&shell);
+
+		const TPtrC name = args.Right(len+1);
+		Printf(_L("Settings backed up to '%S, use --restore option to restore.\r\n"), &name);
+		}
+	else if (iRestore)
+		{
+		TFileName args;
+		GetBackupFileNameL(args);
+		TInt len = args.Length();
+		//TEntry e;
+		//LeaveIfErr(FsL().Entry(args, e), _L("No backup file found"));
+		// Args should be: --exec 'cp E:\Private\10202be9\persists\10272efd.cre C:\Private\10202be9\persists\10272efd.cre'
+		args.Append(args);
+		args.Append('\'');
+		args[len] = 'C';
+		args.Insert(len, _L(" "));
+		args.Insert(0, _L("--exec 'cp -ro "));
+		
+		RChildProcess shell;
+		shell.CreateL(_L("fshell.exe"), args, IoSession(), Stdin(), Stdout(), Stderr());
+		CleanupClosePushL(shell);
+		TRequestStatus stat;
+		shell.Run(stat);
+		User::WaitForRequest(stat);
+		LeaveIfErr(stat.Int(), _L("Failed to copy cenrep file"));
+		CleanupStack::PopAndDestroy(&shell);
+
+		Printf(_L("Settings restored. You must reboot or restart cloggerserver to get the new settings\r\n"));
+		}
+	}
+
+void CCmdCloggerConfig::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iTagName, _L("tag_name"));
+	aArguments.AppendUintL(iEnabledMask, _L("enabled_mask"));
+	}
+
+void CCmdCloggerConfig::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendUintL(iGlobalOptions, _L("set-global"));
+	aOptions.AppendBoolL(iPersist, _L("persist"));
+	aOptions.AppendBoolL(iReset, _L("reset"));
+	aOptions.AppendUintL(iRotateOptions, _L("set-rotate"));
+	aOptions.AppendBoolL(iRotate, _L("rotate"));
+	aOptions.AppendBoolL(iFollow, _L("follow"));
+	aOptions.AppendIntL(iNumBuffers, _L("num-buffers"));
+	aOptions.AppendUintL((TUint&)iBufferSize, _L("buffer-size"));
+	aOptions.AppendBoolL(iWipe, _L("wipe"));
+	aOptions.AppendBoolL(iRdebug, _L("rdebug"));
+	aOptions.AppendBoolL(iBackup, _L("backup"));
+	aOptions.AppendBoolL(iRestore, _L("restore"));
+	aOptions.AppendBoolL(iDisableAll, _L("disable-all"));
+	aOptions.AppendBoolL(iEnableAll, _L("enable-all"));
+	}
+
+
+EXE_BOILER_PLATE(CCmdCloggerConfig)
+
+void CCmdCloggerConfig::PrintLogL()
+	{
+	// Because of how RCloggerLogConsumer API works we can only 'see' things in the clogger ChunkForBufs. This however
+	// won't be where the descriptor being logged will be unless buffered logging is enabled. To fix properly,
+	// the rdebug chunk would need to be mapped into the client, and also the Server's iSessionTempBuf and 
+	// CDebugRouterClient's iTempBuf would need to be moved to an accessible chunk
+	TUint opts = iClogger.GetGlobalOptions();
+	opts |= RClogger::EBufferLog;
+	iClogger.SetGlobalOptions(opts);
+
+	LeaveIfErr(iLogGetter.Connect(), _L("Couldn't connect to RCloggerLogConsumer"));
+	iTempBuffer.CreateL(2048);
+
+	TRequestStatus stat;
+	TPtrC8 logLine;
+	while (ETrue)
+		{
+		iLogGetter.GetNextLog(stat, logLine);
+		User::WaitForRequest(stat);
+		LeaveIfErr(stat.Int(), _L("GetNextLog returned error"));
+		
+		// CCommandBase::Write doesn't take 8-bit descriptor so write in iTempBuffer-sized chunks
+		TPtrC8 lineFrag(logLine);
+		const TInt buflen = iTempBuffer.MaxLength();
+		while (lineFrag.Length())
+			{
+			TPtrC8 frag = lineFrag.Left(buflen);
+			iTempBuffer.Copy(frag);
+			//HexDumpL(frag, iTempBuffer);
+			TInt err = Stdout().Write(iTempBuffer);
+			LeaveIfErr(err, _L("Write of %d bytes (%d total) failed"), iTempBuffer.Length(), logLine.Length());
+			lineFrag.Set(lineFrag.Mid(frag.Length()));
+			}
+		}
+	}
+
+void CCmdCloggerConfig::GetBackupFileNameL(TFileName& aName)
+	{
+	TInt err = KErrNone;
+	TInt theDrive = KErrNotFound;
+	// Figure out the first external media device
+	for (TInt drive = EDriveA; drive <= EDriveZ; drive++)
+		{
+		TVolumeInfo info;
+		err = FsL().Volume(info, drive);
+		if (err == KErrNone)
+			{
+			//LogNote(ELogDisks, _L8("Found drive %c iDrivaAtt=0x%x iType=0x%x"), 'A' + drive, info.iDrive.iDriveAtt, info.iDrive.iType);
+			}
+		if (err == KErrNone && ((info.iDrive.iDriveAtt & KDriveAttRemovable) || info.iDrive.iType == EMediaHardDisk)) // Added the check for hard disk so we can use _epoc_drive_d in the emulator
+			{
+			// Found one
+			theDrive = drive;
+			break;
+			}
+		}
+	LeaveIfErr(theDrive, _L("Couldn't find a removable drive to backup on to"));
+
+	aName = _L("?:\\private\\10202be9\\persists\\10272efd.cre");
+	TChar c;
+	Fs().DriveToChar(theDrive, c);
+	aName[0] = c;
+	}
+
+void CCmdCloggerConfig::SetAllL(TBool aEnabled)
+	{
+	CDesC16Array* tags = NULL;
+	RBuf8 states;
+	CleanupClosePushL(states);
+	iClogger.GetTagStatesL(tags, states);
+	CleanupStack::PushL(tags);
+	if (aEnabled)
+		{
+		states.Fill(TChar(0xff));
+		}
+	else
+		{
+		states.FillZ();
+		}
+	iClogger.SetTagStatesL(tags, states);
+	CleanupStack::PopAndDestroy(2, &states);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/cloggerconfig/cloggerconfig.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// cloggerconfig.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          cloggerconfig.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_CLOGGERCONFIG
+
+capability		none
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          cloggerconfig.cpp
+
+library         euser.lib
+library         iocli.lib
+library			clogger.lib
+library			efsrv.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/drvinfo/drvinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# drvinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name drvinfo
+
+==short-description
+
+Display information about the currently installed drives.
+
+==argument string drive_letter optional
+
+The drive letter to display information about (e.g. C<drvinfo c:>). If not specified, information on all drives is displayed.
+
+==option bool v verbose
+
+Display more detailed information.
+
+==option bool H human
+
+Display sizes in human readable form.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/drvinfo/drvinfo.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,282 @@
+// drvinfo.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <f32file.h>
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdDrvinfo : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdDrvinfo();
+private:
+	CCmdDrvinfo();
+	void ArgumentErrorL();
+	void PrintDriveInfoL(TInt aDriveNum);
+	void FormatVolInfoL(const TVolumeInfo& volInfo, IoUtils::CTextBuffer& aPrintBuf);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	HBufC* iDriveLetter;
+	TBool iVerbose;
+	TBool iHuman;
+	};
+
+
+CCommandBase* CCmdDrvinfo::NewLC()
+	{
+	CCmdDrvinfo* self = new(ELeave) CCmdDrvinfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdDrvinfo::~CCmdDrvinfo()
+	{
+	delete iDriveLetter;
+	}
+
+CCmdDrvinfo::CCmdDrvinfo()
+	{
+	}
+
+void CCmdDrvinfo::ArgumentErrorL()
+	{
+	Stderr().Write(_L("Invalid drive specification - use \'<drive_letter>:\', e.g. \'drvinfo c:\'\r\n"));
+	User::Leave(KErrArgument);
+	}
+
+void FormatLineEndL(IoUtils::CTextBuffer& aPrintBuf)
+	{
+	_LIT(KSeparator, " | ");
+	if (aPrintBuf.Descriptor().Right(KSeparator().Length()) == KSeparator)
+		{
+		aPrintBuf.Delete(aPrintBuf.Length() - KSeparator().Length(), KSeparator().Length());
+		}
+	if (aPrintBuf.Descriptor()[aPrintBuf.Length() - 1] == '(')
+		{
+		aPrintBuf.Delete(aPrintBuf.Length() - 2, 2);
+		}
+	else
+		{
+		aPrintBuf.AppendL(_L(")"));
+		}
+	aPrintBuf.AppendL(_L("\r\n"));
+	}
+
+void FormatDrvMediaTypeInfoL(const TDriveInfo& aDrvInfo, IoUtils::CTextBuffer& aPrintBuf)
+	{
+	aPrintBuf.AppendFormatL(_L("TMediaType:\t%d ("), aDrvInfo.iType);
+	switch(aDrvInfo.iType)
+		{
+		case EMediaNotPresent:  aPrintBuf.AppendL(_L("EMediaNotPresent"));   break;
+		case EMediaUnknown:	    aPrintBuf.AppendL(_L("EMediaUnknown"));      break;
+		case EMediaFloppy:      aPrintBuf.AppendL(_L("EMediaFloppy"));       break;
+		case EMediaHardDisk:    aPrintBuf.AppendL(_L("EMediaHardDisk"));     break;
+		case EMediaCdRom:		aPrintBuf.AppendL(_L("EMediaCdRom"));        break;
+		case EMediaRam:         aPrintBuf.AppendL(_L("EMediaRam"));          break;
+		case EMediaFlash:       aPrintBuf.AppendL(_L("EMediaFlash"));        break;
+		case EMediaRom:         aPrintBuf.AppendL(_L("EMediaRom"));          break;
+		case EMediaRemote:      aPrintBuf.AppendL(_L("EMediaRemote"));       break;
+		case EMediaNANDFlash:   aPrintBuf.AppendL(_L("EMediaNANDFlash"));    break;
+		default:                aPrintBuf.AppendL(_L("??? Unknown Type"));   break;
+		};
+	FormatLineEndL(aPrintBuf);
+	}
+
+void FormatDriveAttInfoL(const TDriveInfo& aDrvInfo, IoUtils::CTextBuffer& aPrintBuf)
+	{
+	aPrintBuf.AppendFormatL(_L("DriveAtt:\t0x%x ("), aDrvInfo.iDriveAtt);
+	if (aDrvInfo.iDriveAtt & KDriveAttLocal)         aPrintBuf.AppendL(_L("KDriveAttLocal | "));
+	if (aDrvInfo.iDriveAtt & KDriveAttRom)           aPrintBuf.AppendL(_L("KDriveAttRom | "));
+	if (aDrvInfo.iDriveAtt & KDriveAttRedirected)    aPrintBuf.AppendL(_L("KDriveAttRedirected | "));
+	if (aDrvInfo.iDriveAtt & KDriveAttSubsted)       aPrintBuf.AppendL(_L("KDriveAttSubsted | "));
+	if (aDrvInfo.iDriveAtt & KDriveAttInternal)      aPrintBuf.AppendL(_L("KDriveAttInternal | "));
+	if (aDrvInfo.iDriveAtt & KDriveAttRemovable)     aPrintBuf.AppendL(_L("KDriveAttRemovable | "));
+	if (aDrvInfo.iDriveAtt & KDriveAttRemote)        aPrintBuf.AppendL(_L("KDriveAttRemote | "));
+	if (aDrvInfo.iDriveAtt & KDriveAttTransaction)   aPrintBuf.AppendL(_L("KDriveAttTransaction | "));
+	FormatLineEndL(aPrintBuf);
+	}
+
+void FormatMediaAttInfoL(const TDriveInfo& aDrvInfo, IoUtils::CTextBuffer& aPrintBuf)
+	{
+	aPrintBuf.AppendFormatL(_L("MediaAtt:\t0x%x ("),aDrvInfo.iMediaAtt);
+	if (aDrvInfo.iMediaAtt & KMediaAttVariableSize)      aPrintBuf.AppendL(_L("KMediaAttVariableSize | "));
+	if (aDrvInfo.iMediaAtt & KMediaAttDualDensity)       aPrintBuf.AppendL(_L("KMediaAttDualDensity | "));
+	if (aDrvInfo.iMediaAtt & KMediaAttFormattable)       aPrintBuf.AppendL(_L("KMediaAttFormattable | "));
+	if (aDrvInfo.iMediaAtt & KMediaAttWriteProtected)    aPrintBuf.AppendL(_L("KMediaAttWriteProtected | "));
+	if (aDrvInfo.iMediaAtt & KMediaAttLockable)          aPrintBuf.AppendL(_L("KMediaAttLockable | "));
+	if (aDrvInfo.iMediaAtt & KMediaAttLocked)            aPrintBuf.AppendL(_L("KMediaAttLocked | "));
+	if (aDrvInfo.iMediaAtt & KMediaAttHasPassword)       aPrintBuf.AppendL(_L("KMediaAttHasPassword | "));
+	if (aDrvInfo.iMediaAtt & KMediaAttReadWhileWrite)    aPrintBuf.AppendL(_L("KMediaAttReadWhileWrite | "));
+	if (aDrvInfo.iMediaAtt & KMediaAttDeleteNotify)      aPrintBuf.AppendL(_L("KMediaAttDeleteNotify | "));
+	FormatLineEndL(aPrintBuf);
+	}
+
+void CCmdDrvinfo::FormatVolInfoL(const TVolumeInfo& volInfo, IoUtils::CTextBuffer& aPrintBuf)
+	{
+	if (iVerbose)
+		{
+		aPrintBuf.AppendFormatL(_L("VolId:\t0x%x\r\n"), volInfo.iUniqueID);
+		}
+	aPrintBuf.AppendL(_L("VolSize:\t"));
+	if (iHuman)
+		{
+		aPrintBuf.AppendHumanReadableSizeL(volInfo.iSize);
+		aPrintBuf.AppendL(_L("\r\n"));
+		}
+	else
+		{
+		aPrintBuf.AppendFormatL(_L("%ld\r\n"), volInfo.iSize);
+		}
+	aPrintBuf.AppendL(_L("Free:\t"));
+	if (iHuman)
+		{
+		aPrintBuf.AppendHumanReadableSizeL(volInfo.iFree);
+		aPrintBuf.AppendL(_L("\r\n"));
+		}
+	else
+		{
+		aPrintBuf.AppendFormatL(_L("%ld\r\n"), volInfo.iFree);
+		}
+	if (iVerbose)
+		{
+		aPrintBuf.AppendFormatL(_L("VolName:\t\'%S\'"), &volInfo.iName);
+		}
+	aPrintBuf.AppendL(_L("\r\n"));
+	}
+
+void CCmdDrvinfo::PrintDriveInfoL(TInt aDriveNum)
+	{
+	IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x100);
+
+	TDriveInfo 	driveInfo;
+	User::LeaveIfError(FsL().Drive(driveInfo, aDriveNum));
+
+	TVolumeInfo volInfo;
+	User::LeaveIfError(Fs().Volume(volInfo, aDriveNum));
+
+	if (iVerbose || (iDriveLetter == NULL))
+		{
+		buf->AppendFormatL(_L("Drive:\t%c:\r\n"), 'A'+ aDriveNum);
+		}
+
+	if (iVerbose)
+		{
+		buf->AppendFormatL(_L("Number:\t%d\r\n"), aDriveNum);
+
+		TBuf<256> tbuf;
+		if (Fs().FileSystemName(tbuf, aDriveNum) == KErrNone)
+			{
+			buf->AppendFormatL(_L("FS name:\t\'%S\'\r\n"), &tbuf);
+			}
+
+		FormatDrvMediaTypeInfoL(driveInfo, *buf);
+		buf->AppendFormatL(_L("BatteryState:\t%d\r\n"),driveInfo.iBattery);
+		FormatDriveAttInfoL(driveInfo, *buf);
+		FormatMediaAttInfoL(driveInfo, *buf);
+		}
+
+	FormatVolInfoL(volInfo, *buf);
+
+	CTextFormatter* formatter = CTextFormatter::NewLC(Stdout());
+	formatter->TabulateL(0, 2, buf->Descriptor());
+	Write(formatter->Descriptor());
+
+	CleanupStack::PopAndDestroy(2, buf);
+	}
+
+const TDesC& CCmdDrvinfo::Name() const
+	{
+	_LIT(KName, "drvinfo");	
+	return KName;
+	}
+
+void CCmdDrvinfo::DoRunL()
+	{
+	TInt driveNum = -1;
+
+	if (iDriveLetter)
+		{
+		const TInt len = iDriveLetter->Length();
+
+		if ((len < 2) || (len > 3) || ((*iDriveLetter)[1] != ':'))
+			{
+			ArgumentErrorL();
+			}
+
+		if ((len == 3) && ((*iDriveLetter)[2] != '\\'))
+			{
+			ArgumentErrorL();
+			}
+
+		driveNum = TChar((*iDriveLetter)[0]).GetUpperCase() - 'A';
+
+		if (driveNum > EDriveZ)
+			{
+			ArgumentErrorL();
+			}
+		}
+
+
+	TDriveList driveList;
+	User::LeaveIfError(FsL().DriveList(driveList));
+
+	if (driveNum >= 0)
+		{
+		if (!driveList[driveNum])
+			{
+			ArgumentErrorL();
+			}
+
+		PrintDriveInfoL(driveNum);
+		}
+	else
+		{
+		for (TInt i = 0; i < KMaxDrives; ++i)
+			{
+			if (driveList[i])
+				{
+				TRAPD(err, PrintDriveInfoL(i));
+				if (err)
+					{
+					PrintWarning(_L("Couldn't read drive info for %c"), 'A'+ i);
+					}
+				Printf(_L("\r\n"));
+				}
+			}
+		}
+	}
+
+void CCmdDrvinfo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg, "drive_letter");
+	aArguments.AppendStringL(iDriveLetter, KArg);
+	}
+
+void CCmdDrvinfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	_LIT(KOptHuman, "human");
+
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	aOptions.AppendBoolL(iHuman, KOptHuman);
+	}
+
+
+EXE_BOILER_PLATE(CCmdDrvinfo)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/drvinfo/drvinfo.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// drvinfo.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          drvinfo.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_DRVINFO
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          drvinfo.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ecom/ecom.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+# ecom.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name ecom
+
+==short-description
+
+Query available ECOM plugins and test loading them.
+
+==long-description
+
+This command has no capabilities to ensure that it can see all plugins regardless of their capabilties. To see how plugins behave with different capabilities, try using the sudo command. For example to run at All -TCB do: C<sudo --add-cap All --remove-cap TCB fshell_ecom.exe list xyz>.
+
+==argument enum command
+
+The command to execute.
+
+==enum-value list
+
+List the available interface implementations (by executing C<REComSession::ListImplementationsL>).
+
+==enum-value create
+
+Attempt to create an instance of an interface implementation (by executing C<REComSession::CreateImplementationL>).
+
+==argument uint uid
+
+The interface UID to list (for the C<list> command), or implementation UID to create (for the C<create> command).
+
+==option bool v verbose
+
+For the C<list> command, display all available information about the implementations. For the C<create> command, attempt to use memoryaccess to figure out the DLL the plugin was loaded from.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ecom/ecom.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,151 @@
+// ecom.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/memoryaccesscmd.h>
+#include <ecom/ecom.h>
+#include <fshell/ltkutils.h>
+
+using namespace IoUtils;
+
+class CCmdEcom : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdEcom();
+private:
+	CCmdEcom();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TCmd
+		{
+		EList,
+		ECreate,
+		};
+	TCmd iCmd;
+	TUint iUid;
+	TBool iVerbose;
+	};
+
+
+CCommandBase* CCmdEcom::NewLC()
+	{
+	CCmdEcom* self = new(ELeave) CCmdEcom();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdEcom::~CCmdEcom()
+	{
+	REComSession::FinalClose();
+	}
+
+CCmdEcom::CCmdEcom()
+	{
+	}
+
+const TDesC& CCmdEcom::Name() const
+	{
+	_LIT(KName, "ecom");	
+	return KName;
+	}
+
+void CCmdEcom::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCmd, _L("command"));
+	aArguments.AppendUintL(iUid, _L("uid"));
+	}
+
+void CCmdEcom::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	}
+
+
+EXE_BOILER_PLATE(CCmdEcom)
+
+void CCmdEcom::DoRunL()
+	{
+	TUid uid = TUid::Uid(iUid);
+	if (iCmd == EList)
+		{
+		RImplInfoPtrArray impls;
+		LtkUtils::CleanupResetAndDestroyPushL(impls);
+		TRAPL(REComSession::ListImplementationsL(uid, impls), _L("Couldn't ListImplementations for 0x%x"), iUid);
+		if (impls.Count() == 0)
+			{
+			Printf(_L("No implementations found."));
+			}
+		else
+			{
+			for (TInt i = 0; i < impls.Count(); i++)
+				{
+				const CImplementationInformation* info = impls[i];
+				Printf(_L("0x%x: %S"), info->ImplementationUid(), &info->DisplayName());
+				TInt version = info->Version();
+				if (version != 1)
+					{
+					Printf(_L(" (v%d)"), version);
+					}
+				if (iVerbose)
+					{
+					Printf(_L("\r\nRomOnly=%d RomBased=%d Drive=%c Disabled=%d"), info->RomOnly(), info->RomBased(), 'A' + (TInt)info->Drive(), info->Disabled());
+					if (info->DataType().Length())
+						{
+						Printf(_L8("\r\nDataType: %S"), &info->DataType());
+						}
+					if (info->OpaqueData().Length())
+						{
+						Printf(_L("\r\nOpaqueData:\r\n"));
+						LtkUtils::HexDumpToOutput(info->OpaqueData(), Stdout());
+						}
+					Printf(_L("\r\n"));
+					}
+				Printf(_L("\r\n"));
+				}
+			}
+		CleanupStack::PopAndDestroy(&impls);
+		}
+	else if (iCmd == ECreate)
+		{
+		TUid implKey; // We don't care about this
+		TAny* impl = NULL;
+		TRAPL(impl = REComSession::CreateImplementationL(uid, implKey), _L("Couldn't instanciate plugin uid 0x%x"), iUid);
+		if (impl == NULL) LeaveIfErr(KErrGeneral, _L("Plugin returned NULL implementation pointer!"));
+		Printf(_L("Instanciated plugin 0x%x ok.\r\n"), iUid);
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+		if (iVerbose)
+			{
+			LoadMemoryAccessL();
+			
+			TAny* vtablePtr = *(TAny**)impl;
+			TFullName8 dllName;
+			TInt res = iMemAccess.FindAddressInCodeSegments(dllName, vtablePtr);
+			if (res < 0)
+				{
+				PrintError(res, _L("Couldn't find vtable address in code segments"));
+				}
+			else
+				{
+				Printf(_L8("Implementation is probably from DLL %S at offset %d.\r\n"), &dllName, res);
+				}
+			}
+#endif
+
+		User::Exit(KErrNone); // Don't even try and clean up - the plugin would probably crash if we did
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ecom/ecom.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// ecom.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target				fshell_ecom.exe
+targettype			exe
+uid					0x102835BE FSHELL_UID_ECOM
+capability			none // No caps to be sure we can see all plugins
+
+userinclude			.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath			.
+source				ecom.cpp
+
+library				euser.lib
+library				iocli.lib
+library				ecom.lib
+library				ltkutils.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fcalendar/fcalendar.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,92 @@
+# fcalendar.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fcalendar
+
+==short-description
+
+Queries the calendar database.
+
+==long-description
+
+Note, all dates and times are shown in UTC.
+
+==see-also
+
+L<fcontacts|fcontacts>
+
+==argument enum command optional
+
+The command to execute. Defaults to C<list>.
+
+==enum-value list
+
+List all the calendar entries. Optionally use C<-f> to specify the database file.
+
+==enum-value delete
+
+Delete the specified calendar entries. Use C<-g> to specify the global identifier of the entry to be deleted.
+
+==enum-value add
+
+Add a calendar entry. Use options C<-g>, C<-t>, C<-s>, C<-a> and C<-e> to specify properties.
+
+==enum-value change
+
+Change a calendar entry. Use options C<-g>, C<-s>, C<-a> and C<-e> to specify properties.
+
+==option bool v verbose multiple
+
+Print verbose output. Specify twice (i.e. C<-vv>) for even more detail.
+
+==option string f file
+
+Specify calendar database file. By default F<c:Calendar> will be used. Note, the file name must not contain a path.
+
+==option uint l local_id
+
+Speficify a local identifier. Used by C<add> and C<change> if specified.
+
+==option string g global_id
+
+Speficify a global identifier. Must be specified when using C<add> or C<change>.
+
+==option enum t type
+
+Specify type of entry.
+
+==enum-value appointment
+
+==enum-value todo
+
+==enum-value event
+
+==enum-value reminder
+
+==enum-value anniversary
+
+==option string s summary
+
+Specify the summary (or subject) text. Use quotes if there the string contains spaces.
+
+==option string a start_time
+
+Specify the entry's start time. The string format must match current locale setting. E.g. C<25-12-2009 01:30:30> if current locale setting is UK. Use quotes the string contains spaces.
+
+==option string e end_time
+
+Specify entry's end time. Format as for C<start_time>.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fcalendar/fcalendar.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,765 @@
+// fcalendar.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "caliterator.h"
+#include <calsession.h>
+#include <calentryview.h>
+#include <calentry.h>
+#include <calalarm.h>
+#include <calrrule.h>
+#include <caluser.h>
+#include <calprogresscallback.h>
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+
+// Destroy the RPointerArray
+void DestroyCalEntryRPointerArray(TAny* aPtr)
+    {
+    RPointerArray<CCalEntry>* self = static_cast<RPointerArray<CCalEntry>*> (aPtr);
+    self->ResetAndDestroy();
+    }
+
+
+
+enum TCurrentOperation
+	{
+	ECONewEntryView,
+	ECONone	
+	};
+
+class CCmdCalendar : public CCommandBase, public MCalProgressCallBack
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdCalendar();
+private:
+	CCmdCalendar();
+
+	void DoListEntryL();
+	void DoDeleteEntryL();
+	void DoAddEntryL();
+	void DoChangeEntryL();
+	
+	void ReadCmdLineAmendEntryContentL(CCalEntry& aEntry);	
+	void ListGSDetailL(const TDesC8& aGlobalId, TInt aVerboseLevel);	
+	void PrintEntryDetailL(CCalEntry* aEntry, TInt aVerboseLevel);	
+	
+	void PrintAcceptedOptions();
+	
+	TInt CheckAlarmAlertServer();
+	
+	static const TDesC* UidName(TUid aUid);
+	static const TDesC* EntryMethodToString(CCalEntry::TMethod aEntryMethod);
+	static const TDesC* EntryStatusToString(CCalEntry::TStatus aEntryStatus);	
+	static const TDesC* EntryTypeToString(CCalEntry::TType aEntryType);	
+	static const TDesC* RepeatTypeToString(TCalRRule::TType aType);
+	void PrintTime(const TTime& aTime, TBool aNewline);	
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	
+private:	//MCalProgressCallBack
+	virtual void Progress(TInt aPercentageCompleted);
+	virtual void Completed(TInt aError);
+	virtual TBool NotifyProgress();
+	
+private:
+	CActiveSchedulerWait* iActiveWait;
+	TCurrentOperation iCurOpr;
+	
+	CCalSession* iCalSes;
+	CCalEntryView* iEntryView;
+	
+	RArray<TBool> iVerbose;
+	HBufC* iOptFileName;	//calendar database file full path
+	TInt iOptLocalId;		//local ID
+	HBufC* iOptGlobalID;
+	CCalEntry::TType iOptType;
+	HBufC* iOptSummary;
+	HBufC* iOptStartTime;
+	HBufC* iOptEndTime;
+
+	
+	enum 
+		{
+		EListEntry,
+		EDeleteEntry,
+		EAddEntry,
+		EChangeEntry,		
+		} iCommand;
+	};
+
+CCommandBase* CCmdCalendar::NewLC()
+	{
+	CCmdCalendar* self = new(ELeave) CCmdCalendar();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdCalendar::CCmdCalendar()
+	{
+	iCurOpr = ECONone;
+	iActiveWait = new (ELeave) CActiveSchedulerWait;
+	}
+
+
+CCmdCalendar::~CCmdCalendar()
+	{
+	delete iOptFileName;
+	delete iOptGlobalID;
+	delete iOptSummary;	
+	delete iOptStartTime;
+	delete iOptEndTime;
+	delete iEntryView;
+	delete iCalSes;
+	delete iActiveWait;
+	iVerbose.Close();
+	}
+
+//////////////////////////////////////////////////////
+
+//virtual 
+void CCmdCalendar::Progress(TInt /*aPercentageCompleted*/)
+	{
+	;
+	}
+
+//virtual 
+void CCmdCalendar::Completed(TInt /*aError*/)
+	{
+	TBool bWaitStarted = iActiveWait->IsStarted();
+	ASSERT(bWaitStarted);
+	(void)bWaitStarted;
+	
+	if (iCurOpr == ECONewEntryView)
+		{
+		iActiveWait->AsyncStop();
+		}
+
+	iCurOpr = ECONone;
+	}
+
+TBool CCmdCalendar::NotifyProgress()
+	{
+	return ETrue;
+	}
+
+const TDesC& CCmdCalendar::Name() const
+	{
+	_LIT(KName, "fcalendar");
+	return KName;
+	}
+
+void CCmdCalendar::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgCommand, "command");
+	aArguments.AppendEnumL((TInt&)iCommand, KArgCommand);
+	}
+
+void CCmdCalendar::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptFile, "file");
+	aOptions.AppendStringL(iOptFileName, KOptFile);
+
+	_LIT(KOptLocalId, "local_id");
+	aOptions.AppendUintL((TUint&)iOptLocalId, KOptLocalId);
+
+	_LIT(KOptGlobalId, "global_id");
+	aOptions.AppendStringL(iOptGlobalID, KOptGlobalId);
+
+	_LIT(KOptType, "type");
+	aOptions.AppendEnumL((TInt&)iOptType, KOptType);
+
+	_LIT(KOptSummary, "summary");
+	aOptions.AppendStringL(iOptSummary, KOptSummary);
+
+	_LIT(KOptStartTime, "start_time");
+	aOptions.AppendStringL(iOptStartTime, KOptStartTime);
+
+	_LIT(KOptEndTime, "end_time");
+	aOptions.AppendStringL(iOptEndTime, KOptEndTime);
+	}
+
+//calendar have dependency on !AlamAlertServer,
+//this server is usually part of eikon and not likely to be started separately
+//we need to check if this server is up and running,
+//if not, no point to contiune
+//
+//return:
+//-1 (KErrNotFound): this server is not running
+//0 (KErrNone): OK
+TInt CCmdCalendar::CheckAlarmAlertServer()
+	{
+	TInt Ret;
+	TInt Res;
+	TFindServer findASServer(_L("!AlarmAlertServer"));
+	TFullName name;
+	Res = findASServer.Next(name);
+	
+	if (Res==KErrNotFound )
+		Ret = KErrNotFound;
+	else
+		Ret = KErrNone;
+	
+	return Ret;
+	}
+
+
+void CCmdCalendar::DoRunL()
+	{
+	TInt res;
+	res = CheckAlarmAlertServer();
+	LeaveIfErr(res, _L("!AlarmAlertServer not running"));
+	
+	TRAPD(err, iCalSes = CCalSession::NewL() );
+	LeaveIfErr(err, _L("Could not connect to Calendar server"));
+	
+	//open the calendar database file
+	if (iOptFileName && iOptFileName->Length()>0 ) 
+		{
+		Printf(_L("Calendar Database file: %S \r\n"), iOptFileName);
+		}
+	else
+		{
+		Printf(_L("Calendar Database file unspecified, by default S60 database file is c:Calendar\r\n"));
+		delete iOptFileName; iOptFileName = NULL;
+		iOptFileName = HBufC::NewL(128);
+		*iOptFileName = _L("c:Calendar");
+		}
+	
+	//open database file
+	TRAP(err, iCalSes->OpenL(*iOptFileName) );
+	LeaveIfErr(err, _L("Could not open database file"));
+	
+	//Create an entry view 
+	iCurOpr = ECONewEntryView;
+	TRAP(err, iEntryView = CCalEntryView::NewL(*iCalSes, *this));
+	LeaveIfErr(err, _L("Could not create entry view"));
+	
+	//entry view takes a long time to build index, and we must not do anything 
+	//until we received callback, therefore, must wait here.
+	iActiveWait->Start();
+	
+	///////////////////////////////////////////////////////////////////////////
+	
+	switch (iCommand)
+		{
+	case EListEntry:
+		DoListEntryL();
+		break;
+	case EDeleteEntry:
+		DoDeleteEntryL();	
+		break;
+	case EAddEntry:
+		DoAddEntryL();
+		break;
+	case EChangeEntry:
+		DoChangeEntryL();
+		break;
+		};
+
+	}
+
+void CCmdCalendar::DoChangeEntryL()
+	{
+	//compulsory: globalid, these can not be changed later
+	if (!iOptGlobalID || iOptGlobalID->Length()== 0)
+		LeaveIfErr(KErrArgument, _L("No global id specified. Use -g to specify one"));
+	
+	//type cannot be changed by calendar API, warning user of this fact
+	if (iOptions.IsPresent(&iOptType))
+		{
+		Printf(_L("Type is not allowed to change, this option (-t) will be ignored.\r\n"));
+		}
+		
+	RPointerArray<CCalEntry> CalEntryArray;
+	CleanupStack::PushL(TCleanupItem(DestroyCalEntryRPointerArray, &CalEntryArray));
+		
+	TBuf8<128> TmpGlobalId;
+	TmpGlobalId.Copy(*iOptGlobalID);
+	HBufC8* pGlobalId = HBufC8::New(128);
+	CleanupStack::PushL(pGlobalId);
+	*pGlobalId = TmpGlobalId;
+	
+	//do an extra check if the same global ID is already used.
+	iEntryView->FetchL(*pGlobalId, CalEntryArray);
+	CleanupStack::PopAndDestroy(pGlobalId);
+	pGlobalId = NULL;	//this HBufC is owned by CalEntry
+	
+	TInt Cnt = CalEntryArray.Count();
+	if (Cnt == 0)
+		LeaveIfErr(KErrNotFound, _L("No such Global ID."));					
+
+	Printf(_L("%d entries found\r\n"), Cnt);
+			
+	CCalEntry* pEntry = CalEntryArray[0];
+	
+	//amend necessary calendar entry properties
+	ReadCmdLineAmendEntryContentL(*pEntry);
+		
+	TInt SucessfulEntryCnt = 0;
+	iEntryView->UpdateL(CalEntryArray, SucessfulEntryCnt);
+	
+	Printf(_L("%d entries changed\r\n"), SucessfulEntryCnt);
+	
+	CleanupStack::PopAndDestroy();	
+	}
+
+void CCmdCalendar::DoAddEntryL()
+	{
+	//compulsory: globalid, type, these can not be changed later
+	if (!iOptGlobalID || iOptGlobalID->Length()== 0)
+		LeaveIfErr(KErrArgument, _L("No global id specified. Use -g to specify one"));							
+	if (!iOptions.IsPresent(&iOptType))
+		LeaveIfErr(KErrArgument, _L("No type specified. Use -t to specify one"));
+		
+	RPointerArray<CCalEntry> CalEntryArray;
+	CleanupStack::PushL(TCleanupItem(DestroyCalEntryRPointerArray, &CalEntryArray));
+		
+	TBuf8<128> TmpGlobalId;
+	TmpGlobalId.Copy(*iOptGlobalID);
+	HBufC8* pGlobalId = HBufC8::New(128);
+	CleanupStack::PushL(pGlobalId);
+	*pGlobalId = TmpGlobalId;
+	
+	//do an extra check if the same global ID is already used.
+	//if yes, then adding with such global id is not allowed
+		{
+		iEntryView->FetchL(*pGlobalId, CalEntryArray);
+		TInt Cnt = CalEntryArray.Count();
+		if (Cnt > 0)
+			LeaveIfErr(KErrAlreadyExists, _L("The same Global ID is already used."));					
+		}
+	
+	CCalEntry* pEntry = CCalEntry::NewL(iOptType, pGlobalId, 
+			CCalEntry::EMethodNone, 0);
+	CleanupStack::Pop(pGlobalId);
+	pGlobalId = NULL;	//this HBufC is owned by CalEntry
+		
+	CalEntryArray.Append(pEntry);
+	
+	//amend necessary calendar entry properties
+	ReadCmdLineAmendEntryContentL(*pEntry);
+		
+	TInt SucessfulEntryCnt = 0;
+	iEntryView->StoreL(CalEntryArray, SucessfulEntryCnt);
+	
+	Printf(_L("%d entries added\r\n"), SucessfulEntryCnt);
+	
+	CleanupStack::PopAndDestroy();	
+	}
+
+void CCmdCalendar::DoDeleteEntryL()
+	{
+	//TInt VerboseLevel = iVerbose.Count();
+	if (iOptGlobalID && iOptGlobalID->Length())
+		{
+		RPointerArray<CCalEntry> CalEntryArray;
+		CleanupStack::PushL(TCleanupItem(DestroyCalEntryRPointerArray, &CalEntryArray));
+
+		//FetchL is not Async
+		//and there will be new CCalEntry objects generared 
+		//and pointer stored in CalEntryArray
+		TBuf8<256> GlobalID;
+		GlobalID.Copy(*iOptGlobalID);
+		
+		iEntryView->FetchL(GlobalID, CalEntryArray);
+		
+		TInt EntryCount = CalEntryArray.Count();
+		Printf(_L("%d Entries found\r\n"), EntryCount);
+		
+		for (TInt i=0; i<EntryCount; i++)
+			{
+			CCalEntry* pEntry = CalEntryArray[0];
+			CalEntryArray.Remove(0);				
+			
+			CleanupStack::PushL(pEntry);
+			iEntryView->DeleteL(*pEntry);
+			CleanupStack::PopAndDestroy(pEntry);
+			}		
+		
+		Printf(_L("%d Entries deleted\r\n"), EntryCount);
+		CleanupStack::PopAndDestroy();
+		}
+	else
+		{
+		LeaveIfErr(KErrArgument, _L("No global id specified. Use -g to specify one"));							
+		}	
+	}
+
+//list all agenda entry in the agenda server
+void CCmdCalendar::DoListEntryL()
+	{
+	TInt VerboseLevel = iVerbose.Count();
+	
+	CCalIter* pIter = CCalIter::NewL(*iCalSes);
+	CleanupStack::PushL(pIter);
+	
+	const TDesC8* pGlb = &(pIter->FirstL());
+	TBuf<128> GlbId;
+	
+	while(*pGlb != KNullDesC8)
+		{	
+		GlbId.Copy(*pGlb);
+		Printf(_L("================================\r\n"));
+		Printf(_L("Group Scheduling Entry, Global ID: %S\r\n"), &GlbId);
+		ListGSDetailL(*pGlb, VerboseLevel);
+		
+		pGlb = &(pIter->NextL());
+		}		
+	
+	CleanupStack::PopAndDestroy(pIter);
+	}
+
+//this function read user command line options,
+//and amend the corresponding Entry properties
+//
+void CCmdCalendar::ReadCmdLineAmendEntryContentL(CCalEntry& aEntry)
+	{
+	TInt res;
+	//summary is optional
+	if (iOptSummary && iOptSummary->Length() > 0)
+		aEntry.SetSummaryL(*iOptSummary);	
+
+	TCalTime StartTime = aEntry.StartTimeL();
+	TCalTime EndTime = aEntry.EndTimeL();
+
+	if (iOptStartTime && iOptStartTime->Length() > 0)
+		{
+		TTime Tmp(Time::NullTTime());
+		res = Tmp.Parse(*iOptStartTime);
+		if (res >= 0)
+			{
+			Printf(_L("StartTime recognised as ") );
+			PrintTime(Tmp, ETrue);
+			StartTime.SetTimeUtcL(Tmp);					
+			}
+		else
+			{
+			Printf(_L("Start Date/Time format not recogised.\r\n") );			
+			}		
+		}
+	if (iOptEndTime && iOptEndTime->Length() > 0)
+		{
+		TTime Tmp(Time::NullTTime());
+		res = Tmp.Parse(*iOptEndTime);		
+		if (res >= 0)
+			{
+			Printf(_L("EndTime recognised as ") );
+			PrintTime(Tmp, ETrue);
+			EndTime.SetTimeUtcL(Tmp);		
+			}
+		else
+			{
+			Printf(_L("End Date/Time format not recogised.\r\n") );			
+			}		
+		
+		}
+	
+	aEntry.SetStartAndEndTimeL(StartTime, EndTime);
+	
+	if (iOptLocalId)
+		{
+		TCalLocalUid LocalId = (TCalLocalUid) iOptLocalId;
+		aEntry.SetLocalUidL(LocalId);		
+		}	
+	}
+
+
+//verbose level
+//-v = 1, -vv = 2
+//
+void CCmdCalendar::ListGSDetailL(const TDesC8& aGlobalId, TInt aVerboseLevel)
+	{
+	RPointerArray<CCalEntry> CalEntryArray;
+	CleanupStack::PushL(TCleanupItem(DestroyCalEntryRPointerArray, &CalEntryArray));
+
+	//FetchL is not Async
+	//and there will be new CCalEntry objects generared 
+	//and pointer stored in CalEntryArray  
+	iEntryView->FetchL(aGlobalId, CalEntryArray);
+	
+	TInt Count = CalEntryArray.Count();
+	for (TInt i=0; i<Count; i++)
+		{
+		CCalEntry* pCalEntry= CalEntryArray[0];
+		CalEntryArray.Remove(0);		
+		CleanupStack::PushL(pCalEntry);
+		
+		//make sure leave does not occur inside this scope, 
+		//or contents in CalEntryArray may not be cleaned
+		TRAP_IGNORE(PrintEntryDetailL(pCalEntry, aVerboseLevel));
+		
+		CleanupStack::PopAndDestroy(pCalEntry);
+		}
+	
+	
+	CleanupStack::PopAndDestroy();
+	}
+
+
+void CCmdCalendar::PrintEntryDetailL(CCalEntry* aEntry, TInt aVerboseLevel)
+	{
+	//this matches the Group Scheduling global ID, no need to print it out
+	//const TDesC8& EntryID = aEntry->UidL();	
+	
+	//for verbose level 0
+	//entry type, summery, start time, end time, priority
+	CCalEntry::TType EntryType = aEntry->EntryTypeL();
+	const TDesC& EntrySummary = aEntry->SummaryL();
+	TCalTime EntryStartTime = aEntry->StartTimeL();
+	TCalTime EntryEndTime = aEntry->EndTimeL();
+	
+	TCalTime EntryCompTime = aEntry->CompletedTimeL();
+	TCalTime EntryModDate = aEntry->LastModifiedDateL();
+	
+	TUint EntryPriority = aEntry->PriorityL();
+
+	Printf(_L("Type:%S Priority: %u Summary:%S\r\n"), 
+			EntryTypeToString(EntryType), EntryPriority, &EntrySummary);
+		
+	Printf(_L(" StartTime:"));
+	PrintTime(EntryStartTime.TimeUtcL(), EFalse);
+	
+	Printf(_L(" EndTime:"));
+	PrintTime(EntryEndTime.TimeUtcL(), EFalse);
+
+	Printf(_L("\r\n"));
+	Printf(_L(" CompletedTime:"));
+	PrintTime(EntryCompTime.TimeUtcL(), EFalse);
+	
+	Printf(_L(" Last Modified:"));
+	PrintTime(EntryModDate.TimeUtcL(), EFalse);
+
+	Printf(_L("\r\n"));
+	
+	
+	if (aVerboseLevel < 1)
+		return;
+	
+	//local id, location, status, method, description
+	TCalLocalUid EntryLocalId = aEntry->LocalUidL();	
+	const TDesC& EntryLocation = aEntry->LocationL();
+	CCalEntry::TStatus EntryStatus = aEntry->StatusL();
+	CCalEntry::TMethod EntryMethod = aEntry->MethodL();
+	const TDesC& EntryDesc = aEntry->DescriptionL();
+	TInt EntrySequenceNo = aEntry->SequenceNumberL();
+	
+	Printf(_L(" LocalId:%u, SeqNo:%d,Location:%S Description:%S\r\n"),
+			EntryLocalId, EntrySequenceNo, &EntryLocation, &EntryDesc);
+	Printf(_L(" Status:%S Method:%S\r\n"),
+			EntryStatusToString(EntryStatus), EntryMethodToString(EntryMethod));
+	
+	
+	//alarm
+	CCalAlarm* pAlarm = aEntry->AlarmL();
+	TPtrC AlarmYesNo = (pAlarm)?_L("Yes"):_L("No");
+	Printf(_L(" Alarm: %S "), &AlarmYesNo);
+	
+	if (pAlarm && aVerboseLevel > 1)
+		{
+		CleanupStack::PushL(pAlarm);
+		const TDesC& AlarmSound = pAlarm->AlarmSoundNameL();
+		TTimeIntervalMinutes AlarmOffset = pAlarm->TimeOffset();
+		
+		Printf(_L("AlarmSound:%S, MinutesInAdvance:%d"), 
+				&AlarmSound, AlarmOffset.Int());
+		
+		//CCalContent is optional, will be included from calalarm if it's present
+#ifdef __CALCONTENT_H__
+		CCalContent* pAlarmContent = pAlarm->AlarmAction();
+		if (pAlarmContent)
+			{
+			const TDesC8& AlarmContent = pAlarmContent->Content();
+			const TDesC8& AlarmMime = pAlarmContent->MimeType();
+
+			Printf(_L8("\r\nAlarmContent:%S, AlarmMime:%S "), 
+					&AlarmContent, &AlarmMime);
+			
+			}
+#endif
+		CleanupStack::PopAndDestroy(pAlarm);
+		}
+	Printf(_L("\r\n"));
+	
+	//repeat rules
+	TCalRRule RepeatRule;
+	TBool bRepeat = aEntry->GetRRuleL(RepeatRule);
+	TPtrC RepeatYesNo = (bRepeat)?_L("Yes"):_L("No");
+	Printf(_L(" Repeat: %S "), &RepeatYesNo);
+	
+	if (bRepeat && aVerboseLevel > 1)
+		{
+		TCalRRule::TType RepeatType = RepeatRule.Type();
+		TInt RepeatInterval = RepeatRule.Interval();
+		TUint RepeatCount = RepeatRule.Count();
+
+		Printf(_L("RepeatType: %S Interval: %d Count:%u\r\n"),
+				RepeatTypeToString(RepeatType), RepeatInterval, RepeatCount);
+		TCalTime RepeatStart = RepeatRule.DtStart();
+		TCalTime RepeatUntil = RepeatRule.Until();
+		
+		Printf(_L(" RepeatStart:"));
+		PrintTime(RepeatStart.TimeUtcL(), EFalse);
+		
+		Printf(_L(" RepeatUntil:"));
+		PrintTime(RepeatUntil.TimeUtcL(), EFalse);
+		}
+	Printf(_L("\r\n"));
+		
+	//attendee, in most of phone implementation it is not used
+	RPointerArray<CCalAttendee>& AttendeeArray = aEntry->AttendeesL();
+	TInt AttendeeCnt = AttendeeArray.Count();
+	TPtrC AttendeeYesNo = (AttendeeCnt>0)?_L("Yes"):_L("No");
+	Printf(_L(" Attendee: %S "), &AttendeeYesNo);
+
+	if (AttendeeCnt>0 && aVerboseLevel > 1)
+		{
+		for (TInt i=0; i<AttendeeCnt; i++)
+			{
+			CCalAttendee* pAttendee = AttendeeArray[i];
+			const TDesC& AttendeeName = pAttendee->CommonName();
+			Printf(_L("Attendee:%S "), &AttendeeName);
+			}
+		}
+	Printf(_L("\r\n"));
+		
+	}
+
+//print the accepted options from the command line
+void CCmdCalendar::PrintAcceptedOptions()
+	{
+	}
+
+
+void CCmdCalendar::PrintTime(const TTime& aTime, TBool aNewline)
+	{
+	
+	TTime NullTime = Time::NullTTime();
+	if (aTime == NullTime) 
+		{
+		Printf(_L("(NullTime)"));
+		}
+	else
+		{
+		_LIT8(KDateTimeFormat, "%d-%02d-%02d %02d:%02d:%02d");
+		TDateTime dt = aTime.DateTime();
+		Printf(KDateTimeFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
+		}
+	
+	if (aNewline) Printf(_L("\r\n"));
+	}
+
+
+#define CASE_LIT(x) case x: { _LIT(KName, #x); return &KName; }
+
+
+const TDesC* CCmdCalendar::RepeatTypeToString(TCalRRule::TType aType)
+	{
+	switch(aType)
+		{
+		CASE_LIT(TCalRRule::EInvalid)
+		CASE_LIT(TCalRRule::EDaily)
+		CASE_LIT(TCalRRule::EWeekly)
+		CASE_LIT(TCalRRule::EMonthly)
+		CASE_LIT(TCalRRule::EYearly)
+		default:
+			{
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+const TDesC* CCmdCalendar::EntryMethodToString(CCalEntry::TMethod aEntryMethod)
+	{
+	switch(aEntryMethod)
+		{
+		CASE_LIT(CCalEntry::EMethodNone)
+		CASE_LIT(CCalEntry::EMethodPublish)
+		CASE_LIT(CCalEntry::EMethodRequest)
+		CASE_LIT(CCalEntry::EMethodReply)
+		CASE_LIT(CCalEntry::EMethodAdd)
+		CASE_LIT(CCalEntry::EMethodCancel)
+		CASE_LIT(CCalEntry::EMethodRefresh)
+		CASE_LIT(CCalEntry::EMethodCounter)
+		CASE_LIT(CCalEntry::EMethodDeclineCounter)
+		default:
+			{
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+const TDesC* CCmdCalendar::EntryStatusToString(CCalEntry::TStatus aEntryStatus)
+	{
+	switch(aEntryStatus)
+		{
+		CASE_LIT(CCalEntry::ETentative)
+		CASE_LIT(CCalEntry::EConfirmed)
+		CASE_LIT(CCalEntry::ECancelled)
+		CASE_LIT(CCalEntry::ETodoNeedsAction)
+		CASE_LIT(CCalEntry::ETodoCompleted)
+		CASE_LIT(CCalEntry::ETodoInProcess)
+		CASE_LIT(CCalEntry::ENullStatus)
+		default:
+			{
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+const TDesC* CCmdCalendar::EntryTypeToString(CCalEntry::TType aEntryType)
+	{
+	switch(aEntryType)
+		{
+		CASE_LIT(CCalEntry::EAppt)
+		CASE_LIT(CCalEntry::ETodo)
+		CASE_LIT(CCalEntry::EEvent)
+		CASE_LIT(CCalEntry::EReminder)
+		CASE_LIT(CCalEntry::EAnniv)
+		default:
+			{
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+const TDesC* CCmdCalendar::UidName(TUid aUid)
+	{
+	switch (aUid.iUid)
+		{
+
+		default:
+			{
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+
+EXE_BOILER_PLATE(CCmdCalendar)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fcalendar/fcalendar.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// fcalendar.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+TARGET			fcalendar.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_FCALENDAR
+
+capability		ReadUserData WriteUserData
+
+USERINCLUDE		.
+#include <fshell/fsh_system_include.mmh>
+
+SOURCEPATH		.
+SOURCE			fcalendar.cpp
+
+library			euser.lib
+library			iocli.lib
+library			calinterimapi.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fcontacts/fcontacts.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,110 @@
+# fcontacts.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fcontacts
+
+==short-description
+
+Queries the contacts database.
+
+==long-description
+
+Note, all dates are shown in UTC.
+
+==see-also
+
+L<fcalendar|fcalendar>
+
+==argument enum command optional
+
+The command to execute. Defaults to C<list>.
+
+==enum-value list
+
+List all contacts. Use C<-i> to specify a contact identifier or C<-m> to specify a match sting to list a sub-set of contacts.
+
+==enum-value add
+
+Add a contact. Use options C<-f>, C<-s>, C<-t> and C<-b> to specify the contact's details.
+
+==enum-value delete
+
+Delete a contact. Use C<-i> to specify the identifier of the contact entry to be deleted.
+
+==enum-value change
+
+Change an existing contact. Use C<-i> to specify the identifier of the contact entry to be changed. Use options C<-f>, C<-s>, C<-m> and C<-t> to specify the new details. Unspecified details will remain the same.
+
+==enum-value delete-all
+
+Delete all contacts in the database.
+
+==enum-value create-group
+
+Create a new group. Use C<-g> to specify the group's name.
+
+==enum-value add-to-group
+
+Add a contact to a group. Use C<-i> and C<-d> to specify the contact and group identifiers.
+
+==enum-value compact
+
+Compact the database.
+
+==option bool v verbose multiple
+
+Shows all fields. Specify twice (i.e. C<-vv>) for even more detail about field mappings.
+
+==option uint i contact-id
+
+Specify the identifier of a contact.
+
+==option uint d group-id
+
+Specify the identifer of a group. Used when adding a contact to a group.
+
+==option string m match
+
+A match string to limit what contacts are shown. Only valid with the C<list> command. Can contain wild-cards C<*> and C<?>.
+
+==option bool o first-phone-only
+
+Only print the first phone number of the first matching contact. Only valid with the C<list> command, and if C<--verbose> has not been specified.
+
+==option string f first-name
+
+Specify the contact's first name.
+
+==option string l last-name
+
+Specify the contact's last name.
+
+==option string t telephone
+
+Specify the contact's general telephone number.
+
+==option string b mobile
+
+Specify the contact's mobile phone number.
+
+==option filename p photo
+
+Specify the name of a file that contains a photo or logo of the contact.
+
+==option string g group
+
+Specify the name of a group. Used when creating a new group.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fcontacts/fcontacts.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,891 @@
+// fcontacts.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <CNTDB.H>
+#include <CNTITEM.H>
+#include <CNTFLDST.H>
+
+// Some things that v9.1 doesn't have
+#include "fcontacts_support.h"
+
+using namespace IoUtils;
+
+class CCmdContacts : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdContacts();
+private:
+	CCmdContacts();
+	
+	TInt CheckDuplicateAndUpdate(CContactItemFieldSet &aFieldSet, CContactItemField &aField);	
+	void FillContactFieldSetL(CContactItemFieldSet &aFieldSet, TUid aType);
+	void PrintContact(CContactItem* aContact);
+	
+	void PrintGroupContentsL(CContactItem* aContactGroup, TInt aVerboseLevel);
+	void PrintGroupsJoined(CContactItem* aContact, TInt aVerboseLevel);	
+	void PrintTime(const TTime& aTime, TBool aNewline=EFalse);
+	
+	void PrintAcceptedOptions();	
+	static const TDesC* UidName(TUid aUid);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	
+	void DoListL();
+	void DoAddL();
+	void DoDeleteL();
+	void DoChangeL();
+	void DoDeleteAllL();
+	void DoCreateGroupL();
+	void DoAddToGroupL();		
+	void DoCompactL();
+private:
+	
+	CContactDatabase* iDb;
+	RArray<TBool> iVerbose;
+	TInt iOptContactId;
+	TInt iOptDestGrpId;
+	HBufC* iMatch;
+	TBool iShowFirstPhoneOnly;
+	
+	HBufC* iOptFirstName;
+	HBufC* iOptLastName;
+	HBufC* iOptTelephone;
+	HBufC* iOptMobile;
+	TFileName2 iOptPhotoFileName;
+	HBufC* iOptGroupName;
+	
+	HBufC* iOptStr;
+	enum
+		{
+		EList, EAdd, EDelete, EChange, EDeleteAll, ECreateGroup, EAddToGroup, ECompact
+		} iCommand;
+	};
+
+
+CCommandBase* CCmdContacts::NewLC()
+	{
+	CCmdContacts* self = new(ELeave) CCmdContacts();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdContacts::~CCmdContacts()
+	{
+	delete iOptFirstName;
+	delete iOptLastName;
+	delete iOptTelephone;
+	delete iOptMobile;
+	delete iOptGroupName;
+	delete iOptStr;
+	delete iMatch;
+	delete iDb;
+	iVerbose.Close();
+	}
+
+CCmdContacts::CCmdContacts()
+	{
+	}
+
+const TDesC& CCmdContacts::Name() const
+	{
+	_LIT(KName, "fcontacts");
+	return KName;
+	}
+
+void CCmdContacts::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCommand, _L("command"));
+	}
+
+void CCmdContacts::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	aOptions.AppendUintL((TUint&)iOptContactId, _L("contact-id"));
+	aOptions.AppendUintL((TUint&)iOptDestGrpId, _L("group-id"));
+	aOptions.AppendStringL(iMatch, _L("match"));
+	aOptions.AppendBoolL(iShowFirstPhoneOnly, _L("first-phone-only"));
+	aOptions.AppendStringL(iOptFirstName, _L("first-name"));
+	aOptions.AppendStringL(iOptLastName, _L("last-name"));
+	aOptions.AppendStringL(iOptTelephone, _L("telephone"));
+	aOptions.AppendStringL(iOptMobile, _L("mobile"));
+	aOptions.AppendFileNameL(iOptPhotoFileName, _L("photo"));
+	aOptions.AppendStringL(iOptGroupName, _L("group"));
+	}
+
+void CCmdContacts::DoRunL()
+	{
+	TRAPD(err, iDb = CContactDatabase::OpenL());
+	LeaveIfErr(err, _L("Couldn't open contacts database"));
+	
+	switch (iCommand)
+		{
+	case EList:
+		DoListL();
+		break;
+	case EAdd:
+		DoAddL();
+		break;
+	case EDelete:
+		DoDeleteL();
+		break;
+	case EChange:
+		DoChangeL();
+		break;
+	case EDeleteAll:
+		DoDeleteAllL();
+		break;
+	case ECreateGroup:
+		DoCreateGroupL();
+		break;
+	case EAddToGroup:
+		DoAddToGroupL();	
+		break;
+	case ECompact:
+		DoCompactL();
+		break;
+		}
+	}
+
+
+void CCmdContacts::DoListL()
+	{
+	if (iOptContactId)
+		{
+		CContactItem* contact = NULL;
+		TRAPD(err, contact = iDb->ReadContactL(iOptContactId));
+		LeaveIfErr(err, _L("Couldn't read contact %d"), iOptContactId);
+		PrintContact(contact);
+		delete contact;
+		}
+	else
+		{
+		// List all
+		TContactIter iter(*iDb);
+		TContactItemId id;
+		TBool foundMatch = EFalse;
+		while ((id = iter.NextL()) != KNullContactId)
+			{
+			CContactItem* contact = iDb->ReadContactLC(id);
+			TBool show = ETrue;
+			if (iMatch)
+				{
+				show = EFalse;
+				CContactItemFieldSet& fields = contact->CardFields();
+				TInt num = fields.Count();
+				for (TInt i = 0; i < num; i++)
+					{
+					CContactItemField& field = fields[i];
+					switch (field.StorageType())
+						{
+						case KStorageTypeText:
+							if (field.TextStorage()->Text().MatchF(*iMatch) != KErrNotFound)
+								{
+								show = ETrue;
+								foundMatch = ETrue;
+								}
+							break;
+						default:
+							break;
+						}
+					if (show) break;
+					}
+				}
+			if (show)
+				{
+				PrintContact(contact);
+				}
+			CleanupStack::PopAndDestroy(contact);
+			if (show && iShowFirstPhoneOnly)
+				{
+				break;
+				}
+			}
+		if (iMatch && !foundMatch)
+			{
+			User::Leave(KErrNotFound);
+			}
+		}
+	}
+
+void CCmdContacts::DoAddL()
+	{
+	TContactItemId newId = 0;
+	//create a "contact card" contact item
+	CContactItem* contact = CContactCard::NewLC();
+	CContactItemFieldSet& fieldSet = contact->CardFields();
+	FillContactFieldSetL(fieldSet, KUidContactCard);
+			
+	TRAPD(err, newId = iDb->AddNewContactL(*contact));
+	LeaveIfErr(err, _L("Could not add this contact"));
+	
+	Printf(_L("Contact Added\r\nContact ID:%d\r\n"), newId);
+	CleanupStack::PopAndDestroy(contact);
+	}
+
+
+void CCmdContacts::DoDeleteL()
+	{
+	if (iOptContactId)
+		{
+		TRAPD(err, iDb->DeleteContactL(iOptContactId));
+		if (err == KErrNone)
+			{
+			Printf(_L("Contact %d deleted\r\n"), iOptContactId);
+			}
+		else
+			{
+			LeaveIfErr(err, _L("Could not detelet contact item %d"), iOptContactId);
+			}
+		}
+	else
+		{
+		LeaveIfErr(KErrArgument, _L("No contact id specified. Use -i to specify a contact ID"));						
+		}	
+	}
+
+
+void CCmdContacts::DoChangeL()
+	{
+	if (iOptContactId) 
+		{
+		PrintAcceptedOptions();		
+		CContactItem* contact = NULL;
+		TRAPD(err, contact = iDb->OpenContactL(iOptContactId));
+		LeaveIfErr(err, _L("could not open contact item %d"), iOptContactId);
+				
+		CleanupStack::PushL(contact);
+		
+		CContactItemFieldSet& FieldSet = contact->CardFields();
+		FillContactFieldSetL(FieldSet, KUidContactCard);
+		
+		TRAP(err, iDb->CommitContactL(*contact));
+		LeaveIfErr(err, _L("Could not commit the change for item %d"), iOptContactId);
+						
+		CleanupStack::PopAndDestroy(contact);
+		
+		}
+	else
+		{
+		LeaveIfErr(KErrArgument, _L("No contact id specified. Use -i to specify a contact ID"));
+		}		
+	}
+
+void CCmdContacts::DoDeleteAllL()
+	{
+	TInt TotalErrors = 0;	//how many items are not deleted due to error 
+	TInt ContactItemCnt = iDb->CountL();
+	Printf(_L("Database contains %d items \r\n"), ContactItemCnt);
+	// List all
+	TContactIter iter(*iDb);
+	TContactItemId id;
+	while ((id = iter.NextL()) != KNullContactId)
+		{
+		Printf(_L("Deleting contact item %d ..."), id);
+		TRAPD(err, iDb->DeleteContactL(id));
+		
+		if (err==KErrNone)
+			Printf(_L("done \r\n"), id);
+		else 
+			{
+			TotalErrors++;
+			Printf(_L("fail, error code=%d \r\n"), err);
+			}		
+		}
+	
+	if (TotalErrors > 0)
+		{
+		LeaveIfErr(KErrGeneral, _L("%d items are not deleted due to error"), TotalErrors);
+		}	
+	}
+
+void CCmdContacts::DoCreateGroupL()
+	{
+	Printf(_L("Creating a new group... \r\n"));
+	CContactItem* contact = NULL;
+	TRAPD(err, contact = iDb->CreateContactGroupL());
+	LeaveIfErr(err, _L("Could not create contact group"));
+	
+	CleanupStack::PushL(contact);
+	TContactItemId GroupId = contact->Id();
+	CleanupStack::PopAndDestroy(contact);
+	contact = NULL;
+	
+	///////////////////////////////////////////////////
+	TRAP(err, contact = iDb->OpenContactL(GroupId));
+	LeaveIfErr(err, _L("Could not open contact group for editing"));
+	CleanupStack::PushL(contact);
+	
+	Printf(_L("Changing group name for contact item %d... \r\n"), GroupId);
+	
+	CContactItemFieldSet& FieldSet = contact->CardFields();
+	FillContactFieldSetL(FieldSet, KUidContactGroup);
+	TRAP(err, iDb->CommitContactL(*contact));
+	LeaveIfErr(err, _L("Could not sumbit the change"));
+
+	CleanupStack::PopAndDestroy(contact);
+
+	}
+
+void CCmdContacts::DoCompactL()
+	{
+	TRAPD(err, iDb->CompactL());
+	LeaveIfErr(err, _L("Could not compact the database"));
+	}
+
+void CCmdContacts::DoAddToGroupL()
+	{
+	if (iOptContactId && iOptDestGrpId)
+		{
+		Printf(_L("Adding contact item %d to destination group item %d \r\n"), 
+				iOptContactId, iOptDestGrpId);
+		TRAPD(err, iDb->AddContactToGroupL( (TContactItemId)iOptContactId, (TContactItemId)iOptDestGrpId) ) ;
+		
+		//this is most common mistake, need to point out especially to remind the user.
+		if (err==KErrNotSupported)
+			PrintError(KErrNotSupported, _L("Destination is not a group"));
+		
+		User::LeaveIfError(err);
+		
+		}
+	else 
+		{
+		LeaveIfErr(KErrArgument, _L("No contact id specified. Use -i to specify a contact ID"));						
+		}	
+	}
+
+
+// FOR TEST PURPOSE
+//to check if a field of the same type has already existed in a FieldSet.
+//if yes, delete that field first and then add it
+TInt CCmdContacts::CheckDuplicateAndUpdate(CContactItemFieldSet &aFieldSet, CContactItemField &aField) 
+	{
+	const CContentType &newContentType=aField.ContentType();
+	TInt fieldPos=0;
+	
+	TInt FieldCnt = aFieldSet.Count();
+	for(; fieldPos<FieldCnt ; fieldPos++ )
+		{
+		CContactItemField& TestedField = aFieldSet[fieldPos];
+		if (newContentType == TestedField.ContentType())
+			{
+				aFieldSet.Remove(fieldPos);
+				break;
+			}
+		}
+	
+	if (aField.Storage()->IsFull())
+		{
+		CContactItemField* field=CContactItemField::NewLC(aField);
+		aFieldSet.InsertL(fieldPos,*field);
+		CleanupStack::Pop();	// field
+		}	
+	
+	return 0;
+	}
+
+//this function will retrieve infomation from command line arguments and fill them into 
+//a field set, FieldSet doesn't have to be empty
+//aType: either KUidContactCard or KUidContactGroup
+void CCmdContacts::FillContactFieldSetL(CContactItemFieldSet &aFieldSet, TUid aType)
+	{	
+	if (aType == KUidContactGroup)
+		{
+		//group name
+		if (iOptGroupName && iOptGroupName->Length())
+			{		
+			CContactItemField* field = NULL;
+			field = CContactItemField::NewLC(KStorageTypeText);
+			field->SetLabelL(_L("Group Label"));
+			field->SetMapping(KUidContactFieldNone);
+			field->AddFieldTypeL(KUidContactFieldTemplateLabel);	
+			CContactTextField* pFieldText = field->TextStorage();
+			pFieldText->SetTextL(*iOptGroupName);
+			aFieldSet.UpdateFieldL(*field, 1);
+			CleanupStack::PopAndDestroy(field);	
+			}
+		}
+	
+	//Synchronization, for both Group and normal contacts
+		{
+		CContactItemField* field = NULL;		
+		field = CContactItemField::NewLC(KStorageTypeText);
+		field->SetLabelL(_L("Synchronization"));
+		field->SetMapping(KUidContactFieldVCardMapClass);
+		field->AddFieldTypeL(KUidContactFieldClass);	
+		CContactTextField* pFieldText = field->TextStorage();
+		pFieldText->SetTextL(_L("private"));
+		aFieldSet.UpdateFieldL(*field, 1);
+		CleanupStack::PopAndDestroy(field);		
+		}
+		
+	if (aType == KUidContactCard)
+		{
+		//last name
+		if (iOptLastName && iOptLastName->Length())
+			{		
+			CContactItemField* field = NULL;
+			field = CContactItemField::NewLC(KStorageTypeText);
+			field->SetLabelL(_L("Last name"));
+			field->SetMapping(KUidContactFieldVCardMapUnusedN);
+			field->AddFieldTypeL(KUidContactFieldFamilyName);	
+			CContactTextField* pFieldText = field->TextStorage();
+			pFieldText->SetTextL(*iOptLastName);
+			aFieldSet.UpdateFieldL(*field, 1);
+			CleanupStack::PopAndDestroy(field);	
+			}
+		
+		//first name
+		if (iOptFirstName && iOptFirstName->Length())
+			{	
+			CContactItemField* field = NULL;
+			field = CContactItemField::NewLC(KStorageTypeText);
+			field->SetLabelL(_L("First name"));
+			field->SetMapping(KUidContactFieldVCardMapUnusedN);
+			field->AddFieldTypeL(KUidContactFieldGivenName);	
+			CContactTextField* pFieldText = field->TextStorage();
+			pFieldText->SetTextL(*iOptFirstName);
+			aFieldSet.UpdateFieldL(*field, 1);
+			CleanupStack::PopAndDestroy(field);	
+			}			
+		//general telephone
+		if (iOptTelephone && iOptTelephone->Length())
+			{	
+			CContactItemField* field = NULL;
+			field = CContactItemField::NewLC(KStorageTypeText);
+			field->SetLabelL(_L("Telephone"));
+			field->SetMapping(KUidContactFieldVCardMapTEL);
+			field->AddFieldTypeL(KUidContactFieldPhoneNumber);	
+			field->AddFieldTypeL(KUidContactFieldVCardMapVOICE);		
+			CContactTextField* pFieldText = field->TextStorage();
+			pFieldText->SetTextL(*iOptTelephone);
+			aFieldSet.UpdateFieldL(*field, 1);
+			CleanupStack::PopAndDestroy(field);	
+			}			
+		//mobile phone
+		if (iOptMobile && iOptMobile->Length())
+			{	
+			CContactItemField* field = NULL;
+			field = CContactItemField::NewLC(KStorageTypeText);
+			field->SetLabelL(_L("Mobile"));
+			field->SetMapping(KUidContactFieldVCardMapTEL);
+			field->AddFieldTypeL(KUidContactFieldPhoneNumber);
+			field->AddFieldTypeL(KUidContactFieldVCardMapCELL);
+			CContactTextField* pFieldText = field->TextStorage();
+			pFieldText->SetTextL(*iOptMobile);
+			aFieldSet.UpdateFieldL(*field, 1);
+			CleanupStack::PopAndDestroy(field);	
+			}
+		
+		//photo
+		if (iOptPhotoFileName.Length())
+			{
+			RFile file;
+			LeaveIfErr(file.Open(FsL(), iOptPhotoFileName, EFileRead), _L("Couldn't open file \"%S\""), &iOptPhotoFileName);
+			TInt fileSize;
+			LeaveIfErr(file.Size(fileSize), _L("Couldn't read the size of file \"%S\""), &iOptPhotoFileName);
+			RBuf8 buf;
+			buf.Create(fileSize);
+			buf.CleanupClosePushL();
+			LeaveIfErr(file.Read(buf), _L("Couldn't read the contents of file \"%S\""), &iOptPhotoFileName);
+
+			CContactItemField* field = CContactItemField::NewLC(KStorageTypeStore);
+			field->SetLabelL(_L("Photo"));
+			field->SetMapping(KUidContactFieldVCardMapPHOTO);
+			field->AddFieldTypeL(KUidContactFieldPicture);
+			CContactStoreField* storeField = field->StoreStorage();
+			storeField->SetThingL(buf);
+			aFieldSet.UpdateFieldL(*field, 1);
+
+			CleanupStack::PopAndDestroy(2, &buf);	
+			}
+		}
+	}
+
+void CCmdContacts::PrintContact(CContactItem* aContact)
+	{
+	TContactItemId ContactId = aContact->Id();
+	TUid ContactType = aContact->Type();
+	CContactItemFieldSet& fields = aContact->CardFields();
+
+	TBool verbose = (iVerbose.Count() > 0);
+	TBool veryverbose = (iVerbose.Count() > 1);
+
+	if (verbose)
+		{
+		Printf(_L("Contact item id %d:\r\n"), aContact->Id());
+		Printf(_L("\tLast modified: "));
+		PrintTime(aContact->LastModified(), ETrue);
+		if (veryverbose)
+			{
+			Printf(_L("\tHidden=%d System=%d AccessCount=%d Deleted=%d\r\n"), aContact->IsHidden(), aContact->IsSystem(), aContact->AccessCount(), aContact->IsDeleted());
+			TPtrC uid = aContact->UidStringL(iDb->MachineId()); // Don't understand the syntax of this function
+			Printf(_L("\tUid: %S\r\n"), &uid);
+			TUint32 type = aContact->Type().iUid;
+			Printf(_L("\tType: 0x%08x "), type);
+			switch (type)
+				{
+				case KUidContactCardValue:
+					Printf(_L("(KUidContactCard)\r\n")); break;
+				case KUidContactGroupValue:
+					Printf(_L("(KUidContactGroup)\r\n")); break;
+				case KUidContactOwnCardValue:
+					Printf(_L("(KUidContactOwnCard)\r\n")); break;
+				case KUidContactICCEntryValue:
+					Printf(_L("(KUidContactICCEntry)\r\n")); break;
+				case KUidContactTemplateValue:
+					Printf(_L("(KUidContactTemplate)\r\n")); break;
+				case KUidContactCardTemplateValue:
+					Printf(_L("(KUidContactCardTemplate)\r\n")); break;
+				default:
+					Printf(_L("(Unknown)\r\n")); break;
+				}
+			}
+		
+		PrintGroupContentsL(aContact, iVerbose.Count());
+		PrintGroupsJoined(aContact, iVerbose.Count());
+		
+		TInt num = fields.Count();
+		for (TInt i = 0; i < num; i++)
+			{
+			CContactItemField& field = fields[i];
+			TPtrC label = field.Label();
+			Printf(_L("\t%d [%S]: "), field.Id(), &label);
+			switch (field.StorageType())
+				{
+				case KStorageTypeText:
+					{					
+					TPtrC fieldText = field.TextStorage()->Text();
+					Printf(_L("KStorageTypeText: %S\r\n"), &fieldText);
+					break;
+					}
+				case KStorageTypeDateTime:
+					{
+					TTime time = field.DateTimeStorage()->Time();
+					PrintTime(time, ETrue);
+					break;
+					}
+				case KStorageTypeStore:
+					{
+					HBufC8* thing = field.StoreStorage()->Thing();
+					if (thing)
+						{
+						Printf(_L("<Binary data of length %d>\r\n"), thing->Size());
+						}
+					else
+						{
+						Printf(_L("<Null binary data>\r\n"));
+						}
+					break;
+					}
+				case KStorageTypeContactItemId:
+					{
+					Printf(_L("<Contact item id %d>\r\n"), field.AgentStorage()->Value());
+					break;
+					}
+				default:
+					Printf(_L("<Unknown storage type>"));
+					break;
+				}
+			if (veryverbose)
+				{
+				Printf(_L("\t\tDeleted=%d Disabled=%d Hidden=%d Private=%d Readonly=%d SpeedDial=%d\r\n"), field.IsDeleted(), field.IsDisabled(), field.IsHidden(), field.IsPrivate(), field.IsReadOnly(), field.IsSpeedDial());
+				Printf(_L("\t\tUser flags:    0x%08x\r\n"), field.UserFlags());
+				const CContentType& contentType = field.ContentType();
+				Printf(_L("\t\tVCard mapping: 0x%08x (%S)\r\n"), contentType.Mapping(), UidName(contentType.Mapping()));
+				TInt fieldTypeCount = contentType.FieldTypeCount();
+				for (TInt i = 0; i < fieldTypeCount; i++)
+					{
+					TUid fieldType = contentType.FieldType(i);
+					Printf(_L("\t\tField type %d:  0x%08x (%S)\r\n"), i, fieldType, UidName(fieldType));
+					}
+				}
+			}
+		}
+	else
+		{
+		TInt found;
+		if (ContactType == KUidContactGroup)
+			{
+			TPtrC GroupName;
+			found = fields.Find(KUidContactFieldTemplateLabel, KUidContactFieldNone);
+			if (found != KErrNotFound)
+				GroupName.Set( fields[found].TextStorage()->Text() );
+			else
+				GroupName.Set(_L("[Unnamed]"));
+			
+			Printf(_L("%d. [Group] %S "), ContactId, &GroupName);
+			
+			//list containing items...
+			PrintGroupContentsL(aContact, 0);
+			}
+		else
+			{
+			if (iShowFirstPhoneOnly)
+				{
+				found = fields.Find(KUidContactFieldPhoneNumber);
+				if (found != KErrNotFound)
+					{
+					TPtrC phone = TPtrC(fields[found].TextStorage()->Text());
+					Printf(_L("%S"), &phone);
+					}
+				}
+			else
+				{
+				TPtrC first;
+				found = fields.Find(KUidContactFieldGivenName);
+				if (found != KErrNotFound) first.Set(fields[found].TextStorage()->Text());
+				TPtrC last;
+				found = fields.Find(KUidContactFieldFamilyName);
+				if (found != KErrNotFound) last.Set(fields[found].TextStorage()->Text());
+				TPtrC phone;
+				found = fields.Find(KUidContactFieldPhoneNumber);
+				if (found != KErrNotFound) phone.Set(fields[found].TextStorage()->Text());
+				Printf(_L("%d. %S %S %S\r\n"), ContactId, &first, &last, &phone);			
+				}
+			}
+		
+		}
+	}
+
+//This function will not LEAVE for the moment
+//aVerboseLevel: possible values: 0 1 2
+//
+void CCmdContacts::PrintGroupContentsL(CContactItem* aContactGroup, TInt /*aVerboseLevel*/)
+	{
+	if (aContactGroup->Type() == KUidContactGroup)
+		{
+		CContactGroup* pContactGroup = (CContactGroup*)aContactGroup;
+		const CContactIdArray* pContactIdAry = pContactGroup->ItemsContained();	
+		
+		//
+		TInt ElementCount = pContactIdAry->Count();
+		Printf(_L("\tThis Group contains %d items."), ElementCount);
+		if (ElementCount)
+			{
+			Printf(_L(" Member contact ID list: "));
+			TInt i;
+			for (i=0; i<ElementCount; i++)
+				{
+				TContactItemId ID = (*pContactIdAry) [i];
+				Printf(_L("%d "), ID);
+				}
+			}
+		Printf(_L("\r\n"));
+		
+		}	
+	}
+
+void CCmdContacts::PrintGroupsJoined(CContactItem* aContact, TInt aVerboseLevel)
+	{
+	if (aVerboseLevel < 1) return;
+	TUid ContactType = aContact->Type();
+	if (ContactType == KUidContactGroup || ContactType == KUidContactCard)
+		{
+		CContactItemPlusGroup * pContact = (CContactItemPlusGroup *)aContact;
+		const CContactIdArray* pContactIdAry = pContact->GroupsJoined();
+		
+		if (!pContactIdAry) 
+			return;
+					
+		TInt ElementCount = pContactIdAry->Count();
+		Printf(_L("\tThis item belongs to %d groups."), ElementCount);
+		if (ElementCount)
+			{
+			Printf(_L(" Group contact ID list: "));
+			TInt i;
+			for (i=0; i<ElementCount; i++)
+				{
+				TContactItemId ID = (*pContactIdAry) [i];
+				Printf(_L("%d "), ID);
+				}
+			}
+		Printf(_L("\r\n"));		
+		}	
+	}
+
+void CCmdContacts::PrintTime(const TTime& aTime, TBool aNewline)
+	{
+	_LIT8(KDateTimeFormat, "%d-%02d-%02d %02d:%02d:%02d");
+	TDateTime dt = aTime.DateTime();
+	Printf(KDateTimeFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
+	if (aNewline) Printf(_L("\r\n"));
+	}
+
+//print the accepted options from the command line
+void CCmdContacts::PrintAcceptedOptions()
+	{
+	//surname
+	if (iOptLastName && iOptLastName->Length())
+		Printf(_L("surname: %S \r\n"), iOptLastName );				
+	//first name
+	if (iOptFirstName && iOptFirstName->Length())
+		Printf(_L("first name: %S \r\n"), iOptFirstName );					
+	//general telephone
+	if (iOptTelephone && iOptTelephone->Length())
+		Printf(_L("general telephone: %S \r\n"), iOptTelephone );
+	//mobile phone
+	if (iOptMobile && iOptMobile->Length())
+		Printf(_L("mobile: %S \r\n"), iOptMobile );
+	//photo
+	if (iOptPhotoFileName.Length())
+		Printf(_L("photo: %S \r\n"), &iOptPhotoFileName );
+	}
+
+
+#define CASE_LIT(x) case x: { _LIT(KName, #x); return &KName; }
+const TDesC* CCmdContacts::UidName(TUid aUid)
+	{
+	switch (aUid.iUid)
+		{
+		CASE_LIT(KUidContactFieldAddressValue)
+		CASE_LIT(KUidContactFieldPostOfficeValue)
+		CASE_LIT(KUidContactFieldExtendedAddressValue)
+		CASE_LIT(KUidContactFieldLocalityValue)
+		CASE_LIT(KUidContactFieldRegionValue)
+		CASE_LIT(KUidContactFieldPostCodeValue)
+		CASE_LIT(KUidContactFieldCountryValue)
+		CASE_LIT(KUidContactFieldCompanyNameValue)
+		CASE_LIT(KUidContactFieldCompanyNamePronunciationValue)
+		CASE_LIT(KUidContactFieldPhoneNumberValue)
+		CASE_LIT(KUidContactFieldGivenNameValue)
+		CASE_LIT(KUidContactFieldFamilyNameValue)
+		CASE_LIT(KUidContactFieldGivenNamePronunciationValue)
+		CASE_LIT(KUidContactFieldFamilyNamePronunciationValue)
+		CASE_LIT(KUidContactFieldAdditionalNameValue)
+		CASE_LIT(KUidContactFieldSuffixNameValue)
+		CASE_LIT(KUidContactFieldPrefixNameValue)
+		CASE_LIT(KUidContactFieldHiddenValue)
+		CASE_LIT(KUidContactFieldEMailValue)
+		CASE_LIT(KUidContactFieldMsgValue)
+		CASE_LIT(KUidContactFieldSmsValue)
+		CASE_LIT(KUidContactFieldFaxValue)
+		CASE_LIT(KUidContactFieldDefinedTextValue)
+		CASE_LIT(KUidContactFieldNoteValue)
+		CASE_LIT(KUidContactFieldBirthdayValue)
+		CASE_LIT(KUidContactFieldUrlValue)
+		CASE_LIT(KUidContactFieldStorageInlineValue)
+		CASE_LIT(KUidContactFieldTemplateLabelValue)
+		CASE_LIT(KUidContactFieldPictureValue)
+		CASE_LIT(KUidContactFieldRingToneValue)
+		CASE_LIT(KUidContactFieldDTMFValue)
+		CASE_LIT(KUidContactsVoiceDialFieldValue)
+		CASE_LIT(KUidContactFieldNoneValue)
+		CASE_LIT(KUidContactFieldJobTitleValue)
+		CASE_LIT(KUidContactFieldICCSlotValue)
+		CASE_LIT(KUidContactFieldICCPhonebookValue)
+		CASE_LIT(KUidContactFieldICCGroupValue)
+		CASE_LIT(KUidContactFieldIMAddressValue)
+		CASE_LIT(KUidContactFieldSecondNameValue)
+		CASE_LIT(KUidContactFieldSIPIDValue)
+		CASE_LIT(KUidContactFieldAssistantValue)
+		CASE_LIT(KUidContactFieldAnniversaryValue)
+		CASE_LIT(KUidContactFieldSpouseValue)
+		CASE_LIT(KUidContactFieldChildrenValue)
+		CASE_LIT(KUidContactFieldClassValue)
+		CASE_LIT(KUidContactFieldDepartmentNameValue)
+		CASE_LIT(KIntContactFieldVCardMapWORK)
+		CASE_LIT(KIntContactFieldVCardMapHOME)
+		CASE_LIT(KIntContactFieldVCardMapMSG)
+		CASE_LIT(KIntContactFieldVCardMapVOICE)
+		CASE_LIT(KIntContactFieldVCardMapFAX)
+		CASE_LIT(KIntContactFieldVCardMapPREF)
+		CASE_LIT(KIntContactFieldVCardMapCELL)
+		CASE_LIT(KIntContactFieldVCardMapPAGER)
+		CASE_LIT(KIntContactFieldVCardMapBBS)
+		CASE_LIT(KIntContactFieldVCardMapMODEM)
+		CASE_LIT(KIntContactFieldVCardMapCAR)
+		CASE_LIT(KIntContactFieldVCardMapISDN)
+		CASE_LIT(KIntContactFieldVCardMapVIDEO)
+		CASE_LIT(KIntContactFieldVCardMapDOM)
+		CASE_LIT(KIntContactFieldVCardMapADR)
+		CASE_LIT(KIntContactFieldVCardMapPOSTOFFICE)
+		CASE_LIT(KIntContactFieldVCardMapEXTENDEDADR)
+		CASE_LIT(KIntContactFieldVCardMapLOCALITY)
+		CASE_LIT(KIntContactFieldVCardMapREGION)
+		CASE_LIT(KIntContactFieldVCardMapPOSTCODE)
+		CASE_LIT(KIntContactFieldVCardMapCOUNTRY)
+		CASE_LIT(KIntContactFieldVCardMapAGENT)
+		CASE_LIT(KIntContactFieldVCardMapBDAY)
+		CASE_LIT(KIntContactFieldVCardMapEMAILINTERNET)
+		CASE_LIT(KIntContactFieldVCardMapGEO)
+		CASE_LIT(KIntContactFieldVCardMapLABEL)
+		CASE_LIT(KIntContactFieldVCardMapLOGO)
+		CASE_LIT(KIntContactFieldVCardMapMAILER)
+		CASE_LIT(KIntContactFieldVCardMapNOTE)
+		CASE_LIT(KIntContactFieldVCardMapORG)
+		CASE_LIT(KIntContactFieldVCardMapORGPronunciation)
+		CASE_LIT(KIntContactFieldVCardMapPHOTO)
+		CASE_LIT(KIntContactFieldVCardMapROLE)
+		CASE_LIT(KIntContactFieldVCardMapSOUND)
+		CASE_LIT(KIntContactFieldVCardMapTEL)
+		CASE_LIT(KIntContactFieldVCardMapTELFAX)
+		CASE_LIT(KIntContactFieldVCardMapTITLE)
+		CASE_LIT(KIntContactFieldVCardMapURL)
+		CASE_LIT(KIntContactFieldVCardMapUnusedN)
+		CASE_LIT(KIntContactFieldVCardMapUnusedFN)
+		CASE_LIT(KIntContactFieldVCardMapNotRequired)
+		CASE_LIT(KIntContactFieldVCardMapUnknownXDash)
+		CASE_LIT(KIntContactFieldVCardMapUnknown)
+		CASE_LIT(KIntContactFieldVCardMapUID)
+		CASE_LIT(KIntContactFieldVCardMapINTL)
+		CASE_LIT(KIntContactFieldVCardMapPOSTAL)
+		CASE_LIT(KIntContactFieldVCardMapPARCEL)
+		CASE_LIT(KIntContactFieldVCardMapGIF)
+		CASE_LIT(KIntContactFieldVCardMapCGM)
+		CASE_LIT(KIntContactFieldVCardMapWMF)
+		CASE_LIT(KIntContactFieldVCardMapBMP)
+		CASE_LIT(KIntContactFieldVCardMapMET)
+		CASE_LIT(KIntContactFieldVCardMapPMB)
+		CASE_LIT(KIntContactFieldVCardMapDIB)
+		CASE_LIT(KIntContactFieldVCardMapPICT)
+		CASE_LIT(KIntContactFieldVCardMapTIFF)
+		CASE_LIT(KIntContactFieldVCardMapPDF)
+		CASE_LIT(KIntContactFieldVCardMapPS)
+		CASE_LIT(KIntContactFieldVCardMapJPEG)
+		CASE_LIT(KIntContactFieldVCardMapMPEG)
+		CASE_LIT(KIntContactFieldVCardMapMPEG2)
+		CASE_LIT(KIntContactFieldVCardMapAVI)
+		CASE_LIT(KIntContactFieldVCardMapQTIME)
+		CASE_LIT(KIntContactFieldVCardMapTZ)
+		CASE_LIT(KIntContactFieldVCardMapKEY)
+		CASE_LIT(KIntContactFieldVCardMapX509)
+		CASE_LIT(KIntContactFieldVCardMapPGP)
+		CASE_LIT(KIntContactFieldVCardMapSMIME)
+		CASE_LIT(KIntContactFieldVCardMapWV)
+		CASE_LIT(KIntContactFieldVCardMapSECONDNAME)
+		CASE_LIT(KIntContactFieldVCardMapSIPID)
+		CASE_LIT(KIntContactFieldVCardMapPOC)
+		CASE_LIT(KIntContactFieldVCardMapSWIS)
+		CASE_LIT(KIntContactFieldVCardMapVOIP)
+		CASE_LIT(KIntContactFieldVCardMapAssistant)
+		CASE_LIT(KIntContactFieldVCardMapAssistantTel)
+		CASE_LIT(KIntContactFieldVCardMapAnniversary)
+		CASE_LIT(KIntContactFieldVCardMapSpouse)
+		CASE_LIT(KIntContactFieldVCardMapChildren)
+		CASE_LIT(KIntContactFieldVCardMapClass)
+		CASE_LIT(KIntContactFieldVCardMapDepartment)
+		default:
+			{
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+EXE_BOILER_PLATE(CCmdContacts)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fcontacts/fcontacts.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// fcontacts.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fcontacts.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_FCONTACTS
+
+capability      ReadUserData WriteUserData
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          fcontacts.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+library         cntmodel.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fcontacts/fcontacts_support.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+// fcontacts_support.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FCONTACTS_SUPPORT_H
+#define FCONTACTS_SUPPORT_H
+
+#include <cntdef.hrh>
+
+#ifndef KUidContactCardValue
+// v9.1 didn't have these (the uids were used and understood, just these variables didn't exist)
+
+#define KUidContactCardValue			0x10001309
+#define KUidContactGroupValue			0x1000130A
+#define KUidContactOwnCardValue			0x10004F95
+#define KUidContactICCEntryValue		0x101F4A6F
+#define KUidContactTemplateValue		0x1000130B
+#define KUidContactCardTemplateValue	0x10004FF1
+
+#define KUidContactFieldAssistantValue		0x10274DA4
+#define KUidContactFieldAnniversaryValue	0x10274DA5
+#define KUidContactFieldSpouseValue		0x10274DA6
+#define KUidContactFieldChildrenValue		0x10274DA7
+#define KUidContactFieldClassValue		0x10274DA8
+
+#define KIntContactFieldVCardMapAssistant		0x10274DAA
+#define KIntContactFieldVCardMapAssistantTel		0x10274DAB
+#define KIntContactFieldVCardMapAnniversary		0x10274DAC
+#define KIntContactFieldVCardMapSpouse			0x10274DAD
+
+#endif // KUidContactCardValue
+
+#ifndef KIntContactFieldVCardMapChildren
+#define KIntContactFieldVCardMapChildren		0x10274DAE
+#define KIntContactFieldVCardMapClass			0x10274DAF
+
+// v9.1 didn't have these at all, but I think we only use them for sync support and 9.1 will happily just store them for us
+const TUid KUidContactFieldVCardMapClass={KIntContactFieldVCardMapClass};
+const TUid KUidContactFieldClass = { KUidContactFieldClassValue };
+
+#endif // KIntContactFieldVCardMapChildren
+
+#endif // FCONTACTS_SUPPORT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fdb/fdb.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,146 @@
+# fdb.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fdb
+
+==argument uint threadid optional
+
+Thread id to attach to. If not specified, tries to attach to the first available crashed thread.
+
+==option bool a all
+
+Monitor all thread exits, not just abnormal ones.
+
+==option filename s symbols ROM_SYMBOLS
+
+Specify a .bsym symbol file to use.
+
+==option filename m mapfiles MAP_FILES
+
+Specify a directory that contains .map files.
+
+==short-description
+
+A run-mode debugger for Symbian OS.
+
+==long-description
+
+Fdb is a simple run-mode debugger capable of debugging user threads and non-system critical crashes. It allows you to attach to running or crashed threads, and examine their stacks, registers and address space using an interactive command shell similar to gdb. If a suitable BSYM file or .map file is available (eg on the memory card) stacktraces will be decoded. Breakpoints are supported on user-side threads. You can examine kernel threads, but you cannot set breakpoints on them or debug them if they crash.
+
+Hardcoded breakpoints via a call to C<LtkUtils::Breakpoint()> will also be picked up.
+
+A device driver is used to monitor thread exits, and once it has been installed (by running fdb the first time) it will continue to monitor even after fdb has quit. This is useful if for example you find that you don't have the right map files for the thread you are debugging: you can close fdb, copy the appropriate files around, then relaunch fdb, reattach to the same thread as before and carry on where you left off. To close the debugger completely and uninstall the thread monitor, launch fdb and use the 'uninstall' command.
+
+Typing 'fdb' with no arguments will enter interactive mode and try to attach to the first available crashed thread.
+
+If you attach to a running thread you can set a breakpoint on it using the C<break> command. There are 2 types of breakpoint:
+
+=over 4
+
+=item Hardware breakpoints
+
+On platforms that support it (currently, ARM11xx and ARM11 MPCore only) a limited number of hardware breakpoints can be specified. These are efficient and only affect the specified thread. In the breakpoints listing these are marked with "(HARDWARE)". You can have a maximum of 4 hardware breakpoints in up to 2 different threads.
+
+=item Software breakpoints
+
+On platforms that don't support hardware breakpoints, or if the maximum number of hardware breakpoints has been reached, the fallback behaviour is to set a software breakpoint. These have a number of disadvantages, chief of which is that they affect all threads, so any thread that hits the breakpointed address will suffer a performance penalty while the code to emulate thread-specific breakpoints runs. Their implementation in the kernel is also fraught with corner cases and strange implementation quirks. Setting a software breakpoint on a non-code address will have undesirable behaviour (whereas with a hardware breakpoint it would just have no effect).
+
+=back
+
+=head1 SUPPORTED COMMANDS
+
+=over 4
+
+=item a | attach [<id>]
+
+Attach to the given thread and set it focussed, or if no id is given use the first available crashed or breakpointed thread.
+
+=item d | detach [<id>]
+
+Detaches the given thread, or the focussed one if no argument given. Detaching a thread unblocks it, meaning it is allowed to continue (or exit) normally. Once a thread has fully exited it can no longer be examined in the debugger. If the thread is on a breakpoint, an implicit continue is performed first before detaching.
+
+=item f | focus [<id>]
+
+Set the given thread to be the currently focussed one. If no argument given, shows info about the currently focussed thread. Thread must have already been attached.
+
+=item r | registers
+
+List the valid registers for the currently focussed thread. Not all registers will be available, depending on whether the thread is running or the reason for its exit.
+
+=item t | stack [all]
+
+Dumps the user-mode stack, from R13 (if available, otherwise from limit) down to base. If 'all' is specified, show every byte rather than skipping memory that doesn't look like code addresses.
+
+=item k | kstack [all]
+
+Like 'stack' but for the thread's kernel-mode stack.
+
+=item l | list
+
+Show all zombied and attached threads. Ones already attached to by fdb are marked with an 'a', the currently focussed thread is marked with a '*'. Threads that have been suspended by fdb have a 's', threads on breakpoints have a 'b'.
+
+=item ? | lookup <addr>
+
+Attempts to decode the given address. Uses the loaded BSYM or map files if present, otherwise just looks at the codesegments currently loaded in the kernel.
+
+=item m | mem <addr> <len>
+
+Dumps the memory at the given (user) address range.
+
+=item browse [<addr>|heap|stack]
+
+Enter the interactive memory browser I<(UNDER CONSTRUCTION)>. The keywords 'heap' and 'stack' are also allowed, instead of an address. If no address specified, assumes 'heap'.
+
+=item b | break
+
+Z<>
+
+=item b | break <addr> [<cond>]
+
+Z<>
+
+=item b | break <codeseg> <symbol> [<cond>]
+
+Sets a breakpoint in the currently focussed thread at the given code addess. If no arguments given, lists the currently installed breakpoints. Hardware breakpoints are marked with "(HARDWARE)", otherwise they are software breakpoints. If suitable symbolics are available you can specify a codesegment and symbol name instead of an address, eg C<break euser.dll User::LeaveIfError(int)>. Tab completion is supported on symbol names. Note that pending breakpoints (either due to a codesegment unloading or by setting a breakpoint on a codesegment that isn't loaded yet) are I<UNDER CONSTRUCTION> (and don't work yet).
+
+Breakpoints can be conditional based on what the registers are when the breakpoint is hit, by specifying the <cond> argument. For example, to set a breakpoint when the thread Leaves with KErrNoMemory, you could say C<break euser.dll User::LeaveIfError(int) r0=-4>. The first argument to a (static) function goes in register r0, the second in r1 etc. For C++ member functions the first argument goes in r1, the second in r2 etc. You can specify up to 4 conditions separated by commas, eg C<r0=3,r1E<gt>=3>. All the conditions must match in order for the breakpoint to be hit. These conditions are not supported in hardware so there will be a slight performance impact when the condition isn't met (the same as if the wrong thread hits a software breakpoint). The supported operators are: = != < <= > >=. When using the comparison operators < > <= >= the comparison is assumed to be signed unless there is a 'U' following the value, eg C<r0E<gt>0x80000000u>.
+
+=item c | continue
+
+Continues execution of the current thread, if it was stopped on a breakpoint. Does nothing if the current thread is not on a breakpoint.
+
+=item clear [<id>]
+
+Clears the breakpoint with the specified id, or if not specified clears all breakpoints. Clearing a breakpoint removes it completely but does not automatically resume any thread that has already paused on it. (To do that use the 'list' command to find the threads stuck on breakpoints and attach to them one by one and use 'continue'.)
+
+=item u | uninstall
+
+Detaches all threads, clears all breakpoints, uninstalls the thread monitor and exits fdb.
+
+=item load <path>
+
+If <path> ends with .bsym, adds the BSYM file to the currently loaded symbols. Otherwise sets <path> as the default .MAP file directory.
+
+=item h | help
+
+Print the supported commands (this help text).
+
+=item x | exit
+
+Exit fdb.
+
+=back
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fdb/fdb.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1564 @@
+// fdb.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/memoryaccesscmd.h>
+#include <fshell/ltkutils.h>
+#include <fshell/bsym.h>
+#include <fshell/descriptorutils.h>
+#include <fshell/iocons_writer.h>
+#include <fshell/line_editor.h>
+#include <fshell/qr3dll.h>
+#include <u32std.h> // Is this available in all environments? If not, need to define TDesType ourselves
+#include <babitflags.h>
+#include <badesca.h>
+_LIT(KCrLf, "\r\n");
+_LIT(KPrompt, "fdb>");
+
+using namespace IoUtils;
+using namespace LtkUtils;
+
+const TInt KMaxRegisters = 32;
+
+class CCmdFdb : public CMemoryAccessCommandBase, public MLineEditorObserver, public MLineCompleter
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdFdb();
+private:
+	struct SThreadContext;
+	CCmdFdb();
+	void InstallL();
+	void AttachL(TUint aThreadId);
+	void Detach(SThreadContext* aContext);
+	void PrintThreadInfo(SThreadContext& aContext);
+	void PrintRegistersL(SThreadContext& aThread);
+	void PrintRegistersL(SThreadContext& aThread, TBool aUserMode);
+	void PrintRegistersLRPC(SThreadContext& aThread, TBool aUserMode);
+	void RefreshL(SThreadContext& aContext);
+	void RefreshIfRunningL(SThreadContext& aContext);
+	TPtrC LookupSymbol(TUint32 aAddress);
+	void StartCommandParsingL();
+	void ProcessLineL(const TDesC& aLine);
+	void FocusL(TUint aThreadId);
+	SThreadContext* ContextForThread(TUint aThreadId) const;
+	SThreadContext& CurrentL();
+	SThreadContext& CurrentNoRefreshL();
+	enum TPrintMode { EJustSymbols, EAllData, EHexDump };
+	void PrintMemL(TUint aThreadId, TUint32 aStart, TUint32 aEnd, TPrintMode aMode);
+	void BrrrrrainsL();
+	void ShowHelpTextL();
+	TBool IsSymbol(TUint aAddress) const;
+	void StartInteractiveViewL(TLinAddr aAddress);
+	void DrawMemViewL(TBool aUpdate);
+	void UpdateMemForMemViewL();
+	static TInt IsDescriptorHeader(TUint8 const* aHeaderPtr, TInt aMaxLen);
+	void ShowBreakpointsL();
+	static TInt BreakTest(TAny* aPtr);
+	static TInt BreakTestLtk(TAny* aPtr);
+	static TInt BreakTestCond(TAny* aPtr);
+	void ClearAllBreakpointsL();
+	void BreakpointHit(const RMemoryAccess::TBreakpointNotification& aNotif);
+	void CompleteLineWithSymbolL(TConsoleLine& aLine, TLex& aLex);
+	void CheckForConditionL(TLex& aLex, RMemoryAccess::TPredicate& aCondition);
+	
+private: // From MLineCompleter
+	void LcCompleteLineL(TConsoleLine& aLine, const TChar& aEscapeChar);
+
+private: // From MLineEditorObserver
+	void LeoHandleLine(const TDesC& aLine);
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	void RunL();
+	void DoCancel();
+
+private:
+	// Command line stuff
+	TBool iAllThreads;
+	TUint iThreadId;
+	TFileName2 iBsymFile;
+	TFileName2 iMapFileDir;
+
+	// Thread context
+	struct SThreadContext
+		{
+		SThreadContext() : iUserValidRegisters(0), iSupervisorValidRegisters(0), iFlags(0) {}
+
+		RThread iThread;
+		TUint32 iUserRegisters[KMaxRegisters];
+		TUint32 iUserValidRegisters;
+		TUint32 iSupervisorRegisters[KMaxRegisters];
+		TUint32 iSupervisorValidRegisters;
+		TThreadKernelInfo iKernelInfo;
+		enum TFlags { ERunning = 1, };
+		TBitFlags32 iFlags;
+		};
+	SThreadContext* iCurrent;
+	RPointerArray<SThreadContext> iThreads;
+
+	// Other stuff
+	CSymbolics* iSymbols;
+	TBuf<256> iTempNameBuf;
+
+	// Line editor support
+	TIoConsWriterAdaptor iConsoleAdapter;
+	CLineEditor* iLineEditor;
+	TBuf<256> iCommandLineBuf;
+	TBool iFinishedCommand;
+	TBool iShouldExit;
+
+	// Interactive wossname support
+	enum TViewType
+		{
+		EUnspecified,
+		EStack,
+		EHeap,
+		};
+	TViewType iMemoryViewType;
+	TLinAddr iMemStart;
+	RBuf8 iMemBuf;
+	/*
+	class TCrumb
+		{
+		enum TType { EAddress, EHeapCell, };
+		TType iType;
+		TLinAddr iAddress;
+		TInt iIndex;
+		}
+	RArray<TCrumb> iBreadcrumbs;
+	RArray<TLinAddr> iMarks;
+	RArray<TLinAddr> iLinks;
+	*/
+
+	// Breakpoint support
+	RMemoryAccess::TBreakpointNotification iBreakpointNotification;
+	TPckg<RMemoryAccess::TBreakpointNotification> iBreakpointNotificationPkg;
+	class CBreakpointNotifier : public CActive
+		{
+	public:
+		CBreakpointNotifier(CCmdFdb& aCmd);
+		~CBreakpointNotifier();
+
+	private:
+		void Request();
+		void RunL();
+		void DoCancel();
+
+	private:
+		CCmdFdb& iCmd;
+		};
+	friend class CBreakpointNotifier; // Declaration needed for gcc 2.9
+	CBreakpointNotifier* iBreakpointNotifier;
+	};
+
+EXE_BOILER_PLATE(CCmdFdb)
+
+CCommandBase* CCmdFdb::NewLC()
+	{
+	CCmdFdb* self = new(ELeave) CCmdFdb();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdFdb::~CCmdFdb()
+	{
+	Cancel();
+	delete iLineEditor;
+	for (TInt i = 0; i < iThreads.Count(); i++)
+		{
+		SThreadContext* thread = iThreads[i];
+		thread->iThread.Close();
+		delete thread;
+		}
+	iThreads.Close();
+	delete iSymbols;
+	iMemBuf.Close();
+	delete iBreakpointNotifier;
+	/*
+	iLinks.Close();
+	iBreadcrumbs.Close();
+	iMarks.Close();
+	*/
+	}
+
+CCmdFdb::CCmdFdb()
+	: CMemoryAccessCommandBase(EManualComplete), iConsoleAdapter(Stdout()), iBreakpointNotificationPkg(iBreakpointNotification)
+	{
+	}
+
+const TDesC& CCmdFdb::Name() const
+	{
+	_LIT(KName, "fdb");	
+	return KName;
+	}
+
+void CCmdFdb::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendUintL(iThreadId, _L("threadid"));
+	}
+
+void CCmdFdb::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iAllThreads, _L("all"));
+	aOptions.AppendFileNameL(iBsymFile, _L("symbols"));
+	aOptions.AppendFileNameL(iMapFileDir, _L("mapfiles"));
+	}
+
+struct STestData
+	{
+	STestData() : iPtr8(NULL, 0) {}
+
+	char iPad1[12];
+	TBuf8<6> iBuf8;
+	TInt iPad2;
+	TBufC8<9> iBufC8;
+	char iPad3;
+	TPtrC8 iPtrC8;
+	TUint64 iPad4;
+	TPtr8 iPtr8;
+	char iPad5[3];
+	};
+
+
+void CCmdFdb::DoRunL()
+	{
+	LoadMemoryAccessL();
+	TInt mode = iMemAccess.GetZombieDebugMode();
+	LeaveIfErr(mode, _L("Couldn't get zombie mode from driver"));
+
+	iSymbols = new(ELeave) CSymbolics(FsL());
+	if (iBsymFile.Length())
+		{
+		//Printf(_L("Loading symbolics... ")); // It can take a while...
+		iSymbols->AddBsymFileL(iBsymFile);
+		//Printf(_L("done.\r\n"));
+		}
+	if (iMapFileDir.Length())
+		{
+		iSymbols->SetFallbackMapFileDirL(iMapFileDir);
+		}
+
+	// Testing
+	//CMapFile* map = CMapFile::NewL(FsL(), _L("C:\\symbols\\QResources3.exe.map"));
+	//iSymbols->AddMapFileL(map);
+	//const TDesC& symName = iSymbols->LookupL(_L("QResources3.exe"), 0x10abc);
+	//Printf(_L("Found symbol = %S\r\n"), &symName);
+	
+	if (Env().IsDefined(_L("FDB_TEST")))
+		{
+		STestData test;
+		test.iBuf8 = _L8("12345");
+		test.iBufC8 = _L8("abcdefg");
+		test.iPtrC8.Set(test.iBufC8);
+		TPckg<STestData> pkg(test);
+		iMemBuf.Assign(pkg.AllocL());
+		DrawMemViewL(EFalse);
+		return;
+		}
+	
+	TBool install = ETrue;
+	// Figure out something sensible to do
+	if (mode != 0 || iThreadId != 0) install = EFalse;
+
+	if (iAllThreads) Printf(_L("Note that because --all-threads was specified, this and all future commands will hang rather than exiting!\r\n"));
+
+	InstallL(); // Always do this, in case user has changed the --all-threads setting
+	if (install)
+		{
+		// This will really mess up evalid, but the toolkit doesn't really use it so I don't feel *too* guilty
+		Printf(_L8("Welcome to fdb (build " __DATE__ " " __TIME__ ").\r\nDebugger hook installed and will stay running until you type 'uninstall'.\r\nYou can exit fdb if required and it will stay running in the background.\r\nType 'help' for command info.\r\n"));
+		}
+	else
+		{
+		AttachL(iThreadId);
+		}
+
+	iBreakpointNotifier = new(ELeave) CBreakpointNotifier(*this);
+	TInt err = iMemAccess.RegisterPersistantBreakpoint(LtkUtils::BreakpointAddr());
+	if (err != KErrNone && err != KErrAlreadyExists)
+		{
+		LeaveIfErr(err, _L("Couldn't install the LtkUtils::Breakpoint() breakpoint"));
+		}
+	StartCommandParsingL();
+	}
+
+void CCmdFdb::InstallL()
+	{
+	LeaveIfErr(iMemAccess.SetZombieDebugMode(iAllThreads ? 2 : 1), _L("Couldn't install thread monitor"));
+	const TUint32 KAllThreadsSystem = 1; // Word 2, bit 0
+	TUint32 dbgmask = UserSvr::DebugMask(2);
+	if (dbgmask & KAllThreadsSystem)
+		{
+		Printf(_L("(Clearing KAllThreadsSystem attribute)\r\n"));
+		User::SetDebugMask(dbgmask & ~KAllThreadsSystem, 2);
+		}
+	}
+
+void CCmdFdb::AttachL(TUint aThreadId)
+	{
+	if (aThreadId == 0)
+		{
+		// Need to figure out something to attach to
+		TBuf8<64> buf; // TODO handle more than this many zombies
+		TInt res = iMemAccess.GetZombies(buf);
+		LeaveIfErr(res, _L("Couldn't get zombie info from driver"));
+		//TInt leftOver = 0;
+		//if (res > buf.MaxLength()) leftOver = (res - buf.MaxLength()) / sizeof(TUint);
+		RMemoryAccess::TZombieInfo* ptr = (RMemoryAccess::TZombieInfo*)buf.Ptr();
+		TInt zombiecount = buf.Length() / sizeof(RMemoryAccess::TZombieInfo);
+		for (TInt i = 0; i < zombiecount; i++)
+			{
+			TUint id = ptr[i].iThreadId;
+			if (ContextForThread(id)) continue; // already attached to this thread, keep looking
+			RThread thread;
+			TInt err = iMemAccess.RThreadForceOpen(thread, id);
+			if (err)
+				{
+				PrintWarning(_L("Couldn't open thread %u"), id);
+				continue;
+				}
+			iTempNameBuf = thread.FullName();
+			Printf(_L("(Found thread id %u %S)\r\n"), id, &iTempNameBuf);
+			if (aThreadId == 0) aThreadId = id;
+			thread.Close();
+			}
+		if (aThreadId == 0)
+			{
+			if (buf.Length())
+				Printf(_L("No zombied threads found that aren't already attached.\r\n"));
+			else
+				PrintWarning(_L("No zombied threads found to attach to."));
+			return;
+			}
+		else
+			{
+			Printf(_L("(Attaching to thread %u)\r\n"), aThreadId);
+			}
+		}
+
+	SThreadContext* context = ContextForThread(aThreadId);
+	if (context)
+		{
+		PrintWarning(_L("Already attached to thread %u, focussing it instead."), aThreadId);
+		iCurrent = context;
+		return;
+		}
+
+	context = new(ELeave) SThreadContext;
+	CleanupStack::PushL(context);
+	RThread& thread(context->iThread);
+	CleanupClosePushL(thread);
+	LeaveIfErr(iMemAccess.RThreadForceOpen(thread, aThreadId), _L("Couldn't open thread %u"), aThreadId);
+	RefreshL(*context);
+	iThreads.AppendL(context);
+	CleanupStack::Pop(2, context); // context->iThread, context
+	iCurrent = context;
+
+	PrintThreadInfo(*context);
+	// Don't print any more than this - it makes the output too wordy
+	//PrintRegistersL(*context);
+	}
+
+void CCmdFdb::PrintThreadInfo(SThreadContext& aContext)
+	{
+	RThread& aThread = aContext.iThread;
+	TFullName name = aThread.FullName();
+	Write(_L("Name: "));
+	Write(name);
+
+	Printf(_L("\r\nThread Id: %d, exit type: "), (TUint)aThread.Id());
+	TExitType exitType = aThread.ExitType();
+	if (exitType == EExitPending)
+		{
+		Printf(_L("Still running\r\n"));
+		}
+	else if (exitType == EExitKill)
+		{
+		Printf(_L("Kill %d\r\n"), aThread.ExitReason());
+		}
+	else if (exitType == EExitTerminate)
+		{
+		Printf(_L("Terminate %d\r\n"), aThread.ExitReason());
+		}
+	else if (exitType == EExitPanic)
+		{
+		TExitCategoryName exitCategory = aThread.ExitCategory();
+		Printf(_L("Panic %S %d\r\n"), &exitCategory, aThread.ExitReason());
+		}
+
+	Printf(_L("User stack: base=%08x limit=%08x\r\n"), aContext.iKernelInfo.UserStackBase(), aContext.iKernelInfo.iUserStackLimit);
+	Printf(_L("Kern stack: base=%08x limit=%08x\r\n"), aContext.iKernelInfo.iSupervisorStack + aContext.iKernelInfo.iSupervisorStackSize, aContext.iKernelInfo.iSupervisorStack);
+	}
+
+void CCmdFdb::PrintRegistersL(SThreadContext& aThread)
+	{
+	PrintRegistersL(aThread, ETrue);
+	PrintRegistersL(aThread, EFalse);
+	}
+
+void CCmdFdb::PrintRegistersL(SThreadContext& aThread, TBool aUserMode)
+	{
+	if (aUserMode)
+		{
+		Printf(_L("User mode registers:\r\n"));
+		}
+	else
+		{
+		Printf(_L("Supervisor mode registers:\r\n"));
+		}
+
+	TUint32 valid = aThread.iUserValidRegisters;
+	TUint32* ptr = aThread.iUserRegisters;
+	if (!aUserMode)
+		{
+		valid = aThread.iSupervisorValidRegisters;
+		ptr = aThread.iSupervisorRegisters;
+		}
+
+	if (valid == 0) Printf(_L("(No valid registers)\r\n"));
+	// From here down is ARM specific, but since no other platforms implement this API there's no pressing need to ifdef it
+	// See TArmRegSet for the ordering
+	for (TInt i = 0; i < 16; i++)
+		{
+		if (valid & (1<<i))
+			{
+			if (i < 10) Write(_L(" ")); // extra space for padding
+			Printf(_L("  R%d: "), i);
+			Printf(_L("%08x "), ptr[i]);
+			Write(LookupSymbol(ptr[i]));
+			Write(KCrLf);
+			}
+		}
+	if (valid & (1<<16))
+		{
+		Printf(_L("Flags (%cPSR): %08x\r\n"), aUserMode ? 'C' : 'S', ptr[16]); // CPSR or SPSR
+		}
+	if (valid & (1<<17))
+		{
+		// Domain Access Control Register
+		Printf(_L(" DACR: %08x\r\n"), ptr[16]);
+		}
+	}
+
+void CCmdFdb::PrintRegistersLRPC(SThreadContext& aThread, TBool aUserMode)
+	{
+	// Print these in the format of the stack trace
+	TUint32 valid = aThread.iUserValidRegisters;
+	TUint32* ptr = aThread.iUserRegisters;
+	if (!aUserMode)
+		{
+		valid = aThread.iSupervisorValidRegisters;
+		ptr = aThread.iSupervisorRegisters;
+		}
+	
+	if (valid & 1<<15)
+		{
+		Printf(_L("     R15: %08x "), ptr[15]);
+		Write(LookupSymbol(ptr[15]));
+		Write(KCrLf);
+		}
+	if (valid & 1<<14)
+		{
+		Printf(_L("     R14: %08x "), ptr[14]);
+		Write(LookupSymbol(ptr[14]));
+		Write(KCrLf);
+		}
+	}
+
+void CCmdFdb::RefreshIfRunningL(SThreadContext& aContext)
+	{
+	if (iCurrent->iFlags.IsSet(SThreadContext::ERunning))
+		{
+		// Thread is still running, we should refresh our info
+		RefreshL(aContext);
+		}
+	}
+
+void CCmdFdb::RefreshL(SThreadContext& aContext)
+	{
+	aContext.iFlags.Assign(SThreadContext::ERunning, aContext.iThread.ExitType() == EExitPending);
+	TUint tid = aContext.iThread.Id();
+
+	// Get registers
+	TPtr8 userreg((TUint8*)&aContext.iUserRegisters[0], KMaxRegisters*sizeof(TUint32), KMaxRegisters*sizeof(TUint32));
+	userreg.FillZ();
+	aContext.iUserValidRegisters = 0;
+	TInt err = iMemAccess.GetRegisters(aContext.iThread, ETrue, userreg, aContext.iUserValidRegisters);
+	if (err) PrintError(err, _L("Couldn't read user registers for thread %u"), tid);
+
+	TPtr8 supreg((TUint8*)&aContext.iSupervisorRegisters[0], KMaxRegisters*sizeof(TUint32), KMaxRegisters*sizeof(TUint32));
+	supreg.FillZ();
+	aContext.iSupervisorValidRegisters = 0;
+	err = iMemAccess.GetRegisters(aContext.iThread, EFalse, supreg, aContext.iSupervisorValidRegisters);
+	if (err) PrintError(err, _L("Couldn't read supervisor registers for thread %u\r\n"), tid);
+
+	// And memaccess info
+	TPckg<TThreadKernelInfo> kerninfo(aContext.iKernelInfo);
+	err = iMemAccess.GetObjectInfoByHandle(EThread, RThread().Id(), aContext.iThread.Handle(), kerninfo);
+	if (err) PrintError(err, _L("Couldn't read thread info from memoryaccess for thread %u\r\n"), tid);
+	//aContext.iFlags.Assign(SThreadContext::ESuspended, aContext.iKernelInfo.iNThreadSuspendCount != 0);
+	}
+	
+TPtrC CCmdFdb::LookupSymbol(TUint32 aAddress)
+	{
+	TPtrC name;
+	if (iSymbols)
+		{
+		// Try straight ROM address lookup
+		TRAPD(err, name.Set(iSymbols->LookupL(aAddress)));
+		if (err) PrintError(err, _L("Failed to lookup symbol"));
+		if (name.Length()) return name;
+		}
+	// Try getting a codeseg from memaccess
+	TFullName8 codesegname;
+	TInt res = iMemAccess.FindAddressInCodeSegments(codesegname, (TAny*)aAddress);
+	if (res >= 0)
+		{
+		iTempNameBuf.Copy(codesegname);
+		if (iSymbols)
+			{
+			// Try codeseg lookup in CSymbolics (ie in a CMapFile)
+			TParsePtrC parse(iTempNameBuf);
+			TRAPD(err, name.Set(iSymbols->LookupL(parse.NameAndExt(), res)));
+			if (err) PrintError(err, _L("Failed to lookup symbol"));
+			if (name.Length()) return name;
+			}
+		// Otherwise fallback to just doing codeseg+offset
+		iTempNameBuf.AppendFormat(_L(" + 0x%x"), res);
+		return iTempNameBuf;
+		}
+	// Last ditch, check if euser thinks it's in ROM
+	if (RFs::IsRomAddress((TAny*)aAddress))
+		{
+		_LIT(KSomewhere, "[Somewhere in ROM]");
+		return KSomewhere();
+		}
+	return KNullDesC();
+	}
+
+void CCmdFdb::StartCommandParsingL()
+	{
+	TBuf<64> historyFile;
+	User::LeaveIfError(FsL().PrivatePath(historyFile));
+	historyFile.Insert(0, _L("c:"));
+	historyFile.Append(_L("fdb_history"));
+	Fs().CreatePrivatePath(EDriveC);
+
+	iLineEditor = CLineEditor::NewL(Fs(), iConsoleAdapter, *this, *this, historyFile);
+	iLineEditor->Start(KPrompt, iCommandLineBuf);
+	iLineEditor->ReinstatePromptAndUserInput();
+	SetErrorReported(EFalse);
+	Stdin().WaitForKey(iStatus);
+	SetActive();
+	}
+
+void CCmdFdb::RunL()
+	{
+	if (iStatus.Int() < 0)
+		{
+		// iosrv dead?
+		Complete(iStatus.Int());
+		return;
+		}
+
+	iLineEditor->HandleKey(Stdin().KeyCode(), Stdin().KeyModifiers());
+	if (iShouldExit)
+		{
+		Complete(KErrNone);
+		}
+	else if (iFinishedCommand)
+		{
+		iLineEditor->Start(KPrompt, iCommandLineBuf);
+		iLineEditor->ReinstatePromptAndUserInput();
+		iFinishedCommand = EFalse;
+		SetErrorReported(EFalse); // We need to clear this each time through
+		}
+	
+	if (!iShouldExit)
+		{
+		Stdin().WaitForKey(iStatus);
+		SetActive();
+		}
+	}
+
+void CCmdFdb::DoCancel()
+	{
+	Stdin().WaitForKeyCancel();
+	}
+
+void CCmdFdb::LcCompleteLineL(TConsoleLine& aLine, const TChar& /*aEscapeChar*/)
+	{
+	TPtrC line = aLine.ContentsToCursor();
+	TLex lex(line);
+	TPtrC cmd = lex.NextToken();
+	if (cmd != _L("b") && cmd != _L("break")) return; // We only currently do completion on the 'break' command
+
+	CompleteLineWithSymbolL(aLine, lex);
+	}
+
+void CCmdFdb::CompleteLineWithSymbolL(TConsoleLine& aLine, TLex& aLex)
+	{
+	// Have we got as far as a codeseg? We don't support completing on codeseg yet
+	TPtrC codeseg = aLex.NextToken();
+	TPtrC ext = codeseg.Right(4);
+	if (ext != _L(".dll") && ext != _L(".exe")) return;
+
+	aLex.SkipSpace();
+	TInt symbolStartPos = aLex.Offset();
+	TPtrC symbol = aLex.Remainder();
+	RLtkBuf buf;
+	buf.CreateLC(512);
+	buf.Copy(symbol);
+	CDesC16Array* suggestions = new(ELeave) CDesC16ArrayFlat(32);
+	CleanupStack::PushL(suggestions);
+	//TODO this can be slow first time, need some UI to warn the user
+	iSymbols->CompleteL(codeseg, buf, *suggestions);
+	if (buf.Length() > symbol.Length())
+		{
+		aLine.Replace(symbolStartPos, buf);
+		}
+	// If the tab added any chars we don't show choices
+	else if (suggestions->Count() > 1)
+		{
+		buf.Zero();
+		for (TInt i = 0; i < suggestions->Count(); i++)
+			{
+			if (i > 0) buf.AppendL('\t');
+			buf.AppendL((*suggestions)[i]);
+			}
+		aLine.PrintCompletionPossibilitiesL(buf);
+		}
+
+	CleanupStack::PopAndDestroy(suggestions);
+	CleanupStack::PopAndDestroy(&buf);
+	}
+
+void CCmdFdb::LeoHandleLine(const TDesC& aLine)
+	{
+	iFinishedCommand = ETrue;
+	if (aLine.Length())
+		{
+		TRAPD(err, ProcessLineL(aLine));
+		if (err)
+			{
+			PrintError(err, _L("Error executing command"));
+			}
+		}
+	}
+
+void CCmdFdb::ProcessLineL(const TDesC& aLine)
+	{
+	TLex lex(aLine);
+	TPtrC cmd = lex.NextToken();
+	lex.SkipSpace();
+
+	char ch = 0;
+	if (cmd.Length() == 1)
+		{
+		ch = cmd[0];
+		}
+
+	_LIT(KHelp, "help");
+	_LIT(KExit, "exit");
+	_LIT(KAttach, "attach");
+	_LIT(KDetach, "detach");
+	_LIT(KFocus, "focus");
+	_LIT(KRegisters, "registers");
+	_LIT(KLookup, "lookup");
+	_LIT(KStack, "stack");
+	_LIT(KKstack, "kstack");
+	_LIT(KList, "list");
+	_LIT(KMem, "mem");
+	_LIT(KUninstall, "uninstall");
+	_LIT(KBrowse, "browse");
+	_LIT(KBreak, "break");
+	_LIT(KContinue, "continue");
+	_LIT(KClear, "clear");
+	_LIT(KLoad, "load");
+	if (cmd == KHelp || ch == 'h')
+		{
+		ShowHelpTextL();
+		}
+	else if (cmd == KExit || ch == 'x')
+		{
+		iShouldExit = ETrue; // TODO check whether a detach is desired
+		}
+	else if (cmd == KUninstall || ch == 'u')
+		{
+		Printf(_L("Uninstalling thread hook, clearing all breakpoints, freeing all zombie threads. Undertakers will now get notified of the threads' exits.\r\n"));
+		iMemAccess.SetZombieDebugMode(0);
+		iShouldExit = ETrue;
+		}
+	else if (cmd == KAttach || ch == 'a')
+		{
+		TUint threadId = 0;
+		lex.Val(threadId);
+		AttachL(threadId);
+		}
+	else if (cmd == KFocus || ch == 'f')
+		{
+		TUint threadId = 0;
+		lex.Val(threadId);
+		if (threadId == 0)
+			{
+			PrintThreadInfo(CurrentL());
+			}
+		else
+			{
+			FocusL(threadId);
+			}
+		}
+	else if (cmd == KRegisters || ch == 'r')
+		{
+		PrintRegistersL(CurrentL());
+		}
+	else if (cmd == KLookup || ch == '?')
+		{
+		TUint32 addr = LtkUtils::HexLexL(lex);
+		Printf(_L("%08x: "), addr);
+		Write(LookupSymbol(addr));
+		Write(KCrLf);
+		}
+	else if (cmd == KDetach || ch == 'd')
+		{
+		TUint threadId = 0;
+		lex.Val(threadId);
+		SThreadContext* thread = NULL;
+		if (threadId == 0)
+			{
+			// No point refreshing, all it will do is possibly complain about reading the registers (which looks confusing)
+			thread = &CurrentNoRefreshL();
+			}
+		else
+			{
+			thread = ContextForThread(threadId);
+			if (!thread) LeaveIfErr(KErrNotFound, _L("Thread %u is not currently attached."), threadId);
+			}
+		Detach(thread);
+		}
+	else if (cmd == KStack || ch == 't')
+		{
+		TBool all = lex.NextToken() == _L("all");
+		SThreadContext& c = CurrentL();
+		TUint32 start = c.iKernelInfo.iUserStackLimit;
+		TUint32 end = c.iKernelInfo.UserStackBase();
+		if (start == 0)
+			{
+			Printf(_L("No user stack for this thread.\r\n"));
+			}
+		else
+			{
+			PrintRegistersLRPC(c, ETrue);
+			if ((c.iUserValidRegisters & (1 << 13)) && Rng(start, c.iUserRegisters[13], end)) start = c.iUserRegisters[13];
+			PrintMemL(c.iThread.Id(), start, end, all ? EAllData : EJustSymbols);
+			}
+		}
+	else if (cmd == KKstack || ch == 'k')
+		{
+		TBool all = lex.NextToken() == _L("all");
+		SThreadContext& c = CurrentL();
+		TUint32 start = c.iKernelInfo.iSupervisorStack;
+		TUint32 end = start + c.iKernelInfo.iSupervisorStackSize;
+		if (start == 0)
+			{
+			Printf(_L("Couldn't find kernel stack for this thread (!?).\r\n"));
+			}
+		else
+			{
+			PrintRegistersLRPC(c, EFalse);
+			if ((c.iSupervisorValidRegisters & (1 << 13)) && Rng(start, c.iSupervisorRegisters[13], end)) start = c.iSupervisorRegisters[13];
+			PrintMemL(0, start, end, all ? EAllData : EJustSymbols); // zero is the null thread, which is a kernel thread thus has the address space we're interested in
+			}
+		}
+	else if (cmd == KList || ch == 'l')
+		{
+		BrrrrrainsL();
+		}
+	else if (cmd == KMem || ch == 'm')
+		{
+		TUint32 start = LtkUtils::HexLexL(lex);
+		lex.SkipSpace();
+		TUint32 len = LtkUtils::HexLexL(lex);
+		PrintMemL(CurrentL().iThread.Id(), start, start+len, EHexDump);
+		}
+	else if (cmd == KBrowse)
+		{
+		TPtrC remainder = lex.Remainder();
+		TLinAddr addr = 0;
+		if (remainder.Length() == 0 || remainder == _L("heap"))
+			{
+			//TODO
+			}
+		else if (remainder == _L("stack"))
+			{
+			//TODO
+			}
+		else
+			{
+			addr = LtkUtils::HexLexL(lex);
+			}
+		StartInteractiveViewL(addr);
+		}
+	else if (cmd == KBreak || ch == 'b')
+		{
+		TInt res = KErrNone;
+		TBool set = ETrue;
+		TPtrC remainder = lex.Remainder();
+		if (remainder.Length() == 0)
+			{
+			ShowBreakpointsL();
+			set = EFalse;
+			}
+		else if (remainder == _L("test"))
+			{
+			// This is undocumented, for testing only
+			RThread me;
+			res = iMemAccess.SetBreakpoint(me, (TLinAddr)&LtkUtils::RawPrint);
+			LeaveIfErr(res, _L("Couldn't set test breakpoint"));
+			RThread testThread;
+			LeaveIfErr(testThread.Create(_L("BreakpointTestThread"), &BreakTest, 8192, NULL, NULL), _L("Couldn't create test thread"));
+			testThread.Resume();
+			testThread.Close();
+			}
+		else if (remainder == _L("testltk"))
+			{
+			// This is undocumented, for testing only
+			RThread testThread;
+			LeaveIfErr(testThread.Create(_L("BreakpointLtkTestThread"), &BreakTestLtk, 8192, NULL, NULL), _L("Couldn't create test thread"));
+			testThread.Resume();
+			testThread.Close();
+			set = EFalse;
+			}
+		else if (remainder == _L("testhw"))
+			{
+			// This is undocumented, for testing only
+			RThread testThread;
+			LeaveIfErr(testThread.Create(_L("BreakpointTestThread"), &BreakTest, 8192, NULL, NULL), _L("Couldn't create test thread"));
+			res = iMemAccess.SetBreakpoint(testThread, (TLinAddr)&LtkUtils::RawPrint);
+			LeaveIfErr(res, _L("Couldn't set test breakpoint"));
+			testThread.Resume();
+			testThread.Close();
+			}
+		else if (remainder == _L("testcond"))
+			{
+			// This is undocumented, for testing only
+			RThread testThread;
+			LeaveIfErr(testThread.Create(_L("BreakpointTestThread"), &BreakTestCond, 8192, NULL, NULL), _L("Couldn't create test thread"));
+			RMemoryAccess::TPredicate condition;
+			LeaveIfErr(condition.AddCondition(RMemoryAccess::TPredicate::ESignedEq, 0, (TUint)-5), _L("Couldn't add condition"));
+			res = iMemAccess.SetBreakpoint(testThread, (TLinAddr)&User::Leave, &condition);
+			LeaveIfErr(res, _L("Couldn't set test breakpoint"));
+			testThread.Resume();
+			testThread.Close();
+			}
+		else
+			{
+			TUint addr;
+			TInt err = HexLex(lex, addr);
+			if (err)
+				{
+				// Try codeseg and symbol name
+				TPtrC codeseg = lex.NextToken();
+				lex.SkipSpace();
+				TPtrC name = lex.Remainder();
+				// Hmm symbols can have spaces in, how to distinguish the condition? Assume if the last word starts with an 'r' it's a condition. Not very nice.
+				TInt space = name.LocateReverse(' ');
+				RMemoryAccess::TPredicate condition;
+				if (space >= 0 && space+1 < name.Length() && name[space+1] == 'r')
+					{
+					name.Set(name.Left(space));
+					lex.Inc(name.Length());
+					while (!lex.Eos())
+						{
+						CheckForConditionL(lex, condition);
+						}
+					}
+
+				TUint offset = 0;
+				TRAPL(offset = iSymbols->CodesegOffsetFromSymbolNameL(codeseg, name), _L("Couldn't find offset of symbol '%S' in codeseg '%S'"), &name, &codeseg);
+				RLtkBuf8 codeseg8;
+				CleanupClosePushL(codeseg8);
+				codeseg8.AppendL(codeseg);
+				res = iMemAccess.SetSymbolicBreakpoint(CurrentL().iThread, codeseg8, offset, &condition);
+				LeaveIfErr(res, _L("Couldn't create symbolic breakpoint"));
+				CleanupStack::PopAndDestroy(&codeseg8);
+				}
+			else
+				{
+				RMemoryAccess::TPredicate condition;
+				while (!lex.Eos())
+					{
+					CheckForConditionL(lex, condition);
+					}
+				res = iMemAccess.SetBreakpoint(CurrentL().iThread, addr, &condition);
+				LeaveIfErr(res, _L("Couldn't create breakpoint"));
+				Printf(_L("Breakpoint created at 0x%08x "), addr);
+				Write(LookupSymbol(addr));
+				Write(KCrLf);
+				}
+			}
+
+		if (set)
+			{
+			if (res & RMemoryAccess::TBreakpointInfo::EHardware)
+				{
+				Printf(_L("Hardware breakpoint %d set.\r\n"), res & ~RMemoryAccess::TBreakpointInfo::EHardware);
+				}
+			else if (res == 0)
+				{
+				Printf(_L("Pending breakpoint set (Note these don't work yet!)\r\n"));
+				}
+			else
+				{
+				Printf(_L("Breakpoint %d set.\r\n"), res);
+				}
+			}
+		}
+	else if (cmd == KContinue || ch =='c')
+		{
+		TInt err = iMemAccess.ContinueFromBreakpoint(CurrentL().iThread);
+		LeaveIfErr(err, _L("Couldn't continue - is the thread definitely stopped on a breakpoint?"));
+		}
+	else if (cmd == KClear)
+		{
+		TPtrC remainder = lex.Remainder();
+		if (remainder.Length() == 0)
+			{
+			ClearAllBreakpointsL();
+			}
+		else
+			{
+			TInt n;
+			User::LeaveIfError(lex.Val(n));
+			LeaveIfErr(iMemAccess.ClearBreakpoint(n), _L("Couldn't clear breakpoint %d"), n);
+			}
+		}
+	else if (cmd == KLoad)
+		{
+		TPtrC path = lex.Remainder();
+		if (path.Right(5).CompareF(_L(".bsym")) == 0)
+			{
+			//Printf(_L("Loading symbolics... ")); // It can take a while...
+			iSymbols->AddBsymFileL(path);
+			//Printf(_L("done.\r\n"));
+			}
+		else
+			{
+			iSymbols->SetFallbackMapFileDirL(path);
+			}
+		}
+	else
+		{
+		PrintError(KErrNotFound, _L("Unrecognised command '%S'. Try 'help'."), &cmd);
+		}
+	}
+
+CCmdFdb::SThreadContext* CCmdFdb::ContextForThread(TUint aThreadId) const
+	{
+	for (TInt i = 0; i < iThreads.Count(); i++)
+		{
+		if ((TUint)iThreads[i]->iThread.Id() == aThreadId)
+			{
+			return iThreads[i];
+			}
+		}
+	return NULL;
+	}
+
+CCmdFdb::SThreadContext& CCmdFdb::CurrentL()
+	{
+	CCmdFdb::SThreadContext& current = CurrentNoRefreshL();
+	RefreshIfRunningL(current);
+	return current;
+	}
+
+CCmdFdb::SThreadContext& CCmdFdb::CurrentNoRefreshL()
+	{
+	if (!iCurrent)
+		{
+		LeaveIfErr(KErrNotReady, _L("No currently focussed thread"));
+		}
+	return *iCurrent;
+	}
+
+void CCmdFdb::FocusL(TUint aThreadId)
+	{
+	SThreadContext* c = ContextForThread(aThreadId);
+	if (c) iCurrent = c;
+	else
+		{
+		LeaveIfErr(KErrNotFound, _L("Couldn't find thread id %u in the attached threads. Do you need to do 'attach %u'?"), aThreadId, aThreadId);
+		}
+	}
+
+void CCmdFdb::Detach(SThreadContext* aContext)
+	{
+	TInt err = iMemAccess.ReleaseZombie(aContext->iThread);
+	if (err && aContext->iFlags.IsSet(SThreadContext::ERunning))
+		{
+		// Don't complain about driver if the thread wasn't actually zombied
+		PrintError(err, _L("Driver couldn't find zombie thread"));
+		}
+
+	TInt arrayPos = iThreads.Find(aContext);
+	iThreads.Remove(arrayPos);
+	if (iCurrent == aContext) iCurrent = NULL;
+	aContext->iThread.Close();
+	delete aContext;
+	}
+
+void CCmdFdb::PrintMemL(TUint aThreadId, TUint32 aStart, TUint32 aEnd, TPrintMode aMode)
+	{
+	// word-align start and end
+	aStart &= ~3;
+	aEnd = (aEnd+3) & (~3);
+
+	TInt size = aEnd - aStart;
+	RBuf8 mem;
+	CleanupClosePushL(mem);
+	mem.CreateL(size);
+
+	TThreadMemoryAccessParamsBuf params;
+	params().iId = aThreadId;
+	params().iAddr = (TUint8*)aStart;
+	params().iSize = size;
+
+	TInt err = iMemAccess.GetThreadMem(params, mem);
+	LeaveIfErr(err, _L("Couldn't read thread memory %08x-%08x"), aStart, aEnd);
+
+	if (aMode == EHexDump)
+		{
+		TInt offset = (TInt)aStart;
+		LtkUtils::HexDumpToOutput(mem, Stdout(), offset);
+		}
+	else
+		{
+		const TUint32* ptr = (const TUint32*)mem.Ptr();
+		const TInt count = mem.Size() / 4;
+		for (TInt i = 0; i < count; i++)
+			{
+			TUint32 word = ptr[i];
+			TBool print = aMode == EAllData || IsSymbol(word);
+			if (print)
+				{
+				Printf(_L("%08x: %08x "), aStart + i*4, word);
+				Write(LookupSymbol(word));
+				Write(KCrLf);
+				}
+			}
+		}
+	CleanupStack::PopAndDestroy(&mem);
+	}
+
+void CCmdFdb::BrrrrrainsL()
+	{
+	RBuf8 buf;
+	CleanupClosePushL(buf);
+	buf.CreateL(1024);
+	TInt res = iMemAccess.GetZombies(buf);
+	LeaveIfErr(res, _L("Couldn't get zombie info from driver"));
+	RMemoryAccess::TZombieInfo* ptr = (RMemoryAccess::TZombieInfo*)buf.Ptr();
+	const TInt zombiecount = buf.Length()/sizeof(RMemoryAccess::TZombieInfo);
+
+	// Go through all the zombies
+	for (TInt i = 0; i < zombiecount; i++)
+		{
+		TUint id = ptr[i].iThreadId;
+		SThreadContext* context = ContextForThread(id);
+		char stat = '-';
+		char suspended = '-';
+		if (context)
+			{
+			stat = 'a';
+			if (context == iCurrent) stat = '*';
+			iTempNameBuf = context->iThread.FullName();
+			}
+		else
+			{
+			RThread thread;
+			TInt err = iMemAccess.RThreadForceOpen(thread, id);
+			if (err)
+				{
+				PrintWarning(_L("Couldn't open thread %u"), id);
+				continue;
+				}
+			iTempNameBuf = thread.FullName();
+			thread.Close();
+			}
+		if (ptr[i].iFlags & RMemoryAccess::TZombieInfo::ESuspended) suspended = 's';
+		if (ptr[i].iFlags & RMemoryAccess::TZombieInfo::EBreakpoint) suspended = 'b';
+
+		Printf(_L("%c%c %u "), stat, suspended, id);
+		Write(iTempNameBuf);
+		Write(KCrLf);
+		}
+
+	// Now do any attached threads that aren't zombied
+	for (TInt i = 0; i < iThreads.Count(); i++)
+		{
+		SThreadContext* c = iThreads[i];
+		TUint id = (TUint)c->iThread.Id();
+		RMemoryAccess::TZombieInfo dummy; dummy.iThreadId = id;
+		TBool foundInZombies = EFalse;
+		if (zombiecount) foundInZombies = RArray<RMemoryAccess::TZombieInfo>(sizeof(RMemoryAccess::TZombieInfo), ptr, zombiecount).Find(dummy) != KErrNotFound;
+		if (!foundInZombies)
+			{
+			char stat = 'a';
+			if (c == iCurrent) stat = '*';
+			iTempNameBuf = c->iThread.FullName();
+			Printf(_L("%c- %u "), stat, id);
+			Write(iTempNameBuf);
+			Write(KCrLf);
+			}
+		}
+
+	CleanupStack::PopAndDestroy(&buf);
+	}
+
+void CCmdFdb::ShowHelpTextL()
+	{
+	// Possible TODOs: hEap, Save, Ymodem?
+	_LIT(KStartOfCommands, "SUPPORTED COMMANDS\r\n\r\n");
+	CTextBuffer* helpText = const_cast<CTextBuffer*>(GetHelpTextL());
+	TInt found = helpText->Descriptor().Find(KStartOfCommands);
+	helpText->Delete(0, found + KStartOfCommands().Length());
+	helpText->Write(Stdout());
+	delete helpText;
+	}
+
+TBool CCmdFdb::IsSymbol(TUint aAddress) const
+	{
+	// Ranges probably not perfect, seem to be roughly ok though
+	TBool okRange = Rng(0x70000000u, aAddress, 0xA0000000u) || Rng(0xC0000000u, aAddress, 0xFC000000u);
+	return okRange && aAddress != 0xDEDEDEDE && aAddress != 0xAAAAAAAA && aAddress != 0xBBBBBBBB && aAddress != 0xCCCCCCCC; 
+	}
+
+void CCmdFdb::StartInteractiveViewL(TLinAddr aAddress)
+	{
+	iMemStart = aAddress & (~3);
+	if (iMemStart >= iCurrent->iKernelInfo.iUserStackLimit && iMemStart <= iCurrent->iKernelInfo.UserStackBase())
+		{
+		iMemoryViewType = EStack;
+		}
+	else //TODO EHeap
+		{
+		iMemoryViewType = EUnspecified;
+		}
+
+	iMemBuf.Zero();
+	TSize consoleSize(80,24);
+	Stdout().GetScreenSize(consoleSize);
+	iMemBuf.ReAllocL(consoleSize.iHeight * 16); // At most we display 16 bytes per line
+	TInt numBytesOnLine = 16; // By default
+	if (iMemoryViewType == EStack) numBytesOnLine = 4;
+	TInt numBytesOnScreen = numBytesOnLine * consoleSize.iHeight;
+
+	TLinAddr lastAddr = 0;
+	for (;;)
+		{
+		iMemStart &= ~3; // Just checking
+		TBool update = (iMemStart != lastAddr);
+		lastAddr = iMemStart;
+		DrawMemViewL(update);
+		TUint key = Stdin().ReadKey();
+		switch (key)
+			{
+			case EKeyPageUp:
+				iMemStart -= numBytesOnScreen;
+				break;
+			case EKeyPageDown:
+				iMemStart += numBytesOnScreen;
+				break;
+			case EKeyUpArrow:
+				iMemStart -= numBytesOnLine;
+				break;
+			case EKeyDownArrow:
+				iMemStart += numBytesOnLine;
+				break;
+			case 'q':
+			case 'x':
+			case EKeyEscape:
+				//Stdout().SetAttributesL(ConsoleAttributes::ENone);
+				return;
+			default:
+				break;
+			}
+		}
+	}
+
+void CCmdFdb::UpdateMemForMemViewL()
+	{
+	iMemBuf.Zero();
+	
+	TThreadMemoryAccessParamsBuf params;
+	params().iId = iCurrent->iThread.Id();
+	params().iAddr = (TUint8*)iMemStart;
+	params().iSize = iMemBuf.MaxSize();
+
+	TInt err = iMemAccess.GetThreadMem(params, iMemBuf);
+	if (err) PrintError(err, _L("Couldn't read thread memory %08x-%08x"), params().iAddr, params().iAddr+params().iSize);
+	}
+
+/*
+class TFocusable
+	{
+public:
+	TLinAddr iAddr;
+	enum TType
+		{
+		EHeapPtr,
+		}
+	}
+*/
+
+void CCmdFdb::DrawMemViewL(TBool aUpdate)
+	{
+	Stdout().ClearScreen();
+	if (aUpdate) UpdateMemForMemViewL();
+
+
+	// This is a really messy function. Can't seem to find a way of making it easier to read.
+	const ConsoleAttributes::TAttributes KNormal(ConsoleAttributes::ENone, ConsoleAttributes::EBlack, ConsoleAttributes::EWhite);
+	const ConsoleAttributes::TAttributes KSymbol(0, ConsoleAttributes::ERed, ConsoleAttributes::EUnchanged);
+	const ConsoleAttributes::TAttributes KDescriptor(0, ConsoleAttributes::EUnchanged, ConsoleAttributes::EYellow);
+	//const ConsoleAttributes::TAttributes KHeap(0, ConsoleAttributes::EUnchanged, ConsoleAttributes::ECyan);
+	//const ConsoleAttributes::TAttributes KHeapAlternate(0, ConsoleAttributes::EUnchanged, ConsoleAttributes::EBlue);
+	enum { ENoColor = 0, ESymbol = 1, EDescriptor = 2 };
+
+	TSize consoleSize(80,24);
+	Stdout().GetScreenSize(consoleSize);
+	TUint8 const*const bptr = iMemBuf.Ptr();
+	TUint32 const*const ptr = (TUint32 const*)bptr;
+	//iLinks.Reset();
+	CTextBuffer* text = CTextBuffer::NewLC(1024);
+	text->SetAttributesL(KNormal);
+	
+	TInt numBytesOnLine = 16; // By default
+	if (iMemoryViewType == EStack)
+		{
+		numBytesOnLine = 4;
+		}
+	//TInt numBytesOnScreen = numBytesOnLine * consoleSize.iHeight;
+	TInt remainingInDescriptor = 0; // Not in descriptor initially
+	//TInt remainingInHeapCell = 0; // Not worrying about heap cells right now
+
+	for (TInt line = 0; line < consoleSize.iHeight - 1 && line*numBytesOnLine < iMemBuf.Length(); line++)
+		{
+		TBuf8<16> colorBuf; colorBuf.SetLength(colorBuf.MaxLength());
+		TUint8* colorBufPtr = (TUint8*)colorBuf.Ptr();
+		Mem::Fill(colorBufPtr, 16, ENoColor);
+		text->AppendFormatL(_L("%08x: "), iMemStart + line*numBytesOnLine);
+
+		const TInt idxForLine = line * numBytesOnLine;
+		TInt i;
+		for (i = 0; i < numBytesOnLine; i += 4, colorBufPtr += 4)
+			{
+			const TInt idxInBuf = idxForLine + i;
+			if (idxInBuf >= iMemBuf.Length()) break;
+
+			if (remainingInDescriptor == 0) remainingInDescriptor = IsDescriptorHeader(bptr + idxInBuf, 256);
+			TInt runLen = 0;
+			if (remainingInDescriptor > 0)
+				{
+				text->SetAttributesL(KDescriptor);
+				runLen = Min(remainingInDescriptor, numBytesOnLine-i);
+				if (runLen > 4) runLen = 4; // We only do up to 4 bytes at a time
+				Mem::Fill(colorBufPtr, runLen, EDescriptor);
+				}
+
+			// Check for symbols
+			TUint32 word = ptr[idxInBuf / 4];
+			if (IsSymbol(word))
+				{
+				text->SetAttributesL(KSymbol);
+				colorBufPtr[0] |= ESymbol;
+				colorBufPtr[1] |= ESymbol;
+				colorBufPtr[2] |= ESymbol;
+				colorBufPtr[3] |= ESymbol;
+				if (iMemoryViewType == EStack)
+					{
+					TPtrC symb = LookupSymbol(word);
+					text->AppendFormatL(_L("%08x %S"), word, &symb);
+					text->SetAttributesL(KNormal);
+					text->AppendL(KCrLf);
+					continue;
+					}
+				}
+
+			// Actually print the hex bytes
+			for (TInt ch = 0; ch < 4; ch++)
+				{
+				text->AppendFormatL(_L("%02X"), bptr[idxInBuf+ch]);
+				if (runLen)
+					{
+					remainingInDescriptor--;
+					runLen--;
+					if (remainingInDescriptor == 0)	text->SetAttributesL(KNormal); // If we've just finished a run we clear the formatting before the space
+					}
+				text->AppendL(' ');
+				}
+			if (((i+4) % 16) == 0) text->SetAttributesL(KNormal); // In preparation for printing the ascii
+			if (((i+4) % 8) == 0) text->AppendL(' '); // Extra space every 8th char
+			}
+
+		TInt rem = numBytesOnLine - i;
+		if (rem > 0)
+			{
+			// Need to fill in spaces for the hex bytes we don't have
+			_LIT(K3Space, "   ");
+			while (rem--) text->AppendL(K3Space);
+			// And the final 2 spaces before the ascii
+			text->AppendL(' ');
+			text->AppendL(' ');
+			}
+
+
+		// Time to print the ascii
+		const TInt max = Min(numBytesOnLine, iMemBuf.Length() - idxForLine);
+		for (TInt j = 0; j < max; j++)
+			{
+			char ch = bptr[idxForLine + j];
+			if (ch < 32 || ch >= 128) ch = '.';
+			text->SetAttributesL(KNormal);
+			if (colorBuf[j] & EDescriptor) text->SetAttributesL(KDescriptor);
+			if (colorBuf[j] & ESymbol) text->SetAttributesL(KSymbol);
+			text->AppendL(ch);
+			}
+		text->SetAttributesL(KNormal);
+		text->AppendL(KCrLf);
+		}
+
+	text->SetAttributesL(ConsoleAttributes::ENone);
+	text->Write(Stdout());
+	CleanupStack::PopAndDestroy(text);
+	}
+
+/*static*/ TInt CCmdFdb::IsDescriptorHeader(TUint8 const* aHeaderPtr, TInt aMaxLen)
+	{
+	if (((TLinAddr)aHeaderPtr & 0x3) != 0) return 0; // Not aligned
+	TInt type = *(TUint32*)aHeaderPtr >> 28;
+
+	if ((type == EPtr || type == EBufCPtr) && aMaxLen >= 12) return 12; // Len + maxlen + ptr
+	else if (type == EPtrC && aMaxLen >= 8) return 8; // Len + ptr
+	else if (type == EBuf || type == EBufC)
+		{
+		TInt len = (*(TInt32 const*)aHeaderPtr) & 0xfffffff;
+		if (len > aMaxLen || (type == 0 && len == 0)) return 0;
+		// Take a stab at whether it's a 16-bit descriptor
+		TInt wideness = 1;
+		TInt bufOffset = (type == EBuf ? 8 : 4);
+		TUint16 const* wptr = (TUint16 const*)(aHeaderPtr + bufOffset);
+		if (len > 4 && wptr[0] < 256 && wptr[1] < 256) wideness = 2;
+		return bufOffset + len * wideness; // Add 4 so the header itself is included in the calculation
+		}
+	else
+		{
+		return 0;
+		}
+	}
+
+void CCmdFdb::ShowBreakpointsL()
+	{
+	RBuf8 buf;
+	CleanupClosePushL(buf);
+	buf.CreateL(1024);
+	LeaveIfErr(iMemAccess.GetBreakpoints(buf), _L("Couldn't read breakpoint information"));
+	RMemoryAccess::TBreakpointInfo* bs = (RMemoryAccess::TBreakpointInfo*)buf.Ptr();
+	RLtkBuf desc;
+	desc.CreateL(256);
+	TInt count = buf.Length() / sizeof(RMemoryAccess::TBreakpointInfo);
+	if (count)
+		{
+		for (TInt i = 0; i < count; i++)
+			{
+			RMemoryAccess::TBreakpointInfo& b = bs[i];
+			Printf(_L("Breakpoint %d (thread id %u): "), b.iBreakpointId, b.iThreadId);
+			Write(LookupSymbol(b.iAddress));
+			TBool brackets = b.iFlags & (RMemoryAccess::TBreakpointInfo::EPending | b.iFlags & RMemoryAccess::TBreakpointInfo::EHardware) || !(b.iFlags & RMemoryAccess::TBreakpointInfo::EEnabled) || b.iCondition.HasConditions();
+			if (brackets) Write(_L(" ("));
+			desc.Zero();
+			if (b.iFlags & RMemoryAccess::TBreakpointInfo::EPending) desc.Append(_L("PENDING "));
+			if (!(b.iFlags & RMemoryAccess::TBreakpointInfo::EEnabled)) desc.Append(_L("DISABLED "));
+			if (b.iFlags & RMemoryAccess::TBreakpointInfo::EHardware) desc.Append(_L("HARDWARE "));
+			b.iCondition.Description(desc);
+			if (desc.Length() && desc[desc.Length()-1] == ' ') desc.SetLength(desc.Length()-1);
+			Write(desc);
+			if (brackets) Write(_L(")"));
+			Write(KCrLf);
+			}
+		}
+	else
+		{
+		Printf(_L("No breakpoints defined.\r\n"));
+		}
+	CleanupStack::PopAndDestroy(&buf);
+	}
+
+void CCmdFdb::CBreakpointNotifier::RunL()
+	{
+	if (iStatus.Int() < 0)
+		{
+		iCmd.PrintError(iStatus.Int(), _L("Error returned from NotifyBreakpoint"));
+		return;
+		}
+	
+	RMemoryAccess::TBreakpointNotification notif = iCmd.iBreakpointNotification;
+	iCmd.iMemAccess.NotifyBreakpoint(iCmd.iBreakpointNotificationPkg, iStatus);
+	SetActive();
+
+	iCmd.BreakpointHit(notif);
+	}
+
+void CCmdFdb::CBreakpointNotifier::DoCancel()
+	{
+	iCmd.iMemAccess.CancelNotifyBreakpoint();
+	}
+
+CCmdFdb::CBreakpointNotifier::CBreakpointNotifier(CCmdFdb& aCmd)
+: CActive(CActive::EPriorityStandard), iCmd(aCmd)
+	{
+	CActiveScheduler::Add(this);
+	iCmd.iMemAccess.NotifyBreakpoint(iCmd.iBreakpointNotificationPkg, iStatus);
+	SetActive();
+	}
+
+CCmdFdb::CBreakpointNotifier::~CBreakpointNotifier()
+	{
+	Cancel();
+	}
+
+void CCmdFdb::BreakpointHit(const RMemoryAccess::TBreakpointNotification& aNotif)
+	{
+	iLineEditor->RemovePromptAndUserInput();
+	Printf(_L("Breakpoint %d hit in thread %u: "), aNotif.iBreakpointId, aNotif.iThreadId);
+	Write(LookupSymbol(aNotif.iAddress));
+	Write(KCrLf);
+	if (iCurrent == NULL)
+		{
+		Printf(_L("(Attaching to thread %u)\r\n"), aNotif.iThreadId);
+		TRAP_IGNORE(AttachL(aNotif.iThreadId));
+		}
+	iLineEditor->ReinstatePromptAndUserInput();
+	}
+
+TInt CCmdFdb::BreakTest(TAny* /*aPtr*/)
+	{
+	//LtkUtils::Breakpoint();
+	LtkUtils::RawPrint(_L8("Breaktest has completed\r\n"));
+	return 5;
+	}
+
+TInt CCmdFdb::BreakTestLtk(TAny* /*aPtr*/)
+	{
+	LtkUtils::Breakpoint();
+	return 6;
+	}
+
+TInt CCmdFdb::BreakTestCond(TAny* /*aPtr*/)
+	{
+	CTrapCleanup* trap = CTrapCleanup::New();
+	TRAPD(err, User::Leave(-1)); // This shouldn't trigger the break
+	TRAP(err, User::Leave(-5)); // This should
+	delete trap;
+	return 0;
+	}
+
+void CCmdFdb::ClearAllBreakpointsL()
+	{
+	RBuf8 buf;
+	CleanupClosePushL(buf);
+	buf.CreateL(1024);
+	LeaveIfErr(iMemAccess.GetBreakpoints(buf), _L("Couldn't read breakpoint information"));
+	RMemoryAccess::TBreakpointInfo* bs = (RMemoryAccess::TBreakpointInfo*)buf.Ptr();
+	TInt count = buf.Length() / sizeof(RMemoryAccess::TBreakpointInfo);
+	for (TInt i = 0; i < count; i++)
+		{
+		RMemoryAccess::TBreakpointInfo& b = bs[i];
+		TInt err = iMemAccess.ClearBreakpoint(b.iBreakpointId);
+		if (err) PrintWarning(_L("Couldn't clear breakpoint %d, err=%d"), b.iBreakpointId, err);
+		}
+	CleanupStack::PopAndDestroy(&buf);
+	}
+
+void CCmdFdb::CheckForConditionL(TLex& aLex, RMemoryAccess::TPredicate& aCondition)
+	{
+	aLex.SkipSpace();
+	if (aLex.Eos()) return;
+	_LIT(KRegErr, "First argument in a conditional must be a register r0-r15");
+	if (aLex.Get() != 'r') LeaveIfErr(KErrArgument, KRegErr);
+	TInt reg;
+	LeaveIfErr(aLex.Val(reg), KRegErr);
+	if (reg < 0 || reg > 15) LeaveIfErr(KErrArgument, KRegErr);
+	RMemoryAccess::TPredicate::TOp op = RMemoryAccess::TPredicate::ENothing;
+	TUint opchar = aLex.Get();
+	switch (opchar)
+		{
+		case '<':
+			op = RMemoryAccess::TPredicate::ELt;
+			if (aLex.Peek() == '=')
+				{
+				op = RMemoryAccess::TPredicate::ELe;
+				aLex.Get();
+				}
+			break;
+		case '>':
+			op = RMemoryAccess::TPredicate::EGt;
+			if (aLex.Peek() == '=')
+				{
+				op = RMemoryAccess::TPredicate::EGe;
+				aLex.Get();
+				}
+			break;
+		case '!':
+			if (aLex.Get() != '=') LeaveIfErr(KErrArgument, _L("Unrecognised operand"));
+			op = RMemoryAccess::TPredicate::ENe;
+			break;
+		case '=':
+			op = RMemoryAccess::TPredicate::EEq;
+			if (aLex.Peek() == '=') aLex.Get(); // We allow == as well as =
+			break;
+		default:
+			LeaveIfErr(KErrArgument, _L("Unrecognised operand"));
+			break;
+		}
+	TInt val;
+	TInt err = LtkUtils::HexLex(aLex, (TUint&)val);
+	if (err)
+		{
+		// Try normal - this handles signed negative numbers, which HexLex doesn't afaik
+		err = aLex.Val(val);
+		}
+	LeaveIfErr(err, _L("Couldn't parse value"));
+	TBool signedCompare = ETrue;
+	if (aLex.Peek() == 'u' || aLex.Peek() == 'U')
+		{
+		aLex.Get();
+		signedCompare = EFalse;
+		}
+	if (signedCompare)
+		{
+		op = (RMemoryAccess::TPredicate::TOp)(op + 6); // ELt -> ESignedLt etc
+		//Printf(_L("Op=%d reg=%d val=%d\r\n"), op, reg, val);
+		}
+	//else Printf(_L("Op=%d reg=%d val=%uu\r\n"), op, reg, (TUint)val);
+	if (aLex.Peek() == ',')
+		{
+		// Eat comma
+		aLex.Get();
+		}
+	LeaveIfErr(aCondition.AddCondition(op, reg, (TUint32)val), _L("Couldn't add condition to TPredicate"));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fdb/fdb.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// fdb.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			fdb.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_FDB
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			fdb.cpp
+
+library			euser.lib
+library			iocli.lib
+library			ltkutils.lib
+library			lineeditor.lib
+library			efsrv.lib
+library			bafl.lib
+
+epocheapsize	4096 0xA00000 // 10MB - to handle really big map files
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(fed.iby)
+fed.inf						\epoc32\fshell\documentation\fshell\inf_files\fed.inf
+fed.cif						z:\resource\cif\fshell\fed.cif
+
+PRJ_MMPFILES
+fed.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/group/fed.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,68 @@
+# fed.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fed
+
+==argument filename file optional multiple
+
+File or files to open. If not specified, opens an untitled document.
+
+==option int w tab-width TAB_WIDTH
+
+Specify the tab width to use (defaults to 4 characters).
+
+==short-description
+
+Console text editor.
+
+==long-description
+
+Fed is a basic console text editor. Its interface is similar to pico/nano. It can handle ASCII, UTF-8 and UTF-16 format files, different line endings, very large files, copy and paste, and opening multiple files at once.
+
+The supported commands are given below. The control key is represented as a caret '^', so ^G means Control-G.
+
+=head1 Commands
+
+    ^L, F1  Get help
+    ^N      New document
+    ^O      Open document
+    ^S      Save document
+    ^A      Save as
+
+    ^U      Page up (alternative to PgUp key)
+    ^D      Page down (alternative to PgDn key)
+    ^T      Go to top of document
+    ^B      Go to bottom of document
+
+    ^F      Find text
+    ^K      Delete current line
+    ^G      Go to line
+    ^R, F5  Redraw the screen
+    ^X      Cut (see below)
+    ^C      Copy (see below)
+    ^V      Paste
+
+    ^P, F2  Switch to Previous view
+    ^], F3  Switch to Next view
+    ^W, Esc Close current doc
+    ^Q      Quit and close all docs
+
+=head1 Clipboard support
+
+The standard Symbian clipboard is supported. You can use ^V to paste into the frontmost document. Cut and copy are two-stage operations, because of the limitations of the console:
+
+To begin a cut/copy operation, press ^X or ^C. Then move the cursor to the other end of the selection you want to make, and press ^X/^C again to confirm the cut/copy operation.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/group/fed.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// fed.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			fed.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_FED
+CAPABILITY		FSHELL_CAP_MMP_NORMAL
+
+USERINCLUDE		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+SOURCEPATH		..\src
+SOURCE			fed.cpp textview.cpp lrtextview.cpp cmdwindow.cpp screenmngr.cpp filebuffer.cpp
+SOURCE			bufferbase.cpp
+//SOURCE		main.cpp
+SOURCE			mainfshell.cpp
+
+LIBRARY			euser.lib
+LIBRARY			bafl.lib
+LIBRARY			efsrv.lib
+LIBRARY			charconv.lib
+LIBRARY			lineeditor.lib
+LIBRARY			iocli.lib
+LIBRARY			ltkutils.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/bufferbase.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,132 @@
+// bufferbase.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef BUFFERBASE_H_
+#define BUFFERBASE_H_
+
+#include <e32base.h>
+
+#include "common.h"
+
+enum TEncodingType
+	{
+	EEncodingUnknown,
+	EEncodingNarrow,
+	EEncodingUtf8,
+	EEncodingUtf16LE,
+	EEncodingUtf16BE,
+#ifdef __BIG_ENDIAN__ // I know Symbian doesn't actually define the endian macros (afaics) but if they do, we'll do the right thing(TM)
+	EEncodingUtf16Native = EEncodingUtf16BE,
+	EEncodingUtf16Switched = EEncodingUtf16LE,
+#else
+	// Assume little-endian unless specifically told otherwise
+	EEncodingUtf16Native = EEncodingUtf16LE,
+	EEncodingUtf16Switched = EEncodingUtf16BE,
+#endif
+	};
+
+enum TDelimiterType
+	{
+	EDelimNotYetKnown = 0,
+	EDelimLF, // Unix
+	EDelimCRLF, // DOS
+	EDelimCR, // old school mac
+	EDelimUnicode, // KUnicodeLineBreak - really doubt we'll see many of these!
+	};
+
+class CFileBlock;
+
+//Parent class for all memory buffers which can be used by appropriate views to read/write data and show it on the screen
+class CFedBufferBase : public CActive, public MSharedCacheProvider
+{
+protected:
+	CFedBufferBase();
+
+public:
+	TInt RefCount() const;
+	void PushL(); // Pushes a cleanup stack item that does a DecRef()
+	void IncRef();
+	TInt DecRef();
+	~CFedBufferBase();
+
+public: // From MSharedCacheProvider
+	TInt RegisterClient(MSharedCacheClient& aClient, TPtrC& aDes, TRange& aRange, TInt& aRangeStartLineNumber);
+	void UnregisterClient(MSharedCacheClient& aClient);
+
+public: // CActive (noops in this class, override if you actually use the CActive-ness
+	void DoCancel();
+	void RunL();
+
+public:
+	virtual const TDesC& Title() const = 0;
+	virtual TBool Modified() const;
+	virtual TBool Editable() const;
+	virtual TDelimiterType DelimiterType() const = 0;
+	virtual TEncodingType Encoding() const = 0;
+	virtual TBool IsOpen() const;
+
+	virtual TInt GetData(MSharedCacheClient& aClient, TInt aDocumentPosition) = 0; // "Get me the block containing aDocumentPosition".
+	virtual TInt SeekFromOffset(MSharedCacheClient& aClient, TInt aOffset, TInt aNumLinesFromOffset, TInt aLineLength) = 0; 
+	virtual TBool DocumentPositionIsEof(TInt aDocumentPosition) const = 0; // The block containing aDocumentPosition MUST have already have been loaded (otherwise we could not guarantee const-ness)
+	virtual TInt Find(TInt aStartingPosition, const TDesC& aSearchString, TBool aBackwards) = 0;
+
+	virtual void InsertTextL(TInt aDocumentPosition, const TDesC& aText);
+	virtual void DeleteTextL(TRange aRange);
+	virtual void SaveL(const TDesC& aName, TBool aReplace);
+
+protected:
+	TInt FindClientRequest(MSharedCacheClient& aClient);
+
+	class TClientRequest
+		{
+	public:
+		TClientRequest(MSharedCacheClient* aClient, TPtrC& aDes, TRange& aRange, TInt& aRangeStartLineNumber)
+			: iClient(aClient), iDes(aDes), iRange(aRange), iLastRequestedBlock(NULL), iRangeStartLineNumber(aRangeStartLineNumber)
+			{}
+	public:
+		MSharedCacheClient* iClient;
+		TPtrC& iDes;
+		TRange& iRange; // iRange is the document range for whatever's in iDes (used for something else during seeking)
+		CFileBlock* iLastRequestedBlock;
+		TInt& iRangeStartLineNumber;
+		};
+
+private:
+	TInt iRefCount;
+protected:
+	RArray<TClientRequest> iClientRequests;
+
+};
+
+class CConstDataBuffer : public CFedBufferBase
+	{
+public:
+	CConstDataBuffer(const TDesC& aTitle, const TDesC& aText);
+	CConstDataBuffer(const TDesC& aTitle, HBufC* aTextPtr);
+	~CConstDataBuffer();
+
+	const TDesC& Title() const;
+	TDelimiterType DelimiterType() const;
+	TEncodingType Encoding() const;
+
+	TInt GetData(MSharedCacheClient& aClient, TInt aDocumentPosition);
+	TInt SeekFromOffset(MSharedCacheClient& aClient, TInt aOffset, TInt aNumLinesFromOffset, TInt aLineLength); 
+	TBool DocumentPositionIsEof(TInt aDocumentPosition) const;
+	TInt Find(TInt aStartingPosition, const TDesC& aSearchString, TBool aBackwards);
+
+private:
+	const TDesC& iTitle;
+	TPtrC iText;
+	HBufC* iOwnedTextPtr;
+	};
+
+#endif /*BUFFERBASE_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/cmdwindow.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,99 @@
+// cmdwindow.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef CMDWINDOW_H_
+#define CMDWINDOW_H_
+
+#include <e32base.h>
+#include "common.h"
+#include <fshell/cconsolebase_writer.h>
+#include <fshell/line_editor.h>
+
+class CColorConsoleBase;
+class TPoint;
+class RFs;
+class CLineEditor;
+class CDesC16Array;
+
+/*
+ The purpose of this class is to handle so-called command window - a piece of of screen where different views can write their
+ problems, query the user, etc. In general the command window is only one-line in height, but if it is necessary then it is
+ possible to make the command window bigger. One can imagine that the user wants to open a new file and the editor allows
+ to browse the directory and use auto-completion for specifying which file should be opened. That could be much better done
+ if the command window was bigger than one line in height. To resize the command window CScreenManager::ResizeCommandWindowL
+ should be called, which will first ensure that all open views are resized as well.
+ 
+ The reason why there is a special class and views don't access the command window directly, is that at different times
+ different classes would like to show something on the screen. For example when user wants to close an unsaved file then
+ only a particular buffer (CFedBufferBase) would know it and should be able to query an user. Similarly when User enters
+ an invalid char, or a combination of chars which make a complicated command, a particular View should be able to show a
+ message or a text explaining the complicated command (or even the just entered command keys, like in emacs). Similarly
+ when User is opening a new file and we don't know what is its type then we don't know which View should be used,
+ and in that case DCommandWindow could have a function to allow the user browsing and selecting the required file.
+
+ DCommandWindow is not responsible for controlling which class has access to the command window, it is only responsible
+ for writing chars on the command window and holds some common function which use the command window (i.e. browsing for
+ a new file). The access, which class should be allowed to access the command window, is controlled by CFed and
+ CRequestHandler (which receives requests to access the command window from particular classes inheriting the
+ MCommandWindowClient interface).
+*/
+class CCommandWindow : public CBase, public MConsoleProvider, public MLineEditorObserver, public MLineCompleter
+	{
+public:
+	static CCommandWindow* NewL(RFs& aFs, CColorConsoleBase& aConsole);
+	static CCommandWindow* NewL(RFs& aFs, CConsoleBase& aConsole);
+	~CCommandWindow();
+
+	//Sets the window which the command window can use
+	void SetWindow(const TWindow& aWindow) {iWindow = aWindow;}
+
+	CConsoleBase& Console();
+	CColorConsoleBase* ColorConsole();
+	void WriteStatus(const TDesC& aNameToTruncate, TRefByValue<const TDesC> aFmt, ...);
+	void InfoPrint(TRefByValue<const TDesC> aFmt, ...);
+	TKeyCode Query(const TDesC& aPrompt, const TDesC& aValidKeys);
+	TBool QueryFilename(const TDesC& aPrompt, TFileName& aFileName);
+	TBool QueryText(const TDesC& aPrompt, TDes& aText);
+	RFs& Fs();
+
+private:
+	CCommandWindow(RFs& aFs, CConsoleBase& aConsole);
+	CCommandWindow(RFs& aFs, CColorConsoleBase& aConsole);
+	void ConstructL();
+	void DoWriteLine(const TDesC& aLine, TInt aHighlightStart=0, TInt aHighlightLength=0);
+	static TInt DismissInfoPrint(TAny* aSelf);
+	TBool DoQueryText(const TDesC& aPrompt, TDes& aText);
+
+private: // Line editor stuff
+	void LeoHandleLine(const TDesC& aLine);
+	void LcCompleteLineL(TConsoleLine& aLine, const TChar& aEscapeChar);
+
+	void SuggestDrivesL(CDesC16Array* aSuggestions);
+	void CompleteL(TConsoleLine& aLine, const CDesC16Array& aPossibilities, const TDesC* aPrefix, const TDesC* aSuffix);
+
+
+private:
+	RFs& iFs;
+	CConsoleBase& iConsole;
+	CColorConsoleBase* iColorConsole;
+	TWindow iWindow;
+	TBuf<256> iLastStatus;
+	TBuf<256> iQuery;
+	CPeriodic* iInfoPrintDismisser;
+	CLineEditor* iGeneralLineEditor;
+	CLineEditor* iFileNameLineEditor; // Have different editors because they have different histories
+	CLineEditor* iLineEditor; // The current line editor (one of the above). Not owned.
+	TConsoleBaseAdaptor iConsoleAdapter; // Needed by line editor
+	TBool iFinished;
+	TDes* iResultForQuery;
+	};
+
+#endif /*CMDWINDOW_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/common.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,171 @@
+// common.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef COMMON_H_
+#define COMMON_H_
+
+#include <e32std.h>
+#include <e32def.h>
+#include <e32cmn.h>
+#include <e32keys.h>
+
+#ifdef ASSERT
+#undef ASSERT
+#endif
+#define ASSERT(x) __ASSERT_ALWAYS(x, AssertionFail(#x, __FILE__, __LINE__))
+void AssertionFail(const char* aAssertion, const char* aFile, TInt aLine);
+
+#if defined(_DEBUG)
+#define ASSERT_DEBUG(c,p) ASSERT(c)
+#else
+#define ASSERT_DEBUG(c,p)
+#endif
+
+#define CTRL(x) ((x)-'a'+1)
+
+class DCommandWindow;
+
+class TWindow
+{
+public:
+	TWindow()
+		: iX(0), iY(0), iWidth(0), iHeight(0) {}
+	TWindow(TInt aPosX, TInt aPosY, TInt aWidth, TInt aHeight)
+		: iX(aPosX), iY(aPosY), iWidth(aWidth), iHeight(aHeight) {}
+
+	TBool operator==(const TWindow& aWindow) const
+		{return iX == aWindow.iX && iY == aWindow.iY && iWidth == aWindow.iWidth && iHeight == aWindow.iHeight;}
+
+	TPoint Relocate(const TPoint& aPos) const
+		{return TPoint(iX + aPos.iX, iY + aPos.iY);}
+
+	TInt NextX() const {return iX + iWidth;}
+	TInt NextY() const {return iY + iHeight;}
+
+	TPoint Origin() const { return TPoint(iX, iY); }
+
+	TInt iX;
+	TInt iY;
+	TInt iWidth;
+	TInt iHeight;
+};
+
+//Overloaded by a class which can draw on the console
+class MViewController
+{
+public:
+	/*
+	 Activate the View and set the new position and size of the window (which may be not changed).
+	 The window is visible so only the difference between the old and the new window has to be redrawn.
+	 Used when the window needs to be resized or moved.*/
+	virtual void ResizeL(const TWindow& aWindow) = 0;
+	/*
+	 Activate the View and set the new position and size of the window (which may be not changed).
+	 The View is not visible so it has to redraw the whole window.
+	 Used when switching views visible in the same window.*/
+	virtual void RedrawL(const TWindow& aWindow) = 0;
+	/*
+	This view must stop drawing on the console, however It can still process data in the background.*/
+	virtual void DeactivateL() = 0;
+};
+
+//Overloaded by a class which uses a memory cache shared by another class (i.e. by MShareCacheProvider)
+class MSharedCacheClient
+{
+	//Gives the class, which owns the buffer, a chance to complete all writings using data in the buffer
+	virtual void InvalidateBuffer(TRequestStatus& aStatus) = 0;
+};
+
+class TRange;
+
+/*
+ Overloaded by a class which provides shared access to its memory cache. The MSharedCacheClient class, which
+ needs access to the memory cache provided by this class, supplies TPtrC8 descriptor pointer, which is being
+ set to point to the existing data loaded to the memory cache and maintained by this class.
+*/
+class MSharedCacheProvider
+	{
+	//Called to add a new client to this file buffer
+	virtual TInt RegisterClient(MSharedCacheClient& aClient, TPtrC& aDes, TRange& aRange, TInt& aRangeStartLineNumber) = 0;
+	virtual void UnregisterClient(MSharedCacheClient& aClient) = 0;
+	};
+
+//Overloaded by a class which can receive key input from the user
+class MKeyConsumer
+{
+public:
+	//Returns EFalse if the key wasn't consumed
+	virtual TBool ConsumeKeyL(const TKeyCode& aCode) = 0;
+};
+
+//Overloaded by a class which can defer closing the application
+class MDeferredClose
+{
+public:
+	/*
+	 Called when the object is about to be closed, gives a chance to save changed data.
+	 If the object can be closed immediately it should return ETrue, otherwise EFalse.
+	 If any data or info should be shown to the user then a request should be registered with MRequestHandler*/
+	virtual TBool TryCloseL() = 0;
+};
+
+class CConsoleBase;
+class CColorConsoleBase;
+class RFs;
+
+class MConsoleProvider
+	{
+public:
+	virtual CConsoleBase& Console() = 0;
+	virtual CColorConsoleBase* ColorConsole() = 0;
+	virtual RFs& Fs() = 0;
+	virtual void WriteStatus(const TDesC& aNameToTruncate, TRefByValue<const TDesC> aFmt, ...) = 0;
+	virtual void InfoPrint(TRefByValue<const TDesC> aFmt, ...) = 0;
+	virtual TKeyCode Query(const TDesC& aPrompt, const TDesC& aValidKeys) = 0;
+	virtual TBool QueryFilename(const TDesC& aPrompt, TFileName& aFileName) = 0;
+	virtual TBool QueryText(const TDesC& aPrompt, TDes& aText) = 0;
+	};
+
+// General helper class, suprised we don't have anything else suitable...
+class TRange
+	{
+public:
+	inline TRange() : iLocation(0), iLength(0) {}
+	inline TRange(TInt aLocation, TInt aLength)
+		: iLocation(aLocation), iLength(aLength)
+		{}
+		
+	inline TInt Max() const
+		{
+		return iLocation + iLength;
+		}
+
+	inline TBool Contains(TInt aLocation) const
+		{
+		return aLocation >= iLocation && aLocation < Max();
+		}
+	inline void Intersect(const TRange& aRange)
+		{
+		TInt end = Min(this->Max(), aRange.Max());
+		iLocation = ::Max(iLocation, aRange.iLocation); // Have to use :: to say "look at global namespace implementation of Max()"
+		iLength = end - iLocation;
+		}
+public:
+	TInt iLocation;
+	TInt iLength;
+	};
+
+extern TInt KConsoleWidthCorrection;
+extern TInt KConsoleHeightCorrection;
+TInt TabWidth();
+void ShowHelpL();
+
+#endif /*COMMON_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/fed.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,91 @@
+// fed.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FED_H_
+#define FED_H_
+
+#include <e32base.h>
+#include <f32file.h>
+
+#include "screenmngr.h"
+#include "cmdwindow.h"
+
+class CColorConsoleBase;
+class CFedBufferBase;
+class CFedViewBase;
+class CDesC16Array;
+class CCnvCharacterSetConverter;
+
+class CFed : public CActive
+{
+public:
+	static CFed* NewL(CColorConsoleBase& aConsole, RFs& aFs);
+	static CFed* NewL(CConsoleBase& aConsole, RFs& aFs);
+	~CFed();
+
+	//Main entrance to the editor
+	void StartL(CDesC16Array* aFiles); // Takes ownership of aFiles immediately
+
+	void RedrawEverythingL();
+	void ShowHelpL(HBufC* aHelpText);
+
+public:
+	//CActive
+	void DoCancel();
+	void RunL();
+	TInt RunError(TInt aError);
+
+private:
+	CFed(CColorConsoleBase& aConsole, RFs& aFs);
+	CFed(CConsoleBase& aConsole, RFs& aFs);
+	void ConstructL();
+	//Construct all necessary views as specified in the command line
+	void CreateViewsL(CDesC16Array* aFiles);
+	//Some standard commands which need to be handled in the CFed class
+	enum TCmdType
+		{
+		ECmdNone,
+		ECmdHelp,
+		ECmdPrevView,
+		ECmdNextView,
+		ECmdNewDocument,
+		ECmdCloseCurrent,
+		ECmdCloseAll,
+		ECmdOpenDocument,
+		ECmdRefresh,
+		};
+	//Main function processing keys which should catch all commands related to the whole editor, not to any particular view
+	TCmdType ProcessKeyL(const TKeyCode& aCode);
+	//Execute commands returned by ProcessKeyL
+	TBool ExecuteCommandL(TCmdType aCmd);
+
+	//Closes the view which is currently active
+	TBool CloseCurrentViewL();
+	//Closes all views, will cause the program to close only if special char has been pressed (EKeyEscape)
+	void CloseAllViewsL();
+	//Removes the view from the array of views
+	void DeleteView();
+	void NewViewL(const TDesC& aFileName, TBool aPromptOnNonexistantName=EFalse);
+	void OpenDocumentL();
+
+private:
+	RFs& iFs;
+	CConsoleBase& iConsole;
+	CColorConsoleBase* iColorConsole;
+	CScreenManager iScreenMngr;
+	CCommandWindow* iCmdWindow;
+
+	RArray<CFedViewBase*> iViewArray;
+	TInt iViewIdx;
+	CCnvCharacterSetConverter* iCharconv; // Shared between CFileBuffers, for doing UTF-8 conversion. May be null if charconv isn't available
+};
+
+#endif /*FED_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/filebuffer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,165 @@
+// filebuffer.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FILEBUFFER_H_
+#define FILEBUFFER_H_
+
+#include <f32file.h>
+#include <Babitflags.h>
+#include "bufferbase.h"
+
+class CFileBlock;
+class CCnvCharacterSetConverter;
+
+_LIT8(KBigEndianBom,    "\xFE\xFF");
+_LIT8(KLittleEndianBom, "\xFF\xFE");
+_LIT8(KUtf8Bom,         "\xEF\xBB\xBF");
+
+#ifdef __BIG_ENDIAN__
+static const TDesC8& KNativeBom(KBigEndianBom);
+#else
+static const TDesC8& KNativeBom(KLittleEndianBom);
+#endif
+
+/*
+ An efficient backing store for document data, that allows files larger than available memory to be shown.
+ Data is paged in and out of the store depending on what part of the document is being viewed. The
+ granularity of paging is the CFileBlock object, which can represent up to 64KB of on-disk data. Blocks that
+ have been modified are kept in memory until the file is saved, whereas unmodified blocks can be flushed
+ whenever it is required. We take care to ensure that UTF-8 and CRLF sequences are never split across blocks,
+ and that blocks are split if they become too large to page out (ie >64KB)
+
+ CFileBlock keeps some metadata about the block it represents in memory at all times - the extent and number of
+ lines in the block. This is so we can support efficient per-character and per-line seeking through the file
+ without having to page the whole thing into memory.
+
+ In principle CFileBuffer supports file sizes up to 2GB, but in practice the CFileBlock metadata will probably
+ fill the default 1MB heap after around 50-100MB.
+*/
+
+class CFileBuffer : public CFedBufferBase
+	{
+public:
+
+	static CFileBuffer* NewL(RFs& aFs, CCnvCharacterSetConverter* aCharconv, const TDesC& aName, TBool aAllowNonexistantName);
+	~CFileBuffer();
+
+protected:
+	CFileBuffer(RFs& aFs, CCnvCharacterSetConverter* aCharconv);
+	void ConstructL(const TDesC& aName, TBool aAllowNonexistantName);
+	void ConstructL();
+	void CommonConstructL();
+
+public:
+	const TDesC& Title() const;
+	TBool Modified() const;
+	TDelimiterType DelimiterType() const;
+	TEncodingType Encoding() const;
+	TBool Editable() const;
+	TBool IsOpen() const;
+
+	TInt GetData(MSharedCacheClient& aClient, TInt aDocumentPosition); // "Get me the block containing aDocumentPosition".
+	TInt SeekFromOffset(MSharedCacheClient& aClient, TInt aOffset, TInt aNumLinesFromOffset, TInt aLineLength); 
+	TBool DocumentPositionIsEof(TInt aDocumentPosition) const; // The block containing aDocumentPosition MUST have already have been loaded (otherwise we could not guarantee const-ness)
+
+	void InsertTextL(TInt aDocumentPosition, const TDesC& aText);
+	void DeleteTextL(TRange aRange);
+	void SaveL(const TDesC& aName, TBool aReplace);
+	TInt Find(TInt aStartingPosition, const TDesC& aSearchString, TBool aBackwards);
+
+protected:
+	static TInt CalculateCacheBufSize(TInt aFileSize);
+	void TidyCache(); // Calls UnloadBlockIfPossible on all blocks
+	void UnloadBlockIfPossible(CFileBlock* aBlock);
+	CFileBlock* FindBlockForDocumentPosition(TInt aPosition, TInt* aOffset, TInt* aLineCountToDocPos=NULL); // If aOffset isn't null, it is set to the offset from the block start to the specified document position. If aLineCountToDocPos is nonnull the line count to the offset is calculated (may load the block if necessary)
+	TInt LoadBlock(CFileBlock* aBlock);
+	static void DeleteTempFile(TAny* aSelf);
+	static void SetFinalNameToTemporary(TAny* aSelf);
+	TInt DoFindL(TInt aStartingPosition, const TDesC& aSearchString, TBool aBackwards);
+
+protected:
+	TDelimiterType iDelimType;
+	TEncodingType iEncoding;
+	RFs& iFs;
+	RFile iFile;
+	TInt iCacheBufSize;
+	TFileName iFinalName;
+	TFileName* iTempName; // Used during saving, if we're writing to a temporary.
+
+	CFileBlock* iFirstBlock;
+	CFileBlock* iCurrentBlock; // For a given (currently, unimportant) value of current
+	RBuf8 iNarrowBuf;
+	TBool iUnsaved;
+	CCnvCharacterSetConverter* iCharconv; // This wouldn't be needed if the exported version of CnvUtfConverter::ConvertToUnicodeFromUtf8 ACTUALLY WORKED
+	};
+
+class CFileBlock : public CBase
+	{
+public:
+	CFileBlock(TInt aFilePosition, TInt aBlockSize);
+	~CFileBlock();
+	void InsertAfterBlock(CFileBlock* aBlock);
+	CFileBlock* Next() const;
+	CFileBlock* Prev() const;
+	TInt BlockDidLoad(TEncodingType& aFileEncoding, TDelimiterType& aDelimType, const TDesC8& aData, CCnvCharacterSetConverter* aCharconvForUtf8Conversion);
+	TInt ConvertToEightBit(TEncodingType aEncoding, TDelimiterType aDelimeter, RBuf8& aResultBuf);
+	void FileHasBeenSaved(); // Only call on the first block of the file - it will update other blocks as needed
+	
+	/* Return the buffer position after the aTarget'th newline, or KErrNotFound.
+	 * On return, aTarget is set to the number of newlines actually read.
+	 * Pass in KMaxTInt as aTarget to count how many newlines in the buffer. (target passes back the resulting number read, the function returns KErrNotFound in this case because your 'target' of KMaxTInt was not reached)
+	 * Pass in negative target to count backwards from end of block
+	 * Pass in KMaxTInt as aSoftWrapLineLength if you don't want lines to soft wrap
+	 * If non-null, aDelimType is set to the first type of newline encountered in the block
+	 */
+	static TInt CountNewLines(const TDesC& aDes, TInt& aTarget, TInt aSoftWrapLineLength, TDelimiterType* aDelimType=NULL);
+	void Unload();
+
+	TBool IsLoaded() const; // Returns true if the block is in memory, ie if iData.Size() != 0.
+	TBool HasBeenLoaded() const; // Indicates that cached data (such as num newlines etc) is valid
+	TBool IsDirty() const; // Returns true if the block has been modified
+	const TDesC16& Text() const; // block must be loaded
+
+	void CalculateBlockPositions(TInt& aCharacterPos, TInt& aLineCount) const; // Requires iterating block list
+	TInt FilePosition() const; // Returns the on-disk location (in bytes) of this block (constant-time operation)
+	TInt BlockSize() const; // block size in bytes
+	TInt CharacterCount() const; // block must have been loaded, as knowing block size is not sufficient to calculate number of chars
+	TInt NewlineCount() const; // block must have been loaded
+	TInt CountNewLinesUpToOffset(TInt aOffset) const;
+
+	void InsertTextL(TInt aBlockOffset, const TDesC16& aText);
+	void DeleteText(TInt aPos, TInt aLen);
+
+private:
+	TInt TransferDataFromPreviousBlock(CFileBlock* aPrev, const TDesC8& aData);
+	TInt ReplaceAll(const TDesC& aFrom, const TDesC& aTo);
+	TInt SplitBufferAt(TInt aCharacterPosition); // Splits one buffer in to two
+
+private:
+	enum TFlags
+		{
+		EHasBeenLoaded = 0,
+		EDirty = 1,
+		EHaveCalculatedLineEndings = 2, // We can't use iNumLineEndings=-1 to indicate it's not valid because it's unsigned, and it's unsigned because we need every bit
+		};
+	TInt iFilePosition; // in bytes
+	TUint16 iBlockSize; // in bytes
+	TUint16 iNumCharacters; // Cached first time block is loaded. Will never be more than iBlockSize because one byte can never represent more than one character (in any encoding we support)
+	// We cache the number of line endings so that "Go to line" operations are fast, the correct block for a particular line can be calculated just by iterating the CFileBlocks
+	mutable TUint16 iNumLineEndings; // Number of line endings *in this block*. Mutable so NewlineCount can update it 
+	mutable TBitFlags16 iFlags; // Only the EHaveCalculatedLineEndings flag needs to be mutable but no avoiding it
+	
+	HBufC16* iData;
+	CFileBlock* iPrev;
+	CFileBlock* iNext;
+	};
+
+#endif /*FILEBUFFER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/lrtextview.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,121 @@
+// lrtextview.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef LRTEXTVIEW_H_
+#define LRTEXTVIEW_H_
+
+#include "textview.h"
+
+class CColorConsoleBase;
+class CLineData;
+
+//Main class reading/writing normal (not-unicode) text arranged left-to-right on the screen.
+class CLRTextView : public CTextView
+{
+public:
+	static CLRTextView* NewL(MConsoleProvider& aConsoleProvider, CFedBufferBase& aBuffer);
+	~CLRTextView();
+
+protected:
+	CLRTextView(MConsoleProvider& aConsoleProvider, CFedBufferBase& aBuffer);
+	void ConstructL();
+
+public:
+	//MDeferredClose
+	TBool TryCloseL();
+
+	//MKeyConsumer
+	TBool ConsumeKeyL(const TKeyCode& aCode);
+
+	//CTextView
+	void DoResizeL(const TWindow& aOldWindow);
+	void DoRedrawL();
+	void DoDrawL();
+
+protected:
+	void ValidateCursor();
+	void UpdateCursor(const TPoint& aNewPos);
+	void HandleControlChar();
+	void AppendChar(TUint16 aChar);
+	void WriteLine();
+	void WriteChars();
+	void GoToNextLine();
+	void WriteLineContinue();
+	void LineFinished();
+	TInt DocumentPosition() const;
+	void MoveCursor(TInt aX, TInt aY);
+	void InsertTextL(const TDesC& aText);
+	void DeleteTextL(TInt aNumChars);
+	void DeleteCurrentLineL();
+	void UpdateStatus();
+	TInt Save();
+	TInt SaveAs();
+	void HandleSaveResult(TInt aError, TBool aWasOpen, const TDesC& aName);
+	void GoToLine();
+	void GoToLine(TInt aLine);
+	void DoDrawL(TBool aUpdateCursorAndStatus); // Occasionally we want to do a draw without updating
+	void CenterDocPosOnScreen(TInt aDocumentPosition);
+	TPoint WindowLocationForDocumentPosition(TInt aDocPos) const; // Assuming the doc pos is on screen in an area that's been drawn
+	void RedrawFromPositionToEndOfLine(TInt aDocumentPosition, TInt aNumCharsInserted);
+	void Find();
+	void CopyOrCutL(TBool aCut);
+	void PasteL();
+	void CopyToClipboardL(const TDesC& aBuf);
+	HBufC* GetFromClipboardL();
+	void SetMark();
+	void CancelMark();
+	static TInt FlashMark(TAny* aSelf);
+	void DoFlashMark();
+	TBool MarkActive() const;
+	void UpdateDocumentPositionsStartingAtLine(TInt aLine, TInt aDelta);
+
+private:
+	CLineData* iLineData;
+	TInt iCurrentDrawDocIndex; // Used while drawing to construct iLineData document positions, has no meaning outside of there
+	TBool iLineIsErrorMessage;
+	TBuf<256> iFindText;
+	CPeriodic* iMarkFlasher;
+	TInt iMarkDocPos;
+	TBool iMarkShown;
+	TInt iOldNextLine; // Used to limit how much redrawing we need to do
+	TInt iOldNextLineDocPos; // Ditto
+	TInt iPredictedOldNextLineDocPosDelta; // Ditto
+	TBool* iRecursiveUpdateFlag; // For times when DoDrawL's aUpdateStatusAndCursor flag needs tracking through calls to RequestData
+};
+
+class CLineData : public CBase
+	{
+public:
+	void EnsureCapacityL(TInt aWidth, TInt aHeight);
+	TInt DocumentPosition(TInt aLine) const;
+	TInt FileLineNumber(TInt aLine) const;
+	TBool IsScreenPositionValid(TInt aLine, TInt aCol) const;
+	TInt LastValidPosition(TInt aLine) const;
+
+	void SetDocumentPositionForLine(TInt aLine, TInt aDocumentPosition);
+	void SetFileLineNumberForLine(TInt aLine, TInt aDocumentPosition);
+	void SetPositionIsValid(TInt aLine, TInt aCol, TBool aValid);
+	void LineFinishedAt(TInt aLine, TInt aCol);
+
+	~CLineData();
+
+private:
+	const TUint8& ByteForPos(TInt aLine, TInt aCol, TInt& aOffset) const;
+	TUint8& ByteForPos(TInt aLine, TInt aCol, TInt& aOffset);
+
+private:
+	TInt iLineLen;
+	TInt* iDocPosAndLine;
+	TUint8* iScreenIndexes;
+	};
+
+
+#endif /*LRTEXTVIEW_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/screenmngr.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+// screenmngr.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef SCREENMNGR_H_
+#define SCREENMNGR_H_
+
+#include "common.h"
+
+class MViewController;
+
+/*
+ Class responsible for arranging windows on the screen. For now it handles only one main window and one command window.
+ New windows can be added by calling AddViewL. The class should rearrange visible windows and resize appropriate views.
+ Many views can be shown in the same window - switching between visible views is done by calling AttachViewL. The class
+ automatically disables old views and activates new views. If more than one window is supported then there may be
+ another function necessary which attaches a provided view to a particular window, not just the default one.
+*/
+class CScreenManager : public CBase
+	{
+public:
+	//Returns the TWindow occupied by the command window
+	const TWindow& GetCommandWindow() {return iCmdWnd;}
+	//Sets new coordinates of the screen available to this screen manager
+	void ResizeScreenL(const TWindow& aWindow);
+	//Resizes all Views to make space (if possible) for the new size of the command window.
+	//Returns the new size of the command window.
+	const TWindow& ResizeCommandWindowL(TInt aHeight);
+	//Opens a new window and attaches the view provided to it. The new view becomes active.
+	void AddViewL(MViewController& aView);
+	//Attaches the provided view to the currently active window. The attached view becomes active.
+	void AttachViewL(MViewController& aView);
+
+	void RefreshScreenL();
+
+	void UnsetCurrentView();
+
+private:
+	TWindow iScreenWnd;
+	TWindow iCmdWnd;
+	TWindow iMainWnd;
+	MViewController* iCurrentView;
+	};
+
+#endif /*SCREENMNGR_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/textview.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,81 @@
+// textview.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef TEXTVIEW_H_
+#define TEXTVIEW_H_
+
+#include <e32base.h>
+
+#include "viewbase.h"
+
+class CColorConsoleBase;
+class CFileBuffer;
+
+/*
+ Main parent class for all views able to show any texts on the screen using data read/written from/to the universal
+ memory buffer CFileBuffer (unicode, left-to-right, right-to-left, up-to-down), etc.
+*/
+class CTextView : public CFedViewBase
+{
+protected:
+	CTextView(MConsoleProvider& aConsoleProvider, CFedBufferBase& aBuffer, TInt aPriority = CActive::EPriorityStandard);
+	void ConstructL();
+	~CTextView();
+
+public:
+	//CActive
+	void DoCancel();
+	void RunL();
+	TInt RunError(TInt aError);
+
+	void ResizeL(const TWindow& aWindow);
+	void RedrawL(const TWindow& aWindow);
+	void DeactivateL();
+
+	//MSharedCacheClient
+	void InvalidateBuffer(TRequestStatus& aStatus);
+
+	CFedBufferBase& Buffer();
+
+protected:
+	void RequestData(TBool aFromTheTop, TInt aOffset);
+	void SeekData(TInt aDocumentPosition, TInt aNumLines);
+	virtual void UpdateCursor(const TPoint& aNewPos);
+	virtual void ValidateCursor();
+	void ShowCursor();
+	void HideCursor();
+	void HandleDataLoadError(TInt aError);
+
+protected:
+	virtual void DoResizeL(const TWindow& aOldWindow) = 0;
+	virtual void DoRedrawL() = 0;
+	virtual void DoDrawL() = 0;
+
+private:
+	enum TState
+		{
+		EStateNone,
+		EStateGetData,
+		} iState;
+
+	//member variables to use by inheriting classes
+protected:
+	CFedBufferBase& iBuffer;
+	TPtrC16 iDes;		// This is set to whatever cache block is currently active	
+	TBool iActive;		// Whether the view is active and can draw on the screen or not
+	TPoint iCursor;		// Current position of cursor on the screen (in window coords, NOT console coords)
+	TPoint iDrawPoint;	// Current position of drawing new characters on the screen (in console coordinates)
+	RBuf iLine;			// Temp buffer for chars to be drawn on the screen
+	TRange iRange;		// Document range of last fetched data (iDes)
+	TInt iRangeStartLineNumber; // Line number for the first character of iRange
+};
+
+#endif /*TEXTVIEW_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/inc/viewbase.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+// viewbase.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef VIEWBASE_H_
+#define VIEWBASE_H_
+
+#include <e32base.h>
+
+#include "common.h"
+
+class CConsoleBase;
+class CFedBufferBase;
+
+//Main View class inherited by any views able to show data on the screen, either backed by a file buffer or not
+class CFedViewBase : public CActive, public MViewController, public MSharedCacheClient, public MDeferredClose, public MKeyConsumer
+{
+protected:
+	CFedViewBase(MConsoleProvider& aConsoleProvider, TInt aPriority = CActive::EPriorityStandard)
+		: CActive(aPriority), iConsoleProvider(aConsoleProvider), iConsole(aConsoleProvider.Console()) {}
+
+public:
+	void StoreWindow(const TWindow& aWindow) {iWindow = aWindow;}
+	virtual CFedBufferBase& Buffer() = 0;
+
+protected:
+	MConsoleProvider& iConsoleProvider;
+	CConsoleBase& iConsole;
+	TWindow iWindow;
+};
+
+#endif /*VIEWBASE_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/bufferbase.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,217 @@
+// bufferbase.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "bufferbase.h"
+#include "filebuffer.h" // for CFileBlock::CountNewLines
+
+CFedBufferBase::CFedBufferBase()
+	: CActive(EPriorityStandard), iRefCount(1)
+	{
+	}
+
+TInt CFedBufferBase::RefCount() const
+	{
+	return iRefCount;
+	}
+
+void CFedBufferBase::IncRef()
+	{
+	iRefCount++;
+	}
+
+TInt CFedBufferBase::DecRef()
+	{
+	iRefCount--;
+	TInt refCount = iRefCount;
+	if (refCount == 0) delete this; 
+	return refCount;
+	}
+
+void StaticDecRef(TAny* aPtr)
+	{
+	static_cast<CFedBufferBase*>(aPtr)->DecRef();
+	}
+
+void CFedBufferBase::PushL()
+	{
+	CleanupStack::PushL(TCleanupItem(&StaticDecRef, this));
+	}
+
+void CFedBufferBase::DoCancel()
+	{
+	ASSERT(EFalse);
+	}
+
+void CFedBufferBase::RunL()
+	{
+	ASSERT(EFalse);
+	}
+
+TInt CFedBufferBase::FindClientRequest(MSharedCacheClient& aClient)
+	{
+	TPtrC dummy;
+	TRange dummyRange;
+	TInt dummyLine;
+	return iClientRequests.FindInUnsignedKeyOrder(TClientRequest(&aClient, dummy, dummyRange, dummyLine));
+	}
+
+TInt CFedBufferBase::RegisterClient(MSharedCacheClient& aClient, TPtrC& aDes, TRange& aRange, TInt& aRangeStartLineNumber)
+	{
+	TInt err = iClientRequests.InsertInUnsignedKeyOrder(TClientRequest(&aClient, aDes, aRange, aRangeStartLineNumber));
+	return err;
+	}
+
+void CFedBufferBase::UnregisterClient(MSharedCacheClient& aClient)
+	{
+	TInt res = FindClientRequest(aClient);
+	if (res >= 0) iClientRequests.Remove(res);
+	}
+
+CFedBufferBase::~CFedBufferBase()
+	{
+	ASSERT(iRefCount == 0); // Otherwise someone has deleted us directly rather than going through the reference counting
+	iClientRequests.Reset();
+	}
+
+void CFedBufferBase::InsertTextL(TInt /*aDocumentPosition*/, const TDesC& /*aText*/)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+void CFedBufferBase::DeleteTextL(TRange /*aRange*/)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+void CFedBufferBase::SaveL(const TDesC& /*aNewName*/, TBool /*aReplace*/)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+TBool CFedBufferBase::Modified() const
+	{
+	return EFalse;
+	}
+
+TBool CFedBufferBase::Editable() const
+	{
+	return EFalse;
+	}
+
+TBool CFedBufferBase::IsOpen() const
+	{
+	return EFalse;
+	}
+
+///////
+
+CConstDataBuffer::CConstDataBuffer(const TDesC& aTitle, const TDesC& aText)
+: iTitle(aTitle), iText(aText)
+	{
+	}
+
+CConstDataBuffer::CConstDataBuffer(const TDesC& aTitle, HBufC* aTextPtr)
+	: iTitle(aTitle), iText(*aTextPtr), iOwnedTextPtr(aTextPtr)
+	{
+	}
+
+CConstDataBuffer::~CConstDataBuffer()
+	{
+	delete iOwnedTextPtr;
+	}
+
+const TDesC& CConstDataBuffer::Title() const
+	{
+	return iTitle;
+	}
+
+TDelimiterType CConstDataBuffer::DelimiterType() const
+	{
+	return EDelimLF;
+	}
+
+TEncodingType CConstDataBuffer::Encoding() const
+	{
+	return EEncodingUtf16Native;
+	}
+
+TInt CConstDataBuffer::GetData(MSharedCacheClient& aClient, TInt aDocumentPosition)
+	{
+	TInt idx = FindClientRequest(aClient);
+	if (idx < 0)
+		{
+		return idx;
+		}
+
+	TClientRequest& client = iClientRequests[idx];
+	ASSERT(aDocumentPosition >= 0);
+
+	client.iRange = TRange(aDocumentPosition, iText.Length()-aDocumentPosition);
+	client.iDes.Set(iText.Mid(aDocumentPosition));
+	TInt lines = KMaxTInt;
+	CFileBlock::CountNewLines(iText.Left(aDocumentPosition), lines, KMaxTInt);
+	client.iRangeStartLineNumber = lines;
+	return KErrNone;
+	}
+
+TInt CConstDataBuffer::SeekFromOffset(MSharedCacheClient& aClient, TInt aOffset, TInt aNumLinesFromOffset, TInt aLineLength)
+	{
+	TInt idx = FindClientRequest(aClient);
+	if (idx < 0)
+		{
+		return idx;
+		}
+	TClientRequest& client = iClientRequests[idx];
+
+	TInt lineDelta = aNumLinesFromOffset;
+	TInt bufPos = -1;
+	if (lineDelta > 0)
+		{
+		TPtrC ptr = iText.Mid(aOffset);
+		bufPos = CFileBlock::CountNewLines(ptr, lineDelta, aLineLength);
+		if (bufPos == KErrNotFound)
+			{
+			aOffset = 0;
+			ptr.Set(iText);
+			lineDelta = -1;
+			bufPos = CFileBlock::CountNewLines(ptr, lineDelta, aLineLength);
+			}
+		}
+	else
+		{
+		lineDelta--;
+		TPtrC ptr = iText.Left(aOffset);
+		aOffset = 0;
+		bufPos = CFileBlock::CountNewLines(ptr, lineDelta, aLineLength);
+		if (bufPos == KErrNotFound) bufPos = 0;
+		}
+	
+
+	client.iDes.Set(iText.Mid(bufPos+aOffset));
+	client.iRange = TRange(bufPos + aOffset, client.iDes.Length());
+	TInt lines = KMaxTInt;
+	CFileBlock::CountNewLines(iText.Left(bufPos + aOffset), lines, KMaxTInt);
+	client.iRangeStartLineNumber = lines;
+	return KErrNone;
+	}
+
+TBool CConstDataBuffer::DocumentPositionIsEof(TInt aDocumentPosition) const
+	{
+	return (aDocumentPosition == iText.Length());
+	}
+
+TInt CConstDataBuffer::Find(TInt aStartingPosition, const TDesC& aSearchString, TBool aBackwards)
+	{
+	ASSERT(!aBackwards);
+	TInt res = iText.Mid(aStartingPosition).Find(aSearchString);
+	if (res >= 0) res += aStartingPosition;
+	return res;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/cmdwindow.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,432 @@
+// cmdwindow.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "cmdwindow.h"
+#include <e32cons.h>
+#include <BADESCA.H>
+
+const TInt KInfoPrintTime = 2500000; // 2.5 seconds
+
+CCommandWindow* CCommandWindow::NewL(RFs& aFs, CColorConsoleBase& aConsole)
+	{
+	CCommandWindow* self = new(ELeave) CCommandWindow(aFs, aConsole);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CCommandWindow* CCommandWindow::NewL(RFs& aFs, CConsoleBase& aConsole)
+	{
+	CCommandWindow* self = new(ELeave) CCommandWindow(aFs, aConsole);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CCommandWindow::CCommandWindow(RFs& aFs, CConsoleBase& aConsole)
+	: iFs(aFs), iConsole(aConsole), iColorConsole(NULL), iConsoleAdapter(aConsole)
+	{}
+
+CCommandWindow::CCommandWindow(RFs& aFs, CColorConsoleBase& aConsole)
+	: iFs(aFs), iConsole(aConsole), iColorConsole(&aConsole), iConsoleAdapter(aConsole)
+	{}
+
+void CCommandWindow::ConstructL()
+	{
+	iInfoPrintDismisser = CPeriodic::NewL(CActive::EPriorityStandard);
+	TBuf<64> buf;
+
+	User::LeaveIfError(iFs.PrivatePath(buf));
+	buf.Insert(0, _L("c:"));
+	buf.Append(_L("fed_filehistory"));
+	iFileNameLineEditor = CLineEditor::NewL(iFs, iConsoleAdapter, *this, *this, buf);
+
+	User::LeaveIfError(iFs.PrivatePath(buf));
+	buf.Insert(0, _L("c:"));
+	buf.Append(_L("fed_generalhistory"));
+	iGeneralLineEditor = CLineEditor::NewL(iFs, iConsoleAdapter, *this, *this, buf);
+	}
+
+CCommandWindow::~CCommandWindow()
+	{
+	if (iInfoPrintDismisser) iInfoPrintDismisser->Cancel();
+	delete iInfoPrintDismisser;
+	delete iGeneralLineEditor;
+	delete iFileNameLineEditor;
+	}
+
+CConsoleBase& CCommandWindow::Console()
+	{
+	return iConsole;
+	}
+
+CColorConsoleBase* CCommandWindow::ColorConsole()
+	{
+	return iColorConsole;
+	}
+
+class TOverflow16 : public TDes16Overflow
+	{
+public:
+	void Overflow(TDes16 &) {}
+	};
+
+void CCommandWindow::WriteStatus(const TDesC& aNameToTruncate, TRefByValue<const TDesC> aFmt, ...)
+	{
+	TDes& buf = iLastStatus;
+	buf.Zero();
+	VA_LIST args;
+	VA_START(args, aFmt);
+	TOverflow16 overflow;
+	buf.AppendFormatList(aFmt, args, &overflow);
+	VA_END(args);
+
+	const TInt availWidth = iWindow.iWidth - 1;
+	buf.SetLength(Min(buf.Length(), availWidth));
+	TInt widthForName = availWidth - buf.Length();
+	buf.Insert(0, aNameToTruncate.Right(widthForName));
+	if (buf.Length() < iWindow.iWidth) buf.Append(' ');
+	buf.AppendFill('-', iWindow.iWidth - buf.Length() - 1); // Don't fill to edge of screen, that causes a wrap
+
+	DoWriteLine(buf);
+	}
+
+void CCommandWindow::DoWriteLine(const TDesC& aLine, TInt aHighlightStart, TInt aHighlightLength)
+	{
+	TPoint cursor = iConsole.CursorPos();
+	iConsole.SetCursorHeight(0);
+	iConsole.SetPos(iWindow.iX, iWindow.iY);
+	if (aHighlightLength && ColorConsole())
+		{
+		TPtrC left = aLine.Left(aHighlightStart);
+		TPtrC mid = aLine.Mid(aHighlightStart, aHighlightLength);
+		TPtrC right = aLine.Mid(aHighlightStart + aHighlightLength);
+		ColorConsole()->Write(left);
+		ColorConsole()->SetTextAttribute(ETextAttributeInverse);
+		ColorConsole()->Write(mid);
+		ColorConsole()->SetTextAttribute(ETextAttributeNormal);
+		ColorConsole()->Write(right);
+		}
+	else
+		{
+		iConsole.Write(aLine);
+		}
+	iConsole.SetCursorPosAbs(cursor);
+	iConsole.SetCursorHeight(20);
+	}
+
+void CCommandWindow::InfoPrint(TRefByValue<const TDesC> aFmt, ...)
+	{
+	iInfoPrintDismisser->Cancel(); // If there's already a print onscreen, we bin it straight away (same as how User::InfoPrint works)
+	TBuf<256> buf;
+	VA_LIST args;
+	VA_START(args, aFmt);
+	TOverflow16 overflow;
+	buf.AppendFormatList(aFmt, args, &overflow);
+	VA_END(args);
+
+	buf.SetLength(Min(buf.Length(), iWindow.iWidth-5)); // 4 for -[ and ]-, and one more to avoid hitting the final column
+	TInt highlightLen = buf.Length() + 2; // Highlight the [] as well
+	buf.Insert(0, _L("-["));
+	buf.Append(_L("]-"));
+	TInt fillWidth = iWindow.iWidth - buf.Length() - 1;
+	TInt left = fillWidth / 2;
+	TInt highlightStart = left+1;
+	TInt right = fillWidth - left;
+	while(left--)
+		{
+		buf.Insert(0, _L("-"));
+		}
+	buf.AppendFill('-', right);
+	DoWriteLine(buf, highlightStart, highlightLen);
+	iInfoPrintDismisser->Start(KInfoPrintTime, KInfoPrintTime, TCallBack(&DismissInfoPrint, this));
+	}
+
+TInt CCommandWindow::DismissInfoPrint(TAny* aSelf)
+	{
+	CCommandWindow* self = static_cast<CCommandWindow*>(aSelf);
+	// Restore previous status
+	self->DoWriteLine(self->iLastStatus);
+	self->iInfoPrintDismisser->Cancel();
+	return 0;
+	}
+
+TKeyCode CCommandWindow::Query(const TDesC& aPrompt, const TDesC& aValidKeys)
+	{
+	TPoint cursor = iConsole.CursorPos();
+	iQuery = aPrompt;
+	iQuery.Append(_L("[ ]"));
+	iQuery.AppendFill('-', iQuery.MaxLength() - iQuery.Length());
+	iQuery.SetLength(iWindow.iWidth - 1);
+	DoWriteLine(iQuery);
+	iConsole.SetPos(iWindow.iX + aPrompt.Length()+1, iWindow.iY);
+	iConsole.SetCursorHeight(20);
+	TKeyCode res = EKeyNull;
+	while (aValidKeys.Locate(res) == KErrNotFound)
+		{
+		res = iConsole.Getch();
+		}
+	// Print the key that the user entered, between the square brackets
+	if (TChar(res).IsPrint())
+		{
+		TBuf<1> chbuf;
+		chbuf.Append(res);
+		iConsole.Write(chbuf);
+		}
+	iConsole.SetCursorPosAbs(cursor);
+	// Async clear the query (in case we are called repeatedly)
+	iInfoPrintDismisser->Cancel();
+	iInfoPrintDismisser->Start(0, KInfoPrintTime, TCallBack(&DismissInfoPrint, this));
+	return res;
+	}
+
+TBool CCommandWindow::QueryText(const TDesC& aPrompt, TDes& aText)
+	{
+	iLineEditor = iGeneralLineEditor;
+	return DoQueryText(aPrompt, aText);
+	}
+
+TBool CCommandWindow::QueryFilename(const TDesC& aPrompt, TFileName& aFileName)
+	{
+	iLineEditor = iFileNameLineEditor;
+	TBool res = DoQueryText(aPrompt, aFileName);
+	if (res)
+		{
+		IoUtils::TFileName2 fn2(aFileName);
+		TRAPD(err, fn2.MakeAbsoluteL(iFs));
+		if (err) res = EFalse;
+		aFileName.Copy(fn2);
+		}
+	return res;
+	}
+
+TBool CCommandWindow::DoQueryText(const TDesC& aPrompt, TDes& aText)
+	{
+	// Get cursor in right position
+	TPoint cursor = iConsole.CursorPos();
+	// Clear the way
+	iConsole.SetPos(iWindow.iX, iWindow.iY);
+	iQuery.Fill(' ', iWindow.iWidth-1);
+	iConsole.Write(iQuery);
+	iConsole.SetPos(iWindow.iX, iWindow.iY);
+	// Start the line editor going
+	iLineEditor->Start(aPrompt, aText);
+	iLineEditor->ReinstatePromptAndUserInput();
+	iFinished = EFalse;
+	TBool result = ETrue;
+	iResultForQuery = &aText;
+	while (!iFinished)
+		{
+		TKeyCode ch = iConsole.Getch();
+		if (ch == EKeyEscape) 
+			{
+			result = EFalse;
+			break;
+			}
+		if (ch == EKeyEnter)
+			{
+			// Fool line editor by moving cursor up a line, so when it does its newline it doesn't screw us up
+			iConsole.SetCursorPosRel(TPoint(0, -1));
+			}
+		iLineEditor->HandleKey(ch, iConsole.KeyModifiers());
+		}
+	iConsole.SetCursorPosAbs(cursor);
+	// Async clear the query (in case of... something. Velociraptors maybe?)
+	iInfoPrintDismisser->Cancel();
+	iInfoPrintDismisser->Start(0, KInfoPrintTime, TCallBack(&DismissInfoPrint, this));
+	return result;
+	}
+
+RFs& CCommandWindow::Fs()
+	{
+	return iFs;
+	}
+
+void CCommandWindow::LeoHandleLine(const TDesC& aLine)
+	{
+	iFinished = ETrue;
+	*iResultForQuery = aLine.Left(iResultForQuery->MaxLength());
+	}
+
+_LIT(KFileNameSlash, "\\");
+_LIT(KDriveColonSlash, ":\\");
+_LIT(KTab, "\t");
+_LIT(KSpace, " ");
+
+// This code ripped from ptf
+void CCommandWindow::LcCompleteLineL(TConsoleLine& aLine, const TChar& /*aEscapeChar*/)
+	{
+	if (iLineEditor != iFileNameLineEditor) return; // Don't autocomplete for anything that isn't a filename
+
+	IoUtils::TFileName2 fileNameMatch;
+	fileNameMatch.Copy(aLine.ContentsToCursor());
+	
+	CDesCArray* suggestions = new(ELeave) CDesC16ArrayFlat(16);
+	CleanupStack::PushL(suggestions);
+
+	if (fileNameMatch.Length()==0)
+		{
+		SuggestDrivesL(suggestions);
+		}
+	else if (fileNameMatch.Length() == 2 && TChar(fileNameMatch[0]).IsAlpha() && fileNameMatch[1] == ':')
+		{
+		fileNameMatch.Append(KFileNameSlash);
+		}
+
+	if (!fileNameMatch.IsAbsolute())
+		{
+		fileNameMatch.MakeAbsoluteL(iFs);
+		}
+	
+	TPtrC relativeDir = aLine.ContentsToCursor();
+	relativeDir.Set(relativeDir.Left(relativeDir.LocateReverse('\\')+1)); // Remove any name to the right of the last backslash
+		
+	fileNameMatch.Append('*');
+	
+	CDir* files = NULL;
+	User::LeaveIfError(iFs.GetDir(fileNameMatch, KEntryAttNormal | KEntryAttDir, ESortByName, files));
+	CleanupStack::PushL(files);
+		
+	TInt numFiles = files->Count();
+	if (numFiles == 1)
+		{
+		fileNameMatch.SetLength(fileNameMatch.DriveAndPath().Length());
+		fileNameMatch.AppendComponentL((*files)[0].iName);
+		TEntry entry;
+		User::LeaveIfError(iFs.Entry(fileNameMatch, entry));
+		suggestions->AppendL(fileNameMatch.NameAndExt());
+		CompleteL(aLine, *suggestions, &relativeDir, entry.IsDir() ? &KFileNameSlash : NULL);
+		}
+	else if (numFiles > 0)
+		{
+		for (TInt i=0; i<numFiles; ++i)
+			{
+			suggestions->AppendL((*files)[i].iName);
+			}
+		CompleteL(aLine, *suggestions, &relativeDir, NULL);
+		}
+	
+	CleanupStack::PopAndDestroy(2, suggestions); // files, suggestions
+	}
+
+void CCommandWindow::SuggestDrivesL(CDesCArray* aSuggestions)
+	{
+	TDriveList drives;
+	User::LeaveIfError(iFs.DriveList(drives));
+	
+	for (TInt i=0; i<drives.Length(); ++i)
+		{
+		if (drives[i])
+			{
+			TBuf<3> buf;
+			
+			TChar driveChar;
+			User::LeaveIfError(iFs.DriveToChar(i, driveChar));
+			
+			buf.Append(driveChar);
+			buf.Append(KDriveColonSlash);
+			aSuggestions->AppendL(buf);						
+			}
+		}
+	}
+	
+void CCommandWindow::CompleteL(TConsoleLine& aLine, const CDesCArray& aPossibilities, const TDesC* aPrefix, const TDesC* aSuffix)
+	{
+	const TInt numPossibilities = aPossibilities.Count();
+
+	if (numPossibilities > 1)
+		{
+		// Fill out possibilities buffer.
+		IoUtils::CTextBuffer* possibilities = IoUtils::CTextBuffer::NewLC(0x100);
+		for (TInt i = 0; i < numPossibilities; ++i)
+			{
+			possibilities->AppendL(aPossibilities[i]);
+			if (i != (numPossibilities - 1))
+				{
+				possibilities->AppendL(KTab);
+				}
+			}
+
+		aLine.PrintCompletionPossibilitiesL(possibilities->Descriptor());
+		CleanupStack::PopAndDestroy(possibilities);
+		}
+
+	if (numPossibilities > 0)
+		{
+		IoUtils::CTextBuffer* completion = IoUtils::CTextBuffer::NewLC(0x100);
+		TPtrC commonChars(NULL, 0);
+		if (numPossibilities > 1)
+			{
+			// Find common leading characters of the possibilities.
+			TInt commonCharPos = -1;
+			TBool finished(EFalse);
+			do
+				{
+				++commonCharPos;
+				TChar character(0);
+				for (TInt i = 0; i < numPossibilities; ++i)
+					{
+					if (commonCharPos >= aPossibilities[i].Length())
+						{
+						finished = ETrue;
+						break;
+						}
+					else if (i == 0)
+						{
+						character = aPossibilities[0][commonCharPos];
+						character.Fold();
+						}
+					else
+						{
+						TChar c(aPossibilities[i][commonCharPos]);
+						c.Fold();
+						if (c != character)
+							{
+							finished = ETrue;
+							break;
+							}
+						}
+					}
+				}
+				while (!finished);
+
+			commonChars.Set(aPossibilities[0].Mid(0, commonCharPos));
+			}
+		else
+			{
+			commonChars.Set(aPossibilities[0]);
+			}
+
+		if (aPrefix)
+			{
+			completion->AppendL(*aPrefix);
+			}
+		completion->AppendL(commonChars);
+
+		if ((numPossibilities == 1) && (aSuffix))
+			{
+			completion->AppendL(*aSuffix);
+			}
+			
+		if ((numPossibilities == 1) && (!aSuffix))
+			{
+			completion->AppendL(KSpace);
+			}
+			
+		if (completion->Descriptor().Length() > 0)
+			{
+			aLine.Replace(0, completion->Descriptor());
+			}
+		CleanupStack::PopAndDestroy(completion);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/fed.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,376 @@
+// fed.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32cons.h>
+#include <BADESCA.H>
+#include <charconv.h>
+
+#include "fed.h"
+#include "viewbase.h"
+#include "bufferbase.h"
+#include "screenmngr.h"
+#include "cmdwindow.h"
+
+#include "filebuffer.h"
+#include "lrtextview.h"
+
+const TInt KDefScreenPosX = 0;
+const TInt KDefScreenPosY = 0;
+
+CFed* CFed::NewL(CColorConsoleBase& aConsole, RFs& aFs)
+	{
+	CFed* fed = new (ELeave) CFed(aConsole, aFs);
+	CleanupStack::PushL(fed);
+	fed->ConstructL();
+	CleanupStack::Pop(fed);
+	return fed;
+	}
+
+CFed* CFed::NewL(CConsoleBase& aConsole, RFs& aFs)
+	{
+	CFed* fed = new (ELeave) CFed(aConsole, aFs);
+	CleanupStack::PushL(fed);
+	fed->ConstructL();
+	CleanupStack::Pop(fed);
+	return fed;
+	}
+
+CFed::CFed(CColorConsoleBase& aConsole, RFs& aFs)
+	: CActive(CActive::EPriorityStandard), iFs(aFs), iConsole(aConsole), iColorConsole(&aConsole), iViewIdx(-1)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CFed::CFed(CConsoleBase& aConsole, RFs& aFs)
+	: CActive(CActive::EPriorityStandard), iFs(aFs), iConsole(aConsole), iViewIdx(-1)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CFed::~CFed()
+	{
+	Cancel();
+	for (TInt i = iViewArray.Count()-1; i >= 0; i--)
+		delete iViewArray[i];
+	iViewArray.Reset();
+	delete iCmdWindow;
+	delete iCharconv;
+	}
+
+void CFed::ConstructL()
+	{
+	iFs.CreatePrivatePath(EDriveC);
+	TSize size = iConsole.ScreenSize();
+	iScreenMngr.ResizeScreenL(TWindow(KDefScreenPosX, KDefScreenPosY, size.iWidth, size.iHeight));
+	if (iColorConsole)
+		{
+		iCmdWindow = CCommandWindow::NewL(iFs, *iColorConsole);
+		}
+	else
+		{
+		iCmdWindow = CCommandWindow::NewL(iFs, iConsole);
+		}
+	iCmdWindow->SetWindow(iScreenMngr.GetCommandWindow());
+	
+	TRAPD(err, iCharconv = CCnvCharacterSetConverter::NewL());
+	if (!err)
+		{
+		// This can fail if charconv isn't properly configured in the ROM
+		ASSERT(iCharconv->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, iFs) == CCnvCharacterSetConverter::EAvailable);
+		}
+	}
+
+void CFed::StartL(CDesC16Array* aFiles)
+	{
+	CleanupStack::PushL(aFiles);
+	CreateViewsL(aFiles);
+	CleanupStack::PopAndDestroy(aFiles);
+
+	iConsole.Read(iStatus);
+	SetActive();
+	}
+
+//CActive
+void CFed::DoCancel()
+	{
+	iConsole.ReadCancel();
+	}
+
+void CFed::RunL()
+	{
+	if(iStatus.Int() < 0)
+		{
+		CActiveScheduler::Stop();
+		return;
+		}
+
+	TKeyCode code = iConsole.KeyCode();
+	TCmdType cmd = ProcessKeyL(code);
+
+	if(!ExecuteCommandL(cmd) && iViewIdx >= 0)
+		iViewArray[iViewIdx]->ConsumeKeyL(code);
+	if(iViewArray.Count() == 0)
+		{
+		// No more views, time to exit.
+		// Set the cursor to the bottom of the screen before we do - easier for the user to see that we've exited
+		TSize screenSize = iConsole.ScreenSize();
+		iConsole.SetPos(screenSize.iWidth-1, screenSize.iHeight-1); // Bottom right corner
+		iConsole.Write(_L(" ")); // This should cause the window to scroll and the cursor to be on the bottom line
+		CActiveScheduler::Stop();
+		return;
+		}
+
+	iConsole.Read(iStatus);
+	SetActive();
+	}
+
+TInt CFed::RunError(TInt aError)
+	{
+	if (iCmdWindow)
+		{
+		iCmdWindow->InfoPrint(_L("Leave occurred: %d"), aError);
+
+		// And rerequest further keys
+		iConsole.Read(iStatus);
+		SetActive();
+
+		return KErrNone;
+		}
+	return aError;
+	}
+
+void CFed::CreateViewsL(CDesC16Array* aFiles)
+	{
+	TInt n = aFiles->Count();
+	for (TInt i = 0; i < n; i++)
+		{
+		NewViewL((*aFiles)[i], ETrue);
+		}
+
+	if (n == 0)
+		{
+		// Create a new untitled view instead
+		NewViewL(KNullDesC);
+		}
+	if (iCharconv)
+		{
+		iCmdWindow->InfoPrint(_L("Welcome to fed. Press Ctrl-L for help."));
+		}
+	else
+		{
+		iCmdWindow->InfoPrint(_L("Warning: couldn't load charconv. UTF-8 not available."));
+		}
+	}
+
+CFed::TCmdType CFed::ProcessKeyL(const TKeyCode& aCode)
+	{
+	switch(aCode)
+		{
+	case CTRL('q'):
+		return ECmdCloseAll;
+	case EKeyF1:
+	case CTRL('l'):
+		return ECmdHelp;
+	case EKeyF2:
+	case CTRL('p'):
+		return ECmdPrevView;
+	case EKeyF3:
+	case CTRL('}'):
+		return ECmdNextView;
+	case EKeyEscape:
+	case CTRL('w'):
+		return ECmdCloseCurrent;
+	case CTRL('n'):
+		return ECmdNewDocument;
+	case CTRL('o'):
+		return ECmdOpenDocument;
+	case CTRL('r'):
+	case EKeyF5:
+		return ECmdRefresh;
+	default:
+		break;
+		}
+	return ECmdNone;
+	}
+
+TBool CFed::ExecuteCommandL(TCmdType aCmd)
+{
+	switch(aCmd)
+		{
+		case ECmdHelp:
+			::ShowHelpL();
+			break;
+		case ECmdPrevView:
+			iViewIdx--;
+			if (iViewIdx < 0) iViewIdx = iViewArray.Count()-1;
+			iScreenMngr.AttachViewL(*iViewArray[iViewIdx]);
+			break;
+		case ECmdNextView:
+			iViewIdx++;
+			if (iViewIdx >= iViewArray.Count()) iViewIdx = 0;
+			iScreenMngr.AttachViewL(*iViewArray[iViewIdx]);
+			break;
+		case ECmdCloseCurrent:
+			CloseCurrentViewL();
+			break;
+		case ECmdCloseAll:
+			CloseAllViewsL();
+			break;
+		case ECmdNewDocument:
+			NewViewL(KNullDesC);
+			break;
+		case ECmdOpenDocument:
+			OpenDocumentL();
+			break;
+		case ECmdRefresh:
+			iScreenMngr.RefreshScreenL();
+			break;
+		default:
+			return EFalse;
+		}
+	return ETrue;
+}
+
+TBool CFed::CloseCurrentViewL()
+{
+	if(iViewIdx < 0)
+		{
+		//Show a message to the user that there is nothing to close
+		return EFalse;
+		}
+
+	CFedViewBase* view = iViewArray[iViewIdx];
+	TBool okToClose = ETrue; 
+	if (view->Buffer().RefCount() == 1)
+		{
+		// We're the only view on this buffer - better ask about saving
+		okToClose = view->TryCloseL();
+		}
+
+	if (okToClose)
+		{
+		DeleteView();
+		}
+	return okToClose;
+	}
+
+void CFed::CloseAllViewsL()
+{
+	TBool ret = ETrue;
+	while(iViewIdx >=0 && ret)
+		ret = CloseCurrentViewL();
+}
+
+void CFed::DeleteView()
+	{
+	delete iViewArray[iViewIdx];
+	iViewArray.Remove(iViewIdx);
+	iScreenMngr.UnsetCurrentView();
+	if (iViewIdx >= iViewArray.Count())
+		{
+		iViewIdx = iViewArray.Count()-1;
+		}
+	if (iViewIdx >= 0)
+		{
+		// Attach the new frontmost view
+		iScreenMngr.AttachViewL(*(iViewArray[iViewIdx]));
+		}
+	}
+
+void CFed::NewViewL(const TDesC& aFileName, TBool aPromptOnNonexistantName)
+	{
+	CFileBuffer* buffer = NULL;
+	TRAPD(err, buffer = CFileBuffer::NewL(iFs, iCharconv, aFileName, EFalse));
+	if ((err == KErrNotFound || err == KErrPathNotFound) && aPromptOnNonexistantName)
+		{
+		if (iCmdWindow->Query(_L("File not found. Create? (yes/no) "), _L("yn")) == 'y')
+			{
+			buffer = CFileBuffer::NewL(iFs, iCharconv, aFileName, ETrue);
+			err = KErrNone;
+			}
+		}
+	User::LeaveIfError(err);
+
+	buffer->PushL();
+	CLRTextView* view = CLRTextView::NewL(*iCmdWindow, *buffer);
+	CleanupStack::Pop(buffer);
+	buffer->DecRef(); // view now has a ref to it
+	CleanupStack::PushL(view);
+	iViewArray.AppendL(view);
+	CleanupStack::Pop(view);
+	iViewIdx = iViewArray.Count()-1;
+	iScreenMngr.AddViewL(*view);
+	}
+
+void CFed::OpenDocumentL()
+	{
+	TFileName name;
+	TBool go = iCmdWindow->QueryFilename(_L("Open file: "), name);
+	if (go)
+		{
+		TInt prevIdx = iViewIdx;
+		TRAPD(err, NewViewL(name));
+		if (err)
+			{
+			switch (err)
+				{
+				case KErrNotFound:
+					iCmdWindow->InfoPrint(_L("File '%S' not found"), &name);
+					break;
+				case KErrPathNotFound:
+					iCmdWindow->InfoPrint(_L("KErrPathNotFound. Directory doesn't exist?"));
+					break;
+				case KErrBadName:
+					iCmdWindow->InfoPrint(_L("Bad name"));
+					break;
+				default:
+					iCmdWindow->InfoPrint(_L("Unable to open file: %d."), err);
+					break;
+				}
+			}
+		else if (!err && prevIdx >= 0)
+			{
+			CFedViewBase* prevView = iViewArray[prevIdx];
+			if (prevView->Buffer().Editable() && !prevView->Buffer().Modified() && prevView->Buffer().Title().Length() == 0)
+				{
+				// Then previous doc was an empty, untitled window, which this open should replace
+				delete prevView;
+				iViewArray.Remove(prevIdx);
+				iViewIdx = iViewArray.Count()-1;
+				}
+			}
+		}
+	}
+
+// Not usable: ^H = Bksp, ^M = CR, ^I = Tab, ^J = LF, ^Z = suspend, ^[ = Esc
+// Currently free: ^E, ^Y
+void CFed::ShowHelpL(HBufC* aHelpText)
+	{
+	_LIT(KHelpTitle, "Fed Help");
+	CleanupStack::PushL(aHelpText);
+	CConstDataBuffer* helpBuf = new(ELeave) CConstDataBuffer(KHelpTitle, aHelpText);
+	CleanupStack::Pop(aHelpText);
+	helpBuf->PushL();
+	CLRTextView* view = CLRTextView::NewL(*iCmdWindow, *helpBuf);
+	CleanupStack::Pop(helpBuf);
+	helpBuf->DecRef(); // view now has a ref to it
+	CleanupStack::PushL(view);
+	iViewArray.AppendL(view);
+	CleanupStack::Pop(view);
+	iViewIdx = iViewArray.Count()-1;
+	iScreenMngr.AddViewL(*view);
+	}
+
+void CFed::RedrawEverythingL()
+	{
+	ExecuteCommandL(ECmdRefresh);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/filebuffer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1258 @@
+// filebuffer.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include <e32math.h>
+#include <utf.h>
+#include <charconv.h>
+
+#include "filebuffer.h"
+
+const TInt KMinBlockSize = 2048; // Not least because an 80x24 console is about 2k
+const TInt KMaxBlockSize = 28*1024; // 28 is good compromise, at least up to about 50MB files
+const TInt KTargetNumBlocks = 100; // Grow block size linearly to try and keep the number of blocks at around 100
+
+/////DEBUG
+//const TInt KMaxBlockSize = 64*1024-1;
+//const TInt KTargetNumBlocks = 2;
+//////END DEBUG
+
+__ASSERT_COMPILE(KMaxBlockSize <= (TInt)KMaxTUint16);
+
+const TInt KUnicodeLineBreak = 0x2028;
+//const TInt KUnicodeParagraphBreak = 0x2029; // We treat this the same as a unicode line break, oh well.
+const TUint KFilePermissions = EFileShareReadersOnly | EFileRead;
+void ByteSwitch(TUint16* data, TInt aLen);
+
+CFileBuffer* CFileBuffer::NewL(RFs& aFs, CCnvCharacterSetConverter* aCharconv, const TDesC& aName, TBool aAllowNonexistantName)
+	{
+	CFileBuffer* fb = new (ELeave) CFileBuffer(aFs, aCharconv);
+	fb->PushL();
+	if (aName.Length())
+		{
+		fb->ConstructL(aName, aAllowNonexistantName);
+		}
+	else
+		{
+		fb->ConstructL();
+		}
+	CleanupStack::Pop(fb);
+	return fb;
+	}
+
+CFileBuffer::~CFileBuffer()
+	{
+	iFile.Close();
+
+	CFileBlock* block = iFirstBlock;
+	while (block)
+		{
+		CFileBlock* next = block->Next();
+		delete block;
+		block = next;
+		}
+	iNarrowBuf.Close();
+	}
+
+CFileBuffer::CFileBuffer(RFs& aFs, CCnvCharacterSetConverter* aCharconv)
+	: iDelimType(EDelimNotYetKnown), iEncoding(EEncodingUnknown), iFs(aFs), iCharconv(aCharconv)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CFileBuffer::ConstructL(const TDesC& aName, TBool aAllowNonexistantName)
+	{
+	TInt err = iFile.Open(iFs, aName, KFilePermissions);
+	if ((err == KErrNotFound || err == KErrPathNotFound) && aAllowNonexistantName)
+		{
+		// Then treat it the same as an new untitled file (except that it has a title)
+		ConstructL();
+		iFinalName = aName;
+		return;
+		}
+
+	User::LeaveIfError(err); // view will take care of displaying appropriate message
+	CommonConstructL();
+	User::LeaveIfError(iFile.FullName(iFinalName));
+	TInt size = 0;
+	User::LeaveIfError(iFile.Size(size));
+	iCacheBufSize = CalculateCacheBufSize(size);
+	User::LeaveIfError(iCacheBufSize);
+	iNarrowBuf.CreateL(iCacheBufSize);
+	// And set up our initial file blocks, all of which start out with size iCacheBufSize (with the exception of the last one)
+	CFileBlock* endBlock = NULL;
+	TInt blockStart = 0;
+	while (blockStart < size)
+		{
+		TInt blockSize = Min(iCacheBufSize, size - blockStart);
+		CFileBlock* block = new(ELeave) CFileBlock(blockStart, blockSize);
+		if (endBlock)
+			{
+			block->InsertAfterBlock(endBlock);
+			}
+		else
+			{
+			iFirstBlock = block;
+			}
+		endBlock = block;
+		blockStart += blockSize;
+		}
+	if (!iFirstBlock)
+		{
+		// File must be empty, in which case we need to do the same as in ConstructL() and create a placeholder empty block
+		iFirstBlock = new(ELeave) CFileBlock(0, 0);
+		// Do I need to call this?
+		User::LeaveIfError(iFirstBlock->BlockDidLoad(iEncoding, iDelimType, KNullDesC8, iCharconv));
+		}
+	}
+
+void CFileBuffer::ConstructL() // Overload for no file - ie use new, untitled file
+	{
+	CommonConstructL();
+	iCacheBufSize = KMinBlockSize;
+	iNarrowBuf.CreateL(iCacheBufSize);
+	iFirstBlock = new(ELeave) CFileBlock(0, 0);
+	User::LeaveIfError(iFirstBlock->BlockDidLoad(iEncoding, iDelimType, KNullDesC8, iCharconv));
+	}
+
+void CFileBuffer::CommonConstructL()
+	{
+	// Used to be something here, not any more
+	}
+
+TInt CFileBuffer::CalculateCacheBufSize(TInt aFileSize)
+	{
+	TInt blockSize = aFileSize / KTargetNumBlocks;
+	blockSize = blockSize & 0xFFFFFF0; // Round down to nearest 16-byte boundary
+	if (blockSize < KMinBlockSize)
+		{
+		return KMinBlockSize;
+		}
+	else if (blockSize > KMaxBlockSize)
+		{
+		return KMaxBlockSize;
+		}
+	else
+		{
+		return blockSize;
+		}
+	}
+
+/*
+ This function is responsible for unloading unnecessary CFileBlocks [and calling MSharedCacheClient::InvalidateBuffer
+ on any client accessing data from buffers being deleted]. The function decides who is using which blocks based on
+ TClientRequest::iRequestedBlock to see what the most-recently requested block was.
+ */
+//For now the function is kept as simple as possible. For each client it just keeps three read-only buffers: the current buffer,
+//the previous buffer, and the next buffer. It also keeps all writable buffers (containing data written by the user) because
+//they have to be written to the disk before deleting.
+void CFileBuffer::TidyCache()
+	{
+	for (CFileBlock* block = iFirstBlock; block != NULL; block = block->Next())
+		{
+		UnloadBlockIfPossible(block);
+		}
+	}
+
+void CFileBuffer::UnloadBlockIfPossible(CFileBlock* aBlock)
+	{
+	if (aBlock->IsDirty() || !aBlock->IsLoaded() || aBlock == iCurrentBlock) return;
+	// Check if any client is using it
+	TBool inUse = EFalse;
+	for (TInt i = 0; i < iClientRequests.Count(); i++)
+		{
+		CFileBlock* clientBlock = iClientRequests[i].iLastRequestedBlock;
+		if (!clientBlock) continue;
+		else if (clientBlock == aBlock || clientBlock->Prev() == aBlock || clientBlock->Next() == aBlock)
+			{
+			inUse = ETrue;
+			break;
+			}
+		}
+	if (!inUse)
+		{
+		aBlock->Unload();
+		}
+	}
+
+CFileBlock* CFileBuffer::FindBlockForDocumentPosition(TInt aDocPosition, TInt* aOffset, TInt* aLineCountToDocPos)
+	{
+	ASSERT(aDocPosition >= 0);
+
+	TInt blockStart = 0;
+	TInt lineCount = 0;
+	CFileBlock* block = iFirstBlock;
+	while (block)
+		{
+		if (!block->HasBeenLoaded())
+			{
+			// Need the block to have been loaded to know the char count (and the line count)
+			TInt err = LoadBlock(block);
+			if (err) return NULL;
+			}
+
+		TInt charCount = block->CharacterCount();
+
+		if (aDocPosition < blockStart + charCount || block->Next() == NULL && aDocPosition == blockStart + charCount)
+			{
+			// Found it (note that the last block is returned if the document position DocumentSize() is requested)
+			TInt offset = aDocPosition - blockStart;
+			if (aOffset) *aOffset = offset;
+			if (aLineCountToDocPos)
+				{
+				TInt lineCountToOffset = 0;
+				if (offset != 0)
+					{
+					// We have to load the block if the caller requested line count info and offset is non-zero
+					TInt err = LoadBlock(block);
+					if (err) return NULL;
+					lineCountToOffset = block->CountNewLinesUpToOffset(offset);
+					}
+				*aLineCountToDocPos = lineCount + lineCountToOffset;
+				}
+			return block;
+			}
+		else
+			{
+			UnloadBlockIfPossible(block);
+			}
+		blockStart += charCount;
+		lineCount += block->NewlineCount();
+		block = block->Next();
+		}
+	//ASSERT(EFalse); // If we get here then we don't have a block for this offset - maybe offset was >= file length?
+	return NULL;
+	}
+
+TInt CFileBuffer::LoadBlock(CFileBlock* aBlock)
+	{
+	TInt err = KErrNone;
+	if (aBlock->IsLoaded())
+		{
+		return KErrNone;
+		}
+
+	if (!iFile.SubSessionHandle()) return KErrNotReady;
+
+	// Then load it from disk
+	iNarrowBuf.Zero();
+	TInt blockSize = aBlock->BlockSize();
+	if (blockSize > iNarrowBuf.MaxSize())
+		{
+		err = iNarrowBuf.ReAlloc(blockSize);
+		}
+
+	if (!err)
+		{
+		err = iFile.Read(aBlock->FilePosition(), iNarrowBuf, blockSize);
+		if (err)
+			{
+			aBlock->Unload();
+			}
+		}
+
+	if (err == KErrNone)
+		{
+		TEncodingType blockEncoding = iEncoding;
+		TDelimiterType blockDelim = iDelimType;
+		err = aBlock->BlockDidLoad(blockEncoding, blockDelim, iNarrowBuf, iCharconv);
+		if (err)
+			{
+			// Don't do anything with encodings
+			return err;
+			}
+
+		if (iEncoding == EEncodingUtf8 && blockEncoding == EEncodingNarrow)
+			{
+			// Conceivably previous blocks could have been narrow that was also UTF-8 conformant but this block makes it clear the file definitely isn't UTF-8 - therefore allow the change of encoding
+			iEncoding = EEncodingNarrow;
+			}
+		else if (iEncoding == EEncodingUnknown)
+			{
+			iEncoding = blockEncoding;
+			}
+		else if (blockEncoding != iEncoding)
+			{
+			__DEBUGGER();
+			err = KErrCorrupt;
+			}
+
+		if (iDelimType == EDelimNotYetKnown && blockDelim)
+			{
+			iDelimType = blockDelim;
+			}
+		// Inconsistant line ending info is ignored here, as most of it has already been thrown away by CountNewLines
+		}
+
+	return err;
+	}
+
+TInt CFileBuffer::GetData(MSharedCacheClient& aClient, TInt aDocumentPosition)
+	{
+	TInt idx = FindClientRequest(aClient);
+	if (idx < 0)
+		{
+		return idx;
+		}
+
+	TClientRequest& client = iClientRequests[idx];
+	ASSERT(aDocumentPosition >= 0);
+
+	TInt offset;
+	TInt lineCount;
+	CFileBlock* block = FindBlockForDocumentPosition(aDocumentPosition, &offset, &lineCount);
+	client.iRange = TRange(aDocumentPosition, 0); // Length will be filled in once block is loaded (as could change due to TransferDataFromPreviousBlock)
+	client.iRangeStartLineNumber = lineCount;
+
+	TInt err = LoadBlock(block);
+	if (err) return err;
+
+	const TDesC& text = block->Text();
+	client.iDes.Set(text.Mid(offset));
+	client.iRange.iLength = text.Length() - offset;
+	client.iLastRequestedBlock = block;
+	TidyCache();
+	return KErrNone;
+	}
+
+TInt CFileBuffer::SeekFromOffset(MSharedCacheClient& aClient, TInt aDocumentPosition, TInt aNumLinesFromOffset, TInt aLineLength)
+	{
+	TInt idx = FindClientRequest(aClient);
+	if (idx < 0)
+		{
+		return idx;
+		}
+
+	TClientRequest& client = iClientRequests[idx];
+	//ASSERT(client.iClientStatus == NULL); // Client can't make more than 1 request at once
+	ASSERT(aDocumentPosition >= 0);
+	//ASSERT(aDocumentPosition < DocumentSize());
+	ASSERT(aNumLinesFromOffset != 0);
+
+	TInt offset;
+	CFileBlock* block = FindBlockForDocumentPosition(aDocumentPosition, &offset);
+
+	TInt& lineDelta = aNumLinesFromOffset;
+	TInt& maxLineLength = aLineLength;
+
+	TInt err = KErrNone;
+	while (ETrue)
+		{
+		ASSERT(block);
+		err = LoadBlock(block);
+		if (err) return err;
+
+		TInt lines = lineDelta;
+		TInt bufPos;
+		if (lines > 0)
+			{
+			bufPos = CFileBlock::CountNewLines(block->Text().Mid(offset), lines, maxLineLength);
+			if (bufPos == KErrNotFound)
+				{
+				CFileBlock* nextBlock = block->Next();
+				if (!nextBlock)
+					{
+					// If no more blocks, change the request to be "find the first newline searching backwards from the end of the last block" (phrasing it like this means it'll work even if there aren't any newlines in this block at all)
+					lineDelta = -1;
+					offset = block->CharacterCount();
+					continue;
+					}
+				offset = 0;
+				lineDelta -= lines;
+				UnloadBlockIfPossible(block);
+				block = nextBlock;
+				continue;
+				}
+			else
+				{
+				bufPos += offset; // Since the bufPos returned was relative to the Mid we did
+				}
+			}
+		else
+			{
+			lineDelta--; // Client will want the line *before* the first new line we encounter (the first new line we encounter will be for the line they're actually on)
+			lines = lineDelta;
+			bufPos = CFileBlock::CountNewLines(block->Text().Left(offset), lines, maxLineLength);
+			if (bufPos == KErrNotFound)
+				{
+				CFileBlock* prevBlock = block->Prev();
+				if (!prevBlock)
+					{
+					// If no more blocks, then the start of the first block is closest
+					offset = 0;
+					break;
+					}
+				UnloadBlockIfPossible(block);
+				block = prevBlock;
+				offset = block->CharacterCount();
+				lineDelta += lines; // since lineDelta is negative
+				continue;
+				}
+			}
+		ASSERT(bufPos != KErrNotFound); // Must be, to have got here
+		offset = bufPos;
+		break;
+		}
+
+	client.iDes.Set(block->Text().Mid(offset));
+	TInt docPos;
+	TInt lineCount;
+	block->CalculateBlockPositions(docPos, lineCount);
+	client.iRange = TRange(docPos + offset, block->CharacterCount() - offset);
+	client.iLastRequestedBlock = block;
+	ASSERT(client.iRange.iLength == client.iDes.Length());
+	client.iRangeStartLineNumber = lineCount + block->CountNewLinesUpToOffset(offset);
+	TidyCache();
+	return KErrNone;
+	}
+
+TBool CFileBuffer::DocumentPositionIsEof(TInt aDocumentPosition) const
+	{
+	// Like FindBlockForDocumentPosition but doesn't try and load blocks
+	TInt blockStart = 0;
+	for (CFileBlock* block = iFirstBlock; block != NULL; block = block->Next())
+		{
+		if (!block->HasBeenLoaded())
+			{
+			return EFalse;
+			}
+		TInt charCount = block->CharacterCount();
+		TInt endOfBlock = blockStart + charCount;
+		if (aDocumentPosition < endOfBlock) return EFalse; // We have more characters than this doc pos so it can't be the end
+		else if (charCount == 0 && block->Next() != NULL)
+			{
+			continue; // we're an empty block followed by another block, so defer the decision to the next block
+			}
+		else if (aDocumentPosition == endOfBlock)
+			{
+			// Then this position is the eof if there aren't any more blocks
+			return (block->Next() == NULL);
+			}
+		blockStart += charCount;
+		}
+	ASSERT(EFalse);
+	return EFalse;
+	}
+
+void CFileBuffer::InsertTextL(TInt aDocumentPosition, const TDesC& aText)
+	{
+	TInt offset;
+	CFileBlock* block = FindBlockForDocumentPosition(aDocumentPosition, &offset);
+
+	TInt err = LoadBlock(block);
+	User::LeaveIfError(err);
+
+	block->InsertTextL(offset, aText);
+	iUnsaved = ETrue;
+	}
+
+void CFileBuffer::DeleteTextL(TRange aRange)
+	{
+	while (aRange.iLength > 0)
+		{
+		TInt offset;
+		CFileBlock* block = FindBlockForDocumentPosition(aRange.iLocation, &offset);
+		if (!block) return; // We will tolerate it if the range is beyond the document position
+		TInt err = LoadBlock(block);
+		User::LeaveIfError(err);
+
+		TInt blockCharCount = block->CharacterCount();
+		TInt blockLen = Min(blockCharCount - offset, aRange.iLength);
+		if (blockLen) // Again, tolerating if the range is completely outside the document length
+			{
+			block->DeleteText(offset, blockLen);
+			// The range location stays the same, since everything will have shuffled up
+			aRange.iLength -= blockLen;
+			iUnsaved = ETrue;
+			}
+		else
+			{
+			break;
+			}
+		}	
+	}
+
+void CFileBuffer::DeleteTempFile(TAny* aSelf)
+	{
+	CFileBuffer* self = static_cast<CFileBuffer*>(aSelf);
+	if (self->iTempName->Length())
+		{
+		self->iFs.Delete(*self->iTempName);
+		}
+	delete self->iTempName;
+	self->iTempName = NULL;
+	}
+
+void CFileBuffer::SetFinalNameToTemporary(TAny* aSelf)
+	{
+	CFileBuffer* self = static_cast<CFileBuffer*>(aSelf);
+	self->iFinalName = *self->iTempName;
+	}
+
+void CFileBuffer::SaveL(const TDesC& aName, TBool aReplace)
+	{
+	// Try opening aName as given - if it suceeds use it, if it fails with alreadyExists use a temp file and rename at the end
+	RBuf origRenamed;
+	CleanupClosePushL(origRenamed);
+	iTempName = new(ELeave) TFileName;
+	origRenamed.CreateL(KMaxFileName);
+
+	RFile outFile;
+	CleanupStack::PushL(TCleanupItem(&DeleteTempFile, this));
+	CleanupClosePushL(outFile);
+	TBool needToRename = EFalse;
+
+	TInt err = iFs.MkDirAll(aName); // Avoid path not found errors in the case where the file has not yet been saved
+	if (err == KErrAlreadyExists) err = KErrNone;
+	User::LeaveIfError(err);
+
+	const TUint fileMode = EFileWrite | EFileShareExclusive | EFileStream;
+	err = outFile.Create(iFs, aName, fileMode);
+	if ((err == KErrAlreadyExists || err == KErrInUse) && aReplace)
+		{
+		needToRename = ETrue;
+		TParsePtrC parse(aName);
+		TPtrC path = parse.DriveAndPath();
+		err = outFile.Temp(iFs, path, *iTempName, fileMode);
+		}
+	User::LeaveIfError(err);
+
+	if (iDelimType == EDelimNotYetKnown) iDelimType = EDelimCRLF; // It's conceivable that we still might not have a newline type - default to Symbian default, CRLF.
+	if (iEncoding == EEncodingUnknown) iEncoding = EEncodingUtf8;
+
+	CFileBlock* block = iFirstBlock;
+	while (block)
+		{
+		err = LoadBlock(block);
+		User::LeaveIfError(err);
+		err = block->ConvertToEightBit(iEncoding, iDelimType, iNarrowBuf);
+		User::LeaveIfError(err); // Conversion could fail, or oom trying to realloc iNarrowBuf
+		err = outFile.Write(iNarrowBuf);
+		User::LeaveIfError(err); // File writing failed
+		UnloadBlockIfPossible(block);
+		block = block->Next();
+		}
+	CleanupStack::PopAndDestroy(&outFile); // closes outFile
+	TBool fileWasOpen = IsOpen();
+	if (fileWasOpen)
+		{
+		// If the file wasn't open, there's no need for us to preserve the temporary (because the whole file must be by definition in memory)
+		CleanupStack::Pop(); // Remove DeleteTempFile - the temp file is important once we start tinkering with the original
+		CleanupStack::PushL(iTempName); // But the descriptor isn't
+		iUnsaved = EFalse; // We've succeeded in saving it *somewhere*
+		}
+	// From here on in, we bail on any failure that leaves the original file moved and/or closed. We do not try to recover from any of these, instead just bail and let the user tidy up the temp files
+
+	if (needToRename)
+		{
+		CleanupStack::PushL(TCleanupItem(&SetFinalNameToTemporary, this)); // If we bail out and leave, this indicates where we managed to save the file to
+		iFile.Close(); // Is necessary if we're trying to overwrite the original
+		TBool done = EFalse;
+		TInt nonce = 1;
+
+		// First, rename the original out of the way
+		while (!done)
+			{
+			_LIT(KFmt, "%S.orig%d");
+			origRenamed.Format(KFmt, &aName, nonce);
+			nonce++;
+			err = iFs.Rename(aName, origRenamed);
+			if (err != KErrAlreadyExists) done = ETrue;
+			}
+		User::LeaveIfError(err);
+
+		// If we reach here, rename has succeeded - now rename temp file to orig
+		err = iFs.Rename(*iTempName, aName);
+		User::LeaveIfError(err);
+
+		// Now just need to bin the original file
+		iFs.Delete(origRenamed); // Don't care if this succeeds or not
+
+		// Finally, reopen the file
+		err = iFile.Open(iFs, aName, KFilePermissions);
+		User::LeaveIfError(err);
+		// If this all succeeded, we're sorted
+		CleanupStack::Pop(); // SetFinalNameToTemporary
+		}
+	else
+		{
+		// If we didn't use a temporary, we just have to reopen the file
+		iFile.Close(); // Don't imagine it could be open here...
+		err = iFile.Open(iFs, aName, KFilePermissions);
+		User::LeaveIfError(err);
+		}
+
+	CleanupStack::PopAndDestroy(2, &origRenamed); // iTempName OR DeleteTempFile, origNamed
+	iTempName = NULL;
+	iUnsaved = EFalse;
+	iFile.FullName(iFinalName); // We don't just do "iFinalName = aName", in case the caller managed to sneak a relative path past the file system
+	// Once everything has completed ok, go through and set every block as not dirty. This also updates block file positions
+	iFirstBlock->FileHasBeenSaved();
+	}
+
+TBool CFileBuffer::Modified() const
+	{
+	return iUnsaved;
+	}
+
+TDelimiterType CFileBuffer::DelimiterType() const
+	{
+	return iDelimType;
+	}
+
+TEncodingType CFileBuffer::Encoding() const
+	{
+	return iEncoding;
+	}
+
+const TDesC& CFileBuffer::Title() const
+	{
+	return iFinalName;
+	}
+
+TBool CFileBuffer::Editable() const
+	{
+	return ETrue;
+	}
+
+TBool CFileBuffer::IsOpen() const
+	{
+	return iFile.SubSessionHandle() != 0;
+	}
+
+TInt CFileBuffer::Find(TInt aStartingPosition, const TDesC& aSearchString, TBool aBackwards)
+	{
+	TInt res = 0;
+	TRAPD(err, res = DoFindL(aStartingPosition, aSearchString, aBackwards));
+	if (err) res = err;
+	return res;
+	}
+
+#define EnsureCapacity(buf, len) if (buf.MaxLength() < len) { TInt err = buf.ReAlloc(Max(len, buf.Length()*2)); if (err) return err; }
+#define EnsureCapacityL(buf, len) if (buf.MaxLength() < len) { buf.ReAllocL(Max(len, buf.Length()*2)); }
+#define EnsureHBufCapacity(hbuf, len) if (hbuf->Des().MaxLength() < len) { HBufC* newBuf = hbuf->ReAllocL(Max(len, hbuf->Length()*2)); if (newBuf) { hbuf = newBuf; } else { return KErrNoMemory; } }
+#define EnsureHBufCapacityL(hbuf, len) if (hbuf->Des().MaxLength() < len) { hbuf = hbuf->ReAllocL(Max(len, hbuf->Length()*2)); }
+
+TInt CFileBuffer::DoFindL(TInt aStartingPosition, const TDesC& aSearchString, TBool aBackwards)
+	{
+	ASSERT(!aBackwards); // TODO not supported yet
+	// We use a separate buffer because searching directly through the block's text wouldn't handle the case
+	// where the search string is split over 2 blocks. We use a rolling buffer containing the current buffer and
+	// the last one, and seach in that, so 
+	RBuf searchBuf;
+	CleanupClosePushL(searchBuf);
+	const TInt searchLen = aSearchString.Length();
+	searchBuf.CreateL(iCacheBufSize + searchLen); // A match could only span buffers by a max of searchLen
+	
+	TInt offset;
+	CFileBlock* block = FindBlockForDocumentPosition(aStartingPosition, &offset);
+	TInt bufStartPos = aStartingPosition;
+	while (block)
+		{
+		// Block must be loaded to search through its data
+		TInt err = LoadBlock(block);
+		User::LeaveIfError(err);
+		// Get block data into the search buf, leaving up to searchLen's worth of the previous block, so we can handle the search term spanning 2 buffers
+		TPtrC blockData = block->Text().Mid(offset);
+		TInt newBlockLen = blockData.Length();
+
+		EnsureCapacityL(searchBuf, newBlockLen + searchLen);
+		TPtrC toKeep = searchBuf.Right(searchLen);
+		TInt amountToDeleteFromBuf = searchBuf.Length() - toKeep.Length();
+		searchBuf.Delete(0, amountToDeleteFromBuf);
+		bufStartPos += amountToDeleteFromBuf;
+		searchBuf.Append(blockData);
+
+		TInt found = searchBuf.Find(aSearchString);
+		if (found != KErrNotFound)
+			{
+			TInt result = bufStartPos + found;
+			CleanupStack::PopAndDestroy(&searchBuf);
+			return result;
+			}
+		
+		UnloadBlockIfPossible(block);
+		block = block->Next();
+		offset = 0; // Non-zero offset only relevant for the first block searced, the one returned by FindBlockForDocumentPosition
+		}
+	User::Leave(KErrNotFound);
+	return 0;
+	}
+
+//////
+
+CFileBlock::CFileBlock(TInt aFilePosition, TInt aBlockSize)
+	: iFilePosition(aFilePosition), iBlockSize(aBlockSize)
+	{
+	if (aBlockSize == 0)
+		{
+		ASSERT(aFilePosition == 0); // A zero blocksize is only valid if we're the first (and only) block of an empty, untitled, unsaved file
+		iFlags.Set(EHasBeenLoaded); // Ie, it doesn't need loading
+		}
+	}
+
+TInt CFileBlock::BlockSize() const
+	{
+	ASSERT(!iFlags.IsSet(EDirty)); // We can't know the blocksize for a dirty block (it's not known until the block is saved, ie converted back to 8-bit data)
+	return iBlockSize;
+	}
+
+TBool CFileBlock::IsLoaded() const
+	{
+	return iData != NULL;
+	}
+
+TBool CFileBlock::HasBeenLoaded() const
+	{
+	return iFlags.IsSet(EHasBeenLoaded);
+	}
+
+void CFileBlock::CalculateBlockPositions(TInt& aCharacterPos, TInt& aLineCount) const
+	{
+	// Have to figure out our document position from the previous blocks. We don't cache this information because that would make inserting text into the file much harder
+	aCharacterPos = 0;
+	aLineCount = 0;
+	
+	CFileBlock* prev = iPrev;
+	while (prev)
+		{
+		aCharacterPos += prev->CharacterCount();
+		aLineCount += prev->NewlineCount();
+		prev = prev->iPrev;
+		}
+	}
+
+TInt CFileBlock::FilePosition() const
+	{
+	return iFilePosition;
+	}
+
+CFileBlock::~CFileBlock()
+	{
+	delete iData;
+	}
+
+TBool CFileBlock::IsDirty() const
+	{
+	return iFlags.IsSet(EDirty);
+	}
+
+void CFileBlock::Unload()
+	{
+	ASSERT(!IsDirty());
+	ASSERT(iData->Length() <= (TInt)KMaxTUint16); // Otherwise we can't safely update our character count
+	iNumCharacters = iData->Length();
+	delete iData;
+	iData = NULL;
+	}
+
+void CFileBlock::InsertAfterBlock(CFileBlock* aBlock)
+	{
+	ASSERT(iPrev == NULL);
+	ASSERT(iNext == NULL);
+	CFileBlock* next = aBlock->iNext;
+	aBlock->iNext = this;
+	iPrev = aBlock;
+	iNext = next;
+	if (next) next->iPrev = this;
+	}
+
+const TDesC16& CFileBlock::Text() const
+	{
+	ASSERT(IsLoaded()); // Otherwise shouldn't be calling this function
+	return *iData;
+	}
+
+CFileBlock* CFileBlock::Next() const
+	{
+	return iNext;
+	}
+
+CFileBlock* CFileBlock::Prev() const
+	{
+	return iPrev;
+	}
+
+TInt CFileBlock::BlockDidLoad(TEncodingType& aEncoding, TDelimiterType& aDelimType, const TDesC8& aData, CCnvCharacterSetConverter* aCharconvForUtf8Conversion)
+	{
+	ASSERT(!IsLoaded());
+	iData = HBufC::New(HasBeenLoaded() ? iNumCharacters : iBlockSize);
+	if (!iData) return KErrNoMemory;
+	
+	// For the duration of this function, iData is now defined to be this->iData->Des(). This saves me having to rewrite the rest of the function that is expecting iData to be an RBuf
+	TPtr iData = this->iData->Des();
+
+	iFlags.Set(EHasBeenLoaded);
+
+	TEncodingType& blockEncoding = aEncoding;
+
+	TBool bom = EFalse;
+	if (FilePosition() == 0)
+		{
+		// First block - check for BOM
+		TPtrC8 bomData = aData.Left(2);
+		if (bomData == KLittleEndianBom)
+			{
+			blockEncoding = EEncodingUtf16LE;
+			bom = ETrue;
+			}
+		else if (bomData == KBigEndianBom)
+			{
+			blockEncoding = EEncodingUtf16BE;
+			bom = ETrue;
+			}
+		else if (aData.Left(3) == KUtf8Bom)
+			{
+			blockEncoding = EEncodingUtf8;
+			bom = ETrue;
+			}
+		}
+	
+	switch (blockEncoding)
+		{
+		case EEncodingUtf16Native:
+			{
+			TPtrC16 wdata = TPtrC16((TUint16*)aData.Ptr(), aData.Size()/2);
+			if (bom) wdata.Set(wdata.Mid(1));
+			iData.Copy(wdata);
+			break;
+			}
+		case EEncodingUtf16Switched:
+			{
+			// There's a way to do this using charconv, but it's more effort to look it up than to byte-switch it myself
+			TPtrC16 wdata = TPtrC16((TUint16*)aData.Ptr(), aData.Size()/2);
+			if (bom) wdata.Set(wdata.Mid(1));
+			iData.Copy(wdata);
+			ByteSwitch((TUint16*)iData.Ptr(), iData.Length());
+			break;
+			}
+		case EEncodingNarrow:
+			// No attempt at conversion in this case
+			iData.Copy(aData);
+			break;
+		case EEncodingUtf8:
+		case EEncodingUnknown:
+			{
+			TPtrC8 data(aData);
+			if (bom) data.Set(data.Mid(3));
+			//TInt bytesLeft = CnvUtfConverter::ConvertToUnicodeFromUtf8(iData, data); <--- DOESN'T WORK!
+			TInt state = CCnvCharacterSetConverter::KStateDefault;
+			TInt numUnconverted = 0, firstUnconverted = -1;
+			TInt bytesLeft = -1;
+			if (aCharconvForUtf8Conversion)
+				{
+				// Can be null if charconv is busted
+				bytesLeft = aCharconvForUtf8Conversion->ConvertToUnicode(iData, data, state, numUnconverted, firstUnconverted);
+				ASSERT(bytesLeft <= 0); // Otherwise we didn't make our buffer big enough
+				// bytesLeft less than zero means an invalid sequence at the start of the buffer. Since our block size will never be so small there's no risk it's the start of a truncated sequence
+				}
+
+			if (bytesLeft < 0)
+				{
+				// It's just not UTF-8
+				iData.Copy(aData);
+				blockEncoding = EEncodingNarrow;
+				}
+			else if (firstUnconverted >= 0)
+				{
+				// Got some bad data
+				if (iNext && data.Length() - firstUnconverted < 4)
+					{
+					// Possibly a UTF-8 sequence spread over a block boundary
+					blockEncoding = EEncodingUtf8;
+					TInt err = iNext->TransferDataFromPreviousBlock(this, data.Mid(firstUnconverted));
+					if (!err)
+						{
+						iBlockSize = firstUnconverted;
+						}
+					iData.SetLength(iData.Locate(0xFFFD)); // No better way of figuring out where charconv barfed than to scan for the first instance of the substitution character
+					}
+				else
+					{
+					// It's just not UTF-8
+					iData.Copy(aData);
+					blockEncoding = EEncodingNarrow;
+					}
+				}
+			else
+				{
+				// it is conformant UTF-8, go with that for now. A future block could downgrade to narrow, if so no harm done (unless we had characters that appeared valid UTF-8 even though they weren't)
+				blockEncoding = EEncodingUtf8;
+				}
+			break;
+			}
+		default:
+			ASSERT(EFalse);
+		}
+
+	iNumCharacters = iData.Length();
+	if (!iFlags.IsSet(EHaveCalculatedLineEndings))
+		{
+		// Need to calculate num line endings
+		TInt numLineEndings = KMaxTInt;
+		CountNewLines(iData, numLineEndings, KMaxTInt, &aDelimType);
+		ASSERT(numLineEndings <= (TInt)KMaxTUint16); // Otherwise I've got some overflow-related badness
+		iNumLineEndings = numLineEndings;
+		iFlags.Set(EHaveCalculatedLineEndings);
+		}
+
+	if (iData.Length() && iData[iData.Length()-1] == '\r')
+		{
+		// uh oh, possible new line split over a block. To simplify matters we'll ensure this never happens, by moving the newline to the next block
+		TInt charLen = (blockEncoding == EEncodingUtf16LE || blockEncoding == EEncodingUtf16BE) ? 2 : 1;
+		if (iNext)
+			{
+			TInt err = iNext->TransferDataFromPreviousBlock(this, aData.Right(charLen));
+			if (err)
+				{
+				// The hell with it, we tried... (line counts will not be precise but otherwise shouldn't be the end of the world
+				}
+			else
+				{
+				iBlockSize -= charLen;
+				iNumCharacters--;
+				iNumLineEndings--;
+				iData.SetLength(iNumCharacters);
+				}
+			}
+		}
+
+	return KErrNone;
+	}
+
+TInt CFileBlock::CountNewLines(const TDesC& aDes, TInt& aTarget, TInt aSoftWrapLineLength, TDelimiterType* aDelimType)
+	{
+	ASSERT(aTarget != 0);
+	ASSERT(aSoftWrapLineLength > 0);
+	TBool countUp = aTarget > 0;
+	if (!countUp) aTarget = -aTarget;
+	TInt numFound = 0;
+	TInt lineLen = 0;
+	TBool foundDelim = EFalse;
+	if (aDelimType) *aDelimType = EDelimNotYetKnown;
+
+	for (TInt i = 0; i < aDes.Length(); i++)
+		{
+		TInt idx = (countUp ? i : aDes.Length()-1 - i);
+		TUint16 ch = aDes[idx];
+		TDelimiterType delim = EDelimNotYetKnown;
+
+		if (ch == '\r')
+			{
+			numFound++;
+			lineLen = 0;
+			if (countUp && i+1 < aDes.Length() && aDes[i+1] == '\n')
+				{
+				delim = EDelimCRLF;
+				i++; // Skip over the LF of a CRLF pair
+				idx++; // Idx needs to point to the END of the line ending
+				}
+			else
+				{
+				delim = EDelimCR;
+				}
+			}
+		else if (ch == '\n')
+			{
+			numFound++;
+			lineLen = 0;
+			if (!countUp && idx > 0 && aDes[idx-1] == '\r')
+				{
+				delim = EDelimCRLF;
+				i++; // Skip over the CR of a CRLF pair
+				// Don't modify idx, it is already pointing at the end character of the line ending
+				}
+			else
+				{
+				delim = EDelimLF;
+				}
+			}
+		else if (ch == KUnicodeLineBreak /*|| ch == KUnicodeParagraphBreak*/)
+			{
+			numFound++;
+			lineLen = 0;
+			delim = EDelimUnicode;
+			}
+		else
+			{
+			lineLen++;
+			}
+
+		if (lineLen == aSoftWrapLineLength)
+			{
+			//TODO fix this so that soft wraps are put in the correct place when iterating backwards
+			numFound++;
+			lineLen = 0;
+			}
+
+		if (!foundDelim && delim && aDelimType)
+			{
+			foundDelim = ETrue;
+			*aDelimType = delim;
+			}
+		if (numFound == aTarget)
+			{
+			return idx+1; // We return the index of the first character after the newline
+			}
+		}
+	aTarget = numFound;
+	return KErrNotFound;
+	}
+
+TInt CFileBlock::TransferDataFromPreviousBlock(CFileBlock* aPrev, const TDesC8& aData)
+	{
+	ASSERT(aPrev == iPrev);
+	ASSERT(!IsLoaded()); // We should only ever be doing a transfer the first time through the file. It's too complicated to update everything (char count, etc) if the block is already loaded
+
+	iBlockSize += aData.Length();
+	iFilePosition -= aData.Length();
+	return KErrNone;
+	}
+
+TInt CFileBlock::NewlineCount() const
+	{
+	ASSERT(HasBeenLoaded());
+	if (!iFlags.IsSet(EHaveCalculatedLineEndings))
+		{
+		// We don't know the line count
+		ASSERT(IsLoaded());
+		TInt numLineEndings = KMaxTInt;
+		CountNewLines(*iData, numLineEndings, KMaxTInt);
+		ASSERT(numLineEndings <= (TInt)KMaxTUint16); // Otherwise I've got some overflow-related badness
+		iNumLineEndings = numLineEndings;
+		iFlags.Set(EHaveCalculatedLineEndings);
+		}
+
+	return iNumLineEndings;
+	}
+
+TInt CFileBlock::CountNewLinesUpToOffset(TInt aOffset) const
+	{
+	ASSERT(IsLoaded());
+	// Don't try and be smart (yet)
+	TInt res = KMaxTInt;
+	CountNewLines(iData->Left(aOffset), res, KMaxTInt);
+	return res;
+	}
+
+void CFileBlock::InsertTextL(TInt aBlockOffset, const TDesC16& aText)
+	{
+	ASSERT(IsLoaded());
+	ASSERT(aBlockOffset <= iData->Length());
+	EnsureHBufCapacityL(iData, iData->Length() + aText.Length());
+	TPtr data = iData->Des();
+
+	// Ugh check we're not splitting a CRLF
+	if (aBlockOffset > 0 && aBlockOffset < data.Length() && data[aBlockOffset-1] == '\r' && data[aBlockOffset] == '\n')
+		{
+		aBlockOffset++;
+		}
+
+	data.Insert(aBlockOffset, aText);
+	iFlags.Clear(EHaveCalculatedLineEndings); // Don't recalculate until asked for
+	// iBlockSize is not updated until we save the file (as we don't know how much space it will take up until then)
+	// iNumCharacters is not updated because it's not needed while the block is loaded (plus, in case our data has exceeded KMaxTUint16)
+	iFlags.Set(EDirty);
+	}
+
+void CFileBlock::DeleteText(TInt aPos, TInt aLen)
+	{
+	ASSERT(IsLoaded());
+	TPtr data = iData->Des();
+	ASSERT(aPos >= 0);
+	ASSERT(aLen > 0);
+	ASSERT(aPos < data.Length());
+	ASSERT(aPos + aLen <= data.Length());
+
+	// Ugh check neither end of the range splits a CRLF
+	if (data[aPos] == '\n' && aPos > 0 && data[aPos-1] == '\r') { aPos--; aLen++; }
+	if (data[aPos+aLen-1] == '\r' && aPos + aLen < data.Length() && data[aPos+aLen] == '\n') aLen++; // Be greedy in both directions? Is this right?
+
+	data.Delete(aPos, aLen);
+	iFlags.Clear(EHaveCalculatedLineEndings); // Don't recalculate until asked for
+	iFlags.Set(EDirty);
+	}
+
+TInt CFileBlock::CharacterCount() const
+	{
+	ASSERT(HasBeenLoaded());
+	if (IsLoaded()) return Text().Length();
+	else return iNumCharacters;
+	}
+
+TInt CFileBlock::ReplaceAll(const TDesC& aFrom, const TDesC& aTo)
+	{
+	// Replace all occurences of aFrom with aTo, in iData
+	TInt pos = 0;
+	TInt lenDelta = -aFrom.Length() + aTo.Length();
+	while (ETrue)
+		{
+		TPtrC des(iData->Mid(pos));
+		TInt found = des.Find(aFrom);
+		if (found == KErrNotFound) break;
+		TInt idx = pos + found;
+		EnsureHBufCapacity(iData, iData->Length() + lenDelta);
+		iData->Des().Replace(idx, aFrom.Length(), aTo);
+		pos = idx + aTo.Length();
+		}
+	return KErrNone;
+	}
+
+TInt CFileBlock::ConvertToEightBit(TEncodingType aEncoding, TDelimiterType aDelimeter, RBuf8& aResultBuf)
+	{
+	ASSERT(IsLoaded());
+	aResultBuf.Zero();
+	// First, make sure the line endings are consistant
+	
+	_LIT(KCr, "\r");
+	_LIT(KCrLf, "\r\n");
+	_LIT(KLf, "\n");
+	_LIT(KUniNl, "\x2028");
+	//_LIT(KUniPara, "\x2029");
+	// This could benefit from some optimisation, it is at least easy to understand
+	TInt err = KErrNone;
+	switch(aDelimeter)
+		{
+		case EDelimCR:
+			ReplaceAll(KCrLf, KCr);
+			ReplaceAll(KLf, KCr);
+			ReplaceAll(KUniNl, KCr);
+			break;
+		case EDelimLF:
+			ReplaceAll(KCrLf, KLf);
+			ReplaceAll(KCr, KLf);
+			ReplaceAll(KUniNl, KLf);
+			break;
+		case EDelimUnicode:
+			ReplaceAll(KCrLf, KUniNl);
+			ReplaceAll(KCr, KUniNl);
+			ReplaceAll(KLf, KUniNl);
+			break;
+		case EDelimCRLF:
+			// Easiest to replace everything (including CRLFs) with a single-character sequence, then replace that to CRLF at the end. This avoids having to figure out if a CR is part of a CRLF, etc
+			ReplaceAll(KCrLf, KUniNl);
+			ReplaceAll(KCr, KUniNl);
+			ReplaceAll(KLf, KUniNl);
+			err = ReplaceAll(KUniNl, KCrLf); // This one could actually need an alloc as the string could be bigger
+			if (err) return err;
+			break;
+		default:
+			__DEBUGGER();
+			break;
+		}
+
+	switch (aEncoding)
+		{
+		case EEncodingUtf16Native:
+		case EEncodingUtf16Switched:
+			{
+			TBool needBom = (FilePosition() == 0);
+			TPtrC8 narrowData = TPtrC8((TUint8*)iData->Ptr(), iData->Size());
+			TInt requiredLen = narrowData.Length();
+			if (needBom) requiredLen += 2;
+			EnsureCapacity(aResultBuf, requiredLen);
+			if (needBom) aResultBuf.Append(KNativeBom);
+			aResultBuf.Append(narrowData);
+			if (aEncoding == EEncodingUtf16Switched)
+				{
+				ByteSwitch((TUint16*)aResultBuf.Ptr(), requiredLen);
+				}
+			break;
+			}
+		case EEncodingNarrow:
+			// No attempt at conversion in this case
+			EnsureCapacity(aResultBuf, iData->Length());
+			aResultBuf.Copy(*iData);
+			break;
+		case EEncodingUtf8:
+			{
+			EnsureCapacity(aResultBuf, iData->Length() * 4); // Worst case for UTF-8 is 4 bytes per character
+			TInt result = CnvUtfConverter::ConvertFromUnicodeToUtf8(aResultBuf, *iData);
+			if (result > 0) return KErrCorrupt;
+			if (result < 0) return result;
+			break;
+			}
+		default:
+			ASSERT(EFalse);
+		}
+
+	if (iData->Length() > (TInt)KMaxTUint16 || aResultBuf.Length() > (TInt)KMaxTUint16)
+		{
+		// Oh dear we've blown our (self-imposed) limit on how big iNumCharacters and iBlockSize can get
+		// Split the block and try again
+		TInt err = SplitBufferAt(iData->Length()/2);
+		if (err) return err;
+		else return ConvertToEightBit(aEncoding, aDelimeter, aResultBuf);
+		}
+	iBlockSize = aResultBuf.Length(); // Now we know how big the block will be when it gets written back to disk
+	return KErrNone;
+	}
+
+void CFileBlock::FileHasBeenSaved()
+	{
+	ASSERT(iPrev == NULL); // Should only call on the first block
+	TInt filePos = 0;
+	CFileBlock* block = this;
+	while (block)
+		{
+		block->iFilePosition = filePos;
+		block->iFlags.Clear(EDirty);
+		filePos = filePos + block->BlockSize(); // File positions need updating in light of how block sizes may have changed (the blocksize is set to the correct value at the end of ConvertToEightBit)
+		block = block->Next();
+		}
+	}
+
+TInt CFileBlock::SplitBufferAt(TInt aCharacterPosition)
+	{
+	ASSERT(IsLoaded());
+	ASSERT(iData);
+
+	if (aCharacterPosition > iData->Length()) aCharacterPosition = iData->Length();
+	// Ugh check we're not splitting a CRLF
+	if (aCharacterPosition > 0 && (*iData)[aCharacterPosition-1] == '\r' && (*iData)[aCharacterPosition] == '\n')
+		{
+		aCharacterPosition++;
+		}
+
+	CFileBlock* newBlock = new CFileBlock(-1, 1); // Neither file position nor blocksize is important for a block that is dirty, and this block will be created dirty
+	if (!newBlock) return KErrNoMemory;
+	newBlock->iFlags.Set(EDirty);
+	newBlock->iFlags.Set(EHasBeenLoaded);
+
+	TPtrC dataToMove = iData->Mid(aCharacterPosition);
+	newBlock->iData = HBufC::New(dataToMove.Length());
+	if (!newBlock->iData)
+		{
+		delete newBlock;
+		return KErrNoMemory;
+		}
+	newBlock->iData->Des().Copy(dataToMove);
+	// That's it bar the shouting
+	iData->Des().SetLength(aCharacterPosition);
+	iFlags.Set(EDirty); // We have to do this because we've invalidated iBlockSize (we can't just update iBlockSize because we don't know how many bytes aCharacterPosition corresponds to).
+	newBlock->iPrev = this;
+	newBlock->iNext = iNext;
+	iNext->iPrev = newBlock;
+	iNext = newBlock;
+	return KErrNone;
+	}
+
+void ByteSwitch(TUint16* data, TInt aLen)
+	{
+	const TUint16* endp = data + aLen;
+	while (data < endp)
+		{
+		TUint16 ch = *data;
+		*data = (ch>>8) | ((ch & 0xFF) << 8);
+		data++;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/lrtextview.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1120 @@
+// lrtextview.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "lrtextview.h"
+#include <e32cons.h>
+#include "filebuffer.h"
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+
+const TInt KLastCtrlChar = 0x1f;	//Last control char in ASCII
+const TInt KCtrlHTab = 0x09;		//Horizontal Tab
+
+CLRTextView* CLRTextView::NewL(MConsoleProvider& aConsoleProvider, CFedBufferBase& aBuffer)
+	{
+	CLRTextView* self = new (ELeave) CLRTextView(aConsoleProvider, aBuffer);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CLRTextView::~CLRTextView()
+	{
+	delete iLineData;
+	delete iMarkFlasher;
+	}
+
+CLRTextView::CLRTextView(MConsoleProvider& aConsoleProvider, CFedBufferBase& aBuffer)
+	: CTextView(aConsoleProvider, aBuffer), iMarkDocPos(-1), iOldNextLine(-1)
+	{
+	}
+
+void CLRTextView::ConstructL()
+	{
+	iLineData = new(ELeave) CLineData;
+	CTextView::ConstructL();
+	iMarkFlasher = CPeriodic::NewL(CActive::EPriorityStandard);
+	}
+
+//MDeferredClose
+TBool CLRTextView::TryCloseL()
+	{
+	if (!iBuffer.Modified())
+		{
+		return ETrue; // Ok to close now
+		}
+	else
+		{
+		TKeyCode ch = iConsoleProvider.Query(_L("Save changes to file? (yes/no/cancel) "), _L("ync\x1B"));
+		if (ch == 'c' || ch == EKeyEscape) return EFalse;
+		if (ch == 'y')
+			{
+			TInt err = Save();
+			if (err) return EFalse; // Don't allow exit if the save failed
+			}
+		return ETrue;
+		}
+	}
+
+TInt CLRTextView::Save()
+	{
+	if (!iBuffer.Editable() || iLineIsErrorMessage) return KErrNotSupported;
+	
+	CancelMark();
+	TBool wasOpen = iBuffer.IsOpen();
+	TInt err = KErrNone;
+	const TDesC& name = iBuffer.Title();
+	if (name.Length())
+		{
+		iConsoleProvider.InfoPrint(_L("Saving"));
+		TRAP(err, iBuffer.SaveL(name, ETrue));
+		HandleSaveResult(err, wasOpen, iBuffer.Title());
+		return err;
+		}
+	else
+		{
+		return SaveAs();
+		}
+	}
+
+TInt CLRTextView::SaveAs()
+	{
+	if (!iBuffer.Editable() || iLineIsErrorMessage) return KErrNotSupported;
+	
+	CancelMark();
+	TBool wasOpen = iBuffer.IsOpen();
+	TFileName name = iBuffer.Title();
+	TInt err = KErrCancel;
+	TBool go = iConsoleProvider.QueryFilename(_L("Save as: "), name);
+	if (go)
+		{
+		iConsoleProvider.InfoPrint(_L("Saving"));
+		TRAP(err, iBuffer.SaveL(name, EFalse));
+		if (err == KErrAlreadyExists)
+			{
+			if (iConsoleProvider.Query(_L("File already exists. Replace? (yes/no) "), _L("yn")) == 'y')
+				{
+				iConsoleProvider.InfoPrint(_L("Saving"));
+				TRAP(err, iBuffer.SaveL(name, ETrue));
+				}
+			}
+		HandleSaveResult(err, wasOpen, iBuffer.Title());
+		}
+	return err;
+	}
+
+void CLRTextView::HandleSaveResult(TInt aError, TBool aWasOpen, const TDesC& aName)
+	{
+	if (aError == KErrNone)
+		{
+		TRAP_IGNORE(DoRedrawL()); // Not only can QueryFilename mess up the screen, saving the file could change the line endings and thus change the character counts, meaning we need to recalculate & redraw
+		iConsoleProvider.InfoPrint(_L("Save succeeded"));
+		}
+	else if (aWasOpen && !iBuffer.IsOpen())
+		{
+		// An error occurred after the original file was closed. This is fatal so we need to put up a dialog to that effect
+		iLine.Format(_L("Temp file @ %S"), &aName);
+		iLineIsErrorMessage = ETrue;
+		UpdateStatus();
+		iConsoleProvider.InfoPrint(_L("Failed to rename temp file (%d)"), aError);
+		}
+	else
+		{
+		// Failed to save, but we didn't mess with the original so we can carry on using it
+		TRAP_IGNORE(DoRedrawL()); // Not only can QueryFilename mess up the screen, saving the file could change the line endings and thus change the character counts, meaning we need to recalculate & redraw
+		switch (aError)
+			{
+			case KErrDiskFull:
+				iConsoleProvider.InfoPrint(_L("Disk full, couldn't save file"));
+				break;
+			case KErrNoMemory:
+				iConsoleProvider.InfoPrint(_L("Out of memory!"));
+				break;
+			case KErrPathNotFound:
+				iConsoleProvider.InfoPrint(_L("KErrPathNotFound. Directory doesn't exist?"));
+				break;
+			case KErrGeneral:
+				iConsoleProvider.InfoPrint(_L("Couldn't save file. No idea why"));
+				break;
+			case KErrBadName:
+				iConsoleProvider.InfoPrint(_L("Bad file name"));
+				break;
+			case KErrAccessDenied:
+				iConsoleProvider.InfoPrint(_L("Access denied. Read-only file or disk?"));
+				break;
+			default:
+				iConsoleProvider.InfoPrint(_L("Unable to save file: %d"), aError);
+				break;
+			}
+		}
+	}
+
+//MKeyConsumer
+TBool CLRTextView::ConsumeKeyL(const TKeyCode& aCode)
+	{
+	TBool handled = ETrue;
+	switch(aCode)
+		{
+		case EKeyUpArrow:
+			MoveCursor(0, -1); break;
+		case EKeyDownArrow:
+			MoveCursor(0, 1); break;
+		case EKeyLeftArrow:
+			MoveCursor(-1, 0); break;
+		case EKeyRightArrow:
+			MoveCursor(1, 0); break;
+		case EKeyPageUp:
+		case CTRL('u'):
+			MoveCursor(0, -iWindow.iHeight); break;
+		case EKeyPageDown:
+		case CTRL('d'):
+			MoveCursor(0, iWindow.iHeight); break;
+		case EKeyHome:
+			UpdateCursor(TPoint(0, iCursor.iY));
+			break;
+		case CTRL('t'):
+			iCursor.SetXY(0, 0);
+			RequestData(ETrue, 0); break;
+		case CTRL('b'):
+			GoToLine(KMaxTInt); break;
+		case EKeyEnd:
+			{
+			TInt pos = iLineData->LastValidPosition(iCursor.iY);
+			UpdateCursor(TPoint(pos, iCursor.iY));
+			break;
+			}
+		case EKeyBackspace:
+			DeleteTextL(-1);
+			break;
+		case EKeyDelete:
+			DeleteTextL(1);
+			break;
+		case CTRL('s'):
+			Save();
+			break;
+		case CTRL('a'):
+			SaveAs();
+			break;
+		case CTRL('k'):
+			DeleteCurrentLineL();
+			break;
+		case CTRL('g'):
+			GoToLine();
+			break;
+		case CTRL('f'):
+			Find();
+			break;
+		case CTRL('v'):
+			PasteL();
+			break;
+		case CTRL('c'):
+			if (MarkActive()) CopyOrCutL(EFalse);
+			else SetMark();
+			break;
+		case CTRL('x'):
+			if (MarkActive()) CopyOrCutL(ETrue);
+			else SetMark();
+			break;
+		default:
+			handled = EFalse;
+			break;
+		}
+
+	if (!handled && (aCode == EKeyEnter || aCode == EKeyTab || TChar(aCode).IsPrint()))
+		{
+		TBuf<1> buf;
+		buf.Append(aCode);
+		InsertTextL(buf);
+		handled = ETrue;
+		}
+	return handled;
+}
+
+void CLRTextView::MoveCursor(TInt aX, TInt aY)
+	{
+	if (aX) ASSERT(aY == 0);
+	if (aY) ASSERT(aX == 0); // Can't handle moving in both axes at once
+
+	TInt line = iCursor.iY;
+	TInt dir = (aX > 0) ? 1 : -1;
+	TInt newX = iCursor.iX;
+	while (aX)
+		{
+		newX += dir;
+		if (newX < 0)
+			{
+			// Move to end of previous line
+			newX = iWindow.iWidth; // Validate cursor will fix this, in the case where this causes us to scroll up a line
+			aY--;
+			break; // We don't really support seeking further than one line either way
+			}
+		else if (newX >= iWindow.iWidth-1)
+			{
+			// Move to start of next line
+			newX = 0;
+			aY++;
+			break; // We don't really support seeking further than one line either way
+			}
+
+		if (iLineData->IsScreenPositionValid(line, newX))
+			{
+			aX -= dir;
+			}
+		}
+
+	if (line + aY < 0)
+		{
+		// Scroll up
+		SeekData(iLineData->DocumentPosition(0), aY);
+		}
+	else if (line + aY >= iWindow.iHeight)
+		{
+		// Scroll down
+		SeekData(iLineData->DocumentPosition(0), aY);
+		}
+	else
+		{
+		// Just update cursor
+		if (iLineData->IsScreenPositionValid(line + aY, 0))
+			{
+			// If the line len is -1 it means the doc doesn't extend as far as this line, therefore we shouldn't allow the cursor to be moved to it
+			UpdateCursor(TPoint(newX, iCursor.iY + aY));
+			}
+		}
+	}
+
+void CLRTextView::DoResizeL(const TWindow& /*aOldWindow*/)
+	{
+	DoRedrawL();
+	}
+
+void CLRTextView::DoRedrawL()
+	{
+	iLineData->EnsureCapacityL(iWindow.iWidth, iWindow.iHeight);
+	ValidateCursor();
+	RequestData(ETrue, iLineData->DocumentPosition(0));
+	}
+
+void CLRTextView::DoDrawL()
+	{
+	DoDrawL(iRecursiveUpdateFlag ? *iRecursiveUpdateFlag : ETrue);
+	}
+
+void CLRTextView::DoDrawL(TBool aUpdateCursorAndStatus)
+	{
+	if (iDrawPoint == TPoint(iWindow.iX, iWindow.iY))
+		{
+		iLineData->SetDocumentPositionForLine(0, iRange.iLocation);
+		iLineData->SetFileLineNumberForLine(0, iRangeStartLineNumber);
+		}
+
+	ASSERT(iRange.iLength == iDes.Length());
+	HideCursor(); // Don't show the cursor while we're moving it around drawing - will be shown again by UpdateCursor
+	for (iCurrentDrawDocIndex = 0; iCurrentDrawDocIndex < iDes.Length(); iCurrentDrawDocIndex++)
+		{
+		TUint16 c = iDes[iCurrentDrawDocIndex];
+		if(iDrawPoint.iY >= iWindow.NextY())
+			{
+			break;
+			}
+		if(c <= KLastCtrlChar)
+			HandleControlChar();
+		else
+			AppendChar(c);
+		}
+
+	TBool moreData = !iBuffer.DocumentPositionIsEof(iRange.Max());
+	TBool filledScreen = iDrawPoint.iY >= iWindow.NextY();
+	if (!filledScreen)
+		{
+		WriteChars();
+		LineFinished();
+		}
+	if (!moreData)
+		{
+		iDrawPoint.iY++; // Start from the line *after* the line we were on
+		// In the case where we've finished writing but haven't filled the screen, we need to blank the rest of it (because to avoid flicker we don't do ClearScreens)
+		while (iDrawPoint.iY < iWindow.NextY())
+			{
+			iDrawPoint.iX = iWindow.iX;
+			iLine.Copy(_L("^"));
+			WriteChars();
+			TInt lineNum = iDrawPoint.iY - iWindow.iY;
+			iLineData->SetDocumentPositionForLine(lineNum+1, iLineData->DocumentPosition(lineNum));
+			iLineData->SetFileLineNumberForLine(lineNum, -1);
+			iLineData->LineFinishedAt(lineNum, -1);
+			iDrawPoint.iY++;
+			}
+		}
+
+	if (filledScreen || !moreData)
+		{
+		// Finished - null iDes and restore cursor
+		iDes.Set(NULL, 0);
+		if (aUpdateCursorAndStatus)
+			{
+			UpdateCursor(iCursor);
+			}
+		}
+	else
+		{
+		TBool flagSet = EFalse;
+		if (!iRecursiveUpdateFlag)
+			{
+			iRecursiveUpdateFlag = &aUpdateCursorAndStatus;
+			flagSet = ETrue;
+			}
+		// More data needed to fill the screen
+		RequestData(EFalse, iRange.Max());
+		if (flagSet) iRecursiveUpdateFlag = NULL;
+		}
+}
+
+void CLRTextView::ValidateCursor()
+	{	
+	CTextView::ValidateCursor();
+	TInt maxX = iWindow.iWidth - 1;
+	TInt line = iCursor.iY;
+	while (iCursor.iX > 0 && !iLineData->IsScreenPositionValid(line, iCursor.iX))
+		{
+		// In case the cursor ended up in the dead space in the middle of a tab character
+		iCursor.iX--;
+		}
+	while (line > 0 && !iLineData->IsScreenPositionValid(line, 0))
+		{
+		// In case the cursor has ended up in dead space
+		iCursor.iY--;
+		line--;
+		}
+	maxX = iLineData->LastValidPosition(line);
+	if(iCursor.iX > maxX)
+		iCursor.iX = maxX;
+	}
+
+void CLRTextView::HandleControlChar()
+	{
+	TUint8 c = iDes[iCurrentDrawDocIndex];
+	if (c == KCtrlHTab)
+		{
+		TInt pos = iDrawPoint.iX - iWindow.iX + iLine.Length();
+		TInt numToWrite = TabWidth() - (pos % TabWidth()); // Tabs align to 4-column boundaries rather than just outputting 4 spaces
+		numToWrite = Min(numToWrite, iWindow.iWidth-1-pos); // In case the tab causes a line continuation, we want to make sure the tab ends at the end of the line so the following character will start at column zero
+		for(TInt i=0; i<numToWrite; i++)
+			{
+			TInt line = iDrawPoint.iY - iWindow.iY;
+			TInt col = iDrawPoint.iX - iWindow.iX + iLine.Length();
+			AppendChar(' ');
+			if (i > 0) iLineData->SetPositionIsValid(line, col, EFalse); // i==0 (ie the first screen position of the tab) is a valid place to move the cursor to
+			}
+		}
+	else if (c == '\r')
+		{
+		if (iCurrentDrawDocIndex+1 < iDes.Length() && iDes[iCurrentDrawDocIndex+1] == '\n') iCurrentDrawDocIndex++; // Skip over the CR to the LF
+		WriteLine();
+		}
+	else if (c == '\n')
+		{
+		WriteLine();
+		}
+	else
+		{
+		// unknown control char - so escape it
+		AppendChar('.');
+		}
+	}
+
+void CLRTextView::AppendChar(TUint16 aChar)
+	{
+	iLine.Append(TChar(aChar));
+	iLineData->SetPositionIsValid(iDrawPoint.iY - iWindow.iY, iDrawPoint.iX - iWindow.iX + iLine.Length(), ETrue);
+	if(iDrawPoint.iX + iLine.Length() == iWindow.NextX()-1)
+		{
+		WriteChars();
+		WriteLineContinue();
+		GoToNextLine();
+		}
+	}
+
+//Writes the current line on the screen and moves to the next verse and line
+void CLRTextView::WriteLine()
+	{
+	TInt thisLine = iDrawPoint.iY-iWindow.iY;
+	WriteChars();
+	GoToNextLine();
+	iLineData->SetFileLineNumberForLine(thisLine+1, iLineData->FileLineNumber(thisLine) + 1);
+	if (iOldNextLine != -1 && thisLine+1 == iOldNextLine && iLineData->DocumentPosition(iOldNextLine) == iOldNextLineDocPos + iPredictedOldNextLineDocPosDelta)
+		{
+		// We have drawn everything we need to, and the drawing didn't cause the former next line to move
+		iDrawPoint.iY = iWindow.NextY();
+		UpdateDocumentPositionsStartingAtLine(iOldNextLine+1, iPredictedOldNextLineDocPosDelta);
+		}
+	iOldNextLine = -1;
+	}
+
+//Writes the current line on the screen
+void CLRTextView::WriteChars()
+	{
+	/* As an performance optimisation, we avoid calling ClearScreen when redrawing. Therefore we must ensure we 
+	 * write to the entire line to prevent artifacts. 
+	 *
+	 * There are 2 approaches to this - either using CConsoleBase::ClearToEndOfLine or padding the line with 
+	 * spaces up to the window width. ClearToEndOfLine is really slow in WINSCW tshell which is why it's not
+	 * used by default. On target it's probably more efficient to use it.
+	 */
+	TPoint drawPoint(iDrawPoint);
+	TPoint endPoint(drawPoint.iX + iLine.Length(), drawPoint.iY);
+	iConsole.SetCursorPosAbs(drawPoint);
+#ifdef FSHELL_WSERV_SUPPORT
+// text windowserver is really slow at ClearToEndOfLine
+#define USE_CLEARTOENDOFLINE
+#endif
+#ifdef USE_CLEARTOENDOFLINE
+	iConsole.Write(iLine);
+	iConsole.ClearToEndOfLine();
+#else
+	iLine.AppendFill(' ', iWindow.iWidth - (iDrawPoint.iX-iWindow.iX) - iLine.Length());
+	iConsole.Write(iLine);
+#endif
+	iLine.Zero();
+	// Remember to reset the console pos and the drawpoint to the end of the line proper in case the WriteChars 
+	// was to half a line and the rest of the line is in another block.
+	iDrawPoint = endPoint;
+	iConsole.SetCursorPosAbs(iDrawPoint);
+	}
+
+// Moves to the next screen line but doesn't move to the next file line (used when a line is longer than the width of the window)
+void CLRTextView::GoToNextLine()
+	{
+	LineFinished();
+	iDrawPoint.iX = iWindow.iX;
+	iDrawPoint.iY++;
+	iLineData->SetPositionIsValid(iDrawPoint.iY-iWindow.iY, 0, ETrue);
+	}
+
+void CLRTextView::LineFinished()
+	{
+	TInt currentLine = iDrawPoint.iY - iWindow.iY;
+	if (currentLine == iWindow.iHeight) return; // This can happen (and is ok) when drawing the last line of the screen
+	iLineData->LineFinishedAt(currentLine, iDrawPoint.iX - iWindow.iX);
+	iLineData->SetDocumentPositionForLine(currentLine+1, iRange.iLocation+iCurrentDrawDocIndex+1); // Plus one cos we haven't drawn the first character of the next line yet
+	}
+
+void CLRTextView::WriteLineContinue()
+	{
+	CColorConsoleBase* cons = iConsoleProvider.ColorConsole();
+	if (cons) cons->SetTextAttribute(ETextAttributeHighlight);
+	_LIT(KContinuation, "\\");
+	iConsole.Write(KContinuation);
+	if (cons) cons->SetTextAttribute(ETextAttributeNormal);
+
+	TInt thisLine = iDrawPoint.iY-iWindow.iY;
+	iLineData->SetFileLineNumberForLine(thisLine+1, iLineData->FileLineNumber(thisLine)); // The new line has the same file number as the current line, because it's a continuation line
+	}
+
+TInt CLRTextView::DocumentPosition() const
+	{
+	TInt line = iCursor.iY;
+	TInt pos = iLineData->DocumentPosition(line);
+	for (TInt i = 0; i < iCursor.iX; i++)
+		{
+		if (iLineData->IsScreenPositionValid(line, i)) pos++;
+		}
+	return pos;
+	}
+
+void CLRTextView::InsertTextL(const TDesC& aText)
+	{
+	if (!iBuffer.Editable() || iLineIsErrorMessage) return;
+	
+	CancelMark();
+	TInt pos = DocumentPosition();
+	iBuffer.InsertTextL(pos, aText);
+	if (iCursor.iX == iWindow.iWidth-1)
+		{
+		// If the cursor is over a line continuation character (which it will be if it gets to this value) move cursor to the real insertion point at the start of the next line before doing anything - makes the logic much easier!
+		MoveCursor(1, 0);
+		}
+
+	// If we can be sure it won't cause a reflow, shortcut the requesting and redrawing mechanism, for performance reasons
+	TPoint cursorPos = WindowLocationForDocumentPosition(pos);
+	TInt lineNum = cursorPos.iY;
+	TBool posWasAtEndOfLine = cursorPos.iX == iLineData->LastValidPosition(lineNum) && cursorPos.iX + aText.Length() < iWindow.iWidth-1;
+	if (posWasAtEndOfLine && aText.Locate('\t') == KErrNotFound && aText.Locate('\r') == KErrNotFound)
+		{
+		// Can't optimise if the text contains tabs or newlines, we need to do the full algorithm in that case
+		iConsole.Write(aText);
+		for (TInt i = 0; i < aText.Length(); i++)
+			{
+			iLineData->SetPositionIsValid(lineNum, cursorPos.iX + 1 + i, ETrue); // Each added char makes the character position one after that character valid
+			}
+		for (TInt l = lineNum+1; l <= iWindow.iHeight; l++)
+			{
+			iLineData->SetDocumentPositionForLine(l, iLineData->DocumentPosition(l) + aText.Length());
+			}
+		MoveCursor(aText.Length(),0);
+		}
+	else
+		{
+		RedrawFromPositionToEndOfLine(pos, aText.Length());
+		CenterDocPosOnScreen(pos + aText.Length());
+		}
+	}
+
+void CLRTextView::RedrawFromPositionToEndOfLine(TInt aDocumentPosition, TInt aNumCharsInserted)
+	{
+	TPoint point = WindowLocationForDocumentPosition(aDocumentPosition);
+	ASSERT(point.iY >= 0);
+	iDrawPoint = point + iWindow.Origin();
+	// Try and avoid redrawing the whole screen if the RequestData doesn't make the line longer (in terms of screen lines)
+	TInt lastScreenLineForCurrentLine = point.iY;
+	while (iLineData->FileLineNumber(lastScreenLineForCurrentLine+1) == iLineData->FileLineNumber(lastScreenLineForCurrentLine))
+		{
+		// We have to allow for the current line wrapping onto additional screen lines
+		lastScreenLineForCurrentLine++;
+		}
+	iOldNextLine = lastScreenLineForCurrentLine + 1;
+	iOldNextLineDocPos = iLineData->DocumentPosition(iOldNextLine);
+	iPredictedOldNextLineDocPosDelta = aNumCharsInserted;
+	RequestData(EFalse, aDocumentPosition);
+	}
+
+void CLRTextView::DeleteTextL(TInt aNumChars)
+	{
+	if (!iBuffer.Editable() || iLineIsErrorMessage) return;
+
+	CancelMark();
+	ASSERT(aNumChars >= -1); // Can't backspace more than one character
+	TInt pos = DocumentPosition();
+	TRange range;
+	if (aNumChars < 0)
+		range = TRange(pos + aNumChars, -aNumChars);
+	else
+		range = TRange(pos, aNumChars);
+	range.Intersect(TRange(0, KMaxTInt)); // Clamp the range to zero
+
+	if (range.iLength)
+		{
+		iBuffer.DeleteTextL(range);
+		TInt line = iCursor.iY;
+		if (aNumChars == -1) MoveCursor(-1, 0);
+		// Seems to be an issue using RedrawFromPositionToEndOfLine when deleting from the start of a line - since we know it wouldn't be worth using it in that case, don't do it.
+		if (iCursor.iY == line && aNumChars == -1)
+			{
+			RedrawFromPositionToEndOfLine(range.iLocation, -range.iLength);
+			}
+		else
+			{
+			iDrawPoint = iCursor + iWindow.Origin();
+			RequestData(EFalse, DocumentPosition());
+			}
+		}
+	}
+
+void CLRTextView::DeleteCurrentLineL()
+	{
+	if (!iBuffer.Editable() || iLineIsErrorMessage) return;
+
+	CancelMark();
+	TInt currentLine = iCursor.iY;
+	TInt lineStart = iLineData->DocumentPosition(currentLine);
+	TInt lineLen = iLineData->DocumentPosition(currentLine+1) - lineStart;
+	if (lineLen > 0)
+		{
+		TRange range(lineStart, lineLen);
+		iBuffer.DeleteTextL(range);
+		iDrawPoint = TPoint(iWindow.iX, iWindow.iY + iCursor.iY);
+		RequestData(EFalse, lineStart);
+		}
+	}
+
+void CLRTextView::UpdateCursor(const TPoint& aNewPos)
+	{
+	CTextView::UpdateCursor(aNewPos);
+	UpdateStatus();
+	}
+
+void CLRTextView::UpdateStatus()
+	{
+	if (iLineIsErrorMessage)
+		{
+		iConsoleProvider.WriteStatus(iLine, KNullDesC);
+		return;
+		}
+
+	_LIT(KUnknownDelim, "CRLF"); // Since that's what it will get output as
+	_LIT(KUnknownEnc, "UTF-8"); // ditto
+	const TDesC* lineEnding = &KUnknownDelim;
+#define CASE_LIT(res, x, y) case x: { _LIT(KName, y); res = &KName; break; }
+	switch(iBuffer.DelimiterType())
+		{
+		CASE_LIT(lineEnding, EDelimLF, "LF")
+		CASE_LIT(lineEnding, EDelimCR, "CR")
+		CASE_LIT(lineEnding, EDelimCRLF, "CRLF")
+		CASE_LIT(lineEnding, EDelimUnicode, "UniLF")
+		default:
+			break;
+		}
+	const TDesC* encoding = &KUnknownEnc;
+	switch (iBuffer.Encoding())
+		{
+		CASE_LIT(encoding, EEncodingNarrow, "8-bit")
+		CASE_LIT(encoding, EEncodingUtf8, "UTF-8")
+		CASE_LIT(encoding, EEncodingUtf16LE, "UTF-16LE")
+		CASE_LIT(encoding, EEncodingUtf16BE, "UTF-16BE")
+		default:
+			break;
+		}
+
+	const TDesC* modified = &KNullDesC;
+	if (iBuffer.Modified())
+		{
+		_LIT(KMod, "(*)");
+		modified = &KMod;
+		}
+
+	TInt currentLine = iLineData->FileLineNumber(iCursor.iY) + 1; // Human-readable line numbers are always shown as 1-based
+	TInt currentCol = iCursor.iX + 1; // Human-readable col numbers are always shown as 1-based, annoying as it is we will do the same
+	TInt docPos = DocumentPosition();
+	_LIT(KStatus, "%S %S %S Ln:%d Col:%d Char:%d");
+	_LIT(KShortStatus, "%S %S %S Ln:%d");
+	_LIT(KMarkStatus, "Mark@%d. ^X/^C to complete. Ln:%d Ch:%d");
+	const TDesC* title = &iBuffer.Title();
+	_LIT(KUntitled, "untitled");
+	if (title->Length() == 0) title = &KUntitled;
+	if (MarkActive())
+		{
+		iConsoleProvider.WriteStatus(KNullDesC, KMarkStatus, iMarkDocPos, currentLine, docPos);
+		}
+	else if (iConsole.ScreenSize().iWidth < 50)
+		{
+		iConsoleProvider.WriteStatus(*title, KShortStatus, modified, lineEnding, encoding, currentLine);
+		}
+	else
+		{
+		iConsoleProvider.WriteStatus(*title, KStatus, modified, lineEnding, encoding, currentLine, currentCol, docPos);
+		}
+	}
+
+void CLRTextView::GoToLine()
+	{
+	TBuf<32> lineText;
+	TBool go = iConsoleProvider.QueryText(_L("Go to line: "), lineText);
+	if (go == EFalse) return;
+
+	TLex lex(lineText);
+	TBool gotoLine = ETrue;
+	if (lex.Peek() == 'c')
+		{
+		// Go to character pos
+		lex.Inc();
+		gotoLine = EFalse;
+		}
+
+	TInt pos;
+	TInt err = lex.Val(pos);
+	if (err || pos <= 0)
+		{
+		iConsoleProvider.InfoPrint(_L("Couldn't parse line number '%S'"), &lineText);
+		return;
+		}
+
+	if (gotoLine && pos > 1)
+		{
+		GoToLine(pos-1); // -1 to change 1-based display number to internal 0-based.
+		}
+	else
+		{
+		CenterDocPosOnScreen(pos-1);
+		}
+	}
+
+void CLRTextView::GoToLine(TInt aLine)
+	{
+	TInt err = iBuffer.SeekFromOffset(*this, 0, aLine, KMaxTInt); 
+	if (err)
+		{
+		HandleDataLoadError(err);
+		}
+	else
+		{
+		CenterDocPosOnScreen(iRange.iLocation);
+		}
+	}
+
+void CLRTextView::Find()
+	{
+	TBool searchBackwards = EFalse;
+	TBool proceed = iConsoleProvider.QueryText(_L("Find text: "), iFindText);
+	while (proceed)
+		{
+		TInt nextLineStart = iLineData->DocumentPosition(iCursor.iY + 1);
+		iConsoleProvider.InfoPrint(_L("Searching..."));
+		TInt found = iBuffer.Find(nextLineStart, iFindText, searchBackwards);
+		if (found == KErrNotFound)
+			{
+			iConsoleProvider.InfoPrint(_L("Cannot find '%S'"), &iFindText);
+			proceed = EFalse;
+			}
+		else if (found < 0)
+			{
+			iConsoleProvider.InfoPrint(_L("Error during searching: %d"), found);
+			proceed = EFalse;
+			}
+		else
+			{
+			CenterDocPosOnScreen(found);
+			/*TKeyCode ch = iConsoleProvider.Query(_L("Search again? (next/previous/cancel) "));
+			if (ch == 'n')
+				{
+				searchBackwards = EFalse;
+				continue;
+				}
+			else if (ch == 'p')
+				{
+				searchBackwards = ETrue;
+				continue;
+				}
+			else*/
+				{
+				proceed = EFalse;
+				}
+			}
+		}
+	}
+
+void CLRTextView::CenterDocPosOnScreen(TInt aDocumentPosition)
+	{
+	const TInt numScreenLines = iWindow.iHeight;
+	TPoint point = WindowLocationForDocumentPosition(aDocumentPosition);
+	if (point.iY != -1)
+		{
+		// pos is on screen already - just move the cursor
+		UpdateCursor(point);
+		return;
+		}
+
+	TInt err = iBuffer.SeekFromOffset(*this, aDocumentPosition, -(numScreenLines/2), iWindow.iWidth-1);
+	if (err)
+		{
+		HandleDataLoadError(err);
+		}
+	else
+		{
+		iDrawPoint.SetXY(iWindow.iX, iWindow.iY);
+		DoDrawL(EFalse); // EFalse to say we will update the cursor and status ourselves
+		UpdateCursor(WindowLocationForDocumentPosition(aDocumentPosition));
+		}
+	}
+
+void CLineData::EnsureCapacityL(TInt aWidth, TInt aHeight)
+	{
+	if (!iDocPosAndLine || (TUint)User::AllocLen(iDocPosAndLine) < sizeof(TInt)*2 * (aHeight+1))
+		{
+		User::Free(iDocPosAndLine);
+		iDocPosAndLine = NULL;
+		iDocPosAndLine = (TInt*)User::AllocZL(sizeof(TInt)*2*(aHeight+1));
+		}
+	iLineLen = aWidth-1;
+	TInt lineWidthBytes = ((iLineLen+7)&~7)/8;
+	TInt screenBytes = lineWidthBytes * (aHeight+1);
+	if (!iScreenIndexes || User::AllocLen(iScreenIndexes) < screenBytes)
+		{
+		User::Free(iScreenIndexes);
+		iScreenIndexes = NULL;
+		iScreenIndexes = (TUint8*)User::AllocZL(screenBytes);
+		}
+	SetPositionIsValid(0, 0, ETrue); // This position is always valid even if the document is empty
+	}
+
+TInt CLineData::DocumentPosition(TInt aLine) const
+	{
+	return iDocPosAndLine[aLine*2];
+	}
+
+TInt CLineData::FileLineNumber(TInt aLine) const
+	{
+	return iDocPosAndLine[aLine*2 + 1];
+	}
+
+const TUint8& CLineData::ByteForPos(TInt aLine, TInt aCol, TInt& aOffset) const
+	{
+	return const_cast<CLineData*>(this)->ByteForPos(aLine, aCol, aOffset);
+	}
+
+TUint8& CLineData::ByteForPos(TInt aLine, TInt aCol, TInt& aOffset)
+	{
+	TInt lineWidthBytes = ((iLineLen+7)&~7)/8;
+	TInt byteIndex = aLine*lineWidthBytes + aCol/8;
+	aOffset = aCol%8;
+	TUint8& b = iScreenIndexes[byteIndex];
+	return b;
+	}
+
+TBool CLineData::IsScreenPositionValid(TInt aLine, TInt aCol) const
+	{
+	TInt offset;
+	TUint8 b = ByteForPos(aLine, aCol, offset);
+	return b & (1 << offset);
+	}
+
+void CLineData::SetDocumentPositionForLine(TInt aLine, TInt aDocumentPosition)
+	{
+	ASSERT(iDocPosAndLine && aLine*2*sizeof(TInt) < (TUint)User::AllocLen(iDocPosAndLine));
+	iDocPosAndLine[aLine*2] = aDocumentPosition;
+	}
+
+void CLineData::SetFileLineNumberForLine(TInt aLine, TInt aFileLineNumber)
+	{
+	ASSERT(iDocPosAndLine && (aLine*2+1)*sizeof(TInt) < (TUint)User::AllocLen(iDocPosAndLine));
+	iDocPosAndLine[aLine*2 + 1] = aFileLineNumber;
+	}
+
+void CLineData::SetPositionIsValid(TInt aLine, TInt aCol, TBool aValid)
+	{
+	TInt offset;
+	TUint8& b = ByteForPos(aLine, aCol, offset);
+	if (aValid)
+		{
+		b |= (1<<offset);
+		}
+	else
+		{
+		b &= ~(1<<offset);
+		}
+	}
+
+void CLineData::LineFinishedAt(TInt aLine, TInt aCol)
+	{
+	if (aCol >=0 && aCol < iLineLen) SetPositionIsValid(aLine, aCol, ETrue); //  The last position on the line is valid even though nothing is drawn there
+	TInt offset;
+	TUint8& b = ByteForPos(aLine, aCol+1, offset); // Plus one as we want to clear everything beyond the aCol position
+	// Clear everything above the offset'th bit
+	b &= (1 << offset) - 1;
+	// And clear all bytes from b to the end of the line
+	TUint8* endb = &ByteForPos(aLine, iLineLen-1, offset);
+	// Armv5 doesn't like passing in a length of zero to memset, not sure why. Anyway, check there are actually some other bytes that need clearing
+	if (endb > &b)
+		{
+		Mem::FillZ((&b)+1, endb - &b);
+		}
+	}
+
+CLineData::~CLineData()
+	{
+	User::Free(iDocPosAndLine);
+	User::Free(iScreenIndexes);
+	}
+
+TInt CLineData::LastValidPosition(TInt aLine) const
+	{
+	TInt offset;
+	TInt pos = iLineLen-1; // Start comparing from the last possible valid position
+	const TUint8* b = &ByteForPos(aLine, pos, offset);
+	while(*b == 0)
+		{
+		b--; // Optimisation to skip over blanks
+		pos -= offset+1;
+		offset = 7;
+		}
+
+	while (offset >= 0 && ((*b) & (1<<offset)) == 0)
+		{
+		pos--;
+		offset--;
+		}
+	ASSERT(IsScreenPositionValid(aLine, pos)); // Something's gone very wrong in the logic of this function if this assert is not true!
+	return pos;
+	}
+
+void CLRTextView::CopyToClipboardL(const TDesC& aBuf)
+	{
+	LtkUtils::CopyToClipboardL(aBuf, &iConsoleProvider.Fs());
+	}
+
+HBufC* CLRTextView::GetFromClipboardL()
+	{
+	return LtkUtils::GetFromClipboardL(&iConsoleProvider.Fs());
+	}
+
+void CLRTextView::PasteL()
+	{
+	HBufC* text = GetFromClipboardL();
+	CleanupStack::PushL(text);
+	if (text->Length() == 0)
+		{
+		iConsoleProvider.InfoPrint(_L("Nothing to paste"));
+		}
+	else
+		{
+		InsertTextL(*text);
+		}
+	CleanupStack::PopAndDestroy(text);
+	}
+
+TPoint CLRTextView::WindowLocationForDocumentPosition(TInt aDocumentPosition) const
+	{
+	TPoint result(-1,-1); // We return this if doc pos is not on screen
+	const TInt numScreenLines = iWindow.iHeight;
+	if (aDocumentPosition >= iLineData->DocumentPosition(0) && aDocumentPosition < iLineData->DocumentPosition(numScreenLines))
+		{
+		// pos is on screen
+		for (TInt line = 0; line < numScreenLines; line++)
+			{
+			if (aDocumentPosition < iLineData->DocumentPosition(line+1))
+				{
+				result.iY = line;
+				TInt docPos = iLineData->DocumentPosition(line);
+				TInt column = 0;
+				// Find the column screen position whose document position is what we want
+				for (; docPos <= aDocumentPosition; column++)
+					{
+					if (iLineData->IsScreenPositionValid(line, column))
+						{
+						docPos++;
+						}
+					}
+				result.iX = column-1;
+				break;
+				}
+			}
+		}
+	return result;
+	}
+
+void CLRTextView::SetMark()
+	{
+	iMarkFlasher->Cancel();
+	iMarkDocPos = DocumentPosition();
+	iMarkShown = EFalse;
+	const TInt KFlashInterval = 500000;
+	iMarkFlasher->Start(0, KFlashInterval, TCallBack(&FlashMark, this));
+	UpdateStatus();
+	iConsoleProvider.InfoPrint(_L("Mark set. Move cursor then press ^X/^C to cut/copy"));
+	}
+
+void CLRTextView::CancelMark()
+	{
+	if (MarkActive())
+		{
+		iMarkFlasher->Cancel();
+		if (WindowLocationForDocumentPosition(iMarkDocPos).iY != -1)
+			{
+			// If the mark pos is on screen, redraw it to get rid of the '*'
+			RedrawFromPositionToEndOfLine(iMarkDocPos, 0);
+			}
+		}
+	}
+
+TInt CLRTextView::FlashMark(TAny* aSelf)
+	{
+	static_cast<CLRTextView*>(aSelf)->DoFlashMark();
+	return 1;
+	}
+
+void CLRTextView::DoFlashMark()
+	{
+	TPoint markPos = WindowLocationForDocumentPosition(iMarkDocPos);
+	if (markPos.iY != -1)
+		{
+		TPoint cursor = iConsole.CursorPos();
+		iConsole.SetCursorPosAbs(markPos);
+		if (iMarkShown)
+			iConsole.Write(_L(" "));
+		else
+			iConsole.Write(_L("*"));
+		iMarkShown = !iMarkShown;
+		iConsole.SetCursorPosAbs(cursor);
+		}
+	}
+
+TBool CLRTextView::MarkActive() const
+	{
+	return iMarkFlasher->IsActive();
+	}
+
+void CLRTextView::CopyOrCutL(TBool aCut)
+	{
+	TInt docPos = DocumentPosition();
+	const TInt start = Min(docPos, iMarkDocPos);
+	const TInt len = Abs(docPos - iMarkDocPos);
+	CancelMark();
+	RBuf textCopy;
+	CleanupClosePushL(textCopy);
+	TInt dataPos = start;
+	while(ETrue)
+		{
+		TInt err = iBuffer.GetData(*this, dataPos);
+		if (err)
+			{
+			HandleDataLoadError(err);
+			CleanupStack::PopAndDestroy(&textCopy);
+			return;
+			}
+		else
+			{
+			TPtrC text = iDes.Left(len - textCopy.Length());
+			if (textCopy.MaxLength() == 0 && len <= iRange.iLength)
+				{
+				// All fits in one buffer, no need to copy anything!
+				CopyToClipboardL(text);
+				break;
+				}
+			else
+				{
+				// Need to do some copying
+				if (textCopy.MaxLength() == 0) textCopy.CreateL(len);
+				textCopy.Append(text);
+				dataPos += text.Length();
+				if (textCopy.Length() == len)
+					{
+					// Done
+					CopyToClipboardL(textCopy);
+					break;
+					}
+				}
+			}
+		}
+	CleanupStack::PopAndDestroy(&textCopy);
+	if (aCut)
+		{
+		TRange range(start, len);
+		iBuffer.DeleteTextL(range);
+		iCursor = WindowLocationForDocumentPosition(start);
+		if (iCursor.iY == -1)
+			{
+			// Start of the selection is offscreen - force a scroll
+			CenterDocPosOnScreen(start);
+			}
+		else
+			{
+			iDrawPoint = iCursor + iWindow.Origin();
+			RequestData(EFalse, start);
+			}
+		iConsoleProvider.InfoPrint(_L("Text cut to clipboard"));
+		}
+	else
+		{
+		iConsoleProvider.InfoPrint(_L("Text copied to clipboard"));
+		}
+	}
+
+void CLRTextView::UpdateDocumentPositionsStartingAtLine(TInt aLine, TInt aDelta)
+	{
+	// This is important because even though we can optimise away the drawing, when a line has changed
+	// length but not caused wrapping, we still need to make sure the document positions of all the
+	// lines we didn't draw are correct to reflect the extra characters.
+	for (TInt i = aLine; i < iWindow.iHeight+1; i++)
+		{
+		iLineData->SetDocumentPositionForLine(i, iLineData->DocumentPosition(i) + aDelta);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/main.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,158 @@
+// main.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include <e32std.h>
+#include <e32cons.h>
+#include <BADESCA.H>
+#include <BACLINE.H>
+
+#include "fed.h"
+
+//  Constants
+_LIT(KTextConsoleTitle, "Fed editor");
+_LIT(KTextFailed, "\n failed, leave code = %d\n press any key to exit");
+
+//  Global Variables
+//CColorConsoleBase* console = NULL;  // write all messages to this
+CConsoleBase* console = NULL;
+CFed* gFed = NULL;
+
+LOCAL_C void DoStartL()
+	{
+	// Create active scheduler (to run active objects)
+	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+	CFed* fed = CFed::NewL(*console, fs);
+	CleanupStack::PushL(fed);
+	CDesC16ArrayFlat* argsBuf = new(ELeave) CDesC16ArrayFlat(4);
+	CleanupStack::PushL(argsBuf);
+	CCommandLineArguments* args = CCommandLineArguments::NewLC();
+	for (TInt i = 1; i < args->Count(); i++) // Start from 1 as arg zero is the exe name
+		{
+		// No attempt to be clever with arguments - this code is only used when building a raw non-fshell version - mainfshell has the nicer equivalent
+		TPtrC arg = args->Arg(i);
+		argsBuf->AppendL(arg);
+		}
+	CleanupStack::PopAndDestroy(args);
+	CleanupStack::Pop(argsBuf);
+	gFed = fed;
+	fed->StartL(argsBuf);
+	CActiveScheduler::Start();
+
+	// Delete active scheduler
+	CleanupStack::PopAndDestroy(3, scheduler); // fed, fs, scheduler
+	}
+
+//  Global Functions
+GLDEF_C TInt E32Main()
+	{
+	// Create cleanup stack
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+
+	// Create output console
+	//TRAPD(createError, console = dynamic_cast<CColorConsoleBase*>(Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen))));
+	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
+	if (createError)
+		return createError;
+
+	// Run application code inside TRAP harness, wait keypress when terminated
+	TRAPD(mainError, DoStartL());
+	if (mainError)
+		{
+		console->Printf(KTextFailed, mainError);
+		console->Getch();
+		}
+	
+	delete console;
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
+
+class TSilentOverflow : public TDes8Overflow
+	{
+	void Overflow(TDes8& /*aDes*/) { /* Silently truncate */ }
+	};
+
+void AssertionFail(const char* aAssertion, const char* aFile, TInt aLine)
+	{
+	__DEBUGGER();
+	TBuf8<256> buf;
+	TSilentOverflow o;
+	buf.AppendFormat(_L8("Assertion failed: \"%s\" in %s:%i\n"), &o, aAssertion, aFile, aLine);
+	if (buf.Length()*2>buf.MaxLength()) buf.SetLength(buf.MaxLength()/2);
+	console->Write(buf.Expand());
+	User::Panic(_L("Fed"), aLine);
+	}
+
+extern TInt KConsoleWidthCorrection = -2;
+extern TInt KConsoleHeightCorrection = -2;
+
+TInt TabWidth()
+	{
+	return 4;
+	}
+
+_LIT(KHelpText, "\
+Fed Help\n\
+========\n\
+Fed is a basic console text editor. Its interface is similar to pico/nano. It can handle ASCII, UTF-8 and UTF-16 format files, different line endings, very large files, copy and paste, and opening multiple files at once.\n\
+\n\
+The supported commands are given below. The control key is represented as a caret '^', so ^G means Control-G.\n\
+\n\
+Commands\n\
+========\n\
+^L, F1  Get help\n\
+^N      New document\n\
+^O      Open document\n\
+^S      Save document\n\
+^A      Save as\n\
+\n\
+^U      Page up (alternative to PgUp key)\n\
+^D      Page down (alternative to PgDn key)\n\
+^T      Go to top of document\n\
+^B      Go to bottom of document\n\
+\n\
+^F      Find text\n\
+^K      Delete current line\n\
+^G      Go to line\n\
+^R, F5  Redraw the screen\n\
+^X      Cut (see below)\n\
+^C      Copy (see below)\n\
+^V      Paste\n\
+\n\
+^P, F2  Switch to Previous view\n\
+^], F3  Switch to Next view\n\
+^W, Esc Close current doc\n\
+^Q      Quit and close all docs\n\
+\n\
+Press ^W to close this window, or use ^P etc to cycle between the help and other documents.\n\
+\n\
+Clipboard support\n\
+=================\n\
+The standard Symbian clipboard is supported. You can use ^V to paste into the frontmost document. Cut and copy are two-stage operations, because of the limitations of the console:\n\
+\n\
+To begin a cut/copy operation, press ^X or ^C. Then move the cursor to the other end of the selection you want to make, and press ^X/^C again to confirm the cut/copy operation.\n\
+");
+
+void ShowHelpL()
+	{
+	gFed->ShowHelpL(KHelpText().AllocL());
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/mainfshell.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,162 @@
+// mainfshell.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ioutils.h>
+#include "fed.h"
+#include <e32cons.h>
+#include <BADESCA.H>
+#include <fshell/descriptorutils.h>
+
+using namespace IoUtils;
+
+class CCmdFed : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdFed();
+	CConsoleBase* Console() { return iConsole; }
+	TInt TabWidth() const { return iTabWidth; }
+	void ShowHelpL();
+private:
+	CCmdFed();
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void StdinChange(TUint aChange);
+private:
+	RArray<TFileName2> iFiles;
+	CColorConsoleBase* iConsole;
+	CFed* iFed;
+	TInt iTabWidth;
+	};
+
+CCmdFed* gCmd = NULL; // Only used for the assertion handler and tab fns
+
+CCommandBase* CCmdFed::NewLC()
+	{
+	CCmdFed* self = new(ELeave) CCmdFed();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdFed::~CCmdFed()
+	{
+	iFiles.Close();
+	delete iFed;
+	delete iConsole;
+	}
+
+CCmdFed::CCmdFed()
+	: CCommandBase(EManualComplete | ENotifyStdinChanges), iTabWidth(4)
+	{
+	}
+
+const TDesC& CCmdFed::Name() const
+	{
+	_LIT(KName, "fed");	
+	return KName;
+	}
+
+void CCmdFed::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendFileNameL(iFiles, _L("file"));
+	}
+
+void CCmdFed::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendIntL(iTabWidth, _L("tab-width"));
+	}
+
+EXE_BOILER_PLATE(CCmdFed)
+
+void CCmdFed::DoRunL()
+	{
+	iConsole = GetColorConsoleBaseL();
+	gCmd = this;
+
+	// Set the console title - nice for when using win32cons
+	// Not so nice - fshell doesn't reset it when fed exits... -TomS
+	/*
+	_LIT(KFed, "fed ");
+	RBuf cmdLine;
+	cmdLine.CreateL(User::CommandLineLength() + KFed().Length());
+	User::CommandLine(cmdLine);
+	cmdLine.Insert(0, KFed);
+	iConsole->SetTitle(cmdLine);
+	cmdLine.Close();
+	*/
+
+	// Capture CTRL-C so we can (a) use it and (b) prevent users from accidentally nuking their work
+	User::LeaveIfError(Stdin().CaptureKey(CTRL('c'), 0, 0));
+
+	iFed = CFed::NewL(*iConsole, FsL());
+	CDesC16ArrayFlat* argsBuf = new(ELeave) CDesC16ArrayFlat(Max(1, iFiles.Count()));
+	CleanupStack::PushL(argsBuf);
+	for (TInt i = 0; i < iFiles.Count(); i++)
+		{
+		argsBuf->AppendL(iFiles[i]);
+		}
+	CleanupStack::Pop(argsBuf);
+	iFed->StartL(argsBuf);
+	}
+
+void CCmdFed::StdinChange(TUint aChange)
+	{
+	if (aChange & RIoReadHandle::EGainedForeground)
+		{
+		iFed->RedrawEverythingL();
+		}
+	}
+
+void AssertionFail(const char* aAssertion, const char* aFile, TInt aLine)
+	{
+	__DEBUGGER();
+	TBuf8<256> buf;
+	TOverflowTruncate8 o;
+	buf.AppendFormat(_L8("Assertion failed: \"%s\" in %s:%i\n"), &o, aAssertion, aFile, aLine);
+	if (buf.Length()*2>buf.MaxLength()) buf.SetLength(buf.MaxLength()/2);
+	gCmd->Console()->Write(buf.Expand());
+	User::Panic(_L("Fed"), aLine);
+	}
+
+TInt KConsoleWidthCorrection = 0;
+TInt KConsoleHeightCorrection = 0;
+
+TInt TabWidth()
+	{
+	return gCmd->TabWidth();
+	}
+
+void ShowHelpL()
+	{
+	gCmd->ShowHelpL();
+	}
+
+void CCmdFed::ShowHelpL()
+	{
+	LtkUtils::RLtkBuf helpText;
+	CleanupClosePushL(helpText);
+	helpText.AppendL(_L("\
+Fed Help\r\n\
+========\
+"));
+	_LIT(KStart, "Console text editor.");
+	CTextBuffer* helpBuf = const_cast<CTextBuffer*>(GetHelpTextL()); // nasty cast... GetHelpTextL shouldn't return a const obj...
+	CleanupStack::PushL(helpBuf);
+	TInt found = helpBuf->Descriptor().Find(KStart);
+	helpText.AppendL(helpBuf->Descriptor().Mid(found + KStart().Length()));
+	iFed->ShowHelpL(helpText.ToHBuf());
+	CleanupStack::PopAndDestroy(2, &helpText); // helpBuf, helpText
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/screenmngr.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,97 @@
+// screenmngr.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+
+#include "screenmngr.h"
+#include "viewbase.h"
+
+const TInt KCmdWndMinHeight = 3;
+const TInt KCmdWndMinWidth = 20;
+const TInt KRM = 1000; //const multiplication to avoid inexact calculations on small numbers
+
+void CScreenManager::ResizeScreenL(const TWindow& aWindow)
+	{
+	if(aWindow.iHeight < KCmdWndMinHeight
+		|| aWindow.iWidth < KCmdWndMinWidth)
+		User::Leave(KErrNotSupported);
+
+	if(aWindow == iScreenWnd)
+		return;
+
+	//We need to leave one char on each side for the border around the console window, so the width/height is actually less by 2
+	iMainWnd.iX = iCmdWnd.iX = aWindow.iX;
+	iMainWnd.iWidth = iCmdWnd.iWidth = aWindow.iWidth + KConsoleWidthCorrection;
+	iMainWnd.iY = aWindow.iY;
+
+	//Based on proportions of windows on the old screen calculate proportions on the new screen
+	TInt newcmdh = 1;
+	if(iScreenWnd.iHeight)
+		{
+		newcmdh = ((iCmdWnd.iHeight*KRM) * (aWindow.iHeight*KRM)) / iScreenWnd.iHeight*KRM*KRM;
+		if(newcmdh >= aWindow.iHeight)
+			newcmdh = aWindow.iHeight/2;
+		}
+	iCmdWnd.iHeight = newcmdh > 0 ? newcmdh : 1;
+	iMainWnd.iHeight = aWindow.iHeight - iCmdWnd.iHeight + KConsoleWidthCorrection;
+	iCmdWnd.iY = aWindow.iY + iMainWnd.iHeight;
+	iScreenWnd = aWindow;
+
+	if(iCurrentView)
+		iCurrentView->ResizeL(iMainWnd);
+	}
+
+const TWindow& CScreenManager::ResizeCommandWindowL(TInt aHeight)
+	{
+	if(aHeight == iCmdWnd.iHeight)
+		return iCmdWnd;
+
+	//resize the main and cmd windows
+	if(aHeight > iScreenWnd.iHeight)
+		aHeight = iScreenWnd.iHeight;
+
+	iCmdWnd.iHeight = aHeight;
+	iMainWnd.iHeight = iScreenWnd.iHeight - iCmdWnd.iHeight;
+	iCmdWnd.iY = iScreenWnd.iY + iMainWnd.iHeight;
+
+	if(iCurrentView)
+		iCurrentView->ResizeL(iMainWnd);
+
+	return iCmdWnd;
+	}
+
+void CScreenManager::AddViewL(MViewController& aView)
+	{
+	//Here create a new window if necessary
+	AttachViewL(aView);
+	}
+
+void CScreenManager::AttachViewL(MViewController& aView)
+	{
+	if(iCurrentView)
+		{
+		iCurrentView->DeactivateL();
+		}
+
+	iCurrentView = &aView;
+	iCurrentView->RedrawL(iMainWnd);
+	}
+
+void CScreenManager::UnsetCurrentView()
+	{
+	iCurrentView = NULL;
+	}
+
+void CScreenManager::RefreshScreenL()
+	{
+	if (iCurrentView) iCurrentView->RedrawL(iMainWnd);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fed/src/textview.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,183 @@
+// textview.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32cmn.h>
+#include <e32cons.h>
+
+#include "textview.h"
+#include "filebuffer.h"
+
+CTextView::CTextView(MConsoleProvider& aConsoleProvider, CFedBufferBase& aBuffer, TInt aPriority)
+	: CFedViewBase(aConsoleProvider, aPriority), iBuffer(aBuffer)
+	{
+	iBuffer.IncRef();
+	CActiveScheduler::Add(this);
+	}
+
+void CTextView::ConstructL()
+	{
+	User::LeaveIfError(iBuffer.RegisterClient(*this, iDes, iRange, iRangeStartLineNumber));
+	// Make iLine as big as it will ever need to be
+	TSize size = iConsole.ScreenSize();
+	iLine.CreateL(size.iWidth);
+	}
+
+CTextView::~CTextView()
+	{
+	Cancel();
+	iLine.Close();
+	iBuffer.DecRef();
+	}
+
+void CTextView::DoCancel()
+	{
+	ASSERT(EFalse);
+	}
+
+void CTextView::RunL()
+{
+	ASSERT(EFalse);
+/*
+	if(iStatus.Int() != KErrNone)
+		return;
+
+	//redraw by calling DoDrawL if iDrawPoint is within iWindow and iActive is ETrue
+	switch(iState)
+		{
+		case EStateGetData:
+			iState = EStateNone;
+			if(iActive)
+				DoDrawL();
+			break;
+		default:;
+		}
+*/
+}
+
+TInt CTextView::RunError(TInt aError)
+{
+	return aError;
+}
+
+//MViewController
+void CTextView::ShowCursor()
+	{
+	if (iBuffer.Editable())
+		{
+		// Don't show a cursor if the file isn't editable
+		iConsole.SetCursorHeight(20);
+		}
+	}
+
+void CTextView::HideCursor()
+	{
+	iConsole.SetCursorHeight(0);
+	}
+
+void CTextView::ResizeL(const TWindow& aWindow)
+{
+	iActive = ETrue;
+	TWindow oldWindow = iWindow;
+	StoreWindow(aWindow);
+	DoResizeL(oldWindow);
+}
+
+void CTextView::RedrawL(const TWindow& aWindow)
+{
+	iActive = ETrue;
+	StoreWindow(aWindow);
+	DoRedrawL();
+}
+
+void CTextView::DeactivateL()
+{
+	iActive = EFalse;
+}
+
+//MSharedCacheClient
+void CTextView::InvalidateBuffer(TRequestStatus& aStatus)
+{
+	aStatus = KRequestPending;
+	iDes.Set(NULL, 0);
+	TRequestStatus* stat = &aStatus;
+	User::RequestComplete(stat, KErrNone);
+}
+
+void CTextView::RequestData(TBool aFromTheTop, TInt aOffset)
+	{
+	if (aFromTheTop) iDrawPoint.SetXY(iWindow.iX, iWindow.iY);
+	TInt err = iBuffer.GetData(*this, aOffset);
+	if (err)
+		{
+		HandleDataLoadError(err);
+		}
+	else
+		{
+		DoDrawL();
+		}
+	}
+
+void CTextView::SeekData(TInt aDocumentPosition, TInt aNumLines)
+	{
+	if (aDocumentPosition == 0 && aNumLines <= 0)
+		{
+		// Nothing to do
+		return;
+		}
+
+	iDrawPoint.SetXY(iWindow.iX, iWindow.iY); // Seeks always cause a redraw from the top
+	TInt err = iBuffer.SeekFromOffset(*this, aDocumentPosition, aNumLines, iWindow.iWidth-1); // minus one because we can't use the last char
+	if (err)
+		{
+		HandleDataLoadError(err);
+		}
+	else
+		{
+		DoDrawL();
+		}
+	}
+
+void CTextView::UpdateCursor(const TPoint& aNewPos)
+	{
+	ASSERT(aNewPos.iX >= 0);
+	ASSERT(aNewPos.iY >= 0);
+	iCursor = aNewPos;
+	ValidateCursor();
+	if (iActive)
+		{
+		ShowCursor();
+		iConsole.SetCursorPosAbs(iCursor + iWindow.Origin());
+		}
+	}
+
+void CTextView::ValidateCursor()
+	{
+	// Subclasses can override for additional validation
+	if(iCursor.iX < 0)
+		iCursor.iX = 0;
+	if(iCursor.iX >= iWindow.iWidth)
+		iCursor.iX = iWindow.iWidth - 1;
+	if(iCursor.iY < 0)
+		iCursor.iY = 0;
+	if(iCursor.iY >= iWindow.iHeight)
+		iCursor.iY = iWindow.iHeight -1;
+	}
+
+CFedBufferBase& CTextView::Buffer()
+	{
+	return iBuffer;
+	}
+
+void CTextView::HandleDataLoadError(TInt aError)
+	{
+	iConsoleProvider.InfoPrint(_L("Error loading data: %d"), aError);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ffstrace/ffstrace.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,48 @@
+# ffstrace.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name ffstrace
+
+==short-description
+
+Control file system tracing.
+
+==long-description
+
+Control the ffstraceplugin.fxt file system plugin. This plugin loads into the file system and outputs BTrace for useful file system operations.
+
+Note that on older platforms, operations on the Z drive are not logged and you need to hack the f32 code to enable it. On newer platforms Z drive operations are correctly logged.
+
+==argument enum command optional
+
+The command to execute.
+
+==enum-value monitor
+
+Load the plugin and watch the btrace buffer, print out all the operations.
+
+==enum-value load
+
+Load the plugin.
+
+==enum-value unload
+
+Unload the plugin.
+
+==see-also
+
+L<fuser|fuser>
+
+==copyright
+
+Copyright (c) 2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ffstrace/ffstrace.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,184 @@
+// ffstrace.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/extrabtrace.h>
+#include <fshell/btrace_parser.h>
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdFfstrace : public CCommandBase, public MBtraceObserver
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdFfstrace();
+private:
+	CCmdFfstrace();
+	void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TCmd
+		{
+		EMonitor,
+		ELoad,
+		EUnload,
+		};
+	TCmd iCommand;
+private:
+	CBtraceReader* iBtraceReader;
+	};
+
+EXE_BOILER_PLATE(CCmdFfstrace)
+
+CCommandBase* CCmdFfstrace::NewLC()
+	{
+	CCmdFfstrace* self = new(ELeave) CCmdFfstrace();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdFfstrace::~CCmdFfstrace()
+	{
+	delete iBtraceReader;
+	}
+
+CCmdFfstrace::CCmdFfstrace()
+	: CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdFfstrace::Name() const
+	{
+	_LIT(KName, "ffstrace");	
+	return KName;
+	}
+
+void CCmdFfstrace::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCommand, _L("command"));
+	}
+
+void CCmdFfstrace::OptionsL(RCommandOptionList& /*aOptions*/)
+	{
+	//TODO: aOptions.AppendBoolL(iOpt, _L("example_opt"));
+	//TODO: Also remember to update the CIF file for any options you add.
+	}
+
+void CCmdFfstrace::DoRunL()
+	{
+	_LIT(KPluginDll, "ffstraceplugin.fxt");
+	_LIT(KFfsTracerPluginName, "FfsTracePlugin");
+	if (iCommand == EMonitor || iCommand == ELoad)
+		{
+		TInt err = FsL().AddPlugin(KPluginDll);
+		if (err && err != KErrAlreadyExists) LeaveIfErr(err, _L("Couldn't load filesystem plugin %S"), &KPluginDll);
+
+		err = FsL().MountPlugin(KFfsTracerPluginName);
+		//TODO handle this being called repeatedly
+		LeaveIfErr(err, _L("Couldn't mount filesystem plugin %S"), &KFfsTracerPluginName);
+		}
+	else if (iCommand == EUnload)
+		{
+		FsL().DismountPlugin(KFfsTracerPluginName);
+		LeaveIfErr(FsL().RemovePlugin(KFfsTracerPluginName), _L("No plugin to unload"));
+		}
+
+	if (iCommand == EMonitor)
+		{
+		iBtraceReader = CBtraceReader::NewL(CBtraceReader::EFlushOnBtraceThreshold, 1024*1024, 512*1024);
+		iBtraceReader->AddObserverL(BTrace::EFfsTrace, *this);
+		iBtraceReader->SetMultipartReassemblyL(10);
+		TBtraceTickCount now;
+		now.SetToNow();
+		iBtraceReader->Start(now, 1000000);
+		}
+	else
+		{
+		Complete(KErrNone);
+		}
+	}
+
+void CCmdFfstrace::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iCategory == BTrace::EFfsTrace)
+		{
+		TInt fn = aFrame.iSubCategory & ~BTrace::EFfsPost;
+		TBool post = aFrame.iSubCategory & BTrace::EFfsPost;
+		TUint threadId = *(TUint*)aFrame.iData.Ptr();
+		TPtrC name((TUint16*)(aFrame.iData.Ptr()+4), (aFrame.iData.Size()-4)/2);
+		TPtrC newName;
+		// Not everything gets as far as post - if an error occurs during the pre checking for eg
+		if (post) Printf(_L("-"));
+		else Printf(_L("+"));
+
+		TBool twoNames = (fn == BTrace::EFfsRename || fn == BTrace::EFfsFileRename);
+		if (twoNames)
+			{
+			TInt separator = name.Locate(0);
+			if (separator != KErrNotFound)
+				{
+				newName.Set(name.Mid(separator+1));
+				name.Set(name.Left(separator));
+				}
+			}
+
+		switch (fn)
+			{
+			case BTrace::EFfsDelete:
+				Printf(_L("Delete %S"), &name);
+				break;
+			case BTrace::EFfsFileOpen:
+				Printf(_L("Open %S"), &name);
+				break;
+			case BTrace::EFfsFileCreate:
+				Printf(_L("Create %S"), &name);
+				break;
+			case BTrace::EFfsFileSubClose:
+				Printf(_L("Close %S"), &name);
+				break;
+			case BTrace::EFfsFileReplace:
+				Printf(_L("Replace %S"), &name);
+				break;
+			case BTrace::EFfsFileTemp:
+				Printf(_L("Open temp %S"), &name);
+				break;
+			case BTrace::EFfsRename:
+			case BTrace::EFfsFileRename:
+				Printf(_L("Rename from %S to %S"), &name, &newName);
+				break;
+			case BTrace::EFfsEntry:
+				Printf(_L("RFs::Entry %S"), &name);
+				break;
+			default:
+				Printf(_L("Event %d"), fn);
+				break;
+			}
+		Printf(_L(" from thread %u"), threadId);
+		RThread thread;
+		TInt err = thread.Open(threadId);
+		if (err == KErrNone)
+			{
+			Printf(_L(" "));
+			TFullName name = thread.FullName();
+			Write(name);
+			thread.Close();
+			}
+		Printf(_L("\r\n"));
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ffstrace/ffstrace.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// ffstrace.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			ffstrace.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_FFSTRACE
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			ffstrace.cpp
+
+library			euser.lib
+library			iocli.lib
+library			efsrv.lib
+library			btrace_parser.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ffstrace/ffstraceplugin.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,230 @@
+// ffstraceplugin.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/extrabtrace.h>
+#include <f32plugin.h>
+#include <f32pluginutils.h>
+#include <fshell/ltkutils.h>
+
+//#define LOG_FUNC() RDebug::Printf(__PRETTY_FUNCTION__)
+//#define LOG(args...) RDebug::Printf(args)
+//#define LOGW(args...) RDebug::Print(args)
+#define LOG_FUNC()
+#define LOG(args...)
+#define LOGW(args...)
+
+
+NONSHARABLE_CLASS(CFfsTracerPluginFactory) : public CFsPluginFactory
+	{
+public:
+	static CFfsTracerPluginFactory* NewL();
+
+	// from CFsPluginFactory
+	virtual TInt Install();
+	virtual CFsPlugin* NewPluginL();
+	virtual TInt UniquePosition();
+
+private:
+	CFfsTracerPluginFactory();
+	};
+
+NONSHARABLE_CLASS(CFfsTracerFsPlugin) : public CFsPlugin
+	{
+public:
+	static CFfsTracerFsPlugin* NewL();
+	virtual ~CFfsTracerFsPlugin();
+	
+	// from CFsPlugin
+	virtual void InitialiseL();
+	TInt SessionDisconnect(CSessionFs* aSession);
+	virtual TInt DoRequestL(TFsPluginRequest& aRequest);
+	virtual CFsPluginConn* NewPluginConnL();
+private:
+	CFfsTracerFsPlugin();
+	};
+	
+class CFfsTracerFsPluginConn : public CFsPluginConn
+	{
+public:
+	CFfsTracerFsPluginConn();
+
+	// from CFsPluginConn
+	virtual TInt DoControl(CFsPluginConnRequest& aRequest);
+	virtual void DoRequest(CFsPluginConnRequest& aRequest);
+	virtual void DoCancel(TInt aReqMask);
+	};
+
+extern "C" EXPORT_C CFsPluginFactory* CreateFileSystem()
+	{
+	return CFfsTracerPluginFactory::NewL();
+	}
+
+CFfsTracerPluginFactory* CFfsTracerPluginFactory::NewL()
+	{
+	return(new(ELeave) CFfsTracerPluginFactory());
+	}
+
+CFfsTracerPluginFactory::CFfsTracerPluginFactory()
+	{
+	}
+
+_LIT(KFfsTracerPluginName, "FfsTracePlugin");
+
+TInt CFfsTracerPluginFactory::Install()
+	{
+	LOG_FUNC();
+	iSupportedDrives = 0x7FFFFFF; // KPluginSupportAllDrives | KPluginVersionTwo. Not specified symbolically to be compatible with fileservers that didn't support v2 plugins
+	
+	TInt err;
+	err = SetName(&KFfsTracerPluginName);
+	LOG(" returned %d", err);
+	return err;
+	}
+
+CFsPlugin* CFfsTracerPluginFactory::NewPluginL()
+	{
+	return CFfsTracerFsPlugin::NewL();
+	}
+	
+TInt CFfsTracerPluginFactory::UniquePosition()
+	{
+	return 1; // Isn't used, apparently
+	}
+
+//
+
+CFfsTracerFsPluginConn::CFfsTracerFsPluginConn()
+	{
+	}
+
+TInt CFfsTracerFsPluginConn::DoControl(CFsPluginConnRequest& /*aRequest*/)
+	{
+	return KErrNone;
+	}
+
+void CFfsTracerFsPluginConn::DoRequest(CFsPluginConnRequest& /*aRequest*/)
+	{
+	}
+
+void CFfsTracerFsPluginConn::DoCancel(TInt /*aReqMask*/)
+	{
+	}
+
+//
+
+CFfsTracerFsPlugin* CFfsTracerFsPlugin::NewL()
+	{
+	return new(ELeave) CFfsTracerFsPlugin();
+	}
+	
+CFfsTracerFsPlugin::CFfsTracerFsPlugin()
+	{
+	LOG_FUNC();
+	}
+
+static const TFsMessage KMessages[] =
+	{
+	EFsDelete,
+	EFsRename,
+	EFsReplace,
+	EFsEntry,
+	EFsFileSubClose,
+	EFsFileOpen,
+	EFsFileCreate,
+	EFsFileReplace,
+	EFsFileTemp,
+	EFsFileRename,
+	};
+static const TInt KMessageCount = sizeof(KMessages) / sizeof(TFsMessage);
+
+CFfsTracerFsPlugin::~CFfsTracerFsPlugin()
+	{
+	LOG_FUNC();
+	for (TInt i = 0; i < KMessageCount; i++)
+		{
+		UnregisterIntercept(KMessages[i], CFsPlugin::EPrePostIntercept);
+		}
+	}
+
+void CFfsTracerFsPlugin::InitialiseL()
+	{
+	// intercept all calls at start
+	for (TInt i = 0; i < KMessageCount; i++)
+		{
+		RegisterIntercept(KMessages[i], CFsPlugin::EPrePostIntercept);
+		}
+	}
+
+TInt CFfsTracerFsPlugin::SessionDisconnect(CSessionFs* /*aSession*/)
+	{
+	// CSessionFs is a private class! It's in the main file server and 
+	// has no exported methods!  What's the use of passing it here?
+	return KErrNone;
+	}
+
+CFsPluginConn* CFfsTracerFsPlugin::NewPluginConnL()
+	{
+	LOG_FUNC();
+	return new(ELeave) CFfsTracerFsPluginConn();
+	}
+
+TInt CFfsTracerFsPlugin::DoRequestL(TFsPluginRequest& aRequest)
+	{
+	// This is where it all happens
+	
+	TInt subcat = 0;
+	TInt fn = aRequest.Function();
+	// Map from FS opcodes to the compacted btrace ones
+	switch (fn)
+		{
+		case EFsDelete: subcat = BTrace::EFfsDelete; break;
+		case EFsRename: subcat = BTrace::EFfsRename; break;
+		case EFsReplace: subcat = BTrace::EFfsReplace; break;
+		case EFsEntry: subcat = BTrace::EFfsEntry; break;
+		case EFsFileSubClose: subcat = BTrace::EFfsFileSubClose; break;
+		case EFsFileOpen: subcat = BTrace::EFfsFileOpen; break;
+		case EFsFileCreate: subcat = BTrace::EFfsFileCreate; break;
+		case EFsFileReplace: subcat = BTrace::EFfsFileReplace; break;
+		case EFsFileTemp: subcat = BTrace::EFfsFileTemp; break;
+		case EFsFileRename: subcat = BTrace::EFfsFileRename; break;
+		default:
+			// An operation we're not interested in
+			return KErrNone;
+		}
+	if (aRequest.IsPostOperation()) subcat |= BTrace::EFfsPost;
+
+	TBuf<513> name; // Twice as big as a max filename because for renames we need it to fit two TFileNames
+	GetName(&aRequest, name);
+
+	if (fn == EFsRename || fn == EFsFileRename)
+		{
+		name.Append(TChar(0));
+		TPtr newName((TUint16*)(name.Ptr() + name.Length()), 0, name.MaxLength() - name.Length());
+		GetNewName(&aRequest, newName);
+		LOGW(_L("new name is %S"), &newName);
+		name.SetLength(name.Length() + newName.Length());
+		}
+
+	// Only try to use request.Message() if it's a valid handle
+	TUint threadId = 0xFFFFFFFFu;
+	if(aRequest.Message().Handle() != KNullHandle)
+		{
+		RThread clientThread;
+		aRequest.Message().Client(clientThread, EOwnerThread);
+		threadId = clientThread.Id();
+		clientThread.Close();
+		}
+
+	BTraceBig(BTrace::EFfsTrace, subcat, threadId, name.Ptr(), name.Size());
+	
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ffstrace/ffstraceplugin.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// ffstraceplugin.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET		ffstraceplugin.fxt
+TARGETTYPE 	FSY
+
+UID         0x100039df FSHELL_UID_FFSTRACERPLUGIN
+
+#include <fshell/fsh_system_include.mmh>
+
+SOURCE		ffstraceplugin.cpp
+
+FSHELL_TRACE_LIBRARY
+LIBRARY		euser.lib efile.lib efsrv.lib ltkutils-tcb.lib
+
+CAPABILITY	TCB ProtServ DiskAdmin AllFiles PowerMgmt CommDD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/find/find.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+# find.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name find
+
+==short-description
+
+Search for files.
+
+==long-description
+
+Searches the file system for files or directories matching the given conditions. For example...
+
+  find . --name *.ini
+
+...to find all files in the current directory (including subdirectories) whose names end with C<.ini>. The results are printed to stdout.
+
+==argument filename path
+
+The directory to base the search in. Use C<.> to search in current directory.
+
+==option string n name
+
+Include files whose name (excluding path) matches the given pattern (according to C<TDesC::MatchF>).
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/find/find.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,139 @@
+// find.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdFind : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdFind();
+private:
+	CCmdFind();
+	void FoundFile(const TDesC& aDir, const TDesC& aName, TBool aIsDir);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TFileName2 iPath;
+	HBufC* iName;
+	TBool iPrint;
+	TBool iAllDrives;
+	TFileName2 iTempName;
+	RPointerArray<HBufC> iSearchDirs;
+	};
+
+
+CCommandBase* CCmdFind::NewLC()
+	{
+	CCmdFind* self = new(ELeave) CCmdFind();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdFind::~CCmdFind()
+	{
+	delete iName;
+	iSearchDirs.ResetAndDestroy();
+	}
+
+CCmdFind::CCmdFind()
+	{
+	}
+
+const TDesC& CCmdFind::Name() const
+	{
+	_LIT(KName, "find");
+	return KName;
+	}
+
+void CCmdFind::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgPath, "path");
+	aArguments.AppendFileNameL(iPath, KArgPath);
+	}
+
+void CCmdFind::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptName, "name");
+	aOptions.AppendStringL(iName, KOptName);
+	//aOptions.AppendBoolL(iPrint, TChar('p'), _L("print"), _L("Print the paths of files that match the given conditions, one per line. This is the default if no other options are specified."));
+	}
+
+
+EXE_BOILER_PLATE(CCmdFind)
+
+
+void CCmdFind::DoRunL()
+	{
+	RFs& fs = FsL();
+	iPath.SetIsDirectoryL();
+	if (!iName)
+		{
+		LeaveIfErr(KErrArgument, _L("You must specify a name to match against"));
+		}
+
+	iSearchDirs.AppendL(iPath.AllocLC());
+	CleanupStack::Pop();
+
+	while (iSearchDirs.Count())
+		{
+		const TDesC& path = *iSearchDirs[0];
+
+		TInt err;
+		CDir* matchingFiles = NULL;
+		iTempName.Copy(path);
+		iTempName.AppendComponentL(*iName, TFileName2::EFile);
+		// Look for files in this directory first
+		err = fs.GetDir(iTempName, KEntryAttNormal|KEntryAttDir, ESortByName, matchingFiles);
+		if (!err)
+			{
+			for (TInt i = 0; i < matchingFiles->Count(); i++)
+				{
+				const TEntry& entry = (*matchingFiles)[i];
+				FoundFile(path, entry.iName, entry.IsDir());
+				}
+			}
+		delete matchingFiles;
+
+		// Then add all this dir's subdirectories to the list of ones to be scanned
+		CDir* dirsToRecurse = NULL;
+		err = fs.GetDir(path, KEntryAttDir|KEntryAttMatchExclusive, ESortNone, dirsToRecurse);
+		if (!err)
+			{
+			CleanupStack::PushL(dirsToRecurse);
+			for (TInt i = 0; i < dirsToRecurse->Count(); i++)
+				{
+				const TEntry& entry = (*dirsToRecurse)[i];
+				iTempName.Copy(path);
+				iTempName.AppendComponentL(entry);
+				iSearchDirs.AppendL(iTempName.AllocLC());
+				CleanupStack::Pop();
+				}
+			CleanupStack::PopAndDestroy(dirsToRecurse);
+			}
+		delete iSearchDirs[0];
+		iSearchDirs.Remove(0);
+		}
+	}
+
+void CCmdFind::FoundFile(const TDesC& aDir, const TDesC& aName, TBool aIsDir)
+	{
+	// For now, always print
+	_LIT(KBack, "\\");
+	Printf(_L("%S%S%S\n"), &aDir, &aName, aIsDir ? &KBack : &KNullDesC);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/find/find.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// find.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			fshell_find.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_FIND
+capability		FSHELL_CAP_MMP_MAX
+
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			find.cpp
+
+library			euser.lib
+library			iocli.lib
+library			efsrv.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/focus/focus.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+# focus.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name focus
+
+==short-description
+
+Display information about the focused window group.
+
+==long-description
+
+Optionally tracks changes to the focused window group.
+
+==see-also
+
+L<listapps|listapps>, L<activeview|activeview>, L<switchview|switchview>
+
+==option int i id
+
+The identifier of the window group to gain focus. Window group identifiers can be found using L<listapps|listapps>.
+
+==option string m match
+
+A pattern that matches the name of the window group to gain focus. May contain wild characters ('*' and '?'). Window group names can be found using L<listapps|listapps>.
+
+==option bool f follow
+
+Track changes to the focused window group.
+
+==option bool v verbose
+
+Print verbose details.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/focus/focus.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,160 @@
+// focus.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <w32std.h>
+#include <apgwgnam.h>
+#include <fshell/ioutils.h>
+
+const TInt KPriorityNeverAtFront = -999;
+
+using namespace IoUtils;
+
+class CCmdFocus : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdFocus();
+private:
+	CCmdFocus();
+	void PrintDetailsL();
+	void FocusWindowGroupL(TInt aWindowGroupId);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RWsSession iWsSession;
+	RWindowGroup iWindowGroup;
+	TInt iWindowGroupId;
+	HBufC* iWindowGroupPattern;
+	TBool iFollow;
+	TBool iVerbose;
+	};
+
+
+CCommandBase* CCmdFocus::NewLC()
+	{
+	CCmdFocus* self = new(ELeave) CCmdFocus();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdFocus::~CCmdFocus()
+	{
+	iWindowGroup.Close();
+	iWsSession.Close();
+	delete iWindowGroupPattern;
+	}
+
+CCmdFocus::CCmdFocus()
+	{
+	}
+
+const TDesC& CCmdFocus::Name() const
+	{
+	_LIT(KName, "focus");	
+	return KName;
+	}
+
+void CCmdFocus::DoRunL()
+	{
+	LeaveIfErr(iWsSession.Connect(), _L("Couldn't connect to windowserver"));
+
+	if (iOptions.IsPresent(&iWindowGroupId))
+		{
+		FocusWindowGroupL(iWindowGroupId);
+		}
+	else if (iWindowGroupPattern)
+		{
+		TInt id = 0;
+		id = iWsSession.FindWindowGroupIdentifier(id, *iWindowGroupPattern);
+		if (id >= 0)
+			{
+			FocusWindowGroupL(id);
+			}
+		}
+	else
+		{
+		PrintDetailsL();
+		if (iFollow)
+			{
+			iWindowGroup = RWindowGroup(iWsSession);
+			User::LeaveIfError(iWindowGroup.Construct((TUint32)this,EFalse));
+			iWindowGroup.SetOrdinalPosition(0, KPriorityNeverAtFront);
+			iWindowGroup.EnableFocusChangeEvents();
+
+			TRequestStatus status;
+			FOREVER
+				{
+				iWsSession.EventReady(&status);
+				User::WaitForRequest(status);
+				User::LeaveIfError(status.Int());
+				TWsEvent event;
+				iWsSession.GetEvent(event);
+				if (event.Type() == EEventFocusGroupChanged) 
+					{
+					PrintDetailsL();
+					}
+				}
+			}
+		}
+	}
+
+void CCmdFocus::PrintDetailsL()
+	{
+	TInt focusedWgId = iWsSession.GetFocusWindowGroup();
+	CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC(iWsSession, focusedWgId);
+	_LIT(KUnknown, "Un-named");
+	TPtrC caption(wgn->Caption());
+	if (caption.Length() == 0)
+		{
+		caption.Set(KUnknown);
+		}
+	Printf(_L("Focused window group: %S\r\n"), &caption);
+	CleanupStack::PopAndDestroy(wgn);
+
+	if (iVerbose)
+		{
+		TThreadId focusedThreadId;
+		User::LeaveIfError(iWsSession.GetWindowGroupClientThreadId(focusedWgId, focusedThreadId));
+		RThread thread;
+		User::LeaveIfError(thread.Open(focusedThreadId));
+		TFullName name(thread.FullName());
+		thread.Close();
+		Printf(_L("  Window group id:    %u\r\n"), focusedWgId);
+		Printf(_L("  Owning thread:      %S\r\n"), &name);
+		Printf(_L("  Owning thread id:   %u\r\n"), (TUint32)focusedThreadId);
+		Printf(_L("  Tick count:         %u\r\n"), User::NTickCount());
+		}
+	}
+
+void CCmdFocus::FocusWindowGroupL(TInt aWindowGroupId)
+	{
+	LeaveIfErr(iWsSession.SetWindowGroupOrdinalPosition(aWindowGroupId, 0), _L("Unable to set window group %d to ordinal position zero"), aWindowGroupId);
+	}
+
+void CCmdFocus::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptWindowGroupId, "id");
+	aOptions.AppendIntL(iWindowGroupId, KOptWindowGroupId);
+	_LIT(KOptWindowGroupPattern, "match");
+	aOptions.AppendStringL(iWindowGroupPattern, KOptWindowGroupPattern);
+	_LIT(KOptFollow, "follow");
+	aOptions.AppendBoolL(iFollow, KOptFollow);
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	}
+
+
+EXE_BOILER_PLATE(CCmdFocus)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/focus/focus.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// focus.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          focus.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_FOCUS
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          focus.cpp
+
+library         euser.lib
+library         iocli.lib
+library         ws32.lib
+library         apgrfx.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fzip/fzip.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,60 @@
+# fzip.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fzip
+
+==short-description
+
+Compress and decompress files.
+
+==long-description
+
+Generates compressed archives of files or extracts files from a compressed archive. Both 'zip' and 'gzip' file formats are support ('zip' is used by default).
+
+==argument filename archive optional
+
+The zip archive to create or extract.
+
+==option bool v verbose
+
+Enables additional reporting of information regarding the zip/unzip process.
+
+==option bool u unzip
+
+Extract files from the specified archive.
+
+==option filename d directory
+
+The directory to extract files into. Must be used in conjunction with '--unzip'.
+
+==option bool r recurse
+
+Include sub-directories and any files contained therein when archiving.  Must be used in conjunction with '--unzip'.
+
+==option filename f file multiple
+
+A file to archive. Only applicable when creating a new archive.
+
+==option enum t compression-type
+
+==enum-value zip
+
+PK Zip format (the default if not specified).
+
+==enum-value gzip
+
+GNU Zip format. Note, this format can only handle a single file.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fzip/fzip.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,393 @@
+// fzip.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <zipfile.h>
+#include <ezgzip.h>
+#include "fzip.h"
+
+_LIT(KGzExtension, ".gz");
+
+CCommandBase* CCmdZip::NewLC()
+	{
+	CCmdZip* self = new (ELeave) CCmdZip();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdZip::~CCmdZip()
+	{
+	if (iFileToZip.Count() > 0)
+		iFileToZip.Close();
+	}
+	
+CCmdZip::CCmdZip() : CCommandBase(CCommandBase::EManualComplete)
+	{
+	}
+
+const TDesC& CCmdZip::Name() const
+	{	
+	_LIT(KName, "fzip");
+	return KName;
+	}
+
+void CCmdZip::DoRunL()
+	{
+	FsL();
+	if (iUnzip)
+		{
+		if (!iOptions.IsPresent(&iUnzipPath))
+			{
+			iUnzipPath = Env().Pwd();
+			}
+
+		if (iVerbose)
+			{
+			// command-line sanity checks
+			if (iFileToZip.Count() > 0)
+				{
+				PrintWarning(_L("Ignoring \'-f\' file option."));
+				}
+			if (iRecurse)
+				{
+				PrintWarning(_L("Ignoring \'-r\' recurse option."));
+				}
+			}
+		TRAPL(ExpandArchiveL(), _L("Couldn't expand archive"));
+		}
+	else
+		{
+		if (iVerbose)
+			{
+			// command-line sanity checks
+			if (iUnzipPath.Length() > 0)
+				{
+				PrintWarning(_L("Ignoring '-d' directory option."));	
+				}
+			}
+		if (iFileToZip.Count() == 0)
+			{
+			PrintError(KErrArgument, _L("Use '-f' to specify source files."));
+			User::Leave(KErrArgument);
+			}
+		TRAPD(err, CreateArchiveL());
+		if (err != KErrNone)
+			{
+			PrintError(err, _L("Couldn't create archive"));
+			Fs().Delete(iArchive); // ignore error
+			User::Leave(err);
+			}
+		}
+	if (iVerbose)
+		{
+		Printf(_L("Done\r\n"));	
+		}
+	Complete(KErrNone);
+	}
+	
+void CCmdZip::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg1, "archive");
+	aArguments.AppendFileNameL(iArchive, KArg1);
+	}
+
+void CCmdZip::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptUnzip, "unzip");
+	aOptions.AppendBoolL(iUnzip, KOptUnzip);
+
+	_LIT(KOptDirectory, "directory");
+	aOptions.AppendFileNameL(iUnzipPath, KOptDirectory);
+
+	_LIT(KOptRecurse, "recurse");
+	aOptions.AppendBoolL(iRecurse, KOptRecurse);
+
+	_LIT(KOptSource, "file");
+	aOptions.AppendFileNameL(iFileToZip, KOptSource);
+
+	_LIT(KOptCompressionType, "compression-type");
+	aOptions.AppendEnumL((TInt&)iCompressionType, KOptCompressionType);
+	}
+
+
+//
+// COMPRESSION FUNCTIONS
+//
+
+//
+// CCmdZip::CreateArchiveL
+// determine which zip format to use and go ahead & create the archive
+//
+void CCmdZip::CreateArchiveL()
+	{
+	if (iCompressionType == EGZip)
+		{
+		CreateGzArchiveL();
+		}
+	else
+		{
+		CreateZipArchiveL();
+		}
+	}
+
+//
+// CCmdZip::CreateGzArchiveL
+// create an archive, zipping up all the specified files
+//
+void CCmdZip::CreateGzArchiveL()
+	{
+	if (iRecurse)
+		{
+		LeaveIfErr(KErrArgument, _L("GNU Zip format does not support recursion"));
+		}
+
+	if (iFileToZip.Count() > 1)
+		{
+		LeaveIfErr(KErrArgument, _L("GNU Zip format can only handle a single file"));
+		}
+
+	if (iArchive.Length() == 0)
+		{
+		iArchive = iFileToZip[0];
+		iArchive.Append(KGzExtension);
+		}
+
+	RFile input;
+	if (iVerbose)
+		{
+		Printf(_L("Creating '%S'\r\n"), &iArchive);
+		}
+
+	// open the input file
+	User::LeaveIfError(input.Open(Fs(), iFileToZip[0], EFileStream | EFileRead | EFileShareAny));
+	CleanupClosePushL(input);
+
+	CEZFileToGZip* zip = CEZFileToGZip::NewLC(Fs(), iArchive, input);
+	while (zip->DeflateL())
+		{
+		// do nothing
+		}
+	if (iVerbose)
+		{
+		Printf(_L("Deflating '%S'\r\n"), &iFileToZip[0]);
+		}
+
+	CleanupStack::PopAndDestroy(2); // zip, input
+	}
+
+//
+// CCmdZip::CreateZipArchiveL
+// zip format archive creation
+//
+void CCmdZip::CreateZipArchiveL()
+	{
+	CZipItUp* zipArchive = CZipItUp::NewLC(Fs(), iArchive);
+	for (TInt ii = 0 ; ii < iFileToZip.Count() ; ii++)
+		{
+		TFileName2& fileName = iFileToZip[ii];
+		fileName.SetTypeL(Fs());
+		AddFileL(*zipArchive, fileName);
+		}
+	zipArchive->CreateZipL();
+	if (iVerbose)
+		{
+		Printf(_L("Created '%S'\r\n"), &iArchive);
+		}
+	CleanupStack::PopAndDestroy(); // zipArchive 
+	}
+
+//
+// CCmdZip::AddFileL
+// examines a file for wildcards, directories/recursion etc
+// if it finds an actual file, it'll add it to the zip archive
+// recursive function
+//
+void CCmdZip::AddFileL(CZipItUp& aZipArchive, const TFileName2& aFile)
+	{
+	if (aFile.IsDir())
+		{
+		CDir* dir;
+		LeaveIfErr(Fs().GetDir(aFile, KEntryAttMatchMask, EDirsLast, dir), _L("Unable to read directory '%S'"), &aFile);
+		CleanupStack::PushL(dir);
+		for (TInt ii = 0 ; ii < dir->Count() ; ii++)
+			{
+			const TEntry& entry = (*dir)[ii];
+			TFileName2* newFile = new(ELeave) TFileName2(entry.iName);
+			CleanupStack::PushL(newFile);
+			newFile->MakeAbsoluteL(aFile.DriveAndPath());
+			newFile->SetTypeL(Fs());
+			if (newFile->IsDir())
+				{
+				if (iRecurse)
+					{
+					AddFileL(aZipArchive, *newFile);
+					}
+				}
+			else
+				{
+				AddFileL(aZipArchive, *newFile);
+				}
+			CleanupStack::PopAndDestroy(newFile);
+			}
+		CleanupStack::PopAndDestroy(dir);
+		}
+	else
+		{
+		if (iVerbose)
+			{
+			Printf(_L("Adding '%S'\r\n"), &aFile);
+			}
+		aZipArchive.AddFileL(aFile);
+		}
+	}
+
+
+//
+// DECOMPRESSION FUNCTIONS
+//
+
+//
+// CCmdZip::ExpandArchiveL
+// determine which zip format to use and go ahead & expand the archive
+//
+void CCmdZip::ExpandArchiveL()
+	{
+	if (iCompressionType == EGZip)
+		{
+		ExpandGzArchiveL();
+		}
+	else
+		{
+		ExpandZipArchiveL();
+		}
+	}
+
+//
+// CCmdZip::ExpandGzArchiveL
+// unzip an existing gzip compressed file
+//
+void CCmdZip::ExpandGzArchiveL()
+	{
+	// open the destination file, determine where it goes
+	RFile newFile;
+	TFileName2 dest(iUnzipPath);
+	if (iVerbose)
+		{
+		Printf(_L("Opening\t\t\'%S\'\r\n"), &iArchive);
+		}
+	if (iArchive.Ext().CompareF(KGzExtension) != 0)
+		{
+		LeaveIfErr(KErrArgument, _L("Compressed file must have '.gz' extension."));
+		}
+	dest.AppendComponentL(iArchive.Name());
+	TInt err = Fs().MkDirAll(dest);
+	if ((err != KErrNone) && (err != KErrAlreadyExists))
+		{
+		LeaveIfErr(err, _L("Couldn't create path '%S'"), &dest);
+		}
+	User::LeaveIfError(newFile.Replace(Fs(), dest, EFileStream | EFileRead | EFileShareAny));
+	CleanupClosePushL(newFile);
+
+	// inflate the compressed file
+	CEZGZipToFile* zip = CEZGZipToFile::NewLC(Fs(), iArchive, newFile);
+	while (zip->InflateL())
+		{
+		// do nothing
+		}
+	if (iVerbose)
+		{
+		Printf(_L("Inflating '%S'\r\n"), &dest);
+		}
+	CleanupStack::PopAndDestroy(2); // zip, newFile
+	}
+
+//
+// CCmdZip::ExpandZipArchiveL
+// Unzip an existing archive iterating through each member file contained within the archive
+//
+void CCmdZip::ExpandZipArchiveL()
+	{
+	if (iVerbose)
+		{
+		Printf(_L("Opening\t\t\'%S\'\r\n"), &iArchive);
+		}
+	CZipFile* zip = CZipFile::NewL(Fs(), iArchive);
+	CleanupStack::PushL(zip);
+	CZipFileMemberIterator* zipIterator = zip->GetMembersL();
+	CleanupStack::PushL(zipIterator);
+	CZipFileMember* zipMember = zipIterator->NextL();
+	while (zipMember)
+		{
+		CleanupStack::PushL(zipMember);
+		ExtractZipFileL(*zip, *zipMember);
+		CleanupStack::PopAndDestroy(zipMember);
+		zipMember = zipIterator->NextL();
+		}
+	CleanupStack::PopAndDestroy(2); // zipIterator, zip
+	}
+	
+//
+// CCmdZip::ExtractZipFileL
+// extracts a single file from within the zip archive
+//
+void CCmdZip::ExtractZipFileL(CZipFile& aZip, const CZipFileMember& aMember)
+	{
+	// prep. the stream
+	RZipFileMemberReaderStream* readStream;
+	aZip.GetInputStreamL(&aMember, readStream);
+	CleanupStack::PushL(readStream);
+	// prep. the destination file. 
+	// note if iUnzipPath is not specified, it'll stuff the extracted file in the current directory from which fzip.exe runs
+	RFile newFile;
+	TFileName2 dest(iUnzipPath);
+	dest.AppendComponentL(*aMember.Name());
+	TInt err = Fs().MkDirAll(dest);
+	if ((err != KErrNone) && (err != KErrAlreadyExists))
+		{
+		User::Leave(err);
+		}
+	User::LeaveIfError(newFile.Replace(Fs(), dest, EFileShareExclusive));
+	CleanupClosePushL(newFile);
+	if (iVerbose)
+		{
+		Printf(_L("Inflating '%S'\r\n\tcrc: 0x%x\r\n\tcompressed size: %d\r\n\tuncompressed size: %d\r\n"), &dest, aMember.CRC32(), aMember.CompressedSize(), aMember.UncompressedSize());
+		}
+		
+	// stream from the zip archive member into the destination file
+	TInt bytesRead = 0;
+	TInt length = KDefaultZipBufferLength; // 32Kb
+	if (aMember.UncompressedSize() < KDefaultZipBufferLength)
+		{
+		length = aMember.UncompressedSize();
+		}
+	HBufC8* data = HBufC8::NewLC(length);
+	TPtr8 ptr = data->Des();
+	do
+		{
+		User::LeaveIfError(readStream->Read(ptr, length));
+		User::LeaveIfError(newFile.Write(ptr));
+		bytesRead += length;
+		if ((aMember.UncompressedSize() - bytesRead) < KDefaultZipBufferLength)
+			{
+			length = aMember.UncompressedSize() - bytesRead;
+			}
+		} while (length > 0);
+		
+	// cleanup
+	CleanupStack::PopAndDestroy(3); // data, newfile, readstream
+	}
+
+	
+EXE_BOILER_PLATE(CCmdZip)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fzip/fzip.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+// fzip.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __FZIP_H__
+#define __FZIP_H__
+
+#include "fzipup.h"
+
+class CZipFile;
+class CZipFileMember;
+class CZipFileMemberIterator;
+class CCmdZip : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdZip();
+
+	// from CCommandBase
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	CCmdZip();
+	void CreateArchiveL();
+	void ExpandArchiveL();
+
+	// gz (gzip) format support
+	void CreateGzArchiveL();
+	void ExpandGzArchiveL();
+
+	// zip format support
+	void CreateZipArchiveL();
+	void ExpandZipArchiveL();
+	void ExtractZipFileL(CZipFile& aZip, const CZipFileMember& aMember);
+	void AddFileL(CZipItUp& aZipArchive, const TFileName2& aFile);
+private:
+	// user-specified command-line options and arguments
+	TBool iVerbose;
+	TBool iUnzip;
+	TBool iRecurse;
+	enum TType
+		{
+		EZip,
+		EGZip
+		} iCompressionType;
+	TFileName2 iArchive;
+	TFileName2 iUnzipPath;
+	RArray<TFileName2> iFileToZip;
+	};
+
+
+#endif // __FZIP_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fzip/fzip.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// fzip.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target		fzip.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_FZIP
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	\epoc32\include\fshell
+
+sourcepath		.
+source		fzip.cpp
+source		fzipup.cpp
+
+library		euser.lib
+library		iocli.lib
+library		ezip.lib
+library		ezlib.lib
+library		efsrv.lib
+library		estor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fzip/fzipup.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,554 @@
+// fzipup.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <ezstream.h>
+#include <ezcompressor.h>
+#include <ezdecompressor.h>
+#include <ezfilebuffer.h>
+#include <f32file.h>
+#include "fzipup.h"
+
+const TInt KDefaultDiskNumber = 0;
+const TInt CZipEntry::iOffset = _FOFF(CZipEntry, iLink);
+const TUint16 KFZipVersion = 0x0014;
+TInt KWindowBits = -CEZCompressor::EMaxWBits; // negative value is an undocumented feature of our zlib implementation, ensuring we do not include the zlib header in the compressed data (which we must do for zip-file format support)
+const TInt KCompressedSizeRelativePosition = 18; // iCompressedSize is 18 bytes in from the current entry's LFH
+
+//
+// CBufferManager
+//
+CBufferManager *CBufferManager::NewLC(RFileReadStream& aInput, RFileWriteStream& aOutput, TInt aInputStreamBytes, TInt aBufferSize)
+	{
+	CBufferManager *bm = new (ELeave) CBufferManager(aInput, aOutput, aInputStreamBytes, aBufferSize);
+	CleanupStack::PushL(bm);
+	bm->ConstructL();
+	return bm;
+	}
+
+CBufferManager::CBufferManager(RFileReadStream& aInput, RFileWriteStream& aOutput, TInt aInputStreamBytes, TInt aBufferSize)
+:iInput(aInput), iOutput(aOutput), iInputStreamBytes(aInputStreamBytes), iBufferSize(aBufferSize), iInputDescriptor(NULL,0), iOutputDescriptor(NULL,0)
+	{
+	}
+
+CBufferManager::~CBufferManager()
+	{
+	delete[] iInputBuffer;
+	delete[] iOutputBuffer;
+	}
+
+void CBufferManager::ConstructL()
+	{
+	if (iInputStreamBytes < iBufferSize)
+		iBufferSize = iInputStreamBytes;
+	if (iBufferSize <=0)
+		{
+		User::Leave(KErrUnderflow);
+		}
+	
+	iInputBuffer = new (ELeave) TUint8[iBufferSize];
+	iOutputBuffer = new (ELeave) TUint8[iBufferSize];
+	
+	iInputDescriptor.Set(iInputBuffer,0,iBufferSize);
+	iOutputDescriptor.Set(iOutputBuffer,0,iBufferSize);
+	
+	iReadLength = iBufferSize;
+	}
+	
+void CBufferManager::InitializeL(CEZZStream &aZStream)
+	{
+	ReadInputL();
+	aZStream.SetInput(iInputDescriptor);
+	aZStream.SetOutput(iOutputDescriptor);
+	}
+
+void CBufferManager::NeedInputL(CEZZStream &aZStream)
+	{
+	ReadInputL();
+	aZStream.SetInput(iInputDescriptor);
+	}
+
+void CBufferManager::NeedOutputL(CEZZStream &aZStream)
+	{
+	WriteOutputL(aZStream);
+	aZStream.SetOutput(iOutputDescriptor);
+	}
+
+void CBufferManager::FinalizeL(CEZZStream &aZStream)
+	{
+	WriteOutputL(aZStream);
+	}
+
+void CBufferManager::ReadInputL()
+	{
+	iInput.ReadL(iInputDescriptor, iReadLength);
+	iInputStreamBytes -= iReadLength;
+	if (iInputStreamBytes < iBufferSize)
+		{
+		iReadLength = iInputStreamBytes;
+		}
+	if (iReadLength < 0)
+		{
+		User::Leave(KErrOverflow);
+		}
+	}
+
+void CBufferManager::WriteOutputL(CEZZStream& aZStream)
+	{
+	TPtrC8 od = aZStream.OutputDescriptor();
+	iOutput.WriteL(od);
+	iBytesWritten += od.Size();
+	}
+
+//
+// CZipEntry
+// 
+CZipEntry* CZipEntry::NewLC(RFs& aFs, const TDesC& aFilename, const TInt aUid)
+	{
+	CZipEntry* self = new (ELeave) CZipEntry(aFs, aUid);
+	CleanupStack::PushL(self);
+	self->ConstructL(aFilename);
+	return self;
+	}
+
+CZipEntry::CZipEntry(RFs& aFs, const TInt aUid):
+iFs(aFs), iUid(aUid)
+	{
+	iLFH.iCRC32 = crc32(iLFH.iCRC32, NULL, 0);
+	}
+
+CZipEntry::~CZipEntry()
+	{
+	if (iFileData)
+		delete iFileData;
+	if (iInput.SubSessionHandle() > 0)
+		iInput.Close();
+	}
+	
+void CZipEntry::ConstructL(const TDesC& aFilename)
+	{
+	User::LeaveIfError(iInput.Open(iFs, aFilename, EFileRead | EFileShareReadersOnly));
+
+	// ensure aFileName is stored in accordance with zip file-format specification
+	TFileName2 file(aFilename);
+	if (file.HasDriveLetter())
+		{
+		file.Delete(0, 3); // remove '<drive>:\'
+		}
+	if (file.HasLeadingSlash())
+		{
+		file.Delete(0, 1); // remove '\'
+		}
+	iAsciiName.Copy(file);
+	TUint8* ptr = const_cast<TUint8*> (iAsciiName.Ptr());
+	TInt count = 0;
+	do
+		{
+		if (*ptr == '\\')
+			{
+			*ptr = '/';
+			}
+		ptr++;
+		} while (count++ < iAsciiName.Length());
+	
+	// config. local file header
+	iLFH.iSignature = KLocalHeaderSignature;
+	iLFH.iVersionNeeded = KFZipVersion;
+	iLFH.iFlags = 0x0002; // best (-exx/-ex) compression was used
+	iLFH.iCompressionMethod = EDeflated;
+	TTime time;
+	User::LeaveIfError(iInput.Modified(time));
+	TDateTime td = time.DateTime();
+	TUint16 param1 = td.Year() - 1980;
+	TUint16 param2 = td.Month() + 1;
+	TUint16 param3 = td.Day() + 1;
+	iLFH.iLastModifiedFileDate = (param1 << 9) | (param2 << 5) | param3;
+	param1 = td.Hour() + 1;
+	param2 = td.Minute() + 1;
+	param3 = td.Second() + 1;
+	iLFH.iLastModifiedFileTime = (param1 << 11) | (param2 << 5) | (param3 >> 1);
+	TInt uSize = 0;
+	User::LeaveIfError(iInput.Size(uSize));
+	if (uSize <= 0)
+		{
+		User::Leave(KErrAbort);
+		}
+	iLFH.iUncompressedSize = uSize;
+	iLFH.iCompressedSize = uSize; // note: to be adjusted later once the compression is performed
+	CalcCRCL();
+	iLFH.iFileNameLength = iAsciiName.Size();
+	iLFH.iExtraFieldLength = 0;
+	
+	// config. file header
+	iFH.iSignature = KCentralDirectoryHeaderSignature;
+	iFH.iMadeBy = KFZipVersion;
+	iFH.iRequired = KFZipVersion;
+	iFH.iFlags = iLFH.iFlags;
+	iFH.iCompressionMethod = iLFH.iCompressionMethod;
+	iFH.iLastModifiedFileTime = iLFH.iLastModifiedFileTime;
+	iFH.iLastModifiedFileDate = iLFH.iLastModifiedFileDate;
+	iFH.iCRC32 = iLFH.iCRC32;
+	iFH.iCompressedSize = iLFH.iCompressedSize;	// note: to be adjusted later once the compression is performed
+	iFH.iUncompressedSize = iLFH.iUncompressedSize;
+	iFH.iFileNameLength = iLFH.iFileNameLength;
+	iFH.iExtraFieldLength = iLFH.iExtraFieldLength;
+	iFH.iFileCommentLength = 0x0000;
+	iFH.iDiskNumberStart = KDefaultDiskNumber;
+	iFH.iInternalFileAttributes = 0x0001;
+	iFH.iExternalFileAttributes = 0x00000020;	// hardcoded to 'Archive'
+	iFH.iLocalHeaderOffset = 0x00000000; // to be adjusted later (if necessary)
+	}
+
+void CZipEntry::SetOffset(TUint32 aOffset)
+	{
+	iFH.iLocalHeaderOffset = aOffset;
+	}
+
+TUint32 CZipEntry::ReturnOffset()
+	{
+	TUint32 result = iFH.iLocalHeaderOffset; // start with the offset of the LFH
+	result += KLocalHeaderFixedLength; // add the size of the LFH itself
+	result += iAsciiName.Size(); // add the size of the filename
+	result += iLFH.iCompressedSize; // add any compressed data
+	return result;
+	}
+
+TUint32 CZipEntry::FileHeaderSize()
+	{
+	TUint32 result = KCentralDirectoryHeaderFixedLength;
+	result += iAsciiName.Size();
+	return result;
+	}
+
+//
+// CZipEntry::CalcCRCL
+// mem. efficient means of calculating the crc on uncompressed data
+// we require a maximum of KDefaultZipBufferLength heap space regardless size of data
+//
+void CZipEntry::CalcCRCL()
+	{
+	ASSERT(iInput.SubSessionHandle() > 0);
+	TInt bytesRead = 0;
+	TInt length = KDefaultZipBufferLength; // 32Kb
+	if (iLFH.iUncompressedSize < KDefaultZipBufferLength)
+		{
+		length = iLFH.iUncompressedSize;
+		}
+	
+	iLFH.iCRC32 = crc32(0, NULL, 0);
+	HBufC8* crc = HBufC8::NewLC(length);
+	TPtr8 crcPtr = crc->Des();
+	User::LeaveIfError(iInput.Seek(ESeekStart, bytesRead));
+	do
+		{
+		User::LeaveIfError(iInput.Read(crcPtr, length));
+		iLFH.iCRC32 = crc32(iLFH.iCRC32, crcPtr.Ptr(), length);
+		bytesRead += length;
+		if ((iLFH.iUncompressedSize - bytesRead) < KDefaultZipBufferLength)
+			{
+			length = iLFH.iUncompressedSize - bytesRead;
+			}
+		} while (length > 0);
+	CleanupStack::PopAndDestroy(1); // crc	
+	}
+
+//
+// CZipItUp
+// 
+CZipItUp* CZipItUp::NewLC(RFs& aFs, TDesC& aArchive)
+	{
+	CZipItUp* self = new (ELeave) CZipItUp(aFs, aArchive);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}		
+
+CZipItUp::CZipItUp(RFs& aFs, TDesC& aArchive):
+iFs(aFs), iFileName(aArchive), iZipMemberLinkedList(CZipEntry::iOffset), iZipMemberLinkedListIter(iZipMemberLinkedList)
+	{
+	}
+
+CZipItUp::~CZipItUp()
+	{
+	if (iFile.SubSessionHandle() > 0)
+		{
+		iFile.Close();
+		}
+	while (!iZipMemberLinkedList.IsEmpty())
+		{
+		CZipEntry* entry = iZipMemberLinkedList.First();
+		iZipMemberLinkedList.Remove(*entry);
+		delete entry;	
+		}
+	iZipMemberLinkedList.Reset();
+	}
+	
+void CZipItUp::ConstructL()
+	{
+	User::LeaveIfError(iFile.Create(iFs, iFileName, EFileStream | EFileShareExclusive));
+	}
+	
+//
+// CZipItUp::AddFileL
+//
+void CZipItUp::AddFileL(const TDesC& aFile)
+	{
+	if (!DuplicateEntryL(aFile))
+		{
+		// spawn a new zip entry, compress the file, add it to the list of zip file contained in the archive
+		CZipEntry* zipEntry = CZipEntry::NewLC(iFs, aFile, ++iEntryUid);
+		AddEntryL(*zipEntry);
+		CleanupStack::Pop(zipEntry);
+		}
+	}
+
+//
+// CZipItUp::DuplicateEntryL
+// run a check against the zip archive's current entries (if any!) for duplicate files
+// return ETrue if a duplicate is found
+//
+TBool CZipItUp::DuplicateEntryL(const TDesC& aFile)
+	{
+	if (iZipMemberLinkedList.IsEmpty())
+		{
+		return EFalse;
+		}
+	
+	// turn aFile into a zip-file format filename
+	TFileName2 file(aFile);
+	if (file.HasDriveLetter())
+		{
+		file.Delete(0, 3); // remove '<drive>:\'
+		}
+	if (file.HasLeadingSlash())
+		{
+		file.Delete(0, 1); // remove '\'
+		}
+	TBuf8<KMaxFileName> ascii;
+	ascii.Copy(file);
+	TUint8* ptr = const_cast<TUint8*> (ascii.Ptr());
+	TInt count = 0;
+	do
+		{
+		if (*ptr == '\\')
+			{
+			*ptr = '/';
+			}
+		ptr++;
+		} while (count++ < ascii.Length());
+	
+	// iterate through zip archive entries looking for a duplicate 
+	iZipMemberLinkedListIter.SetToFirst();
+	CZipEntry* entry = iZipMemberLinkedListIter++;
+	while (entry != NULL)
+		{
+		if (entry->iAsciiName == ascii)
+			{
+			return ETrue;
+			}
+		entry = iZipMemberLinkedListIter++;
+		}
+	return EFalse;
+	}
+
+//
+// CZipItUp::AddEntryL
+// Add an entry to the zip archive.
+//
+void CZipItUp::AddEntryL(CZipEntry& aEntry)
+	{
+	// append the new entry to the queue
+	if (!iZipMemberLinkedList.IsEmpty())
+		{
+		// prior entries in the list therefore need to adjust this entry's local file header offset
+		CZipEntry* lastEntry = iZipMemberLinkedList.Last();
+		User::LeaveIfNull(lastEntry);
+		}
+	iZipMemberLinkedList.AddLast(aEntry);
+	}
+
+//
+// CZipItUp::CreateZipL
+// Creates the actual file, including all the previously compressed zip files in the archive
+//
+void CZipItUp::CreateZipL()
+	{
+	ASSERT(iFile.SubSessionHandle() > 0);
+	if (iZipMemberLinkedList.IsEmpty())
+		{
+		User::Leave(KErrGeneral);
+		}
+	RFileWriteStream stream(iFile);
+	stream.PushL();
+	
+	// initialise central directory header
+	iCDT.iSignature = CZipArchive::KCentralDirectorySignature;
+	iCDT.iDiskNumber = KDefaultDiskNumber;
+	iCDT.iStartDiskNumber = KDefaultDiskNumber;
+	iCDT.iLocalEntryCount = 0;
+	iCDT.iTotalEntryCount = 0;
+	iCDT.iSize = 0;
+	iCDT.iCommentLength = 0;
+	
+	// iterate through each zip entry, appending local file header (LFH), file data (FD) to file
+	iZipMemberLinkedListIter.SetToFirst();
+	CZipEntry* entry = iZipMemberLinkedListIter++;
+	CZipEntry* prior = NULL;
+	User::LeaveIfNull(entry);
+	do
+		{
+		if (prior)
+			{
+			// adjust file header local offset if necessary
+			entry->SetOffset(prior->ReturnOffset());
+			}
+
+		// insert entry's Local File Header
+		AppendLocalFileHeaderL(stream, *entry);
+		
+		// insert entry's File Data
+		AppendCompressedDataL(stream, *entry);
+		
+		// adjust cdt parameters
+		iCDT.iLocalEntryCount++;
+		iCDT.iTotalEntryCount++;
+		iCDT.iSize += entry->FileHeaderSize();
+		
+		// move onto the next entry
+		prior = entry;
+		entry = iZipMemberLinkedListIter++;
+		} while (entry != NULL);
+		
+	// adjust cdt offset parameter
+	iCDT.iOffset = iZipMemberLinkedList.Last()->ReturnOffset();
+	
+	// iterate through each zip entry, appending the central directory File Headers to file (these must go after LFH, FD entries)
+	iZipMemberLinkedListIter.SetToFirst();
+	entry = iZipMemberLinkedListIter++;
+	
+	do
+		{
+		// central directory File Header
+		AppendCentralDirectoryFileHeaderL(stream, *entry);
+		
+		// move onto the next entry
+		entry = iZipMemberLinkedListIter++;
+		} while (entry != NULL);
+	
+	// append the central directory trailer
+	AppendCentralDirectoryTrailerL(stream);	
+	
+	// commit the transaction
+	stream.CommitL();
+	stream.Pop();
+	stream.Close();
+	
+	// go back through & adjust compressed size values for each zip entry post-mortem
+	ASSERT(iFile.SubSessionHandle() == 0);
+	User::LeaveIfError(iFile.Open(iFs, iFileName, EFileWrite | EFileShareExclusive));
+	TInt pos = 0;
+	const TInt remainder = 8; // CZipArchive::KLocalHeaderFixedLength - KCompressedSizeRelativePosition
+	User::LeaveIfError(iFile.Seek(ESeekStart, pos));
+	iZipMemberLinkedListIter.SetToFirst();
+	entry = iZipMemberLinkedListIter++;
+	do
+		{
+		pos += KCompressedSizeRelativePosition; // step to iCompressedSize location in the current entry's LFH
+		TUint32 cs = entry->iLFH.iCompressedSize;
+		TUint32 KMyByte = 0x000000FF;
+		TInt bytecount = 0;
+		TBuf8<8> compSize;
+		do
+			{
+			TUint32 csChar((cs & KMyByte));
+			compSize.Append(csChar);
+			cs >>= 8;
+			} while (++bytecount < 4); // zip-file format allows us 4 bytes only for the compressed size value
+		User::LeaveIfError(iFile.Write(pos, compSize));
+		pos += bytecount; // the 4 bytes we just wrote
+		
+		// step over remaing bytes to the beginning of the next entry's LFH
+		pos += remainder; 
+		pos += entry->iAsciiName.Size();
+		pos += entry->iLFH.iCompressedSize;
+		
+		// we're now positioned at the next entry's LFH
+		entry = iZipMemberLinkedListIter++;
+		} while (entry != NULL);
+	}
+
+void CZipItUp::AppendLocalFileHeaderL(RFileWriteStream& aStream, CZipEntry& aZipEntry)
+	{
+	aStream.WriteUint32L(aZipEntry.iLFH.iSignature);
+	aStream.WriteUint16L(aZipEntry.iLFH.iVersionNeeded);
+	aStream.WriteUint16L(aZipEntry.iLFH.iFlags);
+	aStream.WriteUint16L(aZipEntry.iLFH.iCompressionMethod);
+	aStream.WriteUint16L(aZipEntry.iLFH.iLastModifiedFileTime);
+	aStream.WriteUint16L(aZipEntry.iLFH.iLastModifiedFileDate);
+	aStream.WriteUint32L(aZipEntry.iLFH.iCRC32);
+	aStream.WriteUint32L(aZipEntry.iLFH.iCompressedSize);
+	aStream.WriteUint32L(aZipEntry.iLFH.iUncompressedSize);
+	aStream.WriteUint16L(aZipEntry.iLFH.iFileNameLength);
+	aStream.WriteUint16L(aZipEntry.iLFH.iExtraFieldLength);
+	aStream.WriteL(aZipEntry.iAsciiName);
+	}
+
+void CZipItUp::AppendCompressedDataL(RFileWriteStream& aStream, CZipEntry& aZipEntry)
+	{
+	// compress data & stream it to the zip archive (aStream)
+	RFileReadStream inStream;
+	inStream.Attach(aZipEntry.iInput); // note takes ownership of iInput subsession handle
+	CBufferManager* fb = CBufferManager::NewLC(inStream, aStream, aZipEntry.iLFH.iUncompressedSize, KDefaultZipBufferLength);
+	CEZCompressor* compressor = CEZCompressor::NewLC(*fb, CEZCompressor::EBestCompression, KWindowBits, CEZCompressor::EDefMemLevel, CEZCompressor::EDefaultStrategy);
+	while (compressor->DeflateL()){/* do nothing */}
+	
+	// update the entry's LocalFileHeader and FileHeader
+	aZipEntry.iLFH.iCompressedSize = fb->TotalBytesOut();
+	aZipEntry.iFH.iCompressedSize = aZipEntry.iLFH.iCompressedSize;
+	
+	// cleanup
+	CleanupStack::PopAndDestroy(2, fb); // compressor, fb
+	inStream.Close();
+	}
+
+void CZipItUp::AppendCentralDirectoryFileHeaderL(RFileWriteStream& aStream, CZipEntry& aEntry)
+	{
+	aStream.WriteUint32L(aEntry.iFH.iSignature);
+	aStream.WriteUint16L(aEntry.iFH.iMadeBy);
+	aStream.WriteUint16L(aEntry.iFH.iRequired);
+	aStream.WriteUint16L(aEntry.iFH.iFlags);
+	aStream.WriteUint16L(aEntry.iFH.iCompressionMethod);
+	aStream.WriteUint16L(aEntry.iFH.iLastModifiedFileTime);
+	aStream.WriteUint16L(aEntry.iFH.iLastModifiedFileDate);
+	aStream.WriteUint32L(aEntry.iFH.iCRC32);
+	aStream.WriteUint32L(aEntry.iFH.iCompressedSize);
+	aStream.WriteUint32L(aEntry.iFH.iUncompressedSize);
+	aStream.WriteUint16L(aEntry.iFH.iFileNameLength);
+	aStream.WriteUint16L(aEntry.iFH.iExtraFieldLength);
+	aStream.WriteUint16L(aEntry.iFH.iFileCommentLength);
+	aStream.WriteUint16L(aEntry.iFH.iDiskNumberStart);
+	aStream.WriteUint16L(aEntry.iFH.iInternalFileAttributes);
+	aStream.WriteUint32L(aEntry.iFH.iExternalFileAttributes);
+	aStream.WriteUint32L(aEntry.iFH.iLocalHeaderOffset);
+	aStream.WriteL(aEntry.iAsciiName);
+	}
+
+void CZipItUp::AppendCentralDirectoryTrailerL(RFileWriteStream& aStream)
+	{
+	aStream.WriteUint32L(iCDT.iSignature);
+	aStream.WriteUint16L(iCDT.iDiskNumber);
+	aStream.WriteUint16L(iCDT.iStartDiskNumber);
+	aStream.WriteUint16L(iCDT.iLocalEntryCount);
+	aStream.WriteUint16L(iCDT.iTotalEntryCount);
+	aStream.WriteUint32L(iCDT.iSize);
+	aStream.WriteUint32L(iCDT.iOffset);
+	aStream.WriteUint16L(iCDT.iCommentLength);	
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/fzip/fzipup.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,136 @@
+// fzipup.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __FZIP_UP_H__
+#define __FZIP_UP_H__
+
+#include <zipfile.h>
+#include <ezbufman.h>
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+const TUint32 KDefaultZipBufferLength = 0x8000; // 32 Kbytes
+
+//
+// class CBufferManager
+// manage the i/o buffers for compression, wrapper over the MEZBufferManager mix-in
+// takes input data from one file stream & writes the compressed output to another file stream
+//
+class CBufferManager : public CBase, public MEZBufferManager
+	{
+public:
+	static CBufferManager *NewLC(RFileReadStream& aInput, RFileWriteStream& aOutput, TInt aInputStreamBytes, TInt aBufferSize);
+	~CBufferManager();
+	inline TInt TotalBytesOut(){ return iBytesWritten; }
+	
+	// from MEzBufferManager
+	void InitializeL(CEZZStream &aZStream);
+	void NeedInputL(CEZZStream &aZStream);
+	void NeedOutputL(CEZZStream &aZStream);
+	void FinalizeL(CEZZStream &aZStream);
+private:
+	CBufferManager(RFileReadStream& aInput, RFileWriteStream& aOutput, TInt aInputStreamBytes, TInt aBufferSize);
+	void ConstructL();
+	void ReadInputL();
+	void WriteOutputL(CEZZStream& aZStream);
+private:
+	RFileReadStream& iInput;
+	RFileWriteStream& iOutput;
+	TInt iInputStreamBytes; // size of the input stream in bytes
+	TInt iReadLength;
+	TInt iBufferSize;
+	TInt iBytesWritten;
+	TUint8* iInputBuffer;
+	TUint8* iOutputBuffer;
+	TPtr8 iInputDescriptor;
+	TPtr8 iOutputDescriptor;
+	};
+
+//
+// class CZipEntry
+// defines attributes associated with a file contained within a zip archive
+// note these are taken from PKWARE'S APPNOTE.TXT zip-file format specification
+//
+class CZipItUp;
+class CZipEntry : public CZipArchive
+{
+public:
+	friend class CZipItUp;
+	static CZipEntry* NewLC(RFs& aFs, const TDesC& aFilename, const TInt aUid);
+        virtual ~CZipEntry();
+
+	void SetOffset(TUint32 aOffset);
+	TUint32 ReturnOffset();
+	TUint32 FileHeaderSize();
+private:
+	CZipEntry(RFs& aFs, const TInt aUid);
+	void ConstructL(const TDesC& aFilename);
+	void CalcCRCL();
+private:
+        static const TInt iOffset;
+        TLocalHeader iLFH;					// Local File Header
+        HBufC8* iFileData;					// File Data
+        TCentralDirectoryHeader iFH;		// File Header
+        RFs& iFs;							// f32 hook
+        TBuf8<KMaxFileName>	iAsciiName;	// Ascii file name
+        RFile iInput;						// input data from file
+        const TInt iUid;					// uid id'ing this particular zip entry
+        TSglQueLink iLink;
+	};
+	
+//
+// class CZipItUp
+// create a zip archive
+//
+typedef TSglQue<CZipEntry> CZipMemberLinkedList;
+typedef TSglQueIter<CZipEntry> CZipMemberLinkedListIter;
+	
+class CZipItUp : public CBase
+	{
+public:
+	static CZipItUp* NewLC(RFs& aFs, TDesC& aArchive);
+	virtual ~CZipItUp();
+	void AddFileL(const TDesC& aFile);
+	void CreateZipL();
+private:
+	CZipItUp(RFs& aFs, TDesC& aArchive);
+	void ConstructL();
+	void AddEntryL(CZipEntry& aEntry);
+	TBool DuplicateEntryL(const TDesC& aFile);
+	void AppendLocalFileHeaderL(RFileWriteStream& aStream, CZipEntry& aZipEntry);
+	void AppendCompressedDataL(RFileWriteStream& aStream, CZipEntry& aZipEntry);
+	void AppendCentralDirectoryFileHeaderL(RFileWriteStream& aStream, CZipEntry& aEntry);
+	void AppendCentralDirectoryTrailerL(RFileWriteStream& aStream);
+private:
+	RFs& iFs;
+	TDesC& iFileName;
+	RFile iFile;
+	CZipMemberLinkedList iZipMemberLinkedList;
+	CZipMemberLinkedListIter iZipMemberLinkedListIter;
+	TInt iEntryUid;
+
+  struct TCdt 
+		{
+        TUint32 iSignature;
+		TUint16 iDiskNumber;
+		TUint16 iStartDiskNumber;
+		TUint16 iLocalEntryCount;
+		TUint16 iTotalEntryCount;
+		TUint32 iSize;
+		TUint32 iOffset;
+		TUint16 iCommentLength;
+		};
+	TCdt iCDT;		// Central Directory Trailer
+	};
+
+#endif // __FZIP_UP_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/genbmp/genbmp.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,58 @@
+# genbmp.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name genbmp
+
+==short-description
+
+Generates simple bitmap files that contain text.
+
+==argument filename file_name
+
+The name of the bitmap file generate.
+
+==argument string text multiple
+
+The text to be rendered into the bitmap. For multiple lines, enclose the text for each line in quotes.
+
+==option uint f foreground-color
+
+The color (in 32 bit RGB format) to render the text in. Defaults to white (0xffffff).
+
+==option uint b background-color
+
+The color (in 32 bit RGB format) to render the background behind the text in. Defaults to black (0x000000).
+
+==option int w width
+
+The width (in pixels) of the bitmap to be created. Defaults to 150.
+
+==option int H height
+
+The height (in pixels) of the bitmap to be created. Defaults to 150.
+
+==option string t typeface
+
+The name of the typeface to render the text with. Defaults to 'Arial'.
+
+==option int m max-font-height
+
+The maximum height of the font to use in pixels. Defaults to 15.
+
+==option int g gap
+
+The gap (in pixels) between the text and the bitmap edge and also between each line of text. Defaults to 10.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/genbmp/genbmp.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,161 @@
+// genbmp.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <gdi.h>
+#include <fbs.h>
+#include <imageconversion.h>
+
+using namespace IoUtils;
+
+class CCmdGenbmp : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdGenbmp();
+private:
+	CCmdGenbmp();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From CActive.
+	virtual void RunL();
+private:
+	RFbsSession iFbsSession;
+	CFbsBitmap* iBitmap;
+	CFbsBitmapDevice* iBitmapDevice;
+	CBitmapContext* iBitmapContext;
+	CImageEncoder* iImageEncoder;
+	RFile iFile;
+	TFileName2 iFileName;
+	RPointerArray<HBufC> iText;
+	TSize iSize;
+	TUint32 iForegroundColor;
+	TUint32 iBackgroundColor;
+	HBufC* iTypefaceName;
+	TInt iMaxFontHeight;
+	TInt iGap;
+	};
+
+
+CCommandBase* CCmdGenbmp::NewLC()
+	{
+	CCmdGenbmp* self = new(ELeave) CCmdGenbmp();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdGenbmp::~CCmdGenbmp()
+	{
+	delete iTypefaceName;
+	delete iImageEncoder;
+	delete iBitmapContext;
+	delete iBitmapDevice;
+	delete iBitmap;
+	iFbsSession.Disconnect();
+	iFile.Close();
+	iText.ResetAndDestroy();
+	REComSession::FinalClose();
+	}
+
+CCmdGenbmp::CCmdGenbmp()
+	: iSize(150, 150), iForegroundColor(0xffffff), iBackgroundColor(0x000000), iMaxFontHeight(15), iGap(10)
+	{
+	}
+
+const TDesC& CCmdGenbmp::Name() const
+	{
+	_LIT(KName, "genbmp");	
+	return KName;
+	}
+
+void CCmdGenbmp::DoRunL()
+	{
+	LeaveIfErr(iFbsSession.Connect(FsL()), _L("Couldn't connect to the Font & Bitmap Server"));
+	iBitmap = new(ELeave)CFbsBitmap;
+	User::LeaveIfError(iBitmap->Create(iSize, EColor16));
+	iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap);
+	LeaveIfErr(iBitmapDevice->CreateBitmapContext(iBitmapContext), _L("Couldn't create bitmap context"));
+	iBitmapContext->SetPenColor(iForegroundColor);
+	iBitmapContext->SetPenStyle(CGraphicsContext::ENullPen);
+	iBitmapContext->SetBrushColor(iBackgroundColor);
+	iBitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
+
+	TFontSpec fontSpec;
+	fontSpec.iTypeface.iName = iTypefaceName ? *iTypefaceName : _L("Arial");
+	fontSpec.iTypeface.SetIsSymbol(EFalse);
+	CFont* font;
+	LeaveIfErr(iBitmapDevice->GetNearestFontToMaxHeightInPixels(font, fontSpec, iMaxFontHeight), _L("Couldn't get suitable font"));
+	iBitmapContext->DrawRect(iSize);
+	iBitmapContext->UseFont(font);
+
+	TPoint linePos(iGap, iGap + iMaxFontHeight);
+	const TInt numLines = iText.Count();
+	for (TInt i = 0; i < numLines; ++i)
+		{
+		iBitmapContext->DrawText(*(iText[i]), linePos);
+		linePos.iY += (iGap + iMaxFontHeight);
+		}
+
+	iBitmapContext->DiscardFont();
+
+	LeaveIfErr(iFile.Replace(FsL(), iFileName, EFileWrite), _L("Unable to open \"%S\" for writing"), &iFileName);
+	iImageEncoder = CImageEncoder::FileNewL(iFile, CImageEncoder::EOptionNone, KImageTypeBMPUid);
+	iImageEncoder->Convert(&iStatus, *iBitmap);
+	SetActive();
+	}
+
+void CCmdGenbmp::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFileName, "file_name");
+	aArguments.AppendFileNameL(iFileName, KArgFileName);
+
+	_LIT(KArgText, "text");
+	aArguments.AppendStringL(iText, KArgText);
+	}
+
+void CCmdGenbmp::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptForegroundColor, "foreground-color");
+	aOptions.AppendUintL((TUint&)iForegroundColor, KOptForegroundColor);
+
+	_LIT(KOptBackgroundColor, "background-color");
+	aOptions.AppendUintL((TUint&)iBackgroundColor, KOptBackgroundColor);
+
+	_LIT(KOptWidth, "width");
+	aOptions.AppendIntL(iSize.iWidth, KOptWidth);
+
+	_LIT(KOptHeight, "height");
+	aOptions.AppendIntL(iSize.iHeight, KOptHeight);
+
+	_LIT(KOptTypefaceName, "typeface");
+	aOptions.AppendStringL(iTypefaceName, KOptTypefaceName);
+
+	_LIT(KOptMaxFontHeight, "max-font-height");
+	aOptions.AppendIntL(iMaxFontHeight, KOptMaxFontHeight);
+
+	_LIT(KOptGap, "gap");
+	aOptions.AppendIntL(iGap, KOptGap);
+	}
+	
+void CCmdGenbmp::RunL()
+	{
+	LeaveIfErr(iStatus.Int(), _L("Encode to BMP failed"));
+	Complete(KErrNone);
+	}
+
+
+EXE_BOILER_PLATE(CCmdGenbmp)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/genbmp/genbmp.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// genbmp.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_genbmp.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_GENBMP
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          genbmp.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         ecom.lib
+library         iocli.lib
+library         bitgdi.lib
+library         gdi.lib
+library         fbscli.lib
+library         imageconversion.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/getstack/getstack.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# getstack.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name getstack
+
+==short-description
+
+Dumps the specified thread's stack to a file.
+
+==argument filename file_name
+
+The name of the file to be written.
+
+==argument uint thread_id
+
+The thread's identifier.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/getstack/getstack.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,99 @@
+// getstack.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "getstack.h"
+#include <fshell/memoryaccess.h>
+
+
+CCommandBase* CCmdGetStack::NewLC()
+	{
+	CCmdGetStack* self = new(ELeave) CCmdGetStack();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdGetStack::~CCmdGetStack()
+	{
+	}
+
+CCmdGetStack::CCmdGetStack()
+	{
+	}
+
+const TDesC& CCmdGetStack::Name() const
+	{
+	_LIT(KName, "getstack");
+	return KName;
+	}
+
+void CCmdGetStack::DoRunL()
+	{
+	RMemoryAccess memoryAccess;
+	TInt err = RMemoryAccess::LoadDriver();
+	if ((err == KErrNone) || (err == KErrAlreadyExists))
+		{
+		User::LeaveIfError(memoryAccess.Open());
+		CleanupClosePushL(memoryAccess);
+		}
+	else
+		{
+		User::LeaveIfError(err);
+		}
+	RThread thread;
+	User::LeaveIfError(thread.Open(iThreadId));
+	CleanupClosePushL(thread);
+
+	RFile file;
+	User::LeaveIfError(file.Create(FsL(), iFileName, EFileWrite | EFileStream));
+	CleanupClosePushL(file);
+
+	TThreadStackInfo stackInfo;
+	User::LeaveIfError(thread.StackInfo(stackInfo));
+	const TInt stackSize = stackInfo.iBase - stackInfo.iLimit;
+
+	const TInt KBufSize = 4096; // The largest amount RMemoryAccess allows us to copy in one go.
+	HBufC8* stackBuf = HBufC8::NewLC(KBufSize);
+	TPtr8 stackBufPtr(stackBuf->Des());
+
+	TThreadMemoryAccessParamsBuf accessParamsBuf;
+	TThreadMemoryAccessParams& accessParams = accessParamsBuf();
+	accessParams.iId = (TInt)thread.Id().Id();
+
+	TInt numBytesRead = 0;
+	while (numBytesRead < stackSize)
+		{
+		accessParams.iAddr = (TUint8*)stackInfo.iLimit + numBytesRead;
+		accessParams.iSize = Min(KBufSize, stackSize - numBytesRead);
+		stackBufPtr.Zero();
+		User::LeaveIfError(memoryAccess.GetThreadMem(accessParamsBuf, stackBufPtr));
+		User::LeaveIfError(file.Write(*stackBuf));
+		numBytesRead += stackBuf->Length();
+		}
+
+	CleanupStack::PopAndDestroy(4, &memoryAccess);
+	}
+
+void CCmdGetStack::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFileName, "file_name");
+	aArguments.AppendFileNameL(iFileName, KArgFileName);
+
+	_LIT(KArgThreadId, "thread_id");
+	aArguments.AppendUintL(iThreadId, KArgThreadId);
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdGetStack)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/getstack/getstack.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// getstack.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+
+class CCmdGetStack : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdGetStack();
+private:
+	CCmdGetStack();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iThreadId;
+	TFileName2 iFileName;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/getstack/getstack.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// getstack.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          getstack.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_GETSTACK
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          getstack.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/glinfo/glinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# glinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name glinfo
+
+==short-description
+
+Display information about the currently installed graphics libraries.
+
+==argument enum library
+
+The library of interest.
+
+==enum-value egl
+
+Embedded-system Graphics Library.
+
+==enum-value openvg
+
+Open Vector Graphics Library.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/glinfo/glinfo.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,166 @@
+// glinfo.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <egl/egl.h>
+#include <vg/openvg.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdGlInfo : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdGlInfo();
+private:
+	CCmdGlInfo();
+
+#ifdef FSHELL_EGL_SUPPORT
+	void PrintElgInfoL();
+	void PrintElgQueryString(EGLDisplay aDisplay, EGLint aName, const TDesC8& aSymbol);
+#endif // FSHELL_EGL_SUPPORT
+
+#ifdef FSHELL_OPENVG_SUPPORT
+	void PrintOpenVgInfoL();
+	void PrintOpenVgString(VGStringID aName, const TDesC8& aSymbol);
+#endif // FSHELL_OPENVG_SUPPORT
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum
+		{
+		ELibEgl,
+		ELibOpenVg
+		} iLibrary;
+	};
+
+
+CCommandBase* CCmdGlInfo::NewLC()
+	{
+	CCmdGlInfo* self = new(ELeave) CCmdGlInfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdGlInfo::~CCmdGlInfo()
+	{
+	}
+
+CCmdGlInfo::CCmdGlInfo()
+	{
+	}
+
+#ifdef FSHELL_EGL_SUPPORT
+
+void CCmdGlInfo::PrintElgInfoL()
+	{
+    EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+	EGLint major;
+	EGLint minor;
+	if (!eglInitialize(dpy, &major, &minor))
+		{
+		LeaveIfErr(KErrGeneral, _L("Couldn't initialize EGL display"));
+		}
+	PrintElgQueryString(dpy, EGL_CLIENT_APIS, _L8("EGL_CLIENT_APIS"));
+	PrintElgQueryString(dpy, EGL_EXTENSIONS, _L8("EGL_EXTENSIONS"));
+	PrintElgQueryString(dpy, EGL_VENDOR, _L8("EGL_VENDOR"));
+	PrintElgQueryString(dpy, EGL_VERSION, _L8("EGL_VERSION"));
+	if (!eglTerminate(dpy))
+		{
+		LeaveIfErr(KErrGeneral, _L("Couldn't terminate EGL display"));
+		}
+	}
+
+void CCmdGlInfo::PrintElgQueryString(EGLDisplay aDisplay, EGLint aName, const TDesC8& aSymbol)
+	{
+	const char* string = eglQueryString(aDisplay, aName);
+	if (string == NULL)
+		{
+		string = "Unknown";
+		}
+	Printf(_L8("%S: %s\r\n"), &aSymbol, string);
+	}
+
+#endif // FSHELL_EGL_SUPPORT
+
+#ifdef FSHELL_OPENVG_SUPPORT
+
+void CCmdGlInfo::PrintOpenVgInfoL()
+	{
+	PrintOpenVgString(VG_VENDOR, _L8("VG_VENDOR"));
+	PrintOpenVgString(VG_RENDERER, _L8("VG_RENDERER"));
+	PrintOpenVgString(VG_EXTENSIONS, _L8("VG_EXTENSIONS"));
+	PrintOpenVgString(VG_VERSION, _L8("VG_VERSION"));
+	}
+
+void CCmdGlInfo::PrintOpenVgString(VGStringID aName, const TDesC8& aSymbol)
+	{
+	const VGubyte* string = vgGetString(aName);
+	if (string == NULL)
+		{
+		string = (const VGubyte*)"Unknown";
+		}
+	Printf(_L8("%S: %s\r\n"), &aSymbol, string);
+	}
+
+#endif // FSHELL_OPENVG_SUPPORT
+
+const TDesC& CCmdGlInfo::Name() const
+	{
+	_LIT(KName, "glinfo");	
+	return KName;
+	}
+
+void CCmdGlInfo::DoRunL()
+	{
+	switch (iLibrary)
+		{
+#ifdef FSHELL_EGL_SUPPORT
+		case ELibEgl:
+			{
+			PrintElgInfoL();
+			break;
+			}
+#endif // FSHELL_EGL_SUPPORT
+#ifdef FSHELL_OPENVG_SUPPORT
+		case ELibOpenVg:
+			{
+			PrintOpenVgInfoL();
+			break;
+			}
+#endif // FSHELL_OPENVG_SUPPORT
+		default:
+			{
+			User::Leave(KErrNotSupported);
+			}
+		}
+	}
+
+void CCmdGlInfo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgLibrary, "library");
+	aArguments.AppendEnumL((TInt&)iLibrary, KArgLibrary);
+	}
+
+void CCmdGlInfo::OptionsL(RCommandOptionList&)
+	{
+	}
+
+
+EXE_BOILER_PLATE(CCmdGlInfo)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/glinfo/glinfo.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// glinfo.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_glinfo.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_GLINFO
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+systeminclude   \epoc32\include\osextensions
+
+sourcepath      .
+source          glinfo.cpp
+
+library         euser.lib
+library         iocli.lib
+
+#ifdef FSHELL_EGL_SUPPORT
+library         libegl.lib
+#endif
+
+#ifdef FSHELL_OPENVG_SUPPORT
+library         libopenvg.lib
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/grabscreen/grabscreen.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,60 @@
+# grabscreen.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name grabscreen
+
+==short-description
+
+Creates a bitmap file of the current contents of the screen.
+
+==long-description
+
+Creates a bitmap file (by default in JPEG format) of the current contents of the screen. Only operates in graphical environments.
+
+==argument filename file_name optional
+
+The name of the bitmap file write. If not specified, writes to STDOUT. Must be specified when using raw format.
+
+==option enum f format
+
+The required output format; defaults to 'jpeg'. 'raw' is the format produced by CFbsBitmap::Save.
+
+==enum-value jpeg
+
+==enum-value gif
+
+==enum-value bmp
+
+==enum-value png
+
+==enum-value raw
+
+==option int r rect multiple
+
+The required rectangle to capture, specified as four integers corresponding to top left x, top left y, bottom right x and bottom right y. For example, C<--rect 10,15,50,65>.
+
+==option int s screen
+
+The required screen to capture from. Defaults to zero.
+
+==option int q quality
+
+The desired image quality. For 'jpeg', a value in the range 0-100.
+
+==option bool g greyscale
+
+Encode the screen as greyscale rather than colour, for a smaller file size. Supported for 'jpeg' and 'png'.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/grabscreen/grabscreen.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,290 @@
+// grabscreen.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <w32std.h>
+#include <fbs.h>
+#include <bitdev.h>
+#include <imageconversion.h>
+
+using namespace IoUtils;
+
+
+class CCmdGrabscreen : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdGrabscreen();
+private:
+	enum TFormat
+		{
+		EJpeg,
+		EGif,
+		EBmp,
+		EPng,
+		ERaw
+		};
+private:
+	CCmdGrabscreen();
+	void WriteEncodedL(TUid aEncodingUid);
+	void WriteRawL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	
+	virtual void RunL();
+private:
+	TFileName2 iFileName;
+	CImageEncoder* iImageEncoder;
+	HBufC8* iImageData;
+	CFrameImageData* iFrameImageData;
+	RFile iFile;
+	TFormat iFormat;
+	RArray<TInt> iRect;
+	TInt iScreen;
+	CFbsBitmap* iBitMap;
+	CWsScreenDevice* iDev;
+	RWsSession iWsSession;
+	TInt iQuality;
+	TBool iGreyscale;
+	};
+
+
+CCommandBase* CCmdGrabscreen::NewLC()
+	{
+	CCmdGrabscreen* self = new(ELeave) CCmdGrabscreen();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdGrabscreen::~CCmdGrabscreen()
+	{
+	delete iImageEncoder;
+	delete iFrameImageData;
+	delete iDev;
+	delete iBitMap;
+	delete iImageData;
+	iFile.Close();
+	iRect.Close();
+	iWsSession.Close();
+	REComSession::FinalClose();
+	}
+
+CCmdGrabscreen::CCmdGrabscreen() 
+	: CCommandBase(EManualComplete), iQuality(100)
+	{
+	}
+
+const TDesC& CCmdGrabscreen::Name() const
+	{
+	_LIT(KName, "grabscreen");	
+	return KName;
+	}
+
+void CCmdGrabscreen::DoRunL()
+	{
+	if ((iFormat == ERaw) && (!iArguments.IsPresent(0)))
+		{
+		PrintError(KErrArgument, _L("STDOUT writing is not supported for raw format; please specify a filename"));
+		DisplayHelp();
+		User::Leave(KErrArgument);
+		}
+	
+	LeaveIfErr(iWsSession.Connect(), _L("Couldn't connect to windowserver"));
+	iDev = new(ELeave) CWsScreenDevice(iWsSession);
+#ifdef SYMBIAN_WSERV_AND_CONE_MULTIPLE_SCREENS
+	const TInt numScreens = iWsSession.NumberOfScreens();
+	if (iScreen >= numScreens)
+		{
+		if (numScreens == 1)
+			{
+			LeaveIfErr(KErrArgument, _L("Invalid screen number - there is only 1 screen"));
+			}
+		else
+			{
+			LeaveIfErr(KErrArgument, _L("Invalid screen number - there are only %d screens"));
+			}
+		}
+#endif
+	LeaveIfErr(iDev->Construct(iScreen), _L("Couldn't construct CWsScreenDevice for screen %d"), iScreen);
+	iBitMap = new(ELeave) CFbsBitmap();
+
+	TRect rect;
+	if (iOptions.IsPresent(&iRect))
+		{
+		if (iRect.Count() != 4)
+			{
+			LeaveIfErr(KErrArgument, _L("Invalid --rect option - four integers must be specifed"));
+			}
+		rect.SetRect(iRect[0], iRect[1], iRect[2], iRect[3]);
+		}
+	else
+		{
+		rect.SetRect(TPoint(0, 0), iDev->SizeInPixels());
+		}
+	
+	LeaveIfErr(iBitMap->Create(rect.Size(), iDev->DisplayMode()), _L("Couldn't create fbsbitmap of size (%d,%d) for display mode %d"), rect.Width(), rect.Height(), iDev->DisplayMode());
+	User::LeaveIfError(iDev->CopyScreenToBitmap(iBitMap, rect));
+
+	switch (iFormat)
+		{
+		case EJpeg:
+			WriteEncodedL(KImageTypeJPGUid);
+			break;
+		case EGif:
+			WriteEncodedL(KImageTypeGIFUid);
+			break;
+		case EBmp:
+			WriteEncodedL(KImageTypeBMPUid);
+			break;
+		case EPng:
+			WriteEncodedL(KImageTypePNGUid);
+			break;
+		case ERaw:
+			WriteRawL();
+			break;
+		}
+	}
+
+void CCmdGrabscreen::WriteEncodedL(TUid aEncodingUid)
+	{
+	if (aEncodingUid == KImageTypeJPGUid)
+		{
+		TJpegImageData* imageData = new(ELeave) TJpegImageData();
+		CleanupStack::PushL(imageData);
+		imageData->iSampleScheme = iGreyscale ? TJpegImageData::EMonochrome : TJpegImageData::EColor444;
+		imageData->iQualityFactor = iQuality;
+		iFrameImageData = CFrameImageData::NewL();
+		User::LeaveIfError(iFrameImageData->AppendImageData(imageData));
+		CleanupStack::Pop(imageData);
+		}
+	else if (aEncodingUid == KImageTypeGIFUid)
+		{
+		if (iGreyscale)
+			{
+			PrintWarning(_L("Greyscale not supported for GIF images."));
+			}
+		if (iOptions.IsPresent(&iQuality))
+			{
+			PrintWarning(_L("Quality control not supported for GIF images."));
+			}
+		}
+	else if (aEncodingUid == KImageTypeBMPUid)
+		{
+		if (iGreyscale)
+			{
+			PrintWarning(_L("Greyscale not supported for BMP images."));
+			}
+		if (iOptions.IsPresent(&iQuality))
+			{
+			PrintWarning(_L("Quality control not supported for BMP images."));
+			}
+		}
+	else if (aEncodingUid == KImageTypePNGUid)
+		{
+		if (iOptions.IsPresent(&iQuality))
+			{
+			PrintWarning(_L("Quality control not supported for PNG images."));
+			}
+
+		TPngEncodeData* imageData = new(ELeave) TPngEncodeData();
+		CleanupStack::PushL(imageData);
+		imageData->iBitsPerPixel = iGreyscale ? 4 : 8;
+		imageData->iColor = !iGreyscale;
+		imageData->iLevel = TPngEncodeData::EBestCompression;
+		imageData->iPaletted = EFalse;
+		iFrameImageData = CFrameImageData::NewL();
+		User::LeaveIfError(iFrameImageData->AppendFrameData(imageData));
+		CleanupStack::Pop(imageData);
+		}
+		
+	if (iArguments.IsPresent(0))
+		{
+		LeaveIfErr(iFile.Replace(FsL(), iFileName, EFileWrite), _L("Unable to open \"%S\" for writing"), &iFileName);
+		iImageEncoder = CImageEncoder::FileNewL(iFile, CImageEncoder::EOptionNone, aEncodingUid);
+		}
+	else
+		{
+		iImageEncoder = CImageEncoder::DataNewL(iImageData, CImageEncoder::EOptionNone, aEncodingUid);
+		}
+	iImageEncoder->Convert(&iStatus, *iBitMap, iFrameImageData);
+	SetActive();
+	}
+	
+void CCmdGrabscreen::RunL()
+	{
+	User::LeaveIfError(iStatus.Int());
+	if (!iArguments.IsPresent(0))
+		{
+		User::LeaveIfNull(iImageData);
+		
+		Stdout().SetModeL(RIoReadWriteHandle::EBinary);
+		
+		// we need to expand the 8 bit data when writing to stdout
+		static const TInt KBufferSize = 0x100;
+		TBuf<KBufferSize> buf;
+		TPtr8 imageData(iImageData->Des());
+		while (imageData.Length())
+			{
+			TInt thisCopyLen = Min(KBufferSize, imageData.Length());
+			buf.Copy(imageData.Left(thisCopyLen));
+			imageData.Set(imageData.MidTPtr(thisCopyLen));
+			Stdout().WriteL(buf);
+			}
+		}
+	Complete(KErrNone);
+	}
+
+void CCmdGrabscreen::WriteRawL()
+	{
+	if (iGreyscale)
+		{
+		PrintWarning(_L("Greyscale not supported for raw images."));
+		}
+	if (iOptions.IsPresent(&iQuality))
+		{
+		PrintWarning(_L("Quality control not supported for raw images."));
+		}
+	LeaveIfErr(iBitMap->Save(iFileName), _L("Unable to write \"%S\""), &iFileName);
+	Complete(KErrNone);
+	}
+
+void CCmdGrabscreen::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg, "file_name");
+	aArguments.AppendFileNameL(iFileName, KArg);
+	}
+
+void CCmdGrabscreen::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptFormat, "format");
+	aOptions.AppendEnumL((TInt&)iFormat, KOptFormat);
+
+	_LIT(KOptRect, "rect");
+	aOptions.AppendIntL(iRect, KOptRect);
+
+	_LIT(KOptScreen, "screen");
+	aOptions.AppendIntL(iScreen, KOptScreen);
+
+	_LIT(KOptQuality, "quality");
+	aOptions.AppendIntL(iQuality, KOptQuality);
+
+	_LIT(KOptGreyscale, "greyscale");
+	aOptions.AppendBoolL(iGreyscale, KOptGreyscale);
+	}
+
+
+EXE_BOILER_PLATE(CCmdGrabscreen)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/grabscreen/grabscreen.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// grabscreen.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          grabscreen.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_GRABSCREEN
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          grabscreen.cpp
+
+library         euser.lib
+library         iocli.lib
+library         ws32.lib
+library         bitgdi.lib
+library         fbscli.lib
+library         efsrv.lib
+library         imageconversion.lib
+library         ecom.lib
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,447 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+
+FSHELL_ROM_INCLUDE(fshell_commands.iby)
+
+..\cat\cat.cif                           z:\resource\cif\fshell\cat.cif
+..\tail\tail.cif                         z:\resource\cif\fshell\tail.cif
+..\leak\leak.cif                         z:\resource\cif\fshell\leak.cif
+..\drvinfo\drvinfo.cif                   z:\resource\cif\fshell\drvinfo.cif
+..\clipboard\clipboard.cif               z:\resource\cif\fshell\clipboard.cif
+..\backup\backup.cif                     z:\resource\cif\fshell\backup.cif
+..\restore\restore.cif                   z:\resource\cif\fshell\restore.cif
+..\chkdrift\chkdrift.cif                 z:\resource\cif\fshell\chkdrift.cif
+..\spinlock\spinlock.cif                 z:\resource\cif\fshell\spinlock.cif
+..\load\load.cif                         z:\resource\cif\fshell\load.cif
+..\cenrep\cenrep.cif                     z:\resource\cif\fshell\cenrep.cif
+..\cloggerconfig\cloggerconfig.cif       z:\resource\cif\fshell\cloggerconfig.cif
+..\pubsub\pubsub.cif                     z:\resource\cif\fshell\pubsub.cif
+..\rez\rez.cif                           z:\resource\cif\fshell\rez.cif
+..\find\find.cif                         z:\resource\cif\fshell\find.cif
+..\sysinfo\sysinfo.cif                   z:\resource\cif\fshell\sysinfo.cif
+..\uidinfo\uidinfo.cif                   z:\resource\cif\fshell\uidinfo.cif
+..\fed\group\fed.cif                     z:\resource\cif\fshell\fed.cif
+..\snake\snake.cif                       z:\resource\cif\fshell\snake.cif
+..\iniedit\iniedit.cif                   z:\resource\cif\fshell\iniedit.cif
+
+PRJ_MMPFILES
+..\cat\cat.mmp
+..\tail\tail.mmp
+..\leak\leak.mmp
+..\drvinfo\drvinfo.mmp
+..\clipboard\clipboard.mmp
+..\backup\backup.mmp
+..\backup\backup_child.mmp
+..\restore\restore.mmp
+..\chkdrift\chkdrift.mmp
+..\spinlock\spinlock.mmp
+..\load\load.mmp
+..\cenrep\cenrep.mmp
+..\cloggerconfig\cloggerconfig.mmp
+..\pubsub\pubsub.mmp
+..\rez\rez.mmp
+..\find\find.mmp
+..\sysinfo\sysinfo.mmp
+..\uidinfo\uidinfo.mmp
+..\fed\group\fed.mmp
+..\snake\snake.mmp
+..\iniedit\iniedit.mmp
+
+#ifdef FSHELL_CORE_SUPPORT_SWI
+PRJ_EXPORTS
+..\swi\swi.cif           z:\resource\cif\fshell\swi.cif
+PRJ_MMPFILES
+..\swi\swi.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_PATCHDATA
+PRJ_EXPORTS
+..\patchdata\patchdata.cif          z:\resource\cif\fshell\patchdata.cif
+PRJ_MMPFILES
+..\patchdata\patchdata.mmp
+#endif
+
+#ifdef FSHELL_TRACE_SUPPORT
+// Btrace.cif needs to exported if any kind of tracing supported
+PRJ_EXPORTS
+..\btrace\btrace.cif             z:\resource\cif\fshell\btrace.cif
+#endif
+#ifdef FSHELL_CORE_SUPPORT_BTRACE
+PRJ_MMPFILES
+..\btrace\btrace.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_GETHEAP
+PRJ_EXPORTS
+..\getheap\getheap.cif            z:\resource\cif\fshell\getheap.cif
+PRJ_MMPFILES
+..\getheap\getheap.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_GETSTACK
+PRJ_EXPORTS
+..\getstack\getstack.cif           z:\resource\cif\fshell\getstack.cif
+PRJ_MMPFILES
+..\getstack\getstack.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SUDO
+PRJ_EXPORTS
+..\sudo\sudo.cif               z:\resource\cif\fshell\sudo.cif
+PRJ_MMPFILES
+..\sudo\sudo.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_CHKDEPS
+PRJ_EXPORTS
+..\chkdeps\chkdeps.cif            z:\resource\cif\fshell\chkdeps.cif
+PRJ_MMPFILES
+..\chkdeps\chkdeps.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_MEMSAMPLER
+PRJ_EXPORTS
+..\memsampler\memsampler.cif         z:\resource\cif\fshell\memsampler.cif
+PRJ_MMPFILES
+..\memsampler\memsampler.mmp
+..\memsampler\memsamplerdd.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FCONTACTS
+PRJ_EXPORTS
+..\fcontacts\fcontacts.cif          z:\resource\cif\fshell\fcontacts.cif
+PRJ_MMPFILES
+..\fcontacts\fcontacts.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_PING
+PRJ_EXPORTS
+..\ping\ping.cif          z:\resource\cif\fshell\ping.cif
+PRJ_MMPFILES
+..\ping\ping.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FCALENDAR
+PRJ_EXPORTS
+..\fcalendar\fcalendar.cif          z:\resource\cif\fshell\fcalendar.cif
+PRJ_MMPFILES
+..\fcalendar\fcalendar.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_MROUTER
+PRJ_EXPORTS
+..\mrouter\mrouter.cif                z:\resource\cif\fshell\mrouter.cif
+PRJ_MMPFILES
+..\mrouter\mrouter.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_UPROFILER
+PRJ_EXPORTS
+..\uprofiler\uprofiler.cif           z:\resource\cif\fshell\uprofiler.cif
+PRJ_MMPFILES
+..\uprofiler\uprofiler.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_BTRACEOUT
+PRJ_EXPORTS
+..\btraceout\btraceout.cif                z:\resource\cif\fshell\btraceout.cif
+PRJ_MMPFILES
+..\btraceout\btraceout.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_LISTAPPS
+PRJ_EXPORTS
+..\listapps\listapps.cif               z:\resource\cif\fshell\listapps.cif
+PRJ_MMPFILES
+..\listapps\listapps.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SHUTAPP
+PRJ_EXPORTS
+..\shutapp\shutapp.cif               z:\resource\cif\fshell\shutapp.cif
+PRJ_MMPFILES
+..\shutapp\shutapp.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_OPENDOC
+PRJ_EXPORTS
+..\opendoc\opendoc.cif                z:\resource\cif\fshell\opendoc.cif
+PRJ_MMPFILES
+..\opendoc\opendoc.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_GRABSCREEN
+PRJ_EXPORTS
+..\grabscreen\grabscreen.cif             z:\resource\cif\fshell\grabscreen.cif
+PRJ_MMPFILES
+..\grabscreen\grabscreen.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FOCUS
+PRJ_EXPORTS
+..\focus\focus.cif                  z:\resource\cif\fshell\focus.cif
+PRJ_MMPFILES
+..\focus\focus.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_ACTIVEVIEW
+PRJ_EXPORTS
+..\activeview\activeview.cif             z:\resource\cif\fshell\activeview.cif
+PRJ_MMPFILES
+..\activeview\activeview.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SWITCHVIEW
+PRJ_EXPORTS
+..\switchview\switchview.cif             z:\resource\cif\fshell\switchview.cif
+PRJ_MMPFILES
+..\switchview\switchview.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_PLAY
+PRJ_EXPORTS
+..\play\play.cif                   z:\resource\cif\fshell\play.cif
+PRJ_MMPFILES
+..\play\play.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_WGET
+PRJ_EXPORTS
+..\wget\wget.cif              z:\resource\cif\fshell\wget.cif
+PRJ_MMPFILES
+..\wget\wget.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FZIP
+PRJ_EXPORTS
+..\fzip\fzip.cif                    z:\resource\cif\fshell\fzip.cif
+PRJ_MMPFILES
+..\fzip\fzip.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_WSLOG
+PRJ_EXPORTS
+..\wslog\wslog.cif             z:\resource\cif\fshell\wslog.cif
+PRJ_MMPFILES
+..\wslog\wslog.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_RCOMM
+PRJ_EXPORTS
+..\rcomm\rcomm.cif                  z:\resource\cif\fshell\rcomm.cif
+PRJ_MMPFILES
+..\rcomm\rcomm.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_RCONN
+PRJ_EXPORTS
+..\rconn\rconn.cif                  z:\resource\cif\fshell\rconn.cif
+PRJ_MMPFILES
+..\rconn\rconn.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_IAP
+PRJ_EXPORTS
+..\iap\iap.cif                    z:\resource\cif\fshell\iap.cif
+PRJ_MMPFILES
+..\iap\iap.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_BTSERVICES
+PRJ_EXPORTS
+..\btservices\btservices.cif                    z:\resource\cif\fshell\btservices.cif
+PRJ_MMPFILES
+..\btservices\btservices.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SCREENMODE
+PRJ_EXPORTS
+..\screenmode\screenmode.cif        z:\resource\cif\fshell\screenmode.cif
+PRJ_MMPFILES
+..\screenmode\screenmode.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_HEAPTRACE
+PRJ_EXPORTS
+..\heaptrace\heaptrace.cif        z:\resource\cif\fshell\heaptrace.cif
+PRJ_MMPFILES
+..\heaptrace\heaptrace.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_PASTE
+PRJ_EXPORTS
+..\paste\paste.cif        z:\resource\cif\fshell\paste.cif
+PRJ_MMPFILES
+..\paste\paste.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_RAMDEFRAG
+PRJ_EXPORTS
+..\ramdefrag\ramdefrag.cif        z:\resource\cif\fshell\ramdefrag.cif
+PRJ_MMPFILES
+..\ramdefrag\ramdefrag.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_ICC
+PRJ_EXPORTS
+..\icc\icc.cif        z:\resource\cif\fshell\icc.cif
+PRJ_MMPFILES
+..\icc\icc.mmp
+#endif
+
+PRJ_EXPORTS
+..\ecom\ecom.cif        z:\resource\cif\fshell\ecom.cif
+PRJ_MMPFILES
+..\ecom\ecom.mmp
+
+#ifdef FSHELL_CORE_SUPPORT_RSOCKET
+PRJ_EXPORTS
+..\rsocket\rsocket.cif        z:\resource\cif\fshell\rsocket.cif
+PRJ_MMPFILES
+..\rsocket\rsocket.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_GENBMP
+PRJ_EXPORTS
+..\genbmp\genbmp.cif        z:\resource\cif\fshell\genbmp.cif
+PRJ_MMPFILES
+..\genbmp\genbmp.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_TFINFO
+PRJ_EXPORTS
+..\tfinfo\tfinfo.cif        z:\resource\cif\fshell\tfinfo.cif
+PRJ_MMPFILES
+..\tfinfo\tfinfo.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FDB
+PRJ_EXPORTS
+..\fdb\fdb.cif        z:\resource\cif\fshell\fdb.cif
+PRJ_MMPFILES
+..\fdb\fdb.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_NITZ
+PRJ_EXPORTS
+..\nitz\nitz.cif        z:\resource\cif\fshell\nitz.cif
+PRJ_MMPFILES
+..\nitz\nitz.mmp
+#endif
+
+PRJ_EXPORTS
+..\hal\hal.cif        z:\resource\cif\fshell\hal.cif
+PRJ_MMPFILES
+..\hal\hal.mmp
+
+PRJ_EXPORTS
+..\pointer\pointer.cif        z:\resource\cif\fshell\pointer.cif
+PRJ_MMPFILES
+..\pointer\pointer.mmp
+
+#ifdef FSHELL_CORE_SUPPORT_LBS
+PRJ_EXPORTS
+..\lbs\lbs.cif        z:\resource\cif\fshell\lbs.cif
+PRJ_MMPFILES
+..\lbs\lbs.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SQL
+PRJ_EXPORTS
+..\sql\sql.cif        z:\resource\cif\fshell\sql.cif
+PRJ_MMPFILES
+..\sql\sql.mmp
+..\sql\sqlsrv.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_GLINFO
+PRJ_EXPORTS
+..\glinfo\glinfo.cif        z:\resource\cif\fshell\glinfo.cif
+PRJ_MMPFILES
+..\glinfo\glinfo.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_HASH
+PRJ_EXPORTS
+..\hash\hash.cif        z:\resource\cif\fshell\hash.cif
+PRJ_MMPFILES
+..\hash\hash.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_STARTUP
+PRJ_EXPORTS
+..\startup\startup.cif        z:\resource\cif\fshell\startup.cif
+PRJ_MMPFILES
+..\startup\startup.mmp
+#endif
+
+#ifdef FSHELL_FSTRACER_SUPPORT
+PRJ_EXPORTS
+..\ffstrace\ffstrace.cif        z:\resource\cif\fshell\ffstrace.cif
+PRJ_MMPFILES
+..\ffstrace\ffstraceplugin.mmp
+..\ffstrace\ffstrace.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_LOCALDRIVE
+PRJ_EXPORTS
+..\localdrive\localdrive.cif        z:\resource\cif\fshell\localdrive.cif
+PRJ_MMPFILES
+..\localdrive\localdrive.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_BUILTIN_VARIANT
+PRJ_EXPORTS
+..\variant\variant.cif           z:\resource\cif\fshell\variant.cif
+PRJ_MMPFILES
+..\variant\variant.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_USB
+PRJ_EXPORTS
+..\usb\usb.cif                    z:\resource\cif\fshell\usb.cif
+PRJ_MMPFILES
+..\usb\usb.mmp
+#endif
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+PRJ_EXPORTS
+..\kerninfo\kerninfo.cif		z:\resource\cif\fshell\kerninfo.cif
+..\setpriority\setpriority.cif		z:\resource\cif\fshell\setpriority.cif
+..\setcritical\setcritical.cif		z:\resource\cif\fshell\setcritical.cif
+..\top\top.cif				z:\resource\cif\fshell\top.cif
+PRJ_MMPFILES
+..\kerninfo\kerninfo.mmp
+..\setpriority\setpriority.mmp
+..\setcritical\setcritical.mmp
+..\top\top.mmp
+..\top\top_sampler.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SMS
+PRJ_EXPORTS
+..\sms\sms.cif                    z:\resource\cif\fshell\sms.cif
+PRJ_MMPFILES
+..\sms\sms.mmp
+#endif
+
+#ifdef FSHELL_MEMSPY_SUPPORT
+PRJ_EXPORTS
+..\memspy\memspy.cif			z:\resource\cif\fshell\memspy.cif
+PRJ_MMPFILES
+..\memspy\memspy.mmp
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/group/fshell_commands.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,372 @@
+// fshell_commands.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __FSHELL_COMMANDS_IBY__
+#define __FSHELL_COMMANDS_IBY__
+
+#include <fsh_config.iby>
+
+#if defined(FSHELL_ROMBUILD) && defined(FSHELL_CORE_SUPPORT_SWI)
+// Note, we only want to include Software Install dependencies when building a
+// ROM. When building a SIS, these should already be present in the target handset.
+#include <swi.iby>
+#endif
+
+FSHELL_EXECUTABLE_FILE(fshell_cat.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,cat.cif)
+
+FSHELL_EXECUTABLE_FILE(fshell_tail.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,tail.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_GETHEAP
+FSHELL_EXECUTABLE_FILE(getheap.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,getheap.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_GETSTACK
+FSHELL_EXECUTABLE_FILE(getstack.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,getstack.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_LISTAPPS
+FSHELL_EXECUTABLE_FILE(listapps.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,listapps.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SHUTAPP
+FSHELL_EXECUTABLE_FILE(shutapp.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,shutapp.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(leak.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,leak.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_OPENDOC
+FSHELL_EXECUTABLE_FILE(opendoc.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,opendoc.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(cenrep.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,cenrep.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_GRABSCREEN
+FSHELL_EXECUTABLE_FILE(grabscreen.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,grabscreen.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_MROUTER
+FSHELL_EXECUTABLE_FILE(mrouter.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,mrouter.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(drvinfo.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,drvinfo.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_RCOMM
+FSHELL_EXECUTABLE_FILE(rcomm.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,rcomm.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_CHKDEPS
+FSHELL_EXECUTABLE_FILE(chkdeps.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,chkdeps.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_PLAY
+FSHELL_EXECUTABLE_FILE(play.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,play.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SUDO
+FSHELL_EXECUTABLE_FILE(sudo.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,sudo.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(clipboard.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,clipboard.cif)
+
+FSHELL_EXECUTABLE_FILE(backup.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,backup.cif)
+
+FSHELL_EXECUTABLE_FILE(restore.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,restore.cif)
+
+FSHELL_EXECUTABLE_FILE(backup_child.exe)
+
+FSHELL_EXECUTABLE_FILE(chkdrift.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,chkdrift.cif)
+
+FSHELL_EXECUTABLE_FILE(sysinfo.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,sysinfo.cif)
+
+FSHELL_EXECUTABLE_FILE(iniedit.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,iniedit.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_PATCHDATA
+FSHELL_EXECUTABLE_FILE(patchdata.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,patchdata.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(spinlock.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,spinlock.cif)
+
+FSHELL_EXECUTABLE_FILE(fshell_load.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,load.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_FOCUS
+FSHELL_EXECUTABLE_FILE(focus.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,focus.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_ACTIVEVIEW
+FSHELL_EXECUTABLE_FILE(activeview.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,activeview.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SWITCHVIEW
+FSHELL_EXECUTABLE_FILE(switchview.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,switchview.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SWI
+FSHELL_EXECUTABLE_FILE(swi.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,swi.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_WGET
+FSHELL_COMMAND_INFO_FILE(fshell,wget.cif)
+FSHELL_EXECUTABLE_FILE(wget.exe)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_IAP
+FSHELL_EXECUTABLE_FILE(iap.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,iap.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FZIP
+FSHELL_EXECUTABLE_FILE(fzip.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,fzip.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(pubsub.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,pubsub.cif)
+
+FSHELL_EXECUTABLE_FILE(cloggerconfig.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,cloggerconfig.cif)
+
+#ifdef FSHELL_TRACE_SUPPORT
+// The cif is needed by atrace, potentially
+FSHELL_COMMAND_INFO_FILE(fshell,btrace.cif)
+#endif
+#ifdef FSHELL_CORE_SUPPORT_BTRACE
+FSHELL_EXECUTABLE_FILE(fshell_btrace.exe)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_ATRACE
+FSHELL_EXECUTABLE_FILE(atrace.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,atrace.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FCONTACTS
+FSHELL_EXECUTABLE_FILE(fcontacts.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,fcontacts.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_MEMSAMPLER
+FSHELL_EXECUTABLE_FILE(memsampler.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,memsampler.cif)
+FSHELL_DEVICE_DRIVER(memsamplerdd.ldd)
+#endif
+
+FSHELL_EXECUTABLE_FILE(rez.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,rez.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_RCONN
+FSHELL_EXECUTABLE_FILE(rconn.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,rconn.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_WSLOG
+FSHELL_EXECUTABLE_FILE(wslog.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,wslog.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_BUILTIN_VARIANT
+FSHELL_EXECUTABLE_FILE(variant.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,variant.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_PING
+FSHELL_EXECUTABLE_FILE(fshell_ping.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,ping.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FCALENDAR
+FSHELL_EXECUTABLE_FILE(fcalendar.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,fcalendar.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(fshell_find.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,find.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_UPROFILER
+FSHELL_EXECUTABLE_FILE(fshell_uprofiler.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,uprofiler.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_BTRACEOUT
+FSHELL_EXECUTABLE_FILE(btraceout.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,btraceout.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_BTSERVICES
+FSHELL_EXECUTABLE_FILE(fshell_btservices.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,btservices.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(uidinfo.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,uidinfo.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_SCREENMODE
+FSHELL_EXECUTABLE_FILE(screenmode.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,screenmode.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_HEAPTRACE
+FSHELL_EXECUTABLE_FILE(heaptrace.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,heaptrace.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_PASTE
+FSHELL_EXECUTABLE_FILE(paste.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,paste.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_RAMDEFRAG
+FSHELL_EXECUTABLE_FILE(fshell_ramdefrag.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,ramdefrag.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_ICC
+FSHELL_EXECUTABLE_FILE(fshell_icc.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,icc.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(fshell_ecom.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,ecom.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_RSOCKET
+FSHELL_EXECUTABLE_FILE(fshell_rsocket.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,rsocket.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_TFINFO
+FSHELL_EXECUTABLE_FILE(fshell_tfinfo.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,tfinfo.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_GENBMP
+FSHELL_EXECUTABLE_FILE(fshell_genbmp.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,genbmp.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_FDB
+FSHELL_EXECUTABLE_FILE(fdb.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,fdb.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_NITZ
+FSHELL_EXECUTABLE_FILE(fshell_nitz.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,nitz.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(fshell_hal.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,hal.cif)
+
+FSHELL_EXECUTABLE_FILE(pointer.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,pointer.cif)
+
+#ifdef FSHELL_CORE_SUPPORT_LBS
+FSHELL_EXECUTABLE_FILE(fshell_lbs.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,lbs.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SQL
+FSHELL_EXECUTABLE_FILE(fshell_sql.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,sql.cif)
+FSHELL_EXECUTABLE_FILE(fshell_sqlsrv.exe)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_GLINFO
+FSHELL_EXECUTABLE_FILE(fshell_glinfo.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,glinfo.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_HASH
+FSHELL_EXECUTABLE_FILE(fshell_hash.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,hash.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_STARTUP
+FSHELL_EXECUTABLE_FILE(fshell_startup.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,startup.cif)
+#endif
+
+#ifdef FSHELL_FSTRACER_SUPPORT
+FSHELL_EXECUTABLE_FILE(ffstrace.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,ffstrace.cif)
+FSHELL_EXECUTABLE_FILE(ffstraceplugin.fxt)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_LOCALDRIVE
+FSHELL_EXECUTABLE_FILE(localdrive.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,localdrive.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_USB
+FSHELL_EXECUTABLE_FILE(fshell_usb.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,usb.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SMS
+FSHELL_EXECUTABLE_FILE(fshell_sms.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,sms.cif)
+#endif
+
+#ifdef FSHELL_MEMSPY_SUPPORT
+FSHELL_EXECUTABLE_FILE(fshell_memspy.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,memspy.cif)
+#endif
+
+FSHELL_EXECUTABLE_FILE(fed.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,fed.cif)
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+FSHELL_EXECUTABLE_FILE(kerninfo.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,kerninfo.cif)
+FSHELL_EXECUTABLE_FILE(setpriority.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,setpriority.cif)
+FSHELL_EXECUTABLE_FILE(setcritical.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,setcritical.cif)
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_TOP
+#if defined(FSHELL_ROMBUILD) && defined(SMP)
+// Don't include topsampler on SMP rombuilds.
+// We don't build the armv5smp topsampler and this will otherwise try and put the armv5 one on the rom, which will fail to link against the SMP kernel
+#else
+FSHELL_DEVICE_DRIVER(topsampler.ldd)
+#endif
+FSHELL_EXECUTABLE_FILE(top.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,top.cif)
+#endif
+
+#endif // __FSHELL_COMMANDS_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/hal/hal.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+# hal.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name hal
+
+==short-description
+
+Set, get and list available Hardware Abstraction Layer attributes.
+
+==see-also
+
+L<sysinfo|sysinfo>, L<kerninfo|kerninfo>
+
+==argument enum operation optional
+
+The required operation. If not specified, 'list' is assumed.
+
+==enum-value list
+
+List all the attributes on the system.
+
+==enum-value get
+
+Get a HAL value.
+
+==enum-value set
+
+Set a HAL value.
+
+==enum-value dump
+
+Display the contents of (by default) '<system_drive>:\private\102825B1\HAL.DAT' in symbolic form. Note, the name of the file to be dumped can be overridden with the '-f' option.
+
+==argument uint attribute optional
+
+The attribute to get or set.
+
+==argument int value optional
+
+The attribute value to set.
+
+==option int d device
+
+Specify the HAL device number. This can be used, for example, to specify which screen you are interested in.
+
+==option filename f dump-file-name
+
+Specify the name of the file to be dumped by the 'dump-file' operation.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/hal/hal.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,196 @@
+// hal.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <hal.h>
+#include <fshell/common.mmh>
+#include <fshell/ltkhal.h>
+
+using namespace IoUtils;
+
+_LIT(KDefaultDumpFileName, "c:\\private\\102825B1\\HAL.DAT");
+
+class CCmdHal : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdHal();
+private:
+	CCmdHal();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum 
+		{
+		EList,
+		EGet,
+		ESet,
+		EDumpFile
+		} iOperation;
+	HAL::TAttribute iAttribute;
+	TInt iValue;
+	TInt iDeviceNumber;
+	TFileName2 iDumpFileName;
+	};
+
+
+CCommandBase* CCmdHal::NewLC()
+	{
+	CCmdHal* self = new(ELeave) CCmdHal();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdHal::~CCmdHal()
+	{
+	}
+
+CCmdHal::CCmdHal() : iDumpFileName(KDefaultDumpFileName)
+	{
+	}
+
+const TDesC& CCmdHal::Name() const
+	{
+	_LIT(KName, "hal");	
+	return KName;
+	}
+
+void CCmdHal::DoRunL()
+	{
+	switch (iOperation)
+		{
+		case EGet:
+			{
+			if (!iArguments.IsPresent(1))
+				{
+				LeaveIfErr(KErrArgument, _L("Attribute to get not specified"));
+				}
+			LtkUtils::CHalAttribute* attrib = NULL;
+			if (iOptions.IsPresent(&iDeviceNumber))
+				{
+				TRAPL(attrib = LtkUtils::GetHalInfoL(iDeviceNumber, iAttribute), _L("Couldn't get attribute value"));
+				}
+			else
+				{
+				TRAPL(attrib = LtkUtils::GetHalInfoL(iAttribute), _L("Couldn't get attribute value"));
+				}
+			Printf(_L("%S: %S\r\n"), &attrib->iAttributeName, attrib->iDescription);
+			delete attrib;
+			}
+			break;
+		case ESet:
+			{
+			if (!iArguments.IsPresent(1))
+				{
+				LeaveIfErr(KErrArgument, _L("Attribute to set not specified"));
+				}
+			if (!iArguments.IsPresent(2))
+				{
+				LeaveIfErr(KErrArgument, _L("Attribute value to set not specified"));
+				}
+			if (iOptions.IsPresent(&iDeviceNumber))
+				{
+				LeaveIfErr(HAL::Set(iDeviceNumber, iAttribute, iValue), _L("Couldn't set attribute"));
+				}
+			else
+				{
+				LeaveIfErr(HAL::Set(iAttribute, iValue), _L("Couldn't set attribute"));
+				}
+			}
+			break;
+		case EList:
+			{
+			RPointerArray<LtkUtils::CHalAttribute> attribs;
+			LtkUtils::GetHalInfoL(attribs);
+			for (TInt i = 0; i < attribs.Count(); ++i)
+				{
+				LtkUtils::CHalAttribute& attrib = *attribs[i];
+				Printf(_L("%4d %S: %S\r\n"), attrib.iAttribute, &attrib.iAttributeName, attrib.iDescription);
+				}
+			attribs.ResetAndDestroy();
+			}
+			break;
+		case EDumpFile:
+			{
+			if (!iOptions.IsPresent(&iDumpFileName))
+				{
+#ifdef FSHELL_9_1_SUPPORT
+				TInt ch = 'c';
+				HAL::Get(HAL::ESystemDrive, ch);
+				iDumpFileName[0] = 'A' + ch;
+#else
+				iDumpFileName[0] = 'A' + static_cast<TInt>(RFs::GetSystemDrive());
+#endif
+				}
+			RFile file;
+			LeaveIfErr(file.Open(FsL(), iDumpFileName, EFileRead), _L("Couldn't open \"%S\" for reading"), &iDumpFileName);
+			CleanupClosePushL(file);
+
+			TInt fileSize;
+			LeaveIfErr(file.Size(fileSize), _L("Couldn't find the size of \"%S\""), &iDumpFileName);
+
+			RBuf8 buf;
+			buf.Create(fileSize);
+			buf.CleanupClosePushL();
+
+			LeaveIfErr(file.Read(buf), _L("Couldn't read \"%S\""), &iDumpFileName);
+
+			TInt32* p = (TInt32*)buf.Ptr();
+			TInt32* pE = p + (fileSize / sizeof(TInt32)) - 1;
+			Printf(_L("Machine UID: 0x%08x\r\n"), *p++);
+			Printf(_L("Type prefix: 0x%08x\r\n"), *p++);
+
+			while (p < pE)
+				{
+				TInt attribute = *p++;
+				TInt deviceNumber = (TUint)attribute >> 24;
+				attribute &= 0xFFFFFF;
+				TInt value = *p++;
+				LtkUtils::CHalAttribute* attrib = LtkUtils::GetHalInfoForValueL(deviceNumber, attribute, value);
+				Printf(_L("%4d %S[%d]: %S\r\n"), attrib->iAttribute, &attrib->iAttributeName, deviceNumber, attrib->iDescription);
+				delete attrib;
+				}
+
+			CleanupStack::PopAndDestroy(2, &file);
+			}
+			break;
+		}
+	}
+
+void CCmdHal::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgOperation, "operation");
+	aArguments.AppendEnumL((TInt&)iOperation, KArgOperation);
+
+	_LIT(KArgAttribute, "attribute");
+	aArguments.AppendUintL((TUint&)iAttribute, KArgAttribute);
+
+	_LIT(KArgValue, "value");
+	aArguments.AppendIntL(iValue, KArgValue);
+	}
+
+void CCmdHal::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptDevice, "device");
+	aOptions.AppendIntL(iDeviceNumber, KOptDevice);
+
+	_LIT(KOptDumpFileName, "dump-file-name");
+	aOptions.AppendFileNameL(iDumpFileName, KOptDumpFileName);
+	}
+
+
+EXE_BOILER_PLATE(CCmdHal)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/hal/hal.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// hal.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_hal.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_HAL
+capability      FSHELL_CAP_MMP_MAX
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          hal.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+library         hal.lib
+library         ltkutils-tcb.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/hash/hash.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,63 @@
+# hash.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name hash
+
+==short-description
+
+Calculate cryptographic hashes.
+
+==long-description
+
+Given some input data, caculates a corresponding number using one of several supported hashing algorithms. Hashing algorithms are designed to have a high likelihood of producing a significantly different number for even small differences in input data. As such, they are useful gaining a degree of certainly about whether a particular data set has changed without having to store the whole data set.
+
+Reads data to be hashed either from a file or from STDIN. Writes the corresponding hash either to a file or to STDOUT. Supports a variety of different hashing algorithms.
+
+Defaults to using the SHA1 algorithm if the '-a' option is not specified. This means that to create an hash file of an executable file stored on removable media (such that F32 will allow it to be loaded), run:
+
+  hash -i <executable_file_name> -o c:\sys\hash\<executable_file_name>
+
+==option bool v verbose
+
+Verbose output.
+
+==option filename i input
+
+The name of the file whose data is to be hashed. If not specified, data is read from STDIN.
+
+==option filename o output
+
+The name of the file to write the hash to. If not specified, the hash is ASCII / hex dumped to STDOUT.
+
+==option enum a algorithm
+
+==enum-value SHA1
+
+==enum-value MD2
+
+==enum-value MD4
+
+==enum-value MD5
+
+==enum-value SHA224
+
+==enum-value SHA256
+
+==enum-value SHA384
+
+==enum-value SHA512
+
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/hash/hash.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,178 @@
+// hash.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/ltkutils.h>
+#include <fshell/common.mmh>
+#include <hash.h>
+
+const TInt KBlockSize = 512;
+
+using namespace IoUtils;
+
+class CCmdHash : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdHash();
+private:
+	CCmdHash();
+	CMessageDigest::THashId HashIdL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iVerbose;
+	TFileName2 iInputFileName;
+	TFileName2 iOutputFileName;
+	enum TAlgorithm
+		{
+		ESha1,
+		ESha224,
+		ESha256,
+		ESha384,
+		ESha512,
+		EMd2,
+		EMd4,
+		EMd5
+		} iAlgorithm;
+	CMessageDigest* iMessageDigest;
+	};
+
+
+CCommandBase* CCmdHash::NewLC()
+	{
+	CCmdHash* self = new(ELeave) CCmdHash();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdHash::~CCmdHash()
+	{
+	delete iMessageDigest;
+	}
+
+CCmdHash::CCmdHash()
+	{
+	}
+
+CMessageDigest::THashId CCmdHash::HashIdL()
+	{
+	switch (iAlgorithm)
+		{
+		case ESha1:
+			return CMessageDigest::ESHA1;
+		case EMd2:
+			return CMessageDigest::EMD2;
+#ifdef FSHELL_MD4_SUPPORT
+		case EMd4:
+			return CMessageDigest::EMD4;
+#endif // FSHELL_MD4_SUPPORT
+		case EMd5:
+			return CMessageDigest::EMD5;
+#ifdef FSHELL_SHA2_SUPPORT
+		case ESha224:
+			return CMessageDigest::ESHA224;
+		case ESha256:
+			return CMessageDigest::ESHA256;
+		case ESha384:
+			return CMessageDigest::ESHA384;
+		case ESha512:
+			return CMessageDigest::ESHA512;
+#endif // FSHELL_SHA2_SUPPORT
+		default:
+			LeaveIfErr(KErrNotSupported, _L("Requested hashing algorithm is not available in this Symbian OS platform"));
+			return CMessageDigest::ESHA1;
+		}
+	}
+
+const TDesC& CCmdHash::Name() const
+	{
+	_LIT(KName, "hash");	
+	return KName;
+	}
+
+void CCmdHash::DoRunL()
+	{
+	iMessageDigest = CMessageDigestFactory::NewDigestL(HashIdL());
+
+	RIoReadHandle readHandle;
+	readHandle.Create(IoSession());
+	CleanupClosePushL(readHandle);
+
+	RIoFile ioFile;
+	if (iOptions.IsPresent(&iInputFileName))
+		{
+		LeaveIfErr(ioFile.Create(IoSession(), iInputFileName, RIoFile::ERead), _L("Couldn't open handle to file '%S'"), &iInputFileName);
+		CleanupClosePushL(ioFile);
+		LeaveIfErr(ioFile.Attach(readHandle, RIoEndPoint::EForeground), _L("Couldn't attach read handle to file object"));
+		}
+	else
+		{
+		LeaveIfErr(readHandle.Duplicate(Stdin()), _L("Couldn't duplicate STDIN"));
+		}
+
+	LeaveIfErr(readHandle.SetReadMode(RIoReadHandle::EOneOrMore), _L("Couldn't set read handle into read one or more mode"));
+
+	TBuf<KBlockSize> buf;
+	TInt err = KErrNone;
+	do
+		{
+		err = readHandle.Read(buf);
+		if (err == KErrNone)
+			{
+			iMessageDigest->Update(buf.Collapse());
+			}
+		}
+		while (err == KErrNone);
+
+	if (err != KErrEof)
+		{
+		LeaveIfErr(err, _L("Unable to read input"));
+		}
+
+	TPtrC8 hash(iMessageDigest->Final());
+
+	if (iOptions.IsPresent(&iOutputFileName))
+		{
+		RFile outputFile;
+		LeaveIfErr(outputFile.Create(FsL(), iOutputFileName, EFileWrite), _L("Couldn't create '%S'"), &iOutputFileName);
+		CleanupClosePushL(outputFile);
+		outputFile.Write(hash);
+		CleanupStack::PopAndDestroy(&outputFile);
+		}
+	else
+		{
+		LtkUtils::HexDumpToOutput(hash, Stdout());
+		}
+
+	if (iOptions.IsPresent(&iInputFileName))
+		{
+		CleanupStack::PopAndDestroy(&ioFile);
+		}
+
+	CleanupStack::PopAndDestroy(&readHandle);
+	}
+
+void CCmdHash::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	aOptions.AppendFileNameL(iInputFileName, _L("input"));
+	aOptions.AppendFileNameL(iOutputFileName, _L("output"));
+	aOptions.AppendEnumL((TInt&)iAlgorithm, _L("algorithm"));
+	}
+
+
+EXE_BOILER_PLATE(CCmdHash)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/hash/hash.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// hash.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_hash.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_HASH
+capability      FSHELL_CAP_MMP_MAX
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          hash.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+library         hash.lib
+library         ltkutils-tcb.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/heaptrace/heaptrace.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+# heaptrace.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name heaptrace
+
+==short-description
+
+Enables tracing for the given thread's heap.
+
+==long-description
+
+This command does not modify any btrace settings, only the flags in the given thread's RAllocator. Therefore to actually get the logs you'll need to do enable btrace and the EHeap category, eg 'btrace -m 1 -f 14'. When FSHELL_ATRACE_USES_BTRACE is not defined, this command uses the autometric eikplugin to switch to a tracing allocator, therefore in this config it is only possible to enable tracing for UI applications. When FSHELL_ATRACE_USES_BTRACE is defined, you can enable tracing for any thread including kernel threads (which trace the kernel heap). To perform the allocator switching regardless of config, use 'amcommand --logging-allocator' instead.
+
+==argument enum command
+
+The command to execute.
+
+==enum-value enable
+
+==enum-value disable
+
+==argument uint thread_id
+
+The TThreadId of the thread whose allocator you want to change.
+
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/heaptrace/heaptrace.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,85 @@
+// heaptrace.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/memoryaccesscmd.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdHeapTrace : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdHeapTrace();
+private:
+	CCmdHeapTrace();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	enum TCmd
+		{
+		EEnable,
+		EDisable,
+		//EDump
+		};
+	TCmd iCommand;
+	TUint iThreadId;
+	};
+
+EXE_BOILER_PLATE(CCmdHeapTrace)
+
+CCommandBase* CCmdHeapTrace::NewLC()
+	{
+	CCmdHeapTrace* self = new(ELeave) CCmdHeapTrace();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdHeapTrace::~CCmdHeapTrace()
+	{
+	}
+
+CCmdHeapTrace::CCmdHeapTrace()
+	{
+	}
+
+const TDesC& CCmdHeapTrace::Name() const
+	{
+	_LIT(KName, "heaptrace");
+	return KName;
+	}
+
+void CCmdHeapTrace::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCommand, _L("command"));
+	aArguments.AppendUintL(iThreadId, _L("thread_id"));
+	}
+
+void CCmdHeapTrace::DoRunL()
+	{
+	LoadMemoryAccessL();
+	TInt err;
+	switch (iCommand)
+		{
+		case EEnable:
+			err = iMemAccess.EnableHeapTracing(iThreadId, ETrue);
+			LeaveIfErr(err, _L("Couldn't enable tracing."));
+			break;
+		case EDisable:
+			err = iMemAccess.EnableHeapTracing(iThreadId, EFalse);
+			LeaveIfErr(err, _L("Couldn't disable tracing."));
+			break;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/heaptrace/heaptrace.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// heaptrace.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			heaptrace.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_HEAPTRACE
+
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			heaptrace.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/iap/iap.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+# iap.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name iap
+
+==short-description
+
+Retrieves IAP records from the Comms Database.
+
+==option bool w winsockprt
+
+Add a dummy IAP for use with WinSockPrt (an ESock protocol module that replaces Symbian's TCP/IP stack with a shim over Microsoft's WinSock API).
+
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/iap/iap.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,197 @@
+// iap.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <commsdattypesv1_1.h>
+#include <fshell/ioutils.h>
+
+using namespace CommsDat;
+using namespace IoUtils;
+
+class CCmdIap : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdIap();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	CCmdIap();
+	void ListIapsL();
+	void AddWinsockprtIapL();
+	void DoAddWinsockprtIapL(CMDBSession& aDbSession);
+private:
+	TBool iAddWinsockprtIap;
+	};
+
+	
+CCommandBase* CCmdIap::NewLC()
+	{
+	CCmdIap* self = new (ELeave) CCmdIap();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdIap::~CCmdIap()
+	{
+	}
+	
+CCmdIap::CCmdIap()
+	{
+	}
+
+const TDesC& CCmdIap::Name() const
+	{
+	_LIT(KName, "iap");
+	return KName;
+	}
+
+void CCmdIap::DoRunL()
+	{
+	if (iAddWinsockprtIap)
+		{
+		AddWinsockprtIapL();
+		}
+	else
+		{
+		ListIapsL();
+		}
+	}
+
+void CCmdIap::ListIapsL()
+	{
+	CMDBSession* session = CMDBSession::NewL(CMDBSession::LatestVersion());
+	CleanupStack::PushL(session);
+	CMDBRecordSet<CCDIAPRecord>* iapRecordSet = new (ELeave) CMDBRecordSet<CCDIAPRecord>(KCDTIdIAPRecord);
+	CleanupStack::PushL(iapRecordSet);
+	iapRecordSet->LoadL(*session);
+	const TInt maxCount = iapRecordSet->iRecords.Count();
+	if (maxCount == 0)
+		{
+		Printf(_L("No IAP records present.\r\n"));
+		}
+	else
+		{
+		IoUtils::CTextFormatter* formatter = CTextFormatter::NewLC(Stdout());
+		IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x100);
+		buf->AppendFormatL(_L("Name\tType\tIdentifier\r\n"));
+		for (TInt count = 0 ; count < maxCount ; count++)
+			{
+			// print to stdout details on this particular IAP record
+			CCDIAPRecord& rec = *((*iapRecordSet)[count]);
+			TPtrC ptr(static_cast<const TDesC&>(rec.iRecordName));
+			TPtrC iapServiceType(rec.iServiceType);
+			buf->AppendFormatL(_L("%S\t%S\t%d\r\n"), &ptr, &iapServiceType, rec.RecordId());
+			}
+		formatter->TabulateL(0, 2, buf->Descriptor());
+		Write(formatter->Descriptor());
+		CleanupStack::PopAndDestroy(2, formatter);
+		}
+	CleanupStack::PopAndDestroy(2); // iaprecordSet, session
+	}
+
+void CCmdIap::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptWinsockprt, "winsockprt");
+	aOptions.AppendBoolL(iAddWinsockprtIap, KOptWinsockprt);
+	}
+
+void CCmdIap::AddWinsockprtIapL()
+	{
+	CMDBSession* session = CMDBSession::NewL(CMDBSession::LatestVersion());
+	CleanupStack::PushL(session);
+	session->OpenTransactionL();
+
+	TRAPD(err, DoAddWinsockprtIapL(*session));
+
+	if (err == KErrNone)
+		{
+		session->CommitTransactionL();
+		}
+	else
+		{
+		PrintError(err, _L("Unable to add WinSockPrt IAP, rolling back..."));
+		session->RollbackTransactionL();
+		}
+
+	CleanupStack::PopAndDestroy(session);
+	}
+
+void CCmdIap::DoAddWinsockprtIapL(CMDBSession& aDbSession)
+	{
+	_LIT(KIapName, "WinSockPrt");
+	_LIT(KIspType, "DialOutISP");
+	_LIT(KNifName, "nullnif");
+	_LIT(KAgentName, "nullagt.agt");
+	_LIT(KBearerType, "ModemBearer");
+	_LIT(KDescription, "A dummy IAP for use with WinSockPrt.");
+	_LIT(KNetwork, "ip");
+
+	CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
+	CleanupStack::PushL(iapRecord);
+	iapRecord->iRecordName.SetL(KIapName);
+	if (iapRecord->FindL(aDbSession))
+		{
+		iapRecord->DeleteL(aDbSession);
+		}
+
+	CCDDialOutISPRecord* ispRecord = static_cast<CCDDialOutISPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdDialOutISPRecord));
+	CleanupStack::PushL(ispRecord);
+	ispRecord->iRecordName.SetL(KIapName);
+	if (ispRecord->FindL(aDbSession))
+		{
+		ispRecord->DeleteL(aDbSession);
+		}
+	ispRecord->SetRecordId(KCDNewRecordRequest);
+	ispRecord->iDescription.SetL(KDescription);
+	ispRecord->iUseLoginScript = EFalse;
+	ispRecord->iPromptForLogin = EFalse;
+	ispRecord->iIfNetworks.SetL(KNetwork);
+	ispRecord->StoreL(aDbSession);
+
+	CCDModemBearerRecord* bearerRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
+	CleanupStack::PushL(bearerRecord);
+	bearerRecord->iRecordName.SetL(KIapName);
+	if (bearerRecord->FindL(aDbSession))
+		{
+		bearerRecord->DeleteL(aDbSession);
+		}
+	bearerRecord->SetRecordId(KCDNewRecordRequest);
+	bearerRecord->iBearerAgent.SetL(KAgentName);
+	bearerRecord->iNifName.SetL(KNifName);
+	bearerRecord->StoreL(aDbSession);
+
+	CCDNetworkRecord* networkRecord = static_cast<CCDNetworkRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdNetworkRecord));
+	CleanupStack::PushL(networkRecord);
+	networkRecord->iRecordName.SetL(KIapName);
+	if (networkRecord->FindL(aDbSession))
+		{
+		networkRecord->DeleteL(aDbSession);
+		}
+	networkRecord->SetRecordId(KCDNewRecordRequest);
+	networkRecord->StoreL(aDbSession);
+
+	iapRecord->SetRecordId(KCDNewRecordRequest);
+	iapRecord->iRecordName.SetL(KIapName);
+	iapRecord->iServiceType.SetL(KIspType);
+	iapRecord->iService.SetL(ispRecord->RecordId());
+	iapRecord->iBearerType.SetL(KBearerType);
+	iapRecord->iBearer.SetL(bearerRecord->RecordId());
+	iapRecord->iNetwork.SetL(networkRecord->RecordId());
+	iapRecord->StoreL(aDbSession);
+
+	CleanupStack::PopAndDestroy(4, iapRecord);
+	}
+
+EXE_BOILER_PLATE(CCmdIap)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/iap/iap.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// iap.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			iap.exe
+targettype		exe
+uid                     FSHELL_UID2_FSHELL_EXE FSHELL_UID_IAP
+capability      	FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	\epoc32\include\fshell
+
+sourcepath		.
+source			iap.cpp
+
+library			euser.lib
+library			iocli.lib
+library			commsdat.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/icc/icc.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,82 @@
+# icc.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name icc
+
+==short-description
+
+Retrieve various pieces of information from the handset's ICC (SIM card).
+
+==long-description
+
+Also supports basic editing of phone book entries.
+
+==argument enum operation optional
+
+The operation to perform. Defaults to 'access-caps'.
+
+==enum-value access-caps
+
+List the access capabilities of the ICC.
+
+==enum-value service-table
+
+Dump a service table. Use C<--service-table> to specify the required service table.
+
+==enum-value fdn-status
+
+Display the Fixed Dial Number status.
+
+==enum-value phone-book-info
+
+Print information about a phone book store. Use C<--store-name> to specify the required store.
+
+==enum-value dump-phone-book
+
+Dump the contents of a phone book in hex / ASCII.
+
+==enum-value edit-phone-book
+
+Change the contents of a phone book. Use C<--data> to specify the new contents. Note, binary information must be specified which necessitates the use of escape sequences (see fshell's documentation for more details).
+
+==option bool v verbose
+
+Display verbose output.
+
+==option string t tsy-name
+
+The name of the ETel server plug-in to use. If not specified the handset's default TSY is read from COMMSDAT.
+
+==option uint S service-table
+
+Must be used in conjuction with the 'service-table' operation. The identifier of the service table to display as defined by C<RMobilePhone::TMobilePhoneServiceTable> in F<\epoc32\include\etelmm.h>.
+
+==option string s store-name
+
+The name of the phone store to display information about. These are defined in F<\epoc32\include\etelmm.h> and have names like 'S1', 'S2', etc.
+
+==option string m mode
+
+The mode of the store. These are defined in F<\epoc32\include\etelmm.h> and have names like 'T1' (for CDMA), 'T2' (for GSM) and 'T3' (for USIM).
+
+==option int l slot
+
+Must be used in conjuction with the 'edit-phone-book' operation. Specifies which phone book entry is to be edited. A value of -1 will cause the first free slot to be written to.
+
+==option string d data
+
+Must be used in conjunction with 'edit-phone-book'. Specifies the data to be written to a phone book slot.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/icc/icc.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,757 @@
+// icc.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <etelmm.h>
+#include <commsdattypesv1_1.h>
+#include <fshell/ltkutils.h>
+#include <cdblen.h>
+
+
+#define SERVICE_ENTRY(XXX) { XXX, #XXX }
+
+struct SEnumFlag
+	{
+	TInt iValue;
+	const char* iIndentifer;
+	};
+
+SEnumFlag KSstServices1to8[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KSstPin1Disable),
+	SERVICE_ENTRY(RMobilePhone::KSstADN),
+	SERVICE_ENTRY(RMobilePhone::KSstFDN),
+	SERVICE_ENTRY(RMobilePhone::KSstSMS),
+	SERVICE_ENTRY(RMobilePhone::KSstAoC),
+	SERVICE_ENTRY(RMobilePhone::KSstCCP),
+	SERVICE_ENTRY(RMobilePhone::KSstPLMNSelector)
+	};
+
+SEnumFlag KSstServices9to16[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KSstMSISDN),
+	SERVICE_ENTRY(RMobilePhone::KSstExt1),
+	SERVICE_ENTRY(RMobilePhone::KSstExt2),
+	SERVICE_ENTRY(RMobilePhone::KSstSMSP),
+	SERVICE_ENTRY(RMobilePhone::KSstLND),
+	SERVICE_ENTRY(RMobilePhone::KSstCBMI),
+	SERVICE_ENTRY(RMobilePhone::KSstGID1),
+	SERVICE_ENTRY(RMobilePhone::KSstGID2)
+	};
+
+SEnumFlag KSstServices17to24[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KSstSPName),
+	SERVICE_ENTRY(RMobilePhone::KSstSDN),
+	SERVICE_ENTRY(RMobilePhone::KSstExt3),
+	SERVICE_ENTRY(RMobilePhone::KSstVGCSList),
+	SERVICE_ENTRY(RMobilePhone::KSstVBSList),
+	SERVICE_ENTRY(RMobilePhone::KSsteMLPP),
+	SERVICE_ENTRY(RMobilePhone::KSstAnswereMLPP)
+	};
+
+SEnumFlag KSstServices25to32[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KSstSmsCbDataDownload),
+	SERVICE_ENTRY(RMobilePhone::KSstSmsPpDataDownload),
+	SERVICE_ENTRY(RMobilePhone::KSstMenuSelection),
+	SERVICE_ENTRY(RMobilePhone::KSstCallControl),
+	SERVICE_ENTRY(RMobilePhone::KSstProactiveSim),
+	SERVICE_ENTRY(RMobilePhone::KSstCBMIRanges),
+	SERVICE_ENTRY(RMobilePhone::KSstBDN),
+	SERVICE_ENTRY(RMobilePhone::KSstExt4)
+	};
+
+SEnumFlag KSstServices33to40[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KSstDepersonalisationKeys),
+	SERVICE_ENTRY(RMobilePhone::KSstCooperativeNetworks),
+	SERVICE_ENTRY(RMobilePhone::KSstSMStatusReports),
+	SERVICE_ENTRY(RMobilePhone::KSstNetworkIndAlerting),
+	SERVICE_ENTRY(RMobilePhone::KSstMoSmControlBySim),
+	SERVICE_ENTRY(RMobilePhone::KSstGprs),
+	SERVICE_ENTRY(RMobilePhone::KSstImage),
+	SERVICE_ENTRY(RMobilePhone::KSstSoLSA)
+	};
+
+SEnumFlag KSstServices41to48[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KSstUssdStringInCallControl),
+	SERVICE_ENTRY(RMobilePhone::KSstRunATCommand),
+	SERVICE_ENTRY(RMobilePhone::KSstPlmnSelectorListWithAccessTechnology),
+	SERVICE_ENTRY(RMobilePhone::KSstOplmnSelectorListWithAccessTechnology),
+	SERVICE_ENTRY(RMobilePhone::KSstHplmnAccessTechnology),
+	SERVICE_ENTRY(RMobilePhone::KSstCpbcchInformation),
+	SERVICE_ENTRY(RMobilePhone::KSstInvestigationScan),
+	SERVICE_ENTRY(RMobilePhone::KSstExtendedCcp)
+	};
+
+SEnumFlag KSstServices49to56[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KSstMExE),
+	SERVICE_ENTRY(RMobilePhone::KSstRplmnLastUsedAccessTechnology)
+	};
+
+SEnumFlag KUstServices1to8[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KUstLocalPhBk),
+	SERVICE_ENTRY(RMobilePhone::KUstFDN),
+	SERVICE_ENTRY(RMobilePhone::KUstExt2),
+	SERVICE_ENTRY(RMobilePhone::KUstSDN),
+	SERVICE_ENTRY(RMobilePhone::KUstExt3),
+	SERVICE_ENTRY(RMobilePhone::KUstBDN),
+	SERVICE_ENTRY(RMobilePhone::KUstExt4),
+	SERVICE_ENTRY(RMobilePhone::KUstOugoingCallInfo)
+	};
+
+SEnumFlag KUstServices9to16[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KUstIncomingCallInfo),
+	SERVICE_ENTRY(RMobilePhone::KUstSMS),
+	SERVICE_ENTRY(RMobilePhone::KUstSMSR),
+	SERVICE_ENTRY(RMobilePhone::KUstSMSP),
+	SERVICE_ENTRY(RMobilePhone::KUstAoC),
+	SERVICE_ENTRY(RMobilePhone::KUstCCP),
+	SERVICE_ENTRY(RMobilePhone::KUstCBMI),
+	SERVICE_ENTRY(RMobilePhone::KUstCBMIRanges)
+	};
+
+SEnumFlag KUstServices17to24[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KUstGID1),
+	SERVICE_ENTRY(RMobilePhone::KUstGID2),
+	SERVICE_ENTRY(RMobilePhone::KUstSPN),
+	SERVICE_ENTRY(RMobilePhone::KUstPLMNSelAccessTech),
+	SERVICE_ENTRY(RMobilePhone::KUstMSISDN),
+	SERVICE_ENTRY(RMobilePhone::KUstIMG),
+	SERVICE_ENTRY(RMobilePhone::KUsteMLPP)
+	};
+
+SEnumFlag KUstServices25to32[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KUstAnswereMLPP),
+	SERVICE_ENTRY(RMobilePhone::KUstGSMAccess),
+	SERVICE_ENTRY(RMobilePhone::KUstSMSPpDataDownload),
+	SERVICE_ENTRY(RMobilePhone::KUstSMSCbDataDownload),
+	SERVICE_ENTRY(RMobilePhone::KUstCallControl),
+	SERVICE_ENTRY(RMobilePhone::KUstMoSmControl),
+	SERVICE_ENTRY(RMobilePhone::KUstPCmdRunAtCommand)
+	};
+
+SEnumFlag KUstServices33to40[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KUstAlways),
+	SERVICE_ENTRY(RMobilePhone::KUstEST),
+	SERVICE_ENTRY(RMobilePhone::KUstACL),
+	SERVICE_ENTRY(RMobilePhone::KIstDepersonalisationKeys),
+	SERVICE_ENTRY(RMobilePhone::KUstCooperativeNetwork),
+	SERVICE_ENTRY(RMobilePhone::KUstGSMSecurityContext),
+	SERVICE_ENTRY(RMobilePhone::KUstCPBCCHInfo),
+	SERVICE_ENTRY(RMobilePhone::KUstInvestigationScan)
+	};
+
+SEnumFlag KUstServices41to48[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KUstMExE),
+	SERVICE_ENTRY(RMobilePhone::KUstOperatorPLMNSelector),
+	SERVICE_ENTRY(RMobilePhone::KUstHPLMNSelAccessTech),
+	SERVICE_ENTRY(RMobilePhone::KUstExt5),
+	SERVICE_ENTRY(RMobilePhone::KUstPLMNNetworkName),
+	SERVICE_ENTRY(RMobilePhone::KUstOperatorPLMNList),
+	SERVICE_ENTRY(RMobilePhone::KUstMDN),
+	SERVICE_ENTRY(RMobilePhone::KUstMWISo)
+	};
+
+SEnumFlag KUstServices49to56[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KUstCFIS),
+	SERVICE_ENTRY(RMobilePhone::KUstRPLMN),
+	SERVICE_ENTRY(RMobilePhone::KUstSPDI),
+	SERVICE_ENTRY(RMobilePhone::KUstMMS),
+	SERVICE_ENTRY(RMobilePhone::KUstExt8),
+	SERVICE_ENTRY(RMobilePhone::KUstCConGPRS),
+	SERVICE_ENTRY(RMobilePhone::KUstMMSUCP)
+	};
+
+#if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
+SEnumFlag KUstServices57to64[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KUstVGCSGroupIdList),
+	SERVICE_ENTRY(RMobilePhone::KUstVBSGroupIdList),
+	SERVICE_ENTRY(RMobilePhone::KUstPseudonym),
+	SERVICE_ENTRY(RMobilePhone::KUstUserPLMNSelectorWLAN),
+	SERVICE_ENTRY(RMobilePhone::KUstOperatorPLMNSelectorWLAN),
+	SERVICE_ENTRY(RMobilePhone::KUstUserWSIDList),
+	SERVICE_ENTRY(RMobilePhone::KUstOperatorWSIDList),
+	SERVICE_ENTRY(RMobilePhone::KUstVGCSSecurity)
+	};
+#endif
+
+SEnumFlag KEstServices1to8[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KEstFDN),
+	SERVICE_ENTRY(RMobilePhone::KEstBDN),
+	SERVICE_ENTRY(RMobilePhone::KEstACL)
+	};
+
+#if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
+SEnumFlag KIstServices1to8[] =
+	{
+	SERVICE_ENTRY(RMobilePhone::KIstPCSCF),
+	SERVICE_ENTRY(RMobilePhone::KIstGBA),
+	SERVICE_ENTRY(RMobilePhone::KIstHTTPDigest)
+	};
+#endif
+
+
+using namespace IoUtils;
+
+class CCmdIcc : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdIcc();
+private:
+	CCmdIcc();
+	void OpenPhoneL();
+	void GetPhoneBookInfoL();
+	void ApiSupported(TInt aApi, TBool& aIsSupported);
+	void DisplayAccessCapsL();
+	void DisplayServiceTablesL();
+	void DisplayFdnStatusL();
+	void DisplayPhoneBookInfoL();
+	void DumpPhoneBookL();
+	void EditPhoneBookL();
+	void PrintServices(const TDesC& iTableName, TUint aServices, SEnumFlag aServiceTableDefinitions[], TInt aNumServiceTableDefinitions);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TOperation
+		{
+		EAccessCaps,
+		EServiceTables,
+		EFdnStatus,
+		EPhoneBookInfo,
+		EDumpPhoneBook,
+		EEditPhoneBook
+		};
+private:
+	RTelServer iEtelServer;
+	RMobilePhone iPhone;
+	RMobilePhoneBookStore iPhoneBookStore;
+	TBool iVerbose;
+	HBufC* iTsyName;
+	TUint iServiceTable;
+	HBufC* iStoreName;
+	HBufC* iMode;
+	TInt iSlot;
+	HBufC* iData;
+	TOperation iOperation;
+	TBool iV5Tsy;
+	TBool iV2Tsy;
+	TBool iUsimTsy;
+	RMobilePhoneBookStore::TMobilePhoneBookInfoV5 iStoreInfo;
+	};
+
+
+CCommandBase* CCmdIcc::NewLC()
+	{
+	CCmdIcc* self = new(ELeave) CCmdIcc();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdIcc::~CCmdIcc()
+	{
+	iPhoneBookStore.Close();
+	iPhone.Close();
+	iEtelServer.Close();
+	delete iTsyName;
+	delete iStoreName;
+	delete iMode;
+	delete iData;
+	}
+
+CCmdIcc::CCmdIcc()
+	{
+	}
+
+const TDesC& CCmdIcc::Name() const
+	{
+	_LIT(KName, "icc");	
+	return KName;
+	}
+
+void CCmdIcc::DoRunL()
+	{
+	OpenPhoneL();
+
+	switch (iOperation)
+		{
+		case EAccessCaps:
+			DisplayAccessCapsL();
+			break;
+		case EServiceTables:
+			DisplayServiceTablesL();
+			break;
+		case EFdnStatus:
+			DisplayFdnStatusL();
+			break;
+		case EPhoneBookInfo:
+			DisplayPhoneBookInfoL();
+			break;
+		case EDumpPhoneBook:
+			DumpPhoneBookL();
+			break;
+		case EEditPhoneBook:
+			EditPhoneBookL();
+			break;
+		default:
+			User::Leave(KErrArgument);
+		}
+	}
+
+void CCmdIcc::DisplayAccessCapsL()
+	{
+	TUint32 iccCaps;
+	LeaveIfErr(iPhone.GetIccAccessCaps(iccCaps), _L("Couldn't get ICC access capabilities"));
+
+	TBool first(ETrue);
+	if (iccCaps & RMobilePhone::KCapsSimAccessSupported)
+		{
+		if (first)
+			{
+			first = EFalse;
+			}
+		else
+			{
+			Write(_L(" | "));
+			}
+		Write(_L("KCapsSimAccessSupported"));
+		}
+	if (iccCaps & RMobilePhone::KCapsRUimAccessSupported)
+		{
+		if (first)
+			{
+			first = EFalse;
+			}
+		else
+			{
+			Write(_L(" | "));
+			}
+		Write(_L("KCapsRUimAccessSupported"));
+		}
+	if (iccCaps & RMobilePhone::KCapsUSimAccessSupported)
+		{
+		if (first)
+			{
+			first = EFalse;
+			}
+		else
+			{
+			Write(_L(" | "));
+			}
+		Write(_L("KCapsUSimAccessSupported"));
+		}
+	if (!first)
+		{
+		Write(_L("\r\n"));
+		}
+	}
+	
+void CCmdIcc::PrintServices(const TDesC& iTableName, TUint aServices, SEnumFlag aServiceTableDefinitions[], TInt aNumServiceTableDefinitions)
+	{
+	Printf(_L("%S "), &iTableName);
+	TBool first(ETrue);
+	for (TInt i = 0; i < aNumServiceTableDefinitions; ++i)
+		{
+		if (aServices & aServiceTableDefinitions[i].iValue)
+			{
+			if (first)
+				{
+				first = EFalse;
+				}
+			else
+				{
+				Printf(_L(" | "));
+				}
+			TPtrC8 identifier((const TUint8*)aServiceTableDefinitions[i].iIndentifer);
+			identifier.Set(identifier.Mid(identifier.Find(_L8("::")) + 2));
+			Printf(identifier);
+			}
+		}
+	Write(_L("\r\n"));
+	}
+
+void CCmdIcc::DisplayServiceTablesL()
+	{
+	RMobilePhone::TMobilePhoneServiceTableV2 serviceTable;
+	TRequestStatus status;
+
+	if (iV2Tsy)
+		{
+		RMobilePhone::TMobilePhoneServiceTableV2Pckg serviceTablePckg(serviceTable);
+		iPhone.GetServiceTable(status, (RMobilePhone::TMobilePhoneServiceTable)iServiceTable, serviceTablePckg);
+		}
+	else
+		{
+		RMobilePhone::TMobilePhoneServiceTableV1Pckg serviceTablePckg(serviceTable);
+		iPhone.GetServiceTable(status, (RMobilePhone::TMobilePhoneServiceTable)iServiceTable, serviceTablePckg);
+		}
+	
+	User::WaitForRequest(status);
+	LeaveIfErr(status.Int(), _L("Unable to get service table %d"), iServiceTable);
+
+	switch (iServiceTable)
+		{
+		case RMobilePhone::ESIMServiceTable:
+			PrintServices(_L("1 to 8:  "), serviceTable.iServices1To8, KSstServices1to8, sizeof(KSstServices1to8) / sizeof(SEnumFlag));
+			PrintServices(_L("9 to 16: "), serviceTable.iServices9To16, KSstServices9to16, sizeof(KSstServices9to16) / sizeof(SEnumFlag));
+			PrintServices(_L("17 to 24:"), serviceTable.iServices17To24, KSstServices17to24, sizeof(KSstServices17to24) / sizeof(SEnumFlag));
+			PrintServices(_L("25 to 32:"), serviceTable.iServices25To32, KSstServices25to32, sizeof(KSstServices25to32) / sizeof(SEnumFlag));
+			PrintServices(_L("33 to 40:"), serviceTable.iServices33To40, KSstServices33to40, sizeof(KSstServices33to40) / sizeof(SEnumFlag));
+			PrintServices(_L("41 to 48:"), serviceTable.iServices41To48, KSstServices41to48, sizeof(KSstServices41to48) / sizeof(SEnumFlag));
+			PrintServices(_L("49 to 56:"), serviceTable.iServices49To56, KSstServices49to56, sizeof(KSstServices49to56) / sizeof(SEnumFlag));
+			break;
+		case RMobilePhone::EUSIMServiceTable:
+			PrintServices(_L("1 to 8:  "), serviceTable.iServices1To8, KUstServices1to8, sizeof(KUstServices1to8) / sizeof(SEnumFlag));
+			PrintServices(_L("9 to 16: "), serviceTable.iServices9To16, KUstServices9to16, sizeof(KUstServices9to16) / sizeof(SEnumFlag));
+			PrintServices(_L("17 to 24:"), serviceTable.iServices17To24, KUstServices17to24, sizeof(KUstServices17to24) / sizeof(SEnumFlag));
+			PrintServices(_L("25 to 32:"), serviceTable.iServices25To32, KUstServices25to32, sizeof(KUstServices25to32) / sizeof(SEnumFlag));
+			PrintServices(_L("33 to 40:"), serviceTable.iServices33To40, KUstServices33to40, sizeof(KUstServices33to40) / sizeof(SEnumFlag));
+			PrintServices(_L("41 to 48:"), serviceTable.iServices41To48, KUstServices41to48, sizeof(KUstServices41to48) / sizeof(SEnumFlag));
+			PrintServices(_L("49 to 56:"), serviceTable.iServices49To56, KUstServices49to56, sizeof(KUstServices49to56) / sizeof(SEnumFlag));
+			break;
+		case RMobilePhone::ECDMAServiceTable:
+			break;
+		case RMobilePhone::EUSIMEnabledServiceTable:
+			PrintServices(_L("1 to 8:  "), serviceTable.iServices1To8, KEstServices1to8, sizeof(KEstServices1to8) / sizeof(SEnumFlag));
+			break;
+#if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
+		case RMobilePhone::EISIMServiceTable:
+			PrintServices(_L("1 to 8:  "), serviceTable.iServices1To8, KIstServices1to8, sizeof(KIstServices1to8) / sizeof(SEnumFlag));
+			break;
+#endif
+		}
+
+	if (iV2Tsy)
+		{
+		Write(_L("AID:\r\n"));
+		LtkUtils::HexDumpToOutput(serviceTable.iAID, Stdout());
+		}
+	}
+
+void CCmdIcc::DisplayFdnStatusL()
+	{
+	RMobilePhone::TMobilePhoneFdnStatus fdnStatus;
+	LeaveIfErr(iPhone.GetFdnStatus(fdnStatus), _L("Unable to get FDN status"));
+	switch (fdnStatus)
+		{
+		case RMobilePhone::EFdnNotActive:
+			Write(_L("EFdnNotActive\r\n"));
+			break;
+		case RMobilePhone::EFdnActive:
+			Write(_L("EFdnActive\r\n"));
+			break;
+		case RMobilePhone::EFdnPermanentlyActive:
+			Write(_L("EFdnPermanentlyActive\r\n"));
+			break;
+		case RMobilePhone::EFdnNotSupported:
+			Write(_L("EFdnNotSupported\r\n"));
+			break;
+		case RMobilePhone::EFdnUnknown:
+		default:
+			Write(_L("EFdnUnknown\r\n"));
+			break;
+		}
+	}
+
+void CCmdIcc::DisplayPhoneBookInfoL()
+	{
+	if (iStoreName == NULL)
+		{
+		LeaveIfErr(KErrArgument, _L("The name of the phone store must be specified using -s"));
+		}
+
+	if (iVerbose)
+		{
+		Printf(_L("Getting phone store info for phone book \"%S\"...\r\n"), iStoreName);
+		}
+
+	GetPhoneBookInfoL();
+
+	Printf(_L("Total number of entries:                 %d\r\n"), iStoreInfo.iTotalEntries);
+	Printf(_L("Used number of entries:                  %d\r\n"), iStoreInfo.iUsedEntries);
+	Printf(_L("Capabilities:                            0x%08x\r\n"), iStoreInfo.iCaps);
+	Printf(_L("Phone name:                              %S\r\n"), &iStoreInfo.iName);
+	Printf(_L("Maximum number length:                   %d\r\n"), iStoreInfo.iMaxNumLength);
+	Printf(_L("Maximum text length:                     %d\r\n"), iStoreInfo.iMaxTextLength);
+	Write( _L("Store location:                          "));
+	switch (iStoreInfo.iLocation)
+		{
+		default:
+		case RMobilePhoneBookStore::ELocationUnknown:
+			Write(_L("ELocationUnknown"));
+			break;
+		case RMobilePhoneBookStore::ELocationIccMemory:
+			Write(_L("ELocationIccMemory"));
+			break;
+		case RMobilePhoneBookStore::ELocationPhoneMemory:
+			Write(_L("ELocationPhoneMemory"));
+			break;
+		case RMobilePhoneBookStore::ELocationExternalMemory:
+			Write(_L("ELocationExternalMemory"));
+			break;
+		case RMobilePhoneBookStore::ELocationCombinedMemory:
+			Write(_L("ELocationCombinedMemory"));
+			break;
+		}
+	Write(_L("\r\n"));
+	Printf(_L("Change counter:                          %d\r\n"), iStoreInfo.iChangeCounter);
+	Printf(_L8("Phone book identity:                     %S\r\n"), &iStoreInfo.iIdentity);
+
+	if (iV2Tsy)
+		{
+		Printf(_L("Mode:                                    %S\r\n"), &iStoreInfo.iPhBkMode);
+		}
+
+	if (iV5Tsy)
+		{
+		Printf(_L("Maximum second names:                    %d\r\n"), iStoreInfo.iMaxSecondNames);
+		Printf(_L("Maximum text length second names:        %d\r\n"), iStoreInfo.iMaxTextLengthSecondName);
+		Printf(_L("Maximum additional numbers:              %d\r\n"), iStoreInfo.iMaxAdditionalNumbers);
+		Printf(_L("Maximum number length additional number: %d\r\n"), iStoreInfo.iMaxNumLengthAdditionalNumber);
+		Printf(_L("Maximum text length additional number:   %d\r\n"), iStoreInfo.iMaxTextLengthAdditionalNumber);
+		Printf(_L("Maximum group names:                     %d\r\n"), iStoreInfo.iMaxGroupNames);
+		Printf(_L("Maximum text length group name:          %d\r\n"), iStoreInfo.iMaxTextLengthGroupName);
+		Printf(_L("Maximum email address:                   %d\r\n"), iStoreInfo.iMaxEmailAddr);
+		Printf(_L("Maximum text length email address:       %d\r\n"), iStoreInfo.iMaxTextLengthEmailAddr);
+		}
+	}
+
+void CCmdIcc::DumpPhoneBookL()
+	{
+	if (iStoreName == NULL)
+		{
+		LeaveIfErr(KErrArgument, _L("The name of the phone store must be specified using -s"));
+		}
+
+	if (iVerbose)
+		{
+		Printf(_L("Dumping phone book store \"%S\"...\r\n"), iStoreName);
+		}
+
+	GetPhoneBookInfoL();
+
+	if (iVerbose)
+		{
+		Printf(_L("Phone book store has %d slots\r\n"), iStoreInfo.iTotalEntries);
+		}
+
+	for (TInt slotIndex = 0; slotIndex < iStoreInfo.iTotalEntries; ++slotIndex)
+		{
+		if (iVerbose)
+			{
+			Printf(_L("Reading slot %d...\r\n"), slotIndex);
+			}
+
+		TBuf8<1024> buf;
+		TRequestStatus status;
+		iPhoneBookStore.Read(status, slotIndex, 1, buf);
+		User::WaitForRequest(status);
+		if (status.Int() != KErrNone)
+			{
+			Printf(_L8("%d: %d\r\n"), slotIndex, status.Int());
+			}
+		else
+			{
+			Printf(_L8("%d:\r\n"), slotIndex);
+			LtkUtils::HexDumpToOutput(buf, Stdout());
+			Write(_L("\r\n"));
+			}
+		}
+	}
+
+void CCmdIcc::EditPhoneBookL()
+	{
+	if (iStoreName == NULL)
+		{
+		LeaveIfErr(KErrArgument, _L("The name of the phone store must be specified using -s"));
+		}
+
+	if (iData == NULL)
+		{
+		LeaveIfErr(KErrArgument, _L("The data to be entered must be specified using -d"));
+		}
+
+	if (!iOptions.IsPresent(&iSlot))
+		{
+		LeaveIfErr(KErrArgument, _L("The slot to be edited must be specified using -l"));
+		}
+
+	GetPhoneBookInfoL();
+	TRequestStatus status;
+	TPtrC8 data((const TUint8*)iData->Ptr(), iData->Size());
+
+	if (iVerbose)
+		{
+		Printf(_L("Writing the following to slot %d:\r\n"), iSlot);
+		LtkUtils::HexDumpToOutput(data, Stdout());
+		}
+
+	iPhoneBookStore.Write(status, data, iSlot);
+	User::WaitForRequest(status);
+	LeaveIfErr(status.Int(), _L("Unable to write to phone book store \"%S\""), iStoreName);
+	Printf(_L("Slot %d edited\r\n"), iSlot);
+	}
+
+void CCmdIcc::ApiSupported(TInt aApi, TBool& aIsSupported)
+	{
+	TInt err = iEtelServer.IsSupportedByModule(*iTsyName, aApi, aIsSupported);
+	if (err != KErrNone)
+		{
+		aIsSupported = EFalse;
+		}
+	}
+
+void CCmdIcc::GetPhoneBookInfoL()
+	{
+	if (iMode)
+		{
+		LeaveIfErr(iPhoneBookStore.Open(iPhone, *iStoreName, *iMode), _L("Unable to open phone book store \"%S\" in mode \"%S\""), iStoreName, iMode);
+		}
+	else
+		{
+		LeaveIfErr(iPhoneBookStore.Open(iPhone, *iStoreName), _L("Unable to open phone book store \"%S\""), iStoreName);
+		}
+
+	TRequestStatus status;
+	if (iV5Tsy)
+		{
+		TPckg<RMobilePhoneBookStore::TMobilePhoneBookInfoV5> pckg(iStoreInfo);
+		iPhoneBookStore.GetInfo(status, pckg);
+		}
+	else if (iV2Tsy)
+		{
+		TPckg<RMobilePhoneBookStore::TMobilePhoneBookInfoV2> pckg(iStoreInfo);
+		iPhoneBookStore.GetInfo(status, pckg);
+		}
+	else
+		{
+		TPckg<RMobilePhoneBookStore::TMobilePhoneBookInfoV1> pckg(iStoreInfo);
+		iPhoneBookStore.GetInfo(status, pckg);
+		}
+	User::WaitForRequest(status);
+	LeaveIfErr(status.Int(), _L("Couldn't get phone book store info"));
+	}
+
+void CCmdIcc::OpenPhoneL()
+	{
+	if (iTsyName == NULL)
+		{
+		CommsDat::CMDBSession* db = CommsDat::CMDBSession::NewLC(KCDLatestVersion);
+		CommsDat::CMDBField<TUint32>* globalSettingField = new(ELeave) CommsDat::CMDBField<TUint32>(CommsDat::KCDTIdModemPhoneServicesSMS);
+		CleanupStack::PushL(globalSettingField);
+		globalSettingField->SetRecordId(1);
+		globalSettingField->LoadL(*db);
+		TUint32 modemId = *globalSettingField;
+		CommsDat::CMDBField<TDesC>* tsyField = new(ELeave) CommsDat::CMDBField<TDesC>(CommsDat::KCDTIdTsyName);
+		CleanupStack::PushL(tsyField);
+		tsyField->SetRecordId(modemId);
+		TRAPL(tsyField->LoadL(*db), _L("Unable to read default TSY name"));
+		TBuf<KCommsDbSvrMaxFieldLength> tsyName;
+		tsyName = *tsyField;
+		iTsyName = tsyName.AllocL();
+		CleanupStack::PopAndDestroy(3, db); // db, tsyField & globalSettingField
+		}
+	
+	LeaveIfErr(iEtelServer.Connect(), _L("Unable to connect to the ETel server"));
+	LeaveIfErr(iEtelServer.LoadPhoneModule(*iTsyName), _L("Unable to load TSY module \"%S\""), iTsyName);
+	TInt numPhones = 0;
+	LeaveIfErr(iEtelServer.EnumeratePhones(numPhones), _L("Couldn't enumerate phones"));
+	TBool matchFound(EFalse);
+	TInt phoneIndex;
+	for (phoneIndex = 0; phoneIndex < numPhones; ++phoneIndex)
+		{
+		TName thisTsyName;
+		if ((iEtelServer.GetTsyName(phoneIndex, thisTsyName) == KErrNone) && (iTsyName->CompareF(thisTsyName) == KErrNone))
+			{
+			matchFound = ETrue;
+			break;
+			}
+		}
+	if (!matchFound)
+		{
+		LeaveIfErr(KErrNotFound, _L("Couldn't find phone using TSY \"%S\""), iTsyName);
+		}
+	RTelServer::TPhoneInfo phoneInfo;
+	LeaveIfErr(iEtelServer.GetPhoneInfo(phoneIndex, phoneInfo), _L("Couldn't get phone info"));
+	LeaveIfErr(iPhone.Open(iEtelServer, phoneInfo.iName), _L("Couldn't open phone"));
+
+	ApiSupported(KEtelExtMultimodeV5, iV5Tsy);
+	ApiSupported(KETelExtMultimodeV2, iV2Tsy);
+	ApiSupported(KEtelFuncMobileUSIMApplications, iUsimTsy);
+
+	if (iVerbose)
+		{
+		if (iUsimTsy)
+			{
+			Write(_L("TSY supports USIM API\r\n"));
+			}
+		if (iV2Tsy)
+			{
+			Write(_L("TSY supports V2 API\r\n"));
+			}
+		if (iV5Tsy)
+			{
+			Write(_L("TSY supports V5 API\r\n"));
+			}
+		}
+	}
+
+void CCmdIcc::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KOperationName, "operation");
+	aArguments.AppendEnumL((TInt&)iOperation, KOperationName);
+	}
+
+void CCmdIcc::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptTsyName, "tsy-name");
+	aOptions.AppendStringL(iTsyName, KOptTsyName);
+
+	_LIT(KArgServiceTable, "service-table");
+	aOptions.AppendUintL(iServiceTable, KArgServiceTable);
+
+	_LIT(KArgStoreName, "store-name");
+	aOptions.AppendStringL(iStoreName, KArgStoreName);
+
+	_LIT(KArgMode, "mode");
+	aOptions.AppendStringL(iMode, KArgMode);
+
+	_LIT(KArgSlot, "slot");
+	aOptions.AppendIntL(iSlot, KArgSlot);
+
+	_LIT(KArgData, "data");
+	aOptions.AppendStringL(iData, KArgData);
+	}
+
+
+EXE_BOILER_PLATE(CCmdIcc)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/icc/icc.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// icc.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_icc.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_ICC
+capability	FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          icc.cpp
+
+library         euser.lib
+library         iocli.lib
+library         etel.lib
+library         etelmm.lib
+library         commsdat.lib
+library         ltkutils.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/iniedit/iniedit.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# iniedit.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name iniedit
+
+==short-description
+
+Manipulate (fshell format) INI configuration files.
+
+==argument filename inifile
+
+The INI file to use.
+
+==option filename i idf
+
+Specify an INI description file (IDF) to use. Has no effect if --force is specified.
+
+==option bool d dump
+
+Dump the file contents to stdout.
+
+==option bool f force
+
+Continue even if the file structure is invalid.
+
+==option string g get
+
+Write a single value from the file to stdout.
+
+==option string s set
+
+Update or add a value to the file. Specify the value in the format 'id[=value]'. If no '=' is specified, the value will be read from STDIN.
+
+==option string r remove
+
+Remove a value from the file.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/iniedit/iniedit.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,202 @@
+// iniedit.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <settings.h>
+
+using namespace IoUtils;
+using namespace LtkUtils;
+
+
+class CCmdIniEdit : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdIniEdit();
+private:
+	CCmdIniEdit();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TFileName2 iIniFile;
+	TFileName2 iDescriptionFile;
+	TBool iDump;
+	TBool iForce;
+	HBufC* iSet;
+	HBufC* iGet;
+	HBufC* iRemove;
+	
+	RBuf iBuf;
+	CIniReader* iReader;
+	};
+
+
+CCommandBase* CCmdIniEdit::NewLC()
+	{
+	CCmdIniEdit* self = new(ELeave) CCmdIniEdit();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdIniEdit::~CCmdIniEdit()
+	{
+	delete iSet;
+	delete iGet;
+	delete iRemove;
+	delete iReader;
+	iBuf.Close();
+	}
+
+CCmdIniEdit::CCmdIniEdit()
+	{
+	}
+
+const TDesC& CCmdIniEdit::Name() const
+	{
+	_LIT(KName, "iniedit");	
+	return KName;
+	}
+	
+_LIT(KEquals, "=");
+
+TPtrC Trim(const TDesC& aDes)
+	{
+	TPtrC des(aDes);
+	while (des.Length() && TChar(des[0]).IsSpace())
+		{
+		des.Set(des.Mid(1));
+		}
+	while (des.Length() && TChar(des[des.Length()-1]).IsSpace())
+		{
+		des.Set(des.Left(des.Length()-1));
+		}
+	return des;
+	}
+
+void CCmdIniEdit::DoRunL()
+	{
+	TBool interactive = ETrue;
+	if (iForce)
+		{
+		iReader = CIniReader::NewL(iIniFile);
+		}
+	else
+		{
+		iReader = CIniFile::NewL(iIniFile, iDescriptionFile);
+		}
+	TBool updated = EFalse;
+		
+	if (iSet)
+		{
+		TInt eqPos = iSet->Find(KEquals);
+		TPtrC value(KNullDesC);
+		TPtrC id(KNullDesC);
+		if (eqPos == KErrNotFound)
+			{
+			id.Set(*iSet);
+			
+			Stdin().SetReadModeL(RIoReadHandle::ELine);
+			iBuf.CreateL(0x100);
+			Stdin().ReadL(iBuf);
+			value.Set(iBuf);
+			}
+		else
+			{
+			id.Set(iSet->Left(eqPos));
+			value.Set(iSet->Mid(eqPos+1));
+			}
+		
+		iReader->SetValueL(Trim(id), value);
+		updated = ETrue;
+		interactive = EFalse;
+		}
+	if (iRemove)
+		{
+		iReader->RemoveValueL(*iRemove);
+		updated = ETrue;
+		interactive = EFalse;
+		}
+	
+	if (iGet)
+		{
+		const TDesC* value = iReader->GetValue(*iGet);
+		if (!value) LeaveIfErr(KErrNotFound, _L("id '%S' not found in %S"), iGet, &iIniFile);
+		Write(*value);
+		interactive = EFalse;
+		}
+	else if (iDump)
+		{
+		RPointerArray<CValue> values;
+		CleanupClosePushL(values);
+		iReader->GetValuesL(values);
+		for (TInt i=0; i<values.Count(); ++i)
+			{
+			if (iForce)
+				{
+				Printf(_L("%S: %S\n"), &values[i]->Id(), &values[i]->Value());
+				}
+			else
+				{
+				CSetting* setting = (CSetting*)values[i];
+				Printf(_L("%S: %S\n"), &setting->Name(), &setting->Value());
+				}
+			}
+		CleanupStack::PopAndDestroy(&values);
+		interactive = EFalse;
+		}
+	
+	if (interactive)
+		{
+		// TODO enter interactive mode
+		LeaveIfErr(KErrNotSupported, _L("Interactive mode not implemented yet."));
+		}
+
+	if (updated)
+		{
+		WriteIniFileL(iIniFile, *iReader);
+		}
+	}
+
+void CCmdIniEdit::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KIniFile, "inifile");
+	aArguments.AppendFileNameL(iIniFile, KIniFile);
+	}
+
+void CCmdIniEdit::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptIdfFile, "idf");
+	aOptions.AppendFileNameL(iDescriptionFile, KOptIdfFile);
+	
+	_LIT(KOptDump, "dump");
+	aOptions.AppendBoolL(iDump, KOptDump);
+	
+	_LIT(KOptForce, "force");
+	aOptions.AppendBoolL(iForce, KOptForce);
+	
+	_LIT(KOptGet, "get");
+	aOptions.AppendStringL(iGet, KOptGet);
+
+	_LIT(KOptSet, "set");
+	aOptions.AppendStringL(iSet, KOptSet);
+	
+	_LIT(KOptRemove, "remove");
+	aOptions.AppendStringL(iRemove, KOptRemove);
+	}
+
+
+EXE_BOILER_PLATE(CCmdIniEdit)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/iniedit/iniedit.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// iniedit.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          iniedit.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_INIEDIT
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+systeminclude   \epoc32\include\fshell
+
+sourcepath      .
+source          iniedit.cpp
+
+library         euser.lib
+library         iocli.lib
+library		ltkutils.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/kerninfo/kerninfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,88 @@
+# kerninfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name kerninfo
+
+==short-description
+
+Displays lists of useful things, such as processes, threads, feature registry settings, and the like.
+
+==long-description
+
+For example to list all the chunks containing the word "fshell", do:
+
+    kerninfo chunk --match *fshell*
+
+To get detailed information about the thread with ID 27, do:
+
+	kerninfo --verbose thread 27
+
+==see-also
+
+L<ps|ps>, L<objinfo|objinfo>, L<chunkinfo|chunkinfo>, L<fuser|fuser>, L<svrinfo|svrinfo>, L<listapps|listapps>, L<hal|hal>
+
+==argument enum object-type
+
+The type of object to list.
+
+==enum-value process
+
+==enum-value thread
+
+==enum-value chunk
+
+==enum-value server
+
+==enum-value codeseg
+
+==enum-value hal
+
+==enum-value windowgroup
+
+==enum-value mimetype
+
+==enum-value openfile
+
+==enum-value featurereg
+
+==enum-value msgq
+
+==enum-value mutex
+
+==enum-value semaphore
+
+==enum-value timer
+
+==argument int object-index optional
+
+List information about a particular object. If not specified, list all objects of this type. For threads and processes, you can pass in a thread/process ID. For other object types, you must pass in the index obtained by running the command with no index argument.
+
+==option string m match
+
+Only display objects whose (non-verbose) info matches the specified string. TDesC::Match style wildcards are allowed. Only makes sense when listing all objects, ie when object-index is not specified.
+
+==option string M regex-match
+
+Like --match but allows a regular expression to be used rather than simple TDesC::Match.
+
+==option bool v verbose
+
+Displays full information for the objects.
+
+==option bool V verbosematch
+
+Makes --match (and --regex-match) match against the verbose info rather than the short info. Caution, this can be extremely slow particularly for threads. Implies --verbose.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/kerninfo/kerninfo.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,226 @@
+// kerninfo.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/memoryaccesscmd.h>
+#include <fshell/qr3dll.h>
+#include <fshell/ltkutils.h>
+#include <fshell/descriptorutils.h>
+#ifdef FSHELL_SPCRE_SUPPORT
+#include <fshell/pcre/cregex.h>
+#endif
+
+using namespace IoUtils;
+class CRegEx;
+
+class CCmdKerninfo : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdKerninfo();
+private:
+	CCmdKerninfo();
+	TInt InfoL(TInt aIndex, TBool aUseId, TBool aVerbose);
+	void PrintInfoForL(TInt aIndex, TBool aUseId=EFalse);
+	static TBool SupportsIds(TKernelObjectType aType);
+	static void ChompBlankLines(TDes& aDes);
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TKernelObjectType iType; 
+	TInt iObjectIndex;
+	TBool iVerbose;
+	TBool iVerboseMatch;
+	HBufC* iMatch;
+	HBufC* iRegexMatch;
+
+	CKernelObjectList* iModel;
+	RBuf iTitle, iInfo;
+	LtkUtils::RLtkBuf8 iNarrowBuf;
+	CRegEx* iRegex;
+	};
+
+
+CCommandBase* CCmdKerninfo::NewLC()
+	{
+	CCmdKerninfo* self = new(ELeave) CCmdKerninfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdKerninfo::~CCmdKerninfo()
+	{
+	delete iModel;
+	iTitle.Close();
+	iInfo.Close();
+	iNarrowBuf.Close();
+	delete iMatch;
+	delete iRegexMatch;
+#ifdef FSHELL_SPCRE_SUPPORT
+	delete iRegex;
+#endif
+	}
+
+CCmdKerninfo::CCmdKerninfo()
+	{
+	}
+
+const TDesC& CCmdKerninfo::Name() const
+	{
+	_LIT(KName, "kerninfo");	
+	return KName;
+	}
+
+void CCmdKerninfo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iType, _L("object-type"));
+	aArguments.AppendIntL(iObjectIndex, _L("object-index"));
+	}
+
+void CCmdKerninfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendStringL(iMatch, _L("match"));
+#ifdef FSHELL_SPCRE_SUPPORT
+	aOptions.AppendStringL(iRegexMatch, _L("regex-match"));
+#endif
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	aOptions.AppendBoolL(iVerboseMatch, _L("verbosematch"));
+	}
+
+EXE_BOILER_PLATE(CCmdKerninfo)
+
+void CCmdKerninfo::DoRunL()
+	{
+	LoadMemoryAccessL();
+
+	iModel = CKernelObjectList::NewL(&iMemAccess);
+	
+	iModel->SetCurrentType(iType);
+	TRAPL(iModel->RefreshDataL(), _L("Couldn't get model data"));
+
+	iTitle.CreateL(256);
+	iInfo.CreateL(256);
+
+#ifdef FSHELL_SPCRE_SUPPORT
+	if (iRegexMatch)
+		{
+		if (iMatch) LeaveIfErr(KErrArgument, _L("Can't specify both --match and --regex-match, use one or the other"));
+		iRegex = CRegEx::NewL(*iRegexMatch, TRegExOptions(EPcreExtended|EPcreNewlineAny));
+		}
+#endif
+	if (iVerboseMatch) iVerbose = ETrue; // verbosematch implies verbose
+
+	const TInt n = iModel->Count();
+	TBool listAll = !iArguments.IsPresent(&iObjectIndex);
+	if (listAll)
+		{
+		for (TInt i = 0; i < n; i++)
+			{
+			PrintInfoForL(i);
+			}
+		}
+	else
+		{
+		TBool usingId = SupportsIds(iType);
+		if (!usingId && (iObjectIndex < 0 || iObjectIndex >= n))
+			{
+			LeaveIfErr(KErrArgument, _L("Bad argument %d. Number of objects in this category: %d"), iObjectIndex, n);
+			}
+		PrintInfoForL(iObjectIndex, usingId);
+		}
+	}
+
+TInt CCmdKerninfo::InfoL(TInt aIndex, TBool aUseId, TBool aVerbose)
+	{
+	TInt err = KErrNone;
+	TInt itemid = 0;
+	if (aUseId)
+		{
+		TRAP(err, iModel->GetInfoByIdL(aIndex, aVerbose, iTitle, iInfo));
+		}
+	else
+		{
+		TRAP(err, itemid = iModel->GetInfoByIndexL(aIndex, aVerbose, iTitle, iInfo));
+		}
+	LeaveIfErr(err, _L("Couldn't get info for item %d"), aIndex);
+	return itemid;
+	}
+
+void CCmdKerninfo::PrintInfoForL(TInt aIndex, TBool aUseId /* =EFalse */)
+	{
+	TInt itemid = 0;
+
+	if (iMatch || iRegexMatch)
+		{
+		// Filter out anything not matching iMatch/iRegexMatch
+		// Unless --verbosematch is specified, match on the non-verbose (but display the verbose if specified). This is because calculating the verbose can be really slow so don't do it until we know we match.
+		itemid = InfoL(aIndex, aUseId, (TBool)iVerboseMatch);
+		const TDesC& toMatchAgainst = iVerboseMatch ? iInfo : iTitle;
+
+		TBool match = EFalse;
+		if (iMatch)
+			{
+			match = (toMatchAgainst.MatchF(*iMatch) != KErrNotFound);
+			}
+#ifdef FSHELL_SPCRE_SUPPORT
+		else if (iRegexMatch)
+			{
+			iNarrowBuf.Zero();
+			iNarrowBuf.AppendL(toMatchAgainst);
+			match = iRegex->PartialMatchL(iNarrowBuf);
+			}
+#endif
+		if (!match) return;
+		}
+	
+	if ((!iMatch && !iRegexMatch) || (iVerbose && !iVerboseMatch))
+		{
+		// Need to get info for first time (if !iMatch) or re-get the verbose info (in the case of we just did a match on the non-verbose info)
+		itemid = InfoL(aIndex, aUseId, iVerbose);
+		}
+
+	TInt idxToDisplay = (SupportsIds(iType) && !aUseId) ? itemid : aIndex;
+	if (iVerbose)
+		{
+		// In verbose mode the title is always just "Process info" (etc) so no point displaying it
+		Printf(_L("%d:\n"), idxToDisplay);
+		ChompBlankLines(iInfo); // When doing a verbose listing (specially multiple ones) it's easier to remove the blank lines that the model adds for readability in the QResources dialog
+		Write(iInfo);
+		Write(_L("\n\n"));
+		}
+	else
+		{
+		Printf(_L("%d: %S\t%S\n"), idxToDisplay, &iTitle, &iInfo);
+		}
+	}
+
+TBool CCmdKerninfo::SupportsIds(TKernelObjectType aType)
+	{
+	// These types can (and should) be looked up directly by id and not by index into the list.
+	return (aType == EListThread || aType == EListProcess || aType == EListHal);
+	}
+
+void CCmdKerninfo::ChompBlankLines(TDes& aDes)
+	{
+	_LIT(KLfLf, "\n\n");
+	TInt found;
+	while ((found = aDes.Find(KLfLf)) != KErrNotFound)
+		{
+		aDes.Delete(found, 1); // Nuke one of the newlines
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/kerninfo/kerninfo.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// kerninfo.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          kerninfo.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_KERNINFO
+
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          kerninfo.cpp
+
+library         euser.lib
+library         iocli.lib
+library         qr3.lib
+library         ltkutils.lib
+
+#ifdef FSHELL_SPCRE_SUPPORT
+systeminclude	/epoc32/include/fshell/pcre
+library			spcre.lib
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/lbs/lbs.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+# lbs.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name lbs
+
+==short-description
+
+Retrieve location information.
+
+==argument enum command optional
+
+The command to perform.
+
+==enum-value location
+
+Get a location reading.
+
+==enum-value modules
+
+List information about installed modules.
+
+==enum-value modules60
+
+The same as 'modules', but based on a proprietary S60 API (can be used to verify the results).
+
+==enum-value enable
+
+Enable a particular module (S60 proprietary).
+
+==enum-value disable
+
+Disable a particular module (S60 proprietary).
+
+==option bool v verbose multiple
+
+Verbose mode. Specify twice (eg -vv) for even more details.
+
+==option uint m module-index
+
+Specify which module to use (note, module B<index>, not module B<id>). If not specified, the first module available in module list will be used.
+
+==option uint l loops
+
+Specify how many loops needed to retrieve location information. Defaults to 1.
+
+==option uint t timeout
+
+Specify a timeout value in seconds to be used before reporting a timeout error. Defaults to 300 seconds. Note, it can take over an hour to get a reading in some circumstance.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/lbs/lbs.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,617 @@
+// lbs.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+#include <lbs.h>
+#include <lbssatellite.h>
+#include <LbsErrors.h>
+
+#if defined (FSHELL_PLATFORM_S60) || defined (FSHELL_PLATFORM_FOUNDATION)
+#include <EPos_CPosModules.h>
+#include <EPos_CPosModuleUpdate.h>
+#include <EPos_CPosModuleIdList.h> 
+#endif
+
+#if !defined (FSHELL_PLATFORM_S60) && !defined (FSHELL_PLATFORM_FOUNDATION)
+#include <lbs/lbsadmin.h>
+#endif
+
+#include <fshell/ioutils.h>
+using namespace IoUtils;
+
+class CCmdLbs : public CCommandBase
+	{
+public:
+	void PrintTime(const TTime& aTime, TBool aNewline);	
+	static const TDesC* TechnologyTypeToString(TPositionModuleInfo::TTechnologyType aType);
+	static const TDesC* DeviceLocationToString(TPositionModuleInfo::TDeviceLocation aLoc);
+	static const TDesC* CostIndicatorToString(TPositionQuality::TCostIndicator aCost);
+	static const TDesC* PowerConsumptionToString(TPositionQuality::TPowerConsumption aPower);
+	static void CapabilitiesToString(TPositionModuleInfo::TCapabilities aCap, TDes &aDes);
+	
+	static CCommandBase* NewLC();
+	~CCmdLbs();
+private:
+	CCmdLbs();
+	void PrintModuleDetail(TPositionModuleInfo& aModInfo);
+	void DoListModuleL();
+	void DoListModuleS60L();
+	void DoLocation();
+	void DoEnableModuleL(TBool aEnable = ETrue);	
+#if !defined (FSHELL_PLATFORM_S60)
+	void DoSynchTimeL();
+#endif
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+
+private:
+	CActiveSchedulerWait* iActiveWait;
+	RPositionServer iPosSrv;
+	RPositioner iPos;
+	TPositionSatelliteInfo iSatelliteInfo;	//NOT all LBS modules accept satellite info
+	TPositionInfo iPosInfo;	
+	TPositionInfoBase* ipPosInfo;			//point to appropriate structure 
+		
+	RArray<TBool> iVerbose;
+	TInt iOptModuleIndex;		//which module to use (module index, not id) 
+	TInt iOptTimeoutSec;		//timeout in second, default is 60 second
+	TInt iOptLoops;				//how many loops (default 1)
+	
+	enum TLbsCmd
+		{
+		ECmdLocation,		
+		ECmdListModule,
+		ECmdListModuleS60,
+		ECmdEnableModule,
+		ECmdDisableModule,
+		ECmdSynchTime		//synchronise system time with GPS timestamp
+		};
+	
+		
+	TLbsCmd iCommand;
+	};
+
+CCommandBase* CCmdLbs::NewLC()
+	{
+	CCmdLbs* self = new(ELeave) CCmdLbs();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdLbs::CCmdLbs()
+	{
+	iOptModuleIndex = -1;
+	iOptTimeoutSec = 300;
+	iOptLoops = 1;
+	iActiveWait = new (ELeave) CActiveSchedulerWait;	
+	}
+
+
+CCmdLbs::~CCmdLbs()
+	{
+	iPos.Close();
+	iPosSrv.Close();
+	
+	iVerbose.Close();
+	delete iActiveWait;
+	}
+
+//////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////
+
+const TDesC& CCmdLbs::Name() const
+	{
+	_LIT(KName, "lbs");
+	return KName;
+	}
+
+void CCmdLbs::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgCommand, "command");
+	aArguments.AppendEnumL((TInt&)iCommand, KArgCommand);
+	}
+
+void CCmdLbs::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	
+	_LIT(KOptModuleIndex, "module-index");
+	aOptions.AppendUintL((TUint&)iOptModuleIndex, KOptModuleIndex);
+
+	_LIT(KOptLoops, "loops");
+	aOptions.AppendUintL((TUint&)iOptLoops, KOptLoops);
+
+	_LIT(KOptTimeout, "timeout");
+	aOptions.AppendUintL((TUint&)iOptTimeoutSec, KOptTimeout);
+	}
+
+void CCmdLbs::DoRunL()
+	{
+	Printf(_L("Connecting to RPositionServer...\r\n"));
+	TInt err = iPosSrv.Connect();
+	LeaveIfErr(err, _L("Cannot connect to position server"));
+	
+	switch(iCommand)
+		{
+		case ECmdLocation:
+			DoLocation();
+			break;
+		case ECmdListModule:
+			DoListModuleL();
+			break;
+		case ECmdListModuleS60:
+			DoListModuleS60L();
+			break;
+		case ECmdEnableModule:
+			DoEnableModuleL(ETrue);
+			break;
+		case ECmdDisableModule:
+			DoEnableModuleL(EFalse);
+			break;
+		case ECmdSynchTime:
+		//TODO There's no way of actually specifying this command
+#if !defined (FSHELL_PLATFORM_S60)
+			DoSynchTimeL();
+#else
+			LeaveIfErr(KErrNotSupported, _L("SynchTime not supported on S60"));
+#endif
+			break;
+		}	
+		
+	}
+
+void CCmdLbs::DoLocation()
+	{
+	TInt VerboseLevel = iVerbose.Count();		
+	TInt err;
+	TBool bSatelliteCapable = EFalse;
+	TPositionModuleId modId; //which module to use
+	if (iOptModuleIndex != -1) 
+		{
+		TPositionModuleInfo modInfo;
+		err = iPosSrv.GetModuleInfoByIndex(iOptModuleIndex, modInfo);
+		LeaveIfErr(err, _L("invalid module index"));
+		modId = modInfo.ModuleId();						
+		}
+	else
+		{	//use the default module
+		err = iPosSrv.GetDefaultModuleId(modId);
+		LeaveIfErr(err, _L("Invalid default module"));
+		}		
+	
+	TPositionModuleInfo modInfo;
+	err = iPosSrv.GetModuleInfoById(modId, modInfo);
+	TBuf<128> modName;
+	modInfo.GetModuleName(modName);	
+	
+	Printf(_L("Openning RPositioner...(Module ID: 0x%X \"%S\")\r\n"), modId.iUid, &modName);
+	err = iPos.Open(iPosSrv, modId);
+	LeaveIfErr(err, _L("Cannot open positioner"));
+	
+   // Set position requestor, it is compulsory on S60 only
+    err = iPos.SetRequestor( CRequestor::ERequestorService ,
+         CRequestor::EFormatApplication , _L("FSHELL FLBS COMMAND") );
+	LeaveIfErr(err, _L("Cannot set requestor"));
+			
+	TPositionUpdateOptions UpdateOption;
+	TTimeIntervalMicroSeconds TimeoutMs = (TInt64)iOptTimeoutSec * (TInt64)1000000;
+	UpdateOption.SetUpdateTimeOut(TimeoutMs);
+	
+	Printf(_L("SetUpdateOptions... Timeout = %d seconds\r\n"), iOptTimeoutSec);
+	err = iPos.SetUpdateOptions(UpdateOption);
+	LeaveIfErr(err, _L("Cannot set update options"));
+	
+	//check if the module is capable of satellite info
+	{
+		TPositionModuleInfo::TCapabilities modCap = modInfo.Capabilities();
+		bSatelliteCapable = modCap & TPositionModuleInfo::ECapabilitySatellite;
+		if (bSatelliteCapable)
+			{
+			ipPosInfo = &iSatelliteInfo;
+			Printf(_L("This module is capable of receiving satellite information\r\n"));
+			}
+		else
+			ipPosInfo = &iPosInfo;			
+	}
+	
+	for (TInt i=0; i<iOptLoops; i++)
+		{
+		TRequestStatus status;
+		TPosition pos;
+		Printf(_L("Calling RPositioner::NotifyPositionUpdate...\r\n"));
+		iPos.NotifyPositionUpdate(*ipPosInfo, status);
+		User::WaitForRequest(status);
+		
+		err = status.Int();
+		if (err != KErrNone)
+			LeaveIfErr(err, _L("NotifyPositionUpdate encountered an error"));
+				
+		static_cast <TPositionInfo*>(ipPosInfo) -> GetPosition(pos);
+		TTime LocTime = pos.Time();
+		TReal32 HorizontalAccuracy = pos.HorizontalAccuracy();
+		TReal32 VerticalAccuracy = pos.VerticalAccuracy();
+		//print current location information
+		Printf(_L("Altit:%f Latit:%f Longt:%f HAccu:%.2f VAccu:%.2f\r\n"), 
+				pos.Altitude(), pos.Latitude(), pos.Longitude(), 
+				HorizontalAccuracy, VerticalAccuracy);		
+		
+		Printf(_L("Location Signal Time:"));
+		PrintTime(LocTime, ETrue);
+		
+		//if there is satellite information, optionally print it out
+		if (bSatelliteCapable && (VerboseLevel>0) )
+			{
+			TPositionSatelliteInfo* pSateInfo = static_cast <TPositionSatelliteInfo*> (ipPosInfo);
+			
+			TInt NumSatellitesInView = pSateInfo->NumSatellitesInView();
+			TInt NumSatellitesUsed = pSateInfo->NumSatellitesUsed();
+			TTime SatelliteTime = pSateInfo->SatelliteTime();
+			TReal32 HorizontalDoP = pSateInfo->HorizontalDoP();
+			TReal32 VerticalDoP = pSateInfo->VerticalDoP();
+			TReal32 TimeDoP = pSateInfo->TimeDoP(); 
+			Printf(_L("Satellite In View:%d Used:%d Time:"), 
+					NumSatellitesInView, NumSatellitesUsed );
+			PrintTime(SatelliteTime, ETrue);
+			Printf(_L("HoriDop:%f VertDop:%f TimeDop:%f \r\n"), 
+					HorizontalDoP, VerticalDoP, TimeDoP);
+			
+			//Print each satellite info
+			for (TInt i=0; i<NumSatellitesInView; i++ )
+				{
+				TSatelliteData SatellliteData;
+				err = pSateInfo->GetSatelliteData((TUint)i, SatellliteData);
+				if (err == KErrNotFound)
+					{
+					Printf(_L("Satellite #%d Not Found\r\n"), i);
+					continue;
+					}
+				else
+					{
+					User::LeaveIfError(err);
+					}
+				
+				TInt SatelliteId = SatellliteData.SatelliteId(); 
+				TReal32 Azimuth = SatellliteData.Azimuth();
+				TReal32 Elevation = SatellliteData.Elevation();
+				TBool IsUsed = SatellliteData.IsUsed();
+				TInt SignalStrength = SatellliteData.SignalStrength();
+				
+				Printf(_L("Satellite #%d, ID:%d Azimuth %.2f Elevation %.2f IsUsed:%d Strenth:%d\r\n"), 
+						i, SatelliteId, Azimuth, Elevation, IsUsed, SignalStrength);
+			
+				}
+			}			
+		}	
+	}
+
+void CCmdLbs::DoListModuleL()
+	{
+	TInt err;
+	TUint numModules;
+	TPositionModuleInfo modInfo;
+	
+	err = iPosSrv.GetNumModules(numModules);
+	User::LeaveIfError(err);
+
+	Printf(_L("%d Modules found\r\n"), 
+			numModules);
+	
+	for (TUint i=0 ; i < numModules ; i++)
+		{
+		Printf(_L("============================\r\n")); 		
+		err = iPosSrv.GetModuleInfoByIndex(i, modInfo);
+		User::LeaveIfError(err);
+		
+		Printf(_L("Module Index: %d\r\n"), i);
+		
+		PrintModuleDetail(modInfo);
+		}
+	
+	Printf(_L("=================================\r\n"));
+	//print default module ID
+	TPositionModuleId DefaultId;
+	err = iPosSrv.GetDefaultModuleId(DefaultId);		
+	Printf(_L("Default Module ID 0x%X\r\n"), DefaultId.iUid );
+	}
+
+//S60 proprietary
+//similar to DoListModuleL, but list module based on S60 API,
+//and sometimes it gives different results than symbain API
+void CCmdLbs::DoListModuleS60L()
+	{
+#ifdef FSHELL_PLATFORM_S60
+	//TInt err;
+	TUint numModules;
+	CPosModules* pModHand = CPosModules::OpenL();
+	CleanupStack::PushL(pModHand);
+	
+	CPosModuleIdList* pIdList = pModHand->ModuleIdListL();
+	CleanupStack::PushL(pIdList);
+	
+	numModules = pIdList->Count();
+	Printf(_L("%d Modules found\r\n"), 
+			numModules);
+	
+	for (TUint i=0 ; i < numModules ; i++)
+		{
+		Printf(_L("============================\r\n"));
+		TPositionModuleId S60modId = (*pIdList) [i];
+		TPositionModuleInfo S60modInfo;
+		TBuf<128> S60modName;			//to store module name
+		
+		pModHand->GetModuleInfoL(S60modId, S60modInfo);
+		S60modInfo.GetModuleName(S60modName);
+				
+		Printf(_L("Module Index: %d\r\n"), i);
+		
+		PrintModuleDetail(S60modInfo);
+		}
+
+	Printf(_L("=================================\r\n"));		
+	
+	CleanupStack::PopAndDestroy(pIdList);
+	CleanupStack::PopAndDestroy(pModHand);		
+#endif
+	}
+
+void CCmdLbs::PrintModuleDetail(TPositionModuleInfo& aModInfo)
+	{
+	//TInt err;
+	TBool bAvailable = aModInfo.IsAvailable();
+	
+	TPositionModuleId modId;
+	modId = aModInfo.ModuleId();
+	
+	TBuf<128> modName;
+	aModInfo.GetModuleName(modName);
+	
+	//==quality
+	TPositionQuality modQuality;
+	aModInfo.GetPositionQuality(modQuality);
+	TTimeIntervalMicroSeconds firstFix = modQuality.TimeToFirstFix();
+	TTimeIntervalMicroSeconds nextFix = modQuality.TimeToNextFix();
+	TReal32 horiAccu = modQuality.HorizontalAccuracy();
+	TReal32 vertAccu = modQuality.VerticalAccuracy();
+	TPositionQuality::TCostIndicator cost = modQuality.CostIndicator();
+	TPositionQuality::TPowerConsumption power = modQuality.PowerConsumption();
+	////////////////////////////////////////////////////////////////
+	TPositionModuleInfo::TTechnologyType modType = aModInfo.TechnologyType();		
+	TPositionModuleInfo::TDeviceLocation modLoc = aModInfo.DeviceLocation();		
+	TPositionModuleInfo::TCapabilities modCap = aModInfo.Capabilities();
+	TVersion modVersion = aModInfo.Version();
+	TVersionName VersionName = modVersion.Name(); 
+	
+	//TPositionClassFamily aClassType;
+	//modInfo.ClassesSupported(aClassType);
+	
+	Printf(_L("Module Id:0x%X, Name:\"%S\" Available:%d \r\n"),
+			modId.iUid, &modName, bAvailable);
+	Printf(_L("Type:%S Version:%S\r\n"), 
+			TechnologyTypeToString(modType), &VersionName );
+	Printf(_L("Location:%S\r\n"), DeviceLocationToString (modLoc));
+
+	Printf(_L("Quality first fix:%Ld next fix:%Ld \r\n"),
+			firstFix.Int64(), nextFix.Int64());
+	Printf(_L("Horizontal Accuracy:%f Vertical Accuray:%f \r\n"),
+			horiAccu, vertAccu);
+	Printf(_L("Cost Indicator:%S\r\n"), CostIndicatorToString(cost));
+	Printf(_L("Power Consumption:%S\r\n"), PowerConsumptionToString(power));		
+				
+	TBuf<256> CapString;
+	CapabilitiesToString(modCap, CapString);
+	Printf(_L("Capabilities:%S\r\n"), &CapString);	
+	}
+	
+//it is a S60 proprietary function
+//
+void CCmdLbs::DoEnableModuleL(TBool aEnable)
+	{
+	TInt err;
+	TBuf<128> modName;			//to store module name
+	TPositionModuleInfo modInfo;
+	TPositionModuleId modId = TUid::Null(); //which module to use
+	TBool bIsCurAvail;
+	
+	if (iOptModuleIndex != -1) 
+		{
+		err = iPosSrv.GetModuleInfoByIndex(iOptModuleIndex, modInfo);
+		LeaveIfErr(err, _L("invalid module index"));
+		modId = modInfo.ModuleId();						
+		}
+	else 
+		{
+		LeaveIfErr(KErrArgument, _L("Need to specify a module"));
+		}
+	
+	bIsCurAvail = modInfo.IsAvailable();
+	modInfo.GetModuleName(modName);
+	
+	TPtrC AvailNow = (bIsCurAvail)?_L("Yes"):_L("No");
+	Printf(_L("Module Id=0x%08x Name:\"%S\" Current Availability:%S \r\n"), 
+			modId.iUid, &modName, &AvailNow);
+	
+	//modInfo.SetIsAvailable(ETrue);	//Note: this has no effect on S60 platform
+	
+#ifdef FSHELL_PLATFORM_S60
+	CPosModules* pModHand = CPosModules::OpenL();
+	CleanupStack::PushL(pModHand);
+	
+	//diagnosis code: to verify the information given by S60 API matches Symbian API
+	{
+		CPosModuleIdList* pIdList = pModHand->ModuleIdListL();
+		CleanupStack::PushL(pIdList);
+		
+		TPositionModuleId S60modId = (*pIdList) [iOptModuleIndex];
+		TPositionModuleInfo S60modInfo;
+		TBuf<128> S60modName;			//to store module name
+				
+		pModHand->GetModuleInfoL(S60modId, S60modInfo);
+		S60modInfo.GetModuleName(S60modName);
+		RDebug::Print(_L("S60 LBS module name:%S"), &S60modName);
+		
+		CleanupStack::PopAndDestroy(pIdList);
+	}
+	
+	
+	CPosModuleUpdate* pModUpdate = CPosModuleUpdate::NewLC();	
+	TBool bNewAvail = aEnable;
+	pModUpdate->SetUpdateAvailability(bNewAvail);	
+	TRAP(err, pModHand->UpdateModuleL(modId, *pModUpdate));
+	LeaveIfErr(err, _L("Could not update module information") );
+		
+	CleanupStack::PopAndDestroy(pModUpdate);		
+	CleanupStack::PopAndDestroy(pModHand);		
+#endif
+	
+	//verify if the change has take effect
+		{
+		err = iPosSrv.GetModuleInfoByIndex(iOptModuleIndex, modInfo);
+		LeaveIfErr(err, _L("invalid module index"));
+		modId = modInfo.ModuleId();						
+		bIsCurAvail = modInfo.IsAvailable();
+		TPtrC NewAvail = (bIsCurAvail)?_L("Yes"):_L("No");
+		Printf(_L("Module Id=0x%08x Name:\"%S\" New Availability:%S \r\n"), 
+				modId.iUid, &modName, &NewAvail);		
+		}
+		
+	}
+	
+#if !defined (FSHELL_PLATFORM_S60)
+void CCmdLbs::DoSynchTimeL()
+	{
+	// Set LBS setting to allow manual clock adjustment
+	//This may not be set by default
+    CLbsAdmin* admin = CLbsAdmin::NewL();
+    CleanupStack::PushL(admin);
+    CLbsAdmin::TClockAdjust clockAdjust;   
+    User::LeaveIfError(admin->Get(KLbsSettingAllowManualClockAdjust,clockAdjust));
+    admin->Set(KLbsSettingAllowManualClockAdjust,CLbsAdmin::EClockAdjustOn);
+    CleanupStack::PopAndDestroy(admin);
+	}
+#endif
+
+EXE_BOILER_PLATE(CCmdLbs)
+
+void CCmdLbs::PrintTime(const TTime& aTime, TBool aNewline)
+	{
+	
+	TTime NullTime = Time::NullTTime();
+	if (aTime == NullTime) 
+		{
+		Printf(_L("(NullTime)"));
+		}
+	else
+		{
+		_LIT8(KDateTimeFormat, "%d-%02d-%02d %02d:%02d:%02d");
+		TDateTime dt = aTime.DateTime();
+		Printf(KDateTimeFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
+		}
+	
+	if (aNewline) Printf(_L("\r\n"));
+	}
+
+
+#define CASE_LIT(x) case x: { _LIT(KName, #x); return &KName; }
+
+const TDesC* CCmdLbs::TechnologyTypeToString(TPositionModuleInfo::TTechnologyType aType)
+	{
+	switch(aType)
+		{
+		CASE_LIT(TPositionModuleInfo::ETechnologyUnknown);
+		CASE_LIT(TPositionModuleInfo::ETechnologyTerminal);
+		CASE_LIT(TPositionModuleInfo::ETechnologyNetwork);
+		CASE_LIT(TPositionModuleInfo::ETechnologyAssisted);
+		default:
+			{			
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+
+const TDesC* CCmdLbs::DeviceLocationToString(TPositionModuleInfo::TDeviceLocation aLoc)
+	{
+	switch(aLoc)
+		{
+		CASE_LIT(TPositionModuleInfo::EDeviceUnknown);
+		CASE_LIT(TPositionModuleInfo::EDeviceInternal);
+		CASE_LIT(TPositionModuleInfo::EDeviceExternal);
+		default:
+			{			
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+
+const TDesC* CCmdLbs::CostIndicatorToString(TPositionQuality::TCostIndicator aCost)
+	{
+	switch(aCost)
+		{
+		CASE_LIT(TPositionQuality::ECostUnknown);
+		CASE_LIT(TPositionQuality::ECostZero);
+		CASE_LIT(TPositionQuality::ECostPossible);
+		CASE_LIT(TPositionQuality::ECostCharge);
+		default:
+			{			
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+
+const TDesC* CCmdLbs::PowerConsumptionToString(TPositionQuality::TPowerConsumption aPower)
+	{
+	switch(aPower)
+		{
+		CASE_LIT(TPositionQuality::EPowerUnknown);
+		CASE_LIT(TPositionQuality::EPowerZero);
+		CASE_LIT(TPositionQuality::EPowerLow);
+		CASE_LIT(TPositionQuality::EPowerMedium);
+		CASE_LIT(TPositionQuality::EPowerHigh);
+		default:
+			{			
+			_LIT(KUnknown, "Unknown");
+			return &KUnknown;
+			}
+		}
+	}
+#define CAPFLAG(x) if (aCap & TPositionModuleInfo::x) { aDes += _L(#x); aDes += _L("|");}
+
+void CCmdLbs::CapabilitiesToString(TPositionModuleInfo::TCapabilities aCap, TDes &aDes)
+	{
+	aDes.SetLength(0);
+	//if (aCap & TPositionModuleInfo::ECapabilityNone) aDes += _L("ECapabilityNone|");
+	CAPFLAG(ECapabilityNone);
+	CAPFLAG(ECapabilityHorizontal);
+	CAPFLAG(ECapabilityVertical);
+	CAPFLAG(ECapabilitySpeed);
+	CAPFLAG(ECapabilityDirection);
+	CAPFLAG(ECapabilitySatellite);
+	CAPFLAG(ECapabilityCompass);
+	CAPFLAG(ECapabilityNmea);
+	CAPFLAG(ECapabilityAddress);
+	CAPFLAG(ECapabilityBuilding);
+	CAPFLAG(ECapabilityMedia);
+	}
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/lbs/lbs.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// lbs.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			fshell_lbs.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_LBS
+
+capability		Location WriteDeviceData ReadDeviceData ReadUserData
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	FSHELL_NETWORKING_SYSTEMINCLUDE FSHELL_LBS_SYSTEMINCLUDE
+
+sourcepath		.
+source			lbs.cpp
+
+library			euser.lib
+library			iocli.lib
+
+#ifdef FSHELL_PLATFORM_S60
+LIBRARY			lbs.lib eposmodset.lib
+#else
+LIBRARY			lbsselflocate.lib
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/leak/leak.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,58 @@
+# leak.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name leak
+
+==short-description
+
+A tool for purposefully wasting memory.
+
+==long-description
+
+Sits in a loop allocating memory. This continues until either the specified amount of memory has been consumed, or an error occurs. The allocations can be configured to come from a raw RChunk, or via an RHeap (C<User::ChunkHeap()>). The command waits for a keypress before exiting and freeing the memory.
+
+==see-also
+
+L<gobble|gobble>
+
+==argument int amount optional
+
+The target amount of memory to consume (in bytes). If not specified attempts to consumes all available memory.
+
+==option bool v verbose
+
+Display more detailed output.
+
+==option int i increment-amount
+
+The number of bytes to leak on each increment. If not specified and a target amount is specified, tries to allocate the entire target amount in one go. If not specified and a target amount isn't specified either, defaults to 4096 bytes. Note that unless C<--heap> is used, the increment amount must be a multiple of 4096 bytes.
+
+==option uint r rate
+
+The amount of time (in milliseconds) to wait between each increment. Defaults to zero (i.e. no wait).
+
+==option uint a address
+
+The address of a heap to leak into. The value should be in the address space of the process given by the C<--processid> option.
+
+==option bool H heap
+
+Use a ChunkHeap to consume the memory rather than a straight RChunk.
+
+==option bool t retry
+
+If specified, when an allocation fails retry using a smaller increment amount.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/leak/leak.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,169 @@
+// leak.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "leak.h"
+#include <fshell/common.mmh>
+
+const TInt KMinChunkSize = 4 * 1024;
+const TInt KMaxChunkSize = 512 * 1024 * 1024;
+
+CCommandBase* CCmdLeak::NewLC()
+	{
+	CCmdLeak* self = new(ELeave) CCmdLeak();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdLeak::~CCmdLeak()
+	{
+	iChunk.Close();
+	if (iChunkHeap)
+		{
+		iChunkHeap->Reset();
+		iChunkHeap->Close();
+		}
+	}
+
+CCmdLeak::CCmdLeak()
+	{
+	}
+
+const TDesC& CCmdLeak::Name() const
+	{
+	_LIT(KName, "leak");
+	return KName;
+	}
+
+void CCmdLeak::DoRunL()
+	{
+	if ((iAmount < 0) || (iIncrementAmount < 0))
+		{
+		User::Leave(KErrArgument);
+		}
+
+	if (iArguments.IsPresent(0))
+		{
+		if (iIncrementAmount == 0)
+			{
+			iIncrementAmount = iAmount;
+			}
+		}
+	else
+		{
+		iAmount = KMaxTInt;
+		if (iIncrementAmount == 0)
+			{
+			iIncrementAmount = KMinChunkSize;
+			}
+		}
+
+	if (iUseHeap)
+		{
+		iChunkHeap = UserHeap::ChunkHeap(NULL, KMinChunkSize, 256*1024*1024);
+		if (!iChunkHeap) LeaveIfErr(KErrNoMemory, _L("Couldn't create chunk heap"));
+		}
+	else
+		{
+		if (iIncrementAmount & 4095) LeaveIfErr(KErrArgument, _L("increment-amount must be a multiple of 4096"));
+		TInt err = iChunk.CreateLocal(KMinChunkSize, KMaxChunkSize);
+		LeaveIfErr(err, _L("Failed to create local chunk"));
+		}
+
+	RIoConsoleWriteHandle stdout = Stdout();
+	stdout.SetCursorHeight(0);
+	TInt err = KErrNone;
+	do
+		{
+		err = LeakStep(Min(iIncrementAmount, iAmount - iCurrentLeak));
+		if (iVerbose)
+			{
+			Write(_L("\r"));
+			stdout.ClearToEndOfLine();
+			Printf(_L("Allocated %d: %d"), iCurrentLeak, err);
+			}
+		if (err && iRetry && iIncrementAmount > 4)
+			{
+			// Keep going with a smaller increment
+			err = KErrNone;
+			iIncrementAmount /= 2;
+			continue;
+			}
+
+		if (iRate > 0)
+			{
+			User::After(iRate * 1000);
+			}
+		}
+		while ((err == KErrNone) && (iCurrentLeak < iAmount));
+
+	if (err == KErrNoMemory)
+		{
+		Printf(_L("Out of memory. "));
+		}
+	else if (err)
+		{
+		Printf(_L("Error: %d. "), err);
+		}
+
+	Printf(_L("\r\nLeaked %d bytes. Press any key to exit (and free the memory).\r\n"), iCurrentLeak);
+
+	RIoConsoleReadHandle stdin = Stdin();
+	stdin.ReadKey();
+	}
+
+void CCmdLeak::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptIncrementAmount, "increment-amount");
+	aOptions.AppendIntL(iIncrementAmount, KOptIncrementAmount);
+
+	_LIT(KOptRate, "rate");
+	aOptions.AppendUintL(iRate, KOptRate);
+
+	_LIT(KOptUseHeap, "heap");
+	aOptions.AppendBoolL(iUseHeap, KOptUseHeap);
+
+	_LIT(KOptRetry, "retry");
+	aOptions.AppendBoolL(iRetry, KOptRetry);
+	}
+
+void CCmdLeak::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgAmount, "amount");
+	aArguments.AppendIntL(iAmount, KArgAmount);
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdLeak)
+#endif
+
+TInt CCmdLeak::LeakStep(TInt aAmount)
+	{
+	TInt err = KErrNone;
+	if (iChunkHeap)
+		{
+		TAny* cell = iChunkHeap->Alloc(aAmount);
+		if (!cell) err = KErrNoMemory;
+		}
+	else
+		{
+		if (aAmount < 4096) err = KErrNoMemory; // implies we're retrying - unlike the others that keep retrying down to 4 bytes, we have to stop at page granularity
+		else err = iChunk.Adjust(iCurrentLeak + aAmount);
+		}
+
+	if (!err) iCurrentLeak += aAmount;
+	return err;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/leak/leak.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// leak.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdLeak : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdLeak();
+private:
+	CCmdLeak();
+	TInt LeakStep(TInt aAmount);
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TInt iAmount;
+	TBool iVerbose;
+	TInt iIncrementAmount;
+	TUint iRate;
+
+	TUint iHeapAddr;
+	TBool iUseHeap;
+	TBool iRetry;
+
+	RChunk iChunk;
+	RAllocator* iChunkHeap;
+
+	TInt iCurrentLeak;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/leak/leak.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// leak.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          leak.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_LEAK
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          leak.cpp
+
+library         euser.lib
+library         iocli.lib
+
+#ifdef FSHELL_AUTOMETRIC_SUPPORT_EIKPLUGIN
+library         am-eikclient.lib
+#endif
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/listapps/listapps.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,44 @@
+# listapps.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name listapps
+
+==short-description
+
+Displays details about the currently running applications.
+
+==long-description
+
+Unless you specify C<--verbose>, displays each application's caption and its window group id in brackets. Unless you specify C<--show-all> only window groups with standard ordinal priority (zero) will be displayed. Applications are displayed in decending priority and ascending position within that priority. I.e. the frontmost group is shown first, then the ones beneath it at the same priority, then the next priority etc.
+
+==see-also
+
+L<focus|focus>
+
+==option bool v verbose
+
+Display more detailed information about each application.
+
+==option bool a show-all
+
+Show all window groups, not just ones with standard priority.
+
+==argument uint id optional
+
+Display the details of the application with the specified window group identifier. If not specified, details of all currently running applications are displayed.
+
+
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/listapps/listapps.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,167 @@
+// listapps.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <w32std.h>
+#include <apgwgnam.h>
+#include "listapps.h"
+
+
+CCommandBase* CCmdListApps::NewLC()
+	{
+	CCmdListApps* self = new(ELeave) CCmdListApps();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdListApps::~CCmdListApps()
+	{
+	delete iFormatter;
+	}
+
+CCmdListApps::CCmdListApps()
+	{
+	}
+
+const TDesC& CCmdListApps::Name() const
+	{
+	_LIT(KName, "listapps");
+	return KName;
+	}
+
+void CCmdListApps::DoRunL()
+	{
+	iFormatter = CTextFormatter::NewL(Stdout());
+	RWsSession wsSession;
+	LeaveIfErr(wsSession.Connect(), _L("Couldn't connect to windowserver"));
+	CleanupClosePushL(wsSession);
+	if (iArguments.IsPresent(0))
+		{
+		PrintDetailsL(wsSession, iWgId);
+		}
+	else
+		{
+		CArrayFixFlat<TInt>* wgIds = new(ELeave) CArrayFixFlat<TInt>(16);
+		CleanupStack::PushL(wgIds);
+		TInt err = KErrNone;
+		if (iShowAll)
+			{
+			err = wsSession.WindowGroupList(wgIds);
+			}
+		else
+			{
+			err = wsSession.WindowGroupList(0, wgIds);
+			}
+		LeaveIfErr(err, _L("Couldn't get window group list"));
+		TInt numWgs = wgIds->Count();
+		for (TInt i = 0; i < numWgs; ++i)
+			{
+			PrintDetailsL(wsSession, (*wgIds)[i]);
+			}
+		CleanupStack::PopAndDestroy(wgIds);
+		}
+	CleanupStack::PopAndDestroy(&wsSession);
+	}
+
+void AppendBoolL(CTextFormatter& aFormatter, const TDesC& aCaption, TBool aBool)
+	{
+	_LIT(KYes, "yes");
+	_LIT(KNo, "no");
+	aFormatter.AppendFormatL(_L("\t%S: %S\r\n"), &aCaption, aBool ? &KYes : &KNo);
+	}
+	
+void CCmdListApps::PrintDetailsL(RWsSession& aWsSession, TInt aWindowGroupId)
+	{
+	CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC(aWsSession, aWindowGroupId);
+	_LIT(KUnknown, "not named");
+	TPtrC caption(wgn->Caption());
+	if (caption.Length() == 0)
+		{
+		caption.Set(KUnknown);
+		}
+	if (iVerbose)
+		{
+		iFormatter->AppendFormatL(_L("%S\r\n"), &caption);
+		TPtrC docName(wgn->DocName());
+		iFormatter->AppendFormatL(_L("\tDocument name: %S\r\n"), &docName);
+		iFormatter->AppendFormatL(_L("\tWindow group id: %u\r\n"), aWindowGroupId);
+		TThreadId threadId;
+		TInt err = aWsSession.GetWindowGroupClientThreadId(aWindowGroupId, threadId);
+		if (err)
+			{
+			PrintWarning(_L("Couldn't read window group client thread id: %d"), err);
+			}
+		else
+			{
+			TFullName threadName(_L("unknown"));
+			RThread thread;
+			if (thread.Open(threadId) == KErrNone)
+				{
+				thread.FullName(threadName);
+				thread.Close();
+				}
+#ifdef EKA2
+			iFormatter->AppendFormatL(_L("\tThread id: %Lu '%S'\r\n"), threadId.Id(), &threadName);
+#else
+			iFormatter->AppendFormatL(_L("\tThread id: %u '%S'\r\n"), threadId, &threadName);
+#endif
+			}
+		iFormatter->AppendFormatL(_L("\tUID: 0x%08x\r\n"), wgn->AppUid().iUid);
+		AppendBoolL(*iFormatter, _L("Busy"), wgn->IsBusy());
+		AppendBoolL(*iFormatter, _L("System"), wgn->IsSystem());
+		AppendBoolL(*iFormatter, _L("Doc name is a file"), wgn->DocNameIsAFile());
+		AppendBoolL(*iFormatter, _L("Responds to shutdown event"), wgn->RespondsToShutdownEvent());
+		AppendBoolL(*iFormatter, _L("Responds to switch files event"), wgn->RespondsToSwitchFilesEvent());
+		AppendBoolL(*iFormatter, _L("Hidden"), wgn->Hidden());
+#ifdef EKA2
+		AppendBoolL(*iFormatter, _L("Ready"), wgn->IsAppReady());
+#endif
+		iFormatter->AppendFormatL(_L("\tOrdinal priority: %d\r\n"), aWsSession.GetWindowGroupOrdinalPriority(aWindowGroupId));
+		if (aWindowGroupId == aWsSession.GetFocusWindowGroup())
+			{
+			iFormatter->AppendL(_L("\tFocussed\r\n"));
+			}
+		Write(iFormatter->Descriptor());
+		iFormatter->Zero();
+		}
+	else
+		{
+		Printf(_L("%S (%d)"), &caption, aWindowGroupId);
+		if (aWindowGroupId == aWsSession.GetFocusWindowGroup())
+			{
+			Printf(_L(" (focussed)"));
+			}
+		Printf(_L("\r\n"));
+		}
+	CleanupStack::PopAndDestroy(wgn);
+	}
+
+void CCmdListApps::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KCmdOptVerbose);
+
+	_LIT(KCmdOptShowAll, "show-all");
+	aOptions.AppendBoolL(iShowAll, KCmdOptShowAll);
+	}
+
+void CCmdListApps::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgWgId, "id");
+	aArguments.AppendUintL(iWgId, KArgWgId);
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdListApps)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/listapps/listapps.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+// listapps.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class TApaTask;
+class RWsSession;
+
+class CCmdListApps : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdListApps();
+private:
+	CCmdListApps();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	void PrintDetailsL(RWsSession& aWsSession, TInt aWindowGroupId);
+private:
+	CTextFormatter* iFormatter;
+	TUint iWgId;
+	TBool iVerbose;
+	TBool iShowAll;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/listapps/listapps.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// listapps.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          listapps.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_LISTAPPS
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          listapps.cpp
+
+library         euser.lib
+library         iocli.lib
+library         ws32.lib
+library         apgrfx.lib
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/load/load.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,44 @@
+# load.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name load
+
+==short-description
+
+Dynamically load a DLL.
+
+==long-description
+
+Useful for checking whether the file server is able to resolve all the DLL's dependencies. Makes no attempt to actually run code in the DLL.
+
+The syntax of the DLL name, uids and other arguments are as per the C<RLibrary::Load> documentation. The command will stay running once the DLL has loaded - to exit use CTRL-C. To run the command in the background append C<&> to the fshell command-line.
+
+==see-also
+
+L<chkdeps|chkdeps>, L<driver|driver>
+
+==option uint u uid multiple
+
+The UID of the DLL to be loaded. May be use up to three times to specify all three Symbian DLL UIDs (specifying it once defines UID1, if you specify it again that is UID2 etc).
+
+==option uint V version
+
+The version of the DLL to be loaded. The top 16 bits of the version are the major version, the bottom 16 the minor. Unless otherwise specified DLLs are given the version 10.0, ie 0x000A0000. Note versions are not checked on the WINSCW platform because it uses the windows DLL loader.
+
+==argument string dll_name
+
+The name of the DLL to load.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/load/load.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,113 @@
+// load.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+
+class CCmdLoad : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdLoad();
+private:
+	CCmdLoad();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iDllName;
+	RArray<TUint> iUids;
+	TUint iModuleVersion;
+	RLibrary iLibrary;
+	};
+
+
+//
+// CCmdLoad.
+//
+
+CCommandBase* CCmdLoad::NewLC()
+	{
+	CCmdLoad* self = new(ELeave) CCmdLoad();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdLoad::~CCmdLoad()
+	{
+	iLibrary.Close();
+	delete iDllName;
+	iUids.Close();
+	}
+
+CCmdLoad::CCmdLoad() : CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdLoad::Name() const
+	{
+	_LIT(KName, "load");
+	return KName;
+	}
+
+void CCmdLoad::DoRunL()
+	{
+	if (iUids.Count() > 3)
+		{
+		LeaveIfErr(KErrArgument, _L("Too many UIDs specified"));
+		}
+
+	while (iUids.Count() < 3)
+		{
+		iUids.AppendL(KNullUid.iUid);
+		}
+	TUidType type(TUid::Uid(iUids[0]), TUid::Uid(iUids[1]), TUid::Uid(iUids[2]));
+
+	_LIT(KError, "Unable to load \"%S\"");
+	if (iOptions.IsPresent(&iModuleVersion))
+		{
+		LeaveIfErr(iLibrary.Load(*iDllName, KNullDesC, type, iModuleVersion), KError, iDllName);
+		}
+	else
+		{
+		LeaveIfErr(iLibrary.Load(*iDllName, type), KError, iDllName);
+		}
+
+	TFileName file = iLibrary.FileName();
+	TUidType uids = iLibrary.Type();
+	Printf(_L("Loaded %S\r\n"), &file);
+	Printf(_L("Uids: 0x%x, 0x%x, 0x%x\r\n"), uids[0].iUid, uids[1].iUid, uids[2].iUid);
+	}
+
+void CCmdLoad::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdOptUid, "uid");
+	aOptions.AppendUintL(iUids, KCmdOptUid);
+
+	_LIT(KCmdOptVersion, "version");
+	aOptions.AppendUintL(iModuleVersion, KCmdOptVersion);
+	}
+
+void CCmdLoad::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdArgFileName, "dll_name");
+	aArguments.AppendStringL(iDllName, KCmdArgFileName);
+	}
+
+
+EXE_BOILER_PLATE(CCmdLoad)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/load/load.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// load.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_load.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_LOAD
+capability      none
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          load.cpp
+
+library         euser.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/localdrive/localdrive.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+# localdrive.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name localdrive
+
+==short-description
+
+Manipulate local drives using RLocalDrive.
+
+==long-description
+
+==argument enum operation optional
+
+Operation to perform.
+
+==enum-value list
+
+List info about the given drive, or if not specified list all available local drives.
+
+==enum-value read
+
+Dumps the raw contents of the specified drive to the file given by --file, or stdout if not specified.
+
+==enum-value write
+
+Write the file specified by --file back into the partition given by <drive>. The file size must match the partition size exactly.
+
+==argument int drive optional
+
+The drive to operate on. Must be specified for read and write commands.
+
+==option bool b bytes
+
+Display sizes in bytes rather than as human-readable strings - ie "1048576" rather than "1 MB".
+
+==option filename f file
+
+Use in conjunction with read and write to specify the file to read/write the raw partition data from/to.
+
+==copyright
+
+Copyright (c) 2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/localdrive/localdrive.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,236 @@
+// localdrive.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#include <d32locd.h>
+
+using namespace IoUtils;
+
+class CCmdLocalDrive : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdLocalDrive();
+private:
+	CCmdLocalDrive();
+	TInt OpenL(TInt aDrive, TBool aLeaveOnConnectErr);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TCmd
+		{
+		EList,
+		ERead,
+		EWrite,
+		};
+	TInt iDriveNum;
+	TCmd iCmd;
+	TBool iSizesInBytes;
+	TFileName2 iFile;
+
+	RLocalDrive iDrive;
+	TLocalDriveCapsV2 iCaps;
+	};
+
+EXE_BOILER_PLATE(CCmdLocalDrive)
+
+CCommandBase* CCmdLocalDrive::NewLC()
+	{
+	CCmdLocalDrive* self = new(ELeave) CCmdLocalDrive();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdLocalDrive::~CCmdLocalDrive()
+	{
+	iDrive.Close();
+	}
+
+CCmdLocalDrive::CCmdLocalDrive()
+	{
+	}
+
+const TDesC& CCmdLocalDrive::Name() const
+	{
+	_LIT(KName, "localdrive");	
+	return KName;
+	}
+
+void CCmdLocalDrive::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCmd, _L("operation"));
+	aArguments.AppendIntL(iDriveNum, _L("drive"));
+	}
+
+void CCmdLocalDrive::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iSizesInBytes, _L("bytes"));
+	aOptions.AppendFileNameL(iFile, _L("file"));
+	}
+
+// More GCC issues (see qresources3\src\utils.cpp). Happily the compiler is happier with SLitC and DESC than it is with TLitC and _LIT
+#include <fshell/descriptorutils.h>
+#define CASE_LIT(x) case x: { LtkUtils::SLitC KName = DESC(#x); return &KName; }
+
+const TDesC* MediaTypeDesc(TMediaType aType)
+	{
+	enum TEnumsNotIn91
+		{
+		EMediaRotatingMedia = EMediaNANDFlash + 1,
+		};
+	switch (aType)
+		{
+		CASE_LIT(EMediaNotPresent)
+		CASE_LIT(EMediaUnknown)
+		CASE_LIT(EMediaFloppy)
+		CASE_LIT(EMediaHardDisk)
+		CASE_LIT(EMediaCdRom)
+		CASE_LIT(EMediaRam)
+		CASE_LIT(EMediaFlash)
+		CASE_LIT(EMediaRom)
+		CASE_LIT(EMediaRemote)
+		CASE_LIT(EMediaNANDFlash)
+		CASE_LIT(EMediaRotatingMedia)
+		default:
+			{
+			_LIT(KUnknown, "?");
+			return &KUnknown;
+			}
+		}
+	}
+
+void CCmdLocalDrive::DoRunL()
+	{
+	if (iCmd == EList)
+		{
+		for (TInt i = 0; i < KMaxLocalDrives; i++)
+			{
+			if (iArguments.IsPresent(&iDriveNum) && i != iDriveNum) continue;
+			TInt err = OpenL(i, EFalse);
+			if (err == KErrNone)
+				{
+				CTextBuffer* buf = CTextBuffer::NewLC(256);
+				buf->AppendFormatL(_L("Found drive %d partitionType=0x%x mediatype=%S(%d) size="), i, iCaps.iPartitionType, MediaTypeDesc(iCaps.iType), iCaps.iType);
+				if (iSizesInBytes)
+					{
+					buf->AppendFormatL(_L("%Ld"), iCaps.iSize);
+					}
+				else
+					{
+					buf->AppendHumanReadableSizeL(iCaps.iSize, EUnaligned);
+					}
+				if (iCaps.iType == EMediaFlash)
+					{
+					// NOR flash
+					buf->AppendFormatL(_L(" eraseblocksize=%d"), iCaps.iEraseBlockSize);
+					}
+
+				buf->AppendL(_L("\r\n"));
+				buf->Write(Stdout());
+				CleanupStack::PopAndDestroy(buf);
+				}
+			iDrive.Close();
+			}
+		}
+	else if (iCmd == ERead)
+		{
+		if (!iArguments.IsPresent(&iDriveNum)) LeaveIfErr(KErrArgument, _L("Must supply <drive> argument for the read command"));
+		OpenL(iDriveNum, ETrue);
+		RFile file;
+		CleanupClosePushL(file);
+		const TInt KBufSize = 32*1024;
+		RBuf8 buf;
+		CleanupClosePushL(buf);
+		if (iFile.Length())
+			{
+			LeaveIfErr(file.Create(FsL(), iFile, EFileWrite), _L("Couldn't create file %S"), &iFile);
+			buf.CreateL(KBufSize);
+			}
+		else
+			{
+			LeaveIfErr(Stdout().SetMode(RIoReadWriteHandle::EBinary), _L("Unable to set stdout to binary mode"));
+			buf.CreateL(KBufSize*2);
+			}
+
+		TInt64 bytesRead = 0;
+		while (bytesRead < iCaps.iSize)
+			{
+			buf.Zero();
+			LeaveIfErr(iDrive.Read(bytesRead, KBufSize, buf), _L("Failed to read %Ld+%d bytes from partition"), bytesRead, KBufSize);
+			bytesRead += buf.Length();
+			if (file.SubSessionHandle())
+				{
+				LeaveIfErr(file.Write(buf), _L("Couldn't write %d bytes to file"), buf.Length());
+				}
+			else
+				{
+				Stdout().Write(buf.Expand());
+				}
+			}
+		CleanupStack::PopAndDestroy(2, &file); // buf, file
+		}
+	else if (iCmd == EWrite)
+		{
+		if (!iArguments.IsPresent(&iDriveNum)) LeaveIfErr(KErrArgument, _L("Must supply <drive> argument for the write command"));
+		if (!iOptions.IsPresent(&iFile)) LeaveIfErr(KErrArgument, _L("Must supply file name argument for the write command, using --file"));
+
+		OpenL(iDriveNum, ETrue);
+		RFile file;
+		CleanupClosePushL(file);
+		const TInt KBufSize = 32*1024;
+		RBuf8 buf;
+		CleanupClosePushL(buf);
+		LeaveIfErr(file.Open(FsL(), iFile, EFileRead), _L("Couldn't open file %S"), &iFile);
+		TInt fileSize;
+		LeaveIfErr(file.Size(fileSize), _L("Couldn't read file size"));
+		if (fileSize != iCaps.iSize) LeaveIfErr(KErrNotReady, _L("File size (%d) does not match partition size (%d)"), fileSize, (TInt)iCaps.iSize);
+
+		buf.CreateL(KBufSize);
+
+		TInt64 bytesRead = 0;
+		while (bytesRead < fileSize)
+			{
+			buf.Zero();
+			LeaveIfErr(file.Read(buf), _L("Failed to read file"));
+			LeaveIfErr(iDrive.Write(bytesRead, buf), _L("Couldn't write %d bytes to flash at partition offset %Ld"), buf.Length(), bytesRead);
+			bytesRead += buf.Length();
+			}
+		CleanupStack::PopAndDestroy(2, &file); // buf, file
+		}
+	else
+		{
+		LeaveIfErr(KErrArgument, _L("Unrecognised operation %d"), iCmd);
+		}
+	}
+
+TInt CCmdLocalDrive::OpenL(TInt aDrive, TBool aLeaveOnConnectErr)
+	{
+	if (aDrive >= KMaxLocalDrives) LeaveIfErr(KErrArgument, _L("drive number %d is outside of KMaxLocalDrives (%d)"), aDrive, KMaxLocalDrives);
+
+	TBool changed; // What is this for?
+	TInt err = iDrive.Connect(aDrive, changed);
+	if (err == KErrNone)
+		{
+		TPckg<TLocalDriveCapsV2> capsBuf(iCaps);
+		LeaveIfErr(iDrive.Caps(capsBuf), _L("Opened drive %d but couldn't read caps"), aDrive);
+		}
+	else if (aLeaveOnConnectErr)
+		{
+		LeaveIfErr(err, _L("Couldn't open drive %d"), aDrive);
+		}
+	return err;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/localdrive/localdrive.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// localdrive.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			localdrive.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_LOCALDRIVE
+capability		All
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			localdrive.cpp
+
+library			euser.lib
+library			iocli.lib
+library			efsrv.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memsampler/memsampler.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,84 @@
+# memsampler.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name memsampler
+
+==short-description
+
+Gather statistics about memory usage.
+
+==long-description
+
+A tool that (by default) presents a live view of system memory usage. Memory usage is sampled using a device driver and presented in the form of a table. The order of the table can be changed using the following keys:
+
+=over 5
+
+=item C<u>
+
+Display the most recently updated chunks first.
+
+=item C<n>
+
+Sort by chunk name.
+
+=item C<c>
+
+Sort by current chunk size.
+
+=item C<m>
+
+Sort by maximum chunk size.
+
+=item C<p>
+
+Sort by peak chunk size.
+
+=back
+
+If the same sort order key is pressed more than once, the direction of the sort is toggled. The tool can be exited cleanly by pressing C<q>. If you're using the C<rcons> remote console implementation, it is recommented that you run C<memsampler> in a larger than default window. For example:
+
+  c:\>memsampler --console rcons.dll --console-size 100,60
+
+Note, if the raw data is capture to a file (using the C<--file> option) this data can be converted into comma separated value data (suitable for importing into a spreadsheet) using the tool F<\epoc32\tools\dmemsampler>.
+
+==see-also
+
+L<meminfo>
+
+==option uint r rate
+
+The rate at which to sample memory usage (in milliseconds). Defaults to 1000 ms (1 second).
+
+==option bool n no-btrace-config
+
+Don't attempt to configure the BTrace buffer before running the memory sampler. If this option is not specified then BTrace will be configured to only contain traces relating to memory sampling.
+
+==option bool d debug
+
+Enable debug output to the underlying console. It only makes sense to use this option if you redirect the main console to a separate window by adding something like C<--console rcons.dll> to your command line.
+
+==option bool H human
+
+Display sizes in human readable form.
+
+==option filename f file
+
+Capture raw btrace data to the specified file.
+
+==option bool l no-live-view
+
+Don't display a live view of memory usage. Only sensible in conjunction with C<--file> or C<--dedbug>.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memsampler/memsampler.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1021 @@
+// memsampler.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#include <e32cons.h>
+#include FSHELL_D32BTRACE_HEADER
+#include "memsamplerdd.h"
+
+_LIT(KLdd, "memsamplerdd");	
+const TInt KMaxCategories = 256;
+const TInt KBtraceBufferSize = 64 * 1024;
+
+using namespace IoUtils;
+
+
+class TChunkInfo
+	{
+public:
+	TChunkInfo(TUint32 aAddress);
+	TChunkInfo(const TDesC& aName, TUint32 aAddress, TInt aMaxSize);
+	static TBool Match(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByUpdateHistoryAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByUpdateHistoryDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByNameAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByNameDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByMaxSizeAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByMaxSizeDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByCurrentSizeAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByCurrentSizeDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByHighWaterMarkAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+	static TInt SortByHighWaterMarkDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB);
+public:
+	TInt iUpdateCount;
+	TFullName iName;
+	TUint32 iAddress;
+	TInt iMaxSize;
+	TInt iCurrentSize;
+	TInt iHighWaterMark;
+	};
+
+TChunkInfo::TChunkInfo(TUint32 aAddress)
+	: iUpdateCount(0), iAddress(aAddress), iMaxSize(0), iCurrentSize(0), iHighWaterMark(0)
+	{
+	}
+
+TChunkInfo::TChunkInfo(const TDesC& aName, TUint32 aAddress, TInt aMaxSize)
+	: iUpdateCount(0), iName(aName), iAddress(aAddress), iMaxSize(aMaxSize), iCurrentSize(0), iHighWaterMark(0)
+	{
+	}
+
+TBool TChunkInfo::Match(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iAddress == aChunkInfoB.iAddress);
+	}
+
+TInt TChunkInfo::SortByUpdateHistoryAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iUpdateCount > aChunkInfoB.iUpdateCount);
+	}
+
+TInt TChunkInfo::SortByUpdateHistoryDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iUpdateCount < aChunkInfoB.iUpdateCount);
+	}
+
+TInt TChunkInfo::SortByNameAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iName.CompareC(aChunkInfoB.iName));
+	}
+
+TInt TChunkInfo::SortByNameDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoB.iName.CompareC(aChunkInfoA.iName));
+	}
+
+TInt TChunkInfo::SortByMaxSizeAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iMaxSize > aChunkInfoB.iMaxSize);
+	}
+
+TInt TChunkInfo::SortByMaxSizeDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iMaxSize < aChunkInfoB.iMaxSize);
+	}
+
+TInt TChunkInfo::SortByCurrentSizeAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iCurrentSize > aChunkInfoB.iCurrentSize);
+	}
+
+TInt TChunkInfo::SortByCurrentSizeDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iCurrentSize < aChunkInfoB.iCurrentSize);
+	}
+
+TInt TChunkInfo::SortByHighWaterMarkAscending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iHighWaterMark > aChunkInfoB.iHighWaterMark);
+	}
+
+TInt TChunkInfo::SortByHighWaterMarkDescending(const TChunkInfo& aChunkInfoA, const TChunkInfo& aChunkInfoB)
+	{
+	return (aChunkInfoA.iHighWaterMark < aChunkInfoB.iHighWaterMark);
+	}
+
+
+class CMemoryView : public CBase
+	{
+public:
+	enum TSortType
+		{
+		ESortUnspecified,
+		ESortByChunkName,
+		ESortByCurrentSize,
+		ESortByHighWaterMark,
+		ESortByMaxSize,
+		ESortByUpdateHistory
+		};
+	enum TSortOrder
+		{
+		EAscending,
+		EDescending
+		};
+public:
+	static CMemoryView* NewL(RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, TBool aHuman);
+	~CMemoryView();
+	void ChangeSortType(TSortType aSortType);
+	void ChangeSortOrder(TSortOrder aSortOrder);
+	void ScrollUp();
+	void ScrollDown();
+	void ScrollLeft();
+	void ScrollRight();
+	void HandleNewChunk(const TDesC& aName, TUint32 aAddress, TInt aMaxSize);
+	void HandleChangedChunk(TUint32 aAddress, TInt aSize, TInt aHighWaterMark);
+	void HandleDeletedChunk(TUint32 aAddress);
+	void UpdateL();
+private:
+	CMemoryView(RIoWriteHandle& aStderr, TBool aHuman);
+	void ConstructL(RIoWriteHandle& aStdout);
+	void Sort();
+	void PrintWarning(TRefByValue<const TDesC> aFmt, ...);
+private:
+	RIoWriteHandle& iStderr;
+	TBool iHuman;
+	RIoConsoleWriteHandle iStdout;
+	TInt iNumConsoleLines;
+	TInt iNumLinesInLastUpdate;
+	RArray<TChunkInfo> iChunkList;
+	CTextBuffer* iBuffer;
+	CTextFormatter* iFormatter;
+	TSortOrder iSortOrder;
+	TLinearOrder<TChunkInfo> iSortByUpdateHistoryAscending;
+	TLinearOrder<TChunkInfo> iSortByUpdateHistoryDescending;
+	TLinearOrder<TChunkInfo> iSortByChunkNameAscending;
+	TLinearOrder<TChunkInfo> iSortByChunkNameDescending;
+	TLinearOrder<TChunkInfo> iSortByCurrentSizeAscending;
+	TLinearOrder<TChunkInfo> iSortByCurrentSizeDescending;
+	TLinearOrder<TChunkInfo> iSortByHighWaterMarkAscending;
+	TLinearOrder<TChunkInfo> iSortByHighWaterMarkDescending;
+	TLinearOrder<TChunkInfo> iSortByMaxSizeAscending;
+	TLinearOrder<TChunkInfo> iSortByMaxSizeDescending;
+	TLinearOrder<TChunkInfo>* iCurrentSortType;
+	TInt iVerticalOffset;
+	TInt iHorizontalOffset;
+	};
+
+CMemoryView* CMemoryView::NewL(RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, TBool aHuman)
+	{
+	CMemoryView* self = new(ELeave) CMemoryView(aStderr, aHuman);
+	CleanupStack::PushL(self);
+	self->ConstructL(aStdout);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CMemoryView::~CMemoryView()
+	{
+	delete iBuffer;
+	delete iFormatter;
+	iChunkList.Close();
+	}
+
+void CMemoryView::ChangeSortType(TSortType aSortType)
+	{
+	switch (aSortType)
+		{
+		default:
+		case ESortByChunkName:
+			{
+			if (iCurrentSortType == &iSortByChunkNameAscending)
+				{
+				iCurrentSortType = &iSortByChunkNameDescending;
+				}
+			else if (iCurrentSortType == &iSortByChunkNameDescending)
+				{
+				iCurrentSortType = &iSortByChunkNameAscending;
+				}
+			else
+				{
+				iCurrentSortType = &iSortByChunkNameAscending;
+				}
+			break;
+			}
+		case ESortByCurrentSize:
+			{
+			if (iCurrentSortType == &iSortByCurrentSizeAscending)
+				{
+				iCurrentSortType = &iSortByCurrentSizeDescending;
+				}
+			else if (iCurrentSortType == &iSortByCurrentSizeDescending)
+				{
+				iCurrentSortType = &iSortByCurrentSizeAscending;
+				}
+			else
+				{
+				iCurrentSortType = &iSortByCurrentSizeDescending;
+				}
+			break;
+			}
+		case ESortByHighWaterMark:
+			{
+			if (iCurrentSortType == &iSortByHighWaterMarkAscending)
+				{
+				iCurrentSortType = &iSortByHighWaterMarkDescending;
+				}
+			else if (iCurrentSortType == &iSortByHighWaterMarkDescending)
+				{
+				iCurrentSortType = &iSortByHighWaterMarkAscending;
+				}
+			else
+				{
+				iCurrentSortType = &iSortByHighWaterMarkDescending;
+				}
+			break;
+			}
+		case ESortByMaxSize:
+			{
+			if (iCurrentSortType == &iSortByMaxSizeAscending)
+				{
+				iCurrentSortType = &iSortByMaxSizeDescending;
+				}
+			else if (iCurrentSortType == &iSortByMaxSizeDescending)
+				{
+				iCurrentSortType = &iSortByMaxSizeAscending;
+				}
+			else
+				{
+				iCurrentSortType = &iSortByMaxSizeDescending;
+				}
+			break;
+			}
+		case ESortByUpdateHistory:
+			{
+			if (iCurrentSortType == &iSortByUpdateHistoryAscending)
+				{
+				iCurrentSortType = &iSortByUpdateHistoryDescending;
+				}
+			else if (iCurrentSortType == &iSortByUpdateHistoryDescending)
+				{
+				iCurrentSortType = &iSortByUpdateHistoryAscending;
+				}
+			else
+				{
+				iCurrentSortType = &iSortByUpdateHistoryAscending;
+				}
+			break;
+			}
+		}
+	Sort();
+	}
+
+void CMemoryView::ChangeSortOrder(TSortOrder aSortOrder)
+	{
+	iSortOrder = aSortOrder;
+	}
+
+void CMemoryView::ScrollUp()
+	{
+	if (iChunkList.Count() > iNumConsoleLines)
+		{
+		if (iVerticalOffset > 0)
+			{
+			// Not yet reached the top.
+			--iVerticalOffset;
+			}
+		}
+	}
+
+void CMemoryView::ScrollDown()
+	{
+	const TInt numChunks = iChunkList.Count();
+	if (numChunks > iNumConsoleLines)
+		{
+		if ((numChunks - iVerticalOffset) > iNumConsoleLines)
+			{
+			// Not yet reached the bottom.
+			++iVerticalOffset;
+			}
+		}
+	}
+
+void CMemoryView::ScrollLeft()
+	{
+	if (iHorizontalOffset > 0)
+		{
+		--iHorizontalOffset;
+		}
+	}
+
+void CMemoryView::ScrollRight()
+	{
+	// Allow the horizontal offset to increase unboundedly here - it'll be limited to something sensible in UpdateL.
+	++iHorizontalOffset;
+	}
+
+void CMemoryView::HandleNewChunk(const TDesC& aName, TUint32 aAddress, TInt aMaxSize)
+	{
+	// Age all the existing chunk's update counts by one.
+	const TInt numChunks = iChunkList.Count();
+	for (TInt i = 0; i < numChunks; ++i)
+		{
+		++iChunkList[i].iUpdateCount;
+		}
+
+	// Insert the new chunk (claiming update count zero).
+	TChunkInfo newChunkInfo(aName, aAddress, aMaxSize);
+	TInt err = iChunkList.InsertInOrderAllowRepeats(newChunkInfo, *iCurrentSortType);
+	if (err)
+		{
+		PrintWarning(_L("Couldn't handle new chunk: %d"), err);
+		}
+	}
+
+void CMemoryView::HandleChangedChunk(TUint32 aAddress, TInt aSize, TInt aHighWaterMark)
+	{
+	TChunkInfo chunkInfo(aAddress);
+	TInt pos = iChunkList.Find(chunkInfo, TChunkInfo::Match);
+	if (pos < 0)
+		{
+		PrintWarning(_L("Couldn't handle updated to chunk 0x%08x: %d"), aAddress, pos);
+		}
+	else
+		{
+		TChunkInfo& c = iChunkList[pos];
+		// Age all the chunks that have been updated more recently than this one.
+		const TInt numChunks = iChunkList.Count();
+		for (TInt i = 0; i < numChunks; ++i)
+			{
+			TChunkInfo& d = iChunkList[i];
+			if (d.iUpdateCount < c.iUpdateCount)
+				{
+				++d.iUpdateCount;
+				}
+			}
+
+		c.iUpdateCount = 0;
+		c.iCurrentSize = aSize;
+		c.iHighWaterMark = aHighWaterMark;
+		Sort();
+		}
+	}
+
+void CMemoryView::HandleDeletedChunk(TUint32 aAddress)
+	{
+	TChunkInfo chunkInfo(aAddress);
+	TInt pos = iChunkList.Find(chunkInfo, TChunkInfo::Match);
+	if (pos < 0)
+		{
+		PrintWarning(_L("Couldn't handle deletion of chunk 0x%08x: %d"), aAddress, pos);
+		}
+	else
+		{
+		TChunkInfo& c = iChunkList[pos];
+
+		// Rejuvenate chunks that haven't been updated since this one last was.
+		const TInt numChunks = iChunkList.Count();
+		for (TInt i = 0; i < numChunks; ++i)
+			{
+			TChunkInfo& d = iChunkList[i];
+			if (d.iUpdateCount > c.iUpdateCount)
+				{
+				--d.iUpdateCount;
+				}
+			}
+		
+		iChunkList.Remove(pos);
+		if (iChunkList.Count() <= iNumConsoleLines)
+			{
+			iVerticalOffset = 0;
+			}
+		}
+	}
+
+CMemoryView::CMemoryView(RIoWriteHandle& aStderr, TBool aHuman)
+	: iStderr(aStderr),
+	iHuman(aHuman),
+	iSortByUpdateHistoryAscending(TChunkInfo::SortByUpdateHistoryAscending),
+	iSortByUpdateHistoryDescending(TChunkInfo::SortByUpdateHistoryDescending),
+	iSortByChunkNameAscending(TChunkInfo::SortByNameAscending),
+	iSortByChunkNameDescending(TChunkInfo::SortByNameDescending),
+	iSortByCurrentSizeAscending(TChunkInfo::SortByCurrentSizeAscending),
+	iSortByCurrentSizeDescending(TChunkInfo::SortByCurrentSizeDescending),
+	iSortByHighWaterMarkAscending(TChunkInfo::SortByHighWaterMarkAscending),
+	iSortByHighWaterMarkDescending(TChunkInfo::SortByHighWaterMarkDescending),
+	iSortByMaxSizeAscending(TChunkInfo::SortByMaxSizeAscending),
+	iSortByMaxSizeDescending(TChunkInfo::SortByMaxSizeDescending),
+	iCurrentSortType(&iSortByUpdateHistoryAscending)
+	{
+	}
+
+void CMemoryView::ConstructL(RIoWriteHandle& aStdout)
+	{
+	if (aStdout.AttachedToConsole())
+		{
+		iStdout = aStdout;
+		TSize size;
+		User::LeaveIfError(iStdout.GetScreenSize(size));
+		iNumConsoleLines = size.iHeight;
+		iBuffer = CTextBuffer::NewL(0x100);
+		iFormatter = CTextFormatter::NewL(size.iWidth);
+		iStdout.SetCursorHeight(0);
+		iStdout.ClearScreen();
+		}
+	else
+		{
+		PrintWarning(_L("memsampler can't run unless it is attached directly to a console, aborting..."));
+		User::Leave(KErrArgument);
+		}
+
+	}
+
+void CMemoryView::Sort()
+	{
+	iChunkList.Sort(*iCurrentSortType);
+	}
+
+void CMemoryView::UpdateL()
+	{
+	iBuffer->Zero();
+	iFormatter->Zero();
+	const TInt numChunks = iChunkList.Count();
+	iBuffer->AppendL(_L("Chunk name\t   Current\t       Max\t      Peak\r\n"));
+	TInt numLines = 1;
+	for (TInt i = iVerticalOffset; i < numChunks; ++i)
+		{
+		++numLines;
+		const TChunkInfo& chunkInfo = iChunkList[i];
+		if (iHuman)
+			{
+			if (iHorizontalOffset >= chunkInfo.iName.Length())
+				{
+				// The horizontal offset is larger than this chunk name - reduce it to stop the chunk name column disappearing altogether.
+				// Note, ideally it would be nice to limit horizontal scrolling when the right most part of all the chunk names is visible.
+				// However, that would involve calculating all the column widths twice which seems a bit clumsy.
+				iHorizontalOffset = chunkInfo.iName.Length() - 1;
+				}
+			TPtrC name(chunkInfo.iName.Mid(iHorizontalOffset));
+			iBuffer->AppendFormatL(_L("%S\t"), &name);
+			iBuffer->AppendHumanReadableSizeL(chunkInfo.iCurrentSize, EColumnAlignedRight);
+			iBuffer->AppendL(_L("\t"));
+			iBuffer->AppendHumanReadableSizeL(chunkInfo.iMaxSize, EColumnAlignedRight);
+			iBuffer->AppendL(_L("\t"));
+			iBuffer->AppendHumanReadableSizeL(chunkInfo.iHighWaterMark, EColumnAlignedRight);
+			iBuffer->AppendL(_L("\r\n"));
+			}
+		else
+			{
+			iBuffer->AppendFormatL(_L("%S\t%d\t%d\t%d\r\n"), &chunkInfo.iName, chunkInfo.iCurrentSize, chunkInfo.iMaxSize, chunkInfo.iHighWaterMark);
+			}
+		if (numLines >= (iNumConsoleLines - 1))
+			{
+			break;
+			}
+		}
+	iFormatter->TabulateL(0, 1, iBuffer->Descriptor(), ETruncateLongestColumn);
+	User::LeaveIfError(iStdout.SetCursorPosAbs(TPoint(0, 0)));
+	iStdout.Write(iFormatter->Descriptor());
+	TInt numOldLines = iNumLinesInLastUpdate - numLines;
+	while (numOldLines > 0)
+		{
+		iStdout.ClearToEndOfLine();
+		iStdout.SetCursorPosRel(TPoint(0, 1));
+		--numOldLines;
+		}
+	iNumLinesInLastUpdate = numLines;
+	}
+
+void CMemoryView::PrintWarning(TRefByValue<const TDesC> aFmt, ...)
+	{
+	TOverflowTruncate overflow;
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TBuf<0x100> buf(_L("Warning: "));
+	buf.AppendFormatList(aFmt, list, &overflow);
+	buf.AppendFormat(_L("\r\n"), &overflow);
+	iStderr.Write(buf);
+	}
+
+
+class CStdinReader : public CActive
+	{
+public:
+	static CStdinReader* NewL(RIoReadHandle& aStdin, CCommandBase& aCommand, CMemoryView* aMemoryView);
+	~CStdinReader();
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+private:
+	CStdinReader(RIoReadHandle& aStdin, CCommandBase& aCommand, CMemoryView* aMemoryView);
+	void QueueRead();
+private:
+	RIoConsoleReadHandle iStdin;
+	CCommandBase& iCommand;
+	CMemoryView* iMemoryView;
+	};
+
+CStdinReader* CStdinReader::NewL(RIoReadHandle& aStdin, CCommandBase& aCommand, CMemoryView* aMemoryView)
+	{
+	CStdinReader* self = new(ELeave) CStdinReader(aStdin, aCommand, aMemoryView);
+	self->QueueRead();
+	return self;
+	}
+
+CStdinReader::~CStdinReader()
+	{
+	Cancel();
+	}
+
+void CStdinReader::RunL()
+	{
+	if (iStatus.Int())
+		{
+		iCommand.Complete(iStatus.Int());
+		}
+	else
+		{
+		TBool noUpdate(EFalse);
+		CMemoryView::TSortType newSortType = CMemoryView::ESortUnspecified;
+		switch (iStdin.KeyCode())
+			{
+			case 'n':
+			case 'N':
+				{
+				newSortType = CMemoryView::ESortByChunkName;
+				break;
+				}
+			case 'c':
+			case 'C':
+				{
+				newSortType = CMemoryView::ESortByCurrentSize;
+				break;
+				}
+			case 'p':
+			case 'P':
+				{
+				newSortType = CMemoryView::ESortByHighWaterMark;
+				break;
+				}
+			case 'm':
+			case 'M':
+				{
+				newSortType = CMemoryView::ESortByMaxSize;
+				break;
+				}
+			case 'u':
+			case 'U':
+				{
+				newSortType = CMemoryView::ESortByUpdateHistory;
+				break;
+				}
+			case 'q':
+			case 'Q':
+				{
+				iCommand.Complete(KErrNone);
+				break;
+				}
+			case EKeyUpArrow:
+				{
+				if (iMemoryView)
+					{
+					iMemoryView->ScrollUp();
+					}
+				break;
+				}
+			case EKeyDownArrow:
+				{
+				if (iMemoryView)
+					{
+					iMemoryView->ScrollDown();
+					}
+				break;
+				}
+			case EKeyLeftArrow:
+				{
+				if (iMemoryView)
+					{
+					iMemoryView->ScrollLeft();
+					}
+				break;
+				}
+			case EKeyRightArrow:
+				{
+				if (iMemoryView)
+					{
+					iMemoryView->ScrollRight();
+					}
+				break;
+				}
+			default:
+				{
+				noUpdate = ETrue;
+				}
+			}
+
+		if ((newSortType != CMemoryView::ESortUnspecified) && iMemoryView)
+			{
+			iMemoryView->ChangeSortType(newSortType);
+			}
+
+		if (iMemoryView && !noUpdate)
+			{
+			iMemoryView->UpdateL();
+			}
+
+		QueueRead();
+		}
+	}
+
+void CStdinReader::DoCancel()
+	{
+	iStdin.WaitForKeyCancel();
+	}
+
+TInt CStdinReader::RunError(TInt aError)
+	{
+	iCommand.Complete(aError);
+	return KErrNone;
+	}
+
+CStdinReader::CStdinReader(RIoReadHandle& aStdin, CCommandBase& aCommand, CMemoryView* aMemoryView)
+	: CActive(CActive::EPriorityStandard), iCommand(aCommand), iMemoryView(aMemoryView)
+	{
+	iStdin = aStdin;
+	CActiveScheduler::Add(this);
+	}
+
+void CStdinReader::QueueRead()
+	{
+	iStdin.WaitForKey(iStatus);
+	SetActive();
+	}
+
+
+
+class TBtraceHeader
+	{
+public:
+	TUint8 iSize;
+	TUint8 iFlags;
+	TUint8 iCategory;
+	TUint8 iSubCategory;
+	};
+
+class CBtraceReader : public CActive
+	{
+public:
+	enum TMode
+		{
+		EConfigBtrace = 0x0001,
+		EDebug        = 0x0002
+		};
+public:
+	static CBtraceReader* NewL(TUint aMode, const TDesC& aFileName, CCommandBase& aCommand, CMemoryView* aMemoryView);
+	~CBtraceReader();
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+private:
+	CBtraceReader(const TDesC& aFileName, CCommandBase& aCommand, CMemoryView* aMemoryView);
+	void ConstructL(TUint aMode);
+	void QueueRead();
+	void DecodeFrame(const TBtraceHeader& aHeader, const TDesC8& aFrame, TUint32 aTickCount);
+	void Printf(TRefByValue<const TDesC> aFmt, ...);
+private:
+	const TDesC& iFileName;
+	CCommandBase& iCommand;
+	CMemoryView* iMemoryView;
+	RBTrace iBtrace;
+	CConsoleBase* iDebugConsole;
+	RFile iFile;
+	};
+
+CBtraceReader* CBtraceReader::NewL(TUint aMode, const TDesC& aFileName, CCommandBase& aCommand, CMemoryView* aMemoryView)
+	{
+	CBtraceReader* self = new(ELeave) CBtraceReader(aFileName, aCommand, aMemoryView);
+	CleanupStack::PushL(self);
+	self->ConstructL(aMode);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBtraceReader::~CBtraceReader()
+	{
+	Cancel();
+	iBtrace.Close();
+	iFile.Close();
+	delete iDebugConsole;
+	}
+
+void CBtraceReader::RunL()
+	{
+	QueueRead();
+	TUint8* data;
+	TInt size;
+	while ((size = iBtrace.GetData(data)) != 0)
+		{
+		if (iMemoryView || iDebugConsole)
+			{
+			// Only decode btrace frames if we're attached to a CMemoryView object or have a debug console.
+			TUint8* c = data;
+			TUint8* end = c + size;
+			do
+				{
+				TBtraceHeader* header = (TBtraceHeader*)c;
+				TUint8* d = c + sizeof(TBtraceHeader);
+				TUint32 tickCount = 0;
+				if (header->iFlags & BTrace::EMissingRecord)
+					{
+					User::Leave(KErrOverflow);
+					}
+				if (header->iFlags & BTrace::EHeader2Present)
+					{
+					d += 4;
+					}
+				if (header->iFlags & BTrace::ETimestampPresent)
+					{
+					tickCount = *((TUint32*)d);
+					d += 4;
+					}
+				if (header->iFlags & BTrace::ETimestamp2Present)
+					{
+					d += 4;
+					}
+				if (header->iFlags & BTrace::EContextIdPresent)
+					{
+					d += 4;
+					}
+				if (header->iFlags & BTrace::EPcPresent)
+					{
+					d += 4;
+					}
+				if (header->iFlags & BTrace::EExtraPresent)
+					{
+					d += 4;
+					}
+				TPtrC8 ptr(d, (c + header->iSize) - d);
+				DecodeFrame(*header, ptr, tickCount);
+				c += (header->iSize + 3) & ~3;
+				}
+				while (c < end);
+			}
+		if (iFileName.Length())
+			{
+			User::LeaveIfError(iFile.Write(TPtrC8(data, size)));
+			}
+		iBtrace.DataUsed();
+		}
+	if (iMemoryView)
+		{
+		iMemoryView->UpdateL();
+		}
+	}
+
+void CBtraceReader::DoCancel()
+	{
+	iBtrace.CancelRequestData();
+	}
+
+TInt CBtraceReader::RunError(TInt aError)
+	{
+	if (aError == KErrOverflow)
+		{
+		Printf(_L("Warning: BTrace buffer overflowed, aborting..."), aError);
+		iCommand.Complete(aError);
+		}
+	else if (aError)
+		{
+		Printf(_L("Warning: Could not update view (%d), aborting..."), aError);
+		iCommand.Complete(aError);
+		}
+	return KErrNone;
+	}
+
+CBtraceReader::CBtraceReader(const TDesC& aFileName, CCommandBase& aCommand, CMemoryView* aMemoryView)
+	: CActive(CActive::EPriorityStandard), iFileName(aFileName), iCommand(aCommand), iMemoryView(aMemoryView)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CBtraceReader::ConstructL(TUint aMode)
+	{
+	if (aMode & EDebug)
+		{
+		iDebugConsole = Console::NewL(_L("debug"), TSize(KConsFullScreen,KConsFullScreen));
+		}
+	User::LeaveIfError(iBtrace.Open());
+	if (aMode & EConfigBtrace)
+		{
+		User::LeaveIfError(iBtrace.ResizeBuffer(KBtraceBufferSize));
+		// Turn everything off.
+		for (TInt i = 0; i < KMaxCategories; ++i)
+			{
+			iBtrace.SetFilter(i, 0);
+			}
+		if (aMode & EDebug)
+			{
+			iBtrace.SetFilter(BTrace::EKernPrintf, 1);
+			}
+		iBtrace.SetFilter(RMemSampler::EBtraceCategory, 1);
+		User::LeaveIfError(iBtrace.SetFilter2((const TUint32*)NULL, 0));
+		iBtrace.SetMode(RBTrace::EEnable | RBTrace::EFreeRunning);
+		}
+	if (iFileName.Length())
+		{
+		User::LeaveIfError(iFile.Replace(iCommand.FsL(), iFileName, EFileWrite));
+		}
+	QueueRead();
+	}
+
+void CBtraceReader::QueueRead()
+	{
+	iBtrace.RequestData(iStatus, 0);
+	SetActive();
+	}
+
+void CBtraceReader::DecodeFrame(const TBtraceHeader& aHeader, const TDesC8& aFrame, TUint32)
+	{
+	if (aHeader.iCategory == BTrace::EKernPrintf)
+		{
+		TUint32 threadId = *(TUint32*)aFrame.Ptr();
+		TBuf<256> text;
+		text.Copy(aFrame.Mid(4));
+		if (iDebugConsole)
+			{
+			iDebugConsole->Printf(_L("Kern::Printf (0x%08x) \'%S\'\r\n"), &threadId, &text);
+			}
+		}
+	else if (aHeader.iCategory == RMemSampler::EBtraceCategory)
+		{
+		switch (aHeader.iSubCategory)
+			{
+			case RMemSampler::ENewChunk:
+				{
+				TUint32 address = *(TUint32*)aFrame.Ptr();
+				TInt maxSize = *((TUint32*)aFrame.Ptr() + 1);
+				TFullName fullName;
+				fullName.Copy(aFrame.Mid(8));
+				if (iDebugConsole)
+					{
+					iDebugConsole->Printf(_L("New chunk - %S\r\n\taddress: 0x%08x max size: %d\r\n"), &fullName, address, maxSize);
+					}
+				if (iMemoryView)
+					{
+					iMemoryView->HandleNewChunk(fullName, address, maxSize);
+					}
+				break;
+				}
+			case RMemSampler::EChangedChunk:
+				{
+				TUint32 address = *(TUint32*)aFrame.Ptr();
+				TUint32 size = *((TUint32*)aFrame.Ptr() + 1);
+				TUint32 highWaterMark = *((TUint32*)aFrame.Ptr() + 2);
+				if (iDebugConsole)
+					{
+					iDebugConsole->Printf(_L("Changed chunk - address: 0x%08x size: %d hwm: %d\r\n"), address, size, highWaterMark);
+					}
+				if (iMemoryView)
+					{
+					iMemoryView->HandleChangedChunk(address, size, highWaterMark);
+					}
+				break;
+				}
+			case RMemSampler::EDeletedChunk:
+				{
+				TUint32 address = *(TUint32*)aFrame.Ptr();
+				if (iDebugConsole)
+					{
+					iDebugConsole->Printf(_L("Deleted chunk - address: 0x%08x\r\n"), address);
+					}
+				if (iMemoryView)
+					{
+					iMemoryView->HandleDeletedChunk(address);
+					}
+				break;
+				}
+			}
+		}
+	}
+
+void CBtraceReader::Printf(TRefByValue<const TDesC> aFmt, ...)
+	{
+	TOverflowTruncate overflow;
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TBuf<0x100> buf;
+	buf.AppendFormatList(aFmt, list, &overflow);
+	iCommand.Stdout().Write(buf);
+	}
+
+
+class CCmdMemsampler : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdMemsampler();
+private:
+	CCmdMemsampler();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RMemSampler iMemSampler;
+	CMemoryView* iMemoryView;
+	CStdinReader* iStdinReader;
+	CBtraceReader* iBtraceReader;
+	TUint iRate;
+	TBool iNoBtraceConfig;
+	TBool iDebug;
+	TBool iHuman;
+	TFileName2 iFileName;
+	TBool iNoLiveView;
+	};
+
+
+CCommandBase* CCmdMemsampler::NewLC()
+	{
+	CCmdMemsampler* self = new(ELeave) CCmdMemsampler();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdMemsampler::~CCmdMemsampler()
+	{
+	iMemSampler.Close();
+	User::FreeLogicalDevice(KLdd);
+	delete iStdinReader;
+	delete iBtraceReader;
+	delete iMemoryView;
+	}
+
+CCmdMemsampler::CCmdMemsampler() : CCommandBase(EManualComplete), iRate(1000)
+	{
+	}
+
+const TDesC& CCmdMemsampler::Name() const
+	{
+	_LIT(KName, "memsampler");	
+	return KName;
+	}
+
+void CCmdMemsampler::DoRunL()
+	{
+	TUint mode = 0;
+	if (!iNoBtraceConfig)
+		{
+		mode |= CBtraceReader::EConfigBtrace;
+		}
+	if (iDebug)
+		{
+		mode |= CBtraceReader::EDebug;
+		}
+
+	if (!iNoLiveView)
+		{
+		iMemoryView = CMemoryView::NewL(Stdout(), Stderr(), iHuman);
+		}
+	iStdinReader = CStdinReader::NewL(Stdin(), *this, iMemoryView);
+	iBtraceReader = CBtraceReader::NewL(mode, iFileName, *this, iMemoryView);
+	User::LeaveIfError(User::LoadLogicalDevice(KLdd));
+	User::LeaveIfError(iMemSampler.Open());
+	iMemSampler.Start(iRate);
+	}
+
+void CCmdMemsampler::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptSampleRate, "rate");
+	aOptions.AppendUintL(iRate, KOptSampleRate);
+
+	_LIT(KOptNoBtraceConfig, "no-btrace-config");
+	aOptions.AppendBoolL(iNoBtraceConfig, KOptNoBtraceConfig);
+
+	_LIT(KOptDebug, "debug");
+	aOptions.AppendBoolL(iDebug, KOptDebug);
+
+	_LIT(KOptHuman, "human");
+	aOptions.AppendBoolL(iHuman, KOptHuman);
+
+	_LIT(KOptFile, "file");
+	aOptions.AppendFileNameL(iFileName, KOptFile);
+
+	_LIT(KOptNoLiveView, "no-live-view");
+	aOptions.AppendBoolL(iNoLiveView, KOptNoLiveView);
+	}
+
+
+EXE_BOILER_PLATE(CCmdMemsampler)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memsampler/memsampler.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// memsampler.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          memsampler.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_MEMSAMPLER
+capability      ReadDeviceData WriteDeviceData
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          memsampler.cpp
+
+FSHELL_TRACE_CONTROL_LIBRARY
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memsampler/memsamplerdd.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,342 @@
+// memsamplerdd.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/extrabtrace.h>
+#include <platform.h>
+#include <kern_priv.h>
+#include "memsamplerdd.h"
+#include <fshell/common.mmh>
+
+const TInt KMinRate = 10;
+const TInt KMaxRate = 10000;
+const TInt KMajorVersionNumber = 1;
+const TInt KMinorVersionNumber = 0;
+const TInt KBuildVersionNumber = 0;
+const TInt KArrayGranularity = 32;
+const TInt KDfcThreadPriority = 26;
+_LIT(KDfcThreadName, "MemSamplerDD");
+
+class DDeviceMemSampler : public DLogicalDevice
+	{
+public:
+	DDeviceMemSampler();
+	virtual TInt Install();
+	virtual void GetCaps(TDes8& aDes) const;
+	virtual TInt Create(DLogicalChannelBase*& aChannel);
+	};
+
+class TChunkInfo
+	{
+public:
+	TChunkInfo(DChunk& aChunk);
+	TBool operator==(const TChunkInfo& aChunkInfo);
+public:
+	DChunk* iAddress;
+	TInt iSize;
+	TInt iHighWaterMark;
+	TBool iSeen;
+	};
+
+TChunkInfo::TChunkInfo(DChunk& aChunk)
+	: iAddress(&aChunk), iSize(aChunk.Size()), iHighWaterMark(aChunk.Size()), iSeen(ETrue)
+	{
+	}
+
+TBool TChunkInfo::operator==(const TChunkInfo& aChunkInfo)
+	{
+	return (iSize == aChunkInfo.iSize);
+	}
+
+class DMemSamplerChannel : public DLogicalChannel
+	{
+public:
+	DMemSamplerChannel();
+	~DMemSamplerChannel();
+protected:
+	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	virtual void HandleMsg(TMessageBase* aMsg);
+private:
+	TInt StartSampling(TInt aRate);
+	TInt StopSampling();
+	TInt ResetSampling();
+	TInt ReadChunks();
+	void TraceNewChunk(const TChunkInfo& aChunkInfo) const;
+	void TraceChangedChunk(const TChunkInfo& aChunkInfo) const;
+	void TraceDeletedChunk(const TChunkInfo& aChunkInfo) const;
+	void TraceNewSample() const;
+#if FSHELL_PLATFORM_SYMTB >= 92
+	inline TBool Running()
+		{return iTimer.IsPending();}
+#else
+	inline TBool Running()
+		{return iTimer.iState!=NTimer::EIdle;}
+#endif
+private:
+	static void Sample(TAny*);
+	static void DoSample(TAny*);
+	static void ExitDfcThread(TAny*);
+private:
+	RArray<TChunkInfo> iChunkInfo;
+	NTimer iTimer;
+	TInt iPeriod;
+	TInt iPeriodNumber;
+	TDfcQue iPrivateDfcQ;
+	TDfc iDoSampleDfc;
+	TDfc iExitDfc;
+	DThread* iClient;
+	mutable TBool iNewSampleTraced;
+	};
+
+DECLARE_STANDARD_LDD()
+	{
+	return new DDeviceMemSampler;
+	}
+
+DDeviceMemSampler::DDeviceMemSampler()
+	{
+	iVersion=TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
+	}
+
+TInt DDeviceMemSampler::Install()
+	{
+	TInt r = SetName(&KMemSamplerName);
+	return r;
+	}
+
+void DDeviceMemSampler::GetCaps(TDes8&) const
+	{
+	}
+
+TInt DDeviceMemSampler::Create(DLogicalChannelBase*& aChannel)
+	{
+	aChannel = new DMemSamplerChannel;
+	return aChannel ? KErrNone : KErrNoMemory;
+	}
+
+DMemSamplerChannel::DMemSamplerChannel()
+	: iChunkInfo(KArrayGranularity, _FOFF(TChunkInfo, iAddress)), iTimer(Sample, this), iPeriodNumber(-1), iDoSampleDfc(DoSample, this, 1), iExitDfc(ExitDfcThread, this, 0), iNewSampleTraced(EFalse)
+	{
+	}
+
+DMemSamplerChannel::~DMemSamplerChannel()
+	{
+	Kern::SafeClose((DObject*&)iClient, NULL);
+	iExitDfc.Enque(); 
+	}
+
+void DMemSamplerChannel::ExitDfcThread(TAny*)
+	{
+	Kern::Exit(KErrNone);
+	} 
+
+TInt DMemSamplerChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer)
+	{
+	if (!Kern::QueryVersionSupported(TVersion(1,0,0),aVer))
+		{
+		return KErrNotSupported;
+		}
+	iClient=&Kern::CurrentThread();
+	iClient->Open();
+	TInt err = Kern::DfcQInit(&iPrivateDfcQ, KDfcThreadPriority, &KDfcThreadName);
+	if (err == KErrNone)
+		{
+    	SetDfcQ(&iPrivateDfcQ);
+		iDoSampleDfc.SetDfcQ(&iPrivateDfcQ);
+		iExitDfc.SetDfcQ(&iPrivateDfcQ);
+    	iMsgQ.Receive();		
+		}
+	
+	return err;
+	}
+
+TInt DMemSamplerChannel::StartSampling(TInt aRate)
+	{
+	DEBUG_MEMSAMPLER(Kern::Printf("START");)
+	ReadChunks();
+	aRate = Min(KMaxRate, Max(KMinRate, aRate));
+	iPeriod = NKern::TimerTicks(aRate);
+	if (!Running())
+		{
+		iTimer.OneShot(iPeriod, EFalse);
+		}
+	DEBUG_MEMSAMPLER(Kern::Printf("START end");)
+	return KErrNone;
+	}
+
+TInt DMemSamplerChannel::StopSampling()
+	{
+	DEBUG_MEMSAMPLER(Kern::Printf("STOP");)
+	if (Running())
+		{
+		iTimer.Cancel();
+		}
+	DEBUG_MEMSAMPLER(Kern::Printf("STOP end");)
+	return KErrNone;
+	}
+
+TInt DMemSamplerChannel::ResetSampling()
+	{
+	DEBUG_MEMSAMPLER(Kern::Printf("RESET");)
+	iChunkInfo.Reset();
+	DEBUG_MEMSAMPLER(Kern::Printf("RESET end");)
+	return KErrNone;
+	}
+
+TInt DMemSamplerChannel::ReadChunks()
+	{
+	++iPeriodNumber;
+	iNewSampleTraced = EFalse;
+
+	for (TInt i = (iChunkInfo.Count() - 1); i >= 0; --i)
+		{
+		iChunkInfo[i].iSeen = EFalse;
+		}
+
+	DObjectCon* const * containers = Kern::Containers();
+	DObjectCon& container = *containers[EChunk];
+	container.Wait();
+
+	for (TInt i = (container.Count() - 1); i >= 0; --i)
+		{
+		TChunkInfo thisChunk(*(DChunk*)container[i]);
+		TInt pos;
+		TInt err = iChunkInfo.FindInUnsignedKeyOrder(thisChunk, pos);
+		if (err == KErrNotFound)
+			{
+			if (pos < iChunkInfo.Count())
+				{
+				iChunkInfo.Insert(thisChunk, pos);
+				}
+			else
+				{
+				TInt err = iChunkInfo.Append(thisChunk);
+				if (err)
+					{
+					container.Signal();
+					return err;
+					}
+				}
+			TraceNewChunk(thisChunk);
+			}
+		else
+			{
+			if (thisChunk == iChunkInfo[pos])
+				{
+				// Chunk size hasn't changed - ignore.
+				iChunkInfo[pos].iSeen = ETrue;
+				}
+			else
+				{
+				TChunkInfo& c = iChunkInfo[pos];
+				if (thisChunk.iSize > c.iHighWaterMark)
+					{
+					c.iHighWaterMark = thisChunk.iSize;
+					}
+				c.iSize = thisChunk.iSize;
+				c.iSeen = ETrue;
+				TraceChangedChunk(c);
+				}
+			}
+		}
+
+	container.Signal();
+
+	for (TInt i = (iChunkInfo.Count() - 1); i >= 0; --i)
+		{
+		const TChunkInfo& chunkInfo = iChunkInfo[i];
+		if (!chunkInfo.iSeen)
+			{
+			TraceDeletedChunk(chunkInfo);
+			iChunkInfo.Remove(i);
+			}
+		}
+
+	return KErrNone;
+	}
+
+void DMemSamplerChannel::TraceNewChunk(const TChunkInfo& aChunkInfo) const
+	{
+	TraceNewSample();
+	TFullName nameBuf;
+	aChunkInfo.iAddress->FullName(nameBuf);				
+	BTraceN(RMemSampler::EBtraceCategory, RMemSampler::ENewChunk, aChunkInfo.iAddress, aChunkInfo.iAddress->MaxSize(), nameBuf.Ptr(), nameBuf.Size());
+	TraceChangedChunk(aChunkInfo);
+	}
+
+void DMemSamplerChannel::TraceChangedChunk(const TChunkInfo& aChunkInfo) const
+	{
+	TraceNewSample();
+	BTraceContext12(RMemSampler::EBtraceCategory, RMemSampler::EChangedChunk, aChunkInfo.iAddress, aChunkInfo.iSize, aChunkInfo.iHighWaterMark);
+	}
+
+void DMemSamplerChannel::TraceDeletedChunk(const TChunkInfo& aChunkInfo) const
+	{
+	TraceNewSample();
+	BTraceContext4(RMemSampler::EBtraceCategory, RMemSampler::EDeletedChunk, aChunkInfo.iAddress);
+	}
+
+void DMemSamplerChannel::TraceNewSample() const
+	{
+	if (!iNewSampleTraced)
+		{
+		iNewSampleTraced = ETrue;
+		BTraceContext8(RMemSampler::EBtraceCategory, RMemSampler::ENewSample, iPeriod, iPeriodNumber);
+		}
+	}
+
+void DMemSamplerChannel::HandleMsg(TMessageBase* aMsg)
+	{
+	TInt r=KErrNone;
+	TThreadMessage& m=*(TThreadMessage*)aMsg;
+	TInt id=m.iValue;
+	if (id==(TInt)ECloseMsg)
+		{
+		DEBUG_MEMSAMPLER(Kern::Printf("CLOSE");)
+		iTimer.Cancel();
+		m.Complete(KErrNone,EFalse);
+		iMsgQ.CompleteAll(KErrServerTerminated);
+		DEBUG_MEMSAMPLER(Kern::Printf("CLOSE end");)
+		return;
+		}
+	else
+		{
+		switch(id)
+			{
+			case RMemSampler::EControlStartProfile:
+				r = StartSampling(m.Int0());
+				break;
+			case RMemSampler::EControlStopProfile:
+				r = StopSampling();
+				break;
+			case RMemSampler::EControlResetProfile:
+				r = ResetSampling();
+				break;
+			default:
+				r = KErrNotSupported;
+				break;
+			}
+		}
+	m.Complete(r,ETrue);
+	}
+
+void DMemSamplerChannel::Sample(TAny* aPtr)
+	{
+	DMemSamplerChannel& d = *(DMemSamplerChannel*)aPtr;
+	d.iTimer.Again(d.iPeriod);
+	d.iDoSampleDfc.Add(); 
+	}
+
+void DMemSamplerChannel::DoSample(TAny* aPtr)
+	{
+	DMemSamplerChannel& d = *(DMemSamplerChannel*)aPtr;
+	d.ReadChunks();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memsampler/memsamplerdd.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,84 @@
+// memsamplerdd.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __MEMSAMPLERDD_H__
+#define __MEMSAMPLERDD_H__
+
+#include <e32cmn.h>
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
+
+//Uncomment this line to generate debug logging of the profiler and sampler.
+#define DEBUG_MEMSAMPLER(f) f
+//#define DEBUG_MEMSAMPLER(f)
+
+
+/**
+ * The user device driver class for controlling the memory usage sampler.
+ */
+class RMemSampler : public RBusLogicalChannel
+	{
+public:
+	enum
+		{
+		EBtraceCategory = 253
+		};
+	enum
+		{
+		ENewChunk,
+		EChangedChunk,
+		EDeletedChunk,
+		ENewSample
+		};
+	friend class DMemSamplerChannel;
+private:
+	enum TControl
+		{
+		EControlStartProfile,
+		EControlStopProfile,
+		EControlResetProfile
+		};
+	enum TRequest
+		{
+		ERequestRead
+		};
+	static inline TInt CancelRequest(TRequest aRequest);
+public:
+#ifndef __KERNEL_MODE__
+	inline TInt Open();
+	inline void Start(TInt aRate);
+	inline void Stop();
+	inline void Reset();
+#endif
+	};
+
+_LIT(KMemSamplerName,"memsamplerdd");
+
+#ifndef __KERNEL_MODE__
+
+inline TInt RMemSampler::Open()
+	{return DoCreate(KMemSamplerName,TVersion(1,0,0),KNullUnit,NULL,NULL);}
+
+inline void RMemSampler::Start(TInt aRate)
+	{DoControl(EControlStartProfile, reinterpret_cast<TAny*>(aRate));}
+
+inline void RMemSampler::Stop()
+	{DoControl(EControlStopProfile);}
+
+inline void RMemSampler::Reset()
+	{DoControl(EControlResetProfile);}
+
+
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memsampler/memsamplerdd.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// memsamplerdd.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+FSHELL_TRACE_KERNEL_INCLUDE(..\..\..\)
+
+#include <kernel/kern_ext.mmh>
+
+target			memsamplerdd.ldd
+targettype		ldd
+linkas			memsamplerdd.ldd
+romtarget		memsamplerdd.ldd
+
+sourcepath		.
+source			memsamplerdd.cpp
+
+library			ekern.lib
+
+uid				0x100000af FSHELL_UID_MEMSAMPLERDD
+capability      all
+
+start wins
+win32_headers
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memspy/memspy.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+# memspy.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name memspy
+
+==short-description
+
+Command line interface for memspy debugging.
+
+==long-description
+
+==argument enum command
+
+Command to execute.
+
+==enum-value dump
+
+Executes a System Wide Memory Tracker (SYMT) dump.
+
+==enum-value start
+
+Start the System Wide Memory Tracker (SYMT) running. Config is set to dump to file, interval 30secs.
+
+==enum-value heapdump
+
+Save a heap dump. C<parameter> should specify a partial thread name.
+
+==enum-value celldump
+
+Dumps heap cells. C<parameter> should specify a partial thread name.
+
+==enum-value chunkinfo
+
+Dumps chunk info for a particular process. C<parameter> should be specify a partial process name.
+
+==argument string parameter optional
+
+Meaning depends on the operation. Only valid for heapdump operation.
+
+==copyright
+
+Copyright (c) 2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memspy/memspy.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,140 @@
+// memspy.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyenginehelpersysmemtracker.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
+#include <memspy/engine/memspyenginehelperheap.h>
+#include <memspy/engine/memspyenginehelperchunk.h>
+#include <memspy/engine/MemSpyEngineObjectContainer.h>
+
+using namespace IoUtils;
+
+class CCmdMemspy : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdMemspy();
+private:
+	CCmdMemspy();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TCmd
+		{
+		ESymtDump,
+		ESymtStart,
+		EHeapDump,
+		ECellDump,
+		EChunkInfo,
+		};
+	TCmd iCmd;
+	HBufC* iParameter;
+
+	CMemSpyEngine* iEngine;
+	};
+
+EXE_BOILER_PLATE(CCmdMemspy)
+
+CCommandBase* CCmdMemspy::NewLC()
+	{
+	CCmdMemspy* self = new(ELeave) CCmdMemspy();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdMemspy::~CCmdMemspy()
+	{
+	delete iEngine;
+	delete iParameter;
+	}
+
+CCmdMemspy::CCmdMemspy()
+	: CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdMemspy::Name() const
+	{
+	_LIT(KName, "memspy");	
+	return KName;
+	}
+
+void CCmdMemspy::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCmd, _L("command"));
+	aArguments.AppendStringL(iParameter, _L("parameter"));
+	}
+
+void CCmdMemspy::OptionsL(RCommandOptionList& /*aOptions*/)
+	{
+	}
+
+void CCmdMemspy::DoRunL()
+	{
+	TRAPL(iEngine = CMemSpyEngine::NewL(FsL()), _L("Couldn't construct CMemSpyEngine"));
+	iEngine->InstallSinkL(ESinkTypeFile);
+
+	//LtkUtils::BreakpointPushL();
+
+	TMemSpyEngineHelperSysMemTrackerConfig config;
+	config.iEnabledCategories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategorySystemMemory
+							  | TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap
+							  ;
+	config.iDumpData = EFalse;
+	TBool complete = ETrue;
+
+	if (iCmd == ESymtDump)
+		{
+		iEngine->HelperSysMemTracker().SetConfigL(config);
+        iEngine->HelperSysMemTracker().CheckForChangesNowL();
+		}
+	else if (iCmd == ESymtStart)
+		{
+		iEngine->HelperSysMemTracker().StartL(config);
+		complete = EFalse;
+		}
+	else if (iCmd == EHeapDump)
+		{
+		CMemSpyProcess* process = NULL;
+		CMemSpyThread* thread = NULL;
+		LeaveIfErr(iEngine->Container().ProcessAndThreadByPartialName(iParameter ? *iParameter : KNullDesC(), process, thread), _L("Couldn't find thread"));
+
+		iEngine->HelperHeap().OutputHeapDataUserL(*thread);
+		}
+	else if (iCmd == ECellDump)
+		{
+		CMemSpyProcess* process = NULL;
+		CMemSpyThread* thread = NULL;
+		LeaveIfErr(iEngine->Container().ProcessAndThreadByPartialName(iParameter ? *iParameter : KNullDesC(), process, thread), _L("Couldn't find thread"));
+
+		iEngine->HelperHeap().OutputCellListingUserL(*thread);
+		}
+	else if (iCmd == EChunkInfo)
+		{
+		CMemSpyProcess* process = NULL;
+		CMemSpyThread* thread = NULL;
+		LeaveIfErr(iEngine->Container().ProcessAndThreadByPartialName(iParameter ? *iParameter : KNullDesC(), process, thread), _L("Couldn't find process"));
+		iEngine->HelperChunk().OutputChunkInfoForProcessL(*process);
+		}
+
+	//CleanupStack::Pop();
+
+	if (complete) Complete();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/memspy/memspy.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// memspy.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			fshell_memspy.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_MEMSPY
+capability		none // memspyengine has no caps... stupid
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+sourcepath		.
+source			memspy.cpp
+
+library			euser.lib
+library			iocli.lib
+library			memspyengine.lib
+library			ltkutils.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/mrouter/mrouter.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+# mrouter.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name mrouter
+
+==short-description
+
+Provides information about any mRouter PC connection that is currently established.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/mrouter/mrouter.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,87 @@
+// mrouter.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <mrouterclient30.h>
+
+using namespace IoUtils;
+
+class CCmdMrouter : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdMrouter();
+private:
+	CCmdMrouter();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+private:
+	};
+
+
+CCommandBase* CCmdMrouter::NewLC()
+	{
+	CCmdMrouter* self = new(ELeave) CCmdMrouter();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdMrouter::~CCmdMrouter()
+	{
+	}
+
+CCmdMrouter::CCmdMrouter()
+	{
+	}
+
+const TDesC& CCmdMrouter::Name() const
+	{
+	_LIT(KName, "mrouter");	
+	return KName;
+	}
+
+#define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
+#define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
+	
+const TDesC* StringifyConnectionStatus(TmRouterProgressStatus aStatus)
+	{
+	switch (aStatus)
+		{
+		CASE_RETURN_LIT(EmRouterConnecting);
+		CASE_RETURN_LIT(EmRouterConnected);
+		CASE_RETURN_LIT(EmRouterDisconnected);
+		CASE_RETURN_LIT(EmRouterDisconnecting);
+		DEFAULT_RETURN_LIT("Unknown connection status");
+		}
+	}
+
+void CCmdMrouter::DoRunL()
+	{
+	RmRouterClient30 mRouter;
+	mRouter.OpenL();
+	CleanupClosePushL(mRouter);
+	TmRouterConnectionStatus connectionStatus;
+	mRouter.ConnectionStatus(connectionStatus);
+	TName connectionName;
+	mRouter.GetConnectionNameL(connectionName);
+	CleanupStack::PopAndDestroy(&mRouter);
+
+	Printf(_L("Connection status: %S\r\n"), StringifyConnectionStatus(connectionStatus.iStatus));
+	Printf(_L("Connection bearer:  0x%08x\r\n"), connectionStatus.iCurrentBearer.iUid);
+	Printf(_L("Connection name:   \"%S\"\r\n"), &connectionName);
+	}
+
+
+EXE_BOILER_PLATE(CCmdMrouter)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/mrouter/mrouter.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// mrouter.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          mrouter.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_MROUTER
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+systeminclude   \epoc32\include\connect
+
+sourcepath      .
+source          mrouter.cpp
+
+library         euser.lib
+library         iocli.lib
+library         mrouterclient30.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/nitz/nitz.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# nitz.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name nitz
+
+==short-description
+
+Fetch and display Network Information and Time Zone (NITZ) data.
+
+==option bool f follow
+
+Track NITZ updates as they are received by the phone and print details to STDOUT.
+
+==option string t tsy-name
+
+The name of the ETel server plug-in to use. If not specified the handset's default TSY is read from COMMSDAT.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/nitz/nitz.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,203 @@
+// nitz.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <etelmm.h>
+#include <commsdattypesv1_1.h>
+#include <cdblen.h>
+
+using namespace IoUtils;
+
+class CCmdNitz : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdNitz();
+private:
+	CCmdNitz();
+	void OpenPhoneL();
+	void PrintNitzData();
+	void QueueNotification();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	RTelServer iEtelServer;
+	RMobilePhone iPhone;
+	RMobilePhone::TMobilePhoneNITZ iNitzData;
+	TBool iFollow;
+	HBufC* iTsyName;
+	TBool iFirstPrint;
+	};
+
+
+CCommandBase* CCmdNitz::NewLC()
+	{
+	CCmdNitz* self = new(ELeave) CCmdNitz();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdNitz::~CCmdNitz()
+	{
+	delete iTsyName;
+	iPhone.Close();
+	iEtelServer.Close();
+	}
+
+CCmdNitz::CCmdNitz() : iFirstPrint(ETrue)
+	{
+	}
+
+const TDesC& CCmdNitz::Name() const
+	{
+	_LIT(KName, "nitz");	
+	return KName;
+	}
+
+void CCmdNitz::DoRunL()
+	{
+	OpenPhoneL();
+
+	TInt err = iPhone.GetNITZInfo(iNitzData);
+	if (err == KErrNone)
+		{
+		PrintNitzData();
+		}
+	else if (!iFollow)
+		{
+		LeaveIfErr(err, _L("Unable to get NITZ information"));
+		}
+	
+	if (iFollow)
+		{
+		QueueNotification();
+		}
+	}
+
+void CCmdNitz::RunL()
+	{
+	if (iStatus.Int() == KErrNone)
+		{
+		PrintNitzData();
+		QueueNotification();
+		}
+	else
+		{
+		Complete(iStatus.Int());
+		}
+	}
+
+void CCmdNitz::DoCancel()
+	{
+	}
+
+void CCmdNitz::OpenPhoneL()
+	{
+	if (iTsyName == NULL)
+		{
+		CommsDat::CMDBSession* db = CommsDat::CMDBSession::NewLC(KCDLatestVersion);
+		CommsDat::CMDBField<TUint32>* globalSettingField = new(ELeave) CommsDat::CMDBField<TUint32>(CommsDat::KCDTIdModemPhoneServicesSMS);
+		CleanupStack::PushL(globalSettingField);
+		globalSettingField->SetRecordId(1);
+		globalSettingField->LoadL(*db);
+		TUint32 modemId = *globalSettingField;
+		CommsDat::CMDBField<TDesC>* tsyField = new(ELeave) CommsDat::CMDBField<TDesC>(CommsDat::KCDTIdTsyName);
+		CleanupStack::PushL(tsyField);
+		tsyField->SetRecordId(modemId);
+		TRAPL(tsyField->LoadL(*db), _L("Unable to read default TSY name"));
+		TBuf<KCommsDbSvrMaxFieldLength> tsyName;
+		tsyName = *tsyField;
+		iTsyName = tsyName.AllocL();
+		CleanupStack::PopAndDestroy(3, db); // db, tsyField & globalSettingField
+		}
+	
+	LeaveIfErr(iEtelServer.Connect(), _L("Unable to connect to the ETel server"));
+	LeaveIfErr(iEtelServer.LoadPhoneModule(*iTsyName), _L("Unable to load TSY module \"%S\""), iTsyName);
+	TInt numPhones = 0;
+	LeaveIfErr(iEtelServer.EnumeratePhones(numPhones), _L("Couldn't enumerate phones"));
+	TBool matchFound(EFalse);
+	TInt phoneIndex;
+	for (phoneIndex = 0; phoneIndex < numPhones; ++phoneIndex)
+		{
+		TName thisTsyName;
+		if ((iEtelServer.GetTsyName(phoneIndex, thisTsyName) == KErrNone) && (iTsyName->CompareF(thisTsyName) == KErrNone))
+			{
+			matchFound = ETrue;
+			break;
+			}
+		}
+	if (!matchFound)
+		{
+		LeaveIfErr(KErrNotFound, _L("Couldn't find phone using TSY \"%S\""), iTsyName);
+		}
+	RTelServer::TPhoneInfo phoneInfo;
+	LeaveIfErr(iEtelServer.GetPhoneInfo(phoneIndex, phoneInfo), _L("Couldn't get phone info"));
+	LeaveIfErr(iPhone.Open(iEtelServer, phoneInfo.iName), _L("Couldn't open phone"));
+	}
+
+void CCmdNitz::PrintNitzData()
+	{
+	if (iFirstPrint)
+		{
+		iFirstPrint = EFalse;
+		}
+	else
+		{
+		Write(_L("\r\n"));
+		}
+
+	if (iNitzData.iNitzFieldsUsed & RMobilePhone::KCapsTimeAvailable)
+		{
+		Printf(_L("Universal time: %02d/%02d/%04d %02d:%02d:%02d.%d\r\n"), iNitzData.Day(), iNitzData.Month() + 1, iNitzData.Year(), iNitzData.Hour(), iNitzData.Minute(), iNitzData.Second(), iNitzData.MicroSecond());
+		}
+	if (iNitzData.iNitzFieldsUsed & RMobilePhone::KCapsTimezoneAvailable)
+		{
+		Printf(_L("Time zone: %d (+/- 15 minute offsets from GMT)\r\n"), iNitzData.iTimeZone);
+		}
+	if (iNitzData.iNitzFieldsUsed & RMobilePhone::KCapsDSTAvailable)
+		{
+		Printf(_L("Daylight saving adjustment: %d (hours)\r\n"), iNitzData.iDST);
+		}
+	if (iNitzData.iNitzFieldsUsed & RMobilePhone::KCapsShortNameAvailable)
+		{
+		Printf(_L("Short network name: \"%S\"\r\n"), &iNitzData.iShortNetworkId);
+		}
+	if (iNitzData.iNitzFieldsUsed & RMobilePhone::KCapsLongNameAvailable)
+		{
+		Printf(_L("Long network name: \"%S\"\r\n"), &iNitzData.iLongNetworkId);
+		}
+	}
+
+void CCmdNitz::QueueNotification()
+	{
+	iPhone.NotifyNITZInfoChange(iStatus, iNitzData);
+	SetActive();
+	}
+
+void CCmdNitz::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptFollow, "follow");
+	aOptions.AppendBoolL(iFollow, KOptFollow);
+
+	_LIT(KOptTsyName, "tsy-name");
+	aOptions.AppendStringL(iTsyName, KOptTsyName);
+	}
+
+
+EXE_BOILER_PLATE(CCmdNitz)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/nitz/nitz.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// nitz.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_nitz.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_NITZ
+capability	FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          nitz.cpp
+
+library         euser.lib
+library         iocli.lib
+library         etel.lib
+library         etelmm.lib
+library         commsdat.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/opendoc/opendoc.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# opendoc.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name opendoc
+
+==short-description
+
+Opens the specified document file by launching a suitable application.
+
+==long-description
+
+Uses the Symbian OS Application Architecure's file recognition framework to determine a suitable application.
+
+==argument filename file_name
+
+The name of the document file to be opened.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/opendoc/opendoc.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,60 @@
+// opendoc.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <apgcli.h>
+#include <apasvst.h>
+#include "opendoc.h"
+
+
+CCommandBase* CCmdOpenDoc::NewLC()
+	{
+	CCmdOpenDoc* self = new(ELeave) CCmdOpenDoc();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdOpenDoc::~CCmdOpenDoc()
+	{
+	}
+
+CCmdOpenDoc::CCmdOpenDoc()
+	{
+	}
+
+const TDesC& CCmdOpenDoc::Name() const
+	{
+	_LIT(KName, "opendoc");
+	return KName;
+	}
+
+void CCmdOpenDoc::DoRunL()
+	{
+	RApaLsSession lsSession;
+	LeaveIfErr(lsSession.Connect(), _L("Couldn't connect to AppArc"));
+	CleanupClosePushL(lsSession);
+	TThreadId threadId;
+	LeaveIfErr(lsSession.StartDocument(iFileName, threadId), _L("Couldn't open document"));
+	CleanupStack::PopAndDestroy(&lsSession);
+	}
+
+void CCmdOpenDoc::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFileName, "file_name");
+	aArguments.AppendFileNameL(iFileName, KArgFileName);
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdOpenDoc)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/opendoc/opendoc.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// opendoc.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+
+class CCmdOpenDoc : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdOpenDoc();
+private:
+	CCmdOpenDoc();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iFileName;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/opendoc/opendoc.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// opendoc.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          opendoc.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_OPENDOC
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          opendoc.cpp
+
+library         euser.lib
+library         iocli.lib
+library         apgrfx.lib
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/paste/paste.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+# paste.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name paste
+
+==short-description
+
+Pastes the text into the foreground application.
+
+==long-description
+
+Note, the clipboard contents will be overwritten when you run this command if you pass in text on the command line or via C<--stdin>.
+
+==see-also
+
+L<clipboard|clipboard>
+
+==argument string text optional last
+
+The text to be pasted. If not specified, pastes existing clipboard contents.
+
+==option bool s stdin
+
+Read text to paste from STDIN. The C<text> argument must not be specified when using this option.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/paste/paste.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,104 @@
+// paste.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/ltkutils.h>
+#include <e32keys.h>
+#include <txtetext.h>
+#include <baclipb.h>
+
+using namespace IoUtils;
+
+class CCmdPaste : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdPaste();
+private:
+	CCmdPaste();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	HBufC* iString;
+	TBool iStdin;
+	};
+
+
+CCommandBase* CCmdPaste::NewLC()
+	{
+	CCmdPaste* self = new(ELeave) CCmdPaste();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdPaste::~CCmdPaste()
+	{
+	delete iString;
+	}
+
+CCmdPaste::CCmdPaste()
+	{
+	}
+
+const TDesC& CCmdPaste::Name() const
+	{
+	_LIT(KName, "paste");	
+	return KName;
+	}
+
+void CCmdPaste::DoRunL()
+	{
+	if (iString && iStdin)
+		{
+		LeaveIfErr(KErrArgument, _L("Cannot read text from both command line and stdin."));
+		}
+
+	if (iString)
+		{
+		LtkUtils::CopyToClipboardL(*iString, &FsL());
+		}
+	else if (iStdin)
+		{
+		// Copy to clipboard from stdin
+		CTextBuffer* buffer = CTextBuffer::NewLC(0x100);
+		Stdin().SetReadMode(RIoReadHandle::EOneOrMore);
+		TBuf<0x100> buf;
+		while (Stdin().Read(buf) == KErrNone)
+			{
+			buffer->AppendL(buf);
+			}
+
+		LtkUtils::CopyToClipboardL(buffer->Descriptor(), &FsL());
+		CleanupStack::PopAndDestroy(buffer);
+		}
+
+	TInt err = LtkUtils::InjectRawKeyEvent('V', EModifierCtrl, 0); // Send a CTRL-V to the frontmost app.
+	LeaveIfErr(err, _L("Failed to inject ctrl-v event"));
+	}
+
+void CCmdPaste::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iString, _L("text"));
+	}
+
+void CCmdPaste::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iStdin, _L("stdin"));
+	}
+
+
+EXE_BOILER_PLATE(CCmdPaste)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/paste/paste.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// paste.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          paste.exe
+targettype      exe
+uid             0x102835BE FSHELL_UID_PASTE
+capability      swevent
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          paste.cpp
+
+library         euser.lib
+library         iocli.lib
+library         ltkutils.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/patchdata/patchdata.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,44 @@
+# patchdata.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name patchdata
+
+==argument string dll-name optional
+
+The DLL to examine for patchable data. If not specified, list some system-wide well-known patchable constants.
+
+==argument int ordinal optional
+
+The ordinal of the patchable constant to examine. This should be the number from the DEF file, ie it is one-based not zero-based. If not specified lists all the data exports in the DLL.
+
+==argument uint value optional
+
+Set a new value for the given ordinal. If not specified, just lists the current value.
+
+==option bool v verbose
+
+Display verbose information when scanning for exports.
+
+==short-description
+
+Examine the patchable data for a DLL.
+
+==long-description
+
+If no DLL is specified, print various common patchable constant data values. If a DLL is given but no ordinal number, all exports that look like patchable constants are listed. For DLLs in core (xip) ROM, you'll generally see more false positives than ROFS DLLs.
+
+Patchdata can optionally modify the value of a given patchable constant, but there are certain caveats in doing this: Overall the technique used is slightly hairy, use at your own risk: it will not work for DLLs with sparse export tables (generally this means DLLs with lots of exports and/or ABSENT exports); it may appear to work but in some situations code will continue to use the unpatched values (patching EXEXPs used in startup, ECOM plugins that have already been cached, and anything else that hard-codes loading DLLs from a particular drive). Patching a DLL that is in core (xip) image will only persist until the next reboot, but on the plus side most of the other caveats don't apply.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/patchdata/patchdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,395 @@
+// patchdata.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <f32image.h>
+#include "sf_deflate.h"
+#include <e32rom.h>
+#include <fshell/memoryaccesscmd.h>
+
+using namespace IoUtils;
+
+IMPORT_C extern const TInt KHeapMinCellSize;
+
+class CCmdPatchdata : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdPatchdata();
+private:
+	CCmdPatchdata();
+	void HandleXipL();
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	// The stuff from elsewhere
+	void LoadFileInflateL(E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 aRestOfFileSize);
+	void LoadFileNoCompressL(E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 aRestOfFileSize);
+	TInt LoadFile(TUint32 aCompression,E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 iRestOfFileSize);	
+
+private:
+	HBufC* iDll;
+	TInt iOrdinal;
+	TInt iNewValue;
+	TFileName iPath;
+	TFileName iNewPath;
+	RFile iFile;
+	TBool iVerbose;
+	};
+
+
+CCommandBase* CCmdPatchdata::NewLC()
+	{
+	CCmdPatchdata* self = new(ELeave) CCmdPatchdata();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdPatchdata::~CCmdPatchdata()
+	{
+	delete iDll;
+	iFile.Close();
+	}
+
+CCmdPatchdata::CCmdPatchdata()
+	{
+	}
+
+const TDesC& CCmdPatchdata::Name() const
+	{
+	_LIT(KName, "patchdata");	
+	return KName;
+	}
+
+void CCmdPatchdata::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iDll, _L("dll-name"));
+	aArguments.AppendIntL(iOrdinal, _L("ordinal"));
+	aArguments.AppendUintL((TUint&)iNewValue, _L("value"));
+	}
+
+void CCmdPatchdata::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	}
+
+EXE_BOILER_PLATE(CCmdPatchdata)
+
+void CCmdPatchdata::DoRunL()
+	{
+	if (!iDll)
+		{
+		// Just print some standard ones
+		Printf(_L("KHeapMinCellSize: %d\r\n"), KHeapMinCellSize);
+		return;
+		}
+
+	TBool scan = !iArguments.IsPresent(1);
+	TBool change = iArguments.IsPresent(2);
+
+	// First figure out where the dll is - easiest way is to load it
+#ifdef __WINS__
+	PrintWarning(_L("On WINS, exe-name must be a complete path to a E32 DLL"));
+	iPath = *iDll;
+#else
+	// Can't use RLibrary because we have all caps and the DLL won't
+	TFindFile find(FsL());
+	TInt found = find.FindByDir(*iDll, _L("Y:\\sys\\bin\\"));
+	LeaveIfErr(found, _L("Couldn't find DLL %S"), iDll);
+	iPath = find.File();
+
+	if (FsL().IsFileInRom(iPath) != NULL)
+		{
+		HandleXipL();
+		return;
+		}
+#endif
+
+	iNewPath = iPath;
+	TUint fileopenmode = EFileRead|EFileStream|EFileShareAny;
+
+	if (change) fileopenmode = EFileWrite|EFileStream|EFileShareAny;
+
+	if (change && iPath[0] != 'c')
+		{
+		// If file is already on c then we just patch in place
+
+		// We have a new value to set - so copy the DLL to C in preparation for patching it
+		iNewPath[0] = 'c';
+
+		//CleanupStack::PushL(TCleanupItem(&DeleteModifiedBinary, this));
+
+		TInt err = FsL().MkDirAll(iNewPath); // In case C:\sys\bin doesn't exist yet
+		if (err && err != KErrAlreadyExists)
+			{
+			PrintError(err, _L("Couldn't create C:\\sys\\bin"));
+			User::Leave(err);
+			}
+
+		CFileMan* fm = CFileMan::NewL(Fs());
+		CleanupStack::PushL(fm);
+
+		LeaveIfErr(fm->Copy(iPath, iNewPath), _L("Couldn't copy file from %S to %S"), &iPath, &iNewPath);
+		// Clear the read-only bit in the case where we've copied from ROM
+		LeaveIfErr(Fs().SetAtt(iNewPath, 0, KEntryAttReadOnly), _L("Couldn't unset read-only flag"));
+		CleanupStack::PopAndDestroy(fm);
+		}
+
+	// Now start fiddling
+	LeaveIfErr(iFile.Open(FsL(), iNewPath, fileopenmode), _L("Couldn't open file %S"), &iNewPath);
+
+	///// Begin code lifted from chkdeps
+	E32ImageHeaderV* imageHeader=new(ELeave)E32ImageHeaderV;
+	CleanupStack::PushL(imageHeader);
+	TPckg<E32ImageHeaderV> ptr(*imageHeader);
+	LeaveIfErr(iFile.Read(ptr, sizeof(E32ImageHeaderV)), _L("Couldn't read E32ImageHeader"));
+
+	if (!scan && (iOrdinal <= 0 || iOrdinal-1 >= imageHeader->iExportDirCount)) // -1 because ordinals are 1-based in DEF files
+		{
+		LeaveIfErr(KErrArgument, _L("ordinal out of range: only %d exports in file"), imageHeader->iExportDirCount);
+		}
+	if (imageHeader->HeaderFormat() >= KImageHdrFmt_V && imageHeader->iExportDescType != KImageHdr_ExpD_NoHoles)
+		{
+		LeaveIfErr(KErrNotSupported, _L("Don't understand files whose export table format isn't KImageHdr_ExpD_NoHoles (format is %d)"), imageHeader->iExportDescType);
+		}
+
+	TInt exportOffset = imageHeader->iExportDirOffset;
+
+	// Decompress rest of image
+	TUint32 compression = imageHeader->CompressionType();
+	TInt restOfFileSize=0;
+	TUint8* restOfFileData=NULL;
+	//detect the size of import information
+	if (compression != KFormatNotCompressed)
+		{
+		// Compressed executable
+		// iCodeOffset	= header size for format V or above
+		//				= sizeof(E32ImageHeader) for format J
+		restOfFileSize = imageHeader->UncompressedFileSize() - imageHeader->iCodeOffset;
+		}
+	else
+		{
+		TInt FileSize;
+		iFile.Size(FileSize); 		
+		restOfFileSize = FileSize-imageHeader->TotalSize();
+		}	
+	//restOfFileSize -= imageHeader->iCodeSize; // the size of the exe less header & code
+	
+	//allocate memory for rest of file
+	if (restOfFileSize >0)
+		{
+		restOfFileData = (TUint8*)User::AllocLC(restOfFileSize );		
+		}
+
+	LeaveIfErr(LoadFile(compression,imageHeader,restOfFileData,restOfFileSize), _L("Failed to load file data")); // Read import information in
+
+	///// End code lifted from chkdeps
+
+	const TInt headerSize = imageHeader->iCodeOffset;
+	exportOffset -= headerSize; // we are indexing into restoffile which doesn't have the header
+
+	TInt* exports = (TInt*)(restOfFileData + exportOffset);
+
+	if (scan)
+		{
+		//Printf(_L("TextSize = %d\r\n"), imageHeader->iTextSize);
+		//Printf(_L("CodeSize = %d\r\n"), imageHeader->iCodeSize);
+		//Printf(_L("dataoffset = %d\r\n"), imageHeader->iDataOffset);
+		//Printf(_L("importoffset= %d\r\n"), imageHeader->iImportOffset);
+		//Printf(_L("exportdiroffset= %d\r\n"), imageHeader->iExportDirOffset);
+		for (TInt i = 0; i < imageHeader->iExportDirCount; i++)
+			{
+			// No direct way of figuring out where code stops and const data starts. Export table sits between them though
+			// so use this to distiguish. (Don't know if my logic here is right but it seems to mainly work...)
+			TInt valoffset = exports[i] - imageHeader->iCodeBase;
+			if (iVerbose)
+				{
+				Printf(_L("export[%d] = %d\r\n"), i, valoffset + headerSize);
+				}
+			if (valoffset >= (TInt)imageHeader->iExportDirOffset-headerSize)
+				{
+				TInt val = *(TInt*)(restOfFileData + valoffset);
+				Printf(_L("Ordinal %d: 0x%08x (%d)\r\n"), i+1, val, val);
+				}
+			}
+		}
+	else
+		{
+		TInt valoffset = exports[iOrdinal-1] - imageHeader->iCodeBase; // Subtract one from ordinal as they're 1-based in DEF files
+		TInt& val = *(TInt*)(restOfFileData + valoffset);
+
+		if (change)
+			{
+			TInt oldVal = val;
+			val = iNewValue; // This updates restOfFileData
+			// Now write everything back to file. The data has to be written uncompressed as there is no compression
+			// code we can easily rip off. We have to update the header irrespective to increment the version
+ 			iFile.SetSize(headerSize);
+			
+			imageHeader->iCompressionType = KFormatNotCompressed;
+			// Update the version to sort out linking bug (probably not an issue for most uses of patchable data, but it could be in theory)
+			if ((imageHeader->iModuleVersion & 0x0000ffffu) == 0x0000ffffu)
+				{
+				// Don't update if version is XXXXffff as incrementing it would raise the major version - which is considered incompatible
+				PrintWarning(_L("Couldn't update DLL's minor version as it is already at its maximum value"));
+				}
+			else
+				{
+				imageHeader->iModuleVersion++;
+				}
+
+			// Update e32 checksum
+			imageHeader->iHeaderCrc = KImageCrcInitialiser;
+			TUint32 crc = 0;
+			Mem::Crc32(crc, imageHeader, imageHeader->TotalSize());
+			imageHeader->iHeaderCrc = crc;
+			LeaveIfErr(iFile.Write(0, ptr), _L("Couldn't write updated header back to file"));
+
+			TPtrC8 data(restOfFileData, restOfFileSize);
+			LeaveIfErr(iFile.Write(headerSize, data), _L("Couldn't write patched DLL code back to file"));
+
+			Printf(_L("Ordinal %d: old value was 0x%08x, new value is 0x%08x"), iOrdinal, oldVal, iNewValue);
+			}
+		else
+			{
+			Printf(_L("Ordinal %d: 0x%08x (%d)\r\n"), iOrdinal, val, val);
+			}
+		}
+
+	CleanupStack::PopAndDestroy(2, imageHeader); // imageHeader, restOfFileData
+	}
+
+void FileCleanup(TAny* aPtr)
+	{
+	TFileInput* f=(TFileInput*)aPtr;
+	f->Cancel();
+	delete f;
+	}
+
+void CCmdPatchdata::LoadFileInflateL(E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 aRestOfFileSize)
+	{
+	TInt pos = aHeader->TotalSize();
+	User::LeaveIfError(iFile.Seek(ESeekStart,pos)); // Start at beginning of compressed data
+
+	TFileInput* file = new (ELeave) TFileInput(iFile);
+	CleanupStack::PushL(TCleanupItem(&FileCleanup,file));
+	CInflater* inflater=CInflater::NewLC(*file);
+	
+	/*if (aHeader->iCodeSize)
+		{
+		TUint8* CodeData = (TUint8*)User::AllocLC(aHeader->iCodeSize );
+		TInt count=inflater->ReadL((TUint8*)CodeData ,aHeader->iCodeSize,&Mem::Move);
+		if(count!=aHeader->iCodeSize)
+			User::Leave(KErrCorrupt);
+		CleanupStack::PopAndDestroy(CodeData);
+		}*/
+	
+	if (aRestOfFileSize)
+		{
+		TUint32 count=inflater->ReadL(aRestOfFileData,aRestOfFileSize,&Mem::Move);
+		if(count!=aRestOfFileSize)
+			User::Leave(KErrCorrupt);
+		}
+	CleanupStack::PopAndDestroy(2,file);
+	}
+
+void CCmdPatchdata::LoadFileNoCompressL(E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 aRestOfFileSize)
+	{
+	TInt pos = (aHeader->TotalSize() /*+aHeader->iCodeSize*/);
+	if (aRestOfFileSize)
+		{
+		User::LeaveIfError(iFile.Seek(ESeekStart,pos));
+		TPtr8 ptrToData((TText8*)(aRestOfFileData),aRestOfFileSize,aRestOfFileSize);
+		User::LeaveIfError(iFile.Read(ptrToData, (TInt)aRestOfFileSize));	
+		}
+	}	
+//function loads file's import information calling decompression routine if needed
+TInt CCmdPatchdata::LoadFile(TUint32 aCompression,E32ImageHeaderComp* aHeader,TUint8* aRestOfFileData,TUint32 aRestOfFileSize)
+	{
+	TInt r=KErrNone;
+	if(aCompression==KFormatNotCompressed)
+		{
+		TRAP(r,LoadFileNoCompressL(aHeader,aRestOfFileData,aRestOfFileSize));		
+		}
+	else if(aCompression==KUidCompressionDeflate)
+		{
+		TRAP(r,LoadFileInflateL(aHeader,aRestOfFileData,aRestOfFileSize));
+		}
+	else
+		r=KErrNotSupported;
+
+	return r;
+	}
+
+void CCmdPatchdata::HandleXipL()
+	{
+	TBool scan = !iArguments.IsPresent(1);
+	TBool change = iArguments.IsPresent(2);
+	TRomImageHeader* imageHeader = (TRomImageHeader*)FsL().IsFileInRom(iPath);
+
+	if (!scan && (iOrdinal <= 0 || iOrdinal-1 >= imageHeader->iExportDirCount)) // -1 because ordinals are 1-based in DEF files
+		{
+		LeaveIfErr(KErrArgument, _L("ordinal out of range: only %d exports in file"), imageHeader->iExportDirCount);
+		}
+
+	TLinAddr* exports = (TLinAddr*)(imageHeader->iExportDir);
+
+	if (scan)
+		{
+		for (TInt i = 0; i < imageHeader->iExportDirCount; i++)
+			{
+			TLinAddr valAddr = exports[i];
+			if (iVerbose)
+				{
+				Printf(_L("export[%d] = 0x%08x\r\n"), i, valAddr);
+				}
+			valAddr &= ~3; // Clear thumb bit - code exports can have this set. No idea why some can have bit 1 set...
+			// There really doesn't seem to be a way to figure out where code stops and const data starts, for core images. It generally looks to come after the export dir but it gives false positives
+			if (valAddr > (TLinAddr)imageHeader)
+				{
+				TInt val = *(TInt*)valAddr;
+				Printf(_L("Ordinal %d: 0x%08x (%d)\r\n"), i+1, val, val);
+				}
+			}
+		}
+	else
+		{
+		TLinAddr valAddr = exports[iOrdinal-1]; // Subtract one from ordinal as they're 1-based in DEF files
+		TInt val = *(TInt*)(valAddr);
+
+		if (change)
+			{
+			TInt oldVal = val;
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+			LoadMemoryAccessL();
+			TPckg<TInt> valPkg(iNewValue);
+			LeaveIfErr(iMemAccess.WriteShadowMemory(valAddr, valPkg), _L("Couldn't write shadow for new value"));
+#else
+			LeaveIfErr(KErrNotSupported, _L("Can't update patchdata for DLLs in core image without memoryaccess support"));
+#endif
+
+
+			Printf(_L("Ordinal %d: old value was 0x%08x, new value is 0x%08x"), iOrdinal, oldVal, iNewValue);
+			}
+		else
+			{
+			Printf(_L("Ordinal %d: 0x%08x (%d)\r\n"), iOrdinal, val, val);
+			}
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/patchdata/patchdata.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// patchdata.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          patchdata.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_PATCHDATA
+
+capability      FSHELL_CAP_MMP_MAX
+
+userinclude     .
+userinclude		..\chkdeps
+#include <fshell/fsh_system_include.mmh>
+systeminclude   ..\chkdeps
+
+sourcepath      .
+source          patchdata.cpp
+
+sourcepath	..\chkdeps
+source		sf_inflate.cpp sf_decomp.cpp
+
+library         euser.lib
+library         iocli.lib
+library			efsrv.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ping/const.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// const.h - icmp echo client constants
+// This software has been implemented in the 6PACK
+// project at the Mobile Networks Laboratory (MNW)
+// http://www.research.nokia.com/projects/6pack/
+//
+
+#ifndef __CONST_H
+#define __CONST_H
+
+#define KHostNameLimit	80
+
+#define ICMP_ECHO_HEADER_SIZE   8       //Size of a ICMP header echo request/reply
+#define MAX_IP_PACKETLEN      65535		//Determined by the 16-bit field total length
+#define MAX_IP_HDRLEN      60			//Determined by the 4-bit field header length
+#define ICMP_HDRLEN      8				//Defined the HDR for a ECHO_REQUEST ICMP packet
+
+// Maximum ICMP Packet Data size
+#define MAX_ICMP_PACKETSIZE MAX_IP_PACKETLEN - MAX_IP_HDRLEN - ICMP_HDRLEN
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ping/in_icmp.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,72 @@
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+#ifndef __IN_ICMP_H__
+#define __IN_ICMP_H__
+
+#include "in_ip.h"
+
+class ThdrICMP_Echo
+{
+public:
+	inline static ThdrICMP_Echo* Ptr(ThdrICMP* aHdr);
+	inline TUint16 NetGetId();
+	inline void NetSetId(TUint16 aId);
+	inline TInt GetId();
+	inline void SetId(TUint16 aId);
+	inline TUint16 NetGetSeq();
+	inline void NetSetSeq(TUint16 aSeq);
+	inline TInt GetSeq();
+	inline void SetSeq(TUint16 aSeq);
+protected:
+	union
+		{
+		TUint8	iData8[8];
+		TUint16	iData16[4];
+		TUint32	iData32[2];
+		} u;
+};
+
+
+// specific for ECHO calls. (id and seq fields)
+//Net order
+inline TUint16 ThdrICMP_Echo::NetGetId()
+	{ return u.iData16[2]; }
+inline void ThdrICMP_Echo::NetSetId(TUint16 aId)
+	{ u.iData16[2] = aId; }
+//Host order
+inline TInt ThdrICMP_Echo::GetId()
+	{ 
+	return (u.iData8[4] << 8) + u.iData8[5];}
+inline void ThdrICMP_Echo::SetId(TUint16 aId)
+	{
+		u.iData8[4] = (TUint8)(aId >> 8);
+		u.iData8[5] = (TUint8)aId;
+	}
+//Net order
+inline TUint16 ThdrICMP_Echo::NetGetSeq()
+	{ return u.iData16[3]; }
+inline void ThdrICMP_Echo::NetSetSeq(TUint16 aSeq)
+	{ u.iData16[3] = aSeq; }
+//Host order
+inline TInt ThdrICMP_Echo::GetSeq()
+	{ return (u.iData8[6] << 8) + u.iData8[7];}
+inline void ThdrICMP_Echo::SetSeq(TUint16 aSeq)
+	{
+		u.iData8[6] = (TUint8)(aSeq >> 8);
+		u.iData8[7] = (TUint8)aSeq;
+	}
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ping/ping.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+# ping.cif
+# 
+# Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+==name ping
+
+==short-description
+
+Tests whether a network host is reachable.
+
+==see-also
+
+L<iap|iap>, L<rconn|rconn>
+
+==argument string address optional
+
+The IP address to ping. If not specified, C<127.0.0.1> will be used.
+
+==option int n num-packets
+
+The total number of packets to send (defaults to 5).
+
+==option int t time
+
+Time interval between packets in seconds (defaults to 1).
+
+==option int i iap
+
+The Internet Access Point to use. If not specified uses the system default.
+
+==copyright
+
+Copyright (c) 2009 - 2010 Accenture. All rights reserved.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ping/ping.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,160 @@
+// ping.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+using namespace IoUtils;
+
+#include "ping_misc.h"
+#include "pingmodel.h"
+
+
+
+class CCmdPing : public CCommandBase, public CPingContainer
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdPing();
+private:
+	CCmdPing();
+	void InitModelL();
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+
+public:
+	virtual void WriteHostL(TDes& aHostname);
+	virtual void UpdateStatisticsL();
+	virtual void WriteLine(const TDesC& abuf);
+	virtual void OnEnd();
+	
+private:
+	CActiveSchedulerWait* iActiveWait;
+	CPing *iPingModel;	//contains all Ping related Data
+	TInt iOptTotalPackets;		//total packets
+	TInt iOptSecInterval;		//interval between packets
+	TInt iIap;
+	HBufC* iAddress;
+	};
+
+CCommandBase* CCmdPing::NewLC()
+	{
+	CCmdPing* self = new(ELeave) CCmdPing();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdPing::CCmdPing()
+	{
+	iActiveWait = new (ELeave) CActiveSchedulerWait;
+	}
+
+
+CCmdPing::~CCmdPing()
+	{
+	delete iAddress;
+	delete iPingModel;
+	delete iActiveWait;
+	}
+
+void CCmdPing::WriteHostL(TDes& aHostname)
+	{
+	Printf(_L("Host: %S \r\n"), &(aHostname) );
+	}
+
+void CCmdPing::WriteLine(const TDesC& abuf)
+	{
+	Printf(_L("%S\r\n"), &(abuf) );
+	}
+
+void CCmdPing::UpdateStatisticsL()
+	{
+	}
+
+void CCmdPing::OnEnd()
+	{
+	TBool bWait = iActiveWait->IsStarted(); 
+	if (bWait)
+		iActiveWait->AsyncStop();
+	}
+
+const TDesC& CCmdPing::Name() const
+	{
+	_LIT(KName, "ping");
+	return KName;
+	}
+
+void CCmdPing::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iAddress, _L("address"));
+	}
+
+void CCmdPing::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendIntL(iOptTotalPackets, _L("num-packets"));
+	aOptions.AppendIntL(iOptSecInterval, _L("time"));
+#ifdef IAPSETTING
+	aOptions.AppendIntL(iIap, _L("iap"));
+#endif
+	}
+
+void CCmdPing::DoRunL()
+	{
+	InitModelL();
+		
+	iPingModel->SetConsole(this);
+	
+	//set host name, if it is specified
+	if (iAddress && iAddress->Length()>0 )
+		{
+		iPingModel->SetHostName(*iAddress);
+		}
+	
+	//start to ping
+    if (!(iPingModel->IsRunning()))
+    	{
+        iPingModel->BeginL();
+        TBool bPingIsRunning = iPingModel->IsRunning();
+        
+        if (bPingIsRunning)
+            iActiveWait->Start();
+        else
+	        LeaveIfErr(KErrGeneral, _L("Could not connect to socket server or connect to internet"));
+    	}
+	}
+
+void CCmdPing::InitModelL()
+	{
+	TPreferences param;
+	CPing::DefaultPreferences(param);
+    
+	if (iOptTotalPackets > 0)
+		param.iTotalPackets = iOptTotalPackets; 
+		
+	if (iOptSecInterval > 0)
+		param.iSecWait = iOptSecInterval; 
+
+#ifdef IAPSETTING
+	if (iIap > 0)
+		param.iIAP = iIap;
+#endif	
+
+	iPingModel= new (ELeave) CPing();
+	iPingModel->ConstructL(param);
+	}
+
+
+EXE_BOILER_PLATE(CCmdPing)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ping/ping.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// ping.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+target			fshell_ping.exe
+targettype		exe
+UID             FSHELL_UID2_FSHELL_EXE FSHELL_UID_PING
+
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	FSHELL_NETWORKING_SYSTEMINCLUDE
+
+sourcepath		.
+source			ping.cpp pingmodel.cpp
+
+library			euser.lib
+library			iocli.lib
+library			esock.lib insock.lib  commdb.lib
+
+//macro			IAPSETTING // I have no idea if this should be defined or not...
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ping/ping_misc.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+// ping_misc.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __PING_MISC_H
+#define __PING_MISC_H
+
+#define IPv4	0
+#define IPv6	1
+
+class CPing;
+
+//this class is used as pure interface,
+//should be named as M class by Symbian convention.
+//the class name is retained for the purpose of 
+//reference to original class name in pingapp.exe
+
+class CPingContainer
+{
+public:
+	//TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+	virtual void WriteHostL(TDes& aHostname) = 0;
+	virtual void UpdateStatisticsL() = 0;
+	virtual void WriteLine(const TDesC& abuf) = 0;
+	virtual void OnEnd() = 0; 
+	//void ResetScreen();
+
+//protected:
+	//void FocusChanged(TDrawNow aDrawNow);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ping/pingmodel.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1255 @@
+// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+// Accenture - minor mods to work as an fshell command and fixes to broken logic
+//
+// Description:
+// pingmodel.cpp - icmp echo client engine
+// This software has been implemented in the 6PACK
+// project at the Mobile Networks Laboratory (MNW)
+// http://www.research.nokia.com/projects/6pack/
+// REMARKS:
+// The application is prepared to admit the option Hop Limit and
+// Numeric output (no name resolution), but these options are not used
+// because the socket is open in ICMP mode.  To use them need an IP
+// socket and IP packets to set the options. Some code is commented and
+// can be used in case of need
+//
+
+
+
+#ifdef IAPSETTING
+#include <commdb.h>
+#endif
+
+#include <e32math.h>
+#include <e32std.h>
+//#include <eikenv.h>
+//#include <netdial.h>
+
+// IPv6 changes CPing::iType, ComposeFirstIcmpPacket()- ICMPType, Socket Open()
+
+#include "pingmodel.h"
+
+//#include <pingapp.rsg> //resource is not needed as console app
+
+#include "ping_misc.h"
+
+
+CPing::CPing():CActive(EPriorityStandard),iPacket(0,0),iReceivedData(0,0)
+{
+	CActiveScheduler::Add(this);	//Adds itself to the scheduler only the first time
+}
+
+
+
+//Sets all default values. Actually it's no more a L function
+void CPing::ConstructL(TPreferences aPref)
+{
+
+	// Base class second-phase construction.
+
+	//iHostname=_L("bart.research.nokia.com");	//default initial addr
+	//iHostname=_L("127.0.0.1");	//default initial addr
+	//iHostname=_L("dead::beef");	//default initial addr
+	iHostname=aPref.iHostname;
+	iPackLimit = aPref.iFlags & KPingPackLimit;		//Unlimited packets
+	iTotalPackets=aPref.iTotalPackets;	//Default packet number when limited number
+	
+	iSecWait=aPref.iSecWait;		//Default 1 second
+	iPacketDataSize=aPref.iPacketDataSize;	//Default Size
+	iQuiet=aPref.iFlags & KPingQuiet;	//No packet info, just statistics
+		
+	iVerbose=aPref.iFlags & KPingVerbose;	//Verbose Output. All ICMP packets, not only Echo reply. Default no
+	iPattern.Copy(aPref.iPattern);			//Pattern 0xFF (1-filled byte)
+	
+	iDebug=aPref.iFlags & KPingDebug;		//Set SO_DEBUG flag
+	iLastSecWait=aPref.iLastSecWait;	//Default time to wait for the last packet
+
+#ifdef IAPSETTING
+	iIAP = aPref.iIAP;		
+#endif
+
+	//Not used by now
+	iNumericOutput=EFalse;	//Resolve adresses by default
+	iHopLimit=0;			//Time-to-live in hops default 255 ( 1 to 255) (0 means not set)
+
+	iDupPackets=0;			//Duplicated packets
+	iRunning=EFalse;		// Tells if there's an Instance of Ping Running
+
+
+	
+/*
+	iReceivedDataBuffer= HBufC8::NewL(iPacketDataSize + ICMP_ECHO_HEADER_SIZE);	//Maximum size of a return packet
+	TPtr8 auxPtr(iReceivedDataBuffer->Des());	//must be used here because the buffer changes
+	iReceivedData.Set(auxPtr);			//we use an aux var because can't use Des() directly Why??
+*/
+}
+
+//return the current preferences
+void CPing::GetPreferences(TPreferences &aPref)
+{	
+	aPref.iFlags=0;
+	if (iQuiet)
+		aPref.iFlags|=KPingQuiet;
+	if (iVerbose)
+		aPref.iFlags|=KPingVerbose;
+	if (iPackLimit)
+		aPref.iFlags|=KPingPackLimit;
+	if (iDebug)
+		aPref.iFlags|=KPingDebug;
+
+	aPref.iSecWait=iSecWait;               //Time between sent packets (Default 1 second)
+	aPref.iPacketDataSize=iPacketDataSize;//Default Data Size (not including ICMP header)
+	aPref.iTotalPackets=iTotalPackets;  //Number of ICMP Echo Request packets to send
+	aPref.iLastSecWait=iLastSecWait;   //Time to wait for the Last packet. Default 2
+	aPref.iHostname=iHostname;		//Address to Ping
+	aPref.iPattern.Copy(iPattern);
+
+#ifdef IAPSETTING	
+	aPref.iIAP = iIAP;
+#endif
+		
+}
+
+void CPing::DefaultPreferences(TPreferences &aPref)
+{	
+	aPref.iFlags=KPingVerbose|KPingPackLimit;
+
+	aPref.iSecWait=1;               //Time between sent packets (Default 1 second)
+	aPref.iPacketDataSize=56;//Default Data Size (not including ICMP header)
+	aPref.iTotalPackets=5;  //Number of ICMP Echo Request packets to send
+	aPref.iLastSecWait=2;   //Time to wait for the Last packet. Default 2
+	aPref.iPattern=_L("FF");
+	aPref.iHostname=_L("127.0.0.1");
+#ifdef IAPSETTING
+	aPref.iIAP=1;
+#endif
+}
+
+void CPing::Statistics()
+{
+	//TBuf<300> aux(_L("==========================================\n"));
+	TBuf<300> aux(_L("\n"));
+	
+	TReal rLoss=iSentPackets-iRecvPackets-iChksumErrors;	// An error is a received but wrong packet
+										//is not masked as received because of time calculations
+	if (rLoss<0) 
+		rLoss=0;
+	TReal rSent=iSentPackets;
+	TReal r;
+	if (rSent>0)
+		r=rLoss/rSent;
+	else
+		r=0;
+
+	aux.AppendFormat(_L("Lost: %.1f%% Bad: %d"), r*100, iChksumErrors);
+
+	//If there's a timestamp and data received
+	if ((iRecvPackets>0) && (iPacketDataSize >= TIMESTAMP_SIZE))
+	{
+		r=(iTimeSum/iRecvPackets);	//average in ms
+		aux.AppendFormat(_L(" Max: %d Min: %d Avg: "),iMaxTime,iMinTime);
+		TRealFormat format;	//no decimals
+		format.iType|=KDoNotUseTriads;	// no thousands separatorlast
+		aux.AppendNum(r,format);
+		aux.Append(_L(" ms"));
+	}
+
+	if (iDupPackets>0)
+		aux.AppendFormat(_L(" Dup: %d"),iDupPackets);
+
+	//aux.Append(_L("\n==========================================\n"));
+	iConsole->WriteLine(aux);
+}
+
+// Use when data is not going to be displayed in Quiet mode
+void CPing::WriteLineIfNotQuiet(const TDesC& abuf)
+{
+	if (!iQuiet)
+		iConsole->WriteLine(abuf);
+}
+
+TDes* CPing::GetHostName()
+{
+	return &iHostname;
+}
+
+void CPing::SetHostName(const TDesC& ahostname)
+{
+	iHostname=ahostname;
+}
+
+void CPing::SetConsole(CPingContainer* aConsole)
+{
+	iConsole=aConsole;
+}
+
+CPing::~CPing()
+	{
+	Cancel();
+	delete iPacketData;		// If something leaves.
+	delete iReceivedDataBuffer;
+	CloseAll();
+	}
+
+//Shows the error and set the application as not running. 
+//Requires a return after calling it!
+void CPing::ErrorL(const TDesC& string,TInt error)
+{
+	
+	TBuf<150> aux;
+	TBuf<100> errtxt;
+
+	//CEikonEnv::Static()->GetErrorText( errtxt,error);
+	aux.Format(string);	
+	aux.Append(_L(": "));
+	aux.Append(errtxt);
+	aux.AppendFormat(_L(" (%d)\n"), error);
+	WriteLineIfNotQuiet(aux);
+	//iRunning=EFalse;
+
+	iSockErrors++;
+
+	if (error==KErrAbort)	//Critical Error
+	{
+
+/*		RNetDial xnetdial;
+		TBool active;
+
+		xnetdial.Open();
+		TInt err=xnetdial.NetworkActive(active);
+	
+		if (!active)
+		{
+			xnetdial.Start();
+			err=xnetdial.NetworkActive(active);
+		}
+*/
+		EndPingL();
+		User::Leave(0);	// NOT SURE IF IT'S THE BEST WAY!!!
+	}
+
+	if (iSockErrors>5)	//To avoid a chain of errors that blocks everything. Should never happen though 
+	{
+		EndPingL();
+		User::Leave(0);	// NOT SURE IF IT'S THE BEST WAY!!!
+	}
+	
+}
+
+
+// checksum of the ICMP packet (ICMP header + data)
+TUint16 CPing::in_chksum(TUint16* data, TUint len)
+{
+	
+	TUint16 *d=data;
+	TUint left=len;
+	TUint32 sum=0;
+	TUint16 aux=0;
+	
+	while (left > 1)
+	{
+		sum += *d++;
+		left -= 2;		//because adding 16 bits numbers (2 bytes)
+	}
+
+	if (left==1)	//If odd length
+	{
+		*(TUint8*) &aux = *(TUint8*) d;
+		sum += aux;
+	}
+	
+	sum = (sum >> 16) + (sum & 0x0ffff);
+	sum += (sum >> 16);
+	aux = (TUint16) ~sum;
+
+	return aux;
+	
+}
+
+// Clears a bit from the iDup table
+
+void CPing::CLR(TUint16 num)
+{
+	TInt num256 = num % 256;		//num modulus 256
+	TInt pos = num256 >> 5;		//Position of vector iDup
+	iDup[pos] &= ~((1 << num % 32 ));
+}
+
+// Sets a bit from the iDup table
+
+void CPing::SET(TUint16 num)
+{
+	TInt num256= num % 256;		//num modulus 256
+	TInt pos=num256 >> 5;		//Position of vector iDup
+	iDup[pos] |= (1 << num % 32 );
+}
+
+// Tests if the bit is set or not
+
+TBool CPing::TEST(TUint16 num)
+{
+	TUint num256= num % 256;		//num modulus 256
+	TInt pos=num256 >> 5;		//Position of vector iDup
+	return ((iDup[pos] & (1 << num % 32)) == (TUint32)(1 << num % 32));
+}
+
+//Generates a random number using iSeed
+TUint16 CPing::RandomNumber()
+{
+	if (iSeed==0)	//Initialize seed randomly with time
+	{
+		TTime time;
+        time.HomeTime();
+		iSeed=time.Int64();
+    }
+    return ((TUint16)Math::Rand(iSeed));	//Just take the lowest 16 bits)
+}
+
+// Composes the whole ICMP packet except time stamp and checksum
+
+void CPing::ComposeFirstICMPPacket()
+{
+	ThdrICMP *hdr;
+	TUint firstPos = 0;
+	
+	hdr = (ThdrICMP *)&iPacket[0];	// Can use this one for IPv6 because is the same format
+
+	if (iType == IPv4)
+		hdr->NetSetType(KICMPTypeEchoRequest);
+	else
+		hdr->NetSetType(KInet6ICMP_EchoRequest);
+
+	hdr->NetSetCode(KICMPCode);
+
+	iId = RandomNumber();
+	((ThdrICMP_Echo *)hdr)->NetSetId(iId);	
+	((ThdrICMP_Echo *)hdr)->NetSetSeq(0);
+	CLR(0);	// Clears the bit in the received/dup buffer
+	
+	// Jump over possible timestamp
+
+	if (iPacketDataSize >= TIMESTAMP_SIZE)
+	{
+		firstPos = TIMESTAMP_SIZE;
+	}
+
+	// The rest is filled with a pattern
+	// The last part of the packet may only be a part of the pattern
+
+	TInt i;
+	TInt j;
+
+	//First transform the pattern from text to Hexadecimal
+	TLex lex;
+	//TUint8 hex_num;
+	TBuf<2> hex_digit;
+	TBuf<2 * MAX_PATTERN_LENGTH> text_pattern;
+	TUint8 hex_pattern[MAX_PATTERN_LENGTH];
+	if (iPattern.Length() % 2 == 0)
+		text_pattern.Copy(iPattern);
+	else	//odd size so the pattern is doubled and we have a even size
+	{
+		text_pattern.Copy(iPattern);
+		text_pattern.Append(iPattern);
+	}
+
+	for (i = 0; i < text_pattern.Length(); i += 2)
+	{
+		hex_digit.Copy(text_pattern.Ptr() + i, 2);	//Copy 2 text digits 1 byte
+		lex.Assign(hex_digit);
+		lex.Val(hex_pattern[i/2], EHex);		//Can't fail because only 2 digits
+		//hex_pattern.Append((TUint8 *)&hex_num, sizeof(TUint8));	//Append the hex digit (byte)
+	}
+
+
+	
+	for (j = 0, i = firstPos; (TUint)i < iPacketDataSize; i++, j++)
+	{
+		iPacket[ICMP_ECHO_HEADER_SIZE + i] = !text_pattern.Length()
+			? (TUint8)(i % 256)
+			: hex_pattern[j % (text_pattern.Length()/2)];	//hex_pattern is half the size of text pattern
+	}
+//	TBuf8<150> prova;
+//	prova.Copy(iPacket);
+	StampPacket();
+}
+
+// Only composes timestamp and sequence number and calculates checksum
+
+void CPing::ComposeICMPPacket()
+{
+	ThdrICMP *hdr = (ThdrICMP *)&iPacket[0];
+	TUint16 seq = (TUint16)(((ThdrICMP_Echo *)hdr)->NetGetSeq() + 1);
+
+	((ThdrICMP_Echo *)hdr)->NetSetSeq(seq);	// Next seq. Number
+	CLR(seq);	// Clears the bit in the received/dup buffer
+
+	StampPacket();
+}
+
+void CPing::StampPacket()
+{
+	ThdrICMP *hdr = (ThdrICMP *)&iPacket[0];
+
+	if (iPacketDataSize >= TIMESTAMP_SIZE)
+	{
+		TTime time;
+		time.UniversalTime();
+		*(TInt64*)&iPacket[8] = time.Int64();	// Converts the time to a Int64 value
+	}
+
+	hdr->NetSetChecksum(0);
+	hdr->NetSetChecksum(in_chksum((TUint16 *)&iPacket[0], iPacketDataSize + ICMP_ECHO_HEADER_SIZE));
+}
+
+//Puts the next seq number in the packet (iPacket)
+void CPing::NextSeq()
+{
+	ThdrICMP_Echo *hdr;
+
+	hdr=(ThdrICMP_Echo *)&iPacket[8];
+	hdr->SetSeq((TUint16)((hdr->NetGetSeq()) + 1));
+}
+
+//TPtrC CPing::PacketTypev6(TInet6HeaderICMP_Echo *aHdr)
+void CPing::PacketTypev6(TDes& buf,ThdrICMP *aHdr)
+{
+	//TBuf<40> buf;
+	TInet6HeaderICMP *hdr = (TInet6HeaderICMP *)aHdr;
+	//TInet6HeaderICMP_Echo *echoHdr;
+
+	TInt8 code=hdr->Code();
+	switch(hdr->Type())
+	{
+		//Errors 0-127
+		case KInet6ICMP_Unreachable: 
+			//buf.Format(_L("type= "));
+			buf.Append(_L("Dest. Unreachable: "));
+			//buf.Format(_L("type=%d "),type);
+			switch (code)
+			{
+			case KInet6ICMP_NoRoute:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("No Route "));
+				break;
+			case KInet6ICMP_AdminProhibition:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Admin. Prohibition "));
+				break;
+			case KInet6ICMP_NotNeighbour:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Not a Neighbour "));
+				break;
+			case KInet6ICMP_AddrUnreach:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Addr. Unreachable "));
+				break;
+			case KInet6ICMP_PortUnreach:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Port Unreachable "));
+				break;
+			default: buf.AppendFormat(_L("code=%d "),code);
+			}
+			break;
+		case KInet6ICMP_PacketTooBig:
+			//buf.Format(_L("type= "));
+			buf.Append(_L("Pack. Too big "));
+			break;
+		case KInet6ICMP_TimeExceeded:
+			//buf.Format(_L("type= "));
+			buf.Append(_L("Time exceeded: "));
+			switch (code)
+			{
+			case KInet6ICMP_HopLimitExceeded:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Hop Limit "));
+				break;
+			case KInet6ICMP_FragReassExceeded:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Frag. Reassembly "));
+				break;
+			default: buf.AppendFormat(_L("code=%d "),code);
+			}
+			break;
+		case KInet6ICMP_ParameterProblem:
+			//buf.Format(_L("type= "));
+			buf.Append(_L("Parameter problem: "));
+			switch (code)
+			{
+			case KInet6ICMP_ErrHdrField:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Bad header filed"));
+				break;
+			case KInet6ICMP_NextHdrUnknown:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Unknown Next Header "));
+				break;
+			case KInet6ICMP_OptionUnkown:
+				//buf.Append(_L("code= "));
+				buf.Append(_L("Unknown Option"));
+				break;
+			default: buf.AppendFormat(_L("code=%d "),code);
+			}
+			break;
+
+		//Information 128-255
+		case KInet6ICMP_EchoRequest:
+			//echoHdr=(TInet6HeaderICMP_Echo *)hdr;
+			buf.Append(_L("Echo Request "));
+			//buf.AppendFormat(_L("id= %d "),echoHdr->Identifier());
+			//buf.AppendFormat(_L("Seq= %d "),echoHdr->Sequence());
+			break;
+		case KInet6ICMP_EchoReply:
+			//echoHdr=(TInet6HeaderICMP_Echo *)hdr;
+			buf.Append(_L("Echo Reply "));
+			//buf.AppendFormat(_L("id= %d "),echoHdr->Identifier());
+			//buf.AppendFormat(_L("Seq= %d "),echoHdr->Sequence());
+			break;
+	
+		case KInet6ICMP_Redirect:
+ 			buf.Append(_L("Redirect "));
+			break;
+
+		case KICMPTypeRouterAdvert: 
+		case KInet6ICMP_RouterAdv:
+			buf.Append(_L("Router advertisement "));
+			break;
+
+		case KICMPTypeRouterSolicit: 
+		case KInet6ICMP_RouterSol:
+			buf.Append(_L("Router solicitation "));
+			break;
+
+		case KInet6ICMP_GroupQuery:
+			buf.Append(_L("KInet6ICMP_GroupQuery "));
+			break;
+
+		case KInet6ICMP_GroupReport:
+			buf.Append(_L("KInet6ICMP_GroupReport "));
+			break;
+
+		case KInet6ICMP_GroupDone:
+			buf.Append(_L("KInet6ICMP_GroupDone "));
+			break;
+
+		case KInet6ICMP_NeighborSol:
+			buf.Append(_L("Neighbor Solicitation "));
+			break;
+
+		case KInet6ICMP_NeighborAdv:
+			buf.Append(_L("Neighbor Advertisement "));
+			break;
+
+		default: //buf.Format(_L("Unknown ICMP Type"));
+			buf.Format(_L("Unknown ICMP Type"));
+			//buf.Format(_L("type=%d "),hdr->Type());
+	}
+	//buf.Append(_L("\n"));
+
+}
+
+TPtrC CPing::PacketType(ThdrICMP *aHdr)
+{
+	switch(aHdr->NetGetType())
+	{
+		case KICMPTypeEchoReply: return _L("ICMP Echo reply");
+		case KICMPTypeUnreachable: 
+			switch (aHdr->NetGetCode())
+			{
+				case KICMPCodeUnreachNet: return _L("Network Unreachable");
+				case KICMPCodeUnreachHost: return _L("Host Unreachable");
+				case KICMPCodeUnreachProtocol: return _L("Protocol Unreachable");
+				case KICMPCodeUnreachPort: return _L("Port Unreachable");
+				case KICMPCodeUnreachNeedFrag: return _L("Message too long. Fragmentation needed");
+				case KICMPCodeUnreachSrcRouteFail: return _L("Source Route Failed");
+				case KICMPCodeUnreachNetUnknown: return _L("Destination Network Unknown");
+				case KICMPCodeUnreachHostUnknown: return _L("Destination Host Unknown");
+				case KICMPCodeUnreachSrcHostIsolated: return _L("Source host isolated");
+				case KICMPCodeUnreachNetProhibited: return _L("Destination Network Administatively prohibited");
+				case KICMPCodeUnreachHostProhibited: return _L("Destination Host Administatively prohibited");
+				case KICMPCodeUnreachNetTOS: return _L("Network Unreachable for TOS");
+				case KICMPCodeUnreachHostTOS: return _L("Host Unreachable for TOS");
+				case KICMPCodeUnreachProhibited: return _L("Communication Administatively prohibited");
+				case KICMPCodeUnreachPrecVolation: return _L("Host Precedence violation");
+				case KICMPCodeUnreachPrecCutoff: return _L("Precedence cutoff in effect");
+				default: return _L("Unknown code for Destination Unreachable");
+			}
+		case KICMPTypeSourceQuench: return _L("Source Quench");
+		case KICMPTypeRedirect: 
+			switch (aHdr->NetGetCode())
+			{
+				case KICMPCodeRedirectNet: return _L("Redirect for network");
+				case KICMPCodeRedirectHost: return _L("Redirect for Host");
+				case KICMPCodeRedirectNetTOS: return _L("Redirect for TOS and Network");
+				case KICMPCodeRedirectHostTOS: return _L("Redirect for TOS and Host");
+				default: return _L("Unknown code for ICMP Redirect");
+			}
+		case KICMPTypeEchoRequest: return _L("Echo Request");
+		case KICMPTypeRouterAdvert: return _L("Router advertisement");
+		case KICMPTypeRouterSolicit: return _L("Router solicitation");
+		case KICMPTypeTimeExceeded: 
+			switch (aHdr->NetGetCode())
+			{
+				case KICMPCodeExceedInTransit: return _L("TTL 0 during Transit");
+				case KICMPCodeExceedInReasm: return _L("TTL 0 during Reassembly");
+				default: return _L("Unknown Code for Time exceeded type");
+			}
+		case KICMPTypeBadParameter: return _L("Parameter Problem");
+		case KICMPTypeTimeRequest: return _L("Timestamp Request");
+		case KICMPTypeTimeReply: return _L("Timestamp Reply");
+		case KICMPTypeInfoRequest: return _L("Information Request");
+		case KICMPTypeInfoReply: return _L("Information Reply");
+		case KICMPTypeMaskRequest: return _L("Adress Mask Request");
+		case KICMPTypeMaskReply: return _L("Adress Mask Reply");
+		default: return _L("Unknown ICMP Type");
+	}
+}
+
+// Shows ICMP data in the Packet and calculates time related info
+
+void CPing::PrintICMPData(const TDesC8& data)
+{
+	TBuf<300> aux;
+	ThdrICMP *hdr;	// Use only this one because the packet format for ICMP_Echo_reply is 
+					// identical in both ICMPv4 and ICMPv6
+
+	hdr=(ThdrICMP*)&data[0];	// ICMP packet format
+
+	TUint type;
+	if (iType==IPv4)
+		type=KICMPTypeEchoReply;
+	else	// ICMPv6
+		type=KInet6ICMP_EchoReply;
+
+	if (hdr->NetGetType()!=type)
+	{
+		// We want to list other packets than ICMP Echo Reply
+		if (iVerbose)
+		{
+			if (iType==IPv4)
+				aux.Format(PacketType(hdr)); // Return a description of the packet Type and Code
+			else
+			{
+				TBuf<40> auxBuf;
+				PacketTypev6(auxBuf,hdr);
+				aux.Format(auxBuf);	// Return a description of the packet Type and Code
+			}
+			aux.Append(_L("\n"));
+			WriteLineIfNotQuiet(aux);
+		}	// else we ignore them
+		return;
+	}
+	
+	// Checks if it's a the packet have a correct Id
+	// Useful if two instances if Ping running (not possible in this version)
+
+	if (((ThdrICMP_Echo *)hdr)->NetGetId()!=iId)
+	{
+		aux.Append(_L("Packet with wrong id received\n"));
+		WriteLineIfNotQuiet(aux);
+		return;
+	}
+
+	// Correct packet type and code
+
+	aux.AppendFormat(_L("Seq: %u"),((ThdrICMP_Echo *)hdr)->NetGetSeq());
+
+	// Checks if chksum is correct must be 0 (because includes the checksum field)
+	// else there's something wrong
+
+	if (iType==IPv4)
+	{
+		if (in_chksum((TUint16 *)&data[0], iPacketDataSize + ICMP_ECHO_HEADER_SIZE)!=0)
+		{
+			aux.Append(_L(" Checksum Error\n"));
+			WriteLineIfNotQuiet(aux);
+			iChksumErrors++;
+			return;
+		}
+	}
+	// ICMPv6 checks checksum internally
+
+	// Timestamp calculation
+
+	if (iPacketDataSize >= TIMESTAMP_SIZE)
+	{
+		TTime now;
+		TTime time(*(TInt64*)&data[8]);
+		now.UniversalTime();
+
+		TTimeIntervalMicroSeconds interval;
+		interval = now.MicroSecondsFrom(time);
+#ifdef I64LOW
+		TUint num = I64LOW(interval.Int64()) / 1000;
+#else
+		TUint num = interval.Int64().GetTInt() / 1000;
+#endif
+
+		if (num > iMaxTime)
+			iMaxTime = num;
+
+		if (num < iMinTime)
+			iMinTime = num;
+
+		iTimeSum += num;
+
+		aux.AppendFormat(_L("\tTime: %d ms"),num);
+	}
+	
+	iRecvPackets++;
+
+	// Test if duplicated
+
+	if (TEST(((ThdrICMP_Echo *)hdr)->NetGetSeq()))
+	{
+		aux.Append(_L("\tDUPLICATED"));
+		iRecvPackets--;	// because duplicated
+		iDupPackets++;  // to show it in statistics
+	}
+	else
+	{
+		SET(((ThdrICMP_Echo *)hdr)->NetGetSeq());	// Marks the packet as received
+	}
+
+	//aux.Append(_L("\n"));
+	WriteLineIfNotQuiet(aux);
+}
+
+void CPing::Stop()
+{
+	iRunning=EFalse;
+	iConsole->OnEnd();
+
+	//CEikonEnv::Static()->BusyMsgCancel();
+	/*
+	delete iPacketData;
+	iPacketData=NULL;
+	delete iReceivedDataBuffer;
+	iReceivedDataBuffer=NULL;
+	*/
+}
+
+void CPing::BeginL()
+{
+	TInt err=0;
+
+	if (IsRunning())	// There's another instance running
+		return;
+	else
+		iRunning=ETrue;
+
+	//INITIALIZATION
+	iSentPackets=0;		//ICMP Echo Request Packets sent
+	iRecvPackets=0;		//ICMP Echo Reply Packets received
+	iChksumErrors=0;	//Packets with errors when checking checksum
+	iSockErrors=0;		//Errors when writing/reading to/from the sockets
+	iDupPackets=0;		//Duplicated packets
+
+	iMaxTime=0;			//Time-related vars
+	iMinTime=KMaxTUint32;
+	iTimeSum=0;
+
+	if (iPacketDataSize > MAX_ICMP_PACKETSIZE)  //Is prevented in .rss file
+		iPacketDataSize = MAX_ICMP_PACKETSIZE;
+
+	
+	delete iPacketData;
+	iPacketData= HBufC8::NewL(iPacketDataSize + ICMP_HDRLEN); 
+						//Allocates space for the ICMP packet
+	TPtr8 aux(iPacketData->Des());	//weird but necessary. Cannot use Des() directly in iPacket
+	iPacket.Set(aux);
+	//iPacket.SetMax();	//because it'll be written directly using [] in Compose...() and it would crash.
+	//HUOM!!! Cannot be SetMax because sometimes the reserved size is slightly bigger. Because of block size?
+	iPacket.SetLength(iPacketDataSize + ICMP_HDRLEN);	//because it'll be written directly using [] in Compose...() and it would crash.
+
+
+	delete iReceivedDataBuffer;
+	iReceivedDataBuffer= HBufC8::NewL(iPacketDataSize + ICMP_ECHO_HEADER_SIZE);	//Maximum size of a return packet
+	TPtr8 auxPtr(iReceivedDataBuffer->Des());	//must be used here because the buffer changes
+	iReceivedData.Set(auxPtr);			//we use an aux var because can't use Des() directly Why??
+	
+	iConsole->WriteHostL(iHostname);
+	iConsole->WriteLine(_L("Connecting...\n"));	
+	iConsole->UpdateStatisticsL();
+	
+	
+#ifdef IAPSETTING
+	//CStoreableOverrideSettings *settings = NULL;
+	//CCommDbOverrideSettings::TParamList ParamList = CCommDbOverrideSettings::TParamList::EParamListPartial;
+	//CCommDbOverrideSettings::TParamList ParamList = CCommDbOverrideSettings::TParamList::EParamListPartial;
+	TCommDbDatabaseType Type = EDatabaseTypeIAP;
+	CStoreableOverrideSettings *settings = CStoreableOverrideSettings::NewL(CCommDbOverrideSettings::EParamListPartial,Type);
+	
+	CleanupStack::PushL(settings);
+	
+	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref conPref;
+	conPref.iRanking = 1;
+	conPref.iDirection = ECommDbConnectionDirectionOutgoing;
+	CCommsDbConnectionPrefTableView::TCommDbIapBearer bearer;
+	bearer.iIapId = iIAP;
+	conPref.iBearer = bearer;
+
+	err = settings->SetConnectionPreferenceOverride(conPref);
+	User::LeaveIfError(err);
+	User::LeaveIfError(iGenericAgent.Open());
+    iGenericAgent.StartOutgoing(*settings,iStatus);
+	
+	err = iGenericAgent.DisableTimers();
+    if (err != KErrAlreadyExists)
+        User::LeaveIfError(err);
+	CleanupStack::PopAndDestroy();	
+	User::WaitForAnyRequest();
+#endif
+
+
+	//connecting the Socket Server
+	err=iSockServ.Connect();	//KESockDefaultMessageSlots
+	if (err!=KErrNone)
+	{
+		ErrorL(_L("Socket Server Error (Connect)"),err);
+		Stop();
+		return;
+	}
+
+	err=iHostResolv.Open(iSockServ, KAfInet, KProtocolInetIcmp);	// Address Resolver 
+	
+	if (err!=KErrNone)
+	{
+		ErrorL(_L("Resolver Error (Open)"),err);
+
+		Stop();
+		return;
+	}
+
+
+
+	//Report(_L("Resolver Open"));
+	iConsole->WriteLine(_L("Resolving..."));	
+	iHostResolv.GetByName(iHostname,iEntry,iStatus);
+	//Report(_L("Resolver GetByName"));
+	iStage=0;
+	//CEikonEnv::Static()->BusyMsgL(R_RESOLVING_NAME);
+
+	
+//-------------------------------------------------
+	//DO NOT REMOVE the next commented code!!!!!!!!!!!!!!!!!!
+	/*
+	//Never will be used because the socket is opened as ICMP not IP so is not usable 
+	//unless some changes are made to the socket and packet format.
+	
+	
+	if (iHopLimit!=0)	// 0 means value not set
+	{	//Only setable for multicast adresses
+		err=iSocket.SetOpt(KSoIpTTL,KSOLSocket,iHopLimit);	//Set TTL (max. hops)
+		
+		
+		if (err==KErrNotSupported)
+			iConsole->WriteLine(_L("TTL can only be set with multicast adress (Not used)\n"));
+		else
+			if (err<0)
+			{
+				ErrorL(_L("Socket Error (SetOpt)"),err);
+				return;
+			}
+		
+	}
+--------------------------------------------------------	*/
+	IssueRequest();
+/*	iStage=0;
+	TRequestStatus *xst=&iStatus;
+	User::RequestComplete(xst,KErrNone);*/
+}
+
+void CPing::CreateSocketAOL()
+{
+	
+	iPingSender=new(ELeave) CPingSender;
+    iPingSender->ConstructL(this);	//2nd phase
+	iPingSender->FirstRunL();	//Starts packet sending
+}
+
+//Issues next RunL execution
+void CPing::IssueRequest()
+{
+	SetActive();	//Sets the object as Active.
+					//RunL will be executed when iStatus!=KRequestPending (set by CPingSender)
+}
+
+
+void CPing::RunL()
+{
+	TInt err=KErrNone;
+	TBuf<39> textIPaddress;	//text address to be displayed
+	TBuf<356> aux;
+	TInetAddr anyaddr;
+	TRequestStatus xStatus;
+
+	switch (iStage)
+	{
+	case 0:
+		//Report(_L("Resolver GetByName end"));
+		if (iStatus==KErrNotFound)
+		{//The Nameserver couldn't find the Host. 
+			TBuf<100> warn(iHostname);
+			warn.Append(_L(" not found!\n"));
+			iConsole->WriteLine(warn);
+			iHostResolv.Close();
+			Stop();
+			return;
+		}	
+		if (iStatus!=KErrNone)
+		{
+			ErrorL(_L("Resolver Error (GetByName)"),iStatus.Int());
+			iHostResolv.Close();
+			//iSockServ.Close();
+			Stop();
+			return;
+		}
+
+		iHostResolv.Close();
+		iHostAddr = TInetAddr::Cast(iEntry().iAddr);	//host address
+
+		// The type of PING (ICMPv4 or ICMPv6) depens purely on the destination address.
+		// ...for IPv4 (or IPv4 mapped), use ICMPv4
+		// ...for true IPv6, use ICMPv6
+		iType = (iHostAddr.Family() == KAfInet6 && !iHostAddr.IsV4Mapped()) ? IPv6 : IPv4;
+
+		iHostAddr.Output(textIPaddress);
+		/*aux.Append(iEntry().iName);   // maybe the main name is not the entered
+		aux.Append(_L(" is "));
+		aux.Append(textIPaddress);
+
+		aux.AppendFormat(_L("\nUsing %d data bytes"), iPacketDataSize);
+		*/
+		aux.AppendFormat(_L("Pinging %S [%S] with %d bytes of data:\n"), &iEntry().iName, &textIPaddress, iPacketDataSize);
+		if (iPacketDataSize < TIMESTAMP_SIZE)
+			aux.AppendFormat(_L("timestamps disabled (min %d bytes)\n"), TIMESTAMP_SIZE);
+
+		//aux.Append(_L("\n\n"));
+		iConsole->WriteLine(aux);
+
+		if (iType==IPv4)
+		{
+			err=iSocket.Open(iSockServ,_L("icmp"));
+		}
+		else
+		{
+			err=iSocket.Open(iSockServ,_L("icmp6"));
+		}
+
+		if (err!=KErrNone)
+		{
+			ErrorL(_L("Socket Error (Open)"),err);
+			Stop();
+			return;
+		}
+		//iStage++;
+		
+		anyaddr.SetAddress(KInetAddrAny);	//Sniffs all packets
+		anyaddr.SetPort(KProtocolInetIcmp);	//Sniffs all packets
+
+		err=iSocket.Bind(anyaddr);
+		if (err!=KErrNone)
+		{	
+			ErrorL(_L("Socket Error (Bind)"),err);
+			Stop();
+			return;
+		}
+
+		iSocket.Connect(iHostAddr,xStatus);	//must be wait here or panic esock14
+		User::WaitForRequest(xStatus);
+		if (xStatus.Int()!=KErrNone)
+		{
+			ErrorL(_L("Socket Error (Connect)"),xStatus.Int());
+			Stop();
+			return;
+		}
+	
+		// Socket Options setting
+		if (iDebug)
+			err=iSocket.SetOpt(KSODebug,KSOLSocket,1);	//Enable debugging
+		else
+			err=iSocket.SetOpt(KSODebug,KSOLSocket,0);	//disable debugging (DEFAULT)
+            
+		if (err!=KErrNone)
+		{
+			ErrorL(_L("Socket Error (SetOpt)"),err);
+			//iHostResolv.Close();
+			iSocket.Close();
+			//iSockServ.Close();
+#ifdef IAPSETTING			
+			iGenericAgent.Close();
+#endif 			
+			Stop();
+			return;
+		}
+		//CEikonEnv::Static()->BusyMsgCancel();	//Cancel the resolving name msg
+		CreateSocketAOL();	//Creates the send A.O.
+		iSocket.Read(iReceivedData,iStatus);
+		iStage++;
+		IssueRequest();	//Prepares to receive it in RunL()
+		break;
+
+	case 1:
+		//Report(_L("Socket Read end"));
+		if (iStatus==KErrNone)
+		{
+			PrintICMPData(iReceivedData);	//The previous packet
+		}
+		else
+			ErrorL(_L("Read (Recv)"),iStatus.Int());
+
+		iConsole->UpdateStatisticsL();
+		
+		iSocket.Read(iReceivedData,iStatus);	// NEXT Packet
+		IssueRequest();	// Prepares to receive it in RunL()
+		// No more stages!
+		break;
+
+	default:
+		//CEikonEnv::Static()->InfoMsg(_L("Bad Stage!!!"));
+		EndPingL();
+	}
+
+}
+
+void CPing::DoCancel()
+	{
+	if (iStage==0)
+		{
+		iHostResolv.Cancel();
+		}
+	else if (iStage==1)	
+		{
+		//RSocket::Read has been called, so need to cancel this outstanding Read
+		iSocket.CancelRead();
+		}
+	}
+
+void CPing::CloseAll()
+	{
+	iHostResolv.Close();
+	//iSocket.CancelAll();	//Cancel all outstanding requests 
+	iSocket.Close();	
+	iSockServ.Close();
+#ifdef IAPSETTING
+	iGenericAgent.Close();
+#endif
+}
+
+// Stops Ping
+
+void CPing::EndPingL()
+{	
+	//CEikonEnv::Static()->BusyMsgCancel();	// Cancel the resolving name msg in case it wasn't
+
+	Statistics();
+	iConsole->UpdateStatisticsL();
+	
+	if (iPingSender!=0)	// Not needed if control dimmed because can't launch 2 pings
+	{
+		delete iPingSender;
+		iPingSender=0;
+	}
+
+	Cancel();
+
+	CloseAll();
+	iRunning = EFalse;
+	iConsole->OnEnd();
+}
+
+// Just checks if sending packets from a previous ping
+
+TBool CPing::IsRunning()
+{
+	return iRunning;
+}
+
+// Sends packets with an active Timer
+// Created by CPing
+// Not intended to run alone
+
+CPingSender::CPingSender():CTimer(EPriorityStandard)//,iSentData(0,0)
+{
+	CActiveScheduler::Add(this);	//Adds itself to the scheduler only the first time
+}
+
+CPingSender::~CPingSender()
+	{
+	Cancel();
+	delete iSender;
+	}
+
+void CPingSender::ConstructL(CPing *aPingModel)
+{
+	//Base class 2nd phase constructor
+	CTimer::ConstructL();
+
+	iPingModel=aPingModel;	// Poiter to the model which contains data
+	//iSentDataBuffer= HBufC8::NewL(iPingModel->iPacketDataSize + ICMP_HDRLEN);
+							//Allocates the maximum space needed the size chosen + ICMP Header
+	iSender=new(ELeave) CPingSingleSender(iPingModel);
+}
+
+
+//Issues next RunL execution
+void CPingSender::IssueRequest()
+{
+	After(iPingModel->iSecWait*SECOND);	//Also sets the object as Active
+}
+
+//Issues last RunL execution
+void CPingSender::IssueLastRequest()
+{
+	After(iPingModel->iLastSecWait*SECOND);	//Also sets the object as Active
+}
+
+
+void CPingSender::FirstRunL()
+{	
+	
+	SendFirstPacketL();
+	
+	if ((iPingModel->iSentPackets==iPingModel->iTotalPackets) && (iPingModel->iPackLimit))
+		IssueLastRequest();	//Last RunL	have a special waiting time. to receive the last reply
+	else
+		IssueRequest();	//First RunL
+}
+
+
+
+// will send all the packets. One packet each Time
+void CPingSender::RunL()
+{
+	if ((iPingModel->iSentPackets>=iPingModel->iTotalPackets) && (iPingModel->iPackLimit))
+	{
+		iPingModel->EndPingL();
+		return;
+	}
+	else	//There are packets to send or number unlimited
+	{		
+		SendPacket();
+
+		if ((iPingModel->iSentPackets>=iPingModel->iTotalPackets) && (iPingModel->iPackLimit))
+			IssueLastRequest();	//Last RunL	have a special waiting time. to receive the last reply
+		else
+			IssueRequest();	//Next RunL
+	}
+
+}
+
+
+//Creates a AO that sends a packets waits for it to be send and dies
+void CPingSender::SendFirstPacketL()
+{
+	iSender->FirstRunLD();	//Starts packet sending. Destroys itself
+}
+
+
+//Creates a AO that sends a packets waits for it to be send and dies
+void CPingSender::SendPacket()
+{
+	iSender->NextPacket();
+}
+
+//Cancel Packet Sending
+void CPingSender::DoCancel()
+	{
+	CTimer::DoCancel();
+	}
+
+
+
+
+// Used by CPingSender
+// Sends packets. Cannot be done directly by CPingSender because there are conflicts with
+//					diferent TRequestStatus.
+
+CPingSingleSender::CPingSingleSender(CPing *aPingModel):CActive(EPriorityStandard)
+{
+	iPingModel=aPingModel;	// Pointer to the model which contains data
+	CActiveScheduler::Add(this);	//Adds itself to the scheduler only the first time
+}
+
+CPingSingleSender::~CPingSingleSender()
+	{
+	Cancel();
+	}
+
+
+// Issues next RunL execution
+
+void CPingSingleSender::IssueRequest()
+{
+	SetActive();	// Sets the object as Active.
+}
+
+void CPingSingleSender::FirstRunLD()
+{	
+	iPingModel->ComposeFirstICMPPacket();
+	iPingModel->iSocket.Write(iPingModel->iPacket, iStatus); // iStatus used by CTimer
+	iPingModel->iSentPackets++;
+	iUnsent=0;
+	IssueRequest();
+}
+
+void CPingSingleSender::NextPacket()
+{	
+	if (IsActive())		// Still a packet being sent
+		iUnsent++;		// Cannot sent here because iSatus would be overwritten
+	else
+	{
+		iPingModel->ComposeICMPPacket();
+		iPingModel->iSocket.Write(iPingModel->iPacket, iStatus); // No other request waiting
+		iPingModel->iSentPackets++;
+		IssueRequest();
+	}
+}
+
+// will send all the packets. One packet each Time
+// when entering this function, 
+// it means either one packet has actually been sent, or failed
+void CPingSingleSender::RunL()
+{
+//	TBuf<50> aux;
+	
+//	if (iStatus==KErrNone)
+//		iPingModel->iSentPackets++;
+	//else if (iStatus!=KRequestPending)
+	if (iStatus!=KErrNone)
+	{
+		iPingModel->iSentPackets--;	//Packet sending failed
+		iPingModel->ErrorL(_L("Write"),iStatus.Int());
+	}
+
+	//aux.Format(_L("Write end (st=%d, sent=%d)"),iStatus,iPingModel->iSentPackets);
+	//iPingModel->WriteLineIfNotQuiet(aux);
+	iPingModel->iConsole->UpdateStatisticsL();
+	//Ignores the timer request because there are packets that should already be sent
+	if (iUnsent)
+	{
+		iPingModel->ComposeICMPPacket();
+		iPingModel->iSocket.Write(iPingModel->iPacket, iStatus); // iStatus used by CTimer
+		iPingModel->iSentPackets++;
+		iUnsent--;
+		IssueRequest();
+	}
+}
+
+// Cancel Packet Sending
+
+void CPingSingleSender::DoCancel()
+	{
+	iPingModel->iSocket.CancelWrite();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ping/pingmodel.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,291 @@
+// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// pingmodel.h - icmp echo client engine
+// This software has been implemented in the 6PACK
+// project at the Mobile Networks Laboratory (MNW)
+// http://www.research.nokia.com/projects/6pack/
+//
+
+#if !defined __PINGMODEL_H
+#define __PINGMODEL_H
+
+#include <es_sock.h>
+#include <in_sock.h>
+
+#include <nifmbuf.h>
+#include "in_icmp.h"
+#include <icmp6_hdr.h>
+
+#include "const.h"
+
+#ifdef IAPSETTING
+#include <agentclient.h>
+#endif
+
+// constants
+
+#define TIMESTAMP_SIZE  sizeof(TInt64)  //Timestamp Size
+
+#define DEFDATALEN      64 - TIMESTAMP_SIZE     //default data length
+
+
+#define SECOND 1000000  // One second is 1000000 us. (1 us. per tick)
+
+//ICMPv6 codes not defined in .h's
+#define KInet6ICMP_HopLimitExceeded		0
+#define KInet6ICMP_FragReassExceeded	1
+
+#define KInet6ICMP_NoRoute				0
+#define KInet6ICMP_AdminProhibition		1
+#define KInet6ICMP_NotNeighbour			2
+#define KInet6ICMP_AddrUnreach			3
+#define KInet6ICMP_PortUnreach			4
+
+#define KInet6ICMP_ErrHdrField			0
+#define KInet6ICMP_NextHdrUnknown		1
+#define KInet6ICMP_OptionUnkown			2
+
+
+#define MAX_PATTERN_LENGTH	16	//Must match the value of the pattern in the RSS file!!!
+#ifdef IAPSETTING
+#define MAX_IAP_LENGTH	5	//Must match the value of the pattern in the RSS file!!!
+#endif
+class CPingContainer;
+class CPingSender;
+
+
+const TUint KPingQuiet			= 0x01;
+const TUint KPingVerbose		= 0x02;
+const TUint KPingPackLimit		= 0x04;
+const TUint KPingDebug			= 0x08;
+
+//Contains engine's saved preferences
+class TPreferences
+{
+public:
+	TUint iFlags;
+	//Contains:
+		//Bit 0 TBool   iQuiet;                 //No packet info, just statistics
+		//Bit 1 TBool   iVerbose;               //Verbose Output. All ICMP packets, not only Echo reply
+		//Bit 2 TBool   iPackLimit;             //Indicates if unlimited packet number
+		//Bit 3 TBool   iDebug;                 //Set the SO_DEBUG flag in the socket
+
+	TUint   iSecWait;			//Time between sent packets (Default 1 second)
+	TUint   iPacketDataSize;	//Default Data Size (not including ICMP header)
+	TUint   iTotalPackets;		//Number of ICMP Echo Request packets to send
+	TUint   iLastSecWait;		//Time to wait for the Last packet. Default 2
+	TBuf<KHostNameLimit> iHostname;
+	TBuf<MAX_PATTERN_LENGTH> iPattern;	//Pattern to fill the packet.Default 0xFF (Stored as text)
+
+#ifdef IAPSETTING
+	TUint iIAP;	
+#endif
+	//Not used yet
+	//TUint   iHopLimit;              //Time-to-live in hops default 255 (0 means not set)
+	//TBool   iNumericOutput; //Resolve adresses by default	
+};
+
+class CPingSender;
+class CPingSingleSender;
+//Ping Utility class. Contains All the ping model and create active objects to
+//                                              send and receive from the socket
+class CPing : public CActive
+{
+friend class CPingSender;
+friend class CPingSingleSender;
+public:
+	CPing();
+	~CPing();
+	
+	void ConstructL(TPreferences aPref);
+
+	//return the current preferences
+	void GetPreferences(TPreferences &aPref);
+	static void DefaultPreferences(TPreferences &aPref);
+	void SetConsole(CPingContainer *aConsole);
+	TDes* GetHostName();
+	void SetHostName(const TDesC& ahostname);
+	
+	void EndPingL();
+	TBool IsRunning();
+	void BeginL();
+
+#ifdef IAPSETTING
+	void StartConnection();
+#endif
+
+protected:
+	
+	TUint16 in_chksum(TUint16 *data, TUint len);
+	void ComposeFirstICMPPacket();  //Compose a whole ICMPPacket
+	void ComposeICMPPacket();               //Only composes timestamp and sequence number
+	void StampPacket(); // Modify the composed packet with fresh timestamp and checksum
+	void NextSeq();
+
+	void CloseAll();        //Closes all the resources
+	void PrintICMPData(const TDesC8& adata);
+
+	void IssueRequest();
+	void RunL();    //Segment of code to execute
+	void DoCancel();        //Stops Execution of Ping
+
+private:
+	void CreateSocketAOL();
+	void Statistics();
+	void WriteLineIfNotQuiet(const TDesC& abuf);
+	void ErrorL(const TDesC& string,TInt error);
+	void CLR(TUint16 num);
+	void SET(TUint16 num);
+	TBool TEST(TUint16 num);
+	TPtrC PacketType(ThdrICMP *hdr);
+	//TPtrC PacketTypev6(TInet6HeaderICMP_Echo *aHdr);
+	void PacketTypev6(TDes& buf,ThdrICMP *aHdr);
+	void Stop();
+	TUint16 RandomNumber();
+
+private:
+	
+    CPingContainer *iConsole;
+	RSocketServ iSockServ;  // Socket Server
+	RSocket iSocket;                                // Socket
+	RHostResolver iHostResolv;      //Resolver
+	//TRequestStatus status;		// To wait for socket operations completion
+
+	CPingSender *iPingSender;
+	TUint32 iDup[8];                //Calculates duplicate packets up to 256 packets, after
+						//it begins again using modulus (%, MOD)
+
+	HBufC8 *iPacketData;
+	TPtr8 iPacket;
+	TUint16 iId;
+
+	TUint iMaxTime;                         //Maximum time 
+	TUint iMinTime;                         //Minimum time
+	TUint iTimeSum;                         //all times sum
+	TBuf<KHostNameLimit> iHostname;         // Contains hostname to ping
+	
+	TUint iDupPackets;						//Duplicated packets
+	TBool iRunning;
+	TUint iStage;		//Stages to use non-blocking resolver in RunL
+	TNameEntry iEntry;	//contains address resolution data
+
+	HBufC8 *iReceivedDataBuffer;
+	TPtr8 iReceivedData;
+
+	TUint iType;
+
+	TInt64 iSeed;	//Used for random iId generation
+
+public:
+	TBool   iNumericOutput; //Resolve adresses by default
+	TUint   iSecWait;               //Time between sent packets (Default 1 second)
+	TUint   iPacketDataSize;//Default Data Size (not including ICMP header)
+	TBool   iQuiet;                 //No packet info, just statistics
+	TUint   iHopLimit;              //Time-to-live in hops default 255 (0 means not set)
+	TBool   iVerbose;               //Verbose Output. All ICMP packets, not only Echo reply
+	TBool   iPackLimit;             //Indicates if unlimited packet number
+	TUint   iSentPackets;   //ICMP Echo Request Packets sent til now
+	TUint   iRecvPackets;   //ICMP Echo Reply Packets received til now
+	TUint   iTotalPackets;  //Number of ICMP Echo Request packets to send
+	TBuf<MAX_PATTERN_LENGTH> iPattern;               //Pattern to fill the packet.Default 0xFF
+	TBool   iDebug;                 //Set the SO_DEBUG flag in the socket
+	TUint   iLastSecWait;   //Time to wait for the Last packet. Default 2
+	TUint   iChksumErrors;
+	TUint   iSockErrors;
+	TInetAddr iHostAddr;		//Address to Ping
+#ifdef IAPSETTING
+	TUint iIAP;		
+	RGenericAgent iGenericAgent;     // To establish the connection with the ISP.
+#endif
+};
+
+// Used by CPing
+// Send packets using a CTimer (CActive) object
+// Not intended to run alone!!!
+
+class CPingSender : public CTimer
+{
+public:
+	//constructor
+	CPingSender();
+
+	//destructor
+	~CPingSender();
+	
+	//second phase constructor
+	void ConstructL(CPing *aPingModel);
+	void FirstRunL();
+
+protected:
+	//Issues next RunL execution
+	void IssueRequest();
+
+	//Issues last RunL execution
+	void IssueLastRequest();
+
+	// will send all the packets
+	void RunL();
+
+	//Cancel Packet Sending
+	void DoCancel();
+	
+	void SendFirstPacketL();
+	void SendPacket();
+
+private:
+	CPing *iPingModel;
+	CPingSingleSender *iSender;
+	
+
+};
+
+
+// Used by CPingSender
+// Sends packets. Cannot be done directly by CPingSender because there are conflicts with
+//					diferent TRequestStatus.
+
+
+class CPingSingleSender : public CActive
+{
+public:
+	//constructor
+	CPingSingleSender(CPing *aPingModel);
+
+	//destructor
+	~CPingSingleSender();
+	
+	void FirstRunLD();
+	void NextPacket();
+
+protected:
+	//Issues next RunL execution
+	void IssueRequest();
+
+	//Issues last RunL execution
+	void IssueLastRequest();
+
+	// will send all the packets
+	void RunL();
+
+	//Cancel Packet Sending
+	void DoCancel();
+
+
+private:
+	CPing *iPingModel;
+	TUint iUnsent;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/play/play.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+# play.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name play
+
+==short-description
+
+Plays an audio file using the Symbian OS Multi-Media Framework.
+
+==argument filename file_name optional
+
+The name of the file to be played. Must be specified unless C<--max-volume> is used.
+
+==option int p priority
+
+Specifies the audio priority to use for playback.
+
+==option int f preference
+
+Sepcifies the audio priority preferense for playback.
+
+==option int V volume
+
+Specifies the audio volume to use for playback. To find the maximum valid value for this value, use option C<--max-volume>.
+
+==option bool v verbose
+
+Display more detailed output.
+
+==option bool m max-volume
+
+Display the maximum valid volume level, then exit.
+
+==copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/play/play.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,272 @@
+// play.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include <e32base.h>
+#include <bacline.h>
+#include <mmf/server/sounddevice.h>
+#include "play.h"
+
+_LIT(KNewLine, "\n");
+
+
+//______________________________________________________________________________
+//						~CCmdPlay
+CCommandBase* CCmdPlay::NewLC()
+	{
+	CCmdPlay* self = new(ELeave)CCmdPlay();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+	
+void CCmdPlay::ConstructL()
+	{
+	BaseConstructL();
+	iPlayer = CMmfPlayer::NewL(Stdout());
+	}
+	
+CCmdPlay::~CCmdPlay()
+	{
+	delete iPlayer;
+	}
+	
+const TDesC& CCmdPlay::Name() const
+	{
+	_LIT(KName, "play");
+	return KName;
+	}
+	
+void CCmdPlay::DoRunL()
+	{
+	if (iMaxVolume)
+		{
+		// we use DevSound to get the max volume, as CMdaAudioRecorderUtility
+		// always returns 0 until we have opened a file.
+		CMMFDevSound* devSound = CMMFDevSound::NewL();
+		TInt maxVol = devSound->MaxVolume();
+		TBool cons = Stdout().AttachedToConsole();
+		if (cons) Printf(_L("Maximum volume: "));
+		Printf(_L("%d"), maxVol);
+		if (cons) Printf(_L("\r\n"));
+		delete devSound;
+		}
+	else
+		{
+		if (!iArguments.IsPresent(0)) 
+			{
+			PrintError(KErrArgument, _L("No filename specified"));
+			DisplayHelp();
+			Complete(KErrArgument);
+			return;
+			}
+		iPlayer->GetReady(iFile, iVerbose);
+		if (iOptions.IsPresent(&iPriority) || iOptions.IsPresent(&iPreference))
+			{
+			iPlayer->SetPriority(iPriority, iPreference);
+			}
+		if (iOptions.IsPresent(&iVolume))
+			{
+			iPlayer->SetVolume(iVolume);
+			}
+		CActiveScheduler::Start();
+		User::LeaveIfError(iPlayer->Error());
+		}
+	}
+
+void CCmdPlay::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptPriority, "priority");
+	aOptions.AppendIntL(iPriority, KOptPriority);
+
+	_LIT(KOptPreference, "preference");
+	aOptions.AppendIntL(iPreference, KOptPreference);
+
+	_LIT(KOptVolume, "volume");
+	aOptions.AppendIntL(iVolume, KOptVolume);
+
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptMaxVolume, "max-volume");
+	aOptions.AppendBoolL(iMaxVolume, KOptMaxVolume);
+	}
+	
+void CCmdPlay::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFiles, "file_name");
+	aArguments.AppendFileNameL(iFile, KArgFiles);
+	}
+			
+CCmdPlay::CCmdPlay()
+	{
+	}
+
+//______________________________________________________________________________
+//						CMmfPlayer
+CMmfPlayer* CMmfPlayer::NewL(RIoConsoleWriteHandle& aStdOut)
+	{
+	CMmfPlayer* self = new(ELeave)CMmfPlayer(aStdOut);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+void CMmfPlayer::ConstructL()
+	{
+	CActiveScheduler::Add(this);
+	iUtil = CMdaAudioRecorderUtility::NewL(*this);
+	}
+	
+CMmfPlayer::CMmfPlayer(RIoConsoleWriteHandle& aStdOut)
+	: CActive(CActive::EPriorityStandard), iStdOut(aStdOut), iVolume(-1)
+	{
+	}
+
+CMmfPlayer::~CMmfPlayer()
+	{
+	delete iUtil;
+	}
+	
+TInt CMmfPlayer::GetMaxVolume()
+	{
+	return iUtil->MaxVolume();
+	}
+	
+TInt CMmfPlayer::Error()
+	{
+	return iError;
+	}
+
+void CMmfPlayer::GetReady(const TDesC& aFileName, TBool aVerbose)
+	{
+	iFileName = &aFileName;
+	iVerbose = aVerbose;
+	iState = EInitial;
+	TRequestStatus* stat = &iStatus;
+	User::RequestComplete(stat, KErrNone);
+	SetActive();
+	}
+	
+void CMmfPlayer::SetPriority(TInt aPriority, TInt aPreference)
+	{
+	iUtil->SetPriority(aPriority, (TMdaPriorityPreference)aPreference);
+	}
+
+void CMmfPlayer::SetVolume(TInt aVolume)
+	{
+	iVolume = aVolume;
+	}
+
+void CMmfPlayer::RunL()
+	{
+	ProcessL();
+	}
+	
+TInt CMmfPlayer::RunError(TInt aError)
+	{
+	Error(aError);
+	return KErrNone;
+	}
+
+void CMmfPlayer::DoCancel()
+	{
+	}
+
+void CMmfPlayer::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode)
+	{
+	if (aErrorCode!=KErrNone)
+		{
+		Error(aErrorCode);
+		}
+	else
+		{
+		if (aCurrentState!=EPlaying)
+			{
+			TRAPD(err, ProcessL());
+			if (err!=KErrNone) Error(err);
+			}				
+		}
+	}
+	
+void CMmfPlayer::ProcessL()
+	{
+	switch (iState)
+		{
+	case EInitial:
+		iState = EOpening;
+		iUtil->OpenFileL(*iFileName);
+		Message(_L("Opening clip %S"), &iFileName);
+		break;
+	case EOpening:
+		iState = EPlaying;
+		if (iVolume != -1)
+			{
+			iUtil->SetVolume(iVolume);
+			}
+		iUtil->PlayL();
+		Message(_L("Playing"));
+		break;
+	case EPlaying:
+		Message(_L("Playing complete"));
+		Stop();
+		break;
+		}
+	}
+	
+void CMmfPlayer::Error(TInt aError)
+	{
+	switch (iState)
+		{
+	case EInitial:
+		Message(_L("Error %d"), aError);
+		break;
+	case EOpening:
+		Message(_L("Error %d when opening clip"), aError);
+		break;
+	case EPlaying:
+		Message(_L("Error %d when playing clip"), aError);
+		break;
+	default:
+		Message(_L("Error %d (in unknown state)"), aError);
+		break;
+		}
+	Stop();
+	iError = aError;
+	}
+	
+void CMmfPlayer::Message(TRefByValue<const TDesC> aFmt, ...)
+	{
+	if (iVerbose)
+		{
+		TDesC fmt(aFmt);
+		RBuf16 newText;
+		iMsgBuf.Zero();
+
+		TTruncateOverflow overflow;
+		VA_LIST list;
+		VA_START(list, aFmt);
+		iMsgBuf.AppendFormatList(aFmt, list, &overflow);
+		
+		iStdOut.Write(iMsgBuf);
+		iStdOut.Write(KNewLine);
+		}
+	}
+	
+void CMmfPlayer::Stop()
+	{
+	CActiveScheduler::Stop();
+	}
+
+EXE_BOILER_PLATE(CCmdPlay);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/play/play.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,101 @@
+// play.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __PLAY_H__
+#define __PLAY_H__
+
+#include <fshell/ioutils.h>
+#include <MdaAudioSampleEditor.h>
+
+using namespace IoUtils;
+
+class CMmfPlayer;
+
+class CCmdPlay	: public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdPlay();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	CCmdPlay();
+	void ConstructL();
+private:
+	CMmfPlayer* iPlayer;
+	TFileName2 iFile;
+	TInt iPriority;
+	TInt iPreference;
+	TInt iVolume;
+	TBool iVerbose;
+	TBool iMaxVolume;
+	};
+
+
+class CConsoleKeystrokeNotifier;
+
+class CMmfPlayer : public CActive, public MMdaObjectStateChangeObserver
+	{
+public:
+	static CMmfPlayer* NewL(RIoConsoleWriteHandle& aStdOut);
+	virtual ~CMmfPlayer();
+	
+	TInt GetMaxVolume();
+	TInt Error();
+	
+	void GetReady(const TDesC& aFileName, TBool aVerbose);
+	void SetPriority(TInt aPriority, TInt iPreference);
+	void SetVolume(TInt aVolume);
+	
+	virtual void RunL();
+	virtual TInt RunError(TInt aError);
+	virtual void DoCancel();
+	
+	virtual void MoscoStateChangeEvent(CBase *aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode);
+	
+	void KeyStroke(TKeyCode aCode);
+private:
+	CMmfPlayer(RIoConsoleWriteHandle& aStdOut);
+	void ConstructL();
+	void Message(TRefByValue<const TDesC> aFmt, ...);
+	void ProcessL();
+	void Error(TInt aError);
+	void Stop();
+private:
+	RIoConsoleWriteHandle& iStdOut;
+	TBuf<0x200> iMsgBuf;
+	
+	const TDesC* iFileName;
+	
+	enum TState
+		{
+		EInitial,
+		EOpening,
+		EPlaying,
+		};
+	TState iState;
+	
+	CMdaAudioRecorderUtility* iUtil;
+	TInt iVolume;
+	TBool iVerbose;
+	TInt iError;
+	};
+
+class TTruncateOverflow : public TDes16Overflow
+	{
+	virtual void Overflow(TDes16& /*aDes*/) {};
+	};
+	
+#endif // __PLAY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/play/play.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+// play.mmp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			play.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_PLAY
+SOURCEPATH 		.
+SOURCE			play.cpp
+USERINCLUDE		.
+#include <fshell/fsh_system_include.mmh>
+LIBRARY			euser.lib MediaClientAudio.lib bafl.lib mmfdevsound.lib
+library			iocli.lib
+
+CAPABILITY		FSHELL_CAP_MMP_NORMAL // Would like MultimediaDD (for system sounds), but still useful without.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/pointer/pointer.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# pointer.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name pointer
+
+==short-description
+
+Inject pointer events.
+
+==argument int x-pos
+
+The x coordinate of the event.
+
+==argument int y-pos
+
+The y coordinate of the event.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/pointer/pointer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,73 @@
+// pointer.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdPointer : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdPointer();
+private:
+	CCmdPointer();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TPoint iStart;
+	};
+
+EXE_BOILER_PLATE(CCmdPointer)
+
+CCommandBase* CCmdPointer::NewLC()
+	{
+	CCmdPointer* self = new(ELeave) CCmdPointer();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdPointer::~CCmdPointer()
+	{
+	}
+
+CCmdPointer::CCmdPointer()
+	{
+	}
+
+const TDesC& CCmdPointer::Name() const
+	{
+	_LIT(KName, "pointer");	
+	return KName;
+	}
+
+void CCmdPointer::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgXPos, "x-pos");
+	aArguments.AppendIntL(iStart.iX, KArgXPos);
+
+	_LIT(KArgYPos, "y-pos");
+	aArguments.AppendIntL(iStart.iY, KArgYPos);
+	}
+
+void CCmdPointer::DoRunL()
+	{
+	TRawEvent rawEvent;
+	rawEvent.Set(TRawEvent::EButton1Down, iStart.iX, iStart.iY);
+	LeaveIfErr(UserSvr::AddEvent(rawEvent), _L("Failed to add TRawEvent::EButton1Down event at %d, %d"), iStart.iX, iStart.iY);
+	rawEvent.Set(TRawEvent::EButton1Up, iStart.iX, iStart.iY);
+	LeaveIfErr(UserSvr::AddEvent(rawEvent), _L("Failed to add TRawEvent::EButton1Up event at %d, %d"), iStart.iX, iStart.iY);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/pointer/pointer.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// pointer.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			pointer.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_POINTER
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			Pointer.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/pubsub/pubsub.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+# pubsub.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name pubsub
+
+==short-description
+
+Get and set Publish and Subscribe (P&S) keys.
+
+==long-description
+
+To set integer key zero on category 0x12345678 to 6 (for example) run:
+
+  pubsub set 0x12345678 0 --int 6
+
+For P&S keys of type C<EByteArray>, C<ELargeByteArray>, C<EText> or C<ELargeText>, only the hexdump of the key is given because it is not possible to figure out which are text and which are binary data.
+
+==argument enum command
+
+The command to run.
+
+==enum-value get
+
+Get the value of the given key. Category and Key args must be specified.
+
+==enum-value set
+
+Sets the value. Category and key must be specified along with one of C<--int> or C<--string>.
+
+==enum-value define
+
+Like set, but defines the key first, if necessary, with an C<AlwaysPass> security policy.
+
+==enum-value notify
+
+Print when this value changes. Category and key must be specified.
+
+==argument uint category
+
+RProperty category UID, if applicable for the given command.
+
+==argument uint key
+
+The id of the key (if applicable) for the specified command.
+
+==option int i int
+
+Sets the specified property to this integer value.
+
+==option string s string
+
+Sets the specified property to this 16-bit descriptor value.
+
+==option bool f force
+
+Force read / set this property, disregarding the C<TSecurityPolicy> restrictions on the property. This option can be used with any of the commands. It uses C<RMemoryAccess> to manipulate an C<RPropertyRef> directly.
+
+==option bool b btrace
+
+When specified in conjunction with the C<notify> command, uses C<CBtracePubSub> to get the notifications instead of using C<RProperty::Subscribe> or C<memoryaccess>.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/pubsub/pubsub.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,438 @@
+// pubsub.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include <fshell/memoryaccesscmd.h>
+
+#ifdef FSHELL_TRACE_SUPPORT
+#include <fshell/extrabtrace.h>
+#include <fshell/btrace_parser.h>
+#endif
+
+#include <fshell/ltkutils.h>
+#include <fshell/qr3dll.h>
+
+using namespace IoUtils;
+
+#ifdef FSHELL_TRACE_SUPPORT
+class CCmdPubsub : public CMemoryAccessCommandBase, public MBtracePubSubObserver
+	{
+private: // From MBtracePubSubObserver
+	void HandlePropertyChangedL(const TBtraceTickCount& aTickCount, TUint aCategory, TUint aKey, TInt aNewValue);
+	void HandlePropertyChangedL(const TBtraceTickCount& aTickCount, TUint aCategory, TUint aKey, const TDesC8& aNewValue);
+
+#else
+class CCmdPubsub : public CMemoryAccessCommandBase
+	{
+#endif
+public:
+	static CCommandBase* NewLC();
+	~CCmdPubsub();
+
+private:
+	CCmdPubsub();
+	void PrintKey(TUint aCategory, TUint aKey, TBool aFull=EFalse);
+	template <class KEYTYPE>
+	void SetKeyL(const KEYTYPE& aVal);
+	static TInt PropertyChanged(TAny* aSelf);
+	void GetAllL(TBool aNotify);
+	TBool IsExcluded(TUint aCat, TUint aKey) const;
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	void DoCancel();
+	void RunL();
+
+private:
+	// Arguments
+	enum TCmd
+		{
+		EGet, ESet, EDefine, ENotify
+		};
+	TCmd iCommand;
+	TUid iCategory;
+	TUint iKey;
+	// Options
+	HBufC* iStringVal;
+	TInt iIntVal;
+	TBool iForce;
+
+	TBool iNotify;
+	TBool iDefine;
+
+	// Other assorted stuff
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TPropNotifyResult iNotifyResult;
+#endif
+#ifdef FSHELL_TRACE_SUPPORT
+	CBtraceReader* iReader;
+	CBtracePubSub* iPubSub;
+#endif
+	TBool iUseBtrace;
+	CPropertyManager* iPropertyManager;
+	RBuf8 iValDescription;
+	};
+
+CCommandBase* CCmdPubsub::NewLC()
+	{
+	CCmdPubsub* self = new(ELeave) CCmdPubsub();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdPubsub::~CCmdPubsub()
+	{
+	Cancel();
+	delete iStringVal;
+#ifdef FSHELL_TRACE_SUPPORT
+	delete iPubSub;
+	delete iReader;
+#endif
+	delete iPropertyManager;
+	iValDescription.Close();
+	}
+
+CCmdPubsub::CCmdPubsub()
+	: CMemoryAccessCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdPubsub::Name() const
+	{
+	_LIT(KName, "pubsub");	
+	return KName;
+	}
+
+void CCmdPubsub::DoRunL()
+	{
+#if defined (FSHELL_MEMORY_ACCESS_SUPPORT)
+	if (iForce || iUseBtrace)
+		{
+		// In order to implement the --force option, we talk to the memaccess device driver, which uses an RPropertyRef
+		// that isn't subject to security checks
+		LoadMemoryAccessL();
+		}
+#endif
+
+	iValDescription.CreateL(RProperty::KMaxLargePropertySize);
+
+	/*
+	if (iDelete)
+		{
+		if (!iArgList->IsPresent(1))
+			{
+			// Delete all not supported for pubsub
+			PrintError(KErrArgument, _L("You must specify a key for the delete option"));
+			User::Leave(KErrArgument);
+			}
+		else
+			{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+			if (iForce)
+				{
+				err = iMemAccess.DeleteProperty(iCategory, iKey);
+				}
+			else
+#endif
+				{
+				err = RProperty::Delete(iCategory, iKey);
+				}
+			}
+		if (err == KErrPermissionDenied)
+			{
+			PrintError(err, _L("Delete failed, retry with --force"));
+			}
+		User::LeaveIfError(err);
+		}
+	*/
+	if (iCommand == EDefine) iDefine = ETrue;
+	if (iCommand == ENotify) iNotify = ETrue;
+
+	if ((iCommand == ESet) || iDefine)
+		{
+		if (iOptions.IsPresent(&iIntVal))
+			{
+			// Set int
+			SetKeyL(iIntVal);
+			}
+		else if (iOptions.IsPresent(&iStringVal))
+			{
+			// Set string
+			TPtrC8 data((TUint8*)iStringVal->Ptr(), iStringVal->Size());
+			SetKeyL(data);
+			}
+		else
+			{
+			LeaveIfErr(KErrArgument, _L("set/define command requires --int or --string arguments"));
+			}
+		}
+	else if ((iCommand == EGet) || iNotify)
+		{
+		// Get
+		if (!iArguments.IsPresent(1))
+			LeaveIfErr(KErrArgument, _L("get command requires key and category"));
+		PrintKey(iCategory.iUid, iKey, ETrue);
+
+		if (iNotify)
+			{
+#if defined (FSHELL_MEMORY_ACCESS_SUPPORT)
+			if (iForce || iUseBtrace)
+				{
+				//TPckgBuf<SKeyPair> key;
+				//key().iCat = iCategory.iUid;
+				//key().iKey = iKey;
+				//LeaveIfErr(iMemAccess.SetupMassPropertyNotify(key), _L("Couldn't set up notification"));
+				LeaveIfErr(iMemAccess.SubscribeToProperty(iCategory, iKey, iUseBtrace), _L("Couldn't subscribe to property"));
+#ifdef FSHELL_TRACE_SUPPORT
+				if (iUseBtrace)
+					{
+					const TInt KFlushInterval = 1000000; // 1s
+					const TInt KBtraceBufferSize = 1 * 1024 * 1024;
+					TRAPL(iReader = CBtraceReader::NewL(CBtraceReader::EFlushOnBtraceThreshold, KBtraceBufferSize, KBtraceBufferSize / 2), _L("Couldn't create btrace reader"));
+					TRAPL(iPubSub = CBtracePubSub::NewL(*iReader), _L("Couldn't create CBtracePubSub"));
+					TBtraceTickCount now;
+					now.SetToNow();
+					iReader->Start(now, KFlushInterval);
+					iPubSub->NotifyPropertyChangedL(*this);
+					return; // iPubSub will take it from here
+					}
+				else
+#endif
+					{
+					iMemAccess.NotifyPropertyChange(iNotifyResult, iStatus);
+					SetActive();
+					}
+				}
+			else
+#endif
+				{
+				iPropertyManager = CPropertyManager::NewL(TCallBack(&PropertyChanged, this));
+				iPropertyManager->ChangeProperty(iCategory.iUid, iKey);
+				}
+			return; // Don't complete
+			}
+		}
+	Complete();
+	}
+
+template <class KEYTYPE>
+void CCmdPubsub::SetKeyL(const KEYTYPE& aVal)
+	{
+	if (!iArguments.IsPresent(1))
+		{
+		LeaveIfErr(KErrArgument, _L("You must specify a key to set"));
+		}
+	TInt err = KErrNone;
+#if defined (FSHELL_MEMORY_ACCESS_SUPPORT)
+	if (iForce)
+		{
+		err = iMemAccess.SetProperty(iCategory, iKey, aVal);
+		}
+	else
+#endif
+		{
+		err = RProperty::Set(iCategory, iKey, aVal);
+		if (err == KErrArgument)
+			{
+			LeaveIfErr(err, _L("Key does not appear to be of the right type"));
+			}
+		}
+
+#if defined (FSHELL_MEMORY_ACCESS_SUPPORT)
+	if (err == KErrNotFound && iDefine)
+		{
+		if (!iForce)
+			{
+			LeaveIfErr(err, _L("Key does not exist, cannot define it unless --force is also specified"));
+			}
+		err = iMemAccess.SetProperty(iCategory, iKey, aVal, ETrue);
+		}
+#endif
+	if (err)
+		{
+		LeaveIfErr(err, _L("Error setting key"));
+		}
+	}
+
+void CCmdPubsub::PrintKey(TUint aCategory, TUint aKey, TBool aFull)
+	{
+	TUid cat = { aCategory };
+	TInt valInt;
+	RBuf8& valDes = iValDescription;
+	valDes.Zero();
+	enum TType { EUnknown, EInt, EDes };
+	TType type = EUnknown;
+	TInt reallen = 0;
+
+	TInt err = KErrNotFound;
+
+#if defined (FSHELL_MEMORY_ACCESS_SUPPORT)
+	if (iForce)
+		{
+		err = iMemAccess.GetProperty(cat, aKey, valInt);
+		if (err == KErrNone)
+			{
+			type = EInt;
+			}
+		else
+			{
+			err = iMemAccess.GetProperty(cat, aKey, valDes, reallen);
+			type = EDes;
+			}
+		}
+	else
+#endif
+		{
+		// Guess the value type
+		// Int?
+		if (type == EUnknown)
+			{
+			err = RProperty::Get(cat, aKey, valInt);
+			if (err != KErrArgument)
+				{
+				type = EInt;
+				}
+			}
+		
+		if (type == EUnknown)
+			{
+			// Des?
+			err = RProperty::Get(cat, aKey, valDes);
+			if (err != KErrArgument)
+				{
+				type = EDes;
+				}
+			}
+		}
+
+	switch(err)
+		{
+		case KErrNotFound:
+			PrintError(err, _L("Key 0x%x 0x%x not found"), aCategory, aKey);
+			break;
+		case KErrArgument:
+			PrintError(err, _L("Unknown key type, not int, des8 or des16"));
+			break;
+		case KErrPermissionDenied:
+			PrintError(err, _L("Permission denied on 0x%x 0x%x, retry with --force"), aCategory, aKey);
+			break;
+		case KErrNone:
+			// do nothing
+			break;
+		default:
+			PrintError(err, _L("Unrecognised error returned from RProperty"));
+			break;
+		}
+
+	if (err == KErrNone)
+		{
+		switch (type)
+			{
+			case EInt:
+				Printf(_L("0x%08x 0x%08x TInt: %d (0x%x)\r\n"), aCategory, aKey, valInt, valInt);
+				break;
+			case EDes:
+				{
+				TPtrC8 des(valDes);
+				if (!aFull) des.Set(valDes.Left(32)); // Don't print the whole thing, only 2 lines max
+				Printf(_L("0x%08x 0x%08x TDesC8 hex dump:\r\n"), aCategory, aKey);
+				LtkUtils::HexDumpToOutput(des, Stdout());
+				if (des.Length() < valDes.Length()) Write(_L("...\r\n"));
+				break;
+				}
+			default:
+				break;
+			}
+		}
+	}
+	
+void CCmdPubsub::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCommand, _L("command"));
+	aArguments.AppendUintL((TUint&)iCategory.iUid, _L("category"));
+	aArguments.AppendUintL(iKey, _L("key"));
+	}
+
+void CCmdPubsub::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendIntL(iIntVal, _L("int"));
+	aOptions.AppendStringL(iStringVal, _L("string"));
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	aOptions.AppendBoolL(iForce, _L("force"));
+#endif
+#ifdef FSHELL_TRACE_SUPPORT
+	aOptions.AppendBoolL(iUseBtrace, _L("btrace"));
+#endif
+	//aOptions.AppendStringL(iStringVal, '8', _L("set-data"), _L("Sets the specified key to this 8-bit value"));
+	//aOptions.AppendBoolL(iDelete, 'l', _L("delete"), _L("Deletes the specified property"));
+	}
+
+TInt CCmdPubsub::PropertyChanged(TAny* aSelf)
+	{
+	CCmdPubsub* self = static_cast<CCmdPubsub*>(aSelf);
+	self->PrintKey(self->iCategory.iUid, self->iKey);
+	return 0;
+	}
+
+EXE_BOILER_PLATE(CCmdPubsub)
+
+void CCmdPubsub::DoCancel()
+	{
+#if defined (FSHELL_MEMORY_ACCESS_SUPPORT)
+	iMemAccess.CancelPropertyChange();
+#endif
+	}
+
+void CCmdPubsub::RunL()
+	{
+#if defined (FSHELL_MEMORY_ACCESS_SUPPORT)
+
+	TPropNotifyResult notifyResult = iNotifyResult;
+	// rerequest asap
+	if (iStatus == KErrNone)
+		{
+		iMemAccess.NotifyPropertyChange(iNotifyResult, iStatus);
+		SetActive();
+		}
+
+	if (notifyResult.iMissedChanges)
+		{
+		PrintWarning(_L("Missed %d publish and subscribe notifications"), notifyResult.iMissedChanges);
+		}
+
+	if (notifyResult.iError)
+		{
+		Printf(_L("NotifyChange for 0x%08x 0x%x completed with error %d\r\n"), notifyResult.iCategory, notifyResult.iKey, notifyResult.iError);
+		}
+	else
+		{
+		//Printf(_L("P&S Key changed:\r\n"));
+		PrintKey(notifyResult.iCategory, notifyResult.iKey);
+		}
+#endif
+	}
+
+#ifdef FSHELL_TRACE_SUPPORT
+void CCmdPubsub::HandlePropertyChangedL(const TBtraceTickCount&, TUint aCategory, TUint aKey, TInt /*aNewValue*/)
+	{
+	PrintKey(aCategory, aKey);
+	}
+
+void CCmdPubsub::HandlePropertyChangedL(const TBtraceTickCount&, TUint aCategory, TUint aKey, const TDesC8& /*aNewValue*/)
+	{
+	PrintKey(aCategory, aKey);
+	}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/pubsub/pubsub.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// pubsub.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          pubsub.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_PUBSUB
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          pubsub.cpp
+
+library         euser.lib
+library         iocli.lib
+library         qr3.lib
+library         ltkutils.lib
+library         btrace_parser.lib
+FSHELL_TRACE_CONTROL_LIBRARY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ramdefrag/ramdefrag.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,54 @@
+# ramdefrag.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name ramdefrag
+
+==short-description
+
+Initiates RAM defragmentation.
+
+==long-description
+
+Triggers a RAM defrag by getting C<memoryaccess> to call C<TRamDefragRequest>. Returns once the defrag is complete. Also can be used to get RAM zone statistics or to call C<EmptyRamZone>.
+
+==argument enum command optional
+
+The command to execute. If not specified, defaults to C<defrag>.
+
+==enum-value defrag
+
+Calls C<TRamDefragRequest::DefragRam>.
+
+==enum-value empty
+
+Calls C<EmptyRamZone> on the given zone(s).
+
+==enum-value info
+
+Prints some statistics about the given zone.
+
+==argument uint zone multiple optional
+
+Zone to operate on. Only applicable for C<empty> or C<info> commands. Zone IDs are different for each baseport and hardware variant so don't use this option unless you really know what you're doing.
+
+==option int p priority
+
+The thread priority at which to run the defrag. If not specified, defaults to the priority of the C<memoryaccess> DFC thread (currently 27).
+
+==option bool c csv
+
+Print zone info statistics in CSV format.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ramdefrag/ramdefrag.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,129 @@
+// ramdefrag.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/memoryaccesscmd.h>
+
+using namespace IoUtils;
+
+class CCmdRamDefrag : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRamDefrag();
+private:
+	CCmdRamDefrag();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TCmd
+		{
+		EDefrag,
+		EEmptyZone,
+		EZoneInfo,
+		};
+	TCmd iCmd;
+	RArray<TUint> iZones;
+	TInt iPriority;
+	TBool iCsv;
+	};
+
+EXE_BOILER_PLATE(CCmdRamDefrag)
+
+CCommandBase* CCmdRamDefrag::NewLC()
+	{
+	CCmdRamDefrag* self = new(ELeave) CCmdRamDefrag();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRamDefrag::~CCmdRamDefrag()
+	{
+	iZones.Close();
+	}
+
+CCmdRamDefrag::CCmdRamDefrag()
+	: iPriority(-1)
+	{
+	}
+
+const TDesC& CCmdRamDefrag::Name() const
+	{
+	_LIT(KName, "ramdefrag");
+	return KName;
+	}
+
+void CCmdRamDefrag::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCmd, _L("command"));
+	aArguments.AppendUintL(iZones, _L("zone"));
+	}
+
+void CCmdRamDefrag::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendIntL(iPriority, _L("priority"));
+	aOptions.AppendBoolL(iCsv, _L("csv"));
+	}
+
+void CCmdRamDefrag::DoRunL()
+	{
+	LoadMemoryAccessL();
+
+	switch (iCmd)
+		{
+		case EDefrag:
+			LeaveIfErr(iMemAccess.DefragRam(iPriority), _L("Couldn't defrag RAM."));
+			break;
+		case EEmptyZone:
+			{
+			if (iZones.Count() == 0) LeaveIfErr(KErrArgument, _L("Must specify at least one zone to empty."));
+			for (TInt i = 0; i < iZones.Count(); i++)
+				{
+				TUint zone = iZones[i];
+				TInt err = iMemAccess.EmptyRamZone(zone, iPriority);
+				if (err) PrintError(err, _L("Failed to empty RAM zone %u"), zone);
+				}
+			break;
+			}
+		case EZoneInfo:
+			if (iZones.Count() == 0) LeaveIfErr(KErrArgument, _L("Must specify at least one zone."));
+			if (iCsv) Printf(_L("Zone,Discardable pages,Fixed pages,Free pages,Movable pages,Unknown pages\r\n"));
+
+			for (TInt i = 0; i < iZones.Count(); i++)
+				{
+				TUint zone = iZones[i];
+				TRamZoneInfo info;
+				TPckg<TRamZoneInfo> infoPkg(info);
+				TInt err = iMemAccess.GetRamZoneInfo(zone, infoPkg);
+				if (err)
+					{
+					PrintError(err, _L("Failed to get info for RAM zone %u"), zone);
+					}
+				else
+					{
+					if (iCsv)
+						{
+						Printf(_L("%u,%d,%d,%d,%d,%d\r\n"), zone, info.iDiscardablePages, info.iFixedPages, info.iFreePages, info.iMovablePages, info.iUnknownPages);
+						}
+					else
+						{
+						Printf(_L("Zone %u:\r\nDiscardable pages: %d\r\nFixed pages: %d\r\nFree pages: %d\r\nMovable pages: %d\r\nUnknown pages: %d\r\n\r\n"), zone, info.iDiscardablePages, info.iFixedPages, info.iFreePages, info.iMovablePages, info.iUnknownPages);
+						}
+					}
+				}
+			break;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/ramdefrag/ramdefrag.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// ramdefrag.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			fshell_ramdefrag.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_RAMDEFRAG
+
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			ramdefrag.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rcomm/rcomm.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,76 @@
+# rcomm.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name rcomm
+
+==short-description
+
+Get info about supported serial channels, or read / write to them.
+
+==long-description
+
+A command for reading data from or writing data to a serial comms port. With no arguments (or just a CSY name) lists all ports (on the given CSY).
+
+==see-also
+
+L<rsocket|rsocket>, L<rconn|rconn>, L<iap|iap>
+
+==argument string csy_name optional
+
+The name of the C32 plug-in module to load, e.g. C<ECUART.CSY>. If not specified, information about all the currently loaded CSY modules is displayed.
+
+==argument string port_name optional
+
+The name of the port, e.g. C<COMM::0>. If not specified, information about the CSY is displayed.
+
+==argument string mode optional
+
+The mode of operation.
+
+=over 5
+
+=item * C<read>
+
+Read the port and write the results to STDOUT.
+
+=item * C<write>
+
+Read STDIN and write the results to the port.
+
+=back
+
+==option uint a access
+
+The access mode to open the port in as defined by C<TCommAccess> in F<c32comm.h>:
+
+  0  ECommExclusive
+  1  ECommShared
+  2  ECommPreemptable
+
+If not specified, defaults to C<ECommShared>.
+
+==option uint b buffer
+
+The size of buffer to use for either reading or writing. If not specified, defaults to 1 KB.
+
+==option bool r raw
+
+Ordinarily reads from the comm port will be expanded from 8 bit data to 16 bit data (i.e. it is assumed the data be read is ASCII). Likewise, writes will be collapsed from 16 bit to 8 bit. This option disables the expansion and collapse functionality.
+
+==option bool v verbose
+
+Print verbose output.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rcomm/rcomm.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,276 @@
+// rcomm.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <c32comm.h>
+
+using namespace IoUtils;
+
+class CCmdRcomm : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRcomm();
+private:
+	CCmdRcomm();
+	void ReadL();
+	void WriteL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	HBufC* iCsyName;
+	HBufC* iPortName;
+	HBufC* iMode;
+	TCommAccess iCommAccess;
+	TUint iBufSize;
+	TBool iRaw;
+	TBool iVerbose;
+	RCommServ iCommServ;
+	RComm iComm;
+	};
+
+
+CCommandBase* CCmdRcomm::NewLC()
+	{
+	CCmdRcomm* self = new(ELeave) CCmdRcomm();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRcomm::~CCmdRcomm()
+	{
+	delete iCsyName;
+	delete iPortName;
+	delete iMode;
+	iComm.Close();
+	iCommServ.Close();
+	}
+
+CCmdRcomm::CCmdRcomm()
+	: iCommAccess(ECommShared), iBufSize(1024)
+	{
+	}
+
+const TDesC& CCmdRcomm::Name() const
+	{
+	_LIT(KName, "rcomm");	
+	return KName;
+	}
+
+void CCmdRcomm::DoRunL()
+	{
+	User::LeaveIfError(iCommServ.Connect());
+
+	if (iCsyName)
+		{
+		TInt err = iCommServ.LoadCommModule(*iCsyName);
+		if (err && (err != KErrAlreadyExists))
+			{
+			PrintError(err, _L("Unable to load comm module \'%S\'"), iCsyName);
+			User::Leave(err);
+			}
+		}
+	else
+		{
+		TInt numPorts;
+		User::LeaveIfError(iCommServ.NumPorts(numPorts));
+		for (TInt i = 0; i < numPorts; ++i)
+			{
+			TName moduleName;
+			TSerialInfo serialInfo;
+			TInt err = iCommServ.GetPortInfo(i, moduleName, serialInfo);
+			if (err == KErrNone)
+				{
+				Printf(_L("%S:\r\n\tPort name: \'%S\'\r\n\tLow unit: %d\r\n\tHigh unit: %d\r\n\tDescription: %S\r\n\r\n"), &moduleName, &serialInfo.iName, serialInfo.iLowUnit, serialInfo.iHighUnit, &serialInfo.iDescription);
+				}
+			else
+				{
+				PrintWarning(_L("Couldn't get info for port %d, err=%d"), i, err);
+				}
+			}
+		return;
+		}
+
+	if (iPortName)
+		{
+		TInt err = iComm.Open(iCommServ, *iPortName, iCommAccess);
+		LeaveIfErr(err, _L("Unable to open port \'%S\'"), iPortName);
+		}
+	else
+		{
+		TSerialInfo serialInfo;
+		_LIT(KCsy, ".csy");
+		TPtrC csyName(*iCsyName);
+		if (csyName.Right(KCsy().Length()).CompareF(KCsy) == 0)
+			{
+			// Remove the trailing '.csy' because otherwise C32 won't find the module.
+			csyName.Set(csyName.Left(csyName.Length() - KCsy().Length()));
+			}
+		TInt err = iCommServ.GetPortInfo(csyName, serialInfo);
+		LeaveIfErr(err, _L("Couldn't get port info for CSY '%S'"), &csyName);
+		Printf(_L("Port name: \'%S\'\r\nLow unit: %d\r\nHigh unit: %d\r\nDescription: %S\r\n"), &serialInfo.iName, serialInfo.iLowUnit, serialInfo.iHighUnit, &serialInfo.iDescription);
+		return;
+		}
+
+
+	_LIT(KModeRead, "read");
+	_LIT(KModeWrite, "write");
+	if (iMode)
+		{
+		if (*iMode == KModeRead)
+			{
+			ReadL();
+			}
+		else if (*iMode == KModeWrite)
+			{
+			WriteL();
+			}
+		else
+			{
+			PrintError(KErrArgument, _L("Invalid mode: \'%S\'"), iMode);
+			}
+		}
+	}
+
+void CCmdRcomm::ReadL()
+	{
+	if (iRaw)
+		{
+		HBufC8* readBuf = HBufC8::NewLC(iBufSize);
+		TPtr8 readBufPtr(readBuf->Des());
+		TInt err = KErrNone;
+		while (err == KErrNone)
+			{
+			TRequestStatus status;
+			iComm.ReadOneOrMore(status, readBufPtr);
+			User::WaitForRequest(status);
+			err = status.Int();
+			if (err == KErrNone)
+				{
+				TPtrC writePtr((TUint16*)readBuf->Ptr(), readBuf->Length() / 2);
+				Write(writePtr);
+				}
+			else if (iVerbose)
+				{
+				PrintWarning(_L("RComm::ReadOneOrMore failed with %d"), err);
+				}
+			}
+		CleanupStack::PopAndDestroy(readBuf);
+		}
+	else
+		{
+		HBufC8* readBuf = HBufC8::NewLC(iBufSize);
+		TPtr8 readBufPtr(readBuf->Des());
+		HBufC* writeBuf = HBufC::NewLC(iBufSize / 2);
+		TPtr writeBufPtr(writeBuf->Des());
+		TInt err = KErrNone;
+		while (err == KErrNone)
+			{
+			TRequestStatus status;
+			iComm.ReadOneOrMore(status, readBufPtr);
+			User::WaitForRequest(status);
+			err = status.Int();
+			if (err == KErrNone)
+				{
+				writeBufPtr.Copy(*readBuf);
+				Write(*writeBuf);
+				}
+			else if (iVerbose)
+				{
+				PrintWarning(_L("RComm::ReadOneOrMore failed with %d"), err);
+				}
+			}
+		CleanupStack::PopAndDestroy(2, readBuf);
+		}
+	}
+
+void CCmdRcomm::WriteL()
+	{
+	RIoConsoleReadHandle& stdin = Stdin();
+	User::LeaveIfError(stdin.SetReadMode(RIoReadHandle::EOneOrMore));
+
+	if (iRaw)
+		{
+		HBufC* readBuf = HBufC::NewLC(iBufSize / 2);
+		TPtr readBufPtr(readBuf->Des());
+		TInt err = KErrNone;
+		while (err == KErrNone)
+			{
+			err = stdin.Read(readBufPtr);
+			if (err == KErrNone)
+				{
+				TPtrC8 writePtr((TUint8*)readBuf->Ptr(), readBuf->Size());
+				TRequestStatus status;
+				iComm.Write(status, writePtr);
+				User::WaitForRequest(status);
+				LeaveIfErr(status.Int(), _L("RComm::Write failed with %d"), status.Int());
+				}
+			}
+		CleanupStack::PopAndDestroy(readBuf);
+		}
+	else
+		{
+		HBufC* readBuf = HBufC::NewLC(iBufSize / 2);
+		TPtr readBufPtr(readBuf->Des());
+		HBufC8* writeBuf = HBufC8::NewLC(iBufSize);
+		TPtr8 writeBufPtr(writeBuf->Des());
+		TInt err = KErrNone;
+		while (err == KErrNone)
+			{
+			err = stdin.Read(readBufPtr);
+			if (err == KErrNone)
+				{
+				writeBufPtr.Copy(*readBuf);
+				TRequestStatus status;
+				iComm.Write(status, *writeBuf);
+				User::WaitForRequest(status);
+				LeaveIfErr(status.Int(), _L("RComm::Write failed with %d"), status.Int());
+				}
+			}
+		CleanupStack::PopAndDestroy(2, readBuf);
+		}
+	}
+
+void CCmdRcomm::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg1, "csy_name");
+	aArguments.AppendStringL(iCsyName, KArg1);
+
+	_LIT(KArg2, "port_name");
+	aArguments.AppendStringL(iPortName, KArg2);
+
+	_LIT(KArg3, "mode");
+	aArguments.AppendStringL(iMode, KArg3);
+	}
+
+void CCmdRcomm::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOption1, "access");
+	aOptions.AppendUintL((TUint&)iCommAccess, KOption1);
+
+	_LIT(KOption2, "buffer");
+	aOptions.AppendUintL(iBufSize, KOption2);
+
+	_LIT(KOption3, "raw");
+	aOptions.AppendBoolL(iRaw, KOption3);
+
+	_LIT(KOption4, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOption4);
+	}
+
+
+EXE_BOILER_PLATE(CCmdRcomm)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rcomm/rcomm.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// rcomm.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          rcomm.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_RCOMM
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          rcomm.cpp
+
+library         euser.lib
+library         iocli.lib
+library         c32.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rconn/rconn.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# rconn.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name rconn
+
+==short-description
+
+Enumerate and control network connections.
+
+==see-also
+
+L<rsocket|rsocket>, L<rcomm|rcomm>, L<iap|iap>
+
+==argument enum operation optional
+
+The operation required. Defaults to C<list>.
+
+==enum-value list
+
+List the currently active connections.
+
+==enum-value start
+
+Start a new connection.
+
+==enum-value stop
+
+Stop an existing connection.
+
+==option uint i iap
+
+The Internet Access Provider identifier to use.
+
+==option uint n network
+
+The network identifier to use.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rconn/rconn.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,203 @@
+// rconn.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#undef SYMBIAN_ENABLE_SPLIT_HEADERS // Stopgap to handle TConnectionInfoV2 being moved in latest TB92
+
+#include <fshell/ioutils.h>
+#include <es_sock.h>
+#include <es_enum.h>
+#include <nifvar.h>
+#include <commdbconnpref.h>
+
+using namespace IoUtils;
+
+class CCmdRconn : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRconn();
+private:
+	CCmdRconn();
+	void ListConnectionsL();
+	void StartConnectionL();
+	void StopConnectionL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RSocketServ iSocketSession;
+	RConnection iConnection;
+	enum 
+		{
+		EList, EStart, EStop
+		} iOperation;
+	TUint iIapId;
+	TUint iNetworkId;
+	};
+
+
+CCommandBase* CCmdRconn::NewLC()
+	{
+	CCmdRconn* self = new(ELeave) CCmdRconn();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRconn::~CCmdRconn()
+	{
+	iConnection.Close();
+	iSocketSession.Close();
+	}
+
+CCmdRconn::CCmdRconn()
+	{
+	}
+
+const TDesC& CCmdRconn::Name() const
+	{
+	_LIT(KName, "rconn");	
+	return KName;
+	}
+
+#define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
+#define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
+
+const TDesC* StringifyConnectionType(TConnectionType aConnectionType)
+	{
+	enum TConnectionType_NotPresentInTB92
+		{
+		EConnectionCDMA = 2500,
+		EConnectionCDMA20001xRTT,
+		EConnectionCDMA20001xRTTDO,
+		EConnectionCDMA20001xRTTDV,
+		EConnectionCDMA20003xRTT,
+		};
+		
+	switch (aConnectionType)
+		{
+		CASE_RETURN_LIT(EConnectionGeneric);
+		CASE_RETURN_LIT(EConnectionCSD);
+		CASE_RETURN_LIT(EConnectionGPRS);
+		CASE_RETURN_LIT(EConnectionGPRSR97);
+		CASE_RETURN_LIT(EConnectionGPRSR99);
+		CASE_RETURN_LIT(EConnectionGPRSRel4);
+		CASE_RETURN_LIT(EConnectionGPRSRel5);
+		CASE_RETURN_LIT(EConnectionCDMA);
+		CASE_RETURN_LIT(EConnectionCDMA20001xRTT);
+		CASE_RETURN_LIT(EConnectionCDMA20001xRTTDO);
+		CASE_RETURN_LIT(EConnectionCDMA20001xRTTDV);
+		CASE_RETURN_LIT(EConnectionCDMA20003xRTT);
+		CASE_RETURN_LIT(EConnectionEthernet);
+		CASE_RETURN_LIT(EConnectionWLAN);
+		CASE_RETURN_LIT(EConnectionBTPAN);
+		DEFAULT_RETURN_LIT("Unknown");
+		}
+	}
+
+void CCmdRconn::DoRunL()
+	{
+	LeaveIfErr(iSocketSession.Connect(), _L("Couldn't open socket server session"));
+	LeaveIfErr(iConnection.Open(iSocketSession), _L("Couldn't open connection handle"));
+
+	if (!iArguments.IsPresent(0)) iOperation = EList;
+	switch (iOperation)
+		{
+	case EList:
+		ListConnectionsL();
+		break;
+	case EStart:
+		StartConnectionL();
+		break;
+	case EStop:
+		StopConnectionL();
+		break;
+		}
+	}
+
+void CCmdRconn::ListConnectionsL()
+	{
+	TUint numConnections;
+	LeaveIfErr(iConnection.EnumerateConnections(numConnections), _L("Couldn't enumerate connections"));
+
+	if (numConnections <= 0)
+		{
+		Write(_L("No connections currently up.\r\n"));
+		}
+	else
+		{
+		IoUtils::CTextFormatter* formatter = CTextFormatter::NewLC(Stdout());
+		IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x100);
+		buf->AppendFormatL(_L("IAP\tNetwork\tType\r\n"));
+		for (TInt i = 1; i <= numConnections; ++i)
+			{
+			TConnectionInfoV2Buf connectionInfoBuf;
+			LeaveIfErr(iConnection.GetConnectionInfo(i, connectionInfoBuf), _L("Couldn't get connection info (%d of %d)"), i, numConnections);
+			TConnectionInfoV2& info = connectionInfoBuf();
+			buf->AppendFormatL(_L("%d\t%d\t%S\r\n"), info.iIapId, info.iNetId, StringifyConnectionType(info.ConnectionType()));
+			}
+		formatter->TabulateL(0, 2, buf->Descriptor());
+		Write(formatter->Descriptor());
+		CleanupStack::PopAndDestroy(2, formatter);
+		}
+	}
+
+void CCmdRconn::StartConnectionL()
+	{
+	TCommDbConnPref prefs;
+	if (iIapId > 0)
+		{
+		prefs.SetIapId(iIapId);
+		prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+		}
+	if (iNetworkId > 0)
+		{
+		prefs.SetNetId(iNetworkId);
+		}
+	LeaveIfErr(iConnection.Start(prefs), _L("Failed to start connection"));
+	}
+
+void CCmdRconn::StopConnectionL()
+	{
+	TConnectionInfo connectionInfo;
+	if (iIapId > 0)
+		{
+		connectionInfo.iIapId = iIapId;
+		}
+	if (iNetworkId > 0)
+		{
+		connectionInfo.iNetId = iNetworkId;
+		}
+	TPckgC<TConnectionInfo> connectionInfoPckg(connectionInfo);
+	LeaveIfErr(iConnection.Attach(connectionInfoPckg, RConnection::EAttachTypeNormal), _L("Unable to attach to connection"));
+	LeaveIfErr(iConnection.Stop(), _L("Unable to stop connection"));
+	}
+
+void CCmdRconn::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptIapId, "iap");
+	aOptions.AppendUintL(iIapId, KOptIapId);
+
+	_LIT(KOptNetworkId, "network");
+	aOptions.AppendUintL(iNetworkId, KOptNetworkId);
+	}
+
+void CCmdRconn::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgOperation, "operation");
+	aArguments.AppendEnumL((TInt&)iOperation, KArgOperation);
+	}
+
+EXE_BOILER_PLATE(CCmdRconn)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rconn/rconn.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// rconn.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          rconn.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_RCONN
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          rconn.cpp
+
+library         euser.lib
+library         iocli.lib
+library         esock.lib
+library		commdb.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/restore/restore.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+# restore.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name restore
+
+==short-description
+
+Put the handset into restore mode.
+
+==long-description
+
+A means of requesting backup aware modules to close their file handles. Note, this command does not actually B<perform> a restore, it merely prepares the system for one.
+
+==see-also
+
+L<backup|backup>
+
+==argument enum operation
+
+The required operation.
+
+==enum-value start
+
+Request that all backup aware modules release their file handles and prepare for a restore.
+
+==enum-value stop
+
+Request that all backup aware modules reclaim their files.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/restore/restore.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,210 @@
+// restore.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "restore.h"
+
+_LIT(KRestoreOp,	"-r");
+
+//
+// CRestoreDriver
+//
+CRestoreDriver* CRestoreDriver::NewL(MBackupParent& aParent)
+	{
+	CRestoreDriver* self = new (ELeave) CRestoreDriver(aParent);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CRestoreDriver::CRestoreDriver(MBackupParent& aParent):
+CActive(CActive::EPriorityStandard), iParent(aParent)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CRestoreDriver::~CRestoreDriver()
+	{
+	Cancel();
+	}
+
+void CRestoreDriver::ConstructL()
+	{
+	}
+
+void CRestoreDriver::SendInstructionL(MBackupObserver::TFileLockFlags aInstruction)
+	{
+	iInstruction = aInstruction;
+	switch (iInstruction)
+		{
+		case MBackupObserver::EReleaseLockNoAccess:
+			LaunchProcessL();
+		break;
+
+		case MBackupObserver::ETakeLock:
+			TerminateProcessL();
+		break;
+
+		default:
+			User::Leave(KErrNotSupported);
+		break;		
+		};
+	}
+
+//
+// CRestoreDriver::ChildProcessExists
+// checks whether the backup_child process
+// is already running
+//
+TBool CRestoreDriver::ChildProcessExists()
+	{
+	_LIT(KWildCard, "*");
+	TName woop(KBackupProcessName);
+	woop.Append(KWildCard);
+	TFindProcess check(woop);
+	TFullName name;
+	TInt result = check.Next(name);
+	if (result == KErrNone)
+		return ETrue;	
+	return EFalse;
+	}
+
+//
+// CRestoreDriver::LaunchProcessL
+// spawns the backup_child process
+// & waits to rendezvous
+//
+void CRestoreDriver::LaunchProcessL()
+	{
+	if (ChildProcessExists())
+		User::Leave(KErrInUse);
+	
+	_LIT(KExeExt, ".exe");
+	TName name(KBackupProcessName);
+	name.Append(KExeExt);
+	User::LeaveIfError(iChild.Create(name, KRestoreOp, EOwnerProcess));
+	iChild.Resume();
+	iChild.Rendezvous(iStatus);
+	SetActive();
+	}
+
+//
+// CRestoreDriver::TerminateProcessL
+// open the backup_child process & signal it's semaphore
+// that semaphore is the signal to shut itself down cleanly
+//
+void CRestoreDriver::TerminateProcessL()
+	{
+	if (!ChildProcessExists())
+		User::Leave(KErrNotFound);
+	
+	// signal the semaphore 
+	RSemaphore sem;
+	User::LeaveIfError(sem.OpenGlobal(KBackupSemaphore, EOwnerProcess));
+	sem.Signal();
+
+	SelfComplete(KErrNone);
+	}
+
+void CRestoreDriver::SelfComplete(const TInt aError)
+	{
+	ASSERT(!IsActive());
+	iStatus = KRequestPending;
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete(status, aError);
+	SetActive();
+	}
+
+//
+// CRestoreDriver::RunL
+// 
+void CRestoreDriver::RunL()
+	{
+	iParent.Finished(iStatus.Int());
+	}
+
+//
+// CRestoreDriver::DoCancel
+//
+void CRestoreDriver::DoCancel()
+	{
+	ASSERT(EFalse); // not dealing with this!
+	}
+
+
+//
+// CCmdRestore
+//
+CCommandBase* CCmdRestore::NewLC()
+	{
+	CCmdRestore* self = new (ELeave) CCmdRestore();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRestore::~CCmdRestore()
+	{
+	delete iRestore;
+	}
+
+CCmdRestore::CCmdRestore() : 
+CCommandBase(CCommandBase::EManualComplete)
+	{
+	}
+
+const TDesC& CCmdRestore::Name() const
+	{
+	_LIT(KName, "restore");	
+	return KName;
+	}
+
+void CCmdRestore::DoRunL()
+	{
+	// spawn the stuff I need to do the task
+	iRestore = CRestoreDriver::NewL(*this);
+
+	// process the argument
+	MBackupObserver::TFileLockFlags flag = MBackupObserver::EReleaseLockNoAccess;
+
+	switch (iOperation)
+		{
+	case EStart:
+		flag = MBackupObserver::EReleaseLockNoAccess;
+		break;
+	case EStop:
+		flag = MBackupObserver::ETakeLock;
+		break;
+	default:
+		User::LeaveIfError(KErrArgument);
+		}
+			
+	// send the instruction through
+	iRestore->SendInstructionL(flag);
+	}
+
+void CCmdRestore::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgOperation, "operation");
+	aArguments.AppendEnumL((TInt&)iOperation, KArgOperation);
+	}
+
+void CCmdRestore::OptionsL(RCommandOptionList&)
+	{
+	}
+
+void CCmdRestore::Finished(const TInt aError)
+	{
+	Complete(aError);
+	}
+
+EXE_BOILER_PLATE(CCmdRestore)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/restore/restore.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,75 @@
+// restore.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <babackup.h>
+
+using namespace IoUtils;
+
+_LIT(KArgStart, 			"start");
+_LIT(KArgStop,	 			"stop");
+_LIT(KBackupProcessName,	"backup_child");
+_LIT(KBackupSemaphore,		"AutometricBackup");
+
+class MBackupParent
+	{
+public:
+	virtual void Finished(const TInt aError) = 0;	
+	};
+
+class CRestoreDriver : public CActive
+	{
+public:
+	static CRestoreDriver* NewL(MBackupParent& aParent);
+	~CRestoreDriver();
+	void SendInstructionL(MBackupObserver::TFileLockFlags aInstruction);
+private:
+	CRestoreDriver(MBackupParent& aParent);
+	void ConstructL();
+	void SelfComplete(const TInt aError);
+	void LaunchProcessL();
+	void TerminateProcessL();
+	TBool ChildProcessExists();
+
+	// from CActive
+	void DoCancel();
+	void RunL();
+private:
+	MBackupParent& iParent;
+	RProcess iChild;
+	MBackupObserver::TFileLockFlags iInstruction;
+	};
+
+class CCmdRestore : public CCommandBase, public MBackupParent
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRestore();
+private:
+	CCmdRestore();
+
+	// From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+
+	// From MBackupParent
+	virtual void Finished(const TInt aError);
+private:
+	CRestoreDriver* iRestore;
+	enum
+		{
+		EStart,
+		EStop
+		} iOperation;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/restore/restore.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// restore.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          restore.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_RESTORE
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+systeminclude   \epoc32\include\fshell
+
+sourcepath      .
+source          restore.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+library	 bafl.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rez/rez.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+# rez.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name rez
+
+==short-description
+
+Reads text out of resource files.
+
+==argument string resource-identifier
+
+The identifier of the resource to display, of the form C<R:FILENAME:ID[:OFFSET]>.
+
+==option bool x hex
+
+Display the resource in hex.
+
+==long-description
+
+Extracts a string from a resource file, taking in to account the current device language settings and the different drives that a resource file might be installed on to.
+
+The C<resource-identifier> syntax is as follows:
+
+=over 4
+
+=item *
+
+C<FILENAME> is the path of the resource file, relative to the resource directory and not including extension. Eg "Apps\MyApp" would match a file that (on an unlocalised, uncustomised system) resided at C<Z:\Resource\Apps\MyApp.rsc>.
+
+=item *
+
+C<ID> is the numeric resource id, in hex with preceding 0x or in decimal.
+
+=item *
+
+C<OFFSET> is a sequence of numbers and d/D characters. A number indicates the number of bytes to skip over, 'D' means read a 16-bit descriptor (an LTEXT, in resource file parlance), 'd' means read an 8-bit descriptor (LTEXT8). So an offset of 14DD24D means 'skip 14 bytes from the start of the resource, then skip over 2 LTEXTs, then skip another 24 bytes, the descriptor I want is next (and is a 16-bit LTEXT).
+
+If no offset is specified, the whole resource is read as if it was a TBUF. This is different to specifying an offset of 0D, which would be a resource starting with an LTEXT (the difference is whether there's a leading length byte - TBUF doesn't use one).
+
+=back
+
+A full resource identifier might be C<R:Apps\MyApp:0x23> indicating resource 0x23 of C<x:\Resource\Apps\MyApp.rxx>. Or C<R:eikcoctl:7:8D30d> indicating resource 7 of C<x:\Resource\eikcoctl.rxx>, seeking 8 bytes, one 16-bit descriptor, 30 bytes more, then the result is a 8-bit descriptor at that point.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rez/rez.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,120 @@
+// rez.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <fshell/ltkutils.h>
+
+using namespace IoUtils;
+
+class CCmdRez : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRez();
+private:
+	CCmdRez();
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	HBufC* iIdentifier;
+	TBool iHex;
+	RResourceFile iFile;
+	};
+
+
+CCommandBase* CCmdRez::NewLC()
+	{
+	CCmdRez* self = new(ELeave) CCmdRez();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRez::~CCmdRez()
+	{
+	delete iIdentifier;
+	iFile.Close();
+	}
+
+CCmdRez::CCmdRez()
+	{
+	}
+
+const TDesC& CCmdRez::Name() const
+	{
+	_LIT(KName, "rez");
+	return KName;
+	}
+
+void CCmdRez::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iIdentifier, _L("resource-identifier"));
+	}
+
+void CCmdRez::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iHex, _L("hex"));
+	}
+
+
+EXE_BOILER_PLATE(CCmdRez)
+
+void CCmdRez::DoRunL()
+	{
+	if (iIdentifier->Left(2) != _L("R:"))
+		{
+		LeaveIfErr(KErrArgument, _L("Resource identifiers must start R: (see help for details)"));
+		}
+
+	TBool wide = ETrue;
+	if ((*iIdentifier)[iIdentifier->Length()-1] == 'd') wide = EFalse;
+
+	HBufC* errString = NULL;
+	HBufC8* result = NULL;
+	TRAPD(err, result = LtkUtils::Rez8L(*iIdentifier, NULL, &errString));
+	if (err && errString)
+		{
+		PrintError(err, _L("%S"), errString);
+		}
+	delete errString;
+	User::LeaveIfError(err);
+	CleanupStack::PushL(result);
+
+	if (iHex)
+		{
+		LtkUtils::HexDumpToOutput(*result, Stdout());
+		}
+	else if (wide)
+		{
+		TPtrC16 wptr((TUint16*)result->Ptr(), result->Size()/2);
+		Write(wptr);
+		}
+	else
+		{
+		RBuf buf;
+		buf.CreateL(result->Length());
+		buf.Copy(*result);
+		Write(buf);
+		buf.Close();
+		}
+	CleanupStack::PopAndDestroy(result);
+	if (Stdout().AttachedToConsole())
+		{
+		Printf(_L("\r\n"));
+		}
+	}	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rez/rez.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// rez.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          rez.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_REZ
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          rez.cpp
+
+library         euser.lib
+library         iocli.lib
+library         bafl.lib
+library         ltkutils.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rsocket/rsocket.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+# rsocket.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name rsocket
+
+==short-description
+
+Send and receive data via Symbian's C<RSocket> API.
+
+==long-description
+
+This command allows a TCP connection to be established using Symbian's C<RSocket> API. Currently, after establishing the connection it immediately disconnects. However, it is intended that future versions will support writing data read from STDIN to the socket and write data read from the socket to STDOUT.
+
+==see-also
+
+L<iap|iap>, L<rconn|rconn>
+
+==argument enum operation
+
+The operation required.
+
+==enum-value connect
+
+Establish an active TCP connection to the specified host.
+
+==enum-value listen
+
+Listen for incoming TCP connections on the specified port (not yet implemented).
+
+==argument string host
+
+The name or IP address of the host to connect to or the interface to listen on.
+
+==argument uint port
+
+The port of the host to connect to or the interface to listen on.
+
+==option bool v verbose
+
+Print verbose output.
+
+==option uint i iap
+
+The Internet Access Provider identifier to use.
+
+==option uint n network
+
+The network identifier to use.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rsocket/rsocket.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,191 @@
+// rsocket.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <es_sock.h>
+#include <es_enum.h>
+#include <in_sock.h>
+#include <nifvar.h>
+#include <commdbconnpref.h>
+
+using namespace IoUtils;
+
+class CCmdRsocket : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRsocket();
+private:
+	CCmdRsocket();
+	void StartConnectionL();
+	void TcpConnectL();
+	void TcpDisconnect();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RSocketServ iSocketSession;
+	RConnection iConnection;
+	RSocket iSocket;
+	enum 
+		{
+		EConnect, EListen
+		} iOperation;
+	HBufC* iHost;
+	TUint iPort;
+	TUint iIapId;
+	TUint iNetworkId;
+	TBool iVerbose;
+	};
+
+
+CCommandBase* CCmdRsocket::NewLC()
+	{
+	CCmdRsocket* self = new(ELeave) CCmdRsocket();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRsocket::~CCmdRsocket()
+	{
+	delete iHost;
+	iSocket.Close();
+	iConnection.Close();
+	iSocketSession.Close();
+	}
+
+CCmdRsocket::CCmdRsocket()
+	{
+	}
+
+const TDesC& CCmdRsocket::Name() const
+	{
+	_LIT(KName, "rsocket");	
+	return KName;
+	}
+
+void CCmdRsocket::DoRunL()
+	{
+	LeaveIfErr(iSocketSession.Connect(), _L("Couldn't open socket server session"));
+	LeaveIfErr(iConnection.Open(iSocketSession), _L("Couldn't open connection handle"));
+
+	switch (iOperation)
+		{
+		case EConnect:
+			TcpConnectL();
+			break;
+		case EListen:
+			LeaveIfErr(KErrNotSupported, _L("Listen operation not yet implemented"));
+			break;
+		};
+	}
+
+void CCmdRsocket::StartConnectionL()
+	{
+	if (iVerbose)
+		{
+		Write(_L("Starting RConnection...\r\n"));
+		}
+
+	TCommDbConnPref prefs;
+	if (iIapId > 0)
+		{
+		prefs.SetIapId(iIapId);
+		prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+		}
+	if (iNetworkId > 0)
+		{
+		prefs.SetNetId(iNetworkId);
+		}
+	LeaveIfErr(iConnection.Start(prefs), _L("Failed to start connection"));
+	}
+
+void CCmdRsocket::TcpConnectL()
+	{
+	StartConnectionL();
+
+	TInetAddr addr(iPort);
+	TInt err = addr.Input(*iHost);
+	if (err)
+		{
+		if (iVerbose)
+			{
+			Write(_L("Resolving name...\r\n"));
+			}
+		RHostResolver resolver;
+		LeaveIfErr(resolver.Open(iSocketSession, KAfInet, KProtocolInetTcp, iConnection), _L("Unable to open host resolver"));
+		CleanupClosePushL(resolver);
+		TNameEntry nameEntry;
+		LeaveIfErr(resolver.GetByName(*iHost, nameEntry), _L("Unable to resolve name \"%S\""), iHost);
+		addr.SetAddress(TInetAddr::Cast(nameEntry().iAddr).Address());
+		CleanupStack::PopAndDestroy(&resolver);
+		}
+
+	if (iVerbose)
+		{
+		Write(_L("Opening socket...\r\n"));
+		}
+	LeaveIfErr(iSocket.Open(iSocketSession, KAfInet, KSockStream, KProtocolInetTcp, iConnection), _L("Unable to open TCP socket"));
+
+	if (iVerbose)
+		{
+		Write(_L("Connecting socket...\r\n"));
+		}
+	TRequestStatus status;
+	iSocket.Connect(addr, status);
+	User::WaitForRequest(status);
+	LeaveIfErr(status.Int(), _L("Unable to connect to %S : %u"), iHost, iPort);
+
+	TcpDisconnect();
+	}
+
+void CCmdRsocket::TcpDisconnect()
+	{
+	if (iVerbose)
+		{
+		Write(_L("Shutting down socket...\r\n"));
+		}
+	TRequestStatus status;
+	iSocket.Shutdown(RSocket::ENormal, status);
+	User::WaitForRequest(status);
+	}
+
+void CCmdRsocket::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgOperation, "operation");
+	aArguments.AppendEnumL((TInt&)iOperation, KArgOperation);
+
+	_LIT(KOptHost, "host");
+	aArguments.AppendStringL(iHost, KOptHost);
+
+	_LIT(KOptPort, "port");
+	aArguments.AppendUintL(iPort, KOptPort);
+	}
+
+void CCmdRsocket::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptIapId, "iap");
+	aOptions.AppendUintL(iIapId, KOptIapId);
+
+	_LIT(KOptNetworkId, "network");
+	aOptions.AppendUintL(iNetworkId, KOptNetworkId);
+	}
+
+
+EXE_BOILER_PLATE(CCmdRsocket)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/rsocket/rsocket.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// rsocket.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_rsocket.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_RSOCKET
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          rsocket.cpp
+
+library         euser.lib
+library         esock.lib
+library         insock.lib
+library		commdb.lib
+library         iocli.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/screenmode/screenmode.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# screenmode.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name screenmode
+
+==short-description
+
+Reports or changes the current Window Server screen mode.
+
+==argument enum command optional
+
+The command to perform. Defaults to C<list>.
+
+==enum-value list
+
+List the available screen modes, and get a index number of current screen mode.
+
+==enum-value set
+
+Set the screen mode by calling C<CWsScreenDevice::SetScreenMode>. Use C<--mode> to specify a mode index. Note some UI platforms don't handle the screen mode being changed in this way. If available, it is recommended to use a UI platform specific method instead.
+
+==enum-value follow
+
+Track changes to the screen mode.
+
+==enum-value rotate
+
+Change the screen orientation by calling C<CAknCapServer::RotateScreenL> (only supported on S60).
+
+==option bool v verbose
+
+Print verbose output.
+
+==option uint m mode
+
+The screen mode to set. Only applicable to the C<set> command.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/screenmode/screenmode.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,463 @@
+// screenmode.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+#if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
+#include "AknCapServerClient.h"	//for screen orientation change
+#endif
+
+#include <W32STD.H>
+
+#include <fshell/ioutils.h>
+using namespace IoUtils;
+
+class CCmdScreenMode : public CCommandBase
+	{
+public:
+	void PrintTime(const TTime& aTime, TBool aNewline);	
+	static const TDesC* EventCodeToString(TUint aEvent);
+	static const TDesC* DisplayModeToString(TDisplayMode aMode);
+	static const TDesC* RotationToString(CFbsBitGc::TGraphicsOrientation aRotation);
+	static const TDesC* EnforcementToString(TScreenModeEnforcement aEnforcement);
+	static CCommandBase* NewLC();
+	~CCmdScreenMode();
+private:
+	CCmdScreenMode();
+	void PrintCurrentModeDetailL();
+	void DoListModeL();
+	void DoSetModeL();
+	void DoFollowL();
+	void DoRotateL();
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+
+private:
+	RWsSession iWsSes;
+	CWsScreenDevice* iWsDev;
+	
+	TBool iVerbose;
+	TInt iOptModeIndex; // Which mode to use.
+	
+	enum TScreenModeCmd
+		{	
+		ECmdListMode,
+		ECmdSetMode,
+		ECmdFollow,
+		ECmdRotate
+		};
+			
+	TScreenModeCmd iCommand;
+	};
+
+CCommandBase* CCmdScreenMode::NewLC()
+	{
+	CCmdScreenMode* self = new(ELeave) CCmdScreenMode();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdScreenMode::CCmdScreenMode()
+	{
+	}
+
+CCmdScreenMode::~CCmdScreenMode()
+	{
+	delete iWsDev;
+	iWsDev = NULL;
+	iWsSes.Close();
+	}
+
+const TDesC& CCmdScreenMode::Name() const
+	{
+	_LIT(KName, "screenmode");
+	return KName;
+	}
+
+void CCmdScreenMode::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgCommand, "command");
+	aArguments.AppendEnumL((TInt&)iCommand, KArgCommand);
+	}
+
+void CCmdScreenMode::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	aOptions.AppendUintL((TUint&)iOptModeIndex, _L("mode"));
+	}
+
+void CCmdScreenMode::PrintCurrentModeDetailL()
+	{
+	TInt scrMode = iWsDev->CurrentScreenMode();
+	TPixelsTwipsAndRotation modeSizeAndRotation;
+	iWsDev->GetDefaultScreenSizeAndRotation(modeSizeAndRotation);
+	const TDesC* pRotationStr = RotationToString(modeSizeAndRotation.iRotation);
+    
+	TPoint origin = iWsDev->GetDefaultScreenModeOrigin(); 
+	TSize scale = iWsDev->GetCurrentScreenModeScale();
+	TPoint scaledOrigin = iWsDev->GetCurrentScreenModeScaledOrigin(); 
+	TScreenModeEnforcement screenModeEnforcement = iWsDev->ScreenModeEnforcement();
+	const TDesC* pEnforcementStr = EnforcementToString(screenModeEnforcement);
+	
+	Printf(_L("Current ScreenMode %d,%dx%d,Twips:%dx%d,%S\r\n"), scrMode,
+			modeSizeAndRotation.iPixelSize.iWidth, modeSizeAndRotation.iPixelSize.iHeight,
+			modeSizeAndRotation.iTwipsSize.iWidth , modeSizeAndRotation.iTwipsSize.iHeight,			
+			pRotationStr);
+	Printf(_L("Origin:(%d,%d) Scale:%dx%d ScaledOrigin:(%d,%d) %S\r\n"),
+			origin.iX, origin.iX, scale.iWidth, scale.iHeight, scaledOrigin.iX, scaledOrigin.iY,
+			pEnforcementStr);	
+	}
+
+//if VerboseLevel > 0, then print every message received
+//
+void CCmdScreenMode::DoFollowL()
+	{
+	const TUint KClientHandle = 0xC0C0C0C0;
+	TInt err;
+	//TInt verboseLevel = iVerbose.Count();
+
+	RWindowGroup wndGrp(iWsSes);
+	err = wndGrp.Construct(KClientHandle);
+	LeaveIfErr(err, _L("Could not construct window group"));
+	
+	CleanupClosePushL(wndGrp);
+	err = wndGrp.EnableScreenChangeEvents();
+	LeaveIfErr(err, _L("Could not enable screen change events"));
+	
+	Printf(_L("Tracking screen change events... press 'q' to quit\r\n"));
+	
+	TWsEvent event;
+	TInt eventType;
+	TUint eventHandle;
+	TTime eventTime;
+	TRequestStatus status;
+	
+	RIoConsoleReadHandle& keyIn = Stdin();
+	TRequestStatus statusKey;
+	keyIn.WaitForKey(statusKey);
+	
+	for(;;) 
+		{
+		iWsSes.EventReady(&status);
+WaitAgain:		
+		User::WaitForRequest(status, statusKey);
+		
+		if (status.Int()==KRequestPending)
+			{
+			err = statusKey.Int();
+			ASSERT(err == KErrNone);
+			//it must be user press a key, so check if that key is 'q'
+			TUint pressedKey = keyIn.KeyCode();
+			if (pressedKey=='q' || pressedKey=='Q')
+				break;
+			else
+				{
+				keyIn.WaitForKey(statusKey);
+				goto WaitAgain;
+				}
+			}
+		
+		iWsSes.GetEvent(event);
+		
+		eventType = event.Type();
+		eventHandle = event.Handle();
+		eventTime = event.Time(); 
+
+		/*
+		if (verboseLevel > 0)
+			{
+			const TDesC* eventCodeStr = EventCodeToString(eventType);
+			Printf(_L(" Event:%d(%S) Handle:0x%08x Time:"), eventType, eventCodeStr,
+					eventHandle);
+			PrintTime(eventTime, ETrue);
+			}
+		*/
+		
+		if (eventType == EEventScreenDeviceChanged && eventHandle==KClientHandle)
+			{
+			// Get the new screen mode and size
+			TInt newMode = iWsDev->CurrentScreenMode();
+			TPixelsTwipsAndRotation modeSizeAndRotation;
+			iWsDev->GetScreenModeSizeAndRotation(newMode, modeSizeAndRotation);
+			
+    		Printf(_L("\r\n"));
+    		Printf(_L("Screen Device Changed, EventTime:"));
+			PrintTime(eventTime, ETrue);
+			PrintCurrentModeDetailL();
+			}
+		}
+	
+	wndGrp.DisableScreenChangeEvents();
+	CleanupStack::PopAndDestroy(&wndGrp);
+	}
+
+//S60 proprietary: toggle screen oritation by calling CAknCapServer::RotateScreenL
+//
+void CCmdScreenMode::DoRotateL()
+	{
+#if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
+	TInt err;
+	RAknUiServer akSrv;
+	err = akSrv.Connect();
+	LeaveIfErr(err, _L("Could not connect to AknCapServer"));
+	
+	CleanupClosePushL(akSrv);
+	
+	if (iVerbose)
+		{
+		Printf(_L("Calling RAknUiServer::RotateScreen() / CAknCapServer::RotateScreenL...\r\n"));
+		}
+	err = akSrv.RotateScreen();
+	LeaveIfErr(err, _L("RotateScreen() failed"));
+		
+	CleanupStack::PopAndDestroy(&akSrv);
+	if (iVerbose)
+		{
+		PrintCurrentModeDetailL();
+		}
+#else
+	LeaveIfErr(KErrNotSupported, _L("Rotate not supported on this platform."));
+#endif	
+	}
+
+void CCmdScreenMode::DoSetModeL()
+	{
+	TInt numScreenModes = iWsDev->NumScreenModes();
+	if ( (iOptModeIndex >= numScreenModes) || iOptModeIndex<0)
+		{
+		LeaveIfErr(KErrArgument, _L("Invalid screenmode index:%d"), iOptModeIndex);
+		}
+	
+	if (iVerbose)
+		{
+		Printf(_L("Calling CWsScreenDevice::SetScreenMode(%d)\r\n"), iOptModeIndex);
+		}
+	iWsDev->SetScreenMode(iOptModeIndex);
+	
+	//verify the result by query current screen mode
+	if (iVerbose)
+		{
+		PrintCurrentModeDetailL();
+		}
+	}
+
+void CCmdScreenMode::DoListModeL()
+	{
+	//for platform defined with SYMBIAN_WSERV_AND_CONE_MULTIPLE_SCREENS
+	//it would be possible to query how many screens on this device
+	//but S60 5.0 doesn't define this
+	//TInt Screens = iWsSes.NumberOfScreens();	
+	TInt curScreenNum = iWsDev->GetScreenNumber();
+	TInt numScreenModes = iWsDev->NumScreenModes();
+	Printf(_L("Current Screen number:%d Screen Modes:%d \r\n"), curScreenNum, numScreenModes);
+	
+	for (TInt i=0; i<numScreenModes; i++)
+		{
+		Printf(_L("-------------------------------------------\r\n"));
+		TDisplayMode dMode = iWsDev->GetScreenModeDisplayMode(i);
+		const TDesC* pModeString = DisplayModeToString(dMode);
+		TSize modeScale = iWsDev->GetScreenModeScale(i);
+		TPoint modeOrigin = iWsDev->GetScreenModeOrigin(i);
+		TPoint scaledOrigin = iWsDev->GetScreenModeScaledOrigin(i);
+		
+		TPixelsTwipsAndRotation modeSizeAndRotation;
+		iWsDev->GetScreenModeSizeAndRotation(i, modeSizeAndRotation);
+		const TDesC* pRotationStr = RotationToString(modeSizeAndRotation.iRotation);
+		
+		Printf(_L("Mode:%d DisplayMode:%S Scale(WxH):%dx%d Origin:(%d,%d) ScaledOrigin:(%d,%d)\r\n"), 
+				i, pModeString, 
+				modeScale.iWidth, modeScale.iHeight,
+				modeOrigin.iX, modeOrigin.iY, scaledOrigin.iX, scaledOrigin.iY);
+		
+		Printf(_L("Size(WxH) Pixels:%dx%d, Twips:%dx%d %S\r\n"), 
+				modeSizeAndRotation.iPixelSize.iWidth, modeSizeAndRotation.iPixelSize.iHeight,
+				modeSizeAndRotation.iTwipsSize.iWidth, modeSizeAndRotation.iTwipsSize.iHeight,
+				pRotationStr);
+		}
+
+	//current screen mode
+	Printf(_L("===========================================\r\n"));
+	PrintCurrentModeDetailL();	
+	}
+
+void CCmdScreenMode::DoRunL()
+	{
+	TInt err;
+	err = iWsSes.Connect();
+	LeaveIfErr(err, _L("Could not connect to the window server"));
+	
+	iWsDev = new (ELeave) CWsScreenDevice(iWsSes);
+	err = iWsDev->Construct();
+	LeaveIfErr(err, _L("Could not construct CWsScreenDevice"));
+		
+	switch(iCommand)
+		{
+		case ECmdListMode:
+			DoListModeL();
+			break;
+		case ECmdSetMode:
+			DoSetModeL();
+			break;
+		case ECmdFollow:
+			DoFollowL();
+			break;
+		case ECmdRotate:
+			DoRotateL();
+			break;
+		}	
+		
+	}
+
+EXE_BOILER_PLATE(CCmdScreenMode)
+
+#define CASE_MODELIT(x) case x: { _LIT(KName, #x); pString = &KName; break; }
+
+const TDesC* CCmdScreenMode::DisplayModeToString(TDisplayMode aMode)
+	{
+	enum { EColor16MAP = EColor16MA+1 }; // Not defined in 9.1
+	const TDesC* pString = NULL;
+	switch(aMode)
+		{
+		CASE_MODELIT(ENone);
+		CASE_MODELIT(EGray2);
+		CASE_MODELIT(EGray4);
+		CASE_MODELIT(EGray16);
+		CASE_MODELIT(EGray256);
+		CASE_MODELIT(EColor16);
+		CASE_MODELIT(EColor256);
+		CASE_MODELIT(EColor64K);
+		CASE_MODELIT(EColor16M);
+		CASE_MODELIT(ERgb);
+		CASE_MODELIT(EColor4K);
+		CASE_MODELIT(EColor16MU);
+		CASE_MODELIT(EColor16MA);
+		CASE_MODELIT(EColor16MAP);
+		default:
+			_LIT(KUnknowStr, "Unknown");
+			pString = &KUnknowStr;		
+		}
+	return pString;
+	}
+
+const TDesC* CCmdScreenMode::EnforcementToString(TScreenModeEnforcement aEnforcement)
+	{
+	const TDesC* pString = NULL;
+	switch(aEnforcement)
+		{
+		CASE_MODELIT(ESizeEnforcementNone);
+		CASE_MODELIT(ESizeEnforcementPixelsAndRotation);
+		CASE_MODELIT(ESizeEnforcementPixelsTwipsAndRotation);
+		default:
+			_LIT(KUnknowStr, "Unknown");
+			pString = &KUnknowStr;		
+		}
+	return pString;
+	}
+
+const TDesC* CCmdScreenMode::EventCodeToString(TUint aEvent)
+	{
+	const TDesC* pString = NULL;
+	switch(aEvent)
+		{
+		CASE_MODELIT(EEventNull);
+		CASE_MODELIT(EEventKey);
+		CASE_MODELIT(EEventKeyUp);
+		CASE_MODELIT(EEventKeyDown);
+		CASE_MODELIT(EEventModifiersChanged);
+		CASE_MODELIT(EEventPointer);
+		CASE_MODELIT(EEventPointerEnter);
+		CASE_MODELIT(EEventPointerExit);
+		CASE_MODELIT(EEventPointerBufferReady);
+		CASE_MODELIT(EEventDragDrop);
+		CASE_MODELIT(EEventFocusLost);
+		CASE_MODELIT(EEventFocusGained);
+		CASE_MODELIT(EEventSwitchOn);
+		CASE_MODELIT(EEventPassword);
+		CASE_MODELIT(EEventWindowGroupsChanged);
+		CASE_MODELIT(EEventErrorMessage);
+		CASE_MODELIT(EEventMessageReady);
+		CASE_MODELIT(EEventMarkInvalid);
+		CASE_MODELIT(EEventSwitchOff);
+		CASE_MODELIT(EEventKeySwitchOff);
+		CASE_MODELIT(EEventScreenDeviceChanged);
+		CASE_MODELIT(EEventFocusGroupChanged);
+		CASE_MODELIT(EEventCaseOpened);
+		CASE_MODELIT(EEventCaseClosed);
+		CASE_MODELIT(EEventWindowGroupListChanged);
+		CASE_MODELIT(EEventWindowVisibilityChanged);
+#ifdef SYMBIAN_PROCESS_MONITORING_AND_STARTUP		
+		CASE_MODELIT(EEventRestartSystem);
+#endif		
+		CASE_MODELIT(EEventKeyRepeat);
+		
+		//the following 3 are not defined in S60 3.2
+#if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
+		CASE_MODELIT(EEventGroupWindowOpen);
+		CASE_MODELIT(EEventGroupWindowClose);
+		CASE_MODELIT(EEventWindowClose);
+#endif		
+		
+		CASE_MODELIT(EEventDirectScreenAccessBegin);
+		CASE_MODELIT(EEventDirectScreenAccessEnd);
+		CASE_MODELIT(EEventHeartbeatTimerStateChange);
+		CASE_MODELIT(EEventPowerMgmt);
+		CASE_MODELIT(EEventReserved);
+		CASE_MODELIT(EEventUser);
+		default:
+			_LIT(KUnknowStr, "Unknown");
+			pString = &KUnknowStr;
+		}
+	return pString;
+	}
+
+#define CASE_ROTLIT(x) case CFbsBitGc::x: { _LIT(KName, #x); pString = &KName; break; }
+
+const TDesC* CCmdScreenMode::RotationToString(CFbsBitGc::TGraphicsOrientation aRotation)
+	{
+	const TDesC* pString = NULL;
+	switch(aRotation)
+		{
+		CASE_ROTLIT(EGraphicsOrientationNormal);
+		CASE_ROTLIT(EGraphicsOrientationRotated90);
+		CASE_ROTLIT(EGraphicsOrientationRotated180);
+		CASE_ROTLIT(EGraphicsOrientationRotated270);
+		default:
+			_LIT(KUnknowStr, "Unknown");
+			pString = &KUnknowStr;		
+		}
+	return pString;
+	}
+
+void CCmdScreenMode::PrintTime(const TTime& aTime, TBool aNewline)
+	{	
+	TTime NullTime = Time::NullTTime();
+	if (aTime == NullTime) 
+		{
+		Printf(_L("(NullTime)"));
+		}
+	else
+		{
+		_LIT8(KDateTimeFormat, "%d-%02d-%02d %02d:%02d:%02d");
+		TDateTime dt = aTime.DateTime();
+		Printf(KDateTimeFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
+		}
+	
+	if (aNewline)
+		{
+		Printf(_L("\r\n"));
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/screenmode/screenmode.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// screenmode.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			screenmode.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_SCREENMODE
+
+capability        Location WriteDeviceData ReadDeviceData ReadUserData
+
+userinclude     .
+SYSTEMINCLUDE   \epoc32\include\networking
+
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          screenmode.cpp
+
+library         euser.lib
+library         iocli.lib
+
+LIBRARY			ws32.lib
+
+#if defined (FSHELL_PLATFORM_S60) && FSHELL_PLATFORM_S60 >= 5
+LIBRARY         akncapserverclient.lib apparc.lib eikcore.lib
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/setcritical/setcritical.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+# setcritical.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name setcritical
+
+==short-description
+
+Sets the User::TCritcal attribute of a thread.
+
+==long-description
+
+To make thread 42 system critical, do C<setcritical --system --critical 42>. To set a thread as not critical, do C<setcritical 42>.
+
+==argument uint threadid multiple
+
+Id of the thread(s) to change.
+
+==option bool s system
+
+System attribute. Combine with --critical or --permanent.
+
+==option bool r process
+
+Process attribute. Combine with --critical or --permanent.
+
+==option bool c critical
+
+Sets the thread to be system/process critical.
+
+==option bool p permanent
+
+Sets the thread to be system/process permanent.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/setcritical/setcritical.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,105 @@
+// setcritical.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/memoryaccesscmd.h>
+
+using namespace IoUtils;
+
+class CCmdSetcritical : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSetcritical();
+private:
+	CCmdSetcritical();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RArray<TUint> iTids;
+	TBool iSystem, iPermanent, iProcess, iCritical;
+	};
+
+
+CCommandBase* CCmdSetcritical::NewLC()
+	{
+	CCmdSetcritical* self = new(ELeave) CCmdSetcritical();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSetcritical::~CCmdSetcritical()
+	{
+	iTids.Close();
+	}
+
+CCmdSetcritical::CCmdSetcritical()
+	{
+	}
+
+const TDesC& CCmdSetcritical::Name() const
+	{
+	_LIT(KName, "setcritical");	
+	return KName;
+	}
+
+void CCmdSetcritical::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendUintL(iTids, _L("threadid"));
+	}
+
+void CCmdSetcritical::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iSystem, _L("system"));
+	aOptions.AppendBoolL(iProcess, _L("process"));
+	aOptions.AppendBoolL(iCritical, _L("critical"));
+	aOptions.AppendBoolL(iPermanent, _L("permanent"));
+	}
+
+void CCmdSetcritical::DoRunL()
+	{
+	LoadMemoryAccessL();
+
+	TUint set = 0;
+	if (iSystem && iCritical)
+		set = KThreadFlagSystemCritical;
+	else if (iSystem && iPermanent)
+		set = KThreadFlagSystemPermanent;
+	else if (iProcess && iCritical)
+		set = KThreadFlagProcessCritical;
+	else if (iProcess && iPermanent)
+		set = KThreadFlagProcessPermanent;
+	else if (!iSystem && !iCritical && !iProcess && !iPermanent)
+		set = 0;
+	else
+		{
+		LeaveIfErr(KErrArgument, _L("Incompatible options specified. You must either give no options (to specify ENotCritical) or one of --system/--process and one of --critical/--permanent"));
+		}
+
+	for (TInt i = 0; i < iTids.Count(); i++)
+		{
+		TUint id = iTids[i];
+		RThread thread;
+		TInt err = iMemAccess.RThreadForceOpen(thread, id);
+		if (!err) err = iMemAccess.SetThreadCriticalFlags(thread, set);
+		if (err)
+			{
+			PrintError(err, _L("Couldn't set flags for thread %u."), id);
+			}
+		thread.Close();
+		}
+	}
+
+EXE_BOILER_PLATE(CCmdSetcritical)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/setcritical/setcritical.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// setcritical.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          setcritical.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_SETCRITICAL
+
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          setcritical.cpp
+
+library         euser.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/setpriority/setpriority.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,57 @@
+# setpriority.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name setpriority
+
+==short-description
+
+Set the priority of a thread or process.
+
+==long-description
+
+For threads, the priority must be either an absolute kernel priority between 0 and 64, or a relative thread priority as follows:
+
+    Idle:       101
+    MuchLess:   102
+    Less:       103
+    Normal:     104
+    More:       105
+    MuchMore:   106
+    RealTime:   107
+
+For processes, the only settable priorities are:
+
+    Low:        150
+    Background: 250
+    Foreground: 350
+    High:       450
+
+==argument int priority
+
+The priority to set.
+
+==option string m match
+
+Wait for threads matching the passed in name to be created, and change their priority when they do. Pass in a name or wildcarded partial name. For example to set all threads created in tail.exe to priority 19, do: C<setpriority 19 -m tail.exe*>
+
+==option uint p pid multiple
+
+The ID of the process whose priority you want to change.
+
+==option uint t tid multiple
+
+The ID of the thread whose priority you want to change.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/setpriority/setpriority.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,240 @@
+// setpriority.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/memoryaccesscmd.h>
+
+using namespace IoUtils;
+
+class CCmdSetpriority;
+class CNewThreadNotifier : public CActive
+	{
+public:
+	CNewThreadNotifier(CCmdSetpriority& aCmd, RMemoryAccess& aMemAccess);
+	void Start();
+	~CNewThreadNotifier();
+	void DoCancel();
+	void RunL();
+
+private:
+	CCmdSetpriority& iCmd;
+	RMemoryAccess& iMemAccess;
+	};
+
+class CCmdSetpriority : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSetpriority();
+	void NewThread(TInt aHandle);
+private:
+	CCmdSetpriority();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RArray<TUint> iTids;
+	RArray<TUint> iPids;
+	TInt iPriority;
+	HBufC* iName;
+	TProcessKernelInfo iProcInfo;
+	TThreadKernelInfo iThreadInfo;
+	CNewThreadNotifier* iNotifier;
+	};
+
+
+CCommandBase* CCmdSetpriority::NewLC()
+	{
+	CCmdSetpriority* self = new(ELeave) CCmdSetpriority();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSetpriority::~CCmdSetpriority()
+	{
+	delete iNotifier;
+	delete iName;
+	iTids.Close();
+	iPids.Close();
+	}
+
+CCmdSetpriority::CCmdSetpriority()
+	: CMemoryAccessCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdSetpriority::Name() const
+	{
+	_LIT(KName, "setpriority");
+	return KName;
+	}
+
+void CCmdSetpriority::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendIntL(iPriority, _L("priority"));
+	}
+
+void CCmdSetpriority::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendStringL(iName, _L("match"));
+	aOptions.AppendUintL(iPids, _L("pid"));
+	aOptions.AppendUintL(iTids, _L("tid"));
+	}
+
+
+EXE_BOILER_PLATE(CCmdSetpriority)
+
+void CCmdSetpriority::DoRunL()
+	{
+	LoadMemoryAccessL();
+	TInt err = KErrNone;
+
+	// Fix up priorities that we had to make different to kernel cos fshell can't handle negative arguments
+	// See enum TThrdPriority in kern_priv.h for the meaning of these negative numbers
+	switch(iPriority)
+		{
+		case 101: iPriority = -8; break;
+		case 102: iPriority = -7; break;
+		case 103: iPriority = -6; break;
+		case 104: iPriority = -5; break;
+		case 105: iPriority = -4; break;
+		case 106: iPriority = -3; break;
+		case 107: iPriority = -2; break;
+		default:
+			break;
+		}
+
+	if (iName)
+		{
+		TPtrC8 name8 = iName->Des().Collapse();
+		LeaveIfErr(iMemAccess.SetPriorityOverride(iPriority, name8), _L("Couldn't set priority override"));
+		iNotifier = new(ELeave) CNewThreadNotifier(*this, iMemAccess);
+		iNotifier->Start();
+		return;
+		}
+	
+	if (iTids.Count() && iPids.Count())
+		{
+		LeaveIfErr(KErrArgument, _L("You cannot specify both --tid and --pid - a single priority cannot be valid for thread and process."));
+		}
+
+	for (TInt i = 0; i < iTids.Count(); i++)
+		{
+		TUint id = iTids[i];
+		RThread thread;
+		err = iMemAccess.RThreadForceOpen(thread, id);
+		if (!err) err = iMemAccess.SetThreadPriority(thread, iPriority);
+		if (err) PrintError(err, _L("Couldn't set priority for thread %u"), id);
+		thread.Close();
+		}
+	
+	for (TInt i = 0; i < iPids.Count(); i++)
+		{
+		TUint id = iPids[i];
+		// Get KProcessFlagPriorityControl flag
+		RProcess process;
+		err = process.Open(id);
+		LeaveIfErr(err, _L("Couldn't open process with ID %u"), id);
+
+		TBool priorityControlAllowed = EFalse;
+		TPckg<TProcessKernelInfo> pkg(iProcInfo);
+		err = iMemAccess.GetObjectInfoByHandle(EProcess, RThread().Id(), process.Handle(), pkg);
+		if (err)
+			{
+			PrintWarning(_L("Couldn't get priority control flag setting (%d)\r\n"), err);
+			}
+		else
+			{
+			if (iProcInfo.iFlags & KProcessFlagPriorityControl) priorityControlAllowed = ETrue;
+			}
+
+		if (!priorityControlAllowed)
+			{
+			PrintError(KErrAccessDenied, _L("This process does not allow setting of its priority"));
+			}
+		else if (iPriority != EPriorityBackground && iPriority != EPriorityForeground)
+			{
+			PrintError(KErrAccessDenied, _L("The kernel will ignore requests to set a process priority that isn't Background (250) or Foreground (350). I can't see how to get round this even using memory access. Sorry."));
+			}
+		process.SetPriority((TProcessPriority)iPriority);
+		process.Close();
+		}
+	Complete(KErrNone);
+	}
+
+void CCmdSetpriority::NewThread(TInt aHandle)
+	{
+	if (aHandle == KErrNotSupported)
+		{
+		PrintError(KErrNotSupported, _L("Kernel was not compiled with __DEBUGGER_SUPPORT__, can't get thread creation notifications."));
+		Complete(aHandle);
+		}
+	else if (aHandle < 0)
+		{
+		PrintError(aHandle, _L("Failed to get new thread notification, or couldn't open handle to thread."));
+		Complete(aHandle);
+		}
+	else
+		{
+		RThread thread;
+		thread.SetHandle(aHandle);
+		TFullName name(thread.FullName());
+		TInt priority = 0;
+		TPckg<TThreadKernelInfo> pkg(iThreadInfo);
+		TInt err = iMemAccess.GetObjectInfoByHandle(EThread, RThread().Id(), aHandle, pkg);
+		if (!err)
+			{
+			priority = iThreadInfo.iThreadPriority;
+			}
+
+		TUint tid = thread.Id();
+		Printf(_L("New thread id %u name %S priority adjusted to %d\r\n"), tid, &name, priority);
+		thread.Close();
+		}
+	}
+
+CNewThreadNotifier::CNewThreadNotifier(CCmdSetpriority& aCmd, RMemoryAccess& aMemAccess)
+	: CActive(CActive::EPriorityStandard), iCmd(aCmd), iMemAccess(aMemAccess)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CNewThreadNotifier::~CNewThreadNotifier()
+	{
+	Cancel();
+	}
+
+void CNewThreadNotifier::DoCancel()
+	{
+	iMemAccess.CancelNotifyThreadCreation();
+	}
+
+void CNewThreadNotifier::RunL()
+	{
+	TInt stat = iStatus.Int();
+	if (stat >= 0)
+		{
+		Start();
+		}
+	iCmd.NewThread(stat);
+	}
+
+void CNewThreadNotifier::Start()
+	{
+	if (!IsActive())
+		{
+		iMemAccess.NotifyThreadCreation(iStatus);
+		SetActive();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/setpriority/setpriority.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// setpriority.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          setpriority.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_SETPRIORITY
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          setpriority.cpp
+
+library         euser.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/shutapp/shutapp.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# shutapp.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name shutapp
+
+==short-description
+
+Requests the shutdown of one or more applications.
+
+==see-also
+
+L<listapps|listapps>, L<focus|focus>
+
+==option uint i id multiple
+
+Send the shut down message to just the application with the specified window group identifier.
+
+==option string m match multiple
+
+Send the shut down message to just the applications that match the specified window group name. Wild characters C<*> and C<?> are supported.
+
+==option int t timeout
+
+The time (in seconds) after which to abort waiting for each application's thread to exit. Defaults to 5 seconds.
+
+==option bool v verbose
+
+Print verbose output.
+
+==option bool a all
+
+Shut all currently running applications down.
+
+==option bool f force
+
+Send the more forceful C<EApaSystemEventSecureShutdown> as opposed to C<EApaSystemEventShutdown>. This should allow system apps to be shut.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/shutapp/shutapp.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,185 @@
+// shutapp.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <w32std.h>
+#include <apgtask.h>
+#include <apgwgnam.h>
+#include "shutapp.h"
+
+
+CCommandBase* CCmdShutApp::NewLC()
+	{
+	CCmdShutApp* self = new(ELeave) CCmdShutApp();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdShutApp::~CCmdShutApp()
+	{
+	iWgIds.Close();
+	iWgNames.ResetAndDestroy();
+	}
+
+CCmdShutApp::CCmdShutApp()
+	: iTimeout(5)
+	{
+	}
+
+const TDesC& CCmdShutApp::Name() const
+	{
+	_LIT(KName, "shutapp");
+	return KName;
+	}
+
+void CCmdShutApp::DoRunL()
+	{
+	RWsSession wsSession;
+	User::LeaveIfError(wsSession.Connect());
+	CleanupClosePushL(wsSession);
+
+	const TInt numIds = iWgIds.Count();
+	for (TInt i = 0; i < numIds; ++i)
+		{
+		ShutL(wsSession, iWgIds[i]);
+		}
+
+	const TInt numNames = iWgNames.Count();
+	for (TInt i = 0; i < numNames; ++i)
+		{
+		const TDesC& name = *(iWgNames[i]);
+		TInt id = 0;
+		while ((id = wsSession.FindWindowGroupIdentifier(id, name)) != KErrNotFound)
+			{
+			ShutL(wsSession, id);
+			}
+		}
+
+	if (iAll)
+		{
+		TInt numWgs = wsSession.NumWindowGroups(0);
+		if (numWgs > 0)
+			{
+			CArrayFixFlat<TInt>* wgIds = new(ELeave) CArrayFixFlat<TInt>(numWgs);
+			CleanupStack::PushL(wgIds);
+			User::LeaveIfError(wsSession.WindowGroupList(0, wgIds));
+			numWgs = wgIds->Count();
+			for (TInt i = 0; i < numWgs; ++i)
+				{
+				ShutL(wsSession, (*wgIds)[i]);
+				}
+			CleanupStack::PopAndDestroy(wgIds);
+			}
+		}
+	CleanupStack::PopAndDestroy(&wsSession);
+	}
+	
+void CCmdShutApp::ShutL(RWsSession& aWsSession, TInt aWindowGroupId)
+	{
+	CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC(aWsSession, aWindowGroupId);
+	if (iVerbose)
+		{
+		_LIT(KUnknown, "not named");
+		TPtrC caption(wgn->Caption());
+		if (caption.Length() == 0)
+			{
+			caption.Set(KUnknown);
+			}
+		Printf(_L("Shutting down %d (%S)\r\n"), aWindowGroupId, &caption);
+		}
+
+	TThreadId threadId;
+	User::LeaveIfError(aWsSession.GetWindowGroupClientThreadId(aWindowGroupId, threadId));
+
+	RThread thread;
+	User::LeaveIfError(thread.Open(threadId));
+	CleanupClosePushL(thread);
+
+	TRequestStatus threadStatus;
+	thread.Logon(threadStatus);
+	if (threadStatus != KRequestPending)
+		{
+		User::WaitForRequest(threadStatus);
+		User::Leave(KErrGeneral);
+		}
+
+	RTimer timer;
+	User::LeaveIfError(timer.CreateLocal());
+	CleanupClosePushL(timer);
+	TRequestStatus timeoutStatus;
+	timer.After(timeoutStatus, iTimeout * 1000000);
+
+	TApaTask task(aWsSession);
+	task.SetWgId(aWindowGroupId);
+#ifdef EKA2
+	if (iForce)
+		{
+		task.SendSystemEvent(EApaSystemEventSecureShutdown);
+		}
+	else
+		{
+		task.SendSystemEvent(EApaSystemEventShutdown);
+		}
+#else
+	task.SendSystemEvent(EApaSystemEventShutdown);
+#endif
+
+	User::WaitForRequest(threadStatus, timeoutStatus);
+
+	if (timeoutStatus != KRequestPending)
+		{
+		// Timeout occurred.
+		thread.LogonCancel(threadStatus);
+		User::WaitForRequest(threadStatus);
+		User::Leave(KErrTimedOut);
+		}
+	else
+		{
+		timer.Cancel();
+		User::WaitForRequest(timeoutStatus);
+		}
+
+	CleanupStack::PopAndDestroy(3, wgn);
+	}
+
+void CCmdShutApp::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptWgId, "id");
+	aOptions.AppendUintL(iWgIds, KOptWgId);
+
+	_LIT(KOptWgPattern, "match");
+	aOptions.AppendStringL(iWgNames, KOptWgPattern);
+
+	_LIT(KOptTimeout, "timeout");
+	aOptions.AppendIntL(iTimeout, KOptTimeout);
+
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptAll, "all");
+	aOptions.AppendBoolL(iAll, KOptAll);
+
+#ifdef EKA2
+	_LIT(KOptForce, "force");
+	aOptions.AppendBoolL(iForce, KOptForce);
+#endif
+	}
+
+void CCmdShutApp::ArgumentsL(RCommandArgumentList&)
+	{
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdShutApp)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/shutapp/shutapp.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+// shutapp.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+
+class CCmdShutApp : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdShutApp();
+private:
+	CCmdShutApp();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	void ShutL(RWsSession& aWsSession, TInt aWindowGroupId);
+private:
+	RArray<TUint> iWgIds;
+	RPointerArray<HBufC> iWgNames;
+	TInt iTimeout;
+	TBool iForce;
+	TBool iVerbose;
+	TBool iAll;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/shutapp/shutapp.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// shutapp.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          shutapp.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_SHUTAPP
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          shutapp.cpp
+
+library         euser.lib
+library         iocli.lib
+library         ws32.lib
+library         apgrfx.lib
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/sms.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+# sms.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name sms
+
+==short-description
+
+Send or receive text messages.
+
+==long-description
+
+The send functionality simply sends a text message to the specified mobile phone number. The receive functionality is intended to allow the handset it's running on to be remotely controlled. Any SMS that is received which started with C<#!fshell> or C<#!perl> is intercepted from the user's messaging inbox and instead is executed as a script. The script can make use of the environment variable SMS_SENDER with is set to the phone number that sent the message.
+
+Note, use of receive mode represents a significant security risk. It is recommended that the C<--match> option be used to restrict which sending parties the handset will allow control from.
+
+==argument enum command
+
+The action to perform.
+
+==enum-value send
+
+Send an SMS.
+
+==enum-value receive
+
+Receive, intercept and execute all SMSs that start with C<#!fshell> or C<#!perl>.
+
+==argument string message optional last
+
+The text to send. If not specified, C<send> will read from C<STDIN>.
+
+==option string d destination
+
+The destination of the SMS. This option is required when sending an SMS, and ignored otherwise.
+
+==option bool n no-delete
+
+Scripts that are received are stored in F<C:\shared\fshellN.script> (and F<perlN.pl>) while they are being executed. By default they are deleted when the script completes. Specify this option to not delete them - useful if you need to debug or examine a script.
+
+==option string m match multiple
+
+A match string to limit the numbers from which shebang messages will be processed. Shebang messages from numbers that do not match will be discarded. Supports C<TDesC::Match> style wildcards.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/sms.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,166 @@
+// sms.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "sms.h"
+
+CCmdSms* CCmdSms::NewLC()
+	{
+	CCmdSms* self = new (ELeave) CCmdSms();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSms::~CCmdSms()
+	{
+	delete iCompletionCallBack;
+	delete iWatch;
+	delete iSendMsg;
+	delete iMsgToSend;
+	delete iDestination;
+	delete iMessageFromStdin;
+	iMatchStrings.ResetAndDestroy();
+	}
+
+CCmdSms::CCmdSms():
+CCommandBase(CCommandBase::EManualComplete)
+	{
+	}
+
+const TDesC& CCmdSms::Name() const
+	{
+	_LIT(KName, "sms");	
+	return KName;
+	}
+
+//
+// CCmdSms::DoRunL
+//
+void CCmdSms::DoRunL()
+	{
+	iCompletionCallBack = new(ELeave) CAsyncCallBack(TCallBack(CompletionCallBack, this), CActive::EPriorityStandard);
+
+	switch (iOperation)
+		{
+	case ESend:
+			{
+			if (!iDestination)
+				{
+				LeaveIfErr(KErrArgument, _L("Option --destination not specified for send."));
+				}
+			if (!iMsgToSend)
+				{
+				iMessageFromStdin = CTextBuffer::NewL(160);
+				Stdin().SetReadMode(RIoReadHandle::EFull);
+				TBuf<0x100> buf;
+				while (Stdin().Read(buf) == KErrNone)
+					{
+					iMessageFromStdin->AppendL(buf);
+					}
+				
+				iSendMsg = CSmsSender::NewL(FsL(), *this, iMessageFromStdin->Descriptor(), *iDestination);
+				}
+			else
+				{
+				iSendMsg = CSmsSender::NewL(FsL(), *this, *iMsgToSend, *iDestination);
+				}
+			iSendMsg->StartL();
+			}
+		break;
+	case EReceive:
+			{
+			FsL(); // So that CSmsWatcher can call Fs() if it needs to
+			iWatch = CSmsWatcher::NewL(*this);
+			iWatch->WaitForMessage();
+			}
+		break;
+		};
+	}
+
+void CCmdSms::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iOperation, _L("command"));
+	aArguments.AppendStringL(iMsgToSend, _L("message"));
+	}
+
+//
+// CCmdSms::OptionsL
+//
+void CCmdSms::OptionsL(RCommandOptionList& aOptions)
+	{
+	// send sms options
+	_LIT(KOptDestination, "destination");
+	aOptions.AppendStringL(iDestination, KOptDestination);
+	
+	// receive sms options
+	_LIT(KOptDebug, "no-delete");
+	aOptions.AppendBoolL(iDebug, KOptDebug);
+	
+	_LIT(KOptMatch, "match");
+	aOptions.AppendStringL(iMatchStrings, KOptMatch);
+	}
+
+//
+// CCmdSms::SendComplete
+// up-call from the underlying smssender to indicate
+// it has finished its task
+//
+void CCmdSms::SendComplete(TInt aError)
+	{
+	EventsFinished(aError);
+	}
+
+//
+// CCmdSms::EventsFinished
+// up-call from the underlying smswatcher to indicate
+// it has finished its task(s)
+//
+void CCmdSms::EventsFinished(const TInt aError)
+	{
+	iCompletionError = aError;
+	iCompletionCallBack->CallBack();
+	}
+
+//
+// CCmdSms::CompletionCallBack
+// static function called in the event the cmd has finished executing
+// 
+TInt CCmdSms::CompletionCallBack(TAny* aEvent)
+	{
+	CCmdSms* self = static_cast<CCmdSms*>(aEvent);
+	self->Cleanup();
+	return KErrNone;
+	}
+
+//
+// CCmdSms::Cleanup
+// 
+void CCmdSms::Cleanup()
+	{
+	if (iCompletionError)
+		PrintError(iCompletionError, _L("amsms.exe failure"));
+	else
+		{
+		if (iWatch)
+			{
+			// dump any underlying messages (if any!)
+			const TDesC& msg = iWatch->Message();
+			if (msg.Length() > 0)
+				Printf(_L("Message received: \r\n"), &msg); // dump the message to stdout
+			}
+		}
+	// complete the fshell command
+	Complete(iCompletionError);
+	}
+
+EXE_BOILER_PLATE(CCmdSms);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/sms.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+// sms.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SMS_H__
+#define __SMS_H__
+
+#include <fshell/ioutils.h>
+#include "smswatch.h"
+#include "smssend.h"
+
+using namespace IoUtils;
+
+NONSHARABLE_CLASS(CCmdSms) : public CCommandBase, public MSmsSendObserver
+	{
+public:
+	static CCmdSms* NewLC();
+	~CCmdSms();
+
+	// Functions for helper objects
+	using CCommandBase::Fs;
+	using CCommandBase::Printf;
+	using CCommandBase::PrintError;
+	using CCommandBase::IoSession;
+	using CCommandBase::Stdin;
+	using CCommandBase::Stdout;
+	using CCommandBase::Stderr;
+	TBool Debug() const { return iDebug; }
+	RPointerArray<HBufC>& MatchStrings() { return iMatchStrings; }
+		
+
+private:
+	CCmdSms();
+	static TInt CompletionCallBack(TAny* aEvent);
+	void Cleanup();
+	
+	// From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	
+	// From MSmsListenerObserver
+	virtual void EventsFinished(const TInt aError);
+	
+	// From MSmsSendObserver
+	virtual void SendComplete(const TInt aError);
+	
+private:
+	CAsyncCallBack* iCompletionCallBack;
+	CSmsWatcher* iWatch;
+	CSmsSender* iSendMsg;
+	TInt iCompletionError;
+	enum 
+		{
+		ESend, EReceive
+		} iOperation;
+	TBool iAutometricSms;
+	HBufC* iMsgToSend;
+	HBufC* iDestination;
+	RPointerArray<HBufC> iMatchStrings;
+	TBool iDebug;
+	CTextBuffer* iMessageFromStdin;
+	};
+
+#endif // __SMS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/sms.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+// sms.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			fshell_sms.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_SMS
+
+CAPABILITY		FSHELL_CAP_MMP_NORMAL
+
+USERINCLUDE		.
+#include <fshell/fsh_system_include.mmh>
+
+SOURCEPATH		.
+SOURCE			sms.cpp
+SOURCE			smswatch.cpp
+SOURCE			smsevent.cpp smssend.cpp
+
+LIBRARY			euser.lib
+LIBRARY			iocli.lib
+LIBRARY			esock.lib
+LIBRARY			smsu.lib
+LIBRARY			gsmu.lib
+LIBRARY			etel.lib
+LIBRARY			etelmm.lib
+LIBRARY			estor.lib
+LIBRARY			efsrv.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/smsevent.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,303 @@
+// smsevent.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "smsevent.h"
+#include "sms.h"
+
+_LIT(KInternationlDialDirectIndicator,	"+");
+
+//
+// CSmsEventBase
+//
+CSmsEventBase::CSmsEventBase(CCmdSms& aObserver):
+CActive(CActive::EPriorityStandard), iObserver(aObserver)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+//
+// CSmsEventDial
+//
+CSmsEventDial* CSmsEventDial::NewL(CCmdSms& aObserver, RCall::TTelNumberC& aTelNumber)
+	{
+	CSmsEventDial* self = new (ELeave) CSmsEventDial(aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL(aTelNumber);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CSmsEventDial::CSmsEventDial(CCmdSms& aObserver):
+CSmsEventBase(aObserver), iState(ESmsEventNetworkIdle)
+	{
+	}
+
+CSmsEventDial::~CSmsEventDial()
+	{
+	Cancel();
+	iTimeout.Cancel();
+	iTimeout.Close();
+	if (iCall.SubSessionHandle() > 0)
+		iCall.Close(); // should also force a hangup on the call object if it's active
+	if (iLine.SubSessionHandle() > 0)
+		iLine.Close();
+	if (iPhone.SubSessionHandle() > 0)
+		iPhone.Close();
+	if (iTelServer.Handle() > 0)
+		iTelServer.Close();
+	}
+
+void CSmsEventDial::ConstructL(RCall::TTelNumberC& aTelNumber)
+	{
+	// timeout timer 
+	iTimeout.CreateLocal();
+	
+	// capture the number to dial
+	iNumber.iTypeOfNumber = RMobilePhone::ENationalNumber;
+	iNumber.iNumberPlan = RMobilePhone::EIsdnNumberPlan;
+	iNumber.iTelNumber.Copy(aTelNumber);
+	
+	// check if there's a '+' at the front of the number
+	if (aTelNumber.MatchC(KInternationlDialDirectIndicator) == 0)
+		iNumber.iTypeOfNumber = RMobilePhone::EInternationalNumber;
+	
+	// connect to ETel. Note we're assuming the TSY has been loaded already
+	RTelServer::TPhoneInfo phoneInfo;
+	User::LeaveIfError(iTelServer.Connect());
+	User::LeaveIfError(iTelServer.GetPhoneInfo(0, phoneInfo));
+	
+	// open the first phone object
+	User::LeaveIfError(iPhone.Open(iTelServer, phoneInfo.iName));
+	
+	// find the voice line & open it
+	TInt lines = 0;
+	RPhone::TLineInfo lineInfo;
+	User::LeaveIfError(iPhone.EnumerateLines(lines));
+	if (lines <= 0)
+		User::Leave(KErrNotSupported);
+	for (TInt ii = 0 ; ii < lines ; ii++)
+		{
+		User::LeaveIfError(iPhone.GetLineInfo(ii, lineInfo));
+		if (lineInfo.iLineCapsFlags & RLine::KCapsVoice)
+			{
+			// found our voice line
+			if (lineInfo.iStatus > RCall::EStatusIdle)
+				User::Leave(KErrInUse);
+			User::LeaveIfError(iLine.Open(iPhone, lineInfo.iName));
+			break;
+			}
+		}
+	if (iLine.SubSessionHandle() <= 0)
+		User::Leave(KErrNotFound);
+	
+	// create a voice call (note it's not currently active)
+	User::LeaveIfError(iCall.OpenNewCall(iLine, iCallName));
+	}
+
+//
+// CSmsEventDial::StartL
+// start the dial-out procedure, beginning
+// with a check of the network, line/call status
+//
+void CSmsEventDial::StartL()
+	{
+	User::LeaveIfError(iLine.GetMobileLineStatus(iCallStatus));
+	if (iCallStatus > RMobileCall::EStatusIdle)
+		User::Leave(KErrInUse);
+	
+	// some product tsy implementations can't handle a dial request immediately following receiving an sms. so we wait a little bit..5 seconds in fact
+	iTimeout.After(iStatus, 5000000);
+	SetActive();
+	iState = ESmsEventDial;
+	}
+
+void CSmsEventDial::RunL()
+	{
+	User::LeaveIfError(iStatus.Int()); // process the error elsewhere
+	switch (iState)
+		{
+		case ESmsEventDial:
+			{
+			// dial the number
+			iCall.Dial(iStatus, iNumber.iTelNumber);
+			SetActive();
+			iState = ESmsEventStatusChange;
+			}
+		break;
+				
+		case ESmsEventWatchStatus:
+		case ESmsEventStatusChange:
+			{
+			User::LeaveIfError(iCall.GetMobileCallStatus(iCallStatus));
+			if (iCallStatus > RMobileCall::EStatusIdle)
+				{
+				// keep the call going until it drops
+				iCall.NotifyMobileCallStatusChange(iStatus, iCallStatus);
+				SetActive();
+				iState = ESmsEventWatchStatus;
+				return;
+				}
+			}
+		break;
+		
+		default:
+		break;
+		};
+	}
+
+//
+// CSmsEventDial::RunError
+// inform the observer we hit a prob. with execution of the dial state machine
+//
+TInt CSmsEventDial::RunError(TInt /*aError*/)
+	{
+	//TODO iObserver.EventComplete(aError); 
+	return KErrNone;
+	}
+
+void CSmsEventDial::DoCancel()
+	{
+	switch (iState)
+		{
+		case ESmsEventDial:
+			iTimeout.Cancel();
+		break;
+		
+		case ESmsEventStatusChange:
+			iCall.DialCancel();
+		break;
+		
+		case ESmsEventWatchStatus:
+			iCall.NotifyStatusChangeCancel();			
+		break;
+		
+		default:
+		break;
+		};
+	}
+
+CSmsShellCommand* CSmsShellCommand::NewL(CCmdSms& aObserver, const TDesC& aCommandText, const TDesC& aSenderAddress)
+	{
+	CSmsShellCommand* self = new(ELeave) CSmsShellCommand(aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL(aCommandText, aSenderAddress);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CSmsShellCommand::CSmsShellCommand(CCmdSms& aObserver)
+	: CSmsEventBase(aObserver)
+	{
+	}
+
+void CSmsShellCommand::ConstructL(const TDesC& aCommandText, const TDesC& aSenderAddress)
+	{
+	iSmsSender.CreateL(aSenderAddress);
+	// Set up environment for script
+	iScriptEnv = CEnvironment::NewL(iObserver.Env());
+	_LIT(KSmsSenderEnvironmentVariable, "SMS_SENDER");
+	iScriptEnv->SetL(KSmsSenderEnvironmentVariable, iSmsSender);
+
+	const TDesC* scriptName = NULL;
+	_LIT(KFshellName, "C:\\shared\\fshellscript%d.script");
+	_LIT(KPerlName, "C:\\shared\\perlscript%d.pl");
+	if (aCommandText.MatchF(_L("#!fshell*")) == 0)
+		{
+		iExeName = _L("fshell.exe");
+		scriptName = &KFshellName;
+		}
+	else if (aCommandText.MatchF(_L("#!perl*")) == 0)
+		{
+		iExeName = _L("perl.exe");
+		scriptName = &KPerlName;
+		}
+	else
+		{
+		User::Leave(KErrArgument);
+		}	
+	
+	RBuf8 buf;
+	CleanupClosePushL(buf);
+	buf.CreateL(aCommandText.Length());
+	buf.Copy(aCommandText);
+
+	RFile scriptFile;
+	CleanupClosePushL(scriptFile);
+	TInt nonce = 0;
+	iObserver.Fs().MkDirAll(*scriptName);
+	TInt err = KErrNone;
+	do {
+		iScriptFile.Format(*scriptName, nonce);
+		nonce++;
+		err = scriptFile.Create(iObserver.Fs(), iScriptFile, EFileShareAny|EFileWrite);
+		} while (err == KErrAlreadyExists);
+	User::LeaveIfError(scriptFile.Write(buf));
+	CleanupStack::PopAndDestroy(2, &buf);
+	}
+
+void CSmsShellCommand::StartL()
+	{
+	iProcess.CreateL(iExeName, iScriptFile, iObserver.IoSession(), iObserver.Stdin(), iObserver.Stdout(), iObserver.Stderr(), *iScriptEnv);
+	iProcess.Run(iStatus);
+	SetActive();
+	}
+
+void CSmsShellCommand::DoCancel()
+	{
+	iProcess.Process().LogonCancel(iStatus);
+	}
+
+CSmsShellCommand::~CSmsShellCommand()
+	{
+	Cancel();
+	iProcess.Close();
+	if (!iObserver.Debug())
+		{
+		iObserver.Fs().Delete(iScriptFile);
+		}
+	delete iScriptEnv;
+	iSmsSender.Close();
+	}
+
+void CSmsShellCommand::RunL()
+	{
+	TExitType exitType = iProcess.Process().ExitType();
+	TInt exitReason = iProcess.Process().ExitReason();
+	TBool ok = exitType == EExitKill && exitReason == 0;
+	if (ok)
+		{
+		iObserver.Printf(_L("Script from %S completed ok.\r\n"), &iSmsSender);
+		}
+	else
+		{
+		TInt err = exitReason;
+		if (err >= 0) err = KErrGeneral;
+		switch (iProcess.Process().ExitType())
+			{
+			case EExitKill:
+				iObserver.PrintError(err, _L("Script %S failed, returned %d"), &iScriptFile, exitReason);
+				break;
+			case EExitTerminate:
+				iObserver.PrintError(err, _L("Script %S terminated with %d"), &iScriptFile, exitReason);
+				break;
+			case EExitPanic:
+				{
+				TExitCategoryName cat = iProcess.Process().ExitCategory();
+				iObserver.PrintError(err, _L("Script %S panicked with %S %d"), &iScriptFile, &cat, exitReason);
+				break;
+				}
+			default:
+				break;
+			}
+		}
+	delete this;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/smsevent.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,103 @@
+// smsevent.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SMS_EVENT_H__
+#define __SMS_EVENT_H__
+
+#include <e32base.h>
+#include <etelmm.h>
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdSms;
+
+//
+// CSmsEventBase
+// abstrace base class providing functionality
+// common to all sms events
+//
+class CSmsEventBase : public CActive
+	{
+public:
+	// pure virtuals 
+	virtual void StartL() = 0;
+
+protected:
+	CSmsEventBase(CCmdSms& aObserver);
+
+protected:
+	CCmdSms& iObserver;
+	};
+
+//
+// CSmsEventDial
+// functionality specific to a dial event
+// 
+NONSHARABLE_CLASS(CSmsEventDial) : public CSmsEventBase
+	{
+public:
+	static CSmsEventDial* NewL(CCmdSms& aObserver, RCall::TTelNumberC& aTelNumber);
+	virtual ~CSmsEventDial();
+
+	// from CSmsEventBase 
+	virtual void StartL();
+	
+	// from CActive
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+private:
+	CSmsEventDial(CCmdSms& aObserver);
+	void ConstructL(RCall::TTelNumberC& aTelNumber);
+private:
+	RTelServer iTelServer;
+	RMobilePhone iPhone;
+	RMobileLine iLine;
+	RMobileCall iCall;
+	RMobilePhone::TMobileAddress iNumber;
+	TName iCallName;
+	RMobileCall::TMobileCallStatus iCallStatus;
+	RTimer iTimeout;
+	
+	enum TSmsEventState
+		{
+		ESmsEventNetworkIdle,
+		ESmsEventDial,
+		ESmsEventStatusChange,
+		ESmsEventWatchStatus
+		};
+	TSmsEventState iState;
+	};
+
+NONSHARABLE_CLASS(CSmsShellCommand) : public CSmsEventBase
+	{
+public:
+	static CSmsShellCommand* NewL(CCmdSms& aObserver, const TDesC& aCommandText, const TDesC& aSenderAddress);
+	~CSmsShellCommand();
+	void StartL();
+
+private:
+	CSmsShellCommand(CCmdSms& aObserver);
+	void ConstructL(const TDesC& aCommandText, const TDesC& aSenderAddress);
+	void RunL();
+	void DoCancel();
+
+private:
+	RChildProcess iProcess;
+	TFileName iScriptFile;
+	TBuf<32> iExeName;
+	CEnvironment* iScriptEnv;
+	RBuf iSmsSender;
+	};
+
+#endif // __SMS_EVENT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/smssend.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,200 @@
+// smssend.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <gsmuset.h>
+#include "smssend.h"
+
+CSmsSender* CSmsSender::NewL(RFs& aFs, MSmsSendObserver& aParent, const TDesC& aMsgToSend, const TDesC& aDestination)
+	{
+	CSmsSender* self = new (ELeave) CSmsSender(aParent, aFs, aMsgToSend, aDestination);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CSmsSender::CSmsSender(MSmsSendObserver& aParent, RFs& aFs, const TDesC& aMsgToSend, const TDesC& aDestination):
+CActive(CActive::EPriorityStandard), iParent(aParent), iFs(aFs), iMsgContent(aMsgToSend), iDestination(aDestination), iState(ESmsSenderIdle)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CSmsSender::~CSmsSender()
+	{
+	// iMsgBuffer doesn't need to be explicitly deleted. iMsgSend takes care of that
+	if (iMsgToSend)
+		delete iMsgToSend;
+	if (iSmspList)
+		delete iSmspList;
+	if (iMobileMessaging.SubSessionHandle() > 0)
+		iMobileMessaging.Close();
+	if (iPhone.SubSessionHandle() > 0)
+		iPhone.Close();
+	if (iTelServer.Handle() > 0)
+		iTelServer.Close();
+	if (iSocket.SubSessionHandle())
+		iSocket.Close();
+	if (iSocketServer.Handle())
+		iSocketServer.Close();
+	}
+
+void CSmsSender::ConstructL()
+	{
+	// connect to ETel. Note we're assuming the TSY has been loaded already
+	RTelServer::TPhoneInfo phoneInfo;
+	User::LeaveIfError(iTelServer.Connect());
+	User::LeaveIfError(iTelServer.GetPhoneInfo(0, phoneInfo));
+	
+	// open the first phone object
+	User::LeaveIfError(iPhone.Open(iTelServer, phoneInfo.iName));
+	
+	// open a hook to messaging functionality
+	User::LeaveIfError(iMobileMessaging.Open(iPhone));
+	
+	// JoeF: I can't see a sane way to just retrieve the gsm service centre address from the sim?!
+	iSmspList = CRetrieveMobilePhoneSmspList::NewL(iMobileMessaging);
+	
+	// connect & bind the sms socket
+	User::LeaveIfError(iSocketServer.Connect());
+	User::LeaveIfError(iSocket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol));
+	iSmsAddr.SetSmsAddrFamily(ESmsAddrSendOnly);
+	User::LeaveIfError(iSocket.Bind(iSmsAddr));
+	}
+
+void CSmsSender::StartL()
+	{
+	ASSERT(!IsActive());
+	
+	// retrieve the gsm service centre number from the sim
+	iSmspList->Start(iStatus);
+	iState = ESmsSenderGetServiceCentre;
+	SetActive();
+	}
+
+void CSmsSender::RunL()
+	{
+	TInt error = iStatus.Int();
+	if (error != KErrNone)
+		{
+		iParent.SendComplete(error);
+		return;
+		}
+	switch (iState)
+		{
+		case ESmsSenderGetServiceCentre:
+			{
+			error = GetServiceCentreAndSendSms();
+			if (error == KErrNone)
+				return;
+			}
+		break;
+		
+		case ESmsSenderSendMessage:
+			iState = ESmsSenderIdle;
+		break;
+		
+		default:
+		break;
+		};
+	iParent.SendComplete(error);
+	}
+
+void CSmsSender::DoCancel()
+	{
+	switch (iState)
+		{
+		case ESmsSenderGetServiceCentre:
+			iSmspList->Cancel();
+		break;
+		
+		case ESmsSenderSendMessage:
+			iSocket.CancelIoctl();
+		break;
+		
+		default:
+		break;
+		};
+	}
+
+//
+// CSmsSender::GetServiceCentreAndSendSms
+// retrieve the service centre phone number & 
+// create a correctly formatted sms message from
+// the constiuent parts gathered. Send the sms
+//
+TInt CSmsSender::GetServiceCentreAndSendSms()
+	{
+	TRAPD(err, RetrieveServiceCentreL());
+	if (err == KErrNone)
+		TRAP(err, CreateAndSendSmsL());
+	return err;
+	}
+
+//
+// CSmsSender::RetrieveServiceCentreL
+// extract the service centre from the smsp list
+//
+void CSmsSender::RetrieveServiceCentreL()
+	{
+	if (iSmspList)
+		{
+		CMobilePhoneSmspList* list = iSmspList->RetrieveListL();
+		if (list)
+			{
+			TInt count = list->Enumerate();
+			while (--count >= 0)
+				{
+				const RMobileSmsMessaging::TMobileSmspEntryV1& entry = list->GetEntryL(count);
+				if (entry.iServiceCentre.iTelNumber.Length() > 0)
+					{
+					iServiceCentre.iTypeOfNumber = entry.iServiceCentre.iTypeOfNumber;
+					iServiceCentre.iNumberPlan = entry.iServiceCentre.iNumberPlan;
+					iServiceCentre.iTelNumber = entry.iServiceCentre.iTelNumber;
+					return;
+					}
+				}
+			}
+		}
+	User::Leave(KErrNotFound);
+	}
+
+//
+// CSmsSender::CreateAndSendSmsL
+// create a correctly formatted sms from the available data
+// send it on its way via smsstack
+//
+void CSmsSender::CreateAndSendSmsL()
+	{
+	TSmsUserDataSettings settings;
+	settings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet7Bit);
+	settings.SetTextCompressed(EFalse);
+	
+	iMsgBuffer = CSmsBuffer::NewL();
+	iMsgBuffer->InsertL(0, iMsgContent);
+	iMsgToSend = CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit, iMsgBuffer);
+	iMsgToSend->SetUserDataSettingsL(settings);
+	iMsgToSend->SetToFromAddressL(iDestination);
+	iMsgToSend->SmsPDU().SetServiceCenterAddressL(iServiceCentre.iTelNumber);
+	
+	ASSERT(iSocket.SubSessionHandle() > 0);
+	RSmsSocketWriteStream writestream(iSocket);
+	writestream << *iMsgToSend;
+	writestream.CommitL();
+
+	TPckgBuf<TUint> sbuf;
+	iSocket.Ioctl(KIoctlSendSmsMessage, iStatus, &sbuf, KSolSmsProv);
+	SetActive();
+	iState = ESmsSenderSendMessage;
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/smssend.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,70 @@
+// smssend.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SMS_SEND_H__
+#define __SMS_SEND_H__
+
+#include <gsmubuf.h>
+#include <gsmumsg.h>
+#include <es_sock.h>
+#include <smsustrm.h>
+#include <smsuaddr.h>
+#include <mmretrieve.h>
+
+class MSmsSendObserver
+	{
+public:
+	virtual void SendComplete(const TInt aError) = 0;
+	};
+
+NONSHARABLE_CLASS(CSmsSender) : public CActive
+	{
+public:
+	static CSmsSender* NewL(RFs& aFs, MSmsSendObserver& aParent, const TDesC& aMsgToSend, const TDesC& aDestination);
+	~CSmsSender();
+	void StartL();
+private:
+	CSmsSender(MSmsSendObserver& aParent, RFs& aFs, const TDesC& aMsgToSend, const TDesC& aDestination);
+	void ConstructL();
+	TInt GetServiceCentreAndSendSms();
+	void RetrieveServiceCentreL();
+	void CreateAndSendSmsL();
+	
+	// From CActive
+	void RunL();
+	void DoCancel();
+private:
+	MSmsSendObserver& iParent;
+	RFs& iFs;
+	const TDesC& iMsgContent;
+	const TDesC& iDestination;
+	CSmsBuffer* iMsgBuffer;
+	CSmsMessage* iMsgToSend;
+	RMobilePhone::TMobileAddress iServiceCentre;
+	RTelServer iTelServer;
+	RMobilePhone iPhone;
+	RMobileSmsMessaging iMobileMessaging;
+	CRetrieveMobilePhoneSmspList* iSmspList;
+	RSocketServ iSocketServer;
+	RSocket iSocket;
+	TSmsAddr iSmsAddr;
+	
+	enum TSmsSenderState
+		{
+		ESmsSenderIdle,
+		ESmsSenderGetServiceCentre,
+		ESmsSenderSendMessage
+		};
+	TSmsSenderState iState;
+	};
+
+#endif // __SMS_SEND_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/smswatch.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,298 @@
+// smswatch.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "smswatch.h"
+#include <gsmumsg.h>
+#include <gsmubuf.h>
+#include <smsustrm.h>
+#include "sms.h"
+
+// __TEST_MODE__ provides a dummy autometric command
+//#define __TEST_MODE__
+
+#undef ASSERT
+#define ASSERT(x) if (!(x)) { iParent.Printf(_L8("Assertion failed at line %d: " #x "\r\n"), __LINE__); PanicMe(__LINE__); }
+
+// local static method definitions
+static void PanicMe(TInt aError)
+	 {
+	 _LIT(KSmsWatcherPanic, "AmSms");
+	 User::Panic(KSmsWatcherPanic, aError);	 
+	 }
+
+//
+// CSmsWatcher
+//
+CSmsWatcher* CSmsWatcher::NewL(CCmdSms& aParent)
+	{
+	CSmsWatcher* self = new (ELeave) CSmsWatcher(aParent);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+CSmsWatcher::CSmsWatcher(CCmdSms& aParent)
+	: CActive(CActive::EPriorityStandard), iParent(aParent), iState(ESmsListenIdle)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CSmsWatcher::~CSmsWatcher()
+	{
+	Cancel();
+	delete iMessage;
+	iCommand.Close();
+	if (iSocket.SubSessionHandle() > 0)
+		iSocket.Close();
+	if (iSocketServer.Handle() > 0)
+		iSocketServer.Close();
+	}
+
+void CSmsWatcher::ConstructL()
+	{
+	// connect to the sms socket
+	User::LeaveIfError(iSocketServer.Connect());
+	User::LeaveIfError(iSocket.Open(iSocketServer,KSMSAddrFamily,KSockDatagram,KSMSDatagramProtocol));
+	iSmsAddr.SetSmsAddrFamily(ESmsAddrMatchText);
+	_LIT8(KShebang, "#!");
+	iSmsAddr.SetTextMatch(KShebang());
+	User::LeaveIfError(iSocket.Bind(iSmsAddr));
+	}
+
+void CSmsWatcher::DoCancel()
+	{
+	switch(iState)
+		{
+		case ESmsListenReadSms:
+		case ESmsListenProcessSms:
+		case ESmsListenIdle: // This could happen when signalling failure via KIoctlReadMessageFailed
+			iSocket.CancelIoctl();
+			break;
+		default:
+			PanicMe(__LINE__);
+		}
+	}
+
+
+void CSmsWatcher::RunL()
+	{
+	iErrorMessage.Zero();
+	if (iStatus.Int() < 0)
+		{
+		iErrorMessage.AppendFormat(_L("Error reported from CSmsWatcher::RunL"));
+		User::Leave(iStatus.Int()); // process any errors elsewhere
+		}
+	
+	switch(iState)
+		{
+		case ESmsListenReadSms:
+			ReadSmsAndRespondToStackL(); // inform the stack we've got the sms
+			break;
+		
+		case ESmsListenProcessSms:
+			ProcessCommandL(); // process the contents of the sms
+			WaitForMessage(); // Start listening for another message (RunError will call it if ProcessCommandL leaves)
+			break;
+#ifdef __TEST_MODE__
+		case ESmsListenTestMode:
+			{
+			// a test mode skipping reception & decoding of an autometric sms
+			//_LIT(KTestMsg, "!#AUTOMETRIC;d:0243261943;?");
+			_LIT(KTestMsg, "#!fshell\ninfoprint \"hello world!\"\n");
+			ParseBufferL(KTestMsg, _L("012345678"));
+			}
+			break;
+#endif
+		case ESmsListenIdle:
+			//CompleteWatch(KErrCompletion); // indicate an error with a prior event
+			break;
+		
+		default:
+			PanicMe(KErrUnknown); // design fault
+			break;
+		}
+	}
+
+//
+// CSmsWatcher::RunError
+// handle any probs with the state machine 
+//
+TInt CSmsWatcher::RunError(TInt aError)
+	{
+	switch (iState)
+		{
+		case ESmsListenProcessSms:
+			// Problem such as bad message - log it and carry on
+			if (iErrorMessage.Length())
+				{
+				iParent.PrintError(aError, iErrorMessage);
+				}
+			else
+				{
+				iParent.PrintError(aError, _L("Error when processing SMS"));
+				}
+			WaitForMessage(); // Start listening for another message
+		break;
+		
+		case ESmsListenReadSms:
+			{
+			// inform the stack we've failed to retrieve the sms. Likely due to OOM when calling PrepBuffersL
+			iSocket.Ioctl(KIoctlReadMessageFailed, iStatus, &iIoctlResult, KSolSmsProv);
+			SetActive();
+			iState = ESmsListenIdle;
+			}
+		break;
+		
+		default:
+			PanicMe(__LINE__); // design fault
+		break;
+		};
+	return KErrNone;
+	}
+
+//
+// CSmsWatcher::WaitForMessage
+// posts an async. read against the sms socket waiting for an incoming sms
+//
+void CSmsWatcher::WaitForMessage()
+	{
+	ASSERT(!IsActive());
+
+#ifndef __TEST_MODE__
+	iIoctlResult = KSockSelectRead;
+	ASSERT(iSocket.SubSessionHandle() > 0);
+	iSocket.Ioctl(KIOctlSelect, iStatus, &iIoctlResult, KSOLSocket);
+	iState = ESmsListenReadSms;
+#else
+	TRequestStatus* status = &iStatus;
+	*status = KRequestPending;
+	User::RequestComplete(status, KErrNone);
+	iState = ESmsListenTestMode;
+#endif
+	SetActive();
+	}
+
+//
+// CSmsWatcher::ReadSmsAndRespondToStackL
+// retrieve the sms and inform the stack whether we've got it
+//
+void CSmsWatcher::ReadSmsAndRespondToStackL()
+	{
+	// prep. buffers used to hold the message
+	PrepBuffersL();
+	
+	// retrieve the sms from the stack
+	RSmsSocketReadStream readstream1(iSocket);
+	CleanupClosePushL(readstream1);
+	iMessage->InternalizeL(readstream1);
+	CleanupStack::PopAndDestroy();
+	
+	// inform the stack we've got the sms
+	iSocket.Ioctl(KIoctlReadMessageSucceeded, iStatus, &iIoctlResult, KSolSmsProv);
+	iState = ESmsListenProcessSms;
+	SetActive();
+	}
+
+//
+// CSmsWatcher::ProcessCommandL
+// having captured the sms that contains the command, slurp it out & process any instructions contained therein
+//
+void CSmsWatcher::ProcessCommandL()
+	{
+	ASSERT(iMessage);
+	ASSERT(iCommand.Length() == 0);
+	const TInt length = iMessage->Buffer().Length();
+	iCommand.CreateL(length);
+	iMessage->Buffer().Extract(iCommand, 0, length);
+	TPtrC address = iMessage->ToFromAddress();
+	ParseBufferL(iCommand, address);
+	}
+
+//
+// CSmsWatcher::PrepBuffersL
+// trash the old buffer data, replace with virgin ones
+//
+void CSmsWatcher::PrepBuffersL()
+	{
+	delete iMessage;
+	iMessage = NULL;
+	iCommand.Close();
+	CSmsBuffer* buffer = CSmsBuffer::NewL();
+	CleanupStack::PushL(buffer);
+	iMessage = CSmsMessage::NewL(iParent.Fs(), CSmsPDU::ESmsDeliver, buffer);
+	CleanupStack::Pop(buffer); // iMessage takes ownership
+	}
+
+//
+// CSmsWatcher::ParseInstructionsL
+// interpret the instructions received OTA
+// eg: "#!fshell\necho Hello!\n"
+//
+void CSmsWatcher::ParseBufferL(const TDesC& aInstruction, const TDesC& aSenderAddress)
+	{
+	TBool accept = EFalse;
+	RPointerArray<HBufC>& matchStrings = iParent.MatchStrings();
+	if (matchStrings.Count()==0)
+		{
+		accept = ETrue;
+		}
+	else
+		{
+		for (TInt i=0; i<matchStrings.Count(); ++i)
+			{
+			Printf(_L("Sender %S matches %S: "), &aSenderAddress, matchStrings[i]);
+			if (aSenderAddress.Match(*matchStrings[i])!=KErrNotFound)
+				{
+				accept = ETrue;
+				}
+			}
+		}
+		
+	if (!accept)
+		{
+		iErrorMessage.Zero();
+		iErrorMessage.AppendFormat(_L("Rejecting SMS from %S: did not match authorised sender"), &aSenderAddress);
+		User::Leave(KErrAccessDenied);
+		}
+	
+	
+	if (aInstruction.MatchF(_L("#!fshell*")) == 0 || aInstruction.MatchF(_L("#!perl*")) == 0)
+		{
+		CSmsShellCommand* command = CSmsShellCommand::NewL(iParent, aInstruction, aSenderAddress);
+		command->StartL();		
+		}
+	else
+		{
+		TPtrC firstLine(aInstruction);
+		TInt pos = firstLine.Find(_L("\n"));
+		if (pos!=KErrNotFound)
+			{
+			firstLine.Set(firstLine.Left(pos));
+			if ((firstLine.Length()>0)&&(firstLine[firstLine.Length()-1]=='\r'))
+				{
+				firstLine.Set(firstLine.Left(firstLine.Length()-1));
+				}
+			}
+		iErrorMessage.Zero();
+		iErrorMessage.AppendFormat(_L("Unhandled shebang command from %S: %S"), &aSenderAddress, &firstLine);
+		User::Leave(KErrArgument);
+		}
+	}
+
+//
+// CSmsWatcher::Message
+// 
+const TDesC& CSmsWatcher::Message()
+	{
+	return iCommand;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sms/smswatch.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,66 @@
+// smswatch.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SMS_WATCH__
+#define __SMS_WATCH__
+
+#include <smsuaddr.h>
+class CSmsMessage;
+#include "smsevent.h"
+
+//
+// CSmsWatcher
+// listen for incoming sms's from smsstack (via esock)
+// interpret & execute the command contained therein
+//
+NONSHARABLE_CLASS(CSmsWatcher) : public CActive
+	{
+public:
+	static CSmsWatcher* NewL(CCmdSms& aParent);
+	~CSmsWatcher();
+	void WaitForMessage();
+	const TDesC& Message();
+private:
+	CSmsWatcher(CCmdSms& aParent);
+	void ConstructL();
+	void ReadSmsAndRespondToStackL();
+	void PrepBuffersL();
+	void ProcessCommandL();
+	void ParseBufferL(const TDesC& aInstruction, const TDesC& aSenderAddress);
+	
+	// from CActive
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+private:
+	CCmdSms& iParent;
+	RSocketServ iSocketServer;
+	RSocket iSocket;
+	TSmsAddr iSmsAddr;
+	TPckgBuf<TUint>	iIoctlResult;
+	CSmsMessage* iMessage;
+	RBuf iCommand;
+		
+	enum TSmsListenState
+		{
+		ESmsListenIdle,
+		ESmsListenWaitForSms,
+		ESmsListenReadSms,
+		ESmsListenProcessSms,
+		ESmsListenTestMode
+		};
+	TSmsListenState iState;
+	TBuf<0x100> iErrorMessage;
+	};
+
+
+#endif // __SMS_WATCH__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/snake/snake.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+# snake.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name snake
+
+==short-description
+
+Snake!
+
+==long-description
+
+Basic snake game. Move the snake around the screen using the cursor keys to gather the bait ($) without colliding with the side of the screen or the tail of your snake.
+
+Press escape at any time to exit the game.
+
+==option int s speed
+
+Speed of the game, in microseconds. This is the interval between each step forward the snake makes. Values in the range of 200000 (very easy) to 10000 (very hard) are reasonable.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/snake/snake.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,473 @@
+// snake.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <e32math.h>
+
+using namespace IoUtils;
+
+_LIT(KSnakeSeg, "*");
+_LIT(KBait, "$");
+
+class CKeyWatcher;
+
+class CCmdSnake : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSnake();
+	
+	void Up();
+	void Down();
+	void Left();
+	void Right();
+	void Exit();
+	void OnTimer();
+private:
+	CCmdSnake();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	
+	void ConstructL();
+	void InitBoardL();
+	void SetBoard(TInt aX, TInt aY, TBool aSet);
+	TBool GetBoard(TInt aX, TInt aY);
+	void DrawBoardL();
+	void InitSnakeL(TInt aLen, TPoint aPos);
+	void DrawSnakeL();
+	void DrawScore();
+	void PlaceBait();
+	void Grow();
+	
+	void Dead();
+private:
+	RIoConsoleWriteHandle iCons;
+	RIoConsoleReadHandle iConsIn;
+	TSize iBoardSize;
+	RArray<TPoint> iSnake;
+	TInt iSnakeHead;
+	RArray<TUint32> iBoard;
+	TInt iBoardWidthWords;
+	TPoint iDirection;
+	TPoint iBait;
+	TInt iScore;
+	TInt iSpeed;
+	
+	CKeyWatcher* iKeys;
+	CPeriodic* iTimer;
+	TInt64 iRandomSeed;
+	TBool iInCollisionGracePeriod;
+	};
+
+class CKeyWatcher : public CActive
+	{
+public:
+	CKeyWatcher(CCmdSnake& aOwner, RIoConsoleReadHandle& aCons);
+	~CKeyWatcher();
+	void Request();
+
+private:
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	CCmdSnake& iOwner;
+	RIoConsoleReadHandle& iCons;
+	};
+
+
+CCommandBase* CCmdSnake::NewLC()
+	{
+	CCmdSnake* self = new(ELeave) CCmdSnake();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CCmdSnake::~CCmdSnake()
+	{
+	delete iKeys;
+	delete iTimer;
+	iSnake.Close();
+	iBoard.Close();
+	}
+
+CCmdSnake::CCmdSnake()
+	: CCommandBase(EManualComplete), iSpeed(50000)
+	{
+	}
+
+const TDesC& CCmdSnake::Name() const
+	{
+	_LIT(KName, "snake");	
+	return KName;
+	}
+	
+TInt OnTimerS(TAny* aSnake)
+	{
+	((CCmdSnake*)aSnake)->OnTimer();
+	return KErrNone;
+	}
+
+void CCmdSnake::DoRunL()
+	{
+	if (!Stdout().AttachedToConsole())
+		{
+		LeaveIfErr(KErrNotSupported, _L("Stdout must be connected to a console"));
+		}
+	iCons = Stdout();
+	if (!Stdin().AttachedToConsole())
+		{
+		LeaveIfErr(KErrNotSupported, _L("Stdin must be connected to a console"));
+		}
+	iConsIn = Stdin();
+	iKeys = new(ELeave)CKeyWatcher(*this, iConsIn);
+	iCons.SetCursorHeight(0);
+	
+	User::LeaveIfError(iCons.GetScreenSize(iBoardSize));
+	iBoardSize.iHeight--; // space for status bar, plus to ensure that the console doesn't scroll when we draw the bottom line
+	iBoardWidthWords = iBoardSize.iWidth / 32;
+	if (iBoardSize.iWidth % 32) ++iBoardWidthWords;
+	InitBoardL();
+	
+	DrawBoardL();
+	
+	TPoint centre;
+	centre.iX = iBoardSize.iWidth / 2;
+	centre.iY = iBoardSize.iHeight / 2;
+	InitSnakeL(10, centre);	
+	DrawSnakeL();
+	PlaceBait();
+	DrawScore();
+	
+	iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+	iTimer->Start(iSpeed, iSpeed, TCallBack(OnTimerS, this));
+	}
+
+void CCmdSnake::ArgumentsL(RCommandArgumentList& /*aArguments*/)
+	{
+	}
+
+void CCmdSnake::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptSpeed, "speed");
+	aOptions.AppendIntL(iSpeed, KOptSpeed);
+	}
+	
+void CCmdSnake::ConstructL()
+	{
+	BaseConstructL();
+	TTime now;
+	now.HomeTime();
+	iRandomSeed = now.Int64();
+	}
+
+void CCmdSnake::InitBoardL()
+	{
+	// first, zero the whole board
+	iBoard.Reset();
+	for (TInt y=0; y<iBoardSize.iHeight; ++y)
+		{
+		for (TInt x=0; x<iBoardWidthWords; ++x)
+			{
+			iBoard.AppendL(0);
+			}
+		}
+	// draw a box around the edge
+	for (TInt i=0; i<iBoardSize.iWidth; ++i)
+		{
+		SetBoard(i, 0, ETrue);
+		SetBoard(i, iBoardSize.iHeight-1, ETrue);
+		}
+	for (TInt i=0; i<iBoardSize.iHeight; ++i)
+		{
+		SetBoard(0, i, ETrue);
+		SetBoard(iBoardSize.iWidth-1, i, ETrue);
+		}
+	}
+	
+void CCmdSnake::SetBoard(TInt aX, TInt aY, TBool aSet)
+	{
+	TInt word = (aY * iBoardWidthWords) + (aX / 32);
+	TInt bit = 1 << (aX % 32);
+	if (aSet)
+		{
+		iBoard[word] |= bit;
+		}
+	else
+		{
+		iBoard[word] &= (~bit);
+		}
+	}
+	
+TBool CCmdSnake::GetBoard(TInt aX, TInt aY)
+	{
+	TInt word = (aY * iBoardWidthWords) + (aX / 32);
+	TInt bit = 1 << (aX % 32);
+	return iBoard[word] & bit;
+	}
+	
+void CCmdSnake::DrawBoardL()
+	{
+	User::LeaveIfError(iCons.ClearScreen());
+	
+	RBuf line;
+	line.CreateMaxL(iBoardSize.iWidth);
+	CleanupClosePushL(line);
+	
+	for (TInt y=0; y<iBoardSize.iHeight; ++y)
+		{
+		for (TInt x=0; x<iBoardSize.iWidth; ++x)
+			{
+			line[x] = GetBoard(x,y) ? '#' : ' ';
+			}
+		User::LeaveIfError(iCons.SetCursorPosAbs(TPoint(0, y)));
+		User::LeaveIfError(iCons.Write(line));
+		}
+	
+	
+	CleanupStack::PopAndDestroy();
+	}
+	
+void CCmdSnake::InitSnakeL(TInt aLen, TPoint aPos)
+	{
+	iSnake.Reset();
+	for (TInt i=0; i<aLen; ++i)
+		{
+		iSnake.AppendL(aPos);
+		}
+	iSnakeHead = 0;
+	}
+	
+void CCmdSnake::DrawSnakeL()
+	{
+	for (TInt i=0; i<iSnake.Count(); ++i)
+		{
+		User::LeaveIfError(iCons.SetCursorPosAbs(iSnake[i]));
+		User::LeaveIfError(iCons.Write(KSnakeSeg));
+		}
+	}
+
+void CCmdSnake::Up()
+	{
+	if (iDirection.iY != 1)
+		{
+		iDirection.SetXY(0, -1);
+		}
+	}
+	
+void CCmdSnake::Down()
+	{
+	if (iDirection.iY != -1)
+		{
+		iDirection.SetXY(0, 1);
+		}
+	}
+	
+void CCmdSnake::Left()
+	{
+	if (iDirection.iX != 1)
+		{
+		iDirection.SetXY(-1, 0);
+		}
+	}
+	
+void CCmdSnake::Right()
+	{
+	if (iDirection.iX != -1)
+		{
+		iDirection.SetXY(1, 0);
+		}
+	}
+	
+_LIT(KQuitFmt, "Quit; score: %d\n");
+
+void CCmdSnake::Exit()
+	{
+	iCons.SetCursorPosAbs(TPoint(0, iBoardSize.iHeight));
+	iCons.SetCursorHeight(20);
+	TBuf<0x20> buf;
+	buf.AppendFormat(KQuitFmt, iScore);
+	iCons.Write(buf);
+	Complete(iScore);
+	}
+	
+_LIT(KDeadFmt, "Game over; score: %d\n");
+
+void CCmdSnake::Dead()
+	{
+	iKeys->Cancel();
+	iCons.SetCursorPosAbs(TPoint(0, iBoardSize.iHeight));
+	iCons.SetCursorHeight(20);
+	TBuf<0x20> buf;
+	buf.AppendFormat(KDeadFmt, iScore);
+	iCons.Write(buf);
+	Complete(iScore);
+	}
+	
+void CCmdSnake::OnTimer()
+	{
+	iKeys->Request();
+	if (!(iDirection.iX || iDirection.iY)) return;
+	TPoint newHead = iSnake[iSnakeHead] + iDirection + iBoardSize;
+	newHead.iX %= iBoardSize.iWidth;
+	newHead.iY %= iBoardSize.iHeight;
+	
+	// check for obstacles
+	if (GetBoard(newHead.iX, newHead.iY))
+		{
+		if (iInCollisionGracePeriod)
+			{
+			Dead();
+			}
+		else
+			{
+			iInCollisionGracePeriod = ETrue;
+			}
+		return;
+		}
+	iInCollisionGracePeriod = EFalse;
+	for (TInt i=0; i<iSnake.Count(); ++i)
+		{
+		if (newHead == iSnake[i])
+			{
+			Dead();
+			return;
+			}
+		}
+	
+	TInt tail = (iSnakeHead+1) % iSnake.Count();
+	// overwrite the tail if it's not in the same position as the segment before it
+	if (iSnake[tail] != iSnake[(tail+1)%iSnake.Count()])
+		{
+		iCons.SetCursorPosAbs(iSnake[tail]);
+		iCons.Write(_L(" "));
+		}
+	iCons.SetCursorPosAbs(newHead);
+	iCons.Write(KSnakeSeg);
+	iSnakeHead = (iSnakeHead+1) % iSnake.Count();
+	iSnake[iSnakeHead] = newHead;
+	
+	if (iSnake[iSnakeHead] == iBait)
+		{
+		// Yummy!
+		iScore++;
+		DrawScore();
+		PlaceBait();
+		Grow();
+		}
+	}
+	
+_LIT(KScoreFormat, "Score: %d");
+	
+void CCmdSnake::DrawScore()
+	{
+	iCons.SetCursorPosAbs(TPoint(0, iBoardSize.iHeight));
+	TBuf<0x20> score;
+	score.AppendFormat(KScoreFormat, iScore);
+	iCons.Write(score);
+	}
+
+void CCmdSnake::PlaceBait()
+	{
+	TBool ok;
+	do
+		{
+		ok = ETrue;
+		iBait.iX = Math::Rand(iRandomSeed) % iBoardSize.iWidth;
+		iBait.iY = Math::Rand(iRandomSeed) % iBoardSize.iHeight;
+		
+		if (GetBoard(iBait.iX, iBait.iY)) ok = EFalse;
+		if (ok)
+			{
+			for (TInt i=0; i<iSnake.Count(); ++i)
+				{
+				if (iSnake[i] == iBait) ok = EFalse;
+				}
+			}
+		} while (!ok);
+	iCons.SetCursorPosAbs(iBait);
+	iCons.Write(KBait);
+	}
+
+void CCmdSnake::Grow()
+	{
+	TInt tail = (iSnakeHead+1)% iSnake.Count();
+	iSnake.Insert(iSnake[tail], tail);
+	if (tail < iSnakeHead) iSnakeHead++;
+	}
+
+
+
+EXE_BOILER_PLATE(CCmdSnake)
+
+
+//______________________________________________________________________________
+//						CKeyWatcher
+CKeyWatcher::CKeyWatcher(CCmdSnake& aOwner, RIoConsoleReadHandle& aCons)
+	: CActive(EPriorityHigh), iOwner(aOwner), iCons(aCons)
+	{
+	CActiveScheduler::Add(this);
+	Request();
+	}
+
+CKeyWatcher::~CKeyWatcher()
+	{
+	Cancel();
+	}
+
+void CKeyWatcher::RunL()
+	{
+	User::LeaveIfError(iStatus.Int());
+	TKeyCode key = (TKeyCode)iCons.KeyCode();
+	switch (key)
+		{
+	case EKeyUpArrow:
+	case '2':
+		iOwner.Up();
+		break;
+	case EKeyDownArrow:
+	case '8':
+		iOwner.Down();
+		break;
+	case EKeyLeftArrow:
+	case '4':
+		iOwner.Left();
+		break;
+	case EKeyRightArrow:
+	case '6':
+		iOwner.Right();
+		break;
+	case EKeyEscape:
+	case EKeyBackspace:
+		iOwner.Exit();
+		break;
+	default:
+		break;
+		}
+	}
+
+void CKeyWatcher::DoCancel()
+	{
+	iCons.WaitForKeyCancel();
+	}
+
+void CKeyWatcher::Request()
+	{
+	if (!IsActive())
+		{
+		iCons.WaitForKey(iStatus);
+		SetActive();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/snake/snake.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// snake.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          snake.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_SNAKE
+capability		none
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          snake.cpp
+
+library         euser.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/spinlock/spinlock.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+# spinlock.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name spinlock
+
+==short-description
+
+Consumes CPU cycles up to the loading you specify.
+
+==long-description
+
+Press CTRL-C or use the C<--duration> option to stop it.
+
+==see-also
+
+L<sleep|sleep>
+
+==argument int load optional
+
+The amount of CPU to consume. This number is the same order of magnitude as a percentage, but it isn't calibrated that precisely. So a number less than 10 generally produces a CPU load of a few percent, a value in the hundreds will generally max the CPU out. If omitted it will spin as fast as possible with no attempt at calibration.
+
+==option int s start-after
+
+Wait this number of seconds before starting to consume CPU. If not specified start immediately.
+
+==option int d duration
+
+Run for this number of seconds. If not specifed run indefinitely.
+
+==option int p priority
+
+Run the spinloop at this kernel priority. If not specified, use default priority 12 (C<EPriorityForeground+EPriorityNormal>).
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/spinlock/spinlock.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,146 @@
+// spinlock.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/memoryaccesscmd.h>
+#include <fshell/ioutils.h>
+#include <HAL.H>
+
+using namespace IoUtils;
+
+class CCmdSpinlock : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSpinlock();
+private:
+	CCmdSpinlock();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TInt iStartIn;
+	TInt iDuration;
+	TInt iLoad;
+	TInt iPriority;
+	volatile TInt iCounter;
+	};
+
+
+CCommandBase* CCmdSpinlock::NewLC()
+	{
+	CCmdSpinlock* self = new(ELeave) CCmdSpinlock();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSpinlock::~CCmdSpinlock()
+	{
+	}
+
+CCmdSpinlock::CCmdSpinlock()
+	{
+	}
+
+const TDesC& CCmdSpinlock::Name() const
+	{
+	_LIT(KName, "spinlock");
+	return KName;
+	}
+
+void CCmdSpinlock::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendIntL(iLoad, _L("load"));
+	}
+
+void CCmdSpinlock::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendIntL(iStartIn, _L("start-after"));
+	aOptions.AppendIntL(iDuration, _L("duration"));
+	aOptions.AppendIntL(iPriority, _L("priority"));
+	}
+
+EXE_BOILER_PLATE(CCmdSpinlock)
+
+void CCmdSpinlock::DoRunL()
+	{
+	if (iPriority)
+		{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+		LoadMemoryAccessL();
+
+		RThread me;
+		CleanupClosePushL(me);
+		LeaveIfErr(me.Open(me.Id()), _L("Couldn't open myself (!?!)"));
+		LeaveIfErr(iMemAccess.SetThreadPriority(me, iPriority), _L("Couldn't set priority"));
+		CleanupStack::PopAndDestroy(&me);
+#else
+		PrintWarning(_L("--priority is not supported if memoryaccess is not available."));
+#endif
+		}
+
+	if (iStartIn)
+		{
+		Printf(_L("Starting in %d seconds...\r\n"), iStartIn);
+		User::After(iStartIn * 1000000);
+		}
+
+	if (iDuration)
+		{
+		Printf(_L("Starting to spin for %d seconds... (Press CTRL-C to exit earlier)\r\n"), iDuration);
+		}
+	else
+		{
+		Printf(_L("Starting to spin... (Press CTRL-C to exit)\r\n"));
+		}
+
+	// We have ~300,000 cycles per millisecond to play with. We will do some amount of work then wait a millisecond.
+	// This is pretty arbitrary.
+
+	TInt tickPeriod;
+	HAL::Get(HAL::ENanoTickPeriod, tickPeriod);
+
+	TInt endTime; // in nkern ticks
+	if (iDuration)
+		{
+		endTime = User::NTickCount() + (iDuration * 1000000)/tickPeriod;
+		}
+	else
+		{
+		endTime = KMaxTInt;
+		}
+
+	if (iLoad)
+		{
+		//TODO this loop needs sorting out. The User::After is a bit broken.
+		TInt n = iLoad * 1000;
+		while (User::NTickCount() < (TUint)endTime)
+			{
+			for (iCounter = 0; iCounter < n; iCounter++)
+				{
+				// Let's do an exec call just for fun
+				UserSvr::DebugMask(0);
+				}
+
+			User::After(1000); // Wait 1 ms
+			}
+		}
+	else
+		{
+		// Just spin
+		while (User::NTickCount() < (TUint)endTime)
+			{
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/spinlock/spinlock.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// spinlock.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          spinlock.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_SPINLOCK
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          spinlock.cpp
+
+library         euser.lib
+library         iocli.lib
+library			hal.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sql/sql.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# sql.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name sql
+
+==short-description
+
+An interface to the Symbian SQLite API.
+
+==long-description
+
+This command is a thin client to a server process that is created on the first invokation. The server maintains state between invokations of this command. Run 'sql help' for a list of the available commands and 'sql E<lt>command-nameE<gt> --help' for help on individual commands.
+
+==option bool v verbose SQLCLI_VERBOSE
+
+Verbose output. Causes all communication between the client and server to be displayed.
+
+==argument string command last
+
+The SQL command to be executed.
+
+==copyright
+
+Copyright (c) 2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sql/sql.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,345 @@
+// sql.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+#include <fshell/ioutils.h>
+using namespace IoUtils;
+
+class TResponseLex
+	{
+public:
+	TResponseLex(const TDesC& aResponse);
+	
+	TInt GetIntColon(TInt& aValue);
+	TInt GetStringColon(TPtrC& aValue);
+	TInt GetIntEof(TInt& aValue);
+	TPtrC Remainder();
+private:
+	TPtrC iRemainder;
+	};
+
+class CCmdSqlCli : public CClientBase
+	{
+public:
+/*	
+	static const TDesC* PowerConsumptionToString(TPositionQuality::TPowerConsumption aPower);
+	static void CapabilitiesToString(TPositionModuleInfo::TCapabilities aCap, TDes &aDes);
+*/	
+	void PrintTime(const TTime& aTime, TBool aNewline);	
+	static CCommandBase* NewLC();
+	~CCmdSqlCli();
+private:
+	enum TLineProcessingBehaviour
+		{
+		EIgnoreLines,
+		EProcessLines,
+		};
+	
+	CCmdSqlCli();
+	
+	void ProcessLineL(const TDesC& aLine);
+	TBool MatchLineStart(const TDesC& aPrefix, TPtrC& aRemainder);
+	void ProcessErrorL(const TDesC& aDes);
+	void ProcessFailureL(const TDesC& aDes);
+	void UnrecognizedLineL(const TDesC& aDes);
+	void ProcessAsyncIdL(const TDesC& aDes);
+	void ProcessTimeoutL(const TDesC& aDes);
+	void ProcessResultL(const TDesC& aDes);
+	
+	void ProcessLogL(const TDesC& aDes);
+
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	// From CClientBase.
+	virtual void HandleServerResponseL(RPointerArray<HBufC> aLines);		
+	};
+
+///////////////////////////////////////////////////////////////////////////////
+
+_LIT(KPersistentConsoleName, "fshell_sqlsrv");
+_LIT(KSrvExeName, "fshell_sqlsrv");
+_LIT(KNewLine, "\r\n");
+_LIT(KPrompt, "ok\r\n");
+_LIT(KErrorPrefix, "error:");
+_LIT(KFailurePrefix, "failure:");
+_LIT(KAsyncIdPrefix, "id:");
+_LIT(KTimeoutPrefix, "timedout:");
+_LIT(KResultPrefix, "result:");
+_LIT(KLogPrefix, "log:");
+_LIT(KColon, ":");
+
+
+CCommandBase* CCmdSqlCli::NewLC()
+	{
+	CCmdSqlCli* self = new (ELeave)CCmdSqlCli();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSqlCli::CCmdSqlCli()
+	: CClientBase(0, KSrvExeName, KPersistentConsoleName, KPrompt)
+	{
+	//iActiveWait = new (ELeave) CActiveSchedulerWait;	
+	}
+
+
+CCmdSqlCli::~CCmdSqlCli()
+	{
+	}
+
+//////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////
+
+const TDesC& CCmdSqlCli::Name() const
+	{
+	_LIT(KName, "sql");
+	return KName;
+	}
+
+void CCmdSqlCli::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KVerbose);
+	}
+
+void CCmdSqlCli::HandleServerResponseL(RPointerArray<HBufC> aLines)
+	{
+	const TInt numLines = aLines.Count();
+	for (TInt i = 0; i < numLines; ++i)
+		{
+		ProcessLineL(*aLines[i]);
+		}
+	}
+
+TBool CCmdSqlCli::MatchLineStart(const TDesC& aPrefix, TPtrC& aRemainder)
+	{
+	if (aRemainder.Left(aPrefix.Length()).Compare(aPrefix)==0)
+		{
+		aRemainder.Set(aRemainder.Mid(aPrefix.Length()));
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+void CCmdSqlCli::UnrecognizedLineL(const TDesC& aDes)
+	{
+	if (!iVerbose)
+		{
+		Write(aDes);
+		Write(KNewLine);
+		}
+	}
+
+void CCmdSqlCli::ProcessLogL(const TDesC& aDes)
+	{
+	TResponseLex lex(aDes);
+	TInt id;
+	TInt err = lex.GetIntColon(id);
+	if (err != KErrNone)
+		{
+		UnrecognizedLineL(aDes);
+		}
+	}
+
+void CCmdSqlCli::ProcessLineL(const TDesC& aLine)
+	{
+	TPtrC remainder(aLine);
+	if (MatchLineStart(KErrorPrefix, remainder))
+		{
+		ProcessErrorL(remainder);
+		}
+	else if (MatchLineStart(KFailurePrefix, remainder))
+		{
+		ProcessFailureL(remainder);
+		}
+	else if (MatchLineStart(KAsyncIdPrefix, remainder))
+		{
+		ProcessAsyncIdL(remainder);
+		}
+	else if (MatchLineStart(KTimeoutPrefix, remainder))
+		{
+		ProcessTimeoutL(remainder);
+		}
+	else if (MatchLineStart(KResultPrefix, remainder))
+		{
+		ProcessResultL(remainder);
+		}
+	else if (MatchLineStart(KLogPrefix, remainder))
+		{
+		ProcessLogL(remainder);
+		}
+	else
+		{
+		UnrecognizedLineL(aLine);
+		}
+	}
+
+void CCmdSqlCli::ProcessErrorL(const TDesC& aDes)
+	{
+	TResponseLex lex(aDes);
+	TInt commandId;
+	TInt errorFromServer;
+	TInt err = lex.GetIntColon(errorFromServer);
+	if (err == KErrNone)
+		{
+		err = lex.GetIntColon(commandId);
+		}
+		
+	if (err == KErrNone)
+		{
+		TPtrC remander = lex.Remainder();
+		LeaveIfErr(errorFromServer, remander);
+		}
+	else
+		{
+		UnrecognizedLineL(aDes);
+		}
+	}
+
+void CCmdSqlCli::ProcessFailureL(const TDesC&)
+	{
+	LeaveIfErr(KErrGeneral, _L("Failed"));
+	}
+	
+void CCmdSqlCli::ProcessAsyncIdL(const TDesC& aDes)
+	{
+	TResponseLex lex(aDes);
+	TInt id;
+	TInt err = lex.GetIntEof(id);
+	if (err != KErrNone)
+		{
+		UnrecognizedLineL(aDes);
+		}
+	}
+
+void CCmdSqlCli::ProcessTimeoutL(const TDesC& aDes)
+	{
+	TResponseLex lex(aDes);
+	TInt id;
+	TInt err = lex.GetIntEof(id);
+	if (err == KErrNone)
+		{
+		LeaveIfErr(KErrTimedOut, _L("Command %d timed-out"), id);
+		}
+	else
+		{
+		UnrecognizedLineL(aDes);
+		}
+	}
+	
+void CCmdSqlCli::ProcessResultL(const TDesC& aDes)
+	{
+	TResponseLex lex(aDes);
+	TInt id;
+	TInt err = lex.GetIntColon(id);
+	if (err == KErrNone)
+		{
+		if (id == 0)
+			{
+			TPtrC name;
+			err = lex.GetStringColon(name);
+			if (err == KErrNone)
+				{
+				Write(lex.Remainder());
+				Write(KNewLine);
+				}
+			}
+		}
+	if (err != KErrNone)
+		{
+		UnrecognizedLineL(aDes);
+		}
+	}
+
+
+
+EXE_BOILER_PLATE(CCmdSqlCli)
+
+#define CASE_MODELIT(x) case x: { _LIT(KName, #x); pString = &KName; break; }
+
+void CCmdSqlCli::PrintTime(const TTime& aTime, TBool aNewline)
+	{	
+	TTime NullTime = Time::NullTTime();
+	if (aTime == NullTime) 
+		{
+		Printf(_L("(NullTime)"));
+		}
+	else
+		{
+		_LIT8(KDateTimeFormat, "%d-%02d-%02d %02d:%02d:%02d");
+		TDateTime dt = aTime.DateTime();
+		Printf(KDateTimeFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
+		}
+	
+	if (aNewline) Printf(_L("\r\n"));
+	}
+
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+TResponseLex::TResponseLex(const TDesC& aResponse)
+	: iRemainder(aResponse)
+	{
+	}
+
+TInt TResponseLex::GetIntColon(TInt& aValue)
+	{
+	TInt pos = iRemainder.Find(KColon);
+	if (pos == KErrNotFound)
+		{
+		return pos;
+		}
+	TPtrC intStr(iRemainder.Left(pos));
+	TLex lex(intStr);
+	TInt err = lex.Val(aValue);
+	if (err!=KErrNone) return err;
+	if (lex.Remainder().Length()) return KErrArgument;
+	iRemainder.Set(iRemainder.Mid(pos+1));
+	return KErrNone;
+	}
+
+TInt TResponseLex::GetStringColon(TPtrC& aValue)
+	{
+	TInt pos = iRemainder.Find(KColon);
+	if (pos == KErrNotFound)
+		{
+		return pos;
+		}
+	aValue.Set(iRemainder.Left(pos));
+	iRemainder.Set(iRemainder.Mid(pos+1));
+	return KErrNone;
+	}
+	
+TInt TResponseLex::GetIntEof(TInt& aValue)
+	{
+	TLex lex(iRemainder);
+	TInt err = lex.Val(aValue);
+	if (err==KErrNone)
+		{
+		if (lex.Remainder().Length()) err = KErrArgument;
+		}
+	if (err==KErrNone)
+		{
+		iRemainder.Set(lex.Remainder());
+		}
+	return err;
+	}
+
+TPtrC TResponseLex::Remainder()
+	{
+	return iRemainder;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sql/sql.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// sql.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+
+TARGET			fshell_sql.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_SQL
+
+capability		WriteDeviceData ReadDeviceData ReadUserData
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	FSHELL_NETWORKING_SYSTEMINCLUDE
+
+sourcepath		.
+source			sql.cpp
+
+library			euser.lib
+library			iocli.lib
+library			ws32.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sql/sqlcmd_open.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,562 @@
+// sqlcmd_open.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "sqlcmd_open.h"
+#include "sqlsrv.h"
+
+/////////////////////////////////////////////////////////////////////////////////////////
+_LIT(KCommandName, "open");
+
+CServerCommandBase* CSqlCmdOpen::NewLC()
+	{
+	CSqlCmdOpen* self = new(ELeave) CSqlCmdOpen();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdOpen::~CSqlCmdOpen()
+	{
+	delete iFileName;	
+	}
+
+const TDesC& CSqlCmdOpen::NameS()
+	{
+	return KCommandName;
+	}
+
+void CSqlCmdOpen::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdOpen::Name() const
+	{
+	return KCommandName;
+	}
+
+const TDesC& CSqlCmdOpen::Description() const
+	{
+	_LIT(KDescription, "open an existing SQL database file");
+	return KDescription;
+	}
+
+//virtual 
+void CSqlCmdOpen::ArgumentsL(RCommandArgumentList& aArguments)
+{
+	_LIT(KName, "filename");
+	_LIT(KDescription, "filename of the SQL database file. Should contain path.");
+	aArguments.AppendStringL(iFileName, KName, KDescription, KValueTypeFlagOptional);
+}
+
+void CSqlCmdOpen::DoRunL()
+	{
+	if (iFileName==NULL || iFileName->Length()==0 )
+		{
+		LeaveIfErr(KErrArgument, _L("Database filename unspecified."));
+		}
+	
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->SqlOpenL(*iFileName, this);
+	}
+
+/////////////////////////////////////////////////////////////////////////////////////
+_LIT(KCommandExit, "exit");
+
+CServerCommandBase* CSqlCmdExit::NewLC()
+	{
+	CSqlCmdExit* self = new(ELeave) CSqlCmdExit();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdExit::~CSqlCmdExit()
+	{
+	}
+
+const TDesC& CSqlCmdExit::NameS()
+	{
+	return KCommandExit;
+	}
+
+void CSqlCmdExit::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdExit::Name() const
+	{
+	return KCommandExit;
+	}
+
+const TDesC& CSqlCmdExit::Description() const
+	{
+	_LIT(KDescription, "Shut down amsrv.");
+	return KDescription;
+	}
+
+void CSqlCmdExit::DoRunL()
+	{
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->Exit(KErrNone);
+
+	}
+
+/////////////////////////////////////////////////////////////////////////////////////
+_LIT(KCommandClose, "close");
+
+CServerCommandBase* CSqlCmdClose::NewLC()
+	{
+	CSqlCmdClose* self = new(ELeave) CSqlCmdClose();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdClose::~CSqlCmdClose()
+	{
+	}
+
+const TDesC& CSqlCmdClose::NameS()
+	{
+	return KCommandClose;
+	}
+
+void CSqlCmdClose::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdClose::Name() const
+	{
+	return KCommandClose;
+	}
+
+const TDesC& CSqlCmdClose::Description() const
+	{
+	_LIT(KDescription, "close a SQL database file");
+	return KDescription;
+	}
+
+void CSqlCmdClose::DoRunL()
+	{
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->SqlClose(this);
+
+	}
+
+/////////////////////////////////////////////////////////////////////////////////////
+_LIT(KCommandCreate, "create");
+
+CServerCommandBase* CSqlCmdCreate::NewLC()
+	{
+	CSqlCmdCreate* self = new(ELeave) CSqlCmdCreate();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdCreate::~CSqlCmdCreate()
+	{
+	delete iFileName;
+	}
+
+const TDesC& CSqlCmdCreate::NameS()
+	{
+	return KCommandCreate;
+	}
+
+void CSqlCmdCreate::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdCreate::Name() const
+	{
+	return KCommandCreate;
+	}
+
+const TDesC& CSqlCmdCreate::Description() const
+	{
+	_LIT(KDescription, "Create a SQL database");
+	return KDescription;
+	}
+
+//virtual 
+void CSqlCmdCreate::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KName, "filename");
+	_LIT(KDescription, "filename of the SQL database file. Should contain path.");
+	aArguments.AppendStringL(iFileName, KName, KDescription, KValueTypeFlagOptional);
+	}
+
+void CSqlCmdCreate::DoRunL()
+	{
+	if (iFileName==NULL || iFileName->Length()==0 )
+		{
+		LeaveIfErr(KErrArgument, _L("Database filename unspecified."));
+		}
+	
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->SqlCreateL(*iFileName, this);
+	}
+
+///////////////////////////////////////////////////////////////////////////////
+
+_LIT(KCommandExec, "exec");
+
+CServerCommandBase* CSqlCmdExec::NewLC()
+	{
+	CSqlCmdExec* self = new(ELeave) CSqlCmdExec();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdExec::~CSqlCmdExec()
+	{
+	delete iExec;
+	}
+
+const TDesC& CSqlCmdExec::NameS()
+	{
+	return KCommandExec;
+	}
+
+void CSqlCmdExec::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdExec::Name() const
+	{
+	return KCommandExec;
+	}
+
+const TDesC& CSqlCmdExec::Description() const
+	{
+	_LIT(KDescription, "Execute a SQL statement without parameter and response.");
+	return KDescription;
+	}
+
+void CSqlCmdExec::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KName, "statement");
+	_LIT(KDescription, "The SQL statement to execute");
+	aArguments.AppendStringL(iExec, KName, KDescription, KValueTypeFlagOptional|KValueTypeFlagLast);
+	}
+
+void CSqlCmdExec::DoRunL()
+	{
+	if (iExec==NULL || iExec->Length()==0 )
+		{
+		LeaveIfErr(KErrArgument, _L("SQL statement unspecified."));
+		}
+	CCmdSqlSrv::StripWrapDoubleQuote(*iExec);
+	
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->SqlExecL(*iExec, this);
+	}
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+_LIT(KCommandState, "state");
+
+CServerCommandBase* CSqlCmdState::NewLC()
+	{
+	CSqlCmdState* self = new(ELeave) CSqlCmdState();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdState::~CSqlCmdState()
+	{
+	delete iExec;
+	
+	delete iOptFileName;
+	
+	//delete optional multiple parameter file
+		{
+		TInt optParamCnt = iOptParamFile.Count();
+		if (optParamCnt)
+			{
+			for (TInt i=0; i<optParamCnt; i++)
+				{
+				HBufC* pEle = iOptParamFile[i];
+				delete pEle;			
+				}		
+			}
+		iOptParamFile.Close();
+		}
+		
+/*	
+	//release resource for command-specific arguments 
+	TInt cmdArguCnt = iCmdArgu.Count();
+	if (cmdArguCnt)
+		{
+		for (TInt i=0; i<cmdArguCnt; i++)
+			{
+			HBufC* pEle = iCmdArgu[i];
+			delete pEle;			
+			}		
+		}
+	iCmdArgu.Close();
+*/			
+	}
+
+const TDesC& CSqlCmdState::NameS()
+	{
+	return KCommandState;
+	}
+
+void CSqlCmdState::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdState::Name() const
+	{
+	return KCommandState;
+	}
+
+const TDesC& CSqlCmdState::Description() const
+	{
+	_LIT(KDescription, "Execute a SQL statement that may come with parameter and response.");
+	return KDescription;
+	}
+
+void CSqlCmdState::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KName, "statement");
+	_LIT(KDescription, "The SQL statement to execute");
+	aArguments.AppendStringL(iExec, KName, KDescription, KValueTypeFlagOptional|KValueTypeFlagLast);	
+	}
+
+void CSqlCmdState::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptFile, "temp");
+	_LIT(KOptFileDescription, "Specify TEMP file template(used to dump large binary content to file)");
+	aOptions.AppendStringL(iOptFileName, TChar('t'), KOptFile, KOptFileDescription);
+	
+	_LIT(KOptParam, "param");
+	_LIT(KOptParamDescription, "Specify file names, of which the content will be used to fill parameters in SQL statement");
+	aOptions.AppendStringL(iOptParamFile, TChar('p'), KOptParam, KOptParamDescription);
+	}
+
+
+void CSqlCmdState::DoRunL()
+	{
+	//this command requires at least one argument
+	//first argument is a SQL statement, 
+	//and remaining arguments are optional parameters
+	
+	TInt paramCnt = iOptParamFile.Count();
+	if (iExec==0 || iExec->Length()==0 )
+		{
+		LeaveIfErr(KErrArgument, _L("SQL statement unspecified."));
+		}
+	
+	CCmdSqlSrv::StripWrapDoubleQuote(*iExec);
+	
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->SqlStateL(*iExec, iOptParamFile, this, iOptFileName);
+	}
+
+///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////
+_LIT(KCommandAttach, "attach");
+
+CServerCommandBase* CSqlCmdAttach::NewLC()
+	{
+	CSqlCmdAttach* self = new(ELeave) CSqlCmdAttach();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdAttach::~CSqlCmdAttach()
+	{
+	delete iOptFileName;
+	delete iOptDBName;
+	}
+
+const TDesC& CSqlCmdAttach::NameS()
+	{
+	return KCommandAttach;
+	}
+
+void CSqlCmdAttach::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdAttach::Name() const
+	{
+	return KCommandAttach;
+	}
+
+const TDesC& CSqlCmdAttach::Description() const
+	{
+	_LIT(KDescription, "Attach additional database onto main database file");
+	return KDescription;
+	}
+
+//virtual 
+void CSqlCmdAttach::ArgumentsL(RCommandArgumentList& /*aArguments*/)
+	{
+	}
+
+void CSqlCmdAttach::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptFile, "file");
+	_LIT(KOptFileDescription, "Specify additional database file.");
+	aOptions.AppendStringL(iOptFileName, TChar('f'), KOptFile, KOptFileDescription);
+
+	_LIT(KOptDB, "name");
+	_LIT(KOptDBDescription, "Specify additional database name.");
+	aOptions.AppendStringL(iOptDBName, TChar('n'), KOptDB, KOptDBDescription);
+	}
+
+void CSqlCmdAttach::DoRunL()
+	{
+	if (iOptFileName==NULL || iOptFileName->Length()==0 )
+		{
+		LeaveIfErr(KErrArgument, _L("Database filename unspecified."));
+		}
+	if (iOptDBName==NULL || iOptDBName->Length()==0 )
+		{
+		LeaveIfErr(KErrArgument, _L("Database name unspecified."));
+		}
+	
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->SqlAttachL(*iOptFileName, *iOptDBName, this);
+	}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+_LIT(KCommandDetach, "detach");
+
+CServerCommandBase* CSqlCmdDetach::NewLC()
+	{
+	CSqlCmdDetach* self = new(ELeave) CSqlCmdDetach();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdDetach::~CSqlCmdDetach()
+	{
+	delete iOptDBName;
+	}
+
+const TDesC& CSqlCmdDetach::NameS()
+	{
+	return KCommandDetach;
+	}
+
+void CSqlCmdDetach::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdDetach::Name() const
+	{
+	return KCommandDetach;
+	}
+
+const TDesC& CSqlCmdDetach::Description() const
+	{
+	_LIT(KDescription, "Detach additional database which is previously attached onto main database file.");
+	return KDescription;
+	}
+
+void CSqlCmdDetach::ArgumentsL(RCommandArgumentList& /*aArguments*/)
+	{
+	}
+
+void CSqlCmdDetach::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptDB, "name");
+	_LIT(KOptDBDescription, "Specify additional database name.");
+	aOptions.AppendStringL(iOptDBName, TChar('n'), KOptDB, KOptDBDescription);
+	}
+
+void CSqlCmdDetach::DoRunL()
+	{
+	if (iOptDBName==NULL || iOptDBName->Length()==0 )
+		{
+		LeaveIfErr(KErrArgument, _L("Database name unspecified."));
+		}
+	
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->SqlDetachL(*iOptDBName, this);
+	}
+
+///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////
+#ifdef SQL_COMPACT
+
+_LIT(KCommandCompact, "compact");
+
+CServerCommandBase* CSqlCmdCompact::NewLC()
+	{
+	CSqlCmdCompact* self = new(ELeave) CSqlCmdCompact();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSqlCmdCompact::~CSqlCmdCompact()
+	{
+	delete iOptDBName;
+	}
+
+const TDesC& CSqlCmdCompact::NameS()
+	{
+	return KCommandCompact;
+	}
+
+void CSqlCmdCompact::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CSqlCmdCompact::Name() const
+	{
+	return KCommandCompact;
+	}
+
+const TDesC& CSqlCmdCompact::Description() const
+	{
+	_LIT(KDescription, "Compacts the database.(RSqlDatabase::Compact)");
+	return KDescription;
+	}
+
+//virtual 
+void CSqlCmdCompact::ArgumentsL(RCommandArgumentList& aArguments)
+{
+}
+
+void CSqlCmdCompact::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptDB, "name");
+	_LIT(KOptDBDescription, "Specify database name, if unspecified, then main database will be compacted");
+	aOptions.AppendStringL(iOptDBName, TChar('n'), KOptDB, KOptDBDescription);
+	}
+
+void CSqlCmdCompact::DoRunL()
+	{
+	CCmdSqlSrv* pSrv = CCmdSqlSrv::GetServer(); 
+	pSrv->SqlCompactL(iOptDBName, this);
+	}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sql/sqlcmd_open.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,208 @@
+// sqlcmd_open.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __FSQLCMD_OPEN_H__
+#define __FSQLCMD_OPEN_H__
+
+#include <fshell/ioutils.h>
+
+
+using namespace IoUtils;
+
+////////////////////////////////////////////////////////////////////////////
+class CSqlCmdOpen : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdOpen();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);	
+	virtual void DoRunL();
+private:
+	HBufC* iFileName;
+	};
+
+/////////////////////////////////////////////////////////////////
+
+class CSqlCmdExit : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdExit();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	};
+
+///////////////////////////////////////////////////////////////////
+
+class CSqlCmdClose : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdClose();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	};
+
+/////////////////////////////////////////////////////////////////
+
+class CSqlCmdCreate : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdCreate();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void DoRunL();
+	
+private:
+	HBufC* iFileName;	
+	};
+
+
+//////////////////////////////////////////////////////////////////
+class CSqlCmdExec : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdExec();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void DoRunL();
+	
+private:
+	HBufC* iExec;	
+	};
+
+//////////////////////////////////////////////////////////////////
+
+class CSqlCmdState : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdState();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void DoRunL();
+	
+private:
+	HBufC* iOptFileName;	//TEMP file template, used to dump large binary contents
+	RPointerArray<HBufC> iOptParamFile;	//multiple filenames for use with parameter
+	
+	HBufC* iExec;	//the SQL statement
+	//RPointerArray<HBufC> iCmdArgu;	//arguments could be multiple strings	
+		
+	};
+
+/////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////
+
+class CSqlCmdAttach : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdAttach();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	void OptionsL(RCommandOptionList& aOptions);
+	virtual void DoRunL();
+	
+private:
+	HBufC* iOptFileName;
+	HBufC* iOptDBName;	//database name
+	};
+
+///////////////////////////////////////////////////////////////////
+
+class CSqlCmdDetach : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdDetach();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	void OptionsL(RCommandOptionList& aOptions);
+	virtual void DoRunL();
+	
+private:
+	HBufC* iOptDBName;	//database name
+	};
+
+/////////////////////////////////////////////////////////////////////
+
+#ifdef SQL_COMPACT
+
+//RSqlDatabase::Compact() is documented in Symbian Developer Library, 
+//but not exists in header file.
+//so just reserved this for future
+class CSqlCmdCompact : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CSqlCmdCompact();
+	static const TDesC& NameS();
+private:
+	void ConstructL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	void OptionsL(RCommandOptionList& aOptions);
+	virtual void DoRunL();
+	
+private:
+	HBufC* iOptDBName;	//database name
+	};
+#endif
+
+#endif // __FSQLCMD_OPEN_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sql/sqlsrv.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,634 @@
+// sqlsrv.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "sqlsrv.h"
+
+#include "sqlcmd_open.h"
+
+_LIT(KNewLine, "\r\n");
+_LIT(KPrompt, "ok\r\n");
+
+_LIT(KHistoryFile, "c:\\system\\console\\fshell_sqlsrv\\history");
+
+const TInt KFileBufferSize = 32768;
+
+CCmdSqlSrv*	CCmdSqlSrv::iOnlyInstance = NULL;
+
+CCommandBase* CCmdSqlSrv::NewLC()
+	{
+	if (CCmdSqlSrv::iOnlyInstance)
+		{
+		User::LeaveIfError(KErrAlreadyExists);
+		}
+	
+	CCmdSqlSrv* self = new (ELeave)CCmdSqlSrv();
+	CCmdSqlSrv::iOnlyInstance = self;
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+//static:
+//Check if a string is wrapped by double quote, and removed them
+//
+void CCmdSqlSrv::StripWrapDoubleQuote(HBufC& aText)
+	{
+	RBuf text;
+	text.Create(aText);
+	text.Trim();
+	if (text.Left(1)==_L("\"") && text.Right(1)== _L("\""))
+		{
+		//delete right side quote
+		text.Delete(text.Length()-1, 1);
+		//delete left side quote
+		text.Delete(0,1);
+		aText = text;
+		}
+	text.Close();
+	}
+
+
+
+//static 
+CCmdSqlSrv* CCmdSqlSrv::GetServer()
+	{
+	return CCmdSqlSrv::iOnlyInstance;	
+	}
+
+CCmdSqlSrv::CCmdSqlSrv()
+	: CServerBase(0, KPrompt, KHistoryFile), iNextCommandId(1)
+	{
+	iTmpFileNo = 1;
+	iDatabaseOpened = EFalse;
+	}
+
+void CCmdSqlSrv::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+CCmdSqlSrv::~CCmdSqlSrv()
+	{
+	iSqlDb.Close();	
+	CCmdSqlSrv::iOnlyInstance = NULL;
+	}
+
+//////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////
+
+const TDesC& CCmdSqlSrv::Name() const
+	{
+	_LIT(KName, "sqlsrv");
+	return KName;
+	}
+
+const TDesC& CCmdSqlSrv::Description() const
+	{
+	_LIT(KDescription, "a command to interact with Symbian SQLite server");
+	return KDescription;
+	}
+
+void CCmdSqlSrv::ArgumentsL(RCommandArgumentList& /*aArguments*/)
+	{
+	}
+
+void CCmdSqlSrv::OptionsL(RCommandOptionList& /*aOptions*/)
+	{
+	}
+
+TInt CCmdSqlSrv::NextCommandId()
+	{
+	return iNextCommandId++;
+	}
+
+//when retrieving SQL records, if there is any binary columns and user has specified
+//a Temp file template, then we will generate a temp file and dump the binary into such file.
+void CCmdSqlSrv::MakeTempFilename(TDes& aTmpFile, TDesC& aTemplate)
+	{
+	TFileName2 tmpTemplate(aTemplate);
+	TPtrC drvPath = tmpTemplate.DriveAndPath();
+	TPtrC name = tmpTemplate.Name();
+	TPtrC ext = tmpTemplate.Ext();
+	
+	aTmpFile.Format(_L("%S%S.%02d%S"), &drvPath, &name, iTmpFileNo, &ext);
+	iTmpFileNo++;
+	}
+
+
+void CCmdSqlSrv::ReportResult(const TServerCommandId& aId, const TDesC& aName, TRefByValue<const TDesC> aFmt, ...)
+	{
+	CheckNewConsoleLine();
+	DoPrintf(_L("result:%u:%S:"), aId.Value(), &aName);
+	VA_LIST list;
+	VA_START(list, aFmt);
+	DoPrintList(aFmt, list, ENewLine);
+	VA_END(list);
+	}
+
+
+void CCmdSqlSrv::InitializeL()
+	{
+	CServerCommandFactory& factory = Factory();
+	
+	factory.AddLeafCommandL<CSqlCmdExit>();
+	factory.AddLeafCommandL<CSqlCmdOpen>();
+	factory.AddLeafCommandL<CSqlCmdCreate>();
+	factory.AddLeafCommandL<CSqlCmdExec>();
+	factory.AddLeafCommandL<CSqlCmdClose>();	
+	factory.AddLeafCommandL<CSqlCmdState>();
+	factory.AddLeafCommandL<CSqlCmdAttach>();
+	factory.AddLeafCommandL<CSqlCmdDetach>();
+	
+#ifdef SQL_COMPACT	
+	factory.AddLeafCommandL<CSqlCmdCompact>();
+#endif
+		
+	}
+
+void CCmdSqlSrv::DoPrintf(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	DoPrintList(aFmt, list);
+	VA_END(list);
+	}
+
+void CCmdSqlSrv::DoPrintf(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	DoPrintList(aFmt, list);
+	VA_END(list);
+	}
+
+void CCmdSqlSrv::DoPrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList, TPrintPostfix aPostfix)
+	{
+	TOverflowTruncate overflow;
+	TBuf<0x100> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	DoPrint(buf, aPostfix);
+	}
+
+void CCmdSqlSrv::DoPrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList, TPrintPostfix aPostfix)
+	{
+	TOverflowTruncate8 overflow;
+	TBuf8<0x200> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	if (buf.Length() > 0x100) buf.SetLength(0x100); // Truncate to half the buffer size so that the call to Expand doesn't panic
+	TPtrC wideBuf = buf.Expand();
+	DoPrint(wideBuf, aPostfix);
+	}
+
+void CCmdSqlSrv::DoPrint(const TDesC& aDes, TPrintPostfix aPostfix)
+	{
+	Stdout().Write(aDes);
+	if ((aPostfix == ENewLine) && ((aDes.Length() < KNewLine().Length()) || (aDes.Right(KNewLine().Length()) != KNewLine)))
+		{
+		Stdout().Write(KNewLine);
+		}
+	}
+
+
+void CCmdSqlSrv::Report(const TServerCommandId& /*aId*/, const TDesC& /*aDes*/)
+	{
+	//TODO?
+//	Log(aId, aDes);
+	}
+
+void CCmdSqlSrv::Report(const TServerCommandId& /*aId*/, const TDesC8& /*aDes*/)
+	{
+	//TODO?
+//	Log(aId, aDes);
+	}
+
+void CCmdSqlSrv::ReportWarning(const TServerCommandId& aId, const TDesC& aDes)
+	{
+	CheckNewConsoleLine();
+	DoPrintf(_L("warning:%u:%S\r\n"), aId.Value(), &aDes);
+	}
+
+void CCmdSqlSrv::ReportError(const TServerCommandId& aId, TInt aError, const TDesC& aDes)
+	{
+	CheckNewConsoleLine();
+	DoPrintf(_L("error:%d:%u:%S\r\n"), aError, aId.Value(), &aDes);
+	}
+
+////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+
+//aCommand: the command which is invoking this function, SHOULD NOT BE NULL
+//
+void CCmdSqlSrv::SqlCreateL(TDesC& aFilename, CServerCommandBase* aCommand)
+	{
+	if (iDatabaseOpened)
+		LeaveIfErr(KErrGeneral, _L("A database is already opened"));
+	
+	iSqlDb.CreateL(aFilename);
+	
+	//Print size information if no error occurrs
+	TInt size = iSqlDb.Size();
+	ReportResult(aCommand->Id(), aCommand->Name(), _L("Database created, size: %d bytes.\r\n"), size);
+	iDatabaseOpened = ETrue;
+	}
+
+void CCmdSqlSrv::SqlOpenL(TDesC& aFilename, CServerCommandBase* aCommand)
+	{
+	if (iDatabaseOpened)
+		LeaveIfErr(KErrGeneral, _L("A database is already opened"));
+		
+	iSqlDb.OpenL(aFilename);
+	
+	//Print size information if no error occurrs
+	TInt size = iSqlDb.Size();
+	ReportResult(aCommand->Id(), aCommand->Name(), _L("Database opened, size: %d bytes.\r\n"), size);
+	iDatabaseOpened = ETrue;
+
+	//more detailed size information seems only available from Symbian OS 9.5 or later.
+/*	
+	RSqlDatabase::TSize size;
+	iSqlDb.Size(size);
+	ReportResult(aCommand->Id(), aCommand->Name(), _L("Database opened, size: %Ld bytes. free:%Ld bytes\r\n"), 
+			size.iSize, size.iFree);
+*/			
+	}
+
+//execute a SQL statement without parameter/response
+void CCmdSqlSrv::SqlExecL(TDesC& aStatement, CServerCommandBase* aCommand)
+	{
+	TInt err;
+	if (!iDatabaseOpened)
+		LeaveIfErr(KErrGeneral, _L("No database opened"));
+		
+	err = iSqlDb.Exec(aStatement);
+	
+	if (err < 0)
+		{
+		TPtrC errMsg = iSqlDb.LastErrorMessage();
+		ReportResult(aCommand->Id(), aCommand->Name(), _L("Exec return code:%d message:%S\r\n"),
+				err, &errMsg);				
+		}
+	
+	User::LeaveIfError(err);
+	
+	//print the return code if it's not error
+	ReportResult(aCommand->Id(), aCommand->Name(), _L("Exec return code:%d\r\n"),err);		
+	}
+
+//execute a SQL statement with parameter/response
+//aStatement: SQL statement
+//aOptParamFile: contains multiple string (HBufC*):should be parameters for that statement
+//aTempFileTemplate: template to generate temp file, used to dump binary contents
+void CCmdSqlSrv::SqlStateL(TDesC& aStatement, RPointerArray<HBufC> &aOptParamFile, CServerCommandBase* aCommand, TDesC* aTempFileTemplate)
+	{
+	TInt err;
+	if (!iDatabaseOpened)
+		LeaveIfErr(KErrGeneral, _L("No database opened"));
+	
+	RSqlStatement sqlState;
+	CleanupClosePushL(sqlState);
+	
+	err = sqlState.Prepare(iSqlDb, aStatement);
+	if (err < 0)
+		{
+		TPtrC errMsg = iSqlDb.LastErrorMessage();
+		ReportResult(aCommand->Id(), aCommand->Name(), _L("RSqlStatement::Prepare() return code:%d message:%S\r\n"),
+				err, &errMsg);				
+		}
+	User::LeaveIfError(err);
+
+	//depend on the statement type, for something like SELECT, which is expected to have returned results,
+	//we should call Next(),
+	//otherwise we should call Exec();
+	//Panic will occur if calling wrong function
+	//so check if this statement is SELECT
+	TBool bIsSelect;
+	TBuf<64> strBegin;
+	strBegin.Copy(aStatement.Left(64));
+	strBegin.TrimLeft();
+	strBegin.UpperCase();
+	
+	if (strBegin.Left(6)==_L("SELECT"))
+		bIsSelect = ETrue;
+	else
+		bIsSelect = EFalse;
+	
+	if (bIsSelect) 
+		{
+		//once successfully execute the statement, check if there is any response.
+		//only quit the loop when there is no more results found
+		TInt totalRecordsReturned = 0;	
+		while(ETrue)
+			{	
+			err =  sqlState.Next();
+			if (err==KSqlAtRow)	//ready to retrieve a result (usual response for SELECT command)
+				{
+				totalRecordsReturned++;
+				ReportResult(aCommand->Id(), aCommand->Name(), _L("Record #%d =========================\r\n"), totalRecordsReturned);
+				
+				ParseResultL(sqlState, aCommand, aTempFileTemplate);
+					
+				}
+			else if (err==KSqlAtEnd) //no records found
+				{
+				ReportResult(aCommand->Id(), aCommand->Name(), _L("===================================\r\n"));
+				ReportResult(aCommand->Id(), aCommand->Name(), _L("%d record(s) returned\r\n"), totalRecordsReturned);
+				break;
+				}
+			else 
+				{
+				User::LeaveIfError(err);			
+				}
+			}
+		}
+	else
+		{		
+		RSqlParamWriteStream strm;	//only will have effect when parameters are used
+	    CleanupClosePushL(strm);
+		//check if there is any parameters that need to be bound with the statement
+	    TInt paramCnt = aOptParamFile.Count();
+		if (paramCnt)
+			{
+			for (TInt paramId = 0; paramId<paramCnt; paramId++)
+				{
+				HBufC* paramFile = aOptParamFile[paramId];
+				RFile file;
+				CleanupClosePushL(file);
+				err = file.Open(FsL(), *paramFile, EFileRead);
+				LeaveIfErr(err, _L("Error openning file %S"), paramFile);
+				
+				err = strm.BindBinary(sqlState, paramId);
+				User::LeaveIfError(err);
+				
+				//dump the file content the the parameter
+				//file could be very large, so it is wise to separate it into several times. each time 32K or so.
+				{
+				TInt fileSize; 
+				file.Size(fileSize);
+				RBuf8 buf;
+				buf.CreateL(KFileBufferSize);	//each time 32KB
+
+				for (TInt curPos = 0; curPos<fileSize ;)
+					{
+					TInt remaingBytes = (fileSize-curPos);
+					TInt bytesToProc = (remaingBytes>KFileBufferSize)? KFileBufferSize : remaingBytes;
+					err = file.Read(curPos, buf, bytesToProc);
+					User::LeaveIfError(err);
+					
+					strm.WriteL(buf);
+					curPos += bytesToProc;
+					}
+				
+				buf.Close();
+				strm.CommitL();
+				strm.Close();
+				}
+				
+				CleanupStack::PopAndDestroy();	//file
+				}
+		
+			}				
+		err = sqlState.Exec();
+		ReportResult(aCommand->Id(), aCommand->Name(), _L("Exec return code:%d\r\n"),err);
+		
+		CleanupStack::PopAndDestroy();	//strm
+		}
+	
+	CleanupStack::PopAndDestroy();
+	}
+
+
+//close SQL database file
+void CCmdSqlSrv::SqlClose(CServerCommandBase* aCommand)
+	{
+	if (!iDatabaseOpened)
+		LeaveIfErr(KErrGeneral, _L("No database opened"));
+	
+	iSqlDb.Close();
+	//print the return code if it's not error
+	ReportResult(aCommand->Id(), aCommand->Name(), _L("SQL database file closed\r\n"));
+	iDatabaseOpened = EFalse;
+	}
+
+//attach additional database onto main database
+void CCmdSqlSrv::SqlAttachL(TDesC& aFilename, TDesC& aDateBaseName, CServerCommandBase* aCommand)
+	{
+	TInt err;
+	if (!iDatabaseOpened)
+		LeaveIfErr(KErrGeneral, _L("No database opened"));
+	
+	err = iSqlDb.Attach(aFilename, aDateBaseName);
+	ReportResult(aCommand->Id(), aCommand->Name(), _L("RSqlDatabase::Attach return code:%d\r\n"), err);		
+	User::LeaveIfError(err);	
+	}
+
+//
+void CCmdSqlSrv::SqlDetachL(TDesC& aDateBaseName, CServerCommandBase* aCommand)
+	{
+	TInt err;
+	if (!iDatabaseOpened)
+		LeaveIfErr(KErrGeneral, _L("No database opened"));
+	
+	err = iSqlDb.Detach(aDateBaseName);
+	ReportResult(aCommand->Id(), aCommand->Name(), _L("RSqlDatabase::Detach return code:%d\r\n"), err);		
+	User::LeaveIfError(err);	
+	}
+
+#ifdef SQL_COMPACT
+//RSqlDatabase::Compact() is documented but not implemented, so Do not use for now
+//aDateBaseName: can be NULL (compacting main database)
+void CCmdSqlSrv::SqlCompactL(TDesC* aDateBaseName, CServerCommandBase* aCommand)
+	{
+	TInt err;
+	err = iSqlDb.Compact(0, aDateBaseName);
+	ReportResult(aCommand->Id(), aCommand->Name(), _L("RSqlDatabase::Compact return code:%d\r\n"), err);		
+	User::LeaveIfError(err);	
+	}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////
+
+
+//once we got a result from a SELECT command, then we go through the returned result
+//only call this function after calling Next().
+//we only analyse ONE returned record in this function
+void CCmdSqlSrv::ParseResultL(RSqlStatement& aState, CServerCommandBase* aCommand, TDesC* aTempFileTemplate)
+	{
+	TInt err;
+	TInt colCnt = aState.ColumnCount();
+	TBuf<64> colHdr;	//column information fixed header
+	
+	for (TInt i=0; i<colCnt; i++)
+		{
+		TPtrC columnName;
+		err = aState.ColumnName(i, columnName);
+		if (err != KErrNone)
+			{
+			_LIT(KNotAvailable, "N/A");
+			columnName.Set(KNotAvailable);
+			}
+				
+		TSqlColumnType colType = aState.ColumnType(i);
+		const TDesC* pTypeStr = ColumnTypeToString(colType);
+		TInt colSize = aState.ColumnSize(i);
+		
+		colHdr.Format(_L("Column %d \"%S\"(%S)"), i, &columnName, pTypeStr);
+		
+		switch(colType)
+			{
+			case ESqlNull:
+				{
+				ReportResult(aCommand->Id(), aCommand->Name(), _L("%S \r\n"), &colHdr);	
+				break;
+				}
+			case ESqlInt:
+				{
+				TInt colValue = aState.ColumnInt(i);
+				ReportResult(aCommand->Id(), aCommand->Name(), _L("%S %d\r\n"), &colHdr, colValue);	
+				break;
+				}
+			case ESqlInt64:
+				{
+				TInt64 colValue = aState.ColumnInt64(i);
+				ReportResult(aCommand->Id(), aCommand->Name(),_L("%S %Ld\r\n"), &colHdr , colValue);
+				break;
+				}			
+			case ESqlReal:
+				{
+				TInt64 colValue = aState.ColumnReal(i);
+				ReportResult(aCommand->Id(), aCommand->Name(),_L("%S %f\r\n"), &colHdr, colValue);				
+				break;
+				}						
+			case ESqlText:
+				{
+				TPtrC  colValue = aState.ColumnTextL(i);
+				ReportResult(aCommand->Id(), aCommand->Name(),_L("%S %S\r\n"), &colHdr, &colValue);				
+				break;
+				}						
+			case ESqlBinary:
+				{
+				TBool dumpToFile = EFalse;
+				TBuf<128> printableHex;
+				TFileName tmpFileName;
+				
+				RSqlColumnReadStream strm;
+				CleanupClosePushL(strm);
+				err = strm.ColumnBinary(aState, i);
+				
+				//generate a temp file name for dumping binary content
+				RFile tmpFile;
+				CleanupClosePushL(tmpFile);
+				if (aTempFileTemplate && aTempFileTemplate->Length()>0 )
+					{
+					MakeTempFilename(tmpFileName, *aTempFileTemplate);
+					//open the file
+					err = tmpFile.Replace(FsL(), tmpFileName, EFileWrite);
+					if (err==KErrNone)
+						dumpToFile = ETrue;
+					}
+				
+				//go through the binary content, and dump it if tmp file is available
+				RBuf8 readBuf;
+				CleanupClosePushL(readBuf);
+				readBuf.CreateL(KFileBufferSize);
+				for(TInt cursor=0; cursor < colSize; )
+					{
+					TInt bytesRemain = (colSize-cursor);
+					TInt bytesToProc = (bytesRemain>KFileBufferSize) ? KFileBufferSize : bytesRemain;
+					strm.ReadL(readBuf, bytesToProc);
+					
+					if (cursor==0)	//it is beginning the binary data, always print first few bytes on screen
+						{
+						TInt byteCnt = bytesToProc;
+						TInt byteToPrint = (byteCnt > 32)? 32 : byteCnt;
+						printableHex.AppendFormat(_L("DataLength:%d Hex: "), colSize);
+						
+						for (TInt a=0; a<byteToPrint; a++)
+							{
+							TInt byteVal = readBuf[a]; 
+							printableHex.AppendFormat(_L("%02x "), byteVal);
+							}
+						if (byteToPrint < byteCnt)
+							printableHex.AppendFormat(_L("..."));
+						}
+					
+					if (dumpToFile)
+						{
+						err = tmpFile.Write(cursor, readBuf, bytesToProc);
+						if (err != KErrNone) 
+							{
+							dumpToFile = EFalse;
+							break;
+							}
+						}
+					else
+						break;
+					
+					cursor += bytesToProc; 
+					}								
+				CleanupStack::PopAndDestroy(); //readBuf			
+				CleanupStack::PopAndDestroy(); //tmpFile
+				CleanupStack::PopAndDestroy();//strm;				
+				ReportResult(aCommand->Id(), aCommand->Name(),_L("%S %S\r\n"), &colHdr, &printableHex);
+				if (dumpToFile)
+					{
+					ReportResult(aCommand->Id(), aCommand->Name(),_L("Binary content dumped to file %S\r\n"), 
+							&tmpFileName);
+					}
+				}
+				break;
+			}
+		
+		}
+	}
+
+
+
+EXE_BOILER_PLATE(CCmdSqlSrv)
+
+#define CASE_LIT(x) case x: { _LIT(KName, #x); pString = &KName; break; }
+
+//static
+const TDesC* CCmdSqlSrv::ColumnTypeToString(TSqlColumnType aType)
+	{
+	const TDesC* pString = NULL;
+	switch(aType)
+		{
+		CASE_LIT(ESqlNull);
+		CASE_LIT(ESqlInt);
+		CASE_LIT(ESqlInt64);
+		CASE_LIT(ESqlReal);
+		CASE_LIT(ESqlText);
+		CASE_LIT(ESqlBinary);
+		default:
+			_LIT(KUnknowStr, "Unknown");
+			pString = &KUnknowStr;		
+		}
+	return pString;	
+	}
+
+void CCmdSqlSrv::PrintTime(const TTime& aTime, TBool aNewline)
+	{	
+	TTime NullTime = Time::NullTTime();
+	if (aTime == NullTime) 
+		{
+		Printf(_L("(NullTime)"));
+		}
+	else
+		{
+		_LIT8(KDateTimeFormat, "%d-%02d-%02d %02d:%02d:%02d");
+		TDateTime dt = aTime.DateTime();
+		Printf(KDateTimeFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
+		}
+	
+	if (aNewline) Printf(_L("\r\n"));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sql/sqlsrv.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,108 @@
+// sqlsrv.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __SQLSRV_H__
+#define __SQLSRV_H__
+//  Include Files
+
+#include <fshell/common.mmh>
+
+#include <fshell/ioutils.h>
+#include <SqlDb.h>
+
+//class CSqlShared;
+//class CLineEditor;
+
+using namespace IoUtils;
+
+class CCmdSqlSrv : public CServerBase
+	{
+public:
+	static const TDesC* ColumnTypeToString(TSqlColumnType aType);
+	static void StripWrapDoubleQuote(HBufC& aText);
+
+	void PrintTime(const TTime& aTime, TBool aNewline);	
+	static CCommandBase* NewLC();
+	static CCmdSqlSrv* GetServer();	
+	~CCmdSqlSrv();
+	
+	TInt NextCommandId();
+	
+	//SQL commands
+	void SqlCreateL(TDesC& aFilename, CServerCommandBase* aCommand);
+	void SqlOpenL(TDesC& aFilename, CServerCommandBase* aCommand);
+	void SqlExecL(TDesC& aStatement, CServerCommandBase* aCommand);
+	void SqlStateL(TDesC& aStatement, RPointerArray<HBufC> &aOptParamFile, CServerCommandBase* aCommand, 
+			TDesC* aTempFileTemplate = NULL);
+	void SqlClose(CServerCommandBase* aCommand);
+	void SqlAttachL(TDesC& aFilename, TDesC& aDateBaseName, CServerCommandBase* aCommand);
+	void SqlDetachL(TDesC& aDateBaseName, CServerCommandBase* aCommand);
+	
+#ifdef SQL_COMPACT	
+	void SqlCompactL(TDesC* aDateBaseName, CServerCommandBase* aCommand);
+#endif
+	///////////////////////////////////
+	void ReportResult(const TServerCommandId& aId, const TDesC& aName, TRefByValue<const TDesC> aFmt, ...);
+
+	//////////////////////////////////
+	void ParseResultL(RSqlStatement& aState, CServerCommandBase* aCommand, TDesC* aTempFileTemplate);
+
+private:
+	CCmdSqlSrv();
+	void ConstructL();
+	void MakeTempFilename(TDes& aTmpFile, TDesC& aTemplate);
+
+private:
+	enum TPrintPostfix
+		{
+		ENone,
+		ENewLine
+		};
+
+	void DoPrintf(TRefByValue<const TDesC> aFmt, ...);
+	void DoPrintf(TRefByValue<const TDesC8> aFmt, ...);
+	void DoPrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList, TPrintPostfix aPostfix = ENone);
+	void DoPrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList, TPrintPostfix aPostfix = ENone);
+	void DoPrint(const TDesC& aDes, TPrintPostfix aPostfix = ENone);
+	
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From CServerBase.
+	virtual void InitializeL();
+	virtual void Report(const TServerCommandId& aId, const TDesC& aDes);
+	virtual void Report(const TServerCommandId& aId, const TDesC8& aDes);
+	virtual void ReportWarning(const TServerCommandId& aId, const TDesC& aDes);
+	virtual void ReportError(const TServerCommandId& aId, TInt aError, const TDesC& aDes);
+	
+private:
+	RSqlDatabase	iSqlDb;
+	TBool			iDatabaseOpened;	//when database is created or opened, set this to ETrue
+	
+	TBool iExit;
+	TBuf<512> iLine;
+	TInt iExitReason;
+	
+	TBool iLineRead;
+	
+	TInt iNextCommandId;
+	TInt iTmpFileNo;	
+		
+private:
+	//use this static variable to make sure only one instance exists
+	static CCmdSqlSrv*	iOnlyInstance;
+	};
+
+
+#endif //__SQLSRV_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sql/sqlsrv.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// sqlsrv.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+
+TARGET			fshell_sqlsrv.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_SQLSRV
+
+capability		Location WriteDeviceData ReadDeviceData ReadUserData
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	FSHELL_NETWORKING_SYSTEMINCLUDE
+
+sourcepath		.
+source			sqlsrv.cpp
+
+SOURCE			sqlcmd_open.cpp
+
+library			euser.lib efsrv.lib estor.lib 
+library			iocli.lib
+
+LIBRARY			ws32.lib
+
+library			sqldb.lib 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/startup/startup.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,59 @@
+# startup.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name startup
+
+==short-description
+
+Manipulate the Dynamic Startup Configuration API.
+
+==long-description
+
+Uses the RDscStore API to examine the Dynamic Startup Configuration (DSC). For reference the underlying database is stored at c:\private\100012a5\DBS_2000836D_DBS_DSC.db.
+
+==argument enum command optional
+
+The operation to perform.
+
+==enum-value list
+
+List the current contents of the specified DSC.
+
+==enum-value add
+
+Add an item to the specified DSC. The C<filename> argument must be specified, arguments are optional.
+
+==enum-value delete
+
+Deletes an item from a DSC. The filename and arguments must be specified and must match what is in the DSC item.
+
+==argument string filename optional
+
+Not applicable for 'list' command. The name of the exe to launch. May be unqualified (eg 'fshell.exe') or a full path ('z:\sys\bin\fshell.exe').
+
+==argument string arguments optional
+
+Not applicable for 'list' command. The arguments to pass to the launched exe. The underlying SQL implementation does not appear to support putting quotes in the args.
+
+
+==option uint u dsc-uid
+
+The UID of the DSC to use. If not specified, all commands assume the default DSC C<KDefaultSymbianDsc>.
+
+==option bool c create
+
+Creates the DSC if it doesn't already exist.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/startup/startup.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,141 @@
+// startup.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#include <dscstore.h>
+#include <dscitem.h>
+
+using namespace IoUtils;
+
+class CCmdStartup : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdStartup();
+private:
+	CCmdStartup();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TOp
+		{
+		EList,
+		EAdd,
+		EDelete,
+		};
+	TOp iOperation;
+	TUid iDscUid;
+	RDscStore iDsc;
+
+	TUid iItemUid;
+	HBufC* iItemFileName;
+	HBufC* iItemArgs;
+	TBool iCreate;
+	};
+
+EXE_BOILER_PLATE(CCmdStartup)
+
+CCommandBase* CCmdStartup::NewLC()
+	{
+	CCmdStartup* self = new(ELeave) CCmdStartup();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdStartup::~CCmdStartup()
+	{
+	iDsc.Close();
+	delete iItemFileName;
+	delete iItemArgs;
+	}
+
+CCmdStartup::CCmdStartup()
+	: iDscUid(TUid::Uid(KDefaultSymbianDsc))
+	{
+	}
+
+const TDesC& CCmdStartup::Name() const
+	{
+	_LIT(KName, "startup");	
+	return KName;
+	}
+
+void CCmdStartup::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iOperation, _L("command"));
+	aArguments.AppendStringL(iItemFileName, _L("filename"));
+	aArguments.AppendStringL(iItemArgs, _L("arguments"));
+	}
+
+void CCmdStartup::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendUintL((TUint&)iDscUid.iUid, _L("dsc-uid"));
+	aOptions.AppendBoolL(iCreate, _L("create"));
+	}
+
+void EnumClose(TAny* aPtr)
+	{
+	static_cast<RDscStore*>(aPtr)->EnumClose();
+	}
+
+void CCmdStartup::DoRunL()
+	{
+	TRAPL(iDsc.OpenL(), _L("Couldn't open RDscStore"));
+
+	if (iCreate && !iDsc.DscExistsL(iDscUid))
+		{
+		TRAPL(iDsc.CreateDscL(iDscUid, _L("[DSC created by fshell_startup.exe]")), _L("Couldn't create DSC 0x%08x"), iDscUid.iUid);
+		}
+
+	if (iOperation == EList)
+		{
+		TRAPL(iDsc.EnumOpenLC(iDscUid); CleanupStack::Pop(), _L("Couldn't list DSC 0x%x"), iDscUid.iUid);
+		CleanupStack::PushL(TCleanupItem(&EnumClose, &iDsc)); // Can't use the EnumOpenLC's cleanupitem because we have to pop it, because we need it inside its own TRAP harness to get good error messages out
+		for (;;)
+			{
+			CDscItem* item = iDsc.EnumReadNextL();
+			if (!item) break;
+			TPtrC args = item->Args();
+			TPtrC fn = item->FileName();
+			Printf(_L("DscId=0x%08x ItemId=0x%08x FileName=%S Args=%S\r\n"), item->DscId(), item->ItemId(), &fn, &args);
+			delete item;
+			}
+		CleanupStack::PopAndDestroy(); // close enum
+		}
+	else if (iOperation == EAdd)
+		{
+		if (iItemFileName == NULL) LeaveIfErr(KErrArgument, _L("Must specify a file name for the 'add' operation"));
+		CDscItem* item = CDscItem::NewLC(*iItemFileName, iItemArgs ? *iItemArgs : KNullDesC());
+		item->SetStartMethodL(EFireAndForget);
+		item->SetStartupTypeL(EStartProcess);
+		item->SetDscId(iDscUid);
+		TRAPL(iDsc.AddItemL(*item), _L("Couldn't add DSC item (try using --create option?)"));
+		CleanupStack::PopAndDestroy(item);
+		}
+	else if (iOperation == EDelete)
+		{
+		if (iItemFileName == NULL) LeaveIfErr(KErrArgument, _L("Must specify a file name for the 'delete' operation"));
+		CDscItem* item = CDscItem::NewLC(*iItemFileName, iItemArgs ? *iItemArgs : KNullDesC());
+		item->SetDscId(iDscUid);
+		TRAPL(iDsc.DeleteItemL(*item), _L("Couldn't delete DSC item"));
+		CleanupStack::PopAndDestroy(item);
+		}
+	else
+		{
+		LeaveIfErr(KErrArgument, _L("Unrecognised operation %d"), iOperation);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/startup/startup.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// startup.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			fshell_startup.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_STARTUP
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			startup.cpp
+
+library			euser.lib
+library			iocli.lib
+library			dscstore.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sudo/sudo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,114 @@
+# sudo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name sudo
+
+==short-description
+
+Launch an executable with modified capabilities and / or other properties.
+
+==long-description
+
+The command operates in one of two modes, depending on whether C<--disk> is specified. With this option, a copy of the exe is made on the C drive, modified there then executed. Without it, the process is launched then before it is resumed the properties are modified in the kernel. The default (without C<--disk>) is neater but is limited in that it cannot change heap or stack sizes, and if the DLLs that are linked to have too many capabilities to allow the exe to launch as is, you won't get far enough to change them. Previously the C<--disk> option was the default. If no capability or sid etc options are specified then the exe will be launched with capabilities C<All -TCB> and no other changes.
+
+==argument string exe-name
+
+The executable to modify then launch.
+
+==argument string arguments optional last
+
+Arguments to pass to the exe.
+
+==option string a add-cap multiple
+
+Adds the specified capability.
+
+==option string r remove-cap multiple
+
+Removes the specified capability (if a cap is included in both add and remove lists, the remove takes precedence).
+
+==option uint s sid
+
+Sets the Secure ID to the specified value.
+
+==option uint v vid
+
+Sets the Vendor ID to the specified value.
+
+==option uint m heap-min
+
+Sets the process's default minimum heap size to the specified value (in bytes).
+
+==option uint x heap-max
+
+Sets the process's default maximum heap size to the specified value (in bytes).
+
+==option uint z stack-size
+
+Sets the process's default stack size to the specified value (in bytes).
+
+==option int p process-priority
+
+Sets the process priority to the specified value (as per C<TProcessPriority>).
+
+=over 5
+
+=item low
+
+150
+
+=item background
+
+250
+
+=item foreground
+
+350
+
+=item high
+
+450
+
+=item windowserver
+
+650
+
+=item fileserver
+
+750
+
+=item realtimeServer
+
+850
+
+=item supervisor
+
+950
+
+=back
+
+==option bool k keep
+
+Do not delete the modified exe when the process exits. If the exe is in the Core ROM, this option will keep the modified binary in memory until next reboot, such that any other code that launches the exe will pick up these settings (running sudo a second time on this exe without C<--keep> will undo it).
+
+==option bool d disk
+
+Change the on-disk binary rather than modifying the in-memory kernel process attributes. This option is required for changing heap and stack sizes. On WINSCW the C<--disk> option still operates on E32 binaries, therefore it is not possible to modify a WINSCW binary with C<--disk>.
+
+==option bool w wait
+
+Wait for a keypress before resuming the process. Use this option if you need to examine the process before it runs.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sudo/sudo.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,537 @@
+// sudo.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#define __INCLUDE_CAPABILITY_NAMES__
+#include <fshell/ioutils.h>
+#include <f32image.h>
+#include <fshell/memoryaccesscmd.h>
+#include <e32rom.h>
+
+using namespace IoUtils;
+
+class CCmdSudo : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSudo();
+private:
+	CCmdSudo();
+	static void DeleteModifiedBinary(TAny* aSelf);
+	void DeleteModifiedBinary();
+	TBool FileExists(const TDesC& aFileName);
+	void FixupExeInMemoryL(RProcess& aProcess);
+	void CalculateCaps();
+
+	void FindExeL();
+	void CopyExeLC();
+	void FixupExeL();
+	void RunExeL();
+	void FixupCoreExeLC();
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+
+private:
+	HBufC* iCmd;
+	HBufC* iArgs;
+	RPointerArray<HBufC> iAdd;
+	RPointerArray<HBufC> iRemove;
+	TCapabilitySet iCapsToAdd;
+	TCapabilitySet iCapsToRemove;
+	TUint iSid;
+	TUint iVid;
+	TUint iHeapMin;
+	TUint iHeapMax;
+	TUint iStackSize;
+	TInt iProcessPriority;
+
+	TBool iKeep;
+	TBool iWait;
+	TBool iChangeBinaryOnDisk;
+	TBool iFileIsInCore;
+
+	TFileName iPath;
+	TFileName iNewPath;
+	CArrayPtrFlat<HBufC>* iPathsToCleanup;
+	// following 2 are temporaries needed during CopyExeLC
+	TFileName iTempSrc;
+	TFileName iTempDest;
+	};
+
+
+CCommandBase* CCmdSudo::NewLC()
+	{
+	CCmdSudo* self = new(ELeave) CCmdSudo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSudo::~CCmdSudo()
+	{
+	delete iCmd;
+	delete iArgs;
+	iAdd.ResetAndDestroy();
+	iRemove.ResetAndDestroy();
+	
+	if (iPathsToCleanup)
+		{
+		for (TInt i = 0; i < iPathsToCleanup->Count(); i++)
+			{
+			HBufC* file = (*iPathsToCleanup)[i];
+			//Printf(_L("Deleting file %S (not really)\n"), file);
+			Fs().Delete(*file);
+			delete file;
+			}
+		}
+	delete iPathsToCleanup;
+	}
+
+CCmdSudo::CCmdSudo()
+	{
+	}
+
+TCapability CapabilityFromString(const TDesC& aName)
+	{
+	TBuf<32> cap;
+	for (TInt i = 0; i < ECapability_Limit; i++)
+		{
+		cap.Copy(TPtrC8((TUint8*)CapabilityNames[i]));
+		if (aName.CompareF(cap) == 0)
+			{
+			return (TCapability)i;
+			}
+		}
+	return ECapability_None;
+	}
+
+void CCmdSudo::DoRunL()
+	{
+	iPathsToCleanup = new(ELeave) CArrayPtrFlat<HBufC>(8);
+	CalculateCaps();
+	FindExeL();
+	if (iChangeBinaryOnDisk)
+		{
+#ifndef __WINS__
+		// Don't try and use IsFileInRom on WINSCW, the emulator makes a mess of it and anyway, shadowing isn't supported so it being in the core is irrelevant
+		iFileIsInCore = FsL().IsFileInRom(iPath) != NULL;
+#endif
+		if (iFileIsInCore)
+			{
+			// Things in core have to be handled differently
+			iNewPath = iPath; // We don't call CopyExeLC so something has to set this
+			FixupCoreExeLC();
+			}
+		else
+			{
+			CopyExeLC();
+			FixupExeL();
+			}
+		}
+	else
+		{
+		if (iHeapMin || iHeapMax  || iStackSize) LeaveIfErr(KErrArgument, _L("Heap or stack sizes cannot be modified unless you specify --disk"));
+		if (iKeep) LeaveIfErr(KErrArgument, _L("--keep option makes no sense if --disk isn't specified."));
+
+		CleanupStack::PushL((CBase*)NULL); // RunExeL expects a cleanup item for DeleteModifiedBinary, which isn't necessary when --disk isn't specified
+		// Everything else is taken care of from RunExeL
+		}
+	RunExeL();
+	}
+
+void CCmdSudo::FindExeL()
+	{
+	if (!iChangeBinaryOnDisk)
+		{
+		// If we're not changing on disk, it's fine to just use the path as-is and let RProcess::Create sort it out
+		iPath = *iCmd;
+		iNewPath = iPath;
+		return;
+		}
+
+#ifdef __WINS__
+	PrintWarning(_L("On WINS, exe-name must be a complete path to a E32 exe"));
+	iPath = *iCmd;
+#else
+
+	// We can't reliably use RProcess::Create then FileName because the reason we're calling sudo may be because
+	// the capabilities don't allow it to load.
+	_LIT(KExe, ".exe");
+	_LIT(KSysBin, "\\sys\\bin\\");
+	iPath = *iCmd;
+	if (iPath.Right(KExe().Length()).CompareF(KExe) != 0)
+		{
+		iPath.Append(KExe);
+		}
+	TParsePtrC parse(iPath);
+	if (!parse.PathPresent())
+		{
+		TFindFile find(FsL());
+		TInt found = find.FindByDir(iPath, KSysBin);
+		LeaveIfErr(found, _L("Couldn't locate file %S"), &iPath);
+		iPath = find.File();
+		}
+#endif
+	}
+
+void CCmdSudo::CopyExeLC()
+	{
+	iNewPath = iPath;
+	iNewPath[0] = 'c'; // Has to be on C otherwise the loader performs hash checks
+	iNewPath.Append(_L(".sudoed.exe"));
+
+	CleanupStack::PushL(TCleanupItem(&CCmdSudo::DeleteModifiedBinary, this));
+
+	TInt err = FsL().MkDirAll(iNewPath); // In case C:\sys\bin doesn't exist yet
+	if (err && err != KErrAlreadyExists)
+		{
+		LeaveIfErr(err, _L("Couldn't create C:\\sys\\bin"));
+		}
+
+	CFileMan* fm = CFileMan::NewL(Fs());
+	CleanupStack::PushL(fm);
+
+	LeaveIfErr(fm->Copy(iPath, iNewPath), _L("Couldn't copy file from %S to %S"), &iPath, &iNewPath);
+	// Clear the read-only bit in the case where we've copied from Z drive
+	LeaveIfErr(Fs().SetAtt(iNewPath, 0, KEntryAttReadOnly), _L("Couldn't unset read-only flag"));
+
+	/* TODO this code looks like it should work but doesn't. Something in cone or similar is not behaving the way it looks like it should.
+
+	// In case it's an app which will rely on having its main rsc and its mbm file on the same drive as it, copy them over too
+	// (Damn cone for not searching drives or working relative to the reg rsc...)
+	TParsePtrC parse(iPath);
+	TPtrC exename = parse.Name();
+
+	_LIT(KResFmt, "%c:\\Resource\\Apps\\%S.rsc");
+	_LIT(KResDestFmt, "C:\\Resource\\Apps\\%S.sudoed.rsc");
+	iTempSrc.Format(KResFmt, iPath[0], &exename);
+	iTempDest.Format(KResDestFmt, &exename);
+
+	iPathsToCleanup->SetReserveL(iPathsToCleanup->Count() + 2);
+	iPathsToCleanup->AppendL(iTempDest.AllocL());
+	LeaveIfErr(fm->Copy(iTempSrc, iTempDest), _L("Couldn't copy ancillary file %S to %S"), &iTempSrc, &iTempDest);
+	LeaveIfErr(Fs().SetAtt(iTempDest, 0, KEntryAttReadOnly), _L("Couldn't unset read-only flag of %S"), &iTempDest);
+
+	_LIT(KMbmFmt, "%c:\\Resource\\Apps\\%S.mbm");
+	iTempSrc.Format(KMbmFmt, iPath[0], &exename);
+	iTempDest.Format(KMbmFmt, 'c', &exename);
+	if (!FileExists(iTempDest))
+		{
+		iPathsToCleanup->AppendL(iTempDest.AllocL());
+		LeaveIfErr(fm->Copy(iTempSrc, iTempDest), _L("Couldn't copy ancillary file %S to %S"), &iTempSrc, &iTempDest);
+		LeaveIfErr(Fs().SetAtt(iTempDest, 0, KEntryAttReadOnly), _L("Couldn't unset read-only flag of %S"), &iTempDest);
+		}
+	*/
+	CleanupStack::PopAndDestroy(fm);
+	}
+
+void CCmdSudo::FixupExeL()
+	{
+	// Now fix up the capabilities or other stuff
+	RFile file;
+	CleanupClosePushL(file);
+	LeaveIfErr(file.Open(Fs(), iNewPath, EFileWrite|EFileStream|EFileShareAny), _L("Couldn't open file"));
+
+	E32ImageHeaderV* imageHeader=new(ELeave)E32ImageHeaderV;
+	CleanupStack::PushL(imageHeader);
+	TPckg<E32ImageHeaderV> ptr(*imageHeader);
+	LeaveIfErr(file.Read(ptr, sizeof(E32ImageHeaderV)), _L("Couldn't read E32ImageHeader"));
+
+	SSecurityInfo& secinfo = imageHeader->iS;
+	for (TInt i = 0; i < ECapability_Limit; i++)
+		{
+		TCapability cap = (TCapability)i;
+		if (iCapsToAdd.HasCapability(cap)) secinfo.iCaps.AddCapability(cap);
+		if (iCapsToRemove.HasCapability(cap)) reinterpret_cast<TCapabilitySet*>(&secinfo.iCaps)->RemoveCapability(cap);
+		}
+
+	if (iOptions.IsPresent(&iSid))
+		{
+		secinfo.iSecureId = iSid;
+		}
+	if (iOptions.IsPresent(&iVid))
+		{
+		secinfo.iVendorId = iVid;
+		}
+	if (iHeapMin)
+		{
+		imageHeader->iHeapSizeMin = iHeapMin;
+		}
+	if (iHeapMax)
+		{
+		imageHeader->iHeapSizeMax = iHeapMax;
+		}
+	if (iStackSize)
+		{
+		imageHeader->iStackSize = iStackSize;
+		}
+	if (iProcessPriority)
+		{
+		imageHeader->iProcessPriority = iProcessPriority;
+		}
+
+	// Update e32 checksum
+	imageHeader->iHeaderCrc = KImageCrcInitialiser;
+	TUint32 crc = 0;
+	Mem::Crc32(crc, imageHeader, imageHeader->TotalSize());
+	imageHeader->iHeaderCrc = crc;
+
+	LeaveIfErr(file.Write(0, ptr), _L("Couldn't write updated header back to file"));
+	CleanupStack::PopAndDestroy(2, &file); // imageHeader, file
+	}
+
+void CCmdSudo::RunExeL()
+	{
+	// Now actually execute it
+#ifdef __WINS__
+	if (iChangeBinaryOnDisk)
+		{
+		PrintWarning(_L("Updated file written to %S. Not actually executing it."), &iNewPath);
+		CleanupStack::Pop(); // DeleteModifiedBinary
+		return;
+		}
+#endif
+
+	RChildProcess childProcess;
+	TRAPL(childProcess.CreateL(iNewPath, iArgs ? *iArgs : KNullDesC(), IoSession(), Stdin(), Stdout(), Stderr(), Env()), _L("Failed to execute %S"), &iNewPath);
+	if (iKeep)
+		{
+		Printf(_L("Executing %S...\r\n"), &iNewPath);
+		CleanupStack::Pop(); // Don't delete if user asked for --keep
+		}
+	else
+		{
+		CleanupStack::PopAndDestroy(); // DeleteModifiedBinary - remove the binary before we actually start running it, so it is guaranteed cleaned up even if the user kills us with ctrl-c
+		}
+	if (!iChangeBinaryOnDisk)
+		{
+		// Time to get memaccess involved
+		TRAPD(err, FixupExeInMemoryL(childProcess.Process()));
+		if (err)
+			{
+			childProcess.Process().Kill(err);
+			childProcess.Close();
+			User::Leave(err);
+			}
+		}
+
+	if (iWait)
+		{
+		Printf(_L("Process is created but not yet resumed. Press a key to continue...\r\n"));
+		Stdin().ReadKey();
+		}
+
+	TRequestStatus stat;
+	childProcess.Run(stat);
+	User::WaitForRequest(stat);
+	TInt err = stat.Int();
+	childProcess.Close();
+	User::LeaveIfError(err); // This gets translated to our exe's return code I hope
+	}
+
+const TDesC& CCmdSudo::Name() const
+	{
+	_LIT(KName, "sudo");
+	return KName;
+	}
+
+void CCmdSudo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iCmd, _L("exe-name"));
+	aArguments.AppendStringL(iArgs, _L("arguments"));
+	}
+
+void CCmdSudo::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendStringL(iAdd, _L("add-cap"));
+	aOptions.AppendStringL(iRemove, _L("remove-cap"));
+	aOptions.AppendUintL(iSid, _L("sid"));
+	aOptions.AppendUintL(iVid, _L("vid"));
+	aOptions.AppendUintL(iHeapMin, _L("heap-min"));
+	aOptions.AppendUintL(iHeapMax, _L("heap-max"));
+	aOptions.AppendUintL(iStackSize, _L("stack-size"));
+	aOptions.AppendIntL(iProcessPriority, _L("process-priority"));
+	aOptions.AppendBoolL(iKeep, _L("keep"));
+	aOptions.AppendBoolL(iChangeBinaryOnDisk, _L("disk"));
+	aOptions.AppendBoolL(iWait, _L("wait"));
+	}
+
+void CCmdSudo::DeleteModifiedBinary(TAny* aSelf)
+	{
+	CCmdSudo* self = static_cast<CCmdSudo*>(aSelf);
+	self->DeleteModifiedBinary();
+	}
+
+void CCmdSudo::DeleteModifiedBinary()
+	{
+	if (iFileIsInCore)
+		{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+		iMemAccess.FreeShadowMemory((TLinAddr)Fs().IsFileInRom(iPath), sizeof(TRomImageHeader));
+#endif
+		}
+	else
+		{
+		TInt err = Fs().Delete(iNewPath);
+		if (err && err != KErrNotFound && err != KErrPathNotFound) PrintError(err, _L("Couldn't delete file %S"), &iNewPath);
+		}
+	}
+
+EXE_BOILER_PLATE(CCmdSudo)
+
+TBool CCmdSudo::FileExists(const TDesC& aFileName)
+	{
+	TEntry entry;
+	return Fs().Entry(aFileName, entry) == KErrNone;
+	}
+
+void CCmdSudo::FixupExeInMemoryL(RProcess& aProcess)
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	LoadMemoryAccessL();
+	TProcessProperties prop;
+	prop.iCapsToAdd = iCapsToAdd;
+	prop.iCapsToRemove = iCapsToRemove;
+	prop.iProcessPriority = iProcessPriority;
+	if (iOptions.IsPresent(&iSid))
+		{
+		prop.iSid = iSid;
+		}
+	if (iOptions.IsPresent(&iVid))
+		{
+		prop.iVid = iVid;
+		}
+	LeaveIfErr(iMemAccess.SetProcessProperties(aProcess, prop), _L("Couldn't set process properties using memoryaccess"));
+#else
+	(void)aProcess;
+	LeaveIfErr(KErrNotSupported, _L("Can't fixup process in memory without MemoryAccess, try the --disk option instead"));
+#endif
+	}
+
+void CCmdSudo::CalculateCaps()
+	{
+	_LIT(KAll, "All");
+	// Add caps
+	iCapsToAdd.SetEmpty();
+	for (TInt i = 0; i < iAdd.Count(); i++)
+		{
+		const TDesC& capName = *iAdd[i];
+		TCapability cap = CapabilityFromString(capName);
+		if (cap == ECapability_None)
+			{
+			if (capName.CompareF(KAll) == 0)
+				{
+				// The pseudo-cap 'All'
+				iCapsToAdd.SetAllSupported();
+				}
+			else
+				{
+				PrintWarning(_L("Couldn't understand capability name %S"), &capName);
+				}
+			}
+		else
+			{
+			iCapsToAdd.AddCapability(cap);
+			}
+		}
+	// Remove caps
+	iCapsToRemove.SetEmpty();
+	for (TInt i = 0; i < iRemove.Count(); i++)
+		{
+		const TDesC& capName = *iRemove[i];
+		TCapability cap = CapabilityFromString(capName);
+		if (cap == ECapability_None)
+			{
+			if (capName.CompareF(KAll) == 0)
+				{
+				// The pseudo-cap 'All'
+				iCapsToRemove.SetAllSupported();
+				}
+			else
+				{
+				PrintWarning(_L("Couldn't understand capability name %S"), &capName);
+				}
+			}
+		else
+			{
+			iCapsToRemove.AddCapability(cap);
+			}
+		}
+
+	TBool noOptions = (iAdd.Count() == 0) && (iRemove.Count() == 0) && !iOptions.IsPresent(&iSid) && !iOptions.IsPresent(&iVid) && (iHeapMin == 0) && (iHeapMax == 0) && (iStackSize == 0) && (iProcessPriority == 0);
+
+	if (noOptions)
+		{
+		// Default to All -TCB
+		iCapsToAdd.SetAllSupported();
+		iCapsToRemove.AddCapability(ECapabilityTCB);
+		}
+	}
+
+void CCmdSudo::FixupCoreExeLC()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	LoadMemoryAccessL();
+
+	const TRomImageHeader* imageHeader = (const TRomImageHeader*)FsL().IsFileInRom(iPath);
+	if (!imageHeader) LeaveIfErr(KErrNotFound, _L("In FixupCoreExeLC but IsFileInRom returned null??"));
+
+	SCapabilitySet caps = imageHeader->iS.iCaps;
+	for (TInt i = 0; i < ECapability_Limit; i++)
+		{
+		TCapability cap = (TCapability)i;
+		if (iCapsToAdd.HasCapability(cap)) caps.AddCapability(cap);
+		if (iCapsToRemove.HasCapability(cap)) reinterpret_cast<TCapabilitySet*>(&caps)->RemoveCapability(cap);
+		}
+	TPckg<SCapabilitySet> pkg(caps);
+	LeaveIfErr(iMemAccess.WriteShadowMemory((TLinAddr)&imageHeader->iS.iCaps, pkg), _L("Couldn't write shadow memory for caps"));
+
+	if (iOptions.IsPresent(&iSid))
+		{
+		TPckg<TUint> pkg(iSid);
+		LeaveIfErr(iMemAccess.WriteShadowMemory((TLinAddr)&imageHeader->iS.iSecureId, pkg), _L("Couldn't write shadow memory for sid"));
+		}
+	if (iOptions.IsPresent(&iVid))
+		{
+		TPckg<TUint> pkg(iVid);
+		LeaveIfErr(iMemAccess.WriteShadowMemory((TLinAddr)&imageHeader->iS.iVendorId, pkg), _L("Couldn't write shadow memory for sid"));
+		}
+	if (iHeapMin)
+		{
+		TPckg<TUint> pkg(iHeapMin);
+		LeaveIfErr(iMemAccess.WriteShadowMemory((TLinAddr)&imageHeader->iHeapSizeMin, pkg), _L("Couldn't write shadow memory for iHeapSizeMin"));
+		}
+	if (iHeapMax)
+		{
+		TPckg<TUint> pkg(iHeapMax);
+		LeaveIfErr(iMemAccess.WriteShadowMemory((TLinAddr)&imageHeader->iHeapSizeMax, pkg), _L("Couldn't write shadow memory for iHeapSizeMax"));
+		}
+	if (iStackSize)
+		{
+		TPckg<TUint> pkg(iStackSize);
+		LeaveIfErr(iMemAccess.WriteShadowMemory((TLinAddr)&imageHeader->iStackSize, pkg), _L("Couldn't write shadow memory for iStackSize"));
+		}
+	if (iProcessPriority)
+		{
+		TPckg<TUint> pkg(iProcessPriority);
+		LeaveIfErr(iMemAccess.WriteShadowMemory((TLinAddr)&imageHeader->iPriority, pkg), _L("Couldn't write shadow memory for iProcessPriority"));
+		}
+
+	// DeleteModifiedBinary does the right thing in the case of shadowing
+	CleanupStack::PushL(TCleanupItem(&CCmdSudo::DeleteModifiedBinary, this));
+#else
+	LeaveIfErr(KErrNotSupported, _L("Can't fixup an exe in Core image without memoryaccess"));
+#endif
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sudo/sudo.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// sudo.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          sudo.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_SUDO
+capability      all
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          sudo.cpp
+
+library         euser.lib efsrv.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/swi/swi.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,58 @@
+# swi.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name swi
+
+==short-description
+
+Console-based application installer/uninstaller.
+
+==argument enum operation optional
+
+The operation to perform. If not specified, defaults to 'list'.
+
+==enum-value list
+
+Lists the currently installed packages (use --verbose for more info). The list can be filtered by specifying a C<--uid> or <--match> option.
+
+==enum-value install
+
+Installs the package specified by the C<sis-file> argument.
+
+==enum-value uninstall
+
+Uninstalls the package specified by the C<--uid> option.
+
+==argument filename sis-file optional
+
+The SIS file to install. Only valid when the operation is "install".
+
+==option uint u uid
+
+Package UID to uninstall or display information about.
+
+==option bool v verbose
+
+Display verbose output.
+
+==option bool q quiet
+
+If specified, swi will not ask any questions during the install. It will assume yes to any yes/no questions, and will install into the Current Working Directory's drive.
+
+==option string m match
+
+A pattern used to match package names and vendors for "list" (defaults to "*").
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/swi/swi.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1250 @@
+// swi.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "swi.h"
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+
+typedef TBuf<1> TUserInput;
+_LIT(KSwiYes,	"y");
+_LIT(KSwiNo,	"n");
+_LIT(KSwiJarExtension,	"*.jar");
+_LIT(KSwiJadExtension,	"*.jad");
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+_LIT8(KDefaultJadMimeType, "text/vnd.sun.j2me.app-descriptor");
+_LIT8(KDefaultJarMimeType, "application/java-archive");
+#endif
+_LIT(KDefaultMatch, "*");
+
+//
+// CCmdSwi
+// class to handle the fshell console user interaction
+//
+CCommandBase* CCmdSwi::NewLC()
+	{
+	CCmdSwi* self = new(ELeave) CCmdSwi();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSwi::~CCmdSwi()
+	{
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+	delete iMidletHandler;
+#endif
+	delete iSisHandler;
+	delete iMatch;
+	}
+
+CCmdSwi::CCmdSwi():
+CCommandBase(CCommandBase::EManualComplete)
+	{
+	}
+
+const TDesC& CCmdSwi::Name() const
+	{
+	_LIT(KName, "swi");
+	return KName;
+	}
+
+void CCmdSwi::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCommand, _L("operation"));
+
+	_LIT(KArgFilename, "sis-file");
+	aArguments.AppendFileNameL(iSisFile, KArgFilename);
+	}
+	
+void CCmdSwi::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptUid, "uid");
+	aOptions.AppendUintL((TUint&)iUid.iUid, KOptUid);
+
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptQuiet, "quiet");
+	aOptions.AppendBoolL(iQuiet, KOptQuiet);
+
+	_LIT(KOptMatch, "match");
+	aOptions.AppendStringL(iMatch, KOptMatch);
+	}
+
+void CCmdSwi::DoRunL()
+	{
+	if (iMatch == NULL)
+		{
+		iMatch = KDefaultMatch().AllocL();
+		}
+
+	iSisHandler = CSwiSisInstallerAO::NewL(*this, FsL(), iVerbose, iQuiet);
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+	iMidletHandler = CSwiMidletInstallerAO::NewL(*this, FsL(), iVerbose, iQuiet);
+#endif
+
+	switch (iCommand)
+		{
+	case EList:
+		//TODO matching
+		TRAPL(iSisHandler->ListInstalledAppsL(iUid, *iMatch), _L("Couldn't list installed SIS files"));
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+		TRAPL(iMidletHandler->ListInstalledAppsL(iUid, *iMatch), _L("Couldn't list installed midlets"));
+#endif
+		Complete(KErrNone);
+		break;
+		
+	case EUninstall:
+		if (!iOptions.IsPresent(&iUid))
+			{
+			LeaveIfErr(KErrArgument, _L("UID must be specified for \"uninstall\""));
+			}
+		TRAPD(error, iSisHandler->UninstallL(iUid));
+		if (error != KErrNone)
+			{
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+			// possibly a midlet
+			TRAP(error, iMidletHandler->UninstallL(iUid));
+#endif
+			}
+		LeaveIfErr(error, _L("Failed to uninstall package 0x%08x"), iUid.iUid);
+		break;
+		
+	case EInstall:
+		if (!iArguments.IsPresent(1))
+			{
+			LeaveIfErr(KErrArgument, _L("SIS file must be specified for \"install\""));
+			}
+		User::LeaveIfError(Stdin().SetReadMode(RIoReadHandle::ELine));
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+		if (IsMidlet())
+			{
+			TRAPL(iMidletHandler->InstallL(iSisFile), _L("Failed to install midlet '%S'"), &iSisFile);
+			}
+		else
+#endif
+			{
+			TRAPL(iSisHandler->InstallL(iSisFile), _L("Failed to install sis '%S'"), &iSisFile);
+			}
+		break;
+		}
+
+	}
+	
+TBool CCmdSwi::IsMidlet()
+	{
+	if ((iSisFile.MatchF(KSwiJarExtension) != KErrNotFound) || (iSisFile.MatchF(KSwiJadExtension) != KErrNotFound))
+		return ETrue;
+	return EFalse;
+	}
+
+//
+// CCmdSwi::GetAnswer
+// only for use when not in quiet mode
+// Reads input from stdin, determines whether it's a 'yes' or 'no', returning ETrue, EFalse respectively
+//
+TBool CCmdSwi::GetAnswer()
+	{
+	ASSERT(!iQuiet);
+	TUserInput in;
+	for (;;)
+		{
+		if (Stdin().Read(in) != KErrNone)
+			{
+			return EFalse;
+			}
+		Stdout().Write(in);
+		if (in.MatchF(KSwiYes) == 0)
+			{
+			return ETrue;
+			}
+		if (in.MatchF(KSwiNo) == 0)
+			{
+			return EFalse;
+			}
+		// else it's an unrecognised response
+		}
+	}
+
+//
+// MCmdSwiParent hooks
+//
+RIoConsoleReadHandle& CCmdSwi::Input()
+	{
+	return Stdin();
+	}
+
+RIoConsoleWriteHandle& CCmdSwi::Output(TInt aError)
+	{
+	if (aError == KErrNone)
+		{
+		return Stdout();
+		}
+	return Stderr();
+	}
+
+//
+// CCmdSwi::Finished
+// callback from the underlying AO's RunL
+//
+void CCmdSwi::Finished(const TInt aError)
+	{
+	Complete(aError);
+	}
+
+//
+// Sis installer AO
+//
+CSwiSisInstallerAO* CSwiSisInstallerAO::NewL(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet)
+	{
+	CSwiSisInstallerAO* self = new (ELeave) CSwiSisInstallerAO(aParent, aFs, aVerbose, aQuiet);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CSwiSisInstallerAO::CSwiSisInstallerAO(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet)
+	: CActive(CActive::EPriorityStandard), iParent(aParent), iVerbose(aVerbose), iQuiet(aQuiet), iCurrentDrive('c')
+	{
+	TFileName sessionPath;
+	TInt err = aFs.SessionPath(sessionPath);
+	if (err == KErrNone)
+		{
+		iCurrentDrive = sessionPath[0];
+		iCurrentDrive.LowerCase();
+		}
+	CActiveScheduler::Add(this);
+	}
+
+CSwiSisInstallerAO::~CSwiSisInstallerAO()
+	{
+	Cancel();
+	delete iLauncher;
+	delete iRegPackage;
+	iRegistrySession.Close();
+	delete iPrefs;
+	}
+
+void CSwiSisInstallerAO::ConstructL()
+	{
+	iLauncher = CAsyncLauncher::NewL();
+	User::LeaveIfError(iRegistrySession.Connect());
+	iPrefs = Swi::CInstallPrefs::NewL();
+	iPrefs->SetPerformRevocationCheck(EFalse); // TODO - not currently supported in CCmdSwi
+	}
+
+void CSwiSisInstallerAO::RunL()
+	{
+	iParent.Finished(iStatus.Int());
+	}
+
+void CSwiSisInstallerAO::DoCancel()
+	{
+	iLauncher->CancelOperation();
+	iParent.Finished(KErrCancel);
+	}
+
+void CSwiSisInstallerAO::PrintDetails(Swi::CSisRegistryPackage& aPackage)
+	{
+	if (iVerbose)
+		{
+		TName myBuf;
+		myBuf.Format(_L("\r\nName:\t%S\r\n"), &aPackage.Name());
+		Stdout().Write(myBuf);
+		myBuf.Format(_L("Vendor:\t%S\r\n"), &aPackage.Vendor());
+		Stdout().Write(myBuf);
+		myBuf.Format(_L("Uid:\t0x%x\r\n"), aPackage.Uid());
+		Stdout().Write(myBuf);
+		}
+	else
+		{
+		TBuf<256> buf; buf.Format(_L("0x%08x: "), aPackage.Uid());
+		Stdout().Write(buf);
+		Stdout().Write(aPackage.Name());
+		Stdout().Write(_L("\r\n"));
+		}
+	}
+
+void CSwiSisInstallerAO::InstallL(TFileName& aInstallFile)
+	{
+	// install regular sis file
+	ASSERT(iPrefs);
+	ASSERT(iLauncher);
+	iLauncher->InstallL(*this, aInstallFile, *iPrefs, iStatus);
+	SetActive();
+	}
+
+void CSwiSisInstallerAO::UninstallL(const TUid& aPackageUid)
+	{
+	// remove regular sis file
+	ASSERT(iLauncher);
+	ASSERT(!iRegPackage);
+	Swi::CSisRegistryPackage* iRegPackage = GetSisRegistryPackageL(aPackageUid);
+	iLauncher->UninstallL(*this, *iRegPackage, iStatus);
+	SetActive();
+	}
+
+//
+// CSwiSisInstallerAO::ListInstalledAppsL
+// lists apps currently installed on the device
+//
+void CSwiSisInstallerAO::ListInstalledAppsL(const TUid& aAppUid, const TDesC& aMatchString)
+	{
+	if (aAppUid.iUid != 0)
+		{
+		DisplayPackageL(aAppUid);
+		}
+	else
+		{
+		ASSERT(iRegistrySession.Handle() > 0);
+		RPointerArray<CSisRegistryPackage> packages;
+		LtkUtils::CleanupResetAndDestroyPushL(packages);
+		iRegistrySession.InstalledPackagesL(packages);
+		if (packages.Count() <= 0)
+			{
+			User::Leave(KErrNotFound);
+			}
+		TInt count = 0;
+		const TInt endCount = packages.Count();
+		do
+			{
+			CSisRegistryPackage* current = packages[count++];
+			if ((current->Name().MatchF(aMatchString) >= 0) || (current->Vendor().MatchF(aMatchString) >= 0))
+				{
+				PrintDetails(*current);
+				}
+			} while (count < endCount);
+		CleanupStack::PopAndDestroy(&packages);
+		}
+	}
+
+//
+// CSwiSisInstallerAO::DisplayPackageL
+// find information on the specified package uid and display it on the console
+//
+void CSwiSisInstallerAO::DisplayPackageL(const TUid& aPackageUid)
+	{
+	ASSERT(iRegistrySession.Handle() > 0);
+	Swi::RSisRegistryEntry entry;
+	User::LeaveIfError(entry.Open(iRegistrySession, aPackageUid));
+	CleanupClosePushL(entry);
+	Swi::CSisRegistryPackage* registryPackage = entry.PackageL();
+	CleanupStack::PushL(registryPackage);
+	PrintDetails(*registryPackage);
+	CleanupStack::PopAndDestroy(2, &entry);	
+	}
+
+//
+// CSwiSisInstallerAO::GetSisRegistryPackageL
+// locate the sis registry package corresponding to the specified package ui
+//
+Swi::CSisRegistryPackage* CSwiSisInstallerAO::GetSisRegistryPackageL(const TUid& aPackageUid)
+	{
+	ASSERT(iRegistrySession.Handle() > 0);
+	if (!iRegistrySession.IsInstalledL(aPackageUid))
+		{
+		User::Leave(KErrNotFound); // invalid uid
+		}
+	// else iterate through the installed packages to find ours
+	RPointerArray<Swi::CSisRegistryPackage> packages;
+	iRegistrySession.InstalledPackagesL(packages);
+	if (packages.Count() <= 0)
+		{
+		User::Leave(KErrNotFound);
+		}
+	TInt count = 0;
+	const TInt endCount = packages.Count();
+	Swi::CSisRegistryPackage* found = NULL;
+	do
+		{
+		Swi::CSisRegistryPackage* current = packages[count];
+		 if (current->Uid() == aPackageUid)
+			{
+			found = current;
+			break;
+			}
+		count++;
+		} while (count < endCount);
+	ASSERT(found); // IsInstalledL stated it's in there
+	return found; 
+	}
+
+//
+// SWI UI Hooks
+//
+TBool CSwiSisInstallerAO::DisplayTextL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TFileTextOption /*aOption*/, const TDesC& aText)
+	{
+	TBool response = ETrue; // default, the user will continue with the installation/uninstallation
+	if (!iQuiet)
+		{
+		Stdout().Write(aText);
+		Stdout().Write(_L("Continue [y/n]?\r\n"));
+		response = iParent.GetAnswer();
+		}
+	return response;
+	}
+
+void CSwiSisInstallerAO::DisplayErrorL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TErrorDialog aType, const TDesC& /*aParam*/)
+	{
+	if (iVerbose)
+		{
+		switch (aType)
+			{
+			case Swi::EUiAlreadyInRom:
+				Stderr().Write(_L("\r\nCannot overwrite a ROM component.\r\n"));
+			break;
+			
+			case Swi::EUiMissingDependency:
+				Stderr().Write(_L("\r\nMissing a dependency.\r\n"));
+			break;
+			
+			case Swi::EUiRequireVer:
+				Stderr().Write(_L("\r\nA dependency exists on a specific version of an application which is different from the one installed.\r\n"));
+			break;
+
+			case Swi::EUiFileCorrupt:
+				Stderr().Write(_L("\r\nSISX file corrupt. Checksums stored in file do not match actual.\r\n"));
+			break;
+
+			case Swi::EUiDiskNotPresent:
+				Stderr().Write(_L("\r\nAll your bases are belong to us. <disk not present>\r\n"));
+			break;
+
+			case Swi::EUiCannotRead:
+				Stderr().Write(_L("\r\nCannot read a file which is needed in order to proceed.\r\n"));
+			break;
+
+			case Swi::EUiCannotDelete:
+				Stderr().Write(_L("\r\nCannot delete a file.\r\n"));
+			break;
+
+			case Swi::EUiInvalidFileName:
+				Stderr().Write(_L("\r\nA filename specified in the SISX package is not valid.\r\n"));
+			break;
+
+			case Swi::EUiInsufficientSpaceOnDrive:
+				Stderr().Write(_L("\r\nInsufficient space on the drive.\r\n"));
+			break;
+
+			case Swi::EUiCapabilitiesCannotBeGranted:
+				Stderr().Write(_L("\r\nApplication requires system capability it is not signed for.\r\n"));
+			break;
+
+			case Swi::EUiUnknownFile:
+				Stderr().Write(_L("\r\nNot a recognised SISX file.\r\n"));
+			break;
+
+			case Swi::EUiMissingBasePackage:
+				Stderr().Write(_L("\r\nA base package required for installation is not present.\r\n"));
+			break;
+
+			case Swi::EUiConstraintsExceeded:
+				Stderr().Write(_L("\r\nConstraints imposed by a developer mode certificate have been exceeded.\r\n"));
+			break;
+
+			case Swi::EUiSIDViolation:
+				Stderr().Write(_L("\r\nThe package contains a file with a protected SID which is not signed for.\r\n"));
+			break;
+
+			case Swi::EUiVIDViolation:
+				Stderr().Write(_L("\r\nThe package contains a file with a protected VID which is not signed for.\r\n"));
+			break;
+
+			case Swi::EUiSIDMismatch:
+				Stderr().Write(_L("\r\nMismatched SID.\r\n"));
+			break;
+
+			case Swi::EUiBlockingEclipsingFile:
+				Stderr().Write(_L("\r\nThe package contains an invalid eclipsing file which is already in the device other than ROM.\r\n"));
+			break;
+
+			default:
+				{
+				TBuf<64> buf;
+				buf.Format(_L("\r\nAn error %d has occured. Aborting.\r\n"), aType);
+				Stderr().Write(buf);
+				}
+			break;
+			};
+		}
+	}
+	
+TBool CSwiSisInstallerAO::DisplayDependencyBreakL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aComponents*/)
+	{
+	TBool response = ETrue; // default response is to continue with uninstallation
+	if (iVerbose)
+		{
+		Stdout().Write(_L("\r\nComponent being uninstalled has dependencies which may no longer work. Continue uninstalling [y/n]?\r\n"));
+		response = iParent.GetAnswer();
+		}
+	return response;
+	}
+
+TBool CSwiSisInstallerAO::DisplayApplicationsInUseL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aAppNames*/)
+	{
+	TBool response = EFalse; // EFalse indicates we don't continue with uninstallation
+	if (!iQuiet)
+		{
+		Stdout().Write(_L("\r\nApplication is currently open. Continue uninstalling? [y/n]\r\n"));
+		response = iParent.GetAnswer();
+		}
+	if (!response)
+		{
+		Stderr().Write(_L("Uninstall aborted. Application will not be closed.\r\n"));
+		}
+	return response;
+	}
+
+TBool CSwiSisInstallerAO::DisplayQuestionL(const Swi::CAppInfo& /* aAppInfo */, Swi::TQuestionDialog aQuestion, const TDesC& aDes)
+	{
+	TBool response = ETrue; // default behaviour assumes the user presses 'Yes' to any question
+	if (!iQuiet)
+		{
+		if (aQuestion == Swi::EQuestionIncompatible)
+			{
+			Stdout().Write(_L("\r\nApplication is not compatible with this device. Install anyway [y/n]?"));
+			}
+		else if (aQuestion == Swi::EQuestionOverwriteFile)
+			{
+			Stdout().Write(_L("\r\nSome system files will be overwritten by this installation. Install anyway [y/n]?"));
+			}
+		else
+			{
+			TBuf<128> buf; buf.Format(_L("Unrecognised question from engine %d\r\n"), aQuestion);
+			Stderr().Write(buf);
+			User::Leave(KErrNotSupported);
+			}
+
+		if (aDes.Length() > 0)
+			{
+			Stdout().Write(aDes);
+			}
+		Stdout().Write(_L("\r\n"));
+		response = iParent.GetAnswer();
+		}
+	return response;
+	}
+	
+TBool CSwiSisInstallerAO::DisplayInstallL(const Swi::CAppInfo& aAppInfo, const CApaMaskedBitmap* /*aLogo*/, const RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/)
+	{
+	if (iVerbose)
+		{
+		TBuf<256> myBuf;
+		myBuf.Format(_L("NAME:\t\t%S\r\n"), &aAppInfo.AppName());
+		Stdout().Write(myBuf);
+		myBuf.Format(_L("VENDOR:\t\t%S\r\n"), &aAppInfo.AppVendor());
+		Stdout().Write(myBuf);
+		myBuf.Format(_L("VERSION:\t%d.%d.%d\r\n"), aAppInfo.AppVersion().iMajor, aAppInfo.AppVersion().iMinor, aAppInfo.AppVersion().iBuild);
+		Stdout().Write(myBuf);
+		}
+	TBool response = ETrue; // default behaviour is to continue the install
+	return response;
+	}
+	
+TBool CSwiSisInstallerAO::DisplayGrantCapabilitiesL(const Swi::CAppInfo& /*aAppInfo*/, const TCapabilitySet& /*aCapabilitySet*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (iVerbose)
+		{
+		// todo verbose mode
+		Stdout().Write(_L("\r\nTODO - CCmdSwi::DisplayGrantCapabilitiesL\r\n"));
+		}
+	return response;
+	}
+	
+TInt CSwiSisInstallerAO::DisplayLanguageL(const Swi::CAppInfo& /*aAppInfo*/, const RArray<TLanguage>& /*aLanguages*/)
+	{
+	if (iVerbose)
+		{
+		// todo verbose mode
+		Stdout().Write(_L("\r\nTODO - CCmdSwi::DisplayLanguageL\r\n"));
+		}
+	return 0; // the first language
+	}
+	
+TInt CSwiSisInstallerAO::DisplayDriveL(const Swi::CAppInfo& /*aAppInfo*/, TInt64 aSize, const RArray<TChar>& aDriveLetters, const RArray<TInt64>& aDriveSpaces)
+	{
+	TInt response = 0; // default to the first known drive
+	for (TInt i = 0; i < aDriveLetters.Count(); i++)
+		{
+		TChar letter = aDriveLetters[i];
+		letter.LowerCase();
+		if (letter == iCurrentDrive)
+			{
+			response = i; // Default to using the CWD drive, if it is in the list of available drives
+			break;
+			}
+		}
+
+	if (!iQuiet)
+		{
+		TBuf<128> info;
+		info.Format(_L("Application requires %d bytes free space. Please select installation drive:\r\n"), aSize);
+		Stdout().Write(info);
+		for (TInt ii = 0 ; ii < aDriveLetters.Count() ; ii++)
+			{
+			info.Format(_L("%d. \'"), ii);		// pseudo-drive number
+			info.Append(aDriveLetters[ii]);		// drive letter
+			info.Append(_L("\' "));
+			info.AppendNum(aDriveSpaces[ii]); // free space
+			info.Append(_L(" bytes free\r\n"));
+			Stdout().Write(info);
+			}
+		TUserInput in;
+		User::LeaveIfError(Stdin().Read(in));
+		TLex lex(in);
+		User::LeaveIfError(lex.Val(response));
+		}
+	return response;
+	}
+	
+TBool CSwiSisInstallerAO::DisplayUpgradeL(const Swi::CAppInfo& /*aAppInfo*/, const Swi::CAppInfo& /*aExistingAppInfo*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (!iQuiet)
+		{
+		Stdout().Write(_L("Do you wish to replace the existing installed application [y/n]?\r\n"));
+		response = iParent.GetAnswer();
+		}
+	return response;
+	}
+	
+TBool CSwiSisInstallerAO::DisplayOptionsL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aOptions*/, RArray<TBool>& /*aSelections*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (iVerbose)
+		{
+		// todo verbose mode
+		Stdout().Write(_L("TODO - CCmdSwi::DisplayOptionsL\r\n"));
+		}
+	return response;
+	}
+	
+TBool CSwiSisInstallerAO::HandleInstallEventL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TInstallEvent aEvent, TInt /*aValue*/, const TDesC& /*aDes*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (iVerbose)
+		{
+		switch (aEvent)
+			{
+			case Swi::EEventUpdateProgressBar:
+				Stdout().Write(_L("."));
+			break;
+			
+			case Swi::EEventCompletedInstall:
+			case Swi::EEventCompletedUnInstall:
+				{
+				Stdout().Write(_L("\r\nComplete\r\n"));
+				}
+			break;
+
+			default:
+				// do nothing to inform the user of other cases
+			break;
+			};
+		}
+	return response;
+	}
+	
+void CSwiSisInstallerAO::HandleCancellableInstallEventL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TInstallCancellableEvent aEvent, Swi::MCancelHandler& /*aCancelHandler*/, TInt /*aValue*/, const TDesC& /*aDes*/)
+	{
+	if (iVerbose)
+		{
+		switch (aEvent)
+			{
+			case Swi::EEventRemovingFiles:
+				{
+				Stdout().Write(_L("\r\nRemoving files\r\n"));
+				}
+			break;
+			
+			case Swi::EEventShuttingDownApps:
+				{
+				Stdout().Write(_L("Closing App\r\n"));
+				}
+			break;
+
+			case Swi::EEventCopyingFiles:
+				{
+				Stdout().Write(_L("Copying files\r\n"));
+				}
+			break;
+
+			default:
+			break;
+			};
+		}
+	}
+
+TBool CSwiSisInstallerAO::DisplaySecurityWarningL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TSignatureValidationResult /*aSigValidationResult*/, RPointerArray<CPKIXValidationResultBase>& /*aPkixResults*/, RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/, TBool /*aInstallAnyway*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (!iQuiet)
+		{
+		Stdout().Write(_L("\r\nApplication signature cannot be validated. Continue installing [y/n]?\r\n"));
+		response = iParent.GetAnswer();
+		}
+	return response;
+	}
+	
+TBool CSwiSisInstallerAO::DisplayOcspResultL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TRevocationDialogMessage /*aMessage*/, RPointerArray<TOCSPOutcome>& /*aOutcomes*/, RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/, TBool /*aWarningOnly*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (iVerbose)
+		{
+		// todo verbose mode
+		Stdout().Write(_L("TODO - CCmdSwi::DisplayOcspResultL\r\n"));
+		}
+	return response;	
+	}
+	
+void CSwiSisInstallerAO::DisplayCannotOverwriteFileL(const Swi::CAppInfo& /*aAppInfo*/, const Swi::CAppInfo& /*aInstalledAppInfo*/, const TDesC& aFileName)
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("\r\nCannot overwrite a file required for installation. Aborting -"));
+		Stdout().Write(aFileName);
+		Stdout().Write(_L(" - \r\n"));
+		}
+	}
+	
+TBool CSwiSisInstallerAO::DisplayMissingDependencyL(const Swi::CAppInfo& /*aAppInfo*/, const TDesC& aDependencyName, TVersion /*aWantedVersionFrom*/, TVersion /*aWantedVersionTo*/, TVersion /*aInstalledVersion*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (!iQuiet)
+		{
+		Stdout().Write(_L("Warning: Depedency is missing or has incorrect version - "));
+		Stdout().Write(aDependencyName);
+		Stdout().Write(_L(" - \r\n"));
+		}
+	return response;	
+	}
+	
+TBool CSwiSisInstallerAO::DisplayUninstallL(const Swi::CAppInfo& aAppInfo)
+	{
+	if (iVerbose)
+		{
+		TName myBuf;
+		myBuf.Format(_L("NAME:\t\t%S\r\n"), &aAppInfo.AppName());
+		Stdout().Write(myBuf);
+		myBuf.Format(_L("VENDOR:\t\t%S\r\n"), &aAppInfo.AppVendor());
+		Stdout().Write(myBuf);
+		myBuf.Format(_L("VERSION:\t%d.%d.%d\r\n"), aAppInfo.AppVersion().iMajor, aAppInfo.AppVersion().iMinor, aAppInfo.AppVersion().iBuild);
+		Stdout().Write(myBuf);
+		}
+	TBool response = ETrue; // default behaviour is to continue the uninstall
+	return response;	
+	}
+
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+//
+// java ui installer
+//
+CSwiMidletInstallerAO* CSwiMidletInstallerAO::NewL(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet)
+	{
+	CSwiMidletInstallerAO* self = new (ELeave) CSwiMidletInstallerAO(aParent, aFs, aVerbose, aQuiet);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CSwiMidletInstallerAO::CSwiMidletInstallerAO(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet)
+	: CActive(CActive::EPriorityStandard), iParent(aParent), iFs(aFs), iVerbose(aVerbose), iQuiet(aQuiet)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CSwiMidletInstallerAO::~CSwiMidletInstallerAO()
+	{
+	Cancel();
+	if (iInstaller)
+		delete iInstaller;
+	if (iJadHandle)
+		iJadHandle->CloseFileHandle();
+	if (iJarHandle)
+		iJarHandle->CloseFileHandle();
+	if (iInfo)
+		delete iInfo;
+	if (iRemover)
+		delete iRemover;
+	}
+
+void CSwiMidletInstallerAO::ConstructL()
+	{
+	iInstaller = CJavaInstaller::NewL(*this, *this, KNullDesC8, EFalse, 0);
+	}
+
+TBool CSwiMidletInstallerAO::IsJad(TDes& aMidlet)
+	{
+	if (aMidlet.MatchF(KSwiJadExtension) > 0)
+		return ETrue;
+	return EFalse;
+	}
+
+TBool CSwiMidletInstallerAO::IsJar(TDes& aMidlet)
+	{
+	if (aMidlet.MatchF(KSwiJarExtension) > 0)
+		return ETrue;
+	return EFalse;
+	}
+
+void CSwiMidletInstallerAO::ListInstalledAppsL(TUid aAppUid, const TDesC& aMatchString)
+	{
+	MJavaRegistry* reg = MJavaRegistry::CreateL();
+	RArray<TUid> list;
+	TInt count = 0;
+	CleanupStack::PushL(reg);
+	if ((aAppUid.iUid != 0) && (reg->SuiteEntryExistsL(aAppUid)))
+		{
+		MJavaRegistrySuiteEntry* suite = reg->SuiteEntryL(aAppUid);
+		CleanupStack::PushL(suite);
+		suite->MIDletUidsL(list);
+		while (count < list.Count())
+			{
+			MJavaRegistryMIDletEntry* entry = reg->MIDletEntryL(list[count++]);
+			CleanupStack::PushL(entry);
+			DisplayPackageL(*entry);
+			CleanupStack::Pop(entry);
+			entry->Release();
+			}
+		CleanupStack::Pop(suite);
+		suite->Release();
+		}
+	else
+		{
+		reg->InstalledMIDletUidsL(list);
+		while (count < list.Count())
+			{
+			MJavaRegistryMIDletEntry* entry = reg->MIDletEntryL(list[count++]);
+			CleanupStack::PushL(entry);
+			if ((entry->MIDletNameL().MatchF(aMatchString)>=0) || (entry->SuiteEntryL().VendorL().MatchF(aMatchString)>=0))
+				{
+				DisplayPackageL(*entry);
+				}
+			CleanupStack::Pop(entry);
+			entry->Release();
+			}
+		}
+	CleanupStack::Pop(reg);
+	}
+
+//
+// CSwiMidleInstallerAO::DisplayPackageL
+// find information on the specified package uid and display it on the console
+//
+void CSwiMidletInstallerAO::DisplayPackageL(MJavaRegistryMIDletEntry& aPackage)
+	{
+	TName myBuf;
+	myBuf.Format(_L("\r\nNAME:\t%S\r\n"), &aPackage.MIDletNameL());
+	Stdout().Write(myBuf);
+	myBuf.Format(_L("VENDOR:\t%S\r\n"), &aPackage.SuiteEntryL().VendorL());
+	Stdout().Write(myBuf);
+	myBuf.Format(_L("UID:\t0x%x\r\n"), aPackage.SuiteEntryL().UidL());
+	Stdout().Write(myBuf);
+	}
+
+//
+// CSwiMidletInstallerAO::InstallL
+// installs a jar/jad midp 1.0/2.0-compatible midlet
+//
+void CSwiMidletInstallerAO::InstallL(TFileName& aInstallFile)
+	{
+	ASSERT(iInstaller);
+	ASSERT(!iInfo);
+	ASSERT(!iJarHandle);
+	ASSERT(!iJadHandle);
+	if (aInstallFile.Length() <= 0)
+		{
+		User::Leave(KErrNotFound);
+		}
+	if (iVerbose)
+		{
+		Stdout().Write(_L("Installing Midlet...\r\n"));
+		}
+	const TInt length = aInstallFile.Length() - 3; // the java midlet filename minus the jad/jar extension name
+	TFileName sisterFile(aInstallFile.Left(length));
+	if (IsJad(aInstallFile))
+		{
+		iJadHandle = CJavaFileHandle::NewL(iFs, aInstallFile, KNullDesC, KDefaultJadMimeType());
+		// name the associated jar file
+		sisterFile.Append(_L("jar"));
+		iJarHandle = CJavaFileHandle::NewL(iFs, sisterFile, KNullDesC, KDefaultJarMimeType());
+		}
+	else
+		{
+		ASSERT(IsJar(aInstallFile));
+		iJarHandle = CJavaFileHandle::NewL(iFs, aInstallFile, KNullDesC, KDefaultJarMimeType());
+		// name the associated jad file
+		sisterFile.Append(_L("jad"));
+		iJadHandle = CJavaFileHandle::NewL(iFs, sisterFile, KNullDesC, KDefaultJadMimeType());
+		}
+	iInfo = CMIDPInstallationLaunchInfo::NewL(iFs, *iJadHandle, *iJarHandle);
+	iInstaller->Install(*iInfo, iStatus);
+	SetActive();
+	}
+
+//
+// CSwiMidletInstallerAO::Uninstall
+// uninstalls a jar/jad midp 1.0/2.0-compatible midlet
+//
+void CSwiMidletInstallerAO::UninstallL(const TUid& aPackageUid)
+	{
+	ASSERT(!iRemover);
+	if (iVerbose)
+		{
+		Stdout().Write(_L("Removing Midlet...\r\n"));
+		}
+	iRemover = CJavaRemover::NewL(aPackageUid, *this);
+	iRemover->Remove(iStatus);
+	SetActive();
+	}
+
+void CSwiMidletInstallerAO::RunL()
+	{
+	iParent.Finished(iStatus.Int());
+	}
+
+void CSwiMidletInstallerAO::DoCancel()
+	{
+	ASSERT(iInstaller);
+	ASSERT(iRemover);
+	iInstaller->Cancel();
+	iRemover->Cancel();
+	iParent.Finished(KErrCancel);
+	}
+
+//
+// java installer UI hooks
+//
+TBool CSwiMidletInstallerAO::StartInstallL(const CMIDletSuiteAttributes& aMIDlet)
+	{
+	if (iVerbose)
+		{
+		TName myBuf;
+		myBuf.Format(_L("\r\nNAME:\t\t%S\r\n"), &aMIDlet.MIDletName());
+		Stdout().Write(myBuf);
+		myBuf.Format(_L("VENDOR:\t\t%S\r\n"), &aMIDlet.MIDletVendor());
+		Stdout().Write(myBuf);
+		myBuf.Format(_L("VERSION:\t%d.%d.%d\r\n"), aMIDlet.MIDletVersion().iMajor, aMIDlet.MIDletVersion().iMinor, aMIDlet.MIDletVersion().iBuild);
+		Stdout().Write(myBuf);
+		}
+	TBool response = ETrue; // default behaviour is to continue the install
+	return response;
+	}
+
+TBool CSwiMidletInstallerAO::SelectDriveL(const CMIDletSuiteAttributes& /*aMIDlet*/, TInt aSpaceRequired, TChar& aDrive, TBool& aSufficientSpace)
+	{
+	aSufficientSpace = ETrue;
+	aDrive = 'c';
+	if (iQuiet)
+		{
+		// Default to CWD drive if writeable
+		TFileName sessionPath;
+		TInt err = iFs.SessionPath(sessionPath);
+		if (err == KErrNone)
+			{
+			TChar drive = sessionPath[0];
+			drive.LowerCase();
+			TVolumeInfo volInfo;
+			if (iFs.Volume(volInfo, ((TUint)drive)-'a') == KErrNone && volInfo.iFree >= aSpaceRequired && !(volInfo.iDrive.iDriveAtt & KDriveAttRom) && !(volInfo.iDrive.iMediaAtt & KMediaAttWriteProtected))
+				{
+				aDrive = drive;
+				}
+			}
+		}
+	else
+		{
+		// ask the question
+		TBuf<128> info;
+		info.Format(_L("Midlet requires %d bytes free space. Please select installation drive:\r\n"), aSpaceRequired);
+		Stdout().Write(info);
+
+		// cycle through drive list checking for existing drive
+		TDriveList drives;
+		TVolumeInfo volume;
+		TChar driveChar;
+		TBool displayed = EFalse;
+		User::LeaveIfError(iFs.DriveList(drives));
+		for (TInt ii = 0 ; ii < KMaxDrives ; ii++)
+			{
+			if (drives[ii])
+				{
+				// drive exists
+				if (KErrNone == iFs.Volume(volume, ii))
+					{
+					// drive is present
+					if (volume.iFree >= aSpaceRequired)
+						{
+						// drive has sufficient space
+						aSufficientSpace = ETrue;
+						if (!(volume.iDrive.iDriveAtt & KDriveAttRom) && 
+							!(volume.iDrive.iMediaAtt & KMediaAttWriteProtected))
+							{
+							// drive is not a rom drive and is not write protected
+							User::LeaveIfError(iFs.DriveToChar(ii, driveChar));
+							info.Format(_L("%d. \'"), ii);		// drive number
+							info.Append(driveChar);		// drive letter
+							info.Append(_L("\' "));
+							info.AppendNum(volume.iFree); // free space
+							info.Append(_L(" bytes free\r\n"));
+							Stdout().Write(info);
+							displayed = ETrue;
+							}
+						}
+					}
+				}
+			}
+		// get the answer
+		if (displayed)
+			{
+			TUserInput in;
+			User::LeaveIfError(Stdin().Read(in));
+			TLex lex(in);
+			TInt response;
+			User::LeaveIfError(lex.Val(response));
+			User::LeaveIfError(iFs.DriveToChar(response, aDrive));
+			}
+		else
+			{
+			Stdout().Write(_L("Error. No drives capable of supporting midlet install. Aborting\r\n"));
+			return EFalse;
+			}
+		}
+	return ETrue;
+	}
+
+TBool CSwiMidletInstallerAO::ReplaceExistingMIDletL(const CMIDletSuiteAttributes& /*aMIDlet*/, const TAppVersion& /*aOldVersion*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (!iQuiet)
+		{
+		Stdout().Write(_L("Do you wish to replace the existing midlet [y/n]?\r\n"));
+		response = iParent.GetAnswer();
+		}
+	return response;
+	}
+	
+TBool CSwiMidletInstallerAO::UpgradeRMSL(const CMIDletSuiteAttributes& /*aMIDlet*/, const TAppVersion& /*aOldVersion*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (!iQuiet)
+		{
+		Stdout().Write(_L("Do you wish to upgrade the existing midlet [y/n]?\r\n"));
+		response = iParent.GetAnswer();
+		}
+	return response;
+	}
+
+TBool CSwiMidletInstallerAO::MIDletUntrustedL(const CMIDletSuiteAttributes& /*aMIDlet*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the install
+	if (!iQuiet)
+		{
+		Stdout().Write(_L("\r\nMidlet is untrusted. Continue installing [y/n]?\r\n"));
+		response = iParent.GetAnswer();
+		}
+	return response;
+	}
+
+void CSwiMidletInstallerAO::CertificateHasNoRootL(const CMIDletSuiteAttributes& /*aMIDlet*/, const CPKIXCertChain& /*aCertChain*/, const CPKIXValidationResult& /*aValidationResult*/)
+	{
+	Stderr().Write(_L("\r\nCertificate attached to midlet has no identifiable root. Aborting installation.\r\n"));
+	}
+
+void CSwiMidletInstallerAO::BadSignatureL(const CMIDletSuiteAttributes& /*aMIDlet*/, const CPKIXCertChain& /*aCertChain*/, const CPKIXValidationResult& /*aValidationResult*/)
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("\r\nWarning: Midlet certificate chain is incomplete. Continuing installation\r\n"));
+		}
+	}
+
+TBool CSwiMidletInstallerAO::PerformRevocationCheckL(TBool& aDoCheck)
+	{
+	aDoCheck = EFalse;
+	return ETrue;
+	}
+
+void CSwiMidletInstallerAO::StartRevocationCheckL()
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("\r\nStarted: Revocation check\r\n"));
+		}
+	}
+
+void CSwiMidletInstallerAO::FinishedRevocationCheckL()
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("\r\nFinished: Revocation check\r\n"));
+		}
+	}
+
+void CSwiMidletInstallerAO::StartIconConversionL()
+	{
+	}
+
+void CSwiMidletInstallerAO::FinishedIconConversionL()
+	{
+	}
+
+TBool CSwiMidletInstallerAO::OCSPWarningL(const CMIDletSuiteAttributes& /*aMIDlet*/, TRevocationMsg /*aRevocationMsg*/, const TOCSPOutcome* /*aOCSPOutcome*/)
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("\r\nWarning: OCSP failure. Continuing installation.\r\n"));
+		}
+	return ETrue;
+	}
+
+void CSwiMidletInstallerAO::OCSPErrorL(const CMIDletSuiteAttributes& /*aMIDlet*/, TRevocationMsg /*aRevocationMsg*/, const TOCSPOutcome* /*aOCSPOutcome*/)
+	{
+	Stderr().Write(_L("\r\nOCSP Error. Aborting installation.\r\n"));
+	}
+
+TBool CSwiMidletInstallerAO::MIDletInUseL(const CMIDletSuiteAttributes& /*aMIDlet*/)
+	{
+	TBool response = EFalse; // EFalse indicates we don't continue with uninstallation
+	if (!iQuiet)
+		{
+		// print the question
+		Stdout().Write(_L("\r\nMidlet is currently open. Continue installing? [y/n]\r\n"));
+		
+		// get the answer
+		TUserInput in;
+		const TInt error = Stdin().Read(in);
+		if ((error == KErrNone) && (in.MatchF(KSwiYes) == 0))
+			{
+			response = ETrue;
+			}
+		}
+	if (!response)
+		{
+		Stderr().Write(_L("Uninstall aborted. Midlet has not been closed.\r\n"));
+		}
+	return response;
+	}
+
+void CSwiMidletInstallerAO::OTAReportResponseL(TInt aOTAResponseCode, const TDesC& /*aReportBody*/)
+	{
+	if (iVerbose)
+		{
+		switch (aOTAResponseCode)
+			{
+			case CJavaMIDletInstallationResult::EOkay:
+				Stdout().Write(_L("\r\nComplete\r\n"));
+			break;
+			
+			default:
+				Stdout().Write(_L("Abort\r\n"));
+			break;
+			};
+		}
+	}
+
+TInt CSwiMidletInstallerAO::CopyStarted(TInt /*aSize*/)
+	{
+	return KErrNone;
+	}
+
+TInt CSwiMidletInstallerAO::DownloadStarted(TInt /*aSize*/)
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("Downloading midlet\r\n"));
+		}
+	return KErrNone;
+	}
+
+TInt CSwiMidletInstallerAO::UpdateProgress(TInt /*aSize*/)
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("."));
+		}
+	return KErrNone;
+	}
+
+TBool CSwiMidletInstallerAO::GetUsernamePasswordL(HBufC8*& /*aUsername*/, HBufC8*& /*aPassword*/)
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("\r\nTODO: CCmdSwi::GetUsernamePasswordL\r\n"));
+		}
+	return EFalse;
+	}
+
+TBool CSwiMidletInstallerAO::ConfirmRemovalL(const TDesC& /*aRemovalMessage*/)
+	{
+	TBool response = ETrue; // default behaviour is to continue the uninstall
+	return response;	
+	}
+
+void CSwiMidletInstallerAO::InitialiseProgressBarL(TInt /*aMaximumLength*/)
+	{
+	}
+
+void CSwiMidletInstallerAO::UpdateProgressBarL(TInt /*aUnits*/)
+	{
+	if (iVerbose)
+		{
+		Stdout().Write(_L("."));
+		}
+	}
+
+TBool CSwiMidletInstallerAO::MIDletInUseL()
+	{
+	TBool response = EFalse; // EFalse indicates we don't continue with uninstallation
+	if (!iQuiet)
+		{
+		// print the question
+		Stdout().Write(_L("\r\nApplication is currently open. Continue uninstalling? [y/n]\r\n"));
+		
+		// get the answer
+		TUserInput in;
+		const TInt error = Stdin().Read(in);
+		if ((error == KErrNone) && (in.MatchF(KSwiYes) == 0))
+			{
+			response = ETrue;
+			}
+		}
+	return response;
+	}
+
+TBool CSwiMidletInstallerAO::FileInUseL(const TDesC& /*aFileName*/)
+	{
+	TBool response = EFalse; // EFalse indicates we don't continue with uninstallation
+	if (!iQuiet)
+		{
+		// print the question
+		Stdout().Write(_L("\r\nApplication has a file handle open. Continue uninstalling? [y/n]\r\n"));
+		
+		// get the answer
+		TUserInput in;
+		const TInt error = Stdin().Read(in);
+		if ((error == KErrNone) && (in.MatchF(KSwiYes) == 0))
+			{
+			response = ETrue;
+			}
+		}
+	return response;
+	}
+
+#endif //  SYMBIAN_JAVA_NOT_INCLUDED
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdSwi)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/swi/swi.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,221 @@
+// swi.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef _SWI_CMD_
+#define _SWI_CMD_
+
+#include <fshell/ioutils.h>
+#include <e32cmn.h>
+#include <swi/asynclauncher.h>
+#include <swi/sisregistrysession.h>
+#include <swi/sisregistryentry.h>
+#include <swi/sisregistrypackage.h>
+
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+	#include <midpinstallationlaunchinfo.h>
+	#include <midletsuiteattributes.h>
+	#include <javafilehandle.h>
+	#include <javainstaller.h>
+	#include <javaremover.h>
+	#include <mjavainstallerui.h>
+	#include <mjardownloaderui.h>
+	#include <mjavaregistry.h>
+#endif // SYMBIAN_JAVA_NOT_INCLUDED
+
+using namespace IoUtils;
+using namespace Swi;
+
+//
+// MCmdSwiParent
+//
+class MCmdSwiParent
+	{
+public:
+	virtual RIoConsoleReadHandle& Input() = 0;
+	virtual RIoConsoleWriteHandle& Output(TInt aError = KErrNone) = 0;
+	virtual void Finished(const TInt aError) = 0;
+	virtual TBool GetAnswer() = 0;
+	};
+
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+	//
+	// CSwiMidletInstallerAO
+	// active object managing the actual installation/uninstallation of jar/jad files
+	//
+	class CSwiMidletInstallerAO : public CActive, public MJavaInstallerUI, public MJarDownloaderUI, public MJavaRemoverUI
+		{
+	public:
+		static CSwiMidletInstallerAO* NewL(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet);
+		~CSwiMidletInstallerAO();
+		
+		void InstallL(TFileName& aInstallFile);
+		void UninstallL(const TUid& aPackageUid);
+		void ListInstalledAppsL(TUid aAppUid, const TDesC& aMatchString);
+		TBool IsJad(TDes& aMidlet);
+		TBool IsJar(TDes& aMidlet);
+	
+		// java UI handlers
+		virtual TBool StartInstallL(const CMIDletSuiteAttributes& aMIDlet);
+		virtual TBool SelectDriveL(const CMIDletSuiteAttributes& aMIDlet, TInt aSpaceRequired, TChar& aDrive, TBool& aSufficientSpace);
+		virtual TBool ReplaceExistingMIDletL(const CMIDletSuiteAttributes& aMIDlet, const TAppVersion& aOldVersion);
+		virtual TBool UpgradeRMSL(const CMIDletSuiteAttributes& aMIDlet, const TAppVersion& aOldVersion);
+		virtual TBool MIDletUntrustedL(const CMIDletSuiteAttributes& aMIDlet);
+		virtual void CertificateHasNoRootL(const CMIDletSuiteAttributes& aMIDlet, const CPKIXCertChain& aCertChain, const CPKIXValidationResult& aValidationResult);
+		virtual void BadSignatureL(const CMIDletSuiteAttributes& aMIDlet, const CPKIXCertChain& aCertChain, const CPKIXValidationResult& aValidationResult);
+		virtual TBool PerformRevocationCheckL(TBool& aDoCheck);
+		virtual void StartRevocationCheckL();
+		virtual void FinishedRevocationCheckL();
+		virtual void StartIconConversionL();
+		virtual void FinishedIconConversionL();
+		virtual TBool OCSPWarningL(const CMIDletSuiteAttributes& aMIDlet, TRevocationMsg aRevocationMsg, const TOCSPOutcome* aOCSPOutcome);
+		virtual void OCSPErrorL(const CMIDletSuiteAttributes& aMIDlet, TRevocationMsg aRevocationMsg, const TOCSPOutcome* aOCSPOutcome);
+		virtual TBool MIDletInUseL(const CMIDletSuiteAttributes& aMIDlet);
+		virtual void OTAReportResponseL(TInt aOTAResponseCode, const TDesC& aReportBody);
+		virtual TInt CopyStarted(TInt aSize);
+		virtual TInt DownloadStarted(TInt aSize);
+		virtual TInt UpdateProgress(TInt aSize);
+		virtual TBool GetUsernamePasswordL(HBufC8*& aUsername, HBufC8*& aPassword);	
+		virtual TBool ConfirmRemovalL(const TDesC& aRemovalMessage);
+		virtual void InitialiseProgressBarL(TInt aMaximumLength);
+		virtual void UpdateProgressBarL(TInt aUnits);
+		virtual TBool MIDletInUseL();
+		virtual TBool FileInUseL(const TDesC& aFileName);
+	private:
+		CSwiMidletInstallerAO(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet);
+		void ConstructL();
+		void DisplayPackageL(MJavaRegistryMIDletEntry& aPackage);
+		
+		inline RIoConsoleReadHandle& Stdin(){return iParent.Input();}
+		inline RIoConsoleWriteHandle& Stdout(){return iParent.Output();}
+		inline RIoConsoleWriteHandle& Stderr(){return iParent.Output(KErrGeneral);}
+	
+		// from CActive
+		void DoCancel();
+		void RunL();
+	private:
+		MCmdSwiParent& iParent;
+		RFs& iFs;
+		TBool iVerbose;
+		TBool iQuiet;
+		CJavaInstaller* iInstaller;
+		CJavaFileHandle* iJadHandle;
+		CJavaFileHandle* iJarHandle;
+		CMIDPInstallationLaunchInfo* iInfo;
+		CJavaRemover* iRemover;
+		};
+#endif // SYMBIAN_JAVA_NOT_INCLUDED
+
+//
+// CSwiSisInstallerAO
+// active object managing the actual installation/uninstallation of sis files
+//
+class CSwiSisInstallerAO : public CActive, public Swi::MUiHandler
+	{
+public:
+	static CSwiSisInstallerAO* NewL(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet);
+	~CSwiSisInstallerAO();
+	
+	// user commands
+	void InstallL(TFileName& aInstallFile);
+	void UninstallL(const TUid& aPackageUid);
+	void ListInstalledAppsL(const TUid& aAppUid, const TDesC& aMatchString);
+	
+	// Swi UI handlers
+	virtual TBool DisplayTextL(const Swi::CAppInfo& aAppInfo, Swi::TFileTextOption aOption, const TDesC& aText);
+	virtual void DisplayErrorL(const Swi::CAppInfo& aAppInfo, Swi::TErrorDialog aType, const TDesC& aParam);
+	virtual TBool DisplayDependencyBreakL(const Swi::CAppInfo& aAppInfo, const RPointerArray<TDesC>& aComponents);
+	virtual TBool DisplayApplicationsInUseL(const Swi::CAppInfo& aAppInfo, const RPointerArray<TDesC>& aAppNames);
+	virtual TBool DisplayQuestionL(const Swi::CAppInfo& aAppInfo, Swi::TQuestionDialog aQuestion, const TDesC& aDes=KNullDesC);
+	virtual TBool DisplayInstallL(const Swi::CAppInfo& aAppInfo, const CApaMaskedBitmap* aLogo, const RPointerArray<Swi::CCertificateInfo>& aCertificates);
+	virtual TBool DisplayGrantCapabilitiesL(const Swi::CAppInfo& aAppInfo, const TCapabilitySet& aCapabilitySet);
+	virtual TInt DisplayLanguageL(const Swi::CAppInfo& aAppInfo, const RArray<TLanguage>& aLanguages);
+	virtual TInt DisplayDriveL(const Swi::CAppInfo& aAppInfo, TInt64 aSize, const RArray<TChar>& aDriveLetters, const RArray<TInt64>& aDriveSpaces);
+	virtual TBool DisplayUpgradeL(const Swi::CAppInfo& aAppInfo, const Swi::CAppInfo& aExistingAppInfo);
+	virtual TBool DisplayOptionsL(const Swi::CAppInfo& aAppInfo, const RPointerArray<TDesC>& aOptions, RArray<TBool>& aSelections);
+	virtual TBool HandleInstallEventL(const Swi::CAppInfo& aAppInfo, Swi::TInstallEvent aEvent, TInt aValue=0, const TDesC& aDes=KNullDesC);
+	virtual void HandleCancellableInstallEventL(const Swi::CAppInfo& aAppInfo, Swi::TInstallCancellableEvent aEvent, Swi::MCancelHandler& aCancelHandler, TInt aValue=0, const TDesC& aDes=KNullDesC);
+	virtual TBool DisplaySecurityWarningL(const Swi::CAppInfo& aAppInfo, Swi::TSignatureValidationResult aSigValidationResult, RPointerArray<CPKIXValidationResultBase>& aPkixResults, RPointerArray<Swi::CCertificateInfo>& aCertificates, TBool aInstallAnyway);
+	virtual TBool DisplayOcspResultL(const Swi::CAppInfo& aAppInfo, Swi::TRevocationDialogMessage aMessage, RPointerArray<TOCSPOutcome>& aOutcomes, RPointerArray<Swi::CCertificateInfo>& aCertificates, TBool aWarningOnly);
+	virtual void DisplayCannotOverwriteFileL(const Swi::CAppInfo& aAppInfo, const Swi::CAppInfo& aInstalledAppInfo, const TDesC& aFileName);
+	virtual TBool DisplayMissingDependencyL(const Swi::CAppInfo& aAppInfo, const TDesC& aDependencyName, TVersion aWantedVersionFrom, TVersion aWantedVersionTo, TVersion aInstalledVersion);
+	virtual TBool DisplayUninstallL(const Swi::CAppInfo& aAppInfo);
+private:
+	CSwiSisInstallerAO(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet);
+	void ConstructL();
+	
+	void PrintDetails(Swi::CSisRegistryPackage& aPackage);
+	void DisplayPackageL(const TUid& aPackageUid);
+	Swi::CSisRegistryPackage* GetSisRegistryPackageL(const TUid& aPackageUid);
+
+	inline RIoConsoleReadHandle& Stdin(){return iParent.Input();}
+	inline RIoConsoleWriteHandle& Stdout(){return iParent.Output();}
+	inline RIoConsoleWriteHandle& Stderr(){return iParent.Output(KErrGeneral);}
+		
+	// from CActive
+	void DoCancel();
+	void RunL();
+private:
+	MCmdSwiParent& iParent;
+	TBool iVerbose;
+	TBool iQuiet;
+	CAsyncLauncher* iLauncher;
+	Swi::RSisRegistrySession iRegistrySession;
+	Swi::CInstallPrefs* iPrefs;
+	Swi::CSisRegistryPackage* iRegPackage;
+	TChar iCurrentDrive;
+	};
+
+//
+// CCmdSwi
+// Fshell-console based class handling swi related functionality
+//
+class CCmdSwi : public CCommandBase, public MCmdSwiParent
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSwi();
+private:
+	CCmdSwi();
+
+	// utilities
+	TBool IsMidlet();
+	
+	// fshell hooks
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+		
+	// MCmdSwiParent hooks 	
+	virtual RIoConsoleReadHandle& Input();
+	virtual RIoConsoleWriteHandle& Output(TInt aError);
+	virtual void Finished(const TInt aError);
+	virtual TBool GetAnswer();
+private:
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+	CSwiMidletInstallerAO* iMidletHandler;
+#endif
+	CSwiSisInstallerAO* iSisHandler;
+	TFileName2 iSisFile;
+	enum 
+		{
+		EList,
+		EInstall,
+		EUninstall,
+		} iCommand;
+	TUid iUid;
+	HBufC* iMatch;
+	TBool iVerbose;
+	TBool iQuiet;
+	};
+
+#endif // _SWI_CMD_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/swi/swi.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// swi.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target		swi.exe
+targettype		exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_SWI
+//capability		FSHELL_CAP_MMP_NORMAL
+capability		All -Tcb
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source		swi.cpp
+
+library		euser.lib
+library		iocli.lib
+library		efsrv.lib
+library		sishelper.lib
+library		sisregistryclient.lib
+#ifndef SYMBIAN_JAVA_NOT_INCLUDED
+	library		javahelper.lib
+	library		jarfiledecoder.lib
+	library		javaregistry.lib
+#endif
+
+macro		EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/switchview/switchview.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,49 @@
+# switchview.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name switchview
+
+==short-description
+
+Perform a user interface level view switch.
+
+==long-description
+
+On modern platforms (i.e. more recent than 9.1) does not return until the view switch has completed. On 9.1 and earlier, returns B<before> the view switch has completed, which may cause problems in scripts.
+
+Note, application and view identifiers can be found using the L<activeview|activeview> command.
+
+==see-also
+
+L<activeview|activeview>
+
+==argument uint app_id
+
+The identifier of the application that owns the view to be switched to.
+
+==argument uint view_id
+
+The identifier of the view to be switched to.
+
+==argument uint custom_message_id optional
+
+A custom message ID to pass to the activating view.
+
+==argument string custom_message optional
+
+A custom message to pass to the activating view, using the given custom message ID. To send binary data use the fshell escape sequences ^x or ^u.
+
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/switchview/switchview.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,104 @@
+// switchview.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#undef SYMBIAN_ENABLE_SPLIT_HEADERS // Stopgap to handle CVwsSessionWrapper being compiled out of viewcli.h in latest TB92
+#include <fshell/ioutils.h>
+#include <viewcli.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdSwitchview : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSwitchview();
+private:
+	CCmdSwitchview();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TUid iAppId;
+	TUid iViewId;
+	TUid iCustomMessageId;
+	HBufC* iCustomMessage;
+	};
+
+
+CCommandBase* CCmdSwitchview::NewLC()
+	{
+	CCmdSwitchview* self = new(ELeave) CCmdSwitchview();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSwitchview::~CCmdSwitchview()
+	{
+	delete iCustomMessage;
+	}
+
+CCmdSwitchview::CCmdSwitchview()
+	{
+	}
+
+const TDesC& CCmdSwitchview::Name() const
+	{
+	_LIT(KName, "switchview");	
+	return KName;
+	}
+
+void CCmdSwitchview::DoRunL()
+	{
+	CVwsSessionWrapper* vws = CVwsSessionWrapper::NewLC();
+	TVwsViewId viewId(iAppId, iViewId);
+
+	TPtrC8 customMessagePtr(KNullDesC8);
+	if (iCustomMessage)
+		{
+		customMessagePtr.Set((TUint8*)iCustomMessage->Ptr(), iCustomMessage->Size());
+		}
+
+#ifdef FSHELL_9_1_SUPPORT
+	User::LeaveIfError(vws->ActivateView(viewId, iCustomMessageId, customMessagePtr));
+#else
+	TRequestStatus status;
+	vws->ActivateView(viewId, iCustomMessageId, customMessagePtr, status);
+	User::WaitForRequest(status);
+	User::LeaveIfError(status.Int());
+#endif
+
+	CleanupStack::PopAndDestroy(vws);
+	}
+
+void CCmdSwitchview::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgAppId, "app_id");
+	aArguments.AppendUintL((TUint&)iAppId.iUid, KArgAppId);
+	_LIT(KArgViewId, "view_id");
+	aArguments.AppendUintL((TUint&)iViewId.iUid, KArgViewId);
+	_LIT(KArgCustomMessageId, "custom_message_id");
+	aArguments.AppendUintL((TUint&)iCustomMessageId.iUid, KArgCustomMessageId);
+	_LIT(KArgCustomMessage, "custom_message");
+	aArguments.AppendStringL(iCustomMessage, KArgCustomMessage);
+	}
+
+void CCmdSwitchview::OptionsL(RCommandOptionList&)
+	{
+	}
+
+
+EXE_BOILER_PLATE(CCmdSwitchview)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/switchview/switchview.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// switchview.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          switchview.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_SWITCHVIEW
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          switchview.cpp
+
+library         euser.lib
+library         iocli.lib
+library		viewcli.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sysinfo/sysinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+# sysinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name sysinfo
+
+==short-description
+
+Display hardware specific information.
+
+==long-description
+
+Currently, the information displayed includes:
+
+=over 5
+
+=item *
+
+Various HAL settings
+
+=item *
+
+The contents of the kernel config flags (PlatSec enforcement; demand paging attributes; crazy scheduler status)
+
+=item *
+
+Phone model, manufacturer, IMEI and IMSI (if available)
+
+=item *
+
+Cell id and tag for currently attached network cell (if available)
+
+=item *
+
+WLAN MAC address (if available)
+
+=item *
+
+ROM checksum and, if available, version.
+
+=back
+
+==see-also
+
+L<hal|hal>, L<kerninfo|kerninfo>
+
+==option bool m machine-uid
+
+Display Machine UID only. Useful for getting the machine uid into an environment variable, eg C<sysinfo -m | export -s MACHINE_UID>.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sysinfo/sysinfo.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,354 @@
+// sysinfo.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+//
+// CCmdSysInfo.
+//
+#include "u32std.h"
+#include <ETELMM.H>
+#include "sysinfo.h"
+#include <fshell/common.mmh>
+#include <fshell/ltkhal.h>
+#include <fshell/ltkutils.h>
+#ifdef FSHELL_CORE_SUPPORT_SYSINFO_WLAN
+#include <wlansdkpskeys.h>	//for WLAN info
+#endif
+#include <e32rom.h>
+
+	
+CCommandBase* CCmdSysInfo::NewLC()
+	{
+	CCmdSysInfo* self = new (ELeave) CCmdSysInfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSysInfo::~CCmdSysInfo()
+	{
+	}
+
+CCmdSysInfo::CCmdSysInfo()
+	: CCommandBase(EReportAllErrors)
+	{
+	}
+
+void CCmdSysInfo::PrintHalL(HALData::TAttribute aHalAttribute)
+	{
+	LtkUtils::CHalAttribute* attrib = LtkUtils::GetHalInfoL(aHalAttribute);
+	if (attrib->iError)
+		{
+		PrintWarning(_L("Unable to read %S: %S (%d)"), &attrib->iAttributeName, Stringify::Error(attrib->iError), attrib->iError);
+		}
+	else
+		{
+		Printf(_L("%S: %S\r\n"), &attrib->iAttributeName, attrib->iDescription);
+		}
+	delete attrib;
+	}
+
+void CCmdSysInfo::PrintWlanL()
+	{
+#ifdef FSHELL_CORE_SUPPORT_SYSINFO_WLAN
+    //result format 00:18:0f:1e:96:a2.
+    TBuf8<KPSWlanMacAddressLength> DesC8AddrText;
+    TBuf<50> formatedMacAddress;
+    LeaveIfErr(RProperty::Get(KPSUidWlan,KPSWlanMacAddress,DesC8AddrText), _L("Unable to get MAC address"));
+    for ( TInt i=0; i < (TInt)KPSWlanMacAddressLength; i++ )
+        {
+        // Set separator
+        if( i > 0 )
+            formatedMacAddress.Append(':');
+ 
+        // Set data
+        TBuf<10> FormatText;
+        FormatText.Format(_L("%02x"), DesC8AddrText[i]);
+        formatedMacAddress.Append(FormatText);
+        }
+    Printf(_L("WLAN MAC Address: %S\r\n"), &formatedMacAddress);
+#endif
+	}
+
+void CCmdSysInfo::PrintPhoneIdL()
+	{
+#ifdef FSHELL_TELEPHONY_SUPPORT
+	TRequestStatus status;
+
+	RTelServer telSvr;
+	LeaveIfErr(telSvr.Connect(), _L("Unable to connect to telephony server"));
+	CleanupClosePushL(telSvr);
+
+	RMobilePhone mobilePhone;
+	LeaveIfErr(mobilePhone.Open(telSvr, _L("DefaultPhone")), _L("Unable to open default mobile phone"));
+	CleanupClosePushL(mobilePhone);
+		
+	TUint32 identCap;
+	mobilePhone.GetIdentityCaps(identCap);
+		
+	RMobilePhone::TMobilePhoneIdentityV1 Id;
+	mobilePhone.GetPhoneId(status, Id);
+	User::WaitForRequest(status);
+
+	LeaveIfErr(status.Int(), _L("Unable to retrieve phone identity"));
+	if (identCap & RMobilePhone::KCapsGetManufacturer)
+		Printf(_L("Manufacturer (from TSY): %S\r\n"), &(Id.iManufacturer) );
+
+	if (identCap & RMobilePhone::KCapsGetModel)
+		Printf(_L("Model (from TSY): %S\r\n"), &(Id.iModel) );
+		
+	if (identCap & RMobilePhone::KCapsGetRevision)
+		Printf(_L("Revision (from TSY): %S\r\n"), &(Id.iRevision) );
+		
+	if (identCap & RMobilePhone::KCapsGetSerialNumber)
+		Printf(_L("SerialNumber (IMEI): %S\r\n"), &(Id.iSerialNumber) );
+	
+	//query subscriber id
+	if (identCap & RMobilePhone::KCapsGetSubscriberId)
+		{
+		RMobilePhone::TMobilePhoneSubscriberId subsId;
+		mobilePhone.GetSubscriberId(status, subsId);
+		User::WaitForRequest(status);
+
+		LeaveIfErr(status.Int(), _L("Unable to query subscriber id"));
+		Printf(_L("SubscriberId (IMSI): %S\r\n"), &(subsId) );
+		}
+
+	TPckgBuf<RMobilePhone::TMobilePhoneNetworkInfoV1> info;
+	RMobilePhone::TMobilePhoneLocationAreaV1 loc;
+	mobilePhone.GetCurrentNetwork(status, info, loc);
+	User::WaitForRequest(status);
+	LeaveIfErr(status.Int(), _L("Unable to get current network info"));
+	Printf(_L8("Network id: %S "), &info().iNetworkId);
+	Printf(_L("shortName: %S longName: %S displayTag: %S"), &info().iShortName, &info().iLongName, &info().iDisplayTag);
+
+	CleanupStack::PopAndDestroy();	//mobilePhone
+	CleanupStack::PopAndDestroy();	//telSvr
+#endif	
+	}	
+
+void CCmdSysInfo::DoRunL()
+	{
+	if (iMachineUIDOnly)
+		{
+		// sysinfo command-line configured to return only the machine uid value & nothing else
+		TInt value;
+		TInt err = HAL::Get(HALData::EMachineUid, value);
+		if (err)
+			{
+			PrintWarning(_L("Unable to read Machine UID %S (%d)"), Stringify::Error(err), err);
+			}
+		else
+			{
+			TBuf<10> buf;
+			buf.Format(_L("%d"), value);
+			Write(buf);
+			}
+		}
+	else
+		{
+		// sys info command-line configured to return all information, including HAL field description
+		PrintHalL(HALData::EManufacturer);
+		PrintHalL(HALData::EManufacturerHardwareRev);
+		PrintHalL(HALData::EManufacturerSoftwareRev);
+		PrintHalL(HALData::EManufacturerSoftwareBuild);
+		PrintHalL(HALData::EModel);
+		PrintHalL(HALData::EMachineUid);
+		PrintHalL(HALData::ECPUSpeed);
+		PrintHalL(HALData::ESystemStartupReason);
+		PrintHalL(HALData::ESystemTickPeriod);
+		PrintHalL(HALData::ENanoTickPeriod);
+		PrintHalL(HALData::EFastCounterFrequency);
+		PrintHalL(HALData::EFastCounterCountsUp);
+		PrintHalL(HALData::ESystemException);
+		PrintHalL(HALData::EDisplayXPixels);
+		PrintHalL(HALData::EDisplayYPixels);
+		PrintHalL(HALData::EDisplayXTwips);
+		PrintHalL(HALData::EDisplayYTwips);
+		PrintHalL(HALData::EDisplayColors);
+		PrintKernelHalStuff();
+		PrintRomVersion();
+		TRAP_IGNORE(PrintWlanL());
+		TRAP_IGNORE(PrintPhoneIdL());
+		}
+	}
+	
+const TDesC& CCmdSysInfo::Name() const
+	{
+	_LIT(KName, "sysinfo");
+	return KName;
+	}
+
+void CCmdSysInfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptUid, "machine-uid");
+	aOptions.AppendBoolL(iMachineUIDOnly, KOptUid);
+	}
+
+EXE_BOILER_PLATE(CCmdSysInfo)
+
+void CCmdSysInfo::PrintKernelHalStuff()
+	{
+	enum TKernelConfigFlagsNotIn91
+		{
+		EKernelConfigPlatSecLocked = 1<<7,
+		EKernelConfigCrazyScheduling = 1<<8,
+
+		EKernelConfigPagingPolicyNoPaging = 0,
+		EKernelConfigPagingPolicyAlwaysPage = 1,
+		EKernelConfigPagingPolicyDefaultUnpaged = 2,
+		EKernelConfigPagingPolicyDefaultPaged = 3,
+
+		EKernelConfigCodePagingPolicyShift			= 5,
+		EKernelConfigCodePagingPolicyMask			= 3<<5,
+		EKernelConfigCodePagingPolicyNoPaging		= EKernelConfigPagingPolicyNoPaging<<5,
+		EKernelConfigCodePagingPolicyAlwaysPage		= EKernelConfigPagingPolicyAlwaysPage<<5,
+		EKernelConfigCodePagingPolicyDefaultUnpaged	= EKernelConfigPagingPolicyDefaultUnpaged<<5,
+		EKernelConfigCodePagingPolicyDefaultPaged	= EKernelConfigPagingPolicyDefaultPaged<<5,
+
+		EKernelConfigDataPagingPolicyShift			= 9,
+		EKernelConfigDataPagingPolicyMask			= 3<<9,
+		};
+
+	enum THalFunctionsNotIn91
+		{
+		EKernelHalSmpSupported = 15,
+		EKernelHalNumLogicalCpus = 16,
+		EKernelHalConfigFlags = 20,
+		};
+
+	// Memory model
+	TUint memModelInfo = UserSvr::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, 0, 0);
+	Printf(_L("Memory model: "));
+	const TInt EMemModelTypeFlexible = 4;
+	switch (memModelInfo & EMemModelTypeMask)
+		{
+		case EMemModelTypeDirect:
+			Printf(_L("Direct")); break;
+		case EMemModelTypeMoving:
+			Printf(_L("Moving")); break;
+		case EMemModelTypeMultiple:
+			Printf(_L("Multiple")); break;
+		case EMemModelTypeEmul:
+			Printf(_L("Emulator")); break;
+		case EMemModelTypeFlexible:
+			Printf(_L("Flexible")); break;
+		default:
+			Printf(_L("Unknown (%d)"), memModelInfo & EMemModelTypeMask);
+			break;
+		}
+	Printf(_L("\r\n"));
+
+	// Hal config
+	TInt flags = UserSvr::HalFunction(EHalGroupKernel, EKernelHalConfigFlags, 0, 0); // Not the most documented of APIs but has been around since at least v9.1
+	if (flags < 0)
+		{
+#ifdef __EPOC32__
+		// The only things that are dynamically calculated are things that aren't supported on platforms that don't support the HalFunction, so this is a good compromise
+		flags = ((const TRomHeader*)UserSvr::RomHeaderAddress())->iKernelConfigFlags;
+#else
+		return;
+#endif
+		}
+
+	_LIT(KOn, "On");
+	_LIT(KOff, "Off");
+	Printf(_L("PlatSec Enforcement: %S\r\n"), (flags & EKernelConfigPlatSecEnforcement) ? &KOn : &KOff);
+	Printf(_L("PlatSec Locked: %S\r\n"), (flags & EKernelConfigPlatSecLocked) ? &KOn : &KOff);
+	Printf(_L("Crazy scheduling: %S\r\n"), (flags & EKernelConfigCrazyScheduling) ? &KOn : &KOff);
+
+	Printf(_L("Code paging: "));
+	PagingFormat((flags & EKernelConfigCodePagingPolicyMask) >> EKernelConfigCodePagingPolicyShift);
+	Printf(_L("\r\nData paging: "));
+	PagingFormat((flags & EKernelConfigDataPagingPolicyMask) >> EKernelConfigDataPagingPolicyShift);
+	Printf(_L("\r\n"));
+
+	// Num CPUs
+	TBool smpEnabled = (UserSvr::HalFunction(EHalGroupKernel, EKernelHalSmpSupported, 0, 0) == KErrNone);
+	if (smpEnabled)
+		{
+		TInt cpus = UserSvr::HalFunction(EHalGroupKernel, EKernelHalNumLogicalCpus, 0, 0);
+		Printf(_L("Num CPUs: %d\r\n"), cpus);
+		}
+	else
+		{
+		Printf(_L("Num CPUs: 1 (no SMP)\r\n"));
+		}
+	}
+
+void CCmdSysInfo::PagingFormat(TUint aFlags)
+	{
+	enum TMoreFlagsNotIn91
+		{
+		EKernelConfigPagingPolicyNoPaging = 0,
+		EKernelConfigPagingPolicyAlwaysPage = 1,
+		EKernelConfigPagingPolicyDefaultUnpaged = 2,
+		EKernelConfigPagingPolicyDefaultPaged = 3,
+		};
+
+	switch (aFlags)
+		{
+		case EKernelConfigPagingPolicyNoPaging:
+			Printf(_L("No paging")); break;
+		case EKernelConfigPagingPolicyAlwaysPage:
+			Printf(_L("Always page")); break;
+		case EKernelConfigPagingPolicyDefaultUnpaged:
+			Printf(_L("Default unpaged")); break;
+		case EKernelConfigPagingPolicyDefaultPaged:
+			Printf(_L("Default paged")); break;
+		default:
+			break;
+		}
+	}
+
+typedef TInt(*TSysUtilGetSWVersionFunction)(TDes&);
+#ifdef __EPOC32__
+const TInt KSysUtilOrdinal = 9;
+#else
+const TInt KSysUtilOrdinal = 6;
+#endif
+
+void CCmdSysInfo::PrintRomVersion()
+	{
+#ifdef __EPOC32__
+	// Get checksum 
+	TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress();
+	if  (romHeader)
+		{
+		Printf(_L("Rom checksum: 0x%08x\r\n"), romHeader->iCheckSum);
+		}
+#endif
+
+	// Platform version
+	_LIT(KS60VersionDllName, "SysUtil.dll");
+	RLibrary lib;
+	if (lib.Load(KS60VersionDllName) == KErrNone)
+		{
+		// Get exported version function
+		TLibraryFunction fn = lib.Lookup(KSysUtilOrdinal);
+		if (fn != NULL)
+			{
+			TSysUtilGetSWVersionFunction sysUtilGetSWVersion = (TSysUtilGetSWVersionFunction) fn;
+			TBuf<128> buf;
+			TInt err = (*sysUtilGetSWVersion)(buf);
+			if (err)
+				{
+				Printf(_L("Error returned from SysUtilGetSWVersionFunction: %d\r\n"), err);
+				}
+			else
+				{
+				LtkUtils::ReplaceText(buf, _L("\n"), _L(" "));
+				Printf(_L("ROM version: %S\r\n"), &buf);
+				}
+			}
+		lib.Close();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sysinfo/sysinfo.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+// sysinfo.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __SYSINFO_H__
+#define __SYSINFO_H__
+
+#include <hal.h>
+#include <hal_data.h>
+
+#include <fshell/ioutils.h>
+using namespace IoUtils;
+
+class CCmdSysInfo : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSysInfo();
+private:
+	CCmdSysInfo();
+	void UpdateEnvironmentL();
+	void PrintHalL(HALData::TAttribute aHalAttribute);
+	void PrintPhoneIdL();
+	void PrintWlanL();
+	void PrintKernelHalStuff();
+	void PagingFormat(TUint aFlags);
+	void PrintRomVersion();
+	static void IdentCapToString(TUint32& aCap, TDes &aDes);
+	
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iMachineUIDOnly;
+	};
+
+
+#endif // __SYSINFO_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/sysinfo/sysinfo.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// sysinfo.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+
+TARGET			sysinfo.exe
+TARGETTYPE		exe
+UID				FSHELL_UID2_FSHELL_EXE FSHELL_UID_SYSINFO
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			sysinfo.cpp
+
+library			euser.lib
+library			iocli.lib
+library			hal.lib
+library			ltkutils.lib
+
+#ifdef FSHELL_TELEPHONY_SUPPORT
+library		etelmm.lib etel.lib 
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/tail/tail.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# tail.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name tail
+
+==short-description
+
+Print the last portion of the specified file to the console.
+
+==option bool f follow
+
+Print new lines as the file grows.
+
+==option int n lines
+
+The number of lines to be printed (rather than the default 10).
+
+==argument filename file_name
+
+The name of the file to be tailed.
+
+==copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/tail/tail.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,458 @@
+// tail.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "character_converter.h"
+#include "file_reader.h"
+#include "tail.h"
+
+const TInt KBlockSize = 512;
+const TText KUnicodeParagraphSeparator = 0x2029;
+const TText KUnicodeLineSeparator = 0x2028;
+const TText KCarriageReturn = 0x000d;
+const TText KLineFeed = 0x000a;
+
+
+//
+// CTrailingLineFinder.
+//
+
+class CTrailingLineFinder : public CBase, public MFileReaderObserver
+	{
+public:
+	static CTrailingLineFinder* NewL(TInt aBlockSize, CCharacterConverter& aCharacterConverter);
+	~CTrailingLineFinder();
+	void Find(CFileReader& aFileReader, const TDesC& aFileName, TInt aNumLines, MTrailingLineFinderObserver& aObserver);
+	void Cancel();
+	const TDesC& operator[](TInt aIndex) const;
+private:
+	CTrailingLineFinder(CCharacterConverter& aCharacterConverter);
+	void ConstructL(TInt aBlockSize);
+	void HandleFileDataL(const TDesC8& aData, TReadType aType, TBool& aContinue);
+	void FindNextLine(const TDesC& aData, TInt aOffset, TPtrC& aLine, TBool& aComplete);
+	void AddLineL(const TDesC& aLine, TBool aComplete);
+private:	// From MFileReaderObserver.
+	virtual void HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue);
+	virtual void HandleFileReadError(TInt aError);
+private:
+	CFileReader* iFileReader;
+	CCharacterConverter& iCharacterConverter;
+	MTrailingLineFinderObserver* iObserver;
+	HBufC8* iBuf;
+	TPtr8 iPtr;
+	RPointerArray<HBufC> iTrailingLines;
+	TInt iCurrentLineIndex;
+	TInt iNumLinesToFind;
+	TInt iNumCompleteLinesFound;
+	TInt iFilePos;
+	TBool iPossiblySplitCrLf;
+	TBool iLastLineNotComplete;
+	};
+
+CTrailingLineFinder* CTrailingLineFinder::NewL(TInt aBlockSize, CCharacterConverter& aCharacterConverter)
+	{
+	CTrailingLineFinder* self = new(ELeave) CTrailingLineFinder(aCharacterConverter);
+	CleanupStack::PushL(self);
+	self->ConstructL(aBlockSize);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CTrailingLineFinder::~CTrailingLineFinder()
+	{
+	delete iBuf;
+	iTrailingLines.ResetAndDestroy();
+	}
+
+void CTrailingLineFinder::Find(CFileReader& aFileReader, const TDesC& aFileName, TInt aNumLines, MTrailingLineFinderObserver& aObserver)
+	{
+	ASSERT(!iFileReader);
+	iTrailingLines.ResetAndDestroy();
+	iFileReader = &aFileReader;
+	iObserver = &aObserver;
+	iNumLinesToFind = aNumLines;
+	iNumCompleteLinesFound = 0;
+	iCurrentLineIndex = -1;
+	iPossiblySplitCrLf = EFalse;
+	iFileReader->Read(aFileName, *this);
+	}
+
+void CTrailingLineFinder::Cancel()
+	{
+	if (iFileReader)
+		{
+		iFileReader->Cancel();
+		}
+	}
+
+const TDesC& CTrailingLineFinder::operator[](TInt aIndex) const
+	{
+	return *iTrailingLines[aIndex];
+	}
+
+void CTrailingLineFinder::HandleFileDataL(const TDesC8& aData, TReadType aType, TBool& aContinue)
+	{
+	iFilePos += aData.Length();
+	aContinue = ETrue;
+	const TDesC* convertedData = NULL;
+
+	switch (aType)
+		{
+		case MFileReaderObserver::EFirst:
+			{
+			convertedData = &iCharacterConverter.ConvertChunkL(aData, CCharacterConverter::EFirst);
+			break;
+			}
+		case MFileReaderObserver::EMiddle:
+			{
+			convertedData = &iCharacterConverter.ConvertChunkL(aData, CCharacterConverter::EMiddle);
+			break;
+			}
+		case MFileReaderObserver::ELast:
+			{
+			convertedData = &iCharacterConverter.ConvertChunkL(aData, CCharacterConverter::ELast);
+			break;
+			}
+		default:
+			{
+			ASSERT(FALSE);
+			}
+		}
+
+	if (convertedData->Length() > 0)
+		{
+		TInt offset = 0;
+		FOREVER
+			{
+			TPtrC linePtr;
+			TBool completeLine;
+			FindNextLine(*convertedData, offset, linePtr, completeLine);
+			AddLineL(linePtr, completeLine);
+			if (!completeLine)
+				{
+				break;
+				}
+			offset += linePtr.Length();
+			}
+		}
+
+	if (aType == MFileReaderObserver::ELast)
+		{
+		iFileReader = NULL;
+		iObserver->HandleTrailingLines(iCurrentLineIndex + 1, iFilePos);
+		}
+	}
+
+void CTrailingLineFinder::AddLineL(const TDesC& aLine, TBool aComplete)
+	{
+	if (iLastLineNotComplete)
+		{
+		HBufC*& buf = iTrailingLines[iCurrentLineIndex];
+		buf = buf->ReAllocL(buf->Length() + aLine.Length());
+		buf->Des() += aLine;
+		}
+	else
+		{
+		HBufC* line = aLine.AllocLC();
+		if (iNumCompleteLinesFound <= iNumLinesToFind)
+			{
+			++iCurrentLineIndex;
+			User::LeaveIfError(iTrailingLines.Append(line));
+			}
+		else
+			{
+			delete iTrailingLines[0];
+			iTrailingLines.Remove(0);
+			iTrailingLines.Append(line); // Will always succeed due to the above removal.
+			}
+		CleanupStack::Pop(line);
+		}
+
+	iLastLineNotComplete = !aComplete;
+	if (aComplete)
+		{
+		++iNumCompleteLinesFound;
+		}
+	}
+
+CTrailingLineFinder::CTrailingLineFinder(CCharacterConverter& aCharacterConverter)
+	: iCharacterConverter(aCharacterConverter), iPtr(NULL, 0)
+	{
+	}
+
+void CTrailingLineFinder::ConstructL(TInt aBlockSize)
+	{
+	iBuf = HBufC8::NewL(aBlockSize);
+	iPtr.Set(iBuf->Des());
+	}
+
+void CTrailingLineFinder::FindNextLine(const TDesC& aData, TInt aOffset, TPtrC& aLine, TBool& aComplete)
+	{
+	const TText* first = aData.Ptr() + aOffset;
+	const TText* p = first;
+	const TText* last = first + aData.Length() - aOffset - 1;
+	aComplete = EFalse;
+	TBool foundLineBreak = EFalse;
+	while ((p <= last) && !foundLineBreak)
+		{
+		if (iPossiblySplitCrLf)
+			{
+			iPossiblySplitCrLf = EFalse;
+			if (*p == KLineFeed)
+				{
+				aComplete = ETrue;
+				foundLineBreak = ETrue;
+				}
+			}
+		else if ((*p == KUnicodeParagraphSeparator) || (*p == KUnicodeLineSeparator) || (*p == KLineFeed))
+			{
+			aComplete = ETrue;
+			foundLineBreak = ETrue;
+			}
+		else if (*p == KCarriageReturn)
+			{
+			if (p == last)
+				{
+				iPossiblySplitCrLf = ETrue;
+				}
+			else if (*(p + 1) == KLineFeed)
+				{
+				aComplete = ETrue;
+				foundLineBreak = ETrue;
+				++p;
+				}
+			else
+				{
+				aComplete = ETrue;
+				foundLineBreak = ETrue;
+				}
+			}
+		++p;
+		}
+
+	aLine.Set(first, p - first);
+	}
+
+void CTrailingLineFinder::HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue)
+	{
+	TRAPD(err, HandleFileDataL(aData, aType, aContinue));
+	if (err)
+		{
+		iObserver->HandleTrailingLineError(err);
+		}
+	}
+
+void CTrailingLineFinder::HandleFileReadError(TInt aError)
+	{
+	iObserver->HandleTrailingLineError(aError);
+	}
+
+
+//
+// CFileWatcher.
+//
+
+class CFileWatcher : public CActive
+	{
+public:
+	static CFileWatcher* NewL(RFs& aFs);
+	~CFileWatcher();
+	void Start(const TDesC& aFileName, MFileChangeObserver& aObserver);
+private:
+	CFileWatcher(RFs& aFs);
+	void Queue();
+private:	// From CActive.
+	virtual void DoCancel();
+	virtual void RunL();
+private:
+	RFs& iFs;
+	TFileName iFileName;
+	MFileChangeObserver* iObserver;
+	};
+
+
+CFileWatcher* CFileWatcher::NewL(RFs& aFs)
+	{
+	return new(ELeave) CFileWatcher(aFs);
+	}
+
+CFileWatcher::~CFileWatcher()
+	{
+	Cancel();
+	}
+
+void CFileWatcher::Start(const TDesC& aFileName, MFileChangeObserver& aObserver)
+	{
+	ASSERT(!IsActive());
+	iFileName = aFileName;
+	iObserver = &aObserver;
+	Queue();
+	}
+
+CFileWatcher::CFileWatcher(RFs& aFs)
+	: CActive(CActive::EPriorityStandard), iFs(aFs)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CFileWatcher::Queue()
+	{
+	ASSERT(!IsActive());
+	iFs.NotifyChange(ENotifyWrite, iStatus, iFileName);
+	SetActive();
+	}
+
+void CFileWatcher::DoCancel()
+	{
+	iFs.NotifyChangeCancel(iStatus);
+	}
+
+void CFileWatcher::RunL()
+	{
+	Queue();
+	iObserver->HandleFileChange(iFileName);
+	}
+
+
+//
+// CCmdTail.
+//
+
+CCommandBase* CCmdTail::NewLC()
+	{
+	CCmdTail* self = new(ELeave) CCmdTail();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CCmdTail::~CCmdTail()
+	{
+	delete iCharacterConverter;
+	delete iTrailingLineFinder;
+	delete iFileWatcher;
+	delete iFileReader;
+	}
+
+CCmdTail::CCmdTail()
+	: CCommandBase(EManualComplete), iNumLines(10)
+	{
+	}
+
+void CCmdTail::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+void CCmdTail::WriteChunkToConsoleL(const TDesC8& aData, TReadType aType)
+	{
+	switch (aType)
+		{
+		case MFileReaderObserver::EFirst:
+			{
+			Write(iCharacterConverter->ConvertChunkL(aData, CCharacterConverter::EFirst));
+			break;
+			}
+		case MFileReaderObserver::EMiddle: // Treat "middle" and "last" to same as with tailing it's not possible to know if "last" is really last.
+		case MFileReaderObserver::ELast:
+			{
+			Write(iCharacterConverter->ConvertChunkL(aData, CCharacterConverter::EMiddle));
+			break;
+			}
+		default:
+			{
+			ASSERT(FALSE);
+			}
+		}
+	}
+
+const TDesC& CCmdTail::Name() const
+	{
+	_LIT(KName, "tail");
+	return KName;
+	}
+
+void CCmdTail::DoRunL()
+	{
+	iCharacterConverter = CCharacterConverter::NewL(KBlockSize, FsL());
+	iTrailingLineFinder = CTrailingLineFinder::NewL(KBlockSize, *iCharacterConverter);
+	iFileWatcher = CFileWatcher::NewL(Fs());
+	iFileReader = CFileReader::NewL(KBlockSize, Fs(), ETrue);
+	iTrailingLineFinder->Find(*iFileReader, iFileName, iNumLines, *this);
+	}
+
+void CCmdTail::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptFollow, "follow");
+	_LIT(KOptNumLines, "lines");
+	aOptions.AppendBoolL(iFollow, KOptFollow);
+	aOptions.AppendIntL(iNumLines, KOptNumLines);
+	}
+
+void CCmdTail::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFileName, "file_name");
+	aArguments.AppendFileNameL(iFileName, KArgFileName);
+	}
+
+void CCmdTail::HandleTrailingLines(TInt aNumLinesFound, TInt aEndFilePos)
+	{
+	if (iFollow)
+		{
+		iFilePos = aEndFilePos;
+		iFileWatcher->Start(iFileName, *this);
+		}
+	for (TInt i = 0; i < aNumLinesFound; ++i)
+		{
+		Write((*iTrailingLineFinder)[i]);
+		}
+	if (!iFollow)
+		{
+		Complete();
+		}
+	}
+
+void CCmdTail::HandleTrailingLineError(TInt aError)
+	{
+	PrintError(aError, _L("Problem finding trailing %d lines in %S: %d"), iNumLines, &iFileName, aError);
+	Complete(aError);
+	}
+
+void CCmdTail::HandleFileChange(const TDesC& /*aFileName*/)
+	{
+	if (!iFileReader->IsActive())
+		{
+		iFileReader->Read(iFileName, iFilePos, *this);
+		}
+	}
+
+void CCmdTail::HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue)
+	{
+	aContinue = ETrue;
+	iFilePos += aData.Length();
+	TRAPD(err, WriteChunkToConsoleL(aData, aType));
+	if (err)
+		{
+		aContinue = EFalse;
+		PrintError(err, _L("Problem writing chunk of %S to console: %d"), &iFileName, err);
+		}
+	}
+
+void CCmdTail::HandleFileReadError(TInt aError)
+	{
+	PrintWarning(_L("Problem reading %S: %d"), &iFileName, aError);
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdTail)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/tail/tail.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,69 @@
+// tail.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include "file_reader.h"
+#include "character_converter.h"
+
+using namespace IoUtils;
+
+class CFileWatcher;
+class CTrailingLineFinder;
+
+
+class MTrailingLineFinderObserver
+	{
+public:
+	virtual void HandleTrailingLines(TInt aNumLinesFound, TInt aEndFilePos) = 0;
+	virtual void HandleTrailingLineError(TInt aError) = 0;
+	};
+
+
+class MFileChangeObserver
+	{
+public:
+	virtual void HandleFileChange(const TDesC& aFileName) = 0;
+	};
+
+
+class CCmdTail : public CCommandBase, public MTrailingLineFinderObserver, public MFileChangeObserver, public MFileReaderObserver
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTail();
+private:
+	CCmdTail();
+	void ConstructL();
+	void WriteChunkToConsoleL(const TDesC8& aData, TReadType aType);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private: // From MTrailingLineFinderObserver.
+	virtual void HandleTrailingLines(TInt aNumLinesFound, TInt aEndFilePos);
+	virtual void HandleTrailingLineError(TInt aError);
+private: // From MFileChangeObserver.
+	virtual void HandleFileChange(const TDesC& aFileName);
+private: // From MFileReaderObserver.
+	virtual void HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue);
+	virtual void HandleFileReadError(TInt aError);
+private:
+	TFileName2 iFileName;
+	CCharacterConverter* iCharacterConverter;
+	CTrailingLineFinder* iTrailingLineFinder;
+	CFileWatcher* iFileWatcher;
+	CFileReader* iFileReader;
+	TBool iFollow;
+	TInt iNumLines;
+	TInt iFilePos;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/tail/tail.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// tail.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_tail.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_TAIL
+
+userinclude     .
+userinclude     ..\..\core\src
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          tail.cpp
+
+sourcepath      ..\..\core\src
+source          character_converter.cpp
+source          file_reader.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         iocli.lib
+library         charconv.lib
+
+macro           EXE_BUILD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/tfinfo/tfinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# tfinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name tfinfo
+
+==short-description
+
+Display information about the currently install type faces (fonts).
+
+==option bool v verbose
+
+Display verbose information.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/tfinfo/tfinfo.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,110 @@
+// tfinfo.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <w32std.h>
+#include <gdi.h>
+#include <fbs.h>
+
+using namespace IoUtils;
+
+class CCmdTfinfo : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTfinfo();
+private:
+	CCmdTfinfo();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RWsSession iWsSession;
+	CWsScreenDevice* iScreenDevice;
+	CFbsTypefaceStore* iTypefaceStore;
+	TBool iVerbose;
+	};
+
+
+CCommandBase* CCmdTfinfo::NewLC()
+	{
+	CCmdTfinfo* self = new(ELeave) CCmdTfinfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTfinfo::~CCmdTfinfo()
+	{
+	delete iTypefaceStore;
+	delete iScreenDevice;
+	iWsSession.Close();
+	}
+
+CCmdTfinfo::CCmdTfinfo()
+	{
+	}
+
+const TDesC& CCmdTfinfo::Name() const
+	{
+	_LIT(KName, "tfinfo");	
+	return KName;
+	}
+
+void CCmdTfinfo::DoRunL()
+	{
+	LeaveIfErr(iWsSession.Connect(), _L("Couldn't connect to the Window Server"));
+	iScreenDevice = new(ELeave) CWsScreenDevice(iWsSession);
+	iScreenDevice->Construct();
+	iTypefaceStore = CFbsTypefaceStore::NewL(iScreenDevice);
+
+	TInt numTypeFaces = iTypefaceStore->NumTypefaces();
+	if (iVerbose)
+		{
+		Printf(_L("%d type faces found\r\n"), numTypeFaces);
+		}
+	for (TInt i = 0; i < numTypeFaces; ++i)
+		{
+		TTypefaceSupport typefaceSupport;
+		iTypefaceStore->TypefaceSupport(typefaceSupport, i);
+		Printf(_L("%S\r\n"), &typefaceSupport.iTypeface.iName);
+		if (iVerbose)
+			{
+			Printf(_L("\tProportional: %d\r\n"), typefaceSupport.iTypeface.IsProportional());
+			Printf(_L("\tSerif: %d\r\n"), typefaceSupport.iTypeface.IsSerif());
+			Printf(_L("\tSymbol: %d\r\n"), typefaceSupport.iTypeface.IsSymbol());
+			Printf(_L("\tScalable: %d\r\n"), typefaceSupport.iIsScalable);
+			if (!typefaceSupport.iIsScalable)
+				{
+				Printf(_L("\tNumber of heights: %d\r\n"), typefaceSupport.iNumHeights);
+				Printf(_L("\tMin height in twips: %d\r\n"), typefaceSupport.iMinHeightInTwips);
+				Printf(_L("\tMax height in twips: %d\r\n"), typefaceSupport.iMaxHeightInTwips);
+				}
+			}
+		}
+	}
+
+void CCmdTfinfo::ArgumentsL(RCommandArgumentList&)
+	{
+	}
+
+void CCmdTfinfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	}
+
+
+EXE_BOILER_PLATE(CCmdTfinfo)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/tfinfo/tfinfo.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// tfinfo.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_tfinfo.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_TFINFO
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          tfinfo.cpp
+
+library         euser.lib
+library         iocli.lib
+library         fbscli.lib
+library         gdi.lib
+library         ws32.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/top/sampler.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,334 @@
+// sampler.cpp
+// 
+// Copyright (c) 1999 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <platform.h>
+
+#include "sampler.h"
+//#include <nkern.h>
+//#include <kernel.h>
+#include <kern_priv.h>
+_LIT(KLddName,"topsampler");
+
+const TInt KMinRate=10;
+const TInt KMaxRate=1000;
+const TInt KRawBufSize = 20000; // Enough for 20 seconds of samples - since max expected refresh rate in UI is 10s we can do everything nice and simply with one buffer
+
+class DDeviceSampler : public DLogicalDevice
+	{
+public:
+	DDeviceSampler();
+	virtual TInt Install();
+	virtual void GetCaps(TDes8& aDes) const;
+	virtual TInt Create(DLogicalChannelBase*& aChannel);
+	};
+
+class DProfile : public DLogicalChannel
+	{
+public:
+	DProfile();
+	~DProfile();
+protected:
+	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	virtual void HandleMsg(TMessageBase* aMsg);
+private:
+	TInt StartSampling(TInt aRate);
+	TInt StopSampling();
+	TInt Reset();
+	//TInt GetErrors(TDes8* aDes);
+	TInt ProcessReadRequest();
+	void Complete(TInt aResult);
+	inline TBool Running()
+		{return iTimer.iState!=NTimer::EIdle;}
+private:
+	static void Sample(TAny*);
+	void DoSample();
+
+	
+private:
+	TUint32 iStartTime;
+	TInt iRepeat;
+	TInt iPeriod;
+	DThread* iClient;
+	TRequestStatus* iReqStatus;
+	TDes8* iClientDes;		// client des pointer
+	TUint32 iBuf1[KRawBufSize]; // First word is the current position in the buffer
+	TUint32 iBuf2[KRawBufSize]; // Have two buffers that we can switch between, this avoids us having to stop the sampler timer, or disable interrupts or whatever, when we want to drain the buffer
+	TUint32* iCurrentBuf; // Pointer to either iBuf1 or iBuf2
+
+	struct TReport
+		{
+		TUint iRawBufferErrCounter;
+		TUint iCodeSegErrCounter;
+		TInt  iReportMask; 
+		} iReport;
+
+	NTimer iTimer;
+	};
+
+DECLARE_STANDARD_LDD()
+	{
+	return new DDeviceSampler;
+	}
+
+DDeviceSampler::DDeviceSampler()
+//
+// Constructor
+//
+	{
+	//iParseMask=0;
+	//iUnitsMask=0;
+	iVersion=TVersion(1,0,0);
+	}
+
+TInt DDeviceSampler::Install()
+//
+// Install the device driver.
+//
+	{
+	TInt r=SetName(&KLddName);
+	return r;
+	}
+
+void DDeviceSampler::GetCaps(TDes8& /*aDes*/) const
+//
+// Return the capabilities.
+//
+	{
+	}
+
+TInt DDeviceSampler::Create(DLogicalChannelBase*& aChannel)
+//
+// Create a channel on the device.
+//
+	{
+	aChannel=new DProfile;
+	return aChannel?KErrNone:KErrNoMemory;
+	}
+
+DProfile::DProfile()
+	:	iTimer(Sample,this)
+//
+// Constructor
+//
+	{
+	iCurrentBuf = iBuf1;
+	iCurrentBuf[0] = 1;
+	}
+
+DProfile::~DProfile()
+//
+// Destructor
+//
+	{
+	iTimer.Cancel();
+	Kern::SafeClose((DObject*&)iClient, NULL);
+	}
+
+TInt DProfile::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer)
+//
+// Create the channel from the passed info.
+//
+	{
+	if (!Kern::QueryVersionSupported(TVersion(1,0,1),aVer))
+		return KErrNotSupported;
+
+	iClient=&Kern::CurrentThread();
+	iClient->Open();
+	//Kern::SetThreadPriority(24);
+	SetDfcQ(Kern::DfcQue0());
+	iMsgQ.Receive();
+	return KErrNone;
+	}
+
+void DProfile::Complete(TInt aResult)
+//Completes user request
+	{
+	DEBUG_PROFILER(Kern::Printf("C");)
+	Kern::RequestComplete(iClient,iReqStatus,aResult);
+	}
+
+TInt DProfile::StartSampling(TInt aRate)
+	{
+	DEBUG_PROFILER(Kern::Printf("START");)
+	//Activate timer
+	aRate=Min(KMaxRate, Max(KMinRate, aRate));
+	iPeriod=1000/aRate;
+
+	if (!Running())
+		{
+		iCurrentBuf = iBuf1;
+		iCurrentBuf[0] = 1;
+		iTimer.OneShot(iPeriod);
+		}
+	
+	DEBUG_PROFILER(Kern::Printf("START end");)
+	return KErrNone;
+	}
+
+TInt DProfile::Reset()
+	{
+//
+// Resets the device. It is the first message sent by profiler application.
+//	
+	if (Running())
+		return KErrGeneral;
+	
+	DEBUG_PROFILER(Kern::Printf("RST %d", aXIPOnly);)
+
+	iTimer.Cancel();
+	iPeriod=1;
+	iReqStatus=NULL;
+	iClientDes=NULL;
+
+	iReport.iRawBufferErrCounter = 0;
+	iReport.iCodeSegErrCounter = 0;
+	iReport.iReportMask = 0;
+	DEBUG_PROFILER(Kern::Printf("RST end");)
+	return KErrNone;
+	}
+
+TInt DProfile::StopSampling()
+//
+// Stops sampling
+//
+	{
+	DEBUG_PROFILER(Kern::Printf("STOP");)
+	if (Running())
+		{
+		iTimer.Cancel();
+		}
+	if (iReqStatus)
+		Complete(KErrNone);
+	
+	DEBUG_PROFILER(Kern::Printf("STOP end");)
+	return KErrNone;
+	}
+
+TInt DProfile::ProcessReadRequest()
+	{
+	// Whatever the status of the profiler, return the contents of the current sampling buffer
+	DEBUG_PROFILER(Kern::Printf("READ");)
+	TInt max=Kern::ThreadGetDesMaxLength(iClient, iClientDes);
+	if (max<0)
+		return max;
+	if (max==0)
+		return KErrArgument;
+
+	TUint32* otherBuf = (iCurrentBuf == iBuf1 ? iBuf2 : iBuf1);
+	otherBuf[0] = 1; // Reset other buf
+	TUint32* bufToWrite = iCurrentBuf;
+	iCurrentBuf = otherBuf; // And switch do it, so we can safely mess with bufToWrite without the sampling ISR adding more data under our feet
+	TInt numSamples = bufToWrite[0] - 1; // Because bufToWrite[0] is an index and the data actually starts at index 1
+	TPtrC8 desToWrite((TUint8*)&bufToWrite[1], (numSamples)*sizeof(TUint32));
+	
+	TInt r = Kern::ThreadDesWrite(iClient, iClientDes, desToWrite, 0, 0, iClient);
+	return r;
+	}
+
+void DProfile::HandleMsg(TMessageBase* aMsg)
+//
+// Client requests
+//
+	{
+	TInt r=KErrNone;
+	TThreadMessage& m=*(TThreadMessage*)aMsg;
+	//BEGIN TOMSCI commented out this check as it is too strict
+	/*
+	if (m.Client()!=iClient)
+		{
+		m.PanicClient(_L("SAMPLER"),EAccessDenied);
+		return;
+		}
+	*/
+	//END TOMSCI
+	TInt id=m.iValue;
+	if (id==(TInt)ECloseMsg)
+		{
+		DEBUG_PROFILER(Kern::Printf("CLOSE");)
+		iTimer.Cancel();
+		m.Complete(KErrNone,EFalse);
+		iMsgQ.CompleteAll(KErrServerTerminated);
+		DEBUG_PROFILER(Kern::Printf("CLOSE end");)
+		return;
+		}
+	else if (id<0)
+		{
+		if (id!=~RSampler::ERequestRead)
+			{
+			TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
+			Kern::RequestComplete(iClient,pS,KErrNotSupported);
+			}
+		if (iReqStatus)
+			{
+			m.PanicClient(_L("SAMPLER"),ERequestAlreadyPending);
+			return;
+			}
+		iReqStatus=(TRequestStatus*)m.Ptr0();
+		iClientDes=(TDes8*)m.Ptr1();
+		TInt err = ProcessReadRequest();
+		Complete(err);
+		}
+	else if (id==KMaxTInt)
+		{
+		TInt mask=m.Int0();
+		if (mask & (1<<RSampler::ERequestRead))
+			{
+			Complete(KErrCancel);
+			}
+		}
+	else
+		{
+		switch(id)
+			{
+			case RSampler::EControlStartProfile:
+				r=StartSampling(m.Int0());
+				break;
+			case RSampler::EControlStopProfile:
+				r=StopSampling();
+				break;
+			case RSampler::EControlResetProfile:
+				r=Reset();
+				break;
+			//case RSampler::EControlGetErrors:
+			//	r=GetErrors((TDes8*)m.Ptr0());
+			//	break;
+			default:
+				r=KErrNotSupported;
+				break;
+			}
+		}
+	m.Complete(r,ETrue);
+	}
+
+void DProfile::Sample(TAny* aPtr)
+	{
+	DProfile& d=*(DProfile*)aPtr;
+	d.DoSample();
+	}
+
+void DProfile::DoSample()
+	{
+	iTimer.Again(iPeriod);
+
+	TUint32& currentPos = iCurrentBuf[0];
+	if (currentPos < (TUint)KRawBufSize) // space in buffer
+		{
+		DThread* pT=Kern::NThreadToDThread(NKern::CurrentThread());
+		if (pT!=NULL)
+			{
+			iCurrentBuf[currentPos] = pT->iId;
+			currentPos++;
+			}
+		}
+	else
+		iReport.iRawBufferErrCounter++;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/top/sampler.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,156 @@
+// sampler.h
+// 
+// Copyright (c) 1999 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SAMPLER_H__
+#define __SAMPLER_H__
+
+#include <e32cmn.h>
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
+
+//Uncomment this line to generate debug logging of the profiler and sampler.
+//#define DEBUG_PROFILER(f) f
+#define DEBUG_PROFILER(f)
+
+/**
+ * The user device driver class for controlling the sampler.
+ */
+class RSampler : public RBusLogicalChannel
+	{
+	friend class DProfile;
+private:
+	enum TControl
+		{
+		EControlGetSegments,
+		EControlStartProfile,
+		EControlStopProfile,
+		EControlResetProfile,
+		EControlResetSegments,
+		EControlDrain,
+		EControlGetErrors
+		};
+	enum TRequest
+		{
+		ERequestRead
+		};
+	static inline TInt CancelRequest(TRequest aRequest);
+public:
+#ifndef __KERNEL_MODE__
+	/** Open a channel to the sampling device */
+	inline TInt Open();
+	/** Get the current non-XIP Code Segments*/
+	inline void GetSegments(TDes8& aData);
+	/** Start sampling */
+	inline void Start(TInt aRate);
+	/** Stop sampling */
+	inline void Stop();
+	/** Extract the sample data */
+	inline void Read(TDes8& aData,TRequestStatus& aStatus);
+	/** Cancel a read request */
+	inline void ReadCancel();
+	/** Extract any remaining sample data */
+	inline void Drain(TDes8& aData);
+	/** Get error report */
+	inline void GetErrors(TDes8& aData);
+	/** Reset the sampler for a new run */
+	inline void Reset(TBool aXIPOnly);
+	/** Initialise non-XIP segments for a new run */
+	inline void ResetSegments();
+#endif
+	};
+
+_LIT(KSamplerName,"topsampler");
+
+#ifndef __KERNEL_MODE__
+inline TInt RSampler::CancelRequest(TRequest aRequest)
+	{return 1<<aRequest;}
+
+inline TInt RSampler::Open()
+	{return DoCreate(KSamplerName,TVersion(1,0,0),KNullUnit,NULL,NULL);}
+
+/**
+ * Get the existing non-XIP Code Segments.
+ *
+ * @param aData	A descriptor to receive data. Returns as zero-length if all data 
+ * records are already transfered.
+ */
+inline void RSampler::GetSegments(TDes8& aData)
+	{DoControl(EControlGetSegments, &aData);}
+
+/**
+ * Start sampling at the requested rate. If currently sampling, this will just
+ * change the sample rate.
+ *
+ * @param aRate The sample rate in samples/second
+ */
+inline void RSampler::Start(TInt aRate)
+	{DoControl(EControlStartProfile, reinterpret_cast<TAny*>(aRate));}
+
+/**
+ * Stop sampling. If currently sampling, any outstanding read request will be completed
+ * with data remaining in the buffer.
+ */
+inline void RSampler::Stop()
+	{DoControl(EControlStopProfile);}
+
+/**
+ * Reset the sampler. All sample data is discarded and history is removed, preparing the
+ * sampler for a new run. The sampler must be stopped before it can be reset.
+ *
+ * @param aXIPOnly True if the profiler runs in XIPOnly mode.
+ */
+inline void RSampler::Reset(TBool aXIPOnly)
+	{DoControl(EControlResetProfile,(TAny*)aXIPOnly);}
+
+/**
+* Reset non-XIP code segments, preparing the sampler for a new run
+*/
+inline void RSampler::ResetSegments()
+	{DoControl(EControlResetSegments);}
+
+/**
+ * Extract the sample data from the device. This will complete when the device's buffer is
+ * full, when the provided descriptor is full, or when the sampler is stopped.
+ *
+ * @param aData		A descriptor to receive the sample data
+ * @param aStatus	A request status used to signal when this request is completed
+ */
+inline void RSampler::Read(TDes8& aData,TRequestStatus& aStatus)
+	{DoRequest(ERequestRead,aStatus,&aData);}
+
+/**
+ * Cancel the outstanding read request
+ */
+inline void RSampler::ReadCancel()
+	{DoCancel(CancelRequest(ERequestRead));}
+
+/**
+ * Extract any remaining sample data from the device buffer. When the buffer is
+ * empty, the descriptor will be empty on return.
+ *
+ * @param aData	A descriptor to receive the sample data
+ */
+inline void RSampler::Drain(TDes8& aData)
+	{DoControl(EControlDrain,&aData);}
+
+/**
+ * Get error report from the sampler.
+ *
+ * @param aData		A descriptor to receive error report
+ */
+inline void RSampler::GetErrors(TDes8& aData)
+	{DoControl(EControlGetErrors,&aData);}
+
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/top/top.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# top.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name top
+
+==short-description
+
+Display CPU usage by thread.
+
+==long-description
+
+Note that this command does not currently work on SMP systems, and will always return KErrNotSupported.
+
+==option int r rate
+
+How frequently to update, in milliseconds. Defaults to 1000 (1 second). Anything over 10 seconds (10000) will probably cause dropped samples in the driver.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/top/top.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// top.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          top.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_TOP
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+capability		PowerMgmt
+#endif
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          topfshell.cpp
+
+library         euser.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/top/top_sampler.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// top_sampler.mmp
+// 
+// Copyright (c) 1996 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include		<fshell/common.mmh>
+#include		"kernel\kern_ext.mmh"
+
+target			topsampler.ldd
+targettype		ldd
+
+uid				0x100000af FSHELL_UID_TOPSAMPLE
+capability		all
+
+sourcepath		.
+source			sampler.cpp
+
+library			ekern.lib
+epocallowdlldata
+
+start wins
+win32_headers
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/top/topfshell.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,245 @@
+// topfshell.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32hashtab.h>
+#include <fshell/ioutils.h>
+#include <fshell/memoryaccesscmd.h>
+#include "sampler.h"
+
+using namespace IoUtils;
+
+class CCmdTop : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTop();
+private:
+	CCmdTop();
+	static TInt TimerCallback(TAny* aSelf);
+	void TimerCallback();
+	void UpdateL();
+	struct SThreadData;
+	static TInt SortReverse(const CCmdTop::SThreadData& aLeft, const CCmdTop::SThreadData& aRight);
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RBuf8 iReadBuf;
+	struct SThreadData
+		{
+		TUint iId;
+		TInt iNumSamples;
+		TFullName iName; // Saves recalculating every time
+		};
+	RHashMap<TUint, SThreadData*> iSeenThreads; // Saves linear searching through iThreads for each sample (Maps thread id to SThreadData
+	RPointerArray<SThreadData> iThreads;
+	RSampler iSampler;
+	CPeriodic* iTimer;
+	TInt iRate;
+
+	CTextBuffer* iBuffer;
+	CTextFormatter* iFormatter;
+	TInt iNumConsoleLines;
+	TInt iNumLinesInLastUpdate;
+	};
+
+CCommandBase* CCmdTop::NewLC()
+	{
+	CCmdTop* self = new(ELeave) CCmdTop();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTop::~CCmdTop()
+	{
+	if (iTimer)
+		{
+		iTimer->Cancel();
+		}
+	delete iTimer;
+	if (iSampler.Handle())
+		{
+		iSampler.Stop();
+		iSampler.Close();
+		User::FreeLogicalDevice(KSamplerName);
+		}
+	delete iBuffer;
+	delete iFormatter;
+	iReadBuf.Close();
+	iThreads.ResetAndDestroy();
+	iSeenThreads.Close();
+	}
+
+CCmdTop::CCmdTop()
+	: CMemoryAccessCommandBase(EManualComplete), iRate(1000)
+	{
+	}
+
+const TDesC& CCmdTop::Name() const
+	{
+	_LIT(KName, "top");	
+	return KName;
+	}
+
+void CCmdTop::ArgumentsL(RCommandArgumentList& /*aArguments*/)
+	{
+	}
+
+void CCmdTop::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendIntL(iRate, _L("rate"));
+	}
+
+EXE_BOILER_PLATE(CCmdTop)
+
+void CCmdTop::DoRunL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	LoadMemoryAccessL();
+#endif
+
+	TInt err = User::LoadLogicalDevice(KSamplerName);
+	if (err != KErrNone && err != KErrAlreadyExists)
+		{
+		LeaveIfErr(err, _L("Couldn't load sampler ldd %S"), &KSamplerName);
+		}
+	iReadBuf.CreateL(iRate * 2 * sizeof(TUint32)); // go twice as big as needed just to be safe, allows for AO not getting to run on time
+	iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+	iTimer->Start(iRate*1000, iRate*1000, TCallBack(&CCmdTop::TimerCallback, this));
+
+	LeaveIfErr(iSampler.Open(), _L("Couldn't open sampler"));
+	iSampler.Reset(ETrue); // Parameter is ignored
+	iSampler.Start(1000); // Always tell sampler to sample every millisecond, regardless of the frequency we update the UI
+
+	TSize size;
+	User::LeaveIfError(Stdout().GetScreenSize(size));
+	iNumConsoleLines = size.iHeight;
+	iBuffer = CTextBuffer::NewL(512);
+	iFormatter = CTextFormatter::NewL(size.iWidth);
+	Stdout().ClearScreen();
+	UpdateL(); // Just so we display something on screen before the first update
+	}
+
+TInt CCmdTop::TimerCallback(TAny* aSelf)
+	{
+	static_cast<CCmdTop*>(aSelf)->TimerCallback();
+	return 0;
+	}
+
+void CCmdTop::TimerCallback()
+	{
+	iReadBuf.Zero();
+	TRequestStatus stat;
+	iSampler.Read(iReadBuf, stat);
+	User::WaitForRequest(stat); // API used to be async, it's now sync but I haven't changed the interface
+	
+	// First off clear all the iNumSamples (as that was for the previous sampling period)
+	for (TInt i = 0; i < iThreads.Count(); i++)
+		{
+		iThreads[i]->iNumSamples = 0;
+		}
+
+	TInt numSamples = iReadBuf.Length() / sizeof(TUint32);
+	TUint32* buf = (TUint32*)iReadBuf.Ptr();
+	for (TInt i = 0; i < numSamples; i++)
+		{
+		TUint32 threadId = buf[i];
+		SThreadData** thread = iSeenThreads.Find(threadId);
+		if (thread)
+			{
+			(*thread)->iNumSamples++;
+			}
+		else
+			{
+			// New thread id
+			SThreadData* thread = new SThreadData;
+			if (!thread) continue;
+			TInt err = iThreads.Append(thread);
+			if (err)
+				{
+				delete thread;
+				continue;
+				}
+			err = iSeenThreads.Insert(threadId, thread);
+			if (err)
+				{
+				iThreads.Remove(iThreads.Count()-1);
+				delete thread;
+				continue;
+				}
+			thread->iNumSamples = 1;
+			thread->iId = threadId;
+			RThread rthread;
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+			err = iMemAccess.RThreadForceOpen(rthread, threadId);
+#else
+			err = rthread.Open(TThreadId(threadId));
+#endif
+			if (err == KErrNone)
+				{
+				thread->iName = rthread.FullName();
+				//PrettyName(EListThread, thread->iName);
+				rthread.Close();
+				}
+			else
+				{
+				thread->iName = _L("Tid: ");
+				thread->iName.AppendNum(threadId);
+				}
+			}
+		}
+	TRAP_IGNORE(UpdateL());
+	}
+
+TInt CCmdTop::SortReverse(const CCmdTop::SThreadData& aLeft, const CCmdTop::SThreadData& aRight)
+	{
+	// This sorts largest number of samples first 
+	TInt res = - (aLeft.iNumSamples - aRight.iNumSamples);
+	if (res == 0) return aLeft.iId - aRight.iId; // make sure there is a total ordering in event of tie break
+	return res;
+	}
+
+void CCmdTop::UpdateL()
+	{
+	// First, sort iThreads
+	iThreads.Sort(TLinearOrder<SThreadData>(&SortReverse));
+
+	TInt numSamples = iReadBuf.Size() / sizeof(TUint32);
+	
+	iBuffer->Zero();
+	iFormatter->Zero();
+	iBuffer->AppendL(_L("Tid\tThread name\tCPU usage\r\n"));
+
+	for (TInt i = 0; i < iThreads.Count() && i < iNumConsoleLines-2; i++) // minus one for title, one for last line of screen which I can't seem to figure out how to make use of
+		{
+		SThreadData& thread = *iThreads[i];
+		TReal percent = 100 * thread.iNumSamples / (TReal)numSamples;
+		iBuffer->AppendFormatL(_L("%d\t%S\t%00.2f%%\r\n"), thread.iId, &thread.iName, percent);
+		}
+	Stdout().SetCursorHeight(0);
+	iFormatter->TabulateL(0, 1, iBuffer->Descriptor(), ETruncateLongestColumn);
+	User::LeaveIfError(Stdout().SetCursorPosAbs(TPoint(0, 0)));
+	Stdout().Write(iFormatter->Descriptor());
+	TInt numLines = 1 + iThreads.Count(); // plus 1 for the title line
+	TInt numOldLines = iNumLinesInLastUpdate - numLines;
+	while (numOldLines > 0)
+		{
+		Stdout().ClearToEndOfLine();
+		Stdout().SetCursorPosRel(TPoint(0, 1));
+		--numOldLines;
+		}
+	iNumLinesInLastUpdate = numLines;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/uidinfo/uidinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# uidinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name uidinfo
+
+==short-description
+
+Displays the name of any exe whose UID3 matches the given value. 
+
+==long-description
+
+If using --stdin, expects a uid per line, and outputs the name next to the uid. This is compatible with doing, say, C<ls C:\private | uidinfo -s>.
+
+==argument uint uid optional
+
+Specify a uid to look up.
+
+==option bool s stdin
+
+Read uids one per line from stdin. All uids read from stdin are assumed to be in hex format even if they don't have a preceding 0x.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/uidinfo/uidinfo.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,126 @@
+// uidinfo.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <apgcli.h>
+#include <fshell/ltkutils.h>
+#include <fshell/qr3dll.h>
+
+using namespace IoUtils;
+
+class CCmdUidInfo : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdUidInfo();
+private:
+	CCmdUidInfo();
+	TInt PrintUid(TUint aUid);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TUint iUid;
+	TBool iStdin;
+	RBuf iBuf;
+	};
+
+CCommandBase* CCmdUidInfo::NewLC()
+	{
+	CCmdUidInfo* self = new(ELeave) CCmdUidInfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdUidInfo::~CCmdUidInfo()
+	{
+	iBuf.Close();
+	}
+
+CCmdUidInfo::CCmdUidInfo()
+	{
+	}
+
+const TDesC& CCmdUidInfo::Name() const
+	{
+	_LIT(KName, "uidinfo");	
+	return KName;
+	}
+
+void CCmdUidInfo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendUintL(iUid, _L("uid"));
+	}
+
+void CCmdUidInfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iStdin, _L("stdin"));
+	}
+
+
+EXE_BOILER_PLATE(CCmdUidInfo)
+
+void CCmdUidInfo::DoRunL()
+	{
+	if (iStdin)
+		{
+		Stdin().SetReadModeL(RIoReadHandle::ELine);
+		TBuf<512> lineBuf; // Note, the code below doesn't properly handle the situation where a given line of input in longer than this buffer.
+		while (ETrue)
+			{
+			TInt err = Stdin().Read(lineBuf);
+			if (err == KErrEof)
+				{
+				break;
+				}
+			else if (err)
+				{
+				User::Leave(err);
+				}
+			if (lineBuf.Length() < 2) continue;
+			// In this case we assume hex even without an 0x
+			if (lineBuf.Left(2).CompareF(_L("0x")) != 0) lineBuf.Insert(0, _L("0x"));
+			TLex lex(lineBuf);
+			TUint uid = 0;
+			TRAP(err, uid = LtkUtils::HexLexL(lex));
+			if (err)
+				{
+				PrintWarning(_L("Failed to find a uid on line '%S'"), &lineBuf);
+				continue;
+				}
+			err = PrintUid(uid);
+			if (err)
+				{
+				PrintWarning(_L("Couldn't find exe for uid 0x%08x, err = %d\r\n"), uid, err);
+				}
+			}
+		}
+	else if (!iArguments.IsPresent(&iUid))
+		{
+		LeaveIfErr(KErrArgument, _L("You must specify either a uid or the --stdin option."));
+		}
+	else
+		{
+		LeaveIfErr(PrintUid(iUid), _L("Couldn't find exe for uid 0x%08x"), iUid);
+		}
+	}
+
+TInt CCmdUidInfo::PrintUid(TUint aUid)
+	{
+	TInt err = ExeNameForSid(aUid, iBuf);
+	if (err) return err;
+	Printf(_L("0x%x %S\r\n"), aUid, &iBuf);
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/uidinfo/uidinfo.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// uidinfo.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			uidinfo.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_UIDINFO
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			uidinfo.cpp
+
+library			euser.lib
+library			iocli.lib
+library			ltkutils.lib qr3.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/uprofiler/uprofiler.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+# uprofiler.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name uprofiler
+
+==short-description
+
+Start or stop the uprofiler-compatible atrace sampler.
+
+==long-description
+
+This will also modify the EProfiling BTrace category.
+
+==argument enum command
+
+Whether to start or stop the profiler.
+
+==enum-value start
+
+==enum-value stop
+
+==argument int rate optional
+
+Sampling frequency rate, in Hertz. Must be between 1 and 1000 (to give sample period of 1s down to 1ms). For compatability it is recommended that this argument is always specified when doing a uprofiler start, and always be set to 1000.
+
+==option bool v verbose
+
+This option is accepted for compatibility with symbian uprofiler.exe. It has no effect. For maximum compatibility, only the short form -v should be used.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/uprofiler/uprofiler.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,93 @@
+// uprofiler.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/extrabtrace.h>
+
+using namespace IoUtils;
+
+class CCmdUprofiler : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdUprofiler();
+private:
+	CCmdUprofiler();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TCommand
+		{
+		EStart = 0,
+		EStop = 1,
+		};
+	TCommand iCommand;
+	TInt iRate; // In Hz, just for fun
+	RExtraBtrace iBtrace;
+	TBool iVerbose;
+	};
+
+CCommandBase* CCmdUprofiler::NewLC()
+	{
+	CCmdUprofiler* self = new(ELeave) CCmdUprofiler();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdUprofiler::~CCmdUprofiler()
+	{
+	iBtrace.Close();
+	}
+
+CCmdUprofiler::CCmdUprofiler()
+	: iRate(1000)
+	{
+	}
+
+const TDesC& CCmdUprofiler::Name() const
+	{
+	_LIT(KName, "uprofiler");	
+	return KName;
+	}
+
+void CCmdUprofiler::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendEnumL((TInt&)iCommand, _L("command"));
+	aArguments.AppendIntL(iRate, _L("rate"));
+	}
+
+void CCmdUprofiler::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, _L("verbose"));
+	}
+
+EXE_BOILER_PLATE(CCmdUprofiler)
+
+void CCmdUprofiler::DoRunL()
+	{
+	if (iRate <= 0 || iRate > 1000) LeaveIfErr(KErrArgument, _L("rate must be between 1 and 1000"));
+
+	TInt ms = 1000 / iRate;
+	LeaveIfErr(iBtrace.Connect(), _L("Couldn't connect to RExtraBtrace"));
+	if (iCommand == EStart)
+		{
+		LeaveIfErr(iBtrace.EnableProfiling(ms), _L("Couldn't enable profiling"));
+		}
+	else
+		{
+		LeaveIfErr(iBtrace.EnableProfiling(0), _L("Couldn't disable profiling"));
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/uprofiler/uprofiler.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// uprofiler.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_uprofiler.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_UPROFILER
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          uprofiler.cpp
+
+library         euser.lib
+library         iocli.lib
+library			extrabtrace.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/usb/usb.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# usb.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name usb
+
+==short-description
+
+Get info about the state of the USB connection.
+
+==argument int personality optional
+
+Personality to start.
+
+==copyright
+
+Copyright (c) 2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/usb/usb.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,135 @@
+// usb.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#include <usbman.h>
+
+using namespace IoUtils;
+
+class CCmdUsb : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdUsb();
+private:
+	CCmdUsb();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RUsb iUsb;
+	TInt iPersonality;
+	};
+
+EXE_BOILER_PLATE(CCmdUsb)
+
+CCommandBase* CCmdUsb::NewLC()
+	{
+	CCmdUsb* self = new(ELeave) CCmdUsb();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdUsb::~CCmdUsb()
+	{
+	iUsb.Close();
+	}
+
+CCmdUsb::CCmdUsb()
+	{
+	}
+
+const TDesC& CCmdUsb::Name() const
+	{
+	_LIT(KName, "usb");	
+	return KName;
+	}
+
+void CCmdUsb::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendIntL(iPersonality, _L("personality"));
+	}
+
+void CCmdUsb::OptionsL(RCommandOptionList& /*aOptions*/)
+	{
+	}
+
+#define CASE_LIT(x) case x: { _LIT(KName, #x); return &KName; }
+
+const TDesC* DeviceState(TUsbDeviceState aState)
+	{
+	switch (aState)
+		{
+		CASE_LIT(EUsbDeviceStateUndefined);
+		CASE_LIT(EUsbDeviceStateDefault);
+		CASE_LIT(EUsbDeviceStateAttached);
+		CASE_LIT(EUsbDeviceStatePowered);
+		CASE_LIT(EUsbDeviceStateConfigured);
+		CASE_LIT(EUsbDeviceStateAddress);
+		CASE_LIT(EUsbDeviceStateSuspended);
+		default:
+			{
+			_LIT(KUnknown, "?");
+			return &KUnknown;
+			}
+		}
+	}
+
+const TDesC* ServiceState(TUsbServiceState aState)
+	{
+	switch (aState)
+		{
+		CASE_LIT(EUsbServiceIdle);
+		CASE_LIT(EUsbServiceStarting);
+		CASE_LIT(EUsbServiceStarted);
+		CASE_LIT(EUsbServiceStopping);
+		CASE_LIT(EUsbServiceFatalError);
+		default:
+			{
+			_LIT(KUnknown, "?");
+			return &KUnknown;
+			}
+		}
+	}
+
+void CCmdUsb::DoRunL()
+	{
+	LeaveIfErr(iUsb.Connect(), _L("Couldn't connect to RUsb"));
+
+	TUsbDeviceState dev;
+	LeaveIfErr(iUsb.GetDeviceState(dev), _L("Couldn't get device state"));
+	Printf(_L("Usb Device state = %S (%d)\r\n"), DeviceState(dev), dev);
+
+	TUsbServiceState servicestate;
+	LeaveIfErr(iUsb.GetServiceState(servicestate), _L("Couldn't get service state"));
+	Printf(_L("Usb Service state = %S (%d)\r\n"), ServiceState(servicestate), servicestate);
+
+	RArray<TInt> ids;
+	LeaveIfErr(iUsb.GetPersonalityIds(ids), _L("Couldn't get personalities ids"));
+	for (TInt i = 0; i < ids.Count(); i++)
+		{
+		Printf(_L("Personality %d\r\n"), ids[i]);
+		}
+
+	if (iArguments.IsPresent(&iPersonality))
+		{
+		TRequestStatus stat;
+		iUsb.TryStart(iPersonality, stat);
+		User::WaitForRequest(stat);
+		LeaveIfErr(stat.Int(), _L("Couldn't start USB personality %d"), iPersonality);
+		Printf(_L("USB started ok.\r\n"));
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/usb/usb.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// usb.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			fshell_usb.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_USB
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+sourcepath		.
+source			usb.cpp
+
+library			euser.lib
+library			iocli.lib
+library			usbman.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/variant/variant.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+# variant.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name variant
+
+==short-description
+
+Determines the hardware variant and whether or not that matches the variant specified via the command line.
+
+==long-description
+
+If the device matches the given command line options, KErrNone is returned. If not, KErrNotSupported is returned. Note that the command will not print any error message in the case of the variant not being supported, so that it doesn't make script output untidy. If an error message is required, use the C<--verbose> option.
+
+In addition there are two special variants understood by all implementations of this command: C<wins> and C<target> for WINS[CW] emulator and non-emulator platforms respectively.
+
+Example usage:
+
+    variant h4 && do-something-h4-specific
+    variant wins && do-something-emulator-specific
+    variant h4 h6 && do-something-for-h4-and-h6
+
+==option uint u uid multiple
+
+Test whether the device matches any of the specified machine UIDs.
+
+==option bool v verbose
+
+Display verbose output.
+
+==argument string variantname optional multiple
+
+A symbolic name for the hardware variant may be specified instead of having to know the machine uid. This maximises compatibility with platforms that provide a custom variant.exe and/or that need more than just the machine UID to determine the variant. Check the platform-specific documentation for what variant string is used to identify that platform's hardware. If multiple variant names are specified KErrNone is returned if any one of them matches.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/variant/variant.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,153 @@
+// variant.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <hal.h>
+#include "variant.h"
+#include <fshell/descriptorutils.h>
+
+//
+// CCmdVariant
+//
+CCommandBase* CCmdVariant::NewLC()
+	{
+	CCmdVariant* self = new (ELeave) CCmdVariant();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdVariant::~CCmdVariant()
+	{
+	iVariant.ResetAndDestroy();
+	}
+
+CCmdVariant::CCmdVariant() : 
+CCommandBase(CCommandBase::EManualComplete)
+	{
+	}
+
+const TDesC& CCmdVariant::Name() const
+	{
+	_LIT(KName, "variant");	
+	return KName;
+	}
+
+//
+// CCmdVariant::DoRunL
+// looks for a match between the variant uids specified via the command line and the
+// actual variant uid of the device
+//
+
+struct TVariant
+	{
+	TInt iUid;
+	LtkUtils::SLitC iName;
+	};
+
+// Only shipping products or established reference hardware platforms in here please.
+// Unannounced protos should have their platform build its own variant.exe to identify their hardware,
+// alternatively people have to rely on doing a "variant --uid xyz" whichever is preferred by the platform
+const TVariant KMachineIdVariants[] = {
+	{ 0x102734E3, DESC("h4") },
+	{ 0x10286564, DESC("h6") },
+	{ 0x102864F7, DESC("naviengine") },
+	{ 0x20002D82, DESC("n96") },
+	{ 0x20002496, DESC("e90") },
+	{ 0x20002D7E, DESC("6120") },
+	{ 0x20002D83, DESC("n81") },
+	{ 0x2000DA56, DESC("5800") },
+	{ 0x2001F0A1, DESC("satio") }, // I assume this is what it shipped with...
+	{ 0x20029a73, DESC("n8") }, // Likewise...
+	};
+const TInt KMachineIdVariantCount = sizeof(KMachineIdVariants) / sizeof(TVariant);
+
+void CCmdVariant::DoRunL()
+	{
+	if (iMachineId.Count() == 0 && iVariant.Count() == 0)
+		{
+		LeaveIfErr(KErrArgument, _L("You must specify at least one <variantname> argument or --uid option"));
+		}
+
+	TInt localMachineUid = GetMachineUidL();
+	TBool match = EFalse;
+	if (iMachineId.Count())
+		{
+		for (TInt i = 0; i < iMachineId.Count(); i++)
+			{
+			if (iMachineId[i] == (TUint)localMachineUid)
+				{
+				match = ETrue;
+				break;
+				}
+			}
+		}
+
+	if (iVariant.Count())
+		{
+		for (TInt i = 0; match == EFalse && i < iVariant.Count(); i++)
+			{
+			for (TInt j = 0; match == EFalse && j < KMachineIdVariantCount; j++)
+				{
+				if (iVariant[i]->CompareF(KMachineIdVariants[j].iName) == 0 && localMachineUid == KMachineIdVariants[j].iUid)
+					{
+					match = ETrue;
+					}
+				}
+#ifdef __WINS__
+			if (iVariant[i]->CompareF(_L("wins")) == 0) match = ETrue;
+#else
+			if (iVariant[i]->CompareF(_L("target")) == 0) match = ETrue;
+#endif
+			}
+		}
+
+	if (iVerbose)
+		{
+		if (match)
+			{
+			Printf(_L("Specified variant supported\r\n"));
+			}
+		else
+			{
+			PrintError(KErrNotSupported, _L("Specified variant not supported"));
+			}
+		}
+
+	SetErrorReported(ETrue); // Don't show the error
+	Complete(match ? KErrNone : KErrNotSupported);
+	}
+
+void CCmdVariant::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iVariant, _L("variantname"));
+	}
+
+void CCmdVariant::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdOptUid, "uid");
+	aOptions.AppendUintL(iMachineId, KCmdOptUid);
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	}
+
+//
+// CCmdVariant::GetMachineUidL
+// retrieve the variant's machine uid
+//
+TInt CCmdVariant::GetMachineUidL()
+	{
+	TInt value = KErrNotSupported;
+	User::LeaveIfError(HAL::Get(HALData::EMachineUid, value));
+	return value;
+	}
+	
+EXE_BOILER_PLATE(CCmdVariant)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/variant/variant.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// variant.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdVariant : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdVariant();
+private:
+	CCmdVariant();
+	TInt GetMachineUidL();
+
+	// From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RArray<TUint> iMachineId;
+	RPointerArray<HBufC> iVariant;
+	TBool iVerbose;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/variant/variant.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// variant.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          	variant.exe
+targettype    	exe
+uid             	FSHELL_UID2_FSHELL_EXE FSHELL_UID_VARIANT
+
+userinclude     	.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      	.
+source          	variant.cpp
+
+library         	euser.lib
+library         	efsrv.lib
+library         	iocli.lib
+library		hal.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/wget/wget.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,54 @@
+# wget.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name wget
+
+==short-description
+
+A non-interactive network retriever.
+
+==argument string url
+
+The URL identifying the file to download from or upload to. Eg: 'http://www.symbian.org/'.
+
+==option bool c continue
+
+Continue resume getting a partially-downloaded file.
+
+==option filename d downloadfile
+
+Download-only option. Specify the path and filename of the file being downloaded. By default the filename from the server is used, and the file is downloaded to the current working directory
+
+==option filename f uploadfile
+
+Use this option to upload a file rather than download.
+
+==option int i iap
+
+Connect using the specified IAP id. If not given, the no-arguments overload of C<RConnection::Start()> is used.
+
+==option string u username
+
+Username for use in authentication, if required, with the HTTP server.
+
+==option string p password
+
+Password for use in authentication, if required, with the HTTP server.
+
+==option bool v verbose
+
+Enables verbose reporting of the download progress.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/wget/wget.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,892 @@
+// wget.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// TODO: byte-range support
+
+#include <commdbconnpref.h>
+#include <httpstringconstants.h>
+#include <httperr.h>
+#include <mhttpdatasupplier.h>
+#include <rhttpheaders.h>
+#include <thttphdrfielditer.h>
+#include <bautils.h>
+#include "wget.h"
+
+using namespace IoUtils;
+
+_LIT8(KHttpProtocol,	"HTTP/TCP");
+_LIT(KDateFormat,		"%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S.%C%:3");
+const TInt KMaxHeaderNameLen = 32;
+const TInt KMaxHeaderValueLen = 128;
+
+CCommandBase* CCmdWget::NewLC()
+	{
+	CCmdWget* self = new(ELeave) CCmdWget();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdWget::~CCmdWget()
+	{
+	delete iUrl;
+	delete iUsername;
+	delete iPassword;
+	if (iSessionIsOpen)
+		{
+		iSession.Close(); // closes iTransaction also
+		}
+	if (iConnection.SubSessionHandle() > 0)
+		{
+		iConnection.Close();
+		}
+	if (iSocketServ.Handle() > 0)
+		{
+		iSocketServ.Close();
+		}
+	if (iLocalFile.SubSessionHandle() > 0)
+		{
+		iLocalFile.Flush();
+		iLocalFile.Close();
+		}
+	}
+
+CCmdWget::CCmdWget() : CCommandBase(CCommandBase::EManualComplete)
+	{
+	}
+
+const TDesC& CCmdWget::Name() const
+	{
+	_LIT(KName, "wget");
+	return KName;
+	}
+
+void CCmdWget::DoRunL()
+	{
+	// sanity check parameters
+	if (!iUrl || iUrl->Des().Length() > KMaxName)
+		{
+		if (iVerbose)
+			{
+			PrintError(KErrArgument, _L("Url not specified or is too large."));
+			}
+		User::Leave(KErrArgument);
+		}		
+	if ((iUsername && iUsername->Des().Length() > KMaxName) || (iPassword && iPassword->Des().Length() > KMaxName))
+		{
+		if (iVerbose)
+			{
+			PrintError(KErrArgument, _L("Username or Password is too large."));
+			}
+		User::Leave(KErrArgument);
+		}
+
+	if (iUploadFilename.Length())
+		{
+		iPostData = ETrue; // Keep this member variable because lots of code assumes it
+		}
+
+	LaunchConnectionL(); // start a connection - KErrNone returned if successfully started or a compatible connection already exists
+		
+	if (iPostData)
+		{
+		// http post
+		PrepareUploadFileL();
+		}
+	else
+		{
+		// http get
+		PrepareDownloadFileL(); // prep. the local file to receive the downloaded data
+		}
+	User::LeaveIfError(iLocalFile.Size(iLocalFileSize));
+	ConfigureHTTPL(); // setup http session & configure with connection parameters
+	LaunchHTTPTransactionL(); // launch a http transaction
+	}
+
+void CCmdWget::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg1, "url");
+	aArguments.AppendStringL(iUrl, KArg1);
+	}
+
+void CCmdWget::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptContinue, "continue");
+	aOptions.AppendBoolL(iContinue, KOptContinue);
+
+	_LIT(KOptDestinationFilename, "downloadfile");
+	aOptions.AppendFileNameL(iDestinationFilename, KOptDestinationFilename);
+
+	_LIT(KOptSourceFilename, "uploadfile");
+	aOptions.AppendFileNameL(iUploadFilename, KOptSourceFilename);
+
+	_LIT(KOptIapId, "iap");
+	aOptions.AppendIntL(iIapId, KOptIapId);
+
+	_LIT(KOptUsername, "username");
+	aOptions.AppendStringL(iUsername, KOptUsername);
+
+	_LIT(KOptPassword, "password");
+	aOptions.AppendStringL(iPassword, KOptPassword);
+	
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	}
+
+//
+// CCmdWget::PrepareDownloadFileL
+// determine the destination file & path and open a handle to a local file
+//
+void CCmdWget::PrepareDownloadFileL()
+	{
+	ASSERT(iUrl);
+	ASSERT(!iPostData);
+	TFileName fname;
+	RFs& fs = FsL(); 
+	fname.Zero();
+	if (iDestinationFilename.Length() <= 0)
+		{
+		// use current path
+		fname.Append(Env().Pwd());
+		
+		// use the same name as the file we're intending to download
+		TChar dirMarker('/');
+		TInt mark = iUrl->Des().LocateReverse(dirMarker);
+		if (mark <= 0)
+			{
+			User::Leave(KErrNotFound);
+			}
+		fname.Append(iUrl->Des().Mid(++mark)); // increment mark to step over the '/' 
+		}
+	else 
+		{
+		fname.Copy(iDestinationFilename); // user has specified a local file name
+		}
+	if (BaflUtils::FileExists(fs, fname))
+		{
+		if (iContinue)
+			{
+			// open the file & append any new data to what's already in there
+			User::LeaveIfError(iLocalFile.Open(fs, fname, EFileShareExclusive));
+			}
+		else
+			{
+			// open the file & replace old data with new data
+			User::LeaveIfError(iLocalFile.Replace(fs, fname, EFileShareExclusive));
+			}
+		}
+	else
+		{
+		// create the file for the first time
+		User::LeaveIfError(iLocalFile.Create(fs, fname, EFileShareExclusive));
+		}
+	}
+
+//
+// CCmdWget::PrepareUploadFileL
+// prep. the local file containing data for upload to the web server
+//
+void CCmdWget::PrepareUploadFileL()
+	{
+	ASSERT(iUrl);
+	ASSERT(iPostData);
+	
+	User::LeaveIfError(iLocalFile.Open(FsL(), iUploadFilename, EFileRead | EFileShareReadersOnly));
+		
+	
+	}
+
+//
+// CCmdWget::LaunchConnectionL
+// establish a connection to the network
+//
+void CCmdWget::LaunchConnectionL()
+	{
+	User::LeaveIfError(iSocketServ.Connect());
+	User::LeaveIfError(iConnection.Open(iSocketServ));
+	
+	TInt connError = KErrNone;	
+	TCommDbConnPref prefs;
+	if (iIapId > 0)
+		{
+		prefs.SetIapId(iIapId);
+		prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+		connError = iConnection.Start(prefs);
+		}
+	else
+		{
+		connError = iConnection.Start();
+		}
+	if (iVerbose && (connError != KErrNone))
+		{
+		PrintError(connError, _L("Unable to establish network connection"));
+		User::Leave(connError);
+		}	
+	}
+
+//
+// CCmdWget::ConfigureHTTPL
+//
+void CCmdWget::ConfigureHTTPL()
+	{
+	iSession.OpenL(KHttpProtocol);
+	iSessionIsOpen = ETrue;
+	iSession.SetSessionEventCallback(this);
+	RStringPool pool = iSession.StringPool();
+	RHTTPConnectionInfo conInf = iSession.ConnectionInfo();
+	conInf.SetPropertyL(pool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ.Handle()));
+	conInf.SetPropertyL(pool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(reinterpret_cast<TInt> (&iConnection)));
+	InstallAuthenticationL(iSession);
+	}
+
+//
+// CCmdWget::LaunchHTTPTransactionL
+// launches a new http transaction
+//
+void CCmdWget::LaunchHTTPTransactionL()
+	{
+	// create the transaction
+	TBuf8<KMaxName> url8;
+	url8.Copy(iUrl->Des());
+	TUriParser8 uri;
+	User::LeaveIfError(uri.Parse(url8));
+	RStringPool pool = iSession.StringPool();
+	RStringF method = pool.StringF(HTTP::EGET,RHTTPSession::GetTable());
+	if (iPostData)
+		{
+		method = pool.StringF(HTTP::EPOST,RHTTPSession::GetTable());
+		}
+	iTransaction = iSession.OpenTransactionL(uri, *this, method);
+	
+	// some transaction configuration is required for posting data
+	if (iPostData)
+		{
+		RHTTPRequest req = iTransaction.Request();
+		req.SetBody(*this); // ccmdwget to supply the data for posting
+		THTTPHdrVal length(OverallDataSize());
+		THTTPHdrVal type(pool.StringF(HTTP::ETextAny, RHTTPSession::GetTable()));
+		RHTTPHeaders hdr = req.GetHeaderCollection();
+		hdr.SetFieldL(pool.StringF(HTTP::EContentLength, RHTTPSession::GetTable()), length);
+		hdr.SetFieldL(pool.StringF(HTTP::EContentType, RHTTPSession::GetTable()), type);
+		}
+	
+	// launch it
+	iTransaction.SubmitL();	
+	}
+
+//
+// CCmdWget::GetCredentialsL
+// request from the underlying HTTP session to provide it with some authentication credentials (if present)
+//
+TBool CCmdWget::GetCredentialsL(const TUriC8& /*aURI*/, RString aRealm, RStringF /*aAuthenticationType*/, RString& aUsername, RString& aPassword)
+	{
+	TBool present = EFalse;
+	RStringPool pl = aRealm.Pool();
+	if (iUsername)
+		{
+		present = ETrue;
+		TBuf8<KMaxName> user;
+		user.Copy(iUsername->Des());
+		aUsername = pl.OpenStringL(user);
+		}
+	if (iPassword)
+		{
+		present = ETrue;
+		TBuf8<KMaxName> pwd;
+		pwd.Copy(iPassword->Des());
+		aPassword = pl.OpenStringL(pwd);
+		}
+	return present;
+	}
+	
+//
+// CCmdWget::MHFSessionRunL
+// handles any up-calls from the http session
+//
+void CCmdWget::MHFSessionRunL(const THTTPSessionEvent& aEvent)
+	{
+	switch (aEvent.iStatus)
+		{
+		case THTTPSessionEvent::EConnect:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Connect\r\n"));
+				}
+			}
+		break;
+		
+		case THTTPSessionEvent::EConnectedOK:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Connected OK\r\n"));
+				}
+			}
+		break;
+		
+		case THTTPSessionEvent::EDisconnect:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Disconnect\r\n"));
+				}
+			}
+		break;
+		
+		case THTTPSessionEvent::EConnectedWithReducedCapabilities:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Connected with reduced capabilities\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EDisconnected:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Disconnected\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EAuthenticatedOK:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Authenticated OK\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EAuthenticationFailure:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Authentication failure\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EConnectionTimedOut:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Connection timed out\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::ENotConnected:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Not connected\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EExceptionInfo:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Exception info\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::ERedirected:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Redirected\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EAlreadyConnecting:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Already connecting\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EAlreadyConnected:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Already connected\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EAlreadyDisconnecting:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Already disconnecting\r\n"));
+				}
+			
+			}
+		break;
+
+		case THTTPSessionEvent::EAlreadyDisconnected:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Already disconnected\r\n"));
+				}
+			
+			}
+		break;
+
+		default:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Session Event unrecgonised\r\n"));
+				}
+			}
+		break;
+		};
+	}
+
+//
+// CCmdWget::MHFSessionRunError
+// handles an error related up-calls 
+TInt CCmdWget::MHFSessionRunError(TInt aError, const THTTPSessionEvent& /*aEvent*/)
+	{
+	if (iVerbose)
+		{
+		PrintError(aError, _L("HTTP Session Error"));
+		}
+	return KErrNone;
+	}
+	
+//
+// CCmdWget::MHFRunL
+// handles any up-calls regarding a current transaction
+//
+void CCmdWget::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
+	{
+	if (aTransaction.Id() != iTransaction.Id())
+		{
+		if (iVerbose)
+			{
+			PrintError(KErrUnknown, _L("HTTP Transaction Id is invalid"));
+			}
+		User::Leave(KErrUnknown);
+		}
+	switch (aEvent.iStatus)
+		{
+		case THTTPEvent::EGotResponseHeaders:
+			{
+			if (iVerbose)
+				{
+				DumpRespHeadersL(aTransaction);
+				}
+			}
+		break;
+		
+		case THTTPEvent::EGotResponseBodyData:
+			{
+			RHTTPResponse response = aTransaction.Response();
+			if (iVerbose)
+				{
+				Printf(_L("HTTP <%d> received\r\n"), response.StatusCode());
+				}
+			switch (response.StatusCode())
+				{
+				// informational codes (1xx)
+				case HTTPStatus::EContinue:
+				case HTTPStatus::ESwitchingProtocols:
+				break;
+				
+				// successful codes (2xx)
+				case HTTPStatus::EOk:
+					{
+					MHTTPDataSupplier* body = aTransaction.Response().Body();
+					TPtrC8 data;
+					TBool last = body->GetNextDataPart(data);
+					if (!iPostData)
+						{
+						User::LeaveIfError(iLocalFile.Write(data));
+						if (last)
+							{
+							iLocalFile.Flush();
+							}
+						if (iVerbose)
+							{
+							Printf(_L("bytes: %d\r\n"), data.Length());
+							}
+						}
+					else
+						{
+						TBuf<512> woop;
+						woop.Copy(data);
+						Stdout().Write(woop);
+						}
+					body->ReleaseData();
+					}
+				break;
+				
+				case HTTPStatus::ECreated:
+				case HTTPStatus::EAccepted:
+				case HTTPStatus::ENonAuthoritativeInfo:
+				case HTTPStatus::ENoContent:
+				case HTTPStatus::EResetContent:
+				break;
+				
+				case HTTPStatus::EPartialContent:
+					{
+					// TODO - byte range support
+					}
+				break;
+				
+				// Redirection codes (3xx)
+				case HTTPStatus::EMultipleChoices:
+				case HTTPStatus::EMovedPermanently:
+				case HTTPStatus::EFound:
+				case HTTPStatus::ESeeOther:
+				case HTTPStatus::ENotModified:
+				case HTTPStatus::EUseProxy:
+				case HTTPStatus::EUnused:
+				case HTTPStatus::ETemporaryRedirect:
+					if (iVerbose)
+						{
+						Printf(_L("Redirecting\r\n"));
+						}
+					
+				break;
+				
+				// Client error codes (4xx)
+				case HTTPStatus::EBadRequest:
+				case HTTPStatus::EUnauthorized:
+				case HTTPStatus::EPaymentRequired:
+				case HTTPStatus::EForbidden:
+				case HTTPStatus::ENotFound:
+				case HTTPStatus::EMethodNotAllowed:
+				case HTTPStatus::ENotAcceptable:
+				case HTTPStatus::EProxyAuthenticationRequired:
+				case HTTPStatus::ERequestTimeout:
+				case HTTPStatus::EConflict:
+				case HTTPStatus::EGone:
+				case HTTPStatus::ELengthRequired:
+				case HTTPStatus::EPreconditionFailed:
+				case HTTPStatus::ERequestEntityTooLarge:
+				case HTTPStatus::ERequestURITooLong:
+				case HTTPStatus::EUnsupportedMediaType:
+				case HTTPStatus::ERequestedRangeNotSatisfiable:
+				case HTTPStatus::EExpectationFailed:
+					{
+					if (iVerbose)
+						{
+						PrintError(KErrGeneral, _L("HTTP client error"));
+						}
+					Complete(KErrGeneral);
+					}
+				break;
+				
+				// Server error codes (5xx)
+				case HTTPStatus::EInternalServerError:
+				case HTTPStatus::ENotImplemented:
+				case HTTPStatus::EBadGateway:
+				case HTTPStatus::EServiceUnavailable:
+				case HTTPStatus::EGatewayTimeout:
+				case HTTPStatus::EHTTPVersionNotSupported:
+					{
+					if (iVerbose)
+						{
+						PrintError(KErrGeneral, _L("HTTP Remote Server Error"));
+						}
+					Complete(KErrGeneral);
+					}
+				break;
+
+				default:
+					Complete(KErrGeneral);
+				break;
+				};
+			}
+		break;
+		
+		case THTTPEvent::EResponseComplete:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("HTTP Response complete.\r\n"));
+				}
+			}
+		break;
+		
+		case THTTPEvent::ESucceeded:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("Download transaction complete.\r\n"));
+				}
+			Complete(KErrNone);
+			}
+		break;
+		
+		case THTTPEvent::EFailed:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("Download transaction failed. Aborting\r\n"));
+				}
+			Complete(KErrGeneral);			
+			}
+		break;
+		
+		case THTTPEvent::ERedirectedPermanently:
+		case THTTPEvent::ERedirectedTemporarily:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("Redirecting\r\n"));
+				}
+			}
+		break;
+		
+		case THTTPEvent::ERedirectRequiresConfirmation:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("Redirect requires confirmation. Aborting\r\n"));
+				}
+			Complete(KErrAbort);
+			}
+		break;
+		
+		default:
+			{
+			if (iVerbose)
+				{
+				Printf(_L("Transaction result: <%d>\r\n"), aEvent.iStatus);
+				}
+			if (aEvent.iStatus < 0)
+				{
+				Complete(aEvent.iStatus);
+				}
+			}
+		break;
+		};
+	}
+	
+//
+// CCmdWget::MHFRunError
+// handles any error related up-calls from an underlying transaction in progress
+//
+TInt CCmdWget::MHFRunError(TInt aError, RHTTPTransaction /* aTransaction */, const THTTPEvent& /* aEvent */)
+	{
+	if (iVerbose)
+		{
+		PrintError(aError, _L("HTTP Transaction error"));
+		}
+	return KErrNone;
+	}
+	
+//
+// CCmdWget::DumpRespHeadersL
+// dump the transaction response headers
+//
+void CCmdWget::DumpRespHeadersL(RHTTPTransaction& aTransaction)
+	{
+	RHTTPResponse resp = aTransaction.Response();
+	RStringPool strP = aTransaction.Session().StringPool();
+	RHTTPHeaders hdr = resp.GetHeaderCollection();
+	THTTPHdrFieldIter it = hdr.Fields();
+
+	TBuf<KMaxHeaderNameLen>  fieldName16;
+	TBuf<KMaxHeaderValueLen> fieldVal16;
+
+	while (it.AtEnd() == EFalse)
+		{
+		RStringTokenF fieldName = it();
+		RStringF fieldNameStr = strP.StringF(fieldName);
+		THTTPHdrVal fieldVal;
+		if (hdr.GetField(fieldNameStr,0,fieldVal) == KErrNone)
+			{
+			const TDesC8& fieldNameDesC = fieldNameStr.DesC();
+			fieldName16.Copy(fieldNameDesC.Left(KMaxHeaderNameLen));
+			switch (fieldVal.Type())
+				{
+			case THTTPHdrVal::KTIntVal:
+				Printf(_L("%S: %d\r\n"), &fieldName16, fieldVal.Int());
+				break;
+			case THTTPHdrVal::KStrFVal:
+				{
+				RStringF fieldValStr = strP.StringF(fieldVal.StrF());
+				const TDesC8& fieldValDesC = fieldValStr.DesC();
+				fieldVal16.Copy(fieldValDesC.Left(KMaxHeaderValueLen));
+				Printf(_L("%S: %S\r\n"), &fieldName16, &fieldVal16);
+				}
+				break;
+			case THTTPHdrVal::KStrVal:
+				{
+				RString fieldValStr = strP.String(fieldVal.Str());
+				const TDesC8& fieldValDesC = fieldValStr.DesC();
+				fieldVal16.Copy(fieldValDesC.Left(KMaxHeaderValueLen));
+				Printf(_L("%S: %S\r\n"), &fieldName16, &fieldVal16);
+				}
+				break;
+			case THTTPHdrVal::KDateVal:
+				{
+				TDateTime date = fieldVal.DateTime();
+				TBuf<40> dateTimeString;
+				TTime t(date);
+				t.FormatL(dateTimeString,KDateFormat);
+				Printf(_L("%S: %S\r\n"), &fieldName16, &dateTimeString);
+				} 
+				break;
+			default:
+				Printf(_L("%S: <unrecognised value type>\r\n"), &fieldName16);
+				break;
+				};
+
+			// Display realm for WWW-Authenticate header
+			RStringF wwwAuth = strP.StringF(HTTP::EWWWAuthenticate,RHTTPSession::GetTable());
+			if (fieldNameStr == wwwAuth)
+				{
+				// check the auth scheme is 'basic'
+				RStringF basic = strP.StringF(HTTP::EBasic,RHTTPSession::GetTable());
+				RStringF realm = strP.StringF(HTTP::ERealm,RHTTPSession::GetTable());
+				THTTPHdrVal realmVal;
+				if ((fieldVal.StrF() == basic) && 
+					(!hdr.GetParam(wwwAuth, realm, realmVal)))
+					{
+					RStringF realmValStr = strP.StringF(realmVal.StrF());
+					fieldVal16.Copy(realmValStr.DesC());
+					Printf(_L("Realm is: %S\r\n"), &fieldVal16);
+					}
+				}
+			}
+		++it;
+		}	
+	}
+
+//
+// MHTTPDataSupplier methods
+//
+
+//
+// CCmdWget::GetNextDataPart
+// reads a chunk of data from the source file
+// 
+TBool CCmdWget::GetNextDataPart(TPtrC8& aDataPart)
+	{
+	ASSERT(iPostData);
+	ASSERT(iLocalFile.SubSessionHandle() > 0);
+		
+	TBool result = EFalse;
+	
+	// calc read length
+	TInt readlength = KDefaultChunkSize;
+	if ((iLocalFileSize - iLocalBytesRead) < readlength)
+		{
+		readlength = iLocalFileSize - iLocalBytesRead;
+		}
+	
+	// if necessary, return previous chunk (per the SDK's MHTTPDataSupplier documentation)
+	if (!iReleaseDataCalled && (iPrevData.Length() > 0))
+		{
+		iReleaseDataCalled = EFalse;
+		aDataPart.Set(iPrevData);
+		return result;
+		}
+	
+	// read another chunk of the data & pass it back
+	TInt error = iLocalFile.Read(iPrevData, readlength);
+	if (error != KErrNone)
+		{
+		if (iVerbose)
+			{
+			PrintError(error, _L("Unable to read data from local file."));
+			}
+		Complete(error);
+		return result;
+		}
+	aDataPart.Set(iPrevData);
+	iReleaseDataCalled = EFalse;
+	iLocalBytesRead += readlength;
+	if (iLocalBytesRead >= iLocalFileSize)
+		{
+		ASSERT((iLocalBytesRead == iLocalFileSize)); // else our math has gone wrong somewhere 
+		result = ETrue;
+		}
+	return result;
+	}
+
+//
+// CCmdWget::ReleaseData
+// tell the http transaction we have more data available
+//
+void CCmdWget::ReleaseData()
+	{
+	ASSERT(iPostData);
+	iReleaseDataCalled = ETrue;
+	if ((iLocalFileSize - iLocalBytesRead) > 0)
+		{
+		// more data to come
+		TRAPD(error, iTransaction.NotifyNewRequestBodyPartL());
+		if (error != KErrNone)
+			{
+			if (iVerbose)
+				{
+				PrintError(error, _L("Unable to release data."));
+				}
+			Complete(error);
+			}
+		}
+	}
+
+//
+// CCmdWget::OverallDataSize
+// return the total size of the data we're to upload to the server
+//
+TInt CCmdWget::OverallDataSize()
+	{
+	ASSERT(iPostData);
+	ASSERT(iLocalFile.SubSessionHandle() > 0);
+	return iLocalFileSize;
+	}
+
+//
+// CCmdWget::Reset
+// Reset the data supply to the beginning of the local file
+// 
+TInt CCmdWget::Reset()
+	{
+	ASSERT(iPostData);
+	ASSERT(iLocalFile.SubSessionHandle() > 0);
+	TInt pos = 0;
+	TInt error = iLocalFile.Seek(ESeekStart, pos); // not interested in pos
+	return error;
+	}
+
+
+EXE_BOILER_PLATE(CCmdWget)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/wget/wget.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,94 @@
+// wget.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __W_GET_H__
+#define __W_GET_H__
+
+#include <e32std.h>
+#include <es_sock.h>
+#include <rhttpsession.h>
+#include <mhttpsessioneventcallback.h>
+#include <mhttpauthenticationcallback.h>
+#include <mhttptransactioncallback.h>
+#include <mhttpdatasupplier.h>
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+const TUint32 KDefaultChunkSize = 0x200; // 512 Bytes
+
+//
+// CCmdWget
+// fshell command to retrieve a file from an HTTP Server on a network
+//
+class CCmdWget : public CCommandBase, public MHTTPSessionEventCallback, public MHTTPAuthenticationCallback, public MHTTPTransactionCallback, public MHTTPDataSupplier
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdWget();
+private:
+	CCmdWget();
+	void PrepareDownloadFileL();
+	void PrepareUploadFileL();
+	void DumpRespHeadersL(RHTTPTransaction& aTransaction);
+	void LaunchConnectionL();
+	void ConfigureHTTPL();
+	void LaunchHTTPTransactionL();
+	
+	// From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+
+	// From MHTTPSessionEventCallback
+	virtual void MHFSessionRunL(const THTTPSessionEvent& aEvent);
+	virtual TInt MHFSessionRunError(TInt aError, const THTTPSessionEvent& aEvent);
+	
+	// From MHTTPTransactionCallback
+	virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
+	virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
+
+	// From MHTTPAuthenticationCallback
+	virtual TBool GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword);
+	
+	// From MHTTPDataSupplier
+	virtual TBool GetNextDataPart(TPtrC8& aDataPart);
+	virtual void ReleaseData();
+	virtual TInt OverallDataSize();
+	virtual TInt Reset();
+private:
+	RHTTPSession iSession;
+	RHTTPTransaction iTransaction;
+	RHTTPRequest iRequest;
+	RSocketServ iSocketServ;
+	RConnection iConnection;
+	RFile iLocalFile;
+	TInt iLocalFileSize;
+	TInt iLocalBytesRead;
+	TBuf8<KDefaultChunkSize> iPrevData;
+	TBool iSessionIsOpen;
+	TBool iReleaseDataCalled;
+	
+	// user-specified arguments & options
+	TBool iContinue;
+	TBool iVerbose;
+	TBool iPostData;
+	HBufC* iUrl;
+	HBufC* iUsername;
+	HBufC* iPassword;
+	TFileName2 iDestinationFilename;
+	TFileName2 iUploadFilename;
+	TInt iIapId;
+	};
+
+#endif // __W_GET_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/wget/wget.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// wget.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			wget.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_WGET
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	\epoc32\include\ecom
+systeminclude	FSHELL_HTTP_SYSTEMINCLUDE
+
+sourcepath		.
+source			wget.cpp
+
+library			euser.lib
+library			iocli.lib
+library			http.lib
+library			esock.lib
+library			bafl.lib
+library			commdb.lib
+library			efsrv.lib
+library			ecom.lib
+library			inetprotutil.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/wslog/wslog.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,44 @@
+# wslog.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name wslog
+
+==short-description
+
+Enables or disables windowserver logging.
+
+==long-description
+
+If no options are specified, shows current status. To change what logging engine is actually used when the enable call is made, try w32crack.
+
+==argument enum operation optional
+
+Operation to perform; defaults to 'status' if not present.
+
+==enum-value status
+
+==enum-value enable
+
+==enum-value disable
+
+==enum-value message
+
+==enum-value treedump
+
+==argument string message optional
+
+A message to log. Valid only when the operation is 'message'.
+
+==copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/wslog/wslog.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,151 @@
+// wslog.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <bautils.h>
+#include <W32STD.H>
+#include <fshell/ltkutils.h>
+
+using namespace IoUtils;
+
+class CCmdWslog : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdWslog();
+private:
+	CCmdWslog();
+	void CmdL(const TDesC& aCommand, const TDesC& aArgs);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RWsSession iWs;
+	enum 
+		{
+		EStatus,
+		EEnable,
+		EDisable,
+		EMessage,
+		EDump,
+		} iOperation;
+	HBufC* iMessage;
+	};
+
+CCommandBase* CCmdWslog::NewLC()
+	{
+	CCmdWslog* self = new(ELeave) CCmdWslog();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdWslog::~CCmdWslog()
+	{
+	iWs.Close();
+	delete iMessage;
+	}
+
+CCmdWslog::CCmdWslog()
+	{
+	}
+
+const TDesC& CCmdWslog::Name() const
+	{
+	_LIT(KName, "wslog");
+	return KName;
+	}
+
+void CCmdWslog::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KOperation, "operation");
+	aArguments.AppendEnumL((TInt&)iOperation, KOperation);
+	_LIT(KMessage, "message");
+	aArguments.AppendStringL(iMessage, KMessage);
+	}
+
+void CCmdWslog::OptionsL(RCommandOptionList&)
+	{
+	}
+
+EXE_BOILER_PLATE(CCmdWslog)
+
+void CCmdWslog::DoRunL()
+	{
+	if (iMessage && iOperation != EMessage)
+		{
+		LeaveIfErr(KErrArgument, _L("Message can only be specified if operation is 'message'"));
+		}
+	
+	LeaveIfErr(iWs.Connect(FsL()), _L("Couldn't connect to wserv"));
+
+	switch (iOperation)
+		{
+		case EEnable:
+			iWs.LogCommand(RWsSession::ELoggingEnable);
+			break;
+		case EDisable:
+			iWs.LogCommand(RWsSession::ELoggingDisable);
+			break;
+		case EMessage:
+			{
+			if (!iMessage)
+				{
+				LeaveIfErr(KErrArgument, _L("A message must be provided for operation 'message'"));
+				}
+			TLogMessageText message = *iMessage;
+			iWs.LogMessage(message);
+			}
+			break;
+		case EStatus:
+			{
+			Printf(_L("LtkUtils::W32CrackIsEnabled reports: %d\r\n"), LtkUtils::W32CrackIsEnabled());
+
+			//_LIT(KWsIniFile, "z:\\system\\data\\wsini.ini");
+			_LIT(KCWsIniFile, "c:\\system\\data\\wsini.ini");
+
+			if (BaflUtils::FileExists(FsL(), KCWsIniFile))
+				{
+				Printf(_L("C drive wsini log lines:\r\n"));
+				CmdL(_L("fshell.exe"), _L("-e 'cat c:\\system\\data\\wsini.ini | grep LOG*'"));
+				}
+			else
+				{
+				Printf(_L("(No C drive wsini)\r\n"));
+				}
+			Printf(_L("Z drive wsini log lines:\r\n"));
+			CmdL(_L("fshell.exe"), _L("-e 'cat z:\\system\\data\\wsini.ini | grep LOG*'"));
+
+			Printf(_L("Possible logging DLLs (none means logging probably not enabled):\r\n"));
+			CmdL(_L("kerninfo.exe"), _L("codeseg -m DLOG*"));
+			}
+			break;
+		case EDump:
+			//__DEBUGGER();
+			iWs.LogCommand(RWsSession::ELoggingStatusDump);
+			break;
+		};
+	iWs.Flush();
+	}
+
+void CCmdWslog::CmdL(const TDesC& aCommand, const TDesC& aArgs)
+	{
+	RChildProcess proc;
+	TRequestStatus stat;
+	proc.CreateL(aCommand, aArgs, IoSession(), Stdin(), Stdout(), Stderr());
+	proc.Run(stat);
+
+	User::WaitForRequest(stat);
+	proc.Close();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commands/wslog/wslog.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// wslog.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          wslog.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_WSLOG
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          wslog.cpp
+
+library         euser.lib
+library         iocli.lib
+library         ws32.lib
+library         bafl.lib
+library         ltkutils.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/bg.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# bg.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name bg
+
+==short-description
+
+Run a job in the background.
+
+==long-description
+
+Note, only the foreground job receives data entered using the keyboard.
+
+==see-also
+
+L<fg|fg>, L<jobs|jobs>, L<disown|disown>
+
+==argument string job_spec optional
+
+The identifier of the job, as given by the C<jobs> command.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/cd.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# cd.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name cd
+
+==short-description
+
+Change the current working directory.
+
+==argument filename directory
+
+The directory to change to.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/chunkinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# chunkinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name chunkinfo
+
+==short-description
+
+Print information about memory chunks.
+
+==long-description
+
+If no arguments are given, lists the address and name of each DChunk object currently present in the kernel. The chunk list includes local and anonymous chunks. If a chunk address is specified, more detailed information about the specific chunk is printed. If the chunk appears to contain a heap (according to the criteria of C<LtkUtils::RAllocatorHelper>), then the detailed info includes heap statistics as well.
+
+==argument uint chunk_address optional
+
+The address of the C<DChunk> object to display information about. If not specified, lists a summary of all chunks. Note chunk addresses can be found either by running C<chunkinfo> with no arguments, or by using C<ps --chunks> (note though that L<ps|ps> only finds globally named chunks).
+
+==option uint r rate
+
+The rate (in milliseconds) at which to update the information.  If not specified (or specified as zero) the current information will be displayed and the tool will exit.
+
+==option bool H human
+
+Display sizes in human readable form.
+
+==option string o owning-process
+
+If specified, limits the chunk summary list to just those chunks belonging to the named process. Note, the process name may contain C<?> and C<*> wild characters. Note also that global chunks don't have an explicit owner. If you want to find all the chunks that were created by a particular process, then use C<--controlling-process> instead.
+
+==option uint c controlling-process
+
+If specified, limits the chunk summary list to just those chunks that were created by the specified process identifier. Note, this option will find global and local chunks that were created by the process.
+
+==option bool s size
+
+Include current chunk size in the chunk summary list.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/clear.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# clear.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name clear
+
+==short-description
+
+Clear the console screen.
+
+==long-description
+
+Note, fshell aliases this command to C<cls> also.
+
+==option bool f formfeed
+
+Instead of clearing the console completely, write a page's worth of newlines to the console.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/compare.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+# compare.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name compare
+
+==short-description
+
+Compare the contents of a pair of files.
+
+==long-description
+
+Completes with zero (C<KErrNone>) if they are are same, or a positive code if they are different.
+
+==argument filename file_name_1
+
+The name of the first file to compare.
+
+==argument filename file_name_2
+
+The name of the second file to compare.
+
+==option bool v verbose
+
+Display verbose information.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/console.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+# console.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name console
+
+==short-description
+
+Displays the name (and optionally other details) of the console implementation that L<fshell|fshell> is attached to.
+
+==long-description
+
+Note, fshell provides various console implementations. See the F<Consoles> section of the fshell's documentation for details.
+
+==see-also
+
+L<pcons|pcons>, L<ioinfo|ioinfo>
+
+==option bool v verbose
+
+Display verbose information.
+
+==option bool r remote
+
+Return zero if the console implementation is remotely hosted (i.e. F<rcons.dll> or one of the VT100 console variants), non-zero if it isn't.
+
+==option bool n null
+
+Return zero if the console implementation is F<nullcons.dll>.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/cp.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# cp.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name cp
+
+==short-description
+
+Copy one or more files or folders.
+
+==long-description
+
+If source is a directory and --recurse is used, destination is assumed to be a directory. If C<destination> exists, C<source> is copied into it, giving the directory structure C<destinationdir\sourcename\...>. This is in line with how posix cp behaves, but it is different to the default Symbian CFileMan behaviour, which would put the files in sourcedir directly into destinationdir without creating a directory called sourcename. In posix cp terms, CFileMan usually performs C<cp -r source\* destination\> instead of C<cp -r source destination>. If C<destination> does not exist, it is created, and posix cp and CFileMan behave the same in this case. It is considered preferable for fshell cp to behave the same as posix cp, rather than following CFileMan's behaviour.
+
+Because of the above behavioural ambiguity (and other strangenesses in CFileMan) it is not recommended to copy a directory without specifying the --recurse option.
+
+Note, also aliased to C<copy>.
+
+==argument filename source
+
+The name of the source file (may contain wild characters) or directory.
+
+==argument filename destination
+
+The name of the destination file or directory.
+
+==option bool r recurse
+
+Copy matching files in sub-directories. Creates any missing directories in the destination path.
+
+==option bool o overwrite
+
+Overwrite file at destination, if it exists.
+
+==option bool f force
+
+Forcibly copy, even if the file is in use. Note, this option can't be used with --recurse.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/date.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,83 @@
+# date.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name date
+
+==short-description
+
+Displays or sets the current time and date.
+
+==long-description
+
+Example usage:
+
+To get the current date and time:
+
+    c:\>date
+    07/04/2010 13:46:58.647500
+
+To check how a human readable date is parsed:
+
+    c:\>date --set --just-display "07/04/2010 13:47:00"
+    07/04/2010 13:47:00.000000
+
+To convert a raw TInt64 timestamp to a human-readable string:
+
+    c:\>date --raw-set 1234567890 --display-only
+    01/01/0000 00:20:34.567890
+
+To set the current local time:
+
+    c:\>date --set "07/04/2010 13:47:00"
+    c:\>
+
+To use a timestamp in a filename:
+
+    date --timestamp | export -s TIMESTAMP
+    do-something > C:\logs\myoutput-$TIMESTAMP.txt
+
+==option bool u universal
+
+Display or set universal time (UTC) rather than local time.
+
+==option string s set
+
+Sets the time and date. Format is that accepted by TTime::Parse(). For UK English localisations, C<DD/MM/YYYY HH:MM:SS> is one such acceptable format.
+
+==option int o utc-offset
+
+Sets the UTC offset in seconds. Must be used in conjunction with the C<--set> option.
+
+==option bool S secure
+
+Displays or sets the secure variant of the kernel's reckoning of time.
+
+==option bool r raw
+
+Displays the time and date as the number of microseconds since 2000AD (Symbian OS's native time format).
+
+==option bool j just-display
+
+Rather than going ahead and setting the specified time and date, do a dry run and just displays it in human readable form. Must be used in conjunction with C<--set>. In effect it is an option to check that the set string has been parsed correctly before actually making the change.
+
+==option int64 R raw-set
+
+Sets the time and date from a number corresponding to the number of microseconds since 2000AD (Symbian OS's native time format).
+
+==option bool t timestamp
+
+Display the date in timestamp format C<YYYYMMDD-HHMM.SS> suitable for use in a file name.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/debug.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,58 @@
+# debug.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name debug
+
+==short-description
+
+Run the specified fshell script under a simple debugger.
+
+==long-description
+
+Before executing each line of the script, commands can be entered. Currently the following commands are supported:
+
+=over 5
+
+=item C<s>
+
+Run the next line of the script.
+
+=item C<x>
+
+Show the next line of the script with its variables expanded.
+
+=back
+
+Unlike the L<source|source> command, environment variables set by the script being debugged are not inherited by the parent fshell instance.
+
+Note, this command is specifically for debugging L<fshell|fshell> scripts. If you were looking for a general-purpose debugger, see L<fdb|fdb>.
+
+==see-also
+
+L<fdb|fdb>, L<source|source>
+
+==argument filename script_file_name
+
+The name of the script file to be debugged.
+
+==argument string script_args optional last
+
+Arguments to be send to the script.
+
+==option bool k keep-going
+
+Keep processing the script even if a previous command has returned an error. Without this option set, an error would cause script processing to abort (and the debug command to exit with the error code) unless either C<&&>, C<||> or C<&|> was used to handle the error.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/debugport.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# debugport.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name debugport
+
+==short-description
+
+Sets the debug port. If the port is not specified, displays the current setting.
+
+==argument int port optional
+
+The debug port to set. The meaning of the number is platform-specific, but as a general rule: -2 means debug prints disabled entirely; Zero through n means uarts zero through n (where n is platform dependant); 42 means JTAG debug output (if supported by baseport).
+
+==option bool f force
+
+Forcibly set the debugport in the kernel superpage. This allows to change the debugport to (eg) zero on variants that incorrectly disallow it because they were copied and pasted from the sample variant code. It also bypasses any variant initialisation that might normally happen when changing the debugport, so isn't entirely safe. Requires memoryaccess to be available.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/dialog.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,64 @@
+# dialog.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name dialog
+
+==short-description
+
+Displays a UI dialog.
+
+==long-description
+
+Up to two buttons are supported. By default the first is labelled C<OK> and the second C<Cancel>. The button the user selected can be determined by the return code of the command. The first button will produce a return code of zero (0), and the second a code of one (1). If there was an error displaying the dialog, the error code will be returned (always a negative number). The return code makes it possible to write scripts like:
+
+  dialog --body 'Do you want to proceed?' && do_something
+
+This will result in F<do_something> only being executed if the user presses the first button. An error or the user pressing the second button with NOT result in F<do_something> being executed. Note though that the text window server's notifier implementation appears to assign the first button one (1) and the second, zero (0). Also, on the 3rd edition of S60 killing a dialog command while it is running will result in the handset resetting itself when the actual dialog is dismissed.
+
+The environment variable C<DIALOG_IMPL> can be used to control the way in which the user is interacted with. The following values of C<DIALOG_IMPL> are supported:
+
+=over 5
+
+=item C<notifier>
+
+The C<RNotifier> API will be used. This is the default if C<DIALOG_IMPL> is not defined The behaviour of C<RNotifier> depends on the handset configuration, but normally it will result in graphical dialogs being displayed.
+
+=item C<console>
+
+The user will be interacted with via the console that the dialog command is connected to. In this mode, pressing the enter (or on some platforms, select) key corresponds to pressing the first button and any other corresponds to pressing the second button.
+
+=item C<null>
+
+No attempt is made to interact with the user and it is assumed that the first button is always pressed. This mode allows all user interaction to be disabled.
+
+=back
+
+==argument string body optional
+
+The body of the dialog. If not specified, the body is read from C<stdin>.
+
+==option string t title
+
+The title of the dialog.
+
+==option string f first-button
+
+The text for the first button.
+
+==option string s second-button
+
+The text for the first button.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/disown.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# disown.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name disown
+
+==short-description
+
+Disown a pending L<fshell|fshell> job.
+
+==long-description
+
+Ordinarily L<fshell|fshell> observes the completion of any job (or command) that it creates. This command causes fshell to forget about a particular job. Note, it is only possible to disown jobs that comprise entirely of external process commands. Any attempt to disown a job that contains built in fshell commands will fail with C<KErrPermissionDenied>.
+
+==see-also
+
+L<jobs|jobs>, L<reattach|reattach>, L<start|start>
+
+==argument string job_spec
+
+The identifier of the job the be disowned. Note, job identifiers are listed by the L<jobs|jobs> command.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/driver.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# driver.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name driver
+
+==short-description
+
+Loads, frees or list currently loaded device drivers.
+
+==argument enum operation
+
+The required operation.
+
+==enum-value load
+
+Load the specified driver.
+
+==enum-value free
+
+Free (or unload) the specified driver. Note, has no effect if the driver is still in use.
+
+==enum-value list
+
+Lists the currently loads drivers of the specified type.
+
+==argument enum type
+
+The driver type.
+
+==enum-value logical
+
+==enum-value physical
+
+==argument string name optional
+
+The driver name, e.g. C<ECOMM>. Need not be specified for the C<list> operation.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/dump.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# dump.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name dump
+
+==short-description
+
+Write a hex and ASCII representation of the contents of a file to C<stdout>.
+
+==argument filename file_name optional multiple
+
+The name of the file to dump. If not specified, C<stdin> is dumped.
+
+==option bool B binary
+
+Read from C<stdin> in binary mode. This prevents the console from intercepting escape sequences.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/e32header.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+# e32header.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name e32header
+
+==short-description
+
+Dumps the contents of an E32 image file's header in human readable plain text.
+
+==long-description
+
+Note, a different header is present in XIP ROM files compared to other file systems. By default the header type is determined according to the type of file system the image file resides in (using C<RFs::IsFileInRom>). It is possible to override this behaviour using the C<--xip> option.
+
+==argument filename file_name
+
+The name of the image file.
+
+==option bool x xip
+
+Assume the image file has a ROM header even if it does not reside in an XIP ROM.
+
+==option bool n not-xip
+
+Assume the image file does not have a ROM header even if resides in an XIP ROM.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/echo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,104 @@
+# echo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name echo
+
+==short-description
+
+Print a text string to C<stdout>. If no text is specified as an argument, reads from C<stdin> and writes the result to C<stdout>.
+
+==long-description
+
+Note, this command used to interpret escape sequences such as C<^r> and C<^t> itself. This functionality has now been moved into C<CCommandBase> so all fshell commands can benefit from it. A consequence of this change is that it is no longer necessary to double escape such sequences.
+
+==argument string string optional last
+
+The text to be printed.
+
+==option bool e stderr
+
+Print to C<stderr> rather than C<stdout>.
+
+==option bool w wrap
+
+Wraps the text to the screen width, ensuring that words do not get split across lines.
+
+==option uint i indent
+
+The number of characters to indent the text by. Only has an effect when used with C<--wrap>.
+
+==option enum a attributes multiple
+
+The attributes to assign to the text written to the console.
+
+==enum-value bold
+
+==enum-value underscore
+
+==enum-value blink
+
+==enum-value inverse
+
+==enum-value conceal
+
+==option enum f foreground-color
+
+The color the font glyphs are to be drawn in.
+
+==enum-value black
+
+==enum-value red
+
+==enum-value green
+
+==enum-value yellow
+
+==enum-value blue
+
+==enum-value magenta
+
+==enum-value cyan
+
+==enum-value white
+
+==option enum b background-color
+
+The color the rectangle behind the font glyphs is to be drawn in.
+
+==enum-value black
+
+==enum-value red
+
+==enum-value green
+
+==enum-value yellow
+
+==enum-value blue
+
+==enum-value magenta
+
+==enum-value cyan
+
+==enum-value white
+
+==option bool B binary
+
+Write to the console in I<binary mode>. Note, not all consoles support the notion of I<binary mode>. If not, KErrNotSupported (-5) will be returned. In practice, currently only the VT100 console variants support this.
+
+==option bool n no-newline
+
+By default echo will append a new line (C<CRLF>) on to the end of the C<string> argument, if it doesn't already have one. Use C<--no-newline> to prevent this.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/env.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+# env.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name env
+
+==short-description
+
+Display the current values of all environment variables.
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/error.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+# error.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name error
+
+==short-description
+
+Exits with the given error. Useful in scripts.
+
+==long-description
+
+This command exits with the given error and optionally prints the specified text to stderr. This is useful to abort scripts, for example as a precondition check:
+
+	# Some setup...
+	var SOMEVARIABLE not-defined && error -6 "The variable SOMEVARIABLE must be defined before you run this script"
+	
+	# Rest of script...
+
+==argument int error-number optional
+
+The error code to exit with. Must be negative. If not specified, defaults to C<KErrAbort> (-39).
+
+==argument string text optional
+
+If specified, prints the given text to stderr before exiting.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/exists.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# exists.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name exists
+
+==short-description
+
+Tests if a particular file or directory exists.
+
+==long-description
+
+Returns KErrNone if it does, or either KErrNotFound or KErrPathNotFound otherwise. Intended to be used in conjunction with fshell's C<&&> and C<||> operators.
+
+==argument filename file_name
+
+The name of the file or directory of interest.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/exit.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+# exit.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name exit
+
+==short-description
+
+Shutdown fshell.
+
+==long-description
+
+Note, this causes fshell's command history to be persisted to a file.
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/export.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# export.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name export
+
+==short-description
+
+Define a new environment variable or change the value of an existing one.
+
+==argument string variable
+
+The name of the environment variable.
+
+==argument string value optional
+
+The new value of the variable. If not specified, the variable with be undefined.
+
+==option bool s stdin
+
+Read the value from C<stdin>. May not be used in conjunction with a value argument.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/fg.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# fg.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fg
+
+==short-description
+
+Bring a background job into the foreground.
+
+==long-description
+
+Note, only the foreground job receives data entered using the keyboard.
+
+==see-also
+
+L<bg|bg>, L<jobs|jobs>, L<disown|disown>
+
+==argument string job_spec optional
+
+The identifier of the job, as given by the C<jobs> command.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/foreach.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+# foreach.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==argument filename directory_name
+
+The name of the directory to iterate through.
+
+==include source.cif
+
+==name foreach
+
+==short-description
+
+Execute a script for each file in a specified directory.
+
+==long-description
+
+This command is similar to L<source|source>, but executes the specified script once for every entry (file or directory) that is found in the specified directory. The first argument passed to the script is the full path name of the entry. If any C<script_args> were specified, these are passed to the script as the second and third arguments, etc.
+
+Note, as with L<source|source>, this command executes in the context of the L<fshell|fshell> instance that executed it. Any changes to environment variables will be written to the L<fshell|fshell> environment when it completes.
+
+==see-also
+
+L<source|source>
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/fsck.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# fsck.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fsck
+
+==short-description
+
+Checks the integrity of a file system.
+
+==argument string drive_letter
+
+The driver letter of the file system to be checked specified (e.g. C<fsck c:>).
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/fshell.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,405 @@
+# fshell.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fshell
+
+==short-description
+
+A UNIX-like shell for Symbian OS.
+
+==long-description
+
+=head2 Introduction
+
+F<fshell> is a console based executable for Symbian OS that behaves somewhat like typical UNIX shells (e.g. Bash, http://www.gnu.org/software/bash/ ). It can be used via a remote console implementation on hardware that doesn't have a full keyboard, giving an experience similar to telnet. F<fshell> contains a set of built-in commands and is also able to launch arbitrary Symbian OS executables. This document describes how to install F<fshell>, how to use its built-in commands and how to use the set of external commands that are also provided.
+
+=head2 Getting Started
+
+See L<Getting Started|getting_started> for a description of how to get console based tools like F<fshell> up and running on the platform you are using. Alternatively, if you would like to configure things yourself, see L<Console Options|console_options> for a description of the technology that's available for hosting consoles.
+
+F<fshell> is more like a UNIX shell than a DOS one, so it supports commands like C<cd Z:\>, C<ls>, C<mkdir> and C<rm>. It does also support the DOS-style equivalents C<z:> C<dir>, C<md>, and C<del> via internal fshell aliases. However, you still can't execute eshell *.bat files directly, although you can launch eshell from within fshell by typing 'eshell' so it is possible to run them indirectly if you need to. In practice, many simple bat files can run as fshell scripts due to fshell providing broadly-compatible commands.
+
+=head2 General fshell Functionality
+
+=over 5
+
+=item * Tab Completion
+
+At any point through entering a command, pressing the C<tab> key will cause F<fshell> to attempt to complete the part of the line currently being entered. Completion is performed on command names, directory and file names, and environment variables. If a command has been typed, and that command uses a L<CIF file|cif_syntax>, completion will additionally be performed on option names. Where the completion choice is ambiguous, a list of choices will be displayed above the line being edited. DOS-style F8 line completion is also supported, this looks in the command history for the first command that matches what has been typed so far. Pressing F8 repeatedly cycles through all the matching commands. For VT100 compatibility (F8 technically only became supported in VT220) F4 has the same effect.
+
+For example:
+
+  Input:   c:\>under<TAB>
+  Outputs: c:\>undertaker
+
+  Input:   c:\>kill --<TAB>
+  Outputs: c:\>kill --
+           --reason  --terminate --panic --thread --match --all
+
+  Input:   c:\>ls $P<TAB>
+  Outputs: c:\>ls $PWD
+
+=item * Command History
+
+The 'up arrow' and 'down arrow' keys can be used to review previously entered commands. The commands entered in a particular session are persisted to disk when fshell is idle or when it is exited.
+
+=item * Standard Input / Output
+
+F<fshell> supports the notion of standard input / ouput. Each command has access to the following IO handles:
+
+=over 5
+
+=item * STDIN
+
+By default, keyboard input.
+
+=item * STDOUT
+
+By default, the console screen.
+
+=item * STDERR
+
+By default, the console screen.
+
+=back
+
+=item * Console Sharing
+
+F<fshell> arranges for all commands (including external ones run in separate processes) to share its console. This may not seem like a big deal as it's the behaviour you'd expect from using UNIX or DOS, but Symbian OS's default console implementation (F<econs.dll>) and shell implementation (F<eshell.exe>) run external commands in a separate console windows, making it difficult to see any output they may produce because their windows disappear when the command finishes.
+
+With the right configuration tweaks, fshell is capable of 'hooking up' existing CConsoleBase-based command line tools to share fshell's console. In other words fshell can transparently support running legacy command line tools as if they were native fshell tools. The same support is available for PIPS-based tools.
+
+=item * Pipelines
+
+The output of one command to be sent as input to another command. For example:
+
+  cat text.txt | match *hello*
+
+This command-line causes the C<cat> command to print the contents of the file C<text.txt>. This output is directed into the L<match|match> command, which filters out any lines that don't contain the text C<hello>.
+
+=item * Redirection
+
+The output of commands can be redirected to files. For example:
+
+  ls > ls.txt
+
+This causes the output of a directory listing (produced by the C<ls> command) to be redirected to the file C<ls.txt> in the current directory, replacing its current contents. The following command...
+
+  ls >> ls.txt
+
+...causes the directory listing to be appended to the current contents of F<ls.txt>.
+
+So far, all the examples have shown how C<STDOUT> can be redirected. It is however also possible to redirect C<STDERR>. For example...
+
+  ls 2> stderr.txt > stdout.txt
+
+...redirects C<STDERR> to the file F<stderr.txt> and C<STDOUT> to the file F<stdout.txt>. It is also possible to redirect C<STDERR> to C<STDOUT> (and vice versa), for example:
+
+  ls 2>&1 > stderr_and_stdout.txt
+
+Lastly, it is also possible to redirect C<STDIN> to be read from a file rather than from the keyboard. For example...
+
+  match *hello* < text.txt
+
+...is equivalent to the first example but avoids using the C<cat> command.
+
+=item * Job Control
+
+Each command line is treated as a separate job within F<fshell>. Ordinarily, when F<fshell> is executing a job, any characters you enter using the keyboard are directed to the job. The presence of a 'C<&>' character at the end a of command line causes it to be run in the background. While such a job is running, F<fshell> will allow you to create and run other command lines. Whilst a job is running in the background, it will not receive any keyboard input.
+
+The following key combinations are intercepted by F<fshell>:
+
+=over 5
+
+=item * Ctrl-C
+
+Causes the foreground job to be terminated.
+
+=item * Ctrl-Z
+
+Causes the foreground job to be stopped (in the case of pre-platform security versions of Symbian OS) or sent to the background whilst still running (in the case of platform security versions of Symbian OS).
+
+=back
+
+See also the commands L<fg|fg>, L<bg|bg> and L<jobs|jobs>.
+
+=item * Conditional Execution
+
+Commands can conditionally execute using the logical 'and' operator C<&&>, the logical 'or' operator C<||> or the (somewhat strange) 'andor' operator C<&|>. For example...
+
+  command_1 && command_2
+
+...C<command_2> is only run if C<command_1> ran successfully (i.e. returned KErrNone). Or...
+
+  command_1 || command_2
+
+...C<command_2> is only run if C<command_1> did not run sucessfully (i.e. returned something other than KErrNone).
+
+The 'andor' operator is effectively an alternative for proper block support. It allows a script to contain conditional elements and then execute a block of commands regardless of whether previous ones have returned an error. This might sound like a strange thing to want to do, but it can be useful. For example...
+
+  exist some_dir || do_something &| do_something_else
+
+In this example, "do_something" is only executed if "some_dir" does not already exist. However, if "do_something" is run, then "do_something_else" is also guaranteed to also run.
+
+=item * Environment variables
+
+Environment variables can be defined (and undefined) using the L<export|export> command. Once defined, variables can be used in fshell command lines (or scripts) by prefixing them with a C<$> sign as follows:
+
+  c:\>export MYVAL 'some value'
+  c:\>echo $MYVAL
+  some value
+
+Fshell defines some variables at all times. C<PWD> is set to the current directory, and C<?> is set to the return code of the last command that ran. For example:
+
+  c:\somewhere\>echo "Current dir is: $PWD"
+  Current dir is: c:\somewhere\
+  c:\somewhere\>error -3
+  Error: Command "error" failed : KErrCancel (-3)
+  c:\somewhere\>echo "Last command returned $?"
+  Last command returned -3
+
+See the section on scripting for some further uses of environment variables. 
+
+=item * Escaping and Quoting
+
+F<fshell> treats the value of the variable C<ESCAPE> (which defaults to C<^>) as the beginning of an escape sequence. One or more characters following an escape are ignored by F<fshell's> usual string processing. The DOS-style '^' escape is used in preference for the more usual unix '\', because backslash is used as the path separator, and being forced to write C<cat C:\\dir\\file.txt> is considered more inconvenient. It is not recommended to change the escape character, particularly not to '\'.
+
+For example, to get list the contents of a directory whose name contains a space character:
+
+  c:\>ls test^ dir
+  test.txt
+
+The following escape sequences have special meanings:
+
+  ^a          (bell)
+  ^b          (back space)
+  ^f          (form feed)
+  ^n          (new line)
+  ^r          (carriage return)
+  ^t          (horizontal tab)
+  ^v          (vertical tab)
+  ^xnn        (numeric escape where 'n' is a hex digit)
+  ^Xnn        (same as ^x)
+  ^unnnn      (numeric escape for a UTF-16 character, where nnnn is a sequence of 4 hex digits)
+  ^Unnnnnnnn  (same as ^u but for a UTF-32 character)
+  ^^          (to represent the escape character itself.
+               if $ESCAPE was a backslash, the sequence would be \\ etc.)
+
+For example:
+
+  c:\>echo hello^r^x0aworld
+  hello
+  world
+
+Note, the hex value 0x0a corresponds to a new line character, which could have been represented by C<^n>.
+
+F<fshell> also supports use of single and double quotes around strings. With single quotes environment variables are not expanded and the only supported escape sequence is C<^'> to produce a literal single quote character. With double quotes, environment variables B<are> expanded and all the above escape sequences are supported. For example:
+
+  c:\>export TEST "hello world"
+  c:\>echo '^'$TEST^' will not be expanded'
+  '$TEST' will not be expanded
+  c:\>echo "TEST contains:^r^n$TEST"
+  TEST contains:
+  hello world
+
+=item * PIPS Integration
+
+If F<fshell> detects that it is launching a PIPS based executable (because it has a UID2 of 0x20004c45, the UID used by the makmake target C<stdexe>), it takes steps to ensure that F<fshell's> native implementations of pipes and environment variables are mapped onto those provided by PIPS. This is done using a helper executable named F<pipsrun.exe> that is responsible for providing the necessary translations. The end result is that the executables that use PIPS can share F<fshell's> console, take part in pipelines and also inherit environment variables.
+
+=back
+
+=head2 Commands
+
+All commands support the C<-h> (or C<--help>) option, which causes them to display text describing what they do and the syntax they support.
+
+A list of all the supported commands is available L<here|commands>.
+
+=head2 Scripting Support
+
+F<fshell> supports simple scripting to allow more than one command to be run in succession. Scripts can be invoked in two ways:
+
+=over 5
+
+=item *
+
+By running fshell with the script file name as an argument. If a path isn't given, the location F<\system\console\scripts> is searched on all drives if the script isn't found in the current working directory. For example:
+
+  c:\>fshell myscript.script # checks for c:\myscript.script and ?:\system\console\scripts\myscript.script
+  c:\>fshell e:\scripts\something # tries to run e:\scripts\something
+  c:\>fshell myscript # checks for c:\myscript, ?:\system\console\scripts\myscript and finally ?:\system\console\scripts\myscript.script
+
+=item *
+
+By 'executing' the script file itself (this is normally done by selecting the file in the handset's file manager). To support this F<fshell> provides a recognizer plug-in that recognizes files that begin with 'C<#!fshell>'. For example:
+
+  #!fshell
+  echo 'An example script'
+
+Note, the text following 'C<#!>' doesn't need to be 'C<fshell>' - the recognizer will attempt to launch any executable you care to name, providing the script file name in its command line.
+
+=back
+
+Scripts may contain any number of valid F<fshell> command lines. Separate script files may be run in the context of a single F<fshell> instance by using the L<source|source> command. Note, when F<fshell> runs a script, it defines the following environment variables within itself before doing so:
+
+=over 5
+
+=item * C<SCRIPT_PATH>
+
+Contains the absolute path (with trailing slash) to the directory that contains the script being executed. This may be used by the script to, for example, load other source files (using L<source|source>) that exist in the same directory as itself.
+
+=item * C<SCRIPT_NAME>
+
+Contains the name of the script file being executed.
+
+=item * C<SCRIPT_LINE>
+
+Contains the line number of the script that is currently being executed.
+
+=item * C<$0> ("dollar zero")
+
+The absolute path of the script. Equivalent to C<$SCRIPT_PATH$SCRIPT_NAME>.
+
+=item * C<$1, $2, etc>
+
+If any command line arguments to the script were specified, they are set in the environment. The first argument goes in $1, the second (if present) in $2 etc. For example, a script called envtest.script that just consisted of a call to C<env> would print out something like:
+
+  c:\>fshell envtest.script AnArgument "Another argument" Something Else
+  0=c:\envtest.script
+  1=AnArgument
+  2=Another argument
+  3=Something
+  4=Else
+  ?=0
+  ARG_COUNT=4
+  PWD=c:\
+  SCRIPT_LINE=1
+  SCRIPT_NAME=envtest.script
+  SCRIPT_PATH=c:\
+
+=item * C<ARG_COUNT>
+
+The number of arguments to the script. If $ARG_COUNT is 2, there are 2 arguments (in addition to $0), which are named $1 and $2.
+
+=back
+
+=head2 Global Command Line Options
+
+All commands, including fshell itself, have the following common set of command line options which control where/how the command runs. These global options are not generally listed when you run C<command --help>. There are no short alternatives for these options.
+
+=over 5
+
+=item * --console <console_implementation>
+
+This allows the console implementation F<.dll> to be overridden. Ordinarily, commands share the console of the F<fshell> instance that launched them. By explicitly specifying a console implementation, a different kind of console may be used to that of the parent F<fshell> instance. Another use of this option is to force the console provider to create a new console window for the command to run in. Note however that not all console implementations support multiple windows. See the L<consoles documentation|consoles> for more information.
+
+=item * --console-title <text>
+
+Only has an effect when used in conjunction with C<--console>. Allows the title of the overridden console window to be specified. Some consoles use this parameter to pass in additional configuration options.
+
+=item * --console-size <width>, <height>
+
+Only has an effect when used in conjunction with C<--console>. Allows the character width and height of the overridden console window to be specified. Note, some console implementations impose restrictions on the minimum and maximum size of their console windows. Generally this option isn't needed any more because in most configurations fshell or the console is capable of auto-detecting the size.
+
+=item * --persistent-console <name>
+
+Creates a new L<persistent console|persistent_consoles> to be used as the console for the command. Cannot be used in conjunction with C<--console>.
+
+=back
+
+=head2 Advanced command-line syntax
+
+Short options may be run together in one block, the only restriction being that only the last option in the block may take an argument. For example the following are equivalent:
+
+    kill --all --thread --match *undertaker
+    kill -a -T -m *undertaker
+    kill -aTm *undertaker
+
+Commands that have options that can be specified multiple times can be called in a number of different ways, partly depending on the type of the option. In the most basic case, you can specify the long or the short option repeatedly:
+
+    echo --attributes bold --attributes underscore "hello!"
+    echo -a bold -a underscore "hello!"
+
+For integer options, you can use the above or you can use commas. All of the below are valid fshell syntax and mean exactly the same:
+
+    btrace --filter 1 --filter 3
+    btrace --filter 1,3
+    btrace -f 1,3
+    btrace -f1,3
+
+For boolean options, you can additionally specify the short option multiple times in the same block. All of the below mean the same:
+
+    fcontacts -v -v list
+    fcontacts --verbose -v list
+    fcontacts -vv list
+
+For most commands, it doesn't matter where you put the options - they can go before, after or mixed in with the arguments. The following are all equivalent:
+
+    cat --binary file1 file2
+    cat -b file1 file2
+    cat file1 file2 -b
+    cat file1 -b file2
+
+The only exception to this is commands that are designed to take other command-lines as their arguments. These will not parse options themselves if they appear as part of the arguments. For example the C<repeat> command will not parse C<-k> if it appears during the C<command> argument, even though C<-k> is a valid option for L<repeat|fshell::commands::repeat>. Therefore:
+
+    repeat -k 3 ps
+
+is different to:
+
+    repeat 3 ps -k
+
+The former means "repeat C<ps> three times, and specify the C<-k> repeat option". The latter means "repeat C<ps -k> three times". Commands that parse in this way can be identified by the phrase "Any further arguments or options will be coalesced into this one." which appears in their documentation. They are specifed in CIF files using the C<last> keyword. The precise rule for how C<last> behaves can be stated as: If the command line following the C<last> argument would need quoting or escaping to make it a single string argument, the string is taken literally as-is. Otherwise, the normal expansions take place:
+
+    c:\>echo This^ gets^ expanded^ as^ expected
+    This gets expanded as expected
+    c:\>echo "Quoting the entire argument works as normal as well"
+    Quoting the entire argument works as normal as well
+
+But a command line that has unescaped spaces or quotes will cause the entire thing to be taken literally:
+
+    c:\>echo This is taken as one string even though it has spaces and 'unbalanced quotes"
+    This is taken as one string even though it has spaces and 'unbalanced quotes"
+    c:\>echo Note how escapes like ^r^n aren't expanded
+    Note how escapes like ^r^n aren't expanded
+    c:\>echo "But if it's all in quotes, escapes like ^r^n are expanded"
+    But if it's all in quotes, escapes like 
+     are expanded
+
+Environment variables are always expanded unless the entire argument is enclosed in 'single quotes'.
+
+==see-also
+
+L<fshell commands|commands>
+
+L<consoles|consoles>
+
+L<CIF file syntax|cif_syntax>
+
+==argument filename script_name optional
+
+The name of a script file to be executed. If a path isn't specified, and C<script_name> is not a file in the current working directory, the directory F<\system\console\scripts> is searched on all drives.
+
+==argument string script_args optional last
+
+Arguments to be send to the script.
+
+==option string e exec
+
+Execute the specified one line script.
+
+==option bool k keep-going
+
+When running in script mode, keep processing the script even if a previous command has returned an error. Without this option set, an error would cause the processing to abort (and fshell to exit with the error code) unless either C<&&>, C<||> or C<&|> was used to handle the error. For the convenience of scripts that may wish to pass on the flag to sub-instances of fshell, if this flag is specified the environment variable C<KEEP_GOING> is defined.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/fuser.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# fuser.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name fuser
+
+==short-description
+
+Lists the threads that are currently holding handles to a particular file.
+
+==argument filename file_name optional multiple
+
+The names of the files for which users should be found. If not specified, all open files will be listed.
+
+==copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/fuser.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,146 @@
+// fuser.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "fuser.h"
+#include <f32file.h>
+
+
+CCommandBase* CCmdFileUser::NewLC()
+	{
+	CCmdFileUser* self = new(ELeave) CCmdFileUser();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdFileUser::~CCmdFileUser()
+	{
+	iFiles.Close();
+	}
+
+CCmdFileUser::CCmdFileUser()
+	{
+	}
+
+const TDesC& CCmdFileUser::Name() const
+	{
+	_LIT(KName, "fuser");
+	return KName;
+	}
+
+void CCmdFileUser::DoRunL()
+	{
+	const TInt numFiles = iFiles.Count();
+	if (numFiles == 0)
+		{
+		PrintAllUsersL();
+		}
+	else
+		{
+		for (TInt i = 0; i < numFiles; ++i)
+			{
+			PrintUsersL(iFiles[i]);
+			}
+		}
+	}
+
+void CCmdFileUser::PrintAllUsersL()
+	{
+	TOpenFileScan openFileScanner(FsL());
+	CFileList* fileList = NULL;
+	FOREVER
+		{
+		openFileScanner.NextL(fileList);
+		if (fileList == NULL)
+			{
+			break;
+			}
+		CleanupStack::PushL(fileList);
+		const TInt numOpenFiles = fileList->Count();
+		for (TInt i = 0; i < numOpenFiles; ++i)
+			{
+			const TEntry& entry = (*fileList)[i];
+			Printf(_L("%S: \r\n"), &entry.iName);
+			TThreadId threadId(openFileScanner.ThreadId());
+			RThread thread;
+			TInt err = thread.Open(threadId);
+			if (err)
+				{
+				Printf(_L("\tError %d opening thread id %u\r\n"), err, (TUint)threadId);
+				}
+			else
+				{
+				TFullName name(thread.FullName());
+				thread.Close();
+				Printf(_L("\t%S (%u)\r\n"), &name, (TUint)threadId);
+				}
+			}
+		CleanupStack::PopAndDestroy(fileList);
+		}
+	}
+
+void CCmdFileUser::PrintUsersL(const TDesC& aFileName)
+	{
+	Printf(_L("%S: \r\n"), &aFileName);
+	TOpenFileScan openFileScanner(FsL());
+	CFileList* fileList = NULL;
+	TBool userFound(EFalse);
+	FOREVER
+		{
+		openFileScanner.NextL(fileList);
+		if (fileList == NULL)
+			{
+			break;
+			}
+		CleanupStack::PushL(fileList);
+		const TInt numOpenFiles = fileList->Count();
+		for (TInt i = 0; i < numOpenFiles; ++i)
+			{
+			const TEntry& entry = (*fileList)[i];
+			if (entry.iName.MatchF(aFileName.Mid(2)) != KErrNotFound) // Note entry.iName doesn't have a drive letter, hence the Mid(2).
+				{
+				userFound = ETrue;
+				TThreadId threadId(openFileScanner.ThreadId());
+				RThread thread;
+				TInt err = thread.Open(threadId);
+				if (err)
+					{
+					Printf(_L("\tError %d opening thread id %u\r\n"), err, (TUint)threadId);
+					}
+				else
+					{
+					TFullName name(thread.FullName());
+					thread.Close();
+					Printf(_L("\t%S (%u)\r\n"), &name, (TUint)threadId);
+					}
+				break;
+				}
+			}
+		CleanupStack::PopAndDestroy(fileList);
+		}
+
+	if (!userFound)
+		{
+		Write(_L("\tNo users"));
+		}
+	}
+
+void CCmdFileUser::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFiles, "file_name");
+	aArguments.AppendFileNameL(iFiles, KArgFiles);
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdFileUser)
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/fuser.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// fuser.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdFileUser : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdFileUser();
+private:
+	CCmdFileUser();
+	void PrintAllUsersL();
+	void PrintUsersL(const TDesC& aFileName);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	RArray<TFileName2> iFiles;
+	};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/gobble.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+# gobble.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name gobble
+
+==short-description
+
+A tool for purposefully wasting persistent storage space.
+
+==long-description
+
+If the specified file does not already exist, it will be created. If it does exist, it will be grown.
+
+==see-also
+
+L<leak|leak>
+
+==option bool v verbose
+
+Display more detailed output.
+
+==argument filename file_name
+
+The file to create or to append to.
+
+==argument uint amount
+
+The total number of bytes to consume.
+
+==argument uint block_size optional
+
+The maximum size of each write (in bytes). Defaults to 512.
+
+==copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/gobble.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,124 @@
+// gobble.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "gobble.h"
+
+
+CCommandBase* CCmdGobble::NewLC()
+	{
+	CCmdGobble* self = new(ELeave) CCmdGobble();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdGobble::~CCmdGobble()
+	{
+	}
+
+CCmdGobble::CCmdGobble()
+	: iBlockSize(512)
+	{
+	}
+
+const TDesC& CCmdGobble::Name() const
+	{
+	_LIT(KName, "gobble");
+	return KName;
+	}
+
+void CCmdGobble::DoRunL()
+	{
+	if (iAmount < iBlockSize)
+		{
+		LeaveIfErr(KErrArgument, _L("The amount to consume must be less than the block size (%d)"), iBlockSize);
+		}
+	if (iAmount & 0x80000000)
+		{
+		LeaveIfErr(KErrArgument, _L("The amount to consume is too large (maximum is %d)"), KMaxTInt);
+		}
+	if (iBlockSize & 0x80000000)
+		{
+		LeaveIfErr(KErrArgument, _L("The block size is too large (maximum is %d)"), KMaxTInt);
+		}
+	RFs& fs = FsL();
+	fs.MkDirAll(iFileName);
+	RFile file;
+	TInt err = file.Open(fs, iFileName, EFileWrite);
+	if (err == KErrNotFound)
+		{
+		err = file.Create(fs, iFileName, EFileWrite);
+		}
+	User::LeaveIfError(err);
+	CleanupClosePushL(file);
+	TInt pos = 0;
+	User::LeaveIfError(file.Seek(ESeekEnd, pos));
+
+	HBufC8* buf = HBufC8::NewLC(iBlockSize);
+	TPtr8 ptr(buf->Des());
+	ptr.Fill(TChar('x'), iBlockSize);
+	
+	TInt toWrite = static_cast<TInt>(iAmount);
+	do
+		{
+		TInt writeSize;
+		if (toWrite > static_cast<TInt>(iBlockSize))
+			{
+			writeSize = static_cast<TInt>(iBlockSize);
+			}
+		else
+			{
+			writeSize = toWrite;
+			}
+		ptr.SetLength(writeSize);
+		err = file.Write(ptr);
+		if (err == KErrNone)
+			{
+			if (iVerbose)
+				{
+				Printf(_L("\rWrote %d"), iAmount - toWrite);
+				}
+			toWrite -= writeSize;
+			}
+		}
+		while ((err == KErrNone) && (toWrite > 0));
+		if (iVerbose)
+			{
+			Printf(_L("\rWrote %d"), iAmount - toWrite);
+			}
+		
+	CleanupStack::PopAndDestroy(2, &file);
+	}
+
+void CCmdGobble::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KCmdOptVerbose);
+	}
+
+void CCmdGobble::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFileName, "file_name");
+	aArguments.AppendFileNameL(iFileName, KArgFileName);
+
+	_LIT(KArgAmount, "amount");
+	aArguments.AppendUintL(iAmount, KArgAmount);
+
+	_LIT(KArgBlockSize, "block_size");
+	aArguments.AppendUintL(iBlockSize, KArgBlockSize);
+	}
+
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdGobble)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/gobble.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// gobble.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+
+class CCmdGobble : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdGobble();
+private:
+	CCmdGobble();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iFileName;
+	TUint iAmount;
+	TUint iBlockSize;
+	TBool iVerbose;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/hello.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# hello.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name hello
+
+==short-description
+
+Classic C<Hello World!> example.
+
+==long-description
+
+Intended to be an example of a minimal command implementation. Simply prints C<Hello World!> to the console.
+
+==option bool c color
+
+Write C<Hello World!> in color.
+
+==copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/hello.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+// hello.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "hello.h"
+
+
+CCommandBase* CCmdHello::NewLC()
+	{
+	CCmdHello* self = new(ELeave) CCmdHello();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdHello::~CCmdHello()
+	{
+	}
+
+CCmdHello::CCmdHello()
+	{
+	}
+
+const TDesC& CCmdHello::Name() const
+	{
+	_LIT(KName, "hello");
+	return KName;
+	}
+
+void CCmdHello::DoRunL()
+	{
+	_LIT(KHelloWorld, "Hello World!");
+
+	if (iColor)
+		{
+		CTextBuffer* buf = CTextBuffer::NewLC(16);
+		TInt color = ConsoleAttributes::ERed;
+		for (TInt i = 0; i < KHelloWorld().Length(); ++i)
+			{
+			buf->SetAttributesL(ConsoleAttributes::ENone, (ConsoleAttributes::TColor)color);
+			buf->AppendL(KHelloWorld()[i]);
+			++color;
+			if (color == ConsoleAttributes::EWhite)
+				{
+				color = ConsoleAttributes::ERed;
+				}
+			}
+		buf->SetAttributesL(ConsoleAttributes::ENone); // Restore the colours to normal
+		buf->Write(Stdout());
+		CleanupStack::PopAndDestroy(buf);
+		}
+	else
+		{
+		Write(KHelloWorld);
+		}
+	}
+
+void CCmdHello::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iColor, _L("color"));
+	}
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdHello)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/hello.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// hello.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdHello : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdHello();
+private:
+	CCmdHello();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iColor;
+	};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/help.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+# help.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name help
+
+==short-description
+
+List the available commands.
+
+==long-description
+
+Lists fshell's built-in and alias commands (e.g. C<dir> is an alias for C<ls -l>). Also lists external commands, DLLs that have a UID2 of 0x102864C8 and EXEs that have a UID2 of 0x102835BE.
+
+==option bool c count
+
+Display the number of unique commands.
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/infoprint.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# infoprint.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name infoprint
+
+==short-description
+
+Display an informational message.
+
+==long-description
+
+The output of this command depends on the Symbian OS platform it is run on. Commonly a small text window is displayed in one of the corners of the handset's screen. It uses C<User::InfoPrint>. Note, some platforms ignore calls to this API.
+
+==argument string message optional
+
+The message to be printed. If not specified, then the message is read from C<stdin>.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ioinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,66 @@
+# ioinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name ioinfo
+
+==short-description
+
+Provides information on IO objects within the IO server.
+
+==argument enum object_type
+
+The type of IO object to display information about. The following values are supported:
+
+==enum-value read-write
+
+Both read and write objects.
+
+==enum-value read
+
+Just read objects.
+
+==enum-value write
+
+Just write objects.
+
+==enum-value end-point
+
+All end-points. Note, the remaining values are specific kinds of end-point.
+
+==enum-value console
+
+Just console end-points.
+
+==enum-value file
+
+Just file end-points. Note, file end-points are used by L<fshell|fshell> when it redirects the input or output of a command from or to a file in response to <, > or >>.
+
+==enum-value null
+
+Just null end-points. Note, null end-points are used by L<fshell|fshell> when the input or output of a command is redirected from or to F</dev/nul> or C<NUL>.
+
+==enum-value pipe
+
+Just pipe end-points. Note, pipe end-points are used by L<fshell|fshell> when a command-line contains the pipe (C<|>) operator.
+
+==enum-value persistent-console
+
+Just persistent console end-points. See L<pcons|pcons> and the F<Persistent Consoles> section of the tool-kit's documentation for more details.
+
+==option string m match
+
+Match string to filter object names. Defaults to C<*>.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/jit.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+# jit.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name jit
+
+==short-description
+
+Controls and shows the emulator's Just In Time debug setting.
+
+==argument enum operation optional
+
+The operation to perform.
+
+==enum-value status
+
+Display the current JIT status. This is the default if no operation is specified.
+
+==enum-value on
+
+Turn JIT on.
+
+==enum-value off
+
+Turn JIT off.
+
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/jobs.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# jobs.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name jobs
+
+==short-description
+
+List the currently running or stopped jobs.
+
+==see-also
+
+L<fg|fg>, L<bg|bg>, L<disown|disown>
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/kill.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# kill.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name kill
+
+==short-description
+
+Kill, terminate or panic one or more processes or threads.
+
+==argument uint id optional
+
+The identifier of the process or thread to be killed, as given by "ps" or similar.
+
+==option int r reason
+
+The reason code to kill the process with (defaults to 0). If --panic is specified, this is used as the panic number (the "3" in "KERN-EXEC 3").
+
+==option bool t terminate
+
+Terminate the process (or thread) rather than Kill.
+
+==option string p panic
+
+Panic the process (or thread) with the specified category rather than Kill (use --reason to specify the panic number).
+
+==option bool T thread
+
+Kill a single thread within a process rather than the whole process (may still kill the whole process if the thread is process permanent or process critical). If this option is specified, any supplied <id> argument is expected to be a thread ID rather than a process ID.
+
+==option string m match
+
+A pattern used to match the process or thread name. Can be used instead of specifying the process or thread identifer value. If the --thread option is given, the match string is compared against the thread Full Name (ie includes the process name).
+
+==option bool a all
+
+Only relevant when using the --match option. Kill (or terminate, etc) every process (or thread, as applicable) matching the given string. By default, if there is more than one match that is still running, an error will be printed and the command aborts.
+
+==copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/kill.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,219 @@
+// kill.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "kill.h"
+#include <fshell/common.mmh>
+
+CCommandBase* CCmdKill::NewLC()
+	{
+	CCmdKill* self = new(ELeave) CCmdKill();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdKill::~CCmdKill()
+	{
+	delete iPanicCategory;
+	delete iMatch;
+	}
+
+CCmdKill::CCmdKill()
+	{
+	}
+
+const TDesC& CCmdKill::Name() const
+	{
+	_LIT(KName, "kill");
+	return KName;
+	}
+
+void CCmdKill::DoRunL()
+	{
+	if (iTerminate && iPanicCategory)
+		{
+		PrintError(KErrArgument, _L("Options --terminate and --panic are mutually exclusive"));
+		User::Leave(KErrArgument);
+		}
+
+	if (iMatch)
+		{
+		FindIdAndKillL(*iMatch);
+		}
+	else if (iArguments.IsPresent(&iId))
+		{
+		KillIdL(iId);
+		}
+	else
+		{
+		LeaveIfErr(KErrArgument, _L("You must specify either an id or a match string"));
+		}
+	}
+
+template <class T>
+void CCmdKill::DoKillByHandleL(TUint aId)
+	{
+	T handle;
+	LeaveIfErr(handle.Open(aId, EOwnerThread), _L("Unable to open handle id %u"), aId);
+	TName name(handle.Name());
+	
+	if (handle.ExitType() != EExitPending)
+		{
+		Printf(_L("%S (id=%u) has already exited"), &name, aId);
+		handle.Close();
+		return;
+		}
+
+	if (iTerminate)
+		{
+		handle.Terminate(iReason);
+		Printf(_L("Terminated %S (id=%u) with %d\r\n"), &name, aId, iReason);
+		}
+	else if (iPanicCategory)
+		{
+		handle.Panic(*iPanicCategory, iReason);
+		Printf(_L("Panicked %S (id=%u) with %S %d\r\n"), &name, aId, iPanicCategory, iReason);
+		}
+	else
+		{
+		handle.Kill(iReason);
+		Printf(_L("Killed %S (id=%u) with %d\r\n"), &name, aId, iReason);
+		}
+
+	handle.Close();
+	}
+
+void CCmdKill::FindIdAndKillL(const TDesC& aPattern)
+	{
+	if (iThread) DoFindIdAndKillL<RThread, TFindThread>(aPattern);
+	else DoFindIdAndKillL<RProcess, TFindProcess>(aPattern);
+	}
+
+template <class RProcessOrThread, class TFindProcessOrThread>
+void CCmdKill::DoFindIdAndKillL(const TDesC& aPattern)
+	{
+	TFullName fullName;
+	TInt numFound = 0;
+	TFindProcessOrThread finder(aPattern);
+	while (finder.Next(fullName) == KErrNone)
+		{
+		RProcessOrThread handle;
+		TInt err = handle.Open(finder, EOwnerThread);
+		if ((err == KErrNone) && (handle.ExitType() == EExitPending))
+			{
+			++numFound;
+			TUint id = handle.Id().Id();
+			handle.Close();
+			if (iAll || numFound == 1)
+				{
+				KillIdL(id);
+				}
+			}
+		else if (err)
+			{
+			PrintWarning(_L("Couldn't open %S (err=%d)"), &fullName);
+			}
+		}
+	if (numFound == 0)
+		{
+		LeaveIfErr(KErrNotFound, _L("No matches for pattern \"%S\", or all matches are zombies"), &aPattern);
+		}
+	else if (numFound > 1 && !iAll)
+		{
+		PrintWarning(_L("%d further matches for pattern \"%S\" found, be more specific or use --all option"), numFound-1, &aPattern);
+		}
+	}
+
+void CCmdKill::DoKillThreadL(TUint aId)
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	LoadMemoryAccessL();
+
+	RThread thread;
+	LeaveIfErr(iMemAccess.RThreadForceOpen(thread, aId), _L("Unable to open thread"));
+	TName name(thread.FullName());
+	if (thread.ExitType() != EExitPending)
+		{
+		Printf(_L("%S (id=%u) has already exited"), &name, aId);
+		thread.Close();
+		return;
+		}
+
+	CleanupClosePushL(thread);
+	TExitType type = EExitKill;
+	if (iTerminate)
+		{
+		type = EExitTerminate;
+		}
+	else if (iPanicCategory)
+		{
+		type = EExitPanic;
+		}
+	TInt err = iMemAccess.ObjectDie(EThread, aId, NULL, type, iReason, iPanicCategory ? *iPanicCategory : KNullDesC());
+	LeaveIfErr(err, _L("Couldn't kill thread id %u"), aId);
+
+	if (iTerminate)
+		{
+		Printf(_L("Terminated %S (id=%u) with %d\r\n"), &name, aId, iReason);
+		}
+	else if (iPanicCategory)
+		{
+		Printf(_L("Panicked %S (id=%u) with %S %d\r\n"), &name, aId, iPanicCategory, iReason);
+		}
+	else
+		{
+		Printf(_L("Killed %S (id=%u) with %d\r\n"), &name, aId, iReason);
+		}
+	CleanupStack::PopAndDestroy(&thread);
+
+#else
+	DoKillByHandleL<RThread>(aId);
+#endif
+	}
+
+void CCmdKill::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptReason, "reason");
+	_LIT(KOptThread, "thread");
+	_LIT(KOptTerminate, "terminate");
+	_LIT(KOptPanic, "panic");
+	_LIT(KOptMatch, "match");
+	_LIT(KOptAll, "all");
+	aOptions.AppendIntL(iReason, KOptReason);
+	aOptions.AppendBoolL(iTerminate, KOptTerminate);
+	aOptions.AppendStringL(iPanicCategory, KOptPanic);
+	aOptions.AppendBoolL(iThread, KOptThread);
+	aOptions.AppendStringL(iMatch, KOptMatch);
+	aOptions.AppendBoolL(iAll, KOptAll);
+	}
+
+void CCmdKill::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgId, "id");
+	aArguments.AppendUintL(iId, KArgId);
+	}
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdKill)
+#endif
+
+void CCmdKill::KillIdL(TUint aId)
+	{
+	if (iThread)
+		{
+		DoKillThreadL(aId);
+		}
+	else
+		{
+		DoKillByHandleL<RProcess>(aId);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/kill.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+// kill.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/memoryaccesscmd.h>
+
+using namespace IoUtils;
+
+class CCmdKill : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdKill();
+private:
+	CCmdKill();
+	void KillIdL(TUint aId);
+	template <class T> void DoKillByHandleL(TUint aId);
+	void DoKillThreadL(TUint aId);
+	void FindIdAndKillL(const TDesC& aPattern);
+	template <class RProcessOrThread, class TFindProcessOrThread> void DoFindIdAndKillL(const TDesC& aPattern);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iId;
+	TInt iReason;
+	TBool iThread;
+	TBool iTerminate;
+	HBufC* iPanicCategory;
+	HBufC* iMatch;
+	TBool iAll;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ls.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,76 @@
+# ls.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name ls
+
+==short-description
+
+List the contents of a directory.
+
+==long-description
+
+Note, C<cd> can be used to navigate between drives, but the DOS approach of switching between drives with commands like C<c:> and C<e:> is also supported.
+
+==argument filename dir_name optional
+
+The directory to list (defaults to the current working directory).
+
+==option bool a all
+
+Display all files, including those with hidden and system attributes.
+
+==option bool l long
+
+Display verbose file information, including attributes, file size and last-modified date. The attributes have the following format:
+
+=over 5
+
+=item d
+
+directory
+
+=item r
+
+read only
+
+=item h
+
+hidden
+
+=item s
+
+system
+
+=item a
+
+archived
+
+=back
+
+For example, C<d--s-> indicates a drectory with the system bit set.
+
+==option bool H human
+
+Display file sizes in human readable form.
+
+==option bool 1 one
+
+Outputs one entry per line rather than trying to columnise the output. Is implied if C<stdout> is redirected or if C<--long> is specified.
+
+==option bool r recurse
+
+Recursively list any directories that are encountered. Currently only supported for C<--long> listings.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/match.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+# match.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name match
+
+==short-description
+
+Print to C<stdout> any lines of C<stdin> that match a particular pattern.
+
+==long-description
+
+Note, does not support regular expressions, only Symbian's descriptor wild characters (aka C<TDesC::Match()>. Since these don't explicitly support anchoring (functionality provided by C<^> and C<$> in regular expressions) if you want to match an word within a line you need to put C<*> characters at either end of the pattern string. If you don't, then the match will be implicitly anchored to either end of the line.
+
+==argument string pattern
+
+The pattern to be matched. Symbian descriptor wild characters supported.
+
+==option bool i ignore-case
+
+Ignore case distinctions.
+
+==option bool v invert-match
+
+Print lines that do B<not> match.
+
+==option bool c count
+
+Don't print the lines that match, just count them and print the total at the end. If used with C<--invert-match>, counts the number of non-matching lines.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
+==see-also
+
+L<grep|grep>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/meminfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+# meminfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name meminfo
+
+==short-description
+
+Display information about memory usage.
+
+==option bool H human
+
+Display sizes in human readable form.
+
+==option uint r rate
+
+Repeatedly update after the specified number of milliseconds. If not specified (or specified as zero) the current memory information will be displayed and the tool will exit.
+
+==option bool f free
+
+Display only the free amount of RAM.
+
+==option bool t total
+
+Display only the total amount of RAM.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/mkdir.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# mkdir.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name mkdir
+
+==short-description
+
+Create a new directory.
+
+==long-description
+
+Makes all the directories in a given path that don't already exist. Also aliased to C<md>.
+
+==argument filename dir_name
+
+The name of the directory to be created.
+
+==option bool a allow_exists
+
+Don't return an error if the directory already exists.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/more.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# more.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name more
+
+==short-description
+
+Write a file or C<stdin> a screen-full at a time to C<stdout>.
+
+==long-description
+
+C<q> or C<Q> causes paging to abort. C<Enter> advances by one line. Any other key advances by a page.
+
+==argument filename file_name optional
+
+The file to be paged. Reads from C<stdin> in not specified.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/mv.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# mv.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name mv
+
+==short-description
+
+Rename one or more files.
+
+==long-description
+
+Note, also aliased to C<ren>.
+
+==argument filename source_file
+
+The name of the file to be moved (may contain wild characters).
+
+==argument filename destination_file
+
+The new name of the file or target directory.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/objinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# objinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name objinfo
+
+==short-description
+
+Display information about kernel objects.
+
+==long-description
+
+Given a kernel object address, prints details of the threads and processes that are currently holding handles to it (note, kernel objects addresses can be found using L<ps|ps> (e.g. C<ps -A> or C<ps -At>), L<chunkinfo|chunkinfo> or L<svrinfo|svrinfo>). Given a thread or process identifier, lists details of all the owned objects.
+
+==see-also
+
+L<ps|ps>, L<chunkinfo|chunkinfo>, L<svrinfo|svrinfo>
+
+==argument uint object_address optional
+
+The address of the kernel object to find the owners of. If not specified, a thread or process identifier must be specified using C<-t> or C<-p>.
+
+==option bool r referencers
+
+Print the names of threads and processes that are holding handles to a given object.
+
+==option uint p process-id
+
+List all the objects that the specified process references.
+
+==option uint t thread-id
+
+List all the objects that the specified thread references.
+
+==option bool a all
+
+Include details of objects referenced by threads of a given process. Only useful in conjunction with the C<-p> option.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/pcons.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,73 @@
+# pcons.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name pcons
+
+==short-description
+
+Manipulates persistent console objects.
+
+==see-also
+
+Commands:
+
+L<console|console>, L<ioinfo|ioinfo>
+
+Tool-kit documentation:
+
+F<Persistent Consoles>, F<Consoles>
+
+==argument enum operation optional
+
+The operation to perform. Defaults to C<list>.
+
+==enum-value list
+
+List the currently running persistent consoles.
+
+==enum-value new
+
+Create a new persistent console.
+
+==enum-value connect
+
+Attach the current console to an existing persistent console.
+
+==enum-value start
+
+Effectively the same as a C<new> followed by a C<connect>. However, if a persistent console of the specified name already exists, no error is reported. Note, in this circumstance the C<command> argument is ignored.
+
+==enum-value disconnect
+
+Detach the current console from the peristent console that is connected to.
+
+==argument string name optional
+
+The name of the persistent console to use. For C<list>, this is used as a match string and defaults to C<*>. For C<disconnect>, defaults to the current persistent console if not given. Must be provided for C<connect>.
+
+==argument string command optional
+
+The executable to be launched within a new persistent console. Only applicable for C<new> and C<start> operations. Defaults to C<fshell>.
+
+==argument string command_args optional last
+
+The arguments for the executable to be launched within a new persistent console.
+
+==option bool v verbose
+
+Display verbose information.
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ps.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,102 @@
+# ps.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name ps
+
+==short-description
+
+List information relating to the currently running processes and threads.
+
+==see-also
+
+L<kerninfo|kerninfo>, L<objinfo|objinfo>, L<chunkinfo|chunkinfo>, L<top|top>
+
+==argument uint process_id optional
+
+The identifier of the process to examine. If not specified, displays information on all processes.
+
+==option bool v verbose
+
+Verbose output. Prints warnings if threads couldn't be opened, and displays full thread names instead of short ones.
+
+==option string m match
+
+A pattern used to match processes by name (defaults to C<*>).
+
+==option string M matchify
+
+Like C<--match> but without the need for leading/trailing asterisks (see C<LtkUtils::Matchify>).
+
+==option bool H human
+
+Print human readable sizes.
+
+==option bool p priority
+
+Print process and thread priority information.
+
+==option bool x exclude-dead
+
+Does not list threads/processes that have exited or died (by default they will appear if anything still has a handle open to them).
+
+==option bool o only-dead
+
+Only list threads/processes that have exited or died.
+
+==option bool n handle-count
+
+Print the number of handles held by a given thread or process.
+
+==option bool A addresses
+
+Print kernel object addresses.
+
+==option bool t threads
+
+Print thread information.
+
+==option bool s stacks
+
+Print thread stack information (only valid with the C<--thread> option). Note, the term 'High water mark' is used to indicate the largest amount of stack a given thread has used in its lifetime.
+
+==option bool a heaps
+
+Print thread heap usage (only valid with the C<--thread> option).
+
+==option bool c cpu-time
+
+Print thread CPU time (only valid with the C<--thread> option).
+
+==option bool k chunks
+
+Print details about the chunks belonging to each process.
+
+==option bool f filename
+
+Print the executable's file name.
+
+==option bool r memory
+
+Print memory usage information.
+
+==option bool d command_line
+
+Print the command line arguments. Only available on non-emulated builds of EKA1.
+
+==option bool l flags
+
+Print C<System>, C<Protected> and C<LoadedFromRam> flag values. Only available on EKA1.
+
+==copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ps.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,548 @@
+// ps.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+#include <fshell/heaputils.h>
+#include "ps.h"
+
+_LIT(KDefaultMatch, "*");
+
+CCommandBase* CCmdPs::NewLC()
+	{
+	CCmdPs* self = new(ELeave) CCmdPs();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdPs::~CCmdPs()
+	{
+	delete iMatch;
+	delete iFormatter;
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	iMemoryAccess.Close();
+#endif
+	}
+
+CCmdPs::CCmdPs()
+	{
+	}
+
+const TDesC& CCmdPs::Name() const
+	{
+	_LIT(KName, "ps");
+	return KName;
+	}
+
+void CCmdPs::DoRunL()
+	{
+	if (iMatch == NULL)
+		{
+		iMatch = KDefaultMatch().AllocL();
+		}
+
+	iFormatter = CTextFormatter::NewL(Stdout());
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TInt err = RMemoryAccess::LoadDriver();
+	if ((err == KErrNone) || (err == KErrAlreadyExists))
+		{
+		err = iMemoryAccess.Open();
+		}
+	if (err)
+		{
+		PrintWarning(_L("Unable to load memory access device driver: %d"), err);
+		}
+#endif
+
+#if defined(__WINS__) && !defined(EKA2)
+	TFindThread finder(*iMatch);
+	RThread process;
+#else
+	TFindProcess finder(*iMatch);
+	RProcess process;
+#endif
+
+	
+	if (iProcessId)
+		{
+		User::LeaveIfError(process.Open(iProcessId));
+		CleanupClosePushL(process);
+		iProcessName = process.Name();
+		PrintInfoL(process);
+		CleanupStack::PopAndDestroy(&process);
+		}
+	else
+		{
+		while (finder.Next(iProcessName) == KErrNone)
+			{
+			TInt err = process.Open(finder);
+			if (err)
+				{
+				PrintWarning(_L("Unable to open handle to process %S: %d"), &iProcessName, err);
+				continue;
+				}
+			if ((iExcludeDead && (process.ExitType() != EExitPending)) || (iOnlyDead && (process.ExitType() == EExitPending)))
+				{
+				process.Close();
+				continue;
+				}
+			CleanupClosePushL(process);
+			PrintInfoL(process);
+			CleanupStack::PopAndDestroy(&process);
+			}
+		}
+		
+	Write(iFormatter->Descriptor());
+	Complete();
+	}
+
+void CCmdPs::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg1, "process_id");
+	aArguments.AppendUintL(iProcessId, KArg1);
+	}
+
+void CCmdPs::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptMatch, "match");
+	aOptions.AppendStringL(iMatch, KOptMatch);
+
+	_LIT(KOptHuman, "human");
+	aOptions.AppendBoolL(iHuman, KOptHuman);
+
+	_LIT(KOptPriority, "priority");
+	aOptions.AppendBoolL(iPrintPriority, KOptPriority);
+
+	_LIT(KOptExclude, "exclude-dead");
+	aOptions.AppendBoolL(iExcludeDead, KOptExclude);
+
+	_LIT(KOptOnlyDead, "only-dead");
+	aOptions.AppendBoolL(iOnlyDead, KOptOnlyDead);
+
+	_LIT(KOptHandleCount, "handle-count");
+	aOptions.AppendBoolL(iHandleCount, KOptHandleCount);
+
+#if defined(EKA2) || !defined(__WINS__)
+	_LIT(KOptThreads, "threads");
+	aOptions.AppendBoolL(iPrintThreads, KOptThreads);
+
+	_LIT(KOptStack, "stacks");
+	aOptions.AppendBoolL(iPrintStackInfo, KOptStack);
+
+	_LIT(KOptHeap, "heaps");
+	aOptions.AppendBoolL(iPrintHeapInfo, KOptHeap);
+
+	_LIT(KOptCpu, "cpu-time");
+	aOptions.AppendBoolL(iPrintCpuTime, KOptCpu);
+
+	_LIT(KOptChunk, "chunks");
+	aOptions.AppendBoolL(iPrintChunkInfo, KOptChunk);
+
+	_LIT(KOptFileName, "filename");
+	aOptions.AppendBoolL(iPrintFileName, KOptFileName);
+
+	_LIT(KOptMemoryInfo, "memory");
+	aOptions.AppendBoolL(iPrintMemoryInfo, KOptMemoryInfo);
+#endif
+#if !defined(EKA2) && !defined(__WINS__)
+	_LIT(KOptCommandLine, "command_line");
+	aOptions.AppendBoolL(iPrintCommandLine, KOptCommandLine);
+#endif
+#if !defined(EKA2)
+	_LIT(KOptFlags, "flags");
+	aOptions.AppendBoolL(iPrintFlags, KOptFlags);
+#endif
+
+	_LIT(KOptAddresses, "addresses");
+	aOptions.AppendBoolL(iAddresses, KOptAddresses);
+	}
+
+#if defined(__WINS__) && !defined(EKA2)
+void CCmdPs::PrintInfoL(RThread& aProcess)
+#else
+void CCmdPs::PrintInfoL(RProcess& aProcess)
+#endif
+	{
+	TInt processHandleCount = 0;
+	
+	TBool dead = aProcess.ExitType() != EExitPending;
+	iFormatter->AppendFormatL(_L("%u "), TUint(aProcess.Id()));
+	if (dead) iFormatter->AppendL(_L("["));
+	if (iVerbose)
+		{
+		iFormatter->AppendL(iProcessName);
+		}
+	else
+		{
+		TFullName name = iProcessName;
+		LtkUtils::MakeProcessNameFriendly(name);
+		iFormatter->AppendL(name);
+		}
+	if (dead) iFormatter->AppendL(_L("]"));
+	iFormatter->AppendL(_L("\r\n"));
+
+	iProcessName.Append(_L("::*"));
+
+	if (iPrintThreads)
+		{
+		iFormatter->AppendL(_L("\tThreads:\r\n"));
+		TFindThread threadFinder(iProcessName);
+		RThread thread;
+		while (threadFinder.Next(iThreadName) == KErrNone)
+			{
+			TInt err = thread.Open(threadFinder);
+			if (err)
+				{
+				if ((err != KErrPermissionDenied) || iVerbose)
+					{
+					PrintWarning(_L("Unable to open handle to thread %S: %d"), &iThreadName, err);
+					}
+				continue;
+				}
+			if ((iExcludeDead && (thread.ExitType() != EExitPending)) || (iOnlyDead && (thread.ExitType() == EExitPending)))
+				{
+				thread.Close();
+				continue;
+				}
+
+			CleanupClosePushL(thread);
+			iThreadName = thread.Name();
+#ifdef EKA2
+			iFormatter->AppendFormatL(_L("\t\t%Lu %S\r\n"), thread.Id().Id(), &iThreadName);
+#else
+			iFormatter->AppendFormatL(_L("\t\t%u %S\r\n"), thread.Id(), &iThreadName);
+#endif
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+			if (iAddresses && iMemoryAccess.Handle())
+				{
+				TObjectKernelInfo objectInfo;
+				TPckg<TObjectKernelInfo> objectInfoPckg(objectInfo);
+				TInt err = iMemoryAccess.GetObjectInfoByHandle(EThread, RThread().Id(), thread.Handle(), objectInfoPckg);
+				if (err == KErrNone)
+					{
+					iFormatter->AppendFormatL(_L("\t\t\tAddress: 0x%08x\r\n"), objectInfo.iAddressOfKernelObject);
+					}
+				}
+#endif // FSHELL_MEMORY_ACCESS_SUPPORT
+			if (iPrintPriority)
+				{
+				iFormatter->AppendFormatL(_L("\t\t\tPriority: %d\r\n"), thread.Priority());
+				}
+			PrintStackInfoL(thread, iThreadName);
+			PrintHeapInfoL(thread, iThreadName);
+			PrintCpuTimeL(thread, iThreadName);
+			if (iHandleCount)
+				{
+				TInt threadHandleCount;
+				thread.HandleCount(processHandleCount, threadHandleCount);
+				iFormatter->AppendFormatL(_L("\t\t\tHandle count: %d\r\n"), threadHandleCount);
+				}
+			CleanupStack::PopAndDestroy(&thread);
+			}
+		}
+	if (iPrintPriority)
+		{
+		iFormatter->AppendFormatL(_L("\tPriority: %d\r\n"), aProcess.Priority());
+		}
+#if defined(EKA2) || !defined(__WINS__)
+	PrintChunkInfoL(iProcessName);
+	if (iPrintFileName)
+		{
+		TFileName fileName(aProcess.FileName());
+		iFormatter->AppendFormatL(_L("\tFile name: %S\r\n"), &fileName);
+		}
+	if (iPrintMemoryInfo)
+		{
+		TProcessMemoryInfo memoryInfo;
+		TInt err = aProcess.GetMemoryInfo(memoryInfo);
+		if (err)
+			{
+			PrintWarning(_L("Couldn't read memory information: %d"), err);
+			}
+		else
+			{
+			iFormatter->AppendFormatL(_L("\tCode base: 0x%08x\r\n"), memoryInfo.iCodeBase);
+			PrintSizeL(_L("\tCode size: "), memoryInfo.iCodeSize);
+			iFormatter->AppendFormatL(_L("\tConst data base: 0x%08x\r\n"), memoryInfo.iConstDataBase);
+			PrintSizeL(_L("\tConst data size: "), memoryInfo.iConstDataSize);
+			iFormatter->AppendFormatL(_L("\tInitialised data base: 0x%08x\r\n"), memoryInfo.iInitialisedDataBase);
+			PrintSizeL(_L("\tInitialised data size: "), memoryInfo.iInitialisedDataSize);
+			iFormatter->AppendFormatL(_L("\tUninitialised data base: 0x%08x\r\n"), memoryInfo.iUninitialisedDataBase);
+			PrintSizeL(_L("\tUninitialised data size: "), memoryInfo.iUninitialisedDataSize);
+			}
+		}
+#endif
+#if !defined(EKA2) && !defined(__WINS__)
+	if (iPrintCommandLine)
+		{
+		HBufC* cl = HBufC::NewL(aProcess.CommandLineLength());
+		TPtr clPtr(cl->Des());
+		aProcess.CommandLine(clPtr);
+		iFormatter->AppendFormatL(_L("\tCommand line: %S\r\n"), cl);
+		delete cl;
+		}
+#endif
+	if (iPrintFlags)
+		{
+#ifndef EKA2
+		iFormatter->AppendFormatL(_L("\tSystem: %d\r\n\tProtected: %d\r\n"), aProcess.System(), aProcess.Protected());
+#endif
+#if !defined(__WINS__) && !defined(EKA2)
+		iFormatter->AppendFormatL(_L("\tLoaded from RAM: %d\r\n"), aProcess.LoadedFromRam());
+#endif
+		}
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	if (iAddresses && iMemoryAccess.Handle())
+		{
+		TObjectKernelInfo objectInfo;
+		TPckg<TObjectKernelInfo> objectInfoPckg(objectInfo);
+		TInt err = iMemoryAccess.GetObjectInfoByHandle(EProcess, RThread().Id(), aProcess.Handle(), objectInfoPckg);
+		if (err == KErrNone)
+			{
+			iFormatter->AppendFormatL(_L("\tAddress: 0x%08x\r\n"), objectInfo.iAddressOfKernelObject);
+			}
+		}
+#endif // FSHELL_MEMORY_ACCESS_SUPPORT
+	
+	if (iHandleCount)
+		{
+		if (iPrintThreads)
+			{
+			iFormatter->AppendFormatL(_L("\tProcess handle count: %d\r\n"), processHandleCount);
+			}
+		else
+			{
+			// Summarise the total handle count for this process and all its threads.
+			TInt threadHandleCount = 0;
+			TFindThread threadFinder(iProcessName);
+			RThread thread;
+			while (threadFinder.Next(iThreadName) == KErrNone)
+				{
+				TInt err = thread.Open(threadFinder);
+				if (err)
+					{
+					continue;
+					}
+				TInt thc;
+				thread.HandleCount(processHandleCount, thc);
+				thread.Close();
+				threadHandleCount += thc;
+				}
+			iFormatter->AppendFormatL(_L("\tTotal handle count: %d\r\n"), processHandleCount + threadHandleCount);
+			}
+		}
+	}
+
+void CCmdPs::PrintStackInfoL(RThread& aThread, const TDesC& aThreadName)
+	{
+#ifdef EKA2
+	if (iPrintStackInfo)
+		{
+		TThreadStackInfo stackInfo;
+		TInt err = aThread.StackInfo(stackInfo);
+		if (err)
+			{
+			PrintWarning(_L("Unable to get stack info for thread %S: %d"), &aThreadName, err);
+			}
+		else
+			{
+			const TInt stackSize = stackInfo.iBase - stackInfo.iLimit;
+			iFormatter->AppendFormatL(_L("\t\t\tStack info:\r\n"));
+			PrintSizeL(_L("\t\t\t\tSize: "), stackSize);
+			iFormatter->AppendFormatL(_L("\t\t\t\tBase: 0x%08x\r\n"), stackInfo.iBase);
+			iFormatter->AppendFormatL(_L("\t\t\t\tLimit: 0x%08x\r\n"), stackInfo.iLimit);
+			iFormatter->AppendFormatL(_L("\t\t\t\tExpand limit: 0x%08x\r\n"), stackInfo.iExpandLimit);
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+			if (iMemoryAccess.Handle())
+				{
+				const TInt KBufSize = 4096; // The largest amount RMemoryAccess allows us to copy in one go.
+				HBufC8* stackBuf = HBufC8::NewLC(KBufSize);
+				TPtr8 stackBufPtr(stackBuf->Des());
+				TThreadMemoryAccessParamsBuf accessParamsBuf;
+				TThreadMemoryAccessParams& accessParams = accessParamsBuf();
+				accessParams.iId = (TInt)aThread.Id().Id();
+				TInt numBytesRead = 0;
+				TInt numUnusedBytes = 0;
+				while (numBytesRead < stackSize)
+					{
+					accessParams.iAddr = (TUint8*)stackInfo.iLimit + numBytesRead;
+					accessParams.iSize = Min(KBufSize, stackSize - numBytesRead);
+					stackBufPtr.Zero();
+					err = iMemoryAccess.GetThreadMem(accessParamsBuf, stackBufPtr);
+					if (err)
+						{
+						PrintWarning(_L("Unable to read stack data for thread %S: %d"), &aThreadName, err);
+						break;
+						}
+					else
+						{
+						const TInt bufLength = stackBuf->Length();
+						for (TInt i = 0; i < bufLength; ++i)
+							{
+							if ((*stackBuf)[i] != 0x29)
+								{
+								break;
+								}
+							++numUnusedBytes;
+							}
+						numBytesRead += bufLength;
+						}
+					}
+				if (err == KErrNone)
+					{
+					const TInt numUsedBytes = stackSize - numUnusedBytes;
+					iFormatter->AppendFormatL(_L("\t\t\t\tHigh water mark: 0x%08x ("), stackInfo.iBase - numUsedBytes);
+					if (iHuman)
+						{
+						iFormatter->AppendHumanReadableSizeL(numUsedBytes, EUnaligned);
+						iFormatter->AppendFormatL(_L(")\r\n"));
+						}
+					else
+						{
+						iFormatter->AppendFormatL(_L("%d bytes)\r\n"), numUsedBytes);
+						}
+					}
+				CleanupStack::PopAndDestroy(stackBuf);
+				}
+#endif // FSHELL_MEMORY_ACCESS_SUPPORT
+			}
+		}
+#endif // EKA2
+	}
+
+#if defined(EKA2) && defined(FSHELL_MEMORY_ACCESS_SUPPORT)
+void CCmdPs::PrintHeapInfoL(RThread& aThread, const TDesC& aThreadName)
+	{
+	if (iPrintHeapInfo && iMemoryAccess.Handle())
+		{
+		LtkUtils::RProxyAllocatorHelper allocHelper;
+		CleanupClosePushL(allocHelper);
+		TInt err = allocHelper.Open(iMemoryAccess, TUint(aThread.Id()));
+		if (err)
+			{
+			PrintWarning(_L("Couldn't open allocator helper for thread %S: %d"), &aThreadName, err);
+			}
+		else
+			{
+			TInt committed = allocHelper.CommittedSize();
+			TInt alloced = allocHelper.AllocatedSize();
+			PrintSizeL(_L("\t\t\tHeap size:   "), committed);
+			iFormatter->AppendFormatL(_L("\t\t\tAlloc count: %d\r\n"), allocHelper.AllocationCount());
+			PrintSizeL(_L("\t\t\tAlloc size:  "), alloced);
+			}
+		CleanupStack::PopAndDestroy(&allocHelper);
+		}
+	}
+#else
+void CCmdPs::PrintHeapInfoL(RThread&, const TDesC&)
+	{
+	}
+#endif
+
+#ifdef EKA2
+void CCmdPs::PrintCpuTimeL(RThread& aThread, const TDesC& aThreadName)
+	{
+	if (iPrintCpuTime)
+		{
+		TTimeIntervalMicroSeconds time;
+		TInt err = aThread.GetCpuTime(time);
+		if (err)
+			{
+			PrintWarning(_L("Unable to get CPU time for thread %S: %d"), &aThreadName, err);
+			}
+		else
+			{
+			iFormatter->AppendFormatL(_L("\t\t\tCPU time: %Lu\r\n"), time.Int64());
+			}
+		}
+	}
+#else
+void CCmdPs::PrintCpuTimeL(RThread&, const TDesC&)
+	{
+	}
+#endif
+
+void CCmdPs::PrintChunkInfoL(const TDesC& aProcessName)
+	{
+	if (iPrintChunkInfo)
+		{
+		iFormatter->AppendL(_L("\tChunks:\r\n"));
+		TFindChunk findChunk(aProcessName);
+		while (findChunk.Next(iChunkName) == KErrNone)
+			{
+			TPtrC shortChunkName(iChunkName.Mid(aProcessName.Length() - 1));
+			iFormatter->AppendFormatL(_L("\t\t%S\r\n"), &shortChunkName);
+#ifdef EKA2
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+			if (iMemoryAccess.Handle())
+				{
+				TChunkKernelInfo chunkInfo;
+				TPckg<TChunkKernelInfo> chunkInfoPckg(chunkInfo);
+				TInt err = iMemoryAccess.GetObjectInfo(EChunk, iChunkName, chunkInfoPckg);
+				if (err)
+					{
+					PrintWarning(_L("Unable to get info for chunk %S: %d"), &iChunkName, err);
+					}
+				else
+					{
+					iFormatter->AppendFormatL(_L("\t\t\tAddress:   0x%08x\r\n"), chunkInfo.iAddressOfKernelObject);
+					PrintSizeL(_L("\t\t\tSize:      "), chunkInfo.iSize);
+					PrintSizeL(_L("\t\t\tMax size:  "), chunkInfo.iMaxSize);
+					iFormatter->AppendFormatL(_L("\t\t\tType:      %d\r\n"), chunkInfo.iChunkType);
+					}
+				}
+#endif // FSHELL_MEMORY_ACCESS_SUPPORT
+#else  // !EKA2
+			RChunk chunk;
+			TInt err = chunk.Open(findChunk);
+			if (err)
+				{
+				PrintWarning(_L("Unable to open chunk %S: %d"), &iChunkName, err);
+				}
+			else
+				{
+				CleanupClosePushL(chunk);
+				PrintSizeL(_L("\t\t\tSize:      "), chunk.Size());
+				PrintSizeL(_L("\t\t\tMax size:  "), chunk.MaxSize());
+				CleanupStack::PopAndDestroy(&chunk);
+				}
+#endif // EKA2
+			}
+		}
+	}
+
+void CCmdPs::PrintSizeL(const TDesC& aCaption, TInt aSize)
+	{
+	if (iHuman)
+		{
+		iFormatter->AppendL(aCaption);
+		iFormatter->AppendHumanReadableSizeL(aSize, EUnaligned);
+		_LIT(KNewLine, "\r\n");
+		iFormatter->AppendL(KNewLine);
+		}
+	else
+		{
+		_LIT(KFormat, "%S%d\r\n");
+		iFormatter->AppendFormatL(KFormat, &aCaption, aSize);
+		}
+	}
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdPs)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ps.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,71 @@
+// ps.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+#include <fshell/memoryaccess.h>
+#endif
+
+using namespace IoUtils;
+
+
+class CCmdPs : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdPs();
+private:
+	CCmdPs();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+#if defined(__WINS__) && !defined(EKA2)
+	void PrintInfoL(RThread& aThread);
+#else
+	void PrintInfoL(RProcess& aProcess);
+#endif
+	void PrintStackInfoL(RThread& aThread, const TDesC& aThreadName);
+	void PrintHeapInfoL(RThread& aThread, const TDesC& aThreadName);
+	void PrintCpuTimeL(RThread& aThread, const TDesC& aThreadName);
+	void PrintChunkInfoL(const TDesC& aProcessName);
+	void PrintSizeL(const TDesC& aCaption, TInt aSize);
+private:
+	TUint iProcessId;
+	HBufC* iMatch;
+	TBool iPrintPriority;
+	TBool iPrintThreads;
+	TBool iPrintStackInfo;
+	TBool iPrintHeapInfo;
+	TBool iPrintCpuTime;
+	TBool iPrintChunkInfo;
+	TBool iPrintFileName;
+	TBool iPrintCommandLine;
+	TBool iPrintFlags;
+	TBool iPrintMemoryInfo;
+	TBool iVerbose;
+	TBool iHuman;
+	TBool iExcludeDead;
+	TBool iOnlyDead;
+	TBool iAddresses;
+	TBool iHandleCount;
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	RMemoryAccess iMemoryAccess;
+#endif
+	TFullName iProcessName;
+	TFullName iThreadName;
+	TFullName iChunkName;
+	CTextFormatter* iFormatter;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/rdebug.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+# rdebug.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name rdebug
+
+==short-description
+
+Write a debug trace.
+
+==long-description
+
+Uses C<RDebug::Print>, the destination of which is platform dependent. However, commonly this is directed to the debug serial port. See L<debugport|debugport> command for details.
+
+==argument string message optional
+
+The text to be logged. If not specified, reads from C<stdin>.
+
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/readmem.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+# readmem.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name readmem
+
+==short-description
+
+Read a section of memory to a file (or hex / ASCII dump it to C<stdout>).
+
+==argument uint address
+
+The memory address to be read.
+
+==argument uint size
+
+The number of bytes to read.
+
+==argument filename file_name optional
+
+The name of a file to write the memory contents to. If not specified, the memory contents is hex / ASCII dumped to C<stdout>.
+
+==option int t thread_id
+
+The identifier of the thread whose context the memory is to be read from.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/reattach.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+# reattach.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name reattach
+
+==short-description
+
+Attach an existing job to a different set of I/O end points.
+
+==see-also
+
+L<jobs|jobs>, L<disown|disown>, L<start|start>
+
+==argument string job
+
+The identifier of the job the be reattached. Must be prefixed with C<%>. Note, job identifiers are listed by the L<jobs|jobs> command.
+
+==argument string stdin optional
+
+The name of the end point that the job's standard input should be reattached to. If not specified a new null end point is created and the job is attached to that.
+
+==argument string stdout optional
+
+The name of the end point that the job's standard output should be reattached to. If not specified the job is attached the same end point as its standard input.
+
+==argument string stderr optional
+
+The name of the end point that the job's standard error should be reattached to. If not specified the job is attached the same end point as its standard output.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/reboot.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# reboot.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name reboot
+
+==short-description
+
+Reboot the device, using Kern::Restart().
+
+==argument uint reason optional
+
+The reboot reason to use. If not specified, defaults to 0x40000000 which is KtRestartReasonSoftRestart in most baseports.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/repeat.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+# repeat.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name repeat
+
+==short-description
+
+Execute a command-line multiple times.
+
+==long-description
+
+On each iteration, the environment variable C<REPEAT_COUNT> is set to an integer value representing the iteration number currently being processed. This can be used, for example, to produce unique file names.
+
+==argument uint count
+
+The number of repetitions to perform. If set to zero, will repeat indefinitely.
+
+==argument string command last
+
+The command to run.
+
+==option bool k keep-going
+
+If an iteration returns an error, proceed with the next iteration. Ordinarily execution will abort if an error is returned.
+
+==option int w wait
+
+If specified, wait this number of milliseconds between iterations.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/rm.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# rm.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name rm
+
+==short-description
+
+Remove one or more files.
+
+==argument filename file_name multiple
+
+The name of the file to be removed. May contain wild characters C<*> and C<?> to specify more than one file.
+
+==option bool r recurse
+
+Also delete files in sub-directories.
+
+==option bool f force
+
+Force delete the file even if it is read-only (won't allow you to delete a directory containing read-only files).
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/rmdir.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# rmdir.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name rmdir
+
+==short-description
+
+Remove a directory.
+
+==long-description
+
+Note, only the foreground job receives data entered using the keyboard.
+
+==argument filename dir_name multiple
+
+The name of the directory to be removed.
+
+==option bool r recurse
+
+Remove sub-directories also.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/rom.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# rom.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name rom
+
+==short-description
+
+Displays information from the handset's ROM header.
+
+==option bool v verbose
+
+Display verbose information.
+
+==option bool H human
+
+Print sizes in human readable form.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/sleep.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+# sleep.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name sleep
+
+==short-description
+
+Pause for a specified number of seconds.
+
+==argument uint duration optional
+
+The length of time to sleep for in seconds. If not specified, sleeps indefinately.
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/sort.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+# sort.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name sort
+
+==short-description
+
+Alphabetically sort lines read from C<stdin> and print to C<stdout>.
+
+==long-description
+
+Note, requires enough free memory to store all the input.
+
+==option bool r reverse
+
+Reverse the sort order.
+
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/source.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,58 @@
+# source.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name source
+
+==short-description
+
+Run the specified script in the context of the current L<fshell|fshell> instance.
+
+==long-description
+
+The main reasons for using this command are:
+
+=over 5
+
+=item *
+
+To avoid the overhead of creating a separate fshell process in which to run a script.
+
+=item *
+
+To allow the environment variables of the executing fshell instance to be updated by a script.
+
+=back
+
+Note, fshell defines an environment variable named C<SCRIPT_PATH> that contains the full path to the script that is currently executing. This can be used to make scripts independent of their file system location, for example:
+
+  source $SCRIPT_PATH\some.script
+
+==see-also
+
+L<debug|debug>
+
+==argument filename script_file_name
+
+The name of the script file to be run.
+
+==argument string script_args optional last
+
+The arguments to pass to the script.
+
+==option bool k keep-going
+
+Keep processing the script even if a previous command has returned an error. Without this option set, an error would cause script processing to abort (and the source command to exit with the error code) unless either C<&&>, C<||> or C<&|> was used to handle the error.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/start.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,54 @@
+# start.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name start
+
+==short-description
+
+Starts the specified process and then completely disowns it.
+
+==long-description
+
+This is useful in the situation where you want the process to have a longer lifetime than the L<fshell|fshell> instance that created it. Note the child process does not inherit fshell's I/O handles or environment variables.
+
+==see-also
+
+L<disown|disown>, L<time|time>
+
+==argument string exe-name
+
+The executable to start.
+
+==argument string arguments optional last
+
+The arguments to pass to the exe.
+
+==option bool r rendezvous
+
+Wait for the child process to call C<RProcess::Rendezvous> before exiting. Can not be used with C<--wait>.
+
+==option bool w wait
+
+Wait for the child process to exit before exiting. May not be used with C<--rendezvous>.
+
+==option int t timeout
+
+Only relevant with either C<--rendezvous> or C<--wait>. Causes the command to abort after the specified number of seconds if the child process hasn't called C<RProcess::Rendezvous> or exited (as appropriate) in that time. If the timeout is zero or not specified, the command will wait indefinitely.
+
+==option bool m measure
+
+If specified, measure the time taken for the child process to rendezvous (if C<--rendezvous> is specified) or exit (if C<--wait> is specified). This can be more accurate than using the fshell L<time|time> command if C<exe-name> is not an fshell command, because start doesn't attempt to parse its arguments as an fshell command line (adding the overhead of variable expansion, pipeline establishment etc) or to set up iosrv connections for the child process.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/svrinfo.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+# svrinfo.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name svrinfo
+
+==short-description
+
+Print details of currently running servers.
+
+==long-description
+
+Lists the address and name of each C<DServer> object currently present in the kernel. Can optionally provided more detailed information about a specific server (see C<--verbose>).
+
+==argument uint server_address optional
+
+The address of the C<DServer> object to display information about. Note server addresses can be found by running C<svrinfo> with no arguments.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/tee.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+# tee.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name tee
+
+==short-description
+
+Copies stdin to stdout and additionally to a file.
+
+==long-description
+
+Copies standard input to standard output and also to any files given as arguments. This is useful when you want not only want to see a command's output on the console, but also to save a copy.
+
+==argument filename file multiple optional
+
+The file to be written.
+
+==option bool a append
+
+If specified, append to the file(s) if it already exists, rather than overwriting it. The default is to create the file if it doesn't already exist, and overwrite it if it does.
+
+==option bool r rdebug
+
+If specified, send the output to RDebug::Print as well as to stdout and any specified files.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/tickle.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# tickle.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name tickle
+
+==short-description
+
+Reset's the OS's inactivity timer.
+
+==long-description
+
+Calls C<User::ResetInactivtyTime> to wake the system up.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ticks.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# ticks.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name ticks
+
+==short-description
+
+Print the current tick counts.
+
+==option bool v verbose
+
+Display verbose information.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/time.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+# time.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name time
+
+==short-description
+
+Report how long it takes to execute a command.
+
+==argument string command last
+
+The command to run.
+
+==option bool H human
+
+Print the execution time in human readable form.
+
+==option bool f fast-counter
+
+Use the kernel's fast counter rather than the nano-kernel tick. Note, if available, the fast counter normally has significantly higher resolution.
+
+==option int r repeat
+
+If specified, call the command this number of times and print out the average time taken.
+
+==see-also
+
+L<start|start>
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/touch.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+# touch.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name touch
+
+==short-description
+
+Updates the last-modified date of the specified file to be the current date.
+
+==long-description
+
+If file does not exist it is created and its size is set to zero bytes.
+
+==argument filename file
+
+The file to touch.
+
+
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/trace.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,85 @@
+# trace.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name trace
+
+==short-description
+
+Edit the flags that control kernel and file server tracing.
+
+==long-description
+
+If no debug_mask (and no fileserver options) is specified, the current values of all the trace flags are displayed.
+
+Fileserver trace flags can be specified by name, using the C<--f32> and related options. A subsequent call to the trace command will overwrite what was previously specified. For example see the following sequence of calls:
+
+    trace --f32       # General fileserver traces enabled
+    trace --fat       # FAT traces enabled, but general traces NO LONGER enabled
+    trace --f32 --fat # Both sets of traces are enabled
+    trace             # This will turn off all fileserver tracing
+
+==argument uint debug_mask optional
+
+The kernel debug mask value (prefix hex with "0x").
+
+==argument uint index optional
+
+The kernel debug mask index.
+
+==option bool s f32
+
+Enable general file server traces.
+
+==option bool m multi-thread
+
+Enable general multi-threaded file server traces.
+
+==option bool l loader
+
+Enable loader traces.
+
+==option bool f fat
+
+Enable FAT traces.
+
+==option bool t lffs
+
+Enable LFFS traces.
+
+==option bool i iso9660
+
+Enable ISO9660 traces.
+
+==option bool n ntfs
+
+Enable NTFS traces.
+
+==option bool o rofs
+
+Enable ROFS traces.
+
+==option bool c compfs
+
+Enable COMPFS traces.
+
+==option string e enable multiple
+
+Enable the given trace flag. Eg C<trace --enable kusb>.
+
+==option string d disable multiple
+
+Disable the given trace flag. Eg C<trace --disable kusb>.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/undertaker.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# undertaker.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name undertaker
+
+==short-description
+
+Prints details of any thread in the system that exits abnormally.
+
+==option bool a all
+
+Print details of all thread exits (even normal ones).
+
+==option bool n noclose
+
+Don't close the handles of the exited threads. This is useful during debugging to ensure the DThreads are not deleted until this command exits.
+
+==option bool p paranoid
+
+Tries to ensure notifications are not missed, by manipulating thread priorities and spawning a worker thread.
+
+==copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/undertaker.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,229 @@
+// undertaker.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/iocli.h>
+#include "undertaker.h"
+
+TInt CCmdUndertaker::Queue()
+	{
+	TInt err = iUndertaker.Logon(iStatus, iDeadThreadHandle);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+void CCmdUndertaker::DoCancel()
+	{
+	iUndertaker.LogonCancel();
+	}
+
+void CCmdUndertaker::RunL()
+	{
+	TInt handle = iDeadThreadHandle;
+	Queue(); // Queue early, to try and avoid missing notifications
+	// We don't use the RunL if we're in paranoid mode - the undertaker notifications are serviced directly in DoWork() without an active scheduler
+	ProcessHandle(handle);
+	}
+	
+void CCmdUndertaker::ProcessHandle(TInt aDeadThreadHandle)
+	{
+	RThread deadThread;
+	deadThread.SetHandle(aDeadThreadHandle);
+	TFullName name(deadThread.FullName());
+	TExitType type = deadThread.ExitType();
+	if (type != EExitKill || deadThread.ExitReason() != 0 || iAll)
+		{
+		Write(_L("Thread "));
+		Write(name);
+		Printf(_L(" (tid=%d) "), (TUint)deadThread.Id());
+		}
+
+	if (type == EExitPanic)
+		{
+		TExitCategoryName cat = deadThread.ExitCategory();
+		Printf(_L("panicked with %S %d\r\n"), &cat, deadThread.ExitReason());
+		}
+	else if (type == EExitTerminate)
+		{
+		Printf(_L("terminated with reason %d\r\n"), deadThread.ExitReason());
+		}
+	else if (deadThread.ExitReason() != 0)
+		{
+		// We'll consider a kill with non-zero exit code as counting as abnormal
+		Printf(_L("killed with reason %d\r\n"), deadThread.ExitReason());
+		}
+	else if (iAll)
+		{
+		Printf(_L("exited cleanly\r\n"));
+		}
+		
+	if (!iLeakThreads)
+		{
+		deadThread.Close();
+		}
+	}
+
+CCommandBase* CCmdUndertaker::NewLC()
+	{
+	CCmdUndertaker* self = new(ELeave) CCmdUndertaker();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CCmdUndertaker::~CCmdUndertaker()
+	{
+	Cancel();
+	if (iWorkerThread.Id() != RThread().Id()) iWorkerThread.Kill(KErrAbort);
+	iHandles.Close();
+	CloseProcessOwnedHandles();
+	}
+
+CCmdUndertaker::CCmdUndertaker()
+	: CMemoryAccessCommandBase(EManualComplete)
+	{
+	}
+
+void CCmdUndertaker::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CCmdUndertaker::Name() const
+	{
+	_LIT(KName, "undertaker");
+	return KName;
+	}
+
+void CCmdUndertaker::DoRunL()
+	{	
+	User::LeaveIfError(iUndertaker.Create());
+
+	if (iParanoid)
+		{
+		User::LeaveIfError(iMainThread.Open(RThread().Id()));
+		User::LeaveIfError(iLock.CreateLocal());
+		iHandles.ReserveL(10);
+		TFullName threadName(RThread().Name());
+		threadName.Append(_L("_worker"));
+		LeaveIfErr(iWorkerThread.Create(threadName, &WorkerThreadFn, 8192, NULL, this), _L("Couldn't create worker thread"));
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+		LoadMemoryAccessL();
+		LeaveIfErr(iMemAccess.SetThreadPriority(iWorkerThread, 31), _L("Couldn't set worker thread priority with memoryaccess"));
+#else
+		iWorkerThread.SetPriority(EPriorityMuchMore); // Best we can do
+#endif
+		iWorkerThread.Resume();
+		}
+	else
+		{
+		User::LeaveIfError(Queue());
+		}	
+		
+	if (Stdin().IsForeground() > 0)
+		{
+		Write(iAll ? _L("Waiting for any thread exit...\r\n") : _L("Waiting for panicked thread exit...\r\n"));
+		}
+		
+	if (iParanoid)
+		{
+		// We've spawned off our worker thread, which is the client of the RUndertaker. We now wait for it to signal us back again.
+		// It's easier to balance the requests if we don't go through the active scheduler (so long as nothing else signals this thread!)
+		for (;;)
+			{
+			User::WaitForRequest(iMainThreadStat);
+			if (iMainThreadStat.Int() != KErrNone) User::Leave(iMainThreadStat.Int());
+			iLock.Wait();
+			TInt handle = iHandles[0];
+			iHandles.Remove(0);
+			iLock.Signal();
+			ProcessHandle(handle);
+			}
+		}
+	}
+
+void CCmdUndertaker::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptAll, "all");
+	_LIT(KOptNoClose, "noclose");
+	_LIT(KOptParanoid, "paranoid");
+	aOptions.AppendBoolL(iAll, KOptAll);
+	aOptions.AppendBoolL(iLeakThreads, KOptNoClose);
+	aOptions.AppendBoolL(iParanoid, KOptParanoid);
+	}
+
+TInt CCmdUndertaker::WorkerThreadFn(TAny* aSelf)
+	{
+	CCmdUndertaker* self = static_cast<CCmdUndertaker*>(aSelf);
+	return self->DoWork();
+	}
+	
+TInt CCmdUndertaker::DoWork()
+	{
+	TRequestStatus mainThreadDeadStat;
+	iMainThread.Logon(mainThreadDeadStat);
+	
+	TRequestStatus stat;
+	TInt deadThreadHandle;
+	TInt err = KErrNone;
+	for (;;)
+		{
+		err = iUndertaker.Logon(stat, deadThreadHandle);
+		TRequestStatus* s = &iMainThreadStat;
+		if (err)
+			{
+			iMainThread.RequestComplete(s, err);
+			break;
+			}
+		else
+			{
+			User::WaitForRequest(stat, mainThreadDeadStat);
+			if (mainThreadDeadStat.Int() != KRequestPending)
+				{
+				// We're dead
+				err = mainThreadDeadStat.Int();
+				// Have to clean up our process-owned handles here...
+				CloseProcessOwnedHandles();
+				break;
+				}
+			// Have to duplicate the thread handle so the main thread can see it. Can't seem to persuade RUndertaker to give us a process-owned handle in the first place
+			RThread origHandle;
+			origHandle.SetHandle(deadThreadHandle);
+			RThread newHandle(origHandle);
+			err = newHandle.Duplicate(RThread(), EOwnerProcess);
+			origHandle.Close();
+			if (!err)
+				{
+				iLock.Wait();
+				err = iHandles.Append(newHandle.Handle());
+				iLock.Signal();
+				}
+			iMainThread.RequestComplete(s, err);
+			}
+		}
+	return err;
+	}
+
+void CCmdUndertaker::CloseProcessOwnedHandles()
+	{
+	iMainThread.Close();
+	iWorkerThread.Close();
+	iUndertaker.Close();
+	iLock.Close();
+	}
+
+#ifdef EXE_BUILD
+EXE_BOILER_PLATE(CCmdUndertaker)
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/undertaker.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+// undertaker.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef UNDERTAKER_H
+#define UNDERTAKER_H
+
+#include <fshell/ioutils.h>
+#include <fshell/memoryaccesscmd.h>
+
+using namespace IoUtils;
+
+class CCmdUndertaker : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdUndertaker();
+private:
+	CCmdUndertaker();
+	void ConstructL();
+	TInt Queue();
+	void ProcessHandle(TInt aDeadThreadHandle);
+	static TInt WorkerThreadFn(TAny* aSelf);
+	TInt DoWork();
+	void CloseProcessOwnedHandles();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From CActive
+	void RunL();
+	void DoCancel();
+
+private:
+	TInt iDeadThreadHandle;
+	RUndertaker iUndertaker;
+	TBool iAll;
+	TBool iLeakThreads;
+	TBool iParanoid;
+	// The following are only used if in paranoid mode
+	RFastLock iLock;
+	RArray<TInt> iHandles;
+	RThread iWorkerThread;
+	RThread iMainThread;
+	TRequestStatus iMainThreadStat;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/uptime.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# uptime.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name uptime
+
+==short-description
+
+Print the number of microseconds since the handset was booted.
+
+==option bool H human
+
+Print time in human readable form.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/var.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+# var.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name var
+
+==short-description
+
+Perform an operation involving environment variables.
+
+==long-description
+
+This command returns zero (KErrNone) in the success case, and a non-zero positive code otherwise. Usage:
+
+    var SOMETHING defined # Doesn't cause an error, returns '1'
+    var SOMETHING defined && echo Defined # Nothing is echoed
+    export SOMETHING 1
+    var SOMETHING defined && echo Defined # "Defined" will be printed
+    var SOMETHING == 1 && echo "Equal" # "Equal" will be printed
+    var SOMETHING add 3 && echo "$SOMETHING" # $SOMETHING now has value "4"
+
+C<==> and C<!=> are text comparisons not numerical, and all environment variables are strings, so the following will I<not> work:
+
+    export VAL 16
+    var VAL == 0x10 && echo Equal # Error! "16" does not equal "0x10"
+
+==argument string variable
+
+The environment variable to be operated on.
+
+==argument enum operation
+
+The operation to be performed.
+
+==enum-value defined
+
+Test if the specified environment variable is defined.
+
+==enum-value not-defined
+
+Opposite of C<defined>.
+
+==enum-value ==
+
+Tests if the specified environment variable is an exact string match for the supplied argument.
+
+==enum-value !=
+
+Opposite of C<==>.
+
+==enum-value add
+
+Assume that the specified environment variable holds an integer, and adds the value given by the argument to it. If the variable isn't defined or doesn't contain a decimal integer, it is assumed to have value zero.
+
+==enum-value subtract
+
+Subtracts the given value from the environment variable. Semantics as per add.
+
+==argument string argument optional
+
+The argument to the operation.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/version.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# version.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name version
+
+==short-description
+
+Display the version of this build of fshell.
+
+==option bool v verbose
+
+Display verbose version information.
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/version.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,49 @@
+// version.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "version.h"
+
+// Note, this function is generated by "group\genver.pl".
+extern void PrintVersionInfo(RIoWriteHandle& aOut, TBool aVerbose);
+
+CCommandBase* CCmdVersion::NewLC()
+	{
+	CCmdVersion* self = new(ELeave) CCmdVersion();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdVersion::~CCmdVersion()
+	{
+	}
+
+CCmdVersion::CCmdVersion()
+	{
+	}
+
+const TDesC& CCmdVersion::Name() const
+	{
+	_LIT(KName, "version");	
+	return KName;
+	}
+
+void CCmdVersion::DoRunL()
+	{
+	PrintVersionInfo(Stdout(), iVerbose);
+	}
+
+void CCmdVersion::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/version.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// version.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+class CCmdVersion : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdVersion();
+private:
+	CCmdVersion();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iVerbose;
+	};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/which.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+# which.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name which
+
+==short-description
+
+Prints the location of a particular fshell command or exe.
+
+==argument string command
+
+The command or exe to locate.
+
+==copyright
+
+Copyright (c) 2006-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/xmodem.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+# xmodem.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==name xmodem
+
+==short-description
+
+An implementation of the XMODEM file transfer protocol.
+
+==long-description
+
+Note, where possible it is recommended that the alternative C<ymodem> command is used rather than C<xmodem>. This is because C<xmodem> has the unhelpful side effect of appending 0x1a characters to the end of the file being transferred. C<ymodem> on the other hand, knows how long the file being transferred is and so can avoid this problem. It is also able to transfer multiple files in a batch and allows the sending end to specify their names. Note also that the console implementation that ymodem is attached to must support binary mode. If it doesn't, C<KErrExtensionNotSupported> (-47) will be reported. In practice, this currently means that one of the vt100 console variants (F<vt100cons.dll>, F<vt100busdevcons.dll>, F<vt100usbcons.dll>, F<vt100btcons.dll> or F<vt100tcpcons.dll>) must be used.
+
+==argument enum mode
+
+The required mode.
+
+==enum-value send
+
+==enum-value receive
+
+==argument filename file_name optional
+
+The name of the file to be read or written. If not specified, reads will be written to STDOUT and writes will be read from STDIN.
+
+==option bool v verbose
+
+Print progress information to STDERR. Only use this if STDERR is attached to something other than STDOUT (e.g. a file).
+
+==option bool o overwrite
+
+Overwrite any files that already exist.
+
+==see-also
+
+L<ymodem|ymodem>
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/xmodem.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1029 @@
+// xmodem.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include "xmodem.h"
+
+using namespace IoUtils;
+
+const TInt KMaxRetries = 5;
+const TInt KSmallBlockSize = 128;
+const TInt KLargeBlockSize = 1024;
+const TInt KLongTimeout = 60;
+const TInt KMediumTimeout = 10;
+const TInt KShortTimeout = 1;
+const TUint8 KByteSoh = 0x01;
+const TUint8 KByteStx = 0x02;
+const TUint8 KByteEot = 0x04;
+const TUint8 KByteAck = 0x06;
+const TUint8 KByteNak = 0x15;
+const TUint8 KByteCan = 0x18;
+const TUint8 KByteSub = 0x1a;
+const TUint8 KByteTelnetIac = 0xff;
+const TUint8 KByteTelnetDo = 0xfd;
+const TUint8 KByteTelnetWill = 0xfb;
+const TUint8 KByteTelnetBinaryMode = 0x00;
+_LIT(KLitEot, "\x04");
+_LIT(KLitAck, "\x06");
+_LIT(KLitNak, "\x15");
+_LIT(KLitCancel, "\x18\x18\x18");
+_LIT(KLitC, "C");
+_LIT(KLitTelnetDoBinaryMode, "\xff\xfd\x00");
+_LIT(KLitTelnetWillBinaryMode, "\xff\xfb\x00");
+
+#ifdef FSHELL_CORE_SUPPORT_XMODEM_CRCNOTAB
+
+TUint16 Crc16(const TDesC& aData)
+	{
+	TInt crc	= 0;
+	const TInt length = aData.Length();
+	for (TInt i = 0; i < length; ++i)
+		{
+		crc = crc ^ ((TInt)(aData[i]&0x00FF) << 8);
+		for (TInt j = 0; j < 8; ++j)
+			{
+			if (crc & 0x8000)
+				{
+				crc = crc << 1 ^ 0x1021;
+				}
+			else
+				{
+				crc = crc << 1;
+				}
+			}
+		}
+	return (crc	& 0xFFFF);
+	}
+
+#else
+
+static TUint16 KCrc16Tab[256]= {
+	0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
+	0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
+	0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,
+	0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,
+	0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,
+	0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d,
+	0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4,
+	0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,
+	0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,
+	0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b,
+	0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,
+	0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,
+	0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,
+	0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49,
+	0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,
+	0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,
+	0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f,
+	0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067,
+	0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,
+	0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,
+	0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d,
+	0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,
+	0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,
+	0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634,
+	0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab,
+	0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,
+	0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,
+	0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92,
+	0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9,
+	0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,
+	0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,
+	0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0
+};
+  
+TUint16 Crc16(const TDesC& aData)
+	{
+	TUint16 crc = 0;
+	const TInt length = aData.Length();
+	for (TInt i = 0; i < length; ++i)
+		{
+		crc = (crc<<8) ^ KCrc16Tab[((crc>>8) ^ (TUint8)aData[i])&0x00FF];
+		}
+	return crc;
+	}
+
+#endif // FSHELL_CORE_SUPPORT_XMODEM_CRCNOTAB
+
+CCommandBase* CCmdXmodem::NewLC()
+	{
+	CCmdXmodem* self = new(ELeave) CCmdXmodem();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	self->ConstructL();
+	return self;
+	}
+
+CCmdXmodem::~CCmdXmodem()
+	{
+	delete iBuf;
+	iTimer.Close();
+	}
+
+CCmdXmodem::CCmdXmodem() : iBlockSize(KSmallBlockSize), iPacketNumber(1)
+	{
+	}
+
+void CCmdXmodem::ConstructL()
+	{
+	User::LeaveIfError(iTimer.CreateLocal());
+	}
+
+TUint8 CCmdXmodem::ReceiveByteL(TInt aTimeout, TBool* aTimeoutOccurred)
+	{
+	return (TUint8)ReceiveShortL(aTimeout, aTimeoutOccurred);
+	}
+
+TUint16 CCmdXmodem::ReceiveShortL(TInt aTimeout, TBool* aTimeoutOccurred)
+	{
+	TBuf<1> buf;
+	ReceiveWithTimeoutL(buf, aTimeout, aTimeoutOccurred);
+	if (buf.Length() == 1)
+		{
+		return buf[0];
+		}
+	return 0;
+	}
+
+void CCmdXmodem::ReceiveWithTimeoutL(TDes& aBuf, TInt aTimeout, TBool* aTimeoutOccurred)
+	{
+	aBuf.Zero();
+	TBool timeOutOccurred(EFalse);
+
+	if (iTelnetMode & ERecvBinary)
+		{
+		TBool prevReceiveEndedWithIac(EFalse);
+		while ((aBuf.Length() < aBuf.MaxLength()) && !timeOutOccurred)
+			{
+			TPtr ptr(const_cast<TUint16*>(aBuf.Ptr()) + aBuf.Length(), 0, aBuf.MaxLength() - aBuf.Length()); // Create a TPtr over the unused part of aBuf.
+			DoReceiveWithTimeoutL(ptr, aTimeout, &timeOutOccurred);
+			if (!timeOutOccurred)
+				{
+				if (prevReceiveEndedWithIac && (ptr.Length() >= 1) && (ptr[0] == KByteTelnetIac))
+					{
+					ptr.Delete(0, 1);
+					}
+				prevReceiveEndedWithIac = EFalse;
+				TInt numChars = ptr.Length();
+				for (TInt i = 0; i < numChars; ++i)
+					{
+					if (ptr[i] == KByteTelnetIac)
+						{
+						if ((i < (numChars - 1)) && (ptr[i + 1] == KByteTelnetIac))
+							{
+							ptr.Delete(i, 1);
+							--numChars;
+							}
+						else if (i == (numChars - 1))
+							{
+							prevReceiveEndedWithIac = ETrue;
+							}
+						}
+					}
+				aBuf.SetLength(aBuf.Length() + ptr.Length());
+				}
+			}
+		}
+	else
+		{
+		DoReceiveWithTimeoutL(aBuf, aTimeout, &timeOutOccurred);
+		}
+
+	if (!timeOutOccurred)
+		{
+		Progress(_L("Received:\r\n"));
+		Dump(aBuf);
+		}
+
+	if (aTimeoutOccurred)
+		{
+		*aTimeoutOccurred = timeOutOccurred;
+		}
+	}
+
+void CCmdXmodem::DoReceiveWithTimeoutL(TDes& aBuf, TInt aTimeout, TBool* aTimeoutOccurred)
+	{
+	iStarted = ETrue;
+	aBuf.Zero();
+	if (aBuf.MaxLength() <= iUngetBuf.Length())
+		{
+		aBuf.Copy(iUngetBuf.Mid(0, aBuf.MaxLength()));
+		iUngetBuf.Delete(0, aBuf.MaxLength());
+		Progress(_L("Received (from unget buf):\r\n"));
+		Dump(aBuf);
+		}
+	else
+		{
+		aBuf.Copy(iUngetBuf);
+		TPtr ptr(const_cast<TUint16*>(aBuf.Ptr()) + aBuf.Length(), 0, aBuf.MaxLength() - aBuf.Length()); // Create a TPtr over the unused part of aBuf.
+		iUngetBuf.Zero();
+		TRequestStatus readStatus;
+		TRequestStatus timeoutStatus;
+		iTimer.After(timeoutStatus, aTimeout * 1000000);
+		Stdin().Read(aBuf, readStatus);
+		User::WaitForRequest(readStatus, timeoutStatus);
+		if (readStatus == KRequestPending)
+			{
+			Progress(_L("Timeout expired, cancelling read...\r\n"));
+			if (aTimeoutOccurred)
+				{
+				*aTimeoutOccurred = ETrue;
+				}
+			Stdin().ReadCancel();
+			User::WaitForRequest(readStatus);
+			return;
+			}
+		else
+			{
+			if (aTimeoutOccurred)
+				{
+				*aTimeoutOccurred = EFalse;
+				}
+			iTimer.Cancel();
+			User::WaitForRequest(timeoutStatus);
+			User::LeaveIfError(readStatus.Int());
+			aBuf.SetLength(aBuf.Length() + ptr.Length());
+			Progress(_L("Received (raw):\r\n"));
+			Dump(aBuf);
+			return;
+			}
+		}
+	}
+
+void CCmdXmodem::PurgeInputL()
+	{
+	Progress(_L("Purging input...\r\n"));
+	TBool timeoutOccurred;
+	do
+		{
+		ReceiveByteL(KShortTimeout, &timeoutOccurred);
+		if (timeoutOccurred)
+			{
+			Progress(_L("Timed out\r\n"));
+			}
+		else
+			{
+			Progress(_L("Received byte\r\n"));
+			}
+		}
+		while (!timeoutOccurred);
+	}
+
+void CCmdXmodem::SendL(const TDesC& aData)
+	{
+	Progress(_L("Sending:\r\n"));
+	Dump(aData);
+	iStarted = ETrue;
+
+	if (iTelnetMode & ESendBinary)
+		{
+		const TInt numChars = aData.Length();
+		TInt numIacs = 0;
+		for (TInt i = 0; i < numChars; ++i)
+			{
+			if (aData[i] == KByteTelnetIac)
+				{
+				++numIacs;
+				}
+			}
+		if (numIacs > 0)
+			{
+			Progress(_L("Escaping %d IACs\r\n"), numIacs);
+			HBufC* newBuf = HBufC::NewLC(aData.Length() + numIacs);
+			TPtr newBufPtr(newBuf->Des());
+			for (TInt i = 0; i < numChars; ++i)
+				{
+				if (aData[i] == KByteTelnetIac)
+					{
+					newBufPtr.Append(KByteTelnetIac);
+					}
+				newBufPtr.Append(aData[i]);
+				}
+			Dump(*newBuf);
+			User::LeaveIfError(Stdout().Write(*newBuf));
+			CleanupStack::PopAndDestroy(newBuf);
+			}
+		else
+			{
+			User::LeaveIfError(Stdout().Write(aData));
+			}
+		}
+	else
+		{
+		User::LeaveIfError(Stdout().Write(aData));
+		}
+	}
+
+TInt CCmdXmodem::CheckSize() const
+	{
+	if (iCrc)
+		{
+		return 2;
+		}
+	else
+		{
+		return 1;
+		}
+	}
+
+TInt CCmdXmodem::ProtocolOverhead() const
+	{
+	return 3 + CheckSize();
+	}
+
+TBool CCmdXmodem::CheckBlock() const
+	{
+	TBool match(EFalse);
+
+	if (iCrc)
+		{
+		TUint16 crc = Crc16(iBuf->Mid(2, iBlockSize));
+		TUint16 receivedCrc = ((*iBuf)[iBlockSize + 2] << 8) + (*iBuf)[iBlockSize + 3];
+		match = (crc == receivedCrc);
+		if (!match)
+			{
+			Progress(_L("CRC failed (calculated %u, received %u)\r\n"), crc, receivedCrc);
+			}
+		}
+	else
+		{
+		TUint8 sum = 0;
+		for (TInt i = 2; i < (iBlockSize + 2); ++i)	// Plus 2 because iBuf contains the two packet number bytes.
+			{
+			sum += (*iBuf)[i];
+			}
+		TUint8 received = (*iBuf)[iBlockSize + 2];
+		match = (sum == received);
+		if (!match)
+			{
+			Progress(_L("CheckSum failed (calculated %u, received %u)\r\n"), sum, received);
+			}
+		}
+
+	return match;
+	}
+
+void CCmdXmodem::Progress(TRefByValue<const TDesC> aFmt, ...) const
+	{
+	if (iVerbose)
+		{
+		TOverflowTruncate overflow;
+		VA_LIST list;
+		VA_START(list, aFmt);
+		TBuf<0x100> buf;
+		buf.AppendFormatList(aFmt, list, &overflow);
+		const_cast<CCmdXmodem*>(this)->Stderr().Write(buf);
+		}
+	}
+
+void CCmdXmodem::Dump(const TDesC& aData)
+	{
+	if (iVerbose)
+		{
+		TBuf<80> out;
+		TBuf<16> ascii;
+		TInt dataIndex = 0;
+		TInt pos = 0;
+		do
+			{
+			out.Zero();
+			ascii.Zero();
+			out.AppendNumFixedWidthUC(pos, EHex, 8);
+			out.Append(_L(": "));
+			for (TInt i = 0; i < 16; ++i)
+				{
+				if (dataIndex < aData.Length())
+					{
+					TUint8 byte = (TUint8)aData[dataIndex++];
+					out.AppendNumFixedWidthUC(byte, EHex, 2);
+					out.Append(_L(" "));
+					if ((byte < 0x20) || (byte >= 0x7f) || byte == '%')
+						{
+						byte = '.';
+						}
+					ascii.Append(TChar(byte));
+					++pos;
+					}
+				else
+					{
+					out.Append(_L("   "));
+					}
+				}
+			out.Append(ascii);
+			out.Append(_L("\r\n"));
+			Stderr().Write(out);
+			}
+			while (dataIndex < aData.Length());
+		}
+	}
+
+void CCmdXmodem::Abort()
+	{
+	TRAP_IGNORE(
+				SendL(KLitCancel);
+				PurgeInputL();
+				);
+	}
+
+void CCmdXmodem::WaitForSyncL()
+	{
+	Progress(_L("Waiting for sync...\r\n"));
+	for (TInt numRetries = 0; numRetries < KMaxRetries; ++numRetries)
+		{
+		switch (ReceiveByteL(KLongTimeout))
+			{
+			case 'C':
+				Progress(_L("Receiver supports CRC\r\n"));
+				iCrc = ETrue;
+				return;
+			case KByteNak:
+				Progress(_L("Receiver does not support CRC\r\n"));
+				iCrc = EFalse;
+				return;
+			case KByteCan:
+				Progress(_L("Receiver cancelled\r\n"));
+				SendL(KLitAck);
+				User::Leave(KErrCancel);
+				break;
+			case KByteTelnetIac:
+				HandleTelnetCommandL();
+				break;
+			default:
+				break;
+			}
+		}
+
+	Progress(_L("Failed to sync\r\n"));
+	SendL(KLitCancel);
+	User::Leave(KErrCancel);
+	}
+
+CCmdXmodem::TSyncResult CCmdXmodem::SendSyncL()
+	{
+	Progress(_L("Sending sync...\r\n"));
+	iCrc = ETrue;
+	const TDesC* syncLit = &KLitC();
+	FOREVER
+		{
+		TBool skipNextSync(EFalse);
+		for (TInt numRetries = 0; numRetries < KMaxRetries; ++numRetries)
+			{
+			if (skipNextSync)
+				{
+				skipNextSync = EFalse;
+				}
+			else
+				{
+				SendL(*syncLit);
+				}
+			switch (ReceiveByteL(KMediumTimeout))
+				{
+				case KByteSoh:
+					Progress(_L("Using 128 byte block size\r\n"));
+					iBlockSize = KSmallBlockSize;
+					return ENormal;
+				case KByteStx:
+					Progress(_L("Using 1024 byte block size\r\n"));
+					iBlockSize = KLargeBlockSize;
+					return ENormal;
+				case KByteCan:
+					Progress(_L("Sender cancelled\r\n"));
+					SendL(KLitAck);
+					PurgeInputL();
+					User::Leave(KErrCancel);
+					break;
+				case KByteEot:
+					Progress(_L("Received EOT\r\n"));
+					SendL(KLitAck);
+					return EEot;
+				case KByteTelnetIac:
+					HandleTelnetCommandL();
+					--numRetries;
+					skipNextSync = ETrue; // This is to avoid HyperTerminal complaining about an "Unexpected response".
+					break;
+				default:
+					break;
+				}
+			}
+		if (syncLit == &KLitC)
+			{
+			Progress(_L("Sender doesn't support CRC\r\n"));
+			syncLit = &KLitNak;
+			iCrc = EFalse;
+			}
+		else
+			{
+			Progress(_L("Failed to sync\r\n"));
+			SendL(KLitCancel);
+			User::Leave(KErrCancel);
+			}
+		}
+	}
+
+TBool IsValidTelnetCommand(TChar aChar)
+	{
+	return (aChar == KByteTelnetDo) || (aChar == KByteTelnetWill);
+	}
+
+void CCmdXmodem::HandleTelnetCommandL()
+	{
+	Progress(_L("Received (what looks like) the start of a Telnet command\r\n"));
+	TBuf<1> buf;
+	TBool timedOut(EFalse);
+	ReceiveWithTimeoutL(buf, KShortTimeout, &timedOut);
+	if (!timedOut)
+		{
+		TChar command = buf[0];
+		if (IsValidTelnetCommand(command))
+			{
+			Progress(_L("Valid telnet command received\r\n"));
+			timedOut = EFalse;
+			ReceiveWithTimeoutL(buf, KShortTimeout, &timedOut);
+			if (timedOut)
+				{
+				Progress(_L("Timed-out, ungetting last character... (2)\r\n"));
+				Unget(command);
+				}
+			else if (buf[0] == KByteTelnetBinaryMode)
+				{
+				if (command == KByteTelnetDo)
+					{
+					iTelnetMode &= (~ESendBinary);
+					SendL(KLitTelnetWillBinaryMode);
+					iTelnetMode |= ESendBinary;
+					Progress(_L("Set ESendBinary\r\n"));
+					}
+				else if (command == KByteTelnetWill)
+					{
+					TBool enableSend = iTelnetMode & ESendBinary;
+					iTelnetMode &= (~ESendBinary);
+					SendL(KLitTelnetDoBinaryMode);
+					iTelnetMode |= ERecvBinary;
+					Progress(_L("Set ERecvBinary\r\n"));
+					if (enableSend)
+						{
+						iTelnetMode |= ESendBinary;
+						}
+					}
+				else
+					{
+					ASSERT(EFalse);
+					}
+				}
+			else
+				{
+				Progress(_L("Unknown command option, ungetting last two characters...\r\n"));
+				Unget(command);
+				Unget(buf[0]);
+				}
+			}
+		else
+			{
+			Progress(_L("Timed-out, ungetting last character... (1)\r\n"));
+			Unget(command);
+			}
+		}
+	Progress(_L("Telnet command handled - resuming...\r\n"));
+	}
+
+void CCmdXmodem::Unget(TChar aChar)
+	{
+	ASSERT(iUngetBuf.Length() <= 1);
+	iUngetBuf.Append(aChar);
+	}
+
+void CCmdXmodem::PrepareConsoleToTransferL()
+	{
+	Write(_L("Please start the file transfer in your terminal...\r\n"));
+	User::LeaveIfError(Stdin().CaptureAllKeys());			// To prevent other things (like fshell) interpreting binary data as special key presses (like cntrl-C).
+	LeaveIfErr(Stdin().SetMode(RIoReadWriteHandle::EBinary), _L("Unable to set stdin to binary mode"));	// To prevent vt100cons from scanning for ANSI escape sequences. 
+	LeaveIfErr(Stdout().SetMode(RIoReadWriteHandle::EBinary), _L("Unable to set stdout to binary mode")); // To tell iosrv to not mess about with line endings.
+	}
+
+void CCmdXmodem::CleanupClonsoleAfterTransferL()
+	{
+	PurgeInputL();
+	LeaveIfErr(Stdin().SetMode(RIoReadWriteHandle::EText), _L("Unable to set stdin back to text mode"));
+	LeaveIfErr(Stdout().SetMode(RIoReadWriteHandle::EText), _L("Unable to set stdout back to text mode"));
+	if (Stdout().AttachedToConsole())
+		{
+		RIoConsoleWriteHandle stdout = Stdout();
+		TPoint pos(stdout.GetCursorPosL());
+		stdout.SetCursorPosAbsL(TPoint(0, pos.iY));
+		stdout.ClearToEndOfLineL();
+		}
+	}
+
+void CCmdXmodem::SendBlockL(const TDesC& aBlock)
+	{
+	Progress(_L("Sending block...\r\n"));
+	ASSERT(aBlock.Length() <= iBlockSize);
+
+	if (iBuf == NULL)
+		{
+		iBuf = HBufC::NewL(iBlockSize + ProtocolOverhead());
+		}
+
+	TPtr buf(iBuf->Des());
+
+	FOREVER
+		{
+		buf.Zero();
+		buf.Append((TUint16)KByteSoh);
+		buf.Append((TUint16)iPacketNumber);
+		buf.Append((TUint16)((TUint8)(~iPacketNumber)));
+		buf.Append(aBlock);
+		if (aBlock.Length() < iBlockSize)
+			{
+			// There's not enough data to fill this block, so pad with SUB.
+			buf.AppendFill((TUint16)KByteSub, iBlockSize - aBlock.Length());
+			}
+		if (iCrc)
+			{
+			TUint16 crc = Crc16(buf.Mid(3, iBlockSize));
+			buf.Append((crc >> 8) & 0xFF);
+			buf.Append(crc & 0xFF);
+			}
+		else
+			{
+			TUint8 sum = 0;
+			for (TInt i = 3; i < (iBlockSize + 3); ++i)
+				{
+				sum += (*iBuf)[i];
+				}
+			buf.Append((TUint16)sum);
+			}
+
+		Progress(_L("Sending block %d\r\n"), iPacketNumber);
+
+		for (TInt numRetries = 0; numRetries < KMaxRetries; ++numRetries)
+			{
+			SendL(*iBuf);
+			TBool timedOut(EFalse);
+			TUint8 byte = ReceiveByteL(KLongTimeout, &timedOut);
+			if (timedOut)
+				{
+				User::Leave(KErrTimedOut);
+				}
+			switch (byte) 
+				{
+				case KByteAck:
+					Progress(_L("Block %d successfully sent\r\n"), iPacketNumber);
+					++iPacketNumber;
+					return;
+				case KByteCan:
+					Progress(_L("Receiver cancelled\r\n"));
+					SendL(KLitAck);
+					PurgeInputL();
+					User::Leave(KErrCancel);
+					break;
+				case KByteNak:
+					Progress(_L("Block NAK'd, sending again...\r\n"));
+					break;
+				default:
+					Progress(_L("Unexpected response (0x%x), sending again...\r\n"), byte);
+					break;
+				}
+			}
+		}
+	}
+
+TPtrC CCmdXmodem::ReceiveBlockL(TBool aIsFirstBlock, TBool& aIsFinalBlock)
+	{
+	_LIT(KFirst, "first ");
+	Progress(_L("Receiving %Sblock...\r\n"), aIsFirstBlock ? &KFirst : &KNullDesC);
+	TPtrC ret(NULL, 0);
+	TInt repeats = 0;
+	aIsFinalBlock = EFalse;
+
+	if (iBuf == NULL)
+		{
+		iBuf = HBufC::NewL(iBlockSize + ProtocolOverhead());
+		}
+	if (!aIsFirstBlock)	// The first byte of the first block should have already been read by SendSyncL.
+		{
+again:
+		iBuf->Des().Zero();
+		TInt numRetries;
+		for (numRetries = 0; numRetries < KMaxRetries; ++numRetries)
+			{
+			TBool startReceiving(EFalse);
+			Progress(_L("Receiving first byte of block...\r\n"));
+			TBool timedOut(EFalse);
+			TUint8 c = ReceiveByteL(KMediumTimeout, &timedOut);
+			if (timedOut)
+				{
+				Progress(_L("Timed out - sending NAK...\r\n"));
+				SendL(KLitNak);
+				}
+			else
+				{
+				switch (c)
+					{
+					case KByteSoh:
+						if (iBlockSize != KSmallBlockSize)
+							{
+							Progress(_L("Block size set to 128 bytes\r\n"));
+							iBlockSize = KSmallBlockSize;
+							}
+						startReceiving = ETrue;
+						break;
+					case KByteStx:
+						if (iBlockSize != KLargeBlockSize)
+							{
+							Progress(_L("Block size set to 1024 bytes\r\n"));
+							iBlockSize = KLargeBlockSize;
+							}
+						startReceiving = ETrue;
+						break;
+					case KByteEot:
+						Progress(_L("Last block received\r\n"));
+						aIsFinalBlock = ETrue;
+						SendL(KLitAck);
+						return ret;
+					case KByteCan:
+						Progress(_L("Sender cancelled\r\n"));
+						SendL(KLitAck);
+						PurgeInputL();
+						User::Leave(KErrCancel);
+						break;
+					default:
+						break;
+					}
+
+				if (startReceiving)
+					{
+					break;
+					}
+				}
+			}
+
+		if (numRetries == KMaxRetries)
+			{
+			Progress(_L("Failed to receive valid block\r\n"));
+			User::Leave(KErrCommsLineFail);
+			}
+		}
+
+	if (iBuf->Des().MaxLength() < (iBlockSize + ProtocolOverhead()))
+		{
+		Progress(_L("Reallocating buffer from %d to %d bytes\r\n"), iBuf->Des().MaxLength(), iBlockSize + ProtocolOverhead());
+		iBuf = iBuf->ReAllocL(iBlockSize + ProtocolOverhead());
+		}
+
+	Progress(_L("Receiving remainder of block...\r\n"));
+	TPtr ptr(const_cast<TUint16*>(iBuf->Ptr()), 0, iBlockSize + ProtocolOverhead() - 1); // - 1 because the first byte of the header isn't in the buffer. Note, can't use HBufC::Des because the max length of the resulting TPtr could be larger than the amount of data we are expecting.
+	TBool timeoutOccurred;
+	ReceiveWithTimeoutL(ptr, KLongTimeout, &timeoutOccurred);
+	if (timeoutOccurred)
+		{
+		Progress(_L("Timed out, retrying...\r\n"));
+		SendL(KLitNak);
+		PurgeInputL();
+		goto again;
+		}
+	iBuf->Des().SetLength(ptr.Length());
+
+	TUint8 b0 = (*iBuf)[0];
+	TUint8 b1 = (*iBuf)[1];
+	// workaround for a compiler bug: and b0 and ~b1 with 0xff, otherwise some compilers will compare
+	// the full 32-bit values, the top 3 bytes of which contain garbage. Observed with WINSW and GCCE
+	// compilers.
+	if (((b0 & 0xff) == ((~b1) & 0xff)) && ((b0 == iPacketNumber) || (b0 == (iPacketNumber - 1))) && CheckBlock())
+		{
+		Progress(_L("Block successfully received\r\n"));
+		if ((*iBuf)[0] == iPacketNumber)
+			{
+			Progress(_L("Packet number matched (%d)\r\n"), iPacketNumber);
+			ret.Set(iBuf->Mid(2, iBuf->Length() - CheckSize() - 2));
+			++iPacketNumber;
+			}
+		repeats = 0;
+		SendL(KLitAck);
+		}
+	else if (++repeats >= KMaxRetries)
+		{
+		Progress(_L("Block not successfully received after %d retries, cancelling...\r\n"), KMaxRetries);
+		SendL(KLitCancel);
+		PurgeInputL();
+		User::Leave(KErrCancel);
+		}
+	else
+		{
+		Progress(_L("Block not successfully received, retrying...\r\n"));
+		SendL(KLitNak);
+		goto again;
+		}
+
+	return ret;
+	}
+
+void CCmdXmodem::SendTerminateL()
+	{
+	for (TInt numRetries = 0; numRetries < KMaxRetries; ++numRetries)
+		{
+		SendL(KLitEot);
+		if (ReceiveByteL(KMediumTimeout) == KByteAck)
+			{
+			return;
+			}
+		}
+	PurgeInputL();
+	User::Leave(KErrCompletion);
+	}
+
+void CCmdXmodem::SendStdinL()
+	{
+	HBufC* buf = HBufC::NewLC(iBlockSize);
+	TPtr bufPtr(buf->Des());
+
+	while (Stdin().Read(bufPtr) == KErrNone)
+		{
+		SendBlockL(*buf);
+		bufPtr.Zero();
+		}
+	SendTerminateL();
+
+	CleanupStack::PopAndDestroy(buf);
+	}
+
+void CCmdXmodem::SendFileL(const TDesC& aFileName)
+	{
+	Progress(_L("Sending file \"%S\"...\r\n"), &aFileName);
+	RFile file;
+	User::LeaveIfError(file.Open(FsL(), aFileName, EFileRead));
+	CleanupClosePushL(file);
+
+	HBufC8* buf = HBufC8::NewLC(iBlockSize);
+	HBufC* wideBuf = HBufC::NewLC(iBlockSize);
+	TPtr8 bufPtr(buf->Des());
+	while ((file.Read(bufPtr, iBlockSize) == KErrNone) && (buf->Length() > 0))
+		{
+		wideBuf->Des().Copy(*buf);
+		SendBlockL(*wideBuf);
+		}
+	SendTerminateL();
+
+	CleanupStack::PopAndDestroy(3, &file);
+	}
+
+void CCmdXmodem::ReceiveToStdoutL()
+	{
+	TBool firstBlock(ETrue);
+	TBool finalBlock(EFalse);
+	while (!finalBlock)
+		{
+		TPtrC block(ReceiveBlockL(firstBlock, finalBlock));
+		User::LeaveIfError(Stdout().Write(block));
+		firstBlock = EFalse;
+		}
+	}
+
+void CCmdXmodem::ReceiveToFileL(const TDesC& aFileName)
+	{
+	RFile file;
+	if (iOverwrite)
+		{
+		FsL().MkDirAll(aFileName); // Create the directory if it doesn't already exist
+		User::LeaveIfError(file.Replace(FsL(), aFileName, EFileWrite));
+		}
+	else
+		{
+		User::LeaveIfError(file.Create(FsL(), aFileName, EFileWrite));
+		}
+	CleanupClosePushL(file);
+
+	HBufC8* narrowBuf = HBufC8::NewLC(iBlockSize);
+	TPtr8 narrowBufPtr(narrowBuf->Des());
+	TBool firstBlock(ETrue);
+	TBool finalBlock(EFalse);
+	while (!finalBlock)
+		{
+		TPtrC block(ReceiveBlockL(firstBlock, finalBlock));
+		firstBlock = EFalse;
+		if (block.Length() > narrowBufPtr.MaxLength())
+			{
+			HBufC8* newNarrowBuf = narrowBuf->ReAllocL(iBuf->Length());
+			CleanupStack::Pop(narrowBuf);
+			narrowBuf = newNarrowBuf;
+			CleanupStack::PushL(narrowBuf);
+			narrowBufPtr.Set(narrowBuf->Des());
+			}
+		narrowBufPtr.Copy(block);
+		User::LeaveIfError(file.Write(*narrowBuf));
+		narrowBufPtr.Zero();
+		}
+
+	CleanupStack::PopAndDestroy(2, &file);
+	}
+
+void CCmdXmodem::ReceiveToNullL()
+	{
+	TBool firstBlock(EFalse);
+	TBool finalBlock(EFalse);
+	while (!finalBlock)
+		{
+		ReceiveBlockL(firstBlock, finalBlock);
+		firstBlock = EFalse;
+		}
+	}
+
+const TDesC& CCmdXmodem::Name() const
+	{
+	_LIT(KName, "xmodem");	
+	return KName;
+	}
+
+void CCmdXmodem::DoRunL()
+	{
+	PrepareConsoleToTransferL();
+
+	if (iMode == EReceive)
+		{
+		if (iFileName.Length() > 0)
+			{
+			LeaveIfFileExists(iFileName);
+			}
+		TSyncResult syncResult = SendSyncL();
+		if (syncResult == ENormal)
+			{
+			if (iFileName.Length() > 0)
+				{
+				ReceiveToFileL(iFileName);
+				}
+			else
+				{
+				ReceiveToStdoutL();
+				}
+
+			CleanupClonsoleAfterTransferL();
+			if (iFileName.Length() > 0)
+				{
+				Printf(_L("Successfully received \"%S\".\r\n"), &iFileName);
+				}
+			}
+		}
+	else if (iMode == ESend)
+		{
+		if (iFileName.Length() > 0)
+			{
+			LeaveIfFileNotFound(iFileName);
+			}
+		WaitForSyncL();
+		if (iFileName.Length() > 0)
+			{
+			SendFileL(iFileName);
+			}
+		else
+			{
+			SendStdinL();
+			}
+
+		CleanupClonsoleAfterTransferL();
+		if (iFileName.Length() > 0)
+			{
+			Printf(_L("Successfully sent \"%S\".\r\n"), &iFileName);
+			}
+		else
+			{
+			Printf(_L("Successfully stdin.\r\n"));
+			}
+		}
+	User::LeaveIfError(Stdin().CancelCaptureAllKeys());
+	}
+
+void CCmdXmodem::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg1, "mode");
+	aArguments.AppendEnumL((TInt&)iMode, KArg1);
+	_LIT(KArg2, "file_name");
+	aArguments.AppendFileNameL(iFileName, KArg2);
+	}
+
+void CCmdXmodem::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptVerbose, "verbose");
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+
+	_LIT(KOptOverwrite, "overwrite");
+	aOptions.AppendBoolL(iOverwrite, KOptOverwrite);
+	}
+
+void CCmdXmodem::HandleLeave(TInt aError)
+	{
+	if (iStarted)
+		{
+		Abort();
+		CleanupClonsoleAfterTransferL();
+		}
+	CCommandBase::HandleLeave(aError);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/xmodem.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,94 @@
+// xmodem.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __XMODEM_H__
+#define __XMODEM_H__
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+
+class CCmdXmodem : public CCommandBase
+	{
+public:
+	enum TSyncResult
+		{
+		ENormal,
+		EEot
+		};
+public:
+	static CCommandBase* NewLC();
+	~CCmdXmodem();
+protected:
+	CCmdXmodem();
+	void ConstructL();
+	void SendStdinL();
+	void SendFileL(const TDesC& aFileName);
+	void ReceiveToStdoutL();
+	void ReceiveToFileL(const TDesC& aFileName);
+	void ReceiveToNullL();
+	void SendBlockL(const TDesC& aBlock);
+	TPtrC ReceiveBlockL(TBool aIsFirstBlock, TBool& aIsFinalBlock);
+	void DoReceiveBlockL();
+	void SendTerminateL();
+	void WaitForSyncL();
+	TSyncResult SendSyncL();
+	TUint8 ReceiveByteL(TInt aTimeout, TBool* aTimeoutOccurred = NULL);
+	TUint16 ReceiveShortL(TInt aTimeout, TBool* aTimeoutOccurred = NULL);
+	void ReceiveWithTimeoutL(TDes& aBuf, TInt aTimeout, TBool* aTimeoutOccurred = NULL);
+	void DoReceiveWithTimeoutL(TDes& aBuf, TInt aTimeout, TBool* aTimeoutOccurred = NULL);
+	void PurgeInputL();
+	void SendL(const TDesC& aData);
+	TInt CheckSize() const;
+	TInt ProtocolOverhead() const;
+	TBool CheckBlock() const;
+	void Progress(TRefByValue<const TDesC> aFmt, ...) const;
+	void Dump(const TDesC& aData);
+	void Abort();
+	void HandleTelnetCommandL();
+	void Unget(TChar aChar);
+	void PrepareConsoleToTransferL();
+	void CleanupClonsoleAfterTransferL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void HandleLeave(TInt aError);
+protected:
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum TTelnetMode
+		{
+		ESendBinary = 0x00000001,
+		ERecvBinary = 0x00000002
+		};
+protected:
+	enum 
+		{
+		ESend, EReceive
+		} iMode;
+	TFileName2 iFileName;
+	TInt iBlockSize;
+	TUint8 iPacketNumber;
+	TBool iOverwrite;
+private:
+	TBool iVerbose;
+	TBool iCrc;
+	TBool iStarted;
+	TUint iTelnetMode;
+	HBufC* iBuf;
+	TBuf<2> iUngetBuf;
+	RTimer iTimer;
+	};
+
+#endif // __XMODEM_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ymodem.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+# ymodem.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+==include xmodem.cif
+
+==name ymodem
+
+==short-description
+
+An implementation of the YMODEM file transfer protocol.
+
+==long-description
+
+Allows the transfer of files to and from remote terminal software that supports YMODEM. Supports batch mode, allowing multiple files to be sent and received. Note, the console implementation that ymodem is attached to must support binary mode. If it doesn't, C<KErrExtensionNotSupported> (-47) will be reported. In practice, this currently means that one of the vt100 console variants (F<vt100cons.dll>, F<vt100busdevcons.dll>, F<vt100usbcons.dll>, F<vt100btcons.dll> or F<vt100tcpcons.dll>) must be used.
+
+==argument filename file_name optional multiple
+
+=over 4
+
+=item Send mode:
+
+The names of the files to be sent (wild characters are accepted). At least one file must be specified.
+
+=item Receive mode:
+
+The name of the directory in which to write the received files (the name of each received file is provided by the send). If not specified, the received files are saved in the current working directory
+
+=back
+
+==see-also
+
+L<xmodem|xmodem>
+
+==copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ymodem.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,283 @@
+// ymodem.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include "ymodem.h"
+
+using namespace IoUtils;
+
+CCommandBase* CCmdYmodem::NewLC()
+	{
+	CCmdYmodem* self = new(ELeave) CCmdYmodem();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	self->ConstructL();
+	return self;
+	}
+
+CCmdYmodem::~CCmdYmodem()
+	{
+	iFileNames.Close();
+	}
+
+CCmdYmodem::CCmdYmodem()
+	{
+	}
+
+const TDesC& CCmdYmodem::Name() const
+	{
+	_LIT(KName, "ymodem");	
+	return KName;
+	}
+
+class TFailedFile
+	{
+public:
+	TFailedFile();
+public:
+	TInt iError;
+	TFileName2 iFileName;
+	};
+
+TFailedFile::TFailedFile()
+	: iError(KErrNone)
+	{
+	}
+
+void CCmdYmodem::DoRunL()
+	{
+	PrepareConsoleToTransferL();
+
+	if (iMode == EReceive)
+		{
+		TPtrC receiveDir;
+		if (iFileNames.Count() > 1)
+			{
+			PrintError(KErrArgument, _L("Too many arguments - only the receive directory may be specified in receive mode."));
+			User::Leave(KErrArgument);
+			}
+		else if (iFileNames.Count() == 1)
+			{
+			TFileName2 fileName(iFileNames[0]);
+			receiveDir.Set(iFileNames[0]);
+
+			if ((fileName.Exists(FsL()) && !fileName.IsDirL(FsL())) || (!fileName.Exists(FsL()) && !iOverwrite))
+				{
+				LeaveIfErr(KErrArgument, _L("\"%S\" is not a directory"), &fileName);
+				}
+			}
+		else
+			{
+			receiveDir.Set(Env().Pwd());
+			}
+
+		Progress(_L("YMODEM receive to \"%S\"\r\n"), &receiveDir);
+		RArray<TFileName2> receivedFiles;
+		CleanupClosePushL(receivedFiles);
+		TFailedFile failedFile;
+		TBool finished(EFalse);
+		while (!finished)
+			{
+			TSyncResult syncResult = SendSyncL();
+			if (syncResult == EEot)
+				{
+				finished = ETrue;
+				}
+			else
+				{
+				iPacketNumber = 0;
+				TBool isFinalBlock(EFalse);
+				TPtrC block(ReceiveBlockL(ETrue, isFinalBlock));
+				TPtrC fileName(block.Ptr()); // filename is the first null terminated string in the block.
+				if (fileName.Length() > 0)
+					{
+					TFileName2 fileName2(fileName);
+					fileName2.MakeAbsoluteL(receiveDir);
+					TLex lex(block.Mid(fileName.Length() + 1));
+					TInt size;
+					User::LeaveIfError(lex.Val(size));
+					TInt err = KErrNone;
+					if (!iOverwrite && fileName2.Exists(FsL()))
+						{
+						err = KErrAlreadyExists;
+						}
+					RFile file;
+					if (err == KErrNone)
+						{
+						if (size == 0)
+							{
+							if (iOverwrite)
+								{
+								err = file.Replace(FsL(), fileName2, EFileWrite);
+								}
+							else
+								{
+								err = file.Create(FsL(), fileName2, EFileWrite);
+								}
+							}
+						else
+							{
+							Progress(_L("Starting receive of \"%S\" (%d bytes)\r\n"), &fileName, size);
+							SendSyncL();
+							TRAP(err, ReceiveToFileL(fileName2));
+							if (err == KErrNone)
+								{
+								err = file.Open(FsL(), fileName2, EFileWrite);
+								if (err == KErrNone)
+									{
+									err = file.SetSize(size);
+									}
+								}
+							else
+								{
+								Fs().Delete(fileName2);
+								}
+							}
+						}
+					else
+						{
+						TRAP_IGNORE(ReceiveToNullL());
+						}
+					file.Close();
+					if (err)
+						{
+						failedFile.iError = err;
+						failedFile.iFileName = fileName2;
+						finished = ETrue;
+						}
+					else
+						{
+						receivedFiles.Append(fileName2); // Ignore error.
+						}
+					}
+				else
+					{
+					finished = ETrue;
+					}
+				}
+			}
+
+		CleanupClonsoleAfterTransferL();
+
+		const TInt numFilesReceived = receivedFiles.Count();
+		if (numFilesReceived == 0)
+			{
+			if (failedFile.iError == KErrNone)
+				{
+				Printf(_L("No files to receive.\r\n"));
+				}
+			}
+		else if (numFilesReceived == 1)
+			{
+			const TFileName2& fileName = receivedFiles[0];
+			Printf(_L("Successfully received \"%S\".\r\n"), &fileName);
+			}
+		else
+			{
+			Printf(_L("Successfully received:\r\n"));
+			for (TInt i = 0; i < numFilesReceived; ++i)
+				{
+				const TFileName2& fileName = receivedFiles[i];
+				Printf(_L("\t\"%S\"\r\n"), &fileName);
+				}
+			}
+
+		if (failedFile.iError)
+			{
+			PrintError(failedFile.iError, _L("Failed to receive \"%S\""), &failedFile.iFileName);
+			}
+		CleanupStack::PopAndDestroy(&receivedFiles);
+		}
+	else if (iMode == ESend)
+		{
+		const TInt numFiles = iFileNames.Count();
+		if (numFiles == 0)
+			{
+			PrintError(KErrArgument, _L("No files to send specified"));
+			User::Leave(KErrArgument);
+			}
+		for (TInt i = 0; i < numFiles; ++i)
+			{
+			const TFileName2& fileName = iFileNames[i];
+			if (fileName.Exists(FsL()))
+				{
+				if (fileName.IsDirL(FsL()))
+					{
+					LeaveIfErr(KErrArgument, _L("\"%S\" is not a file"), &fileName);
+					}
+				}
+			else
+				{
+				LeaveIfErr(KErrArgument, _L("\"%S\" does not exist"), &fileName);
+				}
+			}
+		WaitForSyncL();
+		HBufC* buf = HBufC::NewLC(iBlockSize);
+		TPtr bufPtr(buf->Des());
+		for (TInt i = 0; i < numFiles; ++i)
+			{
+			const TFileName2& fileName = iFileNames[i];
+			LeaveIfFileNotFound(fileName);
+			TEntry entry;
+			User::LeaveIfError(FsL().Entry(fileName, entry));
+			bufPtr.SetLength(bufPtr.MaxLength());
+			bufPtr.FillZ();
+			bufPtr.Copy(fileName.NameAndExt());
+			bufPtr.SetLength(buf->Length() + 1); // To leave a terminating null after the file name.
+			bufPtr.AppendNum(entry.iSize);
+			if (bufPtr.Length() < iBlockSize)
+				{
+				// There's not enough data to fill this block, so pad with NULL.
+				bufPtr.AppendFill(0, iBlockSize - bufPtr.Length());
+				}
+			iPacketNumber = 0;
+			SendBlockL(*buf);
+			WaitForSyncL();
+			SendFileL(fileName);
+			}
+		iPacketNumber = 0;
+		bufPtr.SetLength(bufPtr.MaxLength());
+		bufPtr.FillZ();
+		SendBlockL(*buf);
+		CleanupStack::PopAndDestroy(buf);
+		CleanupClonsoleAfterTransferL();
+
+		if (numFiles == 1)
+			{
+			Printf(_L("Successfully sent \"%S\".\r\n"), &iFileNames[0]);
+			}
+		else
+			{
+			Printf(_L("Successfully sent:\r\n"));
+			for (TInt i = 0; i < numFiles; ++i)
+				{
+				const TFileName2& fileName = iFileNames[i];
+				Printf(_L("\t\"%S\"\r\n"), &fileName);
+				}
+			}
+		}
+	User::LeaveIfError(Stdin().CancelCaptureAllKeys());
+	}
+
+void CCmdYmodem::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArg1, "mode");
+	aArguments.AppendEnumL((TInt&)iMode, KArg1);
+	_LIT(KArg2, "file_name");
+	aArguments.AppendFileNameL(iFileNames, KArg2);
+	}
+
+void CCmdYmodem::OptionsL(RCommandOptionList& aOptions)
+	{
+	CCmdXmodem::OptionsL(aOptions);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/builtins/ymodem.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+// ymodem.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __YMODEM_H__
+#define __YMODEM_H__
+
+#include <fshell/ioutils.h>
+#include "xmodem.h"
+
+using namespace IoUtils;
+
+
+class CCmdYmodem : public CCmdXmodem
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdYmodem();
+private:
+	CCmdYmodem();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RArray<TFileName2> iFileNames;
+	};
+
+
+#endif // __YMODEM_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/bwins/sbrec.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+	?KAutoStartFshell@@3HB @ 2 NONAME ; int const KAutoStartFshell
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/docs/commands.index	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4 @@
+=head1 FShell Commands
+
+A list of all the built-in and external commands that L<fshell|fshell> currently supports.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/docs/console_options.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,61 @@
+# console_options.pod
+#
+# Copyright (c) 2008-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 Console Options
+
+The way in which F<fshell> is initially started depends on the console implementation that it is using. Ordinarly, the choice of console implementation is something that the F<fshell> maintainers take care of independently for each of the supported platforms. However, the choice generally boils down to:
+
+=over 5
+
+=item * econs.dll
+
+This is the console implementation for the text window server, generally only used for minimal base-port all ROMs and the early stages of product bring up.
+
+=item * econseik.dll
+
+This is the console implementation for the graphical window server. It is generally only usable on devices that have a full keyboard, and so is rarely the default console implementation used by the F<fshell>. If F<fshell> has been configured to use this console implementation, it should be possible to start using it selecting its icon from the application launcher. You'll then be presented with a full screen window and a command prompt that can be interacted with using the device's keyboard.
+
+=item * L<rcons.dll|rcons>
+
+This is a console implementation that connects via TCP to a Win32 executable (called L<rcons.exe|rcons.exe>) that hosts console windows remotely. The TCP transport is normally Symbian's PC Connectivity transport, mRouter. It is therefore necessary to have the correct connectivity suite for the handset being used to run F<fshell> installed and connected (normally via USB, but Bluetooth is also possible). It is also necessary to run L<rcons.exe|rcons.exe> on the PC hosting the connectivity suite (this file can be found in C<\epoc32\tools>). Having done this, launching F<fshell> from the application launcher should result in a new Win32 window appearing on the PC with a command prompt in it.
+
+Note, L<rcons.dll|rcons.dll> is normally the console implementation of choice provided the device in question has a working PC connectivity suite. This is because it supports multiple console windows without any special configuration. However, L<rcons.dll|rcons.dll> does require that the device is able to make an active TCP connection to the PC. While this works fine with mRouter, other TCP transports may be blocked by firewalling software running on the host PC.
+
+=item * L<vt100cons.dll|vt100cons>
+
+This is a console implementation that will communicate with a VT100 compatible terminal (or terminal emulator such as HyperTerminal) via a serial connection. There are variants that work over TCP connnections (vt100tcpcons.dll), Bluetooth (vt100btcons.dll) and USB (vt100usbcons.dll). On platforms that support it, the Bluetooth or USB consoles can be started from the application launcher, whereupon they will listen for an incoming connection to the appropriate Bluetooth serial port or USB ACM channel. The console supports basic VT100, colour, some VT220 key escapes, and binary mode.
+
+=item * win32cons.dll
+
+A specialised console for running the WINSCW fshell directly in a DOS box. Launch \epoc32\tools\fshell.bat to start a headless, gui-less epoc.exe emulator connected to an fshell session in the DOS box. Note this console is only for talking to the emulator, it cannot be used to talk to a device.
+
+=item * Guicons
+
+On platforms that support it, guicons is supplied as an alternative to econseik. This can be launched from the application launcher, and integrates better with the UI layer than econseik.
+
+=back
+
+=head1 See Also
+
+L<fshell|fshell>
+
+L<rcons|rcons>
+
+L<vt100cons|vt100cons>
+
+=head1 Copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/docs/index.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4 @@
+=head2 FShell Core Functionality
+
+L<FShell|commands::fshell>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/docs/persistent_consoles.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,139 @@
+# persistent_consoles.pod
+#
+# Copyright (c) 2008-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 Persistent consoles
+
+Persistent consoles allow you to maintain a persistent L<fshell|fshell> (or other console application) instance on a device while actual console connections come and go. A persistent console consists of a I<persistent> side, which is owned by a L<fshell|fshell> or other application as its console, and a I<transient> side, which can be connected to or disconnected from another console at any time. This allows you to interact with the persistent console owning application using any console connection available on the device at the time.
+
+To illustrate, we can create a new persistent console thus:
+
+	c:\>pcons new "my pcons"
+
+This create a new, disconnected persistent console. We can use the L<pcons|pcons> command see it:
+
+	c:\>pcons list
+	Name      Creator           Reader  Writer
+	my pcons  fshell::pcons_00  -       -
+
+Note that no reader or writer are attached. We can now connect to the console:
+
+	c:\>pcons connect "my pcons"
+	pcons: connecting to existing console my pcons.
+	c:\>pcons list
+	Name         Creator           Reader               Writer
+	my pcons(*)  fshell::pcons_00  vt100tcpcons_fshell  vt100tcpcons_fshell
+	(*) indicates current console
+
+Now, C<pcons list> shows what I<transient> console the persistent console is connected to - C<vt100tcpcons_fshell>. It also indicates with a C<(*)> the persistent console that we are currently interacting with.
+
+If the TCP console we are currently using is disconnected for any reason (perhaps we lost the connection with the device), then the I<transient> side of the console will simply be disconnected and the I<persistent> side will be unaffected. If it tries to interact with the console (perhaps to write some data to it), the call will simply block until we get a new I<transient> side. Hence, after the I<transient> console connection is lost, we can simply reconnect to the same C<fshell> when we are able to re-establish a connection with the device and continue from where we left off, with no state lost.
+
+Note, if we exit the C<fshell> session that is connected to the I<persistent> side of the console, the persistent console will be destroyed:
+
+	c:\>exit
+	pcons: disconnected from my pcons
+	c:\>pcons list
+	c:\>
+
+Hence you should be careful not to exit the C<fshell> session attached to the I<persistent> side of the console if you are relying on the persistency of it to maintain state.
+
+We can disconnect the I<transient> side of a persistent console using C<pcons disconnect>:
+
+	c:\>pcons disconnect
+	pcons: disconnected from my pcons
+	c:\>pcons
+	Name      Creator           Reader  Writer
+	my pcons  fshell::pcons_00  -       -
+	c:\>
+
+We can also disconnect a persistent console that we are not currently interacting with by specifying it's name to C<pcons disconnect>.
+
+=head2 Creating persistent consoles
+
+The above shows the basics of creating a persistent console, however there are several ways of doing this.
+
+All L<fshell|fshell> commands support an option C<--persistent-console>, similar to C<--console> but creating a persistent console. For example,
+
+	c:\>fshell --persistent-console "fshell_pcons"
+
+Note, this call does not return; the new C<fshell> instance is waiting for input on the persistent console, which is currently disconnected. Instead, it may be more useful to use the L<start|start> command to create the new fshell session:
+
+	c:\>start fshell --persistent-console "fshell_pcons"
+	c:\>
+
+This creates a new process in the background, which owns a a new persistent console.
+
+	c:\>pcons list
+	Name          Creator           Reader  Writer
+	my pcons      fshell::pcons_00  -       -
+	fshell_pcons  fshell(2)         -       -
+
+This equivilant to typing C<pcons new fshell_pcons>.
+
+You can also specify a process to launch when using C<pcons new> by specifying a command and arguments after the console name. For example,
+
+	c:\>pcons new ptf_pcons ptf
+	c:\>pcons connect ptf_pcons
+	pcons: connecting to existing console ptf_pcons.
+	
+	PromptTestFramework 007d
+	!>
+
+Instead of C<pcons new>, you could have instead used
+
+	c:\>start ptf --persistent-console ptf_pcons
+
+The L<pcons|pcons> command also supports a C<start> argument, which is similar to C<new>, but with the following semantics:
+
+=over
+
+=item *
+
+If a persistent console with the given name already exists, it will not be created
+
+=item *
+
+a connection with the named persistent console will be established.
+
+=back
+
+This can provide a useful shortcut to start interacting with the process attached to the I<persistent> side of the console, creating it if it doesn't already exist. Note, you can specify a command and arguments to C<start> as with C<new>, but these will be ignored if the persistent console already exists.
+
+	c:\>pcons start "my pcons"
+	pcons: connecting to existing console my pcons.
+	c:\>
+	
+	c:\>pcons start "new pcons"
+	pcons: connecting to new console new pcons.
+	c:\>
+
+=head2 Connecting other consoles
+
+You can use C<pcons connect> to connect a new console as the I<transient> side by using the C<--console> option:
+
+	c:\>pcons connect "my pcons" --console vt100tcpcons
+
+This will create a new console implementation of the type specified and connect it to the persistent console.
+
+As stated earlier, when a persistent consoles I<transient> side is disconnected, any operations on it will block. This will generally cause the process connected to the I<persistent> side to lock up until a real console implementation is connected. If you want to allow this process to run, without blocking while no I<transient> console is connected, you can connect it to the null console:
+
+	c:\>pcons connect "my pcons" --console nullcons
+
+This cause all output written by the persistent process to be discarded, and hence allow the process to run while no console is connected to the device.
+
+=head1 Copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/eabi/sbrec.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	KAutoStartFshell @ 2 NONAME DATA 4
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/inst/fshell_inst.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,64 @@
+// fshell_inst.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <e32std.h>
+#include <f32file.h>
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+void RunL()
+	{
+	RProcess process;
+	TFileName2 sourceFileName(process.FileName());
+	RArray<TFileName2> splitFileName;
+	CleanupClosePushL(splitFileName);
+	sourceFileName.SplitL(splitFileName);
+	splitFileName.Remove(splitFileName.Count() - 1);
+	splitFileName.Append(_L("iocons.dll"));
+	sourceFileName.UnsplitL(splitFileName);
+
+	TFileName2 destinationFileName;
+	splitFileName.Remove(splitFileName.Count() - 1);
+	splitFileName.Append(_L("econs.dll"));
+	destinationFileName.UnsplitL(splitFileName);
+	
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+	CFileMan* fileMan = CFileMan::NewL(fs, NULL);
+	CleanupStack::PushL(fileMan);
+
+	User::LeaveIfError(fileMan->Copy(sourceFileName, destinationFileName));
+
+	CleanupStack::PopAndDestroy(3, &splitFileName);
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	TInt err = KErrNoMemory;
+	CActiveScheduler* sheduler = new CActiveScheduler;
+	if (sheduler)
+		{
+		CActiveScheduler::Install(sheduler);
+		CTrapCleanup* cleanup = CTrapCleanup::New();
+		if (cleanup)
+			{
+			TRAP(err, RunL());
+			delete cleanup;
+			}
+		delete sheduler;
+		}
+	__UHEAP_MARKEND;
+	return err;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/inst/fshell_inst.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// fshell_inst.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_inst.exe
+targettype      exe
+uid             0x100039CE FSHELL_UID_FSHELL_INST
+capability      all
+
+sourcepath	.
+#include <fshell/fsh_system_include.mmh>
+
+source  	fshell_inst.cpp
+
+library  	euser.lib
+library  	efsrv.lib
+library  	iocli.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/inst/fshell_uinst.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+// fshell_uinst.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <e32std.h>
+#include <f32file.h>
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+void RunL()
+	{
+	RProcess process;
+	TFileName2 fileName(process.FileName());
+	RArray<TFileName2> splitFileName;
+	CleanupClosePushL(splitFileName);
+	fileName.SplitL(splitFileName);
+	splitFileName.Remove(splitFileName.Count() - 1);
+	splitFileName.Append(_L("econs.dll"));
+	fileName.UnsplitL(splitFileName);
+	
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+	User::LeaveIfError(fs.Delete(fileName));
+
+	CleanupStack::PopAndDestroy(2, &splitFileName);
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	TInt err = KErrNoMemory;
+	CActiveScheduler* sheduler = new CActiveScheduler;
+	if (sheduler)
+		{
+		CActiveScheduler::Install(sheduler);
+		CTrapCleanup* cleanup = CTrapCleanup::New();
+		if (cleanup)
+			{
+			TRAP(err, RunL());
+			delete cleanup;
+			}
+		delete sheduler;
+		}
+	__UHEAP_MARKEND;
+	return err;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/inst/fshell_uinst.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// fshell_uinst.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell_uinst.exe
+targettype      exe
+uid             0x100039CE FSHELL_UID_FSHELL_UINST
+capability      all
+
+sourcepath	.
+#include <fshell/fsh_system_include.mmh>
+
+source  	fshell_uinst.cpp
+
+library  	euser.lib
+library  	efsrv.lib
+library  	iocli.lib
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/inst/readme.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,9 @@
+These two executables exists to allow fshell to eclipse the ROM based "econs.dll". This can't be done
+within the .SIS file because the app installer doesn't allow ROM files to be eclipsed.
+
+fshell_inst.exe copies "<install_drive>:\sys\bin\iocons.dll" to "<install_drive>:\sys\bin\econs.dll".
+It is launched by the tool-kit .SIS file at install time.
+
+fshell_uinst.exe deletes "<install_drive>:\sys\bin\econs.dll".
+It is launched by the tool-kit .SIS file at uninstall time.
+
Binary file core/extra/launch/fshell_bt.mif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_bt.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="84"
+   height="58"
+   viewBox="0 0 84 58"
+   id="svg6562">
+  <defs
+     id="defs6649" />
+  <rect
+     width="59.448528"
+     height="49.411762"
+     x="11.889707"
+     y="4.1102939"
+     id="rect6661"
+     style="fill:#0000ff" />
+  <path
+     d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z"
+     id="text2481"
+     style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold" />
+  <path
+     d="M 53.888786,42.556988 C 54.211696,42.603868 54.50206,42.689806 54.75988,42.8148 C 55.017685,42.939805 55.239039,43.099961 55.423942,43.295269 C 55.60883,43.490586 55.750757,43.722357 55.849723,43.990582 C 55.948673,44.258814 55.998152,44.564804 55.998161,44.90855 C 55.998152,45.153345 55.961694,45.409855 55.888786,45.678082 C 55.815861,45.946313 55.694767,46.206729 55.525505,46.459332 C 55.356226,46.711937 55.134872,46.94501 54.861442,47.15855 C 54.587998,47.372093 54.248154,47.546572 53.841911,47.681988 C 53.529405,47.786155 53.183051,47.859071 52.802848,47.900738 C 52.422635,47.942404 51.966906,47.963238 51.435661,47.963238 L 48.732536,47.963238 L 48.732536,37.510113 L 51.341911,37.510113 C 51.58149,37.510123 51.798938,37.514029 51.994255,37.521832 C 52.189562,37.529654 52.36925,37.541373 52.533317,37.556988 C 52.697374,37.572623 52.849718,37.592154 52.990348,37.615582 C 53.130968,37.639029 53.26378,37.666373 53.388786,37.697613 C 53.716905,37.786165 54.015081,37.907258 54.283317,38.060894 C 54.551539,38.21455 54.779404,38.398143 54.966911,38.611675 C 55.154403,38.825226 55.298934,39.067413 55.400505,39.338238 C 55.502059,39.609079 55.55284,39.90335 55.552848,40.22105 C 55.55284,40.476266 55.522892,40.721058 55.463005,40.955425 C 55.403101,41.189807 55.306747,41.405953 55.173942,41.603863 C 55.041122,41.801786 54.869247,41.978869 54.658317,42.135113 C 54.447373,42.291368 54.190863,42.421577 53.888786,42.525738 L 53.888786,42.556988 z M 51.943473,42.03355 C 52.193469,42.033556 52.409614,42.021837 52.591911,41.998394 C 52.774197,41.974963 52.93826,41.939806 53.084098,41.892925 C 53.474717,41.762723 53.759873,41.559598 53.939567,41.28355 C 54.119248,41.007516 54.209092,40.681995 54.209098,40.306988 C 54.209092,39.921579 54.115342,39.606475 53.927848,39.361675 C 53.740342,39.116892 53.446072,38.934601 53.045036,38.8148 C 52.847114,38.757518 52.617947,38.717153 52.357536,38.693707 C 52.097115,38.670278 51.789823,38.65856 51.435661,38.65855 L 50.005973,38.65855 L 50.005973,42.03355 L 51.943473,42.03355 z M 50.005973,43.181988 L 50.005973,46.8148 L 51.545036,46.8148 C 51.909615,46.814801 52.248156,46.797874 52.560661,46.764019 C 52.873156,46.730166 53.13878,46.676781 53.357536,46.603863 C 53.597113,46.525739 53.800238,46.425479 53.966911,46.303082 C 54.133571,46.180687 54.267685,46.045271 54.369255,45.896832 C 54.47081,45.748396 54.543727,45.590844 54.588005,45.424175 C 54.632268,45.257511 54.654404,45.088241 54.654411,44.916363 C 54.654404,44.718449 54.630966,44.532252 54.584098,44.357769 C 54.537216,44.183294 54.460394,44.027044 54.35363,43.889019 C 54.246852,43.751002 54.106227,43.629909 53.931755,43.525738 C 53.757269,43.421576 53.539822,43.340847 53.279411,43.28355 C 53.123155,43.247097 52.94477,43.221055 52.744255,43.205425 C 52.543729,43.189805 52.295031,43.181993 51.998161,43.181988 L 50.005973,43.181988 z M 61.982536,47.963238 L 60.709098,47.963238 L 60.709098,38.65855 L 57.216911,38.65855 L 57.216911,37.510113 L 65.474723,37.510113 L 65.474723,38.65855 L 61.982536,38.65855 L 61.982536,47.963238 z"
+     id="text2563"
+     style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel" />
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_bt.tiny.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" height="58" version="1.0" viewBox="0 0 84 58" width="84">
+<rect height="49.411762" style="fill:#0000ff" width="59.448528" x="11.889707" y="4.1102939"/>
+<path d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z" style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold"/>
+<path d="M 53.888786,42.556988 C 54.211696,42.603868 54.50206,42.689806 54.75988,42.8148 C 55.017685,42.939805 55.239039,43.099961 55.423942,43.295269 C 55.60883,43.490586 55.750757,43.722357 55.849723,43.990582 C 55.948673,44.258814 55.998152,44.564804 55.998161,44.90855 C 55.998152,45.153345 55.961694,45.409855 55.888786,45.678082 C 55.815861,45.946313 55.694767,46.206729 55.525505,46.459332 C 55.356226,46.711937 55.134872,46.94501 54.861442,47.15855 C 54.587998,47.372093 54.248154,47.546572 53.841911,47.681988 C 53.529405,47.786155 53.183051,47.859071 52.802848,47.900738 C 52.422635,47.942404 51.966906,47.963238 51.435661,47.963238 L 48.732536,47.963238 L 48.732536,37.510113 L 51.341911,37.510113 C 51.58149,37.510123 51.798938,37.514029 51.994255,37.521832 C 52.189562,37.529654 52.36925,37.541373 52.533317,37.556988 C 52.697374,37.572623 52.849718,37.592154 52.990348,37.615582 C 53.130968,37.639029 53.26378,37.666373 53.388786,37.697613 C 53.716905,37.786165 54.015081,37.907258 54.283317,38.060894 C 54.551539,38.21455 54.779404,38.398143 54.966911,38.611675 C 55.154403,38.825226 55.298934,39.067413 55.400505,39.338238 C 55.502059,39.609079 55.55284,39.90335 55.552848,40.22105 C 55.55284,40.476266 55.522892,40.721058 55.463005,40.955425 C 55.403101,41.189807 55.306747,41.405953 55.173942,41.603863 C 55.041122,41.801786 54.869247,41.978869 54.658317,42.135113 C 54.447373,42.291368 54.190863,42.421577 53.888786,42.525738 L 53.888786,42.556988 z M 51.943473,42.03355 C 52.193469,42.033556 52.409614,42.021837 52.591911,41.998394 C 52.774197,41.974963 52.93826,41.939806 53.084098,41.892925 C 53.474717,41.762723 53.759873,41.559598 53.939567,41.28355 C 54.119248,41.007516 54.209092,40.681995 54.209098,40.306988 C 54.209092,39.921579 54.115342,39.606475 53.927848,39.361675 C 53.740342,39.116892 53.446072,38.934601 53.045036,38.8148 C 52.847114,38.757518 52.617947,38.717153 52.357536,38.693707 C 52.097115,38.670278 51.789823,38.65856 51.435661,38.65855 L 50.005973,38.65855 L 50.005973,42.03355 L 51.943473,42.03355 z M 50.005973,43.181988 L 50.005973,46.8148 L 51.545036,46.8148 C 51.909615,46.814801 52.248156,46.797874 52.560661,46.764019 C 52.873156,46.730166 53.13878,46.676781 53.357536,46.603863 C 53.597113,46.525739 53.800238,46.425479 53.966911,46.303082 C 54.133571,46.180687 54.267685,46.045271 54.369255,45.896832 C 54.47081,45.748396 54.543727,45.590844 54.588005,45.424175 C 54.632268,45.257511 54.654404,45.088241 54.654411,44.916363 C 54.654404,44.718449 54.630966,44.532252 54.584098,44.357769 C 54.537216,44.183294 54.460394,44.027044 54.35363,43.889019 C 54.246852,43.751002 54.106227,43.629909 53.931755,43.525738 C 53.757269,43.421576 53.539822,43.340847 53.279411,43.28355 C 53.123155,43.247097 52.94477,43.221055 52.744255,43.205425 C 52.543729,43.189805 52.295031,43.181993 51.998161,43.181988 L 50.005973,43.181988 z M 61.982536,47.963238 L 60.709098,47.963238 L 60.709098,38.65855 L 57.216911,38.65855 L 57.216911,37.510113 L 65.474723,37.510113 L 65.474723,38.65855 L 61.982536,38.65855 L 61.982536,47.963238 z" style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel"/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,75 @@
+// fshell_launch.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32std.h>
+#include <e32base.h>
+
+#include <fshell/common.mmh>
+
+void RunL()
+	{
+	_LIT(KProcess, "fshell.exe");
+	RProcess process;
+#ifdef FSHELL_CORE_LAUNCH_TCP
+	_LIT(KTcpArgs, "--console vt100tcpcons --console-title port=8080");
+	User::LeaveIfError(process.Create(KProcess, KTcpArgs));
+#endif
+
+#ifdef FSHELL_CORE_LAUNCH_BT
+	_LIT(KBtArgs, "--console vt100btcons");
+	User::LeaveIfError(process.Create(KProcess, KBtArgs));
+#endif
+
+//#define LQUOTE(x) L ## #x
+#define LCONS(x) L ## x
+#define EXPAND(f, x) f(x)
+
+#ifdef FSHELL_CORE_LAUNCH_USB
+	// FSHELL_CORE_SUPPORT_USB_ICON is "ACM::3" or whatever
+	_LIT(KUsbArgs, "--console vt100usbcons --console-title '" EXPAND(LCONS, FSHELL_CORE_SUPPORT_USB_ICON) L"'");
+	User::LeaveIfError(process.Create(KProcess, KUsbArgs));
+#endif
+
+#ifdef FSHELL_CORE_LAUNCH_RCONS
+	_LIT(KRconsArgs, "--console rcons");
+	User::LeaveIfError(process.Create(KProcess, KRconsArgs));
+#endif
+
+#ifdef FSHELL_CORE_LAUNCH_SERIAL
+	// FSHELL_CORE_SUPPORT_SERIAL_ICON is "COMM::1" or whatever
+	_LIT(KSerialArgs, "--console vt100cons --console-title '" EXPAND(LCONS, FSHELL_CORE_SUPPORT_SERIAL_ICON) L"'");
+	User::LeaveIfError(process.Create(KProcess, KSerialArgs));
+#endif
+
+	process.Resume();
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	TInt err = KErrNoMemory;
+	CActiveScheduler* sheduler = new CActiveScheduler;
+	if (sheduler)
+		{
+		CActiveScheduler::Install(sheduler);
+		CTrapCleanup* cleanup = CTrapCleanup::New();
+		if (cleanup)
+			{
+			TRAP(err, RunL());
+			delete cleanup;
+			}
+		delete sheduler;
+		}
+	__UHEAP_MARKEND;
+	return err;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch.mmh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+// fshell_launch.mmh
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+targettype      exe
+capability      none
+
+sourcepath	.
+systeminclude   \epoc32\include
+
+source  	fshell_launch.cpp
+
+library  	euser.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_bt.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// fshell_launch_bt.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include "fshell_launch.mmh"
+
+target          fshell_launch_bt.exe
+uid             0 FSHELL_UID_FSHELL_LAUNCH_BT
+macro           FSHELL_CORE_LAUNCH_BT
+
+sourcepath      .
+
+START RESOURCE	fshell_launch_bt_reg.rss
+    TARGETPATH  \private\10003a3f\apps
+END
+
+START RESOURCE  fshell_launch_bt_loc.rss
+    TARGETPATH  \resource\apps
+    LANG        SC
+END
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_bt_loc.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// fshell_launch_bt_loc.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = "fshell (BT)";
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO
+			{
+			caption = "fshell via Bluetooth Serial Port";
+#ifndef FSHELL_PLATFORM_UIQ
+			number_of_icons = 1;
+			icon_file = "\\Resource\\Apps\\fshell_bt.mif";
+#endif
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_bt_reg.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// fshell_launch_bt_reg.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 FSHELL_UID_FSHELL_LAUNCH_BT // application UID
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "fshell_launch_bt"; // filename of application binary (minus extension)
+	localisable_resource_file = "\\resource\\apps\\fshell_launch_bt_loc";
+	hidden = KAppNotHidden;
+	embeddability = KAppNotEmbeddable;
+	newfile = KAppDoesNotSupportNewFile;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_rcons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// fshell_launch_rcons.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include "fshell_launch.mmh"
+
+target          fshell_launch_rcons.exe
+uid             0 FSHELL_UID_FSHELL_LAUNCH_RCONS
+macro           FSHELL_CORE_LAUNCH_RCONS
+
+sourcepath      .
+
+START RESOURCE	fshell_launch_rcons_reg.rss
+    TARGETPATH  \private\10003a3f\apps
+END
+
+START RESOURCE  fshell_launch_rcons_loc.rss
+    TARGETPATH  \resource\apps
+    LANG        SC
+END
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_rcons_loc.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// fshell_launch_rcons_loc.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = "fshell (rcons)";
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO
+			{
+			caption = "Launch fshell via an outgoing rcons connection.";
+#ifndef FSHELL_PLATFORM_UIQ
+			number_of_icons = 1;
+			icon_file = "\\Resource\\Apps\\fshell_rcons.mif";
+#endif
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_rcons_reg.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// fshell_launch_rcons_reg.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 FSHELL_UID_FSHELL_LAUNCH_RCONS // application UID
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "fshell_launch_rcons"; // filename of application binary (minus extension)
+	localisable_resource_file = "\\resource\\apps\\fshell_launch_rcons_loc";
+	hidden = KAppNotHidden;
+	embeddability = KAppNotEmbeddable;
+	newfile = KAppDoesNotSupportNewFile;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_serial.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// fshell_launch_serial.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include "fshell_launch.mmh"
+
+target          fshell_launch_serial.exe
+uid             0 FSHELL_UID_FSHELL_LAUNCH_SERIAL
+macro           FSHELL_CORE_LAUNCH_SERIAL
+
+sourcepath      .
+
+START RESOURCE	fshell_launch_serial.rss
+    TARGETPATH  \private\10003a3f\apps
+END
+
+START RESOURCE  fshell_launch_serial_loc.rss
+    TARGETPATH  \resource\apps
+    LANG        SC
+END
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_serial.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// fshell_launch_serial.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 FSHELL_UID_FSHELL_LAUNCH_SERIAL // application UID
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "fshell_launch_serial"; // filename of application binary (minus extension)
+	localisable_resource_file = "\\Resource\\Apps\\fshell_launch_serial_loc.rsc";
+	hidden = KAppNotHidden;
+	embeddability = KAppNotEmbeddable;
+	newfile = KAppDoesNotSupportNewFile;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_serial_loc.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// fshell_launch_serial_loc.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = "fshell (Serial)";
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO
+			{
+			caption = "Launch fshell via an serial connection.";
+//#ifndef FSHELL_PLATFORM_UIQ
+//			number_of_icons = 1;
+//			icon_file = "\\Resource\\Apps\\fshell_usb.mif";
+//#endif
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_tcp.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// fshell_launch_tcp.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include "fshell_launch.mmh"
+
+target          fshell_launch_tcp.exe
+uid             0 FSHELL_UID_FSHELL_LAUNCH_TCP
+macro           FSHELL_CORE_LAUNCH_TCP
+
+sourcepath      .
+
+START RESOURCE	fshell_launch_tcp_reg.rss
+    TARGETPATH  \private\10003a3f\apps
+END
+
+START RESOURCE  fshell_launch_tcp_loc.rss
+    TARGETPATH  \resource\apps
+    LANG        SC
+END
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_tcp_loc.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// fshell_launch_tcp_loc.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = "fshell (TCP)";
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO
+			{
+			caption = "fshell via incoming TCP connection";
+#ifndef FSHELL_PLATFORM_UIQ
+			number_of_icons = 1;
+			icon_file = "\\Resource\\Apps\\fshell_tcp.mif";
+#endif
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_tcp_reg.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// fshell_launch_tcp_reg.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 FSHELL_UID_FSHELL_LAUNCH_TCP // application UID
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "fshell_launch_tcp"; // filename of application binary (minus extension)
+	localisable_resource_file = "\\resource\\apps\\fshell_launch_tcp_loc";
+	hidden = KAppNotHidden;
+	embeddability = KAppNotEmbeddable;
+	newfile = KAppDoesNotSupportNewFile;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_usb.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// fshell_launch_usb.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include "fshell_launch.mmh"
+
+target          fshell_launch_usb.exe
+uid             0 FSHELL_UID_FSHELL_LAUNCH_USB
+macro           FSHELL_CORE_LAUNCH_USB
+
+sourcepath      .
+
+START RESOURCE	fshell_launch_usb_reg.rss
+    TARGETPATH  \private\10003a3f\apps
+END
+
+START RESOURCE  fshell_launch_usb_loc.rss
+    TARGETPATH  \resource\apps
+    LANG        SC
+END
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_usb_loc.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// fshell_launch_usb_loc.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = "fshell (USB)";
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO
+			{
+			caption = "fshell via USB ACM";
+#ifndef FSHELL_PLATFORM_UIQ
+			number_of_icons = 1;
+			icon_file = "\\Resource\\Apps\\fshell_usb.mif";
+#endif
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_launch_usb_reg.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// fshell_launch_usb_reg.rss
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 FSHELL_UID_FSHELL_LAUNCH_USB // application UID
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "fshell_launch_usb"; // filename of application binary (minus extension)
+	localisable_resource_file = "\\resource\\apps\\fshell_launch_usb_loc";
+	hidden = KAppNotHidden;
+	embeddability = KAppNotEmbeddable;
+	newfile = KAppDoesNotSupportNewFile;
+	}
Binary file core/extra/launch/fshell_local.mif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_local.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="84"
+   height="58"
+   viewBox="0 0 84 58"
+   id="svg6562">
+  <defs
+     id="defs6649" />
+  <rect
+     width="59.448528"
+     height="49.411762"
+     x="11.889707"
+     y="4.1102939"
+     id="rect6661"
+     style="fill:#0000ff" />
+  <path
+     d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z"
+     id="text2481"
+     style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold" />
+  <path
+     d="M 35.683824,48.735292 L 35.683824,37.422792 L 36.894761,37.422792 L 36.894761,48.735292 L 35.683824,48.735292 z M 44.676011,45.032167 C 44.676005,44.573838 44.620015,44.166286 44.508043,43.809511 C 44.396057,43.452745 44.239807,43.150662 44.039293,42.903261 C 43.838766,42.655871 43.600485,42.468371 43.324449,42.340761 C 43.048402,42.213163 42.746319,42.149361 42.418199,42.149354 C 42.09007,42.149361 41.787987,42.213163 41.511949,42.340761 C 41.235904,42.468371 40.997623,42.655871 40.797105,42.903261 C 40.596582,43.150662 40.440332,43.452745 40.328355,43.809511 C 40.216374,44.166286 40.160384,44.573838 40.160386,45.032167 C 40.160384,45.485295 40.216374,45.890243 40.328355,46.247011 C 40.440332,46.603784 40.597884,46.904565 40.801011,47.149354 C 41.004134,47.394147 41.243717,47.580345 41.519761,47.707948 C 41.795799,47.835553 42.097882,47.899355 42.426011,47.899354 C 42.754132,47.899355 43.054913,47.835553 43.328355,47.707948 C 43.601787,47.580345 43.838766,47.394147 44.039293,47.149354 C 44.239807,46.904565 44.396057,46.603784 44.508043,46.247011 C 44.620015,45.890243 44.676005,45.485295 44.676011,45.032167 L 44.676011,45.032167 z M 45.941636,45.032167 C 45.941629,45.615503 45.858295,46.146753 45.691636,46.625917 C 45.524962,47.105085 45.289285,47.515241 44.984605,47.856386 C 44.679911,48.197532 44.311422,48.461855 43.879136,48.649354 C 43.446839,48.836854 42.962465,48.930604 42.426011,48.930604 C 41.873924,48.930604 41.380435,48.836854 40.945543,48.649354 C 40.510644,48.461855 40.140853,48.197532 39.836168,47.856386 C 39.531479,47.515241 39.298406,47.105085 39.136949,46.625917 C 38.97549,46.146753 38.894761,45.615503 38.894761,45.032167 C 38.894761,44.44363 38.978094,43.909776 39.144761,43.430604 C 39.311427,42.951444 39.547104,42.539986 39.851793,42.196229 C 40.156478,41.852486 40.526269,41.586862 40.961168,41.399354 C 41.39606,41.211862 41.881737,41.118112 42.418199,41.118104 C 42.965069,41.118112 43.457256,41.211862 43.894761,41.399354 C 44.332255,41.586862 44.702046,41.852486 45.004136,42.196229 C 45.306213,42.539986 45.537983,42.951444 45.699449,43.430604 C 45.860899,43.909776 45.941629,44.44363 45.941636,45.032167 L 45.941636,45.032167 z M 51.043199,41.118104 C 51.402569,41.118112 51.746319,41.155872 52.074449,41.231386 C 52.402568,41.306914 52.683818,41.412383 52.918199,41.547792 L 52.918199,42.555604 C 52.590068,42.430611 52.287985,42.336861 52.011949,42.274354 C 51.735902,42.211861 51.454652,42.180611 51.168199,42.180604 C 50.866111,42.180611 50.566632,42.23009 50.269761,42.329042 C 49.972883,42.428007 49.707258,42.590767 49.472886,42.817323 C 49.238509,43.043891 49.049707,43.34337 48.90648,43.715761 C 48.763249,44.088161 48.691634,44.5504 48.691636,45.102479 C 48.691634,45.503524 48.74502,45.873316 48.851793,46.211854 C 48.958561,46.550398 49.117415,46.843367 49.328355,47.090761 C 49.53929,47.338158 49.803612,47.530866 50.121324,47.668886 C 50.439028,47.806907 50.806216,47.875918 51.222886,47.875917 C 51.524965,47.875918 51.829652,47.843366 52.136949,47.778261 C 52.444235,47.713158 52.743714,47.62071 53.035386,47.500917 L 53.035386,48.508729 C 52.946838,48.560813 52.830953,48.612896 52.68773,48.664979 C 52.544495,48.717063 52.386943,48.762636 52.215074,48.801698 C 52.043193,48.840761 51.860902,48.872011 51.668199,48.895448 C 51.475486,48.918885 51.282778,48.930604 51.090074,48.930604 C 50.59007,48.930604 50.117414,48.855083 49.672105,48.704042 C 49.22679,48.553 48.837468,48.32123 48.504136,48.008729 C 48.170802,47.69623 47.907781,47.300398 47.715074,46.821229 C 47.522365,46.342065 47.426011,45.774357 47.426011,45.118104 C 47.426011,44.628525 47.476792,44.188421 47.578355,43.797792 C 47.679917,43.407172 47.819239,43.063423 47.996324,42.766542 C 48.173406,42.469673 48.380437,42.217069 48.617418,42.008729 C 48.854395,41.800403 49.106999,41.62983 49.37523,41.497011 C 49.643456,41.364206 49.9208,41.267851 50.207261,41.207948 C 50.493716,41.14806 50.772361,41.118112 51.043199,41.118104 L 51.043199,41.118104 z M 59.230699,47.914979 L 59.199449,47.914979 C 59.100485,48.03998 58.975485,48.163678 58.824449,48.286073 C 58.673402,48.408469 58.498923,48.517844 58.301011,48.614198 C 58.10309,48.710552 57.886945,48.787375 57.652574,48.844667 C 57.418195,48.901958 57.168195,48.930604 56.902574,48.930604 C 56.543196,48.930604 56.213769,48.877219 55.914293,48.770448 C 55.614812,48.663677 55.356999,48.507428 55.140855,48.301698 C 54.924708,48.09597 54.756739,47.844668 54.636949,47.547792 C 54.517156,47.250918 54.457261,46.914981 54.457261,46.539979 C 54.457261,46.17019 54.523667,45.839461 54.65648,45.547792 C 54.789292,45.256129 54.975489,45.008733 55.215074,44.805604 C 55.454655,44.602484 55.742416,44.446234 56.078355,44.336854 C 56.41429,44.227484 56.785383,44.172796 57.191636,44.172792 C 57.577049,44.178005 57.93382,44.211859 58.261949,44.274354 C 58.590069,44.336859 58.881735,44.414984 59.136949,44.508729 L 59.168199,44.508729 L 59.168199,43.993104 C 59.168193,43.789984 59.155173,43.610297 59.129136,43.454042 C 59.103089,43.297797 59.058819,43.159777 58.996324,43.039979 C 58.860902,42.789985 58.644756,42.582954 58.347886,42.418886 C 58.051007,42.25483 57.649966,42.172798 57.144761,42.172792 C 56.769758,42.172798 56.416894,42.207955 56.086168,42.278261 C 55.755436,42.34858 55.42601,42.446236 55.097886,42.571229 L 55.097886,41.555604 C 55.222885,41.493112 55.37002,41.434518 55.539293,41.379823 C 55.708561,41.325143 55.886947,41.278268 56.074449,41.239198 C 56.261946,41.200143 56.459863,41.170195 56.668199,41.149354 C 56.876529,41.128529 57.084862,41.118112 57.293199,41.118104 C 58.043195,41.118112 58.656475,41.250924 59.133043,41.516542 C 59.609599,41.782174 59.952047,42.133736 60.160386,42.571229 C 60.238505,42.737902 60.294494,42.921496 60.328355,43.122011 C 60.362203,43.322537 60.37913,43.542589 60.379136,43.782167 L 60.379136,48.735292 L 59.363511,48.735292 L 59.230699,47.914979 z M 59.168199,45.477479 C 58.944235,45.414983 58.678611,45.355087 58.371324,45.297792 C 58.064028,45.240504 57.725487,45.209254 57.355699,45.204042 C 56.840071,45.204045 56.436425,45.31342 56.144761,45.532167 C 55.853093,45.75092 55.707259,46.086857 55.707261,46.539979 C 55.707259,46.769148 55.743718,46.969669 55.816636,47.141542 C 55.889551,47.313418 55.989811,47.455345 56.117418,47.567323 C 56.245019,47.679303 56.396061,47.762637 56.570543,47.817323 C 56.745019,47.872012 56.931216,47.899355 57.129136,47.899354 C 57.389549,47.899355 57.631737,47.861595 57.855699,47.786073 C 58.079653,47.710553 58.278871,47.62071 58.453355,47.516542 C 58.627829,47.412377 58.776267,47.30821 58.898668,47.204042 C 59.021058,47.099877 59.110902,47.019148 59.168199,46.961854 L 59.168199,45.477479 z M 62.808824,48.735292 L 62.808824,37.422792 L 64.019761,37.422792 L 64.019761,48.735292 L 62.808824,48.735292 z"
+     id="text6673"
+     style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel" />
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_local.tiny.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" height="58" version="1.0" viewBox="0 0 84 58" width="84">
+<rect height="49.411762" style="fill:#0000ff" width="59.448528" x="11.889707" y="4.1102939"/>
+<path d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z" style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold"/>
+<path d="M 35.683824,48.735292 L 35.683824,37.422792 L 36.894761,37.422792 L 36.894761,48.735292 L 35.683824,48.735292 z M 44.676011,45.032167 C 44.676005,44.573838 44.620015,44.166286 44.508043,43.809511 C 44.396057,43.452745 44.239807,43.150662 44.039293,42.903261 C 43.838766,42.655871 43.600485,42.468371 43.324449,42.340761 C 43.048402,42.213163 42.746319,42.149361 42.418199,42.149354 C 42.09007,42.149361 41.787987,42.213163 41.511949,42.340761 C 41.235904,42.468371 40.997623,42.655871 40.797105,42.903261 C 40.596582,43.150662 40.440332,43.452745 40.328355,43.809511 C 40.216374,44.166286 40.160384,44.573838 40.160386,45.032167 C 40.160384,45.485295 40.216374,45.890243 40.328355,46.247011 C 40.440332,46.603784 40.597884,46.904565 40.801011,47.149354 C 41.004134,47.394147 41.243717,47.580345 41.519761,47.707948 C 41.795799,47.835553 42.097882,47.899355 42.426011,47.899354 C 42.754132,47.899355 43.054913,47.835553 43.328355,47.707948 C 43.601787,47.580345 43.838766,47.394147 44.039293,47.149354 C 44.239807,46.904565 44.396057,46.603784 44.508043,46.247011 C 44.620015,45.890243 44.676005,45.485295 44.676011,45.032167 L 44.676011,45.032167 z M 45.941636,45.032167 C 45.941629,45.615503 45.858295,46.146753 45.691636,46.625917 C 45.524962,47.105085 45.289285,47.515241 44.984605,47.856386 C 44.679911,48.197532 44.311422,48.461855 43.879136,48.649354 C 43.446839,48.836854 42.962465,48.930604 42.426011,48.930604 C 41.873924,48.930604 41.380435,48.836854 40.945543,48.649354 C 40.510644,48.461855 40.140853,48.197532 39.836168,47.856386 C 39.531479,47.515241 39.298406,47.105085 39.136949,46.625917 C 38.97549,46.146753 38.894761,45.615503 38.894761,45.032167 C 38.894761,44.44363 38.978094,43.909776 39.144761,43.430604 C 39.311427,42.951444 39.547104,42.539986 39.851793,42.196229 C 40.156478,41.852486 40.526269,41.586862 40.961168,41.399354 C 41.39606,41.211862 41.881737,41.118112 42.418199,41.118104 C 42.965069,41.118112 43.457256,41.211862 43.894761,41.399354 C 44.332255,41.586862 44.702046,41.852486 45.004136,42.196229 C 45.306213,42.539986 45.537983,42.951444 45.699449,43.430604 C 45.860899,43.909776 45.941629,44.44363 45.941636,45.032167 L 45.941636,45.032167 z M 51.043199,41.118104 C 51.402569,41.118112 51.746319,41.155872 52.074449,41.231386 C 52.402568,41.306914 52.683818,41.412383 52.918199,41.547792 L 52.918199,42.555604 C 52.590068,42.430611 52.287985,42.336861 52.011949,42.274354 C 51.735902,42.211861 51.454652,42.180611 51.168199,42.180604 C 50.866111,42.180611 50.566632,42.23009 50.269761,42.329042 C 49.972883,42.428007 49.707258,42.590767 49.472886,42.817323 C 49.238509,43.043891 49.049707,43.34337 48.90648,43.715761 C 48.763249,44.088161 48.691634,44.5504 48.691636,45.102479 C 48.691634,45.503524 48.74502,45.873316 48.851793,46.211854 C 48.958561,46.550398 49.117415,46.843367 49.328355,47.090761 C 49.53929,47.338158 49.803612,47.530866 50.121324,47.668886 C 50.439028,47.806907 50.806216,47.875918 51.222886,47.875917 C 51.524965,47.875918 51.829652,47.843366 52.136949,47.778261 C 52.444235,47.713158 52.743714,47.62071 53.035386,47.500917 L 53.035386,48.508729 C 52.946838,48.560813 52.830953,48.612896 52.68773,48.664979 C 52.544495,48.717063 52.386943,48.762636 52.215074,48.801698 C 52.043193,48.840761 51.860902,48.872011 51.668199,48.895448 C 51.475486,48.918885 51.282778,48.930604 51.090074,48.930604 C 50.59007,48.930604 50.117414,48.855083 49.672105,48.704042 C 49.22679,48.553 48.837468,48.32123 48.504136,48.008729 C 48.170802,47.69623 47.907781,47.300398 47.715074,46.821229 C 47.522365,46.342065 47.426011,45.774357 47.426011,45.118104 C 47.426011,44.628525 47.476792,44.188421 47.578355,43.797792 C 47.679917,43.407172 47.819239,43.063423 47.996324,42.766542 C 48.173406,42.469673 48.380437,42.217069 48.617418,42.008729 C 48.854395,41.800403 49.106999,41.62983 49.37523,41.497011 C 49.643456,41.364206 49.9208,41.267851 50.207261,41.207948 C 50.493716,41.14806 50.772361,41.118112 51.043199,41.118104 L 51.043199,41.118104 z M 59.230699,47.914979 L 59.199449,47.914979 C 59.100485,48.03998 58.975485,48.163678 58.824449,48.286073 C 58.673402,48.408469 58.498923,48.517844 58.301011,48.614198 C 58.10309,48.710552 57.886945,48.787375 57.652574,48.844667 C 57.418195,48.901958 57.168195,48.930604 56.902574,48.930604 C 56.543196,48.930604 56.213769,48.877219 55.914293,48.770448 C 55.614812,48.663677 55.356999,48.507428 55.140855,48.301698 C 54.924708,48.09597 54.756739,47.844668 54.636949,47.547792 C 54.517156,47.250918 54.457261,46.914981 54.457261,46.539979 C 54.457261,46.17019 54.523667,45.839461 54.65648,45.547792 C 54.789292,45.256129 54.975489,45.008733 55.215074,44.805604 C 55.454655,44.602484 55.742416,44.446234 56.078355,44.336854 C 56.41429,44.227484 56.785383,44.172796 57.191636,44.172792 C 57.577049,44.178005 57.93382,44.211859 58.261949,44.274354 C 58.590069,44.336859 58.881735,44.414984 59.136949,44.508729 L 59.168199,44.508729 L 59.168199,43.993104 C 59.168193,43.789984 59.155173,43.610297 59.129136,43.454042 C 59.103089,43.297797 59.058819,43.159777 58.996324,43.039979 C 58.860902,42.789985 58.644756,42.582954 58.347886,42.418886 C 58.051007,42.25483 57.649966,42.172798 57.144761,42.172792 C 56.769758,42.172798 56.416894,42.207955 56.086168,42.278261 C 55.755436,42.34858 55.42601,42.446236 55.097886,42.571229 L 55.097886,41.555604 C 55.222885,41.493112 55.37002,41.434518 55.539293,41.379823 C 55.708561,41.325143 55.886947,41.278268 56.074449,41.239198 C 56.261946,41.200143 56.459863,41.170195 56.668199,41.149354 C 56.876529,41.128529 57.084862,41.118112 57.293199,41.118104 C 58.043195,41.118112 58.656475,41.250924 59.133043,41.516542 C 59.609599,41.782174 59.952047,42.133736 60.160386,42.571229 C 60.238505,42.737902 60.294494,42.921496 60.328355,43.122011 C 60.362203,43.322537 60.37913,43.542589 60.379136,43.782167 L 60.379136,48.735292 L 59.363511,48.735292 L 59.230699,47.914979 z M 59.168199,45.477479 C 58.944235,45.414983 58.678611,45.355087 58.371324,45.297792 C 58.064028,45.240504 57.725487,45.209254 57.355699,45.204042 C 56.840071,45.204045 56.436425,45.31342 56.144761,45.532167 C 55.853093,45.75092 55.707259,46.086857 55.707261,46.539979 C 55.707259,46.769148 55.743718,46.969669 55.816636,47.141542 C 55.889551,47.313418 55.989811,47.455345 56.117418,47.567323 C 56.245019,47.679303 56.396061,47.762637 56.570543,47.817323 C 56.745019,47.872012 56.931216,47.899355 57.129136,47.899354 C 57.389549,47.899355 57.631737,47.861595 57.855699,47.786073 C 58.079653,47.710553 58.278871,47.62071 58.453355,47.516542 C 58.627829,47.412377 58.776267,47.30821 58.898668,47.204042 C 59.021058,47.099877 59.110902,47.019148 59.168199,46.961854 L 59.168199,45.477479 z M 62.808824,48.735292 L 62.808824,37.422792 L 64.019761,37.422792 L 64.019761,48.735292 L 62.808824,48.735292 z" style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel"/>
+</svg>
Binary file core/extra/launch/fshell_rcons.mif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_rcons.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   version="1.0"
+   width="84"
+   height="58"
+   viewBox="0 0 84 58"
+   id="svg6562"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   sodipodi:docname="fshell_rcons.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape">
+  <metadata
+     id="metadata2449">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     inkscape:window-height="675"
+     inkscape:window-width="640"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     guidetolerance="10.0"
+     gridtolerance="10.0"
+     objecttolerance="10.0"
+     borderopacity="1.0"
+     bordercolor="#666666"
+     pagecolor="#ffffff"
+     id="base"
+     showgrid="false"
+     inkscape:zoom="6.4761905"
+     inkscape:cx="42"
+     inkscape:cy="29"
+     inkscape:window-x="22"
+     inkscape:window-y="22"
+     inkscape:current-layer="svg6562" />
+  <defs
+     id="defs6649">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 29 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="84 : 29 : 1"
+       inkscape:persp3d-origin="42 : 19.333333 : 1"
+       id="perspective2451" />
+  </defs>
+  <rect
+     width="59.448528"
+     height="49.411762"
+     x="11.889707"
+     y="4.1102939"
+     id="rect6661"
+     style="fill:#0000ff" />
+  <path
+     d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z"
+     id="text2481"
+     style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold" />
+  <text
+     xml:space="preserve"
+     style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel"
+     x="29.183825"
+     y="47.345589"
+     id="text2453"
+     sodipodi:linespacing="125%"><tspan
+       sodipodi:role="line"
+       id="tspan2455"
+       x="29.183825"
+       y="47.345589">rcons</tspan></text>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_rcons.tiny.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" height="58" version="1.0" viewBox="0 0 84 58" width="84">
+<defs/>
+<rect height="49.411762" style="fill:#0000ff" width="59.448528" x="11.889707" y="4.1102939"/>
+<path d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z" style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold"/>
+<text style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel" x="29.183825" y="47.345589"/>
+</svg>
Binary file core/extra/launch/fshell_tcp.mif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_tcp.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   version="1.0"
+   width="84"
+   height="58"
+   viewBox="0 0 84 58"
+   id="svg6562">
+  <defs
+     id="defs6649" />
+  <rect
+     width="59.448528"
+     height="49.411762"
+     x="11.889707"
+     y="4.1102939"
+     id="rect6661"
+     style="fill:#0000ff" />
+  <path
+     d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z"
+     id="text2481"
+     style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold" />
+  <path
+     d="M 42.44577,47.963238 L 41.172333,47.963238 L 41.172333,38.65855 L 37.680145,38.65855 L 37.680145,37.510113 L 45.937958,37.510113 L 45.937958,38.65855 L 42.44577,38.65855 L 42.44577,47.963238 z M 52.648895,38.447613 C 52.070764,38.447622 51.5304,38.54007 51.027802,38.724957 C 50.525193,38.909861 50.088996,39.185903 49.719208,39.553082 C 49.349413,39.920277 49.057747,40.376006 48.844208,40.920269 C 48.630664,41.464546 48.523893,42.09866 48.523895,42.822613 C 48.523893,43.541367 48.622851,44.165064 48.82077,44.693707 C 49.018684,45.222355 49.299934,45.659855 49.66452,46.006207 C 50.0291,46.352562 50.467901,46.609072 50.980927,46.775738 C 51.493942,46.942405 52.065556,47.025739 52.69577,47.025738 C 52.867639,47.025739 53.04993,47.016624 53.242645,46.998394 C 53.435346,46.980166 53.629357,46.954124 53.824677,46.920269 C 54.019981,46.886416 54.210085,46.847353 54.394989,46.803082 C 54.579877,46.758812 54.745241,46.710635 54.891083,46.65855 L 54.891083,47.78355 C 54.583783,47.903342 54.227012,47.99579 53.82077,48.060894 C 53.414513,48.125998 52.997847,48.15855 52.57077,48.15855 C 51.700973,48.15855 50.930141,48.037456 50.25827,47.795269 C 49.586392,47.553082 49.02259,47.205426 48.566864,46.7523 C 48.111133,46.299177 47.766081,45.745792 47.531708,45.092144 C 47.297332,44.438502 47.180144,43.697617 47.180145,42.869488 C 47.180144,42.056994 47.303842,41.309599 47.551239,40.6273 C 47.798633,39.945017 48.155404,39.35908 48.621552,38.869488 C 49.087695,38.379914 49.652798,37.998404 50.316864,37.724957 C 50.980922,37.45153 51.727015,37.314811 52.555145,37.3148 C 52.773889,37.314811 52.990034,37.323925 53.203583,37.342144 C 53.417117,37.360384 53.621544,37.386425 53.816864,37.420269 C 54.012169,37.454134 54.193158,37.494498 54.359833,37.541363 C 54.526491,37.588248 54.66972,37.637727 54.78952,37.6898 L 54.78952,38.8148 C 54.477012,38.710643 54.135867,38.623403 53.766083,38.553082 C 53.396284,38.482778 53.023888,38.447622 52.648895,38.447613 L 52.648895,38.447613 z M 58.281708,47.963238 L 57.00827,47.963238 L 57.00827,37.510113 L 59.906708,37.510113 C 60.338995,37.510123 60.738734,37.536165 61.105927,37.588238 C 61.473108,37.640331 61.810347,37.721061 62.117645,37.830425 C 62.742638,38.054394 63.216596,38.389029 63.53952,38.834332 C 63.862429,39.279653 64.023887,39.827829 64.023895,40.478863 C 64.023887,41.01012 63.918418,41.477567 63.707489,41.881207 C 63.496544,42.284858 63.190554,42.622097 62.78952,42.892925 C 62.388472,43.163763 61.900191,43.36819 61.324677,43.506207 C 60.749151,43.644232 60.096808,43.713242 59.367645,43.713238 C 59.018684,43.713242 58.656705,43.697617 58.281708,43.666363 L 58.281708,47.963238 z M 58.281708,42.5023 C 58.45358,42.523139 58.633267,42.538764 58.82077,42.549175 C 59.008267,42.559597 59.18535,42.564806 59.35202,42.5648 C 59.950974,42.564806 60.46139,42.517931 60.88327,42.424175 C 61.30514,42.330431 61.648889,42.193712 61.91452,42.014019 C 62.180139,41.834338 62.372847,41.615588 62.492645,41.357769 C 62.61243,41.099963 62.672326,40.806995 62.672333,40.478863 C 62.672326,40.072621 62.57467,39.739288 62.379364,39.478863 C 62.184045,39.218455 61.906702,39.020538 61.547333,38.885113 C 61.323369,38.801789 61.065557,38.743195 60.773895,38.709332 C 60.482224,38.675487 60.143682,38.65856 59.75827,38.65855 L 58.281708,38.65855 L 58.281708,42.5023 z"
+     id="text2503"
+     style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel" />
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_tcp.tiny.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" height="58" version="1.0" viewBox="0 0 84 58" width="84">
+<rect height="49.411762" style="fill:#0000ff" width="59.448528" x="11.889707" y="4.1102939"/>
+<path d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z" style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold"/>
+<path d="M 42.44577,47.963238 L 41.172333,47.963238 L 41.172333,38.65855 L 37.680145,38.65855 L 37.680145,37.510113 L 45.937958,37.510113 L 45.937958,38.65855 L 42.44577,38.65855 L 42.44577,47.963238 z M 52.648895,38.447613 C 52.070764,38.447622 51.5304,38.54007 51.027802,38.724957 C 50.525193,38.909861 50.088996,39.185903 49.719208,39.553082 C 49.349413,39.920277 49.057747,40.376006 48.844208,40.920269 C 48.630664,41.464546 48.523893,42.09866 48.523895,42.822613 C 48.523893,43.541367 48.622851,44.165064 48.82077,44.693707 C 49.018684,45.222355 49.299934,45.659855 49.66452,46.006207 C 50.0291,46.352562 50.467901,46.609072 50.980927,46.775738 C 51.493942,46.942405 52.065556,47.025739 52.69577,47.025738 C 52.867639,47.025739 53.04993,47.016624 53.242645,46.998394 C 53.435346,46.980166 53.629357,46.954124 53.824677,46.920269 C 54.019981,46.886416 54.210085,46.847353 54.394989,46.803082 C 54.579877,46.758812 54.745241,46.710635 54.891083,46.65855 L 54.891083,47.78355 C 54.583783,47.903342 54.227012,47.99579 53.82077,48.060894 C 53.414513,48.125998 52.997847,48.15855 52.57077,48.15855 C 51.700973,48.15855 50.930141,48.037456 50.25827,47.795269 C 49.586392,47.553082 49.02259,47.205426 48.566864,46.7523 C 48.111133,46.299177 47.766081,45.745792 47.531708,45.092144 C 47.297332,44.438502 47.180144,43.697617 47.180145,42.869488 C 47.180144,42.056994 47.303842,41.309599 47.551239,40.6273 C 47.798633,39.945017 48.155404,39.35908 48.621552,38.869488 C 49.087695,38.379914 49.652798,37.998404 50.316864,37.724957 C 50.980922,37.45153 51.727015,37.314811 52.555145,37.3148 C 52.773889,37.314811 52.990034,37.323925 53.203583,37.342144 C 53.417117,37.360384 53.621544,37.386425 53.816864,37.420269 C 54.012169,37.454134 54.193158,37.494498 54.359833,37.541363 C 54.526491,37.588248 54.66972,37.637727 54.78952,37.6898 L 54.78952,38.8148 C 54.477012,38.710643 54.135867,38.623403 53.766083,38.553082 C 53.396284,38.482778 53.023888,38.447622 52.648895,38.447613 L 52.648895,38.447613 z M 58.281708,47.963238 L 57.00827,47.963238 L 57.00827,37.510113 L 59.906708,37.510113 C 60.338995,37.510123 60.738734,37.536165 61.105927,37.588238 C 61.473108,37.640331 61.810347,37.721061 62.117645,37.830425 C 62.742638,38.054394 63.216596,38.389029 63.53952,38.834332 C 63.862429,39.279653 64.023887,39.827829 64.023895,40.478863 C 64.023887,41.01012 63.918418,41.477567 63.707489,41.881207 C 63.496544,42.284858 63.190554,42.622097 62.78952,42.892925 C 62.388472,43.163763 61.900191,43.36819 61.324677,43.506207 C 60.749151,43.644232 60.096808,43.713242 59.367645,43.713238 C 59.018684,43.713242 58.656705,43.697617 58.281708,43.666363 L 58.281708,47.963238 z M 58.281708,42.5023 C 58.45358,42.523139 58.633267,42.538764 58.82077,42.549175 C 59.008267,42.559597 59.18535,42.564806 59.35202,42.5648 C 59.950974,42.564806 60.46139,42.517931 60.88327,42.424175 C 61.30514,42.330431 61.648889,42.193712 61.91452,42.014019 C 62.180139,41.834338 62.372847,41.615588 62.492645,41.357769 C 62.61243,41.099963 62.672326,40.806995 62.672333,40.478863 C 62.672326,40.072621 62.57467,39.739288 62.379364,39.478863 C 62.184045,39.218455 61.906702,39.020538 61.547333,38.885113 C 61.323369,38.801789 61.065557,38.743195 60.773895,38.709332 C 60.482224,38.675487 60.143682,38.65856 59.75827,38.65855 L 58.281708,38.65855 L 58.281708,42.5023 z" style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel"/>
+</svg>
Binary file core/extra/launch/fshell_usb.mif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_usb.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   version="1.0"
+   width="84"
+   height="58"
+   viewBox="0 0 84 58"
+   id="svg6562"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   sodipodi:docname="fshell_usb.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape">
+  <metadata
+     id="metadata2449">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     inkscape:window-height="675"
+     inkscape:window-width="640"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     guidetolerance="10.0"
+     gridtolerance="10.0"
+     objecttolerance="10.0"
+     borderopacity="1.0"
+     bordercolor="#666666"
+     pagecolor="#ffffff"
+     id="base"
+     showgrid="false"
+     inkscape:zoom="6.4761905"
+     inkscape:cx="42"
+     inkscape:cy="29"
+     inkscape:window-x="176"
+     inkscape:window-y="98"
+     inkscape:current-layer="svg6562" />
+  <defs
+     id="defs6649">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 29 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="84 : 29 : 1"
+       inkscape:persp3d-origin="42 : 19.333333 : 1"
+       id="perspective2451" />
+  </defs>
+  <rect
+     width="59.448528"
+     height="49.411762"
+     x="11.889707"
+     y="4.1102939"
+     id="rect6661"
+     style="fill:#0000ff" />
+  <path
+     d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z"
+     id="text2481"
+     style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold" />
+  <path
+     style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel"
+     d="M 41.808361,47.643379 C 42.188564,47.64338 42.525803,47.599109 42.82008,47.510567 C 43.114344,47.422026 43.370854,47.297026 43.589611,47.135567 C 43.808354,46.97411 43.990645,46.7801 44.136486,46.553535 C 44.282312,46.326975 44.394291,46.075673 44.472424,45.799629 C 44.524499,45.627757 44.560957,45.436351 44.581799,45.22541 C 44.602624,45.014477 44.61304,44.81005 44.613049,44.612129 L 44.613049,38.127754 L 45.886486,38.127754 L 45.886486,44.580879 C 45.886477,44.825675 45.873456,45.080883 45.847424,45.346504 C 45.821373,45.612132 45.779706,45.859528 45.722424,46.088692 C 45.623456,46.47411 45.475019,46.830881 45.277111,47.159004 C 45.079186,47.48713 44.821374,47.770984 44.503674,48.010567 C 44.185957,48.25015 43.804447,48.43765 43.359142,48.573067 C 42.913823,48.708483 42.391688,48.776192 41.792736,48.776192 C 41.219815,48.776192 40.717211,48.713692 40.284924,48.588692 C 39.852628,48.463692 39.481535,48.290515 39.171642,48.06916 C 38.861744,47.847807 38.607838,47.584786 38.409924,47.280098 C 38.212005,46.975412 38.058359,46.643381 37.948986,46.284004 C 37.87086,46.02359 37.81487,45.744945 37.781017,45.448067 C 37.747162,45.151195 37.730235,44.862133 37.730236,44.580879 L 37.730236,38.127754 L 39.003674,38.127754 L 39.003674,44.612129 C 39.003671,44.846508 39.020598,45.087393 39.054455,45.334785 C 39.088306,45.582184 39.141692,45.807444 39.214611,46.010567 C 39.3969,46.515777 39.700285,46.914214 40.124767,47.205879 C 40.549242,47.497547 41.11044,47.64338 41.808361,47.643379 L 41.808361,47.643379 z M 49.488049,40.893379 C 49.488046,41.200678 49.550546,41.454584 49.675549,41.655098 C 49.800546,41.855626 49.968515,42.02099 50.179455,42.151192 C 50.390389,42.281406 50.635181,42.388177 50.91383,42.471504 C 51.192472,42.554844 51.482836,42.632968 51.784924,42.705879 C 52.191169,42.804843 52.590908,42.914218 52.984142,43.034004 C 53.377365,43.153801 53.727625,43.319166 54.034924,43.530098 C 54.342208,43.74104 54.590906,44.01578 54.781017,44.354317 C 54.971114,44.692862 55.066166,45.127758 55.066174,45.659004 C 55.066166,46.200673 54.965905,46.668121 54.765392,47.061348 C 54.564864,47.454578 54.286219,47.777495 53.929455,48.030098 C 53.572678,48.282702 53.146897,48.470202 52.652111,48.592598 C 52.157314,48.714994 51.615648,48.776192 51.027111,48.776192 C 50.756274,48.776192 50.478931,48.759264 50.19508,48.72541 C 49.911223,48.691556 49.64039,48.645983 49.38258,48.588692 C 49.124765,48.5314 48.891693,48.466296 48.683361,48.393379 C 48.475026,48.320463 48.310964,48.247546 48.191174,48.174629 L 48.191174,47.010567 C 48.378672,47.104318 48.58961,47.190256 48.823986,47.268379 C 49.058359,47.346505 49.300546,47.412912 49.550549,47.467598 C 49.800546,47.522287 50.05315,47.565255 50.308361,47.596504 C 50.563566,47.627755 50.803149,47.64338 51.027111,47.643379 C 51.39169,47.64338 51.739346,47.61213 52.07008,47.549629 C 52.400804,47.48713 52.691168,47.382964 52.941174,47.237129 C 53.191168,47.091297 53.389084,46.892079 53.534924,46.639473 C 53.68075,46.386871 53.753667,46.070465 53.753674,45.690254 C 53.753667,45.377757 53.689865,45.119945 53.562267,44.916817 C 53.434657,44.713696 53.264084,44.545727 53.050549,44.41291 C 52.837001,44.280102 52.590908,44.172029 52.312267,44.088692 C 52.033617,44.005363 51.740648,43.927238 51.433361,43.854317 C 51.027107,43.760572 50.629972,43.655103 50.241955,43.53791 C 49.853931,43.420728 49.507577,43.257968 49.202892,43.049629 C 48.898203,42.841302 48.653412,42.573073 48.468517,42.244942 C 48.28362,41.916823 48.191173,41.497553 48.191174,40.987129 C 48.191173,40.455887 48.284922,39.998857 48.472424,39.616035 C 48.659922,39.233232 48.91513,38.916826 49.238049,38.666817 C 49.560963,38.416827 49.938567,38.231931 50.370861,38.112129 C 50.803149,37.992348 51.264086,37.932452 51.753674,37.932442 C 52.31096,37.932452 52.830491,37.985838 53.312267,38.092598 C 53.794032,38.199379 54.235437,38.338702 54.636486,38.510567 L 54.636486,39.690254 C 54.204187,39.507972 53.757573,39.359534 53.296642,39.244942 C 52.835699,39.130368 52.34221,39.070472 51.816174,39.065254 C 51.420336,39.065264 51.076586,39.108232 50.784924,39.19416 C 50.493254,39.280107 50.251066,39.402503 50.058361,39.561348 C 49.86565,39.720211 49.722421,39.912919 49.628674,40.139473 C 49.534921,40.366044 49.488046,40.617346 49.488049,40.893379 L 49.488049,40.893379 z M 62.519299,43.174629 C 62.842208,43.22151 63.132573,43.307447 63.390392,43.432442 C 63.648197,43.557447 63.869551,43.717603 64.054455,43.91291 C 64.239342,44.108227 64.381269,44.339998 64.480236,44.608223 C 64.579186,44.876456 64.628665,45.182445 64.628674,45.526192 C 64.628665,45.770986 64.592207,46.027496 64.519299,46.295723 C 64.446373,46.563954 64.32528,46.824371 64.156017,47.076973 C 63.986739,47.329578 63.765385,47.562651 63.491955,47.776192 C 63.21851,47.989734 62.878667,48.164213 62.472424,48.299629 C 62.159917,48.403796 61.813564,48.476713 61.433361,48.518379 C 61.053148,48.560046 60.597419,48.580879 60.066174,48.580879 L 57.363049,48.580879 L 57.363049,38.127754 L 59.972424,38.127754 C 60.212003,38.127765 60.42945,38.131671 60.624767,38.139473 C 60.820075,38.147296 60.999762,38.159015 61.16383,38.174629 C 61.327887,38.190265 61.480231,38.209796 61.620861,38.233223 C 61.76148,38.256671 61.894293,38.284015 62.019299,38.315254 C 62.347417,38.403806 62.645594,38.5249 62.91383,38.678535 C 63.182052,38.832191 63.409916,39.015785 63.597424,39.229317 C 63.784916,39.442868 63.929447,39.685055 64.031017,39.955879 C 64.132572,40.226721 64.183353,40.520991 64.183361,40.838692 C 64.183353,41.093908 64.153405,41.338699 64.093517,41.573067 C 64.033613,41.807448 63.937259,42.023594 63.804455,42.221504 C 63.671635,42.419427 63.49976,42.59651 63.28883,42.752754 C 63.077885,42.90901 62.821375,43.039218 62.519299,43.143379 L 62.519299,43.174629 z M 60.573986,42.651192 C 60.823981,42.651198 61.040127,42.639479 61.222424,42.616035 C 61.40471,42.592604 61.568772,42.557448 61.714611,42.510567 C 62.10523,42.380365 62.390386,42.17724 62.57008,41.901192 C 62.749761,41.625157 62.839604,41.299636 62.839611,40.924629 C 62.839604,40.539221 62.745854,40.224117 62.558361,39.979317 C 62.370855,39.734534 62.076584,39.552242 61.675549,39.432442 C 61.477626,39.375159 61.24846,39.334795 60.988049,39.311348 C 60.727627,39.28792 60.420336,39.276201 60.066174,39.276192 L 58.636486,39.276192 L 58.636486,42.651192 L 60.573986,42.651192 z M 58.636486,43.799629 L 58.636486,47.432442 L 60.175549,47.432442 C 60.540127,47.432443 60.878669,47.415516 61.191174,47.38166 C 61.503668,47.347808 61.769293,47.294422 61.988049,47.221504 C 62.227626,47.143381 62.43075,47.04312 62.597424,46.920723 C 62.764083,46.798329 62.898198,46.662912 62.999767,46.514473 C 63.101323,46.366038 63.174239,46.208486 63.218517,46.041817 C 63.262781,45.875153 63.284916,45.705882 63.284924,45.534004 C 63.284916,45.336091 63.261479,45.149893 63.214611,44.97541 C 63.167729,44.800935 63.090906,44.644685 62.984142,44.50666 C 62.877365,44.368644 62.73674,44.24755 62.562267,44.143379 C 62.387782,44.039217 62.170334,43.958488 61.909924,43.901192 C 61.753668,43.864738 61.575283,43.838696 61.374767,43.823067 C 61.174241,43.807446 60.925544,43.799634 60.628674,43.799629 L 58.636486,43.799629 z"
+     id="text2453" />
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/fshell_usb.tiny.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" height="58" version="1.0" viewBox="0 0 84 58" width="84">
+<defs/>
+<rect height="49.411762" style="fill:#0000ff" width="59.448528" x="11.889707" y="4.1102939"/>
+<path d="M 32.247932,12.929947 C 31.790888,12.812782 31.319209,12.716102 30.832893,12.639908 C 30.346554,12.563759 29.886593,12.525673 29.45301,12.52565 C 28.984251,12.525673 28.568235,12.581337 28.204963,12.692642 C 27.841674,12.803993 27.534057,12.988563 27.282112,13.246353 C 27.030151,13.504187 26.839721,13.838171 26.710823,14.248306 C 26.581909,14.658483 26.517456,15.156529 26.517463,15.742447 L 26.517463,17.974869 L 31.245979,17.974869 L 31.245979,21.402603 L 26.517463,21.402603 L 26.517463,35.008072 L 22.351447,35.008072 L 22.351447,21.402603 L 19.468635,21.402603 L 19.468635,17.974869 L 22.351447,17.974869 L 22.351447,15.953385 C 22.351444,14.758092 22.518436,13.729773 22.852423,12.868424 C 23.186404,12.007119 23.652224,11.298135 24.249884,10.741471 C 24.847535,10.184855 25.550659,9.7746992 26.35926,9.5110022 C 27.167846,9.2473562 28.046752,9.1155207 28.995979,9.1154947 C 29.581906,9.1155207 30.164913,9.1653247 30.745002,9.2649082 C 31.325069,9.3645432 31.826045,9.4846602 32.247932,9.6252602 L 32.247932,12.929947 z M 40.931526,30.068619 C 40.931516,29.705343 40.828977,29.406515 40.623909,29.172135 C 40.418821,28.937766 40.146361,28.741477 39.806526,28.583267 C 39.466674,28.425071 39.077026,28.287376 38.637581,28.170181 C 38.19812,28.053001 37.73816,27.935814 37.257698,27.818619 C 36.648317,27.654564 36.06238,27.464134 35.499885,27.24733 C 34.937381,27.030541 34.442265,26.746362 34.014534,26.394791 C 33.586797,26.043237 33.246953,25.600855 32.995002,25.067642 C 32.743048,24.53445 32.617071,23.88113 32.617073,23.107681 C 32.617071,22.158476 32.786993,21.335234 33.126838,20.637955 C 33.46668,19.940704 33.92664,19.363556 34.506721,18.90651 C 35.086795,18.449495 35.760623,18.109651 36.528206,17.886978 C 37.295778,17.664339 38.1073,17.553011 38.962776,17.552994 C 40.005736,17.553011 40.98425,17.637972 41.898323,17.807877 C 42.812374,17.977816 43.638545,18.197542 44.376838,18.467056 L 44.376838,21.859635 C 43.990107,21.730742 43.582881,21.610625 43.155159,21.499283 C 42.727413,21.387968 42.293819,21.291289 41.854377,21.209244 C 41.414914,21.127227 40.978391,21.059844 40.544807,21.007096 C 40.111204,20.954375 39.701049,20.928008 39.314338,20.927994 C 38.822143,20.928008 38.406128,20.974883 38.066292,21.068619 C 37.726441,21.162383 37.451051,21.288359 37.24012,21.446549 C 37.029176,21.604765 36.876833,21.786406 36.783088,21.991471 C 36.689333,22.196561 36.642458,22.410428 36.642463,22.633072 C 36.642458,23.019803 36.744997,23.336209 36.950081,23.582291 C 37.155153,23.828396 37.439332,24.027614 37.80262,24.179947 C 38.165894,24.332301 38.546753,24.458278 38.945198,24.557877 C 39.343627,24.657496 39.730345,24.754176 40.105354,24.847916 C 40.691282,24.988551 41.277219,25.158473 41.863167,25.357681 C 42.449093,25.55691 42.976436,25.83523 43.445198,26.192642 C 43.913935,26.550073 44.297724,27.012963 44.596565,27.581314 C 44.895379,28.14968 45.044793,28.873313 45.044807,29.752213 C 45.044793,30.713154 44.863153,31.551044 44.499885,32.265885 C 44.136591,32.98073 43.629756,33.575456 42.979377,34.050064 C 42.328976,34.524674 41.54968,34.876236 40.641487,35.104752 C 39.733275,35.333267 38.734253,35.447525 37.644417,35.447525 C 36.566286,35.447525 35.59656,35.362564 34.735237,35.192642 C 33.873906,35.02272 33.161993,34.808854 32.599495,34.551041 L 32.599495,31.193619 C 33.513555,31.533466 34.357304,31.764911 35.130745,31.887955 C 35.904177,32.011005 36.62488,32.072528 37.292854,32.072525 C 37.808472,32.072528 38.288941,32.034442 38.73426,31.958267 C 39.179565,31.882099 39.563353,31.761982 39.885627,31.597916 C 40.207884,31.433857 40.462767,31.225849 40.650276,30.973892 C 40.837766,30.721944 40.931516,30.420186 40.931526,30.068619 L 40.931526,30.068619 z M 52.99012,16.498306 C 52.990113,17.37723 52.975465,18.100862 52.946174,18.669205 C 52.916871,19.23758 52.867066,19.750275 52.79676,20.207291 L 52.867073,20.207291 C 53.11316,19.879181 53.414917,19.551056 53.772346,19.222916 C 54.12976,18.894807 54.522338,18.610628 54.950081,18.370377 C 55.377806,18.130159 55.864134,17.93387 56.409065,17.78151 C 56.953976,17.629183 57.554562,17.553011 58.210823,17.552994 C 58.77331,17.553011 59.321161,17.608675 59.854377,17.719986 C 60.387567,17.831331 60.885613,18.004183 61.348518,18.238541 C 61.811393,18.472932 62.233268,18.77762 62.614143,19.152603 C 62.994986,19.527619 63.314321,19.972931 63.572151,20.488541 C 63.79479,20.933867 63.958852,21.437773 64.064338,22.00026 C 64.169789,22.562772 64.222524,23.248318 64.222542,24.0569 L 64.222542,35.008072 L 60.056526,35.008072 L 60.056526,24.6194 C 60.056512,24.092067 60.033075,23.661404 59.986213,23.327408 C 59.939325,22.993436 59.857294,22.703397 59.74012,22.457291 C 59.494013,21.941679 59.142451,21.578398 58.685432,21.367447 C 58.228389,21.156523 57.706905,21.051055 57.120979,21.051041 C 56.312375,21.062774 55.565306,21.256133 54.879768,21.631119 C 54.194213,22.006132 53.564331,22.556913 52.99012,23.283463 L 52.99012,35.008072 L 48.824104,35.008072 L 48.824104,9.5549472 L 52.99012,9.5549472 L 52.99012,16.498306 z" style="font-size:36px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel Bold"/>
+<path d="M 41.808361,47.643379 C 42.188564,47.64338 42.525803,47.599109 42.82008,47.510567 C 43.114344,47.422026 43.370854,47.297026 43.589611,47.135567 C 43.808354,46.97411 43.990645,46.7801 44.136486,46.553535 C 44.282312,46.326975 44.394291,46.075673 44.472424,45.799629 C 44.524499,45.627757 44.560957,45.436351 44.581799,45.22541 C 44.602624,45.014477 44.61304,44.81005 44.613049,44.612129 L 44.613049,38.127754 L 45.886486,38.127754 L 45.886486,44.580879 C 45.886477,44.825675 45.873456,45.080883 45.847424,45.346504 C 45.821373,45.612132 45.779706,45.859528 45.722424,46.088692 C 45.623456,46.47411 45.475019,46.830881 45.277111,47.159004 C 45.079186,47.48713 44.821374,47.770984 44.503674,48.010567 C 44.185957,48.25015 43.804447,48.43765 43.359142,48.573067 C 42.913823,48.708483 42.391688,48.776192 41.792736,48.776192 C 41.219815,48.776192 40.717211,48.713692 40.284924,48.588692 C 39.852628,48.463692 39.481535,48.290515 39.171642,48.06916 C 38.861744,47.847807 38.607838,47.584786 38.409924,47.280098 C 38.212005,46.975412 38.058359,46.643381 37.948986,46.284004 C 37.87086,46.02359 37.81487,45.744945 37.781017,45.448067 C 37.747162,45.151195 37.730235,44.862133 37.730236,44.580879 L 37.730236,38.127754 L 39.003674,38.127754 L 39.003674,44.612129 C 39.003671,44.846508 39.020598,45.087393 39.054455,45.334785 C 39.088306,45.582184 39.141692,45.807444 39.214611,46.010567 C 39.3969,46.515777 39.700285,46.914214 40.124767,47.205879 C 40.549242,47.497547 41.11044,47.64338 41.808361,47.643379 L 41.808361,47.643379 z M 49.488049,40.893379 C 49.488046,41.200678 49.550546,41.454584 49.675549,41.655098 C 49.800546,41.855626 49.968515,42.02099 50.179455,42.151192 C 50.390389,42.281406 50.635181,42.388177 50.91383,42.471504 C 51.192472,42.554844 51.482836,42.632968 51.784924,42.705879 C 52.191169,42.804843 52.590908,42.914218 52.984142,43.034004 C 53.377365,43.153801 53.727625,43.319166 54.034924,43.530098 C 54.342208,43.74104 54.590906,44.01578 54.781017,44.354317 C 54.971114,44.692862 55.066166,45.127758 55.066174,45.659004 C 55.066166,46.200673 54.965905,46.668121 54.765392,47.061348 C 54.564864,47.454578 54.286219,47.777495 53.929455,48.030098 C 53.572678,48.282702 53.146897,48.470202 52.652111,48.592598 C 52.157314,48.714994 51.615648,48.776192 51.027111,48.776192 C 50.756274,48.776192 50.478931,48.759264 50.19508,48.72541 C 49.911223,48.691556 49.64039,48.645983 49.38258,48.588692 C 49.124765,48.5314 48.891693,48.466296 48.683361,48.393379 C 48.475026,48.320463 48.310964,48.247546 48.191174,48.174629 L 48.191174,47.010567 C 48.378672,47.104318 48.58961,47.190256 48.823986,47.268379 C 49.058359,47.346505 49.300546,47.412912 49.550549,47.467598 C 49.800546,47.522287 50.05315,47.565255 50.308361,47.596504 C 50.563566,47.627755 50.803149,47.64338 51.027111,47.643379 C 51.39169,47.64338 51.739346,47.61213 52.07008,47.549629 C 52.400804,47.48713 52.691168,47.382964 52.941174,47.237129 C 53.191168,47.091297 53.389084,46.892079 53.534924,46.639473 C 53.68075,46.386871 53.753667,46.070465 53.753674,45.690254 C 53.753667,45.377757 53.689865,45.119945 53.562267,44.916817 C 53.434657,44.713696 53.264084,44.545727 53.050549,44.41291 C 52.837001,44.280102 52.590908,44.172029 52.312267,44.088692 C 52.033617,44.005363 51.740648,43.927238 51.433361,43.854317 C 51.027107,43.760572 50.629972,43.655103 50.241955,43.53791 C 49.853931,43.420728 49.507577,43.257968 49.202892,43.049629 C 48.898203,42.841302 48.653412,42.573073 48.468517,42.244942 C 48.28362,41.916823 48.191173,41.497553 48.191174,40.987129 C 48.191173,40.455887 48.284922,39.998857 48.472424,39.616035 C 48.659922,39.233232 48.91513,38.916826 49.238049,38.666817 C 49.560963,38.416827 49.938567,38.231931 50.370861,38.112129 C 50.803149,37.992348 51.264086,37.932452 51.753674,37.932442 C 52.31096,37.932452 52.830491,37.985838 53.312267,38.092598 C 53.794032,38.199379 54.235437,38.338702 54.636486,38.510567 L 54.636486,39.690254 C 54.204187,39.507972 53.757573,39.359534 53.296642,39.244942 C 52.835699,39.130368 52.34221,39.070472 51.816174,39.065254 C 51.420336,39.065264 51.076586,39.108232 50.784924,39.19416 C 50.493254,39.280107 50.251066,39.402503 50.058361,39.561348 C 49.86565,39.720211 49.722421,39.912919 49.628674,40.139473 C 49.534921,40.366044 49.488046,40.617346 49.488049,40.893379 L 49.488049,40.893379 z M 62.519299,43.174629 C 62.842208,43.22151 63.132573,43.307447 63.390392,43.432442 C 63.648197,43.557447 63.869551,43.717603 64.054455,43.91291 C 64.239342,44.108227 64.381269,44.339998 64.480236,44.608223 C 64.579186,44.876456 64.628665,45.182445 64.628674,45.526192 C 64.628665,45.770986 64.592207,46.027496 64.519299,46.295723 C 64.446373,46.563954 64.32528,46.824371 64.156017,47.076973 C 63.986739,47.329578 63.765385,47.562651 63.491955,47.776192 C 63.21851,47.989734 62.878667,48.164213 62.472424,48.299629 C 62.159917,48.403796 61.813564,48.476713 61.433361,48.518379 C 61.053148,48.560046 60.597419,48.580879 60.066174,48.580879 L 57.363049,48.580879 L 57.363049,38.127754 L 59.972424,38.127754 C 60.212003,38.127765 60.42945,38.131671 60.624767,38.139473 C 60.820075,38.147296 60.999762,38.159015 61.16383,38.174629 C 61.327887,38.190265 61.480231,38.209796 61.620861,38.233223 C 61.76148,38.256671 61.894293,38.284015 62.019299,38.315254 C 62.347417,38.403806 62.645594,38.5249 62.91383,38.678535 C 63.182052,38.832191 63.409916,39.015785 63.597424,39.229317 C 63.784916,39.442868 63.929447,39.685055 64.031017,39.955879 C 64.132572,40.226721 64.183353,40.520991 64.183361,40.838692 C 64.183353,41.093908 64.153405,41.338699 64.093517,41.573067 C 64.033613,41.807448 63.937259,42.023594 63.804455,42.221504 C 63.671635,42.419427 63.49976,42.59651 63.28883,42.752754 C 63.077885,42.90901 62.821375,43.039218 62.519299,43.143379 L 62.519299,43.174629 z M 60.573986,42.651192 C 60.823981,42.651198 61.040127,42.639479 61.222424,42.616035 C 61.40471,42.592604 61.568772,42.557448 61.714611,42.510567 C 62.10523,42.380365 62.390386,42.17724 62.57008,41.901192 C 62.749761,41.625157 62.839604,41.299636 62.839611,40.924629 C 62.839604,40.539221 62.745854,40.224117 62.558361,39.979317 C 62.370855,39.734534 62.076584,39.552242 61.675549,39.432442 C 61.477626,39.375159 61.24846,39.334795 60.988049,39.311348 C 60.727627,39.28792 60.420336,39.276201 60.066174,39.276192 L 58.636486,39.276192 L 58.636486,42.651192 L 60.573986,42.651192 z M 58.636486,43.799629 L 58.636486,47.432442 L 60.175549,47.432442 C 60.540127,47.432443 60.878669,47.415516 61.191174,47.38166 C 61.503668,47.347808 61.769293,47.294422 61.988049,47.221504 C 62.227626,47.143381 62.43075,47.04312 62.597424,46.920723 C 62.764083,46.798329 62.898198,46.662912 62.999767,46.514473 C 63.101323,46.366038 63.174239,46.208486 63.218517,46.041817 C 63.262781,45.875153 63.284916,45.705882 63.284924,45.534004 C 63.284916,45.336091 63.261479,45.149893 63.214611,44.97541 C 63.167729,44.800935 63.090906,44.644685 62.984142,44.50666 C 62.877365,44.368644 62.73674,44.24755 62.562267,44.143379 C 62.387782,44.039217 62.170334,43.958488 61.909924,43.901192 C 61.753668,43.864738 61.575283,43.838696 61.374767,43.823067 C 61.174241,43.807446 60.925544,43.799634 60.628674,43.799629 L 58.636486,43.799629 z" style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Corbel;-inkscape-font-specification:Corbel"/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/launch/readme.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+To update the icon files:
+
+1) Edit the .sgv file useing an editor such as Inkscape. Note, things like text
+   must be converted using "Path | Object to path" if they are to survive the next
+   step.
+
+2) Convert the .sgv file to a Tiny SGV file using Nokia's SGV2SGVT tool (available in
+   the S60 SDK).
+
+3) Convert the Tiny SGV file to a .mif file using "mifconv" as follows:
+
+	\epoc32\tools\mifconv fshell_local.mif /x /c32 fshell_local.tiny.svg
+
+   Note, it is important that the .mif file is not encoded in binary XML (the "/x"
+   option arranges for this) because not all S60 handsets can handle the more compact
+   format.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/pipsrun/pipsrun.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,227 @@
+// pipsrun.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/ltkutils.h>
+#include <stdapis/unistd.h>
+#include <stdapis/stdio.h>
+#include <stdapis/pthread.h>
+
+const TInt KBlockSize = 512;
+
+using namespace IoUtils;
+
+class CCmdPipsRun : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdPipsRun();
+private:
+	CCmdPipsRun();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	};
+
+
+CCommandBase* CCmdPipsRun::NewLC()
+	{
+	CCmdPipsRun* self = new(ELeave) CCmdPipsRun();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdPipsRun::~CCmdPipsRun()
+	{
+	}
+
+CCmdPipsRun::CCmdPipsRun() : CCommandBase(ESharableIoSession)
+	{
+	}
+
+const TDesC& CCmdPipsRun::Name() const
+	{
+	_LIT(KName, "pipsrun");	
+	return KName;
+	}
+
+const TDesC& CCmdPipsRun::Description() const
+	{
+	_LIT(KDescription, "Internal helper executable for launching processes that use PIPS in such a way that they can interact with fshell's I/O primitives. You should not call it directly.");
+	return KDescription;
+	}
+
+const TUint8* GetDesParamLC(TInt aSlot)
+	{
+	TInt paramLen = User::ParameterLength(aSlot);
+	StaticLeaveIfErr(paramLen, _L("Couldn't read environment slot %d"), aSlot);
+	HBufC* buf = HBufC::NewLC(paramLen + 1); // + 1 for the terminating null character.
+	TPtr bufPtr(buf->Des());
+	User::LeaveIfError(User::GetDesParameter(aSlot, bufPtr));
+	TPtr8 narrowPtr = buf->Des().Collapse();
+	narrowPtr.ZeroTerminate();
+	return narrowPtr.Ptr();
+	}
+
+void AppendNarrowDes(TUint8*& aTarget, const TDesC& aDes)
+	{
+	TInt len = aDes.Length();
+	const TUint16 *pS = aDes.Ptr();
+	const TUint16 *pE = pS + len;
+	while (pS < pE)
+		{
+		TUint c = (*pS++);
+		if (c >= 0x100)
+			{
+			c = 1;
+			}
+		*aTarget++ = (TUint8)c;
+		}
+	}
+
+class TGlueParams
+	{
+public:
+	TGlueParams(TInt aFileDescriptor, RIoWriteHandle aWriteHandle);
+public:
+	TInt iFileDescriptor;
+	RIoWriteHandle iWriteHandle;
+	};
+
+TGlueParams::TGlueParams(TInt aFileDescriptor, RIoWriteHandle aWriteHandle)
+	: iFileDescriptor(aFileDescriptor), iWriteHandle(aWriteHandle)
+	{
+	}
+
+void* GlueFileDescriptor(void* aParams)
+	{
+	TGlueParams* params = (TGlueParams*)aParams;
+	TBuf8<KBlockSize * 2> buf;
+	ssize_t s;
+	TInt err = KErrNone;
+	do
+		{
+		s = read((int)params->iFileDescriptor, (char*)buf.Ptr(), KBlockSize);
+		if (s > 0)
+			{
+			buf.SetLength(s);
+			err = params->iWriteHandle.Write(buf.Expand());
+			}
+		}
+		while ((s > 0) && (err == KErrNone));
+	return (void*)err;
+	}
+
+void CCmdPipsRun::DoRunL()
+	{
+	// Pack the envronment object we inherited from fshell in the way POSIX expects.
+	_LIT(KEquals, "=");
+	_LIT(KNull, "\x0");
+	const CEnvironment& env = Env();
+	RPointerArray<HBufC> keys;
+	LtkUtils::CleanupResetAndDestroyPushL(keys);
+	env.GetKeysL(keys);
+	const TInt numVars = keys.Count();
+	TUint8** envp = (TUint8**)User::AllocLC((numVars  + 1) * sizeof(TInt*)); // + 1 because the last pointer must be NULL.
+	for (TInt i = 0; i < numVars; ++i)
+		{
+		const TDesC& key = *keys[i];
+		const TDesC& val = env.GetAsDesL(key);
+		const TInt length = (key.Length() + 2 + val.Length()); // 2 for the delimiting '=' and the terminating null.
+		TUint8* p = (TUint8*)User::AllocLC(length);
+		envp[i] = p;
+		AppendNarrowDes(p, key);
+		AppendNarrowDes(p, KEquals);
+		AppendNarrowDes(p, val);
+		AppendNarrowDes(p, KNull);
+		}
+	envp[numVars] = NULL;
+
+	const TUint8* commandName(GetDesParamLC(IoUtils::KPipsCommandNameProcessSlot));
+	const TUint8* commandLine(GetDesParamLC(IoUtils::KPipsCommandLineProcessSlot));
+	TInt fds[3];
+	TInt pid = popen3((const char*)commandName, (const char*)commandLine, (char**)envp, fds);
+	if (pid == -1)
+		{
+		User::Leave(KErrGeneral);
+		}
+	CleanupStack::PopAndDestroy(2 + numVars + 1);
+	CleanupStack::PopAndDestroy(&keys);
+
+	RProcess childProcess;
+	User::LeaveIfError(childProcess.Open(pid));
+	CleanupClosePushL(childProcess);
+	TRequestStatus childProcessStatus;
+	childProcess.Logon(childProcessStatus);
+	RProcess::Rendezvous(pid);
+
+	pthread_t stdoutReaderThreadId = 0;
+	pthread_t stderrReaderThreadId = 0;
+	pthread_attr_t threadAttr;
+	pthread_attr_init(&threadAttr);
+	pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED);
+	TGlueParams stdoutParams(fds[1], Stdout());
+	TGlueParams stderrParams(fds[2], Stderr());
+	TInt err = pthread_create(&stdoutReaderThreadId, &threadAttr, GlueFileDescriptor, (void*)&stdoutParams);
+	if (err == 0)
+		{
+		err = pthread_create(&stderrReaderThreadId, &threadAttr, GlueFileDescriptor, (void*)&stderrParams);
+		}
+	if (err != 0)
+		{
+		User::Leave(err);
+		}
+
+	Stdin().SetReadMode(RIoReadHandle::EOneOrMore);
+	TBuf<KBlockSize> buf;
+	TRequestStatus stdinReadStatus;
+	TBool finished(EFalse);
+	while (!finished)
+		{
+		Stdin().Read(buf, stdinReadStatus);
+		User::WaitForRequest(childProcessStatus, stdinReadStatus);
+		if (childProcessStatus == KRequestPending)
+			{
+			TPtr8 narrowPtr(buf.Collapse());
+			narrowPtr.ZeroTerminate();			
+			do
+				{
+				TInt ret = write(fds[0], narrowPtr.Ptr(), narrowPtr.Length());
+				if (ret < 0)
+					{
+					finished = ETrue;
+					}
+				else
+					{
+					narrowPtr.Set(narrowPtr.MidTPtr(ret));
+					}
+				}
+				while (!finished && narrowPtr.Length());
+			}
+		else
+			{
+			finished = ETrue;
+			Stdin().ReadCancel();
+			User::WaitForRequest(stdinReadStatus);
+			}
+		}
+
+	CleanupStack::PopAndDestroy(&childProcess);
+	pthread_join(stdoutReaderThreadId, NULL);
+	pthread_join(stderrReaderThreadId, NULL);
+	Complete(childProcessStatus.Int());
+	}
+
+EXE_BOILER_PLATE(CCmdPipsRun)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/pipsrun/pipsrun.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// pipsrun.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          pipsrun.exe
+targettype      stdexe
+uid             0 FSHELL_UID_PIPSRUN
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          pipsrun.cpp
+
+// euser and libc are included implicitly for stdexes
+// [but seemingly not by sbs, so back they go... better to have a warning in abld than an error in SBS. -TomS]
+library         euser.lib libc.lib
+library         iocli.lib
+library         libpthread.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/102835bf.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+// 102835bf.rss
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <registryinfo.rh>
+#include <fshell/common.mmh>
+
+RESOURCE REGISTRY_INFO r_registry
+	{
+	dll_uid = FSHELL_UID_SBREC;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x101F7D87;
+			implementations =
+			 {
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102835C1;
+					version_no = 1;
+					display_name = "Shebang Recognizer";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/patchdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+// patchdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <e32std.h>
+
+EXPORT_C extern const TBool KAutoStartFshell = 0;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/sbapp.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,87 @@
+// sbapp.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// Description:
+// Launches the executable named in a "shebang" line (e.g "#!fshell") at the beginning of a script.
+
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <apacmdln.h>
+
+void RunL()
+	{
+	CApaCommandLine* commandLine = NULL;
+	User::LeaveIfError(CApaCommandLine::GetCommandLineFromProcessEnvironment(commandLine));
+	CleanupStack::PushL(commandLine);
+	TFileName scriptFileName(commandLine->DocumentName());
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+	RFile file;
+	commandLine->GetFileByHandleL(file);
+	if (!file.SubSessionHandle())
+		{
+		User::LeaveIfError(file.Open(fs, scriptFileName, EFileRead));
+		}
+	RThread().Rendezvous(KErrNone);
+	CleanupClosePushL(file);
+	TBuf8<64> buf;
+	User::LeaveIfError(file.Read(buf));
+	CleanupStack::PopAndDestroy(3, commandLine);
+	if (buf.Left(2) == _L8("#!"))
+		{
+		TLex8 lex(buf.Mid(2));
+		lex.Mark();
+		while (!lex.Eos())
+			{
+			TChar ch(lex.Get());
+			if ((ch == TChar('\r')) || (ch == TChar('\n')))
+				{
+				lex.UnGet();
+				break;
+				}
+			}
+		TPtrC8 narrowExeName(lex.MarkedToken());
+		if (narrowExeName.Length() > 0)
+			{
+			TBuf<64> exeName;
+			exeName.Copy(narrowExeName);
+			_LIT(KSingleQuote, "'");
+			scriptFileName.Insert(0, KSingleQuote);
+			scriptFileName.Append(KSingleQuote);
+			RProcess process;
+			User::LeaveIfError(process.Create(exeName, scriptFileName));
+			TRequestStatus status;
+			process.Logon(status);
+			process.Resume();
+			User::WaitForRequest(status);
+			User::LeaveIfError(status.Int());
+			process.Close();
+			}
+		}
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	TInt err = KErrNoMemory;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup)
+		{
+		TRAP(err, RunL());
+		delete cleanup;
+		}
+	__UHEAP_MARKEND;
+	return err;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/sbapp.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// sbapp.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          sbapp.exe
+targettype      exe
+uid             0x100039ce FSHELL_UID_SBAPP
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          sbapp.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         apparc.lib
+
+START RESOURCE	sbapp_reg.rss
+    TARGETPATH  \private\10003a3f\apps
+END
+
+START RESOURCE  sbapp_loc.rss
+    TARGETPATH  \resource\apps
+    LANG        sc
+END
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/sbapp.rls	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// sbapp.rls
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+/*&
+@localize no
+@description dummy
+@uicontext ShortAppTitleBar
+*/
+rls_string STRING_r_short_caption "sbapp"
+
+/*&
+@localize no
+@description dummy
+@uicontext AppTitleBar
+*/
+rls_string STRING_r_caption "sbapp"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/sbapp_loc.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// sbapp_loc.rss
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include "sbapp.rls"
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = STRING_r_short_caption;
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO
+			{
+			caption = STRING_r_caption;
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/sbapp_reg.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// sbapp_reg.rss
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 FSHELL_UID_SBAPP // application UID
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "sbapp"; // filename of application binary (minus extension)
+	localisable_resource_file = "\\resource\\apps\\sbapp_loc";
+	hidden = KAppIsHidden;
+	embeddability = KAppNotEmbeddable;
+	newfile = KAppDoesNotSupportNewFile;
+	datatype_list =
+		{
+		DATATYPE
+			{
+			priority = EDataTypePriorityNormal;
+			type = "X-Symbian-Shebang";
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/sbrec.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,108 @@
+// sbrec.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// Description:
+// Recognizes files that begin with a "shebang" ("#!").
+
+#include <e32debug.h>
+#include <apmrec.h>
+#include <apmstd.h>
+#include <implementationproxy.h> 
+#include <fshell/common.mmh>
+#include "sbrec.h"
+
+
+//
+// Constants.
+//
+
+const TUid KShebangRecognizerUid = {FSHELL_UID_SBREC};
+const TInt KShebangRecognizerImplementationUidValue = {0x102835C1};
+_LIT8(KShebang, "#!");
+_LIT8(KShebangDataType, "X-Symbian-Shebang");
+
+#ifdef FSHELL_PATCHABLE_CONSTANTS_SUPPORT
+EXPORT_C extern const TBool KAutoStartFshell; // from patchdata.cpp
+#endif
+
+//
+// CShebangRecognizer.
+//
+ 
+CShebangRecognizer::CShebangRecognizer()
+	: CApaDataRecognizerType(KShebangRecognizerUid, CApaDataRecognizerType::EHigh)
+	{
+	iCountDataTypes = 1;
+	}
+
+TUint CShebangRecognizer::PreferredBufSize()
+	{
+	return 2;
+	}
+
+TDataType CShebangRecognizer::SupportedDataTypeL(TInt /*aIndex*/) const
+	{
+	return TDataType(KShebangDataType);
+	}
+
+void CShebangRecognizer::DoRecognizeL(const TDesC& /*aName*/, const TDesC8& aBuffer)
+	{
+	if ((aBuffer.Length() >= 2) && (aBuffer.Left(2) == KShebang))
+		{
+		iDataType = TDataType(KShebangDataType);
+		iConfidence = ECertain;
+		}
+	}
+
+CApaDataRecognizerType* CShebangRecognizer::CreateRecognizerL()
+	{
+#ifdef FSHELL_PATCHABLE_CONSTANTS_SUPPORT
+	if (KAutoStartFshell)
+		{
+	_LIT(KFshell, "fshell.exe");
+		_LIT(KArgs, "autostart.script");
+		RProcess proc;
+		TInt err = proc.Create(KFshell, KArgs);
+		if (err)
+			{
+			RDebug::Printf("Couldn't start fshell, err=%d", err);
+			}
+		else
+			{
+			proc.Resume();
+			proc.Close();
+			}
+		}
+#endif
+	return new (ELeave) CShebangRecognizer();
+	}
+
+
+//
+// ECOM boiler-plate.
+//
+
+const TImplementationProxy ImplementationTable[] = 
+	{
+	IMPLEMENTATION_PROXY_ENTRY(KShebangRecognizerImplementationUidValue, CShebangRecognizer::CreateRecognizerL)
+	};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+	return ImplementationTable;
+	}
+
+GLDEF_C TInt E32Dll()
+	{
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/sbrec.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// sbrec.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SBREC_H__
+#define __SBREC_H__
+
+#include <apmrec.h>
+
+NONSHARABLE_CLASS(CShebangRecognizer) : public CApaDataRecognizerType
+	{
+public: // From CApaDataRecognizerType.
+	CShebangRecognizer();
+	TUint PreferredBufSize();
+	TDataType SupportedDataTypeL(TInt aIndex) const;
+	// For ECOM.
+	static CApaDataRecognizerType* CreateRecognizerL();
+private: // From CApaDataRecognizerType.
+	void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/extra/shebang/sbrec.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+// sbrec.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			sbrec.dll
+targettype		plugin
+uid				0x10009d8d FSHELL_UID_SBREC
+
+systeminclude	\epoc32\include\ecom
+
+start resource	102835BF.rss
+target sbrec.rsc
+end
+
+capability		ProtServ
+
+sourcepath		.
+systeminclude	.
+#include <fshell/fsh_system_include.mmh>
+
+source			sbrec.cpp
+
+#ifdef FSHELL_PATCHABLE_CONSTANTS_SUPPORT
+source			patchdata.cpp
+nostrictdef
+deffile		..\..\~\sbrec.def
+#endif
+
+library			euser.lib apmime.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/group/autostart.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+#!fshell
+# autostart.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+source $SCRIPT_PATH\comm.script
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,185 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(fshell_core.iby)
+
+..\builtins\fshell.cif            z:\resource\cif\fshell\fshell.cif
+..\builtins\help.cif              z:\resource\cif\fshell\help.cif
+..\builtins\exit.cif              z:\resource\cif\fshell\exit.cif
+..\builtins\ls.cif                z:\resource\cif\fshell\ls.cif
+..\builtins\cd.cif                z:\resource\cif\fshell\cd.cif
+..\builtins\clear.cif             z:\resource\cif\fshell\clear.cif
+..\builtins\fg.cif                z:\resource\cif\fshell\fg.cif
+..\builtins\bg.cif                z:\resource\cif\fshell\bg.cif
+..\builtins\hello.cif             z:\resource\cif\fshell\hello.cif
+..\builtins\jobs.cif              z:\resource\cif\fshell\jobs.cif
+..\builtins\rm.cif                z:\resource\cif\fshell\rm.cif
+..\builtins\cp.cif                z:\resource\cif\fshell\cp.cif
+..\builtins\mv.cif                z:\resource\cif\fshell\mv.cif
+..\builtins\mkdir.cif             z:\resource\cif\fshell\mkdir.cif
+..\builtins\rmdir.cif             z:\resource\cif\fshell\rmdir.cif
+..\builtins\echo.cif              z:\resource\cif\fshell\echo.cif
+..\builtins\more.cif              z:\resource\cif\fshell\more.cif
+..\builtins\trace.cif             z:\resource\cif\fshell\trace.cif
+..\builtins\meminfo.cif           z:\resource\cif\fshell\meminfo.cif
+..\builtins\dump.cif              z:\resource\cif\fshell\dump.cif
+..\builtins\sleep.cif             z:\resource\cif\fshell\sleep.cif
+..\builtins\env.cif               z:\resource\cif\fshell\env.cif
+..\builtins\export.cif            z:\resource\cif\fshell\export.cif
+..\builtins\sort.cif              z:\resource\cif\fshell\sort.cif
+..\builtins\exists.cif            z:\resource\cif\fshell\exists.cif
+..\builtins\infoprint.cif         z:\resource\cif\fshell\infoprint.cif
+..\builtins\rdebug.cif            z:\resource\cif\fshell\rdebug.cif
+..\builtins\date.cif              z:\resource\cif\fshell\date.cif
+..\builtins\fsck.cif              z:\resource\cif\fshell\fsck.cif
+..\builtins\fuser.cif             z:\resource\cif\fshell\fuser.cif
+..\builtins\gobble.cif            z:\resource\cif\fshell\gobble.cif
+..\builtins\driver.cif            z:\resource\cif\fshell\driver.cif
+..\builtins\tickle.cif            z:\resource\cif\fshell\tickle.cif
+..\builtins\ticks.cif             z:\resource\cif\fshell\ticks.cif
+..\builtins\uptime.cif            z:\resource\cif\fshell\uptime.cif
+..\builtins\var.cif               z:\resource\cif\fshell\var.cif
+..\builtins\source.cif            z:\resource\cif\fshell\source.cif
+..\builtins\foreach.cif           z:\resource\cif\fshell\foreach.cif
+..\builtins\start.cif             z:\resource\cif\fshell\start.cif
+..\builtins\compare.cif           z:\resource\cif\fshell\compare.cif
+..\builtins\time.cif              z:\resource\cif\fshell\time.cif
+..\builtins\repeat.cif            z:\resource\cif\fshell\repeat.cif
+..\builtins\debug.cif             z:\resource\cif\fshell\debug.cif
+..\builtins\readmem.cif           z:\resource\cif\fshell\readmem.cif
+..\builtins\e32header.cif         z:\resource\cif\fshell\e32header.cif
+..\builtins\objinfo.cif           z:\resource\cif\fshell\objinfo.cif
+..\builtins\touch.cif             z:\resource\cif\fshell\touch.cif
+..\builtins\dialog.cif            z:\resource\cif\fshell\dialog.cif
+..\builtins\jit.cif               z:\resource\cif\fshell\jit.cif
+..\builtins\console.cif           z:\resource\cif\fshell\console.cif
+..\builtins\pcons.cif             z:\resource\cif\fshell\pcons.cif
+..\builtins\ioinfo.cif            z:\resource\cif\fshell\ioinfo.cif
+..\builtins\reattach.cif          z:\resource\cif\fshell\reattach.cif
+..\builtins\disown.cif            z:\resource\cif\fshell\disown.cif
+..\builtins\debugport.cif         z:\resource\cif\fshell\debugport.cif
+..\builtins\rom.cif               z:\resource\cif\fshell\rom.cif
+..\builtins\ps.cif                z:\resource\cif\fshell\ps.cif
+..\builtins\which.cif             z:\resource\cif\fshell\which.cif
+..\builtins\tee.cif               z:\resource\cif\fshell\tee.cif
+..\builtins\kill.cif              z:\resource\cif\fshell\kill.cif
+..\builtins\error.cif             z:\resource\cif\fshell\error.cif
+..\builtins\xmodem.cif            z:\resource\cif\fshell\xmodem.cif
+..\builtins\ymodem.cif            z:\resource\cif\fshell\ymodem.cif
+..\builtins\version.cif           z:\resource\cif\fshell\version.cif
+..\builtins\undertaker.cif        z:\resource\cif\fshell\undertaker.cif
+
+#ifdef FSHELL_CORE_SUPPORT_CHUNKINFO
+..\builtins\chunkinfo.cif         z:\resource\cif\fshell\chunkinfo.cif
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SVRINFO
+..\builtins\svrinfo.cif           z:\resource\cif\fshell\svrinfo.cif
+#endif
+
+..\builtins\match.cif             z:\resource\cif\fshell\match.cif
+
+#ifdef FSHELL_CORE_SUPPORT_BUILTIN_REBOOT
+..\builtins\reboot.cif              z:\resource\cif\fshell\reboot.cif
+#endif
+
+.\autostart.script                     z:\system\console\scripts\autostart.script
+.\comm.script                          z:\system\console\scripts\comm.script
+.\fshell.bat                           \epoc32\tools\fshell.bat
+
+PRJ_MMPFILES
+gnumakefile .\fshell_version.mk
+..\src\fshell.mmp
+
+#ifdef FSHELL_CORE_SUPPORT_SHEBANG
+..\extra\shebang\sbrec.mmp
+..\extra\shebang\sbapp.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SIS_ECLIPSE
+..\extra\inst\fshell_inst.mmp
+..\extra\inst\fshell_uinst.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_PIPSRUN
+..\extra\pipsrun\pipsrun.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_LOCAL_ICON
+PRJ_EXPORTS
+..\extra\launch\fshell_local.mif              z:\resource\apps\fshell_local.mif
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_TCP_ICON
+PRJ_EXPORTS
+..\extra\launch\fshell_tcp.mif                z:\resource\apps\fshell_tcp.mif
+PRJ_MMPFILES
+..\extra\launch\fshell_launch_tcp.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_BT_ICON
+PRJ_EXPORTS
+..\extra\launch\fshell_bt.mif                 z:\resource\apps\fshell_bt.mif
+PRJ_MMPFILES
+..\extra\launch\fshell_launch_bt.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_USB_ICON
+PRJ_EXPORTS
+..\extra\launch\fshell_usb.mif                z:\resource\apps\fshell_usb.mif
+PRJ_MMPFILES
+..\extra\launch\fshell_launch_usb.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_RCONS_ICON
+PRJ_EXPORTS
+..\extra\launch\fshell_rcons.mif              z:\resource\apps\fshell_rcons.mif
+PRJ_MMPFILES
+..\extra\launch\fshell_launch_rcons.mmp
+#endif
+
+#ifdef FSHELL_CORE_SUPPORT_SERIAL_ICON
+PRJ_MMPFILES
+..\extra\launch\fshell_launch_serial.mmp
+#endif
+
+
+PRJ_TESTEXPORTS
+..\tsrc\args.script						z:\system\console\scripts\args.script
+..\tsrc\checkargs.script				z:\system\console\scripts\checkargs.script
+..\tsrc\setenv.script					z:\system\console\scripts\setenv.script
+..\tsrc\addenv.script					z:\system\console\scripts\addenv.script
+..\tsrc\printerror.script				z:\system\console\scripts\printerror.script
+..\tsrc\fshell-basic-test.script		z:\system\console\scripts\fshell-basic-test.script
+..\tsrc\fshell-last-test.script			z:\system\console\scripts\fshell-last-test.script
+..\tsrc\fshell-ccommandbase-test.script	z:\system\console\scripts\fshell-ccommandbase-test.script
+..\tsrc\fshell-unicode-test.script		z:\system\console\scripts\fshell-unicode-test.script
+..\tsrc\fshell-scriptcif-test.script	z:\system\console\scripts\fshell-scriptcif-test.script
+..\tsrc\smoketest.script				z:\system\console\scripts\smoketest.script
+..\tsrc\tscriptargs.script				z:\system\console\scripts\tscriptargs.script
+..\tsrc\tlotsofscriptargs.script		z:\system\console\scripts\tlotsofscriptargs.script
+..\tsrc\errordef.script					z:\system\console\scripts\errordef.script
+
+..\tsrc\tenvarguments.cif				z:\resource\cif\fshell\tenvarguments.cif
+
+
+PRJ_TESTMMPFILES
+..\tsrc\tlast.mmp
+..\tsrc\tconsole.mmp
+..\tsrc\tinteger.mmp
+..\tsrc\tfshellarguments.mmp
+..\tsrc\tenvarguments.mmp
+..\tsrc\tnoncifenvarguments.mmp
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/group/comm.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+#!fshell
+# comm.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# NaviEngine, port next to VGA
+variant naviengine && export ARGS "--console vt100busdevcons --console-title pdd=euart1,ldd=ecomm,port=1,rate=115200"
+
+# H4, serial riser marked "J3"
+variant h4 && export ARGS "--console vt100cons --console-title port=COMM::3,rate=115200"
+
+# H6 - port marked "UART 3"
+variant h6 && export ARGS "--console vt100busdevcons --console-title pdd=euart1,ldd=ecomm,port=7,rate=115200"
+
+# Beagle board, serial riser marked RS232 P9.
+variant beagle && export ARGS "--console vt100busdevcons --console-title port=2,rate=115200"
+
+# OPP Mid-Size Prototype, requires a special USB cable with a UART bridge built into it (normally covered in heat shrink) or a "black box".
+variant opp-mid-size && export ARGS "--console vt100busdevcons --console-title pdd=euart1,ldd=ecomm,rate=115200,port=4"
+
+# Add new variants here
+
+# And finally, start fshell with the given configuration
+var ARGS defined || error -5 "Variant not recognised, can't open serial connection"
+fshell $ARGS &
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/group/fshell.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,13 @@
+@REM fshell.bat
+@REM 
+@REM Copyright (c) 2010 Accenture. All rights reserved.
+@REM This component and the accompanying materials are made available
+@REM under the terms of the "Eclipse Public License v1.0"
+@REM which accompanies this distribution, and is available
+@REM at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@REM 
+@REM Initial Contributors:
+@REM Accenture - Initial contribution
+@REM
+@%epocroot%epoc32\release\winscw\udeb\fshell.exe -mltkconsole -dnogui  -- --console win32cons.dll %*
+@if %ERRORLEVEL% NEQ 0 echo fshell.exe exited with error %ERRORLEVEL%
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/group/fshell_core.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,185 @@
+// fshell_core.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __FSHELL_IBY__
+#define __FSHELL_IBY__
+
+#include <fsh_config.iby>
+
+FSHELL_EXECUTABLE_FILE(fshell.exe)
+
+#ifdef FSHELL_CORE_SUPPORT_LOCAL_ICON
+FSHELL_DATA_FILE(ZPRIVATE\10003a3f\Apps\fshell_reg.rsc, Private\10003a3f\import\Apps\fshell_reg.rsc)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_loc.rsc, Resource\Apps\fshell_loc.rsc)
+#ifdef FSHELL_PLATFORM_UIQ
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshellAppIcon.mbm, Resource\Apps\fshellAppIcon.mbm)
+#else
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_local.mif, Resource\Apps\fshell_local.mif)
+#endif
+#endif // FSHELL_CORE_SUPPORT_LOCAL_ICON
+
+#ifdef FSHELL_CORE_SUPPORT_TCP_ICON
+FSHELL_EXECUTABLE_FILE(fshell_launch_tcp.exe)
+FSHELL_DATA_FILE(ZPRIVATE\10003a3f\Apps\fshell_launch_tcp_reg.rsc, Private\10003a3f\import\Apps\fshell_launch_tcp_reg.rsc)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_launch_tcp_loc.rsc, Resource\Apps\fshell_launch_tcp_loc.rsc)
+#ifndef FSHELL_PLATFORM_UIQ
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_tcp.mif, Resource\Apps\fshell_tcp.mif)
+#endif
+#endif // FSHELL_CORE_SUPPORT_TCP_ICON
+
+#ifdef FSHELL_CORE_SUPPORT_BT_ICON
+FSHELL_EXECUTABLE_FILE(fshell_launch_bt.exe)
+FSHELL_DATA_FILE(ZPRIVATE\10003a3f\Apps\fshell_launch_bt_reg.rsc, Private\10003a3f\import\Apps\fshell_launch_bt_reg.rsc)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_launch_bt_loc.rsc, Resource\Apps\fshell_launch_bt_loc.rsc)
+#ifndef FSHELL_PLATFORM_UIQ
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_bt.mif, Resource\Apps\fshell_bt.mif)
+#endif
+#endif // FSHELL_CORE_SUPPORT_BT_ICON
+
+#ifdef FSHELL_CORE_SUPPORT_USB_ICON
+FSHELL_EXECUTABLE_FILE(fshell_launch_usb.exe)
+FSHELL_DATA_FILE(ZPRIVATE\10003a3f\Apps\fshell_launch_usb_reg.rsc, Private\10003a3f\import\Apps\fshell_launch_usb_reg.rsc)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_launch_usb_loc.rsc, Resource\Apps\fshell_launch_usb_loc.rsc)
+#ifndef FSHELL_PLATFORM_UIQ
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_usb.mif, Resource\Apps\fshell_usb.mif)
+#endif
+#endif // FSHELL_CORE_SUPPORT_USB_ICON
+
+#ifdef FSHELL_CORE_SUPPORT_RCONS_ICON
+FSHELL_EXECUTABLE_FILE(fshell_launch_rcons.exe)
+FSHELL_DATA_FILE(ZPRIVATE\10003a3f\Apps\fshell_launch_rcons_reg.rsc, Private\10003a3f\import\Apps\fshell_launch_rcons_reg.rsc)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_launch_rcons_loc.rsc, Resource\Apps\fshell_launch_rcons_loc.rsc)
+#ifndef FSHELL_PLATFORM_UIQ
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_rcons.mif, Resource\Apps\fshell_rcons.mif)
+#endif
+#endif // FSHELL_CORE_SUPPORT_RCONS_ICON
+
+#ifdef FSHELL_CORE_SUPPORT_SERIAL_ICON
+FSHELL_EXECUTABLE_FILE(fshell_launch_serial.exe)
+FSHELL_DATA_FILE(ZPRIVATE\10003a3f\Apps\fshell_launch_serial.rsc, Private\10003a3f\import\Apps\fshell_launch_serial.rsc)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\fshell_launch_serial_loc.rsc, Resource\Apps\fshell_launch_serial_loc.rsc)
+#endif // FSHELL_CORE_SUPPORT_SERIAL_ICON
+
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\comm.script, system\console\scripts\comm.script)
+#ifdef FSHELL_AUTOEXEC
+FSHELL_DATA_FILE(DATAZ_\autoexec.bat.comm, autoexec.bat)
+#endif
+
+FSHELL_EXECUTABLE_FILE(iosrv.exe)
+FSHELL_EXECUTABLE_FILE(iocli.dll)
+FSHELL_DATA_FILE(ZRESOURCE\iosrv.idf, resource\iosrv.idf)
+#ifdef FSHELL_CORE_SUPPORT_SHEBANG
+FSHELL_EXECUTABLE_FILE(sbapp.exe)
+FSHELL_ECOM_PLUGIN(sbrec.dll, sbrec.rsc)
+FSHELL_DATA_FILE(ZPRIVATE\10003a3f\apps\sbapp_reg.RSC, Private\10003a3f\import\Apps\sbapp_reg.RSC)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\sbapp_loc.rsc, Resource\Apps\sbapp_loc.rsc)
+#ifdef FSHELL_AUTOSTART
+patchdata sbrec.dll@KAutoStartFshell 1
+FSHELL_DATA_FILE(ZSYSTEM\console\scripts\autostart.script, system\console\scripts\autostart.script)
+#endif
+#endif
+#ifdef FSHELL_CORE_SUPPORT_PIPSRUN
+FSHELL_EXECUTABLE_FILE(pipsrun.exe)
+#endif
+
+FSHELL_COMMAND_INFO_FILE(fshell,fshell.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,help.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,exit.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,ls.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,cd.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,clear.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,fg.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,bg.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,jobs.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,rm.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,cp.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,mv.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,mkdir.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,rmdir.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,match.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,echo.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,more.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,trace.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,meminfo.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,dump.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,sleep.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,env.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,export.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,sort.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,exists.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,infoprint.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,rdebug.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,date.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,fsck.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,fuser.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,gobble.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,driver.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,chunkinfo.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,svrinfo.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,tickle.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,ticks.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,uptime.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,var.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,source.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,foreach.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,start.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,compare.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,time.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,repeat.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,debug.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,readmem.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,e32header.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,objinfo.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,touch.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,dialog.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,jit.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,console.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,pcons.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,ioinfo.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,reattach.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,disown.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,hello.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,debugport.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,rom.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,which.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,tee.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,kill.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,error.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,xmodem.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,ymodem.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,version.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,undertaker.cif)
+FSHELL_COMMAND_INFO_FILE(fshell,ps.cif)
+#ifdef FSHELL_CORE_SUPPORT_BUILTIN_REBOOT
+FSHELL_COMMAND_INFO_FILE(fshell,reboot.cif)
+#endif
+
+#ifdef FSHELL_REPLACE_ECONS
+FSHELL_RENAMED_EXECUTABLE_FILE(iocons.dll, econs.dll)
+
+#ifdef FSHELL_USE_BLUETOOTH_CONSOLE
+FSHELL_DATA_FILE(ZSYSTEM\console\iosrv.ini.bluetooth, system\console\iosrv.ini)
+#else
+FSHELL_DATA_FILE(ZSYSTEM\console\iosrv.ini.econs_fb, system\console\iosrv.ini)
+#ifdef FSHELL_WSERV_SUPPORT
+FSHELL_RENAMED_EXECUTABLE_FILE(econseik.dll, econs_fb.dll)
+#else
+FSHELL_RENAMED_EXECUTABLE_FILE(econs.dll, econs_fb.dll)
+#endif
+#endif // FSHELL_USE_BLUETOOTH_CONSOLE
+
+#endif // FSHELL_REPLACE_ECONS
+
+#ifdef FSHELL_PERL_SUPPORT
+FSHELL_DATA_FILE(ZSYSTEM\perl\lib\Fshell\TextServerClient.pm, system\perl\lib\Fshell\TextServerClient.pm)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/group/fshell_version.mk	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+# fshell_version.mk
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+GENERATED_SOURCE_DIR = $(EPOCROOT)epoc32\build\fshell\core\generated
+GENERATED_SOURCE = $(GENERATED_SOURCE_DIR)\fshell_version.cpp
+
+MAKMAKE :
+	perl -S emkdir.pl $(GENERATED_SOURCE_DIR)
+	echo perl .\genver.pl $(PLATFORM) $(CFG)
+	perl .\genver.pl $(PLATFORM) > $(GENERATED_SOURCE)
+
+CLEAN :
+	perl -S ermdir.pl $(GENERATED_SOURCE_DIR)
+
+BLD FREEZE LIB CLEANLIB RESOURCE SAVESPACE RELEASABLES FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/group/genver.pl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,85 @@
+# genver.pl
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+use strict;
+use lib "../../tools";
+use fshu;
+
+my $platform = shift @ARGV;
+my $version = fshu::Version();
+my $localTime = scalar(localtime);
+my $gmTime = scalar(gmtime);
+my $builder = $ENV{USERNAME};
+my $compilerVersion = CompilerVersion();
+
+
+print "
+#include <fshell/iocli.h>
+
+extern void PrintVersionInfo(RIoWriteHandle& aOut, TBool aVerbose)
+	{
+	if (aVerbose)
+		{
+		aOut.Write(_L(\"Version:              $version\\r\\n\"));
+		aOut.Write(_L(\"Local build time:     $localTime\\r\\n\"));
+		aOut.Write(_L(\"GMT build time:       $gmTime\\r\\n\"));
+		aOut.Write(_L(\"User-name of builder: $builder\\r\\n\"));
+		aOut.Write(_L(\"Compiler version:     $compilerVersion\\r\\n\"));
+#ifdef _DEBUG
+		aOut.Write(_L(\"Build configuration:  debug\\r\\n\"));
+#else
+		aOut.Write(_L(\"Build configuration:  release\\r\\n\"));
+#endif
+		}
+	else
+		{
+		aOut.Write(_L(\"$version\\r\\n\"));
+		}
+	}
+";
+
+sub CompilerVersion {
+  my $version = 'Unknown';
+  if ($platform =~ /^armv5$/i) {
+    open (COMPILER, "armcc 2>&1 |") or die "Couldn't run \"armcc\": $!\n";
+    while (my $line = <COMPILER>) {
+      if ($line =~ /\[Build\s+\d+\]/) {
+	chomp $line;
+	$version = $line;
+	last;
+      }
+    }
+    close (COMPILER);
+  }
+  elsif ($platform =~ /^gcce$/i) {
+    open (COMPILER, "arm-none-symbianelf-gcc.exe -v 2>&1 |") or die "Couldn't run \"arm-none-symbianelf-gcc.exe -v\": $!\n";
+    while (my $line = <COMPILER>) {
+      if ($line =~ /^gcc version/) {
+	chomp $line;
+	$version = $line;
+	last;
+      }
+    }
+    close (COMPILER);
+  }
+  elsif ($platform =~ /^(arm4|armi|thumb)$/i) {
+    open (COMPILER, "gcc.exe -v 2>&1 |") or die "Couldn't run \"gcc.exe -v\": $!\n";
+    while (my $line = <COMPILER>) {
+      if ($line =~ /^gcc version/) {
+	chomp $line;
+	$version = $line;
+	last;
+      }
+    }
+    close (COMPILER);
+  }
+  return $version;
+}
Binary file core/src/AppIcon/48x48.bmp has changed
Binary file core/src/AppIcon/48x48m.bmp has changed
Binary file core/src/AppIcon/fshell_Large.bmp has changed
Binary file core/src/AppIcon/fshell_Large_mask.bmp has changed
Binary file core/src/AppIcon/fshell_Small.bmp has changed
Binary file core/src/AppIcon/fshell_Small_mask.bmp has changed
Binary file core/src/AppIcon/fshell_xLarge.bmp has changed
Binary file core/src/AppIcon/fshell_xLarge_mask.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/character_converter.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,129 @@
+// character_converter.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include "character_converter.h"
+
+const TInt KSlack = 20;
+
+
+CCharacterConverter* CCharacterConverter::NewL(TInt aMaxBlockSize, RFs& aFs, TUint aCharset)
+	{
+	CCharacterConverter* self = new(ELeave) CCharacterConverter(aMaxBlockSize, aFs, aCharset);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CCharacterConverter::~CCharacterConverter()
+	{
+	delete iCharSets;
+	delete iConverter;
+	delete iNarrowBuf;
+	delete iWideBuf;
+	}
+
+const TDesC& CCharacterConverter::ConvertChunkL(const TDesC8& aNarrowBuf, TChunkType aType)
+	{
+	ASSERT(aNarrowBuf.Length() <= iMaxBlockSize);
+
+	switch (aType)
+		{
+		case EFirst:
+			{
+			iCharConvState = CCnvCharacterSetConverter::KStateDefault;
+			iNarrowPtr = aNarrowBuf;
+			if (iCharset == 0)
+				{
+				// Only spend time autodetecting if we haven't been told the charset to use
+				const TUint16* p = (const TUint16*)aNarrowBuf.Ptr();
+				if ((*p == 0xFEFF) || (*p == 0xFFFE))
+					{
+					iNarrowPtr.Delete(0, 2);
+					iCharset = (*p == 0xFEFF) ? KCharacterSetIdentifierUnicodeLittle : KCharacterSetIdentifierUnicodeBig;
+					}
+				else
+					{
+					iCharSets = CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableL(iFs);
+					TInt confidenceLevel;
+					CCnvCharacterSetConverter::AutoDetectCharacterSetL(confidenceLevel, iCharset, *iCharSets, iNarrowPtr.Left(32));
+					}
+				}
+			iConverter->PrepareToConvertToOrFromL(iCharset, iFs);
+			}	// Deliberate fall through.
+		case EMiddle:
+			{
+			if (aType == EMiddle)
+				{
+				iNarrowPtr += aNarrowBuf;
+				}
+			TInt numUnconvertibleChars;
+			const TInt ret = iConverter->ConvertToUnicode(iWidePtr,	iNarrowPtr,	iCharConvState, numUnconvertibleChars);
+			iNumUnconvertibleChars += numUnconvertibleChars;
+			if (ret < 0)
+				{
+				User::Leave(ret);
+				}
+			else if (ret > KSlack)
+				{
+				User::Leave(KErrCorrupt);
+				}
+			else if (ret > 0)
+				{
+				iNarrowPtr = iNarrowPtr.Right(ret);
+				}
+			else
+				{
+				iNarrowPtr.Zero();
+				}
+			break;
+			}
+		case ELast:
+			{
+			iNarrowPtr += aNarrowBuf;
+			TInt numUnconvertibleChars;
+			const TInt ret = iConverter->ConvertToUnicode(iWidePtr,	iNarrowPtr,	iCharConvState, numUnconvertibleChars);
+			iNumUnconvertibleChars += numUnconvertibleChars;
+			if (ret < 0)
+				{
+				User::Leave(ret);
+				}
+			else if (ret > 0)
+				{
+				User::Leave(KErrCorrupt);
+				}
+			iNarrowPtr.Zero();
+			break;
+			}
+		default:
+			{
+			ASSERT(EFalse);
+			}
+		}
+
+	return iWidePtr;
+	}
+
+CCharacterConverter::CCharacterConverter(TInt aMaxBlockSize, RFs& aFs, TUint aCharset)
+	: iFs(aFs), iMaxBlockSize(aMaxBlockSize), iNarrowPtr(NULL, 0), iWidePtr(NULL, 0), iCharset(aCharset)
+	{
+	}
+
+void CCharacterConverter::ConstructL()
+	{
+	iNarrowBuf = HBufC8::NewL(iMaxBlockSize + KSlack);
+	iWideBuf = HBufC16::NewL(iMaxBlockSize + KSlack);
+	iNarrowPtr.Set(iNarrowBuf->Des());
+	iWidePtr.Set(iWideBuf->Des());
+	iConverter = CCnvCharacterSetConverter::NewL();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/character_converter.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+// character_converter.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __CHARACTER_CONVERTER_H__
+#define __CHARACTER_CONVERTER_H__
+
+#include <e32std.h>
+#include <f32file.h>
+#include <charconv.h>
+
+
+class CCharacterConverter : public CBase
+	{
+public:
+	enum TChunkType
+		{
+		EFirst,
+		EMiddle,
+		ELast
+		};
+public:
+	static CCharacterConverter* NewL(TInt aMaxBlockSize, RFs& aFs, TUint aCharset=0); // 0 means autodetect
+	~CCharacterConverter();
+	const TDesC& ConvertChunkL(const TDesC8& aNarrowBuf, TChunkType aType);
+private:
+	CCharacterConverter(TInt aMaxBlockSize, RFs& aFs, TUint aCharset);
+	void ConstructL();
+private:
+	RFs& iFs;
+	TInt iCharConvState;
+	TInt iNumUnconvertibleChars;
+	const TInt iMaxBlockSize;
+	HBufC8* iNarrowBuf;
+	HBufC16* iWideBuf;
+	TPtr8 iNarrowPtr;
+	TPtr16 iWidePtr;
+	CCnvCharacterSetConverter* iConverter;
+	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iCharSets;
+	TUint iCharset;
+	};
+
+
+#endif // __CHARACTER_CONVERTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/command_constructors.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,233 @@
+// command_constructors.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/descriptorutils.h>
+#include "command_constructors.h"
+#include "command_wrappers.h"
+
+
+//
+// CCommandConstructorBase.
+//
+
+const TDesC& CCommandConstructorBase::CommandName() const
+	{
+	return *iCommandName;
+	}
+
+TUint CCommandConstructorBase::Attributes() const
+	{
+	return iAttributes;
+	}
+
+CCommandConstructorBase::TType CCommandConstructorBase::Type() const
+	{
+	return iType;
+	}
+
+void CCommandConstructorBase::SetAttributes(TUint aAttributes)
+	{
+	iAttributes = aAttributes;
+	}
+
+void CCommandConstructorBase::BaseConstructL(const TDesC& aCommandName)
+	{
+	iCommandName = aCommandName.AllocL();
+	iCommandName->Des().Fold();
+	}
+
+CCommandConstructorBase::CCommandConstructorBase()
+	: iType(ETypeUnknown)
+	{
+	}
+
+CCommandConstructorBase::CCommandConstructorBase(TType aType)
+	: iType(aType)
+	{
+	}
+
+CCommandConstructorBase::~CCommandConstructorBase()
+	{
+	delete iCommandName;
+	}
+
+
+//
+// CThreadCommandConstructor.
+//
+
+CThreadCommandConstructor* CThreadCommandConstructor::NewLC(TCommandConstructor aConstructor, TUint aFlags)
+	{
+	CCommandBase* command = (*aConstructor)();
+	CThreadCommandConstructor* self = CThreadCommandConstructor::NewLC(command->Name(), aConstructor, aFlags);
+	CleanupStack::Pop(self);
+	CleanupStack::PopAndDestroy(command);
+	CleanupStack::PushL(self);
+	return self;
+	}
+
+CThreadCommandConstructor* CThreadCommandConstructor::NewLC(const TDesC& aCommandName, TCommandConstructor aConstructor, TUint aFlags)
+	{
+	CThreadCommandConstructor* self = new(ELeave) CThreadCommandConstructor(aFlags, aConstructor);
+	CleanupStack::PushL(self);
+	self->BaseConstructL(aCommandName);
+	return self;
+	}
+
+CThreadCommandConstructor::CThreadCommandConstructor(TUint aFlags, TCommandConstructor aConstructor)
+	: CCommandConstructorBase(ETypeThread), iFlags(aFlags), iConstructor(aConstructor)
+	{
+	}
+
+MCommand* CThreadCommandConstructor::ConstructCommandL()
+	{
+	return CThreadCommand::NewL(CommandName(), iConstructor, iFlags);
+	}
+
+void CThreadCommandConstructor::AppendDescriptionL(RLtkBuf16& aBuf) const
+	{
+	aBuf.AppendFormatL(_L("built-in command '%S'"), &CommandName());
+	if (Attributes() & EAttAlias) aBuf.AppendFormatL(_L(" (alias)")); // In this case we don't record what it's aliased to, unfortunately
+	}
+
+//
+// CExeCommandConstructor.
+//
+
+CExeCommandConstructor* CExeCommandConstructor::NewLC(const TDesC& aCommandName, const TDesC& aExeName)
+	{
+	CExeCommandConstructor* self = new(ELeave) CExeCommandConstructor();
+	CleanupStack::PushL(self);
+	self->ConstructL(aCommandName, aExeName);
+	return self;
+	}
+
+CExeCommandConstructor::CExeCommandConstructor()
+	: CCommandConstructorBase(ETypeExe)
+	{
+	}
+
+CExeCommandConstructor::~CExeCommandConstructor()
+	{
+	delete iExeName;
+	}
+
+void CExeCommandConstructor::ConstructL(const TDesC& aCommandName, const TDesC& aExeName)
+	{
+	iExeName = aExeName.AllocL();
+	BaseConstructL(aCommandName);
+	}
+
+MCommand* CExeCommandConstructor::ConstructCommandL()
+	{
+	return CProcessCommand::NewL(*iExeName);
+	}
+
+const TDesC& CExeCommandConstructor::ExeName() const
+	{
+	return *iExeName;
+	}
+
+void CExeCommandConstructor::AppendDescriptionL(RLtkBuf16& aBuf) const
+	{
+	aBuf.AppendFormatL(_L("exe command '%S'"), &ExeName());
+	}
+
+//
+// CPipsCommandConstructor.
+//
+
+CPipsCommandConstructor* CPipsCommandConstructor::NewLC(const TDesC& aCommandName)
+	{
+	CPipsCommandConstructor* self = new(ELeave) CPipsCommandConstructor();
+	CleanupStack::PushL(self);
+	self->BaseConstructL(aCommandName);
+	return self;
+	}
+
+CPipsCommandConstructor::CPipsCommandConstructor()
+	: CCommandConstructorBase(ETypePips)
+	{
+	}
+
+MCommand* CPipsCommandConstructor::ConstructCommandL()
+	{
+	return CPipsCommand::NewL(CommandName());
+	}
+
+
+void CPipsCommandConstructor::AppendDescriptionL(RLtkBuf16& aBuf) const
+	{
+	aBuf.AppendFormatL(_L("PIPS exe '%S.exe'"), &CommandName());
+	}
+
+//
+// CAliasCommandConstructor.
+//
+
+CAliasCommandConstructor* CAliasCommandConstructor::NewLC(const TDesC& aCommandName, CCommandConstructorBase* aAliasedConstructor, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments)
+	{
+	CAliasCommandConstructor* self = new(ELeave) CAliasCommandConstructor(aAliasedConstructor);
+	CleanupStack::PushL(self);
+	self->ConstructL(aCommandName, aAdditionalArguments, aReplacementArguments);
+	return self;
+	}
+
+CAliasCommandConstructor::CAliasCommandConstructor(CCommandConstructorBase* aAliasedConstructor)
+	: CCommandConstructorBase(ETypeAlias), iAliasedConstructor(aAliasedConstructor)
+	{
+	}
+
+CAliasCommandConstructor::~CAliasCommandConstructor()
+	{
+	delete iAliasedConstructor;
+	delete iAdditionalArguments;
+	delete iReplacementArguments;
+	}
+
+void CAliasCommandConstructor::ConstructL(const TDesC& aCommandName, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments)
+	{
+	if (aAdditionalArguments)
+		{
+		iAdditionalArguments = aAdditionalArguments->AllocL();
+		}
+	if (aReplacementArguments)
+		{
+		iReplacementArguments = aReplacementArguments->AllocL();
+		}
+	BaseConstructL(aCommandName);
+	}
+
+MCommand* CAliasCommandConstructor::ConstructCommandL()
+	{
+	MCommand* aliasCommand = iAliasedConstructor->ConstructCommandL();
+	CleanupStack::PushL(aliasCommand);
+	MCommand* command = CAliasCommand::NewL(*aliasCommand, iAdditionalArguments, iReplacementArguments);
+	CleanupStack::Pop(aliasCommand); // Now owned by "command".
+	return command;
+	}
+
+void CAliasCommandConstructor::AppendDescriptionL(RLtkBuf16& aBuf) const
+	{
+	aBuf.AppendFormatL(_L("aliased to '%S"), &iAliasedConstructor->CommandName());
+	// Hope I've understood what CAliasCommand::CmndRun does correctly...
+	if (iReplacementArguments)
+		{
+		aBuf.AppendFormatL(_L(" %S"), iReplacementArguments);
+		}
+	else if (iAdditionalArguments)
+		{
+		aBuf.AppendFormatL(_L(" %S <args>"), iAdditionalArguments);
+		}
+	aBuf.AppendL(_L("'"));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/command_constructors.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,121 @@
+// command_constructors.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __COMMAND_CONSTRUCTORS_H__
+#define __COMMAND_CONSTRUCTORS_H__
+
+#include <e32base.h>
+#include <fshell/ioutils.h>
+
+class MCommand;
+namespace LtkUtils { class RLtkBuf16; }
+using LtkUtils::RLtkBuf16;
+
+class CCommandConstructorBase : public CBase
+	{
+public:
+	enum TAttributes
+		{
+		EAttExternal   = 0x00000001,
+		EAttNotInHelp  = 0x00000002,
+		EAttAlias      = 0x00000004
+		};
+	enum TType
+		{
+		ETypeUnknown,
+		ETypeThread,
+		ETypeAlias,
+		ETypeExe,
+		ETypePips
+		};
+public:
+	const TDesC& CommandName() const;
+	TUint Attributes() const;
+	TType Type() const;
+	void SetAttributes(TUint aAttributes);
+	virtual MCommand* ConstructCommandL() = 0;
+	virtual void AppendDescriptionL(RLtkBuf16& aBuf) const = 0;
+	virtual ~CCommandConstructorBase();
+protected:
+	CCommandConstructorBase();
+	CCommandConstructorBase(TType aType);
+	void BaseConstructL(const TDesC& aCommandName);
+private:
+	TType iType;
+	TUint iAttributes;
+	HBufC* iCommandName;
+	};
+
+typedef IoUtils::CCommandBase* (*TCommandConstructor)();
+
+class CThreadCommandConstructor : public CCommandConstructorBase
+	{
+public:
+	static CThreadCommandConstructor* NewLC(TCommandConstructor aConstructor, TUint aFlags);
+	static CThreadCommandConstructor* NewLC(const TDesC& aCommandName, TCommandConstructor aConstructor, TUint aFlags);
+private:
+	CThreadCommandConstructor(TUint aFlags, TCommandConstructor aConstructor);
+private: // From CCommandConstructorBase.
+	virtual MCommand* ConstructCommandL();
+	virtual void AppendDescriptionL(RLtkBuf16& aBuf) const;
+private:
+	TUint iFlags;
+	TCommandConstructor iConstructor;
+	};
+
+class CExeCommandConstructor : public CCommandConstructorBase
+	{
+public:
+	static CExeCommandConstructor* NewLC(const TDesC& aCommandName, const TDesC& aExeName);
+	const TDesC& ExeName() const;
+private:
+	CExeCommandConstructor();
+	~CExeCommandConstructor();
+	void ConstructL(const TDesC& aCommandName, const TDesC& aExeName);
+private: // From CCommandConstructorBase.
+	virtual MCommand* ConstructCommandL();
+	virtual void AppendDescriptionL(RLtkBuf16& aBuf) const;
+private:
+	HBufC* iExeName;
+	};
+
+class CPipsCommandConstructor : public CCommandConstructorBase
+	{
+public:
+	static CPipsCommandConstructor* NewLC(const TDesC& aCommandName);
+private:
+	CPipsCommandConstructor();
+private: // From CCommandConstructorBase.
+	virtual MCommand* ConstructCommandL();
+	virtual void AppendDescriptionL(RLtkBuf16& aBuf) const;
+	};
+
+class CAliasCommandConstructor : public CCommandConstructorBase
+	{
+public:
+	static CAliasCommandConstructor* NewLC(const TDesC& aCommandName, CCommandConstructorBase* aAliasedConstructor, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments);
+	
+private:
+	~CAliasCommandConstructor();
+	CAliasCommandConstructor(CCommandConstructorBase* aAliasedConstructor);
+	void ConstructL(const TDesC& aCommandName, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments);
+private: // From CCommandConstructorBase.
+	virtual MCommand* ConstructCommandL();
+	virtual void AppendDescriptionL(RLtkBuf16& aBuf) const;
+private:
+	CCommandConstructorBase* iAliasedConstructor;
+	HBufC* iAdditionalArguments;
+	HBufC* iReplacementArguments;
+	};
+
+#endif // __COMMAND_CONSTRUCTORS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/command_factory.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,625 @@
+// command_factory.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <f32file.h>
+#include <fshell/common.mmh>
+#include "command_factory.h"
+#include "command_wrappers.h"
+#include "commands.h"
+#include "hello.h"
+#include "kill.h"
+#include "ps.h"
+#include "undertaker.h"
+#include "fuser.h"
+#include "gobble.h"
+#include "xmodem.h"
+#include "ymodem.h"
+#include "version.h"
+
+
+//
+// Constants.
+//
+
+//const TUid KFshellDllUid = {FSHELL_UID2_FSHELL_DLL};
+const TUid KFshellExeUid = {FSHELL_UID2_FSHELL_EXE};
+const TUint KPipsExeUidValue = 0x20004c45;
+const TUid KPipsExeUid = { KPipsExeUidValue };
+_LIT(KExecutableDir, "\\sys\\bin\\");
+_LIT(KFshellPrefix, "fshell_"); // This	MUST be in lower case.
+
+
+//
+// CDummyCommandConstructor.
+//
+
+class CDummyCommandConstructor : public CCommandConstructorBase
+	{
+public:
+	static CDummyCommandConstructor* NewLC(const TDesC& aCommandName);
+private: // From CCommandConstructorBase.
+	virtual MCommand* ConstructCommandL();
+	virtual void AppendDescriptionL(RLtkBuf16& /*aBuf*/) const { }
+	};
+
+CDummyCommandConstructor* CDummyCommandConstructor::NewLC(const TDesC& aCommandName)
+	{
+	CDummyCommandConstructor* self = new(ELeave) CDummyCommandConstructor();
+	CleanupStack::PushL(self);
+	self->BaseConstructL(aCommandName);
+	return self;
+	}
+
+MCommand* CDummyCommandConstructor::ConstructCommandL()
+	{
+	ASSERT(EFalse);
+	return NULL;
+	}
+
+
+//
+// CCommandFactory.
+//
+
+CCommandFactory* CCommandFactory::NewL(RFs& aFs)
+	{
+	CCommandFactory* self = new(ELeave) CCommandFactory(aFs);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CCommandFactory::~CCommandFactory()
+	{
+	Cancel();
+	iCommands.ResetAndDestroy();
+	iLock.Close();
+	}
+
+TInt CompareCommandNames(const CCommandConstructorBase& aCommand1, const CCommandConstructorBase& aCommand2)
+	{
+	return aCommand1.CommandName().Compare(aCommand2.CommandName());
+	}
+
+TInt CCommandFactory::FindCommandL(const TDesC& aCommandName)
+	{
+	CCommandConstructorBase* dummyCommand = CDummyCommandConstructor::NewLC(aCommandName);
+	TInt ret = iCommands.FindInOrder(dummyCommand, TLinearOrder<CCommandConstructorBase>(CompareCommandNames));
+	CleanupStack::PopAndDestroy(dummyCommand);
+	return ret;
+	}
+
+void CCommandFactory::GetCommandInfoL(const TDesC& aCommand, RLtkBuf16& aDescriptionBuf)
+	{
+	CheckExternalCommands();
+	WaitLC();
+
+	TInt pos = FindCommandL(aCommand);
+	User::LeaveIfError(pos);
+
+	iCommands[pos]->AppendDescriptionL(aDescriptionBuf);
+	CleanupStack::PopAndDestroy(); // WaitLC
+	}
+
+void KillAndCloseProcess(RProcess& aProcess)
+	{
+	if (aProcess.Handle() != KNullHandle && aProcess.Handle() != KCurrentProcessHandle)
+		{
+		aProcess.Kill(KErrGeneral);
+		aProcess.Close();
+		}
+	}
+
+MCommand* CCommandFactory::CreateCommandL(const TDesC& aCommandName, TError& aErrorContext, const TDesC& aArguments)
+	{
+	WaitLC();
+	MCommand* command = NULL;
+	RProcess process; // It makes DoCreateCommandL simpler if it doesn't have to worry about cleaning this up
+	TRAPD(err, command = DoCreateCommandL(aCommandName, aArguments, process));
+	if (err)
+		{
+		KillAndCloseProcess(process);
+		aErrorContext.Set(err, TError::EFailedToConstructCommand, aCommandName);
+		User::Leave(err);
+		}
+	CleanupStack::PopAndDestroy(); // WaitLC()
+	return command;
+	}
+
+MCommand* CCommandFactory::DoCreateCommandL(const TDesC& aCommandName, const TDesC& aArguments, RProcess& aProcess)
+	{
+	RProcess& process(aProcess);
+
+	TInt ret = FindCommandL(aCommandName);
+	if (ret >= 0)
+		{
+		// (1) we explicitly know about it
+		return iCommands[ret]->ConstructCommandL();
+		}
+
+	if (iFileSystemScanned)
+		{
+		// (2) We successfully scanned the file system (which means we had enough PlatSec capabilities to do so),
+		//     so any command that we don't know about must be a process command.
+		User::LeaveIfError(process.Create(aCommandName, aArguments));
+		return CProcessCommand::NewL(aCommandName, process);
+		}
+
+	// We didn't manage to scan the file system, so this command could be any kind of external command.
+
+	// See if a .exe extension was explicitly specified.
+	_LIT(KExeSuffix, ".exe");
+	if (aCommandName.Right(KExeSuffix().Length()).CompareF(KExeSuffix) == 0)
+		{
+		// (3) The user spelled it out for us.
+		return CProcessCommand::NewL(aCommandName);
+		}
+
+	// Next, see if it's a process command prefixed with "fshell_".
+	TFileName commandName(KFshellPrefix);
+	commandName.Append(aCommandName);
+	TInt err = process.Create(commandName, aArguments);
+	if (err == KErrNone)
+		{
+		TUid uid2 = process.Type()[1];
+		if (uid2 == KFshellExeUid)
+			{
+			// (6) It's an fshell exe.
+			return CProcessCommand::NewL(commandName, process);
+			}
+		
+		// Found a .exe called fshell_cmd, but it didn't have UID2 of KFshellExeUid. Ignore it and keep looking.
+		KillAndCloseProcess(process);
+		}
+
+	// This is the fallback, a process command of some kind.
+	err = process.Create(aCommandName, aArguments);
+	User::LeaveIfError(err); // We don't have anything else to try, at this point.
+	TUid uid2 = process.Type()[1];
+	if (uid2 == KPipsExeUid && process.Type()[2].iUid != FSHELL_UID_PIPSRUN) // pipsrun itself appears to be a PIPS exe but needs to be treated as an fshell one
+		{
+		// (8) PIPS exe.
+		// CPipsCommand can't make use of the process (because it needs to open it via popen3) so we still need to kill it in this case.
+		KillAndCloseProcess(process);
+		return CPipsCommand::NewL(aCommandName);
+		}
+
+	// (9) Process - either an fshell cmd (one which doesn't start fshell_) or a plain old non-fshell process.
+	return CProcessCommand::NewL(aCommandName, process);
+	}
+
+void CCommandFactory::ListCommandsL(RArray<TPtrC>& aList)
+	{
+	CheckExternalCommands();
+	WaitLC();
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		CCommandConstructorBase* constructor = iCommands[i];
+		if (!(constructor->Attributes() & CCommandConstructorBase::EAttNotInHelp))
+			{
+			TInt err = aList.Append(TPtrC(iCommands[i]->CommandName()));
+			if (err && (err != KErrAlreadyExists))
+				{
+				User::Leave(err);
+				}
+			}
+		}
+	CleanupStack::PopAndDestroy(); // WaitLC.
+	}
+
+TInt CCommandFactory::CountUniqueCommandsL()
+	{
+	CheckExternalCommands();
+	WaitLC();
+	TInt count = 0;
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		CCommandConstructorBase* constructor = iCommands[i];
+		TUint attributes = constructor->Attributes();
+		if (!(attributes & (CCommandConstructorBase::EAttNotInHelp | CCommandConstructorBase::EAttAlias)))
+			{
+			++count;
+			}
+		}
+	CleanupStack::PopAndDestroy(); // WaitLC.
+	return count;
+	}
+
+CCommandFactory::CCommandFactory(RFs& aFs)
+	: CActive(CActive::EPriorityStandard), iFs(aFs)
+#ifdef __WINS__
+	, iFailedToScanFileSystem(ETrue)
+#endif
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CCommandFactory::ConstructL()
+	{
+	User::LeaveIfError(iLock.CreateLocal());
+	User::LeaveIfError(iFs.DriveList(iDriveList));
+
+	AddThreadCommandL(CCmdExit::NewLC); // Note, this command should never execute as 'exit' has handled explicitly by CParser. It exists so that 'exit' appears in fshell's help list and also to support 'exit --help'.
+	AddThreadCommandL(CCmdHelp::NewLC, CThreadCommand::ESharedHeap);
+	AddThreadCommandL(CCmdCd::NewLC, CThreadCommand::EUpdateEnvironment);
+	AddThreadCommandL(CCmdClear::NewLC);
+	AddThreadCommandL(CCmdFg::NewLC, CThreadCommand::ESharedHeap);
+	AddThreadCommandL(CCmdBg::NewLC, CThreadCommand::ESharedHeap);
+	AddThreadCommandL(CCmdJobs::NewLC, CThreadCommand::ESharedHeap);
+	AddThreadCommandL(CCmdExport::NewLC, CThreadCommand::EUpdateEnvironment);
+	AddThreadCommandL(CCmdExists::NewLC);
+	AddThreadCommandL(CCmdVar::NewLC, CThreadCommand::EUpdateEnvironment);
+	AddThreadCommandL(CCmdReattach::NewLC, CThreadCommand::ESharedHeap);
+	AddThreadCommandL(CCmdDisown::NewLC, CThreadCommand::ESharedHeap);
+	AddThreadCommandL(CCmdSource::NewLC, CThreadCommand::EUpdateEnvironment);
+	AddThreadCommandL(CCmdForEach::NewLC, CThreadCommand::EUpdateEnvironment);
+	AddThreadCommandL(CCmdHello::NewLC);
+	AddThreadCommandL(CCmdRm::NewLC);
+	AddThreadCommandL(CCmdCp::NewLC);
+	AddThreadCommandL(CCmdMv::NewLC);
+	AddThreadCommandL(CCmdMkDir::NewLC);
+	AddThreadCommandL(CCmdRmDir::NewLC);
+	AddThreadCommandL(CCmdKill::NewLC);
+	AddThreadCommandL(CCmdLs::NewLC);
+	AddThreadCommandL(CCmdPs::NewLC);
+	AddThreadCommandL(CCmdMatch::NewLC);
+	AddThreadCommandL(CCmdEcho::NewLC);
+	AddThreadCommandL(CCmdMore::NewLC);
+	AddThreadCommandL(CCmdUndertaker::NewLC);
+	AddThreadCommandL(CCmdFileUser::NewLC);
+	AddThreadCommandL(CCmdTrace::NewLC);
+	AddThreadCommandL(CCmdMemInfo::NewLC);
+	AddThreadCommandL(CCmdGobble::NewLC);
+	AddThreadCommandL(CCmdDump::NewLC);
+	AddThreadCommandL(CCmdSleep::NewLC);
+	AddThreadCommandL(CCmdEnv::NewLC);
+	AddThreadCommandL(CCmdSort::NewLC);
+	AddThreadCommandL(CCmdInfoPrint::NewLC);
+	AddThreadCommandL(CCmdRDebug::NewLC);
+	AddThreadCommandL(CCmdDate::NewLC);
+	AddThreadCommandL(CCmdFsck::NewLC);
+	AddThreadCommandL(CCmdDriver::NewLC);
+	AddThreadCommandL(CCmdChunkInfo::NewLC);
+	AddThreadCommandL(CCmdSvrInfo::NewLC);
+	AddThreadCommandL(CCmdXmodem::NewLC);
+	AddThreadCommandL(CCmdYmodem::NewLC);
+	AddThreadCommandL(CCmdTickle::NewLC);
+	AddThreadCommandL(CCmdTicks::NewLC);
+	AddThreadCommandL(CCmdUpTime::NewLC);
+	AddThreadCommandL(CCmdStart::NewLC);
+	AddThreadCommandL(CCmdCompare::NewLC);
+	AddThreadCommandL(CCmdTime::NewLC);
+	AddThreadCommandL(CCmdRepeat::NewLC);
+	AddThreadCommandL(CCmdDebug::NewLC);
+	AddThreadCommandL(CCmdReadMem::NewLC);
+	AddThreadCommandL(CCmdE32Header::NewLC);
+	AddThreadCommandL(CCmdObjInfo::NewLC);
+	AddThreadCommandL(CCmdVersion::NewLC);
+	AddThreadCommandL(CCmdTouch::NewLC);
+	AddThreadCommandL(CCmdDialog::NewLC);
+	AddThreadCommandL(CCmdConsole::NewLC);
+	AddThreadCommandL(CCmdPcons::NewLC);
+	AddThreadCommandL(CCmdIoInfo::NewLC);
+#ifdef __WINS__
+	AddThreadCommandL(CCmdJit::NewLC);
+#endif
+	AddThreadCommandL(CCmdDebugPort::NewLC);
+	AddThreadCommandL(CCmdRom::NewLC);
+	AddThreadCommandL(CCmdWhich::NewLC, CThreadCommand::ESharedHeap);
+	AddThreadCommandL(CCmdTee::NewLC);
+	AddThreadCommandL(CCmdError::NewLC);
+#ifdef FSHELL_CORE_SUPPORT_BUILTIN_REBOOT
+	AddThreadCommandL(CCmdReboot::NewLC);
+#endif
+
+	// Add some DOS-style namings of common commands.
+	AddThreadCommandL(_L("del"), CCmdRm::NewLC, CCommandConstructorBase::EAttAlias);
+	AddThreadCommandL(_L("md"), CCmdMkDir::NewLC, CCommandConstructorBase::EAttAlias);
+	AddThreadCommandL(_L("rd"), CCmdRmDir::NewLC, CCommandConstructorBase::EAttAlias);
+	AddThreadCommandL(_L("copy"), CCmdCp::NewLC, CCommandConstructorBase::EAttAlias);
+	AddThreadCommandL(_L("cls"), CCmdClear::NewLC, CCommandConstructorBase::EAttAlias);
+	AddThreadCommandL(_L("move"), CCmdMv::NewLC, CCommandConstructorBase::EAttAlias);
+	AddThreadCommandL(_L("ren"), CCmdMv::NewLC, CCommandConstructorBase::EAttAlias);
+	_LIT(KDirArg, "-l");
+	AddAliasCommandL(_L("dir"), CCmdLs::NewLC, &KDirArg, NULL, CCommandConstructorBase::EAttAlias);
+
+	// Add aliases for drive letters so that "c:" is treated like "cd c:\".
+	const TInt numDrives = iDriveList.Length();
+	for (TInt i = 0; i < numDrives; ++i)
+		{
+		if (iDriveList[i] & KDriveAttLocal|KDriveAttRom)
+			{
+			TChar driveLetter;
+			if (RFs::DriveToChar(i, driveLetter) == KErrNone)
+				{
+				driveLetter.LowerCase();
+				TBuf<2> name;
+				name.SetLength(2);
+				name[0] = driveLetter;
+				name[1] = ':';
+				TBuf<3> dir(name);
+				dir.Append(_L("\\"));
+				AddAliasCommandL(name, CCmdCd::NewLC, NULL, &dir, CCommandConstructorBase::EAttNotInHelp | CCommandConstructorBase::EAttAlias, CThreadCommand::EUpdateEnvironment);
+				}
+			}
+		}
+	}
+
+void CCommandFactory::WatchFileSystem()
+	{
+	if (!IsActive())
+		{
+		_LIT(KExecutableDir, "?:\\sys\\bin\\");
+		iFs.NotifyChange(ENotifyAll, iStatus, KExecutableDir);
+		SetActive();
+		}
+	}
+
+void CCommandFactory::AddCommandL(CCommandConstructorBase* aCommandConstructor)
+	{
+	TInt err = iCommands.InsertInOrder(aCommandConstructor, TLinearOrder<CCommandConstructorBase>(CompareCommandNames));
+	if (err == KErrAlreadyExists)
+		{
+		// Decide whether this command implementation should override what we already know about.
+		// Note, the precedence should match that in CCommandFactory::CreateCommandL for the case where is wasn't possible
+		// to scan the file system.
+
+		// The order of precedence is:
+		//
+		// 1) Local commands (because if they get overridden, there is no way to access them - external commands can always be specified explicitly using a file extension).
+		// 2) "fshell_" prefixed commands.
+		// 3) EXE commands.
+
+		ASSERT(aCommandConstructor->Attributes() & CCommandConstructorBase::EAttExternal); // Assert that local commands have a unique name.
+		TInt pos = FindCommandL(aCommandConstructor->CommandName());
+		ASSERT(pos >= 0);
+		CCommandConstructorBase* existingCommand = iCommands[pos];
+		TBool override(EFalse);
+		if (existingCommand->Attributes() & CCommandConstructorBase::EAttExternal) 
+			{
+			// Existing is not a local command.
+			CExeCommandConstructor* existingExeCommand = static_cast<CExeCommandConstructor*>(existingCommand); // Note, this cast assumes that ALL external commands are sub-classed from CExeCommandConstructor (which at the time of writing is true).
+			if (existingExeCommand->ExeName().Left(KFshellPrefix().Length()).Compare(KFshellPrefix) != 0)
+				{
+				// Existing is not an "fshell_" prefixed command.
+				if (static_cast<CExeCommandConstructor*>(aCommandConstructor)->ExeName().Left(KFshellPrefix().Length()).Compare(KFshellPrefix) == 0)
+					{
+					// aCommandConstructor is "fshell_" prefixed - allow it to override.
+					override = ETrue;
+					}
+				}
+			}
+		if (override)
+			{
+			delete existingCommand;
+			existingCommand = NULL;
+			iCommands.Remove(pos);
+			iCommands.Insert(aCommandConstructor, pos);
+			}
+		}
+	else
+		{
+		User::LeaveIfError(err);
+		}
+	}
+
+void CCommandFactory::AddThreadCommandL(TCommandConstructor aConstructor, TUint aFlags)
+	{
+	CCommandConstructorBase* constructor = CThreadCommandConstructor::NewLC(aConstructor, aFlags);
+	AddCommandL(constructor);
+	CleanupStack::Pop(constructor);
+	}
+
+void CCommandFactory::AddThreadCommandL(const TDesC& aCommandName, TCommandConstructor aConstructor, TUint aAttributes, TUint aFlags)
+	{
+	CCommandConstructorBase* constructor = CThreadCommandConstructor::NewLC(aCommandName, aConstructor, aFlags);
+	constructor->SetAttributes(aAttributes);
+	AddCommandL(constructor);
+	CleanupStack::Pop(constructor);
+	}
+
+void CCommandFactory::AddAliasCommandL(const TDesC& aAliasName, TCommandConstructor aConstructor, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments, TUint aAttributes, TUint aFlags)
+	{
+	CCommandConstructorBase* aliasedCommand = CThreadCommandConstructor::NewLC(aConstructor, aFlags);
+	CCommandConstructorBase* constructor = CAliasCommandConstructor::NewLC(aAliasName, aliasedCommand, aAdditionalArguments, aReplacementArguments);
+	CleanupStack::Pop(2, aliasedCommand); // Now owned by "constructor".
+	CleanupStack::PushL(constructor);
+	constructor->SetAttributes(aAttributes);
+	AddCommandL(constructor);
+	CleanupStack::Pop(constructor);
+	}
+
+void CCommandFactory::CheckExternalCommands()
+	{
+	if (!iFailedToScanFileSystem && !iFileSystemScanned)
+		{
+		TRAPD(err, FindExternalCommandsL()); // Will fail with KErrPermissionDenied if we don't have TCB.
+		if (err == KErrNone)
+			{
+			WatchFileSystem();
+			}
+		else
+			{
+			iFailedToScanFileSystem = ETrue;
+			}
+		}
+	}
+
+void CCommandFactory::FindExternalCommandsL()
+	{
+	WaitLC();
+
+	// Remove any external commands that we already know about.
+	TInt numCommands = iCommands.Count();
+	for (TInt i = (numCommands - 1); i >= 0; --i)
+		{
+		CCommandConstructorBase* command = iCommands[i];
+		if (command->Attributes() & CCommandConstructorBase::EAttExternal)
+			{
+			iCommands.Remove(i);
+			}
+		}
+
+	//_LIT(KDllExtension, ".dll");
+	//TUidType dllUids(KNullUid, KFshellDllUid, KNullUid);
+	//AppendExternalCommandsL(dllUids, KDllExtension);
+
+	_LIT(KExeExtension, ".exe");
+	TUidType exeUids(KNullUid, KFshellExeUid, KNullUid);
+	AppendExternalCommandsL(exeUids, KExeExtension);
+
+	TUidType pipsUids(KNullUid, KPipsExeUid, KNullUid);
+	AppendExternalCommandsL(pipsUids, KExeExtension);
+
+	iFileSystemScanned = ETrue;
+
+	CleanupStack::PopAndDestroy(); // WaitLC.
+	}
+
+void CCommandFactory::AppendExternalCommandsL(const TUidType& aUidType, const TDesC& aExtension)
+	{
+	//const TInt numDrives = iDriveList.Length();
+	for (TInt drive = EDriveY; ; --drive)
+		{
+		if (drive == -1)
+			{
+			drive = EDriveZ;
+			}
+
+		TChar driveLetter;
+		User::LeaveIfError(RFs::DriveToChar(drive, driveLetter));
+		CDir* dir = NULL;
+		TFileName dirName;
+		dirName.Append(driveLetter);
+		dirName.Append(':');
+		dirName.Append(KExecutableDir);
+		// Try getting the directory contents in one go
+		TInt err = iFs.GetDir(dirName, aUidType, ESortByName, dir);
+		if (err == KErrNone)
+			{
+			CleanupStack::PushL(dir);
+			const TInt count = dir->Count();
+			for (TInt i = 0; i < count; ++i)
+				{
+				DoAppendExternalCommandsL((*dir)[i], aUidType, aExtension);
+				}
+			CleanupStack::PopAndDestroy(dir);
+			}
+		else if (err == KErrNoMemory)
+			{
+			// If not enough memory to read dir in one go, iterate the RDir (slower but uses less memory)
+			RDir d;
+			TInt err = d.Open(iFs, dirName, aUidType);
+			if (err == KErrNone)
+				{
+				CleanupClosePushL(d);
+				TEntry entry;
+				while (err == KErrNone)
+					{
+					err = d.Read(entry);
+					if (err == KErrNone)
+						{
+						DoAppendExternalCommandsL(entry, aUidType, aExtension);
+						}
+					}
+				CleanupStack::PopAndDestroy(&d);
+				}
+			}
+		else if (err == KErrPermissionDenied)
+			{
+			// Abort in this case because all drives will doubtless fail with the same error if we don't have enough capabilities.
+			User::Leave(err);
+			}
+
+		if (drive == EDriveZ)
+			{
+			break;
+			}
+		}
+	}
+
+void CCommandFactory::DoAppendExternalCommandsL(const TEntry& aEntry, const TUidType& aUidType, const TDesC& aExtension)
+	{
+	TInt pos = aEntry.iName.FindF(aExtension);
+	TPtrC name;
+	if (pos >= 0)
+		{
+		name.Set(aEntry.iName.Left(pos));
+		}
+	else
+		{
+		name.Set(aEntry.iName);
+		}
+
+	HBufC* nameBuf = name.AllocLC();
+	nameBuf->Des().Fold();
+	CCommandConstructorBase* commandConstructor = NULL;
+
+	switch (aUidType[1].iUid)
+		{
+		case FSHELL_UID2_FSHELL_EXE:
+			{
+			if (nameBuf->Left(KFshellPrefix().Length()).Compare(KFshellPrefix) == 0)
+				{
+				// Remove the fshell_ from the front, if necessary
+				nameBuf->Des().Delete(0, KFshellPrefix().Length());
+				}
+			commandConstructor = CExeCommandConstructor::NewLC(*nameBuf, aEntry.iName);
+			commandConstructor->SetAttributes(CCommandConstructorBase::EAttExternal);
+			break;
+			}
+		case KPipsExeUidValue:
+			{
+			commandConstructor = CPipsCommandConstructor::NewLC(*nameBuf);
+			commandConstructor->SetAttributes(CCommandConstructorBase::EAttExternal | CCommandConstructorBase::EAttNotInHelp);
+			break;
+			}
+		}
+
+	AddCommandL(commandConstructor);
+	CleanupStack::Pop(commandConstructor);
+	CleanupStack::PopAndDestroy(nameBuf);
+	}
+
+void CCommandFactory::WaitLC() const
+	{
+	iLock.Wait();
+	CleanupStack::PushL(TCleanupItem(Signal, const_cast<CCommandFactory*>(this)));
+	}
+
+void CCommandFactory::Signal(TAny* aSelf)
+	{
+	static_cast<CCommandFactory*>(aSelf)->iLock.Signal();
+	}
+
+void CCommandFactory::RunL()
+	{
+	if (iStatus == KErrNone)
+		{
+		iFileSystemScanned = EFalse;
+		WatchFileSystem();
+		}
+	}
+
+void CCommandFactory::DoCancel()
+	{
+	iFs.NotifyChangeCancel(iStatus);
+	}
+
+TInt CCommandFactory::RunError(TInt)
+	{
+	WatchFileSystem();
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/command_factory.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,64 @@
+// command_factory.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __COMMAND_FACTORY_H__
+#define __COMMAND_FACTORY_H__
+
+#include <e32base.h>
+#include "command_constructors.h"
+#include "error.h"
+
+class RFs;
+class MCommand;
+class CCommandSet;
+
+class CCommandFactory : public CActive
+	{
+public:
+	static CCommandFactory* NewL(RFs& aFs);
+	~CCommandFactory();
+	MCommand* CreateCommandL(const TDesC& aCommandName, TError& aErrorContext, const TDesC& aArguments);
+	void ListCommandsL(RArray<TPtrC>& aList);
+	TInt CountUniqueCommandsL();
+	void GetCommandInfoL(const TDesC& aCommand, RLtkBuf16& aDescriptionBuf);
+private:
+	CCommandFactory(RFs& aFs);
+	void ConstructL();
+	void WatchFileSystem();
+	void AddCommandL(CCommandConstructorBase* aCommandConstructor);
+	void AddThreadCommandL(TCommandConstructor aConstructor, TUint aFlags = 0);
+	void AddThreadCommandL(const TDesC& aCommandName, TCommandConstructor aConstructor, TUint aAttributes, TUint aFlags = 0);
+	void AddAliasCommandL(const TDesC& aAliasName, TCommandConstructor aConstructor, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments, TUint aAttributes, TUint aFlags = 0);
+	void CheckExternalCommands();
+	void FindExternalCommandsL();
+	void AppendExternalCommandsL(const TUidType& aUidType, const TDesC& aExtension);
+	void DoAppendExternalCommandsL(const TEntry& aEntry, const TUidType& aUidType, const TDesC& aExtension);
+	void WaitLC() const;
+	TInt FindCommandL(const TDesC& aCommandName);
+	MCommand* DoCreateCommandL(const TDesC& aCommandName, const TDesC& aArguments, RProcess& aProcess);
+	static void Signal(TAny* aSelf);
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+private:
+	RFs& iFs;
+	mutable RMutex iLock;
+	RPointerArray<CCommandConstructorBase> iCommands;
+	TDriveList iDriveList;
+	TBool iFileSystemScanned;
+	TBool iFailedToScanFileSystem;
+	};
+
+
+#endif // __COMMAND_FACTORY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/command_wrappers.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,789 @@
+// command_wrappers.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "command_wrappers.h"
+
+
+//
+// Constants.
+//
+
+const TInt KMaxHeapSize = KMinHeapSize * 1024;
+
+
+//
+// CCommandWrapperBase.
+//
+
+CCommandWrapperBase::CCommandWrapperBase()
+	{
+	}
+
+CCommandWrapperBase::~CCommandWrapperBase()
+	{
+	iStdin.Close();
+	iStdout.Close();
+	iStderr.Close();
+	delete iName;
+	}
+
+void CCommandWrapperBase::BaseConstructL(const TDesC& aName)
+	{
+	iName = aName.AllocL();
+	}
+
+RIoReadHandle& CCommandWrapperBase::CmndStdin()
+	{
+	return iStdin;
+	}
+
+RIoWriteHandle& CCommandWrapperBase::CmndStdout()
+	{
+	return iStdout;
+	}
+
+RIoWriteHandle& CCommandWrapperBase::CmndStderr()
+	{
+	return iStderr;
+	}
+
+const TDesC& CCommandWrapperBase::CmndName() const
+	{
+	return *iName;
+	}
+
+TInt CCommandWrapperBase::CmndReattachStdin(RIoEndPoint& aStdinEndPoint)
+	{
+	TInt isForeground = iStdin.IsForeground();
+	if (isForeground < 0)
+		{
+		return isForeground;
+		}
+	return aStdinEndPoint.Attach(iStdin, isForeground ? RIoEndPoint::EForeground : RIoEndPoint::EBackground);
+	}
+
+TInt CCommandWrapperBase::CmndReattachStdout(RIoEndPoint& aStdoutEndPoint)
+	{
+	return aStdoutEndPoint.Attach(iStdout);
+	}
+
+TInt CCommandWrapperBase::CmndReattachStderr(RIoEndPoint& aStderrEndPoint)
+	{
+	return aStderrEndPoint.Attach(iStderr);
+	}
+
+TBool CCommandWrapperBase::CmndIsDisownable() const
+	{
+	return EFalse;
+	}
+
+void CCommandWrapperBase::CmndDisown()
+	{
+	ASSERT(EFalse);
+	}
+
+void CCommandWrapperBase::CmndRelease()
+	{
+	delete this;
+	}
+
+
+//
+// CThreadCommand.
+//
+
+CThreadCommand* CThreadCommand::NewL(const TDesC& aName, TCommandConstructor aCommandConstructor, TUint aFlags)
+	{
+	CThreadCommand* self = new(ELeave) CThreadCommand(aCommandConstructor, aFlags);
+	CleanupStack::PushL(self);
+	self->ConstructL(aName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CThreadCommand::~CThreadCommand()
+	{
+	delete iWatcher;
+	delete iArgs;
+	iThread.Close();
+	}
+
+CThreadCommand::CThreadCommand(TCommandConstructor aCommandConstructor, TUint aFlags)
+	: iFlags(aFlags), iCommandConstructor(aCommandConstructor)
+	{
+	iThread.SetHandle(0); // By default RThread refers to the current thread. This results in fshell's thread exiting if this object gets killed before it has managed to open a real thread handle.
+	if (iFlags & EUpdateEnvironment) iFlags |= ESharedHeap; // Update environment implies a shared heap, ever since we did away with the explict SwitchAllocator
+	}
+
+void CThreadCommand::ConstructL(const TDesC& aName)
+	{
+	BaseConstructL(aName);
+	iWatcher = CThreadWatcher::NewL();
+	}
+
+void CommandThreadStartL(CThreadCommand::TArgs& aArgs)
+	{
+	if (aArgs.iFlags & CThreadCommand::ESharedHeap)
+		{
+		// If we're sharing the main fshell heap, we have to play by the rules and not crash
+		User::SetCritical(User::EProcessCritical);
+		}
+
+	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+
+	HBufC* commandLine = aArgs.iCommandLine.AllocLC();
+
+	IoUtils::CEnvironment* env;
+	if (aArgs.iFlags & CThreadCommand::EUpdateEnvironment)
+		{
+		env = aArgs.iEnv.CreateSharedEnvironmentL();
+		}
+	else
+		{
+		// A straight-forward copy
+		env = IoUtils::CEnvironment::NewL(aArgs.iEnv);
+		}
+	CleanupStack::PushL(env);
+
+	CCommandBase* command = (*aArgs.iCommandConstructor)();
+	RThread parentThread;
+	User::LeaveIfError(parentThread.Open(aArgs.iParentThreadId));
+	parentThread.RequestComplete(aArgs.iParentStatus, KErrNone);
+	parentThread.Close();
+
+	command->RunCommandL(commandLine, env);
+	CleanupStack::PopAndDestroy(4, scheduler); // env, command, commandline, scheduler
+	}
+
+TInt CommandThreadStart(TAny* aPtr)
+	{
+	CThreadCommand::TArgs args = *(CThreadCommand::TArgs*)aPtr;
+	TBool sharedHeap = (args.iFlags & CThreadCommand::ESharedHeap);
+	if (!sharedHeap)
+		{
+		__UHEAP_MARK;
+		}
+	TInt err = KErrNoMemory;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup)
+		{
+		TRAP(err, CommandThreadStartL(args));
+		delete cleanup;
+		}
+	if (!sharedHeap)
+		{
+		__UHEAP_MARKEND;
+		}
+	return err;
+	}
+
+void SetHandleOwnersL(TThreadId aThreadId, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr)
+	{
+	User::LeaveIfError(aStdin.SetOwner(aThreadId));
+	User::LeaveIfError(aStdout.SetOwner(aThreadId));
+	User::LeaveIfError(aStderr.SetOwner(aThreadId));
+	};
+
+TInt CThreadCommand::CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession&)
+	{
+	ASSERT(iObserver == NULL);
+
+	TRequestStatus status(KRequestPending);
+	iArgs = new TArgs(iFlags, aEnv, iCommandConstructor, aCommandLine, status);
+	if (iArgs == NULL)
+		{
+		return KErrNoMemory;
+		}
+
+	TInt i = 0;
+	TName threadName;
+	TInt err = KErrNone;
+	do
+		{
+		const TDesC& name = CmndName();
+		threadName.Format(_L("%S_%02d"), &name, i++);
+		if (iFlags & ESharedHeap)
+			{
+			err = iThread.Create(threadName, CommandThreadStart, KDefaultStackSize, NULL, iArgs);
+			}
+		else
+			{
+			err = iThread.Create(threadName, CommandThreadStart, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, iArgs);
+			}
+		}
+		while (err == KErrAlreadyExists);
+
+	if (err)
+		{
+		return err;
+		}
+
+	err = iWatcher->Logon(*this, iThread, aObserver);
+	if (err)
+		{
+		iThread.Kill(0);
+		iThread.Close();
+		return err;
+		}
+
+	TThreadId threadId = iThread.Id();
+	TRAP(err, SetHandleOwnersL(threadId, CmndStdin(), CmndStdout(), CmndStderr()));
+	if (err)
+		{
+		iThread.Kill(0);
+		iThread.Close();
+		return err;
+		}
+
+	iThread.Resume();
+	User::WaitForRequest(status, iWatcher->iStatus);
+	if (status == KRequestPending)
+		{
+		iThread.Close();
+		return iWatcher->iStatus.Int();
+		}
+
+	iWatcher->SetActive();
+	iObserver = &aObserver;
+	return KErrNone;
+	}
+
+void CThreadCommand::CmndForeground()
+	{
+	iThread.SetPriority(EPriorityAbsoluteForeground);
+	}
+
+void CThreadCommand::CmndBackground()
+	{
+	iThread.SetPriority(EPriorityAbsoluteBackground);
+	}
+
+void CThreadCommand::CmndKill()
+	{
+	if (iThread.Handle())
+		{
+		iThread.Kill(KErrAbort);
+		}
+	}
+
+TInt CThreadCommand::CmndSuspend()
+	{
+	iThread.Suspend();
+	return KErrNone;
+	}
+
+TInt CThreadCommand::CmndResume()
+	{
+	iThread.Resume();
+	return KErrNone;
+	}
+
+TExitType CThreadCommand::CmndExitType() const
+	{
+	return iThread.ExitType();
+	}
+
+
+TExitCategoryName CThreadCommand::CmndExitCategory() const
+	{
+	return iThread.ExitCategory();
+	}
+
+
+//
+// CThreadCommand::TArgs.
+//
+
+CThreadCommand::TArgs::TArgs(TUint aFlags, IoUtils::CEnvironment& aEnv, TCommandConstructor aCommandConstructor, const TDesC& aCommandLine, TRequestStatus& aParentStatus)
+	: iFlags(aFlags), iEnv(aEnv), iCommandConstructor(aCommandConstructor), iCommandLine(aCommandLine), iParentStatus(&aParentStatus), iParentThreadId(RThread().Id())
+	{
+	}
+
+
+//
+// CThreadCommand::CThreadWatcher.
+//
+
+CThreadCommand::CThreadWatcher* CThreadCommand::CThreadWatcher::NewL()
+	{
+	return new(ELeave) CThreadWatcher();
+	}
+
+CThreadCommand::CThreadWatcher::~CThreadWatcher()
+	{
+	Cancel();
+	}
+
+CThreadCommand::CThreadWatcher::CThreadWatcher()
+	: CActive(CActive::EPriorityStandard)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+TInt CThreadCommand::CThreadWatcher::Logon(CThreadCommand& aCommand, RThread& aThread, MCommandObserver& aObserver)
+	{
+	TInt ret = KErrNone;
+	aThread.Logon(iStatus);
+	if (iStatus != KRequestPending)
+		{
+		User::WaitForRequest(iStatus);
+		ret = iStatus.Int();
+		}
+	else
+		{
+		iCommand = &aCommand;
+		iThread = &aThread;
+		iObserver = &aObserver;
+		}
+	return ret;
+	}
+
+void CThreadCommand::CThreadWatcher::SetActive()
+	{
+	CActive::SetActive();
+	}
+
+void CThreadCommand::CThreadWatcher::RunL()
+	{
+	iObserver->HandleCommandComplete(*iCommand, iStatus.Int());
+	}
+
+void CThreadCommand::CThreadWatcher::DoCancel()
+	{
+	if (iThread)
+		{
+		iThread->LogonCancel(iStatus);
+		}
+	}
+
+
+//
+// CProcessCommand.
+//
+
+CProcessCommand* CProcessCommand::NewL(const TDesC& aExeName)
+	{
+	CProcessCommand* self = new(ELeave) CProcessCommand();
+	CleanupStack::PushL(self);
+	self->ConstructL(aExeName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CProcessCommand* CProcessCommand::NewL(const TDesC& aExeName, RProcess& aProcess)
+	{
+	CProcessCommand* self = new(ELeave) CProcessCommand();
+	CleanupStack::PushL(self);
+	self->ConstructL(aExeName, &aProcess);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+CProcessCommand::~CProcessCommand()
+	{
+	delete iWatcher;
+	iProcess.Close();
+	}
+
+CProcessCommand::CProcessCommand()
+	{
+	iProcess.SetHandle(KNullHandle); // By default RProcess refers to the current process (KCurrentProcessHandle). This results in fshell's process exiting if this object gets killed before it has managed to open a real process handle.
+	}
+
+void CProcessCommand::ConstructL(const TDesC& aExeName, RProcess* aProcess)
+	{
+	BaseConstructL(aExeName);
+	iWatcher = CProcessWatcher::NewL();
+	if (aProcess)
+		{
+		// Don't take ownership of the aProcess handle until after everything that can leave has been run
+		iProcess.SetHandle(aProcess->Handle());
+		}
+	}
+
+void CProcessCommand::CreateProcessL(const TDesC& aCommandLine, IoUtils::CEnvironment&)
+	{
+	if (iProcess.Handle() == KNullHandle)
+		{
+		// Don't create new proc if we were passed one in initially
+		User::LeaveIfError(iProcess.Create(CmndName(), aCommandLine));
+		}
+	}
+
+void CProcessCommand::CmndRunL(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver)
+	{
+	CreateProcessL(aCommandLine, aEnv);
+
+	HBufC8* envBuf = aEnv.ExternalizeLC();
+	User::LeaveIfError(iProcess.SetParameter(IoUtils::KEnvironmentProcessSlot, *envBuf));
+	CleanupStack::PopAndDestroy(envBuf);
+
+	TFullName fullName(iProcess.Name());
+	_LIT(KThreadName,"::Main");
+	fullName.Append(KThreadName);
+	RThread thread;
+	User::LeaveIfError(thread.Open(fullName));
+	TThreadId threadId(thread.Id());
+	thread.Close();
+	User::LeaveIfError(CmndStdin().SetOwner(threadId));
+	User::LeaveIfError(CmndStdout().SetOwner(threadId));
+	User::LeaveIfError(CmndStderr().SetOwner(threadId));
+	TInt err = iWatcher->Logon(*this, iProcess, aObserver);
+	if (err)
+		{
+		iProcess.Kill(0);
+		}
+	User::LeaveIfError(err);
+	iObserver = &aObserver;
+	iProcess.Resume();
+	}
+
+TInt CProcessCommand::CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession&)
+	{
+	ASSERT(iObserver == NULL);
+	TRAPD(err, CmndRunL(aCommandLine, aEnv, aObserver));
+	return err;
+	}
+
+void CProcessCommand::CmndForeground()
+	{
+	iProcess.SetPriority(EPriorityForeground);
+	}
+
+void CProcessCommand::CmndBackground()
+	{
+	iProcess.SetPriority(EPriorityBackground);
+	}
+
+void CProcessCommand::CmndKill()
+	{
+	if (iProcess.Handle())
+		{
+		iProcess.Kill(KErrAbort);
+		}
+	}
+
+TInt CProcessCommand::CmndSuspend()
+	{
+#ifdef EKA2
+	// Can't currently support suspend in EKA2 - KERN-EXEC 46 will result.
+	return KErrNotSupported;
+#else
+	TName processName(iProcess.Name());
+	processName.Append(_L("::*"));
+	TFullName threadName;
+	TFindThread threadFinder(processName);
+	while (threadFinder.Next(threadName) == KErrNone)
+		{
+		RThread thread;
+		if (thread.Open(threadName) == KErrNone)
+			{
+			thread.Suspend();
+			thread.Close();
+			}
+		}
+	return KErrNone;
+#endif
+	}
+
+TInt CProcessCommand::CmndResume()
+	{
+#ifdef EKA2
+	// Can't currently support resume in EKA2 - KERN-EXEC 46 will result.
+	return KErrNotSupported;
+#else
+	TName processName(iProcess.Name());
+	processName.Append(_L("::*"));
+	TFullName threadName;
+	TFindThread threadFinder(processName);
+	while (threadFinder.Next(threadName) == KErrNone)
+		{
+		RThread thread;
+		if (thread.Open(threadName) == KErrNone)
+			{
+			thread.Resume();
+			thread.Close();
+			}
+		}
+	return KErrNone;
+#endif
+	}
+
+TExitType CProcessCommand::CmndExitType() const
+	{
+	return iProcess.ExitType();
+	}
+
+TExitCategoryName CProcessCommand::CmndExitCategory() const
+	{
+	return iProcess.ExitCategory();
+	}
+
+TBool CProcessCommand::CmndIsDisownable() const
+	{
+	return ETrue;
+	}
+
+void CProcessCommand::CmndDisown()
+	{
+	delete iWatcher;
+	iWatcher = NULL;
+	iProcess.Close();
+	}
+
+
+//
+// CProcessCommand::CProcessWatcher.
+//
+
+CProcessCommand::CProcessWatcher* CProcessCommand::CProcessWatcher::NewL()
+	{
+	return new(ELeave) CProcessWatcher();
+	}
+
+CProcessCommand::CProcessWatcher::~CProcessWatcher()
+	{
+	Cancel();
+	}
+
+TInt CProcessCommand::CProcessWatcher::Logon(CProcessCommand& aCommand, RProcess& aProcess, MCommandObserver& aObserver)
+	{
+	TInt ret = KErrNone;
+	aProcess.Logon(iStatus);
+	if (iStatus != KRequestPending)
+		{
+		User::WaitForRequest(iStatus);
+		ret = iStatus.Int();
+		}
+	else
+		{
+		iCommand = &aCommand;
+		iProcess = &aProcess;
+		iObserver = &aObserver;
+		SetActive();
+		}
+	return ret;
+	}
+
+CProcessCommand::CProcessWatcher::CProcessWatcher()
+	: CActive(CActive::EPriorityStandard)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CProcessCommand::CProcessWatcher::RunL()
+	{
+	iObserver->HandleCommandComplete(*iCommand, iStatus.Int());
+	}
+
+void CProcessCommand::CProcessWatcher::DoCancel()
+	{
+	if (iProcess)
+		{
+		iProcess->LogonCancel(iStatus);
+		}
+	}
+
+//
+// CPipsCommand.
+//
+
+CPipsCommand* CPipsCommand::NewL(const TDesC& aExeName)
+	{
+	CPipsCommand* self = new (ELeave) CPipsCommand();
+	CleanupStack::PushL(self);
+	self->ConstructL(aExeName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CPipsCommand::CPipsCommand()
+	{
+	}
+
+CPipsCommand::~CPipsCommand()
+	{
+	}
+
+TInt CPipsCommand::CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession)
+	{
+	TInt err = CProcessCommand::CmndRun(aCommandLine, aEnv, aObserver, aIoSession);
+	if ((err == KErrNone) && iUsingPipsRun)
+		{
+		TRequestStatus status;
+		iProcess.Rendezvous(status);
+		User::WaitForRequest(status);
+		err = status.Int();
+		if (err > 0)
+			{
+			iPipsRunChildProcessId = err;
+			err = KErrNone;
+			}
+		}
+	return err;
+	}
+
+void CPipsCommand::CmndKill()
+	{
+	CProcessCommand::CmndKill();
+
+	if (iUsingPipsRun)
+		{
+		RProcess pipsRunChildProcess;
+		if (pipsRunChildProcess.Open(iPipsRunChildProcessId) == KErrNone)
+			{
+			pipsRunChildProcess.Kill(KErrAbort);
+			pipsRunChildProcess.Close();
+			}
+		}
+	}
+
+void CPipsCommand::CreateProcessL(const TDesC& aCommandLine, IoUtils::CEnvironment&)
+	{
+	_LIT(KPipsRunExe, "pipsrun");
+	TInt err = iProcess.Create(KPipsRunExe, KNullDesC);
+	if (err == KErrNotFound)
+		{
+		// Looks like pipsrun.exe isn't present - just load the PIPS exe directly.
+		User::LeaveIfError(iProcess.Create(CmndName(), aCommandLine));
+		}
+	else
+		{
+		User::LeaveIfError(err);
+		User::LeaveIfError(iProcess.SetParameter(IoUtils::KPipsCommandNameProcessSlot, CmndName()));
+		User::LeaveIfError(iProcess.SetParameter(IoUtils::KPipsCommandLineProcessSlot, aCommandLine));
+		iUsingPipsRun = ETrue;
+		}
+	}
+
+
+//
+// CAliasCommand.
+//
+
+CAliasCommand* CAliasCommand::NewL(MCommand& aAliasedCommand, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments)
+	{
+	CAliasCommand* self = new(ELeave) CAliasCommand(aAliasedCommand);
+	CleanupStack::PushL(self);
+	self->ConstructL(aAdditionalArguments, aReplacementArguments);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CAliasCommand::~CAliasCommand()
+	{
+	delete iAdditionalArguments;
+	delete iReplacementArguments;
+	iAliasedCommand.CmndRelease();
+	}
+
+CAliasCommand::CAliasCommand(MCommand& aAliasedCommand)
+	: iAliasedCommand(aAliasedCommand)
+	{
+	}
+
+void CAliasCommand::ConstructL(const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments)
+	{
+	BaseConstructL(iAliasedCommand.CmndName());
+	if (aAdditionalArguments)
+		{
+		iAdditionalArguments = aAdditionalArguments->AllocL();
+		}
+	if (aReplacementArguments)
+		{
+		iReplacementArguments = aReplacementArguments->AllocL();
+		}
+	}
+
+RIoReadHandle& CAliasCommand::CmndStdin()
+	{
+	return iAliasedCommand.CmndStdin();
+	}
+
+RIoWriteHandle& CAliasCommand::CmndStdout()
+	{
+	return iAliasedCommand.CmndStdout();
+	}
+
+RIoWriteHandle& CAliasCommand::CmndStderr()
+	{
+	return iAliasedCommand.CmndStderr();
+	}
+
+TInt CAliasCommand::CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession)
+	{
+	if (iAdditionalArguments && !iReplacementArguments)
+		{
+		iAdditionalArguments = iAdditionalArguments->ReAlloc(iAdditionalArguments->Length() + aCommandLine.Length() + 1);
+		if (iAdditionalArguments == NULL)
+			{
+			return KErrNoMemory;
+			}
+		_LIT(KSpace, " ");
+		iAdditionalArguments->Des().Append(KSpace);
+		iAdditionalArguments->Des().Append(aCommandLine);
+		}
+	iCommandObserver = &aObserver;
+	const TDesC* args = &aCommandLine;
+	if (iReplacementArguments)
+		{
+		args = iReplacementArguments;
+		}
+	else if (iAdditionalArguments)
+		{
+		args = iAdditionalArguments;
+		}
+	return iAliasedCommand.CmndRun(*args, aEnv, *this, aIoSession);
+	}
+
+void CAliasCommand::CmndForeground()
+	{
+	iAliasedCommand.CmndForeground();
+	}
+
+void CAliasCommand::CmndBackground()
+	{
+	iAliasedCommand.CmndBackground();
+	}
+
+void CAliasCommand::CmndKill()
+	{
+	iAliasedCommand.CmndKill();
+	}
+
+TInt CAliasCommand::CmndSuspend()
+	{
+	return iAliasedCommand.CmndSuspend();
+	}
+
+TInt CAliasCommand::CmndResume()
+	{
+	return iAliasedCommand.CmndResume();
+	}
+
+TExitType CAliasCommand::CmndExitType() const
+	{
+	return iAliasedCommand.CmndExitType();
+	}
+
+TExitCategoryName CAliasCommand::CmndExitCategory() const
+	{
+	return iAliasedCommand.CmndExitCategory();
+	}
+
+void CAliasCommand::HandleCommandComplete(MCommand&, TInt aError)
+	{
+	iCommandObserver->HandleCommandComplete(*this, aError);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/command_wrappers.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,242 @@
+// command_wrappers.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __COMMAND_WRAPPERS_H__
+#define __COMMAND_WRAPPERS_H__
+
+#include <e32base.h>
+#include <fshell/iocli.h>
+#include <fshell/ioutils.h>
+#include "command_constructors.h"
+
+using namespace IoUtils;
+
+
+class MCommandObserver;
+
+
+class MCommand
+	{
+public:
+	virtual RIoReadHandle& CmndStdin() = 0;
+	virtual RIoWriteHandle& CmndStdout() = 0;
+	virtual RIoWriteHandle& CmndStderr() = 0;
+	virtual TInt CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession) = 0;
+	virtual void CmndForeground() = 0;
+	virtual void CmndBackground() = 0;
+	virtual void CmndKill() = 0;
+	virtual TInt CmndSuspend() = 0;
+	virtual TInt CmndResume() = 0;
+	virtual void CmndRelease() = 0;
+	virtual TExitType CmndExitType() const = 0;
+	virtual TExitCategoryName CmndExitCategory() const = 0;
+	virtual const TDesC& CmndName() const = 0;
+	virtual TInt CmndReattachStdin(RIoEndPoint& aStdinEndPoint) = 0;
+	virtual TInt CmndReattachStdout(RIoEndPoint& aStdoutEndPoint) = 0;
+	virtual TInt CmndReattachStderr(RIoEndPoint& aStderrEndPoint) = 0;
+	virtual TBool CmndIsDisownable() const = 0;
+	virtual void CmndDisown() = 0;
+	};
+
+
+class MCommandObserver
+	{
+public:
+	virtual void HandleCommandComplete(MCommand& aCommand, TInt aError) = 0;
+	};
+
+
+class CCommandWrapperBase : public CBase, public MCommand
+	{
+protected:
+	CCommandWrapperBase();
+	~CCommandWrapperBase();
+	void BaseConstructL(const TDesC& aName);
+protected: // From MCommand.
+	virtual RIoReadHandle& CmndStdin();
+	virtual RIoWriteHandle& CmndStdout();
+	virtual RIoWriteHandle& CmndStderr();
+	virtual const TDesC& CmndName() const;
+	virtual TInt CmndReattachStdin(RIoEndPoint& aStdinEndPoint);
+	virtual TInt CmndReattachStdout(RIoEndPoint& aStdoutEndPoint);
+	virtual TInt CmndReattachStderr(RIoEndPoint& aStderrEndPoint);
+	virtual TBool CmndIsDisownable() const;
+	virtual void CmndDisown();
+private: // From MCommand.
+	virtual void CmndRelease();
+private:
+	HBufC* iName;	///< This is used by concrete classes as they see fit.
+	RIoReadHandle iStdin;
+	RIoWriteHandle iStdout;
+	RIoWriteHandle iStderr;
+	};
+
+
+class CThreadCommand : public CCommandWrapperBase
+	{
+public:
+	enum TFlags
+		{
+		EUpdateEnvironment = 0x00000001,
+		ESharedHeap = 0x00000002, // Any command that accesses gShell must have this set
+		};
+public:
+	static CThreadCommand* NewL(const TDesC& aName, TCommandConstructor aCommandConstructor, TUint aFlags);
+	~CThreadCommand();
+private:
+	CThreadCommand(TCommandConstructor aCommandConstructor, TUint aFlags);
+	void ConstructL(const TDesC& aName);
+private: // From MCommand.
+	virtual TInt CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession);
+	virtual void CmndForeground();
+	virtual void CmndBackground();
+	virtual void CmndKill();
+	virtual TInt CmndSuspend();
+	virtual TInt CmndResume();
+	virtual TExitType CmndExitType() const;
+	virtual TExitCategoryName CmndExitCategory() const;
+public:
+	class TArgs
+		{
+	public:
+		TArgs(TUint aFlags, CEnvironment& aEnv, TCommandConstructor aCommandConstructor, const TDesC& aCommandLine, TRequestStatus& aParentStatus);
+	public:
+		TUint iFlags;
+		CEnvironment& iEnv;
+		TCommandConstructor iCommandConstructor;
+		const TPtrC iCommandLine;
+		TRequestStatus* iParentStatus;
+		TThreadId iParentThreadId;
+		};
+	class CThreadWatcher : public CActive
+		{
+	public:
+		static CThreadWatcher* NewL();
+		~CThreadWatcher();
+		TInt Logon(CThreadCommand& aCommand, RThread& aThread, MCommandObserver& aObserver);
+		void SetActive();
+	private:
+		CThreadWatcher();
+	private: // From CActive.
+		virtual void RunL();
+		virtual void DoCancel();
+	private:
+		CThreadCommand* iCommand;
+		RThread* iThread;
+		MCommandObserver* iObserver;
+		};
+private:
+	TUint iFlags;
+	TCommandConstructor iCommandConstructor;
+	MCommandObserver* iObserver;
+	TArgs* iArgs;
+	RThread iThread;
+	CThreadWatcher* iWatcher;
+	};
+
+
+class CProcessCommand : public CCommandWrapperBase
+	{
+public:
+	static CProcessCommand* NewL(const TDesC& aExeName);
+	static CProcessCommand* NewL(const TDesC& aExeName, RProcess& aProcess);
+	~CProcessCommand();
+protected:
+	CProcessCommand();
+	void ConstructL(const TDesC& aExeName, RProcess* aProcess = NULL);
+	virtual void CreateProcessL(const TDesC& aCommandLine, CEnvironment& aEnv);
+private:
+	void CmndRunL(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver);
+protected: // From MCommand.
+	virtual TInt CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession);
+	virtual void CmndForeground();
+	virtual void CmndBackground();
+	virtual void CmndKill();
+	virtual TInt CmndSuspend();
+	virtual TInt CmndResume();
+	virtual TExitType CmndExitType() const;
+	virtual TExitCategoryName CmndExitCategory() const;
+	virtual TBool CmndIsDisownable() const;
+	virtual void CmndDisown();
+public:
+	class CProcessWatcher : public CActive
+		{
+	public:
+		static CProcessWatcher* NewL();
+		~CProcessWatcher();
+		TInt Logon(CProcessCommand& aCommand, RProcess& aProcess, MCommandObserver& aObserver);
+	private:
+		CProcessWatcher();
+	private: // From CActive.
+		virtual void RunL();
+		virtual void DoCancel();
+	private:
+		CProcessCommand* iCommand;
+		RProcess* iProcess;
+		MCommandObserver* iObserver;
+		};
+protected:
+	MCommandObserver* iObserver;
+	RProcess iProcess;
+	CProcessWatcher* iWatcher;
+	};
+
+
+class CPipsCommand : public CProcessCommand
+	{
+public:
+	static CPipsCommand* NewL(const TDesC& aExeName);
+	CPipsCommand();
+	~CPipsCommand();
+private: // From MCommand.
+	virtual TInt CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession);
+	virtual void CmndKill();
+private: // From CProcessCommand.
+	virtual void CreateProcessL(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv);
+private:
+	TBool iUsingPipsRun;
+	TInt iPipsRunChildProcessId;
+	};
+
+
+class CAliasCommand : public CCommandWrapperBase, public MCommandObserver
+	{
+public:
+	static CAliasCommand* NewL(MCommand& aAliasedCommand, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments);
+	~CAliasCommand();
+private:
+	CAliasCommand(MCommand& aAliasedCommand);
+	void ConstructL(const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments);
+private: // From MCommand.
+	RIoReadHandle& CmndStdin();
+	RIoWriteHandle& CmndStdout();
+	RIoWriteHandle& CmndStderr();
+	TInt CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession);
+	void CmndForeground();
+	void CmndBackground();
+	void CmndKill();
+	TInt CmndSuspend();
+	TInt CmndResume();
+	TExitType CmndExitType() const;
+	TExitCategoryName CmndExitCategory() const;
+private: // From MCommandObserver.
+	virtual void HandleCommandComplete(MCommand& aCommand, TInt aError);
+private:
+	MCommand& iAliasedCommand;
+	HBufC* iAdditionalArguments;
+	HBufC* iReplacementArguments;
+	MCommandObserver* iCommandObserver;
+	};
+
+
+#endif // __COMMAND_WRAPPERS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/commands.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,6152 @@
+// commands.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32debug.h>
+#include <e32rom.h>
+#include <f32dbg.h>
+#include <f32image.h>
+#include <hal.h>
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+#include <fshell/descriptorutils.h>
+#include <fshell/heaputils.h>
+using LtkUtils::RAllocatorHelper;
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+#include <fshell/memoryaccess.h>
+#endif
+#include "fshell.h"
+#include "commands.h"
+#include "command_factory.h"
+#include "string_utils.h"
+
+
+//
+// Constants.
+//
+
+_LIT(KOptVerbose, "verbose");
+_LIT(KOptHuman, "human");
+
+_LIT(KNewLine, "\r\n");
+_LIT(KTab, "\t");
+_LIT(KRepeatCount, "REPEAT_COUNT");
+const TInt KBlockSize = 512;
+
+_LIT(KMatchAll, "*");
+
+
+//
+// CCmdHelp.
+//
+
+CCommandBase* CCmdHelp::NewLC()
+	{
+	CCmdHelp* self = new(ELeave) CCmdHelp();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdHelp::~CCmdHelp()
+	{
+	delete iFormatter;
+	}
+
+CCmdHelp::CCmdHelp() : CCommandBase(ECompleteOnRunL)
+	{
+	}
+
+const TDesC& CCmdHelp::Name() const
+	{
+	_LIT(KCmdHelpName, "help");
+	return KCmdHelpName;
+	}
+
+void CCmdHelp::DoRunL()
+	{
+	if (iOptions.IsPresent(&iCount))
+		{
+		const TInt count = gShell->CommandFactory().CountUniqueCommandsL();
+		Complete(_L("%d\r\n"), count);
+		}
+	else
+		{
+		RArray<TPtrC> commands;
+		CleanupClosePushL(commands);
+		gShell->CommandFactory().ListCommandsL(commands);
+		iFormatter = CTextFormatter::NewL(Stdout());
+		iFormatter->ColumnizeL(0, 2, commands.Array());
+		CleanupStack::PopAndDestroy(&commands);
+		Stdout().Write(iFormatter->Descriptor(), iStatus);
+		SetActive();
+		}
+	}
+
+void CCmdHelp::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptCount, "count");
+	aOptions.AppendBoolL(iCount, KOptCount);
+	}
+
+
+//
+// CCmdExit.
+//
+
+CCommandBase* CCmdExit::NewLC()
+	{
+	CCmdExit* self = new(ELeave) CCmdExit();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdExit::~CCmdExit()
+	{
+	}
+
+CCmdExit::CCmdExit()
+	{
+	}
+
+const TDesC& CCmdExit::Name() const
+	{
+	_LIT(KCmdExitName, "exit");
+	return KCmdExitName;
+	}
+
+void CCmdExit::DoRunL()
+	{
+	// Note, this command should never execute as 'exit' has handled explicitly by CParser.
+	// It exists so that 'exit' appears in fshell's help list and also to support 'exit --help'.
+	LeaveIfErr(KErrGeneral, _L("Invalid context for 'exit' command (must be run as a bare command, not in a pipe-line)"));
+	}
+
+
+//
+// CCmdLs.
+//
+
+CCommandBase* CCmdLs::NewLC()
+	{
+	CCmdLs* self = new(ELeave) CCmdLs();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CCmdLs::~CCmdLs()
+	{
+	delete iFormatter;
+	}
+
+CCmdLs::CCmdLs()
+	{
+	}
+
+void CCmdLs::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+void CCmdLs::PrintDirContentL(RDir& aDir)
+	{
+	TInt err = KErrNone;
+	TEntry entry;
+	while (err == KErrNone)
+		{
+		err = aDir.Read(entry);
+		if (err == KErrNone)
+			{
+			FormatEntryL(entry);
+			Write(iFormatter->Descriptor());
+			iFormatter->Zero();
+
+			if (iOptRecurse && entry.IsDir())
+				{
+				RecursiveScanDirL(entry.iName);
+				}
+			}
+		}
+	if (err == KErrEof)
+		{
+		err = KErrNone;
+		}
+	User::LeaveIfError(err);
+	}
+
+void CCmdLs::PrintDirContentL(const CDir& aDir)
+	{
+	IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x100);
+
+	const TInt numEntries = aDir.Count();
+	for (TInt i = 0; i < numEntries; ++i)
+		{
+		const TEntry& entry = aDir[i];
+		buf->AppendL(entry.iName);
+		buf->AppendL(_L("\t"));
+		}
+
+	iFormatter->ColumnizeL(0, 2, buf->Descriptor());
+	Write(iFormatter->Descriptor());
+	CleanupStack::PopAndDestroy(buf);
+	}
+
+void CCmdLs::FormatEntryL(const TEntry& aEntry)
+	{
+	if (iOptLong)
+		{
+		iFormatter->AppendFormatL(_L("%c%c%c%c%c  "), aEntry.IsDir() ? 'd' : '-', aEntry.IsReadOnly() ? 'r' : '-', aEntry.IsHidden() ? 'h' : '-', aEntry.IsSystem() ? 's' : '-', aEntry.IsArchive() ? 'a' : '-');
+		if (iOptHuman)
+			{
+			iFormatter->AppendHumanReadableSizeL(aEntry.iSize);
+			iFormatter->AppendL(_L("  "));
+			}
+		else
+			{
+			iFormatter->AppendFormatL(_L("%+ 10d  "), aEntry.iSize);
+			}
+		aEntry.iModified.FormatL(iTempBuf, _L("%1%/1%2%/2%3 %H%:1%T%:2%S "));
+		TPtrC pathRelativeToBaseDir = iFileName.Mid(iBaseDir.Length());
+		iFormatter->AppendFormatL(_L("%S%S%S\r\n"), &iTempBuf, &pathRelativeToBaseDir, &aEntry.iName);
+		}
+	else
+		{
+		TPtrC pathRelativeToBaseDir = iFileName.Mid(iBaseDir.Length());
+		iFormatter->AppendFormatL(_L("%S%S\r\n"), &pathRelativeToBaseDir, &aEntry.iName);
+		}
+	}
+
+const TDesC& CCmdLs::Name() const
+	{
+	_LIT(KCmdLsName, "ls");
+	return KCmdLsName;
+	}
+
+void CCmdLs::DoRunL()
+	{
+	if (iFileName.Length() == 0)
+		{
+		iFileName = Env().Pwd();
+		}
+
+	if (!iFileName.IsWild() && !iFileName.IsDriveRoot())
+		{
+		LeaveIfFileNotFound(iFileName);
+		if (iFileName.IsDirL(FsL()))
+			{
+			iFileName.SetIsDirectoryL();
+			}
+		}
+
+	if (iOptRecurse || iOptLong || !Stdout().AttachedToConsole())
+		{
+		iOptOnePerLine = ETrue;
+		}
+
+	iFormatter = CTextFormatter::NewL(Stdout());
+	iBaseDir.Set(TParsePtrC(iFileName).DriveAndPath());
+
+	if (iOptOnePerLine)
+		{
+		DoScanDirL();
+		}
+	else
+		{
+		CDir* files;
+		LeaveIfErr(FsL().GetDir(iFileName, iOptAll ? KEntryAttMaskSupported : KEntryAttNormal | KEntryAttDir, ESortByName, files), _L("Couldn't read whole directory into memory - try using -1"));
+		CleanupStack::PushL(files);
+		PrintDirContentL(*files);
+		CleanupStack::PopAndDestroy(files);
+		}
+	}
+
+void CCmdLs::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdLsOptAll, "all");
+	_LIT(KCmdLsOptLong, "long");
+	_LIT(KCmdLsOptHuman, "human");
+	_LIT(KCmdLsOptOnePerLine, "one");
+	_LIT(KCmdLsOpRecurse, "recurse");
+
+	aOptions.AppendBoolL(iOptAll, KCmdLsOptAll);
+	aOptions.AppendBoolL(iOptLong, KCmdLsOptLong);
+	aOptions.AppendBoolL(iOptHuman, KCmdLsOptHuman);
+	aOptions.AppendBoolL(iOptOnePerLine, KCmdLsOptOnePerLine);
+	aOptions.AppendBoolL(iOptRecurse, KCmdLsOpRecurse);
+	}
+
+void CCmdLs::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdLsArg, "dir_name");
+	aArguments.AppendFileNameL(iFileName, KCmdLsArg);
+	}
+
+void CCmdLs::RecursiveScanDirL(const TDesC& aName)
+	{
+	TInt currentDirectoryLen = iFileName.Length();
+	iFileName.AppendComponentL(aName, TFileName2::EDirectory);
+	DoScanDirL();
+	iFileName.SetLength(currentDirectoryLen); // Since this is called recursively, restore iTempName to what it was previously
+	}
+
+void CCmdLs::DoScanDirL()
+	{
+	RDir dir;
+	User::LeaveIfError(dir.Open(FsL(), iFileName, iOptAll ? KEntryAttMaskSupported : KEntryAttNormal | KEntryAttDir));
+	CleanupClosePushL(dir);
+	iFileName.SetLength(TParsePtrC(iFileName).DriveAndPath().Length()); // Remove any possible wildcard or name from the end of iFileName before recursing
+	PrintDirContentL(dir);
+	CleanupStack::PopAndDestroy(&dir);
+	}
+
+//
+// CCmdCd.
+//
+
+CCommandBase* CCmdCd::NewLC()
+	{
+	CCmdCd* self = new(ELeave) CCmdCd();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdCd::~CCmdCd()
+	{
+	}
+
+CCmdCd::CCmdCd()
+	: iDir(TFileName2::EDirectory)
+	{
+	}
+
+const TDesC& CCmdCd::Name() const
+	{
+	_LIT(KCmdCdName, "cd");
+	return KCmdCdName;
+	}
+
+void CCmdCd::DoRunL()
+	{
+	if (iDir.IsDriveRoot()) // For some reason best known to the designers of F32, it's not possible to retrieve a TEntry object for the root of a drive (fails with KErrBadName).
+		{
+		TDriveList driveList;
+		LeaveIfErr(FsL().DriveList(driveList), _L("Couldn't get drive list"));
+		TInt driveNum = TChar(iDir[0]).GetUpperCase() - 'A';
+		if (driveNum >= KMaxDrives)
+			{
+			Complete(KErrArgument, _L("Invalid drive letter"));
+			return;
+			}
+		if (!driveList[driveNum])
+			{
+			Complete(KErrNotReady, _L("Drive not present"));
+			return;
+			}
+		}
+	else
+		{
+		LeaveIfFileNotFound(iDir);
+		if (!iDir.IsDirL(FsL()))
+			{
+			Complete(KErrBadName, _L("%S is not a directory"), &iDir);
+			return;
+			}
+		}
+
+	Env().SetPwdL(iDir);
+	}
+
+void CCmdCd::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdCdArg, "directory");
+	aArguments.AppendFileNameL(iDir, KCmdCdArg);
+	}
+
+
+//
+// CCmdClear.
+//
+
+CCommandBase* CCmdClear::NewLC()
+	{
+	CCmdClear* self = new(ELeave) CCmdClear();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdClear::~CCmdClear()
+	{
+	}
+
+CCmdClear::CCmdClear()
+	{
+	}
+
+const TDesC& CCmdClear::Name() const
+	{
+	_LIT(KCmdClearName, "clear");
+	return KCmdClearName;
+	}
+
+void CCmdClear::DoRunL()
+	{
+	if (iFormFeed)
+		{
+		TInt consoleHeight = Stdout().GetScreenSizeL().iHeight;
+		Stdout().SetCursorPosAbsL(TPoint(0, consoleHeight-1));
+		RBuf buf;
+		buf.CreateL(consoleHeight * 2);
+		while (consoleHeight--) buf.Append(KNewLine);
+		Stdout().Write(buf);
+		buf.Close();
+		Stdout().SetCursorPosAbsL(TPoint(0,0));
+		}
+	else
+		{
+		Stdout().ClearScreenL();
+		Stdin().SetMode(RIoReadWriteHandle::EText);
+		Stdout().SetMode(RIoReadWriteHandle::EText);
+		Stderr().SetMode(RIoReadWriteHandle::EText);
+		}
+	}
+
+void CCmdClear::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptFormFeed, "formfeed");
+	aOptions.AppendBoolL(iFormFeed, KOptFormFeed);
+	}
+
+//
+// CForegroundAdjuster
+//
+
+class CForegroundAdjuster : public CActive
+	{
+public:
+	static CForegroundAdjuster* NewL(CCommandBase& aCommand, TInt aJobId, TBool aToForeground);
+	~CForegroundAdjuster();
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+	virtual TInt RunError(TInt aError);
+private:
+	CForegroundAdjuster(CCommandBase& aCommand, TInt aJobId, TBool aToForeground);
+private:
+	CCommandBase& iCommand;
+	TInt iJobId;
+	TBool iToForeground;
+	};
+
+CForegroundAdjuster* CForegroundAdjuster::NewL(CCommandBase& aCommand, TInt aJobId, TBool aToForeground)
+	{
+	return new(ELeave) CForegroundAdjuster(aCommand, aJobId, aToForeground);
+	}
+
+void CForegroundAdjuster::RunL()
+	{
+	gShell->ClaimJobsLockLC();
+
+	if (iToForeground)
+		{
+		gShell->BringJobToForeground(iJobId);
+		}
+	else
+		{
+		gShell->SendJobToBackground(iJobId);
+		}
+
+	CleanupStack::PopAndDestroy(); // jobs lock.
+	iCommand.Complete();
+	}
+
+void CForegroundAdjuster::DoCancel()
+	{
+	}
+
+TInt CForegroundAdjuster::RunError(TInt aError)
+	{
+	iCommand.Complete(aError);
+	return KErrNone;
+	}
+
+CForegroundAdjuster::CForegroundAdjuster(CCommandBase& aCommand, TInt aJobId, TBool aToForeground)
+	: CActive(CActive::EPriorityStandard), iCommand(aCommand), iJobId(aJobId), iToForeground(aToForeground)
+	{
+	CActiveScheduler::Add(this);
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete(status, KErrNone);
+	SetActive();
+	}
+
+CForegroundAdjuster::~CForegroundAdjuster()
+	{
+	}
+
+
+//
+// CCmdFg.
+//
+
+void ParseJobSpecL(const TDesC& aString, TInt& aJobId)
+	{
+	TLex lex(aString);
+	lex.SkipSpace();
+	if (lex.Peek() == '%')
+		{
+		lex.Get();
+		}
+	User::LeaveIfError(lex.Val(aJobId));
+	}
+
+CCommandBase* CCmdFg::NewLC()
+	{
+	CCmdFg* self = new(ELeave) CCmdFg();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdFg::~CCmdFg()
+	{
+	delete iJobSpec;
+	delete iForegroundAdjuster;
+	}
+
+CCmdFg::CCmdFg() : CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdFg::Name() const
+	{
+	_LIT(KCmdFgName, "fg");
+	return KCmdFgName;
+	}
+
+void CCmdFg::DoRunL()
+	{
+	TInt jobId = -1;
+	if (iJobSpec)
+		{
+		ParseJobSpecL(*iJobSpec, jobId);
+		}
+	else
+		{
+		gShell->ClaimJobsLockLC();
+		const RPointerArray<CJob>& jobs = gShell->Jobs();
+		const TInt numJobs = jobs.Count();
+		if (numJobs >= 2)
+			{
+			jobId = jobs[numJobs - 2]->Id(); // Note, the most recent job (jobs[numJobs - 1]) will be this command.
+			}
+		CleanupStack::PopAndDestroy(); // jobs lock.
+		}
+	if (jobId >= 0)
+		{
+		iForegroundAdjuster = CForegroundAdjuster::NewL(*this, jobId, ETrue);
+		}
+	else
+		{
+		Complete();
+		}
+	}
+
+void CCmdFg::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdFgArg, "job_spec");
+	aArguments.AppendStringL(iJobSpec, KCmdFgArg);
+	}
+
+
+//
+// CCmdBg.
+//
+
+CCommandBase* CCmdBg::NewLC()
+	{
+	CCmdBg* self = new(ELeave) CCmdBg();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdBg::~CCmdBg()
+	{
+	delete iJobSpec;
+	delete iForegroundAdjuster;
+	}
+
+CCmdBg::CCmdBg() : CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdBg::Name() const
+	{
+	_LIT(KCmdBgName, "bg");
+	return KCmdBgName;
+	}
+
+void CCmdBg::DoRunL()
+	{
+	TInt jobId = -1;
+	if (iJobSpec)
+		{
+		ParseJobSpecL(*iJobSpec, jobId);
+		}
+	else
+		{
+		gShell->ClaimJobsLockLC();
+		const RPointerArray<CJob>& jobs = gShell->Jobs();
+		const TInt numJobs = jobs.Count();
+		if (numJobs >= 2)
+			{
+			jobId = jobs[numJobs - 2]->Id(); // Note, the most recent job (jobs[numJobs - 1]) will be this command.
+			}
+		CleanupStack::PopAndDestroy(); // jobs lock.
+		}
+	if (jobId >= 0)
+		{
+		iForegroundAdjuster = CForegroundAdjuster::NewL(*this, jobId, EFalse);
+		}
+	}
+
+void CCmdBg::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdBgArg, "job_spec");
+	aArguments.AppendStringL(iJobSpec, KCmdBgArg);
+	}
+
+
+//
+// CCmdJobs.
+//
+
+CCommandBase* CCmdJobs::NewLC()
+	{
+	CCmdJobs* self = new(ELeave) CCmdJobs();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdJobs::~CCmdJobs()
+	{
+	delete iFormatter;
+	}
+
+CCmdJobs::CCmdJobs() : CCommandBase(ECompleteOnRunL)
+	{
+	}
+
+const TDesC& CCmdJobs::Name() const
+	{
+	_LIT(KCmgJobsName, "jobs");
+	return KCmgJobsName;
+	}
+
+void CCmdJobs::DoRunL()
+	{
+	iFormatter = CTextFormatter::NewL(Stdout());
+	gShell->ClaimJobsLockLC();
+	const RPointerArray<CJob>& jobs = gShell->Jobs();
+	const TInt numJobs = (jobs.Count() - 1);
+	if (numJobs > 0)
+		{
+		IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x100);
+		for (TInt i = 0; i < numJobs; ++i)
+			{
+			const CJob& job = *(jobs[i]);
+			buf->AppendFormatL(_L("[%d]\t%S\t%S\r\n"), job.Id(), ShStringify::JobStatus(job.Status()), job.Name());
+			}
+		iFormatter->TabulateL(0, 2, buf->Descriptor());
+		CleanupStack::PopAndDestroy(2); // buf, jobs lock.
+		Stdout().Write(iFormatter->Descriptor(), iStatus);
+		SetActive();
+		}
+	else
+		{
+		CleanupStack::PopAndDestroy(); // jobs lock.
+		Complete();
+		}
+	}
+
+
+//
+// CCmdRm.
+//
+
+CCommandBase* CCmdRm::NewLC()
+	{
+	CCmdRm* self = new(ELeave) CCmdRm();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRm::~CCmdRm()
+	{
+	delete iFileMan;
+	iFileNames.Close();
+	}
+
+CCmdRm::CCmdRm()
+	{
+	}
+
+const TDesC& CCmdRm::Name() const
+	{
+	_LIT(KCmdRmName, "rm");
+	return KCmdRmName;
+	}
+
+void CCmdRm::DoRunL()
+	{
+	iFileMan = CFileMan::NewL(FsL());
+
+	const TInt numFiles = iFileNames.Count();
+	for (TInt i = 0; i < numFiles; ++i)
+		{
+		TFileName2& fileName = iFileNames[i];
+		LeaveIfFileNotFound(fileName);
+		if (iRecurse)
+			{
+			if (fileName.IsDirL(FsL()))
+				{
+				fileName.SetTypeL(TFileName2::EDirectory);
+				}
+			else
+				{
+				PrintError(KErrArgument, _L("Invalid use of \"-r\" option - \"%S\" is not a directory."), &fileName);
+				User::Leave(KErrArgument);
+				}
+			}
+		else if (fileName.IsDirL(FsL()))
+			{
+			PrintError(KErrArgument, _L("Couldn't remove \"%S\" because it is a directory - use \"rm -r\" or \"rmdir\" instead."), &fileName);
+			User::Leave(KErrArgument);
+			}
+
+		TInt err = DoDelete(fileName);
+		if (err == KErrAccessDenied && iForce)
+			{
+			// Try removing read-only attribute from file and try again
+			err = Fs().SetAtt(fileName, 0, KEntryAttReadOnly);
+			if (!err)
+				{
+				iForce = EFalse; // Otherwise we'll end up here again (could happen if iFileName is a directory and cannot be deleted because it contains read-only files
+				err = DoDelete(fileName);
+				}
+			}
+		User::LeaveIfError(err);
+		}
+	}
+
+TInt CCmdRm::DoDelete(const TDesC& aFileName)
+	{
+	TInt err;
+	if (iRecurse)
+		{
+		err = iFileMan->RmDir(aFileName);
+		}
+	else
+		{
+		err = iFileMan->Delete(aFileName);
+		}
+	return err;
+	}
+
+void CCmdRm::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdRmOptRecurse, "recurse");
+	_LIT(KCmdRmOptForce, "force");
+	aOptions.AppendBoolL(iRecurse, KCmdRmOptRecurse);
+	aOptions.AppendBoolL(iForce, KCmdRmOptForce);
+	}
+
+void CCmdRm::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdRmArg, "file_name");
+	aArguments.AppendFileNameL(iFileNames, KCmdRmArg);
+	}
+
+
+//
+// CCmdCp.
+//
+
+CCommandBase* CCmdCp::NewLC()
+	{
+	CCmdCp* self = new(ELeave) CCmdCp();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdCp::~CCmdCp()
+	{
+	delete iFileMan;
+	}
+
+CCmdCp::CCmdCp()
+	{
+	}
+
+const TDesC& CCmdCp::Name() const
+	{
+	_LIT(KCmdCpName, "cp");
+	return KCmdCpName;
+	}
+
+void CCmdCp::ForciblyCopyFileL(const TDesC& aSourceFileName, const TDesC& aDestFileName)
+	{
+	RFs& fs = FsL();
+	TInt err = fs.MkDirAll(aDestFileName);
+	if (err != KErrNone && err != KErrAlreadyExists)
+		{
+		User::Leave(err);
+		}
+	TInt numRetries = 3;
+retry:
+	TEntry startEntry;
+	User::LeaveIfError(fs.Entry(aSourceFileName, startEntry));
+	RFile destFile;
+	if (iOverwrite)
+		{
+		User::LeaveIfError(destFile.Replace(fs, aDestFileName, EFileShareExclusive | EFileStream | EFileWrite));
+		}
+	else
+		{
+		User::LeaveIfError(destFile.Create(fs, aDestFileName, EFileShareExclusive | EFileStream | EFileWrite));
+		}
+	CleanupClosePushL(destFile);
+
+	HBufC8* blockBuf = HBufC8::NewLC(KBlockSize);
+	TPtr8 blockPtr(blockBuf->Des());
+	TInt pos = 0;
+	while (pos < startEntry.iSize)
+		{
+		User::LeaveIfError(fs.ReadFileSection(aSourceFileName, pos, blockPtr, KBlockSize));
+		if (blockPtr.Length() == 0)
+			{
+			Printf(_L("\r\nReadFileSection returned zero length descriptor, aborting\r\n"));
+			pos = startEntry.iSize;
+			}
+		else
+			{
+			pos += blockPtr.Length();
+			User::LeaveIfError(destFile.Write(*blockBuf));
+			}
+		}
+	Printf(KNewLine);
+
+	CleanupStack::PopAndDestroy(2, &destFile); // blockBuf, destFile.
+
+	TEntry endEntry;
+	User::LeaveIfError(fs.Entry(aSourceFileName, endEntry));
+	if (startEntry.iModified != endEntry.iModified)
+		{
+		--numRetries;
+		if (numRetries > 0)
+			{
+			Printf(_L("Modification while copying - retrying...\r\n"));
+			fs.Delete(aDestFileName);	// Ignore error.
+			goto retry;
+			}
+		else
+			{
+			Printf(_L("Modification while copying - failed 3 times, aborting...\r\n"));
+			}
+		}
+	}
+
+void CCmdCp::DoRunL()
+	{
+	if (iRecurse && iForce)
+		{
+		PrintWarning(_L("--recurse and --force options can't be used together"));
+		User::Leave(KErrArgument);
+		}
+
+	if (iForce)
+		{
+		ForciblyCopyFileL(iFrom, iTo);
+		}
+	else
+		{
+		iFileMan = CFileMan::NewL(FsL());
+		TUint flags = 0;
+		if (iRecurse) flags |= CFileMan::ERecurse;
+		if (iOverwrite) flags |= CFileMan::EOverWrite;
+
+		if (iRecurse && iFrom.Exists(FsL()) && iFrom.IsDirL(FsL()))
+			{
+			// CFileMan behaves markedly differently to standard posix cp, in the case of copying a directory.
+			// POSIX cp does different things depending on whether the destination exists or not:
+			// 1) "cp -r dirname existingdir" will produce the tree "./existingdir/dirname/<files>"
+			// 2) "cp -r dirname nonexistingdir" will produce the tree "./nonexistingdir/<files>"
+			//
+			// CFileMan differs in case (1) and puts the contents of dirname straight into the destination dir.
+			// Therefore to behave sensibly like posix cp in case (1) we add the source name to the destination
+			if (iTo.Exists(FsL()))
+				{
+				iTo.AppendComponentL(iFrom.Name(), TFileName2::EDirectory);
+				}
+			}
+		User::LeaveIfError(iFileMan->Copy(iFrom, iTo, flags));
+		}
+	}
+
+void CCmdCp::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdCpOptRecurse, "recurse");
+	_LIT(KCmdCpOptOverwrite, "overwrite");
+	_LIT(KCmdCpOptForce, "force");
+	aOptions.AppendBoolL(iRecurse, KCmdCpOptRecurse);
+	aOptions.AppendBoolL(iOverwrite, KCmdCpOptOverwrite);
+	aOptions.AppendBoolL(iForce, KCmdCpOptForce);
+	}
+
+void CCmdCp::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdCpArg1, "source");
+	_LIT(KCmdCpArg2, "destination");
+	aArguments.AppendFileNameL(iFrom, KCmdCpArg1);
+	aArguments.AppendFileNameL(iTo, KCmdCpArg2);
+	}
+
+
+//
+// CCmdMv.
+//
+
+CCommandBase* CCmdMv::NewLC()
+	{
+	CCmdMv* self = new(ELeave) CCmdMv();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdMv::~CCmdMv()
+	{
+	delete iFileMan;
+	}
+
+CCmdMv::CCmdMv()
+	{
+	}
+
+const TDesC& CCmdMv::Name() const
+	{
+	_LIT(KCmdMvName, "mv");
+	return KCmdMvName;
+	}
+
+void CCmdMv::DoRunL()
+	{
+	if (iTo.Exists(FsL()) && iTo.IsDirL(FsL()))
+		{
+		iTo.SetTypeL(TFileName2::EDirectory);
+		}
+	iFileMan = CFileMan::NewL(FsL());
+	User::LeaveIfError(iFileMan->Move(iFrom, iTo, 0));
+	}
+
+void CCmdMv::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdMvArg1, "source_file");
+	_LIT(KCmdMvArg2, "destination_file");
+	aArguments.AppendFileNameL(iFrom, KCmdMvArg1);
+	aArguments.AppendFileNameL(iTo, KCmdMvArg2);
+	}
+
+
+//
+// CCmdMkDir.
+//
+
+CCommandBase* CCmdMkDir::NewLC()
+	{
+	CCmdMkDir* self = new(ELeave) CCmdMkDir();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdMkDir::~CCmdMkDir()
+	{
+	}
+
+CCmdMkDir::CCmdMkDir()
+	: iDir(TFileName2::EDirectory)
+	{
+	}
+
+const TDesC& CCmdMkDir::Name() const
+	{
+	_LIT(KCmdMkDirName, "mkdir");
+	return KCmdMkDirName;
+	}
+
+void CCmdMkDir::DoRunL()
+	{
+	TInt err = FsL().MkDirAll(iDir);
+	if (iAllowExists && (err == KErrAlreadyExists))
+		{
+		err = KErrNone;
+		}
+	User::LeaveIfError(err);
+	}
+
+void CCmdMkDir::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdMkDirOptAllowExists, "allow_exists");
+	aOptions.AppendBoolL(iAllowExists, KCmdMkDirOptAllowExists);
+	}
+
+void CCmdMkDir::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdMkDirArg, "dir_name");
+	aArguments.AppendFileNameL(iDir, KCmdMkDirArg);
+	}
+
+
+//
+// CCmdRmDir.
+//
+
+CCommandBase* CCmdRmDir::NewLC()
+	{
+	CCmdRmDir* self = new(ELeave) CCmdRmDir();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRmDir::~CCmdRmDir()
+	{
+	delete iFileMan;
+	iDirs.Close();
+	}
+
+CCmdRmDir::CCmdRmDir()
+	{
+	}
+
+const TDesC& CCmdRmDir::Name() const
+	{
+	_LIT(KCmdRmDirName, "rmdir");
+	return KCmdRmDirName;
+	}
+
+void CCmdRmDir::DoRunL()
+	{
+	const TInt numDirs = iDirs.Count();
+	for (TInt i = 0; i < numDirs; ++i)
+		{
+		TFileName2& dir = iDirs[i];
+		if (dir.IsDirL(FsL()))
+			{
+			dir.SetTypeL(TFileName2::EDirectory);
+			}
+		else
+			{
+			PrintError(KErrArgument, _L("\"%S\" is not a directory."), &dir);
+			User::Leave(KErrArgument);
+			}
+
+		LeaveIfFileNotFound(dir);
+	
+		if (iRecurse)
+			{
+			if (iFileMan == NULL)
+				{
+				iFileMan = CFileMan::NewL(FsL());
+				}
+			User::LeaveIfError(iFileMan->RmDir(dir));
+			}
+		else
+			{
+			User::LeaveIfError(FsL().RmDir(dir));
+			}
+		}
+	}
+
+void CCmdRmDir::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdRmDirOptRecurse, "recurse");
+	aOptions.AppendBoolL(iRecurse, KCmdRmDirOptRecurse);
+	}
+
+void CCmdRmDir::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdRmDirArg, "dir_name");
+	aArguments.AppendFileNameL(iDirs, KCmdRmDirArg);
+	}
+
+
+//
+// CCmdMatch.
+//
+
+CCommandBase* CCmdMatch::NewLC()
+	{
+	CCmdMatch* self = new(ELeave) CCmdMatch();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdMatch::~CCmdMatch()
+	{
+	delete iToMatch;
+	}
+
+CCmdMatch::CCmdMatch()
+	{
+	}
+
+const TDesC& CCmdMatch::Name() const
+	{
+	_LIT(KCmdMatchName, "match");
+	return KCmdMatchName;
+	}
+
+void CCmdMatch::DoRunL()
+	{
+	Stdin().SetReadMode(RIoReadHandle::ELine);
+	TBuf<0x100> line;
+	TInt count = 0;
+	while (Stdin().Read(line) == KErrNone)
+		{
+		TBool matches;
+		if (iIgnoreCase)
+			{
+			matches = (line.MatchF(*iToMatch) != KErrNotFound);
+			}
+		else
+			{
+			matches = (line.Match(*iToMatch) != KErrNotFound);
+			}
+		if (iInvertMatch)
+			{
+			matches = !matches;
+			}
+		if (matches)
+			{
+			if (iCount)
+				{
+				count++;
+				}
+			else
+				{
+				Write(line);
+				}
+			}
+		}
+
+	if (iCount)
+		{
+		Printf(_L("Count = %d"), count);
+		}
+	}
+
+void CCmdMatch::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdMatchOptIgnoreCase, "ignore-case");
+	_LIT(KCmdMatchOptInvertMatch, "invert-match");
+	_LIT(KCmdMatchOptCount, "count");
+	aOptions.AppendBoolL(iIgnoreCase, KCmdMatchOptIgnoreCase);
+	aOptions.AppendBoolL(iInvertMatch, KCmdMatchOptInvertMatch);
+	aOptions.AppendBoolL(iCount, KCmdMatchOptCount);
+	}
+
+void CCmdMatch::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdMatchArg1, "pattern");
+	aArguments.AppendStringL(iToMatch, KCmdMatchArg1);
+	}
+
+
+//
+// CCmdEcho.
+//
+
+CCommandBase* CCmdEcho::NewLC()
+	{
+	CCmdEcho* self = new(ELeave) CCmdEcho();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdEcho::~CCmdEcho()
+	{
+	delete iToEcho;
+	iAttributes.Close();
+	}
+
+CCmdEcho::CCmdEcho()
+	: iForegroundColor(ConsoleAttributes::EUnchanged), iBackgroundColor(ConsoleAttributes::EUnchanged)
+	{
+	}
+
+void CCmdEcho::DoWriteL(const TDesC& aDes)
+	{
+	if (iToStderr)
+		{
+		Stderr().Write(aDes);
+		}
+	else
+		{
+		Stdout().Write(aDes);
+		}
+	}
+
+const TDesC& CCmdEcho::Name() const
+	{
+	_LIT(KCmdEchoName, "echo");
+	return KCmdEchoName;
+	}
+
+void CCmdEcho::DoRunL()
+	{
+	RIoConsoleWriteHandle& out = iToStderr ? Stderr() : Stdout();
+
+	if (iBinaryMode)
+		{
+		LeaveIfErr(out.SetMode(RIoReadWriteHandle::EBinary), _L("Unable to set write handle to binary mode"));
+		}
+	
+	CTextFormatter* formatter = CTextFormatter::NewLC(out);
+
+	TUint attributes = 0;
+	const TInt numAttributes = iAttributes.Count();
+	for (TInt i = 0; i < numAttributes; ++i)
+		{
+		switch ((TAttr)iAttributes[i])
+			{
+			case EBold:
+				attributes |= ConsoleAttributes::EBold;
+				break;
+			case EUnderscore:
+				attributes |= ConsoleAttributes::EUnderscore;
+				break;
+			case EBlink:
+				attributes |= ConsoleAttributes::EBlink;
+				break;
+			case EInverse:
+				attributes |= ConsoleAttributes::EInverse;
+				break;
+			case EConceal:
+				attributes |= ConsoleAttributes::EConceal;
+				break;
+			}
+		}
+
+	formatter->SetAttributesL(attributes, iForegroundColor, iBackgroundColor);
+
+	if (iToEcho)
+		{
+		if (iWrap) 
+			{
+			formatter->WrapL(iIndent, *iToEcho);
+			}
+		else
+			{
+			formatter->AppendL(*iToEcho);
+			}
+		// Add a newline if it doesn't already end in one (and --no-newline isn't specified)
+		if (!iNoNewline && iToEcho->Right(KNewLine().Length()) != KNewLine)
+			{
+			formatter->AppendL(KNewLine);
+			}
+		}
+	else
+		{
+		TBuf<0x100> buf;
+		TInt err = KErrNone;
+		do
+			{
+			err = Stdin().Read(buf);
+			if (err == KErrNone)
+				{
+				if (iWrap) 
+					{
+					formatter->WrapL(iIndent, buf);
+					}
+				else
+					{
+					formatter->AppendL(buf);
+					}
+				}
+			}
+			while (err == KErrNone);
+		}
+
+	formatter->Write();
+	CleanupStack::PopAndDestroy(formatter);
+	}
+
+void CCmdEcho::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdEchoOptToStderr, "stderr");
+	_LIT(KCmdEchoOptWrap, "wrap");
+	_LIT(KCmdEchoOptIndent, "indent");
+	_LIT(KCmdEchoOptAttributes, "attributes");
+	_LIT(KCmdEchoOptForground, "foreground-color");
+	_LIT(KCmdEchoOptBackground, "background-color");
+	_LIT(KCmdEchoOptBinaryMode, "binary");
+	_LIT(KCmdEchoOptNoNewline, "no-newline");
+
+	aOptions.AppendBoolL(iToStderr, KCmdEchoOptToStderr);
+	aOptions.AppendBoolL(iWrap, KCmdEchoOptWrap);
+	aOptions.AppendUintL(iIndent, KCmdEchoOptIndent);
+	aOptions.AppendEnumL(iAttributes, KCmdEchoOptAttributes);
+	aOptions.AppendEnumL((TInt&)iForegroundColor, KCmdEchoOptForground);
+	aOptions.AppendEnumL((TInt&)iBackgroundColor, KCmdEchoOptBackground);
+	aOptions.AppendBoolL(iBinaryMode, KCmdEchoOptBinaryMode);
+	aOptions.AppendBoolL(iNoNewline, KCmdEchoOptNoNewline);
+	}
+
+void CCmdEcho::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdEchoArg1, "string");
+	aArguments.AppendStringL(iToEcho, KCmdEchoArg1);
+	}
+
+
+//
+// CCmdMore.
+//
+
+CCommandBase* CCmdMore::NewLC()
+	{
+	CCmdMore* self = new(ELeave) CCmdMore();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdMore::~CCmdMore()
+	{
+	}
+
+CCmdMore::CCmdMore()
+	{
+	}
+
+const TDesC& CCmdMore::Name() const
+	{
+	_LIT(KCmdMoreName, "more");
+	return KCmdMoreName;
+	}
+	
+void CCmdMore::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KMoreArg1, "file_name");
+	aArguments.AppendFileNameL(iFile, KMoreArg1);
+	}
+
+void CCmdMore::DoRunL()
+	{
+	RIoReadHandle input;
+	input.CreateL(IoSession());
+	CleanupClosePushL(input);
+
+	RIoFile file;
+	CleanupClosePushL(file);
+
+	if (iArguments.IsPresent(0))
+		{
+		file.CreateL(IoSession(), iFile, RIoFile::ERead);
+		IoSession().SetObjectNameL(file.SubSessionHandle(), iFile);
+		_LIT(KReaderSuffix, "_more_reader");
+		iFile.SetLength(Min(iFile.Length(), iFile.MaxLength() - KReaderSuffix().Length()));
+		iFile.Append(KReaderSuffix);
+		IoSession().SetObjectNameL(input.SubSessionHandle(), iFile);
+		file.AttachL(input, RIoEndPoint::EForeground);
+		}
+	else
+		{
+		input.DuplicateL(Stdin());
+		input.SetToForegroundL();
+		}
+
+	PageL(input);
+	
+	CleanupStack::PopAndDestroy(2, &input);
+	}
+
+
+//
+// CCmdTrace.
+//
+
+CCommandBase* CCmdTrace::NewLC()
+	{
+	CCmdTrace* self = new(ELeave) CCmdTrace();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTrace::~CCmdTrace()
+	{
+	iEnable.ResetAndDestroy();
+	iDisable.ResetAndDestroy();
+	}
+
+CCmdTrace::CCmdTrace()
+	{
+	}
+
+const TDesC& CCmdTrace::Name() const
+	{
+	_LIT(KCmdTraceName, "trace");
+	return KCmdTraceName;
+	}
+
+const LtkUtils::SLitC8 KTraceBitNames[] =
+	{
+	DESC8("khardware"),
+	DESC8("kboot"),
+	DESC8("kserver"),
+	DESC8("kmmu"),
+	DESC8("ksemaphore"),
+	DESC8("ksched"),
+	DESC8("kproc"),
+	DESC8("kexec"),
+	DESC8("kdebugger"),
+	DESC8("kthread"),
+	DESC8("kdll"),
+	DESC8("kipc"),
+	DESC8("kpbus1"),
+	DESC8("kpbus"),
+	DESC8("kpbusdrv"),
+	DESC8("kpower"),
+	DESC8("ktiming"),
+	DESC8("kevent"),
+	DESC8("kobject"),
+	DESC8("kdfc"),
+	DESC8("kextension"),
+	DESC8("ksched2"),
+	DESC8("klocdrv"),
+	DESC8("kfail"),
+	DESC8("kthread2"),
+	DESC8("kdevice"),
+	DESC8("kmemtrace"),
+	DESC8("kdma"),
+	DESC8("kmmu2"),
+	DESC8("knkern"),
+	DESC8("kscratch"),
+	DESC8("kpanic"),
+	// Word 1
+	DESC8("kusb"),
+	DESC8("kusbpsl"),
+	DESC8("knetwork1"),
+	DESC8("knetwork2"),
+	DESC8("ksound1"),
+	DESC8("kusbhost"),
+	DESC8("kusbotg"),
+	DESC8("kusbjournal"),
+	DESC8("kusbho"),
+	DESC8("kresmanager"),
+	DESC8("kiic"),
+	DESC8("khcr"),
+	DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""),
+	DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""),
+	DESC8("kpipe"),
+	DESC8("kpci"),
+	DESC8("kdatapagewarn"),
+	DESC8("klocdpaging"),
+	DESC8("kpaging"),
+	DESC8("krealtime"),
+	// Word 2
+	DESC8("kallthreadssystem"),
+	DESC8("ktestfast"),
+	DESC8("ktestlatency"),
+	DESC8("kdebugmonitordisable"),
+	DESC8("kcrashmonitordisable"),
+	DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""),
+	DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""),
+	DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""), DESC8(""),
+	DESC8(""), DESC8(""), DESC8(""),
+	// Word 3
+	DESC8("kuserheaptrace"),
+	};
+const TInt KTraceBitCount = sizeof(KTraceBitNames) / sizeof(LtkUtils::SLitC);
+
+#ifndef KCOMPFS // Not defined on 9.1
+#define	KCOMPFS		0x0400
+#endif
+
+void CCmdTrace::DoRunL()
+	{
+	TInt debugVal = 0;
+	if (iOptF32)
+		debugVal|=KFSERV;
+	if (iOptLoader)
+		debugVal|=KFLDR;
+	if (iOptFat)
+		debugVal|=KFSYS;
+	if (iOptLffs)
+		debugVal|=KLFFS;
+#ifdef EKA2
+	if (iOptIso9660)
+		debugVal|=KISO9660;
+	if (iOptNtfs)
+		debugVal|=KNTFS;
+	if (iOptMultiThread)
+		debugVal|=KTHRD;
+	if (iOptRofs)
+		debugVal|=KROFS;
+	if (iOptCompfs)
+		debugVal|=KCOMPFS;
+#endif
+	TInt err = FsL().SetDebugRegister(debugVal);
+	if (err && debugVal != 0)
+		{
+		// Don't bother printing a warning if none of the FS-related options were actually specified
+		PrintWarning(_L("Unable to configure file server traces: %d"), err);
+		}
+	
+	if (iArguments.IsPresent(0))
+		{
+#ifdef EKA2
+		User::SetDebugMask(iMask, iIndex);
+#else
+		User::SetDebugMask(iMask);
+#endif
+		}
+	else if (debugVal == 0)
+		{
+		if (iEnable.Count() || iDisable.Count())
+			{
+			for (TInt i = 0; i < iEnable.Count(); i++)
+				{
+				TInt err = SetFlag(*iEnable[i], ETrue);
+				if (err) PrintWarning(_L("Flag '%S' not understood"), iEnable[i]);
+				}
+			for (TInt i = 0; i < iDisable.Count(); i++)
+				{
+				TInt err = SetFlag(*iDisable[i], EFalse);
+				if (err) PrintWarning(_L("Flag '%S' not understood"), iEnable[i]);
+				}
+			}
+		else
+			{
+			PrintConfig();
+			}
+		}
+	}
+
+void CCmdTrace::PrintConfig()
+	{
+#ifdef EKA2
+	for (TInt i = 0; i < 8; ++i)
+		{
+		TBool seen = EFalse;
+		TUint32 mask = UserSvr::DebugMask(i);
+		Printf(_L("DebugMask(%d) = 0x%08X"), i, mask);
+		for (TInt bit = 0; bit < 32; bit++)
+			{
+			if (mask & (1 << bit))
+				{
+				if (seen)
+					{
+					Write(_L("|"));
+					}
+				else
+					{
+					Write(_L(" ("));
+					}
+				seen = ETrue;
+				TInt idx = i*32 + bit;
+				if (idx < KTraceBitCount && KTraceBitNames[idx]().Length())
+					{
+					Printf(KTraceBitNames[idx]());
+					}
+				else
+					{
+					Write(_L("?"));
+					}
+				}
+			}
+		if (seen) Write(_L(")"));
+		Write(KNewLine);
+		}
+#else
+	Printf(_L("DebugMask = 0x%08X\r\n"), UserSvr::DebugMask());
+#endif
+	}
+
+TInt CCmdTrace::SetFlag(const TDesC& aFlagName, TBool aSet)
+	{
+	// Find aFlagName in KTraceBitNames
+	TBuf8<64> flagname;
+	for (TInt i = 0; i < KTraceBitCount; i++)
+		{
+		flagname.Copy(aFlagName);
+		flagname.LowerCase();
+		if (flagname.Compare(KTraceBitNames[i]) == 0)
+			{
+			TInt word = i / 32;
+			TInt idx = i % 32;
+			TUint32 mask = UserSvr::DebugMask(word);
+			if (aSet)
+				{
+				mask |= 1 << idx;
+				}
+			else
+				{
+				mask &= ~(1 << idx);
+				}
+			User::SetDebugMask(mask, word);
+			return KErrNone;
+			}
+		}
+	return KErrNotFound;
+	}
+
+void CCmdTrace::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdTraceOptS, "f32");
+	_LIT(KCmdTraceOptM, "multi-thread");
+	_LIT(KCmdTraceOptL, "loader");
+	_LIT(KCmdTraceOptF, "fat");
+	_LIT(KCmdTraceOptT, "lffs");
+	_LIT(KCmdTraceOptI, "iso9660");
+	_LIT(KCmdTraceOptN, "ntfs");
+	_LIT(KCmdTraceOptO, "rofs");
+	_LIT(KCmdTraceOptC, "compfs");
+
+	aOptions.AppendBoolL(iOptF32, KCmdTraceOptS);
+	aOptions.AppendBoolL(iOptMultiThread, KCmdTraceOptM);
+	aOptions.AppendBoolL(iOptLoader, KCmdTraceOptL);
+	aOptions.AppendBoolL(iOptFat, KCmdTraceOptF);
+	aOptions.AppendBoolL(iOptLffs, KCmdTraceOptT);
+#ifdef EKA2
+	aOptions.AppendBoolL(iOptIso9660, KCmdTraceOptI);
+	aOptions.AppendBoolL(iOptNtfs, KCmdTraceOptN);
+	aOptions.AppendBoolL(iOptRofs, KCmdTraceOptO);
+	aOptions.AppendBoolL(iOptCompfs, KCmdTraceOptC);
+#endif
+
+	_LIT(KEnable, "enable");
+	aOptions.AppendStringL(iEnable, KEnable);
+	_LIT(KDisable, "disable");
+	aOptions.AppendStringL(iDisable, KDisable);
+	}
+
+void CCmdTrace::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdTraceArg1, "debug_mask");
+	aArguments.AppendUintL(iMask, KCmdTraceArg1);
+#ifdef EKA2
+	_LIT(KCmdTraceArg2, "index");
+	aArguments.AppendUintL(iIndex, KCmdTraceArg2);
+#endif
+	}
+
+
+//
+// CCmdMemInfo.
+//
+
+CCommandBase* CCmdMemInfo::NewLC()
+	{
+	CCmdMemInfo* self = new(ELeave) CCmdMemInfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdMemInfo::~CCmdMemInfo()
+	{
+	}
+
+CCmdMemInfo::CCmdMemInfo()
+	{
+	}
+
+const TDesC& CCmdMemInfo::Name() const
+	{
+	_LIT(KCmdMemInfoName, "meminfo");
+	return KCmdMemInfoName;
+	}
+
+void CCmdMemInfo::AppendLineL(CTextFormatter& aFormatter, const TDesC& aCaption, HALData::TAttribute aHalAttribute, TBool aNewLine)
+	{
+	TInt value;
+	TInt err = HAL::Get(aHalAttribute, value);
+	if (err)
+		{
+		PrintWarning(_L("Unable to read %S%d"), &aCaption, err);
+		}
+	else
+		{
+		if ((aHalAttribute != HALData::EMemoryRAMFree) || ((aHalAttribute == HALData::EMemoryRAMFree) && (value != iLastTotalRamUsage)))
+			{
+			aFormatter.AppendL(aCaption);
+			if (iHumanReadable)
+				{
+				aFormatter.AppendHumanReadableSizeL(value, EColumnAlignedRight);
+				}
+			else
+				{
+				aFormatter.AppendFormatL(_L("%d"), value);
+				}
+			if (aNewLine)
+				{
+				aFormatter.AppendL(KNewLine);
+				}
+			}
+		if (aHalAttribute == HALData::EMemoryRAMFree)
+			{
+			iLastTotalRamUsage = value;
+			}
+		}
+	}
+
+void CCmdMemInfo::DoRunL()
+	{
+	if (iOnlyFreeRam && iOnlyTotalRam)
+		{
+		LeaveIfErr(KErrArgument, _L("Mutually exclusive options"));
+		}
+	CTextFormatter* formatter = CTextFormatter::NewLC(Stdout());
+	if (iOnlyFreeRam)
+		{
+		AppendLineL(*formatter, KNullDesC, HALData::EMemoryRAMFree, EFalse);
+		}
+	else if (iOnlyTotalRam)
+		{
+		AppendLineL(*formatter, KNullDesC, HALData::EMemoryRAM, EFalse);
+		}
+	else
+		{
+		AppendLineL(*formatter, _L("Total ROM: "), HALData::EMemoryROM, ETrue);
+		AppendLineL(*formatter, _L("Total RAM: "), HALData::EMemoryRAM, ETrue);
+		AppendLineL(*formatter, _L("Page size: "), HALData::EMemoryPageSize, ETrue);
+		AppendLineL(*formatter, _L("Free RAM:  "), HALData::EMemoryRAMFree, EFalse);
+		}
+
+	Write(formatter->Descriptor());
+	if (iUpdateRate)
+		{
+		if (Stdout().AttachedToConsole())
+			{
+			RIoConsoleWriteHandle stdout = Stdout();
+			stdout.SetCursorHeight(0);
+			}
+		FOREVER
+			{
+			User::After(iUpdateRate * 1000);
+			formatter->Zero();
+			AppendLineL(*formatter, _L("\rFree RAM:  "), HALData::EMemoryRAMFree, EFalse);
+			Write(formatter->Descriptor());
+			}
+		}
+	CleanupStack::PopAndDestroy(formatter);
+	}
+
+void CCmdMemInfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdMemInfoOptUpdateRate, "rate");
+	_LIT(KCmdMemInfoOptHuman, "human");
+	_LIT(KCmdMemInfoOptOnlyFreeRam, "free");
+	_LIT(KCmdMemInfoOptOnlyTotalRam, "total");
+
+	aOptions.AppendBoolL(iHumanReadable, KCmdMemInfoOptHuman);
+	aOptions.AppendUintL(iUpdateRate, KCmdMemInfoOptUpdateRate);
+	aOptions.AppendBoolL(iOnlyFreeRam, KCmdMemInfoOptOnlyFreeRam);
+	aOptions.AppendBoolL(iOnlyTotalRam, KCmdMemInfoOptOnlyTotalRam);
+	}
+
+
+//
+// CCmdDump.
+//
+
+void Dump(const TDesC8& aData, CCommandBase& aCommand, TInt& aPos)
+	{
+	TBuf<80> out;
+	TBuf<16> ascii;
+	TInt dataIndex = 0;
+	do
+		{
+		out.Zero();
+		ascii.Zero();
+		out.AppendNumFixedWidthUC(aPos, EHex, 8);
+		out.Append(_L(": "));
+		for (TInt i = 0; i < 16; ++i)
+			{
+			if (dataIndex < aData.Length())
+				{
+				TUint8 byte = aData[dataIndex++];
+				out.AppendNumFixedWidthUC(byte, EHex, 2);
+				out.Append(_L(" "));
+				if ((byte < 0x20) || (byte >= 0x7f) || byte == '%')
+					{
+					byte = '.';
+					}
+				ascii.Append(TChar(byte));
+				++aPos;
+				}
+			else
+				{
+				out.Append(_L("   "));
+				aPos = 0;
+				}
+			}
+		out.Append(ascii);
+		out.Append(KNewLine);
+		aCommand.Write(out);
+		}
+		while (dataIndex < aData.Length());
+	}
+
+CCommandBase* CCmdDump::NewLC()
+	{
+	CCmdDump* self = new(ELeave) CCmdDump();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdDump::~CCmdDump()
+	{
+	iFileNames.Close();
+	}
+
+CCmdDump::CCmdDump()
+	{
+	}
+
+const TDesC& CCmdDump::Name() const
+	{
+	_LIT(KCmdDumpName, "dump");
+	return KCmdDumpName;
+	}
+
+void CCmdDump::DoRunL()
+	{
+	if (iFileNames.Count())
+		{
+		for (TInt i = 0; i < iFileNames.Count(); i++)
+			{
+			TInt pos = 0;
+			const TFileName& fn = iFileNames[i];
+			LeaveIfFileNotFound(fn);
+			RFile file;
+			User::LeaveIfError(file.Open(FsL(), fn, EFileRead));
+			TBuf8<KBlockSize> buf;
+			TInt err = KErrNone;
+			if (iFileNames.Count() > 1) Printf(_L("%S:\r\n"), &fn); // For compatability don't print the file name if there's only one file
+			FOREVER
+				{
+				err = file.Read(buf);
+				if ((err == KErrNone) && (buf.Length() > 0))
+					{
+					Dump(buf, *this, pos);
+					buf.Zero();
+					}
+				else
+					{
+					break;
+					}
+				}
+			file.Close();
+			}
+		}
+	else
+		{
+		TInt pos = 0;
+		RIoConsoleReadHandle& stdin = Stdin();
+		if (iBinaryMode)
+			{
+			stdin.SetModeL(RIoReadWriteHandle::EBinary);
+			}
+		stdin.SetReadModeL(RIoReadHandle::EOneOrMore);
+		TBuf<KBlockSize> buf;
+		TInt err = KErrNone;
+		while (err == KErrNone)
+			{
+			err = stdin.Read(buf);
+			if (err == KErrNone)
+				{
+				Dump(TPtrC8((TUint8*)buf.Ptr(), buf.Length() * 2), *this, pos);
+				}
+			}
+		}
+	}
+
+void CCmdDump::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdDumpOptBinaryMode, "binary");
+	aOptions.AppendBoolL(iBinaryMode, KCmdDumpOptBinaryMode);
+	}
+
+void CCmdDump::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdDumpArg1, "file_name");
+	aArguments.AppendFileNameL(iFileNames, KCmdDumpArg1);
+	}
+
+
+//
+// CCmdSleep.
+//
+
+CCommandBase* CCmdSleep::NewLC()
+	{
+	CCmdSleep* self = new(ELeave) CCmdSleep();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSleep::~CCmdSleep()
+	{
+	}
+
+CCmdSleep::CCmdSleep() : CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdSleep::Name() const
+	{
+	_LIT(KCmdSleepName, "sleep");
+	return KCmdSleepName;
+	}
+
+void CCmdSleep::DoRunL()
+	{
+	if (iDuration > (KMaxTUint / 1000000))
+		{
+		LeaveIfErr(KErrArgument, _L("Duration too large"));
+		}
+
+	if (iDuration > 0)
+		{
+		User::After(iDuration * 1000000);
+		Complete();
+		}
+	}
+
+void CCmdSleep::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdSleepArg1, "duration");
+	aArguments.AppendUintL(iDuration, KCmdSleepArg1);
+	}
+
+
+//
+// CCmdEnv.
+//
+
+CCommandBase* CCmdEnv::NewLC()
+	{
+	CCmdEnv* self = new(ELeave) CCmdEnv();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdEnv::~CCmdEnv()
+	{
+	}
+
+CCmdEnv::CCmdEnv()
+	{
+	}
+
+const TDesC& CCmdEnv::Name() const
+	{
+	_LIT(KCmdEnvName, "env");
+	return KCmdEnvName;
+	}
+
+void CCmdEnv::DoRunL()
+	{
+	const IoUtils::CEnvironment& env = Env();
+
+	RPointerArray<HBufC> keys;
+	LtkUtils::CleanupResetAndDestroyPushL(keys);
+	env.GetKeysL(keys);
+
+	const TInt numVars = keys.Count();
+	for (TInt i = 0; i < numVars; ++i)
+		{
+		const TDesC& key = *keys[i];
+		if (env.IsInt(key))
+			{
+			Printf(_L("%S=%d\r\n"), &key, env.GetAsIntL(key));
+			}
+		else if (env.IsDes(key))
+			{
+			const TDesC& des = env.GetAsDesL(key);
+			Printf(_L("%S=%S\r\n"), &key, &des);
+			}
+		}
+	CleanupStack::PopAndDestroy(&keys);
+	}
+
+
+//
+// CCmdExport.
+//
+
+CCommandBase* CCmdExport::NewLC()
+	{
+	CCmdExport* self = new(ELeave) CCmdExport();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdExport::~CCmdExport()
+	{
+	delete iKey;
+	delete iVal;
+	}
+
+CCmdExport::CCmdExport()
+	{
+	}
+
+const TDesC& CCmdExport::Name() const
+	{
+	_LIT(KCmdExportName, "export");
+	return KCmdExportName;
+	}
+
+void CCmdExport::DoRunL()
+	{
+	if (iStdin)
+		{
+		if (iVal)
+			{
+			Complete(KErrArgument, _L("You can only specify one of --stdin or <value>"));
+			return;
+			}
+
+		Stdin().SetReadModeL(RIoReadHandle::EFull);
+		TInt err = Stdin().Read(iBuf);
+		if (err == KErrEof)
+			{
+			Env().SetL(*iKey, KNullDesC);
+			}
+		else
+			{
+			LeaveIfErr(err, _L("Couldn't read from stdin"));
+			Env().SetL(*iKey, iBuf);
+			}
+		}
+	else if (iVal)
+		{
+		Env().SetL(*iKey, *iVal);
+		}
+	else
+		{
+		Env().RemoveL(*iKey);
+		}
+	}
+
+void CCmdExport::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdExportOptStdin, "stdin");
+	aOptions.AppendBoolL(iStdin, KCmdExportOptStdin);
+	}
+
+void CCmdExport::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdExportArg1, "variable");
+	_LIT(KCmdExportArg2, "value");
+	aArguments.AppendStringL(iKey, KCmdExportArg1);
+	aArguments.AppendStringL(iVal, KCmdExportArg2);
+	}
+
+
+//
+// CCmdSort.
+//
+
+CCommandBase* CCmdSort::NewLC()
+	{
+	CCmdSort* self = new(ELeave) CCmdSort();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSort::~CCmdSort()
+	{
+	}
+
+CCmdSort::CCmdSort()
+	{
+	}
+
+const TDesC& CCmdSort::Name() const
+	{
+	_LIT(KCmdSortName, "sort");
+	return KCmdSortName;
+	}
+
+TInt ComparePtrs(const TPtrC& aPtr1, const TPtrC& aPtr2)
+	{
+	return aPtr1.Compare(aPtr2);
+	}
+
+void CCmdSort::DoRunL()
+	{
+	// Read all input into a buffer.
+	CTextBuffer* buffer = CTextBuffer::NewLC(0x100);
+	Stdin().SetReadMode(RIoReadHandle::EOneOrMore);
+	TBuf<0x100> buf;
+	while (Stdin().Read(buf) == KErrNone)
+		{
+		buffer->AppendL(buf);
+		}
+
+	// Populate an ordered list of lines.
+	RArray<TPtrC> sortedLines;
+	CleanupClosePushL(sortedLines);
+	TPtrC ptr(buffer->Descriptor());
+	FOREVER
+		{
+		TInt pos = ptr.Find(KNewLine);
+		if (pos >= 0)
+			{
+			pos += KNewLine().Length();
+			TPtrC line(ptr.Left(pos));
+			User::LeaveIfError(sortedLines.InsertInOrderAllowRepeats(line, TLinearOrder<TPtrC>(ComparePtrs)));
+			if (pos < (ptr.Length() - 1))
+				{
+				ptr.Set(ptr.Mid(pos));
+				}
+			else
+				{
+				break;
+				}
+			}
+		else
+			{
+			User::LeaveIfError(sortedLines.InsertInOrderAllowRepeats(ptr, TLinearOrder<TPtrC>(ComparePtrs)));
+			break;
+			}
+		}
+
+	// Output the ordered list of lines.
+	const TInt numLines = sortedLines.Count();
+	if (iReverse)
+		{
+		for (TInt i = (numLines - 1); i >= 0; --i)
+			{
+			Write(sortedLines[i]);
+			}
+		}
+	else
+		{
+		for (TInt i = 0; i < numLines; ++i)
+			{
+			Write(sortedLines[i]);
+			}
+		}
+
+	CleanupStack::PopAndDestroy(2, buffer);
+	}
+
+void CCmdSort::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdSortOptReverse, "reverse");
+	aOptions.AppendBoolL(iReverse, KCmdSortOptReverse);
+	}
+
+
+//
+// CCmdExists.
+//
+
+CCommandBase* CCmdExists::NewLC()
+	{
+	CCmdExists* self = new(ELeave) CCmdExists();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdExists::~CCmdExists()
+	{
+	}
+
+CCmdExists::CCmdExists()
+	{
+	}
+
+const TDesC& CCmdExists::Name() const
+	{
+	_LIT(KCmdExistsName, "exists");
+	return KCmdExistsName;
+	}
+
+void CCmdExists::DoRunL()
+	{
+	TUint att;
+	Complete(!(FsL().Att(iFileName, att) == KErrNone));
+	}
+
+void CCmdExists::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdExistsArg, "file_name");
+	aArguments.AppendFileNameL(iFileName, KCmdExistsArg);
+	}
+
+
+//
+// CCmdInfoPrint.
+//
+
+CCommandBase* CCmdInfoPrint::NewLC()
+	{
+	CCmdInfoPrint* self = new(ELeave) CCmdInfoPrint();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdInfoPrint::~CCmdInfoPrint()
+	{
+	delete iToPrint;
+	}
+
+CCmdInfoPrint::CCmdInfoPrint()
+	{
+	}
+
+const TDesC& CCmdInfoPrint::Name() const
+	{
+	_LIT(KCmdInfoPrintName, "infoprint");
+	return KCmdInfoPrintName;
+	}
+
+void CCmdInfoPrint::DoRunL()
+	{
+	if (!iToPrint)
+		{
+		TBuf<0x100> toPrint;
+		Stdin().SetReadModeL(RIoReadHandle::EFull);
+		Stdin().Read(toPrint);
+		// remove a newline from the end, if one exists
+		if ((toPrint.Length() > 0) && (toPrint[toPrint.Length()-1] == '\n'))
+			{
+			toPrint.SetLength(toPrint.Length()-1);
+			if ((toPrint.Length() > 0) && (toPrint[toPrint.Length()-1] == '\r'))
+				{
+				toPrint.SetLength(toPrint.Length()-1);
+				}
+			}
+		User::InfoPrint(toPrint);
+		}
+	else
+		{
+		User::InfoPrint(*iToPrint);
+		}
+	}
+
+void CCmdInfoPrint::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdInfoPrintArg, "message");
+	aArguments.AppendStringL(iToPrint, KCmdInfoPrintArg);
+	}
+
+
+//
+// CCmdRDebug.
+//
+
+CCommandBase* CCmdRDebug::NewLC()
+	{
+	CCmdRDebug* self = new(ELeave) CCmdRDebug();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRDebug::~CCmdRDebug()
+	{
+	delete iToPrint;
+	}
+
+CCmdRDebug::CCmdRDebug()
+	{
+	}
+
+const TDesC& CCmdRDebug::Name() const
+	{
+	_LIT(KCmdRDebugName, "rdebug");
+	return KCmdRDebugName;
+	}
+
+void CCmdRDebug::DoRunL()
+	{
+	if (iToPrint)
+		{
+		RDebug::Print(*iToPrint);
+		}
+	else
+		{
+		RIoConsoleReadHandle& stdin = Stdin();
+		stdin.SetReadModeL(RIoReadHandle::ELine);
+		TBuf<512> buf;
+		TInt err = KErrNone;
+		while (err == KErrNone)
+			{
+			err = stdin.Read(buf);
+			if (err == KErrNone)
+				{
+				RDebug::Print(buf);
+				}
+			}
+		}
+	}
+
+void CCmdRDebug::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdRDebugArg, "message");
+	aArguments.AppendStringL(iToPrint, KCmdRDebugArg);
+	}
+
+
+//
+// CCmdDate.
+//
+
+CCommandBase* CCmdDate::NewLC()
+	{
+	CCmdDate* self = new(ELeave) CCmdDate();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdDate::~CCmdDate()
+	{
+	delete iDateToSet;
+	}
+
+CCmdDate::CCmdDate()
+	{
+	}
+
+void CCmdDate::Display(const TTime& aTime)
+	{
+	if (iRaw)
+		{
+		Printf(_L("%Ld\r\n"), aTime.Int64());
+		}
+	else if (iUseTimestampFormat)
+		{
+		TDateTime dateTime(aTime.DateTime());
+		Printf(_L("%04d%02d%02d-%02d%02d.%02d"), dateTime.Year(), dateTime.Month() + 1, dateTime.Day() + 1, dateTime.Hour(), dateTime.Minute(), dateTime.Second());
+		}
+	else
+		{
+		TDateTime dateTime(aTime.DateTime());
+		Printf(_L("%+02d/%+02d/%+04d %+02d:%+02d:%+02d.%+06d\r\n"), dateTime.Day() + 1, dateTime.Month() + 1, dateTime.Year(), dateTime.Hour(), dateTime.Minute(), dateTime.Second(), dateTime.MicroSecond());
+		}
+	}
+
+const TDesC& CCmdDate::Name() const
+	{
+	_LIT(KCmdDateName, "date");
+	return KCmdDateName;
+	}
+
+void CCmdDate::DoRunL()
+	{
+	if (!iDateToSet && !iOptions.IsPresent(&iRawTimeToSet))
+		{
+		TTime time;
+		if (iUniversalTime)
+			{
+#ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
+			if (iSecure)
+				{
+				LeaveIfErr(time.UniversalTimeSecure(), _L("Unable to get secure universal time"));
+				}
+			else
+#endif
+				{
+				time.UniversalTime();
+				}
+			}
+		else
+			{
+#ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
+			if (iSecure)
+				{
+				LeaveIfErr(time.HomeTimeSecure(), _L("Unable to get secure home time"));
+				}
+			else
+#endif
+				{
+				time.HomeTime();
+				}
+			}
+		Display(time);
+		}
+	else
+		{
+		_LIT(KSettingError, "Cannot set the time");
+		TTime time(iRawTimeToSet);
+		if (iDateToSet)
+			{
+			_LIT(KParsingTime, "Cannot parse time string");
+			LeaveIfErr(time.Parse(*iDateToSet), KParsingTime);
+			}
+		if (iJustDisplay)
+			{
+			Display(time);
+			}
+		else
+			{
+			if (iUniversalTime)
+				{
+#ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
+				if (iSecure)
+					{
+					LeaveIfErr(User::SetUTCTimeSecure(time), KSettingError);
+					}
+				else
+#endif
+					{
+					LeaveIfErr(User::SetUTCTime(time), KSettingError);
+					}
+				}
+			else
+				{
+#ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
+				if (iSecure)
+					{
+					LeaveIfErr(User::SetHomeTimeSecure(time), KSettingError);
+					}
+				else
+#endif
+					{
+					LeaveIfErr(User::SetHomeTime(time), KSettingError);
+					}
+				}
+			if (iOptions.IsPresent(&iUtcOffset))
+				{
+				User::SetUTCOffset(TTimeIntervalSeconds(iUtcOffset));
+				}
+			}
+		}
+	}
+
+void CCmdDate::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdDateOptUniversal, "universal");
+	_LIT(KCmdDateOptSet, "set");
+	_LIT(KCmdDateOptUtcOffset, "utc-offset");
+#ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
+	_LIT(KCmdDateOptSecure, "secure");
+#endif
+	_LIT(KCmdDateOptRaw, "raw");
+	_LIT(KCmdDateOptJustDisplay, "just-display");
+	_LIT(KCmdDateOptSetRaw, "raw-set");
+	_LIT(KCmdDataOptTimestamp, "timestamp");
+
+	aOptions.AppendBoolL(iUniversalTime, KCmdDateOptUniversal);
+	aOptions.AppendStringL(iDateToSet, KCmdDateOptSet);
+	aOptions.AppendIntL(iUtcOffset, KCmdDateOptUtcOffset);
+#ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
+	aOptions.AppendBoolL(iSecure, KCmdDateOptSecure);
+#endif
+	aOptions.AppendBoolL(iRaw, KCmdDateOptRaw);
+	aOptions.AppendBoolL(iJustDisplay, KCmdDateOptJustDisplay);
+	aOptions.AppendIntL(iRawTimeToSet, KCmdDateOptSetRaw);
+	aOptions.AppendBoolL(iUseTimestampFormat, KCmdDataOptTimestamp);
+	}
+
+
+//
+// CCmdFsck.
+//
+
+CCommandBase* CCmdFsck::NewLC()
+	{
+	CCmdFsck* self = new(ELeave) CCmdFsck();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdFsck::~CCmdFsck()
+	{
+	delete iDriveLetter;
+	}
+
+CCmdFsck::CCmdFsck()
+	{
+	}
+
+const TDesC& CCmdFsck::Name() const
+	{
+	_LIT(KCmdFsckName, "fsck");
+	return KCmdFsckName;
+	}
+
+void CCmdFsck::DoRunL()
+	{
+	TInt ret = FsL().CheckDisk(*iDriveLetter);
+
+	switch (ret)
+		{
+		case KErrNotSupported:
+			Printf(_L("Not supported\r\n"));
+			break;
+		case 0:
+			Printf(_L("No errors\r\n"));
+			break;
+		case 1:
+			Printf(_L("Error: File cluster chain contains a bad value (<2 or >maxCluster)\r\n"));
+			break;
+		case 2:
+			Printf(_L("Error: Two files are linked to the same cluster\r\n"));
+			break;
+		case 3:
+			Printf(_L("Error: Unallocated cluster contains a value != 0\r\n"));
+			break;
+		case 4:
+			Printf(_L("Error: Size of file != number of clusters in chain\r\n"));
+			break;
+		default:
+			Printf(_L("Error: %d\r\n"), ret);
+		}
+
+	User::LeaveIfError(ret);
+	}
+
+void CCmdFsck::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdFsckArg, "drive_letter");
+	aArguments.AppendStringL(iDriveLetter, KCmdFsckArg);
+	}
+
+
+//
+// CCmdDriver.
+//
+
+CCommandBase* CCmdDriver::NewLC()
+	{
+	CCmdDriver* self = new(ELeave) CCmdDriver();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdDriver::~CCmdDriver()
+	{
+	delete iDriverName;
+	}
+
+CCmdDriver::CCmdDriver()
+	{
+	}
+
+const TDesC& CCmdDriver::Name() const
+	{
+	_LIT(KCmdDriverName, "driver");
+	return KCmdDriverName;
+	}
+
+void CCmdDriver::DoRunL()
+	{
+	TInt err = KErrNone;
+	switch (iOperation)
+		{
+		case ELoad:
+			{
+			if (iType == ELogical)
+				{
+				err = User::LoadLogicalDevice(*iDriverName);
+				}
+			else
+				{
+				err = User::LoadPhysicalDevice(*iDriverName);
+				}
+			break;
+			}
+		case EFree:
+			{
+			if (iType == ELogical)
+				{
+				err = User::FreeLogicalDevice(*iDriverName);
+				}
+			else
+				{
+				err = User::FreePhysicalDevice(*iDriverName);
+				}
+			break;
+			}
+		case EFind:
+			{
+			if (iType == ELogical)
+				{
+				TFindLogicalDevice findLogicalDevice;
+				TFullName name;
+				while (findLogicalDevice.Next(name) == KErrNone)
+					{
+					Printf(_L("%S\r\n"), &name);
+					}
+				}
+			else
+				{
+				TFindPhysicalDevice findPhysicalDevice;
+				TFullName name;
+				while (findPhysicalDevice.Next(name) == KErrNone)
+					{
+					Printf(_L("%S\r\n"), &name);
+					}
+				}
+			break;
+			}
+		default:
+			{
+			ASSERT(EFalse);
+			break;
+			}
+		}
+
+	if (err)
+		{
+		TPtrC operation(iArguments.AsString(&iOperation));
+		TPtrC type(iArguments.AsString(&iType));
+		PrintError(err, _L("Unable to %S %S device"), &operation, &type);
+		User::Leave(err);
+		}
+	}
+
+void CCmdDriver::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdDriverArg1, "operation");
+	_LIT(KCmdDriverArg2, "type");
+	_LIT(KCmdDriverArg3, "name");
+
+	aArguments.AppendEnumL((TInt&)iOperation, KCmdDriverArg1);
+	aArguments.AppendEnumL((TInt&)iType, KCmdDriverArg2);
+	aArguments.AppendStringL(iDriverName, KCmdDriverArg3);
+	}
+
+
+//
+// CCmdChunkInfo.
+//
+
+CCommandBase* CCmdChunkInfo::NewLC()
+	{
+	CCmdChunkInfo* self = new(ELeave) CCmdChunkInfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdChunkInfo::~CCmdChunkInfo()
+	{
+	delete iOwningProcess;
+	delete iBuf;
+	delete iFormatter;
+	}
+
+CCmdChunkInfo::CCmdChunkInfo()
+	{
+	}
+
+void CCmdChunkInfo::ListChunksL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TInt bufSize = 1024;
+	TInt err = KErrNone;
+	HBufC8* addressesBuf;
+	do
+		{
+		addressesBuf = HBufC8::NewLC(bufSize);
+		TPtr8 addressesPtr(addressesBuf->Des());
+		if (iControllingProcess != 0)
+			{
+			err = iMemAccess.GetChunkAddresses(iControllingProcess, addressesPtr);
+			}
+		else
+			{
+			err = iMemAccess.GetObjectAddresses(EChunk, iOwningProcess ? *iOwningProcess : KNullDesC(), addressesPtr);
+			}
+		if (err == KErrOverflow)
+			{
+			CleanupStack::PopAndDestroy(addressesBuf);
+			bufSize *= 2;
+			}
+		}
+		while (err == KErrOverflow);
+
+	if (err)
+		{
+		PrintError(err, _L("Unable to read chunk addresses."));
+		User::Leave(err);
+		}
+
+	const TInt numAddresses = addressesBuf->Length() / sizeof(TUint32*);
+	if (numAddresses == 0)
+		{
+		Write(_L("No chunks found.\r\n"));
+		}
+	else
+		{
+		TUint32* p = (TUint32*)addressesBuf->Ptr();
+		TInt offset = 0;
+		while (offset < numAddresses)
+			{
+			TChunkKernelInfo chunkInfo;
+			TPckg<TChunkKernelInfo> chunkInfoPckg(chunkInfo);
+			TUint32* ptr = p + offset++;
+			err = iMemAccess.GetObjectInfo(EChunk, (TUint8*)(*ptr), chunkInfoPckg);
+			if (err == KErrNone)
+				{
+				iFullName.Copy(chunkInfo.iFullName);
+				if (iIncludeSize)
+					{
+					iBuf->AppendFormatL(_L("0x%08x\t"), *ptr);
+					if (iHumanReadable)
+						{
+						iBuf->AppendHumanReadableSizeL(chunkInfo.iSize, EUnaligned);
+						iBuf->AppendFormatL(KTab);
+						}
+					else
+						{
+						iBuf->AppendFormatL(_L("%d\t"), chunkInfo.iSize);
+						}
+					iBuf->AppendFormatL(_L("\'%S\'\r\n"), &iFullName);
+					}
+				else
+					{
+					iBuf->AppendFormatL(_L("0x%08x\t\'%S\'\r\n"), *ptr, &iFullName);
+					}
+				}
+			else if (err != KErrNotFound)
+				{
+				// Only abort on something other than KErrNotFound. KErrNotFound could legitimately
+				// happen if the chunk in question has been deleted since we called RMemoryAccess::GetObjectAddresses.
+				PrintError(err, _L("Unable to read chunk at 0x%08x, aborting."), ptr);
+				User::Leave(err);
+				}
+			}
+		}
+
+	CleanupStack::PopAndDestroy(addressesBuf);
+#endif
+	}
+
+void CCmdChunkInfo::PrintChunkInfoL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TChunkKernelInfo chunkInfo;
+	TPckg<TChunkKernelInfo> chunkInfoPckg(chunkInfo);
+	TInt err = iMemAccess.GetObjectInfo(EChunk, (TUint8*)iAddress, chunkInfoPckg);
+	if (err)
+		{
+		PrintError(err, _L("Unable to get info for chunk 0x%08x"), iAddress);
+		User::Leave(err);
+		}
+	else
+		{
+		iFullName.Copy(chunkInfo.iFullName);
+		iBuf->AppendFormatL(_L("Name:\t\'%S\'\r\n"), &iFullName);
+		iBuf->AppendFormatL(_L("Base:\t0x%08x\r\n"), chunkInfo.iBase);
+		PrintSizeL(_L("Max size:\t"), chunkInfo.iMaxSize);
+		PrintSizeL(_L("Current size:\t"), chunkInfo.iSize);
+		iBuf->AppendFormatL(_L("Attributes:\t0x%08x\r\n"), chunkInfo.iAttributes);
+		iBuf->AppendFormatL(_L("Type:\t0x%08x\r\n"), chunkInfo.iChunkType);
+		iBuf->AppendFormatL(_L("Restrictions:\t0x%08x\r\n"), chunkInfo.iRestrictions);
+
+		RProcess process;
+		TInt err = process.Open(chunkInfo.iControllingOwnerProcessId);
+		if (err == KErrNone)
+			{
+			iName = process.Name();
+			process.Close();
+			iBuf->AppendFormatL(_L("Controlling process:\t\'%S\' (%u)\r\n"), &iName, chunkInfo.iControllingOwnerProcessId);
+			LtkUtils::RProxyAllocatorHelper allocHelper;
+			CleanupClosePushL(allocHelper);
+			err = allocHelper.OpenChunkHeap(iMemAccess, (TAny*)iAddress);
+			if (err == KErrNone)
+				{
+				iBuf->AppendFormatL(_L("Allocator type:\t%S\r\n"), &allocHelper.Description());
+				PrintSizeL(_L("Heap size:\t"), allocHelper.CommittedSize());
+				PrintSizeL(_L("Heap max size:\t"), allocHelper.MaxCommittedSize());
+				iBuf->AppendFormatL(_L("Alloc count:\t%d\r\n"), allocHelper.AllocationCount());
+				PrintSizeL(_L("Total alloc size:\t"), allocHelper.AllocatedSize());
+				TReal overheadRatio = ((allocHelper.CommittedSize() - allocHelper.AllocatedSize() - allocHelper.CommittedFreeSpace()) * 100) / (TReal)allocHelper.CommittedSize();
+				iBuf->AppendFormatL(_L("Metadata overhead:\t%00.2f%%\r\n"), overheadRatio);
+				TInt val = allocHelper.SizeForCellType(RAllocatorHelper::EDlaAllocation);
+				if (val >= 0)
+					{
+					PrintSizeL(_L("DL alloc size:\t"), val);
+					iBuf->AppendFormatL(_L("DL alloc count:\t%d\r\n"), allocHelper.CountForCellType(RAllocatorHelper::EDlaAllocation));
+					PrintSizeL(_L("DL free size:\t"), allocHelper.SizeForCellType(RAllocatorHelper::EDlaFreeCell));
+					iBuf->AppendFormatL(_L("DL free cell count:\t%d\r\n"), allocHelper.CountForCellType(RAllocatorHelper::EDlaFreeCell));
+					PrintSizeL(_L("Paged alloc size:\t"), allocHelper.SizeForCellType(RAllocatorHelper::EPageAllocation));
+					iBuf->AppendFormatL(_L("Paged alloc count:\t%d\r\n"), allocHelper.CountForCellType(RAllocatorHelper::EPageAllocation));
+					PrintSizeL(_L("Slab alloc size:\t"), allocHelper.SizeForCellType(RAllocatorHelper::ESlabAllocation));
+					iBuf->AppendFormatL(_L("Slab alloc count:\t%d\r\n"), allocHelper.CountForCellType(RAllocatorHelper::ESlabAllocation));
+					PrintSizeL(_L("Slab free size:\t"), allocHelper.SizeForCellType(RAllocatorHelper::ESlabFreeCell));
+					iBuf->AppendFormatL(_L("Slab free cell count:\t%d\r\n"), allocHelper.CountForCellType(RAllocatorHelper::ESlabFreeCell));
+					PrintSizeL(_L("Unused slabs size:\t"), allocHelper.SizeForCellType(RAllocatorHelper::ESlabFreeSlab));
+					iBuf->AppendFormatL(_L("Unused slabs count:\t%d\r\n"), allocHelper.CountForCellType(RAllocatorHelper::ESlabFreeSlab));
+					}
+				else if (val != KErrNotSupported)
+					{
+					iBuf->AppendFormatL(_L("\t[Error %d returned from heap stats]\r\n"), val);
+					}
+				}
+			else
+				{
+				iBuf->AppendL(_L("\t[RHeap allocator not found]\r\n"));
+				}
+			CleanupStack::PopAndDestroy(&allocHelper);
+			}
+		if (err)
+			{
+			PrintWarning(_L("Unable to read RHeap info: %d"), err);
+			}
+		}
+#endif
+	}
+
+void CCmdChunkInfo::PrintSizeL(const TDesC& aCaption, TInt aSize)
+	{
+	if (iHumanReadable)
+		{
+		iBuf->AppendL(aCaption);
+		iBuf->AppendHumanReadableSizeL(aSize, EUnaligned);
+		iBuf->AppendL(KNewLine);
+		}
+	else
+		{
+		_LIT(KFormat, "%S%d\r\n");
+		iBuf->AppendFormatL(KFormat, &aCaption, aSize);
+		}
+	}
+
+const TDesC& CCmdChunkInfo::Name() const
+	{
+	_LIT(KCmdChunkInfoName, "chunkinfo");
+	return KCmdChunkInfoName;
+	}
+
+void CCmdChunkInfo::DoPrintL()
+	{
+	iBuf->Zero();
+	iFormatter->Zero();
+
+	if (iAddress == 0)
+		{
+		ListChunksL();
+		}
+	else
+		{
+		PrintChunkInfoL();
+		}
+
+	iFormatter->TabulateL(0, 2, iBuf->Descriptor(), ETruncateLongestColumn);
+	Write(iFormatter->Descriptor());
+	}
+
+void CCmdChunkInfo::DoRunL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	iFormatter = CTextFormatter::NewL(Stdout());
+	iBuf = IoUtils::CTextBuffer::NewL(0x100);
+	LoadMemoryAccessL();
+
+	RIoConsoleWriteHandle stdout = Stdout();
+	TBool attachedToConsole(stdout.AttachedToConsole());
+	if (attachedToConsole && iUpdateRate && iAddress)
+		{
+		stdout.SetCursorHeight(0);
+		stdout.ClearScreen();
+		}
+
+	DoPrintL();
+
+	if (iUpdateRate && iAddress)
+		{
+		FOREVER
+			{
+			User::After(iUpdateRate * 1000);
+			if (attachedToConsole)
+				{
+				stdout.ClearScreen();
+				}
+			DoPrintL();
+			}
+		}
+#else
+	PrintError(KErrNotSupported, _L("Unable to fetch chunk information because fshell was not built with FSHELL_MEMORY_ACCESS_SUPPORT defined. That probably means this plaform doesn't support the MemoryAccess device driver."));
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+void CCmdChunkInfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdChunkInfoOptRate, "rate");
+	_LIT(KCmdChunkInfoOptHuman, "human");
+	_LIT(KCmdChunkInfoOptOwningProcess, "owning-process");
+	_LIT(KCmdChunkInfoOptControllingProcess, "controlling-process");
+	_LIT(KCmdChunkInfoOptSize, "size");
+
+	aOptions.AppendUintL(iUpdateRate, KCmdChunkInfoOptRate);
+	aOptions.AppendBoolL(iHumanReadable, KCmdChunkInfoOptHuman);
+	aOptions.AppendStringL(iOwningProcess, KCmdChunkInfoOptOwningProcess);
+	aOptions.AppendUintL(iControllingProcess, KCmdChunkInfoOptControllingProcess);
+	aOptions.AppendBoolL(iIncludeSize, KCmdChunkInfoOptSize);
+
+	}
+
+void CCmdChunkInfo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdChunkInfoArg, "chunk_address");
+	aArguments.AppendUintL(iAddress, KCmdChunkInfoArg);
+	}
+
+
+//
+// CCmdSvrInfo.
+//
+
+CCommandBase* CCmdSvrInfo::NewLC()
+	{
+	CCmdSvrInfo* self = new(ELeave) CCmdSvrInfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSvrInfo::~CCmdSvrInfo()
+	{
+	delete iBuf;
+	delete iFormatter;
+	}
+
+CCmdSvrInfo::CCmdSvrInfo()
+	{
+	}
+
+void CCmdSvrInfo::ListServersL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TInt bufSize = 1024;
+	TInt err = KErrNone;
+	HBufC8* addressesBuf;
+	do
+		{
+		addressesBuf = HBufC8::NewLC(bufSize);
+		TPtr8 addressesPtr(addressesBuf->Des());
+		err = iMemAccess.GetObjectAddresses(EServer, KNullDesC(), addressesPtr);
+		if (err == KErrOverflow)
+			{
+			CleanupStack::PopAndDestroy(addressesBuf);
+			bufSize *= 2;
+			}
+		}
+		while (err == KErrOverflow);
+
+	if (err)
+		{
+		PrintError(err, _L("Unable to read server addresses."));
+		User::Leave(err);
+		}
+
+	const TInt numAddresses = addressesBuf->Length() / sizeof(TUint32*);
+	if (numAddresses == 0)
+		{
+		Write(_L("No servers found.\r\n"));
+		}
+	else
+		{
+		TUint32* p = (TUint32*)addressesBuf->Ptr();
+		TInt offset = 0;
+		while (offset < numAddresses)
+			{
+			TPckg<TServerKernelInfo> serverInfoPckg(iServerInfo);
+			TUint32* ptr = p + offset++;
+			err = iMemAccess.GetObjectInfo(EServer, (TUint8*)(*ptr), serverInfoPckg);
+			if (err == KErrNone)
+				{
+				iFullName.Copy(iServerInfo.iFullName);
+				iBuf->AppendFormatL(_L("0x%08x\t\'%S\'\r\n"), *ptr, &iFullName);
+				}
+			else if (err != KErrNotFound)
+				{
+				// Only warn on something other than KErrNotFound. KErrNotFound could legitimately
+				// happen if the chunk in question has been deleted since we called RMemoryAccess::GetObjectAddresses.
+				PrintWarning(_L("Unable to read server at 0x%08x (%d)"), ptr, err);
+				}
+			}
+		}
+
+	CleanupStack::PopAndDestroy(addressesBuf);
+
+#endif
+	}
+
+void CCmdSvrInfo::ListSessionsL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TPckg<TServerKernelInfo> serverInfoPckg(iServerInfo);
+	TInt err = iMemAccess.GetObjectInfo(EServer, (TUint8*)iAddress, serverInfoPckg);
+	if (err)
+		{
+		PrintError(err, _L("Unable to get info for server 0x%08x"), iAddress);
+		User::Leave(err);
+		}
+	
+	TPckg<TThreadKernelInfo> threadInfoPckg(iThreadInfo);
+	err = iMemAccess.GetObjectInfo(EThread, iServerInfo.iAddressOfOwningThread, threadInfoPckg);
+	if (err)
+		{
+		PrintError(err, _L("Unable to get info for thread 0x%08x"), iServerInfo.iAddressOfOwningThread);
+		User::Leave(err);
+		}
+
+	iFullName.Copy(iThreadInfo.iFullName);
+	iBuf->AppendFormatL(_L("Owning thread id:\t%u\r\n"), iThreadInfo.iThreadId);
+	iBuf->AppendFormatL(_L("Owning thread name:\t\'%S\'\r\n"), &iFullName);
+	TUint type = iServerInfo.iSessionType;
+	iBuf->AppendFormatL(_L("Session type:\t%u\r\n"), type);
+
+	for (TUint i = iServerInfo.iSessionQ.iStartFrom; i < iServerInfo.iSessionQ.iCount; ++i)
+		{
+		TPckg<TSessionKernelInfo> sessionInfoPckg(iSessionInfo);
+		err = iMemAccess.GetObjectInfo(ESession, iServerInfo.iSessionQ.iBuffer[i], sessionInfoPckg);
+		if (err)
+			{
+			PrintWarning(_L("Unable to get info for session 0x%08x (%d)"), iServerInfo.iSessionQ.iBuffer[i], err);
+			}
+		else
+			{
+			iFullName.Copy(iSessionInfo.iFullName);
+			iBuf->AppendFormatL(_L("Session:\t\'%S\'\r\n"), &iFullName);
+
+			TPckg<TProcessKernelInfo> processInfoPckg(iProcessInfo);
+			err = iMemAccess.GetObjectInfo(EProcess, iSessionInfo.iAddressOfKernelOwner, processInfoPckg);
+			if (err == KErrNone)
+				{
+				iFullName.Copy(iProcessInfo.iFullName);
+				iBuf->AppendFormatL(_L("Session owner:\t\'%S\'\r\n"), &iFullName);
+				}
+			else
+				{
+				err = iMemAccess.GetObjectInfo(EThread, iSessionInfo.iAddressOfKernelOwner, threadInfoPckg);
+				if (err == KErrNone)
+					{
+					iFullName.Copy(iThreadInfo.iFullName);
+					iBuf->AppendFormatL(_L("Session owner:\t\'%S\'\r\n"), &iFullName);
+					}
+				else
+					{
+					PrintWarning(_L("Unable to get info for session owner 0x%08x (%d)"), iSessionInfo.iAddressOfKernelOwner, err);
+					}
+				}
+			}
+		}
+#endif
+	}
+
+const TDesC& CCmdSvrInfo::Name() const
+	{
+	_LIT(KCmdSvrInfoName, "svrinfo");
+	return KCmdSvrInfoName;
+	}
+
+void CCmdSvrInfo::DoRunL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	iFormatter = CTextFormatter::NewL(Stdout());
+	iBuf = IoUtils::CTextBuffer::NewL(0x100);
+	LoadMemoryAccessL();
+
+	if (iAddress == 0)
+		{
+		ListServersL();
+		}
+	else
+		{
+		ListSessionsL();
+		}
+
+	iFormatter->TabulateL(0, 2, iBuf->Descriptor(), ETruncateLongestColumn);
+	Write(iFormatter->Descriptor());
+#else
+	PrintError(KErrNotSupported, _L("Unable to fetch server information because fshell was not built with FSHELL_MEMORY_ACCESS_SUPPORT defined. That probably means this plaform doesn't support the MemoryAccess device driver."));
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+void CCmdSvrInfo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdSvrInfoArg, "server_address");
+	aArguments.AppendUintL(iAddress, KCmdSvrInfoArg);
+	}
+
+
+//
+// CCmdTickle.
+//
+	
+CCommandBase* CCmdTickle::NewLC()
+	{
+	CCmdTickle* self = new (ELeave) CCmdTickle();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTickle::~CCmdTickle()
+	{
+	}
+
+CCmdTickle::CCmdTickle()
+	{
+	}
+
+void CCmdTickle::DoRunL()
+	{
+	User::ResetInactivityTime();
+	const TInt KGiveSystemTimeToFocus = 500000; // microseconds
+	User::After(KGiveSystemTimeToFocus);
+	}
+	
+const TDesC& CCmdTickle::Name() const
+	{
+	_LIT(KName, "tickle");
+	return KName;
+	}
+
+
+//
+// CCmdTicks.
+//
+	
+CCommandBase* CCmdTicks::NewLC()
+	{
+	CCmdTicks* self = new (ELeave) CCmdTicks();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTicks::~CCmdTicks()
+	{
+	}
+
+CCmdTicks::CCmdTicks()
+	{
+	}
+
+TInt NanoTickPeriod()
+	{
+	TInt nanoTickPeriod;
+	if (HAL::Get(HAL::ENanoTickPeriod, nanoTickPeriod) != KErrNone)
+		{
+		nanoTickPeriod = 1000;
+		}
+	return nanoTickPeriod;
+	}
+
+TInt FastCounterFrequency()
+	{
+	TInt fastCounterFrequency;
+	if (HAL::Get(HAL::EFastCounterFrequency, fastCounterFrequency) != KErrNone)
+		{
+		fastCounterFrequency = 1000;
+		}
+	return fastCounterFrequency;
+	}
+
+TBool FastCounterCountsUp()
+	{
+	TBool countsUp;
+	if (HAL::Get(HAL::EFastCounterCountsUp, countsUp) != KErrNone)
+		{
+		countsUp = EFalse;
+		}
+	return countsUp;
+	}
+
+void CCmdTicks::DoRunL()
+	{
+	TUint nticks = User::NTickCount();
+	TUint fast = User::FastCounter();
+
+	Printf(_L("NKern ticks: %u\r\n"), nticks);
+	Printf(_L("Fast ticks: %u\r\n"), fast);
+
+	if (iVerbose)
+		{
+		Printf(_L("\r\nNKern tick period: %d\r\n"), NanoTickPeriod());
+		Printf(_L("Fast counter frequency: %d\r\n"), FastCounterFrequency());
+		Printf(_L("Fast counter counts up: %d\r\n"), FastCounterCountsUp());
+		}
+	}
+	
+const TDesC& CCmdTicks::Name() const
+	{
+	_LIT(KName, "ticks");
+	return KName;
+	}
+
+void CCmdTicks::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	}
+
+
+//
+// CCmdUpTime.
+//
+	
+CCommandBase* CCmdUpTime::NewLC()
+	{
+	CCmdUpTime* self = new (ELeave) CCmdUpTime();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdUpTime::~CCmdUpTime()
+	{
+	}
+
+CCmdUpTime::CCmdUpTime()
+	{
+	}
+
+void AppendTimeUnit(TInt aValue, const TDesC& aUnit, TDes& aBuf)
+	{
+	if (aValue == 1)
+		{
+		aBuf.AppendFormat(_L("1 %S "), &aUnit);
+		}
+	else
+		{
+		aBuf.AppendFormat(_L("%d %Ss "), aValue, &aUnit);
+		}
+	}
+
+void FormatTime(const TUint64& aInterval, TDes& aBuf)
+	{
+	const TInt ms = 1000;
+	const TInt s = ms * ms;
+	const TInt64 m = s * 60;
+	const TInt64 h = m * 60;
+	const TInt64 d = h * 24;
+
+	TInt64 interval = aInterval;
+	const TInt numDays = interval / d;
+	if (numDays > 0)
+		{
+		AppendTimeUnit(numDays, _L("day"), aBuf);
+		interval = interval % d;
+		}
+
+	const TInt numHours = interval / h;
+	if (numHours > 0)
+		{
+		AppendTimeUnit(numHours, _L("hour"), aBuf);
+		interval = interval % h;
+		}
+
+	const TInt numMinutes = interval / m;
+	if (numMinutes > 0)
+		{
+		AppendTimeUnit(numMinutes, _L("minute"), aBuf);
+		interval = interval % m;
+		}
+
+	TBuf<16> format(_L("%.2f "));
+	TReal realInterval = interval;
+	if (realInterval >= s)
+		{
+		realInterval /= s;
+		format.Append(_L("s"));
+		}
+	else if (realInterval >= ms)
+		{
+		realInterval /= ms;
+		format.Append(_L("ms"));
+		}
+	else
+		{
+		format.Append(_L("us"));
+		}
+	aBuf.AppendFormat(format, realInterval); 
+	}
+
+void CCmdUpTime::DoRunL()
+	{
+	TUint64 n = User::NTickCount();
+	n *= NanoTickPeriod();
+
+	if (iHuman)
+		{
+		TBuf<256> timeBuf;
+		FormatTime(n, timeBuf);
+		Printf(_L("%S"), &timeBuf);
+		}
+	else
+		{
+		Printf(_L("%Lu"), n);
+		}
+	}
+	
+const TDesC& CCmdUpTime::Name() const
+	{
+	_LIT(KName, "uptime");
+	return KName;
+	}
+
+void CCmdUpTime::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iHuman, KOptHuman);
+	}
+
+
+//
+// CCmdVar.
+//
+	
+CCommandBase* CCmdVar::NewLC()
+	{
+	CCmdVar* self = new (ELeave) CCmdVar();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdVar::~CCmdVar()
+	{
+	delete iVar1;
+	delete iArg;
+	}
+
+CCmdVar::CCmdVar()
+	{
+	}
+
+void CCmdVar::DoRunL()
+	{
+	IoUtils::CEnvironment& env = Env();
+	switch (iOperation)
+		{
+		case EDefined:
+			if (iArg)
+				{
+				Complete(KErrArgument, _L("Argument should not be specified for \"defined\" operation"));
+				}
+			else
+				{
+				SetErrorReported(ETrue); // To silence leaves.
+				Complete(!env.IsDefined(*iVar1));
+				}
+			break;
+		case ENotDefined:
+			if (iArg)
+				{
+				Complete(KErrArgument, _L("Argument should not be specified for \"not-defined\" operation"));
+				}
+			else
+				{
+				SetErrorReported(ETrue); // To silence leaves.
+				Complete(env.IsDefined(*iVar1));
+				}
+			break;
+		case EEqual:
+			if (iArg == NULL)
+				{
+				Complete(KErrArgument, _L("Argument must be specified for == operation"));
+				}
+			else
+				{
+				SetErrorReported(ETrue); // To silence leaves.
+				Complete(!(env.GetAsDesL(*iVar1) == *iArg));
+				}
+			break;
+		case ENotEqual:
+			if (iArg == NULL)
+				{
+				Complete(KErrArgument, _L("Argument must be specified for != operation"));
+				}
+			else
+				{
+				SetErrorReported(ETrue); // To silence leaves.
+				Complete(env.GetAsDesL(*iVar1) == *iArg);
+				}
+			break;
+		case EAdd:
+		case ESubtract:
+			{
+			if (iArg == NULL) LeaveIfErr(KErrArgument, _L("Argument must be specified for add and subtract operations"));
+			TLex lex(*iArg);
+			TInt operand;
+			TInt err = lex.Val(operand);
+			LeaveIfErr(err, _L("Couldn't parse an integer from argument '%S'"), iArg);
+			if (iOperation == ESubtract) operand = -operand;
+			TInt current = 0;
+			TRAP_IGNORE(current = env.GetAsIntL(*iVar1)); // If it doesn't yet exist or isn't an int, we'll treat it as if it was zero
+			env.SetL(*iVar1, current + operand);
+			break;
+			}
+		default:
+			User::Leave(KErrNotSupported);
+		}
+	}
+	
+const TDesC& CCmdVar::Name() const
+	{
+	_LIT(KName, "var");
+	return KName;
+	}
+
+void CCmdVar::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgVariable, "variable");
+	_LIT(KArgOperation, "operation");
+	_LIT(KArgArgument, "argument");
+
+	aArguments.AppendStringL(iVar1, KArgVariable);
+	aArguments.AppendEnumL((TInt&)iOperation, KArgOperation);
+	aArguments.AppendStringL(iArg, KArgArgument);
+	}
+
+
+//
+// CCmdSource.
+//
+
+CCommandBase* CCmdSource::NewLC()
+	{
+	CCmdSource* self = new (ELeave) CCmdSource();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSource::~CCmdSource()
+	{
+	delete iArgs;
+	delete iScriptData;
+	delete iParser;
+	}
+
+CCmdSource::CCmdSource() : CCommandBase(EManualComplete)
+	{
+	}
+
+void CCmdSource::DoRunL()
+	{
+	TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr());
+	TBool helpPrinted;
+	iScriptData = CShell::ReadScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, helpPrinted);
+
+	if (helpPrinted)
+		{
+		Complete();
+		}
+	else
+		{
+		TUint mode = CParser::EExportLineNumbers;
+		if (iKeepGoing)
+			{
+			mode |= CParser::EKeepGoing;
+			}
+		iParser = CParser::NewL(mode, *iScriptData, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this);
+		iParser->Start();
+		}
+	}
+	
+const TDesC& CCmdSource::Name() const
+	{
+	_LIT(KName, "source");
+	return KName;
+	}
+
+void CCmdSource::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFileName, "script_file_name");
+	aArguments.AppendFileNameL(iFileName, KArgFileName);
+
+	_LIT(KArgArgs, "script_args");
+	aArguments.AppendStringL(iArgs, KArgArgs);
+	}
+
+void CCmdSource::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptKeepGoing, "keep-going");
+	aOptions.AppendBoolL(iKeepGoing, KOptKeepGoing);
+	}
+
+void CCmdSource::HandleParserComplete(CParser&, const TError& aError)
+	{
+	TInt err = aError.Error();
+	if (err < 0)
+		{
+		aError.Report();
+		const TDesC& scriptPath = Env().GetAsDes(KScriptPath);
+		const TDesC& scriptName = Env().GetAsDes(KScriptName);
+		PrintError(err, _L("Aborted \"%S\" at line %d"), &aError.ScriptFileName(), aError.ScriptLineNumber());
+		}
+	Complete(err);
+	}
+
+//
+// CCmdStart.
+//
+	
+CCommandBase* CCmdStart::NewLC()
+	{
+	CCmdStart* self = new (ELeave) CCmdStart();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdStart::~CCmdStart()
+	{
+	delete iExe;
+	delete iCommandLine;
+	}
+
+CCmdStart::CCmdStart()
+	{
+	}
+
+void CCmdStart::DoRunL()
+	{
+	if (iRendezvous && iWait)
+		{
+		LeaveIfErr(KErrArgument, _L("--rendezvous cannot be used with --wait"));
+		}
+	if (iTimeout && !(iRendezvous || iWait))
+		{
+		LeaveIfErr(KErrArgument, _L("--timeout must be used with either --rendezvous or --wait"));
+		}
+	if (iMeasure && !(iRendezvous || iWait))
+		{
+		LeaveIfErr(KErrArgument, _L("--measure must be used with either --rendezvous or --wait"));
+		}
+
+	TRequestStatus waitStatus;
+	RProcess process;
+	LeaveIfErr(process.Create(*iExe, iCommandLine ? *iCommandLine : KNullDesC(), EOwnerThread), _L("Couldn't create \"%S\" process"), iExe);
+	CleanupClosePushL(process);
+
+	if (iRendezvous)
+		{
+		process.Rendezvous(waitStatus);
+		if (waitStatus != KRequestPending)
+			{
+			User::WaitForRequest(waitStatus);
+			process.Kill(0);
+			LeaveIfErr(waitStatus.Int(), _L("Failed to log on to process"));
+			}
+		}
+	else if (iWait)
+		{
+		process.Logon(waitStatus);
+		if (waitStatus != KRequestPending)
+			{
+			User::WaitForRequest(waitStatus);
+			process.Kill(0);
+			LeaveIfErr(waitStatus.Int(), _L("Failed to log on to process"));
+			}
+		}
+
+	TRequestStatus timerStat;
+	RTimer timer;
+	if (iTimeout)
+		{
+		User::LeaveIfError(timer.CreateLocal());
+		CleanupClosePushL(timer);
+		timer.After(timerStat, iTimeout * 1000 * 1000);
+		}
+
+	TUint32 startTime = 0, endTime = 0;
+	if (iMeasure) startTime = User::NTickCount();
+
+	process.Resume();
+
+	if (iTimeout)
+		{
+		timer.After(timerStat, iTimeout * 1000 * 1000);
+		User::WaitForRequest(waitStatus, timerStat);
+		if (iMeasure) endTime = User::NTickCount();
+
+		if (waitStatus == KRequestPending)
+			{
+			// Then the timer expired
+			if (iRendezvous)
+				{
+				process.RendezvousCancel(waitStatus);
+				}
+			else if (iWait)
+				{
+				process.LogonCancel(waitStatus);
+				}
+			User::WaitForRequest(waitStatus);
+			LeaveIfErr(KErrTimedOut, _L("Timed out waiting for \"%S\""), iExe);
+			}
+		else
+			{
+			timer.Cancel();
+			User::WaitForRequest(timerStat);
+			}
+
+		CleanupStack::PopAndDestroy(&timer);
+		}
+	else if (iRendezvous || iWait)
+		{
+		User::WaitForRequest(waitStatus);
+		if (iMeasure) endTime = User::NTickCount();
+		}
+
+	CleanupStack::PopAndDestroy(&process);
+
+	if (iMeasure)
+		{
+		TUint32 elapsed = endTime - startTime;
+		elapsed *= NanoTickPeriod();
+		TBuf<50> timeBuf;
+		FormatTime(elapsed, timeBuf);
+		Write(timeBuf);
+		Write(_L("\r\n"));
+		}
+
+	if (iRendezvous)
+		{
+		LeaveIfErr(waitStatus.Int(), _L("Error returned from rendezvous"));
+		}
+	if (iWait)
+		{
+		LeaveIfErr(waitStatus.Int(), _L("Error returned from logon"));
+		}
+	}
+	
+const TDesC& CCmdStart::Name() const
+	{
+	_LIT(KName, "start");
+	return KName;
+	}
+
+void CCmdStart::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KExeName, "exe-name");
+	_LIT(KArgs, "arguments");
+
+	aArguments.AppendStringL(iExe, KExeName);
+	aArguments.AppendStringL(iCommandLine, KArgs);
+	}
+
+void CCmdStart::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptRendezvous, "rendezvous");
+	_LIT(KOptWait, "wait");
+	_LIT(KOptTimeout, "timeout");
+	_LIT(KOptMeasure, "measure");
+
+	aOptions.AppendBoolL(iRendezvous, KOptRendezvous);
+	aOptions.AppendBoolL(iWait, KOptWait);
+	aOptions.AppendIntL(iTimeout, KOptTimeout);
+	aOptions.AppendBoolL(iMeasure, KOptMeasure);
+	}
+
+
+//
+// CCmdCompare.
+//
+	
+CCommandBase* CCmdCompare::NewLC()
+	{
+	CCmdCompare* self = new (ELeave) CCmdCompare();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdCompare::~CCmdCompare()
+	{
+	}
+
+CCmdCompare::CCmdCompare()
+	{
+	}
+
+void CCmdCompare::DoRunL()
+	{
+	RFile file1;
+	LeaveIfErr(file1.Open(FsL(), iFileName1, EFileRead), _L("Couldn't open \"%S\" for reading"), &iFileName1);
+	CleanupClosePushL(file1);
+	RFile file2;
+	LeaveIfErr(file2.Open(FsL(), iFileName2, EFileRead), _L("Couldn't open \"%S\" for reading"), &iFileName2);
+	CleanupClosePushL(file2);
+
+	TBool same(ETrue);
+	FOREVER
+		{
+		TBuf8<KBlockSize> buf1;
+		TBuf8<KBlockSize> buf2;
+		LeaveIfErr(file1.Read(buf1), _L("Couldn't read \"%S\""), &iFileName1);
+		LeaveIfErr(file2.Read(buf2), _L("Couldn't read \"%S\""), &iFileName2);
+		if (buf1 != buf2)
+			{
+			same = EFalse;
+			break;
+			}
+		if (buf1.Length() == 0)
+			{
+			break;
+			}
+		}
+
+	CleanupStack::PopAndDestroy(2, &file1);
+	if (iVerbose)
+		{
+		if (same)
+			{
+			Write(_L("Identical\r\n"));
+			}
+		else
+			{
+			Write(_L("Different\r\n"));
+			}
+		}
+	Complete(!same);
+	}
+	
+const TDesC& CCmdCompare::Name() const
+	{
+	_LIT(KName, "compare");
+	return KName;
+	}
+
+void CCmdCompare::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KFileName1, "file_name_1");
+	_LIT(KFileName2, "file_name_2");
+	aArguments.AppendFileNameL(iFileName1, KFileName1);
+	aArguments.AppendFileNameL(iFileName2, KFileName2);
+	}
+
+void CCmdCompare::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	}
+
+
+//
+// CCmdTime.
+//
+	
+CCommandBase* CCmdTime::NewLC()
+	{
+	CCmdTime* self = new (ELeave) CCmdTime();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTime::~CCmdTime()
+	{
+	delete iParser;
+	delete iCommandLine;
+	}
+
+CCmdTime::CCmdTime() : CCommandBase(EManualComplete), iRepeatCount(1)
+	{
+	}
+
+void CCmdTime::DoRunL()
+	{
+	NextIterationL();
+	}
+
+void CCmdTime::NextIterationL()
+	{
+	delete iParser;
+	iParser = NULL;
+	iParser = CParser::NewL(CParser::ENormal, *iCommandLine, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this);
+	iCountBefore = iFastCounter ? User::FastCounter() : User::NTickCount();
+	iParser->Start();
+	}
+	
+const TDesC& CCmdTime::Name() const
+	{
+	_LIT(KName, "time");
+	return KName;
+	}
+
+void CCmdTime::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgs, "command");
+	aArguments.AppendStringL(iCommandLine, KArgs);
+	}
+
+void CCmdTime::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptFastCounter, "fast-counter");
+	_LIT(KOptRepeatCount, "repeat");
+	aOptions.AppendBoolL(iHuman, KOptHuman);
+	aOptions.AppendBoolL(iFastCounter, KOptFastCounter);
+	aOptions.AppendIntL(iRepeatCount, KOptRepeatCount);
+	}
+
+void CCmdTime::HandleParserComplete(CParser&, const TError& aError)
+	{
+	if (aError.Error() < 0)
+		{
+		aError.Report();
+		}
+
+	TUint32 countAfter = iFastCounter ? User::FastCounter() : User::NTickCount();
+	
+	TUint64 difference;
+	if (iFastCounter)
+		{
+		difference = FastCounterCountsUp() ? (countAfter - iCountBefore) : (iCountBefore - countAfter);
+		difference *= 1000000;
+		difference /= FastCounterFrequency();
+		}
+	else
+		{
+		difference = countAfter - iCountBefore;
+		difference *= NanoTickPeriod();
+		}
+
+	if (Stdout().AttachedToConsole())
+		{
+		TPoint cursorPos;
+		Stdout().GetCursorPos(cursorPos);
+		if (cursorPos.iX != 0)
+			{
+			Write(KNewLine);
+			}
+		}
+
+	if (iHuman)
+		{
+		TBuf<256> timeBuf;
+		FormatTime(difference, timeBuf);
+		timeBuf.Append(KNewLine);
+		Write(timeBuf);
+		}
+	else if (iRepeatCount == 1)
+		{
+		// Don't print individual times if we asked for non-human readable output. (If you want that behaviour, use "repeat n time xyz...")
+		Printf(_L("%Lu\r\n"), difference);
+		}
+	
+	iTotalTime += difference;
+	iIteration++;
+	if (iRepeatCount > 1 && iIteration == iRepeatCount)
+		{
+		// Need to print the average
+		difference = iTotalTime / iRepeatCount;
+		if (iHuman)
+			{
+			TBuf<256> timeBuf;
+			timeBuf.Append(_L("Average: "));
+			FormatTime(difference, timeBuf);
+			timeBuf.Append(KNewLine);
+			Write(timeBuf);
+			}
+		else
+			{
+			Printf(_L("%Lu\r\n"), difference);
+			}
+		}
+	if (aError.Error() < 0 || iIteration == iRepeatCount)
+		{
+		Complete(aError.Error());
+		}
+	else
+		{
+		// Rerun the fun
+		TRAPD(err, NextIterationL());
+		if (err) Complete(err);
+		}
+	}
+
+
+//
+// CCmdRepeat.
+//
+	
+CCommandBase* CCmdRepeat::NewLC()
+	{
+	CCmdRepeat* self = new (ELeave) CCmdRepeat();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRepeat::~CCmdRepeat()
+	{
+	delete iParser;
+	delete iCommandLine;
+	}
+
+CCmdRepeat::CCmdRepeat() : CCommandBase(EManualComplete)
+	{
+	}
+
+void CCmdRepeat::DoRunL()
+	{
+	if (iNumRepeats == 0)
+		{
+		iForever = ETrue;
+		}
+
+	CreateParserL();
+	}
+	
+const TDesC& CCmdRepeat::Name() const
+	{
+	_LIT(KName, "repeat");
+	return KName;
+	}
+
+void CCmdRepeat::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCount, "count");
+	_LIT(KArgs, "command");
+
+	aArguments.AppendUintL(iNumRepeats, KCount);
+	aArguments.AppendStringL(iCommandLine, KArgs);
+	}
+
+void CCmdRepeat::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptKeepGoing, "keep-going");
+	_LIT(KOptWait, "wait");
+
+	aOptions.AppendBoolL(iKeepGoing, KOptKeepGoing);
+	aOptions.AppendIntL(iWaitTime, KOptWait);
+	}
+
+void CCmdRepeat::HandleParserComplete(CParser&, const TError& aError)
+	{
+	TRAPD(err, HandleParserCompleteL(aError));
+	if (err)
+		{
+		Complete(err);
+		}
+	}
+
+void CCmdRepeat::HandleParserCompleteL(const TError& aError)
+	{
+	if (aError.Error() < 0)
+		{
+		aError.Report();
+		}
+
+	if (((aError.Error() == KErrNone) || iKeepGoing) && ((++iCount < iNumRepeats) || iForever))
+		{
+		delete iParser;
+		iParser = NULL;
+		if (iWaitTime) User::After(iWaitTime * 1000);
+		CreateParserL();
+		}
+	else
+		{
+		Complete(aError.Error());
+		}
+	}
+
+void CCmdRepeat::CreateParserL()
+	{
+	TBuf<32> buf;
+	buf.AppendNum(iCount);
+	Env().SetL(KRepeatCount, buf);
+	iParser = CParser::NewL(iKeepGoing ? CParser::EKeepGoing : CParser::ENormal, *iCommandLine, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this);
+	iParser->Start();
+	}
+
+
+//
+// CCmdDebug.
+//
+	
+CCommandBase* CCmdDebug::NewLC()
+	{
+	CCmdDebug* self = new (ELeave) CCmdDebug();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdDebug::~CCmdDebug()
+	{
+	delete iScriptData;
+	delete iParser;
+	delete iArgs;
+	}
+
+CCmdDebug::CCmdDebug() : CCommandBase(EManualComplete)
+	{
+	}
+
+void CCmdDebug::DoRunL()
+	{
+	TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr());
+	TBool helpPrinted;
+	iScriptData = CShell::ReadScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, helpPrinted);
+	if (helpPrinted)
+		{
+		Complete();
+		}
+	else
+		{
+		TUint mode = CParser::EDebug | CParser::EExportLineNumbers;
+		if (iKeepGoing)
+			{
+			mode |= CParser::EKeepGoing;
+			}
+		iParser = CParser::NewL(mode, *iScriptData, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this);
+		iParser->Start();
+		}
+	}
+	
+const TDesC& CCmdDebug::Name() const
+	{
+	_LIT(KName, "debug");
+	return KName;
+	}
+
+void CCmdDebug::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgFileName, "script_file_name");
+	aArguments.AppendFileNameL(iFileName, KArgFileName);
+
+	_LIT(KArgArgs, "script_args");
+	aArguments.AppendStringL(iArgs, KArgArgs);
+	}
+
+void CCmdDebug::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptKeepGoing, "keep-going");
+	aOptions.AppendBoolL(iKeepGoing, KOptKeepGoing);
+	}
+
+void CCmdDebug::HandleParserComplete(CParser&, const TError& aError)
+	{
+	Printf(_L("Completed with %d (%S)\r\n"), aError.Error(), Stringify::Error(aError.Error()));
+	Complete(aError.Error());
+	}
+
+void CCmdDebug::AboutToExecuteLine(const TDesC& aOrignalLine, const TDesC& aExpandedLine)
+	{
+	Write(aOrignalLine);
+	Write(KNewLine);
+	TRAP_IGNORE(InteractL(aExpandedLine));
+	}
+
+void CCmdDebug::LineReturned(TInt aError)
+	{
+	Printf(_L("Returned %d (%S)\r\n"), aError, Stringify::Error(aError));
+	}
+
+void CCmdDebug::InteractL(const TDesC& aExpandedLine)
+	{
+	FOREVER
+		{
+		TBuf<1> command;
+		ReadL(command);
+
+		_LIT(KStep, "s");
+		_LIT(KExpand, "x");
+
+		if (command == KStep)
+			{
+			return;
+			}
+		else if (command == KExpand)
+			{
+			Write(aExpandedLine);
+			Write(KNewLine);
+			}
+		else
+			{
+			Write(_L("Unknown command\r\n"));
+			}
+		}
+	}
+
+
+//
+// CCmdReadMem.
+//
+
+CCommandBase* CCmdReadMem::NewLC()
+	{
+	CCmdReadMem* self = new(ELeave) CCmdReadMem();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdReadMem::~CCmdReadMem()
+	{
+	}
+
+CCmdReadMem::CCmdReadMem()
+	{
+	}
+
+const TDesC& CCmdReadMem::Name() const
+	{
+	_LIT(KName, "readmem");
+	return KName;
+	}
+
+void CCmdReadMem::DoRunL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	LoadMemoryAccessL();
+
+	if (iFileName.Length() > 0)
+		{
+		LeaveIfErr(iFile.Create(FsL(), iFileName, EFileWrite), _L("Unable to create \"%S\""), &iFileName);
+		}
+
+	if (!iOptions.IsPresent(&iThreadId))
+		{
+		iThreadId = RThread().Id();
+		}
+
+	TBuf8<KBlockSize> buf;
+	TInt bytesRead = 0;
+	TInt dumpPos = 0;
+	while ((TUint)bytesRead < iSize)
+		{
+		buf.Zero();
+		TThreadMemoryAccessParamsBuf memoryAccessParamsBuf;
+		TThreadMemoryAccessParams& memoryAccessParams = memoryAccessParamsBuf();
+		memoryAccessParams.iId = iThreadId;
+		memoryAccessParams.iAddr = (TUint8*)iAddress + bytesRead;
+		TInt bytesToRead = iSize - bytesRead;
+		if (bytesToRead > KBlockSize)
+			{
+			bytesToRead = KBlockSize;
+			}
+		memoryAccessParams.iSize = bytesToRead;
+		User::LeaveIfError(iMemAccess.GetThreadMem(memoryAccessParamsBuf, buf));
+		if (iFile.SubSessionHandle())
+			{
+			User::LeaveIfError(iFile.Write(buf));
+			}
+		else
+			{
+			Dump(buf, *this, dumpPos);
+			}
+		bytesRead += bytesToRead;
+		}
+
+#else
+	PrintError(KErrNotSupported, _L("Unable to read memory because fshell was not built with FSHELL_MEMORY_ACCESS_SUPPORT defined. That probably means this plaform doesn't support the MemoryAccess device driver."));
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+void CCmdReadMem::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdOptThreadId, "thread_id");
+	aOptions.AppendIntL(iThreadId, KCmdOptThreadId);
+	}
+
+void CCmdReadMem::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdArgAddress, "address");
+	_LIT(KCmdArgSize, "size");
+	_LIT(KCmdArgFileName, "file_name");
+
+	aArguments.AppendUintL(iAddress, KCmdArgAddress);
+	aArguments.AppendUintL(iSize, KCmdArgSize);
+	aArguments.AppendFileNameL(iFileName, KCmdArgFileName);
+	}
+
+
+//
+// CCmdE32Header.
+//
+
+CCommandBase* CCmdE32Header::NewLC()
+	{
+	CCmdE32Header* self = new(ELeave) CCmdE32Header();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdE32Header::~CCmdE32Header()
+	{
+	delete iFormatter;
+	}
+
+CCmdE32Header::CCmdE32Header()
+	{
+	}
+
+const TDesC& CCmdE32Header::Name() const
+	{
+	_LIT(KName, "e32header");
+	return KName;
+	}
+
+#define CASE_LIT2(x, y) case x: { _LIT(KName, #y); return &KName; }
+const TDesC* CompressionType(TUint aType)
+	{
+	switch (aType)
+		{
+		CASE_LIT2(0, KFormatNotCompressed)
+		CASE_LIT2(0x101F7AFC, KUidCompressionDeflate)
+		CASE_LIT2(0x102822AA, KUidCompressionBytePair)
+		default:
+			_LIT(KUnknown, "?");
+			return &KUnknown;
+		}
+	}
+
+void CCmdE32Header::DoRunL()
+	{
+	if (iXip && iNotXip)
+		{
+		LeaveIfErr(KErrArgument, _L("--xip and --not-xip options are mutually exclusive"));
+		}
+
+	RFile file;
+	CleanupClosePushL(file);
+	LeaveIfErr(file.Open(FsL(), iFileName, EFileRead), _L("Couldn't open \"%S\" for reading"), &iFileName);
+
+	iFormatter = CTextFormatter::NewL(Stdout());
+	IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x100);
+
+	if ((Fs().IsFileInRom(iFileName) || iXip) && !iNotXip)
+		{
+		TAny* ptr = Fs().IsFileInRom(iFileName);
+		if (ptr)
+			{
+			buf->AppendFormatL(_L("ROM file address:\t0x%08x\r\n"), ptr);
+			}
+		TRomImageHeader imageHeader;
+		TPckg<TRomImageHeader> pckg(imageHeader);
+		LeaveIfErr(file.Read(pckg, sizeof(TRomImageHeader)), _L("Couldn't read E32 image header"));
+		buf->AppendFormatL(_L("UIDs:\t0x%08x 0x%08x 0x%08x\r\n"), imageHeader.iUid1, imageHeader.iUid2, imageHeader.iUid3);
+		buf->AppendFormatL(_L("UID checksum:\t0x%08x\r\n"), imageHeader.iUidChecksum);
+		buf->AppendFormatL(_L("Entry point offset:\t0x%08x\r\n"), imageHeader.iEntryPoint);
+		buf->AppendFormatL(_L("Code address:\t0x%08x\r\n"), imageHeader.iCodeAddress);
+		buf->AppendFormatL(_L("Data address:\t0x%08x\r\n"), imageHeader.iDataAddress);
+		buf->AppendFormatL(_L("Code size:\t%d\r\n"), imageHeader.iCodeSize);
+		buf->AppendFormatL(_L("Text size:\t%d\r\n"), imageHeader.iTextSize);
+		buf->AppendFormatL(_L("Data size:\t%d\r\n"), imageHeader.iDataSize);
+		buf->AppendFormatL(_L("BSS size:\t%d\r\n"), imageHeader.iBssSize);
+		buf->AppendFormatL(_L("Minimum heap size:\t%d\r\n"), imageHeader.iHeapSizeMin);
+		buf->AppendFormatL(_L("Maximum heap size:\t%d\r\n"), imageHeader.iHeapSizeMax);
+		buf->AppendFormatL(_L("Stack size:\t%d\r\n"), imageHeader.iStackSize);
+		buf->AppendFormatL(_L("DLL ref table address:\t0x%08x\r\n"), imageHeader.iDllRefTable);
+		buf->AppendFormatL(_L("Export dir count:\t%d\r\n"), imageHeader.iExportDirCount);
+		buf->AppendFormatL(_L("Export dir address:\t0x%08x\r\n"), imageHeader.iExportDir);
+		buf->AppendFormatL(_L("Secure ID:\t0x%08x\r\n"), imageHeader.iS.iSecureId);
+		buf->AppendFormatL(_L("Vendor ID:\t0x%08x\r\n"), imageHeader.iS.iVendorId);
+		buf->AppendFormatL(_L("Capabilities:\t0x%08x 0x%08x\r\n"), imageHeader.iS.iCaps[0], imageHeader.iS.iCaps[1]);
+		TInt majorVersion = imageHeader.iToolsVersion.iMajor;
+		TInt minorVersion = imageHeader.iToolsVersion.iMinor;
+		TInt buildVersion = imageHeader.iToolsVersion.iBuild;
+		buf->AppendFormatL(_L("Tools version:\t%d.%d (%d)\r\n"), majorVersion, minorVersion, buildVersion);
+		buf->AppendFormatL(_L("Flags:\t0x%08x\r\n"), imageHeader.iFlags);
+		buf->AppendFormatL(_L("Process priority:\t%d\r\n"), imageHeader.iPriority);
+		buf->AppendFormatL(_L("Data BSS linear base:\t0x%08x\r\n"), imageHeader.iDataBssLinearBase);
+		buf->AppendFormatL(_L("Next extension:\t0x%08x\r\n"), imageHeader.iNextExtension);
+		buf->AppendFormatL(_L("Hardware variant:\t0x%08x\r\n"), imageHeader.iHardwareVariant);
+		buf->AppendFormatL(_L("Total data size:\t%d\r\n"), imageHeader.iTotalDataSize);
+		buf->AppendFormatL(_L("Module version:\t0x%08x (%d.%d)\r\n"), imageHeader.iModuleVersion, imageHeader.iModuleVersion>>16, imageHeader.iModuleVersion&0xFFFF);
+		buf->AppendFormatL(_L("Exception descriptor:\t0x%08x\r\n"), imageHeader.iExceptionDescriptor);
+		}
+	else
+		{
+		E32ImageHeaderV* imageHeader = new(ELeave) E32ImageHeaderV;
+		CleanupStack::PushL(imageHeader);
+		TPckg<E32ImageHeaderV> pckg(*imageHeader);
+		LeaveIfErr(file.Read(pckg, sizeof(E32ImageHeaderV)), _L("Couldn't read E32 image header"));
+		buf->AppendFormatL(_L("UIDs:\t0x%08x 0x%08x 0x%08x\r\n"), imageHeader->iUid1, imageHeader->iUid2, imageHeader->iUid3);
+		buf->AppendFormatL(_L("UID checksum:\t0x%08x\r\n"), imageHeader->iUidChecksum);
+		buf->AppendFormatL(_L("Header CRC:\t0x%08x\r\n"), imageHeader->iHeaderCrc);
+		buf->AppendFormatL(_L("Module version:\t0x%08x (%d.%d)\r\n"), imageHeader->iModuleVersion, imageHeader->iModuleVersion>>16, imageHeader->iModuleVersion&0xFFFF);
+		buf->AppendFormatL(_L("Compression type:\t0x%08x (%S)\r\n"), imageHeader->iCompressionType, CompressionType(imageHeader->iCompressionType));
+		TInt majorVersion = imageHeader->iToolsVersion.iMajor;
+		TInt minorVersion = imageHeader->iToolsVersion.iMinor;
+		TInt buildVersion = imageHeader->iToolsVersion.iBuild;
+		buf->AppendFormatL(_L("Tools version:\t%d.%d (%d)\r\n"), majorVersion, minorVersion, buildVersion);
+		buf->AppendFormatL(_L("Build time:\t0x%08x 0x%08x\r\n"), imageHeader->iTimeLo, imageHeader->iTimeHi);
+		buf->AppendFormatL(_L("Flags:\t0x%08x\r\n"), imageHeader->iFlags);
+		buf->AppendFormatL(_L("Code size:\t%d\r\n"), imageHeader->iCodeSize);
+		buf->AppendFormatL(_L("Minimum heap size:\t%d\r\n"), imageHeader->iHeapSizeMin);
+		buf->AppendFormatL(_L("Maximum heap size:\t%d\r\n"), imageHeader->iHeapSizeMax);
+		buf->AppendFormatL(_L("Stack size:\t%d\r\n"), imageHeader->iStackSize);
+		buf->AppendFormatL(_L("BSS size:\t%d\r\n"), imageHeader->iBssSize);
+		buf->AppendFormatL(_L("Entry point offset:\t0x%08x\r\n"), imageHeader->iEntryPoint);
+		buf->AppendFormatL(_L("Code base:\t0x%08x\r\n"), imageHeader->iCodeBase);
+		buf->AppendFormatL(_L("Data base:\t0x%08x\r\n"), imageHeader->iDataBase);
+		buf->AppendFormatL(_L("DLL ref table count:\t%d\r\n"), imageHeader->iDllRefTableCount);
+		buf->AppendFormatL(_L("Export dir offset:\t0x%08x\r\n"), imageHeader->iExportDirOffset);
+		buf->AppendFormatL(_L("Export dir count:\t%d\r\n"), imageHeader->iExportDirCount);
+		buf->AppendFormatL(_L("Text size:\t%d\r\n"), imageHeader->iTextSize);
+		buf->AppendFormatL(_L("Code offset:\t0x%08x\r\n"), imageHeader->iCodeOffset);
+		buf->AppendFormatL(_L("Data offset:\t0x%08x\r\n"), imageHeader->iDataOffset);
+		buf->AppendFormatL(_L("Import offset:\t0x%08x\r\n"), imageHeader->iImportOffset);
+		buf->AppendFormatL(_L("Code reloc offset:\t0x%08x\r\n"), imageHeader->iCodeRelocOffset);
+		buf->AppendFormatL(_L("Data reloc offset:\t0x%08x\r\n"), imageHeader->iDataRelocOffset);
+		TInt temp; // Why use a temp here?
+		temp = imageHeader->iProcessPriority;
+		buf->AppendFormatL(_L("Process priority:\t%d\r\n"), temp);
+		temp = imageHeader->iCpuIdentifier;
+		buf->AppendFormatL(_L("CPU identifier:\t%d\r\n"), temp);
+		buf->AppendFormatL(_L("Uncompressed size:\t%d\r\n"), imageHeader->iUncompressedSize);
+		buf->AppendFormatL(_L("Secure ID:\t0x%08x\r\n"), imageHeader->iS.iSecureId);
+		buf->AppendFormatL(_L("Vendor ID:\t0x%08x\r\n"), imageHeader->iS.iVendorId);
+		buf->AppendFormatL(_L("Capabilities:\t0x%08x 0x%08x\r\n"), imageHeader->iS.iCaps[0], imageHeader->iS.iCaps[1]);
+		buf->AppendFormatL(_L("Exception descriptor:\t0x%08x\r\n"), imageHeader->iExceptionDescriptor);
+		buf->AppendFormatL(_L("Spare2:\t0x%08x\r\n"), imageHeader->iSpare2);
+		temp = imageHeader->iExportDescSize;
+		buf->AppendFormatL(_L("Export description size:\t%d\r\n"), temp);
+		temp = imageHeader->iExportDescType;
+		buf->AppendFormatL(_L("Export description type:\t%d\r\n"), temp);
+		temp = imageHeader->iExportDesc[0];
+		buf->AppendFormatL(_L("Export description:\t%d\r\n"), temp);
+		CleanupStack::PopAndDestroy(imageHeader);
+		}
+
+	iFormatter->TabulateL(0, 2, buf->Descriptor());
+	Write(iFormatter->Descriptor());
+	CleanupStack::PopAndDestroy(2, &file);
+	}
+
+void CCmdE32Header::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdOptXip, "xip");
+	_LIT(KCmdOptNotXip, "not-xip");
+
+	aOptions.AppendBoolL(iXip, KCmdOptXip);
+	aOptions.AppendBoolL(iNotXip, KCmdOptNotXip);
+	}
+
+void CCmdE32Header::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdArgFileName, "file_name");
+	aArguments.AppendFileNameL(iFileName, KCmdArgFileName);
+	}
+
+
+//
+// CCmdObjInfo.
+//
+
+CCommandBase* CCmdObjInfo::NewLC()
+	{
+	CCmdObjInfo* self = new(ELeave) CCmdObjInfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdObjInfo::~CCmdObjInfo()
+	{
+	}
+
+CCmdObjInfo::CCmdObjInfo()
+	{
+	}
+
+const TDesC& CCmdObjInfo::Name() const
+	{
+	_LIT(KName, "objinfo");
+	return KName;
+	}
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+
+#define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
+#define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
+
+EXPORT_C const TDesC* StringifyObjectType(TObjectType aObjectType)
+	{
+	switch (aObjectType)
+		{
+		CASE_RETURN_LIT(EThread);
+		CASE_RETURN_LIT(EProcess);
+		CASE_RETURN_LIT(EChunk);
+		CASE_RETURN_LIT(ELibrary);
+		CASE_RETURN_LIT(ESemaphore);
+		CASE_RETURN_LIT(EMutex);
+		CASE_RETURN_LIT(ETimer);
+		CASE_RETURN_LIT(EServer);
+		CASE_RETURN_LIT(ESession);
+		CASE_RETURN_LIT(ELogicalDevice);
+		CASE_RETURN_LIT(EPhysicalDevice);
+		CASE_RETURN_LIT(ELogicalChannel);
+		CASE_RETURN_LIT(EChangeNotifier);
+		CASE_RETURN_LIT(EUndertaker);
+		CASE_RETURN_LIT(EMsgQueue);
+		CASE_RETURN_LIT(EPropertyRef);
+		CASE_RETURN_LIT(ECondVar);
+		CASE_RETURN_LIT(EIpcMessageD);
+		CASE_RETURN_LIT(EIpcMessage);
+		CASE_RETURN_LIT(EIpcClient);
+		DEFAULT_RETURN_LIT("*** OBJECT TYPE UNKNOWN ***");
+		}
+	}
+
+void CCmdObjInfo::PrintObjectDetailsL(TUint aObjectAddress)
+	{
+	TObjectType objectType;
+	TInt err = iMemAccess.GetObjectType((TUint8*)aObjectAddress, objectType);
+	if (err == KErrNone)
+		{
+		TObjectKernelInfo objectInfo;
+		TPckg<TObjectKernelInfo> objectInfoPckg(objectInfo);
+		err = iMemAccess.GetObjectInfo(objectType, (TUint8*)(aObjectAddress), objectInfoPckg);
+		if (err == KErrNone)
+			{
+			TFullName fullName;
+			fullName.Copy(objectInfo.iFullName);
+			Printf(_L("0x%08x %2d %S (type=%d) %S\r\n"), aObjectAddress, objectInfo.iAccessCount, StringifyObjectType(objectType), objectType, &fullName);
+			}
+		else
+			{
+			PrintWarning(_L("Couldn't read details of %S 0x%08x : %S(%d)"), StringifyObjectType(objectType), aObjectAddress, Stringify::Error(err), err);
+			}
+		}
+	else
+		{
+		PrintWarning(_L("Couldn't find type of object 0x%08x : %S(%d)"), aObjectAddress, Stringify::Error(err), err);
+		}
+
+	if (iReferencers)
+		{
+		PrintObjectReferencersL(aObjectAddress);
+		}
+	}
+
+void CCmdObjInfo::PrintObjectReferencersL(TUint aObjectAddress)
+	{
+	TInt err = KErrNone;
+	TInt bufSize = 256;
+	HBufC8* idBuf;
+	do
+		{
+		idBuf = HBufC8::NewLC(bufSize);
+		TPtr8 idPtr(idBuf->Des());
+		err = iMemAccess.GetHandleOwners((TUint8*)aObjectAddress, idPtr);
+		if (err == KErrOverflow)
+			{
+			CleanupStack::PopAndDestroy(idBuf);
+			bufSize *= 2;
+			}
+		}
+		while (err == KErrOverflow);
+
+	const TInt numIds = idBuf->Length() / sizeof(TUint);
+	if (numIds > 0)
+		{
+		Write(_L("Referenced by:\r\n"));
+		}
+	for (TInt i = 0; i < numIds; i++)
+		{
+		TUint id = ((TUint*)idBuf->Ptr())[i];
+		TBool isThread = ETrue;
+		RHandleBase h;
+		TInt err = ((RThread&)h).Open(TThreadId(id));
+		if (err)
+			{
+			// Maybe it's a process id instead.
+			isThread = EFalse;
+			err = ((RProcess&)h).Open(TProcessId(id));
+			}
+
+		if (err)
+			{
+			PrintWarning(_L("Unable to open thread or process for id %d: %S (%d)"), id, Stringify::Error(err), err);
+			}
+		else
+			{
+			TFullName name = h.FullName();
+			_LIT(KThread,  "\tthread:  ");
+			_LIT(KProcess, "\tprocess: ");
+			Printf(_L("%S%u\t%S\r\n"), isThread ? &KThread : &KProcess, id, &name);
+			}
+		}
+
+	CleanupStack::PopAndDestroy(idBuf);
+	}
+
+void CCmdObjInfo::PrintReferencedObjectDetailsL(TOwnerType aOwnerType, TUint aId)
+	{
+	TInt err = KErrNone;
+	TInt bufSize = 256;
+
+	HBufC8* addressesBuf;
+	do
+		{
+		addressesBuf = HBufC8::NewLC(bufSize);
+		TPtr8 addressesPtr(addressesBuf->Des());
+		if (aOwnerType == EOwnerProcess)
+			{
+			err = iMemAccess.GetProcessHandles(aId, addressesPtr);
+			}
+		else
+			{
+			err = iMemAccess.GetThreadHandles(aId, addressesPtr);
+			}
+		if (err == KErrOverflow)
+			{
+			CleanupStack::PopAndDestroy(addressesBuf);
+			bufSize *= 2;
+			}
+		}
+		while (err == KErrOverflow);
+
+	const TInt numAddresses = addressesBuf->Length() / sizeof(TUint32*);
+	if (numAddresses == 0)
+		{
+		Write(_L("No objects found.\r\n"));
+		}
+	else
+		{
+		TUint32* p = (TUint32*)addressesBuf->Ptr();
+		TInt offset = 0;
+		while (offset < numAddresses)
+			{
+			TUint32* ptr = p + offset++;
+			PrintObjectDetailsL(*ptr);
+			}
+		}
+
+	CleanupStack::PopAndDestroy(addressesBuf);
+	}
+
+#endif // FSHELL_MEMORY_ACCESS_SUPPORT
+
+void CCmdObjInfo::DoRunL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	LoadMemoryAccessL();
+
+	if (iObjectAddress)
+		{
+		PrintObjectDetailsL(iObjectAddress);
+		}
+	else if (iProcessId)
+		{
+		if (iAll)
+			{
+			RProcess process;
+			LeaveIfErr(process.Open(iProcessId), _L("Couldn't open process with id \"%u\""), iProcessId);
+			TFullName processName(process.Name());
+			Printf(_L("Objects owned by process \"%S\":\r\n"), &processName);
+			PrintReferencedObjectDetailsL(EOwnerProcess, iProcessId);
+			Write(_L("\r\n"));
+
+			processName.Append(_L("*"));
+			TFindThread threadFinder(processName);
+			RThread thread;
+			TFullName threadName;
+			while (threadFinder.Next(threadName) == KErrNone)
+				{
+				TInt err = thread.Open(threadFinder);
+				if (err)
+					{
+					continue;
+					}
+				Printf(_L("Objects owned by thread \"%S\":\r\n"), &threadName);
+				PrintReferencedObjectDetailsL(EOwnerThread, thread.Id());
+				Write(_L("\r\n"));
+				}
+			}
+		else
+			{
+			PrintReferencedObjectDetailsL(EOwnerProcess, iProcessId);
+			}
+		}
+	else if (iThreadId)
+		{
+		PrintReferencedObjectDetailsL(EOwnerThread, iThreadId);
+		}
+
+#else
+	PrintError(KErrNotSupported, _L("Unable to fetch object information because fshell was not built with FSHELL_MEMORY_ACCESS_SUPPORT defined. That probably means this plaform doesn't support the MemoryAccess device driver."));
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+void CCmdObjInfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdOptReferencers, "referencers");
+	_LIT(KCmdOptProcessId, "process-id");
+	_LIT(KCmdOptThreadId, "thread-id");
+	_LIT(KCmdOptAll, "all");
+
+	aOptions.AppendBoolL(iReferencers, KCmdOptReferencers);
+	aOptions.AppendUintL(iProcessId, KCmdOptProcessId);
+	aOptions.AppendUintL(iThreadId, KCmdOptThreadId);
+	aOptions.AppendBoolL(iAll, KCmdOptAll);
+	}
+
+void CCmdObjInfo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdArgObjectAddress, "object_address");
+	aArguments.AppendUintL(iObjectAddress, KCmdArgObjectAddress);
+	}
+
+//
+// CCmdTouch.
+//
+
+CCommandBase* CCmdTouch::NewLC()
+	{
+	CCmdTouch* self = new(ELeave) CCmdTouch();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTouch::~CCmdTouch()
+	{
+	}
+
+CCmdTouch::CCmdTouch()
+	{
+	}
+
+const TDesC& CCmdTouch::Name() const
+	{
+	_LIT(KName, "touch");
+	return KName;
+	}
+
+void CCmdTouch::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCmdArgFile, "file");
+	aArguments.AppendFileNameL(iFileName, KCmdArgFile);
+	}
+
+void CCmdTouch::DoRunL()
+	{
+	TEntry e;
+	TInt err = FsL().Entry(iFileName, e);
+
+	if (err == KErrNotFound || err == KErrPathNotFound)
+		{
+		RFile file;
+		err = file.Create(Fs(), iFileName, EFileWrite);
+		LeaveIfErr(err, _L("Couldn't create file %S"), &iFileName);
+		file.Close();
+		}
+	else
+		{
+		LeaveIfErr(err, _L("Couldn't get file info for %S"), &iFileName);
+		TTime now;
+		now.UniversalTime();
+		err = Fs().SetEntry(iFileName, now, 0, 0);
+		LeaveIfErr(err, _L("Couldn't update last-modified date for %S"), &iFileName);
+		}
+	}
+
+
+//
+// CCmdDialog.
+//
+
+CCommandBase* CCmdDialog::NewLC()
+	{
+	CCmdDialog* self = new(ELeave) CCmdDialog();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdDialog::~CCmdDialog()
+	{
+	delete iTitle;
+	delete iBody;
+	delete iButton1;
+	delete iButton2;
+	}
+
+CCmdDialog::CCmdDialog() : CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdDialog::Name() const
+	{
+	_LIT(KName, "dialog");
+	return KName;
+	}
+
+CCmdDialog::TMode CCmdDialog::ModeL() const
+	{
+	_LIT(KDialogImpl, "DIALOG_IMPL");
+	_LIT(KImplNotifier, "notifier");
+	_LIT(KImplConsole, "console");
+	_LIT(KImplNull, "null");
+
+	TMode mode = EModeNotifier;
+	if (Env().IsDefined(KDialogImpl))
+		{
+		const TDesC& impl = Env().GetAsDesL(KDialogImpl);
+		if (impl == KImplNotifier)
+			{
+			mode = EModeNotifier;
+			}
+		else if (impl == KImplConsole)
+			{
+			mode = EModeConsole;
+			}
+		else if (impl == KImplNull)
+			{
+			mode = EModeNull;
+			}
+		}
+
+	return mode;
+	}
+
+void CCmdDialog::DoRunL()
+	{
+	if (iTitle == NULL)
+		{
+		iTitle = _L("Attention").AllocL();
+		}
+	if ((iButton1 == NULL) && (iButton2 == NULL))
+		{
+		iButton1 = _L("OK").AllocL();
+		iButton2 = _L("Cancel").AllocL();
+		}
+	else if (iButton2 == NULL)
+		{
+		iButton2 = KNullDesC().AllocL();
+		}
+	else if (iButton1 == NULL)
+		{
+		LeaveIfErr(KErrArgument, _L("First button not specified"));
+		}
+	
+	if (iBody == NULL)
+		{
+		iBody = HBufC::NewL(0x200);
+		Stdin().SetReadMode(RIoReadHandle::EFull);
+		TPtr ptr(iBody->Des());
+		Stdin().ReadL(ptr);
+		}
+	
+	switch (ModeL())
+		{
+		case EModeNotifier:
+			{
+			RNotifier notifier;
+			User::LeaveIfError(notifier.Connect());
+			CleanupClosePushL(notifier);
+
+			TInt buttonValue;
+			TRequestStatus status;
+			notifier.Notify(*iTitle, *iBody, *iButton1, *iButton2, buttonValue, status);
+			User::WaitForRequest(status);
+			Complete(buttonValue);
+
+			CleanupStack::PopAndDestroy(&notifier);
+			break;
+			}
+		case EModeConsole:
+			{
+			RIoConsole console;
+			console.OpenL(IoSession(), Stdin());
+			CleanupClosePushL(console);
+			
+			RIoConsoleWriteHandle consWriter;
+			consWriter.CreateL(IoSession());
+			CleanupClosePushL(consWriter);
+			console.AttachL(consWriter);
+			
+			RIoConsoleReadHandle consReader;
+			consReader.CreateL(IoSession());
+			CleanupClosePushL(consReader);
+			console.AttachL(consReader, RIoEndPoint::EForeground);
+			
+			consWriter.Write(*iTitle);
+			consWriter.Write(KNewLine);
+			consWriter.Write(KNewLine);
+			consWriter.Write(*iBody);
+			consWriter.Write(KNewLine);
+			consWriter.Write(KNewLine);
+				{
+				TBuf<0x100> buf;
+				buf.AppendFormat(_L("%S <enter / select> or %S <any other key> "), iButton1, iButton2);
+				consWriter.Write(buf);
+				}
+			TBuf<1> buf;
+			consReader.ReadL(buf);
+			ClearLineL(consWriter);
+			CleanupStack::PopAndDestroy(3); // consReader, consWriter, console
+			switch (buf[0])
+				{
+				case EKeyEnter:
+	#ifdef FSHELL_PLATFORM_S60
+				case EKeyDevice3:
+	#endif
+					Complete(0);
+					break;
+				default:
+					Complete(1);
+					break;
+				}
+			break;
+			}
+		case EModeNull:
+			{
+			Complete(0);
+			break;
+			}
+		}
+	}
+
+void CCmdDialog::ClearLineL(RIoConsoleWriteHandle& aWriteHandle)
+	{
+	if (aWriteHandle.AttachedToConsole())
+		{
+		TPoint cursorPos;
+		LeaveIfErr(aWriteHandle.GetCursorPos(cursorPos), _L("Couldn't get cursor position"));
+		cursorPos.iX = 0;
+		LeaveIfErr(aWriteHandle.SetCursorPosAbs(cursorPos), _L("Couldn't set cursor position to beginning of line"));
+		LeaveIfErr(aWriteHandle.ClearToEndOfLine(), _L("Couldn't clear to end of line"));
+		}
+	else
+		{
+		aWriteHandle.Write(KNewLine);
+		}
+	}
+
+void CCmdDialog::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptTitle, "title");
+	_LIT(KOptButton1, "first-button");
+	_LIT(KOptButton2, "second-button");
+
+	aOptions.AppendStringL(iTitle, KOptTitle);
+	aOptions.AppendStringL(iButton1, KOptButton1);
+	aOptions.AppendStringL(iButton2, KOptButton2);
+	}
+
+void CCmdDialog::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgBody, "body");
+	aArguments.AppendStringL(iBody, KArgBody);
+	}
+
+
+//
+// CCmdJit.
+//
+
+#ifdef __WINS__
+
+CCommandBase* CCmdJit::NewLC()
+	{
+	CCmdJit* self = new(ELeave) CCmdJit();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdJit::~CCmdJit()
+	{
+	}
+
+CCmdJit::CCmdJit()
+	{
+	}
+
+const TDesC& CCmdJit::Name() const
+	{
+	_LIT(KName, "jit");
+	return KName;
+	}
+
+void CCmdJit::DoRunL()
+	{
+	switch (iOperation)
+		{
+		case EStatus:
+			if (User::JustInTime())
+				{
+				Write(_L("on\r\n"));
+				}
+			else
+				{
+				Write(_L("off\r\n"));
+				}
+			break;
+		case EOn:
+			User::SetJustInTime(ETrue);
+			break;
+		case EOff:
+			User::SetJustInTime(EFalse);
+			break;
+		default:
+			LeaveIfErr(KErrArgument, _L("Unrecognised operation"));
+		}
+	}
+
+void CCmdJit::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgOperation, "operation");
+	aArguments.AppendEnumL((TInt&)iOperation, KArgOperation);
+	}
+
+#endif // __WINS__
+
+
+//
+// CCmdConsole.
+//
+
+CCommandBase* CCmdConsole::NewLC()
+	{
+	CCmdConsole* self = new(ELeave) CCmdConsole();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdConsole::~CCmdConsole()
+	{
+	}
+
+CCmdConsole::CCmdConsole()
+	{
+	}
+
+const TDesC& CCmdConsole::Name() const
+	{
+	_LIT(KName, "console");
+	return KName;
+	}
+	
+_LIT(KPersistentConsole, " (persistent console)");
+
+void CCmdConsole::DoRunL()
+	{
+	if (iIsRemote && iIsNull)
+		{
+		LeaveIfErr(KErrArgument, _L("-r and -n options are mutually exclusive"));
+		}
+
+	RIoConsole console;
+	LeaveIfErr(console.Open(IoSession(), Stdout()), _L("Couldn't open handle to console"));
+	CleanupClosePushL(console);
+	
+	TFileName name;
+	if (console.IsTypeL(RIoHandle::EPersistentConsole))
+		{
+		TInt err = console.ObjectName(name);
+		if (err!=KErrOverflow) User::LeaveIfError(err);
+		name.SetLength(Min(name.Length(), name.MaxLength()-KPersistentConsole().Length()));
+		name.Append(KPersistentConsole);
+		}
+	else
+		{
+		LeaveIfErr(console.Implementation(name), _L("Couldn't read console implemenation name"));
+		}
+	if (iIsRemote)
+		{
+		_LIT(KRconsPattern, "rcons*");
+		_LIT(KVt100Pattern, "vt100*");
+		Complete(!((name.MatchF(KRconsPattern) == 0) || (name.MatchF(KVt100Pattern) == 0)));
+		}
+	else if (iIsNull)
+		{
+		_LIT(KNullPattern, "nullcons*");
+		Complete(!(name.MatchF(KNullPattern) == 0));
+		}
+	else if (iVerbose)
+		{
+		TSize size;
+		LeaveIfErr(Stdout().GetScreenSize(size), _L("Couldn't get screen size"));
+		Printf(_L("Name: %S\r\n"), &name);
+		Printf(_L("Size: %dx%d\r\n"), size.iWidth, size.iHeight);
+		}
+	else
+		{
+		Write(name);
+		}
+	CleanupStack::PopAndDestroy(&console);
+	}
+
+void CCmdConsole::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptIsRemote, "remote");
+	_LIT(KOptIsNull, "null");
+
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	aOptions.AppendBoolL(iIsRemote, KOptIsRemote);
+	aOptions.AppendBoolL(iIsNull, KOptIsNull);
+	}
+
+
+//
+// CCmdPcons.
+//
+
+CCommandBase* CCmdPcons::NewLC()
+	{
+	CCmdPcons* self = new(ELeave) CCmdPcons();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdPcons::~CCmdPcons()
+	{
+	delete iName;
+	delete iCommand;
+	delete iCommandArgs;
+	}
+
+CCmdPcons::CCmdPcons()
+	{
+	}
+
+const TDesC& CCmdPcons::Name() const
+	{
+	_LIT(KName, "pcons");
+	return KName;
+	}
+
+_LIT(KNone, "-");
+_LIT(KDefaultCommand, "fshell");
+_LIT(KCurrentConsMarker, "(*)");
+_LIT(KNew, "new");
+_LIT(KExisting, "existing");
+
+void CCmdPcons::DoRunL()
+	{
+	RIoPersistentConsole pcons;
+	CleanupClosePushL(pcons);
+	if ((iOperation != ENew) && (iOperation != EStart) && iCommand)
+		{
+		TPtrC operation(iArguments.AsString(&iOperation));
+		PrintWarning(_L("'command' argument being ignored for operation %S"), &operation);
+		}
+	
+	switch (iOperation)
+		{
+	case EList:
+		{
+		RIoConsole thisCons;
+		LeaveIfErr(thisCons.Open(IoSession(), Stdout()), _L("Couldn't open handle to current console"));
+		CleanupClosePushL(thisCons);
+
+		const TDesC& matchStr = iName ? *iName : KMatchAll();
+		TInt foundHandle;
+		TName foundName;
+		TBool foundCurrent = EFalse;
+		
+		CTextBuffer* buf = CTextBuffer::NewLC(0x20);
+		_LIT(KColumnHeadings, "Name\tCreator\tReader\tWriter\r\n");
+		buf->AppendL(KColumnHeadings);
+		TInt err = IoSession().FindFirstHandle(RIoHandle::EConsole, matchStr, foundHandle, foundName);
+		TInt count = 0;
+		while (err==KErrNone)
+			{
+			RIoPersistentConsole pcons;
+			pcons.OpenFoundHandleL(IoSession(), foundHandle);
+			CleanupClosePushL(pcons);
+			if (pcons.IsTypeL(RIoHandle::EPersistentConsole))
+				{
+				count++;
+				buf->AppendL(foundName);
+				if (pcons.EqualsL(thisCons))
+					{
+					buf->AppendL(KCurrentConsMarker);
+					foundCurrent = ETrue;
+					}
+				buf->AppendL(KTab);
+				
+					{
+					TThreadId creatorId = pcons.GetCreatorL();
+					RThread creator;
+					if (creator.Open(creatorId)==KErrNone)
+						{
+						TFullName name;
+						LtkUtils::GetFriendlyThreadName(creator, name);
+						creator.Close();
+						buf->AppendL(name);
+						buf->AppendL(KTab);
+						}
+					else
+						{
+						buf->AppendFormatL(_L("(%Ld)\t"), creatorId.Id());
+						}
+					}
+				
+					{
+					TName readerName;
+					TName writerName;
+					pcons.GetAttachedReaderAndWriterNamesL(readerName, writerName);
+					
+					buf->AppendL(readerName.Length() ? readerName : KNone());
+					buf->AppendL(KTab);
+					buf->AppendL(writerName.Length() ? writerName : KNone());
+					buf->AppendL(KNewLine);
+					}
+				}			
+			CleanupStack::PopAndDestroy(&pcons);
+			err = IoSession().FindNextHandle(foundHandle, foundName);
+			}
+		if (err!=KErrNotFound) User::LeaveIfError(err);
+		if (count)
+			{
+			CTextFormatter* tf = CTextFormatter::NewLC(Stdout());
+			// if this fails, it's probably just because the console is too narrow; just print it
+			// untabulated in this case.
+			TRAP(err, tf->TabulateL(0, 2, buf->Descriptor()));
+			if (err==KErrNone)
+				{
+				Write(tf->Descriptor());
+				}
+			else
+				{
+				Write(buf->Descriptor());
+				}
+			CleanupStack::PopAndDestroy(tf);
+			}
+		if (foundCurrent)
+			{
+			Write(KCurrentConsMarker);
+			Write(_L(" indicates current console"));
+			}
+		CleanupStack::PopAndDestroy(2, &thisCons);
+		break;
+		}
+	case EStart:
+		{
+		if (!iName)
+			{
+			PrintError(KErrArgument, _L("A persistent console name to start to must be specified"));
+			DisplayHelp();
+			break;
+			}
+		TInt err = pcons.OpenByName(IoSession(), *iName);
+		const TDesC* newOrExisting;
+		if (err==KErrNone)
+			{
+			newOrExisting = &KExisting;
+			if (iCommand)
+				{
+				PrintWarning(_L("Ignoring 'command' argument as console already exists."));
+				}
+			}
+		else
+			{
+			newOrExisting = &KNew;
+			CreateL(pcons);
+			}
+		AttachL(pcons, *newOrExisting, ETrue);
+		break;
+		}
+	case EConnect:
+		{
+		if (!iName)
+			{
+			PrintError(KErrArgument, _L("A persistent console name to connect to must be specified"));
+			DisplayHelp();
+			break;
+			}
+		LeaveIfErr(pcons.OpenByName(IoSession(), *iName), _L("Couldn't open persistent console with name %S"), iName);
+		AttachL(pcons, KExisting, EFalse);
+		break;
+		}
+	case EDisconnect:
+		{
+		if (iName)
+			{
+			LeaveIfErr(pcons.OpenByName(IoSession(), *iName), _L("Couldn't open persistent console with name %S"), iName);
+			}
+		else
+			{
+			LeaveIfErr(pcons.Open(IoSession(), Stdout()), _L("Couldn't open handle to console"));
+			if (!pcons.IsTypeL(RIoHandle::EPersistentConsole))
+				{
+				LeaveIfErr(KErrNotSupported, _L("Not connected to a persistent console"));
+				}
+			}
+		pcons.DetachReader();
+		pcons.DetachWriter();
+		break;
+		}
+	case ENew:
+		{
+		if (!iName)
+			{
+			PrintError(KErrArgument, _L("A name for the new persistent console must be specified"));
+			DisplayHelp();
+			break;
+			}
+		CreateL(pcons);
+		break;
+		}
+		}
+	CleanupStack::PopAndDestroy(&pcons);
+	}
+	
+void CCmdPcons::CreateL(RIoPersistentConsole& aPcons)
+	{
+	const TDesC& command(iCommand ? *iCommand : KDefaultCommand());
+	const TDesC& args(iCommandArgs ? *iCommandArgs : KNullDesC());
+
+	LeaveIfErr(aPcons.Create(IoSession(), *iName, *iName), _L("Could not create persistent console '%S'"), iName);
+
+	RChildProcess proc;
+	TRAPL(proc.CreateL(command, args, IoSession(), aPcons, &Env()), _L("Could not create process %S"), &command);
+	
+	proc.Detach();
+	proc.Close();
+	}
+	
+TInt CCmdPcons::DoAttach(RIoPersistentConsole& aPcons, RIoConsole& aNew, RIoPersistentConsole::TCloseBehaviour aOnClose)
+	{
+	TInt err = aPcons.AttachWriter(aNew, aOnClose);
+	if (err==KErrNone)
+		{
+		err = aPcons.AttachReader(aNew, aOnClose);
+		if (err!=KErrNone)
+			{
+			aPcons.DetachWriter();
+			}
+		}
+	return err;
+	}
+	
+void CCmdPcons::AttachL(RIoPersistentConsole& aPcons, const TDesC& aNewOrExisting, TBool aForce)
+	{
+	RIoConsole thisCons;
+	LeaveIfErr(thisCons.Open(IoSession(), Stdout()), _L("Couldn't open handle to current console"));
+	CleanupClosePushL(thisCons);
+	
+	TBool usingExistingConsole = !ConsoleImplementation();
+	RIoPersistentConsole::TCloseBehaviour onClose = 
+			usingExistingConsole ? 
+			RIoPersistentConsole::EDetachOnHandleClose : 
+			RIoPersistentConsole::EKeepAttachedOnHandleClose;
+	
+	if (usingExistingConsole)
+		{
+		Printf(_L("pcons: connecting to %S console %S.\r\n"), &aNewOrExisting, iName);
+		}
+	TInt err = DoAttach(aPcons, thisCons, onClose);
+	if ((err == KErrInUse) && (aForce))
+		{
+		if (iVerbose) Printf(_L("Detaching existing connection from %S"), iName);
+		aPcons.DetachReader();
+		aPcons.DetachWriter();
+		err = DoAttach(aPcons, thisCons, onClose);
+		}
+	LeaveIfErr(err, _L("Could not connect to persistent console %S"), iName);
+	
+	if (usingExistingConsole)
+		{
+		// we've not been a custom console implementation
+		// so we need to wait until the persistent side is disconnected.
+		TRequestStatus readerDetach;
+		TRequestStatus writerDetach;
+		aPcons.NotifyReaderDetach(readerDetach);
+		aPcons.NotifyWriterDetach(writerDetach);
+		User::WaitForRequest(readerDetach);
+		if (iVerbose) Printf(_L("Persistent console reader detached; waiting for writer to detach\r\n"));
+		User::WaitForRequest(writerDetach);		
+		if (iVerbose) Printf(_L("Persistent console writer detached\r\n"));
+		if (Stdout().GetCursorPosL().iX != 0) Printf(KNewLine);
+		Printf(_L("pcons: disconnected from %S\r\n"), iName);
+		}
+
+	CleanupStack::PopAndDestroy(&thisCons);		
+	}
+
+void CCmdPcons::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KOperationName, "operation");
+	_LIT(KNameName, "name");
+	_LIT(KArgCommand, "command");
+	_LIT(KCommandArgs, "command_args");
+
+	aArguments.AppendEnumL((TInt&)iOperation, KOperationName);
+	aArguments.AppendStringL(iName, KNameName);
+	aArguments.AppendStringL(iCommand, KArgCommand);
+	aArguments.AppendStringL(iCommandArgs, KCommandArgs);
+	}
+
+void CCmdPcons::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	}
+
+
+//
+// CCmdIoInfo.
+//
+
+CCommandBase* CCmdIoInfo::NewLC()
+	{
+	CCmdIoInfo* self = new(ELeave) CCmdIoInfo();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdIoInfo::~CCmdIoInfo()
+	{
+	delete iMatchString;
+	}
+
+CCmdIoInfo::CCmdIoInfo()
+	{
+	}
+
+const TDesC& CCmdIoInfo::Name() const
+	{
+	_LIT(KName, "ioinfo");
+	return KName;
+	}
+
+void CCmdIoInfo::DoRunL()
+	{
+	TInt foundHandle;				
+	TName name;
+	TInt err = IoSession().FindFirstHandle(iObjectType, iMatchString ? *iMatchString : KMatchAll(), foundHandle, name);
+	while (err==KErrNone)
+		{
+		Write(name);
+		Write(KNewLine);
+		err = IoSession().FindNextHandle(foundHandle, name);
+		}
+	if (err!=KErrNotFound) User::LeaveIfError(err);
+	}
+
+void CCmdIoInfo::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KObjectType, "object_type");
+	aArguments.AppendEnumL((TInt&)iObjectType, KObjectType);
+	}
+
+void CCmdIoInfo::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KMatch, "match");
+	aOptions.AppendStringL(iMatchString, KMatch);
+	}
+
+
+//
+// CCmdReattach.
+//
+
+CCommandBase* CCmdReattach::NewLC()
+	{
+	CCmdReattach* self = new(ELeave) CCmdReattach();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdReattach::~CCmdReattach()
+	{
+	delete iJobSpec;
+	delete iStdinEndPointName;
+	delete iStdoutEndPointName;
+	delete iStderrEndPointName;
+	}
+
+CCmdReattach::CCmdReattach() : CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdReattach::Name() const
+	{
+	_LIT(KName, "reattach");
+	return KName;
+	}
+
+void CCmdReattach::OpenEndPointLC(RIoEndPoint& aEndPoint, const TDesC& aName)
+	{
+	TInt foundHandle;
+	TName name;
+	LeaveIfErr(IoSession().FindFirstHandle(RIoHandle::EEndPoint, aName, foundHandle, name), _L("Couldn't find and end point named \"%S\""), &aName);
+	aEndPoint.OpenFoundHandleL(IoSession(), foundHandle);
+	CleanupClosePushL(aEndPoint);
+	}
+
+void CCmdReattach::DoRunL()
+	{
+	TInt jobId = -1;
+	ParseJobSpecL(*iJobSpec, jobId);
+	RIoEndPoint stdinEndPoint;
+	RIoEndPoint stdoutEndPoint;
+	RIoEndPoint stderrEndPoint;
+	if (iStdinEndPointName)
+		{
+		OpenEndPointLC(stdinEndPoint, *iStdinEndPointName);
+		}
+	else
+		{
+		static_cast<RIoNull&>(stdinEndPoint).CreateL(IoSession());
+		CleanupClosePushL(stdinEndPoint);
+		}
+	TInt numCleanupPushes = 1;
+	if (iStdoutEndPointName)
+		{
+		OpenEndPointLC(stdoutEndPoint, *iStdoutEndPointName);
+		++numCleanupPushes;
+		}
+	else
+		{
+		stdoutEndPoint = stdinEndPoint;
+		}
+	if (iStderrEndPointName)
+		{
+		OpenEndPointLC(stderrEndPoint, *iStderrEndPointName);
+		++numCleanupPushes;
+		}
+	else
+		{
+		stderrEndPoint = stdoutEndPoint;
+		}
+
+	gShell->ClaimJobsLockLC();
+	CJob* job = gShell->Job(jobId);
+	if (job)
+		{
+		TInt err = job->Reattach(stdinEndPoint, stdoutEndPoint, stderrEndPoint);
+		CleanupStack::PopAndDestroy(); // jobs lock.
+		if (err)
+			{
+			Complete(err, _L("Couldn't reattach job %S"), iJobSpec);
+			}
+		else
+			{
+			Complete();
+			}
+		}
+	else
+		{
+		CleanupStack::PopAndDestroy(); // jobs lock.
+		Complete(KErrNotFound, _L("Job %S not found"), iJobSpec);
+		}
+
+	CleanupStack::PopAndDestroy(numCleanupPushes);
+	}
+
+void CCmdReattach::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgJobSpec, "job");
+	_LIT(KArgStdinEndPointName, "stdin");
+	_LIT(KArgStdoutEndPointName, "stdout");
+	_LIT(KArgStderrEndPointName, "stderr");
+
+	aArguments.AppendStringL(iJobSpec, KArgJobSpec);
+	aArguments.AppendStringL(iStdinEndPointName, KArgStdinEndPointName);
+	aArguments.AppendStringL(iStdoutEndPointName, KArgStdoutEndPointName);
+	aArguments.AppendStringL(iStderrEndPointName, KArgStderrEndPointName);
+	}
+
+
+//
+// CCmdDisown.
+//
+
+CCommandBase* CCmdDisown::NewLC()
+	{
+	CCmdDisown* self = new(ELeave) CCmdDisown();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdDisown::~CCmdDisown()
+	{
+	delete iJobSpec;
+	}
+
+CCmdDisown::CCmdDisown() : CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdDisown::Name() const
+	{
+	_LIT(KName, "disown");
+	return KName;
+	}
+
+void CCmdDisown::DoRunL()
+	{
+	TInt jobId = -1;
+	ParseJobSpecL(*iJobSpec, jobId);
+	gShell->ClaimJobsLockLC();
+	TInt err = gShell->DisownJob(jobId);
+	CleanupStack::PopAndDestroy(); // jobs lock.
+	if (err)
+		{
+		Complete(err, _L("Couldn't disown job %S"), iJobSpec);
+		}
+	else
+		{
+		Complete();
+		}
+	}
+
+void CCmdDisown::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgJobSpec, "job_spec");
+	aArguments.AppendStringL(iJobSpec, KArgJobSpec);
+	}
+
+
+//
+// CCmdDebugPort
+//
+
+CCommandBase* CCmdDebugPort::NewLC()
+	{
+	CCmdDebugPort* self = new(ELeave) CCmdDebugPort();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdDebugPort::~CCmdDebugPort()
+	{
+	}
+
+CCmdDebugPort::CCmdDebugPort()
+	{
+	}
+
+const TDesC& CCmdDebugPort::Name() const
+	{
+	_LIT(KName, "debugport");
+	return KName;
+	}
+
+void CCmdDebugPort::DoRunL()
+	{
+	if (iArguments.IsPresent(0))
+		{
+		if (iForce)
+			{
+			LoadMemoryAccessL();
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+			LeaveIfErr(iMemAccess.SetDebugPort(iPort), _L("Couldn't set debug port"));
+#endif
+			}
+		else
+			{
+			LeaveIfErr(HAL::Set(HAL::EDebugPort, iPort), _L("Couldn't set debug port (Try --force)."));
+			}
+		}
+	else
+		{
+		TInt debugport = 0;
+		TInt err = HAL::Get(HAL::EDebugPort, debugport);
+		LeaveIfErr(err, _L("Couldn't read debug port."));
+		Printf(_L("Debug port: %d\r\n"), debugport);
+		}
+	}
+
+void CCmdDebugPort::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgPort, "port");
+	aArguments.AppendIntL(iPort, KArgPort);
+	}
+
+void CCmdDebugPort::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptForce, "force");
+	aOptions.AppendBoolL(iForce, KOptForce);
+	}
+
+
+//
+// CCmdRom
+//
+
+CCommandBase* CCmdRom::NewLC()
+	{
+	CCmdRom* self = new(ELeave) CCmdRom();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdRom::~CCmdRom()
+	{
+	delete iBuffer;
+	}
+
+CCmdRom::CCmdRom()
+	{
+	}
+
+const TDesC& CCmdRom::Name() const
+	{
+	_LIT(KName, "rom");
+	return KName;
+	}
+
+void CCmdRom::PrintIntL(TInt32 aInt32, const TDesC& aLabel, const TDesC& aDescription)
+	{
+	_LIT(KFormat, "%S:\t%d (0x%08x)\t%S\r\n");
+	iBuffer->AppendFormatL(KFormat, &aLabel, aInt32, aInt32, &aDescription);
+	}
+
+void CCmdRom::PrintIntL(TInt64 aInt64, const TDesC& aLabel, const TDesC& aDescription)
+	{
+	_LIT(KFormat, "%S:\t%Ld\t%S\r\n");
+	iBuffer->AppendFormatL(KFormat, &aLabel, aInt64, &aDescription);
+	}
+
+void CCmdRom::PrintUintL(TUint32 aUint32, const TDesC& aLabel, const TDesC& aDescription)
+	{
+	_LIT(KFormat, "%S:\t%u (0x%08x)\t%S\r\n");
+	iBuffer->AppendFormatL(KFormat, &aLabel, aUint32, aUint32, &aDescription);
+	}
+
+void CCmdRom::PrintUintL(TUint64 aUint64, const TDesC& aLabel, const TDesC& aDescription)
+	{
+	_LIT(KFormat, "%S:\t%Lu\t%S\r\n");
+	iBuffer->AppendFormatL(KFormat, &aLabel, aUint64, &aDescription);
+	}
+
+void CCmdRom::PrintAddressL(TLinAddr aAddress, const TDesC& aLabel, const TDesC& aDescription)
+	{
+	_LIT(KFormat, "%S:\t0x%08x\t%S\r\n");
+	iBuffer->AppendFormatL(KFormat, &aLabel, aAddress, &aDescription, &aDescription);
+	}
+
+void CCmdRom::PrintSizeL(TInt32 aSize, const TDesC& aLabel, const TDesC& aDescription)
+	{
+	if (iHumanReadable)
+		{
+		_LIT(KFormat1, "%S:\t");
+		iBuffer->AppendFormatL(KFormat1, &aLabel);
+		iBuffer->AppendHumanReadableSizeL((TInt)aSize, EUnaligned);
+		_LIT(KFormat2, "\t%S\r\n");
+		iBuffer->AppendFormatL(KFormat2, &aDescription);
+		}
+	else
+		{
+		PrintIntL(aSize, aLabel, aDescription);
+		}
+	}
+
+void CCmdRom::PrintTimeL(TInt64 aTime, const TDesC& aLabel, const TDesC& aDescription)
+	{
+	if (iHumanReadable)
+		{
+		TTime time(aTime);
+		TDateTime dateTime(time.DateTime());
+		_LIT(KFormat, "%S:\t%+02d/%+02d/%+04d %+02d:%+02d:%+02d.%+06d\t%S\r\n");
+		iBuffer->AppendFormatL(KFormat, &aLabel, dateTime.Day() + 1, dateTime.Month() + 1, dateTime.Year(), dateTime.Hour(), dateTime.Minute(), dateTime.Second(), dateTime.MicroSecond(), &aDescription);
+		}
+	else
+		{
+		PrintIntL(aTime, aLabel, aDescription);
+		}
+	}
+
+void CCmdRom::PrintVersionL(TVersion aVersion, const TDesC& aLabel, const TDesC& aDescription)
+	{
+	_LIT(KFormat, "%S:\t%d.%d (build %d)\t%S\r\n");
+	iBuffer->AppendFormatL(KFormat, &aLabel, aVersion.iMajor, aVersion.iMinor, aVersion.iBuild, &aDescription);
+	}
+
+void CCmdRom::DoRunL()
+	{
+#ifdef __WINS__
+	LeaveIfErr(KErrNotSupported, _L("This command is not supported on the emulator"));
+#endif
+
+	TRomHeader* header = (TRomHeader*)UserSvr::RomHeaderAddress();
+
+	iBuffer = CTextBuffer::NewL(0x100);
+
+	PrintVersionL(header->iVersion, _L("iVersion"), _L("The ROM version number."));
+	PrintTimeL(header->iTime, _L("iTime"), _L("The time and date that the ROM image was built."));
+	PrintSizeL(header->iRomSize, _L("iRomSize"), _L("The size of the ROM image. This includes the second section for sectioned ROMs."));
+	PrintUintL((TUint32)header->iCheckSum, _L("iCheckSum"), _L("A computed constant that causes the 32-bit checksum of the image to equal the value specified by the \"romchecksum\" keyword."));
+	PrintUintL(header->iKernelConfigFlags, _L("iKernelConfigFlags"), _L("Contains the flags that define the security options in force. See TKernelConfigFlags for details."));
+
+	if (iVerbose)
+		{
+		PrintAddressL(header->iRestartVector, _L("iRestartVector"), _L("The restart vector"));
+		PrintUintL(header->iTimeHi, _L("iTimeHi"), _L("The high order 32 bits of the ROM image build time and date."));
+		PrintAddressL(header->iRomBase, _L("iRomBase"), _L("The virtual address of the base of the ROM."));
+		PrintAddressL(header->iRomRootDirectoryList, _L("iRomRootDirectoryList"), _L("The virtual address of the TRomRootDirectoryList structure."));
+		PrintAddressL(header->iKernDataAddress, _L("iKernDataAddress"), _L("The virtual address of kernel data, when in RAM."));
+		PrintAddressL(header->iKernelLimit, _L("iKernelLimit"), _L("The virtual address of the top of the kernel region, when in RAM."));
+		PrintAddressL(header->iPrimaryFile, _L("iPrimaryFile"), _L("The virtual address of the primarys ROM file image header."));
+		PrintAddressL(header->iSecondaryFile, _L("iSecondaryFile"), _L("The virtual address of the secondarys ROM file image header."));
+		PrintUintL(header->iHardware, _L("iHardware"), _L("A unique number identifying the hardware for which this ROM image has been built. Note that this is only used for testing purposes."));
+		PrintIntL(header->iLanguage, _L("iLanguage"), _L("A bitmask identifying which of the languages are supported by the ROM image, as specified by the \"languages\" keyword. Note that this is only used for testing purposes."));
+		PrintAddressL(header->iRomExceptionSearchTable, _L("iRomExceptionSearchTable"), _L("The virtual address of the TRomExceptionSearchTable structure."));
+		PrintUintL(header->iRomHeaderSize, _L("iRomHeaderSize"), _L("Current size of ROM header (previously iUnused3). If value is 0x69966996 then header size is 0x100."));
+		PrintAddressL(header->iRomSectionHeader, _L("iRomSectionHeader"), _L("The virtual address of the ROM section header, if the ROM is sectioned. See TRomSectionHeader for details."));
+		PrintSizeL(header->iTotalSvDataSize, _L("iTotalSvDataSize"), _L("The total supervisor data size, i.e. the amount of memory mapped for the kernel data chunk."));
+		PrintAddressL(header->iVariantFile, _L("iVariantFile"), _L("The virtual address of the TRomEntry for the Variant file. See TRomEntry for details."));
+		PrintAddressL(header->iExtensionFile, _L("iExtensionFile"), _L("The virtual address of TRomEntry for the first extension file, if it exists. If there is more than one extension, then the next extension field in the extensions TRomImageHeader points to the TRomEntry for that next extension. See TRomEntry and TRomImageHeader for details."));
+		PrintAddressL(header->iRelocInfo, _L("iRelocInfo"), _L("The old position of the kernel trace mask, see iTraceMask."));
+		PrintUintL(header->iOldTraceMask, _L("iOldTraceMask"), _L("Current size of ROM header (previously iUnused3). If value is 0x69966996 then header size is 0x100."));
+		PrintAddressL(header->iUserDataAddress, _L("iUserDataAddress"), _L("The virtual address of the user data area."));
+		PrintSizeL(header->iTotalUserDataSize, _L("iTotalUserDataSize"), _L("The total size of the user data."));
+		PrintUintL(header->iDebugPort, _L("iDebugPort"), _L("A value that is interpreted by the Bootstrap and kernel as the debug port to be used."));
+		PrintUintL(header->iCompressionType, _L("iCompressionType"), _L("The type of compression used for the image. This is a UID, or 0 if there is no compression."));
+		PrintSizeL(header->iCompressedSize, _L("iCompressedSize"), _L("The size of the image after compression."));
+		PrintSizeL(header->iUncompressedSize, _L("iUncompressedSize"), _L("The size of the image before compression."));
+		PrintUintL(header->iDisabledCapabilities[0], _L("iDisabledCapabilities[0]"), _L("Disabled capabilities."));
+		PrintUintL(header->iDisabledCapabilities[1], _L("iDisabledCapabilities[1]"), _L("Disabled capabilities."));
+		for (TInt i = 0; i < TRomHeader::KNumTraceMask; ++i)
+			{
+			TBuf<16> buf;
+			_LIT(KFormat, "iTraceMask[%d]");
+			buf.Format(KFormat, i);
+			PrintUintL(header->iTraceMask[i], buf, _L("The initial value for one of the kernel trace masks."));
+			}
+#ifdef FSHELL_BTRACE_SUPPORT
+		for (TInt i = 0; i < 9; ++i)
+			{
+			TBuf<32> buf;
+			_LIT(KFormat, "iInitialBTraceFilter[%d]");
+			buf.Format(KFormat, i);
+			PrintUintL(header->iInitialBTraceFilter[i], buf, _L("Initial value for a btrace filter."));
+			}
+		PrintSizeL(header->iInitialBTraceBuffer, _L("iInitialBTraceBuffer"), _L("The initial btrace buffer size."));
+		PrintUintL((TUint32)header->iInitialBTraceMode, _L("iInitialBTraceMode"), _L("The initial btrace mode."));
+#endif
+#ifndef FSHELL_9_1_SUPPORT
+		PrintIntL((TInt32)header->iPageableRomStart, _L("iPageableRomStart"), _L("An offset, in bytes from ROM start, for the start of the pageable ROM area."));
+		PrintSizeL(header->iPageableRomSize, _L("iPageableRomSize"), _L("The size of the pageable ROM area."));
+		PrintIntL((TInt32)header->iRomPageIndex, _L("iRomPageIndex"), _L("An offset in bytes from ROM start, for the page index. (Array of SRomPageInfo objects.)"));
+		PrintUintL((TUint32)header->iDemandPagingConfig.iMinPages, _L("iMinPages"), _L("The minimum number of demand pages."));
+		PrintUintL((TUint32)header->iDemandPagingConfig.iMaxPages, _L("iMinPages"), _L("The maximum number of demand pages."));
+		PrintUintL((TUint32)header->iDemandPagingConfig.iYoungOldRatio, _L("iYoungOldRatio"), _L("The young / old ration of demand pages."));
+#endif
+		}
+
+	CTextFormatter* formatter = CTextFormatter::NewLC(Stdout());
+	formatter->TabulateL(0, 2, iBuffer->Descriptor(), EWrapLastColumn);
+	formatter->Write();
+	CleanupStack::PopAndDestroy(formatter);
+	}
+
+void CCmdRom::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iVerbose, KOptVerbose);
+	aOptions.AppendBoolL(iHumanReadable, KOptHuman);
+	}
+
+CCommandBase* CCmdWhich::NewLC()
+	{
+	CCmdWhich* self = new(ELeave) CCmdWhich();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdWhich::~CCmdWhich()
+	{
+	delete iCommand;
+	}
+
+CCmdWhich::CCmdWhich()
+	{
+	}
+
+const TDesC& CCmdWhich::Name() const
+	{
+	_LIT(KName, "which");
+	return KName;
+	}
+	
+void CCmdWhich::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCommand, "command");
+	aArguments.AppendStringL(iCommand, KCommand);
+	}
+	
+void CCmdWhich::DoRunL()
+	{
+	LtkUtils::RLtkBuf desc;
+	CleanupClosePushL(desc);
+	TRAPD(err, gShell->CommandFactory().GetCommandInfoL(*iCommand, desc));
+	_LIT(KFmt, "%S: %S\r\n");
+	_LIT(KFailed, "%S not a built-in or an exe in \\sys\\bin\r\n");
+	if (err == KErrNotFound)
+		{
+		// Must be an external non-fshell exe
+		TFindFile find(FsL());
+		TInt err = find.FindByDir(*iCommand, _L("Y:\\sys\\bin\\")); // Specify Y: to prevent it from checking the session path first
+		if (err == KErrNone)
+			{
+			Printf(KFmt, iCommand, &find.File());
+			}
+		else if (err == KErrPermissionDenied)
+			{
+			// FShell must be built without AllFiles - try just creating it and getting its path
+			RProcess proc;
+			err = proc.Create(*iCommand, KNullDesC);
+			if (err == KErrNone)
+				{
+				TFileName path = proc.FileName();
+				Printf(KFmt, iCommand, &path);
+				proc.Kill(KErrCancel);
+				proc.Close();
+				}
+			else
+				{
+				Printf(KFailed, iCommand);
+				}
+			}
+		else
+			{
+			Printf(KFailed, iCommand);
+			}
+		}
+	else
+		{
+		LeaveIfErr(err, _L("Error finding command %S"), iCommand);
+		Printf(_L("%S: %S\r\n"), iCommand, &desc);
+		}
+	CleanupStack::PopAndDestroy(&desc);
+	}
+
+CCommandBase* CCmdTee::NewLC()
+	{
+	CCmdTee* self = new(ELeave) CCmdTee();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTee::~CCmdTee()
+	{
+	iFileNames.Close();
+	for (TInt i = 0; i < iFiles.Count(); i++)
+		{
+		iFiles[i].Close();
+		}
+	iFiles.Close();
+	}
+
+CCmdTee::CCmdTee()
+	{
+	}
+
+const TDesC& CCmdTee::Name() const
+	{
+	_LIT(KName, "tee");
+	return KName;
+	}
+
+void CCmdTee::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendFileNameL(iFileNames, _L("file"));
+	}
+
+void CCmdTee::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iAppend, _L("append"));
+	aOptions.AppendBoolL(iRdebug, _L("rdebug"));
+	}
+	
+void CCmdTee::DoRunL()
+	{
+	TUint filemode = EFileWrite | EFileShareAny | EFileStream; // Allow someone else to read it while we're writing
+	for (TInt i = 0; i < iFileNames.Count(); i++)
+		{
+		RFile f;
+		TInt err = KErrNone;
+		if (iAppend)
+			{
+			err = f.Open(FsL(), iFileNames[i], filemode); // First try append
+			if (err) err = f.Create(FsL(), iFileNames[i], filemode); // Then just create
+			TInt whatDoesThisArgumentForSeekEndDoDoesAnybodyKnow = 0;
+			f.Seek(ESeekEnd, whatDoesThisArgumentForSeekEndDoDoesAnybodyKnow);
+			}
+		else
+			{
+			err = f.Replace(FsL(), iFileNames[i], filemode);
+			}
+		LeaveIfErr(err, _L("Couldn't open file %S"), &iFileNames[i]);
+		iFiles.AppendL(f);
+		}
+	
+	RBuf readBuf;
+	CleanupClosePushL(readBuf);
+	readBuf.CreateL(512);
+	LtkUtils::RLtkBuf8 writeBuf;
+	CleanupClosePushL(writeBuf);
+	writeBuf.CreateL(readBuf.MaxSize() * 4);
+	Stdin().SetReadModeL(RIoReadHandle::EOneOrMore);
+	while (Stdin().Read(readBuf) == KErrNone)
+		{
+		writeBuf.CopyAsUtf8L(readBuf);
+		for (TInt i = 0; i < iFiles.Count(); i++)
+			{
+			TInt err = iFiles[i].Write(writeBuf);
+			if (err) PrintWarning(_L("Failed to write to file %d: %d"), i, err);
+			}
+		if (iRdebug) LtkUtils::RawPrint(writeBuf);
+		Stdout().Write(readBuf);
+		}
+	
+	CleanupStack::PopAndDestroy(2, &readBuf);
+	}
+
+CCommandBase* CCmdError::NewLC()
+	{
+	CCmdError* self = new(ELeave) CCmdError();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdError::~CCmdError()
+	{
+	delete iErrorText;
+	}
+
+CCmdError::CCmdError()
+	: iErrorVal(KErrAbort)
+	{
+	}
+
+const TDesC& CCmdError::Name() const
+	{
+	_LIT(KName, "error");
+	return KName;
+	}
+
+void CCmdError::DoRunL()
+	{
+	if (iErrorVal >= 0) LeaveIfErr(KErrArgument, _L("Non-negative value %d passed to error command"), iErrorVal);
+
+	if (iErrorText)
+		{
+		LeaveIfErr(iErrorVal, *iErrorText);
+		}
+	else
+		{
+		User::Leave(iErrorVal);
+		}
+	}
+
+void CCmdError::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendIntL(iErrorVal, _L("error-number"));
+	aArguments.AppendStringL(iErrorText, _L("text"));
+	}
+
+	
+//
+// CCmdReboot
+//
+
+CCommandBase* CCmdReboot::NewLC()
+	{
+	CCmdReboot* self = new(ELeave) CCmdReboot();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdReboot::~CCmdReboot()
+	{
+	}
+
+CCmdReboot::CCmdReboot()
+	{
+	}
+
+const TDesC& CCmdReboot::Name() const
+	{
+	_LIT(KName, "reboot");
+	return KName;
+	}
+
+void CCmdReboot::DoRunL()
+	{
+	if (!iArguments.IsPresent(0))
+		{
+		iReason = 0x40000000; // On most baseports this represents 'soft reboot'
+		}
+
+	LoadMemoryAccessL();
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	iMemAccess.Reboot(iReason);
+#endif
+	}
+
+void CCmdReboot::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgReason, "reason");
+	aArguments.AppendUintL(iReason, KArgReason);
+	}
+
+	
+//
+// CCmdForEach
+//
+
+CCommandBase* CCmdForEach::NewLC()
+	{
+	CCmdForEach* self = new(ELeave) CCmdForEach();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdForEach::~CCmdForEach()
+	{
+	iDir.Close();
+	}
+
+CCmdForEach::CCmdForEach()
+	: iDirName(TFileName2::EDirectory)
+	{
+	}
+
+void CCmdForEach::DoNextL(TBool aFirstTime)
+	{
+	if (!aFirstTime) Env().RemoveAll(); // Remove all only does locals
+
+	delete iScriptData;
+	iScriptData = NULL;
+	delete iParser;
+	iParser = NULL;
+
+	TEntry entry;
+	TInt err = iDir.Read(entry);
+	if (err == KErrEof)
+		{
+		Complete(iLastError);
+		}
+	else
+		{
+		LeaveIfErr(err, _L("Couldn't read directory '%S'"), &iDirName);
+		// Update the first element of the argument array with the full name of the file we just found.
+		TFileName2 fileName(iDirName);
+		fileName.AppendComponentL(entry.iName, TFileName2::EFile);
+
+		RPointerArray<HBufC> extraArgs;
+		LtkUtils::CleanupResetAndDestroyPushL(extraArgs);
+		extraArgs.AppendL(fileName.AllocLC());
+		CleanupStack::Pop(); // hbufc
+
+		TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr());
+		TBool helpPrinted;
+		iScriptData = CShell::ReadScriptL(iFileName, iArgs, Env(), FsL(), ioHandles, helpPrinted, &extraArgs);
+		CleanupStack::PopAndDestroy(&extraArgs);
+		if (helpPrinted)
+			{
+			Complete();
+			}
+		else
+			{
+			TUint mode = CParser::EExportLineNumbers;
+			if (iKeepGoing)
+				{
+				mode |= CParser::EKeepGoing;
+				}
+			iParser = CParser::NewL(mode, *iScriptData, IoSession(), Stdin(), Stdout(), Stderr(), Env(), gShell->CommandFactory(), this);
+			iParser->Start();
+			}
+		}
+	}
+
+const TDesC& CCmdForEach::Name() const
+	{
+	_LIT(KName, "foreach");
+	return KName;
+	}
+
+void CCmdForEach::DoRunL()
+	{
+	LeaveIfFileNotFound(iDirName);
+	if (!iDirName.IsDirL(FsL()))
+		{
+		LeaveIfErr(KErrArgument, _L("'%S' is not a directory"), &iDirName);
+		}
+	LeaveIfErr(iDir.Open(FsL(), iDirName, KEntryAttNormal | KEntryAttDir), _L("Couldn't open directory '%S'"), &iDirName);
+
+	DoNextL(ETrue);
+	}
+
+void CCmdForEach::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgDirectoryName, "directory_name");
+	aArguments.AppendFileNameL(iDirName, KArgDirectoryName);
+
+	CCmdSource::ArgumentsL(aArguments);
+	}
+
+void CCmdForEach::HandleParserComplete(CParser&, const TError& aError)
+	{
+	TInt err = aError.Error();
+	if (err < 0)
+		{
+		aError.Report();
+		PrintError(err, _L("Aborted \"%S\" at line %d"), &aError.ScriptFileName(), aError.ScriptLineNumber());
+		iLastError = err;
+		}
+
+	if ((err < 0) && !iKeepGoing)
+		{
+		Complete(iLastError);
+		}
+	else
+		{
+		TRAPD(err, DoNextL());
+		if (err)
+			{
+			Complete(err);
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/commands.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1243 @@
+// commands.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __COMMANDS_H__
+#define __COMMANDS_H__
+
+#include <fshell/common.mmh>
+#include <fshell/consoleextensions.h>
+#include "parser.h"
+#include <hal.h>
+#include <fshell/ioutils.h>
+#include <fshell/memoryaccesscmd.h>
+
+using namespace IoUtils;
+
+
+class CCmdHelp : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdHelp();
+private:
+	CCmdHelp();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	IoUtils::CTextFormatter* iFormatter;
+	TBool iCount;
+	};
+
+
+// Note, this command should never execute as 'exit' has handled explicitly by CParser.
+// It exists so that 'exit' appears in fshell's help list and also to support 'exit --help'.
+class CCmdExit : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdExit();
+private:
+	CCmdExit();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	};
+
+
+class MDirReaderObserver
+	{
+public:
+	virtual void DirReadComplete(TInt aError) = 0;
+	};
+
+
+class CCmdLs : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdLs();
+private:
+	CCmdLs();
+	void ConstructL();
+	void PrintDirContentL(const CDir& aDir);
+	void PrintDirContentL(RDir& aDir);
+	void RecursiveScanDirL(const TDesC& aName);
+	void DoScanDirL();
+	void FormatEntryL(const TEntry& aEntry);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iFileName;
+	TPtrC iBaseDir;
+	TBuf<256> iTempBuf;
+	CTextFormatter* iFormatter;
+	TBool iOptAll;
+	TBool iOptLong;
+	TBool iOptHuman;
+	TBool iOptOnePerLine;
+	TBool iOptRecurse;
+	};
+
+
+class CCmdCd : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdCd();
+private:
+	CCmdCd();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iDir;
+	};
+
+
+class CCmdClear : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdClear();
+private:
+	CCmdClear();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+
+private:
+	TBool iFormFeed;
+	};
+
+
+class CForegroundAdjuster;
+
+class CCmdFg : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdFg();
+private:
+	CCmdFg();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iJobSpec;
+	CForegroundAdjuster* iForegroundAdjuster;
+	};
+
+
+class CCmdBg : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdBg();
+private:
+	CCmdBg();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iJobSpec;
+	CForegroundAdjuster* iForegroundAdjuster;
+	};
+
+
+class CCmdJobs : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdJobs();
+private:
+	CCmdJobs();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+private:
+	CTextFormatter* iFormatter;
+	};
+
+
+class CCmdRm : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRm();
+private:
+	CCmdRm();
+	TInt DoDelete(const TDesC& aFileName);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	RArray<TFileName2> iFileNames;
+	CFileMan* iFileMan;
+	TBool iRecurse;
+	TBool iForce;
+	};
+
+
+class CCmdCp : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdCp();
+private:
+	CCmdCp();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	void ForciblyCopyFileL(const TDesC& aSourceFileName, const TDesC& aDestFileName);
+private:
+	TFileName2 iFrom;
+	TFileName2 iTo;
+	CFileMan* iFileMan;
+	TBool iRecurse;
+	TBool iForce;
+	TBool iOverwrite;
+	};
+
+
+class CCmdMv : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdMv();
+private:
+	CCmdMv();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iFrom;
+	TFileName2 iTo;
+	CFileMan* iFileMan;
+	};
+
+
+class CCmdMkDir : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdMkDir();
+private:
+	CCmdMkDir();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iDir;
+	TBool iAllowExists;
+	};
+
+
+class CCmdRmDir : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRmDir();
+private:
+	CCmdRmDir();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	RArray<TFileName2> iDirs;
+	CFileMan* iFileMan;
+	TBool iRecurse;
+	};
+
+
+class CCmdMatch : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdMatch();
+private:
+	CCmdMatch();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iToMatch;
+	TBool iIgnoreCase;
+	TBool iInvertMatch;
+	TBool iCount;
+	};
+
+
+class CCmdEcho : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdEcho();
+private:
+	CCmdEcho();
+	void DoWriteL(const TDesC& aDes);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	enum TAttr
+		{
+		EBold,
+		EUnderscore,
+		EBlink,
+		EInverse,
+		EConceal
+		};
+private:
+	HBufC* iToEcho;
+	TBool iToStderr;
+	TBool iWrap;
+	TUint iIndent;
+	RArray<TInt> iAttributes;
+	ConsoleAttributes::TColor iForegroundColor;
+	ConsoleAttributes::TColor iBackgroundColor;
+	TBool iBinaryMode;
+	TBool iNoNewline;
+	};
+
+
+class CCmdMore : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdMore();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	CCmdMore();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+private:
+	TFileName2 iFile;
+	};
+
+
+class CCmdTrace : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTrace();
+private:
+	CCmdTrace();
+	void PrintConfig();
+	TInt SetFlag(const TDesC& aFlagName, TBool aSet);
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iMask;
+	TUint iIndex;
+	TBool iOptF32;
+	TBool iOptMultiThread;
+	TBool iOptLoader;
+	TBool iOptFat;
+	TBool iOptLffs;
+	TBool iOptIso9660;
+	TBool iOptNtfs;
+	TBool iOptRofs;
+	TBool iOptCompfs;
+	RPointerArray<HBufC> iEnable;
+	RPointerArray<HBufC> iDisable;
+	};
+
+
+class CCmdMemInfo : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdMemInfo();
+private:
+	CCmdMemInfo();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	void AppendLineL(CTextFormatter& aFormatter, const TDesC& aCaption, HALData::TAttribute aHalAttribute, TBool aNewLine);
+private:
+	TUint iUpdateRate;
+	TBool iHumanReadable;
+	TBool iOnlyFreeRam;
+	TBool iOnlyTotalRam;
+	TInt iLastTotalRamUsage;
+	};
+
+
+class CCmdDump : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdDump();
+private:
+	CCmdDump();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	RArray<TFileName2> iFileNames;
+	TBool iBinaryMode;
+	};
+
+
+class CCmdSleep : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSleep();
+private:
+	CCmdSleep();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iDuration;
+	};
+
+
+class CCmdEnv : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdEnv();
+private:
+	CCmdEnv();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	};
+
+
+class CCmdExport : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdExport();
+private:
+	CCmdExport();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iKey;
+	HBufC* iVal;
+	TBool iStdin;
+	TBuf<512> iBuf;
+	};
+
+
+class CCmdSort : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSort();
+private:
+	CCmdSort();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iReverse;
+	};
+
+
+class CCmdExists : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdExists();
+private:
+	CCmdExists();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iFileName;
+	};
+
+
+class CCmdInfoPrint : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdInfoPrint();
+private:
+	CCmdInfoPrint();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iToPrint;
+	};
+
+
+class CCmdRDebug : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRDebug();
+private:
+	CCmdRDebug();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iToPrint;
+	};
+
+
+class CCmdDate : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdDate();
+private:
+	CCmdDate();
+	void Display(const TTime& aTime);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iUniversalTime;
+	HBufC* iDateToSet;
+	TInt iUtcOffset;
+	TBool iSecure;
+	TBool iRaw;
+	TBool iJustDisplay;
+	TInt64 iRawTimeToSet;
+	TBool iUseTimestampFormat;
+	};
+
+
+class CCmdFsck : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdFsck();
+private:
+	CCmdFsck();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iDriveLetter;
+	};
+
+
+class CCmdDriver : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdDriver();
+private:
+	enum TOperation
+		{
+		ELoad,
+		EFree,
+		EFind
+		};
+	enum TType
+		{
+		ELogical,
+		EPhysical
+		};
+private:
+	CCmdDriver();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TOperation iOperation;
+	TType iType;
+	HBufC* iDriverName;
+	};
+
+
+class CCmdChunkInfo : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdChunkInfo();
+private:
+	CCmdChunkInfo();
+	void DoPrintL();
+	void ListChunksL();
+	void PrintChunkInfoL();
+	void PrintSizeL(const TDesC& aCaption, TInt aSize);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iAddress;
+	TUint iUpdateRate;
+	TBool iHumanReadable;
+	TBool iIncludeSize;
+	HBufC* iOwningProcess;
+	TUint iControllingProcess;
+	TName iName;
+	TFullName iFullName;
+	CTextFormatter* iFormatter;
+	CTextBuffer* iBuf;
+	};
+
+
+class CCmdSvrInfo : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSvrInfo();
+private:
+	CCmdSvrInfo();
+	void ListServersL();
+	void ListSessionsL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iAddress;
+	TName iName;
+	TFullName iFullName;
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TServerKernelInfo iServerInfo;
+	TThreadKernelInfo iThreadInfo;
+	TProcessKernelInfo iProcessInfo;
+	TSessionKernelInfo iSessionInfo;
+#endif
+	CTextFormatter* iFormatter;
+	CTextBuffer* iBuf;
+	};
+
+
+class CCmdTickle : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTickle();
+private:
+	CCmdTickle();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	};
+
+
+class CCmdTicks : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTicks();
+private:
+	CCmdTicks();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iVerbose;
+	};
+
+
+class CCmdUpTime : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdUpTime();
+private:
+	CCmdUpTime();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iHuman;
+	};
+
+
+class CCmdVar : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdVar();
+private:
+	CCmdVar();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	enum
+		{
+		EDefined,
+		ENotDefined,
+		EEqual,
+		ENotEqual,
+		EAdd,
+		ESubtract,
+		} iOperation;
+	HBufC* iVar1;
+	HBufC* iArg;
+	};
+
+
+class CCmdSource : public CCommandBase, public MParserObserver
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSource();
+protected:
+	CCmdSource();
+private:
+	void BackupVarL(const TDesC& aKey, HBufC*& aBuf);
+	void RestoreVarL(const TDesC& aKey, const HBufC* aBuf);
+protected: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From MParserObserver.
+	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+protected:
+	TFileName2 iFileName;
+	HBufC* iArgs;
+	TBool iKeepGoing;
+	HBufC* iScriptData;
+	CParser* iParser;
+	};
+
+
+class CCmdStart : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdStart();
+private:
+	CCmdStart();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iRendezvous;
+	TBool iWait;
+	TInt iTimeout;
+	HBufC* iExe;
+	HBufC* iCommandLine;
+	TBool iMeasure;
+	};
+
+
+class CCmdCompare : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdCompare();
+private:
+	CCmdCompare();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TFileName2 iFileName1;
+	TFileName2 iFileName2;
+	TBool iVerbose;
+	};
+
+
+class CCmdTime : public CCommandBase, public MParserObserver
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTime();
+private:
+	CCmdTime();
+	void NextIterationL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From MParserObserver.
+	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+private:
+	HBufC* iCommandLine;
+	TUint32 iCountBefore;
+	CParser* iParser;
+	TBool iHuman;
+	TBool iFastCounter;
+	TInt iRepeatCount;
+	TInt iIteration;
+	TUint64 iTotalTime;
+	};
+
+
+class CCmdRepeat : public CCommandBase, public MParserObserver
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRepeat();
+private:
+	CCmdRepeat();
+	void CreateParserL();
+	void HandleParserCompleteL(const TError& aError);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From MParserObserver.
+	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+private:
+	HBufC* iCommandLine;
+	CParser* iParser;
+	TUint iCount;
+	TUint iNumRepeats;
+	TBool iKeepGoing;
+	TBool iForever;
+	TInt iWaitTime;
+	};
+
+
+class CCmdDebug : public CCommandBase, public MParserObserver
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdDebug();
+private:
+	CCmdDebug();
+	void InteractL(const TDesC& aExpandedLine);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private: // From MParserObserver.
+	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+	virtual void AboutToExecuteLine(const TDesC& aOrignalLine, const TDesC& aExpandedLine);
+	virtual void LineReturned(TInt aError);
+private:
+	TFileName2 iFileName;
+	HBufC* iArgs;
+	TBool iKeepGoing;
+	HBufC* iScriptData;
+	CParser* iParser;
+	};
+
+
+class CCmdReadMem : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdReadMem();
+private:
+	CCmdReadMem();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iAddress;
+	TUint iSize;
+	TFileName2 iFileName;
+	TInt iThreadId;
+	RFile iFile;
+	};
+
+
+class CCmdE32Header : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdE32Header();
+private:
+	CCmdE32Header();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iFileName;
+	TBool iXip;
+	TBool iNotXip;
+	CTextFormatter* iFormatter;
+	};
+
+
+class CCmdObjInfo : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdObjInfo();
+private:
+	CCmdObjInfo();
+	void PrintObjectDetailsL(TUint aObjectAddress);
+	void PrintObjectReferencersL(TUint aObjectAddress);
+	void PrintReferencedObjectDetailsL(TOwnerType aOwnerType, TUint aId);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iObjectAddress;
+	TBool iReferencers;
+	TUint iProcessId;
+	TUint iThreadId;
+	TBool iAll;
+	};
+
+class CCmdTouch : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTouch();
+private:
+	CCmdTouch();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TFileName2 iFileName;
+	};
+
+class CCmdDialog : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdDialog();
+private:
+	enum TMode
+		{
+		EModeNotifier,
+		EModeConsole,
+		EModeNull
+		};
+private:
+	CCmdDialog();
+	TMode ModeL() const;
+	void ClearLineL(RIoConsoleWriteHandle& aWriteHandle);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iTitle;
+	HBufC* iBody;
+	HBufC* iButton1;
+	HBufC* iButton2;
+	};
+
+#ifdef __WINS__
+
+class CCmdJit : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdJit();
+private:
+	CCmdJit();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	enum
+		{
+		EStatus,
+		EOn,
+		EOff
+		} iOperation;
+	};
+
+#endif // __WINS__
+
+class CCmdConsole : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdConsole();
+private:
+	CCmdConsole();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iVerbose;
+	TBool iIsRemote;
+	TBool iIsNull;
+	};
+	
+class CCmdPcons : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdPcons();
+private:
+	CCmdPcons();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	
+	void CreateL(RIoPersistentConsole& aPcons);
+	void AttachL(RIoPersistentConsole& aPcons, const TDesC& aNewOrExisting, TBool aForce);
+	TInt DoAttach(RIoPersistentConsole& aPcons, RIoConsole& aNew, RIoPersistentConsole::TCloseBehaviour aOnClose);
+private:
+	enum
+		{
+		EList,
+		ENew,
+		EConnect,
+		EStart,
+		EDisconnect,
+		} iOperation;
+	HBufC* iName;
+	HBufC* iCommand;
+	HBufC* iCommandArgs;
+	TBool iVerbose;
+	};
+
+class CCmdIoInfo : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdIoInfo();
+private:
+	CCmdIoInfo();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RIoHandle::TType iObjectType;
+	HBufC* iMatchString;
+	};
+
+class CCmdReattach : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdReattach();
+private:
+	CCmdReattach();
+	void OpenEndPointLC(RIoEndPoint& aEndPoint, const TDesC& aName);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iJobSpec;
+	HBufC* iStdinEndPointName;
+	HBufC* iStdoutEndPointName;
+	HBufC* iStderrEndPointName;
+	};
+
+class CCmdDisown : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdDisown();
+private:
+	CCmdDisown();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iJobSpec;
+	};
+
+class CCmdDebugPort : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdDebugPort();
+private:
+	CCmdDebugPort();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TInt iPort;
+	TBool iForce;
+	};
+
+class CCmdRom : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdRom();
+private:
+	CCmdRom();
+	void PrintIntL(TInt32 aInt32, const TDesC& aLabel, const TDesC& aDescription);
+	void PrintIntL(TInt64 aInt64, const TDesC& aLabel, const TDesC& aDescription);
+	void PrintUintL(TUint32 aUint32, const TDesC& aLabel, const TDesC& aDescription);
+	void PrintUintL(TUint64 aUint64, const TDesC& aLabel, const TDesC& aDescription);
+	void PrintAddressL(TLinAddr aAddress, const TDesC& aLabel, const TDesC& aDescription);
+	void PrintSizeL(TInt32 aSize, const TDesC& aLabel, const TDesC& aDescription);
+	void PrintTimeL(TInt64 aTime, const TDesC& aLabel, const TDesC& aDescription);
+	void PrintVersionL(TVersion aVersion, const TDesC& aLabel, const TDesC& aDescription);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	CTextBuffer* iBuffer;
+	TBool iVerbose;
+	TBool iHumanReadable;
+	};
+
+class CCmdWhich : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdWhich();
+private:
+	CCmdWhich();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	
+private:
+	HBufC* iCommand;
+	};
+
+class CCmdTee : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTee();
+private:
+	CCmdTee();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	
+private:
+	RArray<TFileName2> iFileNames;
+	RArray<RFile> iFiles;
+	TBool iAppend;
+	TBool iRdebug;
+	};
+
+class CCmdError : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdError();
+private:
+	CCmdError();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	
+private:
+	TInt iErrorVal;
+	HBufC* iErrorText;
+	};
+
+class CCmdReboot : public CMemoryAccessCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdReboot();
+private:
+	CCmdReboot();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	TUint iReason;
+	};
+	
+class CCmdForEach : public CCmdSource
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdForEach();
+private:
+	CCmdForEach();
+	void DoNextL(TBool aFirstTime=EFalse);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private: // From MParserObserver.
+	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+private:
+	TFileName2 iDirName;
+	RDir iDir;
+	TInt iLastError;
+	};
+	
+#endif // __COMMANDS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/console.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,89 @@
+// console.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32cons.h>
+#include <fshell/ioutils.h>
+#include "console.h"
+
+
+//
+// CConsoleReader.
+//
+
+CConsoleReader* CConsoleReader::NewL(RIoConsoleReadHandle& aStdin, MConsoleObserver& aObserver)
+	{
+	CConsoleReader* self = new(ELeave) CConsoleReader(aStdin, aObserver);
+	self->Queue();
+	return self;
+	}
+
+CConsoleReader::~CConsoleReader()
+	{
+	Cancel();
+	}
+
+CConsoleReader::CConsoleReader(RIoConsoleReadHandle& aStdin, MConsoleObserver& aObserver)
+	: CActive(CActive::EPriorityStandard), iStdin(aStdin), iObserver(aObserver)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CConsoleReader::Queue()
+	{
+	TInt result = iStdin.AttachedToConsole();
+	if (result > 0)
+		{
+		iRawRead = ETrue;
+		iStdin.Read(iRawReadBuf, iStatus);
+		}
+	else if (result == 0)
+		{
+		iRawRead = EFalse;
+		iStdin.WaitForKey(iStatus);
+		}
+	else
+		{
+		// This seems to happen if the console failed to construct
+		// [I've seen a E32USER-CBase 45 panic as a result of this call so possibly it's not always the right thing to do (I added this in the first place). -TomS]
+		iObserver.CoHandleError(result);
+		return;
+		}
+	SetActive();
+	}
+
+void CConsoleReader::RunL()
+	{
+	TInt err = iStatus.Int();
+	if (err)
+		{
+		iObserver.CoHandleError(err);
+		}
+	else
+		{
+		TUint keyCode = iRawRead ? iRawReadBuf[0] : iStdin.KeyCode();
+		TUint modifiers = iRawRead ? 0 : iStdin.KeyModifiers();
+		iObserver.CoHandleKey(keyCode, modifiers);
+		}
+	Queue();
+	}
+
+void CConsoleReader::DoCancel()
+	{
+	if (iRawRead)
+		{
+		iStdin.ReadCancel();
+		}
+	else
+		{
+		iStdin.WaitForKeyCancel();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/console.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,48 @@
+// console.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __CONSOLE_H__
+#define __CONSOLE_H__
+
+#include <e32base.h>
+#include <fshell/iocli.h>
+
+
+class MConsoleObserver
+	{
+public:
+	virtual void CoHandleKey(TUint aKeyCode, TUint aModifiers) = 0;
+	virtual void CoHandleError(TInt aError) = 0;
+	};
+
+
+class CConsoleReader : public CActive
+	{
+public:
+	static CConsoleReader* NewL(RIoConsoleReadHandle& aStdin, MConsoleObserver& aObserver);
+	~CConsoleReader();
+private:
+	CConsoleReader(RIoConsoleReadHandle& aStdin, MConsoleObserver& aObserver);
+	void Queue();
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	RIoConsoleReadHandle& iStdin;
+	MConsoleObserver& iObserver;
+	TBool iRawRead;
+	TBuf<1> iRawReadBuf;
+	};
+
+
+#endif // __CONSOLE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/error.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,73 @@
+// error.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __ERROR_H__
+#define __ERROR_H__
+
+#include <e32base.h>
+
+class RIoWriteHandle;
+namespace IoUtils
+	{
+	class CEnvironment;
+	}
+
+
+class TError
+	{
+public:
+	enum TReason
+		{
+		EUnknown,
+		EFailedToCreatePipeLine,
+		EFailedToConstructCommand,
+		EFailedToRunCommand,
+		EFailedToSetChildErrorVar,
+		ECommandError,
+		EFailedToSetScriptLineVar,
+		};
+public:
+	TError(RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv);
+	void Set(const TError& aError);
+	void Set(TInt aError, TReason aReason);
+	void Set(TInt aError, TReason aReason, TRefByValue<const TDesC> aFmt, ...);
+	void Report() const;
+	TInt Error() const;
+	TReason Reason() const;
+	const TDesC* Context() const;
+	const TDesC& ScriptFileName() const;
+	TInt ScriptLineNumber() const;
+private:
+	void Format(TRefByValue<const TDesC> aFmt, ...);
+	void FormatList(TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	void LogIfRequired(TInt aError, TReason aReason, TRefByValue<const TDesC> aFmt, ...);
+	void LogListIfRequired(TInt aError, TReason aReason, TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	const TDesC* StringifyReason(TReason aReason) const;
+	TBool Verbose() const;
+	void NewLine() const;
+	void PrintError() const;
+	void FormatError(TRefByValue<const TDesC> aFmt, ...) const;
+private:
+	RIoWriteHandle* iStderr;
+	IoUtils::CEnvironment* iEnv;
+	TInt iError;
+	TReason iReason;
+	TBool iSet;
+	TBuf<256> iContext;
+	mutable TBuf<512> iScratch;
+	TFileName iScriptFileName;
+	TInt iScriptLineNumber;
+	};
+
+
+#endif // __ERROR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/file_reader.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,146 @@
+// file_reader.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "file_reader.h"
+
+
+CFileReader* CFileReader::NewL(TInt aBlockSize, RFs& aFs, TBool aDirect)
+	{
+	CFileReader* self = new(ELeave) CFileReader(aFs, aDirect, aBlockSize);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CFileReader::~CFileReader()
+	{
+	Cancel();
+	iFile.Close();
+	delete iBuf;
+	}
+
+void CFileReader::Read(const TDesC& aFileName, MFileReaderObserver& aObserver)
+	{
+	Read(aFileName, 0, aObserver);
+	}
+
+void CFileReader::Read(const TDesC& aFileName, TInt aOffset, MFileReaderObserver& aObserver)
+	{
+	ASSERT(!IsActive());
+	iObserver = &aObserver;
+	iFirstRead = ETrue;
+	if (iDirect)
+		{
+		iDirectOffset = aOffset;
+		iFileName = aFileName;
+		ReadNextDirectChunk();
+		}
+	else
+		{
+		iFile.Close();
+		TInt err = iFile.Open(iFs, aFileName, EFileRead);
+		if (err)
+			{
+			iObserver->HandleFileReadError(err);
+			}
+		else
+			{
+			err = iFile.Seek(ESeekStart, aOffset);
+			if (err)
+				{
+				iObserver->HandleFileReadError(err);
+				}
+			ReadNextChunk();
+			}
+		}
+	}
+
+CFileReader::CFileReader(RFs& aFs, TBool aDirect, TInt aBlockSize)
+	: CActive(CActive::EPriorityStandard), iFs(aFs), iBlockSize(aBlockSize), iPtr(NULL, 0), iDirect(aDirect)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CFileReader::ConstructL()
+	{
+	iBuf = HBufC8::NewL(iBlockSize);
+	iPtr.Set(iBuf->Des());
+	}
+
+void CFileReader::ReadNextChunk()
+	{
+	ASSERT(!IsActive());
+	iPtr.Zero();
+	iFile.Read(iPtr, iBlockSize, iStatus);
+	SetActive();
+	}
+
+void CFileReader::ReadNextDirectChunk()
+	{
+	ASSERT(!IsActive());
+	iPtr.Zero();
+	SetActive();
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete(status, KErrNone);
+	}
+
+void CFileReader::DoCancel()
+	{
+	// Can't cancel reads, to do nothing.
+	}
+
+void CFileReader::RunL()
+	{
+	TInt err;
+	if (iDirect)
+		{
+		err = iFs.ReadFileSection(iFileName, iDirectOffset, iPtr, iBlockSize);
+		if (err == KErrNone)
+			{
+			iDirectOffset += iPtr.Length();
+			}
+		}
+	else
+		{
+		err = iStatus.Int();
+		}
+
+	if (err)
+		{
+		iObserver->HandleFileReadError(err);
+		return;
+		}
+
+	TBool keepGoing(EFalse);
+	if (iFirstRead)
+		{
+		iFirstRead = EFalse;
+		iObserver->HandleFileData(iPtr, MFileReaderObserver::EFirst, keepGoing);
+		}
+	else if (iPtr.Length() < iBlockSize)
+		{
+		iFile.Close();
+		TBool dummy;
+		iObserver->HandleFileData(iPtr, MFileReaderObserver::ELast, dummy);
+		}
+	else
+		{
+		iObserver->HandleFileData(iPtr, MFileReaderObserver::EMiddle, keepGoing);
+		}
+
+	if (keepGoing)
+		{
+		iDirect ? ReadNextDirectChunk() : ReadNextChunk();
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/file_reader.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,63 @@
+// file_reader.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __FILE_READER_H__
+#define __FILE_READER_H__
+
+#include <f32file.h>
+
+
+class MFileReaderObserver
+	{
+public:
+	enum TReadType
+		{
+		EFirst,
+		EMiddle,
+		ELast
+		};
+public:
+	virtual void HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue) = 0;
+	virtual void HandleFileReadError(TInt aError) = 0;
+	};
+
+
+class CFileReader : public CActive
+	{
+public:
+	static CFileReader* NewL(TInt aBlockSize, RFs& aFs, TBool aDirect);
+	~CFileReader();
+	void Read(const TDesC& aFileName, MFileReaderObserver& aObserver);
+	void Read(const TDesC& aFileName, TInt aOffset, MFileReaderObserver& aObserver);
+private:
+	CFileReader(RFs& aFs, TBool aDirect, TInt aBlockSize);
+	void ConstructL();
+	void ReadNextChunk();
+	void ReadNextDirectChunk();
+private:	// From CActive.
+	virtual void DoCancel();
+	virtual void RunL();
+private:
+	RFs& iFs;
+	MFileReaderObserver* iObserver;
+	TFileName iFileName;
+	TInt iBlockSize;
+	HBufC8* iBuf;
+	TPtr8 iPtr;
+	RFile iFile;
+	TBool iFirstRead;
+	TBool iDirect;
+	TInt iDirectOffset;
+	};
+
+
+#endif // __FILE_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/fshell.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,853 @@
+// fshell.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32cons.h>
+#include <f32file.h>
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+#include "string_utils.h"
+#include "line_completer.h"
+#include "command_factory.h"
+#include "fshell.h"
+#include "license.h"
+#include "script_command.h"
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+#include <fshell/memoryaccess.h>
+#endif
+
+//
+// Constants.
+//
+
+const TInt KNoForegroundJob = -1;
+
+
+//
+// Globals.
+//
+
+CShell* gShell;
+TInt gExitValue(KErrNone);
+
+
+//
+// TError.
+//
+
+TError::TError(RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv)
+	: iStderr(&aStderr), iEnv(&aEnv), iScriptLineNumber(-1)
+	{
+	if (iEnv->IsDefined(KScriptLine))
+		{
+		iScriptFileName = iEnv->GetAsDes(KScriptPath);
+		iScriptFileName.Append(iEnv->GetAsDes(KScriptName));
+		iScriptLineNumber = iEnv->GetAsInt(KScriptLine);
+		}
+	}
+
+void TError::Set(const TError& aError)
+	{
+	if (!iSet)
+		{
+		iError = aError.iError;
+		iReason = aError.iReason;
+		iContext = aError.iContext;
+		iScriptFileName = aError.iScriptFileName;
+		iScriptLineNumber = aError.iScriptLineNumber;
+		iSet = ETrue;
+		}
+	}
+
+void TError::Set(TInt aError, TReason aReason)
+	{
+	if (!iSet)
+		{
+		iError = aError;
+		iReason = aReason;
+		iContext.Zero();
+		iSet = ETrue;
+		}
+	LogIfRequired(aError, aReason, KNullDesC);
+	}
+
+void TError::Set(TInt aError, TReason aReason, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	if (!iSet)
+		{
+		iError = aError;
+		iReason = aReason;
+		Format(aFmt, list);
+		iSet = ETrue;
+		}
+	LogListIfRequired(aError, aReason, aFmt, list);
+	VA_END(list);
+	}
+
+void TError::Report() const
+	{
+	ASSERT(iError < 0);
+
+	switch (iReason)
+		{
+		case ECommandError:
+			{
+			// Do nothing - assume an error message has been printed by CCommandBase.
+			break;
+			}
+		case EFailedToConstructCommand:
+			{
+			FormatError(_L("Unable to create command \"%S\""), &iContext);
+			break;
+			}
+		case EFailedToRunCommand:
+			{
+			FormatError(_L("Unable to run command \"%S\""), &iContext);
+			break;
+			}
+		case EFailedToCreatePipeLine:
+		case EFailedToSetChildErrorVar:
+		case EFailedToSetScriptLineVar:
+		case EUnknown:
+		default:
+			{
+			PrintError();
+			break;
+			}
+		}
+	}
+
+void TError::Format(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	FormatList(aFmt, list);
+	VA_END(list);
+	}
+
+void TError::FormatList(TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	iContext.Zero();
+	TOverflowTruncate overflow;
+	iContext.AppendFormatList(aFmt, aList, &overflow);
+	}
+
+TInt TError::Error() const
+	{
+	return iError;
+	}
+
+TError::TReason TError::Reason() const
+	{
+	return iReason;
+	}
+
+const TDesC* TError::Context() const
+	{
+	return &iContext;
+	}
+
+const TDesC& TError::ScriptFileName() const
+	{
+	return iScriptFileName;
+	}
+
+TInt TError::ScriptLineNumber() const
+	{
+	return iScriptLineNumber;
+	}
+
+void TError::LogIfRequired(TInt aError, TReason aReason, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	LogListIfRequired(aError, aReason, aFmt, list);
+	VA_END(list);
+	}
+
+void TError::LogListIfRequired(TInt aError, TReason aReason, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	if (Verbose())
+		{
+		IoUtils::TOverflowTruncate overflow;
+		iScratch.Zero();
+		iScratch.AppendFormat(_L("Error: %S (%d), Reason: %S (%d), Context: \""), &overflow, Stringify::Error(aError), aError, StringifyReason(aReason), aReason);
+		iScratch.AppendFormatList(aFmt, aList, &overflow);
+		iScratch.AppendFormat(_L("\"\r\n"), &overflow);
+		iStderr->Write(iScratch);
+		}
+	}
+
+#define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
+#define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
+
+const TDesC* TError::StringifyReason(TReason aReason) const
+	{
+	switch (aReason)
+		{
+		CASE_RETURN_LIT(EUnknown);
+		CASE_RETURN_LIT(EFailedToCreatePipeLine);
+		CASE_RETURN_LIT(EFailedToConstructCommand);
+		CASE_RETURN_LIT(EFailedToRunCommand);
+		CASE_RETURN_LIT(EFailedToSetChildErrorVar);
+		CASE_RETURN_LIT(EFailedToSetScriptLineVar);
+		CASE_RETURN_LIT(ECommandError);
+		DEFAULT_RETURN_LIT("*** REASON UNKNOWN ***");
+		}
+	}
+
+TBool TError::Verbose() const
+	{
+	_LIT(KVerbose, "FSHELL_VERBOSE");
+	return (iEnv->IsDefined(KVerbose));
+	}
+
+void TError::NewLine() const
+	{
+	if (iStderr->AttachedToConsole())
+		{
+		RIoConsoleWriteHandle consoleWriteHandle;
+		consoleWriteHandle = *iStderr;
+		TPoint cursorPos;
+		consoleWriteHandle.GetCursorPos(cursorPos);
+		if (cursorPos.iX != 0)
+			{
+			iStderr->Write(_L("\r\n"));
+			}
+		}
+	}
+
+void TError::PrintError() const
+	{
+	NewLine();
+	IoUtils::TOverflowTruncate overflow;
+	iScratch.Zero();
+	iScratch.AppendFormat(_L("Error: %S (%d)\r\n"), &overflow, Stringify::Error(iError), iError);
+	iStderr->Write(iScratch);
+	}
+
+void TError::FormatError(TRefByValue<const TDesC> aFmt, ...) const
+	{
+	NewLine();
+	VA_LIST list;
+	VA_START(list, aFmt);
+	IoUtils::TOverflowTruncate overflow;
+	iScratch = _L("Error: ");
+	iScratch.AppendFormatList(aFmt, list, &overflow);
+	VA_END(list);
+	iScratch.AppendFormat(_L(" : %S (%d)\r\n"), Stringify::Error(iError), iError);
+	iStderr->Write(iScratch);
+	}
+
+//
+// CShell.
+//
+
+
+void Log(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	RFs fs;
+	TInt err = fs.Connect();
+	if (err == KErrNone)
+		{
+		RFile file;
+		err = file.Open(fs, _L("c:\\fshell.txt"), EFileWrite);
+		if (err == KErrNotFound)
+			{
+			err = file.Replace(fs, _L("c:\\fshell.txt"), EFileWrite);
+			}
+		if (err == KErrNone)
+			{
+			TOverflowTruncate8 overflow;
+			VA_LIST list;
+			VA_START(list, aFmt);
+			TBuf8<0x100> buf;
+			buf.AppendFormatList(aFmt, list, &overflow);
+			VA_END(list);
+			buf.Append(_L("\r\n"));
+			TInt pos(0);
+			file.Seek(ESeekEnd, pos);
+			file.Write(buf);
+			file.Close();
+			}
+		fs.Close();
+		}
+	}
+
+
+CShell* CShell::NewLC()
+	{
+	CShell* self = new(ELeave) CShell();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CShell::~CShell()
+	{
+	iJobsLock.Close();
+	iJobs.ResetAndDestroy();
+	delete iScriptArgs;
+	delete iLineEditor;
+	delete iLineCompleter;
+	delete iConsole;
+	delete iCommandFactory;
+	delete iScriptData;
+	delete iOneLiner;
+	delete iParser;
+	}
+
+CCommandFactory& CShell::CommandFactory()
+	{
+	return *iCommandFactory;
+	}
+
+void CShell::ClaimJobsLockLC()
+	{
+	iJobsLock.Wait();
+	CleanupStack::PushL(TCleanupItem(ReleaseJobsLock, const_cast<CShell*>(this)));
+	}
+
+void CShell::ReleaseJobsLock(TAny* aSelf)
+	{
+	static_cast<CShell*>(aSelf)->iJobsLock.Signal();
+	}
+
+TInt CShell::BringJobToForeground(TInt aJobId)
+	{
+	TInt ret = KErrNotFound;
+	CJob* job = Job(aJobId);
+	if (job != NULL)
+		{
+		Printf(_L("[%d] %S\r\n"), aJobId, job->Name());
+		job->Resume();
+		ret = job->BringToForeground();
+		if (ret == KErrNone)
+			{
+			if (iForegroundJobId != KNoForegroundJob)
+				{
+				ForegroundJob().SendToBackground();
+				}
+			iForegroundJobId = aJobId;
+			}
+		}
+	if (ret)
+		{
+		PrintError(ret, _L("Unable to bring job [%d] to foreground"), aJobId);
+		}
+	return ret;
+	}
+
+void CShell::SendJobToBackground(TInt aJobId)
+	{
+	CJob* job = Job(aJobId);
+	if (job != NULL)
+		{
+		job->SendToBackground();
+		job->Resume();
+		Printf(_L("[%d] %S\r\n"), aJobId, job->Name());
+		if (aJobId == iForegroundJobId)
+			{
+			iForegroundJobId = KNoForegroundJob;
+			}
+		}
+	else
+		{
+		PrintError(KErrNotFound, _L("Unable to send job [%d] to background"), aJobId);
+		}
+	}
+
+const RPointerArray<CJob>& CShell::Jobs() const
+	{
+	ASSERT(const_cast<RMutex&>(iJobsLock).IsHeld()); // IsHeld should be const but isn't
+	return iJobs;
+	}
+
+CShell::CShell()
+	: CCommandBase(EManualComplete | ENotifyStdinChanges | ESharableIoSession), iForegroundJobId(KNoForegroundJob), iWriterAdaptor(Stdout())
+	{
+	gShell = this;
+	}
+
+void CShell::ConstructL()
+	{
+	BaseConstructL();
+	User::LeaveIfError(iJobsLock.CreateLocal());
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	// We call LoadDriver here so that memoryaccess gets a chance to start the thread creator tracker as early as possible
+	// Possibly this isn't the best place to put it...
+	RMemoryAccess::LoadDriver();
+#endif
+	}
+
+void CShell::PrintPrompt()
+	{
+	const TDesC& pwd = Env().Pwd();
+	// Truncate the prompt if it will take up more than half the screen, or half of KMaxLineLength
+	TInt maxLen = KMaxLineLength / 2;
+	TSize screenSize;
+	TInt err = Stdout().GetScreenSize(screenSize);
+	if (err == KErrNone && screenSize.iWidth > 3) maxLen = Min(maxLen, screenSize.iWidth / 2); // Nullcons has a width of 1, apparently
+	TBuf<KMaxLineLength> prompt;
+	if (pwd.Length() > maxLen)
+		{
+		TPtrC left(pwd.Left(3)); // For the driveletter:\ bit
+		TPtrC right = pwd.Right(maxLen - 3);
+		prompt.Format(_L("%S...%S>"), &left, &right);
+		}
+	else
+		{
+		prompt.Format(_L("%S>"), &pwd);
+		}
+	iLineEditor->Start(prompt);
+	iLineEditor->ReinstatePromptAndUserInput();
+	}
+
+void CShell::PrintErr(TInt aError)
+	{
+	TPoint cursorPos;
+	Stdout().GetCursorPos(cursorPos);
+	if (cursorPos.iX != 0)
+		{
+		Stderr().Write(_L("\r\n"));
+		}
+	TBuf<128> buf;
+	IoUtils::TOverflowTruncate overflow;
+	buf.AppendFormat(_L("Error: %S (%d)\r\n"), &overflow, Stringify::Error(aError), aError);
+	Stderr().Write(buf);
+	}
+
+void CShell::ProcessLineL(const TDesC& aLine)
+	{
+	TInt jobId = NextJobId();
+	CJob* job = CJob::NewL(jobId, aLine, IoSession(), Stdin(), Stdout(), Stderr(), Env(), *iCommandFactory, this);
+	CleanupStack::PushL(job);
+	ClaimJobsLockLC();
+	User::LeaveIfError(iJobs.Append(job));
+	CleanupStack::PopAndDestroy(); // Jobs lock
+	CleanupStack::Pop(job);
+	iNextJobId = jobId;
+	TBool isForeground(EFalse);
+	job->Start(isForeground);
+	if (isForeground)
+		{
+		iForegroundJobId = jobId;
+		}
+	else
+		{
+		PrintPrompt();
+		}
+	}
+
+const TDesC& CShell::Name() const
+	{
+	_LIT(KName, "fshell");
+	return KName;
+	}
+
+void CShell::DoRunL()
+	{
+#if defined (__WINS__) && !defined (EKA2)
+	RThread().SetPriority(::EPriorityAbsoluteHigh);
+#else
+	RProcess().SetPriority(::EPriorityHigh);
+#endif
+	User::LeaveIfError(iFs.Connect());
+	User::LeaveIfError(iFs.ShareAuto()); // Necessary because this handle is used by CCommandFactory and that can be used from the context of other threads (e.g. the "debug" command).
+	iCommandFactory = CCommandFactory::NewL(iFs);
+
+	if (iOneLiner)
+		{
+		// One line script mode.
+		iParser = CParser::NewL(CParser::ENormal, *iOneLiner, IoSession(), Stdin(), Stdout(), Stderr(), Env(), *iCommandFactory, this);
+		RProcess::Rendezvous(KErrNone);
+		iParser->Start();
+		}
+	else if (iScriptName.Length() > 0)
+		{
+		TIoHandleSet ioHandles(IoSession(), Stdin(), Stdout(), Stderr());
+		TBool helpPrinted;
+		iScriptData = ReadScriptL(iScriptName, iScriptArgs, Env(), FsL(), ioHandles, helpPrinted);
+		if (helpPrinted)
+			{
+			Complete();
+			}
+		else
+			{
+			TUint mode = CParser::EExportLineNumbers;
+			if (iKeepGoing)
+				{
+				mode |= CParser::EKeepGoing;
+				}
+			iParser = CParser::NewL(mode, *iScriptData, IoSession(), Stdin(), Stdout(), Stderr(), Env(), *iCommandFactory, this);
+			RProcess::Rendezvous(KErrNone);
+			iParser->Start();
+			}
+		}
+	else
+		{
+		// Interactive mode.
+
+#ifdef FSHELL_CORE_SUPPORT_LICENSE
+		if (TLicense::CheckL(Stdin(), Stdout()) != TLicense::EValid)
+			{
+			Complete(KErrPermissionDenied);
+			return;
+			}
+#endif
+		
+		User::LeaveIfError(Stdin().CaptureKey(CTRL('c'), 0, 0));
+		User::LeaveIfError(Stdin().CaptureKey(CTRL('z'), 0, 0));
+		iConsole = CConsoleReader::NewL(Stdin(), *this);
+		iLineCompleter = CLineCompleter::NewL(iFs, *iCommandFactory, Env());
+		_LIT(KFshellHistory, "c:\\system\\console\\shell\\history");
+		iLineEditor = CLineEditor::NewL(iFs, iWriterAdaptor, *this, *iLineCompleter, KFshellHistory);
+		RProcess::Rendezvous(KErrNone);
+		PrintPrompt();
+		}
+	}
+
+void CShell::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KOptExec, "exec");
+	aOptions.AppendStringL(iOneLiner, KOptExec);
+	_LIT(KOptKeepGoing, "keep-going");
+	aOptions.AppendBoolL(iKeepGoing, KOptKeepGoing);
+	}
+
+void CShell::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgScriptName, "script_name");
+	aArguments.AppendFileNameL(iScriptName, KArgScriptName);
+
+	_LIT(KArgArgs, "script_args");
+	aArguments.AppendStringL(iScriptArgs, KArgArgs);
+	}
+	
+void CShell::StdinChange(TUint)
+	{
+	if (iLineEditor && !iIgnoreNextStdinChange)
+		{
+		iLineEditor->Redraw();
+		}
+	iIgnoreNextStdinChange = EFalse;
+	}
+
+TInt CShell::NextJobId()
+	{
+	TInt next = iNextJobId;
+	++next;
+	if (next == KNoForegroundJob)
+		{
+		next = 0;
+		}
+	return next;
+	}
+
+CJob& CShell::ForegroundJob()
+	{
+	ASSERT(iForegroundJobId != KNoForegroundJob);
+	CJob* job = Job(iForegroundJobId);
+	ASSERT(job != NULL);
+	return *job;
+	}
+
+CJob* CShell::Job(TInt aId)
+	{
+	ASSERT(iJobsLock.IsHeld());
+	const TInt numJobs = iJobs.Count();
+	CJob* job = NULL;
+	for (TInt i = 0; i < numJobs; ++i)
+		{
+		if (iJobs[i]->Id() == aId)
+			{
+			job = iJobs[i];
+			break;
+			}
+		}
+	return job;
+	}
+
+TInt CShell::DisownJob(TInt aId)
+	{
+	ASSERT(iJobsLock.IsHeld());
+	const TInt numJobs = iJobs.Count();
+	for (TInt i = 0; i < numJobs; ++i)
+		{
+		CJob* job = iJobs[i];
+		if (job->Id() == aId)
+			{
+			if (job->IsDisownable())
+				{
+				job->Disown();
+				delete job;
+				iJobs.Remove(i);
+				return KErrNone;
+				}
+			else
+				{
+				return KErrAccessDenied;
+				}
+			}
+		}
+	return KErrNotFound;
+	}
+
+HBufC* CShell::ReadScriptL(const TDesC& aScriptName, const TDesC* aArguments, IoUtils::CEnvironment& aEnv, RFs& aFs, TIoHandleSet& aIoHandles, TBool& aHelpPrinted, RPointerArray<HBufC>* aAdditionalPrefixArguments)
+	{
+	TFileName2 scriptName(aScriptName);
+
+	// Check the scripts dirs in case it wasn't given as an absolute path (although iocli will have made it absolute relative to the pwd)
+	_LIT(KScriptDir, "y:\\system\\console\\scripts\\");
+	_LIT(KScriptSuffix, ".script");
+	TInt scriptNameLen = scriptName.Length();
+	if (!scriptName.Exists(aFs) && (scriptName.DriveAndPath().CompareF(aEnv.Pwd()) == 0))
+		{
+		TFindFile finder(aFs);
+		TInt found = finder.FindByDir(scriptName.NameAndExt(), KScriptDir);
+		if (found == KErrNotFound && scriptName.Right(KScriptSuffix().Length()).CompareF(KScriptSuffix) != 0)
+			{
+			// If it doesn't already end in .script, try that
+			scriptName.Append(KScriptSuffix);
+			found = finder.FindByDir(scriptName.NameAndExt(), KScriptDir);
+			}
+		if (found == KErrNone)
+			{
+			scriptName.Copy(finder.File());
+			}
+		else
+			{
+			// Put scriptname back the way it was
+			scriptName.SetLength(scriptNameLen);
+			} 
+		}
+
+	RFile scriptFile;
+	TInt err;
+	TInt retries = 5;
+	do
+		{
+		err = scriptFile.Open(aFs, scriptName, EFileRead | EFileShareReadersOnly);
+		if ((err == KErrNone) || (err != KErrInUse))
+			{
+			break;
+			}
+		User::After(500000);
+		--retries;
+		}
+		while (retries >= 0);
+	StaticLeaveIfErr(err, _L("Couldn't open script file %S"), &scriptName);
+	CleanupClosePushL(scriptFile);
+	TInt scriptFileSize;
+	User::LeaveIfError(scriptFile.Size(scriptFileSize));
+	HBufC8* scriptData = HBufC8::NewLC(scriptFileSize);
+	TPtr8 scriptDataPtr(scriptData->Des());
+	User::LeaveIfError(scriptFile.Read(scriptDataPtr));
+	HBufC* decodedScriptData = LtkUtils::DecodeUtf8L(*scriptData);
+	CleanupStack::PopAndDestroy(2, &scriptFile);
+	CleanupStack::PushL(decodedScriptData);
+	aEnv.SetLocalL(KScriptName);
+	aEnv.SetLocalL(KScriptPath);
+	aEnv.SetLocalL(KScriptLine);
+	aEnv.SetLocalL(_L("0"));
+	aEnv.SetL(KScriptName, scriptName.NameAndExt());
+	aEnv.SetL(KScriptPath, scriptName.DriveAndPath());
+	aEnv.SetL(_L("0"), scriptName);
+	CScriptCommand* scriptCommand = CScriptCommand::NewLC(scriptName, aIoHandles);
+	TRAP(err, scriptCommand->ParseCommandLineArgsL(aArguments ? *aArguments : KNullDesC(), aEnv, aAdditionalPrefixArguments));
+	if (err == KErrArgument || scriptCommand->ShouldDisplayHelp())
+		{
+		// Need to display help
+		if (scriptCommand->ShouldDisplayHelp())
+			{
+			err = KErrNone;
+			}
+		else if (err == KErrArgument)
+			{
+			scriptCommand->PrintError(KErrArgument, _L("Couldn't parse command line"));
+			}
+		scriptCommand->DisplayScriptHelpL();
+		aHelpPrinted = ETrue;
+		}
+	else
+		{
+		aHelpPrinted = EFalse;
+		}
+	User::LeaveIfError(err); // Propagate error
+	CleanupStack::PopAndDestroy(scriptCommand);
+	CleanupStack::Pop(decodedScriptData);
+	return decodedScriptData;
+	}
+
+void CShell::SetToForeground()
+	{
+	Stdin().SetToForeground();
+	iIgnoreNextStdinChange = ETrue;
+	}
+
+void CShell::CoHandleKey(TUint aKeyCode, TUint aModifiers)
+	{
+	switch (aKeyCode)
+		{
+		case CTRL('c'):
+			{
+			if (iForegroundJobId == KNoForegroundJob)
+				{
+				PrintPrompt();
+				}
+			else
+				{
+				ClaimJobsLockLC();
+				ForegroundJob().Kill();
+				CleanupStack::PopAndDestroy(); // Jobs lock.
+				}
+			SetToForeground();
+			break;
+			}
+		case CTRL('z'):
+			{
+			if (iForegroundJobId != KNoForegroundJob)
+				{
+				ClaimJobsLockLC();
+				CJob& job = ForegroundJob();
+				job.Suspend();
+				CleanupStack::PopAndDestroy(); // Jobs lock.
+				SetToForeground();
+				Printf(_L("[%d] %S\t\t%S\r\n"), iForegroundJobId, ShStringify::JobStatus(job.Status()), job.Name());
+				PrintPrompt();
+				iForegroundJobId = KNoForegroundJob;
+				}
+			break;
+			}
+		default:
+			{
+			// Only handle the key if there's no foreground job. Note, it's possible for the foreground job
+			// to still be pending, but have implicilty given keyboard focus back to fshell. For example:
+			//
+			// sleep& && echo hello
+			//
+			// The above job will not complete until the background sleep command is killed. During this period
+			// fshell has implicitly taken keyboard focus because the hello command has released it. However
+			// fshell's line editor hasn't been started and so isn't ready to handle input. Perhaps the line
+			// editor should implicitly start in this situation? For the time being playing safe by ignoring
+			// the keyboard input if there's a foreground job in progress.
+			if (iForegroundJobId == KNoForegroundJob)
+				{
+				iLineEditor->HandleKey(aKeyCode, aModifiers);
+				}
+			}
+		}
+	}
+
+void CShell::CoHandleError(TInt aError)
+	{
+	// Treat console errors as fatal (they're likely to be due to a remote console being closed).
+	if (!IsComplete()) Complete(aError);
+	}
+
+void CShell::LeoHandleLine(const TDesC& aLine)
+	{
+	if (aLine.Length() > 0)
+		{
+		TRAPD(err, ProcessLineL(aLine));
+		if (err)
+			{
+			PrintErr(err);
+			PrintPrompt();
+			}
+		}
+	else
+		{
+		PrintPrompt();
+		}
+	}
+
+void CShell::HandleJobComplete(CJob& aJob, const TError& aError)
+	{
+	if (aError.Error() < 0)
+		{
+		aError.Report();
+		}
+
+	if (aJob.Id() == iForegroundJobId)
+		{
+		iForegroundJobId = KNoForegroundJob;
+		PrintPrompt();
+		}
+
+#ifdef _DEBUG
+	TInt pos = iJobs.Find(&aJob);
+	ASSERT(pos >= 0);
+#else
+	TInt pos = iJobs.Find(&aJob);
+#endif
+
+	delete &aJob;
+	iJobs.Remove(pos);
+	}
+
+void CShell::HandleParserComplete(CParser&, const TError& aError)
+	{
+	if ((aError.Error() < 0))
+		{
+		aError.Report();
+		if (!iOneLiner)
+			{
+			PrintError(aError.Error(), _L("Aborted \"%S\" at line %d"), &aError.ScriptFileName(), aError.ScriptLineNumber());
+			}
+		SetErrorReported(ETrue);
+		}
+
+	gExitValue = aError.Error();
+	Complete(aError.Error());
+	}
+
+
+//
+// Main.
+//
+
+void MainL()
+	{
+	_LIT(KShellName, "fshell");
+#ifdef EKA2
+	User::RenameThread(KShellName);
+#else
+	RThread().Rename(KShellName);
+#endif
+	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+	IoUtils::CCommandBase* command = CShell::NewLC();
+	command->RunCommandL();
+	CleanupStack::PopAndDestroy(2, scheduler);
+	if (gExitValue)
+		{
+		User::Leave(gExitValue);
+		}
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	TInt err = KErrNoMemory;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup)
+		{
+		TRAP(err, MainL());
+		delete cleanup;
+		}
+	__UHEAP_MARKEND;
+	return err;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/fshell.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,100 @@
+// fshell.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __SHELL_H__
+#define __SHELL_H__
+
+#include <e32base.h>
+#include <fshell/iocli.h>
+#include <fshell/ioutils.h>
+#include "job.h"
+#include "error.h"
+#include "console.h"
+#include <fshell/line_editor.h>
+#include <fshell/iocons_writer.h>
+
+
+_LIT(KScriptPath, "SCRIPT_PATH");
+_LIT(KScriptName, "SCRIPT_NAME");
+_LIT(KScriptLine, "SCRIPT_LINE");
+_LIT(KScriptArgCount, "ARG_COUNT");
+_LIT(KKeepGoing, "KEEP_GOING");
+
+class CLineCompleter;
+class CCommandFactory;
+
+
+class CShell : public IoUtils::CCommandBase, public MConsoleObserver, public MLineEditorObserver, public MJobObserver, public MParserObserver
+	{
+public:
+	static CShell* NewLC();
+	~CShell();
+	CCommandFactory& CommandFactory();
+	void ClaimJobsLockLC();
+	TInt BringJobToForeground(TInt aJobId);
+	void SendJobToBackground(TInt aJobId);
+	const RPointerArray<CJob>& Jobs() const;
+	CJob* Job(TInt aId);
+	TInt DisownJob(TInt aId);
+	static HBufC* ReadScriptL(const TDesC& aScriptName, const TDesC* aArguments, IoUtils::CEnvironment& aEnv, RFs& aFs, TIoHandleSet& aIoHandles, TBool& aHelpPrinted, RPointerArray<HBufC>* aAdditionalPrefixArguments=NULL);
+private:
+	CShell();
+	void ConstructL();
+	void PrintPrompt();
+	void PrintErr(TInt aError);
+	void ProcessLineL(const TDesC& aLine);
+	TInt NextJobId();
+	CJob& ForegroundJob();
+	void SetToForeground();
+	static void ReleaseJobsLock(TAny* aSelf);
+private: // From IoUtils::CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void OptionsL(RCommandOptionList& aOptions);
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void StdinChange(TUint aChange);
+private: // From MConsoleObserver.
+	virtual void CoHandleKey(TUint aKeyCode, TUint aModifiers);
+	virtual void CoHandleError(TInt aError);
+private: // From MLineEditorObserver.
+	virtual void LeoHandleLine(const TDesC& aLine);
+private: // From MJobObserver.
+	virtual void HandleJobComplete(CJob& aJob, const TError& aError);
+private: // From MParserObserver.
+	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+private:
+	RFs iFs;
+	CConsoleReader* iConsole;
+	CLineEditor* iLineEditor;
+	CLineCompleter* iLineCompleter;
+	CCommandFactory* iCommandFactory;
+	RPointerArray<CJob> iJobs;
+	HBufC* iScriptData;
+	CParser* iParser;
+	TInt iForegroundJobId;
+	TInt iNextJobId;
+	TIoConsWriterAdaptor iWriterAdaptor;
+	TFileName2 iScriptName;
+	HBufC* iScriptArgs;
+	HBufC* iOneLiner;
+	TBool iKeepGoing;
+	TBool iIgnoreNextStdinChange;
+	RMutex iJobsLock;
+	};
+
+extern CShell* gShell;
+extern TInt gExitValue;
+void Log(TRefByValue<const TDesC8> aFmt, ...);
+
+
+#endif // __SHELL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/fshell.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,95 @@
+// fshell.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          fshell.exe
+targettype      exe
+uid             0x100039CE FSHELL_UID_FSHELL
+capability      FSHELL_CAP_MMP_MAX
+
+userinclude     .
+userinclude     ..\builtins
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+
+#ifdef FSHELL_CORE_SUPPORT_LOCAL_ICON
+
+START RESOURCE	fshell_reg.rss
+    TARGETPATH  \private\10003a3f\apps
+END
+
+START RESOURCE  fshell_loc.rss
+    TARGETPATH  \resource\apps
+    LANG        SC
+END
+
+#ifdef FSHELL_PLATFORM_UIQ
+START BITMAP	fshellAppIcon.mbm
+TARGETPATH		\resource\apps
+SOURCEPATH		.\AppIcon
+SOURCE	c24		fshell_Small.bmp
+SOURCE	8		fshell_Small_mask.bmp
+SOURCE	c24		fshell_Large.bmp
+SOURCE	8		fshell_Large_mask.bmp
+SOURCE	c24		fshell_xLarge.bmp
+SOURCE	8		fshell_xLarge_mask.bmp
+SOURCE	c24		48x48.bmp
+SOURCE	8		48x48.bmp
+END
+#endif
+
+#endif // FSHELL_CORE_SUPPORT_LOCAL_ICON
+
+source          fshell.cpp
+source          job.cpp
+source          parser.cpp
+source          console.cpp
+source          commands.cpp
+source          pipe_line.cpp
+source          command_factory.cpp
+source          command_constructors.cpp
+source          command_wrappers.cpp
+source          line_completer.cpp
+source          string_utils.cpp
+source          lexer.cpp
+source          file_reader.cpp
+source          script_command.cpp
+
+sourcepath      ..\builtins
+source          hello.cpp
+source          kill.cpp
+source          ps.cpp
+source          undertaker.cpp
+source          fuser.cpp
+source          gobble.cpp
+source          xmodem.cpp
+source          ymodem.cpp
+source          version.cpp
+
+sourcepath      \epoc32\build\fshell\core\generated
+source          fshell_version.cpp
+#ifdef FSHELL_CORE_SUPPORT_LICENSE
+source          license.cpp
+#endif
+
+library         euser.lib
+library         efsrv.lib
+library         hal.lib
+library         iocli.lib
+library			lineeditor.lib
+library			ltkutils-tcb.lib
+
+START WINS
+win32_library   kernel32.lib
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/fshell.rls	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// fshell.rls
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+/*&
+@localize no
+@description dummy
+@uicontext ShortAppTitleBar
+*/
+rls_string STRING_r_fshell_short_caption "fshell" 
+
+/*&
+@localize no
+@description dummy
+@uicontext AppTitleBar
+*/
+rls_string STRING_r_fshell_caption "fshell" 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/fshell_loc.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// fshell_loc.rss
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+#include "fshell.rls"
+
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	short_caption = STRING_r_fshell_short_caption;
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO
+			{
+			caption = STRING_r_fshell_caption;
+#ifdef FSHELL_PLATFORM_UIQ
+			number_of_icons = 4;
+			icon_file = "\\Resource\\Apps\\fshellAppIcon.mbm";
+#else
+			number_of_icons = 1;
+			icon_file = "\\Resource\\Apps\\fshell_local.mif";
+#endif
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/fshell_reg.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// fshell_reg.rss
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <AppInfo.rh>
+#include <fshell/common.mmh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 FSHELL_UID_FSHELL // application UID
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "fshell"; // filename of application binary (minus extension)
+	localisable_resource_file = "\\resource\\apps\\fshell_loc";
+	hidden = KAppNotHidden;
+	embeddability = KAppNotEmbeddable;
+	newfile = KAppDoesNotSupportNewFile;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/job.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,136 @@
+// job.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "job.h"
+#include "command_factory.h"
+
+
+//
+// CJob.
+//
+
+CJob* CJob::NewL(TInt aId, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MJobObserver* aObserver)
+	{
+	CJob* self = new(ELeave) CJob(aId, aObserver, aStderr, aEnv);
+	CleanupStack::PushL(self);
+	self->ConstructL(aCommandLine, aIoSession, aStdin, aStdout, aStderr, aEnv, aFactory);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CJob::~CJob()
+	{
+	delete iParser;
+	delete iCommandLine;
+	delete iCompletionCallBack;
+	}
+
+void CJob::Start(TBool& aIsForeground)
+	{
+	iParser->Start(aIsForeground);
+	}
+
+CJob::CJob(TInt aId, MJobObserver* aObserver, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv)
+	: iId(aId), iStatus(EPending), iObserver(aObserver), iCompletionError(aStderr, aEnv)
+	{
+	}
+
+void CJob::Kill()
+	{
+	iParser->Kill();
+	}
+
+void CJob::Suspend()
+	{
+	TInt err = iParser->Suspend();
+	if (err == KErrNone)
+		{
+		iStatus = EStopped;
+		}
+	}
+
+void CJob::Resume()
+	{
+	TInt err = iParser->Resume();
+	if (err == KErrNone)
+		{
+		iStatus = ERunning;
+		}
+	}
+
+TInt CJob::BringToForeground()
+	{
+	return iParser->BringToForeground();
+	}
+
+void CJob::SendToBackground()
+	{
+	iParser->SendToBackground();
+	}
+
+TInt CJob::Id() const
+	{
+	return iId;
+	}
+
+const TDesC* CJob::Name() const
+	{
+	return iCommandLine;
+	}
+
+CJob::TStatus CJob::Status() const
+	{
+	return iStatus;
+	}
+
+TInt CJob::Reattach(RIoEndPoint& aStdinEndPoint, RIoEndPoint& aStdoutEndPoint, RIoEndPoint& aStderrEndPoint)
+	{
+	return iParser->Reattach(aStdinEndPoint, aStdoutEndPoint, aStderrEndPoint);
+	}
+
+TBool CJob::IsDisownable() const
+	{
+	return iParser->IsDisownable();
+	}
+
+void CJob::Disown()
+	{
+	iParser->Disown();
+	}
+
+void CJob::ConstructL(const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory)
+	{
+	if (iObserver)
+		{
+		iCompletionCallBack = new(ELeave) CAsyncCallBack(TCallBack(CompletionCallBack, this), CActive::EPriorityStandard);
+		}
+	iCommandLine = aCommandLine.AllocL();
+	iParser = CParser::NewL(CParser::ENormal, *iCommandLine, aIoSession, aStdin, aStdout, aStderr, aEnv, aFactory, this);
+	iStatus = ERunning;
+	}
+
+TInt CJob::CompletionCallBack(TAny* aSelf)
+	{
+	CJob* self = static_cast<CJob*>(aSelf);
+	self->iObserver->HandleJobComplete(*self, self->iCompletionError);
+	return KErrNone;
+	}
+
+void CJob::HandleParserComplete(CParser& aParser, const TError& aError)
+	{
+	ASSERT(iParser == &aParser);
+	iCompletionError = aError;
+	if (iObserver)
+		{
+		iCompletionCallBack->CallBack();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/job.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+// job.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __JOB_H__
+#define __JOB_H__
+
+#include <e32base.h>
+#include "parser.h"
+
+class CJob;
+class RIoSession;
+class MConsole;
+class CParser;
+class CCommandFactory;
+
+class MJobObserver
+	{
+public:
+	virtual void HandleJobComplete(CJob& aJob, const TError& aError) = 0;
+	};
+
+
+class CJob : public CBase, public MParserObserver
+	{
+public:
+	enum TStatus
+		{
+		EPending,
+		ERunning,
+		EStopped,
+		EComplete
+		};
+public:
+	static CJob* NewL(TInt aId, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MJobObserver* aObserver);
+	~CJob();
+	void Start(TBool& aIsForeground);
+	void Kill();
+	void Suspend();
+	void Resume();
+	TInt BringToForeground();
+	void SendToBackground();
+	TInt Id() const;
+	const TDesC* Name() const;
+	TStatus Status() const;
+	TInt Reattach(RIoEndPoint& aStdinEndPoint, RIoEndPoint& aStdoutEndPoint, RIoEndPoint& aStderrEndPoint);
+	TBool IsDisownable() const;
+	void Disown();
+private:
+	CJob(TInt aId, MJobObserver* aObserver, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv);
+	void ConstructL(const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory);
+	static TInt CompletionCallBack(TAny* aSelf);
+private:	// From MParserObserver.
+	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+private:
+	TInt iId;
+	TStatus iStatus;
+	MJobObserver* iObserver;
+	HBufC* iCommandLine;
+	TError iCompletionError;
+	CAsyncCallBack* iCompletionCallBack;
+	CParser* iParser;
+	};
+
+#endif // __JOB_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/lexer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,347 @@
+// lexer.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "lexer.h"
+
+
+//
+// TToken
+//
+
+TToken::TToken()
+	: iToken(NULL, 0), iPos(0)
+	{
+	}
+
+TToken::TToken(TType aType, const TDesC& aToken, TInt aPos)
+	: iType(aType), iToken(aToken), iPos(aPos)
+	{
+	}
+
+TToken& TToken::operator=(const TToken& aToken)
+	{
+	iType = aToken.iType;
+	iToken.Set(aToken.iToken);
+	iPos = aToken.iPos;
+	return *this;
+	}
+
+TToken::TType TToken::Type() const
+	{
+	return iType;
+	}
+
+TInt TToken::Position() const
+	{
+	return iPos;
+	}
+
+const TDesC& TToken::String() const
+	{
+	return iToken;
+	}
+
+
+//
+// CReservedLookup
+//
+
+class CReservedLookup : public CBase
+	{
+public:
+	class TResult
+		{
+	public:
+		enum TType
+			{
+			ENoMatch,
+			EMatch
+			};
+	public:
+		TResult();
+	public:
+		TType iResultType;
+		TToken::TType iTokenType;
+		TInt iTokenLength;
+		};
+	enum TCharPos
+		{
+		ENotLast,
+		ELast
+		};
+public:
+	static CReservedLookup* NewL();
+	~CReservedLookup();
+	void DefineTokenTypeL(TToken::TType aTokenType, const TDesC& aString);
+	void Reset();
+	TResult Lookup(const TDesC& aDes);
+private:
+	class TReserved
+		{
+	public:
+		TReserved(TToken::TType aType, const TDesC& aString);
+	public:
+		TToken::TType iType;
+		TPtrC iString;
+		};
+private:
+	RArray<TReserved> iList;
+	};
+
+CReservedLookup* CReservedLookup::NewL()
+	{
+	return new(ELeave) CReservedLookup();
+	}
+
+CReservedLookup::~CReservedLookup()
+	{
+	iList.Close();
+	}
+
+void CReservedLookup::DefineTokenTypeL(TToken::TType aTokenType, const TDesC& aString)
+	{
+	User::LeaveIfError(iList.Append(TReserved(aTokenType, aString)));
+	}
+
+CReservedLookup::TResult CReservedLookup::Lookup(const TDesC& aDes)
+	{
+	// Find the longest reserved word that matches from the beginning of this string.
+	TResult result;
+	const TInt count = iList.Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		const TReserved& reserved = iList[i];
+		if (aDes.Left(reserved.iString.Length()) == reserved.iString)
+			{
+			if (result.iTokenLength < reserved.iString.Length())
+				{
+				result.iTokenLength = reserved.iString.Length();
+				result.iResultType = TResult::EMatch;
+				result.iTokenType = reserved.iType;
+				}
+			}
+		}
+	return result;
+	}
+
+CReservedLookup::TReserved::TReserved(TToken::TType aType, const TDesC& aString)
+	: iType(aType), iString(aString)
+	{
+	}
+
+CReservedLookup::TResult::TResult()
+	: iResultType(ENoMatch), iTokenType(TToken::EString), iTokenLength(0)
+	{
+	}
+
+
+//
+// CLexer
+//
+
+CLexer* CLexer::NewL()
+	{
+	CLexer* self = CLexer::NewLC();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CLexer* CLexer::NewL(TUint aBehaviour)
+	{
+	CLexer* self = CLexer::NewLC(aBehaviour);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CLexer* CLexer::NewLC()
+	{
+	CLexer* self = new(ELeave) CLexer(EHandleSingleQuotes | EHandleDoubleQuotes | EHandleComments);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CLexer* CLexer::NewLC(TUint aBehaviour)
+	{
+	CLexer* self = new(ELeave) CLexer(aBehaviour);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CLexer::~CLexer()
+	{
+	delete iReservedLookup;
+	}
+
+void CLexer::DefineTokenTypeL(TToken::TType aTokenType, const TDesC& aString)
+	{
+	iReservedLookup->DefineTokenTypeL(aTokenType, aString);
+	}
+
+void CLexer::Set(const TDesC& aDes, const TChar& aEscapeChar)
+	{
+	iLex = aDes;
+	iEscapeChar = aEscapeChar;
+	}
+
+TToken CLexer::NextToken()
+	{
+	SkipWhiteSpace();
+	iLex.Mark();
+	TToken::TType type(TToken::ENull);
+
+	while (!iLex.Eos())
+		{
+		type = TToken::EString;
+		TChar c = iLex.Get();
+		if (c == iEscapeChar)
+			{
+			iLex.Get();
+			}
+		else if ((c == '\'') && (iBehaviour & EHandleSingleQuotes))
+			{
+			SkipSingleQuotedChars();
+			}
+		else if ((c == '\"') && (iBehaviour & EHandleDoubleQuotes))
+			{
+			SkipDoubleQuotedChars();
+			}
+		else if ((c == '#') && (iBehaviour & EHandleComments))
+			{
+			if (iLex.MarkedToken().Length() > 1)
+				{
+				iLex.UnGet();
+				break;
+				}
+			else
+				{
+				SkipComment();
+				if (iLex.Eos())
+					{
+					type = TToken::ENull;
+					break;
+					}
+				else
+					{
+					iLex.Mark();
+					}
+				}
+			}
+		else if (c.IsSpace() && (c != '\n') && (c != '\r'))
+			{
+			iLex.UnGet();
+			break;
+			}
+		else
+			{
+			iLex.UnGet();
+			CReservedLookup::TResult result = iReservedLookup->Lookup(iLex.Remainder());
+			if (result.iResultType == CReservedLookup::TResult::EMatch)
+				{
+				if (iLex.MarkedToken().Length() > 0)
+					{
+					break;
+					}
+				else
+					{
+					iLex.Inc(result.iTokenLength);
+					type = result.iTokenType;
+					break;
+					}
+				}
+			iLex.Get();
+			}
+		}
+
+	return TToken(type, iLex.MarkedToken(), iLex.MarkedOffset());
+	}
+
+TInt CLexer::CurrentOffset() const
+	{
+	return iLex.Offset();
+	}
+
+TBool CLexer::More()
+	{
+	SkipWhiteSpace();
+	return !iLex.Eos();
+	}
+
+CLexer::CLexer(TUint aBehaviour)
+	: iBehaviour(aBehaviour)
+	{
+	}
+
+void CLexer::ConstructL()
+	{
+	iReservedLookup = CReservedLookup::NewL();
+	}
+
+void CLexer::SkipSingleQuotedChars()
+	{
+	while (!iLex.Eos())
+		{
+		TChar c = iLex.Get();
+		if ((c == iEscapeChar) && !iLex.Eos() && (iLex.Peek() == '\''))
+			{
+			// Allow quoted single quote characters. Note, the is a departure from Bash behaviour, but is in line with Perl and is generally helpful.
+			iLex.Get();
+			}
+		else if (c == '\'')
+			{
+			break;
+			}
+		}
+	}
+
+void CLexer::SkipDoubleQuotedChars()
+	{
+	while (!iLex.Eos())
+		{
+		TChar c = iLex.Get();
+		if ((c == iEscapeChar) && !iLex.Eos())
+			{
+			iLex.Get();
+			}
+		else if (c == '"')
+			{
+			break;
+			}
+		}
+	}
+
+void CLexer::SkipComment()
+	{
+	while (!iLex.Eos())
+		{
+		TChar c = iLex.Get();
+		if ((c == '\n') || (c == '\r'))
+			{
+			iLex.UnGet();
+			break;
+			}
+		}
+	}
+
+void CLexer::SkipWhiteSpace()
+	{
+	while (!iLex.Eos())
+		{
+		TChar c = iLex.Get();
+		if (!c.IsSpace() || (c == '\n') || (c == '\r'))
+			{
+			iLex.UnGet();
+			break;
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/lexer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,93 @@
+// lexer.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __LEXER_H__
+#define __LEXER_H__
+
+#include <e32base.h>
+
+class CReservedLookup;
+
+
+class TToken
+	{
+public:
+	enum TType
+		{
+		ENull,
+		EString,
+		EPipe,
+		EDoublePipe,
+		ERedirectStdinFromFile,
+		ERedirectStdoutToFile,
+		ERedirectStdoutToFileAppend,
+		ERedirectStdoutToStderr,
+		ERedirectStderrToFile,
+		ERedirectStderrToFileAppend,
+		ERedirectStderrToStdout,
+		EAmpersand,
+		EDoubleAmpersand,
+		EAmpersandPipe,
+		ENewLine,
+		ESemicolon,
+		EVariable
+		};
+public:
+	TToken();
+	TToken(TType aType, const TDesC& aToken, TInt aPos);
+	TToken& operator=(const TToken& aToken);
+	TType Type() const;
+	TInt Position() const;
+	const TDesC& String() const;
+private:
+	TType iType;
+	TPtrC iToken;
+	TInt iPos;
+	};
+
+
+class CLexer : public CBase
+	{
+public:
+	enum TBehaviour
+		{
+		EHandleSingleQuotes	= 0x00000001,	///< Causes text within single quotes to be reported as a single TToken::EString type token.
+		EHandleDoubleQuotes	= 0x00000002,	///< Causes text within double quotes to be reported as a single TToken::EString type token.
+		EHandleComments		= 0x00000004	///< Causes text following a '#' until the end of the line to be discarded.
+		};
+public:
+	static CLexer* NewL();
+	static CLexer* NewL(TUint aBehaviour);
+	static CLexer* NewLC();
+	static CLexer* NewLC(TUint aBehaviour);
+	~CLexer();
+	void DefineTokenTypeL(TToken::TType aTokenType, const TDesC& aString);
+	void Set(const TDesC& aDes, const TChar& aEscapeChar);
+	TToken NextToken();
+	TInt CurrentOffset() const;
+	TBool More();
+private:
+	CLexer(TUint aBehaviour);
+	void ConstructL();
+	void SkipSingleQuotedChars();
+	void SkipDoubleQuotedChars();
+	void SkipComment();
+	void SkipWhiteSpace();
+private:
+	TUint iBehaviour;
+	TChar iEscapeChar;
+	TLex iLex;
+	CReservedLookup* iReservedLookup;
+	};
+
+
+#endif // __LEXER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/license.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// license.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __LICENSE_H__
+#define __LICENSE_H__
+
+class TLicense
+	{
+public:
+	enum TLicenseStatus
+		{
+		EValid,
+		EInvalid
+		};
+public:
+	static TLicenseStatus CheckL(RIoReadHandle& aReadHandle, RIoWriteHandle& aWriteHandle);
+	};
+
+#endif // __LICENSE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/line_completer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,423 @@
+// line_completer.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <f32file.h>
+#include <fshell/ltkutils.h>
+#include "lexer.h"
+#include "command_factory.h"
+#include "line_completer.h"
+
+_LIT(KTab, "\t");
+_LIT(KWild, "*");
+_LIT(KDoubleQuote, "\"");
+_LIT(KSpace, " ");
+_LIT(KFileNameSlash, "\\");
+_LIT(KPipe, "|");
+_LIT(KDoublePipe, "||");
+_LIT(KAmpersand, "&");
+_LIT(KDoubleAmpersand, "&&");
+_LIT(KAmpersandPipe, "&|");
+_LIT(KSemicolon, ";");
+_LIT(KDollar, "$");
+_LIT(KDashDash, "--");
+_LIT(KDash, "-");
+
+CLineCompleter* CLineCompleter::NewL(RFs& aFs, CCommandFactory& aCommandFactory, IoUtils::CEnvironment& aEnv)
+	{
+	CLineCompleter* self = new(ELeave) CLineCompleter(aFs, aCommandFactory, aEnv);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CLineCompleter::~CLineCompleter()
+	{
+	delete iLexer;
+	delete iLastUsedCif;
+	}
+
+void CLineCompleter::LcCompleteLineL(TConsoleLine& aLine, const TChar& aEscapeChar)
+	{
+	iLexer->Set(aLine.ContentsToCursor(), aEscapeChar);
+	TToken token(iLexer->NextToken());
+	TToken firstToken = token;
+	TToken prevToken(TToken::EString, KNullDesC, aLine.ContentsToCursor().Length());
+	TInt lastTokenIdx = 0;
+	while (iLexer->More())
+		{
+		// More than one token - skip to last.
+		prevToken = token;
+		token = iLexer->NextToken();
+		lastTokenIdx++;
+		}
+
+	switch (prevToken.Type())
+		{
+		case TToken::EPipe:
+		case TToken::EAmpersand:
+		case TToken::ESemicolon:
+		case TToken::EDoublePipe:
+		case TToken::EDoubleAmpersand:
+		case TToken::EAmpersandPipe:
+			CompleteCommandNameL(aLine, token, aEscapeChar);
+			break;
+		default:
+			if (token.Position() + token.String().Length() < aLine.ContentsToCursor().Length())
+				{
+				// Looks like there's whitespace after this token, so consider it to be completing the empty token.
+				token = TToken(TToken::EString, KNullDesC, aLine.ContentsToCursor().Length());
+				}
+			else if (lastTokenIdx == 0)
+				{
+				CompleteCommandNameL(aLine, token, aEscapeChar);
+				break;
+				}
+
+			if (token.String().Left(1) == KDollar)
+				{
+				CompleteEnvVarL(aLine, token, aEscapeChar);
+				}
+			else if (token.String() == KDash || token.String().Left(2) == KDashDash)
+				{
+				// Check the CIF is loaded and it's the right one
+				if (iLastUsedCif && iLastUsedCif->Name().CompareF(firstToken.String()) != 0)
+					{
+					delete iLastUsedCif;
+					iLastUsedCif = NULL;
+					}
+				TInt err = KErrNone;
+				if (iLastUsedCif == NULL)
+					{
+					// We need to supress StaticLeaveIfErrs from CCommandInfoFile::NewL causing a PrintError if there's no CIF for this command,
+					// hence the use of TRAP_QUIETLY.
+					TRAP_QUIETLY(err, iLastUsedCif = IoUtils::CCommandInfoFile::NewL(iFs, iEnv, firstToken.String()));
+					}
+				if (err == KErrNone)
+					{
+					CompleteOptionL(aLine, token, aEscapeChar);
+					}
+				}
+			else
+				{
+				CompleteFileNameL(aLine, token, aEscapeChar);
+				}
+			break;
+		}
+	}
+
+CLineCompleter::CLineCompleter(RFs& aFs, CCommandFactory& aCommandFactory, IoUtils::CEnvironment& aEnv)
+	: iFs(aFs), iCommandFactory(aCommandFactory), iEnv(aEnv)
+	{
+	}
+
+void CLineCompleter::ConstructL()
+	{
+	iLexer = CLexer::NewL();
+	iLexer->DefineTokenTypeL(TToken::EPipe, KPipe);
+	iLexer->DefineTokenTypeL(TToken::EAmpersand, KAmpersand);
+	iLexer->DefineTokenTypeL(TToken::ESemicolon, KSemicolon);
+	iLexer->DefineTokenTypeL(TToken::EDoublePipe, KDoublePipe);
+	iLexer->DefineTokenTypeL(TToken::EDoubleAmpersand, KDoubleAmpersand);
+	iLexer->DefineTokenTypeL(TToken::EAmpersandPipe, KAmpersandPipe);
+	}
+
+HBufC* SimplifyStringLC(const TDesC& aString, const TChar& aEscapeChar)
+	{
+	HBufC* buf = HBufC::NewLC(aString.Length());
+	TPtr bufPtr(buf->Des());
+	TLex lex(aString);
+	while (!lex.Eos())
+		{
+		TChar c = lex.Get();
+		if (c == aEscapeChar)
+			{
+			if (!lex.Eos())
+				{
+				bufPtr.Append(lex.Get());
+				}
+			}
+		else if (c == '\'')
+			{
+			while (!lex.Eos())
+				{
+				c = lex.Get();
+				if (c == '\'')
+					{
+					break;
+					}
+				else
+					{
+					bufPtr.Append(c);
+					}
+				}
+			}
+		else if (c == '"')
+			{
+			while (!lex.Eos())
+				{
+				c = lex.Get();
+				if (c == aEscapeChar)
+					{
+					bufPtr.Append(lex.Get());
+					}
+				else if (c == '"')
+					{
+					break;
+					}
+				else
+					{
+					bufPtr.Append(c);
+					}
+				}
+			}
+		else
+			{
+			bufPtr.Append(c);
+			}
+		}
+	return buf;
+	}
+
+void CLineCompleter::CompleteCommandNameL(TConsoleLine& aLine, const TToken& aToken, const TChar& aEscapeChar) const
+	{
+	RArray<TPtrC> commands;
+	CleanupClosePushL(commands);
+	iCommandFactory.ListCommandsL(commands);
+	HBufC* commandBuf = SimplifyStringLC(aToken.String(), aEscapeChar);
+
+	// Remove commands that don't match aLine.
+	TInt i;
+	for (i = (commands.Count() - 1); i >= 0; --i)
+		{
+		if (commands[i].Find(*commandBuf) != 0)
+			{
+			commands.Remove(i);
+			}
+		}
+
+	if (commands.Count() > 0)
+		{
+		CompleteL(aLine, aToken, commands, NULL, NULL);
+		}
+	else
+		{
+		CompleteFileNameL(aLine, aToken, aEscapeChar);
+		}
+	CleanupStack::PopAndDestroy(2, &commands);
+	}
+
+void RemovePartialElement(HBufC*& aBuf)
+	{
+	TPtr ptr(aBuf->Des());
+	while (ptr.Length() > 0)
+		{
+		if (ptr[ptr.Length() - 1] == KPathDelimiter)
+			{
+			break;
+			}
+		else
+			{
+			ptr.Delete(ptr.Length() - 1, 1);
+			}
+		}
+	}
+
+void CLineCompleter::CompleteFileNameL(TConsoleLine& aLine, const TToken& aToken, const TChar& aEscapeChar) const
+	{
+	HBufC* fileNameBuf = SimplifyStringLC(aToken.String(), aEscapeChar);
+	IoUtils::TFileName2 absFileName(*fileNameBuf);
+	RemovePartialElement(fileNameBuf);
+	absFileName.Append(KWild);
+	absFileName.MakeAbsoluteL(iEnv.Pwd());
+	CDir* files;
+	User::LeaveIfError(iFs.GetDir(absFileName, KEntryAttNormal | KEntryAttDir, ESortByName, files));
+	CleanupStack::PushL(files);
+	RArray<TPtrC> fileNames;
+	CleanupClosePushL(fileNames);
+	const TInt numFiles = files->Count();
+	if (numFiles == 1)
+		{
+		absFileName = absFileName.DriveAndPath();
+		absFileName.AppendComponentL((*files)[0].iName);
+		TEntry entry;
+		User::LeaveIfError(iFs.Entry(absFileName, entry));
+		User::LeaveIfError(fileNames.Append(absFileName.NameAndExt()));
+		CompleteL(aLine, aToken, fileNames, fileNameBuf, entry.IsDir() ? &KFileNameSlash : NULL);
+		}
+	else if (numFiles > 1)
+		{
+		for (TInt i = 0; i < numFiles; ++i)
+			{
+			User::LeaveIfError(fileNames.Append(TPtrC((*files)[i].iName)));
+			}
+		CompleteL(aLine, aToken, fileNames, fileNameBuf, NULL);
+		}
+	CleanupStack::PopAndDestroy(3, fileNameBuf);
+	}
+
+TBool NeedsQuoting(const TDesC& aDes)
+	{
+	return ((aDes.Locate(TChar(' ')) >= 0) || aDes.Locate(TChar('\'')) >= 0);
+	}
+
+void CLineCompleter::CompleteL(TConsoleLine& aLine, const TToken& aToken, const RArray<TPtrC> aPossibilities, const TDesC* aPrefix, const TDesC* aSuffix, TBool aPrefixIsPartOfToken) const
+	{
+	const TInt numPossibilities = aPossibilities.Count();
+
+	if (numPossibilities > 1)
+		{
+		// Fill out possibilities buffer.
+		IoUtils::CTextBuffer* possibilities = IoUtils::CTextBuffer::NewLC(0x100);
+		for (TInt i = 0; i < numPossibilities; ++i)
+			{
+			if (aPrefixIsPartOfToken) possibilities->AppendL(*aPrefix);
+			possibilities->AppendL(aPossibilities[i]);
+			if (i != (numPossibilities - 1))
+				{
+				possibilities->AppendL(KTab);
+				}
+			}
+
+		aLine.PrintCompletionPossibilitiesL(possibilities->Descriptor());
+		CleanupStack::PopAndDestroy(possibilities);
+		}
+
+	if (numPossibilities > 0)
+		{
+		IoUtils::CTextBuffer* completion = IoUtils::CTextBuffer::NewLC(0x100);
+		TPtrC commonChars(NULL, 0);
+		if (numPossibilities > 1)
+			{
+			// Find common leading characters of the possibilities.
+			TInt commonCharPos = -1;
+			TBool finished(EFalse);
+			do
+				{
+				++commonCharPos;
+				TChar character(0);
+				for (TInt i = 0; i < numPossibilities; ++i)
+					{
+					if (commonCharPos >= aPossibilities[i].Length())
+						{
+						finished = ETrue;
+						break;
+						}
+					else if (i == 0)
+						{
+						character = aPossibilities[0][commonCharPos];
+						character.Fold();
+						}
+					else
+						{
+						TChar c(aPossibilities[i][commonCharPos]);
+						c.Fold();
+						if (c != character)
+							{
+							finished = ETrue;
+							break;
+							}
+						}
+					}
+				}
+				while (!finished);
+
+			commonChars.Set(aPossibilities[0].Mid(0, commonCharPos));
+			}
+		else
+			{
+			commonChars.Set(aPossibilities[0]);
+			}
+
+		TBool quote(EFalse);
+		if ((aPrefix && NeedsQuoting(*aPrefix)) || NeedsQuoting(commonChars) || (aSuffix && NeedsQuoting(*aSuffix)))
+			{
+			quote = ETrue;
+			}
+		if (quote)
+			{
+			completion->AppendL(KDoubleQuote);
+			}
+		if (aPrefix)
+			{
+			completion->AppendL(*aPrefix);
+			}
+		completion->AppendL(commonChars);
+		if ((numPossibilities == 1) && quote)
+			{
+			completion->AppendL(KDoubleQuote);
+			}
+		if (numPossibilities == 1)
+			{
+			if (aSuffix)
+				{
+				completion->AppendL(*aSuffix);
+				}
+			else
+				{
+				completion->AppendL(KSpace);
+				}
+			}
+		if (completion->Descriptor().Length() > 0)
+			{
+			aLine.Replace(aToken.Position(), completion->Descriptor());
+			}
+		CleanupStack::PopAndDestroy(completion);
+		}
+	}
+
+void CLineCompleter::CompleteEnvVarL(TConsoleLine& aLine, const TToken& aToken, const TChar& /*aEscapeChar*/) const
+	{
+	RArray<TPtrC> matchingVars;
+	CleanupClosePushL(matchingVars);
+	TPtrC envVar = aToken.String().Mid(1); // Lose the $
+
+	RPointerArray<HBufC> keys;
+	LtkUtils::CleanupResetAndDestroyPushL(keys);
+	iEnv.GetKeysL(keys);
+	
+	const TInt count = keys.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		const TDesC& key = *keys[i];
+		if (key.Left(envVar.Length()) == envVar)
+			{
+			matchingVars.AppendL(TPtrC(key));
+			}
+		}
+	CompleteL(aLine, aToken, matchingVars, &KDollar, NULL, ETrue);
+	CleanupStack::PopAndDestroy(2, &matchingVars); // keys, matchingVars
+	}
+
+void CLineCompleter::CompleteOptionL(TConsoleLine& aLine, const TToken& aToken, const TChar& /*aEscapeChar*/) const
+	{
+	RArray<TPtrC> matchingOptions;
+	CleanupClosePushL(matchingOptions);
+	TPtrC optFrag = aToken.String();
+	if (optFrag.Length() >= 2) optFrag.Set(optFrag.Mid(2)); // Lose the --
+	else if (optFrag.Length() == 1) optFrag.Set(TPtrC()); // single dash gets dropped completely
+
+	const IoUtils::RCommandOptionList& options = iLastUsedCif->Options();
+	const TInt count = options.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		const TDesC& optName = options[i].Name();;
+		if (optName.Left(optFrag.Length()) == optFrag)
+			{
+			matchingOptions.AppendL(TPtrC(optName));
+			}
+		}
+	CompleteL(aLine, aToken, matchingOptions, &KDashDash, NULL, ETrue);
+	CleanupStack::PopAndDestroy(&matchingOptions);
+	}
+	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/line_completer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+// line_completer.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __LINE_COMPLETER_H__
+#define __LINE_COMPLETER_H__
+
+#include <e32base.h>
+#include <fshell/line_editor.h>
+
+class RFs;
+class TToken;
+class TConsoleLine;
+class CLexer;
+class CTextBuffer;
+class CCommandFactory;
+namespace IoUtils
+	{
+	class CCommandInfoFile;
+	}
+
+class CLineCompleter : public CBase, public MLineCompleter
+	{
+public:
+	static CLineCompleter* NewL(RFs& aFs, CCommandFactory& aCommandFactory, IoUtils::CEnvironment& aEnv);
+	~CLineCompleter();
+private: // From MLineCompleter.
+	virtual void LcCompleteLineL(TConsoleLine& aLine, const TChar& aEscapeChar);
+private:
+	CLineCompleter(RFs& aFs, CCommandFactory& aCommandFactory, IoUtils::CEnvironment& aEnv);
+	void ConstructL();
+	void CompleteCommandNameL(TConsoleLine& aLine, const TToken& aToken, const TChar& aEscapeChar) const;
+	void CompleteFileNameL(TConsoleLine& aLine, const TToken& aToken, const TChar& aEscapeChar) const;
+	void CompleteL(TConsoleLine& aLine, const TToken& aToken, const RArray<TPtrC> aPossibilities, const TDesC* aPrefix, const TDesC* aSuffix, TBool aPrefixIsPartOfToken=EFalse) const;
+	void CompleteEnvVarL(TConsoleLine& aLine, const TToken& aToken, const TChar& aEscapeChar) const;
+	void CompleteOptionL(TConsoleLine& aLine, const TToken& aToken, const TChar& aEscapeChar) const;
+
+private:
+	RFs& iFs;
+	CCommandFactory& iCommandFactory;
+	IoUtils::CEnvironment& iEnv;
+	CLexer* iLexer;
+	IoUtils::CCommandInfoFile* iLastUsedCif;
+	};
+
+
+#endif // __LINE_COMPLETER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/line_reader.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+// line_reader.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __LINE_READER_H__
+#define __LINE_READER_H__
+
+
+class MLineReaderObserver
+	{
+public:
+	virtual void HandleLine(const TDesC& aLineData) = 0;
+	virtual void HandleLineReadError(TInt aError) = 0;
+	};
+
+
+#endif // __LINE_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/parser.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,904 @@
+// parser.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/ltkutils.h>
+#include "parser.h"
+#include "fshell.h"
+#include "lexer.h"
+#include "command_factory.h"
+
+//
+// Globals.
+//
+
+_LIT(KChildError, "?");
+_LIT(KPipe, "|");
+_LIT(KDoublePipe, "||");
+_LIT(KRedirectStdinFromFile, "<");
+_LIT(KRedirectStdoutToFile1, ">");
+_LIT(KRedirectStdoutToFile2, "1>");
+_LIT(KRedirectStdoutToFileAppend1, ">>");
+_LIT(KRedirectStdoutToFileAppend2, "1>>");
+_LIT(KRedirectStdoutToStderr, "1>&2");
+_LIT(KRedirectStderrToFile, "2>");
+_LIT(KRedirectStderrToFileAppend, "2>>");
+_LIT(KRedirectStderrToStdout, "2>&1");
+_LIT(KAmpersand, "&");
+_LIT(KDoubleAmpersand, "&&");
+_LIT(KAmpersandPipe, "&|");
+_LIT(KNewLine1, "\r");
+_LIT(KNewLine2, "\n");
+_LIT(KNewLine3, "\r\n");
+_LIT(KNewLine4, "\n\r");
+_LIT(KSemicolon, ";");
+_LIT(KDollar, "$");
+
+
+void MParserObserver::AboutToExecuteLine(const TDesC&, const TDesC&)
+	{
+	}
+
+void MParserObserver::LineReturned(TInt)
+	{
+	}
+
+CParser* CParser::NewL(TUint aMode, const TDesC& aDes, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MParserObserver* aObserver)
+	{
+	CParser* self = new(ELeave) CParser(aMode, aDes, aIoSession, aStdin, aStdout, aStderr, aEnv, aFactory, aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+CParser::~CParser()
+	{
+	delete iForegroundPipeLine;
+	iBackgroundPipeLines.ResetAndDestroy();
+	delete iLexer1;
+	delete iLexer2;
+	delete iCompletionCallBack;
+	delete iNextPipeLineCallBack;
+	delete iExitCallBack;
+	if (iOwnsIoHandles)
+		{
+		iStdin.Close();
+		iStdout.Close();
+		iStderr.Close();
+		}
+	}
+
+CParser::CParser(TUint aMode, const TDesC& aDes, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MParserObserver* aObserver)
+	: iMode(aMode), iData(aDes), iIoSession(aIoSession), iStdin(aStdin), iStdout(aStdout), iStderr(aStderr), iEnv(aEnv), iFactory(aFactory), iObserver(aObserver), iCompletionError(aStderr, aEnv), iNextLineNumber(1)
+	{
+	}
+
+void CParser::ConstructL()
+	{
+	if (iObserver)
+		{
+		iCompletionCallBack = new(ELeave) CAsyncCallBack(TCallBack(CompletionCallBack, this), CActive::EPriorityStandard);
+		}
+	iNextPipeLineCallBack = new(ELeave) CAsyncCallBack(TCallBack(NextCallBack, this), CActive::EPriorityStandard);
+
+	iLexer1 = CLexer::NewL(CLexer::EHandleSingleQuotes | CLexer::EHandleDoubleQuotes | CLexer::EHandleComments);
+	iLexer1->DefineTokenTypeL(TToken::EDoublePipe, KDoublePipe);
+	iLexer1->DefineTokenTypeL(TToken::EDoubleAmpersand, KDoubleAmpersand);
+	iLexer1->DefineTokenTypeL(TToken::EAmpersandPipe, KAmpersandPipe);
+	iLexer1->DefineTokenTypeL(TToken::ENewLine, KNewLine1);
+	iLexer1->DefineTokenTypeL(TToken::ENewLine, KNewLine2);
+	iLexer1->DefineTokenTypeL(TToken::ENewLine, KNewLine3);
+	iLexer1->DefineTokenTypeL(TToken::ENewLine, KNewLine4);
+	iLexer1->DefineTokenTypeL(TToken::ESemicolon, KSemicolon);
+	iLexer1->Set(iData, iEnv.EscapeChar());
+
+	iLexer2 = CLexer::NewL(CLexer::EHandleSingleQuotes | CLexer::EHandleDoubleQuotes);
+	iLexer2->DefineTokenTypeL(TToken::EPipe, KPipe);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStdinFromFile, KRedirectStdinFromFile);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStdoutToFile, KRedirectStdoutToFile1);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStdoutToFile, KRedirectStdoutToFile2);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStdoutToFileAppend, KRedirectStdoutToFileAppend1);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStdoutToFileAppend, KRedirectStdoutToFileAppend2);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStdoutToStderr, KRedirectStdoutToStderr);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStderrToFile, KRedirectStderrToFile);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStderrToFileAppend, KRedirectStderrToFileAppend);
+	iLexer2->DefineTokenTypeL(TToken::ERedirectStderrToStdout, KRedirectStderrToStdout);
+	iLexer2->DefineTokenTypeL(TToken::EAmpersand, KAmpersand);
+
+	if (iMode & EExportLineNumbers)
+		{
+		iEnv.SetL(KScriptLine, iNextLineNumber++);
+		}
+	if (iMode & EKeepGoing)
+		{
+		iEnv.SetL(KKeepGoing, 1);
+		}
+	}
+
+void CParser::Start()
+	{
+	CreateNextPipeLine(NULL);
+	}
+
+void CParser::Start(TBool& aIsForeground)
+	{
+	CreateNextPipeLine(&aIsForeground);
+	}
+
+void CParser::Kill()
+	{
+	iAbort = ETrue;
+	if (iForegroundPipeLine)
+		{
+		iForegroundPipeLine->Kill();
+		}
+	const TInt numBackground = iBackgroundPipeLines.Count();
+	for (TInt i = 0; i < numBackground; ++i)
+		{
+		iBackgroundPipeLines[i]->Kill();
+		}
+	}
+
+TInt CParser::Suspend()
+	{
+	TInt ret = KErrNone;
+	if (iForegroundPipeLine)
+		{
+		TInt err = iForegroundPipeLine->Suspend();
+		if (err)
+			{
+			ret = err;
+			}
+		}
+	const TInt numBackground = iBackgroundPipeLines.Count();
+	for (TInt i = 0; i < numBackground; ++i)
+		{
+		TInt err = iBackgroundPipeLines[i]->Suspend();
+		if (err && (ret == KErrNone))
+			{
+			ret = err;
+			}
+		}
+	return ret;
+	}
+
+TInt CParser::Resume()
+	{
+	TInt ret = KErrNone;
+	if (iForegroundPipeLine)
+		{
+		TInt err = iForegroundPipeLine->Resume();
+		if (err)
+			{
+			ret = err;
+			}
+		}
+	const TInt numBackground = iBackgroundPipeLines.Count();
+	for (TInt i = 0; i < numBackground; ++i)
+		{
+		TInt err = iBackgroundPipeLines[i]->Resume();
+		if (err && (ret == KErrNone))
+			{
+			ret = err;
+			}
+		}
+	return ret;
+	}
+
+TInt CParser::BringToForeground()
+	{
+	if (iForegroundPipeLine)
+		{
+		return iForegroundPipeLine->BringToForeground();
+		}
+	else if (iBackgroundPipeLines.Count() == 1)
+		{
+		return iBackgroundPipeLines[0]->BringToForeground();
+		}
+	return KErrGeneral;
+	}
+
+void CParser::SendToBackground()
+	{
+	if (iForegroundPipeLine)
+		{
+		iForegroundPipeLine->SendToBackground();
+		}
+	}
+
+TInt CParser::Reattach(RIoEndPoint& aStdinEndPoint, RIoEndPoint& aStdoutEndPoint, RIoEndPoint& aStderrEndPoint)
+	{
+	RIoReadHandle stdin;
+	RIoWriteHandle stdout;
+	RIoWriteHandle stderr;
+	TInt err = stdin.Create(iIoSession);
+	if (err == KErrNone)
+		{
+		err = stdout.Create(iIoSession);
+		if (err == KErrNone)
+			{
+			err = stderr.Create(iIoSession);
+			if (err == KErrNone)
+				{
+				err = aStdinEndPoint.Attach(stdin, RIoEndPoint::EBackground);
+				if (err == KErrNone)
+					{
+					err = aStdoutEndPoint.Attach(stdout);
+					if (err == KErrNone)
+						{
+						err = aStderrEndPoint.Attach(stderr);
+						if (err == KErrNone)
+							{
+							if (iForegroundPipeLine)
+								{
+								err = iForegroundPipeLine->Reattach(aStdinEndPoint, aStdoutEndPoint, aStderrEndPoint);
+								}
+							if (err == KErrNone)
+								{
+								const TInt numBackground = iBackgroundPipeLines.Count();
+								for (TInt i = 0; i < numBackground; ++i)
+									{
+									err = iBackgroundPipeLines[i]->Reattach(aStdinEndPoint, aStdoutEndPoint, aStderrEndPoint);
+									if (err)
+										{
+										break;
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+	if (err == KErrNone)
+		{
+		iStdin = stdin;
+		iStdout = stdout;
+		iStderr = stderr;
+		iOwnsIoHandles = ETrue;
+		}
+	else
+		{
+		stdin.Close();
+		stdout.Close();
+		stderr.Close();
+		}
+	return err;
+	}
+
+TBool CParser::IsDisownable() const
+	{
+	if (iForegroundPipeLine && !iForegroundPipeLine->IsDisownable())
+		{
+		return EFalse;
+		}
+	const TInt numBackground = iBackgroundPipeLines.Count();
+	for (TInt i = 0; i < numBackground; ++i)
+		{
+		if (!(iBackgroundPipeLines[i]->IsDisownable()))
+			{
+			return EFalse;
+			}
+		}
+	return ETrue;
+	}
+
+void CParser::Disown()
+	{
+	if (iForegroundPipeLine)
+		{
+		iForegroundPipeLine->Disown();
+		}
+	const TInt numBackground = iBackgroundPipeLines.Count();
+	for (TInt i = 0; i < numBackground; ++i)
+		{
+		iBackgroundPipeLines[i]->Disown();
+		}
+	}
+
+TBool HandleRedirectionL(TToken::TType aTokenType, const TDesC& aCwd, CLexer& aLexer, RPipeSection& aPipeSection)
+	{
+	RPipeSection::TRedirection* redirection;
+	switch (aTokenType)
+		{
+		case TToken::ERedirectStdinFromFile:
+			{
+			redirection = &aPipeSection.iStdinRedirection;
+			break;
+			}
+		case TToken::ERedirectStdoutToFile:
+		case TToken::ERedirectStdoutToFileAppend:
+		case TToken::ERedirectStdoutToStderr:
+			{
+			redirection = &aPipeSection.iStdoutRedirection;
+			break;
+			}
+		case TToken::ERedirectStderrToFile:
+		case TToken::ERedirectStderrToFileAppend:
+		case TToken::ERedirectStderrToStdout:
+			{
+			redirection = &aPipeSection.iStderrRedirection;
+			break;
+			}
+		default:
+			{
+			redirection = NULL;
+			ASSERT(EFalse);
+			}
+		}
+
+	if (aTokenType == TToken::ERedirectStderrToStdout)
+		{
+		redirection->iType = RPipeSection::TRedirection::EHandle;
+		redirection->iHandle = RPipeSection::TRedirection::EStdout;
+		}
+	else if (aTokenType == TToken::ERedirectStdoutToStderr)
+		{
+		redirection->iType = RPipeSection::TRedirection::EHandle;
+		redirection->iHandle = RPipeSection::TRedirection::EStderr;
+		}
+	else
+		{
+		if (aLexer.More())
+			{
+			redirection->iType = ((aTokenType == TToken::ERedirectStdoutToFileAppend) || (aTokenType == TToken::ERedirectStderrToFileAppend)) ? RPipeSection::TRedirection::EFileAppend : RPipeSection::TRedirection::EFile;
+			TToken fileName(aLexer.NextToken());
+			redirection->SetFileNameL(aCwd, fileName.String());
+			}
+		else
+			{
+			return EFalse;
+			}
+		}
+
+	return ETrue;
+	}
+
+void CleanupPipeSectionsArray(TAny* aArray)
+	{
+	RArray<RPipeSection>* array = static_cast<RArray<RPipeSection>*>(aArray);
+	const TInt numSections = array->Count();
+	for (TInt i = 0; i < numSections; ++i)
+		{
+		(*array)[i].Close();
+		}
+	array->Close();
+	}
+
+void CParser::CreateNextPipeLine(TBool* aIsForeground)
+	{
+	TRAPD(err, CreateNextPipeLineL(aIsForeground));
+	if (err && iObserver)
+		{
+		iCompletionError.Set(err, TError::EFailedToCreatePipeLine);
+		iCompletionCallBack->CallBack();
+		}
+	}
+
+void CParser::CreateNextPipeLineL(TBool* aIsForeground)
+	{
+	// Parsing is now carried out in three main steps:
+	//
+	// 1) Use iLexer1 to find the next "pipe-line's worth" of data (carried out by FindNextPipeLine).
+	// 2) Expand environment variables in this data into a new HBufC ('expandedPipeLine' returned by ExpandVariablesLC).
+	// 3) Use iLexer2 to parse the data in this expanded descriptor.
+
+	if (aIsForeground)
+		{
+		*aIsForeground = ETrue;
+		}
+
+	TPtrC pipeLineData;
+	TBool reachedLineEnd(EFalse);
+	FindNextPipeLineL(pipeLineData, iCondition, reachedLineEnd);
+	HBufC* expandedPipeLine = ExpandVariablesLC(pipeLineData);
+	iLexer2->Set(*expandedPipeLine, iEnv.EscapeChar());
+
+	const TDesC& cwd = iEnv.Pwd();
+	RArray<RPipeSection> pipeSections;
+	CleanupStack::PushL(TCleanupItem(CleanupPipeSectionsArray, &pipeSections));
+	RPipeSection pipeSection;
+	CleanupClosePushL(pipeSection);
+	TInt offset = iLexer2->CurrentOffset();
+	TBool background(EFalse);
+	while (iLexer2->More())
+		{
+		TToken token(iLexer2->NextToken());
+		switch (token.Type())
+			{
+			case TToken::EPipe:
+				{
+				pipeSection.iFullName.Set(iData.Ptr() + offset, iLexer2->CurrentOffset() - offset - token.String().Length());
+				offset = iLexer2->CurrentOffset();
+				User::LeaveIfError(pipeSections.Append(pipeSection));
+				new(&pipeSection) RPipeSection;
+				break;
+				}
+			case TToken::EAmpersand:
+				{
+				background = ETrue;
+				break;
+				}
+			case TToken::ERedirectStdinFromFile:
+			case TToken::ERedirectStdoutToFile:
+			case TToken::ERedirectStdoutToFileAppend:
+			case TToken::ERedirectStdoutToStderr:
+			case TToken::ERedirectStderrToFile:
+			case TToken::ERedirectStderrToFileAppend:
+			case TToken::ERedirectStderrToStdout:
+				{
+				if (HandleRedirectionL(token.Type(), cwd, *iLexer2, pipeSection))
+					{
+					break;
+					}
+				// Deliberate fall through - if it wasn't possible to handle the redirection, treat token as a string.
+				}
+			case TToken::EString:
+			default:
+				{
+				if (token.String().Length() > 0)
+					{
+					if (pipeSection.iCommandName.Length() == 0)
+						{
+						pipeSection.iCommandName.Set(token.String());
+						}
+					else
+						{
+						User::LeaveIfError(pipeSection.iCommandArguments.Append(TPtrC(token.String())));
+						}
+					}
+				break;
+				}
+			}
+		}
+
+	if (pipeSection.iCommandName.Length() > 0)
+		{
+		_LIT(KExit, "exit");
+		if ((pipeSections.Count() == 0) && (pipeSection.iCommandName.CompareF(KExit) == 0) && (pipeSection.iCommandArguments.Count() == 0))
+			{
+			// Special case the handling of 'exit'. This allows the concept of 'local commands' (i.e. commands that run in either fshell's main
+			// thread or in the thread belonging to a 'source' or 'debug' command) to be dropped. That's a good thing, because local commands
+			// can't synchronously interact with iosrv without risk of deadlock when two or more thread commands are run in a pipe-line. 
+			CleanupStack::PopAndDestroy(2, &pipeSections);
+			if (CActiveScheduler::Current()->StackDepth() > 0)
+				{
+				CActiveScheduler::Stop();
+				}
+			else
+				{
+				// The active scheduler hasn't been started yet. Probably because someone is doing something crazy like 'fshell -e exit'.
+				iExitCallBack = new(ELeave) CAsyncCallBack(TCallBack(ExitCallBack, this), CActive::EPriorityStandard);
+				iExitCallBack->Call();
+				}
+			}
+		else
+			{
+			pipeSection.iFullName.Set(iData.Ptr() + offset, iLexer2->CurrentOffset() - offset);
+			User::LeaveIfError(pipeSections.Append(pipeSection));
+			CleanupStack::Pop(&pipeSection);
+			if ((iMode & EDebug) && iObserver)
+				{
+				iObserver->AboutToExecuteLine(pipeLineData, *expandedPipeLine);
+				}
+			if (background)
+				{
+				CPipeLine* pipeLine = CPipeLine::NewLC(iIoSession, iStdin, iStdout, iStderr, iEnv, iFactory, pipeSections, background, this, iCompletionError);
+				User::LeaveIfError(iBackgroundPipeLines.Append(pipeLine));
+				CleanupStack::Pop(pipeLine);
+				}
+			else
+				{
+				ASSERT(iForegroundPipeLine == NULL);
+				iForegroundPipeLine = CPipeLine::NewL(iIoSession, iStdin, iStdout, iStderr, iEnv, iFactory, pipeSections, background, this, iCompletionError);
+				}
+			CleanupStack::PopAndDestroy(&pipeSections);
+			if (aIsForeground && !iLexer1->More())
+				{
+				*aIsForeground = !background;
+				}
+			if (background && iLexer1->More())
+				{
+				iNextPipeLineCallBack->Call();
+				}
+			}
+		}
+	else
+		{
+		if (iObserver && (iForegroundPipeLine == NULL) && (iBackgroundPipeLines.Count() == 0))
+			{
+			iCompletionCallBack->CallBack();
+			}
+		CleanupStack::PopAndDestroy(2, &pipeSections);
+		}
+
+	CleanupStack::PopAndDestroy(expandedPipeLine);
+
+	if (reachedLineEnd && (iMode & EExportLineNumbers))
+		{
+		iEnv.SetL(KScriptLine, iNextLineNumber++);
+		}
+	}
+
+void CParser::FindNextPipeLineL(TPtrC& aData, TCondition& aCondition, TBool& aReachedLineEnd)
+	{
+	aReachedLineEnd = EFalse;
+	aCondition = ENone;
+	TInt startOffset = iLexer1->CurrentOffset();
+	TInt endOffset = -1;
+
+	TBool foundSomething(EFalse);
+	while (iLexer1->More())
+		{
+		TBool finished(EFalse);
+		TToken token(iLexer1->NextToken());
+
+		switch (token.Type())
+			{
+			case TToken::EString:
+				{
+				foundSomething = ETrue;
+				endOffset = iLexer1->CurrentOffset();
+				break;
+				}
+			case TToken::EDoublePipe:
+				{
+				finished = ETrue;
+				aCondition = EOr;
+				break;
+				}
+			case TToken::EDoubleAmpersand:
+				{
+				finished = ETrue;
+				aCondition = EAnd;
+				break;
+				}
+			case TToken::EAmpersandPipe:
+				{
+				finished = ETrue;
+				aCondition = EAndOr;
+				break;
+				}
+			case TToken::ENull:
+			case TToken::ENewLine:
+				{
+				if (foundSomething)
+					{
+					// Leave it to CreateNextPipeLineL to increment SCRIPT_LINE when it's finished building the pipe-line.
+					aReachedLineEnd = ETrue;
+					}
+				else
+					{
+					// Reached the end of a comment line - increment SCRIPT_LINE.
+					if (iMode & EExportLineNumbers)
+						{
+						iEnv.SetL(KScriptLine, iNextLineNumber++);
+						}
+					}
+				// Deliberate fall through.
+				}
+			case TToken::ESemicolon:
+				{
+				if (foundSomething)
+					{
+					finished = ETrue;
+					}
+				else
+					{
+					// Nothing on this line - adjust 'startOffset' to pretend it doesn't exist.
+					startOffset = iLexer1->CurrentOffset();
+					}
+				break;
+				}
+			default:
+				{
+				ASSERT(EFalse);
+				break;
+				}
+			}
+
+		if (finished)
+			{
+			break;
+			}
+		}
+
+	if (foundSomething)
+		{
+		aData.Set(iData.Ptr() + startOffset, endOffset - startOffset);
+		}
+	else
+		{
+		aData.Set(KNullDesC);
+		}
+	}
+
+HBufC* ExpandVariablesLC(const TDesC& aData, CLexer& aLexer, IoUtils::CEnvironment& aEnv, TBool aEscape)
+	{
+	TChar escapeChar = aEnv.EscapeChar();
+	RArray<TInt> charsToEscape;
+	CleanupClosePushL(charsToEscape);
+	HBufC* buf = aData.AllocLC();
+
+	// Repeatedly check the data for environment variable tokens. This is done in a loop
+	// because there could be variables within variables and we want to expand them all.
+	aLexer.Set(*buf, escapeChar);
+	FOREVER
+		{
+		TToken token(aLexer.NextToken());
+		if (token.Type() == TToken::ENull)
+			{
+			break;
+			}
+		else if (token.Type() == TToken::EVariable)
+			{
+			const TDesC& val = aEnv.GetAsDesL(token.String().Mid(1));
+			TPtr bufPtr(buf->Des());
+			const TInt freeSpace = bufPtr.MaxLength() - bufPtr.Length();
+			TInt requiredSpace = val.Length() - token.String().Length();
+			if (aEscape)
+				{
+				charsToEscape.Reset();
+				TLex lex(val);
+				while (!lex.Eos())
+					{
+					TChar c = lex.Get();
+					if ((c == aEnv.EscapeChar()) || (c == '\"'))
+						{
+						charsToEscape.AppendL(token.Position() + lex.Offset() - 1);
+						++requiredSpace;
+						}
+					}
+				}
+			if (requiredSpace > freeSpace)
+				{
+				HBufC* oldBuf = buf;
+				buf = buf->ReAllocL(bufPtr.MaxLength() + requiredSpace - freeSpace);
+				CleanupStack::Pop(oldBuf);
+				CleanupStack::PushL(buf);
+				bufPtr.Set(buf->Des());
+				}
+
+			bufPtr.Replace(token.Position(), token.String().Length(), val);
+
+			if (aEscape)
+				{
+				TPtrC escape((TUint16*)&escapeChar, 1);
+				while (charsToEscape.Count() > 0)
+					{
+					bufPtr.Insert(charsToEscape[charsToEscape.Count() - 1], escape);
+					charsToEscape.Remove(charsToEscape.Count() - 1);
+					}
+				}
+
+			aLexer.Set(*buf, escapeChar);
+			}
+		}
+
+	CleanupStack::Pop(buf);
+	CleanupStack::PopAndDestroy(&charsToEscape);
+	CleanupStack::PushL(buf);
+
+	return buf;
+	}
+
+HBufC* CParser::ExpandVariablesLC(const TDesC& aData)
+	{
+	CLexer* lexer1 = CLexer::NewLC(CLexer::EHandleSingleQuotes | CLexer::EHandleDoubleQuotes  | CLexer::EHandleComments);
+	CLexer* lexer2 = CLexer::NewLC(0);
+
+	// Populate 'lexer2' with a token definition for each environment variable (preceded with '$').
+	RPointerArray<HBufC> keys;
+	LtkUtils::CleanupResetAndDestroyPushL(keys);
+	iEnv.GetKeysL(keys);
+
+	const TInt numVars = keys.Count();
+	for (TInt i = 0; i < numVars; ++i)
+		{
+		keys[i] = keys[i]->ReAllocL(keys[i]->Length() + KDollar().Length());
+		keys[i]->Des().Insert(0, KDollar);
+		lexer2->DefineTokenTypeL(TToken::EVariable, *keys[i]);
+		}
+
+	HBufC* buf = aData.AllocLC();
+	lexer1->Set(*buf, iEnv.EscapeChar());
+	FOREVER
+		{
+		TToken token(lexer1->NextToken());
+		if (token.Type() == TToken::ENull)
+			{
+			break;
+			}
+		else if (token.Type() == TToken::EString)
+			{
+			if (token.String()[0] != '\'')
+				{
+				HBufC* expandedString = ::ExpandVariablesLC(token.String(), *lexer2, iEnv, token.String()[0] == '\"');
+				if (*expandedString != token.String())
+					{
+					TPtr bufPtr(buf->Des());
+					const TInt freeSpace = bufPtr.MaxLength() - bufPtr.Length();
+					const TInt requiredSpace = expandedString->Length() - token.String().Length();
+
+					if (requiredSpace > freeSpace)
+						{
+						HBufC* oldBuf = buf;
+						buf = buf->ReAllocL(bufPtr.MaxLength() + requiredSpace - freeSpace);
+						CleanupStack::Pop(expandedString);
+						CleanupStack::Pop(oldBuf);
+						CleanupStack::PushL(buf);
+						CleanupStack::PushL(expandedString);
+						bufPtr.Set(buf->Des());
+						}
+
+					bufPtr.Replace(token.Position(), token.String().Length(), *expandedString);
+					lexer1->Set(*buf, iEnv.EscapeChar());
+					}
+				CleanupStack::PopAndDestroy(expandedString);
+				}
+			}
+		}
+
+	CleanupStack::Pop(buf);
+	CleanupStack::PopAndDestroy(3, lexer1);
+	CleanupStack::PushL(buf);
+	return buf;
+	}
+
+TInt CParser::SkipLineRemainder()
+	{
+	while (iLexer1->More())
+		{
+		TToken token(iLexer1->NextToken());
+		if (token.Type() == TToken::ENewLine)
+			{
+			if (iMode & EExportLineNumbers)
+				{
+				// can we do something better with errors here?
+				TRAPD(err, iEnv.SetL(KScriptLine, iNextLineNumber++));
+				if (err!=KErrNone)
+					{
+					iCompletionError.Set(err, TError::EFailedToSetScriptLineVar);
+					return err;
+					}
+				}
+			break;
+			}
+		}
+	return KErrNone;
+	}
+
+void CParser::SkipToEnd()
+	{
+	while (iLexer1->More())
+		{
+		iLexer1->NextToken();
+		}
+	}
+
+TInt CParser::CompletionCallBack(TAny* aSelf)
+	{
+	CParser* self = static_cast<CParser*>(aSelf);
+	self->iObserver->HandleParserComplete(*self, self->iCompletionError);
+	return KErrNone;
+	}
+
+TInt CParser::NextCallBack(TAny* aSelf)
+	{
+	CParser* self = static_cast<CParser*>(aSelf);
+	self->CreateNextPipeLine(NULL);
+	return KErrNone;
+	}
+
+TInt CParser::ExitCallBack(TAny*)
+	{
+	CActiveScheduler::Stop();
+	return KErrNone;
+	}
+
+void CParser::HandlePipeLineComplete(CPipeLine& aPipeLine, const TError& aError)
+	{
+	TRAPD(err, iEnv.SetL(KChildError, aError.Error()));
+	if (err)
+		{
+		iCompletionError.Set(err, TError::EFailedToSetChildErrorVar);
+		iCompletionCallBack->CallBack();
+		return;
+		}
+
+	if ((iMode & EDebug) && iObserver)
+		{
+		iObserver->LineReturned(aError.Error());
+		}
+
+	if (iForegroundPipeLine == &aPipeLine)
+		{
+		switch (iCondition)
+			{
+			case ENone:
+				{
+				if ((aError.Error() != KErrNone) && !(iMode & EKeepGoing))
+					{
+					// Bail out of script if an error is found that isn't "handled" by an "&&" or and "||".
+					SkipToEnd();
+					iCompletionError.Set(aError);
+					}
+				break;
+				}
+			case EAnd:
+				{
+				if (iAbort)
+					{
+					SkipToEnd();
+					}
+				else if (aError.Error() != KErrNone)
+					{
+					TInt err = SkipLineRemainder();
+					if (err!=KErrNone) SkipToEnd();
+					}
+				break;
+				}
+			case EOr:
+				{
+				if (iAbort)
+					{
+					SkipToEnd();
+					}
+				else if (aError.Error() == KErrNone)
+					{
+					TInt err = SkipLineRemainder();
+					if (err!=KErrNone) SkipToEnd();
+					}
+				break;
+				}
+			case EAndOr:
+				{
+				if (iAbort)
+					{
+					SkipToEnd();
+					}
+				break;
+				}
+			default:
+				{
+				ASSERT(EFalse);
+				}
+			}
+
+		delete iForegroundPipeLine;
+		iForegroundPipeLine = NULL;
+
+		if (iLexer1->More())
+			{
+			iNextPipeLineCallBack->Call();
+			}
+		}
+	else
+		{
+		TInt pos = iBackgroundPipeLines.Find(&aPipeLine);
+		ASSERT(pos >= 0);
+		iBackgroundPipeLines.Remove(pos);
+		if (aError.Error() != KErrNone)
+			{
+			iCompletionError.Set(aError);
+			}
+		delete &aPipeLine;
+		}
+
+	if (iObserver && !iLexer1->More() && (iForegroundPipeLine == NULL) && (iBackgroundPipeLines.Count() == 0))
+		{
+		iCompletionCallBack->CallBack();
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/parser.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,103 @@
+// parser.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __PARSER_H__
+#define __PARSER_H__
+
+#include <e32base.h>
+#include "error.h"
+#include "pipe_line.h"
+
+class CLexer;
+class CParser;
+
+
+class MParserObserver
+	{
+public:
+	virtual void HandleParserComplete(CParser& aParser, const TError& aError) = 0;
+	virtual void AboutToExecuteLine(const TDesC& aOrignalLine, const TDesC& aExpandedLine);
+	virtual void LineReturned(TInt aError);
+	};
+
+
+class CParser : public CBase, public MPipeLineObserver
+	{
+public:
+	enum TMode
+		{
+		ENormal				= 0x00000000,
+		EKeepGoing			= 0x00000001,
+		EDebug				= 0x00000002,
+		EExportLineNumbers	= 0x00000004
+		};
+public:
+	static CParser* NewL(TUint aMode, const TDesC& aDes, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MParserObserver* aObserver);
+	~CParser();
+	void Start();
+	void Start(TBool& aIsForeground);
+	void Kill();
+	TInt Suspend();
+	TInt Resume();
+	TInt BringToForeground();
+	void SendToBackground();
+	TInt Reattach(RIoEndPoint& aStdinEndPoint, RIoEndPoint& aStdoutEndPoint, RIoEndPoint& aStderrEndPoint);
+	TBool IsDisownable() const;
+	void Disown();
+private:
+	enum TCondition
+		{
+		ENone,
+		EAnd,
+		EOr,
+		EAndOr
+		};
+private:
+	CParser(TUint aMode, const TDesC& aDes, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MParserObserver* aObserver);
+	void ConstructL();
+	void CreateNextPipeLine(TBool* aIsForeground);
+	void CreateNextPipeLineL(TBool* aIsForeground);
+	void FindNextPipeLineL(TPtrC& aData, TCondition& aCondition, TBool& aReachedLineEnd);
+	HBufC* ExpandVariablesLC(const TDesC& aData);
+	TInt SkipLineRemainder();
+	void SkipToEnd();
+	static TInt CompletionCallBack(TAny* aSelf);
+	static TInt NextCallBack(TAny* aSelf);
+	static TInt ExitCallBack(TAny* aSelf);
+private:	// From MPipeLineObserver.
+	virtual void HandlePipeLineComplete(CPipeLine& aPipeLine, const TError& aError);
+private:
+	const TUint iMode;
+	const TPtrC iData;
+	TCondition iCondition;
+	RIoSession& iIoSession;
+	RIoReadHandle iStdin;
+	RIoWriteHandle iStdout;
+	RIoWriteHandle iStderr;
+	IoUtils::CEnvironment& iEnv;
+	CCommandFactory& iFactory;
+	CLexer* iLexer1;	///< Used to find a "pipe-line's worth" of data in iData.
+	CLexer* iLexer2;	///< Used to parse a particular pipe-line (after its variables have been expanded).
+	MParserObserver* iObserver;
+	CPipeLine* iForegroundPipeLine;
+	RPointerArray<CPipeLine> iBackgroundPipeLines;
+	TError iCompletionError;
+	CAsyncCallBack* iCompletionCallBack;
+	CAsyncCallBack* iNextPipeLineCallBack;
+	CAsyncCallBack* iExitCallBack;
+	TBool iAbort;
+	TInt iNextLineNumber;
+	TBool iOwnsIoHandles;
+	};
+
+
+#endif // __PARSER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/pipe_line.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,652 @@
+// pipe_line.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include "error.h"
+#include "pipe_line.h"
+#include "console.h"
+#include "command_factory.h"
+#include "command_wrappers.h"
+
+
+//
+// RPipeSection.
+//
+
+RPipeSection::TRedirection::TRedirection()
+	: iType(ENotRedirected), iFileName(NULL), iHandle(EUnknown)
+	{
+	}
+
+void RPipeSection::TRedirection::SetFileNameL(const TDesC& aCwd, const TDesC& aName)
+	{
+	if ((aName == _L("NUL")) || (aName == _L("/dev/null")))
+		{
+		iType = ENull;
+		}
+	else
+		{
+		if (iFileName == NULL)
+			{
+			iFileName = new(ELeave) TFileName2();
+			}
+		*iFileName = aName;
+
+		if (iFileName->Length() > 0)
+			{
+			const TUint16 firstChar = (*iFileName)[0];
+			const TUint16 lastChar = (*iFileName)[iFileName->Length() - 1];
+			const TUint16 singleQuote = '\'';
+			const TUint16 doubleQuote = '"';
+			if (((firstChar == singleQuote) && (lastChar == singleQuote)) || ((firstChar == doubleQuote) && (lastChar == doubleQuote)))
+				{
+				// The string is quoted - remove the quotes.
+				*iFileName = iFileName->Mid(1, iFileName->Length() - 2);
+				}
+			}
+		iFileName->MakeAbsoluteL(aCwd);
+		}
+	}
+
+RPipeSection::RPipeSection()
+	: iCommandArguments(5), iCommandArgumentsBuf(NULL)
+	{
+	}
+
+void RPipeSection::Close()
+	{
+	iCommandArguments.Close();
+	delete iStdinRedirection.iFileName;
+	delete iStdoutRedirection.iFileName;
+	delete iStderrRedirection.iFileName;
+	delete iCommandArgumentsBuf;
+	iCommandArgumentsBuf = NULL;
+	}
+
+HBufC* RPipeSection::GetCommandArguments() const
+	{
+	if (iCommandArgumentsBuf) return iCommandArgumentsBuf;
+
+	TInt length = 0;
+	const TInt numArgs = iCommandArguments.Count();
+	for (TInt i = 0; i < numArgs; ++i)
+		{
+		length += iCommandArguments[i].Length() + 1;
+		}
+	iCommandArgumentsBuf = HBufC::New(length);
+	if (iCommandArgumentsBuf)
+		{
+		TPtr ptr(iCommandArgumentsBuf->Des());
+		for (TInt i = 0; i < numArgs; ++i)
+			{
+			ptr.Append(iCommandArguments[i]);
+			if (i < (numArgs - 1))
+				{
+				ptr.Append(_L(" "));
+				}
+			}
+		}
+	return iCommandArgumentsBuf;
+	}
+
+
+
+//
+// CPipeLine.
+//
+
+CPipeLine* CPipeLine::NewL(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, const RArray<RPipeSection>& aPipeSections, TBool aBackground, MPipeLineObserver* aObserver, TError& aErrorContext)
+	{
+	CPipeLine* self = NewLC(aIoSession, aStdin, aStdout, aStderr, aEnv, aFactory, aPipeSections, aBackground, aObserver, aErrorContext);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CPipeLine* CPipeLine::NewLC(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, const RArray<RPipeSection>& aPipeSections, TBool aBackground, MPipeLineObserver* aObserver, TError& aErrorContext)
+	{
+	CPipeLine* self = new(ELeave) CPipeLine(aIoSession, aStdin, aStdout, aStderr, aEnv, aFactory, aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL(aPipeSections, aBackground, aErrorContext);
+	return self;
+	}
+
+CPipeLine::~CPipeLine()
+	{
+	const TInt count = iCommands.Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		iCommands[i].Close();
+		}
+	iCommands.Close();
+	delete iCompletionCallBack;
+	}
+
+void CPipeLine::Kill()
+	{
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		MCommand* command = iCommands[i].iCommand;
+		if (command)
+			{
+			command->CmndKill();
+			}
+		}
+	}
+
+TInt CPipeLine::Suspend()
+	{
+	TInt ret = KErrNone;
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		MCommand* command = iCommands[i].iCommand;
+		if (command)
+			{
+			TInt err = command->CmndSuspend();
+			if (err != KErrNone)
+				{
+				ret = err;
+				}
+			}
+		}
+	return ret;
+	}
+
+TInt CPipeLine::Resume()
+	{
+	TInt ret = KErrNone;
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		MCommand* command = iCommands[i].iCommand;
+		if (command)
+			{
+			TInt err = command->CmndResume();
+			if (err != KErrNone)
+				{
+				ret = err;
+				}
+			}
+		}
+	return ret;
+	}
+
+TInt CPipeLine::BringToForeground()
+	{
+	TInt ret = KErrNone;
+	const TInt numCommands = iCommands.Count();
+	if (numCommands > 0)
+		{
+		MCommand* command = iCommands[0].iCommand;
+		if (command)
+			{
+			ret = command->CmndStdin().SetToForeground();
+			}
+		else
+			{
+			ret = KErrDied;
+			}
+		if (ret == KErrNone)
+			{
+			for (TInt i = 0; i < numCommands; ++i)
+				{
+				MCommand* command = iCommands[i].iCommand;
+				if (command)
+					{
+					command->CmndForeground();
+					}
+				}
+			}
+		}
+	else
+		{
+		ret = KErrNotFound;
+		}
+	return ret;
+	}
+
+void CPipeLine::SendToBackground()
+	{
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		MCommand* command = iCommands[i].iCommand;
+		if (command)
+			{
+			command->CmndBackground();
+			}
+		}
+	}
+
+TInt CPipeLine::Reattach(RIoEndPoint& aStdinEndPoint, RIoEndPoint& aStdoutEndPoint, RIoEndPoint& aStderrEndPoint)
+	{
+	// Go through the array of pipe-commands attaching them to the new end points where appropriate.
+	// Note, some commands may have already completed, in which case they can be ignored.
+	// Also, we have to be careful to only reattach I/O handles that weren't explicitly redirected
+	// by the user, or by virtue of their position in the pipe-line.
+
+	TInt err = KErrNone;
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		RPipedCommand& pipedCommand = iCommands[i];
+		if (pipedCommand.iCommand)
+			{
+			if ((i == 0) && !pipedCommand.iStdinRedirected)
+				{
+				// The first command in the pipe-line whose stdin was not redirected.
+				err = pipedCommand.iCommand->CmndReattachStdin(aStdinEndPoint);
+				}
+			if ((err == KErrNone) && ((i < (numCommands - 1)) || (numCommands == 1)) && !pipedCommand.iStderrRedirected)
+				{
+				// A middle command in the pipe-line whose stderr has not been redirected.
+				err = pipedCommand.iCommand->CmndReattachStderr(aStderrEndPoint);
+				}
+			if ((err == KErrNone) && (i == (numCommands - 1)) && !pipedCommand.iStdoutRedirected)
+				{
+				// The last command in the pipe-line, whose stdout has not been redirected.
+				err = pipedCommand.iCommand->CmndReattachStdout(aStdoutEndPoint);
+				}
+			}
+		if (err)
+			{
+			break;
+			}
+		}
+	return err;
+	}
+
+TBool CPipeLine::IsDisownable() const
+	{
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		const RPipedCommand& pipedCommand = iCommands[i];
+		if (pipedCommand.iCommand && !pipedCommand.iCommand->CmndIsDisownable())
+			{
+			return EFalse;
+			}
+		}
+	return ETrue;
+	}
+
+void CPipeLine::Disown()
+	{
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		RPipedCommand& pipedCommand = iCommands[i];
+		if (pipedCommand.iCommand)
+			{
+			pipedCommand.iCommand->CmndDisown();
+			}
+		}
+	}
+
+CPipeLine::CPipeLine(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MPipeLineObserver* aObserver)
+	: iIoSession(aIoSession), iStdin(aStdin), iStdout(aStdout), iStderr(aStderr), iEnv(aEnv), iFactory(aFactory), iObserver(aObserver), iCompletionError(aStderr, aEnv)
+	{
+	}
+
+void SetIoObjectName(RIoSession& aIoSession, TInt aObjHandle, TRefByValue<const TDesC> aFmt, ...)
+	{
+	TOverflowTruncate overflow;
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TFullName name;
+	name.AppendFormatList(aFmt, list, &overflow);
+	aIoSession.SetObjectName(aObjHandle, name);
+	}
+
+void CPipeLine::ConstructL(const RArray<RPipeSection>& aPipeSections, TBool aBackground, TError& aErrorContext)
+	{
+	// Run the pipe-line in the background even if we weren't explicitly asked to if fshell's
+	// STDIN read handle isn't in the foreground. This prevents the pipe-line from stealing the
+	// foreground from whatever has it (normally another instance of fshell running in interactive
+	// mode).
+	if (!aBackground && !iStdin.IsForeground())
+		{
+		aBackground = ETrue;
+		}
+
+	if (iObserver)
+		{
+		iCompletionCallBack = new(ELeave) CAsyncCallBack(TCallBack(CompletionCallBack, this), CActive::EPriorityStandard);
+		}
+	
+	TInt i;
+	const TInt numPipeSections = aPipeSections.Count();
+
+	// Construct the command objects and IO handles.
+	// Note, all the IO handles are duplicated from the shell's to ensure that the underlying console is correctly set.
+	// Later redirections may cause some handles to be re-attached to different end points.
+	for (i = 0; i < numPipeSections; ++i)
+		{
+		const RPipeSection& thisPipeSection = aPipeSections[i];
+		User::LeaveIfError(iCommands.Append(RPipedCommand()));
+		RPipedCommand& pipedCommand = iCommands[i];
+		pipedCommand.iCommandName = thisPipeSection.iCommandName.AllocL();
+		HBufC* args = thisPipeSection.GetCommandArguments();
+		User::LeaveIfNull(args);
+		pipedCommand.iCommand = iFactory.CreateCommandL(thisPipeSection.iCommandName, aErrorContext, *args);
+		User::LeaveIfError(pipedCommand.iCommand->CmndStdin().Create(iIoSession));
+		User::LeaveIfError(pipedCommand.iCommand->CmndStdin().Duplicate(iStdin));
+		SetIoObjectName(iIoSession, pipedCommand.iCommand->CmndStdin().SubSessionHandle(), _L("%S_stdin"), &thisPipeSection.iFullName);
+		User::LeaveIfError(pipedCommand.iCommand->CmndStdout().Create(iIoSession));
+		User::LeaveIfError(pipedCommand.iCommand->CmndStdout().Duplicate(iStdout));
+		SetIoObjectName(iIoSession, pipedCommand.iCommand->CmndStdout().SubSessionHandle(), _L("%S_stdout"), &thisPipeSection.iFullName);
+		User::LeaveIfError(pipedCommand.iCommand->CmndStderr().Create(iIoSession));
+		User::LeaveIfError(pipedCommand.iCommand->CmndStderr().Duplicate(iStderr));
+		SetIoObjectName(iIoSession, pipedCommand.iCommand->CmndStderr().SubSessionHandle(), _L("%S_stderr"), &thisPipeSection.iFullName);
+		}
+
+	// Construct pipes.
+	RArray<RIoPipe> pipes;
+	CleanupClosePushL(pipes);
+	for (i = 1; i < numPipeSections; ++i)
+		{
+		RIoPipe pipe;
+		User::LeaveIfError(pipe.Create(iIoSession));
+		CleanupClosePushL(pipe);
+		SetIoObjectName(iIoSession, pipe.SubSessionHandle(), _L("%S ==> %S_pipe"), &aPipeSections[i - 1].iFullName, &aPipeSections[i].iFullName);
+		User::LeaveIfError(pipes.Append(pipe));
+		}
+
+	RIoNull null;
+	User::LeaveIfError(null.Create(iIoSession));
+	CleanupClosePushL(null);
+	SetIoObjectName(iIoSession, null.SubSessionHandle(), _L("null"));
+
+	// Connect the pipe-line.
+	for (i = 0; i < numPipeSections; ++i)
+		{
+		const RPipeSection& thisPipeSection = aPipeSections[i];
+		RPipedCommand& thisPipedCommand = iCommands[i];
+
+		switch (thisPipeSection.iStdinRedirection.iType)
+			{
+			case RPipeSection::TRedirection::ENotRedirected:
+				{
+				if (i == 0)
+					{
+					// This is the first pipe section. No wiring to do - already wired to the shell's stdin.
+					if (!aBackground)
+						{
+						User::LeaveIfError(thisPipedCommand.iCommand->CmndStdin().SetToForeground());
+						}
+					}
+				else
+					{
+					if (aPipeSections[i - 1].iStdoutRedirection.iType == RPipeSection::TRedirection::ENotRedirected)
+						{
+						// Wire intermediate pipe sections input up to the previous one's output via a pipe.
+						User::LeaveIfError(pipes[i - 1].Attach(thisPipedCommand.iCommand->CmndStdin(), RIoEndPoint::EForeground));
+						}
+					else
+						{
+						// The previous pipe section's output has been redirected, so attach this pipe section's input to null.
+						User::LeaveIfError(null.Attach(thisPipedCommand.iCommand->CmndStdin(), RIoEndPoint::EForeground));
+						}
+					}
+				break;
+				}
+			case RPipeSection::TRedirection::EFile:
+				{
+				RIoFile file;
+				User::LeaveIfError(file.Create(iIoSession, *thisPipeSection.iStdinRedirection.iFileName, RIoFile::ERead));
+				CleanupClosePushL(file);
+				SetIoObjectName(iIoSession, file.SubSessionHandle(), _L("file_%S"), thisPipeSection.iStdinRedirection.iFileName);
+				User::LeaveIfError(file.Attach(thisPipedCommand.iCommand->CmndStdin(), RIoEndPoint::EForeground));
+				CleanupStack::PopAndDestroy(&file);
+				if (i > 0)
+					{
+					if (aPipeSections[i - 1].iStdoutRedirection.iType == RPipeSection::TRedirection::ENotRedirected)
+						{
+						// Re-wire the previous pipe section's output to null.
+						User::LeaveIfError(null.Attach(iCommands[i - 1].iCommand->CmndStdout()));
+						}
+					}
+				thisPipedCommand.iStdinRedirected = ETrue;
+				break;
+				}
+			case RPipeSection::TRedirection::ENull:
+				{
+				User::LeaveIfError(null.Attach(thisPipedCommand.iCommand->CmndStdin(), RIoEndPoint::EForeground));
+				if (i > 0)
+					{
+					if (aPipeSections[i - 1].iStdoutRedirection.iType == RPipeSection::TRedirection::ENotRedirected)
+						{
+						// Re-wire the previous pipe section's output to null.
+						User::LeaveIfError(null.Attach(iCommands[i - 1].iCommand->CmndStdout()));
+						}
+					}
+				thisPipedCommand.iStdinRedirected = ETrue;
+				break;
+				}
+			case RPipeSection::TRedirection::EHandle:
+			case RPipeSection::TRedirection::EFileAppend:
+			default:
+				{
+				ASSERT(EFalse);
+				break;
+				}
+			}
+
+		switch (thisPipeSection.iStdoutRedirection.iType)
+			{
+			case RPipeSection::TRedirection::ENotRedirected:
+				{
+				if (i < (numPipeSections - 1))
+					{
+					// Attach this pipe section's output to the next one's input via a pipe.
+					User::LeaveIfError(pipes[i].Attach(thisPipedCommand.iCommand->CmndStdout()));
+					}
+				break;
+				}
+			case RPipeSection::TRedirection::EFile:
+			case RPipeSection::TRedirection::EFileAppend:
+				{
+				RIoFile file;
+				User::LeaveIfError(file.Create(iIoSession, *thisPipeSection.iStdoutRedirection.iFileName, (thisPipeSection.iStdoutRedirection.iType == RPipeSection::TRedirection::EFile) ? RIoFile::EOverwrite : RIoFile::EAppend));
+				CleanupClosePushL(file);
+				SetIoObjectName(iIoSession, file.SubSessionHandle(), _L("file_%S"), thisPipeSection.iStdoutRedirection.iFileName);
+				User::LeaveIfError(file.Attach(thisPipedCommand.iCommand->CmndStdout()));
+				CleanupStack::PopAndDestroy(&file);
+				thisPipedCommand.iStdoutRedirected = ETrue;
+				break;
+				}
+			case RPipeSection::TRedirection::ENull:
+				{
+				User::LeaveIfError(null.Attach(thisPipedCommand.iCommand->CmndStdout()));
+				thisPipedCommand.iStdoutRedirected = ETrue;
+				break;
+				}
+			case RPipeSection::TRedirection::EHandle:
+				{
+				// Handle redirection of stdout to stderr after stderr has been wired up.
+				thisPipedCommand.iStdoutRedirected = ETrue;
+				break;
+				}
+			default:
+				{
+				ASSERT(EFalse);
+				break;
+				}
+			}
+
+		switch (thisPipeSection.iStderrRedirection.iType)
+			{
+			case RPipeSection::TRedirection::ENotRedirected:
+				{
+				// Wire error output directly to the shell's stderr.
+				User::LeaveIfError(thisPipedCommand.iCommand->CmndStderr().Duplicate(iStderr));
+				break;
+				}
+			case RPipeSection::TRedirection::EFile:
+			case RPipeSection::TRedirection::EFileAppend:
+				{
+				RIoFile file;
+				User::LeaveIfError(file.Create(iIoSession, *thisPipeSection.iStderrRedirection.iFileName, (thisPipeSection.iStderrRedirection.iType == RPipeSection::TRedirection::EFile) ? RIoFile::EOverwrite : RIoFile::EAppend));
+				CleanupClosePushL(file);
+				SetIoObjectName(iIoSession, file.SubSessionHandle(), _L("file_%S"), thisPipeSection.iStderrRedirection.iFileName);
+				User::LeaveIfError(file.Attach(thisPipedCommand.iCommand->CmndStderr()));
+				CleanupStack::PopAndDestroy(&file);
+				thisPipedCommand.iStderrRedirected = ETrue;
+				break;
+				}
+			case RPipeSection::TRedirection::ENull:
+				{
+				User::LeaveIfError(null.Attach(thisPipedCommand.iCommand->CmndStderr()));
+				thisPipedCommand.iStderrRedirected = ETrue;
+				break;
+				}
+			case RPipeSection::TRedirection::EHandle:
+				{
+				ASSERT(thisPipeSection.iStderrRedirection.iHandle == RPipeSection::TRedirection::EStdout);
+				User::LeaveIfError(thisPipedCommand.iCommand->CmndStderr().Duplicate(thisPipedCommand.iCommand->CmndStdout()));
+				thisPipedCommand.iStderrRedirected = ETrue;
+				break;
+				}
+			default:
+				{
+				ASSERT(EFalse);
+				break;
+				}
+			}
+
+		if (thisPipeSection.iStdoutRedirection.iType == RPipeSection::TRedirection::EHandle)
+			{
+			ASSERT(thisPipeSection.iStdoutRedirection.iHandle == RPipeSection::TRedirection::EStderr);
+			User::LeaveIfError(thisPipedCommand.iCommand->CmndStdout().Duplicate(thisPipedCommand.iCommand->CmndStderr()));
+			}
+		}
+
+	// Pipe handles (if any) and null object (if needed) now held open by attached read a write handles.
+	CleanupStack::PopAndDestroy(&null);
+	if (numPipeSections > 1)
+		{
+		CleanupStack::PopAndDestroy(numPipeSections - 1); // The pipe handles.
+		}
+	CleanupStack::PopAndDestroy(&pipes);
+
+	// Run the pipe-line.
+	for (i = 0; i < numPipeSections; ++i)
+		{
+		const RPipeSection& thisPipeSection = aPipeSections[i];
+		RPipedCommand& thisPipedCommand = iCommands[i];
+		HBufC* args = thisPipeSection.GetCommandArguments();
+		TInt err = KErrNoMemory;
+		if (args)
+			{
+			err = thisPipedCommand.iCommand->CmndRun(*args, iEnv, *this, iIoSession);
+			if ((err == KErrNone) && thisPipedCommand.iCommand)
+				{
+				aBackground ? thisPipedCommand.iCommand->CmndBackground() : thisPipedCommand.iCommand->CmndForeground();
+				}
+			}
+		if (err)
+			{
+			Kill();
+			aErrorContext.Set(err, TError::EFailedToRunCommand, thisPipeSection.iFullName);
+			User::Leave(err);
+			}
+		}
+	}
+
+TInt CPipeLine::CompletionCallBack(TAny* aSelf)
+	{
+	CPipeLine* self = static_cast<CPipeLine*>(aSelf);
+	self->iCompletionError.Set(self->iCommands[self->iCommands.Count() - 1].iCompletionError, TError::ECommandError);
+	self->iObserver->HandlePipeLineComplete(*self, self->iCompletionError);
+	return KErrNone;
+	}
+
+void CPipeLine::HandleCommandComplete(MCommand& aCommand, TInt aError)
+	{
+	TBool allNowComplete(ETrue);
+	const TInt numCommands = iCommands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		RPipedCommand& thisPipedCommand = iCommands[i];
+		if (thisPipedCommand.iCommand == &aCommand)
+			{
+			if (aCommand.CmndExitType() == EExitPanic)
+				{
+				_LIT(KFormat, "*** PANIC ***\r\n\tCommand:  \'%S\'\r\n\tCategory: \'%S\'\r\n\tReason:   %d\r\n");
+				TBuf<256> buf;
+				TOverflowTruncate overflow;
+				TExitCategoryName category(aCommand.CmndExitCategory());
+				buf.AppendFormat(KFormat, &overflow, thisPipedCommand.iCommandName, &category, aError);
+				iStderr.Write(buf);
+				if (aError >= 0)
+					{
+					// Panicking with KERN-EXEC 0 shouldn't equate to a completionerror of KErrNone!
+					aError = KErrDied;
+					}
+				}
+			else if (aCommand.CmndExitType() == EExitTerminate)
+				{
+				_LIT(KFormat, "Command '%S' terminated with reason %d\r\n");
+				TBuf<256> buf;
+				TOverflowTruncate overflow;
+				buf.AppendFormat(KFormat, &overflow, thisPipedCommand.iCommandName, aError);
+				iStderr.Write(buf);
+					if (aError >= 0)
+					{
+					// Terminate 0 shouldn't equate to a completionError of KErrNone
+					aError = KErrDied;
+					}
+				}
+			thisPipedCommand.iCommand->CmndRelease();
+			thisPipedCommand.iCommand = NULL;
+			thisPipedCommand.iCompletionError = aError;
+			}
+		else if (thisPipedCommand.iCommand)
+			{
+			allNowComplete = EFalse;
+			}
+		}
+
+	if (allNowComplete && iObserver)
+		{
+		iCompletionCallBack->CallBack();
+		}
+	}
+
+
+//
+// CPipeLine::RPipedCommand.
+//
+
+CPipeLine::RPipedCommand::RPipedCommand()
+	: iCommand(NULL), iCompletionError(KErrNone), iCommandName(NULL), iStdinRedirected(EFalse), iStdoutRedirected(EFalse), iStderrRedirected(EFalse)
+	{
+	}
+
+void CPipeLine::RPipedCommand::Close()
+	{
+	if (iCommand)
+		{
+		iCommand->CmndKill();
+		if (iCommand)
+			{
+			iCommand->CmndRelease();
+			iCommand = NULL;
+			}
+		}
+	if (iCommandName)
+		{
+		delete iCommandName;
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/pipe_line.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,131 @@
+// pipe_line.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __PIPE_LINE_H__
+#define __PIPE_LINE_H__
+
+#include <e32base.h>
+#include "command_wrappers.h"
+
+class TError;
+class CPipeLine;
+class MConsole;
+class CCommandFactory;
+namespace IoUtils
+	{
+	class CEnvironment;
+	}
+
+
+class MPipeLineObserver
+	{
+public:
+	virtual void HandlePipeLineComplete(CPipeLine& aPipeLine, const TError& aError) = 0;
+	};
+
+
+class RPipeSection
+	{
+public:
+	RPipeSection();
+	void Close();
+	HBufC* GetCommandArguments() const;
+public:
+	class TRedirection
+		{
+	public:
+		enum TType
+			{
+			ENotRedirected,
+			EFile,
+			EFileAppend,
+			EHandle,
+			ENull
+			};
+		enum THandle
+			{
+			EUnknown,
+			EStdin,
+			EStdout,
+			EStderr
+			};
+	public:
+		TRedirection();
+		void SetFileNameL(const TDesC& aCwd, const TDesC& aName);
+	public:
+		TType iType;
+		IoUtils::TFileName2* iFileName;
+		THandle iHandle;
+		};
+public:
+	TPtrC iFullName;
+	TPtrC iCommandName;
+	RArray<TPtrC> iCommandArguments;
+	TRedirection iStdinRedirection;
+	TRedirection iStdoutRedirection;
+	TRedirection iStderrRedirection;
+private:
+	mutable HBufC* iCommandArgumentsBuf;
+	};
+
+
+class CPipeLine : public CBase, public MCommandObserver
+	{
+public:
+	static CPipeLine* NewL(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, const RArray<RPipeSection>& aPipeSections, TBool aBackground, MPipeLineObserver* aObserver, TError& aErrorContext);
+	static CPipeLine* NewLC(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, const RArray<RPipeSection>& aPipeSections, TBool aBackground, MPipeLineObserver* aObserver, TError& aErrorContext);
+	~CPipeLine();
+	void Kill();
+	TInt Suspend();
+	TInt Resume();
+	TInt BringToForeground();
+	void SendToBackground();
+	const TDesC& Name() const;
+	TInt Reattach(RIoEndPoint& aStdinEndPoint, RIoEndPoint& aStdoutEndPoint, RIoEndPoint& aStderrEndPoint);
+	TBool IsDisownable() const;
+	void Disown();
+private:
+	CPipeLine(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MPipeLineObserver* aObserver);
+	void ConstructL(const RArray<RPipeSection>& aPipeSections, TBool aBackground, TError& aErrorContext);
+	static TInt CompletionCallBack(TAny* aSelf);
+private:	// From MCommandObserver.
+	virtual void HandleCommandComplete(MCommand& aCommand, TInt aError);
+private:
+	class RPipedCommand
+		{
+	public:
+		RPipedCommand();
+		void Close();
+	public:
+		MCommand* iCommand;
+		TInt iCompletionError;
+		HBufC* iCommandName;
+		TBool iStdinRedirected;
+		TBool iStdoutRedirected;
+		TBool iStderrRedirected;
+		};
+private:
+	TPtrC iName;
+	RIoSession& iIoSession;
+	RIoReadHandle& iStdin;
+	RIoWriteHandle& iStdout;
+	RIoWriteHandle& iStderr;
+	IoUtils::CEnvironment& iEnv;
+	CCommandFactory& iFactory;
+	MPipeLineObserver* iObserver;
+	RArray<RPipedCommand> iCommands;
+	CAsyncCallBack* iCompletionCallBack;
+	TError iCompletionError;
+	};
+
+
+#endif // __PIPE_LINE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/script_command.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,376 @@
+// script_command.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "script_command.h"
+#include "fshell.h" // For KScriptArgCount etc
+#include <fshell/descriptorutils.h>
+
+using namespace IoUtils;
+using namespace LtkUtils;
+
+CScriptCommand* CScriptCommand::NewLC(const TDesC& aScriptPath, TIoHandleSet& aIoHandles)
+	{
+	CScriptCommand* self = new(ELeave) CScriptCommand;
+	CleanupStack::PushL(self);
+	self->ConstructL(aScriptPath, aIoHandles);
+	return self;
+	}
+
+const TDesC& CScriptCommand::Name() const
+	{
+	return iName;
+	}
+
+void CScriptCommand::DoRunL()
+	{
+	// Never actually runs
+	__DEBUGGER();
+	}
+
+CScriptCommand::CScriptCommand()
+	: CCommandBase()
+	{
+	}
+
+void CScriptCommand::ConstructL(const TDesC& aScriptPath, TIoHandleSet& aIoHandles)
+	{
+	BaseConstructL();
+
+	// Duplicate some handles in case we need to display the script's help text.
+	IoSession().SetHandle(aIoHandles.IoSession().Handle());
+	User::LeaveIfError(IoSession().Duplicate(RThread(), EOwnerThread));
+	Stdout().CreateL(IoSession());
+	Stdout().Duplicate(aIoHandles.Stdout());
+	Stderr().CreateL(IoSession());
+	Stderr().Duplicate(aIoHandles.Stderr());
+	
+	iScriptPath = aScriptPath.AllocL();
+	iName.Set(TParsePtrC(*iScriptPath).NameAndExt());
+	RFs fs; // Can't use FsL(), that needs an env set up
+	CleanupClosePushL(fs);
+	User::LeaveIfError(fs.Connect());
+
+	iOwnedCif = CCommandInfoFile::NewL(fs, *iScriptPath); // A script file is also its own cif
+
+	if (iOwnedCif->Name().Length() == 0)
+		{
+		// No cif data - fall back to just creating a basic array of args (for converting into $1 $2 etc)
+		iArguments.AppendStringL(iNonCifScriptArguments, _L("args"), _L("Arguments for the script. These are converted to the environment variables C<$1>, C<$2> etc."), KValueTypeFlagOptional);
+		delete iOwnedCif;
+		iOwnedCif = NULL;
+		}
+	else
+		{
+		SetCif(*iOwnedCif); // SetCif doesn't take ownership (which is what iOwnedCif is for)
+
+		// Now go through and make up "member variables" to correspond to everything in the CIF so we can fool CCommandBase into
+		// doing the parsing work for us
+		const TInt argCount = iOwnedCif->Arguments().Count();
+		for (TInt i = 0; i < argCount; i++)
+			{
+			SetupArgumentL(iOwnedCif->Arguments()[i]);
+			}
+		
+		const TInt optCount = iOwnedCif->Options().Count();
+		for (TInt i = 0; i < optCount; i++)
+			{
+			const TCommandOption& opt = iOwnedCif->Options()[i];
+			SetupOptionL(opt);
+			}
+
+		iOwnedCif->AssignL(iArguments, iOptions);
+		}
+
+	iOptions.AppendBoolL(iDisplayHelp, 'h', _L("help"), _L("Display help.")); // Always support --help (cannot do this before the call to CCommandInfoFile::AssignL())
+
+	// Our argument data structures should now be fully constructed
+	CleanupStack::PopAndDestroy(&fs);
+	}
+
+TInt StorageSizeForType(TUint aType)
+	{
+	TInt size = sizeof(TInt);
+	switch (aType)
+		{
+		case KValueTypeReal:
+			size = sizeof(TReal); break;
+		case KValueTypeFileName:
+			size = sizeof(TFileName2); break;
+		case KValueTypeUint64:
+		case KValueTypeInt64:
+			size = sizeof(TInt64); break;
+		default:
+			break;
+		}
+	return size;
+	}
+
+void CScriptCommand::SetupArgumentL(const TValue& aValue)
+	{
+	if (aValue.AcceptsMultiple()) StaticLeaveIfErr(KErrArgument, _L("Arguments with the 'multiple' attribute are not supported for scripts"));
+
+	const TUint type = aValue.Type();
+	void* valptr = User::AllocZL(StorageSizeForType(type));
+	CleanupStack::PushL(valptr);
+
+	TPtrC name = aValue.Name();
+	switch (type)
+		{
+	case KValueTypeInt:
+		iArguments.AppendIntL(*(TInt*)valptr, name);
+		break;
+	case KValueTypeUint:
+		iArguments.AppendUintL(*(TUint*)valptr, name);
+		break;
+	case KValueTypeString:
+		iArguments.AppendStringL(*(HBufC**)valptr, name);
+		break;
+	case KValueTypeFileName:
+		new (valptr) TFileName2; // We only AllocZL'd, we didn't initialise it
+		iArguments.AppendFileNameL(*(TFileName2*)valptr, name);
+		break;
+	case KValueTypeEnum:
+		iArguments.AppendEnumL(*(TInt*)valptr, name);
+		break;
+	case KValueTypeReal:
+		iArguments.AppendRealL(*(TReal*)valptr, name);
+		break;
+	case KValueTypeUint64:
+		iArguments.AppendUintL(*(TUint64*)valptr, name);
+		break;
+	case KValueTypeInt64:
+		iArguments.AppendIntL(*(TInt64*)valptr, name);
+		break;
+	default:
+		StaticLeaveIfErr(KErrArgument, _L("Script argument '%S' is of unsupported type %d"), &name, aValue.Type());
+		break;
+		}
+	CleanupStack::Pop(valptr);
+	}
+
+void CScriptCommand::SetupOptionL(const IoUtils::TValue& aValue)
+	{
+	if (aValue.AcceptsMultiple()) StaticLeaveIfErr(KErrArgument, _L("Options with the 'multiple' attribute are not supported for scripts"));
+
+	const TUint type = aValue.Type();
+	void* valptr = User::AllocZL(StorageSizeForType(type));
+	CleanupStack::PushL(valptr);
+
+	TPtrC name = aValue.Name();
+	switch (type)
+		{
+	case KValueTypeBool:
+		iOptions.AppendBoolL(*(TBool*)valptr, name);
+		break;
+	case KValueTypeInt:
+		iOptions.AppendIntL(*(TInt*)valptr, name);
+		break;
+	case KValueTypeUint:
+		iOptions.AppendUintL(*(TUint*)valptr, name);
+		break;
+	case KValueTypeString:
+		iOptions.AppendStringL(*(HBufC**)valptr, name);
+		break;
+	case KValueTypeFileName:
+		new (valptr) TFileName2; // We only AllocZL'd, we didn't initialise it
+		iOptions.AppendFileNameL(*(TFileName2*)valptr, name);
+		break;
+	case KValueTypeEnum:
+		iOptions.AppendEnumL(*(TInt*)valptr, name);
+		break;
+	case KValueTypeReal:
+		iOptions.AppendRealL(*(TReal*)valptr, name);
+		break;
+	case KValueTypeUint64:
+		iOptions.AppendUintL(*(TUint64*)valptr, name);
+		break;
+	case KValueTypeInt64:
+		iOptions.AppendIntL(*(TInt64*)valptr, name);
+		break;
+	default:
+		StaticLeaveIfErr(KErrArgument, _L("Script argument '%S' is of unsupported type %d"), &name, aValue.Type());
+		break;
+		}
+	CleanupStack::Pop(valptr);
+	}
+
+CScriptCommand::~CScriptCommand()
+	{
+	if (iOwnedCif)
+		{
+		// We set all these up, we need to delete them
+		for (TInt i = 0; i < iArguments.Count(); i++)
+			{
+			const TCommandArgument& arg = ((const RCommandArgumentList&)iArguments)[i];
+			if (arg.Type() == KValueTypeString) delete *(HBufC**)arg.ValuePtr();
+			delete arg.ValuePtr();
+			}
+		for (TInt i = 0; i < iOptions.Count(); i++)
+			{
+			const TCommandOption& opt = ((const RCommandOptionList&)iOptions)[i];
+			if (opt.ValuePtr() != &iDisplayHelp)
+				{
+				if (opt.Type() == KValueTypeString) delete *(HBufC**)opt.ValuePtr();
+				delete opt.ValuePtr();
+				}
+			}
+		}
+
+	delete iScriptPath;
+	delete iOwnedCif;
+	iNonCifScriptArguments.ResetAndDestroy();
+	Stderr().Close();
+	Stdout().Close();
+	IoSession().Close();
+	}
+
+void CScriptCommand::ParseCommandLineArgsL(const TDesC& aArgs, CEnvironment& aEnv, RPointerArray<HBufC>* aAdditionalPrefixArguments)
+	{
+	CreateEnvironmentL(&aEnv); // This sets aEnv as our environment. Doesn't copy or take ownership. ParseCommandLineL needs access to the env for things like the escape char setting
+
+	if (aAdditionalPrefixArguments && aAdditionalPrefixArguments->Count())
+		{
+		// Must be a nicer way of doing this... prefix onto aArgs some args that couldn't possibly require escaping (this way we don't have to worry if anything in aAdditionalPrefixArguments actually does need escaping)
+		LtkUtils::RLtkBuf argsBuf;
+		CleanupClosePushL(argsBuf);
+		TInt c = aAdditionalPrefixArguments->Count();
+		while (c--)
+			{
+			argsBuf.AppendL(_L("placeholder "));
+			}
+		argsBuf.AppendL(aArgs);
+		ParseCommandLineL(argsBuf);
+		CleanupStack::PopAndDestroy(&argsBuf);
+		}
+	else
+		{
+		ParseCommandLineL(aArgs);
+		}	
+
+	if (!iArguments.AllSet())
+		{
+		User::Leave(KErrArgument);
+		}
+
+	// Everything is filled in now, just have to setup aEnv with the results
+	TInt argCount = iArguments.Count();
+	if (iOwnedCif)
+		{
+		for (TInt i = 0; i < argCount; i++)
+			{
+			const TCommandArgument& arg = ((const RCommandArgumentList&)iArguments)[i];
+			SetEnvironmentVariableFromValueL(aEnv, arg);
+			}
+
+		// Now check for overrides from aAdditionalPrefixArguments
+		if (aAdditionalPrefixArguments)
+			{
+			for (TInt i = 0; i < aAdditionalPrefixArguments->Count(); i++)
+				{
+				const TCommandArgument& arg = ((const RCommandArgumentList&)iArguments)[i]; // This const cast shouldn't be needed, I don't think, to make sure that we use the const operator[]
+				aEnv.SetL(arg.Name(), *(*aAdditionalPrefixArguments)[i]);
+				}
+			}
+		for (TInt i = 0; i < iOptions.Count(); i++)
+			{
+			const TCommandOption& opt = ((const RCommandOptionList&)iOptions)[i];
+			if (opt.ValuePtr() != &iDisplayHelp) SetEnvironmentVariableFromValueL(aEnv, opt);
+			}
+		}
+	else
+		{
+		// Just set $1, $2 etc
+		argCount = iNonCifScriptArguments.Count();
+		for (TInt i = 0; i < argCount; i++)
+			{
+			TBuf<16> varname;
+			varname.AppendNum(i+1);
+			aEnv.SetLocalL(varname);
+			if (aAdditionalPrefixArguments && i < aAdditionalPrefixArguments->Count())
+				{
+				aEnv.SetL(varname, *(*aAdditionalPrefixArguments)[i]);
+				}
+			else
+				{
+				aEnv.SetL(varname, *iNonCifScriptArguments[i]);
+				}
+			}
+		}
+
+	aEnv.SetLocalL(KScriptArgCount);
+	aEnv.SetL(KScriptArgCount, argCount);
+	}
+
+void CScriptCommand::DisplayScriptHelpL()
+	{
+	const CTextBuffer* helpText = GetHelpTextL();
+	CleanupStack::PushL(const_cast<CTextBuffer*>(helpText));
+	PageL(*helpText);
+	CleanupStack::PopAndDestroy(const_cast<CTextBuffer*>(helpText));
+	}
+
+void CScriptCommand::SetEnvironmentVariableFromValueL(IoUtils::CEnvironment& aEnv, const IoUtils::TValue& aValue)
+	{
+	const TPtrC name(aValue.Name());
+	aEnv.SetLocalL(name);
+	void* valptr = aValue.ValuePtr();
+
+	switch (aValue.Type())
+		{
+	case KValueTypeBool:
+		if (*(TBool*)valptr)
+			{	
+			aEnv.SetL(name, 1);
+			}
+		break;
+	case KValueTypeInt:
+		aEnv.SetL(name, *(TInt*)valptr);
+		break;
+	case KValueTypeUint:
+		iTempStr.Num(*(TUint*)valptr, EDecimal);
+		aEnv.SetL(name, iTempStr);
+		break;
+	case KValueTypeString:
+		{
+		HBufC* val = *(HBufC**)valptr;
+		if (val) aEnv.SetL(name, *val);
+		break;
+		}
+	case KValueTypeFileName:
+		aEnv.SetL(name, *(TFileName2*)valptr);
+		break;
+	case KValueTypeEnum:
+		{
+		TEnum enumObj(aValue.EnumValueList());
+		aEnv.SetL(name, enumObj.GetString(*(TInt*)valptr));
+		break;
+		}
+	case KValueTypeReal:
+		{
+		_LIT(KRealFormat, "%g");
+		iTempStr.Format(KRealFormat, *(TReal*)valptr);
+		aEnv.SetL(name, iTempStr);
+		break;
+		}
+	case KValueTypeUint64:
+		iTempStr.Num(*(TUint64*)valptr, EDecimal);
+		aEnv.SetL(name, iTempStr);
+		break;
+	case KValueTypeInt64:
+		iTempStr.Num(*(TInt64*)valptr);
+		aEnv.SetL(name, iTempStr);
+		break;
+	default:
+		StaticLeaveIfErr(KErrArgument, _L("Script argument '%S' is of unsupported type %d"), &name, aValue.Type());
+		break;
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/script_command.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// script_command.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ioutils.h>
+#include <fshell/stringhash.h>
+
+// Helper class for parsing the arguments passed to a script (via "fshell script" or "source script")
+class CScriptCommand : public IoUtils::CCommandBase
+	{
+public:
+	static CScriptCommand* NewLC(const TDesC& aScriptPath, TIoHandleSet& aIoHandles);
+	~CScriptCommand();
+	void ParseCommandLineArgsL(const TDesC& aArgs, IoUtils::CEnvironment& aEnv, RPointerArray<HBufC>* aAdditionalPrefixArguments=NULL);
+	void DisplayScriptHelpL();
+
+	TBool ShouldDisplayHelp() const { return iDisplayHelp; }
+
+protected: // From CCommandBase
+	const TDesC& Name() const;
+	void DoRunL();
+
+private:
+	CScriptCommand();
+	void ConstructL(const TDesC& aScriptPath, TIoHandleSet& aIoHandles);
+	void SetupArgumentL(const IoUtils::TValue& aValue);
+	void SetupOptionL(const IoUtils::TValue& aValue);
+	void SetEnvironmentVariableFromValueL(IoUtils::CEnvironment& aEnv, const IoUtils::TValue& aValue);
+
+private:
+	HBufC* iScriptPath;
+	TPtrC iName;
+	IoUtils::CCommandInfoFile* iOwnedCif; // We can't access the base class iCif or iFlags directly...
+
+	RPointerArray<HBufC> iNonCifScriptArguments;
+	TBool iDisplayHelp;
+	TBuf<256> iTempStr;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/string_utils.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// string_utils.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "string_utils.h"
+
+#define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
+#define CASE_RETURN_LIT2(XXX, YYY) case XXX: { _LIT(_KLit, YYY); return &_KLit; }
+#define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
+
+const TDesC* ShStringify::JobStatus(CJob::TStatus aStatus)
+	{
+	switch (aStatus)
+		{
+		CASE_RETURN_LIT2(CJob::EPending, "Pending");
+		CASE_RETURN_LIT2(CJob::ERunning, "Running");
+		CASE_RETURN_LIT2(CJob::EStopped, "Stopped");
+		CASE_RETURN_LIT2(CJob::EComplete, "Complete");
+		DEFAULT_RETURN_LIT("*** STATUS UNKNOWN ***");
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/string_utils.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// string_utils.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __STRING_UTILS_H__
+#define __STRING_UTILS_H__
+
+#include <e32std.h>
+#include "job.h"
+
+class ShStringify
+	{
+public:
+	static const TDesC* JobStatus(CJob::TStatus aStatus);
+	};
+
+
+#endif // __STRING_UTILS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/addenv.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+#!fshell
+# addenv.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Syntax: source addenv.script <variablename> <value>
+# Note: Have to use source to call this, otherwise the env changes will be lost!
+
+var ARG_COUNT != 2 && error -6 "Syntax: source addenv.script <variablename> <value>"
+
+var $1 add $2
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/args.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+#!fshell
+# args.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# syntax: fshell args.script <arguments>
+# Tests fshell's script argument parser, by printing out the parsed arguments as it sees them
+
+repeat $ARG_COUNT 'export I $REPEAT_COUNT && var I add 1 && echo Arg $I: $$I^r^n'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/checkargs.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+#!fshell
+# checkargs.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# syntax: export ARG1, ARG2 etc then call fshell checkargs.script ARG1 ARG2 and it errors if they don't match
+# Tests fshell's script argument parser, by printing out the parsed arguments as it sees them
+
+var ARG_COUNT == 0 && exit # Repeat 0 means repeat forever, not never
+
+repeat $ARG_COUNT 'export I $REPEAT_COUNT && var I add 1 && var $I == "$ARG$I" || error -6 "Argument $I didn^'t match ^$ARG$I ($$I != $ARG$I)"'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/errordef.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,15 @@
+#!fshell
+# errordef.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+var KEEP_GOING not-defined && export Error 'fshell -e "echo ^"Test failed, env is:^" && env && error"'
+var KEEP_GOING defined && export Error 'error -39 "Test failure in $SCRIPT_NAME at line $SCRIPT_LINE"'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/fshell-basic-test.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,164 @@
+#!fshell
+# fshell-basic-test.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Syntax: fshell fshell-basic-test.script
+# Tests fundamental fshell primitives.
+# Start with comments with awkward things in > && < in; I suppose ' "
+
+var ARG_COUNT == 0 || error -6 "fshell-basic-test should not be called with any arguments"
+
+# Check the basics -  environment variables, export, var
+export TEST testing
+var TEST == testing || error
+
+export TEST
+var TEST not-defined || error
+
+# Test multistage pipelines
+# Pipeline operators are right-associative, ie "x || y && z" means "x || (y && z)" and *NOT* (x || y) && z
+export TEST 1 && var TEST == 2 && error
+export TEST 1 && var TEST == 2 || var TEST add 3
+var TEST == 4 || error
+export TEST 1 && var TEST == 2 || var TEST add 3 && var TEST == 4 || error # As above but all in one line
+var NONEXISTANT not-defined || var NONEXISTANT defined && error
+
+# Test that an env var can be expanded to a whole pipeline stage
+export TEST_CMD "export TEST_CMD_COMPLETED 1"
+$TEST_CMD
+var TEST_CMD_COMPLETED == 1 || error
+
+# Now we know that works, use it to give ourselves better error reporting
+# Apparently an env var can't expand to more than one pipeline stage, which is why we have to wrap this in fshell -e
+var KEEP_GOING not-defined && export Error 'fshell -e "echo ^"Test failed, env is:^" && env && error"'
+var KEEP_GOING defined && export Error 'error -39 "Test failure in $SCRIPT_NAME at line $SCRIPT_LINE"'
+
+# Check we've defined the things we're supposed to in a script
+var SCRIPT_PATH defined || $Error
+var SCRIPT_NAME == fshell-basic-test.script || $Error
+var SCRIPT_LINE == 48 || error -39 "SCRIPT_LINE isn't 48, it's $SCRIPT_LINE" # Remember to update this if you change the script above this point!
+var 0 == $SCRIPT_PATH$SCRIPT_NAME || $Error
+export DOLLAR_SCRIPT_LINE_VALUE $SCRIPT_LINE
+var DOLLAR_SCRIPT_LINE_VALUE == 50 || $Error
+
+# Test pipes, redirection
+
+echo -n "Testing pipes" | export -s TEST
+var TEST == "Testing pipes" || $Error
+
+# Check export -s can cope with complex stuff
+echo -n "" | export -s TEST
+var TEST == "" || $Error
+echo -n "a^r^nb" | export -s TEST
+var TEST == "a^r^nb" || $Error
+
+# Check echo's handling of newlines is correct
+echo --no-newline "Hello world!" | export -s TEST
+var TEST == "Hello world!" || $Error
+echo "Hello world!" | export -s TEST
+var TEST == "Hello world!^r^n" || $Error
+echo "Hello world!^r^n" | export -s TEST
+# If there's already a newline, echo shouldn't add another
+var TEST == "Hello world!^r^n" || $Error
+
+# Check that hashes, ampersands etc can be quoted ok
+export TEST "something ^x3e somewhere ^x26^x26 something else ^x23 with comment^x0d^x0a"
+echo "something > somewhere && something else # with comment^r^n" | export -s RESULT
+var RESULT == "$TEST" || $Error
+var TEST == "$RESULT" || $Error # Check it's a reflexive relationship
+echo something^ ^>^ somewhere^ ^&^&^ something^ else^ ^#^ with^ comment^r^n | export -s RESULT
+var RESULT == "$TEST" || $Error
+var TEST == "$RESULT" || $Error # Check it's a reflexive relationship
+export "#" "Let's define ^$# just for the fun of it"
+var "#" == "Let's define ^$# just for the fun of it" || $Error
+
+# Test hashes inside single quotes
+var '#' == 'Let^'s define $# just for the fun of it' || $Error # Balance ' for my struggling text editor syntax highlighter
+
+# Check that 2>&1 works as expected
+echo --stderr --no-newline Hello 2>&1 | export -s TEST
+var TEST == Hello || $Error
+
+echo "SHOULDN'T SEE THIS ON STDOUT (1)" > NUL
+echo "SHOULDN'T SEE THIS ON STDOUT (2)" > /dev/null
+
+echo --stderr "SHOULDN'T SEE THIS ON STDERR (1)" 2> NUL
+echo --stderr "SHOULDN'T SEE THIS ON STDERR (2)" 2> /dev/null
+
+exists /dev/null && $Error # Check we didn't actually create a file called /dev/null
+variant wins || exists NUL && $Error # Check we didn't actually create a file called NUL. Don't do this check on wins because apparently NUL gets passed through to the underlying Win32 file system, on which NUL is valid... it really shouldn't do that!
+
+# Check we can use &| to continue past an error
+echo -n "" &| export OK 1
+var OK defined || $Error
+export OK
+error -39 "Shouldn't ever see this!" 2>NUL &| export OK 1
+var OK defined || $Error
+export OK
+
+export FILE c:\fshell-basic-test.txt
+rm $FILE 2>/dev/null &| echo -n "" # I don't like using "&| echo" syntax to indicate don't care if it fails. Probably rm -f should be quiet like unix version
+echo -n "Testing file redirection" > c:\fshell-basic-test.txt
+
+# The redirect stdin operation doesn't get used much
+export -s FILECONTENTS < $FILE
+var FILECONTENTS == "Testing file redirection" || $Error
+
+# Check doing the same thing via a pipe-line also works
+cat -e utf-8 $FILE | export -s FILECONTENTS
+var FILECONTENTS == "Testing file redirection" || $Error
+
+rm $FILE # clean up
+
+# Test that source works, takes arguments ok, and inherits environment correctly
+source $SCRIPT_PATH\setenv.script SOMETHING 1234
+var SOMETHING == 1234 || $Error
+source $SCRIPT_PATH\addenv.script SOMETHING 4321
+var SOMETHING == 5555 || $Error
+
+source $SCRIPT_PATHsetenv.script SOMETHING # Check that the \ isn't required after the $SCRIPT_PATH
+var SOMETHING not-defined || $Error
+
+# Check that source hasn't nuked our vars
+var SCRIPT_NAME == fshell-basic-test.script || $Error
+var 0 == $SCRIPT_PATH$SCRIPT_NAME || $Error
+var ARG_COUNT defined || $Error
+var ARG_COUNT == 0 || $Error
+# And that none of the sources we just ran have polluted $1 etc with their arguments
+var 1 not-defined || $Error
+
+# Ambiguous variable expansion - appears to be done by longest prefix match
+export AA bb
+export AAAA bbbb
+export AAA bbb
+echo -n $AAAa | export -s RESULT
+var RESULT == bbba || $Error
+echo -n $AAAAa | export -s RESULT
+var RESULT == bbbba || $Error
+
+# Ambiguous *nested* variable expansion. Evil!
+export ANEST correct
+export INNER NEST
+echo -n $A$INNER | export -s RESULT 
+var RESULT == correct || $Error
+export A aaa
+#TODO with $A defined this no longer works - is this reasonable? I'm guessing the string is expanded left-to-right.
+#echo $A$INNER | export -s RESULT # I'd like this to expand to $ANEST then to "correct" but it expands to aaaNEST
+
+# Test that errors reported from scripts are reported with correct line numbers
+export EXPECTED_ERR "Error: Aborted ^"$SCRIPT_PATHprinterror.script^" at line 17 : KErrNotFound (-1)^r^n"
+
+fshell $SCRIPT_PATHprinterror.script 2>&1 | export -s PRINTERR
+var PRINTERR == "$EXPECTED_ERR" || $Error
+
+source $SCRIPT_PATHprinterror.script 2>&1 | export -s PRINTERR
+var PRINTERR == "$EXPECTED_ERR" || $Error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/fshell-ccommandbase-test.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,43 @@
+#!fshell
+# fshell-ccommandbase-test.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Syntax: fshell fshell-ccommandbase-test.script
+# Tests various features of CCommandBase relating to argument and option parsing
+
+source $SCRIPT_PATH\errordef.script
+
+# Check that negative integers are parsed correctly
+tinteger -1 -2 -3 -4 # -1 is a short option, -2 is an integer argument, -3 is a short option that takes an int (being -4). If any of them don't get filled in correctly tinteger will bail
+tinteger -3 -4 -2 -1 # This should be equivalent
+export TESTINT "-8"
+var TESTINT subtract "-5" # "subtract -5" is a trickier-to-parse equivalent of "add 5"
+var TESTINT == "-3" || $Error
+#TODO hmm should we have to quote the string arguments that start with a dash?
+
+# Check that 64-bit types are handled ok (these don't get used much so worth testing here)
+# If tfshellarguments doesn't see these exact values it will error
+tfshellarguments 1099511627776 3.1415927
+tfshellarguments 0x10000000000 31415927.0e-7
+tfshellarguments 0x10000000000 31415927 2>/dev/null && $Error # If this *succeeds* it's an error, because the floating point arg is wrong, hence the use of && rather than ||
+
+# Check that options and args can be filled in from the environment (run tenvarguments first with all args specified on command line as a control)
+tenvarguments StringArg 1234 0x1234 --boolopt --stringopt StringOpt --intopt 4321 --uintopt 0x4321
+export STRINGARG StringArg
+export INTARG 1234
+export UINTARG 0x1234
+export BOOLOPT 1
+export STRINGOPT StringOpt
+export INTOPT 4321
+export UINTOPT 0x4321
+tenvarguments # CCommandBase will moan if anything non-optional is not filled in, and tenvarguments itself checks the values it receives are what it expects.
+tnoncifenvarguments # same but testing that the behaviour is the same when not using a CIF (the way the arguments are set up is a slightly different code path)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/fshell-last-test.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+#!fshell
+# fshell-last-test.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Test that the behaviour of the 'last' attribute behaves the way we expect, in various awkward cases involving pipes and pipelines
+
+source $SCRIPT_PATH\errordef.script
+
+export TEST_TEXT "Something with spaces and 'inner quotes' and --options"
+
+echo -n "Something with spaces and 'inner quotes' and --options" | export -s RESULT
+var RESULT == "$TEST_TEXT" || $Error
+
+echo -n Something with spaces and 'inner quotes' and --options | export -s RESULT
+var RESULT == "$TEST_TEXT" || $Error
+
+fshell -e "echo -n a && echo -n b" | export -s RESULT
+var RESULT == "ab" || $Error
+
+repeat 1 "fshell -e 'echo -n c && echo -n d'" | export -s RESULT
+var RESULT == "cd" || $Error
+
+repeat 3 echo a && echo b | export -s RESULT
+var RESULT == b^r^n || $Error # Apparently pipe only operates on a single pipeline stage
+
+# Put the repeat inside an fshell -e merely so we can pipe the whole lot into export
+fshell -e "repeat 3 echo -n a && echo -n b" | export -s RESULT
+var RESULT == aaab || $Error # last doesn't include &&
+
+fshell -e "repeat 3 'echo -n a && echo -n b'" | export -s RESULT
+var RESULT == ababab || $Error
+
+fshell -e "repeat 1 echo -n 'quotation ^^'soup^^''" | export -s RESULT
+var RESULT == "quotation 'soup'" || $Error
+
+export ARG1 "Arg 1"
+export ARG2 "2222"
+export ARG3 "Arg '3' has inner quotes"
+fshell $SCRIPT_PATH\checkargs.script "Arg 1" 2222 "Arg '3' has inner quotes"
+
+# Check that escape sequences inside a "last" command are handled correctly (ie aren't expanded)
+echo hello ^t world | export -s RESULT
+var RESULT == "hello ^^t world^r^n" || $Error
+
+# Check that variable expansion inside a "last" command is handled correctly
+echo -n dollar questionmark is: $? | export -s RESULT
+var RESULT == "dollar questionmark is: 0" || $Error
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/fshell-scriptcif-test.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+#!fshell
+# fshell-scriptcif-test.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+source $SCRIPT_PATH\errordef.script
+export QUIET "2>&1 >/dev/null" # Used to quieten the things that we're fully expecting to fail
+
+# The things that should suceed use "|| $Error", the things that should fail use $QUIET and "&& $Error" in case they actually succeed when the shouldn't
+
+fshell $SCRIPT_PATH\tscriptargs.script abc123 || $Error
+fshell $SCRIPT_PATH\tscriptargs.script $QUIET && $Error
+
+export EXPECTEDMYOPTIONALARG optionalarg
+fshell $SCRIPT_PATH\tscriptargs.script abc123 optionalarg || $Error
+fshell $SCRIPT_PATH\tscriptargs.script abc123 $QUIET && $Error
+fshell $SCRIPT_PATH\tscriptargs.script abc123 wrongoptionalarg $QUIET && $Error
+export EXPECTEDMYOPTIONALARG
+
+# Check that the arguments to the script are being set as local environment variables and so don't pollute our env
+var myarg not-defined || $Error # Just to make sure our env is sane to start with
+source $SCRIPT_PATH\tscriptargs.script abc123 || $Error
+var myarg not-defined || $Error
+
+# Now test that even if we define a var of the same name, we don't see the definition from the child script
+export myarg "Something that isn't abc123."
+source $SCRIPT_PATH\tscriptargs.script abc123 || $Error
+var myarg == "Something that isn't abc123." || $Error
+
+fshell tlotsofscriptargs abc123 123 0x123 $SCRIPT_PATHtlotsofscriptargs.script 3.141 enumsecondvalue || $Error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/fshell-unicode-test.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+#!fshell
+# fshell-unicode-test.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Note this file is UTF-8!
+
+# Assume fshell-basic-test is working and this Error definition doesn't need testing
+var KEEP_GOING not-defined && export Error 'fshell -e "echo ^"Test failed, env is:^" && env && error"'
+var KEEP_GOING defined && export Error 'error -39 "Test failure in $SCRIPT_NAME at line $SCRIPT_LINE"'
+
+export TEST_STRING "EAcute:^u00E9 Beta:^u03b2 Smiley:^u263a"
+echo -n EAcute:é Beta:β Smiley:☺ | export -s RESULT
+
+# Check symmetric properties - I don't imagine these will ever fail unless variable expansion is really broken
+var TEST_STRING == "$TEST_STRING" || $Error
+var RESULT == "$RESULT" || $Error
+
+var RESULT == "$TEST_STRING" || $Error
+# And vice-versa
+var TEST_STRING == "$RESULT" || $Error
+
+echo "$TEST_STRING" > unicodetest.txt # This will output in UTF-8
+
+cat --encoding ltk-utf-8 unicodetest.txt | export -s CATRESULT
+var CATRESULT == "$TEST_STRING^r^n" || $Error
+
+export -s REDIRRESULT < unicodetest.txt
+var REDIRRESULT == "$TEST_STRING^r^n" || $Error
+
+rm unicodetest.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/printerror.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+#!fshell
+# printerror.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Causes an error quietly on line 17 (for testing purposes)
+
+echo -n "" | export -s SOMETHING
+error -1 2> NUL
+
+echo -n "" # Just to mix things up
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/setenv.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,20 @@
+#!fshell
+# setenv.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Syntax: source setenv.script <variablename> [<value>]
+# Note: Have to use source to call this, otherwise the env changes will be lost!
+
+var ARG_COUNT != 1 && var ARG_COUNT != 2 && error -6 "Syntax: source setenv.script <variablename> [<value>]"
+
+var ARG_COUNT == 2 && export $1 "$2"
+var ARG_COUNT == 1 && export $1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/smoketest.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,20 @@
+#!fshell
+# smoketest.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# If everything passes, you shouldn't see anything outputted. If you see any errors, run the relevant script without the -k option to get more details
+
+fshell -k $SCRIPT_PATH\fshell-basic-test.script
+fshell -k $SCRIPT_PATH\fshell-last-test.script > /dev/null # One of the last tests prints garbage to stdout
+fshell -k $SCRIPT_PATH\fshell-ccommandbase-test.script
+fshell -k $SCRIPT_PATH\fshell-unicode-test.script
+fshell -k $SCRIPT_PATH\fshell-scriptcif-test.script
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tconsole.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,55 @@
+// tconsole.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32cons.h>
+
+void MainL()
+	{
+	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+	
+	CConsoleBase* console = Console::NewL(_L("tconsole"), TSize(KConsFullScreen, KConsFullScreen));
+	CleanupStack::PushL(console);
+
+	if (User::CommandLineLength() == 0)
+		{
+		console->Printf(_L("Output from direct fshell descendant\r\n"));
+		RProcess child;
+		User::LeaveIfError(child.Create(_L("tconsole.exe"), _L("child")));
+		TRequestStatus stat;
+		child.Logon(stat);
+		child.Resume();
+		User::WaitForRequest(stat);
+		child.Close();
+		}
+	else
+		{
+		console->Printf(_L("Output from tconsole once removed\r\n"));
+		// If iocons is doing its thing, these lines should both end up on the fshell console if "tconsole" is launched from fshell
+		}
+	CleanupStack::PopAndDestroy(2, scheduler);
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	TInt err = KErrNoMemory;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup)
+		{
+		TRAP(err, MainL());
+		delete cleanup;
+		}
+	__UHEAP_MARKEND;
+	return err;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tconsole.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+// tconsole.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+target			tconsole.exe
+targettype		exe
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			tconsole.cpp
+
+library			euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tenvarguments.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,44 @@
+# tenvarguments.cif
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+==name tenvarguments
+
+==short-description
+
+Test for command-line arguments that get filled in from the environment.
+
+==argument string stringarg STRINGARG
+
+String argument.
+
+==argument int intarg INTARG
+
+Int argument.
+
+==argument uint uintarg UINTARG
+
+Uint argument.
+
+==option bool b boolopt BOOLOPT
+
+Bool option.
+
+==option string s stringopt STRINGOPT
+
+String option.
+
+==option int i intopt INTOPT
+
+Int option.
+
+==option uint u uintopt UINTOPT
+
+Uint option.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tenvarguments.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,124 @@
+// tenvarguments.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdtenvarguments : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdtenvarguments();
+private:
+	CCmdtenvarguments();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	HBufC* iStringArg;
+	TInt iIntArg;
+	TUint iUintArg;
+	TBool iBoolOpt;
+	TInt iIntOpt;
+	TUint iUintOpt;
+	HBufC* iStringOpt;
+	};
+
+EXE_BOILER_PLATE(CCmdtenvarguments)
+
+CCommandBase* CCmdtenvarguments::NewLC()
+	{
+	CCmdtenvarguments* self = new(ELeave) CCmdtenvarguments();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdtenvarguments::~CCmdtenvarguments()
+	{
+	delete iStringArg;
+	delete iStringOpt;
+	}
+
+CCmdtenvarguments::CCmdtenvarguments()
+	{
+	}
+
+const TDesC& CCmdtenvarguments::Name() const
+	{
+#ifdef USE_CIF
+	_LIT(KName, "tenvarguments");
+#else
+	_LIT(KName, "tnoncifenvarguments");
+#endif
+	return KName;
+	}
+
+const TDesC& CCmdtenvarguments::Description() const
+	{
+#ifdef USE_CIF
+	return CCommandBase::Description();
+#else
+	_LIT(KDescription, "Test for command-line arguments that get filled in from the environment.");
+	return KDescription;
+#endif
+	}
+
+void CCmdtenvarguments::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+#ifdef USE_CIF
+	aArguments.AppendStringL(iStringArg, _L("stringarg"));
+	aArguments.AppendIntL(iIntArg, _L("intarg"));
+	aArguments.AppendUintL(iUintArg, _L("uintarg"));
+#else
+	aArguments.AppendStringL(iStringArg, _L("stringarg"), _L("String argument."), 0, _L("STRINGARG"));
+	aArguments.AppendIntL(iIntArg, _L("intarg"), _L("Int argument."), 0, _L("INTARG"));
+	aArguments.AppendUintL(iUintArg, _L("uintarg"), _L("Uint argument."), 0, _L("UINTARG"));
+#endif
+	}
+
+void CCmdtenvarguments::OptionsL(RCommandOptionList& aOptions)
+	{
+#ifdef USE_CIF
+	aOptions.AppendBoolL(iBoolOpt, _L("boolopt"));
+	aOptions.AppendIntL(iIntOpt, _L("intopt"));
+	aOptions.AppendUintL(iUintOpt, _L("uintopt"));
+	aOptions.AppendStringL(iStringOpt, _L("stringopt"));
+#else
+	aOptions.AppendBoolL(iBoolOpt, 'b', _L("boolopt"), _L("Bool option."), 0, _L("BOOLOPT"));
+	aOptions.AppendIntL(iIntOpt, 'i', _L("intopt"), _L("Int option."), 0, _L("INTOPT"));
+	aOptions.AppendUintL(iUintOpt, 'u', _L("uintopt"), _L("Uint option."), 0, _L("UINTOPT"));
+	aOptions.AppendStringL(iStringOpt, 's', _L("stringopt"), _L("String option."), 0, _L("STRINGOPT"));
+#endif
+	}
+
+#define CHECKINT(arg, val) if (arg != val) LeaveIfErr(KErrArgument, _L("%s is %d, expected %d"), L ## #arg , arg, (TInt)val)
+#define CHECKSTR(arg, val) if (!arg) LeaveIfErr(KErrArgument, _L("%s is null, should be %S"), L ## #arg, &val); else if (*arg != val) LeaveIfErr(KErrArgument, _L("%s is %S, expected %S"), L ## #arg , arg, &val)
+
+void CCmdtenvarguments::DoRunL()
+	{
+	_LIT(KStringArg, "StringArg");
+	_LIT(KStringOpt, "StringOpt");
+
+	CHECKINT(iIntArg, 1234);
+	CHECKINT(iUintArg, 0x1234);
+	CHECKSTR(iStringArg, KStringArg);
+	CHECKINT(iBoolOpt, 1);
+	CHECKINT(iIntOpt, 4321);
+	CHECKINT(iUintOpt, 0x4321);
+	CHECKSTR(iStringOpt, KStringOpt);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tenvarguments.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// tenvarguments.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			tenvarguments.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE 0
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+MACRO			USE_CIF
+sourcepath		.
+source			tenvarguments.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tfshellarguments.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,90 @@
+// tfshellarguments.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdTfshellArguments : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTfshellArguments();
+private:
+	CCmdTfshellArguments();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TUint64 iBigInt;
+	TReal iReal;
+	};
+
+EXE_BOILER_PLATE(CCmdTfshellArguments)
+
+CCommandBase* CCmdTfshellArguments::NewLC()
+	{
+	CCmdTfshellArguments* self = new(ELeave) CCmdTfshellArguments();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTfshellArguments::~CCmdTfshellArguments()
+	{
+	}
+
+CCmdTfshellArguments::CCmdTfshellArguments()
+	{
+	}
+
+const TDesC& CCmdTfshellArguments::Name() const
+	{
+	_LIT(KName, "tfshellarguments");	
+	return KName;
+	}
+
+const TDesC& CCmdTfshellArguments::Description() const
+	{
+	_LIT(KDescription, "Test different fshell argument types");
+	return KDescription;
+	}
+
+void CCmdTfshellArguments::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendUintL(iBigInt, _L("bigint"), _L("64-bit int type. Must be set to 2^40 (ie 1099511627776 or 0x10000000000)."));
+	aArguments.AppendRealL(iReal, _L("real"), _L("double-precision floating point type. Must be set to 3.1415927 or equivalent"));
+	}
+
+void CCmdTfshellArguments::OptionsL(RCommandOptionList& /*aOptions*/)
+	{
+	}
+
+void CCmdTfshellArguments::DoRunL()
+	{
+	const TUint64 KInt = 1099511627776ULL;
+	const TReal KReal = 3.1415927;
+
+	if (iBigInt != KInt)
+		{
+		LeaveIfErr(KErrArgument, _L("bigint %Ld doesn't equal %Ld"), iBigInt, KInt);
+		}
+	if (iReal < 3.14159265 || iReal > 3.14159275)
+		{
+		// Specify a range because it's floating point
+		LeaveIfErr(KErrArgument, _L("real %f doesn't equal %f"), iReal, KReal);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tfshellarguments.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// tfshellarguments.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			tfshellarguments.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE 0
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			tfshellarguments.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tinteger.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,83 @@
+// tinteger.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdTinteger : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTinteger();
+private:
+	CCmdTinteger();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TBool iDashOne;
+	TInt iArg;
+	TInt iDashThree;
+	};
+
+EXE_BOILER_PLATE(CCmdTinteger)
+
+CCommandBase* CCmdTinteger::NewLC()
+	{
+	CCmdTinteger* self = new(ELeave) CCmdTinteger();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTinteger::~CCmdTinteger()
+	{
+	}
+
+CCmdTinteger::CCmdTinteger()
+	{
+	}
+
+const TDesC& CCmdTinteger::Name() const
+	{
+	_LIT(KName, "tinteger");	
+	return KName;
+	}
+
+const TDesC& CCmdTinteger::Description() const
+	{
+	_LIT(KDescription, "Test of fshell's parsing of commands with negative integer arguments.");
+	return KDescription;
+	}
+
+void CCmdTinteger::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendIntL(iArg, _L("arg"), _L("test arg - this must be set to -2"));
+	}
+
+void CCmdTinteger::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iDashOne, '1', _L("ignore"), _L("test option - should be specified with -1"));
+	aOptions.AppendIntL(iDashThree, '3', _L("ignore2"), _L("test option - should be specified with -3 -4"));
+	}
+
+void CCmdTinteger::DoRunL()
+	{
+	if (!iDashOne) LeaveIfErr(KErrArgument, _L("-1 didn't get picked up"));
+	if (iArg != -2) LeaveIfErr(KErrArgument, _L("arg isn't -2"));
+	if (iDashThree != -4) LeaveIfErr(KErrArgument, _L("the dash3 option ('-3') isn't -4"));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tinteger.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// tinteger.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			fshell_tinteger.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE 0
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			tinteger.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tlast.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,73 @@
+// tlast.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdTlast : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTlast();
+private:
+	CCmdTlast();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	HBufC* iArg;
+	};
+
+EXE_BOILER_PLATE(CCmdTlast)
+
+CCommandBase* CCmdTlast::NewLC()
+	{
+	CCmdTlast* self = new(ELeave) CCmdTlast();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTlast::~CCmdTlast()
+	{
+	delete iArg;
+	}
+
+CCmdTlast::CCmdTlast()
+	{
+	}
+
+const TDesC& CCmdTlast::Name() const
+	{
+	_LIT(KName, "tlast");	
+	return KName;
+	}
+
+const TDesC& CCmdTlast::Description() const
+	{
+	_LIT(KDescription, "Test of fshell's parsing of commands with the 'last' attribute");
+	return KDescription;
+	}
+
+void CCmdTlast::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iArg, _L("arg"), _L("test arg"), KValueTypeFlagLast);
+	}
+
+void CCmdTlast::DoRunL()
+	{
+	Printf(_L("arg = %S\r\n"), iArg);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tlast.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// tlast.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			tlast.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE 0
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			tlast.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tlotsofscriptargs.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,63 @@
+#!fshell
+# tlotsofscriptargs.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+source $SCRIPT_PATH\errordef.script
+
+var myarg == "abc123" || $Error
+var myint == 123 || $Error
+var myuint == 291 || $Error
+var myfile == "$0" || $Error
+var myreal == "3.141" || $Error
+var myenum == enumsecondvalue || $Error
+
+exit # Like __END__ in perl this stops the fshell parser tripping over the CIF data
+
+==name tlotsofscriptargs
+
+==short-description
+
+An example of a script that uses CIF syntax.
+
+==argument string myarg
+
+An example argument. Fshell defines the environment variable $myarg based on what the first argument to the script is (ie $1). Must be set to "abc123".
+
+==argument int myint
+
+Must be 123.
+
+==argument uint myuint
+
+Must be 291 (0x123).
+
+==argument filename myfile
+
+Must equal $0.
+
+==argument real myreal
+
+Must be 3.141
+
+==argument enum myenum
+
+Must equal "enumsecondvalue".
+
+==enum-value enumfirstval
+
+==enum-value enumsecondvalue
+
+==enum-value enumthirdvalue
+
+==option bool o opt
+
+An option.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tnoncifenvarguments.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// tnoncifenvarguments.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			tnoncifenvarguments.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE 0
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			tenvarguments.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tsrc/tscriptargs.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+#!fshell
+# tscriptargs.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Syntax: as per the CIF definition below, tscriptargs <myarg> [<myoptionalarg>]
+
+source $SCRIPT_PATH\errordef.script
+
+var ARG_COUNT == 0 && $Error # Because myarg isn't optional we shouldn't even get this far if there's no options
+
+var myarg == "abc123" || $Error
+var EXPECTEDMYOPTIONALARG defined && var myoptionalarg == "$EXPECTEDMYOPTIONALARG" || $Error
+
+exit # Like __END__ in perl this stops the fshell parser tripping over the CIF data
+
+==name tscriptargs
+
+==short-description
+
+An example of a script that uses CIF syntax.
+
+==argument string myarg
+
+An example argument. Fshell defines the environment variable $myarg based on what the first argument to the script is (ie $1). Must be set to "abc123".
+
+==argument string myoptionalarg optional
+
+An optional argument. If specified must equal $MYEXPECTEDOPTIONALARG.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+documentation-style.css         \epoc32\build\fshell\documentation\documentation-style.css
+common_mmh.pod                  \epoc32\build\fshell\documentation\common_mmh.pod
+cif_syntax.pod                  \epoc32\build\fshell\documentation\cif_syntax.pod
+
+PRJ_MMPFILES
+gnumakefile fshell_builddocs.mk
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/change_history.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+# change_history.pod
+#
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 FShell Change History
+
+=head2 Release 000.1
+
+Prerelease to the SF staging server.
+
+=head1 Copyright
+
+Copyright (c) 2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/cif_syntax.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,220 @@
+# cif_syntax.pod
+#
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+=head1 Command Info Files
+
+I<This documentation is only useful for developers of fshell commands.>
+
+=head2 Introduction
+
+Command Info Files (CIFs) can be used to define the interface and documentation for fshell commands that are implemented using CCommandBase. Where previously details of arguments and options etc. were specified in C++ source code, the majority of this information can now be defined in a CIF, which is a plain text file. The format of CIFs is similar to POD (Perl's documentation source format), but with an additional set of key-words that relate to the specifics of command interfaces.
+
+CIF files for fshell commands live in F<\resource\cif\fshell> and should be named I<commandname>.cif where I<commandname> is the same as what is returned by the command's Name() function.
+
+=head2 Syntax
+
+=head3 ==name <commandname>
+
+The name of the command, without any prefix or suffix. Eg C<==name hello>. Mandatory.
+
+=head3 ==short-description
+
+A one-line summary of the functionality of the command. Mandatory. Eg:
+
+    ==short-description
+
+    Classic C<Hello World!> example.
+
+=head3 ==long-description
+
+A fuller description of the command can go here. Full POD syntax is supported, including lists and multiple paragraphs. The POD is terminated by the next CIF double-equals line, or the end of the file. Optional. For example:
+
+    ==long-description
+
+    Intended to be an example of a minimal command implementation. Simply prints C<Hello World!> to the console.
+
+=head3 ==argument <type> <name> [optional] [multiple | last] [<envvar-name>]
+
+One argument section is specified for each argument that the command accepts. C<type> is the type of the argument, one of the supported fshell types: int, int64, uint, uint64, string, filename, real, enum. See later for more details about the enum type. If a command doesn't take any arguments, then there will be no C<==argument> sections. Example:
+
+    ==argument int priority
+
+    The priority to set.
+
+    ==argument filename file optional multiple
+    
+    File or files to open. If not specified, opens an untitled document.
+
+The rules for the attributes are:
+
+=over 4
+
+=item *
+
+An argument with the C<optional> attribute cannot be followed by a non-optional argument.
+
+=item *
+
+Only the final argument is allowed to have the C<multiple> attribute set.
+
+=item *
+
+An argument with just the C<multiple> attribute can be specified one or more times, C<optional> means zero or one times. An argument may have both C<optional> and C<multiple> to indicate it can be specified zero or more times.
+
+=item *
+
+Only the final argument is allowed to have the C<last> attribute. It indicates that further arguments are allowed without needing to quote them and will be merged into this argument. C<last> may not be combined with C<multiple>. If a string provided for a C<last> argument naturally (i.e. as a result of normal string quote and escape handling) forms a single argument and consumes the whole of the remainder of the command line, the resulting single argument will be used as is. Otherwise, the string will be used without any quote or escape handling. Here are some example (using fshell's 'time' command, which takes a single argument that uses the C<last> attribute):
+
+      Input command-line            Argument receive by the 'time' command
+
+ 1)   time echo foo                 echo foo
+ 2)   time 'echo foo'               echo foo
+ 3)   time echo^ foo                echo foo
+ 4)   time echo foo && echo bar     echo foo          (note, fshell intercepts the '&&' and launches 'echo bar' separately).
+ 5)   time 'echo foo && echo bar'   echo foo && echo bar
+ 6)   time echo -h                  echo -h
+
+Note, the presence of C<last> in C<time>'s argument specification makes cases (1) and (6) possible. If C<last> were not used, case (1) C<CCommandBase> would have failed to parse the command-line (due to the presence of C<foo>) and in case (6) C<CCommandBase> would have treated the C<-h> as an argument to C<time> and printed its help (rather than C<echo>'s).
+
+=back
+
+If an environment variable name is specified using C<envvar-name>, then fshell will use it to attempt to fill in this argument's value, if it isn't specified on the command line. Any arguments that are "filled in" in this manner cannot cause any non-filled in arguments to be reordered. In other words you can't try to supply arguments 1 and 3 on the command line and have argument 2 filled in from the environment. If an argument isn't supplied on the command line, and isn't available from the environment, and isn't optional, then it is a syntax error.
+
+=head3 ==option <type> <shortname> <longname> [multiple | <envvar-name>]
+
+Each option that the command supports is specified by an C<==option> section. C<Type> is an fshell type, one of: bool, int, int64, uint, uint64, string, filename, real, enum. C<shortname> is the single letter used as the short option (eg C<-v> as a short option for C<--verbose>). If a command doesn't have any options, then there will be no C<==option> sections. Example:
+
+    ==option bool c color
+
+    Write C<Hello World!> in color.
+
+Some commands have configuration options which can also be specified by defining an environment variable. The environment variable can be specified on the end of the C<==option> line. For example an option which can also be specified by exporting $TAB_WIDTH would be defined as:
+
+    ==option int w tab-width TAB_WIDTH
+
+    Specify the tab width to use (defaults to 4 characters).
+
+=head3 ==include <ciffile>
+
+The C<==include> tag can be used to import information from another CIF file. This is useful for commands that inherit from other commands for which the base class documentation is still relevant. For example, ymodem.cif includes xmodem.cif, and just overrides the options and arguments (and description) that differs between the xmodem and ymodem protocols. Optional. Example:
+
+    ==include xmodem.cif
+
+CIF files are processed sequentially, therefore any includes should normally be specified at the top of the file, so that later sections can override the included ones.
+
+=head3 ==see-also
+
+Optional. If present, a section titled "See Also" is generated in the resulting documentation. For example:
+
+    ==see-also
+
+    L<ps|ps>, L<objinfo|objinfo>
+
+=head2 The enum type
+
+The C<enum> type can be used for an option or argument that takes a limited number of named values, in much the same was as C/C++ enums are used. For an option or argument of type C<enum> you must specify the possible values that the enum can take using the C<==enum-value> keyword. These may optionally have a separate description per value. If any value has an individual description, they all must.
+
+    ==argument enum object-type
+
+    The type of object to list.
+
+    ==enum-value process
+
+    ==enum-value thread
+
+    ==enum-value chunk
+
+Or for an option (which, in this case, has individual descriptions for each value):
+
+    ==option enum e encoding
+
+    Encoding to use. If not specified, defaults to 'auto'.
+
+    ==enum-value auto
+
+    Use charconv to try and figure out the encoding (slow and error-prone for anything other than UTF-16 with BOM).
+
+    ==enum-value binary
+
+    Read the files in binary mode and do not perform any character conversion.
+
+    ==enum-value utf-8
+
+    Assume the file is UTF-8 (with or without BOM).
+
+The order of the values in the CIF file must match how the enum is defined in the C++. Example usage:
+
+    class CMyCommand : public CCommandBase
+        {
+        ...
+        enum TOperation
+            {
+            ELoad,
+            EStore,
+            EDelete,
+            };
+        TOperation iOperation;
+        };
+    ...
+    void CMyCommand::ArgumentsL(RCommandArgumentList& aArguments)
+        {
+        aArguments.AppendEnum((TInt&)iOperation, _L("operation"));
+        }
+
+The CIF file would therefore contain:
+
+    ==argument enum operation optional
+
+    The operation to perform. If not specified, defaults to load.
+
+    ==enum-value load
+
+    ==enum-value store
+
+    ==enum-value delete
+
+Note how the C++ enum values C<ELoad, EStore, EDelete> are in the same order as the CIF declaration of C<load, store, delete>. The C++ enum must not specify any custom values, ie the enum must start from zero and be sequential.
+
+=head2 CIF types and CCommandBase types
+
+Each of the argument and option types mentioned here corresponds to a C++ type that is used in the command's implementation. In summary they are:
+
+    CIF type    CCommandBase type
+    --------    -----------------
+    bool        TBool
+    int         TInt
+    int64       TInt64
+    uint        TUint
+    uint64      TUint64
+    string      HBufC*
+    filename    IoUtils::TFileName2
+    real        TReal
+    enum        TInt (or more usually, some enum type)
+
+If the argument/option can take multiple values (by specifying C<multiple> in the CIF), the types are:
+
+    CIF type    CCommandBase type
+    --------    -----------------
+    bool        RArray<TBool>
+    int         RArray<TInt>
+    int64       RArray<TInt64>
+    uint        RArray<TUint>
+    uint64      RArray<TUint64>
+    string      RPointerArray<HBufC>
+    filename    RArray<IoUtils::TFileName2>
+    real        RArray<TReal>
+    enum        RArray<TInt>
+
+=head1 Copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/common_mmh.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,264 @@
+# common_mmh.pod
+#
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+=head1 common.mmh and platform.mmh Syntax
+
+The fshell build system uses a number of macros to control what should be built and how. These are defined in F<fshell/build/common/common.mmh> and F<fshell/platforms/E<lt>PLATFORME<gt>/platform.mmh>. Each platform defines the things it does and doesn't support in its platform.mmh. common.mmh takes these and defines some derived macros. This system allows fshell to be built in a large number of configurations, ranging from minimal base textshell on Symbian OS v9.1 to full GUI on the latest Symbian Foundation codeline.
+
+Any code wishing to use the fshell conditional system should C<< #include <fshell/common.mmh> >> and use the macros below and/or the ones defined in common.mmh to decide how to behave. Below follows the complete list of things that the platform.mmh can define. This isn't the complete list of all the macros that can be I<used>, for that see common.mmh directly. common.mmh can be included anywhere that the preprocessor is used - eg in source code, MMP files, RSS files or bld.infs.
+
+The macros that have a [NO_] in are assumed to be supported unless the [NO_] variant is defined. Eg in your MMP file you would check for btrace support with C<#ifdef FSHELL_BTRACE_SUPPORT> and to say a platform didn't support it you'd add C<#define FSHELL_NO_BTRACE_SUPPORT> to the platform.mmh. Unless the platform.mmh says otherwise, common.mmh would define C<FSHELL_BTRACE_SUPPORT>. Everything in fshell that uses btrace checks for C<FSHELL_SUPPORT_BTRACE> in either the bld.inf (in the case of a command that shouldn't be built at all if btrace isn't available) or in its MMP and/or source code (for a command that can still offer some functionality when btrace isn't available).
+
+=head2 Supported platform.mmh macros
+
+=over 4
+
+=item FSHELL_[NO_]BTRACE_SUPPORT
+
+BTrace (including timestamp2) supported in kernel.
+
+=item FSHELL_[NO_]PIPS_SUPPORT
+
+Pips runtime available.
+
+=item FSHELL_[NO_]PATCHABLE_CONSTANTS_SUPPORT
+
+Platform/toolchain supports patchdata. Everything since about Symbian OS v9.1 does therefore it is assumed to be supported by default.
+
+=item FSHELL_[NO_]DYNAMICDFC_SUPPORT
+
+Kern::DynamicDfcQCreate API is present. Also used to guard TDfc::RawAdd.
+
+=item FSHELL_REPLACE_ECONS
+
+buildrom macro (on platforms that support it) to say that iosrv should replace econs.DLL with its own implementation.
+
+=item FSHELL_PLATFORM_S60
+
+S60 platform (value of this is either 3 or 5, for 3rd edition or 5th edition, or > 5 for foundation). Various UI code uses this to decide whether to build or not.
+
+=item FSHELL_PLATFORM_FOUNDATION
+
+Symbian Foundation platform (value of this is n, where n is Symbian^n).
+
+=item FSHELL_PLATFORM_SYMTB
+
+Symbian Timebox release (value can be 92 or 101).
+
+=item FSHELL_9_1_SUPPORT
+
+Used to guard things that don't work in Symbian OS v9.1, that don't have their own macro. Its use is discouraged in any new code. Currently guards: switchview missing API; missing thread priorities; demand paging definitions; missing RFs API; kernel TFindHandle class.
+
+=item FSHELL_CAP_ALL
+
+All capabilities are available (platform.mmh must define either this macro or the specific C<FSHELL_CAP_xxx> that are supported)
+
+=item FSHELL_PROTECTED_UIDS
+
+Protected uids (0x10xxxxxx) should be used, as opposed to unprotected (0xE0xxxxxx), for exe and dll UID3. The UIDs themselves are all defined at the bottom of common.mmh so nothing else uses this macro directly. Unprotected UIDs should only be specified if the platform produces an unsigned sis file.
+
+=item FSHELL_BASE_ROM
+
+Configure IBYs for base 'rom' command rather than 'buildrom' style.
+
+=item FSHELL_[NO_]COMMS_SUPPORT
+
+ESock and C32 are available.
+
+=item FSHELL_[NO_]BLUETOOTH_SUPPORT
+
+Bluetooth is available. If C<FSHELL_COMMS_SUPPORT> isn't available, BT is assumed not to be, also.
+
+=item FSHELL_[NO_]TELEPHONY_SUPPORT
+
+Etel and SMS available.
+
+=item FSHELL_[NO_]APPARC_SUPPORT
+
+Apparc available.
+
+=item FSHELL_[NO_]EZLIB_SUPPORT
+
+Zip libraries available.
+
+=item FSHELL_[NO_]AUDIO_SUPPORT
+
+MMF/Devsound available.
+
+=item FSHELL_[NO_]WSERV_SUPPORT
+
+Graphical windowserver (either version) is present (as opposed to text windowserver).
+
+=item FSHELL_[NO_]WSERV2_SUPPORT
+
+Windowserver v2 is being used. Very few things need to know what windowserver version is in use, but occasionally it is needed.
+
+=item FSHELL_[NO_]RAMDEFRAG_SUPPORT
+
+RAM defrag (in form of TRamDefragRequest API) is supported.
+
+=item FSHELL_CORE_SUPPORT_LOCAL_ICON
+
+Create a launch icon for running fshell local.
+
+=item FSHELL_CORE_SUPPORT_TCP_ICON
+
+Create a launch icon for running fshell remotely via TCP/IP.
+
+=item FSHELL_CORE_SUPPORT_BT_ICON
+
+Create a launch icon for running fshell remotely via Bluetooth.
+
+=item FSHELL_CORE_SUPPORT_USB_ICON
+
+Create a launch icon for running fshell remotely via USB. The value of the macro is the port name to use (eg C<"ACM::1">).
+
+=item FSHELL_CORE_SUPPORT_SERIAL_ICON
+
+Create a launch icon for running fshell remotely via Serial. The value of the macro is the console-title arguments to use (eg C<"port=COMM::1,rate=115200">).
+
+=item FSHELL_CORE_SUPPORT_RCONS_ICON
+
+Create a launch icon for running fshell remotely via rcons.
+
+=item FSHELL_CORE_SUPPORT_LICENSE
+
+Build platform specific license support into fshell. Note, the platform must export F<\epoc32\build\fshell\core\generated\license.cpp> that provides the implementation of the interface defined in F<\fshell\core\src\license.h>.
+
+=item FSHELL_[NO_]SAMPLINGPROFILER_SUPPORT
+
+Samping profiler (profiler.h) is present. (foundation forgot to include it in S^2).
+
+=item FSHELL_CLOGGER_REPLACE_FLOGGER
+
+Put "FLOGGER_clogger_stub.DLL" into the ROM file as "flogger.dll". Probably won't work for SIS install.
+
+=item FSHELL_CLOGGER_REPLACE_CDU
+
+Put "COMSDBGUTIL_clogger_stub.DLL" into the ROM file as "comsdbgutil.dll". Probably won't work for SIS install.
+
+=item FSHELL_ROM_INCLUDE(ibyname)
+
+Optional function-like macro, can be defined to override default IBY export path. Only a few platforms need to override this.
+
+=item FSHELL_ROM_INCLUDE2(srciby,destiby)
+
+Optional function-like macro, can be defined to override default IBY export path. Only a few platforms need to override this.
+
+=item FSHELL_[NO_]COPYTOSHADOWMEMORY_SUPPORT
+
+The kernel supports Epoc::CopyToShadowMemory.
+
+=item FSHELL_[NO_]LBS_SUPPORT
+
+LBS libraries (Symbian or S60) are available.
+
+=item FSHELL_[NO_]SQL_SUPPORT
+
+SQLite libraries are available.
+
+=item FSHELL_[NO_]EGL_SUPPORT
+
+Embedded-system Graphics Library is available. If FSHELL_NO_WSERV_SUPPORT is defined, it is assumed EGL is not supported either.
+
+=item FSHELL_[NO_]OPENVG_SUPPORT
+
+Open Vector Graphics Library is available. If FSHELL_NO_WSERV_SUPPORT is defined, it is assumed OpenVG is not supported either.
+
+=item FSHELL_ARM11XX_SUPPORT
+
+Defined if the target platform is ARM11. Eg ARM1136 or ARM1176. Do NOT define for Cortex A8/A9. Only used by fdb.
+
+=item FSHELL_ARM_MEM_MAPPED_DEBUG
+
+Defined if the target platform supports ARM PRB. Should be defined for Cortex A8/A9. Only used by fdb.
+
+=item FSHELL_[NO_]DOBJECTIX_SUPPORT
+
+On newer baselines DObjectIx has been replaced. This macro is to (hopefully temporarily) guard code that assumes that DObjectIx is being used.
+
+=item FSHELL_[NO_]CRYPTO_SUPPORT
+
+Cryptographic libraries are available.
+
+=item FSHELL_[NO_]SHA2_SUPPORT
+
+SHA2 message digest implementation is available.
+
+=item FSHELL_[NO_]MD4_SUPPORT
+
+MD4 message digest implementation is available.
+
+=item FSHELL_FLEXIBLEMM_AWARE
+
+Indicates that the baseline is recent enough to be aware of the flexible memory model. It doesn't necessarily mean that the flexible model is actually the one being used. It generally guards kernel APIs that weren't introduced until the FMM was (such as Kern::ChunkUserBase).
+
+=item FSHELL_SPCRE_SUPPORT
+
+The regular expression libraries spcre.dll and libpcre.dll are available.
+
+=item FSHELL_DYNAMICSTARTUP_SUPPORT
+
+The Dynamic Startup Configuration (DSC) APIs such as RDscStore are available.
+
+=item FSHELL_MEMSPY_SUPPORT
+
+The MemSpy Engine APIs are available.
+
+=back
+
+A couple of further macros follow - these are specifically for platforms that provide an custom implementation of the relevant command rather than using fshell's built-in version.
+
+=over 4
+
+=item FSHELL_NO_SUPPORT_BUILTIN_REBOOT
+
+=item FSHELL_NO_SUPPORT_BUILTIN_VARIANT
+
+=back
+
+=head2 Example platform.mmh file
+
+An example platform.mmh is included below. This is for an imaginary platform based on the S^4 release, that is text-only but supports most other things. Generally the older and/or more restricted the platform is, the more C<FSHELL_NO_...> macros you have to define.
+
+	// platform.mmh for the imaginary Mythic platform
+
+	#ifndef FSHELL_PLATFORM_MMH
+	#define FSHELL_PLATFORM_MMH
+
+	// We support all Platsec capabilities
+	#define FSHELL_CAP_ALL
+	#define FSHELL_PROTECTED_UIDS
+
+	// We're based on S^4
+	#define FSHELL_PLATFORM_FOUNDATION 4
+
+	// We are Mythic v1
+	#define FSHELL_PLATFORM_MYTHIC 1
+
+	// We are text-only
+	#define FSHELL_NO_WSERV_SUPPORT
+
+	// We have a recent kernel that supports the flexible memory model
+	#define FSHELL_FLEXIBLEMM_AWARE
+	#define FSHELL_NO_DOBJECTIX_SUPPORT
+
+	// For the sake of argument, say we don't support Location Based Services but we do support regexes
+	#define FSHELL_NO_LBS_SUPPORT
+	#define FSHELL_SPCRE_SUPPORT
+
+	#endif // FSHELL_PLATFORM_MMH
+
+=head1 Copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/documentation-style.css	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+code
+	{
+	font-family: monospace;
+	background-color: #FFFDDF;
+	padding:1px;
+	border:1px solid #EEECCE;
+	}
+
+body
+	{
+	background-color: #FFFFFF;
+	font-family: verdana, sans-serif;
+	font-size: 12px;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/fshell_builddocs.mk	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+# fshell_builddocs.mk
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+MAKMAKE :
+	..\tools\fsh-builddocs -i ../../epoc32/include pod-list.txt
+
+RELEASABLES :
+	..\tools\fsh-builddocs -i ../../epoc32/include pod-list.txt -w
+
+CLEAN :
+	..\tools\fsh-builddocs -i ../../epoc32/include pod-list.txt -c
+
+MAKMAKE BLD FREEZE LIB CLEANLIB RESOURCE SAVESPACE FINAL : 
Binary file documentation/fshell_overview.pptx has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/getting_started.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,260 @@
+#!perl
+# getting_started.pod
+#
+# Copyright (c) 2008-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+
+__END__
+
+=head1 Retreiving the FShell Source Code
+
+I<Todo - add instructions for accessing the Mercurial repository.>
+
+=head1 Building FShell
+
+FShell is normally distributed in source code form, and so needs to be compiled before it can be used. The conventional Symbian build tools -- either SBSv1 (aka abld) or SBSv2 (aka Raptor) -- are used. Currently three Symbian OS based platforms are supported:
+
+=over 5
+
+=item * Symbian Foundation (S^2 and S^3)
+
+=item * Nokia S60 (3.x and 5.x)
+
+=item * Nokia Symbian Timebox 9.2
+
+=back
+
+Each of these platforms have a separate directory with F<\fshell\build>. In some platforms there may be further separate sub-directories for specific variants of the platform. You need to identify a suitable directory (that contains a file named F<bld.inf>) from which to build from. Open a command prompt and C<cd> to this directory.
+
+You also need to identify the type of binaries you want to build. Common ones are:
+
+=over 5
+
+=item * C<winscw>
+
+Used for running fshell on the WINSCW emulator. Requires an installation of the CodeWarrior Win32 compiler.
+
+=item * C<armv5>
+
+Used for running fshell on either physical or simulated ARM hardware. Requires an installation of ARM's RVCT compiler. Version 2.2 is commonly used on current Symbian based handsets.
+
+=item * C<gcce>
+
+Used for running fshell on either physical or simulated ARM hardware. Requires an installation of the GCC-E. I<Todo - does the SF provide builds of GCC-E?>
+
+=back
+
+Lastly, you need to identify the build variant you plan to use, either debug (C<udeb>) or release (C<urel>). Commonly, C<udeb> is used on the emulator whereas C<urel> is used on target hardward. For the purposes of this introduction we will assume that you will be building C<winscw udeb> and C<armv5 urel>.
+
+=head2 SBSv1 (aka abld)
+
+  M:\fshell\build\s60\3>bldmake bldfiles
+  M:\fshell\build\s60\3>abld build winscw udeb
+  M:\fshell\build\s60\3>abld build armv5 urel
+
+=head2 SBSv2 (aka Raptor)
+
+  M:\fshell\build\sf\2>sbs -c armv5_urel -c winscw_udeb
+
+=head1 Installation
+
+Having performed a build, you should have a full set of binaries in your F<\epoc32> tree. If you want to run fshell on the emulator, no further action is necessary. If you want to run fshell on the simulator or target hardware, then the fshell binaries need to be either added to a ROM image or installed at runtime.
+
+=head2 Adding FShell to a ROM Image
+
+This is probably the easiest approach, assuming you have a means of reprogramming the ROM of the hardware you plan to use. By putting fshell in the ROM, the complexities of platform security are normally avoided.
+
+Detailed instructions for building a ROM image for your hardware are outside of the scope of this document, however adding fshell fundamentally boils down to adding F<\epoc32\rom\include\fshell.iby> to your ROMBUILD scripts. Often the easiest way to do this is to add the following line to your main F<.oby> file:
+
+  #include <fshell.iby>
+
+Alternatively, depending on how you're building the ROM you can specify additional F<.oby> or F<.iby> files as command line arguments. For example:
+
+=over 5
+
+=item * buildrom
+
+  buildrom techview fshell.iby
+
+=item * imaker
+
+  imaker default BLDROBY="\epoc32\rom\include\fshell.iby"
+
+=back
+
+=head2 Installing fshell at Runtime
+
+Another product of the fshell build is F<\epoc32\fshell\fshell.unsigned.sis>. This is a Symbian OS install file that contains precisely the same set of files that F<fshell.iby> refers to. There are however some additional hurdles that need to be negotiated in order to be able to install the SIS file.
+
+=over 5
+
+=item 1
+
+Most production handset will not allow unsigned SIS files to be installed. The SIS file that the fshell build process produced must therefore be signed first. The Symbian Foundation provide a tool called F<signsis.exe> to perform the signing, however you need to get hold of a suitable certificate to sign with. Refer to http://www.symbiansigned.com/ for more details. Building on some platforms may automatically generate a signed SIS file F<\epoc32\fshell\fshell.sis> if there is a standard certificate for the platform.
+
+=item 2
+
+By default the fshell build produces binaries that use B<all> security capabilities (including C<TCB>). When they are installed at ROM build time, this isn't a problem. However, SIS files are generally restricted in the set of security capabilities that they can be signed for. To cater for this, you will need to restrict the fshell build to the set of capabilities that you are able to sign for. This is done by editing your platform's F<platform.mmh> (or in the case of platforms that support multiple variants, F<platform_(generic|shared).mmh>). You'll need to replace the following line:
+
+  #define FSHELL_CAP_ALL
+
+The file F<\fshell\build\common\common.mmh> contains definitions of the complete set of platform security macros that the fshell build system supports. For example, suppose you have access to all the user capabilities, your would replace the above line with:
+
+  #define FSHELL_CAP_MMP_MAX localservices location networkservices readuserdata userenvironment writeuserdata
+
+  #define FSHELL_CAP_LOCALSERVICES
+  #define FSHELL_CAP_LOCATION
+  #define FSHELL_CAP_NETWORKSERVICES
+  #define FSHELL_CAP_READUSERDATA
+  #define FSHELL_CAP_USERENVIRONMENT
+  #define FSHELL_CAP_WRITEUSERDATA
+
+The macro C<FSHELL_CAP_MMP_MAX> should be set to all the capabilities that you have access to. There is another macro C<FSHELL_CAP_MMP_NORMAL> which is what most DLLs and EXEs in fshell actually use. The difference is only important if you can sign for all capabilities (ie C<FSHELL_CAP_MMP_MAX> is C<All>) - in this case C<FSHELL_CAP_MMP_NORMAL> is set to C<All -TCB> to make sure you can link against normal DLLs.
+
+The act of defining the above macros may cause certain fshell binaries not to be built (for example, if the bianry can't do anything useful unless a particular capability is available). However, F<fshell.iby> and F<fshell.unsigned.sis> should automatically accommodate for the missing binaries without any further action on your part. If they don't, please contact the maintainers of fshell because that's probably a bug!
+
+=item 2
+
+Depending on the configuration of the target handset's certificate store and the key you are signing with, you may also need to use UIDs from the non-protected range. By default the fshell builds with UIDs from the protected range. To change this, remove the definition of C<FSHELL_PROTECTED_UIDS> from your platform's F<platform.mmh>. Note however, that currently the fshell's non-protected UIDs are not properly allocated UIDs. Rather they are the protected UID values but with the top nibble changed from 0x1 to 0xE. It is therefore possible (albeit pretty unlikely) that they could clash with UIDs used in other software.
+
+=back
+
+If you needed to change your F<platform.mmh> to satisfy platform security requirements, you'll need to perform a re-build of the source. It's advisable to run C<abld reallyclean> (or C<sbs reallyclean>) before doing this to ensure that everything is fully re-built.
+
+Having built and signed a SIS file, it can be installed by copying it to a memory card and inserting this in the target hardware. Details of how to do this for your particular hardware are outside of the scope of this document, but normally there's a File Manager type application that can be used to launch the SIS file. Alternatively, some handsets provide a PC Connectivity Suite that can be used to install SIS files from your PC.
+
+=head2 Running FShell
+
+Once fshell has been installed, the following icons should appear in the menu application*:
+
+* Note, the folder in which the icons can be found varies between hardware and software platforms. For S60, try looking in "Installations", "Installed", "Applications" or "Applications->My Own".
+
+=over 5
+
+=item * fshell
+
+This icon will launch an L<fshell|fshell> instance using the default console. Where supported, this will be fshell's own GuiCons console, but on platforms where this isn't supported it will fall back to the Symbian Foundation F<econs> or F<econseik> consoles (see L<consoles|plugins::consoles> for a discussion of the various consoles that fshell supports). This puts up a full-screen window and allows text input via whatever keyboard the handset has. It is certainly the easiest console to get going with, but (depending on the handset you're using) entering text can be fairly tiresome.
+
+=item * fshell (USB)
+
+This icon will launch an L<fshell|fshell> instance that is connected to a remote terminal (e.g. HyperTerminal) via USB. The following steps must be taken before using this launch method:
+
+=over 5
+
+=item 1
+
+Install the PC Suite USB drivers applicable for your device.
+
+=item 2
+
+Connect your handset to your PC via USB.
+
+=item 3
+
+On your handset, if a dialog appears asking what USB service to use, select "PC Suite". You may have to change the USB settings in the control panel if you don't see this dialog.
+
+=item 4
+
+On your PC determine the name of the virtual serial port associated with your device. This can be done by right clicking on "My Computer", selecting "Manage". Then select "Device Manager" and expand the category "Ports (COM & LPT)". You should see one of the ports labelled something like "Nokia N96 USB". Make a note of the name that follow this in brackets (e.g. "(COM7)").
+
+=item 5
+
+On your PC, open a terminal emulator (such as TeraTerm or HyperTerminal). Instruct this application to open the serial port you identified in the previous step. Set the bits per second to 115200, data bits to "8", parity to "None", stop bits to "1" and flow control to "None". HyperTerminal has many restrictions, so we generally recommend TeraTerm Pro 4.6, available from http://ttssh2.sourceforge.jp/ .
+
+=item 6
+
+Connect your terminal emulator to the port identified in step 4.
+
+=item 7
+
+On your handset, tap "fshell (USB)". You should see a command prompt appear in your terminal emulator. If you don't you may need to reboot both your PC and your handset.
+
+=back
+
+After you have finished using the command prompt, the 'polite' way to disconnect your handset is as follows. Generally if you're using recent software you can get away with just closing the terminal emulator and/or unplugging the cable (in either order). Less tolerant USB drivers may require you to take care to follow the instructions below:
+
+=over 5
+
+=item 1
+
+Type "exit" to exit from fshell.
+
+=item 2
+
+Disconnect your terminal emulator from the serial port.
+
+=item 3
+
+Remove your USB cable.
+
+=back
+
+To reconnect, repeat steps 6 and 7 above. (Reconnecting the USB cable and choosing the usb service, if necessary.)
+
+=item * fshell (BT)
+
+This icon will launch an L<fshell|fshell> instance using the Bluetooth variant of L<vt100cons|vt100cons>. Assuming your PC is paired with the handset, after launching this icon it should be possible to establish a serial connection from your PC to the handset. Once that has been done, HyperTerminal (or some other VT100 compatible terminal emulator) can be pointed at the PC side virtual serial port, and an fshell prompt should appear.
+
+=item * fshell (TCP)
+
+This icon will launch an L<fshell|fshell> instance using the TCP variant of L<vt100cons|vt100cons> in passive mode. This means that the handset will listen for an incoming TCP connection on a particular port. After you launch the icon, you will first have to select the bearer for the TCP/IP session. Assuming it is available on your handset, WLAN is probably the best choice of bearer. Once the WLAN connection has been established, a console window should appear stating the IP address and port that is being listened on. Your PC will need to be connected to the same network. Open HyperTerminal (assuming you're using Windows) and connect using "TCP/IP (Winsock)" mode, specifying the IP and port displayed on the handset. An fshell prompt should appear in HyperTerminal.
+
+If you're using hardware that doesn't support WLAN, then all is still not lost. It is possible to establish a remote console session using a packet context. However, the hoops you have to jump through to achieve this are rather tighter than any of the other methods described. There are two main problems that have to be overcome. Firstly, most PCs don't have a public IP address, and so cannot be connected to directly. Secondly, most packet context connection don't have a public IP address, and so the same applies. The latter issue can be handled by using F<vt100tcpcons> in active mode (i.e. where it actively connects to a particular host). The first issue can be handled using an SSH tunnel. However, its not possible to configure an SSH tunnel that listens on both ends - one end must listen (i.e. be passive) and the other connect (i.e. be active). Because we need the end that F<vt100tcpcons> will be connecting to to listen, we need to provide something for the other end to connect to. This can't be HyperTerminal, because that only supports active connection. So instead we use C<com2tcp> (see http://com0com.sourceforge.net/) to listen on a particular port and then present this as a virtual serial port that HyperTerminal can connect to. In a more visual form, we end up with:
+
+  |   Handset        |       SSH Server     |                               PC                                 |
+
+  vt100tcpcons.dll  <-->  SSH tunnel end  <-->  SSH tunnel end  <-->  com2tcp  <--> com0com  <-->  HyperTerminal
+
+All this can be achieved with the following steps:
+
+=over 5
+
+=item *
+
+Install C<com0com>, C<com2tcp> and an SSH client (the example below uses OpenSSH provided by Cygwin).
+
+=item *
+
+Establish an SSH tunnel between your PC and an SSH server that has a public IP address:
+
+  ssh <username>@<ssh_server> -R <ssh_server_IP>:8080:localhost:8080
+
+Note, C<ssh_server_IP> is the public IP address of the SSH server. This is necessary ensure that the tunnel listens on the public IP rather than the loopback interface. If you're using OpenSSH, make sure that C<AllowTcpForwarding> is set to C<yes> on the server.
+
+=item *
+
+Configure C<com2tcp> to listen on port 8080 of the PC's loopback interface:
+
+  com2tcp \\.\<com0com_port_name> 8080
+
+Note, C<com0com_port_name> is the name of one port of a virtual serial port pair provided by C<com0com>. You can create a suitable virtual serial port pair using "Start | Programs | com0com | Setup". Be sure to work your way through "New hardware detected dialogs" as the pop up (rather than simply dismissing them), because if you don't the ports won't be visible to Windows software. No actual driver file should be necessary.
+
+=item *
+
+Open HyperTerminal and point it at the other port of the virtual serial port pair provided by C<com0com>.
+
+=item *
+
+Configure F<vt100tcpcons> to use an outgoing TCP connection by running the following at an fshell prompt (you may need a "local" fshell prompt for this):
+
+  fshell --console vt100tcpcons --console-title host=<ssh_server>,port=8080
+
+=back
+
+If all has gone well, you should see an fshell prompt in HyperTerminal.
+
+=back
+
+=head1 Copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/index.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,15 @@
+=head1 FShell Documentation
+
+L<Introduction|fshell::commands::fshell/Introduction> - an introduction to fshell.
+
+L<Getting started|getting_started> - a guide to getting fshell up and running on various different platforms.
+
+L<Change History|fshell::change_history>
+
+L<Core FShell functionality|core>
+
+L<FShell Commands|commands> - an A to Z of all the commands that fshell supports.
+
+L<Plug-ins|plugins>
+
+L<Developer documentation|internal> - documentation for developers wishing to extend fshell or write new commands.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/pod-list.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+#include <fshell/common.mmh>
+
+doc-root    \epoc32\documentation
+temp-root   \epoc32\build\documentation
+css         documentation-style.css
+
+pod .\index.pod                                                    fshell\index.html
+pod .\change_history.pod                                           fshell\change_history.html
+pod .\getting_started.pod                                          fshell\getting_started.html
+
+index fshell\core ..\core\docs\index.pod
+pod ..\core\docs\console_options.pod                               fshell\core\console_options.html
+pod ..\core\docs\persistent_consoles.pod                           fshell\core\persistent_consoles.html
+
+index fshell\internal
+pod ..\documentation\common_mmh.pod                                fshell\internal\common_mmh.html
+pod ..\documentation\cif_syntax.pod                                fshell\internal\cif_syntax.html
+pod ..\documentation\writing_fshell_commands.pod                   fshell\internal\writing_fshell_commands.html
+
+index fshell\internal\libraries
+pod ..\libraries\clogger\docs\clogger.pod                          fshell\internal\libraries\clogger.html
+
+index fshell\plugins
+pod ..\plugins\consoles\docs\consoles.pod                          fshell\plugins\consoles.html
+pod ..\plugins\consoles\guicons\doc\guicons_todo.pod               fshell\plugins\consoles\guicons_todo.html
+pod ..\plugins\consoles\rcons\documentation\rcons.dll.pod          fshell\plugins\consoles\rcons.dll.html
+pod ..\plugins\consoles\rcons\documentation\rcons.exe.pod          fshell\plugins\consoles\rcons.exe.html
+pod ..\plugins\consoles\rcons\documentation\rcons.pod              fshell\plugins\consoles\rcons.html
+pod ..\plugins\consoles\vt100cons\doc\vt100cons.pod                fshell\plugins\consoles\vt100cons.html
+
+index fshell\plugins\networking
+pod ..\plugins\networking\tcpcsy\doc\tcpcsy.pod                    fshell\plugins\networking\tcpcsy.html
+pod ..\plugins\networking\winsockprt\docs\winsockprt.pod           fshell\plugins\networking\winsockprt.html
+
+cif \epoc32\data\z\resource\cif\fshell fshell\commands  ..\core\docs\commands.index
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/documentation/writing_fshell_commands.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,178 @@
+#!perl
+# writing_fshell_commands.pod
+#
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 Writing fshell commands
+
+A quick guide to adding a new fshell command, covering the fshell build and configuration system, the internals of commands themselves and some background on the relevant concepts.
+
+=head1 Before you start
+
+=head2 Step 1: RTM!
+
+The first step is to make sure there isn't already a command that does what you need. It may seem obvious but there are quite a lot of commands and some have a lot of options and different functionality. Skim through the L<command list|fshell::commands> to be certain. For example you might note there's no 'bluetooth' command in fshell - however a check of the L<command list|fshell::commands> will reveal the L<btservices|fshell::commands::btservices> command which supports a number of Bluetooth-related operations.
+
+=head2 Check the todo list
+
+Check the todo list (I<TODO: figure out where the todo list is going to live!>). Someone else may have similar ideas or already be working on similar functionality.
+
+=head2 Decide whether you want to add it to fshell
+
+You're free to write whatever tools you like that use fshell and build on top of it. We (Accenture) have a number of specialised tools that use fshell but aren't part of the fshell package itself. You may however wish to contribute back to the fshell package; if so there are some additional constraints regarding where to put the source and the fshell build and configuration system (in addition to the Foundation Contribution guidelines http://developer.symbian.org/wiki/index.php/Contribution_Process ). You can ignore a lot of the below if you don't plan to add your command to the fshell package.
+
+=head1 Getting stuck in
+
+Once you've decided there isn't a suitable existing command, and no-one else is developing one, it's time to get started. Let's assume your new fshell command will be called C<qotd> and displays an insightful Quote Of The Day each time you run it. We're also assuming that you plan to integrate the command into the fshell package, thus will create the source code in the fshell\commands\qotd directory. (Please note we have no plans to actually add a qotd command - attributing the quotes and copyright is far too much like hard work!)
+
+If you are not contributing the command to the fshell package please put the source outside of the fshell tree.
+
+=head2 Built-in vs external
+
+(aka 'thread' vs 'process')
+
+There are two types of fshell command: ones built into fshell.exe itself (such as cd, export, source, etc) and ones that are implemented as standalone exes (such as listapps.exe, drvinfo.exe and so forth). Built-in commands are restricted as to what APIs they can use (so as to not introduce problematic dependancies), so we generally recommend that new commands are external ones that run in a separate process. Contact the fshell maintainers if you think you've a candidate for a new built-in command.
+
+Each external command lives in a separate directory \fshell\commands\<commandname>. Built in commands live in the \fshell\core tree.
+
+=head2 Using C<createsrc> to generate the boilerplate
+
+The createsrc command (installed in \epoc32\tools) is a great way to automate creating the skeleton of a new command. Run it with no arguments to be prompted for every option, for brevity the example below shortcuts it slightly and assumes you've already created the directory F<fshell\commands\qotd>. It also overrides the default copyright message, since you presumably won't want to assign copyright to Accenture!
+
+    M:\fshell\commands\qotd>
+    M:\fshell\commands\qotd>createsrc fshellcmd qotd -DCOPYRIGHT="Copyright (c) 2010 N. Seagoon. All Rights Reserved."
+    Enter short description of the command (for the .cif file) for qotd: Displays a randomly selected quote of the day.
+    M:\fshell\commands\qotd>
+    M:\fshell\commands\qotd>dir /B
+    bld.inf
+    qotd.cif
+    qotd.cpp
+    qotd.mmp
+
+At this point you have an fshell command that will compile and run - although it won't do very much yet.
+
+The C<.cif> file contains meta-data about the command - its description and what arguments and options it accepts. See L<here|cif_syntax> for more information on the CIF file format. The C<bld.inf> and C<.mmp> are the standard Symbian OS build files. The C<.cpp> is a minimalist implementation of your command, based on the information you passed to createsrc.
+
+=head2 CCommandBase
+
+As you'll see, the C<.cpp> file declares a single class CCmdQotd, which derives from C<IoUtils::CCommandBase> and implements a few derived functions. CCommandBase is the base class for all fshell commands. When your command is executed, fshell converts the command line arguments into member variables of your CCommandBase subclass and calls DoRunL(). (It figures out how to do this from the CIF file and the result of calling the OptionsL() and ArgumentsL() functions). The implementation of your command goes in DoRunL(). For now we will implement a very simple DoRunL that just prints a single string and exits:
+
+    void CCmdQotd::DoRunL()
+        {
+        Printf(_L("Quote goes here!\r\n"));
+        }
+
+If you build your command now, you'll see it in action:
+
+    M:\fshell\commands\qotd>sbs -c winscw_udeb
+    ...
+    M:\fshell\commands\qotd>fshell
+    ...
+    c:\>qotd
+    Quote goes here!
+    c:\>exit
+    M:\fshell\commands\qotd>
+
+Note how we've used the fshell bat file to start the winscw emulator inside the DOS command prompt. There's a lot of stuff going on behind the scenes to make this work, but it's a convenient way of testing commands. Normally you'd build the fshell tree (or any part of it) from one of the \fshell\build directories, and you wouldn't use the bld.inf that createsrc generated. I've skipped that for the moment for simplicity's sake.
+
+=head2 Adding options and arguments
+
+Fshell takes care of parsing command lines in a consistant manner, but you have to let it know what your command supports. Let's say that you want to give qotd a C<--shouty> option which, if specified, prints the quote in upper case. Since all options in fshell commands have a long form and a single-letter abbreviation, we'll choose C<-s>. Firstly we need to add a C<==option> section to the CIF file:
+
+    ==option bool s shouty
+
+    Displays the quote in UPPER CASE.
+
+Now we need to update the C++ code. Firstly, to add a TBool to CCmdQotd for fshell to fill in:
+
+     class CCmdQotd : public CCommandBase
+        {
+    ...
+     private:
+    -//TODO: arguments/options
+    +   TBool iShouty;    
+        };
+
+Then we need to associate the --shouty option with the iShouty member variable:
+
+    void CCmdQotd::OptionsL(RCommandOptionList& aOptions)
+        {
+        aOptions.AppendBoolL(iShouty, _L("shouty"));
+        }
+
+If you rebuild and run the help now, you'll see that the option is all configured:
+
+    c:\>qotd --help
+    SYNTAX
+
+        qotd [options]
+
+    OPTIONS
+
+         -s (--shouty)  Displays the quote in UPPER CASE.
+         -h (--help)    Display help.
+
+    DESCRIPTION
+
+    Displays a randomly selected quote of the day.
+
+    COPYRIGHT
+
+    Copyright (c) 2010 N. Seagoon. All Rights Reserved.
+
+    c:\>
+
+All that remains is to actually do something when --shouty is specified:
+
+    void CCmdQotd::DoRunL()
+        {
+        if (iShouty)
+            {
+            Printf(_L("QUOTE GOES HERE!\r\n"));
+            }
+        else
+            {
+            Printf(_L("Quote goes here!\r\n"));
+            }
+        }
+
+After rebuilding, you should be able to do:
+
+    c:\>qotd
+    Quote goes here!
+    c:\>
+    c:\>qotd --shouty
+    QUOTE GOES HERE!
+    c:\>
+    c:\>qotd -s
+    QUOTE GOES HERE!
+    c:\>
+
+Adding other types of option/argument is done in a similar way, see L<here|cif_syntax/CIF types and CCommandBase types> for the list of CIF types and their equivalent C++ types. The one thing to be aware of is that you are responsible for deleting any string or array arguments in the command's destructor, even though the fshell framework created them. This is mainly for legacy compatability reasons, it should probably be done automatically in ~CCommandBase().
+
+=head2 Integrating with fshell's build system
+
+I<If you're not writing a command that's going to be integrated into the fshell source tree, you can mostly ignore this section.>
+
+To make sure your new command gets built, add the mmp and any exports (eg the CIF) to \fshell\commands\group\bld.inf:
+
+    PRJ_EXPORTS
+    ..\qotd\qotd.cif            z:\resource\cif\fshell\qotd.cif
+    PRJ_MMPFILES
+    ..\qotd\qotd.mmp
+
+The fshell build system makes heavy use of preprocessor conditionals to make sure that the codebase builds on a wide variety of platforms. In this example qotd doesn't have any depenancies so the files can be added unconditionally to the bld.inf. If however you take the USB command as an example, you'll see that in the bld.inf it is surrounded by C<#ifdef FSHELL_CORE_SUPPORT_USB>. This in turn is defined in L<common.mmh|common_mmh> only if C<FSHELL_COMMS_SUPPORT> is available. In other words the USB command relies on comms support being available in the platform that's being build. (You may thing that's overkill but early baseport bringup regularly needs to build minimalist textshell ROMs without any form of comms support other than maybe a uart - this level of configurability means it's possible to include fshell on there too.)
+
+If your command can take advantage of a feature, but doesn't absolutely require it, you may wish to guard only sections of code with an appropriate C<FSHELL_xyz> macro. common.mmh can be included anywhere the preprocessor is used (source files, bld.inf, MMPs, resource files) so you can be as fine-grained as you like. For example fshell itself uses many C<#ifdef FSHELL_MEMORYACCESS_SUPPORT> blocks so that ps can give more detailed process listings if MemoryAccess is available, but falls back gracefully to less detailed info if it isn't.
+
+B<I<To be completed...>>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/BMARM/btrace_parserU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,155 @@
+EXPORTS
+	__ne__C16TBtraceTickCountRC16TBtraceTickCount @ 1 NONAME R3UNUSED ; TBtraceTickCount::operator!=(TBtraceTickCount const &) const
+	AddObserverL__13CBtraceReaderR15MBtraceObserver @ 2 NONAME R3UNUSED ; CBtraceReader::AddObserverL(MBtraceObserver &)
+	AddObserverL__13CBtraceReaderR15MBtraceObserverQ213CBtraceReader13TObserverType @ 3 NONAME R3UNUSED ; CBtraceReader::AddObserverL(MBtraceObserver &, CBtraceReader::TObserverType)
+	AddObserverL__13CBtraceReaderUiR15MBtraceObserver @ 4 NONAME R3UNUSED ; CBtraceReader::AddObserverL(unsigned int, MBtraceObserver &)
+	AddObserverL__13CBtraceReaderUiR15MBtraceObserverQ213CBtraceReader13TObserverType @ 5 NONAME ; CBtraceReader::AddObserverL(unsigned int, MBtraceObserver &, CBtraceReader::TObserverType)
+	CancelNotifyAppResponse__18CBtraceAppResponseR26MBtraceAppResponseObserver @ 6 NONAME R3UNUSED ; CBtraceAppResponse::CancelNotifyAppResponse(MBtraceAppResponseObserver &)
+	CancelNotifyDomainEvent__18CBtraceDomainEventR26MBtraceDomainEventObserver @ 7 NONAME R3UNUSED ; CBtraceDomainEvent::CancelNotifyDomainEvent(MBtraceDomainEventObserver &)
+	CancelNotifyFocusChanged__18CBtraceFocusChangeR26MBtraceFocusChangeObserver @ 8 NONAME R3UNUSED ; CBtraceFocusChange::CancelNotifyFocusChanged(MBtraceFocusChangeObserver &)
+	CancelNotifyKeyEvent__15CBtraceKeyPressR23MBtraceKeyPressObserver @ 9 NONAME R3UNUSED ; CBtraceKeyPress::CancelNotifyKeyEvent(MBtraceKeyPressObserver &)
+	CancelNotifyPointerEvent__15CBtraceKeyPressR23MBtraceKeyPressObserver @ 10 NONAME R3UNUSED ; CBtraceKeyPress::CancelNotifyPointerEvent(MBtraceKeyPressObserver &)
+	CancelNotifyPropertyChanged__13CBtracePubSubR21MBtracePubSubObserver @ 11 NONAME R3UNUSED ; CBtracePubSub::CancelNotifyPropertyChanged(MBtracePubSubObserver &)
+	CancelNotifyRawKeyEvent__15CBtraceKeyPressR23MBtraceKeyPressObserver @ 12 NONAME R3UNUSED ; CBtraceKeyPress::CancelNotifyRawKeyEvent(MBtraceKeyPressObserver &)
+	CancelNotifyScreenUpdate__19CBtraceScreenUpdateR27MBtraceScreenUpdateObserver @ 13 NONAME R3UNUSED ; CBtraceScreenUpdate::CancelNotifyScreenUpdate(MBtraceScreenUpdateObserver &)
+	CancelNotifyTextOnScreen__19CBtraceTextOnScreenR27MBtraceTextOnScreenObserver @ 14 NONAME R3UNUSED ; CBtraceTextOnScreen::CancelNotifyTextOnScreen(MBtraceTextOnScreenObserver &)
+	CancelNotifyThreadExit__14CBtraceContextR22MBtraceContextObserver @ 15 NONAME R3UNUSED ; CBtraceContext::CancelNotifyThreadExit(MBtraceContextObserver &)
+	CancelNotifyThreadGone__14CBtraceContextR22MBtraceContextObserver @ 16 NONAME R3UNUSED ; CBtraceContext::CancelNotifyThreadGone(MBtraceContextObserver &)
+	CancelNotifyThreadIdle__15CBtraceCpuUsageR23MBtraceCpuUsageObserver @ 17 NONAME R3UNUSED ; CBtraceCpuUsage::CancelNotifyThreadIdle(MBtraceCpuUsageObserver &)
+	CancelNotifyThreadSeen__14CBtraceContextR22MBtraceContextObserver @ 18 NONAME R3UNUSED ; CBtraceContext::CancelNotifyThreadSeen(MBtraceContextObserver &)
+	CancelNotifyUnclassifiedData__15CBtraceKeyPressR23MBtraceKeyPressObserver @ 19 NONAME R3UNUSED ; CBtraceKeyPress::CancelNotifyUnclassifiedData(MBtraceKeyPressObserver &)
+	CancelNotifyWindowGroupSeen__14CBtraceContextR22MBtraceContextObserver @ 20 NONAME R3UNUSED ; CBtraceContext::CancelNotifyWindowGroupSeen(MBtraceContextObserver &)
+	CurrentTickCount__C13CBtraceReader @ 21 NONAME R3UNUSED ; CBtraceReader::CurrentTickCount(void) const
+	DebugOverrideTimerSettings__12TBtraceUtilsiii @ 22 NONAME R3UNUSED ; TBtraceUtils::DebugOverrideTimerSettings(int, int, int)
+	DecRef__17CRefCountedObject @ 23 NONAME R3UNUSED ; CRefCountedObject::DecRef(void)
+	DisableBtrace__13CBtraceReader @ 24 NONAME R3UNUSED ; CBtraceReader::DisableBtrace(void)
+	DisableCategoryL__13CBtraceReaderUi @ 25 NONAME R3UNUSED ; CBtraceReader::DisableCategoryL(unsigned int)
+	EnableCategoryL__13CBtraceReaderUi @ 26 NONAME R3UNUSED ; CBtraceReader::EnableCategoryL(unsigned int)
+	FastTicksToMicroSeconds__12TBtraceUtilsRCUx @ 27 NONAME R3UNUSED ; TBtraceUtils::FastTicksToMicroSeconds(unsigned long long const &)
+	FindThread__C14CBtraceContextRC9TThreadId @ 28 NONAME R3UNUSED ; CBtraceContext::FindThread(TThreadId const &) const
+	FindThread__C14CBtraceContextUl @ 29 NONAME R3UNUSED ; CBtraceContext::FindThread(unsigned long) const
+	FindThreadsL__C14CBtraceContextRC7TDesC16Rt6RArray1Z15TBtraceThreadId @ 30 NONAME R3UNUSED ; CBtraceContext::FindThreadsL(TDesC16 const &, RArray<TBtraceThreadId> &) const
+	FindWindowGroup__C14CBtraceContexti @ 31 NONAME R3UNUSED ; CBtraceContext::FindWindowGroup(int) const
+	FindWindowGroupsByThreadName__C14CBtraceContextRC7TDesC16Rt6RArray1Z20TBtraceWindowGroupId @ 32 NONAME R3UNUSED ; CBtraceContext::FindWindowGroupsByThreadName(TDesC16 const &, RArray<TBtraceWindowGroupId> &) const
+	FindWindowGroupsL__C14CBtraceContextRC7TDesC16Rt6RArray1Z20TBtraceWindowGroupId @ 33 NONAME R3UNUSED ; CBtraceContext::FindWindowGroupsL(TDesC16 const &, RArray<TBtraceWindowGroupId> &) const
+	FlushL__13CBtraceReader @ 34 NONAME R3UNUSED ; CBtraceReader::FlushL(void)
+	GetFullThreadName__C14CBtraceContextRC15TBtraceThreadIdR6TDes16 @ 35 NONAME R3UNUSED ; CBtraceContext::GetFullThreadName(TBtraceThreadId const &, TDes16 &) const
+	GetReplayStartTickCountL__13CBtraceReaderR16TBtraceTickCount @ 36 NONAME R3UNUSED ; CBtraceReader::GetReplayStartTickCountL(TBtraceTickCount &)
+	HandleThreadExitL__22MBtraceContextObserverRC16TBtraceTickCountRC15TBtraceThreadId9TExitTypeiRC7TDesC16Ui @ 37 NONAME ; MBtraceContextObserver::HandleThreadExitL(TBtraceTickCount const &, TBtraceThreadId const &, TExitType, int, TDesC16 const &, unsigned int)
+	HandleThreadGoneL__22MBtraceContextObserverRC16TBtraceTickCountRC15TBtraceThreadIdUi @ 38 NONAME ; MBtraceContextObserver::HandleThreadGoneL(TBtraceTickCount const &, TBtraceThreadId const &, unsigned int)
+	HandleThreadSeenL__22MBtraceContextObserverRC16TBtraceTickCountRC15TBtraceThreadIdUi @ 39 NONAME ; MBtraceContextObserver::HandleThreadSeenL(TBtraceTickCount const &, TBtraceThreadId const &, unsigned int)
+	HandleWindowGroupSeenL__22MBtraceContextObserverRC16TBtraceTickCountRC20TBtraceWindowGroupIdUi @ 40 NONAME ; MBtraceContextObserver::HandleWindowGroupSeenL(TBtraceTickCount const &, TBtraceWindowGroupId const &, unsigned int)
+	IncRef__17CRefCountedObject @ 41 NONAME R3UNUSED ; CRefCountedObject::IncRef(void)
+	IntervalInFastTicks__C16TBtraceTickCountRC16TBtraceTickCount @ 42 NONAME R3UNUSED ; TBtraceTickCount::IntervalInFastTicks(TBtraceTickCount const &) const
+	IntervalInMicroSeconds__C16TBtraceTickCountRC16TBtraceTickCount @ 43 NONAME R3UNUSED ; TBtraceTickCount::IntervalInMicroSeconds(TBtraceTickCount const &) const
+	IntervalInNanoTicks__C16TBtraceTickCountRC16TBtraceTickCount @ 44 NONAME R3UNUSED ; TBtraceTickCount::IntervalInNanoTicks(TBtraceTickCount const &) const
+	LogBtraceStatus__13CBtraceReader @ 45 NONAME R3UNUSED ; CBtraceReader::LogBtraceStatus(void)
+	MicroSecondsToFastTicks__12TBtraceUtilsG27TTimeIntervalMicroSeconds32 @ 46 NONAME R3UNUSED ; TBtraceUtils::MicroSecondsToFastTicks(TTimeIntervalMicroSeconds32)
+	MicroSecondsToNanoTicks__12TBtraceUtilsG27TTimeIntervalMicroSeconds32 @ 47 NONAME R3UNUSED ; TBtraceUtils::MicroSecondsToNanoTicks(TTimeIntervalMicroSeconds32)
+	NanoTicksToMicroSeconds__12TBtraceUtilsUl @ 48 NONAME R3UNUSED ; TBtraceUtils::NanoTicksToMicroSeconds(unsigned long)
+	NewL__13CBtracePubSubR13CBtraceReader @ 49 NONAME R3UNUSED ; CBtracePubSub::NewL(CBtraceReader &)
+	NewL__13CBtraceReaderQ213CBtraceReader5TModeiiP10MBtraceLog @ 50 NONAME ; CBtraceReader::NewL(CBtraceReader::TMode, int, int, MBtraceLog *)
+	NewL__13CBtraceReaderRC7TDesC16P10MBtraceLog @ 51 NONAME R3UNUSED ; CBtraceReader::NewL(TDesC16 const &, MBtraceLog *)
+	NewL__14CBtraceContextR13CBtraceReaderQ214CBtraceContext5TMode @ 52 NONAME R3UNUSED ; CBtraceContext::NewL(CBtraceReader &, CBtraceContext::TMode)
+	NewL__14CBtraceGenericR13CBtraceReader @ 53 NONAME R3UNUSED ; CBtraceGeneric::NewL(CBtraceReader &)
+	NewL__15CBtraceCpuUsageR13CBtraceReaderR14CBtraceContext @ 54 NONAME R3UNUSED ; CBtraceCpuUsage::NewL(CBtraceReader &, CBtraceContext &)
+	NewL__15CBtraceKeyPressR13CBtraceReader @ 55 NONAME R3UNUSED ; CBtraceKeyPress::NewL(CBtraceReader &)
+	NewL__18CBtraceAppResponseR13CBtraceReader @ 56 NONAME R3UNUSED ; CBtraceAppResponse::NewL(CBtraceReader &)
+	NewL__18CBtraceDomainEventR13CBtraceReader @ 57 NONAME R3UNUSED ; CBtraceDomainEvent::NewL(CBtraceReader &)
+	NewL__18CBtraceFocusChangeR13CBtraceReaderR14CBtraceContext @ 58 NONAME R3UNUSED ; CBtraceFocusChange::NewL(CBtraceReader &, CBtraceContext &)
+	NewL__19CBtraceScreenUpdateR13CBtraceReader @ 59 NONAME R3UNUSED ; CBtraceScreenUpdate::NewL(CBtraceReader &)
+	NewL__19CBtraceTextOnScreenR13CBtraceReader @ 60 NONAME R3UNUSED ; CBtraceTextOnScreen::NewL(CBtraceReader &)
+	NotifyAppResponseL__18CBtraceAppResponseR26MBtraceAppResponseObserverRC10TProcessId @ 61 NONAME R3UNUSED ; CBtraceAppResponse::NotifyAppResponseL(MBtraceAppResponseObserver &, TProcessId const &)
+	NotifyAppResponseL__18CBtraceAppResponseR26MBtraceAppResponseObserverRC10TProcessId30TBtraceNotificationPersistence @ 62 NONAME ; CBtraceAppResponse::NotifyAppResponseL(MBtraceAppResponseObserver &, TProcessId const &, TBtraceNotificationPersistence)
+	NotifyContextSwitchL__15CBtraceCpuUsageRC15TBtraceThreadIdR23MBtraceCpuUsageObserver @ 63 NONAME R3UNUSED ; CBtraceCpuUsage::NotifyContextSwitchL(TBtraceThreadId const &, MBtraceCpuUsageObserver &)
+	NotifyCpuUsageL__15CBtraceCpuUsageUlG27TTimeIntervalMicroSeconds32R23MBtraceCpuUsageObserver @ 64 NONAME ; CBtraceCpuUsage::NotifyCpuUsageL(unsigned long, TTimeIntervalMicroSeconds32, MBtraceCpuUsageObserver &)
+	NotifyCpuUsageL__15CBtraceCpuUsageUlG27TTimeIntervalMicroSeconds32R23MBtraceCpuUsageObserver30TBtraceNotificationPersistence @ 65 NONAME ; CBtraceCpuUsage::NotifyCpuUsageL(unsigned long, TTimeIntervalMicroSeconds32, MBtraceCpuUsageObserver &, TBtraceNotificationPersistence)
+	NotifyDataPropertyChangedL__13CBtracePubSubPUiT1PC6TDesC8R21MBtracePubSubObserver30TBtraceNotificationPersistence @ 66 NONAME ; CBtracePubSub::NotifyDataPropertyChangedL(unsigned int *, unsigned int *, TDesC8 const *, MBtracePubSubObserver &, TBtraceNotificationPersistence)
+	NotifyDomainEventL__18CBtraceDomainEventUiR26MBtraceDomainEventObserver30TBtraceNotificationPersistence @ 67 NONAME ; CBtraceDomainEvent::NotifyDomainEventL(unsigned int, MBtraceDomainEventObserver &, TBtraceNotificationPersistence)
+	NotifyDomainEventL__18CBtraceDomainEventUiUiR26MBtraceDomainEventObserver30TBtraceNotificationPersistence @ 68 NONAME ; CBtraceDomainEvent::NotifyDomainEventL(unsigned int, unsigned int, MBtraceDomainEventObserver &, TBtraceNotificationPersistence)
+	NotifyDomainEventL__18CBtraceDomainEventUiUiUiR26MBtraceDomainEventObserver30TBtraceNotificationPersistence @ 69 NONAME ; CBtraceDomainEvent::NotifyDomainEventL(unsigned int, unsigned int, unsigned int, MBtraceDomainEventObserver &, TBtraceNotificationPersistence)
+	NotifyDomainEventL__18CBtraceDomainEventUiUiUiUiR26MBtraceDomainEventObserver30TBtraceNotificationPersistence @ 70 NONAME ; CBtraceDomainEvent::NotifyDomainEventL(unsigned int, unsigned int, unsigned int, unsigned int, MBtraceDomainEventObserver &, TBtraceNotificationPersistence)
+	NotifyFocusChangedL__18CBtraceFocusChangeRC7TDesC16R26MBtraceFocusChangeObserver @ 71 NONAME R3UNUSED ; CBtraceFocusChange::NotifyFocusChangedL(TDesC16 const &, MBtraceFocusChangeObserver &)
+	NotifyFocusChangedL__18CBtraceFocusChangeRC7TDesC16R26MBtraceFocusChangeObserver30TBtraceNotificationPersistence @ 72 NONAME ; CBtraceFocusChange::NotifyFocusChangedL(TDesC16 const &, MBtraceFocusChangeObserver &, TBtraceNotificationPersistence)
+	NotifyGenericEventL__14CBtraceGenericR22MBtraceGenericObserver @ 73 NONAME R3UNUSED ; CBtraceGeneric::NotifyGenericEventL(MBtraceGenericObserver &)
+	NotifyIntegerPropertyChangedL__13CBtracePubSubPUiT1PiR21MBtracePubSubObserver30TBtraceNotificationPersistence @ 74 NONAME ; CBtracePubSub::NotifyIntegerPropertyChangedL(unsigned int *, unsigned int *, int *, MBtracePubSubObserver &, TBtraceNotificationPersistence)
+	NotifyKeyEventL__15CBtraceKeyPressR23MBtraceKeyPressObserver @ 75 NONAME R3UNUSED ; CBtraceKeyPress::NotifyKeyEventL(MBtraceKeyPressObserver &)
+	NotifyKeyEventL__15CBtraceKeyPressR23MBtraceKeyPressObserver30TBtraceNotificationPersistence @ 76 NONAME R3UNUSED ; CBtraceKeyPress::NotifyKeyEventL(MBtraceKeyPressObserver &, TBtraceNotificationPersistence)
+	NotifyPointerEventL__15CBtraceKeyPressR23MBtraceKeyPressObserver @ 77 NONAME R3UNUSED ; CBtraceKeyPress::NotifyPointerEventL(MBtraceKeyPressObserver &)
+	NotifyPointerEventL__15CBtraceKeyPressR23MBtraceKeyPressObserver30TBtraceNotificationPersistence @ 78 NONAME R3UNUSED ; CBtraceKeyPress::NotifyPointerEventL(MBtraceKeyPressObserver &, TBtraceNotificationPersistence)
+	NotifyPropertyChangedL__13CBtracePubSubPUiT1R21MBtracePubSubObserver30TBtraceNotificationPersistence @ 79 NONAME ; CBtracePubSub::NotifyPropertyChangedL(unsigned int *, unsigned int *, MBtracePubSubObserver &, TBtraceNotificationPersistence)
+	NotifyPropertyChangedL__13CBtracePubSubR21MBtracePubSubObserver @ 80 NONAME R3UNUSED ; CBtracePubSub::NotifyPropertyChangedL(MBtracePubSubObserver &)
+	NotifyRawKeyEventL__15CBtraceKeyPressR23MBtraceKeyPressObserver @ 81 NONAME R3UNUSED ; CBtraceKeyPress::NotifyRawKeyEventL(MBtraceKeyPressObserver &)
+	NotifyRawKeyEventL__15CBtraceKeyPressR23MBtraceKeyPressObserver30TBtraceNotificationPersistence @ 82 NONAME R3UNUSED ; CBtraceKeyPress::NotifyRawKeyEventL(MBtraceKeyPressObserver &, TBtraceNotificationPersistence)
+	NotifyScreenUpdateL__19CBtraceScreenUpdateR27MBtraceScreenUpdateObserver @ 83 NONAME R3UNUSED ; CBtraceScreenUpdate::NotifyScreenUpdateL(MBtraceScreenUpdateObserver &)
+	NotifyScreenUpdateL__19CBtraceScreenUpdateR27MBtraceScreenUpdateObserver30TBtraceNotificationPersistence @ 84 NONAME R3UNUSED ; CBtraceScreenUpdate::NotifyScreenUpdateL(MBtraceScreenUpdateObserver &, TBtraceNotificationPersistence)
+	NotifyScreenUpdateL__19CBtraceScreenUpdateiRC5TRectR27MBtraceScreenUpdateObserver @ 85 NONAME ; CBtraceScreenUpdate::NotifyScreenUpdateL(int, TRect const &, MBtraceScreenUpdateObserver &)
+	NotifyScreenUpdateL__19CBtraceScreenUpdateiRC5TRectR27MBtraceScreenUpdateObserver30TBtraceNotificationPersistence @ 86 NONAME ; CBtraceScreenUpdate::NotifyScreenUpdateL(int, TRect const &, MBtraceScreenUpdateObserver &, TBtraceNotificationPersistence)
+	NotifyTextOnScreenL__19CBtraceTextOnScreenRC7TDesC16Q219CBtraceTextOnScreen10TMatchModeR27MBtraceTextOnScreenObserver30TBtraceNotificationPersistence @ 87 NONAME ; CBtraceTextOnScreen::NotifyTextOnScreenL(TDesC16 const &, CBtraceTextOnScreen::TMatchMode, MBtraceTextOnScreenObserver &, TBtraceNotificationPersistence)
+	NotifyTextOnScreenL__19CBtraceTextOnScreenRC7TDesC16R27MBtraceTextOnScreenObserver @ 88 NONAME R3UNUSED ; CBtraceTextOnScreen::NotifyTextOnScreenL(TDesC16 const &, MBtraceTextOnScreenObserver &)
+	NotifyTextOnScreenL__19CBtraceTextOnScreenRC7TDesC16R27MBtraceTextOnScreenObserver30TBtraceNotificationPersistence @ 89 NONAME ; CBtraceTextOnScreen::NotifyTextOnScreenL(TDesC16 const &, MBtraceTextOnScreenObserver &, TBtraceNotificationPersistence)
+	NotifyTextOnScreenL__19CBtraceTextOnScreenRC7TDesC16iQ219CBtraceTextOnScreen10TMatchModeR27MBtraceTextOnScreenObserver @ 90 NONAME ; CBtraceTextOnScreen::NotifyTextOnScreenL(TDesC16 const &, int, CBtraceTextOnScreen::TMatchMode, MBtraceTextOnScreenObserver &)
+	NotifyTextOnScreenL__19CBtraceTextOnScreenRC7TDesC16iQ219CBtraceTextOnScreen10TMatchModeR27MBtraceTextOnScreenObserver30TBtraceNotificationPersistence @ 91 NONAME ; CBtraceTextOnScreen::NotifyTextOnScreenL(TDesC16 const &, int, CBtraceTextOnScreen::TMatchMode, MBtraceTextOnScreenObserver &, TBtraceNotificationPersistence)
+	NotifyThreadExitL__14CBtraceContextRC7TDesC16UiPiPC7TDesC16R22MBtraceContextObserverUi30TBtraceNotificationPersistence @ 92 NONAME ; CBtraceContext::NotifyThreadExitL(TDesC16 const &, unsigned int, int *, TDesC16 const *, MBtraceContextObserver &, unsigned int, TBtraceNotificationPersistence)
+	NotifyThreadGoneL__14CBtraceContextRC7TDesC16R22MBtraceContextObserverUi @ 93 NONAME ; CBtraceContext::NotifyThreadGoneL(TDesC16 const &, MBtraceContextObserver &, unsigned int)
+	NotifyThreadGoneL__14CBtraceContextRC7TDesC16R22MBtraceContextObserverUi30TBtraceNotificationPersistence @ 94 NONAME ; CBtraceContext::NotifyThreadGoneL(TDesC16 const &, MBtraceContextObserver &, unsigned int, TBtraceNotificationPersistence)
+	NotifyThreadIdleL__15CBtraceCpuUsageRC15TBtraceThreadIdRC16TBtraceTickCountG27TTimeIntervalMicroSeconds32R23MBtraceCpuUsageObserver @ 95 NONAME ; CBtraceCpuUsage::NotifyThreadIdleL(TBtraceThreadId const &, TBtraceTickCount const &, TTimeIntervalMicroSeconds32, MBtraceCpuUsageObserver &)
+	NotifyThreadIdleL__15CBtraceCpuUsageRC15TBtraceThreadIdRC16TBtraceTickCountG27TTimeIntervalMicroSeconds32R23MBtraceCpuUsageObserver30TBtraceNotificationPersistence @ 96 NONAME ; CBtraceCpuUsage::NotifyThreadIdleL(TBtraceThreadId const &, TBtraceTickCount const &, TTimeIntervalMicroSeconds32, MBtraceCpuUsageObserver &, TBtraceNotificationPersistence)
+	NotifyThreadSeenL__14CBtraceContextRC7TDesC16R22MBtraceContextObserverUi @ 97 NONAME ; CBtraceContext::NotifyThreadSeenL(TDesC16 const &, MBtraceContextObserver &, unsigned int)
+	NotifyThreadSeenL__14CBtraceContextRC7TDesC16R22MBtraceContextObserverUi30TBtraceNotificationPersistence @ 98 NONAME ; CBtraceContext::NotifyThreadSeenL(TDesC16 const &, MBtraceContextObserver &, unsigned int, TBtraceNotificationPersistence)
+	NotifyUnclassifiedDataL__15CBtraceKeyPressR23MBtraceKeyPressObserver @ 99 NONAME R3UNUSED ; CBtraceKeyPress::NotifyUnclassifiedDataL(MBtraceKeyPressObserver &)
+	NotifyUnclassifiedDataL__15CBtraceKeyPressR23MBtraceKeyPressObserver30TBtraceNotificationPersistence @ 100 NONAME R3UNUSED ; CBtraceKeyPress::NotifyUnclassifiedDataL(MBtraceKeyPressObserver &, TBtraceNotificationPersistence)
+	NotifyWindowGroupSeenByThreadNameL__14CBtraceContextRC7TDesC16R22MBtraceContextObserverUi30TBtraceNotificationPersistence @ 101 NONAME ; CBtraceContext::NotifyWindowGroupSeenByThreadNameL(TDesC16 const &, MBtraceContextObserver &, unsigned int, TBtraceNotificationPersistence)
+	NotifyWindowGroupSeenL__14CBtraceContextRC7TDesC16R22MBtraceContextObserverUi30TBtraceNotificationPersistence @ 102 NONAME ; CBtraceContext::NotifyWindowGroupSeenL(TDesC16 const &, MBtraceContextObserver &, unsigned int, TBtraceNotificationPersistence)
+	ProcessName__C14CBtraceContextRC16TBtraceProcessId @ 103 NONAME R3UNUSED ; CBtraceContext::ProcessName(TBtraceProcessId const &) const
+	RecordBtraceDataToFileL__13CBtraceReaderRC7TDesC16 @ 104 NONAME R3UNUSED ; CBtraceReader::RecordBtraceDataToFileL(TDesC16 const &)
+	RefCount__C17CRefCountedObject @ 105 NONAME R3UNUSED ; CRefCountedObject::RefCount(void) const
+	RemoveFrameObserver__13CBtraceReaderR20MBtraceFrameObserver @ 106 NONAME R3UNUSED ; CBtraceReader::RemoveFrameObserver(MBtraceFrameObserver &)
+	RemoveObserver__13CBtraceReaderR15MBtraceObserver @ 107 NONAME R3UNUSED ; CBtraceReader::RemoveObserver(MBtraceObserver &)
+	RemoveObserver__13CBtraceReaderUiR15MBtraceObserver @ 108 NONAME R3UNUSED ; CBtraceReader::RemoveObserver(unsigned int, MBtraceObserver &)
+	Reset__13CBtraceReader @ 109 NONAME R3UNUSED ; CBtraceReader::Reset(void)
+	SetBufferSizeL__13CBtraceReaderi @ 110 NONAME R3UNUSED ; CBtraceReader::SetBufferSizeL(int)
+	SetMultipartReassemblyL__13CBtraceReaderi @ 111 NONAME R3UNUSED ; CBtraceReader::SetMultipartReassemblyL(int)
+	SetReplayFileNameL__13CBtraceReaderRC7TDesC16 @ 112 NONAME R3UNUSED ; CBtraceReader::SetReplayFileNameL(TDesC16 const &)
+	SetToNow__16TBtraceTickCount @ 113 NONAME R3UNUSED ; TBtraceTickCount::SetToNow(void)
+	Set__13TBtraceIdBaseUi @ 114 NONAME R3UNUSED ; TBtraceIdBase::Set(unsigned int)
+	Start__13CBtraceReaderRC16TBtraceTickCount @ 115 NONAME R3UNUSED ; CBtraceReader::Start(TBtraceTickCount const &)
+	Start__13CBtraceReaderRC16TBtraceTickCountG27TTimeIntervalMicroSeconds32 @ 116 NONAME R3UNUSED ; CBtraceReader::Start(TBtraceTickCount const &, TTimeIntervalMicroSeconds32)
+	SynchronizeL__13CBtraceReader @ 117 NONAME R3UNUSED ; CBtraceReader::SynchronizeL(void)
+	ThreadId__C14CBtraceContextRC15TBtraceThreadId @ 118 NONAME R3UNUSED ; CBtraceContext::ThreadId(TBtraceThreadId const &) const
+	ThreadName__C14CBtraceContextRC15TBtraceThreadId @ 119 NONAME R3UNUSED ; CBtraceContext::ThreadName(TBtraceThreadId const &) const
+	Value__C13TBtraceIdBase @ 120 NONAME R3UNUSED ; TBtraceIdBase::Value(void) const
+	WindowGroupId__C14CBtraceContextRC20TBtraceWindowGroupId @ 121 NONAME R3UNUSED ; CBtraceContext::WindowGroupId(TBtraceWindowGroupId const &) const
+	WindowGroupName__C14CBtraceContextRC20TBtraceWindowGroupId @ 122 NONAME R3UNUSED ; CBtraceContext::WindowGroupName(TBtraceWindowGroupId const &) const
+	"_._13CBtracePubSub" @ 123 NONAME R3UNUSED ; CBtracePubSub::~CBtracePubSub(void)
+	"_._13CBtraceReader" @ 124 NONAME R3UNUSED ; CBtraceReader::~CBtraceReader(void)
+	"_._14CBtraceContext" @ 125 NONAME R3UNUSED ; CBtraceContext::~CBtraceContext(void)
+	"_._14CBtraceGeneric" @ 126 NONAME R3UNUSED ; CBtraceGeneric::~CBtraceGeneric(void)
+	"_._15CBtraceCpuUsage" @ 127 NONAME R3UNUSED ; CBtraceCpuUsage::~CBtraceCpuUsage(void)
+	"_._15CBtraceKeyPress" @ 128 NONAME R3UNUSED ; CBtraceKeyPress::~CBtraceKeyPress(void)
+	"_._18CBtraceAppResponse" @ 129 NONAME R3UNUSED ; CBtraceAppResponse::~CBtraceAppResponse(void)
+	"_._18CBtraceDomainEvent" @ 130 NONAME R3UNUSED ; CBtraceDomainEvent::~CBtraceDomainEvent(void)
+	"_._18CBtraceFocusChange" @ 131 NONAME R3UNUSED ; CBtraceFocusChange::~CBtraceFocusChange(void)
+	"_._19CBtraceScreenUpdate" @ 132 NONAME R3UNUSED ; CBtraceScreenUpdate::~CBtraceScreenUpdate(void)
+	"_._19CBtraceTextOnScreen" @ 133 NONAME R3UNUSED ; CBtraceTextOnScreen::~CBtraceTextOnScreen(void)
+	__13TBtraceIdBase @ 134 NONAME R3UNUSED ; TBtraceIdBase::TBtraceIdBase(void)
+	__13TBtraceIdBaseRC13TBtraceIdBase @ 135 NONAME R3UNUSED ; TBtraceIdBase::TBtraceIdBase(TBtraceIdBase const &)
+	__13TBtraceIdBaseUi @ 136 NONAME R3UNUSED ; TBtraceIdBase::TBtraceIdBase(unsigned int)
+	__15TBtraceThreadId @ 137 NONAME R3UNUSED ; TBtraceThreadId::TBtraceThreadId(void)
+	__15TBtraceThreadIdRC15TBtraceThreadId @ 138 NONAME R3UNUSED ; TBtraceThreadId::TBtraceThreadId(TBtraceThreadId const &)
+	__15TBtraceThreadIdUi @ 139 NONAME R3UNUSED ; TBtraceThreadId::TBtraceThreadId(unsigned int)
+	__16TBtraceProcessId @ 140 NONAME R3UNUSED ; TBtraceProcessId::TBtraceProcessId(void)
+	__16TBtraceProcessIdRC16TBtraceProcessId @ 141 NONAME R3UNUSED ; TBtraceProcessId::TBtraceProcessId(TBtraceProcessId const &)
+	__16TBtraceProcessIdUi @ 142 NONAME R3UNUSED ; TBtraceProcessId::TBtraceProcessId(unsigned int)
+	__16TBtraceTickCount @ 143 NONAME R3UNUSED ; TBtraceTickCount::TBtraceTickCount(void)
+	__20TBtraceWindowGroupId @ 144 NONAME R3UNUSED ; TBtraceWindowGroupId::TBtraceWindowGroupId(void)
+	__20TBtraceWindowGroupIdRC20TBtraceWindowGroupId @ 145 NONAME R3UNUSED ; TBtraceWindowGroupId::TBtraceWindowGroupId(TBtraceWindowGroupId const &)
+	__20TBtraceWindowGroupIdUi @ 146 NONAME R3UNUSED ; TBtraceWindowGroupId::TBtraceWindowGroupId(unsigned int)
+	__eq__C13TBtraceIdBaseRC13TBtraceIdBase @ 147 NONAME R3UNUSED ; TBtraceIdBase::operator==(TBtraceIdBase const &) const
+	__eq__C16TBtraceTickCountRC16TBtraceTickCount @ 148 NONAME R3UNUSED ; TBtraceTickCount::operator==(TBtraceTickCount const &) const
+	__ge__C16TBtraceTickCountRC16TBtraceTickCount @ 149 NONAME R3UNUSED ; TBtraceTickCount::operator>=(TBtraceTickCount const &) const
+	__gt__C16TBtraceTickCountRC16TBtraceTickCount @ 150 NONAME R3UNUSED ; TBtraceTickCount::operator>(TBtraceTickCount const &) const
+	__le__C16TBtraceTickCountRC16TBtraceTickCount @ 151 NONAME R3UNUSED ; TBtraceTickCount::operator<=(TBtraceTickCount const &) const
+	__lt__C16TBtraceTickCountRC16TBtraceTickCount @ 152 NONAME R3UNUSED ; TBtraceTickCount::operator<(TBtraceTickCount const &) const
+	AddFrameObseverL__13CBtraceReaderR20MBtraceFrameObserver @ 153 NONAME R3UNUSED ; CBtraceReader::AddFrameObseverL(MBtraceFrameObserver &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/bwins/btrace_parseru.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,155 @@
+EXPORTS
+	??0TBtraceThreadId@@QAE@I@Z @ 1 NONAME ; TBtraceThreadId::TBtraceThreadId(unsigned int)
+	?NotifyPointerEventL@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@W4TBtraceNotificationPersistence@@@Z @ 2 NONAME ; void CBtraceKeyPress::NotifyPointerEventL(class MBtraceKeyPressObserver &, enum TBtraceNotificationPersistence)
+	?NotifyDomainEventL@CBtraceDomainEvent@@QAEXIIIIAAVMBtraceDomainEventObserver@@W4TBtraceNotificationPersistence@@@Z @ 3 NONAME ; void CBtraceDomainEvent::NotifyDomainEventL(unsigned int, unsigned int, unsigned int, unsigned int, class MBtraceDomainEventObserver &, enum TBtraceNotificationPersistence)
+	?FindThread@CBtraceContext@@QBEPBVTBtraceThreadId@@K@Z @ 4 NONAME ; class TBtraceThreadId const * CBtraceContext::FindThread(unsigned long) const
+	?NotifyRawKeyEventL@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@W4TBtraceNotificationPersistence@@@Z @ 5 NONAME ; void CBtraceKeyPress::NotifyRawKeyEventL(class MBtraceKeyPressObserver &, enum TBtraceNotificationPersistence)
+	?NotifyScreenUpdateL@CBtraceScreenUpdate@@QAEXHABVTRect@@AAVMBtraceScreenUpdateObserver@@W4TBtraceNotificationPersistence@@@Z @ 6 NONAME ; void CBtraceScreenUpdate::NotifyScreenUpdateL(int, class TRect const &, class MBtraceScreenUpdateObserver &, enum TBtraceNotificationPersistence)
+	?Start@CBtraceReader@@QAEXABVTBtraceTickCount@@@Z @ 7 NONAME ; void CBtraceReader::Start(class TBtraceTickCount const &)
+	?NewL@CBtracePubSub@@SAPAV1@AAVCBtraceReader@@@Z @ 8 NONAME ; class CBtracePubSub * CBtracePubSub::NewL(class CBtraceReader &)
+	??1CBtraceContext@@UAE@XZ @ 9 NONAME ; CBtraceContext::~CBtraceContext(void)
+	?NewL@CBtraceContext@@SAPAV1@AAVCBtraceReader@@W4TMode@1@@Z @ 10 NONAME ; class CBtraceContext * CBtraceContext::NewL(class CBtraceReader &, enum CBtraceContext::TMode)
+	??0TBtraceThreadId@@QAE@XZ @ 11 NONAME ; TBtraceThreadId::TBtraceThreadId(void)
+	?SynchronizeL@CBtraceReader@@QAEXXZ @ 12 NONAME ; void CBtraceReader::SynchronizeL(void)
+	?SetToNow@TBtraceTickCount@@QAEXXZ @ 13 NONAME ; void TBtraceTickCount::SetToNow(void)
+	?NotifyThreadExitL@CBtraceContext@@QAEXABVTDesC16@@IPAHPBV2@AAVMBtraceContextObserver@@IW4TBtraceNotificationPersistence@@@Z @ 14 NONAME ; void CBtraceContext::NotifyThreadExitL(class TDesC16 const &, unsigned int, int *, class TDesC16 const *, class MBtraceContextObserver &, unsigned int, enum TBtraceNotificationPersistence)
+	?Value@TBtraceIdBase@@QBEIXZ @ 15 NONAME ; unsigned int TBtraceIdBase::Value(void) const
+	?NotifyThreadGoneL@CBtraceContext@@QAEXABVTDesC16@@AAVMBtraceContextObserver@@I@Z @ 16 NONAME ; void CBtraceContext::NotifyThreadGoneL(class TDesC16 const &, class MBtraceContextObserver &, unsigned int)
+	?NotifyKeyEventL@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@@Z @ 17 NONAME ; void CBtraceKeyPress::NotifyKeyEventL(class MBtraceKeyPressObserver &)
+	?CancelNotifyPointerEvent@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@@Z @ 18 NONAME ; void CBtraceKeyPress::CancelNotifyPointerEvent(class MBtraceKeyPressObserver &)
+	??9TBtraceTickCount@@QBEHABV0@@Z @ 19 NONAME ; int TBtraceTickCount::operator!=(class TBtraceTickCount const &) const
+	?NotifyRawKeyEventL@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@@Z @ 20 NONAME ; void CBtraceKeyPress::NotifyRawKeyEventL(class MBtraceKeyPressObserver &)
+	?NotifyPropertyChangedL@CBtracePubSub@@QAEXAAVMBtracePubSubObserver@@@Z @ 21 NONAME ; void CBtracePubSub::NotifyPropertyChangedL(class MBtracePubSubObserver &)
+	?DebugOverrideTimerSettings@TBtraceUtils@@SAXHHH@Z @ 22 NONAME ; void TBtraceUtils::DebugOverrideTimerSettings(int, int, int)
+	??8TBtraceTickCount@@QBEHABV0@@Z @ 23 NONAME ; int TBtraceTickCount::operator==(class TBtraceTickCount const &) const
+	?NotifyDomainEventL@CBtraceDomainEvent@@QAEXIIAAVMBtraceDomainEventObserver@@W4TBtraceNotificationPersistence@@@Z @ 24 NONAME ; void CBtraceDomainEvent::NotifyDomainEventL(unsigned int, unsigned int, class MBtraceDomainEventObserver &, enum TBtraceNotificationPersistence)
+	?FindThread@CBtraceContext@@QBEPBVTBtraceThreadId@@ABVTThreadId@@@Z @ 25 NONAME ; class TBtraceThreadId const * CBtraceContext::FindThread(class TThreadId const &) const
+	??0TBtraceIdBase@@IAE@XZ @ 26 NONAME ; TBtraceIdBase::TBtraceIdBase(void)
+	??1CBtraceDomainEvent@@UAE@XZ @ 27 NONAME ; CBtraceDomainEvent::~CBtraceDomainEvent(void)
+	?NewL@CBtraceGeneric@@SAPAV1@AAVCBtraceReader@@@Z @ 28 NONAME ; class CBtraceGeneric * CBtraceGeneric::NewL(class CBtraceReader &)
+	?NewL@CBtraceAppResponse@@SAPAV1@AAVCBtraceReader@@@Z @ 29 NONAME ; class CBtraceAppResponse * CBtraceAppResponse::NewL(class CBtraceReader &)
+	?FlushL@CBtraceReader@@QAEXXZ @ 30 NONAME ; void CBtraceReader::FlushL(void)
+	?FindThreadsL@CBtraceContext@@QBEXABVTDesC16@@AAV?$RArray@VTBtraceThreadId@@@@@Z @ 31 NONAME ; void CBtraceContext::FindThreadsL(class TDesC16 const &, class RArray<class TBtraceThreadId> &) const
+	??1CBtraceTextOnScreen@@UAE@XZ @ 32 NONAME ; CBtraceTextOnScreen::~CBtraceTextOnScreen(void)
+	?NotifyTextOnScreenL@CBtraceTextOnScreen@@QAEXABVTDesC16@@AAVMBtraceTextOnScreenObserver@@@Z @ 33 NONAME ; void CBtraceTextOnScreen::NotifyTextOnScreenL(class TDesC16 const &, class MBtraceTextOnScreenObserver &)
+	?CancelNotifyAppResponse@CBtraceAppResponse@@QAEXAAVMBtraceAppResponseObserver@@@Z @ 34 NONAME ; void CBtraceAppResponse::CancelNotifyAppResponse(class MBtraceAppResponseObserver &)
+	?AddObserverL@CBtraceReader@@QAEXIAAVMBtraceObserver@@W4TObserverType@1@@Z @ 35 NONAME ; void CBtraceReader::AddObserverL(unsigned int, class MBtraceObserver &, enum CBtraceReader::TObserverType)
+	?SetBufferSizeL@CBtraceReader@@QAEXH@Z @ 36 NONAME ; void CBtraceReader::SetBufferSizeL(int)
+	?CancelNotifyThreadGone@CBtraceContext@@QAEXAAVMBtraceContextObserver@@@Z @ 37 NONAME ; void CBtraceContext::CancelNotifyThreadGone(class MBtraceContextObserver &)
+	?SetReplayFileNameL@CBtraceReader@@QAEXABVTDesC16@@@Z @ 38 NONAME ; void CBtraceReader::SetReplayFileNameL(class TDesC16 const &)
+	?RemoveObserver@CBtraceReader@@QAEXAAVMBtraceObserver@@@Z @ 39 NONAME ; void CBtraceReader::RemoveObserver(class MBtraceObserver &)
+	?NotifyUnclassifiedDataL@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@W4TBtraceNotificationPersistence@@@Z @ 40 NONAME ; void CBtraceKeyPress::NotifyUnclassifiedDataL(class MBtraceKeyPressObserver &, enum TBtraceNotificationPersistence)
+	?NotifyTextOnScreenL@CBtraceTextOnScreen@@QAEXABVTDesC16@@HW4TMatchMode@1@AAVMBtraceTextOnScreenObserver@@W4TBtraceNotificationPersistence@@@Z @ 41 NONAME ; void CBtraceTextOnScreen::NotifyTextOnScreenL(class TDesC16 const &, int, enum CBtraceTextOnScreen::TMatchMode, class MBtraceTextOnScreenObserver &, enum TBtraceNotificationPersistence)
+	??OTBtraceTickCount@@QBEHABV0@@Z @ 42 NONAME ; int TBtraceTickCount::operator>(class TBtraceTickCount const &) const
+	?AddObserverL@CBtraceReader@@QAEXAAVMBtraceObserver@@W4TObserverType@1@@Z @ 43 NONAME ; void CBtraceReader::AddObserverL(class MBtraceObserver &, enum CBtraceReader::TObserverType)
+	??0TBtraceProcessId@@QAE@I@Z @ 44 NONAME ; TBtraceProcessId::TBtraceProcessId(unsigned int)
+	??1CBtraceGeneric@@UAE@XZ @ 45 NONAME ; CBtraceGeneric::~CBtraceGeneric(void)
+	?HandleThreadSeenL@MBtraceContextObserver@@UAEXABVTBtraceTickCount@@ABVTBtraceThreadId@@I@Z @ 46 NONAME ; void MBtraceContextObserver::HandleThreadSeenL(class TBtraceTickCount const &, class TBtraceThreadId const &, unsigned int)
+	?NotifyKeyEventL@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@W4TBtraceNotificationPersistence@@@Z @ 47 NONAME ; void CBtraceKeyPress::NotifyKeyEventL(class MBtraceKeyPressObserver &, enum TBtraceNotificationPersistence)
+	?NewL@CBtraceReader@@SAPAV1@W4TMode@1@HHPAVMBtraceLog@@@Z @ 48 NONAME ; class CBtraceReader * CBtraceReader::NewL(enum CBtraceReader::TMode, int, int, class MBtraceLog *)
+	?FastTicksToMicroSeconds@TBtraceUtils@@SA?AVTTimeIntervalMicroSeconds@@AB_K@Z @ 49 NONAME ; class TTimeIntervalMicroSeconds TBtraceUtils::FastTicksToMicroSeconds(unsigned long long const &)
+	?CancelNotifyDomainEvent@CBtraceDomainEvent@@QAEXAAVMBtraceDomainEventObserver@@@Z @ 50 NONAME ; void CBtraceDomainEvent::CancelNotifyDomainEvent(class MBtraceDomainEventObserver &)
+	?CancelNotifyThreadExit@CBtraceContext@@QAEXAAVMBtraceContextObserver@@@Z @ 51 NONAME ; void CBtraceContext::CancelNotifyThreadExit(class MBtraceContextObserver &)
+	??1CBtraceCpuUsage@@UAE@XZ @ 52 NONAME ; CBtraceCpuUsage::~CBtraceCpuUsage(void)
+	?NotifyTextOnScreenL@CBtraceTextOnScreen@@QAEXABVTDesC16@@AAVMBtraceTextOnScreenObserver@@W4TBtraceNotificationPersistence@@@Z @ 53 NONAME ; void CBtraceTextOnScreen::NotifyTextOnScreenL(class TDesC16 const &, class MBtraceTextOnScreenObserver &, enum TBtraceNotificationPersistence)
+	?CancelNotifyWindowGroupSeen@CBtraceContext@@QAEXAAVMBtraceContextObserver@@@Z @ 54 NONAME ; void CBtraceContext::CancelNotifyWindowGroupSeen(class MBtraceContextObserver &)
+	?IntervalInFastTicks@TBtraceTickCount@@QBE_KABV1@@Z @ 55 NONAME ; unsigned long long TBtraceTickCount::IntervalInFastTicks(class TBtraceTickCount const &) const
+	?CancelNotifyFocusChanged@CBtraceFocusChange@@QAEXAAVMBtraceFocusChangeObserver@@@Z @ 56 NONAME ; void CBtraceFocusChange::CancelNotifyFocusChanged(class MBtraceFocusChangeObserver &)
+	?IncRef@CRefCountedObject@@QAEXXZ @ 57 NONAME ; void CRefCountedObject::IncRef(void)
+	?LogBtraceStatus@CBtraceReader@@QAEXXZ @ 58 NONAME ; void CBtraceReader::LogBtraceStatus(void)
+	?RemoveObserver@CBtraceReader@@QAEXIAAVMBtraceObserver@@@Z @ 59 NONAME ; void CBtraceReader::RemoveObserver(unsigned int, class MBtraceObserver &)
+	?NotifyTextOnScreenL@CBtraceTextOnScreen@@QAEXABVTDesC16@@W4TMatchMode@1@AAVMBtraceTextOnScreenObserver@@W4TBtraceNotificationPersistence@@@Z @ 60 NONAME ; void CBtraceTextOnScreen::NotifyTextOnScreenL(class TDesC16 const &, enum CBtraceTextOnScreen::TMatchMode, class MBtraceTextOnScreenObserver &, enum TBtraceNotificationPersistence)
+	??1CBtraceScreenUpdate@@UAE@XZ @ 61 NONAME ; CBtraceScreenUpdate::~CBtraceScreenUpdate(void)
+	?HandleThreadExitL@MBtraceContextObserver@@UAEXABVTBtraceTickCount@@ABVTBtraceThreadId@@W4TExitType@@HABVTDesC16@@I@Z @ 62 NONAME ; void MBtraceContextObserver::HandleThreadExitL(class TBtraceTickCount const &, class TBtraceThreadId const &, enum TExitType, int, class TDesC16 const &, unsigned int)
+	?CancelNotifyTextOnScreen@CBtraceTextOnScreen@@QAEXAAVMBtraceTextOnScreenObserver@@@Z @ 63 NONAME ; void CBtraceTextOnScreen::CancelNotifyTextOnScreen(class MBtraceTextOnScreenObserver &)
+	?WindowGroupId@CBtraceContext@@QBEHABVTBtraceWindowGroupId@@@Z @ 64 NONAME ; int CBtraceContext::WindowGroupId(class TBtraceWindowGroupId const &) const
+	?NotifyTextOnScreenL@CBtraceTextOnScreen@@QAEXABVTDesC16@@HW4TMatchMode@1@AAVMBtraceTextOnScreenObserver@@@Z @ 65 NONAME ; void CBtraceTextOnScreen::NotifyTextOnScreenL(class TDesC16 const &, int, enum CBtraceTextOnScreen::TMatchMode, class MBtraceTextOnScreenObserver &)
+	?FindWindowGroupsByThreadName@CBtraceContext@@QBEXABVTDesC16@@AAV?$RArray@VTBtraceWindowGroupId@@@@@Z @ 66 NONAME ; void CBtraceContext::FindWindowGroupsByThreadName(class TDesC16 const &, class RArray<class TBtraceWindowGroupId> &) const
+	?NotifyWindowGroupSeenL@CBtraceContext@@QAEXABVTDesC16@@AAVMBtraceContextObserver@@IW4TBtraceNotificationPersistence@@@Z @ 67 NONAME ; void CBtraceContext::NotifyWindowGroupSeenL(class TDesC16 const &, class MBtraceContextObserver &, unsigned int, enum TBtraceNotificationPersistence)
+	?NotifyScreenUpdateL@CBtraceScreenUpdate@@QAEXAAVMBtraceScreenUpdateObserver@@@Z @ 68 NONAME ; void CBtraceScreenUpdate::NotifyScreenUpdateL(class MBtraceScreenUpdateObserver &)
+	??0TBtraceIdBase@@IAE@ABV0@@Z @ 69 NONAME ; TBtraceIdBase::TBtraceIdBase(class TBtraceIdBase const &)
+	?NewL@CBtraceScreenUpdate@@SAPAV1@AAVCBtraceReader@@@Z @ 70 NONAME ; class CBtraceScreenUpdate * CBtraceScreenUpdate::NewL(class CBtraceReader &)
+	??0TBtraceWindowGroupId@@QAE@I@Z @ 71 NONAME ; TBtraceWindowGroupId::TBtraceWindowGroupId(unsigned int)
+	?GetReplayStartTickCountL@CBtraceReader@@QAEXAAVTBtraceTickCount@@@Z @ 72 NONAME ; void CBtraceReader::GetReplayStartTickCountL(class TBtraceTickCount &)
+	?CancelNotifyKeyEvent@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@@Z @ 73 NONAME ; void CBtraceKeyPress::CancelNotifyKeyEvent(class MBtraceKeyPressObserver &)
+	?FindWindowGroup@CBtraceContext@@QBEPBVTBtraceWindowGroupId@@H@Z @ 74 NONAME ; class TBtraceWindowGroupId const * CBtraceContext::FindWindowGroup(int) const
+	?NotifyScreenUpdateL@CBtraceScreenUpdate@@QAEXAAVMBtraceScreenUpdateObserver@@W4TBtraceNotificationPersistence@@@Z @ 75 NONAME ; void CBtraceScreenUpdate::NotifyScreenUpdateL(class MBtraceScreenUpdateObserver &, enum TBtraceNotificationPersistence)
+	?MicroSecondsToFastTicks@TBtraceUtils@@SA_KVTTimeIntervalMicroSeconds32@@@Z @ 76 NONAME ; unsigned long long TBtraceUtils::MicroSecondsToFastTicks(class TTimeIntervalMicroSeconds32)
+	??1CBtraceFocusChange@@UAE@XZ @ 77 NONAME ; CBtraceFocusChange::~CBtraceFocusChange(void)
+	?NotifyFocusChangedL@CBtraceFocusChange@@QAEXABVTDesC16@@AAVMBtraceFocusChangeObserver@@W4TBtraceNotificationPersistence@@@Z @ 78 NONAME ; void CBtraceFocusChange::NotifyFocusChangedL(class TDesC16 const &, class MBtraceFocusChangeObserver &, enum TBtraceNotificationPersistence)
+	?NotifyThreadIdleL@CBtraceCpuUsage@@QAEXABVTBtraceThreadId@@ABVTBtraceTickCount@@VTTimeIntervalMicroSeconds32@@AAVMBtraceCpuUsageObserver@@@Z @ 79 NONAME ; void CBtraceCpuUsage::NotifyThreadIdleL(class TBtraceThreadId const &, class TBtraceTickCount const &, class TTimeIntervalMicroSeconds32, class MBtraceCpuUsageObserver &)
+	?RecordBtraceDataToFileL@CBtraceReader@@QAEXABVTDesC16@@@Z @ 80 NONAME ; void CBtraceReader::RecordBtraceDataToFileL(class TDesC16 const &)
+	?RemoveFrameObserver@CBtraceReader@@QAEXAAVMBtraceFrameObserver@@@Z @ 81 NONAME ; void CBtraceReader::RemoveFrameObserver(class MBtraceFrameObserver &)
+	??0TBtraceProcessId@@QAE@ABV0@@Z @ 82 NONAME ; TBtraceProcessId::TBtraceProcessId(class TBtraceProcessId const &)
+	??1CBtracePubSub@@UAE@XZ @ 83 NONAME ; CBtracePubSub::~CBtracePubSub(void)
+	?NotifyIntegerPropertyChangedL@CBtracePubSub@@QAEXPAI0PAHAAVMBtracePubSubObserver@@W4TBtraceNotificationPersistence@@@Z @ 84 NONAME ; void CBtracePubSub::NotifyIntegerPropertyChangedL(unsigned int *, unsigned int *, int *, class MBtracePubSubObserver &, enum TBtraceNotificationPersistence)
+	?AddObserverL@CBtraceReader@@QAEXIAAVMBtraceObserver@@@Z @ 85 NONAME ; void CBtraceReader::AddObserverL(unsigned int, class MBtraceObserver &)
+	?NotifyDataPropertyChangedL@CBtracePubSub@@QAEXPAI0PBVTDesC8@@AAVMBtracePubSubObserver@@W4TBtraceNotificationPersistence@@@Z @ 86 NONAME ; void CBtracePubSub::NotifyDataPropertyChangedL(unsigned int *, unsigned int *, class TDesC8 const *, class MBtracePubSubObserver &, enum TBtraceNotificationPersistence)
+	?NanoTicksToMicroSeconds@TBtraceUtils@@SA?AVTTimeIntervalMicroSeconds@@K@Z @ 87 NONAME ; class TTimeIntervalMicroSeconds TBtraceUtils::NanoTicksToMicroSeconds(unsigned long)
+	?NotifyThreadGoneL@CBtraceContext@@QAEXABVTDesC16@@AAVMBtraceContextObserver@@IW4TBtraceNotificationPersistence@@@Z @ 88 NONAME ; void CBtraceContext::NotifyThreadGoneL(class TDesC16 const &, class MBtraceContextObserver &, unsigned int, enum TBtraceNotificationPersistence)
+	?CancelNotifyPropertyChanged@CBtracePubSub@@QAEXAAVMBtracePubSubObserver@@@Z @ 89 NONAME ; void CBtracePubSub::CancelNotifyPropertyChanged(class MBtracePubSubObserver &)
+	?NewL@CBtraceDomainEvent@@SAPAV1@AAVCBtraceReader@@@Z @ 90 NONAME ; class CBtraceDomainEvent * CBtraceDomainEvent::NewL(class CBtraceReader &)
+	?AddFrameObseverL@CBtraceReader@@QAEXAAVMBtraceFrameObserver@@@Z @ 91 NONAME ; void CBtraceReader::AddFrameObseverL(class MBtraceFrameObserver &)
+	?IntervalInMicroSeconds@TBtraceTickCount@@QBE?AVTTimeIntervalMicroSeconds@@ABV1@@Z @ 92 NONAME ; class TTimeIntervalMicroSeconds TBtraceTickCount::IntervalInMicroSeconds(class TBtraceTickCount const &) const
+	?NewL@CBtraceKeyPress@@SAPAV1@AAVCBtraceReader@@@Z @ 93 NONAME ; class CBtraceKeyPress * CBtraceKeyPress::NewL(class CBtraceReader &)
+	?NotifyPropertyChangedL@CBtracePubSub@@QAEXPAI0AAVMBtracePubSubObserver@@W4TBtraceNotificationPersistence@@@Z @ 94 NONAME ; void CBtracePubSub::NotifyPropertyChangedL(unsigned int *, unsigned int *, class MBtracePubSubObserver &, enum TBtraceNotificationPersistence)
+	?Reset@CBtraceReader@@QAEXXZ @ 95 NONAME ; void CBtraceReader::Reset(void)
+	?ThreadName@CBtraceContext@@QBEABVTDesC16@@ABVTBtraceThreadId@@@Z @ 96 NONAME ; class TDesC16 const & CBtraceContext::ThreadName(class TBtraceThreadId const &) const
+	?WindowGroupName@CBtraceContext@@QBEABVTDesC16@@ABVTBtraceWindowGroupId@@@Z @ 97 NONAME ; class TDesC16 const & CBtraceContext::WindowGroupName(class TBtraceWindowGroupId const &) const
+	??8TBtraceIdBase@@QBEHABV0@@Z @ 98 NONAME ; int TBtraceIdBase::operator==(class TBtraceIdBase const &) const
+	?DecRef@CRefCountedObject@@QAEXXZ @ 99 NONAME ; void CRefCountedObject::DecRef(void)
+	??1CBtraceAppResponse@@UAE@XZ @ 100 NONAME ; CBtraceAppResponse::~CBtraceAppResponse(void)
+	?CurrentTickCount@CBtraceReader@@QBEABVTBtraceTickCount@@XZ @ 101 NONAME ; class TBtraceTickCount const & CBtraceReader::CurrentTickCount(void) const
+	?NotifyAppResponseL@CBtraceAppResponse@@QAEXAAVMBtraceAppResponseObserver@@ABVTProcessId@@W4TBtraceNotificationPersistence@@@Z @ 102 NONAME ; void CBtraceAppResponse::NotifyAppResponseL(class MBtraceAppResponseObserver &, class TProcessId const &, enum TBtraceNotificationPersistence)
+	?NotifyContextSwitchL@CBtraceCpuUsage@@QAEXABVTBtraceThreadId@@AAVMBtraceCpuUsageObserver@@@Z @ 103 NONAME ; void CBtraceCpuUsage::NotifyContextSwitchL(class TBtraceThreadId const &, class MBtraceCpuUsageObserver &)
+	??PTBtraceTickCount@@QBEHABV0@@Z @ 104 NONAME ; int TBtraceTickCount::operator>=(class TBtraceTickCount const &) const
+	?CancelNotifyUnclassifiedData@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@@Z @ 105 NONAME ; void CBtraceKeyPress::CancelNotifyUnclassifiedData(class MBtraceKeyPressObserver &)
+	?GetFullThreadName@CBtraceContext@@QBEXABVTBtraceThreadId@@AAVTDes16@@@Z @ 106 NONAME ; void CBtraceContext::GetFullThreadName(class TBtraceThreadId const &, class TDes16 &) const
+	??NTBtraceTickCount@@QBEHABV0@@Z @ 107 NONAME ; int TBtraceTickCount::operator<=(class TBtraceTickCount const &) const
+	?AddObserverL@CBtraceReader@@QAEXAAVMBtraceObserver@@@Z @ 108 NONAME ; void CBtraceReader::AddObserverL(class MBtraceObserver &)
+	?CancelNotifyScreenUpdate@CBtraceScreenUpdate@@QAEXAAVMBtraceScreenUpdateObserver@@@Z @ 109 NONAME ; void CBtraceScreenUpdate::CancelNotifyScreenUpdate(class MBtraceScreenUpdateObserver &)
+	?NewL@CBtraceFocusChange@@SAPAV1@AAVCBtraceReader@@AAVCBtraceContext@@@Z @ 110 NONAME ; class CBtraceFocusChange * CBtraceFocusChange::NewL(class CBtraceReader &, class CBtraceContext &)
+	?NewL@CBtraceTextOnScreen@@SAPAV1@AAVCBtraceReader@@@Z @ 111 NONAME ; class CBtraceTextOnScreen * CBtraceTextOnScreen::NewL(class CBtraceReader &)
+	??0TBtraceWindowGroupId@@QAE@ABV0@@Z @ 112 NONAME ; TBtraceWindowGroupId::TBtraceWindowGroupId(class TBtraceWindowGroupId const &)
+	?NotifyCpuUsageL@CBtraceCpuUsage@@QAEXKVTTimeIntervalMicroSeconds32@@AAVMBtraceCpuUsageObserver@@@Z @ 113 NONAME ; void CBtraceCpuUsage::NotifyCpuUsageL(unsigned long, class TTimeIntervalMicroSeconds32, class MBtraceCpuUsageObserver &)
+	?NotifyAppResponseL@CBtraceAppResponse@@QAEXAAVMBtraceAppResponseObserver@@ABVTProcessId@@@Z @ 114 NONAME ; void CBtraceAppResponse::NotifyAppResponseL(class MBtraceAppResponseObserver &, class TProcessId const &)
+	?ProcessName@CBtraceContext@@QBEABVTDesC16@@ABVTBtraceProcessId@@@Z @ 115 NONAME ; class TDesC16 const & CBtraceContext::ProcessName(class TBtraceProcessId const &) const
+	?EnableCategoryL@CBtraceReader@@QAEXI@Z @ 116 NONAME ; void CBtraceReader::EnableCategoryL(unsigned int)
+	?NotifyGenericEventL@CBtraceGeneric@@QAEXAAVMBtraceGenericObserver@@@Z @ 117 NONAME ; void CBtraceGeneric::NotifyGenericEventL(class MBtraceGenericObserver &)
+	?NotifyThreadIdleL@CBtraceCpuUsage@@QAEXABVTBtraceThreadId@@ABVTBtraceTickCount@@VTTimeIntervalMicroSeconds32@@AAVMBtraceCpuUsageObserver@@W4TBtraceNotificationPersistence@@@Z @ 118 NONAME ; void CBtraceCpuUsage::NotifyThreadIdleL(class TBtraceThreadId const &, class TBtraceTickCount const &, class TTimeIntervalMicroSeconds32, class MBtraceCpuUsageObserver &, enum TBtraceNotificationPersistence)
+	?HandleWindowGroupSeenL@MBtraceContextObserver@@UAEXABVTBtraceTickCount@@ABVTBtraceWindowGroupId@@I@Z @ 119 NONAME ; void MBtraceContextObserver::HandleWindowGroupSeenL(class TBtraceTickCount const &, class TBtraceWindowGroupId const &, unsigned int)
+	??0TBtraceWindowGroupId@@QAE@XZ @ 120 NONAME ; TBtraceWindowGroupId::TBtraceWindowGroupId(void)
+	?ThreadId@CBtraceContext@@QBE?AVTThreadId@@ABVTBtraceThreadId@@@Z @ 121 NONAME ; class TThreadId CBtraceContext::ThreadId(class TBtraceThreadId const &) const
+	??0TBtraceTickCount@@QAE@XZ @ 122 NONAME ; TBtraceTickCount::TBtraceTickCount(void)
+	?NotifyScreenUpdateL@CBtraceScreenUpdate@@QAEXHABVTRect@@AAVMBtraceScreenUpdateObserver@@@Z @ 123 NONAME ; void CBtraceScreenUpdate::NotifyScreenUpdateL(int, class TRect const &, class MBtraceScreenUpdateObserver &)
+	??0TBtraceThreadId@@QAE@ABV0@@Z @ 124 NONAME ; TBtraceThreadId::TBtraceThreadId(class TBtraceThreadId const &)
+	?NewL@CBtraceReader@@SAPAV1@ABVTDesC16@@PAVMBtraceLog@@@Z @ 125 NONAME ; class CBtraceReader * CBtraceReader::NewL(class TDesC16 const &, class MBtraceLog *)
+	?NotifyThreadSeenL@CBtraceContext@@QAEXABVTDesC16@@AAVMBtraceContextObserver@@IW4TBtraceNotificationPersistence@@@Z @ 126 NONAME ; void CBtraceContext::NotifyThreadSeenL(class TDesC16 const &, class MBtraceContextObserver &, unsigned int, enum TBtraceNotificationPersistence)
+	?NotifyUnclassifiedDataL@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@@Z @ 127 NONAME ; void CBtraceKeyPress::NotifyUnclassifiedDataL(class MBtraceKeyPressObserver &)
+	?NotifyDomainEventL@CBtraceDomainEvent@@QAEXIIIAAVMBtraceDomainEventObserver@@W4TBtraceNotificationPersistence@@@Z @ 128 NONAME ; void CBtraceDomainEvent::NotifyDomainEventL(unsigned int, unsigned int, unsigned int, class MBtraceDomainEventObserver &, enum TBtraceNotificationPersistence)
+	?IntervalInNanoTicks@TBtraceTickCount@@QBEKABV1@@Z @ 129 NONAME ; unsigned long TBtraceTickCount::IntervalInNanoTicks(class TBtraceTickCount const &) const
+	??0TBtraceProcessId@@QAE@XZ @ 130 NONAME ; TBtraceProcessId::TBtraceProcessId(void)
+	?NotifyCpuUsageL@CBtraceCpuUsage@@QAEXKVTTimeIntervalMicroSeconds32@@AAVMBtraceCpuUsageObserver@@W4TBtraceNotificationPersistence@@@Z @ 131 NONAME ; void CBtraceCpuUsage::NotifyCpuUsageL(unsigned long, class TTimeIntervalMicroSeconds32, class MBtraceCpuUsageObserver &, enum TBtraceNotificationPersistence)
+	?RefCount@CRefCountedObject@@QBEHXZ @ 132 NONAME ; int CRefCountedObject::RefCount(void) const
+	?DisableCategoryL@CBtraceReader@@QAEXI@Z @ 133 NONAME ; void CBtraceReader::DisableCategoryL(unsigned int)
+	?FindWindowGroupsL@CBtraceContext@@QBEXABVTDesC16@@AAV?$RArray@VTBtraceWindowGroupId@@@@@Z @ 134 NONAME ; void CBtraceContext::FindWindowGroupsL(class TDesC16 const &, class RArray<class TBtraceWindowGroupId> &) const
+	?HandleThreadGoneL@MBtraceContextObserver@@UAEXABVTBtraceTickCount@@ABVTBtraceThreadId@@I@Z @ 135 NONAME ; void MBtraceContextObserver::HandleThreadGoneL(class TBtraceTickCount const &, class TBtraceThreadId const &, unsigned int)
+	?NotifyPointerEventL@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@@Z @ 136 NONAME ; void CBtraceKeyPress::NotifyPointerEventL(class MBtraceKeyPressObserver &)
+	?CancelNotifyThreadSeen@CBtraceContext@@QAEXAAVMBtraceContextObserver@@@Z @ 137 NONAME ; void CBtraceContext::CancelNotifyThreadSeen(class MBtraceContextObserver &)
+	??MTBtraceTickCount@@QBEHABV0@@Z @ 138 NONAME ; int TBtraceTickCount::operator<(class TBtraceTickCount const &) const
+	?NotifyThreadSeenL@CBtraceContext@@QAEXABVTDesC16@@AAVMBtraceContextObserver@@I@Z @ 139 NONAME ; void CBtraceContext::NotifyThreadSeenL(class TDesC16 const &, class MBtraceContextObserver &, unsigned int)
+	?CancelNotifyRawKeyEvent@CBtraceKeyPress@@QAEXAAVMBtraceKeyPressObserver@@@Z @ 140 NONAME ; void CBtraceKeyPress::CancelNotifyRawKeyEvent(class MBtraceKeyPressObserver &)
+	?CancelNotifyThreadIdle@CBtraceCpuUsage@@QAEXAAVMBtraceCpuUsageObserver@@@Z @ 141 NONAME ; void CBtraceCpuUsage::CancelNotifyThreadIdle(class MBtraceCpuUsageObserver &)
+	??1CBtraceReader@@UAE@XZ @ 142 NONAME ; CBtraceReader::~CBtraceReader(void)
+	?NotifyWindowGroupSeenByThreadNameL@CBtraceContext@@QAEXABVTDesC16@@AAVMBtraceContextObserver@@IW4TBtraceNotificationPersistence@@@Z @ 143 NONAME ; void CBtraceContext::NotifyWindowGroupSeenByThreadNameL(class TDesC16 const &, class MBtraceContextObserver &, unsigned int, enum TBtraceNotificationPersistence)
+	?NewL@CBtraceCpuUsage@@SAPAV1@AAVCBtraceReader@@AAVCBtraceContext@@@Z @ 144 NONAME ; class CBtraceCpuUsage * CBtraceCpuUsage::NewL(class CBtraceReader &, class CBtraceContext &)
+	?Set@TBtraceIdBase@@QAEXI@Z @ 145 NONAME ; void TBtraceIdBase::Set(unsigned int)
+	?DisableBtrace@CBtraceReader@@QAEXXZ @ 146 NONAME ; void CBtraceReader::DisableBtrace(void)
+	?NotifyDomainEventL@CBtraceDomainEvent@@QAEXIAAVMBtraceDomainEventObserver@@W4TBtraceNotificationPersistence@@@Z @ 147 NONAME ; void CBtraceDomainEvent::NotifyDomainEventL(unsigned int, class MBtraceDomainEventObserver &, enum TBtraceNotificationPersistence)
+	??0TBtraceIdBase@@IAE@I@Z @ 148 NONAME ; TBtraceIdBase::TBtraceIdBase(unsigned int)
+	??1CBtraceKeyPress@@UAE@XZ @ 149 NONAME ; CBtraceKeyPress::~CBtraceKeyPress(void)
+	?NotifyFocusChangedL@CBtraceFocusChange@@QAEXABVTDesC16@@AAVMBtraceFocusChangeObserver@@@Z @ 150 NONAME ; void CBtraceFocusChange::NotifyFocusChangedL(class TDesC16 const &, class MBtraceFocusChangeObserver &)
+	?SetMultipartReassemblyL@CBtraceReader@@QAEXH@Z @ 151 NONAME ; void CBtraceReader::SetMultipartReassemblyL(int)
+	?MicroSecondsToNanoTicks@TBtraceUtils@@SAKVTTimeIntervalMicroSeconds32@@@Z @ 152 NONAME ; unsigned long TBtraceUtils::MicroSecondsToNanoTicks(class TTimeIntervalMicroSeconds32)
+	?Start@CBtraceReader@@QAEXABVTBtraceTickCount@@VTTimeIntervalMicroSeconds32@@@Z @ 153 NONAME ; void CBtraceReader::Start(class TBtraceTickCount const &, class TTimeIntervalMicroSeconds32)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/eabi/btrace_parseru.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,192 @@
+EXPORTS
+	_ZN12TBtraceUtils23FastTicksToMicroSecondsERKy @ 1 NONAME
+	_ZN12TBtraceUtils23MicroSecondsToFastTicksE27TTimeIntervalMicroSeconds32 @ 2 NONAME
+	_ZN12TBtraceUtils23MicroSecondsToNanoTicksE27TTimeIntervalMicroSeconds32 @ 3 NONAME
+	_ZN12TBtraceUtils23NanoTicksToMicroSecondsEm @ 4 NONAME
+	_ZN12TBtraceUtils26DebugOverrideTimerSettingsEiii @ 5 NONAME
+	_ZN13CBtracePubSub22NotifyPropertyChangedLEPjS0_R21MBtracePubSubObserver30TBtraceNotificationPersistence @ 6 NONAME
+	_ZN13CBtracePubSub22NotifyPropertyChangedLER21MBtracePubSubObserver @ 7 NONAME
+	_ZN13CBtracePubSub26NotifyDataPropertyChangedLEPjS0_PK6TDesC8R21MBtracePubSubObserver30TBtraceNotificationPersistence @ 8 NONAME
+	_ZN13CBtracePubSub27CancelNotifyPropertyChangedER21MBtracePubSubObserver @ 9 NONAME
+	_ZN13CBtracePubSub29NotifyIntegerPropertyChangedLEPjS0_PiR21MBtracePubSubObserver30TBtraceNotificationPersistence @ 10 NONAME
+	_ZN13CBtracePubSub4NewLER13CBtraceReader @ 11 NONAME
+	_ZN13CBtracePubSubD0Ev @ 12 NONAME
+	_ZN13CBtracePubSubD1Ev @ 13 NONAME
+	_ZN13CBtracePubSubD2Ev @ 14 NONAME
+	_ZN13CBtraceReader12AddObserverLER15MBtraceObserver @ 15 NONAME
+	_ZN13CBtraceReader12AddObserverLER15MBtraceObserverNS_13TObserverTypeE @ 16 NONAME
+	_ZN13CBtraceReader12AddObserverLEjR15MBtraceObserver @ 17 NONAME
+	_ZN13CBtraceReader12AddObserverLEjR15MBtraceObserverNS_13TObserverTypeE @ 18 NONAME
+	_ZN13CBtraceReader12SynchronizeLEv @ 19 NONAME
+	_ZN13CBtraceReader13DisableBtraceEv @ 20 NONAME
+	_ZN13CBtraceReader14RemoveObserverER15MBtraceObserver @ 21 NONAME
+	_ZN13CBtraceReader14RemoveObserverEjR15MBtraceObserver @ 22 NONAME
+	_ZN13CBtraceReader14SetBufferSizeLEi @ 23 NONAME
+	_ZN13CBtraceReader15EnableCategoryLEj @ 24 NONAME
+	_ZN13CBtraceReader15LogBtraceStatusEv @ 25 NONAME
+	_ZN13CBtraceReader16AddFrameObseverLER20MBtraceFrameObserver @ 26 NONAME
+	_ZN13CBtraceReader16DisableCategoryLEj @ 27 NONAME
+	_ZN13CBtraceReader18SetReplayFileNameLERK7TDesC16 @ 28 NONAME
+	_ZN13CBtraceReader19RemoveFrameObserverER20MBtraceFrameObserver @ 29 NONAME
+	_ZN13CBtraceReader23RecordBtraceDataToFileLERK7TDesC16 @ 30 NONAME
+	_ZN13CBtraceReader23SetMultipartReassemblyLEi @ 31 NONAME
+	_ZN13CBtraceReader24GetReplayStartTickCountLER16TBtraceTickCount @ 32 NONAME
+	_ZN13CBtraceReader4NewLENS_5TModeEiiP10MBtraceLog @ 33 NONAME
+	_ZN13CBtraceReader4NewLERK7TDesC16P10MBtraceLog @ 34 NONAME
+	_ZN13CBtraceReader5ResetEv @ 35 NONAME
+	_ZN13CBtraceReader5StartERK16TBtraceTickCount @ 36 NONAME
+	_ZN13CBtraceReader6FlushLEv @ 37 NONAME
+	_ZN13CBtraceReaderD0Ev @ 38 NONAME
+	_ZN13CBtraceReaderD1Ev @ 39 NONAME
+	_ZN13CBtraceReaderD2Ev @ 40 NONAME
+	_ZN13TBtraceIdBase3SetEj @ 41 NONAME
+	_ZN13TBtraceIdBaseC1ERKS_ @ 42 NONAME
+	_ZN13TBtraceIdBaseC1Ej @ 43 NONAME
+	_ZN13TBtraceIdBaseC1Ev @ 44 NONAME
+	_ZN13TBtraceIdBaseC2ERKS_ @ 45 NONAME
+	_ZN13TBtraceIdBaseC2Ej @ 46 NONAME
+	_ZN13TBtraceIdBaseC2Ev @ 47 NONAME
+	_ZN14CBtraceContext17NotifyThreadExitLERK7TDesC16jPiPS1_R22MBtraceContextObserverj30TBtraceNotificationPersistence @ 48 NONAME
+	_ZN14CBtraceContext17NotifyThreadGoneLERK7TDesC16R22MBtraceContextObserverj @ 49 NONAME
+	_ZN14CBtraceContext17NotifyThreadGoneLERK7TDesC16R22MBtraceContextObserverj30TBtraceNotificationPersistence @ 50 NONAME
+	_ZN14CBtraceContext17NotifyThreadSeenLERK7TDesC16R22MBtraceContextObserverj @ 51 NONAME
+	_ZN14CBtraceContext17NotifyThreadSeenLERK7TDesC16R22MBtraceContextObserverj30TBtraceNotificationPersistence @ 52 NONAME
+	_ZN14CBtraceContext22CancelNotifyThreadExitER22MBtraceContextObserver @ 53 NONAME
+	_ZN14CBtraceContext22CancelNotifyThreadGoneER22MBtraceContextObserver @ 54 NONAME
+	_ZN14CBtraceContext22CancelNotifyThreadSeenER22MBtraceContextObserver @ 55 NONAME
+	_ZN14CBtraceContext22NotifyWindowGroupSeenLERK7TDesC16R22MBtraceContextObserverj30TBtraceNotificationPersistence @ 56 NONAME
+	_ZN14CBtraceContext27CancelNotifyWindowGroupSeenER22MBtraceContextObserver @ 57 NONAME
+	_ZN14CBtraceContext34NotifyWindowGroupSeenByThreadNameLERK7TDesC16R22MBtraceContextObserverj30TBtraceNotificationPersistence @ 58 NONAME
+	_ZN14CBtraceContext4NewLER13CBtraceReaderNS_5TModeE @ 59 NONAME
+	_ZN14CBtraceContextD0Ev @ 60 NONAME
+	_ZN14CBtraceContextD1Ev @ 61 NONAME
+	_ZN14CBtraceContextD2Ev @ 62 NONAME
+	_ZN14CBtraceGeneric19NotifyGenericEventLER22MBtraceGenericObserver @ 63 NONAME
+	_ZN14CBtraceGeneric4NewLER13CBtraceReader @ 64 NONAME
+	_ZN14CBtraceGenericD0Ev @ 65 NONAME
+	_ZN14CBtraceGenericD1Ev @ 66 NONAME
+	_ZN14CBtraceGenericD2Ev @ 67 NONAME
+	_ZN15CBtraceCpuUsage15NotifyCpuUsageLEm27TTimeIntervalMicroSeconds32R23MBtraceCpuUsageObserver @ 68 NONAME
+	_ZN15CBtraceCpuUsage15NotifyCpuUsageLEm27TTimeIntervalMicroSeconds32R23MBtraceCpuUsageObserver30TBtraceNotificationPersistence @ 69 NONAME
+	_ZN15CBtraceCpuUsage17NotifyThreadIdleLERK15TBtraceThreadIdRK16TBtraceTickCount27TTimeIntervalMicroSeconds32R23MBtraceCpuUsageObserver @ 70 NONAME
+	_ZN15CBtraceCpuUsage17NotifyThreadIdleLERK15TBtraceThreadIdRK16TBtraceTickCount27TTimeIntervalMicroSeconds32R23MBtraceCpuUsageObserver30TBtraceNotificationPersistence @ 71 NONAME
+	_ZN15CBtraceCpuUsage20NotifyContextSwitchLERK15TBtraceThreadIdR23MBtraceCpuUsageObserver @ 72 NONAME
+	_ZN15CBtraceCpuUsage22CancelNotifyThreadIdleER23MBtraceCpuUsageObserver @ 73 NONAME
+	_ZN15CBtraceCpuUsage4NewLER13CBtraceReaderR14CBtraceContext @ 74 NONAME
+	_ZN15CBtraceCpuUsageD0Ev @ 75 NONAME
+	_ZN15CBtraceCpuUsageD1Ev @ 76 NONAME
+	_ZN15CBtraceCpuUsageD2Ev @ 77 NONAME
+	_ZN15CBtraceKeyPress15NotifyKeyEventLER23MBtraceKeyPressObserver @ 78 NONAME
+	_ZN15CBtraceKeyPress15NotifyKeyEventLER23MBtraceKeyPressObserver30TBtraceNotificationPersistence @ 79 NONAME
+	_ZN15CBtraceKeyPress18NotifyRawKeyEventLER23MBtraceKeyPressObserver @ 80 NONAME
+	_ZN15CBtraceKeyPress18NotifyRawKeyEventLER23MBtraceKeyPressObserver30TBtraceNotificationPersistence @ 81 NONAME
+	_ZN15CBtraceKeyPress19NotifyPointerEventLER23MBtraceKeyPressObserver @ 82 NONAME
+	_ZN15CBtraceKeyPress19NotifyPointerEventLER23MBtraceKeyPressObserver30TBtraceNotificationPersistence @ 83 NONAME
+	_ZN15CBtraceKeyPress20CancelNotifyKeyEventER23MBtraceKeyPressObserver @ 84 NONAME
+	_ZN15CBtraceKeyPress23CancelNotifyRawKeyEventER23MBtraceKeyPressObserver @ 85 NONAME
+	_ZN15CBtraceKeyPress23NotifyUnclassifiedDataLER23MBtraceKeyPressObserver @ 86 NONAME
+	_ZN15CBtraceKeyPress23NotifyUnclassifiedDataLER23MBtraceKeyPressObserver30TBtraceNotificationPersistence @ 87 NONAME
+	_ZN15CBtraceKeyPress24CancelNotifyPointerEventER23MBtraceKeyPressObserver @ 88 NONAME
+	_ZN15CBtraceKeyPress28CancelNotifyUnclassifiedDataER23MBtraceKeyPressObserver @ 89 NONAME
+	_ZN15CBtraceKeyPress4NewLER13CBtraceReader @ 90 NONAME
+	_ZN15CBtraceKeyPressD0Ev @ 91 NONAME
+	_ZN15CBtraceKeyPressD1Ev @ 92 NONAME
+	_ZN15CBtraceKeyPressD2Ev @ 93 NONAME
+	_ZN15TBtraceThreadIdC1ERKS_ @ 94 NONAME
+	_ZN15TBtraceThreadIdC1Ej @ 95 NONAME
+	_ZN15TBtraceThreadIdC1Ev @ 96 NONAME
+	_ZN15TBtraceThreadIdC2ERKS_ @ 97 NONAME
+	_ZN15TBtraceThreadIdC2Ej @ 98 NONAME
+	_ZN15TBtraceThreadIdC2Ev @ 99 NONAME
+	_ZN16TBtraceProcessIdC1ERKS_ @ 100 NONAME
+	_ZN16TBtraceProcessIdC1Ej @ 101 NONAME
+	_ZN16TBtraceProcessIdC1Ev @ 102 NONAME
+	_ZN16TBtraceProcessIdC2ERKS_ @ 103 NONAME
+	_ZN16TBtraceProcessIdC2Ej @ 104 NONAME
+	_ZN16TBtraceProcessIdC2Ev @ 105 NONAME
+	_ZN16TBtraceTickCount8SetToNowEv @ 106 NONAME
+	_ZN16TBtraceTickCountC1Ev @ 107 NONAME
+	_ZN16TBtraceTickCountC2Ev @ 108 NONAME
+	_ZN17CRefCountedObject6DecRefEv @ 109 NONAME
+	_ZN17CRefCountedObject6IncRefEv @ 110 NONAME
+	_ZN18CBtraceAppResponse18NotifyAppResponseLER26MBtraceAppResponseObserverRK10TProcessId @ 111 NONAME
+	_ZN18CBtraceAppResponse18NotifyAppResponseLER26MBtraceAppResponseObserverRK10TProcessId30TBtraceNotificationPersistence @ 112 NONAME
+	_ZN18CBtraceAppResponse23CancelNotifyAppResponseER26MBtraceAppResponseObserver @ 113 NONAME
+	_ZN18CBtraceAppResponse4NewLER13CBtraceReader @ 114 NONAME
+	_ZN18CBtraceAppResponseD0Ev @ 115 NONAME
+	_ZN18CBtraceAppResponseD1Ev @ 116 NONAME
+	_ZN18CBtraceAppResponseD2Ev @ 117 NONAME
+	_ZN18CBtraceDomainEvent18NotifyDomainEventLEjR26MBtraceDomainEventObserver30TBtraceNotificationPersistence @ 118 NONAME
+	_ZN18CBtraceDomainEvent18NotifyDomainEventLEjjR26MBtraceDomainEventObserver30TBtraceNotificationPersistence @ 119 NONAME
+	_ZN18CBtraceDomainEvent18NotifyDomainEventLEjjjR26MBtraceDomainEventObserver30TBtraceNotificationPersistence @ 120 NONAME
+	_ZN18CBtraceDomainEvent18NotifyDomainEventLEjjjjR26MBtraceDomainEventObserver30TBtraceNotificationPersistence @ 121 NONAME
+	_ZN18CBtraceDomainEvent23CancelNotifyDomainEventER26MBtraceDomainEventObserver @ 122 NONAME
+	_ZN18CBtraceDomainEvent4NewLER13CBtraceReader @ 123 NONAME
+	_ZN18CBtraceDomainEventD0Ev @ 124 NONAME
+	_ZN18CBtraceDomainEventD1Ev @ 125 NONAME
+	_ZN18CBtraceDomainEventD2Ev @ 126 NONAME
+	_ZN18CBtraceFocusChange19NotifyFocusChangedLERK7TDesC16R26MBtraceFocusChangeObserver @ 127 NONAME
+	_ZN18CBtraceFocusChange19NotifyFocusChangedLERK7TDesC16R26MBtraceFocusChangeObserver30TBtraceNotificationPersistence @ 128 NONAME
+	_ZN18CBtraceFocusChange24CancelNotifyFocusChangedER26MBtraceFocusChangeObserver @ 129 NONAME
+	_ZN18CBtraceFocusChange4NewLER13CBtraceReaderR14CBtraceContext @ 130 NONAME
+	_ZN18CBtraceFocusChangeD0Ev @ 131 NONAME
+	_ZN18CBtraceFocusChangeD1Ev @ 132 NONAME
+	_ZN18CBtraceFocusChangeD2Ev @ 133 NONAME
+	_ZN19CBtraceScreenUpdate19NotifyScreenUpdateLER27MBtraceScreenUpdateObserver @ 134 NONAME
+	_ZN19CBtraceScreenUpdate19NotifyScreenUpdateLER27MBtraceScreenUpdateObserver30TBtraceNotificationPersistence @ 135 NONAME
+	_ZN19CBtraceScreenUpdate19NotifyScreenUpdateLEiRK5TRectR27MBtraceScreenUpdateObserver @ 136 NONAME
+	_ZN19CBtraceScreenUpdate19NotifyScreenUpdateLEiRK5TRectR27MBtraceScreenUpdateObserver30TBtraceNotificationPersistence @ 137 NONAME
+	_ZN19CBtraceScreenUpdate24CancelNotifyScreenUpdateER27MBtraceScreenUpdateObserver @ 138 NONAME
+	_ZN19CBtraceScreenUpdate4NewLER13CBtraceReader @ 139 NONAME
+	_ZN19CBtraceScreenUpdateD0Ev @ 140 NONAME
+	_ZN19CBtraceScreenUpdateD1Ev @ 141 NONAME
+	_ZN19CBtraceScreenUpdateD2Ev @ 142 NONAME
+	_ZN19CBtraceTextOnScreen19NotifyTextOnScreenLERK7TDesC16NS_10TMatchModeER27MBtraceTextOnScreenObserver30TBtraceNotificationPersistence @ 143 NONAME
+	_ZN19CBtraceTextOnScreen19NotifyTextOnScreenLERK7TDesC16R27MBtraceTextOnScreenObserver @ 144 NONAME
+	_ZN19CBtraceTextOnScreen19NotifyTextOnScreenLERK7TDesC16R27MBtraceTextOnScreenObserver30TBtraceNotificationPersistence @ 145 NONAME
+	_ZN19CBtraceTextOnScreen19NotifyTextOnScreenLERK7TDesC16iNS_10TMatchModeER27MBtraceTextOnScreenObserver @ 146 NONAME
+	_ZN19CBtraceTextOnScreen19NotifyTextOnScreenLERK7TDesC16iNS_10TMatchModeER27MBtraceTextOnScreenObserver30TBtraceNotificationPersistence @ 147 NONAME
+	_ZN19CBtraceTextOnScreen24CancelNotifyTextOnScreenER27MBtraceTextOnScreenObserver @ 148 NONAME
+	_ZN19CBtraceTextOnScreen4NewLER13CBtraceReader @ 149 NONAME
+	_ZN19CBtraceTextOnScreenD0Ev @ 150 NONAME
+	_ZN19CBtraceTextOnScreenD1Ev @ 151 NONAME
+	_ZN19CBtraceTextOnScreenD2Ev @ 152 NONAME
+	_ZN20TBtraceWindowGroupIdC1ERKS_ @ 153 NONAME
+	_ZN20TBtraceWindowGroupIdC1Ej @ 154 NONAME
+	_ZN20TBtraceWindowGroupIdC1Ev @ 155 NONAME
+	_ZN20TBtraceWindowGroupIdC2ERKS_ @ 156 NONAME
+	_ZN20TBtraceWindowGroupIdC2Ej @ 157 NONAME
+	_ZN20TBtraceWindowGroupIdC2Ev @ 158 NONAME
+	_ZN22MBtraceContextObserver17HandleThreadExitLERK16TBtraceTickCountRK15TBtraceThreadId9TExitTypeiRK7TDesC16j @ 159 NONAME
+	_ZN22MBtraceContextObserver17HandleThreadGoneLERK16TBtraceTickCountRK15TBtraceThreadIdj @ 160 NONAME
+	_ZN22MBtraceContextObserver17HandleThreadSeenLERK16TBtraceTickCountRK15TBtraceThreadIdj @ 161 NONAME
+	_ZN22MBtraceContextObserver22HandleWindowGroupSeenLERK16TBtraceTickCountRK20TBtraceWindowGroupIdj @ 162 NONAME
+	_ZNK13CBtraceReader16CurrentTickCountEv @ 163 NONAME
+	_ZNK13TBtraceIdBase5ValueEv @ 164 NONAME
+	_ZNK13TBtraceIdBaseeqERKS_ @ 165 NONAME
+	_ZNK14CBtraceContext10FindThreadERK9TThreadId @ 166 NONAME
+	_ZNK14CBtraceContext10FindThreadEm @ 167 NONAME
+	_ZNK14CBtraceContext10ThreadNameERK15TBtraceThreadId @ 168 NONAME
+	_ZNK14CBtraceContext11ProcessNameERK16TBtraceProcessId @ 169 NONAME
+	_ZNK14CBtraceContext12FindThreadsLERK7TDesC16R6RArrayI15TBtraceThreadIdE @ 170 NONAME
+	_ZNK14CBtraceContext13WindowGroupIdERK20TBtraceWindowGroupId @ 171 NONAME
+	_ZNK14CBtraceContext15FindWindowGroupEi @ 172 NONAME
+	_ZNK14CBtraceContext15WindowGroupNameERK20TBtraceWindowGroupId @ 173 NONAME
+	_ZNK14CBtraceContext17FindWindowGroupsLERK7TDesC16R6RArrayI20TBtraceWindowGroupIdE @ 174 NONAME
+	_ZNK14CBtraceContext17GetFullThreadNameERK15TBtraceThreadIdR6TDes16 @ 175 NONAME
+	_ZNK14CBtraceContext28FindWindowGroupsByThreadNameERK7TDesC16R6RArrayI20TBtraceWindowGroupIdE @ 176 NONAME
+	_ZNK14CBtraceContext8ThreadIdERK15TBtraceThreadId @ 177 NONAME
+	_ZNK16TBtraceTickCount19IntervalInFastTicksERKS_ @ 178 NONAME
+	_ZNK16TBtraceTickCount19IntervalInNanoTicksERKS_ @ 179 NONAME
+	_ZNK16TBtraceTickCount22IntervalInMicroSecondsERKS_ @ 180 NONAME
+	_ZNK16TBtraceTickCounteqERKS_ @ 181 NONAME
+	_ZNK16TBtraceTickCountgeERKS_ @ 182 NONAME
+	_ZNK16TBtraceTickCountgtERKS_ @ 183 NONAME
+	_ZNK16TBtraceTickCountleERKS_ @ 184 NONAME
+	_ZNK16TBtraceTickCountltERKS_ @ 185 NONAME
+	_ZNK16TBtraceTickCountneERKS_ @ 186 NONAME
+	_ZNK17CRefCountedObject8RefCountEv @ 187 NONAME
+	_ZTI22MBtraceContextObserver @ 188 NONAME
+	_ZTV22MBtraceContextObserver @ 189 NONAME
+	_ZN13CBtraceReader5StartERK16TBtraceTickCount27TTimeIntervalMicroSeconds32 @ 190 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+
+FSHELL_ROM_INCLUDE(btrace_parser.iby)
+
+..\inc\btrace_parser.h          fshell/btrace_parser.h
+..\inc\btrace_parser_defs.h     fshell/btrace_parser_defs.h
+
+PRJ_MMPFILES
+
+..\src\btrace_parser.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/group/btrace_parser.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+// btrace_parser.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef BTRACE_PARSER_IBY
+#define BTRACE_PARSER_IBY
+
+FSHELL_EXECUTABLE_FILE(btrace_parser.dll)
+
+#endif // BTRACE_PARSER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/inc/btrace_parser.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,927 @@
+// btrace_parser.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+// Backwards Compatibility:
+// The interfaces defined in this file should be considered INTERNAL to the
+// fshell project as they may be subject to change. Expect to have to absorb
+// downstream compatibility breaks if you use these interfaces from outside
+// of the fshell project.
+
+#ifndef __BTRACE_PARSER_H__
+#define __BTRACE_PARSER_H__
+
+#include <e32base.h>
+#include <fshell/btrace_parser_defs.h>
+#include <fshell/extrabtrace.h>
+#include FSHELL_D32BTRACE_HEADER
+#include <f32file.h>
+#include <e32property.h>
+#include <fshell/common.mmh>
+
+#ifdef FSHELL_ATRACE_SUPPORT
+#include <fshell/atrace/atraceconfig.h>
+#endif
+
+class TBtraceHeader;
+struct TKeyEvent;
+struct TPointerEvent;
+class CMultipartFragment;
+class CFlusher;
+
+enum TBtraceParserPanic
+	{
+	EBtpPanicUndefinedCallBack = 0,
+	EBtpPanicIncompatiblePubSubArgs = 1,
+	EBtpPanicThreadIdNotFound = 2,
+	EBtpPanicProcessNameNotFound = 3,
+	EBtpPanicBtraceThreadIdOverflow = 4,
+	EBtpPanicThreadNotFoundForId = 5,
+	EBtpPanicFailedToInsertCpuUsageObject = 6,
+	EBtpPanicBtraceProcessIdOverflow = 7,
+	EBtpPanicUnused1 = 8,
+	EBtpPanicUnused2 = 9,
+	EBtpPanicNegativeTickInterval = 10,
+	EBtpPanicUnused3 = 11,
+	EBtpPanicInvalidReaderMode = 12,
+	EBtpPanicUnexpectedReaderRun = 13,
+	EBtpPanicUnknownCpuContext = 14,
+	EBtpPanicFlusherObserverAlreadySet = 15,
+	EBtpPanicReaderNotReplaying = 16,
+	EBtpPanicNoReplayData = 17,
+	EBtpPanicFailedToFindProcess = 18,
+	EBtpPanicNegativeRefCount = 19,
+	EBtpPanicNestedSynchronizeCalls = 20,
+	EBtpPanicFrameObserverAlreadyExists = 21,
+	EBtpPanicTriedToDisableReplayWhenBtraceNotRunning = 22,
+	EBtpPanicAddObserverCalledWhileIterating = 23,
+	EBtpPanicRemoveObserverCalledWhileIterating = 24,
+	EBtpPanicTooManyDomainEventDataItems = 25,
+	EBtpPanicBtraceWindowGroupIdOverflow = 26,
+	EBtpPanicWindowGroupIdNotFound = 27,
+	EBtpPanicWservWindowGroupIdNotFound = 28
+	};
+
+void Panic(TBtraceParserPanic aReason);
+struct SBtraceParserTls;
+
+enum TBtraceNotificationPersistence
+	{
+	ENotificationOneShot,
+	ENotificationPersistent,
+	};
+
+class TBtraceUtils
+	{
+public:
+	IMPORT_C static TUint32 MicroSecondsToNanoTicks(TTimeIntervalMicroSeconds32 aInterval);
+	IMPORT_C static TUint64 MicroSecondsToFastTicks(TTimeIntervalMicroSeconds32 aInterval);
+	IMPORT_C static TTimeIntervalMicroSeconds NanoTicksToMicroSeconds(TUint32 aNanoTicks);
+	IMPORT_C static TTimeIntervalMicroSeconds FastTicksToMicroSeconds(const TUint64& aFastTicks);
+
+	IMPORT_C static void DebugOverrideTimerSettings(TInt aNanoPeriod, TInt aFastCounterFreq, TBool aFastCountUp);
+
+public:
+	static TInt NanoTickPeriod();
+	static TInt FastCounterFrequency();
+	static TBool FastCounterCountsUp();
+private:
+	static SBtraceParserTls* CreateTls();
+	static TInt CalculateNanoTickPeriod();
+	static TInt CalculateFastCounterFrequency();
+	static TInt CalculateFastCounterCountsUp();
+	};
+
+class TBtraceTickCount
+	{
+public:
+	IMPORT_C TBtraceTickCount();
+	IMPORT_C void SetToNow();
+	IMPORT_C TUint32 IntervalInNanoTicks(const TBtraceTickCount& aTickCount) const;
+	IMPORT_C TUint64 IntervalInFastTicks(const TBtraceTickCount& aTickCount) const;
+	IMPORT_C TTimeIntervalMicroSeconds IntervalInMicroSeconds(const TBtraceTickCount& aTickCount) const;
+	IMPORT_C TBool operator==(const TBtraceTickCount& aTickCount) const;
+	IMPORT_C TBool operator!=(const TBtraceTickCount& aTickCount) const;
+	IMPORT_C TBool operator>=(const TBtraceTickCount& aTickCount) const;
+	IMPORT_C TBool operator<=(const TBtraceTickCount& aTickCount) const;
+	IMPORT_C TBool operator>(const TBtraceTickCount& aTickCount) const;
+	IMPORT_C TBool operator<(const TBtraceTickCount& aTickCount) const;
+public:
+	TUint32 iNano;
+	TUint32 iFast;
+	};
+
+
+class TBtraceFrame
+	{
+public:
+	TBtraceFrame(const TBtraceHeader& aHeader);
+public:
+	TUint8 iSize;
+	TUint8 iFlags;
+	TUint8 iCategory;
+	TUint8 iSubCategory;
+	TBtraceTickCount iTickCount;
+	TUint32 iThreadContext;
+	TUint32 iProgramCounter;
+	TPtrC8 iData;
+	};
+
+
+class MBtraceLog
+	{
+public:
+	IMPORT_C virtual TBool LogEnabled() = 0;
+	IMPORT_C virtual void Log(const TDesC& aLog) = 0;
+	};
+
+class CBtraceReader;
+
+
+class MBtraceObserver
+	{
+public:
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame) = 0;
+	virtual void BtraceBufferHasBeenReset() {} // Empty default impl
+	};
+	
+class MBtraceFrameObserver
+	{
+public:
+	virtual void HandleFrameDispatchStart() = 0;
+	virtual void HandleFrameDispatchComplete() = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceReader) : public CActive
+	{
+public:
+	enum TMode
+		{
+		EAllowBtraceToOverflow,
+		EFlushOnBtraceThreshold,
+		ELeaveOnBtraceThreshold
+		};
+	enum TObserverType
+		{
+		ENormal,
+		EIncludeSynchronizationFrames
+		};
+public:
+	IMPORT_C static CBtraceReader* NewL(TMode aMode, TInt aBufferSize, TInt aThreshold, MBtraceLog* aLog = NULL);
+	IMPORT_C static CBtraceReader* NewL(const TDesC& aReplayFileName, MBtraceLog* aLog = NULL);
+	IMPORT_C ~CBtraceReader();
+	IMPORT_C void Reset();
+	IMPORT_C void SynchronizeL();
+	IMPORT_C void Start(const TBtraceTickCount& aInitialTickCount);
+	IMPORT_C void Start(const TBtraceTickCount& aInitialTickCount, TTimeIntervalMicroSeconds32 aAutoFlushPeriod);
+	IMPORT_C void DisableBtrace();
+	IMPORT_C void EnableCategoryL(TUint aCategory);
+	IMPORT_C void DisableCategoryL(TUint aCategory);
+	IMPORT_C void AddObserverL(MBtraceObserver& aObserver);
+	IMPORT_C void AddObserverL(MBtraceObserver& aObserver, TObserverType aType);
+	IMPORT_C void AddObserverL(TUint aCategory, MBtraceObserver& aObserver);
+	IMPORT_C void AddObserverL(TUint aCategory, MBtraceObserver& aObserver, TObserverType aType);
+	IMPORT_C void RemoveObserver(MBtraceObserver& aObserver);
+	IMPORT_C void RemoveObserver(TUint aCategory, MBtraceObserver& aObserver);
+	IMPORT_C void AddFrameObseverL(MBtraceFrameObserver& aObserver);
+	IMPORT_C void RemoveFrameObserver(MBtraceFrameObserver& aObserver);
+	IMPORT_C void GetReplayStartTickCountL(TBtraceTickCount& aTickCount);
+	IMPORT_C void SetBufferSizeL(TInt aBufferSize);
+	IMPORT_C void SetReplayFileNameL(const TDesC& aReplayFileName); // Pass empty desc to disable (not allowed to disable if constructed with the overload that took a replay filename)
+	IMPORT_C const TBtraceTickCount& CurrentTickCount() const;
+	IMPORT_C void RecordBtraceDataToFileL(const TDesC& aRecordFileName); // Pass empty desc to disable
+	IMPORT_C void LogBtraceStatus();
+	IMPORT_C void SetMultipartReassemblyL(TInt aMaxTrackedFragments); // zero to disable
+	IMPORT_C void FlushL();
+public:
+	void Log(const TDesC& aDes) const;
+	void Log(TRefByValue<const TDesC> aFmt, ...) const;
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	CBtraceReader(TMode aMode, TInt aThreshold, MBtraceLog* aLog);
+	void ConstructL(TInt aBufferSize);
+	void ConstructL(const TDesC& aReplayFileName);
+	void QueueRead();
+	void DoReadL(TBool& aFinished);
+	TInt GetData(TUint8*& aData);
+	void DispatchFrameL(const TBtraceFrame& aFrame);
+	void NotifyObserversOfBufferReset();
+	void ResetAndReprimeL();
+	void NewMultipartFrameL(const TBtraceFrame& aFrame, TUint32 aExtra);
+	void AdditionalMultipartFragmentL(const TBtraceFrame& aFrame, TUint32 aExtra, TBool aLast);
+private:
+	class TObserver
+		{
+	public:
+		TObserver(MBtraceObserver& aObserver, TObserverType aType, TUint aCategory);
+		static TObserver ArrayKey(TUint aCategory);
+
+	private:
+		TObserver(TUint aCategory); // Only for use by ArrayKey
+	public:
+		MBtraceObserver* iObserver;
+		TObserverType iType;
+		TUint iCategory;
+		};
+private:
+	static TBool ObserversEqual(const TObserver& aA, const TObserver& aB);
+	static void DecIteratingObservers(TAny* aSelf);
+private:
+	const TMode iMode;
+	MBtraceLog* iLog;
+	CFlusher* iFlusher;
+	RBTrace iBtrace;
+#ifdef FSHELL_ATRACE_SUPPORT
+	RATraceConfig iAtraceConfig;
+#endif
+	TInt iThreshold;
+	RArray<TObserver> iObservers; // Sorted by TObserver::iCategory
+	TInt iNumBytesRead;
+	TInt iNumFramesRead;
+	TBtraceTickCount iCurrentTickCount;
+	TBtraceTickCount iInitialTickCount;
+	TPtrC8 iBtraceBuffer;
+	HBufC8* iReplayData;
+	RFs iFs;
+	RFile iReplayFile;
+	TBool iSynchronizing;
+	MBtraceFrameObserver* iFrameObserver;
+	RFile iRecordFile;
+	TInt iIteratingObservers;
+	TInt iNextSyncFrameId;
+	TInt iSyncFrameIdToWaitFor;
+	TInt iMaxTrackedMultipartFragments;
+	RPointerArray<CMultipartFragment> iMultipartFragments;
+	};
+
+class CRefCountedObject : public CBase
+	{
+public:
+	IMPORT_C void IncRef();
+	IMPORT_C void DecRef();
+	IMPORT_C TInt RefCount() const;
+protected:
+	CRefCountedObject();
+private:
+	TInt iRefCount;
+	};
+
+class TBtraceIdBase
+	{
+public:
+	IMPORT_C void Set(TUint aValue);
+	IMPORT_C TUint Value() const;
+	IMPORT_C TBool operator==(const TBtraceIdBase& aId) const;
+protected:
+	TBtraceIdBase();
+	TBtraceIdBase(TUint aId);
+	TBtraceIdBase(const TBtraceIdBase& aId);
+private:
+	TUint iId; 
+	};
+
+class TBtraceThreadId : public TBtraceIdBase
+	{
+public:
+	IMPORT_C TBtraceThreadId();
+	IMPORT_C explicit TBtraceThreadId(TUint aId);
+	IMPORT_C TBtraceThreadId(const TBtraceThreadId& aId);
+	};
+
+class TBtraceProcessId : public TBtraceIdBase
+	{
+public:
+	IMPORT_C TBtraceProcessId();
+	IMPORT_C explicit TBtraceProcessId(TUint aId);
+	IMPORT_C TBtraceProcessId(const TBtraceProcessId& aId);
+	};
+
+class TBtraceWindowGroupId : public TBtraceIdBase
+	{
+public:
+	IMPORT_C TBtraceWindowGroupId();
+	IMPORT_C explicit TBtraceWindowGroupId(TUint aId);
+	IMPORT_C TBtraceWindowGroupId(const TBtraceWindowGroupId& aId);
+	};
+
+
+class MBtraceContextObserver
+	{
+public:
+	IMPORT_C virtual void HandleThreadSeenL(const TBtraceTickCount& aTickCount, const TBtraceThreadId& aId, TUint aUserId);
+	IMPORT_C virtual void HandleThreadGoneL(const TBtraceTickCount& aTickCount, const TBtraceThreadId& aId, TUint aUserId);
+	IMPORT_C virtual void HandleThreadExitL(const TBtraceTickCount& aTickCount, const TBtraceThreadId& aId, TExitType aExitType, TInt aReason, const TDesC& aCategory, TUint aUserId);
+	IMPORT_C virtual void HandleWindowGroupSeenL(const TBtraceTickCount& aTickCount, const TBtraceWindowGroupId& aId, TUint aUserId);
+	};
+
+NONSHARABLE_CLASS(CBtraceContext) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	enum TMode
+		{
+		ENormal
+		};
+	enum TExitTypes
+		{
+		EKill		= 0x00000001,
+		ETerminate	= 0x00000002,
+		EPanic		= 0x00000004
+		};
+public:
+	IMPORT_C static CBtraceContext* NewL(CBtraceReader& aReader, TMode aMode = ENormal);
+	IMPORT_C ~CBtraceContext();
+	IMPORT_C const TDesC& ThreadName(const TBtraceThreadId& aId) const;
+	IMPORT_C void GetFullThreadName(const TBtraceThreadId& aId, TDes& aFullName) const;
+	IMPORT_C TThreadId ThreadId(const TBtraceThreadId& aId) const;
+	IMPORT_C const TDesC& ProcessName(const TBtraceProcessId& aId) const;
+	IMPORT_C TInt WindowGroupId(const TBtraceWindowGroupId& aId) const;
+	IMPORT_C const TDesC& WindowGroupName(const TBtraceWindowGroupId& aId) const;
+	IMPORT_C const TBtraceThreadId* FindThread(TUint32 aNThreadAddress) const;
+	IMPORT_C const TBtraceThreadId* FindThread(const TThreadId& aId) const;
+	IMPORT_C const TBtraceWindowGroupId* FindWindowGroup(TInt aWServWgId) const;
+	IMPORT_C void FindThreadsL(const TDesC& aPattern, RArray<TBtraceThreadId>& aThreads) const;
+	IMPORT_C void FindWindowGroupsL(const TDesC& aPattern, RArray<TBtraceWindowGroupId>& aWindowGroups) const;
+	IMPORT_C void FindWindowGroupsByThreadName(const TDesC& aPattern, RArray<TBtraceWindowGroupId>& aWindowGroups) const;
+	IMPORT_C void NotifyThreadSeenL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId);
+	IMPORT_C void NotifyThreadSeenL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyThreadSeen(MBtraceContextObserver& aObserver);
+	IMPORT_C void NotifyThreadGoneL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId);
+	IMPORT_C void NotifyThreadGoneL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyThreadGone(MBtraceContextObserver& aObserver);
+	IMPORT_C void NotifyThreadExitL(const TDesC& aPattern, TUint aExitTypes, TInt* aReason, const TDesC* aCategory, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence);	// Note, the pointer parameters are optional.
+	IMPORT_C void CancelNotifyThreadExit(MBtraceContextObserver& aObserver);
+	IMPORT_C void NotifyWindowGroupSeenL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void NotifyWindowGroupSeenByThreadNameL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyWindowGroupSeen(MBtraceContextObserver& aObserver);
+private:
+	CBtraceContext(CBtraceReader& aReader, TMode aMode);
+	void ConstructL();
+	TUint GetNextThreadId();
+	TUint GetNextProcessId();
+	TUint GetNextWindowGroupId();
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+	virtual void BtraceBufferHasBeenReset();
+private:
+	class TThread
+		{
+	public:
+		TThread(TUint32 aNThreadAddress, TUint32 aOwningProcess, const TDesC8& aName);
+	public:
+		TUint32 iNThreadAddress;
+		TBtraceThreadId iId;
+		TUint32 iOwningProcess;
+		TUint32 iKernelId;
+		TName iName;
+		};
+	class TProcess
+		{
+	public:
+		TProcess(TUint32 aDProcessAddress);
+		TProcess(TUint32 aDProcessAddress, const TDesC8& aName);
+	public:
+		TUint32 iDProcessAddress;
+		TBtraceProcessId iId;
+		TName iName;
+		TInt iReferenceCount;
+		};
+	class TWindowGroup
+		{
+	public:
+		TWindowGroup(TInt aWindowGroupId);
+		TWindowGroup(const TDesC& aName);
+		TWindowGroup(TInt aWindowGroupId, TThreadId aThreadId, const TDesC& aName);
+	public:
+		TBtraceWindowGroupId iId;
+		TInt iWindowGroupId;
+		TThreadId iThreadId;
+		TFullName iName;
+		};
+	class TThreadSeenNotif
+		{
+	public:
+		TThreadSeenNotif(TUint aId, const TDesC& aPattern, MBtraceContextObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	public:
+		TUint iId;
+		TName iPattern;
+		MBtraceContextObserver& iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+	class TThreadGoneNotif
+		{
+	public:
+		TThreadGoneNotif(TUint aId, const TDesC& aPattern, MBtraceContextObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	public:
+		TUint iId;
+		TName iPattern;
+		MBtraceContextObserver& iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+	class TThreadExitNotif
+		{
+	public:
+		TThreadExitNotif(TUint aId, const TDesC& aPattern, TUint aExitTypes, TInt* aReason, const TDesC* aCategory, MBtraceContextObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+		TBool Matches(const TDesC& aThreadName, TExitType aExitType, TInt aReason, const TDesC& aCategory) const;
+	private:
+		TBool MatchesType(TExitType aExitType) const;
+	public:
+		TUint iId;
+		TName iPattern;
+		TUint iExitTypes;
+		TInt* iReason;
+		const TDesC* iCategory;
+		MBtraceContextObserver& iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+	class TWindowGroupSeenNotif
+		{
+	public:
+		enum TPatternType
+			{
+			EWindowGroupName,
+			EThreadName
+			};
+	public:
+		TWindowGroupSeenNotif(TUint aId, const TDesC& aPattern, TPatternType aPatternType, MBtraceContextObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	public:
+		TUint iId;
+		TName iPattern;
+		TPatternType iPatternType;
+		MBtraceContextObserver& iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+private:
+	void SeenL(const TThread& aThread, const TBtraceTickCount& aTickCount);
+	void GoneL(const TThread& aThread, const TBtraceTickCount& aTickCount);
+	void ExitedL(const TThread& aThread, TExitType aExitType, TInt aReason, const TDesC& aCategory, const TBtraceTickCount& aTickCount);
+	void AppendL(const TThread& aThread, const TBtraceTickCount& aTickCount);
+	void AppendL(const TProcess& aProcess, const TBtraceTickCount& aTickCount);
+	void RemoveThread(TInt aPosition);
+	void SeenAllThreadsL(const TProcess& aProcess, const TBtraceTickCount& aTickCount);
+	void SeenL(const TWindowGroup& aWindowGroup, const TBtraceTickCount& aTickCount);
+	static TBool ThreadMatchesId(const TThread& aLeft, const TThread& aRight);
+	static TBool ThreadMatchesKernelId(const TThread& aLeft, const TThread& aRight);
+	static TBool ThreadMatchesNThreadAddress(const TThread& aLeft, const TThread& aRight);
+	static TBool ProcessMatchesId(const TProcess& aLeft, const TProcess& aRight);
+	static TBool ProcessMatchesDProcessAddress(const TProcess& aLeft, const TProcess& aRight);
+	static TBool WindowGroupMatchesId(const TWindowGroup& aLeft, const TWindowGroup& aRight);
+	static TBool WindowGroupMatchesThreadId(const TWindowGroup& aLeft, const TWindowGroup& aRight);
+	static TBool WindowGroupMatchesWServId(const TWindowGroup& aLeft, const TWindowGroup& aRight);
+private:
+	TMode iMode;
+	CBtraceReader& iReader;
+	TUint iNextBtraceThreadId;
+	TUint iNextBtraceProcessId;
+	TUint iNextBtraceWindowGroupId;
+	RArray<TThread> iThreads;
+	RArray<TProcess> iProcesses;
+	RArray<TWindowGroup> iWindowGroups;
+	RArray<TThreadSeenNotif> iThreadSeenNotifs;
+	RArray<TThreadGoneNotif> iThreadGoneNotifs;
+	RArray<TThreadExitNotif> iThreadExitNotifs;
+	RArray<TWindowGroupSeenNotif> iWindowGroupSeenNotifs;
+	};
+
+
+class MBtraceCpuUsageObserver
+	{
+public:
+	enum TContextSwitchType
+		{
+		EToThisThread,
+		EFromThisThread
+		};
+	enum TIdleType
+		{
+		ENeverScheduled,
+		EScheduledAtLeastOnce
+		};
+	class TCpuUsage
+		{
+	public:
+		TCpuUsage(const TBtraceThreadId& aId);
+		TCpuUsage(const TBtraceThreadId& aId, const TBtraceTickCount& aTickCount);
+	public:
+		TBtraceThreadId iId;
+		TUint64 iNumFastTicks;
+	private:
+		friend class CBtraceCpuUsage;
+		TBtraceTickCount iSwitchedInAt;
+		};
+public:
+	virtual void HandleCpuUsageL(const TBtraceTickCount& aTickCount, const TArray<TCpuUsage>& aCpuUsage) = 0;
+	virtual void HandleContextSwitchL(const TBtraceTickCount& aTickCount, const TBtraceThreadId& aId, TContextSwitchType aType) = 0;
+	virtual void HandleThreadIdleL(const TBtraceTickCount& aTickCount, const TBtraceThreadId& aId, TIdleType aIdleType) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceCpuUsage) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	IMPORT_C static CBtraceCpuUsage* NewL(CBtraceReader& aReader, CBtraceContext& aContext);
+	IMPORT_C ~CBtraceCpuUsage();
+	IMPORT_C void NotifyCpuUsageL(TUint32 aNanoTickCount, TTimeIntervalMicroSeconds32 aPeriod, MBtraceCpuUsageObserver& aObserver);
+	IMPORT_C void NotifyCpuUsageL(TUint32 aNanoTickCount, TTimeIntervalMicroSeconds32 aPeriod, MBtraceCpuUsageObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void NotifyContextSwitchL(const TBtraceThreadId& aId, MBtraceCpuUsageObserver& aObserver);
+	IMPORT_C void NotifyThreadIdleL(const TBtraceThreadId& aId, const TBtraceTickCount& aFromTickCount, TTimeIntervalMicroSeconds32 aPeriod, MBtraceCpuUsageObserver& aObserver);
+	IMPORT_C void NotifyThreadIdleL(const TBtraceThreadId& aId, const TBtraceTickCount& aFromTickCount, TTimeIntervalMicroSeconds32 aPeriod, MBtraceCpuUsageObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyThreadIdle(MBtraceCpuUsageObserver& aObserver);
+private:
+	CBtraceCpuUsage(CBtraceReader& aReader, CBtraceContext& aContext);
+	void ConstructL();
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private:
+	class RCpuUsageNotif
+		{
+	public:
+		RCpuUsageNotif(TUint32 aStartTickCount, TUint32 aNumNanoTicks, MBtraceCpuUsageObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+		void Close();
+	public:
+		TUint32 iStartTickCount;
+		TUint32 iNumNanoTicks;
+		MBtraceCpuUsageObserver* iObserver;
+		RArray<MBtraceCpuUsageObserver::TCpuUsage> iUsage;
+		TBtraceNotificationPersistence iPersistence;
+		};
+	class TContextSwitchNotif
+		{
+	public:
+		TContextSwitchNotif(const TBtraceThreadId& aId);
+		TContextSwitchNotif(const TBtraceThreadId& aId, MBtraceCpuUsageObserver& aObserver);
+	public:
+		TBtraceThreadId iId;
+		MBtraceCpuUsageObserver* iObserver;
+		};
+	class TThreadIdleNotif
+		{
+	public:
+		TThreadIdleNotif(const TBtraceThreadId& aId);
+		TThreadIdleNotif(const TBtraceThreadId& aId, const TBtraceTickCount& aFromTickCount, TUint aNumNanoTicks, MBtraceCpuUsageObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	public:
+		TBtraceThreadId iId;
+		TUint32 iNumNanoTicks;
+		MBtraceCpuUsageObserver* iObserver;
+		TBtraceTickCount iLastSwitchedOut;
+		TBool iEverScheduled;
+		TBtraceNotificationPersistence iPersistence;
+		};
+private:
+	void HandleContextSwitchL(const TBtraceTickCount& aTickCount, const TBtraceThreadId& aNewBtraceThreadId);
+	void TestCpuUsagePeriodL(const TBtraceTickCount& aTickCount);
+	void TestThreadIdlenessL(const TBtraceTickCount& aTickCount);
+private:
+	CBtraceReader& iReader;
+	CBtraceContext& iContext;
+	RArray<RCpuUsageNotif> iCpuUsageNotifs;
+	RArray<TContextSwitchNotif> iContextSwitchNotifs;
+	RArray<TThreadIdleNotif> iThreadIdleNotifs;
+	TBtraceThreadId iLastBtractThreadId;
+	TInt iNumIgnoredFrames;
+	TInt iNumProcessedFrames;
+	TInt iNumRelevantFrames;
+	};
+
+
+class MBtraceKeyPressObserver
+	{
+public:
+	virtual void HandleKeyPressL(const TBtraceTickCount& aTickCount, const TKeyEvent& aKey) = 0;
+	virtual void HandlePointerPressL(const TBtraceTickCount& aTickCount, const TPointerEvent& aPointer) = 0;
+	virtual void HandleUnclassifiedDataL(const TBtraceTickCount& aTickCount, const TInt aCommandClass, const TInt aOpcode, const TAny* aData) = 0;
+	virtual void HandleRawKeyL(const TBtraceTickCount& aTickCount, TBool aKeyUp, TInt aScanCode) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceKeyPress) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	IMPORT_C static CBtraceKeyPress* NewL(CBtraceReader& aReader);
+	IMPORT_C ~CBtraceKeyPress();
+	IMPORT_C void NotifyKeyEventL(MBtraceKeyPressObserver& aObserver);
+	IMPORT_C void NotifyKeyEventL(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyKeyEvent(MBtraceKeyPressObserver& aObserver);
+	IMPORT_C void NotifyPointerEventL(MBtraceKeyPressObserver& aObserver);
+	IMPORT_C void NotifyPointerEventL(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyPointerEvent(MBtraceKeyPressObserver& aObserver);
+	IMPORT_C void NotifyUnclassifiedDataL(MBtraceKeyPressObserver& aObserver);
+	IMPORT_C void NotifyUnclassifiedDataL(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyUnclassifiedData(MBtraceKeyPressObserver& aObserver);
+	IMPORT_C void NotifyRawKeyEventL(MBtraceKeyPressObserver& aObserver);
+	IMPORT_C void NotifyRawKeyEventL(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyRawKeyEvent(MBtraceKeyPressObserver& aObserver);
+private:
+	CBtraceKeyPress(CBtraceReader& aReader);
+	void ConstructL();
+	void SeenKeyL(const TBtraceTickCount& aTickCount, const TKeyEvent& aKey);
+	void SeenPointerL(const TBtraceTickCount& aTickCount, const TPointerEvent& aKey);
+	void SeenUnclassifiedL(const TBtraceTickCount& aTickCount, const TInt aCommandClass, const TInt aOpcode, const TAny* aData);
+	void SeenRawKeyL(const TBtraceTickCount& aTickCount, TBool aKeyUp, TInt aScanCode);
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private:		
+	class TKeyPressNotif
+		{
+	public:
+		TKeyPressNotif(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	public:
+		MBtraceKeyPressObserver* iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+	CBtraceReader& iReader;
+	RArray<TKeyPressNotif> iKeyNotifs;
+	RArray<TKeyPressNotif> iPointerNotifs;
+	RArray<TKeyPressNotif> iGenericNotifs;
+	RArray<TKeyPressNotif> iRawKeyNotifs;
+	};
+
+
+class MBtraceTextOnScreenObserver
+	{
+public:
+	virtual void HandleTextSeenL(const TBtraceTickCount& aTickCount, const TDesC& aText, TInt aWindowGroupId) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceTextOnScreen) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	enum TMatchMode
+		{
+		EWildNonSpanning,
+		ESpanningNonWild
+		};
+public:
+	IMPORT_C static CBtraceTextOnScreen* NewL(CBtraceReader& aReader);
+	IMPORT_C ~CBtraceTextOnScreen();
+	IMPORT_C void NotifyTextOnScreenL(const TDesC& aText, MBtraceTextOnScreenObserver& aObserver);
+	IMPORT_C void NotifyTextOnScreenL(const TDesC& aText, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void NotifyTextOnScreenL(const TDesC& aText, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void NotifyTextOnScreenL(const TDesC& aText, TInt aWindowGroupId, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver);
+	IMPORT_C void NotifyTextOnScreenL(const TDesC& aText, TInt aWindowGroupId, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyTextOnScreen(MBtraceTextOnScreenObserver& aObserver);
+private:
+	CBtraceTextOnScreen(CBtraceReader& aReader);
+	void ConstructL();
+	void SeenL(const TBtraceTickCount& aTickCount, const TDesC& aData, TInt aWindowGroupId);
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private:
+	class TTextOnScreenNotif
+		{
+	public:
+		TTextOnScreenNotif(const TDesC& aText, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+		TTextOnScreenNotif(const TDesC& aText, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+		TTextOnScreenNotif(const TDesC& aText, TInt aWindowGroupId, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	public:
+		TPtrC iTxtPtr;
+		TInt iWindowGroupId;
+		TInt iMatchedChars;
+		TMatchMode iMatchMode;
+		MBtraceTextOnScreenObserver* iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+	CBtraceReader& iReader;
+	RArray<TTextOnScreenNotif> iScreenNotifs;
+	};
+
+
+//
+// An observer to identify the occurrence of generic events (see btrace_parser_defs.h)
+//
+class MBtraceGenericObserver
+	{
+public:
+	virtual void HandleGenericEvent0L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory) = 0;
+	virtual void HandleGenericEvent1L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory, TUint32 aData1) = 0;
+	virtual void HandleGenericEvent2L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory, TUint32 aData1, TUint32 aData2) = 0;
+	virtual void HandleGenericEvent3L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory, TUint32 aData1, TUint32 aData2, TUint32 aData3) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceGeneric) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	IMPORT_C static CBtraceGeneric* NewL(CBtraceReader& aReader);
+	IMPORT_C ~CBtraceGeneric();
+	IMPORT_C void NotifyGenericEventL(MBtraceGenericObserver& aObserver);
+private:
+	CBtraceGeneric(CBtraceReader& aReader);
+	void ConstructL();
+	// MBtraceObserver pure virtuals
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+	void SeenGeneric0L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory);
+	void SeenGeneric1L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory,	TUint32 aData1);
+	void SeenGeneric2L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory,	TUint32 aData1, TUint32 aData2);
+	void SeenGeneric3L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory,	TUint32 aData1, TUint32 aData2, TUint32 aData3);
+private:
+	CBtraceReader& iReader;
+		 //TODO TBtraceNotificationPersistence iPersistence
+	RPointerArray<MBtraceGenericObserver> iObservers;		// pointers not owned
+	};
+
+
+class MBtraceDomainEventObserver
+	{
+public:
+	virtual void HandleDomainEventL(const TBtraceTickCount& aTickCount, MBtraceDomainEventObserver& aObserver) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceDomainEvent) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	IMPORT_C static CBtraceDomainEvent* NewL(CBtraceReader& aReader);
+	IMPORT_C ~CBtraceDomainEvent();
+	IMPORT_C void NotifyDomainEventL(TUint aSubCategory, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void NotifyDomainEventL(TUint aSubCategory, TUint aData1, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void NotifyDomainEventL(TUint aSubCategory, TUint aData1, TUint aData2, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void NotifyDomainEventL(TUint aSubCategory, TUint aData1, TUint aData2, TUint aData3, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyDomainEvent(MBtraceDomainEventObserver& aObserver);
+private:
+	CBtraceDomainEvent(CBtraceReader& aReader);
+	void ConstructL();
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private:
+	class TDomainEventNotif
+		{
+	public:
+		TDomainEventNotif(TUint aSubCategory);
+		TDomainEventNotif(TUint aSubCategory, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+		void AddDataItem(TUint aData);
+		TBool operator==(const TDomainEventNotif& aNotif) const;
+	public:
+		enum { KMaxNumDataItems = 3 };
+	public:
+		TUint iSubCategory;
+		MBtraceDomainEventObserver* iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		TInt iDataCount;
+		TFixedArray<TUint, KMaxNumDataItems> iData;
+		};
+private:
+	CBtraceReader& iReader;
+	RArray<TDomainEventNotif> iNotifs;
+	};
+
+
+class MBtraceAppResponseObserver
+	{
+public:
+	virtual void HandleAppResponseSeenL(const TBtraceTickCount& aTickCount) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceAppResponse) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	IMPORT_C static CBtraceAppResponse* NewL(CBtraceReader& aReader);
+	IMPORT_C ~CBtraceAppResponse();
+	IMPORT_C void NotifyAppResponseL(MBtraceAppResponseObserver& aObserver, const TProcessId& aProcessId);
+	IMPORT_C void NotifyAppResponseL(MBtraceAppResponseObserver& aObserver, const TProcessId& aProcessId, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyAppResponse(MBtraceAppResponseObserver& aObserver);
+private:
+	CBtraceAppResponse(CBtraceReader& aReader);
+	void ConstructL();
+	void SeenAppResponseL(const TBtraceTickCount& aTickCount, const TProcessId& aProcessId);
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private:
+	class TAppResponseNotif
+		{
+	public:
+		TAppResponseNotif(MBtraceAppResponseObserver& aObserver, const TProcessId& aProcessId, TBtraceNotificationPersistence aPersistence);
+	public:
+		MBtraceAppResponseObserver& iObserver;
+		TProcessId iProcessId;
+		TBtraceNotificationPersistence iPersistence;
+		};
+private:
+	CBtraceReader& iReader;
+	RArray<TAppResponseNotif> iNotifs;
+	};
+
+
+class MBtraceScreenUpdateObserver
+	{
+public:
+	virtual void HandleScreenUpdateL(const TBtraceTickCount& aTickCount, TInt aScreenNumber, const TRect& aRect) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceScreenUpdate) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	IMPORT_C static CBtraceScreenUpdate* NewL(CBtraceReader& aReader);
+	IMPORT_C ~CBtraceScreenUpdate();
+	IMPORT_C void NotifyScreenUpdateL(MBtraceScreenUpdateObserver& aObserver);
+	IMPORT_C void NotifyScreenUpdateL(MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void NotifyScreenUpdateL(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver);
+	IMPORT_C void NotifyScreenUpdateL(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyScreenUpdate(MBtraceScreenUpdateObserver& aObserver);
+private:
+	CBtraceScreenUpdate(CBtraceReader& aReader);
+	void ConstructL();
+	void HandleScreenUpdateL(const TBtraceTickCount& aTickCount, TInt aScreenNumber, const TRect& aRect);
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private:
+	class TScreenUpdateNotif
+		{
+	public:
+		TScreenUpdateNotif(MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+		TScreenUpdateNotif(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	public:
+		TBool iNotifyAll;
+		TInt iScreenNumber;
+		TRect iRect;
+		MBtraceScreenUpdateObserver* iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+private:
+	CBtraceReader& iReader;
+	RArray<TScreenUpdateNotif> iNotifs;
+	};
+
+class MBtracePubSubObserver
+	{
+public:
+	virtual void HandlePropertyChangedL(const TBtraceTickCount& aTickCount, TUint aCategory, TUint aKey, TInt aNewValue) = 0;
+	virtual void HandlePropertyChangedL(const TBtraceTickCount& aTickCount, TUint aCategory, TUint aKey, const TDesC8& aNewValue) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtracePubSub) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	IMPORT_C static CBtracePubSub* NewL(CBtraceReader& aReader);
+	IMPORT_C ~CBtracePubSub();
+	IMPORT_C void NotifyPropertyChangedL(MBtracePubSubObserver& aObserver);
+	IMPORT_C void NotifyPropertyChangedL(TUint* aCategory, TUint* aKey, MBtracePubSubObserver& aObserver, TBtraceNotificationPersistence aPersistence);		// Note, the pointer parameters are optional.
+	IMPORT_C void NotifyIntegerPropertyChangedL(TUint* aCategory, TUint* aKey, TInt* aValue, MBtracePubSubObserver& aObserver, TBtraceNotificationPersistence aPersistence);		// Note, the pointer parameters are optional.
+	IMPORT_C void NotifyDataPropertyChangedL(TUint* aCategory, TUint* aKey, const TDesC8* aValue, MBtracePubSubObserver& aObserver, TBtraceNotificationPersistence aPersistence);	// Note, the pointer parameters are optional.
+	IMPORT_C void CancelNotifyPropertyChanged(MBtracePubSubObserver& aObserver);
+private:
+	CBtracePubSub(CBtraceReader& aReader);
+	void ConstructL();
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private:
+	class TPubSubNotif
+		{
+	public:
+		TPubSubNotif(TUint* aCategory, TUint* aKey, TInt* aIntegerValue, const TDesC8* aDataValue, MBtracePubSubObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+		TBool Matches(TUint aCategory, TUint aKey, TInt aIntegerValue) const;
+		TBool Matches(TUint aCategory, TUint aKey, const TDesC8& aDataValue) const;
+	public:
+		TUint* iCategory;
+		TUint* iKey;
+		TInt* iIntegerValue;
+		const TDesC8* iDataValue;
+		MBtracePubSubObserver& iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+private:
+	CBtraceReader& iReader;
+	RArray<TPubSubNotif> iNotifs;
+	};
+
+class MBtraceFocusChangeObserver
+	{
+public:
+	virtual void HandleFocusChangedL(const TBtraceTickCount& aTickCount, const TBtraceWindowGroupId& aWindowGroupId) = 0;
+	};
+
+NONSHARABLE_CLASS(CBtraceFocusChange) : public CRefCountedObject, public MBtraceObserver
+	{
+public:
+	IMPORT_C static CBtraceFocusChange* NewL(CBtraceReader& aReader, CBtraceContext& aContext);
+	IMPORT_C ~CBtraceFocusChange();
+	IMPORT_C void NotifyFocusChangedL(const TDesC& aWindowGroupNamePattern, MBtraceFocusChangeObserver& aObserver);
+	IMPORT_C void NotifyFocusChangedL(const TDesC& aWindowGroupNamePattern, MBtraceFocusChangeObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	IMPORT_C void CancelNotifyFocusChanged(MBtraceFocusChangeObserver& aObserver);
+private:
+	CBtraceFocusChange(CBtraceReader& aReader, CBtraceContext& aContext);
+	void ConstructL();
+private: // From MBtraceObserver.
+	virtual void HandleBtraceFrameL(const TBtraceFrame& aFrame);
+private:
+	class TFocusChangeNotif
+		{
+	public:
+		TFocusChangeNotif(const TDesC& aWindowGroupNamePattern, MBtraceFocusChangeObserver& aObserver, TBtraceNotificationPersistence aPersistence);
+	public:
+		TPtrC iWindowGroupNamePattern;
+		MBtraceFocusChangeObserver& iObserver;
+		TBtraceNotificationPersistence iPersistence;
+		};
+private:
+	CBtraceReader& iReader;
+	CBtraceContext& iContext;
+	RArray<TFocusChangeNotif> iNotifs;
+	};
+
+
+#endif // __BTRACE_PARSER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/inc/btrace_parser_defs.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,105 @@
+// btrace_parser_defs.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __BTRACE_PARSER_DEFS_H__
+#define __BTRACE_PARSER_DEFS_H__
+
+#include <e32cmn.h>
+#include <fshell/extrabtrace.h>
+
+// BTrace category
+const TUint KAmTraceCategory = BTrace::ESymbianExtentionsFirst;
+
+// BTrace subcategories
+enum TAmTraceSubCategory
+	{
+	// Subcategories for trace generated by autometric components
+	EAmTraceSubCategoryEvCapture				= 0,
+	EAmTraceSubCategoryScreenDriver				= 1,
+	EAmTraceSubCategoryScreenText				= 2,
+	EAmTraceSubCategoryWindowGroupName			= 3,
+	EAmTraceSubCategoryReaderSync				= 4,
+	EAmTraceSubCategoryWindowGroupFocus			= 5,
+	EAmTraceSubCategoryViewActivated			= 6,
+	EAmTraceSubCategoryThreadKilled				= 7,
+	EAmTraceSubCategoryThreadTerminated			= 8,
+	EAmTraceSubCategoryThreadPanicked			= 9,
+	EAmTraceSubCategoryProcessKilled			= 10,
+	EAmTraceSubCategoryProcessTerminated		= 11,
+	EAmTraceSubCategoryProcessPanicked			= 12,
+	EAmTraceSubCategoryScreenshot               = 13,
+	EAmTraceSubCategoryFreeRAM                  = 14,
+
+	// Btrace frames with subcategory number higher than this are parsed by CBtraceDomainEvent.
+	EAmTraceSubCategoryDomainEventBase          = 64,
+	
+	// Subcategories for trace generated by other subsystems.
+	EAmTraceSubCategoryMultimediaAudio			= 65,
+	EAmTraceSubCategoryMultimediaVideo			= 66,
+	EAmTraceSubCategoryCompatibilityPlaceHolder = 67, // Was previously EAmTraceSubCategoryScreenshot.
+	};
+
+
+/**
+ * Enumeration specifying the event types which can be provided in frames with
+ * the EAmTraceSubCategoryEvCapture subcategory.
+ */
+enum TAmTraceEventEvCapture
+	{
+	EAmTraceEventEvCaptureKeyPress				= 2,
+	EAmTraceEventEvCapturePointer				= 3,
+	EAmTraceEventEvCaptureUnclassified			= 4,
+	EAmTraceEventEvCaptureSystemAppResponse		= 5,
+	EAmTraceEventEvCaptureRawScan				= 6,
+	};
+
+
+/**
+ * Enumeration specifying the event types which can be provided in frames with
+ * the EAmTraceSubCategoryMultimediaVideo subcategory.
+ * 
+ * Note: in future, these should move into a separate, video-specific header.
+ */
+enum TAmTraceEventMultimediaVideo
+	{
+	EAmTraceEventMultimediaVideoStart			= 1,
+	EAmTraceEventMultimediaVideoFrame			= 2,
+	EAmTraceEventMultimediaVideoStop			= 3,
+	EAmTraceEventMultimediaVideoUnderflowError	= 4,
+	EAmTraceEventMultimediaVideoOverflowError	= 5,
+	
+	// Error other than underflow or overflow
+	EAmTraceEventMultimediaVideoError			= 6
+	};
+
+enum TAmTraceEventMultimediaAudio
+	{
+	EAmTraceEventMultimediaAudioStart			= 1,
+	EAmTraceEventMultimediaAudioFrame			= 2,
+	EAmTraceEventMultimediaAudioStop			= 3,
+	EAmTraceEventMultimediaAudioUnderflowError	= 4,
+	EAmTraceEventMultimediaAudioOverflowError	= 5,
+	
+	// Error other than underflow or overflow
+	EAmTraceEventMultimediaAudioError			= 6
+	};
+
+/**
+ * Enumeration specifying the event types which can be provided in frames with
+ * the EAmTraceSubCategoryScreenDriver subcategory.
+ */
+enum TAmTraceEventScreenDriver
+	{
+	EAmTraceEventScreenDriverRectangleUpdated
+	};
+
+#endif // __BTRACE_PARSER_DEFS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_appresponse.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,128 @@
+// btrace_appresponse.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace_parser.h"
+#include <fshell/common.mmh>
+
+
+//
+// CBtraceAppResponse
+//
+
+EXPORT_C CBtraceAppResponse* CBtraceAppResponse::NewL(CBtraceReader& aReader)
+	{
+	CBtraceAppResponse* self = new (ELeave) CBtraceAppResponse(aReader);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBtraceAppResponse::CBtraceAppResponse(CBtraceReader& aReader)
+	: iReader(aReader)
+	{
+	}
+
+EXPORT_C CBtraceAppResponse::~CBtraceAppResponse()
+	{
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	iNotifs.Close();
+	}
+
+void CBtraceAppResponse::ConstructL()
+	{
+	iReader.AddObserverL(KAmTraceCategory, *this);
+	}
+
+void CBtraceAppResponse::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iCategory != KAmTraceCategory) return;
+
+	switch (aFrame.iSubCategory)
+		{
+		case EAmTraceSubCategoryEvCapture:
+			{
+			const TUint32* data = reinterpret_cast<const TUint32*>(aFrame.iData.Ptr());
+			const TAmTraceEventEvCapture event = static_cast<TAmTraceEventEvCapture>(*data++);
+			const TUint32 processIdLowWord = *data++;
+			const TUint32 processIdHighWord = *data++;
+
+			switch (event)
+				{
+				case EAmTraceEventEvCaptureSystemAppResponse:
+					{
+					SeenAppResponseL(aFrame.iTickCount, MAKE_TUINT64(processIdHighWord, processIdLowWord));
+					}
+				break;
+				
+				default:
+					// ignore the event
+				break;
+				};
+			}
+		break;
+
+		default:
+			// ignore anything we don't know about.
+		break;
+		};
+	}
+
+void CBtraceAppResponse::SeenAppResponseL(const TBtraceTickCount& aTickCount, const TProcessId& aProcessId)
+	{
+	TInt ii = iNotifs.Count();
+	while (--ii >= 0)
+		{
+		TAppResponseNotif& nt = iNotifs[ii];
+		if (nt.iProcessId == aProcessId)
+			{
+			MBtraceAppResponseObserver& observer = nt.iObserver;
+			if (nt.iPersistence == ENotificationOneShot)
+				{
+				iNotifs.Remove(ii);
+				}
+			observer.HandleAppResponseSeenL(aTickCount);
+			}
+		}	
+	}
+
+EXPORT_C void CBtraceAppResponse::NotifyAppResponseL(MBtraceAppResponseObserver& aObserver, const TProcessId& aProcessId)
+	{
+	NotifyAppResponseL(aObserver, aProcessId, ENotificationOneShot);
+	}
+
+EXPORT_C void CBtraceAppResponse::NotifyAppResponseL(MBtraceAppResponseObserver& aObserver, const TProcessId& aProcessId, TBtraceNotificationPersistence aPersistence)
+	{
+	TAppResponseNotif notify(aObserver, aProcessId, aPersistence);
+	User::LeaveIfError(iNotifs.Append(notify));
+	}
+
+EXPORT_C void CBtraceAppResponse::CancelNotifyAppResponse(MBtraceAppResponseObserver& aObserver)
+	{
+	for (TInt i = (iNotifs.Count() - 1); i >= 0; --i)
+		{
+		if (&iNotifs[i].iObserver == &aObserver)
+			{
+			iNotifs.Remove(i);
+			}
+		}
+	}
+
+
+//
+// CBtraceAppResponse::TAppResponseNotif
+//
+
+CBtraceAppResponse::TAppResponseNotif::TAppResponseNotif(MBtraceAppResponseObserver& aObserver, const TProcessId& aProcessId, TBtraceNotificationPersistence aPersistence)
+	: iObserver(aObserver), iProcessId(aProcessId), iPersistence(aPersistence)
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_context.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,896 @@
+// btrace_context.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32debug.h>
+#include "btrace_parser.h"
+
+
+_LIT(KUnknown, "unknown");
+
+
+EXPORT_C TBtraceIdBase::TBtraceIdBase()
+	: iId(0)
+	{
+	}
+
+EXPORT_C TBtraceIdBase::TBtraceIdBase(TUint aId)
+	: iId(aId)
+	{
+	}
+
+EXPORT_C TBtraceIdBase::TBtraceIdBase(const TBtraceIdBase& aId)
+	: iId(aId.Value())
+	{
+	}
+
+EXPORT_C void TBtraceIdBase::Set(TUint aValue)
+	{
+	iId = aValue;
+	}
+
+EXPORT_C TUint TBtraceIdBase::Value() const
+	{
+	return iId;
+	}
+
+EXPORT_C TBool TBtraceIdBase::operator==(const TBtraceIdBase& aId) const
+	{
+	return (aId.iId == iId);
+	}
+
+EXPORT_C TBtraceThreadId::TBtraceThreadId()
+	{
+	}
+
+EXPORT_C TBtraceThreadId::TBtraceThreadId(TUint aId)
+	: TBtraceIdBase(aId)
+	{
+	}
+
+EXPORT_C TBtraceThreadId::TBtraceThreadId(const TBtraceThreadId& aId)
+	: TBtraceIdBase(aId)
+	{
+	}
+
+EXPORT_C TBtraceProcessId::TBtraceProcessId()
+	{
+	}
+
+EXPORT_C TBtraceProcessId::TBtraceProcessId(TUint aId)
+	: TBtraceIdBase(aId)
+	{
+	}
+
+EXPORT_C TBtraceProcessId::TBtraceProcessId(const TBtraceProcessId& aId)
+	: TBtraceIdBase(aId)
+	{
+	}
+
+EXPORT_C TBtraceWindowGroupId::TBtraceWindowGroupId()
+	{
+	}
+
+EXPORT_C TBtraceWindowGroupId::TBtraceWindowGroupId(TUint aId)
+	: TBtraceIdBase(aId)
+	{
+	}
+
+EXPORT_C TBtraceWindowGroupId::TBtraceWindowGroupId(const TBtraceWindowGroupId& aId)
+	: TBtraceIdBase(aId)
+	{
+	}
+
+EXPORT_C void MBtraceContextObserver::HandleThreadSeenL(const TBtraceTickCount&, const TBtraceThreadId&, TUint)
+	{
+	Panic(EBtpPanicUndefinedCallBack);
+	}
+
+EXPORT_C void MBtraceContextObserver::HandleThreadGoneL(const TBtraceTickCount&, const TBtraceThreadId&, TUint)
+	{
+	Panic(EBtpPanicUndefinedCallBack);
+	}
+
+EXPORT_C void MBtraceContextObserver::HandleThreadExitL(const TBtraceTickCount&, const TBtraceThreadId&, TExitType, TInt, const TDesC&, TUint)
+	{
+	Panic(EBtpPanicUndefinedCallBack);
+	}
+
+EXPORT_C void MBtraceContextObserver::HandleWindowGroupSeenL(const TBtraceTickCount&, const TBtraceWindowGroupId&, TUint)
+	{
+	Panic(EBtpPanicUndefinedCallBack);
+	}
+
+EXPORT_C CBtraceContext* CBtraceContext::NewL(CBtraceReader& aReader, TMode aMode)
+	{
+	CBtraceContext* self = new(ELeave) CBtraceContext(aReader, aMode);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CBtraceContext::~CBtraceContext()
+	{
+	iWindowGroupSeenNotifs.Close();
+	iThreadExitNotifs.Close();
+	iThreadGoneNotifs.Close();
+	iThreadSeenNotifs.Close();
+	iWindowGroups.Close();
+	iThreads.Close();
+	iProcesses.Close();
+	iReader.RemoveObserver(BTrace::EThreadIdentification, *this);
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	}
+
+
+TBool CBtraceContext::ThreadMatchesId(const TThread& aLeft, const TThread& aRight)
+	{
+	return (aLeft.iId == aRight.iId);
+	}
+
+TBool CBtraceContext::ThreadMatchesKernelId(const TThread& aLeft, const TThread& aRight)
+	{
+	return (aLeft.iKernelId == aRight.iKernelId);
+	}
+
+TBool CBtraceContext::ThreadMatchesNThreadAddress(const TThread& aLeft, const TThread& aRight)
+	{
+	return (aLeft.iNThreadAddress == aRight.iNThreadAddress);
+	}
+
+TBool CBtraceContext::ProcessMatchesId(const TProcess& aLeft, const TProcess& aRight)
+	{
+	return (aLeft.iId == aRight.iId);
+	}
+
+TBool CBtraceContext::ProcessMatchesDProcessAddress(const TProcess& aLeft, const TProcess& aRight)
+	{
+	return (aLeft.iDProcessAddress == aRight.iDProcessAddress);
+	}
+
+TBool CBtraceContext::WindowGroupMatchesId(const TWindowGroup& aLeft, const TWindowGroup& aRight)
+	{
+	return (aLeft.iId == aRight.iId);
+	}
+
+TBool CBtraceContext::WindowGroupMatchesThreadId(const TWindowGroup& aLeft, const TWindowGroup& aRight)
+	{
+	return (aLeft.iThreadId == aRight.iThreadId);
+	}
+
+TBool CBtraceContext::WindowGroupMatchesWServId(const TWindowGroup& aLeft, const TWindowGroup& aRight)
+	{
+	return (aLeft.iWindowGroupId == aRight.iWindowGroupId);
+	}
+
+EXPORT_C const TDesC& CBtraceContext::ThreadName(const TBtraceThreadId& aId) const
+	{
+	TThread findKey(0, 0, KNullDesC8);
+	findKey.iId = aId;
+	TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesId));
+	if (pos >= 0)
+		{
+		return iThreads[pos].iName;
+		}
+	else
+		{
+		return KUnknown;
+		}
+	}
+
+EXPORT_C void CBtraceContext::GetFullThreadName(const TBtraceThreadId& aId, TDes& aFullName) const
+	{
+	TThread findKey(0, 0, KNullDesC8);
+	findKey.iId = aId;
+	TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesId));
+	if (pos >= 0)
+		{
+		const TThread& thread = iThreads[pos];
+		TProcess findKey(thread.iOwningProcess);
+		TInt processPos = iProcesses.Find(findKey, TIdentityRelation<TProcess>(ProcessMatchesDProcessAddress));
+		__ASSERT_ALWAYS(processPos >= 0, Panic(EBtpPanicFailedToFindProcess));
+		aFullName.Zero();
+		aFullName.Append(ProcessName(iProcesses[processPos].iId));
+		aFullName.Append(_L("::"));
+		aFullName.Append(thread.iName);
+		}
+	else
+		{
+		aFullName = KUnknown;
+		}
+	}
+
+EXPORT_C TThreadId CBtraceContext::ThreadId(const TBtraceThreadId& aId) const
+	{
+	TThread findKey(0, 0, KNullDesC8);
+	findKey.iId = aId;
+	TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesId));
+	__ASSERT_ALWAYS(pos >= 0, Panic(EBtpPanicThreadIdNotFound));
+	return iThreads[pos].iKernelId;
+	}
+
+EXPORT_C const TDesC& CBtraceContext::ProcessName(const TBtraceProcessId& aId) const
+	{
+	TProcess findKey(0);
+	findKey.iId = aId;
+	TInt pos = iProcesses.Find(findKey, TIdentityRelation<TProcess>(ProcessMatchesId));
+	__ASSERT_ALWAYS(pos >= 0, Panic(EBtpPanicProcessNameNotFound));
+	return iProcesses[pos].iName;
+	}
+
+EXPORT_C TInt CBtraceContext::WindowGroupId(const TBtraceWindowGroupId& aId) const
+	{
+	TWindowGroup findKey(0, 0, KNullDesC);
+	findKey.iId = aId;
+	TInt pos = iWindowGroups.Find(findKey, TIdentityRelation<TWindowGroup>(WindowGroupMatchesId));
+	__ASSERT_ALWAYS(pos >= 0, Panic(EBtpPanicWindowGroupIdNotFound));
+	return iWindowGroups[pos].iWindowGroupId;
+	}
+
+EXPORT_C const TDesC& CBtraceContext::WindowGroupName(const TBtraceWindowGroupId& aId) const
+	{
+	TWindowGroup findKey(0, 0, KNullDesC);
+	findKey.iId = aId;
+	TInt pos = iWindowGroups.Find(findKey, TIdentityRelation<TWindowGroup>(WindowGroupMatchesId));
+	__ASSERT_ALWAYS(pos >= 0, Panic(EBtpPanicWindowGroupIdNotFound));
+	return iWindowGroups[pos].iName;
+	}
+
+EXPORT_C const TBtraceThreadId* CBtraceContext::FindThread(TUint32 aNThreadAddress) const
+	{
+	TThread findKey(aNThreadAddress, 0, KNullDesC8);
+	TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesNThreadAddress));
+	if (pos >= 0)
+		{
+		return &iThreads[pos].iId;
+		}
+	else
+		{
+		return NULL;
+		}
+	}
+
+EXPORT_C const TBtraceThreadId* CBtraceContext::FindThread(const TThreadId& aId) const
+	{
+	TThread findKey(0, 0, KNullDesC8);
+	findKey.iKernelId = TUint(aId);
+	TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesKernelId));
+	if (pos >= 0)
+		{
+		return &iThreads[pos].iId;
+		}
+	else
+		{
+		return NULL;
+		}
+	}
+
+EXPORT_C const TBtraceWindowGroupId* CBtraceContext::FindWindowGroup(TInt aWServWgId) const
+	{
+	TWindowGroup findKey(aWServWgId);
+	TInt pos = iWindowGroups.Find(findKey, TIdentityRelation<TWindowGroup>(WindowGroupMatchesWServId));
+	if (pos >= 0)
+		{
+		return &iWindowGroups[pos].iId;
+		}
+	else
+		{
+		return NULL;
+		}
+	}
+
+EXPORT_C void CBtraceContext::FindThreadsL(const TDesC& aPattern, RArray<TBtraceThreadId>& aThreads) const
+	{
+	TInt count = iThreads.Count();
+	while (--count >= 0)
+		{
+		const TThread& thread = iThreads[count];
+		TFullName name;
+		GetFullThreadName(thread.iId, name);
+		if (name.MatchF(aPattern) != KErrNotFound)
+			{
+			aThreads.AppendL(thread.iId);
+			}
+		}
+	}
+
+EXPORT_C void CBtraceContext::FindWindowGroupsL(const TDesC& aPattern, RArray<TBtraceWindowGroupId>& aWindowGroups) const
+	{
+	TInt count = iWindowGroups.Count();
+	while (--count >= 0)
+		{
+		const TWindowGroup& windowGroup = iWindowGroups[count];
+		if (windowGroup.iName.MatchF(aPattern) != KErrNotFound)
+			{
+			aWindowGroups.AppendL(windowGroup.iId);
+			}
+		}
+	}
+
+EXPORT_C void CBtraceContext::FindWindowGroupsByThreadName(const TDesC& aPattern, RArray<TBtraceWindowGroupId>& aWindowGroups) const
+	{
+	TInt count = iThreads.Count();
+	while (--count >= 0)
+		{
+		const TThread& thread = iThreads[count];
+		TFullName name;
+		GetFullThreadName(thread.iId, name);
+		if (name.MatchF(aPattern) != KErrNotFound)
+			{
+			for (TInt i = (iWindowGroups.Count() - 1); i >= 0; --i)
+				{
+				const TWindowGroup& thisWindowGroup = iWindowGroups[i];
+				if (thisWindowGroup.iThreadId.Id() == thread.iKernelId)
+					{
+					aWindowGroups.AppendL(thisWindowGroup.iId);
+					}
+				}
+			}
+		}
+	}
+
+EXPORT_C void CBtraceContext::NotifyThreadSeenL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId)
+	{
+	NotifyThreadSeenL(aPattern, aObserver, aId, ENotificationOneShot);
+	}
+
+EXPORT_C void CBtraceContext::NotifyThreadSeenL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence)
+	{
+	iThreadSeenNotifs.AppendL(TThreadSeenNotif(aId, aPattern, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtraceContext::CancelNotifyThreadSeen(MBtraceContextObserver& aObserver)
+	{
+	for (TInt i = (iThreadSeenNotifs.Count() - 1); i >= 0; --i)
+		{
+		if (&iThreadSeenNotifs[i].iObserver == &aObserver)
+			{
+			iThreadSeenNotifs.Remove(i);
+			}
+		}
+	}
+
+EXPORT_C void CBtraceContext::NotifyThreadGoneL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId)
+	{
+	return NotifyThreadGoneL(aPattern, aObserver, aId, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceContext::NotifyThreadGoneL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence)
+	{
+	iThreadGoneNotifs.AppendL(TThreadGoneNotif(aId, aPattern, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtraceContext::CancelNotifyThreadGone(MBtraceContextObserver& aObserver)
+	{
+	for (TInt i = (iThreadGoneNotifs.Count() - 1); i >= 0; --i)
+		{
+		if (&iThreadGoneNotifs[i].iObserver == &aObserver)
+			{
+			iThreadGoneNotifs.Remove(i);
+			}
+		}
+	}
+
+EXPORT_C void CBtraceContext::NotifyThreadExitL(const TDesC& aPattern, TUint aExitTypes, TInt* aReason, const TDesC* aCategory, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence)
+	{
+	iThreadExitNotifs.AppendL(TThreadExitNotif(aId, aPattern, aExitTypes, aReason, aCategory, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtraceContext::CancelNotifyThreadExit(MBtraceContextObserver& aObserver)
+	{
+	for (TInt i = (iThreadExitNotifs.Count() - 1); i >= 0; --i)
+		{
+		if (&iThreadExitNotifs[i].iObserver == &aObserver)
+			{
+			iThreadExitNotifs.Remove(i);
+			}
+		}
+	}
+
+EXPORT_C void CBtraceContext::NotifyWindowGroupSeenL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence)
+	{
+	iWindowGroupSeenNotifs.AppendL(TWindowGroupSeenNotif(aId, aPattern, TWindowGroupSeenNotif::EWindowGroupName, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtraceContext::NotifyWindowGroupSeenByThreadNameL(const TDesC& aPattern, MBtraceContextObserver& aObserver, TUint aId, TBtraceNotificationPersistence aPersistence)
+	{
+	iWindowGroupSeenNotifs.AppendL(TWindowGroupSeenNotif(aId, aPattern, TWindowGroupSeenNotif::EThreadName, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtraceContext::CancelNotifyWindowGroupSeen(MBtraceContextObserver& aObserver)
+	{
+	for (TInt i = (iWindowGroupSeenNotifs.Count() - 1); i >= 0; --i)
+		{
+		if (&iWindowGroupSeenNotifs[i].iObserver == &aObserver)
+			{
+			iWindowGroupSeenNotifs.Remove(i);
+			}
+		}
+	}
+
+CBtraceContext::CBtraceContext(CBtraceReader& aReader, TMode aMode)
+	: iMode(aMode), iReader(aReader), iNextBtraceThreadId(KMaxTUint), iNextBtraceProcessId(KMaxTUint)
+	{
+	}
+
+void CBtraceContext::ConstructL()
+	{
+	iReader.AddObserverL(BTrace::EThreadIdentification, *this, CBtraceReader::EIncludeSynchronizationFrames);
+	iReader.AddObserverL(KAmTraceCategory, *this);
+	}
+
+TUint CBtraceContext::GetNextThreadId()
+	{
+	TUint id = iNextBtraceThreadId--;
+	__ASSERT_ALWAYS(iNextBtraceThreadId > 0, Panic(EBtpPanicBtraceThreadIdOverflow));
+	return id;
+	}
+
+TUint CBtraceContext::GetNextProcessId()
+	{
+	TUint id = iNextBtraceProcessId--;
+	__ASSERT_ALWAYS(iNextBtraceProcessId > 0, Panic(EBtpPanicBtraceProcessIdOverflow));
+	return id;
+	}
+
+TUint CBtraceContext::GetNextWindowGroupId()
+	{
+	TUint id = iNextBtraceWindowGroupId--;
+	__ASSERT_ALWAYS(iNextBtraceWindowGroupId > 0, Panic(EBtpPanicBtraceWindowGroupIdOverflow));
+	return id;
+	}
+
+void CBtraceContext::SeenL(const TThread& aThread, const TBtraceTickCount& aTickCount)
+	{
+	TFullName name;
+	GetFullThreadName(aThread.iId, name);
+	for (TInt i = (iThreadSeenNotifs.Count() - 1); i >= 0; --i)
+		{
+		const TThreadSeenNotif& thisNotif = iThreadSeenNotifs[i];
+		if (name.MatchF(thisNotif.iPattern) != KErrNotFound)
+			{
+			MBtraceContextObserver& observer = thisNotif.iObserver;
+			TUint id = thisNotif.iId;
+			if (thisNotif.iPersistence == ENotificationOneShot)
+				{
+				iThreadSeenNotifs.Remove(i);
+				}
+			observer.HandleThreadSeenL(aTickCount, aThread.iId, id);
+			}
+		}
+	}
+
+void CBtraceContext::GoneL(const TThread& aThread, const TBtraceTickCount& aTickCount)
+	{
+	TFullName name;
+	GetFullThreadName(aThread.iId, name);
+	for (TInt i = (iThreadGoneNotifs.Count() - 1); i >= 0; --i)
+		{
+		const TThreadGoneNotif& notif = iThreadGoneNotifs[i];
+		if (name.MatchF(notif.iPattern) != KErrNotFound)
+			{
+			MBtraceContextObserver& observer = notif.iObserver;
+			TUint id = notif.iId;
+			if (notif.iPersistence == ENotificationOneShot)
+				{
+				iThreadGoneNotifs.Remove(i);
+				}
+			observer.HandleThreadGoneL(aTickCount, aThread.iId, id);
+			}
+		}
+	}
+
+void CBtraceContext::ExitedL(const TThread& aThread, TExitType aExitType, TInt aReason, const TDesC& aCategory, const TBtraceTickCount& aTickCount)
+	{
+	TFullName name;
+	GetFullThreadName(aThread.iId, name);
+	for (TInt i = (iThreadExitNotifs.Count() - 1); i >= 0; --i)
+		{
+		const TThreadExitNotif& notif = iThreadExitNotifs[i];
+		if (notif.Matches(name, aExitType, aReason, aCategory))
+			{
+			MBtraceContextObserver& observer = notif.iObserver;
+			TUint id = notif.iId;
+			if (notif.iPersistence == ENotificationOneShot)
+				{
+				iThreadExitNotifs.Remove(i);
+				}
+			observer.HandleThreadExitL(aTickCount, aThread.iId, aExitType, aReason, aCategory, id);
+			}
+		}
+	}
+
+void CBtraceContext::SeenL(const TWindowGroup& aWindowGroup, const TBtraceTickCount& aTickCount)
+	{
+	for (TInt i = (iWindowGroupSeenNotifs.Count() - 1); i >= 0; --i)
+		{
+		const TWindowGroupSeenNotif& thisNotif = iWindowGroupSeenNotifs[i];
+		if (thisNotif.iPatternType == TWindowGroupSeenNotif::EWindowGroupName)
+			{
+			if (aWindowGroup.iName.MatchF(thisNotif.iPattern) != KErrNotFound)
+				{
+				MBtraceContextObserver& observer = thisNotif.iObserver;
+				TUint id = thisNotif.iId;
+				if (thisNotif.iPersistence == ENotificationOneShot)
+					{
+					iWindowGroupSeenNotifs.Remove(i);
+					}
+				observer.HandleWindowGroupSeenL(aTickCount, aWindowGroup.iId, id);
+				}
+			}
+		else
+			{
+			TThread findKey(0, 0, KNullDesC8);
+			findKey.iKernelId = TUint(aWindowGroup.iThreadId);
+			TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesKernelId));
+			if (pos >= 0)
+				{
+				TFullName threadName;
+				GetFullThreadName(iThreads[pos].iId, threadName);
+				if (threadName.MatchF(thisNotif.iPattern))
+					{
+					MBtraceContextObserver& observer = thisNotif.iObserver;
+					TUint id = thisNotif.iId;
+					if (thisNotif.iPersistence == ENotificationOneShot)
+						{
+						iWindowGroupSeenNotifs.Remove(i);
+						}
+					observer.HandleWindowGroupSeenL(aTickCount, aWindowGroup.iId, id);
+					}
+				}
+			}
+		}
+	}
+
+void CBtraceContext::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	const TUint8* data = aFrame.iData.Ptr();
+
+	if (aFrame.iCategory == BTrace::EThreadIdentification)
+		{
+		switch (aFrame.iSubCategory)
+			{
+			case BTrace::EThreadCreate:
+				{
+				TUint32 nthreadAddress = *(TUint32*)data;
+				TUint32 dprocessAddress = *((TUint32*)data + 1);
+				TPtrC8 name(aFrame.iData.Mid(8));
+
+#ifdef BTRACE_CONTEXT_DEBUG
+				TFullName name16;
+				name16.Copy(name);
+				RDebug::Print(_L("BTrace::EThreadCreate: 0x%08x \"%S\""), nthreadAddress, &name16);
+#endif
+
+				TThread thread(nthreadAddress, dprocessAddress, name);
+				AppendL(thread, aFrame.iTickCount);
+				break;
+				}
+			case BTrace::EThreadDestroy:
+				{
+				TUint32 nthreadAddress = *(TUint32*)data;
+				TThread findKey(nthreadAddress, 0, KNullDesC8);
+				TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesNThreadAddress));
+				if (pos >= 0)
+					{
+#ifdef BTRACE_CONTEXT_DEBUG
+					RDebug::Print(_L("BTrace::EThreadDestroy: %u %u 0x%08x \"%S\""), iThreads[pos].iId.Value(), iThreads[pos].iKernelId, nthreadAddress, &iThreads[pos].iName);
+#endif
+					GoneL(iThreads[pos], aFrame.iTickCount);
+					RemoveThread(pos);
+					}
+				else
+					{
+					// This can happen if a thread is destroyed after the btrace buffer has been enabled but before the BTrace::EThreadIdentification category has been enabled.
+					iReader.Log(_L("Destroyed thread 0x%08x not found\r\n"), nthreadAddress);
+					}
+				break;
+				}
+			case BTrace::EThreadName:
+				{
+				TUint32 nthreadAddress = *(TUint32*)data;
+				TUint32 dprocessAddress = *((TUint32*)data + 1);
+				TPtrC8 name(aFrame.iData.Mid(8));
+
+#ifdef BTRACE_CONTEXT_DEBUG
+				TFullName name16;
+				name16.Copy(name);
+				RDebug::Print(_L("BTrace::EThreadName: 0x%08x \"%S\""), nthreadAddress, &name16);
+#endif				
+				TThread findKey(nthreadAddress, 0, KNullDesC8);
+				TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesNThreadAddress));
+				if (pos >= 0)
+					{
+					iThreads[pos].iName.Copy(name);
+					SeenL(iThreads[pos], aFrame.iTickCount);
+					}
+				else
+					{
+					TThread thread(nthreadAddress, dprocessAddress, name);
+					AppendL(thread, aFrame.iTickCount);
+					}
+				break;
+				}
+			case BTrace::EProcessCreate:
+				{
+				TUint32 dprocessAddress = *(TUint32*)data;
+#ifdef BTRACE_CONTEXT_DEBUG
+				RDebug::Print(_L("BTrace::EProcessCreate: 0x%08x"), dprocessAddress);
+#endif
+				TProcess process(dprocessAddress);
+				AppendL(process, aFrame.iTickCount);
+				break;
+				}
+			case BTrace::EProcessName:
+				{
+				TUint32 dprocessAddress = *((TUint32*)data + 1);
+				TPtrC8 name(aFrame.iData.Mid(8));
+
+#ifdef BTRACE_CONTEXT_DEBUG
+				TFullName name16;
+				name16.Copy(name);
+				RDebug::Print(_L("BTrace::EProcessName: 0x%08x \"%S\""), dprocessAddress, &name16);
+#endif
+				TProcess findKey(dprocessAddress);
+				TInt pos = iProcesses.Find(findKey, TIdentityRelation<TProcess>(ProcessMatchesDProcessAddress));
+				if (pos >= 0)
+					{
+					iProcesses[pos].iName.Copy(name);
+					SeenAllThreadsL(iProcesses[pos], aFrame.iTickCount);
+					}
+				else
+					{
+					TProcess process(dprocessAddress, name);
+					AppendL(process, aFrame.iTickCount);
+					}
+				break;
+				}
+			case BTrace::EThreadId:
+				{
+				TUint32 nthreadAddress = *(TUint32*)data;
+				TUint32 threadId = *((TUint32*)data + 2);
+				TThread findKey(nthreadAddress, 0, KNullDesC8);
+				TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesNThreadAddress));
+				__ASSERT_ALWAYS(pos >= 0, Panic(EBtpPanicThreadNotFoundForId));
+				iThreads[pos].iKernelId = threadId;
+#ifdef BTRACE_CONTEXT_DEBUG
+				RDebug::Print(_L("BTrace::EThreadId: %u 0x%08x \"%S\""), threadId, nthreadAddress, &iThreads[pos].iName);
+#endif
+				break;
+				}
+			default:
+				{
+				// Ignore anything we don't know about.
+				break;
+				}
+			}
+		}
+	else if (aFrame.iCategory == KAmTraceCategory)
+		{
+		if (aFrame.iSubCategory == EAmTraceSubCategoryWindowGroupName)
+			{
+			TUint wgId = *(TUint32*)data;
+			TInt kernelThreadId = *((TInt32*)data + 1);
+			TPtrC8 nameData = aFrame.iData.Mid(8);
+			TPtrC name((TUint16*)nameData.Ptr(), nameData.Length() / 2);
+			TWindowGroup findKey(wgId);
+			TInt pos = iWindowGroups.Find(findKey, TIdentityRelation<TWindowGroup>(WindowGroupMatchesWServId));
+			if (pos >= 0)
+				{
+				TWindowGroup& windowGroup = iWindowGroups[pos];
+				windowGroup.iName = name;
+				SeenL(windowGroup, aFrame.iTickCount);
+				}
+			else
+				{
+				TWindowGroup windowGroup(wgId, TThreadId(kernelThreadId), name);
+				windowGroup.iId.Set(GetNextWindowGroupId());
+				iWindowGroups.AppendL(windowGroup);
+				SeenL(windowGroup, aFrame.iTickCount);
+				}
+			}
+		else if ((aFrame.iSubCategory >= EAmTraceSubCategoryThreadKilled) && (aFrame.iSubCategory <= EAmTraceSubCategoryThreadPanicked))
+			{
+			TUint id = *(TUint32*)data;
+			TInt reason = *((TInt32*)data + 1);
+			TThread findKey(0, 0, KNullDesC8);
+			findKey.iKernelId = id;
+			TInt pos = iThreads.Find(findKey, TIdentityRelation<TThread>(ThreadMatchesKernelId));
+			if (pos >= 0)
+				{
+				const TThread& thread = iThreads[pos];
+				switch (aFrame.iSubCategory)
+					{
+					case EAmTraceSubCategoryThreadKilled:
+						{
+						ExitedL(thread, EExitKill, reason, KNullDesC, aFrame.iTickCount);
+						break;
+						}
+					case EAmTraceSubCategoryThreadTerminated:
+						{
+						ExitedL(thread, EExitTerminate, reason, KNullDesC, aFrame.iTickCount);
+						break;
+						}
+					case EAmTraceSubCategoryThreadPanicked:
+						{
+						TPtrC8 narrowCategory(aFrame.iData.Mid(sizeof(TInt) * 2));
+						TExitCategoryName category;
+						category.Copy(narrowCategory);
+						ExitedL(thread, EExitPanic, reason, category, aFrame.iTickCount);
+						break;
+						}
+					default:
+						{
+						// Ignore anything we don't know about.
+						break;
+						}
+					}
+				}
+			}
+		}
+	}
+
+void CBtraceContext::AppendL(const TThread& aThread, const TBtraceTickCount& aTickCount)
+	{
+	iThreads.AppendL(aThread);
+	TThread& thread = iThreads[iThreads.Count() - 1];
+	thread.iId.Set(GetNextThreadId());
+
+	// Increment the reference count of the owning process.
+	TProcess findKey(thread.iOwningProcess);
+	TInt pos = iProcesses.Find(findKey, TIdentityRelation<TProcess>(ProcessMatchesDProcessAddress));
+	if (pos >= 0)
+		{
+		++(iProcesses[pos].iReferenceCount);
+		}
+
+	SeenL(thread, aTickCount);
+	}
+
+void CBtraceContext::AppendL(const TProcess& aProcess, const TBtraceTickCount& aTickCount)
+	{
+	iProcesses.AppendL(aProcess);
+	TProcess& process = iProcesses[iProcesses.Count() - 1];
+	process.iId.Set(GetNextProcessId());
+
+	// Set the reference count for this process.
+	for (TInt i = (iThreads.Count() - 1); i >= 0; --i)
+		{
+		if (iThreads[i].iOwningProcess == process.iDProcessAddress)
+			{
+			++process.iReferenceCount;
+			}
+		}
+
+	SeenAllThreadsL(process, aTickCount);
+	}
+
+void CBtraceContext::RemoveThread(TInt aPosition)
+	{
+	TProcess findKey(iThreads[aPosition].iOwningProcess);
+	TInt processPos = iProcesses.Find(findKey, TIdentityRelation<TProcess>(ProcessMatchesDProcessAddress));
+	if (processPos >= 0)
+		{
+		if (--(iProcesses[processPos].iReferenceCount) == 0)
+			{
+			iProcesses.Remove(processPos);
+			}
+		}
+	iThreads.Remove(aPosition);
+	}
+
+void CBtraceContext::SeenAllThreadsL(const TProcess& aProcess, const TBtraceTickCount& aTickCount)
+	{
+	// Call SeenL for each thread belonging to this process because. This is called when a process
+	// is created or altered because this change may allow a TThreadSeenNotif to be completed.
+	const TInt numThreads = iThreads.Count();
+	for (TInt i = 0; i < numThreads; ++i)
+		{
+		const TThread& thread = iThreads[i];
+		if (thread.iOwningProcess == aProcess.iDProcessAddress)
+			{
+			SeenL(thread, aTickCount);
+			}
+		}
+	}
+
+void CBtraceContext::BtraceBufferHasBeenReset()
+	{
+	iThreads.Close();
+	iProcesses.Close();
+	}
+
+CBtraceContext::TThread::TThread(TUint32 aNThreadAddress, TUint32 aOwningProcess, const TDesC8& aName)
+	: iNThreadAddress(aNThreadAddress), iOwningProcess(aOwningProcess), iKernelId(0)
+	{
+	iName.Copy(aName);
+	}
+
+CBtraceContext::TProcess::TProcess(TUint32 aDProcessAddress)
+	: iDProcessAddress(aDProcessAddress), iReferenceCount(0)
+	{
+	}
+
+CBtraceContext::TProcess::TProcess(TUint32 aDProcessAddress, const TDesC8& aName)
+	: iDProcessAddress(aDProcessAddress), iReferenceCount(0)
+	{
+	iName.Copy(aName);
+	}
+
+CBtraceContext::TWindowGroup::TWindowGroup(TInt aWindowGroupId)
+	: iWindowGroupId(aWindowGroupId), iThreadId(0)
+	{
+	}
+
+CBtraceContext::TWindowGroup::TWindowGroup(const TDesC& aName)
+	: iWindowGroupId(0), iThreadId(0), iName(aName)
+	{
+	}
+
+CBtraceContext::TWindowGroup::TWindowGroup(TInt aWindowGroupId, TThreadId aThreadId, const TDesC& aName)
+	: iWindowGroupId(aWindowGroupId), iThreadId(aThreadId), iName(aName)
+	{
+	}
+
+CBtraceContext::TThreadSeenNotif::TThreadSeenNotif(TUint aId, const TDesC& aPattern, MBtraceContextObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iId(aId), iPattern(aPattern), iObserver(aObserver), iPersistence(aPersistence)
+	{
+	}
+
+CBtraceContext::TThreadGoneNotif::TThreadGoneNotif(TUint aId, const TDesC& aPattern, MBtraceContextObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iId(aId), iPattern(aPattern), iObserver(aObserver), iPersistence(aPersistence)
+	{
+	}
+
+CBtraceContext::TThreadExitNotif::TThreadExitNotif(TUint aId, const TDesC& aPattern, TUint aExitTypes, TInt* aReason, const TDesC* aCategory, MBtraceContextObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iId(aId), iPattern(aPattern), iExitTypes(aExitTypes), iReason(aReason), iCategory(aCategory), iObserver(aObserver), iPersistence(aPersistence)
+	{
+	}
+
+CBtraceContext::TWindowGroupSeenNotif::TWindowGroupSeenNotif(TUint aId, const TDesC& aPattern, TPatternType aPatternType, MBtraceContextObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iId(aId), iPattern(aPattern), iPatternType(aPatternType), iObserver(aObserver), iPersistence(aPersistence)
+	{
+	}
+
+TBool CBtraceContext::TThreadExitNotif::Matches(const TDesC& aThreadName, TExitType aExitType, TInt aReason, const TDesC& aCategory) const
+	{
+	if (aThreadName.MatchF(iPattern) != KErrNotFound)
+		{
+		if (MatchesType(aExitType))
+			{
+			if ((iReason == NULL) || (*iReason == aReason))
+				{
+				if ((aExitType != EExitPanic) || ((iCategory == NULL) || (*iCategory == aCategory)))
+					{
+					return ETrue;
+					}
+				}
+			}
+		}
+	return EFalse;
+	}
+
+TBool CBtraceContext::TThreadExitNotif::MatchesType(TExitType aExitType) const
+	{
+	switch (aExitType)
+		{
+		case EExitKill:
+			return (iExitTypes & EKill);
+		case EExitTerminate:
+			return (iExitTypes & ETerminate);
+		case EExitPanic:
+			return (iExitTypes & EPanic);
+		default:
+			ASSERT(EFalse);
+			return EFalse;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_cpuusage.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,344 @@
+// btrace_cpuusage.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace_parser.h"
+
+MBtraceCpuUsageObserver::TCpuUsage::TCpuUsage(const TBtraceThreadId& aId)
+	: iId(aId), iNumFastTicks(0)
+	{
+	}
+
+MBtraceCpuUsageObserver::TCpuUsage::TCpuUsage(const TBtraceThreadId& aId, const TBtraceTickCount& aTickCount)
+	: iId(aId), iNumFastTicks(0), iSwitchedInAt(aTickCount)
+	{
+	}
+
+EXPORT_C CBtraceCpuUsage* CBtraceCpuUsage::NewL(CBtraceReader& aReader, CBtraceContext& aContext)
+	{
+	CBtraceCpuUsage* self = new(ELeave) CBtraceCpuUsage(aReader, aContext);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CBtraceCpuUsage::~CBtraceCpuUsage()
+	{
+	while (iCpuUsageNotifs.Count())
+		{
+		iCpuUsageNotifs[0].Close();
+		iCpuUsageNotifs.Remove(0);
+		}
+	iCpuUsageNotifs.Close();
+	iContextSwitchNotifs.Close();
+	iThreadIdleNotifs.Close();
+	iReader.RemoveObserver(BTrace::ECpuUsage, *this);
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	}
+
+EXPORT_C void CBtraceCpuUsage::NotifyCpuUsageL(TUint32 aNanoTickCount, TTimeIntervalMicroSeconds32 aPeriod, MBtraceCpuUsageObserver& aObserver)
+	{
+	NotifyCpuUsageL(aNanoTickCount, aPeriod, aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceCpuUsage::NotifyCpuUsageL(TUint32 aNanoTickCount, TTimeIntervalMicroSeconds32 aPeriod, MBtraceCpuUsageObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	RCpuUsageNotif notif(aNanoTickCount, TBtraceUtils::MicroSecondsToNanoTicks(aPeriod), aObserver, aPersistence);
+	User::LeaveIfError(iCpuUsageNotifs.Append(notif));
+	}
+	
+EXPORT_C void CBtraceCpuUsage::NotifyContextSwitchL(const TBtraceThreadId& aId, MBtraceCpuUsageObserver& aObserver)
+	{
+	TContextSwitchNotif notif(aId, aObserver);
+	User::LeaveIfError(iContextSwitchNotifs.InsertInUnsignedKeyOrderAllowRepeats(notif));
+	}
+
+EXPORT_C void CBtraceCpuUsage::NotifyThreadIdleL(const TBtraceThreadId& aId, const TBtraceTickCount& aFromTickCount, TTimeIntervalMicroSeconds32 aPeriod, MBtraceCpuUsageObserver& aObserver)
+	{
+	NotifyThreadIdleL(aId, aFromTickCount, aPeriod, aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceCpuUsage::NotifyThreadIdleL(const TBtraceThreadId& aId, const TBtraceTickCount& aFromTickCount, TTimeIntervalMicroSeconds32 aPeriod, MBtraceCpuUsageObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TThreadIdleNotif notif(aId, aFromTickCount, TBtraceUtils::MicroSecondsToNanoTicks(aPeriod), aObserver, aPersistence);
+	User::LeaveIfError(iThreadIdleNotifs.InsertInUnsignedKeyOrderAllowRepeats(notif));
+	}
+	
+EXPORT_C void CBtraceCpuUsage::CancelNotifyThreadIdle(MBtraceCpuUsageObserver& aObserver)
+	{
+	for (TInt i = iThreadIdleNotifs.Count()-1; i>=0; --i)
+		{
+		if (iThreadIdleNotifs[i].iObserver == &aObserver)
+			{
+			iThreadIdleNotifs.Remove(i);
+			}
+		}
+	}
+
+CBtraceCpuUsage::CBtraceCpuUsage(CBtraceReader& aReader, CBtraceContext& aContext)
+	: iReader(aReader), iContext(aContext)
+	{
+	}
+
+void CBtraceCpuUsage::ConstructL()
+	{
+	iReader.AddObserverL(BTrace::ECpuUsage, *this);
+	iReader.AddObserverL(KAmTraceCategory, *this); // To ensure we get heartbeat and sync frames, which are needed to flush through and force TestThreadIdlenessL to be called
+	}
+
+void CBtraceCpuUsage::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iCategory == BTrace::ECpuUsage)
+		{
+		switch (aFrame.iSubCategory)
+			{
+			case BTrace::ENewThreadContext:
+				{
+				++iNumProcessedFrames;
+				const TBtraceThreadId* btraceThreadId = iContext.FindThread(aFrame.iThreadContext);
+//				__ASSERT_ALWAYS(btraceThreadId, Panic(EBtpPanicUnknownCpuContext));
+				if (btraceThreadId)
+					{
+					HandleContextSwitchL(aFrame.iTickCount, *btraceThreadId);
+					}
+				else
+					{
+					iReader.Log(_L("BTrace::ENewThreadContext: Unknown thread context 0x%08x\r\n"), aFrame.iThreadContext);
+					}
+				break;
+				}
+			default:
+				{
+				// Ignore anything we don't know about.
+				++iNumIgnoredFrames;
+				break;
+				}
+			}
+		}
+
+	TestCpuUsagePeriodL(aFrame.iTickCount);
+	TestThreadIdlenessL(aFrame.iTickCount);
+	}
+
+CBtraceCpuUsage::RCpuUsageNotif::RCpuUsageNotif(TUint32 aStartTickCount, TUint32 aNumNanoTicks, MBtraceCpuUsageObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iStartTickCount(aStartTickCount), iNumNanoTicks(aNumNanoTicks), iObserver(&aObserver), iPersistence(aPersistence)
+	{
+	}
+
+void CBtraceCpuUsage::RCpuUsageNotif::RCpuUsageNotif::Close()
+	{
+	iUsage.Close();
+	}
+
+CBtraceCpuUsage::TContextSwitchNotif::TContextSwitchNotif(const TBtraceThreadId& aId)
+	: iId(aId), iObserver(NULL)
+	{
+	}
+
+CBtraceCpuUsage::TContextSwitchNotif::TContextSwitchNotif(const TBtraceThreadId& aId, MBtraceCpuUsageObserver& aObserver)
+	: iId(aId), iObserver(&aObserver)
+	{
+	}
+
+CBtraceCpuUsage::TThreadIdleNotif::TThreadIdleNotif(const TBtraceThreadId& aId)
+	: iId(aId), iNumNanoTicks(0), iObserver(NULL), iEverScheduled(EFalse), iPersistence(ENotificationOneShot)
+	{
+	}
+
+CBtraceCpuUsage::TThreadIdleNotif::TThreadIdleNotif(const TBtraceThreadId& aId, const TBtraceTickCount& aFromTickCount, TUint aNumNanoTicks, MBtraceCpuUsageObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iId(aId), iNumNanoTicks(aNumNanoTicks), iObserver(&aObserver), iLastSwitchedOut(aFromTickCount), iEverScheduled(EFalse), iPersistence(aPersistence)
+	{
+	}
+
+void CBtraceCpuUsage::HandleContextSwitchL(const TBtraceTickCount& aTickCount, const TBtraceThreadId& aNewBtraceThreadId)
+	{
+	TBool relevant(EFalse);
+
+	if (iLastBtractThreadId.Value() != 0)
+		{
+		// Update CPU usage notifications for the thread that has been switched out.
+		for (TInt i = (iCpuUsageNotifs.Count() - 1); i >= 0; --i)
+			{
+			RCpuUsageNotif& notif = iCpuUsageNotifs[i];
+			TInt pos = notif.iUsage.FindInUnsignedKeyOrder(MBtraceCpuUsageObserver::TCpuUsage(iLastBtractThreadId));
+			if (pos >= 0)
+				{
+				MBtraceCpuUsageObserver::TCpuUsage& usage = notif.iUsage[pos];
+				usage.iNumFastTicks += aTickCount.IntervalInFastTicks(usage.iSwitchedInAt);
+				relevant = ETrue;
+				}
+			}
+		}
+	
+	// Update CPU usage notifications to store this tick count at which this thread was switched in.
+	for (TInt i = (iCpuUsageNotifs.Count() - 1); i >= 0; --i)
+		{
+		relevant = ETrue;
+		RCpuUsageNotif& notif = iCpuUsageNotifs[i];
+		TInt pos = notif.iUsage.FindInUnsignedKeyOrder(aNewBtraceThreadId);
+		if (pos == KErrNotFound)
+			{
+			MBtraceCpuUsageObserver::TCpuUsage cpuUsage(aNewBtraceThreadId, aTickCount);
+			TInt err = notif.iUsage.InsertInUnsignedKeyOrder(cpuUsage);
+			__ASSERT_ALWAYS(err == KErrNone, Panic(EBtpPanicFailedToInsertCpuUsageObject));
+			}
+		else
+			{
+			notif.iUsage[pos].iSwitchedInAt = aTickCount;
+			}
+		}
+
+	// Inform context switch observers that are interested in switches from the previous thread.
+	TInt pos = iContextSwitchNotifs.SpecificFindInUnsignedKeyOrder(TContextSwitchNotif(iLastBtractThreadId), EArrayFindMode_First);
+	if (pos >= 0)
+		{
+		const TInt numNotifs = iContextSwitchNotifs.Count();
+		for (TInt i = 0; i < numNotifs; ++i)
+			{
+			const TContextSwitchNotif& thisNotif = iContextSwitchNotifs[i];
+			if (thisNotif.iId == iLastBtractThreadId)
+				{
+				relevant = ETrue;
+				thisNotif.iObserver->HandleContextSwitchL(aTickCount, iLastBtractThreadId, MBtraceCpuUsageObserver::EFromThisThread);
+				}
+			else
+				{
+				break;
+				}
+			}
+		}
+
+	// Inform context switch observers that are interested in switches to this new thread.
+	pos = iContextSwitchNotifs.SpecificFindInUnsignedKeyOrder(TContextSwitchNotif(aNewBtraceThreadId), EArrayFindMode_First);
+	if (pos >= 0)
+		{
+		const TInt numNotifs = iContextSwitchNotifs.Count();
+		for (TInt i = pos; i < numNotifs; ++i)
+			{
+			const TContextSwitchNotif& thisNotif = iContextSwitchNotifs[i];
+			if (thisNotif.iId == aNewBtraceThreadId)
+				{
+				relevant = ETrue;
+				thisNotif.iObserver->HandleContextSwitchL(aTickCount, aNewBtraceThreadId, MBtraceCpuUsageObserver::EToThisThread);
+				}
+			else
+				{
+				break;
+				}
+			}
+		}
+
+	// Update thread idle notifications' last switched out time.
+	pos = iThreadIdleNotifs.SpecificFindInUnsignedKeyOrder(TThreadIdleNotif(iLastBtractThreadId), EArrayFindMode_First);
+	if (pos >= 0)
+		{
+		const TInt numNotifs = iThreadIdleNotifs.Count();
+		for (TInt i = pos; i < numNotifs; ++i)
+			{
+			TThreadIdleNotif& thisNotif = iThreadIdleNotifs[i];
+			if (thisNotif.iId == iLastBtractThreadId)
+				{
+				relevant = ETrue;
+				thisNotif.iLastSwitchedOut = aTickCount;
+				}
+			else
+				{
+				break;
+				}
+			}
+		}
+
+	// Update thread idle notifications' ever scheduled.
+	pos = iThreadIdleNotifs.SpecificFindInUnsignedKeyOrder(TThreadIdleNotif(aNewBtraceThreadId), EArrayFindMode_First);
+	if (pos >= 0)
+		{
+		const TInt numNotifs = iThreadIdleNotifs.Count();
+		for (TInt i = pos; i < numNotifs; ++i)
+			{
+			TThreadIdleNotif& thisNotif = iThreadIdleNotifs[i];
+			if (thisNotif.iId == aNewBtraceThreadId)
+				{
+				relevant = ETrue;
+				thisNotif.iEverScheduled = ETrue;
+				}
+			else
+				{
+				break;
+				}
+			}
+		}
+
+	iLastBtractThreadId = aNewBtraceThreadId;
+
+	if (relevant)
+		{
+		++iNumRelevantFrames;
+		}
+	}
+
+TInt CompareUsage(const MBtraceCpuUsageObserver::TCpuUsage& aFirst,const MBtraceCpuUsageObserver::TCpuUsage& aSecond)
+	{
+	if (aFirst.iNumFastTicks > aSecond.iNumFastTicks)
+		{
+		return -1;
+		}
+	else if (aFirst.iNumFastTicks < aSecond.iNumFastTicks)
+		{
+		return 1;
+		}
+	else
+		{
+		return 0;
+		}
+	}
+
+void CBtraceCpuUsage::TestCpuUsagePeriodL(const TBtraceTickCount& aTickCount)
+	{
+	for (TInt i = (iCpuUsageNotifs.Count() - 1); i >= 0; --i)
+		{
+		RCpuUsageNotif& thisNotif = iCpuUsageNotifs[i];
+		if ((aTickCount.iNano - thisNotif.iStartTickCount) >= thisNotif.iNumNanoTicks)
+			{
+			thisNotif.iUsage.Sort(TLinearOrder<MBtraceCpuUsageObserver::TCpuUsage>(CompareUsage));
+			TArray<MBtraceCpuUsageObserver::TCpuUsage> array(thisNotif.iUsage.Array());
+			thisNotif.iObserver->HandleCpuUsageL(aTickCount, array);
+			if (thisNotif.iPersistence == ENotificationOneShot)
+				{
+				thisNotif.Close();
+				iCpuUsageNotifs.Remove(i);
+				}
+			}
+		}
+	}
+
+void CBtraceCpuUsage::TestThreadIdlenessL(const TBtraceTickCount& aTickCount)
+	{
+	for (TInt i = (iThreadIdleNotifs.Count() - 1); i >= 0; --i)
+		{
+		const TThreadIdleNotif& thisNotif = iThreadIdleNotifs[i];
+		//iReader.Log(_L("CBtraceCpuUsage::TestThreadIdlenessL: now %d, lastswitch %d, remaining %d\r\n"), aTickCount.iNano, thisNotif.iLastSwitchedOut.iNano, thisNotif.iNumNanoTicks - (aTickCount.iNano - thisNotif.iLastSwitchedOut.iNano));
+		if ((aTickCount.iNano > thisNotif.iLastSwitchedOut.iNano) && ((aTickCount.iNano - thisNotif.iLastSwitchedOut.iNano) >= thisNotif.iNumNanoTicks))
+			{
+			MBtraceCpuUsageObserver* observer = thisNotif.iObserver;
+			TBtraceTickCount lastSwitchedOut = thisNotif.iLastSwitchedOut;
+			TBtraceThreadId threadId = thisNotif.iId;
+			MBtraceCpuUsageObserver::TIdleType idleType = thisNotif.iEverScheduled ? MBtraceCpuUsageObserver::EScheduledAtLeastOnce : MBtraceCpuUsageObserver::ENeverScheduled;
+
+			if (thisNotif.iPersistence == ENotificationOneShot)
+				{
+				iThreadIdleNotifs.Remove(i);
+				}
+
+			observer->HandleThreadIdleL(lastSwitchedOut, threadId, idleType);
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_domainevent.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,147 @@
+// btrace_domainevent.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace_parser.h"
+
+EXPORT_C CBtraceDomainEvent* CBtraceDomainEvent::NewL(CBtraceReader& aReader)
+	{
+	CBtraceDomainEvent* self = new (ELeave) CBtraceDomainEvent(aReader);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBtraceDomainEvent::CBtraceDomainEvent(CBtraceReader& aReader)
+	: iReader(aReader)
+	{
+	}
+
+EXPORT_C CBtraceDomainEvent::~CBtraceDomainEvent()
+	{
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	iNotifs.Close();
+	}
+
+void CBtraceDomainEvent::ConstructL()
+	{
+	iReader.AddObserverL(KAmTraceCategory, *this);
+	}
+
+EXPORT_C void CBtraceDomainEvent::NotifyDomainEventL(TUint aSubCategory, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TDomainEventNotif notif(aSubCategory, aObserver, aPersistence);
+	iNotifs.AppendL(notif);
+	}
+
+EXPORT_C void CBtraceDomainEvent::NotifyDomainEventL(TUint aSubCategory, TUint aData1, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TDomainEventNotif notif(aSubCategory, aObserver, aPersistence);
+	notif.AddDataItem(aData1);
+	iNotifs.AppendL(notif);
+	}
+
+EXPORT_C void CBtraceDomainEvent::NotifyDomainEventL(TUint aSubCategory, TUint aData1, TUint aData2, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TDomainEventNotif notif(aSubCategory, aObserver, aPersistence);
+	notif.AddDataItem(aData1);
+	notif.AddDataItem(aData2);
+	iNotifs.AppendL(notif);
+	}
+
+EXPORT_C void CBtraceDomainEvent::NotifyDomainEventL(TUint aSubCategory, TUint aData1, TUint aData2, TUint aData3, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TDomainEventNotif notif(aSubCategory, aObserver, aPersistence);
+	notif.AddDataItem(aData1);
+	notif.AddDataItem(aData2);
+	notif.AddDataItem(aData3);
+	iNotifs.AppendL(notif);
+	}
+
+EXPORT_C void CBtraceDomainEvent::CancelNotifyDomainEvent(MBtraceDomainEventObserver& aObserver)
+	{
+	for (TInt i = (iNotifs.Count() - 1); i >= 0; --i)
+		{
+		const TDomainEventNotif& thisNotif = iNotifs[i];
+		if (thisNotif.iObserver == &aObserver)
+			{
+			iNotifs.Remove(i);
+			}
+		}
+	}
+
+void CBtraceDomainEvent::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iCategory == KAmTraceCategory && aFrame.iSubCategory > EAmTraceSubCategoryDomainEventBase)
+		{
+		const TInt numDataItems = (aFrame.iData.Length() / sizeof(TUint));
+		if (numDataItems <= TDomainEventNotif::KMaxNumDataItems)
+			{
+			const TUint* data = reinterpret_cast<const TUint*>(aFrame.iData.Ptr());
+			TDomainEventNotif notif(aFrame.iSubCategory);
+			for (TInt i = 0; i < numDataItems; ++i)
+				{
+				notif.AddDataItem(*(data + i));
+				}
+
+			for (TInt i = (iNotifs.Count() - 1); i >= 0; --i)
+				{
+				const TDomainEventNotif& thisNotif = iNotifs[i];
+				if (thisNotif == notif)
+					{
+					MBtraceDomainEventObserver* observer = thisNotif.iObserver;
+					if (thisNotif.iPersistence == ENotificationOneShot)
+						{
+						iNotifs.Remove(i);
+						}
+					observer->HandleDomainEventL(aFrame.iTickCount, *observer);
+					}
+				}
+			}
+		}
+	}
+
+CBtraceDomainEvent::TDomainEventNotif::TDomainEventNotif(TUint aSubCategory)
+	: iSubCategory(aSubCategory), iObserver(NULL), iPersistence(ENotificationOneShot), iDataCount(0)
+	{
+	}
+
+CBtraceDomainEvent::TDomainEventNotif::TDomainEventNotif(TUint aSubCategory, MBtraceDomainEventObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iSubCategory(aSubCategory), iObserver(&aObserver), iPersistence(aPersistence), iDataCount(0)
+	{
+	}
+
+void CBtraceDomainEvent::TDomainEventNotif::AddDataItem(TUint aData)
+	{
+	__ASSERT_ALWAYS(iDataCount < KMaxNumDataItems, Panic(EBtpPanicTooManyDomainEventDataItems));
+	iData[iDataCount++] = aData;
+	}
+
+TBool CBtraceDomainEvent::TDomainEventNotif::operator==(const TDomainEventNotif& aNotif) const
+	{
+	if ((aNotif.iSubCategory == iSubCategory) && (aNotif.iDataCount == iDataCount))
+		{
+		for (TInt i = 0; i < iDataCount; ++i)
+			{
+			if (aNotif.iData[i] != iData[i])
+				{
+				return EFalse;
+				}
+			}
+		return ETrue;
+		}
+	else
+		{
+		return EFalse;
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_focuschange.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,90 @@
+// btrace_focuschange.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace_parser.h"
+
+EXPORT_C CBtraceFocusChange* CBtraceFocusChange::NewL(CBtraceReader& aReader, CBtraceContext& aContext)
+	{
+	CBtraceFocusChange* self = new(ELeave) CBtraceFocusChange(aReader, aContext);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBtraceFocusChange::CBtraceFocusChange(CBtraceReader& aReader, CBtraceContext& aContext)
+	: iReader(aReader), iContext(aContext)
+	{
+	}
+
+EXPORT_C CBtraceFocusChange::~CBtraceFocusChange()
+	{
+	iNotifs.Close();
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	}
+
+void CBtraceFocusChange::ConstructL()
+	{
+	iReader.AddObserverL(KAmTraceCategory, *this);
+	}
+
+EXPORT_C void CBtraceFocusChange::NotifyFocusChangedL(const TDesC& aWindowGroupNamePattern, MBtraceFocusChangeObserver& aObserver)
+	{
+	NotifyFocusChangedL(aWindowGroupNamePattern, aObserver, ENotificationOneShot);
+	}
+
+EXPORT_C void CBtraceFocusChange::NotifyFocusChangedL(const TDesC& aWindowGroupNamePattern, MBtraceFocusChangeObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	iNotifs.AppendL(TFocusChangeNotif(aWindowGroupNamePattern, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtraceFocusChange::CancelNotifyFocusChanged(MBtraceFocusChangeObserver& aObserver)
+	{
+	for (TInt i = (iNotifs.Count() - 1); i >= 0; --i)
+		{
+		if (&iNotifs[i].iObserver == &aObserver)
+			{
+			iNotifs.Remove(i);
+			}
+		}
+	}
+
+void CBtraceFocusChange::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iSubCategory == EAmTraceSubCategoryWindowGroupFocus)
+		{
+		const TInt32* data = (const TInt32*)aFrame.iData.Ptr();
+		TInt wservWindowGroupId = *data;
+		const TBtraceWindowGroupId* windowGroupId = iContext.FindWindowGroup(wservWindowGroupId);
+		__ASSERT_ALWAYS(windowGroupId, Panic(EBtpPanicWservWindowGroupIdNotFound));
+		const TDesC& windowGroupName = iContext.WindowGroupName(*windowGroupId);
+		
+		for (TInt i = (iNotifs.Count() - 1); i >= 0; --i)
+			{
+			const TFocusChangeNotif& thisNotif = iNotifs[i];
+			if (windowGroupName.MatchF(thisNotif.iWindowGroupNamePattern) != KErrNotFound)
+				{
+				MBtraceFocusChangeObserver& observer = thisNotif.iObserver;
+				if (thisNotif.iPersistence == ENotificationOneShot)
+					{
+					iNotifs.Remove(i);
+					}
+				observer.HandleFocusChangedL(aFrame.iTickCount, *windowGroupId);
+				}
+			}
+		}
+	}
+
+CBtraceFocusChange::TFocusChangeNotif::TFocusChangeNotif(const TDesC& aWindowGroupNamePattern, MBtraceFocusChangeObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iWindowGroupNamePattern(aWindowGroupNamePattern), iObserver(aObserver), iPersistence(aPersistence)
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_generic.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,126 @@
+// btrace_generic.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace_parser.h"
+
+EXPORT_C CBtraceGeneric* CBtraceGeneric::NewL(CBtraceReader& aReader)
+	{
+	CBtraceGeneric* self = new (ELeave) CBtraceGeneric(aReader);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+CBtraceGeneric::CBtraceGeneric(CBtraceReader& aReader)
+:	iReader(aReader)
+	{
+	
+	}
+
+
+EXPORT_C CBtraceGeneric::~CBtraceGeneric()
+	{
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	iObservers.Close();
+	}
+
+
+void CBtraceGeneric::ConstructL()
+	{
+	iReader.AddObserverL(KAmTraceCategory, *this);
+	}
+
+
+EXPORT_C void CBtraceGeneric::NotifyGenericEventL
+	(MBtraceGenericObserver& aObserver)
+	{
+	iObservers.AppendL(&aObserver);
+	}
+
+
+void CBtraceGeneric::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iCategory == KAmTraceCategory && aFrame.iSubCategory > EAmTraceSubCategoryDomainEventBase)
+		{
+		const TInt length = aFrame.iData.Length();
+		const TUint32* data = reinterpret_cast<const TUint32*>(aFrame.iData.Ptr());
+		
+		switch(length)
+			{
+			case 0:
+				SeenGeneric0L(aFrame.iTickCount, aFrame.iSubCategory);
+				break;
+			
+			case 4:
+				SeenGeneric1L(aFrame.iTickCount, aFrame.iSubCategory, *data);
+				break;
+				
+			case 8:
+				SeenGeneric2L(aFrame.iTickCount, aFrame.iSubCategory, *data, *(data+1));
+				break;
+				
+			case 12:
+				SeenGeneric3L(aFrame.iTickCount, aFrame.iSubCategory, *data, *(data+1), *(data+2));
+				break;
+			}
+		}
+	}
+
+
+void CBtraceGeneric::SeenGeneric0L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory)
+	{
+	TInt ii = iObservers.Count();
+	while (--ii >= 0)
+		{
+		iObservers[ii]->HandleGenericEvent0L(aTickCount, aSubCategory);
+		iObservers.Remove(ii);
+		}	
+	}
+
+
+void CBtraceGeneric::SeenGeneric1L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory, TUint32 aData1)
+	{
+	TInt ii = iObservers.Count();
+	while (--ii >= 0)
+		{
+		iObservers[ii]->HandleGenericEvent1L(aTickCount, aSubCategory, aData1);
+		iObservers.Remove(ii);
+		}	
+	}
+
+
+void CBtraceGeneric::SeenGeneric2L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory, TUint32 aData1, TUint32 aData2)
+	{
+	TInt ii = iObservers.Count();
+	while (--ii >= 0)
+		{
+		iObservers[ii]->HandleGenericEvent2L
+			(aTickCount, aSubCategory, aData1, aData2);
+		iObservers.Remove(ii);
+		}	
+	}
+
+
+void CBtraceGeneric::SeenGeneric3L(const TBtraceTickCount& aTickCount, TUint8 aSubCategory, TUint32 aData1, TUint32 aData2, TUint32 aData3)
+	{
+	TInt ii = iObservers.Count();
+	while (--ii >= 0)
+		{
+		iObservers[ii]->HandleGenericEvent3L
+			(aTickCount, aSubCategory, aData1, aData2, aData3);
+		iObservers.Remove(ii);
+		}	
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_keypress.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,278 @@
+// btrace_keypress.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ltkutils.h>
+#include "btrace_parser.h"
+
+EXPORT_C CBtraceKeyPress* CBtraceKeyPress::NewL(CBtraceReader& aReader)
+	{
+	CBtraceKeyPress* self = new (ELeave) CBtraceKeyPress(aReader);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBtraceKeyPress::CBtraceKeyPress(CBtraceReader& aReader): 
+iReader(aReader)
+	{
+	}
+
+EXPORT_C CBtraceKeyPress::~CBtraceKeyPress()
+	{
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	iKeyNotifs.Close();
+	iPointerNotifs.Close();
+	iGenericNotifs.Close();
+	iRawKeyNotifs.Close();
+	}
+
+void CBtraceKeyPress::ConstructL()
+	{
+	iReader.AddObserverL(KAmTraceCategory, *this);
+	
+	LtkUtils::W32CrackL(); // In case no-one's called it yet
+	}
+
+//
+// CBtraceKeyPress::HandleBtraceFrameL
+// process the btrace frame, stripping out the key event data
+//
+void CBtraceKeyPress::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if(aFrame.iCategory == KAmTraceCategory && aFrame.iSubCategory == EAmTraceSubCategoryEvCapture)
+		{
+		const TUint32* data = reinterpret_cast<const TUint32*>(aFrame.iData.Ptr());
+		const TAmTraceEventEvCapture event = static_cast<TAmTraceEventEvCapture>(*data++);
+			
+		switch(event)
+			{
+			case EAmTraceEventEvCaptureKeyPress:
+				{
+				data += 1; // step over superfluous bytes
+				TKeyEvent* key = (TKeyEvent*) data;
+				SeenKeyL(aFrame.iTickCount, *key);
+				}
+			break;
+	
+			case EAmTraceEventEvCapturePointer:
+				{
+				data += 1; // step over superfluous bytes
+				TPointerEvent* pointer = (TPointerEvent*) data;
+				SeenPointerL(aFrame.iTickCount, *pointer);			
+				}
+			break;
+	
+			case EAmTraceEventEvCaptureUnclassified:
+				{
+				TInt commandClass = *data++;
+				TInt opcode = *data++;
+				SeenUnclassifiedL(aFrame.iTickCount, commandClass, opcode, NULL);
+				}
+				break;
+			
+			case EAmTraceEventEvCaptureRawScan:
+				{
+				TBool isKeyUp = *data++;
+				TInt scanCode = *data++;
+				SeenRawKeyL(aFrame.iTickCount, isKeyUp, scanCode);
+				}
+			break;
+
+			default:
+				// Ignore anything we don't know about.
+			break;
+			}
+		};
+	}
+
+//
+// CBtraceKeyPress::SeenKeyL
+// inform any observers that a key event has occured 
+// & pass a reference back to the key event
+//
+void CBtraceKeyPress::SeenKeyL(const TBtraceTickCount& aTickCount, const TKeyEvent& aKey)
+	{
+	TInt ii = iKeyNotifs.Count();
+	while (--ii >= 0)
+		{
+		MBtraceKeyPressObserver* observer = iKeyNotifs[ii].iObserver;
+		if (iKeyNotifs[ii].iPersistence == ENotificationOneShot)
+			{
+			iKeyNotifs.Remove(ii);
+			}
+		observer->HandleKeyPressL(aTickCount, aKey);
+		}	
+	}
+
+void CBtraceKeyPress::SeenRawKeyL(const TBtraceTickCount& aTickCount, TBool aKeyUp, TInt aScanCode)
+	{
+	TInt ii = iRawKeyNotifs.Count();
+	while (--ii >= 0)
+		{
+		MBtraceKeyPressObserver* observer = iRawKeyNotifs[ii].iObserver;
+		if (iRawKeyNotifs[ii].iPersistence == ENotificationOneShot)
+			{
+			iRawKeyNotifs.Remove(ii);
+			}
+		observer->HandleRawKeyL(aTickCount, aKeyUp, aScanCode);
+		}
+	}
+
+//
+// CBtraceKeyPress::SeenPointerL
+// inform any observers that a key event has occured 
+// & pass a reference back to the key event
+//
+void CBtraceKeyPress::SeenPointerL(const TBtraceTickCount& aTickCount, const TPointerEvent& aPointer)
+	{
+	TInt ii = iPointerNotifs.Count();
+	while (--ii >= 0)
+		{
+		MBtraceKeyPressObserver* observer = iPointerNotifs[ii].iObserver;
+		if (iPointerNotifs[ii].iPersistence == ENotificationOneShot)
+			{
+			iPointerNotifs.Remove(ii);
+			}
+		observer->HandlePointerPressL(aTickCount, aPointer);
+		}	
+	}
+
+//
+// CBtraceKeyPress::SeenUnclassifiedL
+// inform any observers that unknown/unclassified data 
+// has been received for a specific opcode
+void CBtraceKeyPress::SeenUnclassifiedL(const TBtraceTickCount& aTickCount, const TInt aCommandClass, const TInt aOpcode, const TAny* aData)
+	{
+	TInt ii = iGenericNotifs.Count();
+	while (--ii >= 0)
+		{
+		MBtraceKeyPressObserver* observer = iGenericNotifs[ii].iObserver;
+		if (iGenericNotifs[ii].iPersistence == ENotificationOneShot)
+			{
+			iGenericNotifs.Remove(ii);
+			}
+		observer->HandleUnclassifiedDataL(aTickCount, aCommandClass, aOpcode, aData);
+		}	
+	}
+
+//
+// CBtraceKeyPress::NotifyKeyEvent
+// called by the client to register an 
+// interest in any key events captured 
+//
+EXPORT_C void CBtraceKeyPress::NotifyKeyEventL(MBtraceKeyPressObserver& aObserver)
+	{
+	NotifyKeyEventL(aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceKeyPress::NotifyKeyEventL(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TKeyPressNotif notify(aObserver, aPersistence);
+	User::LeaveIfError(iKeyNotifs.Append(notify));
+	}
+	
+EXPORT_C void CBtraceKeyPress::CancelNotifyKeyEvent(MBtraceKeyPressObserver& aObserver)
+	{
+	for (TInt i=iKeyNotifs.Count()-1; i>=0; --i)
+		{
+		if (iKeyNotifs[i].iObserver == &aObserver)
+			{
+			iKeyNotifs.Remove(i);
+			}
+		}
+	}
+
+EXPORT_C void CBtraceKeyPress::NotifyRawKeyEventL(MBtraceKeyPressObserver& aObserver)
+	{
+	NotifyRawKeyEventL(aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceKeyPress::NotifyRawKeyEventL(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TKeyPressNotif notify(aObserver, aPersistence);
+	User::LeaveIfError(iRawKeyNotifs.Append(notify));
+	}
+
+EXPORT_C void CBtraceKeyPress::CancelNotifyRawKeyEvent(MBtraceKeyPressObserver& aObserver)
+	{
+	for (TInt i=iRawKeyNotifs.Count()-1; i>=0; --i)
+		{
+		if (iRawKeyNotifs[i].iObserver == &aObserver)
+			{
+			iRawKeyNotifs.Remove(i);
+			}
+		}
+	}
+
+//
+// CBtraceKeyPress::NotifyPointerEvent
+// called by the client to register an 
+// interest in any pointer events captured 
+//
+EXPORT_C void CBtraceKeyPress::NotifyPointerEventL(MBtraceKeyPressObserver& aObserver)
+	{
+	NotifyPointerEventL(aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceKeyPress::NotifyPointerEventL(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TKeyPressNotif notify(aObserver, aPersistence);
+	User::LeaveIfError(iPointerNotifs.Append(notify));
+	}
+
+EXPORT_C void CBtraceKeyPress::CancelNotifyPointerEvent(MBtraceKeyPressObserver& aObserver)
+	{
+	for (TInt i=iPointerNotifs.Count()-1; i>=0; --i)
+		{
+		if (iPointerNotifs[i].iObserver == &aObserver)
+			{
+			iPointerNotifs.Remove(i);
+			}
+		}
+	}
+
+//
+// CBtraceKeyPress::NotifyUnclassifiedDataL
+// called by the client to register an 
+// interest in any 'generic' events captured 
+//
+EXPORT_C void CBtraceKeyPress::NotifyUnclassifiedDataL(MBtraceKeyPressObserver& aObserver)
+	{
+	NotifyUnclassifiedDataL(aObserver, ENotificationOneShot);
+	}
+
+EXPORT_C void CBtraceKeyPress::NotifyUnclassifiedDataL(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TKeyPressNotif notify(aObserver, aPersistence);
+	User::LeaveIfError(iGenericNotifs.Append(notify));	
+	}
+
+EXPORT_C void CBtraceKeyPress::CancelNotifyUnclassifiedData(MBtraceKeyPressObserver& aObserver)
+	{
+	for (TInt i=iGenericNotifs.Count()-1; i>=0; --i)
+		{
+		if (iGenericNotifs[i].iObserver == &aObserver)
+			{
+			iGenericNotifs.Remove(i);
+			}
+		}
+	}
+
+//
+// TKeyPressNotif
+// place holder for observers interested in key &/or pointer events
+//
+CBtraceKeyPress::TKeyPressNotif::TKeyPressNotif(MBtraceKeyPressObserver& aObserver, TBtraceNotificationPersistence aPersistence):
+iObserver(&aObserver), iPersistence(aPersistence)
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_parser.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// btrace_parser.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          btrace_parser.dll
+targettype      dll
+uid             0x100000af FSHELL_UID_BTRACE_PARSER
+
+userinclude     ..\inc
+#include <fshell/fsh_system_include.mmh>
+capability      FSHELL_CAP_MMP_NORMAL
+
+sourcepath      .
+source          btrace_utils.cpp
+source          btrace_reader.cpp
+source          btrace_context.cpp
+source          btrace_cpuusage.cpp
+source          btrace_keypress.cpp
+source          btrace_textonscreen.cpp
+source          btrace_generic.cpp
+source          btrace_appresponse.cpp
+source          btrace_screenupdate.cpp
+source          btrace_pubsub.cpp
+source          btrace_domainevent.cpp
+source          btrace_focuschange.cpp
+
+FSHELL_TRACE_CONTROL_LIBRARY
+library         euser.lib
+library         efsrv.lib
+library         hal.lib
+library         ltkutils.lib
+
+#ifdef FSHELL_AUTOMETRIC_SUPPORT_EIKPLUGIN
+library         am-eikclient.lib
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_pubsub.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,142 @@
+// btrace_pubsub.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace_parser.h"
+
+EXPORT_C CBtracePubSub* CBtracePubSub::NewL(CBtraceReader& aReader)
+	{
+	CBtracePubSub* self = new(ELeave) CBtracePubSub(aReader);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBtracePubSub::CBtracePubSub(CBtraceReader& aReader)
+	: iReader(aReader)
+	{
+	}
+
+EXPORT_C CBtracePubSub::~CBtracePubSub()
+	{
+	iNotifs.Close();
+	iReader.RemoveObserver(ExtraBTrace::EPubSub, *this);
+	}
+
+void CBtracePubSub::ConstructL()
+	{
+	iReader.AddObserverL(ExtraBTrace::EPubSub, *this);
+	}
+
+EXPORT_C void CBtracePubSub::NotifyPropertyChangedL(MBtracePubSubObserver& aObserver)
+	{
+	iNotifs.AppendL(TPubSubNotif(NULL, NULL, NULL, NULL, aObserver, ENotificationOneShot));
+	}
+
+EXPORT_C void CBtracePubSub::NotifyPropertyChangedL(TUint* aCategory, TUint* aKey, MBtracePubSubObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	iNotifs.AppendL(TPubSubNotif(aCategory, aKey, NULL, NULL, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtracePubSub::NotifyIntegerPropertyChangedL(TUint* aCategory, TUint* aKey, TInt* aValue, MBtracePubSubObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	iNotifs.AppendL(TPubSubNotif(aCategory, aKey, aValue, NULL, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtracePubSub::NotifyDataPropertyChangedL(TUint* aCategory, TUint* aKey, const TDesC8* aValue, MBtracePubSubObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	iNotifs.AppendL(TPubSubNotif(aCategory, aKey, NULL, aValue, aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtracePubSub::CancelNotifyPropertyChanged(MBtracePubSubObserver& aObserver)
+	{
+	for (TInt i = (iNotifs.Count() - 1); i >= 0; --i)
+		{
+		if (&iNotifs[i].iObserver == &aObserver)
+			{
+			iNotifs.Remove(i);
+			}
+		}
+	}
+
+void CBtracePubSub::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iCategory != ExtraBTrace::EPubSub) return;
+
+	const TUint8* data = aFrame.iData.Ptr();
+	TUint cat = *(TUint32*)data;
+	TUint key = *((TUint32*)data + 1);
+
+	switch (aFrame.iSubCategory)
+		{
+		case ExtraBTrace::EPubSubIntPropertyChanged:
+			{
+			TInt val = *((TUint32*)data + 2);
+			for (TInt i = 0; i < iNotifs.Count(); i++)
+				{
+				if (iNotifs[i].Matches(cat, key, val))
+					{
+					iNotifs[i].iObserver.HandlePropertyChangedL(aFrame.iTickCount, cat, key, val);
+					}
+				}
+			break;
+			}
+		case ExtraBTrace::EPubSubDataPropertyChanged:
+			{
+			TPtrC8 val = aFrame.iData.Mid(8);
+			for (TInt i = 0; i < iNotifs.Count(); i++)
+				{
+				if (iNotifs[i].Matches(cat, key, val))
+					{
+					iNotifs[i].iObserver.HandlePropertyChangedL(aFrame.iTickCount, cat, key, val);
+					}
+				}
+			break;
+			}
+		}
+	}
+
+CBtracePubSub::TPubSubNotif::TPubSubNotif(TUint* aCategory, TUint* aKey, TInt* aIntegerValue, const TDesC8* aDataValue, MBtracePubSubObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iCategory(aCategory), iKey(aKey), iIntegerValue(aIntegerValue), iDataValue(aDataValue), iObserver(aObserver), iPersistence(aPersistence)
+	{
+	__ASSERT_ALWAYS(!(iIntegerValue && iDataValue), Panic(EBtpPanicIncompatiblePubSubArgs));
+	}
+
+TBool CBtracePubSub::TPubSubNotif::Matches(TUint aCategory, TUint aKey, TInt aIntegerValue) const
+	{
+	if ((iCategory == NULL) || (*iCategory == aCategory))
+		{
+		if ((iKey == NULL) || (*iKey == aKey))
+			{
+			if (((iIntegerValue == NULL) && (iDataValue == NULL)) || (*iIntegerValue == aIntegerValue))
+				{
+				return ETrue;
+				}
+			}
+		}
+	return EFalse;
+	}
+
+TBool CBtracePubSub::TPubSubNotif::Matches(TUint aCategory, TUint aKey, const TDesC8& aDataValue) const
+	{
+	if ((iCategory == NULL) || (*iCategory == aCategory))
+		{
+		if ((iKey == NULL) || (*iKey == aKey))
+			{
+			if (((iIntegerValue == NULL) && (iDataValue == NULL)) || (*iDataValue == aDataValue))
+				{
+				return ETrue;
+				}
+			}
+		}
+	return EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_reader.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,954 @@
+// btrace_reader.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace_parser.h"
+
+
+class TBtraceHeader
+	{
+public:
+	TUint8 iSize;
+	TUint8 iFlags;
+	TUint8 iCategory;
+	TUint8 iSubCategory;
+	};
+
+NONSHARABLE_CLASS(CMultipartFragment) : public CBase
+	{
+public:
+	static CMultipartFragment* NewLC(const TBtraceFrame& aFirstFrame, TUint32 aExtra);
+	~CMultipartFragment();
+	static TInt Compare(const CMultipartFragment& aFirst, const CMultipartFragment& aSecond);
+	void AddDataL(const TDesC8& aData);
+
+	TUint8 Category() const { return iFirstFrame.iCategory; }
+	TUint8 SubCategory() const { return iFirstFrame.iSubCategory; }
+	const TBtraceFrame& Frame() const { return iFirstFrame; }
+	TInt TotalSize() const { return iTotalSize; }
+
+	CMultipartFragment(TUint32 aExtra); // Only used for search key
+
+private:
+	CMultipartFragment(const TBtraceFrame& aFirstFrame, TUint32 aExtra);
+	void ConstructL();
+
+private:
+	TInt iTotalSize;
+	TBtraceFrame iFirstFrame;
+	TUint32 iUniqueId;
+	RBuf8 iData;
+	};
+
+NONSHARABLE_CLASS(CFlusher) : public CTimer
+	{
+public:
+	static CFlusher* NewL(CBtraceReader& aReader);
+	~CFlusher();
+	void Start(TTimeIntervalMicroSeconds32 aPeriod);
+	void Stop();
+private:
+	CFlusher(CBtraceReader& aReader);
+	void Queue();
+private: // From CTimer.
+	virtual void RunL();
+private:
+	TTimeIntervalMicroSeconds32 iPeriod;
+	CBtraceReader& iReader;
+	};
+
+CFlusher* CFlusher::NewL(CBtraceReader& aReader)
+	{
+	CFlusher* self = new(ELeave) CFlusher(aReader);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CFlusher::~CFlusher()
+	{
+	}
+
+void CFlusher::Start(TTimeIntervalMicroSeconds32 aPeriod)
+	{
+	ASSERT(!IsActive());
+	iPeriod = aPeriod;
+	Queue();
+	}
+
+void CFlusher::Stop()
+	{
+	Cancel();
+	}
+
+CFlusher::CFlusher(CBtraceReader& aReader)
+	: CTimer(CActive::EPriorityStandard), iReader(aReader)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CFlusher::Queue()
+	{
+	if (iPeriod.Int() > 0)
+		{
+		After(iPeriod);
+		}
+	}
+
+void CFlusher::RunL()
+	{
+	Queue();
+	iReader.FlushL();	
+	}
+
+const TInt KMaxCategories = 256;
+const TInt KBlockSize = 512;
+const TInt KArrayGranularity = 4;
+const TUint KObserveAllCategories = 0xFFFFFFFFu;
+
+
+TBtraceFrame::TBtraceFrame(const TBtraceHeader& aHeader)
+	: iSize(aHeader.iSize), iFlags(aHeader.iFlags), iCategory(aHeader.iCategory), iSubCategory(aHeader.iSubCategory)
+	{
+	}
+
+
+EXPORT_C CBtraceReader* CBtraceReader::NewL(TMode aMode, TInt aBufferSize, TInt aThreshold, MBtraceLog* aLog)
+	{
+	CBtraceReader* self = new(ELeave) CBtraceReader(aMode, aThreshold, aLog);
+	CleanupStack::PushL(self);
+	self->ConstructL(aBufferSize);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CBtraceReader* CBtraceReader::NewL(const TDesC& aReplayFileName, MBtraceLog* aLog)
+	{
+	CBtraceReader* self = new(ELeave) CBtraceReader(EAllowBtraceToOverflow, 0, aLog);
+	CleanupStack::PushL(self);
+	self->ConstructL(aReplayFileName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CBtraceReader::~CBtraceReader()
+	{
+	delete iFlusher;
+	Cancel();
+	DisableBtrace();
+	iBtrace.Close();
+#ifdef FSHELL_ATRACE_SUPPORT
+	iAtraceConfig.Close();
+#endif
+	iObservers.Close();
+	iReplayFile.Close();
+	iRecordFile.Close();
+	iFs.Close();
+	delete iReplayData;
+	iMultipartFragments.ResetAndDestroy();
+	}
+
+EXPORT_C void CBtraceReader::Reset()
+	{
+	iReplayFile.Close();
+	iRecordFile.Close();
+	delete iReplayData;
+	ResetAndReprimeL();
+	}
+
+EXPORT_C void CBtraceReader::SynchronizeL()
+	{
+	Log(_L("Synchronizing clock time with btrace time...\r\n"));
+	__ASSERT_ALWAYS(!iSynchronizing, Panic(EBtpPanicNestedSynchronizeCalls));
+	iSynchronizing = ETrue;
+	FlushL(); // FlushL now takes care of putting a sync frame in
+	Log(_L("Synchronize complete\r\n"));
+	}
+
+EXPORT_C void CBtraceReader::Start(const TBtraceTickCount& aInitialTickCount)
+	{
+	iInitialTickCount = aInitialTickCount;
+	QueueRead();
+	}
+
+EXPORT_C void CBtraceReader::Start(const TBtraceTickCount& aInitialTickCount, TTimeIntervalMicroSeconds32 aAutoFlushPeriod)
+	{
+	if (iFlusher)
+		{
+		iFlusher->Stop();
+		}
+	else
+		{
+		iFlusher = CFlusher::NewL(*this);
+		}
+
+	iFlusher->Start(aAutoFlushPeriod);
+	Start(aInitialTickCount);
+	}
+
+EXPORT_C void CBtraceReader::DisableBtrace()
+	{
+	if (iBtrace.Handle())
+		{
+		// Turn everything off.
+		for (TInt i = 0; i < KMaxCategories; ++i)
+			{
+			iBtrace.SetFilter(i, 0);
+			}
+		iBtrace.SetMode(0);
+		}
+	}
+
+EXPORT_C void CBtraceReader::EnableCategoryL(TUint aCategory)
+	{
+#ifdef FSHELL_ATRACE_SUPPORT
+	if (iAtraceConfig.Handle() && aCategory == BTrace::EProfiling)
+		{
+		User::LeaveIfError(iAtraceConfig.EnableProfiling(1));
+		}
+	else
+#endif
+	if (iBtrace.Handle())
+		{
+		User::LeaveIfError(iBtrace.SetFilter(aCategory, 1));
+		}
+	}
+
+EXPORT_C void CBtraceReader::DisableCategoryL(TUint aCategory)
+	{
+	// Check no-one's using it
+	TInt found = iObservers.SpecificFindInUnsignedKeyOrder(TObserver::ArrayKey(aCategory), EArrayFindMode_Any);
+	if (found != KErrNotFound) User::Leave(KErrInUse);
+
+	if (aCategory == BTrace::EMetaTrace) User::Leave(KErrInUse);
+
+#ifdef FSHELL_ATRACE_SUPPORT
+	if (iAtraceConfig.Handle() && aCategory == BTrace::EProfiling)
+		{
+		User::LeaveIfError(iAtraceConfig.EnableProfiling(EFalse));
+		}
+	else
+#endif
+		if (iBtrace.Handle())
+		{
+		User::LeaveIfError(iBtrace.SetFilter(aCategory, 0));
+		}
+	}
+	
+EXPORT_C void CBtraceReader::AddObserverL(MBtraceObserver& aObserver)
+	{
+	AddObserverL(aObserver, ENormal);
+	}
+
+EXPORT_C void CBtraceReader::AddObserverL(MBtraceObserver& aObserver, TObserverType aType)
+	{
+	__ASSERT_ALWAYS(!iIteratingObservers, Panic(EBtpPanicAddObserverCalledWhileIterating));
+	TObserver observer(aObserver, aType, KObserveAllCategories);
+	User::LeaveIfError(iObservers.InsertInUnsignedKeyOrderAllowRepeats(observer));
+	}
+
+EXPORT_C void CBtraceReader::AddObserverL(TUint aCategory, MBtraceObserver& aObserver)
+	{
+	AddObserverL(aCategory, aObserver, ENormal);
+	}
+
+EXPORT_C void CBtraceReader::AddObserverL(TUint aCategory, MBtraceObserver& aObserver, TObserverType aType)
+	{
+	__ASSERT_ALWAYS(!iIteratingObservers, Panic(EBtpPanicAddObserverCalledWhileIterating));
+	EnableCategoryL(aCategory);
+	TObserver observer(aObserver, aType, aCategory);
+	User::LeaveIfError(iObservers.InsertInUnsignedKeyOrderAllowRepeats(observer));
+	}
+
+TBool CBtraceReader::ObserversEqual(const TObserver& aA, const TObserver& aB)
+	{
+	return (aA.iObserver == aB.iObserver && aA.iCategory == aB.iCategory);
+	}
+
+EXPORT_C void CBtraceReader::RemoveObserver(MBtraceObserver& aObserver)
+	{
+	__ASSERT_ALWAYS(!iIteratingObservers, Panic(EBtpPanicRemoveObserverCalledWhileIterating));
+	TObserver observer(aObserver, ENormal, KObserveAllCategories);
+	TInt pos = iObservers.Find(observer, TIdentityRelation<TObserver>(&ObserversEqual));
+	if (pos >= 0)
+		{
+		iObservers.Remove(pos);
+		}
+	}
+
+EXPORT_C void CBtraceReader::RemoveObserver(TUint aCategory, MBtraceObserver& aObserver)
+	{
+	__ASSERT_ALWAYS(!iIteratingObservers, Panic(EBtpPanicRemoveObserverCalledWhileIterating));
+	// There could be multiple observers for each category, so find the last one...
+	TObserver observer(aObserver, ENormal, aCategory);
+	TInt pos = iObservers.SpecificFindInUnsignedKeyOrder(observer, EArrayFindMode_Last);
+	if (pos >= 0)
+		{
+		// ...now do a linear search for this specific one (backwards because the observer can then be removed without messing up the loop index).
+		TBool specificObserverFound(EFalse);
+		TInt numCatObservers = 0;
+		for (TInt i = (pos - 1); i >= 0; --i)
+			{
+			const TObserver& theObserver = iObservers[i];
+			if (theObserver.iCategory == aCategory)
+				{
+				if (theObserver.iObserver == &aObserver)
+					{
+					iObservers.Remove(i);
+					specificObserverFound = ETrue;
+					}
+				else
+					{
+					++numCatObservers;
+					}
+				}
+			else
+				{
+				break;
+				}
+			}
+		//__ASSERT_DEBUG(specificObserverFound, Panic(EBtpPanicObserverNotFound));
+		if (specificObserverFound && (numCatObservers == 0) && (iBtrace.Handle()))
+			{
+			// This was the last observer of this category, so turn it off.
+			DisableCategoryL(aCategory);
+			}
+		}
+	}
+	
+EXPORT_C void CBtraceReader::AddFrameObseverL(MBtraceFrameObserver& aObserver)
+	{
+	if (iFrameObserver) Panic(EBtpPanicFrameObserverAlreadyExists);
+	iFrameObserver = &aObserver;
+	}
+	
+EXPORT_C void CBtraceReader::RemoveFrameObserver(MBtraceFrameObserver& aObserver)
+	{
+	if (iFrameObserver == &aObserver)
+		{
+		iFrameObserver = NULL;
+		}
+	}
+
+EXPORT_C void CBtraceReader::GetReplayStartTickCountL(TBtraceTickCount& aTickCount)
+	{
+	__ASSERT_ALWAYS(iReplayData != NULL, Panic(EBtpPanicReaderNotReplaying));
+
+	aTickCount.iNano = 0;
+	aTickCount.iFast = 0;
+
+	// Read the first btrace frame to find its tick count.
+	TUint8* data;
+	TInt size = GetData(data);
+	__ASSERT_ALWAYS(size > 0, Panic(EBtpPanicNoReplayData));
+	TUint8* c = data;
+	TBtraceHeader* header = (TBtraceHeader*)c;
+	TUint8* d = c + sizeof(TBtraceHeader);
+	if ((header->iFlags & BTrace::EMissingRecord) && (c != data))
+		{
+		Log(_L("Warning: btrace buffer overflowed\r\n"));
+		User::Leave(KErrOverflow);
+		}
+	if (header->iFlags & BTrace::EHeader2Present)
+		{
+		d += 4;
+		}
+	if (header->iFlags & BTrace::ETimestampPresent)
+		{
+		aTickCount.iFast = *((TUint32*)d);
+		d += 4;
+		}
+	if (header->iFlags & BTrace::ETimestamp2Present)
+		{
+		aTickCount.iNano = *((TUint32*)d);
+		d += 4;
+		}
+
+	// Rewind the file to ensure the first btrace frame is read again when the buffer
+	// is properly parsed.
+	TInt pos = 0;
+	User::LeaveIfError(iReplayFile.Seek(ESeekStart, pos));
+	}
+
+EXPORT_C void CBtraceReader::SetBufferSizeL(TInt aBufferSize)
+	{
+	if (iBtrace.Handle() == 0)
+		{
+		User::Leave(KErrNotReady);
+		}
+	User::LeaveIfError(iBtrace.ResizeBuffer(aBufferSize));
+	ResetAndReprimeL(); // This is needed to a) reprime, and b) switch btrace back on. Calling ResizeBuffer actually sets the mode to zero. Who knew?
+	}
+
+EXPORT_C void CBtraceReader::SetReplayFileNameL(const TDesC& aReplayFileName)
+	{
+	__ASSERT_ALWAYS(aReplayFileName.Length() || iBtrace.Handle(), Panic(EBtpPanicTriedToDisableReplayWhenBtraceNotRunning)); // Can't transition from replay to live btrace if btrace was never opened (ie if the NewL overload taking a replay file name was used)
+	
+	if (iReplayFile.SubSessionHandle() > 0)
+		{
+		iReplayFile.Close();
+		}
+
+	if (aReplayFileName.Length())
+		{
+		User::LeaveIfError(iReplayFile.Open(iFs, aReplayFileName, EFileRead));
+		if (iReplayData == NULL)
+			{
+			iReplayData = HBufC8::NewL(KBlockSize);
+			}
+		}
+	else
+		{
+		delete iReplayData;
+		iReplayData = NULL;
+		}
+	}
+
+EXPORT_C const TBtraceTickCount& CBtraceReader::CurrentTickCount() const
+	{
+	Log(_L("Tick count: %u (%u)\r\n"), iCurrentTickCount.iNano, iCurrentTickCount.iFast);
+	return iCurrentTickCount;
+	}
+
+void CBtraceReader::RunL()
+	{
+	switch (iMode)
+		{
+		case EAllowBtraceToOverflow:
+			{
+			__ASSERT_ALWAYS(EFalse, Panic(EBtpPanicUnexpectedReaderRun));
+			}
+		case EFlushOnBtraceThreshold:
+			{
+			Log(_L("Btrace buffer crossed threshold - flushing...\r\n"));
+			QueueRead();
+			FlushL();
+			break;
+			}
+		case ELeaveOnBtraceThreshold:
+			{
+			Log(_L("Btrace buffer crossed threshold - leaving with KErrTooBig\r\n"));
+			User::Leave(KErrTooBig);
+			}
+		default:
+			{
+			__ASSERT_ALWAYS(EFalse, Panic(EBtpPanicInvalidReaderMode));
+			}
+		}
+	}
+
+void CBtraceReader::DoCancel()
+	{
+	if (iBtrace.Handle())
+		{
+		iBtrace.CancelRequestData();
+		}
+	}
+
+CBtraceReader::CBtraceReader(TMode aMode, TInt aThreshold, MBtraceLog* aLog)
+	: CActive(CActive::EPriorityStandard), iMode(aMode), iLog(aLog), iThreshold(aThreshold), iObservers(KArrayGranularity, _FOFF(TObserver, iCategory))
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CBtraceReader::ConstructL(TInt aBufferSize)
+	{
+	User::LeaveIfError(iFs.Connect());
+	User::LeaveIfError(iBtrace.Open());
+#ifdef FSHELL_ATRACE_SUPPORT
+	User::LeaveIfError(iAtraceConfig.Connect());
+#endif
+	iBtrace.Empty();
+	if (iBtrace.BufferSize() < aBufferSize)
+		{
+		// If the buffer is bigger, don't shrink it
+		SetBufferSizeL(aBufferSize);
+		}
+	iBtrace.SetTimestamp2Enabled(ETrue);
+
+	// Turn everything off.
+	for (TInt i = 0; i < KMaxCategories; ++i)
+		{
+		iBtrace.SetFilter(i, 0);
+		}
+	// And turn metatrace on (we always keep this on)
+	iBtrace.SetFilter(BTrace::EMetaTrace, 1);
+
+	iBtrace.SetMode(RBTrace::EEnable);
+	}
+
+void CBtraceReader::ConstructL(const TDesC& aReplayFileName)
+	{
+	User::LeaveIfError(iFs.Connect());
+	SetReplayFileNameL(aReplayFileName);
+	}
+
+void CBtraceReader::QueueRead()
+	{
+	if ((iMode > EAllowBtraceToOverflow) && (iThreshold > 0))
+		{
+		iBtrace.RequestData(iStatus, iThreshold);
+		SetActive();
+		}
+	}
+
+void CBtraceReader::DoReadL(TBool& aFinished)
+	{
+	TUint8* data;
+	TInt size = GetData(data);
+	if (size <= 0)
+		{
+		aFinished = ETrue;
+		iBtraceBuffer.Set(NULL, 0);
+		}
+	else
+		{
+		aFinished = EFalse;
+		iBtraceBuffer.Set(data, size);
+		iNumBytesRead += size;
+		TUint8* c = data;
+		TUint8* end = c + size;
+		do
+			{
+			TBtraceHeader* header = (TBtraceHeader*)c;
+			TBtraceFrame frame(*header);
+			TUint8* d = c + sizeof(TBtraceHeader);
+			TUint32 extra = 0;
+			TUint32 header2 = 0;
+			if ((header->iFlags & BTrace::EMissingRecord)) // && (c != data))
+				{
+				Log(_L("Warning: btrace buffer overflowed\r\n"));
+				//TODO: Why check if c != data? A missing record is a missing record isn't it? [TomS]
+				//[JoeB] IIRC there was a bug in btrace that caused it to produce a frame with EMissingRecord set
+				//       each time the btrace buffer was reset. Earlier releases didn't behave that way
+				//       so we hacked our way around it. I'll try removing the hack and see what breaks... 
+				User::Leave(KErrOverflow);
+				}
+			if (header->iFlags & BTrace::EHeader2Present)
+				{
+				header2 = *((TUint32*)d);
+				d += 4;
+				}
+			if (header->iFlags & BTrace::ETimestampPresent)
+				{
+				frame.iTickCount.iFast = *((TUint32*)d);
+				d += 4;
+				}
+			if (header->iFlags & BTrace::ETimestamp2Present)
+				{
+				frame.iTickCount.iNano = *((TUint32*)d);
+				d += 4;
+				}
+			if (header->iFlags & BTrace::EContextIdPresent)
+				{
+				frame.iThreadContext = *((TUint32*)d);
+				d += 4;
+				}
+			if (header->iFlags & BTrace::EPcPresent)
+				{
+				frame.iProgramCounter = *((TUint32*)d);
+				d += 4;
+				}
+			if (header->iFlags & BTrace::EExtraPresent)
+				{
+				extra = *(TUint32*)d;
+				d += 4;
+				}
+			frame.iData.Set(d, (c + header->iSize) - d);
+			iCurrentTickCount = frame.iTickCount;
+
+			TBool multipartHandled = EFalse;
+			TUint multiFlags = (header2 & BTrace::EMultipartFlagMask);
+			if (iMaxTrackedMultipartFragments > 0 && multiFlags != 0)
+				{
+				multipartHandled = ETrue;
+				if (multiFlags == BTrace::EMultipartFirst)
+					{
+					NewMultipartFrameL(frame, extra);
+					}
+				else
+					{
+					TBool last = multiFlags == BTrace::EMultipartLast;
+					AdditionalMultipartFragmentL(frame, extra, last);
+					}
+				}
+
+			if ((frame.iCategory == KAmTraceCategory) && (frame.iSubCategory == EAmTraceSubCategoryReaderSync))
+				{
+				if (frame.iData.Length() == 0)
+					{
+					// Shouldn't happen - old-style sync frame. We'll consider this as always matching
+					iSyncFrameIdToWaitFor = 0;
+					}
+				else if (*(TInt*)frame.iData.Ptr() == iSyncFrameIdToWaitFor)
+					{
+					iSyncFrameIdToWaitFor = 0;
+					}
+				iSynchronizing = EFalse;
+				}
+			if (!multipartHandled)
+				{
+				DispatchFrameL(frame);
+				}
+			c += (header->iSize + 3) & ~3;
+			}
+			while (c < end);
+
+		if (iBtrace.Handle())
+			{
+			iBtrace.DataUsed();
+			}
+		}
+	}
+
+TInt CBtraceReader::GetData(TUint8*& aData)
+	{
+	TInt size = 0;
+	if (iReplayData)
+		{
+		TPtr8 ptr(iReplayData->Des());
+		ptr.Zero();
+		TInt err = iReplayFile.Read(ptr, sizeof(TBtraceHeader));
+		if ((err == KErrNone) && (ptr.Length() == sizeof(TBtraceHeader)))
+			{
+			TBtraceHeader* btraceHeader = (TBtraceHeader*)ptr.Ptr();
+			const TInt length = ((btraceHeader->iSize + 3) & ~3) - sizeof(TBtraceHeader);
+			TPtr8 ptr2(const_cast<TUint8*>(ptr.Ptr()) + sizeof(TBtraceHeader), 0, ptr.MaxLength() - sizeof(TBtraceHeader));
+			ASSERT(ptr2.MaxLength() >= length);
+			err = iReplayFile.Read(ptr2, length);
+			if ((err == KErrNone) && (ptr2.Length() == length))
+				{
+				aData = const_cast<TUint8*>(ptr.Ptr());
+				size = btraceHeader->iSize;
+				}
+			}
+		}
+	else
+		{
+		size = iBtrace.GetData(aData);
+		}
+
+	if (size > 0 && iRecordFile.SubSessionHandle())
+		{
+		TPtrC8 data(aData, size);
+		iRecordFile.Write(data);
+		// Don't care about any error
+		}
+	return size;
+	}
+
+void CBtraceReader::DispatchFrameL(const TBtraceFrame& aFrame)
+	{
+	if (iFrameObserver) iFrameObserver->HandleFrameDispatchStart();
+	iIteratingObservers++;
+	CleanupStack::PushL(TCleanupItem(&DecIteratingObservers, this));
+	TBool preStartFrame = (aFrame.iTickCount < iInitialTickCount);
+	++iNumFramesRead;
+	TObserver arraySearchKey = TObserver::ArrayKey(aFrame.iCategory);
+	const TInt numObservers = iObservers.Count();
+	TInt pos = iObservers.SpecificFindInUnsignedKeyOrder(arraySearchKey, EArrayFindMode_First);
+	for (TInt i = pos; i >= 0 && i < numObservers; ++i)
+		{
+		const TObserver& theObserver = iObservers[i];
+		if (theObserver.iCategory == aFrame.iCategory)
+			{
+			if ((theObserver.iType == EIncludeSynchronizationFrames) || !preStartFrame || !iSynchronizing)
+				{
+				theObserver.iObserver->HandleBtraceFrameL(aFrame);
+				}
+			}
+		else
+			{
+			break;
+			}
+		}
+
+	// Now dispatch to observers who asked for everything
+	arraySearchKey = TObserver::ArrayKey(KObserveAllCategories);
+	pos = iObservers.SpecificFindInUnsignedKeyOrder(arraySearchKey, EArrayFindMode_First);
+	for (TInt i = pos; i >= 0 && i < numObservers; ++i)
+		{
+		const TObserver& theObserver = iObservers[i];
+		if (theObserver.iCategory == KObserveAllCategories && (theObserver.iType == EIncludeSynchronizationFrames || !preStartFrame))
+			{
+			theObserver.iObserver->HandleBtraceFrameL(aFrame);
+			}
+		}
+	CleanupStack::PopAndDestroy(); // iIteratingObservers--
+	if (iFrameObserver) iFrameObserver->HandleFrameDispatchComplete();
+	}
+
+CBtraceReader::TObserver::TObserver(MBtraceObserver& aObserver, TObserverType aType, TUint aCategory)
+	: iObserver(&aObserver), iType(aType), iCategory(aCategory)
+	{
+	}
+
+CBtraceReader::TObserver CBtraceReader::TObserver::ArrayKey(TUint aCategory)
+	{
+	return TObserver(aCategory);
+	}
+
+CBtraceReader::TObserver::TObserver(TUint aCategory)
+	: iObserver(NULL), iType(ENormal), iCategory(aCategory)
+	{
+	}
+
+EXPORT_C void CBtraceReader::RecordBtraceDataToFileL(const TDesC& aRecordFileName)
+	{
+	if (!iBtrace.Handle()) return; // This method is specced to do nothing if we're replaying
+	SynchronizeL(); // Ensure the file won't contain any data from before it asked to start (in the case of starting) or ensure that the file contains everything in the buffer up till this time (in the case of stopping)
+	iRecordFile.Close();
+	if (aRecordFileName.Length())
+		{
+		// File must not already exist, we open in exclusive access
+		User::LeaveIfError(iRecordFile.Create(iFs, aRecordFileName, EFileShareExclusive|EFileWrite));
+		ResetAndReprimeL();
+		}
+	}
+
+EXPORT_C void CBtraceReader::LogBtraceStatus()
+	{
+	Log(_L("BTrace categories currently enabled:"));
+	for (TInt i = 0; i < KMaxCategories; ++i)
+		{
+		TBool isOn = iBtrace.Filter(i) == 1; // 0 means off, 1 is on, KErrNotSupported means off and not supported
+		if (isOn)
+			{
+			Log(_L("%d"), i);
+			}
+		}
+	}
+
+void CBtraceReader::NotifyObserversOfBufferReset()
+	{
+	iIteratingObservers++;
+	const TInt numObservers = iObservers.Count();
+	for (TInt i = 0; i < numObservers; ++i)
+		{
+		const TObserver& theObserver = iObservers[i];
+		theObserver.iObserver->BtraceBufferHasBeenReset();
+		}
+	iIteratingObservers--;
+	}
+
+void CBtraceReader::DecIteratingObservers(TAny* aSelf)
+	{
+	static_cast<CBtraceReader*>(aSelf)->iIteratingObservers--;
+	}
+
+void CBtraceReader::ResetAndReprimeL()
+	{
+	iBtrace.Empty();
+	iBtrace.SetMode(RBTrace::EEnable);
+	iBtrace.SetTimestamp2Enabled(ETrue);
+	iMultipartFragments.ResetAndDestroy();
+	// This seems to be the only way to force repriming
+	for (TInt i = 0; i < KMaxCategories; ++i)
+		{
+		TBool isOn = iBtrace.Filter(i) == 1; // 0 means off, 1 is on, KErrNotSupported means off and not supported
+		if (isOn)
+			{
+			TInt err = iBtrace.SetFilter(i, 0);
+			err = iBtrace.SetFilter(i, 1);
+			}
+		}
+	NotifyObserversOfBufferReset();
+	}
+
+EXPORT_C void CBtraceReader::FlushL()
+	{
+	Log(_L("Flushing btrace buffer...\r\n"));
+
+	// Inject a sync frame so we know when the flush should be considered finished (in case there is a steady stream of data coming in)
+	TBool categoryAlreadySet = iBtrace.Filter(KAmTraceCategory);
+	if (!categoryAlreadySet)
+		{
+		User::LeaveIfError(iBtrace.SetFilter(KAmTraceCategory, 1));
+		}
+	iNextSyncFrameId++;
+	iSyncFrameIdToWaitFor = iNextSyncFrameId;
+	BTrace4(KAmTraceCategory, EAmTraceSubCategoryReaderSync, iSyncFrameIdToWaitFor);
+
+	TInt flushErr = KErrNone;
+	TBool fullyFlushed(EFalse);
+	while (flushErr == KErrNone && !fullyFlushed && iSyncFrameIdToWaitFor != 0)
+		{
+		TRAP(flushErr, DoReadL(fullyFlushed)); // Trap this to make sure we do the cleanup in the rest of this function
+		}
+
+	if (iSyncFrameIdToWaitFor)
+		{
+		Log(_L("Warning: got to end of buffer without finding sync frame!\r\n"));
+		iSyncFrameIdToWaitFor = 0;
+		// Important to clean this up, otherwise a future call to Synchronize will panic
+		iSynchronizing = EFalse;
+		}
+
+	if (!categoryAlreadySet)
+		{
+		iBtrace.SetFilter(KAmTraceCategory, 0);
+		}
+	if (flushErr)
+		{
+		Log(_L("Flush completed with error %d\r\n"), flushErr);
+		User::Leave(flushErr);
+		}
+	Log(_L("Flush complete\r\n"));
+	}
+
+void CBtraceReader::Log(const TDesC& aDes) const
+	{
+	if (iLog && iLog->LogEnabled())
+		{
+		iLog->Log(aDes);
+		}
+	}
+
+class TOverflowTruncate : public TDes16Overflow
+	{
+public:
+	virtual void Overflow(TDes16&) {}
+	};
+
+void CBtraceReader::Log(TRefByValue<const TDesC> aFmt, ...) const
+	{
+	if (iLog && iLog->LogEnabled())
+		{
+		TOverflowTruncate overflow;
+		VA_LIST list;
+		VA_START(list, aFmt);
+		TBuf<0x100> buf;
+		buf.AppendFormatList(aFmt, list, &overflow);
+		iLog->Log(buf);
+		}
+	}
+
+EXPORT_C void CBtraceReader::SetMultipartReassemblyL(TInt aMaxTrackedFragments)
+	{
+	iMaxTrackedMultipartFragments = aMaxTrackedFragments;
+	while (iMultipartFragments.Count() > iMaxTrackedMultipartFragments)
+		{
+		delete iMultipartFragments[0];
+		iMultipartFragments.Remove(0);
+		}
+	iMultipartFragments.ReserveL(iMaxTrackedMultipartFragments);
+	}
+
+CMultipartFragment* CMultipartFragment::NewLC(const TBtraceFrame& aFirstFrame, TUint32 aExtra)
+	{
+	CMultipartFragment* res = new(ELeave) CMultipartFragment(aFirstFrame, aExtra);
+	CleanupStack::PushL(res);
+	res->ConstructL();
+	return res;
+	}
+
+CMultipartFragment::CMultipartFragment(const TBtraceFrame& aFirstFrame, TUint32 aExtra)
+	: iFirstFrame(aFirstFrame), iUniqueId(aExtra)
+	{
+	}
+
+CMultipartFragment::CMultipartFragment(TUint32 aExtra)
+	: iFirstFrame(TBtraceHeader()), iUniqueId(aExtra)
+	{
+	}
+
+void CMultipartFragment::ConstructL()
+	{
+	// header2 and extra have been stripped off by this point.
+	iTotalSize = *(TInt32*)iFirstFrame.iData.Ptr();
+	iData.CreateL(iTotalSize+4);
+	iData.Copy(iFirstFrame.iData.Mid(4)); // iData now has A and the first X bytes of D
+	iFirstFrame.iData.Set(iData); // We keep iFirstFrame's iData set to the running total of the current data
+	}
+
+CMultipartFragment::~CMultipartFragment()
+	{
+	iData.Close();
+	}
+
+TInt CMultipartFragment::Compare(const CMultipartFragment& aFirst, const CMultipartFragment& aSecond)
+	{
+	return aSecond.iUniqueId - aFirst.iUniqueId;
+	}
+
+void CMultipartFragment::AddDataL(const TDesC8& aData)
+	{
+	// iData was allocated to the total size, so this should never fail
+	iData.Append(aData);
+	iFirstFrame.iData.Set(iData); // We keep iFirstFrame's iData set to the running total of the current data
+	}
+
+void CBtraceReader::NewMultipartFrameL(const TBtraceFrame& aFrame, TUint32 aExtra)
+	{
+	if (aFrame.iData.Size() < 8)
+		{
+		// Can't be a real multipart frame, has to have N and A (as per TMultiPart docs)
+		Log(_L("Warning: Corrupt multipart btrace frame found for cat=%d subcat=%d\r\n"), (TInt)aFrame.iCategory, (TInt)aFrame.iSubCategory);
+		}
+	else
+		{
+		if (iMultipartFragments.Count() == iMaxTrackedMultipartFragments)
+			{
+			// We have to drop a fragment on the floor
+			Log(_L("Warning: Maximum number of multipart fragments reached (%d), dropping first (cat=%d subcat=%d)\r\n"), iMaxTrackedMultipartFragments, iMultipartFragments[0]->Category(), iMultipartFragments[0]->SubCategory());
+			delete iMultipartFragments[0];
+			iMultipartFragments.Remove(0);
+			}
+
+		CMultipartFragment* frag = CMultipartFragment::NewLC(aFrame, aExtra);
+		iMultipartFragments.InsertInOrder(frag, &CMultipartFragment::Compare);
+		CleanupStack::Pop(frag);
+		}
+	}
+
+void CBtraceReader::AdditionalMultipartFragmentL(const TBtraceFrame& aFrame, TUint32 aExtra, TBool aLast)
+	{
+	if (aFrame.iData.Size() < 8)
+		{
+		// Can't be a real multipart frame, has to have N and A (as per TMultiPart docs)
+		Log(_L("Warning: Corrupt multipart btrace frame found for cat=%d subcat=%d\r\n"), (TInt)aFrame.iCategory, (TInt)aFrame.iSubCategory);
+		}
+	TInt offset = ((TInt32*)aFrame.iData.Ptr())[1];
+	CMultipartFragment dummySearchKey(aExtra);
+	TInt pos = iMultipartFragments.FindInOrder(&dummySearchKey, &CMultipartFragment::Compare);
+	if (pos == KErrNotFound)
+		{
+		Log(_L("Warning: Couldn't find multipart fragment for frame with cat=%d subcat=%d offset=%d\r\n"), aFrame.iCategory, aFrame.iSubCategory, offset);
+		return;
+		}
+	CMultipartFragment* frag = iMultipartFragments[pos];
+	if (frag->Frame().iData.Size() - 4 != offset)
+		{
+		// Subtract 4 because iData also has the 'A' parameter in it, whereas offset is into the payload data
+		Log(_L("Warning: Out of order multipart fragment - expected offset %d, was actually %d\r\n"), frag->Frame().iData.Size() - 4, offset);
+		// If we've dropped a bit, we're lost
+		delete frag;
+		iMultipartFragments.Remove(pos);
+		}
+	else
+		{
+		frag->AddDataL(aFrame.iData.Mid(8));
+		}
+
+	if (aLast)
+		{
+		if (frag->TotalSize() != frag->Frame().iData.Size() - 4)
+			{
+			Log(_L("Warning: multipart fragment is supposed to be finished but is wrong size - expected %d actually %d\r\n"), frag->TotalSize(), frag->Frame().iData.Size() - 4);
+			// Dispatch it anyway, it's the client's problem now (note we don't do this if we've knowingly dropped part of the frame)
+			}
+		iMultipartFragments.Remove(pos);
+		CleanupStack::PushL(frag);
+		DispatchFrameL(frag->Frame());
+		CleanupStack::PopAndDestroy(frag);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_screenupdate.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,115 @@
+// btrace_screenupdate.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btrace_parser.h"
+
+
+EXPORT_C CBtraceScreenUpdate* CBtraceScreenUpdate::NewL(CBtraceReader& aReader)
+	{
+	CBtraceScreenUpdate* self = new(ELeave) CBtraceScreenUpdate(aReader);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CBtraceScreenUpdate::~CBtraceScreenUpdate()
+	{
+	iNotifs.Close();
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	}
+
+EXPORT_C void CBtraceScreenUpdate::NotifyScreenUpdateL(MBtraceScreenUpdateObserver& aObserver)
+	{
+	NotifyScreenUpdateL(aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceScreenUpdate::NotifyScreenUpdateL(MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	iNotifs.AppendL(TScreenUpdateNotif(aObserver, aPersistence));
+	}
+
+EXPORT_C void CBtraceScreenUpdate::NotifyScreenUpdateL(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver)
+	{
+	NotifyScreenUpdateL(aScreenNumber, aRect, aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceScreenUpdate::NotifyScreenUpdateL(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	iNotifs.AppendL(TScreenUpdateNotif(aScreenNumber, aRect, aObserver, aPersistence));
+	}
+	
+EXPORT_C void CBtraceScreenUpdate::CancelNotifyScreenUpdate(MBtraceScreenUpdateObserver& aObserver)
+	{
+	for (TInt i = iNotifs.Count()-1; i>=0; --i)
+		{
+		if (iNotifs[i].iObserver == &aObserver)
+			{
+			iNotifs.Remove(i);
+			}
+		}
+	}
+
+CBtraceScreenUpdate::CBtraceScreenUpdate(CBtraceReader& aReader)
+	: iReader(aReader)
+	{
+	}
+
+void CBtraceScreenUpdate::ConstructL()
+	{
+	iReader.AddObserverL(KAmTraceCategory, *this);
+	}
+
+void CBtraceScreenUpdate::HandleScreenUpdateL(const TBtraceTickCount& aTickCount, TInt aScreenNumber, const TRect& aRect)
+	{
+	for (TInt i = (iNotifs.Count() - 1); i >= 0; --i)
+		{
+		TScreenUpdateNotif& notif = iNotifs[i];
+		if (notif.iNotifyAll || ((notif.iScreenNumber == aScreenNumber) && (notif.iRect.Intersects(aRect))))
+			{
+			MBtraceScreenUpdateObserver* observer = notif.iObserver;
+			if (notif.iPersistence == ENotificationOneShot)
+				{
+				iNotifs.Remove(i);
+				}
+			observer->HandleScreenUpdateL(aTickCount, aScreenNumber, aRect);
+			}
+		}
+	}
+
+void CBtraceScreenUpdate::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iCategory == KAmTraceCategory && aFrame.iSubCategory == EAmTraceSubCategoryScreenDriver)
+		{
+		const TUint8* data = aFrame.iData.Ptr();
+		TAmTraceEventScreenDriver event = *((const TAmTraceEventScreenDriver*)data);
+		data += sizeof (TAmTraceEventScreenDriver);
+		if (event == EAmTraceEventScreenDriverRectangleUpdated)
+			{
+			TInt screenNumber = *((const TInt32*)data);
+			data += sizeof (TInt);
+			const TRect* rect = (const TRect*)data;
+			HandleScreenUpdateL(aFrame.iTickCount, screenNumber, *rect);
+			}
+		}
+	}
+
+CBtraceScreenUpdate::TScreenUpdateNotif::TScreenUpdateNotif(MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iNotifyAll(ETrue), iObserver(&aObserver), iPersistence(aPersistence)
+	{
+	}
+
+CBtraceScreenUpdate::TScreenUpdateNotif::TScreenUpdateNotif(TInt aScreenNumber, const TRect& aRect, MBtraceScreenUpdateObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iNotifyAll(EFalse), iScreenNumber(aScreenNumber), iRect(aRect), iObserver(&aObserver), iPersistence(aPersistence)
+	{
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_textonscreen.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,186 @@
+// btrace_textonscreen.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ltkutils.h>
+#include "btrace_parser.h"
+
+
+EXPORT_C CBtraceTextOnScreen* CBtraceTextOnScreen::NewL(CBtraceReader& aReader)
+	{
+	CBtraceTextOnScreen* self = new (ELeave) CBtraceTextOnScreen(aReader);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CBtraceTextOnScreen::CBtraceTextOnScreen(CBtraceReader& aReader)
+	: iReader(aReader)
+	{
+	}
+
+EXPORT_C CBtraceTextOnScreen::~CBtraceTextOnScreen()
+	{
+	iReader.RemoveObserver(KAmTraceCategory, *this);
+	iScreenNotifs.Close();
+	}
+
+void CBtraceTextOnScreen::ConstructL()
+	{
+	iReader.AddObserverL(KAmTraceCategory, *this);
+	
+	LtkUtils::W32CrackL(); // In case no-one's called it yet
+	}
+
+//
+// CBtraceTextOnScreen::HandleBtraceFrameL
+// process the btrace frame, stripping out the relevant text
+//
+void CBtraceTextOnScreen::HandleBtraceFrameL(const TBtraceFrame& aFrame)
+	{
+	if (aFrame.iCategory == KAmTraceCategory && aFrame.iSubCategory == EAmTraceSubCategoryScreenText)
+		{
+		// First 2 words have packed windowgroup id and coordinates of text - TODO
+		TUint16 windowGroupId = *((const TUint16*)aFrame.iData.Mid(2).Ptr());
+		TPtrC8 data = aFrame.iData.Mid(8);
+		TPtrC text((const TUint16*)data.Ptr(), data.Length() / 2);
+		SeenL(aFrame.iTickCount, text, windowGroupId);
+		}
+	}
+
+//
+// CBtraceTextOnScreen::Seen
+// inform any observers that text has arrived on-screen, passing a reference to the text
+// note the observer may ask for any or a specific pattern of text to be notified on
+//
+void CBtraceTextOnScreen::SeenL(const TBtraceTickCount& aTickCount, const TDesC& aData, TInt aWindowGroupId)
+	{
+	iReader.Log(_L("Screen text: '%S' (%d)\r\n"), &aData, aWindowGroupId);
+	TInt ii = iScreenNotifs.Count();
+	while (--ii >= 0)
+		{
+		TTextOnScreenNotif& nt = iScreenNotifs[ii];
+
+		if (nt.iWindowGroupId && (nt.iWindowGroupId != aWindowGroupId))
+			{
+			continue;
+			}
+
+
+		switch (nt.iMatchMode)
+			{
+			case EWildNonSpanning:
+				{
+				if (aData.MatchF(nt.iTxtPtr) != KErrNotFound)
+					{
+					MBtraceTextOnScreenObserver* observer = nt.iObserver;
+					if (nt.iPersistence == ENotificationOneShot)
+						{
+						iScreenNotifs.Remove(ii);
+						}
+					observer->HandleTextSeenL(aTickCount, aData, aWindowGroupId);
+					}
+				break;
+				}
+			case ESpanningNonWild:
+				{
+				const TInt length = aData.Length();
+				for (TInt i = 0; i < length; ++i)
+					{
+					if (aData[i] == nt.iTxtPtr[nt.iMatchedChars])
+						{
+						++nt.iMatchedChars;
+						}
+					else
+						{
+						nt.iMatchedChars = 0;
+						}
+
+					if (nt.iMatchedChars == nt.iTxtPtr.Length())
+						{
+						MBtraceTextOnScreenObserver* observer = nt.iObserver;
+						if (nt.iPersistence == ENotificationOneShot)
+							{
+							iScreenNotifs.Remove(ii);
+							}
+						observer->HandleTextSeenL(aTickCount, aData, aWindowGroupId);
+						break;
+						}
+					}
+				break;
+				}
+			default:
+				ASSERT(EFalse);
+			}
+		}	
+	}
+
+//
+// CBtraceTextOnScreen::NotifyTextOnScreenL
+// called by the client to register an interest in any text drawn to screen (via wserv only)
+//
+EXPORT_C void CBtraceTextOnScreen::NotifyTextOnScreenL(const TDesC& aText, MBtraceTextOnScreenObserver& aObserver)
+	{
+	NotifyTextOnScreenL(aText, aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceTextOnScreen::NotifyTextOnScreenL(const TDesC& aText, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TTextOnScreenNotif notify(aText, aObserver, aPersistence);
+	iScreenNotifs.AppendL(notify);
+	}
+
+EXPORT_C void CBtraceTextOnScreen::NotifyTextOnScreenL(const TDesC& aText, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TTextOnScreenNotif notify(aText, aMatchMode, aObserver, aPersistence);
+	iScreenNotifs.AppendL(notify);
+	}
+
+EXPORT_C void CBtraceTextOnScreen::NotifyTextOnScreenL(const TDesC& aText, TInt aWindowGroupId, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver)
+	{
+	NotifyTextOnScreenL(aText, aWindowGroupId, aMatchMode, aObserver, ENotificationOneShot);
+	}
+	
+EXPORT_C void CBtraceTextOnScreen::NotifyTextOnScreenL(const TDesC& aText, TInt aWindowGroupId, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	{
+	TTextOnScreenNotif notify(aText, aWindowGroupId, aMatchMode, aObserver, aPersistence);
+	iScreenNotifs.AppendL(notify);
+	}
+
+EXPORT_C void CBtraceTextOnScreen::CancelNotifyTextOnScreen(MBtraceTextOnScreenObserver& aObserver)
+	{
+	for (TInt i = iScreenNotifs.Count()-1; i>=0; i--)
+		{
+		if (iScreenNotifs[i].iObserver == &aObserver)
+			{
+			iScreenNotifs.Remove(i);
+			}
+		}
+	}
+
+//
+// TTextOnScreenNotif
+//
+CBtraceTextOnScreen::TTextOnScreenNotif::TTextOnScreenNotif(const TDesC& aText, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iTxtPtr(aText), iWindowGroupId(0), iMatchedChars(0), iMatchMode(EWildNonSpanning), iObserver(&aObserver), iPersistence(aPersistence)
+	{
+	}
+
+CBtraceTextOnScreen::TTextOnScreenNotif::TTextOnScreenNotif(const TDesC& aText, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iTxtPtr(aText), iWindowGroupId(0), iMatchedChars(0), iMatchMode(aMatchMode), iObserver(&aObserver), iPersistence(aPersistence)
+	{
+	}
+
+CBtraceTextOnScreen::TTextOnScreenNotif::TTextOnScreenNotif(const TDesC& aText, TInt aWindowGroupId, TMatchMode aMatchMode, MBtraceTextOnScreenObserver& aObserver, TBtraceNotificationPersistence aPersistence)
+	: iTxtPtr(aText), iWindowGroupId(aWindowGroupId), iMatchedChars(0), iMatchMode(aMatchMode), iObserver(&aObserver), iPersistence(aPersistence)
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btrace_parser/src/btrace_utils.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,399 @@
+// btrace_utils.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32math.h>
+#include <hal.h>
+#include "btrace_parser.h"
+#include <fshell/ltkutils.h>
+
+void Panic(TBtraceParserPanic aReason)
+	{
+	_LIT(KCat, "btrace_parser");
+	User::Panic(KCat, aReason);
+	}
+
+enum TTlsFlags
+	{
+	ENanoSet = 1,
+	EFastCounterSet = 2,
+	EFastCountsUpSet = 4,
+	};
+
+struct SBtraceParserTls
+	{
+	TUint32 iFlags;
+	TInt iNanoTickPeriod;
+	TInt iFastCounterFrequency;
+	TBool iFastCounterCountsUp;
+	};
+
+EXPORT_C TUint32 TBtraceUtils::MicroSecondsToNanoTicks(TTimeIntervalMicroSeconds32 aInterval)
+	{
+	TUint32 numTicks = aInterval.Int();
+	numTicks /= NanoTickPeriod();
+	return numTicks;
+	}
+
+EXPORT_C TUint64 TBtraceUtils::MicroSecondsToFastTicks(TTimeIntervalMicroSeconds32 aInterval)
+	{
+	TUint64 numTicks = aInterval.Int();
+	numTicks *= FastCounterFrequency();
+	numTicks /= 1000000;
+	return numTicks;
+	}
+
+EXPORT_C TTimeIntervalMicroSeconds TBtraceUtils::NanoTicksToMicroSeconds(TUint32 aNanoTicks)
+	{
+	TUint64 ms = aNanoTicks;
+	ms *= NanoTickPeriod();
+	return ms;
+	}
+
+EXPORT_C TTimeIntervalMicroSeconds TBtraceUtils::FastTicksToMicroSeconds(const TUint64& aFastTicks)
+	{
+	TUint64 ms = aFastTicks;
+	ms *= 1000000;
+	TUint64 f = FastCounterFrequency();
+	ms /= f;
+	return ms;
+	}
+
+TInt TBtraceUtils::NanoTickPeriod()
+	{
+	SBtraceParserTls* tls = (SBtraceParserTls*)Dll::Tls();
+	if (tls && tls->iFlags & ENanoSet)
+		{
+		return tls->iNanoTickPeriod;
+		}
+	else
+		{
+		TInt res = CalculateNanoTickPeriod();
+		tls = CreateTls();
+		if (tls)
+			{
+			tls->iNanoTickPeriod = res;
+			tls->iFlags |= ENanoSet;
+			}
+		return res;
+		}
+	}
+
+TInt TBtraceUtils::CalculateNanoTickPeriod()
+	{
+	TInt nanoTickPeriod;
+	if (HAL::Get(HAL::ENanoTickPeriod, nanoTickPeriod) != KErrNone)
+		{
+		nanoTickPeriod = 1000;
+		}
+	return nanoTickPeriod;
+	}
+
+TInt TBtraceUtils::FastCounterFrequency()
+	{
+	SBtraceParserTls* tls = (SBtraceParserTls*)Dll::Tls();
+	if (tls && tls->iFlags & EFastCounterSet)
+		{
+		return tls->iFastCounterFrequency;
+		}
+	else
+		{
+		TInt freq = CalculateFastCounterFrequency();
+		tls = CreateTls();
+		if (tls) 
+			{
+			tls->iFastCounterFrequency = freq;
+			tls->iFlags |= EFastCounterSet;
+			}
+		return freq;
+		}
+	}
+
+TInt TBtraceUtils::CalculateFastCounterFrequency()
+	{
+	TInt fastCounterFrequency;
+	if (HAL::Get(HAL::EFastCounterFrequency, fastCounterFrequency) != KErrNone)
+		{
+		fastCounterFrequency = 1000;
+		}
+	return fastCounterFrequency;
+	}
+
+TBool TBtraceUtils::FastCounterCountsUp()
+	{
+	SBtraceParserTls* tls = (SBtraceParserTls*)Dll::Tls();
+	if (tls && tls->iFlags & EFastCountsUpSet)
+		{
+		return tls->iFastCounterCountsUp;
+		}
+	else
+		{
+		TInt res = CalculateFastCounterCountsUp();
+		tls = CreateTls();
+		if (tls)
+			{
+			tls->iFastCounterCountsUp = res;
+			tls->iFlags |= EFastCountsUpSet;
+			}
+		return res;
+		}
+	}
+
+TBool TBtraceUtils::CalculateFastCounterCountsUp()
+	{
+	TBool countsUp;
+	if (HAL::Get(HAL::EFastCounterCountsUp, countsUp) != KErrNone)
+		{
+		countsUp = EFalse;
+		}
+
+	// Hack for N96 which returns countsup=false even though the fast counter is slaved to the nanokernel tick counter (and thus does actually count upwards)
+	TInt fastCount = User::FastCounter();
+	TInt ntick = User::NTickCount();
+	if (FastCounterFrequency() == NanoTickPeriod() && fastCount == ntick)
+		{
+		countsUp = ETrue;
+		}
+
+	return countsUp;
+	}
+
+SBtraceParserTls* TBtraceUtils::CreateTls()
+	{
+	SBtraceParserTls* res = (SBtraceParserTls*)Dll::Tls(); // Sort any reentrancy issues by checking if we are actually created
+	if (res) return res;
+	res = new SBtraceParserTls;
+	if (!res) return NULL;
+	Mem::FillZ(res, sizeof(SBtraceParserTls));
+	LtkUtils::MakeHeapCellInvisible(res);
+	TInt err = Dll::SetTls(res);
+	if (err)
+		{
+		delete res;
+		return NULL;
+		}
+	return res;
+	}
+
+EXPORT_C void TBtraceUtils::DebugOverrideTimerSettings(TInt aNanoPeriod, TInt aFastCounterFreq, TBool aFastCountUp)
+	{
+	SBtraceParserTls* tls = CreateTls();
+	if (tls)
+		{
+		tls->iFlags |= ENanoSet | EFastCounterSet | EFastCountsUpSet;
+		tls->iNanoTickPeriod = aNanoPeriod;
+		tls->iFastCounterFrequency = aFastCounterFreq;
+		tls->iFastCounterCountsUp = aFastCountUp;
+		}
+	}
+
+EXPORT_C TBtraceTickCount::TBtraceTickCount()
+	: iNano(0), iFast(0)
+	{
+	}
+
+EXPORT_C void TBtraceTickCount::SetToNow()
+	{
+	iFast = User::FastCounter();
+	iNano = User::NTickCount();
+	}
+
+EXPORT_C TUint32 TBtraceTickCount::IntervalInNanoTicks(const TBtraceTickCount& aTickCount) const
+	{
+	__ASSERT_ALWAYS(iNano >= aTickCount.iNano, Panic(EBtpPanicNegativeTickInterval));
+	return (iNano - aTickCount.iNano);
+	}
+
+EXPORT_C TUint64 TBtraceTickCount::IntervalInFastTicks(const TBtraceTickCount& aTickCount) const
+	{
+	// Calc the number of nano-kernel ticks (simple subtraction)
+	TUint64 n = IntervalInNanoTicks(aTickCount);
+
+	// Convert to microseconds;
+	n *= TBtraceUtils::NanoTickPeriod();
+
+	// Convert this into fast counter ticks.
+	n *= TBtraceUtils::FastCounterFrequency();
+	n /= 1000000;
+
+	// Round n down to the the nearest KMaxTUint. The next bit of maths is concerned with calculating the remainder
+	n /= KMaxTUint;
+	n *= KMaxTUint;
+
+	/*
+	This represents how the fast counter overflows (assuming fast counter counting up):
+
+	|-----|-----|-----| <- tick periods
+	     /     /     /
+	    /     /     /|
+	   /     /     / |
+	  /     /     /  |
+	 /|    /     /   |
+	/ |   /     /    |
+	  |              |
+	  aTickCount     this
+	  
+	In the case where aTickCount and this are roughly as presented in the above diagram, the answer
+	is (2 tick periods) + this.iFast - aTickCount.iFast
+
+	Where aTickCount.iFast is numerically greater than this.iFast:
+
+  	|-----|-----|-----|-----| <- tick periods
+	     /     /     /     /
+	    /|    /     /     /
+	   / |   /     /     /
+	  /  |  /     /     /
+	 /   | /     /     /
+	/    |/     /     /|
+	     |             |
+	     aTickCount    this
+         
+
+	The sum is slightly different: (2 tick periods) + this.iFast + (tick period - aTickCount.iFast)
+	When the counter counts down, the maths is reversed
+	*/
+
+	// Now calculate the duration (in fast ticks).
+	if (TBtraceUtils::FastCounterCountsUp())
+		{
+		if (aTickCount.iFast < iFast)
+			{
+			n = n + iFast - aTickCount.iFast;
+			}
+		else if (aTickCount.iFast > iFast)
+			{
+			n = n + iFast + (KMaxTUint - aTickCount.iFast);
+			}
+		else
+			{
+			// Do nothing - the fast counts are the numerically the same, so n being a round number of tick periods is already correct
+			}
+		}
+	else
+		{
+		if (iFast < aTickCount.iFast)
+			{
+			n = n + aTickCount.iFast - iFast;
+			}
+		else if (aTickCount.iFast > iFast)
+			{
+			n = n + aTickCount.iFast + (KMaxTUint - iFast);
+			}
+		else
+			{
+			// Do nothing as above
+			}
+		}
+
+	return n;
+	}
+
+EXPORT_C TTimeIntervalMicroSeconds TBtraceTickCount::IntervalInMicroSeconds(const TBtraceTickCount& aTickCount) const
+	{
+	TUint64 n = IntervalInFastTicks(aTickCount);
+	n *= 1000000;
+	n /= TBtraceUtils::FastCounterFrequency();
+	return n;
+	}
+
+EXPORT_C TBool TBtraceTickCount::operator==(const TBtraceTickCount& aTickCount) const
+	{
+	return (aTickCount.iNano == iNano) && (aTickCount.iFast == iFast);
+	}
+
+EXPORT_C TBool TBtraceTickCount::operator!=(const TBtraceTickCount& aTickCount) const
+	{
+	return (aTickCount.iNano != iNano) || (aTickCount.iFast != iFast);
+	}
+
+EXPORT_C TBool TBtraceTickCount::operator>=(const TBtraceTickCount& aTickCount) const
+	{
+	if ((iNano > aTickCount.iNano) || (*this == aTickCount))
+		{
+		return ETrue;
+		}
+	else if (iNano < aTickCount.iNano)
+		{
+		return EFalse;
+		}
+	else
+		{
+		return TBtraceUtils::FastCounterCountsUp() ? (iFast > aTickCount.iFast) : (iFast < aTickCount.iFast);
+		}
+	}
+
+EXPORT_C TBool TBtraceTickCount::operator<=(const TBtraceTickCount& aTickCount) const
+	{
+	if ((iNano < aTickCount.iNano) || (*this == aTickCount))
+		{
+		return ETrue;
+		}
+	else if (iNano > aTickCount.iNano)
+		{
+		return EFalse;
+		}
+	else
+		{
+		return TBtraceUtils::FastCounterCountsUp() ? (iFast < aTickCount.iFast) : (iFast > aTickCount.iFast);
+		}
+	}
+
+EXPORT_C TBool TBtraceTickCount::operator>(const TBtraceTickCount& aTickCount) const
+	{
+	if (iNano > aTickCount.iNano)
+		{
+		return ETrue;
+		}
+	else if ((*this == aTickCount) || (iNano < aTickCount.iNano))
+		{
+		return EFalse;
+		}
+	else
+		{
+		return TBtraceUtils::FastCounterCountsUp() ? (iFast > aTickCount.iFast) : (iFast < aTickCount.iFast);
+		}
+	}
+
+EXPORT_C TBool TBtraceTickCount::operator<(const TBtraceTickCount& aTickCount) const
+	{
+	if (iNano < aTickCount.iNano)
+		{
+		return ETrue;
+		}
+	else if ((*this == aTickCount) || (iNano > aTickCount.iNano))
+		{
+		return EFalse;
+		}
+	else
+		{
+		return TBtraceUtils::FastCounterCountsUp() ? (iFast < aTickCount.iFast) : (iFast > aTickCount.iFast);
+		}
+	}
+
+EXPORT_C void CRefCountedObject::IncRef()
+	{
+	++iRefCount;
+	}
+
+EXPORT_C void CRefCountedObject::DecRef()
+	{
+	__ASSERT_ALWAYS(iRefCount > 0, Panic(EBtpPanicNegativeRefCount));
+	--iRefCount;
+	}
+
+EXPORT_C TInt CRefCountedObject::RefCount() const
+	{
+	return iRefCount;
+	}
+
+CRefCountedObject::CRefCountedObject()
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/bwins/btserial.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,24 @@
+EXPORTS
+	??1CBluetoothIncomingSerialConnection@@UAE@XZ @ 1 NONAME ; CBluetoothIncomingSerialConnection::~CBluetoothIncomingSerialConnection(void)
+	?CancelRead@CBluetoothIncomingSerialConnection@@QAEXXZ @ 2 NONAME ; void CBluetoothIncomingSerialConnection::CancelRead(void)
+	?CancelRead@RBtSerialSession@@QBEXXZ @ 3 NONAME ; void RBtSerialSession::CancelRead(void) const
+	?CancelWaitForConnection@RBtSerialSession@@QAEXXZ @ 4 NONAME ; void RBtSerialSession::CancelWaitForConnection(void)
+	?CancelWrite@CBluetoothIncomingSerialConnection@@QAEXXZ @ 5 NONAME ; void CBluetoothIncomingSerialConnection::CancelWrite(void)
+	?CancelWrite@RBtSerialSession@@QAEXXZ @ 6 NONAME ; void RBtSerialSession::CancelWrite(void)
+	?Close@RBtSerialSession@@QAEXXZ @ 7 NONAME ; void RBtSerialSession::Close(void)
+	?Connect@RBtSerialSession@@QAEHXZ @ 8 NONAME ; int RBtSerialSession::Connect(void)
+	?Connected@CBluetoothIncomingSerialConnection@@QAEHXZ @ 9 NONAME ; int CBluetoothIncomingSerialConnection::Connected(void)
+	?IsConnected@RBtSerialSession@@QBEHXZ @ 10 NONAME ; int RBtSerialSession::IsConnected(void) const
+	?NewL@CBluetoothIncomingSerialConnection@@SAPAV1@AAVMBtIncomingConnectionObserver@@@Z @ 11 NONAME ; class CBluetoothIncomingSerialConnection * CBluetoothIncomingSerialConnection::NewL(class MBtIncomingConnectionObserver &)
+	?Read@CBluetoothIncomingSerialConnection@@QAEXAAVTDes8@@@Z @ 12 NONAME ; void CBluetoothIncomingSerialConnection::Read(class TDes8 &)
+	?Read@RBtSerialSession@@QBEXAAVTDes8@@AAVTRequestStatus@@@Z @ 13 NONAME ; void RBtSerialSession::Read(class TDes8 &, class TRequestStatus &) const
+	?ShutDown@CBluetoothIncomingSerialConnection@@QAEXXZ @ 14 NONAME ; void CBluetoothIncomingSerialConnection::ShutDown(void)
+	?WaitForConnection@CBluetoothIncomingSerialConnection@@QAEXXZ @ 15 NONAME ; void CBluetoothIncomingSerialConnection::WaitForConnection(void)
+	?WaitForConnection@RBtSerialSession@@QAEXAAVTRequestStatus@@@Z @ 16 NONAME ; void RBtSerialSession::WaitForConnection(class TRequestStatus &)
+	?Write@CBluetoothIncomingSerialConnection@@QAEXABVTDesC8@@@Z @ 17 NONAME ; void CBluetoothIncomingSerialConnection::Write(class TDesC8 const &)
+	?Write@RBtSerialSession@@QAEXABVTDesC8@@AAVTRequestStatus@@@Z @ 18 NONAME ; void RBtSerialSession::Write(class TDesC8 const &, class TRequestStatus &)
+	?ConnectedDeviceAddrL@CBluetoothIncomingSerialConnection@@QAE?AVTBTDevAddr@@XZ @ 19 NONAME ; class TBTDevAddr CBluetoothIncomingSerialConnection::ConnectedDeviceAddrL(void)
+	?GetConnectedDeviceAddr@RBtSerialSession@@QAEHAAVTBTDevAddr@@@Z @ 20 NONAME ; int RBtSerialSession::GetConnectedDeviceAddr(class TBTDevAddr &)
+	?GetConnectedDeviceName@RBtSerialSession@@QAEHAAVTDes16@@@Z @ 21 NONAME ; int RBtSerialSession::GetConnectedDeviceName(class TDes16 &)
+	?GetConnectedDeviceNameL@CBluetoothIncomingSerialConnection@@QAEXXZ @ 22 NONAME ; void CBluetoothIncomingSerialConnection::GetConnectedDeviceNameL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/eabi/btserial.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+EXPORTS
+	_ZN16RBtSerialSession11CancelWriteEv @ 1 NONAME
+	_ZN16RBtSerialSession17WaitForConnectionER14TRequestStatus @ 2 NONAME
+	_ZN16RBtSerialSession23CancelWaitForConnectionEv @ 3 NONAME
+	_ZN16RBtSerialSession5CloseEv @ 4 NONAME
+	_ZN16RBtSerialSession5WriteERK6TDesC8R14TRequestStatus @ 5 NONAME
+	_ZN16RBtSerialSession7ConnectEv @ 6 NONAME
+	_ZN34CBluetoothIncomingSerialConnection10CancelReadEv @ 7 NONAME
+	_ZN34CBluetoothIncomingSerialConnection11CancelWriteEv @ 8 NONAME
+	_ZN34CBluetoothIncomingSerialConnection17WaitForConnectionEv @ 9 NONAME
+	_ZN34CBluetoothIncomingSerialConnection4NewLER29MBtIncomingConnectionObserver @ 10 NONAME
+	_ZN34CBluetoothIncomingSerialConnection4ReadER5TDes8 @ 11 NONAME
+	_ZN34CBluetoothIncomingSerialConnection5WriteERK6TDesC8 @ 12 NONAME
+	_ZN34CBluetoothIncomingSerialConnection8ShutDownEv @ 13 NONAME
+	_ZN34CBluetoothIncomingSerialConnection9ConnectedEv @ 14 NONAME
+	_ZN34CBluetoothIncomingSerialConnectionD0Ev @ 15 NONAME
+	_ZN34CBluetoothIncomingSerialConnectionD1Ev @ 16 NONAME
+	_ZN34CBluetoothIncomingSerialConnectionD2Ev @ 17 NONAME
+	_ZNK16RBtSerialSession10CancelReadEv @ 18 NONAME
+	_ZNK16RBtSerialSession11IsConnectedEv @ 19 NONAME
+	_ZNK16RBtSerialSession4ReadER5TDes8R14TRequestStatus @ 20 NONAME
+	_ZTI15CBtSerialServer @ 21 NONAME ; #<TI>#
+	_ZTI16CBtSerialSession @ 22 NONAME ; #<TI>#
+	_ZTI34CBluetoothIncomingSerialConnection @ 23 NONAME ; #<TI>#
+	_ZTV15CBtSerialServer @ 24 NONAME ; #<VT>#
+	_ZTV16CBtSerialSession @ 25 NONAME ; #<VT>#
+	_ZTV34CBluetoothIncomingSerialConnection @ 26 NONAME ; #<VT>#
+	_ZN16RBtSerialSession22GetConnectedDeviceAddrER10TBTDevAddr @ 27 NONAME
+	_ZN16RBtSerialSession22GetConnectedDeviceNameER6TDes16 @ 28 NONAME
+	_ZN34CBluetoothIncomingSerialConnection20ConnectedDeviceAddrLEv @ 29 NONAME
+	_ZN34CBluetoothIncomingSerialConnection23GetConnectedDeviceNameLEv @ 30 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/group/BtSerial.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+// BtSerial.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			btincomingserial.dll
+TARGETTYPE		dll
+UID             0x1000008d FSHELL_UID_BTINCOMINGSERIAL
+CAPABILITY		FSHELL_CAP_MMP_NORMAL
+
+//OPTION			ARMCC --interleave
+
+SOURCEPATH		..\src\connection
+SOURCE			BtService.cpp
+SOURCE			btincoming.cpp
+SOURCEPATH		..\src\server
+SOURCE			btserialserver.cpp
+SOURCE			btserialsession.cpp
+SOURCEPATH		..\src\client
+SOURCE			btserialclient.cpp
+USERINCLUDE		..\inc
+#include <fshell/fsh_system_include.mmh>
+LIBRARY			euser.lib c32.lib btmanclient.lib bluetooth.lib 
+LIBRARY			esock.lib sdpdatabase.lib sdpagent.lib btextnotifiers.lib btdevice.lib
+LIBRARY			vt100.lib
+
+NOSTRICTDEF
+DEFFILE btserial.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// bld.inf
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(btincomingserial.iby)
+
+#ifdef FSHELL_COMMS_SUPPORT
+..\inc\btincomingserial.h	+\include\fshell\btincomingserial.h
+..\inc\btserialclient.h		+\include\fshell\btserialclient.h
+
+PRJ_MMPFILES
+BtSerial
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/group/btincomingserial.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+// btincomingserial.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __BTINCOMINGSERIAL_IBY__
+#define __BTINCOMINGSERIAL_IBY__
+
+#include <fsh_config.iby>
+#include <vt100.iby>
+
+#ifdef FSHELL_COMMS_SUPPORT
+FSHELL_EXECUTABLE_FILE(btincomingserial.dll)
+#endif
+
+#endif //__BTINCOMINGSERIAL_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/inc/btincomingserial.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,113 @@
+// btincomingserial.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __BTINCOMING_H__
+#define __BTINCOMING_H__
+
+#include <es_sock.h>
+#include <bt_sock.h>
+#include <btsdp.h>
+
+
+enum TBtSerialPanic
+	{
+	EBtSerialNotConnected,
+	EBtSerialWritePending,
+	EBtSerialReadPending,	
+	};
+
+class CBtService;
+class CBtRegQuery;
+
+class MBtIncomingConnectionObserver
+	{
+public:
+	virtual void BtSerialConnected() = 0;
+	virtual void BtWriteComplete(TInt aError) = 0;
+	virtual void BtReadComplete(TInt aError) = 0;
+	virtual void BtSerialError(TInt aError) = 0;
+	virtual void BtShutdownComplete(TInt /*aError*/) {};
+	virtual void BtNameReceived(TInt /*aError*/, const TDesC& /*aName*/) {};
+	};
+	
+class CBluetoothIncomingSerialConnection	: public CBase
+											, public MBluetoothSocketNotifier
+	{
+public:
+	IMPORT_C static CBluetoothIncomingSerialConnection* NewL(MBtIncomingConnectionObserver& aObserver);
+	IMPORT_C virtual ~CBluetoothIncomingSerialConnection();
+	
+	IMPORT_C void WaitForConnection();
+	IMPORT_C TBool Connected();
+	
+	IMPORT_C TBTDevAddr ConnectedDeviceAddrL();
+	IMPORT_C void GetConnectedDeviceNameL();
+	
+	/**
+	Write some data. Must already be connected, as signalled via a callback to BtSerialConnected();
+	
+	Will callback to BtWriteComplete() when completed, no more write must be sent until this event
+	occurs.
+	*/
+	IMPORT_C void Write(const TDesC8& aData);
+	IMPORT_C void CancelWrite();
+	/**
+	Read some data. Must already be connected, as signalled via a callback to BtSerialConnected();
+	
+	Will callback to BtReadComplete() when completed, no more write must be sent until this event
+	occurs.
+	*/
+	IMPORT_C void Read(TDes8& aData);
+	IMPORT_C void CancelRead();
+	
+	IMPORT_C void ShutDown();
+	
+private:
+friend class CBtService;
+friend class CBtRegQuery;
+	CBluetoothIncomingSerialConnection(MBtIncomingConnectionObserver& aObserver);
+	void ConstructL();
+
+	virtual void HandleConnectCompleteL(TInt aErr);
+	virtual void HandleAcceptCompleteL(TInt aErr);
+	virtual void HandleShutdownCompleteL(TInt aErr);
+	virtual void HandleSendCompleteL(TInt aErr);
+	virtual void HandleReceiveCompleteL(TInt aErr);
+	virtual void HandleIoctlCompleteL(TInt aErr);
+	virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification);
+
+	void HandleNewConnection(CBluetoothSocket* aConnectedSocket);
+	void HandleConnectFailed(TInt aError);
+	
+	void QueryComplete(TInt aError);
+private:
+	MBtIncomingConnectionObserver& iObserver;
+	RSdp iSdpSession;
+	RSocketServ iSockServ;
+	CBtService* iService;
+
+	CBluetoothSocket* iSocket;
+	TBool iSocketReady;
+	TBool iSending;
+	TBool iReceiving;
+	TSockXfrLength iXferLen;
+	
+	RBTRegServ iBtRegServ;
+	RBTRegistry iBtReg;
+	CBTRegistryResponse* iRegReponse;
+	CBtRegQuery* iRegQuery;
+	
+	CBTDevice* iConnectedDevice;
+	RBuf iDeviceName;
+	};
+
+#endif //__BTINCOMING_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/inc/btserialclient.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+// btserialclient.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// Transient server example - client interface
+
+#ifndef __BTSERIALCLIENT_H__
+#define __BTSERIALCLIENT_H__
+
+#include <e32base.h>
+#include <fshell/vtc_controller.h>
+#include <bttypes.h>
+
+class RBtSerialSession : public RSessionBase
+	{
+public:
+	IMPORT_C TInt Connect();
+	IMPORT_C void Close();
+	
+	IMPORT_C void WaitForConnection(TRequestStatus& aStatus);
+	IMPORT_C void CancelWaitForConnection();
+	IMPORT_C TInt IsConnected() const;
+	IMPORT_C void Write(const TDesC8& aData, TRequestStatus& aStatus);
+	IMPORT_C void CancelWrite();
+	IMPORT_C void Read(TDes8& aData, TRequestStatus& aStatus) const;
+	IMPORT_C void CancelRead() const;	
+	
+	IMPORT_C TInt GetConnectedDeviceName(TDes& aName);
+	IMPORT_C TInt GetConnectedDeviceAddr(TBTDevAddr& aAddr);
+	
+private:
+	TInt StartServer();
+private:
+	RThread iSubThread;
+	RServer2 iServer;
+	};
+
+#endif //__BTSERIALCLIENT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/inc/btserialclientserver.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// btserialclientserver.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __BTSERIALCLIENTSERVER_H
+#define __BTSERIALCLIENTSERVER_H
+
+#include <e32std.h>
+
+_LIT(KBtSerialServerThreadName,"btserial");
+
+const TInt KMaxBtSerialMessage=100;
+
+enum TBtSerialMessages
+	{
+	EBtSerialWaitForConnection,
+	EBtSerialCancelWaitForConnection,
+	EBtSerialIsConnected,
+	EBtSerialWrite,
+	EBtSerialCancelWrite,
+	EBtSerialRead,
+	EBtSerialCancelRead,
+	EBtSerialSetInputMode,
+	EBtSerialGetConnectedDeviceAddr,
+	EBtSerialGetConnectedDeviceName,
+	};
+	
+TInt ServerThread(TAny* aParam);
+
+#endif //__BTSERIALCLIENTSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/client/btserialclient.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,116 @@
+// btserialclient.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// Transient server example - client interface implementation
+
+#include <fshell/btserialclient.h>
+#include "btserialclientserver.h"
+#include "..\connection\btdebug.h"
+
+_LIT(KSubThreadName, "btconsolethread");
+static const TInt KMaxHeapSize = 0x100000; // 1M
+
+TInt RBtSerialSession::StartServer()
+//
+// Start the server process. Simultaneous launching
+// of two such processes should be detected when the second one attempts to
+// create the server object, failing with KErrAlreadyExists.
+//
+	{
+	TInt err = iSubThread.Create(KSubThreadName, &ServerThread, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, &iServer);
+	
+	if (err != KErrNone)
+		{
+		return err;
+		}
+	
+	TRequestStatus rendezvous;
+	iSubThread.Rendezvous(rendezvous);
+	
+	iSubThread.Resume();
+	User::WaitForRequest(rendezvous);
+	
+	return rendezvous.Int();
+	}
+
+//______________________________________________________________________________
+//						RBtSerialSession
+EXPORT_C TInt RBtSerialSession::Connect()
+	{
+	TInt err = StartServer();
+	if (err == KErrNone)
+		{
+		TVersion ver;
+		err = CreateSession(iServer, ver);
+		}
+	return err;
+	}
+
+EXPORT_C void RBtSerialSession::Close()
+	{
+	TRACE1("RBtSerialSession::Close closing IPC session");
+	RSessionBase::Close();
+	// when we close the session (above) the server thread will exit.
+	// logon and wait for it
+	TRequestStatus stat;
+	iSubThread.Logon(stat);
+	TRACE1("RBtSerialSession::Close waiting for thread to exit");
+	User::WaitForRequest(stat);	
+	iSubThread.Close();
+	TRACE2("RBtSerialSession::Close done (%d)", stat.Int());
+	}
+	
+EXPORT_C void RBtSerialSession::WaitForConnection(TRequestStatus& aStatus)
+	{
+	SendReceive(EBtSerialWaitForConnection, aStatus);
+	}
+	
+EXPORT_C void RBtSerialSession::CancelWaitForConnection()
+	{
+	SendReceive(EBtSerialCancelWaitForConnection);
+	}
+	
+EXPORT_C TInt RBtSerialSession::IsConnected() const
+	{
+	return SendReceive(EBtSerialIsConnected);
+	}
+	
+EXPORT_C void RBtSerialSession::Write(const TDesC8& aData, TRequestStatus& aStatus)
+	{
+	SendReceive(EBtSerialWrite, TIpcArgs(&aData), aStatus);
+	}
+	
+EXPORT_C void RBtSerialSession::CancelWrite()
+	{
+	SendReceive(EBtSerialCancelWrite);
+	}
+	
+EXPORT_C void RBtSerialSession::Read(TDes8& aData, TRequestStatus& aStatus) const
+	{
+	SendReceive(EBtSerialRead, TIpcArgs(&aData), aStatus);
+	}
+	
+EXPORT_C void RBtSerialSession::CancelRead() const
+	{
+	SendReceive(EBtSerialCancelRead);
+	}
+
+EXPORT_C TInt RBtSerialSession::GetConnectedDeviceName(TDes& aName)
+	{
+	return SendReceive(EBtSerialGetConnectedDeviceName, TIpcArgs(&aName));
+	}
+	
+EXPORT_C TInt RBtSerialSession::GetConnectedDeviceAddr(TBTDevAddr& aAddr)
+	{
+	TPckg<TBTDevAddr> pckg(aAddr);
+	return SendReceive(EBtSerialGetConnectedDeviceAddr, TIpcArgs(&pckg));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/connection/btdebug.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// btdebug.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __BTDEBUG_H__
+#define __BTDEBUG_H__
+
+//#define _DEBUG_BT
+
+#define EXPAND(L, X) L(X)
+#define PANIC() User::Panic(EXPAND(_L, __FILE__), __LINE__)
+#define CHECK(fn) {TInt _err = (fn); if (_err!=KErrNone) return _err; }
+
+#ifdef _DEBUG_BT
+	#include <e32debug.h>
+	#define TRACE1(x) RDebug::Printf(x)
+	#define TRACE2(x, y) RDebug::Printf(x, y)
+	#define TRACE3(x, y, z) RDebug::Printf(x, y, z)
+	#define _BTDEB(x) x
+#else
+	#define TRACE1(x)
+	#define TRACE2(x, y)
+	#define TRACE3(x, y, z)
+	#define _BTDEB(x)
+#endif
+
+#endif //__BTDEBUG_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/connection/btincoming.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,310 @@
+// btincoming.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include "btincomingserial.h"
+#include "btservice.h"
+#include "btdebug.h"
+
+_LIT(KBtSerialPanic, "BTSerial");
+void Panic(TBtSerialPanic aReason)
+	{
+	TRACE2("BtIncoming panic %d", aReason);
+	User::Panic(KBtSerialPanic, aReason);
+	};
+	
+	
+NONSHARABLE_CLASS(CBtRegQuery) : public CActive
+	{
+public:
+	CBtRegQuery(CBluetoothIncomingSerialConnection& aOwner);
+	void Start(CBTRegistryResponse& aResponse);
+private:
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	CBluetoothIncomingSerialConnection& iOwner;
+	CBTRegistryResponse* iResponse;
+	};
+	
+
+EXPORT_C CBluetoothIncomingSerialConnection* CBluetoothIncomingSerialConnection::NewL(MBtIncomingConnectionObserver& aObserver)
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::NewL");
+	CBluetoothIncomingSerialConnection* self = new(ELeave)CBluetoothIncomingSerialConnection(aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CBluetoothIncomingSerialConnection::~CBluetoothIncomingSerialConnection()
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::~CBluetoothIncomingSerialConnection");
+	delete iService;
+	delete iSocket;
+	iSockServ.Close();
+	iSdpSession.Close();
+	}
+	
+CBluetoothIncomingSerialConnection::CBluetoothIncomingSerialConnection(MBtIncomingConnectionObserver& aObserver)
+	: iObserver(aObserver)
+	{
+	}
+	
+void CBluetoothIncomingSerialConnection::ConstructL()
+	{
+	TRACE1("+CBluetoothIncomingSerialConnection::ConstructL");
+	User::LeaveIfError(iSdpSession.Connect());
+	User::LeaveIfError(iSockServ.Connect());
+	TUUID serialPortUUID = TUUID(0x1101);
+	iService = CBtService::NewL(serialPortUUID, iSdpSession, iSockServ, *this, KRFCOMM); 
+	
+	// create a blank socket for the incoming connection
+	iSocket = CBluetoothSocket::NewL(*this, iSockServ);
+	TRACE1("-CBluetoothIncomingSerialConnection::ConstructL");
+	}
+	
+	
+EXPORT_C void CBluetoothIncomingSerialConnection::WaitForConnection()
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::WaitForConnection");
+	iService->AcceptConnection(*iSocket);
+	}
+	
+EXPORT_C TBool CBluetoothIncomingSerialConnection::Connected()
+	{
+	TRACE2("CBluetoothIncomingSerialConnection::Connected %d", iSocketReady);
+	return iSocketReady;
+	}
+	
+EXPORT_C TBTDevAddr CBluetoothIncomingSerialConnection::ConnectedDeviceAddrL()
+	{
+	if (!iSocketReady) User::Leave(KErrNotReady);
+	TBTSockAddr remote;
+	iSocket->RemoteName(remote);
+	return remote.BTAddr();
+	}
+	
+EXPORT_C void CBluetoothIncomingSerialConnection::GetConnectedDeviceNameL()
+	{
+	if (iConnectedDevice) return;
+	if (!iSocketReady) User::Leave(KErrNotReady);
+	// lazy construction....
+	if (!iRegQuery) iRegQuery = new(ELeave)CBtRegQuery(*this);
+	if (iRegQuery->IsActive())
+		{
+		return;
+		}
+	if (reinterpret_cast<RHandleBase&>(iBtRegServ).Handle() == KNullHandle)
+		{
+		User::LeaveIfError(iBtRegServ.Connect());
+		}
+	if (iBtReg.SubSessionHandle() == KNullHandle)
+		{
+		User::LeaveIfError(iBtReg.Open(iBtRegServ));
+		}
+	if (!iRegReponse) iRegReponse = CBTRegistryResponse::NewL(iBtReg);
+	
+	
+	TBTSockAddr remote;
+	iSocket->RemoteName(remote);
+
+	TBTRegistrySearch findConnected;
+	findConnected.FindAddress(remote.BTAddr());
+	TRequestStatus stat;
+	iBtReg.CreateView(findConnected, stat);
+	User::WaitForRequest(stat);
+	User::LeaveIfError(stat.Int());
+	
+	iRegQuery->Start(*iRegReponse);
+	}
+	
+void CBluetoothIncomingSerialConnection::QueryComplete(TInt aError)
+	{
+	iBtReg.CloseView();
+	if (aError == KErrNone)
+		{
+		RBTDeviceArray& results = iRegReponse->Results();
+		if (results.Count() != 1)
+			// we queried by BD address, so should get 1 (or 0) results
+			{
+			aError = KErrNotFound;
+			}
+		if (aError == KErrNone)
+			{
+			TRAP(aError, iConnectedDevice = results[0]->CopyL());
+			}
+		if (aError == KErrNone)
+			{
+			if (iConnectedDevice->IsValidFriendlyName())
+				{
+				aError = iDeviceName.Create(iConnectedDevice->FriendlyName());
+				}
+			else
+				{
+				aError = iDeviceName.Create(iConnectedDevice->DeviceName().Length());
+				if (aError == KErrNone)
+					{
+					iDeviceName.Copy(iConnectedDevice->DeviceName());
+					}
+				}
+			if (aError!=KErrNone)
+				{
+				delete iConnectedDevice;
+				iConnectedDevice = NULL;
+				}
+				
+			}
+		}
+	iObserver.BtNameReceived(aError, iDeviceName);
+	}
+
+EXPORT_C void CBluetoothIncomingSerialConnection::Write(const TDesC8& aData)
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::Write");
+	__ASSERT_ALWAYS(iSocketReady, Panic(EBtSerialNotConnected));
+	__ASSERT_ALWAYS(!iSending, Panic(EBtSerialWritePending));
+	TInt err = iSocket->Send(aData, 0);
+	if (err==KErrNone)
+		{
+		iSending = ETrue;
+		}
+	else
+		{
+		iObserver.BtWriteComplete(err);
+		}
+	}
+	
+EXPORT_C void CBluetoothIncomingSerialConnection::CancelWrite()
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::CancelWrite");
+	iSocket->CancelSend();
+	iSending = EFalse;
+	}
+	
+EXPORT_C void CBluetoothIncomingSerialConnection::Read(TDes8& aData)
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::Read");
+	__ASSERT_ALWAYS(iSocketReady, Panic(EBtSerialNotConnected));
+	__ASSERT_ALWAYS(!iReceiving, Panic(EBtSerialReadPending));
+	aData.Zero();	
+	TInt err = iSocket->RecvOneOrMore(aData, 0, iXferLen);
+	if (err==KErrNone)
+		{
+		iReceiving = ETrue;
+		}
+	else
+		{
+		iObserver.BtReadComplete(err);
+		}
+	}
+	
+EXPORT_C void CBluetoothIncomingSerialConnection::CancelRead()
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::CancelRead");
+	iSocket->CancelRead();
+	iReceiving = EFalse;
+	}
+	
+EXPORT_C void CBluetoothIncomingSerialConnection::ShutDown()
+	{
+	iSocket->Shutdown(RSocket::EImmediate);
+	}
+
+void CBluetoothIncomingSerialConnection::HandleConnectCompleteL(TInt _BTDEB(aErr))
+	{
+	TRACE2("CBluetoothIncomingSerialConnection::HandleConnectCompleteL(%d)", aErr);
+	}
+	
+void CBluetoothIncomingSerialConnection::HandleAcceptCompleteL(TInt _BTDEB(aErr))
+	{
+	TRACE2("CBluetoothIncomingSerialConnection::HandleAcceptCompleteL(%d)", aErr);
+	}
+	
+void CBluetoothIncomingSerialConnection::HandleShutdownCompleteL(TInt aErr)
+	{
+	TRACE2("CBluetoothIncomingSerialConnection::HandleShutdownCompleteL(%d)", aErr);
+	iObserver.BtShutdownComplete(aErr);
+	}
+	
+void CBluetoothIncomingSerialConnection::HandleSendCompleteL(TInt aErr)
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::HandleSendCompleteL");
+	__ASSERT_ALWAYS(iSending, PANIC());
+	iSending = EFalse;
+	iObserver.BtWriteComplete(aErr);
+	}
+	
+void CBluetoothIncomingSerialConnection::HandleReceiveCompleteL(TInt aErr)
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::HandleReceiveCompleteL");
+	__ASSERT_ALWAYS(iReceiving, PANIC());
+	iReceiving = EFalse;
+	iObserver.BtReadComplete(aErr);
+	}
+
+void CBluetoothIncomingSerialConnection::HandleIoctlCompleteL(TInt _BTDEB(aErr))
+	{
+	TRACE2("CBluetoothIncomingSerialConnection::HandleIoctlCompleteL(%d)", aErr);
+	}
+	
+void CBluetoothIncomingSerialConnection::HandleActivateBasebandEventNotifierCompleteL(TInt _BTDEB(aErr), TBTBasebandEventNotification& /*aEventNotification*/)
+	{
+	TRACE2("CBluetoothIncomingSerialConnection::HandleActivateBasebandEventNotifierCompleteL(%d)", aErr);
+	}
+	
+void CBluetoothIncomingSerialConnection::HandleNewConnection(CBluetoothSocket* aConnectedSocket)
+	{
+	TRACE1("CBluetoothIncomingSerialConnection::HandleNewConnection");
+	__ASSERT_ALWAYS(iSocket == aConnectedSocket, PANIC());
+	iSocketReady = ETrue;
+	iObserver.BtSerialConnected();
+	}
+	
+void CBluetoothIncomingSerialConnection::HandleConnectFailed(TInt aError)
+	{
+	TRACE2("CBluetoothIncomingSerialConnection::HandleConnectFailed", aError);
+	iSocketReady = EFalse;
+	iObserver.BtSerialError(aError);
+	}
+	
+CBtRegQuery::CBtRegQuery(CBluetoothIncomingSerialConnection& aOwner)
+	: CActive(CActive::EPriorityStandard), iOwner(aOwner)
+	{
+	CActiveScheduler::Add(this);
+	}
+	
+void CBtRegQuery::Start(CBTRegistryResponse& aBtResponse)
+	{
+	iResponse = &aBtResponse;
+	iResponse->Start(iStatus);
+	SetActive();
+	}
+		
+void CBtRegQuery::RunL()
+	{
+	iOwner.QueryComplete(iStatus.Int());
+	}
+	
+void CBtRegQuery::DoCancel()
+	{
+	iResponse->Cancel();
+	// nasty race condition inside CBTRegistryResponse which means the cancal call may not
+	// request out TRequestStatus (if DoCancel doesn't need to be called)
+	if (iStatus == KRequestPending)
+		{
+		TRequestStatus* stat = &iStatus;
+		User::RequestComplete(stat, KErrCancel);
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/connection/btservice.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,258 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+// Accenture - modified for fshell's btincomingserial.dll
+//
+// Description:
+// Name     : CBtService.cpp
+// Part of  : ex_btsocket
+// Created  : 17/11/2004 by Shane Kearns
+// Server "smart connector" class
+// Version  :
+// 
+//
+
+#include "btservice.h"
+#include "btdebug.h"
+#include "btincomingserial.h"
+
+/**
+Standard Symbian style 2 phase construction
+@param aServiceUUID a universally unique identifier for this application.
+@param aSdpSession a constructed sdp session owned by the application
+@param aSocketServer a constructed socket server session owned by the application
+@param aOwner the owning class which should receive notification of new connections
+@param aProtocol the protocol (RFCOMM or L2CAP) to register
+@param aSecurity optional security settings to use on the socket instead of system defaults
+*/
+CBtService* CBtService::NewL(const TUUID& aServiceUUID, 
+							 RSdp& aSdpSession, 
+							 RSocketServ& aSocketServer, 
+							 CBluetoothIncomingSerialConnection& aOwner,
+							 TUint aProtocol,
+							 const TBTServiceSecurity* aSecurity)
+	{
+	TRACE1("+CBtService::NewL");
+	__ASSERT_ALWAYS(aProtocol == KL2CAP || aProtocol == KRFCOMM, PANIC());
+	CBtService* self = new(ELeave) CBtService(aSocketServer, aOwner, aProtocol);
+	CleanupStack::PushL(self);
+	self->ConstructL(aServiceUUID, aSdpSession, aSecurity);
+	CleanupStack::Pop(self);
+	TRACE1("-CBtService::NewL");
+	return self;
+	}
+
+/**
+Standard 1st phase constructor, inialise member variables
+*/
+CBtService::CBtService(RSocketServ& aSocketServer, CBluetoothIncomingSerialConnection& aOwner, TUint aProtocol) :
+	iSocketServer(aSocketServer),
+	iOwner(aOwner),
+	iProtocol(aProtocol)
+	{
+	TRACE2("CBtService::CBtService@%08x", this);
+	}
+
+/**
+Standard 2nd phase constructor, perform initialisation which could leave
+*/
+void CBtService::ConstructL(const TUUID& aServiceUUID, RSdp& aSdpSession, const TBTServiceSecurity* aSecurity)
+	{
+	TRACE1("+CBtService::ConstructL");
+
+	//open handle so it is certain to be valid in the destructor
+	User::LeaveIfError(iServiceRecord.Open(aSdpSession));
+
+	//First, create a listening socket
+	if(iProtocol == KL2CAP)
+		{
+		iAcceptorSocket = CBluetoothSocket::NewL(*this, iSocketServer, KSockSeqPacket, KL2CAP);
+		//bind the socket to a port
+		TL2CAPSockAddr addr;
+		addr.SetPort(KL2CAPPassiveAutoBind); //allow the stack to choose a free port automatically
+		if(aSecurity)
+			{
+			addr.SetSecurity(*aSecurity); //set security requirements, if present
+			}
+		User::LeaveIfError(iAcceptorSocket->Bind(addr));
+		}
+	else if(iProtocol == KRFCOMM)
+		{
+		iAcceptorSocket = CBluetoothSocket::NewL(*this, iSocketServer, KSockStream, KRFCOMM);
+		//bind the socket to a port
+		TRfcommSockAddr addr;
+		addr.SetPort(KRfcommPassiveAutoBind); //allow the stack to choose a free port automatically
+		if(aSecurity)
+			{
+			addr.SetSecurity(*aSecurity); //set security requirements, if present
+			}
+		User::LeaveIfError(iAcceptorSocket->Bind(addr));
+		}
+	User::LeaveIfError(iAcceptorSocket->Listen(1)); 
+
+	//Now, register in the SDP database
+	TUint port = iAcceptorSocket->LocalPort(); //get the port chosen by the stack
+	TRACE2("Listening for connections on port %d", port);
+	iServiceRecord.CreateServiceRecordL(aServiceUUID, iServiceRecordHandle);
+	
+	// Set attr 4 (protocol list) to L2CAP, and RFCOMM
+	CSdpAttrValueDES *attrValDES;
+
+	//This following code is doing these steps
+	//1. create a DES (data element set) attribute
+	//2. within that list, create a DES for each protocol, L2CAP and optionally RFCOMM
+	//3. each protocol is a list of elements, the UUID of the protocol, and the port to connect to.
+	//4. the service record is updated to include the new attribute
+	//5. discard the attribute we built, as it has been copied to the SDP server
+	attrValDES = CSdpAttrValueDES::NewDESL(NULL);
+	CleanupStack::PushL(attrValDES);
+	if(iProtocol == KL2CAP)
+		{
+		TRACE1("Registering SDP PDL for L2CAP");
+		//This code will register an L2CAP (datagram) service
+		attrValDES
+			->StartListL()
+				->BuildDESL()
+					->StartListL()
+						->BuildUUIDL(TUUID(TUint16(KL2CAP)))	// L2CAP
+						->BuildUintL(TSdpIntBuf<TUint16>(TUint16(port)))	// The Protocol Service Multiplexor (port) for our service
+					->EndListL()
+			->EndListL();
+		}
+	else if(iProtocol == KRFCOMM)
+		{
+		TRACE1("Registering SDP PDL for RFCOMM");
+		//This code will register an RFCOMM (stream) service
+		attrValDES
+			->StartListL()
+				->BuildDESL()
+					->StartListL()
+						->BuildUUIDL(TUUID(TUint16(KL2CAP))) // L2CAP
+					->EndListL()
+				->BuildDESL()
+					->StartListL()
+						->BuildUUIDL(TUUID(TUint16(KRFCOMM))) // RFCOMM
+						->BuildUintL(TSdpIntBuf<TUint8>(TUint8(port)))
+					->EndListL()
+			->EndListL();
+		}
+	iServiceRecord.UpdateAttributeL(iServiceRecordHandle, KSdpAttrIdProtocolDescriptorList, *attrValDES);
+	CleanupStack::PopAndDestroy(attrValDES);
+	attrValDES = NULL;
+
+	_LIT8(KSerialPortServiceName, "Bluetooth Serial Console");
+	CSdpAttrValueString* attrVal = CSdpAttrValueString::NewStringL(KSerialPortServiceName);
+	CleanupStack::PushL(attrVal);
+	iServiceRecord.UpdateAttributeL(iServiceRecordHandle, 
+			KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, *attrVal);
+	CleanupStack::PopAndDestroy(attrVal);
+	attrVal = NULL;
+	TRACE1("-CBtService::ConstructL");
+	}
+
+CBtService::~CBtService()
+	{
+	TRACE1("CBtService::~CBtService");
+	//attempt to remove the SDP record
+	TRAP_IGNORE(iServiceRecord.DeleteRecordL(iServiceRecordHandle));
+	iServiceRecord.Close();
+	delete iAcceptorSocket;
+	}
+
+/**
+Accept a new connection.
+When the incoming connection has been made, HandleAcceptCompleteL() will be called
+in this class.
+That function informs the owner by calling HandleNewConnection() or HandleConnectFailed()
+@param aBlankSocket an empty socket to receive the incoming connection. 
+*/
+void CBtService::AcceptConnection(CBluetoothSocket& aBlankSocket)
+	{
+	TRACE1("+CBtService::AcceptConnection");
+	__ASSERT_ALWAYS(iConnectionSocket == NULL, PANIC());
+	iConnectionSocket = &aBlankSocket;
+	iAcceptorSocket->Accept(*iConnectionSocket);
+	TRACE1("-CBtService::AcceptConnection");
+	}
+
+/**
+Callback from CBluetoothSocket when a new incoming connection is complete.
+Inform the owner 
+*/
+void CBtService::HandleAcceptCompleteL(TInt aErr)
+	{
+	TRACE1("+CBtService::HandleAcceptCompleteL");
+	if(aErr == KErrNone)
+		{
+		iOwner.HandleNewConnection(iConnectionSocket); 
+		}
+	else
+		{
+		iOwner.HandleConnectFailed(aErr);
+		}
+	iConnectionSocket = NULL;
+	TRACE1("-CBtService::HandleAcceptCompleteL");
+	}
+
+/**
+This function is not used but must be implemented as it is pure virtual
+*/
+void CBtService::HandleConnectCompleteL(TInt /*aErr*/)
+	{
+	TRACE1("+CBtService::HandleConnectCompleteL");
+	PANIC();
+	}
+
+/**
+This function is not used but must be implemented as it is pure virtual
+*/
+void CBtService::HandleShutdownCompleteL(TInt /*aErr*/)
+	{
+	TRACE1("+CBtService::HandleShutdownCompleteL");
+	PANIC();
+	}
+
+/**
+This function is not used but must be implemented as it is pure virtual
+*/
+void CBtService::HandleSendCompleteL(TInt /*aErr*/)
+	{
+	TRACE1("+CBtService::HandleSendCompleteL");
+	PANIC();
+	}
+
+/**
+This function is not used but must be implemented as it is pure virtual
+*/
+void CBtService::HandleReceiveCompleteL(TInt /*aErr*/)
+	{
+	TRACE1("+CBtService::HandleReceiveCompleteL");
+	PANIC();
+	}
+
+/**
+This function is not used but must be implemented as it is pure virtual
+*/
+void CBtService::HandleIoctlCompleteL(TInt /*aErr*/)
+	{
+	TRACE1("+CBtService::HandleIoctlCompleteL");
+	PANIC();
+	}
+
+/**
+This function is not used but must be implemented as it is pure virtual
+*/
+void CBtService::HandleActivateBasebandEventNotifierCompleteL(TInt /*aErr*/, TBTBasebandEventNotification& /*aEventNotification*/)
+	{
+	TRACE1("+CBtService::HandleActivateBasebandEventNotifierCompleteL");
+	PANIC();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/connection/btservice.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+// 
+// Contributors:
+// Accenture - modified for fshell's btincomingserial.dll
+// 
+// Description:
+// Name     : CBtService.h
+// Part of  : ex_btsocket
+// Created  : 17/11/2004 by Shane Kearns
+// Server "smart connector" class
+// Version  :
+// 
+
+#ifndef CBTSERVICE_H
+#define CBTSERVICE_H
+
+#include <e32std.h>
+#include <bt_sock.h>
+#include <btsdp.h>
+
+class CBluetoothIncomingSerialConnection;
+
+/**
+This class implements a simple bluetooth application service
+Its responsibility is to advertise and accept incoming bluetooth connections
+*/
+NONSHARABLE_CLASS(CBtService) : public CBase, MBluetoothSocketNotifier
+	{
+	public:
+		static CBtService* NewL(const TUUID& aServiceUUID, 
+			RSdp& aSdpSession, 
+			RSocketServ& aSocketServer, 
+			CBluetoothIncomingSerialConnection& aOwner,
+			TUint aProtocol,
+			const TBTServiceSecurity* aSecurity=NULL);
+		~CBtService();
+
+		void AcceptConnection(CBluetoothSocket& aBlankSocket);
+	private:
+		CBtService(RSocketServ& aSocketServer, 
+			CBluetoothIncomingSerialConnection& aOwner, 
+			TUint aProtocol
+			);
+		void ConstructL(const TUUID& aServiceUUID, 
+			RSdp& aSdpSession, 
+			const TBTServiceSecurity* aSecurity=NULL);
+		//Virtual functions from MBluetoothSocketNotifier
+		virtual void HandleConnectCompleteL(TInt aErr);
+		virtual void HandleAcceptCompleteL(TInt aErr);
+		virtual void HandleShutdownCompleteL(TInt aErr);
+		virtual void HandleSendCompleteL(TInt aErr);
+		virtual void HandleReceiveCompleteL(TInt aErr);
+		virtual void HandleIoctlCompleteL(TInt aErr);
+		virtual void HandleActivateBasebandEventNotifierCompleteL(TInt aErr, TBTBasebandEventNotification& aEventNotification);
+
+		//Data members
+		RSocketServ& iSocketServer;
+		CBluetoothSocket *iAcceptorSocket;
+		CBluetoothSocket *iConnectionSocket; //not owned
+		RSdpDatabase iServiceRecord;
+		TSdpServRecordHandle iServiceRecordHandle;
+		CBluetoothIncomingSerialConnection& iOwner;
+		TUint iProtocol;
+	};
+
+#endif //CBTSERVICE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/server/btserialserver.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,104 @@
+// btserialserver.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btserialserver.h"
+#include "btserialsession.h"
+#include <fshell/btincomingserial.h>
+
+static void RunServerL(RServer2* aServerPtr)
+//
+// Perform all server initialisation, in particular creation of the
+// scheduler and server and then run the scheduler
+//
+	{
+	// naming the server thread after the server helps to debug panics
+	User::LeaveIfError(RThread::RenameMe(KBtSerialServerThreadName));
+	//
+	// create and install the active scheduler we need
+	CActiveScheduler* s=new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(s);
+	CActiveScheduler::Install(s);
+	//
+	// create the server (leave it on the cleanup stack)
+	CServer2* server = CBtSerialServer::NewLC();
+	*aServerPtr = server->Server();
+	//
+	// Initialisation complete, now signal the client
+	RThread::Rendezvous(KErrNone);
+	//
+	// Ready to run
+	CActiveScheduler::Start();
+	//
+	// Cleanup the server and scheduler
+	CleanupStack::PopAndDestroy(2);
+	}
+
+TInt ServerThread(TAny* aRServerPtr)
+//
+// Server process entry-point
+//
+	{
+	__UHEAP_MARK;
+	//
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+	TInt r=KErrNoMemory;
+	if (cleanup)
+		{
+		RServer2* serverPtr = static_cast<RServer2*>(aRServerPtr);
+		
+		TRAP(r,RunServerL(serverPtr));
+		delete cleanup;
+		}
+	//
+	__UHEAP_MARKEND;
+	return r;
+	}
+
+//______________________________________________________________________________
+//						CBtSerialServer
+CServer2* CBtSerialServer::NewLC()
+	{
+	CBtSerialServer* self=new(ELeave) CBtSerialServer;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+	
+inline CBtSerialServer::CBtSerialServer()
+	:CServer2(0,EUnsharableSessions)
+	{
+	}
+
+
+
+void CBtSerialServer::ConstructL()
+	{
+	StartL(KNullDesC);
+	}
+
+
+CSession2* CBtSerialServer::NewSessionL(const TVersion&,const RMessage2&) const
+	{
+	if (iSession)
+		{
+		User::Leave(KErrAlreadyExists);
+		}
+	const_cast<CBtSerialServer*>(this)->iSession = new(ELeave) CBtSerialSession();
+	return iSession;
+	}
+
+void CBtSerialServer::DropSession()
+	{
+	iSession = NULL;
+	CActiveScheduler::Stop();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/server/btserialserver.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// btserialserver.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __BTSERIALSERVER_H__
+#define __BTSERIALSERVER_H__
+
+#include <e32base.h>
+#include "btserialclientserver.h"
+
+class CBtSerialSession;
+
+class CBtSerialServer : public CServer2
+	{
+public:
+	static CServer2* NewLC();
+	void DropSession();
+private:
+	CBtSerialServer();
+	void ConstructL();
+	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+private:
+	CBtSerialSession* iSession;
+	};
+
+#endif //__BTSERIALSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/server/btserialsession.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,312 @@
+// btserialsession.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "btserialsession.h"
+#include "btserialserver.h"
+#include "btserialclient.h"
+#include <fshell/btincomingserial.h>
+#include "..\connection\btdebug.h"
+
+
+void PanicClient(const RMessagePtr2& aMessage,TBtSerialServerPanic aPanic)
+//
+// RMessage::Panic() also completes the message. This is:
+// (a) important for efficient cleanup within the kernel
+// (b) a problem if the message is completed a second time
+//
+	{
+	_LIT(KPanic,"BtSerialSrv");
+	aMessage.Panic(KPanic,aPanic);
+	}
+
+//______________________________________________________________________________
+//						CBtSerialSession
+void CBtSerialSession::CreateL()
+	{
+	TRACE1("CBtSerialSession::CreateL");
+	iConnection = CBluetoothIncomingSerialConnection::NewL(*this);
+	}
+
+CBtSerialSession::CBtSerialSession()
+	{
+	}
+
+CBtSerialSession::~CBtSerialSession()
+	{
+	TRACE1("CBtSerialSession::~CBtSerialSession");
+	delete iConnection;
+	iReadBuf.Close();
+	iWriteBuf.Close();	
+	Server().DropSession();
+	}
+
+void CBtSerialSession::ServiceL(const RMessage2& aMessage)
+	{
+	switch (aMessage.Function())
+		{
+	case EBtSerialWaitForConnection:
+		WaitForConnectionL(aMessage);
+		break;
+	case EBtSerialCancelWaitForConnection:
+		CancelWaitForConnection(aMessage);
+		break;
+	case EBtSerialIsConnected:
+		IsConnectedL(aMessage);
+		break;
+	case EBtSerialWrite:
+		WriteL(aMessage);
+		break;
+	case EBtSerialCancelWrite:
+		CancelWrite(aMessage);
+		break;
+	case EBtSerialRead:
+		ReadL(aMessage);
+		break;
+	case EBtSerialCancelRead:
+		CancelRead(aMessage);
+		break;
+	case EBtSerialGetConnectedDeviceAddr:
+		GetConnectedDeviceAddrL(aMessage);
+		break;
+	case EBtSerialGetConnectedDeviceName:
+		GetConnectedDeviceNameL(aMessage);
+		break;
+	default:
+		PanicClient(aMessage,EPanicIllegalFunction);
+		break;
+		}
+	}
+	
+void CBtSerialSession::Disconnect(const RMessage2& aMessage)
+	{
+	if (iConnection->Connected())
+		{
+		TRACE1("CBtSerialSession::Disconnect shutting down connection & storing message");
+		iDisconnectMessage = aMessage;
+		iConnection->ShutDown();
+		}
+	else
+		{
+		CSession2::Disconnect(aMessage);
+		}
+	}
+
+void CBtSerialSession::ServiceError(const RMessage2& aMessage,TInt aError)
+	{
+	if (aError==KErrBadDescriptor)
+		PanicClient(aMessage,EPanicBadDescriptor);
+	CSession2::ServiceError(aMessage,aError);
+	}
+
+inline CBtSerialServer& CBtSerialSession::Server()
+	{
+	return *static_cast<CBtSerialServer*>(const_cast<CServer2*>(CSession2::Server()));
+	}
+
+void CBtSerialSession::WaitForConnectionL(const RMessage2& aMessage)
+	{
+	TRACE1("CBtSerialSession::WaitForConnectionL");
+	if (iConnection->Connected())
+		{
+		aMessage.Complete(KErrNone);
+		return;
+		}
+	if (!iConnectedMessage.IsNull())
+		{
+		User::Leave(KErrAlreadyExists);
+		}
+	iConnectedMessage = aMessage;
+	if (!iWaitingForConnection)
+		{
+		iConnection->WaitForConnection();
+		}
+	}
+	
+void CBtSerialSession::CancelWaitForConnection(const RMessage2& aMessage)
+	{
+	TRACE1("CBtSerialSession::CancelWaitForConnection");
+	if (!iConnectedMessage.IsNull())
+		{
+		iConnectedMessage.Complete(KErrCancel);
+		}
+	aMessage.Complete(KErrNone);
+	}
+	
+void CBtSerialSession::IsConnectedL(const RMessage2& aMessage)
+	{
+	TRACE1("CBtSerialSession::IsConnectedL");
+	aMessage.Complete(iConnection->Connected());
+	}
+	
+void CBtSerialSession::WriteL(const RMessage2& aMessage)
+	{
+	TRACE1("CBtSerialSession::WriteL");
+	if (!iWriteMessage.IsNull())
+		{
+		User::Leave(KErrInUse);
+		}
+	TInt len = aMessage.GetDesLengthL(0);
+	if (iWriteBuf.MaxLength() < len)
+		{
+		RBuf8 buf;
+		buf.CreateL(len);
+		buf.Swap(iWriteBuf);
+		buf.Close();
+		}
+	iWriteBuf.Zero();
+	aMessage.ReadL(0, iWriteBuf);
+	iWriteMessage = aMessage;
+	if (iConnection->Connected())
+		{
+		iConnection->Write(iWriteBuf);
+		}
+	// else the write will be performed when we are connected
+	}
+	
+void CBtSerialSession::CancelWrite(const RMessage2& aMessage)
+	{
+	TRACE1("CBtSerialSession::CancelWrite");
+	iConnection->CancelWrite();
+	iWriteBuf.Zero();
+	if (!iWriteMessage.IsNull())
+		{
+		iWriteMessage.Complete(KErrCancel);
+		}
+	aMessage.Complete(KErrNone);
+	}
+	
+void CBtSerialSession::ReadL(const RMessage2& aMessage)
+	{
+	TRACE1("CBtSerialSession::ReadL");
+	if (!iReadMessage.IsNull())
+		{
+		User::Leave(KErrInUse);
+		}
+	TInt len = aMessage.GetDesMaxLengthL(0);
+	if (iReadBuf.MaxLength() != len) // better to add length param to CBluetoothIncomingSerialConnection::Read
+		{
+		RBuf8 buf;
+		buf.CreateL(len);
+		buf.Swap(iReadBuf);
+		buf.Close();
+		}
+	iReadBuf.Zero();
+	iReadMessage = aMessage;
+	if (iConnection->Connected())
+		{
+		iConnection->Read(iReadBuf);
+		}
+	}
+	
+void CBtSerialSession::CancelRead(const RMessage2& aMessage)
+	{
+	TRACE1("CBtSerialSession::CancelRead");
+	iConnection->CancelRead();
+	if (!iReadMessage.IsNull())
+		{
+		iReadMessage.Complete(KErrCancel);
+		}
+	aMessage.Complete(KErrNone);
+	}
+
+void CBtSerialSession::GetConnectedDeviceNameL(const RMessage2& aMessage)
+	{
+	if (!iGetNameMessage.IsNull())
+		{
+		User::Leave(KErrAlreadyExists);
+		}
+	iGetNameMessage = aMessage;
+	iConnection->GetConnectedDeviceNameL();
+	}
+
+void CBtSerialSession::GetConnectedDeviceAddrL(const RMessage2& aMessage)
+	{
+	TBTDevAddr addr = iConnection->ConnectedDeviceAddrL();
+	TPckg<TBTDevAddr> pckg(addr);
+	aMessage.WriteL(0, pckg);
+	aMessage.Complete(KErrNone);
+	}
+
+void CBtSerialSession::BtSerialConnected()
+	{
+	TRACE1("CBtSerialSession::BtSerialConnected");
+	if (!iConnectedMessage.IsNull())
+		{
+		iConnectedMessage.Complete(KErrNone);
+		}
+	if (!iWriteMessage.IsNull())
+		{
+		iConnection->Write(iWriteBuf);
+		}
+	if (!iReadMessage.IsNull())
+		{
+		iConnection->Read(iReadBuf);
+		}
+	}
+	
+void CBtSerialSession::BtWriteComplete(TInt aError)
+	{
+	TRACE1("CBtSerialSession::BtWriteComplete");
+	iWriteMessage.Complete(aError);
+	}
+	
+void CBtSerialSession::BtReadComplete(TInt aError)
+	{
+	TRACE1("CBtSerialSession::BtReadComplete");
+	if (aError == KErrNone)
+		{
+		aError = iReadMessage.Write(0, iReadBuf);			
+		}
+	iReadMessage.Complete(aError);
+	}
+	
+void CBtSerialSession::BtSerialError(TInt aError)
+	{
+	TRACE1("CBtSerialSession::BtSerialError");
+	if (!iConnectedMessage.IsNull())
+		{
+		iConnectedMessage.Complete(aError);
+		}
+	}
+	
+void CBtSerialSession::BtShutdownComplete(TInt /*aError*/)
+	{
+	TRACE1("CBtSerialSession::BtShutdownComplete");
+	CSession2::Disconnect(iDisconnectMessage);
+	}
+	
+void CBtSerialSession::BtNameReceived(TInt aError, const TDesC& aName)
+	{
+	TInt len = 0;
+	if (aError == KErrNone)
+		{
+		aError = iGetNameMessage.GetDesMaxLength(0);
+		if (aError >= 0)
+			{
+			len = aError;
+			aError = KErrNone;
+			}
+		}
+	if (aError == KErrNone)
+		{
+		aError = iGetNameMessage.Write(0, aName.Left(len));
+		}
+	if (aError == KErrNone)
+		{
+		if (aName.Length() > len)
+			{
+			aError = KErrOverflow;
+			}
+		}
+	iGetNameMessage.Complete(aError);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/src/server/btserialsession.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,78 @@
+// btserialsession.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __BTSERIALSESSION_H__
+#define __BTSERIALSESSION_H__
+
+#include <e32base.h>
+#include <fshell/btincomingserial.h>
+
+
+class CBtSerialServer;
+
+enum TBtSerialServerPanic
+	{
+	EPanicBadDescriptor,
+	EPanicIllegalFunction,
+	EPanicAlreadyReceiving,
+	EPanicInvalidInputMode,
+	EPanicWrongKeypressDesLength,
+	};
+
+void PanicClient(const RMessagePtr2& aMessage,TBtSerialServerPanic aPanic);
+
+class CBtSerialSession	: public CSession2
+						, public MBtIncomingConnectionObserver
+	{
+public:
+	CBtSerialSession();
+	void CreateL();
+	void Send(const TDesC& aMessage);
+	
+	// from MBtIncomingConnectionObserver:
+	virtual void BtSerialConnected();
+	virtual void BtWriteComplete(TInt aError);
+	virtual void BtReadComplete(TInt aError);
+	virtual void BtSerialError(TInt aError);
+	virtual void BtShutdownComplete(TInt aError);
+	virtual void BtNameReceived(TInt aError, const TDesC& aName);
+	
+	virtual void Disconnect(const RMessage2& aMessage);
+private:
+	~CBtSerialSession();
+	inline CBtSerialServer& Server();
+	void ServiceL(const RMessage2& aMessage);
+	void ServiceError(const RMessage2& aMessage,TInt aError);
+
+	void WaitForConnectionL(const RMessage2& aMessage);
+	void CancelWaitForConnection(const RMessage2& aMessage);
+	void IsConnectedL(const RMessage2& aMessage);
+	void WriteL(const RMessage2& aMessage);
+	void CancelWrite(const RMessage2& aMessage);
+	void ReadL(const RMessage2& aMessage);
+	void CancelRead(const RMessage2& aMessage);
+	void GetConnectedDeviceAddrL(const RMessage2& aMessage);
+	void GetConnectedDeviceNameL(const RMessage2& aMessage);
+private:
+	CBluetoothIncomingSerialConnection* iConnection;
+	TBool iWaitingForConnection;
+	RMessagePtr2 iConnectedMessage;
+	RMessagePtr2 iWriteMessage;
+	RMessagePtr2 iReadMessage;
+	RMessage2 iDisconnectMessage;
+	RMessagePtr2 iGetNameMessage;
+	
+	RBuf8 iReadBuf;
+	RBuf8 iWriteBuf;
+	};
+
+#endif //__BTSERIALSESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/test/BtSerialTest.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,109 @@
+// BtSerialTest.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/btserialclient.h>
+
+using namespace IoUtils;
+
+class CCmdBtSerialTest : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdBtSerialTest();
+private:
+	CCmdBtSerialTest();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RBtSerialSession iSession;
+	};
+
+
+CCommandBase* CCmdBtSerialTest::NewLC()
+	{
+	CCmdBtSerialTest* self = new(ELeave) CCmdBtSerialTest();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdBtSerialTest::~CCmdBtSerialTest()
+	{
+	}
+
+CCmdBtSerialTest::CCmdBtSerialTest()
+	{
+	}
+
+const TDesC& CCmdBtSerialTest::Name() const
+	{
+	_LIT(KName, "BtSerialTest");	
+
+	return KName;
+	}
+
+const TDesC& CCmdBtSerialTest::Description() const
+	{
+	_LIT(KDescription, "Test for BT serial incoming connection");
+	return KDescription;
+	}
+
+void CCmdBtSerialTest::DoRunL()
+	{
+	TInt err = iSession.Connect();
+	if (err!=KErrNone)
+		{
+		Printf(_L("Failed to connect %d\n"), err);
+		iSession.Close();
+		return;
+		}
+	TRequestStatus req;
+	iSession.WaitForConnection(req);
+	Printf(_L("Waiting for connection...\n"));
+	User::WaitForRequest(req);
+	Printf(_L("Connected %d\n"), req.Int());
+	
+	TBuf8<0x100> buf;
+	iSession.Read(buf, req);
+	Printf(_L("Waiting for data...\n"));
+	User::WaitForRequest(req);
+	if (req != KErrNone)
+		{
+		Printf(_L("Read error %d\n"), req.Int());
+		}
+	else
+		{
+		iSession.Write(buf, req);
+		Printf(_L("Echoing data...\n"));
+		User::WaitForRequest(req);
+		Printf(_L("Write returns %d"), req.Int());
+		}
+	
+	iSession.Close();	
+	}
+
+void CCmdBtSerialTest::ArgumentsL(RCommandArgumentList& /*aArguments*/)
+	{
+	}
+
+void CCmdBtSerialTest::OptionsL(RCommandOptionList& /*aOptions*/)
+	{
+	}
+
+
+EXE_BOILER_PLATE(CCmdBtSerialTest)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/test/BtSerialTest.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// BtSerialTest.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          BtSerialTest.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE FSHELL_UID_BTSERIALTEST
+
+capability      FSHELL_CAP_MMP_NORMAL
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+systeminclude	..\inc
+
+sourcepath      .
+source          BtSerialTest.cpp
+
+library         euser.lib
+library         iocli.lib
+library         btincomingserial.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/test/BtSerialTest.pkg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+; BtSerialTest.pkg
+; 
+; Copyright (c) 2010 Accenture. All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+; 
+; Initial Contributors:
+; Accenture - Initial contribution
+;
+
+; List of localised vendor name
+%{"Symbian"}
+
+; The non-localised, globally unique vendor name
+:"Symbian"
+
+; Package header
+; Name, UID3, Major, Minor, Build, Package-type
+#{"BT Serial test"}, (0x10285e14), 1, 0, 0, TYPE=SA
+
+; ProductID for UIQ 3.0
+; Product/platform version UID, Major, Minor, Build, Component name
+(0x101F6300), 3, 0, 0, {"UIQ30ProductID"}
+
+"\EPOC32\RELEASE\ARMv5\UREL\BtSerialTest.exe"-"!:\sys\bin\BtSerialTest.exe"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/btserial/test/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,24 @@
+// bld.inf
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+
+PRJ_TESTEXPORTS
+
+PRJ_MMPFILES
+BtSerialTest
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BMARM/CDUU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+EXPORTS
+	__DbgShutDownServer__11RFileLogger @ 1 NONAME R3UNUSED ; RFileLogger::__DbgShutDownServer(void)
+	ClientRunStubOrdinal1__Fv @ 2 NONAME R3UNUSED ; ClientRunStubOrdinal1(void)
+	CloseLog__11RFileLogger @ 3 NONAME R3UNUSED ; RFileLogger::CloseLog(void)
+	Close__11RFileLogger @ 4 NONAME R3UNUSED ; RFileLogger::Close(void)
+	Connect__11RFileLogger @ 5 NONAME R3UNUSED ; RFileLogger::Connect(void)
+	CreateLog__11RFileLoggerRC7TDesC16T116TFileLoggingMode @ 6 NONAME ; RFileLogger::CreateLog(TDesC16 const &, TDesC16 const &, TFileLoggingMode)
+	Handle__C11RFileLogger @ 7 NONAME R3UNUSED ; RFileLogger::Handle(void) const
+	HexDump__11RFileLoggerPCUsT1PCUci @ 8 NONAME ; RFileLogger::HexDump(unsigned short const *, unsigned short const *, unsigned char const *, int)
+	HexDump__11RFileLoggerRC6TDesC8N31 @ 9 NONAME ; RFileLogger::HexDump(TDesC8 const &, TDesC8 const &, TDesC8 const &, TDesC8 const &)
+	HexDump__11RFileLoggerRC6TDesC8T1 @ 10 NONAME R3UNUSED ; RFileLogger::HexDump(TDesC8 const &, TDesC8 const &)
+	HexDump__11RFileLoggerRC7TDesC16T116TFileLoggingModePCUsT4PCUci @ 11 NONAME ; RFileLogger::HexDump(TDesC16 const &, TDesC16 const &, TFileLoggingMode, unsigned short const *, unsigned short const *, unsigned char const *, int)
+	LastError__C11RFileLogger @ 12 NONAME R3UNUSED ; RFileLogger::LastError(void) const
+	LogValid__C11RFileLogger @ 13 NONAME R3UNUSED ; RFileLogger::LogValid(void) const
+	SetDateAndTime__11RFileLoggerii @ 14 NONAME R3UNUSED ; RFileLogger::SetDateAndTime(int, int)
+	SetLogTags__11RFileLoggerRC6TDesC8T1 @ 15 NONAME R3UNUSED ; RFileLogger::SetLogTags(TDesC8 const &, TDesC8 const &)
+	Share__11RFileLogger @ 16 NONAME R3UNUSED ; RFileLogger::Share(void)
+	Version__C11RFileLogger @ 17 NONAME R3UNUSED ; RFileLogger::Version(void) const
+	WriteBinary__11RFileLoggerRC6TDesC8 @ 18 NONAME R3UNUSED ; RFileLogger::WriteBinary(TDesC8 const &)
+	WriteFormat__11RFileLoggerGt11TRefByValue1ZC6TDesC8RA0_PSc @ 19 NONAME R3UNUSED ; RFileLogger::WriteFormat(TRefByValue<TDesC8 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerGt11TRefByValue1ZC6TDesC8e @ 20 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC8 const>,...)
+	WriteFormat__11RFileLoggerGt11TRefByValue1ZC7TDesC16RA0_PSc @ 21 NONAME R3UNUSED ; RFileLogger::WriteFormat(TRefByValue<TDesC16 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerGt11TRefByValue1ZC7TDesC16e @ 22 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC16 const>,...)
+	WriteFormat__11RFileLoggerRC6TDesC8T1Gt11TRefByValue1ZC6TDesC8RA0_PSc @ 23 NONAME ; RFileLogger::WriteFormat(TDesC8 const &, TDesC8 const &, TRefByValue<TDesC8 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerRC6TDesC8T1Gt11TRefByValue1ZC6TDesC8e @ 24 NONAME ; RFileLogger::WriteFormat(TDesC8 const &, TDesC8 const &, TRefByValue<TDesC8 const>,...)
+	WriteFormat__11RFileLoggerRC6TDesC8T1Gt11TRefByValue1ZC7TDesC16RA0_PSc @ 25 NONAME ; RFileLogger::WriteFormat(TDesC8 const &, TDesC8 const &, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerRC6TDesC8T1Gt11TRefByValue1ZC7TDesC16e @ 26 NONAME ; RFileLogger::WriteFormat(TDesC8 const &, TDesC8 const &, TRefByValue<TDesC16 const>,...)
+	WriteFormat__11RFileLoggerRC7TDesC16T116TFileLoggingModeGt11TRefByValue1ZC6TDesC8RA0_PSc @ 27 NONAME ; RFileLogger::WriteFormat(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TRefByValue<TDesC8 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerRC7TDesC16T116TFileLoggingModeGt11TRefByValue1ZC6TDesC8e @ 28 NONAME ; RFileLogger::WriteFormat(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TRefByValue<TDesC8 const>,...)
+	WriteFormat__11RFileLoggerRC7TDesC16T116TFileLoggingModeGt11TRefByValue1ZC7TDesC16RA0_PSc @ 29 NONAME ; RFileLogger::WriteFormat(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerRC7TDesC16T116TFileLoggingModeGt11TRefByValue1ZC7TDesC16e @ 30 NONAME ; RFileLogger::WriteFormat(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TRefByValue<TDesC16 const>,...)
+	Write__11RFileLoggerRC6TDesC8 @ 31 NONAME R3UNUSED ; RFileLogger::Write(TDesC8 const &)
+	Write__11RFileLoggerRC6TDesC8N21 @ 32 NONAME R3UNUSED ; RFileLogger::Write(TDesC8 const &, TDesC8 const &, TDesC8 const &)
+	Write__11RFileLoggerRC6TDesC8T1RC7TDesC16 @ 33 NONAME R3UNUSED ; RFileLogger::Write(TDesC8 const &, TDesC8 const &, TDesC16 const &)
+	Write__11RFileLoggerRC7TDesC16 @ 34 NONAME R3UNUSED ; RFileLogger::Write(TDesC16 const &)
+	Write__11RFileLoggerRC7TDesC16T116TFileLoggingModeRC6TDesC8 @ 35 NONAME ; RFileLogger::Write(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TDesC8 const &)
+	Write__11RFileLoggerRC7TDesC16T116TFileLoggingModeT1 @ 36 NONAME ; RFileLogger::Write(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TDesC16 const &)
+	"_._11RFileLogger" @ 37 NONAME R3UNUSED ; RFileLogger::~RFileLogger(void)
+	__11RFileLogger @ 38 NONAME R3UNUSED ; RFileLogger::RFileLogger(void)
+	__DbgSetHeapFailure__11RFileLoggeri @ 39 NONAME R3UNUSED ; RFileLogger::__DbgSetHeapFailure(int)
+	ClearLog__11RFileLogger @ 40 NONAME R3UNUSED ; RFileLogger::ClearLog(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BMARM/cloggerU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+EXPORTS
+	__8RCloggerPv @ 1 NONAME R3UNUSED ; RClogger::RClogger(void *)
+	Close__19RCloggerLogConsumer @ 2 NONAME R3UNUSED ; RCloggerLogConsumer::Close(void)
+	Close__8RClogger @ 3 NONAME R3UNUSED ; RClogger::Close(void)
+	Connect__19RCloggerLogConsumer @ 4 NONAME R3UNUSED ; RCloggerLogConsumer::Connect(void)
+	Connect__8RClogger @ 5 NONAME R3UNUSED ; RClogger::Connect(void)
+	Connect__8RCloggerRC7TDesC16 @ 6 NONAME R3UNUSED ; RClogger::Connect(TDesC16 const &)
+	GetGlobalOptions__8RClogger @ 7 NONAME R3UNUSED ; RClogger::GetGlobalOptions(void)
+	GetNextLog__19RCloggerLogConsumerR14TRequestStatusR6TPtrC8 @ 8 NONAME R3UNUSED ; RCloggerLogConsumer::GetNextLog(TRequestStatus &, TPtrC8 &)
+	GetRamBufferSize__8RCloggerPi @ 9 NONAME R3UNUSED ; RClogger::GetRamBufferSize(int *)
+	GetRotateBehaviour__8RCloggerPi @ 10 NONAME R3UNUSED ; RClogger::GetRotateBehaviour(int *)
+	GetTagStatesL__8RCloggerRP12CDesC16ArrayR5RBuf8 @ 11 NONAME R3UNUSED ; RClogger::GetTagStatesL(CDesC16Array *&, RBuf8 &)
+	HexDump__8RCloggerRC6TDesC8T1 @ 12 NONAME R3UNUSED ; RClogger::HexDump(TDesC8 const &, TDesC8 const &)
+	HexDump__8RCloggerUlRC6TDesC8T2 @ 13 NONAME ; RClogger::HexDump(unsigned long, TDesC8 const &, TDesC8 const &)
+	IsEnabled__8RCloggerRC7TDesC16 @ 14 NONAME R3UNUSED ; RClogger::IsEnabled(TDesC16 const &)
+	LogList__8RCloggerGt11TRefByValue1ZC6TDesC8PPSc @ 15 NONAME R3UNUSED ; RClogger::LogList(TRefByValue<TDesC8 const>, signed char **)
+	LogList__8RCloggerGt11TRefByValue1ZC7TDesC16PPSc @ 16 NONAME R3UNUSED ; RClogger::LogList(TRefByValue<TDesC16 const>, signed char **)
+	LogList__8RCloggerPCcPPSc @ 17 NONAME R3UNUSED ; RClogger::LogList(char const *, signed char **)
+	LogList__8RCloggerUlGt11TRefByValue1ZC6TDesC8PPSc @ 18 NONAME ; RClogger::LogList(unsigned long, TRefByValue<TDesC8 const>, signed char **)
+	LogList__8RCloggerUlGt11TRefByValue1ZC7TDesC16PPSc @ 19 NONAME ; RClogger::LogList(unsigned long, TRefByValue<TDesC16 const>, signed char **)
+	LogList__8RCloggerUlPCcPPSc @ 20 NONAME ; RClogger::LogList(unsigned long, char const *, signed char **)
+	Log__8RCloggerGt11TRefByValue1ZC6TDesC8e @ 21 NONAME ; RClogger::Log(TRefByValue<TDesC8 const>,...)
+	Log__8RCloggerGt11TRefByValue1ZC7TDesC16e @ 22 NONAME ; RClogger::Log(TRefByValue<TDesC16 const>,...)
+	Log__8RCloggerPCce @ 23 NONAME ; RClogger::Log(char const *,...)
+	Log__8RCloggerUlGt11TRefByValue1ZC6TDesC8e @ 24 NONAME ; RClogger::Log(unsigned long, TRefByValue<TDesC8 const>,...)
+	Log__8RCloggerUlGt11TRefByValue1ZC7TDesC16e @ 25 NONAME ; RClogger::Log(unsigned long, TRefByValue<TDesC16 const>,...)
+	Log__8RCloggerUlPCce @ 26 NONAME ; RClogger::Log(unsigned long, char const *,...)
+	PersistSettings__8RClogger @ 27 NONAME R3UNUSED ; RClogger::PersistSettings(void)
+	Reserved__8RCloggeriRPvPv @ 28 NONAME ; RClogger::Reserved(int, void *&, void *)
+	ResetSettings__8RClogger @ 29 NONAME R3UNUSED ; RClogger::ResetSettings(void)
+	Rotate__8RClogger @ 30 NONAME R3UNUSED ; RClogger::Rotate(void)
+	Rotate__8RCloggerR6TDes16 @ 31 NONAME R3UNUSED ; RClogger::Rotate(TDes16 &)
+	SetEnabled__8RCloggerRC7TDesC16Ul @ 32 NONAME R3UNUSED ; RClogger::SetEnabled(TDesC16 const &, unsigned long)
+	SetGlobalOptions__8RCloggerUi @ 33 NONAME R3UNUSED ; RClogger::SetGlobalOptions(unsigned int)
+	SetLogBehaviour__8RCloggerUi @ 34 NONAME R3UNUSED ; RClogger::SetLogBehaviour(unsigned int)
+	SetRamBufferSize__8RCloggerii @ 35 NONAME R3UNUSED ; RClogger::SetRamBufferSize(int, int)
+	SetRotateBehaviour__8RCloggeriUi @ 36 NONAME R3UNUSED ; RClogger::SetRotateBehaviour(int, unsigned int)
+	SetStaticLogBehaviour__8RCloggerUi @ 37 NONAME R3UNUSED ; RClogger::SetStaticLogBehaviour(unsigned int)
+	SetTagStatesL__8RCloggerPC12CDesC16ArrayRC6TDesC8 @ 38 NONAME R3UNUSED ; RClogger::SetTagStatesL(CDesC16Array const *, TDesC8 const &)
+	SlogList__8RCloggerGt11TRefByValue1ZC6TDesC8PPSc @ 39 NONAME R3UNUSED ; RClogger::SlogList(TRefByValue<TDesC8 const>, signed char **)
+	SlogList__8RCloggerGt11TRefByValue1ZC7TDesC16PPSc @ 40 NONAME R3UNUSED ; RClogger::SlogList(TRefByValue<TDesC16 const>, signed char **)
+	SlogList__8RCloggerPCcPPSc @ 41 NONAME R3UNUSED ; RClogger::SlogList(char const *, signed char **)
+	SlogList__8RCloggerUlGt11TRefByValue1ZC6TDesC8PPSc @ 42 NONAME R3UNUSED ; RClogger::SlogList(unsigned long, TRefByValue<TDesC8 const>, signed char **)
+	SlogList__8RCloggerUlGt11TRefByValue1ZC7TDesC16PPSc @ 43 NONAME R3UNUSED ; RClogger::SlogList(unsigned long, TRefByValue<TDesC16 const>, signed char **)
+	SlogList__8RCloggerUlPCcPPSc @ 44 NONAME R3UNUSED ; RClogger::SlogList(unsigned long, char const *, signed char **)
+	Slog__8RCloggerGt11TRefByValue1ZC6TDesC8e @ 45 NONAME ; RClogger::Slog(TRefByValue<TDesC8 const>,...)
+	Slog__8RCloggerGt11TRefByValue1ZC7TDesC16e @ 46 NONAME ; RClogger::Slog(TRefByValue<TDesC16 const>,...)
+	Slog__8RCloggerPCce @ 47 NONAME ; RClogger::Slog(char const *,...)
+	Slog__8RCloggerUlGt11TRefByValue1ZC6TDesC8e @ 48 NONAME ; RClogger::Slog(unsigned long, TRefByValue<TDesC8 const>,...)
+	Slog__8RCloggerUlGt11TRefByValue1ZC7TDesC16e @ 49 NONAME ; RClogger::Slog(unsigned long, TRefByValue<TDesC16 const>,...)
+	Slog__8RCloggerUlPCce @ 50 NONAME ; RClogger::Slog(unsigned long, char const *,...)
+	StaticClose__8RClogger @ 51 NONAME R3UNUSED ; RClogger::StaticClose(void)
+	StaticConnect__8RClogger @ 52 NONAME R3UNUSED ; RClogger::StaticConnect(void)
+	StaticConnect__8RCloggerRC7TDesC16 @ 53 NONAME R3UNUSED ; RClogger::StaticConnect(TDesC16 const &)
+	StaticHexDump__8RCloggerRC6TDesC8T1 @ 54 NONAME R3UNUSED ; RClogger::StaticHexDump(TDesC8 const &, TDesC8 const &)
+	StaticHexDump__8RCloggerUlRC6TDesC8T2 @ 55 NONAME R3UNUSED ; RClogger::StaticHexDump(unsigned long, TDesC8 const &, TDesC8 const &)
+	StaticReserved__8RCloggeriRPvPv @ 56 NONAME R3UNUSED ; RClogger::StaticReserved(int, void *&, void *)
+	__19RCloggerLogConsumer @ 57 NONAME R3UNUSED ; RCloggerLogConsumer::RCloggerLogConsumer(void)
+	__8RClogger @ 58 NONAME R3UNUSED ; RClogger::RClogger(void)
+	CancelGetNextLog__19RCloggerLogConsumer @ 59 NONAME R3UNUSED ; RCloggerLogConsumer::CancelGetNextLog(void)
+	Clogger_Slog @ 60 NONAME ; (null)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BMARM/debugrouter_nopatchdata.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	CreateLogicalDevice__Fv @ 1 NONAME R3UNUSED ; CreateLogicalDevice(void)
+	DebugPortChanged__18CloggerDebugRouterv @ 2 NONAME R3UNUSED ; CloggerDebugRouter::DebugPortChanged(void)
+	KChunkSize @ 3 NONAME ; (null)
+	KEnableEarlyRdebug @ 4 NONAME ; (null)
+	KIsrBufSize @ 5 NONAME ; (null)
+	SetCrashDumpFunctions__18CloggerDebugRouterPFPvUiRQ218CloggerDebugRouter14SCrashDumpArea_vPFRQ218CloggerDebugRouter14SCrashDumpArea_v @ 6 NONAME R3UNUSED ; CloggerDebugRouter::SetCrashDumpFunctions(void (*)(void *, unsigned int, CloggerDebugRouter::SCrashDumpArea &), void (*)(CloggerDebugRouter::SCrashDumpArea &))
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BMARM/floggerU.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+EXPORTS
+	__11RFileLogger @ 1 NONAME R3UNUSED ; RFileLogger::RFileLogger(void)
+	Connect__11RFileLogger @ 2 NONAME R3UNUSED ; RFileLogger::Connect(void)
+	CreateLog__11RFileLoggerRC7TDesC16T116TFileLoggingMode @ 3 NONAME ; RFileLogger::CreateLog(TDesC16 const &, TDesC16 const &, TFileLoggingMode)
+	HexDump__11RFileLoggerPCUsT1PCUci @ 4 NONAME ; RFileLogger::HexDump(unsigned short const *, unsigned short const *, unsigned char const *, int)
+	HexDump__11RFileLoggerRC7TDesC16T116TFileLoggingModePCUsT4PCUci @ 5 NONAME ; RFileLogger::HexDump(TDesC16 const &, TDesC16 const &, TFileLoggingMode, unsigned short const *, unsigned short const *, unsigned char const *, int)
+	LastError__C11RFileLogger @ 6 NONAME R3UNUSED ; RFileLogger::LastError(void) const
+	LogValid__C11RFileLogger @ 7 NONAME R3UNUSED ; RFileLogger::LogValid(void) const
+	Run__7FLoggerRQ27FLogger7TSignal @ 8 NONAME R3UNUSED ; FLogger::Run(FLogger::TSignal &)
+	SetDateAndTime__11RFileLoggerii @ 9 NONAME R3UNUSED ; RFileLogger::SetDateAndTime(int, int)
+	Version__C11RFileLogger @ 10 NONAME R3UNUSED ; RFileLogger::Version(void) const
+	WriteFormat__11RFileLoggerGt11TRefByValue1ZC6TDesC8RA0_PSc @ 11 NONAME R3UNUSED ; RFileLogger::WriteFormat(TRefByValue<TDesC8 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerGt11TRefByValue1ZC6TDesC8e @ 12 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC8 const>,...)
+	WriteFormat__11RFileLoggerGt11TRefByValue1ZC7TDesC16RA0_PSc @ 13 NONAME R3UNUSED ; RFileLogger::WriteFormat(TRefByValue<TDesC16 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerGt11TRefByValue1ZC7TDesC16e @ 14 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC16 const>,...)
+	WriteFormat__11RFileLoggerRC7TDesC16T116TFileLoggingModeGt11TRefByValue1ZC6TDesC8RA0_PSc @ 15 NONAME ; RFileLogger::WriteFormat(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TRefByValue<TDesC8 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerRC7TDesC16T116TFileLoggingModeGt11TRefByValue1ZC6TDesC8e @ 16 NONAME ; RFileLogger::WriteFormat(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TRefByValue<TDesC8 const>,...)
+	WriteFormat__11RFileLoggerRC7TDesC16T116TFileLoggingModeGt11TRefByValue1ZC7TDesC16RA0_PSc @ 17 NONAME ; RFileLogger::WriteFormat(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	WriteFormat__11RFileLoggerRC7TDesC16T116TFileLoggingModeGt11TRefByValue1ZC7TDesC16e @ 18 NONAME ; RFileLogger::WriteFormat(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TRefByValue<TDesC16 const>,...)
+	Write__11RFileLoggerRC6TDesC8 @ 19 NONAME R3UNUSED ; RFileLogger::Write(TDesC8 const &)
+	Write__11RFileLoggerRC7TDesC16 @ 20 NONAME R3UNUSED ; RFileLogger::Write(TDesC16 const &)
+	Write__11RFileLoggerRC7TDesC16T116TFileLoggingModeRC6TDesC8 @ 21 NONAME ; RFileLogger::Write(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TDesC8 const &)
+	Write__11RFileLoggerRC7TDesC16T116TFileLoggingModeT1 @ 22 NONAME ; RFileLogger::Write(TDesC16 const &, TDesC16 const &, TFileLoggingMode, TDesC16 const &)
+	"_._11RFileLogger" @ 23 NONAME R3UNUSED ; RFileLogger::~RFileLogger(void)
+	CloseLog__11RFileLogger @ 24 NONAME R3UNUSED ; RFileLogger::CloseLog(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BWINS/CDUU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+EXPORTS
+	??0RFileLogger@@QAE@XZ @ 1 NONAME ; public: __thiscall RFileLogger::RFileLogger(void)
+	??1RFileLogger@@QAE@XZ @ 2 NONAME ; public: __thiscall RFileLogger::~RFileLogger(void)
+	?CloseLog@RFileLogger@@QAEXXZ @ 3 NONAME ; public: void __thiscall RFileLogger::CloseLog(void)
+	?Connect@RFileLogger@@QAEHXZ @ 4 NONAME ; public: int __thiscall RFileLogger::Connect(void)
+	?CreateLog@RFileLogger@@QAEXABVTDesC16@@0W4TFileLoggingMode@@@Z @ 5 NONAME ; public: void __thiscall RFileLogger::CreateLog(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode)
+	?LastError@RFileLogger@@QBEHXZ @ 6 NONAME ; public: int __thiscall RFileLogger::LastError(void)const 
+	?LogValid@RFileLogger@@QBEHXZ @ 7 NONAME ; public: int __thiscall RFileLogger::LogValid(void)const 
+	?ClientRunStubOrdinal1@@YAXXZ @ 8 NONAME ; Stub for binary compability
+	?SetDateAndTime@RFileLogger@@QAEXHH@Z @ 9 NONAME ; public: void __thiscall RFileLogger::SetDateAndTime(int,int)
+	?Version@RFileLogger@@QBE?AVTVersion@@XZ @ 10 NONAME ; public: class TVersion  __thiscall RFileLogger::Version(void)const 
+	?Write@RFileLogger@@QAEXABVTDesC16@@@Z @ 11 NONAME ; public: void __thiscall RFileLogger::Write(class TDesC16 const &)
+	?Write@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@0@Z @ 12 NONAME ; public: static void __cdecl RFileLogger::Write(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TDesC16 const &)
+	?WriteFormat@RFileLogger@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 13 NONAME ; public: void __cdecl RFileLogger::WriteFormat(class TRefByValue<class TDesC16 const >,...)
+	?WriteFormat@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 14 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TRefByValue<class TDesC16 const >,...)
+	?WriteFormat@RFileLogger@@QAEXV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 15 NONAME ; public: void __thiscall RFileLogger::WriteFormat(class TRefByValue<class TDesC16 const >,signed char * (&)[1])
+	?WriteFormat@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@V?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 16 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TRefByValue<class TDesC16 const >,signed char * (&)[1])
+	?HexDump@RFileLogger@@QAEXPBG0PBEH@Z @ 17 NONAME ; public: void __thiscall RFileLogger::HexDump(unsigned short const *,unsigned short const *,unsigned char const *,int)
+	?HexDump@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@PBG2PBEH@Z @ 18 NONAME ; public: static void __cdecl RFileLogger::HexDump(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,unsigned short const *,unsigned short const *,unsigned char const *,int)
+	?Write@RFileLogger@@QAEXABVTDesC8@@@Z @ 19 NONAME ; public: void __thiscall RFileLogger::Write(class TDesC8 const &)
+	?Write@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@ABVTDesC8@@@Z @ 20 NONAME ; public: static void __cdecl RFileLogger::Write(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TDesC8 const &)
+	?WriteFormat@RFileLogger@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 21 NONAME ; public: void __cdecl RFileLogger::WriteFormat(class TRefByValue<class TDesC8 const >,...)
+	?WriteFormat@RFileLogger@@QAEXV?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 22 NONAME ; public: void __thiscall RFileLogger::WriteFormat(class TRefByValue<class TDesC8 const >,signed char * (&)[1])
+	?WriteFormat@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@V?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 23 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TRefByValue<class TDesC8 const >,signed char * (&)[1])
+	?WriteFormat@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@V?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 24 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TRefByValue<class TDesC8 const >,...)
+	?ClearLog@RFileLogger@@QAEHXZ @ 25 NONAME ; public: int __thiscall RFileLogger::ClearLog(void)
+	?Close@RFileLogger@@QAEXXZ @ 26 NONAME ; public: void __thiscall RFileLogger::Close(void)
+	?HexDump@RFileLogger@@QAEXABVTDesC8@@0@Z @ 27 NONAME ; public: void __thiscall RFileLogger::HexDump(class TDesC8 const &,class TDesC8 const &)
+	?HexDump@RFileLogger@@SAXABVTDesC8@@000@Z @ 28 NONAME ; public: static void __cdecl RFileLogger::HexDump(class TDesC8 const &,class TDesC8 const &,class TDesC8 const &,class TDesC8 const &)
+	?SetLogTags@RFileLogger@@QAEHABVTDesC8@@0@Z @ 29 NONAME ; public: int __thiscall RFileLogger::SetLogTags(class TDesC8 const &,class TDesC8 const &)
+	?Write@RFileLogger@@SAXABVTDesC8@@00@Z @ 30 NONAME ; public: static void __cdecl RFileLogger::Write(class TDesC8 const &,class TDesC8 const &,class TDesC8 const &)
+	?Write@RFileLogger@@SAXABVTDesC8@@0ABVTDesC16@@@Z @ 31 NONAME ; public: static void __cdecl RFileLogger::Write(class TDesC8 const &,class TDesC8 const &,class TDesC16 const &)
+	?WriteBinary@RFileLogger@@QAEXABVTDesC8@@@Z @ 32 NONAME ; public: void __thiscall RFileLogger::WriteBinary(class TDesC8 const &)
+	?WriteFormat@RFileLogger@@SAXABVTDesC8@@0V?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 33 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC8 const &,class TDesC8 const &,class TRefByValue<class TDesC16 const >,signed char * (&)[1])
+	?WriteFormat@RFileLogger@@SAXABVTDesC8@@0V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 34 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC8 const &,class TDesC8 const &,class TRefByValue<class TDesC16 const >,...)
+	?WriteFormat@RFileLogger@@SAXABVTDesC8@@0V?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 35 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC8 const &,class TDesC8 const &,class TRefByValue<class TDesC8 const >,signed char * (&)[1])
+	?WriteFormat@RFileLogger@@SAXABVTDesC8@@0V?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 36 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC8 const &,class TDesC8 const &,class TRefByValue<class TDesC8 const >,...)
+	?__DbgSetHeapFailure@RFileLogger@@QAEXH@Z @ 37 NONAME ; public: void __thiscall RFileLogger::__DbgSetHeapFailure(int)
+	?__DbgShutDownServer@RFileLogger@@QAEXXZ @ 38 NONAME ; public: void __thiscall RFileLogger::__DbgShutDownServer(void)
+	?Handle@RFileLogger@@QBEHXZ @ 39 NONAME ; public: int __thiscall RFileLogger::Handle(void)const
+	?Share@RFileLogger@@QAEHXZ @ 40 NONAME ; public: int __thiscall RFileLogger::Share(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BWINS/FLOGGERU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+EXPORTS
+	??0RFileLogger@@QAE@XZ @ 1 NONAME ; public: __thiscall RFileLogger::RFileLogger(void)
+	??1RFileLogger@@QAE@XZ @ 2 NONAME ; public: __thiscall RFileLogger::~RFileLogger(void)
+	?CloseLog@RFileLogger@@QAEXXZ @ 3 NONAME ; public: void __thiscall RFileLogger::CloseLog(void)
+	?Connect@RFileLogger@@QAEHXZ @ 4 NONAME ; public: int __thiscall RFileLogger::Connect(void)
+	?CreateLog@RFileLogger@@QAEXABVTDesC16@@0W4TFileLoggingMode@@@Z @ 5 NONAME ; public: void __thiscall RFileLogger::CreateLog(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode)
+	?LastError@RFileLogger@@QBEHXZ @ 6 NONAME ; public: int __thiscall RFileLogger::LastError(void)const 
+	?LogValid@RFileLogger@@QBEHXZ @ 7 NONAME ; public: int __thiscall RFileLogger::LogValid(void)const 
+	?Run@FLogger@@SAHAAVTSignal@1@@Z @ 8 NONAME ; public: static int __cdecl FLogger::Run(class FLogger::TSignal &)
+	?SetDateAndTime@RFileLogger@@QAEXHH@Z @ 9 NONAME ; public: void __thiscall RFileLogger::SetDateAndTime(int,int)
+	?Version@RFileLogger@@QBE?AVTVersion@@XZ @ 10 NONAME ; public: class TVersion  __thiscall RFileLogger::Version(void)const 
+	?Write@RFileLogger@@QAEXABVTDesC16@@@Z @ 11 NONAME ; public: void __thiscall RFileLogger::Write(class TDesC16 const &)
+	?Write@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@0@Z @ 12 NONAME ; public: static void __cdecl RFileLogger::Write(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TDesC16 const &)
+	?WriteFormat@RFileLogger@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 13 NONAME ; public: void __cdecl RFileLogger::WriteFormat(class TRefByValue<class TDesC16 const >,...)
+	?WriteFormat@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 14 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TRefByValue<class TDesC16 const >,...)
+	?WriteFormat@RFileLogger@@QAEXV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 15 NONAME ; public: void __thiscall RFileLogger::WriteFormat(class TRefByValue<class TDesC16 const >,signed char * (&)[1])
+	?WriteFormat@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@V?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 16 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TRefByValue<class TDesC16 const >,signed char * (&)[1])
+	?HexDump@RFileLogger@@QAEXPBG0PBEH@Z @ 17 NONAME ; public: void __thiscall RFileLogger::HexDump(unsigned short const *,unsigned short const *,unsigned char const *,int)
+	?HexDump@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@PBG2PBEH@Z @ 18 NONAME ; public: static void __cdecl RFileLogger::HexDump(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,unsigned short const *,unsigned short const *,unsigned char const *,int)
+	?Write@RFileLogger@@QAEXABVTDesC8@@@Z @ 19 NONAME ; public: void __thiscall RFileLogger::Write(class TDesC8 const &)
+	?Write@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@ABVTDesC8@@@Z @ 20 NONAME ; public: static void __cdecl RFileLogger::Write(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TDesC8 const &)
+	?WriteFormat@RFileLogger@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 21 NONAME ; public: void __cdecl RFileLogger::WriteFormat(class TRefByValue<class TDesC8 const >,...)
+	?WriteFormat@RFileLogger@@QAEXV?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 22 NONAME ; public: void __thiscall RFileLogger::WriteFormat(class TRefByValue<class TDesC8 const >,signed char * (&)[1])
+	?WriteFormat@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@V?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 23 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TRefByValue<class TDesC8 const >,signed char * (&)[1])
+	?WriteFormat@RFileLogger@@SAXABVTDesC16@@0W4TFileLoggingMode@@V?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 24 NONAME ; public: static void __cdecl RFileLogger::WriteFormat(class TDesC16 const &,class TDesC16 const &,enum TFileLoggingMode,class TRefByValue<class TDesC8 const >,...)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BWINS/cflogu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+EXPORTS
+	?Close@CCFLogIf@@SAXXZ @ 1 NONAME ; public: static void __cdecl CCFLogIf::Close(void)
+	?Connect@CCFLogIf@@SAXXZ @ 2 NONAME ; public: static void __cdecl CCFLogIf::Connect(void)
+	?Context@CCFLogIf@@SAPAV1@XZ @ 3 NONAME ; public: static class CCFLogIf * __cdecl CCFLogIf::Context(void)
+	?Delete@CCFLogIf@@SAHPAV1@@Z @ 4 NONAME ; public: static int __cdecl CCFLogIf::Delete(class CCFLogIf *)
+	?HexDump@CCFLogIf@@SAXABVTDesC8@@0PBG1PBEH@Z @ 5 NONAME ; public: static void __cdecl CCFLogIf::HexDump(class TDesC8 const &,class TDesC8 const &,unsigned short const *,unsigned short const *,unsigned char const *,int)
+	?NewL@CCFLogIf@@SAPAV1@XZ @ 6 NONAME ; public: static class CCFLogIf * __cdecl CCFLogIf::NewL(void)
+	?Panic@CCFLogIf@@SAXW4TCFLogPanic@@@Z @ 7 NONAME ; public: static void __cdecl CCFLogIf::Panic(enum TCFLogPanic)
+	?SetContext@CCFLogIf@@QAEXXZ @ 8 NONAME ; public: void __thiscall CCFLogIf::SetContext(void)
+	?Write@CCFLogIf@@SAXABVTDesC8@@00@Z @ 9 NONAME ; public: static void __cdecl CCFLogIf::Write(class TDesC8 const &,class TDesC8 const &,class TDesC8 const &)
+	?Write@CCFLogIf@@SAXABVTDesC8@@0ABVTDesC16@@@Z @ 10 NONAME ; public: static void __cdecl CCFLogIf::Write(class TDesC8 const &,class TDesC8 const &,class TDesC16 const &)
+	?WriteBinary@CCFLogIf@@SAXABVTDesC8@@00@Z @ 11 NONAME ; public: static void __cdecl CCFLogIf::WriteBinary(class TDesC8 const &,class TDesC8 const &,class TDesC8 const &)
+	?WriteFormat@CCFLogIf@@SAXABVTDesC8@@0V?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 12 NONAME ; public: static void __cdecl CCFLogIf::WriteFormat(class TDesC8 const &,class TDesC8 const &,class TRefByValue<class TDesC16 const >,signed char * (&)[1])
+	?WriteFormat@CCFLogIf@@SAXABVTDesC8@@0V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 13 NONAME ; public: static void __cdecl CCFLogIf::WriteFormat(class TDesC8 const &,class TDesC8 const &,class TRefByValue<class TDesC16 const >,...)
+	?WriteFormat@CCFLogIf@@SAXABVTDesC8@@0V?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 14 NONAME ; public: static void __cdecl CCFLogIf::WriteFormat(class TDesC8 const &,class TDesC8 const &,class TRefByValue<class TDesC8 const >,signed char * (&)[1])
+	?WriteFormat@CCFLogIf@@SAXABVTDesC8@@0V?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 15 NONAME ; public: static void __cdecl CCFLogIf::WriteFormat(class TDesC8 const &,class TDesC8 const &,class TRefByValue<class TDesC8 const >,...)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BWINS/cloggerU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+EXPORTS
+	??0RClogger@@QAE@XZ @ 1 NONAME ; RClogger::RClogger(void)
+	?Close@RClogger@@QAEXXZ @ 2 NONAME ; void RClogger::Close(void)
+	?Connect@RClogger@@QAEHABVTDesC16@@@Z @ 3 NONAME ; int RClogger::Connect(class TDesC16 const &)
+	?Connect@RClogger@@QAEHXZ @ 4 NONAME ; int RClogger::Connect(void)
+	?GetGlobalOptions@RClogger@@QAEIXZ @ 5 NONAME ; unsigned int RClogger::GetGlobalOptions(void)
+	?GetRamBufferSize@RClogger@@QAEHPAH@Z @ 6 NONAME ; int RClogger::GetRamBufferSize(int *)
+	?IsEnabled@RClogger@@QAEKABVTDesC16@@@Z @ 7 NONAME ; unsigned long RClogger::IsEnabled(class TDesC16 const &)
+	?Log@RClogger@@QAAXKPBDZZ @ 8 NONAME ; void RClogger::Log(unsigned long, char const *, ...)
+	?Log@RClogger@@QAAXKV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 9 NONAME ; void RClogger::Log(unsigned long, class TRefByValue<class TDesC16 const >, ...)
+	?Log@RClogger@@QAAXKV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 10 NONAME ; void RClogger::Log(unsigned long, class TRefByValue<class TDesC8 const >, ...)
+	?Log@RClogger@@QAAXPBDZZ @ 11 NONAME ; void RClogger::Log(char const *, ...)
+	?Log@RClogger@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 12 NONAME ; void RClogger::Log(class TRefByValue<class TDesC16 const >, ...)
+	?Log@RClogger@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 13 NONAME ; void RClogger::Log(class TRefByValue<class TDesC8 const >, ...)
+	?LogList@RClogger@@QAEXKPBDQAPAC@Z @ 14 NONAME ; void RClogger::LogList(unsigned long, char const *, signed char * * const)
+	?LogList@RClogger@@QAEXKV?$TRefByValue@$$CBVTDesC16@@@@QAPAC@Z @ 15 NONAME ; void RClogger::LogList(unsigned long, class TRefByValue<class TDesC16 const >, signed char * * const)
+	?LogList@RClogger@@QAEXKV?$TRefByValue@$$CBVTDesC8@@@@QAPAC@Z @ 16 NONAME ; void RClogger::LogList(unsigned long, class TRefByValue<class TDesC8 const >, signed char * * const)
+	?LogList@RClogger@@QAEXPBDQAPAC@Z @ 17 NONAME ; void RClogger::LogList(char const *, signed char * * const)
+	?LogList@RClogger@@QAEXV?$TRefByValue@$$CBVTDesC16@@@@QAPAC@Z @ 18 NONAME ; void RClogger::LogList(class TRefByValue<class TDesC16 const >, signed char * * const)
+	?LogList@RClogger@@QAEXV?$TRefByValue@$$CBVTDesC8@@@@QAPAC@Z @ 19 NONAME ; void RClogger::LogList(class TRefByValue<class TDesC8 const >, signed char * * const)
+	?PersistSettings@RClogger@@QAEXXZ @ 20 NONAME ; void RClogger::PersistSettings(void)
+	?ResetSettings@RClogger@@QAEXXZ @ 21 NONAME ; void RClogger::ResetSettings(void)
+	?Rotate@RClogger@@QAEHXZ @ 22 NONAME ; int RClogger::Rotate(void)
+	?SetEnabled@RClogger@@QAEHABVTDesC16@@K@Z @ 23 NONAME ; int RClogger::SetEnabled(class TDesC16 const &, unsigned long)
+	?SetGlobalOptions@RClogger@@QAEXI@Z @ 24 NONAME ; void RClogger::SetGlobalOptions(unsigned int)
+	?SetLogBehaviour@RClogger@@QAEXI@Z @ 25 NONAME ; void RClogger::SetLogBehaviour(unsigned int)
+	?SetRamBufferSize@RClogger@@QAEXHH@Z @ 26 NONAME ; void RClogger::SetRamBufferSize(int, int)
+	?SetRotateBehaviour@RClogger@@QAEXHI@Z @ 27 NONAME ; void RClogger::SetRotateBehaviour(int, unsigned int)
+	?SetStaticLogBehaviour@RClogger@@SAXI@Z @ 28 NONAME ; void RClogger::SetStaticLogBehaviour(unsigned int)
+	?Slog@RClogger@@SAXKPBDZZ @ 29 NONAME ; void RClogger::Slog(unsigned long, char const *, ...)
+	?Slog@RClogger@@SAXKV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 30 NONAME ; void RClogger::Slog(unsigned long, class TRefByValue<class TDesC16 const >, ...)
+	?Slog@RClogger@@SAXKV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 31 NONAME ; void RClogger::Slog(unsigned long, class TRefByValue<class TDesC8 const >, ...)
+	?Slog@RClogger@@SAXPBDZZ @ 32 NONAME ; void RClogger::Slog(char const *, ...)
+	?Slog@RClogger@@SAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 33 NONAME ; void RClogger::Slog(class TRefByValue<class TDesC16 const >, ...)
+	?Slog@RClogger@@SAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 34 NONAME ; void RClogger::Slog(class TRefByValue<class TDesC8 const >, ...)
+	?SlogList@RClogger@@SAXKPBDQAPAC@Z @ 35 NONAME ; void RClogger::SlogList(unsigned long, char const *, signed char * * const)
+	?SlogList@RClogger@@SAXKV?$TRefByValue@$$CBVTDesC16@@@@QAPAC@Z @ 36 NONAME ; void RClogger::SlogList(unsigned long, class TRefByValue<class TDesC16 const >, signed char * * const)
+	?SlogList@RClogger@@SAXKV?$TRefByValue@$$CBVTDesC8@@@@QAPAC@Z @ 37 NONAME ; void RClogger::SlogList(unsigned long, class TRefByValue<class TDesC8 const >, signed char * * const)
+	?SlogList@RClogger@@SAXPBDQAPAC@Z @ 38 NONAME ; void RClogger::SlogList(char const *, signed char * * const)
+	?SlogList@RClogger@@SAXV?$TRefByValue@$$CBVTDesC16@@@@QAPAC@Z @ 39 NONAME ; void RClogger::SlogList(class TRefByValue<class TDesC16 const >, signed char * * const)
+	?SlogList@RClogger@@SAXV?$TRefByValue@$$CBVTDesC8@@@@QAPAC@Z @ 40 NONAME ; void RClogger::SlogList(class TRefByValue<class TDesC8 const >, signed char * * const)
+	?StaticClose@RClogger@@SAXXZ @ 41 NONAME ; void RClogger::StaticClose(void)
+	?StaticConnect@RClogger@@SAHABVTDesC16@@@Z @ 42 NONAME ; int RClogger::StaticConnect(class TDesC16 const &)
+	?StaticConnect@RClogger@@SAHXZ @ 43 NONAME ; int RClogger::StaticConnect(void)
+	?GetTagStatesL@RClogger@@QAEXAAPAVCDesC16Array@@AAVRBuf8@@@Z @ 44 NONAME ; void RClogger::GetTagStatesL(class CDesC16Array * &, class RBuf8 &)
+	?SetTagStatesL@RClogger@@QAEXPBVCDesC16Array@@ABVTDesC8@@@Z @ 45 NONAME ; void RClogger::SetTagStatesL(class CDesC16Array const *, class TDesC8 const &)
+	?GetRotateBehaviour@RClogger@@QAEIPAH@Z @ 46 NONAME ; unsigned int RClogger::GetRotateBehaviour(int *)
+	?Reserved@RClogger@@QAEHHAAPAXPAX@Z @ 47 NONAME ; int RClogger::Reserved(int, void * &, void *)
+	?HexDump@RClogger@@QAEXABVTDesC8@@0@Z @ 48 NONAME ; void RClogger::HexDump(class TDesC8 const &, class TDesC8 const &)
+	?HexDump@RClogger@@QAEXKABVTDesC8@@0@Z @ 49 NONAME ; void RClogger::HexDump(unsigned long, class TDesC8 const &, class TDesC8 const &)
+	?StaticHexDump@RClogger@@SAXABVTDesC8@@0@Z @ 50 NONAME ; void RClogger::StaticHexDump(class TDesC8 const &, class TDesC8 const &)
+	?StaticHexDump@RClogger@@SAXKABVTDesC8@@0@Z @ 51 NONAME ; void RClogger::StaticHexDump(unsigned long, class TDesC8 const &, class TDesC8 const &)
+	?Rotate@RClogger@@QAEHAAVTDes16@@@Z @ 52 NONAME ; int RClogger::Rotate(class TDes16 &)
+	??0RClogger@@AAE@PAX@Z @ 53 NONAME ; RClogger::RClogger(void *)
+	?StaticReserved@RClogger@@SAHHAAPAXPAX@Z @ 54 NONAME ; int RClogger::StaticReserved(int, void * &, void *)
+	??0RCloggerLogConsumer@@QAE@XZ @ 55 NONAME ; RCloggerLogConsumer::RCloggerLogConsumer(void)
+	?CancelGetNextLog@RCloggerLogConsumer@@QAEXXZ @ 56 NONAME ; void RCloggerLogConsumer::CancelGetNextLog(void)
+	?Close@RCloggerLogConsumer@@QAEXXZ @ 57 NONAME ; void RCloggerLogConsumer::Close(void)
+	?Connect@RCloggerLogConsumer@@QAEHXZ @ 58 NONAME ; int RCloggerLogConsumer::Connect(void)
+	?GetNextLog@RCloggerLogConsumer@@QAEXAAVTRequestStatus@@AAVTPtrC8@@@Z @ 59 NONAME ; void RCloggerLogConsumer::GetNextLog(class TRequestStatus &, class TPtrC8 &)
+	Clogger_Slog @ 60 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BWINS/debugrouter.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	?CreateLogicalDevice@@YAPAVDLogicalDevice@@XZ @ 1 NONAME ; class DLogicalDevice * CreateLogicalDevice(void)
+	?KIsrBufSize@@3HB @ 2 NONAME ; int const KIsrBufSize
+	?KChunkSize@@3HB @ 3 NONAME ; int const KChunkSize
+	?DebugPortChanged@CloggerDebugRouter@@YAXXZ @ 4 NONAME ; void CloggerDebugRouter::DebugPortChanged(void)
+	?SetCrashDumpFunctions@CloggerDebugRouter@@YAXP6AXPAXIAAUSCrashDumpArea@1@@ZP6AX1@Z@Z @ 5 NONAME ; void CloggerDebugRouter::SetCrashDumpFunctions(void (*)(void *, unsigned int, struct CloggerDebugRouter::SCrashDumpArea &), void (*)(struct CloggerDebugRouter::SCrashDumpArea &))
+	?KEnableEarlyRdebug@@3HB @ 6 NONAME ; int const KEnableEarlyRdebug
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/BWINS/debugrouter_nopatchdata.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	?CreateLogicalDevice@@YAPAVDLogicalDevice@@XZ @ 1 NONAME ; class DLogicalDevice * CreateLogicalDevice(void)
+	?KIsrBufSize@@3HB @ 2 NONAME ; int const KIsrBufSize
+	?KChunkSize@@3HB @ 3 NONAME ; int const KChunkSize
+	?DebugPortChanged@CloggerDebugRouter@@YAXXZ @ 4 NONAME ; void CloggerDebugRouter::DebugPortChanged(void)
+	?SetCrashDumpFunctions@CloggerDebugRouter@@YAXP6AXPAXIAAUSCrashDumpArea@1@@ZP6AX1@Z@Z @ 5 NONAME ; void CloggerDebugRouter::SetCrashDumpFunctions(void (*)(void *, unsigned int, struct CloggerDebugRouter::SCrashDumpArea &), void (*)(struct CloggerDebugRouter::SCrashDumpArea &))
+	?KEnableEarlyRdebug@@3HB @ 6 NONAME ; int const KEnableEarlyRdebug
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/EABI/CDUU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,43 @@
+EXPORTS
+	_ZN11RFileLoggerC1Ev @ 1 NONAME ; RFileLogger::RFileLogger(void)
+	_ZN11RFileLogger7ConnectEv @ 2 NONAME ; RFileLogger::Connect(void)
+	_ZN11RFileLogger9CreateLogERK7TDesC16S2_16TFileLoggingMode @ 3 NONAME ; RFileLogger::CreateLog(TDesC16 const&, TDesC16 const&, TFileLoggingMode)
+	_ZNK11RFileLogger9LastErrorEv @ 4 NONAME ; RFileLogger::LastError(void) const
+	_ZNK11RFileLogger8LogValidEv @ 5 NONAME ; RFileLogger::LogValid(void) const
+	_ZN11RFileLoggerD1Ev @ 6 NONAME ;  RFileLogger::~RFileLogger [in-charge](void)
+	_ZN11RFileLogger14SetDateAndTimeEii @ 7 NONAME ; RFileLogger::SetDateAndTime(int, int)
+	_ZNK11RFileLogger7VersionEv @ 8 NONAME ; RFileLogger::Version(void) const
+	_ZN11RFileLogger11WriteFormatE11TRefByValueIK7TDesC16Ez @ 9 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC16 const>, ...)
+	_ZN11RFileLogger11WriteFormatERK7TDesC16S2_16TFileLoggingMode11TRefByValueIS1_Ez @ 10 NONAME ; RFileLogger::WriteFormat(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TRefByValue<TDesC16 const>, ...)
+	_ZN11RFileLogger5WriteERK7TDesC16 @ 11 NONAME ; RFileLogger::Write(TDesC16 const&)
+	_ZN11RFileLogger5WriteERK7TDesC16S2_16TFileLoggingModeS2_ @ 12 NONAME ; RFileLogger::Write(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TDesC16 const&)
+	_ZN11RFileLoggerC2Ev @ 13 NONAME ;  RFileLogger::RFileLogger[not-in-charge](void)
+	_ZN11RFileLogger8CloseLogEv @ 14 NONAME ; RFileLogger::CloseLog(void)
+	_ZN11RFileLogger11WriteFormatE11TRefByValueIK6TDesC8ERSt9__va_list @ 15 NONAME ;  RFileLogger::WriteFormat(TRefByValue<TDesC8 const>, signed char*(&)[0])
+	_ZN11RFileLogger11WriteFormatERK7TDesC16S2_16TFileLoggingMode11TRefByValueIK6TDesC8ERSt9__va_list @ 16 NONAME ;  RFileLogger::WriteFormat(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TRefByValue<TDesC8 const>, signed char*(&)[0])
+	_ZN11RFileLogger7HexDumpEPKtS1_PKhi @ 17 NONAME ; RFileLogger::HexDump(unsigned short const*, unsigned short const*, unsigned char const*, int)
+	_ZN11RFileLogger7HexDumpERK7TDesC16S2_16TFileLoggingModePKtS5_PKhi @ 18 NONAME ; RFileLogger::HexDump(TDesC16 const&, TDesC16 const&, TFileLoggingMode, unsigned short const*, unsigned short const*, unsigned char const*, int)
+	_ZN11RFileLogger11WriteFormatE11TRefByValueIK7TDesC16ERSt9__va_list @ 19 NONAME ;  RFileLogger::WriteFormat(TRefByValue<TDesC16 const>, signed char*(&)[0])
+	_ZN11RFileLogger11WriteFormatE11TRefByValueIK6TDesC8Ez @ 20 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC8 const>, ...)
+	_ZN11RFileLogger11WriteFormatERK7TDesC16S2_16TFileLoggingMode11TRefByValueIS1_ERSt9__va_list @ 21 NONAME ;  RFileLogger::WriteFormat(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TRefByValue<TDesC16 const>, signed char*(&)[0])
+	_ZN11RFileLogger11WriteFormatERK7TDesC16S2_16TFileLoggingMode11TRefByValueIK6TDesC8Ez @ 22 NONAME ; RFileLogger::WriteFormat(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TRefByValue<TDesC8 const>, ...)
+	_ZN11RFileLogger5WriteERK6TDesC8 @ 23 NONAME ; RFileLogger::Write(TDesC8 const&)
+	_ZN11RFileLogger5WriteERK7TDesC16S2_16TFileLoggingModeRK6TDesC8 @ 24 NONAME ; RFileLogger::Write(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TDesC8 const&)
+	_ZN11RFileLogger19__DbgShutDownServerEv @ 25 NONAME ; RFileLogger::__DbgShutDownServer(void)
+	_ZN11RFileLogger5CloseEv @ 26 NONAME ; RFileLogger::Close(void)
+	_ZN11RFileLogger7HexDumpERK6TDesC8S2_S2_S2_ @ 27 NONAME ; RFileLogger::HexDump(TDesC8 const&, TDesC8 const&, TDesC8 const&, TDesC8 const&)
+	_ZN11RFileLogger7HexDumpERK6TDesC8S2_ @ 28 NONAME ; RFileLogger::HexDump(TDesC8 const&, TDesC8 const&)
+	_ZN11RFileLogger10SetLogTagsERK6TDesC8S2_ @ 29 NONAME ; RFileLogger::SetLogTags(TDesC8 const&, TDesC8 const&)
+	_ZN11RFileLogger11WriteBinaryERK6TDesC8 @ 30 NONAME ; RFileLogger::WriteBinary(TDesC8 const&)
+	_ZN11RFileLogger11WriteFormatERK6TDesC8S2_11TRefByValueIS1_ERSt9__va_list @ 31 NONAME ;  RFileLogger::WriteFormat(TDesC8 const&, TDesC8 const&, TRefByValue<TDesC8 const>, signed char*(&)[0])
+	_ZN11RFileLogger11WriteFormatERK6TDesC8S2_11TRefByValueIS1_Ez @ 32 NONAME ; RFileLogger::WriteFormat(TDesC8 const&, TDesC8 const&, TRefByValue<TDesC8 const>, ...)
+	_ZN11RFileLogger11WriteFormatERK6TDesC8S2_11TRefByValueIK7TDesC16ERSt9__va_list @ 33 NONAME ;  RFileLogger::WriteFormat(TDesC8 const&, TDesC8 const&, TRefByValue<TDesC16 const>, signed char*(&)[0])
+	_ZN11RFileLogger11WriteFormatERK6TDesC8S2_11TRefByValueIK7TDesC16Ez @ 34 NONAME ; RFileLogger::WriteFormat(TDesC8 const&, TDesC8 const&, TRefByValue<TDesC16 const>, ...)
+	_ZN11RFileLogger5WriteERK6TDesC8S2_S2_ @ 35 NONAME ; RFileLogger::Write(TDesC8 const&, TDesC8 const&, TDesC8 const&)
+	_ZN11RFileLogger5WriteERK6TDesC8S2_RK7TDesC16 @ 36 NONAME ; RFileLogger::Write(TDesC8 const&, TDesC8 const&, TDesC16 const&)
+	_ZN11RFileLogger19__DbgSetHeapFailureEi @ 37 NONAME ; RFileLogger::__DbgSetHeapFailure(int)
+	_ZN11RFileLogger8ClearLogEv @ 38 NONAME ; RFileLogger::ClearLog(void)
+	_ZNK11RFileLogger6HandleEv @ 39 NONAME ; RFileLogger::Handle(void) const
+	_ZN11RFileLogger5ShareEv @ 40 NONAME ; RFileLogger::Share(void)
+	_Z21ClientRunStubOrdinal1v @ 41 NONAME ;  ClientRunStubOrdinal1(void)
+	_ZN11RFileLoggerD2Ev @ 42 NONAME ;  RFileLogger::~RFileLogger [not-in-charge](void)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/EABI/FLOGGERU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+EXPORTS
+	_ZN11RFileLoggerC1Ev @ 1 NONAME ; RFileLogger::RFileLogger(void)
+	_ZN11RFileLogger7ConnectEv @ 2 NONAME ; RFileLogger::Connect(void)
+	_ZN11RFileLogger9CreateLogERK7TDesC16S2_16TFileLoggingMode @ 3 NONAME ; RFileLogger::CreateLog(TDesC16 const&, TDesC16 const&, TFileLoggingMode)
+	_ZNK11RFileLogger9LastErrorEv @ 4 NONAME ; RFileLogger::LastError(void) const
+	_ZNK11RFileLogger8LogValidEv @ 5 NONAME ; RFileLogger::LogValid(void) const
+	_ZN7FLogger3RunERNS_7TSignalE @ 6 NONAME ; FLogger::Run(FLogger::TSignal&)
+	_ZN11RFileLogger14SetDateAndTimeEii @ 7 NONAME ; RFileLogger::SetDateAndTime(int, int)
+	_ZNK11RFileLogger7VersionEv @ 8 NONAME ; RFileLogger::Version(void) const
+	_ZN11RFileLogger11WriteFormatE11TRefByValueIK7TDesC16Ez @ 9 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC16 const>, ...)
+	_ZN11RFileLogger11WriteFormatERK7TDesC16S2_16TFileLoggingMode11TRefByValueIS1_Ez @ 10 NONAME ; RFileLogger::WriteFormat(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TRefByValue<TDesC16 const>, ...)
+	_ZN11RFileLogger5WriteERK7TDesC16 @ 11 NONAME ; RFileLogger::Write(TDesC16 const&)
+	_ZN11RFileLogger5WriteERK7TDesC16S2_16TFileLoggingModeS2_ @ 12 NONAME ; RFileLogger::Write(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TDesC16 const&)
+	_ZN11RFileLoggerD1Ev @ 13 NONAME ; RFileLogger::~RFileLogger(void)
+	_ZN11RFileLogger8CloseLogEv @ 14 NONAME ; RFileLogger::CloseLog(void)
+	_ZN11RFileLogger11WriteFormatE11TRefByValueIK6TDesC8ERSt9__va_list @ 15 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC8 const>, signed char*(&)[0])
+	_ZN11RFileLogger11WriteFormatERK7TDesC16S2_16TFileLoggingMode11TRefByValueIK6TDesC8ERSt9__va_list @ 16 NONAME ; RFileLogger::WriteFormat(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TRefByValue<TDesC8 const>, signed char*(&)[0])
+	_ZN11RFileLogger7HexDumpEPKtS1_PKhi @ 17 NONAME ; RFileLogger::HexDump(unsigned short const*, unsigned short const*, unsigned char const*, int)
+	_ZN11RFileLogger7HexDumpERK7TDesC16S2_16TFileLoggingModePKtS5_PKhi @ 18 NONAME ; RFileLogger::HexDump(TDesC16 const&, TDesC16 const&, TFileLoggingMode, unsigned short const*, unsigned short const*, unsigned char const*, int)
+	_ZN11RFileLogger11WriteFormatE11TRefByValueIK7TDesC16ERSt9__va_list @ 19 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC16 const>, signed char*(&)[0])
+	_ZN11RFileLogger11WriteFormatE11TRefByValueIK6TDesC8Ez @ 20 NONAME ; RFileLogger::WriteFormat(TRefByValue<TDesC8 const>, ...)
+	_ZN11RFileLogger11WriteFormatERK7TDesC16S2_16TFileLoggingMode11TRefByValueIS1_ERSt9__va_list @ 21 NONAME ; RFileLogger::WriteFormat(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TRefByValue<TDesC16 const>, signed char*(&)[0])
+	_ZN11RFileLogger11WriteFormatERK7TDesC16S2_16TFileLoggingMode11TRefByValueIK6TDesC8Ez @ 22 NONAME ; RFileLogger::WriteFormat(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TRefByValue<TDesC8 const>, ...)
+	_ZN11RFileLogger5WriteERK6TDesC8 @ 23 NONAME ; RFileLogger::Write(TDesC8 const&)
+	_ZN11RFileLogger5WriteERK7TDesC16S2_16TFileLoggingModeRK6TDesC8 @ 24 NONAME ; RFileLogger::Write(TDesC16 const&, TDesC16 const&, TFileLoggingMode, TDesC8 const&)
+	_ZN11RFileLoggerD2Ev @ 25 NONAME ; RFileLogger::~RFileLogger [not-in-charge](void)	
+	_ZN11RFileLoggerC2Ev @ 26 NONAME ; RFileLogger::RFileLogger[not-in-charge](void)
+	
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/EABI/cflogU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+EXPORTS
+	_ZN8CCFLogIf5WriteERK6TDesC8S2_RK7TDesC16 @ 1 NONAME ; CCFLogIf::Write(TDesC8 const&, TDesC8 const&, TDesC16 const&)
+	_ZN8CCFLogIf7ConnectEv @ 2 NONAME ; CCFLogIf::Connect(void)
+	_ZN8CCFLogIf7ContextEv @ 3 NONAME ; CCFLogIf::Context(void)
+	_ZN8CCFLogIf6DeleteEPS_ @ 4 NONAME ; CCFLogIf::Delete(CCFLogIf*)
+	_ZN8CCFLogIf7HexDumpERK6TDesC8S2_PKtS4_PKhi @ 5 NONAME ; CCFLogIf::HexDump(TDesC8 const&, TDesC8 const&, unsigned short const*, unsigned short const*, unsigned char const*, int)
+	_ZN8CCFLogIf4NewLEv @ 6 NONAME ; CCFLogIf::NewL(void)
+	_ZN8CCFLogIf5PanicE11TCFLogPanic @ 7 NONAME ; CCFLogIf::Panic(TCFLogPanic)
+	_ZN8CCFLogIf10SetContextEv @ 8 NONAME ; CCFLogIf::SetContext(void)
+	_ZN8CCFLogIf11WriteBinaryERK6TDesC8S2_S2_ @ 9 NONAME ; CCFLogIf::WriteBinary(TDesC8 const&, TDesC8 const&, TDesC8 const&)
+	_ZN8CCFLogIf11WriteFormatERK6TDesC8S2_11TRefByValueIS1_ERSt9__va_list @ 10 NONAME ;  CCFLogIf::WriteFormat(TDesC8 const&, TDesC8 const&, TRefByValue<TDesC8 const>, signed char*(&)[0])
+	_ZN8CCFLogIf11WriteFormatERK6TDesC8S2_11TRefByValueIS1_Ez @ 11 NONAME ; CCFLogIf::WriteFormat(TDesC8 const&, TDesC8 const&, TRefByValue<TDesC8 const>, ...)
+	_ZN8CCFLogIf11WriteFormatERK6TDesC8S2_11TRefByValueIK7TDesC16ERSt9__va_list @ 12 NONAME ;  CCFLogIf::WriteFormat(TDesC8 const&, TDesC8 const&, TRefByValue<TDesC16 const>, signed char*(&)[0])
+	_ZN8CCFLogIf11WriteFormatERK6TDesC8S2_11TRefByValueIK7TDesC16Ez @ 13 NONAME ; CCFLogIf::WriteFormat(TDesC8 const&, TDesC8 const&, TRefByValue<TDesC16 const>, ...)
+	_ZN8CCFLogIf5WriteERK6TDesC8S2_S2_ @ 14 NONAME ; CCFLogIf::Write(TDesC8 const&, TDesC8 const&, TDesC8 const&)
+	_ZN8CCFLogIf5CloseEv @ 15 NONAME ; CCFLogIf::Close(void)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/EABI/cloggerU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,65 @@
+EXPORTS
+	_ZN8RClogger10SetEnabledERK7TDesC16m @ 1 NONAME
+	_ZN8RClogger11StaticCloseEv @ 2 NONAME
+	_ZN8RClogger13ResetSettingsEv @ 3 NONAME
+	_ZN8RClogger13StaticConnectERK7TDesC16 @ 4 NONAME
+	_ZN8RClogger13StaticConnectEv @ 5 NONAME
+	_ZN8RClogger15PersistSettingsEv @ 6 NONAME
+	_ZN8RClogger15SetLogBehaviourEj @ 7 NONAME
+	_ZN8RClogger16GetGlobalOptionsEv @ 8 NONAME
+	_ZN8RClogger16GetRamBufferSizeEPi @ 9 NONAME
+	_ZN8RClogger16SetGlobalOptionsEj @ 10 NONAME
+	_ZN8RClogger16SetRamBufferSizeEii @ 11 NONAME
+	_ZN8RClogger18SetRotateBehaviourEij @ 12 NONAME
+	_ZN8RClogger21SetStaticLogBehaviourEj @ 13 NONAME
+	_ZN8RClogger3LogE11TRefByValueIK6TDesC8Ez @ 14 NONAME
+	_ZN8RClogger3LogE11TRefByValueIK7TDesC16Ez @ 15 NONAME
+	_ZN8RClogger3LogEPKcz @ 16 NONAME
+	_ZN8RClogger3LogEm11TRefByValueIK6TDesC8Ez @ 17 NONAME
+	_ZN8RClogger3LogEm11TRefByValueIK7TDesC16Ez @ 18 NONAME
+	_ZN8RClogger3LogEmPKcz @ 19 NONAME
+	_ZN8RClogger4SlogE11TRefByValueIK6TDesC8Ez @ 20 NONAME
+	_ZN8RClogger4SlogE11TRefByValueIK7TDesC16Ez @ 21 NONAME
+	_ZN8RClogger4SlogEPKcz @ 22 NONAME
+	_ZN8RClogger4SlogEm11TRefByValueIK6TDesC8Ez @ 23 NONAME
+	_ZN8RClogger4SlogEm11TRefByValueIK7TDesC16Ez @ 24 NONAME
+	_ZN8RClogger4SlogEmPKcz @ 25 NONAME
+	_ZN8RClogger5CloseEv @ 26 NONAME
+	_ZN8RClogger6RotateEv @ 27 NONAME
+	_ZN8RClogger7ConnectERK7TDesC16 @ 28 NONAME
+	_ZN8RClogger7ConnectEv @ 29 NONAME
+	_ZN8RClogger7LogListE11TRefByValueIK6TDesC8ESt9__va_list @ 30 NONAME
+	_ZN8RClogger7LogListE11TRefByValueIK7TDesC16ESt9__va_list @ 31 NONAME
+	_ZN8RClogger7LogListEPKcSt9__va_list @ 32 NONAME
+	_ZN8RClogger7LogListEm11TRefByValueIK6TDesC8ESt9__va_list @ 33 NONAME
+	_ZN8RClogger7LogListEm11TRefByValueIK7TDesC16ESt9__va_list @ 34 NONAME
+	_ZN8RClogger7LogListEmPKcSt9__va_list @ 35 NONAME
+	_ZN8RClogger8SlogListE11TRefByValueIK6TDesC8ESt9__va_list @ 36 NONAME
+	_ZN8RClogger8SlogListE11TRefByValueIK7TDesC16ESt9__va_list @ 37 NONAME
+	_ZN8RClogger8SlogListEPKcSt9__va_list @ 38 NONAME
+	_ZN8RClogger8SlogListEm11TRefByValueIK6TDesC8ESt9__va_list @ 39 NONAME
+	_ZN8RClogger8SlogListEm11TRefByValueIK7TDesC16ESt9__va_list @ 40 NONAME
+	_ZN8RClogger8SlogListEmPKcSt9__va_list @ 41 NONAME
+	_ZN8RClogger9IsEnabledERK7TDesC16 @ 42 NONAME
+	_ZN8RCloggerC1Ev @ 43 NONAME
+	_ZN8RCloggerC2Ev @ 44 NONAME
+	_ZN8RClogger13GetTagStatesLERP12CDesC16ArrayR5RBuf8 @ 45 NONAME
+	_ZN8RClogger13SetTagStatesLEPK12CDesC16ArrayRK6TDesC8 @ 46 NONAME
+	_ZN8RClogger18GetRotateBehaviourEPi @ 47 NONAME
+	_ZN8RClogger8ReservedEiRPvS0_ @ 48 NONAME
+	_ZN8RClogger13StaticHexDumpERK6TDesC8S2_ @ 49 NONAME
+	_ZN8RClogger13StaticHexDumpEmRK6TDesC8S2_ @ 50 NONAME
+	_ZN8RClogger7HexDumpERK6TDesC8S2_ @ 51 NONAME
+	_ZN8RClogger7HexDumpEmRK6TDesC8S2_ @ 52 NONAME
+	_ZN8RClogger6RotateER6TDes16 @ 53 NONAME
+	_ZN8RClogger14StaticReservedEiRPvS0_ @ 54 NONAME
+	_ZN8RCloggerC1EPv @ 55 NONAME
+	_ZN8RCloggerC2EPv @ 56 NONAME
+	_ZN19RCloggerLogConsumer10GetNextLogER14TRequestStatusR6TPtrC8 @ 57 NONAME
+	_ZN19RCloggerLogConsumer16CancelGetNextLogEv @ 58 NONAME
+	_ZN19RCloggerLogConsumer5CloseEv @ 59 NONAME
+	_ZN19RCloggerLogConsumer7ConnectEv @ 60 NONAME
+	_ZN19RCloggerLogConsumerC1Ev @ 61 NONAME
+	_ZN19RCloggerLogConsumerC2Ev @ 62 NONAME
+	Clogger_Slog @ 63 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/EABI/debugrouter.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	_Z19CreateLogicalDevicev @ 1 NONAME
+	KIsrBufSize @ 2 NONAME
+	KChunkSize @ 3 NONAME
+	_ZN18CloggerDebugRouter16DebugPortChangedEv @ 4 NONAME
+	_ZN18CloggerDebugRouter21SetCrashDumpFunctionsEPFvPvjRNS_14SCrashDumpAreaEEPFvS2_E @ 5 NONAME
+	KEnableEarlyRdebug @ 6 NONAME DATA 4
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/EABI/debugrouter_nopatchdata.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	_Z19CreateLogicalDevicev @ 1 NONAME
+	KIsrBufSize @ 2 NONAME
+	KChunkSize @ 3 NONAME
+	_ZN18CloggerDebugRouter16DebugPortChangedEv @ 4 NONAME
+	_ZN18CloggerDebugRouter21SetCrashDumpFunctionsEPFvPvjRNS_14SCrashDumpAreaEEPFvS2_E @ 5 NONAME
+	KEnableEarlyRdebug @ 6 ABSENT
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/debugRouter/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+// bld.inf
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+#ifdef FSHELL_CLOGGER_SUPPORT_DEBUG_ROUTER
+
+prj_exports
+debugRouter-kext.h	\epoc32\include\fshell\debugRouter-kext.h
+
+prj_mmpfiles
+debugRouter.mmp
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/debugRouter/debugRouter-kext.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+// debugRouter-kext.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <u32std.h>
+
+namespace CloggerDebugRouter
+	{
+	const TInt KCloggerDebugPort = 67;
+	
+	NONSHARABLE_STRUCT(SCrashDumpArea)
+		{
+		DChunk* iChunk;
+		TBuf8<32> iName;
+		TUint32 iReserved[6]; // For use by variant-specific functions
+		};
+
+	/* Implementations of these functions should expect to be called in a thread context with the kernel unlocked
+	 */
+	typedef void (*TRegisterFn)(TAny* /*aAddr*/, TUint /*aSize*/, SCrashDumpArea& /*aCrashDumpArea*/);
+	typedef void (*TUnregisterFn)(SCrashDumpArea& /*aCrashDumpArea*/);
+
+	IMPORT_C void DebugPortChanged();
+	
+	/* If you're going to be calling this, the debug router has to be loaded as a kernel extension.
+	 * Call the function after the kext has loaded, and preferably before the user-side cloggerserver has started.
+	 * Kernel must be unlocked, no fast mutexes or system lock held, and in a thread context.
+	 * 
+	 * The functions you pass in must be prepared to get called before this function has returned.
+	 */
+	IMPORT_C void SetCrashDumpFunctions(TRegisterFn aRegisterFn, TUnregisterFn aUnregisterFn);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/debugRouter/debugRouter.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1151 @@
+// debugRouter.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <nkern.h>
+#include <kernel.h>
+#include <kern_priv.h>
+#include <fshell/common.mmh>
+
+#include <e32cmn.h>
+#include "debugRouter.h"
+#include <platform.h>
+
+#include "dobject_compat.h"
+#include "debugRouter-kext.h"
+using namespace CloggerDebugRouter;
+
+//define this to get log output
+//#define DO_LOGGING
+
+#ifdef DO_LOGGING
+#	define LOG Kern::Printf
+#else
+#	ifdef __WINS__
+		inline void LOG(...) {}
+#	else
+#		define LOG(args...)
+#	endif
+#endif
+
+#undef ASSERT
+#define ASSERT __NK_ASSERT_DEBUG
+
+EXPORT_C extern const TInt KChunkSize; // See patchables.cpp
+EXPORT_C extern const TInt KIsrBufSize; // Likewise
+EXPORT_C extern const TBool KEnableEarlyRdebug; // Likewise
+
+////////////////////////////////////////////////
+
+
+const TInt KMajorVersionNumber=1;
+const TInt KMinorVersionNumber=0;
+const TInt KBuildVersionNumber=0;
+_LIT(KPanicCategory,"CloggerRouter");
+const TUid KCloggerUid = { FSHELL_UID_CLOGGERSERVER };
+
+class DCloggerDebugRouter;
+class DCloggerDebugRouterLDD;
+DCloggerDebugRouter* gRouter = NULL;
+
+// DCloggerDebugRouterFactory
+//
+NONSHARABLE_CLASS(DCloggerDebugRouterFactory) : public DLogicalDevice
+    {
+public:
+    DCloggerDebugRouterFactory();
+private:
+    TInt Install();                     //overriding pure virtual
+    void GetCaps(TDes8& aDes) const;    //overriding pure virtual
+    TInt Create(DLogicalChannelBase*& aChannel);         //overriding pure virtual
+    
+private:
+	DOBJECT_PADDING;
+    };
+    
+const TInt KMaxCrashDumpAreas = 8;
+
+NONSHARABLE_CLASS(DCloggerDebugRouter) : public DBase
+	{
+public:
+	DCloggerDebugRouter();
+	~DCloggerDebugRouter();
+
+	static TInt Init();
+	static TBool TraceHook(const TDesC8& aText, TTraceSource aTraceSource);
+	void SetCrashDumpFunctions(TRegisterFn aRegisterFn, TUnregisterFn aUnregisterFn);
+	
+	// Functions for the LDD
+	TInt OpenChunk();
+	void CloseChunk();
+	TInt RegisterCrashDumpAreas(const TDesC8& aAreas); // Kernel must be unlocked & system lock not held
+	TDfcQue& PrivateDfcQ();
+	void SetConsumeLogs(TBool aConsume);
+	void SetEnabled(TBool aEnabled);
+	void ClientRequestData(TRequestStatus* aStatus);
+
+	// DFC callback functions
+	static void HandleInterrupt(TAny* aSelf);
+	static void KillThreadDFC(TAny* aSelf);
+	static void CompleteClient(TAny* aSelf);
+
+	static TBool StayEnabled();
+private:
+	TBool DoTraceHook(const TDesC8& aText, TTraceSource aTraceSource);
+	TBool WriteOut(const TDesC8& aBuf, TInt aLengthToConsider = 0);
+	void DoTrace(const TDesC8& aText, TTraceSource aTraceSource, TUint aTraceThread);
+	void DoCompleteClient();
+	void NotifyClient();
+	TInt Construct();
+	void CheckInterruptBuffer();
+
+private:
+	DChunk* iChunk;
+	TLinAddr iStartAddr;
+	TLinAddr iEndAddr;
+	TLinAddr iCurrent;
+	TLinAddr iFirstFrame; // This isn't necessarily the same as iStartAddr, because if we wrap the first thing in the buffer will be continuation and not a header
+	TTraceSource iTempBufTraceSource;
+
+	TDfcQue iPrivateDfcQ;
+	TDfc iHandleInterruptDfc;
+	TDfc iCompleteClientDfc;
+	HBuf8* iInterruptBuf;
+	//TBuf8<2048> iTempBuf; // This is used to get the data from the unknown context of the trace handler to the DFC
+	// Using iTempBuf means we can minimise the amount of time we have to run with interrupts off, while at the same
+	// time allowing logging from ISRs and suchlike.
+#ifdef __SMP__
+	TSpinLock iInterruptBufLock;
+	TSpinLock iBufferLock;
+#endif
+	TBool iConsumeLogs;
+	TUint iOverflows;
+	TBool iInTheMiddleOfTracing;
+	TBool iClientIsBeingNotified;
+
+	TInt iNumCrashDumpAreas;
+	SCrashDumpArea iCrashDumpAreas[KMaxCrashDumpAreas];
+	TRegisterFn iRegisterCrashDumpFn;
+	TUnregisterFn iUnregisterCrashDumpFn;
+	
+public: // Accessible by LDD class
+	DThread* iClient;
+	TLinAddr iClientStart;
+	TLinAddr iClientEnd;
+	TRequestStatus* iClientStatus;
+	TBuf8<sizeof(SCloggerCrashDumpArea) * 8> iClientCrashDumpBuf; // For temporary use
+	};
+
+// Functions for testing purposes
+void DummyRegisterCrashDump(TAny* aAddr, TUint aSize, SCrashDumpArea& aCrashDumpArea)
+	{
+	LOG("Registering crashdump 0x%x %d %S", aAddr, aSize, &aCrashDumpArea.iName);
+	LOG("First and last words are %x %x", ((TUint*)aAddr)[0], ((TUint*)aAddr)[(aSize/4)-1]);
+	}
+void DummyUnregisterCrashDump(SCrashDumpArea& aCrashDumpArea)
+	{
+	LOG("Unregistering crashdump %S", &aCrashDumpArea.iName);
+	}
+	
+// DECLARE_STANDARD_LDD
+//  Standard Extension Framework export
+DECLARE_STANDARD_EXTENSION()
+	{
+	//__BREAKPOINT();
+	TInt err = DCloggerDebugRouter::Init();
+#ifdef __WINS__
+	// On WINS there's no way of setting the debug port to indicate we should enable ourselves.
+	// Therefore we assume that if someone's gone to the trouble of adding "extension += clogger-debugrouter.ldd" to
+	// their epoc.ini, then they want us to be enabled.
+	if (!err)
+		{
+		err = gRouter->OpenChunk();
+		}
+	if (!err)
+		{
+		gRouter->SetConsumeLogs(ETrue);
+		gRouter->SetEnabled(ETrue);
+		}
+#endif
+
+	return err;
+	}
+
+DECLARE_EXTENSION_LDD()
+	{
+	//__BREAKPOINT();
+	TBool ok = CalculateDObjectSize();
+	if (!ok) return NULL;
+	return new DCloggerDebugRouterFactory();
+	}
+
+// DCloggerDebugRouter
+//
+NONSHARABLE_CLASS(DCloggerDebugRouterLDD) : public DLogicalChannel
+    {
+public:
+	DCloggerDebugRouterLDD(DCloggerDebugRouter* aRouter);
+	~DCloggerDebugRouterLDD();
+private:
+//Framework
+    TInt DoCreate(TInt aUnit,const TDesC* anInfo,const TVersion& aVer);
+	void HandleMsg(TMessageBase* aMsg);
+    void DoCancel(TInt aReqNo);
+    TInt DoRequest(TInt aReqNo,TRequestStatus* aStatus,TAny* a1,TAny* a2);
+    TInt DoControl(TInt aFunction,TAny *a1,TAny *a2);
+
+	DCloggerDebugRouter* _iRouter;
+	DOBJECT_PADDING;
+	};
+
+#define iRouter SAFE_MEMBER(_iRouter)
+
+DCloggerDebugRouterFactory::DCloggerDebugRouterFactory()
+	{
+	SAFE_MEMBER(iVersion)=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
+	}
+
+TInt DCloggerDebugRouterFactory::Create(DLogicalChannelBase*& aChannel)
+    {
+	TInt err = DCloggerDebugRouter::Init();
+	if (err) return err;
+
+    aChannel = new DCloggerDebugRouterLDD(gRouter);
+	if (aChannel==NULL)
+		return KErrNoMemory;
+	else
+		return KErrNone;
+    }
+
+TInt DCloggerDebugRouterFactory::Install()
+    {
+    return(SetName(&KDebugRouterName));
+    }
+
+void DCloggerDebugRouterFactory::GetCaps(TDes8& /*aDes*/) const
+    {
+/*    TCapsMemoryAccessV01 b;
+    b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
+    aDes.FillZ(aDes.MaxLength());
+    aDes.Copy((TUint8*)&b,Min(aDes.MaxLength(),sizeof(b)));
+*/    } 
+
+// class DCloggerDebugRouter Implementation
+
+DCloggerDebugRouterLDD::DCloggerDebugRouterLDD(DCloggerDebugRouter* aRouter)
+    : DLogicalChannel()
+    {
+    //SetBehaviour(-1); //JR
+	iRouter = aRouter;
+    }
+
+DCloggerDebugRouter::DCloggerDebugRouter()
+	: iHandleInterruptDfc(NULL, NULL), iCompleteClientDfc(NULL, NULL)
+#ifdef __SMP__
+	, iInterruptBufLock(TSpinLock::EOrderGenericIrqLow0), iBufferLock(TSpinLock::EOrderGenericPreLow0)
+#endif
+	{
+	}
+
+const TInt KMemAccessDfcThreadPriority = 27;
+
+// DCloggerDebugRouter::DoCreate
+//  Check capabilities & version & start listening for events
+TInt DCloggerDebugRouterLDD::DoCreate(TInt /*aUnit*/,const TDesC* /*anInfo*/,const TVersion& aVer)
+    {
+	TInt ret=KErrNone;
+	
+	/*
+	//Require Power Management and All Files to use this driver
+	//Not ideal, but better than nothing
+	if(!Kern::CurrentThreadHasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by MEMORYACCESS.LDD (Memory Access for Task Managers)")))
+	    ret= KErrPermissionDenied;
+	if(!Kern::CurrentThreadHasCapability(ECapabilityAllFiles,__PLATSEC_DIAGNOSTIC_STRING("Checked by MEMORYACCESS.LDD (Memory Access for Task Managers)")))
+	    ret= KErrPermissionDenied;
+    */
+    if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
+    	{
+    	return KErrNotSupported;
+    	}
+
+	if (iRouter->iClient)
+		{
+		return KErrAlreadyExists;
+		}
+
+    iRouter->iClient=&Kern::CurrentThread();
+
+   	SetDfcQ(&iRouter->PrivateDfcQ());
+   	SAFE_MEMBER(iMsgQ).Receive();		
+
+	//Kern::Printf("DCloggerDebugRouter::DoCreate %d",ret);
+    return ret;
+    }
+
+TDfcQue& DCloggerDebugRouter::PrivateDfcQ()
+	{
+	return iPrivateDfcQ;
+	}
+
+TInt DCloggerDebugRouter::Init()
+	{
+	//__BREAKPOINT();
+	if (gRouter) return KErrNone;
+	TInt err;
+#ifdef __WINS__
+	// WINSCW can't handle DLLs with WSD very well, particularly dynamically loaded ones like LDDs
+	RPropertyRef property; // use this to stash the pointer that DLL loading keeps stomping over
+	NKern::ThreadEnterCS();
+	const TInt EDebugRouterPtr = 1000; // from cliserv.h
+	err = property.Open(KCloggerUid, EDebugRouterPtr);
+	if (!err)
+		{
+		TInt& ptr = *reinterpret_cast<TInt*>(&gRouter);
+		property.Get(ptr);
+		}
+	property.Close();
+	NKern::ThreadLeaveCS();
+	if (gRouter) return KErrNone;
+#endif
+
+	DCloggerDebugRouter* self = new DCloggerDebugRouter;
+	if (!self) return KErrNoMemory;
+
+	err = self->Construct();
+	if (err == KErrNone && StayEnabled())
+		{
+		// Then enable ourselves
+		err = self->OpenChunk();
+		if (!err)
+			{
+			self->SetConsumeLogs(ETrue);
+			self->SetEnabled(ETrue);
+			}
+		}
+	if (err)
+		{
+		delete self;
+		return err;
+		}
+
+	gRouter = self;
+#ifdef __WINS__
+	// See comment at top of function
+	NKern::ThreadEnterCS();
+	err = property.Attach(KCloggerUid, EDebugRouterPtr);
+	if (!err)
+		{
+		_LIT_SECURITY_POLICY_FAIL(KKernOnlyPolicy);
+		err = property.Define(RProperty::EInt, KKernOnlyPolicy, KKernOnlyPolicy);
+		}
+	if (err == KErrNone || err == KErrAlreadyExists)
+		{
+		TInt& ptr = *reinterpret_cast<TInt*>(&gRouter);
+		property.Set(ptr);
+		}
+	property.Close();
+	NKern::ThreadLeaveCS();
+#endif
+	
+	// And finally, set up some dummy functions for debugging
+#ifdef __WINS__
+	CloggerDebugRouter::SetCrashDumpFunctions(&DummyRegisterCrashDump, &DummyUnregisterCrashDump);
+#endif
+
+	return KErrNone;
+	}
+
+TInt DCloggerDebugRouter::Construct()
+	{
+	iInterruptBuf = HBuf8::New(KIsrBufSize);
+	if (!iInterruptBuf) return KErrNoMemory;
+
+	_LIT(KDfcThreadName, "CloggerDebugRouter");
+	TInt err = Kern::DfcQInit(&iPrivateDfcQ, KMemAccessDfcThreadPriority, &KDfcThreadName);
+	if (err) 
+		{
+		return err;
+		}
+	iHandleInterruptDfc = TDfc(&HandleInterrupt, this, &iPrivateDfcQ, 1); // Interrupt handler DFC higher priority than completing client
+	iCompleteClientDfc = TDfc(&CompleteClient, this, &iPrivateDfcQ, 0);
+	return err;
+	}
+
+// dtor
+//
+DCloggerDebugRouter::~DCloggerDebugRouter()
+    {
+	//__BREAKPOINT();
+	TTraceHandler old = Kern::SetTraceHandler(NULL);
+	if (old != &TraceHook)
+		{
+		// Then set it back. What we wanted to do is if (TraceHandler == &TraceHook) { SetTraceHandler(NULL) }
+		// But there is no API to get the hook without also setting it.
+		Kern::SetTraceHandler(old);
+		}
+	CloseChunk();
+
+	// Finally queue a DFC to kill our DFC thread
+	if (iPrivateDfcQ.iThread)
+		{
+		TDfc killDfcThread(KillThreadDFC, this, &iPrivateDfcQ, 0); 
+		killDfcThread.Enque();
+		}
+	}
+
+DCloggerDebugRouterLDD::~DCloggerDebugRouterLDD()
+    {
+	//__BREAKPOINT();
+	ASSERT(!iRouter->iClientStatus); // Should have received a close message first
+	iRouter->iClient = NULL;
+	}
+
+void DCloggerDebugRouter::KillThreadDFC(TAny* /*aSelfP*/)
+	{
+	Kern::Exit(KErrNone);
+	} 
+
+void DCloggerDebugRouter::HandleInterrupt(TAny* aSelf)
+	{
+	static_cast<DCloggerDebugRouter*>(aSelf)->CheckInterruptBuffer();
+	}
+
+void DCloggerDebugRouter::CheckInterruptBuffer()
+	{
+	TBuf8<256> interruptBufCopy; // Using a stack buffer here means we don't have to lock the kernel just yet
+#ifdef __SMP__
+	TInt irq = __SPIN_LOCK_IRQSAVE(iInterruptBufLock);
+#else
+	TInt irq = NKern::DisableAllInterrupts(); // Prevent an interrupt changing it while we're copying it
+#endif
+	if (iInterruptBuf->Length() > 256)
+		{
+		// Need to rethink the stack buffer!
+		__BREAKPOINT();
+		}
+	interruptBufCopy.Copy(*iInterruptBuf);
+	iInterruptBuf->Zero();
+	memclr((TAny*)iInterruptBuf->Ptr(), iInterruptBuf->Length()); // So that you don't see old data in the crashlog
+#ifdef __SMP__
+	__SPIN_UNLOCK_IRQRESTORE(iInterruptBufLock, irq);
+#else
+	NKern::RestoreInterrupts(irq);
+#endif
+	if (interruptBufCopy.Length())
+		{
+		//__BREAKPOINT();
+		DoTrace(interruptBufCopy, EKernelTrace, 0);
+		}
+	}
+   
+// DCloggerDebugRouter::HandleMsg
+//  Called when user side sends us something
+void DCloggerDebugRouterLDD::HandleMsg(TMessageBase* aMsg)
+	{
+	//Kern::Printf("DCloggerDebugRouter::HandleMsg");
+    TThreadMessage& m=*(TThreadMessage*)aMsg;
+
+    // Get message type
+    TInt id=m.iValue;
+
+    // Decode the message type and dispatch it to the relevent handler function...
+    
+    // A logical channel can be closed either explicitly by its user-side client,
+    // or implicitly if the client thread dies. In the latter case, the channel
+    // is closed in the context of the kernel supervisor thread. 
+
+    if (id==(TInt)ECloseMsg)
+        {
+        //Kern::Printf("DCloggerDebugRouter::HandleMsg Close");
+        // Channel Close
+        DoCancel(RCloggerDebugRouter::EAllRequests); //JR
+        m.Complete(KErrNone, EFalse);
+        return;
+        }
+
+    // For all other message types, we check that the message is from the thread
+    // that created us.
+    if(m.Client()!=iRouter->iClient)
+        {
+      	//Kern::Printf("DCloggerDebugRouter::HandleMsg About");
+        Kern::ThreadKill(m.Client(),EExitPanic,ERequestFromWrongThread,KPanicCategory);
+        m.Complete(KErrNone,ETrue);
+        return;
+        }
+    if (id==KMaxTInt)
+        {
+        //Kern::Printf("DCloggerDebugRouter::HandleMsg Cancel");
+        // DoCancel
+        DoCancel(m.Int0());
+        m.Complete(KErrNone,ETrue);
+        return;
+        }
+    if (id<0)
+        {
+        // DoRequest
+        //Kern::Printf("DCloggerDebugRouter::HandleMsg Do Request");
+        TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
+        TInt r=DoRequest(~id, pS, m.Ptr1(), m.Ptr2());
+        if (r!=KErrNone)
+            Kern::RequestComplete(iRouter->iClient,pS,r);
+        m.Complete(KErrNone,ETrue);
+        }
+    else
+        {
+        // DoControl
+        //Kern::Printf("DCloggerDebugRouter::HandleMsg Do Control");
+        TInt r=DoControl(id,m.Ptr0(),m.Ptr1());
+        m.Complete(r,ETrue);
+        }	
+	}
+
+// DCloggerDebugRouter::DoRequest
+//  Handles async messages, called from HandleMsg
+TInt DCloggerDebugRouterLDD::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* /*a1*/, TAny* /*a2*/)
+    {
+	if (aReqNo == RCloggerDebugRouter::ERequestGetData)
+		{
+		iRouter->ClientRequestData(aStatus);
+		}
+    return KErrNone;
+    }
+
+void DCloggerDebugRouter::ClientRequestData(TRequestStatus* aStatus)
+	{
+	iClientStatus = aStatus;
+	NKern::Lock();
+#ifdef __SMP__
+	__SPIN_LOCK(iBufferLock);
+	NotifyClient();
+	__SPIN_UNLOCK(iBufferLock);
+#else
+	NotifyClient();
+#endif
+	NKern::Unlock();
+	}
+
+
+
+// DCloggerDebugRouter::DoCancel
+//  Cancels async messages, called from HandleMsg
+void DCloggerDebugRouterLDD::DoCancel(TInt /*aReqNo*/)
+    {
+	if (iRouter->iClientStatus)
+		{
+		Kern::RequestComplete(iRouter->iClient, iRouter->iClientStatus, KErrCancel);
+		}
+    }
+
+void DCloggerDebugRouter::SetEnabled(TBool aEnabled)
+	{
+	if (aEnabled)
+		{
+		/*TTraceHandler old =*/ Kern::SetTraceHandler(&TraceHook);
+		}
+	else
+		{
+		if (Kern::SuperPage().iDebugPort != KCloggerDebugPort)
+			{
+			// If we are the debug port, we cannot unset our trace hook, there's nowhere else for the logs to go
+			// Don't try and restore any previous trace handler - no guarantee the pointer is still valid or safe to call
+			Kern::SetTraceHandler(NULL);
+			iCurrent = iStartAddr;
+			iFirstFrame = iCurrent;
+			}
+		// Reset client pointers
+		iClientStart = iStartAddr;
+		iClientEnd = iClientStart;
+		}
+	}
+
+void DCloggerDebugRouter::SetConsumeLogs(TBool aConsume)
+	{
+	if (Kern::SuperPage().iDebugPort == KCloggerDebugPort)
+		{
+		// Then the LDD has no say in whether we are allowed to consume the logs or not
+		// Because there is nowhere else for them to go if we are the debug port, we must consume them
+		aConsume = ETrue;
+		}
+	//iConsumeLogs = EFalse; // So that we can get logging from the kernel even when rdebug redirection is enabled
+	iConsumeLogs = aConsume;
+	}
+
+// DCloggerDebugRouter::DoControl
+//  Handles sync messages, called from HandleMsg
+TInt DCloggerDebugRouterLDD::DoControl(TInt aFunction, TAny* a1, TAny* a2)
+    {
+	//Kern::Printf("[DCloggerDebugRouter] ::DoControl; Function: %d", aFunction);
+    switch (aFunction)
+        {
+	case RCloggerDebugRouter::EControlEnableRouting:
+		{
+		TBool consume = (TInt)a1 == RCloggerDebugRouter::EEnableRoutingAndConsume;
+		TBool enable = (TBool)a1;
+
+		iRouter->SetConsumeLogs(consume);
+		iRouter->SetEnabled(enable);
+		return KErrNone;
+		}
+	case RCloggerDebugRouter::EControlOpenChunk:
+		{
+		TInt res = iRouter->OpenChunk();
+		return res;
+		}
+	case RCloggerDebugRouter::EControlRegisterBuffers:
+		{
+		TInt err = Kern::ThreadDesRead(iRouter->iClient, a1, iRouter->iClientCrashDumpBuf, 0);
+		if (!err)
+			{
+			err = iRouter->RegisterCrashDumpAreas(iRouter->iClientCrashDumpBuf);
+			}
+		return err;
+		}
+	case RCloggerDebugRouter::EControlCreateAndOpenAChunk:
+		{
+		SCreateChunkParams params;
+		TInt res = Kern::ThreadRawRead(iRouter->iClient, a1, &params, sizeof(SCreateChunkParams));
+		if (res != KErrNone) return res;
+		
+		DThread* otherThread = NULL;
+		TInt otherThreadHandle = 0;
+		if (params.iHandleOfOtherThread)
+			{
+			NKern::LockSystem();
+			otherThread = (DThread*)Kern::ObjectFromHandle(iRouter->iClient, params.iHandleOfOtherThread, EThread);
+			if (otherThread) otherThread->Open(); // Make sure it doesn't disappear before we've finished with it
+			NKern::UnlockSystem();
+			}
+		
+		DChunk* chunk = NULL;
+		TChunkCreateInfo info;
+		info.iType         = TChunkCreateInfo::ESharedKernelSingle;
+		info.iMaxSize      = params.iMaxSize;
+#ifdef __EPOC32__
+		info.iMapAttr      = (TInt)EMapAttrFullyBlocking; // Full caching
+#endif
+		info.iOwnsMemory   = ETrue; // Use memory from system's free pool
+		info.iDestroyedDfc = NULL;
+
+		TUint32 chunkMapAttr;
+		TLinAddr addr;
+		NKern::ThreadEnterCS();
+		res = Kern::ChunkCreate(info, chunk, addr, chunkMapAttr);
+		if (res != KErrNone)
+			{
+			goto CloseAndBail;
+			}
+		if (params.iCommittedSize > 0)
+			{
+			res = Kern::ChunkCommit(chunk,0,params.iCommittedSize);
+			}
+		if(res!=KErrNone)
+			{
+			goto CloseAndBail;
+			}
+
+		// Still in CS
+		
+		if (otherThread)
+			{
+			// Create handle for other thread
+			otherThreadHandle = Kern::MakeHandleAndOpen(otherThread, chunk);
+			}
+		if (otherThreadHandle < 0)
+			{
+			res = otherThreadHandle;
+			goto CloseAndBail;
+			}
+		// Create handle for our thread
+		res = Kern::MakeHandleAndOpen(iRouter->iClient, chunk);
+		// Open our handle last so we don't have to worry about closing it in CloseAndBail if an error occurred later
+		goto CloseAndBail;
+		// All done.
+		
+CloseAndBail:
+		Kern::ChunkClose(chunk);
+		if (res < 0 && otherThreadHandle > 0) Kern::CloseHandle(otherThread, otherThreadHandle);
+		NKern::ThreadLeaveCS();
+		
+		if (res > 0)
+			{
+			params.iOtherThreadChunkHandle = otherThreadHandle;
+			params.iChunkHandle = res;
+			res = KErrNone;
+			Kern::ThreadRawWrite(iRouter->iClient, a1, &params, sizeof(SCreateChunkParams));
+			}
+		return res;
+		}
+	case RCloggerDebugRouter::EControlAdjustChunk:
+		{
+		TInt handle = (TInt)a1;
+		TInt newSize = (TInt)a2;
+		NKern::LockSystem();
+		DChunk* chunk = (DChunk*)Kern::ObjectFromHandle(iRouter->iClient, handle, EChunk);
+		if (chunk) chunk->Open(); // Make sure it doesn't disappear before we've finished with it
+		NKern::UnlockSystem();
+		TInt err = KErrNotFound;
+		if (chunk)
+			{
+			NKern::ThreadEnterCS();
+			TInt oldSize = chunk->Size();
+			TInt diff = Kern::RoundToPageSize(newSize - oldSize);
+			// Because kernel-created chunks appear to be specified as disconnected, we can't use the simple Adjust
+			//err = chunk->Adjust(newSize);
+			// even though that's the behaviour we want
+			if (diff > 0)
+				{
+				err = Kern::ChunkCommit(chunk, oldSize, diff);
+				if (err == KErrArgument) err = KErrNoMemory; // Generally that's what it means
+				}
+			else if (diff < 0)
+				{
+				// It appears that there is no way of decommitting memory from a shared chunk
+				// So we will just stay the same size
+				//err = chunk->Decommit(newSize, -diff);
+				err = KErrNone;
+				}
+			else
+				{
+				// no change
+				err = KErrNone;
+				}
+			Kern::ChunkClose(chunk);
+			NKern::ThreadLeaveCS();
+			}
+		return err;
+		}
+    default:
+		(void)a2;
+        return KErrNotSupported;
+        }
+    }
+
+
+TBool DCloggerDebugRouter::TraceHook(const TDesC8& aText, TTraceSource aTraceSource)
+	{
+#if defined(DO_LOGGING) // || defined(_DEBUG)
+	// This code is here so it's easier to debug problems in my trace hook that cause kern faults (that in turn
+	// try to call Kern::Printf...)
+	if (aTraceSource == EKernelTrace) return EFalse;
+#endif
+#ifdef __WINS__
+	// This is necessary in case loading the LDD stomped over the global data
+	if (!gRouter) return ETrue;
+#endif
+	return gRouter->DoTraceHook(aText, aTraceSource);
+	}
+
+TBool DCloggerDebugRouter::DoTraceHook(const TDesC8& aText, TTraceSource aTraceSource)
+	{
+	TBool consume = iConsumeLogs;
+
+	TUint traceThread = 0; // 0 means non-thread (ie interrupt or IDFC) that will appear as the generic "Kern::Printf"
+	TInt context = NKern::CurrentContext();
+	if (context == NKern::EInterrupt)
+		{
+		// Interrupts copy to a special buffer. No timestamping or prettying up is done at the point of the interrupt
+		// It is handled next time someone logs or when the DFC fires, whichever is sooner
+#ifdef __SMP__
+		TInt irq = __SPIN_LOCK_IRQSAVE(iInterruptBufLock);
+		iInterruptBuf->Append(aText);
+		__SPIN_UNLOCK_IRQRESTORE(iInterruptBufLock, irq);
+#else
+		iInterruptBuf->Append(aText);
+#endif
+
+		iHandleInterruptDfc.Add();
+		return consume;
+		}
+	
+	if (context == NKern::EThread)
+		{
+		DThread& thread = Kern::CurrentThread();
+		traceThread = thread.iId;
+		}
+
+	// Before doing our logging, check if there's anything in the interrupt buffer. This means that (barring interrupt logging that happens while we're running the TraceHook function) the logging should still end up sequential
+	CheckInterruptBuffer();
+
+	if (aTraceSource == EUserTrace)
+		{
+		DProcess& userProc = Kern::CurrentProcess();
+		if (userProc.iS.iSecureId == (TUint)KCloggerUid.iUid)
+			{
+			return EFalse; // Debugs from clogger itself should be passed through to the debugport
+			}
+		}
+
+	DoTrace(aText, aTraceSource, traceThread);
+	return consume;
+	}
+
+void DCloggerDebugRouter::DoTrace(const TDesC8& aText, TTraceSource aTraceSource, TUint aTraceThread)
+	{
+	LOG("+DoTrace iStartAddr=%x iEndAddr=%x iCurrent=%x iClientStart=%x iClientEnd=%x", iStartAddr, iEndAddr, iCurrent, iClientStart, iClientEnd);
+	SCloggerTraceInfo info;
+	info.iTraceType = aTraceSource == EUserTrace ? 'U' : aTraceSource == EPlatSecTrace ? 'P' : 'K';
+	info.iReserved = 0;
+	info.iLength = aText.Length();
+	info.iTickCount = NKern::TickCount();
+	info.iThreadId = aTraceThread;
+	TPckg<SCloggerTraceInfo> id(info);
+	
+	NKern::Lock();
+#ifdef __SMP__
+	__SPIN_LOCK(iBufferLock);
+#endif
+	if (iInTheMiddleOfTracing)
+		{
+		// In a recursive loop, probably due to an assertion failure in the below code triggering a kern::printf
+		__BREAKPOINT();
+		}
+	iInTheMiddleOfTracing = ETrue;
+
+	TBool ok = WriteOut(id, id.Length() + aText.Length());
+	if (ok) WriteOut(aText);
+	if (!ok)
+		{
+		//consume = EFalse; // Don't consume if the buffer overflowed
+		if (iOverflows != KMaxTUint)
+			{
+			// Don't overflow the overflow counter!
+			iOverflows++;
+			}
+		}
+	NotifyClient();
+	iInTheMiddleOfTracing = EFalse;
+	LOG("-DoTrace iStartAddr=%x iEndAddr=%x iCurrent=%x iClientStart=%x iClientEnd=%x", iStartAddr, iEndAddr, iCurrent, iClientStart, iClientEnd);
+#ifdef __SMP__
+	__SPIN_UNLOCK(iBufferLock);
+#endif
+
+	NKern::Unlock();
+	}
+
+TBool DCloggerDebugRouter::WriteOut(const TDesC8& aBuf, TInt aLengthToConsider)
+	{
+	/*
+	In the case we are using the end of the buffer and the client is writing the start (canWrap == TRUE)
+	                +-----------+
+                    |           |
+	iClientStart -> |           |
+	                |           |
+	                |           |
+	iClientEnd   -> |           | ^
+	                |           | | This is what needs writing out next
+	                |           | | (currently)
+	                |           | v
+	                |           | <- iCurrent
+	                |           |
+	                |           |
+					+-----------+
+
+	In the case where the client is writing near the end and we have wrapped round to the beginning (canWrap == FALSE)
+                    +-----------+
+                    |           |
+                    |           |
+	                |           | <- iCurrent
+	                |           |
+	                |           |
+	                |           |
+	                |           |
+	                |           |
+    iClientStart -> |           | 
+	                |           |
+	iClientEnd   -> |           |
+					+-----------+
+	*/
+
+	TUint endSpace, startSpace;
+	if (iClient && iClientStart)
+		{
+		TBool canWrap = iClientStart <= iCurrent; // If the client is still using the end of the buffer, we can't wrap around
+		endSpace = (canWrap ? iEndAddr : iClientStart) - iCurrent;
+		startSpace = canWrap ? (iClientStart - iStartAddr) : 0;
+		}
+	else
+		{
+		// If there's no client yet, we can ignore the client ptrs.
+		// TODO if there's no client, we should also do a rolling overwrite of the buffer (ie better to drop the oldest statements than the recent ones
+		// TODO however this has its problems because this is not a pure byte stream - it'd mess up the headers if you were to try and save what was in the buffer rather than clearing it when it gets full
+		endSpace = iEndAddr - iCurrent;
+		startSpace = 0; //iCurrent - iStartAddr;
+		}
+
+	ASSERT(endSpace <= iEndAddr - iStartAddr);
+	ASSERT(startSpace < iEndAddr - iStartAddr);
+
+	TInt lenToTest = aLengthToConsider;
+	if (lenToTest == 0) lenToTest = aBuf.Length();
+
+	if ((TUint)lenToTest > startSpace + endSpace) return EFalse;
+
+	TPtrC8 endFrag = aBuf.Left(endSpace);
+	memcpy((TAny*)iCurrent, endFrag.Ptr(), endFrag.Size());
+	iCurrent += endFrag.Size();
+
+	if (endFrag.Length() < aBuf.Length())
+		{
+		LOG("Wrapping round");
+		ASSERT(iCurrent == iEndAddr);
+		iCurrent = iStartAddr;
+		TPtrC8 remainder = aBuf.Mid(endSpace);
+		memcpy((TAny*)iStartAddr, remainder.Ptr(), remainder.Size());
+		iCurrent += remainder.Size();
+		iFirstFrame = iCurrent; // iFirstFrame is now no longer iStartAddr, it's the earliest point in the buffer that a frame starts at
+		}
+	return ETrue;
+	}
+
+void DCloggerDebugRouter::CloseChunk()
+	{
+	if (iChunk)
+		{
+		NKern::ThreadEnterCS();
+		Kern::ChunkClose(iChunk);
+		iChunk = NULL;
+		NKern::ThreadLeaveCS();
+		}
+	}
+    
+TInt DCloggerDebugRouter::OpenChunk()
+	{
+	TInt r = KErrNone;
+	if (iChunk == NULL)
+		{
+		TChunkCreateInfo info;
+		info.iType         = TChunkCreateInfo::ESharedKernelSingle;
+		info.iMaxSize      = KChunkSize;
+#ifdef __EPOC32__
+		info.iMapAttr      = (TInt)EMapAttrFullyBlocking; // Full caching
+#endif
+		info.iOwnsMemory   = ETrue; // Use memory from system's free pool
+		info.iDestroyedDfc = NULL;
+
+		TUint32 chunkMapAttr;
+		TLinAddr addr;
+		NKern::ThreadEnterCS();
+		if (KErrNone != (r = Kern::ChunkCreate(info, iChunk, addr, chunkMapAttr)))
+			{
+			NKern::ThreadLeaveCS();
+			return r;
+			}
+		r = Kern::ChunkCommit(iChunk,0,KChunkSize);
+		if(r!=KErrNone)
+			{
+			Kern::ChunkClose(iChunk);
+			iChunk = NULL;
+			NKern::ThreadLeaveCS();
+			return r;
+			}
+		NKern::ThreadLeaveCS();
+		//TLinAddr addr = (TLinAddr)iChunk->Base();
+		iStartAddr = addr + sizeof(SDebugChunkHeader); // Bottom few words are reserved for metadata
+		iEndAddr = addr + KChunkSize;
+		iCurrent = iStartAddr;
+		iFirstFrame = iStartAddr;
+		RegisterCrashDumpAreas(KNullDesC8); // As now we have our main chunk
+		}
+	if (iClient)
+		{
+		NKern::ThreadEnterCS();
+		r = Kern::MakeHandleAndOpen(iClient, iChunk); 
+		NKern::ThreadLeaveCS();
+		/*
+		if(r < KErrNone)
+			{
+			Kern::ChunkClose(iChunk);
+			iChunk = NULL;
+			NKern::ThreadLeaveCS();
+			return r;
+			}
+		*/
+		iClientStart = iFirstFrame;
+		iClientEnd = iClientStart;
+		}
+
+	return r;
+	}
+
+void DCloggerDebugRouter::NotifyClient()
+	{
+	LOG("NotifyClient");
+	if (iCompleteClientDfc.Queued())
+		{
+		// The DFC that will signal the client has already been fired and the client pointers calculated. Don't get in its way.
+		return;
+		}
+	if (!iClientStatus || !iClient)
+		{
+		// Client not ready
+		return;
+		}
+	if (iCurrent == iClientEnd)
+		{
+		// No new data to send
+		return;
+		}
+
+	LOG("Notifying client enqueuing client DFC");
+	
+	// The start of the chunk stores the info for the client about which bits of the buffer it needs to read
+	TUint realStartAddr = iStartAddr - sizeof(SDebugChunkHeader);
+	SDebugChunkHeader* header = (SDebugChunkHeader*)realStartAddr;
+	TUint* clientStartPtr = &header->iStartOffset;
+	TUint* clientEndPtr = &header->iEndOffset;
+	TUint* overflows = &header->iOverflows;
+
+	LOG("Notifying with iClientStart=%x iClientEnd=%x iCurrent=%x", iClientStart, iClientEnd, iCurrent);
+
+	*overflows = iOverflows;
+	iOverflows = 0; // Reset this each time we write to the client, it's not cumulative
+
+	TLinAddr end = iCurrent;
+	iClientStart = iClientEnd;
+	iClientEnd = end;
+
+	*clientStartPtr = iClientStart - realStartAddr; // Offset of the end of the last read from the start of the chunk
+	*clientEndPtr = iClientEnd - realStartAddr; // Offset of current ptr from start of chunk
+
+	LOG("Signalling client start %08x end %08x", *clientStartPtr, *clientEndPtr);
+	iCompleteClientDfc.DoEnque();
+	}
+
+void DCloggerDebugRouter::CompleteClient(TAny* aSelf)
+	{
+	DCloggerDebugRouter* self = static_cast<DCloggerDebugRouter*>(aSelf);
+	self->DoCompleteClient();
+	}
+
+void DCloggerDebugRouter::DoCompleteClient()
+	{
+	// Kern::RequestComplete involves taking the system lock, which will cause debug if NKERN is set
+	// So temporarily unset it
+	TInt debugMask = 0;
+	TInt oldVal = (TInt)NKern::SafeSwap((TAny*)debugMask, (TAny*&)Kern::SuperPage().iDebugMask[0]);
+	Kern::RequestComplete(iClient, iClientStatus, KErrNone);
+	Kern::SuperPage().iDebugMask[0] = oldVal;
+	}
+
+EXPORT_C void CloggerDebugRouter::DebugPortChanged()
+	{
+	DCloggerDebugRouter* self = gRouter;
+	if (self)
+		{
+		if (Kern::SuperPage().iDebugPort == KCloggerDebugPort)
+			{
+			// Then enable ourselves
+			TInt err = self->OpenChunk();
+			if (!err)
+				{
+				self->SetConsumeLogs(ETrue);
+				self->SetEnabled(ETrue);
+				}
+			}
+		else
+			{
+			// Disable? Or should we just stay running until explicitly disabled by the LDD?
+			//self->SetEnabled(EFalse);
+
+			// I think we should stay enabled until the LDD tells us otherwise...
+			}
+		}
+	}
+
+EXPORT_C void CloggerDebugRouter::SetCrashDumpFunctions(TRegisterFn aRegisterFn, TUnregisterFn aUnregisterFn)
+	{
+	if (gRouter)
+		{
+		gRouter->SetCrashDumpFunctions(aRegisterFn, aUnregisterFn);
+		}
+	}
+
+void DCloggerDebugRouter::SetCrashDumpFunctions(TRegisterFn aRegisterFn, TUnregisterFn aUnregisterFn)
+	{
+	NKern::Lock();
+	iRegisterCrashDumpFn = aRegisterFn;
+	iUnregisterCrashDumpFn = aUnregisterFn;
+	NKern::Unlock();
+	RegisterCrashDumpAreas(KNullDesC8);
+	}
+
+TInt DCloggerDebugRouter::RegisterCrashDumpAreas(const TDesC8& aAreas)
+	{
+	if (!iRegisterCrashDumpFn || !iUnregisterCrashDumpFn)
+		{
+		return KErrNotReady;
+		}
+	
+	LOG("Unregistering current crashdumps");
+	// Unregister current ones
+	for (TInt i = 0; i < iNumCrashDumpAreas; i++)
+		{
+		(*iUnregisterCrashDumpFn)(iCrashDumpAreas[i]);
+		DChunk* chunk = iCrashDumpAreas[i].iChunk;
+		if (chunk)
+			{
+			LOG("Closing chunk %O", chunk);
+			NKern::ThreadEnterCS();
+			chunk->Close(NULL);
+			NKern::ThreadLeaveCS();
+			LOG("Closed chunk %O", chunk);
+			}
+		}
+	iNumCrashDumpAreas = 0;
+	
+	// Register our ones
+	LOG("Registering new crashdumps");
+	if (iChunk)
+		{
+		LOG("Registering rdebugprint buffer");
+		_LIT8(KLddBuf, "Clogger RDebug::Print buffer");
+		SCrashDumpArea& area = iCrashDumpAreas[iNumCrashDumpAreas++];
+		area.iChunk = NULL; // Only specify the chunk for client-side chunks we otherwise don't hold open
+		area.iName = KLddBuf;
+		(*iRegisterCrashDumpFn)((TAny*)iStartAddr, iEndAddr-iStartAddr, area);
+		}
+	LOG("Registering ISR buffer");
+	_LIT8(KIsrBuf, "Clogger ISR buffer");
+	SCrashDumpArea& area = iCrashDumpAreas[iNumCrashDumpAreas++];
+	area.iChunk = NULL; // Only specify the chunk for client-side chunks we otherwise don't hold open
+	area.iName = KIsrBuf;
+	(*iRegisterCrashDumpFn)((TAny*)iInterruptBuf->Ptr(), iInterruptBuf->MaxSize(), area);
+	
+	// Now do client ones
+	const SCloggerCrashDumpArea* clientAreas = (const SCloggerCrashDumpArea*)aAreas.Ptr();
+	TInt num = aAreas.Length() / sizeof(SCloggerCrashDumpArea);
+	for (TInt i = 0; i < num && iNumCrashDumpAreas < KMaxCrashDumpAreas; i++)
+		{
+		const SCloggerCrashDumpArea& clientArea = clientAreas[i];
+		LOG("Getting chunk for client buffer %d", i);
+		NKern::LockSystem();
+		DChunk* chunk = (DChunk*)Kern::ObjectFromHandle(iClient, clientArea.iChunkHandle, EChunk);
+		NKern::UnlockSystem();
+		LOG("Got client chunk %O", chunk);
+		if (chunk && chunk->Open() == KErrNone)
+			{
+			SCrashDumpArea& area = iCrashDumpAreas[iNumCrashDumpAreas++];
+			area.iChunk = chunk;
+			area.iName = clientArea.iName;
+			TAny* ptr = (TAny*)(chunk->Base() + clientArea.iOffset);
+			(*iRegisterCrashDumpFn)(ptr, clientArea.iSize, area);
+			}
+		}
+	LOG("Completed registering new crashdump areas");
+	return KErrNone;
+	}
+
+TBool DCloggerDebugRouter::StayEnabled()
+	{
+	return KEnableEarlyRdebug || Kern::SuperPage().iDebugPort == KCloggerDebugPort;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/debugRouter/debugRouter.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,150 @@
+// debugRouter.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __DebugRouter_H__
+#define __DebugRouter_H__
+
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
+#include <u32std.h>
+
+_LIT(KDebugRouterName,"Clogger-DebugRouter");
+class RChunk;
+
+struct SCloggerCrashDumpArea
+	{
+	TInt iChunkHandle;
+	TUint iOffset;
+	TUint iSize;
+	TBuf8<32> iName;
+	};
+
+struct SCreateChunkParams
+	{
+	TInt iHandleOfOtherThread;
+	TInt iMaxSize;
+	TInt iCommittedSize;
+	TInt iChunkHandle; // Return value
+	TInt iOtherThreadChunkHandle; // Return value, If iHandleOfOtherThread != 0
+	};
+
+struct SCloggerTraceInfo
+	{
+	TUint8 iTraceType; // 'P', 'K', 'U'
+	TUint8 iReserved;
+	TUint16 iLength; // Kern trace is always <=256 chars but unfortunately platsec diagnostics aren't!
+	TUint32 iTickCount;
+	TUint iThreadId;
+	};
+
+struct SDebugChunkHeader
+	{
+	TUint iStartOffset;
+	TUint iEndOffset;
+	TUint iOverflows; // Number of log statements that were dropped because the buffer was full (measured since last completion, not cumulative)
+	};
+	
+class RCloggerDebugRouter : public RBusLogicalChannel
+	{
+public:
+	enum TControl
+		{
+		EControlEnableRouting,
+		EControlOpenChunk,
+		ERequestGetData,
+		EControlRegisterBuffers,
+		EControlCreateAndOpenAChunk,
+		EControlAdjustChunk,
+		ENumRequests,  // Add new commands above this line
+		EAllRequests= (1<<ENumRequests)-1
+        };
+	enum TEnableOption
+		{
+		EDisable,
+		EEnableRouting,
+		EEnableRoutingAndConsume,
+		};
+public:
+	static TInt LoadDriver();
+	static void CloseDriver();
+	TInt Open();
+	void Close();
+
+public: // For retreiving RDebug::Print data
+	TInt OpenChunk(RChunk& aChunk);
+	void ReceiveData(TRequestStatus& aStatus);
+	void CancelReceive();
+	TInt EnableDebugRouting(TEnableOption aEnable);
+
+public: // For registering buffers with the crash dumber (NOTE: requires support in the baseport to have any effect)
+	// This supercedes any previous call to RegisterCrashDumpAreas. Therefore to unregister everything, call RegisterCrashDumpAreas(KNullDesC8)
+	TInt RegisterCrashDumpAreas(const TDesC8& aCrashDumpAreas); // packed array of SCloggerCrashDumpAreas
+	
+	TInt CreateChunk(SCreateChunkParams& aParams); // returns chunk handle or error
+	TInt AdjustChunk(RChunk& aChunk, TInt aNewSize);
+	};
+
+#ifndef __KERNEL_MODE__
+// Inline implementations of user side interface
+
+inline TInt RCloggerDebugRouter::LoadDriver()
+	{	return User::LoadLogicalDevice(KDebugRouterName);	}
+inline void RCloggerDebugRouter::CloseDriver()
+	{	User::FreeLogicalDevice(KDebugRouterName);	}
+inline void RCloggerDebugRouter::Close()
+	{	RHandleBase::Close(); }
+inline TInt RCloggerDebugRouter::Open()
+	{	return DoCreate(KDebugRouterName,TVersion(1,0,0),KNullUnit,NULL,NULL); 	}
+	
+inline TInt RCloggerDebugRouter::EnableDebugRouting(TEnableOption aEnable)
+	{	return DoControl(EControlEnableRouting, (TAny*)aEnable);	}
+
+inline TInt RCloggerDebugRouter::OpenChunk(RChunk& aChunk)
+	{	
+	TInt res = DoControl(EControlOpenChunk);
+	if (res >= 0) 
+		{
+		aChunk.SetHandle(res);
+		return KErrNone;
+		}
+	return res;
+	}
+
+inline void RCloggerDebugRouter::ReceiveData(TRequestStatus& aStatus)
+	{
+	DoRequest(ERequestGetData, aStatus);
+	}
+
+inline void RCloggerDebugRouter::CancelReceive()
+	{
+	DoCancel(0xFFFFFFFF); // We only have 1 async request at the moment
+	}
+
+inline TInt RCloggerDebugRouter::RegisterCrashDumpAreas(const TDesC8& aCrashDumpAreas)
+	{
+	return DoControl(EControlRegisterBuffers, (TAny*)&aCrashDumpAreas);
+	}
+
+inline TInt RCloggerDebugRouter::CreateChunk(SCreateChunkParams& aParams)
+	{
+	return DoControl(EControlCreateAndOpenAChunk, (TAny*)&aParams);
+	}
+
+inline TInt RCloggerDebugRouter::AdjustChunk(RChunk& aChunk, TInt aNewSize)
+	{
+	return DoControl(EControlAdjustChunk, (TAny*)aChunk.Handle(), (TAny*)aNewSize);
+	}
+
+#endif //__KERNEL_MODE__
+
+#endif //__DebugRouter_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/debugRouter/debugRouter.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+// debugRouter.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include <kernel/kern_ext.mmh>
+
+target		clogger-debugrouter.ldd
+//targettype	ldd
+targettype kext
+
+uid			0x100000af FSHELL_UID_CLOGGERDEBUGROUTER
+
+capability	all
+
+userinclude	.
+
+sourcepath	.
+source		debugrouter.cpp
+source		dobject_compat.cpp
+source		patchables.cpp
+
+library		ekern.lib
+nostrictdef
+#ifdef FSHELL_PATCHABLE_CONSTANTS_SUPPORT
+deffile		..\~\debugrouter.def
+#else
+deffile		..\~\debugrouter_nopatchdata.def
+#endif
+
+epocallowdlldata
+
+start wins
+win32_headers
+end
+
+#ifdef SMP
+// This isn't actually used for anything, but it's recommended, to indicate the driver has had some level of SMP safely analysis done (which this has)
+smpsafe
+#endif
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/debugRouter/dobject_compat.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+// dobject_compat.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "dobject_compat.h"
+
+extern TBool gRunningWithOldDefinition = ETrue;
+
+NONSHARABLE_CLASS(DObjectWithPaddingOnly) : public DObject
+	{
+public:
+	DOBJECT_PADDING;
+	};
+
+TBool CalculateDObjectSize()
+	{
+	DObjectWithPaddingOnly* obj = new DObjectWithPaddingOnly;
+	if (!obj) return EFalse;
+	
+	// objectId points to the mem location where iObjectId will be. So if running on a system with the new size DOBject it will always be non-zero (because objectIds are set in the DObject constructor, and are always non-zero), but if running on earlier systems it will be zero because DBase zero-fills the object
+	TUint64& objectId = *reinterpret_cast<TUint64*>((TUint8*)&obj->iName + sizeof(HBuf*));
+	
+	if (objectId != 0)
+		{
+		//Kern::Printf("Detected MemoryAccess is running with new larger DObject");
+		gRunningWithOldDefinition = EFalse;
+		}
+	else
+		{
+		//Kern::Printf("Detected MemoryAccess is running with old-format DObject");		
+		}
+	obj->Close(NULL);
+	return ETrue;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/debugRouter/dobject_compat.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,102 @@
+// dobject_compat.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef DOBJECT_COMPAT_H
+#define DOBJECT_COMPAT_H
+
+#include <kernel.h>
+
+__ASSERT_COMPILE(sizeof(DObject) == 6*4 || sizeof(DObject) == 8*4); // We can't cope if the size changes again!
+#define DOBJECT_PADDING TUint64 _padding
+const TBool KCompiledUsingOldDefinition = sizeof(DObject) == 6*4;
+#define ADD_PADDING(type, variablePtr) (*reinterpret_cast<type*>((TUint8*)variablePtr + sizeof(TUint64)))
+#define SUBTRACT_PADDING(type, variablePtr) (*reinterpret_cast<type*>((TUint8*)variablePtr - sizeof(TUint64)))
+
+
+template <class T>
+class TemplatedPadder
+	{
+public:
+	inline static T& AddPadding(T* aPtr)
+		{
+		return ADD_PADDING(T, aPtr);
+		}
+	inline static T& SubtractPadding(T* aPtr)
+		{
+		return SUBTRACT_PADDING(T, aPtr);
+		}
+	};
+
+template <class T>
+inline T& AddPadding(T* aPtr)
+	{
+	return TemplatedPadder<T>::AddPadding(aPtr);
+	}
+
+template <class T>
+inline T& SubtractPadding(T* aPtr)
+	{
+	return TemplatedPadder<T>::SubtractPadding(aPtr);
+	}
+
+TBool CalculateDObjectSize(); // returns false if unable to determine 
+extern TBool gRunningWithOldDefinition;
+
+/* The SAFE_MEMBER macro exists because DObject grew by 64 bits between 9.1 and 9.2, therefore to write a 
+ * DObject-derived class (such as a DLogicalChannel in an LDD) that can be compiled on one but also works on the
+ * other requires that you be very careful accessing member data of your DObject-derived objects, because the 
+ * offsets are different on the two OS releases. This macro abstracts the differences away by calculating when
+ * an 8 byte correction needs to be applied to where the compiler thinks the variable is versus where the runtime
+ * knows it is. By necessity, it has a weird definition, that relies on the above helper macros and also on
+ * CalculateDObjectSize being called at some point before the first time any code using SAFE_MACRO is run.
+ * It is recommended that for an LDD, you call it from within your DECLARE_EXTENSION_LDD before doing anything
+ * else.
+ * 
+ * SAFE_MEMBER can only be used to access member data of DObject-derived classes, and should be used in ALL 
+ * places where the instance variables are used or set, this includes instance variables of the superclass and
+ * instance variables in DObject-derived objects you define yourself. Accesses to instance variables of DObject
+ * itself must NOT use this macro, since the DObject variable offsets do not change. In order to make sure your
+ * class is large enough and that the macro can be used consistantly, you must include a DOBJECT_PADDING at 
+ * the *end* of all of your DObject subclass definition. You won't get any warning if you forget to do this,
+ * It will just crash. Likewise if you use SAFE_MEMBER to access the member data of the DObject itself.
+ * 
+ * In other words:
+ * DO use SAFE_MEMBER to access the member data of DMyClassThatIsDerivedFromDObject
+ * DO use SAFE_MEMBER to access the member data of DLogicalChannel/DLogicalDevice/DThread etc
+ * DON'T use it to access the member data of DObject itself
+ * ALWAYS include a DOBJECT_PADDING at the end of your DMyDObjectDerivedClass - ie after any other member data
+ * 
+ */
+
+#define SAFE_MEMBER(variable) ( \
+	(KCompiledUsingOldDefinition && gRunningWithOldDefinition) ? variable : ( \
+	(KCompiledUsingOldDefinition && !gRunningWithOldDefinition) ? AddPadding(&variable) : ( \
+	(!KCompiledUsingOldDefinition && gRunningWithOldDefinition) ? SubtractPadding(&variable) : ( \
+	/* running and compiling with new-definition DObject */ variable ))))
+
+/* Old definition that doesn't require templating to work, (so is callable from non-C++). A consequence is you
+ * have to explicitly give the type of the variable.
+ */
+//#define SAFE_MEMBER(type, variable) ( \
+//	(KCompiledUsingOldDefinition && gRunningWithOldDefinition) ? variable : ( \
+//	(KCompiledUsingOldDefinition && !gRunningWithOldDefinition) ? ADD_PADDING(type, &variable) : ( \
+//	(!KCompiledUsingOldDefinition && gRunningWithOldDefinition) ? SUBTRACT_PADDING(type, &variable) : ( \
+//	/* running and compiling with new-definition DObject */ variable ))))
+
+
+/* These macros are equivalent to _FOFF and _LOFF and should be used whenever
+ * f refers to a member variable that you would need to use SAFE_MEMBER on
+ */
+#define _SAFE_FOFF(c,f)			(((TInt)&  SAFE_MEMBER((((c *)0x1000)->f) )  )-0x1000)
+#define _SAFE_LSOFF(p,T,f) ((T*)(((TUint8*)(p))-_SAFE_FOFF(T,f)))
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/debugRouter/patchables.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// patchables.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32def.h>
+#include <e32const.h>
+
+/* Patchable constants, to specify the size of the chunk used to transfer trace data from the kernel to the cloggerserver,
+ * and the size of the buffer used to buffer logging from ISRs
+ *
+ * To modify, include the following in your OBY file: (the following sets the chunk size to 128KB)
+ *     patchdata clogger-debugrouter.ldd@KChunkSize 0x20000
+ * Note: In order for this to work, the LDD must be in the core ROM image, ie the IBY file for
+ * clogger-debugrouter.ldd must start device[VARID]=ABI_DIR\BUILD_DIR\clogger-debugrouter.ldd
+
+ */
+
+EXPORT_C extern const TInt KChunkSize = 64 * 1024; // 64KB for now
+EXPORT_C extern const TInt KIsrBufSize = 2048;
+
+EXPORT_C extern const TBool KEnableEarlyRdebug = EFalse; // Alternative to messing with the debug port - inventing new port numbers can confuse some baseports
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/docs/clogger.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,361 @@
+# clogger.pod
+#
+# Copyright (c) 2007-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 Clogger
+
+=head2 Introduction
+
+I<This document describes the underlying clogger log engine. For how to configure clogger from fshell, see L<here|fshell::commands::cloggerconfig>. >
+
+Clogger (pronounced clogger or see-logger) is an alternative logging engine that aims to unify all the disperate logging systems currently used across the system, and to try and improve on them all wherever possible. Clogger has a single log file that everything logs to (using multiple files was one of the major problems with Flogger). It also provides BC stubs for the older logging APIs so that you can use Clogger without needing to modify your source code (although generally it will be neater if you do). Good ideas and useful features from the existing loggers have been included wherever possible, as well as a few new ones.
+
+=head2 Features, or, What can Clogger do that other loggers can't?
+
+=over 4
+
+=item Unified log file
+
+All logging ends up in a single interleaved file. Much nicer than Flogger, similar to CDU. In addition, logging from other logging solutions can be redirected to the unified log, unlike CDU.
+
+=item Integrates with other loggers
+
+Replacement stub DLLs are provided to redirect Flogger and CDU logging into Clogger. RDebug::Print logs can also be redirected, and switched on and off per-thread. No other logging solution offers this (that I am aware of).
+
+=item More focused on performance
+
+Or rather, focused on not impacting the performance of whatever you are trying to get logging from. There have been a number of recent occasions where a problem was unreproducable when the conventional logging was enabled, but when the logging was switched to using clogger it could be successfully reproduced and the problem diagnosed from the log. Even RDebug::Print is faster to call if Clogger's RDebug redirection is enabled (albeit it is no longer synchronous).
+
+Examples of the performance features include: the static functions use TLS to avoid the overhead of repeatedly connecting to the Clogger server (unlike flogger); buffering can be enabled which means the timing overhead of logging calls is very low; when logging is present but disabled the overhead is a single exec call plus a couple of branch instructions (like CDU); in buffered mode file writes are guaranteed to be block aligned and rounded up to the flash block size for maximum performance; 
+
+There is also a separate client library (called clogger-buffered.dll instead of clogger.dll) which uses highly optimised code and has minimal impact on the calling thread. It has reduced functionality and no error handling so is not suitable for general logging, but where it is critical to not affect the timing of the calling thread then you can elect to use this library instead.
+
+=item Easier to use
+
+A contentious claim, but a simple client side API that has lots of logging functions (and not a lot else) goes a long way towards it. Compare the number of macro definitions in CDU's header file for example, then factor in how easy it is to fail to get CDU to log anything at all because you wanted logging in UREL or you forgot to include the mmh file, or you had to change your design because Flogger's static methods give such lousy performance. Or you couldn't copy your log file off the device because it was still being logged to and therefore was in use. Or you had to fiddle around for creating directories or rebooting in order to turn a particular bit of logging on or off, or...
+
+=item Configuration and logging can be toggled at run time
+
+CDU tried with allowing you to overwrite the comsdbg.ini file but it was pretty tedious. Clogger has a proper API for enabling and disabling what is logging, and for configuring the log server. There are command line and (UIQ3) GUI tools so you don't have to call the API directly yourself (see the L<See Also> section for details of these tools.)
+
+=item Multiple output mechanisms are supported at the same time
+
+You can output your logging to RDebug::Print at the same time as writing it to disk and outputting over bluetooth, should you want to. The logging is fully asynchronous so that, for eg, the file writer is not waiting for RDebug to complete before writing the next buffer to disk. Because of the SetGlobalOptions API and the tools that use it, you can toggle the different output mechanisms on and off at runtime.
+
+=item Carbide support!
+
+Ok, not really. But if someone wants to write a carbide plugin that integrates into the Bluetooth logger (or some other way) then it will be straightforward to support it within the server.
+
+=back
+
+=head1 Using the RClogger API
+
+=head2 Logging functions
+
+Summary of the main logging API. Note that there is an overload of every Log function which accepts a TDesC8 and a char*, in addition to the TDesC versions shown below. Every variable argument function also has an overload that takes a VA_LIST, these have been omitted below for clarity. The Log functions take a format string in the same way as RDebug::Printf, RFileLogger::WriteFormat etc. The class and its usage should look pretty familiar to anyone who has used RFileLogger.
+
+Clogger is, like the kernel, deliberately only 8-bit aware. Therefore if you log a 16 bit descriptor containing non-ASCII unicode, the log file will contain a mangled 8-bit version of the string. If you really need to log some unicode, use the HexDump() API. 16-bit descriptors are accepted as input but will be Collapsed into 8-bit.
+
+From C<\epoc32\include\clogger.h>:
+
+    class RClogger: public RSessionBase
+        {
+    public:
+        IMPORT_C void Log(TRefByValue<const TDesC> aFmt, ...);
+        IMPORT_C void HexDump(const TDesC8& aHeader, const TDesC8& aData);
+        
+        IMPORT_C static void Slog(TRefByValue<const TDesC> aFmt, ...);
+        IMPORT_C static void StaticHexDump(const TDesC8& aHeader, const TDesC8& aData);
+        
+        IMPORT_C void Log(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, ...);
+        IMPORT_C void HexDump(TUint32 aLogMask, const TDesC8& aHeader, const TDesC8& aData);
+        
+        IMPORT_C static void Slog(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, ...);
+        IMPORT_C static void StaticHexDump(TUint32 aLogMask, const TDesC8& aHeader, const TDesC8& aData);
+    
+        IMPORT_C RClogger();
+        IMPORT_C TInt Connect(); // If using this overload your thread full name becomes your tag
+        IMPORT_C TInt Connect(const TDesC& aTag); // All logging will be prepended with this tag.
+        
+        // ...
+        };
+
+The first 2 functions listed above (and their equivalents that take a TDesC8/char*) are the most basic interface to Clogger. Usage:
+
+    RClogger clogger;
+    User::LeaveIfError(clogger.Connect(_L("MyLogging")));
+    clogger.Log("This is me doing some logging");
+
+... I<Outputs the following to the clogger log file> :
+
+    2007-06-07 16:44:21.563: [MyLogging] This is me doing some logging
+
+The second 2 functions are the static equivalents, that don't require you to construct an RClogger instance. TLS is used to cache the RClogger object:
+
+    RClogger::Slog(_L("Some static logging");
+    RClogger::StaticHexDump(_L8("Heading "), myData);
+
+... I<Outputs the following to the clogger log file> :
+
+    2007-05-28 14:38:45.794: [MyLogging] Some static logging
+    2007-05-28 14:38:45.794: [MyLogging] Heading 0000 : 43 50 6F 72 64 6C 65 72 BC B3 57 7C 00 00 FA 7F  PlainText
+    2007-05-28 14:38:45.794: [MyLogging]         0010 : 60 21 5C 7C 08 2B 57 7C                          GoesHere
+
+The C<Connect()> function and its static equivalent C<StaticConnect()> are used to give a name to your logging that differentiates it from logging produced by other components in the system. This name is called a tag, you can see above that the tag (in this case "MyLogging") is included on every line of the log file. Logging can be enabled and disabled on a per-tag basis. If finer granularity control over what gets logged is required (eg you have different logging verbosities), Clogger supports an additional 32-bit parameter called the log mask that can be used to subdivide your logging. Example usage:
+
+    enum TLoggingMasks
+        {
+        ELogWarning = 1,
+        ELogUnderflow = 2,
+        ELogError = 4,
+        ELogConnectionFailure = 8,
+        };
+        
+    // ...
+    
+    RClogger::StaticConnect(_L("MyLoggingTag"));
+    RClogger::Slog(ELogConnectionFailure, "A connection failure occurred");
+    RClogger::Slog(ELogWarning, "A warning that probably isn't very interesting and will fill up your log");
+
+The mechanism for enabling and disabling logging allows you to specify what log mask you want to enable, so in the example above you could specify that logging should be enabled for MyLoggingTag, but only for C<ELogError|ELogConnectionFailure>. Log statements that specified C<ELogWarning> would not be recorded in the log. The above code snippet uses the static logging APIs but the non-static ones are treated the same.
+
+When you call one of the logging functions that doesn't take a log mask, such as C<RClogger::Slog("Some Logging")>, it is treated the same as if you'd called C<RClogger::Slog(0x80000000, "Some Logging")>. In other words, the top bit of the log mask implicitly means "any logging which doesn't specify a log mask".
+
+=head2 Configuring Clogger
+
+Note that the APIs in this section are generally only used by the GUI/command line configuration tool. Most of them (with the exception of C<SetLogBehaviour>) have a global effect on all clients of the logger so calling them from within your logging code is almost certainly the wrong thing to do.
+
+    class RClogger: public RSessionBase
+        {
+    public:
+        // ...
+        enum TGlobalOptions {
+            EBufferLog = 1,
+            EMirrorToRDebugPrint = 2,
+            EMirrorToBluetooth = 4,
+            ERedirectRDebugPrintToClogger = 8,
+			EDisableFileWriter = 16,
+        };
+        IMPORT_C void SetGlobalOptions(TUint aGlobalOptions);
+
+EBufferLog determines whether calls to the log functions should be buffered or whether the calls should wait for the log to be written to disk before returning. It is a toss up between performance and the need to collect logs from immediately before the phone crashes. In the future there may be support added to baseports to allow the buffer to be flushed to the crashlog in the event of a crash. The C<EMirror...> options are fairly self-explanatory, if you set them then clogger will echo the log file over a bluetooth serial port or the debug port. Note that C<EMirrorToBluetooth> is unlikely to work properly if you are trying to collect comms logging. C<EMirrorToMessageQueue> is deprecated and should not be used. C<EDisableFileWriter> is useful if you're trying to log something that is dependant on good file server performance - you'd usually combine this another option that allowed you to get the logs off the device, such as C<EMirrorToRDebugPrint> or something that uses C<RCloggerLogConsumer>.
+
+        IMPORT_C void SetRamBufferSize(TInt aSizeInBytes, TInt aNum)
+
+How many linked RAM buffers to use and how big. Defaults to 2 buffers of 4KB each. The log is only written out when the current RAM buffer is full, so a larger buffer may give a performance improvement but will increase latency. There is a 2-second timer on the buffer to ensure that the latency is bounded. The buffers are arranged in a ring structure so that one (or more) can be in the process of being written to disk/bluetooth/etc while another is being logged to. Has no effect if EBufferLog option is not being used.
+
+        enum TLogBehaviour {
+            EUseHeapBuffer = 2,
+        };      
+        IMPORT_C void SetLogBehaviour(TUint aLogBehaviour);
+
+By default RClogger allocates a buffer on the client side to aid formatting without limiting log lines to 256 chars using a stack-allocated buffer (as Flogger/CDU/RDebug do). If it is important that your RClogger doesn't do this, you may disable it on a per-session basis by calling C<SetLogBehaviour(0)> before your first call to any of the Log functions. If you plan on sharing the RClogger object across multiple threads, you must disable C<EUseHeapBuffer> as it is not safe to use if there is any possibility that multiple threads could call Log at the same time. If it disabled then log lines will be silently truncated to 256 characters. The Flogger/CDU compatibility libraries turn this off automatically to be compatible with how RFileLogger is supposed to work. More options may be added to this enum in the future. 
+
+        IMPORT_C TInt SetEnabled(const TDesC& aTag, TUint32 aEnabledMask);
+
+API to allow you to enable and disable logging for a given tag. The convenience variable C<RClogger::EAllEnabled> can be passed in as aEnabledMask to indicate that all logging for the tag should be enabled. To disable all logging, pass in zero. If aTag is not known to clogger (ie has not yet logged anything), this function will try and create the tag (returning KErrNoMemory if the tag could not be created). In all other circumstances returns KErrNone.
+
+There is a special tag called C<KCloggerDefaultTag> (whose value is "DefaultForNewTags") which holds the default setting for anything that connects to the clogger server in the future. This is useful to avoid turning on all your logging at once on boot (ie before you can get to the config tool to disable the bits you don't need). You cannot pass this tag into C<Connect()>, consequently you will never see it in the log. Equally using "Clogger" for your tag is not allowed. If you do pass in a disallowed tag, then the server will fall back to using the threadname, just as if you didn't specify a tag at all.
+
+        enum TRotateBehaviour {
+            EDoNothingSpecial = 0,
+            ECopyRotatedToExternalMedia = 1,
+            EAutoRotateAtStartup = 4,
+            ECompressRotatedLogs = 8,
+        };
+        IMPORT_C void SetRotateBehaviour(TInt aNumberOfOldLogsToKeep, TUint aRotateBehaviour);
+        IMPORT_C TInt Rotate();
+
+The clogger log file is written to C:\logs\clogger.txt. Because that file is permanently kept open by the Clogger server, you cannot directly copy it off the device (unless you use fshell's force copy option). So there is an API to tell Clogger to close the log file, rename it to clogger-TIMESTAMP.txt, and start logging into a fresh clogger.txt file. If C<ECopyRotatedToExternalMedia> is configured then calling C<Rotate()> will copy the old file onto the first external disk it can find, if there are any. (on most devices, this is the D: or E: drive). C<ECompressRotatedLogs> will cause the logs to be GZIP compressed to save disk space (GZIP can be opened by WinZip or UNIX command line zip). Note that the current log file is never compressed, in case the device crashes before the log can be cleanly closed.
+
+        IMPORT_C void PersistSettings();
+        IMPORT_C void ResetSettings();
+        };
+
+You can save all the settings (including what tags are enabled) across reboots by calling C<PersistSettings()>. C<ResetSettings()> will reset all settings to their default values. All the settings are altered immediately, with the exception of what tags are enabled - these are not reset until reboot.
+
+=head1 Architecture
+
+Clogger is a standard client-server setup, the client API RClogger (in clogger.dll) talks to the server (in cloggerserver.exe). The client takes care of checking whether logging is enabled (so as to avoid having to make a client-server call if disabled) then formatting the format string and passing the buffer to the server. The client also takes care of stashing an RClogger handle in TLS when the static functions are called.
+
+The server behaves differently depending on whether EBufferLog has been specified. If it hasn't, then all Log() calls are fully synchronous and will not return until the log string has been written to disk. If it has, then the log string goes into a buffer which is written out asynchronously. An idle timer (currently 2 seconds) ensures that logging does get written out reasonably quickly even if there isn't enough logging to fill the buffer and cause it to be flushed to disk.
+
+Multiple buffers arranged in a ring take care of the fact that the different output mechanisms that may be enabled (file, bluetooth, RDebug::Print) take different times to complete. It also handles the case of logging coming in faster than it can be written out by allocating one or more new buffers and adding them to the ring.
+
+The redirection of RDebug::Print is done by a device driver, clogger-debugrouter.ldd (For more info see the section L<"Base and baseport support"> below). CDU/Flogger/CFlog is done by replacing the client-side library DLL (eg flogger.dll) with one provided by clogger (flogger_clogger_stub.dll in this case). Generally the easiest way of doing this is by changing the flogger IBY to include the Clogger version instead. It is also possible to install the stub on the C drive providing you have a helper tool that can bypass Software Install.
+
+The server writes out to C:\logs\clogger.txt, if the logs directory is not present it will do nothing (other writer mechanisms like RDebug or bluetooth will still work regardless). If you create the logs directory while the device is running clogger will start logging to it without needing to reboot. Rotating the log in order to copy it off the device renames the log file by adding a date and time stamp, eg clogger_2007-07-01_12-23-00.000.txt. Optionally the server can copy the logs to the external media and compress them using GZIP.
+
+Logging statements from Flogger appear in the clogger log file with tag C<[Folder/FileName]>, logging from CDU gets the tag C<[Subsystem:Component]>. If RDebug redirection is enabled, things work a little differently. Internally clogger keeps track of RDebug::Prints and Kern::Printfs via the name of the thread that called it (the same as if the thread had called RClogger::Slog). Thread names are however rather long to include in every log statement, so in the log file clogger will only show the thread ID. If you want to figure out what that thread name actually is, check back in the log as clogger will note it the first time a thread prints. Ie:
+
+    2008-02-07 00:36:13.862: [Clogger] Thread [67] (c32exe::ESock_Bt) has started rdebugging
+    2008-02-07 00:36:14.011: [67] Logging here
+    2008-02-07 00:36:19.810: [67] More logging from this thread...
+    2008-02-07 00:36:19.974: [67] ... only logs the thread ID, [67]
+
+If you want to disable logging from a thread, you should use the threadname, not the ID. In the case above, C<clogger.SetEnabled(_L("c32exe::ESock_Bt"), 0)>. In rare out-of-memory situations, rdebug logging will appear with just C<[RDebug]>. As shown in the example above, Clogger trims the excess from the thread name, it uses C<c32exe::ESock_Bt> instead of the fullname C<c32exe.exe[101f7989]0001::ESock_Bt>.
+
+Logs are all timestamped using the fast tick counter (C<User::FastCounter()>) translated into GMT. The format is:
+
+    2007-05-28 14:38:45.794: [MyLogging] The logging text
+    YYYY-MM-DD HH:MM:SS:MMM: [TAGNAME] The logging text
+
+Where C<MMM> is milliseconds. The timestamp is added on the client side when the call to RClogger::Log (etc) is made so whether buffering is enabled or how busy the server is will make no difference to the timestamp. Because the FastCounter API is not directly related to the system time, changing the system time while the server is running will have no effect on the timestamps, they will still show the time in GMT as it would have been if the clock had not been changed. Because RDebug logging is asynchronous and the timestamp is taken when the logging is done not when the clogger server processes it, RDebug logging may appear out of sequence with respect to non-RDebug logs.
+
+=head2 Performance-critical logging
+
+Occasionally it is necessary to add instrumentation to your code that has a near-zero impact on timing and thread scheduling. If you find that using clogger even in buffered mode alters the timing too much for your needs, clogger does provide an alternative library called clogger-buffered.dll which uses the same API but uses a large RAM buffer to avoid IPC and talking the server. The log routines themselves are also optimised to minimise branching, memory accesses and exec calls.
+
+The performance-critical library clogger-buffered.dll is enabled by changing your MMP to link against clogger-buffered.lib instead of clogger.lib. The static log functions (C<RClogger::Slog>) have been replaced with versions that log to a 2MB mem buffer without causing memory allocations or client-server calls. This means the log functions should return very quickly without blocking the thread or causing it to reshedule. The log functions that take a TDesC16 are not implemented, it made the code more complicated. Calling them (as well as any other error condition that would mean that logging couldn't take place) will cause a panic - the idea being that if you've enabled the performance logging, you either want the logging to work or you want it to fail quickly and noticably. Global variables are used for the RClogger, RChunk and temp buffers. The buffer is flushed when the session is closed (by calling C<RClogger::StaticClose()>) or when the client thread exits. It is not currently thread-safe, if multiple threads in the client try and use the interface at once (unlike the usual RClogger interface, which is). It also skips a bunch of checks and error handling. It will probably panic if the logging exceeds 2MB, or if the formatted log string is over 2KB, or in a dozen other places. If the baseport supports crashdumpareas then the logging chunk will be added to the crashlog.
+
+=head2 Base and baseport support
+
+The kernel-side clogger library (clogger-debugrouter.ldd) is now able to capture Kern::Printf logging that occurs before the cloggerserver has started. This is possible because you can now load clogger-debugrouter.ldd as a kernel extension, this is done by defining the CLOGGER_EARLY_DEBUG rombuild macro. The earlier you put clogger.iby in your master OBY the more logging you will (potentially) capture (because of how extensions are loaded by the kernel). When the debug router loads it will enable RDebug::Print (and Kern::Printf) redirection. Until the clogger server connects to the LDD, the debug output will be cached in the LDD buffer. This allows you to capture debug from early on in the boot process. You must enable rdebug redirection before the debug router's buffers will be read. There are also a couple of APIs that the baseport can use to improve how the logger works. These are defined in F<fshell/debugRouter-kext.h>:
+    
+    namespace CloggerDebugRouter
+    {
+    /* Implementations of these functions should expect to be called in a thread context with the kernel unlocked
+     */
+    typedef void (*TRegisterFn)(TAny* /*aAddr*/, TUint /*aSize*/, SCrashDumpArea& /*aCrashDumpArea*/);
+    typedef void (*TUnregisterFn)(SCrashDumpArea& /*aCrashDumpArea*/);
+    
+    IMPORT_C void SetCrashDumpFunctions(TRegisterFn aRegisterFn, TUnregisterFn aUnregisterFn);
+    };
+
+If the baseport supports adding information to the crashlogs, then clogger can be configured to add the buffers it uses. To configure it, the baseport (or something kernel-side) can call C<CloggerDebugRouter::SetCrashDumpFunctions> passing in appropriate function pointers to register and unregister areas of memory. Clogger will then use these functions to map all its buffers into the log. This functionality is very useful if you need to use buffered logging for performance reasons, but you need to see what was logged immediately before the device crashed (ie before clogger had a chance to flush the buffer). Because of how the RDebug::Print redirection works, the debug prints are always buffered in the LDD, so this support is vital for capturing all the RDebug info. Clogger will add the following sections to the crashlog if SetCrashDumpFunctions has been called:
+
+=over 4
+
+=item RDebug::Print buffer
+
+If RDebug::Print redirection has been enabled, the buffer used to get the debug prints from the kernel to the clogger server.
+
+=item Interrupt handler debugprint buffer
+
+To handle the possiblitily of kernel code calling Kern::Printf during an Interrupt Service Routine, a separate buffer is needed
+
+=item Performance logging chunks
+
+If any clients are using the performance-critical library clogger-buffered.dll, then all the memory chunk used for that will also be saved.
+
+=item "Buffered logging" buffers
+
+If the clogger server is configured to do buffered logging then these buffers are also added.
+
+=back
+
+=head2 Patchable constants
+
+A couple of patchable constants are defined in the debug router LDD. These are:
+
+=over 4
+
+=item * KChunkSize
+
+64KB by default, this is the size of the RDebug::Print buffer. You can modify this by specifying the rombuild argument C<-DCLOGGER_RDEBUG_BUFSIZE=xyz>.
+
+=item * KIsrBufSize
+
+The interrupt handler debugprint buffer size. Defaults to 256 bytes. Please note, the support for patching KIsrBufSize is not yet complete!
+
+=item * KEnableEarlyRdebug
+
+Whether to start logging from the moment the debug router loads. Better to use the rombuild argument C<-DCLOGGER_EARLY_DEBUG> because that also ensures the debug router is loaded as a kernel extension and sets the buffer size.
+
+=back
+
+You may wish to raise KChunkSize, for example, if you need to capture more than 64KB of tracing during bootup, before the cloggerserver has connected. The buffers used by the clogger server's buffered logging are configured either in the cenrep config, or at runtime using the RClogger::SetRamBufferSize API.
+
+On platforms that do not support patchable constants (ie v9.1 or earlier) you cannot use the CLOGGER_EARLY_DEBUG macro, because it relies on a patchable constant. Instead you can set the debugport to 67 (C<KCloggerDebugPort> in F<fshell/debugRouter-kext.h>) to achieve the same thing. This mechanism is only recommended for platforms without patchdata support though.
+
+=head1 Collecting logs
+
+Checklist for using clogger logging:
+
+=over 4
+
+=item 1. Add the logging statements to your code
+
+As appropriate, either by using your existing logging setup (eg flogger/CDU) or by using RClogger directly. The RClogger class behaves identically when called/run from UREL or UDEB, but if you are using macros for your logging ensure they are setup such that your logging is getting called (eg by putting the UDEB binaries in the ROM or by defining USE_CLOGGER etc).
+
+=item 2. Include the clogger IBY(s) in the ROM
+
+The main clogger IBY is \epoc32\rom\include\clogger.iby. If you want to redirect logging from flogger/CDU then you also need to change flogger.iby or commsdbgutil.iby to include xxx_CLOGGER_STUB.DLL instead of the client library flogger.dll or commsdbgutil.dll.
+
+=item 3. Configure clogger to enable the logging you want
+
+Using the command line or GUI configuration tools, or by specifying defaults in the cenrep config. Logging defaults to being on for all tags, so you'll only need to change this if you want to limit the amount of logging you want.
+
+Also remember to turn on RDebug::Print redirection or the other configuration options that you want. Use C<PersistSettings()> as needed. Turn on C<EBufferLog> if desired, depending on whether you want performance or guaranteed logging.
+
+=item 4. Collect your logs
+
+You may wish to call C<Rotate()> immediately before doing the logging you're interested in, so that the log file doesn't contain irrelevant logging. Likewise setting C<EAutoRotateAtStartup> and yanking the battery after you've collected the logs you need is a good way of ensuring that there isn't irrelevant stuff at the end of the log.
+
+=item 5. Retreive the log
+
+Call C<Rotate()> from the command line or gui tool (or C<EAutoRotateAtStartup>) to move your logs to C:\logs\clogger-TIMESTAMP.txt (or D:, or .txt.gz, depending on what options you've configured.). If you configured RDebug::Print or bluetooth logging then you obviously won't need to do this step.
+
+=back
+
+=head2 Rombuild-time configuration
+
+Clogger has a cenrep file which can be used to setup default values for the settings mentioned in L<"Configuring Clogger">. These settings are:
+
+    0 The default TGlobalOptions settings (eg "5" means EMirrorToBluetooth|EBufferLog)
+    1 The default buffer size (as per RClogger::SetRamBufferSize)
+    2 The default number of buffers (as per RClogger::SetRamBufferSize)
+    3 The default number of rotated logs to keep (as per SetRotateBehaviour)
+    4 The default TRotateBehaviour setting (eg "5" means EAutoRotateAtStartup|ECopyRotatedToExternalMedia)
+
+You can also specify what tags are enabled by default using the following syntax. The special tag name C<"**Everything else**"> specifies the default setting for any tags not specified here. Therefore, use this tag to specify whether logging is on or off by default for any new tags. This tag name is defined in clogger.h as C<KCloggerDefaultTag>.
+
+    # This sets the logging mask for MyComponent to 0xFFFFFFFF (ie all logging enabled)
+    0x80000000 string8 "MyComponent" 0
+    0x80000001 int 0xFFFFFFFF 0
+    # This sets the default for everything else to be zero (ie disabled)
+    0x80000002 string8 "**Everything else**" 0
+    0x80000003 int 0 0
+    # Further tags could be specified at location 0x80000004 etc
+
+For setting tags, the first tag must be specified with index 0x80000000, with the tag name being at the even-numbered location and the value at the corresponding odd-numbered location. The actual location used isn't important so long as they're all unique and in the 0x80nnnnnn range. Remember that this cenrep file and the settings in it will only be considered if the settings haven't been saved to the persistant cenrep file on the C drive!
+
+The debug router LDD is configured in the IBY as specified in the L<"Base and baseport support"> section.
+
+=head2 Setting up Bluetooth logging
+
+I<Please note, Bluetooth logging support is not compiled in by default - you'll need to recompile with _USE_BLUETOOTH_ defined in server.mmp>
+
+Using the command line or GUI config tools, ensure that the EMirrorToBluetooth option is enabled.
+
+You will need HyperTerminal or similar running on your PC. On your PC's "My Bluetooth Places" find the relvant phone in "Entire Bluetooth Neighborhood". Open the phone, and double click on "m-Router Connectivity". You will see a dialog saying that COM xx is now connected. If the PC has chosen the correct serial port (it's a bit of a toss-up) the you'll see "Clogger: Bluetooth connected" info print on the device. IF that happens, then you are free to connect Hyperterminal to the COM port that the bluetooth dialog said, and you're good to go.
+
+If however the PC chose the wrong port (and you didn't get an info print on the phone) then you still need to connect to the appropriate port using HyperTerminal. The trick to making it work is to connect in hyperterminal, wait for mrouter to start outputting junk data, then disconnect in hyperterminal and re-try double-clicking on "m-Router Connectivity" in the My Bluetooth Places window. Generally, the PC gets it right second time around.
+
+The reason this is more complicated that it should be is that the PC Bluetooth UI doesn't allow you to make connections to services it doesn't understand, so clogger has to appear to be a "Virtual serial port". This causes problems because m-Router advertises itself in the same way, and the BT UI is not very good when a device advertises multiple instances of the same service. Generally though it does sort itself out and connects you to the right port second time round.
+
+=head1 See also
+
+=over 4
+
+=item L<cloggerconfig|fshell::commands::cloggerconfig>
+
+Command-line tool for configuring Clogger options (built as part of fshell)
+
+=back
+
+=head1 Copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// bld.inf
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+..\inc\clogger.h		\epoc32\include\fshell\clogger.h
+cenrep.txt z:\private\10202BE9\10272EFD.txt
+FSHELL_ROM_INCLUDE(clogger.iby)
+clogger-stub.sis z:\system\install\clogger-stub.sis
+
+PRJ_MMPFILES
+.\lib.mmp
+.\lib-buffered.mmp
+.\server.mmp
+.\flogger.mmp
+.\cdu.mmp
+//.\cflog.mmp
+
+PRJ_TESTMMPFILES
+..\tsrc\tclog.mmp
+//.\clogger_coneplugin.mmp
+
+#include "..\debugrouter\bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/cdu.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// cdu.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+//#ifdef WINS
+//TARGET			COMSDBGUTIL.DLL
+//#else
+TARGET			COMSDBGUTIL_CLOGGER_STUB.DLL
+//#endif
+
+TARGETTYPE		DLL
+UID		        0x1000008d FSHELL_UID_COMSDBGUTIL_CLOGGER_STUB
+CAPABILITY      FSHELL_CAP_MMP_NORMAL
+
+MACRO __CDU__
+
+SOURCE ..\src\flogger.cpp
+
+USERINCLUDE		..\INC
+#include <fshell/fsh_system_include.mmh>
+LIBRARY			EUSER.LIB CLOGGER.LIB
+
+DEFFILE			CDU.DEF
+
+// So that we supercede the flogger on Z:, use a version > 10.0
+VERSION 10.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/cenrep.pkg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+; cenrep.pkg
+; 
+; Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+; 
+; Initial Contributors:
+; Accenture - Initial contribution
+;
+
+#{"Clogger-cenrep"}, (0x10202BE9),1,0,1,TYPE=PU
+
+%{"Tomsci"}
+:"Tomsci"
+
+"\EPOC32\DATA\Z\private\10202BE9\10272EFD.txt"-"C:\private\10202BE9\10272EFD.txt"
Binary file libraries/clogger/group/cenrep.txt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/cflog.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// cflog.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/fsh_system_include.mmh>
+
+TARGET        cflog.dll
+CAPABILITY    FSHELL_CAP_MMP_NORMAL
+TARGETTYPE    dll
+
+#include	"comms-infras\commsdebugutility.mmh"
+
+SOURCEPATH    ..\src
+SOURCE        cflog.cpp
+
+USERINCLUDE   ..\inc
+
+LIBRARY  euser.lib
Binary file libraries/clogger/group/clogger-stub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/clogger-stub.pkg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+; clogger-stub.pkg
+; 
+; Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+; 
+; Initial Contributors:
+; Accenture - Initial contribution
+;
+
+#{"Clogger"}, (0x10272EFD),1,0,1,TYPE=SA
+
+%{"Tomsci"}
+:"Tomsci"
+
+"\epoc32\RELEASE\ARMV5\UREL\cloggerserver.exe"-"Z:\sys\bin\cloggerserver.exe"
+"\epoc32\RELEASE\ARMV5\UREL\clogger.dll"-"Z:\sys\bin\clogger.dll"
+"\epoc32\RELEASE\ARMV5\UREL\clogger-buffered.dll"-"Z:\sys\bin\clogger-buffered.dll"
+
+"\epoc32\RELEASE\ARMV5\UREL\FLOGGER_clogger_stub.DLL"-"Z:\sys\bin\FLOGGER_clogger_stub.DLL"
+"\epoc32\RELEASE\ARMV5\UREL\COMSDBGUTIL_clogger_stub.DLL"-"Z:\sys\bin\COMSDBGUTIL_clogger_stub.DLL"
+
+"\epoc32\RELEASE\ARMV5\UREL\clogger-debugrouter.ldd"-"Z:\sys\bin\clogger-debugrouter.ldd"
+
+
+; No need to bother about cenrep in a stub
+;@"cenrep_signed.sis", (0x10202BE9)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/clogger.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,71 @@
+// clogger.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef CLOGGER_IBY
+#define CLOGGER_IBY
+
+#include <fsh_config.iby>
+
+FSHELL_EXECUTABLE_FILE(CloggerServer.exe)
+FSHELL_EXECUTABLE_FILE(Clogger.dll)
+FSHELL_EXECUTABLE_FILE(Clogger-buffered.dll)
+
+#ifdef FSHELL_CLOGGER_REPLACE_FLOGGER
+FSHELL_RENAMED_EXECUTABLE_FILE(FLOGGER_clogger_stub.DLL, flogger.dll)
+#else
+FSHELL_EXECUTABLE_FILE(FLOGGER_clogger_stub.DLL)
+#endif // FSHELL_CLOGGER_REPLACE_FLOGGER
+
+#ifdef FSHELL_CLOGGER_REPLACE_CDU
+FSHELL_RENAMED_EXECUTABLE_FILE(COMSDBGUTIL_clogger_stub.DLL, comsdbgutil.dll)
+#else
+FSHELL_EXECUTABLE_FILE(COMSDBGUTIL_clogger_stub.DLL)
+#endif
+
+FSHELL_DATA_FILE(ZSYSTEM\install\clogger-stub.sis, system\install\clogger-stub.sis)
+//ToDo - fixme for SIS files.
+#ifdef FSHELL_ROMBUILD
+FSHELL_DATA_FILE(ZPRIVATE\10202BE9\10272EFD.txt, private\10202BE9\10272EFD.txt)
+#endif
+
+#ifdef FSHELL_CLOGGER_SUPPORT_DEBUG_ROUTER
+
+#ifdef CLOGGER_EARLY_DEBUG
+
+// If you  want debug from really early on you'll have to include this IBY nearer the top of the master IBY
+FSHELL_KERNEL_EXTENSION(clogger-debugrouter.ldd)
+
+#ifdef FSHELL_ROMBUILD
+ROM_IMAGE[0] {
+patchdata clogger-debugrouter.ldd@KEnableEarlyRdebug 1
+}
+#endif
+
+#ifndef CLOGGER_RDEBUG_BUFSIZE
+#define CLOGGER_RDEBUG_BUFSIZE 0x80000 // 512KB
+#endif
+
+#else // CLOGGER_EARLY_DEBUG
+
+FSHELL_DEVICE_DRIVER(clogger-debugrouter.ldd)
+
+#endif // CLOGGER_EARLY_DEBUG
+
+#if defined(CLOGGER_RDEBUG_BUFSIZE) && defined(FSHELL_ROMBUILD)
+// Patch this to increase the RDebug::Print buffer size. Default is 64KB, 0x10000
+ROM_IMAGE[0] {
+patchdata clogger-debugrouter.ldd@KChunkSize CLOGGER_RDEBUG_BUFSIZE
+}
+#endif
+
+#endif // FSHELL_CLOGGER_SUPPORT_DEBUG_ROUTER
+
+#endif // CLOGGER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/clogger.pkg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+; clogger.pkg
+; 
+; Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+; 
+; Initial Contributors:
+; Accenture - Initial contribution
+;
+
+#{"Clogger"}, (0x10272EFD),1,0,1,TYPE=SA
+
+%{"Tomsci"}
+:"Tomsci"
+
+"\epoc32\RELEASE\ARMV5\UREL\cloggerserver.exe"-"C:\sys\bin\cloggerserver.exe"
+"\epoc32\RELEASE\ARMV5\UREL\clogger.dll"-"C:\sys\bin\clogger.dll"
+"\epoc32\RELEASE\ARMV5\UREL\clogger-buffered.dll"-"C:\sys\bin\clogger-buffered.dll"
+
+"\epoc32\RELEASE\ARMV5\UREL\FLOGGER_clogger_stub.DLL"-"C:\sys\bin\FLOGGER_clogger_stub.DLL"
+"\epoc32\RELEASE\ARMV5\UREL\COMSDBGUTIL_clogger_stub.DLL"-"C:\sys\bin\COMSDBGUTIL_clogger_stub.DLL"
+
+"\epoc32\RELEASE\ARMV5\UREL\clogger-debugrouter.ldd"-"C:\sys\bin\clogger-debugrouter.ldd"
+
+@"cenrep_signed.sis", (0x10202BE9)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/flogger.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// flogger.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+//#ifdef WINS
+//TARGET			FLOGGER.DLL
+//#else
+TARGET			FLOGGER_CLOGGER_STUB.DLL
+//#endif
+
+TARGETTYPE		DLL
+UID             0x1000008d 0x10004d0a //FSHELL_UID_FLOGGER_CLOGGER_STUB
+CAPABILITY      FSHELL_CAP_MMP_NORMAL
+
+USERINCLUDE ..\inc
+#include <fshell/fsh_system_include.mmh>
+
+SOURCE ..\src\flogger.cpp
+
+deffile flogger.def
+
+LIBRARY euser.lib clogger.lib
+
+// So that we supercede the flogger on Z:, use a version > 10.0
+VERSION 10.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/lib-buffered.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// lib-buffered.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET          clogger-buffered.dll
+TARGETTYPE      dll
+
+UID             0x1000008D FSHELL_UID_CLOGGERBUFFERED
+CAPABILITY      FSHELL_CAP_MMP_NORMAL
+
+USERINCLUDE ..\inc
+#include <fshell/fsh_system_include.mmh>
+
+SOURCEPATH ..\src
+SOURCE SensibleClient.cpp
+SOURCE CloggerClient.cpp
+SOURCE PerformanceCritical.cpp
+
+MACRO PERFORMANCE_CRITICAL
+EPOCALLOWDLLDATA
+
+DEFFILE		clogger.def
+
+LIBRARY         euser.lib
+LIBRARY			bafl.lib
+LIBRARY			estor.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/lib.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// lib.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET          clogger.dll
+TARGETTYPE      dll
+
+UID		0x1000008D FSHELL_UID_CLOGGER
+CAPABILITY FSHELL_CAP_MMP_NORMAL
+
+USERINCLUDE ..\inc
+#include <fshell/fsh_system_include.mmh>
+
+SOURCEPATH ..\src
+SOURCE SensibleClient.cpp
+SOURCE CloggerClient.cpp
+
+
+LIBRARY         euser.lib
+LIBRARY			bafl.lib
+LIBRARY			estor.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/server.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+// server.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET		cloggerserver.exe
+TARGETTYPE	exe
+EPOCHEAPSIZE	0x1000 0x400000 // 4kB - 4MB
+
+UID		0x0 FSHELL_UID_CLOGGERSERVER
+
+SOURCEPATH	..\src
+SOURCE		SensibleServer.cpp
+SOURCE		CloggerServer.cpp
+SOURCE		MiscServer.cpp
+SOURCE		SessionWriter.cpp
+
+USERINCLUDE	..\inc
+#include <fshell/fsh_system_include.mmh>
+USERINCLUDE	..\debugrouter
+
+LIBRARY		euser.lib efsrv.lib bafl.lib hal.lib
+LIBRARY		centralrepository.lib
+LIBRARY		estor.lib
+#ifdef FSHELL_EZLIB_SUPPORT
+LIBRARY		ezlib.lib
+#endif
+LIBRARY		ltkutils.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/group/tclog.pkg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,20 @@
+; tclog.pkg
+; 
+; Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+; 
+; Initial Contributors:
+; Accenture - Initial contribution
+;
+
+#{"TClog"}, (0x10272F03),1,0,1,TYPE=SA
+
+%{"Tomsci"}
+:"Tomsci"
+
+"\epoc32\RELEASE\ARMV5\UREL\tclog.exe"-"!:\sys\bin\tclog.exe"
+
+@"..\group\clogger-SIGNED.sis", (0x10272EFD)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/CliServ.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,146 @@
+// CliServ.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef CLISERV_H
+#define CLISERV_H
+
+#include <fshell/common.mmh>
+
+_LIT(KMyServerName,"CloggerServer");
+_LIT(KMyServerImg,"CloggerServer");		// DLL/EXE name
+const TUid KServerUid3 = { FSHELL_UID_CLOGGERSERVER };
+const TUid KCloggerUid = { FSHELL_UID_CLOGGERSERVER };
+
+enum TPubSubKeys
+	{
+	ESequenceNumber,
+	
+	EDebugRouterPtr = 1000, // Used only be debug router, included here for completeness
+	};
+
+#if defined(__WINS__) && !defined(EKA2)
+const TInt KMyServerStackSize=0x2000;			//  8KB
+const TInt KMyServerInitHeapSize=0x1000;		//  4KB
+const TInt KMyServerMaxHeapSize=0x1000000;		// 16MB
+#endif
+
+enum TOpPanic
+	{
+	EPanicBadDescriptor,
+	EPanicIllegalFunction,
+	ENotRegisteredForLogs,
+	};
+
+
+#ifdef HIDE_TSERVERSTART_FROM_DAMN_EIKSERVER
+
+class TServerStart;
+
+#else
+
+class TServerStart
+	{
+public:
+	TServerStart(TRequestStatus& aStatus);
+	TPtrC AsCommand() const;
+
+	TServerStart();
+	TInt GetCommand();
+	void SignalL();
+private:
+	TThreadId iId;
+	TRequestStatus* iStatus;
+	};
+
+#endif
+
+#define DISOWN(x) { delete x; x = NULL; }
+
+enum TCallbackCode
+	{
+	ETagEnabledChanged,
+	};
+
+/* Types:
+ */
+class TServerCallback
+	{
+public:
+	TServerCallback() : iContextLength(0), iData() {}
+	TServerCallback(TCallbackCode aCode) : iCode(aCode), iContextLength(0), iData() {}
+
+	TCallbackCode iCode;
+	TInt iContextLength;
+	TBuf8<40> iData;
+	};
+
+/* Format of stuff in iData above (and any context) is a one character code (below) which identifies the type, 
+ * followed by the data for that type. 16-bit descriptors are automatically 2-byte aligned. (If you didn't know 
+ * this was a requirement to construct a TPtrC16, well you've learned something)
+ * Types are:
+ * i - TInt
+ * u - TUint
+ * P - TPoint
+ * S - TSize
+ * G - TRgb
+ * R - TRect
+ * D - TDesC16 (an 'i' followed by an int is written first for the length of the descriptor)
+ * 8 - TDesC8  (an 'i' followed by an int is written first for the length of the descriptor)
+ */
+
+enum TOpCode
+	{
+	EDummy, // Does nothing, just completes with no error
+	ERegisterCallbackNotifier = 1, // [TPkg<TServerCallback>]
+	EGetCallbackContext, // [TDes8]
+	EWriteCallbackResultAndReregister, // [TPkg<TServerCallback>, TDesX, len]
+	ECancelCallbackNotifier, // []
+	//EMultiball, // [a number of IPC args packaged in a TDesC8, num, TDes8 result, result len] async. result must be big enough to handle all the results from the IPC.
+
+	ESetTag, // [tag, secondLevelTag, TPckg<enabledMask>] returns sequence number that the enabledMask is valid for, or error
+	ESetTag8, // [tag, secondLevelTag, TPckg<enabledMask>]
+	ELog8, // [text, tickcount, logMask]
+	ESetEnabled, // [tag, logMask]
+	EIsEnabled, // [tag, TPkg<logMask>]
+	//ETailLogToRDebug, // [numChars]
+	//ETailLogToBuf, // [buf]
+	ESetGlobalOptions, // [flags]
+	EGetGlobalOptions, // []
+	ESetRamBufferSize, // [size, num]
+	EGetRamBufferSize, // [TPkg<size, num>]
+	ESetRotateBehaviour, // [numLogs, flags]
+	ERotate, // [filename(optional)]
+	EPersistSettings, // []
+	EResetSettings, // []
+	EGetTagStates1, // [TPkg<TServerCallback: enabledTagsBuf, tags...>]
+	EGetTagStates2, // [&context]
+	ESetTagStates, // [RBufStream: numTags, enabledTagsBuf, tags...]
+	EGetRotateBehaviour, // [TPkg<behaviour, numLogs>]
+	EHexDump, // [header, data, tickcount, logMask]
+	EUpdateEnabledMask, // [TPkg<logMask>]
+	ERegisterPerformanceLoggingChunk, // [chunkHandle]
+	ECreatePerformanceLoggingChunk, // [size]
+
+	EStartSessionWriterServer, //[]
+	ERegisterForLogMessages, // []
+	EGetNextLog, // [TPckg<TPtrC8>(aResultBuffer), sharedChunkBase]
+	ECancelGetNextLog, // []
+
+	EDebugAlignLogFile = 2000, // [lessThisAmount]
+	EDebugShutdownServer, // 2001, []
+	EHexDump16, // 2002, [header16, data, tickcount, logMask]
+	EDebugForceBreakpointInServiceL, // 2003
+	};
+
+_LIT(KSessionLogServer, "CloggerSessionLogServer");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/Clogger.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,233 @@
+// Clogger.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef CLOGGER_H
+#define CLOGGER_H
+
+#if defined(_DEBUG) && !defined(USE_CLOGGER)
+#define USE_CLOGGER
+#endif
+
+#ifdef __cplusplus
+
+#include <e32std.h>
+
+class CDesC16Array;
+
+class RClogger: public RSessionBase
+	{
+public:
+	/*
+	 * Logging commands
+	 */
+	
+	IMPORT_C void Log(TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C void Log(TRefByValue<const TDesC8> aFmt, ...);
+	IMPORT_C void Log(const char* aFmt, ...);
+	IMPORT_C void LogList(TRefByValue<const TDesC> aFmt, VA_LIST aList);
+	IMPORT_C void LogList(TRefByValue<const TDesC8> aFmt, VA_LIST aList);
+	IMPORT_C void LogList(const char* aFmt, VA_LIST aList);
+	IMPORT_C void HexDump(const TDesC8& aHeader, const TDesC8& aData);
+	
+	IMPORT_C void Log(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C void Log(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, ...);
+	IMPORT_C void Log(TUint32 aLogMask, const char* aFmt, ...);
+	IMPORT_C void LogList(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, VA_LIST aList);
+	IMPORT_C void LogList(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, VA_LIST aList);
+	IMPORT_C void LogList(TUint32 aLogMask, const char* aFmt, VA_LIST aList);
+	IMPORT_C void HexDump(TUint32 aLogMask, const TDesC8& aHeader, const TDesC8& aData);
+
+	enum TLogBehaviour {
+		/* This flag is no longer needed, and has no effect
+		 */
+		EMonitorTagState = 1,
+			
+		/* If set, a heap buffer will be allocated (and cached between calls) 
+		 * so that arbitrary sized strings can be logged. If it is not set, a 
+		 * fixed 256-character buffer on the stack will be used and anything
+		 * longer will be silently truncated. It means memory doesn't have to 
+		 * be allocated in the client thread (which is good for performance, 
+		 * and also means RClogger instances can be shared between threads).
+		 *
+		 * Note: an RClogger instance CANNOT be shared by multiple threads 
+		 * if this flag is set.
+		 *
+		 * This flag is set by default.
+		*/
+		EUseHeapBuffer = 2,
+
+		ETrimTrailingNewlines = 4,
+	};
+		
+	IMPORT_C void SetLogBehaviour(TUint aLogBehaviour);
+	
+	/*
+	 * These APIs use TLS to cache an RClogger session. The first time they 
+	 * are called they will create a session, store it in TLS, and call
+	 * Connect() on it. They then call the non-static function of the same
+	 * name on that session. These functions will not allocate any memory
+	 * in the client heap unless SetStaticLogBehaviour is called with
+	 * EUseHeapBuffer. In other words the EUseHeapBuffer
+	 * flag is NOT set by default when calling the static functions.
+	 *
+	 * You can also call RClogger::StaticConnect(tag) to assign a tag to the
+	 * static session
+	 */
+	
+	IMPORT_C static void Slog(TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C static void Slog(TRefByValue<const TDesC8> aFmt, ...);
+	IMPORT_C static void Slog(const char* aFmt, ...);
+	IMPORT_C static void SlogList(TRefByValue<const TDesC> aFmt, VA_LIST aList);
+	IMPORT_C static void SlogList(TRefByValue<const TDesC8> aFmt, VA_LIST aList);
+	IMPORT_C static void SlogList(const char* aFmt, VA_LIST aList);
+	IMPORT_C static void StaticHexDump(const TDesC8& aHeader, const TDesC8& aData);
+
+	IMPORT_C static void Slog(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C static void Slog(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, ...);
+	IMPORT_C static void Slog(TUint32 aLogMask, const char* aFmt, ...);
+	IMPORT_C static void SlogList(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, VA_LIST aList);
+	IMPORT_C static void SlogList(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, VA_LIST aList);
+	IMPORT_C static void SlogList(TUint32 aLogMask, const char* aFmt, VA_LIST aList);
+	IMPORT_C static void StaticHexDump(TUint32 aLogMask, const TDesC8& aHeader, const TDesC8& aData);
+	
+	IMPORT_C static void SetStaticLogBehaviour(TUint aLogBehaviour);
+	IMPORT_C static TInt StaticConnect(); // This is implicitly called if you call Slog when not connected
+	IMPORT_C static TInt StaticConnect(const TDesC& aTag);
+	IMPORT_C static void StaticClose(); // Cleans up TLS, deallocates memory, closes the TLS session
+		
+	/*
+	 * Configuring logging on the fly - APIs for a gui config tool to use
+	 */
+
+	static const TUint32 EAllEnabled = 0xFFFFFFFFu;
+	
+	IMPORT_C TInt SetEnabled(const TDesC& aTag, TUint32 aEnabledMask);
+	IMPORT_C TUint32 IsEnabled(const TDesC& aTag); // Non-existant tags will return all true, ie 0xFFFFFFFF, because if someone did create it later, it would default to being enabled). Failure to connect to the server will return false (because we can't log!)
+	
+	IMPORT_C void GetTagStatesL(CDesC16Array*& aTagNames, RBuf8& aEnabled); // aTagNames and aEnabled will be zeroed/deleted before being used. aEnabled is a bitfield of the enabled states (32 bits per tag in aTagNames)
+	IMPORT_C void SetTagStatesL(const CDesC16Array* aTagNames, const TDesC8& aEnabled); // Any tag names not yet known to clogger will (in the current implementation) be ignored. aEnabled[0..4] is the enabled mask for aTagNames[0], aEnabled[4..8] is for aTagNames[1] etc
+	
+	/*
+	 * Global logging options (ones that affect all users of Clogger)
+	 */
+	 
+	enum TGlobalOptions {
+		// All these options default to being unset
+		EBufferLog = 1, // If set, use a RAM buffer for increased performance. If unset, writes are guaranteed to be flushed to disk before Log() returns. Default is not to buffer.
+		ERDebugPrint = 2, // Deprecated because the name is no longer clear given we have ERedirectRDebugPrintToClogger as well. Use EMirrorToRDebugPrint instead.
+		EMirrorToRDebugPrint = 2, // Mirror all logging to RDebug::Print. Note enabling this may impact performance as RDebug can be quite slow. If EBufferLog is enabled as well the RDebug printing will be done from the buffer in a separate thread, which should mean performance is not affected unless the clogger serve runs out of memory to buffer the output
+		EMirrorToBluetooth = 4, // Outputs to a bluetooth serial port. The logger is dormant until something connects to the port
+		EMirrorToMessageQueue = 32, // This outputs the log data to an RMsgQueue. Caution is advised, you should not turn on this option unless you know what you're doing!
+		ERedirectRDebugPrintToClogger = 8, // Mirrors Kern::Printf and RDebug::Print to the clogger log file. May be combined with EMirrorToRDebugPrint, in which case all RDebug::Print calls *except* ones made by clogger itself are redirected
+		EDisableFileWriter = 16, // Set this option to disable writing to the log file. Useful for debugging out-of-disk problems assuming you're using EMirrorToRDebugPrint 
+	};
+ 		
+	IMPORT_C void SetGlobalOptions(TUint aGlobalOptions);
+	IMPORT_C TUint GetGlobalOptions();
+	
+	IMPORT_C TInt GetRamBufferSize(TInt* aNumberOfBuffers);
+	IMPORT_C void SetRamBufferSize(TInt aSizeInBytes, TInt aNum); // If buffering is enabled the server will use this many buffers of this size
+	
+	/*
+	 * Configuring rotation on the fly
+	 */
+	 
+	IMPORT_C TInt Rotate();
+	IMPORT_C TInt Rotate(TDes& aFileName); // On success aFileName will be set to the name of the rotated log
+
+	enum TRotateBehaviour {
+		EDoNothingSpecial = 0,
+		ECopyRotatedToExternalMedia = 1,
+		EAutoRotateAtStartup = 4,
+		ECompressRotatedLogs = 8, // Currently uses GZip compression on the rotated log files
+	};
+		
+	IMPORT_C void SetRotateBehaviour(TInt aNumberOfOldLogsToKeep, TUint aRotateBehaviour); // First argument of zero means don't keep any. If you don't want to ever delete the old logs, use A Big Number
+	IMPORT_C TUint GetRotateBehaviour(TInt* aNumberOfOldLogsToKeep);
+	
+	/*
+	 * General
+	 */
+	IMPORT_C RClogger(); 
+	IMPORT_C TInt Connect(); // If using this overload your thread full name becomes your tag
+	IMPORT_C TInt Connect(const TDesC& aTag); // All logging will be prepended with this tag. Multiple clients may use the same tag.
+	IMPORT_C void Close();
+	
+	IMPORT_C void PersistSettings(); // Store enabled and rotate settings for next boot
+	IMPORT_C void ResetSettings(); // Restore all settings to default, including stored ones (ie PersistSettings is implicitly called)
+
+	IMPORT_C TInt Reserved(TInt aCode, TAny*& aArg, TAny* aArg2); // Reserved, do not call or you will get panicked
+	IMPORT_C static TInt StaticReserved(TInt aCode, TAny*& aArg, TAny* aArg2); // Reserved, do not call or you will get panicked
+
+private:
+	static TBool GetTls(RClogger*& aClogger, TBool aAutoConnect, const TDesC* aTag = NULL, TInt* aError = 0);
+	inline TBool Enabled(TUint32);
+	void UpdateEnabled(TInt aSequence);
+	IMPORT_C RClogger(TAny* aTls); // Do not call directly
+
+protected:
+	TUint iFlags;
+	TUint32 iEnabled;
+	RBuf8 iBuf;
+	TUint32 iPimpl[2]; // an RCloggerBody
+	TUint32 iSpare;
+	TInt iSequence;
+
+	friend class RCloggerBody;
+	};
+
+_LIT(KCloggerDefaultTag, "DefaultForNewTags"); // This tag controls the default value for the enabled mask of things that start logging for the first time
+
+#ifdef USE_CLOGGER
+#define SLOG(args...) RClogger::Slog(args)
+#else
+#define SLOG(args...)
+#endif
+
+#ifdef USE_CLOGGER
+// Debatable whether you'd want/need these
+#define CLOGGER_STATICCONNECT(aTag) RClogger::StaticConnect(aTag)
+#define CLOGGER_STATICCONNECTL(aTag) User::LeaveIfError(RClogger::StaticConnect(aTag))
+#define CLOGGER_STATICCLOSE() RClogger::StaticClose()
+#else
+#define CLOGGER_STATICCONNECT(aTag)
+#define CLOGGER_STATICCONNECTL(aTag)
+#define CLOGGER_STATICCLOSE()
+#endif
+
+class RCloggerLogConsumer : public RSessionBase
+	{
+public:
+	/*
+	 * API for clients that want the logging data - not for general usage!
+	 */
+	IMPORT_C RCloggerLogConsumer();
+	IMPORT_C TInt Connect();
+	IMPORT_C void GetNextLog(TRequestStatus& aStatus, TPtrC8& aResultBuffer);
+	IMPORT_C void CancelGetNextLog();
+	IMPORT_C void Close();
+
+private:
+	RChunk iSharedChunk;
+	TPtr8 iResultBufferPtr;
+	};
+
+extern "C" IMPORT_C void Clogger_Slog(const char* aFmt, ...);
+
+#else // __cplusplus
+
+IMPORT_C void Clogger_Slog(const char* aFmt, ...);
+
+#endif // __cplusplus
+
+
+#endif // CLOGGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/CloggerServer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,385 @@
+// CloggerServer.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef CLOGGERSERVER_H
+#define CLOGGERSERVER_H
+
+#include "SensibleServer.h"
+#include <babitflags.h>
+#include <e32hashtab.h>
+#include <e32msgqueue.h>
+#include "debugrouter.h"
+
+class CCloggerServer;
+class MWriter;
+class CLogsDirWatcher;
+class CSyncWriterWrapper;
+class CDebugRouterClient;
+class CSessionWriter;
+class CSessionWriterSession;
+class CSessionWriterServer;
+
+class CCloggerSession : public CSensibleSession
+	{
+public:
+	CCloggerSession();
+
+private:
+	TBool DoServiceL(const RMessage& aMessage);
+
+	inline CCloggerServer& Server();
+	~CCloggerSession();
+
+public:
+	TAny* iContext;
+	RBuf8 iGetTagStatesContext;
+	RChunk iPerformanceLoggingChunk; // Only used by the high performance logging library clogger-buffered.dll
+	};
+
+class CCloggerServer : public CSensibleServer
+	{
+public:
+	CCloggerServer();
+	~CCloggerServer();
+	void ConstructL();
+
+	TBool DoServiceL(const RMessage& aMessage);
+
+	// Functions to be called by the session
+	inline RBuf8& SessionTempBuf() { iSessionTempBuf.Zero(); return iSessionTempBuf; }
+	void Log(TAny* aContext, const TDesC8& aLine, TUint32 aTickCount); // aContext can be NULL to indicate KCloggerTag
+	TUint32 TagEnabled(const TAny* aContext, TInt* aCurrentSequenceNumber = NULL);
+	void WriteCallbackForGetTagStatesL(TCallbackWriter& aWriter);
+	TAny* NewSessionForTagL(HBufC8* aTag); // Takes ownership at end. Returns an opaque identifier for this tag (which may have been shared with other sessions)
+	TAny* NewSessionForTag(HBufC8* aTag);
+	void ReplaceTagL(TAny*& aCurrentContext, HBufC8* aNewTag); // If the tag for aCurrentContext hasn't been used yet, deletes it from the tag list. In either case, it then calls NewSessionForTagL. Takes ownership of both arguments if nothing leaves
+	void DropSession(CCloggerSession* aSession);
+	void HexDumpL(TAny* aContext, const TDesC8& aHeader, const TDesC8& aData, TUint32 aTickCount);
+	void RegisterDisabledLog(TAny* aContext);
+	void UpdatedBuffers(TBool aAboutToCloseBuffers=EFalse); // Registers the log buffers with the debug router, so they can be recorded in a crash log (if supported by the baseport)
+	TInt CreateKernChunkForClient(RThread* aClient, TInt aMaxSize, TInt aCommittedSize, RChunk& aOurChunk);
+	CSessionWriter* RegisterSessionWithSessionWriter(CSessionWriterSession* aSession);
+	RChunk& GetBufChunk();
+	static void ThreadPrettyName(TDes8& aName);
+	TBool ForceBreakpointRequested() const;
+
+	void LogsDirHasBeenCreated();
+	void ResetIdleWriteTimer();
+
+	// Functions to be called by writers (eg CLogFile, RDebug::Print thingy)
+	const TDesC8& GetBuf(TInt aIdx); // Increments ref count. May be called from other threads
+	void CompletedWritingBuf(MWriter* aWriter, TInt aBuf); // Tells the server that aWriter has finished writing aBuf. If all writers have finished with this buffer then the buffer is marked ready to use. Must be called from main thread.
+	TDes& GetFilenameToRotate(); // Should only be called by iCompressor, but may be called from its SyncWriter thread. iCompressor should update the name to indicate the new file it has created (so that ECopyRotatedToExternalMedia will work)
+
+	void LogKernMessage(TUint8 aWhere, TUint32 aTickCount, TUint aThreadId, const TDesC8& aMsg); //  Should only be called by CDebugRouterClient
+	void LogHighPerformanceBuffer(const TDesC8& aBuf);
+	void LogError(TRefByValue<const TDesC8> aFmt, ...);
+
+private:
+	TInt TransientServerShutdownTime() const;
+	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+	void LogLine(const TDesC8& aLine);
+	void CloseBuffers(); // Deletes all buffers and removes them from iBufs
+	void FlushBuffers();
+	void GotoNextBufL(); // Sets iCurrent to the next empty buffer, or allocates one if there isn't a free one. Also tells writers to get cracking if they aren't already busy
+	void GetSettingsL();
+	void DoGetSettingsL();
+	void PersistSettingsL();
+	void ResetSettingsL();
+	void UpdateBufferSizeL(TInt aSize, TInt aNum);
+	static TInt StaticIdleTimerExpired(TAny* aThis);
+	void IdleTimerExpired();
+	TUint GetEnabledWriters() const;
+	void Rotate(const RMessage* aMessage = NULL);
+	void LogNote(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, ...);
+	void DoLogErrorOrNote(TUint32 aLogMask, const TDesC8 &aFmt, VA_LIST args);
+	void CopyLogToExternalMediaL(TDes& aFile);
+	class TTagData; // I see now why the coding standards say declare inner classes etc at the start of the class declaration...
+	void NotifySessionsOfChangedTag(TTagData* aTag);
+	void SetKernelLoggingL(TBool aEnable);
+	void UpdatedGlobalOptionsL(TUint aOldOptions);
+	void TellAllWritersToWriteBuf(TInt aBuf);
+	void TellWriterToWriteBuf(TInt aWriterId, TInt aBuf);
+	void ReCalculateFileAlignment();
+	TInt OpenLogFile();
+	TInt AdjustBufferChunk(TInt aNewSize);
+	inline TTime TickCountToTime(TUint32 aTickCount) const;
+
+private:
+	// Buffers
+	class TBufEntry {
+	public:
+		TBufEntry() : iBuf(NULL, 0), iArrayIdx(-1), iNext(NULL), iBufferBusy(0) {}
+
+		//RBuf8 iBuf;
+		TPtr8 iBuf;
+		TInt iArrayIdx;
+		TBufEntry* iNext;
+		TUint iBufferBusy; // This is used to track when all the different consumers of the buffer (RDebug, Bluetooth, File etc) are finished with it
+		};
+	RPointerArray<TBufEntry> iBufs;
+	TBufEntry* iCurrent;
+	TInt iSubtractSizeOfNextBuffer;
+	RBuf8 iSessionTempBuf; // Used by sessions for reading descriptor from client
+	RBuf8 iTempBuf; // Used for formatting line with timestamp and tag
+	RChunk iChunkForBufs; // Use a separate chunk so we can map into crashlogs
+
+	// Miscellaneous stuff used when doing flushes and sync writes
+	CActiveSchedulerWait iFlushBufferWait;
+	const TDesC8* iSyncWriteBuffer; // This is only used when doing synchronous writing. If not for the OOM handling behaviour of LogLine, it would always be equal to &iTempBuf
+	TUint iSyncWriteBufferBusy;
+	CPeriodic* iIdleWriteTimer;
+
+	// Log file
+	RFs iFs; // A couple of things assume the session path is always in the log directory on the c drive
+	RFile iLogFile;
+	CLogsDirWatcher* iLogsDirWatcher;
+	RPointerArray<MWriter> iWriters;
+	TFileName iFileBeingRotated; // This is used to temporarily store the name of a file while it's being rotated and possibly compressed
+	CSyncWriterWrapper* iCompressor;
+	RMessagePtr2 iRotationMessage; // To be completed when the log file compression finishes
+
+	// Settings
+	TUint iOptions; // TGlobalOptions
+	TBitFlags32 iFlags;
+	TInt iBufferSize;
+	TInt iNumBuffers;
+	TInt iNumRotates;
+	TUint iRotateBehaviour;
+	TInt64 iStartupTickInMicroseconds;
+	TTime iTimeAtStartup;
+	TInt iTickFreq;
+	// Tags
+	class TTagData
+		{
+	public:
+		TTagData(HBufC8* aName) : iTagName(aName), iRefCount(0), iEnabled(0), iThreadIdForRDebugger(0), iFlags() {}
+		void SetShouldDisplay() { iFlags.Set(EShouldDisplay); }
+		TBool ShouldDisplay() const { return iFlags.IsSet(EShouldDisplay); }
+
+		HBufC8* iTagName;
+		TInt iRefCount;
+		TUint32 iEnabled; // bitmask
+		TUint iThreadIdForRDebugger;
+	private:
+		enum TFlags {
+			EShouldDisplay, // Indicates this tag should be exposed to the client via GetTagStatesL
+			};
+		TBitFlags32 iFlags;
+		};
+
+	RPtrHashMap<TDesC8, TTagData> iTags; // Keys are the tag names, values are TTagDatas
+	RHashMap<TUint, TTagData*> iRDebugTags;
+	CDebugRouterClient* iKernDebugRouter;
+	TTagData* iRDebugTag; // Is always set. Only used in OOM conditions when we can't create a threadid&name tag
+	TTagData* iFallbackTag; // Always set. This tag represents the default enabled state for any new tags that appear while we're running
+	TTagData* iCloggerTag; // Always set. Used to figure out the internal logging mask (previously used iInternalLoggingMask)
+
+	CSessionWriterServer* iSessionWriterServer; // Support for the session writer
+	TInt iEnabledStatesSequenceNumber;
+	};
+
+#define MINTAGSTART "---------- --:--:--.---: [Clogger] " // Writers can use this too, if they want to
+
+class MSyncWriter
+	{
+public:
+	/*
+	 * Synchronously writes aBuf. Can leave to indicate failure (although the failure may well be ignored)
+	 */
+	virtual void WriteBufL(const TDesC8& aBuf) =0;
+	
+	/*
+	 * delete writer and all resources.
+	 */
+	virtual void CloseWriter() =0;
+	};
+
+class MWriter
+	{
+public:
+	/*
+	 * Start writing aBuf. The server guarantees not to call this if the plugin is not enabled (as defined by a call
+	 * to IsEnabled()) or if the plugin is already busy writing something else (as defined by IsBusyWriting()).
+	 * If the writer is enabled and not currently writing something else, but is unable to perform the write,
+	 * then it should call CompletedWritingBuf before returning, to indicate that the server shouldn't wait for it.
+	 *
+	 * All calls to WriteBuf must be matched by a call to CompletedWritingBuf.
+	 */
+	virtual void WriteBuf(TInt aBuf) =0;
+
+	virtual void CloseWriter() =0; // delete writer and all resources. Will never be called while a write is in progress.
+
+	/*
+	 * Enables complex writers to take action when they are disabled.
+	 * Writers must honour this setting by returning immediately when a write function is called when they are disabled.
+	 * This may be called when a write is in progess - if so the write of the current buffer should complete as normal, it
+	 * should just update its internal flag so that next time the server calls WriteBuf it returns immediately
+	 *
+	 * Generally though SetEnabled will simply update an iEnabled member variable
+	 *
+	 * Writers will get a call to SetEnabled after they are constructed, before WriteBuf is called for the first time.
+	 */
+	virtual void SetEnabled(TBool aEnabled) =0;
+	virtual TBool IsEnabled() =0;
+
+	virtual TBool IsBusyWriting() =0;
+	};
+
+class CLogWriter : public CActive, public MWriter
+	{
+public:
+	CLogWriter(CCloggerServer& aServer, RFile& aFile)
+		: CActive(EPriorityHigh), // It's more important to keep writing than to handle clientserver calls
+		iServer(aServer), iFile(aFile), iBuf(-1), iEnabled(EFalse)
+		{
+		CActiveScheduler::Add(this);
+		}
+
+	void WriteBuf(TInt aBuf);
+	void DoCancel();
+	void RunL();
+	void SetEnabled(TBool aEnabled);
+	TBool IsEnabled() { return iEnabled; }
+	void CloseWriter();
+	~CLogWriter();
+	TBool IsBusyWriting();
+		
+private:
+	CCloggerServer& iServer;
+	RFile& iFile;
+	TInt iBuf;
+	TBool iEnabled;
+	};
+
+class CRDebugWriter : public CBase, public MSyncWriter
+	{
+public:
+	CRDebugWriter(CCloggerServer& aServer);
+	void WriteBufL(const TDesC8& aBuf);
+	void CloseWriter();
+
+private:
+	CCloggerServer& iServer;
+	};
+
+class CMessageQueueWriter : public CBase, public MSyncWriter
+	{
+public:
+	static CMessageQueueWriter* NewL();	
+	void WriteBufL(const TDesC8& aBuf);
+	void CloseWriter();
+
+private:
+	CMessageQueueWriter();
+	~CMessageQueueWriter();
+
+private:
+	RMsgQueue<TBuf8<128> > iQ;
+	};
+
+class CSessionWriter : public CBase, public MWriter
+	{
+public:
+	CSessionWriter(CCloggerServer& aServer);
+	~CSessionWriter();
+
+	void WriteBuf(TInt aBuf);
+	void DoCancel();
+	void RunL();
+	void SetEnabled(TBool aEnabled);
+	TBool IsEnabled() { return iEnabled; }
+	void CloseWriter();
+	TBool IsBusyWriting();
+
+	void Completed();
+
+public:
+	CSessionWriterSession* iSession; // Support only one session
+
+private:
+	CCloggerServer& iServer;
+	TInt iBuf;
+	TBool iEnabled;
+	};
+
+class CSyncWriterWrapper : public CActive, public MWriter
+	{
+public:
+	static CSyncWriterWrapper* NewL(CCloggerServer& aServer, MSyncWriter& aWriter, TInt aWriterId); // Takes ownership of aWriter at end
+	void WriteBuf(TInt aBuf);
+	void DoCancel();
+	void RunL();
+	void SetEnabled(TBool aEnabled);
+	TBool IsEnabled() { return iEnabled; }
+	void CloseWriter();
+	~CSyncWriterWrapper();
+	TBool IsBusyWriting();
+
+private:
+	CSyncWriterWrapper(CCloggerServer& aServer, MSyncWriter& aWriter);
+	void ConstructL(TInt aWriterId);
+	static TInt ThreadFunction(TAny* aSelf);
+private:
+	CCloggerServer& iServer;
+	MSyncWriter& iWriter;
+	TInt iBuf;
+	TBool iEnabled;
+	RThread iMainThread;
+	RThread iWorkerThread;
+	TRequestStatus iThreadStatus;
+	TBool iOwnWriter; // Bit of a cludge to ensure ownership of aWriter is correct
+	};
+
+class CLogCompressor : public CBase, public MSyncWriter
+	{
+public:
+	static CLogCompressor* NewLC(CCloggerServer& aServer);
+	~CLogCompressor();
+	void WriteBufL(const TDesC8& aBuf);
+	void CloseWriter();
+
+private:
+	CLogCompressor(CCloggerServer& aServer);
+	void DoGzipL(RFile& aInput, const TDesC& aOutput);
+
+private:
+	CCloggerServer& iServer;
+	RFs iFs;
+	};
+
+class CDebugRouterClient : public CActive
+	{
+public:
+	static CDebugRouterClient* NewL(CCloggerServer& aServer);
+	~CDebugRouterClient();
+	void RunL();
+	void DoCancel();
+	void StartRouting(TBool aConsumeLogs);
+	void StopRouting();
+	void OpenChunkL();
+	TInt RegisterCrashDumpAreas(const TDesC8& aCrashDumpAreas);
+	TInt CreateKernChunkForClient(RThread* aClient, TInt aMaxSize, TInt aCommittedSize, RChunk& aOurChunk);
+	TInt AdjustChunk(RChunk& aChunk, TInt aNewSize);
+
+private:
+	CDebugRouterClient(CCloggerServer& aServer);
+	void ConstructL();
+
+private:
+	CCloggerServer& iServer;
+	RCloggerDebugRouter iDebugRouter;
+	RChunk iSharedChunk;
+	RBuf8 iTempBuf;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/SensibleClient.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,53 @@
+// SensibleClient.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef SENSIBLECLIENT_H
+#define SENSIBLECLIENT_H
+
+#include <e32std.h>
+
+class CServerCallbackDispatcher;
+class TServerCallback;
+class TCallbackParser;
+
+/* This class is designed to be usable in a handle-body implementation. Ie you can hide the use of RSensibleSessionBody 
+ * from your clients by declaring a TUint32 iPimpl[3] (or somesuch) in your client class, and constructing a subclass of
+ * RSensibleSessionBody with appropriate definitions of DoCreateSession and DoSendReceive that call into the real session
+ * object.
+ *
+ * You can also derive directly from RSensibleSessionBody if you're not fussed about hiding the implementation.
+ */
+
+NONSHARABLE_CLASS(RSensibleSessionBody)
+	{
+	friend class CServerCallbackDispatcher;
+public:
+	RSensibleSessionBody();
+	
+protected:
+	void Close();
+	TInt Connect(TInt aMessageSlots, TBool aStartCallbackDispatcher);
+	TInt StartCallbackDispatcher(); // If not already started
+	void StopCallbackDispatcher();
+	virtual void DispatchCallbackL(TServerCallback& aCallback, TCallbackParser& aParser);
+	virtual void ServerDiedL();
+
+	// These have to be implemented by a derived class to call through to the session proper
+	virtual TInt DoCreateSession(const TDesC &aServer, const TVersion &aVersion, TInt aAsyncMessageSlots)=0;
+	virtual TInt DoSendReceive(TInt aFunction, const TIpcArgs &aArgs) const=0;
+	virtual void DoSendReceive(TInt aFunction, const TIpcArgs &aArgs, TRequestStatus &aStatus) const=0;
+
+protected:
+	CServerCallbackDispatcher* iDispatcher;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/SensibleClient_internals.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,99 @@
+// SensibleClient_internals.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef SENSIBLECLIENT_INTERNALS_H
+#define SENSIBLECLIENT_INTERNALS_H
+
+#include <e32base.h>
+#include "cliserv.h"
+#include "sensibleclient.h"
+#include <gdi.h>
+
+NONSHARABLE_CLASS(CServerCallbackDispatcher) : public CActive
+	{
+public:
+	CServerCallbackDispatcher(RSensibleSessionBody& aSession);
+	~CServerCallbackDispatcher();
+	void Register();
+
+private:
+	void RunL();
+	void DoCancel();
+	
+private:
+	RSensibleSessionBody& iSession;
+	TPckgBuf<TServerCallback> iNextCallback;
+	HBufC8* iCachedCallbackResult8;
+	HBufC16* iCachedCallbackResult16;
+	HBufC8* iContext;
+	TPtr8 iContextPtr; // Stupid client-server...
+
+	enum TState { EWaitingForCallback, EWaitingForContext };
+	TState iState;
+	};
+
+/*
+// An active object that holds on to a bunch of pointers, and frees them when its
+// iStatus is completed. Useful for passing temporary descriptors via asyncronous client-
+// -server (Otherwise you'd have to ensure yourself that they didn't go out of scope before
+// the server had read from them).
+// It can optionally pass on the completion message to another TRequestStatus
+class CCleanupAndComplete : public CActive
+	{
+public:
+	static CCleanupAndComplete* NewLC(TRequestStatus* aClientStatus);
+	static TInt Create(TRequestStatus*& aStatus, const TDesC16& aDes, TInt& aIpcArg); // Non-leaving convenience functions
+	static TInt Create(TRequestStatus*& aStatus, const TDesC8& aDes, TInt& aIpcArg); // Non-leaving convenience functions
+	void SetActive(); // Declare this so RDasherSession etc can activate us
+	void RunL();
+	void DoCancel();
+	CCleanupAndComplete(TRequestStatus* aClientStatus);
+	void AddL(CBase* aWithDestructor);
+	void AddL(TAny* aWithoutDestructor);
+	~CCleanupAndComplete();
+	
+public:
+	RPointerArray<CBase> iWithDestructor;
+	RArray<TAny*> iWithoutDestructor;
+
+private:
+	TRequestStatus* iClientStatus;
+	};
+*/
+
+// A helper class to parse arguments out of a callback from the server
+class TCallbackParser
+	{
+public:
+	TCallbackParser(const TServerCallback& aCallback);
+	void SetContext(TDesC8& aContext);
+
+	TInt NextInt();
+	TUint NextUint();
+	TPoint NextPoint();
+	TSize NextSize();
+	TRgb NextRgb();
+	TRect NextRect();
+	TPtrC NextDesC();
+	TPtrC8 NextDesC8();
+
+private:
+	TAny* Next(TInt aSize, char* aType);
+
+private:
+	const TServerCallback& iCallback;
+	TDesC8* iContext;
+	const TUint8* iNextPtr;
+	TBool iInContext;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/SensibleCompat.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,41 @@
+// SensibleCompat.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef SENSIBLECOMPAT_H
+#define SENSIBLECOMPAT_H
+
+#ifdef __HIDE_IPC_V1__
+
+// Differences in client server stuff
+#define RMessage RMessage2
+#define CServerBase CServer2
+#define CSessionBase CSession2
+#define SLOT(msg, n) n
+#define IPC(name, a,b,c,d) TIpcArgs name(a,b,c,d);
+
+#else
+
+#define CServerBase CServer
+#define CSessionBase CSharableSession
+#define SLOT(msg, n) msg.Ptr ## n ()
+#define IPC(name, a,b,c,d) TInt name[4] = {(TInt)a,(TInt)b,(TInt)c,(TInt)d}
+
+#endif
+
+#ifndef EKA2
+
+// Some things EKA1 platforms didn't have
+#define TRAP_IGNORE(x) { TRAPD(dontCare, x); }
+
+#endif
+
+#endif /* SENSIBLECOMPAT_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/SensibleFormat.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,145 @@
+// SensibleFormat.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// The purpose of this file is to define a generic format command that works reasonably even when there's no heap free
+// Because it uses a stack buffer in this case, it is very difficult to make this a generic function without macroing
+
+// Because I needed a 16-bit variant as well, and even templating would generate the same amount of code, I've done it
+// as a #includable code snippet
+
+// Note: If you do define SF_WIDE, Collapse() will be called on the result of the format before being passed to SF_ACTION
+
+// If you want to pass in a VA_LIST, then #define SF_LIST aArgList
+// If you want to pass in a bunch of arguments, #define SF_ARGLIST arg1,arg2,arg3
+
+#if !defined(SF_FORMAT) || !defined(SF_BUF) || !defined(SF_ACTION)
+#error "you must define all of SF_FORMAT, SF_BUF and SF_ACTION before including this file"
+#endif
+
+#if !((defined(SF_LIST) && !defined(SF_ARGLIST)) || (!defined(SF_LIST) && defined(SF_ARGLIST)))
+#error "you must define exactly one of SF_LIST and SF_ARGLIST before including this file"
+#endif
+
+#ifndef COMMON_H
+#error "you need to include common.h somewhere before including this file"
+#endif
+
+#ifdef SF_WIDE
+#define TOverflowX TOverflow16
+#define TBufX TBuf16<256>
+#else
+#define TOverflowX TOverflow8
+#define TBufX TBuf8<256>
+#endif
+
+#ifdef SF_ARGLIST
+#define SFAppend() AppendFormat(SF_FORMAT, &overflow, SF_ARGLIST)
+#else
+#define SFAppend() AppendFormatList(SF_FORMAT, SF_LIST, &overflow)
+#endif
+
+// Think of this as Format(RBuf8& SF_BUF, FunctionPointer SF_ACTION, const TDesCX& SF_FORMAT, TBool SF_STACKONLY, VA_LIST SF_LIST)
+// where SF_ACTION(SF_BUF) is called passing in the fully formatted string
+	{
+	const TInt minBufSize = Max(SF_BUF.MaxSize(), 512);
+	const TInt KMaxBufSize = 8192;
+	TInt err = KErrNone;
+
+#ifdef SF_STACKONLY
+	if (SF_STACKONLY)
+		{
+		err = KErrNoMemory;
+		}
+	else
+#endif
+		{
+		if (SF_BUF.MaxSize() == 0)
+			{
+			err = SF_BUF.Create(256);
+			}
+		else
+			{
+			SF_BUF.Zero();
+			}
+		}
+
+	TOverflowX overflow;
+	if (err == KErrNone)
+		{
+		// Do clever things to try and ensure that the format string won't be truncated, while at the same time not allocating an insanely big buffer
+		for (TInt bufSize = minBufSize; bufSize <= KMaxBufSize; bufSize*=2)
+			{
+			#ifdef SF_WIDE
+				TPtr16 widePtr((TUint16*)SF_BUF.Ptr(), SF_BUF.MaxSize()/2);
+				widePtr.SFAppend();
+			#else
+				SF_BUF.SFAppend();
+			#endif
+			if (!overflow.iOverflow)
+				{
+				// Then the format went ok
+				#ifdef SF_WIDE
+					TPtr8 collapsed = widePtr.Collapse();
+					SF_ACTION(collapsed);
+				#else
+					SF_ACTION(SF_BUF);
+				#endif
+				break;
+				}
+			else
+				{
+				// Overflowed
+
+				if (bufSize == KMaxBufSize)
+					{
+					// We've grown up to our (self-imposed) max buf size, so just live with the truncation
+					#ifdef SF_WIDE
+						TPtr8 collapsed = widePtr.Collapse();
+						SF_ACTION(collapsed);
+					#else
+						SF_ACTION(SF_BUF);
+					#endif
+					break;
+					}
+
+				// Try and grow
+				SF_BUF.Close();
+				err = SF_BUF.Create(bufSize*2);
+				if (err) break;
+				else continue;
+				}
+			}
+		}
+	if (err)
+		{
+		// Last resort, use 256 char buf on the stack
+		TBufX stackBuf;
+		stackBuf.SFAppend(); // Silently truncate if overflow happens now
+		#ifdef SF_WIDE
+			TPtr8 collapsed = stackBuf.Collapse();
+			SF_ACTION(collapsed);
+		#else
+			SF_ACTION(stackBuf);
+		#endif
+		}
+	}
+
+#undef SF_WIDE
+#undef SF_FORMAT
+#undef SF_LIST
+#undef SF_ARGLIST
+#undef SF_BUF
+#undef SF_ACTION
+#undef TBufX
+#undef TOverflowX
+#undef SFAppend
+#undef SF_STACKONLY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/SensibleServer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,177 @@
+// SensibleServer.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef SENSIBLESERVER_H
+#define SENSIBLESERVER_H
+
+#include <e32base.h>
+#include "cliserv.h"
+#include <f32file.h>
+#include <gdi.h>
+#include <basched.h>
+
+#include "SensibleCompat.h"
+
+class CCallbackContext;
+class CSensibleSession;
+class CFilteringScheduler;
+
+void PanicClient(const RMessage& aMessage, TInt TMyPanic);
+extern void CleanupPanicPushL();
+
+class CShutdown : public CTimer
+	{
+public:
+	inline CShutdown();
+	inline void ConstructL();
+	inline void Start(TInt aDelay);
+private:
+	void RunL();
+	};
+
+class CSensibleServer : public CServerBase
+	{
+public:
+	void AddSession();
+	void DropSession();
+	inline CFilteringScheduler* Scheduler();
+	CSensibleServer();
+	~CSensibleServer();
+	virtual void ConstructL();
+
+	// Some functions that call into the filtering scheduler
+	// NOTE: These functions cannot be used at the same time as queuing a callback that requires a result, nor can they be nested (you'll get a panic)
+	//void BlockAllAOsExceptServerRequests();
+	void BlockRequestsFrom(CActive* aActive1, CActive* aActive2=NULL);
+	void StopBlocking();
+
+protected:
+	#ifdef __HIDE_IPC_V1__
+	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+	#else
+	CSessionBase* NewSessionL(const TVersion& aVersion) const;
+	#endif
+	TInt RunError(TInt aError);
+	virtual TInt TransientServerShutdownTime() const; // Return 0 to never shutdown
+
+private:
+	TInt iSessionCount;
+	CShutdown iShutdown;
+	CFilteringScheduler* iScheduler;
+	CActiveScheduler* iOldScheduler;
+	};
+
+class CSensibleSession : public CSessionBase
+	{
+public:
+	CSensibleSession();
+	#ifndef __HIDE_IPC_V1__
+	void CreateL(const CServer& aServer);
+	#endif
+	void CreateL();
+	void QueueCallbackL(CCallbackContext* aContext); // This completes a callback immediately if possible, otherwise queues it. Used for callbacks that MUST be delivered.
+	TBool DispatchCallback(TServerCallback& aCallback); // This completes a callback immediately if possible, otherwise returns EFalse. Used for notify-style callbacks. The callback cannot have a context.
+	void CompleteNextCallback();
+
+protected:
+	virtual TBool DoServiceL(const RMessage& aMessage); // return EFalse if aMessage wasn't handled
+	~CSensibleSession();
+
+private:
+	inline CSensibleServer& Server();
+	void ServiceL(const RMessage& aMessage);
+//	inline TBool ReceivePending() const;
+private:
+	TSglQue<CCallbackContext> iCallbackQ;
+	RMessage iCallbackNotifier;
+	TBool iCallbackPending;
+	TBool iWaitingForCallbackResult;
+	};
+
+enum TCallbackContextFlags
+	{
+	EResultHBufC8 = 2,
+	EResultHBufC16 = 4,
+	EResultIsLeaveCode = 8,
+	EActive = 16,
+	EBlockServer = 32,
+	};
+
+class TCallbackWriter
+	{
+public:
+	TCallbackWriter(TServerCallback& aCallback, HBufC8** aContext);
+
+	// If any of the AddLs leave, they will delete aContext if it has been created
+	void AddL(TInt aInt);
+	void AddL(TUint aInt);
+	void AddL(TPoint aPoint);
+	void AddL(TSize aSize);
+	void AddL(TRgb aRgb);
+	void AddL(TRect aRect);
+	void AddL(const TDesC16& aDesc);
+	void AddL(const TDesC8& aDesc);
+
+private:
+	void AddL(const TDesC8& aData, char* aType);
+
+private:
+	TServerCallback& iCallback;
+	HBufC8** iContext;
+	TPtr8 iBuf;
+	TBool iInContext;
+	};
+
+class CCallbackContext : public CBase
+	{
+public:
+	union TResult
+		{
+		HBufC8** s;
+		HBufC16** l;
+		TDes8* pkg;
+		TInt integer;
+		};
+		
+public:
+	CCallbackContext(TCallbackCode aCode);
+	~CCallbackContext();
+	void SetFlags(TInt aFlags);
+	TBool Flag(TInt aFlags) const; // All bits of aFlags must be set to return true
+	void ClearFlags(TInt aFlags);
+	TBool CallbackRequiresResult() const;
+	TBool CallbackHasContext() const;
+	//void SetContext(HBufC8* aContext); // Takes ownership and clears flag EContextHBufC16
+	//void SetContext(HBufC16* aContext); // Takes ownership and sets flag EContextHBufC16
+	TCallbackWriter Writer();
+
+	void SetResult(TDes8& aPkg); // Sets appropriate flags
+	void SetResult(HBufC8*& aResult); // Sets appropriate flags
+	void SetResult(HBufC16*& aResult); // Sets appropriate flags
+	//void SetResult(TInt& aResult); // Sets appropriate flags
+	HBufC8* Context();
+	TResult& Result();
+	TServerCallback& Callback();
+	
+private:
+	void AddContext(const TUint8* aPtr, TInt aSize, char* aType);
+private:
+	TInt iFlags; // bitwise OR of TCallbackContextFlags
+	TServerCallback iCallback;
+	HBufC8* iContext;
+	TResult iResult;
+
+public:
+	TSglQueLink iLink;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/SensibleServer_server_specific.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+// SensibleServer_server_specific.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifdef SENSIBLESERVER_SERVER_SPECIFIC_H
+#error This file should only ever be included from one place
+#else
+#define SENSIBLESERVER_SERVER_SPECIFIC_H
+
+// Some tweaks to sensibleserver.cpp etc cannot be avoided,
+// so we put them all in one place
+
+/* Define this to specify that the server should start up an appropriate CEikonEnv
+ */
+//#define RUN_SERVER_WITH_EIKONENV
+
+/* This must be the name of your server subclass
+ */
+#define CServer_Class_Name CCloggerServer
+
+/* Include where the above subclass is defined
+ */
+#include "CloggerServer.h"
+
+/* Pick a name to identify the server in panic codes
+ */
+_LIT(KDebugPanic, "Clogger");
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/SessionWriter.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,54 @@
+// SessionWriter.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef SESSIONWRITER_H
+#define SESSIONWRITER_H
+
+#include <e32base.h>
+
+class CSessionWriter;
+class CSessionWriterServer;
+class CCloggerServer;
+
+class CSessionWriterSession : public CSession2
+	{
+public:
+	TBool WaitingForClient();
+	void WriteBuffer(const TDesC8& aBuf);
+
+private:
+	void ServiceL(const RMessage2 &aMessage);
+	CSessionWriterServer& Server();
+	~CSessionWriterSession();
+
+private:
+	TAny* iClientSharedChunkBase;
+	RMessagePtr2 iSessionWriterMessage;
+	CSessionWriter* iSessionWriter;
+	TBool iWaitingForClient;
+	};
+
+class CSessionWriterServer : public CServer2
+	{
+public:
+	CSessionWriterServer(CCloggerServer& aCloggerServer);
+	void ConstructL();
+	CCloggerServer& CloggerServer() { return iCloggerServer; }
+
+private:
+	CSession2* NewSessionL(const TVersion &aVersion, const RMessage2 &aMessage) const;
+
+private:
+	CCloggerServer& iCloggerServer;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/inc/common.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// common.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef COMMON_H
+#define COMMON_H
+
+class TOverflow16 : public TDes16Overflow
+	{
+public:
+	TOverflow16() : iOverflow(EFalse) {}
+	void Overflow(TDes16 &) { iOverflow = ETrue; }
+	TBool iOverflow;
+	};
+class TOverflow8 : public TDes8Overflow
+	{
+public:
+	TOverflow8() : iOverflow(EFalse) {}
+	void Overflow(TDes8 &) { iOverflow = ETrue; }
+	TBool iOverflow;
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/pctools/cloggercolour.pl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,187 @@
+#!perl
+# cloggercolour.pl
+# 
+# Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+use strict;
+use Getopt::Long;
+use IO::File;
+use IO::Handle;
+
+sub ParseCommandLineArgs();
+sub GetNextColour();
+
+my $clogFile;
+my $outFile;
+my $plainText;
+my $colour = 0;
+my $deltaTimeStamps = 0;
+my $verbose;
+
+ParseCommandLineArgs();
+
+my $logfile;
+my $htmlfile;
+
+if (defined $clogFile) {
+	print "Opening $clogFile for reading\n" if ($verbose);
+	$logfile = new IO::File;
+	$logfile->open("<$clogFile") or die "ERROR: Can't open $clogFile for reading: $!\n";
+} else {
+	print "Reading from STDIN\n" if ($verbose);
+	#$logfile = new IO::Handle;
+	#$logfile->fdopen(fileno(STDIN), "r") or die "ERROR: can't open STDIN: $!\n";
+	$logfile = *STDIN;
+}
+if (defined $outFile) {
+	print "Opening $outFile for writing\n" if ($verbose);
+	$htmlfile = new IO::File;
+	$htmlfile->open(">$outFile") or die "ERROR: Can't open $outFile for writing: $!\n";
+} else {
+	print "Writing to STDOUT\n" if ($verbose);
+	$htmlfile = *STDOUT;
+}
+unless ($plainText) {
+	print $htmlfile "<html><body><pre>\n";
+}
+
+my %tagColours = {};
+my $colours = 0;
+my $lastMillis = -1;
+
+while (my $line = <$logfile>) {
+	chomp $line;
+	if ($line =~ m/^(\d{4}-\d{2}-\d{2} \d{2}\:\d{2}\:\d{2}\.\d{3})\: \[([^]]+)\] (.*)$/ ) {
+		my ($time, $tag, $text) = ($1, $2, $3);
+		my $deltaStr = "";
+		unless (exists $tagColours{$tag}) {
+			$tagColours{$tag} = GetNextColour();
+		}
+		if ($deltaTimeStamps) {
+			$time =~ m|(\d{4})-(\d{2})-(\d{2}) (\d{2})\:(\d{2})\:(\d{2})\.(\d{3})|;
+			my ($year, $month, $day, $hour, $minute, $second, $millisecond) = ($1, $2, $3, $4, $5, $6, $7);
+			my $millis = ((((((((((($year*12)+$month)*31)+$day)*24)+$hour)*60)+$minute)*60)+$second)*1000)+$millisecond;
+			my $delta = 0;
+			if ($lastMillis != -1) {
+				$delta = $millis - $lastMillis;
+			}
+			$lastMillis = $millis;
+			$deltaStr = sprintf("(+% 4d)", $delta);
+		}
+
+		print $htmlfile "<font color=$tagColours{$tag}>" unless ($plainText) ;
+		print $htmlfile "$time:$deltaStr [$tag] $text";
+		print $htmlfile "</font>" unless ($plainText);
+		print $htmlfile "\n";
+	}
+	else {
+		print STDERR "WARNING: could not parse line $. of $clogFile\n";
+	}
+}
+
+
+unless ($plainText) {
+	print $htmlfile "</pre></body></html>\n"
+}
+undef $logfile;
+undef $htmlfile;
+
+sub ParseCommandLineArgs() {
+	Getopt::Long::Configure ("bundling");
+	GetOptions('v+' => \$verbose, 'c' => \$colour, 'd' => \$deltaTimeStamps, 'p'=>\$plainText);
+	if ($#ARGV != -1) {
+		$clogFile = shift @ARGV;
+	}
+	if ($#ARGV != -1) {
+		$outFile = shift @ARGV;
+	} else {
+		if (defined $clogFile) {
+			$outFile = "$clogFile.html";
+		}
+	}
+}
+
+my $colours = 0;
+
+sub GetNextColour() {
+	if ($colour) {
+		# make a new colour
+		my $pattern = $colours % 6;
+		my $newColour;
+		++$pattern;
+		if ($pattern > 3) {
+			$newColour = "#FF";
+			$pattern-=4;
+		} else {
+			$newColour = "#00";
+		}
+		if ($pattern > 1) {
+			$newColour = "${newColour}80";
+			$pattern-=2;
+		} else {
+			$newColour = "${newColour}00";
+		}
+		if ($pattern > 0) {
+			$newColour = "${newColour}FF";
+		} else {
+			$newColour = "${newColour}00";
+		}
+		++$colours;
+		return $newColour;
+	} else { 
+		return "#000000";
+	}
+}
+
+__END__
+
+=head1 NAME
+
+cloggerproc - Post-process clogger logs to add colour or timestamps
+
+=head1 SYNOPSIS
+
+	cloggerproc [options] [infile [outfile]]
+
+options:
+
+=over 4
+
+=item -d
+
+Add a millisecond delta to timestamps
+
+=item -c
+
+Colour logging lines based on the tag
+
+=item -v
+
+verbose output
+
+=item -h
+
+Show this help
+
+=back
+
+=head1 DESCRIPTION
+
+
+=head1 KNOWN BUGS
+
+If the timestamp month or year rolls over during the log, the delta will be incorrect for the first logging line in the new month/year.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/pctools/unhex.pl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,100 @@
+#!perl
+# unhex.pl
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Takes a standard hexdump of format:
+# 6640000c: 55 00 39 00 54 cb 00 00 42 41 46 4c 20 2d 20 42 U.9.T...BAFL - B
+# and outputs the concatenation of the ascii bits
+#
+# if -c is specified, it will further try to parse the hexdump as if it is a clogger debug router buffer
+
+if (scalar(@ARGV) == 1 && $ARGV[0] eq "-h")
+	{
+	print << "ENDHELP";
+Syntax: perl unhex.pl [-c]
+Reads a hexdump from stdin, unhexes it and outputs to stdout.
+If -c is specified, attempts to parse the hexdump as a clogger
+RDebug::Print crashdumparea buffer.
+ENDHELP
+	exit 0;
+	}
+my $clogger = scalar(@ARGV) == 1 && $ARGV[0] eq "-c";
+
+my $currentBuf = "";
+
+while($line = <STDIN>)
+	{
+	if ($line =~ /.*: (.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..)  ?(.*)/)
+		{
+		my $hex = $1;
+		my $frag = "";
+		my $strlen = length($hex);
+		#print "strlen = $strlen\n";
+		for (my $i = 0; $i < $strlen; $i+=3)
+			{
+			my $c = hex(substr($hex, $i, 2));
+			#print ("c = $c\n");
+			if (!$clogger)
+				{
+				# Then escape non-ascii
+				if ($c != 13 && $c != 10 && ($c < 32 || $c > 127)) { $c = ord("."); }
+				}
+			$frag = $frag.chr($c);
+			}
+			
+		if (!$clogger)
+			{
+			# Just print it
+			print($frag);
+			}
+		else
+			{
+			if ($frag eq "\0\0\0\0\0\0\0\0" || $frag eq "\3\3\3\3\3\3\3\3")
+				{
+				# This indicates the buffer doesn't have any data in it. 0x03 is used by as-yet unwritten-to chunks, it would appear
+				$frag = "";
+				}
+			$currentBuf .= $frag;
+			my $len = length($currentBuf);
+			my $start = index($currentBuf, "U\0");
+			if ($start == -1) { $start = index($currentBuf, "K\0"); }
+			if ($start == -1) { $start = index($currentBuf, "P\0"); }
+			if ($start == -1 || $start + 8 > $len)
+				{
+				# No header in buf, or not all of it
+				}
+			else
+				{
+				my ($type, $entryLen, $timeStamp) = unpack("a1xvV", substr($currentBuf, $start));
+				#print("type = $type, entryLen = $entryLen, timestamp = $timeStamp\n");
+				
+				if (8 + $start + $entryLen <= $len)
+					{
+					# Check if there was any junk in the buffer before the first header
+					if ($start > 0)
+						{
+						my $s = substr($currentBuf, 0, $start);
+						printf("00000000 $s\n");
+						}
+					$entry = substr($currentBuf, $start + 8, $entryLen);
+					printf("%08x %s\n", $timeStamp, $entry);
+					$currentBuf = substr($currentBuf, $start + 8 + $entryLen);
+					}
+				}
+			}
+		}
+	}
+if (length($currentBuf))
+	{
+	# The log is truncated, so just print what we have unparsed
+	print("$currentBuf\n");
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/CloggerClient.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,822 @@
+// CloggerClient.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "clogger.h"
+#include "cliserv.h"
+#include "SensibleClient_Internals.h"
+#include "common.h"
+#include <badesca.h>
+#include <s32mem.h>
+#include <e32property.h>
+
+#define KFlagsMask 0x0FFFFFFF
+#define KTestTagEnabled 0x10000000
+#define KNoLogMask 0x80000000 // This is the log mask used internally if you call an overload which doesn't specify one
+
+#define iBody (*reinterpret_cast<RCloggerBody*>(&iPimpl))
+
+#ifndef PERFORMANCE_CRITICAL
+
+// declares RClogger* clogger
+#define CheckConnected()                                       \
+	RClogger _cloggerHandle;                                   \
+	RClogger* clogger = &_cloggerHandle;                       \
+	GetTls(clogger, ETrue);                                    \
+	if (!clogger) return
+
+#define GetTlsOrConnect(aTag)                                  \
+	RClogger _cloggerHandle;                                   \
+	RClogger* clogger = &_cloggerHandle;                       \
+	TInt err;                                                  \
+	TBool isHandle = GetTls(clogger, ETrue, &aTag, &err)
+
+#define GetTlsOrNull()                                         \
+	RClogger _cloggerHandle;                                   \
+	RClogger* clogger = &_cloggerHandle;                       \
+	TBool isHandle = GetTls(clogger, EFalse)
+
+TBool RClogger::GetTls(RClogger*& aClogger, TBool aAutoConnect, const TDesC* aTag, TInt* aError)
+	{
+	TAny* tls = Dll::Tls();
+	if ((TUint)tls & 1)
+		{
+		// Then it's a handle
+		aClogger->SetHandle((TInt)((TUint)tls >> 1));
+		return ETrue;
+		}
+	else if (tls)
+		{
+		// Then it's a pointer
+		aClogger = (RClogger*)tls;
+		return EFalse;
+		}
+	else if (aAutoConnect)
+		{
+		TInt err = aClogger->Connect(aTag ? *aTag : KNullDesC);
+		aClogger->iFlags &= ~EUseHeapBuffer; // Don't (by default) use a buffer for static connections because we can't track it without upgrading TLS
+		if (err)
+			{
+			if (aError) *aError = err;
+			aClogger = NULL;
+			return ETrue;
+			}
+		__ASSERT_DEBUG((aClogger->Handle() & 0x80000000) == 0, User::Panic(_L("HandleTooBig"), 0));
+
+		err = Dll::SetTls((TAny*) ((aClogger->Handle() << 1) | 1));
+		if (err)
+			{
+			aClogger->Close();
+			if (aError) *aError = err;
+			aClogger = NULL;
+			}
+		return ETrue;
+		}
+	else
+		{
+		aClogger = NULL;
+		return ETrue;
+		}
+	}
+
+#endif // PERFORMANCE_CRITICAL
+
+NONSHARABLE_CLASS(RCloggerBody) : public RSensibleSessionBody
+	{
+public:
+	RCloggerBody(RClogger& aSession);
+	TInt DoCreateSession(const TDesC &aServer, const TVersion &aVersion, TInt aAsyncMessageSlots);
+	TInt DoSendReceive(TInt aFunction, const TIpcArgs &aArgs) const;
+	void DoSendReceive(TInt aFunction, const TIpcArgs &aArgs, TRequestStatus& aStatus) const;
+	void ServerDiedL();
+	void DispatchCallbackL(TServerCallback& aCallback, TCallbackParser& aParser);
+
+private:
+	friend class RClogger;
+	//RClogger& iSession; // No need to store this, we can calculate it from our this pointer since we know we are always embedded in an RClogger
+	};
+
+#define iSession (*(RClogger*)((TUint8*)this - _FOFF(RClogger, iPimpl)))
+
+RCloggerBody::RCloggerBody(RClogger& /*aSession*/)
+	: RSensibleSessionBody() //, iSession(aSession)
+	{}
+
+TInt RCloggerBody::DoCreateSession(const TDesC &aServer, const TVersion &aVersion, TInt aAsyncMessageSlots)
+	{
+	return iSession.CreateSession(aServer, aVersion, aAsyncMessageSlots);
+	}
+
+TInt RCloggerBody::DoSendReceive(TInt aFunction, const TIpcArgs &aArgs) const
+	{
+	return iSession.SendReceive(aFunction, aArgs);
+	}
+
+void RCloggerBody::DoSendReceive(TInt aFunction, const TIpcArgs &aArgs, TRequestStatus& aStatus) const
+	{
+	iSession.SendReceive(aFunction, aArgs, aStatus);
+	}
+
+EXPORT_C RClogger::RClogger()
+	: iFlags(0), iEnabled(EAllEnabled), iBuf(), iSequence(0)
+	{
+	__ASSERT_COMPILE(sizeof(iPimpl) >= sizeof(RCloggerBody));
+	__ASSERT_COMPILE(sizeof(RClogger) == 10*4); // This is the size we've published, it CANNOT change
+
+	// Initialise the body using placement new
+	new(iPimpl) RCloggerBody(*this);
+	}
+
+EXPORT_C RClogger::RClogger(TAny* aTls)
+	: iFlags(0), iEnabled(EAllEnabled), iBuf(), iSequence(0)
+	{
+	// This overload is only ever supposed to be used by the TlsLog inline functions, hence why it's private but still
+	// exported.
+	new(iPimpl) RCloggerBody(*this);
+	SetHandle(reinterpret_cast<TInt>(aTls));
+	}
+
+EXPORT_C TInt RClogger::Connect()
+	{
+	return Connect(KNullDesC);
+	}
+
+EXPORT_C TInt RClogger::Connect(const TDesC& aTag)
+	{
+	iFlags |= EUseHeapBuffer; // Set by default
+
+	TInt err = iBody.Connect(1, EFalse); // Only need 1 slot as we only have one async function (which is hidden within RSensibleSession)
+	if (!err)
+		{
+		err = ShareAuto();
+		}
+	if (!err)
+		{
+		TPckg<TUint32> enabledPkg(iEnabled);
+		TInt res = SendReceive(ESetTag, TIpcArgs(&aTag, NULL, &enabledPkg));
+		if (res >= 0)
+			{
+			iSequence = res;
+			}
+		else
+			{
+			err = res;
+			}
+		}
+	if (err)
+		{
+		Close();
+		}
+	return err;
+	}
+
+EXPORT_C TInt RClogger::StaticConnect()
+	{
+	return StaticConnect(KNullDesC);
+	}
+
+#ifndef PERFORMANCE_CRITICAL
+
+EXPORT_C TInt RClogger::StaticConnect(const TDesC& aTag)
+	{
+	GetTlsOrConnect(aTag);
+	if (clogger) return KErrNone;
+	else return err;
+	}
+
+EXPORT_C void RClogger::StaticClose()
+	{
+	GetTlsOrNull();
+	if (clogger)
+		{
+		clogger->Close();
+		if (!isHandle)
+			{
+			delete clogger;
+			}
+		Dll::SetTls(NULL);
+		Dll::FreeTls();
+		}
+	}
+
+#endif // PERFORMANCE_CRITICAL
+
+
+EXPORT_C void RClogger::Log(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	LogList(KNoLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Log(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	LogList(aLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Log(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	LogList(KNoLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Log(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	LogList(aLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Log(const char* aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	LogList(KNoLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Log(TUint32 aLogMask, const char* aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	LogList(aLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::LogList(TRefByValue<const TDesC> aFmt, VA_LIST aList)
+	{
+	LogList(KNoLogMask, aFmt, aList);
+	}
+
+EXPORT_C void RClogger::LogList(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, VA_LIST aList)
+	{
+	if (!Enabled(aLogMask)) return;
+	TUint32 tickCount = User::NTickCount();
+
+	TPtrC fmt(aFmt);
+	if (iFlags & ETrimTrailingNewlines)
+		{
+		TInt len = fmt.Length();
+		if (len && fmt[len-1] == '\n') fmt.Set(fmt.Left(len-1));
+		len = fmt.Length();
+		if (len && fmt[len-1] == '\r') fmt.Set(fmt.Left(len-1));
+		}
+	#define SF_FORMAT fmt
+	#define SF_LIST aList
+	#define SF_BUF iBuf
+	#define SF_ACTION(buf) SendReceive(ELog8, TIpcArgs(&buf, tickCount, aLogMask))
+	#define SF_WIDE
+	#define SF_STACKONLY (!(iFlags & EUseHeapBuffer))
+	#include "SensibleFormat.h"
+
+	//if (!(iFlags&ECacheClientBuffers)) iBuf.Close();
+	}
+
+EXPORT_C void RClogger::LogList(TRefByValue<const TDesC8> aFmt, VA_LIST aList)
+	{
+	LogList(KNoLogMask, aFmt, aList);
+	}
+
+EXPORT_C void RClogger::LogList(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, VA_LIST aList)
+	{
+	if (!Enabled(aLogMask)) return;
+	TUint32 tickCount = User::NTickCount();
+
+	TPtrC8 fmt(aFmt);
+	if (iFlags & ETrimTrailingNewlines)
+		{
+		TInt len = fmt.Length();
+		if (len && fmt[len-1] == '\n') fmt.Set(fmt.Left(len-1));
+		len = fmt.Length();
+		if (len && fmt[len-1] == '\r') fmt.Set(fmt.Left(len-1));
+		}
+	#define SF_FORMAT fmt
+	#define SF_LIST aList
+	#define SF_BUF iBuf
+	#define SF_ACTION(buf) SendReceive(ELog8, TIpcArgs(&buf, tickCount, aLogMask))
+	#define SF_STACKONLY (!(iFlags & EUseHeapBuffer))
+	#include "SensibleFormat.h"
+
+	//if (!(iFlags&ECacheClientBuffers)) iBuf.Close();
+	}
+
+EXPORT_C void RClogger::LogList(const char* aFmt, VA_LIST aList)
+	{
+	TPtrC8 ptr((const TUint8*)aFmt);
+	LogList(KNoLogMask, ptr, aList);
+	}
+
+EXPORT_C void RClogger::LogList(TUint32 aLogMask, const char* aFmt, VA_LIST aList)
+	{
+	TPtrC8 ptr((const TUint8*)aFmt);
+	LogList(aLogMask, ptr, aList);
+	}
+
+#ifndef PERFORMANCE_CRITICAL
+
+EXPORT_C void RClogger::Slog(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, ...)
+	{
+	CheckConnected();
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(aLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Slog(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, ...)
+	{
+	CheckConnected();
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(aLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Slog(TUint32 aLogMask, const char* aFmt, ...)
+	{
+	CheckConnected();
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(aLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Slog(TRefByValue<const TDesC> aFmt, ...)
+	{
+	CheckConnected();
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(KNoLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Slog(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	CheckConnected();
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(KNoLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::Slog(const char* aFmt, ...)
+	{
+	CheckConnected();
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(KNoLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RClogger::SlogList(TUint32 aLogMask, TRefByValue<const TDesC> aFmt, VA_LIST aList)
+	{
+	CheckConnected();
+	clogger->LogList(aLogMask, aFmt, aList);
+	}
+
+EXPORT_C void RClogger::SlogList(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, VA_LIST aList)
+	{
+	CheckConnected();
+	clogger->LogList(aLogMask, aFmt, aList);
+	}
+
+EXPORT_C void RClogger::SlogList(TUint32 aLogMask, const char* aFmt, VA_LIST aList)
+	{
+	CheckConnected();
+	clogger->LogList(aLogMask, aFmt, aList);
+	}
+
+EXPORT_C void RClogger::SlogList(TRefByValue<const TDesC> aFmt, VA_LIST aList)
+	{
+	CheckConnected();
+	clogger->LogList(KNoLogMask, aFmt, aList);
+	}
+
+EXPORT_C void RClogger::SlogList(TRefByValue<const TDesC8> aFmt, VA_LIST aList)
+	{
+	CheckConnected();
+	clogger->LogList(KNoLogMask, aFmt, aList);
+	}
+
+EXPORT_C void RClogger::SlogList(const char* aFmt, VA_LIST aList)
+	{
+	CheckConnected();
+	clogger->LogList(KNoLogMask, aFmt, aList);
+	}
+
+EXPORT_C void RClogger::SetStaticLogBehaviour(TUint aLogBehaviour)
+	{
+	GetTlsOrConnect(KNullDesC);
+	if (isHandle && (aLogBehaviour != 0))
+		{
+		// Then we need to upgrade from handle to pointer
+		TInt err = KErrNoMemory;
+		RClogger* ptr = new RClogger();
+		if (ptr)
+			{
+			ptr->SetHandle(clogger->Handle());
+			err = Dll::SetTls(ptr);
+			if (err) delete ptr;
+			}
+		if (err)
+			{
+			// Then log it.
+			_LIT(KErr, "RClogger couldn't upgrade handle to pointer, err %i");
+			clogger->Log(KErr(), err);
+
+			aLogBehaviour = 0; // Don't update flags if we failed to honour them
+			}
+		else
+			{
+			clogger = ptr;
+			}
+		}
+
+	clogger->SetLogBehaviour(aLogBehaviour);
+	}
+
+#endif // PERFORMANCE_CRITICAL
+
+EXPORT_C void RClogger::SetLogBehaviour(TUint aLogBehaviour)
+	{
+	iFlags = (iFlags & ~KFlagsMask) | (aLogBehaviour & KFlagsMask);
+
+	if (!(iFlags & EUseHeapBuffer)) iBuf.Close();
+	
+	/* This is not needed any more
+	if (iFlags & EMonitorTagState)
+		{
+		iBody.StartCallbackDispatcher();
+		}
+	else
+		{
+		iBody.StopCallbackDispatcher();
+		}
+	*/
+	}
+
+EXPORT_C TInt RClogger::SetEnabled(const TDesC& aTag, TUint32 aEnabledMask)
+	{
+	return SendReceive(ESetEnabled, TIpcArgs(&aTag, aEnabledMask));
+	}
+
+EXPORT_C TUint32 RClogger::IsEnabled(const TDesC& aTag)
+	{
+	TPckgBuf<TUint32> logMask;
+	TInt res = SendReceive(EIsEnabled, TIpcArgs(&aTag, &logMask));
+	return res < 0 ? EFalse : logMask();
+	}
+
+/*
+EXPORT_C void RClogger::TailLogFile(TInt aNumberOfChars)
+	{
+	SendReceive(ETailLogToRDebug, TIpcArgs(aNumberOfChars));
+	}
+
+EXPORT_C void RClogger::TailLogFile(TDes8& aBuf)
+	{
+	SendReceive(ETailLogToBuf, TIpcArgs(&aBuf));
+	}
+*/
+
+EXPORT_C void RClogger::SetGlobalOptions(TUint aGlobalOptions)
+	{
+	SendReceive(ESetGlobalOptions, TIpcArgs(aGlobalOptions));
+	}
+
+EXPORT_C TUint RClogger::GetGlobalOptions()
+	{
+	return SendReceive(EGetGlobalOptions, TIpcArgs());
+	}
+
+EXPORT_C TInt RClogger::GetRamBufferSize(TInt* aNumberOfBuffers)
+	{
+	TBuf8<8> buf;
+	buf.SetLength(8);
+	SendReceive(EGetRamBufferSize, TIpcArgs(&buf));
+	TInt* ptr = (TInt*)buf.Ptr();
+	TInt size = ptr[0];
+	if (aNumberOfBuffers)
+		{
+		*aNumberOfBuffers = ptr[1];
+		}
+	return size;
+	}
+
+EXPORT_C void RClogger::SetRamBufferSize(TInt aSize, TInt aNum)
+	{
+	SendReceive(ESetRamBufferSize, TIpcArgs(aSize, aNum));
+	}
+
+EXPORT_C TInt RClogger::Rotate()
+	{
+	return SendReceive(ERotate, TIpcArgs());
+	}
+
+EXPORT_C TInt RClogger::Rotate(TDes& aFileName)
+	{
+	aFileName.Zero();
+	return SendReceive(ERotate, TIpcArgs(&aFileName));
+	}
+
+EXPORT_C void RClogger::SetRotateBehaviour(TInt aNumberOfOldLogsToKeep, TUint aRotateBehaviour)
+	{
+	SendReceive(ESetRotateBehaviour, TIpcArgs(aNumberOfOldLogsToKeep, aRotateBehaviour));
+	}
+
+EXPORT_C TUint RClogger::GetRotateBehaviour(TInt* aNumberOfOldLogsToKeep)
+	{
+	TBuf8<8> buf;
+	buf.SetLength(8);
+	SendReceive(EGetRotateBehaviour, TIpcArgs(&buf));
+	TInt* ptr = (TInt*)buf.Ptr();
+	TUint behav = ptr[0];
+	if (aNumberOfOldLogsToKeep)
+		{
+		*aNumberOfOldLogsToKeep = ptr[1];
+		}
+	return behav;
+	}
+
+EXPORT_C void RClogger::PersistSettings()
+	{
+	SendReceive(EPersistSettings, TIpcArgs());
+	}
+
+EXPORT_C void RClogger::ResetSettings()
+	{
+	SendReceive(EResetSettings, TIpcArgs());
+	}
+
+EXPORT_C void RClogger::Close()
+	{
+	iBuf.Close();
+	iBody.Close();
+	RSessionBase::Close();
+	}
+
+void RCloggerBody::DispatchCallbackL(TServerCallback& aCallback, TCallbackParser& aParser)
+	{
+	switch (aCallback.iCode)
+		{
+		case ETagEnabledChanged:
+			{
+			iSession.iEnabled = aParser.NextUint();
+
+			/*
+			if (iSession.iFlags & KTestTagEnabled)
+				{
+				iSession.iFlags &= ~KTestTagEnabled;
+				CActiveScheduler::Stop();
+				}
+			*/
+			break;
+			}
+		}
+	}
+
+void RCloggerBody::ServerDiedL()
+	{
+	}
+
+EXPORT_C void RClogger::GetTagStatesL(CDesCArray*& aTagNames, RBuf8& aEnabled)
+	{
+	aTagNames = NULL;
+	aEnabled.Close();
+
+	TServerCallback cb;
+	TPckg<TServerCallback> cbPkg(cb);
+	User::LeaveIfError(SendReceive(EGetTagStates1, TIpcArgs(&cbPkg)));
+	
+	RBuf8 context;
+	CleanupClosePushL(context);
+	if (cb.iContextLength)
+		{
+		context.CreateL(cb.iContextLength);
+		User::LeaveIfError(SendReceive(EGetTagStates2, TIpcArgs(&context)));
+		}
+	TCallbackParser parser(cb);
+	parser.SetContext(context);
+
+	TPtrC8 enabledBuf = parser.NextDesC8();
+	TInt numTags = enabledBuf.Length() / 4; // 32 bits per tag
+
+	CDesCArrayFlat* tags = new(ELeave) CDesCArrayFlat(numTags);
+	CleanupStack::PushL(tags);
+	while (numTags--)
+		{
+		tags->AppendL(parser.NextDesC());
+		}
+	
+	aEnabled.CreateL(enabledBuf);
+	CleanupStack::Pop(tags);
+	CleanupStack::PopAndDestroy(&context);
+	aTagNames = tags;
+	}
+
+EXPORT_C void RClogger::SetTagStatesL(const CDesCArray* aTagNames, const TDesC8& aEnabled)
+	{
+	__ASSERT_ALWAYS(aTagNames, User::Leave(KErrArgument));
+	TInt count = aTagNames->MdcaCount();
+	__ASSERT_ALWAYS(count * 4 == aEnabled.Size(), User::Leave(KErrArgument)); // Number of tags must equal the number of 4-byte entries in aEnabled
+
+	CBufFlat* buf = CBufFlat::NewL(4096);
+	CleanupStack::PushL(buf);
+	RBufWriteStream stream(*buf);
+	CleanupClosePushL(stream);
+	stream.WriteInt32L(count);
+	//stream.WriteL(aEnabled);
+	stream << aEnabled;
+	for (TInt i = 0; i < count; i++)
+		{
+		const TPtrC name = aTagNames->MdcaPoint(i);
+		stream << name;
+		}
+	CleanupStack::PopAndDestroy(&stream); // Calls close, flushes buffer (probably not necessary with a RBufWriteStream)
+	TPtrC8 bufPtr = buf->Ptr(0);
+	User::LeaveIfError(SendReceive(ESetTagStates, TIpcArgs(&bufPtr)));
+	CleanupStack::PopAndDestroy(buf);
+	}
+
+EXPORT_C TInt RClogger::Reserved(TInt aCode, TAny*& aArg, TAny* aArg2)
+	{
+	TInt res = KErrNone;
+	if (aCode == 0xF10C10)
+		{
+		res = iBody.Connect(2, EFalse); // Used by flogger shim to access internals of clogger that would otherwise be hidden to it
+		}
+	else if (aCode == 0xC0FFEE)
+		{
+		RChunk*& chunk = reinterpret_cast<RChunk*&>(aArg);
+		TInt size = reinterpret_cast<TInt>(aArg2);
+		res = SendReceive(ECreatePerformanceLoggingChunk, TIpcArgs(size));
+		if (res > 0)
+			{
+			chunk->SetHandle(res);
+			res = KErrNone;
+			}
+		if (res == KErrNotSupported)
+			{
+			// Getting the chunk from the server is only possible if the debug router LDD is included, because there's no API
+			// to pass a chunk from a server to a client (without doing it kernel side). So if the LDD isn't present, we need
+			// to fall back to constructing it on our side and passing it to the server.
+			res = chunk->CreateGlobal(KNullDesC, size, size);
+			if (res == KErrNone)
+				{
+				res = SendReceive(ERegisterPerformanceLoggingChunk, TIpcArgs(*chunk));
+				}
+			}
+		}
+	else if (aCode == 0x5e55)
+		{
+		res = SendReceive(EStartSessionWriterServer);
+		}
+	else
+		{
+		User::Panic(_L("CloggerClient"), 0);
+		}
+	return res;
+	}
+
+EXPORT_C TInt RClogger::StaticReserved(TInt aCode, TAny*& aArg, TAny* aArg2)
+	{
+	TInt res = KErrNone;
+	if (aCode == 0xD0715)
+		{
+		RClogger clogger;
+		res = clogger.Connect(*reinterpret_cast<const TDesC*>(aArg2));
+		if (res == KErrNone)
+			{
+			aArg = reinterpret_cast<TAny*>(clogger.Handle());
+			}
+		}
+	else
+		{
+		User::Panic(_L("CloggerClient"), 0);
+		}
+	return res;
+	}
+
+EXPORT_C void RClogger::HexDump(TUint32 aLogMask, const TDesC8& aHeader, const TDesC8& aData)
+	{
+	if (!(iEnabled & aLogMask)) return;
+
+	SendReceive(EHexDump, TIpcArgs(&aHeader, &aData, User::NTickCount(), aLogMask));
+	}
+
+EXPORT_C void RClogger::HexDump(const TDesC8& aHeader, const TDesC8& aData)
+	{
+	HexDump(KNoLogMask, aHeader, aData);
+	}
+
+#ifndef PERFORMANCE_CRITICAL
+
+EXPORT_C void RClogger::StaticHexDump(TUint32 aLogMask, const TDesC8& aHeader, const TDesC8& aData)
+	{
+	CheckConnected();
+	clogger->HexDump(aLogMask, aHeader, aData);
+	}
+
+EXPORT_C void RClogger::StaticHexDump(const TDesC8& aHeader, const TDesC8& aData)
+	{
+	CheckConnected();
+	clogger->HexDump(KNoLogMask, aHeader, aData);
+	}
+
+#endif // PERFORMANCE_CRITICAL
+
+inline TBool RClogger::Enabled(TUint32 aMask)
+	{
+	// First check if anything's changed 
+	TInt seq = 0;
+	TInt err = RProperty::Get(KCloggerUid, ESequenceNumber, seq);
+	if (err == KErrNone && seq > iSequence)
+		{
+		UpdateEnabled(seq);
+		}
+
+	if (!(iEnabled & aMask)) return EFalse;
+
+	return ETrue;
+	}
+
+void RClogger::UpdateEnabled(TInt aSequence)
+	{
+	iSequence = aSequence;
+	TPckg<TUint32> buf(iEnabled);
+	SendReceive(EUpdateEnabledMask, TIpcArgs(&buf));
+	iFlags &= ~KTestTagEnabled;
+	}
+
+EXPORT_C RCloggerLogConsumer::RCloggerLogConsumer()
+	: iResultBufferPtr(NULL, 0)
+	{
+	}
+
+EXPORT_C TInt RCloggerLogConsumer::Connect()
+	{
+	RClogger clogger;
+	TInt res = clogger.Connect();
+	if (res) return res;
+
+	TAny* arg1 = NULL;
+	res = clogger.Reserved(0x5E55, arg1, NULL); // This requests clogger to start the session writer server
+	clogger.Close();
+	if (res != KErrNone && res != KErrAlreadyExists)
+		{
+		return res;
+		}
+
+	res = CreateSession(KSessionLogServer, TVersion(0,0,0), 2);
+	if (res) return res;
+
+	res = SendReceive(ERegisterForLogMessages);
+	if (res < 0) return res;
+	iSharedChunk.SetHandle(res);
+	return KErrNone;
+	}
+
+EXPORT_C void RCloggerLogConsumer::GetNextLog(TRequestStatus& aStatus, TPtrC8& aResultBuffer)
+	{
+	// Server will update aResultBuffer to point to the appropriate location in iSharedChunk.
+	// It can do this because we pass in effectively TPckg<TPtrC8>(aResultBuffer) and tell the server
+	// what the shared chunk's Base address is in our address space. The server then computes what
+	// aResultBuffer should look like and writes it back
+	iResultBufferPtr.Set((TUint8*)&aResultBuffer, sizeof(TPtrC8), sizeof(TPtrC8));
+	SendReceive(EGetNextLog, TIpcArgs(&iResultBufferPtr, iSharedChunk.Base()), aStatus);
+	}
+
+EXPORT_C void RCloggerLogConsumer::CancelGetNextLog()
+	{
+	SendReceive(ECancelGetNextLog);
+	}
+
+EXPORT_C void RCloggerLogConsumer::Close()
+	{
+	iSharedChunk.Close();
+	RSessionBase::Close();
+	}
+
+EXPORT_C void Clogger_Slog(const char* aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TPtrC8 fmt((const TUint8*)aFmt);
+	RClogger::SlogList(fmt, list);
+	VA_END(list);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/CloggerServer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2246 @@
+// CloggerServer.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "CloggerServer.h"
+#include "Clogger.h"
+#include "cliserv.h"
+#include "common.h"
+#include <HAL.h>
+#include <centralrepository.h>
+#include <s32mem.h>
+#include "SessionWriter.h"
+#include <fshell/common.mmh>
+
+#define ClientPanic(aMsg) PanicClient(aMsg, __LINE__)
+static const TUint32 KAllEnabled = 0xFFFFFFFFu;
+
+enum TFlags {
+	EAllowCurrentBufferToBeRead,
+	EInMiddleOfLog, // so don't call Log again, you'll stamp all over the buffers! This is a debug check to guard against my carelessness, ie calling something from within Log() that tries to call Log() again. Log() is not reenterant!
+	ELogBufferOverflow, // Can't log when the overflow occurs, so remember it until the log is in an ok state to record the fact
+	EWrittenToLog, // This indicates we have got far enough through construction to have written stuff to the buffers. This is an explicit flag to guard against future changes to the startup ordering
+	ECenrepFailed, // Can't log when cenrep is accessed, so remember for when we can log it
+	ENeedToCopyCompressedLog, // Indicates we need to call CopyLogToExternalMediaL when the background compress of the log completes
+	EForceBreakpoint, // Forces a __DEBUGGER call at the start of DoServiceL(). Useful when debugging tclog
+	EUsingTempBuf, // Another check to make sure I don't do something stupid with my buffers
+	EMaxFlags
+};
+
+__ASSERT_COMPILE(EMaxFlags <= 32);
+
+#define ACQUIRE_FLAG_LOCK_OR_FAIL(aFlag, failureOperation) \
+	ASSERT(!iFlags.IsSet(aFlag)); /* Debug behaviour */ \
+	if (iFlags.IsSet(aFlag)) { failureOperation; } /* Non debug behaviour - fail gracefully */ \
+	iFlags.Set(aFlag);
+#define ACQUIRE_FLAG_LOCK(aFlag) ACQUIRE_FLAG_LOCK_OR_FAIL(aFlag, return)
+#define RELEASE_FLAG_LOCK(aFlag) iFlags.Clear(aFlag)
+
+enum TInternalLoggingMasks {
+	ELogTagChanges = 1,
+	ELogNewTags = 2,
+	ELogDisks = 4,
+	ELogNewRdebuggers = 8,
+	};
+
+enum TRDebugPrintMasks {
+	ELogRDebugPrint = 1,
+	ELogKernPrintf = 2,
+	ELogPlatSecDiagnostics = 4,
+	};
+
+_LIT8(KCloggerTag, "Clogger");
+_LIT8(KOldRDebugTag, "RDebug::Print");
+_LIT8(KRDebugTag, "RDebug");
+_LIT8(KKernPrintfTag, "Kern::Printf"); // Not used any more - keep the definition because we explicitly ignore it when loading tags from cenrep
+_LIT8(KOldFallbackTag, "**Everything else**");
+_LIT8(KFallbackTag, "DefaultForNewTags");
+_LIT(KLogDir, "\\logs\\"); // Don't include the C: because that would upset moap. Rely on RFs to default to the system drive
+_LIT(KLogFile, "clogger.txt");
+
+// Don't reorder these without also changing order they are constructed in CCloggerServer::ConstructL
+enum TWriters {
+	EFile = 0,
+	ERDebug,
+	EMessageQueue,
+	ESessionWriter,
+	// Add new writers here!
+	EMaxWriters
+	};
+
+enum TCenRep {
+	EGlobalOptions = 0,
+	EBufferSize,
+	ENumBuffers,
+	ENumRotates,
+	ERotateBehaviour,
+	EEnabledTags, // This is obsolete because we now use the partial key functionality of cenrep to store enabled tags. And that was necessary because cenrep limits binary values to 2048 bytes
+	ERepositoryVersion,
+	};
+
+// Cenrep constants
+const TUint32 KEverythingMask = 0xFF000000;
+const TUint32 KEverythingPartialKey = 0x80000000;
+const TUint32 KEnabledMask = 0xFF000001;
+const TUint32 KTagEnabledPartialKey = 0x80000000;
+enum TCenrepVersion
+	{
+	ECenrepOriginalFormat = 0,
+	ECenrepThreadNamesArePrettified = 1,
+	};
+
+const TInt KMinWriteSize = 512; // 512 bytes is a good minimum size for efficient writes to disk
+const TInt KSyncBufferIdx = -99; // Magic number given by the server to writers to mean 'the sync buffer'
+const TInt KCompressFileNameBufferIdx = -100; // Magic number given by the server to the compress sync writer, its meaning is internal to CLogCompressor and CCloggerServer
+
+/*
+Clogger AOs:
+
+EPriorityHigh + 1:
+CBtIncomingPrompt Starter - This shouldn't get starved because of writers
+
+EPriorityHigh:
+CLogWriter - emptying buffers
+CSyncWriterWrapper - emptying buffers
+CLogsDirWatcher - will never be running at same time as CLogWriter
+CSessionWriterServer - emptying buffers
+
+EPriorityStandard + 1:
+CDebugRouterClient - reads input from RDdebug::Print redirector
+
+EPriorityStandard:
+CCloggerServer
+CServerCallbackDispatcher - unused
+
+EPriorityLow:
+iIdleWriteTimer - only go to next buffer when nothing better to do
+*/
+
+
+class CLogsDirWatcher : public CActive
+	{
+public:
+	CLogsDirWatcher(RFs& aFs, CCloggerServer& aServer)
+		: CActive(EPriorityHigh), iFs(aFs), iServer(aServer)
+		, iDirToWatch(KLogDir().Left(KLogDir().Length()-1)) // Strip trailing backslash
+		{
+
+		CActiveScheduler::Add(this);	
+		//__DEBUGGER();
+		iFs.NotifyChange(ENotifyAll, iStatus, iDirToWatch);
+		SetActive();
+		}
+
+	void DoCancel()
+		{
+		iFs.NotifyChangeCancel();
+		}
+
+	~CLogsDirWatcher()
+		{
+		Cancel();
+		}
+
+	void RunL()
+		{
+		//__DEBUGGER();
+		if (iStatus != KErrNone) return; // Give up
+		TEntry entry;
+		if (iFs.Entry(KLogDir, entry) == KErrNone)
+			{
+			iServer.LogsDirHasBeenCreated();
+			}
+		else
+			{
+			// Keep listening
+			iFs.NotifyChange(ENotifyAll, iStatus, iDirToWatch);
+			SetActive();
+			}	
+		}
+
+private:
+	RFs& iFs;
+	CCloggerServer& iServer;
+	TPtrC iDirToWatch;
+	};
+
+CSession2* CCloggerServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const
+	{
+	return new(ELeave) CCloggerSession();
+	}
+
+CCloggerServer::CCloggerServer()
+: CSensibleServer()
+	{
+	}
+
+TInt CCloggerServer::TransientServerShutdownTime() const
+	{
+	return 0; // Never shutdown
+	}
+
+CCloggerServer::~CCloggerServer()
+	{
+	//__DEBUGGER();
+	if (iFlags.IsSet(EWrittenToLog)) FlushBuffers();
+	CloseBuffers();
+	iBufs.Close();
+	iChunkForBufs.Close();
+
+	for (TInt i = 0; i < iWriters.Count(); i++)
+		{
+		iWriters[i]->CloseWriter();
+		}
+	iWriters.Close();
+	delete iSessionWriterServer;
+
+	if (iCompressor)
+		{
+		iCompressor->Cancel(); // This will wait for the compress to complete. Safest thing to do
+		delete iCompressor;
+		}
+
+	delete iLogsDirWatcher;
+	iLogFile.Close();
+	iFs.Close();
+	//iFileBeingRotated.Close();
+
+	TPtrHashMapIter<TDesC8, TTagData> tagIter(iTags);
+	TTagData* tag;
+	while ((tag = const_cast<TTagData*>(tagIter.NextValue())) != NULL)
+		{
+		tagIter.RemoveCurrent();
+		delete tag->iTagName;
+		delete tag;
+		}
+	iTags.Close();
+	iTempBuf.Close();
+	iSessionTempBuf.Close();
+	iRDebugTags.Close();
+
+	delete iIdleWriteTimer;
+	ASSERT(!iFlushBufferWait.IsStarted());
+	delete iKernDebugRouter; // When should this be deleted?
+	}
+
+void CCloggerServer::ConstructL()
+	{
+	CSensibleServer::ConstructL();
+	GetSettingsL();
+
+	iWriters.ReserveL(EMaxWriters);
+	// Note: important to get the order of writers in the array to be the same as is defined in enum TWriters
+	CLogWriter* filelogger = new(ELeave) CLogWriter(*this, iLogFile);
+	filelogger->SetEnabled(ETrue);
+	iWriters.Append(filelogger);
+	
+	CRDebugWriter* rdebuglogger = new(ELeave) CRDebugWriter(*this);
+	CleanupStack::PushL(rdebuglogger);
+	CSyncWriterWrapper* rdebugWrapper = CSyncWriterWrapper::NewL(*this, *rdebuglogger, iWriters.Count());
+	CleanupStack::Pop(rdebuglogger);
+	rdebugWrapper->SetEnabled(EFalse);
+	iWriters.Append(rdebugWrapper);
+
+	CMessageQueueWriter* msgq = CMessageQueueWriter::NewL();
+	CleanupStack::PushL(msgq);
+	CSyncWriterWrapper* msgqWrapper = CSyncWriterWrapper::NewL(*this, *msgq, iWriters.Count());
+	CleanupStack::Pop(msgq);
+	rdebugWrapper->SetEnabled(EFalse);
+	iWriters.Append(msgqWrapper);
+
+	CSessionWriter* sessionWriter = new(ELeave) CSessionWriter(*this);
+	sessionWriter->SetEnabled(EFalse);
+	iWriters.Append(sessionWriter);
+
+	User::LeaveIfError(iFs.Connect());
+	User::LeaveIfError(iFs.SetSessionPath(KLogDir));
+
+	TInt err = OpenLogFile();
+	if (err == KErrPathNotFound)
+		{
+		err = KErrNone;
+		iLogsDirWatcher = new(ELeave) CLogsDirWatcher(iFs, *this);
+		}
+	User::LeaveIfError(err);
+	/*TInt err = iLogFile.Open(iFs, KLogFile, EFileWrite|EFileShareAny|EFileStream);
+	if (err == KErrNotFound) err = iLogFile.Create(iFs, KLogFile, EFileWrite|EFileShareAny|EFileStream);
+	if (err == KErrPathNotFound)
+		{
+		iWriters[EFile]->SetEnabled(EFalse);
+		err = KErrNone;
+		iLogsDirWatcher = new(ELeave) CLogsDirWatcher(iFs, *this);
+		}
+	else
+		{
+		User::LeaveIfError(err);
+		TInt seekTo = -1;
+		User::LeaveIfError(iLogFile.Seek(ESeekEnd, seekTo));
+		}
+	*/
+	iIdleWriteTimer = CPeriodic::NewL(CActive::EPriorityLow);
+	
+	// Important that we start the kern debug router early, before the first call to UpdateBufferSizeL because we now rely on the debug router to allocate our chunk for us
+	TRAPD(debugRouterErr, iKernDebugRouter = CDebugRouterClient::NewL(*this)); // We check 'debugRouterErr' further down
+	const TInt KMaxChunkSize = 512*1024; // We will say 512 KB for max chunk size
+	err = CreateKernChunkForClient(NULL, KMaxChunkSize, 0, iChunkForBufs);
+	if (err == KErrNotSupported)
+		{
+		// Then debug router not found - so just create a chunk ourselves
+		_LIT(KName, "CloggerBufferChunk");
+		err = iChunkForBufs.CreateGlobal(KName, 0, KMaxChunkSize);
+		}
+	User::LeaveIfError(err);
+
+	UpdateBufferSizeL(iBufferSize, iNumBuffers);
+	iTempBuf.CreateL(512);
+	iSessionTempBuf.CreateL(512);
+
+	// The mechanism to compress log files in the background is a special case of a CSyncWriterWrapper
+	CLogCompressor* compressor = CLogCompressor::NewLC(*this);
+	iCompressor = CSyncWriterWrapper::NewL(*this, *compressor, -1);
+	CleanupStack::Pop(compressor);
+	iCompressor->SetEnabled(ETrue); // Otherwise CSyncWriterWrapper will ignore our requests to compress things!
+
+	iTags.ReserveL(32);
+	// Construct some tags that always exist
+	iCloggerTag = iTags.Find(KCloggerTag);
+	if (!iCloggerTag)
+		{
+		HBufC8* tag = KCloggerTag().AllocLC();
+		iCloggerTag = reinterpret_cast<TTagData*>(NewSessionForTagL(tag));
+		iCloggerTag->SetShouldDisplay();
+		iCloggerTag->iEnabled = ELogNewRdebuggers; // Defaults to off, except for logging new rdebuggers - because you generally want to be able to see the thread name
+		CleanupStack::Pop(tag);
+		}
+	iRDebugTag = iTags.Find(KRDebugTag);
+	if (!iRDebugTag)
+		{
+		HBufC8* tag = KRDebugTag().AllocLC();
+		iRDebugTag = reinterpret_cast<TTagData*>(NewSessionForTagL(tag));
+		// Should not be shown unless used, so don't SetShouldDisplay
+		CleanupStack::Pop(tag);
+		}
+	iFallbackTag = iTags.Find(KFallbackTag);
+	if (!iFallbackTag)
+		{
+		HBufC8* tag = KFallbackTag().AllocLC();
+		iFallbackTag = reinterpret_cast<TTagData*>(NewSessionForTagL(tag));
+		iFallbackTag->SetShouldDisplay();
+		CleanupStack::Pop(tag);
+		}
+
+	TUint32 tickCount = User::NTickCount();
+	iTimeAtStartup.UniversalTime();
+	TInt tickPeriod;
+	//User::LeaveIfError(HAL::Get(HAL::EFastCounterFrequency, iTickFreq));
+	User::LeaveIfError(HAL::Get(HAL::ENanoTickPeriod, tickPeriod));
+	iTickFreq = 1000000 / tickPeriod; // We work in frequencies because they are the round numbers when using the fast counter, and at some point we might want to again
+
+	iStartupTickInMicroseconds = ((TInt64)tickCount * 1000000) / (TInt64)iTickFreq; // Just making damn sure we're using 64bit math
+
+	// Rotate uses the tick stuff so must come after it
+	if (iRotateBehaviour & RClogger::EAutoRotateAtStartup)
+		{
+		Rotate();
+		}
+
+	UpdatedGlobalOptionsL(iOptions & RClogger::EBufferLog); // Passing in the current value of EBufferLog means we don't trigger another UpdateBufferSizeL, which is good because we've explicitly called that earlier on in this function
+
+	iFlags.Set(EWrittenToLog);
+
+	_LIT8(KCrLf, "\r\n");
+	_LIT8(KStarted, "Server started (log format v4)");
+	// Format v1 used incorrect time stamps, v2 fixed that, v3 indicates that the buffer info is published via P&S
+	// v4 scraps P&S and uses the kern debug router to map the buffers into the crashlog
+
+	LogLine(KCrLf);
+	Log(NULL, KStarted, User::NTickCount());
+	if (iFlags.IsSet(ECenrepFailed))
+		{
+		_LIT8(KCenrep, "Couldn't access the cenrep repository.");
+		LogError(KCenrep);
+		}
+	if (debugRouterErr)
+		{
+		_LIT8(KDebugRouterFailed, "Failed to load the debug router LDD, err=%i.");
+		LogError(KDebugRouterFailed, debugRouterErr);
+		}
+
+	_LIT_SECURITY_POLICY_PASS(KRead);
+	_LIT_SECURITY_POLICY_S0(KWrite, KCloggerUid.iUid);
+
+	RProperty::Define(KCloggerUid, ESequenceNumber, RProperty::EInt, KRead, KWrite);
+	RProperty::Set(KCloggerUid, ESequenceNumber, iEnabledStatesSequenceNumber);
+	}
+
+void CCloggerServer::GetSettingsL()
+	{
+	TRAPD(err, DoGetSettingsL());
+	// Don't allow messed-up cenrep config to prevent us from launching
+
+	if (err)
+		{
+		iBufferSize = 4096;
+		iNumBuffers = 2;
+		iNumRotates = 4;
+		iFlags.Set(ECenrepFailed);
+		}
+	}
+
+void CCloggerServer::DoGetSettingsL()
+	{
+	CRepository* cenrep = CRepository::NewLC(KCloggerUid);
+	User::LeaveIfError(cenrep->Get(EGlobalOptions, (TInt&)iOptions));
+	User::LeaveIfError(cenrep->Get(EBufferSize, iBufferSize));
+	User::LeaveIfError(cenrep->Get(ENumBuffers, iNumBuffers));
+	User::LeaveIfError(cenrep->Get(ENumRotates, iNumRotates));
+	User::LeaveIfError(cenrep->Get(ERotateBehaviour, (TInt&)iRotateBehaviour));
+	TInt version = 0;
+	TBool needToPrettifyThreadNames = EFalse;
+	TInt err = cenrep->Get(ERepositoryVersion, version);
+	if (err || version < ECenrepThreadNamesArePrettified)
+		{
+		needToPrettifyThreadNames = ETrue;
+		}
+
+	RArray<TUint32> foundKeys;
+	CleanupClosePushL(foundKeys);
+	err = cenrep->FindL(KTagEnabledPartialKey, KEnabledMask, foundKeys);
+	if (err == KErrNone)
+		{
+		TInt n = foundKeys.Count();
+		TBuf8<1> dummyBuf;
+		for (TInt i = 0; i < n; i++)
+			{
+			TUint32 enabled;
+			User::LeaveIfError(cenrep->Get(foundKeys[i], (TInt&)enabled));
+			TInt len;
+			HBufC8* tagName = NULL;
+			TInt err = cenrep->Get(foundKeys[i]+1, dummyBuf, len);
+			if (err == KErrNone)
+				{
+				tagName = dummyBuf.AllocLC();
+				}
+			else if (err == KErrOverflow)
+				{
+				tagName = HBufC8::NewLC(len);
+				}
+			else
+				{
+				User::LeaveIfError(err);
+				}
+			TPtr8 ptr = tagName->Des();
+			User::LeaveIfError(cenrep->Get(foundKeys[i]+1, ptr, len));
+			if (needToPrettifyThreadNames)
+				{
+				ThreadPrettyName(ptr);
+				}
+
+			if (*tagName == KKernPrintfTag)
+				{
+				// We don't use this any more
+				CleanupStack::PopAndDestroy(tagName);
+				continue;
+				}
+			else if (*tagName == KOldFallbackTag)
+				{
+				// In case the old definition is kicking round in a cenrep file
+				*tagName = KFallbackTag;
+				}
+			else if (*tagName == KOldRDebugTag)
+				{
+				// We've renamed this too
+				*tagName = KRDebugTag;
+				}
+
+			TTagData* tagData = iTags.Find(*tagName);
+			if (tagData)
+				{
+				// tagName is not needed
+				CleanupStack::PopAndDestroy(tagName);
+				}
+			else
+				{
+				tagData = new(ELeave)TTagData(tagName);
+				if (*tagName == KRDebugTag)
+					{
+					// We don't want this tag to show up unless we've actually used it, since it's only used for last-ditch OOM logging (this is to minimise confusion about which tags are used for what)
+					}
+				else
+					{
+					tagData->SetShouldDisplay(); // If the tag comes from cenrep then we should show it
+					}
+				CleanupStack::PushL(tagData);
+				iTags.InsertL(tagName, tagData);
+				CleanupStack::Pop(tagData);
+				CleanupStack::Pop(tagName);
+				}
+			tagData->iEnabled = enabled;
+			}
+		}
+	CleanupStack::PopAndDestroy(&foundKeys);
+
+	/*
+	TInt descSize = 0;
+	TBuf8<1> dummyBuf; // Don't bother trying to succeed without knowing the buffer size
+	TInt err = cenrep->Get(EEnabledTags, dummyBuf, descSize);
+	if (err == KErrOverflow)
+		{
+		// If err is not found, we don't care (repository key hasn't been defined) so do nothing
+		RBuf8 buf;
+		CleanupClosePushL(buf);
+		buf.CreateL(descSize);
+		err = cenrep->Get(EEnabledTags, buf, descSize);
+		User::LeaveIfError(err); // Shouldn't happen
+
+		CBufFlat* cbuf = CBufFlat::NewL(buf.Length());
+		CleanupStack::PushL(cbuf);
+		cbuf->InsertL(0, buf);
+		RBufReadStream stream(*cbuf);
+		CleanupClosePushL(stream);
+
+		TInt count = stream.ReadInt32L();
+		while (count--)
+			{
+			TUint32 enabled = stream.ReadUint32L();
+			HBufC8* tagName = HBufC8::NewL(stream, 2000);
+			TTagData* tagData = iTags.Find(*tagName);
+			if (tagData)
+				{
+				delete tagName; // Not needed
+				}
+			else
+				{
+				tagData = new(ELeave)TTagData();
+				tagData->iTagName = tagName;
+				tagData->iRefCount = 0;
+				CleanupStack::PushL(tagData);
+				iTags.InsertL(tagName, tagData); // TODO hmm if this leaves, tagName will be leaked
+				CleanupStack::Pop(tagData);
+				}
+			tagData->iEnabled = enabled;
+			}
+		CleanupStack::PopAndDestroy(3, &buf); // stream, cbuf, buf
+		}
+	*/
+	CleanupStack::PopAndDestroy(cenrep);
+	}
+
+void CCloggerServer::PersistSettingsL()
+	{
+	CRepository* cenrep = CRepository::NewLC(KCloggerUid);
+	User::LeaveIfError(cenrep->Set(EGlobalOptions, (TInt&)iOptions));
+	User::LeaveIfError(cenrep->Set(EBufferSize, iBufferSize));
+	User::LeaveIfError(cenrep->Set(ENumBuffers, iNumBuffers));
+	User::LeaveIfError(cenrep->Set(ENumRotates, iNumRotates));
+	User::LeaveIfError(cenrep->Set(ERotateBehaviour, (TInt&)iRotateBehaviour));
+	User::LeaveIfError(cenrep->Set(ERepositoryVersion, ECenrepThreadNamesArePrettified));
+
+	User::LeaveIfError(cenrep->StartTransaction(CRepository::EReadWriteTransaction));
+	cenrep->CleanupCancelTransactionPushL();
+	TUint32 dontCare;
+	TInt err = cenrep->Delete(KEverythingPartialKey, KEverythingMask, dontCare);
+	if (err && err != KErrNotFound) User::Leave(err);
+	TUint32 key = KTagEnabledPartialKey;
+	TPtrHashMapIter<TDesC8, TTagData> tagIter(iTags);
+	const TTagData* tag;
+	while ((tag = tagIter.NextValue()) != NULL)
+		{
+		User::LeaveIfError(cenrep->Set(key, (TInt&)tag->iEnabled));
+		key++;
+		User::LeaveIfError(cenrep->Set(key, *tag->iTagName));
+		key++;
+		}
+	CleanupStack::Pop(); // Transaction
+	User::LeaveIfError(cenrep->CommitTransaction(dontCare));
+	CleanupStack::PopAndDestroy(cenrep);
+	}
+
+void CCloggerServer::ResetSettingsL()
+	{
+	CRepository* cenrep = CRepository::NewLC(KCloggerUid);
+	cenrep->Reset();
+	CleanupStack::PopAndDestroy(cenrep);
+	GetSettingsL();
+	}
+
+
+void CCloggerServer::UpdateBufferSizeL(TInt aSize, TInt aNum)
+	{
+	if (aSize < KMinWriteSize) aSize = KMinWriteSize; // Anything smaller is just pointless
+	if (aNum < 2) aNum = 2; // Likewise
+
+	FlushBuffers(); // Ensure everything is empty before we start
+	CloseBuffers();
+
+	iBufferSize = aSize;
+	iNumBuffers = aNum;
+	if (!(iOptions & RClogger::EBufferLog))
+		{
+		return;
+		}
+	TUint oldOptions = iOptions;
+	iOptions &= ~RClogger::EBufferLog; // Clear this, and set it back to oldOptions at the end, so that if we leave our flags accurately describe the state of our buffers
+	
+	User::LeaveIfError(AdjustBufferChunk(iBufferSize * iNumBuffers));
+	TUint8* ptr = iChunkForBufs.Base();
+	
+	while (aNum--)
+		{
+		TBufEntry* entry = new(ELeave) TBufEntry();
+		CleanupStack::PushL(entry);
+		entry->iBuf.Set(ptr, 0, iBufferSize);
+		entry->iArrayIdx = iBufs.Count();
+		iBufs.AppendL(entry);
+		CleanupStack::Pop(entry);
+		ptr += iBufferSize;
+		if (iBufs.Count() > 1) iBufs[iBufs.Count()-2]->iNext = entry;
+		}
+	
+	iOptions = oldOptions;
+	iBufs[iBufs.Count()-1]->iNext = iBufs[0];
+	iCurrent = iBufs[0];
+	UpdatedBuffers();
+	
+	if (iLogFile.SubSessionHandle())
+		{
+		ReCalculateFileAlignment();
+		// Need to update iSubtractSizeOfNextBuffer in case there's been some unbuffered logging since the file opened
+		// (Or indeed if this is the first time UpdateBuffers has been called, immediately after the file was opened)
+		}
+	}
+
+void CCloggerServer::ReCalculateFileAlignment()
+	{
+	TInt seekTo = 0;
+	/*TInt err =*/ iLogFile.Seek(ESeekCurrent, seekTo);
+	// Assuming iLogFile is valid, ESeekCurrent can never return an error (the documentation is not clear but the implementation is)
+	iSubtractSizeOfNextBuffer = KMinWriteSize - (seekTo % KMinWriteSize);
+	}
+
+TInt CCloggerServer::OpenLogFile()
+	{
+	TInt err = iLogFile.Open(iFs, KLogFile, EFileWrite|EFileShareAny|EFileStream);
+	if (err == KErrNotFound) err = iLogFile.Create(iFs, KLogFile, EFileWrite|EFileShareAny|EFileStream);
+	if (err == KErrNone)
+		{
+		TInt seekTo = -1;
+		/*err =*/ iLogFile.Seek(ESeekEnd, seekTo);
+		iWriters[EFile]->SetEnabled(ETrue);
+		ReCalculateFileAlignment();
+		}
+	else
+		{
+		iWriters[EFile]->SetEnabled(EFalse);
+		}
+	
+	return err;
+	}
+
+// Session
+
+inline CCloggerServer& CCloggerSession::Server()
+	{
+	return *static_cast<CCloggerServer*>(const_cast<CServerBase*>(CSessionBase::Server()));
+	}
+
+CCloggerSession::CCloggerSession()
+: CSensibleSession()
+	{
+	}
+
+
+CCloggerSession::~CCloggerSession()
+	{
+	if (iPerformanceLoggingChunk.Handle())
+		{
+		TUint8* base = iPerformanceLoggingChunk.Base();
+		TInt size = *(TInt*)base;
+		TPtrC8 ptr(base+4, size);
+		//__DEBUGGER();
+		Server().LogHighPerformanceBuffer(ptr);
+		iPerformanceLoggingChunk.Close();
+		}
+	iGetTagStatesContext.Close();
+	Server().DropSession(this);
+	}
+
+TBool CCloggerSession::DoServiceL(const RMessage& aMessage)
+	{
+	//CleanupPanicPushL(); //DEBUG
+
+	if (Server().ForceBreakpointRequested())
+		{
+		__DEBUGGER();
+		}
+
+	TBool handled = ETrue;
+	TInt res = KErrNone;
+
+	TInt func = aMessage.Function();
+	if (!iContext && func != ESetTag && func != ESetTag8)
+		{
+		ClientPanic(aMessage); // SetTag should have been called
+		return ETrue;
+		}
+
+	switch (func)
+		{
+		case ESetTag:
+		case ESetTag8:
+			{
+			TInt tagLen = aMessage.GetDesLengthL(0);
+			TBool twoLevel = aMessage.Ptr1() != NULL;
+			if (tagLen && twoLevel)
+				{
+				// 2-level tag name, as used by flogger/CDU
+				tagLen = tagLen + 1 + aMessage.GetDesLengthL(1); // plus 1 for the slash in "tag/subtag"
+				}
+			if (tagLen > 256)
+				{
+				// It makes it easier to guarantee correctness if we limit tag lengths. Since thread fullnames are also 256, this is a good number
+				User::Leave(KErrTooBig);
+				}
+
+			HBufC8* newTag = NULL;
+			if (tagLen)
+				{
+				newTag = HBufC8::NewMaxLC(tagLen);
+				if (func == ESetTag)
+					{
+					HBufC* tag = HBufC::NewMaxLC(tagLen);
+					TPtr ptr = tag->Des();
+					aMessage.ReadL(0, ptr);
+					if (twoLevel)
+						{
+						ptr.Append('/');
+						TInt len = ptr.Length();
+						TPtr16 endBit((TUint16*)ptr.Ptr()+len, 0, ptr.MaxLength() - len);
+						aMessage.ReadL(1, endBit);
+						ptr.SetLength(len + endBit.Length());
+						}
+					newTag->Des().Copy(ptr);
+					CleanupStack::PopAndDestroy(tag);
+					}
+				else
+					{
+					TPtr8 ptr = newTag->Des();
+					aMessage.ReadL(0, ptr);
+					if (twoLevel)
+						{
+						// Use a different separator for the 8-bit variant (as that distinguishes commsdebug from flogger)
+						ptr.Append(':');
+						TInt len = ptr.Length();
+						TPtr8 endBit((TUint8*)ptr.Ptr()+len, 0, ptr.MaxLength() - len);
+						aMessage.ReadL(1, endBit);
+						ptr.SetLength(len + endBit.Length());
+						}
+					}
+				if (*newTag == KCloggerTag || *newTag == KFallbackTag)
+					{
+					// Not allowed for any session to pretend to be us
+					CleanupStack::PopAndDestroy(newTag);
+					newTag = NULL;
+					tagLen = 0;
+					// Drop through to using thread name in this case
+					}
+				}
+
+			if (!tagLen)
+				{
+				// Default to using thread name for the tag
+				RThread client;
+				aMessage.ClientL(client);
+				CleanupClosePushL(client);
+				TFullName threadName = client.FullName();
+				CleanupStack::PopAndDestroy(&client);
+				newTag = HBufC8::NewLC(threadName.Length());
+				TPtr8 tagPtr = newTag->Des();
+				tagPtr.Copy(threadName);
+				CCloggerServer::ThreadPrettyName(tagPtr);
+				}
+
+			if (iContext)
+				{
+				Server().ReplaceTagL(iContext, newTag);
+				CleanupStack::Pop(newTag);
+				}
+			else
+				{
+				iContext = Server().NewSessionForTagL(newTag);
+				CleanupStack::Pop(newTag);
+				}
+
+			TInt sequenceNumber;
+			TUint32 enabled = Server().TagEnabled(iContext, &sequenceNumber);
+			TPckg<TUint32> enablePkg(enabled);
+			aMessage.WriteL(2, enablePkg);
+			res = sequenceNumber;
+			break;
+			}
+		case ELog8:
+			{
+			TUint32 enabledMask = aMessage.Int2();
+			TUint32 tagEnabled = Server().TagEnabled(iContext);
+			if (!(enabledMask & tagEnabled))
+				{
+				Server().RegisterDisabledLog(iContext); // SetShouldDisplay usually gets called when you call log, but if it's disabled, then we don't get that far...
+				// Don't bother reading the log data
+				break;
+				}
+
+			TInt stringLen = aMessage.GetDesLengthL(0);
+			RBuf8& buf = Server().SessionTempBuf();
+			if (stringLen > buf.MaxLength())
+				{
+				buf.ReAllocL(stringLen);
+				}
+			aMessage.ReadL(0, buf);
+			TInt tickCount = aMessage.Int1();
+			Server().Log(iContext, buf, tickCount);
+			break;
+			}
+		case EUpdateEnabledMask:
+			{
+			TUint32 e = Server().TagEnabled(iContext);
+			TPckg<TUint32> enabledBuf(e);
+			aMessage.WriteL(0, enabledBuf);
+			break;
+			}
+		case EHexDump:
+		case EHexDump16:
+			{
+			TUint32 enabledMask = aMessage.Int3();
+			if (!(enabledMask & Server().TagEnabled(iContext)))
+				{
+				// Don't bother reading the log data
+				break;
+				}
+			
+			RBuf8& header = Server().SessionTempBuf();
+			TInt dataLen = aMessage.GetDesLengthL(1);
+
+			if (func == EHexDump)
+				{
+				aMessage.ReadL(0, header);
+				}
+			else
+				{
+				TPtr16 widePtr((TUint16*)header.Ptr(), header.MaxLength() / 2);
+				aMessage.ReadL(0, widePtr);
+				header.SetLength(widePtr.Size());
+				header.Collapse();
+				}
+
+			// Should we use a preallocated buffer here? For ease of coding, don't
+			RBuf8 data;
+			CleanupClosePushL(data);
+			data.CreateL(dataLen);
+			aMessage.ReadL(1, data);
+			
+			TInt tickCount = aMessage.Int2();
+			Server().HexDumpL(iContext, header, data, tickCount);
+			CleanupStack::PopAndDestroy(&data);
+
+			break;
+			}
+		case EGetTagStates1:
+			{
+			iGetTagStatesContext.Close();
+			TServerCallback cb;
+			HBufC8* context;
+			TCallbackWriter writer(cb, &context);
+			Server().WriteCallbackForGetTagStatesL(writer);
+
+			if (context) iGetTagStatesContext.Assign(context);
+
+			TPckg<TServerCallback> pkg(cb);
+			aMessage.WriteL(0, pkg);
+			break;
+			}
+		case EGetTagStates2:
+			{
+			aMessage.WriteL(0, iGetTagStatesContext);
+			iGetTagStatesContext.Close();
+			break;
+			}
+		case ECreatePerformanceLoggingChunk:
+			{
+			if (iPerformanceLoggingChunk.Handle())
+				{
+				return KErrAlreadyExists;
+				}
+			RThread client;
+			aMessage.ClientL(client);
+			TInt size = aMessage.Int0();
+			res = Server().CreateKernChunkForClient(&client, size, size, iPerformanceLoggingChunk);
+			client.Close();
+			break;
+			}
+		case ERegisterPerformanceLoggingChunk:
+			{
+			TInt err = iPerformanceLoggingChunk.Open(aMessage, 0, EFalse);
+			User::LeaveIfError(err);
+			break;
+			}
+		default:
+			handled = EFalse;
+			break;
+		}
+	//CleanupStack::Pop(); //DEBUG
+	if (handled)
+		{
+		aMessage.Complete(res);
+		}
+	else
+		{
+		// Then just pass the message on to the server
+		return Server().DoServiceL(aMessage);
+
+		//DEBUG to catch unbalanced PushLs
+		//TBool r = 0;
+		//TRAPD(err, r = Server().DoServiceL(aMessage));
+		//User::LeaveIfError(err);
+		//return r;
+		//END DEBUG
+		}
+	return handled;
+	}
+
+
+TBool CCloggerServer::DoServiceL(const RMessage& aMessage)
+	{
+	TBool handled = ETrue;
+	TInt res = KErrNone;
+
+	switch (aMessage.Function())
+		{
+		case EDebugAlignLogFile:
+		case EDebugShutdownServer:
+		case EDebugForceBreakpointInServiceL:
+			{
+			_LIT_SECURITY_POLICY_S0(KTClogPolicy, FSHELL_UID_TCLOG);
+			User::LeaveIfError(KTClogPolicy().CheckPolicy(aMessage, "Debug API called  from not within tclog.exe"));
+			}
+			break;
+		default:
+			break;
+		}
+
+	switch (aMessage.Function())
+		{
+		case ESetGlobalOptions:
+			{
+			TUint oldOptions = iOptions;
+			iOptions = aMessage.Int0();
+
+			UpdatedGlobalOptionsL(oldOptions);
+			break;
+			}
+		case EGetGlobalOptions:
+			{
+			res = iOptions;
+			break;
+			}
+		case ESetEnabled:
+			{
+
+			ACQUIRE_FLAG_LOCK_OR_FAIL(EUsingTempBuf, break);
+			iTempBuf.Zero();
+			TPtr16 ptr((TUint16*)iTempBuf.Ptr(), iTempBuf.MaxLength()/2);
+			TInt err = aMessage.Read(0, ptr);
+			if (err)
+				{
+				RELEASE_FLAG_LOCK(EUsingTempBuf);
+				User::Leave(err);
+				}
+			TPtrC8 tagname8 = ptr.Collapse();
+			TTagData* tag = iTags.Find(tagname8);
+			if (tag == NULL)
+				{
+				// Implicitly create the tag
+				HBufC8* tagBuf = tagname8.AllocLC();
+				tag = reinterpret_cast<TTagData*>(NewSessionForTagL(tagBuf));
+				tag->SetShouldDisplay(); // The user wants to see it if they've just created it
+				CleanupStack::Pop(tagBuf);
+				}
+			RELEASE_FLAG_LOCK(EUsingTempBuf);
+
+			tag->iEnabled = aMessage.Int1();
+			_LIT8(KTagChanged, "Client %S changed log mask of tag [%S] to 0x%08x");
+			TPtrC8 safeTagName = tag->iTagName->Left(128); // LogNote doesn't check lengths
+			RThread client;
+			aMessage.ClientL(client);
+			TFullName clientName = client.FullName();
+			TPtrC8 safeClientName = clientName.Collapse().Left(128);
+			client.Close();
+			LogNote(ELogTagChanges, KTagChanged, &safeClientName, &safeTagName, tag->iEnabled);
+
+			// Send update message to all sessions that have this tag and have enabled
+			// EDontLogIfTagIsDisabled
+			NotifySessionsOfChangedTag(tag);
+
+			iEnabledStatesSequenceNumber++;
+			RProperty::Set(KCloggerUid, ESequenceNumber, iEnabledStatesSequenceNumber);
+			break;
+			}
+		case EIsEnabled:
+			{
+			ACQUIRE_FLAG_LOCK_OR_FAIL(EUsingTempBuf, break);
+			iTempBuf.Zero();
+			TPckgBuf<TUint32> logMask;
+			TPtr16 ptr((TUint16*)iTempBuf.Ptr(), iTempBuf.MaxLength()/2);
+			TInt err = aMessage.Read(0, ptr);
+			if (err)
+				{
+				RELEASE_FLAG_LOCK(EUsingTempBuf);
+				User::Leave(err);
+				}
+			TTagData* tag = iTags.Find(ptr.Collapse());
+			RELEASE_FLAG_LOCK(EUsingTempBuf);
+			if (tag)
+				{
+				logMask = tag->iEnabled;
+				}
+			else
+				{
+				logMask = iFallbackTag->iEnabled; // If/when it does start logging, this is the enabled mask it will get
+				}
+			aMessage.WriteL(1, logMask);
+			break;
+			}
+		case EGetRamBufferSize:
+			{
+			TBuf8<8> buf;
+			buf.SetLength(8);
+			TInt* ptr = (TInt*)buf.Ptr();
+			ptr[0] = iBufferSize;
+			ptr[1] = iNumBuffers;
+			aMessage.WriteL(0, buf);
+			break;
+			}
+		case ESetRamBufferSize:
+			{
+			UpdateBufferSizeL(aMessage.Int0(), aMessage.Int1());
+			break;
+			}
+		case ERotate:
+			{
+			Rotate(&aMessage);
+			return ETrue;
+			}
+		case EGetRotateBehaviour:
+			{
+			TBuf8<8> buf;
+			buf.SetLength(8);
+			TInt* ptr = (TInt*)buf.Ptr();
+			ptr[0] = iRotateBehaviour;
+			ptr[1] = iNumRotates;
+			aMessage.WriteL(0, buf);
+			break;
+			}
+		case ESetRotateBehaviour:
+			{
+			iNumRotates = aMessage.Int0();
+			iRotateBehaviour = aMessage.Int1();
+			break;
+			}
+		case EPersistSettings:
+			{
+			PersistSettingsL();			
+			break;
+			}
+		case EResetSettings:
+			{
+			ResetSettingsL();			
+			break;
+			}
+		case EDebugAlignLogFile:
+			{
+			FlushBuffers();
+			iLogFile.Write(TPtrC8((const TUint8*)MINTAGSTART));
+			TInt pos = 0;
+			User::LeaveIfError(iLogFile.Seek(ESeekCurrent, pos));
+			pos = 4096 - (pos % 4096) - aMessage.Int0();
+			if (pos < 2) pos += 4096; // use 2 rather than zero so that we always have room in buf for "\r\n"
+			RBuf8 buf;
+			buf.CreateMaxL(pos);
+			buf.Fill('.');
+			buf[pos-2] = '\r';
+			buf[pos-1] = '\n';
+			iLogFile.Write(buf);
+			iLogFile.Flush();
+			buf.Close();
+			break;
+			}
+		case EDebugShutdownServer:
+			{
+			CloseBuffers(); // The tests assume we don't flush buffers when we receive a shutdown. Because it tests more things we do a tidy shutdown that would normally involve flushing the buffers.
+			CActiveScheduler::Stop();
+			return ETrue; // To skip the message complete
+			}
+		case ESetTagStates:
+			{
+			RBuf8 buf;
+			CleanupClosePushL(buf);
+			buf.CreateL(aMessage.GetDesLengthL(0));
+			aMessage.ReadL(0, buf);
+
+			// Dear Points of View, Why Oh Why does RBufReadStream's constructor take a CBufBase and not a TDesC8?
+			// Answer: Because no-one's really thought about this API for 15 years.
+			//
+			// There is one copy for IPC, one to construct the CBufFlat, and one to read an HBufC from the stream
+			// Something like TCallbackWriter extended slightly could do it in one copy (the IPC)
+
+			CBufFlat* cbuf = CBufFlat::NewL(buf.Length());
+			CleanupStack::PushL(cbuf);
+			cbuf->InsertL(0, buf);
+			RBufReadStream stream(*cbuf);
+			CleanupClosePushL(stream);
+			TInt count = stream.ReadInt32L();
+			RBuf8 enabled;
+			CleanupClosePushL(enabled);
+			enabled.Assign(HBufC8::NewL(stream, KMaxTInt));
+
+			iEnabledStatesSequenceNumber++;
+			RProperty::Set(KCloggerUid, ESequenceNumber, iEnabledStatesSequenceNumber);
+
+			_LIT8(KTagChanged, "Client %S updating tags");
+			RThread client;
+			aMessage.ClientL(client);
+			TFullName clientName = client.FullName();
+			TPtrC8 safeClientName = clientName.Collapse().Left(128);
+			client.Close();
+			LogNote(ELogTagChanges, KTagChanged, &safeClientName);
+
+			for (TInt i = 0; i < count; i++)
+				{
+				RBuf tagName;
+				CleanupClosePushL(tagName);
+				tagName.Assign(HBufC::NewL(stream, KMaxTInt));
+				TUint32 enabledMask = *((TUint32*)&enabled[i * 4]);
+				TTagData* tag = iTags.Find(tagName.Collapse());
+				if (tag)
+					{
+					tag->iEnabled = enabledMask;
+					NotifySessionsOfChangedTag(tag);
+					}
+				else
+					{
+					// If the client asked us to configure a non-existant tag, we'll just ignore it. The other option
+					// would be to set it up on the assumption that tag will be used later. But we've specified in the API
+					// what we'll do.
+					}
+				CleanupStack::PopAndDestroy(&tagName);
+				}
+			CleanupStack::PopAndDestroy(4, &buf); // enabled, stream, cbuf, buf
+			break;
+			}
+		case EDebugForceBreakpointInServiceL:
+			{
+			iFlags.Set(EForceBreakpoint);
+			break;
+			}
+		case EStartSessionWriterServer:
+			{
+			if (iSessionWriterServer)
+				{
+				res = KErrAlreadyExists;
+				}
+			else
+				{
+				iSessionWriterServer = new(ELeave) CSessionWriterServer(*this);
+				iSessionWriterServer->ConstructL();
+				}
+			break;
+			}
+		default:
+			handled = EFalse;
+			break;
+		}
+	if (handled)
+		{
+		aMessage.Complete(res);
+		}
+	return handled;
+	}
+
+TAny* CCloggerServer::NewSessionForTag(HBufC8* aTag)
+	{
+	// TODO reverse these so that we don't need a TRAP
+	TAny* res = NULL;
+	TRAP_IGNORE(res = NewSessionForTagL(aTag));
+	return res;
+	}
+
+TAny* CCloggerServer::NewSessionForTagL(HBufC8* aTag)
+	{
+	TTagData* tagData = iTags.Find(*aTag);
+	if (!tagData)
+		{
+		tagData = new(ELeave) TTagData(aTag);
+		tagData->iRefCount = 1;
+		if (iFallbackTag)
+			{
+			// If the fallback tag has been initialised (Which it always will be except when we are setting up default tags during startup
+			tagData->iEnabled = iFallbackTag->iEnabled;
+			}
+		else
+			{
+			tagData->iEnabled = KAllEnabled;
+			}
+		// Don't call SetShouldDisplay
+		CleanupStack::PushL(tagData);
+		iTags.InsertL(aTag, tagData);
+		CleanupStack::Pop(tagData);
+
+		TPtrC8 safeTag = aTag->Left(200);
+		_LIT8(KNewTag, "New tag created: [%S]");
+		LogNote(ELogNewTags, KNewTag, &safeTag);
+		}
+	else
+		{
+		delete aTag;
+		tagData->iRefCount++;
+		}
+	return tagData;
+	}
+
+void CCloggerServer::ReplaceTagL(TAny*& aCurrentContext, HBufC8* aNewTag)
+	{
+	//TTagData* tag = iTags.Find(aCurrentTag);
+	TTagData* tag = reinterpret_cast<TTagData*>(aCurrentContext);
+	if (!tag || tag->iRefCount != 1 || tag->ShouldDisplay())
+		{
+		// Can't imagine how tag could be non-null. 
+		// Don't allow tag name to updated if more than one session has been opened for it, or if anything's been written to the log
+
+		// The commsdebug API actually allows this, so we have to cater for it by instead doing a NewSessionForTag
+		aCurrentContext = NewSessionForTagL(aNewTag);
+		}
+	else if (iTags.Find(*aNewTag) != NULL)
+		{
+		// We already have a session for the new tag name, so again NewSessionForTagL is the right thing to do
+		aCurrentContext = NewSessionForTagL(aNewTag);
+		}
+	else
+		{
+		// This is a bit more complex than you'd expect because tag->iTagName must not be deleted until tag has been removed from the hashtable (since it is used as the key)
+
+		iTags.InsertL(aNewTag, tag); // On error, don't change anything, particularly what tag->iTagName points to
+		// If that succeeded, update the tag's iTagName, remove the old tag name from the hashtable and finally delete it
+		HBufC8* oldTagName = tag->iTagName;
+		tag->iTagName = aNewTag; // Takes ownership
+		iTags.Remove(oldTagName);
+
+		_LIT8(KNewTag, "Tag %S renamed to %S");
+		TPtrC8 safeOld = oldTagName->Left(128);
+		TPtrC8 safeNew = aNewTag->Left(128);
+		LogNote(ELogNewTags, KNewTag, &safeOld, &safeNew);
+
+		delete oldTagName;
+		}
+	}
+
+void CCloggerServer::DropSession(CCloggerSession* /*aSession*/)
+	{
+	//TODO decrement ref count and remove tag if reaches zero?
+	}
+
+void CCloggerServer::LogHighPerformanceBuffer(const TDesC8& aBuf)
+	{
+	// To avoid having to copy the data again (it could be 2MB) we use the sync write mechanism
+	TUint oldOptions = iOptions;
+	if (iOptions & RClogger::EBufferLog)
+		{
+		iOptions &= ~RClogger::EBufferLog;
+		FlushBuffers();
+		}
+	_LIT8(KHighPerf, "Dumping high-performance logging chunk (one tick=%00.3fus)");
+	LogError(KHighPerf, 1000000.0/iTickFreq);
+	LogLine(aBuf);
+	// Should really call UpdatedGlobalOptions, or at least UpdateBufferSizeL. Meh.
+	iOptions = oldOptions;
+	ReCalculateFileAlignment();
+	}
+
+void CCloggerServer::LogLine(const TDesC8& aLine)
+	{
+	if (iOptions & RClogger::EBufferLog)
+		{
+		ResetIdleWriteTimer();
+		TPtrC8 lineFrag(aLine);
+		while (lineFrag.Length())
+			{
+			TDes8& buf = iCurrent->iBuf;
+			TInt bufMaxLength = buf.MaxLength();
+			if (iSubtractSizeOfNextBuffer > buf.MaxLength())
+				{
+				// Then we have a buffer < 512B. Can't happen because that's the min buffer size
+				}
+			bufMaxLength -= iSubtractSizeOfNextBuffer;
+
+			TInt spaceFree = bufMaxLength - buf.Length();
+			ASSERT(spaceFree >= 0); // If it's negative then something's gone very wrong, we have less space in the buffer than the size of iSubtractSizeOfNextBuffer, implying the buffer was allowed to get too full
+			buf.Append(lineFrag.Left(spaceFree));
+			if (buf.Length() == bufMaxLength)
+				{
+				TRAPD(err, GotoNextBufL()); //TODO make this not need a trap?
+				iSubtractSizeOfNextBuffer = 0; // If iSubtractSizeOfNextBuffer was non-zero, then by rotating buffers right now, we become all square
+				if (err == KErrNoMemory)
+					{
+					// We needed to allocate a new buffer but couldn't, so block until we have space
+					FlushBuffers(); // strictly we only need to wait for one buffer to be free, not all of them
+					_LIT8(KNoMem, MINTAGSTART "Ran out of memory trying to expand buffers\r\n"); // we shouldn't be using iTempBuf here, so we can't format the timestamp!
+					LogLine(KNoMem);
+					}
+				else if (err)
+					{
+					ASSERT(EFalse); // Nothing else should be causing an error in that function
+					}
+				}
+			lineFrag.Set(lineFrag.Mid(Min(spaceFree, lineFrag.Length())));
+			// If the line was longer than the amount of freespace in the current buffer, we'll loop here to write the rest
+			}
+		}
+	else
+		{
+		iSyncWriteBuffer = &aLine;
+		TUint anythingEnabled = GetEnabledWriters(); // If no writers are enabled, no need to do anything (and moreover we'd hang if we tried it)
+		if (anythingEnabled)
+			{
+			TellAllWritersToWriteBuf(KSyncBufferIdx);
+			BlockRequestsFrom(this, iKernDebugRouter);
+			iFlushBufferWait.Start();
+			// The logic to do the stop is in CompletedWritingBuf
+			ASSERT(iSyncWriteBufferBusy == 0);
+			StopBlocking();
+			}
+		iSyncWriteBuffer = NULL;
+		}
+	}
+
+void CCloggerServer::Log(TAny* aContext, const TDesC8& aLine, TUint32 aTickCount)
+	{
+	ACQUIRE_FLAG_LOCK(EInMiddleOfLog);
+	ACQUIRE_FLAG_LOCK(EUsingTempBuf);
+
+	TTagData* tag = reinterpret_cast<TTagData*>(aContext);
+	if (tag)
+		{
+		tag->SetShouldDisplay();
+		}
+	TBuf8<32> rdebugId;
+	const TDesC8* t = &KCloggerTag;
+	if (tag)
+		{
+		if (tag->iThreadIdForRDebugger)
+			{
+			// For RDebug::Prints we use [tid] for the tag name
+			rdebugId.Num(tag->iThreadIdForRDebugger);
+			t = &rdebugId;
+			}
+		else
+			{
+			t = tag->iTagName;
+			}
+		}
+	const TDesC8& aTag = *t;
+
+	TDateTime dt = TickCountToTime(aTickCount).DateTime();
+	_LIT8(KFormat, "%i-%02i-%02i %02i:%02i:%02i.%03i: [%S] %S\r\n");
+	// Have to add 1 to Month and Day, as these are zero-based
+	#define SF_ARGLIST dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()/1000, &aTag, &aLine
+
+	#define SF_FORMAT KFormat
+	#define SF_BUF iTempBuf
+	#define SF_ACTION(buf) LogLine(buf)
+	#include "SensibleFormat.h"
+
+	RELEASE_FLAG_LOCK(EInMiddleOfLog);
+	RELEASE_FLAG_LOCK(EUsingTempBuf);
+
+	if (iFlags.IsSet(ELogBufferOverflow))
+		{
+		iFlags.Clear(ELogBufferOverflow);
+		_LIT8(KCreated, "Had to create a new buffer because a writer wasn't finished (iBufferBusy=0x%x)");
+
+		// Is OK to use the temp buf now that the rest of the Log() function has finished
+		// Since we know our string is < 512 chars (and that's the minimum for iTempBuf) we can dispense with the usual paranoid formatting constructs above
+		LogError(KCreated, iCurrent->iNext->iBufferBusy);
+		}
+	}
+
+void CCloggerServer::CloseBuffers()
+	{
+	UpdatedBuffers(ETrue);
+	for (TInt i = iBufs.Count()-1; i >= 0; i--)
+		{
+		TBufEntry* buf = iBufs[i];
+		//buf->iBuf.Close();
+		iBufs.Remove(i);
+		delete buf;
+		}
+	AdjustBufferChunk(0);
+	iCurrent = NULL;
+	}
+
+void CCloggerServer::FlushBuffers()
+	{
+	iIdleWriteTimer->Cancel();
+	// In the if statement below, check not only that we are buffering (iCurrent) but also that we have some writers to wait for (anythingEnabled)
+	TUint anythingEnabled = GetEnabledWriters(); // If no writers are enabled, no need to do anything (and moreover we'd hang if we tried it)
+	if (iCurrent && anythingEnabled)
+		{
+		iFlags.Set(EAllowCurrentBufferToBeRead);
+		// All enabled writers should already be writing out any filled buffers we have
+		// In case some have already finished writing all buffers, explicitly ask them to write out the current buffer as well
+		TellAllWritersToWriteBuf(iCurrent->iArrayIdx);
+		BlockRequestsFrom(this, iKernDebugRouter);
+		iFlushBufferWait.Start();
+		// The logic to do the stop is in CompletedWritingBuf
+		StopBlocking();
+		iFlags.Clear(EAllowCurrentBufferToBeRead);
+
+		ASSERT(iCurrent->iBufferBusy == 0); // Otherwise something is still outstanding...
+		}
+	}
+
+void CCloggerServer::GotoNextBufL()
+	{
+	iSubtractSizeOfNextBuffer = KMinWriteSize - (iCurrent->iBuf.Size() % KMinWriteSize);
+	if (iSubtractSizeOfNextBuffer == KMinWriteSize) iSubtractSizeOfNextBuffer = 0;
+
+	// Tell writers to get cracking if they aren't already
+	TellAllWritersToWriteBuf(iCurrent->iArrayIdx);
+
+	// Now update current buf
+	TBufEntry* next = iCurrent->iNext;
+	if (next->iBufferBusy)
+		{
+		// Buffer is still busy - so need to allocate a new one
+		TBufEntry* entry = new(ELeave) TBufEntry();
+		CleanupStack::PushL(entry);
+		TInt size = iChunkForBufs.Size();
+		User::LeaveIfError(AdjustBufferChunk(size + iBufferSize));
+		entry->iBuf.Set(iChunkForBufs.Base() + size, 0, iBufferSize);
+		entry->iArrayIdx = iBufs.Count();
+		iBufs.AppendL(entry);
+		CleanupStack::Pop(entry);
+		// Insert buffer into the circular buffer
+		entry->iNext = next;
+		iCurrent->iNext = entry;
+		iCurrent = entry;
+		iFlags.Set(ELogBufferOverflow);
+		}
+	else
+		{
+		next->iBuf.Zero(); // If there are no writers enabled, next might not actually be empty
+		iCurrent = next;
+		}
+	}
+
+const TDesC8& CCloggerServer::GetBuf(TInt aIdx)
+	{
+	if (aIdx == KSyncBufferIdx) return *iSyncWriteBuffer;
+	if (aIdx == KCompressFileNameBufferIdx) return KNullDesC8; // The compressor sync writer doesn't use this parameter
+
+	TBufEntry* entry = iBufs[aIdx];
+	ASSERT(entry->iBufferBusy); // If the buffer isn't marked as busy, noone should be accessing it
+	return entry->iBuf;
+	}
+
+void CCloggerServer::CompletedWritingBuf(MWriter* aWriter, TInt aIdx)
+	{
+	if (aIdx == KSyncBufferIdx)
+		{
+		// Magic number for sync writes
+		TInt writerId = iWriters.Find(aWriter);
+		ASSERT(writerId != KErrNotFound);
+		iSyncWriteBufferBusy &= ~(1 << writerId);
+		if (iSyncWriteBufferBusy == 0)
+			{
+			iFlushBufferWait.AsyncStop();
+			}
+		return;
+		}
+	else if (aIdx == KCompressFileNameBufferIdx)
+		{
+		// Magic number for background compress completed
+		TInt err = KErrNone;
+		if (iFlags.IsSet(ENeedToCopyCompressedLog) && iFileBeingRotated.Length())
+			{
+			iFlags.Clear(ENeedToCopyCompressedLog);
+			TRAP(err, CopyLogToExternalMediaL(iFileBeingRotated));
+			}
+		if (!iRotationMessage.IsNull())
+			{
+			// Tell the client the rotate has finished
+			if (!err) 
+				{
+				err = iRotationMessage.Write(0, iFileBeingRotated);
+				if (err == KErrBadDescriptor) err = KErrNone; // Probably means they called Rotate() with no arguments and so didn't care about the file name
+				}
+			iRotationMessage.Complete(err);
+			}
+		iFileBeingRotated.SetLength(0);
+		return;
+		}
+
+	TBufEntry* entry = iBufs[aIdx];
+
+	TInt writerId = iWriters.Find(aWriter);
+	ASSERT(writerId != KErrNotFound);
+
+	// Don't leave this in, it will cause an infinite loop if rdebug redirection is enabled!
+	//RDebug::Printf("Writer %i finished writing buffer %i", writerId, aIdx);
+
+	// This writer is done with this buffer
+	entry->iBufferBusy &= ~(1 << writerId);
+
+	TInt bufSize = entry->iBuf.Size();
+	if (entry->iBufferBusy == 0)
+		{
+		// This buffer is now available again
+		entry->iBuf.Zero();
+		}
+
+	// Decide whether the next buffer in the chain also needs writing by this writer
+
+	TBufEntry* next = entry->iNext;
+	if ((next->iBuf.Size() == next->iBuf.MaxSize() && entry != iCurrent) // The check for entry != iCurrent is to ensure we don't read past the end of the chain (ie it's technically possible for current to be full and next to be full but part of the tail of the chain)
+		|| (next == iCurrent && iFlushBufferWait.IsStarted()))
+		{
+		// Next entry needs writing too
+		TellWriterToWriteBuf(writerId, next->iArrayIdx);
+		}
+	else
+		{
+		// No more buffers need writing
+		if (entry == iCurrent && entry->iBufferBusy == 0 && iFlushBufferWait.IsStarted())
+			{
+			// All writers have now completed so stop the scheduler to return to FlushBuffers()
+			iFlushBufferWait.AsyncStop();
+
+			// Additionally we need to update iSubtractSizeOfNextBuffer since we don't do a GotoNextBuf when doing FlushBuffers
+			iSubtractSizeOfNextBuffer = KMinWriteSize - (bufSize % KMinWriteSize);
+			}
+		}
+	}
+
+TUint32 CCloggerServer::TagEnabled(const TAny* aContext, TInt* aSequenceNumber)
+	{
+	TUint32 res = KAllEnabled;
+	const TTagData* data = reinterpret_cast<const TTagData*>(aContext);
+	if (data)
+		{
+		res = data->iEnabled;
+		}
+	if (aSequenceNumber)
+		{
+		*aSequenceNumber = iEnabledStatesSequenceNumber;
+		}
+	return res;
+	}
+
+void CCloggerServer::WriteCallbackForGetTagStatesL(TCallbackWriter& aWriter)
+	{
+	RBuf8 enabled;
+	enabled.CreateL(iTags.Count() * 4);
+	CleanupClosePushL(enabled);
+
+	TPtrHashMapIter<TDesC8, TTagData> tagIter(iTags);
+	const TTagData* tag;
+	while ((tag = tagIter.NextValue()) != NULL)
+		{
+		if (tag->ShouldDisplay())
+			{
+			// Don't include tags that have never logged anything - they are probably only here for getting the tag states
+			const TPckgC<TUint32> tagEnabled(tag->iEnabled);
+			enabled.Append(tagEnabled);
+			}
+		}
+	aWriter.AddL(enabled);
+	CleanupStack::PopAndDestroy(&enabled);
+
+	tagIter.Reset();
+	while ((tag = tagIter.NextValue()) != NULL)
+		{
+		if (tag->ShouldDisplay())
+			{
+			const TDesC8* tagName = tag->iTagName;
+			// Don't include tags that have never logged anything - they are probably only here for getting the tag states
+			HBufC* tag16 = HBufC::NewLC(tagName->Length());
+			tag16->Des().Copy(*tagName);
+			aWriter.AddL(*tag16);
+			CleanupStack::PopAndDestroy(tag16);
+			}
+		}
+	}
+
+void CCloggerServer::NotifySessionsOfChangedTag(CCloggerServer::TTagData* tag)
+	{
+	iSessionIter.SetToFirst();
+	CCloggerSession* sess;
+	TServerCallback callback(ETagEnabledChanged);
+	TCallbackWriter writer(callback, NULL);
+	writer.AddL((TUint)tag->iEnabled);
+
+	while ((sess = (CCloggerSession*)iSessionIter++) != NULL)
+		{
+		if (sess->iContext == tag)
+			{
+			sess->DispatchCallback(callback);
+			}
+		}
+	}
+void CCloggerServer::ResetIdleWriteTimer()
+	{
+	ASSERT(iOptions & RClogger::EBufferLog); // The timer shouldn't get set when buffering is disabled
+	const TInt KIdleTime = 500000; // 0.5 seconds
+	iIdleWriteTimer->Cancel();
+	TCallBack cb(StaticIdleTimerExpired, this);
+	iIdleWriteTimer->Start(KIdleTime, KIdleTime, cb);
+	}
+
+TInt CCloggerServer::StaticIdleTimerExpired(TAny* aThis)
+	{
+	static_cast<CCloggerServer*>(aThis)->IdleTimerExpired();
+	return 0;
+	}
+
+void CCloggerServer::IdleTimerExpired()
+	{
+	ASSERT(iOptions & RClogger::EBufferLog); // The timer shouldn't be firing when buffering is disabled
+	iIdleWriteTimer->Cancel(); // Don't be periodic, this'll just waste CPU
+
+	// Go to the next buf, that will take care of everything
+	TRAPD(err, GotoNextBufL());
+	if (err == KErrNoMemory)
+		{
+		// We needed to allocate a new buffer but couldn't, so block until we have space
+		FlushBuffers(); //TODO we only need to wait for one buffer to be free, not all of them
+		_LIT8(KNoMem, "Ran out of memory trying to expand buffers during idle write");
+		Log(NULL, KNoMem, User::NTickCount());
+		}
+	else if (err)
+		{
+		ASSERT(EFalse); // Nothing else should be causing an error in that function
+		}
+	if (iFlags.IsSet(ELogBufferOverflow))
+		{
+		// Important to check this flag whenever GotoNextBufL is called! Otherwise you risk it not getting picked up
+		// until the next call to Log(), by which time buffering might have been disabled meaning iCurrent is no
+		// longer valid
+		iFlags.Clear(ELogBufferOverflow);
+		_LIT8(KCreated, "Had to create a new buffer during idle write because a writer wasn't finished (iBufferBusy=0x%x)");
+
+		LogError(KCreated, iCurrent->iNext->iBufferBusy);
+		}
+
+	}
+
+TUint CCloggerServer::GetEnabledWriters() const
+	{
+	TUint res = 0;
+	for (TInt i = 0; i < iWriters.Count(); i++)
+		{
+		if (iWriters[i]->IsEnabled()) res |= 1 << i;
+		}
+	return res;
+	}
+
+void CCloggerServer::Rotate(const RMessage* aMsg)
+	{
+	// This function uses a number of different error variables (rotateErr, continuationErr, listingErr) because not all errors are fatal or should be handled in the same way
+
+	if (iCompressor->IsActive() && (iRotateBehaviour & RClogger::ECompressRotatedLogs))
+		{
+		if (aMsg) aMsg->Complete(KErrNotReady);
+		return;
+		}
+
+	ASSERT(iRotationMessage.IsNull());
+
+	_LIT(KFormat, "%c:\\logs\\clogger_%i%02i%02i_%02i-%02i-%02i.%03i.txt");
+	TDateTime dt = TickCountToTime(User::NTickCount()).DateTime();
+	TDes& newName = iFileBeingRotated;
+	iFs.SessionPath(newName);
+	TUint driveLetter = newName[0];
+	newName.Format(KFormat, driveLetter, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()/1000);
+	
+	FlushBuffers(); // overkill again but easier to implement
+	iLogFile.Close();
+	// NOTE: Be sure not to call LogNote or LogError between this point and the call to OpenLogFile below!
+	RFile logFile;
+	TInt rotateErr = logFile.Open(iFs, KLogFile, EFileShareExclusive|EFileWrite); // Need to reopen the file for exclusive access so I can rename it
+	if (rotateErr == KErrNone)
+		{
+		rotateErr = logFile.Rename(newName);
+		}
+	logFile.Close();
+
+	if (rotateErr == KErrNotFound)
+		{
+		rotateErr = KErrNone;
+		// No worries
+		}
+	else if (rotateErr)
+		{
+		// We couldn't rotate the log file. Just log the fact later on
+		}
+
+	TInt continuationErr = OpenLogFile();
+	if (continuationErr)
+		{
+		// We're in trouble now. Log to any remaining writers
+		_LIT8(KRotateErr, "Error trying to reopen log file (%i)");
+		LogError(KRotateErr, continuationErr);
+		}
+
+	if (rotateErr)
+		{
+		// Then we failed to rotate (although we may have succeeded in reopening the file for logging)
+		_LIT8(KRotateErr, "Failed to rotate log file (%i)");
+		LogError(KRotateErr, rotateErr);
+		}
+
+	// Delete all log files more than iNumRotates
+	_LIT(KLogFileFormat, "clogger_*");
+	CDir* list = NULL;
+	TInt listingErr = iFs.GetDir(KLogFileFormat, KEntryAttNormal, ESortByName, list);
+	if (!listingErr && list->Count() > iNumRotates)
+		{
+		for (TInt i = 0; i < list->Count() - iNumRotates; i++)
+			{
+			// Don't delete the log we've just created if we need to rotate it or if iNumRotates is anything other than zero
+			// (On devices where the time is consistantly wrong it is possible to get in this situation)
+			TBool justCreated = (*list)[i].iName.CompareC(newName) == 0;
+			if (justCreated && ((iRotateBehaviour & RClogger::ECopyRotatedToExternalMedia) || iNumRotates > 0))
+				{
+				continue;
+				}
+			iFs.Delete((*list)[i].iName); // Ignore any errors because there's nothing we need to do
+			}
+		}
+	delete list;
+
+	TBool compress = EFalse;
+#ifdef FSHELL_EZLIB_SUPPORT
+	compress = (rotateErr == KErrNone && (iRotateBehaviour & RClogger::ECompressRotatedLogs));
+#endif
+	if (compress)
+		{
+		if (iRotateBehaviour & RClogger::ECopyRotatedToExternalMedia)
+			{
+			iFlags.Set(ENeedToCopyCompressedLog);
+			}
+		iCompressor->WriteBuf(KCompressFileNameBufferIdx);
+		}
+	
+	if (rotateErr == KErrNone && !compress && (iRotateBehaviour & RClogger::ECopyRotatedToExternalMedia))
+		{
+		TRAP(rotateErr, CopyLogToExternalMediaL(newName));
+		}
+	TInt aResult = rotateErr ? rotateErr : continuationErr;
+
+	TBool completeNow = !compress;
+	if (aMsg)
+		{
+		if (completeNow)
+			{
+			if (aResult == KErrNone)
+				{
+				aResult = aMsg->Write(0, iFileBeingRotated);
+				if (aResult == KErrBadDescriptor) aResult = KErrNone; // Probably means they called Rotate() with no arguments and so didn't care about the file name
+				}
+			aMsg->Complete(aResult);
+			iFileBeingRotated.SetLength(0); // Finished with this buffer for now
+			}
+		else
+			{
+			iRotationMessage = *aMsg;
+			}
+		}
+	}
+
+void CCloggerServer::CopyLogToExternalMediaL(TDes& aFile)
+	{
+	TInt err = KErrNone;
+	TInt removableDrive = KErrNotFound;
+	TInt hdAttributeDrive = KErrNotFound;
+	// Figure out the first external media device
+	for (TInt drive = EDriveA; drive <= EDriveZ; drive++)
+		{
+		TVolumeInfo info;
+		err = iFs.Volume(info, drive);
+		if (err == KErrNone)
+			{
+			LogNote(ELogDisks, _L8("Found drive %c iDrivaAtt=0x%x iType=0x%x"), 'A' + drive, info.iDrive.iDriveAtt, info.iDrive.iType);
+			}
+		if (err == KErrNone && (info.iDrive.iDriveAtt & KDriveAttRemovable))
+			{
+			removableDrive = drive;
+			}
+		else if (err == KErrNone && info.iDrive.iType == EMediaHardDisk)
+			{
+			// Added the check for hard disk without removable so we can use _epoc_drive_d in the emulator
+			hdAttributeDrive = drive;
+			break;
+			}
+		}
+	TInt theDrive = hdAttributeDrive;
+	if (removableDrive != KErrNotFound) theDrive = removableDrive; // Prefer something with the removable attribute, if we have both
+
+	if (theDrive != KErrNotFound)
+		{
+		CFileMan* fm = CFileMan::NewL(iFs);
+		CleanupStack::PushL(fm);
+		// aName is of the format C:\logs\clogger_xyz
+		// extName needs to be D:\logs\clogger_xyz
+		HBufC* nm = aFile.AllocLC();
+		RBuf extName;
+		extName.Assign(nm);
+		TChar ffs;
+		RFs::DriveToChar(theDrive, ffs);
+		extName[0] = ffs;
+		// Actually copy the file
+		User::LeaveIfError(fm->Copy(aFile, extName, CFileMan::ERecurse));
+		aFile = extName; // If all went well update the file name to reflect where we copied to
+		CleanupStack::PopAndDestroy(2, fm); // extName/nm, fms
+		}
+	else
+		{
+		LogNote(ELogDisks, _L8("Couldn't find any suitable volumes to copy log file on to"));
+		}
+	}
+
+void CCloggerServer::LogError(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	DoLogErrorOrNote(RClogger::EAllEnabled, aFmt, args);
+	VA_END(args);
+	}
+
+void CCloggerServer::LogNote(TUint32 aLogMask, TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	DoLogErrorOrNote(aLogMask, aFmt, args);
+	VA_END(args);
+	}
+
+void CCloggerServer::DoLogErrorOrNote(TUint32 aLogMask, const TDesC8 &aFmt, VA_LIST args)
+	{
+	if (!iFlags.IsSet(EWrittenToLog))
+		{
+		return; // Not ready to log yet - this can happen in the case that logging is attempted during ConstructL
+		}
+
+	if (!(aLogMask & iCloggerTag->iEnabled) && aLogMask != RClogger::EAllEnabled)
+		{
+		// Make sure we always log errors, which are signified by aLogMask being EAllEnabled
+		return;
+		}
+
+	// Whole string must be less than iTempBuf.MaxLength (ie 512) and will cause a panic if it isn't. So use with caution!
+	// ie don't pass in user-generated strings that might be massive.
+
+	_LIT8(KFmt, "%i-%02i-%02i %02i:%02i:%02i.%03i: [Clogger] ");
+	_LIT8(KEnd, "\r\n");
+
+	ACQUIRE_FLAG_LOCK(EUsingTempBuf);
+
+	iTempBuf.Zero();
+	//iTempBuf.Append(KFmt);
+
+	TDateTime dt = TickCountToTime(User::NTickCount()).DateTime();
+	iTempBuf.Format(KFmt, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()/1000);
+	iTempBuf.AppendFormatList(aFmt, args);
+	iTempBuf.Append(KEnd);
+	LogLine(iTempBuf);
+
+	RELEASE_FLAG_LOCK(EUsingTempBuf);
+	}
+
+void CCloggerServer::LogsDirHasBeenCreated()
+	{
+	//__DEBUGGER();
+	OpenLogFile(); // Ignore error
+	}
+
+TDes& CCloggerServer::GetFilenameToRotate()
+	{
+	return iFileBeingRotated;
+	}
+
+void CCloggerServer::HexDumpL(TAny* aContext, const TDesC8& aHeader, const TDesC8& aData, TUint32 aTickCount)
+	{
+	const TInt KLineSize = 16;
+	const TInt KExtra = 7 + 1; // The number of chars of padding that go into the output line.
+	// Header0000 : 00 01 02 03  ....
+	// So line len is headerLen + 4 + 3 + (3 * lineSize) + 1 + lineSize
+	_LIT8(KFormat, "%04X : ");
+	RBuf8 lineBuf;
+	CleanupClosePushL(lineBuf);
+	lineBuf.CreateL(aHeader.Length() + 4 * KLineSize + KExtra);
+
+	TPtrC8 lineFrag(aData);
+	TInt offset = 0;
+	while (lineFrag.Length())
+		{
+		lineBuf.Zero();
+		TInt lineSize = Min(KLineSize, lineFrag.Length());
+		// Start with header (or empty space if continuation)
+		if (offset == 0)
+			{
+			lineBuf.Append(aHeader);
+			}
+		else
+			{
+			lineBuf.AppendFill(' ', aHeader.Length());
+			}
+
+		// Add offset
+		lineBuf.AppendFormat(KFormat, offset);
+		offset += lineSize;
+
+		// Add hex representation
+		for (TInt i = 0; i < lineSize; i++)
+			{
+			TBuf8<2> charBuf;
+			charBuf.NumFixedWidthUC(lineFrag[i], EHex, 2);
+			lineBuf.Append(charBuf);
+			lineBuf.Append(' ');
+			}
+		// Add filler if lineSize < KLineSize
+		lineBuf.AppendFill(' ', (KLineSize - lineSize) * 3);
+
+		// Add ascii representation
+		lineBuf.Append(' ');
+		for (TInt i = 0; i < lineSize; i++)
+			{
+			TChar c = lineFrag[i];
+			lineBuf.Append(c.IsPrint() ? c : TChar('.'));
+			}
+		lineFrag.Set(lineFrag.Mid(lineSize));
+		Log(aContext, lineBuf, aTickCount);
+		}
+	CleanupStack::PopAndDestroy(&lineBuf);
+	}
+
+void CCloggerServer::SetKernelLoggingL(TBool aEnable)
+	{
+	if (!iKernDebugRouter)
+		{
+		// Either means we're being called very early during server ConstructL, or the debug router LDD is missing
+		return;
+		}
+	if (aEnable)
+		{
+		iKernDebugRouter->OpenChunkL(); // This will do nothing if already open
+		}
+	
+	if (aEnable)
+		{
+		TBool consume = ETrue; //iOptions & RClogger::EMirrorToRDebugPrint;
+		// ^ We always consume, it makes things easier.
+		iKernDebugRouter->StartRouting(consume);
+		}
+	else
+		{
+		iKernDebugRouter->StopRouting();
+		}
+	}
+
+const TInt KThreadTagNamBufLen = 256;
+
+void CCloggerServer::LogKernMessage(TUint8 aWhere, TUint32 aTickCount, TUint aThreadId, const TDesC8& aMsg)
+	{
+	TUint enableMask = aWhere == 'K' ? ELogKernPrintf : aWhere == 'P' ? ELogPlatSecDiagnostics : ELogRDebugPrint;
+	TBool kern = aWhere != 'U';
+	TTagData* tag = iRDebugTag; // This is used only as a last-ditch fallback if we've run out memory
+
+	if (aThreadId != 0)
+		{
+		// Look for a tag in the iRDebugTags
+		TTagData** tagDataPtr = iRDebugTags.Find(aThreadId);
+		if (tagDataPtr) tag = *tagDataPtr;
+		else
+			{
+			// New tag (or rather, look in iTags keyed by thread name)
+			RThread thread;
+			TInt err = KErrNone;
+			HBufC8* tagBuf = HBufC8::New(KThreadTagNamBufLen*2);
+			if (!tagBuf) err = KErrNoMemory;
+			
+			if (err)
+				{
+				// Fall back to just RDebug::Print or Kern::Printf as appropriate
+				_LIT8(KUnknown, "Unknown thread %u has started rdebugging");
+				_LIT8(KUnknownKern, "Unknown kernel thread %u has started rdebugging");
+				LogNote(ELogNewRdebuggers, kern ? KUnknownKern() : KUnknown() , aThreadId);
+				iRDebugTags.Insert(aThreadId, tag); // So that we don't get the above message every time this thread debugs
+				}
+			else
+				{
+				err = thread.Open(aThreadId);
+				TPtr wPtr((TUint16*)tagBuf->Ptr(), KThreadTagNamBufLen);
+				if (err)
+					{
+					// Couldn't open thread - use Thread-xxx as tag
+					_LIT(KThreadFormat, "Thread-%u");
+					wPtr.Format(KThreadFormat, aThreadId);
+					}
+				else
+					{
+					//thread.FullName(wPtr); // This didn't exist on 9.1...
+					TFullName name = thread.FullName();
+					wPtr = name;
+					}
+				thread.Close();
+				TInt len = wPtr.Collapse().Length();
+				TPtr8 narrowPtr = tagBuf->Des();
+				narrowPtr.SetLength(len);
+				ThreadPrettyName(narrowPtr);
+				TPtrC8 safeName = tagBuf->Left(150);
+				_LIT8(KNewTag, "Thread [%u] (%S) has started rdebugging");
+				LogNote(ELogNewRdebuggers, KNewTag, aThreadId, &safeName);
+				TAny* theTag = NewSessionForTag(tagBuf);
+				if (theTag) 
+					{
+					tag = reinterpret_cast<TTagData*>(theTag);
+					tag->iThreadIdForRDebugger = aThreadId;
+					iRDebugTags.Insert(aThreadId, tag);
+					}
+				else
+					{
+					delete tagBuf;
+					}
+				}
+			}
+			// If an error occurred then we'll just log using the RDebug::Print tag
+		}
+
+	if (tag->iEnabled & enableMask)
+		{
+		Log(tag, aMsg, aTickCount);
+		}
+	else
+		{
+		RegisterDisabledLog(tag);
+		}
+	}
+
+void CCloggerServer::UpdatedGlobalOptionsL(TUint aOldOptions)
+	{
+	if ((aOldOptions & RClogger::EBufferLog) != (iOptions & RClogger::EBufferLog))
+		{
+		UpdateBufferSizeL(iBufferSize, iNumBuffers);
+		}
+
+	iWriters[ERDebug]->SetEnabled(iOptions & RClogger::EMirrorToRDebugPrint);
+	iWriters[EMessageQueue]->SetEnabled(iOptions & RClogger::EMirrorToMessageQueue);
+	iWriters[EFile]->SetEnabled(!(iOptions & RClogger::EDisableFileWriter));
+
+	TBool redirectRDebugBeingChanged = (aOldOptions & RClogger::ERedirectRDebugPrintToClogger) != (iOptions & RClogger::ERedirectRDebugPrintToClogger);
+	TBool mirrorRDebugChanged = (aOldOptions & RClogger::EMirrorToRDebugPrint) != (iOptions & RClogger::EMirrorToRDebugPrint);
+
+	if (redirectRDebugBeingChanged || mirrorRDebugChanged)
+		{
+		SetKernelLoggingL(iOptions & RClogger::ERedirectRDebugPrintToClogger);
+		}
+	}
+
+void CCloggerServer::TellAllWritersToWriteBuf(TInt aBuf)
+	{
+	for (TInt i = 0; i < iWriters.Count(); i++)
+		{
+		TellWriterToWriteBuf(i, aBuf);
+		}
+	}
+
+void CCloggerServer::TellWriterToWriteBuf(TInt aWriterId, TInt aBuf)
+	{
+	MWriter* writer = iWriters[aWriterId];
+	if (writer->IsEnabled() && !writer->IsBusyWriting())
+		{
+		if (aBuf == KSyncBufferIdx)
+			{
+			iSyncWriteBufferBusy |= (1<<aWriterId);
+			}
+		else
+			{
+			TBufEntry* entry = iBufs[aBuf];
+			entry->iBufferBusy |= (1<<aWriterId);
+			}
+		writer->WriteBuf(aBuf);
+		}
+	}
+
+void CCloggerServer::RegisterDisabledLog(TAny* aContext)
+	{
+	reinterpret_cast<TTagData*>(aContext)->SetShouldDisplay();
+	}
+
+void CCloggerServer::UpdatedBuffers(TBool aAboutToCloseBuffers)
+	{
+	if (!iKernDebugRouter)
+		{
+		// No point doing anything
+		return;
+		}
+	
+	// If there are more than 8 buffers then you're on your own!
+	const TInt KMaxBuffersInParams = 8; // Note - this should probably be defined to be the same as KMaxCrashDumpAreas
+	
+	TUint32 base = (TUint32)iChunkForBufs.Base();
+	
+	SCloggerCrashDumpArea bufAreas[KMaxBuffersInParams];
+	TInt numBuffers = 0;
+	if (!aAboutToCloseBuffers)
+		{
+		for (TInt i = 0; numBuffers < KMaxBuffersInParams && i < iBufs.Count(); i++)
+			{
+			TBufEntry* buf = iBufs[i];
+			bufAreas[numBuffers].iChunkHandle = iChunkForBufs.Handle();
+			bufAreas[numBuffers].iOffset = (TUint32)buf->iBuf.Ptr() - base;
+			bufAreas[numBuffers].iSize = buf->iBuf.MaxSize();
+			_LIT8(KBufName, "Clogger Buffer %i");
+			bufAreas[numBuffers].iName.Format(KBufName, i);
+			numBuffers++;
+			}
+		}
+	// Now check sessions for performance logging chunks
+	iSessionIter.SetToFirst();
+	CCloggerSession* sess;
+	while ((sess = (CCloggerSession*)iSessionIter++) != NULL)
+		{
+		TInt chunkHandle = sess->iPerformanceLoggingChunk.Handle();
+		if (chunkHandle && numBuffers < KMaxBuffersInParams)
+			{
+			bufAreas[numBuffers].iChunkHandle = chunkHandle;
+			bufAreas[numBuffers].iOffset = 0; // Performance logging uses the whole chunk
+			bufAreas[numBuffers].iSize = sess->iPerformanceLoggingChunk.Size();
+			_LIT8(KBufName, "Clogger MemLog ");
+			bufAreas[numBuffers].iName = KBufName;
+			TPtrC8 tagName = reinterpret_cast<TTagData*>(sess->iContext)->iTagName->Left(bufAreas[numBuffers].iName.MaxLength() - bufAreas[numBuffers].iName.Length());
+			bufAreas[numBuffers].iName.Append(tagName);
+			numBuffers++;
+			}
+		}
+	
+	TPtrC8 ptr((const TUint8*)&bufAreas[0], numBuffers * sizeof(SCloggerCrashDumpArea));
+	iKernDebugRouter->RegisterCrashDumpAreas(ptr);
+	}
+
+TInt CCloggerServer::CreateKernChunkForClient(RThread* aClient, TInt aMaxSize, TInt aCommittedSize, RChunk& aOurChunk)
+	{
+	if (!iKernDebugRouter)
+		{
+		return KErrNotSupported;
+		}
+
+	return iKernDebugRouter->CreateKernChunkForClient(aClient, aMaxSize, aCommittedSize, aOurChunk);
+	}
+
+TInt CCloggerServer::AdjustBufferChunk(TInt aNewSize)
+	{
+	// This is needed because you can't adjust a chunk created on kernel-side from user side. Grr.
+	TInt err = KErrNotSupported;
+	if (iKernDebugRouter)
+		{
+		err = iKernDebugRouter->AdjustChunk(iChunkForBufs, aNewSize);
+		} 
+	else if (iChunkForBufs.Handle()) // Might not have been created yet
+		{
+		// If the chunk wasn't created via the device driver, it's fine to adjust it directly
+		err = iChunkForBufs.Adjust(aNewSize);
+		}
+	return err;
+	}
+
+CSessionWriter* CCloggerServer::RegisterSessionWithSessionWriter(CSessionWriterSession* aSession)
+	{
+	CSessionWriter* sessionWriter = static_cast<CSessionWriter*>(iWriters[ESessionWriter]);
+	if (!aSession)
+		{
+		// Session closing
+		sessionWriter->SetEnabled(EFalse);
+		sessionWriter->iSession = NULL;
+		return NULL;
+		}
+	else if (sessionWriter->iSession)
+		{
+		// Already got one
+		return NULL;
+		}
+	else
+		{
+		sessionWriter->iSession = aSession;
+		return sessionWriter;
+		}
+	}
+
+RChunk& CCloggerServer::GetBufChunk()
+	{
+	return iChunkForBufs;
+	}
+
+void CCloggerServer::ThreadPrettyName(TDes8& aName)
+	{
+	// Algorithm is:
+	// Given a aName xxx(.exe)?\[uid\]nonce::(!)?yyy
+	// if yyy == xxx (case insensitive compare) then just display yyy (with exclamation mark if present)
+	// else display xxx::yyy
+
+	// Find the :: that splits thread and process name
+	_LIT8(KDoubleColon, "::");
+	TInt colon = aName.Find(KDoubleColon);
+	if (colon == KErrNotFound)
+		{
+		// It's not a thread name
+		return;
+		}
+
+	// Remove .exe if present immediately before [uid]
+	TInt brak = aName.Left(colon).LocateReverse('[');
+	_LIT8(KExe, ".exe");
+	if (brak >= 5 && aName.Mid(brak-4, 4).CompareF(KExe) == 0)
+		{
+		aName.Delete(brak-4, 4);
+		brak -= 4;
+		colon -= 4;
+		}
+
+	TPtrC8 procaName = brak >=0 ? aName.Left(brak) : aName.Left(colon);
+	TPtrC8 threadaName = aName.Mid(colon+2);
+	TPtrC8 realThreadaName = threadaName.Length() && threadaName[0] == '!' ? threadaName.Mid(1) : threadaName;
+	if (procaName.CompareF(realThreadaName) == 0)
+		{
+		aName.Delete(0, colon+2);
+		}
+	else if (brak >= 0)
+		{
+		aName.Delete(brak, colon-brak);
+		}
+	}
+
+TBool CCloggerServer::ForceBreakpointRequested() const
+	{
+	return iFlags.IsSet(EForceBreakpoint);
+	}
+
+inline TTime CCloggerServer::TickCountToTime(TUint32 aTickCount) const
+	{
+	return TTime(iTimeAtStartup.Int64() + (((TInt64)aTickCount*1000000) / (TInt64)iTickFreq) - iStartupTickInMicroseconds);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/Flogger.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,581 @@
+// Flogger.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include <fshell/clogger.h>
+#include "cliserv.h"
+
+// This file is shared between building shims for traditional flogger and comms debug util
+// Bits specific to one or the other are guarded with  __CDU__
+
+#ifdef __CDU__
+
+#define __FLOG_SUPPRESS_REL_WARNING
+#define __FLOG_ACTIVE
+#include <comms-infras/commsdebugutility.h>
+#define iPtr ((RClogger*)iLoggerBody)
+#define Connected() (iPtr && iPtr->Handle())
+#define DoClose() { if (iPtr) { iPtr->Close(); delete iPtr; iLoggerBody = NULL; } }
+
+#else
+
+#include <flogger.h>
+#define iPtr (*((RClogger**)&iFormatter))
+#define Connected() (iPtr && iPtr->Handle())
+#define DoClose() { if (iPtr) { iPtr->Close(); delete iPtr; } }
+
+#endif
+
+#define iClogger (*iPtr)
+#define FlogPtr(clogPtr) ((RFloggerClogger*)clogPtr)
+
+// declares RClogger* clogger
+#define CheckConnected(aDir, aPath)                            \
+	RClogger _cloggerHandle;                                   \
+	RClogger* clogger = &_cloggerHandle;                       \
+	GetTls(clogger, ETrue, &aDir, &aPath, ETrue, NULL);        \
+	if (!clogger) return
+
+#define CheckConnected8(aDir, aPath)                           \
+	RClogger _cloggerHandle;                                   \
+	RClogger* clogger = &_cloggerHandle;                       \
+	GetTls(clogger, ETrue, &aDir, &aPath, EFalse, NULL);       \
+	if (!clogger) return
+
+/*
+#define GetTlsOrConnect(aTag)                                  \
+	RClogger _cloggerHandle;                                   \
+	RClogger* clogger = &_cloggerHandle;                       \
+	TInt err;                                                  \
+	TBool isHandle = GetTls(clogger, ETrue, &aTag, &err)
+*/
+
+#define GetTlsOrNull()                                         \
+	RClogger _cloggerHandle;                                   \
+	RClogger* clogger = &_cloggerHandle;                       \
+TBool isHandle = ::GetTls(clogger, EFalse, &KNullDesC, &KNullDesC, ETrue, NULL)
+
+#define KDontAllocateWhileLogging 0x20000000
+
+static TBool GetTls(RClogger*& aClogger, TBool aAutoConnect, const TAny* aTag, const TAny* aSubTag, TBool aWide, TInt* aError);
+
+// Need these because flogger has a single-argument overload that doesn't have a format applied over it, and clogger doesn't
+_LIT8(KEsc8, "%S");
+_LIT(KEsc, "%S");
+
+#define iBody (*(RCloggerBody*)&iPimpl)
+
+#ifdef _DEBUG
+// Close the session after every call in debug builds, to avoid heap-check and handle-check failures
+#define STATICCLOSE() RFloggerClogger::FloggerStaticClose()
+#else
+#define STATICCLOSE()
+#endif
+
+class RFloggerClogger : public RClogger
+	{
+public:
+	TUint& Flags()
+		{
+		return iFlags;
+		}
+
+	TInt FloggerConnect(const TDesC& aDir, const TDesC& aName)
+		{
+		TAny* arg1 = NULL;
+		TInt err = Reserved(0xF10C10, arg1, NULL); // Does the connect
+		if (!err)
+			{
+			err = DoSetTags(aDir, aName);
+			}
+		return err;
+		}
+
+	TInt FloggerConnect(const TDesC8& aDir, const TDesC8& aName)
+		{
+		TAny* arg1 = NULL;
+		TInt err = Reserved(0xF10C10, arg1, NULL); // Does the connect
+		if (!err)
+			{
+			err = DoSetTags8(aDir, aName);
+			}
+		return err;
+		}
+
+	TInt DoSetTags(const TDesC& aDir, const TDesC& aName)
+		{
+		//TPtrC name(aName);
+		//_LIT(KDotTxt, ".txt");
+		//_LIT(KDotLog, ".log");
+		//if (name.Right(KDotTxt().Length()) == KDotTxt) name.Set(name.Left(name.Length()-KDotTxt().Length()));
+		//else if (name.Right(KDotLog().Length()) == KDotLog) name.Set(name.Left(name.Length()-KDotLog().Length()));
+		TPckg<TUint32> enabledPkg(iEnabled);
+		TInt result = SendReceive(ESetTag, TIpcArgs(&aDir, &aName, &enabledPkg));
+		if (result >= 0)
+			{
+			iSequence = result;
+			return KErrNone;
+			}
+		else
+			{
+			return result;
+			}
+		}
+
+	TInt DoSetTags8(const TDesC8& aDir, const TDesC8& aName)
+		{
+		//TPtrC8 name(aName);
+		//_LIT8(KDotTxt, ".txt");
+		//_LIT8(KDotLog, ".log");
+		//if (name.Right(KDotTxt().Length()) == KDotTxt) name.Set(name.Left(name.Length()-KDotTxt().Length()));
+		//else if (name.Right(KDotLog().Length()) == KDotLog) name.Set(name.Left(name.Length()-KDotLog().Length()));
+		TPckg<TUint32> enabledPkg(iEnabled);
+		TInt result = SendReceive(ESetTag8, TIpcArgs(&aDir, &aName, &enabledPkg));
+		if (result >= 0)
+			{
+			iSequence = result;
+			return KErrNone;
+			}
+		else
+			{
+			return result;
+			}
+		}
+
+	static void FloggerStaticClose()
+		{
+		GetTlsOrNull();
+		if (clogger)
+			{
+			clogger->Close();
+			if (!isHandle)
+				{
+				delete clogger;
+				}
+			Dll::SetTls(NULL);
+			Dll::FreeTls();
+			}
+		}
+
+	void HexDump16(const TDesC16& aHeader, const TDesC8& aData)
+		{
+		SendReceive(2002, TIpcArgs(&aHeader, &aData, User::NTickCount(), RClogger::EAllEnabled));
+		}
+	};
+
+static TBool GetTls(RClogger*& aClogger, TBool aAutoConnect, const TAny* aTag, const TAny* aSubTag, TBool aWide, TInt* aError)
+	{
+	TAny* tls = Dll::Tls();
+	if ((TUint)tls & 1)
+		{
+		// Then it's a handle
+		aClogger->SetHandle((TInt)((TUint)tls >> 1));
+		return ETrue;
+		}
+	else if (tls)
+		{
+		// Then it's a pointer
+		aClogger = (RClogger*)tls;
+		return EFalse;
+		}
+	else if (aAutoConnect)
+		{
+		//TInt err = aClogger->Connect(aTag ? *aTag : KNullDesC);
+		TInt err;
+		if (aWide)
+			{
+			err = FlogPtr(aClogger)->FloggerConnect(*(const TDesC*)aTag, *(const TDesC*)aSubTag);
+			}
+		else
+			{
+			err = FlogPtr(aClogger)->FloggerConnect(*(const TDesC8*)aTag, *(const TDesC8*)aSubTag);
+			}
+		
+		if (err)
+			{
+			if (aError) *aError = err;
+			aClogger = NULL;
+			return ETrue;
+			}
+		if ((aClogger->Handle() & 0x80000000) != 0)
+			{
+			__ASSERT_DEBUG(EFalse, User::Panic(_L("HandleTooBig"), 0));
+			err = KErrOverflow;
+			}
+
+		if (!err)
+			{
+			err = Dll::SetTls((TAny*) ((aClogger->Handle() << 1) | 1));
+			}
+
+		if (err)
+			{
+			aClogger->Close();
+			if (aError) *aError = err;
+			aClogger = NULL;
+			}
+		return ETrue;
+		}
+	else
+		{
+		aClogger = NULL;
+		return ETrue;
+		}
+	}
+
+EXPORT_C RFileLogger::RFileLogger()
+	{
+	Mem::FillZ(this, sizeof(RFileLogger));
+	}
+
+EXPORT_C RFileLogger::~RFileLogger()
+	{
+	}
+
+EXPORT_C TVersion RFileLogger::Version() const
+	{
+	return TVersion(1, 0, 20);
+	}
+
+EXPORT_C TInt RFileLogger::Connect()
+	{
+	if (Connected())
+		{
+		return KErrAlreadyExists;
+		}
+
+	#ifdef __CDU__
+		iLoggerBody = (RFileLoggerBody*)new RClogger();
+		if (!iLoggerBody) return KErrNoMemory;
+	#else
+		iPtr = new RClogger();
+		if (!iPtr) return KErrNoMemory;
+	#endif
+
+	TInt err = iClogger.Connect();
+	/*
+	#ifdef _DEBUG
+		if (!err)
+			{
+			// Don't cache client buffers in debug mode (so we will pass UDEB heap check macros)
+			FlogPtr(iPtr)->Flags() &= ~RClogger::ECacheClientBuffers;
+			}
+	#endif
+	*/
+
+	#if !defined(__CDU__) && defined(_DEBUG)
+		if (err == KErrNone)
+			{
+			SetHandle(iClogger.Handle()); // We do this so that when Close() is called, it cleans up the clogger interface. And we do that because we can't override Close(), and if the session doesn't get closed somehow, we'll fail CONE's handle check in debug builds
+			}
+	#endif
+	if (!err)
+		{
+		iClogger.SetLogBehaviour(0 /*RClogger::EMonitorTagState*/); // Don't set EUseHeapBuffer because then we won't be thread-safe
+		}
+	else
+		{
+		DoClose();
+		}
+	return err;
+	}
+
+EXPORT_C void RFileLogger::SetDateAndTime(TBool /*aUseDate*/, TBool /*aUseTime*/)
+	{
+	// Has no real meaning in clogger
+	}
+
+EXPORT_C void RFileLogger::CreateLog(const TDesC& aDir, const TDesC& aName, TFileLoggingMode /*aMode*/)
+	{
+	TInt err;
+	if (Connected())
+		{
+		err = FlogPtr(&iClogger)->DoSetTags(aDir, aName);
+		}
+	else
+		{
+		err = KErrNotFound;
+		}
+	#ifdef __CDU__
+		if (err) {} //Like CDU, ignore errors in legacy methods. This construction shuts up RVCT
+	#else
+		 iLastError = err;
+	#endif
+
+	}
+
+EXPORT_C void RFileLogger::CloseLog()
+	{
+	// Has no meaning in clogger terms
+	}
+
+EXPORT_C void RFileLogger::Write(const TDesC16& aText)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	iClogger.Log(RClogger::EAllEnabled, KEsc, &aText);
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC16> aFmt,...)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	VA_LIST args;
+	VA_START(args, aFmt);
+	iClogger.LogList(RClogger::EAllEnabled, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	iClogger.LogList(RClogger::EAllEnabled, aFmt, aList);
+	}
+
+EXPORT_C void RFileLogger::Write(const TDesC8& aText)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	iClogger.Log(RClogger::EAllEnabled, KEsc8, &aText);
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	VA_LIST args;
+	VA_START(args, aFmt);
+	iClogger.LogList(RClogger::EAllEnabled, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	iClogger.LogList(RClogger::EAllEnabled, aFmt, aList);
+	}
+
+EXPORT_C void RFileLogger::HexDump(const TText* aHeader, const TText* /*aMargin*/, const TUint8* aPtr, TInt aLen)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	TPtrC16 header;
+	if (aHeader)
+		{
+		header.Set(aHeader, User::StringLength(aHeader));
+		}
+	const TPtrC8 data(aPtr, aLen);
+	FlogPtr(iPtr)->HexDump16(header, data);
+	}
+
+EXPORT_C TInt RFileLogger::LastError() const
+	{
+	#ifdef __CDU__
+		return KErrNone;
+	#else
+		return iLastError;
+	#endif
+	}
+
+EXPORT_C TBool RFileLogger::LogValid() const
+	{
+	return ETrue;
+	}
+
+// The static functions
+EXPORT_C void RFileLogger::Write(const TDesC& aDir, const TDesC& aName, TFileLoggingMode /*aMode*/, const TDesC16& aText)
+	{
+	CheckConnected(aDir, aName);
+	clogger->Log(KEsc, &aText);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC16> aFmt,...)
+	{
+	CheckConnected(aDir, aName);
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(aFmt, args);
+	VA_END(args);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
+	{
+	CheckConnected(aDir, aName);
+	clogger->LogList(aFmt, aList);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::Write(const TDesC& aDir, const TDesC& aName, TFileLoggingMode /*aMode*/, const TDesC8& aText)
+	{
+	CheckConnected(aDir, aName);
+	clogger->Log(KEsc8, &aText);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC8> aFmt,...)
+	{
+	CheckConnected(aDir, aName);
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(aFmt, args);
+	VA_END(args);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
+	{
+	CheckConnected(aDir, aName);
+	clogger->LogList(aFmt, aList);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::HexDump(const TDesC& aDir, const TDesC& aName, TFileLoggingMode /*aMode*/, const TText* aHeader, const TText* /*aMargin*/, const TUint8* aPtr, TInt aLen)
+	{
+	CheckConnected(aDir, aName);
+	const TPtrC16 header(aHeader);
+	const TPtrC8 data(aPtr, aLen);
+
+	FlogPtr(clogger)->HexDump16(header, data);
+	}
+
+// Boring stuff
+
+#ifndef __CDU__
+
+TLogFormatter::TLogFormatter() {}
+TLogFile::TLogFile() {}
+void TLogFormatter8Overflow::Overflow(TDes8& /*aDes*/) {}
+void TLogFormatter16Overflow::Overflow(TDes16& /*aDes*/) {}
+EXPORT_C TInt FLogger::Run(FLogger::TSignal& /*aSignal*/)
+	{
+	return KErrNotSupported;
+	}
+
+#endif
+
+#ifdef __CDU__
+
+// Some functions new in CDU
+
+EXPORT_C void RFileLogger::Close()
+	{
+	DoClose();
+	}
+
+EXPORT_C void ClientRunStubOrdinal1()
+	{
+	}
+
+EXPORT_C TInt RFileLogger::ClearLog()
+	{
+	if (!Connected()) return KErrNone; // Be compatible with CDU and flogger in terms of not crashing
+	return iClogger.Rotate(); // Close enough
+	}
+
+EXPORT_C TInt RFileLogger::SetLogTags(const TDesC8& aSubsystem, const TDesC8& aComponent)
+	{
+	return FlogPtr(iPtr)->DoSetTags8(aSubsystem, aComponent);
+	}
+
+EXPORT_C void RFileLogger::__DbgShutDownServer()
+	{
+	// Why bother supporting this?
+	}
+
+EXPORT_C void RFileLogger::__DbgSetHeapFailure(TInt /*aFailAfter*/)
+	{
+	// See above...
+	}
+
+EXPORT_C void RFileLogger::WriteBinary(const TDesC8& aData)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	iClogger.Log(KEsc8, &aData);
+	}
+
+EXPORT_C void RFileLogger::HexDump(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aData, const TDesC8& aHeader)
+	{
+	CheckConnected8(aSubsystem, aComponent);
+
+	clogger->HexDump(aHeader, aData);
+	}
+
+EXPORT_C void RFileLogger::HexDump(const TDesC8& aData, const TDesC8& aHeader)
+	{
+	if (!Connected()) return; // Be compatible with CDU and flogger in terms of not crashing
+	iClogger.HexDump(aHeader, aData);
+	}
+
+EXPORT_C TInt RFileLogger::Handle() const
+	{
+	return iClogger.Handle();
+	}
+
+EXPORT_C TInt RFileLogger::Share() 
+	{
+	return iClogger.ShareAuto();
+	}
+
+EXPORT_C void RFileLogger::Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText)
+	{
+	CheckConnected8(aSubsystem, aComponent);
+	clogger->Log(KEsc8, &aText);
+	}
+
+EXPORT_C void RFileLogger::Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC& aText)
+	{
+	CheckConnected8(aSubsystem, aComponent);
+	clogger->Log(KEsc, &aText);
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC16> aFmt, ...)
+	{
+	CheckConnected8(aSubsystem, aComponent);
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(aFmt, args);
+	VA_END(args);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC8> aFmt, ...)
+	{
+	CheckConnected8(aSubsystem, aComponent);
+	VA_LIST args;
+	VA_START(args, aFmt);
+	clogger->LogList(aFmt, args);
+	VA_END(args);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
+	{
+	CheckConnected8(aSubsystem, aComponent);
+	clogger->LogList(aFmt, aList);
+
+	STATICCLOSE();
+	}
+
+EXPORT_C void RFileLogger::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
+	{
+	CheckConnected8(aSubsystem, aComponent);
+	clogger->LogList(aFmt, aList);
+
+	STATICCLOSE();
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/MiscServer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,541 @@
+// MiscServer.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "CloggerServer.h"
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+
+#ifdef FSHELL_EZLIB_SUPPORT
+#include <EZCompressor.h>
+//#include <EZDecompressor.h>
+#include <EZlib.h>
+#include <EZGzip.h>
+#endif
+
+_LIT8(KDiskFull, "\r\n" MINTAGSTART "Log truncated due to disk full\r\n");
+
+void CLogWriter::WriteBuf(TInt aBuf)
+	{
+	ASSERT(!IsActive() && iEnabled);
+		{
+		iBuf = aBuf;
+		iFile.Write(iServer.GetBuf(aBuf), iStatus);
+		SetActive();
+		}
+	}
+
+TBool CLogWriter::IsBusyWriting()
+	{
+	return IsActive();
+	}
+
+void CLogWriter::RunL()
+	{
+	if (iStatus == KErrDiskFull)
+		{
+		//TODO Make this occur before the disk is actually completely empty?
+		TInt filePos = 0;
+		TInt err = iFile.Seek(ESeekCurrent, filePos);
+		if (err == KErrNone && filePos > KDiskFull().Length()) // ensure the file has enough room in it for our message
+			{
+			// Rewind the log file and overwrite the tail of it with a warning to say the disk is full
+			filePos = filePos - KDiskFull().Length();
+			err = iFile.Seek(ESeekStart, filePos);
+			if (err == KErrNone)
+				{
+				iFile.Write(KDiskFull, iStatus);
+				SetActive();
+				return;
+				}
+			}
+		}
+	iServer.CompletedWritingBuf(this, iBuf);
+	}
+
+void CLogWriter::DoCancel()
+	{
+	// There's no way to cancel a file write (or any semantic sense to do so) so by doing nothing we get the SyncWaitForCompletion behaviour we wanted
+	}
+
+CLogWriter::~CLogWriter()
+	{
+	// Don't cancel, CloggerServer is supposed to guarantee we won't be deleted when still writing
+	//Cancel();
+	}
+
+void CLogWriter::CloseWriter()
+	{
+	delete this;
+	}
+
+void CLogWriter::SetEnabled(TBool aEnabled)
+	{
+	if (!iFile.SubSessionHandle())
+		{
+		// If the log file is not open, we can't enable ourselves even if the client asks us to
+		aEnabled = EFalse;
+		}
+	iEnabled = aEnabled;
+	}
+
+CRDebugWriter::CRDebugWriter(CCloggerServer& aServer)
+	: iServer(aServer)
+	{}
+
+void CRDebugWriter::WriteBufL(const TDesC8& aBuf)
+	{
+	TInt maxLen = 256;
+
+	// RDebug::Print only accepts 256 chars on the kernel side, so split the write up
+	TInt pos = 0;
+	while (pos < aBuf.Length())
+		{
+		TPtrC8 frag = aBuf.Mid(pos, Min(maxLen, aBuf.Length() - pos));
+		//Exec::DebugPrint((TAny*)&frag, 1); // This is quicker than calling RDebugPrint - cuts down on a memory copy
+		// ^ Except that you can't do it from non-euser code...
+		LtkUtils::RawPrint(frag);
+		pos += frag.Length();
+		}
+	}
+
+void CRDebugWriter::CloseWriter()
+	{
+	delete this;
+	}
+
+///////////////
+
+TInt CSyncWriterWrapper::ThreadFunction(TAny* aSelf)
+	{
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+	if (!cleanup) return KErrNoMemory;
+	
+	CSyncWriterWrapper* self = static_cast<CSyncWriterWrapper*>(aSelf);
+	for (;;)
+		{
+		User::WaitForRequest(self->iThreadStatus);
+		//User::After(1); //DEBUG TO TEST SLOW WRITERS
+		if (self->iThreadStatus != KErrNone)
+			{
+			break;
+			}
+
+		const TDesC8& buf = self->iServer.GetBuf(self->iBuf);
+
+		TRAPD(err, self->iWriter.WriteBufL(buf));
+
+		self->iThreadStatus = KRequestPending;
+		TRequestStatus* stat = &self->iStatus;
+		self->iMainThread.RequestComplete(stat, err);
+		}
+
+	delete cleanup;
+	return self->iThreadStatus.Int();
+	}
+
+void CSyncWriterWrapper::WriteBuf(TInt aBuf)
+	{
+	ASSERT(!IsActive() && iEnabled);
+		{
+		iBuf = aBuf;
+		iStatus = KRequestPending;
+		SetActive();
+		TRequestStatus* stat = &iThreadStatus;
+		iWorkerThread.RequestComplete(stat, KErrNone);
+		}
+	}
+
+TBool CSyncWriterWrapper::IsBusyWriting()
+	{
+	return IsActive();
+	}
+
+void CSyncWriterWrapper::RunL()
+	{
+	iServer.CompletedWritingBuf(this, iBuf);
+	}
+
+void CSyncWriterWrapper::DoCancel()
+	{
+	// There's no way to cancel a sync writer
+	}
+
+CSyncWriterWrapper::~CSyncWriterWrapper()
+	{
+	// Don't cancel, CloggerServer is supposed to guarantee we won't be deleted when still writing
+	//Cancel();
+	if (iWorkerThread.Handle())
+		{
+		TRequestStatus* stat = &iThreadStatus;
+		iWorkerThread.RequestComplete(stat, KErrCancel);
+		TRequestStatus rv;
+		iWorkerThread.Rendezvous(rv);
+		User::WaitForRequest(rv);
+		iWorkerThread.Close();
+		}
+	iMainThread.Close();
+	if (iOwnWriter)
+		{
+		iWriter.CloseWriter();
+		}
+	}
+
+void CSyncWriterWrapper::CloseWriter()
+	{
+	delete this;
+	}
+
+void CSyncWriterWrapper::SetEnabled(TBool aEnabled)
+	{
+	iEnabled = aEnabled;
+	}
+
+CSyncWriterWrapper::CSyncWriterWrapper(CCloggerServer& aServer, MSyncWriter& aWriter)
+	: CActive(EPriorityHigh), // It's more important to keep writing than to handle clientserver calls
+	iServer(aServer), iWriter(aWriter), iBuf(-1), iEnabled(EFalse)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CSyncWriterWrapper* CSyncWriterWrapper::NewL(CCloggerServer& aServer, MSyncWriter& aWriter, TInt aWriterId)
+	{
+	CSyncWriterWrapper* self = new(ELeave) CSyncWriterWrapper(aServer, aWriter);
+	CleanupStack::PushL(self);
+	self->ConstructL(aWriterId);
+	CleanupStack::Pop(self);
+	self->iOwnWriter = ETrue;
+	return self;
+	}
+
+void CSyncWriterWrapper::ConstructL(TInt aWriterId)
+	{
+	User::LeaveIfError(iMainThread.Open(RThread().Id()));
+	_LIT(KName, "SyncWriter%i");
+	TBuf<16> name;
+	name.Format(KName, aWriterId);
+	User::LeaveIfError(iWorkerThread.Create(name, &ThreadFunction, 2048, NULL, this));
+	if (aWriterId >= 0)
+		{
+		iWorkerThread.SetPriority(EPriorityMore); // To ensure buffers aren't being filled without us having a chance to empty them
+		}
+	else
+		{
+		iWorkerThread.SetPriority(EPriorityMuchLess); // We use the sync writer wrapper around the background compress of rotated log files, and that operation should be low priority
+		}
+	iWorkerThread.Resume();
+	}
+
+//////////
+
+CLogCompressor* CLogCompressor::NewLC(CCloggerServer& aServer)
+	{
+	CLogCompressor* self = new(ELeave) CLogCompressor(aServer);
+	CleanupStack::PushL(self);
+	User::LeaveIfError(self->iFs.Connect());
+	self->iFs.ShareAuto();
+	return self;
+	}
+
+CLogCompressor::CLogCompressor(CCloggerServer& aServer)
+	: iServer(aServer)
+	{
+	}
+
+CLogCompressor::~CLogCompressor()
+	{
+	}
+
+void CLogCompressor::WriteBufL(const TDesC8& /*aBuf*/)
+	{
+	TDes& filename = iServer.GetFilenameToRotate();
+
+	HBufC* compressedFile = HBufC::NewLC(filename.Length()+3);
+	_LIT(KFmt, "%S.gz");
+	compressedFile->Des().Format(KFmt, &filename);
+
+	RFile input;
+
+	//_LIT(KInfo,"Compressing file %S to %S\n");
+	//console->Printf(KInfo,&inputFile,compressedFile);
+
+	User::LeaveIfError(input.Open(iFs, filename, EFileStream | EFileRead | EFileShareAny));
+	CleanupClosePushL(input);
+
+	TRAPD(err, DoGzipL(input, *compressedFile));
+
+	if (err)
+		{
+		// If the compress failed, delete any fragment (don't care if this fails)
+		iFs.Delete(*compressedFile);
+		}
+
+	//_LIT(KHoorah,"Hoorah");
+	//console->Printf(KHoorah);
+
+	CleanupStack::PopAndDestroy(&input);
+	if (err == KErrNone)
+		{
+		// Don't delete the original unless the compress succeeded!
+		err = iFs.Delete(filename);
+		}
+	if (err == KErrNone)
+		{
+		// We've sucessfully compressed our file, so update filename to reflect that
+		filename = *compressedFile;
+		}
+	// Don't do anything if the delete fails - the file(s) will be cleaned up when the max number of rotated logs is exceeded
+	CleanupStack::PopAndDestroy(compressedFile);
+	}
+
+void CLogCompressor::CloseWriter()
+	{
+	delete this;
+	}
+
+void CLogCompressor::DoGzipL(RFile& aInput, const TDesC& aOutput)
+	{
+#ifdef FSHELL_EZLIB_SUPPORT
+	const TInt bufferSize = 0x8000; // 32 KB
+	CEZFileToGZip* com = CEZFileToGZip::NewLC(iFs, aOutput, aInput, bufferSize);
+	while (com->DeflateL()){/*do nothing*/}
+	CleanupStack::PopAndDestroy(com);
+#else
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+////
+
+CMessageQueueWriter* CMessageQueueWriter::NewL()
+	{
+	CMessageQueueWriter* self = new(ELeave) CMessageQueueWriter;
+	TInt err = self->iQ.CreateGlobal(_L("Clogger.LogMessageQueue"), 4);
+
+	if (err)
+		{
+		DISOWN(self);
+		User::Leave(err);
+		}
+	return self;
+	}
+
+void CMessageQueueWriter::WriteBufL(const TDesC8& aBuf)
+	{
+	TBuf8<128> buf;
+	TPtrC8 lineFrag(aBuf);
+	while (lineFrag.Length())
+		{
+		TInt spaceFree = buf.MaxLength() - buf.Length();
+		buf.Append(lineFrag.Left(spaceFree));
+		TInt err = iQ.Send(buf);
+		if (err == KErrOverflow)
+			{
+			// Drop a frame
+			TBuf8<128> buf2;
+			iQ.Receive(buf2);
+			// And resend
+			err = iQ.Send(buf);
+			}
+
+		lineFrag.Set(lineFrag.Mid(Min(spaceFree, lineFrag.Length())));
+		buf.Zero();
+		}
+	}
+
+void CMessageQueueWriter::CloseWriter()
+	{
+	delete this;
+	}
+
+CMessageQueueWriter::CMessageQueueWriter()
+	{
+	}
+
+CMessageQueueWriter::~CMessageQueueWriter()
+	{
+	iQ.Close();
+	}
+
+CDebugRouterClient* CDebugRouterClient::NewL(CCloggerServer& aServer)
+	{
+	CDebugRouterClient* self = new(ELeave) CDebugRouterClient(aServer);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+void CDebugRouterClient::ConstructL()
+	{
+	TInt err = RCloggerDebugRouter::LoadDriver();
+	if (err != KErrAlreadyExists)
+		{
+		User::LeaveIfError(err);
+		}
+	User::LeaveIfError(iDebugRouter.Open());
+	}
+
+void CDebugRouterClient::OpenChunkL()
+	{
+	if (!iSharedChunk.Handle())
+		{
+		User::LeaveIfError(iDebugRouter.OpenChunk(iSharedChunk));
+		iTempBuf.CreateL(2048);
+		}
+	}
+
+CDebugRouterClient::CDebugRouterClient(CCloggerServer& aServer)
+: CActive(CActive::EPriorityStandard + 1), iServer(aServer) // Priority just higher than the server object - it's slightly more important we keep the device driver buffer serviced than we handle normal logging requests
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CDebugRouterClient::~CDebugRouterClient()
+	{
+	Cancel();
+	if (iDebugRouter.Handle())
+		{
+		iDebugRouter.EnableDebugRouting(RCloggerDebugRouter::EDisable); // I don't really know whether to call this before or after the cancel
+		iDebugRouter.Close();
+		}
+	RCloggerDebugRouter::CloseDriver();
+	iSharedChunk.Close();
+	iTempBuf.Close();
+	}
+
+TPtrC8 Read(TDes8& aTempBuf, TPtrC8& aData, TInt aLength, TPtrC8& aOverflowData)
+	{
+	if (aLength <= aData.Length())
+		{
+		// Can read it from this buffer
+		TPtrC8 res(aData.Left(aLength));
+		aData.Set(aData.Mid(aLength));
+		return res;
+		}
+	else /*if (aLength > aData.Length())*/
+		{
+		// Descriptor spans wrap point, so need to copy into temp buf
+		aTempBuf.Copy(aData.Left(aTempBuf.MaxLength())); // If anyone's crazy enough to write a platsec diagnostic string longer than 2k, it gets truncated
+		TInt overflowLen = aLength - aData.Length();
+		aData.Set(aOverflowData); // Wrap aData
+		aOverflowData.Set(TPtrC8());
+		if (overflowLen > aData.Length())
+			{
+			ASSERT(EFalse); // Shouldn't happen
+			// in urel, return everything we've got
+			return aData;
+			}
+		aTempBuf.Append(aData.Left(overflowLen));
+		aData.Set(aData.Mid(overflowLen));
+		return TPtrC8(aTempBuf);
+		}
+	}
+
+void CDebugRouterClient::RunL()
+	{
+	TUint chunkSize = iSharedChunk.Size();
+	const TUint KDataStartOffset = sizeof(SDebugChunkHeader);
+	SDebugChunkHeader* chunkHeader = (SDebugChunkHeader*)iSharedChunk.Base();
+	TUint start = chunkHeader->iStartOffset;
+	TUint end = chunkHeader->iEndOffset;
+	TUint overflows = chunkHeader->iOverflows;
+
+	TBool wrap = (start > end);
+	TUint endLen = wrap ? chunkSize - start : end - start;
+	TUint startLen = wrap ? end - KDataStartOffset : 0;
+
+	TPtrC8 endData(iSharedChunk.Base() + start, endLen);
+	TPtrC8 startData;
+	if (wrap) startData.Set(iSharedChunk.Base() + KDataStartOffset, startLen);
+	TPtrC8 data(endData);
+
+	while (data.Length())
+		{
+		TPtrC8 header = Read(iTempBuf, data, sizeof(SCloggerTraceInfo), startData);
+		if (header.Length() < (TInt)sizeof(SCloggerTraceInfo))
+			{
+			ASSERT(EFalse); // for udeb
+			break; // Something's broken
+			}
+		SCloggerTraceInfo info;
+		Mem::Copy(&info, header.Ptr(), sizeof(SCloggerTraceInfo));
+		ASSERT(info.iTraceType == 'K' || info.iTraceType == 'U' || info.iTraceType == 'P');
+		TPtrC8 msg = Read(iTempBuf, data, info.iLength, startData);
+		iServer.LogKernMessage(info.iTraceType, info.iTickCount, info.iThreadId, msg);
+		}
+	if (overflows)
+		{
+		_LIT8(KErr, "RDebug::Print buffer overflowed, %u calls not logged");
+		iServer.LogError(KErr, overflows);
+		}
+	// Zero the memory so it's easier to read in the crashlog
+	memclr(iSharedChunk.Base() + start, endLen);
+	if (startLen) memclr(iSharedChunk.Base() + KDataStartOffset, startLen);
+	
+	StartRouting(-1); // Magic number to indicate no need to call EnableDebugRouting again
+	}
+
+void CDebugRouterClient::DoCancel()
+	{
+	iDebugRouter.CancelReceive();
+	//iDebugRouter.EnableDebugRouting(EFalse);
+	// We only call Cancel() outside of our destructor when doing a FlushBuffers, in that case we'd like to make use of the device drivers buffering if possible, and not tell it to stop completely
+	}
+
+void CDebugRouterClient::StartRouting(TBool aConsumeLogs)
+	{
+	if (aConsumeLogs != -1)
+		{
+		RCloggerDebugRouter::TEnableOption enable = aConsumeLogs ? RCloggerDebugRouter::EEnableRoutingAndConsume : RCloggerDebugRouter::EEnableRouting;
+		iDebugRouter.EnableDebugRouting(enable);
+		}
+	if (!IsActive())
+		{
+		iDebugRouter.ReceiveData(iStatus);
+		SetActive();
+		}
+	}
+
+void CDebugRouterClient::StopRouting()
+	{
+	Cancel();
+	iDebugRouter.EnableDebugRouting(RCloggerDebugRouter::EDisable);
+	}
+
+TInt CDebugRouterClient::RegisterCrashDumpAreas(const TDesC8& aCrashDumpAreas)
+	{
+	return iDebugRouter.RegisterCrashDumpAreas(aCrashDumpAreas);
+	}
+
+TInt CDebugRouterClient::CreateKernChunkForClient(RThread* aClient, TInt aMaxSize, TInt aCommittedSize, RChunk& aOurChunk)
+	{
+	SCreateChunkParams params;
+	params.iHandleOfOtherThread = aClient ? aClient->Handle() : 0;
+	params.iMaxSize = aMaxSize;
+	params.iCommittedSize = aCommittedSize;
+	params.iChunkHandle = 0; // Not strictly necessary to set this
+	params.iOtherThreadChunkHandle = 0; // Not strictly necessary to set this
+	
+	TInt err = iDebugRouter.CreateChunk(params);
+	if (err == KErrNone)
+		{
+		aOurChunk.SetHandle(params.iChunkHandle);
+		return aClient ? params.iOtherThreadChunkHandle : KErrNone;
+		}
+	return err;
+	// Return either an error, or the handle for the other thread, or KErrNone if there was no error and we didn't specify another thread
+	}
+
+TInt CDebugRouterClient::AdjustChunk(RChunk& aChunk, TInt aNewSize)
+	{
+	return iDebugRouter.AdjustChunk(aChunk, aNewSize);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/PerformanceCritical.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,366 @@
+// PerformanceCritical.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/clogger.h>
+
+const TInt KChunkSize = 2*1024*1024; // 2MB
+
+#ifdef __ARMCC__
+// RVCT doesn't like inlining DoLog when it's used more than once
+#define FORCEINLINE __forceinline
+#else
+#define FORCEINLINE 
+#endif
+
+// We use a minimum of 4KB by having any global data, so no need to scrimp or only stash a pointer
+
+TBuf8<2048> gTempBuf;
+TUint8* gTempBufPtr = NULL;
+
+RClogger gClogger;
+RChunk gChunk;
+TInt* gBufSize = NULL;
+TUint8* gBufPtr = NULL;
+
+TBool gInitialised = EFalse; // Since POD is guaranteed to be initialised properly we'll use this to test whether we've already setup the global data
+TBuf8<10> gTimeBuf;
+TUint8* gTimeBufPtr = NULL;
+
+enum TPanic
+	{
+	E16BitFunctionsNotSupported,
+	ENotEnoughMemoryForBuffer,
+	ECouldntConnectToClogger,
+	EBufferFull,
+	};
+
+void BlowUp(TPanic aPanic)
+	{
+	User::Panic(_L("CloggerPerfLog"), aPanic);
+	}
+
+EXPORT_C TInt RClogger::StaticConnect(const TDesC& aTag)
+	{
+	if (gInitialised) return KErrNone;
+
+	// Will do these because I not 100% certain about what guarantees the runtime provides
+	// about initialisation of non-POD globals
+	new(&gClogger) RClogger;
+	new(&gChunk) RChunk;
+	new(&gTempBuf) TBuf8<2048>;
+	new(&gTimeBuf) TBuf8<10>;
+	gTimeBufPtr = (TUint8*)gTimeBuf.Ptr();
+	gTempBufPtr = (TUint8*)gTempBuf.Ptr();
+		
+	TInt err = gClogger.Connect(aTag);
+	if (err)
+		{
+		BlowUp(ECouldntConnectToClogger);
+		//gChunk.Close();
+		}
+	
+	TAny* arg0 = &gChunk;
+	err = gClogger.Reserved(0xC0FFEE, arg0, (TAny*)KChunkSize); // Get chunk from the server using the magic Reserved function
+	
+	if (err)
+		{
+		BlowUp(ENotEnoughMemoryForBuffer);
+		}
+
+	TUint8* base = gChunk.Base();
+	gBufSize = reinterpret_cast<TInt*>(base); // Use first word of chunk to indicate size
+	*gBufSize = 0;
+	//gBuf.Set(base+4, 0, KChunkSize-4);
+	gBufPtr = base+4;
+
+#ifdef _DEBUG
+	// For debugging when something failed to write to a part of the chunk
+	memset(gBufPtr, 'i', KChunkSize-4);
+#endif
+
+	gInitialised = ETrue;
+	return err;
+	}
+
+EXPORT_C void RClogger::StaticClose()
+	{
+	if (gInitialised)
+		{
+		gClogger.Close();
+		gChunk.Close();
+		gInitialised = EFalse;
+		}
+	}
+
+//#ifdef __BIG_ENDIAN__
+//const TUint16 KCrLf = 0x0d0a;
+//#else
+//const TUint16 KCrLf = 0x0a0d;
+//#endif
+
+// Use this lookup table as a quick way of hex formatting a string
+char const * const KHexify = "0123456789ABCDEF";
+
+inline void Hexify4(TUint8* aBuf, TUint32 aVal)
+	{
+	char const * const hexify = KHexify; // Saves compiler re-reading global
+	TUint32 idx;
+	idx = aVal & 0xF;
+	aBuf[3] = hexify[idx];
+	idx = (aVal >> 4) & 0xF;
+	aBuf[2] = hexify[idx];
+	idx = (aVal >> 8) & 0xF;
+	aBuf[1] = hexify[idx];
+	idx = (aVal >> 12) & 0xF;
+	aBuf[0] = hexify[idx];
+	}
+
+void Hexify8(TUint8* aBuf, TUint32 aVal)
+	{
+	// Don't use the global object, it's slightly quicker to access a local variable
+	// If we were going to forceinline this function it would probably be advisable to go back to using the global one
+	char const * const hexify = "0123456789ABCDEF";
+	TUint32 idx;
+	idx = aVal & 0xF;
+	aBuf[7] = hexify[idx];
+	idx = (aVal >> 4) & 0xF;
+	aBuf[6] = hexify[idx];
+	idx = (aVal >> 8) & 0xF;
+	aBuf[5] = hexify[idx];
+	idx = (aVal >> 12) & 0xF;
+	aBuf[4] = hexify[idx];
+	idx = (aVal >> 16) & 0xF;
+	aBuf[3] = hexify[idx];
+	idx = (aVal >> 20) & 0xF;
+	aBuf[2] = hexify[idx];
+	idx = (aVal >> 24) & 0xF;
+	aBuf[1] = hexify[idx];
+	idx = (aVal >> 28) & 0xF;
+	aBuf[0] = hexify[idx];
+	}
+
+FORCEINLINE void DoLog(TRefByValue<const TDesC8> aFmt, VA_LIST aList)
+	{
+	TDes8& tempBuf(gTempBuf);
+	tempBuf.FormatList(aFmt, aList);
+	//__ASSERT_ALWAYS(memBuf.MaxLength()-memBuf.Length() >= tempBuf.Length() + 8 + 3, BlowUp(EBufferFull)); // 8 for timebuf, 3 for the space and newlines
+	// This costs 10 instructions - not much compared to FormatList, but what's the point of checking then panicking anyway?
+		
+	TUint8* ptr = gBufPtr;
+	// Copy timebuf plus a space
+	//gTimeBuf.NumFixedWidthUC(User::FastCounter(), EHex, 8);
+	//memcpy(ptr, gTimeBufPtr, 8);
+	Hexify8(ptr, User::NTickCount());
+	ptr[8] = ' ';
+	ptr += 9; // for the space too
+
+	// And append the formatted string plus a newline
+	TInt formatLen = tempBuf.Length();
+	memcpy(ptr, gTempBufPtr, formatLen);
+	ptr += formatLen;
+	//*((TUint16*)ptr) = KCrLf;
+	// ^ Can't do the above because of alignment issues on ARM
+	ptr[0] = '\r';
+	ptr[1] = '\n';
+	gBufPtr = ptr + 2;
+	*gBufSize += formatLen + 11; // 8 for timeBuf, 3 for space&CRLF
+	}
+
+EXPORT_C void RClogger::Slog(TUint32 /*aLogMask*/, TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	DoLog(aFmt, args);
+	}
+
+EXPORT_C void RClogger::Slog(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	DoLog(aFmt, args);
+	}
+
+EXPORT_C void RClogger::Slog(const char* aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	TPtrC8 ptr((const TUint8*)aFmt);
+	DoLog(ptr, args);
+	}
+
+EXPORT_C void RClogger::Slog(TUint32 /*aLogMask*/, const char* aFmt, ...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+	TPtrC8 ptr((const TUint8*)aFmt);
+	DoLog(ptr, args);
+	}
+
+EXPORT_C void RClogger::SlogList(TRefByValue<const TDesC8> aFmt, VA_LIST aList)
+	{
+	DoLog(aFmt, aList);
+	}
+
+EXPORT_C void RClogger::SlogList(const char* aFmt, VA_LIST aList)
+	{
+	TPtrC8 ptr((const TUint8*)aFmt);
+	DoLog(ptr, aList);
+	}
+
+EXPORT_C void RClogger::SlogList(TUint32 /*aLogMask*/, TRefByValue<const TDesC8> aFmt, VA_LIST aList)
+	{
+	DoLog(aFmt, aList);
+	}
+
+EXPORT_C void RClogger::SlogList(TUint32 /*aLogMask*/, const char* aFmt, VA_LIST aList)
+	{
+	TPtrC8 ptr((const TUint8*)aFmt);
+	DoLog(ptr, aList);
+	}
+
+// Screw the 16-bit versions, if you want performance you should be logging in 8-bit
+EXPORT_C void RClogger::Slog(TRefByValue<const TDesC>, ...) { BlowUp(E16BitFunctionsNotSupported); }
+EXPORT_C void RClogger::Slog(TUint32, TRefByValue<const TDesC>, ...) { BlowUp(E16BitFunctionsNotSupported); }
+EXPORT_C void RClogger::SlogList(TRefByValue<const TDesC>, VA_LIST) { BlowUp(E16BitFunctionsNotSupported); }
+EXPORT_C void RClogger::SlogList(TUint32, TRefByValue<const TDesC>, VA_LIST) { BlowUp(E16BitFunctionsNotSupported); }
+
+// Doesn't need to do anything
+EXPORT_C void RClogger::SetStaticLogBehaviour(TUint /*aLogBehaviour*/)
+	{
+	}
+
+/*
+
+Actually, the compiler's may not be optimal but it uses one less register, so avoids accessing main mem as much!
+
+__NAKED__ void Hexify4(TUint8* aBuf, TUint32 aVal, TUint8 const*const aHexify)
+	{
+	// Compiler refuses to generate optimal assembly, so screw it
+
+	// r0 is aBuf, r1 is aVal, r2 is hexify
+	// r4 is 0xF for convenience of ANDing
+	asm("push {r4}");
+	asm("mov r4, #0xF");
+
+	asm("and r3, r4, r1"); // r3 = aVal & 0xF
+	asm("ldrb r3, [r2, r3]"); // r3 = aHexify[r3]
+	asm("strb r3, [r0, #3]"); // aBuf[3] = r3
+
+	asm("and r3, r4, r1, lsr #4"); // r3 = 0xF & (aVal >> 4)
+	asm("ldrb r3, [r2, r3]"); // r3 = aHexify[r3]
+	asm("strb r3, [r0, #2]"); // aBuf[2] = r3
+	
+	asm("and r3, r4, r1, lsr #8"); // r3 = 0xF & (aVal >> 8)
+	asm("ldrb r3, [r2, r3]"); // r3 = aHexify[r3]
+	asm("strb r3, [r0, #1]"); // aBuf[1] = r3
+
+	asm("and r3, r4, r1, lsr #16"); // r3 = 0xF & (aVal >> 16)
+	asm("ldrb r3, [r2, r3]"); // r3 = aHexify[r3]
+	asm("strb r3, [r0, #0]"); // aBuf[0] = r3
+
+	asm("pop {r4}");
+	asm("bx lr");
+	}
+*/
+		
+FORCEINLINE void DoHexDump(const TDesC8& aHeader, const TDesC8& aData)
+	{
+	//__DEBUGGER();
+	TUint8 * const origBufPtr = gBufPtr;
+
+	const TInt KLineSize = 16;
+	const TInt KExtra = 19; // 8-digit timestamp, space, 4-digit idx, space colon space, space, CRLF
+	TUint32 tickCount = User::NTickCount();
+	TUint8 timestampBuf[8];
+	//TPtr8(timestampBuf, 8, 8).NumFixedWidthUC(tickCount, EHex, 8); // TODO replace with custom hexifier?
+	Hexify8(timestampBuf, tickCount);
+
+	TUint8 const * dataPtr = aData.Ptr();
+	TUint8 const * const dataEnd = dataPtr + aData.Length();
+	TInt headerLen = aHeader.Length();
+	// Rather than messing around with putting spaces in where needed, fill the whole buffer with spaces. It'll probably be more efficient to do one big fill like this
+	memset(origBufPtr, ' ', (headerLen + 4*KLineSize + KExtra)*(aData.Length()+8)/16); // I think this is linelen*numLines
+
+	// Do "Timestamp Header : "
+	memcpy(origBufPtr, timestampBuf, 8);
+	TUint8* bufPtr = origBufPtr + 9;
+	memcpy(bufPtr, aHeader.Ptr(), headerLen);
+	bufPtr += headerLen;
+
+	TInt offset = 0;
+	while (dataPtr < dataEnd)
+		{
+		const TInt fragLen = Min(KLineSize, dataEnd-dataPtr);
+		
+		if (offset)
+			{
+			// Write continuation empty space
+			//bufPtr = memset(bufPtr, ' ', headerLen);
+			memcpy(bufPtr, timestampBuf, 8);
+			bufPtr += 9 + headerLen; // 8-byte timestamp, space
+			}
+
+		// Do "0000 : "
+		//gTempBuf.NumFixedWidthUC(offset++, EHex, 4);
+		//memcpy(bufPtr, gTempBufPtr, 4);
+		Hexify4(bufPtr, offset);
+		offset += 16;
+
+		bufPtr += 4;
+		//bufPtr[0] = ' ';
+		bufPtr[1] = ':';
+		//bufPtr[2] = ' ';
+		bufPtr += 3;
+
+		// Do the hexdump of this line's data
+		TInt i = fragLen;
+		while(i--)
+			{
+			TUint8 c = dataPtr[i];
+			TInt idx = i*3;
+			//TInt idx = fragLen<<1 + fragLen;
+			bufPtr[idx] = KHexify[c>>4];
+			bufPtr[idx+1] = KHexify[c & 0xF];
+			//bufPtr[idx+2] = ' ';
+			}
+		bufPtr += KLineSize*3 + 1; // Plus 1 for the extra space char between the hex rep and the nonhex
+		memcpy(bufPtr, dataPtr, fragLen);
+		bufPtr[fragLen] = '\r';
+		bufPtr[fragLen+1] = '\n';
+
+		// Now escape anything nonprintable with '.'
+		i = fragLen;
+		while (i--)
+			{
+			TUint8 c = bufPtr[i];
+			if (c < 0x20 || c > 0x7E) bufPtr[i] = '.';
+			}
+		bufPtr += fragLen + 2; // For the newline
+		dataPtr += fragLen;
+		}
+	gBufPtr = bufPtr;
+	*gBufSize += gBufPtr - origBufPtr;
+	}
+
+EXPORT_C void RClogger::StaticHexDump(TUint32 /*aLogMask*/, const TDesC8& aHeader, const TDesC8& aData)
+	{
+	//TODO
+	//gClogger.HexDump(aLogMask, aHeader, aData);
+	DoHexDump(aHeader, aData);
+	}
+
+EXPORT_C void RClogger::StaticHexDump(const TDesC8& aHeader, const TDesC8& aData)
+	{
+	//TODO
+	//gClogger.HexDump(EAllEnabled, aHeader, aData);
+	DoHexDump(aHeader, aData);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/SensibleClient.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,494 @@
+// SensibleClient.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "SensibleClient.h"
+#include "SensibleClient_internals.h"
+#include "cliserv.h"
+#include "SensibleCompat.h"
+
+_LIT(KClientPanic, "SensibleClient");
+#define DebugPanic() User::Panic(KClientPanic, - __LINE__)
+#define AssertPanic(x) User::Panic(KClientPanic, x)
+enum TPanic
+	{
+	EReadOffEndOfCallback, // A call to TCallbackParser::Next when there's nothing more in the callback buffer
+	EBadType, // A call to TCallbackParser::NextX where X doesn't match the type of the next thing in the buffer
+	};
+
+#ifdef EKA2
+
+static TInt StartServer()
+//
+// Start the server process. Simultaneous launching
+// of two such processes should be detected when the second one attempts to
+// create the server object, failing with KErrAlreadyExists.
+//
+	{
+	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);
+	RProcess server;
+	TInt r=server.Create(KMyServerImg,KNullDesC,serverUid);
+	if (r!=KErrNone)
+		return r;
+	TRequestStatus stat;
+	server.Rendezvous(stat);
+	if (stat!=KRequestPending)
+		server.Kill(0);		// abort startup
+	else
+		server.Resume();	// logon OK - start the server
+	User::WaitForRequest(stat);		// wait for start or death
+	// we are expected to return a negative error code from this function so if the server died 
+	// with a positive (or zero) code, map it to KErrServerTerminated
+	r = (server.ExitType() != EExitPending && stat.Int() >= 0) ? KErrServerTerminated : stat.Int();
+	server.Close();
+	return r;
+	}
+
+
+
+#else
+
+#include <e32math.h>
+
+inline TServerStart::TServerStart(TRequestStatus& aStatus)
+	:iId(RThread().Id()),iStatus(&aStatus)
+	{aStatus=KRequestPending;}
+inline TPtrC TServerStart::AsCommand() const
+	{return TPtrC(reinterpret_cast<const TText*>(this),sizeof(TServerStart)/sizeof(TText));}
+
+static TInt StartServer()
+//
+// Start the server process/thread which lives in an EPOCEXE object
+//
+	{
+	TRequestStatus started;
+	TServerStart start(started);
+
+	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);
+
+#ifdef __WINS__
+	//
+	// In WINS the server is a DLL, the exported entrypoint returns a TInt
+	// which represents the real entry-point for the server thread
+	//
+	RLibrary lib;
+	TInt r=lib.Load(KMyServerImg,serverUid);
+	if (r!=KErrNone)
+		return r;
+	TLibraryFunction ordinal1=lib.Lookup(1);
+	TThreadFunction serverFunc=reinterpret_cast<TThreadFunction>(ordinal1());
+	//
+	// To deal with the unique thread (+semaphore!) naming in EPOC, and that we may
+	// be trying to restart a server that has just exited we attempt to create a
+	// unique thread name for the server.
+	// This uses Math::Random() to generate a 32-bit random number for the name
+	//
+	TName name(KMyServerName);
+	name.AppendNum(Math::Random(),EHex);
+	RThread server;
+	r=server.Create(name,serverFunc,
+					KMyServerStackSize,
+					&start,&lib,NULL,
+					KMyServerInitHeapSize,KMyServerMaxHeapSize,EOwnerProcess);
+	lib.Close();	// if successful, server thread has handle to library now
+#else
+	//
+	// EPOC is easy, we just create a new server process. Simultaneous launching
+	// of two such processes should be detected when the second one attempts to
+	// create the server object, failing with KErrAlreadyExists.
+	//
+	RProcess server;
+	TInt r=server.Create(KMyServerImg,start.AsCommand(),serverUid);
+#endif
+	if (r!=KErrNone)
+		return r;
+	TRequestStatus died;
+	server.Logon(died);
+	if (died!=KRequestPending)
+		{
+		// logon failed - server is not yet running, so cannot have terminated
+		User::WaitForRequest(died);	// eat signal
+		server.Kill(0);				// abort startup
+		server.Close();
+		return died.Int();
+		}
+	//
+	// logon OK - start the server
+	server.Resume();
+	User::WaitForRequest(started,died);		// wait for start or death
+	if (started==KRequestPending)
+		{
+		// server has died, never made it to the startup signal
+		server.Close();
+		return died.Int();
+		}
+	//
+	// server started (at last). Cancel and consume the death-notification
+	// before reporting success
+	server.LogonCancel(died);
+	server.Close();
+	User::WaitForRequest(died);		// eat the signal (from the cancel)
+	return KErrNone;
+	}
+
+TInt E32Dll(TDllReason)
+	{
+	return 0;
+	}
+
+
+#endif
+
+RSensibleSessionBody::RSensibleSessionBody()
+	: iDispatcher(NULL)
+	{}
+
+TInt RSensibleSessionBody::Connect(TInt aMessageSlots, TBool aStartCallbackDispatcher)
+//
+// Connect to the server, attempting to start it if necessary
+//
+	{
+	TInt r = KErrNone;
+	TInt retry=2;
+	for (;;)
+		{
+		r=DoCreateSession(KMyServerName, TVersion(0,0,0), aMessageSlots);
+		if (r!=KErrNotFound && r!=KErrServerTerminated)
+			break;
+		if (--retry==0)
+			break;
+		r=StartServer();
+		if (r!=KErrNone && r!=KErrAlreadyExists)
+			break;
+		}
+	if (r == KErrNone && aStartCallbackDispatcher)
+		{
+		if (StartCallbackDispatcher() != KErrNone)
+			{
+			Close();
+			return KErrNoMemory;
+			}
+		}
+	return r;
+	}
+
+TInt RSensibleSessionBody::StartCallbackDispatcher()
+	{
+	if (!iDispatcher)
+		{
+		iDispatcher = new CServerCallbackDispatcher(*this);
+		}
+	else if (!iDispatcher->IsActive())
+		{
+		iDispatcher->Register();
+		}
+	return iDispatcher == NULL ? KErrNoMemory : KErrNone;
+	}
+
+void RSensibleSessionBody::StopCallbackDispatcher()
+	{
+	if (iDispatcher) iDispatcher->Cancel();
+	}
+
+void RSensibleSessionBody::DispatchCallbackL(TServerCallback& /*aCallback*/, TCallbackParser& /*aParser*/)
+	{
+	// Implemented by subclass
+	}
+
+void RSensibleSessionBody::ServerDiedL()
+	{
+	// Implemented by subclass
+	}
+
+void RSensibleSessionBody::Close()
+	{
+	delete iDispatcher;
+	iDispatcher = NULL;
+	}
+
+// Not happy this actually works or is worth it
+/*
+void CCleanupAndComplete::RunL()
+	{
+	if (iClientStatus)
+		{
+		// We use this class with a null pointer to allow non-asynchronous (ie blind) APIs to still have the ability to cleanup resource when they are completed
+		User::RequestComplete(iClientStatus, iStatus.Int());
+		}
+	delete this;
+	}
+
+void CCleanupAndComplete::DoCancel()
+	{
+	//TODO what? Probably delete this in some way
+	//delete this;
+	}
+
+CCleanupAndComplete::CCleanupAndComplete(TRequestStatus* aClientStatus)
+	: CActive(EPriorityStandard), iClientStatus(aClientStatus)
+	{
+	CActiveScheduler::Add(this);
+	if (iClientStatus)
+		{
+		*iClientStatus = KRequestPending;
+		}
+	}
+	
+CCleanupAndComplete* CCleanupAndComplete::NewLC(TRequestStatus* aClientStatus)
+	{
+	CCleanupAndComplete* self = new(ELeave) CCleanupAndComplete(aClientStatus);
+	CleanupStack::PushL(self);
+	return self;
+	}
+		
+TInt CCleanupAndComplete::Create(TRequestStatus*& aStatus, const TDesC8& aDes, TInt& aIpcArg)
+	{
+	CCleanupAndComplete* self = new CCleanupAndComplete(aStatus);
+	TInt err = KErrNone;
+	if (!self) err = KErrNoMemory;
+	HBufC8* buf = NULL;
+	if (!err)
+		{
+		buf = aDes.Alloc();
+		}
+	if (!buf) err = KErrNoMemory;
+	if (!err)
+		{
+		err = self->iWithoutDestructor.Append(buf);
+		}
+	if (err) 
+		{
+		delete buf;
+		delete self;
+		return KErrNoMemory;
+		}
+	aIpcArg = (TInt)buf;
+	aStatus = &self->iStatus;
+	self->SetActive();
+	return KErrNone;
+	}
+
+TInt CCleanupAndComplete::Create(TRequestStatus*& aStatus, const TDesC16& aDes, TInt& aIpcArg)
+	{
+	CCleanupAndComplete* self = new CCleanupAndComplete(aStatus);
+	TInt err = KErrNone;
+	if (!self) err = KErrNoMemory;
+	HBufC16* buf = NULL;
+	if (!err)
+		{
+		buf = aDes.Alloc();
+		}
+	if (!buf) err = KErrNoMemory;
+	if (!err)
+		{
+		err = self->iWithoutDestructor.Append(buf);
+		}
+	if (err) 
+		{
+		delete buf;
+		delete self;
+		return KErrNoMemory;
+		}
+	aIpcArg = (TInt)buf;
+	aStatus = &self->iStatus;
+	self->SetActive();
+	return KErrNone;
+	}
+
+void CCleanupAndComplete::AddL(CBase* aWithDestructor)
+	{
+	User::LeaveIfError(iWithDestructor.Append(aWithDestructor));
+	}
+
+void CCleanupAndComplete::AddL(TAny* aWithoutDestructor)
+	{
+	User::LeaveIfError(iWithoutDestructor.Append(aWithoutDestructor));
+	}
+
+CCleanupAndComplete::~CCleanupAndComplete()
+	{
+	Cancel();
+	iWithDestructor.ResetAndDestroy();
+	for (TInt i = 0; i < iWithoutDestructor.Count(); i++)
+		{
+		delete iWithoutDestructor[i];
+		}
+	}
+
+void CCleanupAndComplete::SetActive()
+	{
+	CActive::SetActive();
+	}
+
+*/
+
+CServerCallbackDispatcher::CServerCallbackDispatcher(RSensibleSessionBody& aSession)
+	: CActive(EPriorityStandard), iSession(aSession), iContextPtr(NULL, 0)
+	{
+	CActiveScheduler::Add(this);
+	Register();
+	}
+	
+void CServerCallbackDispatcher::Register()
+	{
+	iState = EWaitingForCallback;
+	IPC(args, &iNextCallback, 0,0,0);
+	iSession.DoSendReceive(ERegisterCallbackNotifier, args, iStatus);
+	SetActive();
+	}
+
+void CServerCallbackDispatcher::RunL()
+	{
+	DISOWN(iCachedCallbackResult8);
+	DISOWN(iCachedCallbackResult16);
+
+	if (iStatus == KErrServerTerminated)
+		{
+		iSession.ServerDiedL();
+		return;
+		}
+	else if (iStatus != KErrNone)
+		{
+		//TODO Do something...
+		__DEBUGGER();
+		return;
+		}
+
+	TServerCallback cb = iNextCallback();
+	TCallbackParser p(cb);
+
+	if (iState == EWaitingForCallback && cb.iContextLength != 0)
+		{
+		iState = EWaitingForContext;
+		DISOWN(iContext);
+		iContext = HBufC8::NewL(cb.iContextLength);
+		iContextPtr = iContext->Des();
+		IPC(args, &iContextPtr, 0,0,0);
+		iSession.DoSendReceive(EGetCallbackContext, args, iStatus);
+		SetActive();
+		return;
+		}
+
+	if (iState == EWaitingForContext)
+		{
+		p.SetContext(*iContext);
+		}
+
+	Register();
+	iSession.DispatchCallbackL(cb, p);
+	}
+
+void CServerCallbackDispatcher::DoCancel()
+	{
+	IPC(args, 0,0,0,0);
+	iSession.DoSendReceive(ECancelCallbackNotifier, args);
+	}
+
+CServerCallbackDispatcher::~CServerCallbackDispatcher()
+	{
+	Cancel();
+	DISOWN(iCachedCallbackResult8);
+	DISOWN(iCachedCallbackResult16);
+	DISOWN(iContext);
+	}
+
+
+TCallbackParser::TCallbackParser(const TServerCallback& aCallback)
+	: iCallback(aCallback), iContext(NULL), iNextPtr(aCallback.iData.Ptr()), iInContext(EFalse)
+	{}
+
+void TCallbackParser::SetContext(TDesC8& aContext)
+	{
+	iContext = &aContext;
+	}
+
+#define DOGET(T, type, name) T name; TAny* res = Next(sizeof(T), #type); Mem::Copy(&name, res, sizeof(T));
+#define GET(T, type) DOGET(T, type, __result); return __result;
+
+TInt TCallbackParser::NextInt()
+	{
+	GET(TInt, i);
+	}
+
+TUint TCallbackParser::NextUint()
+	{
+	GET(TUint, u);
+	}
+
+TPoint TCallbackParser::NextPoint()
+	{
+	GET(TPoint, P);
+	}
+
+TSize TCallbackParser::NextSize()
+	{
+	GET(TSize, S);
+	}
+
+TRgb TCallbackParser::NextRgb()
+	{
+	GET(TRgb, G);
+	}
+
+TRect TCallbackParser::NextRect()
+	{
+	GET(TRect, R);
+	}
+
+TPtrC TCallbackParser::NextDesC()
+	{
+	DOGET(TInt, i, len);
+	const TUint16* ptr = reinterpret_cast<const TUint16*>(Next(len*2, "D"));
+	if (TUint(ptr)&1)
+		{
+		// Need to allow for padding
+		ptr = (TUint16*)(((TUint8*)ptr)+1);
+		iNextPtr++; // And also move iNextPtr to the right place for the next read
+		}
+	return TPtrC(ptr, len);
+	}
+
+TPtrC8 TCallbackParser::NextDesC8()
+	{
+	DOGET(TInt, i, len);
+	const TUint8* ptr = reinterpret_cast<const TUint8*>(Next(len, "8"));
+	return TPtrC8(ptr, len);
+	}
+
+void* TCallbackParser::Next(TInt aSize, char* aType)
+	{
+	const TUint8* endPtr = iInContext ? iContext->Ptr() + iContext->Size() : iCallback.iData.Ptr() + iCallback.iData.Size();
+
+	if (iNextPtr + aSize + 1 > endPtr)
+		{
+		// No room for arg and type
+		if (!iInContext && iContext)
+			{
+			// try moving to context
+			iNextPtr = (TUint8*)iContext->Ptr();
+			iInContext = ETrue;
+			}
+		else
+			{
+			// Either there's no context, or we're already in it and reading off the end
+			AssertPanic(EReadOffEndOfCallback);
+			}
+		}
+
+	TUint8 nextType = *iNextPtr; //iInContext ? iCallback.iContextTypes[iIdx] : iCallback.iDataTypes[iIdx];
+	iNextPtr++;
+	void* result = (void*)iNextPtr;
+	
+	__ASSERT_ALWAYS(nextType == *aType, AssertPanic(EBadType)); // Types must match
+
+	iNextPtr = iNextPtr + aSize;
+	return result;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/SensibleServer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,913 @@
+// SensibleServer.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "SensibleServer.h"
+#include "SensibleServer_server_specific.h"
+
+#define DebugPanic() User::Panic(KDebugPanic, __LINE__)
+#define ClientPanic(aMsg) PanicClient(aMsg, - __LINE__)
+
+inline CShutdown::CShutdown()
+	:CTimer(-1)
+	{CActiveScheduler::Add(this);}
+inline void CShutdown::ConstructL()
+	{CTimer::ConstructL();}
+inline void CShutdown::Start(TInt aDelay)
+	{
+	if (aDelay)
+		{
+		After(aDelay);
+		}
+	}
+
+CSensibleServer::CSensibleServer()
+	:CServerBase(0,ESharableSessions)
+	{}
+
+CSensibleSession::CSensibleSession()
+	: iCallbackQ(_FOFF(CCallbackContext, iLink))
+	{}
+
+inline CSensibleServer& CSensibleSession::Server()
+	{return *static_cast<CSensibleServer*>(const_cast<CServerBase*>(CSessionBase::Server()));}
+
+inline CFilteringScheduler* CSensibleServer::Scheduler()
+	{return iScheduler;}
+
+#ifdef RUN_SERVER_WITH_EIKONENV
+
+#include <eikenv.h>
+#include <eikappui.h>
+
+class CSensibleAppUi : public CEikAppUi
+	{
+public:
+	void ConstructL();
+	~CSensibleAppUi();
+
+private:
+	CSensibleServer* iServer;
+	};
+
+void CSensibleAppUi::ConstructL()
+	{
+	BaseConstructL(ENoAppResourceFile /*|ENoScreenFurniture*/);
+
+	//
+	// create the server
+	iServer = new(ELeave) CServer_Class_Name();
+	iServer->ConstructL();
+	}
+
+CSensibleAppUi::~CSensibleAppUi()
+	{
+	delete iServer;
+	}
+
+// Have to derive from CONE scheduler otherwise ccoeenv complains mightily
+#define SCHEDULER_SUPER CCoeScheduler
+#define SCHEDULER_CONSTRUCTOR CCoeScheduler(CCoeEnv::Static())
+inline void ExitScheduler() { CBaActiveScheduler::Exit(); }
+
+#else
+
+#define SCHEDULER_SUPER CActiveScheduler
+#define SCHEDULER_CONSTRUCTOR CActiveScheduler()
+inline void ExitScheduler() { CActiveScheduler::Stop(); }
+
+#endif
+
+class CFilteringScheduler : public SCHEDULER_SUPER
+	{
+public:
+	CFilteringScheduler();
+	void WaitForAnyRequest();
+	//void OnlyRunThisObject(CActive* aActive); // This doesn't work atm!
+	void RunEverythingExcept(CActive* aActive, CActive* aActive2);
+	void StopFiltering();
+	
+private:
+	struct SObj {
+		CActive* iObject;
+		TInt iCachedStatus;
+		};
+	static const TInt KNumFilteredObjects = 2;
+	SObj iFilteredObjects[KNumFilteredObjects];
+	};
+
+inline TServerStart::TServerStart()
+	{}
+
+void TServerStart::SignalL()
+//
+// Signal the owning thread that the server has started successfully
+// This may itself fail
+//
+	{
+#ifdef EKA2
+	RProcess::Rendezvous(KErrNone);
+#else
+	RThread starter;
+	User::LeaveIfError(starter.Open(iId));
+	starter.RequestComplete(iStatus,KErrNone);
+	starter.Close();
+#endif
+	}
+
+
+///////////////////////
+
+#ifndef __HIDE_IPC_V1__
+void CSensibleSession::CreateL(const CServer& aServer)
+//
+// 2nd phase construct for sessions - called by the CServer framework
+//
+	{
+	CSharableSession::CreateL(aServer);	// does not leave
+	CreateL();
+	}
+#endif
+
+void CSensibleSession::CreateL()
+	{
+	Server().AddSession();
+	}
+
+CSensibleSession::~CSensibleSession()
+	{
+	Server().DropSession();
+	}
+
+static void JustPanic(TAny*)
+	{
+	User::Panic(_L("Crash!"), 0);
+	}
+
+extern void CleanupPanicPushL()
+	{
+	CleanupStack::PushL(TCleanupItem(&JustPanic, 0));
+	}
+
+void CSensibleSession::ServiceL(const RMessage& aMessage)
+//
+// Handle a client request.
+// Leaving is handled by CSensibleServer::RunError() which reports the error code
+// to the client
+//
+	{
+	switch (aMessage.Function())
+		{
+	case ERegisterCallbackNotifier:
+		__ASSERT_ALWAYS(!iCallbackPending, ClientPanic(aMessage)); // Can't call Register is there's something already registered
+		iCallbackNotifier = aMessage;
+		iCallbackPending = ETrue;
+		CompleteNextCallback();
+		break;
+	case EGetCallbackContext:
+		{
+		__ASSERT_ALWAYS(!iCallbackQ.IsEmpty(), ClientPanic(aMessage));
+		CCallbackContext* c = iCallbackQ.First();
+		__ASSERT_ALWAYS(c->Flag(EActive), ClientPanic(aMessage));
+		__ASSERT_ALWAYS(c->CallbackHasContext(), ClientPanic(aMessage));
+		aMessage.WriteL(SLOT(aMessage, 0), *c->Context());
+		aMessage.Complete(KErrNone);
+		if (!c->CallbackRequiresResult())
+			{
+			iCallbackQ.Remove(*c);
+			delete c;
+			}
+		break;
+		}
+	case EWriteCallbackResultAndReregister:
+		{
+		__ASSERT_ALWAYS(!iCallbackPending, ClientPanic(aMessage)); // Can't call Register is there's something already registered
+		__ASSERT_ALWAYS(!iCallbackQ.IsEmpty(), ClientPanic(aMessage));
+		CCallbackContext* c = iCallbackQ.First();
+		__ASSERT_ALWAYS(c->Flag(EActive), ClientPanic(aMessage));
+		__ASSERT_ALWAYS(c->CallbackRequiresResult(), ClientPanic(aMessage));
+		
+		// Get the reregistering out of the way
+		iCallbackNotifier = aMessage;
+		iCallbackPending = ETrue;
+		
+		if (aMessage.Int2() < 0)
+			{
+			// Leave code
+			c->SetFlags(EResultIsLeaveCode);
+			c->Result().integer = aMessage.Int2();
+			}
+		else if (c->Flag(EResultHBufC16))
+			{
+			HBufC16* result = HBufC16::New(aMessage.Int2());
+			if (!result) 
+				{
+				c->SetFlags(EResultIsLeaveCode);
+				c->Result().integer = KErrNoMemory;
+				}
+			else
+				{
+				*c->Result().l = result;
+				TPtr16 ptr(result->Des());
+				aMessage.ReadL(SLOT(aMessage, 1), ptr);
+				}
+			}
+		else if (c->Flag(EResultHBufC8))
+			{
+			HBufC8* result = HBufC8::New(aMessage.Int2());
+			if (!result) 
+				{
+				c->SetFlags(EResultIsLeaveCode);
+				c->Result().integer = KErrNoMemory;
+				}
+			else
+				{
+				*c->Result().s = result;
+				TPtr8 ptr(result->Des());
+				aMessage.ReadL(SLOT(aMessage, 1), ptr);
+				}
+			}
+		else
+			{
+			// It's a TPkg
+			aMessage.ReadL(SLOT(aMessage, 1), *c->Result().pkg);
+			}
+		CActiveScheduler::Stop();
+		break;
+		}
+	case ECancelCallbackNotifier:
+		{
+		if (iCallbackPending)
+			{
+			iCallbackNotifier.Complete(KErrCancel);
+			iCallbackPending = EFalse;
+			}
+		aMessage.Complete(KErrNone);
+		break;
+		}
+	case EDummy:
+		aMessage.Complete(KErrNone);
+		break;
+
+	default:
+		if (!DoServiceL(aMessage))
+			{
+			PanicClient(aMessage, EPanicIllegalFunction);
+			}
+		break;
+		}
+	}
+
+TBool CSensibleSession::DoServiceL(const RMessage& aMessage)
+	{
+	// Subclasses override this!
+	aMessage.Complete(KErrNone);
+	return ETrue;
+	}
+
+void CShutdown::RunL()
+//
+// Initiate server exit when the timer expires
+//
+	{
+	ExitScheduler();
+	}
+
+void CSensibleServer::ConstructL()
+//
+// 2nd phase construction - ensure the timer and server objects are running
+//
+	{
+	StartL(KMyServerName);
+	iShutdown.ConstructL();
+	// ensure that the server still exits even if the 1st client fails to connect
+	iShutdown.Start(TransientServerShutdownTime());
+
+	// Now set up our special scheduler. This is tricky because of good old eikonenv doing stuff differently
+	// Basically without eikonenv, RunServer owns the old scheduler so we can't delete it
+	// However eikonenv will delete the new one as part of its shutdown!
+
+	iScheduler = new(ELeave) CFilteringScheduler();
+	iOldScheduler = CActiveScheduler::Replace(iScheduler);
+	
+#ifdef RUN_SERVER_WITH_EIKONENV
+	DISOWN(iOldScheduler);
+#endif
+	}
+
+CSensibleServer::~CSensibleServer()
+	{
+#ifndef RUN_SERVER_WITH_EIKONENV
+	DISOWN(iScheduler); // To mimic what CCoeEnv does
+#endif
+	}
+
+#ifdef __HIDE_IPC_V1__
+CSessionBase* CSensibleServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage& /*aMessage*/) const
+#else
+CSessionBase* CSensibleServer::NewSessionL(const TVersion& /*aVersion*/) const
+#endif
+//
+// Cretae a new client session. This should really check the version number.
+//
+	{
+	return new(ELeave) CSensibleSession();
+	}
+
+void CSensibleServer::AddSession()
+//
+// A new session is being created
+// Cancel the shutdown timer if it was running
+//
+	{
+	++iSessionCount;
+	iShutdown.Cancel();
+	}
+
+void CSensibleServer::DropSession()
+//
+// A session is being destroyed
+// Start the shutdown timer if it is the last session.
+//
+	{
+	if (--iSessionCount==0 && CActiveScheduler::Current()) // Check we have a scheduler, because if the server is being shut down there won't be one (and there'll be no point starting a shutdown timer
+		iShutdown.Start(TransientServerShutdownTime());
+	}
+
+
+TInt CSensibleServer::RunError(TInt aError)
+//
+// Handle an error from CSensibleSession::ServiceL()
+// A bad descriptor error implies a badly programmed client, so panic it;
+// otherwise report the error to the client
+//
+	{
+	if (aError==KErrBadDescriptor)
+		PanicClient(Message(),EPanicBadDescriptor);
+	else
+		Message().Complete(aError);
+	//
+	// The leave will result in an early return from CServer::RunL(), skipping
+	// the call to request another message. So do that now in order to keep the
+	// server running.
+	ReStart();
+	return KErrNone;	// handled the error fully
+	}
+
+/*void CSensibleServer::BlockAllAOsExceptServerRequests()
+	{
+	Scheduler()->OnlyRunThisObject(this);
+	}*/
+
+void CSensibleServer::BlockRequestsFrom(CActive* aActive1, CActive* aActive2)
+	{
+	Scheduler()->RunEverythingExcept(aActive1, aActive2);
+	}
+
+void CSensibleServer::StopBlocking()
+	{
+	Scheduler()->StopFiltering();
+	}
+
+TInt CSensibleServer::TransientServerShutdownTime() const
+	{
+	return 2000000; // Default to 2 seconds
+	}
+
+void PanicClient(const RMessage& aMessage, TInt aPanic)
+//
+// RMessage::Panic() also completes the message. This is:
+// (a) important for efficient cleanup within the kernel
+// (b) a problem if the message is completed a second time
+//
+	{
+	__DEBUGGER();
+	aMessage.Panic(KDebugPanic, aPanic);
+	}
+
+static void RunServerL(TServerStart& aStart)
+//
+// Perform all server initialisation, in particular creation of the
+// scheduler and server and then run the scheduler
+//
+	{
+
+#ifndef RUN_SERVER_WITH_EIKONENV
+	// create and install the active scheduler we need
+	CActiveScheduler* s=new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(s);
+	CActiveScheduler::Install(s);
+#endif
+
+	//
+	// naming the server thread after the server helps to debug panics
+#ifdef __SECURE_API__
+	User::LeaveIfError(User::RenameThread(KMyServerName));
+#else
+	User::LeaveIfError(RThread().Rename(KMyServerName));
+#endif
+
+#ifdef RUN_SERVER_WITH_EIKONENV
+	// In this case, the server creation/destruction is pushed into CSensibleAppUi
+
+	// Give ourselves a eikonenv
+	CEikonEnv* env = new CEikonEnv;
+	CEikAppUi* appui = NULL;
+	TInt err = KErrNone;
+	if (env != NULL)
+		{
+		TRAP(err,
+			env->ConstructL(EFalse);
+			appui = new (ELeave)CSensibleAppUi();
+			appui->ConstructL();
+			env->SetAppUi(appui);
+			);
+		}
+	if (err == KErrNone)
+		{
+		//
+		// Initialisation complete, now signal the client
+		aStart.SignalL();
+		env->ExecuteD();
+		}
+	else
+		{
+		if (env != NULL)
+			{
+			env->DestroyEnvironment();
+			}
+		User::Leave(err); // This will tell the client that something's gone wrong
+		}
+#else	
+
+	//
+	// create the server
+	CSensibleServer* server = new(ELeave) CServer_Class_Name();
+	CleanupStack::PushL(server);
+	server->ConstructL();
+	//
+	// Initialisation complete, now signal the client
+	aStart.SignalL();
+	//
+	// Ready to run
+	CActiveScheduler::Start();
+
+	CleanupStack::PopAndDestroy(2, s); // server, scheduler
+
+#endif
+	}
+
+static TInt RunServer(TServerStart& aStart)
+//
+// Main entry-point for the server thread
+//
+	{
+	__UHEAP_MARK;
+	//
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+	TInt r=KErrNoMemory;
+	if (cleanup)
+		{
+//#ifdef _DEBUG
+//		TRAP(r, CleanupPanicPushL(); RunServerL(aStart); CleanupStack::Pop());
+//#else
+		TRAP(r,RunServerL(aStart));
+//#endif
+		delete cleanup;
+		}
+	//
+	__UHEAP_MARKEND;
+	return r;
+	}
+
+
+#ifndef EKA2
+
+// The server binary is an "EPOCEXE" target type
+// Thus the server parameter passing and startup code for WINS and EPOC are
+// significantly different.
+
+#ifdef __WINS__
+
+// In WINS, the EPOCEXE target is a DLL with an entry point called WinsMain,
+// taking no parameters and returning TInt. This is not really valid as a thread
+// function which takes a TAny* parameter which we need.
+//
+// So the DLL entry-point WinsMain() is used to return a TInt representing the
+// real thread function within the DLL. This is good as long as
+// sizeof(TInt)>=sizeof(TThreadFunction).
+//
+
+static TInt ThreadFunction(TAny* aParms)
+//
+// WINS thread entry-point function.
+// The TServerStart objects is passed as the thread parameter
+//
+	{
+	return RunServer(*static_cast<TServerStart*>(aParms));
+	}
+
+IMPORT_C TInt WinsMain();
+EXPORT_C TInt WinsMain()
+//
+// WINS DLL entry-point. Just return the real thread function 
+// cast to TInt
+//
+	{
+	return reinterpret_cast<TInt>(&ThreadFunction);
+	}
+
+TInt E32Dll(TDllReason)
+	{
+	return KErrNone;
+	}
+
+#else
+
+//
+// In EPOC, the EPOCEXE target is a process, and the server startup
+// parameters are encoded in the command line
+//
+
+TInt TServerStart::GetCommand()
+	{
+	RProcess p;
+	if (p.CommandLineLength()!=sizeof(TServerStart)/sizeof(TText))
+		return KErrGeneral;
+	TPtr ptr(reinterpret_cast<TText*>(this),0,sizeof(TServerStart)/sizeof(TText));
+	p.CommandLine(ptr);
+	return KErrNone;
+	}
+
+TInt E32Main()
+//
+// Server process entry-point
+// Recover the startup parameters and run the server
+//
+	{
+	TServerStart start;
+	TInt r=start.GetCommand();
+	if (r==KErrNone)
+		r=RunServer(start);
+	return r;
+	}
+
+#endif
+
+#else
+
+TInt E32Main()
+//
+// Server process entry-point
+//
+	{
+	TServerStart start;
+	TInt r = RunServer(start);
+	return r;
+	}
+
+#endif
+
+//// CCallbackContext ////
+
+CCallbackContext::CCallbackContext(TCallbackCode aCode)
+	: iCallback(aCode)
+	{
+	iCallback.iCode = aCode;
+	}
+
+CCallbackContext::~CCallbackContext()
+	{
+	__ASSERT_DEBUG(!Flag(EActive), DebugPanic());
+	delete iContext;
+	}
+
+void CCallbackContext::SetFlags(TInt aFlags)
+	{
+	iFlags |= aFlags;
+	}
+
+TBool CCallbackContext::Flag(TInt aFlags) const
+	{
+	return iFlags & aFlags;
+	}
+
+void CCallbackContext::ClearFlags(TInt aFlags)
+	{
+	iFlags = iFlags & ~aFlags;
+	}
+
+TBool CCallbackContext::CallbackRequiresResult() const
+	{
+	//TODO
+	return EFalse;
+	}
+
+TBool CCallbackContext::CallbackHasContext() const
+	{
+	return (iContext != NULL);
+	}
+
+void CCallbackContext::SetResult(TDes8& aPkg)
+	{
+	iResult.pkg = &aPkg;
+	ClearFlags(EResultHBufC8 | EResultHBufC16);
+	}
+
+void CCallbackContext::SetResult(HBufC8*& aResult)
+	{
+	iResult.s = &aResult;
+	SetFlags(EResultHBufC8);
+	ClearFlags(EResultHBufC16);
+	}
+
+void CCallbackContext::SetResult(HBufC16*& aResult)
+	{
+	iResult.l = &aResult;
+	SetFlags(EResultHBufC16);
+	ClearFlags(EResultHBufC8);
+	}
+
+HBufC8* CCallbackContext::Context()
+	{
+	return iContext;
+	}
+
+CCallbackContext::TResult& CCallbackContext::Result()
+	{
+	return iResult;
+	}
+
+TServerCallback& CCallbackContext::Callback()
+	{
+	return iCallback;
+	}
+
+TCallbackWriter CCallbackContext::Writer()
+	{
+	TCallbackWriter res(iCallback, &iContext);
+	return res;
+	}
+
+//// CFilteringScheduler ////
+
+CFilteringScheduler::CFilteringScheduler()
+: SCHEDULER_CONSTRUCTOR
+	{}
+
+
+/*
+void CFilteringScheduler::OnlyRunThisObject(CActive* aActive)
+	{
+	__ASSERT_ALWAYS(!iObject, DebugPanic());
+	iObject = &aActive->iStatus;
+	iOnlyRunThisObject = ETrue;
+	User::Panic(_L("OnlyRunThisObject doesn't work yet!"), 0);
+	}
+*/
+
+void CFilteringScheduler::RunEverythingExcept(CActive* aActive, CActive* aActive2)
+	{
+	__ASSERT_ALWAYS(!iFilteredObjects[0].iObject, DebugPanic());
+	iFilteredObjects[0].iObject = aActive;
+	iFilteredObjects[1].iObject = aActive2;
+
+	iFilteredObjects[0].iCachedStatus = KRequestPending;
+	iFilteredObjects[1].iCachedStatus = KRequestPending;
+	}
+
+void CFilteringScheduler::StopFiltering()
+	{
+	for (TInt i = 0; i < KNumFilteredObjects; i++)
+		{
+		SObj& obj = iFilteredObjects[i];
+		if (obj.iObject && obj.iCachedStatus != KRequestPending)
+			{
+			TRequestStatus* stat = &obj.iObject->iStatus;
+			User::RequestComplete(stat, obj.iCachedStatus); // Since we consumed the signal from the previous complete, we need to re-signal by calling RequestComplete rather than just updating the object status ourselves
+			}
+		obj.iObject = NULL;
+		}
+	}
+
+void CFilteringScheduler::WaitForAnyRequest()
+	{
+
+	if (!iFilteredObjects[0].iObject)
+		{
+		SCHEDULER_SUPER::WaitForAnyRequest();		
+		return;
+		}
+
+	for (;;)
+		{
+		SCHEDULER_SUPER::WaitForAnyRequest();
+		TBool found = EFalse;
+		for (TInt i = 0; i < KNumFilteredObjects; i++)
+			{
+			SObj& obj = iFilteredObjects[i];
+			TBool isReadyToRun = obj.iObject && obj.iObject->IsActive() && obj.iObject->iStatus != KRequestPending;
+			if (isReadyToRun)
+				{
+				// Our target object has completed, so mark it back as pending, and consume the signal
+				ASSERT(obj.iCachedStatus == KRequestPending); // If this is already set something has gone quite wrong with our logic
+				obj.iCachedStatus = obj.iObject->iStatus.Int();
+				*((TInt*)&obj.iObject->iStatus) = KRequestPending; // Cast this to a TInt* to prevent TRequestStatus::operator= changing the flags
+				found = ETrue;
+				break;
+				}
+			}
+		if (!found) break; // It wasn't one of our objects that completed so no need to go round the loop again
+		}
+	}
+
+//// TCallbackWriter ////
+
+TCallbackWriter::TCallbackWriter(TServerCallback& aCallback, HBufC8** aContext)
+: iCallback(aCallback), iContext(aContext), iBuf((TUint8*)aCallback.iData.Ptr(), aCallback.iData.MaxLength()), iInContext(EFalse)
+	{
+	if (iContext) *iContext = NULL;
+	}
+
+void TCallbackWriter::AddL(const TDesC8& aData, char* aType)
+	{
+	__ASSERT_DEBUG(aData.Length(), DebugPanic());
+	__ASSERT_DEBUG(aType, DebugPanic());
+	TInt bytesRemaining = iBuf.MaxSize() - iBuf.Size();
+
+	TInt typeSize = 1;
+	if (*aType == 'D')
+		{
+		// TDesC16s need to be 2-byte aligned, so make sure the data after the type byte will be
+		if (!(iBuf.Length() & 1)) typeSize = 2;
+		}
+
+	if (aData.Size() + typeSize > bytesRemaining)
+		{
+		// No room for arg and type
+ 		if (!iContext) User::Leave(KErrNoMemory);
+		if (!iInContext)
+			{
+			// so construct context
+			if (*aType == 'D') typeSize = 2;
+			*iContext = HBufC8::NewL(aData.Length() + typeSize);
+			iInContext = ETrue;
+			}
+		else
+			{
+			// realloc
+			HBufC8* newContext = (*iContext)->ReAlloc(Max(iBuf.MaxSize() * 2, iBuf.MaxSize() + aData.Size() + typeSize));
+			if (!newContext)
+				{
+				delete *iContext;
+				*iContext = NULL;
+				User::Leave(KErrNoMemory);
+				}
+			*iContext = newContext;
+			}
+		iBuf.Set((*iContext)->Des());
+		}
+	iBuf.Append(*aType);
+	if (typeSize == 2) iBuf.Append('-'); // Padding
+	iBuf.Append(aData);
+	if (iInContext) 
+		{
+		iCallback.iContextLength = iBuf.Length();
+		}
+	else
+		{
+		iCallback.iData.SetLength(iBuf.Length()); // Because a TPtr pointing to a buf doesn't behave like one pointing to an HBufC, sigh...
+		}
+
+	}
+
+#define ADD(T, arg, type) { TPckg<T> x(arg); AddL(x, #type); }
+
+void TCallbackWriter::AddL(TInt aInt)		{ ADD(TInt, aInt, i); }
+void TCallbackWriter::AddL(TUint aInt)		{ ADD(TUint, aInt, u); }
+void TCallbackWriter::AddL(TPoint aPoint)	{ ADD(TPoint, aPoint, P); }
+void TCallbackWriter::AddL(TSize aSize)		{ ADD(TSize, aSize, S); }
+void TCallbackWriter::AddL(TRgb aRgb)		{ ADD(TRgb, aRgb, G); }
+void TCallbackWriter::AddL(TRect aRect)		{ ADD(TRect, aRect, R); }
+
+void TCallbackWriter::AddL(const TDesC16& aDesc)
+	{
+	ADD(TInt, aDesc.Length(), i);
+	TPtrC8 x((TUint8*)aDesc.Ptr(), aDesc.Size());
+	AddL(x, "D");
+	}
+
+void TCallbackWriter::AddL(const TDesC8& aDesc)
+	{
+	ADD(TInt, aDesc.Length(), i);
+	AddL(aDesc, "8");
+	}
+
+//// CSensibleSession ////
+
+void CSensibleSession::QueueCallbackL(CCallbackContext* aContext)
+	{
+	iCallbackQ.AddLast(*aContext);
+	if (aContext->CallbackRequiresResult())
+		{
+		if (aContext->Flag(EBlockServer))
+			{
+			//Server().Scheduler()->OnlyRunThisObject(&Server()); //TODO fix this at some point!
+			}
+		__ASSERT_ALWAYS(!iWaitingForCallbackResult, DebugPanic()); // This means someone queued a callback that required a result without specifying EBlockServer, and in the meantime someone else has queued another callback requiring a result. This isn't supported! If there is the remotest chance this could happen, then all must specify EBlockServer.
+		iWaitingForCallbackResult = ETrue;
+		CompleteNextCallback();
+		CActiveScheduler::Start();
+		// When we reach here, the client stuff has finished and aContext has our result in
+		// We call CompleteNextCallback again here since to reach this point the server must have received a EWriteCallbackResultAndReregister, which means it's ready for another callback
+		CompleteNextCallback();
+		if (aContext->Flag(EBlockServer))
+			{
+			Server().Scheduler()->StopFiltering();
+			}
+		iWaitingForCallbackResult = EFalse;
+		if (aContext->Flag(EResultIsLeaveCode))
+			{
+			iCallbackQ.Remove(*aContext);
+			TInt err = aContext->Result().integer;
+			delete aContext;
+			User::Leave(err);
+			}
+		// Nothing else needed
+		}
+	else
+		{
+		CompleteNextCallback();
+		}
+	}
+
+TBool CSensibleSession::DispatchCallback(TServerCallback& aCallback)
+	{
+	if (!iCallbackPending)
+		{
+		// Client not ready to be notified
+		return EFalse;
+		}
+
+	TPckg<TServerCallback> pkg(aCallback);
+	TRAPD(err, iCallbackNotifier.WriteL(SLOT(iCallbackNotifier, 0), pkg));
+	if (err)
+		{
+		PanicClient(iCallbackNotifier, EPanicBadDescriptor);
+		iCallbackPending = EFalse;
+		return EFalse;
+		}
+	
+	iCallbackNotifier.Complete(KErrNone);
+	iCallbackPending = EFalse;
+	return ETrue;
+	}
+
+void CSensibleSession::CompleteNextCallback()
+	{
+	if (!iCallbackPending)
+		{
+		// Client not ready to be notified
+		return;
+		}
+	else if (iCallbackQ.IsEmpty())
+		{
+		// Nothing to complete yet
+		return;
+		}
+	
+	CCallbackContext* c = iCallbackQ.First();
+	TPckg<TServerCallback> pkg(c->Callback());
+	#ifdef __HIDE_IPC_V1__
+	TRAPD(err, iCallbackNotifier.WriteL(0, pkg));
+	#else
+	TRAPD(err, iCallbackNotifier.WriteL(iCallbackNotifier.Ptr0(), pkg));
+	#endif
+	if (err)
+		{
+		PanicClient(iCallbackNotifier, EPanicBadDescriptor);
+		iCallbackPending = EFalse;
+		return;
+		}
+	
+	iCallbackNotifier.Complete(KErrNone);
+	iCallbackPending = EFalse;
+	
+	if (!c->CallbackRequiresResult() && !c->CallbackHasContext())
+		{
+		iCallbackQ.Remove(*c);
+		delete c;
+		}
+	else
+		{
+		c->SetFlags(EActive);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/SessionWriter.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,185 @@
+// SessionWriter.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "SessionWriter.h"
+#include "cliserv.h"
+#include "CloggerServer.h"
+
+CSession2* CSessionWriterServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const
+	{
+	return new(ELeave) CSessionWriterSession();
+	}
+
+CSessionWriterServer::CSessionWriterServer(CCloggerServer& aCloggerServer)
+	: CServer2(CActive::EPriorityHigh, ESharableSessions), iCloggerServer(aCloggerServer)
+	{
+	}
+
+void CSessionWriterServer::ConstructL()
+	{
+	StartL(KSessionLogServer);
+	}
+
+CSessionWriterServer& CSessionWriterSession::Server()
+	{
+	return *static_cast<CSessionWriterServer*>(const_cast<CServer2*>(CSession2::Server()));
+	}
+
+void CSessionWriterSession::ServiceL(const RMessage2 &aMessage)
+	{
+	TInt res = KErrNone;
+	TBool handled = ETrue;
+
+	switch (aMessage.Function())
+		{
+		case ERegisterForLogMessages:
+			{
+			if (iSessionWriter)
+				{
+				// We're already registered
+				res = KErrAlreadyExists;
+				break;
+				}
+			CSessionWriter* writer = Server().CloggerServer().RegisterSessionWithSessionWriter(this);
+			if (!writer)
+				{
+				// Only one session can be registered at once, and some other session is
+				res = KErrInUse;
+				break;
+				}
+			iSessionWriter = writer;
+			RChunk& bufChunk = Server().CloggerServer().GetBufChunk();
+			aMessage.Complete(bufChunk);
+			return; // As we've handled it ourself
+			}
+		case EGetNextLog:
+			{
+			if (!iSessionWriterMessage.IsNull())
+				{
+				res = KErrAlreadyExists;
+				break;
+				}
+			if (!iSessionWriter)
+				{
+				PanicClient(aMessage, ENotRegisteredForLogs);
+				return;
+				}
+			iClientSharedChunkBase = (TAny*)aMessage.Ptr1();
+			iSessionWriter->SetEnabled(ETrue);
+			iSessionWriterMessage = aMessage;
+			if (iWaitingForClient)
+				{
+				iWaitingForClient = EFalse;
+				iSessionWriter->Completed();
+				}
+			return; // Don't want to complete this yet!
+			}
+		case ECancelGetNextLog:
+			if (iSessionWriter)
+				{
+				iSessionWriter->SetEnabled(EFalse);
+				}
+			if (!iSessionWriterMessage.IsNull())
+				{
+				iSessionWriterMessage.Complete(KErrCancel);
+				}
+			break;
+		default:
+			handled = EFalse;
+		}
+
+	if (handled)
+		{
+		aMessage.Complete(res);
+		}
+	else
+		{
+		PanicClient(aMessage, EPanicIllegalFunction);
+		}
+	}
+
+void CSessionWriterSession::WriteBuffer(const TDesC8& aBuf)
+	{
+	const TUint8* ptr = aBuf.Ptr();
+	const TUint8* base = Server().CloggerServer().GetBufChunk().Base();
+	const TUint8* clientDataPtr = (const TUint8*)((TInt)iClientSharedChunkBase + (TInt)(ptr - base));
+	TPtrC8 clientPtr(clientDataPtr, aBuf.Length());
+	TPckg<TPtrC8> ptrBuf(clientPtr);
+
+	iWaitingForClient = ETrue;
+	TInt err = iSessionWriterMessage.Write(0, ptrBuf);
+	iSessionWriterMessage.Complete(err);
+	}
+
+TBool CSessionWriterSession::WaitingForClient()
+	{
+	return iWaitingForClient;
+	}
+
+CSessionWriterSession::~CSessionWriterSession()
+	{
+	if (iSessionWriter)
+		{
+		Server().CloggerServer().RegisterSessionWithSessionWriter(NULL);
+		}
+	}
+
+//////////////////////////////
+
+CSessionWriter::CSessionWriter(CCloggerServer& aServer)
+	: iServer(aServer)
+	{
+	}
+
+void CSessionWriter::WriteBuf(TInt aBuf)
+	{
+	ASSERT(!IsBusyWriting() && iEnabled && iSession);
+		{
+		iBuf = aBuf;
+		const TDesC8& buf = iServer.GetBuf(aBuf);
+		iSession->WriteBuffer(buf);
+		}
+	}
+
+TBool CSessionWriter::IsBusyWriting()
+	{
+	return iSession && iSession->WaitingForClient();
+	}
+
+CSessionWriter::~CSessionWriter()
+	{
+	}
+
+void CSessionWriter::CloseWriter()
+	{
+	delete this;
+	}
+
+void CSessionWriter::SetEnabled(TBool aEnabled)
+	{
+	if (!iSession)
+		{
+		// If there's no session, we can't enable ourselves even if someone asks us to
+		aEnabled = EFalse;
+		}
+	iEnabled = aEnabled;
+	if (IsBusyWriting() && !aEnabled)
+		{
+		// Need to say we've completed this buffer
+		iServer.CompletedWritingBuf(this, iBuf);
+		}
+	}
+
+void CSessionWriter::Completed()
+	{
+	iServer.CompletedWritingBuf(this, iBuf);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/src/cflog.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,124 @@
+// cflog.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <cflog.h>
+
+#include <comms-infras/commsdebugutility.h>
+
+#define iFlog reinterpret_cast<RFileLogger*>(iCFLog)
+//class CCFLog
+
+
+CCFLogIf::CCFLogIf()
+	{
+	}
+
+void CCFLogIf::ConstructL()
+	{
+//	iCFLog = reintepret_cast<CCFLog*>(new(ELeave) RFileLogger);
+	}
+
+CCFLogIf::~CCFLogIf()
+	{
+//	iFlog->Close();
+//	delete iFlog;
+	}
+
+EXPORT_C CCFLogIf* CCFLogIf::NewL()
+	{
+/*
+	CCFLogIf* self = new(ELeave) CCFLogIf;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+*/
+	return NULL;
+	}
+
+EXPORT_C TInt CCFLogIf::Delete(CCFLogIf* aCFLogIf)
+	{
+	return 0;
+	}
+	
+EXPORT_C void CCFLogIf::Panic(TCFLogPanic aPanic)
+	{
+	_LIT(tcflogger, "TCFLogger-Clogger");
+	User::Panic(tcflogger, aPanic);	
+	}
+
+EXPORT_C CCFLogIf* CCFLogIf::Context()
+	{
+	return NULL;
+	}
+
+EXPORT_C void CCFLogIf::SetContext()
+	{
+	}
+
+
+EXPORT_C void CCFLogIf::Connect()
+	{
+	}
+
+EXPORT_C void Close()
+	{
+	}
+
+EXPORT_C void CCFLogIf::Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC16& aText)
+	{
+	RFileLogger::Write(aSubsystem, aComponent, aText);
+	}
+
+EXPORT_C void CCFLogIf::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC16> aFmt,...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+
+	WriteFormat(aSubsystem, aComponent, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void CCFLogIf::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC16> aFmt, VA_LIST& aList)
+	{
+	RFileLogger::Write(aSubsystem, aComponent, aFmt, aList);
+	}
+
+EXPORT_C void CCFLogIf::Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText)
+	{
+	RFileLogger::Write(aSubsystem, aComponent, aText);
+	}
+
+EXPORT_C void CCFLogIf::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC8> aFmt,...)
+	{
+	VA_LIST args;
+	VA_START(args, aFmt);
+
+	WriteFormat(aSubsystem, aComponent, aFmt, args);
+	VA_END(args);
+	}
+
+EXPORT_C void CCFLogIf::WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
+	{
+	RFileLogger::Write(aSubsystem, aComponent, aFmt, aList);
+	}
+
+EXPORT_C void CCFLogIf::WriteBinary(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aData)
+	{
+	RFileLogger::WriteBinary(aSubsystem, aComponent, aData);
+	}
+
+EXPORT_C void CCFLogIf::HexDump(const TDesC8& aSubsystem, const TDesC8& aComponent, const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen)
+	{
+	RFileLogger::HexDump(aSubsystem, aComponent, aData);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/tsrc/tclog.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,762 @@
+// tclog.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#define USE_CLOGGER
+#include <fshell/clogger.h>
+#include <e32math.h>
+#include <f32file.h>
+#include <badesca.h>
+#include <flogger.h>
+#include "debugrouter.h"
+
+_LIT(KStaticTag, "tclog::Main");
+_LIT(KTag, "tclog1");
+
+#undef ASSERT
+#define ASSERT(x) __ASSERT_ALWAYS(x, AssertionFail(#x, __FILE__, __LINE__))
+
+__NORETURN__ void AssertionFail(const char* aAssertion, const char* aFile, TInt aLine)
+	{
+	RDebug::Printf("Assertion failed: \"%s\" in %s:%i", aAssertion, aFile, aLine);
+	__DEBUGGER();
+	User::Panic(_L("TCLOG"), aLine);
+	}
+
+// Don't instanciate this directly (you can't because of non-exported virtuals) but use the tclogger macro to cheat
+class RTestClogger : public RClogger
+	{
+public:
+	void FlushLog()
+		{
+		TUint opts = GetGlobalOptions();
+		SetGlobalOptions(0); // Flush log by disabling buffer
+		SetGlobalOptions(opts);
+		}
+
+	void ExpectTagChanged()
+		{
+		iFlags |= 0x10000000; // Magic, see KTestTagEnabled in CloggerClient.cpp
+		}
+
+	void CheckTagChanged()
+		{
+		ASSERT(!(iFlags & 0x10000000));
+		}
+
+	void AlignLogToFourK(TInt aLessThisAmount)
+		{
+		SendReceive(2000, TIpcArgs(aLessThisAmount)); // See EDebugAlignLogFile in cliserv.h
+		}
+
+	void Shutdown()
+		{
+		SendReceive(2001, TIpcArgs());
+		Close();
+		RClogger::StaticClose(); // So that our TLS isn't left set to an invalid reference
+		}
+
+	void ForceBreakpoint()
+		{
+		SendReceive(2003, TIpcArgs());
+		}
+	};
+
+#define tclogger (*reinterpret_cast<RTestClogger*>(&clogger))
+
+enum TTests
+	{
+ 	EBasicTests, // 0
+	ESoakTests, // 1
+	ERdebugRedirect, // 2
+	ESoakAndRDebug, // 3
+	ECreateLogsDir, // 4
+	EDoPerformanceLogging, // 5
+	EDebugRouter, // 6
+	ESessionWriter, // 7
+	ENumTests // Must be last in list
+	};
+
+void DoBasicTestsL();
+void SoakTestsL(TBool aRedirectRDebug);
+void DoRDebugTestsL();
+void DoCreateLogsDirTest();
+void TestPerformanceLoggingL();
+void DebugRouterL();
+void SessionWriterL();
+
+RFs fs;
+RClogger clogger;
+
+void RunTestsL()
+	{
+	TBuf<32> cmd;
+	User::CommandLine(cmd);
+	if (cmd.Length() == 0)
+		{
+		// Syntax: tclog all
+		//         tclog 0 3 5 to run tests 0, 3 and 5
+		User::Invariant();
+		}
+
+	// Figure out what tests to run
+	TUint8 runTests[ENumTests];
+	Mem::FillZ(&runTests, sizeof(runTests));
+	if (cmd == _L("all"))
+		{
+		Mem::Fill(&runTests, sizeof(runTests), 1);
+		}
+	else
+		{
+		TLex lex(cmd);
+		TInt err = KErrNone;
+		while (err == KErrNone)
+			{
+			TInt n;
+			err = lex.Val(n);
+			if (!err && n < ENumTests)
+				{
+				runTests[n] = ETrue;
+				}
+			lex.SkipSpace();
+			}
+		}
+
+	// Now actually run them
+	User::LeaveIfError(clogger.Connect(KTag));
+	User::LeaveIfError(fs.Connect());
+
+	if (runTests[EBasicTests]) DoBasicTestsL();
+	if (runTests[ESoakTests]) SoakTestsL(EFalse);
+	if (runTests[ERdebugRedirect]) DoRDebugTestsL();
+	if (runTests[ESoakAndRDebug]) SoakTestsL(ETrue);
+	if (runTests[ECreateLogsDir]) DoCreateLogsDirTest();
+	if (runTests[EDoPerformanceLogging]) TestPerformanceLoggingL();
+	if (runTests[EDebugRouter]) DebugRouterL();
+	if (runTests[ESessionWriter]) SessionWriterL();
+
+	tclogger.FlushLog();
+	clogger.Close();
+	fs.Close();
+	}
+
+
+
+void DoBasicTestsL()
+	{
+	CActiveScheduler* s = NULL;
+
+	// Try spawning multiple servers to ensure that the failed-to-initialise case is handled ok in the server
+	tclogger.Shutdown();
+	clogger.Close();
+	RProcess proc1, proc2, proc3;
+	proc1.Create(_L("CloggerServer.exe"), KNullDesC);
+	proc2.Create(_L("CloggerServer.exe"), KNullDesC);
+	proc3.Create(_L("CloggerServer.exe"), KNullDesC);
+	proc1.Resume();
+	proc2.Resume();
+	proc3.Resume();
+	User::LeaveIfError(clogger.Connect(KTag));
+
+	clogger.Log(_L("1 This is %s format string"), L"my");
+	// Use static methods to check that the format buffer is deallocated when we do our heapcheck at the end
+	SLOG(_L("2 A 16-bit anonymous log entry - the tag at the start should be [%S]"), &KStaticTag);
+
+	clogger.SetGlobalOptions(RClogger::EBufferLog);
+	ASSERT(clogger.GetGlobalOptions() & RClogger::EBufferLog); // This will fail if the buffer allocation has messed up
+	clogger.Log(_L("3 This should appear when we turn buffering off"));
+	clogger.SetGlobalOptions(0);
+
+	clogger.SetGlobalOptions(RClogger::ERDebugPrint);
+	clogger.Log(_L8("4 This should appear on RDebug::Print"));
+	clogger.SetGlobalOptions(RClogger::EBufferLog|RClogger::ERDebugPrint);
+	clogger.Log(_L8("5 This and all future lines up until the idle timer one should also appear on RDebug::Print"));
+
+	clogger.Log(_L("6 An entry..."));
+	User::After(2000000);
+	clogger.Log(_L("7 ...and another 2 seconds later"));
+
+	clogger.SetEnabled(KStaticTag, 0);
+	_LIT(KEnabled, "Enabled");
+	_LIT(KDisabled, "Disabled");
+	SLOG(_L("This shouldn't appear in the log file because the tag is %S"), clogger.IsEnabled(KStaticTag) ? &KEnabled : &KDisabled);
+
+	clogger.SetEnabled(KStaticTag, RClogger::EAllEnabled);
+	SLOG(_L("8 Tag is now enabled again"));
+
+	TInt heapSize = User::Allocator().Count();
+	RClogger::SetStaticLogBehaviour(RClogger::EUseHeapBuffer);
+	RClogger::Slog(_L("9 This call should cause the heapsize to go up by two cells as the TLS is upgraded and the format buffer is cached"));
+	if (User::Allocator().Count() == heapSize + 2)
+		{
+		SLOG("10 And it did!");
+		}
+	else
+		{
+		SLOG("BUT IT DIDN'T!");
+		}
+	RClogger::StaticClose(); // So the heaptest passes
+
+	clogger.SetEnabled(KStaticTag, 2);
+	SLOG(1, _L("This shouldn't appear because the log mask is only 0x2"));
+	SLOG(3, _L8("11 Logging to multiple masks will work so long as at least one of them is enabled"));
+
+	TInt numBuffers;
+	TInt size = clogger.GetRamBufferSize(&numBuffers);
+
+	clogger.Log("12 %i buffers of size %i", numBuffers, size);
+	clogger.SetRamBufferSize(1024, 3);
+	size = clogger.GetRamBufferSize(&numBuffers);
+	SLOG("13 new settings %i buffers of size %i", numBuffers, size);
+
+	s=new(ELeave) CActiveScheduler;
+	CActiveScheduler::Install(s);
+	clogger.SetLogBehaviour(RClogger::EMonitorTagState);
+	clogger.SetEnabled(KTag, EFalse);
+	tclogger.ExpectTagChanged();
+	//CActiveScheduler::Start();
+	SLOG("14 Disabled tag");
+	clogger.Log("This shouldn't appear as we're disabled - in fact it shouldn't get as far as the server");
+	tclogger.CheckTagChanged();
+	clogger.SetEnabled(KTag, RClogger::EAllEnabled);
+
+	TVolumeInfo volInfo;
+	User::LeaveIfError(fs.Volume(volInfo));
+	if (volInfo.iFree < 67108864) // Don't fill up the drive unless the emulator is using a C drive < 64MB
+		{
+		//														  ..---------- --:--:--.---: [Clogger] Log truncated due to disk full\r\n
+		_LIT(KTrunc, "15 This log line should be truncated here: |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+		const TInt KTimeStampLength = 36;
+		tclogger.AlignLogToFourK(KTrunc().Length() + KTimeStampLength); // This is needed so that the next write forces a disk allocation (and doesn't just fill up an already-allocated cluster)
+		clogger.Log(KTrunc);
+		tclogger.FlushLog();
+
+		TFileName tempName;
+		RFile file;
+		file.Temp(fs, _L("C:\\logs\\"), tempName, EFileShareExclusive|EFileWrite);
+		User::LeaveIfError(fs.Volume(volInfo));
+		TInt err = file.SetSize((TUint)volInfo.iFree);
+		ASSERT(!err);
+
+		clogger.Log("This line shouldn't appear in the log because the disk is full");
+		tclogger.FlushLog();
+		clogger.Log("This line shouldn't either");
+		tclogger.FlushLog();
+
+		file.Close();
+		User::LeaveIfError(fs.Delete(tempName));
+		}
+	else
+		{
+		clogger.Log("15 Unable to run disk full test - run emulator with -ci:\\ -- to enable it");
+		}
+
+	CDesCArray* tags;
+	RBuf8 enabled;
+	clogger.GetTagStatesL(tags, enabled);
+	TInt n = tags->Count();
+	while (n--)
+		{
+		TPtrC tagName = tags->MdcaPoint(n);
+		SLOG(_L("16 Tag %S is enabled with 0x%x"), &tagName, *((TInt*)&enabled[n*4]));
+		}
+	SLOG("17 Inverting all tags enabled attributes (and ORing with 0x1 so we can still log)");
+	n = tags->Count();
+	for (TInt i = 0; i < n; i++)
+		{
+		*((TUint32*)&enabled[i*4]) = 1 | ~ *((TUint32*)&enabled[i*4]);
+		}
+	clogger.SetTagStatesL(tags, enabled);
+	delete tags;
+	clogger.GetTagStatesL(tags, enabled);
+	n = tags->Count();
+	while (n--)
+		{
+		TPtrC tagName = tags->MdcaPoint(n);
+		SLOG(_L("18 Tag %S is enabled with 0x%x"), &tagName, *((TInt*)&enabled[n*4]));
+		}
+
+	enabled.Close();
+	delete tags;
+
+	tclogger.FlushLog();
+	clogger.SetGlobalOptions(RClogger::EBufferLog);
+	clogger.Log("19 This line should appear when the idle timer flushes the buffer");
+	User::After(1000000);
+	clogger.Log(_L("This shouldn't appear in the log file because we're buffering"));
+	clogger.SetGlobalOptions(RClogger::EBufferLog); // Setting the global options to be the same as before shouldn't trigger a buffer flush
+
+	// Test cenrep persistance
+	tclogger.Shutdown();
+	//CActiveScheduler::Start(); //DEBUG testing ServerDied
+	clogger.Connect(KTag);
+	clogger.SetRamBufferSize(3000, 9);
+	clogger.PersistSettings();
+	tclogger.Shutdown();
+	clogger.Connect(KTag);
+	size = clogger.GetRamBufferSize(&numBuffers);
+	ASSERT(numBuffers == 9 && size == 3000); // This test can also fail if the disk is full (and therefore cenrep couldn't save the settings).
+	clogger.ResetSettings();
+
+	const TUint32 KEnabledMask = 0xB2FA1128;
+	clogger.Log(_L("20 testing persistance of tag enabled settings"));
+	clogger.SetEnabled(KTag, KEnabledMask);
+	clogger.PersistSettings();
+	tclogger.Shutdown();
+	clogger.Connect(KTag);
+	ASSERT(clogger.IsEnabled(KTag) == KEnabledMask);
+
+	TInt err;
+
+	RClogger clog1, clog2, clog3;
+	clog1.Connect(KTag);
+	clog1.Log("23 Testing multiple sessions for the same tag");
+	clog2.Connect(KTag);
+	clog3.Connect(KTag);
+	clog2.Log("24 Testing multiple sessions for the same tag");
+	clog3.Log("25 Testing multiple sessions for the same tag");
+	clog3.Close();
+	clog1.Close();
+	clog2.Close();
+
+	_LIT8(KBin, "Newline: \n Null: \0 <EOM>"); // Useful to put a zero byte in there to test that string termination isn't an issue
+	//_LIT(KBigHeader, "27 This header is deliberately more than 256 chars (512 bytes on server side) to check that crazily big headers are handled ok (truncation is fine but crashes aren't!) 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 End\0\0");
+	_LIT8(KBigHeader, "27 This header is deliberately more than 256 chars (512 bytes on server side) to check that crazily big headers are handled ok (truncation is fine but crashes aren't!) 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 End");
+	//RFileLogger::HexDump(KTag, KNullDesC, EFileLoggingModeAppend, _S16("26 Testing hexdump "), NULL, KBin().Ptr(), KBin().Length());
+	clogger.HexDump(_L8("26 Testing hexdump"), KBin);
+	//RFileLogger::HexDump(KTag, KNullDesC, EFileLoggingModeAppend, KBigHeader().Ptr(), NULL, KBin().Ptr(), KBin().Length());
+	clogger.HexDump(KBigHeader, KBin);
+
+	clogger.SetEnabled(_L("Clogger"), RClogger::EAllEnabled);
+	clogger.Log("28 Testing turning on all of clogger's internal logging");
+	RClogger longNameClog;
+	_LIT(KBigTag, "This tag is 256 chars to check that big tag names are handled ok, especially when the internal logging is turned on. 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 End");
+	_LIT(KLongTag, "This tag is more than 256 chars to check that too long tag names are return errors when they should. 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 End");
+	err = longNameClog.Connect(KLongTag);
+	ASSERT(err);
+	longNameClog.Connect(KBigTag);
+	longNameClog.SetEnabled(KBigTag, RClogger::EAllEnabled);
+	longNameClog.Log("29 Testing logging with bigTag");
+	longNameClog.Close();
+
+	clogger.Log("29 There should be an empty line after this log statement\n");
+	clogger.SetLogBehaviour(RClogger::ETrimTrailingNewlines);
+	clogger.Log("30 There should be no empty line after this statement\r\n");
+	clogger.Log("31 Just checking the trim doesn't fall over if there's no newline!");
+
+	delete s;
+	}
+
+void DoRDebugTestsL()
+	{
+	clogger.SetGlobalOptions(RClogger::ERedirectRDebugPrintToClogger);
+	RDebug::Printf("30 This should appear in clogger and on RDebug::Print (without a [tag])"); 
+	clogger.Log("31 this should not appear on RDebug::Print");
+	clogger.SetGlobalOptions(RClogger::ERedirectRDebugPrintToClogger | RClogger::EMirrorToRDebugPrint);
+	RDebug::Printf("32 This should appear on RDebug with [tag] and in the clogger log");
+	clogger.Log("33 So should this");
+	clogger.SetGlobalOptions(0);
+	RDebug::Printf("This should appear in the RDebug::Print log (without [tag]) and not in the clogger log");
+	User::After(1000); // Give the rdebug log flusher time to run
+	}
+
+_LIT(KTag1, "Static     Thread1");
+_LIT(KTag2, "Static     Thread2");
+_LIT(KTag3, "Static     Thread3");
+_LIT(KTag4, "Static     Thread4");
+_LIT(KTag5, "Static     Thread5");
+_LIT(KThreadName1, "Thread1");
+_LIT(KThreadName2, "Thread2");
+_LIT(KThreadName3, "Thread3");
+_LIT(KThreadName4, "Thread4");
+_LIT(KThreadName5, "Thread5");
+TInt GoGoGadgetThread(TAny* aTag);
+
+void SoakTestsL(TBool aRedirectRDebug)
+	{
+	clogger.SetRamBufferSize(512, 2);
+	TUint opt = aRedirectRDebug ? RClogger::ERedirectRDebugPrintToClogger : RClogger::EMirrorToRDebugPrint;
+	clogger.SetGlobalOptions(RClogger::EBufferLog | opt);
+
+	RThread t[5];
+	TRequestStatus stat[5];
+	t[0].Create(KThreadName1, &GoGoGadgetThread, 8192, NULL, (TAny*)&KTag1);
+	t[1].Create(KThreadName2, &GoGoGadgetThread, 8192, NULL, (TAny*)&KTag2);
+	t[2].Create(KThreadName3, &GoGoGadgetThread, 8192, NULL, (TAny*)&KTag3);
+	t[3].Create(KThreadName4, &GoGoGadgetThread, 8192, NULL, (TAny*)&KTag4);
+	t[4].Create(KThreadName5, &GoGoGadgetThread, 8192, NULL, (TAny*)&KTag5);
+	
+	for (TInt i = 0; i < 5; i++)
+		{
+		t[i].Rendezvous(stat[i]);
+		t[i].Resume();
+		}
+
+	TInt bytes = 0;
+	for (TInt i = 0; i < 5; i++)
+		{
+		User::WaitForRequest(stat[i]);
+		bytes += stat[i].Int();
+		t[i].Close();
+		}
+
+	clogger.Log("Wrote %i bytes", bytes);
+	clogger.SetGlobalOptions(0); // Flush log
+	}
+
+
+_LIT8(KLorem, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin ornare, odio quis rhoncus tempor, urna dolor pellentesque arcu, vel feugiat eros odio fringilla magna. Phasellus arcu sapien, malesuada blandit, mollis et, sollicitudin id, felis. Nunc pretium quam a tortor. Sed orci aliquam.");
+
+TInt GoGoGadgetThread(TAny* aTag)
+	{
+	// Each thread should log 10000 bytes in as random a way as possible
+
+	// Use a seed in case we get results we want to replicate
+	TInt64 seed = User::FastCounter();
+
+	const TDesC* tag = (const TDesC*)aTag;
+	RClogger clogger;
+	clogger.Connect(*tag);
+	clogger.Log("Connected with random seed %Li", seed);
+
+	RClogger::SetStaticLogBehaviour(RClogger::EUseHeapBuffer);
+	SLOG(_L("Static logging started from thread %S"), tag);
+
+
+	const TInt KNumBytes = 100000;
+	TInt numBytes = 0;
+
+	TBool rotated = EFalse;
+	while (numBytes < KNumBytes)
+		{
+		TInt rand = Math::Rand(seed);
+		for(TInt i = 0; i < 4; i++)
+			{
+			TInt whatToDo = rand & 0xFF;
+			rand = rand >> 4;
+
+			if (whatToDo < 16)
+				{
+				User::After(whatToDo);
+				}
+			else
+				{
+				TPtrC8 lorem = KLorem().Left(whatToDo-16);
+				numBytes += 46 + lorem.Size(); // 46 is the size of the timestamp and static tag,
+				if (whatToDo & 0x80)
+					{
+					SLOG(lorem);
+					}
+				else
+					{
+					clogger.Log(lorem);
+					}
+				}
+			}
+		if (aTag == &KTag1 && !rotated && numBytes > KNumBytes/2)
+			{
+			// Thread 1 is responsible for doing a rotate about halfway through
+			rotated = ETrue;
+			clogger.SetRotateBehaviour(4, RClogger::ECopyRotatedToExternalMedia | RClogger::ECompressRotatedLogs);
+			TFileName fn;
+			ASSERT(clogger.Rotate(fn) == KErrNone);
+			ASSERT(fn.Length());
+			//ASSERT(clogger.Rotate() == KErrNotReady); // Because the server should still be busy doing the background compress
+			// ^ This assumption is not true now, Rotate is now properly synchronous
+			}
+		}
+	clogger.Close();
+	RClogger::StaticClose();
+	RThread::Rendezvous(numBytes);
+	return KErrNone;
+	}
+
+void DoCreateLogsDirTest()
+	{
+	// Test creating logs folder while server is running
+	tclogger.Shutdown();
+	TInt err = fs.Rename(_L("C:\\logs"), _L("C:\\logs-disabled"));
+	clogger.Connect(KTag);
+	clogger.SetGlobalOptions(RClogger::EBufferLog);
+
+	if (err)
+		{
+		SLOG("Couldn't rename logs dir (err=%i)", err);
+		}
+	else
+		{
+		SLOG(_L("21 Started server without logs dir (this will appear in file log because of buffering)"));
+		err = fs.Rename(_L("C:\\logs-disabled"), _L("C:\\logs"));
+		if (!err)
+			{
+			SLOG(_L("22 Logs folder back in business"));
+			}
+		else
+			{
+			SLOG(_L8("Couldn't rename logs-disabled dir (err=%i)"), err);
+			}
+		}
+	}
+
+void TestPerformanceLoggingL()
+	{
+	// Can't link directly against both clogger.dll and clogger-buffered.dll, so this is a bit messy
+	RLibrary perfLib;
+	User::LeaveIfError(perfLib.Load(_L("clogger-buffered.dll")));
+
+	#ifdef __WINS__
+		#define KConnectOrdinal 42
+		#define KSlogOrdinal 34
+		#define KCloseOrdinal 41
+		#define KStaticHexDumpOrdinal 50
+	#else
+		#define KConnectOrdinal 4
+		#define KSlogOrdinal 20
+		#define KCloseOrdinal 2
+		#define KStaticHexDumpOrdinal 49
+	#endif
+
+	typedef TInt (*StaticConnectFn)(const TDesC&);
+	StaticConnectFn StaticConnect = (StaticConnectFn)perfLib.Lookup(KConnectOrdinal);
+	typedef void (*SlogFn)(TRefByValue<const TDesC8> aFmt, ...);
+	SlogFn Slog = (SlogFn)perfLib.Lookup(KSlogOrdinal);
+	typedef void (*StaticCloseFn)();
+	StaticCloseFn StaticClose = (StaticCloseFn)perfLib.Lookup(KCloseOrdinal);
+	typedef void (*StaticHexDumpFn)(const TDesC8& aHeader, const TDesC8& aData);
+	StaticHexDumpFn StaticHexDump = (StaticHexDumpFn)perfLib.Lookup(KStaticHexDumpOrdinal);
+
+	TInt err = StaticConnect(_L("PerfLog"));
+	ASSERT(!err);
+
+	Slog(_L8("This better be some %s logging"), "high performance");
+	User::After(10);
+	Slog(_L8("So had this"));
+
+	_LIT8(KBin, "Newline: \n Null: xxxxx\0 <EOM>"); // Useful to put a zero byte in there to test that string termination isn't an issue
+	StaticHexDump(_L8("Testing static hexdump function "), KBin);
+
+	clogger.Log("This should appear before the high-perf logging");
+	clogger.HexDump(_L8("Normal "), KBin);
+
+	StaticClose();
+	perfLib.Close();
+	}
+
+void DebugRouterL()
+	{
+	// Test the debug router LDD directly, to ensure its buffering code works properly
+	tclogger.Shutdown(); // Otherwise the cloggerserver is still registered as the debug router's client (And only one client is allowed)
+	RCloggerDebugRouter router;
+	TInt err = RCloggerDebugRouter::LoadDriver();
+	ASSERT(!err || err == KErrAlreadyExists);
+	err = router.Open();
+	ASSERT(!err);
+	RChunk chunk;
+	err = router.OpenChunk(chunk);
+	ASSERT(!err);
+	SDebugChunkHeader* chunkHeader = (SDebugChunkHeader*)chunk.Base();
+#define startPtr chunkHeader->iStartOffset
+#define endPtr chunkHeader->iEndOffset
+#define overflows chunkHeader->iOverflows
+
+	err = router.EnableDebugRouting(RCloggerDebugRouter::EEnableRoutingAndConsume);
+	ASSERT(!err);
+
+	// Test queuing up a bunch of prints before the client has registered
+	const char* lorem = (const char*)KLorem().Ptr();
+	const TInt KLoremLength = Min(256, KLorem().Length()); // RDebugs are truncated at 256 chars
+	RDebug::Printf(lorem);
+	RDebug::Printf(lorem);
+	RDebug::Printf(lorem);
+	RDebug::Printf(lorem);
+	RDebug::Printf(lorem);
+
+	TRequestStatus stat;
+	router.ReceiveData(stat);
+	User::WaitForRequest(stat);
+	ASSERT(stat == KErrNone);
+	ASSERT(startPtr == sizeof(SDebugChunkHeader)); // Offset from start of chunk
+	TInt dataLen = endPtr - startPtr;
+	ASSERT(dataLen == (KLoremLength + sizeof(SCloggerTraceInfo)) * 5);
+	SCloggerTraceInfo* traceHeader = (SCloggerTraceInfo*)(chunk.Base() + startPtr);
+	ASSERT(traceHeader->iTraceType == 'U');
+
+	// Now do another write, which will go to the middle of the buffer as we haven't said we've handled all the KLorems yet
+	_LIT(KMiddle, "Middle of buffer");
+	RDebug::Print(KMiddle);
+
+	router.ReceiveData(stat);
+	User::WaitForRequest(stat);
+	ASSERT(stat == KErrNone);
+	ASSERT(startPtr == sizeof(SDebugChunkHeader) + dataLen);
+	ASSERT(endPtr - startPtr == KMiddle().Length() + sizeof(SCloggerTraceInfo));
+
+	// iCurrent and iClientEnd are pointing at the same place, about 1300 bytes in
+	// iClientStart is at start of buffer
+
+	// Now test wrapping
+	// Need to do 250 writes of KLorem to get to the end of the buffer, 64K/(256+12) ~= 250
+	// The buffer should wrap around, then overflow as we still haven't acknowledged we've completed up to 1300 bytes
+
+	TInt loop = 265; // So we put something at the start too
+	while (loop--)
+		{
+		RDebug::Printf(lorem);
+		}
+
+	TInt prevEnd = endPtr;
+	router.ReceiveData(stat);
+	User::WaitForRequest(stat);
+	ASSERT(stat == KErrNone);
+	ASSERT(startPtr == prevEnd);
+	ASSERT(overflows == 21); // 21 is what you get from doing 265 writes
+	//ASSERT(endPtr == ??); // Can't be bothered right now to figure this out
+
+	// Simulate unclean shutdown (ie don't call EnabledDebugRouting(EFalse))
+
+	router.Close();
+	chunk.Close();
+
+	// Try writing enough to wrap the buffer after we've disconnected (ie while there's no client)
+	loop = 265;
+	while (loop--)
+		{
+		RDebug::Printf(lorem);
+		}
+
+	// And reconnect and see what happens
+	err = router.Open();
+	ASSERT(!err);
+	err = router.OpenChunk(chunk);
+	ASSERT(!err);
+	chunkHeader = (SDebugChunkHeader*)chunk.Base();
+
+	err = router.EnableDebugRouting(RCloggerDebugRouter::EEnableRoutingAndConsume);
+	ASSERT(!err);
+
+	router.ReceiveData(stat);
+	User::WaitForRequest(stat);
+	ASSERT(stat == KErrNone);
+	//ASSERT(startPtr == sizeof(SDebugChunkHeader); // Offset from start of chunk
+	traceHeader = (SCloggerTraceInfo*)(chunk.Base() + startPtr);
+	ASSERT(traceHeader->iTraceType == 'U');
+
+	////END
+
+
+	// Done!
+	err = router.EnableDebugRouting(RCloggerDebugRouter::EDisable);
+	ASSERT(!err);
+	router.Close();
+	chunk.Close();
+	
+	// Now test the CreateChunk API
+	err = router.Open();
+	ASSERT(!err);
+	RThread meThread;
+	err = meThread.Open(RThread().Id());
+	ASSERT(!err);
+	SCreateChunkParams params;
+	params.iCommittedSize = 1024;
+	params.iMaxSize = 1024;
+	params.iHandleOfOtherThread = meThread.Handle();
+	err = router.CreateChunk(params);
+	ASSERT(err == KErrNone);
+	RChunk myChunk, otherChunk;
+	myChunk.SetHandle(params.iChunkHandle);
+	otherChunk.SetHandle(params.iOtherThreadChunkHandle);
+	ASSERT(myChunk.Size() >= 1024);
+	ASSERT(otherChunk.Size() >= 1024);
+	myChunk.Close();
+	ASSERT(otherChunk.Size()); // Testing that the one handle stays valid when the other closes
+	otherChunk.Close();
+	meThread.Close();
+	// Try again with nothing specified for otherChunk
+	params.iHandleOfOtherThread = 0;
+	params.iOtherThreadChunkHandle = 0;
+	err = router.CreateChunk(params);
+	ASSERT(!err);
+	ASSERT(params.iOtherThreadChunkHandle == 0);
+	myChunk.SetHandle(params.iChunkHandle);
+	ASSERT(myChunk.Size() >= 1024);
+
+	// Try the resize API
+	err = router.AdjustChunk(myChunk, 512);
+	ASSERT(!err);
+	// We can't actually shrink a shared chunk, so this test is not valid.
+	//ASSERT(myChunk.Size() == 512);
+	myChunk.Close();
+	router.Close();
+	
+	// Restart clogger
+	clogger.Close();
+	err = clogger.Connect(KTag);
+	ASSERT(!err);
+	}
+
+static void JustPanic(TAny*)
+	{
+	User::Panic(_L("Crash!"), 0);
+	}
+
+static void CleanupPanicPushL()
+	{
+	CleanupStack::PushL(TCleanupItem(&JustPanic));
+	}
+
+
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	//
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+	TInt r=KErrNoMemory;
+	if (cleanup)
+		{
+		TRAP(r, CleanupPanicPushL(); RunTestsL(); CleanupStack::Pop());
+		//ASSERT(!r);
+		delete cleanup;
+		}
+	//
+	__UHEAP_MARKEND;
+	ASSERT(!r);
+	return r;
+	}
+
+void SessionWriterL()
+	{
+	//tclogger.Shutdown();
+	//clogger.Connect(KTag);
+	clogger.SetGlobalOptions(RClogger::ERedirectRDebugPrintToClogger);
+	clogger.SetEnabled(_L("Clogger"), 0); // To shut up the "thread x has started debugging" messages from using the debugrouter
+	
+	RCloggerLogConsumer consumer;
+	TInt err = consumer.Connect();
+	ASSERT(!err);
+
+	TRequestStatus stat;
+	TPtrC8 logLine;
+
+	consumer.GetNextLog(stat, logLine);
+	RDebug::Printf("Shouldn't see this as will cancel session writer!"); // Don't use RClogger::Log directly as this will deadlock. Using the debug router to sidestep this is easier than spawning a separate thread in this test app
+	consumer.CancelGetNextLog();
+	User::WaitForRequest(stat);
+
+	consumer.GetNextLog(stat, logLine);
+	_LIT8(KSee, "Better see this\r\n");
+	RDebug::Printf("Better see this");
+	User::WaitForRequest(stat);
+	ASSERT(stat == KErrNone);
+	ASSERT(logLine.Right(KSee().Length()) == KSee);
+
+	consumer.Close();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/clogger/tsrc/tclog.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// tclog.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET		tclog.exe
+TARGETTYPE	exe
+
+UID		0x0 FSHELL_UID_TCLOG
+
+CAPABILITY FSHELL_CAP_MMP_NORMAL
+
+SOURCEPATH	.
+SOURCE		tclog.cpp
+
+USERINCLUDE	..\inc
+USERINCLUDE	..\debugRouter
+#include <fshell/fsh_system_include.mmh>
+
+LIBRARY		euser.lib clogger.lib efsrv.lib
+LIBRARY 	bafl.lib
+LIBRARY		flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/BMARM/extrabtrace.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,7 @@
+EXPORTS
+	Close__12RExtraBtrace @ 1 NONAME R3UNUSED ; RExtraBtrace::Close(void)
+	Connect__12RExtraBtrace @ 2 NONAME R3UNUSED ; RExtraBtrace::Connect(void)
+	EnableProfiling__12RExtraBtracei @ 3 NONAME R3UNUSED ; RExtraBtrace::EnableProfiling(int)
+	Handle__C12RExtraBtrace @ 4 NONAME R3UNUSED ; RExtraBtrace::Handle(void) const
+	__12RExtraBtrace @ 5 NONAME R3UNUSED ; RExtraBtrace::RExtraBtrace(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/bwins/extrabtrace.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,7 @@
+EXPORTS
+	??0RExtraBtrace@@QAE@XZ @ 1 NONAME ; RExtraBtrace::RExtraBtrace(void)
+	?Handle@RExtraBtrace@@QBEHXZ @ 2 NONAME ; int RExtraBtrace::Handle(void) const
+	?EnableProfiling@RExtraBtrace@@QAEHH@Z @ 3 NONAME ; int RExtraBtrace::EnableProfiling(int)
+	?Connect@RExtraBtrace@@QAEHXZ @ 4 NONAME ; int RExtraBtrace::Connect(void)
+	?Close@RExtraBtrace@@QAEXXZ @ 5 NONAME ; void RExtraBtrace::Close(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/eabi/extrabtrace.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	_ZN12RExtraBtrace15EnableProfilingEi @ 1 NONAME
+	_ZN12RExtraBtrace5CloseEv @ 2 NONAME
+	_ZN12RExtraBtrace7ConnectEv @ 3 NONAME
+	_ZN12RExtraBtraceC1Ev @ 4 NONAME
+	_ZN12RExtraBtraceC2Ev @ 5 NONAME
+	_ZNK12RExtraBtrace6HandleEv @ 6 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+
+FSHELL_ROM_INCLUDE(extrabtrace.iby)
+
+..\inc\extrabtrace.h					\epoc32\include\fshell\extrabtrace.h
+..\inc\extrabtracek.h					\epoc32\include\fshell\extrabtracek.h
+
+PRJ_MMPFILES
+
+extrabtrace.mmp
+extrabtracek.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/group/extrabtrace.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,20 @@
+// extrabtrace.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef EXTRABTRACE_IBY
+#define EXTRABTRACE_IBY
+
+#include <fsh_config.iby>
+
+FSHELL_EXECUTABLE_FILE(extrabtrace.dll)
+FSHELL_KERNEL_EXTENSION(extrabtracek.ldd)
+
+#endif // EXTRABTRACE_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/group/extrabtrace.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// extrabtrace.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+target			extrabtrace.dll
+targettype		dll
+uid				0x1000008d FSHELL_UID_EXTRABTRACE
+
+capability		FSHELL_CAP_MMP_MAX
+nostrictdef
+
+#include <fshell/fsh_system_include.mmh>
+userinclude		..\inc
+
+sourcepath		..\src
+source			extrabtrace.cpp
+
+library 		euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/group/extrabtracek.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,47 @@
+// extrabtracek.mmp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+FSHELL_TRACE_KERNEL_INCLUDE(..\..\..\..\)
+
+target			extrabtracek.ldd
+targettype		ldd
+uid				0x100000af FSHELL_UID_EXTRABTRACEK
+
+userinclude		..\inc
+userinclude		..\src
+
+#include <kernel\kern_ext.mmh>
+
+sourcepath		..\src
+
+#if defined(MARM)
+	#ifdef GCCE
+		// Workaround for the gcce makmake module doing weird things with -S when compiling .cia files
+		// And for GCCE.h's definition of __NAKED__ being wrong
+		source			usampler_cia.cpp
+	#else
+		source			usampler.cia
+	#endif
+#endif
+
+source			extrabtracek.cpp sampler.cpp
+source			eventhandler.cpp
+
+start wins
+win32_headers
+end
+
+library			ekern.lib
+
+capability		all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/inc/common.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+// common.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+_LIT(KLogicalDeviceName, "extrabtrace");
+
+#define EControlEnableProfiling 557
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/inc/extrabtrace.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,91 @@
+// extrabtrace.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef EXTRABTRACE_H
+#define EXTRABTRACE_H
+
+#include <fshell/common.mmh>
+
+#ifdef __KERNEL_MODE__
+#include <e32def.h>
+#else
+#include <e32std.h>
+#endif
+
+namespace ExtraBTrace
+	{
+
+	enum TCategory
+		{
+		/**
+		Supported by memoryaccess-fshell.ldd
+		*/
+		EPubSub = 213,
+
+		/**
+		Filesystem tracing from ffstracer (fshell addition).
+		*/
+		EFfsTrace = 214,
+
+		};
+
+	enum TPubSub
+		{
+		EPubSubIntPropertyChanged = 0,
+		EPubSubDataPropertyChanged = 1,
+		};
+
+	// As used by category EFfsTrace
+	enum TFfsTrace
+		{
+		EFfsDelete = 0,
+		EFfsRename,
+		EFfsReplace,
+		EFfsEntry,
+		EFfsFileSubClose,
+		EFfsFileOpen,
+		EFfsFileCreate,
+		EFfsFileReplace,
+		EFfsFileTemp,
+		EFfsFileRename,
+
+		EFfsPost = 128,
+		};
+	}
+
+#ifndef __KERNEL_MODE__
+
+class RExtraBtrace
+	{
+public:
+	IMPORT_C RExtraBtrace();
+	IMPORT_C TInt Connect();
+	IMPORT_C void Close();
+
+	IMPORT_C TInt EnableProfiling(TInt aSamplingPeriod); // in milliseconds. Pass aRate of zero to disable
+
+public:
+	IMPORT_C TInt Handle() const;
+
+private:
+	TInt32 iImpl[5];
+	};
+
+#endif // __KERNEL_MODE__
+
+// Include the actual btrace header - do this after RExtraBtrace so that in principle someone could subclass it in their custom header
+#ifdef FSHELL_CUSTOM_BTRACE_HEADER
+#include FSHELL_CUSTOM_BTRACE_HEADER
+#else
+#include <e32btrace.h>
+#endif
+
+#endif // EXTRABTRACE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/inc/extrabtracek.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,90 @@
+// extrabtracek.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef EXTRABTRACEK_H
+#define EXTRABTRACEK_H
+
+#include <fshell/extrabtrace.h>
+#include <kernel/kern_priv.h>
+
+// This class avoids exporting functions from extrabtracek.ldd - something that has proved problematic on certain platforms
+class MExtraBtrace
+	{
+public:
+	typedef void (*TCpuUsageCallback)(NThread*, NThread*); // First arg is previous thread, second is current
+	virtual void SetCpuUsageSampling(TCpuUsageCallback aCallbackFn)=0;
+	virtual void SetProfilingSampling(TBool aEnabled)=0;
+
+	virtual TAny* GetVersion(TInt aVersion)=0;
+	virtual void MExtraBtrace_Close()=0;
+	};
+
+
+class DCpuSampler;
+class DExtraBtraceEventHandler;
+
+class DExtraBTraceFactory : public DLogicalDevice, public MExtraBtrace
+	{
+public:
+	virtual TInt Install();
+	virtual void GetCaps(TDes8& aDes) const;
+	virtual TInt Create(DLogicalChannelBase*& aChannel);
+	~DExtraBTraceFactory();
+
+public: // From MExtraBtrace
+	void SetCpuUsageSampling(TCpuUsageCallback aCallbackFn);
+	void SetProfilingSampling(TBool aEnabled);
+	TAny* GetVersion(TInt aVersion);
+	void MExtraBtrace_Close();
+
+public:
+	DCpuSampler* iSampler;
+	DExtraBtraceEventHandler* iEventHandler;
+	};
+
+
+// This function avoids using WSD in extrabtracek.ldd - something that, again, has proved problematic on certain platforms
+// (And it's inline because of aforementioned exports problem)
+
+static MExtraBtrace* OpenExtraBtrace()
+	{
+	__ASSERT_CRITICAL;
+	// Find the extrabtrace DLogicalDevice
+	DLogicalDevice* ldd = NULL;
+	DObjectCon* ldds = Kern::Containers()[ELogicalDevice];
+	_LIT(KLogicalDeviceName, "extrabtrace");
+	TKName resultname;
+#ifdef FSHELL_9_1_SUPPORT
+	TInt findHandle;
+#else
+	TFindHandle findHandle;
+#endif
+	TInt found = ldds->FindByName(findHandle, KLogicalDeviceName, resultname);
+	if (found == KErrNone)
+		{
+		ldds->Wait();
+#ifdef FSHELL_9_1_SUPPORT
+		ldd = static_cast<DLogicalDevice*>(ldds->At(findHandle));
+#else
+		if (findHandle.Index() <= ldds->Count()) ldd = static_cast<DLogicalDevice*>((*ldds)[findHandle.Index()]);
+#endif
+		if (ldd && ldd->Open() != KErrNone) ldd = NULL;
+		ldds->Signal();
+
+		if (ldd)
+			{
+			return static_cast<DExtraBTraceFactory*>(ldd);
+			}
+		}
+	return NULL;
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/src/eventhandler.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,87 @@
+// eventhandler.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "eventhandler.h"
+#include <fshell/extrabtracek.h>
+#include <kern_priv.h>
+#include <fshell/btrace_parser_defs.h>
+
+DExtraBtraceEventHandler::DExtraBtraceEventHandler(DObject* aParent)
+	: DKernelEventHandler(&Event, this), iParent(aParent)
+	{
+	// iParent has been opened on our behalf by the caller (or it is null)
+	}
+
+DExtraBtraceEventHandler::~DExtraBtraceEventHandler()
+	{
+	if (iParent)
+		{
+		NKern::ThreadEnterCS();
+		iParent->AsyncClose();
+		NKern::ThreadLeaveCS();
+		}
+	}
+
+TUint DExtraBtraceEventHandler::Event(TKernelEvent aEvent, TAny* a1, TAny* /*a2*/, TAny* /*aPrivateData*/)
+	{
+	switch (aEvent)
+		{
+		case EEventKillThread:
+			{
+			DObjectCon* threads=Kern::Containers()[EThread];
+			threads->Wait(); // hold mutex so so we can't interleave with priming data
+			DThread* thread = static_cast<DThread*>(a1);
+			switch (thread->iExitType)
+				{
+				case EExitKill:
+					BTrace8(KAmTraceCategory, EAmTraceSubCategoryThreadKilled, thread->iId, thread->iExitReason);
+					break;
+				case EExitTerminate:
+					BTrace8(KAmTraceCategory, EAmTraceSubCategoryThreadTerminated, thread->iId, thread->iExitReason);
+					break;
+				case EExitPanic:
+					{
+					BTraceN(KAmTraceCategory, EAmTraceSubCategoryThreadPanicked, thread->iId, thread->iExitReason, thread->iExitCategory.Ptr(), thread->iExitCategory.Size());
+					break;
+					}
+				default:
+					break;
+				}
+			threads->Signal();
+			break;
+			}
+		case EEventRemoveProcess:
+			{
+			DProcess* process = static_cast<DProcess*>(a1);
+			switch (process->iExitType)
+				{
+				case EExitKill:
+					BTrace8(KAmTraceCategory, EAmTraceSubCategoryProcessKilled, process->iId, process->iExitReason);
+					break;
+				case EExitTerminate:
+					BTrace8(KAmTraceCategory, EAmTraceSubCategoryProcessTerminated, process->iId, process->iExitReason);
+					break;
+				case EExitPanic:
+					{
+					BTraceN(KAmTraceCategory, EAmTraceSubCategoryProcessPanicked, process->iId, process->iExitReason, process->iExitCategory.Ptr(), process->iExitCategory.Size());
+					break;
+					}
+				default:
+					break;
+				}
+			break;
+			}
+		default:
+			break;
+		}
+
+	return ERunNext;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/src/eventhandler.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// eventhandler.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef EXTRABTRACE_EVENTHANDLER_H
+#define EXTRABTRACE_EVENTHANDLER_H
+
+#include <kernel.h>
+
+NONSHARABLE_CLASS(DExtraBtraceEventHandler) : public DKernelEventHandler
+	{
+public:
+	DExtraBtraceEventHandler(DObject* aParent);
+	~DExtraBtraceEventHandler();
+	static TUint Event(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aPrivateData);
+
+private:
+	DObject* iParent;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/src/extrabtrace.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,71 @@
+// extrabtrace.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/extrabtrace.h>
+#include "common.h"
+
+NONSHARABLE_CLASS(RExtraBtraceImpl) : public RBusLogicalChannel
+	{
+public:
+	TInt Connect();
+	TInt EnableProfiling(TInt aSamplingPeriod);
+	};
+
+#define iImplementation (*reinterpret_cast<RExtraBtraceImpl*>(iImpl))
+#define iConstImplementation (*reinterpret_cast<const RExtraBtraceImpl*>(iImpl))
+
+EXPORT_C RExtraBtrace::RExtraBtrace()
+	{
+	iImplementation.SetHandle(0);
+	}
+
+EXPORT_C TInt RExtraBtrace::Connect()
+	{
+	return iImplementation.Connect();
+	}
+
+EXPORT_C void RExtraBtrace::Close()
+	{
+	iImplementation.Close();
+	}
+
+EXPORT_C TInt RExtraBtrace::Handle() const
+	{
+	return iConstImplementation.Handle();
+	}
+
+EXPORT_C TInt RExtraBtrace::EnableProfiling(TInt aSamplingPeriod)
+	{
+	return iImplementation.EnableProfiling(aSamplingPeriod);
+	}
+
+TInt RExtraBtraceImpl::Connect()
+	{
+	_LIT(KLddName,"extrabtracek");
+	TInt r = User::LoadLogicalDevice(KLddName);
+	if(r!=KErrNone && r!=KErrAlreadyExists)
+		return r;
+
+#ifdef FSHELL_CUSTOM_BTRACE_SUPPORT_LIBRARY
+	// If FSHELL_TRACE_LIBRARY etc has been overridden it's possible that we need to load an additional driver to have extrabtrace function
+	r = User::LoadLogicalDevice(TPtrC((const TUint16*)FSHELL_CUSTOM_BTRACE_SUPPORT_LIBRARY));
+	if(r!=KErrNone && r!=KErrAlreadyExists)
+		return r;
+#endif
+
+	r = DoCreate(KLogicalDeviceName, TVersion(), KNullUnit, NULL, NULL, EOwnerThread);
+	return r;
+	}
+
+TInt RExtraBtraceImpl::EnableProfiling(TInt aSamplingPeriod)
+	{
+	return DoControl(EControlEnableProfiling, (TAny*)aSamplingPeriod);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/src/extrabtracek.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,154 @@
+// extrabtracek.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/extrabtracek.h>
+#include <kern_priv.h>
+
+#include "common.h"
+#include "sampler.h"
+#include "eventhandler.h"
+
+class DExtraBTraceChannel : public DLogicalChannelBase
+	{
+public:
+	DExtraBTraceChannel();
+	virtual ~DExtraBTraceChannel();
+	//	Inherited from DObject
+	virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
+	// Inherited from DLogicalChannelBase
+	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
+	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
+private:
+	DCpuSampler* Sampler();
+	};
+
+TInt DExtraBTraceFactory::Install()
+	{
+	TInt err = SetName(&KLogicalDeviceName);
+	if (err) return err;
+	err = Open();
+	if (err) return err;
+
+	iSampler = new DCpuSampler();
+	if (!iSampler) err = KErrNoMemory;
+
+	if (!err) iEventHandler = new DExtraBtraceEventHandler(this);
+	if (!iEventHandler) err = KErrNoMemory;
+
+	if (err)
+		{
+		Close(NULL);
+		}
+	else
+		{
+		iEventHandler->Add();
+		// We must NOT call anything that could fail from this point on - otherwise it is impossible to safely close the DExtraBtraceEventHandler (looks like a bug in constructing a DKernelEventHandler from DLogicalDevice::Install())
+		}
+	return err;
+	}
+
+
+void DExtraBTraceFactory::GetCaps(TDes8& /*aDes*/) const
+	{
+	//Kern::InfoCopy(aDes,0,0);
+	}
+
+TInt DExtraBTraceFactory::Create(DLogicalChannelBase*& aChannel)
+	{
+	aChannel=new DExtraBTraceChannel();
+	if(!aChannel)
+		return KErrNoMemory;
+	return KErrNone;
+	}
+
+DExtraBTraceFactory::~DExtraBTraceFactory()
+	{
+	delete iSampler;
+	delete iEventHandler;
+	}
+
+void DExtraBTraceFactory::SetCpuUsageSampling(MExtraBtrace::TCpuUsageCallback aCallbackFn)
+	{
+	iSampler->SetCpuUsageSampling(aCallbackFn);
+	}
+
+void DExtraBTraceFactory::SetProfilingSampling(TBool aEnabled)
+	{
+	iSampler->SetProfilingSampling(aEnabled);
+	}
+
+TAny* DExtraBTraceFactory::GetVersion(TInt /*aVersion*/)
+	{
+	return NULL; // We don't have any versions yet - this is like CBase::_Extension, just in case
+	}
+
+void DExtraBTraceFactory::MExtraBtrace_Close()
+	{
+	Close(NULL);
+	}
+
+//
+
+DExtraBTraceChannel::DExtraBTraceChannel()
+	{
+	}
+
+DExtraBTraceChannel::~DExtraBTraceChannel()
+	{
+	}
+
+TInt DExtraBTraceChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
+	{
+	return KErrNone;
+	}
+
+DCpuSampler* DExtraBTraceChannel::Sampler()
+	{
+	return static_cast<DExtraBTraceFactory*>(iDevice)->iSampler;
+	}
+
+TInt DExtraBTraceChannel::RequestUserHandle(DThread* /*aThread*/, TOwnerType /*aType*/)
+	{
+	//if (aType!=EOwnerThread || aThread!=iClient)
+	//	return KErrAccessDenied;
+	return KErrNone;
+	}
+
+TInt DExtraBTraceChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/)
+	{
+	switch (aReqNo)
+		{
+	case EControlEnableProfiling:
+		{
+		TInt enable = (a1 == 0) ? 0 : 1; // We still ignore the rate, currently
+		TInt err = BTrace::SetFilter(BTrace::EProfiling, enable);
+		if (err >= 0)
+			{
+			Sampler()->SetProfilingSampling(enable);
+			}
+		return err;
+		}
+	default:
+		return KErrNotSupported;
+		}
+	}
+
+DECLARE_EXTENSION_LDD()
+	{
+	return new DExtraBTraceFactory;
+	}
+
+DECLARE_STANDARD_EXTENSION()
+	{
+	return KErrNone;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/src/sampler.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,144 @@
+// sampler.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "sampler.h"
+#include <fshell/btrace_parser_defs.h>
+#include <fshell/common.mmh>
+
+// Please note this code is NOT SMP-safe. The whole mechanism of using an interrupt doesn't work under SMP so there's no point adding TSpinLocks or similar
+#ifdef __SMP__
+#error "Sampler doesn't work under SMP!"
+#endif
+
+TUint IntStackPtr();
+TUint IDFCRunning();
+
+DCpuSampler::DCpuSampler()
+	: iTimer(NTimer(&Sample, this))
+	{
+#if defined(__MARM__)
+	iIntStackTop=(TUint*)IntStackPtr();
+#endif
+	}
+
+DCpuSampler::~DCpuSampler()
+	{
+	iTimer.Cancel();
+	}
+
+void DCpuSampler::Sample(TAny* aPtr)
+	{
+	static_cast<DCpuSampler*>(aPtr)->DoSample();
+	}
+
+void DCpuSampler::DoSample()
+	{
+	TInt err = iTimer.Again(1);
+	if (err == KErrArgument)
+		{
+		// Missed a tick, oh well
+		iTimer.OneShot(1);
+		}
+
+	NThread* thread = NKern::CurrentThread();
+	if (iCpuUsageCallbackFn)
+		{
+		// Not used by anything in fshell pkg
+		(*iCpuUsageCallbackFn)(iContext, thread);
+		}
+
+	if (iProfiling)
+		{
+		Usample(thread);
+		}
+	iContext = thread;
+	}
+
+TBool DCpuSampler::ShouldRun() const
+	{
+	return iProfiling || iCpuUsageCallbackFn != NULL;
+	}
+
+void DCpuSampler::SettingsChanged()
+	{
+	// Call with interrupts disabled
+	if (ShouldRun())
+		{
+#if FSHELL_PLATFORM_SYMTB >= 92
+		if (!iTimer.IsPending())
+#else
+		if (iTimer.iState == NTimer::EIdle)
+#endif
+			{
+			iContext = NULL;
+			iTimerHeartbeat = 0;
+			iTimer.OneShot(1);
+			}
+		}
+	else
+		{
+		iTimer.Cancel();
+		}
+	}
+
+void DCpuSampler::SetCpuUsageSampling(MExtraBtrace::TCpuUsageCallback aCallbackFn)
+	{
+	TUint irq = NKern::DisableAllInterrupts();
+	iCpuUsageCallbackFn = aCallbackFn;
+	SettingsChanged();
+	NKern::RestoreInterrupts(irq);
+	}
+
+
+void DCpuSampler::SetProfilingSampling(TBool aEnabled)
+	{
+	TUint irq = NKern::DisableAllInterrupts();
+	iProfiling = aEnabled;
+	SettingsChanged();
+	NKern::RestoreInterrupts(irq);
+	}
+
+void DCpuSampler::Usample(NThread* pN)
+	{
+	if (Kern::NThreadToDThread(pN)!=NULL)
+		{
+#if defined(__MARM__)
+		TBool idfcRunning = IDFCRunning();
+		TLinAddr pC=((iIntStackTop)[-1]) & ~1; //clear LSB bit (in case of Jazelle code)
+#else
+		// Can't get this info if we don't have the .cia functions
+		TBool idfcRunning = EFalse;
+		TLinAddr pC = 0;
+#endif
+
+		if (idfcRunning)
+			{
+			//no useful thread context
+			BTrace4(BTrace::EProfiling,BTrace::ECpuIdfcSample,pC);
+			}
+		else
+		    {
+			if (iContext!=pN)
+				{
+				BTrace8(BTrace::EProfiling,BTrace::ECpuFullSample,pC,pN);
+				}
+			else
+				{
+				//optimisation - context of previous sample is assumed
+				BTrace4(BTrace::EProfiling,BTrace::ECpuOptimisedSample,pC);
+				}
+ 		    }
+		}
+	else
+		{
+		BTrace0(BTrace::EProfiling,BTrace::ECpuNonSymbianThreadSample);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/src/sampler.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,43 @@
+// sampler.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef EXTRABTRACE_SAMPLER_H
+#define EXTRABTRACE_SAMPLER_H
+
+#include <fshell/extrabtracek.h>
+#include <kernel.h>
+
+NONSHARABLE_CLASS(DCpuSampler) : public DBase
+	{
+public:
+	DCpuSampler();
+	~DCpuSampler();
+
+	void SetCpuUsageSampling(MExtraBtrace::TCpuUsageCallback aCallbackFn);
+	void SetProfilingSampling(TBool aEnabled);
+
+private:
+	static void Sample(TAny* aPtr);
+	void DoSample();
+	void Usample(NThread* aThread);
+	void SettingsChanged();
+	TBool ShouldRun() const;
+
+private:
+	NThread* iContext;
+	NTimer iTimer;
+	TInt iTimerHeartbeat;
+	TUint* iIntStackTop; // I don't understand this, but whover wrote it originally hopefully did!
+	TBool iProfiling;
+	MExtraBtrace::TCpuUsageCallback iCpuUsageCallbackFn;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/src/usampler.cia	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,75 @@
+// usampler.cia
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include <platform.h>
+
+#include <kern_priv.h>		//temporary
+
+#if defined(__GCC32__)
+// CIA symbol macros for Gcc98r2
+#define CSM__ZN5NKern14CurrentContextEv " CurrentContext__5NKern"
+#elif defined(__ARMCC__)
+// CIA symbol macros for RVCT
+#define CSM__ZN5NKern14CurrentContextEv " __cpp(NKern::CurrentContext)"
+#else
+// CIA symbol macros for EABI assemblers
+#define CSM__ZN5NKern14CurrentContextEv " _ZN5NKern14CurrentContextEv"
+#endif
+
+__NAKED__ TUint IntStackPtr()
+	{
+	asm("mrs r1, cpsr ");
+	asm("bic r3, r1, #0x1f ");
+//#ifdef __MISA__
+//	asm("orr r3, r3, #0xd1 ");		// mode_fiq, all interrupts off
+//#else
+	asm("orr r3, r3, #0xd2 ");		// mode_irq, all interrupts off
+//#endif
+	asm("msr cpsr, r3 ");
+	asm("mov r0, sp ");				// r0=sp_irq or sp_fiq
+	asm("msr cpsr, r1 ");			// restore interrupts
+	__JUMP(,lr);
+	}
+
+__NAKED__ TUint32 SPSR()
+	{
+	asm("mrs r0, spsr ");
+	__JUMP(,lr);
+	}
+
+
+// This will return 1 if it was iDFC interrupted (0 otherwise).
+// As there is no Kernel interface for that, we have to 'fake' Kernel by
+// setting SVC mode before calling NKern::CurrentContext.
+// Without that, CurrentContext would always return EInterrupt.
+__NAKED__ TUint IDFCRunning()
+	{
+	asm("stmfd sp!, {r4-r5} ");	
+
+	asm("mrs r5, cpsr");							// r5 = cpsr_irq
+	asm("bic r4, r5, #0xdf ");						// clear interrupt mask & CPU mode
+	asm("orr r4, r4, #0xd3 ");						// disable all interrupts and set SVC mode
+
+	asm("msr CPSR_cf, r4");   						// switch to SVC, (dissable FIQ, IRQ)
+	
+	// NKern::CurrentContext does not use sp (only r0,r1,r2)
+	// It is just lr in svc mode we need to preserve.
+	asm("mov r4, lr");             					// r4 = lr_svc
+	asm("bl " CSM__ZN5NKern14CurrentContextEv ); 	// r0 = 1 if iDFC was running, 0 if a thread was running
+	asm("mov lr, r4");								// lr_svc is back to original state
+
+	asm("msr CPSR_cf, r5");							// return to IRQ mode
+	
+	asm("ldmfd sp!, {r4-r5} ");
+	__JUMP(,lr);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/extrabtrace/src/usampler_cia.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+// usampler_cia.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <platform.h>
+#include <kern_priv.h>
+
+#ifdef __GCCE__
+// GCCE.h on many platforms has completely wrong definitions
+#undef __NAKED__
+#define __NAKED__ __attribute__((__naked__))
+#endif
+
+#include "usampler.cia"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/bmarm/iocliu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,522 @@
+EXPORTS
+	__eq__CQ27IoUtils16TServerCommandIdRCQ27IoUtils16TServerCommandId @ 1 NONAME R3UNUSED ; IoUtils::TServerCommandId::operator==(IoUtils::TServerCommandId const &) const
+	AppendBoolL__Q27IoUtils18RCommandOptionListRiG5TCharRC7TDesC16T3UiT3 @ 2 NONAME ; IoUtils::RCommandOptionList::AppendBoolL(int &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendBoolL__Q27IoUtils18RCommandOptionListRiRC7TDesC16 @ 3 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendBoolL(int &, TDesC16 const &)
+	AppendBoolL__Q27IoUtils18RCommandOptionListRt6RArray1ZiG5TCharRC7TDesC16T3UiT3 @ 4 NONAME ; IoUtils::RCommandOptionList::AppendBoolL(RArray<int> &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendBoolL__Q27IoUtils18RCommandOptionListRt6RArray1ZiRC7TDesC16 @ 5 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendBoolL(RArray<int> &, TDesC16 const &)
+	AppendComponentL__Q27IoUtils10TFileName2RC6TEntry @ 6 NONAME R3UNUSED ; IoUtils::TFileName2::AppendComponentL(TEntry const &)
+	AppendComponentL__Q27IoUtils10TFileName2RC7TDesC16Q37IoUtils10TFileName25TType @ 7 NONAME R3UNUSED ; IoUtils::TFileName2::AppendComponentL(TDesC16 const &, IoUtils::TFileName2::TType)
+	AppendComponentL__Q27IoUtils10TFileName2RCQ27IoUtils10TFileName2 @ 8 NONAME R3UNUSED ; IoUtils::TFileName2::AppendComponentL(IoUtils::TFileName2 const &)
+	AppendEnumL__Q27IoUtils18RCommandOptionListRiG5TCharRC7TDesC16N23UiT3 @ 9 NONAME ; IoUtils::RCommandOptionList::AppendEnumL(int &, TChar, TDesC16 const &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendEnumL__Q27IoUtils18RCommandOptionListRiG5TCharRC7TDesC16N33UiT3 @ 10 NONAME ; IoUtils::RCommandOptionList::AppendEnumL(int &, TChar, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendEnumL__Q27IoUtils18RCommandOptionListRiRC7TDesC16 @ 11 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendEnumL(int &, TDesC16 const &)
+	AppendEnumL__Q27IoUtils18RCommandOptionListRt6RArray1ZiG5TCharRC7TDesC16N23UiT3 @ 12 NONAME ; IoUtils::RCommandOptionList::AppendEnumL(RArray<int> &, TChar, TDesC16 const &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendEnumL__Q27IoUtils18RCommandOptionListRt6RArray1ZiG5TCharRC7TDesC16N33UiT3 @ 13 NONAME ; IoUtils::RCommandOptionList::AppendEnumL(RArray<int> &, TChar, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendEnumL__Q27IoUtils18RCommandOptionListRt6RArray1ZiRC7TDesC16 @ 14 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendEnumL(RArray<int> &, TDesC16 const &)
+	AppendEnumL__Q27IoUtils20RCommandArgumentListRiRC7TDesC16 @ 15 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendEnumL(int &, TDesC16 const &)
+	AppendEnumL__Q27IoUtils20RCommandArgumentListRiRC7TDesC16N22UiT2 @ 16 NONAME ; IoUtils::RCommandArgumentList::AppendEnumL(int &, TDesC16 const &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendEnumL__Q27IoUtils20RCommandArgumentListRiRC7TDesC16N32UiT2 @ 17 NONAME ; IoUtils::RCommandArgumentList::AppendEnumL(int &, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendEnumL__Q27IoUtils20RCommandArgumentListRt6RArray1ZiRC7TDesC16 @ 18 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendEnumL(RArray<int> &, TDesC16 const &)
+	AppendEnumL__Q27IoUtils20RCommandArgumentListRt6RArray1ZiRC7TDesC16N22UiT2 @ 19 NONAME ; IoUtils::RCommandArgumentList::AppendEnumL(RArray<int> &, TDesC16 const &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendEnumL__Q27IoUtils20RCommandArgumentListRt6RArray1ZiRC7TDesC16N32UiT2 @ 20 NONAME ; IoUtils::RCommandArgumentList::AppendEnumL(RArray<int> &, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendFileNameL__Q27IoUtils18RCommandOptionListRQ27IoUtils10TFileName2G5TCharRC7TDesC16T3UiT3 @ 21 NONAME ; IoUtils::RCommandOptionList::AppendFileNameL(IoUtils::TFileName2 &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendFileNameL__Q27IoUtils18RCommandOptionListRQ27IoUtils10TFileName2RC7TDesC16 @ 22 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendFileNameL(IoUtils::TFileName2 &, TDesC16 const &)
+	AppendFileNameL__Q27IoUtils18RCommandOptionListRt6RArray1ZQ27IoUtils10TFileName2G5TCharRC7TDesC16T3UiT3 @ 23 NONAME ; IoUtils::RCommandOptionList::AppendFileNameL(RArray<IoUtils::TFileName2> &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendFileNameL__Q27IoUtils18RCommandOptionListRt6RArray1ZQ27IoUtils10TFileName2RC7TDesC16 @ 24 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendFileNameL(RArray<IoUtils::TFileName2> &, TDesC16 const &)
+	AppendFileNameL__Q27IoUtils20RCommandArgumentListRQ27IoUtils10TFileName2RC7TDesC16 @ 25 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendFileNameL(IoUtils::TFileName2 &, TDesC16 const &)
+	AppendFileNameL__Q27IoUtils20RCommandArgumentListRQ27IoUtils10TFileName2RC7TDesC16T2UiT2 @ 26 NONAME ; IoUtils::RCommandArgumentList::AppendFileNameL(IoUtils::TFileName2 &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendFileNameL__Q27IoUtils20RCommandArgumentListRt6RArray1ZQ27IoUtils10TFileName2RC7TDesC16 @ 27 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendFileNameL(RArray<IoUtils::TFileName2> &, TDesC16 const &)
+	AppendFileNameL__Q27IoUtils20RCommandArgumentListRt6RArray1ZQ27IoUtils10TFileName2RC7TDesC16T2UiT2 @ 28 NONAME ; IoUtils::RCommandArgumentList::AppendFileNameL(RArray<IoUtils::TFileName2> &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendFormatL__Q27IoUtils11CTextBufferGt11TRefByValue1ZC6TDesC8e @ 29 NONAME ; IoUtils::CTextBuffer::AppendFormatL(TRefByValue<TDesC8 const>,...)
+	AppendFormatL__Q27IoUtils11CTextBufferGt11TRefByValue1ZC7TDesC16e @ 30 NONAME ; IoUtils::CTextBuffer::AppendFormatL(TRefByValue<TDesC16 const>,...)
+	AppendFormatListL__Q27IoUtils11CTextBufferRC6TDesC8RA0_PSc @ 31 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendFormatListL(TDesC8 const &, signed char *(&)[0])
+	AppendFormatListL__Q27IoUtils11CTextBufferRC7TDesC16RA0_PSc @ 32 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendFormatListL(TDesC16 const &, signed char *(&)[0])
+	AppendHumanReadableSizeL__Q27IoUtils11CTextBufferi @ 33 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendHumanReadableSizeL(int)
+	AppendHumanReadableSizeL__Q27IoUtils11CTextBufferiQ27IoUtils10TAlignment @ 34 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendHumanReadableSizeL(int, IoUtils::TAlignment)
+	AppendHumanReadableSizeL__Q27IoUtils11CTextBufferx @ 35 NONAME ; IoUtils::CTextBuffer::AppendHumanReadableSizeL(long long)
+	AppendHumanReadableSizeL__Q27IoUtils11CTextBufferxQ27IoUtils10TAlignment @ 36 NONAME ; IoUtils::CTextBuffer::AppendHumanReadableSizeL(long long, IoUtils::TAlignment)
+	AppendIntL__Q27IoUtils18RCommandOptionListRiG5TCharRC7TDesC16T3UiT3 @ 37 NONAME ; IoUtils::RCommandOptionList::AppendIntL(int &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendIntL__Q27IoUtils18RCommandOptionListRiRC7TDesC16 @ 38 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendIntL(int &, TDesC16 const &)
+	AppendIntL__Q27IoUtils18RCommandOptionListRt6RArray1ZiG5TCharRC7TDesC16T3UiT3 @ 39 NONAME ; IoUtils::RCommandOptionList::AppendIntL(RArray<int> &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendIntL__Q27IoUtils18RCommandOptionListRt6RArray1ZiRC7TDesC16 @ 40 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendIntL(RArray<int> &, TDesC16 const &)
+	AppendIntL__Q27IoUtils18RCommandOptionListRt6RArray1ZxG5TCharRC7TDesC16T3UiT3 @ 41 NONAME ; IoUtils::RCommandOptionList::AppendIntL(RArray<long long> &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendIntL__Q27IoUtils18RCommandOptionListRt6RArray1ZxRC7TDesC16 @ 42 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendIntL(RArray<long long> &, TDesC16 const &)
+	AppendIntL__Q27IoUtils18RCommandOptionListRxG5TCharRC7TDesC16T3UiT3 @ 43 NONAME ; IoUtils::RCommandOptionList::AppendIntL(long long &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendIntL__Q27IoUtils18RCommandOptionListRxRC7TDesC16 @ 44 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendIntL(long long &, TDesC16 const &)
+	AppendIntL__Q27IoUtils20RCommandArgumentListRiRC7TDesC16 @ 45 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendIntL(int &, TDesC16 const &)
+	AppendIntL__Q27IoUtils20RCommandArgumentListRiRC7TDesC16T2UiT2 @ 46 NONAME ; IoUtils::RCommandArgumentList::AppendIntL(int &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendIntL__Q27IoUtils20RCommandArgumentListRt6RArray1ZiRC7TDesC16 @ 47 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendIntL(RArray<int> &, TDesC16 const &)
+	AppendIntL__Q27IoUtils20RCommandArgumentListRt6RArray1ZiRC7TDesC16T2UiT2 @ 48 NONAME ; IoUtils::RCommandArgumentList::AppendIntL(RArray<int> &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendIntL__Q27IoUtils20RCommandArgumentListRt6RArray1ZxRC7TDesC16 @ 49 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendIntL(RArray<long long> &, TDesC16 const &)
+	AppendIntL__Q27IoUtils20RCommandArgumentListRt6RArray1ZxRC7TDesC16T2UiT2 @ 50 NONAME ; IoUtils::RCommandArgumentList::AppendIntL(RArray<long long> &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendIntL__Q27IoUtils20RCommandArgumentListRxRC7TDesC16 @ 51 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendIntL(long long &, TDesC16 const &)
+	AppendIntL__Q27IoUtils20RCommandArgumentListRxRC7TDesC16T2UiT2 @ 52 NONAME ; IoUtils::RCommandArgumentList::AppendIntL(long long &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendL__Q27IoUtils11CTextBufferRC5TChar @ 53 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendL(TChar const &)
+	AppendL__Q27IoUtils11CTextBufferRC6TDesC8 @ 54 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendL(TDesC8 const &)
+	AppendL__Q27IoUtils11CTextBufferRC7TDesC16 @ 55 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendL(TDesC16 const &)
+	AppendL__Q27IoUtils11CTextBufferRCQ27IoUtils11CTextBuffer @ 56 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendL(IoUtils::CTextBuffer const &)
+	AppendL__Q27IoUtils11CTextBufferRCQ27IoUtils11CTextBufferi @ 57 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendL(IoUtils::CTextBuffer const &, int)
+	AppendL__Q27IoUtils11CTextBufferRCQ27IoUtils11CTextBufferii @ 58 NONAME ; IoUtils::CTextBuffer::AppendL(IoUtils::CTextBuffer const &, int, int)
+	AppendPodL__Q27IoUtils14CTextFormatterRC7TDesC16 @ 59 NONAME R3UNUSED ; IoUtils::CTextFormatter::AppendPodL(TDesC16 const &)
+	AppendRealL__Q27IoUtils18RCommandOptionListRdG5TCharRC7TDesC16T3UiT3 @ 60 NONAME ; IoUtils::RCommandOptionList::AppendRealL(double &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendRealL__Q27IoUtils18RCommandOptionListRdRC7TDesC16 @ 61 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendRealL(double &, TDesC16 const &)
+	AppendRealL__Q27IoUtils18RCommandOptionListRt6RArray1ZdG5TCharRC7TDesC16T3UiT3 @ 62 NONAME ; IoUtils::RCommandOptionList::AppendRealL(RArray<double> &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendRealL__Q27IoUtils18RCommandOptionListRt6RArray1ZdRC7TDesC16 @ 63 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendRealL(RArray<double> &, TDesC16 const &)
+	AppendRealL__Q27IoUtils20RCommandArgumentListRdRC7TDesC16 @ 64 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendRealL(double &, TDesC16 const &)
+	AppendRealL__Q27IoUtils20RCommandArgumentListRdRC7TDesC16T2UiT2 @ 65 NONAME ; IoUtils::RCommandArgumentList::AppendRealL(double &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendRealL__Q27IoUtils20RCommandArgumentListRt6RArray1ZdRC7TDesC16 @ 66 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendRealL(RArray<double> &, TDesC16 const &)
+	AppendRealL__Q27IoUtils20RCommandArgumentListRt6RArray1ZdRC7TDesC16T2UiT2 @ 67 NONAME ; IoUtils::RCommandArgumentList::AppendRealL(RArray<double> &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendSpacesL__Q27IoUtils11CTextBufferi @ 68 NONAME R3UNUSED ; IoUtils::CTextBuffer::AppendSpacesL(int)
+	AppendStringL__Q27IoUtils18RCommandOptionListRP7HBufC16G5TCharRC7TDesC16T3UiT3 @ 69 NONAME ; IoUtils::RCommandOptionList::AppendStringL(HBufC16 *&, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendStringL__Q27IoUtils18RCommandOptionListRP7HBufC16RC7TDesC16 @ 70 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendStringL(HBufC16 *&, TDesC16 const &)
+	AppendStringL__Q27IoUtils18RCommandOptionListRt13RPointerArray1Z7HBufC16G5TCharRC7TDesC16T3UiT3 @ 71 NONAME ; IoUtils::RCommandOptionList::AppendStringL(RPointerArray<HBufC16> &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendStringL__Q27IoUtils18RCommandOptionListRt13RPointerArray1Z7HBufC16RC7TDesC16 @ 72 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendStringL(RPointerArray<HBufC16> &, TDesC16 const &)
+	AppendStringL__Q27IoUtils20RCommandArgumentListRP7HBufC16RC7TDesC16 @ 73 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendStringL(HBufC16 *&, TDesC16 const &)
+	AppendStringL__Q27IoUtils20RCommandArgumentListRP7HBufC16RC7TDesC16T2UiT2 @ 74 NONAME ; IoUtils::RCommandArgumentList::AppendStringL(HBufC16 *&, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendStringL__Q27IoUtils20RCommandArgumentListRt13RPointerArray1Z7HBufC16RC7TDesC16 @ 75 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendStringL(RPointerArray<HBufC16> &, TDesC16 const &)
+	AppendStringL__Q27IoUtils20RCommandArgumentListRt13RPointerArray1Z7HBufC16RC7TDesC16T2UiT2 @ 76 NONAME ; IoUtils::RCommandArgumentList::AppendStringL(RPointerArray<HBufC16> &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendUintL__Q27IoUtils18RCommandOptionListRUiG5TCharRC7TDesC16T3UiT3 @ 77 NONAME ; IoUtils::RCommandOptionList::AppendUintL(unsigned int &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendUintL__Q27IoUtils18RCommandOptionListRUiRC7TDesC16 @ 78 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendUintL(unsigned int &, TDesC16 const &)
+	AppendUintL__Q27IoUtils18RCommandOptionListRUxG5TCharRC7TDesC16T3UiT3 @ 79 NONAME ; IoUtils::RCommandOptionList::AppendUintL(unsigned long long &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendUintL__Q27IoUtils18RCommandOptionListRUxRC7TDesC16 @ 80 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendUintL(unsigned long long &, TDesC16 const &)
+	AppendUintL__Q27IoUtils18RCommandOptionListRt6RArray1ZUiG5TCharRC7TDesC16T3UiT3 @ 81 NONAME ; IoUtils::RCommandOptionList::AppendUintL(RArray<unsigned int> &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendUintL__Q27IoUtils18RCommandOptionListRt6RArray1ZUiRC7TDesC16 @ 82 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendUintL(RArray<unsigned int> &, TDesC16 const &)
+	AppendUintL__Q27IoUtils18RCommandOptionListRt6RArray1ZUxG5TCharRC7TDesC16T3UiT3 @ 83 NONAME ; IoUtils::RCommandOptionList::AppendUintL(RArray<unsigned long long> &, TChar, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendUintL__Q27IoUtils18RCommandOptionListRt6RArray1ZUxRC7TDesC16 @ 84 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AppendUintL(RArray<unsigned long long> &, TDesC16 const &)
+	AppendUintL__Q27IoUtils20RCommandArgumentListRUiRC7TDesC16 @ 85 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendUintL(unsigned int &, TDesC16 const &)
+	AppendUintL__Q27IoUtils20RCommandArgumentListRUiRC7TDesC16T2UiT2 @ 86 NONAME ; IoUtils::RCommandArgumentList::AppendUintL(unsigned int &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendUintL__Q27IoUtils20RCommandArgumentListRUxRC7TDesC16 @ 87 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendUintL(unsigned long long &, TDesC16 const &)
+	AppendUintL__Q27IoUtils20RCommandArgumentListRUxRC7TDesC16T2UiT2 @ 88 NONAME ; IoUtils::RCommandArgumentList::AppendUintL(unsigned long long &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendUintL__Q27IoUtils20RCommandArgumentListRt6RArray1ZUiRC7TDesC16 @ 89 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendUintL(RArray<unsigned int> &, TDesC16 const &)
+	AppendUintL__Q27IoUtils20RCommandArgumentListRt6RArray1ZUiRC7TDesC16T2UiT2 @ 90 NONAME ; IoUtils::RCommandArgumentList::AppendUintL(RArray<unsigned int> &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendUintL__Q27IoUtils20RCommandArgumentListRt6RArray1ZUxRC7TDesC16 @ 91 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AppendUintL(RArray<unsigned long long> &, TDesC16 const &)
+	AppendUintL__Q27IoUtils20RCommandArgumentListRt6RArray1ZUxRC7TDesC16T2UiT2 @ 92 NONAME ; IoUtils::RCommandArgumentList::AppendUintL(RArray<unsigned long long> &, TDesC16 const &, TDesC16 const &, unsigned int, TDesC16 const &)
+	AppendValuesL__CQ27IoUtils5TEnumRQ27IoUtils11CTextBuffer @ 93 NONAME R3UNUSED ; IoUtils::TEnum::AppendValuesL(IoUtils::CTextBuffer &) const
+	ArgumentsL__Q27IoUtils11CClientBaseRQ27IoUtils20RCommandArgumentList @ 94 NONAME R3UNUSED ; IoUtils::CClientBase::ArgumentsL(IoUtils::RCommandArgumentList &)
+	ArgumentsL__Q27IoUtils12CCommandBaseRQ27IoUtils20RCommandArgumentList @ 95 NONAME R3UNUSED ; IoUtils::CCommandBase::ArgumentsL(IoUtils::RCommandArgumentList &)
+	ArgumentsL__Q27IoUtils18CBranchCommandBaseRQ27IoUtils20RCommandArgumentList @ 96 NONAME R3UNUSED ; IoUtils::CBranchCommandBase::ArgumentsL(IoUtils::RCommandArgumentList &)
+	Arguments__Q27IoUtils16CCommandInfoFile @ 97 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::Arguments(void)
+	AsString__CQ27IoUtils18RCommandOptionListPv @ 98 NONAME R3UNUSED ; IoUtils::RCommandOptionList::AsString(void *) const
+	AsString__CQ27IoUtils20RCommandArgumentListPv @ 99 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::AsString(void *) const
+	AssignL__CQ27IoUtils16CCommandInfoFileRQ27IoUtils20RCommandArgumentListRQ27IoUtils18RCommandOptionList @ 100 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::AssignL(IoUtils::RCommandArgumentList &, IoUtils::RCommandOptionList &) const
+	AttachL__11RIoEndPointR13RIoReadHandleQ211RIoEndPoint9TReadMode @ 101 NONAME R3UNUSED ; RIoEndPoint::AttachL(RIoReadHandle &, RIoEndPoint::TReadMode)
+	AttachL__11RIoEndPointR14RIoWriteHandle @ 102 NONAME R3UNUSED ; RIoEndPoint::AttachL(RIoWriteHandle &)
+	AttachReaderL__20RIoPersistentConsoleR11RIoEndPointQ220RIoPersistentConsole15TCloseBehaviour @ 103 NONAME R3UNUSED ; RIoPersistentConsole::AttachReaderL(RIoEndPoint &, RIoPersistentConsole::TCloseBehaviour)
+	AttachReader__20RIoPersistentConsoleR11RIoEndPointQ220RIoPersistentConsole15TCloseBehaviour @ 104 NONAME R3UNUSED ; RIoPersistentConsole::AttachReader(RIoEndPoint &, RIoPersistentConsole::TCloseBehaviour)
+	AttachWriterL__20RIoPersistentConsoleR11RIoEndPointQ220RIoPersistentConsole15TCloseBehaviour @ 105 NONAME R3UNUSED ; RIoPersistentConsole::AttachWriterL(RIoEndPoint &, RIoPersistentConsole::TCloseBehaviour)
+	AttachWriter__20RIoPersistentConsoleR11RIoEndPointQ220RIoPersistentConsole15TCloseBehaviour @ 106 NONAME R3UNUSED ; RIoPersistentConsole::AttachWriter(RIoEndPoint &, RIoPersistentConsole::TCloseBehaviour)
+	Attach__11RIoEndPointR13RIoReadHandleQ211RIoEndPoint9TReadMode @ 107 NONAME R3UNUSED ; RIoEndPoint::Attach(RIoReadHandle &, RIoEndPoint::TReadMode)
+	Attach__11RIoEndPointR14RIoWriteHandle @ 108 NONAME R3UNUSED ; RIoEndPoint::Attach(RIoWriteHandle &)
+	AttachedToConsoleL__C18RIoReadWriteHandle @ 109 NONAME R3UNUSED ; RIoReadWriteHandle::AttachedToConsoleL(void) const
+	AttachedToConsole__C18RIoReadWriteHandle @ 110 NONAME R3UNUSED ; RIoReadWriteHandle::AttachedToConsole(void) const
+	BaseConstructL__Q27IoUtils11CServerBase @ 111 NONAME R3UNUSED ; IoUtils::CServerBase::BaseConstructL(void)
+	BaseConstructL__Q27IoUtils12CCommandBase @ 112 NONAME R3UNUSED ; IoUtils::CCommandBase::BaseConstructL(void)
+	CancelCaptureAllKeys__20RIoConsoleReadHandle @ 113 NONAME R3UNUSED ; RIoConsoleReadHandle::CancelCaptureAllKeys(void)
+	CancelCaptureKey__20RIoConsoleReadHandleUiUiUi @ 114 NONAME ; RIoConsoleReadHandle::CancelCaptureKey(unsigned int, unsigned int, unsigned int)
+	CancelNotifyChange__13RIoReadHandle @ 115 NONAME R3UNUSED ; RIoReadHandle::CancelNotifyChange(void)
+	CancelNotifyReaderDetach__20RIoPersistentConsoleR14TRequestStatus @ 116 NONAME R3UNUSED ; RIoPersistentConsole::CancelNotifyReaderDetach(TRequestStatus &)
+	CancelNotifyWriterDetach__20RIoPersistentConsoleR14TRequestStatus @ 117 NONAME R3UNUSED ; RIoPersistentConsole::CancelNotifyWriterDetach(TRequestStatus &)
+	CaptureAllKeysL__20RIoConsoleReadHandle @ 118 NONAME R3UNUSED ; RIoConsoleReadHandle::CaptureAllKeysL(void)
+	CaptureAllKeys__20RIoConsoleReadHandle @ 119 NONAME R3UNUSED ; RIoConsoleReadHandle::CaptureAllKeys(void)
+	CaptureKeyL__20RIoConsoleReadHandleUiUiUi @ 120 NONAME ; RIoConsoleReadHandle::CaptureKeyL(unsigned int, unsigned int, unsigned int)
+	CaptureKey__20RIoConsoleReadHandleUiUiUi @ 121 NONAME ; RIoConsoleReadHandle::CaptureKey(unsigned int, unsigned int, unsigned int)
+	CheckNewConsoleLine__Q27IoUtils11CServerBase @ 122 NONAME R3UNUSED ; IoUtils::CServerBase::CheckNewConsoleLine(void)
+	ClearScreenL__21RIoConsoleWriteHandle @ 123 NONAME R3UNUSED ; RIoConsoleWriteHandle::ClearScreenL(void)
+	ClearScreen__21RIoConsoleWriteHandle @ 124 NONAME R3UNUSED ; RIoConsoleWriteHandle::ClearScreen(void)
+	ClearToEndOfLineL__21RIoConsoleWriteHandle @ 125 NONAME R3UNUSED ; RIoConsoleWriteHandle::ClearToEndOfLineL(void)
+	ClearToEndOfLine__21RIoConsoleWriteHandle @ 126 NONAME R3UNUSED ; RIoConsoleWriteHandle::ClearToEndOfLine(void)
+	Close__9RIoHandle @ 127 NONAME R3UNUSED ; RIoHandle::Close(void)
+	Close__Q27IoUtils13RChildProcess @ 128 NONAME R3UNUSED ; IoUtils::RChildProcess::Close(void)
+	Collapse__Q27IoUtils11CTextBuffer @ 129 NONAME R3UNUSED ; IoUtils::CTextBuffer::Collapse(void)
+	ColumnizeL__Q27IoUtils14CTextFormatteriiRC7TDesC16 @ 130 NONAME ; IoUtils::CTextFormatter::ColumnizeL(int, int, TDesC16 const &)
+	ColumnizeL__Q27IoUtils14CTextFormatteriiRCt6TArray1Z7TPtrC16 @ 131 NONAME ; IoUtils::CTextFormatter::ColumnizeL(int, int, TArray<TPtrC16> const &)
+	CompleteAsync__Q27IoUtils12CCommandBasei @ 132 NONAME R3UNUSED ; IoUtils::CCommandBase::CompleteAsync(int)
+	CompleteAsync__Q27IoUtils12CCommandBaseiGt11TRefByValue1ZC7TDesC16e @ 133 NONAME ; IoUtils::CCommandBase::CompleteAsync(int, TRefByValue<TDesC16 const>,...)
+	Complete__Q27IoUtils12CCommandBase @ 134 NONAME R3UNUSED ; IoUtils::CCommandBase::Complete(void)
+	Complete__Q27IoUtils12CCommandBaseGt11TRefByValue1ZC7TDesC16e @ 135 NONAME ; IoUtils::CCommandBase::Complete(TRefByValue<TDesC16 const>,...)
+	Complete__Q27IoUtils12CCommandBasei @ 136 NONAME R3UNUSED ; IoUtils::CCommandBase::Complete(int)
+	Complete__Q27IoUtils12CCommandBaseiGt11TRefByValue1ZC7TDesC16e @ 137 NONAME ; IoUtils::CCommandBase::Complete(int, TRefByValue<TDesC16 const>,...)
+	CompletionReason__CQ27IoUtils12CCommandBase @ 138 NONAME R3UNUSED ; IoUtils::CCommandBase::CompletionReason(void) const
+	ConfigureSubCommand__Q27IoUtils18CBranchCommandBaseRQ27IoUtils18CServerCommandBase @ 139 NONAME R3UNUSED ; IoUtils::CBranchCommandBase::ConfigureSubCommand(IoUtils::CServerCommandBase &)
+	ConnectL__10RIoSession @ 140 NONAME R3UNUSED ; RIoSession::ConnectL(void)
+	Connect__10RIoSession @ 141 NONAME R3UNUSED ; RIoSession::Connect(void)
+	ConsoleImplementation__Q27IoUtils12CCommandBase @ 142 NONAME R3UNUSED ; IoUtils::CCommandBase::ConsoleImplementation(void)
+	CopyL__Q27IoUtils12CEnvironmentRCQ27IoUtils12CEnvironment @ 143 NONAME R3UNUSED ; IoUtils::CEnvironment::CopyL(IoUtils::CEnvironment const &)
+	Count__CQ27IoUtils12CEnvironment @ 144 NONAME R3UNUSED ; IoUtils::CEnvironment::Count(void) const
+	CreateImplementationLC__CQ27IoUtils25CServerCommandConstructor @ 145 NONAME R3UNUSED ; IoUtils::CServerCommandConstructor::CreateImplementationLC(void) const
+	CreateL__10RIoConsoleR10RIoSessionRC7TDesC16R10RIoConsoleT2RC5TSizeUi @ 146 NONAME ; RIoConsole::CreateL(RIoSession &, TDesC16 const &, RIoConsole &, TDesC16 const &, TSize const &, unsigned int)
+	CreateL__10RIoConsoleR10RIoSessionRC7TDesC16RC5TSizeUi @ 147 NONAME ; RIoConsole::CreateL(RIoSession &, TDesC16 const &, TSize const &, unsigned int)
+	CreateL__10RIoConsoleR10RIoSessionRC7TDesC16T2RC5TSizeUi @ 148 NONAME ; RIoConsole::CreateL(RIoSession &, TDesC16 const &, TDesC16 const &, TSize const &, unsigned int)
+	CreateL__13RIoReadHandleR10RIoSession @ 149 NONAME R3UNUSED ; RIoReadHandle::CreateL(RIoSession &)
+	CreateL__14RIoWriteHandleR10RIoSession @ 150 NONAME R3UNUSED ; RIoWriteHandle::CreateL(RIoSession &)
+	CreateL__20RIoPersistentConsoleR10RIoSessionRC7TDesC16T2 @ 151 NONAME ; RIoPersistentConsole::CreateL(RIoSession &, TDesC16 const &, TDesC16 const &)
+	CreateL__7RIoFileR10RIoSessionRC7TDesC16Q27RIoFile5TMode @ 152 NONAME ; RIoFile::CreateL(RIoSession &, TDesC16 const &, RIoFile::TMode)
+	CreateL__7RIoNullR10RIoSession @ 153 NONAME R3UNUSED ; RIoNull::CreateL(RIoSession &)
+	CreateL__7RIoPipeR10RIoSession @ 154 NONAME R3UNUSED ; RIoPipe::CreateL(RIoSession &)
+	CreateL__Q27IoUtils13RChildProcessRC7TDesC16T1R10RIoSessionR10RIoConsolePCQ27IoUtils12CEnvironment @ 155 NONAME ; IoUtils::RChildProcess::CreateL(TDesC16 const &, TDesC16 const &, RIoSession &, RIoConsole &, IoUtils::CEnvironment const *)
+	CreateL__Q27IoUtils13RChildProcessRC7TDesC16T1R10RIoSessionR13RIoReadHandleR14RIoWriteHandleT5 @ 156 NONAME ; IoUtils::RChildProcess::CreateL(TDesC16 const &, TDesC16 const &, RIoSession &, RIoReadHandle &, RIoWriteHandle &, RIoWriteHandle &)
+	CreateL__Q27IoUtils13RChildProcessRC7TDesC16T1R10RIoSessionR13RIoReadHandleR14RIoWriteHandleT5RCQ27IoUtils12CEnvironment @ 157 NONAME ; IoUtils::RChildProcess::CreateL(TDesC16 const &, TDesC16 const &, RIoSession &, RIoReadHandle &, RIoWriteHandle &, RIoWriteHandle &, IoUtils::CEnvironment const &)
+	Create__10RIoConsoleR10RIoSessionRC7TDesC16R10RIoConsoleT2RC5TSizeUi @ 158 NONAME ; RIoConsole::Create(RIoSession &, TDesC16 const &, RIoConsole &, TDesC16 const &, TSize const &, unsigned int)
+	Create__10RIoConsoleR10RIoSessionRC7TDesC16RC5TSizeUi @ 159 NONAME ; RIoConsole::Create(RIoSession &, TDesC16 const &, TSize const &, unsigned int)
+	Create__10RIoConsoleR10RIoSessionRC7TDesC16T2RC5TSizeUi @ 160 NONAME ; RIoConsole::Create(RIoSession &, TDesC16 const &, TDesC16 const &, TSize const &, unsigned int)
+	Create__13RIoReadHandleR10RIoSession @ 161 NONAME R3UNUSED ; RIoReadHandle::Create(RIoSession &)
+	Create__14RIoWriteHandleR10RIoSession @ 162 NONAME R3UNUSED ; RIoWriteHandle::Create(RIoSession &)
+	Create__20RIoPersistentConsoleR10RIoSessionRC7TDesC16T2 @ 163 NONAME ; RIoPersistentConsole::Create(RIoSession &, TDesC16 const &, TDesC16 const &)
+	Create__7RIoFileR10RIoSessionRC7TDesC16Q27RIoFile5TMode @ 164 NONAME ; RIoFile::Create(RIoSession &, TDesC16 const &, RIoFile::TMode)
+	Create__7RIoNullR10RIoSession @ 165 NONAME R3UNUSED ; RIoNull::Create(RIoSession &)
+	Create__7RIoPipeR10RIoSession @ 166 NONAME R3UNUSED ; RIoPipe::Create(RIoSession &)
+	Delete__Q27IoUtils11CTextBufferii @ 167 NONAME R3UNUSED ; IoUtils::CTextBuffer::Delete(int, int)
+	DescriptionList__CQ27IoUtils5TEnum @ 168 NONAME R3UNUSED ; IoUtils::TEnum::DescriptionList(void) const
+	Description__CQ27IoUtils12CCommandBase @ 169 NONAME R3UNUSED ; IoUtils::CCommandBase::Description(void) const
+	Descriptor__CQ27IoUtils11CTextBuffer @ 170 NONAME R3UNUSED ; IoUtils::CTextBuffer::Descriptor(void) const
+	Descriptor__CQ27IoUtils11CTextBufferii @ 171 NONAME R3UNUSED ; IoUtils::CTextBuffer::Descriptor(int, int) const
+	DetachReader__20RIoPersistentConsole @ 172 NONAME R3UNUSED ; RIoPersistentConsole::DetachReader(void)
+	DetachWriter__20RIoPersistentConsole @ 173 NONAME R3UNUSED ; RIoPersistentConsole::DetachWriter(void)
+	Detach__Q27IoUtils13RChildProcess @ 174 NONAME R3UNUSED ; IoUtils::RChildProcess::Detach(void)
+	DisplayHelp__Q27IoUtils12CCommandBase @ 175 NONAME R3UNUSED ; IoUtils::CCommandBase::DisplayHelp(void)
+	DoCancel__Q27IoUtils12CCommandBase @ 176 NONAME R3UNUSED ; IoUtils::CCommandBase::DoCancel(void)
+	DoRunL__Q27IoUtils11CClientBase @ 177 NONAME R3UNUSED ; IoUtils::CClientBase::DoRunL(void)
+	DoRunL__Q27IoUtils11CServerBase @ 178 NONAME R3UNUSED ; IoUtils::CServerBase::DoRunL(void)
+	DoRunL__Q27IoUtils18CBranchCommandBase @ 179 NONAME R3UNUSED ; IoUtils::CBranchCommandBase::DoRunL(void)
+	DriveAndPath__CQ27IoUtils10TFileName2 @ 180 NONAME R3UNUSED ; IoUtils::TFileName2::DriveAndPath(void) const
+	Drive__CQ27IoUtils10TFileName2 @ 181 NONAME R3UNUSED ; IoUtils::TFileName2::Drive(void) const
+	DuplicateL__13RIoReadHandleR13RIoReadHandle @ 182 NONAME R3UNUSED ; RIoReadHandle::DuplicateL(RIoReadHandle &)
+	DuplicateL__14RIoWriteHandleR14RIoWriteHandle @ 183 NONAME R3UNUSED ; RIoWriteHandle::DuplicateL(RIoWriteHandle &)
+	Duplicate__13RIoReadHandleR13RIoReadHandle @ 184 NONAME R3UNUSED ; RIoReadHandle::Duplicate(RIoReadHandle &)
+	Duplicate__14RIoWriteHandleR14RIoWriteHandle @ 185 NONAME R3UNUSED ; RIoWriteHandle::Duplicate(RIoWriteHandle &)
+	Env__CQ27IoUtils12CCommandBase @ 186 NONAME R3UNUSED ; IoUtils::CCommandBase::Env(void) const
+	Env__Q27IoUtils12CCommandBase @ 187 NONAME R3UNUSED ; IoUtils::CCommandBase::Env(void)
+	EqualsL__C9RIoHandleRC9RIoHandle @ 188 NONAME R3UNUSED ; RIoHandle::EqualsL(RIoHandle const &) const
+	Equals__C9RIoHandleRC9RIoHandle @ 189 NONAME R3UNUSED ; RIoHandle::Equals(RIoHandle const &) const
+	Error__Q27IoUtils9Stringifyi @ 190 NONAME R3UNUSED ; IoUtils::Stringify::Error(int)
+	EscapeChar__CQ27IoUtils12CEnvironment @ 191 NONAME R3UNUSED ; IoUtils::CEnvironment::EscapeChar(void) const
+	EscapeLC__Q27IoUtils9StringifyRC6TDesC8RC5TChar @ 192 NONAME R3UNUSED ; IoUtils::Stringify::EscapeLC(TDesC8 const &, TChar const &)
+	EscapeLC__Q27IoUtils9StringifyRC7TDesC16RC5TChar @ 193 NONAME R3UNUSED ; IoUtils::Stringify::EscapeLC(TDesC16 const &, TChar const &)
+	Exists__CQ27IoUtils10TFileName2R3RFs @ 194 NONAME R3UNUSED ; IoUtils::TFileName2::Exists(RFs &) const
+	Exit__Q27IoUtils11CServerBasei @ 195 NONAME R3UNUSED ; IoUtils::CServerBase::Exit(int)
+	Ext__CQ27IoUtils10TFileName2 @ 196 NONAME R3UNUSED ; IoUtils::TFileName2::Ext(void) const
+	Extension___Q27IoUtils12CCommandBaseUiRPvPv @ 197 NONAME ; IoUtils::CCommandBase::Extension_(unsigned int, void *&, void *)
+	ExternalizeL__CQ27IoUtils12CEnvironmentR5TDes8 @ 198 NONAME R3UNUSED ; IoUtils::CEnvironment::ExternalizeL(TDes8 &) const
+	ExternalizedSize__CQ27IoUtils12CEnvironment @ 199 NONAME R3UNUSED ; IoUtils::CEnvironment::ExternalizedSize(void) const
+	Factory__Q27IoUtils11CServerBase @ 200 NONAME R3UNUSED ; IoUtils::CServerBase::Factory(void)
+	Factory__Q27IoUtils18CServerCommandBase @ 201 NONAME R3UNUSED ; IoUtils::CServerCommandBase::Factory(void)
+	FindFileL__Q27IoUtils10TFileName2R3RFs @ 202 NONAME R3UNUSED ; IoUtils::TFileName2::FindFileL(RFs &)
+	FindFile__Q27IoUtils10TFileName2R3RFs @ 203 NONAME R3UNUSED ; IoUtils::TFileName2::FindFile(RFs &)
+	FindFirstHandle__10RIoSessionQ29RIoHandle5TTypeRC7TDesC16RiRt4TBuf1i128 @ 204 NONAME ; RIoSession::FindFirstHandle(RIoHandle::TType, TDesC16 const &, int &, TBuf<128> &)
+	FindNextHandle__10RIoSessionRiRt4TBuf1i128 @ 205 NONAME R3UNUSED ; RIoSession::FindNextHandle(int &, TBuf<128> &)
+	Flags__CQ27IoUtils12CCommandBase @ 206 NONAME R3UNUSED ; IoUtils::CCommandBase::Flags(void) const
+	FsL__CQ27IoUtils12CCommandBase @ 207 NONAME R3UNUSED ; IoUtils::CCommandBase::FsL(void) const
+	FsL__Q27IoUtils12CCommandBase @ 208 NONAME R3UNUSED ; IoUtils::CCommandBase::FsL(void)
+	Fs__CQ27IoUtils12CCommandBase @ 209 NONAME R3UNUSED ; IoUtils::CCommandBase::Fs(void) const
+	Fs__Q27IoUtils12CCommandBase @ 210 NONAME R3UNUSED ; IoUtils::CCommandBase::Fs(void)
+	GetAsDesL__CQ27IoUtils12CEnvironmentRC7TDesC16 @ 211 NONAME R3UNUSED ; IoUtils::CEnvironment::GetAsDesL(TDesC16 const &) const
+	GetAsDes__CQ27IoUtils12CEnvironmentRC7TDesC16 @ 212 NONAME R3UNUSED ; IoUtils::CEnvironment::GetAsDes(TDesC16 const &) const
+	GetAsIntL__CQ27IoUtils12CEnvironmentRC7TDesC16 @ 213 NONAME R3UNUSED ; IoUtils::CEnvironment::GetAsIntL(TDesC16 const &) const
+	GetAsInt__CQ27IoUtils12CEnvironmentRC7TDesC16 @ 214 NONAME R3UNUSED ; IoUtils::CEnvironment::GetAsInt(TDesC16 const &) const
+	GetAttachedReaderAndWriterNamesL__20RIoPersistentConsoleRt4TBuf1i128T1 @ 215 NONAME R3UNUSED ; RIoPersistentConsole::GetAttachedReaderAndWriterNamesL(TBuf<128> &, TBuf<128> &)
+	GetAttachedReaderAndWriterNames__20RIoPersistentConsoleRt4TBuf1i128T1 @ 216 NONAME R3UNUSED ; RIoPersistentConsole::GetAttachedReaderAndWriterNames(TBuf<128> &, TBuf<128> &)
+	GetAttributes__CQ27IoUtils11CTextBufferiRUiRQ217ConsoleAttributes6TColorT3 @ 217 NONAME ; IoUtils::CTextBuffer::GetAttributes(int, unsigned int &, ConsoleAttributes::TColor &, ConsoleAttributes::TColor &) const
+	GetColorConsoleBaseL__Q27IoUtils12CCommandBase @ 218 NONAME R3UNUSED ; IoUtils::CCommandBase::GetColorConsoleBaseL(void)
+	GetConsoleBaseL__Q27IoUtils12CCommandBase @ 219 NONAME R3UNUSED ; IoUtils::CCommandBase::GetConsoleBaseL(void)
+	GetCreatorL__20RIoPersistentConsole @ 220 NONAME R3UNUSED ; RIoPersistentConsole::GetCreatorL(void)
+	GetCreator__20RIoPersistentConsoleR9TThreadId @ 221 NONAME R3UNUSED ; RIoPersistentConsole::GetCreator(TThreadId &)
+	GetCurrentAttributes__CQ27IoUtils11CTextBufferRUiRQ217ConsoleAttributes6TColorT2 @ 222 NONAME ; IoUtils::CTextBuffer::GetCurrentAttributes(unsigned int &, ConsoleAttributes::TColor &, ConsoleAttributes::TColor &) const
+	GetCursorPosL__C21RIoConsoleWriteHandle @ 223 NONAME R3UNUSED ; RIoConsoleWriteHandle::GetCursorPosL(void) const
+	GetCursorPos__C21RIoConsoleWriteHandleR6TPoint @ 224 NONAME R3UNUSED ; RIoConsoleWriteHandle::GetCursorPos(TPoint &) const
+	GetHelpTextL__Q27IoUtils12CCommandBase @ 225 NONAME R3UNUSED ; IoUtils::CCommandBase::GetHelpTextL(void)
+	GetScreenSizeL__C21RIoConsoleWriteHandle @ 226 NONAME R3UNUSED ; RIoConsoleWriteHandle::GetScreenSizeL(void) const
+	GetScreenSize__C21RIoConsoleWriteHandleR5TSize @ 227 NONAME R3UNUSED ; RIoConsoleWriteHandle::GetScreenSize(TSize &) const
+	GetString__CQ27IoUtils5TEnumi @ 228 NONAME R3UNUSED ; IoUtils::TEnum::GetString(int) const
+	GetSubCommandL__CQ27IoUtils21CServerCommandFactoryRC7TDesC16 @ 229 NONAME R3UNUSED ; IoUtils::CServerCommandFactory::GetSubCommandL(TDesC16 const &) const
+	HandleBackgroundSubCommand__Q27IoUtils18CBranchCommandBaseRQ27IoUtils18CServerCommandBase @ 230 NONAME R3UNUSED ; IoUtils::CBranchCommandBase::HandleBackgroundSubCommand(IoUtils::CServerCommandBase &)
+	HandleLeave__Q27IoUtils11CClientBasei @ 231 NONAME R3UNUSED ; IoUtils::CClientBase::HandleLeave(int)
+	HandleLeave__Q27IoUtils12CCommandBasei @ 232 NONAME R3UNUSED ; IoUtils::CCommandBase::HandleLeave(int)
+	HandleSubCommandComplete__Q27IoUtils18CBranchCommandBaseRQ27IoUtils18CServerCommandBase @ 233 NONAME R3UNUSED ; IoUtils::CBranchCommandBase::HandleSubCommandComplete(IoUtils::CServerCommandBase &)
+	HasDriveLetter__CQ27IoUtils10TFileName2 @ 234 NONAME R3UNUSED ; IoUtils::TFileName2::HasDriveLetter(void) const
+	HasLeadingSlash__CQ27IoUtils10TFileName2 @ 235 NONAME R3UNUSED ; IoUtils::TFileName2::HasLeadingSlash(void) const
+	HasTrailingSlash__CQ27IoUtils10TFileName2 @ 236 NONAME R3UNUSED ; IoUtils::TFileName2::HasTrailingSlash(void) const
+	HaveStatic__Q27IoUtils12CCommandBase @ 237 NONAME R3UNUSED ; IoUtils::CCommandBase::HaveStatic(void)
+	Id__CQ27IoUtils18CServerCommandBase @ 238 NONAME R3UNUSED ; IoUtils::CServerCommandBase::Id(void) const
+	ImplementationL__C10RIoConsoleR6TDes16 @ 239 NONAME R3UNUSED ; RIoConsole::ImplementationL(TDes16 &) const
+	Implementation__C10RIoConsoleR6TDes16 @ 240 NONAME R3UNUSED ; RIoConsole::Implementation(TDes16 &) const
+	InternalizeL__Q27IoUtils12CEnvironmentRC6TDesC8 @ 241 NONAME R3UNUSED ; IoUtils::CEnvironment::InternalizeL(TDesC8 const &)
+	IoSession__Q27IoUtils12CCommandBase @ 242 NONAME R3UNUSED ; IoUtils::CCommandBase::IoSession(void)
+	IsAbsolute__CQ27IoUtils10TFileName2 @ 243 NONAME R3UNUSED ; IoUtils::TFileName2::IsAbsolute(void) const
+	IsArchiveL__CQ27IoUtils10TFileName2R3RFs @ 244 NONAME R3UNUSED ; IoUtils::TFileName2::IsArchiveL(RFs &) const
+	IsComplete__CQ27IoUtils12CCommandBase @ 245 NONAME R3UNUSED ; IoUtils::CCommandBase::IsComplete(void) const
+	IsDefined__CQ27IoUtils12CEnvironmentRC7TDesC16 @ 246 NONAME R3UNUSED ; IoUtils::CEnvironment::IsDefined(TDesC16 const &) const
+	IsDes__CQ27IoUtils12CEnvironmentRC7TDesC16 @ 247 NONAME R3UNUSED ; IoUtils::CEnvironment::IsDes(TDesC16 const &) const
+	IsDirL__CQ27IoUtils10TFileName2R3RFs @ 248 NONAME R3UNUSED ; IoUtils::TFileName2::IsDirL(RFs &) const
+	IsDriveLetter__CQ27IoUtils10TFileName2 @ 249 NONAME R3UNUSED ; IoUtils::TFileName2::IsDriveLetter(void) const
+	IsDriveRoot__CQ27IoUtils10TFileName2 @ 250 NONAME R3UNUSED ; IoUtils::TFileName2::IsDriveRoot(void) const
+	IsFactory__CQ27IoUtils21CServerCommandFactory @ 251 NONAME R3UNUSED ; IoUtils::CServerCommandFactory::IsFactory(void) const
+	IsFactory__CQ27IoUtils25CServerCommandConstructor @ 252 NONAME R3UNUSED ; IoUtils::CServerCommandConstructor::IsFactory(void) const
+	IsForegroundL__C13RIoReadHandle @ 253 NONAME R3UNUSED ; RIoReadHandle::IsForegroundL(void) const
+	IsForeground__C13RIoReadHandle @ 254 NONAME R3UNUSED ; RIoReadHandle::IsForeground(void) const
+	IsHiddenL__CQ27IoUtils10TFileName2R3RFs @ 255 NONAME R3UNUSED ; IoUtils::TFileName2::IsHiddenL(RFs &) const
+	IsInt__CQ27IoUtils12CEnvironmentRC7TDesC16 @ 256 NONAME R3UNUSED ; IoUtils::CEnvironment::IsInt(TDesC16 const &) const
+	IsPresent__CQ27IoUtils18RCommandOptionListPv @ 257 NONAME R3UNUSED ; IoUtils::RCommandOptionList::IsPresent(void *) const
+	IsPresent__CQ27IoUtils20RCommandArgumentListPv @ 258 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::IsPresent(void *) const
+	IsPresent__CQ27IoUtils20RCommandArgumentListi @ 259 NONAME R3UNUSED ; IoUtils::RCommandArgumentList::IsPresent(int) const
+	IsReadOnlyL__CQ27IoUtils10TFileName2R3RFs @ 260 NONAME R3UNUSED ; IoUtils::TFileName2::IsReadOnlyL(RFs &) const
+	IsSystemL__CQ27IoUtils10TFileName2R3RFs @ 261 NONAME R3UNUSED ; IoUtils::TFileName2::IsSystemL(RFs &) const
+	IsTypeL__C9RIoHandleQ29RIoHandle5TType @ 262 NONAME R3UNUSED ; RIoHandle::IsTypeL(RIoHandle::TType) const
+	IsType__C9RIoHandleQ29RIoHandle5TType @ 263 NONAME R3UNUSED ; RIoHandle::IsType(RIoHandle::TType) const
+	IsWild__CQ27IoUtils10TFileName2 @ 264 NONAME R3UNUSED ; IoUtils::TFileName2::IsWild(void) const
+	KeyCode__C20RIoConsoleReadHandle @ 265 NONAME R3UNUSED ; RIoConsoleReadHandle::KeyCode(void) const
+	KeyModifiers__C20RIoConsoleReadHandle @ 266 NONAME R3UNUSED ; RIoConsoleReadHandle::KeyModifiers(void) const
+	Key__CQ27IoUtils12CEnvironmenti @ 267 NONAME R3UNUSED ABSENT ; IoUtils::CEnvironment::Key(int) const
+	LeaveIfFileExists__Q27IoUtils12CCommandBaseRC7TDesC16 @ 268 NONAME R3UNUSED ; IoUtils::CCommandBase::LeaveIfFileExists(TDesC16 const &)
+	LeaveIfFileNotFound__Q27IoUtils12CCommandBaseRC7TDesC16 @ 269 NONAME R3UNUSED ; IoUtils::CCommandBase::LeaveIfFileNotFound(TDesC16 const &)
+	Length__CQ27IoUtils11CTextBuffer @ 270 NONAME R3UNUSED ; IoUtils::CTextBuffer::Length(void) const
+	LeoHandleLine__Q27IoUtils11CServerBaseRC7TDesC16 @ 271 NONAME R3UNUSED ; IoUtils::CServerBase::LeoHandleLine(TDesC16 const &)
+	ListCommandsL__CQ27IoUtils21CServerCommandFactoryRt6RArray1Z7TPtrC16 @ 272 NONAME R3UNUSED ; IoUtils::CServerCommandFactory::ListCommandsL(RArray<TPtrC16> &) const
+	LoadMemoryAccessL__Q27IoUtils24CMemoryAccessCommandBase @ 273 NONAME R3UNUSED ; IoUtils::CMemoryAccessCommandBase::LoadMemoryAccessL(void)
+	LongDescription__CQ27IoUtils16CCommandInfoFile @ 274 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::LongDescription(void) const
+	MakeAbsoluteL__Q27IoUtils10TFileName2R3RFs @ 275 NONAME R3UNUSED ; IoUtils::TFileName2::MakeAbsoluteL(RFs &)
+	MakeAbsoluteL__Q27IoUtils10TFileName2RCQ27IoUtils10TFileName2 @ 276 NONAME R3UNUSED ; IoUtils::TFileName2::MakeAbsoluteL(IoUtils::TFileName2 const &)
+	NameAndExt__CQ27IoUtils10TFileName2 @ 277 NONAME R3UNUSED ; IoUtils::TFileName2::NameAndExt(void) const
+	Name__CQ27IoUtils10TFileName2 @ 278 NONAME R3UNUSED ; IoUtils::TFileName2::Name(void) const
+	Name__CQ27IoUtils16CCommandInfoFile @ 279 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::Name(void) const
+	Name__CQ27IoUtils25CServerCommandConstructor @ 280 NONAME R3UNUSED ; IoUtils::CServerCommandConstructor::Name(void) const
+	NarrowLC__Q27IoUtils9StringifyRC7TDesC16 @ 281 NONAME R3UNUSED ; IoUtils::Stringify::NarrowLC(TDesC16 const &)
+	NewConsole__7IoUtilsv @ 282 NONAME R3UNUSED ; IoUtils::NewConsole(void)
+	NewLC__Q27IoUtils11CTextBufferi @ 283 NONAME R3UNUSED ; IoUtils::CTextBuffer::NewLC(int)
+	NewLC__Q27IoUtils14CTextFormatterR21RIoConsoleWriteHandle @ 284 NONAME R3UNUSED ; IoUtils::CTextFormatter::NewLC(RIoConsoleWriteHandle &)
+	NewLC__Q27IoUtils14CTextFormatteri @ 285 NONAME R3UNUSED ; IoUtils::CTextFormatter::NewLC(int)
+	NewLC__Q27IoUtils21CServerCommandFactoryRC7TDesC16PFv_PQ27IoUtils18CServerCommandBasePQ27IoUtils22MServerCommandReporterPCQ27IoUtils16CCommandInfoFile @ 286 NONAME ; IoUtils::CServerCommandFactory::NewLC(TDesC16 const &, IoUtils::CServerCommandBase *(*)(void), IoUtils::MServerCommandReporter *, IoUtils::CCommandInfoFile const *)
+	NewLC__Q27IoUtils25CServerCommandConstructorRC7TDesC16PFv_PQ27IoUtils18CServerCommandBaseRQ27IoUtils21CServerCommandFactoryPQ27IoUtils22MServerCommandReporterPCQ27IoUtils16CCommandInfoFile @ 287 NONAME ; IoUtils::CServerCommandConstructor::NewLC(TDesC16 const &, IoUtils::CServerCommandBase *(*)(void), IoUtils::CServerCommandFactory &, IoUtils::MServerCommandReporter *, IoUtils::CCommandInfoFile const *)
+	NewL__Q27IoUtils11CTextBufferi @ 288 NONAME R3UNUSED ; IoUtils::CTextBuffer::NewL(int)
+	NewL__Q27IoUtils12CEnvironment @ 289 NONAME R3UNUSED ; IoUtils::CEnvironment::NewL(void)
+	NewL__Q27IoUtils12CEnvironmentRCQ27IoUtils12CEnvironment @ 290 NONAME R3UNUSED ; IoUtils::CEnvironment::NewL(IoUtils::CEnvironment const &)
+	NewL__Q27IoUtils14CTextFormatterR21RIoConsoleWriteHandle @ 291 NONAME R3UNUSED ; IoUtils::CTextFormatter::NewL(RIoConsoleWriteHandle &)
+	NewL__Q27IoUtils14CTextFormatteri @ 292 NONAME R3UNUSED ; IoUtils::CTextFormatter::NewL(int)
+	NewL__Q27IoUtils16CCommandInfoFileR3RFsRC7TDesC16 @ 293 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::NewL(RFs &, TDesC16 const &)
+	NewL__Q27IoUtils21CServerCommandFactoryPQ27IoUtils22MServerCommandReporterPCQ27IoUtils16CCommandInfoFile @ 294 NONAME R3UNUSED ; IoUtils::CServerCommandFactory::NewL(IoUtils::MServerCommandReporter *, IoUtils::CCommandInfoFile const *)
+	NotifyChange__13RIoReadHandleRt8TPckgBuf1ZUiR14TRequestStatus @ 295 NONAME R3UNUSED ; RIoReadHandle::NotifyChange(TPckgBuf<unsigned int> &, TRequestStatus &)
+	NotifyReaderDetach__20RIoPersistentConsoleR14TRequestStatus @ 296 NONAME R3UNUSED ; RIoPersistentConsole::NotifyReaderDetach(TRequestStatus &)
+	NotifyWriterDetach__20RIoPersistentConsoleR14TRequestStatus @ 297 NONAME R3UNUSED ; RIoPersistentConsole::NotifyWriterDetach(TRequestStatus &)
+	ObjectNameL__C9RIoHandleR6TDes16 @ 298 NONAME R3UNUSED ; RIoHandle::ObjectNameL(TDes16 &) const
+	ObjectName__C9RIoHandleR6TDes16 @ 299 NONAME R3UNUSED ; RIoHandle::ObjectName(TDes16 &) const
+	OpenByNameL__20RIoPersistentConsoleR10RIoSessionRC7TDesC16 @ 300 NONAME R3UNUSED ; RIoPersistentConsole::OpenByNameL(RIoSession &, TDesC16 const &)
+	OpenByName__20RIoPersistentConsoleR10RIoSessionRC7TDesC16 @ 301 NONAME R3UNUSED ; RIoPersistentConsole::OpenByName(RIoSession &, TDesC16 const &)
+	OpenFoundHandleL__9RIoHandleR10RIoSessioni @ 302 NONAME R3UNUSED ; RIoHandle::OpenFoundHandleL(RIoSession &, int)
+	OpenFoundHandle__9RIoHandleR10RIoSessioni @ 303 NONAME R3UNUSED ; RIoHandle::OpenFoundHandle(RIoSession &, int)
+	OpenL__10RIoConsoleR10RIoSessionR9RIoHandle @ 304 NONAME R3UNUSED ; RIoConsole::OpenL(RIoSession &, RIoHandle &)
+	OpenL__13RIoReadHandleR10RIoSession @ 305 NONAME R3UNUSED ; RIoReadHandle::OpenL(RIoSession &)
+	OpenL__13RIoReadHandleR10RIoSessionG9TThreadId @ 306 NONAME ; RIoReadHandle::OpenL(RIoSession &, TThreadId)
+	OpenL__14RIoWriteHandleR10RIoSession @ 307 NONAME R3UNUSED ; RIoWriteHandle::OpenL(RIoSession &)
+	OpenL__14RIoWriteHandleR10RIoSessionG9TThreadId @ 308 NONAME ; RIoWriteHandle::OpenL(RIoSession &, TThreadId)
+	Open__10RIoConsoleR10RIoSessionR9RIoHandle @ 309 NONAME R3UNUSED ; RIoConsole::Open(RIoSession &, RIoHandle &)
+	Open__13RIoReadHandleR10RIoSession @ 310 NONAME R3UNUSED ; RIoReadHandle::Open(RIoSession &)
+	Open__13RIoReadHandleR10RIoSessionG9TThreadId @ 311 NONAME ; RIoReadHandle::Open(RIoSession &, TThreadId)
+	Open__14RIoWriteHandleR10RIoSession @ 312 NONAME R3UNUSED ; RIoWriteHandle::Open(RIoSession &)
+	Open__14RIoWriteHandleR10RIoSessionG9TThreadId @ 313 NONAME ; RIoWriteHandle::Open(RIoSession &, TThreadId)
+	OptionsL__Q27IoUtils12CCommandBaseRQ27IoUtils18RCommandOptionList @ 314 NONAME R3UNUSED ; IoUtils::CCommandBase::OptionsL(IoUtils::RCommandOptionList &)
+	Options__CQ27IoUtils16CCommandInfoFile @ 315 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::Options(void) const
+	PageL__Q27IoUtils12CCommandBaseR13RIoReadHandle @ 316 NONAME R3UNUSED ; IoUtils::CCommandBase::PageL(RIoReadHandle &)
+	PageL__Q27IoUtils12CCommandBaseRCQ27IoUtils11CTextBuffer @ 317 NONAME R3UNUSED ; IoUtils::CCommandBase::PageL(IoUtils::CTextBuffer const &)
+	ParseCommandLineL__Q27IoUtils12CCommandBaseRC7TDesC16 @ 318 NONAME R3UNUSED ; IoUtils::CCommandBase::ParseCommandLineL(TDesC16 const &)
+	ParseCommandLine__Q27IoUtils12CCommandBaseRC7TDesC16 @ 319 NONAME R3UNUSED ; IoUtils::CCommandBase::ParseCommandLine(TDesC16 const &)
+	ParseL__Q27IoUtils5TEnumRC7TDesC16 @ 320 NONAME R3UNUSED ; IoUtils::TEnum::ParseL(TDesC16 const &)
+	Parse__Q27IoUtils5TEnumRC7TDesC16Ri @ 321 NONAME R3UNUSED ; IoUtils::TEnum::Parse(TDesC16 const &, int &)
+	Path__CQ27IoUtils10TFileName2 @ 322 NONAME R3UNUSED ; IoUtils::TFileName2::Path(void) const
+	PrependL__Q27IoUtils10TFileName2RCQ27IoUtils10TFileName2 @ 323 NONAME R3UNUSED ; IoUtils::TFileName2::PrependL(IoUtils::TFileName2 const &)
+	PrintErrorList__Q27IoUtils11CServerBaseiGt11TRefByValue1ZC7TDesC16RA0_PSc @ 324 NONAME ; IoUtils::CServerBase::PrintErrorList(int, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintErrorList__Q27IoUtils12CCommandBaseiGt11TRefByValue1ZC7TDesC16RA0_PSc @ 325 NONAME ; IoUtils::CCommandBase::PrintErrorList(int, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintErrorList__Q27IoUtils18CServerCommandBaseiGt11TRefByValue1ZC7TDesC16RA0_PSc @ 326 NONAME ; IoUtils::CServerCommandBase::PrintErrorList(int, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintError__Q27IoUtils12CCommandBaseiGt11TRefByValue1ZC7TDesC16e @ 327 NONAME ; IoUtils::CCommandBase::PrintError(int, TRefByValue<TDesC16 const>,...)
+	PrintError___7IoUtilsiGt11TRefByValue1ZC7TDesC16e @ 328 NONAME ; IoUtils::PrintError_(int, TRefByValue<TDesC16 const>,...)
+	PrintList__Q27IoUtils11CServerBaseGt11TRefByValue1ZC6TDesC8RA0_PSc @ 329 NONAME R3UNUSED ; IoUtils::CServerBase::PrintList(TRefByValue<TDesC8 const>, signed char *(&)[0])
+	PrintList__Q27IoUtils11CServerBaseGt11TRefByValue1ZC7TDesC16RA0_PSc @ 330 NONAME R3UNUSED ; IoUtils::CServerBase::PrintList(TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintList__Q27IoUtils12CCommandBaseGt11TRefByValue1ZC6TDesC8RA0_PSc @ 331 NONAME R3UNUSED ; IoUtils::CCommandBase::PrintList(TRefByValue<TDesC8 const>, signed char *(&)[0])
+	PrintList__Q27IoUtils12CCommandBaseGt11TRefByValue1ZC7TDesC16RA0_PSc @ 332 NONAME R3UNUSED ; IoUtils::CCommandBase::PrintList(TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintList__Q27IoUtils18CServerCommandBaseGt11TRefByValue1ZC6TDesC8RA0_PSc @ 333 NONAME R3UNUSED ; IoUtils::CServerCommandBase::PrintList(TRefByValue<TDesC8 const>, signed char *(&)[0])
+	PrintList__Q27IoUtils18CServerCommandBaseGt11TRefByValue1ZC7TDesC16RA0_PSc @ 334 NONAME R3UNUSED ; IoUtils::CServerCommandBase::PrintList(TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintWarningList__Q27IoUtils11CServerBaseGt11TRefByValue1ZC7TDesC16RA0_PSc @ 335 NONAME R3UNUSED ; IoUtils::CServerBase::PrintWarningList(TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintWarningList__Q27IoUtils12CCommandBaseGt11TRefByValue1ZC7TDesC16RA0_PSc @ 336 NONAME R3UNUSED ; IoUtils::CCommandBase::PrintWarningList(TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintWarningList__Q27IoUtils18CServerCommandBaseGt11TRefByValue1ZC7TDesC16RA0_PSc @ 337 NONAME R3UNUSED ; IoUtils::CServerCommandBase::PrintWarningList(TRefByValue<TDesC16 const>, signed char *(&)[0])
+	PrintWarning__Q27IoUtils12CCommandBaseGt11TRefByValue1ZC7TDesC16e @ 338 NONAME ; IoUtils::CCommandBase::PrintWarning(TRefByValue<TDesC16 const>,...)
+	PrintWarning___7IoUtilsGt11TRefByValue1ZC7TDesC16e @ 339 NONAME ; IoUtils::PrintWarning_(TRefByValue<TDesC16 const>,...)
+	Printf__Q27IoUtils12CCommandBaseGt11TRefByValue1ZC6TDesC8e @ 340 NONAME ; IoUtils::CCommandBase::Printf(TRefByValue<TDesC8 const>,...)
+	Printf__Q27IoUtils12CCommandBaseGt11TRefByValue1ZC7TDesC16e @ 341 NONAME ; IoUtils::CCommandBase::Printf(TRefByValue<TDesC16 const>,...)
+	Printf___7IoUtilsGt11TRefByValue1ZC6TDesC8e @ 342 NONAME ; IoUtils::Printf_(TRefByValue<TDesC8 const>,...)
+	Printf___7IoUtilsGt11TRefByValue1ZC7TDesC16e @ 343 NONAME ; IoUtils::Printf_(TRefByValue<TDesC16 const>,...)
+	Process__Q27IoUtils13RChildProcess @ 344 NONAME R3UNUSED ; IoUtils::RChildProcess::Process(void)
+	Pwd__CQ27IoUtils12CEnvironment @ 345 NONAME R3UNUSED ; IoUtils::CEnvironment::Pwd(void) const
+	ReadCancel__13RIoReadHandle @ 346 NONAME R3UNUSED ; RIoReadHandle::ReadCancel(void)
+	ReadKey__20RIoConsoleReadHandle @ 347 NONAME R3UNUSED ; RIoConsoleReadHandle::ReadKey(void)
+	ReadLC__Q27IoUtils9StringifyR6TLex16RC5TChar @ 348 NONAME R3UNUSED ; IoUtils::Stringify::ReadLC(TLex16 &, TChar const &)
+	ReadLC__Q27IoUtils9StringifyR6TLex16RC5TCharRQ27IoUtils12CCommandBase @ 349 NONAME R3UNUSED ; IoUtils::Stringify::ReadLC(TLex16 &, TChar const &, IoUtils::CCommandBase &)
+	ReadLC__Q27IoUtils9StringifyR6TLex16RC5TCharRQ27IoUtils12CCommandBaseUi @ 350 NONAME ; IoUtils::Stringify::ReadLC(TLex16 &, TChar const &, IoUtils::CCommandBase &, unsigned int)
+	ReadLC__Q27IoUtils9StringifyR6TLex16RC5TCharUi @ 351 NONAME R3UNUSED ; IoUtils::Stringify::ReadLC(TLex16 &, TChar const &, unsigned int)
+	ReadL__13RIoReadHandleR6TDes16 @ 352 NONAME R3UNUSED ; RIoReadHandle::ReadL(TDes16 &)
+	ReadL__7IoUtilsR6TDes16 @ 353 NONAME R3UNUSED ; IoUtils::ReadL(TDes16 &)
+	ReadL__Q27IoUtils12CCommandBaseR6TDes16 @ 354 NONAME R3UNUSED ; IoUtils::CCommandBase::ReadL(TDes16 &)
+	Read__13RIoReadHandleR6TDes16 @ 355 NONAME R3UNUSED ; RIoReadHandle::Read(TDes16 &)
+	Read__13RIoReadHandleR6TDes16R14TRequestStatus @ 356 NONAME R3UNUSED ; RIoReadHandle::Read(TDes16 &, TRequestStatus &)
+	RemoveL__Q27IoUtils12CEnvironmentRC7TDesC16 @ 357 NONAME R3UNUSED ; IoUtils::CEnvironment::RemoveL(TDesC16 const &)
+	Remove__Q27IoUtils12CEnvironmentRC7TDesC16 @ 358 NONAME R3UNUSED ; IoUtils::CEnvironment::Remove(TDesC16 const &)
+	ReportErrorList__Q27IoUtils11CServerBaseRCQ27IoUtils16TServerCommandIdiGt11TRefByValue1ZC7TDesC16RA0_PSc @ 359 NONAME ; IoUtils::CServerBase::ReportErrorList(IoUtils::TServerCommandId const &, int, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	ReportError__Q27IoUtils11CServerBaseRCQ27IoUtils16TServerCommandIdiGt11TRefByValue1ZC7TDesC16e @ 360 NONAME ; IoUtils::CServerBase::ReportError(IoUtils::TServerCommandId const &, int, TRefByValue<TDesC16 const>,...)
+	ReportList__Q27IoUtils11CServerBaseRCQ27IoUtils16TServerCommandIdGt11TRefByValue1ZC6TDesC8RA0_PSc @ 361 NONAME ; IoUtils::CServerBase::ReportList(IoUtils::TServerCommandId const &, TRefByValue<TDesC8 const>, signed char *(&)[0])
+	ReportList__Q27IoUtils11CServerBaseRCQ27IoUtils16TServerCommandIdGt11TRefByValue1ZC7TDesC16RA0_PSc @ 362 NONAME ; IoUtils::CServerBase::ReportList(IoUtils::TServerCommandId const &, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	ReportWarningList__Q27IoUtils11CServerBaseRCQ27IoUtils16TServerCommandIdGt11TRefByValue1ZC7TDesC16RA0_PSc @ 363 NONAME ; IoUtils::CServerBase::ReportWarningList(IoUtils::TServerCommandId const &, TRefByValue<TDesC16 const>, signed char *(&)[0])
+	ReportWarning__Q27IoUtils11CServerBaseRCQ27IoUtils16TServerCommandIdGt11TRefByValue1ZC7TDesC16e @ 364 NONAME ; IoUtils::CServerBase::ReportWarning(IoUtils::TServerCommandId const &, TRefByValue<TDesC16 const>,...)
+	Report__Q27IoUtils11CServerBaseRCQ27IoUtils16TServerCommandIdGt11TRefByValue1ZC6TDesC8e @ 365 NONAME ; IoUtils::CServerBase::Report(IoUtils::TServerCommandId const &, TRefByValue<TDesC8 const>,...)
+	Report__Q27IoUtils11CServerBaseRCQ27IoUtils16TServerCommandIdGt11TRefByValue1ZC7TDesC16e @ 366 NONAME ; IoUtils::CServerBase::Report(IoUtils::TServerCommandId const &, TRefByValue<TDesC16 const>,...)
+	ResetText__Q27IoUtils11CTextBuffer @ 367 NONAME R3UNUSED ; IoUtils::CTextBuffer::ResetText(void)
+	ResetText__Q27IoUtils14CTextFormatter @ 368 NONAME R3UNUSED ; IoUtils::CTextFormatter::ResetText(void)
+	Reset__Q27IoUtils11CTextBuffer @ 369 NONAME R3UNUSED ; IoUtils::CTextBuffer::Reset(void)
+	Reset__Q27IoUtils14CTextFormatter @ 370 NONAME R3UNUSED ; IoUtils::CTextFormatter::Reset(void)
+	RunCommandL__Q27IoUtils12CCommandBase @ 371 NONAME R3UNUSED ; IoUtils::CCommandBase::RunCommandL(void)
+	RunCommandL__Q27IoUtils12CCommandBasePC7TDesC16PQ27IoUtils12CEnvironment @ 372 NONAME R3UNUSED ; IoUtils::CCommandBase::RunCommandL(TDesC16 const *, IoUtils::CEnvironment *)
+	RunCommandL__Q27IoUtils12CCommandBaseR10RIoSessionR13RIoReadHandleR14RIoWriteHandleT3PC7TDesC16PQ27IoUtils12CEnvironment @ 373 NONAME ; IoUtils::CCommandBase::RunCommandL(RIoSession &, RIoReadHandle &, RIoWriteHandle &, RIoWriteHandle &, TDesC16 const *, IoUtils::CEnvironment *)
+	RunCommand__Q27IoUtils12CCommandBase @ 374 NONAME R3UNUSED ; IoUtils::CCommandBase::RunCommand(void)
+	RunCommand__Q27IoUtils12CCommandBasePC7TDesC16PQ27IoUtils12CEnvironment @ 375 NONAME R3UNUSED ; IoUtils::CCommandBase::RunCommand(TDesC16 const *, IoUtils::CEnvironment *)
+	RunCommand__Q27IoUtils12CCommandBaseR10RIoSessionR13RIoReadHandleR14RIoWriteHandleT3PC7TDesC16PQ27IoUtils12CEnvironment @ 376 NONAME ; IoUtils::CCommandBase::RunCommand(RIoSession &, RIoReadHandle &, RIoWriteHandle &, RIoWriteHandle &, TDesC16 const *, IoUtils::CEnvironment *)
+	RunCommand__Q27IoUtils12CCommandBaseR10RIoSessionR13RIoReadHandleR14RIoWriteHandleT3PC7TDesC16PQ27IoUtils12CEnvironmentPQ27IoUtils20MCommandBaseObserver @ 377 NONAME ; IoUtils::CCommandBase::RunCommand(RIoSession &, RIoReadHandle &, RIoWriteHandle &, RIoWriteHandle &, TDesC16 const *, IoUtils::CEnvironment *, IoUtils::MCommandBaseObserver *)
+	RunError__Q27IoUtils12CCommandBasei @ 378 NONAME R3UNUSED ; IoUtils::CCommandBase::RunError(int)
+	RunL__Q27IoUtils12CCommandBase @ 379 NONAME R3UNUSED ; IoUtils::CCommandBase::RunL(void)
+	Run__Q27IoUtils13RChildProcessR14TRequestStatus @ 380 NONAME R3UNUSED ; IoUtils::RChildProcess::Run(TRequestStatus &)
+	SeeAlso__CQ27IoUtils16CCommandInfoFile @ 381 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::SeeAlso(void) const
+	SetAttributesL__21RIoConsoleWriteHandleUiQ217ConsoleAttributes6TColorT2 @ 382 NONAME ; RIoConsoleWriteHandle::SetAttributesL(unsigned int, ConsoleAttributes::TColor, ConsoleAttributes::TColor)
+	SetAttributesL__Q27IoUtils11CTextBufferRCQ217ConsoleAttributes11TAttributes @ 383 NONAME R3UNUSED ; IoUtils::CTextBuffer::SetAttributesL(ConsoleAttributes::TAttributes const &)
+	SetAttributesL__Q27IoUtils11CTextBufferUiQ217ConsoleAttributes6TColorT2 @ 384 NONAME ; IoUtils::CTextBuffer::SetAttributesL(unsigned int, ConsoleAttributes::TColor, ConsoleAttributes::TColor)
+	SetAttributes__21RIoConsoleWriteHandleRCQ217ConsoleAttributes11TAttributes @ 385 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetAttributes(ConsoleAttributes::TAttributes const &)
+	SetAttributes__21RIoConsoleWriteHandleUiQ217ConsoleAttributes6TColorT2 @ 386 NONAME ; RIoConsoleWriteHandle::SetAttributes(unsigned int, ConsoleAttributes::TColor, ConsoleAttributes::TColor)
+	SetCursorHeightL__21RIoConsoleWriteHandlei @ 387 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetCursorHeightL(int)
+	SetCursorHeight__21RIoConsoleWriteHandlei @ 388 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetCursorHeight(int)
+	SetCursorPosAbsL__21RIoConsoleWriteHandleRC6TPoint @ 389 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetCursorPosAbsL(TPoint const &)
+	SetCursorPosAbs__21RIoConsoleWriteHandleRC6TPoint @ 390 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetCursorPosAbs(TPoint const &)
+	SetCursorPosRelL__21RIoConsoleWriteHandleRC6TPoint @ 391 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetCursorPosRelL(TPoint const &)
+	SetCursorPosRel__21RIoConsoleWriteHandleRC6TPoint @ 392 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetCursorPosRel(TPoint const &)
+	SetDescriptionList__Q27IoUtils5TEnumRC7TDesC16 @ 393 NONAME R3UNUSED ; IoUtils::TEnum::SetDescriptionList(TDesC16 const &)
+	SetDriveL__Q27IoUtils10TFileName2RC7TDesC16 @ 394 NONAME R3UNUSED ; IoUtils::TFileName2::SetDriveL(TDesC16 const &)
+	SetErrorReported__Q27IoUtils12CCommandBasei @ 395 NONAME R3UNUSED ; IoUtils::CCommandBase::SetErrorReported(int)
+	SetExtL__Q27IoUtils10TFileName2RC7TDesC16 @ 396 NONAME R3UNUSED ; IoUtils::TFileName2::SetExtL(TDesC16 const &)
+	SetFactory__Q27IoUtils18CServerCommandBaseRQ27IoUtils21CServerCommandFactory @ 397 NONAME R3UNUSED ; IoUtils::CServerCommandBase::SetFactory(IoUtils::CServerCommandFactory &)
+	SetFlags__Q27IoUtils12CCommandBaseUi @ 398 NONAME R3UNUSED ; IoUtils::CCommandBase::SetFlags(unsigned int)
+	SetForegroundReadHandleL__11RIoEndPointR13RIoReadHandle @ 399 NONAME R3UNUSED ; RIoEndPoint::SetForegroundReadHandleL(RIoReadHandle &)
+	SetForegroundReadHandle__11RIoEndPointR13RIoReadHandle @ 400 NONAME R3UNUSED ; RIoEndPoint::SetForegroundReadHandle(RIoReadHandle &)
+	SetId__Q27IoUtils18CServerCommandBaseRCQ27IoUtils16TServerCommandId @ 401 NONAME R3UNUSED ; IoUtils::CServerCommandBase::SetId(IoUtils::TServerCommandId const &)
+	SetIsDirectoryL__Q27IoUtils10TFileName2 @ 402 NONAME R3UNUSED ; IoUtils::TFileName2::SetIsDirectoryL(void)
+	SetL__Q27IoUtils10TFileName2RCQ27IoUtils10TFileName2 @ 403 NONAME R3UNUSED ; IoUtils::TFileName2::SetL(IoUtils::TFileName2 const &)
+	SetL__Q27IoUtils12CEnvironmentRC7TDesC16T1 @ 404 NONAME R3UNUSED ; IoUtils::CEnvironment::SetL(TDesC16 const &, TDesC16 const &)
+	SetL__Q27IoUtils12CEnvironmentRC7TDesC16i @ 405 NONAME R3UNUSED ; IoUtils::CEnvironment::SetL(TDesC16 const &, int)
+	SetLineSeparatorL__13RIoReadHandleRC7TDesC16 @ 406 NONAME R3UNUSED ; RIoReadHandle::SetLineSeparatorL(TDesC16 const &)
+	SetLineSeparator__13RIoReadHandleRC7TDesC16 @ 407 NONAME R3UNUSED ; RIoReadHandle::SetLineSeparator(TDesC16 const &)
+	SetModeL__18RIoReadWriteHandleQ218RIoReadWriteHandle5TMode @ 408 NONAME R3UNUSED ; RIoReadWriteHandle::SetModeL(RIoReadWriteHandle::TMode)
+	SetMode__18RIoReadWriteHandleQ218RIoReadWriteHandle5TMode @ 409 NONAME R3UNUSED ; RIoReadWriteHandle::SetMode(RIoReadWriteHandle::TMode)
+	SetNameAndExtL__Q27IoUtils10TFileName2RC7TDesC16 @ 410 NONAME R3UNUSED ; IoUtils::TFileName2::SetNameAndExtL(TDesC16 const &)
+	SetNameL__Q27IoUtils10TFileName2RC7TDesC16 @ 411 NONAME R3UNUSED ; IoUtils::TFileName2::SetNameL(TDesC16 const &)
+	SetObjectNameL__10RIoSessioniRC7TDesC16 @ 412 NONAME R3UNUSED ; RIoSession::SetObjectNameL(int, TDesC16 const &)
+	SetObjectName__10RIoSessioniRC7TDesC16 @ 413 NONAME R3UNUSED ; RIoSession::SetObjectName(int, TDesC16 const &)
+	SetOwnerL__18RIoReadWriteHandleG9TThreadId @ 414 NONAME ; RIoReadWriteHandle::SetOwnerL(TThreadId)
+	SetOwner__18RIoReadWriteHandleG9TThreadId @ 415 NONAME ; RIoReadWriteHandle::SetOwner(TThreadId)
+	SetPathL__Q27IoUtils10TFileName2RC7TDesC16 @ 416 NONAME R3UNUSED ; IoUtils::TFileName2::SetPathL(TDesC16 const &)
+	SetPwdL__Q27IoUtils12CEnvironmentRC7TDesC16 @ 417 NONAME R3UNUSED ; IoUtils::CEnvironment::SetPwdL(TDesC16 const &)
+	SetReadModeL__13RIoReadHandleQ213RIoReadHandle9TReadMode @ 418 NONAME R3UNUSED ; RIoReadHandle::SetReadModeL(RIoReadHandle::TReadMode)
+	SetReadMode__13RIoReadHandleQ213RIoReadHandle9TReadMode @ 419 NONAME R3UNUSED ; RIoReadHandle::SetReadMode(RIoReadHandle::TReadMode)
+	SetTitleL__21RIoConsoleWriteHandleRC7TDesC16 @ 420 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetTitleL(TDesC16 const &)
+	SetTitle__21RIoConsoleWriteHandleRC7TDesC16 @ 421 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetTitle(TDesC16 const &)
+	SetToForegroundL__13RIoReadHandle @ 422 NONAME R3UNUSED ; RIoReadHandle::SetToForegroundL(void)
+	SetToForeground__13RIoReadHandle @ 423 NONAME R3UNUSED ; RIoReadHandle::SetToForeground(void)
+	SetTypeL__Q27IoUtils10TFileName2Q37IoUtils10TFileName25TType @ 424 NONAME R3UNUSED ; IoUtils::TFileName2::SetTypeL(IoUtils::TFileName2::TType)
+	SetUnderlyingConsoleL__18RIoReadWriteHandleR10RIoConsole @ 425 NONAME R3UNUSED ; RIoReadWriteHandle::SetUnderlyingConsoleL(RIoConsole &)
+	SetUnderlyingConsole__18RIoReadWriteHandleR10RIoConsole @ 426 NONAME R3UNUSED ; RIoReadWriteHandle::SetUnderlyingConsole(RIoConsole &)
+	SetValueList__Q27IoUtils5TEnumRC7TDesC16 @ 427 NONAME R3UNUSED ; IoUtils::TEnum::SetValueList(TDesC16 const &)
+	Set__Q27IoUtils16TServerCommandIdRCQ27IoUtils16TServerCommandId @ 428 NONAME R3UNUSED ; IoUtils::TServerCommandId::Set(IoUtils::TServerCommandId const &)
+	ShortDescription__CQ27IoUtils16CCommandInfoFile @ 429 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::ShortDescription(void) const
+	SplitL__Q27IoUtils10TFileName2Rt6RArray1ZQ27IoUtils10TFileName2 @ 430 NONAME R3UNUSED ; IoUtils::TFileName2::SplitL(RArray<IoUtils::TFileName2> &)
+	Static__Q27IoUtils12CCommandBase @ 431 NONAME R3UNUSED ; IoUtils::CCommandBase::Static(void)
+	Stderr__Q27IoUtils12CCommandBase @ 432 NONAME R3UNUSED ; IoUtils::CCommandBase::Stderr(void)
+	StdinChange__Q27IoUtils12CCommandBaseUi @ 433 NONAME R3UNUSED ; IoUtils::CCommandBase::StdinChange(unsigned int)
+	Stdin__Q27IoUtils12CCommandBase @ 434 NONAME R3UNUSED ; IoUtils::CCommandBase::Stdin(void)
+	Stdout__Q27IoUtils12CCommandBase @ 435 NONAME R3UNUSED ; IoUtils::CCommandBase::Stdout(void)
+	TabulateL__Q27IoUtils14CTextFormatteriiRC7TDesC16 @ 436 NONAME ; IoUtils::CTextFormatter::TabulateL(int, int, TDesC16 const &)
+	TabulateL__Q27IoUtils14CTextFormatteriiRC7TDesC16Q27IoUtils8TTabMode @ 437 NONAME ; IoUtils::CTextFormatter::TabulateL(int, int, TDesC16 const &, IoUtils::TTabMode)
+	UnsplitL__Q27IoUtils10TFileName2RCt6RArray1ZQ27IoUtils10TFileName2 @ 438 NONAME R3UNUSED ; IoUtils::TFileName2::UnsplitL(RArray<IoUtils::TFileName2> const &)
+	ValueList__CQ27IoUtils5TEnum @ 439 NONAME R3UNUSED ; IoUtils::TEnum::ValueList(void) const
+	Value__CQ27IoUtils16TServerCommandId @ 440 NONAME R3UNUSED ; IoUtils::TServerCommandId::Value(void) const
+	WaitForKeyCancel__20RIoConsoleReadHandle @ 441 NONAME R3UNUSED ; RIoConsoleReadHandle::WaitForKeyCancel(void)
+	WaitForKey__20RIoConsoleReadHandleR14TRequestStatus @ 442 NONAME R3UNUSED ; RIoConsoleReadHandle::WaitForKey(TRequestStatus &)
+	WidenLC__Q27IoUtils9StringifyRC6TDesC8 @ 443 NONAME R3UNUSED ; IoUtils::Stringify::WidenLC(TDesC8 const &)
+	WrapL__Q27IoUtils14CTextFormatteriRC7TDesC16 @ 444 NONAME R3UNUSED ; IoUtils::CTextFormatter::WrapL(int, TDesC16 const &)
+	WrapL__Q27IoUtils14CTextFormatteriiRC7TDesC16 @ 445 NONAME ; IoUtils::CTextFormatter::WrapL(int, int, TDesC16 const &)
+	WriteCancel__14RIoWriteHandle @ 446 NONAME R3UNUSED ; RIoWriteHandle::WriteCancel(void)
+	WriteL__14RIoWriteHandleRC7TDesC16 @ 447 NONAME R3UNUSED ; RIoWriteHandle::WriteL(TDesC16 const &)
+	Write__14RIoWriteHandleRC7TDesC16 @ 448 NONAME R3UNUSED ; RIoWriteHandle::Write(TDesC16 const &)
+	Write__14RIoWriteHandleRC7TDesC16R14TRequestStatus @ 449 NONAME R3UNUSED ; RIoWriteHandle::Write(TDesC16 const &, TRequestStatus &)
+	Write__CQ27IoUtils11CTextBufferR14RIoWriteHandle @ 450 NONAME R3UNUSED ; IoUtils::CTextBuffer::Write(RIoWriteHandle &) const
+	Write__CQ27IoUtils11CTextBufferR14RIoWriteHandleR14TRequestStatus @ 451 NONAME R3UNUSED ; IoUtils::CTextBuffer::Write(RIoWriteHandle &, TRequestStatus &) const
+	Write__CQ27IoUtils11CTextBufferR14RIoWriteHandleii @ 452 NONAME ; IoUtils::CTextBuffer::Write(RIoWriteHandle &, int, int) const
+	Write__CQ27IoUtils11CTextBufferR14RIoWriteHandleiiR14TRequestStatus @ 453 NONAME ; IoUtils::CTextBuffer::Write(RIoWriteHandle &, int, int, TRequestStatus &) const
+	Write__Q27IoUtils12CCommandBaseRC7TDesC16 @ 454 NONAME R3UNUSED ; IoUtils::CCommandBase::Write(TDesC16 const &)
+	Write__Q27IoUtils14CTextFormatter @ 455 NONAME R3UNUSED ; IoUtils::CTextFormatter::Write(void)
+	Write___7IoUtilsRC7TDesC16 @ 456 NONAME R3UNUSED ; IoUtils::Write_(TDesC16 const &)
+	Zero__Q27IoUtils11CTextBuffer @ 457 NONAME R3UNUSED ; IoUtils::CTextBuffer::Zero(void)
+	Zero__Q27IoUtils14CTextFormatter @ 458 NONAME R3UNUSED ; IoUtils::CTextFormatter::Zero(void)
+	"_._Q27IoUtils11CClientBase" @ 459 NONAME R3UNUSED ; IoUtils::CClientBase::~CClientBase(void)
+	"_._Q27IoUtils11CServerBase" @ 460 NONAME R3UNUSED ; IoUtils::CServerBase::~CServerBase(void)
+	"_._Q27IoUtils11CTextBuffer" @ 461 NONAME R3UNUSED ; IoUtils::CTextBuffer::~CTextBuffer(void)
+	"_._Q27IoUtils12CCommandBase" @ 462 NONAME R3UNUSED ; IoUtils::CCommandBase::~CCommandBase(void)
+	"_._Q27IoUtils12CEnvironment" @ 463 NONAME R3UNUSED ; IoUtils::CEnvironment::~CEnvironment(void)
+	"_._Q27IoUtils14CTextFormatter" @ 464 NONAME R3UNUSED ; IoUtils::CTextFormatter::~CTextFormatter(void)
+	"_._Q27IoUtils16CCommandInfoFile" @ 465 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::~CCommandInfoFile(void)
+	"_._Q27IoUtils18CBranchCommandBase" @ 466 NONAME R3UNUSED ; IoUtils::CBranchCommandBase::~CBranchCommandBase(void)
+	"_._Q27IoUtils18CServerCommandBase" @ 467 NONAME R3UNUSED ; IoUtils::CServerCommandBase::~CServerCommandBase(void)
+	"_._Q27IoUtils21CServerCommandFactory" @ 468 NONAME R3UNUSED ; IoUtils::CServerCommandFactory::~CServerCommandFactory(void)
+	"_._Q27IoUtils24CMemoryAccessCommandBase" @ 469 NONAME R3UNUSED ; IoUtils::CMemoryAccessCommandBase::~CMemoryAccessCommandBase(void)
+	"_._Q27IoUtils25CServerCommandConstructor" @ 470 NONAME R3UNUSED ; IoUtils::CServerCommandConstructor::~CServerCommandConstructor(void)
+	__11RIoEndPoint @ 471 NONAME R3UNUSED ; RIoEndPoint::RIoEndPoint(void)
+	__20RIoConsoleReadHandle @ 472 NONAME R3UNUSED ; RIoConsoleReadHandle::RIoConsoleReadHandle(void)
+	__20RIoConsoleReadHandleR13RIoReadHandle @ 473 NONAME R3UNUSED ; RIoConsoleReadHandle::RIoConsoleReadHandle(RIoReadHandle &)
+	__21RIoConsoleWriteHandle @ 474 NONAME R3UNUSED ; RIoConsoleWriteHandle::RIoConsoleWriteHandle(void)
+	__21RIoConsoleWriteHandleR14RIoWriteHandle @ 475 NONAME R3UNUSED ; RIoConsoleWriteHandle::RIoConsoleWriteHandle(RIoWriteHandle &)
+	__Q27IoUtils10TFileName2 @ 476 NONAME R3UNUSED ; IoUtils::TFileName2::TFileName2(void)
+	__Q27IoUtils10TFileName2Q37IoUtils10TFileName25TType @ 477 NONAME R3UNUSED ; IoUtils::TFileName2::TFileName2(IoUtils::TFileName2::TType)
+	__Q27IoUtils10TFileName2RC7TDesC16 @ 478 NONAME R3UNUSED ; IoUtils::TFileName2::TFileName2(TDesC16 const &)
+	__Q27IoUtils10TFileName2RC7TDesC16Q37IoUtils10TFileName25TType @ 479 NONAME R3UNUSED ; IoUtils::TFileName2::TFileName2(TDesC16 const &, IoUtils::TFileName2::TType)
+	__Q27IoUtils11CClientBaseUiRC7TDesC16N22 @ 480 NONAME ; IoUtils::CClientBase::CClientBase(unsigned int, TDesC16 const &, TDesC16 const &, TDesC16 const &)
+	__Q27IoUtils11CServerBaseUiRC7TDesC16T2 @ 481 NONAME ; IoUtils::CServerBase::CServerBase(unsigned int, TDesC16 const &, TDesC16 const &)
+	__Q27IoUtils12CCommandBase @ 482 NONAME R3UNUSED ; IoUtils::CCommandBase::CCommandBase(void)
+	__Q27IoUtils12CCommandBaseUi @ 483 NONAME R3UNUSED ; IoUtils::CCommandBase::CCommandBase(unsigned int)
+	__Q27IoUtils16TServerCommandId @ 484 NONAME R3UNUSED ; IoUtils::TServerCommandId::TServerCommandId(void)
+	__Q27IoUtils16TServerCommandIdUi @ 485 NONAME R3UNUSED ; IoUtils::TServerCommandId::TServerCommandId(unsigned int)
+	__Q27IoUtils18CBranchCommandBase @ 486 NONAME R3UNUSED ; IoUtils::CBranchCommandBase::CBranchCommandBase(void)
+	__Q27IoUtils18CServerCommandBase @ 487 NONAME R3UNUSED ; IoUtils::CServerCommandBase::CServerCommandBase(void)
+	__Q27IoUtils18CServerCommandBaseUi @ 488 NONAME R3UNUSED ; IoUtils::CServerCommandBase::CServerCommandBase(unsigned int)
+	__Q27IoUtils24CMemoryAccessCommandBase @ 489 NONAME R3UNUSED ; IoUtils::CMemoryAccessCommandBase::CMemoryAccessCommandBase(void)
+	__Q27IoUtils24CMemoryAccessCommandBaseUi @ 490 NONAME R3UNUSED ; IoUtils::CMemoryAccessCommandBase::CMemoryAccessCommandBase(unsigned int)
+	__Q27IoUtils5TEnum @ 491 NONAME R3UNUSED ; IoUtils::TEnum::TEnum(void)
+	__Q27IoUtils5TEnumRC7TDesC16 @ 492 NONAME R3UNUSED ; IoUtils::TEnum::TEnum(TDesC16 const &)
+	__Q27IoUtils5TEnumRC7TDesC16T1 @ 493 NONAME R3UNUSED ; IoUtils::TEnum::TEnum(TDesC16 const &, TDesC16 const &)
+	__as__20RIoConsoleReadHandleR13RIoReadHandle @ 494 NONAME R3UNUSED ; RIoConsoleReadHandle::operator=(RIoReadHandle &)
+	__as__21RIoConsoleWriteHandleR14RIoWriteHandle @ 495 NONAME R3UNUSED ; RIoConsoleWriteHandle::operator=(RIoWriteHandle &)
+	AddSubCommandL__Q27IoUtils21CServerCommandFactoryPCQ27IoUtils25CServerCommandConstructor @ 496 NONAME R3UNUSED ; IoUtils::CServerCommandFactory::AddSubCommandL(IoUtils::CServerCommandConstructor const *)
+	IsDir__CQ27IoUtils10TFileName2 @ 497 NONAME R3UNUSED ; IoUtils::TFileName2::IsDir(void) const
+	IsFile__CQ27IoUtils10TFileName2 @ 498 NONAME R3UNUSED ; IoUtils::TFileName2::IsFile(void) const
+	SetTypeL__Q27IoUtils10TFileName2R3RFs @ 499 NONAME R3UNUSED ; IoUtils::TFileName2::SetTypeL(RFs &)
+	UsingCif__CQ27IoUtils12CCommandBase @ 500 NONAME R3UNUSED ; IoUtils::CCommandBase::UsingCif(void) const
+	Process__CQ27IoUtils13RChildProcess @ 501 NONAME R3UNUSED ; IoUtils::RChildProcess::Process(void) const
+	__vc__Q27IoUtils18RCommandOptionListi @ 502 NONAME R3UNUSED ; IoUtils::RCommandOptionList::operator[](int)
+	Count__CQ27IoUtils18RCommandOptionList @ 503 NONAME R3UNUSED ; IoUtils::RCommandOptionList::Count(void) const
+	Name__CQ27IoUtils6TValue @ 504 NONAME R3UNUSED ; IoUtils::TValue::Name(void) const
+	NewL__Q27IoUtils16CCommandInfoFileR3RFsRCQ27IoUtils12CEnvironmentRC7TDesC16 @ 505 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::NewL(RFs &, IoUtils::CEnvironment const &, TDesC16 const &)
+	StartSupressingErrors__Q27IoUtils12CCommandBase @ 506 NONAME R3UNUSED ; IoUtils::CCommandBase::StartSupressingErrors(void)
+	StopSupressingErrors__Q27IoUtils12CCommandBase @ 507 NONAME R3UNUSED ; IoUtils::CCommandBase::StopSupressingErrors(void)
+	__vc__CQ27IoUtils18RCommandOptionListi @ 508 NONAME R3UNUSED ; IoUtils::RCommandOptionList::operator[](int) const
+	DuplicateHandleFromThread__13RIoReadHandleG9TThreadId @ 509 NONAME ; RIoReadHandle::DuplicateHandleFromThread(TThreadId)
+	DuplicateHandleFromThread__14RIoWriteHandleG9TThreadId @ 510 NONAME ; RIoWriteHandle::DuplicateHandleFromThread(TThreadId)
+	NumSubCommands__CQ27IoUtils16CCommandInfoFile @ 511 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::NumSubCommands(void) const
+	SetIsStdErr__21RIoConsoleWriteHandlei @ 512 NONAME R3UNUSED ; RIoConsoleWriteHandle::SetIsStdErr(int)
+	SubCommand__CQ27IoUtils16CCommandInfoFilei @ 513 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::SubCommand(int) const
+	AppendEnumL__Q27IoUtils18RCommandOptionListRiRC7TDesC16T2 @ 514 NONAME ; IoUtils::RCommandOptionList::AppendEnumL(int &, TDesC16 const &, TDesC16 const &)
+	AppendEnumL__Q27IoUtils18RCommandOptionListRt6RArray1ZiRC7TDesC16T2 @ 515 NONAME ; IoUtils::RCommandOptionList::AppendEnumL(RArray<int> &, TDesC16 const &, TDesC16 const &)
+	AppendEnumL__Q27IoUtils20RCommandArgumentListRiRC7TDesC16T2 @ 516 NONAME ; IoUtils::RCommandArgumentList::AppendEnumL(int &, TDesC16 const &, TDesC16 const &)
+	AppendEnumL__Q27IoUtils20RCommandArgumentListRt6RArray1ZiRC7TDesC16T2 @ 517 NONAME ; IoUtils::RCommandArgumentList::AppendEnumL(RArray<int> &, TDesC16 const &, TDesC16 const &)
+	SubCommand__CQ27IoUtils16CCommandInfoFileRC7TDesC16 @ 518 NONAME R3UNUSED ; IoUtils::CCommandInfoFile::SubCommand(TDesC16 const &) const
+	TypeDescription__Q27IoUtils18CBranchCommandBase @ 519 NONAME R3UNUSED ; IoUtils::CBranchCommandBase::TypeDescription(void)
+	__as__Q27IoUtils5TEnumRCQ27IoUtils5TEnum @ 520 NONAME R3UNUSED ; IoUtils::TEnum::operator=(IoUtils::TEnum const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/bwins/iocliu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,545 @@
+EXPORTS
+	??0CBranchCommandBase@IoUtils@@IAE@XZ @ 1 NONAME ; IoUtils::CBranchCommandBase::CBranchCommandBase(void)
+	??0CClientBase@IoUtils@@IAE@IABVTDesC16@@00@Z @ 2 NONAME ; IoUtils::CClientBase::CClientBase(unsigned int, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &)
+	??0CCommandBase@IoUtils@@IAE@I@Z @ 3 NONAME ; IoUtils::CCommandBase::CCommandBase(unsigned int)
+	??0CCommandBase@IoUtils@@IAE@XZ @ 4 NONAME ; IoUtils::CCommandBase::CCommandBase(void)
+	??0CServerBase@IoUtils@@IAE@IABVTDesC16@@0@Z @ 5 NONAME ; IoUtils::CServerBase::CServerBase(unsigned int, class TDesC16 const &, class TDesC16 const &)
+	??0CServerCommandBase@IoUtils@@IAE@I@Z @ 6 NONAME ; IoUtils::CServerCommandBase::CServerCommandBase(unsigned int)
+	??0CServerCommandBase@IoUtils@@IAE@XZ @ 7 NONAME ; IoUtils::CServerCommandBase::CServerCommandBase(void)
+	??0RIoConsoleReadHandle@@QAE@AAVRIoReadHandle@@@Z @ 8 NONAME ; RIoConsoleReadHandle::RIoConsoleReadHandle(class RIoReadHandle &)
+	??0RIoConsoleReadHandle@@QAE@XZ @ 9 NONAME ; RIoConsoleReadHandle::RIoConsoleReadHandle(void)
+	??0RIoConsoleWriteHandle@@QAE@AAVRIoWriteHandle@@@Z @ 10 NONAME ; RIoConsoleWriteHandle::RIoConsoleWriteHandle(class RIoWriteHandle &)
+	??0RIoConsoleWriteHandle@@QAE@XZ @ 11 NONAME ; RIoConsoleWriteHandle::RIoConsoleWriteHandle(void)
+	??0RIoEndPoint@@QAE@XZ @ 12 NONAME ; RIoEndPoint::RIoEndPoint(void)
+	??0TEnum@IoUtils@@QAE@ABVTDesC16@@@Z @ 13 NONAME ; IoUtils::TEnum::TEnum(class TDesC16 const &)
+	??0TFileName2@IoUtils@@QAE@ABVTDesC16@@@Z @ 14 NONAME ; IoUtils::TFileName2::TFileName2(class TDesC16 const &)
+	??0TFileName2@IoUtils@@QAE@ABVTDesC16@@W4TType@01@@Z @ 15 NONAME ; IoUtils::TFileName2::TFileName2(class TDesC16 const &, enum IoUtils::TFileName2::TType)
+	??0TFileName2@IoUtils@@QAE@W4TType@01@@Z @ 16 NONAME ; IoUtils::TFileName2::TFileName2(enum IoUtils::TFileName2::TType)
+	??0TFileName2@IoUtils@@QAE@XZ @ 17 NONAME ; IoUtils::TFileName2::TFileName2(void)
+	??0TServerCommandId@IoUtils@@QAE@I@Z @ 18 NONAME ; IoUtils::TServerCommandId::TServerCommandId(unsigned int)
+	??0TServerCommandId@IoUtils@@QAE@XZ @ 19 NONAME ; IoUtils::TServerCommandId::TServerCommandId(void)
+	??1CBranchCommandBase@IoUtils@@UAE@XZ @ 20 NONAME ; IoUtils::CBranchCommandBase::~CBranchCommandBase(void)
+	??1CClientBase@IoUtils@@MAE@XZ @ 21 NONAME ; IoUtils::CClientBase::~CClientBase(void)
+	??1CCommandBase@IoUtils@@UAE@XZ @ 22 NONAME ; IoUtils::CCommandBase::~CCommandBase(void)
+	??1CEnvironment@IoUtils@@UAE@XZ @ 23 NONAME ; IoUtils::CEnvironment::~CEnvironment(void)
+	??1CServerBase@IoUtils@@UAE@XZ @ 24 NONAME ; IoUtils::CServerBase::~CServerBase(void)
+	??1CServerCommandBase@IoUtils@@UAE@XZ @ 25 NONAME ; IoUtils::CServerCommandBase::~CServerCommandBase(void)
+	??1CServerCommandConstructor@IoUtils@@UAE@XZ @ 26 NONAME ; IoUtils::CServerCommandConstructor::~CServerCommandConstructor(void)
+	??1CServerCommandFactory@IoUtils@@UAE@XZ @ 27 NONAME ; IoUtils::CServerCommandFactory::~CServerCommandFactory(void)
+	??1CTextBuffer@IoUtils@@UAE@XZ @ 28 NONAME ; IoUtils::CTextBuffer::~CTextBuffer(void)
+	??1CTextFormatter@IoUtils@@UAE@XZ @ 29 NONAME ; IoUtils::CTextFormatter::~CTextFormatter(void)
+	??4RIoConsoleReadHandle@@QAE?AV0@AAVRIoReadHandle@@@Z @ 30 NONAME ; class RIoConsoleReadHandle RIoConsoleReadHandle::operator=(class RIoReadHandle &)
+	??4RIoConsoleWriteHandle@@QAE?AV0@AAVRIoWriteHandle@@@Z @ 31 NONAME ; class RIoConsoleWriteHandle RIoConsoleWriteHandle::operator=(class RIoWriteHandle &)
+	??8TServerCommandId@IoUtils@@QBEHABV01@@Z @ 32 NONAME ; int IoUtils::TServerCommandId::operator==(class IoUtils::TServerCommandId const &) const
+	?AddSubCommandL@CServerCommandFactory@IoUtils@@AAEXPBVCServerCommandConstructor@2@@Z @ 33 NONAME ; void IoUtils::CServerCommandFactory::AddSubCommandL(class IoUtils::CServerCommandConstructor const *)
+	?AppendBoolL@RCommandOptionList@IoUtils@@QAEXAAHVTChar@@ABVTDesC16@@2I2@Z @ 34 NONAME ; void IoUtils::RCommandOptionList::AppendBoolL(int &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendBoolL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@H@@VTChar@@ABVTDesC16@@2I2@Z @ 35 NONAME ; void IoUtils::RCommandOptionList::AppendBoolL(class RArray<int> &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendComponentL@TFileName2@IoUtils@@QAEXABV12@@Z @ 36 NONAME ; void IoUtils::TFileName2::AppendComponentL(class IoUtils::TFileName2 const &)
+	?AppendComponentL@TFileName2@IoUtils@@QAEXABVTDesC16@@W4TType@12@@Z @ 37 NONAME ; void IoUtils::TFileName2::AppendComponentL(class TDesC16 const &, enum IoUtils::TFileName2::TType)
+	?AppendComponentL@TFileName2@IoUtils@@QAEXABVTEntry@@@Z @ 38 NONAME ; void IoUtils::TFileName2::AppendComponentL(class TEntry const &)
+	?AppendEnumL@RCommandArgumentList@IoUtils@@QAEXAAHABVTDesC16@@11I1@Z @ 39 NONAME ; void IoUtils::RCommandArgumentList::AppendEnumL(int &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendEnumL@RCommandOptionList@IoUtils@@QAEXAAHVTChar@@ABVTDesC16@@22I2@Z @ 40 NONAME ; void IoUtils::RCommandOptionList::AppendEnumL(int &, class TChar, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendFileNameL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@VTFileName2@IoUtils@@@@ABVTDesC16@@1I1@Z @ 41 NONAME ; void IoUtils::RCommandArgumentList::AppendFileNameL(class RArray<class IoUtils::TFileName2> &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendFileNameL@RCommandArgumentList@IoUtils@@QAEXAAVTFileName2@2@ABVTDesC16@@1I1@Z @ 42 NONAME ; void IoUtils::RCommandArgumentList::AppendFileNameL(class IoUtils::TFileName2 &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendFileNameL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@VTFileName2@IoUtils@@@@VTChar@@ABVTDesC16@@2I2@Z @ 43 NONAME ; void IoUtils::RCommandOptionList::AppendFileNameL(class RArray<class IoUtils::TFileName2> &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendFileNameL@RCommandOptionList@IoUtils@@QAEXAAVTFileName2@2@VTChar@@ABVTDesC16@@2I2@Z @ 44 NONAME ; void IoUtils::RCommandOptionList::AppendFileNameL(class IoUtils::TFileName2 &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendFormatL@CTextBuffer@IoUtils@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 45 NONAME ; void IoUtils::CTextBuffer::AppendFormatL(class TRefByValue<class TDesC16 const >, ...)
+	?AppendFormatL@CTextBuffer@IoUtils@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 46 NONAME ; void IoUtils::CTextBuffer::AppendFormatL(class TRefByValue<class TDesC8 const >, ...)
+	?AppendFormatListL@CTextBuffer@IoUtils@@QAEXABVTDesC16@@AAY00PAC@Z @ 47 NONAME ; void IoUtils::CTextBuffer::AppendFormatListL(class TDesC16 const &, signed char * [1] &)
+	?AppendFormatListL@CTextBuffer@IoUtils@@QAEXABVTDesC8@@AAY00PAC@Z @ 48 NONAME ; void IoUtils::CTextBuffer::AppendFormatListL(class TDesC8 const &, signed char * [1] &)
+	?AppendHumanReadableSizeL@CTextBuffer@IoUtils@@QAEXH@Z @ 49 NONAME ; void IoUtils::CTextBuffer::AppendHumanReadableSizeL(int)
+	?AppendHumanReadableSizeL@CTextBuffer@IoUtils@@QAEXHW4TAlignment@2@@Z @ 50 NONAME ; void IoUtils::CTextBuffer::AppendHumanReadableSizeL(int, enum IoUtils::TAlignment)
+	?AppendHumanReadableSizeL@CTextBuffer@IoUtils@@QAEX_J@Z @ 51 NONAME ; void IoUtils::CTextBuffer::AppendHumanReadableSizeL(long long)
+	?AppendHumanReadableSizeL@CTextBuffer@IoUtils@@QAEX_JW4TAlignment@2@@Z @ 52 NONAME ; void IoUtils::CTextBuffer::AppendHumanReadableSizeL(long long, enum IoUtils::TAlignment)
+	?AppendIntL@RCommandArgumentList@IoUtils@@QAEXAAHABVTDesC16@@1I1@Z @ 53 NONAME ; void IoUtils::RCommandArgumentList::AppendIntL(int &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendIntL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@1I1@Z @ 54 NONAME ; void IoUtils::RCommandArgumentList::AppendIntL(class RArray<int> &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendIntL@RCommandOptionList@IoUtils@@QAEXAAHVTChar@@ABVTDesC16@@2I2@Z @ 55 NONAME ; void IoUtils::RCommandOptionList::AppendIntL(int &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendIntL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@H@@VTChar@@ABVTDesC16@@2I2@Z @ 56 NONAME ; void IoUtils::RCommandOptionList::AppendIntL(class RArray<int> &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendL@CTextBuffer@IoUtils@@QAEXABVTChar@@@Z @ 57 NONAME ; void IoUtils::CTextBuffer::AppendL(class TChar const &)
+	?AppendL@CTextBuffer@IoUtils@@QAEXABVTDesC16@@@Z @ 58 NONAME ; void IoUtils::CTextBuffer::AppendL(class TDesC16 const &)
+	?AppendL@CTextBuffer@IoUtils@@QAEXABVTDesC8@@@Z @ 59 NONAME ; void IoUtils::CTextBuffer::AppendL(class TDesC8 const &)
+	?AppendRealL@RCommandArgumentList@IoUtils@@QAEXAANABVTDesC16@@1I1@Z @ 60 NONAME ; void IoUtils::RCommandArgumentList::AppendRealL(double &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendRealL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@N@@ABVTDesC16@@1I1@Z @ 61 NONAME ; void IoUtils::RCommandArgumentList::AppendRealL(class RArray<double> &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendRealL@RCommandOptionList@IoUtils@@QAEXAANVTChar@@ABVTDesC16@@2I2@Z @ 62 NONAME ; void IoUtils::RCommandOptionList::AppendRealL(double &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendRealL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@N@@VTChar@@ABVTDesC16@@2I2@Z @ 63 NONAME ; void IoUtils::RCommandOptionList::AppendRealL(class RArray<double> &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendStringL@RCommandArgumentList@IoUtils@@QAEXAAPAVHBufC16@@ABVTDesC16@@1I1@Z @ 64 NONAME ; void IoUtils::RCommandArgumentList::AppendStringL(class HBufC16 * &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendStringL@RCommandArgumentList@IoUtils@@QAEXAAV?$RPointerArray@VHBufC16@@@@ABVTDesC16@@1I1@Z @ 65 NONAME ; void IoUtils::RCommandArgumentList::AppendStringL(class RPointerArray<class HBufC16> &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendStringL@RCommandOptionList@IoUtils@@QAEXAAPAVHBufC16@@VTChar@@ABVTDesC16@@2I2@Z @ 66 NONAME ; void IoUtils::RCommandOptionList::AppendStringL(class HBufC16 * &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendStringL@RCommandOptionList@IoUtils@@QAEXAAV?$RPointerArray@VHBufC16@@@@VTChar@@ABVTDesC16@@2I2@Z @ 67 NONAME ; void IoUtils::RCommandOptionList::AppendStringL(class RPointerArray<class HBufC16> &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendUintL@RCommandArgumentList@IoUtils@@QAEXAAIABVTDesC16@@1I1@Z @ 68 NONAME ; void IoUtils::RCommandArgumentList::AppendUintL(unsigned int &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendUintL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@I@@ABVTDesC16@@1I1@Z @ 69 NONAME ; void IoUtils::RCommandArgumentList::AppendUintL(class RArray<unsigned int> &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendUintL@RCommandOptionList@IoUtils@@QAEXAAIVTChar@@ABVTDesC16@@2I2@Z @ 70 NONAME ; void IoUtils::RCommandOptionList::AppendUintL(unsigned int &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendUintL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@I@@VTChar@@ABVTDesC16@@2I2@Z @ 71 NONAME ; void IoUtils::RCommandOptionList::AppendUintL(class RArray<unsigned int> &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendValuesL@TEnum@IoUtils@@QBEXAAVCTextBuffer@2@@Z @ 72 NONAME ; void IoUtils::TEnum::AppendValuesL(class IoUtils::CTextBuffer &) const
+	?ArgumentsL@CBranchCommandBase@IoUtils@@EAEXAAVRCommandArgumentList@2@@Z @ 73 NONAME ; void IoUtils::CBranchCommandBase::ArgumentsL(class IoUtils::RCommandArgumentList &)
+	?ArgumentsL@CClientBase@IoUtils@@EAEXAAVRCommandArgumentList@2@@Z @ 74 NONAME ; void IoUtils::CClientBase::ArgumentsL(class IoUtils::RCommandArgumentList &)
+	?ArgumentsL@CCommandBase@IoUtils@@MAEXAAVRCommandArgumentList@2@@Z @ 75 NONAME ; void IoUtils::CCommandBase::ArgumentsL(class IoUtils::RCommandArgumentList &)
+	?AsString@RCommandArgumentList@IoUtils@@QBE?AVTPtrC16@@PAX@Z @ 76 NONAME ; class TPtrC16 IoUtils::RCommandArgumentList::AsString(void *) const
+	?AsString@RCommandOptionList@IoUtils@@QBE?AVTPtrC16@@PAX@Z @ 77 NONAME ; class TPtrC16 IoUtils::RCommandOptionList::AsString(void *) const
+	?Attach@RIoEndPoint@@QAEHAAVRIoReadHandle@@W4TReadMode@1@@Z @ 78 NONAME ; int RIoEndPoint::Attach(class RIoReadHandle &, enum RIoEndPoint::TReadMode)
+	?Attach@RIoEndPoint@@QAEHAAVRIoWriteHandle@@@Z @ 79 NONAME ; int RIoEndPoint::Attach(class RIoWriteHandle &)
+	?AttachL@RIoEndPoint@@QAEXAAVRIoReadHandle@@W4TReadMode@1@@Z @ 80 NONAME ; void RIoEndPoint::AttachL(class RIoReadHandle &, enum RIoEndPoint::TReadMode)
+	?AttachL@RIoEndPoint@@QAEXAAVRIoWriteHandle@@@Z @ 81 NONAME ; void RIoEndPoint::AttachL(class RIoWriteHandle &)
+	?AttachReader@RIoPersistentConsole@@QAEHAAVRIoEndPoint@@W4TCloseBehaviour@1@@Z @ 82 NONAME ; int RIoPersistentConsole::AttachReader(class RIoEndPoint &, enum RIoPersistentConsole::TCloseBehaviour)
+	?AttachReaderL@RIoPersistentConsole@@QAEXAAVRIoEndPoint@@W4TCloseBehaviour@1@@Z @ 83 NONAME ; void RIoPersistentConsole::AttachReaderL(class RIoEndPoint &, enum RIoPersistentConsole::TCloseBehaviour)
+	?AttachWriter@RIoPersistentConsole@@QAEHAAVRIoEndPoint@@W4TCloseBehaviour@1@@Z @ 84 NONAME ; int RIoPersistentConsole::AttachWriter(class RIoEndPoint &, enum RIoPersistentConsole::TCloseBehaviour)
+	?AttachWriterL@RIoPersistentConsole@@QAEXAAVRIoEndPoint@@W4TCloseBehaviour@1@@Z @ 85 NONAME ; void RIoPersistentConsole::AttachWriterL(class RIoEndPoint &, enum RIoPersistentConsole::TCloseBehaviour)
+	?AttachedToConsole@RIoReadWriteHandle@@QBEHXZ @ 86 NONAME ; int RIoReadWriteHandle::AttachedToConsole(void) const
+	?AttachedToConsoleL@RIoReadWriteHandle@@QBEHXZ @ 87 NONAME ; int RIoReadWriteHandle::AttachedToConsoleL(void) const
+	?BaseConstructL@CCommandBase@IoUtils@@MAEXXZ @ 88 NONAME ; void IoUtils::CCommandBase::BaseConstructL(void)
+	?BaseConstructL@CServerBase@IoUtils@@MAEXXZ @ 89 NONAME ; void IoUtils::CServerBase::BaseConstructL(void)
+	?CancelCaptureAllKeys@RIoConsoleReadHandle@@QAEHXZ @ 90 NONAME ; int RIoConsoleReadHandle::CancelCaptureAllKeys(void)
+	?CancelCaptureKey@RIoConsoleReadHandle@@QAEHIII@Z @ 91 NONAME ; int RIoConsoleReadHandle::CancelCaptureKey(unsigned int, unsigned int, unsigned int)
+	?CancelNotifyChange@RIoReadHandle@@QAEXXZ @ 92 NONAME ; void RIoReadHandle::CancelNotifyChange(void)
+	?CancelNotifyReaderDetach@RIoPersistentConsole@@QAEXAAVTRequestStatus@@@Z @ 93 NONAME ; void RIoPersistentConsole::CancelNotifyReaderDetach(class TRequestStatus &)
+	?CancelNotifyWriterDetach@RIoPersistentConsole@@QAEXAAVTRequestStatus@@@Z @ 94 NONAME ; void RIoPersistentConsole::CancelNotifyWriterDetach(class TRequestStatus &)
+	?CaptureAllKeys@RIoConsoleReadHandle@@QAEHXZ @ 95 NONAME ; int RIoConsoleReadHandle::CaptureAllKeys(void)
+	?CaptureAllKeysL@RIoConsoleReadHandle@@QAEXXZ @ 96 NONAME ; void RIoConsoleReadHandle::CaptureAllKeysL(void)
+	?CaptureKey@RIoConsoleReadHandle@@QAEHIII@Z @ 97 NONAME ; int RIoConsoleReadHandle::CaptureKey(unsigned int, unsigned int, unsigned int)
+	?CaptureKeyL@RIoConsoleReadHandle@@QAEXIII@Z @ 98 NONAME ; void RIoConsoleReadHandle::CaptureKeyL(unsigned int, unsigned int, unsigned int)
+	?CheckNewConsoleLine@CServerBase@IoUtils@@IAEXXZ @ 99 NONAME ; void IoUtils::CServerBase::CheckNewConsoleLine(void)
+	?ClearScreen@RIoConsoleWriteHandle@@QAEHXZ @ 100 NONAME ; int RIoConsoleWriteHandle::ClearScreen(void)
+	?ClearScreenL@RIoConsoleWriteHandle@@QAEXXZ @ 101 NONAME ; void RIoConsoleWriteHandle::ClearScreenL(void)
+	?ClearToEndOfLine@RIoConsoleWriteHandle@@QAEHXZ @ 102 NONAME ; int RIoConsoleWriteHandle::ClearToEndOfLine(void)
+	?ClearToEndOfLineL@RIoConsoleWriteHandle@@QAEXXZ @ 103 NONAME ; void RIoConsoleWriteHandle::ClearToEndOfLineL(void)
+	?Close@RChildProcess@IoUtils@@QAEXXZ @ 104 NONAME ; void IoUtils::RChildProcess::Close(void)
+	?Close@RIoHandle@@QAEXXZ @ 105 NONAME ; void RIoHandle::Close(void)
+	?Collapse@CTextBuffer@IoUtils@@QAE?AVTPtrC8@@XZ @ 106 NONAME ; class TPtrC8 IoUtils::CTextBuffer::Collapse(void)
+	?ColumnizeL@CTextFormatter@IoUtils@@QAEXHHABV?$TArray@VTPtrC16@@@@@Z @ 107 NONAME ; void IoUtils::CTextFormatter::ColumnizeL(int, int, class TArray<class TPtrC16> const &)
+	?ColumnizeL@CTextFormatter@IoUtils@@QAEXHHABVTDesC16@@@Z @ 108 NONAME ; void IoUtils::CTextFormatter::ColumnizeL(int, int, class TDesC16 const &)
+	?Complete@CCommandBase@IoUtils@@QAAXHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 109 NONAME ; void IoUtils::CCommandBase::Complete(int, class TRefByValue<class TDesC16 const >, ...)
+	?Complete@CCommandBase@IoUtils@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 110 NONAME ; void IoUtils::CCommandBase::Complete(class TRefByValue<class TDesC16 const >, ...)
+	?Complete@CCommandBase@IoUtils@@QAEXH@Z @ 111 NONAME ; void IoUtils::CCommandBase::Complete(int)
+	?Complete@CCommandBase@IoUtils@@QAEXXZ @ 112 NONAME ; void IoUtils::CCommandBase::Complete(void)
+	?CompleteAsync@CCommandBase@IoUtils@@QAAXHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 113 NONAME ; void IoUtils::CCommandBase::CompleteAsync(int, class TRefByValue<class TDesC16 const >, ...)
+	?CompleteAsync@CCommandBase@IoUtils@@QAEXH@Z @ 114 NONAME ; void IoUtils::CCommandBase::CompleteAsync(int)
+	?CompletionReason@CCommandBase@IoUtils@@QBEHXZ @ 115 NONAME ; int IoUtils::CCommandBase::CompletionReason(void) const
+	?ConfigureSubCommand@CBranchCommandBase@IoUtils@@MAEXAAVCServerCommandBase@2@@Z @ 116 NONAME ; void IoUtils::CBranchCommandBase::ConfigureSubCommand(class IoUtils::CServerCommandBase &)
+	?Connect@RIoSession@@QAEHXZ @ 117 NONAME ; int RIoSession::Connect(void)
+	?ConnectL@RIoSession@@QAEXXZ @ 118 NONAME ; void RIoSession::ConnectL(void)
+	?ConsoleImplementation@CCommandBase@IoUtils@@QAEPBVTDesC16@@XZ @ 119 NONAME ; class TDesC16 const * IoUtils::CCommandBase::ConsoleImplementation(void)
+	?CopyL@CEnvironment@IoUtils@@QAEXABV12@@Z @ 120 NONAME ABSENT ; void IoUtils::CEnvironment::CopyL(class IoUtils::CEnvironment const &)
+	?Count@CEnvironment@IoUtils@@QBEHXZ @ 121 NONAME ; int IoUtils::CEnvironment::Count(void) const
+	?Create@RIoConsole@@QAEHAAVRIoSession@@ABVTDesC16@@1ABVTSize@@I@Z @ 122 NONAME ; int RIoConsole::Create(class RIoSession &, class TDesC16 const &, class TDesC16 const &, class TSize const &, unsigned int)
+	?Create@RIoConsole@@QAEHAAVRIoSession@@ABVTDesC16@@AAV1@1ABVTSize@@I@Z @ 123 NONAME ; int RIoConsole::Create(class RIoSession &, class TDesC16 const &, class RIoConsole &, class TDesC16 const &, class TSize const &, unsigned int)
+	?Create@RIoConsole@@QAEHAAVRIoSession@@ABVTDesC16@@ABVTSize@@I@Z @ 124 NONAME ; int RIoConsole::Create(class RIoSession &, class TDesC16 const &, class TSize const &, unsigned int)
+	?Create@RIoFile@@QAEHAAVRIoSession@@ABVTDesC16@@W4TMode@1@@Z @ 125 NONAME ; int RIoFile::Create(class RIoSession &, class TDesC16 const &, enum RIoFile::TMode)
+	?Create@RIoNull@@QAEHAAVRIoSession@@@Z @ 126 NONAME ; int RIoNull::Create(class RIoSession &)
+	?Create@RIoPersistentConsole@@QAEHAAVRIoSession@@ABVTDesC16@@1@Z @ 127 NONAME ; int RIoPersistentConsole::Create(class RIoSession &, class TDesC16 const &, class TDesC16 const &)
+	?Create@RIoPipe@@QAEHAAVRIoSession@@@Z @ 128 NONAME ; int RIoPipe::Create(class RIoSession &)
+	?Create@RIoReadHandle@@QAEHAAVRIoSession@@@Z @ 129 NONAME ; int RIoReadHandle::Create(class RIoSession &)
+	?Create@RIoWriteHandle@@QAEHAAVRIoSession@@@Z @ 130 NONAME ; int RIoWriteHandle::Create(class RIoSession &)
+	?CreateImplementationLC@CServerCommandConstructor@IoUtils@@QBEPAVCServerCommandBase@2@XZ @ 131 NONAME ; class IoUtils::CServerCommandBase * IoUtils::CServerCommandConstructor::CreateImplementationLC(void) const
+	?CreateL@RChildProcess@IoUtils@@QAEXABVTDesC16@@0AAVRIoSession@@AAVRIoConsole@@PBVCEnvironment@2@@Z @ 132 NONAME ; void IoUtils::RChildProcess::CreateL(class TDesC16 const &, class TDesC16 const &, class RIoSession &, class RIoConsole &, class IoUtils::CEnvironment const *)
+	?CreateL@RChildProcess@IoUtils@@QAEXABVTDesC16@@0AAVRIoSession@@AAVRIoReadHandle@@AAVRIoWriteHandle@@3@Z @ 133 NONAME ; void IoUtils::RChildProcess::CreateL(class TDesC16 const &, class TDesC16 const &, class RIoSession &, class RIoReadHandle &, class RIoWriteHandle &, class RIoWriteHandle &)
+	?CreateL@RChildProcess@IoUtils@@QAEXABVTDesC16@@0AAVRIoSession@@AAVRIoReadHandle@@AAVRIoWriteHandle@@3ABVCEnvironment@2@@Z @ 134 NONAME ; void IoUtils::RChildProcess::CreateL(class TDesC16 const &, class TDesC16 const &, class RIoSession &, class RIoReadHandle &, class RIoWriteHandle &, class RIoWriteHandle &, class IoUtils::CEnvironment const &)
+	?CreateL@RIoConsole@@QAEXAAVRIoSession@@ABVTDesC16@@1ABVTSize@@I@Z @ 135 NONAME ; void RIoConsole::CreateL(class RIoSession &, class TDesC16 const &, class TDesC16 const &, class TSize const &, unsigned int)
+	?CreateL@RIoConsole@@QAEXAAVRIoSession@@ABVTDesC16@@AAV1@1ABVTSize@@I@Z @ 136 NONAME ; void RIoConsole::CreateL(class RIoSession &, class TDesC16 const &, class RIoConsole &, class TDesC16 const &, class TSize const &, unsigned int)
+	?CreateL@RIoConsole@@QAEXAAVRIoSession@@ABVTDesC16@@ABVTSize@@I@Z @ 137 NONAME ; void RIoConsole::CreateL(class RIoSession &, class TDesC16 const &, class TSize const &, unsigned int)
+	?CreateL@RIoFile@@QAEXAAVRIoSession@@ABVTDesC16@@W4TMode@1@@Z @ 138 NONAME ; void RIoFile::CreateL(class RIoSession &, class TDesC16 const &, enum RIoFile::TMode)
+	?CreateL@RIoNull@@QAEXAAVRIoSession@@@Z @ 139 NONAME ; void RIoNull::CreateL(class RIoSession &)
+	?CreateL@RIoPersistentConsole@@QAEXAAVRIoSession@@ABVTDesC16@@1@Z @ 140 NONAME ; void RIoPersistentConsole::CreateL(class RIoSession &, class TDesC16 const &, class TDesC16 const &)
+	?CreateL@RIoPipe@@QAEXAAVRIoSession@@@Z @ 141 NONAME ; void RIoPipe::CreateL(class RIoSession &)
+	?CreateL@RIoReadHandle@@QAEXAAVRIoSession@@@Z @ 142 NONAME ; void RIoReadHandle::CreateL(class RIoSession &)
+	?CreateL@RIoWriteHandle@@QAEXAAVRIoSession@@@Z @ 143 NONAME ; void RIoWriteHandle::CreateL(class RIoSession &)
+	?Delete@CTextBuffer@IoUtils@@QAEXHH@Z @ 144 NONAME ; void IoUtils::CTextBuffer::Delete(int, int)
+	?Descriptor@CTextBuffer@IoUtils@@QBEABVTDesC16@@HH@Z @ 145 NONAME ; class TDesC16 const & IoUtils::CTextBuffer::Descriptor(int, int) const
+	?Descriptor@CTextBuffer@IoUtils@@QBEABVTDesC16@@XZ @ 146 NONAME ; class TDesC16 const & IoUtils::CTextBuffer::Descriptor(void) const
+	?Detach@RChildProcess@IoUtils@@QAEXXZ @ 147 NONAME ; void IoUtils::RChildProcess::Detach(void)
+	?DetachReader@RIoPersistentConsole@@QAEXXZ @ 148 NONAME ; void RIoPersistentConsole::DetachReader(void)
+	?DetachWriter@RIoPersistentConsole@@QAEXXZ @ 149 NONAME ; void RIoPersistentConsole::DetachWriter(void)
+	?DisplayHelp@CCommandBase@IoUtils@@QAEXXZ @ 150 NONAME ; void IoUtils::CCommandBase::DisplayHelp(void)
+	?DoCancel@CCommandBase@IoUtils@@MAEXXZ @ 151 NONAME ; void IoUtils::CCommandBase::DoCancel(void)
+	?DoRunL@CBranchCommandBase@IoUtils@@EAEXXZ @ 152 NONAME ; void IoUtils::CBranchCommandBase::DoRunL(void)
+	?DoRunL@CClientBase@IoUtils@@EAEXXZ @ 153 NONAME ; void IoUtils::CClientBase::DoRunL(void)
+	?DoRunL@CServerBase@IoUtils@@MAEXXZ @ 154 NONAME ; void IoUtils::CServerBase::DoRunL(void)
+	?Drive@TFileName2@IoUtils@@QBE?AVTPtrC16@@XZ @ 155 NONAME ; class TPtrC16 IoUtils::TFileName2::Drive(void) const
+	?DriveAndPath@TFileName2@IoUtils@@QBE?AVTPtrC16@@XZ @ 156 NONAME ; class TPtrC16 IoUtils::TFileName2::DriveAndPath(void) const
+	?Duplicate@RIoReadHandle@@QAEHAAV1@@Z @ 157 NONAME ; int RIoReadHandle::Duplicate(class RIoReadHandle &)
+	?Duplicate@RIoWriteHandle@@QAEHAAV1@@Z @ 158 NONAME ; int RIoWriteHandle::Duplicate(class RIoWriteHandle &)
+	?DuplicateL@RIoReadHandle@@QAEXAAV1@@Z @ 159 NONAME ; void RIoReadHandle::DuplicateL(class RIoReadHandle &)
+	?DuplicateL@RIoWriteHandle@@QAEXAAV1@@Z @ 160 NONAME ; void RIoWriteHandle::DuplicateL(class RIoWriteHandle &)
+	?Env@CCommandBase@IoUtils@@QAEAAVCEnvironment@2@XZ @ 161 NONAME ; class IoUtils::CEnvironment & IoUtils::CCommandBase::Env(void)
+	?Env@CCommandBase@IoUtils@@QBEABVCEnvironment@2@XZ @ 162 NONAME ; class IoUtils::CEnvironment const & IoUtils::CCommandBase::Env(void) const
+	?Equals@RIoHandle@@QBEHABV1@@Z @ 163 NONAME ; int RIoHandle::Equals(class RIoHandle const &) const
+	?EqualsL@RIoHandle@@QBEHABV1@@Z @ 164 NONAME ; int RIoHandle::EqualsL(class RIoHandle const &) const
+	?Error@Stringify@IoUtils@@SAPBVTDesC16@@H@Z @ 165 NONAME ; class TDesC16 const * IoUtils::Stringify::Error(int)
+	?EscapeChar@CEnvironment@IoUtils@@QBE?AVTChar@@XZ @ 166 NONAME ; class TChar IoUtils::CEnvironment::EscapeChar(void) const
+	?EscapeLC@Stringify@IoUtils@@SAPAVHBufC16@@ABVTDesC16@@ABVTChar@@@Z @ 167 NONAME ; class HBufC16 * IoUtils::Stringify::EscapeLC(class TDesC16 const &, class TChar const &)
+	?EscapeLC@Stringify@IoUtils@@SAPAVHBufC8@@ABVTDesC8@@ABVTChar@@@Z @ 168 NONAME ; class HBufC8 * IoUtils::Stringify::EscapeLC(class TDesC8 const &, class TChar const &)
+	?Exists@TFileName2@IoUtils@@QBEHAAVRFs@@@Z @ 169 NONAME ; int IoUtils::TFileName2::Exists(class RFs &) const
+	?Exit@CServerBase@IoUtils@@QAEXH@Z @ 170 NONAME ; void IoUtils::CServerBase::Exit(int)
+	?Ext@TFileName2@IoUtils@@QBE?AVTPtrC16@@XZ @ 171 NONAME ; class TPtrC16 IoUtils::TFileName2::Ext(void) const
+	?Extension_@CCommandBase@IoUtils@@MAEHIAAPAXPAX@Z @ 172 NONAME ; int IoUtils::CCommandBase::Extension_(unsigned int, void * &, void *)
+	?ExternalizeL@CEnvironment@IoUtils@@QBEXAAVTDes8@@@Z @ 173 NONAME ABSENT ; void IoUtils::CEnvironment::ExternalizeL(class TDes8 &) const
+	?ExternalizedSize@CEnvironment@IoUtils@@QBEHXZ @ 174 NONAME ABSENT ; int IoUtils::CEnvironment::ExternalizedSize(void) const
+	?Factory@CServerBase@IoUtils@@IAEAAVCServerCommandFactory@2@XZ @ 175 NONAME ; class IoUtils::CServerCommandFactory & IoUtils::CServerBase::Factory(void)
+	?Factory@CServerCommandBase@IoUtils@@IAEAAVCServerCommandFactory@2@XZ @ 176 NONAME ; class IoUtils::CServerCommandFactory & IoUtils::CServerCommandBase::Factory(void)
+	?FindFile@TFileName2@IoUtils@@QAEHAAVRFs@@@Z @ 177 NONAME ; int IoUtils::TFileName2::FindFile(class RFs &)
+	?FindFileL@TFileName2@IoUtils@@QAEXAAVRFs@@@Z @ 178 NONAME ; void IoUtils::TFileName2::FindFileL(class RFs &)
+	?FindFirstHandle@RIoSession@@QAEHW4TType@RIoHandle@@ABVTDesC16@@AAHAAV?$TBuf@$0IA@@@@Z @ 179 NONAME ; int RIoSession::FindFirstHandle(enum RIoHandle::TType, class TDesC16 const &, int &, class TBuf<128> &)
+	?FindNextHandle@RIoSession@@QAEHAAHAAV?$TBuf@$0IA@@@@Z @ 180 NONAME ; int RIoSession::FindNextHandle(int &, class TBuf<128> &)
+	?Flags@CCommandBase@IoUtils@@QBEIXZ @ 181 NONAME ; unsigned int IoUtils::CCommandBase::Flags(void) const
+	?Fs@CCommandBase@IoUtils@@QAEAAVRFs@@XZ @ 182 NONAME ; class RFs & IoUtils::CCommandBase::Fs(void)
+	?Fs@CCommandBase@IoUtils@@QBEABVRFs@@XZ @ 183 NONAME ; class RFs const & IoUtils::CCommandBase::Fs(void) const
+	?FsL@CCommandBase@IoUtils@@QAEAAVRFs@@XZ @ 184 NONAME ; class RFs & IoUtils::CCommandBase::FsL(void)
+	?FsL@CCommandBase@IoUtils@@QBEABVRFs@@XZ @ 185 NONAME ; class RFs const & IoUtils::CCommandBase::FsL(void) const
+	?GetAsDes@CEnvironment@IoUtils@@QBEABVTDesC16@@ABV3@@Z @ 186 NONAME ; class TDesC16 const & IoUtils::CEnvironment::GetAsDes(class TDesC16 const &) const
+	?GetAsDesL@CEnvironment@IoUtils@@QBEABVTDesC16@@ABV3@@Z @ 187 NONAME ; class TDesC16 const & IoUtils::CEnvironment::GetAsDesL(class TDesC16 const &) const
+	?GetAsInt@CEnvironment@IoUtils@@QBEHABVTDesC16@@@Z @ 188 NONAME ; int IoUtils::CEnvironment::GetAsInt(class TDesC16 const &) const
+	?GetAsIntL@CEnvironment@IoUtils@@QBEHABVTDesC16@@@Z @ 189 NONAME ; int IoUtils::CEnvironment::GetAsIntL(class TDesC16 const &) const
+	?GetAttachedReaderAndWriterNames@RIoPersistentConsole@@QAEHAAV?$TBuf@$0IA@@@0@Z @ 190 NONAME ; int RIoPersistentConsole::GetAttachedReaderAndWriterNames(class TBuf<128> &, class TBuf<128> &)
+	?GetAttachedReaderAndWriterNamesL@RIoPersistentConsole@@QAEXAAV?$TBuf@$0IA@@@0@Z @ 191 NONAME ; void RIoPersistentConsole::GetAttachedReaderAndWriterNamesL(class TBuf<128> &, class TBuf<128> &)
+	?GetConsoleBaseL@CCommandBase@IoUtils@@QAEPAVCConsoleBase@@XZ @ 192 NONAME ; class CConsoleBase * IoUtils::CCommandBase::GetConsoleBaseL(void)
+	?GetCreator@RIoPersistentConsole@@QAEHAAVTThreadId@@@Z @ 193 NONAME ; int RIoPersistentConsole::GetCreator(class TThreadId &)
+	?GetCreatorL@RIoPersistentConsole@@QAE?AVTThreadId@@XZ @ 194 NONAME ; class TThreadId RIoPersistentConsole::GetCreatorL(void)
+	?GetCursorPos@RIoConsoleWriteHandle@@QBEHAAVTPoint@@@Z @ 195 NONAME ; int RIoConsoleWriteHandle::GetCursorPos(class TPoint &) const
+	?GetCursorPosL@RIoConsoleWriteHandle@@QBE?AVTPoint@@XZ @ 196 NONAME ; class TPoint RIoConsoleWriteHandle::GetCursorPosL(void) const
+	?GetHelpTextL@CCommandBase@IoUtils@@UAEPBVCTextBuffer@2@XZ @ 197 NONAME ; class IoUtils::CTextBuffer const * IoUtils::CCommandBase::GetHelpTextL(void)
+	?GetScreenSize@RIoConsoleWriteHandle@@QBEHAAVTSize@@@Z @ 198 NONAME ; int RIoConsoleWriteHandle::GetScreenSize(class TSize &) const
+	?GetScreenSizeL@RIoConsoleWriteHandle@@QBE?AVTSize@@XZ @ 199 NONAME ; class TSize RIoConsoleWriteHandle::GetScreenSizeL(void) const
+	?GetString@TEnum@IoUtils@@QBE?BVTPtrC16@@H@Z @ 200 NONAME ; class TPtrC16 const IoUtils::TEnum::GetString(int) const
+	?GetSubCommandL@CServerCommandFactory@IoUtils@@QBEABVCServerCommandConstructor@2@ABVTDesC16@@@Z @ 201 NONAME ; class IoUtils::CServerCommandConstructor const & IoUtils::CServerCommandFactory::GetSubCommandL(class TDesC16 const &) const
+	?HandleBackgroundSubCommand@CBranchCommandBase@IoUtils@@MAEXAAVCServerCommandBase@2@@Z @ 202 NONAME ; void IoUtils::CBranchCommandBase::HandleBackgroundSubCommand(class IoUtils::CServerCommandBase &)
+	?HandleLeave@CClientBase@IoUtils@@EAEXH@Z @ 203 NONAME ; void IoUtils::CClientBase::HandleLeave(int)
+	?HandleLeave@CCommandBase@IoUtils@@UAEXH@Z @ 204 NONAME ; void IoUtils::CCommandBase::HandleLeave(int)
+	?HandleSubCommandComplete@CBranchCommandBase@IoUtils@@MAEXAAVCServerCommandBase@2@@Z @ 205 NONAME ; void IoUtils::CBranchCommandBase::HandleSubCommandComplete(class IoUtils::CServerCommandBase &)
+	?HasDriveLetter@TFileName2@IoUtils@@QBEHXZ @ 206 NONAME ; int IoUtils::TFileName2::HasDriveLetter(void) const
+	?HasLeadingSlash@TFileName2@IoUtils@@QBEHXZ @ 207 NONAME ; int IoUtils::TFileName2::HasLeadingSlash(void) const
+	?HasTrailingSlash@TFileName2@IoUtils@@QBEHXZ @ 208 NONAME ; int IoUtils::TFileName2::HasTrailingSlash(void) const
+	?HaveStatic@CCommandBase@IoUtils@@SAHXZ @ 209 NONAME ; int IoUtils::CCommandBase::HaveStatic(void)
+	?Id@CServerCommandBase@IoUtils@@QBEABVTServerCommandId@2@XZ @ 210 NONAME ; class IoUtils::TServerCommandId const & IoUtils::CServerCommandBase::Id(void) const
+	?Implementation@RIoConsole@@QBEHAAVTDes16@@@Z @ 211 NONAME ; int RIoConsole::Implementation(class TDes16 &) const
+	?ImplementationL@RIoConsole@@QBEXAAVTDes16@@@Z @ 212 NONAME ; void RIoConsole::ImplementationL(class TDes16 &) const
+	?InternalizeL@CEnvironment@IoUtils@@QAEXABVTDesC8@@@Z @ 213 NONAME ; void IoUtils::CEnvironment::InternalizeL(class TDesC8 const &)
+	?IoSession@CCommandBase@IoUtils@@QAEAAVRIoSession@@XZ @ 214 NONAME ; class RIoSession & IoUtils::CCommandBase::IoSession(void)
+	?IsAbsolute@TFileName2@IoUtils@@QBEHXZ @ 215 NONAME ; int IoUtils::TFileName2::IsAbsolute(void) const
+	?IsArchiveL@TFileName2@IoUtils@@QBEHAAVRFs@@@Z @ 216 NONAME ; int IoUtils::TFileName2::IsArchiveL(class RFs &) const
+	?IsComplete@CCommandBase@IoUtils@@QBEHXZ @ 217 NONAME ; int IoUtils::CCommandBase::IsComplete(void) const
+	?IsDefined@CEnvironment@IoUtils@@QBEHABVTDesC16@@@Z @ 218 NONAME ; int IoUtils::CEnvironment::IsDefined(class TDesC16 const &) const
+	?IsDes@CEnvironment@IoUtils@@QBEHABVTDesC16@@@Z @ 219 NONAME ; int IoUtils::CEnvironment::IsDes(class TDesC16 const &) const
+	?IsDirL@TFileName2@IoUtils@@QBEHAAVRFs@@@Z @ 220 NONAME ; int IoUtils::TFileName2::IsDirL(class RFs &) const
+	?IsDriveLetter@TFileName2@IoUtils@@QBEHXZ @ 221 NONAME ; int IoUtils::TFileName2::IsDriveLetter(void) const
+	?IsDriveRoot@TFileName2@IoUtils@@QBEHXZ @ 222 NONAME ; int IoUtils::TFileName2::IsDriveRoot(void) const
+	?IsFactory@CServerCommandConstructor@IoUtils@@UBEHXZ @ 223 NONAME ; int IoUtils::CServerCommandConstructor::IsFactory(void) const
+	?IsFactory@CServerCommandFactory@IoUtils@@UBEHXZ @ 224 NONAME ; int IoUtils::CServerCommandFactory::IsFactory(void) const
+	?IsForeground@RIoReadHandle@@QBEHXZ @ 225 NONAME ; int RIoReadHandle::IsForeground(void) const
+	?IsForegroundL@RIoReadHandle@@QBEHXZ @ 226 NONAME ; int RIoReadHandle::IsForegroundL(void) const
+	?IsHiddenL@TFileName2@IoUtils@@QBEHAAVRFs@@@Z @ 227 NONAME ; int IoUtils::TFileName2::IsHiddenL(class RFs &) const
+	?IsInt@CEnvironment@IoUtils@@QBEHABVTDesC16@@@Z @ 228 NONAME ; int IoUtils::CEnvironment::IsInt(class TDesC16 const &) const
+	?IsPresent@RCommandArgumentList@IoUtils@@QBEHH@Z @ 229 NONAME ; int IoUtils::RCommandArgumentList::IsPresent(int) const
+	?IsPresent@RCommandOptionList@IoUtils@@QBEHPAX@Z @ 230 NONAME ; int IoUtils::RCommandOptionList::IsPresent(void *) const
+	?IsReadOnlyL@TFileName2@IoUtils@@QBEHAAVRFs@@@Z @ 231 NONAME ; int IoUtils::TFileName2::IsReadOnlyL(class RFs &) const
+	?IsSystemL@TFileName2@IoUtils@@QBEHAAVRFs@@@Z @ 232 NONAME ; int IoUtils::TFileName2::IsSystemL(class RFs &) const
+	?IsType@RIoHandle@@QBEHW4TType@1@@Z @ 233 NONAME ; int RIoHandle::IsType(enum RIoHandle::TType) const
+	?IsTypeL@RIoHandle@@QBEHW4TType@1@@Z @ 234 NONAME ; int RIoHandle::IsTypeL(enum RIoHandle::TType) const
+	?IsWild@TFileName2@IoUtils@@QBEHXZ @ 235 NONAME ; int IoUtils::TFileName2::IsWild(void) const
+	?Key@CEnvironment@IoUtils@@QBEABVTDesC16@@H@Z @ 236 NONAME ABSENT ; class TDesC16 const & IoUtils::CEnvironment::Key(int) const
+	?KeyCode@RIoConsoleReadHandle@@QBEIXZ @ 237 NONAME ; unsigned int RIoConsoleReadHandle::KeyCode(void) const
+	?KeyModifiers@RIoConsoleReadHandle@@QBEIXZ @ 238 NONAME ; unsigned int RIoConsoleReadHandle::KeyModifiers(void) const
+	?LeaveIfFileExists@CCommandBase@IoUtils@@QAEXABVTDesC16@@@Z @ 239 NONAME ; void IoUtils::CCommandBase::LeaveIfFileExists(class TDesC16 const &)
+	?LeaveIfFileNotFound@CCommandBase@IoUtils@@QAEXABVTDesC16@@@Z @ 240 NONAME ; void IoUtils::CCommandBase::LeaveIfFileNotFound(class TDesC16 const &)
+	?Length@CTextBuffer@IoUtils@@QBEHXZ @ 241 NONAME ; int IoUtils::CTextBuffer::Length(void) const
+	?LeoHandleLine@CServerBase@IoUtils@@EAEXABVTDesC16@@@Z @ 242 NONAME ; void IoUtils::CServerBase::LeoHandleLine(class TDesC16 const &)
+	?ListCommandsL@CServerCommandFactory@IoUtils@@QBEXAAV?$RArray@VTPtrC16@@@@@Z @ 243 NONAME ; void IoUtils::CServerCommandFactory::ListCommandsL(class RArray<class TPtrC16> &) const
+	?MakeAbsoluteL@TFileName2@IoUtils@@QAEXAAVRFs@@@Z @ 244 NONAME ; void IoUtils::TFileName2::MakeAbsoluteL(class RFs &)
+	?MakeAbsoluteL@TFileName2@IoUtils@@QAEXABV12@@Z @ 245 NONAME ; void IoUtils::TFileName2::MakeAbsoluteL(class IoUtils::TFileName2 const &)
+	?Name@CServerCommandConstructor@IoUtils@@QBEABVTPtrC16@@XZ @ 246 NONAME ; class TPtrC16 const & IoUtils::CServerCommandConstructor::Name(void) const
+	?Name@TFileName2@IoUtils@@QBE?AVTPtrC16@@XZ @ 247 NONAME ; class TPtrC16 IoUtils::TFileName2::Name(void) const
+	?NameAndExt@TFileName2@IoUtils@@QBE?AVTPtrC16@@XZ @ 248 NONAME ; class TPtrC16 IoUtils::TFileName2::NameAndExt(void) const
+	?NarrowLC@Stringify@IoUtils@@SAPAVHBufC8@@ABVTDesC16@@@Z @ 249 NONAME ; class HBufC8 * IoUtils::Stringify::NarrowLC(class TDesC16 const &)
+	?NewConsole@IoUtils@@YAPAVCConsoleBase@@XZ @ 250 NONAME ; class CConsoleBase * IoUtils::NewConsole(void)
+	?NewL@CEnvironment@IoUtils@@SAPAV12@ABV12@@Z @ 251 NONAME ; class IoUtils::CEnvironment * IoUtils::CEnvironment::NewL(class IoUtils::CEnvironment const &)
+	?NewL@CEnvironment@IoUtils@@SAPAV12@XZ @ 252 NONAME ; class IoUtils::CEnvironment * IoUtils::CEnvironment::NewL(void)
+	?NewL@CServerCommandFactory@IoUtils@@SAPAV12@PAVMServerCommandReporter@2@PBVCCommandInfoFile@2@@Z @ 253 NONAME ; class IoUtils::CServerCommandFactory * IoUtils::CServerCommandFactory::NewL(class IoUtils::MServerCommandReporter *, class IoUtils::CCommandInfoFile const *)
+	?NewL@CTextBuffer@IoUtils@@SAPAV12@H@Z @ 254 NONAME ; class IoUtils::CTextBuffer * IoUtils::CTextBuffer::NewL(int)
+	?NewL@CTextFormatter@IoUtils@@SAPAV12@AAVRIoConsoleWriteHandle@@@Z @ 255 NONAME ; class IoUtils::CTextFormatter * IoUtils::CTextFormatter::NewL(class RIoConsoleWriteHandle &)
+	?NewL@CTextFormatter@IoUtils@@SAPAV12@H@Z @ 256 NONAME ; class IoUtils::CTextFormatter * IoUtils::CTextFormatter::NewL(int)
+	?NewLC@CServerCommandConstructor@IoUtils@@SAPAV12@ABVTDesC16@@P6APAVCServerCommandBase@2@XZAAVCServerCommandFactory@2@PAVMServerCommandReporter@2@PBVCCommandInfoFile@2@@Z @ 257 NONAME ; class IoUtils::CServerCommandConstructor * IoUtils::CServerCommandConstructor::NewLC(class TDesC16 const &, class IoUtils::CServerCommandBase * (*)(void), class IoUtils::CServerCommandFactory &, class IoUtils::MServerCommandReporter *, class IoUtils::CCommandInfoFile const *)
+	?NewLC@CServerCommandFactory@IoUtils@@SAPAV12@ABVTDesC16@@P6APAVCServerCommandBase@2@XZPAVMServerCommandReporter@2@PBVCCommandInfoFile@2@@Z @ 258 NONAME ; class IoUtils::CServerCommandFactory * IoUtils::CServerCommandFactory::NewLC(class TDesC16 const &, class IoUtils::CServerCommandBase * (*)(void), class IoUtils::MServerCommandReporter *, class IoUtils::CCommandInfoFile const *)
+	?NewLC@CTextBuffer@IoUtils@@SAPAV12@H@Z @ 259 NONAME ; class IoUtils::CTextBuffer * IoUtils::CTextBuffer::NewLC(int)
+	?NewLC@CTextFormatter@IoUtils@@SAPAV12@AAVRIoConsoleWriteHandle@@@Z @ 260 NONAME ; class IoUtils::CTextFormatter * IoUtils::CTextFormatter::NewLC(class RIoConsoleWriteHandle &)
+	?NewLC@CTextFormatter@IoUtils@@SAPAV12@H@Z @ 261 NONAME ; class IoUtils::CTextFormatter * IoUtils::CTextFormatter::NewLC(int)
+	?NotifyChange@RIoReadHandle@@QAEXAAV?$TPckgBuf@I@@AAVTRequestStatus@@@Z @ 262 NONAME ; void RIoReadHandle::NotifyChange(class TPckgBuf<unsigned int> &, class TRequestStatus &)
+	?NotifyReaderDetach@RIoPersistentConsole@@QAEXAAVTRequestStatus@@@Z @ 263 NONAME ; void RIoPersistentConsole::NotifyReaderDetach(class TRequestStatus &)
+	?NotifyWriterDetach@RIoPersistentConsole@@QAEXAAVTRequestStatus@@@Z @ 264 NONAME ; void RIoPersistentConsole::NotifyWriterDetach(class TRequestStatus &)
+	?ObjectName@RIoHandle@@QBEHAAVTDes16@@@Z @ 265 NONAME ; int RIoHandle::ObjectName(class TDes16 &) const
+	?ObjectNameL@RIoHandle@@QBEXAAVTDes16@@@Z @ 266 NONAME ; void RIoHandle::ObjectNameL(class TDes16 &) const
+	?Open@RIoConsole@@QAEHAAVRIoSession@@AAVRIoHandle@@@Z @ 267 NONAME ; int RIoConsole::Open(class RIoSession &, class RIoHandle &)
+	?Open@RIoReadHandle@@QAEHAAVRIoSession@@@Z @ 268 NONAME ; int RIoReadHandle::Open(class RIoSession &)
+	?Open@RIoReadHandle@@QAEHAAVRIoSession@@VTThreadId@@@Z @ 269 NONAME ; int RIoReadHandle::Open(class RIoSession &, class TThreadId)
+	?Open@RIoWriteHandle@@QAEHAAVRIoSession@@@Z @ 270 NONAME ; int RIoWriteHandle::Open(class RIoSession &)
+	?Open@RIoWriteHandle@@QAEHAAVRIoSession@@VTThreadId@@@Z @ 271 NONAME ; int RIoWriteHandle::Open(class RIoSession &, class TThreadId)
+	?OpenByName@RIoPersistentConsole@@QAEHAAVRIoSession@@ABVTDesC16@@@Z @ 272 NONAME ; int RIoPersistentConsole::OpenByName(class RIoSession &, class TDesC16 const &)
+	?OpenByNameL@RIoPersistentConsole@@QAEXAAVRIoSession@@ABVTDesC16@@@Z @ 273 NONAME ; void RIoPersistentConsole::OpenByNameL(class RIoSession &, class TDesC16 const &)
+	?OpenFoundHandle@RIoHandle@@QAEHAAVRIoSession@@H@Z @ 274 NONAME ; int RIoHandle::OpenFoundHandle(class RIoSession &, int)
+	?OpenFoundHandleL@RIoHandle@@QAEXAAVRIoSession@@H@Z @ 275 NONAME ; void RIoHandle::OpenFoundHandleL(class RIoSession &, int)
+	?OpenL@RIoConsole@@QAEXAAVRIoSession@@AAVRIoHandle@@@Z @ 276 NONAME ; void RIoConsole::OpenL(class RIoSession &, class RIoHandle &)
+	?OpenL@RIoReadHandle@@QAEXAAVRIoSession@@@Z @ 277 NONAME ; void RIoReadHandle::OpenL(class RIoSession &)
+	?OpenL@RIoReadHandle@@QAEXAAVRIoSession@@VTThreadId@@@Z @ 278 NONAME ; void RIoReadHandle::OpenL(class RIoSession &, class TThreadId)
+	?OpenL@RIoWriteHandle@@QAEXAAVRIoSession@@@Z @ 279 NONAME ; void RIoWriteHandle::OpenL(class RIoSession &)
+	?OpenL@RIoWriteHandle@@QAEXAAVRIoSession@@VTThreadId@@@Z @ 280 NONAME ; void RIoWriteHandle::OpenL(class RIoSession &, class TThreadId)
+	?OptionsL@CCommandBase@IoUtils@@MAEXAAVRCommandOptionList@2@@Z @ 281 NONAME ; void IoUtils::CCommandBase::OptionsL(class IoUtils::RCommandOptionList &)
+	?Parse@TEnum@IoUtils@@QAEHABVTDesC16@@AAH@Z @ 282 NONAME ; int IoUtils::TEnum::Parse(class TDesC16 const &, int &)
+	?ParseCommandLine@CCommandBase@IoUtils@@MAEHABVTDesC16@@@Z @ 283 NONAME ; int IoUtils::CCommandBase::ParseCommandLine(class TDesC16 const &)
+	?ParseCommandLineL@CCommandBase@IoUtils@@MAEXABVTDesC16@@@Z @ 284 NONAME ; void IoUtils::CCommandBase::ParseCommandLineL(class TDesC16 const &)
+	?ParseL@TEnum@IoUtils@@QAEHABVTDesC16@@@Z @ 285 NONAME ; int IoUtils::TEnum::ParseL(class TDesC16 const &)
+	?Path@TFileName2@IoUtils@@QBE?AVTPtrC16@@XZ @ 286 NONAME ; class TPtrC16 IoUtils::TFileName2::Path(void) const
+	?PrependL@TFileName2@IoUtils@@QAEXABV12@@Z @ 287 NONAME ; void IoUtils::TFileName2::PrependL(class IoUtils::TFileName2 const &)
+	?PrintError@CCommandBase@IoUtils@@QAAXHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 288 NONAME ; void IoUtils::CCommandBase::PrintError(int, class TRefByValue<class TDesC16 const >, ...)
+	?PrintError@IoUtils@@YAXHV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 289 NONAME ; void IoUtils::PrintError(int, class TRefByValue<class TDesC16 const >, ...)
+	?PrintErrorList@CCommandBase@IoUtils@@UAEXHV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 290 NONAME ; void IoUtils::CCommandBase::PrintErrorList(int, class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?PrintErrorList@CServerBase@IoUtils@@MAEXHV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 291 NONAME ; void IoUtils::CServerBase::PrintErrorList(int, class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?PrintErrorList@CServerCommandBase@IoUtils@@EAEXHV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 292 NONAME ; void IoUtils::CServerCommandBase::PrintErrorList(int, class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?PrintList@CCommandBase@IoUtils@@UAEXV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 293 NONAME ; void IoUtils::CCommandBase::PrintList(class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?PrintList@CCommandBase@IoUtils@@UAEXV?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 294 NONAME ; void IoUtils::CCommandBase::PrintList(class TRefByValue<class TDesC8 const >, signed char * [1] &)
+	?PrintList@CServerBase@IoUtils@@MAEXV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 295 NONAME ; void IoUtils::CServerBase::PrintList(class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?PrintList@CServerBase@IoUtils@@MAEXV?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 296 NONAME ; void IoUtils::CServerBase::PrintList(class TRefByValue<class TDesC8 const >, signed char * [1] &)
+	?PrintList@CServerCommandBase@IoUtils@@EAEXV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 297 NONAME ; void IoUtils::CServerCommandBase::PrintList(class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?PrintList@CServerCommandBase@IoUtils@@EAEXV?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 298 NONAME ; void IoUtils::CServerCommandBase::PrintList(class TRefByValue<class TDesC8 const >, signed char * [1] &)
+	?PrintWarning@CCommandBase@IoUtils@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 299 NONAME ; void IoUtils::CCommandBase::PrintWarning(class TRefByValue<class TDesC16 const >, ...)
+	?PrintWarning@IoUtils@@YAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 300 NONAME ; void IoUtils::PrintWarning(class TRefByValue<class TDesC16 const >, ...)
+	?PrintWarningList@CCommandBase@IoUtils@@UAEXV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 301 NONAME ; void IoUtils::CCommandBase::PrintWarningList(class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?PrintWarningList@CServerBase@IoUtils@@MAEXV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 302 NONAME ; void IoUtils::CServerBase::PrintWarningList(class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?PrintWarningList@CServerCommandBase@IoUtils@@EAEXV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 303 NONAME ; void IoUtils::CServerCommandBase::PrintWarningList(class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?Printf@CCommandBase@IoUtils@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 304 NONAME ; void IoUtils::CCommandBase::Printf(class TRefByValue<class TDesC16 const >, ...)
+	?Printf@CCommandBase@IoUtils@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 305 NONAME ; void IoUtils::CCommandBase::Printf(class TRefByValue<class TDesC8 const >, ...)
+	?Printf@IoUtils@@YAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 306 NONAME ; void IoUtils::Printf(class TRefByValue<class TDesC16 const >, ...)
+	?Printf@IoUtils@@YAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 307 NONAME ; void IoUtils::Printf(class TRefByValue<class TDesC8 const >, ...)
+	?Process@RChildProcess@IoUtils@@QAEAAVRProcess@@XZ @ 308 NONAME ; class RProcess & IoUtils::RChildProcess::Process(void)
+	?Pwd@CEnvironment@IoUtils@@QBEABVTDesC16@@XZ @ 309 NONAME ; class TDesC16 const & IoUtils::CEnvironment::Pwd(void) const
+	?Read@RIoReadHandle@@QAEHAAVTDes16@@@Z @ 310 NONAME ; int RIoReadHandle::Read(class TDes16 &)
+	?Read@RIoReadHandle@@QAEXAAVTDes16@@AAVTRequestStatus@@@Z @ 311 NONAME ; void RIoReadHandle::Read(class TDes16 &, class TRequestStatus &)
+	?ReadCancel@RIoReadHandle@@QAEXXZ @ 312 NONAME ; void RIoReadHandle::ReadCancel(void)
+	?ReadKey@RIoConsoleReadHandle@@QAEIXZ @ 313 NONAME ; unsigned int RIoConsoleReadHandle::ReadKey(void)
+	?ReadL@CCommandBase@IoUtils@@QAEXAAVTDes16@@@Z @ 314 NONAME ; void IoUtils::CCommandBase::ReadL(class TDes16 &)
+	?ReadL@IoUtils@@YAXAAVTDes16@@@Z @ 315 NONAME ; void IoUtils::ReadL(class TDes16 &)
+	?ReadL@RIoReadHandle@@QAEXAAVTDes16@@@Z @ 316 NONAME ; void RIoReadHandle::ReadL(class TDes16 &)
+	?ReadLC@Stringify@IoUtils@@SAPAVHBufC16@@AAVTLex16@@ABVTChar@@@Z @ 317 NONAME ; class HBufC16 * IoUtils::Stringify::ReadLC(class TLex16 &, class TChar const &)
+	?ReadLC@Stringify@IoUtils@@SAPAVHBufC16@@AAVTLex16@@ABVTChar@@AAVCCommandBase@2@@Z @ 318 NONAME ; class HBufC16 * IoUtils::Stringify::ReadLC(class TLex16 &, class TChar const &, class IoUtils::CCommandBase &)
+	?ReadLC@Stringify@IoUtils@@SAPAVHBufC16@@AAVTLex16@@ABVTChar@@AAVCCommandBase@2@I@Z @ 319 NONAME ; class HBufC16 * IoUtils::Stringify::ReadLC(class TLex16 &, class TChar const &, class IoUtils::CCommandBase &, unsigned int)
+	?ReadLC@Stringify@IoUtils@@SAPAVHBufC16@@AAVTLex16@@ABVTChar@@I@Z @ 320 NONAME ; class HBufC16 * IoUtils::Stringify::ReadLC(class TLex16 &, class TChar const &, unsigned int)
+	?Remove@CEnvironment@IoUtils@@QAEHABVTDesC16@@@Z @ 321 NONAME ; int IoUtils::CEnvironment::Remove(class TDesC16 const &)
+	?RemoveL@CEnvironment@IoUtils@@QAEXABVTDesC16@@@Z @ 322 NONAME ; void IoUtils::CEnvironment::RemoveL(class TDesC16 const &)
+	?Report@CServerBase@IoUtils@@EAAXABVTServerCommandId@2@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 323 NONAME ; void IoUtils::CServerBase::Report(class IoUtils::TServerCommandId const &, class TRefByValue<class TDesC16 const >, ...)
+	?Report@CServerBase@IoUtils@@EAAXABVTServerCommandId@2@V?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 324 NONAME ; void IoUtils::CServerBase::Report(class IoUtils::TServerCommandId const &, class TRefByValue<class TDesC8 const >, ...)
+	?ReportError@CServerBase@IoUtils@@EAAXABVTServerCommandId@2@HV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 325 NONAME ; void IoUtils::CServerBase::ReportError(class IoUtils::TServerCommandId const &, int, class TRefByValue<class TDesC16 const >, ...)
+	?ReportErrorList@CServerBase@IoUtils@@EAEXABVTServerCommandId@2@HV?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 326 NONAME ; void IoUtils::CServerBase::ReportErrorList(class IoUtils::TServerCommandId const &, int, class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?ReportList@CServerBase@IoUtils@@EAEXABVTServerCommandId@2@V?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 327 NONAME ; void IoUtils::CServerBase::ReportList(class IoUtils::TServerCommandId const &, class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?ReportList@CServerBase@IoUtils@@EAEXABVTServerCommandId@2@V?$TRefByValue@$$CBVTDesC8@@@@AAY00PAC@Z @ 328 NONAME ; void IoUtils::CServerBase::ReportList(class IoUtils::TServerCommandId const &, class TRefByValue<class TDesC8 const >, signed char * [1] &)
+	?ReportWarning@CServerBase@IoUtils@@EAAXABVTServerCommandId@2@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 329 NONAME ; void IoUtils::CServerBase::ReportWarning(class IoUtils::TServerCommandId const &, class TRefByValue<class TDesC16 const >, ...)
+	?ReportWarningList@CServerBase@IoUtils@@EAEXABVTServerCommandId@2@V?$TRefByValue@$$CBVTDesC16@@@@AAY00PAC@Z @ 330 NONAME ; void IoUtils::CServerBase::ReportWarningList(class IoUtils::TServerCommandId const &, class TRefByValue<class TDesC16 const >, signed char * [1] &)
+	?Reset@CTextBuffer@IoUtils@@UAEXXZ @ 331 NONAME ; void IoUtils::CTextBuffer::Reset(void)
+	?Reset@CTextFormatter@IoUtils@@UAEXXZ @ 332 NONAME ; void IoUtils::CTextFormatter::Reset(void)
+	?Run@RChildProcess@IoUtils@@QAEXAAVTRequestStatus@@@Z @ 333 NONAME ; void IoUtils::RChildProcess::Run(class TRequestStatus &)
+	?RunCommand@CCommandBase@IoUtils@@QAEHAAVRIoSession@@AAVRIoReadHandle@@AAVRIoWriteHandle@@2PBVTDesC16@@PAVCEnvironment@2@@Z @ 334 NONAME ; int IoUtils::CCommandBase::RunCommand(class RIoSession &, class RIoReadHandle &, class RIoWriteHandle &, class RIoWriteHandle &, class TDesC16 const *, class IoUtils::CEnvironment *)
+	?RunCommand@CCommandBase@IoUtils@@QAEHPBVTDesC16@@PAVCEnvironment@2@@Z @ 335 NONAME ; int IoUtils::CCommandBase::RunCommand(class TDesC16 const *, class IoUtils::CEnvironment *)
+	?RunCommand@CCommandBase@IoUtils@@QAEHXZ @ 336 NONAME ; int IoUtils::CCommandBase::RunCommand(void)
+	?RunCommand@CCommandBase@IoUtils@@QAEXAAVRIoSession@@AAVRIoReadHandle@@AAVRIoWriteHandle@@2PBVTDesC16@@PAVCEnvironment@2@PAVMCommandBaseObserver@2@@Z @ 337 NONAME ; void IoUtils::CCommandBase::RunCommand(class RIoSession &, class RIoReadHandle &, class RIoWriteHandle &, class RIoWriteHandle &, class TDesC16 const *, class IoUtils::CEnvironment *, class IoUtils::MCommandBaseObserver *)
+	?RunCommandL@CCommandBase@IoUtils@@QAEXAAVRIoSession@@AAVRIoReadHandle@@AAVRIoWriteHandle@@2PBVTDesC16@@PAVCEnvironment@2@@Z @ 338 NONAME ; void IoUtils::CCommandBase::RunCommandL(class RIoSession &, class RIoReadHandle &, class RIoWriteHandle &, class RIoWriteHandle &, class TDesC16 const *, class IoUtils::CEnvironment *)
+	?RunCommandL@CCommandBase@IoUtils@@QAEXPBVTDesC16@@PAVCEnvironment@2@@Z @ 339 NONAME ; void IoUtils::CCommandBase::RunCommandL(class TDesC16 const *, class IoUtils::CEnvironment *)
+	?RunCommandL@CCommandBase@IoUtils@@QAEXXZ @ 340 NONAME ; void IoUtils::CCommandBase::RunCommandL(void)
+	?RunError@CCommandBase@IoUtils@@MAEHH@Z @ 341 NONAME ; int IoUtils::CCommandBase::RunError(int)
+	?RunL@CCommandBase@IoUtils@@MAEXXZ @ 342 NONAME ; void IoUtils::CCommandBase::RunL(void)
+	?Set@TServerCommandId@IoUtils@@QAEXABV12@@Z @ 343 NONAME ; void IoUtils::TServerCommandId::Set(class IoUtils::TServerCommandId const &)
+	?SetAttributes@RIoConsoleWriteHandle@@QAEHIW4TColor@ConsoleAttributes@@0@Z @ 344 NONAME ; int RIoConsoleWriteHandle::SetAttributes(unsigned int, enum ConsoleAttributes::TColor, enum ConsoleAttributes::TColor)
+	?SetAttributesL@CTextBuffer@IoUtils@@QAEXIW4TColor@ConsoleAttributes@@0@Z @ 345 NONAME ; void IoUtils::CTextBuffer::SetAttributesL(unsigned int, enum ConsoleAttributes::TColor, enum ConsoleAttributes::TColor)
+	?SetAttributesL@RIoConsoleWriteHandle@@QAEXIW4TColor@ConsoleAttributes@@0@Z @ 346 NONAME ; void RIoConsoleWriteHandle::SetAttributesL(unsigned int, enum ConsoleAttributes::TColor, enum ConsoleAttributes::TColor)
+	?SetCursorHeight@RIoConsoleWriteHandle@@QAEHH@Z @ 347 NONAME ; int RIoConsoleWriteHandle::SetCursorHeight(int)
+	?SetCursorHeightL@RIoConsoleWriteHandle@@QAEXH@Z @ 348 NONAME ; void RIoConsoleWriteHandle::SetCursorHeightL(int)
+	?SetCursorPosAbs@RIoConsoleWriteHandle@@QAEHABVTPoint@@@Z @ 349 NONAME ; int RIoConsoleWriteHandle::SetCursorPosAbs(class TPoint const &)
+	?SetCursorPosAbsL@RIoConsoleWriteHandle@@QAEXABVTPoint@@@Z @ 350 NONAME ; void RIoConsoleWriteHandle::SetCursorPosAbsL(class TPoint const &)
+	?SetCursorPosRel@RIoConsoleWriteHandle@@QAEHABVTPoint@@@Z @ 351 NONAME ; int RIoConsoleWriteHandle::SetCursorPosRel(class TPoint const &)
+	?SetCursorPosRelL@RIoConsoleWriteHandle@@QAEXABVTPoint@@@Z @ 352 NONAME ; void RIoConsoleWriteHandle::SetCursorPosRelL(class TPoint const &)
+	?SetErrorReported@CCommandBase@IoUtils@@QAEXH@Z @ 353 NONAME ; void IoUtils::CCommandBase::SetErrorReported(int)
+	?SetFactory@CServerCommandBase@IoUtils@@QAEXAAVCServerCommandFactory@2@@Z @ 354 NONAME ; void IoUtils::CServerCommandBase::SetFactory(class IoUtils::CServerCommandFactory &)
+	?SetFlags@CCommandBase@IoUtils@@QAEXI@Z @ 355 NONAME ; void IoUtils::CCommandBase::SetFlags(unsigned int)
+	?SetForegroundReadHandle@RIoEndPoint@@QAEHAAVRIoReadHandle@@@Z @ 356 NONAME ; int RIoEndPoint::SetForegroundReadHandle(class RIoReadHandle &)
+	?SetForegroundReadHandleL@RIoEndPoint@@QAEXAAVRIoReadHandle@@@Z @ 357 NONAME ; void RIoEndPoint::SetForegroundReadHandleL(class RIoReadHandle &)
+	?SetId@CServerCommandBase@IoUtils@@QAEXABVTServerCommandId@2@@Z @ 358 NONAME ; void IoUtils::CServerCommandBase::SetId(class IoUtils::TServerCommandId const &)
+	?SetIsDirectoryL@TFileName2@IoUtils@@QAEXXZ @ 359 NONAME ; void IoUtils::TFileName2::SetIsDirectoryL(void)
+	?SetL@CEnvironment@IoUtils@@QAEXABVTDesC16@@0@Z @ 360 NONAME ; void IoUtils::CEnvironment::SetL(class TDesC16 const &, class TDesC16 const &)
+	?SetL@CEnvironment@IoUtils@@QAEXABVTDesC16@@H@Z @ 361 NONAME ; void IoUtils::CEnvironment::SetL(class TDesC16 const &, int)
+	?SetL@TFileName2@IoUtils@@QAEXABV12@@Z @ 362 NONAME ; void IoUtils::TFileName2::SetL(class IoUtils::TFileName2 const &)
+	?SetLineSeparator@RIoReadHandle@@QAEHABVTDesC16@@@Z @ 363 NONAME ; int RIoReadHandle::SetLineSeparator(class TDesC16 const &)
+	?SetLineSeparatorL@RIoReadHandle@@QAEXABVTDesC16@@@Z @ 364 NONAME ; void RIoReadHandle::SetLineSeparatorL(class TDesC16 const &)
+	?SetMode@RIoReadWriteHandle@@QAEHW4TMode@1@@Z @ 365 NONAME ; int RIoReadWriteHandle::SetMode(enum RIoReadWriteHandle::TMode)
+	?SetModeL@RIoReadWriteHandle@@QAEXW4TMode@1@@Z @ 366 NONAME ; void RIoReadWriteHandle::SetModeL(enum RIoReadWriteHandle::TMode)
+	?SetObjectName@RIoSession@@QAEHHABVTDesC16@@@Z @ 367 NONAME ; int RIoSession::SetObjectName(int, class TDesC16 const &)
+	?SetObjectNameL@RIoSession@@QAEXHABVTDesC16@@@Z @ 368 NONAME ; void RIoSession::SetObjectNameL(int, class TDesC16 const &)
+	?SetOwner@RIoReadWriteHandle@@QAEHVTThreadId@@@Z @ 369 NONAME ; int RIoReadWriteHandle::SetOwner(class TThreadId)
+	?SetOwnerL@RIoReadWriteHandle@@QAEXVTThreadId@@@Z @ 370 NONAME ; void RIoReadWriteHandle::SetOwnerL(class TThreadId)
+	?SetPwdL@CEnvironment@IoUtils@@QAEXABVTDesC16@@@Z @ 371 NONAME ; void IoUtils::CEnvironment::SetPwdL(class TDesC16 const &)
+	?SetReadMode@RIoReadHandle@@QAEHW4TReadMode@1@@Z @ 372 NONAME ; int RIoReadHandle::SetReadMode(enum RIoReadHandle::TReadMode)
+	?SetReadModeL@RIoReadHandle@@QAEXW4TReadMode@1@@Z @ 373 NONAME ; void RIoReadHandle::SetReadModeL(enum RIoReadHandle::TReadMode)
+	?SetTitle@RIoConsoleWriteHandle@@QAEHABVTDesC16@@@Z @ 374 NONAME ; int RIoConsoleWriteHandle::SetTitle(class TDesC16 const &)
+	?SetTitleL@RIoConsoleWriteHandle@@QAEXABVTDesC16@@@Z @ 375 NONAME ; void RIoConsoleWriteHandle::SetTitleL(class TDesC16 const &)
+	?SetToForeground@RIoReadHandle@@QAEHXZ @ 376 NONAME ; int RIoReadHandle::SetToForeground(void)
+	?SetToForegroundL@RIoReadHandle@@QAEXXZ @ 377 NONAME ; void RIoReadHandle::SetToForegroundL(void)
+	?SetTypeL@TFileName2@IoUtils@@QAEXW4TType@12@@Z @ 378 NONAME ; void IoUtils::TFileName2::SetTypeL(enum IoUtils::TFileName2::TType)
+	?SetUnderlyingConsole@RIoReadWriteHandle@@QAEHAAVRIoConsole@@@Z @ 379 NONAME ; int RIoReadWriteHandle::SetUnderlyingConsole(class RIoConsole &)
+	?SetUnderlyingConsoleL@RIoReadWriteHandle@@QAEXAAVRIoConsole@@@Z @ 380 NONAME ; void RIoReadWriteHandle::SetUnderlyingConsoleL(class RIoConsole &)
+	?SplitL@TFileName2@IoUtils@@QAEXAAV?$RArray@VTFileName2@IoUtils@@@@@Z @ 381 NONAME ; void IoUtils::TFileName2::SplitL(class RArray<class IoUtils::TFileName2> &)
+	?Static@CCommandBase@IoUtils@@SAAAV12@XZ @ 382 NONAME ; class IoUtils::CCommandBase & IoUtils::CCommandBase::Static(void)
+	?Stderr@CCommandBase@IoUtils@@QAEAAVRIoConsoleWriteHandle@@XZ @ 383 NONAME ; class RIoConsoleWriteHandle & IoUtils::CCommandBase::Stderr(void)
+	?Stdin@CCommandBase@IoUtils@@QAEAAVRIoConsoleReadHandle@@XZ @ 384 NONAME ; class RIoConsoleReadHandle & IoUtils::CCommandBase::Stdin(void)
+	?StdinChange@CCommandBase@IoUtils@@UAEXI@Z @ 385 NONAME ; void IoUtils::CCommandBase::StdinChange(unsigned int)
+	?Stdout@CCommandBase@IoUtils@@QAEAAVRIoConsoleWriteHandle@@XZ @ 386 NONAME ; class RIoConsoleWriteHandle & IoUtils::CCommandBase::Stdout(void)
+	?TabulateL@CTextFormatter@IoUtils@@QAEXHHABVTDesC16@@@Z @ 387 NONAME ; void IoUtils::CTextFormatter::TabulateL(int, int, class TDesC16 const &)
+	?TabulateL@CTextFormatter@IoUtils@@QAEXHHABVTDesC16@@W4TTabMode@2@@Z @ 388 NONAME ; void IoUtils::CTextFormatter::TabulateL(int, int, class TDesC16 const &, enum IoUtils::TTabMode)
+	?UnsplitL@TFileName2@IoUtils@@QAEXABV?$RArray@VTFileName2@IoUtils@@@@@Z @ 389 NONAME ; void IoUtils::TFileName2::UnsplitL(class RArray<class IoUtils::TFileName2> const &)
+	?Value@TServerCommandId@IoUtils@@QBEIXZ @ 390 NONAME ; unsigned int IoUtils::TServerCommandId::Value(void) const
+	?ValueList@TEnum@IoUtils@@QBEABVTDesC16@@XZ @ 391 NONAME ; class TDesC16 const & IoUtils::TEnum::ValueList(void) const
+	?WaitForKey@RIoConsoleReadHandle@@QAEXAAVTRequestStatus@@@Z @ 392 NONAME ; void RIoConsoleReadHandle::WaitForKey(class TRequestStatus &)
+	?WaitForKeyCancel@RIoConsoleReadHandle@@QAEXXZ @ 393 NONAME ; void RIoConsoleReadHandle::WaitForKeyCancel(void)
+	?WidenLC@Stringify@IoUtils@@SAPAVHBufC16@@ABVTDesC8@@@Z @ 394 NONAME ; class HBufC16 * IoUtils::Stringify::WidenLC(class TDesC8 const &)
+	?WrapL@CTextFormatter@IoUtils@@QAEXHABVTDesC16@@@Z @ 395 NONAME ; void IoUtils::CTextFormatter::WrapL(int, class TDesC16 const &)
+	?Write@CCommandBase@IoUtils@@QAEXABVTDesC16@@@Z @ 396 NONAME ; void IoUtils::CCommandBase::Write(class TDesC16 const &)
+	?Write@CTextBuffer@IoUtils@@QBEHAAVRIoWriteHandle@@@Z @ 397 NONAME ; int IoUtils::CTextBuffer::Write(class RIoWriteHandle &) const
+	?Write@CTextBuffer@IoUtils@@QBEXAAVRIoWriteHandle@@AAVTRequestStatus@@@Z @ 398 NONAME ; void IoUtils::CTextBuffer::Write(class RIoWriteHandle &, class TRequestStatus &) const
+	?Write@IoUtils@@YAXABVTDesC16@@@Z @ 399 NONAME ; void IoUtils::Write(class TDesC16 const &)
+	?Write@RIoWriteHandle@@QAEHABVTDesC16@@@Z @ 400 NONAME ; int RIoWriteHandle::Write(class TDesC16 const &)
+	?Write@RIoWriteHandle@@QAEXABVTDesC16@@AAVTRequestStatus@@@Z @ 401 NONAME ; void RIoWriteHandle::Write(class TDesC16 const &, class TRequestStatus &)
+	?WriteCancel@RIoWriteHandle@@QAEXXZ @ 402 NONAME ; void RIoWriteHandle::WriteCancel(void)
+	?WriteL@RIoWriteHandle@@QAEXABVTDesC16@@@Z @ 403 NONAME ; void RIoWriteHandle::WriteL(class TDesC16 const &)
+	?Zero@CTextBuffer@IoUtils@@UAEXXZ @ 404 NONAME ; void IoUtils::CTextBuffer::Zero(void)
+	?Zero@CTextFormatter@IoUtils@@UAEXXZ @ 405 NONAME ; void IoUtils::CTextFormatter::Zero(void)
+	?AppendEnumL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@11I1@Z @ 406 NONAME ; void IoUtils::RCommandArgumentList::AppendEnumL(class RArray<int> &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendEnumL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@H@@VTChar@@ABVTDesC16@@22I2@Z @ 407 NONAME ; void IoUtils::RCommandOptionList::AppendEnumL(class RArray<int> &, class TChar, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?ResetText@CTextBuffer@IoUtils@@UAEXXZ @ 408 NONAME ; void IoUtils::CTextBuffer::ResetText(void)
+	?ResetText@CTextFormatter@IoUtils@@UAEXXZ @ 409 NONAME ; void IoUtils::CTextFormatter::ResetText(void)
+	??0CMemoryAccessCommandBase@IoUtils@@QAE@I@Z @ 410 NONAME ; IoUtils::CMemoryAccessCommandBase::CMemoryAccessCommandBase(unsigned int)
+	??0CMemoryAccessCommandBase@IoUtils@@QAE@XZ @ 411 NONAME ; IoUtils::CMemoryAccessCommandBase::CMemoryAccessCommandBase(void)
+	??1CMemoryAccessCommandBase@IoUtils@@UAE@XZ @ 412 NONAME ; IoUtils::CMemoryAccessCommandBase::~CMemoryAccessCommandBase(void)
+	?LoadMemoryAccessL@CMemoryAccessCommandBase@IoUtils@@QAEXXZ @ 413 NONAME ; void IoUtils::CMemoryAccessCommandBase::LoadMemoryAccessL(void)
+	?AppendPodL@CTextFormatter@IoUtils@@QAEXABVTDesC16@@@Z @ 414 NONAME ; void IoUtils::CTextFormatter::AppendPodL(class TDesC16 const &)
+	?WrapL@CTextFormatter@IoUtils@@QAEXHHABVTDesC16@@@Z @ 415 NONAME ; void IoUtils::CTextFormatter::WrapL(int, int, class TDesC16 const &)
+	?AppendSpacesL@CTextBuffer@IoUtils@@QAEXH@Z @ 416 NONAME ; void IoUtils::CTextBuffer::AppendSpacesL(int)
+	?GetCurrentAttributes@CTextBuffer@IoUtils@@QBEXAAIAAW4TColor@ConsoleAttributes@@1@Z @ 417 NONAME ; void IoUtils::CTextBuffer::GetCurrentAttributes(unsigned int &, enum ConsoleAttributes::TColor &, enum ConsoleAttributes::TColor &) const
+	?AppendL@CTextBuffer@IoUtils@@QAEXABV12@@Z @ 418 NONAME ; void IoUtils::CTextBuffer::AppendL(class IoUtils::CTextBuffer const &)
+	?IsPresent@RCommandArgumentList@IoUtils@@QBEHPAX@Z @ 419 NONAME ; int IoUtils::RCommandArgumentList::IsPresent(void *) const
+	?Write@CTextFormatter@IoUtils@@QAEHXZ @ 420 NONAME ; int IoUtils::CTextFormatter::Write(void)
+	?GetAttributes@CTextBuffer@IoUtils@@QBEXHAAIAAW4TColor@ConsoleAttributes@@1@Z @ 421 NONAME ; void IoUtils::CTextBuffer::GetAttributes(int, unsigned int &, enum ConsoleAttributes::TColor &, enum ConsoleAttributes::TColor &) const
+	?AppendEnumL@RCommandArgumentList@IoUtils@@QAEXAAHABVTDesC16@@111I1@Z @ 422 NONAME ; void IoUtils::RCommandArgumentList::AppendEnumL(int &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendEnumL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@111I1@Z @ 423 NONAME ; void IoUtils::RCommandArgumentList::AppendEnumL(class RArray<int> &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendEnumL@RCommandOptionList@IoUtils@@QAEXAAHVTChar@@ABVTDesC16@@222I2@Z @ 424 NONAME ; void IoUtils::RCommandOptionList::AppendEnumL(int &, class TChar, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendEnumL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@H@@VTChar@@ABVTDesC16@@222I2@Z @ 425 NONAME ; void IoUtils::RCommandOptionList::AppendEnumL(class RArray<int> &, class TChar, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?DescriptionList@TEnum@IoUtils@@QBEABVTDesC16@@XZ @ 426 NONAME ; class TDesC16 const & IoUtils::TEnum::DescriptionList(void) const
+	??0TEnum@IoUtils@@QAE@ABVTDesC16@@0@Z @ 427 NONAME ; IoUtils::TEnum::TEnum(class TDesC16 const &, class TDesC16 const &)
+	?GetColorConsoleBaseL@CCommandBase@IoUtils@@QAEPAVCColorConsoleBase@@XZ @ 428 NONAME ; class CColorConsoleBase * IoUtils::CCommandBase::GetColorConsoleBaseL(void)
+	?AppendUintL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@_K@@ABVTDesC16@@1I1@Z @ 429 NONAME ; void IoUtils::RCommandArgumentList::AppendUintL(class RArray<unsigned long long> &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendUintL@RCommandArgumentList@IoUtils@@QAEXAA_KABVTDesC16@@1I1@Z @ 430 NONAME ; void IoUtils::RCommandArgumentList::AppendUintL(unsigned long long &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendUintL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@_K@@VTChar@@ABVTDesC16@@2I2@Z @ 431 NONAME ; void IoUtils::RCommandOptionList::AppendUintL(class RArray<unsigned long long> &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendUintL@RCommandOptionList@IoUtils@@QAEXAA_KVTChar@@ABVTDesC16@@2I2@Z @ 432 NONAME ; void IoUtils::RCommandOptionList::AppendUintL(unsigned long long &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendIntL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@_J@@ABVTDesC16@@1I1@Z @ 433 NONAME ; void IoUtils::RCommandArgumentList::AppendIntL(class RArray<long long> &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendIntL@RCommandArgumentList@IoUtils@@QAEXAA_JABVTDesC16@@1I1@Z @ 434 NONAME ; void IoUtils::RCommandArgumentList::AppendIntL(long long &, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendIntL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@_J@@VTChar@@ABVTDesC16@@2I2@Z @ 435 NONAME ; void IoUtils::RCommandOptionList::AppendIntL(class RArray<long long> &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendIntL@RCommandOptionList@IoUtils@@QAEXAA_JVTChar@@ABVTDesC16@@2I2@Z @ 436 NONAME ; void IoUtils::RCommandOptionList::AppendIntL(long long &, class TChar, class TDesC16 const &, class TDesC16 const &, unsigned int, class TDesC16 const &)
+	?AppendL@CTextBuffer@IoUtils@@QAEXABV12@H@Z @ 437 NONAME ; void IoUtils::CTextBuffer::AppendL(class IoUtils::CTextBuffer const &, int)
+	?AppendL@CTextBuffer@IoUtils@@QAEXABV12@HH@Z @ 438 NONAME ; void IoUtils::CTextBuffer::AppendL(class IoUtils::CTextBuffer const &, int, int)
+	?PageL@CCommandBase@IoUtils@@QAEXAAVRIoReadHandle@@@Z @ 439 NONAME ; void IoUtils::CCommandBase::PageL(class RIoReadHandle &)
+	?PageL@CCommandBase@IoUtils@@QAEXABVCTextBuffer@2@@Z @ 440 NONAME ; void IoUtils::CCommandBase::PageL(class IoUtils::CTextBuffer const &)
+	?Write@CTextBuffer@IoUtils@@QBEHAAVRIoWriteHandle@@HH@Z @ 441 NONAME ; int IoUtils::CTextBuffer::Write(class RIoWriteHandle &, int, int) const
+	?Write@CTextBuffer@IoUtils@@QBEXAAVRIoWriteHandle@@HHAAVTRequestStatus@@@Z @ 442 NONAME ; void IoUtils::CTextBuffer::Write(class RIoWriteHandle &, int, int, class TRequestStatus &) const
+	?SetAttributes@RIoConsoleWriteHandle@@QAEHABVTAttributes@ConsoleAttributes@@@Z @ 443 NONAME ; int RIoConsoleWriteHandle::SetAttributes(class ConsoleAttributes::TAttributes const &)
+	?SetAttributesL@CTextBuffer@IoUtils@@QAEXABVTAttributes@ConsoleAttributes@@@Z @ 444 NONAME ; void IoUtils::CTextBuffer::SetAttributesL(class ConsoleAttributes::TAttributes const &)
+	??0TEnum@IoUtils@@QAE@XZ @ 445 NONAME ; IoUtils::TEnum::TEnum(void)
+	??1CCommandInfoFile@IoUtils@@UAE@XZ @ 446 NONAME ; IoUtils::CCommandInfoFile::~CCommandInfoFile(void)
+	?Arguments@CCommandInfoFile@IoUtils@@QAEABVRCommandArgumentList@2@XZ @ 447 NONAME ; class IoUtils::RCommandArgumentList const & IoUtils::CCommandInfoFile::Arguments(void)
+	?AssignL@CCommandInfoFile@IoUtils@@QBEXAAVRCommandArgumentList@2@AAVRCommandOptionList@2@@Z @ 448 NONAME ; void IoUtils::CCommandInfoFile::AssignL(class IoUtils::RCommandArgumentList &, class IoUtils::RCommandOptionList &) const
+	?Description@CCommandBase@IoUtils@@UBEABVTDesC16@@XZ @ 449 NONAME ; class TDesC16 const & IoUtils::CCommandBase::Description(void) const
+	?LongDescription@CCommandInfoFile@IoUtils@@QBEABVTDesC16@@XZ @ 450 NONAME ; class TDesC16 const & IoUtils::CCommandInfoFile::LongDescription(void) const
+	?Name@CCommandInfoFile@IoUtils@@QBEABVTDesC16@@XZ @ 451 NONAME ; class TDesC16 const & IoUtils::CCommandInfoFile::Name(void) const
+	?NewL@CCommandInfoFile@IoUtils@@SAPAV12@AAVRFs@@ABVTDesC16@@@Z @ 452 NONAME ; class IoUtils::CCommandInfoFile * IoUtils::CCommandInfoFile::NewL(class RFs &, class TDesC16 const &)
+	?Options@CCommandInfoFile@IoUtils@@QBEABVRCommandOptionList@2@XZ @ 453 NONAME ; class IoUtils::RCommandOptionList const & IoUtils::CCommandInfoFile::Options(void) const
+	?SetDescriptionList@TEnum@IoUtils@@QAEXABVTDesC16@@@Z @ 454 NONAME ; void IoUtils::TEnum::SetDescriptionList(class TDesC16 const &)
+	?SetDriveL@TFileName2@IoUtils@@QAEXABVTDesC16@@@Z @ 455 NONAME ; void IoUtils::TFileName2::SetDriveL(class TDesC16 const &)
+	?SetExtL@TFileName2@IoUtils@@QAEXABVTDesC16@@@Z @ 456 NONAME ; void IoUtils::TFileName2::SetExtL(class TDesC16 const &)
+	?SetNameAndExtL@TFileName2@IoUtils@@QAEXABVTDesC16@@@Z @ 457 NONAME ; void IoUtils::TFileName2::SetNameAndExtL(class TDesC16 const &)
+	?SetNameL@TFileName2@IoUtils@@QAEXABVTDesC16@@@Z @ 458 NONAME ; void IoUtils::TFileName2::SetNameL(class TDesC16 const &)
+	?SetPathL@TFileName2@IoUtils@@QAEXABVTDesC16@@@Z @ 459 NONAME ; void IoUtils::TFileName2::SetPathL(class TDesC16 const &)
+	?SetValueList@TEnum@IoUtils@@QAEXABVTDesC16@@@Z @ 460 NONAME ; void IoUtils::TEnum::SetValueList(class TDesC16 const &)
+	?ShortDescription@CCommandInfoFile@IoUtils@@QBEABVTDesC16@@XZ @ 461 NONAME ; class TDesC16 const & IoUtils::CCommandInfoFile::ShortDescription(void) const
+	?AppendBoolL@RCommandOptionList@IoUtils@@QAEXAAHABVTDesC16@@@Z @ 462 NONAME ; void IoUtils::RCommandOptionList::AppendBoolL(int &, class TDesC16 const &)
+	?AppendBoolL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@@Z @ 463 NONAME ; void IoUtils::RCommandOptionList::AppendBoolL(class RArray<int> &, class TDesC16 const &)
+	?AppendEnumL@RCommandArgumentList@IoUtils@@QAEXAAHABVTDesC16@@@Z @ 464 NONAME ; void IoUtils::RCommandArgumentList::AppendEnumL(int &, class TDesC16 const &)
+	?AppendEnumL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@@Z @ 465 NONAME ; void IoUtils::RCommandArgumentList::AppendEnumL(class RArray<int> &, class TDesC16 const &)
+	?AppendEnumL@RCommandOptionList@IoUtils@@QAEXAAHABVTDesC16@@@Z @ 466 NONAME ; void IoUtils::RCommandOptionList::AppendEnumL(int &, class TDesC16 const &)
+	?AppendEnumL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@@Z @ 467 NONAME ; void IoUtils::RCommandOptionList::AppendEnumL(class RArray<int> &, class TDesC16 const &)
+	?AppendFileNameL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@VTFileName2@IoUtils@@@@ABVTDesC16@@@Z @ 468 NONAME ; void IoUtils::RCommandArgumentList::AppendFileNameL(class RArray<class IoUtils::TFileName2> &, class TDesC16 const &)
+	?AppendFileNameL@RCommandArgumentList@IoUtils@@QAEXAAVTFileName2@2@ABVTDesC16@@@Z @ 469 NONAME ; void IoUtils::RCommandArgumentList::AppendFileNameL(class IoUtils::TFileName2 &, class TDesC16 const &)
+	?AppendFileNameL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@VTFileName2@IoUtils@@@@ABVTDesC16@@@Z @ 470 NONAME ; void IoUtils::RCommandOptionList::AppendFileNameL(class RArray<class IoUtils::TFileName2> &, class TDesC16 const &)
+	?AppendFileNameL@RCommandOptionList@IoUtils@@QAEXAAVTFileName2@2@ABVTDesC16@@@Z @ 471 NONAME ; void IoUtils::RCommandOptionList::AppendFileNameL(class IoUtils::TFileName2 &, class TDesC16 const &)
+	?AppendIntL@RCommandArgumentList@IoUtils@@QAEXAAHABVTDesC16@@@Z @ 472 NONAME ; void IoUtils::RCommandArgumentList::AppendIntL(int &, class TDesC16 const &)
+	?AppendIntL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@@Z @ 473 NONAME ; void IoUtils::RCommandArgumentList::AppendIntL(class RArray<int> &, class TDesC16 const &)
+	?AppendIntL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@_J@@ABVTDesC16@@@Z @ 474 NONAME ; void IoUtils::RCommandArgumentList::AppendIntL(class RArray<long long> &, class TDesC16 const &)
+	?AppendIntL@RCommandArgumentList@IoUtils@@QAEXAA_JABVTDesC16@@@Z @ 475 NONAME ; void IoUtils::RCommandArgumentList::AppendIntL(long long &, class TDesC16 const &)
+	?AppendIntL@RCommandOptionList@IoUtils@@QAEXAAHABVTDesC16@@@Z @ 476 NONAME ; void IoUtils::RCommandOptionList::AppendIntL(int &, class TDesC16 const &)
+	?AppendIntL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@@Z @ 477 NONAME ; void IoUtils::RCommandOptionList::AppendIntL(class RArray<int> &, class TDesC16 const &)
+	?AppendIntL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@_J@@ABVTDesC16@@@Z @ 478 NONAME ; void IoUtils::RCommandOptionList::AppendIntL(class RArray<long long> &, class TDesC16 const &)
+	?AppendIntL@RCommandOptionList@IoUtils@@QAEXAA_JABVTDesC16@@@Z @ 479 NONAME ; void IoUtils::RCommandOptionList::AppendIntL(long long &, class TDesC16 const &)
+	?AppendRealL@RCommandArgumentList@IoUtils@@QAEXAANABVTDesC16@@@Z @ 480 NONAME ; void IoUtils::RCommandArgumentList::AppendRealL(double &, class TDesC16 const &)
+	?AppendRealL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@N@@ABVTDesC16@@@Z @ 481 NONAME ; void IoUtils::RCommandArgumentList::AppendRealL(class RArray<double> &, class TDesC16 const &)
+	?AppendRealL@RCommandOptionList@IoUtils@@QAEXAANABVTDesC16@@@Z @ 482 NONAME ; void IoUtils::RCommandOptionList::AppendRealL(double &, class TDesC16 const &)
+	?AppendRealL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@N@@ABVTDesC16@@@Z @ 483 NONAME ; void IoUtils::RCommandOptionList::AppendRealL(class RArray<double> &, class TDesC16 const &)
+	?AppendStringL@RCommandArgumentList@IoUtils@@QAEXAAPAVHBufC16@@ABVTDesC16@@@Z @ 484 NONAME ; void IoUtils::RCommandArgumentList::AppendStringL(class HBufC16 * &, class TDesC16 const &)
+	?AppendStringL@RCommandArgumentList@IoUtils@@QAEXAAV?$RPointerArray@VHBufC16@@@@ABVTDesC16@@@Z @ 485 NONAME ; void IoUtils::RCommandArgumentList::AppendStringL(class RPointerArray<class HBufC16> &, class TDesC16 const &)
+	?AppendStringL@RCommandOptionList@IoUtils@@QAEXAAPAVHBufC16@@ABVTDesC16@@@Z @ 486 NONAME ; void IoUtils::RCommandOptionList::AppendStringL(class HBufC16 * &, class TDesC16 const &)
+	?AppendStringL@RCommandOptionList@IoUtils@@QAEXAAV?$RPointerArray@VHBufC16@@@@ABVTDesC16@@@Z @ 487 NONAME ; void IoUtils::RCommandOptionList::AppendStringL(class RPointerArray<class HBufC16> &, class TDesC16 const &)
+	?AppendUintL@RCommandArgumentList@IoUtils@@QAEXAAIABVTDesC16@@@Z @ 488 NONAME ; void IoUtils::RCommandArgumentList::AppendUintL(unsigned int &, class TDesC16 const &)
+	?AppendUintL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@I@@ABVTDesC16@@@Z @ 489 NONAME ; void IoUtils::RCommandArgumentList::AppendUintL(class RArray<unsigned int> &, class TDesC16 const &)
+	?AppendUintL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@_K@@ABVTDesC16@@@Z @ 490 NONAME ; void IoUtils::RCommandArgumentList::AppendUintL(class RArray<unsigned long long> &, class TDesC16 const &)
+	?AppendUintL@RCommandArgumentList@IoUtils@@QAEXAA_KABVTDesC16@@@Z @ 491 NONAME ; void IoUtils::RCommandArgumentList::AppendUintL(unsigned long long &, class TDesC16 const &)
+	?AppendUintL@RCommandOptionList@IoUtils@@QAEXAAIABVTDesC16@@@Z @ 492 NONAME ; void IoUtils::RCommandOptionList::AppendUintL(unsigned int &, class TDesC16 const &)
+	?AppendUintL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@I@@ABVTDesC16@@@Z @ 493 NONAME ; void IoUtils::RCommandOptionList::AppendUintL(class RArray<unsigned int> &, class TDesC16 const &)
+	?AppendUintL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@_K@@ABVTDesC16@@@Z @ 494 NONAME ; void IoUtils::RCommandOptionList::AppendUintL(class RArray<unsigned long long> &, class TDesC16 const &)
+	?AppendUintL@RCommandOptionList@IoUtils@@QAEXAA_KABVTDesC16@@@Z @ 495 NONAME ; void IoUtils::RCommandOptionList::AppendUintL(unsigned long long &, class TDesC16 const &)
+	?SeeAlso@CCommandInfoFile@IoUtils@@QBEABVTDesC16@@XZ @ 496 NONAME ; class TDesC16 const & IoUtils::CCommandInfoFile::SeeAlso(void) const
+	?UsingCif@CCommandBase@IoUtils@@QBEHXZ @ 497 NONAME ; int IoUtils::CCommandBase::UsingCif(void) const
+	?IsDir@TFileName2@IoUtils@@QBEHXZ @ 498 NONAME ; int IoUtils::TFileName2::IsDir(void) const
+	?IsFile@TFileName2@IoUtils@@QBEHXZ @ 499 NONAME ; int IoUtils::TFileName2::IsFile(void) const
+	?SetTypeL@TFileName2@IoUtils@@QAEXAAVRFs@@@Z @ 500 NONAME ; void IoUtils::TFileName2::SetTypeL(class RFs &)
+	?Process@RChildProcess@IoUtils@@QBEABVRProcess@@XZ @ 501 NONAME ; class RProcess const & IoUtils::RChildProcess::Process(void) const
+	?NewL@CCommandInfoFile@IoUtils@@SAPAV12@AAVRFs@@ABVCEnvironment@2@ABVTDesC16@@@Z @ 502 NONAME ; class IoUtils::CCommandInfoFile * IoUtils::CCommandInfoFile::NewL(class RFs &, class IoUtils::CEnvironment const &, class TDesC16 const &)
+	??ARCommandOptionList@IoUtils@@QBEABVTCommandOption@1@H@Z @ 503 NONAME ; class IoUtils::TCommandOption const & IoUtils::RCommandOptionList::operator[](int) const
+	??ARCommandOptionList@IoUtils@@QAEAAVTCommandOption@1@H@Z @ 504 NONAME ; class IoUtils::TCommandOption & IoUtils::RCommandOptionList::operator[](int)
+	?Count@RCommandOptionList@IoUtils@@QBEHXZ @ 505 NONAME ; int IoUtils::RCommandOptionList::Count(void) const
+	?Name@TValue@IoUtils@@QBEABVTDesC16@@XZ @ 506 NONAME ; class TDesC16 const & IoUtils::TValue::Name(void) const
+	?StopSupressingErrors@CCommandBase@IoUtils@@QAEXXZ @ 507 NONAME ; void IoUtils::CCommandBase::StopSupressingErrors(void)
+	?StartSupressingErrors@CCommandBase@IoUtils@@QAEXXZ @ 508 NONAME ; void IoUtils::CCommandBase::StartSupressingErrors(void)
+	?SubCommand@CCommandInfoFile@IoUtils@@QBEABV12@H@Z @ 509 NONAME ; class IoUtils::CCommandInfoFile const & IoUtils::CCommandInfoFile::SubCommand(int) const
+	?NumSubCommands@CCommandInfoFile@IoUtils@@QBEHXZ @ 510 NONAME ; int IoUtils::CCommandInfoFile::NumSubCommands(void) const
+	?DuplicateHandleFromThread@RIoWriteHandle@@QAEHVTThreadId@@@Z @ 511 NONAME ; int RIoWriteHandle::DuplicateHandleFromThread(class TThreadId)
+	?DuplicateHandleFromThread@RIoReadHandle@@QAEHVTThreadId@@@Z @ 512 NONAME ; int RIoReadHandle::DuplicateHandleFromThread(class TThreadId)
+	?SetIsStdErr@RIoConsoleWriteHandle@@QAEHH@Z @ 513 NONAME ; int RIoConsoleWriteHandle::SetIsStdErr(int)
+	?SubCommand@CCommandInfoFile@IoUtils@@QBEPBV12@ABVTDesC16@@@Z @ 514 NONAME ; class IoUtils::CCommandInfoFile const * IoUtils::CCommandInfoFile::SubCommand(class TDesC16 const &) const
+	??4TEnum@IoUtils@@QAEXABV01@@Z @ 515 NONAME ; void IoUtils::TEnum::operator=(class IoUtils::TEnum const &)
+	?AppendEnumL@RCommandArgumentList@IoUtils@@QAEXAAHABVTDesC16@@1@Z @ 516 NONAME ; void IoUtils::RCommandArgumentList::AppendEnumL(int &, class TDesC16 const &, class TDesC16 const &)
+	?AppendEnumL@RCommandArgumentList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@1@Z @ 517 NONAME ; void IoUtils::RCommandArgumentList::AppendEnumL(class RArray<int> &, class TDesC16 const &, class TDesC16 const &)
+	?AppendEnumL@RCommandOptionList@IoUtils@@QAEXAAHABVTDesC16@@1@Z @ 518 NONAME ; void IoUtils::RCommandOptionList::AppendEnumL(int &, class TDesC16 const &, class TDesC16 const &)
+	?AppendEnumL@RCommandOptionList@IoUtils@@QAEXAAV?$RArray@H@@ABVTDesC16@@1@Z @ 519 NONAME ; void IoUtils::RCommandOptionList::AppendEnumL(class RArray<int> &, class TDesC16 const &, class TDesC16 const &)
+	?TypeDescription@CBranchCommandBase@IoUtils@@MAEABVTDesC16@@XZ @ 520 NONAME ; class TDesC16 const & IoUtils::CBranchCommandBase::TypeDescription(void)
+	?Copyright@CCommandInfoFile@IoUtils@@QBEABVTDesC16@@XZ @ 521 NONAME ; class TDesC16 const & IoUtils::CCommandInfoFile::Copyright(void) const
+	?Cif@CCommandBase@IoUtils@@IBEPBVCCommandInfoFile@2@XZ @ 522 NONAME ; class IoUtils::CCommandInfoFile const * IoUtils::CCommandBase::Cif(void) const
+	??ARCommandArgumentList@IoUtils@@QBEABVTCommandArgument@1@H@Z @ 523 NONAME ; class IoUtils::TCommandArgument const & IoUtils::RCommandArgumentList::operator[](int) const
+	?Count@RCommandArgumentList@IoUtils@@QBEHXZ @ 524 NONAME ; int IoUtils::RCommandArgumentList::Count(void) const
+	?SetCif@CCommandBase@IoUtils@@IAEXABVCCommandInfoFile@2@@Z @ 525 NONAME ; void IoUtils::CCommandBase::SetCif(class IoUtils::CCommandInfoFile const &)
+	?EnvVar@TValue@IoUtils@@QBEABVTDesC16@@XZ @ 526 NONAME ; class TDesC16 const & IoUtils::TValue::EnvVar(void) const
+	?AcceptsMultiple@TValue@IoUtils@@QBEHXZ @ 527 NONAME ; int IoUtils::TValue::AcceptsMultiple(void) const
+	?CreateEnvironmentL@CCommandBase@IoUtils@@IAEXPAVCEnvironment@2@@Z @ 528 NONAME ; void IoUtils::CCommandBase::CreateEnvironmentL(class IoUtils::CEnvironment *)
+	?AllSet@RCommandArgumentList@IoUtils@@QBEHXZ @ 529 NONAME ; int IoUtils::RCommandArgumentList::AllSet(void) const
+	?Session@RIoHandle@@QBE?AVRIoSession@@XZ @ 530 NONAME ; class RIoSession RIoHandle::Session(void) const
+	?Stdout@TIoHandleSet@@QBEAAVRIoWriteHandle@@XZ @ 531 NONAME ; class RIoWriteHandle & TIoHandleSet::Stdout(void) const
+	?IoSession@TIoHandleSet@@QBEAAVRIoSession@@XZ @ 532 NONAME ; class RIoSession & TIoHandleSet::IoSession(void) const
+	?Stdin@TIoHandleSet@@QBEAAVRIoReadHandle@@XZ @ 533 NONAME ; class RIoReadHandle & TIoHandleSet::Stdin(void) const
+	?Stderr@TIoHandleSet@@QBEAAVRIoWriteHandle@@XZ @ 534 NONAME ; class RIoWriteHandle & TIoHandleSet::Stderr(void) const
+	?GetKeysL@CEnvironment@IoUtils@@QBEXAAV?$RPointerArray@VHBufC16@@@@@Z @ 535 NONAME ; void IoUtils::CEnvironment::GetKeysL(class RPointerArray<class HBufC16> &) const
+	?RemoveAll@CEnvironment@IoUtils@@QAEXXZ @ 536 NONAME ; void IoUtils::CEnvironment::RemoveAll(void)
+	?ExternalizeLC@CEnvironment@IoUtils@@QBEPAVHBufC8@@XZ @ 537 NONAME ; class HBufC8 * IoUtils::CEnvironment::ExternalizeLC(void) const
+	?SetLocalL@CEnvironment@IoUtils@@QAEXABVTDesC16@@@Z @ 538 NONAME ; void IoUtils::CEnvironment::SetLocalL(class TDesC16 const &)
+	?CreateSharedEnvironmentL@CEnvironment@IoUtils@@QAEPAV12@XZ @ 539 NONAME ; class IoUtils::CEnvironment * IoUtils::CEnvironment::CreateSharedEnvironmentL(void)
+	??0TIoHandleSet@@QAE@AAVRIoSession@@AAVRIoReadHandle@@AAVRIoWriteHandle@@2@Z @ 540 NONAME ; TIoHandleSet::TIoHandleSet(class RIoSession &, class RIoReadHandle &, class RIoWriteHandle &, class RIoWriteHandle &)
+	?Type@TValue@IoUtils@@QBEIXZ @ 541 NONAME ; unsigned int IoUtils::TValue::Type(void) const
+	?ValuePtr@TValue@IoUtils@@QBEPAXXZ @ 542 NONAME ; void * IoUtils::TValue::ValuePtr(void) const
+	?EnumValueList@TValue@IoUtils@@QBEABVTDesC16@@XZ @ 543 NONAME ; class TDesC16 const & IoUtils::TValue::EnumValueList(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/client.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1334 @@
+// client.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/iocli.h>
+#include "clientserver.h"
+#include <e32math.h>
+
+
+#ifndef EKA2
+
+//
+// TServerStart.
+//
+
+TServerStart::TServerStart(TRequestStatus& aStatus)
+	: iId(RThread().Id()), iStatus(&aStatus)
+	{
+	aStatus = KRequestPending;
+	}
+
+TPtrC TServerStart::AsCommand() const
+	{
+	return TPtrC(reinterpret_cast<const TText*>(this),sizeof(TServerStart)/sizeof(TText));
+	}
+
+#endif
+
+
+//
+// Statics.
+//
+
+static TInt StartServer()
+	{
+#ifdef EKA2
+	const TUidType serverUid(KNullUid, KNullUid, KServerUid3);
+	RProcess server;
+	TInt r = server.Create(KIoServerName, KNullDesC, serverUid);
+	if (r != KErrNone)
+		{
+		return r;
+		}
+	TRequestStatus stat;
+	server.Rendezvous(stat);
+	if (stat != KRequestPending)
+		{
+		server.Kill(0);
+		}
+	else
+		{
+		server.Resume();
+		}
+	User::WaitForRequest(stat);		// wait for start or death
+	r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
+	server.Close();
+	return r;
+#else
+	TRequestStatus started;
+	TServerStart start(started);
+	const TUidType serverUid(KNullUid, KNullUid, KServerUid3);
+#ifdef __WINS__
+	RLibrary lib;
+	TInt r = lib.Load(KIoServerName, serverUid);
+	if (r != KErrNone)
+		{
+		return r;
+		}
+	TLibraryFunction ordinal1 = lib.Lookup(1);
+	TThreadFunction serverFunc = reinterpret_cast<TThreadFunction>(ordinal1());
+	TName name(KIoServerName);
+	name.AppendNum(Math::Random(), EHex);
+	RThread server;
+	r=server.Create(name, serverFunc,
+					KIoStackSize,
+					&start, &lib, NULL,
+					KIoInitHeapSize, KIoMaxHeapSize, EOwnerProcess);
+	lib.Close();
+#else
+	RProcess server;
+	TInt r=server.Create(KIoServerName, start.AsCommand(), serverUid);
+#endif
+	if (r != KErrNone)
+		{
+		return r;
+		}
+	TRequestStatus died;
+	server.Logon(died);
+	if (died != KRequestPending)
+		{
+		User::WaitForRequest(died);
+		server.Kill(0);
+		server.Close();
+		return died.Int();
+		}
+	server.Resume();
+	User::WaitForRequest(started, died);
+	if (started == KRequestPending)
+		{
+		server.Close();
+		return died.Int();
+		}
+	server.LogonCancel(died);
+	server.Close();
+	User::WaitForRequest(died);
+	return KErrNone;
+#endif // EKA2
+	}
+
+#ifndef EKA2
+TInt E32Dll(TDllReason)
+	{
+	return 0;
+	}
+#endif
+
+
+//
+// RIoSession.
+//
+
+EXPORT_C TInt RIoSession::Connect()
+	{
+	TInt retry = 2;
+	for (;;)
+		{
+		TInt r = CreateSession(KIoServerName, TVersion(0,0,0));
+		if ((r != KErrNotFound) && (r != KErrServerTerminated))
+			{
+			return r;
+			}
+		if (--retry == 0)
+			{
+			return r;
+			}
+		r = StartServer();
+		if ((r != KErrNone) && (r != KErrAlreadyExists))
+			{
+			return r;
+			}
+		}
+	}
+	
+EXPORT_C void RIoSession::ConnectL()
+	{
+	User::LeaveIfError(Connect());
+	}
+
+EXPORT_C TInt RIoSession::SetObjectName(TInt aHandle, const TDesC& aName)
+	{
+#ifdef EKA2
+	return SendReceive(EIoSetObjectName, TIpcArgs(aHandle, &aName));
+#else
+	TInt p[4];
+	p[0] = aHandle;
+	p[1] = (TInt)&aName;
+	return SendReceive(EIoSetObjectName, &p[0]);
+#endif
+	}
+
+EXPORT_C void RIoSession::SetObjectNameL(TInt aHandle, const TDesC& aName)
+	{
+	User::LeaveIfError(SetObjectName(aHandle, aName));
+	}
+	
+EXPORT_C TInt RIoSession::FindFirstHandle(RIoHandle::TType aType, const TDesC& aMatchString, TInt& aFoundHandle, TName& aName)
+	{
+#ifdef EKA2
+	TPckg<TInt> foundBuf(aFoundHandle);
+	return SendReceive(EIoFindFirstHandle, TIpcArgs(aType, &aMatchString, &foundBuf, &aName));
+#else
+	TInt p[4];
+	p[0] = aType;
+	p[1] = &aMatchString;
+	p[2] = &aFoundHandle;
+	p[3] = &aName;
+	return SendReceive(EIoFindFirstHandle, &p[0]);
+#endif
+	}
+	
+EXPORT_C TInt RIoSession::FindNextHandle(TInt& aFoundHandle, TName& aName)
+	{
+#ifdef EKA2
+	TPckg<TInt> foundBuf(aFoundHandle);
+	return SendReceive(EIoFindNextHandle, TIpcArgs(&foundBuf, &aName));
+#else
+	TInt p[4];
+	p[0] = &aFoundHandle;
+	p[1] = &aName;
+	return SendReceive(EIoFindNextHandle, &p[0]);
+#endif
+	}
+
+
+//
+// RIoHandle.
+//
+
+EXPORT_C TInt RIoHandle::OpenFoundHandle(RIoSession& aSession, TInt aFoundHandle)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoOpenFoundHandle, TIpcArgs(aFoundHandle));
+#else
+	TInt p[4];
+	p[0] = aFoundHandle;
+	return CreateSubSession(aSession, EIoOpenFoundHandle, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoHandle::OpenFoundHandleL(RIoSession& aSession, TInt aFoundHandle)
+	{
+	User::LeaveIfError(OpenFoundHandle(aSession, aFoundHandle));
+	}
+
+EXPORT_C void RIoHandle::Close()
+	{
+	CloseSubSession(EIoHandleClose);
+	}
+
+EXPORT_C TInt RIoHandle::IsType(TType aType) const
+	{
+#ifdef EKA2
+	return SendReceive(EIoHandleIsType, TIpcArgs(aType));
+#else
+	TInt p[4];
+	p[0] = (TInt)aType;
+	return SendReceive(EIoHandleIsType, &p[0]);
+#endif
+	
+	}
+	
+EXPORT_C TBool RIoHandle::IsTypeL(TType aType) const
+	{
+	return User::LeaveIfError(IsType(aType));
+	}
+	
+EXPORT_C TInt RIoHandle::ObjectName(TDes& aName) const
+	{
+#ifdef EKA2
+	return SendReceive(EIoHandleGetName, TIpcArgs(&aName));
+#else
+	TInt p[4];
+	p[0] = &aName;
+	return SendReceive(EIoHandleGetName, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoHandle::ObjectNameL(TDes& aName) const
+	{
+	User::LeaveIfError(ObjectName(aName));
+	}
+	
+EXPORT_C TInt RIoHandle::Equals(const RIoHandle& aNother) const
+	{
+#ifdef EKA2
+	return SendReceive(EIoHandleEquals, TIpcArgs(aNother.SubSessionHandle()));
+#else
+	TInt p[4];
+	p[0] = (TInt)aNother.SubSessionHandle();
+	return SendReceive(EIoHandleEquals, &p[0]);
+#endif
+	}
+	
+EXPORT_C TBool RIoHandle::EqualsL(const RIoHandle& aNother) const
+	{
+	return User::LeaveIfError(Equals(aNother));
+	}
+
+EXPORT_C RIoSession RIoHandle::Session() const
+	{
+	RSessionBase session = RSubSessionBase::Session();
+	return static_cast<RIoSession&>(session);
+	}
+
+
+//
+// RIoReadWriteHandle.
+//
+
+EXPORT_C TInt RIoReadWriteHandle::SetMode(TMode aMode)
+	{
+#ifdef EKA2
+	return SendReceive(EIoSetReadWriteMode, TIpcArgs(aMode));
+#else
+	TInt p[4];
+	p[0] = (TInt)aMode;
+	return SendReceive(EIoSetReadWriteMode, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoReadWriteHandle::SetModeL(TMode aMode)
+	{
+	User::LeaveIfError(SetMode(aMode));
+	}
+
+EXPORT_C TInt RIoReadWriteHandle::SetOwner(TThreadId aOwningThread)
+	{
+#ifdef EKA2
+	return SendReceive(EIoHandleSetOwner, TIpcArgs(aOwningThread));
+#else
+	TInt p[4];
+	p[0] = aOwningThread;
+	return SendReceive(EIoHandleSetOwner, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoReadWriteHandle::SetOwnerL(TThreadId aOwningThread)
+	{
+	User::LeaveIfError(SetOwner(aOwningThread));
+	}
+
+EXPORT_C TInt RIoReadWriteHandle::SetUnderlyingConsole(RIoConsole& aConsole)
+	{
+#ifdef EKA2
+	return SendReceive(EIoHandleSetUnderlyingConsole, TIpcArgs(aConsole.SubSessionHandle()));
+#else
+	TInt p[4];
+	p[0] = aConsole.SubSessionHandle();
+	return SendReceive(EIoHandleSetUnderlyingConsole, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoReadWriteHandle::SetUnderlyingConsoleL(RIoConsole& aConsole)
+	{
+	User::LeaveIfError(SetUnderlyingConsole(aConsole));
+	}
+
+EXPORT_C TInt RIoReadWriteHandle::AttachedToConsole() const
+	{
+#ifdef EKA2
+	return SendReceive(EIoHandleAttachedToConsole);
+#else
+	return SendReceive(EIoHandleAttachedToConsole, NULL);
+#endif
+	}
+	
+EXPORT_C TBool RIoReadWriteHandle::AttachedToConsoleL() const
+	{
+	return User::LeaveIfError(AttachedToConsole());
+	}
+
+//
+// RIoReadHandle.
+//
+
+EXPORT_C TInt RIoReadHandle::Create(RIoSession& aSession)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoCreateReader);
+#else
+	return CreateSubSession(aSession, EIoCreateReader, NULL);
+#endif
+	}
+	
+EXPORT_C void RIoReadHandle::CreateL(RIoSession& aSession)
+	{
+	User::LeaveIfError(Create(aSession));
+	}
+
+EXPORT_C TInt RIoReadHandle::Open(RIoSession& aSession)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoOpenReaderByThreadId);
+#else
+	return CreateSubSession(aSession, EIoOpenReaderByThreadId, NULL);
+#endif
+	}
+	
+EXPORT_C void RIoReadHandle::OpenL(RIoSession& aSession)
+	{
+	User::LeaveIfError(Open(aSession));
+	}
+
+EXPORT_C TInt RIoReadHandle::Open(RIoSession& aSession, TThreadId aThreadId)
+	{
+	TPckgBuf<TThreadId> threadIdPckg(aThreadId);
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoOpenReaderByExplicitThreadId, TIpcArgs(&threadIdPckg));
+#else
+	TInt p[4];
+	p[0] = &threadIdPckg;
+	return CreateSubSession(aSession, EIoOpenReaderByExplicitThreadId, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoReadHandle::OpenL(RIoSession& aSession, TThreadId aThreadId)
+	{
+	User::LeaveIfError(Open(aSession, aThreadId));
+	}
+
+EXPORT_C TInt RIoReadHandle::Duplicate(RIoReadHandle& aReadHandle)
+	{
+#ifdef EKA2
+	return SendReceive(EIoDuplicateReader, TIpcArgs(aReadHandle.SubSessionHandle()));
+#else
+	TInt p[4];
+	p[0] = aReadHandle.SubSessionHandle();
+	return SendReceive(EIoDuplicateReader, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoReadHandle::DuplicateL(RIoReadHandle& aReadHandle)
+	{
+	User::LeaveIfError(Duplicate(aReadHandle));
+	}
+
+EXPORT_C TInt RIoReadHandle::DuplicateHandleFromThread(TThreadId aThreadId)
+	{
+	return SendReceive(EIoDuplicateReaderHandleFromThread, TIpcArgs(TUint(aThreadId)));
+	}
+
+EXPORT_C TInt RIoReadHandle::SetReadMode(TReadMode aMode)
+	{
+#ifdef EKA2
+	return SendReceive(EIoSetReadMode, TIpcArgs(aMode));
+#else
+	TInt p[4];
+	p[0] = (TInt)aMode;
+	return SendReceive(EIoSetReadMode, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoReadHandle::SetReadModeL(TReadMode aMode)
+	{
+	User::LeaveIfError(SetReadMode(aMode));
+	}
+
+EXPORT_C TInt RIoReadHandle::SetToForeground()
+	{
+#ifdef EKA2
+	return SendReceive(EIoSetReaderToForeground);
+#else
+	return SendReceive(EIoSetReaderToForeground, NULL);
+#endif
+	}
+
+EXPORT_C void RIoReadHandle::SetToForegroundL()
+	{
+	User::LeaveIfError(SetToForeground());
+	}
+
+EXPORT_C TInt RIoReadHandle::Read(TDes& aDes)
+	{
+#ifdef EKA2
+	return SendReceive(EIoRead, TIpcArgs(&aDes));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aDes;
+	return SendReceive(EIoRead, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoReadHandle::ReadL(TDes& aDes)
+	{
+	User::LeaveIfError(Read(aDes));
+	}
+
+EXPORT_C void RIoReadHandle::Read(TDes& aDes, TRequestStatus& aStatus)
+	{
+#ifdef EKA2
+	return SendReceive(EIoRead, TIpcArgs(&aDes), aStatus);
+#else
+	TInt p[4];
+	p[0] = (TInt)&aDes;
+	SendReceive(EIoRead, &p[0], aStatus);
+#endif
+	}
+
+EXPORT_C TInt RIoReadHandle::SetLineSeparator(const TDesC& aSeparator)
+	{
+#ifdef EKA2
+	return SendReceive(EIoSetLineSeparator, TIpcArgs(&aSeparator));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aSeparator;
+	return SendReceive(EIoSetLineSeparator, &p[0]);
+#endif
+	}
+
+EXPORT_C void RIoReadHandle::SetLineSeparatorL(const TDesC& aSeparator)
+	{
+	User::LeaveIfError(SetLineSeparator(aSeparator));
+	}
+
+EXPORT_C void RIoReadHandle::ReadCancel()
+	{
+#ifdef EKA2
+	SendReceive(EIoReadCancel);
+#else
+	SendReceive(EIoReadCancel, NULL);
+#endif
+	}
+
+EXPORT_C TInt RIoReadHandle::IsForeground() const
+	{
+#ifdef EKA2
+	return SendReceive(EIoIsForegroundReader);
+#else
+	return SendReceive(EIoIsForegroundReader, NULL);
+#endif
+	}
+
+EXPORT_C TBool RIoReadHandle::IsForegroundL() const
+	{
+	return User::LeaveIfError(IsForeground());
+	}
+
+EXPORT_C void RIoReadHandle::NotifyChange(TPckgBuf<TUint>& aChangeType, TRequestStatus& aStatus)
+	{
+#ifdef EKA2
+	SendReceive(EIoReadHandleNotifyChange, TIpcArgs(&aChangeType), aStatus);
+#else
+	TInt p[4];
+	p[0] = (TInt)&aChangeType;;
+	SendReceive(EIoReadHandleNotifyChange, &p[0], aStatus);
+#endif
+	}
+
+EXPORT_C void RIoReadHandle::CancelNotifyChange()
+	{
+	SendReceive(EIoReadHandleCancelNotifyChange);
+	}
+
+
+//
+// RIoConsoleReadHandle.
+//
+
+EXPORT_C RIoConsoleReadHandle::RIoConsoleReadHandle()
+	{
+	}
+
+EXPORT_C RIoConsoleReadHandle::RIoConsoleReadHandle(RIoReadHandle& aHandle)
+	{
+	*(RIoReadHandle*)this = aHandle; // Take a bit-wise copy of the base class.
+	}
+
+EXPORT_C RIoConsoleReadHandle RIoConsoleReadHandle::operator=(RIoReadHandle& aHandle)
+	{
+	*(RIoReadHandle*)this = aHandle; // Take a bit-wise copy of the base class.
+	return *this;
+	}
+
+EXPORT_C TUint RIoConsoleReadHandle::ReadKey()
+	{
+	TRequestStatus status;
+	WaitForKey(status);
+	User::WaitForRequest(status);
+	if (status.Int())
+		{
+		return EKeyNull;
+		}
+	return KeyCode();
+	}
+
+EXPORT_C void RIoConsoleReadHandle::WaitForKey(TRequestStatus& aStatus)
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleWaitForKey, TIpcArgs(&iKeyBuf), aStatus);
+#else
+	TInt p[4];
+	p[0] = (TInt)&iKeyBuf;
+	SendReceive(EIoConsoleWaitForKey, &p[0], aStatus);
+#endif
+	}
+
+EXPORT_C void RIoConsoleReadHandle::WaitForKeyCancel()
+	{
+#ifdef EKA2
+	SendReceive(EIoConsoleWaitForKeyCancel);
+#else
+	SendReceive(EIoConsoleWaitForKeyCancel, NULL);
+#endif
+	}
+
+EXPORT_C TUint RIoConsoleReadHandle::KeyCode() const
+	{
+	return iKeyBuf().iKeyCode;
+	}
+
+EXPORT_C TUint RIoConsoleReadHandle::KeyModifiers() const
+	{
+	return iKeyBuf().iModifiers;
+	}
+
+EXPORT_C TInt RIoConsoleReadHandle::CaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers)
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleCaptureKey, TIpcArgs(aKeyCode, aModifierMask, aModifiers));
+#else
+	TInt p[4];
+	p[0] = aKeyCode;
+	p[1] = aModifierMask;
+	p[2] = aModifiers;
+	return SendReceive(EIoConsoleCaptureKey, &p[0]);
+#endif
+	}
+
+EXPORT_C void RIoConsoleReadHandle::CaptureKeyL(TUint aKeyCode, TUint aModifierMask, TUint aModifiers)
+	{
+	User::LeaveIfError(CaptureKey(aKeyCode, aModifierMask, aModifiers));
+	}
+
+EXPORT_C TInt RIoConsoleReadHandle::CancelCaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers)
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleCancelCaptureKey, TIpcArgs(aKeyCode, aModifierMask, aModifiers));
+#else
+	TInt p[4];
+	p[0] = aKeyCode;
+	p[1] = aModifierMask;
+	p[2] = aModifiers;
+	return SendReceive(EIoConsoleCancelCaptureKey, &p[0]);
+#endif
+	}
+
+EXPORT_C TInt RIoConsoleReadHandle::CaptureAllKeys()
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleCaptureAllKeys);
+#else
+	return SendReceive(EIoConsoleCaptureAllKeys, NULL);
+#endif
+	}
+	
+EXPORT_C void RIoConsoleReadHandle::CaptureAllKeysL()
+	{
+	User::LeaveIfError(CaptureAllKeys());
+	}
+
+EXPORT_C TInt RIoConsoleReadHandle::CancelCaptureAllKeys()
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleCancelCaptureAllKeys);
+#else
+	return SendReceive(EIoConsoleCancelCaptureAllKeys, NULL);
+#endif
+	}
+
+
+//
+// RIoWriteHandle.
+//
+
+EXPORT_C TInt RIoWriteHandle::Create(RIoSession& aSession)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoCreateWriter);
+#else
+	return CreateSubSession(aSession, EIoCreateWriter, NULL);
+#endif
+	}
+	
+EXPORT_C void RIoWriteHandle::CreateL(RIoSession& aSession)
+	{
+	User::LeaveIfError(Create(aSession));
+	}
+
+EXPORT_C TInt RIoWriteHandle::Open(RIoSession& aSession)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoOpenWriterByThreadId);
+#else
+	return CreateSubSession(aSession, EIoOpenWriterByThreadId, NULL);
+#endif
+	}
+	
+EXPORT_C void RIoWriteHandle::OpenL(RIoSession& aSession)
+	{
+	User::LeaveIfError(Open(aSession));
+	}
+
+EXPORT_C TInt RIoWriteHandle::Open(RIoSession& aSession, TThreadId aThreadId)
+	{
+	TPckgBuf<TThreadId> threadIdPckg(aThreadId);
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoOpenWriterByExplicitThreadId, TIpcArgs(&threadIdPckg));
+#else
+	TInt p[4];
+	p[0] = &threadIdPckg;
+	return CreateSubSession(aSession, EIoOpenWriterByExplicitThreadId, &p[0]);
+#endif
+	}
+
+EXPORT_C void RIoWriteHandle::OpenL(RIoSession& aSession, TThreadId aThreadId)
+	{
+	User::LeaveIfError(Open(aSession, aThreadId));
+	}
+
+EXPORT_C TInt RIoWriteHandle::Duplicate(RIoWriteHandle& aWriteHandle)
+	{
+#ifdef EKA2
+	return SendReceive(EIoDuplicateWriter, TIpcArgs(aWriteHandle.SubSessionHandle()));
+#else
+	TInt p[4];
+	p[0] = aWriteHandle.SubSessionHandle();
+	return SendReceive(EIoDuplicateWriter, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoWriteHandle::DuplicateL(RIoWriteHandle& aWriteHandle)
+	{
+	User::LeaveIfError(Duplicate(aWriteHandle));
+	}
+
+EXPORT_C TInt RIoWriteHandle::DuplicateHandleFromThread(TThreadId aThreadId)
+	{
+	return SendReceive(EIoDuplicateWriterHandleFromThread, TIpcArgs(TUint(aThreadId)));
+	}
+
+EXPORT_C TInt RIoWriteHandle::Write(const TDesC& aDes)
+	{
+#ifdef EKA2
+	return SendReceive(EIoWrite, TIpcArgs(&aDes));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aDes;
+	return SendReceive(EIoWrite, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoWriteHandle::WriteL(const TDesC& aDes)
+	{
+	User::LeaveIfError(Write(aDes));
+	}
+
+EXPORT_C void RIoWriteHandle::Write(const TDesC& aDes, TRequestStatus& aStatus)
+	{
+#ifdef EKA2
+	return SendReceive(EIoWrite, TIpcArgs(&aDes), aStatus);
+#else
+	TInt p[4];
+	p[0] = (TInt)&aDes;
+	SendReceive(EIoWrite, &p[0], aStatus);
+#endif
+	}
+
+EXPORT_C void RIoWriteHandle::WriteCancel()
+	{
+#ifdef EKA2
+	SendReceive(EIoWriteCancel);
+#else
+	SendReceive(EIoWriteCancel, NULL);
+#endif
+	}
+
+
+//
+// RIoConsoleWriteHandle.
+//
+
+EXPORT_C RIoConsoleWriteHandle::RIoConsoleWriteHandle()
+	{
+	}
+
+EXPORT_C RIoConsoleWriteHandle::RIoConsoleWriteHandle(RIoWriteHandle& aHandle)
+	{
+	*(RIoWriteHandle*)this = aHandle; // Take a bit-wise copy of the base class.
+	}
+
+EXPORT_C RIoConsoleWriteHandle RIoConsoleWriteHandle::operator=(RIoWriteHandle& aHandle)
+	{
+	*(RIoWriteHandle*)this = aHandle; // Take a bit-wise copy of the base class.
+	return *this;
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::GetCursorPos(TPoint& aPos) const
+	{
+	TPckg<TPoint> posPckg(aPos);
+#ifdef EKA2
+	TInt err = SendReceive(EIoConsoleCursorPos, TIpcArgs(&posPckg));
+#else
+	TInt p[4];
+	p[0] = (TInt)&posPckg;
+	TInt err = SendReceive(EIoConsoleCursorPos, &p[0]);
+#endif
+	return err;
+	}
+	
+EXPORT_C TPoint RIoConsoleWriteHandle::GetCursorPosL() const
+	{
+	TPoint pos;
+	User::LeaveIfError(GetCursorPos(pos));
+	return pos;
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	TPckg<TPoint> posPckg(aPoint);
+#ifdef EKA2
+	return SendReceive(EIoConsoleSetCursorPosAbs, TIpcArgs(&posPckg));
+#else
+	TInt p[4];
+	p[0] = (TInt)&posPckg;
+	return SendReceive(EIoConsoleSetCursorPosAbs, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoConsoleWriteHandle::SetCursorPosAbsL(const TPoint& aPos)
+	{
+	User::LeaveIfError(SetCursorPosAbs(aPos));
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::SetCursorPosRel(const TPoint& aPoint)
+	{
+	TPckg<TPoint> posPckg(aPoint);
+#ifdef EKA2
+	return SendReceive(EIoConsoleSetCursorPosRel, TIpcArgs(&posPckg));
+#else
+	TInt p[4];
+	p[0] = (TInt)&posPckg;
+	return SendReceive(EIoConsoleSetCursorPosRel, &p[0]);
+#endif
+	}
+
+EXPORT_C void RIoConsoleWriteHandle::SetCursorPosRelL(const TPoint& aPos)
+	{
+	User::LeaveIfError(SetCursorPosRel(aPos));
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::SetCursorHeight(TInt aPercentage)
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleSetCursorHeight, TIpcArgs(aPercentage));
+#else
+	TInt p[4];
+	p[0] = aPercentage;
+	return SendReceive(EIoConsoleSetCursorHeight, &p[0]);
+#endif
+	}
+
+EXPORT_C void RIoConsoleWriteHandle::SetCursorHeightL(TInt aPercentage)
+	{
+	User::LeaveIfError(SetCursorHeight(aPercentage));
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::SetTitle(const TDesC& aTitle)
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleSetTitle, TIpcArgs(&aTitle));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aTitle;
+	return SendReceive(EIoConsoleSetTitle, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoConsoleWriteHandle::SetTitleL(const TDesC& aTitle)
+	{
+	User::LeaveIfError(SetTitle(aTitle));
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::ClearScreen()
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleClearScreen);
+#else
+	return SendReceive(EIoConsoleClearScreen, NULL);
+#endif
+	}
+	
+EXPORT_C void RIoConsoleWriteHandle::ClearScreenL()
+	{
+	User::LeaveIfError(ClearScreen());
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::ClearToEndOfLine()
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleClearToEndOfLine);
+#else
+	return SendReceive(EIoConsoleClearToEndOfLine, NULL);
+#endif
+	}
+	
+EXPORT_C void RIoConsoleWriteHandle::ClearToEndOfLineL()
+	{
+	User::LeaveIfError(ClearToEndOfLine());
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::GetScreenSize(TSize& aSize) const
+	{
+	TPckg<TSize> sizePckg(aSize);
+#ifdef EKA2
+	TInt err = SendReceive(EIoConsoleScreenSize, TIpcArgs(&sizePckg));
+#else
+	TInt p[4];
+	p[0] = (TInt)&sizePckg;
+	TInt err = SendReceive(EIoConsoleScreenSize, &p[0]);
+#endif
+	return err;
+	}
+	
+EXPORT_C TSize RIoConsoleWriteHandle::GetScreenSizeL() const
+	{
+	TSize size;
+	User::LeaveIfError(GetScreenSize(size));
+	return size;
+	}
+	
+EXPORT_C TInt RIoConsoleWriteHandle::SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor)
+	{
+#ifdef EKA2
+	TInt err = SendReceive(EIoConsoleSetAttributes, TIpcArgs(aAttributes, aForegroundColor, aBackgroundColor));
+#else
+	TInt p[4];
+	p[0] = aAttributes;
+	p[1] = aForegroundColor;
+	p[2] = aBackgroundColor;
+	TInt err = SendReceive(EIoConsoleSetAttributes, &p[0]);
+#endif
+	return err;
+	}
+
+EXPORT_C void RIoConsoleWriteHandle::SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor)
+	{
+	User::LeaveIfError(SetAttributes(aAttributes, aForegroundColor, aBackgroundColor));
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::SetAttributes(const ConsoleAttributes::TAttributes& aAttributes)
+	{
+	return SetAttributes(aAttributes.iAttributes, aAttributes.iForegroundColor, aAttributes.iBackgroundColor);
+	}
+
+EXPORT_C TInt RIoConsoleWriteHandle::SetIsStdErr(TBool aFlag)
+	{
+	return SendReceive(EIoSetIsStdErr, TIpcArgs(aFlag));
+	}
+
+
+//
+// RIoEndPoint.
+//
+
+EXPORT_C TInt RIoEndPoint::Attach(RIoReadHandle& aReader, TReadMode aMode)
+	{
+#ifdef EKA2
+	return SendReceive(EIoEndPointAttachReader, TIpcArgs(aReader.SubSessionHandle(), aMode));
+#else
+	TInt p[4];
+	p[0] = (TInt)aReader.SubSessionHandle();
+	p[1] = aMode;
+	return SendReceive(EIoEndPointAttachReader, &p[0]);
+#endif
+	}
+
+EXPORT_C void RIoEndPoint::AttachL(RIoReadHandle& aReader, TReadMode aMode)
+	{
+	User::LeaveIfError(Attach(aReader, aMode));
+	}
+
+EXPORT_C TInt RIoEndPoint::Attach(RIoWriteHandle& aWriter)
+	{
+#ifdef EKA2
+	return SendReceive(EIoEndPointAttachWriter, TIpcArgs(aWriter.SubSessionHandle()));
+#else
+	TInt p[4];
+	p[0] = (TInt)aWriter.SubSessionHandle();
+	return SendReceive(EIoEndPointAttachWriter, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoEndPoint::AttachL(RIoWriteHandle& aWriter)
+	{
+	User::LeaveIfError(Attach(aWriter));
+	}
+
+EXPORT_C TInt RIoEndPoint::SetForegroundReadHandle(RIoReadHandle& aReader)
+	{
+#ifdef EKA2
+	return SendReceive(EIoEndPointSetForegroundReadHandle, TIpcArgs(aReader.SubSessionHandle()));
+#else
+	TInt p[4];
+	p[0] = (TInt)aReader.SubSessionHandle();
+	return SendReceive(EIoEndPointSetForegroundReadHandle, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoEndPoint::SetForegroundReadHandleL(RIoReadHandle& aReader)
+	{
+	User::LeaveIfError(SetForegroundReadHandle(aReader));
+	}
+
+EXPORT_C RIoEndPoint::RIoEndPoint()
+	{
+	}
+
+
+//
+// RIoPipe.
+//
+
+EXPORT_C TInt RIoPipe::Create(RIoSession& aSession)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoCreatePipe);
+#else
+	return CreateSubSession(aSession, EIoCreatePipe, NULL);
+#endif
+	}
+
+EXPORT_C void RIoPipe::CreateL(RIoSession& aSession)
+	{
+	User::LeaveIfError(Create(aSession));
+	}
+
+//
+// RIoConsole.
+//
+
+EXPORT_C TInt RIoConsole::Create(RIoSession& aSession, const TDesC& aTitle, const TSize& aSize, TUint aOptions)
+	{
+	return Create(aSession, KNullDesC, aTitle, aSize, aOptions);
+	}
+	
+EXPORT_C void RIoConsole::CreateL(RIoSession& aSession, const TDesC& aTitle, const TSize& aSize, TUint aOptions)
+	{
+	User::LeaveIfError(Create(aSession, aTitle, aSize, aOptions));
+	}
+
+EXPORT_C TInt RIoConsole::Create(RIoSession& aSession, const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, TUint aOptions)
+	{
+	TConsoleCreateParams params;
+	params.iSize = aSize;
+	params.iUnderlyingConsoleHandle = KNullHandle;
+	params.iOptions = aOptions;
+	TPckg<TConsoleCreateParams> paramsPckg(params);
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoCreateConsole, TIpcArgs(&aTitle, &paramsPckg, &aImplementation));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aTitle;
+	p[1] = (TInt)&paramsPckg;
+	p[2] = (TInt)&aImplementation;
+	return CreateSubSession(aSession, EIoCreateConsole, &p[0]);
+#endif
+	}
+
+EXPORT_C TInt RIoConsole::Create(RIoSession& aSession, const TDesC& aImplementation, RIoConsole& aUnderlyingConsole, const TDesC& aTitle, const TSize& aSize, TUint aOptions)
+	{
+	TConsoleCreateParams params;
+	params.iSize = aSize;
+	params.iUnderlyingConsoleHandle = aUnderlyingConsole.SubSessionHandle();
+	params.iOptions = aOptions;
+	TPckg<TConsoleCreateParams> paramsPckg(params);
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoCreateConsole, TIpcArgs(&aTitle, &paramsPckg, &aImplementation));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aTitle;
+	p[1] = (TInt)&paramsPckg;
+	p[2] = (TInt)&aImplementation;
+	return CreateSubSession(aSession, EIoCreateConsole, &p[0]);
+#endif
+	}
+
+EXPORT_C void RIoConsole::CreateL(RIoSession& aSession, const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, TUint aOptions)
+	{
+	User::LeaveIfError(Create(aSession, aImplementation, aTitle, aSize, aOptions));
+	}
+
+EXPORT_C void RIoConsole::CreateL(RIoSession& aSession, const TDesC& aImplementation, RIoConsole& aUnderlyingConsole, const TDesC& aTitle, const TSize& aSize, TUint aOptions)
+	{
+	User::LeaveIfError(Create(aSession, aImplementation, aUnderlyingConsole, aTitle, aSize, aOptions));
+	}
+
+EXPORT_C TInt RIoConsole::Open(RIoSession& aSession, RIoHandle& aHandle)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoOpenConsole, TIpcArgs(aHandle.SubSessionHandle()));
+#else
+	TInt p[4];
+	p[0] = aHandle.SubSessionHandle();
+	return CreateSubSession(aSession, EIoOpenConsole, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoConsole::OpenL(RIoSession& aSession, RIoHandle& aHandle)
+	{
+	User::LeaveIfError(Open(aSession, aHandle));
+	}
+
+EXPORT_C TInt RIoConsole::Implementation(TDes& aDes) const
+	{
+#ifdef EKA2
+	return SendReceive(EIoConsoleImplementation, TIpcArgs(&aDes));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aDes;
+	return SendReceive(EIoConsoleImplementation, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoConsole::ImplementationL(TDes& aDes) const
+	{
+	User::LeaveIfError(Implementation(aDes));
+	}
+
+//
+// RIoPersistentConsole.
+//
+EXPORT_C TInt RIoPersistentConsole::Create(RIoSession& aSession, const TDesC& aName, const TDesC& aTitle)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoCreatePersistentConsole, TIpcArgs(&aName, &aTitle));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aName;
+	p[1] = (TInt)&aTitle;
+	return CreateSubSession(aSession, EIoCreatePersistentConsole, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoPersistentConsole::CreateL(RIoSession& aSession, const TDesC& aName, const TDesC& aTitle)
+	{
+	User::LeaveIfError(Create(aSession, aName, aTitle));
+	}
+	
+EXPORT_C TInt RIoPersistentConsole::OpenByName(RIoSession& aSession, const TDesC& aName)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoOpenPersistentConsoleByName, TIpcArgs(&aName));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aTitle;
+	return CreateSubSession(aSession, EIoOpenPersistentConsoleByName, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoPersistentConsole::OpenByNameL(RIoSession& aSession, const TDesC& aName)
+	{
+	User::LeaveIfError(OpenByName(aSession, aName));
+	}
+
+EXPORT_C TInt RIoPersistentConsole::AttachReader(RIoEndPoint& aEndPoint, TCloseBehaviour aCloseBehaviour)
+	{
+#ifdef EKA2
+	return SendReceive(EIoPersistentConsoleAttachReadEndPoint, TIpcArgs(aEndPoint.SubSessionHandle(), aCloseBehaviour));
+#else
+	TInt p[4];
+	p[0] = aEndPoint.Handle();
+	p[1] = aCloseBehaviour;
+	return SendReceive(EIoPersistentConsoleAttachReadEndPoint, &p[0]);
+#endif
+	
+	}
+	
+EXPORT_C void RIoPersistentConsole::AttachReaderL(RIoEndPoint& aEndPoint, TCloseBehaviour aCloseBehaviour)
+	{
+	User::LeaveIfError(AttachReader(aEndPoint, aCloseBehaviour));
+	}
+	
+EXPORT_C void RIoPersistentConsole::DetachReader()
+	{
+#ifdef EKA2
+	SendReceive(EIoPersistentConsoleDetachReadEndPoint, TIpcArgs());
+#else
+	TInt p[4];
+	SendReceive(EIoPersistentConsoleDetachReadEndPoint, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoPersistentConsole::NotifyReaderDetach(TRequestStatus& aStatus)
+	{
+	SendReceive(EIoPersistentConsoleNotifyReadDetach, aStatus);
+	}
+	
+EXPORT_C void RIoPersistentConsole::CancelNotifyReaderDetach(TRequestStatus& aStatus)
+	{
+#ifdef EKA2
+	SendReceive(EIoPersistentConsoleCancelNotifyReadDetach, TIpcArgs(&aStatus));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aStatus;
+	SendReceive(EIoPersistentConsoleCancelNotifyReadDetach, &p[0]);
+#endif
+	}
+
+EXPORT_C TInt RIoPersistentConsole::AttachWriter(RIoEndPoint& aEndPoint, TCloseBehaviour aCloseBehaviour)
+	{
+#ifdef EKA2
+	return SendReceive(EIoPersistentConsoleAttachWriteEndPoint, TIpcArgs(aEndPoint.SubSessionHandle(), aCloseBehaviour));
+#else
+	TInt p[4];
+	p[0] = aEndPoint.Handle();
+	p[1] = aCloseBehaviour;
+	return SendReceive(EIoPersistentConsoleAttachWriteEndPoint, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoPersistentConsole::AttachWriterL(RIoEndPoint& aEndPoint, TCloseBehaviour aCloseBehaviour)
+	{
+	User::LeaveIfError(AttachWriter(aEndPoint, aCloseBehaviour));
+	}
+	
+EXPORT_C void RIoPersistentConsole::DetachWriter()
+	{
+#ifdef EKA2
+	SendReceive(EIoPersistentConsoleDetachWriteEndPoint, TIpcArgs());
+#else
+	TInt p[4];
+	SendReceive(EIoPersistentConsoleDetachWriteEndPoint, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoPersistentConsole::NotifyWriterDetach(TRequestStatus& aStatus)
+	{
+	SendReceive(EIoPersistentConsoleNotifyWriteDetach, aStatus);
+	}
+	
+EXPORT_C void RIoPersistentConsole::CancelNotifyWriterDetach(TRequestStatus& aStatus)
+	{
+#ifdef EKA2
+	SendReceive(EIoPersistentConsoleCancelNotifyWriteDetach, TIpcArgs(&aStatus));
+#else
+	TInt p[4];
+	p[0] = &aStatus;
+	SendReceive(EIoPersistentConsoleCancelNotifyWriteDetach, &p[0]);
+#endif
+	}
+	
+EXPORT_C TInt RIoPersistentConsole::GetAttachedReaderAndWriterNames(TName& aReaderName, TName& aWriterName)
+	{
+#ifdef EKA2
+	return SendReceive(EIoPersistentConsoleGetAttachedNames, TIpcArgs(&aReaderName, &aWriterName));
+#else
+	TInt p[4];
+	p[0] = &aReaderName;
+	p[1] = &aWriterName;
+	return SendReceive(EIoPersistentConsoleGetAttachedNames, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoPersistentConsole::GetAttachedReaderAndWriterNamesL(TName& aReaderName, TName& aWriterName)
+	{
+	User::LeaveIfError(GetAttachedReaderAndWriterNames(aReaderName, aWriterName));
+	}
+
+EXPORT_C TInt RIoPersistentConsole::GetCreator(TThreadId& aThreadId)
+	{
+	TPckg<TThreadId> theadPckg(aThreadId);
+#ifdef EKA2
+	return SendReceive(EIoPersistentConsoleGetCreatorThreadId, TIpcArgs(&theadPckg));
+#else
+	TInt p[4];
+	p[0] = &theadPckg;
+	return SendReceive(EIoPersistentConsoleGetCreatorThreadId, &p[0]);
+#endif
+	}
+	
+EXPORT_C TThreadId RIoPersistentConsole::GetCreatorL()
+	{
+	TThreadId id;
+	User::LeaveIfError(GetCreator(id));
+	return id;
+	}
+
+//
+// RIoFile.
+//
+
+EXPORT_C TInt RIoFile::Create(RIoSession& aSession, const TDesC& aFileName, TMode aMode)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoCreateFile, TIpcArgs(&aFileName, (TInt)aMode));
+#else
+	TInt p[4];
+	p[0] = (TInt)&aFileName;
+	p[1] = (TInt)aMode;
+	return CreateSubSession(aSession, EIoCreateFile, &p[0]);
+#endif
+	}
+	
+EXPORT_C void RIoFile::CreateL(RIoSession& aSession, const TDesC& aFileName, TMode aMode)
+	{
+	User::LeaveIfError(Create(aSession, aFileName,aMode));
+	}
+
+
+//
+// RIoNull.
+//
+
+EXPORT_C TInt RIoNull::Create(RIoSession& aSession)
+	{
+#ifdef EKA2
+	return CreateSubSession(aSession, EIoCreateNull);
+#else
+	return CreateSubSession(aSession, EIoCreateNull, NULL);
+#endif
+	}
+
+EXPORT_C void RIoNull::CreateL(RIoSession& aSession)
+	{
+	User::LeaveIfError(Create(aSession));
+	}
+
+//
+// TIoHandleSet
+//
+
+EXPORT_C TIoHandleSet::TIoHandleSet(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr)
+	: iIoSession(aIoSession), iStdin(aStdin), iStdout(aStdout), iStderr(aStderr), iSpare(0)
+	{
+	}
+
+EXPORT_C RIoSession& TIoHandleSet::IoSession() const
+	{
+	return iIoSession;
+	}
+
+EXPORT_C RIoReadHandle& TIoHandleSet::Stdin() const
+	{
+	return iStdin;
+	}
+
+EXPORT_C RIoWriteHandle& TIoHandleSet::Stdout() const
+	{
+	return iStdout;
+	}
+
+EXPORT_C RIoWriteHandle& TIoHandleSet::Stderr() const
+	{
+	return iStderr;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/client_command.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,445 @@
+// client_command.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/ltkutils.h>
+#include "command_base.h"
+
+namespace IoUtils
+	{
+
+_LIT(KNewLine, "\r\n");
+_LIT(KOutgoingMarker, ">");
+_LIT(KIncomingMarker, "<");
+
+
+//
+// CServerWatcher.
+//
+
+NONSHARABLE_CLASS(CServerWatcher) : public CActive
+	{
+public:
+	static CServerWatcher* NewL(const TDesC& aServerExeName, CClientBase& aClient);
+	~CServerWatcher();
+	void Kill(TInt aReason);
+private:
+	CServerWatcher(CClientBase& aClient);
+	void ConstructL(const TDesC& aServerExeName);
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	CClientBase& iClient;
+	RProcess iServerProcess;
+	};
+
+CServerWatcher* CServerWatcher::NewL(const TDesC& aServerExeName, CClientBase& aClient)
+	{
+	CServerWatcher* self = new(ELeave) CServerWatcher(aClient);
+	CleanupStack::PushL(self);
+	self->ConstructL(aServerExeName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CServerWatcher::~CServerWatcher()
+	{
+	Cancel();
+	iServerProcess.Close();
+	}
+
+void CServerWatcher::Kill(TInt aReason)
+	{
+	Cancel();
+	iServerProcess.Kill(aReason);
+	}
+
+CServerWatcher::CServerWatcher(CClientBase& aClient)
+	: CActive(CActive::EPriorityStandard), iClient(aClient)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CServerWatcher::ConstructL(const TDesC& aServerExeName)
+	{
+	_LIT(KWildCard, "*");
+	TName processName(aServerExeName);
+	processName.Append(KWildCard);
+	TFindProcess findProcess(processName);
+	TFullName name;
+	StaticLeaveIfErr(findProcess.Next(name), _L("Unable to find server process '%S'"), &aServerExeName);
+	StaticLeaveIfErr(iServerProcess.Open(findProcess), _L("Unable to open server process '%S'"), &aServerExeName);
+	if (findProcess.Next(name) != KErrNotFound)
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Found more than one instance of '%S'"), &aServerExeName);
+		}
+	iServerProcess.Logon(iStatus);
+	if (iStatus != KRequestPending)
+		{
+		User::WaitForRequest(iStatus);
+		StaticLeaveIfErr(KErrGeneral, _L("Failed to logon to '%S' - %d"), &aServerExeName, iStatus.Int());
+		}
+	SetActive();
+	}
+
+void CServerWatcher::RunL()
+	{
+	TExitCategoryName exitCategory(iServerProcess.ExitCategory());
+	iClient.HandleServerDeath(iServerProcess.ExitType(), iServerProcess.ExitReason(), exitCategory);
+	}
+
+void CServerWatcher::DoCancel()
+	{
+	iServerProcess.LogonCancel(iStatus);
+	}
+
+
+//
+// CServerReader.
+//
+
+NONSHARABLE_CLASS(CServerReader) : public CActive
+	{
+public:
+	static CServerReader* NewL(RIoReadHandle& aReadHandle, CClientBase& aClient);
+	~CServerReader();
+private:
+	CServerReader(RIoReadHandle& aReadHandle, CClientBase& aClient);
+	void ConstructL();
+	void Queue();
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	RIoReadHandle& iReadHandle;
+	CClientBase& iClient;
+	TBuf<0x200> iLine;
+	};
+
+CServerReader* CServerReader::NewL(RIoReadHandle& aReadHandle, CClientBase& aClient)
+	{
+	CServerReader* self = new(ELeave) CServerReader(aReadHandle, aClient);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CServerReader::~CServerReader()
+	{
+	Cancel();
+	}
+
+CServerReader::CServerReader(RIoReadHandle& aReadHandle, CClientBase& aClient)
+	: CActive(CActive::EPriorityStandard), iReadHandle(aReadHandle), iClient(aClient)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CServerReader::Queue()
+	{
+	iLine.Zero();
+	iReadHandle.Read(iLine, iStatus);
+	SetActive();
+	}
+
+void CServerReader::ConstructL()
+	{
+	iReadHandle.SetReadModeL(RIoReadHandle::ELine);
+	iReadHandle.SetLineSeparatorL(KNewLine());
+	Queue();
+	}
+
+void CServerReader::RunL()
+	{
+	TInt err = iStatus.Int();
+	if (err == KErrEof)
+		{
+		iClient.HandleServerReadComplete(KErrServerTerminated, iLine);
+		}
+	else
+		{
+		iClient.HandleServerReadComplete(err, iLine);
+		}
+	Queue();
+	}
+
+void CServerReader::DoCancel()
+	{
+	iReadHandle.ReadCancel();
+	}
+
+
+//
+// CServerWriter.
+//
+
+NONSHARABLE_CLASS(CServerWriter) : public CActive
+	{
+public:
+	static CServerWriter* NewL(RIoWriteHandle& aWriteHandle, CClientBase& aClient);
+	~CServerWriter();
+	void Write(const TDesC& aLine);
+private:
+	CServerWriter(RIoWriteHandle& aWriteHandle, CClientBase& aClient);
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	RIoWriteHandle& iWriteHandle;
+	CClientBase& iClient;
+	HBufC* iBuf;
+	};
+
+CServerWriter* CServerWriter::NewL(RIoWriteHandle& aWriteHandle, CClientBase& aClient)
+	{
+	return new(ELeave) CServerWriter(aWriteHandle, aClient);
+	}
+
+CServerWriter::~CServerWriter()
+	{
+	Cancel();
+	delete iBuf;
+	}
+
+CServerWriter::CServerWriter(RIoWriteHandle& aWriteHandle, CClientBase& aClient)
+	: CActive(CActive::EPriorityStandard), iWriteHandle(aWriteHandle), iClient(aClient)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CServerWriter::Write(const TDesC& aLine)
+	{
+	ASSERT(!IsActive());
+	TInt bufferRequired = aLine.Length();
+	TBool newLineRequired(EFalse);
+	if ((aLine.Length() < KNewLine().Length()) || (aLine.Right(KNewLine().Length()) != KNewLine))
+		{
+		newLineRequired = ETrue;
+		bufferRequired += KNewLine().Length();
+		}
+	if (iBuf && (iBuf->Des().MaxLength() < bufferRequired))
+		{
+		iBuf = iBuf->ReAllocL(bufferRequired);
+		}
+	else
+		{
+		iBuf = HBufC::NewL(bufferRequired);
+		}
+	TPtr ptr(iBuf->Des());
+	ptr.Copy(aLine);
+	if (newLineRequired)
+		{
+		ptr.Append(KNewLine);
+		}
+	iWriteHandle.Write(*iBuf, iStatus);
+	SetActive();
+	}
+
+void CServerWriter::RunL()
+	{
+	iClient.HandleServerWriteComplete(iStatus.Int());
+	}
+
+void CServerWriter::DoCancel()
+	{
+	iWriteHandle.WriteCancel();
+	}
+
+
+EXPORT_C CClientBase::CClientBase(TUint aFlags, const TDesC& aServerExeName, const TDesC& aPersistentConsoleName, const TDesC& aServerPrompt)
+	: CCommandBase(EManualComplete | aFlags), iServerExeName(aServerExeName), iPersistentConsoleName(aPersistentConsoleName), iServerPrompt(aServerPrompt)
+	{
+	}
+
+EXPORT_C CClientBase::~CClientBase()
+	{
+	delete iCommand;
+	delete iServerReader;
+	delete iServerWriter;
+	delete iServerWatcher;
+	iServerWritePipe.Close();
+	iServerWriteHandle.Close();
+	iServerReadPipe.Close();
+	iServerReadHandle.Close();
+	iPcons.Close();
+	iServerProcess.Close();
+	iLines.ResetAndDestroy();
+	}
+	
+_LIT(KWritePipeNameFmt, "%S client->server pipe");
+_LIT(KWriterNameFmt, "%S server writer");
+_LIT(KReadPipeNameFmt, "%S server->client pipe");
+_LIT(KReaderNameFmt, "%S server reader");
+
+EXPORT_C void CClientBase::DoRunL()
+	{
+	TInt err = iPcons.OpenByName(IoSession(), iPersistentConsoleName);
+	if (err==KErrNotFound)
+		{
+		if (iVerbose)
+			{
+			Printf(_L("'%S' not found, creating...\r\n"), &iPersistentConsoleName);
+			}
+		LeaveIfErr(iPcons.Create(IoSession(), iPersistentConsoleName, iPersistentConsoleName), _L("Couldn't create persistent console '%S'"), &iPersistentConsoleName);
+		TRAPL(iServerProcess.CreateL(iServerExeName, KNullDesC(), IoSession(), iPcons, &Env()), _L("Couldn't create server process"));
+		}
+	else
+		{
+		LeaveIfErr(err, _L("Cannot open persistent console '%S'"), &iPersistentConsoleName);
+		}
+
+	iServerWatcher = CServerWatcher::NewL(iServerExeName, *this);
+		
+	TName objName;		
+
+	iServerWritePipe.CreateL(IoSession());
+	objName.AppendFormat(KWritePipeNameFmt, &Name());
+	IoSession().SetObjectNameL(iServerWritePipe.SubSessionHandle(), objName);
+
+	iServerWriteHandle.CreateL(IoSession());
+	objName.Zero();
+	objName.AppendFormat(KWriterNameFmt, &Name());
+	IoSession().SetObjectNameL(iServerWriteHandle.SubSessionHandle(), objName);
+	iServerWriteHandle.SetModeL(RIoWriteHandle::EText);
+	iServerWritePipe.AttachL(iServerWriteHandle);
+	// attach the pcons reader to the other end of our server write pipe
+	LeaveIfErr(iPcons.AttachReader(iServerWritePipe, RIoPersistentConsole::EDetachOnHandleClose), _L("Cannot connect reader to persistent console %S"), &iPersistentConsoleName);
+	iServerWriter = CServerWriter::NewL(iServerWriteHandle, *this);
+
+	iServerReadPipe.CreateL(IoSession());
+	objName.Zero();
+	objName.AppendFormat(KReadPipeNameFmt, &Name());
+	IoSession().SetObjectNameL(iServerReadPipe.SubSessionHandle(), objName);
+	
+	iServerReadHandle.CreateL(IoSession());
+	objName.Zero();
+	objName.AppendFormat(KReaderNameFmt, &Name());
+	IoSession().SetObjectNameL(iServerReadHandle.SubSessionHandle(), objName);
+	iServerReadPipe.AttachL(iServerReadHandle, RIoEndPoint::EForeground);
+	// attach the pcons writer to the other end of our server read pipe
+	LeaveIfErr(iPcons.AttachWriter(iServerReadPipe, RIoPersistentConsole::EDetachOnHandleClose), _L("Cannot connect writer to persistent console %S"), &iPersistentConsoleName);
+	iServerReader = CServerReader::NewL(iServerReadHandle, *this);
+	
+	if (iServerProcess.Process().Handle() != KNullHandle && iServerProcess.Process().Handle() != RProcess().Handle())
+		{
+		// We created a new server process, but it's not yet been resumed.
+		iServerProcess.Detach(); // Note, iServerWatch has already logged onto the process so there's no need to use RChildProcess::Run.
+		iWaitingForServerPrompt = ETrue;
+		}
+	else
+		{
+		// The server was already running - no need to wait for a prompt, go ahead and write the command.
+		SendCommand();
+		}
+	}
+
+EXPORT_C void CClientBase::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KCommand, "command");
+
+	if (UsingCif()) // Test this dynamically for the time being because not all sub-classes have been migrated to CIFs.
+		{
+		aArguments.AppendStringL(iCommand, KCommand);
+		}
+	else
+		{
+		_LIT(KCommandDescription, "The command to run.");
+		aArguments.AppendStringL(iCommand, KCommand, KCommandDescription, KValueTypeFlagLast);
+		}
+	}
+
+EXPORT_C void CClientBase::HandleLeave(TInt aError)
+	{
+	CCommandBase::HandleLeave(aError);
+	}
+
+void CClientBase::HandleServerReadComplete(TInt aError, TDes& aLine)
+	{
+	if (aError == KErrEof)
+		{
+		Complete(KErrNone);
+		}
+	else if (aError)
+		{
+		iServerWatcher->Kill(KErrAbort);
+		Complete(aError, _L("Failed to read server response"));
+		}
+	else if (aLine == iServerPrompt)
+		{
+		if (iWaitingForServerPrompt)
+			{
+			iWaitingForServerPrompt = EFalse;
+			SendCommand();
+			}
+		else
+			{
+			TRAPD(err, HandleServerResponseL(iLines));
+			Complete(err);
+			}
+		}
+	else
+		{
+		if (iVerbose)
+			{
+			Write(KIncomingMarker);
+			Write(aLine);
+			}
+		if (!iWaitingForServerPrompt)
+			{
+			aLine.TrimRight();
+			HBufC* buf = aLine.AllocLC();
+			iLines.AppendL(buf);
+			CleanupStack::Pop(buf);
+			}
+		}
+	}
+
+void CClientBase::HandleServerWriteComplete(TInt aError)
+	{
+	if (aError)
+		{
+		iServerWatcher->Kill(KErrAbort);
+		Complete(aError, _L("Failed to write command to server"));
+		}
+	}
+
+void CClientBase::HandleServerDeath(TExitType aExitType, TInt aExitReason, const TDesC& aExitCategory)
+	{
+	if (aExitType == EExitPanic)
+		{
+		Complete(KErrServerTerminated, _L("Server '%S' PANIC - %S %d"), &iServerExeName, &aExitCategory, aExitReason);
+		}
+	else if (aExitReason)
+		{
+		Complete(aExitReason, _L("Server '%S' exitied abnormally"), &iServerExeName);
+		}
+	else
+		{
+		Complete();
+		}
+	}
+
+void CClientBase::SendCommand()
+	{
+	if (iVerbose)
+		{
+		Write(KOutgoingMarker);
+		Write(*iCommand);
+		Write(KNewLine);
+		}
+	iServerWriter->Write(*iCommand);
+	}
+
+	} // namespace IoUtils
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/command_base.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3838 @@
+// command_base.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "iocons.h"
+#include "ioutils.h"
+#include "command_base.h"
+#include <fshell/ltkutils.h>
+
+using namespace IoUtils;
+
+#define RETURN_IF_ERROR(x) {TInt _err = (x); if (_err<0) return _err;}
+
+//
+// Constants.
+//
+
+_LIT(KHelpName, "help");
+_LIT(KHelpDescription, "Display help.");
+_LIT(KOptConsole, "console");
+_LIT(KOptConsoleTitle, "console-title");
+_LIT(KOptConsoleSize, "console-size");
+_LIT(KOptPersistentConsole, "persistent-console");
+_LIT(KDllExt, ".dll");
+_LIT(KNewLine, "\r\n");
+
+const TUint KValueTypeUninitialized		= 0x0000ffff;
+const TUint KValueTypeFlagMultiple 		= 0x00010000;
+const TUint KValueTypeFlagMask     		= 0x0000ffff;
+const TUint KPublicFlagsMask			= 0x0000ffff;
+const TUint KPrivateFlagsMask			= 0xffff0000;
+
+
+//
+// Misc.
+//
+
+void IoUtils::Panic(TCmdBasePanic aReason)
+	{
+	_LIT(KCategory, "iocli");
+	User::Panic(KCategory, aReason);
+	}
+
+// If any of these asserts fail, it constitutes a BC break
+__ASSERT_COMPILE(sizeof(RChildProcess) == 7*4);
+__ASSERT_COMPILE(sizeof(RCommandOptionList) == 8*4);
+__ASSERT_COMPILE(sizeof(RCommandArgumentList) == 8*4);
+__ASSERT_COMPILE(sizeof(RIoConsoleReadHandle) == 6*4);
+__ASSERT_COMPILE(sizeof(RIoReadHandle) == 2*4);
+__ASSERT_COMPILE(sizeof(RIoConsoleWriteHandle) == 2*4);
+
+// The member variables of CCommandBase actually sum to 59 words, and from subclasses' point of view it's 59 words,
+// but EABI rounds the sizeof up to an 8-byte boundary. We can't change CCommandBase to be 60 words so that it's
+// handled the same on all platforms, because that in itself would be a BC break.
+#ifdef __EABI__
+__ASSERT_COMPILE(sizeof(CCommandBase) == 60*4);
+#else
+__ASSERT_COMPILE(sizeof(CCommandBase) == 59*4);
+#endif
+
+//
+// TEnumLex.
+//
+	
+class TEnumLex
+	{
+public:
+	TEnumLex(const TDesC& aCommaSeparatedList);
+	TBool More();
+	TPtrC Next();
+private:
+	TPtrC iRemainder;
+	};
+
+TEnumLex::TEnumLex(const TDesC& aCommaSeparatedList)
+	: iRemainder(aCommaSeparatedList)
+	{
+	}
+		
+
+TBool TEnumLex::More()
+	{
+	return iRemainder.Length() > 0;
+	}
+	
+_LIT(KComma, ",");
+
+TPtrC TEnumLex::Next()
+	{
+	TInt commaPos = iRemainder.Find(KComma);
+	if (commaPos<0) commaPos = iRemainder.Length();
+	TPtrC value(iRemainder.Mid(0, commaPos));
+	iRemainder.Set(iRemainder.Mid(commaPos));
+	if (iRemainder.Length()) iRemainder.Set(iRemainder.Mid(1));
+	return value;
+	}
+
+
+//
+// TEnum.
+//
+
+EXPORT_C TEnum::TEnum()
+	{
+	}
+
+EXPORT_C TEnum::TEnum(const TDesC& aEnumValueList)
+	: iEnumValueList(aEnumValueList)
+	{
+	ValidateValues();
+	}
+
+EXPORT_C TEnum::TEnum(const TDesC& aEnumValueList, const TDesC& aEnumDescriptionList)
+	: iEnumValueList(aEnumValueList), iEnumDescriptionList(aEnumDescriptionList)
+	{
+	ValidateValues();
+	}
+	
+TInt TEnum::GetMatches(const TDesC& aString, RArray<TInt>& aMatches, TInt& aExactMatch)
+	{
+	TEnumLex lex(iEnumValueList);
+	TInt i = 0;
+	aExactMatch = KErrNotFound;
+	while ((lex.More()) && (aExactMatch == KErrNotFound))
+		{
+		TPtrC value(lex.Next());
+		if (value.Compare(aString)==0)
+			{
+			aExactMatch = i;
+			}
+		if (value.Find(aString)==0)
+			{
+			TInt err = aMatches.Append(i);
+			if (err) return err;
+			}
+		++i;
+		}
+	return KErrNone;
+	}
+	
+EXPORT_C TInt TEnum::Parse(const TDesC& aString, TInt& aValue)
+	{
+	RArray<TInt> matches;
+	TInt exactMatch;
+	TInt err = GetMatches(aString, matches, exactMatch);
+	if (err==KErrNone)
+		{
+		if (exactMatch != KErrNotFound)
+			{
+			aValue = exactMatch;
+			}
+		else if (matches.Count()==1)
+			{
+			aValue = matches[0];
+			}
+		else
+			{
+			err = KErrArgument;
+			}
+		}
+	matches.Close();
+	return err;	
+	}
+
+EXPORT_C TInt TEnum::ParseL(const TDesC& aString)
+	{
+	RArray<TInt> matches;
+	TInt exactMatch;
+	CleanupClosePushL(matches);
+	User::LeaveIfError(GetMatches(aString, matches, exactMatch));
+	
+	TInt value = 0;
+	if ((matches.Count()==1) || (exactMatch != KErrNotFound))
+		{
+		value = exactMatch != KErrNotFound ? exactMatch : matches[0];
+		}
+	else if (matches.Count()==0)
+		{
+		if (CCommandBase::HaveStatic())
+			{
+			CTextBuffer* buf = CTextBuffer::NewLC(0x20);
+			buf->AppendL(_L("String '"));
+			buf->AppendL(aString);
+			buf->AppendL(_L("' does not match any of "));
+			AppendValuesL(*buf);
+			PrintError(KErrArgument, buf->Descriptor());
+			}
+		User::Leave(KErrArgument);
+		}
+	else
+		{
+		if (CCommandBase::HaveStatic())
+			{
+			CTextBuffer* buf = CTextBuffer::NewLC(0x20);
+			buf->AppendL(_L("String '"));
+			buf->AppendL(aString);
+			buf->AppendL(_L("' does not match a unique value (matches "));
+			TInt enumCount = -1;
+			TEnumLex lex(iEnumValueList);
+			// here we rely on the fact the matches will be sorted, due to the way the array was populated above.
+			for (TInt i=0; i<matches.Count(); ++i)
+				{
+				TPtrC enumValue;
+				while (matches[i]>enumCount)
+					{
+					++enumCount;
+					enumValue.Set(lex.Next());
+					}
+				buf->AppendL(enumValue);
+				if (i<matches.Count()-1) buf->AppendL(_L(", "));
+				}
+			buf->AppendL(')');
+			PrintError(KErrArgument, buf->Descriptor());
+			}
+		User::Leave(KErrArgument);
+		}
+	CleanupStack::PopAndDestroy(); //matches
+	return value;
+	}
+	
+EXPORT_C const TDesC& TEnum::ValueList() const
+	{
+	return iEnumValueList;
+	}
+
+EXPORT_C const TDesC& TEnum::DescriptionList() const
+	{
+	return iEnumDescriptionList;
+	}
+	
+void TEnum::ValidateValues() const
+	{
+	for (TInt i=0; i<iEnumValueList.Length(); ++i)
+		{
+		__ASSERT_ALWAYS(!TChar(iEnumValueList[i]).IsSpace(), IoUtils::Panic(EEnumValueContainsSpace));
+		}
+	}
+
+EXPORT_C void TEnum::AppendValuesL(CTextBuffer& aBuf) const
+	{
+	TEnumLex values(iEnumValueList);
+	while (values.More())
+		{
+		aBuf.AppendL(values.Next());
+		if (values.More())
+			{
+			aBuf.AppendL(_L(", "));
+			}
+		}
+	}
+	
+EXPORT_C const TPtrC TEnum::GetString(TInt aIndex) const
+	{
+	TEnumLex lex(iEnumValueList);
+	while (aIndex)
+		{
+		lex.Next();
+		--aIndex;
+		__ASSERT_ALWAYS(lex.More(), Panic(EEnumValueOutOfRange));
+		}
+	return lex.Next();
+	}
+
+EXPORT_C void TEnum::SetValueList(const TDesC& aValueList)
+	{
+	__ASSERT_ALWAYS(iEnumValueList.Length() == 0, IoUtils::Panic(EEnumValueListAlreadySet));
+	iEnumValueList.Set(aValueList);
+	}
+
+EXPORT_C void TEnum::SetDescriptionList(const TDesC& aDescriptionList)
+	{
+	__ASSERT_ALWAYS(iEnumDescriptionList.Length() == 0, IoUtils::Panic(EEnumDescriptionListAlreadySet));
+	iEnumDescriptionList.Set(aDescriptionList);
+	}
+
+EXPORT_C void TEnum::operator=(const TEnum& aEnum)
+	{
+	iEnumValueList.Set(aEnum.iEnumValueList);
+	iEnumDescriptionList.Set(aEnum.iEnumDescriptionList);
+	}
+
+
+//
+// TValue.
+//
+
+TValue::TValue(TUint aValueType, void* aValuePointer, const TDesC& aName)
+	: iValueType(aValueType), iValue(aValuePointer), iIsSet(EFalse), iEnum(KNullDesC, KNullDesC), iName(aName)
+	{
+	}
+
+TValue::TValue(TUint aValueType, void* aValuePointer, const TDesC& aName, const TDesC& aDescription, const TDesC& aEnvVar)
+	: iValueType(aValueType), iValue(aValuePointer), iIsSet(EFalse), iEnvVar(aEnvVar), iEnum(KNullDesC, KNullDesC), iName(aName), iDescription(aDescription)
+	{
+	__ASSERT_ALWAYS(aValueType != KValueTypeEnum, IoUtils::Panic(EInvalidUseOfEnum));
+	}
+	
+TValue::TValue(TUint aValueType, const TDesC& aEnumValueList, const TDesC& aEnumDescriptionList, void* aValuePointer, const TDesC& aName, const TDesC& aDescription, const TDesC& aEnvVar)
+	: iValueType(aValueType), iValue(aValuePointer), iIsSet(EFalse), iEnvVar(aEnvVar), iEnum(aEnumValueList, aEnumDescriptionList), iName(aName), iDescription(aDescription)
+	{
+	}
+
+TUint TValue::ValueType() const
+	{
+	return iValueType;
+	}
+
+EXPORT_C TUint TValue::Type() const
+	{
+	return iValueType & KPublicFlagsMask;
+	}
+
+void TValue::SetValue()
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeBool, IoUtils::Panic(EIncorrectCommandOptionType1));
+	if (iValueType & KValueTypeFlagMultiple)
+		{
+		(*(TInt*)iValue)++;
+		}
+	else
+		{
+		*(TBool*)iValue = ETrue;
+		}
+	iIsSet = ETrue;
+	}
+
+void TValue::SetValueL(TInt aInt)
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeInt, IoUtils::Panic(EIncorrectCommandOptionType2));
+	if (iValueType & KValueTypeFlagMultiple)
+		{
+		User::LeaveIfError(((RArray<TInt>*)iValue)->Append(aInt));
+		}
+	else
+		{
+		*(TInt*)iValue = aInt;
+		}
+	iIsSet = ETrue;
+	}
+
+void TValue::SetValueL(TInt64 aInt)
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeInt64, IoUtils::Panic(EIncorrectCommandOptionType11));
+	if (iValueType & KValueTypeFlagMultiple)
+		{
+		User::LeaveIfError(((RArray<TInt64>*)iValue)->Append(aInt));
+		}
+	else
+		{
+		*(TInt64*)iValue = aInt;
+		}
+	iIsSet = ETrue;
+	}
+
+void TValue::SetValueL(TUint aUint)
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeUint, IoUtils::Panic(EIncorrectCommandOptionType3));
+	if (iValueType & KValueTypeFlagMultiple)
+		{
+		User::LeaveIfError(((RArray<TUint>*)iValue)->Append(aUint));
+		}
+	else
+		{
+		*(TUint*)iValue = aUint;
+		}
+	iIsSet = ETrue;
+	}
+
+void TValue::SetValueL(TUint64 aUint)
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeUint64, IoUtils::Panic(EIncorrectCommandOptionType10));
+	if (iValueType & KValueTypeFlagMultiple)
+		{
+		User::LeaveIfError(((RArray<TUint64>*)iValue)->Append(aUint));
+		}
+	else
+		{
+		*(TUint64*)iValue = aUint;
+		}
+	iIsSet = ETrue;
+	}
+
+void TValue::SetValueL(TReal64 aReal)
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeReal, IoUtils::Panic(EIncorrectCommandOptionType4));
+	if (iValueType & KValueTypeFlagMultiple)
+		{
+		User::LeaveIfError(((RArray<TReal64>*)iValue)->Append(aReal));
+		}
+	else
+		{
+		*(TReal64*)iValue = aReal;
+		}
+	iIsSet = ETrue;
+	}
+
+void TValue::SetValueL(HBufC* aString)
+	{
+	__ASSERT_ALWAYS( ((iValueType & KValueTypeFlagMask) == KValueTypeString) || (iValueType & KValueTypeFlagMask) == KValueTypeEnum, IoUtils::Panic(EIncorrectCommandOptionType5));
+	if ((iValueType & KValueTypeFlagMask) == KValueTypeEnum)
+		{
+		TInt value = iEnum.ParseL(*aString);
+		if (iValueType & KValueTypeFlagMultiple)
+			{
+			User::LeaveIfError(((RArray<TInt>*)iValue)->Append(value));
+			}
+		else
+			{
+			*(TInt*)iValue = value;
+			}
+		iIsSet = ETrue;
+		}
+	else // string
+		{
+		if (iValueType & KValueTypeFlagMultiple)
+			{
+			User::LeaveIfError(((RPointerArray<HBufC>*)iValue)->Append(aString));
+			}
+		else
+			{
+			*(HBufC**)iValue = aString;
+			}
+		iIsSet = ETrue;
+		}
+	}
+
+void TValue::SetValueL(const TFileName2& aFileName, RFs& aFs)
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeFileName, IoUtils::Panic(EIncorrectCommandOptionType6));
+		
+	if (AcceptsMultiple())
+		{
+		if (aFileName.IsWild())
+			{
+			CDir* matches;
+			User::LeaveIfError(aFs.GetDir(aFileName, KEntryAttMaskSupported, ESortByName, matches));
+			CleanupStack::PushL(matches);
+			for (TInt i = 0; i < matches->Count(); ++i)
+				{
+				TFileName2 expandedFileName((*matches)[i].iName);
+				expandedFileName.MakeAbsoluteL(aFileName.DriveAndPath());
+				((RArray<TFileName2>*)iValue)->AppendL(expandedFileName);
+				}
+			CleanupStack::PopAndDestroy(matches);
+			}
+		else
+			{
+			((RArray<TFileName2>*)iValue)->AppendL(aFileName);
+			}
+		}
+	else
+		{
+		((TFileName2*)iValue)->SetL(aFileName);
+		}
+
+	iIsSet = ETrue;
+	}
+
+void TValue::SetEnumValues(const TEnum& aEnum)
+	{
+	iEnum = aEnum;
+	}
+
+TBool TValue::IsSet() const
+	{
+	return iIsSet;
+	}
+
+EXPORT_C TBool TValue::AcceptsMultiple() const
+	{
+	return (iValueType & KValueTypeFlagMultiple);
+	}
+	
+EXPORT_C const TDesC& TValue::EnumValueList() const
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeEnum, IoUtils::Panic(EIncorrectCommandOptionType7));
+	return iEnum.ValueList();
+	}
+
+const TDesC& TValue::EnumDescriptionList() const
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeEnum, IoUtils::Panic(EIncorrectCommandOptionType8));
+	return iEnum.DescriptionList();
+	}
+
+EXPORT_C const TDesC& TValue::EnvVar() const
+	{
+	return iEnvVar;
+	}
+
+EXPORT_C const TDesC& TValue::Name() const
+	{
+	return iName;
+	}
+
+const TDesC& TValue::Description() const
+	{
+	return iDescription;
+	}
+
+EXPORT_C void* TValue::ValuePtr() const
+	{
+	return iValue;
+	}
+	
+TPtrC TValue::AsString() const
+	{
+	if (!IsSet()) return KNullDesC();
+	if (AcceptsMultiple()) return KNullDesC();
+	switch (iValueType)
+		{
+	case KValueTypeString:
+		return *(HBufC*)iValue;
+	case KValueTypeFileName:
+		return *(TFileName2*)iValue;
+	case KValueTypeEnum:
+		return iEnum.GetString(*(TInt*)iValue);
+	default:
+		return KNullDesC();
+		}
+	}
+	
+void TValue::AppendEnumValuesL(CTextBuffer& aBuf) const
+	{
+	__ASSERT_ALWAYS((iValueType & KValueTypeFlagMask) == KValueTypeEnum, IoUtils::Panic(EIncorrectCommandOptionType9));
+	return iEnum.AppendValuesL(aBuf);
+	}
+
+void TValue::Combine(const TValue& aValue)
+	{
+	__ASSERT_ALWAYS(iDescription.Ptr() == NULL, IoUtils::Panic(EValueDescriptionAlreadySet));
+
+	iValueType = aValue.iValueType;
+	iDescription.Set(aValue.iDescription);
+	if ((iValueType & KValueTypeFlagMask) == KValueTypeEnum)
+		{
+		if (aValue.iEnum.ValueList().Length() > 0)
+			{
+			iEnum.SetValueList(aValue.iEnum.ValueList());
+			}
+		if (aValue.iEnum.DescriptionList().Length() > 0)
+			{
+			iEnum.SetDescriptionList(aValue.iEnum.DescriptionList());
+			}
+		}
+	iEnvVar.Set(aValue.EnvVar());
+	}
+
+
+//
+// TCommandOption.
+//
+
+TCommandOption::TCommandOption(TUint aValueType, void* aValuePointer, const TDesC& aLongName)
+	: TValue(aValueType, aValuePointer, aLongName)
+	{
+	}
+
+TCommandOption::TCommandOption(TUint aValueType, void* aValuePointer, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aEnvVar)
+	: TValue(aValueType, aValuePointer, aLongName, aDescription, aEnvVar), iShortName(aShortName)
+	{
+	}
+	
+TCommandOption::TCommandOption(void* aValuePointer, TUint aValueType, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aEnvVar)
+	: TValue(aValueType, aCommaSeparatedValueList, aCommaSeparatedDescriptionList, aValuePointer, aLongName, aDescription, aEnvVar), iShortName(aShortName)
+	{
+	}
+
+TChar TCommandOption::ShortName() const
+	{
+	return iShortName;
+	}
+
+void TCommandOption::Combine(const TCommandOption& aOption)
+	{
+	TValue::Combine(aOption);
+	iShortName = aOption.iShortName;
+	}
+
+
+//
+// RCommandOptionList.
+//
+
+void RCommandOptionList::Close()
+	{
+	iOptions.Close();
+	}
+
+EXPORT_C void RCommandOptionList::AppendBoolL(TBool& aBool, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeBool, &aBool, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendBoolL(RArray<TBool>& aBools, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeBool | KValueTypeFlagMultiple, &aBools, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendIntL(TInt& aInt, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeInt, &aInt, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendIntL(RArray<TInt>& aInts, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeInt | KValueTypeFlagMultiple, &aInts, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendIntL(TInt64& aInt, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeInt64, &aInt, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendIntL(RArray<TInt64>& aInts, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeInt64 | KValueTypeFlagMultiple, &aInts, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendUintL(TUint& aUint, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeUint, &aUint, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendUintL(RArray<TUint>& aUints, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeUint | KValueTypeFlagMultiple, &aUints, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendUintL(TUint64& aUint, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeUint64, &aUint, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendUintL(RArray<TUint64>& aUints, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeUint64 | KValueTypeFlagMultiple, &aUints, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendRealL(TReal64& aReal, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeReal, &aReal, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendRealL(RArray<TReal64>& aReals, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeReal | KValueTypeFlagMultiple, &aReals, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendStringL(HBufC*& aBuf, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeString, &aBuf, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendStringL(RPointerArray<HBufC>& aBufs, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeString | KValueTypeFlagMultiple, &aBufs, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendFileNameL(TFileName2& aFileName, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeFileName, &aFileName, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendFileNameL(RArray<TFileName2>& aFileNames, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeFileName | KValueTypeFlagMultiple, &aFileNames, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendEnumL(TInt& aEnum, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeEnum, &aEnum, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendEnumL(TInt& aEnum, const TDesC& aLongName, const TDesC& aCommaSeparatedValueList)
+	{
+	TCommandOption opt(KValueTypeEnum, &aEnum, aLongName);
+	opt.SetEnumValues(TEnum(aCommaSeparatedValueList));
+	iOptions.AppendL(opt);
+	}
+
+EXPORT_C void RCommandOptionList::AppendEnumL(RArray<TInt>& aEnum, const TDesC& aLongName)
+	{
+	iOptions.AppendL(TCommandOption(KValueTypeEnum | KValueTypeFlagMultiple, &aEnum, aLongName));
+	}
+
+EXPORT_C void RCommandOptionList::AppendEnumL(RArray<TInt>& aEnum, const TDesC& aLongName, const TDesC& aCommaSeparatedValueList)
+	{
+	TCommandOption opt(KValueTypeEnum | KValueTypeFlagMultiple, &aEnum, aLongName);
+	opt.SetEnumValues(TEnum(aCommaSeparatedValueList));
+	iOptions.AppendL(opt);
+	}
+
+EXPORT_C void RCommandOptionList::AppendBoolL(TBool& aBool, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeBool | aFlags, &aBool, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendBoolL(RArray<TBool>& aBools, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeBool | KValueTypeFlagMultiple | aFlags, &aBools, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendIntL(TInt& aInt, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeInt | aFlags, &aInt, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendIntL(RArray<TInt>& aInts, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeInt | KValueTypeFlagMultiple | aFlags, &aInts, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendIntL(TInt64& aInt, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeInt64 | aFlags, &aInt, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendIntL(RArray<TInt64>& aInts, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeInt64 | KValueTypeFlagMultiple | aFlags, &aInts, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendUintL(TUint& aUint, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeUint | aFlags, &aUint, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendUintL(RArray<TUint>& aUints, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeUint | KValueTypeFlagMultiple | aFlags, &aUints, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendUintL(TUint64& aUint, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeUint64 | aFlags, &aUint, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendUintL(RArray<TUint64>& aUints, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeUint64 | KValueTypeFlagMultiple | aFlags, &aUints, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendRealL(TReal64& aReal, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeReal | aFlags, &aReal, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendRealL(RArray<TReal64>& aReals, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeReal | KValueTypeFlagMultiple | aFlags, &aReals, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendStringL(HBufC*& aBuf, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeString | aFlags, &aBuf, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendStringL(RPointerArray<HBufC>& aBufs, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeString | KValueTypeFlagMultiple | aFlags, &aBufs, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendFileNameL(TFileName2& aFileName, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeFileName | aFlags, &aFileName, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendFileNameL(RArray<TFileName2>& aFileNames, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(KValueTypeFileName | KValueTypeFlagMultiple | aFlags, &aFileNames, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendEnumL(TInt& aEnum, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(&aEnum, KValueTypeEnum | aFlags, aCommaSeparatedValueList, KNullDesC, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendEnumL(TInt& aEnum, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(&aEnum, KValueTypeEnum | aFlags, aCommaSeparatedValueList, aCommaSeparatedDescriptionList, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendEnumL(RArray<TInt>& aEnum, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(&aEnum, KValueTypeEnum | KValueTypeFlagMultiple | aFlags, aCommaSeparatedValueList, KNullDesC, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+EXPORT_C void RCommandOptionList::AppendEnumL(RArray<TInt>& aEnum, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandOption option(&aEnum, KValueTypeEnum | KValueTypeFlagMultiple | aFlags, aCommaSeparatedValueList, aCommaSeparatedDescriptionList, aShortName, aLongName, aDescription, aEnvVar);
+	Validate(option);
+	iOptions.AppendL(option);
+	}
+
+void RCommandOptionList::Validate(const TCommandOption& aOption)
+	{
+	__ASSERT_ALWAYS(!(aOption.ValueType() & KValueTypeFlagLast), Panic(EOptionTaggedAsLast));
+	__ASSERT_ALWAYS((aOption.ShortName() == 0) || (FindShort(aOption.ShortName()) == KErrNotFound), Panic(EDuplicateShortOptionName));
+	TInt pos = Find(aOption.Name());
+	if (pos >= 0)
+		{
+		iOptions.Remove(pos); // Allow a newly added option of the same long name as an existing one to replace it. Primarily of use in .cif files via the "==include" directive to support command class hierarchies.
+		}
+	}
+
+EXPORT_C TInt RCommandOptionList::Count() const
+	{
+	return iOptions.Count();
+	}
+
+EXPORT_C TCommandOption& RCommandOptionList::operator[](TInt aIndex)
+	{
+	return iOptions[aIndex];
+	}
+
+EXPORT_C const TCommandOption& RCommandOptionList::operator[](TInt aIndex) const
+	{
+	return iOptions[aIndex];
+	}
+
+TInt RCommandOptionList::FindShort(TChar aShortName) const
+	{
+	const TInt count = Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		if (iOptions[i].ShortName() == aShortName)
+			{
+			return i;
+			}
+		}
+	return KErrNotFound;
+	}
+
+TInt RCommandOptionList::Find(const TDesC& aLongName) const
+	{
+	const TInt count = Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		if (iOptions[i].Name() == aLongName)
+			{
+			return i;
+			}
+		}
+	return KErrNotFound;
+	}
+
+EXPORT_C TBool RCommandOptionList::IsPresent(void* aValuePointer) const
+	{
+	const TInt count = Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		if (iOptions[i].ValuePtr() == aValuePointer)
+			{
+			return iOptions[i].IsSet();
+			}
+		}
+	return EFalse;
+	}
+	
+EXPORT_C TPtrC RCommandOptionList::AsString(void* aValuePointer) const
+	{
+	const TInt count = Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		if (iOptions[i].ValuePtr() == aValuePointer)
+			{
+			return iOptions[i].AsString();
+			}
+		}
+	return KNullDesC();
+	}
+
+
+//
+// TCommandArgument.
+//
+
+TCommandArgument::TCommandArgument(TUint aValueType, void* aValuePointer, const TDesC& aName)
+	: TValue(aValueType, aValuePointer, aName)
+	{
+	}
+
+TCommandArgument::TCommandArgument(TUint aValueType, void* aValuePointer, const TDesC& aName, const TDesC& aDescription, const TDesC& aEnvVar)
+	: TValue(aValueType, aValuePointer, aName, aDescription, aEnvVar)
+	{
+	}
+
+TCommandArgument::TCommandArgument(void* aValuePointer, TUint aValueType, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, const TDesC& aEnvVar)
+	: TValue(aValueType, aCommaSeparatedValueList, aCommaSeparatedDescriptionList, aValuePointer, aName, aDescription, aEnvVar)
+	{
+	}
+
+TBool TCommandArgument::IsOptional() const
+	{
+	return ValueType() & KValueTypeFlagOptional;
+	}
+
+TBool TCommandArgument::IsLast() const
+	{
+	return ValueType() & KValueTypeFlagLast;
+	}
+
+
+//
+// RCommandArgumentList.
+//
+
+void RCommandArgumentList::Close()
+	{
+	iArguments.Close();
+	}
+
+EXPORT_C void RCommandArgumentList::AppendIntL(TInt& aInt, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeInt, &aInt, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendIntL(RArray<TInt>& aInts, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeInt | KValueTypeFlagMultiple, &aInts, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendIntL(TInt64& aInt, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeInt64, &aInt, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendIntL(RArray<TInt64>& aInts, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeInt64 | KValueTypeFlagMultiple, &aInts, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendUintL(TUint& aUint, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeUint, &aUint, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendUintL(RArray<TUint>& aUints, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeUint | KValueTypeFlagMultiple, &aUints, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendUintL(TUint64& aUint, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeUint64, &aUint, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendUintL(RArray<TUint64>& aUints, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeUint64 | KValueTypeFlagMultiple, &aUints, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendRealL(TReal64& aReal, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeReal, &aReal, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendRealL(RArray<TReal64>& aReals, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeReal | KValueTypeFlagMultiple, &aReals, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendStringL(HBufC*& aBuf, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeString, &aBuf, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendStringL(RPointerArray<HBufC>& aBufs, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeString | KValueTypeFlagMultiple, &aBufs, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendFileNameL(TFileName2& aFileName, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeFileName, &aFileName, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendFileNameL(RArray<TFileName2>& aFileNames, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeFileName | KValueTypeFlagMultiple, &aFileNames, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendEnumL(TInt& aEnum, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeEnum, &aEnum, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendEnumL(TInt& aEnum, const TDesC& aName, const TDesC& aCommaSeparatedValueList)
+	{
+	TCommandArgument arg(KValueTypeEnum, &aEnum, aName);
+	arg.SetEnumValues(TEnum(aCommaSeparatedValueList));
+	iArguments.AppendL(arg);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendEnumL(RArray<TInt>& aEnum, const TDesC& aName)
+	{
+	iArguments.AppendL(TCommandArgument(KValueTypeEnum | KValueTypeFlagMultiple, &aEnum, aName));
+	}
+
+EXPORT_C void RCommandArgumentList::AppendEnumL(RArray<TInt>& aEnum, const TDesC& aName, const TDesC& aCommaSeparatedValueList)
+	{
+	TCommandArgument arg(KValueTypeEnum | KValueTypeFlagMultiple, &aEnum, aName);
+	arg.SetEnumValues(TEnum(aCommaSeparatedValueList));
+	iArguments.AppendL(arg);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendIntL(TInt& aInt, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeInt | aFlags, &aInt, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendIntL(RArray<TInt>& aInts, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeInt | KValueTypeFlagMultiple | aFlags, &aInts, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendIntL(TInt64& aInt, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeInt64 | aFlags, &aInt, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendIntL(RArray<TInt64>& aInts, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeInt64 | KValueTypeFlagMultiple | aFlags, &aInts, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendUintL(TUint& aUint, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeUint | aFlags, &aUint, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendUintL(RArray<TUint>& aUints, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeUint | KValueTypeFlagMultiple | aFlags, &aUints, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendUintL(TUint64& aUint, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeUint64 | aFlags, &aUint, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendUintL(RArray<TUint64>& aUints, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeUint64 | KValueTypeFlagMultiple | aFlags, &aUints, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendRealL(TReal64& aReal, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeReal | aFlags, &aReal, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendRealL(RArray<TReal64>& aReals, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeReal | KValueTypeFlagMultiple | aFlags, &aReals, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendStringL(HBufC*& aBuf, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeString | aFlags, &aBuf, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendStringL(RPointerArray<HBufC>& aBufs, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeString | KValueTypeFlagMultiple | aFlags, &aBufs, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendFileNameL(TFileName2& aFileName, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeFileName | aFlags, &aFileName, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendFileNameL(RArray<TFileName2>& aFileNames, const TDesC& aName, const TDesC& aDescription, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(KValueTypeFileName | KValueTypeFlagMultiple | aFlags, &aFileNames, aName, aDescription, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendEnumL(TInt& aEnum, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(&aEnum, KValueTypeEnum | aFlags, aName, aDescription, aCommaSeparatedValueList, KNullDesC, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendEnumL(TInt& aEnum, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(&aEnum, KValueTypeEnum | aFlags, aName, aDescription, aCommaSeparatedValueList, aCommaSeparatedDescriptionList, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendEnumL(RArray<TInt>& aEnum, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(&aEnum, KValueTypeEnum | KValueTypeFlagMultiple | aFlags, aName, aDescription, aCommaSeparatedValueList, KNullDesC, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C void RCommandArgumentList::AppendEnumL(RArray<TInt>& aEnum, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TUint aFlags, const TDesC& aEnvVar)
+	{
+	TCommandArgument argument(&aEnum, KValueTypeEnum | KValueTypeFlagMultiple | aFlags, aName, aDescription, aCommaSeparatedValueList, aCommaSeparatedDescriptionList, aEnvVar);
+	Validate(argument);
+	iArguments.AppendL(argument);
+	}
+
+EXPORT_C TBool RCommandArgumentList::IsPresent(TInt aIndex) const
+	{
+	__ASSERT_ALWAYS((aIndex >= 0) && (aIndex < Count()), Panic(EInvalidArgumentIndex));	
+	return iArguments[aIndex].IsSet();
+	}
+
+EXPORT_C TBool RCommandArgumentList::IsPresent(void* aValuePointer) const
+	{
+	const TInt count = Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		if (iArguments[i].ValuePtr() == aValuePointer)
+			{
+			return iArguments[i].IsSet();
+			}
+		}
+	return EFalse;
+	}
+
+void RCommandArgumentList::Validate(const TCommandArgument& aArgument)
+	{
+	TUint valueType = aArgument.ValueType();
+	__ASSERT_ALWAYS(!(valueType & KValueTypeFlagLast) || (valueType & KValueTypeString), Panic(ELastArgNotStringType));
+	__ASSERT_ALWAYS(!(valueType & KValueTypeFlagLast) || !(valueType & KValueTypeFlagMultiple), Panic(ELastArgMultiple));
+	if (iArguments.Count() > 0)
+		{
+		__ASSERT_ALWAYS(!iArguments[iArguments.Count() - 1].AcceptsMultiple(), Panic(EArgumentFollowsMultipleArgument));
+		__ASSERT_ALWAYS(valueType & KValueTypeFlagOptional || !iArguments[iArguments.Count() - 1].IsOptional(), Panic(ENonOptionalArgumentFollowsOptionalArgument));
+		}
+	TInt pos = Find(aArgument.Name());
+	if (pos >= 0)
+		{
+		iArguments.Remove(pos); // Allow a newly added argument of the same long name as an existing one to replace it. Primarily of use in .cif files via the "==include" directive to support command class hierarchies.
+		}
+	}
+
+EXPORT_C TInt RCommandArgumentList::Count() const
+	{
+	return iArguments.Count();
+	}
+
+TCommandArgument& RCommandArgumentList::operator[](TInt aIndex)
+	{
+	return iArguments[aIndex];
+	}
+
+EXPORT_C const TCommandArgument& RCommandArgumentList::operator[](TInt aIndex) const
+	{
+	return iArguments[aIndex];
+	}
+
+EXPORT_C TBool RCommandArgumentList::AllSet() const
+	{
+	TBool allSet(ETrue);
+	const TInt count = Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		const TCommandArgument& thisArgument = iArguments[i];
+		if (!thisArgument.IsOptional() && !thisArgument.IsSet() && !(thisArgument.ValueType() == (KValueTypeFileName | KValueTypeFlagMultiple))) // Note, allow multiple file names because "dir\*" might not produces any matches, but we don't want to report that as a syntax error. Instead expect commands to cope with zero file names.
+			{
+			allSet = EFalse;
+			break;
+			}
+		}
+	return allSet;
+	}
+
+TInt RCommandArgumentList::Find(const TDesC& aName) const
+	{
+	const TInt count = Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		if (iArguments[i].Name() == aName)
+			{
+			return i;
+			}
+		}
+	return KErrNotFound;
+	}
+
+EXPORT_C TPtrC RCommandArgumentList::AsString(void* aValuePointer) const
+	{
+	for (TInt i=0; i<Count(); ++i)
+		{
+		if (iArguments[i].ValuePtr() == aValuePointer)
+			{
+			return iArguments[i].AsString();
+			}
+		}
+	return KNullDesC();
+	}
+
+
+//
+// CCommandBase.
+//
+
+EXPORT_C TInt CCommandBase::RunCommand()
+	{
+	TRAPD(err, RunCommandL());
+	return err;
+	}
+
+EXPORT_C void CCommandBase::RunCommandL()
+	{
+	RunCommandL(NULL, NULL);
+	}
+
+EXPORT_C TInt CCommandBase::RunCommand(const TDesC* aCommandLine, CEnvironment* aEnv)
+	{
+	TRAPD(err, RunCommandL(aCommandLine, aEnv));
+	return err;
+	}
+
+NONSHARABLE_CLASS(TExitController) : public MCommandBaseObserver
+	{
+public:
+	TExitController();
+	TBool IsComplete() const;
+	TInt CompletionError() const;
+	void WaitForCompletion();
+private:
+	virtual void HandleCommandComplete(CCommandBase& aCommand, TInt aError);
+private:
+	TBool iSchedulerStarted;
+	TBool iComplete;
+	TInt iCompletionError;
+	};
+
+TExitController::TExitController()
+	: iSchedulerStarted(EFalse), iComplete(EFalse), iCompletionError(KErrNone)
+	{
+	}
+
+TBool TExitController::IsComplete() const
+	{
+	return iComplete;
+	}
+
+TInt TExitController::CompletionError() const
+	{
+	return iCompletionError;
+	}
+
+void TExitController::WaitForCompletion()
+	{
+	iSchedulerStarted = ETrue;
+	CActiveScheduler::Start();
+	}
+
+void TExitController::HandleCommandComplete(CCommandBase&, TInt aError)
+	{
+	iComplete = ETrue;
+	iCompletionError = aError;
+	if (iSchedulerStarted)
+		{
+		CActiveScheduler::Stop();
+		iSchedulerStarted = EFalse;
+		}
+	}
+
+void CCommandBase::CreateHandlesL()
+	{
+	// This function is called *before* the command line is parsed, so things like iConsoleImplementation and iConsoleSize are not available.
+	// UpdateHandlesL is called *after* the command line is parsed to change the handles if necessary.
+
+	TFullName name;
+	LtkUtils::GetFriendlyThreadName(RThread(), name);
+	RIoConsole console;
+	CleanupClosePushL(console);
+
+	TInt err = iStdin.Open(iIoSession);
+	if (err == KErrNone)
+		{
+		User::LeaveIfError(iStdout.Open(iIoSession));
+		User::LeaveIfError(iStderr.Open(iIoSession));
+		}
+	else
+		{
+		console.CreateL(iIoSession, name, TSize(KConsFullScreen, KConsFullScreen), RIoConsole::ELazyCreate);
+		DoCreateHandlesL(console, iStdin, iStdout, iStderr);
+		}
+
+	CleanupStack::PopAndDestroy(&console); // Console (if used) will be held open by the read and write handles.
+
+	if (iFlags & ENotifyStdinChanges)
+		{
+		iReadChangeNotifier = new(ELeave)CReaderChangeNotifier(*this, iStdin);
+		iReadChangeNotifier->Notify();
+		}	
+	}
+
+void CCommandBase::UpdateHandlesL()
+	{
+	TFullName name;
+	LtkUtils::GetFriendlyThreadName(RThread(), name);
+	RIoConsole console;
+	CleanupClosePushL(console);
+
+	if (iPersistentConsoleName)
+		{
+		((RIoPersistentConsole&)console).CreateL(iIoSession, *iPersistentConsoleName, (iConsoleTitle == NULL) ? name : *iConsoleTitle);
+		}
+	else
+		{
+		TSize size(KConsFullScreen, KConsFullScreen);
+		if (iConsoleSize.Count() > 0)
+			{
+			size.iWidth = iConsoleSize[0];
+			}
+		if (iConsoleSize.Count() > 1)
+			{
+			size.iHeight = iConsoleSize[1];
+			}
+		RIoConsole underlyingConsole;
+		underlyingConsole.OpenL(iIoSession, iStdout);
+		CleanupClosePushL(underlyingConsole);
+		console.CreateL(iIoSession, *iConsoleImplementation, underlyingConsole, (iConsoleTitle == NULL) ? name : *iConsoleTitle, size);
+		CleanupStack::PopAndDestroy(&underlyingConsole);
+		RIoConsoleReadHandle stdin;
+		CleanupClosePushL(stdin);
+		RIoConsoleWriteHandle stdout;
+		CleanupClosePushL(stdout);
+		RIoConsoleWriteHandle stderr;
+		CleanupClosePushL(stderr);
+		DoCreateHandlesL(console, stdin, stdout, stderr);
+		if (iFlags & ENotifyStdinChanges)
+			{
+			CReaderChangeNotifier* readChangeNotifier = new(ELeave)CReaderChangeNotifier(*this, iStdin);
+			delete iReadChangeNotifier;
+			iReadChangeNotifier = readChangeNotifier;
+			}	
+		iStdin.Close();
+		iStdin = stdin;
+		iStdout.Close();
+		iStdout = stdout;
+		iStderr.Close();
+		iStderr = stderr;
+		CleanupStack::Pop(3, &stdin);
+		if (iFlags & ENotifyStdinChanges)
+			{
+			iReadChangeNotifier->Notify();
+			}
+		}
+
+	CleanupStack::PopAndDestroy(&console); // Console (if used) will be held open by the read and write handles.
+	}
+
+void CCommandBase::DoCreateHandlesL(RIoConsole& aConsole, RIoConsoleReadHandle& aStdin, RIoConsoleWriteHandle& aStdout, RIoConsoleWriteHandle& aStderr)
+	{
+	TFullName name;
+	LtkUtils::GetFriendlyThreadName(RThread(), name);
+
+	TName consImpl;
+	TInt err = aConsole.Implementation(consImpl);
+	if (err != KErrOverflow)
+		{
+		User::LeaveIfError(err);
+		}
+	if (consImpl.Right(KDllExt().Length()).CompareF(KDllExt)==0)
+		{
+		consImpl.SetLength(consImpl.Length() - KDllExt().Length());
+		}
+	if (name.Length() + consImpl.Length() + 1 > name.MaxLength())
+		{
+		name.SetLength(name.MaxLength() - (name.Length() + consImpl.Length() + 1));
+		}
+	name.Insert(0, _L("_"));
+	name.Insert(0, consImpl);
+
+	iIoSession.SetObjectNameL(aConsole.SubSessionHandle(), name);
+	
+	aStdin.CreateL(iIoSession);
+	_LIT(KStdin, "_stdin");
+	name.Append(KStdin);
+	iIoSession.SetObjectNameL(aStdin.SubSessionHandle(), name);
+
+	aStdout.CreateL(iIoSession);
+	name.Delete(name.Length() - KStdin().Length(), KStdin().Length());
+	_LIT(KStdout, "_stdout");
+	name.Append(KStdout);
+	iIoSession.SetObjectNameL(aStdout.SubSessionHandle(), name);
+
+	aStderr.CreateL(iIoSession);
+	User::LeaveIfError(aStderr.SetIsStdErr(ETrue));
+	name.Delete(name.Length() - KStdout().Length(), KStdout().Length());
+	_LIT(KStderr, "_stderr");
+	name.Append(KStderr);
+	iIoSession.SetObjectNameL(aStderr.SubSessionHandle(), name);
+
+	aConsole.AttachL(aStdin, RIoEndPoint::EForeground);
+	aConsole.AttachL(aStdout);
+	aConsole.AttachL(aStderr);
+
+	aStdin.SetUnderlyingConsoleL(aConsole);
+	aStdout.SetUnderlyingConsoleL(aConsole);
+	aStderr.SetUnderlyingConsoleL(aConsole);
+	}
+
+EXPORT_C void CCommandBase::RunCommandL(const TDesC* aCommandLine, CEnvironment* aEnv)
+	{
+	iFlags |= EOwnsHandles;
+
+	User::LeaveIfError(iIoSession.Connect());
+	if (iFlags & ESharableIoSession)
+		{
+		User::LeaveIfError(iIoSession.ShareAuto());
+		}
+
+	TBool commandLineOnStack(EFalse);
+	const TDesC* commandLine = aCommandLine;
+	if (aCommandLine == NULL)
+		{
+		commandLine = ReadCommandLineLC();
+		commandLineOnStack = ETrue;
+		}
+
+	CreateEnvironmentL(aEnv);
+	CreateHandlesL();
+
+	TExitController exitController;
+	RunCommand(iIoSession, iStdin, iStdout, iStderr, commandLine, iEnv, &exitController);
+	if (!exitController.IsComplete())
+		{
+		exitController.WaitForCompletion();
+		}
+
+	TInt completionError = exitController.CompletionError();
+	if (completionError != KErrNone)
+		{
+		User::Leave(completionError);
+		}
+
+	if (commandLineOnStack)
+		{
+		CleanupStack::PopAndDestroy((TAny*)commandLine);
+		}
+	}
+
+EXPORT_C TInt CCommandBase::RunCommand(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const TDesC* aCommandLine, CEnvironment* aEnv)
+	{
+	TExitController exitController;
+	RunCommand(aIoSession, aStdin, aStdout, aStderr, aCommandLine, aEnv, &exitController);
+	if (exitController.IsComplete())
+		{
+		return exitController.CompletionError();
+		}
+	else
+		{
+		exitController.WaitForCompletion();
+		return exitController.CompletionError();
+		}
+	}
+
+EXPORT_C void CCommandBase::RunCommandL(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const TDesC* aCommandLine, CEnvironment* aEnv)
+	{
+	User::LeaveIfError(RunCommand(aIoSession, aStdin, aStdout, aStderr, aCommandLine, aEnv));
+	}
+
+EXPORT_C void CCommandBase::RunCommand(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const TDesC* aCommandLine, CEnvironment* aEnv, MCommandBaseObserver* aObserver)
+	{
+	TRAPD(err, RunCommandL(aIoSession, aStdin, aStdout, aStderr, aCommandLine, aEnv, aObserver));
+	if (err)
+		{
+		Complete(err);
+		}
+	}
+
+EXPORT_C TUint CCommandBase::Flags() const
+	{
+	return (iFlags & KPublicFlagsMask);
+	}
+
+EXPORT_C void CCommandBase::SetFlags(TUint aFlags)
+	{
+	TUint privateFlags = (iFlags & KPrivateFlagsMask);
+	iFlags = (aFlags & KPublicFlagsMask);
+	iFlags |= privateFlags;
+	if (iFlags & ECompleteOnRunL)
+		{
+		iFlags |= EManualComplete;
+		}
+	}
+
+EXPORT_C void CCommandBase::SetCif(const CCommandInfoFile& aCif)
+	{
+	ASSERT((iCif == NULL) && !(iFlags & EOwnsCif));
+	iCif = &const_cast<CCommandInfoFile&>(aCif);
+	}
+
+EXPORT_C const CCommandInfoFile* CCommandBase::Cif() const
+	{
+	return iCif;
+	}
+
+void CCommandBase::RunCommandL(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const TDesC* aCommandLine, CEnvironment* aEnv, MCommandBaseObserver* aObserver)
+	{
+	iIoSession = aIoSession;
+	iStdin = aStdin;
+	iStdout = aStdout;
+	iStderr = aStderr;
+	iObserver = aObserver;
+
+	CreateEnvironmentL(aEnv);
+
+	if (aCommandLine)
+		{
+		RunL(*aCommandLine);
+		}
+	else
+		{
+		const TDesC* commandLine = ReadCommandLineLC();
+		RunL(*commandLine);
+		CleanupStack::PopAndDestroy((TAny*)commandLine);
+		}
+	}
+
+void CCommandBase::RunL(const TDesC& aCommandLine)
+	{
+	TInt err = ParseCommandLine(aCommandLine);
+	if (iFlags & ECifReadFailed)
+		{
+		// No point in trying to display help.
+		Complete(err);
+		}
+	else if (err || iDisplayHelp)
+		{
+		if (err && !iDisplayHelp)
+			{
+			DisplayHelpAndComplete(err, _L("Couldn't parse command line"));
+			}
+		else
+			{
+			DisplayHelpAndComplete();
+			}
+		}
+	else
+		{
+		if (iConsoleImplementation || iPersistentConsoleName)
+			{
+			UpdateHandlesL();
+			}
+
+		TBool deleted(EFalse);
+		iDeleted = &deleted;	
+		// Note, commands that manually complete may call CCommandBase::Complete from their DoRunL, which in the case 
+		// of "local" fshell commands (i.e. ones that run in the context of fshell's thread) will result in the object
+		// being deleted. This flag detects this to avoid code later in this function blowing up.
+		TRAP(err, DoRunL());
+		if (err)
+			{
+			HandleLeave(err);
+			}
+		else if (!deleted && !(iFlags & EManualComplete) && !IsActive() && !(iFlags & ECompleted))
+			{
+			Complete();
+			}
+		if (!deleted)
+			{
+			iDeleted = NULL;
+			}
+		}
+	}
+
+EXPORT_C CCommandBase::CCommandBase()
+	: CActive(CActive::EPriorityStandard)
+	{
+	// These are protected so could be accessed directly, hence can't move
+	// The asserts have to be scoped inside a CCommandBase function because the member vars are protected. They don't generate any code.
+	__ASSERT_COMPILE(_FOFF(CCommandBase, iOptions) == 7*4);
+	__ASSERT_COMPILE(_FOFF(CCommandBase, iArguments) == 15*4);
+
+	CActiveScheduler::Add(this);
+	if (Dll::Tls() == NULL)
+		{
+		Dll::SetTls(this);
+		iFlags |= ETlsSet;
+		}
+	}
+
+EXPORT_C CCommandBase::CCommandBase(TUint aFlags)
+	: CActive(CActive::EPriorityStandard), iFlags(aFlags)
+	{
+	CActiveScheduler::Add(this);
+	if (Dll::Tls() == NULL)
+		{
+		Dll::SetTls(this);
+		iFlags |= ETlsSet;
+		}
+
+	// Ensure EManualComplete is set if ECompleteOnRunL is.
+	SetFlags(Flags());
+	}
+
+EXPORT_C CCommandBase::~CCommandBase()
+	{
+	delete iReadChangeNotifier;
+	delete iCompleter;
+	iFs.Close();
+	if (iFlags & EOwnsHandles)
+		{
+		iStderr.Close();
+		iStdout.Close();
+		iStdin.Close();
+		iIoSession.Close();
+		}
+
+	if (iFlags & EOwnsEnv)
+		{
+		delete iEnv;
+		}
+	delete iConsoleImplementation;
+	delete iConsoleTitle;
+	delete iPersistentConsoleName;
+	iConsoleSize.Close();
+	iOptions.Close();
+	iArguments.Close();
+	if (iFlags & EOwnsCif)
+		{
+		delete iCif;
+		}
+	if (iDeleted)
+		{
+		*iDeleted = ETrue;
+		}
+	if (iFlags & ETlsSet)
+		{
+		Dll::SetTls(NULL);
+		}
+	}
+
+EXPORT_C void CCommandBase::BaseConstructL()
+	{
+	iCompleter = new(ELeave)CCommandCompleter(*this);
+	}
+
+EXPORT_C CEnvironment& CCommandBase::Env()
+	{
+	__ASSERT_ALWAYS(iEnv, Panic(ENoEnvironment));
+	return *iEnv;
+	}
+
+EXPORT_C const CEnvironment& CCommandBase::Env() const
+	{
+	__ASSERT_ALWAYS(iEnv, Panic(ENoEnvironment));
+	return *iEnv;
+	}
+
+void CCommandBase::CompleteCallback(TInt aError)
+	{
+	Complete(aError);
+	}
+
+EXPORT_C void CCommandBase::Complete()
+	{
+	Complete(KErrNone);
+	}
+
+EXPORT_C void CCommandBase::Complete(TInt aError)
+	{
+	__ASSERT_ALWAYS(!(iFlags & ECompleted), Panic(EAlreadyCompleted));
+	iFlags |= ECompleted;
+	iCompletionReason = aError;
+	if (aError < 0)
+		{
+		RProcess::Rendezvous(aError);
+		const TDesC& name = Name();
+		PrintError(aError, _L("Unable to run \"%S\""), &name);
+		}
+	if (iObserver)
+		{
+		iObserver->HandleCommandComplete(*this, aError);
+		}
+	}
+
+EXPORT_C void CCommandBase::Complete(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TBuf<0x100> buf;
+	TOverflowTruncate overflow;
+	buf.AppendFormatList(aFmt, list, &overflow);
+	VA_END(list);
+	iStdout.Write(buf);
+	Complete();
+	}
+
+EXPORT_C void CCommandBase::Complete(TInt aError, TRefByValue<const TDesC> aFmt, ...)
+	{
+	if (iFlags & EErrorReported)
+		{
+		Complete(aError);
+		}
+	else
+		{
+		RProcess::Rendezvous(aError); // This isn't right for thread commands - not sure how to distinguish. Probably won't cause a problem though. (We also rendezvous in Complete(TInt), but to avoid deadlocks in server commands we need to rendezvous before writing anything (in the error case)
+		VA_LIST list;
+		VA_START(list, aFmt);
+		PrintErrorList(aError, aFmt, list);
+		Complete(aError);
+		VA_END(list);
+		}
+	}
+
+EXPORT_C void CCommandBase::CompleteAsync(TInt aError)
+	{
+	iCompleter->Complete(aError);
+	}
+
+EXPORT_C void CCommandBase::CompleteAsync(TInt aError, TRefByValue<const TDesC> aFmt, ...)
+	{
+	if (iFlags & EErrorReported)
+		{
+		iCompleter->Complete(aError);
+		}
+	else
+		{
+		VA_LIST list;
+		VA_START(list, aFmt);
+		TBuf<0x100> buf;
+		FormatErrorText(buf, aError, aFmt, list);
+		VA_END(list);
+		iCompleter->Complete(aError, buf, iStderr);
+		}
+	}
+
+EXPORT_C void CCommandBase::ReadL(TDes& aData)
+	{
+	User::LeaveIfError(iStdin.Read(aData));
+	}
+
+EXPORT_C void CCommandBase::Write(const TDesC& aData)
+	{
+	iStdout.Write(aData); // Ignore error.
+	}
+
+EXPORT_C void CCommandBase::Printf(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	PrintList(aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void CCommandBase::Printf(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	PrintList(aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void CCommandBase::PrintError(TInt aError, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	PrintErrorList(aError, aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void CCommandBase::PrintWarning(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	PrintWarningList(aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void CCommandBase::PrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	TOverflowTruncate overflow;
+	TBuf<0x100> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	iStdout.Write(buf);
+	}
+
+EXPORT_C void CCommandBase::PrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
+	{
+	TOverflowTruncate8 overflow;
+	TBuf8<0x200> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	if (buf.Length() > 0x100) buf.SetLength(0x100); // Truncate to half the buffer size so that the call to Expand doesn't panic
+	TPtrC wideBuf = buf.Expand();
+	iStdout.Write(wideBuf);
+	}
+
+EXPORT_C void CCommandBase::PrintErrorList(TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	if (!Stderr().SubSessionHandle())
+		{
+		// Only can happen if we error during say command line parsing, which occurs before the handles are set up.
+		return;
+		}
+
+	if (iSupressingErrors > 0 || ((iFlags & EErrorReported) && !(iFlags & EReportAllErrors)))
+		{
+		return;
+		}
+
+	CheckNewLine();
+	TBuf<0x100> buf;
+	FormatErrorText(buf, aError, aFmt, aList);
+	iStderr.Write(buf);
+	iFlags |= EErrorReported;
+	}
+
+EXPORT_C void CCommandBase::PrintWarningList(TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	if (!Stderr().SubSessionHandle())
+		{
+		// Only can happen if we error during say command line parsing, which occurs before the handles are set up.
+		return;
+		}
+	CheckNewLine();
+	TBuf<0x100> buf;
+	FormatWarningText(buf, aFmt, aList);
+	iStderr.Write(buf);
+	}
+
+EXPORT_C void CCommandBase::LeaveIfFileExists(const TDesC& aFileName)
+	{
+	TFileName2 fileName(aFileName);
+	if (fileName.Exists(FsL()))
+		{
+		PrintError(KErrAlreadyExists, _L("\"%S\" already exists"), &aFileName);
+		User::Leave(KErrAlreadyExists);
+		}
+	}
+
+EXPORT_C void CCommandBase::LeaveIfFileNotFound(const TDesC& aFileName)
+	{
+	TEntry e;
+	TInt err = FsL().Entry(aFileName, e);
+	if (err == KErrNotFound)
+		{
+		PrintError(err, _L("\"%S\" not found"), &aFileName);
+		}
+	else if (err)
+		{
+		PrintError(err, _L("Couldn't read \"%S\""), &aFileName);
+		}
+	User::LeaveIfError(err);
+	}
+
+EXPORT_C RFs& CCommandBase::Fs()
+	{
+	__ASSERT_ALWAYS(iFs.Handle(), Panic(ERFsNotConnected));
+	return iFs;
+	}
+
+EXPORT_C const RFs& CCommandBase::Fs() const
+	{
+	__ASSERT_ALWAYS(iFs.Handle(), Panic(ERFsNotConnected));
+	return iFs;
+	}
+
+EXPORT_C RFs& CCommandBase::FsL()
+	{
+	if (iFs.Handle() == 0)
+		{
+		User::LeaveIfError(iFs.Connect());
+		const TDesC& pwd = Env().Pwd();
+		TInt err = iFs.SetSessionPath(pwd);
+		if (err)
+			{
+			// Could fail if, for eg, we have no capabilities and the fshell we were launched from had \sys\bin as its cwd. In such a case shouldn't be considered an error, only a warning.
+			PrintWarning(_L("Couldn't set session path for %S to '%S'. (err = %d)\r\n"), &Name(), &pwd, err);
+			}
+		}
+	return iFs;
+	}
+
+EXPORT_C const RFs& CCommandBase::FsL() const
+	{
+	return const_cast<CCommandBase*>(this)->FsL();
+	}
+
+EXPORT_C RIoSession& CCommandBase::IoSession()
+	{
+	return iIoSession;
+	}
+
+EXPORT_C RIoConsoleReadHandle& CCommandBase::Stdin()
+	{
+	return iStdin;
+	}
+
+EXPORT_C RIoConsoleWriteHandle& CCommandBase::Stdout()
+	{
+	return iStdout;
+	}
+
+EXPORT_C RIoConsoleWriteHandle& CCommandBase::Stderr()
+	{
+	return iStderr;
+	}
+
+EXPORT_C void CCommandBase::OptionsL(RCommandOptionList&)
+	{
+	}
+
+EXPORT_C void CCommandBase::ArgumentsL(RCommandArgumentList&)
+	{
+	}
+
+EXPORT_C TInt CCommandBase::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	return CActive::Extension_(aExtensionId, a0, a1);
+	}
+
+EXPORT_C void CCommandBase::HandleLeave(TInt aError)
+	{
+	const TDesC& name = Name();
+	Complete(aError, _L("Command \"%S\" failed"), &name);
+	}
+
+void HandleEscapeL(TLex& aLex, CTextBuffer& aBuf)
+	{
+	_LIT(KBell, "\a");
+	_LIT(KBackspace, "\b");
+	_LIT(KFormFeed, "\f");
+	_LIT(KHorizontalTab, "\t");
+	_LIT(KVerticalTab, "\v");
+	_LIT(KNewLine, "\n");
+	_LIT(KCarriageReturn, "\r");
+	if (!aLex.Eos())
+		{
+		TChar c2 = aLex.Get();
+		switch (c2)
+			{
+			case 'a':
+				aBuf.AppendL(KBell);
+				break;
+			case 'b':
+				aBuf.AppendL(KBackspace);
+				break;
+			case 'f':
+				aBuf.AppendL(KFormFeed);
+				break;
+			case 't':
+				aBuf.AppendL(KHorizontalTab);
+				break;
+			case 'v':
+				aBuf.AppendL(KVerticalTab);
+				break;
+			case 'n':
+				aBuf.AppendL(KNewLine);
+				break;
+			case 'r':
+				aBuf.AppendL(KCarriageReturn);
+				break;
+			case 'x':
+			case 'X':
+				if (aLex.Remainder().Length() >= 2)
+					{
+					TLex lex(aLex.Remainder().Mid(0, 2)); // Note, can't use aLex directly because there could be hex characters following the 2 that relate to this escape sequence.
+					TUint16 val;
+					User::LeaveIfError(lex.Val(val, EHex));
+					aBuf.AppendL(TPtrC(&val, 1));
+					aLex.Inc(2);
+					}
+				break;
+			case 'u':
+				if (aLex.Remainder().Length() >= 4)
+					{
+					TLex lex(aLex.Remainder().Mid(0, 4)); // Note, can't use aLex directly because there could be hex characters following the 4 that relate to this escape sequence.
+					TUint16 val;
+					User::LeaveIfError(lex.Val(val, EHex));
+					aBuf.AppendL(TChar(val));
+					aLex.Inc(4);
+					}
+				break;
+			case 'U':
+				if (aLex.Remainder().Length() >= 8)
+					{
+					TLex lex(aLex.Remainder().Mid(0, 8)); // Note, can't use aLex directly because there could be hex characters following the 8 that relate to this escape sequence.
+					TUint32 val;
+					User::LeaveIfError(lex.Val(val, EHex));
+					aBuf.AppendL(TChar(val));
+					aLex.Inc(8);
+					}
+				break;
+			default:
+				aBuf.AppendL(TPtrC((TUint16*)&c2, 1));
+				break;
+			}
+		}
+	}
+
+EXPORT_C HBufC* Stringify::ReadLC(TLex& aLex, const TChar& aEscapeChar)
+	{
+	return ReadLC(aLex, aEscapeChar, NULL, 0);
+	}
+
+EXPORT_C HBufC* Stringify::ReadLC(TLex& aLex, const TChar& aEscapeChar, CCommandBase& aErrorContext)
+	{
+	return ReadLC(aLex, aEscapeChar, &aErrorContext, 0);
+	}
+
+EXPORT_C HBufC* Stringify::ReadLC(TLex& aLex, const TChar& aEscapeChar, TUint aReadMode)
+	{
+	return ReadLC(aLex, aEscapeChar, NULL, aReadMode);
+	}
+
+EXPORT_C HBufC* Stringify::ReadLC(TLex& aLex, const TChar& aEscapeChar, CCommandBase& aErrorContext, TUint aReadMode)
+	{
+	return ReadLC(aLex, aEscapeChar, &aErrorContext, aReadMode);
+	}
+	
+#define ReadLCLeaveIfErr(_command, _error, _errorFmtString...) do {if (_command) {CommandLeaveIfErr(*_command, _error, _errorFmtString);} else User::LeaveIfError(_error); } while(0)
+	
+HBufC* Stringify::ReadLC(TLex& aLex, const TChar& aEscapeChar, CCommandBase* aErrorContext, TUint aReadMode)
+	{
+	CTextBuffer* buf = CTextBuffer::NewLC(20);
+	while (!aLex.Eos())
+		{
+		TChar c = aLex.Get();
+		if (c == aEscapeChar)
+			{
+			HandleEscapeL(aLex, *buf);
+			}
+		else if (c == '\'')
+			{
+			TBool foundClose = EFalse;
+			while (!aLex.Eos())
+				{
+				c = aLex.Get();
+				if ((c == aEscapeChar) && !aLex.Eos() && (aLex.Peek() == '\''))
+					{
+					// Allow quoted single quote characters. Note, the is a departure from Bash behaviour, but is in line with Perl and is generally helpful.
+					buf->AppendL('\'');
+					aLex.Get();
+					}
+				else if (c == '\'')
+					{
+					foundClose = ETrue;
+					break;
+					}
+				else
+					{
+					buf->AppendL(c);
+					}
+				}
+			if (!foundClose)
+				{
+				ReadLCLeaveIfErr(aErrorContext, KErrArgument, _L("Unmatched single quote"));
+				}
+			}
+		else if (c == '"')
+			{
+			TBool foundClose = EFalse;
+			while (!aLex.Eos())
+				{
+				c = aLex.Get();
+				if (c == aEscapeChar)
+					{
+					HandleEscapeL(aLex, *buf);
+					}
+				else if (c == '"')
+					{
+					foundClose = ETrue;
+					break;
+					}
+				else
+					{
+					buf->AppendL(c);
+					}
+				}
+			if (!foundClose)
+				{
+				ReadLCLeaveIfErr(aErrorContext, KErrArgument, _L("Unmatched double quote"));
+				}
+			}
+		else if (c.IsSpace() || ((c == ',') && (aReadMode & EBreakOnComma)))
+			{
+			aLex.UnGet();
+			break;
+			}
+		else
+			{
+			buf->AppendL(c);
+			}
+		}
+
+	HBufC* hbuf = buf->Descriptor().AllocL();
+	CleanupStack::PopAndDestroy(buf);
+	CleanupStack::PushL(hbuf);
+	return hbuf;
+	}
+
+EXPORT_C HBufC* Stringify::WidenLC(const TDesC8& aDes)
+	{
+	HBufC* buf = HBufC::NewLC(aDes.Length());
+	buf->Des().Copy(aDes);
+	return buf;
+	}
+
+EXPORT_C HBufC8* Stringify::NarrowLC(const TDesC& aDes)
+	{
+	HBufC8* buf = HBufC8::NewLC(aDes.Length());
+	buf->Des().Copy(aDes);
+	return buf;
+	}
+
+EXPORT_C HBufC* Stringify::EscapeLC(const TDesC& aDes, const TChar& aEscapeChar)
+	{
+	const TInt origLength = aDes.Length();
+	TInt newLength = origLength;
+	for (TInt i = 0; i < origLength; ++i)
+		{
+		if (!TChar(aDes[i]).IsPrint())
+			{
+			// Hmmm, is this going to go horribly wrong with surrogate pairs?
+			newLength += 5; // 5 because <unprintable-char> -> '^unnnn'
+			}
+		}
+	HBufC* buf = HBufC::NewLC(newLength);
+	TPtr bufPtr(buf->Des());
+	for (TInt i = 0; i < origLength; ++i)
+		{
+		if (TChar(aDes[i]).IsPrint())
+			{
+			bufPtr.Append(aDes[i]);
+			}
+		else
+			{
+			bufPtr.Append(aEscapeChar);
+			bufPtr.Append('u');
+			bufPtr.AppendNumFixedWidthUC(aDes[i], EHex, 4);
+			}
+		}
+	return buf;
+	}
+
+EXPORT_C HBufC8* Stringify::EscapeLC(const TDesC8& aDes, const TChar& aEscapeChar)
+	{
+	const TInt origLength = aDes.Length();
+	TInt newLength = origLength;
+	for (TInt i = 0; i < origLength; ++i)
+		{
+		if (!TChar(aDes[i]).IsPrint())
+			{
+			newLength += 3; // 3 because <unprintable-char> -> '^xnn'
+			}
+		}
+	HBufC8* buf = HBufC8::NewLC(newLength);
+	TPtr8 bufPtr(buf->Des());
+	for (TInt i = 0; i < origLength; ++i)
+		{
+		if (TChar(aDes[i]).IsPrint())
+			{
+			bufPtr.Append(aDes[i]);
+			}
+		else
+			{
+			bufPtr.Append(aEscapeChar);
+			bufPtr.Append('x');
+			bufPtr.AppendNumFixedWidthUC(aDes[i], EHex, 2);
+			}
+		}
+	return buf;
+	}
+
+TRadix Radix(TLex& aLex)
+	{
+	_LIT(KBinPrefix, "0b");
+	_LIT(KOctPrefix, "0.");
+	_LIT(KHexPrefix, "0x");
+	
+	TRadix radix(EDecimal);
+
+	if (aLex.Remainder().Length() > 2)
+		{
+		TLexMark mark;
+		aLex.Mark(mark);
+		aLex.Inc(2);
+		TPtrC prefix(aLex.MarkedToken(mark));
+		if (prefix == KBinPrefix)
+			{
+			radix = EBinary;
+			}
+		else if (prefix == KOctPrefix)
+			{
+			radix = EOctal;
+			}
+		else if (prefix == KHexPrefix)
+			{
+			radix = EHex;
+			}
+		
+		if (radix == EDecimal)
+			{
+			aLex.UnGetToMark(mark);
+			}
+		}
+
+	return radix;
+	}
+
+void CCommandBase::SetValueL(TLex& aLex, TValue& aValue)
+	{
+	TBool more((aValue.ValueType() & KValueTypeFlagMultiple) && !(aValue.ValueType() & KValueTypeFlagLast));
+	if (aValue.IsSet() && !(aValue.ValueType() & KValueTypeFlagMultiple)) User::Leave(KErrArgument); // Can't set the same parameter repeatedly unless it has the multiple attribute
+	do
+		{
+		switch (aValue.ValueType() & KValueTypeFlagMask)
+			{
+			case KValueTypeBool:
+				{
+				aValue.SetValue();
+				break;
+				}
+			case KValueTypeInt:
+				{
+				aLex.SkipSpace();
+				TInt val;
+				if (aLex.Val(val) < 0)
+					{
+					User::Leave(KErrArgument);
+					}
+				aValue.SetValueL(val);
+				break;
+				}
+			case KValueTypeInt64:
+				{
+				aLex.SkipSpace();
+				TInt64 val;
+				if (aLex.Val(val) < 0)
+					{
+					User::Leave(KErrArgument);
+					}
+				aValue.SetValueL(val);
+				break;
+				}
+			case KValueTypeUint:
+				{
+				aLex.SkipSpace();
+				TUint val;
+				if (aLex.Val(val, Radix(aLex)) < 0)
+					{
+					User::Leave(KErrArgument);
+					}
+				aValue.SetValueL(val);
+				break;
+				}
+			case KValueTypeUint64:
+				{
+				aLex.SkipSpace();
+				TInt64 val; // There's no implementation of TLex16::Val(TUint64&, TRadix), so we'll have to use the TInt64 version instead.
+				if (aLex.Val(val, Radix(aLex)) < 0)
+					{
+					User::Leave(KErrArgument);
+					}
+				aValue.SetValueL((TUint64)val);
+				break;
+				}
+			case KValueTypeReal:
+				{
+				aLex.SkipSpace();
+				TReal64 val;
+				if (aLex.Val(val) < 0)
+					{
+					User::Leave(KErrArgument);
+					}
+				aValue.SetValueL(val);
+				break;
+				}
+			case KValueTypeString:
+				{
+				if (aValue.ValueType() & KValueTypeFlagLast)
+					{
+					TLexMark mark;
+					aLex.Mark(mark);
+					HBufC* string = ReadStringLC(aLex, 0);
+					if ((aLex.Remainder().Length() == 0) || (aLex.Remainder() == KNewLine))
+						{
+						// ReadStringLC consumed the whole of the remainder of the command line. This means the
+						// user must have either provided a just single word, or explicitly quoted / escaped the whitespace
+						// between multiple words.
+						// Either way, we've got a single argument to satisfy 'last' so we'll use what ReadStringLC
+						// returned.
+						aValue.SetValueL(string);
+						CleanupStack::Pop(string);
+						}
+					else
+						{
+						// ReadStringLC didn't consume the remainder of the command line. This means the user must have
+						// provided multiple words, but didn't quote or escape the whitespace. In this case take the
+						// string they provided unaltered (which is equivalent to adding quotes around the whole string
+						// and passing it back through ReadStringLC).
+						CleanupStack::PopAndDestroy(string);
+						aLex.UnGetToMark(mark);
+						aValue.SetValueL(aLex.Remainder().AllocLC());
+						CleanupStack::Pop();
+						aLex.Inc(aLex.Remainder().Length());
+						}
+					}
+				else
+					{
+					HBufC* string = ReadStringLC(aLex, (aValue.ValueType() & KValueTypeFlagLast) ? 0 : EDisallowLeadingHyphen);
+					aValue.SetValueL(string);
+					CleanupStack::Pop(string);
+					}
+				break;
+				}		
+			case KValueTypeFileName:
+				{
+				HBufC* string = ReadStringLC(aLex, EDisallowLeadingHyphen);
+				TFileName2 fileName(*string);
+				CleanupStack::PopAndDestroy(string);
+				if (fileName.Length() == 0)
+					{
+					User::Leave(KErrArgument);
+					}
+				fileName.MakeAbsoluteL(iEnv->Pwd());
+				aValue.SetValueL(fileName, FsL());
+				break;
+				}
+			case KValueTypeEnum:
+				{
+				HBufC* string = ReadStringLC(aLex, EDisallowLeadingHyphen);
+				aValue.SetValueL(string);	
+				CleanupStack::PopAndDestroy(string);
+				break;
+				}
+			default:
+				{
+				__ASSERT_ALWAYS(EFalse, Panic(EInvalidCommandOptionType));
+				break;
+				}
+			}
+
+		if (more)
+			{
+			TLexMark mark;
+			aLex.Mark(mark);
+			aLex.SkipSpace();
+			if (aLex.Peek() == ',')
+				{
+				aLex.Get();
+				aLex.SkipSpace();
+				// Loop again to process the next value in the set.
+				}
+			else
+				{
+				aLex.UnGetToMark(mark);
+				more = EFalse;
+				}
+			}
+		}
+		while (more);
+	}
+
+void CCommandBase::SetValueFromEnvL(TValue& aValue)
+	{
+	if (!aValue.IsSet() && (aValue.EnvVar().Length() > 0) && iEnv->IsDefined(aValue.EnvVar()))
+		{
+		TUint type = aValue.ValueType() & KValueTypeFlagMask;
+		if ((type == KValueTypeString) || (type == KValueTypeEnum))
+			{
+			HBufC* value = iEnv->GetAsDesL(aValue.EnvVar()).AllocLC();
+			aValue.SetValueL(value);
+			CleanupStack::Pop(value);
+			}
+		else if (type == KValueTypeFileName)
+			{
+			TFileName2 fileName(iEnv->GetAsDesL(aValue.EnvVar()));
+			fileName.MakeAbsoluteL(iEnv->Pwd());
+			aValue.SetValueL(fileName, FsL());
+			}
+		else
+			{
+			TLex lex(iEnv->GetAsDesL(aValue.EnvVar()));
+			SetValueL(lex, aValue);
+			}
+		}
+	}
+
+
+
+template <class T> TBool ValueTypesConsistent(const T& aList)
+	{
+	// class T is expected to be either RCommandArgumentList or RCommandOptionList.
+	// Returns true if either all the list values have an uninitialized value type, or all have an initialized value type.
+	// Returns false if there is a mixture of unitialized and uninitialized value types.
+
+	TBool unitialized(EFalse);
+	const TInt count = aList.Count();
+	if (count > 0)
+		{
+		for (TInt i = 0; i < count; ++i)
+			{
+			if (i == 0)
+				{
+				unitialized = (aList[i].ValueType() == KValueTypeUninitialized);
+				}
+			else if (!unitialized != !(aList[i].ValueType() == KValueTypeUninitialized))
+				{
+				return EFalse;
+				}
+			}
+		}
+	return ETrue;
+	}
+
+template <class T> TBool ValueTypesInitialized(const T& aList)
+	{
+	return !(aList[0].ValueType() == KValueTypeUninitialized);
+	}
+
+
+TBool ValueTypesInitializedL(const RCommandArgumentList& aArguments, const RCommandOptionList& aOptions)
+	{
+	if (!ValueTypesConsistent(aArguments))
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Arguments inconsistently or incompletely initialized."));
+		}
+	if (!ValueTypesConsistent(aOptions))
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Options inconsistently or incompletely initialized."));
+		}
+	if (aArguments.Count() && aOptions.Count())
+		{
+		TBool argumentsInitialized(ValueTypesInitialized(aArguments));
+		TBool optionsInitialized(ValueTypesInitialized(aOptions));
+		if (!argumentsInitialized != !optionsInitialized)
+			{
+			StaticLeaveIfErr(KErrArgument, _L("Arguments and options inconsistently or incompletely initialized."));
+			}
+		}
+	if (aArguments.Count())
+		{
+		return ValueTypesInitialized(aArguments);
+		}
+	else if (aOptions.Count())
+		{
+		return ValueTypesInitialized(aOptions);
+		}
+	else
+		{
+		return ETrue;
+		}
+	}
+
+EXPORT_C TInt CCommandBase::ParseCommandLine(const TDesC& aCommandLine)
+	{
+	TRAPD(err, DoParseCommandLineL(aCommandLine));
+	return err;
+	}
+
+void CCommandBase::DoParseCommandLineL(const TDesC& aCommandLine)
+	{
+	// Read the CIF if required.
+	if (CifReadRequired())
+		{
+		ReadCifL();
+		}
+
+	// Add command specific arguments and options.
+	ArgumentsL(iArguments);
+	OptionsL(iOptions);
+
+	if (iCif)
+		{
+		TRAPD(err, iCif->AssignL(iArguments, iOptions));
+		if (err)
+			{
+			iFlags |= ECifReadFailed;
+			User::Leave(err);
+			}
+		__ASSERT_ALWAYS(ValueTypesInitializedL(iArguments, iOptions), Panic(EIncompleteArgumentOrOptionInitialization));
+		}
+
+	// Add global options.
+	iOptions.AppendBoolL(iDisplayHelp, TChar('h'), KHelpName, KHelpDescription);
+	iOptions.AppendStringL(iConsoleImplementation, TChar(0), KOptConsole, KNullDesC);
+	iOptions.AppendStringL(iConsoleTitle, TChar(0), KOptConsoleTitle, KNullDesC);
+	iOptions.AppendUintL(iConsoleSize, TChar(0), KOptConsoleSize, KNullDesC);
+	iOptions.AppendStringL(iPersistentConsoleName, TChar(0), KOptPersistentConsole, KNullDesC);
+
+	// Parse the command line.
+	ParseCommandLineL(aCommandLine);
+
+	// Set optional arguments that haven't been set explicitly from environment variables if applicable.
+	const TInt numArgs = iArguments.Count();
+	for (TInt i = 0; i < numArgs; ++i)
+		{
+		SetValueFromEnvL(iArguments[i]);
+		}
+
+	// Set options that haven't been set explicitly from environment variables if applicable.
+	const TInt numOpts = iOptions.Count();
+	for (TInt i = 0; i < numOpts; ++i)
+		{
+		SetValueFromEnvL(iOptions[i]);
+		}
+		
+	if (!iArguments.AllSet())
+		{
+		User::Leave(KErrArgument);
+		}
+	}
+
+TBool CCommandBase::CifReadRequired() const
+	{
+	if (iCif)
+		{
+		return EFalse;
+		}
+
+	// Call the virtual Description function to see if the sub-class has implemented it.
+	// If not, it is assumed that it expects a CIF file to be read.
+	Description();
+	return (iFlags & EReadCif);
+	}
+
+void CCommandBase::ReadCifL()
+	{
+	TRAPD(err, DoReadCifL());
+	if (err)
+		{
+		iFlags |= ECifReadFailed;
+		}
+	}
+
+void CCommandBase::DoReadCifL()
+	{
+	iCif = CCommandInfoFile::NewL(FsL(), Env(), Name());
+	iFlags |= EOwnsCif;
+	}
+
+EXPORT_C TBool CCommandBase::UsingCif() const
+	{
+	if (iCif)
+		{
+		return ETrue;
+		}
+	return (CifReadRequired());
+	}
+
+EXPORT_C void CCommandBase::ParseCommandLineL(const TDesC& aCommandLine)
+	{
+	TInt argumentIndex = 0;
+	TLex lex(aCommandLine);
+	lex.SkipSpace();
+	TBool lastArgSeen(EFalse);
+	while (!lex.Eos())
+		{
+		TBool isOption = EFalse;
+		if (!lastArgSeen && (lex.Peek() == TChar('-')))
+			{	// Start of an option.
+			isOption = ETrue;
+			lex.Get();
+			TChar peek = lex.Peek();
+			if (peek == TChar('-'))
+				{	// Start of a long named option.
+				lex.Get();
+				lex.Mark();
+				lex.SkipCharacters();
+				TInt optionIndex = iOptions.Find(lex.MarkedToken());
+				if (optionIndex < 0)
+					{
+					User::Leave(KErrArgument);
+					}
+				SetValueL(lex, iOptions[optionIndex]);
+				}
+			else if (peek.IsDigit())
+				{
+				// It could be a negative integer argument, providing there aren't any numeric short options.
+				// If there are, they take precedence, so don't use a digit as a short option unless you don't care about negative arguments
+				TInt optionIndex = iOptions.FindShort(peek);
+				if (optionIndex < 0)
+					{
+					isOption = EFalse; // get to the argument clause below
+					lex.UnGet(); // So the minus sign is picked up
+					}
+				}
+			
+			if (isOption)
+				{	// Start of a short option (or block of short options).
+				while (!lex.Eos() && !lex.Peek().IsSpace() && (lex.Peek() != TChar('-')))
+					{
+					TInt optionIndex = iOptions.FindShort(lex.Get());
+					if (optionIndex < 0)
+						{
+						User::Leave(KErrArgument);
+						}
+					SetValueL(lex, iOptions[optionIndex]);
+					}
+				}
+			}
+
+		if (!isOption)
+			{	// Start of an argument.
+			if (argumentIndex < iArguments.Count())
+				{
+				TCommandArgument& argument = iArguments[argumentIndex];
+				SetValueL(lex, argument);
+				if (!(argument.ValueType() & KValueTypeFlagMultiple))
+					{
+					++argumentIndex;
+					}
+				lastArgSeen = (argument.ValueType() & KValueTypeFlagLast);
+				// Look ahead to see if the next argument is the last, and if so set lastArgSeen early. This allows the next argument to be an option, but be treated as part of the 'last' string not an option for this command.
+				if (!lastArgSeen && (argumentIndex < iArguments.Count()))
+					{
+					lastArgSeen = (iArguments[argumentIndex].ValueType() & KValueTypeFlagLast);
+					}
+				}
+			else
+				{
+				User::Leave(KErrArgument);
+				}
+			}
+
+		lex.SkipSpace();
+		}
+	}
+
+const TDesC* CCommandBase::ReadCommandLineLC()
+	{
+#ifdef EKA2
+	HBufC* commandLine = HBufC::NewLC(User::CommandLineLength());
+	TPtr commandLinePtr(commandLine->Des());
+	User::CommandLine(commandLinePtr);
+#else
+	RProcess process;
+	HBufC* commandLine = HBufC::NewLC(process.CommandLineLength());
+	TPtr commandLinePtr(commandLine->Des());
+	process.CommandLine(commandLinePtr);
+#endif
+	return commandLine;
+	}
+
+void AppendHeadingL(const TDesC& aHeading, CTextBuffer& aBuffer)
+	{
+	_LIT(KFormat, "\r\n=head1 %S\r\n\r\n");
+	aBuffer.AppendFormatL(KFormat, &aHeading);
+	}
+
+void AppendSubCommandL(TInt aIndent, CTextBuffer& aBuffer, const CCommandInfoFile& aCif)
+	{
+	aBuffer.AppendSpacesL(aIndent);
+	aBuffer.AppendL(aCif.Name());
+	aBuffer.AppendL(KNewLine);
+
+	TInt numSubCommands = aCif.NumSubCommands();
+	for (TInt i = 0; i < numSubCommands; ++i)
+		{
+		AppendSubCommandL(aIndent + 2, aBuffer, aCif.SubCommand(i));
+		}
+	}
+
+EXPORT_C const CTextBuffer* CCommandBase::GetHelpTextL()
+	{
+	CTextBuffer* buffer = CTextBuffer::NewLC(0x100);
+
+	AppendHeadingL(_L("SYNTAX"), *buffer);
+	buffer->AppendFormatL(_L("    %S"), &Name());
+
+	const TInt numOptions = iOptions.Count();
+	if (numOptions > 0)
+		{
+		buffer->AppendL(_L(" [options]"));
+		}
+
+	const TInt numArguments = iArguments.Count();
+	if (numArguments > 0)
+		{
+		for (TInt i = 0; i < numArguments; ++i)
+			{
+			const TCommandArgument& thisArgument = iArguments[i];
+			TBool isOptional = thisArgument.IsOptional();
+			if (isOptional)
+				{
+				buffer->AppendL(_L(" [<"));
+				}
+			else
+				{
+				buffer->AppendL(_L(" <"));
+				}
+			buffer->AppendL(thisArgument.Name());
+			if (isOptional)
+				{
+				buffer->AppendL(_L(">]"));
+				}
+			else
+				{
+				buffer->AppendL(_L(">"));
+				}
+
+			if (thisArgument.AcceptsMultiple())
+				{
+				buffer->AppendL(_L(" ..."));
+				}
+			}
+		}
+	buffer->AppendL(_L("\r\n"));
+
+	if (numOptions > 0)
+		{
+		AppendHeadingL(_L("OPTIONS"), *buffer);
+		buffer->AppendL(_L("=over 5\r\n\r\n"));
+		for (TInt i = 0; i < numOptions; ++i)
+			{
+			const TCommandOption& thisOption = iOptions[i];
+			TChar shortName(thisOption.ShortName());
+			if (shortName)
+				{
+				buffer->AppendFormatL(_L("=item -%c (--%S)"), (TUint)shortName, &thisOption.Name());
+				switch (thisOption.ValueType() & KValueTypeFlagMask)
+					{
+					case KValueTypeBool:
+						{
+						// Do nothing.
+						break;
+						}
+					case KValueTypeInt:
+						{
+						buffer->AppendL(_L(" <int>"));
+						break;
+						}
+					case KValueTypeInt64:
+						{
+						buffer->AppendL(_L(" <int64>"));
+						break;
+						}
+					case KValueTypeUint:
+						{
+						buffer->AppendL(_L(" <uint>"));
+						break;
+						}
+					case KValueTypeUint64:
+						{
+						buffer->AppendL(_L(" <uint64>"));
+						break;
+						}
+					case KValueTypeString:
+						{
+						buffer->AppendL(_L(" <string>"));
+						break;
+						}
+					case KValueTypeFileName:
+						{
+						buffer->AppendL(_L(" <filename>"));
+						break;
+						}
+					case KValueTypeEnum:
+						{
+						buffer->AppendL(_L(" <enum>"));
+						break;
+						}
+					case KValueTypeReal:
+						{
+						buffer->AppendL(_L(" <real>"));
+						break;
+						}
+					default:
+						{
+						__ASSERT_ALWAYS(EFalse, Panic(EInvalidCommandOptionType));
+						break;
+						}
+					}
+				buffer->AppendFormatL(_L("\r\n\r\n%S"), &thisOption.Description());
+				if ((thisOption.ValueType() & KValueTypeFlagMask) == KValueTypeEnum)
+					{
+					if (thisOption.EnumDescriptionList().Length() > 0)
+						{
+						FormatEnumL(thisOption, *buffer);
+						}
+					else
+						{
+						buffer->AppendL(_L(" ["));
+						thisOption.AppendEnumValuesL(*buffer);
+						buffer->AppendL(']');
+						}
+					}
+				if (thisOption.ValueType() & KValueTypeFlagMultiple)
+					{
+					buffer->AppendL(_L(" Can be specified more than once."));
+					}
+				if (thisOption.EnvVar().Length() > 0)
+					{
+					const TDesC& envVar = thisOption.EnvVar();
+					buffer->AppendFormatL(_L(" Can also be specified by defining the environment variable \"%S\"."), &envVar);
+					}
+				buffer->AppendL(_L("\r\n\r\n"));
+				}
+			}
+		buffer->AppendL(_L("=back\r\n"));
+		}
+
+	if (numArguments > 0)
+		{
+		AppendHeadingL(_L("ARGUMENTS"), *buffer);
+		buffer->AppendL(_L("=over 5\r\n\r\n"));
+		for (TInt i = 0; i < numArguments; ++i)
+			{
+			buffer->AppendL(_L("=item "));
+			const TCommandArgument& thisArgument = iArguments[i];
+			TBool isOptional = thisArgument.IsOptional();
+			if (isOptional)
+				{
+				buffer->AppendL(_L("[<"));
+				}
+			else
+				{
+				buffer->AppendL(_L("<"));
+				}
+			buffer->AppendL(thisArgument.Name());
+			if (isOptional)
+				{
+				buffer->AppendL(_L(">]\r\n\r\n"));
+				}
+			else
+				{
+				buffer->AppendL(_L(">\r\n\r\n"));
+				}
+
+			buffer->AppendL(thisArgument.Description());
+
+			if (thisArgument.ValueType() & KValueTypeFlagMultiple)
+				{
+				buffer->AppendL(_L(" Can be specified more than once."));
+				}
+
+			if (thisArgument.EnvVar().Length() > 0)
+				{
+				const TDesC& envVar = thisArgument.EnvVar();
+				buffer->AppendFormatL(_L(" Can also be specified by defining the environment variable \"%S\"."), &envVar);
+				}
+
+			if (thisArgument.IsLast())
+				{
+				buffer->AppendFormatL(_L(" Any further arguments or options will be coalesced into this one."));
+				}
+
+			TBool noClosingSquareBracket(EFalse);
+
+			switch (thisArgument.ValueType() & KValueTypeFlagMask)
+				{
+				case KValueTypeInt:
+					{
+					buffer->AppendL(_L(" [int"));
+					break;
+					}
+				case KValueTypeInt64:
+					{
+					buffer->AppendL(_L(" [int64"));
+					break;
+					}
+				case KValueTypeUint:
+					{
+					buffer->AppendL(_L(" [uint"));
+					break;
+					}
+				case KValueTypeUint64:
+					{
+					buffer->AppendL(_L(" [uint64"));
+					break;
+					}
+				case KValueTypeString:
+					{
+					buffer->AppendL(_L(" [string"));
+					break;
+					}
+				case KValueTypeFileName:
+					{
+					buffer->AppendL(_L(" [filename"));
+					break;
+					}
+				case KValueTypeEnum:
+					{
+					if (thisArgument.EnumDescriptionList().Length() > 0)
+						{
+						FormatEnumL(thisArgument, *buffer);
+						noClosingSquareBracket = ETrue;
+						}
+					else
+						{
+						buffer->AppendL(_L(" ["));
+						thisArgument.AppendEnumValuesL(*buffer);
+						}
+					break;
+					}
+				case KValueTypeReal:
+					{
+					buffer->AppendL(_L(" [real"));
+					break;
+					}
+				default:
+					{
+					__ASSERT_ALWAYS(EFalse, Panic(EInvalidCommandArgumentType));
+					break;
+					}
+				}
+
+			if (!noClosingSquareBracket)
+				{
+				if (thisArgument.ValueType() & KValueTypeFlagMultiple)
+					{
+					buffer->AppendL(_L("(s)]\r\n\r\n"));
+					}
+				else
+					{
+					buffer->AppendL(_L("]\r\n\r\n"));
+					}
+				}
+			}
+		buffer->AppendL(_L("=back\r\n"));
+		}
+
+	AppendHeadingL(_L("DESCRIPTION"), *buffer);
+	buffer->AppendL(Description());
+	buffer->AppendL(_L("\r\n\r\n"));
+	if (iCif && iCif->LongDescription().Length())
+		{
+		buffer->AppendL(iCif->LongDescription());
+		buffer->AppendL(_L("\r\n\r\n"));
+		}
+
+	if (iCif && iCif->SeeAlso().Length())
+		{
+		AppendHeadingL(_L("SEE ALSO"), *buffer);
+		buffer->AppendL(iCif->SeeAlso());
+		buffer->AppendL(_L("\r\n\r\n"));
+		}
+
+	if (iCif && (iCif->NumSubCommands() > 0))
+		{
+		AppendHeadingL(_L("SUB-COMMANDS"), *buffer);
+		TInt numSubCommands = iCif->NumSubCommands();
+		for (TInt i = 0; i < numSubCommands; ++i)
+			{
+			AppendSubCommandL(2, *buffer, iCif->SubCommand(i));
+			}
+		}
+
+	if (iCif && iCif->Copyright().Length())
+		{
+		AppendHeadingL(_L("COPYRIGHT"), *buffer);
+		buffer->AppendL(iCif->Copyright());
+		buffer->AppendL(_L("\r\n\r\n"));
+		}
+	
+	CTextFormatter* textFormatter = CTextFormatter::NewLC(Stdout());
+	textFormatter->AppendPodL(buffer->Descriptor());
+	CleanupStack::Pop(textFormatter);
+	CleanupStack::PopAndDestroy(buffer);
+	return textFormatter;
+	}
+
+void CCommandBase::DisplayHelpAndComplete()
+	{
+	const CTextBuffer* helpText = NULL;
+	TRAPD(err, helpText = GetHelpTextL());
+	if (err)
+		{
+		Complete(err, _L("Error displaying help"));
+		}
+	else
+		{
+		CleanupStack::PushL(const_cast<CTextBuffer*>(helpText));
+		CheckNewLine();
+		PageL(*helpText);
+		Complete();
+		CleanupStack::PopAndDestroy(const_cast<CTextBuffer*>(helpText));
+		}
+	}
+
+void CCommandBase::DisplayHelpAndComplete(TInt aError, const TDesC& aText)
+	{
+	CheckNewLine();
+	PrintError(aError, aText);
+	const CTextBuffer* helpText = NULL;
+	TRAPD(err, helpText = GetHelpTextL());
+	if (err == KErrNone)
+		{
+		CleanupStack::PushL(const_cast<CTextBuffer*>(helpText));
+		PageL(*helpText);
+		CleanupStack::PopAndDestroy(const_cast<CTextBuffer*>(helpText));
+		}
+	Complete(aError);
+	}
+
+void CCommandBase::FormatErrorText(TDes& aDes, TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList) const
+	{
+	TOverflowTruncate overflow;
+	aDes = _L("Error: ");
+	aDes.AppendFormatList(aFmt, aList, &overflow);
+	aDes.AppendFormat(_L(" : %S (%d)\r\n"), &overflow, Stringify::Error(aError), aError);
+	}
+
+void CCommandBase::FormatWarningText(TDes& aDes, TRefByValue<const TDesC> aFmt, VA_LIST& aList) const
+	{
+	TOverflowTruncate overflow;
+	aDes = _L("Warning: ");
+	aDes.AppendFormatList(aFmt, aList, &overflow);
+	if ((aDes.Length() < KNewLine().Length()) || ((aDes.Right(KNewLine().Length()) != KNewLine)))
+		{
+		aDes.AppendFormat(KNewLine, &overflow);
+		}
+	}
+
+void CCommandBase::CheckNewLine()
+	{
+	if (iStderr.AttachedToConsole())
+		{
+		TPoint cursorPos(0, 0);
+		iStderr.GetCursorPos(cursorPos);
+		if (cursorPos.iX != 0)
+			{
+			iStderr.Write(_L("\r\n"));
+			}
+		}
+	}
+
+void CCommandBase::FormatEnumL(const TValue& aValue, CTextBuffer& aBuffer) const
+	{
+	aBuffer.AppendL(_L(" Supported values are:\r\n\r\n=over 5\r\n\r\n"));
+	TLex descLex(aValue.EnumDescriptionList());
+	TLex valLex(aValue.EnumValueList());
+	while (!valLex.Eos())
+		{
+		HBufC* value = ReadStringLC(valLex, EBreakOnComma);
+		__ASSERT_ALWAYS(!descLex.Eos(), IoUtils::Panic(EEnumDescriptionMissing));
+		HBufC* description = ReadStringLC(descLex, EBreakOnComma);
+		aBuffer.AppendFormatL(_L("=item %S\r\n\r\n%S\r\n\r\n"), value, description);
+		CleanupStack::PopAndDestroy(2, value);
+		}
+	aBuffer.AppendL(_L("=back\r\n\r\n"));
+	}
+
+EXPORT_C void CCommandBase::CreateEnvironmentL(CEnvironment* aEnv)
+	{
+	if (aEnv)
+		{
+		iEnv = aEnv;
+		}
+	else
+		{
+		iEnv = CEnvironment::NewL();
+		iFlags |= EOwnsEnv;
+#ifdef EKA2
+		const TInt length = User::ParameterLength(KEnvironmentProcessSlot);
+		if (length > 0)
+			{
+			HBufC8* buf = HBufC8::NewLC(length);
+			TPtr8 bufPtr(buf->Des());
+			User::LeaveIfError(User::GetDesParameter(KEnvironmentProcessSlot, bufPtr));
+			iEnv->InternalizeL(bufPtr);
+			CleanupStack::PopAndDestroy(buf);
+			}
+#endif
+		}
+	}
+
+EXPORT_C void CCommandBase::RunL()
+	{
+	if (iFlags & ECompleteOnRunL)
+		{
+		Complete(iStatus.Int());
+		}
+	else
+		{
+		// if a derived class ever makes this Active Object active, it must also override this unless ECompleteOnRunL is specified.
+		Panic(EActiveObjectRunLNotOverridden);
+		}
+	}
+
+EXPORT_C void CCommandBase::DoCancel()
+	{
+	// if a derived class ever makes this Active Object active, it must also override this.
+	Panic(EActiveObjectRunLNotOverridden);
+	}
+
+EXPORT_C TInt CCommandBase::RunError(TInt aError)
+	{
+	HandleLeave(aError);
+	return KErrNone;
+	}
+
+EXPORT_C CConsoleBase* CCommandBase::GetConsoleBaseL()
+	{
+	CIoConsole* console = new(ELeave) CIoConsole(Stdin(), Stdout());
+	return console;
+	}
+
+EXPORT_C CColorConsoleBase* CCommandBase::GetColorConsoleBaseL()
+	{
+	// CIoConsole now derives from CColorConsoleBase so implementation is the same as GetConsoleBaseL
+	CIoConsole* console = new(ELeave) CIoConsole(Stdin(), Stdout());
+	return console;
+	}
+
+EXPORT_C CCommandBase& CCommandBase::Static()
+	{
+	CCommandBase* self = static_cast<CCommandBase*>(Dll::Tls());
+	__ASSERT_ALWAYS(self, Panic(ENoStaticCommand));
+	return *self;
+	}
+	
+EXPORT_C TBool CCommandBase::HaveStatic()
+	{
+	CCommandBase* self = static_cast<CCommandBase*>(Dll::Tls());
+	return (self != NULL);
+	}
+	
+EXPORT_C void CCommandBase::StdinChange(TUint /*aChange*/)
+	{
+	}
+
+EXPORT_C void CCommandBase::DisplayHelp()
+	{
+	const CTextBuffer* helpText = NULL;
+	TRAPD(err, helpText = GetHelpTextL());
+	if (err)
+		{
+		PrintError(err, _L("Error displaying help"));
+		}
+	else
+		{
+		CleanupStack::PushL(const_cast<CTextBuffer*>(helpText));
+		CheckNewLine();
+		PageL(*helpText);
+		CleanupStack::PopAndDestroy(const_cast<CTextBuffer*>(helpText));
+		}
+	}
+
+namespace IoUtils
+	{
+	class MLineReader
+		{
+	public:
+		virtual TInt GetNextLine(CTextBuffer& aText) = 0;
+		virtual void InitializeL() {}
+		};
+
+	NONSHARABLE_CLASS(TTextBufferLineReader) : public MLineReader
+		{
+	public:
+		TTextBufferLineReader(const CTextBuffer& aBuffer);
+	public: // From MLineReader.
+		virtual TInt GetNextLine(CTextBuffer& aText);
+	private:
+		const CTextBuffer& iBuffer;
+		TInt iPos;
+		};
+
+	NONSHARABLE_CLASS(TReadHandleLineReader) : public MLineReader
+		{
+	public:
+		TReadHandleLineReader(RIoReadHandle& aHandle);
+	public: // From MLineReader.
+		virtual void InitializeL();
+		virtual TInt GetNextLine(CTextBuffer& aText);
+	private:
+		RIoReadHandle& iHandle;
+		TBuf<512> iLineBuf; // Note, the code in CCommandBase::PageL(MLineReader&) doesn't properly handle the situation where a given line of input is longer than this buffer.
+		};
+	}
+
+TTextBufferLineReader::TTextBufferLineReader(const CTextBuffer& aBuffer)
+	: iBuffer(aBuffer), iPos(0)
+	{
+	}
+
+TInt TTextBufferLineReader::GetNextLine(CTextBuffer& aText)
+	{
+	aText.Zero();
+	TInt newLinePos = iBuffer.Descriptor().Mid(iPos).Find(KNewLine);
+	if (newLinePos < 0)
+		{
+		if (iPos < iBuffer.Length())
+			{
+			aText.AppendL(iBuffer, iPos);
+			return KErrNone;
+			}
+		return KErrNotFound;
+		}
+	else
+		{
+		const TInt lineLength = newLinePos + KNewLine().Length();
+		aText.AppendL(iBuffer, iPos, lineLength);
+		iPos += lineLength;
+		return KErrNone;
+		}
+	}
+
+TReadHandleLineReader::TReadHandleLineReader(RIoReadHandle& aHandle)
+	: iHandle(aHandle)
+	{
+	}
+
+void TReadHandleLineReader::InitializeL()
+	{
+	iHandle.SetReadModeL(RIoReadHandle::ELine);
+	}
+
+TInt TReadHandleLineReader::GetNextLine(CTextBuffer& aText)
+	{
+	aText.Zero();
+	TInt err = iHandle.Read(iLineBuf);
+	if (err == KErrNone)
+		{
+		aText.AppendL(iLineBuf);
+		}
+	else if (err == KErrEof)
+		{
+		err = KErrNotFound;
+		}
+	return err;
+	}
+
+
+EXPORT_C void CCommandBase::PageL(const CTextBuffer& aText)
+	{
+	TTextBufferLineReader lineReader(aText);
+	lineReader.InitializeL();
+	PageL(lineReader);
+	}
+
+EXPORT_C void CCommandBase::PageL(RIoReadHandle& aInput)
+	{
+	TReadHandleLineReader lineReader(aInput);
+	lineReader.InitializeL();
+	PageL(lineReader);
+	}
+
+void CCommandBase::PageL(MLineReader& aLineReader)
+	{
+	_LIT(KPrompt, "--More--");
+	_LIT(KRemovePrompt, "\x08\x08\x08\x08\x08\x08\x08\x08        \x08\x08\x08\x08\x08\x08\x08\x08");
+
+	if (iStdout.AttachedToConsole())
+		{
+		RIoConsole console;
+		console.OpenL(IoSession(), iStdout);
+		CleanupClosePushL(console);
+		RIoConsoleReadHandle consReader;
+		consReader.CreateL(IoSession());
+		CleanupClosePushL(consReader);
+		console.AttachL(consReader, RIoEndPoint::EForeground);
+		consReader.CaptureAllKeysL();
+		TSize consoleSize = iStdout.GetScreenSizeL();
+		CTextBuffer* lineBuf = CTextBuffer::NewLC(0x100);
+		TInt linesPrinted = 0;
+		TBool finished(EFalse);
+		while (!finished)
+			{
+			if (linesPrinted < (consoleSize.iHeight - 1))
+				{
+				if (lineBuf->Length() == 0)
+					{
+					TInt err = aLineReader.GetNextLine(*lineBuf);
+					if (err == KErrNotFound)
+						{
+						finished = ETrue;
+						}
+					else if (err)
+						{
+						User::Leave(err);
+						}
+					}
+
+				if (!finished && lineBuf->Length())
+					{
+					const TInt lineLength = lineBuf->Length();
+					const TInt numConsoleLines = ((lineLength / consoleSize.iWidth) + ((lineLength % consoleSize.iWidth) ? 1 : 0));
+					const TInt numFreeLines = consoleSize.iHeight - linesPrinted - 1;
+					TInt lengthToWrite;
+					if (numConsoleLines < numFreeLines)
+						{
+						lengthToWrite = lineLength;
+						}
+					else
+						{
+						lengthToWrite = Min(lineLength, numFreeLines * consoleSize.iWidth);
+						}
+
+					lineBuf->Write(iStdout, 0, lengthToWrite);
+					linesPrinted += ((lengthToWrite / consoleSize.iWidth) + ((lengthToWrite % consoleSize.iWidth) ? 1 : 0));
+					lineBuf->Delete(0, lengthToWrite);
+
+					if (lineBuf->Length() == 0)
+						{
+						TInt err = aLineReader.GetNextLine(*lineBuf);
+						if (err == KErrNotFound)
+							{
+							finished = ETrue;
+							}
+						else if (err)
+							{
+							User::Leave(err);
+							}
+						}
+					}
+				}
+			else
+				{
+				iStdout.Write(KPrompt);
+				switch ((TInt)consReader.ReadKey())
+					{
+					case 'q':
+					case 'Q':
+					case EKeyNull:
+						{
+						finished = ETrue;
+						break;
+						}
+					case EKeyEnter:
+						{
+						--linesPrinted;
+						break;
+						}
+					default:
+						{
+						linesPrinted = 0;
+						break;
+						}
+					}
+				iStdout.Write(KRemovePrompt);
+				}
+			}
+		CleanupStack::PopAndDestroy(3, &console);
+		}
+	else
+		{
+		// Not attached to a console, so just copy stdin to stdout.
+		CTextBuffer* lineBuf = CTextBuffer::NewLC(0x100);
+		while (aLineReader.GetNextLine(*lineBuf) == KErrNone)
+			{
+			iStdout.Write(lineBuf->Descriptor());
+			}
+		CleanupStack::PopAndDestroy(lineBuf);
+		}
+	}
+
+EXPORT_C const TDesC& CCommandBase::Description() const
+	{
+	if (iCif == NULL)
+		{
+		const_cast<CCommandBase*>(this)->iFlags |= EReadCif;
+		return KNullDesC; // Dummy return value.
+		}
+	return iCif->ShortDescription();
+	}
+	
+EXPORT_C const TDesC* CCommandBase::ConsoleImplementation()
+	{
+	return iConsoleImplementation;
+	}
+
+EXPORT_C void CCommandBase::SetErrorReported(TBool aReported)
+	{
+	if (aReported)
+		{
+		iFlags |= EErrorReported;
+		}
+	else
+		{
+		iFlags &= ~EErrorReported;
+		}
+	}
+
+EXPORT_C void CCommandBase::StartSupressingErrors()
+	{
+	iSupressingErrors++;
+	}
+
+EXPORT_C void CCommandBase::StopSupressingErrors()
+	{
+	iSupressingErrors--;
+	}
+
+EXPORT_C TBool CCommandBase::IsComplete() const
+	{
+	return (iFlags & ECompleted);
+	}
+
+EXPORT_C TInt CCommandBase::CompletionReason() const
+	{
+	__ASSERT_ALWAYS(IsComplete(), Panic(ENotYetComplete));
+	return iCompletionReason;
+	}
+
+HBufC* CCommandBase::ReadStringLC(TLex& aLex, TUint aOptions) const
+	{
+	while (!aLex.Eos() && (aLex.Peek().IsSpace() || ((aOptions & EBreakOnComma) && (aLex.Peek() == ','))))
+		{
+		aLex.Inc();
+		}
+
+	if (aLex.Eos())
+		{
+		// There aren't any characters at all. This can be considered a syntax error because if an empty string was intended
+		// it should have been written as "" or ''.
+		CommandLeaveIfErr(*const_cast<CCommandBase*>(this), KErrArgument, _L("Missing argument"));
+		}
+
+	TChar c = aLex.Peek();
+	TBool quoted = ((c == '\'') || (c == '"') || (c == iEnv->EscapeChar()));
+	TUint readMode = 0;
+	if (aOptions & EBreakOnComma)
+		{
+		readMode |= Stringify::EBreakOnComma;
+		}
+	HBufC* string = Stringify::ReadLC(aLex, iEnv->EscapeChar(), *const_cast<CCommandBase*>(this), readMode);
+	if ((aOptions & EDisallowLeadingHyphen) && (string->Length() > 0) && ((*string)[0] == '-') && !quoted)
+		{
+		CommandLeaveIfErr(*const_cast<CCommandBase*>(this), KErrArgument, _L("Argument \"%S\" appears to be an option - probable missing argument"), string);
+		}
+	return string;
+	}
+
+EXPORT_C void RChildProcess::Close()
+	{
+	iStderr.Close();
+	iStdout.Close();
+	iStdin.Close();
+	iProcess.Close();
+	}
+
+void SetIoObjectName(RIoSession& aIoSession, TInt aObjHandle, TRefByValue<const TDesC> aFmt, ...)
+	{
+	TOverflowTruncate overflow;
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TFullName name;
+	name.AppendFormatList(aFmt, list, &overflow);
+	VA_END(list);
+	aIoSession.SetObjectName(aObjHandle, name);
+	}
+
+EXPORT_C void RChildProcess::CreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr)
+	{
+	DoCreateL(aExecutableName, aCommandLine, aIoSession, aStdin, aStdout, aStderr, NULL);
+	}
+
+EXPORT_C void RChildProcess::CreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const CEnvironment& aEnv)
+	{
+	DoCreateL(aExecutableName, aCommandLine, aIoSession, aStdin, aStdout, aStderr, &aEnv);
+	}
+	
+EXPORT_C void RChildProcess::CreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, RIoSession& aIoSession, RIoConsole& aConsole, const CEnvironment* aEnv)
+	{
+	CleanupClosePushL(*this);
+	iStdin.CreateL(aIoSession);
+	iStdout.CreateL(aIoSession);
+	iStderr.CreateL(aIoSession);
+	
+	NameHandles(aExecutableName, aIoSession);
+	
+	aConsole.AttachL(iStdin, RIoEndPoint::EForeground);
+	iStdin.SetUnderlyingConsoleL(aConsole);
+	aConsole.AttachL(iStdout);
+	iStdout.SetUnderlyingConsoleL(aConsole);
+	aConsole.AttachL(iStderr);
+	iStderr.SetUnderlyingConsoleL(aConsole);
+	
+	ProcessCreateL(aExecutableName, aCommandLine, aEnv);
+	
+	CleanupStack::Pop();
+	}
+
+void RChildProcess::NameHandles(const TDesC& aExecutableName, RIoSession& aIoSession)
+	{
+	// Give the handles a name to aid debugging (makes the iosvr logs easier to understand).
+	SetIoObjectName(aIoSession, iStdin.SubSessionHandle(), _L("%S_stdin"), &aExecutableName);
+	SetIoObjectName(aIoSession, iStdout.SubSessionHandle(), _L("%S_stdout"), &aExecutableName);
+	SetIoObjectName(aIoSession, iStderr.SubSessionHandle(), _L("%S_stderr"), &aExecutableName);
+	}
+
+void RChildProcess::DoCreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const CEnvironment* aEnv)
+	{
+	CleanupClosePushL(*this);
+
+	// Create a set of I/O handles for the new process.
+	User::LeaveIfError(iStdin.Create(aIoSession));
+	User::LeaveIfError(iStdout.Create(aIoSession));
+	User::LeaveIfError(iStderr.Create(aIoSession));
+	
+	NameHandles(aExecutableName, aIoSession);
+
+	// Make the newly created handles duplicates of the ones that were passed in.
+	// This makes them attached to the same I/O end-points (consoles, files, etc)
+	// as the passed in handles.
+	User::LeaveIfError(iStdin.Duplicate(aStdin));
+	User::LeaveIfError(iStdin.SetToForeground());
+	User::LeaveIfError(iStdout.Duplicate(aStdout));
+	User::LeaveIfError(iStderr.Duplicate(aStderr));
+
+	// Create the process.
+	ProcessCreateL(aExecutableName, aCommandLine, aEnv);
+	
+	CleanupStack::Pop(this);	
+	}
+	
+void RChildProcess::ProcessCreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, const CEnvironment* aEnv)
+	{
+	User::LeaveIfError(iProcess.Create(aExecutableName, aCommandLine));
+
+#ifdef EKA2
+	if (aEnv)
+		{
+		// Attach a copy of aEnv as a parameter.
+		HBufC8* envBuf = aEnv->ExternalizeLC();
+		User::LeaveIfError(iProcess.SetParameter(IoUtils::KEnvironmentProcessSlot, *envBuf));
+		CleanupStack::PopAndDestroy(envBuf);
+		}
+#endif
+
+	// Make the main thread of the new process the owner of the I/O handles.
+	// This makes it possible for the new process to subsequently open them and
+	// avoid having to create a new set (which would prevent end-point sharing).
+	TFullName fullName(iProcess.Name());
+	_LIT(KThreadName,"::Main");
+	fullName.Append(KThreadName);
+	RThread thread;
+	User::LeaveIfError(thread.Open(fullName));
+	TThreadId threadId(thread.Id());
+	thread.Close();
+	User::LeaveIfError(iStdin.SetOwner(threadId));
+	User::LeaveIfError(iStdout.SetOwner(threadId));
+	User::LeaveIfError(iStderr.SetOwner(threadId));
+	}
+
+EXPORT_C void RChildProcess::Run(TRequestStatus& aStatus)
+	{
+	iProcess.Logon(aStatus);
+	if (aStatus != KRequestPending)
+		{
+		iProcess.Kill(KErrAbort);
+		}
+	else
+		{
+		iProcess.Resume();
+		}
+	}
+	
+EXPORT_C void RChildProcess::Detach()
+	{
+	iProcess.Resume();
+	}
+
+EXPORT_C RProcess& RChildProcess::Process()
+	{
+	return iProcess;
+	}
+
+EXPORT_C const RProcess& RChildProcess::Process() const
+	{
+	return iProcess;
+	}
+
+#define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
+#define CASE_RETURN_LIT2(XXX, YYY) case XXX: { _LIT(_KLit, YYY); return &_KLit; }
+#define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
+	
+EXPORT_C const TDesC* Stringify::Error(TInt aError)
+	{
+	enum TThingsNotAvailableEverywhere
+		{
+		KErrNoSecureTime = -49,
+		KErrCorruptSurrogateFound = -50,
+		};
+
+	switch (aError)
+		{
+		CASE_RETURN_LIT(KErrNone);
+		CASE_RETURN_LIT(KErrNotFound);
+		CASE_RETURN_LIT(KErrGeneral);
+		CASE_RETURN_LIT(KErrCancel);
+		CASE_RETURN_LIT(KErrNoMemory);
+		CASE_RETURN_LIT(KErrNotSupported);
+		CASE_RETURN_LIT(KErrArgument);
+		CASE_RETURN_LIT(KErrTotalLossOfPrecision);
+		CASE_RETURN_LIT(KErrBadHandle);
+		CASE_RETURN_LIT(KErrOverflow);
+		CASE_RETURN_LIT(KErrUnderflow);
+		CASE_RETURN_LIT(KErrAlreadyExists);
+		CASE_RETURN_LIT(KErrPathNotFound);
+		CASE_RETURN_LIT(KErrDied);
+		CASE_RETURN_LIT(KErrInUse);
+		CASE_RETURN_LIT(KErrServerTerminated);
+		CASE_RETURN_LIT(KErrServerBusy);
+		CASE_RETURN_LIT(KErrCompletion);
+		CASE_RETURN_LIT(KErrNotReady);
+		CASE_RETURN_LIT(KErrUnknown);
+		CASE_RETURN_LIT(KErrCorrupt);
+		CASE_RETURN_LIT(KErrAccessDenied);
+		CASE_RETURN_LIT(KErrLocked);
+		CASE_RETURN_LIT(KErrWrite);
+		CASE_RETURN_LIT(KErrDisMounted);
+		CASE_RETURN_LIT(KErrEof);
+		CASE_RETURN_LIT(KErrDiskFull);
+		CASE_RETURN_LIT(KErrBadDriver);
+		CASE_RETURN_LIT(KErrBadName);
+		CASE_RETURN_LIT(KErrCommsLineFail);
+		CASE_RETURN_LIT(KErrCommsFrame);
+		CASE_RETURN_LIT(KErrCommsOverrun);
+		CASE_RETURN_LIT(KErrCommsParity);
+		CASE_RETURN_LIT(KErrTimedOut);
+		CASE_RETURN_LIT(KErrCouldNotConnect);
+		CASE_RETURN_LIT(KErrCouldNotDisconnect);
+		CASE_RETURN_LIT(KErrDisconnected);
+		CASE_RETURN_LIT(KErrBadLibraryEntryPoint);
+		CASE_RETURN_LIT(KErrBadDescriptor);
+		CASE_RETURN_LIT(KErrAbort);
+		CASE_RETURN_LIT(KErrTooBig);
+		CASE_RETURN_LIT(KErrDivideByZero);
+		CASE_RETURN_LIT(KErrBadPower);
+		CASE_RETURN_LIT(KErrDirFull);
+		CASE_RETURN_LIT(KErrHardwareNotAvailable);
+#ifdef EKA2
+		CASE_RETURN_LIT(KErrSessionClosed);
+		CASE_RETURN_LIT(KErrPermissionDenied);
+		CASE_RETURN_LIT(KErrExtensionNotSupported);
+		CASE_RETURN_LIT(KErrCommsBreak);
+		CASE_RETURN_LIT(KErrNoSecureTime);
+		CASE_RETURN_LIT(KErrCorruptSurrogateFound);
+#endif
+		DEFAULT_RETURN_LIT("*** ERROR UNKNOWN ***");
+		}
+	}
+
+EXPORT_C void IoUtils::ReadL(TDes& aData)
+	{
+	CCommandBase::Static().ReadL(aData);
+	}
+
+EXPORT_C void IoUtils::Write(const TDesC& aData)
+	{
+	CCommandBase::Static().Write(aData);
+	}
+
+EXPORT_C void IoUtils::Printf(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	CCommandBase::Static().PrintList(aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void IoUtils::Printf(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	CCommandBase::Static().PrintList(aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void IoUtils::PrintError(TInt aError, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	CCommandBase::Static().PrintErrorList(aError, aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void IoUtils::PrintWarning(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	CCommandBase::Static().PrintWarningList(aFmt, list);
+	VA_END(list);
+	}
+
+
+//
+// CCommandCompleter.
+//
+
+CCommandCompleter::CCommandCompleter(IoUtils::CCommandBase& aCmd)
+	: CActive(CActive::EPriorityStandard), iCmd(aCmd)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CCommandCompleter::~CCommandCompleter()
+	{
+	Cancel();
+	delete iTextBuffer;
+	}
+
+void CCommandCompleter::Complete(TInt aError)
+	{
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete(status, aError);
+	SetActive();
+	}
+
+void CCommandCompleter::Complete(TInt aError, const TDesC& aText, RIoWriteHandle& aWhere)
+	{
+	TOverflowTruncate overflow;
+	iBuf.AppendFormat(aText, &overflow);
+	iError = aError;
+	aWhere.Write(iBuf, iStatus);
+	SetActive();
+	}
+	
+void CCommandCompleter::Complete(TInt aError, const CTextBuffer* aTextBuffer, RIoWriteHandle& aWhere)
+	{
+	ASSERT(iTextBuffer == NULL);
+	iTextBuffer = aTextBuffer;
+	iError = aError;
+	iTextBuffer->Write(aWhere, iStatus);
+	SetActive();
+	}
+
+void CCommandCompleter::RunL()
+	{
+	iCmd.CompleteCallback(iError ? iError : iStatus.Int());
+	}
+
+void CCommandCompleter::DoCancel()
+	{
+	}
+	
+
+//
+// CReaderChangeNotifier.
+//
+
+CReaderChangeNotifier::CReaderChangeNotifier(IoUtils::CCommandBase& aCmd, RIoReadHandle& aReadHandle)
+	: CActive(CActive::EPriorityStandard)
+	, iCmd(aCmd)
+	, iReadHandle(aReadHandle)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CReaderChangeNotifier::~CReaderChangeNotifier()
+	{
+	Cancel();
+	}
+
+void CReaderChangeNotifier::Notify()
+	{
+	iReadHandle.NotifyChange(iChangeType, iStatus);
+	SetActive();
+	}
+
+void CReaderChangeNotifier::RunL()
+	{
+	if (iStatus.Int()==KErrNone)
+		{
+		TUint change = iChangeType();
+		Notify();
+		iCmd.StdinChange(change);
+		}
+	}
+
+void CReaderChangeNotifier::DoCancel()
+	{
+	iReadHandle.CancelNotifyChange();
+	}
+
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/command_base.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,57 @@
+// command_base.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __COMMAND_BASE_H__
+#define __COMMAND_BASE_H__
+
+#include <e32base.h>
+
+namespace IoUtils
+	{
+
+	NONSHARABLE_CLASS(CCommandCompleter) : public CActive
+		{
+	public:
+		CCommandCompleter(IoUtils::CCommandBase& aCmd);
+		~CCommandCompleter();
+		void Complete(TInt aError);
+		void Complete(TInt aError, const TDesC& aText, RIoWriteHandle& aWhere);
+		void Complete(TInt aError, const CTextBuffer* aTextBuffer, RIoWriteHandle& aWhere);
+	private:
+		virtual void RunL();
+		virtual void DoCancel();
+	private:
+		IoUtils::CCommandBase& iCmd;
+		TInt iError;
+		const CTextBuffer* iTextBuffer;
+		TBuf<0x100> iBuf;
+		};
+
+	NONSHARABLE_CLASS(CReaderChangeNotifier) : public CActive
+		{
+	public:
+		CReaderChangeNotifier(IoUtils::CCommandBase& aCmd, RIoReadHandle& aReadHandle);
+		~CReaderChangeNotifier();
+		void Notify();
+	private:
+		virtual void RunL();
+		virtual void DoCancel();
+	private:
+		IoUtils::CCommandBase& iCmd;
+		RIoReadHandle& iReadHandle;
+		TPckgBuf<TUint> iChangeType;
+		};
+
+	void Panic(TCmdBasePanic aReason);
+	}
+	
+#endif //__COMMAND_BASE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/command_info_file.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,893 @@
+// command_info_file.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <f32file.h>
+#include "ioutils.h"
+#include "command_base.h"
+
+_LIT(KCifExt, ".cif");
+_LIT(KCifPathVar, "CIF_PATH");
+_LIT(KCifPath, "\\resource\\cif\\fshell");
+_LIT(KEnumSeparator, ",");
+_LIT(KEnumQuote, "\"");
+_LIT(KNewLine, "\r\n");
+_LIT(KPartialCommandStart, "==");
+_LIT(KCommandStart, "\r\n==");
+_LIT(KCmndName, "name");
+_LIT(KCmndShortDescription, "short-description");
+_LIT(KCmndLongDescription, "long-description");
+_LIT(KCmndSeeAlso, "see-also");
+_LIT(KCmndCopyright, "copyright");
+_LIT(KCmndArgument, "argument");
+_LIT(KCmndOption, "option");
+_LIT(KCmndInclude, "include");
+_LIT(KCmndSubCommand, "sub-command");
+_LIT(KCmndEnumValue, "enum-value");
+_LIT(KCmndFlagOptional, "optional");
+_LIT(KCmndFlagMultiple, "multiple");
+_LIT(KCmndFlagLast, "last");
+_LIT(KTypeBool, "bool");
+_LIT(KTypeInt, "int");
+_LIT(KTypeUint, "uint");
+_LIT(KTypeString, "string");
+_LIT(KTypeFileName, "filename");
+_LIT(KTypeEnum, "enum");
+_LIT(KTypeReal, "real");
+_LIT(KTypeUint64, "uint64");
+_LIT(KTypeInt64, "int64");
+
+using namespace IoUtils;
+
+TInt SkipTo(TLex& aLex, const TDesC& aDes)
+	{
+	TInt ret = aLex.Remainder().Find(aDes);
+	if (ret >= 0)
+		{
+		aLex.Inc(ret);
+		return KErrNone;
+		}
+	return KErrNotFound;
+	}
+
+TInt SkipToEnd(TLex& aLex, const TDesC& aDes)
+	{
+	TInt ret = aLex.Remainder().Find(aDes);
+	if (ret >= 0)
+		{
+		aLex.Inc(ret + aDes.Length());
+		return KErrNone;
+		}
+	return KErrNotFound;
+	}
+
+TInt SkipToNextCommand(TLex& aLex)
+	{
+	if ((aLex.Offset() == 0) && (aLex.Remainder().Find(KPartialCommandStart) == 0))
+		{
+		return KErrNone;
+		}
+
+	return SkipTo(aLex, KCommandStart);
+	}
+
+TPtrC NextCommand(TLex& aLex)
+	{
+	TPtrC command;
+	if (SkipToNextCommand(aLex) == KErrNone)
+		{
+		SkipToEnd(aLex, KPartialCommandStart);
+		aLex.Mark();
+		aLex.SkipCharacters();
+		command.Set(aLex.MarkedToken());
+		}
+	else
+		{
+		aLex.Inc(aLex.Remainder().Length());
+		}
+	return command;
+	}
+
+TPtrC LineRemainder(TLex& aLex)
+	{
+	aLex.Mark();
+	if (SkipTo(aLex, KNewLine) == KErrNone)
+		{
+		return aLex.MarkedToken();
+		}
+	else
+		{
+		return aLex.Remainder();
+		}
+	}
+
+TPtrC NextWord(TLex& aLex)
+	{
+	aLex.SkipSpaceAndMark();
+	aLex.SkipCharacters();
+	TPtrC word(aLex.MarkedToken());
+	return word;
+	}
+
+TPtrC TextToNextCommand(TLex& aLex)
+	{
+	aLex.Mark();
+
+	if (SkipToNextCommand(aLex) != KErrNone)
+		{
+		aLex.Inc(aLex.Remainder().Length());
+		}
+
+	TLex lex(aLex.MarkedToken());
+	
+	// Strip leading white space.
+	while (!lex.Eos())
+		{
+		if (lex.Peek().IsSpace())
+			{
+			lex.Get();
+			}
+		else
+			{
+			break;
+			}
+		}
+	lex.Mark();
+	TInt startOffset = lex.Offset();
+
+	// Remove trailing white space.
+	lex.Inc(lex.Remainder().Length());
+	while (lex.Offset() > startOffset)
+		{
+		lex.UnGet();
+		if (!lex.Peek().IsSpace())
+			{
+			lex.Get();
+			break;
+			}
+		}
+
+	return lex.MarkedToken();
+	}
+
+void AppendL(RBuf& aBuf, const TDesC& aDes, TBool aQuote)
+	{
+	const TInt requiredSpace = aDes.Length() + ((aBuf.Length() == 0) ? 0 : KEnumSeparator().Length()) + (aQuote ? 2 : 0);
+	if ((aBuf.Length() + requiredSpace) > aBuf.MaxLength())
+		{
+		aBuf.ReAllocL(Max(aBuf.Length() * 2, aBuf.Length() + requiredSpace));
+		}
+	if (aBuf.Length() > 0)
+		{
+		aBuf.Append(KEnumSeparator);
+		}
+	if (aQuote)
+		{
+		aBuf.Append(KEnumQuote);
+		}
+	aBuf.Append(aDes);
+	if (aQuote)
+		{
+		aBuf.Append(KEnumQuote);
+		}
+	}
+
+void GetEnumValuesL(TLex& aLex, RBuf& aValues, RBuf& aDescriptions)
+	{
+	aValues.CreateL(0x100);
+	aDescriptions.CreateL(0x100);
+
+	while (!aLex.Eos())
+		{
+		TLexMark mark;
+		aLex.Mark(mark);
+		TPtrC command(NextCommand(aLex));
+		if (command == KCmndEnumValue)
+			{
+			TPtrC value(NextWord(aLex));
+			TPtrC description(TextToNextCommand(aLex));
+			if (value.Length() == 0)
+				{
+				User::Leave(KErrArgument);
+				}
+			AppendL(aValues, value, EFalse);
+			if (description.Length() > 0)
+				{
+				AppendL(aDescriptions, description, ETrue);
+				}
+			}
+		else
+			{
+			aLex.UnGetToMark(mark);
+			break;
+			}
+		}
+	}
+
+
+EXPORT_C CCommandInfoFile* CCommandInfoFile::NewL(RFs& aFs, const TDesC& aFileName)
+	{
+	CCommandInfoFile* self = new(ELeave) CCommandInfoFile(aFileName);
+	CleanupStack::PushL(self);
+	self->ConstructL(aFs);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CCommandInfoFile* CCommandInfoFile::NewL(RFs& aFs, const CEnvironment& aEnvironment, const TDesC& aCommandName)
+	{
+	TFileName2 fileName;
+	TRAPD(err, fileName.Copy(aEnvironment.GetAsDesL(KCifPathVar)));
+	if (err) fileName.Copy(KCifPath);
+
+	// Search the drive the command is running from first (rather than what the session path happens to be, which was the previous behaviour)
+	if (!fileName.HasDriveLetter()) fileName.Insert(0, _L("?:"));
+	fileName[0] = RProcess().FileName()[0];
+
+	fileName.AppendComponentL(aCommandName);
+	fileName.SetExtL(KCifExt);
+	StaticLeaveIfErr(fileName.FindFile(aFs), _L("Couldn't find \"%S\""), &fileName);
+
+	CCommandInfoFile* cif = CCommandInfoFile::NewL(aFs, fileName);
+	if (cif->Name() != aCommandName)
+		{
+		CleanupStack::PushL(cif);
+		StaticLeaveIfErr(KErrArgument, _L("Command named \"%S\" in implementation but \"%S\" in \"%S\""), &aCommandName, &cif->Name(), &fileName);
+		}
+	return cif;
+	}
+
+void CCommandInfoFile::ConstructL(RFs& aFs)
+	{
+	ReadFileL(aFs, iFileName);
+	}
+
+void CCommandInfoFile::ReadFileL(RFs& aFs, const TDesC& aFileName)
+	{
+	// Read the file into a buffer.
+	RFile file;
+	StaticLeaveIfErr(file.Open(aFs, aFileName, EFileRead | EFileShareReadersOnly), _L("Couldn't open '%S' for reading"), &aFileName);
+	CleanupClosePushL(file);
+	TInt fileSize;
+	User::LeaveIfError(file.Size(fileSize));
+	RBuf8 buf8;
+	buf8.CreateL(fileSize);
+	buf8.CleanupClosePushL();
+	User::LeaveIfError(file.Read(buf8));
+	RBuf& buf = NewBuffer();
+	buf.CreateL(fileSize);
+	buf.Copy(buf8);
+	CleanupStack::PopAndDestroy(2, &file);
+	TLex lex(buf);
+	while (!lex.Eos())
+		{
+		if (iProcessInclude || !iCurrentChild)
+			{
+			ReadDetailsL(lex, aFs, aFileName);
+			}
+		else
+			{
+			iCurrentChild->ReadDetailsL(lex, aFs, aFileName);
+			}
+		}
+	}
+
+void CCommandInfoFile::ReadDetailsL(TLex& aLex, RFs& aFs, const TDesC& aFileName)
+	{
+	SkipToNextCommand(aLex); // Ignore everything before the first '==' command.
+
+	while (!aLex.Eos())
+		{
+		TLexMark mark;
+		aLex.Mark(mark);
+		TPtrC command(NextCommand(aLex));
+		if (command == KNullDesC)
+			{
+			// Do nothing - we're at the end of the string.
+			}
+		else if (command == KCmndName)
+			{
+			aLex.SkipSpaceAndMark();
+			aLex.SkipCharacters();
+			iName.Set(aLex.MarkedToken());
+			}
+		else if (command == KCmndShortDescription)
+			{
+			iShortDescription.Set(TextToNextCommand(aLex));
+			}
+		else if (command == KCmndLongDescription)
+			{
+			iLongDescription.Set(TextToNextCommand(aLex));
+			}
+		else if (command == KCmndSeeAlso)
+			{
+			iSeeAlso.Set(TextToNextCommand(aLex));
+			}
+		else if (command == KCmndCopyright)
+			{
+			iCopyright.Set(TextToNextCommand(aLex));
+			}
+		else if (command == KCmndArgument)
+			{
+			ReadArgumentL(aLex, aFileName);
+			}
+		else if (command == KCmndOption)
+			{
+			ReadOptionL(aLex, aFileName);
+			}
+		else if (command == KCmndInclude)
+			{
+			if (iParent == NULL)
+				{
+				iProcessInclude = EFalse;
+				TLex lineLex(LineRemainder(aLex));
+				TPtrC fileName(NextWord(lineLex));
+				TFileName2* fullFileName = new(ELeave) TFileName2(aFileName);
+				CleanupStack::PushL(fullFileName);
+				fullFileName->SetNameAndExtL(fileName);
+				ReadFileL(aFs, *fullFileName);
+				CleanupStack::PopAndDestroy(fullFileName);
+				break;
+				}
+			else
+				{
+				// We're a sub-command. Let control return to the root to handle the include.
+				aLex.UnGetToMark(mark);
+				iParent->ProcessInclude(*this);
+				break;
+				}
+			}
+		else if (command == KCmndSubCommand)
+			{
+			if (iParent == NULL)
+				{
+				TLex lineLex(LineRemainder(aLex));
+				AddSubCommandL(lineLex, aLex, aFs, aFileName);
+				}
+			else
+				{
+				// We're a sub-command. Let control return to the root to handle the next sub-command.
+				aLex.UnGetToMark(mark);
+				iParent->ProcessNewChild();
+				break;
+				}
+			}
+		else
+			{
+			StaticLeaveIfErr(KErrArgument, _L("Unknown command \"%S\" in \"%S\""), &command, &aFileName);
+			}
+		}
+	}
+
+void CCommandInfoFile::ReadArgumentL(TLex& aLex, const TDesC& aFileName)
+	{
+	TLex lineLex(LineRemainder(aLex));
+	TUint flags = 0;
+	TBool multiple(EFalse);
+	TPtrC argType(NextWord(lineLex));
+	TPtrC argName(NextWord(lineLex));
+	TPtrC envVar;
+	while (!lineLex.Eos())
+		{
+		TPtrC word(NextWord(lineLex));
+		if (word == KCmndFlagOptional)
+			{
+			flags |= KValueTypeFlagOptional;
+			}
+		else if (word == KCmndFlagMultiple)
+			{
+			multiple = ETrue;
+			}
+		else if (word == KCmndFlagLast)
+			{
+			flags |= KValueTypeFlagLast;
+			}
+		else
+			{
+			envVar.Set(word);
+			}
+		}
+
+	if (argType.Length() == 0)
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Argument missing type"));
+		}
+	else if (argName.Length() == 0)
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Argument missing name"));
+		}
+	else
+		{
+		TPtrC argDescription = TextToNextCommand(aLex);
+		if (argType == KTypeEnum)
+			{
+			RBuf& enumValues = NewBuffer();
+			RBuf& enumDescriptions = NewBuffer();
+			GetEnumValuesL(aLex, enumValues, enumDescriptions);
+			if (multiple)
+				{
+				RArray<TInt> dummyArray;
+				if (enumDescriptions.Length() > 0)
+					{
+					iArguments.AppendEnumL(dummyArray, argName, argDescription, enumValues, enumDescriptions, flags, envVar);
+					}
+				else
+					{
+					iArguments.AppendEnumL(dummyArray, argName, argDescription, enumValues, flags, envVar);
+					}
+				}
+			else
+				{
+				TInt dummyInt;
+				if (enumDescriptions.Length() > 0)
+					{
+					iArguments.AppendEnumL(dummyInt, argName, argDescription, enumValues, enumDescriptions, flags, envVar);
+					}
+				else
+					{
+					iArguments.AppendEnumL(dummyInt, argName, argDescription, enumValues, flags, envVar);
+					}
+				}
+			}
+		else if (argType == KTypeInt)
+			{
+			if (multiple)
+				{
+				RArray<TInt> dummyArray;
+				iArguments.AppendIntL(dummyArray, argName, argDescription, flags, envVar);
+				}
+			else
+				{
+				TInt dummyInt;
+				iArguments.AppendIntL(dummyInt, argName, argDescription, flags, envVar);
+				}
+			}
+		else if (argType == KTypeUint)
+			{
+			if (multiple)
+				{
+				RArray<TUint> dummyArray;
+				iArguments.AppendUintL(dummyArray, argName, argDescription, flags, envVar);
+				}
+			else
+				{
+				TUint dummyUint;
+				iArguments.AppendUintL(dummyUint, argName, argDescription, flags, envVar);
+				}
+			}
+		else if (argType == KTypeString)
+			{
+			if (multiple)
+				{
+				RPointerArray<HBufC> dummyArray;
+				iArguments.AppendStringL(dummyArray, argName, argDescription, flags, envVar);
+				}
+			else
+				{
+				HBufC* dummyHBufC;
+				iArguments.AppendStringL(dummyHBufC, argName, argDescription, flags, envVar);
+				}
+			}
+		else if (argType == KTypeFileName)
+			{
+			if (multiple)
+				{
+				RArray<TFileName2> dummyArray;
+				iArguments.AppendFileNameL(dummyArray, argName, argDescription, flags, envVar);
+				}
+			else
+				{
+				TFileName2 dummyFileName;
+				iArguments.AppendFileNameL(dummyFileName, argName, argDescription, flags, envVar);
+				}
+			}
+		else if (argType == KTypeReal)
+			{
+			if (multiple)
+				{
+				RArray<TReal64> dummyArray;
+				iArguments.AppendRealL(dummyArray, argName, argDescription, flags, envVar);
+				}
+			else
+				{
+				TReal64 dummyReal;
+				iArguments.AppendRealL(dummyReal, argName, argDescription, flags, envVar);
+				}
+			}
+		else if (argType == KTypeUint64)
+			{
+			if (multiple)
+				{
+				RArray<TUint64> dummyArray;
+				iArguments.AppendUintL(dummyArray, argName, argDescription, flags, envVar);
+				}
+			else
+				{
+				TUint64 dummyUint64;
+				iArguments.AppendUintL(dummyUint64, argName, argDescription, flags, envVar);
+				}
+			}
+		else if (argType == KTypeInt64)
+			{
+			if (multiple)
+				{
+				RArray<TInt64> dummyArray;
+				iArguments.AppendIntL(dummyArray, argName, argDescription, flags, envVar);
+				}
+			else
+				{
+				TInt64 dummyInt64;
+				iArguments.AppendIntL(dummyInt64, argName, argDescription, flags, envVar);
+				}
+			}
+		else
+			{
+			StaticLeaveIfErr(KErrArgument, _L("Unknown argument type \"%S\" in \"%S\""), &argType, &aFileName);
+			}
+		}
+	}
+
+void CCommandInfoFile::ReadOptionL(TLex& aLex, const TDesC& aFileName)
+	{
+	TLex lineLex(LineRemainder(aLex));
+	TBool multiple(EFalse);
+	TPtrC optType(NextWord(lineLex));
+	TPtrC optShortName(NextWord(lineLex));
+	TPtrC optLongName(NextWord(lineLex));
+	TPtrC envVar;
+	while (!lineLex.Eos())
+		{
+		TPtrC word(NextWord(lineLex));
+		if (word == KCmndFlagMultiple)
+			{
+			multiple = ETrue;
+			}
+		else
+			{
+			envVar.Set(word);
+			}
+		}
+
+	if (optType.Length() == 0)
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Option missing type"));
+		}
+	else if (optShortName.Length() == 0)
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Option missing short name"));
+		}
+	else if (optShortName.Length() != 1)
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Option short name not a single character"));
+		}
+	else if (optLongName.Length() == 0)
+		{
+		StaticLeaveIfErr(KErrArgument, _L("Option missing long name"));
+		}
+	else
+		{
+		TPtrC argDescription = TextToNextCommand(aLex);
+		if (optType == KTypeEnum)
+			{
+			RBuf& enumValues = NewBuffer();
+			RBuf& enumDescriptions = NewBuffer();
+			GetEnumValuesL(aLex, enumValues, enumDescriptions);
+			if (multiple)
+				{
+				RArray<TInt> dummyArray;
+				if (enumDescriptions.Length() > 0)
+					{
+					iOptions.AppendEnumL(dummyArray, optShortName[0], optLongName, argDescription, enumValues, enumDescriptions, 0, envVar);
+					}
+				else
+					{
+					iOptions.AppendEnumL(dummyArray, optShortName[0], optLongName, argDescription, enumValues, 0, envVar);
+					}
+				}
+			else
+				{
+				TInt dummyInt;
+				if (enumDescriptions.Length() > 0)
+					{
+					iOptions.AppendEnumL(dummyInt, optShortName[0], optLongName, argDescription, enumValues, enumDescriptions, 0, envVar);
+					}
+				else
+					{
+					iOptions.AppendEnumL(dummyInt, optShortName[0], optLongName, argDescription, enumValues, 0, envVar);
+					}
+				}
+			}
+		else if (optType == KTypeBool)
+			{
+			if (multiple)
+				{
+				RArray<TBool> dummyArray;
+				iOptions.AppendBoolL(dummyArray, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			else
+				{
+				TBool dummyBool;
+				iOptions.AppendBoolL(dummyBool, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			}
+		else if (optType == KTypeInt)
+			{
+			if (multiple)
+				{
+				RArray<TInt> dummyArray;
+				iOptions.AppendIntL(dummyArray, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			else
+				{
+				TInt dummyInt;
+				iOptions.AppendIntL(dummyInt, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			}
+		else if (optType == KTypeUint)
+			{
+			if (multiple)
+				{
+				RArray<TUint> dummyArray;
+				iOptions.AppendUintL(dummyArray, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			else
+				{
+				TUint dummyUint;
+				iOptions.AppendUintL(dummyUint, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			}
+		else if (optType == KTypeString)
+			{
+			if (multiple)
+				{
+				RPointerArray<HBufC> dummyArray;
+				iOptions.AppendStringL(dummyArray, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			else
+				{
+				HBufC* dummyHBufC;
+				iOptions.AppendStringL(dummyHBufC, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			}
+		else if (optType == KTypeFileName)
+			{
+			if (multiple)
+				{
+				RArray<TFileName2> dummyArray;
+				iOptions.AppendFileNameL(dummyArray, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			else
+				{
+				TFileName2 dummyFileName;
+				iOptions.AppendFileNameL(dummyFileName, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			}
+		else if (optType == KTypeReal)
+			{
+			if (multiple)
+				{
+				RArray<TReal64> dummyArray;
+				iOptions.AppendRealL(dummyArray, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			else
+				{
+				TReal64 dummyReal;
+				iOptions.AppendRealL(dummyReal, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			}
+		else if (optType == KTypeUint64)
+			{
+			if (multiple)
+				{
+				RArray<TUint64> dummyArray;
+				iOptions.AppendUintL(dummyArray, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			else
+				{
+				TUint64 dummyUint64;
+				iOptions.AppendUintL(dummyUint64, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			}
+		else if (optType == KTypeInt64)
+			{
+			if (multiple)
+				{
+				RArray<TInt64> dummyArray;
+				iOptions.AppendIntL(dummyArray, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			else
+				{
+				TInt64 dummyInt64;
+				iOptions.AppendIntL(dummyInt64, optShortName[0], optLongName, argDescription, 0, envVar);
+				}
+			}
+		else
+			{
+			StaticLeaveIfErr(KErrArgument, _L("Unknown option type \"%S\" in \"%S\""), &optType, &aFileName);
+			}
+		}
+	}
+
+void CCommandInfoFile::ProcessNewChild()
+	{
+	if (iParent)
+		{
+		iParent->ProcessNewChild();
+		}
+	else
+		{
+		ASSERT(!iProcessInclude);
+		iCurrentChild = NULL;
+		}
+	}
+
+void CCommandInfoFile::ProcessInclude(CCommandInfoFile& aChild)
+	{
+	if (iParent)
+		{
+		iParent->ProcessInclude(aChild);
+		}
+	else
+		{
+		iProcessInclude = ETrue;
+		iCurrentChild = &aChild;
+		}
+	}
+
+void CCommandInfoFile::AddSubCommandL(TLex& aNameLex, TLex& aDataLex, RFs& aFs, const TDesC& aFileName)
+	{
+	TPtrC subCommandName(NextWord(aNameLex));
+	TBool found(EFalse);
+	for (TInt i = (iChildren.Count() - 1); i >= 0; --i)
+		{
+		if (iChildren[i]->Name() == subCommandName)
+			{
+			iChildren[i]->AddSubCommandL(aNameLex, aDataLex, aFs, aFileName);
+			found = ETrue;
+			break;
+			}
+		}
+	__ASSERT_ALWAYS(found || (aNameLex.Remainder().Length() == 0), IoUtils::Panic(ECifSubCommandParentNotFound));
+	if (!found)
+		{
+		CCommandInfoFile* subCommand = new(ELeave) CCommandInfoFile(*this);
+		CleanupStack::PushL(subCommand);
+		subCommand->iName.Set(subCommandName);
+		subCommand->ReadDetailsL(aDataLex, aFs, aFileName);
+		iChildren.AppendL(subCommand);
+		CleanupStack::Pop(subCommand);
+		}
+	}
+
+RBuf& CCommandInfoFile::NewBuffer()
+	{
+	RBuf buf;
+	iBufs.AppendL(buf);
+	return iBufs[iBufs.Count() - 1];
+	}
+
+EXPORT_C CCommandInfoFile::~CCommandInfoFile()
+	{
+	iArguments.Close();
+	iOptions.Close();
+
+	const TInt numBufs = iBufs.Count();
+	for (TInt i = 0; i < numBufs; ++i)
+		{
+		iBufs[i].Close();
+		}
+	iBufs.Close();
+	iChildren.ResetAndDestroy();
+	}
+
+EXPORT_C const TDesC& CCommandInfoFile::Name() const
+	{
+	return iName;
+	}
+
+EXPORT_C const TDesC& CCommandInfoFile::ShortDescription() const
+	{
+	return iShortDescription;
+	}
+
+EXPORT_C const TDesC& CCommandInfoFile::LongDescription() const
+	{
+	return iLongDescription;
+	}
+
+EXPORT_C const TDesC& CCommandInfoFile::SeeAlso() const
+	{
+	return iSeeAlso;
+	}
+
+EXPORT_C const TDesC& CCommandInfoFile::Copyright() const
+	{
+	return iCopyright;
+	}
+
+EXPORT_C const RCommandArgumentList& CCommandInfoFile::Arguments()
+	{
+	return iArguments;
+	}
+
+EXPORT_C const RCommandOptionList& CCommandInfoFile::Options() const
+	{
+	return iOptions;
+	}
+
+template <class T> void CombineL(const T& aSourceList, T& aDestinationList, const TDesC& aListType, const TDesC& aCifName)
+	{
+	const TInt sourceCount = aSourceList.Count();
+	const TInt destinationCount = aDestinationList.Count();
+
+	if (sourceCount < destinationCount) // Note, allow the source to have more than the destination because some things are compile time configurable but CIF files don't support this.
+		{
+		StaticLeaveIfErr(KErrArgument, _L("%S count mismatch between \"%S\" (%d) and implementation (%d)"), &aListType, &aCifName, sourceCount, destinationCount);
+		}
+
+	for (TInt i = 0; i < destinationCount; ++i)
+		{
+		const TDesC& destinationName = aDestinationList[i].Name();
+		TInt sourcePos = aSourceList.Find(destinationName);
+		if (sourcePos < 0)
+			{
+			StaticLeaveIfErr(KErrArgument, _L("Couldn't find %S \"%S\" in \"%S\""), &aListType, &destinationName, &aCifName);
+			}
+
+		TUint sourceType = aSourceList[sourcePos].ValueType();
+		TUint sourceTypeForComparison = sourceType & ~(KValueTypeFlagOptional|KValueTypeFlagLast); // destType can't know about these flags, so clear them from sourceType so we don't have problems when destType doesn't set them
+		TUint destType = aDestinationList[i].ValueType();
+		if (sourceTypeForComparison != destType)
+			{
+			StaticLeaveIfErr(KErrArgument, _L("Type mismatch for %S '%S' between \"%S\" (0x%x) and implementation (0x%x)"), &aListType, &destinationName, &aCifName, sourceType, destType);
+			}
+		aDestinationList[i].Combine(aSourceList[sourcePos]);
+		}
+	}
+
+EXPORT_C void CCommandInfoFile::AssignL(RCommandArgumentList& aArguments, RCommandOptionList& aOptions) const
+	{
+	CombineL(iArguments, aArguments, _L("Argument"), iFileName);
+	CombineL(iOptions, aOptions, _L("Option"), iFileName);
+	}
+
+EXPORT_C TInt CCommandInfoFile::NumSubCommands() const
+	{
+	return iChildren.Count();
+	}
+
+EXPORT_C const CCommandInfoFile& CCommandInfoFile::SubCommand(TInt aIndex) const
+	{
+	return *(iChildren[aIndex]);
+	}
+
+EXPORT_C const CCommandInfoFile* CCommandInfoFile::SubCommand(const TDesC& aSubCommandName) const
+	{
+	for (TInt i = (NumSubCommands() - 1); i >= 0; --i)
+		{
+		const CCommandInfoFile& thisSubCommand = SubCommand(i);
+		if (thisSubCommand.Name() == aSubCommandName)
+			{
+			return &thisSubCommand;
+			}
+		}
+	return NULL;
+	}
+
+CCommandInfoFile::CCommandInfoFile(const TDesC& aFileName)
+	: iFileName(aFileName)
+	{
+	}
+
+CCommandInfoFile::CCommandInfoFile(CCommandInfoFile& aParent)
+	: iFileName(aParent.iFileName), iParent(&aParent)
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/env.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,542 @@
+// env.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "ioutils.h"
+#include "command_base.h"
+#include <fshell/stringhash.h>
+#include <fshell/ltkutils.h>
+#include <fshell/descriptorutils.h>
+
+using namespace IoUtils;
+using LtkUtils::RStringHash;
+using LtkUtils::TStringHashIter;
+
+#define iVars (*reinterpret_cast<RStringHash<HBufC*>*>(iVarsImpl))
+#define ConstVarsFor(x) (*reinterpret_cast<const RStringHash<HBufC*>*>((x)->iVarsImpl))
+#define iConstVars ConstVarsFor(this)
+
+//
+// Constants.
+//
+
+_LIT(KEnvPwd, "PWD");
+_LIT(KDefaultPwd, "c:\\");
+_LIT(KChildError, "?");
+_LIT(KEnvEscapeChar, "ESCAPE");
+
+//
+// CEnvironment.
+//
+
+EXPORT_C CEnvironment* CEnvironment::NewL()
+	{
+	CEnvironment* self = new(ELeave) CEnvironment();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	self->SetPwdL(KDefaultPwd);
+	self->SetL(KChildError, KErrNone);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CEnvironment* CEnvironment::NewL(const CEnvironment& aEnv)
+	{
+	CEnvironment* self = CEnvironment::NewL();
+	CleanupStack::PushL(self);
+	self->CopyL(aEnv);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CEnvironment* CEnvironment::CreateSharedEnvironmentL()
+	{
+	CEnvironment* newenv = new(ELeave) CEnvironment(this);
+	CleanupStack::PushL(newenv);
+	newenv->ConstructL();
+	CleanupStack::Pop(newenv);
+	return newenv;
+	}
+
+EXPORT_C CEnvironment::~CEnvironment()
+	{
+	RemoveAll();
+	iLock.Close();
+	}
+
+EXPORT_C void CEnvironment::RemoveAll()
+	{
+	// Note this doesn't affect iParentEnv
+	if (iLock.Handle())
+		{
+		iLock.Wait();
+		TStringHashIter<HBufC*> iter(iVars);
+		while (iter.NextValue() != NULL)
+			{
+			delete *iter.CurrentValue();
+			}
+		iVars.Close();
+		iLock.Signal();
+		}
+	}
+
+CEnvironment::CEnvironment()
+	{
+	__ASSERT_COMPILE(sizeof(iVarsImpl) == sizeof(RStringHash<HBufC*>));
+	// Have to placement new iVars because we hide the type
+	new(iVarsImpl) RStringHash<HBufC*>;
+	}
+
+CEnvironment::CEnvironment(CEnvironment* aParentEnv)
+	: iParentEnv(aParentEnv)
+	{
+	new(iVarsImpl) RStringHash<HBufC*>;
+	}
+
+void CEnvironment::ConstructL()
+	{
+	User::LeaveIfError(iLock.CreateLocal());
+	}
+
+void CEnvironment::Lock() const
+	{
+	iLock.Wait();
+	if (iParentEnv) iParentEnv->iLock.Wait();
+	}
+
+void CEnvironment::Unlock() const
+	{
+	if (iParentEnv) iParentEnv->iLock.Signal();
+	iLock.Signal();
+	}
+
+void CEnvironment::WaitLC() const
+	{
+	Lock();
+	CleanupStack::PushL(TCleanupItem(Signal, const_cast<CEnvironment*>(this)));
+	}
+
+void CEnvironment::Signal(TAny* aSelf)
+	{
+	static_cast<CEnvironment*>(aSelf)->Unlock();
+	}
+
+EXPORT_C void CEnvironment::SetL(const TDesC& aKey, TInt aValue)
+	{
+	TBuf<32> buf;
+	buf.AppendNum(aValue);
+	SetL(aKey, buf);
+	}
+
+EXPORT_C void CEnvironment::SetL(const TDesC& aKey, const TDesC& aValue)
+	{
+	WaitLC();
+
+	HBufC** valPtr = iVars.Find(aKey);
+	HBufC* currentValue = NULL;
+	if (valPtr) currentValue = *valPtr;
+
+	if (valPtr == NULL && iParentEnv)
+		{
+		// If we don't have it, and we have a parent env, we should pass the request through to it.
+		iParentEnv->SetL(aKey, aValue);
+		}
+	else
+		{
+		if (currentValue)
+			{
+			// If we already have a value in the hash, just update it if possible
+			TPtr ptr = currentValue->Des();
+			if (ptr.MaxLength() >= aValue.Length())
+				{
+				ptr.Copy(aValue);
+				CleanupStack::PopAndDestroy(); // Release lock
+				return;
+				}
+			}
+		}
+	
+	HBufC* newVal = aValue.AllocLC();
+	iVars.InsertL(aKey, newVal);
+	delete currentValue;
+	CleanupStack::Pop(newVal);
+	CleanupStack::PopAndDestroy(); // Release lock
+	}
+
+HBufC* CEnvironment::Get(const TDesC& aKey) const
+	{
+	HBufC*const* valPtr = iConstVars.Find(aKey);
+	if (valPtr == NULL && iParentEnv)
+		{
+		return iParentEnv->Get(aKey);
+		}
+	else if (valPtr)
+		{
+		return *valPtr;
+		}
+	else
+		{
+		return NULL;
+		}
+	}
+
+HBufC* CEnvironment::GetL(const TDesC& aKey) const
+	{
+	HBufC* var = Get(aKey);
+	if (var == NULL) User::Leave(KErrNotFound);
+	return var;
+	}
+
+EXPORT_C TInt CEnvironment::GetAsInt(const TDesC& aKey) const
+	{
+	Lock();
+	HBufC* var = Get(aKey);
+	__ASSERT_ALWAYS(var, Panic(EEnvVarNotFound1));
+	TLex lex(*var);
+	TInt result = 0;
+	lex.Val(result);
+	Unlock();
+	return result;
+	}
+
+EXPORT_C TInt CEnvironment::GetAsIntL(const TDesC& aKey) const
+	{
+	WaitLC();
+	HBufC* var = GetL(aKey);
+	TLex lex(*var);
+	TInt ret = 0;
+	lex.Val(ret);
+	CleanupStack::PopAndDestroy(); // Release lock
+	return ret;
+	}
+
+EXPORT_C const TDesC& CEnvironment::GetAsDes(const TDesC& aKey) const
+	{
+	Lock();
+	HBufC* var = Get(aKey);
+	__ASSERT_ALWAYS(var, Panic(EEnvVarNotFound2));
+	Unlock();
+	return *var;
+	}
+
+EXPORT_C const TDesC& CEnvironment::GetAsDesL(const TDesC& aKey) const
+	{
+	WaitLC();
+	const TDesC& des = *GetL(aKey);
+	CleanupStack::PopAndDestroy(); // Release lock
+	return des;
+	}
+
+EXPORT_C TInt CEnvironment::Remove(const TDesC& aKey)
+	{
+	Lock();
+	HBufC** valPtr = iVars.Find(aKey);
+
+	TInt ret = KErrNone;
+	if (valPtr == NULL && iParentEnv)
+		{
+		// Not in ours, look at parent env
+		ret = iParentEnv->Remove(aKey);
+		}
+	else if (valPtr && *valPtr)
+		{
+		// In ours
+		delete *valPtr;
+		if (iParentEnv)
+			{
+			// Need to remember we've removed it
+			*valPtr = NULL;
+			}
+		else
+			{
+			iVars.Remove(aKey);
+			}
+		}
+	else
+		{
+		// Not in ours and no parent env, or in ours and null
+		ret = KErrNotFound;
+		}
+
+	Unlock();
+	return ret;
+	}
+
+EXPORT_C void CEnvironment::RemoveL(const TDesC& aKey)
+	{
+	User::LeaveIfError(Remove(aKey));
+	}
+
+void CEnvironment::CopyL(const CEnvironment& aEnv)
+	{
+	RemoveAll();
+	WaitLC();
+	aEnv.WaitLC();
+
+	RPointerArray<HBufC> keys;
+	LtkUtils::CleanupResetAndDestroyPushL(keys);
+	aEnv.GetKeysL(keys);
+	for (TInt i = 0; i < keys.Count(); i++)
+		{
+		SetL(*keys[i], aEnv.GetAsDes(*keys[i]));
+		}
+
+	CleanupStack::PopAndDestroy(3); // keys, WaitLC x 2.
+	}
+
+class TDesRead
+	{
+public:
+	TDesRead(const TDesC8& aDes);
+	TInt32 ReadInt32();
+	TPtrC ReadDes();
+private:
+	const TDesC8& iDes;
+	TInt iPos;
+	};
+class TDesWrite
+	{
+public:
+	TDesWrite(LtkUtils::RLtkBuf8& aDes);
+	void WriteL(TInt32 aInt);
+	void WriteL(const TDesC& aDes);
+private:
+	LtkUtils::RLtkBuf8& iDes;
+	};
+
+EXPORT_C void CEnvironment::InternalizeL(const TDesC8& aDes)
+	{
+	WaitLC();
+
+	TDesRead desRead(aDes);
+	TInt varCount = desRead.ReadInt32();
+	while (varCount--)
+		{
+		TPtrC key = desRead.ReadDes();
+		TPtrC val = desRead.ReadDes();
+		SetL(key, val);
+		}
+
+	CleanupStack::PopAndDestroy(); // Release lock
+	}
+
+EXPORT_C HBufC8* CEnvironment::ExternalizeLC() const
+	{
+	WaitLC();
+	LtkUtils::RLtkBuf8 buf;
+	CleanupClosePushL(buf);
+	TDesWrite desWrite(buf);
+
+	RPointerArray<HBufC> keys;
+	LtkUtils::CleanupResetAndDestroyPushL(keys);
+	GetKeysL(keys);
+	desWrite.WriteL(keys.Count());
+	for (TInt i = 0; i < keys.Count(); i++)
+		{
+		desWrite.WriteL(*keys[i]);
+		desWrite.WriteL(GetAsDes(*keys[i]));
+		}
+	CleanupStack::PopAndDestroy(&keys);
+	CleanupStack::Pop(&buf);
+	CleanupStack::PopAndDestroy(); // Release lock
+	HBufC8* res = buf.ToHBuf();
+	CleanupStack::PushL(res);
+	return res;
+	}
+
+TInt StringCompare(const HBufC& aLeft, const HBufC& aRight)
+	{
+	return aLeft.Compare(aRight);
+	}
+
+EXPORT_C void CEnvironment::GetKeysL(RPointerArray<HBufC>& aResult) const
+	{
+	WaitLC();
+	aResult.ResetAndDestroy();
+	TStringHashIter<HBufC*> iter(iConstVars);
+	while (iter.NextValue() != NULL)
+		{
+		if (*iter.CurrentValue() != NULL)
+			{
+			HBufC* key = iter.CurrentKey()->AllocLC();
+			aResult.AppendL(key);
+			CleanupStack::Pop(key);
+			}
+		}
+	
+	if (iParentEnv)
+		{
+		RPointerArray<HBufC> parentKeys;
+		LtkUtils::CleanupResetAndDestroyPushL(parentKeys);
+		iParentEnv->GetKeysL(parentKeys);
+		for (TInt i = parentKeys.Count()-1; i >= 0; i--)
+			{
+			HBufC* key = parentKeys[i];
+			if (iConstVars.Find(*key) == NULL)
+				{
+				// Only add stuff in parent that isn't also in ours
+				aResult.AppendL(key);
+				parentKeys.Remove(i);
+				}
+			}
+		CleanupStack::PopAndDestroy(&parentKeys);
+		}
+
+	// Make sure the resulting array is alphabetic, as RStringHash doesn't guarantee that (unlike RVarSet)
+	aResult.Sort(TLinearOrder<HBufC>(&StringCompare));
+	CleanupStack::PopAndDestroy(); // Release lock
+	}
+
+EXPORT_C TBool CEnvironment::IsDefined(const TDesC& aKey) const
+	{
+	iLock.Wait();
+	TBool ret = (Get(aKey) != NULL);
+	iLock.Signal();
+	return ret;
+	}
+
+EXPORT_C TBool CEnvironment::IsInt(const TDesC& aKey) const
+	{
+	iLock.Wait();
+	HBufC* val = Get(aKey);
+	iLock.Signal();
+
+	if (val == NULL) return EFalse;
+	
+	TLex lex(*val);
+	TBool atLeastOneDigit(EFalse);
+	while (!lex.Eos())
+		{
+		if (lex.Get().IsDigit())
+			{
+			atLeastOneDigit = ETrue;
+			}
+		else
+			{
+			return EFalse;
+			}
+		}
+	return atLeastOneDigit;
+	}
+
+EXPORT_C TBool CEnvironment::IsDes(const TDesC& aKey) const
+	{
+	return IsDefined(aKey);
+	}
+
+EXPORT_C TInt CEnvironment::Count() const
+	{
+	iLock.Wait();
+	TInt ret = iConstVars.Count();
+	iLock.Signal();
+	return ret;
+	}
+
+EXPORT_C void CEnvironment::SetPwdL(const TDesC& aPwd)
+	{
+	SetL(KEnvPwd, aPwd);
+	}
+
+EXPORT_C const TDesC& CEnvironment::Pwd() const
+	{
+	return GetAsDes(KEnvPwd);
+	}
+
+EXPORT_C TChar CEnvironment::EscapeChar() const
+	{
+	iLock.Wait();
+	HBufC* var = Get(KEnvEscapeChar);
+	TUint16 escape = '^';
+	if (var)
+		{
+		escape = (*var)[0];
+		}
+	iLock.Signal();
+	return TChar(escape);
+	}
+
+// Declare aKey so that changes aren't reflected in the parent environment
+EXPORT_C void CEnvironment::SetLocalL(const TDesC& aKey)
+	{
+	if (iParentEnv == NULL)
+		{
+		// Nothing needed if there is no parent, then everything is effectively local anyway
+		return;
+		}
+
+	WaitLC();
+	HBufC** currentValPtr = iVars.Find(aKey);
+	if (currentValPtr)
+		{
+		// It's already local
+		CleanupStack::PopAndDestroy(); // Release lock
+		return;
+		}
+
+	// Local vals start out undefined, regardless of what the parent's value is
+	iVars.InsertL(aKey, NULL);
+
+	CleanupStack::PopAndDestroy(); // Release lock
+	}
+
+//
+// TDesRead.
+//
+
+TDesRead::TDesRead(const TDesC8& aDes)
+	: iDes(aDes), iPos(0)
+	{
+	}
+
+TInt32 TDesRead::ReadInt32()
+	{
+	TInt32 int32;
+	TPckg<TInt32> intPckg(int32);
+	intPckg.Copy(iDes.Mid(iPos, sizeof(TInt32)));
+	iPos += sizeof(TInt32);
+	return int32;
+	}
+
+TPtrC TDesRead::ReadDes()
+	{
+	const TInt length = ReadInt32();
+	const TInt size = length * 2;
+	if (iPos & 1) iPos++; // 16-bit descriptors are 2-byte aligned
+	TPtrC8 ptr8 = iDes.Mid(iPos, size);
+	TPtrC result((const TUint16*)ptr8.Ptr(), length);
+	iPos += size;
+	return result;
+	}
+
+
+//
+// TDesWrite.
+//
+
+TDesWrite::TDesWrite(LtkUtils::RLtkBuf8& aDes)
+	: iDes(aDes)
+	{
+	}
+
+void TDesWrite::WriteL(TInt32 aInt)
+	{
+	TPckgC<TInt32> intPckg(aInt);
+	iDes.AppendL(intPckg);
+	}
+
+void TDesWrite::WriteL(const TDesC& aDes)
+	{
+	WriteL(aDes.Length());
+	if (iDes.Size() & 1) iDes.AppendL('.'); // Pad so the desc is 2-byte aligned
+	TPtrC8 ptr((TUint8*)aDes.Ptr(), aDes.Size());
+	iDes.AppendL(ptr);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/file_utils.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,513 @@
+// file_utils.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include <f32file.h>
+#include "ioutils.h"
+
+using namespace IoUtils;
+
+
+//
+// Constants.
+//
+
+_LIT(KSlash, "\\");
+_LIT(KDoubleSlash, "\\\\");
+_LIT(KDot, ".");
+_LIT(KDoubleDot, "..");
+
+__ASSERT_COMPILE(sizeof(TFileName2) == sizeof(TFileName) + 4);
+
+//
+// TFileName2.
+//
+
+EXPORT_C TFileName2::TFileName2()
+	{
+	new(this) TFileName2(EFile);
+	}
+
+EXPORT_C TFileName2::TFileName2(TType aType)
+	{
+	new(this) TFileName2(KNullDesC, aType);
+	}
+
+EXPORT_C TFileName2::TFileName2(const TDesC& aName)
+	: TBuf<256>(aName), iType(EFile)
+	{
+	new(this) TFileName2(aName, EFile);
+	}
+
+EXPORT_C TFileName2::TFileName2(const TDesC& aName, TType aType)
+	: TBuf<256>(aName), iType(aType)
+	{
+	// Remove any double slashes that may be present.
+	TInt pos;
+	while ((pos = Find(KDoubleSlash)) >= 0)
+		{
+		Delete(pos, 1);
+		}
+	}
+
+EXPORT_C TBool TFileName2::IsAbsolute() const
+	{
+	return ((Length() >= 3) && TChar((*this)[0]).IsAlpha() && ((*this)[1] == ':') && ((*this)[2] == '\\'));
+	}
+
+EXPORT_C TBool TFileName2::IsDriveLetter() const
+	{
+	return (Length() == 2) && TChar((*this)[0]).IsAlpha() && ((*this)[1] == ':');
+	}
+
+EXPORT_C TBool TFileName2::IsDriveRoot() const
+	{
+	return ((Length() == 3) && TChar((*this)[0]).IsAlpha() && ((*this)[1] == ':') && ((*this)[2] == '\\'));
+	}
+
+EXPORT_C TBool TFileName2::IsWild() const
+	{
+	return TParsePtrC(*this).IsWild();
+	}
+
+EXPORT_C TBool TFileName2::IsFile() const
+	{
+	TBool ret = (iType == EFile);
+	ASSERT((ret && !HasTrailingSlash()) || (!ret && HasTrailingSlash()));
+	return ret;
+	}
+
+EXPORT_C TBool TFileName2::IsDir() const
+	{
+	TBool ret = (iType == EDirectory);
+	ASSERT((ret && HasTrailingSlash()) || (!ret && !HasTrailingSlash()));
+	return ret;
+	}
+
+EXPORT_C TBool TFileName2::HasDriveLetter() const
+	{
+	return ((Length() >= 2) && TChar((*this)[0]).IsAlpha() && ((*this)[1] == ':'));
+	}
+
+EXPORT_C TBool TFileName2::HasLeadingSlash() const
+	{
+	return ((Length() >= 1) && ((*this)[0] == '\\'));
+	}
+
+EXPORT_C TBool TFileName2::HasTrailingSlash() const
+	{
+	return ((Length() >= 1) && ((*this)[Length() - 1] == '\\'));
+	}
+
+EXPORT_C TPtrC TFileName2::Drive() const
+	{
+	return TParsePtrC(*this).Drive();
+	}
+
+EXPORT_C TPtrC TFileName2::Path() const
+	{
+	return TParsePtrC(*this).Path();
+	}
+
+EXPORT_C TPtrC TFileName2::DriveAndPath() const
+	{
+	return TParsePtrC(*this).DriveAndPath();
+	}
+
+EXPORT_C TPtrC TFileName2::Name() const
+	{
+	return TParsePtrC(*this).Name();
+	}
+
+EXPORT_C TPtrC TFileName2::Ext() const
+	{
+	return TParsePtrC(*this).Ext();
+	}
+
+EXPORT_C TPtrC TFileName2::NameAndExt() const
+	{
+	return TParsePtrC(*this).NameAndExt();
+	}
+
+EXPORT_C void TFileName2::SetL(const TFileName2& aName)
+	{
+	Zero();
+	AppendComponentL(aName);
+	}
+
+EXPORT_C void TFileName2::SetTypeL(TType aType)
+	{
+	switch (aType)
+		{
+		case EFile:
+			{
+			if (HasTrailingSlash() && ((HasDriveLetter() && (Length() > 3)) || (!HasDriveLetter() && (Length() > 1))))
+				{
+				Delete(Length() - 1, 1);
+				}
+			iType = EFile;
+			break;
+			}
+		case EDirectory:
+			{
+			if (!HasTrailingSlash())
+				{
+				AppendComponentL(KNullDesC());
+				}
+			iType = EDirectory;
+			break;
+			}
+		default:
+			{
+			ASSERT(EFalse);
+			}
+		}
+	}
+
+EXPORT_C void TFileName2::SetTypeL(RFs& aFs)
+	{
+	if (IsDirL(aFs))
+		{
+		SetTypeL(EDirectory);
+		}
+	else
+		{
+		SetTypeL(EFile);
+		}
+	}
+
+EXPORT_C void TFileName2::SetDriveL(const TDesC& aDrive)
+	{
+	if (Drive().Length() > 0)
+		{
+		(*this)[0] = aDrive[0];
+		}
+	else
+		{
+		PrependL(aDrive);
+		}
+	}
+
+EXPORT_C void TFileName2::SetPathL(const TDesC& aPath)
+	{
+	TFileName2 temp;
+	temp.SetDriveL(Drive());
+	temp.AppendComponentL(aPath);
+	temp.SetNameAndExtL(NameAndExt());
+	Copy(temp);
+	}
+
+EXPORT_C void TFileName2::SetNameL(const TDesC& aName)
+	{
+	TPtrC namePtrC(Name());
+	if (namePtrC.Length() > 0)
+		{
+		CheckSpaceL(aName.Length() - namePtrC.Length());
+		TInt namePos = namePtrC.Ptr() - Ptr();
+		Delete(namePos, namePtrC.Length());
+		Insert(namePos, aName);
+		}
+	else
+		{
+		AppendComponentL(aName);
+		}
+	}
+
+EXPORT_C void TFileName2::SetExtL(const TDesC& aExt)
+	{
+	TPtrC extPtrC(Ext());
+	if (extPtrC.Length() > 0)
+		{
+		CheckSpaceL(aExt.Length() + ((aExt[0] == '.') ? 0 : 1) - extPtrC.Length());
+		Delete(extPtrC.Ptr() - Ptr(), extPtrC.Length());
+		}
+	else
+		{
+		CheckSpaceL(aExt.Length() + ((aExt[0] == '.') ? 0 : 1));
+		}
+
+	if (aExt[0] != '.')
+		{
+		Append('.');
+		}
+	Append(aExt);
+	}
+
+EXPORT_C void TFileName2::SetNameAndExtL(const TDesC& aNameAndExt)
+	{
+	TPtrC nameAndExtPtrC(NameAndExt());
+	if (nameAndExtPtrC.Length() > 0)
+		{
+		CheckSpaceL(aNameAndExt.Length() - nameAndExtPtrC.Length());
+		TInt nameAndExtPos = nameAndExtPtrC.Ptr() - Ptr();
+		Delete(nameAndExtPos, nameAndExtPtrC.Length());
+		Insert(nameAndExtPos, aNameAndExt);
+		}
+	else
+		{
+		AppendComponentL(aNameAndExt);
+		}
+	}
+
+EXPORT_C void TFileName2::PrependL(const TFileName2& aName)
+	{
+	if (Length() == 0)
+		{
+		CheckSpaceL(aName.Length() + (((iType == EDirectory) && !HasTrailingSlash()) ? 1 : 0));
+		Append(aName);
+		}
+	else if (aName.HasTrailingSlash() && HasLeadingSlash())
+		{
+		CheckSpaceL(aName.Length() - 1 + (((iType == EDirectory) && !HasTrailingSlash()) ? 1 : 0));
+		Insert(0, aName.Mid(1));
+		}
+	else if (!aName.HasTrailingSlash() && !HasLeadingSlash())
+		{
+		CheckSpaceL(aName.Length() + 1 + (((iType == EDirectory) && !HasTrailingSlash()) ? 1 : 0));
+		Insert(0, KSlash);
+		Insert(0, aName);
+		}
+	else
+		{
+		CheckSpaceL(aName.Length() + (((iType == EDirectory) && !HasTrailingSlash()) ? 1 : 0));
+		Insert(0, aName);
+		}
+
+	if ((iType == EDirectory) && (!HasTrailingSlash()))
+		{
+		Append(KSlash);
+		}
+	}
+
+EXPORT_C void TFileName2::AppendComponentL(const TFileName2& aName)
+	{
+	AppendComponentL(aName, iType);
+	}
+
+EXPORT_C void TFileName2::AppendComponentL(const TDesC& aPathComponent, TFileName2::TType aType)
+	{
+	// This function doesn't use iType, therefore you can call it and get the same results regardless of whether the type has been set - you will only get a trailing slash if (a) aPathComponent ends in a slash, or (b) aType is EDirectory.
+	TPtrC pathWithoutLeadingSlash(aPathComponent);
+	if (aPathComponent.Length() && aPathComponent[0] == '\\') pathWithoutLeadingSlash.Set(aPathComponent.Mid(1));
+	TInt pathLen = pathWithoutLeadingSlash.Length();
+	const TDesC* middle = &KNullDesC;
+	if (Length() && !HasTrailingSlash()) middle = &KSlash;
+	const TDesC* end = &KNullDesC;
+	if (aType == EDirectory && pathLen && pathWithoutLeadingSlash[pathLen-1] != '\\') end = &KSlash;
+	CheckSpaceL(pathLen + middle->Length() + end->Length());
+
+	Append(*middle);
+	Append(pathWithoutLeadingSlash);
+	Append(*end);
+	}
+
+EXPORT_C void TFileName2::AppendComponentL(const TEntry& aEntry)
+	{
+	AppendComponentL(aEntry.iName, aEntry.IsDir() ? EDirectory : EFile);
+	}
+
+EXPORT_C void TFileName2::SetIsDirectoryL()
+	{
+	// This is the more complicated way to do it, the other would be: if (!HasTrailingSlash()) AppendL(KSlash);
+	// Or indeed, AppendComponentL(KNullDesC, EDirectory) since the type is irrelevant if the component is empty
+	AppendComponentL(KNullDesC, EFile);
+	}
+
+void TFileName2::CheckSpaceL(TInt aLengthToAdd) const
+	{
+	if ((MaxLength() - Length()) < aLengthToAdd)
+		{
+		User::Leave(KErrTooBig);
+		}
+	}
+
+EXPORT_C void TFileName2::SplitL(RArray<TFileName2>& aOutput)
+	{
+	TLex lex(*this);
+	while (!lex.Eos())
+		{
+		lex.Mark();
+		while (!lex.Eos() && (lex.Peek() != '\\'))
+			{
+			lex.Get();
+			}
+		User::LeaveIfError(aOutput.Append(TFileName2(lex.MarkedToken())));
+		if (!lex.Eos())
+			{
+			// Skip over the slash
+			lex.Get();
+			if (lex.Eos())
+				{
+				// ended with slash - insert empty path component
+				User::LeaveIfError(aOutput.Append(TFileName2()));
+				}
+			}
+		}
+	}
+
+EXPORT_C void TFileName2::MakeAbsoluteL(const TFileName2& aAbsoluteTo)
+	{
+	ASSERT(aAbsoluteTo.IsAbsolute());
+
+	if (IsAbsolute())
+		{
+		return;
+		}
+
+	if (HasLeadingSlash())
+		{
+		// Just prepend drive letter.
+		PrependL(aAbsoluteTo.Left(2));
+		return;
+		}
+
+	PrependL(aAbsoluteTo);
+	RArray<TFileName2> splitName;
+	CleanupClosePushL(splitName);
+	SplitL(splitName);
+	TInt i = 0;
+	while (i < splitName.Count())
+		{
+		const TFileName2& piece = splitName[i];
+		if (piece == KDot)
+			{
+			splitName.Remove(i);
+			}
+		else if (piece == KDoubleDot)
+			{
+			if ((i == 0) || ((i == 1) && splitName[0].IsDriveLetter()))
+				{
+				User::Leave(KErrBadName);
+				}
+			splitName.Remove(i);
+			splitName.Remove(i - 1);
+			--i;
+			}
+		else if ((piece == KNullDesC) && (i != 0) && (i != splitName.Count()-1))
+			{
+			// Allow empty piece in first or last slot to support leading/trailing slashes.
+			splitName.Remove(i);
+			}
+		else
+			{
+			++i;
+			}
+		}
+
+	UnsplitL(splitName);
+	CleanupStack::PopAndDestroy(&splitName);
+	}
+
+EXPORT_C void TFileName2::MakeAbsoluteL(RFs& aFs)
+	{
+	TFileName2 sessionPath;
+	User::LeaveIfError(aFs.SessionPath(sessionPath));
+	MakeAbsoluteL(sessionPath);
+	}
+
+EXPORT_C void TFileName2::UnsplitL(const RArray<TFileName2>& aInput)
+	{
+	Zero();
+	const TInt count = aInput.Count();
+	for (TInt i = 0; i < count; ++i)
+		{
+		AppendComponentL(aInput[i]);
+		}
+	if ((count == 1) && (aInput[0].Match(_L("?:")) == 0))
+		{
+		Append(KSlash);
+		}
+	}
+
+EXPORT_C TBool TFileName2::Exists(RFs& aFs) const
+	{
+	TInt err;
+	if (IsDriveRoot())
+		{
+		TInt driveNumber;
+		err = RFs::CharToDrive(Drive()[0], driveNumber);
+		if (err == KErrNone)
+			{
+			TDriveInfo driveInfo;
+			err = aFs.Drive(driveInfo, driveNumber);
+			}
+		}
+	else
+		{
+		TUint att;
+		err = aFs.Att(*this, att);
+		}
+	return (err == KErrNone);
+	}
+
+EXPORT_C TBool TFileName2::IsReadOnlyL(RFs& aFs) const
+	{
+	TEntry entry;
+	User::LeaveIfError(aFs.Entry(*this, entry));
+	return entry.IsReadOnly();
+	}
+
+EXPORT_C TBool TFileName2::IsHiddenL(RFs& aFs) const
+	{
+	TEntry entry;
+	User::LeaveIfError(aFs.Entry(*this, entry));
+	return entry.IsHidden();
+	}
+
+EXPORT_C TBool TFileName2::IsSystemL(RFs& aFs) const
+	{
+	TEntry entry;
+	User::LeaveIfError(aFs.Entry(*this, entry));
+	return entry.IsSystem();
+	}
+
+EXPORT_C TBool TFileName2::IsDirL(RFs& aFs) const
+	{
+	if (IsDriveRoot())
+		{
+		if (!Exists(aFs))
+			{
+			User::Leave(KErrNotFound);
+			}
+		return ETrue;
+		}
+	else
+		{
+		TEntry entry;
+		User::LeaveIfError(aFs.Entry(*this, entry));
+		return entry.IsDir();
+		}
+	}
+
+EXPORT_C TBool TFileName2::IsArchiveL(RFs& aFs) const
+	{
+	TEntry entry;
+	User::LeaveIfError(aFs.Entry(*this, entry));
+	return entry.IsArchive();
+	}
+
+EXPORT_C TInt TFileName2::FindFile(RFs& aFs)
+	{
+	TFindFile ff(aFs);
+	TInt err = ff.FindByDir(*this, KNullDesC);
+	if (err==KErrNone)
+		{
+		*this = ff.File();
+		}
+	return err;
+	}
+	
+EXPORT_C void TFileName2::FindFileL(RFs& aFs)
+	{
+	User::LeaveIfError(FindFile(aFs));
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/iocons.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,319 @@
+// iocons.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/iocli.h>
+#include <fshell/consoleextensions.h>
+#include "iocons.h"
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+#include <fshell/memoryaccess.h>
+#endif
+
+// This constant is used to find the PIPS Stdio Server CServer2 object in the situation
+// where iocons in running in the stdioserver.exe process. Normally, when iocons calls
+// RIo(Read|Write)Handle::Open(RIoSession&), iosrv looks to see if it hand any read or
+// write objects that belong to the calling thread. Note, when fshell creates a new process
+// it creates a set of read and write objects inside iosrv, and assigns them as being owned
+// by the main thread of the new process. However, in the case of PIPS, the main thread
+// of the process that fshell creates isn't the one that opens the console. This is done
+// from the context of the sdioserver.exe process. To cater for this, iocons has a special
+// behaviour when its running in the context of sdioserver.exe. This involves finding the
+// server's CServer2 sub-class object, and using this to retrieve the current RMessage2
+// object. From this, the client's thread id can be found. This is passed into a different
+// RIo(Read|Write)Handle::Open overload that attempt to open a handle using the specified
+// thread id (not that which iocons is currently running in). If fshell created the process
+// this should return without error, in which case the PIPS process will be able to share
+// fshell's console (or take part in a pipe-line that it created). If not, then the old
+// behaviour of creating a new console will proceed.
+const TInt KPipsStdioServerAllocPos = 5;
+
+
+CIoConsole::CIoConsole()
+	{
+	}
+
+CIoConsole::CIoConsole(RIoConsoleReadHandle& aReadHandle, RIoConsoleWriteHandle& aWriteHandle)
+	{
+	iReadHandle = aReadHandle;
+	iWriteHandle = aWriteHandle;
+	}
+
+CIoConsole::~CIoConsole()
+	{
+	if (iIoSession.Handle())
+		{
+		// If the handle isn't set it means we don't own iReadHandle/iWriteHandle (or they haven't been constructed and we needn't close them anyway)
+		iReadHandle.Close();
+		iWriteHandle.Close();
+		iConsole.Close();
+		iIoSession.Close();
+		}
+	}
+
+TInt CIoConsole::Create(const TDesC& aTitle, TSize aSize)
+	{
+	// This should only be called via iocons, ie when the zero arguments constructor was used.
+	// When the 2-arg constructor is used, the console is fully constructed and Create should not be called
+	TInt err = iIoSession.Connect();
+	if (err == KErrNone)
+		{
+		// See if iosrv has any handles ready for us
+		err = iReadHandle.Open(iIoSession);
+		if (err)
+			{
+			// If not, check if we're being opened from the stdioserver on behalf of the client PIPS exe
+			TThreadId clientThreadId;
+			if (FindClientThreadId(clientThreadId) == KErrNone)
+				{
+				err = iReadHandle.Open(iIoSession, clientThreadId);
+				if (err == KErrNone)
+					{
+					err = iWriteHandle.Open(iIoSession, clientThreadId);
+					if (err != KErrNone)
+						{
+						iReadHandle.Close();
+						}
+					}
+				}
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+			if (err)
+				{
+				// Try and see if the thread that created us has some handles we can use, and if not, the thread that created it etc until we find one or lose track
+				RMemoryAccess::LoadDriver();
+				RMemoryAccess memAccess;
+				err = memAccess.Open();
+				if (!err) err = iReadHandle.Create(iIoSession);
+				if (!err) iWriteHandle.Create(iIoSession);
+				if (!err)
+					{
+					TUint creator = RThread().Id();
+					while (creator != 0)
+						{
+						creator = memAccess.GetThreadCreatorId(creator);
+						err = iReadHandle.DuplicateHandleFromThread(TThreadId(creator));
+						if (err == KErrNone)
+							{
+							// Found one - open the writer too...
+							err = iWriteHandle.DuplicateHandleFromThread(TThreadId(creator));
+							break; // Stop looking if we found one
+							}
+						}
+					memAccess.Close();
+					}
+				if (err)
+					{
+					iReadHandle.Close();
+					iWriteHandle.Close();
+					}
+				}
+#endif
+
+			if (err)
+				{
+				// If all else fails, create a new console
+				err = CreateNewConsole(aTitle, aSize);
+				}
+			}
+		else
+			{
+			err = iWriteHandle.Open(iIoSession);
+			}
+		}
+	if (err)
+		{
+		iReadHandle.Close();
+		iWriteHandle.Close();
+		iConsole.Close();
+		iIoSession.Close();
+		}
+	return err;
+	}
+
+TInt CIoConsole::CreateNewConsole(const TDesC& aTitle, TSize aSize)
+	{
+	TInt err = iConsole.Create(iIoSession, aTitle, aSize);
+	if (err) return err;
+	err = iReadHandle.Create(iIoSession);
+	if (err) return err;
+	err = iWriteHandle.Create(iIoSession);
+	if (err) return err;
+	err = iConsole.Attach(iReadHandle, RIoEndPoint::EForeground);
+	if (err) return err;
+	err = iConsole.Attach(iWriteHandle);
+	if (err) return err;
+
+	err = iReadHandle.SetOwner(RThread().Id());
+	if (err) return err;
+	err = iWriteHandle.SetOwner(RThread().Id());
+	
+	return err;
+	}
+
+TBool CIoConsole::HeapWalk(TAny* aSelf, RAllocatorHelper::TCellType aCellType, TLinAddr aCellPtr, TInt)
+	{
+	CIoConsole* self = (CIoConsole*)aSelf;
+	if (aCellType == RAllocatorHelper::EAllocation)
+		{
+		if (++(self->iHeapCellCount) == KPipsStdioServerAllocPos)
+			{
+			self->iServerAddress = (TAny*)aCellPtr;
+			return EFalse; // To indicate we're finished
+			}
+		}
+	return ETrue; // keep going
+	}
+
+class CHackedServer : public CServer2
+	{
+public:
+	inline CHackedServer() : CServer2(CActive::EPriorityStandard) {} // needed to shut up gcce
+	inline const RMessage2& Msg() const { return Message(); }
+	};
+
+TInt CIoConsole::FindClientThreadId(TThreadId& aThreadId)
+	{
+	TInt err = KErrNotFound;
+	_LIT(KPipsStdioServer, "stdioserver.exe*");
+	TName processName(RProcess().Name());
+	if (processName.MatchF(KPipsStdioServer) == 0)
+		{
+		LtkUtils::RAllocatorHelper allocHelper;
+		TInt err = allocHelper.Open(&User::Allocator());
+		if (!err) err = allocHelper.Walk(&HeapWalk, this);
+		allocHelper.Close();
+		if (err == KErrNone && iServerAddress)
+			{
+			// This means that we found the server's address (possibly).
+			CHackedServer* server = (CHackedServer*)iServerAddress;
+			RThread client;
+			if (server->Msg().Client(client) == KErrNone)
+				{
+				err = KErrNone;
+				aThreadId = client.Id();
+				client.Close();
+				}
+			}
+		}
+	return err;
+	}
+
+void CIoConsole::Read(TRequestStatus& aStatus)
+	{
+	iReadHandle.WaitForKey(aStatus);
+	}
+
+void CIoConsole::ReadCancel()
+	{
+	iReadHandle.WaitForKeyCancel();
+	}
+
+void CIoConsole::Write(const TDesC& aDes)
+	{
+	iWriteHandle.Write(aDes);
+	}
+
+TPoint CIoConsole::CursorPos() const
+	{
+	TPoint pos;
+	iWriteHandle.GetCursorPos(pos);
+	return pos;
+	}
+
+void CIoConsole::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	iWriteHandle.SetCursorPosAbs(aPoint);
+	}
+
+void CIoConsole::SetCursorPosRel(const TPoint& aPoint)
+	{
+	iWriteHandle.SetCursorPosRel(aPoint);
+	}
+
+void CIoConsole::SetCursorHeight(TInt aPercentage)
+	{
+	iWriteHandle.SetCursorHeight(aPercentage);
+	}
+
+void CIoConsole::SetTitle(const TDesC& aTitle)
+	{
+	iWriteHandle.SetTitle(aTitle);
+	}
+
+void CIoConsole::ClearScreen()
+	{
+	iWriteHandle.ClearScreen();
+	}
+
+void CIoConsole::ClearToEndOfLine()
+	{
+	iWriteHandle.ClearToEndOfLine();
+	}
+
+TSize CIoConsole::ScreenSize() const
+	{
+	TSize size;
+	iWriteHandle.GetScreenSize(size);
+	return size;
+	}
+
+TKeyCode CIoConsole::KeyCode() const
+	{
+	return (TKeyCode)iReadHandle.KeyCode();
+	}
+
+TUint CIoConsole::KeyModifiers() const
+	{
+	return iReadHandle.KeyModifiers();
+	}
+
+TInt CIoConsole::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	return CConsoleBase::Extension_(aExtensionId, a0, a1);
+	}
+
+EXPORT_C CConsoleBase* IoUtils::NewConsole()
+	{
+	return new CIoConsole;
+	}
+
+// This is horrible, but only way to satisfy WINSCW compiler. If we define it always, we end up re-exporting typeinfo for CColorConsoleBase in armv5 which we don't want to be doing
+#ifdef __WINS__
+void CColorConsoleBase::SetTextAttribute(TTextAttribute)
+	{
+	}
+#endif
+
+void CIoConsole::SetTextAttribute(TTextAttribute aAttribute)
+	{
+	TUint attrib = 0;
+	switch (aAttribute)
+		{
+	case ETextAttributeNormal:
+		attrib = ConsoleAttributes::ENone;
+		break;
+	case ETextAttributeBold:
+		attrib = ConsoleAttributes::EBold;
+		break;
+	case ETextAttributeInverse:
+		attrib = ConsoleAttributes::EInverse;
+		break;
+	case ETextAttributeHighlight:
+		// Should highlight map to inverse? Seems slightly better than bold
+		attrib = ConsoleAttributes::EInverse;
+		break;
+	default:
+		break;
+		}
+	iWriteHandle.SetAttributes(attrib); // Can't do anything with the error
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/memoryaccesscmd.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,55 @@
+// memoryaccesscmd.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/memoryaccesscmd.h>
+
+using namespace IoUtils;
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+__ASSERT_COMPILE(sizeof(RMemoryAccess) == sizeof(TUint32) * 3);
+#endif
+
+__ASSERT_COMPILE(sizeof(CMemoryAccessCommandBase) == 62*4); // Otherwise CCommandBase has changed or RMemoryAccess has
+
+EXPORT_C CMemoryAccessCommandBase::CMemoryAccessCommandBase()
+	: CCommandBase()
+	{
+	}
+
+EXPORT_C CMemoryAccessCommandBase::CMemoryAccessCommandBase(TUint aFlags)
+	: CCommandBase(aFlags)
+	{
+	}
+
+EXPORT_C void CMemoryAccessCommandBase::LoadMemoryAccessL()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	__ASSERT_COMPILE(_FOFF(CMemoryAccessCommandBase, iMemAccess) == 59*4); // Otherwise something strange has gone wrong in CCommandBase
+	if (iMemAccess.Handle()) return; // Already open
+
+	TInt err = RMemoryAccess::LoadDriver();
+	if (err != KErrAlreadyExists)
+		{
+		LeaveIfErr(err, _L("Couldn't load %S.LDD"), &KMemoryAccessName);
+		}
+	LeaveIfErr(iMemAccess.Open(), _L("Couldn't open RMemoryAccess"));
+#else
+	LeaveIfErr(KErrNotSupported, _L("Can't load memoryaccess because FSHELL_MEMORY_ACCESS_SUPPORT is not defined");
+#endif
+	}
+
+EXPORT_C CMemoryAccessCommandBase::~CMemoryAccessCommandBase()
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	iMemAccess.Close();
+	// Don't unload memaccess, we want to keep loaded so it can monitor stuff
+#endif
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/pod_formatter.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,313 @@
+// pod_formatter.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "pod_formatter.h"
+
+const TInt KGap = 2;
+
+_LIT(KPartialCommandStart, "\r\n=");
+_LIT(KCommandStart, "\r\n\r\n=");
+_LIT(KBlankLine, "\r\n\r\n");
+_LIT(KNewLine, "\r\n");
+
+using namespace IoUtils;
+
+
+TPodFormatter::TPodFormatter(CTextFormatter& aFormatter)
+	: iFormatter(aFormatter)
+	{
+	}
+
+void TPodFormatter::FormatL(const TDesC& aPod)
+	{
+	iPodLex = aPod;
+	while (!iPodLex.Eos())
+		{
+		TPtrC command(NextCommand());
+		if (command == _L("pod"))
+			{
+			SkipToNextBlankLine();
+			}
+		else if ((command == _L("head1")) || (command == _L("head2")))
+			{
+			iPodLex.SkipSpaceAndMark();
+			SkipToLineEnd();
+			iFormatter.SetAttributesL(ConsoleAttributes::EBold | ConsoleAttributes::EUnderscore);
+			iFormatter.WrapL(0, iPodLex.MarkedToken());
+			iFormatter.SetAttributesL(ConsoleAttributes::ENone);
+			iFormatter.AppendL(KBlankLine);
+			}
+		else if (command == _L("cut"))
+			{
+			SkipToNextBlankLine();
+			break;
+			}
+		else if (command == _L("begin"))
+			{
+			TPtrC nextCommand;
+			do
+				{
+				nextCommand.Set(NextCommand());
+				}
+				while ((nextCommand.Length() > 0) && (nextCommand != _L("end")));
+
+			SkipToNextBlankLine();
+			}
+		else if (command == _L("for"))
+			{
+			SkipToNextBlankLine();
+			}
+		else if (command == _L("over"))
+			{
+			iPodLex.SkipSpace();
+			TUint indent;
+			User::LeaveIfError(iPodLex.Val(indent));
+			OverL(indent);
+			}
+
+		FormatToNextCommandL();
+		}
+	}
+
+void TPodFormatter::OverL(TInt aIndent)
+	{
+	CTextBuffer* buffer = CTextBuffer::NewLC(0x100);
+
+	while (!iPodLex.Eos())
+		{
+		FormatToNextCommandL(aIndent);
+
+		TPtrC command(NextCommand());
+		if (command == _L("item"))
+			{
+			iPodLex.SkipSpaceAndMark();
+			SkipToLineEnd();
+			buffer->AppendL(iPodLex.MarkedToken());
+			iPodLex.SkipSpace();
+			//buffer->AppendL('\t');
+			//buffer->AppendL(TextToNextCommand());
+			// Need to split the text up putting a tab in front of every paragraph of text, in case the item description is multi-paragraph.
+			// If we don't, the next paragraph will end up in column one which will break the column formatter.
+			// If there's a neater way of doing this, someone feel free! -TomS
+			TPtrC text(TextToNextCommand());
+			while(text.Length())
+				{
+				TInt nextNewLine = text.Find(KNewLine);
+				if (nextNewLine == KErrNotFound) nextNewLine = text.Length();
+				TPtrC line(text.Left(nextNewLine+KNewLine().Length()));
+				buffer->AppendL('\t');
+				buffer->AppendL(line);
+				text.Set(text.Mid(line.Length()));
+				}
+			buffer->AppendL(KNewLine);
+			}
+		else if (command == _L("back"))
+			{
+			break;
+			}
+		else if (command == _L("over"))
+			{
+			if (buffer->Descriptor().Length() > 0)
+				{
+				iFormatter.TabulateL(aIndent, KGap, buffer->Descriptor(), EWrapLastColumn);
+				iFormatter.AppendL(KNewLine);
+				buffer->Zero();
+				}
+			iPodLex.SkipSpace();
+			TUint indent;
+			User::LeaveIfError(iPodLex.Val(indent));
+			OverL(indent + aIndent);
+			}
+		}
+
+	if (buffer->Descriptor().Length() > 0)
+		{
+		iFormatter.TabulateL(aIndent, KGap, buffer->Descriptor(), EWrapLastColumn);
+		iFormatter.AppendL(KNewLine);
+		}
+
+	CleanupStack::PopAndDestroy(buffer);
+	}
+
+void TPodFormatter::FormatToNextCommandL(TInt aIndent)
+	{
+	FOREVER
+		{
+		TPtrC paragraph(NextParagraph());
+		if (paragraph.Length() > 0)
+			{
+			if (TChar(paragraph[0]).IsSpace())
+				{
+				iFormatter.AppendL(paragraph);
+				}
+			else
+				{
+				iFormatter.WrapL(aIndent, paragraph);
+				}
+			iFormatter.AppendL(KNewLine);
+			}
+		else
+			{
+			break;
+			}
+		}
+	}
+
+TPtrC TPodFormatter::NextCommand()
+	{
+	TPtrC command;
+	if (SkipToNextCommand() == KErrNone)
+		{
+		iPodLex.Mark();
+		iPodLex.SkipCharacters();
+		command.Set(iPodLex.MarkedToken());
+		}
+	return command;
+	}
+
+TPtrC TPodFormatter::NextParagraph()
+	{
+	// Consume leading new line characters.
+	while (iPodLex.Remainder().Find(KNewLine) == 0)
+		{
+		if (AtCommandStart())
+			{
+			return TPtrC();
+			}
+		iPodLex.Inc(KNewLine().Length());
+		}
+	
+	iPodLex.Mark();
+
+	if (iPodLex.Peek().IsSpace())
+		{
+		// This line has leading white space - treat everything up to the next blank line as a single paragraph.
+		if (SkipToNextBlankLine() != KErrNone)
+			{
+			SkipToLineEnd();
+			}
+		}
+	else if (SkipToNextLine() != KErrNone)
+		{
+		SkipToLineEnd();
+		}
+
+	return iPodLex.MarkedToken();
+	}
+
+TPtrC TPodFormatter::TextToNextCommand()
+	{
+	TInt initialOffset = iPodLex.Offset();
+	iPodLex.Mark();
+
+	if (SkipToNextCommand() == KErrNone)
+		{
+		if (iPodLex.Offset() >= KCommandStart().Length())
+			{
+			iPodLex.Inc(-(KCommandStart().Length()));
+			}
+		else
+			{
+			iPodLex.Inc(-(iPodLex.Remainder().Length()));
+			}
+		}
+	else
+		{
+		iPodLex.Inc(iPodLex.Remainder().Length());
+		}
+
+	if (initialOffset < iPodLex.Offset())
+		{
+		return iPodLex.MarkedToken();
+		}
+	else
+		{
+		return TPtrC(NULL, 0);
+		}
+	}
+
+void TPodFormatter::SkipToLineEnd()
+	{
+	if (SkipTo(KNewLine) != KErrNone)
+		{
+		iPodLex.Inc(iPodLex.Remainder().Length());
+		}
+	}
+
+TInt TPodFormatter::SkipToNextLine()
+	{
+	TInt ret = SkipTo(KNewLine);
+	if (ret == KErrNone)
+		{
+		iPodLex.Inc(KNewLine().Length());
+		}
+	return ret;
+	}
+
+TInt TPodFormatter::SkipToNextCommand()
+	{
+	if (iPodLex.Remainder().Find(KPartialCommandStart) == 0)
+		{
+		if (iPodLex.Offset() == 0)
+			{
+			iPodLex.Inc(KPartialCommandStart().Length());
+			return KErrNone;
+			}
+		else
+			{
+			iPodLex.Inc(-2);
+			if (iPodLex.Remainder().Find(KCommandStart) == 0)
+				{
+				iPodLex.Inc(KCommandStart().Length());
+				return KErrNone;
+				}
+			else
+				{
+				iPodLex.Inc(2);
+				}
+			}
+		}
+
+	TInt ret = SkipTo(KCommandStart);
+	if (ret == KErrNone)
+		{
+		iPodLex.Inc(KCommandStart().Length());
+		}
+	return ret;
+	}
+
+TInt TPodFormatter::SkipToNextBlankLine()
+	{
+	TInt ret = SkipTo(KBlankLine);
+	if (ret == KErrNone)
+		{
+		iPodLex.Inc(2);
+		}
+	return ret;
+	}
+
+TInt TPodFormatter::SkipTo(const TDesC& aDes)
+	{
+	TInt ret = iPodLex.Remainder().Find(aDes);
+	if (ret >= 0)
+		{
+		iPodLex.Inc(ret);
+		return KErrNone;
+		}
+	return KErrNotFound;
+	}
+
+TBool TPodFormatter::AtCommandStart()
+	{
+	return ((iPodLex.Remainder().Find(KCommandStart) == 0) || (iPodLex.Remainder().Find(KPartialCommandStart) == 0));
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/pod_formatter.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,49 @@
+// pod_formatter.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __POD_FORMATTER_H__
+#define __POD_FORMATTER_H__
+
+#include <e32std.h>
+#include "ioutils.h"
+
+namespace IoUtils
+	{
+
+/**
+ * Responsible for handling POD commands ('=head1', '=over', etc).
+ */
+class TPodFormatter
+	{
+public:
+	TPodFormatter(CTextFormatter& aFormatter);
+	void FormatL(const TDesC& aPod);
+private:
+	void OverL(TInt aIndent);
+	void FormatToNextCommandL(TInt aIndent = 0);
+	TPtrC NextCommand();
+	TPtrC NextParagraph();
+	TPtrC TextToNextCommand();
+	void SkipToLineEnd();
+	TInt SkipToNextLine();
+	TInt SkipToNextCommand();
+	TInt SkipToNextBlankLine();
+	TInt SkipTo(const TDesC& aDes);
+	TBool AtCommandStart();
+private:
+	CTextFormatter& iFormatter;
+	TLex iPodLex;
+	};
+
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/pod_lexer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,229 @@
+// pod_lexer.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "pod_lexer.h"
+
+
+TPodLexer::TPodLexer(const TDesC& aString)
+	: iLex(aString), iAttributes(0), iAttributeStackIndex(0)
+	{
+	}
+
+void TPodLexer::NextTokenL(TPtrC& aToken, TTokenType& aTokenType, TUint& aAttributes, TBool& aEop, TBool& aEos)
+	{
+	aTokenType = ETextBlock;
+	iScratch.Zero();
+	TBool finished(EFalse);
+	TBool setAttributes(ETrue);
+	while (!iLex.Eos() && !finished && (iScratch.Length() < (iScratch.MaxLength() - 1)))
+		{
+		iLex.Mark();
+		TUint16 sequenceIdentifier;
+		if ((iAttributeStackIndex > 0) && (iLex.Peek() == '>'))
+			{
+			if (iScratch.Length() > 0)
+				{
+				aAttributes = iAttributes;
+				setAttributes = EFalse;
+				finished = ETrue;
+				}
+			else
+				{
+				iLex.Get();
+				aTokenType = EAttributePop;
+				aAttributes = PopAttribute();
+				setAttributes = EFalse;
+				finished = ETrue;
+				}
+			}
+		else if (IsInteriorSequenceStart(sequenceIdentifier))
+			{
+			if (iScratch.Length() > 0)
+				{
+				iLex.UnGetToMark();
+				finished = ETrue;
+				}
+			else
+				{
+				switch (sequenceIdentifier)
+					{
+					case 'B':
+						PushAttribute(EBold);
+						aAttributes = EBold;
+						setAttributes = EFalse;
+						aTokenType = EAttributePush;
+						finished = ETrue;
+						break;
+					case 'C':
+						PushAttribute(ECode);
+						aAttributes = ECode;
+						setAttributes = EFalse;
+						aTokenType = EAttributePush;
+						finished = ETrue;
+						break;
+					case 'E':
+						if (iLex.Remainder().Length() >= 3)
+							{
+							if (iLex.Remainder().Left(3) == _L("gt>"))
+								{
+								iLex.Inc(3);
+								iScratch.Append('>');
+								}
+							else if (iLex.Remainder().Left(3) == _L("lt>"))
+								{
+								iLex.Inc(3);
+								iScratch.Append('<');
+								}
+							else
+								{
+								TUint num;
+								TInt err = iLex.Val(num);
+								if (err == KErrNone)
+									{
+									iScratch.Append(num);
+									}
+								else
+									{
+									User::Leave(err);
+									}
+								}
+							}
+						break;
+					case 'F':
+						PushAttribute(EFileName);
+						aAttributes = EFileName;
+						setAttributes = EFalse;
+						aTokenType = EAttributePush;
+						finished = ETrue;
+						break;
+					case 'I':
+						PushAttribute(EItalic);
+						aAttributes = EItalic;
+						setAttributes = EFalse;
+						aTokenType = EAttributePush;
+						finished = ETrue;
+						break;
+					case 'L':
+						iLex.Mark();
+						SkipToClosingAngleBracket();
+						iLex.UnGet();
+						iScratch.Copy(iLex.MarkedToken());
+						iLex.Get();
+						aTokenType = ELink;
+						finished = ETrue;
+						break;
+					case 'S':
+					case 'X':
+						PushAttribute(ENull);
+						aAttributes = ENull;
+						setAttributes = EFalse;
+						aTokenType = EAttributePush;
+						finished = ETrue;
+						break;
+					case 'Z':
+						if (iLex.Peek() == '>')
+							{
+							iLex.Inc();
+							iLex.Mark();
+							}
+						else
+							{
+							User::Leave(KErrArgument);
+							}
+						break;
+					}
+				}
+			}
+		else
+			{
+			iScratch.Append(iLex.Get());
+			}
+		}
+
+	if (setAttributes)
+		{
+		aAttributes = iAttributes;
+		}
+	aToken.Set(iScratch);
+	aEop = Eop();
+	aEos = iLex.Eos();
+	}
+
+TInt TPodLexer::SkipToClosingAngleBracket()
+	{
+	TInt numSkippedChars = 0;
+	while (!iLex.Eos())
+		{
+		TUint16 sequenceIdentifier;
+		if (IsInteriorSequenceStart(sequenceIdentifier))
+			{
+			numSkippedChars = SkipToClosingAngleBracket();
+			}
+		else if (iLex.Get() == '>')
+			{
+			break;
+			}
+		else
+			{
+			++numSkippedChars;
+			}
+		}
+	return numSkippedChars;
+	}
+
+TBool TPodLexer::Eop()
+	{
+	_LIT(KParagraphEnd, "\r\n\r\n");
+	return ((iLex.Remainder().Length() >= 4) && (iLex.Remainder().Left(4) == KParagraphEnd));
+	}
+
+TBool TPodLexer::IsInteriorSequenceStart(TUint16& aSequenceIdentifier)
+	{
+	if (iLex.Remainder().Length() >= 2)
+		{
+		TUint16 first = iLex.Get();
+		TUint16 second = iLex.Get();
+		if (second == '<')
+			{
+			switch (first)
+				{
+				case 'B':
+				case 'C':
+				case 'E':
+				case 'F':
+				case 'I':
+				case 'L':
+				case 'S':
+				case 'X':
+				case 'Z':
+					aSequenceIdentifier = first;
+					return ETrue;
+				}
+			}
+		iLex.Inc(-2);
+		}
+	return EFalse;
+	}
+
+void TPodLexer::PushAttribute(TAttribute aAttribute)
+	{
+	iAttributes |= aAttribute;
+	iAttributeStack[iAttributeStackIndex++] = aAttribute;
+	}
+
+TPodLexer::TAttribute TPodLexer::PopAttribute()
+	{
+	TAttribute poppedAttribute = iAttributeStack[--iAttributeStackIndex];
+	iAttributes &= ~poppedAttribute;
+	return poppedAttribute;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/pod_lexer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,61 @@
+// pod_lexer.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __POD_LEXER_H__
+#define __POD_LEXER_H__
+
+#include <e32std.h>
+
+const TInt KMaxNestedAttributes = 16;
+
+
+/**
+ * Responsible for understanding POD interior sequences (B<bold>, I<italic>, etc.).
+ */
+class TPodLexer
+	{
+public:
+	enum TTokenType
+		{
+		EAttributePush,
+		EAttributePop,
+		ETextBlock,
+		ECodeBlock,
+		ELink,
+		EIndexEntry
+		};
+	enum TAttribute
+		{
+		ENull		= 0x00000000,
+		EBold		= 0x00000001,
+		ECode		= 0x00000002,
+		EItalic		= 0x00000004,
+		EFileName	= 0x00000008
+		};
+public:
+	TPodLexer(const TDesC& aString);
+	void NextTokenL(TPtrC& aToken, TTokenType& aTokenType, TUint& aAttributes, TBool& aEop, TBool& aEos);
+private:
+	TInt SkipToClosingAngleBracket();
+	TBool Eop();
+	TBool IsInteriorSequenceStart(TUint16& aSequenceIdentifier);
+	void PushAttribute(TAttribute aAttribute);
+	TAttribute PopAttribute();
+private:
+	TLex iLex;
+	TUint iAttributes;
+	TBuf<64> iScratch;
+	TFixedArray<TAttribute, KMaxNestedAttributes> iAttributeStack;
+	TInt iAttributeStackIndex;
+	};
+
+#endif // __POD_LEXER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/server_command.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,970 @@
+// server_command.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/line_editor.h>
+#include "command_base.h"
+
+using namespace IoUtils;
+
+
+//
+// Constants.
+//
+
+_LIT(KTab, "\t");
+_LIT(KSpace, " ");
+_LIT(KNewLine, "\r\n");
+_LIT(KHelpCommandName, "help");
+
+
+// used for sorting RArray<TPtrC>'s
+TInt PtrOrder(const TPtrC& aDennis, const TPtrC& aGnasher)
+	{
+	return aDennis.Compare(aGnasher);
+	}
+
+
+//
+// TServerCommandId.
+//
+
+EXPORT_C TServerCommandId::TServerCommandId()
+	: iId(0)
+	{
+	}
+
+EXPORT_C TServerCommandId::TServerCommandId(TUint aValue)
+	: iId(aValue)
+	{
+	}
+
+EXPORT_C TUint TServerCommandId::Value() const
+	{
+	return iId;
+	}
+
+EXPORT_C void TServerCommandId::Set(const TServerCommandId& aId)
+	{
+	iId = aId.iId;
+	}
+
+EXPORT_C TBool TServerCommandId::operator==(const TServerCommandId& aId) const
+	{
+	return (iId == aId.iId);
+	}
+
+
+//
+// CServerCommandBase.
+//
+
+EXPORT_C CServerCommandBase::~CServerCommandBase()
+	{
+	}
+
+EXPORT_C const TServerCommandId& CServerCommandBase::Id() const
+	{
+	return iId;
+	}
+
+EXPORT_C void CServerCommandBase::SetId(const TServerCommandId& aId)
+	{
+	iId.Set(aId);
+	}
+
+EXPORT_C void CServerCommandBase::SetFactory(CServerCommandFactory& aFactory)
+	{
+	iFactory = &aFactory;
+	}
+
+EXPORT_C CServerCommandBase::CServerCommandBase()
+	{
+	}
+
+EXPORT_C CServerCommandBase::CServerCommandBase(TUint aFlags)
+	: CCommandBase(aFlags)
+	{
+	}
+
+EXPORT_C CServerCommandFactory& CServerCommandBase::Factory()
+	{
+	__ASSERT_ALWAYS(iFactory, Panic(ENoFactory));
+	return *iFactory;
+	}
+
+EXPORT_C void CServerCommandBase::PrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	if (iReporter)
+		{
+		iReporter->ReportList(iId, aFmt, aList);
+		}
+	else
+		{
+		CCommandBase::PrintList(aFmt, aList);
+		}
+	}
+
+EXPORT_C void CServerCommandBase::PrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
+	{
+	if (iReporter)
+		{
+		iReporter->ReportList(iId, aFmt, aList);
+		}
+	else
+		{
+		CCommandBase::PrintList(aFmt, aList);
+		}
+	}
+
+EXPORT_C void CServerCommandBase::PrintErrorList(TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	if (iReporter)
+		{
+		iReporter->ReportErrorList(iId, aError, aFmt, aList);
+		}
+	else
+		{
+		CCommandBase::PrintErrorList(aError, aFmt, aList);
+		}
+	}
+
+EXPORT_C void CServerCommandBase::PrintWarningList(TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	if (iReporter)
+		{
+		iReporter->ReportWarningList(iId, aFmt, aList);
+		}
+	else
+		{
+		CCommandBase::PrintWarningList(aFmt, aList);
+		}
+	}
+
+void CServerCommandBase::SetReporter(MServerCommandReporter* aReporter)
+	{
+	iReporter = aReporter;
+	}
+
+
+//
+// CHelpCommand.
+//
+
+NONSHARABLE_CLASS(CHelpCommand) : public CServerCommandBase
+	{
+public:
+	static CServerCommandBase* NewLC();
+	~CHelpCommand();
+	static const TDesC& NameS();
+private:
+	CHelpCommand();
+	void ConstructL();
+	void GenerateTextL(const CServerCommandFactory& aFactory, TInt aIndent = 0);
+	HBufC* FullCommandNameLC() const;
+	void Write(TInt aIndent, const TDesC& aCommandName);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+private:
+	CTextBuffer* iBuffer;
+	CTextFormatter* iFormatter;
+	RArray<TPtrC> iCommandNameStack;
+	RFile iPodIndex;
+	};
+
+CServerCommandBase* CHelpCommand::NewLC()
+	{
+	CHelpCommand* self = new(ELeave) CHelpCommand();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CHelpCommand::~CHelpCommand()
+	{
+	delete iBuffer;
+	delete iFormatter;
+	iPodIndex.Close();
+	iCommandNameStack.Close();
+	}
+
+const TDesC& CHelpCommand::NameS()
+	{
+	return KHelpCommandName;
+	}
+
+CHelpCommand::CHelpCommand()
+	{
+	}
+
+void CHelpCommand::ConstructL()
+	{
+	BaseConstructL();
+	}
+
+const TDesC& CHelpCommand::Name() const
+	{
+	return KHelpCommandName;
+	}
+
+const TDesC& CHelpCommand::Description() const
+	{
+	_LIT(KDescription, "List the commands the amsrv supports.");
+	return KDescription;
+	}
+	
+void CHelpCommand::GenerateTextL(const CServerCommandFactory& aFactory, TInt aIndent)
+	{
+	RArray<TPtrC> commands;
+	CleanupClosePushL(commands);
+	aFactory.ListCommandsL(commands);
+	commands.Sort(TLinearOrder<TPtrC>(PtrOrder));
+	
+	const TInt numCommands = commands.Count();
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		const TDesC& commandName = commands[i];
+		Write(aIndent, commandName);
+
+		const CServerCommandConstructor& cmnd = aFactory.GetSubCommandL(commandName);
+		if (cmnd.IsFactory())
+			{
+			GenerateTextL((const CServerCommandFactory&)cmnd, aIndent+1);
+			}
+		}
+	CleanupStack::PopAndDestroy();
+	}
+
+HBufC* CHelpCommand::FullCommandNameLC() const
+	{
+	const TInt numCommands = iCommandNameStack.Count();
+	TInt length = 0;
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		length += iCommandNameStack[i].Length();
+		if (i > 0)
+			{
+			++length;
+			}
+		}
+	HBufC* name = HBufC::NewLC(length);
+	TPtr namePtr(name->Des());
+	for (TInt i = 0; i < numCommands; ++i)
+		{
+		if (i > 0)
+			{
+			namePtr.Append('_');
+			}
+		namePtr.Append(iCommandNameStack[i]);
+		}
+	return name;
+	}
+
+void CHelpCommand::Write(TInt aIndent, const TDesC& aCommandName)
+	{
+	_LIT(KIndent, "  ");
+
+	if (iBuffer)
+		{
+		for (TInt j=0; j<aIndent; ++j)
+			{
+			iBuffer->AppendL(KIndent);
+			}
+		iBuffer->AppendL(aCommandName);
+		iBuffer->AppendL(KTab);
+		}
+	else
+		{
+		for (TInt j=0; j<aIndent; ++j)
+			{
+			CCommandBase::Write(KIndent);
+			}
+		CCommandBase::Write(aCommandName);
+		CCommandBase::Write(KNewLine);
+		}
+	}
+
+void CHelpCommand::DoRunL()
+	{
+	if (Stdout().AttachedToConsole())
+		{
+		iBuffer = CTextBuffer::NewL(0x100);
+		iFormatter = CTextFormatter::NewL(Stdout());
+		}
+	GenerateTextL(Factory());
+	if (iBuffer)
+		{
+		iFormatter->ColumnizeL(0, 2, iBuffer->Descriptor());
+		CCommandBase::Write(iFormatter->Descriptor());
+		}
+	CCommandBase::Write(_L("\r\n"));
+	}
+
+
+//
+// CRootCommand.
+//
+
+NONSHARABLE_CLASS(CRootCommand) : public CBranchCommandBase
+	{
+public:
+	static CRootCommand* NewL(CServerCommandFactory& aFactory);
+	~CRootCommand();
+private:
+	CRootCommand();
+	void ConstructL(CServerCommandFactory& aFactory);
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+private: // From CAmCmndParent.
+	virtual const TDesC& TypeDescription();
+	};
+
+CRootCommand* CRootCommand::NewL(CServerCommandFactory& aFactory)
+	{
+	CRootCommand* root = new(ELeave)CRootCommand();
+	CleanupStack::PushL(root);
+	root->ConstructL(aFactory);
+	CleanupStack::Pop(root);
+	return root;
+	}
+
+CRootCommand::~CRootCommand()
+	{
+	}
+
+CRootCommand::CRootCommand()
+	{
+	}
+
+void CRootCommand::ConstructL(CServerCommandFactory& aFactory)
+	{
+	SetFactory(aFactory);
+	}
+
+const TDesC& CRootCommand::Name() const
+	{
+	_LIT(KCommandName, "root");
+	return KCommandName;
+	}
+
+const TDesC& CRootCommand::Description() const
+	{
+	_LIT(KDescription, "A pseudo-command that is the ancestor of all other commands available in this server. Not intended to be run directly.");
+	return KDescription;
+	}
+
+const TDesC& CRootCommand::TypeDescription()
+	{
+	return KNullDesC;
+	}
+
+
+//
+// CServerBase.
+//
+
+EXPORT_C CServerBase::~CServerBase()
+	{
+	delete iLineEditor;
+	delete iFactory;
+	}
+
+EXPORT_C CServerBase::CServerBase(TUint aFlags, const TDesC& aPrompt, const TDesC& aCommandHistoryFileName)
+	: CCommandBase(aFlags), iPrompt(aPrompt), iCommandHistoryFileName(aCommandHistoryFileName), iWriterAdaptor(Stdout())
+	{
+	}
+
+EXPORT_C CServerCommandFactory& CServerBase::Factory()
+	{
+	return *iFactory;
+	}
+
+EXPORT_C void CServerBase::Exit(TInt aError)
+	{
+	iExitReason = aError;
+	iExit = ETrue;
+	}
+
+EXPORT_C void CServerBase::BaseConstructL()
+	{
+	CCommandBase::BaseConstructL();
+	}
+
+EXPORT_C void CServerBase::DoRunL()
+	{
+	iFactory = CServerCommandFactory::NewL(this, Cif());
+	iLineEditor = CLineEditor::NewL(FsL(), iWriterAdaptor, *this, *iFactory, iCommandHistoryFileName);
+	InitializeL();
+	RProcess::Rendezvous(KErrNone);
+
+	do
+		{
+		CheckNewConsoleLine();
+		Write(iPrompt);
+		ParseLineL(NextLineL());
+		}
+		while (!iExit);
+
+	Complete(iExitReason);
+	}
+
+EXPORT_C void CServerBase::PrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	TOverflowTruncate overflow;
+	TBuf<0x100> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	Report(TServerCommandId(), buf);
+	}
+
+EXPORT_C void CServerBase::PrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
+	{
+	TOverflowTruncate8 overflow;
+	TBuf8<0x100> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	Report(TServerCommandId(), buf);
+	}
+
+EXPORT_C void CServerBase::PrintErrorList(TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	if (!iErrorReported)
+		{
+		TOverflowTruncate overflow;
+		TBuf<0x100> buf;
+		buf.AppendFormatList(aFmt, aList, &overflow);
+		ReportError(TServerCommandId(), aError, buf);
+		iErrorReported = ETrue;
+		}
+	}
+
+EXPORT_C void CServerBase::PrintWarningList(TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	TOverflowTruncate overflow;
+	TBuf<0x100> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	ReportWarning(TServerCommandId(), buf);
+	}
+
+EXPORT_C void CServerBase::Report(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	ReportList(aId, aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void CServerBase::ReportList(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	TOverflowTruncate overflow;
+	TBuf<0x100> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	Report(aId, buf);
+	}
+
+EXPORT_C void CServerBase::Report(const TServerCommandId& aId, TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	ReportList(aId, aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void CServerBase::ReportList(const TServerCommandId& aId, TRefByValue<const TDesC8> aFmt, VA_LIST& aList)
+	{
+	TOverflowTruncate8 overflow;
+	TBuf8<0x100> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	Report(aId, buf);
+	}
+
+EXPORT_C void CServerBase::ReportWarning(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	ReportWarningList(aId, aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void CServerBase::ReportWarningList(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	TOverflowTruncate overflow;
+	TBuf<0x100> buf;
+	buf.AppendFormatList(aFmt, aList, &overflow);
+	ReportWarning(aId, buf);
+	}
+
+EXPORT_C void CServerBase::ReportError(const TServerCommandId& aId, TInt aError, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	ReportErrorList(aId, aError, aFmt, list);
+	VA_END(list);
+	}
+
+EXPORT_C void CServerBase::ReportErrorList(const TServerCommandId& aId, TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList)
+	{
+	if (!iErrorReported)
+		{
+		TOverflowTruncate overflow;
+		TBuf<0x100> buf;
+		buf.AppendFormatList(aFmt, aList, &overflow);
+		ReportError(aId, aError, buf);
+		iErrorReported = ETrue;
+		}
+	}
+
+EXPORT_C void CServerBase::LeoHandleLine(const TDesC& aLine)
+	{
+	iLine = aLine;
+	iLineRead = ETrue;
+	}
+
+void CServerBase::ParseLineL(const TDesC& aLine)
+	{
+	if (aLine.Length() > 0)
+		{
+		iErrorReported = EFalse;
+		CRootCommand* root = CRootCommand::NewL(Factory());
+		root->SetReporter(this);
+		root->RunCommand(IoSession(), Stdin(), Stdout(), Stderr(), &aLine, &Env(), NULL);
+		__ASSERT_ALWAYS(root->IsComplete(), Panic(EUnexpectedAsyncCommand));
+		delete root;
+		}
+	}
+
+const TDesC& CServerBase::NextLineL()
+	{
+retry:
+	iLine.Zero();
+
+	if (Stdin().AttachedToConsole())
+		{
+		iLineEditor->Start(KNullDesC);
+		iLineEditor->ReinstatePromptAndUserInput();
+		iLineRead = EFalse;
+		do
+			{
+			TRequestStatus status;
+			Stdin().WaitForKey(status);
+			User::WaitForRequest(status);
+			if (status.Int() == KErrNotSupported)
+				{
+				// Likely that we're no longer attached to a console and are instead attached to a pipe.
+				// Note, using "pcons" directly gives us a console, but using "am.exe" gives us a pipe.
+				iLineEditor->Abort();
+				goto retry;
+				}
+			User::LeaveIfError(status.Int());
+			iLineEditor->HandleKey(Stdin().KeyCode(), Stdin().KeyModifiers());
+			}
+			while (!iLineRead);
+		}
+	else
+		{
+		LeaveIfErr(Stdin().SetReadMode(RIoReadHandle::ELine), _L("Couldn't set stdin to line mode"));
+		Stdin().SetLineSeparatorL(KNewLine());
+		User::LeaveIfError(Stdin().Read(iLine));
+		}
+
+	iLine.TrimRight();
+	return iLine;
+	}
+
+EXPORT_C void CServerBase::CheckNewConsoleLine()
+	{
+	if (Stdout().AttachedToConsole())
+		{
+		TPoint cursorPos(0, 0);
+		Stdout().GetCursorPos(cursorPos);
+		if (cursorPos.iX != 0)
+			{
+			Stdout().Write(KNewLine);
+			}
+		}
+	}
+
+
+//
+// CServerCommandConstructor.
+//
+
+EXPORT_C CServerCommandConstructor* CServerCommandConstructor::NewLC(const TDesC& aName, TServerCommandConstructor aConstructor, CServerCommandFactory& aFactory, MServerCommandReporter* aReporter, const CCommandInfoFile* aCif)
+	{
+	CServerCommandConstructor* self = new(ELeave)CServerCommandConstructor(aName, aConstructor, aFactory, aReporter, aCif);
+	CleanupStack::PushL(self);
+	return self;
+	}
+
+EXPORT_C CServerCommandConstructor::~CServerCommandConstructor()
+	{
+	}
+
+EXPORT_C const TPtrC& CServerCommandConstructor::Name() const
+	{
+	return iName;
+	}
+
+EXPORT_C CServerCommandBase* CServerCommandConstructor::CreateImplementationLC() const
+	{
+	CServerCommandBase* commandBase = (*iConstructorLC)();
+	commandBase->SetReporter(iReporter);
+	commandBase->SetFactory(iFactory);
+	if (iCif)
+		{
+		commandBase->SetCif(*iCif);
+		}
+	return commandBase;	
+	}
+
+EXPORT_C TBool CServerCommandConstructor::IsFactory() const
+	{
+	return EFalse;
+	}
+
+CServerCommandConstructor::CServerCommandConstructor(const TDesC& aName, TServerCommandConstructor aConstructor, CServerCommandFactory& aFactory, MServerCommandReporter* aReporter, const CCommandInfoFile* aCif)
+	: iName(aName), iConstructorLC(aConstructor), iFactory(aFactory), iReporter(aReporter), iCif(aCif)
+	{
+	}
+
+TUint32 DefaultTPtrCHash(const TPtrC& aPtr)
+	{
+	return DefaultHash::Des16(aPtr);
+	}
+	
+TBool DefaultIdTPtrCRelation(const TPtrC& aPtr1, const TPtrC& aPtr2)
+	{
+	return DefaultIdentity::Des16(aPtr1, aPtr2);
+	}
+
+	
+//
+// CServerCommandFactory.
+//
+
+EXPORT_C CServerCommandFactory* CServerCommandFactory::NewL(MServerCommandReporter* aReporter, const CCommandInfoFile* aCif)
+	{
+	CServerCommandFactory* self = new(ELeave)CServerCommandFactory(aReporter, aCif);
+	CleanupStack::PushL(self);
+	self->ConstructL(ERoot);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CServerCommandFactory* CServerCommandFactory::NewLC(const TDesC& aName, TServerCommandConstructor aConstructor, MServerCommandReporter* aReporter, const CCommandInfoFile* aCif)
+	{
+	CServerCommandFactory* self = new(ELeave)CServerCommandFactory(aName, aConstructor, aReporter, aCif);
+	CleanupStack::PushL(self);
+	self->ConstructL(EBranch);
+	return self;
+	}
+	
+EXPORT_C CServerCommandFactory::~CServerCommandFactory()
+	{
+	THashMapIter<const TPtrC, const CServerCommandConstructor*> iter(iSubCommands);
+	while (iter.NextKey())
+		{
+		delete *iter.CurrentValue();
+		}
+	iSubCommands.Close();
+	}
+
+EXPORT_C const CServerCommandConstructor& CServerCommandFactory::GetSubCommandL(const TDesC& aName) const
+	{
+	const CServerCommandConstructor* cmnd = GetSubCommand(aName);
+	if (!cmnd)
+		{
+		if (iReporter)
+			{
+			iReporter->ReportError(TServerCommandId(), KErrNotFound, _L("Couldn't create command \"%S\""), &aName);
+			}
+		User::Leave(KErrNotFound);
+		}
+	return *cmnd;
+	}
+
+const CServerCommandConstructor* CServerCommandFactory::GetSubCommand(const TDesC& aName) const
+	{
+	TPtrC name(aName);
+	const CServerCommandConstructor* const * cmnd = iSubCommands.Find(name);
+	if (!cmnd)
+		{
+		return NULL;
+		}
+	return *cmnd;
+	}
+
+EXPORT_C TBool CServerCommandFactory::IsFactory() const
+	{
+	return ETrue;
+	}
+
+EXPORT_C void CServerCommandFactory::AddSubCommandL(const CServerCommandConstructor* aCommand)
+	{
+	iSubCommands.InsertL(aCommand->Name(), aCommand);
+	}
+
+CServerCommandFactory::CServerCommandFactory(MServerCommandReporter* aReporter, const CCommandInfoFile* aCif)
+	: CServerCommandConstructor(KNullDesC, NULL, *this, aReporter, aCif), iSubCommands(THashFunction32<const TPtrC>(&DefaultTPtrCHash), TIdentityRelation<const TPtrC>(&DefaultIdTPtrCRelation))
+	{
+	}
+
+CServerCommandFactory::CServerCommandFactory(const TDesC& aName, TServerCommandConstructor aConstructor, MServerCommandReporter* aReporter, const CCommandInfoFile* aCif)
+	: CServerCommandConstructor(aName, aConstructor, *this, aReporter, aCif), iSubCommands(THashFunction32<const TPtrC>(&DefaultTPtrCHash), TIdentityRelation<const TPtrC>(&DefaultIdTPtrCRelation))
+	{
+	}
+
+void CServerCommandFactory::ConstructL(TFactoryType aType)
+	{
+	if (aType == ERoot)
+		{
+		AddLeafCommandL<CHelpCommand>();
+		}
+	}
+
+void CServerCommandFactory::LcCompleteLineL(TConsoleLine& aLine, const TChar&)
+	{
+	TLex lex(aLine.ContentsToCursor());
+	TInt pos = 0;
+	
+	const CServerCommandFactory* factory = this;
+	
+	do
+		{
+		lex.SkipSpaceAndMark();
+		pos = lex.Offset();
+		lex.SkipCharacters();
+		
+		if (!lex.Eos())
+			{
+			const CServerCommandConstructor* command = GetSubCommand(lex.MarkedToken());
+			if (!command || !command->IsFactory())
+				{
+				User::Leave(KErrNotFound);
+				}
+			factory = static_cast<const CServerCommandFactory*>(command);
+			}
+		
+		} while (!lex.Eos());
+	
+	
+	
+	RArray<TPtrC> commands;
+	CleanupClosePushL(commands);
+	TPtrC partialCommandName(lex.MarkedToken());
+
+	factory->ListCommandsL(commands);
+
+	// Remove commands that don't match.
+	TInt i;
+	for (i = (commands.Count() - 1); i >= 0; --i)
+		{
+		if (commands[i].Find(partialCommandName) != 0)
+			{
+			commands.Remove(i);
+			}
+		}
+
+	if (commands.Count() > 0)
+		{
+		CompleteLineL(aLine, pos, commands);
+		}
+
+	CleanupStack::PopAndDestroy(&commands);
+	}
+
+void CServerCommandFactory::CompleteLineL(TConsoleLine& aLine, TInt aPos, const RArray<TPtrC> aPossibilities) const
+	{
+	const TInt numPossibilities = aPossibilities.Count();
+
+	if (numPossibilities > 1)
+		{
+		// Fill out possibilities buffer.
+		IoUtils::CTextBuffer* possibilities = IoUtils::CTextBuffer::NewLC(0x100);
+		for (TInt i = 0; i < numPossibilities; ++i)
+			{
+			possibilities->AppendL(aPossibilities[i]);
+			if (i != (numPossibilities - 1))
+				{
+				possibilities->AppendL(KTab);
+				}
+			}
+
+		aLine.PrintCompletionPossibilitiesL(possibilities->Descriptor());
+		CleanupStack::PopAndDestroy(possibilities);
+		}
+
+	if (numPossibilities > 0)
+		{
+		IoUtils::CTextBuffer* completion = IoUtils::CTextBuffer::NewLC(0x100);
+		TPtrC commonChars(NULL, 0);
+		if (numPossibilities > 1)
+			{
+			// Find common leading characters of the possibilities.
+			TInt commonCharPos = -1;
+			TBool finished(EFalse);
+			do
+				{
+				++commonCharPos;
+				TChar character(0);
+				for (TInt i = 0; i < numPossibilities; ++i)
+					{
+					if (commonCharPos >= aPossibilities[i].Length())
+						{
+						finished = ETrue;
+						break;
+						}
+					else if (i == 0)
+						{
+						character = aPossibilities[0][commonCharPos];
+						character.Fold();
+						}
+					else
+						{
+						TChar c(aPossibilities[i][commonCharPos]);
+						c.Fold();
+						if (c != character)
+							{
+							finished = ETrue;
+							break;
+							}
+						}
+					}
+				}
+				while (!finished);
+
+			commonChars.Set(aPossibilities[0].Mid(0, commonCharPos));
+			}
+		else
+			{
+			commonChars.Set(aPossibilities[0]);
+			}
+
+		completion->AppendL(commonChars);
+		if (numPossibilities == 1)
+			{
+			completion->AppendL(KSpace);
+			}
+		if (completion->Descriptor().Length() > 0)
+			{
+			aLine.Replace(aPos, completion->Descriptor());
+			}
+		CleanupStack::PopAndDestroy(completion);
+		}
+	}
+
+EXPORT_C void CServerCommandFactory::ListCommandsL(RArray<TPtrC>& aList) const
+	{
+	THashMapIter<const TPtrC, const CServerCommandConstructor*> iter(iSubCommands);
+	while (iter.NextKey())
+		{
+		aList.AppendL(*iter.CurrentKey());
+		}
+	aList.Sort(TLinearOrder<TPtrC>(PtrOrder));
+	}
+
+
+
+//
+// CBranchCommandBase.
+//
+
+EXPORT_C CBranchCommandBase::~CBranchCommandBase()
+	{
+	delete iSubCommandEnum;
+	delete iSubCommandArgs;
+	}
+
+EXPORT_C CBranchCommandBase::CBranchCommandBase()
+	{
+	}
+
+EXPORT_C void CBranchCommandBase::DoRunL()
+	{
+	TPtrC subCommandName(iArguments.AsString(&iType));
+
+	CServerCommandBase* subCommand = Factory().GetSubCommandL(subCommandName).CreateImplementationLC();
+	ConfigureSubCommand(*subCommand);
+	subCommand->RunCommand(IoSession(), Stdin(), Stdout(), Stderr(), iSubCommandArgs ? iSubCommandArgs : &KNullDesC, &Env(), NULL);
+	if (subCommand->IsComplete())
+		{
+		HandleSubCommandComplete(*subCommand);
+		CleanupStack::PopAndDestroy(subCommand);
+		}
+	else
+		{
+		HandleBackgroundSubCommand(*subCommand);
+		CleanupStack::Pop(subCommand);
+		}
+	}
+
+void CBranchCommandBase::BuildEnumL()
+	{
+	_LIT(KComma, ",");
+	RArray<TPtrC> subCommands;
+	CleanupClosePushL(subCommands);
+	Factory().ListCommandsL(subCommands);
+	subCommands.Sort(TLinearOrder<TPtrC>(PtrOrder));
+	iSubCommandEnum = IoUtils::CTextBuffer::NewL(0x10);
+	for (TInt i=0; i<subCommands.Count(); ++i)
+		{
+		iSubCommandEnum->AppendL(subCommands[i]);
+		iSubCommandEnum->AppendL(KComma);
+		}
+	CleanupStack::PopAndDestroy(&subCommands);
+	}
+	
+EXPORT_C void CBranchCommandBase::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KArgType, "type");
+	_LIT(KArgArgs, "arguments");
+
+	if (!iSubCommandEnum)
+		{
+		BuildEnumL();
+		}
+
+	if (UsingCif())
+		{
+		aArguments.AppendEnumL((TInt&)iType, KArgType, iSubCommandEnum->Descriptor());
+		aArguments.AppendStringL(iSubCommandArgs, KArgArgs);
+		}
+	else
+		{
+		aArguments.AppendEnumL((TInt&)iType, KArgType, TypeDescription(), iSubCommandEnum->Descriptor());
+
+		_LIT(KArgArgsDescription, "A set of type-specific arguments and options.");
+		aArguments.AppendStringL(iSubCommandArgs, KArgArgs, KArgArgsDescription, KValueTypeFlagOptional | KValueTypeFlagLast);
+		}
+	}
+
+EXPORT_C const TDesC& CBranchCommandBase::TypeDescription()
+	{
+	return KNullDesC;
+	}
+
+EXPORT_C void CBranchCommandBase::ConfigureSubCommand(CServerCommandBase&)
+	{
+	}
+
+EXPORT_C void CBranchCommandBase::HandleSubCommandComplete(CServerCommandBase& aCommand)
+	{
+	if (aCommand.CompletionReason() < 0)
+		{
+		PrintError(aCommand.CompletionReason(), _L("Couldn't run sub-command \"%S\" of command \"%S\""), &aCommand.Name(), &Name());
+		}
+	}
+
+EXPORT_C void CBranchCommandBase::HandleBackgroundSubCommand(CServerCommandBase&)
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/client/text_formatter.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1295 @@
+// text_formatter.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include "ioutils.h"
+#include "pod_lexer.h"
+#include "pod_formatter.h"
+
+using namespace IoUtils;
+
+
+//
+// Constants.
+//
+
+_LIT(KSpace, " ");
+_LIT(KNewLine, "\r\n");
+
+
+//
+// CTextBuffer.
+//
+
+EXPORT_C CTextBuffer* CTextBuffer::NewL(TInt aExpandSize)
+	{
+	CTextBuffer* self = CTextBuffer::NewLC(aExpandSize);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CTextBuffer* CTextBuffer::NewLC(TInt aExpandSize)
+	{
+	CTextBuffer* self = new(ELeave) CTextBuffer();
+	CleanupStack::PushL(self);
+	self->ConstructL(aExpandSize);
+	return self;
+	}
+
+EXPORT_C CTextBuffer::~CTextBuffer()
+	{
+	Cancel();
+	delete iBuf;
+	delete iScratchBuf;
+	delete iScratchBuf8;
+	iAttributes.Close();
+	}
+
+EXPORT_C void CTextBuffer::Zero()
+	{
+	iBuf->Delete(0, iBuf->Size());
+	iAttributes.Reset();
+	}
+
+EXPORT_C void CTextBuffer::Reset()
+	{
+	iBuf->Reset();
+	iAttributes.Reset();
+	}
+
+EXPORT_C void CTextBuffer::ResetText()
+	{
+	iBuf->Reset();
+	}
+
+EXPORT_C void CTextBuffer::SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor)
+	{
+	const TInt numAttributes = iAttributes.Count();
+	if (numAttributes == 0)
+		{
+		if (Length() == 0)
+			{
+			TAttributes attributes(0, aAttributes, aForegroundColor, aBackgroundColor);
+			iAttributes.AppendL(attributes);
+			}
+		else
+			{
+			TAttributes attributes(Length(), aAttributes, aForegroundColor, aBackgroundColor);
+			if (!attributes.Matches(ConsoleAttributes::ENone, ConsoleAttributes::EUnchanged, ConsoleAttributes::EUnchanged))
+				{
+				TAttributes defaultAttributes(0, ConsoleAttributes::ENone, ConsoleAttributes::EUnchanged, ConsoleAttributes::EUnchanged);
+				iAttributes.AppendL(defaultAttributes);
+				TInt err = iAttributes.Append(attributes);
+				if (err != KErrNone)
+					{
+					iAttributes.Reset();
+					User::Leave(err);
+					}
+				}
+			}
+		}
+	else if (iAttributes[numAttributes - 1].Matches(aAttributes, aForegroundColor, aBackgroundColor))
+		{
+		// Do nothing.
+		}
+	else if (iAttributes[numAttributes - 1].iPosition == Length())
+		{
+		TAttributes& att = iAttributes[numAttributes - 1];
+		if (aAttributes & ConsoleAttributes::ENone)
+			{
+			att.iAttributes.iAttributes = aAttributes;
+			att.iAttributes.iForegroundColor = aForegroundColor;
+			att.iAttributes.iBackgroundColor = aBackgroundColor;
+			}
+		else
+			{
+			// Merge on top of existing attributes
+			att.iAttributes.iAttributes |= aAttributes;
+			if (aForegroundColor != ConsoleAttributes::EUnchanged) att.iAttributes.iForegroundColor = aForegroundColor;
+			if (aBackgroundColor != ConsoleAttributes::EUnchanged) att.iAttributes.iBackgroundColor = aBackgroundColor;
+			}
+		}
+	else
+		{
+		TAttributes attributes(Length(), aAttributes, aForegroundColor, aBackgroundColor);
+		iAttributes.AppendL(attributes);
+		}
+	}
+
+EXPORT_C void CTextBuffer::SetAttributesL(const ConsoleAttributes::TAttributes& aAttributes)
+	{
+	SetAttributesL(aAttributes.iAttributes, aAttributes.iForegroundColor, aAttributes.iBackgroundColor);
+	}
+
+EXPORT_C void CTextBuffer::GetCurrentAttributes(TUint& aAttributes, ConsoleAttributes::TColor& aForegroundColor, ConsoleAttributes::TColor& aBackgroundColor) const
+	{
+	if (iAttributes.Count() > 0)
+		{
+		const TAttributes& att = iAttributes[iAttributes.Count() - 1];
+		aAttributes = att.iAttributes.iAttributes;
+		aForegroundColor = att.iAttributes.iForegroundColor;
+		aBackgroundColor = att.iAttributes.iBackgroundColor;
+		}
+	else
+		{
+		aAttributes = ConsoleAttributes::ENone;
+		aForegroundColor = ConsoleAttributes::EUnchanged;
+		aBackgroundColor = ConsoleAttributes::EUnchanged;
+		}
+	}
+
+EXPORT_C void CTextBuffer::GetAttributes(TInt aPos, TUint& aAttributes, ConsoleAttributes::TColor& aForegroundColor, ConsoleAttributes::TColor& aBackgroundColor) const
+	{
+	ASSERT(aPos < Length());
+
+	aAttributes = ConsoleAttributes::ENone;
+	aForegroundColor = ConsoleAttributes::EUnchanged;
+	aBackgroundColor = ConsoleAttributes::EUnchanged;
+
+	const TInt numAttributes = iAttributes.Count();
+	for (TInt i = 0; i < numAttributes; ++i)
+		{
+		const TAttributes& att = iAttributes[i];
+		if (aPos < att.iPosition)
+			{
+			return;
+			}
+		else
+			{
+			aAttributes = att.iAttributes.iAttributes;
+			aForegroundColor = att.iAttributes.iForegroundColor;
+			aBackgroundColor = att.iAttributes.iBackgroundColor;
+			}
+		}
+	}
+
+EXPORT_C void CTextBuffer::AppendL(const TChar& aChar)
+	{
+	TUint16 ch = (TUint16)TUint(aChar); // We don't support surrogate pairs
+	iBuf->InsertL(iBuf->Size(), &ch, 2);
+	}
+
+EXPORT_C void CTextBuffer::AppendL(const TDesC& aText)
+	{
+	iBuf->InsertL(iBuf->Size(), aText.Ptr(), aText.Size());
+	}
+
+EXPORT_C void CTextBuffer::AppendL(const TDesC8& aText)
+	{
+	if (!iScratchBuf)
+		{
+		iScratchBuf = HBufC::NewL(Max(aText.Length(), 256));
+		}
+	if (iScratchBuf->Des().MaxLength() < aText.Length())
+		{
+		iScratchBuf = iScratchBuf->ReAllocL(Max(iScratchBuf->Des().MaxLength()*2, aText.Length()));
+		}
+	iScratchBuf->Des().Copy(aText);	
+	iBuf->InsertL(iBuf->Size(), iScratchBuf->Ptr(), iScratchBuf->Size());
+	}
+
+EXPORT_C void CTextBuffer::AppendL(const CTextBuffer& aText)
+	{
+	AppendL(aText, 0, aText.Length());
+	}
+
+EXPORT_C void CTextBuffer::AppendL(const CTextBuffer& aText, TInt aPosition)
+	{
+	AppendL(aText, aPosition, aText.Length() - aPosition);
+	}
+
+EXPORT_C void CTextBuffer::AppendL(const CTextBuffer& aText, TInt aPosition, TInt aLength)
+	{
+	const TInt numAttributes = aText.iAttributes.Count();
+	if (numAttributes > 0)
+		{
+		TInt textPos = 0;
+		TInt appendCount = 0;
+		TInt blockIndex = 0;
+		const TDesC* block = NULL;
+		do
+			{
+			TUint attributes;
+			ConsoleAttributes::TColor foregroundColor;
+			ConsoleAttributes::TColor backgroundColor;
+			aText.NextBlock(blockIndex, block, attributes, foregroundColor, backgroundColor);
+			if (block != NULL)
+				{
+				if ((textPos + block->Length()) > aPosition)
+					{
+					SetAttributesL(attributes, foregroundColor, backgroundColor);
+					TInt blockOffset = aPosition - textPos;
+					if (blockOffset < 0)
+						{
+						blockOffset = 0;
+						}
+					TPtrC appendBlock(block->Mid(blockOffset, Min(aLength - appendCount, block->Length() - blockOffset)));
+					AppendL(appendBlock);
+					appendCount += appendBlock.Length();
+					if (appendCount == aLength)
+						{
+						break;
+						}
+					}
+				textPos += block->Length();
+				}
+			}
+			while (block != NULL);
+		}
+	else
+		{
+		AppendL(aText.Descriptor().Mid(aPosition, aLength));
+		}
+	}
+
+EXPORT_C void CTextBuffer::AppendFormatL(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	AppendFormatListL(aFmt, list);
+	}
+
+EXPORT_C void CTextBuffer::AppendFormatListL(const TDesC16& aFmt, VA_LIST& aList)
+	{
+	TOverflowLeave overflow;
+	TInt err = KErrNone;
+	do
+		{
+		TPtr ptr(iScratchBuf->Des());
+		ptr.Zero();
+		TRAP(err, ptr.AppendFormatList(aFmt, aList, &overflow));
+		if (err == KErrOverflow)
+			{
+			iScratchBuf = iScratchBuf->ReAllocL(ptr.MaxLength() * 2);
+			}
+		}
+		while (err == KErrOverflow);
+
+	User::LeaveIfError(err);
+	iBuf->InsertL(iBuf->Size(), iScratchBuf->Ptr(), iScratchBuf->Size());
+	}
+	
+EXPORT_C void CTextBuffer::AppendFormatL(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	AppendFormatListL(aFmt, list);
+	}
+	
+EXPORT_C void CTextBuffer::AppendFormatListL(const TDesC8& aFmt, VA_LIST& aList)
+	{
+	TOverflowLeave8 overflow;
+	TInt err = KErrNone;
+	if (!iScratchBuf8)
+		{
+		iScratchBuf8 = HBufC8::NewL(0x100);
+		}
+		
+	do
+		{
+		TPtr8 ptr(iScratchBuf8->Des());
+		ptr.Zero();
+		TRAP(err, ptr.AppendFormatList(aFmt, aList, &overflow));
+		if (err == KErrOverflow)
+			{
+			iScratchBuf8 = iScratchBuf8->ReAllocL(ptr.MaxLength() * 2);
+			}
+		}
+		while (err == KErrOverflow);
+
+	User::LeaveIfError(err);
+	
+	TPtr8 ptr(iScratchBuf8->Des());
+	if (iScratchBuf->Des().MaxLength() < ptr.Length())
+		{
+		iScratchBuf = iScratchBuf->ReAllocL(Max(iScratchBuf->Des().MaxLength()*2, ptr.Length()));
+		}
+	iScratchBuf->Des().Copy(*iScratchBuf8);	
+	
+	iBuf->InsertL(iBuf->Size(), iScratchBuf->Ptr(), iScratchBuf->Size());
+	}
+
+EXPORT_C void CTextBuffer::AppendHumanReadableSizeL(TInt aSize)
+	{
+	AppendHumanReadableSizeL(TInt64(aSize), EColumnAlignedRight);
+	}
+
+EXPORT_C void CTextBuffer::AppendHumanReadableSizeL(TInt64 aSize)
+	{
+	AppendHumanReadableSizeL(aSize, EColumnAlignedRight);
+	}
+
+EXPORT_C void CTextBuffer::AppendHumanReadableSizeL(TInt aSize, TAlignment aAlignment)
+	{
+	AppendHumanReadableSizeL(TInt64(aSize), aAlignment);
+	}
+
+EXPORT_C void CTextBuffer::AppendHumanReadableSizeL(TInt64 aSize, TAlignment aAlignment)
+	{
+	const TInt64 KB = 1024;
+	const TInt64 MB = KB * KB;
+	const TInt64 GB = MB * KB;
+	const TInt64 TB = GB * KB;
+	_LIT(KBytes, " B ");
+	_LIT(KKilobytes, " KB");
+	_LIT(KMegabytes, " MB");
+	_LIT(KGigabytes, " GB");
+	_LIT(KTerabytes, " TB");
+
+	_LIT(KLeftWhole, "%- 7.0f");
+	_LIT(KLeftFrac, "%- 7.2f");
+	_LIT(KRightWhole, "%+ 7.0f");
+	_LIT(KRightFrac, "%+ 7.2f");
+	_LIT(KNormalWhole, "%.0f");
+	_LIT(KNormalFrac, "%.2f");
+
+	const TDesC* suff = &KBytes;
+	TReal n = aSize;
+	TInt64 factor = 1;
+
+	TInt64 absSize = aSize;
+	if (absSize < 0) absSize = -absSize;
+
+	if (absSize >= TB)
+		{
+		suff = &KTerabytes;
+		factor = TB;
+		}
+	else if (absSize >= GB)
+		{
+		suff = &KGigabytes;
+		factor = GB;
+		}
+	else if (absSize >= MB)
+		{
+		suff = &KMegabytes;
+		factor = MB;
+		}
+	else if (absSize >= KB)
+		{
+		suff = &KKilobytes;
+		factor = KB;
+		}
+
+	n = n / (TReal)factor;
+	TBool wholeNumUnits = (absSize & (factor-1)) == 0; // ie aSize % factor == 0
+
+	const TDesC* fmt = NULL;
+	if (aAlignment == EColumnAlignedLeft)
+		{
+		fmt = wholeNumUnits ? &KLeftWhole : &KLeftFrac;
+		}
+	else if (aAlignment == EColumnAlignedRight)
+		{
+		fmt = wholeNumUnits ? &KRightWhole : &KRightFrac;
+		}
+	else
+		{
+		fmt = wholeNumUnits ? &KNormalWhole : &KNormalFrac;
+		}
+
+	AppendFormatL(*fmt, n);
+	AppendL(*suff);
+	}
+
+EXPORT_C void CTextBuffer::AppendSpacesL(TInt aCount)
+	{
+	ASSERT(aCount >= 0);
+	while (aCount > 0)
+		{
+		AppendL(KSpace);
+		--aCount;
+		}
+	}
+
+EXPORT_C void CTextBuffer::Delete(TInt aPos, TInt aLength)
+	{
+	//for (TInt i = 0; i < iAttributes.Count(); i++)
+	//	{
+	//	RDebug::Printf("attribute %d: pos %d", i, iAttributes[i].iPosition);
+	//	}
+
+	// Find the first and last attributes that are inside the delete region.
+	TInt firstAttribute = -1;
+	TInt lastAttribute = -1;
+	TInt numAttributes = iAttributes.Count();
+	for (TInt i = (numAttributes - 1); i >= 0; --i)
+		{
+		const TAttributes& thisAttribute = iAttributes[i];
+		if ((lastAttribute == -1) && (thisAttribute.iPosition >= aPos) && (thisAttribute.iPosition < aPos + aLength))
+			{
+			lastAttribute = i;
+			}
+		if (lastAttribute >= 0 && thisAttribute.iPosition >= aPos)
+			{
+			firstAttribute = i;
+			}
+		}
+	//RDebug::Printf("firstAttribute=%d lastAttribute=%d", firstAttribute, lastAttribute);
+
+	if ((lastAttribute > 0))
+		{
+		// Set the position of the last affected attribute to just after the deleted chunk.
+		iAttributes[lastAttribute].iPosition = aPos + aLength;
+
+		// Remove all but the last affected attribute. Need to keep the last affected attribute
+		// because it has an impact on the formatting of text that appears after the deleted chunk.
+		for (TInt i = (lastAttribute - 1); i >= firstAttribute; --i)
+			{
+			iAttributes.Remove(i);
+			}
+		}
+
+	// Update the positions of attributes after the block being deleted.
+	numAttributes = iAttributes.Count();
+	for (TInt i = Max(0, firstAttribute); i < numAttributes; ++i)
+		{
+		TAttributes& thisAttribute = iAttributes[i];
+		if (thisAttribute.iPosition >= aPos + aLength)
+			{
+			thisAttribute.iPosition -= aLength;
+			}
+		}
+	iBuf->Delete(aPos * 2, aLength * 2);
+	}
+
+EXPORT_C TInt CTextBuffer::Length() const
+	{
+	return iBuf->Size() / 2;
+	}
+
+EXPORT_C const TDesC& CTextBuffer::Descriptor() const
+	{
+	TPtr8 narrowPtr(iBuf->Ptr(0));
+	iPtr.Set((const TUint16 *)narrowPtr.Ptr(), narrowPtr.Length() / 2);
+	return iPtr;
+	}
+
+EXPORT_C const TDesC& CTextBuffer::Descriptor(TInt aPos, TInt aLength) const
+	{
+	TPtr8 narrowPtr(iBuf->Ptr(aPos * 2));
+	iPtr.Set((const TUint16 *)narrowPtr.Ptr(), aLength);
+	return iPtr;
+	}
+	
+EXPORT_C TPtrC8 CTextBuffer::Collapse()
+	{
+	TPtr8 narrowPtr(iBuf->Ptr(0));
+	TPtr ptr((TUint16 *)narrowPtr.Ptr(), narrowPtr.Length() / 2, narrowPtr.Length() / 2);
+	return ptr.Collapse();
+	}
+
+EXPORT_C TInt CTextBuffer::Write(RIoWriteHandle& aWriteHandle) const
+	{
+	return Write(aWriteHandle, 0, Length());
+	}
+
+EXPORT_C void CTextBuffer::Write(RIoWriteHandle& aWriteHandle, TRequestStatus& aStatus) const
+	{
+	Write(aWriteHandle, 0, Length(), aStatus);
+	}
+
+EXPORT_C TInt CTextBuffer::Write(RIoWriteHandle& aWriteHandle, TInt aPosition, TInt aLength) const
+	{
+	const TInt numAttributes = iAttributes.Count();
+	if ((aWriteHandle.AttachedToConsole() > 0) && (numAttributes > 0))
+		{
+		// Write the text buffer to the console a block at a time, updating the console's attributes at the beginning of each block.
+		TInt blockIndex = 0;
+		TInt textPos = 0;
+		TInt writeCount = 0;
+		const TDesC* block = NULL;
+		do
+			{
+			TUint attributes;
+			ConsoleAttributes::TColor foregroundColor;
+			ConsoleAttributes::TColor backgroundColor;
+			NextBlock(blockIndex, block, attributes, foregroundColor, backgroundColor);
+			if (block != NULL)
+				{
+				if ((textPos + block->Length()) > aPosition)
+					{
+					RIoConsoleWriteHandle(aWriteHandle).SetAttributes(attributes, foregroundColor, backgroundColor); // Ignore error - may not be supported.
+					TInt blockOffset = aPosition - textPos;
+					if (blockOffset < 0)
+						{
+						blockOffset = 0;
+						}
+					TPtrC toWrite(block->Mid(blockOffset, Min(aLength - writeCount, block->Length() - blockOffset)));
+					TInt err = aWriteHandle.Write(toWrite);
+					if (err)
+						{
+						return err;
+						}
+					writeCount += toWrite.Length();
+					if (writeCount == aLength)
+						{
+						break;
+						}
+					}
+				textPos += block->Length();
+				}
+			}
+			while (block != NULL);
+		}
+	else
+		{
+		return aWriteHandle.Write(Descriptor().Mid(aPosition, aLength));
+		}
+
+	return KErrNone;
+	}
+
+EXPORT_C void CTextBuffer::Write(RIoWriteHandle& aWriteHandle, TInt aPosition, TInt aLength, TRequestStatus& aStatus) const
+	{
+	const TInt numAttributes = iAttributes.Count();
+	if ((aWriteHandle.AttachedToConsole() > 0) && (numAttributes > 0))
+		{
+		// Write the text buffer asynchronously to the console a block at a time, updating the console's attributes at the beginning of each block.
+		if (!IsAdded())
+			{
+			CActiveScheduler::Add(const_cast<CTextBuffer*>(this));
+			}
+		aStatus = KRequestPending;
+		iWriteStatus = &aStatus;
+		iAsyncBlockIndex = 0;
+		iAsyncWritePos = 0;
+		iAsyncWriteStartPos = aPosition;
+		iAsyncWriteLength = aLength;
+		iConsoleWriteHandle = aWriteHandle;
+		AsyncWriteNextBlock();
+		}
+	else
+		{
+		aWriteHandle.Write(Descriptor().Mid(aPosition, aLength), aStatus);
+		}
+	}
+
+CTextBuffer::CTextBuffer()
+	: CActive(CActive::EPriorityStandard), iPtr(NULL, 0)
+	{
+	}
+
+void CTextBuffer::ConstructL(TInt aExpandSize)
+	{
+	iBuf = CBufFlat::NewL(aExpandSize);
+	iScratchBuf = HBufC::NewL(aExpandSize);
+	}
+
+void CTextBuffer::NextBlock(TInt& aBlockIndex, const TDesC*& aText, TUint& aAttributes, ConsoleAttributes::TColor& aForegroundColor, ConsoleAttributes::TColor& aBackgroundColor) const
+	{
+	if (iAttributes.Count() > 0)
+		{
+		if (aBlockIndex < iAttributes.Count())
+			{
+			const TAttributes& thisAttribute = iAttributes[aBlockIndex];
+			aAttributes = thisAttribute.iAttributes.iAttributes;
+			aForegroundColor = thisAttribute.iAttributes.iForegroundColor;
+			aBackgroundColor = thisAttribute.iAttributes.iBackgroundColor;
+			TInt length;
+			if (aBlockIndex < (iAttributes.Count() - 1))
+				{
+				length = iAttributes[aBlockIndex + 1].iPosition - thisAttribute.iPosition;
+				}
+			else
+				{
+				length = Length() - thisAttribute.iPosition;
+				}
+			aText = &Descriptor(thisAttribute.iPosition, length);
+			++aBlockIndex;
+			}
+		else
+			{
+			aText = NULL;
+			}
+		}
+	else
+		{
+		// There are no attributes, so block zero is the whole buffer.
+		ASSERT((aBlockIndex == 0) || (aBlockIndex == 1));
+		if (aBlockIndex == 0)
+			{
+			aAttributes = ConsoleAttributes::ENone;
+			aForegroundColor = ConsoleAttributes::EUnchanged;
+			aBackgroundColor = ConsoleAttributes::EUnchanged;
+			aText = &Descriptor(0, Length());
+			++aBlockIndex;
+			}
+		else
+			{
+			aText = NULL;
+			}
+		}
+	}
+
+void CTextBuffer::AsyncWriteNextBlock() const
+	{
+	const TDesC* block = NULL;
+	TUint attributes;
+	ConsoleAttributes::TColor foregroundColor;
+	ConsoleAttributes::TColor backgroundColor;
+	NextBlock(iAsyncBlockIndex, block, attributes, foregroundColor, backgroundColor);
+	if (block != NULL)
+		{
+		if ((iAsyncWritePos + block->Length()) > iAsyncWriteStartPos)
+			{
+			iConsoleWriteHandle.SetAttributes(attributes, foregroundColor, backgroundColor); // Ignore error - may not be supported.
+			TInt blockOffset = iAsyncWriteStartPos - iAsyncWritePos;
+			if (blockOffset < 0)
+				{
+				blockOffset = 0;
+				}
+			iAsyncWritePtr.Set(block->Mid(blockOffset, Min(iAsyncWriteLength, block->Length() - blockOffset)));
+			iAsyncWriteLength -= iAsyncWritePtr.Length();
+			iConsoleWriteHandle.Write(iAsyncWritePtr, const_cast<TRequestStatus&>(iStatus));
+			const_cast<CTextBuffer*>(this)->SetActive();
+			}
+		iAsyncWritePos += block->Length();
+		}
+	else
+		{
+		User::RequestComplete(iWriteStatus, KErrNone);
+		}
+	}
+
+void CTextBuffer::RunL()
+	{
+	if (iStatus.Int() || (iAsyncWriteLength <= 0))
+		{
+		User::RequestComplete(iWriteStatus, iStatus.Int());
+		}
+	else
+		{
+		AsyncWriteNextBlock();
+		}
+	}
+
+void CTextBuffer::DoCancel()
+	{
+	iConsoleWriteHandle.WriteCancel();
+	}
+
+CTextBuffer::TAttributes::TAttributes(TInt aPosition, TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor)
+	: iPosition(aPosition), iAttributes(aAttributes, aForegroundColor, aBackgroundColor)
+	{
+	}
+
+TBool CTextBuffer::TAttributes::Matches(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor) const
+	{
+	return ((aAttributes == iAttributes.iAttributes) && (aForegroundColor == iAttributes.iForegroundColor) && (aBackgroundColor == iAttributes.iBackgroundColor));
+	}
+
+
+//
+// CTextFormatter.
+//
+
+EXPORT_C CTextFormatter* CTextFormatter::NewL(TInt aAvailableWidth)
+	{
+	CTextFormatter* self = CTextFormatter::NewLC(aAvailableWidth);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CTextFormatter* CTextFormatter::NewLC(TInt aAvailableWidth)
+	{
+	CTextFormatter* self = new(ELeave) CTextFormatter(aAvailableWidth);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+EXPORT_C CTextFormatter* CTextFormatter::NewL(RIoConsoleWriteHandle& aConsoleWriteHandle)
+	{
+	CTextFormatter* self = CTextFormatter::NewLC(aConsoleWriteHandle);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CTextFormatter* CTextFormatter::NewLC(RIoConsoleWriteHandle& aConsoleWriteHandle)
+	{
+	TSize size;
+	if (aConsoleWriteHandle.AttachedToConsole())
+		{
+		User::LeaveIfError(aConsoleWriteHandle.GetScreenSize(size));
+		}
+	else
+		{
+		size.iWidth = 80;
+		}
+	CTextFormatter* self = CTextFormatter::NewLC(size.iWidth);
+	self->iWriteHandle = &aConsoleWriteHandle;
+	self->iAttributesSupported = (aConsoleWriteHandle.SetAttributes(0) == KErrNone);
+	return self;
+	}
+
+EXPORT_C CTextFormatter::~CTextFormatter()
+	{
+	}
+
+CTextFormatter::CTextFormatter(TInt aAvailableWidth)
+	: iAvailableWidth(aAvailableWidth - 1)
+	{
+	}
+
+void CTextFormatter::ConstructL()
+	{
+	CTextBuffer::ConstructL(0x100);
+	}
+
+EXPORT_C void CTextFormatter::WrapL(TInt aIndent, const TDesC& aText)
+	{
+	AppendSpacesL(aIndent);
+	WrapL(aIndent, aIndent, aText);
+	}
+
+EXPORT_C void CTextFormatter::WrapL(TInt aStartPosition, TInt aIndent, const TDesC& aText)
+	{
+	TUint originalAttributes = ConsoleAttributes::ENone;
+	ConsoleAttributes::TColor foregroundColor = ConsoleAttributes::EUnchanged;
+	ConsoleAttributes::TColor backgroundColor = ConsoleAttributes::EUnchanged;
+	if (iAttributesSupported)
+		{
+		GetCurrentAttributes(originalAttributes, foregroundColor, backgroundColor);
+		}
+
+	CTextBuffer* buffer = CTextBuffer::NewLC(0x100);
+	DecodeInteriorPodSequencesL(aText, *buffer);
+	TLex lex(buffer->Descriptor());
+	TInt linePos = aStartPosition;
+	while (!lex.Eos())
+		{
+		lex.Mark();
+		lex.SkipSpace();
+		TPtrC whiteSpace(lex.MarkedToken());
+		if (whiteSpace.Length() > 0)
+			{
+			TInt newLinePos;
+			do
+				{
+				newLinePos = whiteSpace.Find(KNewLine);
+				if (newLinePos >= 0)
+					{
+					AppendSpacesL(iAvailableWidth - linePos - 1);
+					AppendL(KNewLine);
+					AppendSpacesL(aIndent);
+					linePos = aIndent;
+					whiteSpace.Set(whiteSpace.Mid(newLinePos + KNewLine().Length()));
+					}
+				}
+				while (newLinePos >= 0);
+
+			if (iAvailableWidth < whiteSpace.Length())
+				{
+				AppendSpacesL(iAvailableWidth - linePos - 1);
+				AppendL(KNewLine);
+				AppendSpacesL(aIndent);
+				linePos = aIndent;
+				}
+			else
+				{
+				AppendL(whiteSpace);
+				linePos += whiteSpace.Length();
+				}
+			}
+
+		lex.Mark();
+		lex.SkipCharacters();
+		TPtrC word(lex.MarkedToken());
+		const TInt wordLength = word.Length();
+		if (wordLength > 0)
+			{
+			if ((linePos + wordLength + KNewLine().Length()) > iAvailableWidth)
+				{
+				AppendL(KNewLine);
+				AppendSpacesL(aIndent);
+				linePos = aIndent;
+				}
+
+			if (iAttributesSupported)
+				{
+				for (TInt i = 0; i < wordLength; ++i)
+					{
+					TUint attributes;
+					buffer->GetAttributes(lex.Offset() - wordLength + i, attributes, foregroundColor, backgroundColor);
+					SetAttributesL(originalAttributes | attributes, foregroundColor, backgroundColor);
+					AppendL(word[i]);
+					}
+				}
+			else
+				{
+				AppendL(word);
+				}
+			linePos += wordLength;
+			}
+		}
+
+	CleanupStack::PopAndDestroy(buffer);
+	SetAttributesL(originalAttributes, foregroundColor, backgroundColor);
+	}
+
+EXPORT_C void CTextFormatter::TabulateL(TInt aIndent, TInt aGap, const TDesC& aText)
+	{
+	TabulateL(aIndent, aGap, aText, EWrapLastColumn);
+	}
+
+EXPORT_C void CTextFormatter::TabulateL(TInt aIndent, TInt aGap, const TDesC& aText, TTabMode aMode)
+	{
+	CTextBuffer* scratchBuffer = NULL;
+	RArray<TInt> columnWidths;
+	CleanupClosePushL(columnWidths);
+	TLex lineLexer(aText);
+
+	// Find column widths.
+	TPtrC line;
+	while (NextLine(lineLexer, line))
+		{
+		TLex columnLexer(line);
+		TInt col = 0;
+		TPtrC column;
+		while (NextColumn(columnLexer, column))
+			{
+			if (col >= columnWidths.Count())
+				{
+				User::LeaveIfError(columnWidths.Append(aGap));
+				}
+			TInt thisColumnWidth = ActualLength(column);
+			if (columnWidths[col] < (thisColumnWidth + aGap))
+				{
+				columnWidths[col] = (thisColumnWidth + aGap);
+				}
+			++col;
+			}
+		}
+
+	const TInt numCols = columnWidths.Count();
+
+	if (numCols == 0)
+		{
+		// No columns found, so just copy aText directly.
+		AppendL(aText);
+		CleanupStack::PopAndDestroy(&columnWidths);
+		return;
+		}
+
+	if (aMode == EWrapLastColumn)
+		{
+		// Find the widest of all but the last column.
+		TInt sum = aIndent;
+		for (TInt i = 0; i < (numCols - 1); ++i)
+			{
+			sum += columnWidths[i];
+			}
+		TInt remainingSpace = iAvailableWidth - sum;
+		if (remainingSpace < 0)
+			{
+			// If you hit this, it means that the text cannot be columnised because the columns preceding the last one take up more space than the overall.
+			User::Leave(KErrTooBig); // Let's go for something marginally more descriptive than KErrGeneral
+			}
+		// Assign the remaining space to the last column (which will be wrapped).
+		columnWidths[numCols - 1] = remainingSpace; 
+		}
+	else if (aMode == ETruncateLongestColumn)
+		{
+		// Find the total width of all the columns.
+		TInt sum = aIndent;
+		for (TInt i = 0; i < numCols; ++i)
+			{
+			sum += columnWidths[i];
+			}
+		TInt excess = iAvailableWidth - sum;
+		if (excess < 0)
+			{
+			// Not enough space, so steal from the widest column until there is.
+			while (excess < 0)
+				{
+				TInt widestColumn = -1;
+				TInt widestColumnWidth = 0;
+				for (TInt i = 0; i < numCols; ++i)
+					{
+					if (columnWidths[i] > widestColumnWidth)
+						{
+						widestColumnWidth = columnWidths[i];
+						widestColumn = i;
+						}
+					}
+				if (widestColumn < 0)
+					{
+					User::Leave(KErrGeneral);
+					}
+				--columnWidths[widestColumn];
+				++excess;
+				}
+			}
+		else
+			{
+			// Assign execess to the last column.
+			columnWidths[numCols - 1] += excess; 
+			}
+		}
+	else if (aMode == EIgnoreAvailableWidth)
+		{
+		// just use the column widths we've already worked out, no matter if they're too wide.
+		}
+	else
+		{
+		ASSERT(EFalse);
+		}
+
+	// Write formatted text to the buffer.
+	lineLexer = TLex(aText);
+	TInt linePos = 0;
+	while (NextLine(lineLexer, line))
+		{
+		AppendSpacesL(aIndent);
+		linePos += aIndent;
+		TLex columnLexer(line);
+		TInt col = 0;
+		TPtrC column;
+		while (NextColumn(columnLexer, column))
+			{
+			TBool isLastColumn(col == (numCols - 1));
+			const TInt columnWidth = columnWidths[col];
+			if ((aMode == ETruncateLongestColumn) || !isLastColumn)
+				{
+				if (scratchBuffer == NULL)
+					{
+					scratchBuffer = CTextBuffer::NewLC(0x100);
+					}
+				else
+					{
+					scratchBuffer->Zero();
+					}
+				DecodeInteriorPodSequencesL(column, *scratchBuffer);
+				TInt availableWidth = columnWidth;
+				if (!isLastColumn)
+					{
+					availableWidth -= aGap;
+					}
+				if (scratchBuffer->Descriptor().Length() > availableWidth)
+					{
+					scratchBuffer->Delete(availableWidth, scratchBuffer->Descriptor().Length() - availableWidth);
+					}
+				AppendL(*scratchBuffer);
+				AppendSpacesL(columnWidth - scratchBuffer->Descriptor().Length());
+				linePos += columnWidth;
+				}
+			else if (aMode == EIgnoreAvailableWidth)
+				{
+				AppendL(column);
+				if (!isLastColumn)
+					{
+					AppendSpacesL(columnWidth - column.Length());
+					}
+				linePos += columnWidth;
+				}
+			else
+				{
+				WrapL(linePos, linePos, column);
+				}
+			++col;
+			}
+		AppendL(KNewLine);
+		linePos = 0;
+		}
+
+	if (scratchBuffer)
+		{
+		CleanupStack::PopAndDestroy(scratchBuffer);
+		}
+	CleanupStack::PopAndDestroy(&columnWidths);
+	}
+
+EXPORT_C void CTextFormatter::ColumnizeL(TInt aIndent, TInt aGap, const TDesC& aText)
+	{
+	// Store the tab delimited text as an array of TPtrCs.
+	RArray<TPtrC> items;
+	CleanupClosePushL(items);
+	TLex lex(aText);
+	TPtrC column;
+	while (NextColumn(lex, column))
+		{
+		User::LeaveIfError(items.Append(column));
+		}
+	ColumnizeL(aIndent, aGap, items.Array());
+	CleanupStack::PopAndDestroy(1, &items);
+	}
+
+EXPORT_C void CTextFormatter::ColumnizeL(TInt aIndent, TInt aGap, const TArray<TPtrC>& aItems)
+	{
+	// Lays out tab delimited data as a set of columns that read like a news paper
+	// (i.e. starting with the left most column, you read down to the bottom of it
+	// and then start reading the next column from the top, etc.).
+
+	// Determine the smallest number of rows that allows all the data to fit
+	// the available horizontal space. The algorithm works by iteratively increasing
+	// the number of rows from one until a fit is found.
+	const TInt numItems = aItems.Count();
+	RArray<TInt> columnWidths;
+	CleanupClosePushL(columnWidths);
+	TInt numRows = 0;
+	TBool fits(EFalse);
+	while (!fits)
+		{
+		++numRows;
+		columnWidths.Reset();
+		TInt requiredWidth = aIndent;
+		TInt col = 0;
+		TInt i = 0;
+		while (i < numItems)
+			{
+			for (TInt row = 0; row < numRows; ++row)
+				{
+				if (columnWidths.Count() <= col)
+					{
+					User::LeaveIfError(columnWidths.Append(0));
+					}
+				TInt thisItemWidth = ActualLength(aItems[i]);
+				if (thisItemWidth > columnWidths[col])
+					{
+					columnWidths[col] = thisItemWidth;
+					}
+				if (++i >= numItems)
+					{
+					break;
+					}
+				}
+			requiredWidth += columnWidths[col];
+			if ((requiredWidth + aGap) > iAvailableWidth)
+				{
+				if ((requiredWidth + KNewLine().Length()) > iAvailableWidth)
+					{
+					if (col > 0)
+						{
+						// Not enough space with this number of rows, so try another row.
+						i = 0;
+						break;
+						}
+					else
+						{
+						// Not enough space even with just one column. Lay out as a single column anyway and accept ugly wrapping by the console.
+						CleanupStack::PopAndDestroy(1, &columnWidths);
+						for (TInt i = 0; i < numItems; ++i)
+							{
+							AppendSpacesL(aIndent);
+							AppendL(aItems[i]);
+							AppendL(KNewLine);
+							}
+						return;
+						}
+					}
+				else
+					{
+					requiredWidth += KNewLine().Length();
+					}
+				}
+			else
+				{
+				requiredWidth += aGap;
+				}
+			++col;
+			}
+		if (i >= numItems)
+			{
+			fits = ETrue;
+			}
+		}
+
+	// Layout the columns.
+	const TInt numCols = columnWidths.Count();
+	for (TInt row = 0; row < numRows; ++row)
+		{
+		AppendSpacesL(aIndent);
+		for (TInt col = 0; col < numCols; ++col)
+			{
+			TInt index = (numRows * col) + row;
+			if (index < numItems)
+				{
+				TPtrC item(aItems[index]);
+				DoAppendPodL(item);
+				TInt gap = (col == (numCols - 1)) ? 0 : aGap;
+				AppendSpacesL((columnWidths[col] + gap) - ActualLength(item));
+				}
+			}
+		AppendL(KNewLine);
+		}
+
+	CleanupStack::PopAndDestroy(1, &columnWidths);
+	}
+
+EXPORT_C void CTextFormatter::AppendPodL(const TDesC& aPod)
+	{
+	TPodFormatter podFormatter(*this);
+	podFormatter.FormatL(aPod);
+	}
+
+EXPORT_C TInt CTextFormatter::Write()
+	{
+	return CTextBuffer::Write(*iWriteHandle);
+	}
+
+void CTextFormatter::DoAppendPodL(const TDesC& aPod)
+	{
+	DecodeInteriorPodSequencesL(aPod, *this);
+	}
+
+void CTextFormatter::DecodeInteriorPodSequencesL(const TDesC& aPod, CTextBuffer& aBuffer) const
+	{
+	TPodLexer lexer(aPod);
+	TBool eop(EFalse);
+	TBool eos(EFalse);
+
+	TUint originalAttributes = ConsoleAttributes::ENone;
+	ConsoleAttributes::TColor foregroundColor = ConsoleAttributes::EUnchanged;
+	ConsoleAttributes::TColor backgroundColor = ConsoleAttributes::EUnchanged;
+	if (iAttributesSupported)
+		{
+		aBuffer.GetCurrentAttributes(originalAttributes, foregroundColor, backgroundColor);
+		}
+	TUint currentAttributes = originalAttributes;
+
+	while (!eos)
+		{
+		TPtrC token;
+		TPodLexer::TTokenType tokenType;
+		TUint attributes;
+		lexer.NextTokenL(token, tokenType, attributes, eop, eos);
+
+		switch (tokenType)
+			{
+			case TPodLexer::EAttributePush:
+			case TPodLexer::EAttributePop:
+				if (!iAttributesSupported && (attributes & TPodLexer::EBold))
+					{
+					aBuffer.AppendL('*');
+					}
+				else if (!iAttributesSupported && (attributes & TPodLexer::EItalic))
+					{
+					aBuffer.AppendL('\'');
+					}
+				else if ((!iAttributesSupported && (attributes & TPodLexer::EFileName)) || (attributes & TPodLexer::TPodLexer::ECode))
+					{
+					aBuffer.AppendL('"');
+					}
+				break;
+			case TPodLexer::ELink:
+				{
+				TInt pos = token.Locate('|');
+				if (pos >= 0)
+					{
+					token.Set(token.Left(pos));
+					}
+				}
+				// Deliberate fall through.
+			case TPodLexer::ETextBlock:
+			case TPodLexer::ECodeBlock:
+			case TPodLexer::EIndexEntry:
+				if (iAttributesSupported)
+					{
+					if ((attributes == 0) || (attributes & (TPodLexer::ENull | TPodLexer::ECode)))
+						{
+						currentAttributes = originalAttributes;
+						}
+					if (attributes & (TPodLexer::EBold | TPodLexer::EItalic | TPodLexer::EFileName))
+						{
+						currentAttributes |= ConsoleAttributes::EBold;
+						}
+					aBuffer.SetAttributesL(currentAttributes);
+					}
+				aBuffer.AppendL(token);
+				break;
+			default:
+				ASSERT(EFalse);
+			}
+		}
+
+	if (iAttributesSupported && (currentAttributes != originalAttributes))
+		{
+		aBuffer.SetAttributesL(originalAttributes);
+		}
+	}
+
+EXPORT_C void CTextFormatter::Zero()
+	{
+	CTextBuffer::Zero();
+	}
+
+EXPORT_C void CTextFormatter::Reset()
+	{
+	CTextBuffer::Reset();
+	}
+
+EXPORT_C void CTextFormatter::ResetText()
+	{
+	CTextBuffer::ResetText();
+	}
+
+TBool CTextFormatter::NextColumn(TLex& aLex, TPtrC& aPtr) const
+	{
+	aLex.Mark();
+	while (!aLex.Eos())
+		{
+		if (aLex.Get() == '\t')
+			{
+			aLex.UnGet();
+			aPtr.Set(aLex.MarkedToken());
+			aLex.Get();
+			return ETrue;
+			}
+		}
+	if (aLex.TokenLength() > 0)
+		{
+		aPtr.Set(aLex.MarkedToken());
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+TBool CTextFormatter::NextLine(TLex& aLex, TPtrC& aPtr) const
+	{
+	aLex.Mark();
+	while (!aLex.Eos())
+		{
+		TChar ch = aLex.Get();
+		if (ch == '\r')
+			{
+			if (aLex.Get() == '\n')
+				{
+				aLex.UnGet();
+				aLex.UnGet();
+				aPtr.Set(aLex.MarkedToken());
+				aLex.Get();
+				aLex.Get();
+				return ETrue;
+				}
+			else
+				{
+				aLex.UnGet();
+				}
+			}
+		}
+	if (aLex.TokenLength() > 0)
+		{
+		aPtr.Set(aLex.MarkedToken());
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+TInt CTextFormatter::ActualLength(const TDesC& aPod) const
+	{
+	CTextBuffer* buffer = CTextBuffer::NewLC(0x100);
+	DecodeInteriorPodSequencesL(aPod, *buffer);
+	TInt length = buffer->Descriptor().Length();
+	CleanupStack::PopAndDestroy(buffer);
+	return length;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/data/iosrv.idf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+# iosrv.idf
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+console			string
+console.name		Console
+console.description	Console implementation DLL name
+console.default		defcons.dll
+
+console_size_adjustment 		string
+console_size_adjustment.name		Console size adjustment
+console_size_adjustment.description	Console size adjustment, in format 'x,y'
+
+console_size_detect			boolean
+console_size_detect.name		Autodetect console size
+console_size_detect.description		Automatically detect the size of consoles that are created by the IO server
+console_size_detect.default		true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/data/iosrv.ini.bluetooth	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+#!iniedit -i \resource\iosrv.idf
+# iosrv.ini.bluetooth
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+console			vt100btcons.dll
+console_size_adjustment	0,0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/data/iosrv.ini.econs	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+#!iniedit -i \resource\iosrv.idf
+# iosrv.ini.econs
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+console			econs.dll
+console_size_detect	1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/data/iosrv.ini.econs_fb	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+#!iniedit -i \resource\iosrv.idf
+# iosrv.ini.econs_fb
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+console			econs_fb.dll
+console_size_detect	1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/data/iosrv.ini.eka1	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+#!iniedit -i \resource\iosrv.idf
+# iosrv.ini.eka1
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+console			rcons.dll
+console_size_adjustment	0,0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/data/iosrv.ini.eka2	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+#!iniedit -i \resource\iosrv.idf
+# iosrv.ini.eka2
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+console			econseik.dll
+console_size_detect	1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/data/iosrv.ini.noautodetect	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+#!iniedit -i \resource\iosrv.idf
+# iosrv.ini.noautodetect
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+console_size_detect false
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/data/iosrv.ini.remote	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+#!iniedit -i \resource\iosrv.idf
+# iosrv.ini.remote
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+console			rcons.dll
+console_size_adjustment	0,0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/eabi/iocliu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,617 @@
+EXPORTS
+	_ZN10RIoConsole4OpenER10RIoSessionR9RIoHandle @ 1 NONAME
+	_ZN10RIoConsole5OpenLER10RIoSessionR9RIoHandle @ 2 NONAME
+	_ZN10RIoConsole6CreateER10RIoSessionRK7TDesC16RK5TSizej @ 3 NONAME
+	_ZN10RIoConsole6CreateER10RIoSessionRK7TDesC16RS_S4_RK5TSizej @ 4 NONAME
+	_ZN10RIoConsole6CreateER10RIoSessionRK7TDesC16S4_RK5TSizej @ 5 NONAME
+	_ZN10RIoConsole7CreateLER10RIoSessionRK7TDesC16RK5TSizej @ 6 NONAME
+	_ZN10RIoConsole7CreateLER10RIoSessionRK7TDesC16RS_S4_RK5TSizej @ 7 NONAME
+	_ZN10RIoConsole7CreateLER10RIoSessionRK7TDesC16S4_RK5TSizej @ 8 NONAME
+	_ZN10RIoSession13SetObjectNameEiRK7TDesC16 @ 9 NONAME
+	_ZN10RIoSession14FindNextHandleERiR4TBufILi128EE @ 10 NONAME
+	_ZN10RIoSession14SetObjectNameLEiRK7TDesC16 @ 11 NONAME
+	_ZN10RIoSession15FindFirstHandleEN9RIoHandle5TTypeERK7TDesC16RiR4TBufILi128EE @ 12 NONAME
+	_ZN10RIoSession7ConnectEv @ 13 NONAME
+	_ZN10RIoSession8ConnectLEv @ 14 NONAME
+	_ZN11RIoEndPoint23SetForegroundReadHandleER13RIoReadHandle @ 15 NONAME
+	_ZN11RIoEndPoint24SetForegroundReadHandleLER13RIoReadHandle @ 16 NONAME
+	_ZN11RIoEndPoint6AttachER13RIoReadHandleNS_9TReadModeE @ 17 NONAME
+	_ZN11RIoEndPoint6AttachER14RIoWriteHandle @ 18 NONAME
+	_ZN11RIoEndPoint7AttachLER13RIoReadHandleNS_9TReadModeE @ 19 NONAME
+	_ZN11RIoEndPoint7AttachLER14RIoWriteHandle @ 20 NONAME
+	_ZN11RIoEndPointC1Ev @ 21 NONAME
+	_ZN11RIoEndPointC2Ev @ 22 NONAME
+	_ZN13RIoReadHandle10DuplicateLERS_ @ 23 NONAME
+	_ZN13RIoReadHandle10ReadCancelEv @ 24 NONAME
+	_ZN13RIoReadHandle11SetReadModeENS_9TReadModeE @ 25 NONAME
+	_ZN13RIoReadHandle12NotifyChangeER8TPckgBufIjER14TRequestStatus @ 26 NONAME
+	_ZN13RIoReadHandle12SetReadModeLENS_9TReadModeE @ 27 NONAME
+	_ZN13RIoReadHandle15SetToForegroundEv @ 28 NONAME
+	_ZN13RIoReadHandle16SetLineSeparatorERK7TDesC16 @ 29 NONAME
+	_ZN13RIoReadHandle16SetToForegroundLEv @ 30 NONAME
+	_ZN13RIoReadHandle17SetLineSeparatorLERK7TDesC16 @ 31 NONAME
+	_ZN13RIoReadHandle18CancelNotifyChangeEv @ 32 NONAME
+	_ZN13RIoReadHandle4OpenER10RIoSession @ 33 NONAME
+	_ZN13RIoReadHandle4OpenER10RIoSession9TThreadId @ 34 NONAME
+	_ZN13RIoReadHandle4ReadER6TDes16 @ 35 NONAME
+	_ZN13RIoReadHandle4ReadER6TDes16R14TRequestStatus @ 36 NONAME
+	_ZN13RIoReadHandle5OpenLER10RIoSession @ 37 NONAME
+	_ZN13RIoReadHandle5OpenLER10RIoSession9TThreadId @ 38 NONAME
+	_ZN13RIoReadHandle5ReadLER6TDes16 @ 39 NONAME
+	_ZN13RIoReadHandle6CreateER10RIoSession @ 40 NONAME
+	_ZN13RIoReadHandle7CreateLER10RIoSession @ 41 NONAME
+	_ZN13RIoReadHandle9DuplicateERS_ @ 42 NONAME
+	_ZN14RIoWriteHandle10DuplicateLERS_ @ 43 NONAME
+	_ZN14RIoWriteHandle11WriteCancelEv @ 44 NONAME
+	_ZN14RIoWriteHandle4OpenER10RIoSession @ 45 NONAME
+	_ZN14RIoWriteHandle4OpenER10RIoSession9TThreadId @ 46 NONAME
+	_ZN14RIoWriteHandle5OpenLER10RIoSession @ 47 NONAME
+	_ZN14RIoWriteHandle5OpenLER10RIoSession9TThreadId @ 48 NONAME
+	_ZN14RIoWriteHandle5WriteERK7TDesC16 @ 49 NONAME
+	_ZN14RIoWriteHandle5WriteERK7TDesC16R14TRequestStatus @ 50 NONAME
+	_ZN14RIoWriteHandle6CreateER10RIoSession @ 51 NONAME
+	_ZN14RIoWriteHandle6WriteLERK7TDesC16 @ 52 NONAME
+	_ZN14RIoWriteHandle7CreateLER10RIoSession @ 53 NONAME
+	_ZN14RIoWriteHandle9DuplicateERS_ @ 54 NONAME
+	_ZN18RIoReadWriteHandle20SetUnderlyingConsoleER10RIoConsole @ 55 NONAME
+	_ZN18RIoReadWriteHandle21SetUnderlyingConsoleLER10RIoConsole @ 56 NONAME
+	_ZN18RIoReadWriteHandle7SetModeENS_5TModeE @ 57 NONAME
+	_ZN18RIoReadWriteHandle8SetModeLENS_5TModeE @ 58 NONAME
+	_ZN18RIoReadWriteHandle8SetOwnerE9TThreadId @ 59 NONAME
+	_ZN18RIoReadWriteHandle9SetOwnerLE9TThreadId @ 60 NONAME
+	_ZN20RIoConsoleReadHandle10CaptureKeyEjjj @ 61 NONAME
+	_ZN20RIoConsoleReadHandle10WaitForKeyER14TRequestStatus @ 62 NONAME
+	_ZN20RIoConsoleReadHandle11CaptureKeyLEjjj @ 63 NONAME
+	_ZN20RIoConsoleReadHandle14CaptureAllKeysEv @ 64 NONAME
+	_ZN20RIoConsoleReadHandle15CaptureAllKeysLEv @ 65 NONAME
+	_ZN20RIoConsoleReadHandle16CancelCaptureKeyEjjj @ 66 NONAME
+	_ZN20RIoConsoleReadHandle16WaitForKeyCancelEv @ 67 NONAME
+	_ZN20RIoConsoleReadHandle20CancelCaptureAllKeysEv @ 68 NONAME
+	_ZN20RIoConsoleReadHandle7ReadKeyEv @ 69 NONAME
+	_ZN20RIoConsoleReadHandleC1ER13RIoReadHandle @ 70 NONAME
+	_ZN20RIoConsoleReadHandleC1Ev @ 71 NONAME
+	_ZN20RIoConsoleReadHandleC2ER13RIoReadHandle @ 72 NONAME
+	_ZN20RIoConsoleReadHandleC2Ev @ 73 NONAME
+	_ZN20RIoConsoleReadHandleaSER13RIoReadHandle @ 74 NONAME
+	_ZN20RIoPersistentConsole10GetCreatorER9TThreadId @ 75 NONAME
+	_ZN20RIoPersistentConsole10OpenByNameER10RIoSessionRK7TDesC16 @ 76 NONAME
+	_ZN20RIoPersistentConsole11GetCreatorLEv @ 77 NONAME
+	_ZN20RIoPersistentConsole11OpenByNameLER10RIoSessionRK7TDesC16 @ 78 NONAME
+	_ZN20RIoPersistentConsole12AttachReaderER11RIoEndPointNS_15TCloseBehaviourE @ 79 NONAME
+	_ZN20RIoPersistentConsole12AttachWriterER11RIoEndPointNS_15TCloseBehaviourE @ 80 NONAME
+	_ZN20RIoPersistentConsole12DetachReaderEv @ 81 NONAME
+	_ZN20RIoPersistentConsole12DetachWriterEv @ 82 NONAME
+	_ZN20RIoPersistentConsole13AttachReaderLER11RIoEndPointNS_15TCloseBehaviourE @ 83 NONAME
+	_ZN20RIoPersistentConsole13AttachWriterLER11RIoEndPointNS_15TCloseBehaviourE @ 84 NONAME
+	_ZN20RIoPersistentConsole18NotifyReaderDetachER14TRequestStatus @ 85 NONAME
+	_ZN20RIoPersistentConsole18NotifyWriterDetachER14TRequestStatus @ 86 NONAME
+	_ZN20RIoPersistentConsole24CancelNotifyReaderDetachER14TRequestStatus @ 87 NONAME
+	_ZN20RIoPersistentConsole24CancelNotifyWriterDetachER14TRequestStatus @ 88 NONAME
+	_ZN20RIoPersistentConsole31GetAttachedReaderAndWriterNamesER4TBufILi128EES2_ @ 89 NONAME
+	_ZN20RIoPersistentConsole32GetAttachedReaderAndWriterNamesLER4TBufILi128EES2_ @ 90 NONAME
+	_ZN20RIoPersistentConsole6CreateER10RIoSessionRK7TDesC16S4_ @ 91 NONAME
+	_ZN20RIoPersistentConsole7CreateLER10RIoSessionRK7TDesC16S4_ @ 92 NONAME
+	_ZN21RIoConsoleWriteHandle11ClearScreenEv @ 93 NONAME
+	_ZN21RIoConsoleWriteHandle12ClearScreenLEv @ 94 NONAME
+	_ZN21RIoConsoleWriteHandle13SetAttributesEjN17ConsoleAttributes6TColorES1_ @ 95 NONAME
+	_ZN21RIoConsoleWriteHandle14SetAttributesLEjN17ConsoleAttributes6TColorES1_ @ 96 NONAME
+	_ZN21RIoConsoleWriteHandle15SetCursorHeightEi @ 97 NONAME
+	_ZN21RIoConsoleWriteHandle15SetCursorPosAbsERK6TPoint @ 98 NONAME
+	_ZN21RIoConsoleWriteHandle15SetCursorPosRelERK6TPoint @ 99 NONAME
+	_ZN21RIoConsoleWriteHandle16ClearToEndOfLineEv @ 100 NONAME
+	_ZN21RIoConsoleWriteHandle16SetCursorHeightLEi @ 101 NONAME
+	_ZN21RIoConsoleWriteHandle16SetCursorPosAbsLERK6TPoint @ 102 NONAME
+	_ZN21RIoConsoleWriteHandle16SetCursorPosRelLERK6TPoint @ 103 NONAME
+	_ZN21RIoConsoleWriteHandle17ClearToEndOfLineLEv @ 104 NONAME
+	_ZN21RIoConsoleWriteHandle8SetTitleERK7TDesC16 @ 105 NONAME
+	_ZN21RIoConsoleWriteHandle9SetTitleLERK7TDesC16 @ 106 NONAME
+	_ZN21RIoConsoleWriteHandleC1ER14RIoWriteHandle @ 107 NONAME
+	_ZN21RIoConsoleWriteHandleC1Ev @ 108 NONAME
+	_ZN21RIoConsoleWriteHandleC2ER14RIoWriteHandle @ 109 NONAME
+	_ZN21RIoConsoleWriteHandleC2Ev @ 110 NONAME
+	_ZN21RIoConsoleWriteHandleaSER14RIoWriteHandle @ 111 NONAME
+	_ZN7IoUtils10NewConsoleEv @ 112 NONAME
+	_ZN7IoUtils10PrintErrorEi11TRefByValueIK7TDesC16Ez @ 113 NONAME
+	_ZN7IoUtils10TFileName213MakeAbsoluteLER3RFs @ 114 NONAME
+	_ZN7IoUtils10TFileName213MakeAbsoluteLERKS0_ @ 115 NONAME
+	_ZN7IoUtils10TFileName215SetIsDirectoryLEv @ 116 NONAME
+	_ZN7IoUtils10TFileName216AppendComponentLERK6TEntry @ 117 NONAME
+	_ZN7IoUtils10TFileName216AppendComponentLERK7TDesC16NS0_5TTypeE @ 118 NONAME
+	_ZN7IoUtils10TFileName216AppendComponentLERKS0_ @ 119 NONAME
+	_ZN7IoUtils10TFileName24SetLERKS0_ @ 120 NONAME
+	_ZN7IoUtils10TFileName26SplitLER6RArrayIS0_E @ 121 NONAME
+	_ZN7IoUtils10TFileName28FindFileER3RFs @ 122 NONAME
+	_ZN7IoUtils10TFileName28PrependLERKS0_ @ 123 NONAME
+	_ZN7IoUtils10TFileName28SetTypeLENS0_5TTypeE @ 124 NONAME
+	_ZN7IoUtils10TFileName28UnsplitLERK6RArrayIS0_E @ 125 NONAME
+	_ZN7IoUtils10TFileName29FindFileLER3RFs @ 126 NONAME
+	_ZN7IoUtils10TFileName2C1ENS0_5TTypeE @ 127 NONAME
+	_ZN7IoUtils10TFileName2C1ERK7TDesC16 @ 128 NONAME
+	_ZN7IoUtils10TFileName2C1ERK7TDesC16NS0_5TTypeE @ 129 NONAME
+	_ZN7IoUtils10TFileName2C1Ev @ 130 NONAME
+	_ZN7IoUtils10TFileName2C2ENS0_5TTypeE @ 131 NONAME
+	_ZN7IoUtils10TFileName2C2ERK7TDesC16 @ 132 NONAME
+	_ZN7IoUtils10TFileName2C2ERK7TDesC16NS0_5TTypeE @ 133 NONAME
+	_ZN7IoUtils10TFileName2C2Ev @ 134 NONAME
+	_ZN7IoUtils11CClientBase10ArgumentsLERNS_20RCommandArgumentListE @ 135 NONAME
+	_ZN7IoUtils11CClientBase11HandleLeaveEi @ 136 NONAME
+	_ZN7IoUtils11CClientBase6DoRunLEv @ 137 NONAME
+	_ZN7IoUtils11CClientBaseC2EjRK7TDesC16S3_S3_ @ 138 NONAME
+	_ZN7IoUtils11CClientBaseD0Ev @ 139 NONAME
+	_ZN7IoUtils11CClientBaseD1Ev @ 140 NONAME
+	_ZN7IoUtils11CClientBaseD2Ev @ 141 NONAME
+	_ZN7IoUtils11CServerBase10ReportListERKNS_16TServerCommandIdE11TRefByValueIK6TDesC8ERSt9__va_list @ 142 NONAME
+	_ZN7IoUtils11CServerBase10ReportListERKNS_16TServerCommandIdE11TRefByValueIK7TDesC16ERSt9__va_list @ 143 NONAME
+	_ZN7IoUtils11CServerBase11ReportErrorERKNS_16TServerCommandIdEi11TRefByValueIK7TDesC16Ez @ 144 NONAME
+	_ZN7IoUtils11CServerBase13LeoHandleLineERK7TDesC16 @ 145 NONAME
+	_ZN7IoUtils11CServerBase13ReportWarningERKNS_16TServerCommandIdE11TRefByValueIK7TDesC16Ez @ 146 NONAME
+	_ZN7IoUtils11CServerBase14BaseConstructLEv @ 147 NONAME
+	_ZN7IoUtils11CServerBase14PrintErrorListEi11TRefByValueIK7TDesC16ERSt9__va_list @ 148 NONAME
+	_ZN7IoUtils11CServerBase15ReportErrorListERKNS_16TServerCommandIdEi11TRefByValueIK7TDesC16ERSt9__va_list @ 149 NONAME
+	_ZN7IoUtils11CServerBase16PrintWarningListE11TRefByValueIK7TDesC16ERSt9__va_list @ 150 NONAME
+	_ZN7IoUtils11CServerBase17ReportWarningListERKNS_16TServerCommandIdE11TRefByValueIK7TDesC16ERSt9__va_list @ 151 NONAME
+	_ZN7IoUtils11CServerBase19CheckNewConsoleLineEv @ 152 NONAME
+	_ZN7IoUtils11CServerBase4ExitEi @ 153 NONAME
+	_ZN7IoUtils11CServerBase6DoRunLEv @ 154 NONAME
+	_ZN7IoUtils11CServerBase6ReportERKNS_16TServerCommandIdE11TRefByValueIK6TDesC8Ez @ 155 NONAME
+	_ZN7IoUtils11CServerBase6ReportERKNS_16TServerCommandIdE11TRefByValueIK7TDesC16Ez @ 156 NONAME
+	_ZN7IoUtils11CServerBase7FactoryEv @ 157 NONAME
+	_ZN7IoUtils11CServerBase9PrintListE11TRefByValueIK6TDesC8ERSt9__va_list @ 158 NONAME
+	_ZN7IoUtils11CServerBase9PrintListE11TRefByValueIK7TDesC16ERSt9__va_list @ 159 NONAME
+	_ZN7IoUtils11CServerBaseC2EjRK7TDesC16S3_ @ 160 NONAME
+	_ZN7IoUtils11CServerBaseD0Ev @ 161 NONAME
+	_ZN7IoUtils11CServerBaseD1Ev @ 162 NONAME
+	_ZN7IoUtils11CServerBaseD2Ev @ 163 NONAME
+	_ZN7IoUtils11CTextBuffer13AppendFormatLE11TRefByValueIK6TDesC8Ez @ 164 NONAME
+	_ZN7IoUtils11CTextBuffer13AppendFormatLE11TRefByValueIK7TDesC16Ez @ 165 NONAME
+	_ZN7IoUtils11CTextBuffer14SetAttributesLEjN17ConsoleAttributes6TColorES2_ @ 166 NONAME
+	_ZN7IoUtils11CTextBuffer17AppendFormatListLERK6TDesC8RSt9__va_list @ 167 NONAME
+	_ZN7IoUtils11CTextBuffer17AppendFormatListLERK7TDesC16RSt9__va_list @ 168 NONAME
+	_ZN7IoUtils11CTextBuffer24AppendHumanReadableSizeLEi @ 169 NONAME
+	_ZN7IoUtils11CTextBuffer24AppendHumanReadableSizeLEiNS_10TAlignmentE @ 170 NONAME
+	_ZN7IoUtils11CTextBuffer24AppendHumanReadableSizeLEx @ 171 NONAME
+	_ZN7IoUtils11CTextBuffer24AppendHumanReadableSizeLExNS_10TAlignmentE @ 172 NONAME
+	_ZN7IoUtils11CTextBuffer4NewLEi @ 173 NONAME
+	_ZN7IoUtils11CTextBuffer4ZeroEv @ 174 NONAME
+	_ZN7IoUtils11CTextBuffer5NewLCEi @ 175 NONAME
+	_ZN7IoUtils11CTextBuffer5ResetEv @ 176 NONAME
+	_ZN7IoUtils11CTextBuffer6DeleteEii @ 177 NONAME
+	_ZN7IoUtils11CTextBuffer7AppendLERK5TChar @ 178 NONAME
+	_ZN7IoUtils11CTextBuffer7AppendLERK6TDesC8 @ 179 NONAME
+	_ZN7IoUtils11CTextBuffer7AppendLERK7TDesC16 @ 180 NONAME
+	_ZN7IoUtils11CTextBuffer8CollapseEv @ 181 NONAME
+	_ZN7IoUtils11CTextBufferD0Ev @ 182 NONAME
+	_ZN7IoUtils11CTextBufferD1Ev @ 183 NONAME
+	_ZN7IoUtils11CTextBufferD2Ev @ 184 NONAME
+	_ZN7IoUtils12CCommandBase10ArgumentsLERNS_20RCommandArgumentListE @ 185 NONAME
+	_ZN7IoUtils12CCommandBase10Extension_EjRPvS1_ @ 186 NONAME
+	_ZN7IoUtils12CCommandBase10HaveStaticEv @ 187 NONAME
+	_ZN7IoUtils12CCommandBase10PrintErrorEi11TRefByValueIK7TDesC16Ez @ 188 NONAME
+	_ZN7IoUtils12CCommandBase10RunCommandEPK7TDesC16PNS_12CEnvironmentE @ 189 NONAME
+	_ZN7IoUtils12CCommandBase10RunCommandER10RIoSessionR13RIoReadHandleR14RIoWriteHandleS6_PK7TDesC16PNS_12CEnvironmentE @ 190 NONAME
+	_ZN7IoUtils12CCommandBase10RunCommandER10RIoSessionR13RIoReadHandleR14RIoWriteHandleS6_PK7TDesC16PNS_12CEnvironmentEPNS_20MCommandBaseObserverE @ 191 NONAME
+	_ZN7IoUtils12CCommandBase10RunCommandEv @ 192 NONAME
+	_ZN7IoUtils12CCommandBase11DisplayHelpEv @ 193 NONAME
+	_ZN7IoUtils12CCommandBase11HandleLeaveEi @ 194 NONAME
+	_ZN7IoUtils12CCommandBase11RunCommandLEPK7TDesC16PNS_12CEnvironmentE @ 195 NONAME
+	_ZN7IoUtils12CCommandBase11RunCommandLER10RIoSessionR13RIoReadHandleR14RIoWriteHandleS6_PK7TDesC16PNS_12CEnvironmentE @ 196 NONAME
+	_ZN7IoUtils12CCommandBase11RunCommandLEv @ 197 NONAME
+	_ZN7IoUtils12CCommandBase11StdinChangeEj @ 198 NONAME
+	_ZN7IoUtils12CCommandBase12GetHelpTextLEv @ 199 NONAME
+	_ZN7IoUtils12CCommandBase12PrintWarningE11TRefByValueIK7TDesC16Ez @ 200 NONAME
+	_ZN7IoUtils12CCommandBase13CompleteAsyncEi @ 201 NONAME
+	_ZN7IoUtils12CCommandBase13CompleteAsyncEi11TRefByValueIK7TDesC16Ez @ 202 NONAME
+	_ZN7IoUtils12CCommandBase14BaseConstructLEv @ 203 NONAME
+	_ZN7IoUtils12CCommandBase14PrintErrorListEi11TRefByValueIK7TDesC16ERSt9__va_list @ 204 NONAME
+	_ZN7IoUtils12CCommandBase15GetConsoleBaseLEv @ 205 NONAME
+	_ZN7IoUtils12CCommandBase16ParseCommandLineERK7TDesC16 @ 206 NONAME
+	_ZN7IoUtils12CCommandBase16PrintWarningListE11TRefByValueIK7TDesC16ERSt9__va_list @ 207 NONAME
+	_ZN7IoUtils12CCommandBase16SetErrorReportedEi @ 208 NONAME
+	_ZN7IoUtils12CCommandBase17LeaveIfFileExistsERK7TDesC16 @ 209 NONAME
+	_ZN7IoUtils12CCommandBase17ParseCommandLineLERK7TDesC16 @ 210 NONAME
+	_ZN7IoUtils12CCommandBase19LeaveIfFileNotFoundERK7TDesC16 @ 211 NONAME
+	_ZN7IoUtils12CCommandBase21ConsoleImplementationEv @ 212 NONAME
+	_ZN7IoUtils12CCommandBase2FsEv @ 213 NONAME
+	_ZN7IoUtils12CCommandBase3EnvEv @ 214 NONAME
+	_ZN7IoUtils12CCommandBase3FsLEv @ 215 NONAME
+	_ZN7IoUtils12CCommandBase4RunLEv @ 216 NONAME
+	_ZN7IoUtils12CCommandBase5ReadLER6TDes16 @ 217 NONAME
+	_ZN7IoUtils12CCommandBase5StdinEv @ 218 NONAME
+	_ZN7IoUtils12CCommandBase5WriteERK7TDesC16 @ 219 NONAME
+	_ZN7IoUtils12CCommandBase6PrintfE11TRefByValueIK6TDesC8Ez @ 220 NONAME
+	_ZN7IoUtils12CCommandBase6PrintfE11TRefByValueIK7TDesC16Ez @ 221 NONAME
+	_ZN7IoUtils12CCommandBase6StaticEv @ 222 NONAME
+	_ZN7IoUtils12CCommandBase6StderrEv @ 223 NONAME
+	_ZN7IoUtils12CCommandBase6StdoutEv @ 224 NONAME
+	_ZN7IoUtils12CCommandBase8CompleteE11TRefByValueIK7TDesC16Ez @ 225 NONAME
+	_ZN7IoUtils12CCommandBase8CompleteEi @ 226 NONAME
+	_ZN7IoUtils12CCommandBase8CompleteEi11TRefByValueIK7TDesC16Ez @ 227 NONAME
+	_ZN7IoUtils12CCommandBase8CompleteEv @ 228 NONAME
+	_ZN7IoUtils12CCommandBase8DoCancelEv @ 229 NONAME
+	_ZN7IoUtils12CCommandBase8OptionsLERNS_18RCommandOptionListE @ 230 NONAME
+	_ZN7IoUtils12CCommandBase8RunErrorEi @ 231 NONAME
+	_ZN7IoUtils12CCommandBase8SetFlagsEj @ 232 NONAME
+	_ZN7IoUtils12CCommandBase9IoSessionEv @ 233 NONAME
+	_ZN7IoUtils12CCommandBase9PrintListE11TRefByValueIK6TDesC8ERSt9__va_list @ 234 NONAME
+	_ZN7IoUtils12CCommandBase9PrintListE11TRefByValueIK7TDesC16ERSt9__va_list @ 235 NONAME
+	_ZN7IoUtils12CCommandBaseC2Ej @ 236 NONAME
+	_ZN7IoUtils12CCommandBaseC2Ev @ 237 NONAME
+	_ZN7IoUtils12CCommandBaseD0Ev @ 238 NONAME
+	_ZN7IoUtils12CCommandBaseD1Ev @ 239 NONAME
+	_ZN7IoUtils12CCommandBaseD2Ev @ 240 NONAME
+	_ZN7IoUtils12CEnvironment12InternalizeLERK6TDesC8 @ 241 NONAME
+	_ZN7IoUtils12CEnvironment4NewLERKS0_ @ 242 NONAME
+	_ZN7IoUtils12CEnvironment4NewLEv @ 243 NONAME
+	_ZN7IoUtils12CEnvironment4SetLERK7TDesC16S3_ @ 244 NONAME
+	_ZN7IoUtils12CEnvironment4SetLERK7TDesC16i @ 245 NONAME
+	_ZN7IoUtils12CEnvironment5CopyLERKS0_ @ 246 NONAME ABSENT
+	_ZN7IoUtils12CEnvironment6RemoveERK7TDesC16 @ 247 NONAME
+	_ZN7IoUtils12CEnvironment7RemoveLERK7TDesC16 @ 248 NONAME
+	_ZN7IoUtils12CEnvironment7SetPwdLERK7TDesC16 @ 249 NONAME
+	_ZN7IoUtils12CEnvironmentD0Ev @ 250 NONAME
+	_ZN7IoUtils12CEnvironmentD1Ev @ 251 NONAME
+	_ZN7IoUtils12CEnvironmentD2Ev @ 252 NONAME
+	_ZN7IoUtils12PrintWarningE11TRefByValueIK7TDesC16Ez @ 253 NONAME
+	_ZN7IoUtils13RChildProcess3RunER14TRequestStatus @ 254 NONAME
+	_ZN7IoUtils13RChildProcess5CloseEv @ 255 NONAME
+	_ZN7IoUtils13RChildProcess6DetachEv @ 256 NONAME
+	_ZN7IoUtils13RChildProcess7CreateLERK7TDesC16S3_R10RIoSessionR10RIoConsolePKNS_12CEnvironmentE @ 257 NONAME
+	_ZN7IoUtils13RChildProcess7CreateLERK7TDesC16S3_R10RIoSessionR13RIoReadHandleR14RIoWriteHandleS9_ @ 258 NONAME
+	_ZN7IoUtils13RChildProcess7CreateLERK7TDesC16S3_R10RIoSessionR13RIoReadHandleR14RIoWriteHandleS9_RKNS_12CEnvironmentE @ 259 NONAME
+	_ZN7IoUtils13RChildProcess7ProcessEv @ 260 NONAME
+	_ZN7IoUtils14CTextFormatter10ColumnizeLEiiRK6TArrayI7TPtrC16E @ 261 NONAME
+	_ZN7IoUtils14CTextFormatter10ColumnizeLEiiRK7TDesC16 @ 262 NONAME
+	_ZN7IoUtils14CTextFormatter4NewLER21RIoConsoleWriteHandle @ 263 NONAME
+	_ZN7IoUtils14CTextFormatter4NewLEi @ 264 NONAME
+	_ZN7IoUtils14CTextFormatter4ZeroEv @ 265 NONAME
+	_ZN7IoUtils14CTextFormatter5NewLCER21RIoConsoleWriteHandle @ 266 NONAME
+	_ZN7IoUtils14CTextFormatter5NewLCEi @ 267 NONAME
+	_ZN7IoUtils14CTextFormatter5ResetEv @ 268 NONAME
+	_ZN7IoUtils14CTextFormatter5WrapLEiRK7TDesC16 @ 269 NONAME
+	_ZN7IoUtils14CTextFormatter9TabulateLEiiRK7TDesC16 @ 270 NONAME
+	_ZN7IoUtils14CTextFormatter9TabulateLEiiRK7TDesC16NS_8TTabModeE @ 271 NONAME
+	_ZN7IoUtils14CTextFormatterD0Ev @ 272 NONAME
+	_ZN7IoUtils14CTextFormatterD1Ev @ 273 NONAME
+	_ZN7IoUtils14CTextFormatterD2Ev @ 274 NONAME
+	_ZN7IoUtils16TServerCommandId3SetERKS0_ @ 275 NONAME
+	_ZN7IoUtils16TServerCommandIdC1Ej @ 276 NONAME
+	_ZN7IoUtils16TServerCommandIdC1Ev @ 277 NONAME
+	_ZN7IoUtils16TServerCommandIdC2Ej @ 278 NONAME
+	_ZN7IoUtils16TServerCommandIdC2Ev @ 279 NONAME
+	_ZN7IoUtils18CBranchCommandBase10ArgumentsLERNS_20RCommandArgumentListE @ 280 NONAME
+	_ZN7IoUtils18CBranchCommandBase19ConfigureSubCommandERNS_18CServerCommandBaseE @ 281 NONAME
+	_ZN7IoUtils18CBranchCommandBase24HandleSubCommandCompleteERNS_18CServerCommandBaseE @ 282 NONAME
+	_ZN7IoUtils18CBranchCommandBase26HandleBackgroundSubCommandERNS_18CServerCommandBaseE @ 283 NONAME
+	_ZN7IoUtils18CBranchCommandBase6DoRunLEv @ 284 NONAME
+	_ZN7IoUtils18CBranchCommandBaseC2Ev @ 285 NONAME
+	_ZN7IoUtils18CBranchCommandBaseD0Ev @ 286 NONAME
+	_ZN7IoUtils18CBranchCommandBaseD1Ev @ 287 NONAME
+	_ZN7IoUtils18CBranchCommandBaseD2Ev @ 288 NONAME
+	_ZN7IoUtils18CServerCommandBase10SetFactoryERNS_21CServerCommandFactoryE @ 289 NONAME
+	_ZN7IoUtils18CServerCommandBase14PrintErrorListEi11TRefByValueIK7TDesC16ERSt9__va_list @ 290 NONAME
+	_ZN7IoUtils18CServerCommandBase16PrintWarningListE11TRefByValueIK7TDesC16ERSt9__va_list @ 291 NONAME
+	_ZN7IoUtils18CServerCommandBase5SetIdERKNS_16TServerCommandIdE @ 292 NONAME
+	_ZN7IoUtils18CServerCommandBase7FactoryEv @ 293 NONAME
+	_ZN7IoUtils18CServerCommandBase9PrintListE11TRefByValueIK6TDesC8ERSt9__va_list @ 294 NONAME
+	_ZN7IoUtils18CServerCommandBase9PrintListE11TRefByValueIK7TDesC16ERSt9__va_list @ 295 NONAME
+	_ZN7IoUtils18CServerCommandBaseC2Ej @ 296 NONAME
+	_ZN7IoUtils18CServerCommandBaseC2Ev @ 297 NONAME
+	_ZN7IoUtils18CServerCommandBaseD0Ev @ 298 NONAME
+	_ZN7IoUtils18CServerCommandBaseD1Ev @ 299 NONAME
+	_ZN7IoUtils18CServerCommandBaseD2Ev @ 300 NONAME
+	_ZN7IoUtils18RCommandOptionList10AppendIntLER6RArrayIiE5TCharRK7TDesC16S7_jS7_ @ 301 NONAME
+	_ZN7IoUtils18RCommandOptionList10AppendIntLERi5TCharRK7TDesC16S5_jS5_ @ 302 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendBoolLER6RArrayIiE5TCharRK7TDesC16S7_jS7_ @ 303 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendBoolLERi5TCharRK7TDesC16S5_jS5_ @ 304 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendEnumLERi5TCharRK7TDesC16S5_S5_jS5_ @ 305 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendRealLER6RArrayIdE5TCharRK7TDesC16S7_jS7_ @ 306 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendRealLERd5TCharRK7TDesC16S5_jS5_ @ 307 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendUintLER6RArrayIjE5TCharRK7TDesC16S7_jS7_ @ 308 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendUintLERj5TCharRK7TDesC16S5_jS5_ @ 309 NONAME
+	_ZN7IoUtils18RCommandOptionList13AppendStringLER13RPointerArrayI7HBufC16E5TCharRK7TDesC16S8_jS8_ @ 310 NONAME
+	_ZN7IoUtils18RCommandOptionList13AppendStringLERP7HBufC165TCharRK7TDesC16S7_jS7_ @ 311 NONAME
+	_ZN7IoUtils18RCommandOptionList15AppendFileNameLER6RArrayINS_10TFileName2EE5TCharRK7TDesC16S8_jS8_ @ 312 NONAME
+	_ZN7IoUtils18RCommandOptionList15AppendFileNameLERNS_10TFileName2E5TCharRK7TDesC16S6_jS6_ @ 313 NONAME
+	_ZN7IoUtils20RCommandArgumentList10AppendIntLER6RArrayIiERK7TDesC16S6_jS6_ @ 314 NONAME
+	_ZN7IoUtils20RCommandArgumentList10AppendIntLERiRK7TDesC16S4_jS4_ @ 315 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendEnumLERiRK7TDesC16S4_S4_jS4_ @ 316 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendRealLER6RArrayIdERK7TDesC16S6_jS6_ @ 317 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendRealLERdRK7TDesC16S4_jS4_ @ 318 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendUintLER6RArrayIjERK7TDesC16S6_jS6_ @ 319 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendUintLERjRK7TDesC16S4_jS4_ @ 320 NONAME
+	_ZN7IoUtils20RCommandArgumentList13AppendStringLER13RPointerArrayI7HBufC16ERK7TDesC16S7_jS7_ @ 321 NONAME
+	_ZN7IoUtils20RCommandArgumentList13AppendStringLERP7HBufC16RK7TDesC16S6_jS6_ @ 322 NONAME
+	_ZN7IoUtils20RCommandArgumentList15AppendFileNameLER6RArrayINS_10TFileName2EERK7TDesC16S7_jS7_ @ 323 NONAME
+	_ZN7IoUtils20RCommandArgumentList15AppendFileNameLERNS_10TFileName2ERK7TDesC16S5_jS5_ @ 324 NONAME
+	_ZNK7IoUtils20RCommandArgumentList9IsPresentEi @ 325 NONAME
+	_ZN7IoUtils21CServerCommandFactory14AddSubCommandLEPKNS_25CServerCommandConstructorE @ 326 NONAME
+	_ZN7IoUtils21CServerCommandFactory4NewLEPNS_22MServerCommandReporterEPKNS_16CCommandInfoFileE @ 327 NONAME
+	_ZN7IoUtils21CServerCommandFactory5NewLCERK7TDesC16PFPNS_18CServerCommandBaseEvEPNS_22MServerCommandReporterEPKNS_16CCommandInfoFileE @ 328 NONAME
+	_ZN7IoUtils21CServerCommandFactoryD0Ev @ 329 NONAME
+	_ZN7IoUtils21CServerCommandFactoryD1Ev @ 330 NONAME
+	_ZN7IoUtils21CServerCommandFactoryD2Ev @ 331 NONAME
+	_ZN7IoUtils25CServerCommandConstructor5NewLCERK7TDesC16PFPNS_18CServerCommandBaseEvERNS_21CServerCommandFactoryEPNS_22MServerCommandReporterEPKNS_16CCommandInfoFileE @ 332 NONAME
+	_ZN7IoUtils25CServerCommandConstructorD0Ev @ 333 NONAME
+	_ZN7IoUtils25CServerCommandConstructorD1Ev @ 334 NONAME
+	_ZN7IoUtils25CServerCommandConstructorD2Ev @ 335 NONAME
+	_ZN7IoUtils5ReadLER6TDes16 @ 336 NONAME
+	_ZN7IoUtils5TEnum5ParseERK7TDesC16Ri @ 337 NONAME
+	_ZN7IoUtils5TEnum6ParseLERK7TDesC16 @ 338 NONAME
+	_ZN7IoUtils5TEnumC1ERK7TDesC16 @ 339 NONAME
+	_ZN7IoUtils5TEnumC2ERK7TDesC16 @ 340 NONAME
+	_ZN7IoUtils5WriteERK7TDesC16 @ 341 NONAME
+	_ZN7IoUtils6PrintfE11TRefByValueIK6TDesC8Ez @ 342 NONAME
+	_ZN7IoUtils6PrintfE11TRefByValueIK7TDesC16Ez @ 343 NONAME
+	_ZN7IoUtils9Stringify5ErrorEi @ 344 NONAME
+	_ZN7IoUtils9Stringify6ReadLCER6TLex16RK5TChar @ 345 NONAME
+	_ZN7IoUtils9Stringify6ReadLCER6TLex16RK5TCharRNS_12CCommandBaseE @ 346 NONAME
+	_ZN7IoUtils9Stringify6ReadLCER6TLex16RK5TCharRNS_12CCommandBaseEj @ 347 NONAME
+	_ZN7IoUtils9Stringify6ReadLCER6TLex16RK5TCharj @ 348 NONAME
+	_ZN7IoUtils9Stringify7WidenLCERK6TDesC8 @ 349 NONAME
+	_ZN7IoUtils9Stringify8EscapeLCERK6TDesC8RK5TChar @ 350 NONAME
+	_ZN7IoUtils9Stringify8EscapeLCERK7TDesC16RK5TChar @ 351 NONAME
+	_ZN7IoUtils9Stringify8NarrowLCERK7TDesC16 @ 352 NONAME
+	_ZN7RIoFile6CreateER10RIoSessionRK7TDesC16NS_5TModeE @ 353 NONAME
+	_ZN7RIoFile7CreateLER10RIoSessionRK7TDesC16NS_5TModeE @ 354 NONAME
+	_ZN7RIoNull6CreateER10RIoSession @ 355 NONAME
+	_ZN7RIoNull7CreateLER10RIoSession @ 356 NONAME
+	_ZN7RIoPipe6CreateER10RIoSession @ 357 NONAME
+	_ZN7RIoPipe7CreateLER10RIoSession @ 358 NONAME
+	_ZN9RIoHandle15OpenFoundHandleER10RIoSessioni @ 359 NONAME
+	_ZN9RIoHandle16OpenFoundHandleLER10RIoSessioni @ 360 NONAME
+	_ZN9RIoHandle5CloseEv @ 361 NONAME
+	_ZNK10RIoConsole14ImplementationER6TDes16 @ 362 NONAME
+	_ZNK10RIoConsole15ImplementationLER6TDes16 @ 363 NONAME
+	_ZNK13RIoReadHandle12IsForegroundEv @ 364 NONAME
+	_ZNK13RIoReadHandle13IsForegroundLEv @ 365 NONAME
+	_ZNK18RIoReadWriteHandle17AttachedToConsoleEv @ 366 NONAME
+	_ZNK18RIoReadWriteHandle18AttachedToConsoleLEv @ 367 NONAME
+	_ZNK20RIoConsoleReadHandle12KeyModifiersEv @ 368 NONAME
+	_ZNK20RIoConsoleReadHandle7KeyCodeEv @ 369 NONAME
+	_ZNK21RIoConsoleWriteHandle12GetCursorPosER6TPoint @ 370 NONAME
+	_ZNK21RIoConsoleWriteHandle13GetCursorPosLEv @ 371 NONAME
+	_ZNK21RIoConsoleWriteHandle13GetScreenSizeER5TSize @ 372 NONAME
+	_ZNK21RIoConsoleWriteHandle14GetScreenSizeLEv @ 373 NONAME
+	_ZNK7IoUtils10TFileName210IsAbsoluteEv @ 374 NONAME
+	_ZNK7IoUtils10TFileName210IsArchiveLER3RFs @ 375 NONAME
+	_ZNK7IoUtils10TFileName210NameAndExtEv @ 376 NONAME
+	_ZNK7IoUtils10TFileName211IsDriveRootEv @ 377 NONAME
+	_ZNK7IoUtils10TFileName211IsReadOnlyLER3RFs @ 378 NONAME
+	_ZNK7IoUtils10TFileName212DriveAndPathEv @ 379 NONAME
+	_ZNK7IoUtils10TFileName213IsDriveLetterEv @ 380 NONAME
+	_ZNK7IoUtils10TFileName214HasDriveLetterEv @ 381 NONAME
+	_ZNK7IoUtils10TFileName215HasLeadingSlashEv @ 382 NONAME
+	_ZNK7IoUtils10TFileName216HasTrailingSlashEv @ 383 NONAME
+	_ZNK7IoUtils10TFileName23ExtEv @ 384 NONAME
+	_ZNK7IoUtils10TFileName24NameEv @ 385 NONAME
+	_ZNK7IoUtils10TFileName24PathEv @ 386 NONAME
+	_ZNK7IoUtils10TFileName25DriveEv @ 387 NONAME
+	_ZNK7IoUtils10TFileName26ExistsER3RFs @ 388 NONAME
+	_ZNK7IoUtils10TFileName26IsDirLER3RFs @ 389 NONAME
+	_ZNK7IoUtils10TFileName26IsWildEv @ 390 NONAME
+	_ZNK7IoUtils10TFileName29IsHiddenLER3RFs @ 391 NONAME
+	_ZNK7IoUtils10TFileName29IsSystemLER3RFs @ 392 NONAME
+	_ZNK7IoUtils11CTextBuffer10DescriptorEii @ 393 NONAME
+	_ZNK7IoUtils11CTextBuffer10DescriptorEv @ 394 NONAME
+	_ZNK7IoUtils11CTextBuffer5WriteER14RIoWriteHandle @ 395 NONAME
+	_ZNK7IoUtils11CTextBuffer5WriteER14RIoWriteHandleR14TRequestStatus @ 396 NONAME
+	_ZNK7IoUtils11CTextBuffer6LengthEv @ 397 NONAME
+	_ZNK7IoUtils12CCommandBase10IsCompleteEv @ 398 NONAME
+	_ZNK7IoUtils12CCommandBase16CompletionReasonEv @ 399 NONAME
+	_ZNK7IoUtils12CCommandBase2FsEv @ 400 NONAME
+	_ZNK7IoUtils12CCommandBase3EnvEv @ 401 NONAME
+	_ZNK7IoUtils12CCommandBase3FsLEv @ 402 NONAME
+	_ZNK7IoUtils12CCommandBase5FlagsEv @ 403 NONAME
+	_ZNK7IoUtils12CEnvironment10EscapeCharEv @ 404 NONAME
+	_ZNK7IoUtils12CEnvironment12ExternalizeLER5TDes8 @ 405 NONAME ABSENT
+	_ZNK7IoUtils12CEnvironment16ExternalizedSizeEv @ 406 NONAME ABSENT
+	_ZNK7IoUtils12CEnvironment3KeyEi @ 407 NONAME ABSENT
+	_ZNK7IoUtils12CEnvironment3PwdEv @ 408 NONAME
+	_ZNK7IoUtils12CEnvironment5CountEv @ 409 NONAME
+	_ZNK7IoUtils12CEnvironment5IsDesERK7TDesC16 @ 410 NONAME
+	_ZNK7IoUtils12CEnvironment5IsIntERK7TDesC16 @ 411 NONAME
+	_ZNK7IoUtils12CEnvironment8GetAsDesERK7TDesC16 @ 412 NONAME
+	_ZNK7IoUtils12CEnvironment8GetAsIntERK7TDesC16 @ 413 NONAME
+	_ZNK7IoUtils12CEnvironment9GetAsDesLERK7TDesC16 @ 414 NONAME
+	_ZNK7IoUtils12CEnvironment9GetAsIntLERK7TDesC16 @ 415 NONAME
+	_ZNK7IoUtils12CEnvironment9IsDefinedERK7TDesC16 @ 416 NONAME
+	_ZNK7IoUtils16TServerCommandId5ValueEv @ 417 NONAME
+	_ZNK7IoUtils16TServerCommandIdeqERKS0_ @ 418 NONAME
+	_ZNK7IoUtils18CServerCommandBase2IdEv @ 419 NONAME
+	_ZNK7IoUtils18RCommandOptionList8AsStringEPv @ 420 NONAME
+	_ZNK7IoUtils18RCommandOptionList9IsPresentEPv @ 421 NONAME
+	_ZNK7IoUtils20RCommandArgumentList8AsStringEPv @ 422 NONAME
+	_ZNK7IoUtils21CServerCommandFactory13ListCommandsLER6RArrayI7TPtrC16E @ 423 NONAME
+	_ZNK7IoUtils21CServerCommandFactory14GetSubCommandLERK7TDesC16 @ 424 NONAME
+	_ZNK7IoUtils21CServerCommandFactory9IsFactoryEv @ 425 NONAME
+	_ZNK7IoUtils25CServerCommandConstructor22CreateImplementationLCEv @ 426 NONAME
+	_ZNK7IoUtils25CServerCommandConstructor4NameEv @ 427 NONAME
+	_ZNK7IoUtils25CServerCommandConstructor9IsFactoryEv @ 428 NONAME
+	_ZNK7IoUtils5TEnum13AppendValuesLERNS_11CTextBufferE @ 429 NONAME
+	_ZNK7IoUtils5TEnum9GetStringEi @ 430 NONAME
+	_ZNK7IoUtils5TEnum9ValueListEv @ 431 NONAME
+	_ZNK9RIoHandle10ObjectNameER6TDes16 @ 432 NONAME
+	_ZNK9RIoHandle11ObjectNameLER6TDes16 @ 433 NONAME
+	_ZNK9RIoHandle6EqualsERKS_ @ 434 NONAME
+	_ZNK9RIoHandle6IsTypeENS_5TTypeE @ 435 NONAME
+	_ZNK9RIoHandle7EqualsLERKS_ @ 436 NONAME
+	_ZNK9RIoHandle7IsTypeLENS_5TTypeE @ 437 NONAME
+	_ZTI12CHelpCommand @ 438 NONAME ABSENT ; #<TI>#
+	_ZTI12CRootCommand @ 439 NONAME ABSENT ; #<TI>#
+	_ZTI15TExitController @ 440 NONAME ABSENT ; #<TI>#
+	_ZTIN7IoUtils11CClientBaseE @ 441 NONAME ; #<TI>#
+	_ZTIN7IoUtils11CServerBaseE @ 442 NONAME ; #<TI>#
+	_ZTIN7IoUtils12CCommandBaseE @ 443 NONAME ; #<TI>#
+	_ZTIN7IoUtils18CBranchCommandBaseE @ 444 NONAME ; #<TI>#
+	_ZTIN7IoUtils18CServerCommandBaseE @ 445 NONAME ; #<TI>#
+	_ZTIN7IoUtils21CServerCommandFactoryE @ 446 NONAME ; #<TI>#
+	_ZTIN7IoUtils25CServerCommandConstructorE @ 447 NONAME ; #<TI>#
+	_ZTV12CHelpCommand @ 448 NONAME ABSENT ; #<VT>#
+	_ZTV12CRootCommand @ 449 NONAME ABSENT ; #<VT>#
+	_ZTV15TExitController @ 450 NONAME ABSENT ; #<VT>#
+	_ZTVN7IoUtils11CClientBaseE @ 451 NONAME ; #<VT>#
+	_ZTVN7IoUtils11CServerBaseE @ 452 NONAME ; #<VT>#
+	_ZTVN7IoUtils12CCommandBaseE @ 453 NONAME ; #<VT>#
+	_ZTVN7IoUtils18CBranchCommandBaseE @ 454 NONAME ; #<VT>#
+	_ZTVN7IoUtils18CServerCommandBaseE @ 455 NONAME ; #<VT>#
+	_ZTVN7IoUtils21CServerCommandFactoryE @ 456 NONAME ; #<VT>#
+	_ZTVN7IoUtils25CServerCommandConstructorE @ 457 NONAME ; #<VT>#
+	_ZThn236_N7IoUtils11CServerBase10ReportListERKNS_16TServerCommandIdE11TRefByValueIK6TDesC8ERSt9__va_list @ 458 NONAME ; #<thunk>#
+	_ZThn236_N7IoUtils11CServerBase10ReportListERKNS_16TServerCommandIdE11TRefByValueIK7TDesC16ERSt9__va_list @ 459 NONAME ; #<thunk>#
+	_ZThn236_N7IoUtils11CServerBase11ReportErrorERKNS_16TServerCommandIdEi11TRefByValueIK7TDesC16Ez @ 460 NONAME ; #<thunk>#
+	_ZThn236_N7IoUtils11CServerBase13ReportWarningERKNS_16TServerCommandIdE11TRefByValueIK7TDesC16Ez @ 461 NONAME ; #<thunk>#
+	_ZThn236_N7IoUtils11CServerBase15ReportErrorListERKNS_16TServerCommandIdEi11TRefByValueIK7TDesC16ERSt9__va_list @ 462 NONAME ; #<thunk>#
+	_ZThn236_N7IoUtils11CServerBase17ReportWarningListERKNS_16TServerCommandIdE11TRefByValueIK7TDesC16ERSt9__va_list @ 463 NONAME ; #<thunk>#
+	_ZThn236_N7IoUtils11CServerBase6ReportERKNS_16TServerCommandIdE11TRefByValueIK6TDesC8Ez @ 464 NONAME ; #<thunk>#
+	_ZThn236_N7IoUtils11CServerBase6ReportERKNS_16TServerCommandIdE11TRefByValueIK7TDesC16Ez @ 465 NONAME ; #<thunk>#
+	_ZThn240_N7IoUtils11CServerBase13LeoHandleLineERK7TDesC16 @ 466 NONAME ; #<thunk>#
+	_ZN7IoUtils18RCommandOptionList11AppendEnumLER6RArrayIiE5TCharRK7TDesC16S7_S7_jS7_ @ 467 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendEnumLER6RArrayIiERK7TDesC16S6_S6_jS6_ @ 468 NONAME
+	_ZN7IoUtils11CTextBuffer9ResetTextEv @ 469 NONAME
+	_ZN7IoUtils14CTextFormatter9ResetTextEv @ 470 NONAME
+	_ZN7IoUtils24CMemoryAccessCommandBase17LoadMemoryAccessLEv @ 471 NONAME
+	_ZN7IoUtils24CMemoryAccessCommandBaseC2Ej @ 472 NONAME
+	_ZN7IoUtils24CMemoryAccessCommandBaseC2Ev @ 473 NONAME
+	_ZN7IoUtils24CMemoryAccessCommandBaseD0Ev @ 474 NONAME
+	_ZN7IoUtils24CMemoryAccessCommandBaseD1Ev @ 475 NONAME
+	_ZN7IoUtils24CMemoryAccessCommandBaseD2Ev @ 476 NONAME
+	_ZTIN7IoUtils24CMemoryAccessCommandBaseE @ 477 NONAME
+	_ZTVN7IoUtils24CMemoryAccessCommandBaseE @ 478 NONAME
+	_ZN7IoUtils11CTextBuffer13AppendSpacesLEi @ 479 NONAME
+	_ZN7IoUtils11CTextBuffer7AppendLERKS0_ @ 480 NONAME
+	_ZN7IoUtils14CTextFormatter10AppendPodLERK7TDesC16 @ 481 NONAME
+	_ZN7IoUtils14CTextFormatter5WrapLEiiRK7TDesC16 @ 482 NONAME
+	_ZNK7IoUtils11CTextBuffer20GetCurrentAttributesERjRN17ConsoleAttributes6TColorES4_ @ 483 NONAME
+	_ZNK7IoUtils20RCommandArgumentList9IsPresentEPv @ 484 NONAME
+	_ZN7IoUtils14CTextFormatter5WriteEv @ 485 NONAME
+	_ZNK7IoUtils11CTextBuffer13GetAttributesEiRjRN17ConsoleAttributes6TColorES4_ @ 486 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendEnumLER6RArrayIiE5TCharRK7TDesC16S7_S7_S7_jS7_ @ 487 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendEnumLERi5TCharRK7TDesC16S5_S5_S5_jS5_ @ 488 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendEnumLER6RArrayIiERK7TDesC16S6_S6_S6_jS6_ @ 489 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendEnumLERiRK7TDesC16S4_S4_S4_jS4_ @ 490 NONAME
+	_ZNK7IoUtils5TEnum15DescriptionListEv @ 491 NONAME
+	_ZN7IoUtils5TEnumC1ERK7TDesC16S3_ @ 492 NONAME
+	_ZN7IoUtils5TEnumC2ERK7TDesC16S3_ @ 493 NONAME
+	_ZN7IoUtils12CCommandBase20GetColorConsoleBaseLEv @ 494 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendUintLER6RArrayIyE5TCharRK7TDesC16S7_jS7_ @ 495 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendUintLERy5TCharRK7TDesC16S5_jS5_ @ 496 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendUintLER6RArrayIyERK7TDesC16S6_jS6_ @ 497 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendUintLERyRK7TDesC16S4_jS4_ @ 498 NONAME
+	_ZN7IoUtils18RCommandOptionList10AppendIntLER6RArrayIxE5TCharRK7TDesC16S7_jS7_ @ 499 NONAME
+	_ZN7IoUtils18RCommandOptionList10AppendIntLERx5TCharRK7TDesC16S5_jS5_ @ 500 NONAME
+	_ZN7IoUtils20RCommandArgumentList10AppendIntLER6RArrayIxERK7TDesC16S6_jS6_ @ 501 NONAME
+	_ZN7IoUtils20RCommandArgumentList10AppendIntLERxRK7TDesC16S4_jS4_ @ 502 NONAME
+	_ZN7IoUtils11CTextBuffer7AppendLERKS0_i @ 503 NONAME
+	_ZN7IoUtils11CTextBuffer7AppendLERKS0_ii @ 504 NONAME
+	_ZN7IoUtils12CCommandBase5PageLER13RIoReadHandle @ 505 NONAME
+	_ZN7IoUtils12CCommandBase5PageLERKNS_11CTextBufferE @ 506 NONAME
+	_ZNK7IoUtils11CTextBuffer5WriteER14RIoWriteHandleii @ 507 NONAME
+	_ZNK7IoUtils11CTextBuffer5WriteER14RIoWriteHandleiiR14TRequestStatus @ 508 NONAME
+	_ZN21RIoConsoleWriteHandle13SetAttributesERKN17ConsoleAttributes11TAttributesE @ 509 NONAME
+	_ZN7IoUtils11CTextBuffer14SetAttributesLERKN17ConsoleAttributes11TAttributesE @ 510 NONAME
+	_ZN7IoUtils10TFileName214SetNameAndExtLERK7TDesC16 @ 511 NONAME
+	_ZN7IoUtils10TFileName27SetExtLERK7TDesC16 @ 512 NONAME
+	_ZN7IoUtils10TFileName28SetNameLERK7TDesC16 @ 513 NONAME
+	_ZN7IoUtils10TFileName28SetPathLERK7TDesC16 @ 514 NONAME
+	_ZN7IoUtils10TFileName29SetDriveLERK7TDesC16 @ 515 NONAME
+	_ZN7IoUtils16CCommandInfoFile4NewLER3RFsRK7TDesC16 @ 516 NONAME
+	_ZN7IoUtils16CCommandInfoFile9ArgumentsEv @ 517 NONAME
+	_ZN7IoUtils16CCommandInfoFileD0Ev @ 518 NONAME
+	_ZN7IoUtils16CCommandInfoFileD1Ev @ 519 NONAME
+	_ZN7IoUtils16CCommandInfoFileD2Ev @ 520 NONAME
+	_ZN7IoUtils18RCommandOptionList10AppendIntLER6RArrayIiERK7TDesC16 @ 521 NONAME
+	_ZN7IoUtils18RCommandOptionList10AppendIntLER6RArrayIxERK7TDesC16 @ 522 NONAME
+	_ZN7IoUtils18RCommandOptionList10AppendIntLERiRK7TDesC16 @ 523 NONAME
+	_ZN7IoUtils18RCommandOptionList10AppendIntLERxRK7TDesC16 @ 524 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendBoolLER6RArrayIiERK7TDesC16 @ 525 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendBoolLERiRK7TDesC16 @ 526 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendEnumLER6RArrayIiERK7TDesC16 @ 527 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendEnumLERiRK7TDesC16 @ 528 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendRealLER6RArrayIdERK7TDesC16 @ 529 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendRealLERdRK7TDesC16 @ 530 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendUintLER6RArrayIjERK7TDesC16 @ 531 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendUintLER6RArrayIyERK7TDesC16 @ 532 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendUintLERjRK7TDesC16 @ 533 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendUintLERyRK7TDesC16 @ 534 NONAME
+	_ZN7IoUtils18RCommandOptionList13AppendStringLER13RPointerArrayI7HBufC16ERK7TDesC16 @ 535 NONAME
+	_ZN7IoUtils18RCommandOptionList13AppendStringLERP7HBufC16RK7TDesC16 @ 536 NONAME
+	_ZN7IoUtils18RCommandOptionList15AppendFileNameLER6RArrayINS_10TFileName2EERK7TDesC16 @ 537 NONAME
+	_ZN7IoUtils18RCommandOptionList15AppendFileNameLERNS_10TFileName2ERK7TDesC16 @ 538 NONAME
+	_ZN7IoUtils20RCommandArgumentList10AppendIntLER6RArrayIiERK7TDesC16 @ 539 NONAME
+	_ZN7IoUtils20RCommandArgumentList10AppendIntLER6RArrayIxERK7TDesC16 @ 540 NONAME
+	_ZN7IoUtils20RCommandArgumentList10AppendIntLERiRK7TDesC16 @ 541 NONAME
+	_ZN7IoUtils20RCommandArgumentList10AppendIntLERxRK7TDesC16 @ 542 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendEnumLER6RArrayIiERK7TDesC16 @ 543 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendEnumLERiRK7TDesC16 @ 544 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendRealLER6RArrayIdERK7TDesC16 @ 545 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendRealLERdRK7TDesC16 @ 546 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendUintLER6RArrayIjERK7TDesC16 @ 547 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendUintLER6RArrayIyERK7TDesC16 @ 548 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendUintLERjRK7TDesC16 @ 549 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendUintLERyRK7TDesC16 @ 550 NONAME
+	_ZN7IoUtils20RCommandArgumentList13AppendStringLER13RPointerArrayI7HBufC16ERK7TDesC16 @ 551 NONAME
+	_ZN7IoUtils20RCommandArgumentList13AppendStringLERP7HBufC16RK7TDesC16 @ 552 NONAME
+	_ZN7IoUtils20RCommandArgumentList15AppendFileNameLER6RArrayINS_10TFileName2EERK7TDesC16 @ 553 NONAME
+	_ZN7IoUtils20RCommandArgumentList15AppendFileNameLERNS_10TFileName2ERK7TDesC16 @ 554 NONAME
+	_ZN7IoUtils5TEnum12SetValueListERK7TDesC16 @ 555 NONAME
+	_ZN7IoUtils5TEnum18SetDescriptionListERK7TDesC16 @ 556 NONAME
+	_ZN7IoUtils5TEnumC1Ev @ 557 NONAME
+	_ZN7IoUtils5TEnumC2Ev @ 558 NONAME
+	_ZNK7IoUtils12CCommandBase11DescriptionEv @ 559 NONAME
+	_ZNK7IoUtils16CCommandInfoFile15LongDescriptionEv @ 560 NONAME
+	_ZNK7IoUtils16CCommandInfoFile16ShortDescriptionEv @ 561 NONAME
+	_ZNK7IoUtils16CCommandInfoFile4NameEv @ 562 NONAME
+	_ZNK7IoUtils16CCommandInfoFile7AssignLERNS_20RCommandArgumentListERNS_18RCommandOptionListE @ 563 NONAME
+	_ZNK7IoUtils16CCommandInfoFile7OptionsEv @ 564 NONAME
+	_ZTIN7IoUtils16CCommandInfoFileE @ 565 NONAME ; #<TI>#
+	_ZTVN7IoUtils16CCommandInfoFileE @ 566 NONAME ; #<VT>#
+	_ZNK7IoUtils16CCommandInfoFile7SeeAlsoEv @ 567 NONAME
+	_ZNK7IoUtils12CCommandBase8UsingCifEv @ 568 NONAME
+	_ZN7IoUtils10TFileName28SetTypeLER3RFs @ 569 NONAME
+	_ZNK7IoUtils10TFileName25IsDirEv @ 570 NONAME
+	_ZNK7IoUtils10TFileName26IsFileEv @ 571 NONAME
+	_ZNK7IoUtils13RChildProcess7ProcessEv @ 572 NONAME
+	_ZN7IoUtils12CCommandBase20StopSupressingErrorsEv @ 573 NONAME
+	_ZN7IoUtils12CCommandBase21StartSupressingErrorsEv @ 574 NONAME
+	_ZN7IoUtils16CCommandInfoFile4NewLER3RFsRKNS_12CEnvironmentERK7TDesC16 @ 575 NONAME
+	_ZN7IoUtils18RCommandOptionListixEi @ 576 NONAME
+	_ZNK7IoUtils18RCommandOptionList5CountEv @ 577 NONAME
+	_ZNK7IoUtils18RCommandOptionListixEi @ 578 NONAME
+	_ZNK7IoUtils6TValue4NameEv @ 579 NONAME
+	_ZNK7IoUtils16CCommandInfoFile10SubCommandEi @ 580 NONAME
+	_ZNK7IoUtils16CCommandInfoFile14NumSubCommandsEv @ 581 NONAME
+	_ZN13RIoReadHandle25DuplicateHandleFromThreadE9TThreadId @ 582 NONAME
+	_ZN14RIoWriteHandle25DuplicateHandleFromThreadE9TThreadId @ 583 NONAME
+	_ZN21RIoConsoleWriteHandle11SetIsStdErrEi @ 584 NONAME
+	_ZNK7IoUtils16CCommandInfoFile10SubCommandERK7TDesC16 @ 585 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendEnumLER6RArrayIiERK7TDesC16S6_ @ 586 NONAME
+	_ZN7IoUtils18RCommandOptionList11AppendEnumLERiRK7TDesC16S4_ @ 587 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendEnumLER6RArrayIiERK7TDesC16S6_ @ 588 NONAME
+	_ZN7IoUtils20RCommandArgumentList11AppendEnumLERiRK7TDesC16S4_ @ 589 NONAME
+	_ZN7IoUtils5TEnumaSERKS0_ @ 590 NONAME
+	_ZN7IoUtils18CBranchCommandBase15TypeDescriptionEv @ 591 NONAME
+	_ZNK7IoUtils16CCommandInfoFile9CopyrightEv @ 592 NONAME
+	_ZN12TIoHandleSetC1ER10RIoSessionR13RIoReadHandleR14RIoWriteHandleS5_ @ 593 NONAME
+	_ZN12TIoHandleSetC2ER10RIoSessionR13RIoReadHandleR14RIoWriteHandleS5_ @ 594 NONAME
+	_ZN7IoUtils12CCommandBase18CreateEnvironmentLEPNS_12CEnvironmentE @ 595 NONAME
+	_ZN7IoUtils12CCommandBase6SetCifERKNS_16CCommandInfoFileE @ 596 NONAME
+	_ZNK12TIoHandleSet5StdinEv @ 597 NONAME
+	_ZNK12TIoHandleSet6StderrEv @ 598 NONAME
+	_ZNK12TIoHandleSet6StdoutEv @ 599 NONAME
+	_ZNK7IoUtils12CCommandBase3CifEv @ 600 NONAME
+	_ZNK7IoUtils20RCommandArgumentList5CountEv @ 601 NONAME
+	_ZNK7IoUtils20RCommandArgumentList6AllSetEv @ 602 NONAME
+	_ZNK7IoUtils20RCommandArgumentListixEi @ 603 NONAME
+	_ZNK7IoUtils6TValue15AcceptsMultipleEv @ 604 NONAME
+	_ZNK7IoUtils6TValue6EnvVarEv @ 605 NONAME
+	_ZNK9RIoHandle7SessionEv @ 606 NONAME
+	_ZN7IoUtils12CEnvironment24CreateSharedEnvironmentLEv @ 607 NONAME
+	_ZN7IoUtils12CEnvironment9RemoveAllEv @ 608 NONAME
+	_ZN7IoUtils12CEnvironment9SetLocalLERK7TDesC16 @ 609 NONAME
+	_ZNK7IoUtils12CEnvironment13ExternalizeLCEv @ 610 NONAME
+	_ZNK7IoUtils12CEnvironment8GetKeysLER13RPointerArrayI7HBufC16E @ 611 NONAME
+	_ZNK12TIoHandleSet9IoSessionEv @ 612 NONAME
+	_ZNK7IoUtils6TValue4TypeEv @ 613 NONAME
+	_ZNK7IoUtils6TValue8ValuePtrEv @ 614 NONAME
+	_ZNK7IoUtils6TValue13EnumValueListEv @ 615 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+..\inc\iocli.h			fshell/iocli.h
+..\inc\ioutils.h		fshell/ioutils.h
+..\inc\ioutils.inl		fshell/ioutils.inl
+..\inc\memoryaccesscmd.h	fshell/memoryaccesscmd.h
+..\data\iosrv.idf	z:\resource\iosrv.idf
+..\data\iosrv.ini.remote \epoc32\wins\c\system\console\iosrv.ini.remote
+..\data\iosrv.ini.remote \epoc32\winscw\c\system\console\iosrv.ini.remote
+
+..\data\iosrv.ini.econs_fb Z:\system\console\iosrv.ini.econs_fb
+..\data\iosrv.ini.noautodetect Z:\system\console\iosrv.ini.noautodetect
+..\data\iosrv.ini.bluetooth Z:\system\console\iosrv.ini.bluetooth
+
+PRJ_MMPFILES
+.\iocli.mmp
+.\iosrv.mmp
+
+PRJ_TESTEXPORTS
+..\tsrc\t1_newlineend.txt	\epoc32\winscw\c\t_iosrv\t1_newlineend.txt
+..\tsrc\t2_nonewlineend.txt	\epoc32\winscw\c\t_iosrv\t2_nonewlineend.txt
+..\tsrc\t3_alloneline.txt	\epoc32\winscw\c\t_iosrv\t3_alloneline.txt
+..\tsrc\t_ioread.script		\epoc32\winscw\c\t_iosrv\t_ioread.script
+
+PRJ_TESTMMPFILES
+..\tsrc\t_ioread.mmp
+
+#ifdef FSHELL_PERL_SUPPORT
+#include "..\perl\group\bld.inf"
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/group/iocli.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+// iocli.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          iocli.dll
+targettype      dll
+capability      FSHELL_CAP_MMP_MAX
+
+systeminclude   ..\inc
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      ..\client
+
+source          client.cpp
+source          command_base.cpp
+source          command_info_file.cpp
+source          env.cpp
+source          file_utils.cpp
+source          pod_lexer.cpp
+source          pod_formatter.cpp
+source          text_formatter.cpp
+source          iocons.cpp
+source          client_command.cpp
+source          server_command.cpp
+source          memoryaccesscmd.cpp
+
+library         euser.lib
+library         efsrv.lib
+library         ltkutils-tcb.lib
+library         lineeditor.lib
+
+deffile         iocli.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/group/iosrv.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// iosrv.mmp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          iosrv.exe
+targettype      exe
+uid             0x100039CE FSHELL_UID_IOSRV
+capability      FSHELL_CAP_MMP_NORMAL
+
+systeminclude   ..\inc
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      ..\server
+
+source          server.cpp
+source          session.cpp
+source          endpoint.cpp
+source          pipe.cpp
+source          console.cpp
+source          file.cpp
+source          null.cpp
+source			persistentconsole.cpp
+source          readwrite.cpp
+source          log.cpp
+source          config.cpp
+source          object.cpp
+
+library         euser.lib
+library         efsrv.lib
+library			consoleproxy.lib
+library			ltkutils.lib
+
+// Uncomment these to have the iosrv logging use clogger (IOSRV_LOGGING must be defined too)
+macro			IOSRV_LOGGING_USES_CLOGGER
+library			clogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/inc/clientserver.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,123 @@
+// clientserver.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __CLIENTSERVER_H__
+#define __CLIENTSERVER_H__
+
+#include <e32std.h>
+#include <fshell/common.mmh>
+
+_LIT(KIoServerName, "iosrv");
+
+const TUid KServerUid3 = {FSHELL_UID_IOSRV};
+
+#ifdef __WINS__
+const TInt KIoStackSize = 0x2000;		// 8KB
+const TInt KIoInitHeapSize = 0x1000;	// 4KB
+const TInt KIoMaxHeapSize = 0x200000;	// 2MB
+#endif
+
+enum TIoOpcodes
+	{
+	EIoCreateReader,
+	EIoHandleClose,
+	EIoHandleSetOwner,
+	EIoHandleSetUnderlyingConsole,
+	EIoHandleAttachedToConsole,
+	EIoOpenReaderByThreadId,
+	EIoOpenReaderByExplicitThreadId,
+	EIoDuplicateReader,
+	EIoCreateWriter,
+	EIoOpenWriterByThreadId,
+	EIoOpenWriterByExplicitThreadId,
+	EIoDuplicateWriter,
+	EIoSetReadWriteMode,
+	EIoSetReadMode,
+	EIoSetReaderToForeground,
+	EIoRead,
+	EIoSetLineSeparator,
+	EIoWrite,
+	EIoReadCancel,
+	EIoWriteCancel,
+	EIoIsForegroundReader,
+	EIoConsoleWaitForKey,
+	EIoConsoleWaitForKeyCancel,
+	EIoConsoleCaptureKey,
+	EIoConsoleCancelCaptureKey,
+	EIoConsoleCaptureAllKeys,
+	EIoConsoleCancelCaptureAllKeys,
+	EIoConsoleCursorPos,
+	EIoConsoleSetCursorPosAbs,
+	EIoConsoleSetCursorPosRel,
+	EIoConsoleSetCursorHeight,
+	EIoConsoleSetTitle,
+	EIoConsoleClearScreen,
+	EIoConsoleClearToEndOfLine,
+	EIoConsoleScreenSize,
+	EIoConsoleSetAttributes,
+	EIoEndPointAttachReader,
+	EIoEndPointAttachWriter,
+	EIoEndPointSetForegroundReadHandle,
+	EIoCreatePipe,
+	EIoCreateConsole,
+	EIoOpenConsole,
+	EIoConsoleImplementation,
+	EIoCreateFile,
+	EIoCreateNull,
+	EIoSetObjectName,
+	EIoCreatePersistentConsole,
+	EIoOpenPersistentConsoleByName,
+	EIoPersistentConsoleAttachReadEndPoint,
+	EIoPersistentConsoleAttachWriteEndPoint,
+	EIoPersistentConsoleDetachReadEndPoint,
+	EIoPersistentConsoleDetachWriteEndPoint,
+	EIoPersistentConsoleNotifyReadDetach,
+	EIoPersistentConsoleNotifyWriteDetach,
+	EIoPersistentConsoleCancelNotifyReadDetach,
+	EIoPersistentConsoleCancelNotifyWriteDetach,
+	EIoPersistentConsoleGetAttachedNames,
+	EIoPersistentConsoleGetCreatorThreadId,
+	EIoHandleIsType,
+	EIoFindFirstHandle,
+	EIoFindNextHandle,
+	EIoOpenFoundHandle,
+	EIoHandleGetName,
+	EIoHandleEquals,
+	EIoReadHandleNotifyChange,
+	EIoReadHandleCancelNotifyChange,
+	EIoDuplicateReaderHandleFromThread,
+	EIoDuplicateWriterHandleFromThread,
+	EIoSetIsStdErr,
+	};
+
+class TServerStart
+	{
+public:
+	TServerStart();
+	TServerStart(TRequestStatus& aStatus);
+	TPtrC AsCommand() const;
+	TInt GetCommand();
+	void SignalL();
+private:
+	TThreadId iId;
+	TRequestStatus* iStatus;
+	};
+
+class TConsoleCreateParams
+	{
+public:
+	TSize iSize;
+	TInt iUnderlyingConsoleHandle;
+	TUint iOptions;
+	};
+
+#endif // __CLIENTSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/inc/iocli.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,314 @@
+// iocli.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __IOCLI_H__
+#define __IOCLI_H__
+
+#include <e32std.h>
+#include <e32keys.h>
+#include <fshell/consoleextensions.h>
+
+class RIoSession;
+class RIoConsole;
+
+class RIoHandle : public RSubSessionBase
+	{
+public:
+	enum TType
+		{
+		EReadWriteObject,
+		EReadObject,
+		EWriteObject,
+		EEndPoint,
+		EConsole,
+		EFile,
+		ENull,
+		EPipe,
+		EPersistentConsole,
+		};
+public:
+	IMPORT_C TInt OpenFoundHandle(RIoSession& aSession, TInt aFoundHandle);
+	IMPORT_C void OpenFoundHandleL(RIoSession& aSession, TInt aFoundHandle);
+	IMPORT_C void Close();
+	IMPORT_C TInt IsType(TType aType) const;
+	IMPORT_C TBool IsTypeL(TType aType) const;
+	IMPORT_C TInt ObjectName(TDes& aName) const;
+	IMPORT_C void ObjectNameL(TDes& aName) const;
+	IMPORT_C TInt Equals(const RIoHandle& aNother) const;
+	IMPORT_C TBool EqualsL(const RIoHandle& aNother) const;
+	IMPORT_C RIoSession Session() const;
+	};
+	
+class RIoSession : public RSessionBase
+	{
+public:
+	IMPORT_C TInt Connect();
+	IMPORT_C void ConnectL();
+	IMPORT_C TInt SetObjectName(TInt aHandle, const TDesC& aName);
+	IMPORT_C void SetObjectNameL(TInt aHandle, const TDesC& aName);
+	IMPORT_C TInt FindFirstHandle(RIoHandle::TType aType, const TDesC& aMatchString, TInt& aFoundHandle, TName& aName);
+	IMPORT_C TInt FindNextHandle(TInt& aFoundHandle, TName& aName);
+	};
+
+class RIoReadWriteHandle : public RIoHandle
+	{
+public:
+	enum TMode
+		{
+		EText,
+		EBinary
+		};
+public:
+	IMPORT_C TInt SetMode(TMode aMode);
+	IMPORT_C void SetModeL(TMode aMode);
+	IMPORT_C TInt SetOwner(TThreadId aOwningThread);
+	IMPORT_C void SetOwnerL(TThreadId aOwningThread);
+	IMPORT_C TInt SetUnderlyingConsole(RIoConsole& aConsole);
+	IMPORT_C void SetUnderlyingConsoleL(RIoConsole& aConsole);
+	IMPORT_C TInt AttachedToConsole() const;
+	IMPORT_C TBool AttachedToConsoleL() const;
+	};
+
+class RIoReadHandle : public RIoReadWriteHandle
+	{
+public:
+	enum TReadMode
+		{
+		EFull,
+		ELine,
+		EOneOrMore
+		};
+	enum TChangeType
+		{
+		EGainedForeground	= 0x01,
+		EConsoleSizeChanged	= 0x02,
+		};
+public:
+	IMPORT_C TInt Create(RIoSession& aSession);
+	IMPORT_C void CreateL(RIoSession& aSession);
+	IMPORT_C TInt Open(RIoSession& aSession);
+	IMPORT_C void OpenL(RIoSession& aSession);
+	IMPORT_C TInt Open(RIoSession& aSession, TThreadId aThreadId);
+	IMPORT_C void OpenL(RIoSession& aSession, TThreadId aThreadId);
+	IMPORT_C TInt Duplicate(RIoReadHandle& aReadHandle);
+	IMPORT_C void DuplicateL(RIoReadHandle& aReadHandle);
+	IMPORT_C TInt DuplicateHandleFromThread(TThreadId aThreadId);
+
+	IMPORT_C TInt SetReadMode(TReadMode aMode);
+	IMPORT_C void SetReadModeL(TReadMode aMode);
+	IMPORT_C TInt SetToForeground();
+	IMPORT_C void SetToForegroundL();
+	IMPORT_C TInt Read(TDes& aDes);
+	IMPORT_C void ReadL(TDes& aDes);
+	IMPORT_C void Read(TDes& aDes, TRequestStatus& aStatus);
+	IMPORT_C TInt SetLineSeparator(const TDesC& aSeparator);
+	IMPORT_C void SetLineSeparatorL(const TDesC& aSeparator);
+	IMPORT_C void ReadCancel();
+	IMPORT_C TInt IsForeground() const;
+	IMPORT_C TBool IsForegroundL() const;
+	IMPORT_C void NotifyChange(TPckgBuf<TUint>& aChangeType, TRequestStatus& aStatus);
+	IMPORT_C void CancelNotifyChange();
+	};
+
+class RIoConsoleReadHandle : public RIoReadHandle
+	{
+public:
+	IMPORT_C RIoConsoleReadHandle();
+	IMPORT_C RIoConsoleReadHandle(RIoReadHandle& aHandle);
+	IMPORT_C RIoConsoleReadHandle operator=(RIoReadHandle& aHandle);
+	IMPORT_C TUint ReadKey();
+	IMPORT_C void WaitForKey(TRequestStatus& aStatus);
+	IMPORT_C void WaitForKeyCancel();
+	IMPORT_C TUint KeyCode() const;
+	IMPORT_C TUint KeyModifiers() const;
+	IMPORT_C TInt CaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers);
+	IMPORT_C void CaptureKeyL(TUint aKeyCode, TUint aModifierMask, TUint aModifiers);
+	IMPORT_C TInt CancelCaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers);
+	IMPORT_C TInt CaptureAllKeys();
+	IMPORT_C void CaptureAllKeysL();
+	IMPORT_C TInt CancelCaptureAllKeys();
+public:
+	class TConsoleKey
+		{
+	public:
+		TUint iKeyCode;
+		TUint iModifiers;
+		};
+private:
+	TPckgBuf<TConsoleKey> iKeyBuf;
+	};
+
+class RIoWriteHandle : public RIoReadWriteHandle
+	{
+public:
+	IMPORT_C TInt Create(RIoSession& aSession);
+	IMPORT_C void CreateL(RIoSession& aSession);
+	IMPORT_C TInt Open(RIoSession& aSession);
+	IMPORT_C void OpenL(RIoSession& aSession);
+	IMPORT_C TInt Open(RIoSession& aSession, TThreadId aThreadId);
+	IMPORT_C void OpenL(RIoSession& aSession, TThreadId aThreadId);
+	IMPORT_C TInt Duplicate(RIoWriteHandle& aWriteHandle);
+	IMPORT_C void DuplicateL(RIoWriteHandle& aWriteHandle);
+	IMPORT_C TInt DuplicateHandleFromThread(TThreadId aThreadId);
+	IMPORT_C TInt Write(const TDesC& aDes);
+	IMPORT_C void WriteL(const TDesC& aDes);
+	IMPORT_C void Write(const TDesC& aDes, TRequestStatus& aStatus);
+	IMPORT_C void WriteCancel();
+	};
+
+class RIoConsoleWriteHandle : public RIoWriteHandle
+	{
+public:
+	IMPORT_C RIoConsoleWriteHandle();
+	IMPORT_C RIoConsoleWriteHandle(RIoWriteHandle& aHandle);
+	IMPORT_C RIoConsoleWriteHandle operator=(RIoWriteHandle& aHandle);
+	IMPORT_C TInt GetCursorPos(TPoint& aPos) const;
+	IMPORT_C TPoint GetCursorPosL() const;
+	IMPORT_C TInt SetCursorPosAbs(const TPoint& aPos);
+	IMPORT_C void SetCursorPosAbsL(const TPoint& aPos);
+	IMPORT_C TInt SetCursorPosRel(const TPoint& aPos);
+	IMPORT_C void SetCursorPosRelL(const TPoint& aPos);
+	IMPORT_C TInt SetCursorHeight(TInt aPercentage);
+	IMPORT_C void SetCursorHeightL(TInt aPercentage);
+	IMPORT_C TInt SetTitle(const TDesC& aTitle);
+	IMPORT_C void SetTitleL(const TDesC& aTitle);
+	IMPORT_C TInt ClearScreen();
+	IMPORT_C void ClearScreenL();
+	IMPORT_C TInt ClearToEndOfLine();
+	IMPORT_C void ClearToEndOfLineL();
+	IMPORT_C TInt GetScreenSize(TSize& aSize) const;
+	IMPORT_C TSize GetScreenSizeL() const;
+	IMPORT_C TInt SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor = ConsoleAttributes::EUnchanged, ConsoleAttributes::TColor aBackgroundColor = ConsoleAttributes::EUnchanged);
+	IMPORT_C void SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor = ConsoleAttributes::EUnchanged, ConsoleAttributes::TColor aBackgroundColor = ConsoleAttributes::EUnchanged);
+	IMPORT_C TInt SetAttributes(const ConsoleAttributes::TAttributes& aAttributes);
+	IMPORT_C TInt SetIsStdErr(TBool aFlag);
+	};
+
+class RIoEndPoint : public RIoHandle
+	{
+public:
+	enum TReadMode
+		{
+		EForeground,
+		EBackground
+		};
+public:
+	IMPORT_C TInt Attach(RIoReadHandle& aReader, TReadMode aMode);
+	IMPORT_C void AttachL(RIoReadHandle& aReader, TReadMode aMode);
+	IMPORT_C TInt Attach(RIoWriteHandle& aWriter);
+	IMPORT_C void AttachL(RIoWriteHandle& aWriter);
+	IMPORT_C TInt SetForegroundReadHandle(RIoReadHandle& aReader);
+	IMPORT_C void SetForegroundReadHandleL(RIoReadHandle& aReader);
+	IMPORT_C RIoEndPoint();
+	};
+
+class RIoPipe : public RIoEndPoint
+	{
+public:
+	IMPORT_C TInt Create(RIoSession& aSession);
+	IMPORT_C void CreateL(RIoSession& aSession);
+	};
+
+class RIoConsole : public RIoEndPoint
+	{
+public:
+	enum TOptions
+		{
+		ENormal		= 0,
+		ELazyCreate	= 0x01,
+		};
+public:
+	IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal);
+	IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal);
+	IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal);
+	IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aImplementation, RIoConsole& aUnderlyingConsole, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal);
+	IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal);
+	IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aImplementation, RIoConsole& aUnderlyingConsole, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal);
+	IMPORT_C TInt Open(RIoSession& aSession, RIoHandle& aHandle);
+	IMPORT_C void OpenL(RIoSession& aSession, RIoHandle& aHandle);
+	IMPORT_C TInt Implementation(TDes& aDes) const;
+	IMPORT_C void ImplementationL(TDes& aDes) const;
+	};
+	
+class RIoPersistentConsole : public RIoConsole
+	{
+public:
+	enum TCloseBehaviour
+		{
+		EDetachOnHandleClose,
+		EKeepAttachedOnHandleClose,
+		};
+public:
+	IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aName, const TDesC& aTitle);
+	IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aName, const TDesC& aTitle);
+	
+	IMPORT_C TInt OpenByName(RIoSession& aSession, const TDesC& aName);
+	IMPORT_C void OpenByNameL(RIoSession& aSession, const TDesC& aName);
+	
+	IMPORT_C TInt AttachReader(RIoEndPoint& aEndPoint, TCloseBehaviour aDetachOnClose);
+	IMPORT_C void AttachReaderL(RIoEndPoint& aEndPoint, TCloseBehaviour aDetachOnClose);
+	IMPORT_C void DetachReader();
+	IMPORT_C void NotifyReaderDetach(TRequestStatus& aStatus);
+	IMPORT_C void CancelNotifyReaderDetach(TRequestStatus& aStatus);
+
+	IMPORT_C TInt AttachWriter(RIoEndPoint& aEndPoint, TCloseBehaviour aDetachOnClose);
+	IMPORT_C void AttachWriterL(RIoEndPoint& aEndPoint, TCloseBehaviour aDetachOnClose);
+	IMPORT_C void DetachWriter();
+	IMPORT_C void NotifyWriterDetach(TRequestStatus& aStatus);
+	IMPORT_C void CancelNotifyWriterDetach(TRequestStatus& aStatus);
+	
+	IMPORT_C TInt GetAttachedReaderAndWriterNames(TName& aReaderName, TName& aWriterName);
+	IMPORT_C void GetAttachedReaderAndWriterNamesL(TName& aReaderName, TName& aWriterName);
+	
+	IMPORT_C TInt GetCreator(TThreadId& aThreadId);
+	IMPORT_C TThreadId GetCreatorL();
+	};
+
+class RIoFile : public RIoEndPoint
+	{
+public:
+	enum TMode
+		{
+		ERead,
+		EOverwrite,
+		EAppend
+		};
+public:
+	IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aFileName, TMode aMode);
+	IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aFileName, TMode aMode);
+	};
+
+class RIoNull : public RIoEndPoint
+	{
+public:
+	IMPORT_C TInt Create(RIoSession& aSession);
+	IMPORT_C void CreateL(RIoSession& aSession);
+	};
+
+// Convenience class to wrap up a set of stdin, stdout, stderr handles
+class TIoHandleSet
+	{
+public:
+	IMPORT_C TIoHandleSet(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr);
+	IMPORT_C RIoSession& IoSession() const;
+	IMPORT_C RIoReadHandle& Stdin() const;
+	IMPORT_C RIoWriteHandle& Stdout() const;
+	IMPORT_C RIoWriteHandle& Stderr() const;
+private:
+	RIoSession& iIoSession;
+	RIoReadHandle& iStdin;
+	RIoWriteHandle& iStdout;
+	RIoWriteHandle& iStderr;
+	TUint32 iSpare;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/inc/iocons.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,61 @@
+// iocons.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32cons.h>
+#include <fshell/iocli.h>
+#include <fshell/heaputils.h>
+using LtkUtils::RAllocatorHelper;
+
+#ifdef EKA2
+NONSHARABLE_CLASS(CIoConsole)
+#else
+class CIoConsole
+#endif
+	 : public CColorConsoleBase
+	{
+public:
+	CIoConsole(); // Only for use by iocons.dll
+	CIoConsole(RIoConsoleReadHandle& aReadHandle, RIoConsoleWriteHandle& aWriteHandle); // for use by CCommandBase
+
+public: // From CConsoleBase.
+	virtual ~CIoConsole();
+	virtual TInt Create(const TDesC& aTitle, TSize aSize);
+	virtual void Read(TRequestStatus& aStatus);
+	virtual void ReadCancel();
+	virtual void Write(const TDesC& aDes);
+	virtual TPoint CursorPos() const;
+	virtual void SetCursorPosAbs(const TPoint& aPoint);
+	virtual void SetCursorPosRel(const TPoint& aPoint);
+	virtual void SetCursorHeight(TInt aPercentage);
+	virtual void SetTitle(const TDesC& aTitle);
+	virtual void ClearScreen();
+	virtual void ClearToEndOfLine();
+	virtual TSize ScreenSize() const;
+	virtual TKeyCode KeyCode() const;
+	virtual TUint KeyModifiers() const;
+	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+public: // From CColorConsoleBase
+	virtual void SetTextAttribute(TTextAttribute aAttribute);
+
+private:
+	TInt CreateNewConsole(const TDesC& aTitle, TSize aSize);
+	TInt FindClientThreadId(TThreadId& aThreadId);
+	static TBool HeapWalk(TAny* aSelf, RAllocatorHelper::TCellType aCellType, TLinAddr aCellPtr, TInt aCellLength);
+private:
+	RIoSession iIoSession;
+	RIoConsoleReadHandle iReadHandle;
+	RIoConsoleWriteHandle iWriteHandle;
+	RIoConsole iConsole;
+	TInt iHeapCellCount;
+	TAny* iServerAddress;
+	};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/inc/ioutils.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1250 @@
+// ioutils.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __IOUTILS_H__
+#define __IOUTILS_H__
+
+#include <e32std.h>
+#include <e32keys.h>
+#include <e32base.h>
+#include <e32hashtab.h>
+#include <f32file.h>
+#include <fshell/iocli.h>
+#include <fshell/iocons_writer.h>
+#include <fshell/line_editor_observer.h>
+
+class CColorConsoleBase;
+
+namespace IoUtils
+	{
+
+const TUint KEnvironmentProcessSlot		= 15;
+const TUint KDllCommandLineProcessSlot	= 14;
+const TUint KDllNameToLoadProcessSlot	= 13;
+const TUint KPipsCommandNameProcessSlot = 14;
+const TUint KPipsCommandLineProcessSlot = 13;
+
+const TUint KValueTypeBool         		= 0;
+const TUint KValueTypeInt          		= 1;
+const TUint KValueTypeUint         		= 2;
+const TUint KValueTypeString       		= 3;
+const TUint KValueTypeFileName     		= 4;
+const TUint KValueTypeEnum				= 5;
+const TUint KValueTypeReal				= 6;
+const TUint KValueTypeUint64       		= 7;
+const TUint KValueTypeInt64        		= 8;
+const TUint KValueTypeFlagLast	 		= 0x20000000;	///< Tag this argument as the last one that this command handles. Can only be used with string arguments. Causes the remainder of the command line to be written to the string.
+const TUint KValueTypeFlagOptional 		= 0x40000000;	///< Tag this argument being optional. The command should handle the fact that the corresponding variable may not have been initialised (e.g. by calling RCommandArgumentList::IsPresent).
+
+enum TCmdBasePanic
+	{
+	ENoEnvironment = 0,
+	EInvalidCommandOptionType = 1,
+	EInvalidCommandArgumentType = 2,
+	EIncorrectCommandOptionType1 = 3,
+	EIncorrectCommandOptionType2 = 4,
+	EIncorrectCommandOptionType3 = 5,
+	EIncorrectCommandOptionType4 = 6,
+	EIncorrectCommandOptionType5 = 7,
+	EIncorrectCommandOptionType6 = 8,
+	EIncorrectCommandOptionType7 = 9,
+	EIncorrectCommandOptionType8 = 10,
+	EIncorrectCommandOptionType9 = 11,
+	EIncorrectCommandOptionType10 = 12,
+	EIncorrectCommandOptionType11 = 13,
+	ERFsNotConnected = 14,
+	EAutoAborterAlreadyActive = 15,
+	EInvalidArgumentIndex = 16,
+	EDuplicateShortOptionName = 17,
+	EUnused9 = 18,
+	ENoStaticCommand = 19,
+	EAlreadyCompleted = 20,
+	EInvalidUseOfEnum = 21,
+	EUnused10 = 22,
+	ECifSubCommandParentNotFound = 23,
+	EEnumValueContainsSpace = 24,
+	ENonOptionalArgumentFollowsOptionalArgument = 25,
+	EArgumentFollowsMultipleArgument = 26,
+	EActiveObjectRunLNotOverridden = 27,
+	EActiveObjectDoCancelNotOverridden = 28,
+	ENotYetComplete = 29,
+	EUnused1 = 30,
+	EUnused2 = 31,
+	EUnused3 = 32,
+	EUnused4 = 33,
+	EUnused5 = 34,
+	EUnused6 = 35,
+	EUnused7 = 36,
+	EUnused8 = 37,
+	EEnvVarNotFound1 = 38,
+	EEnvVarNotFound2 = 39,
+	EOptionTaggedAsLast = 40,
+	ELastArgNotStringType = 41,
+	ENoFactory = 42,
+	EUnexpectedAsyncCommand = 43,
+	EUnused11 = 44,
+	ELastArgMultiple = 45,
+	EEnumValueOutOfRange = 46,
+	EEnumDescriptionMissing = 47,
+	EValueTypeAlreadySet = 48,
+	EValueDescriptionAlreadySet = 49,
+	EEnumValueListAlreadySet = 50,
+	EEnumDescriptionListAlreadySet = 51,
+	EIncompleteArgumentOrOptionInitialization = 52,
+	};
+
+class CCommandBase;
+class CReaderChangeNotifier;
+class CCommandCompleter;
+class MLineReader;
+
+
+class TOverflowTruncate : public TDes16Overflow
+	{
+public:
+	virtual void Overflow(TDes16&) {}
+	};
+
+class TOverflowTruncate8 : public TDes8Overflow
+	{
+public:
+	virtual void Overflow(TDes8&) {}
+	};
+
+class TOverflowLeave : public TDes16Overflow
+	{
+public:
+	virtual void Overflow(TDes16&) { User::Leave(KErrOverflow); }
+	};
+
+class TOverflowLeave8 : public TDes8Overflow
+	{
+public:
+	virtual void Overflow(TDes8&) { User::Leave(KErrOverflow); }
+	};
+
+class TFileName2 : public TFileName
+	{
+public:
+	enum TType
+		{
+		EFile,
+		EDirectory
+		};
+public:
+	IMPORT_C TFileName2();
+	IMPORT_C TFileName2(TType aType);
+	IMPORT_C TFileName2(const TDesC& aName);
+	IMPORT_C TFileName2(const TDesC& aName, TType aType);
+	IMPORT_C TBool IsAbsolute() const;
+	IMPORT_C TBool IsDriveLetter() const;
+	IMPORT_C TBool IsDriveRoot() const;
+	IMPORT_C TBool IsWild() const;
+	IMPORT_C TBool IsFile() const;
+	IMPORT_C TBool IsDir() const;
+	IMPORT_C TBool HasDriveLetter() const;
+	IMPORT_C TBool HasLeadingSlash() const;
+	IMPORT_C TBool HasTrailingSlash() const;
+	IMPORT_C TPtrC Drive() const;
+	IMPORT_C TPtrC Path() const;
+	IMPORT_C TPtrC DriveAndPath() const;
+	IMPORT_C TPtrC Name() const;
+	IMPORT_C TPtrC Ext() const;
+	IMPORT_C TPtrC NameAndExt() const;
+	IMPORT_C void SetL(const TFileName2& aName);
+	IMPORT_C void SetTypeL(TType aType);
+	IMPORT_C void SetTypeL(RFs& aFs);
+	IMPORT_C void SetDriveL(const TDesC& aDrive);
+	IMPORT_C void SetPathL(const TDesC& aPath);
+	IMPORT_C void SetNameL(const TDesC& aName);
+	IMPORT_C void SetExtL(const TDesC& aExt);
+	IMPORT_C void SetNameAndExtL(const TDesC& aNameAndExt);
+	IMPORT_C void PrependL(const TFileName2& aName);
+	IMPORT_C void AppendComponentL(const TFileName2& aName);
+	IMPORT_C void AppendComponentL(const TDesC& aPathComponent, TType aPathComponentType);
+	IMPORT_C void AppendComponentL(const TEntry& aEntry);
+	IMPORT_C void SplitL(RArray<TFileName2>& aOutput);
+	IMPORT_C void UnsplitL(const RArray<TFileName2>& aInput);
+	IMPORT_C void MakeAbsoluteL(const TFileName2& aAbsoluteTo);
+	IMPORT_C void MakeAbsoluteL(RFs& aFs); // Make absolute relative to aFs's session path
+	IMPORT_C TBool Exists(RFs& aFs) const;
+	IMPORT_C TBool IsReadOnlyL(RFs& aFs) const;
+	IMPORT_C TBool IsHiddenL(RFs& aFs) const;
+	IMPORT_C TBool IsSystemL(RFs& aFs) const;
+	IMPORT_C TBool IsDirL(RFs& aFs) const;
+	IMPORT_C TBool IsArchiveL(RFs& aFs) const;
+	IMPORT_C void SetIsDirectoryL(); // Ensure the descriptor ends in a slash
+	IMPORT_C TInt FindFile(RFs& aFs);
+	IMPORT_C void FindFileL(RFs& aFs);
+private:
+	void CheckSpaceL(TInt aLengthToAdd) const;
+private:
+	TType iType;
+	};
+
+
+enum TAlignment
+	{
+	EUnaligned,
+	EColumnAlignedLeft,
+	EColumnAlignedRight
+	};
+
+enum TTabMode
+	{
+	EWrapLastColumn,
+	ETruncateLongestColumn,
+	EIgnoreAvailableWidth,
+	};
+
+NONSHARABLE_CLASS(CTextBuffer) : public CActive
+	{
+public:
+	IMPORT_C static CTextBuffer* NewL(TInt aExpandSize);
+	IMPORT_C static CTextBuffer* NewLC(TInt aExpandSize);
+	IMPORT_C ~CTextBuffer();
+	IMPORT_C virtual void Zero();
+	IMPORT_C virtual void Reset();
+	IMPORT_C virtual void ResetText();
+	IMPORT_C void SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor = ConsoleAttributes::EUnchanged, ConsoleAttributes::TColor aBackgroundColor = ConsoleAttributes::EUnchanged);
+	IMPORT_C void SetAttributesL(const ConsoleAttributes::TAttributes& aAttributes);
+	IMPORT_C void GetCurrentAttributes(TUint& aAttributes, ConsoleAttributes::TColor& aForegroundColor, ConsoleAttributes::TColor& aBackgroundColor) const;
+	IMPORT_C void GetAttributes(TInt aPos, TUint& aAttributes, ConsoleAttributes::TColor& aForegroundColor, ConsoleAttributes::TColor& aBackgroundColor) const;
+	IMPORT_C void AppendL(const TChar& aChar);
+	IMPORT_C void AppendL(const TDesC16& aText);
+	IMPORT_C void AppendL(const TDesC8& aText);
+	IMPORT_C void AppendL(const CTextBuffer& aText);
+	IMPORT_C void AppendL(const CTextBuffer& aText, TInt aPosition);
+	IMPORT_C void AppendL(const CTextBuffer& aText, TInt aPosition, TInt aLength);
+	IMPORT_C void AppendFormatL(TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C void AppendFormatL(TRefByValue<const TDesC8> aFmt, ...);
+	IMPORT_C void AppendFormatListL(const TDesC16& aFmt, VA_LIST& aList);
+	IMPORT_C void AppendFormatListL(const TDesC8& aFmt, VA_LIST& aList);
+	IMPORT_C void AppendHumanReadableSizeL(TInt aSize);
+	IMPORT_C void AppendHumanReadableSizeL(TInt64 aSize);
+	IMPORT_C void AppendHumanReadableSizeL(TInt aSize, TAlignment aAlignment);
+	IMPORT_C void AppendHumanReadableSizeL(TInt64 aSize, TAlignment aAlignment);
+	IMPORT_C void AppendSpacesL(TInt aCount);
+	IMPORT_C void Delete(TInt aPos, TInt aLength);
+	IMPORT_C TInt Length() const;
+	IMPORT_C const TDesC& Descriptor() const;
+	IMPORT_C const TDesC& Descriptor(TInt aPos, TInt aLength) const;
+	IMPORT_C TPtrC8 Collapse();
+	IMPORT_C TInt Write(RIoWriteHandle& aWriteHandle) const;
+	IMPORT_C void Write(RIoWriteHandle& aWriteHandle, TRequestStatus& aStatus) const;
+	IMPORT_C TInt Write(RIoWriteHandle& aWriteHandle, TInt aPosition, TInt aLength) const;
+	IMPORT_C void Write(RIoWriteHandle& aWriteHandle, TInt aPosition, TInt aLength, TRequestStatus& aStatus) const;
+protected:
+	CTextBuffer();
+	void ConstructL(TInt aExpandSize);
+private:
+	void NextBlock(TInt& aBlockIndex, const TDesC*& aText, TUint& aAttributes, ConsoleAttributes::TColor& aForegroundColor, ConsoleAttributes::TColor& aBackgroundColor) const;
+	void AsyncWriteNextBlock() const;
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	class TAttributes
+		{
+	public:
+		TAttributes(TInt aPosition, TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor);
+		TBool Matches(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor) const;
+	public:
+		TInt iPosition;
+		ConsoleAttributes::TAttributes iAttributes;
+		};
+private:
+	CBufBase* iBuf;
+	mutable TPtrC iPtr;
+	HBufC* iScratchBuf;
+	HBufC8* iScratchBuf8;
+	RArray<TAttributes> iAttributes;
+	mutable RIoConsoleWriteHandle iConsoleWriteHandle; // Not owned.
+	mutable TInt iAsyncBlockIndex;
+	mutable TInt iAsyncWritePos;
+	mutable TInt iAsyncWriteStartPos;
+	mutable TInt iAsyncWriteLength;
+	mutable TPtrC iAsyncWritePtr;
+	mutable TRequestStatus* iWriteStatus;
+	};
+
+
+NONSHARABLE_CLASS(CTextFormatter) : public CTextBuffer
+	{
+public:
+	IMPORT_C static CTextFormatter* NewL(TInt aAvailableWidth);
+	IMPORT_C static CTextFormatter* NewLC(TInt aAvailableWidth);
+	IMPORT_C static CTextFormatter* NewL(RIoConsoleWriteHandle& aConsoleWriteHandle);
+	IMPORT_C static CTextFormatter* NewLC(RIoConsoleWriteHandle& aConsoleWriteHandle);
+	IMPORT_C ~CTextFormatter();
+	IMPORT_C virtual void Zero();
+	IMPORT_C virtual void Reset();
+	IMPORT_C virtual void ResetText();
+	IMPORT_C void WrapL(TInt aIndent, const TDesC& aText);
+	IMPORT_C void WrapL(TInt aStartPosition, TInt aIndent, const TDesC& aText);
+	IMPORT_C void TabulateL(TInt aIndent, TInt aGap, const TDesC& aText);
+	IMPORT_C void TabulateL(TInt aIndent, TInt aGap, const TDesC& aText, TTabMode aMode);
+	IMPORT_C void ColumnizeL(TInt aIndent, TInt aGap, const TDesC& aText);
+	IMPORT_C void ColumnizeL(TInt aIndent, TInt aGap, const TArray<TPtrC>& aItems);
+	IMPORT_C void AppendPodL(const TDesC& aPod);
+	IMPORT_C TInt Write();
+private:
+	CTextFormatter(TInt aAvailableWidth);
+	void ConstructL();
+	void DoAppendPodL(const TDesC& aPod);
+	void DecodeInteriorPodSequencesL(const TDesC& aPod, CTextBuffer& aBuffer) const;
+	TBool NextColumn(TLex& aLex, TPtrC& aPtr) const;
+	TBool NextLine(TLex& aLex, TPtrC& aPtr) const;
+	TInt ActualLength(const TDesC& aPod) const;
+private:
+	TInt iAvailableWidth;
+	RIoConsoleWriteHandle* iWriteHandle;
+	TBool iAttributesSupported;
+	};
+
+
+NONSHARABLE_CLASS(CEnvironment) : public CBase
+	{
+public:
+	IMPORT_C static CEnvironment* NewL();
+	IMPORT_C static CEnvironment* NewL(const CEnvironment& aEnv);
+	IMPORT_C ~CEnvironment();
+	IMPORT_C void SetL(const TDesC& aKey, TInt aValue);
+	IMPORT_C void SetL(const TDesC& aKey, const TDesC& aValue);
+	IMPORT_C TInt GetAsInt(const TDesC& aKey) const;
+	IMPORT_C TInt GetAsIntL(const TDesC& aKey) const;
+	IMPORT_C const TDesC& GetAsDes(const TDesC& aKey) const;
+	IMPORT_C const TDesC& GetAsDesL(const TDesC& aKey) const;
+	IMPORT_C TInt Remove(const TDesC& aKey);
+	IMPORT_C void RemoveL(const TDesC& aKey);
+	IMPORT_C void RemoveAll(); // Doesn't remove anything in parent env
+	IMPORT_C void InternalizeL(const TDesC8& aDes);
+	IMPORT_C HBufC8* ExternalizeLC() const;
+	IMPORT_C TBool IsDefined(const TDesC& aKey) const;
+	IMPORT_C TBool IsInt(const TDesC& aKey) const;
+	IMPORT_C TBool IsDes(const TDesC& aKey) const;
+	IMPORT_C TInt Count() const;
+	IMPORT_C void GetKeysL(RPointerArray<HBufC>& aResult) const;
+	IMPORT_C void SetPwdL(const TDesC& aPwd);
+	IMPORT_C const TDesC& Pwd() const;
+	IMPORT_C TChar EscapeChar() const;
+	IMPORT_C void SetLocalL(const TDesC& aKey);
+	IMPORT_C CEnvironment* CreateSharedEnvironmentL();
+private:
+	CEnvironment();
+	CEnvironment(CEnvironment* aParentEnv);
+	void ConstructL();
+	void WaitLC() const;
+	static void Signal(TAny* aSelf);
+	void Lock() const;
+	void Unlock() const;
+	void CopyL(const CEnvironment& aEnv);
+	HBufC* Get(const TDesC& aKey) const;
+	HBufC* GetL(const TDesC& aKey) const;
+private:
+	TUint32 iVarsImpl[14];
+	mutable RMutex iLock;
+	CEnvironment* iParentEnv;
+	};
+
+
+class MCommandBaseObserver
+	{
+public:
+	virtual void HandleCommandComplete(CCommandBase& aCommand, TInt aError) = 0;
+	};
+
+class TEnum
+	{
+public:
+	IMPORT_C TEnum();
+	IMPORT_C TEnum(const TDesC& aEnumValueList);
+	IMPORT_C TEnum(const TDesC& aEnumValueList, const TDesC& aEnumDescriptionList);
+	IMPORT_C TInt Parse(const TDesC& aString, TInt& aValue);
+	IMPORT_C TInt ParseL(const TDesC& aString);
+	IMPORT_C const TDesC& ValueList() const;
+	IMPORT_C const TDesC& DescriptionList() const;
+	IMPORT_C void AppendValuesL(CTextBuffer& aBuf) const;
+	IMPORT_C const TPtrC GetString(TInt aIndex) const;
+	IMPORT_C void SetValueList(const TDesC& aValueList);
+	IMPORT_C void SetDescriptionList(const TDesC& aDescriptionList);
+	IMPORT_C void operator=(const TEnum& aEnum);
+private:
+	void ValidateValues() const;
+	TInt GetMatches(const TDesC& aString, RArray<TInt>& aMatches, TInt& aExactMatch);
+private:
+	TPtrC iEnumValueList;
+	TPtrC iEnumDescriptionList;
+	};
+
+class TValue
+	{
+public:
+	IMPORT_C const TDesC& Name() const;
+	IMPORT_C TUint Type() const;
+	IMPORT_C TBool AcceptsMultiple() const;
+	IMPORT_C const TDesC& EnvVar() const;
+	IMPORT_C void* ValuePtr() const;
+	IMPORT_C const TDesC& EnumValueList() const;
+
+	TValue(TUint aValueType, void* aValuePointer, const TDesC& aName);
+	TValue(TUint aValueType, void* aValuePointer, const TDesC& aName, const TDesC& aDescription, const TDesC& aEnvVar = KNullDesC);
+	TValue(TUint aValueType, const TDesC& aEnumValueList, const TDesC& aEnumDescriptionList, void* aValuePointer, const TDesC& aName, const TDesC& aDescription, const TDesC& aEnvVar = KNullDesC);
+	TUint ValueType() const;
+	void SetValue();
+	void SetValueL(TInt aInt);
+	void SetValueL(TInt64 aInt);
+	void SetValueL(TUint aUint);
+	void SetValueL(TUint64 aUint);
+	void SetValueL(TReal64 aReal);
+	void SetValueL(HBufC* aString);
+	void SetValueL(const TFileName2& aFileName, RFs& aFs);
+	void SetEnumValues(const TEnum& aEnum);
+	TBool IsSet() const;
+	const TDesC& EnumDescriptionList() const;
+	const TDesC& Description() const;
+	TPtrC AsString() const;
+	void AppendEnumValuesL(CTextBuffer& aBuf) const;
+	void Combine(const TValue& aValue);
+protected:
+	TUint iValueType;
+	void* iValue;
+	TBool iIsSet;
+	TPtrC iEnvVar;
+	TEnum iEnum;
+	const TPtrC iName;
+	TPtrC iDescription;
+	};
+
+
+class TCommandOption : public TValue
+	{
+public:
+	TCommandOption(TUint aValueType, void* aValuePointer, const TDesC& aLongName);
+	TCommandOption(TUint aValueType, void* aValuePointer, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aEnvVar = KNullDesC);
+	TCommandOption(void* aValuePointer, TUint aValueType, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aEnvVar = KNullDesC);
+	TChar ShortName() const;
+	void Combine(const TCommandOption& aOption);
+private:
+	TChar iShortName;
+	};
+
+
+class RCommandOptionList
+	{
+public:
+	// Use these APIs to only partially declare options in C++ code, and to have the remaining details (e.g. documentation) read from a Command Info File (CIF).
+	IMPORT_C void AppendBoolL(TBool& aBool, const TDesC& aLongName);
+	IMPORT_C void AppendBoolL(RArray<TBool>& aBools, const TDesC& aLongName);
+	IMPORT_C void AppendIntL(TInt& aInt, const TDesC& aLongName);
+	IMPORT_C void AppendIntL(RArray<TInt>& aInts, const TDesC& aLongName);
+	IMPORT_C void AppendIntL(TInt64& aInt, const TDesC& aLongName);
+	IMPORT_C void AppendIntL(RArray<TInt64>& aInts, const TDesC& aLongName);
+	IMPORT_C void AppendUintL(TUint& aUint, const TDesC& aLongName);
+	IMPORT_C void AppendUintL(RArray<TUint>& aUints, const TDesC& aLongName);
+	IMPORT_C void AppendUintL(TUint64& aUint, const TDesC& aLongName);
+	IMPORT_C void AppendUintL(RArray<TUint64>& aUints, const TDesC& aLongName);
+	IMPORT_C void AppendRealL(TReal64& aReal, const TDesC& aLongName);
+	IMPORT_C void AppendRealL(RArray<TReal64>& aReals, const TDesC& aLongName);
+	IMPORT_C void AppendStringL(HBufC*& aBuf, const TDesC& aLongName);
+	IMPORT_C void AppendStringL(RPointerArray<HBufC>& aBufs, const TDesC& aLongName);
+	IMPORT_C void AppendFileNameL(TFileName2& aFileName, const TDesC& aLongName);
+	IMPORT_C void AppendFileNameL(RArray<TFileName2>& aFileNames, const TDesC& aLongName);
+	IMPORT_C void AppendEnumL(TInt& aEnum, const TDesC& aLongName);
+	IMPORT_C void AppendEnumL(TInt& aEnum, const TDesC& aLongName, const TDesC& aCommaSeparatedValueList);
+	IMPORT_C void AppendEnumL(RArray<TInt>& aEnum, const TDesC& aLongName); // Be sure to pass an actual RArray<TInt>& here, not an RArray<TSomeEnum>&. Internally, CCommandBase casts whatever you pass in to an RArray<TInt> and this is a specialized template withe a different memory layout to the general version.
+	IMPORT_C void AppendEnumL(RArray<TInt>& aEnum, const TDesC& aLongName, const TDesC& aCommaSeparatedValueList); // Be sure to pass an actual RArray<TInt>& here, not an RArray<TSomeEnum>&. Internally, CCommandBase casts whatever you pass in to an RArray<TInt> and this is a specialized template withe a different memory layout to the general version.
+
+	// Use these APIs to fully declare options in C++ code.
+	IMPORT_C void AppendBoolL(TBool& aBool, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendBoolL(RArray<TBool>& aBools, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendIntL(TInt& aInt, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendIntL(RArray<TInt>& aInts, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendIntL(TInt64& aInt, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendIntL(RArray<TInt64>& aInts, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendUintL(TUint& aUint, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendUintL(RArray<TUint>& aUints, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendUintL(TUint64& aUint, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendUintL(RArray<TUint64>& aUints, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendRealL(TReal64& aReal, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendRealL(RArray<TReal64>& aReals, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendStringL(HBufC*& aBuf, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendStringL(RPointerArray<HBufC>& aBufs, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendFileNameL(TFileName2& aFileName, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendFileNameL(RArray<TFileName2>& aFileNames, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendEnumL(TInt& aEnum, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendEnumL(TInt& aEnum, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendEnumL(RArray<TInt>& aEnum, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC); // Be sure to pass an actual RArray<TInt>& here, not an RArray<TSomeEnum>&. Internally, CCommandBase casts whatever you pass in to an RArray<TInt> and this is a specialized template withe a different memory layout to the general version.
+	IMPORT_C void AppendEnumL(RArray<TInt>& aEnum, TChar aShortName, const TDesC& aLongName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC); // Be sure to pass an actual RArray<TInt>& here, not an RArray<TSomeEnum>&. Internally, CCommandBase casts whatever you pass in to an RArray<TInt> and this is a specialized template withe a different memory layout to the general version.
+
+	IMPORT_C TBool IsPresent(void* aValuePointer) const;
+	IMPORT_C TPtrC AsString(void* aValuePointer) const;
+	void Close();
+	IMPORT_C TInt Count() const;
+	IMPORT_C TCommandOption& operator[](TInt aIndex);
+	IMPORT_C const TCommandOption& operator[](TInt aIndex) const;
+	TInt FindShort(TChar aShortName) const;
+	TInt Find(const TDesC& aLongName) const;
+private:
+	void Validate(const TCommandOption& aOption);
+private:
+	RArray<TCommandOption> iOptions;
+	};
+
+
+class TCommandArgument : public TValue
+	{
+public:
+	TCommandArgument(TUint aValueType, void* aValuePointer, const TDesC& aName);
+	TCommandArgument(TUint aValueType, void* aValuePointer, const TDesC& aName, const TDesC& aDescription, const TDesC& aEnvVar = KNullDesC);
+	TCommandArgument(void* aValuePointer, TUint aValueType, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, const TDesC& aEnvVar = KNullDesC);
+	TBool IsOptional() const;
+	TBool IsLast() const;
+	};
+
+
+class RCommandArgumentList
+	{
+public:
+	// Use these APIs to only partially declare arguments in C++ code, and to have the remaining details (e.g. documentation) read from a Command Info File (CIF).
+	IMPORT_C void AppendIntL(TInt& aInt, const TDesC& aName);
+	IMPORT_C void AppendIntL(RArray<TInt>& aInts, const TDesC& aName);
+	IMPORT_C void AppendIntL(TInt64& aInt, const TDesC& aName);
+	IMPORT_C void AppendIntL(RArray<TInt64>& aInts, const TDesC& aName);
+	IMPORT_C void AppendUintL(TUint& aUint, const TDesC& aName);
+	IMPORT_C void AppendUintL(RArray<TUint>& aUints, const TDesC& aName);
+	IMPORT_C void AppendUintL(TUint64& aUint, const TDesC& aName);
+	IMPORT_C void AppendUintL(RArray<TUint64>& aUints, const TDesC& aName);
+	IMPORT_C void AppendRealL(TReal64& aReal, const TDesC& aName);
+	IMPORT_C void AppendRealL(RArray<TReal64>& aReals, const TDesC& aName);
+	IMPORT_C void AppendStringL(HBufC*& aBuf, const TDesC& aName);
+	IMPORT_C void AppendStringL(RPointerArray<HBufC>& aBufs, const TDesC& aName);
+	IMPORT_C void AppendFileNameL(TFileName2& aFileName, const TDesC& aName);
+	IMPORT_C void AppendFileNameL(RArray<TFileName2>& aFileNames, const TDesC& aName);
+	IMPORT_C void AppendEnumL(TInt& aEnum, const TDesC& aName);
+	IMPORT_C void AppendEnumL(TInt& aEnum, const TDesC& aName, const TDesC& aCommaSeparatedValueList);
+	IMPORT_C void AppendEnumL(RArray<TInt>& aEnum, const TDesC& aName); // Be sure to pass an actual RArray<TInt>& here, not an RArray<TSomeEnum>&. Internally, CCommandBase casts whatever you pass in to an RArray<TInt> and this is a specialized template with a different memory layout to the general version.
+	IMPORT_C void AppendEnumL(RArray<TInt>& aEnum, const TDesC& aName, const TDesC& aCommaSeparatedValueList); // Be sure to pass an actual RArray<TInt>& here, not an RArray<TSomeEnum>&. Internally, CCommandBase casts whatever you pass in to an RArray<TInt> and this is a specialized template with a different memory layout to the general version.
+
+	// Use these APIs to fully declare arguments in C++ code.
+	IMPORT_C void AppendIntL(TInt& aInt, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendIntL(RArray<TInt>& aInts, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendIntL(TInt64& aInt, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendIntL(RArray<TInt64>& aInts, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendUintL(TUint& aUint, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendUintL(RArray<TUint>& aUints, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendUintL(TUint64& aUint, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendUintL(RArray<TUint64>& aUints, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendRealL(TReal64& aReal, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendRealL(RArray<TReal64>& aReals, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendStringL(HBufC*& aBuf, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendStringL(RPointerArray<HBufC>& aBufs, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendFileNameL(TFileName2& aFileName, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendFileNameL(RArray<TFileName2>& aFileNames, const TDesC& aName, const TDesC& aDescription, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendEnumL(TInt& aEnum, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendEnumL(TInt& aEnum, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC);
+	IMPORT_C void AppendEnumL(RArray<TInt>& aEnum, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC); // Be sure to pass an actual RArray<TInt>& here, not an RArray<TSomeEnum>&. Internally, CCommandBase casts whatever you pass in to an RArray<TInt> and this is a specialized template with a different memory layout to the general version.
+	IMPORT_C void AppendEnumL(RArray<TInt>& aEnum, const TDesC& aName, const TDesC& aDescription, const TDesC& aCommaSeparatedValueList, const TDesC& aCommaSeparatedDescriptionList, TUint aFlags = 0, const TDesC& aEnvVar = KNullDesC); // Be sure to pass an actual RArray<TInt>& here, not an RArray<TSomeEnum>&. Internally, CCommandBase casts whatever you pass in to an RArray<TInt> and this is a specialized template with a different memory layout to the general version.
+
+	IMPORT_C TBool IsPresent(TInt aIndex) const;
+	IMPORT_C TBool IsPresent(void* aValuePointer) const;
+	IMPORT_C TPtrC AsString(void* aValuePointer) const;
+	void Close();
+	IMPORT_C TInt Count() const;
+	TCommandArgument& operator[](TInt aIndex);
+	IMPORT_C const TCommandArgument& operator[](TInt aIndex) const;
+	IMPORT_C TBool AllSet() const;
+	TInt Find(const TDesC& aName) const;
+private:
+	void Validate(const TCommandArgument& aArgument);
+private:
+	RArray<TCommandArgument> iArguments;
+	};
+
+
+class CCommandInfoFile : public CBase
+	{
+public:
+	IMPORT_C static CCommandInfoFile* NewL(RFs& aFs, const TDesC& aFileName);
+	IMPORT_C static CCommandInfoFile* NewL(RFs& aFs, const CEnvironment& aEnvironment, const TDesC& aCommandName);
+	IMPORT_C ~CCommandInfoFile();
+	IMPORT_C const TDesC& Name() const;
+	IMPORT_C const TDesC& ShortDescription() const;
+	IMPORT_C const TDesC& LongDescription() const;
+	IMPORT_C const TDesC& SeeAlso() const;
+	IMPORT_C const TDesC& Copyright() const;
+	IMPORT_C const RCommandArgumentList& Arguments();
+	IMPORT_C const RCommandOptionList& Options() const;
+	IMPORT_C void AssignL(RCommandArgumentList& aArguments, RCommandOptionList& aOptions) const;
+	IMPORT_C TInt NumSubCommands() const;
+	IMPORT_C const CCommandInfoFile& SubCommand(TInt aIndex) const;
+	IMPORT_C const CCommandInfoFile* SubCommand(const TDesC& aSubCommandName) const;
+private:
+	CCommandInfoFile(const TDesC& aFileName);
+	CCommandInfoFile(CCommandInfoFile& aParent);
+	void ConstructL(RFs& aFs);
+	void ReadFileL(RFs& aFs, const TDesC& aFileName);
+	void ReadDetailsL(TLex& aLex, RFs& aFs, const TDesC& aFileName);
+	void ReadArgumentL(TLex& aLex, const TDesC& aFileName);
+	void ReadOptionL(TLex& aLex, const TDesC& aFileName);
+	void ProcessNewChild();
+	void ProcessInclude(CCommandInfoFile& aChild);
+	void AddSubCommandL(TLex& aNameLex, TLex& aDataLex, RFs& aFs, const TDesC& aFileName);
+	RBuf& NewBuffer();
+private:
+	TFileName iFileName;
+	TPtrC iName;
+	TPtrC iShortDescription;
+	TPtrC iLongDescription;
+	TPtrC iSeeAlso;
+	TPtrC iCopyright;
+	RCommandArgumentList iArguments;
+	RCommandOptionList iOptions;
+	RArray<RBuf> iBufs;
+	RPointerArray<CCommandInfoFile> iChildren;
+	CCommandInfoFile* iParent;
+	CCommandInfoFile* iCurrentChild;
+	TBool iProcessInclude;
+	};
+
+
+class Stringify
+	{
+public:
+	enum TReadMode
+		{
+		EBreakOnComma      = 0x00000001		// The default behaviour is to break on white space. If this flag is set both commas and white space (that are unquoted / escaped) will cause reading of the string to terminate.
+		};
+public:
+	IMPORT_C static const TDesC* Error(TInt aError);
+	IMPORT_C static HBufC* ReadLC(TLex& aLex, const TChar& aEscapeChar);
+	IMPORT_C static HBufC* ReadLC(TLex& aLex, const TChar& aEscapeChar, CCommandBase& aErrorContext);
+	IMPORT_C static HBufC* ReadLC(TLex& aLex, const TChar& aEscapeChar, TUint aReadMode);
+	IMPORT_C static HBufC* ReadLC(TLex& aLex, const TChar& aEscapeChar, CCommandBase& aErrorContext, TUint aReadMode);
+	IMPORT_C static HBufC* WidenLC(const TDesC8& aDes);
+	IMPORT_C static HBufC8* NarrowLC(const TDesC& aDes);
+	IMPORT_C static HBufC* EscapeLC(const TDesC& aDes, const TChar& aEscapeChar);
+	IMPORT_C static HBufC8* EscapeLC(const TDesC8& aDes, const TChar& aEscapeChar);
+private:
+	static HBufC* ReadLC(TLex& aLex, const TChar& aEscapeChar, CCommandBase* aErrorContext, TUint aReadMode);
+	};
+
+class CCommandBase : public CActive
+	{
+public:
+	enum TFlags
+		{
+		EManualComplete			= 0x00000001,
+		ESharableIoSession		= 0x00000002,
+		EReportAllErrors		= 0x00000004,
+		ENotifyStdinChanges		= 0x00000008,
+		//EDeprecated			= 0x00000010,
+		ECompleteOnRunL			= 0x00000020,
+		};
+public:
+	IMPORT_C ~CCommandBase();
+	IMPORT_C TInt RunCommand();
+	IMPORT_C void RunCommandL();
+	IMPORT_C TInt RunCommand(const TDesC* aCommandLine, CEnvironment* aEnv);
+	IMPORT_C void RunCommandL(const TDesC* aCommandLine, CEnvironment* aEnv);
+	IMPORT_C TInt RunCommand(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const TDesC* aCommandLine, CEnvironment* aEnv);
+	IMPORT_C void RunCommandL(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const TDesC* aCommandLine, CEnvironment* aEnv);
+	IMPORT_C void RunCommand(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const TDesC* aCommandLine, CEnvironment* aEnv, MCommandBaseObserver* aObserver);
+	IMPORT_C TUint Flags() const;
+	IMPORT_C void SetFlags(TUint aFlags);
+	IMPORT_C const RFs& Fs() const;
+	IMPORT_C const RFs& FsL() const;
+	IMPORT_C RFs& Fs();
+	IMPORT_C RFs& FsL();
+	IMPORT_C RIoSession& IoSession();
+	IMPORT_C RIoConsoleReadHandle& Stdin();
+	IMPORT_C RIoConsoleWriteHandle& Stdout();
+	IMPORT_C RIoConsoleWriteHandle& Stderr();
+	IMPORT_C void Complete();
+	IMPORT_C void Complete(TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C void Complete(TInt aError);
+	IMPORT_C void Complete(TInt aError, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C void CompleteAsync(TInt aError);
+	IMPORT_C void CompleteAsync(TInt aError, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C CEnvironment& Env();
+	IMPORT_C const CEnvironment& Env() const;
+	IMPORT_C void ReadL(TDes& aData);
+	IMPORT_C void Write(const TDesC& aData);
+	IMPORT_C void Printf(TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C void Printf(TRefByValue<const TDesC8> aFmt, ...);
+	IMPORT_C void PrintError(TInt aError, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C void PrintWarning(TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C void LeaveIfFileExists(const TDesC& aFileName);
+	IMPORT_C void LeaveIfFileNotFound(const TDesC& aFileName);
+	IMPORT_C CConsoleBase* GetConsoleBaseL();
+	IMPORT_C CColorConsoleBase* GetColorConsoleBaseL();
+	IMPORT_C const TDesC* ConsoleImplementation();
+	IMPORT_C void SetErrorReported(TBool aReported);
+	IMPORT_C void StartSupressingErrors();
+	IMPORT_C void StopSupressingErrors();
+	IMPORT_C TBool IsComplete() const;
+	IMPORT_C TInt CompletionReason() const;
+	IMPORT_C virtual void HandleLeave(TInt aError);
+	IMPORT_C virtual const CTextBuffer* GetHelpTextL();
+	IMPORT_C virtual void PrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintErrorList(TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintWarningList(TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C static CCommandBase& Static();
+	IMPORT_C static TBool HaveStatic();
+	IMPORT_C virtual void StdinChange(TUint aChange);
+	IMPORT_C void DisplayHelp();
+	IMPORT_C void PageL(const CTextBuffer& aText);
+	IMPORT_C void PageL(RIoReadHandle& aInput);
+	IMPORT_C TBool UsingCif() const;
+
+public:
+	virtual const TDesC& Name() const = 0;
+	IMPORT_C virtual const TDesC& Description() const;
+protected:
+	IMPORT_C CCommandBase();
+	IMPORT_C CCommandBase(TUint aFlags);
+	IMPORT_C virtual void BaseConstructL();
+	IMPORT_C void CreateEnvironmentL(CEnvironment* aEnv);
+
+protected:
+	virtual void DoRunL() = 0;
+	IMPORT_C virtual void OptionsL(RCommandOptionList& aOptions);
+	IMPORT_C virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	IMPORT_C virtual TInt ParseCommandLine(const TDesC& aCommandLine);
+	IMPORT_C virtual void ParseCommandLineL(const TDesC& aCommandLine);
+	IMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+private:
+	enum TPrivateFlags // Must not exceed 0xffff0000 (KPrivateFlagsMask).
+		{
+		EOwnsEnv					= 0x80000000,
+		EOwnsHandles				= 0x40000000,
+		ETlsSet						= 0x20000000,
+		ECompleted					= 0x10000000,
+		EErrorReported				= 0x08000000,
+		EReadCif                    = 0x04000000,
+		ECifReadFailed              = 0x02000000,
+		EOwnsCif                    = 0x01000000
+		};
+	enum TReadStringOptions
+		{
+		EDisallowLeadingHyphen		= 0x00000001,
+		EIncludeWhiteSpace			= 0x00000002,
+		EBreakOnComma               = 0x00000004	// The default behaviour is to break on white space. If this flag is set both commas and white space (that are unquoted / escaped) will cause reading of the string to terminate.
+		};
+protected:
+	IMPORT_C void SetCif(const CCommandInfoFile& aCif);
+	IMPORT_C const CCommandInfoFile* Cif() const;
+private:
+	void RunCommandL(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const TDesC* aCommandLine, CEnvironment* aEnv, MCommandBaseObserver* aObserver);
+	void RunL(const TDesC& aCommandLine);
+	void SetValueL(TLex& aLex, TValue& aValue);
+	void SetValueFromEnvL(TValue& aValue);
+	void ClearValueL(TValue& aValue);
+	const TDesC* ReadCommandLineLC();
+	void DisplayHelpAndComplete();
+	void DisplayHelpAndComplete(TInt aError, const TDesC& aText);
+	void CreateHandlesL();
+	void UpdateHandlesL();
+	void DoCreateHandlesL(RIoConsole& aConsole, RIoConsoleReadHandle& aStdin, RIoConsoleWriteHandle& aStdout, RIoConsoleWriteHandle& aStderr);
+	HBufC* ReadStringLC(TLex& aLex, TUint aOptions) const;
+	void FormatErrorText(TDes& aDes, TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList) const;
+	void FormatWarningText(TDes& aDes, TRefByValue<const TDesC> aFmt, VA_LIST& aList) const;
+	void CheckNewLine();
+	void FormatEnumL(const TValue& aValue, CTextBuffer& aBuffer) const;
+	void PageL(MLineReader& aLineReader);
+	void DoParseCommandLineL(const TDesC& aCommandLine);
+	TBool CifReadRequired() const;
+	void ReadCifL();
+	void DoReadCifL();
+private:
+	friend class CCommandCompleter;
+	void CompleteCallback(TInt aError);
+protected: // From CActive.
+	IMPORT_C virtual void RunL();
+	IMPORT_C virtual void DoCancel();
+	IMPORT_C virtual TInt RunError(TInt aError);
+protected:
+	RCommandOptionList iOptions;
+	RCommandArgumentList iArguments;
+private:
+	TUint iFlags;
+	CEnvironment* iEnv;
+	MCommandBaseObserver* iObserver;
+	mutable RFs iFs;
+	RIoSession iIoSession;
+	RIoConsoleReadHandle iStdin;
+	RIoConsoleWriteHandle iStdout;
+	RIoConsoleWriteHandle iStderr;
+	TBool iDisplayHelp;
+	TInt iSupressingErrors;
+	HBufC* iConsoleImplementation;
+	HBufC* iConsoleTitle;
+	RArray<TUint> iConsoleSize;
+	TBool* iDeleted;
+	HBufC* iPersistentConsoleName;
+	CCommandCompleter* iCompleter;
+	CReaderChangeNotifier* iReadChangeNotifier;
+	TInt iCompletionReason;
+	CCommandInfoFile* iCif;
+	void* iSpare1;
+	void* iSpare2;
+	void* iSpare3;
+	void* iSpare4;
+	void* iSpare5;
+	};
+
+
+/**
+ * @brief A helper class for creating and running child processes that share 
+ * I/O handles (and hence console and / or redirected file handles) with the parent.
+ *
+ * Note, CreateL just creates the process; it doesn't start its main thread. This
+ * can either be done by calling RChildProcess::Process().Resume() or calling
+ * RChildProcess::Run. Either way it is important that the newly created process
+ * is given a chance to open its I/O handles before RChildProcess::Close is called.
+ * Otherwise the server side objects will be destroyed before it has had a chance
+ * to claim a reference count on them. The easiest way to achieve this is by using
+ * RChildProcess::Run, and waiting until the associated TRequestStatus is completed
+ * before calling RChildProcess::Close. The TRequestStatus will be completed when
+ * the child process exits.
+ */
+class RChildProcess
+	{
+public:
+	IMPORT_C void Close();
+	IMPORT_C void CreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr);
+	IMPORT_C void CreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const CEnvironment& aEnv);
+	IMPORT_C void CreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, RIoSession& aIoSession, RIoConsole& aConsole, const CEnvironment* aEnv);
+	IMPORT_C void Run(TRequestStatus& aStatus);
+	IMPORT_C void Detach();
+	IMPORT_C RProcess& Process();
+	IMPORT_C const RProcess& Process() const;
+private:
+	void NameHandles(const TDesC& aExecutableName, RIoSession& aIoSession);
+	void DoCreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, const CEnvironment* aEnv);
+	void ProcessCreateL(const TDesC& aExecutableName, const TDesC& aCommandLine, const CEnvironment* aEnv);
+private:
+	RProcess iProcess;
+	RIoReadHandle iStdin;
+	RIoWriteHandle iStdout;
+	RIoWriteHandle iStderr;
+	};
+
+IMPORT_C CConsoleBase* NewConsole(); // Only for use by iocons
+IMPORT_C void ReadL(TDes& aData);
+IMPORT_C void Write(const TDesC& aData);
+IMPORT_C void Printf(TRefByValue<const TDesC> aFmt, ...);
+IMPORT_C void Printf(TRefByValue<const TDesC8> aFmt, ...);
+IMPORT_C void PrintError(TInt aError, TRefByValue<const TDesC> aFmt, ...);
+IMPORT_C void PrintWarning(TRefByValue<const TDesC> aFmt, ...);
+
+
+class CServerWatcher;
+class CServerReader;
+class CServerWriter;
+
+/**
+ * @brief The base class for command server client commands.
+ *
+ * Normally, CCommandBase derived objects are run in the context of a separate
+ * process (or possibly thread). This process (or thread) only exists until
+ * the command completes. This makes it difficult of such commands to maintain
+ * state between repeated invokations.
+ *
+ * Command servers are a means of addressing this limitation. They are implemented
+ * as a CCommandBase (actually a CServerBase) sub-class that runs in its own
+ * process. However, the stdin and stdout handles of this command are not attached
+ * directly to a console (or set of pipes) as is normally the case. Instead they are
+ * attached to a persistent console (RIoPersistentConsole). This type of console
+ * allows a real console (or set of pipes) to be transiently connected and then
+ * disconnected without the server command being aware that this has happend. This
+ * allows a client command to temporarily connect to the server command's stdio,
+ * issue a command, and receive a response. This can happen numerous times to a
+ * single server command instance, which allows the server command to maintain
+ * state.
+ *
+ * Generally, server commands implement a set of internal commands that are
+ * themselves CCommandBase (actually CServerCommandBase or CBranchCommandBase)
+ * sub-classes. These are created as required inside the command server process
+ * in response to client command requests.
+ *
+ * There is generally a single sub-class of this class (that is built into an
+ * executable) to interact with a given server command. Its job is to:
+ *
+ * a) Create the server command process if its not already running.
+ * b) Create a pair of pipes that are connected to the server command's
+ *    persistent console.
+ * c) Issue a command to the server (normally read from the command-line of
+ *    this command).
+ * d) Retrieve a response from the server.
+ * e) Possibly parse the server response.
+ * f) Print a result to this command's stdout (which, note, is completely
+ *    independent of the server command's stdout).
+ * g) Exit with an integer value indicating the success or failure of the
+ *    command.
+ *
+ * This base class takes care of (a) - (d). The concrete sub-class is responsible
+ * for (e) - (g).
+ */
+class CClientBase : public CCommandBase
+	{
+protected:
+	IMPORT_C CClientBase(TUint aFlags, const TDesC& aServerExeName, const TDesC& aPersistentConsoleName, const TDesC& aServerPrompt);
+	IMPORT_C ~CClientBase();
+private:
+	virtual void HandleServerResponseL(RPointerArray<HBufC> aLines) = 0;
+private: // From CCommandBase.
+	IMPORT_C virtual void DoRunL();
+	IMPORT_C virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	IMPORT_C virtual void HandleLeave(TInt aError);
+private:
+	friend class CServerWatcher;
+	friend class CServerReader;
+	friend class CServerWriter;
+	void HandleServerReadComplete(TInt aError, TDes& aLine);
+	void HandleServerWriteComplete(TInt aError);
+	void HandleServerDeath(TExitType aExitType, TInt aExitReason, const TDesC& aExitCategory);
+	void SendCommand();
+protected:
+	TBool iVerbose;
+private:
+	const TPtrC iServerExeName;
+	const TPtrC iPersistentConsoleName;
+	const TPtrC iServerPrompt;
+	HBufC* iCommand;
+	RChildProcess iServerProcess;
+	RIoPersistentConsole iPcons;
+	RIoPipe iServerWritePipe;
+	RIoWriteHandle iServerWriteHandle;
+	RIoPipe iServerReadPipe;
+	RIoReadHandle iServerReadHandle;
+	CServerWatcher* iServerWatcher;
+	CServerReader* iServerReader;
+	CServerWriter* iServerWriter;
+	RPointerArray<HBufC> iLines;
+	TBool iWaitingForServerPrompt;
+	};
+
+
+/**
+ * @brief A class used to identify instances of individual commands running inside
+ * a command server (which is a CServerBase sub-class).
+ *
+ * Note, it is up to a suitable sub-class (of usually CBranchCommandBase) to assign
+ * these identifiers via CServerCommandBase::SetId.
+ */
+class TServerCommandId
+	{
+public:
+	IMPORT_C TServerCommandId();
+	IMPORT_C TServerCommandId(TUint aValue);
+	IMPORT_C TUint Value() const;
+	IMPORT_C void Set(const TServerCommandId& aId);
+	IMPORT_C TBool operator==(const TServerCommandId& aId) const;
+private:
+	TUint iId;
+	};
+
+
+/**
+ * @brief An interface used by CServerCommandBase to report information to the server's
+ * user.
+ *
+ * Note, this class is not intended for external derivation. Rather, sub-classes of
+ * CServerBase must provide an implementation of its simplified pure virtual interface
+ * (Report, ReportWarning and ReportError).
+ */
+class MServerCommandReporter
+	{
+public:
+	virtual void Report(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, ...) = 0;
+	virtual void ReportList(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, VA_LIST& aList) = 0;
+	virtual void Report(const TServerCommandId& aId, TRefByValue<const TDesC8> aFmt, ...) = 0;
+	virtual void ReportList(const TServerCommandId& aId, TRefByValue<const TDesC8> aFmt, VA_LIST& aList) = 0;
+	virtual void ReportWarning(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, ...) = 0;
+	virtual void ReportWarningList(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, VA_LIST& aList) = 0;
+	virtual void ReportError(const TServerCommandId& aId, TInt aError, TRefByValue<const TDesC> aFmt, ...) = 0;
+	virtual void ReportErrorList(const TServerCommandId& aId, TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList) = 0;
+	};
+
+
+class CServerCommandFactory;
+
+/**
+ * @brief The base class for command servers.
+ *
+ * Each command server is expected to create one (and only one) sub-class of this class. It is
+ * effectively the root object of the server and is responsible for parsing input received on stdin
+ * and creates corresponding command objects accordingly. Note, all textual responses from the
+ * server's commands are routed through the sub-class of this class via its pure virtual interface.
+ * Note also, only one call to ReportError will be received for a given line read from stdin.
+ */
+class CServerBase : public CCommandBase, public MServerCommandReporter, public MLineEditorObserver
+	{
+public:
+	IMPORT_C ~CServerBase();
+	IMPORT_C void Exit(TInt aError);
+protected:
+	IMPORT_C CServerBase(TUint aFlags, const TDesC& aPrompt, const TDesC& aCommandHistoryFileName);
+	IMPORT_C CServerCommandFactory& Factory();
+	IMPORT_C void CheckNewConsoleLine();
+protected:
+	virtual void InitializeL() = 0;
+	virtual void Report(const TServerCommandId& aId, const TDesC& aDes) = 0;
+	virtual void Report(const TServerCommandId& aId, const TDesC8& aDes) = 0;
+	virtual void ReportWarning(const TServerCommandId& aId, const TDesC& aDes) = 0;
+	virtual void ReportError(const TServerCommandId& aId, TInt aError, const TDesC& aDes) = 0;
+protected: // From CCommandBase.
+	IMPORT_C virtual void BaseConstructL();
+	IMPORT_C virtual void DoRunL();
+	IMPORT_C virtual void PrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintErrorList(TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintWarningList(TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+private: // From MServerCommandReporter.
+	IMPORT_C virtual void Report(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C virtual void ReportList(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void Report(const TServerCommandId& aId, TRefByValue<const TDesC8> aFmt, ...);
+	IMPORT_C virtual void ReportList(const TServerCommandId& aId, TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void ReportWarning(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C virtual void ReportWarningList(const TServerCommandId& aId, TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void ReportError(const TServerCommandId& aId, TInt aError, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C virtual void ReportErrorList(const TServerCommandId& aId, TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+private: // From MLineEditorObserver.
+	IMPORT_C virtual void LeoHandleLine(const TDesC& aLine);
+private:
+	void ParseLineL(const TDesC& aLine);
+	const TDesC& NextLineL();
+private:
+	const TDesC& iPrompt;
+	const TDesC& iCommandHistoryFileName;
+	TBuf<512> iLine;
+	CLineEditor* iLineEditor;
+	CServerCommandFactory* iFactory;
+	TIoConsWriterAdaptor iWriterAdaptor;
+	TBool iLineRead;
+	TBool iExit;
+	TInt iExitReason;
+	TBool iErrorReported;
+	};
+
+
+class CServerCommandConstructor;
+
+/**
+ * @brief The base class for commands that run within a command server.
+ *
+ * A class should be derived from this class for each "leaf" command of
+ * the server. A leaf command is one that doesn't support any sub-commands
+ * (see CBranchCommand for details of commands that do support sub-commands).
+ * Each sub-class must be registered with a CServerCommandFactory object
+ * via the template method AddLeafCommandL.
+ */
+class CServerCommandBase : public CCommandBase
+	{
+public:
+	IMPORT_C virtual ~CServerCommandBase();
+	IMPORT_C const TServerCommandId& Id() const;
+	IMPORT_C void SetId(const TServerCommandId& aId);
+	IMPORT_C void SetFactory(CServerCommandFactory& aFactory);
+protected:
+	IMPORT_C CServerCommandBase();
+	IMPORT_C CServerCommandBase(TUint aFlags);
+	IMPORT_C CServerCommandFactory& Factory();
+private: // From CCommandBase.
+	IMPORT_C virtual void PrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintErrorList(TInt aError, TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+	IMPORT_C virtual void PrintWarningList(TRefByValue<const TDesC> aFmt, VA_LIST& aList);
+private:
+	friend class CServerBase;
+	friend class CServerCommandConstructor;
+	void SetReporter(MServerCommandReporter* aReporter);
+private:
+	TServerCommandId iId;
+	MServerCommandReporter* iReporter;
+	CServerCommandFactory* iFactory;
+	};
+
+
+typedef CServerCommandBase* (*TServerCommandConstructor)();
+
+/**
+ * @brief A helper class for CServerCommandFactory used to store a means of
+ * constructing leaf commands.
+ */
+class CServerCommandConstructor : public CBase
+	{
+public:
+	IMPORT_C static CServerCommandConstructor* NewLC(const TDesC& aName, TServerCommandConstructor aConstructor, CServerCommandFactory& aFactory, MServerCommandReporter* aReporter, const CCommandInfoFile* aCif);
+	IMPORT_C ~CServerCommandConstructor();
+	IMPORT_C const TPtrC& Name() const;
+	IMPORT_C CServerCommandBase* CreateImplementationLC() const;
+	IMPORT_C virtual TBool IsFactory() const;
+protected:
+	CServerCommandConstructor(const TDesC& aName, TServerCommandConstructor aConstructor, CServerCommandFactory& aFactory, MServerCommandReporter* aReporter, const CCommandInfoFile* aCif);
+protected:
+	TPtrC iName;
+	TServerCommandConstructor iConstructorLC;
+	CServerCommandFactory& iFactory;
+	MServerCommandReporter* iReporter;
+	const CCommandInfoFile* iCif;
+	};
+
+
+/**
+ * @brief A class that can be used to manage a hierarchy of commands.
+ */
+class CServerCommandFactory : public CServerCommandConstructor, public MLineCompleter
+	{
+public:
+	IMPORT_C static CServerCommandFactory* NewL(MServerCommandReporter* aReporter, const CCommandInfoFile* aCif);
+	IMPORT_C static CServerCommandFactory* NewLC(const TDesC& aName, TServerCommandConstructor aConstructor, MServerCommandReporter* aReporter, const CCommandInfoFile* aCif);
+	IMPORT_C ~CServerCommandFactory();
+	IMPORT_C const CServerCommandConstructor& GetSubCommandL(const TDesC& aName) const;
+	IMPORT_C virtual TBool IsFactory() const;
+	template <class SubCmnd> inline CServerCommandConstructor& AddLeafCommandL();
+	template <class SubCmnd> inline CServerCommandFactory& AddFactoryCommandL();
+	IMPORT_C void ListCommandsL(RArray<TPtrC>& aList) const;
+private: // From MLineCompleter.
+	virtual void LcCompleteLineL(TConsoleLine& aLine, const TChar& aEscapeChar);
+private:
+	enum TFactoryType
+		{
+		ERoot,
+		EBranch
+		};
+private:
+	CServerCommandFactory(MServerCommandReporter* aReporter, const CCommandInfoFile* aCif);
+	CServerCommandFactory(const TDesC& aName, TServerCommandConstructor aConstructor, MServerCommandReporter* aReporter, const CCommandInfoFile* aCif);
+	void ConstructL(TFactoryType aType);
+	void CompleteLineL(TConsoleLine& aLine, TInt aPos, const RArray<TPtrC> aPossibilities) const;
+	const CServerCommandConstructor* GetSubCommand(const TDesC& aName) const;
+	IMPORT_C void AddSubCommandL(const CServerCommandConstructor* aCommand);
+private:
+	RHashMap<const TPtrC, const CServerCommandConstructor*> iSubCommands;
+	};
+
+
+/**
+ * @brief The base class for commands that support multiple sub-commands.
+ */
+class CBranchCommandBase : public CServerCommandBase
+	{
+public:
+	IMPORT_C virtual ~CBranchCommandBase();
+protected:
+	IMPORT_C CBranchCommandBase();
+	IMPORT_C virtual const TDesC& TypeDescription();
+	IMPORT_C virtual void ConfigureSubCommand(CServerCommandBase& aNewlyConstructedCommand);
+	IMPORT_C virtual void HandleSubCommandComplete(CServerCommandBase& aCommand);
+	IMPORT_C virtual void HandleBackgroundSubCommand(CServerCommandBase& aCommand);
+private:
+	void BuildEnumL();
+private: // From CCommandBase.
+	IMPORT_C virtual void DoRunL();
+	IMPORT_C virtual void ArgumentsL(RCommandArgumentList& aArguments);
+private:
+	IoUtils::CTextBuffer* iSubCommandEnum;
+	HBufC* iSubCommandArgs;
+	TInt iType;
+	};
+
+#include <fshell/ioutils.inl>
+
+	} // Closing namespace brace.
+
+
+#define EXE_BOILER_PLATE(__CLASS_NAME) \
+void MainL()\
+	{\
+	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;\
+	CleanupStack::PushL(scheduler);\
+	CActiveScheduler::Install(scheduler);\
+	IoUtils::CCommandBase* command = __CLASS_NAME::NewLC();\
+	command->RunCommandL();\
+	CleanupStack::PopAndDestroy(2, scheduler);\
+	}\
+\
+GLDEF_C TInt E32Main()\
+	{\
+	__UHEAP_MARK;\
+	TInt err = KErrNoMemory;\
+	CTrapCleanup* cleanup = CTrapCleanup::New();\
+	if (cleanup)\
+		{\
+		TRAP(err, MainL());\
+		delete cleanup;\
+		}\
+	__UHEAP_MARKEND;\
+	return err;\
+	}\
+
+// Note, this used to be a member function of CCommandBase (called "LeaveIfError"). It was changed to a macro to work around
+// a problem with GCCE (version "arm-none-symbianelf-gcc.exe (GCC) 3.4.3 (release) (CodeSourcery ARM Q1C 2005)") whereby 
+// USER-EXEC 3 panics would occur if a leave from a function with variadic parameters took place.
+#define LeaveIfErr(_error, _errorFmtString...) \
+	do \
+		{ \
+		TInt __err = (_error); \
+		if (__err < 0) \
+			{ \
+			this->PrintError(__err, _errorFmtString); \
+			User::Leave(__err); \
+			} \
+		} \
+		while (0)
+
+#define StaticLeaveIfErr(_error, _errorFmtString...) \
+	do \
+		{ \
+		TInt __err = (_error); \
+		if (__err < 0) \
+			{ \
+			if (IoUtils::CCommandBase::HaveStatic()) IoUtils::PrintError(__err, _errorFmtString); \
+			User::Leave(__err); \
+			} \
+		} \
+		while (0)
+
+#define CommandLeaveIfErr(_command, _error, _errorFmtString...) \
+	do \
+		{ \
+		TInt __err = (_error); \
+		if (__err < 0) \
+			{ \
+			(_command).PrintError(__err, _errorFmtString); \
+			User::Leave(__err); \
+			} \
+		} \
+		while (0)
+
+#define TRAPL(leavingFunction, errorFmtString...) { TRAPD(_err, leavingFunction); LeaveIfErr(_err, errorFmtString); }
+#define STRAPL(leavingFunction, errorFmtString...) { TRAPD(_err, leavingFunction); StaticLeaveIfErr(_err, errorFmtString); }
+#define CTRAPL(command, leavingFunction, errorFmtString...) { TRAPD(_err, leavingFunction); CommandLeaveIfErr(command, _err, errorFmtString); }
+#define TRAP_QUIETLY(err, leavingFunction) \
+	if (IoUtils::CCommandBase::HaveStatic()) \
+		{ \
+		IoUtils::CCommandBase::Static().StartSupressingErrors(); \
+		TRAP(err, leavingFunction); \
+		IoUtils::CCommandBase::Static().StopSupressingErrors(); \
+		} \
+	else \
+		{ \
+		TRAP(err, leavingFunction); \
+		}
+		
+#define TRAPD_QUIETLY(_err, leavingFunction) TInt _err = KErrNone; TRAP_QUIETLY(_err, leavingFunction);
+#define TRAP_IGNORE_QUIETLY(leavingFunction) { TRAPD_QUIETLY(_err, leavingFunction); (void)_err; }
+
+#endif // __IOUTILS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/inc/ioutils.inl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,51 @@
+// ioutils.inl
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+template <class SubCmnd> CServerCommandConstructor& CServerCommandFactory::AddLeafCommandL()
+	{
+	CServerCommandConstructor* cmnd;
+	if (iCif)
+		{
+		CServerCommandBase* commandBase = SubCmnd::NewLC();
+		const CCommandInfoFile* cif = iCif->SubCommand(commandBase->Name());
+		CleanupStack::PopAndDestroy(commandBase);
+		cmnd = CServerCommandConstructor::NewLC(SubCmnd::NameS(), &SubCmnd::NewLC, *this, iReporter, cif);
+		}
+	else
+		{
+		cmnd = CServerCommandConstructor::NewLC(SubCmnd::NameS(), &SubCmnd::NewLC, *this, iReporter, NULL);
+		}
+	AddSubCommandL(cmnd);
+	CleanupStack::Pop(cmnd);
+	return *cmnd;
+	}
+	
+template <class SubCmnd> CServerCommandFactory& CServerCommandFactory::AddFactoryCommandL()
+	{
+	CServerCommandFactory* cmnd;
+	if (iCif)
+		{
+		CServerCommandBase* commandBase = SubCmnd::NewLC();
+		const CCommandInfoFile* cif = iCif->SubCommand(commandBase->Name());
+		CleanupStack::PopAndDestroy(commandBase);
+		cmnd = CServerCommandFactory::NewLC(SubCmnd::NameS(), &SubCmnd::NewLC, iReporter, cif);
+		}
+	else
+		{
+		cmnd = CServerCommandFactory::NewLC(SubCmnd::NameS(), &SubCmnd::NewLC, iReporter, NULL);
+		}
+	AddSubCommandL(cmnd);
+	CleanupStack::Pop(cmnd);
+	return *cmnd;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/inc/memoryaccesscmd.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+// memoryaccesscmd.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef MEMORYACCESSCMD_H
+#define MEMORYACCESSCMD_H
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+#include <fshell/memoryaccess.h>
+#endif
+
+namespace IoUtils
+	{
+
+/* CMemoryAccessCommandBase
+ * This class is intended to be used by commands that can make use of memory access but don't
+ * necessarily require it. By deriving from CMemoryAccessCommandBase instead of CCommandBase,
+ * you reduce the number of times "#ifdef FSHELL_MEMORY_ACCESS_SUPPORT" needs sprinkling through
+ * your code. The only bits you need to guard are the bits that use iMemAccess and that call 
+ * LoadMemoryAccessL (although you could trap that instead if you really wanted). No need to 
+ * include memoryaccess.h or close iMemAccess, and you can include this header and derive from
+ * this class unconditionally.
+ */
+
+class CMemoryAccessCommandBase : public CCommandBase
+	{
+public:
+	IMPORT_C CMemoryAccessCommandBase();
+	IMPORT_C CMemoryAccessCommandBase(TUint aFlags);
+
+	IMPORT_C void LoadMemoryAccessL();
+	IMPORT_C ~CMemoryAccessCommandBase();
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+protected:
+	RMemoryAccess iMemAccess;
+#else
+private:
+	// So that we're the same size regardless
+	TUint32 iPadding[3];
+#endif
+	};
+
+	}
+
+#endif // MEMORYACCESSCMD_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/perl/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+..\lib\FShell\TextServerClient.pm	z:\system\perl\lib\FShell\TextServerClient.pm
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/perl/lib/FShell/TextServerClient.pm	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,144 @@
+# TextServerClient.pm
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+package FShell::TextServerClient;
+
+use strict;
+use Carp;
+use Pcons;
+
+sub new {
+        my $proto = shift;
+        my $class = ref($proto) || $proto;
+	my $self = {
+		PCONS_NAME	=> undef,
+		SERVER_PROCESS	=> undef,
+		SERVER_PROMPT	=> 'ok',
+		PCONS_READER	=> undef,
+		PCONS_WRITER	=> undef,
+	};
+	bless ($self, $class);
+	return $self;
+}
+
+sub Connected {
+	my ($self) = @_;
+	return (defined $self->{PCONS_READER}) && (defined $self->{PCONS_WRITER});
+}
+
+sub PconsName {
+	my ($self, $name) = @_;
+	if (defined $name) {
+		croak "Cannot change pcons name while connected" if ($self->Connected());
+		$self->{PCONS_NAME} = $name;
+	}
+	return $self->{PCONS_NAME};
+}
+
+sub ServerProcess {
+	my ($self, $proc) = @_;
+	if (defined $proc) {
+		croak "Cannot set server process while connected" if ($self->Connected());
+		$self->{SERVER_PROCESS} = $proc;
+	}
+	return $self->{SERVER_PROCESS};
+}
+
+sub Disconnect {
+	my ($self) = @_;
+	undef $self->{PCONS_READER};
+	undef $self->{PCONS_WRITER};
+}
+
+sub Connect {
+	my ($self) = @_;
+	croak "Cannot connect to server before process has been set" if (!defined $self->ServerProcess());
+	croak "Cannot connect to server becore persisten console name has been set" if (!defined $self->PconsName());
+	return if (Connected());
+
+	my $reader = Pcons::OpenReader($self->{PCONS_NAME});
+	if (!defined $reader) {
+		$self->{SERVER_PROCESS} =~ s|^\s*||;
+		my ($procName, @procArgs) = split(/\s/, $self->{SERVER_PROCESS});
+		Pcons::Create($self->{PCONS_NAME}, $procName, join(' ', @procArgs)) or croak "Cannot create persistent console $self->{PCONS_NAME} with process $procName: $!";
+		$reader = Pcons::OpenReader($self->{PCONS_NAME}) or croak ("Cannot open pcons reader to '$self->{PCONS_NAME}': $!");
+		$self->WaitPrompt($reader) or croak ("Prompt $self->{SERVER_PROMPT} not received from server");
+	}
+	my $writer = Pcons::OpenWriter($self->{PCONS_NAME});
+	croak ("Cannot open pcons writer to '$self->{PCONS_NAME}': $!") unless defined $writer;
+	$self->{PCONS_WRITER} = $writer;
+	$self->{PCONS_READER} = $reader;
+	return 1;
+}
+
+sub WaitPrompt {
+	my ($self, $reader) = @_;
+	my @lines;
+	$reader = $self->{PCONS_READER} unless defined $reader;
+	while (my $line = <$reader>) {
+		chomp $line;
+		return \@lines if ($line eq $self->{SERVER_PROMPT});
+		push @lines, $line;
+	}
+	return undef;
+}
+
+sub Execute {
+	my ($self, $command) = @_;
+	croak "Not connected to server" unless $self->Connected();
+	croak "No command specified" unless (defined $command);
+	my $writer = $self->{PCONS_WRITER};
+	print $writer "$command\n";
+	return $self->WaitPrompt();
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+FShell::TextServerClient - perl interface to Fshell server commands
+
+=head1 SYNOPSIS
+
+	use FShell::TextServerClient;
+
+	my $client = new Fshell::TextServerClient;
+	$client->PconsName('server_console');
+	$client->ServerProcess('server_executable --arguments');
+	$client->Connect();
+
+	my $output = $client->Execute('command');
+	foreach (@$output) {
+		process_line($_);
+	}
+
+=head1 DESCRIPTION
+
+This module provides a perl interface to FShell command servers, i.e. those FShell commands the derive from
+class C<CServerCommandBase>. This module is analgous to the C++ class C<CClientBase>, providing similar
+functionality in perl.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
+=head1 VERSION
+
+Version 0.01 (April 1st, 2009)
+
+=head1 SEE ALSO
+
+perl(1)
+Pcons
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/config.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,77 @@
+// config.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "config.h"
+#include <fshell/settings.h>
+
+
+// Default values (used if the config file can't be read).
+_LIT(KDefaultConsole, "defcons.dll");
+const TSize KDefaultSizeAdjustment(0, 0);
+
+// Config file details.
+_LIT(KConfigFileName, "\\system\\console\\iosrv.ini");
+_LIT(KConfigDescriptionFile, "\\resource\\iosrv.idf");
+
+// Configuration attributes.
+_LIT(KAttConsole, "console");
+_LIT(KAttConsoleSizeAdjustment, "console_size_adjustment");
+_LIT(KAttConsoleSizeDetect, "console_size_detect");
+
+
+TIoConfig::TIoConfig()
+	: iConsoleImplementation(KDefaultConsole), iConsoleSizeAdjustment(KDefaultSizeAdjustment), iConsoleSizeDetect(ETrue)
+	{
+	}
+
+TInt TIoConfig::Init()
+	{
+	LtkUtils::CIniFile* iniFile = NULL;
+	TRAPD(ret, iniFile = LtkUtils::CIniFile::NewL(KConfigFileName, KConfigDescriptionFile));
+	if (ret == KErrNone) ret = DoInit(iniFile);
+	delete iniFile;
+	return ret;
+	}
+
+TInt TIoConfig::DoInit(LtkUtils::CIniFile* iniFile)
+	{
+	TInt ret = KErrNone;
+	iConsoleImplementation.Copy(iniFile->GetString(KAttConsole).Left(iConsoleImplementation.MaxLength()));
+	iConsoleSizeDetect = iniFile->GetBool(KAttConsoleSizeDetect);
+	const TDesC& sizeAdjust(iniFile->GetString(KAttConsoleSizeAdjustment));
+	if (sizeAdjust.Length())
+		{
+		TLex lex(sizeAdjust);
+		ret = lex.Val(iConsoleSizeAdjustment.iWidth);
+		if (ret) return ret;
+		lex.Get(); // Skip delimiter.
+		ret = lex.Val(iConsoleSizeAdjustment.iHeight);
+		if (ret) return ret;
+		iConsoleSizeDetect = EFalse;
+		}
+	return ret;
+	}
+
+const TDesC& TIoConfig::ConsoleImplementation() const
+	{
+	return iConsoleImplementation;
+	}
+
+const TSize& TIoConfig::ConsoleSizeAdjustment() const
+	{
+	return iConsoleSizeAdjustment;
+	}
+
+TBool TIoConfig::ConsoleSizeDetect() const
+	{
+	return iConsoleSizeDetect;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/config.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// config.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include <e32std.h>
+#include <f32file.h>
+
+namespace LtkUtils
+	{
+	class CIniFile;
+	}
+
+class TIoConfig
+	{
+public:
+	TIoConfig();
+	TInt Init();
+	const TDesC& ConsoleImplementation() const;
+	const TSize& ConsoleSizeAdjustment() const;
+	TBool ConsoleSizeDetect() const;
+private:
+	TInt DoInit(LtkUtils::CIniFile* iniFile);
+
+private:
+	TFileName iConsoleImplementation;
+	TSize iConsoleSizeAdjustment;
+	TBool iConsoleSizeDetect;
+	};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/console.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1394 @@
+// console.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32cons.h>
+#include <e32uid.h>
+#include "server.h"
+#include "console.h"
+#include "log.h"
+
+
+#ifdef IOSRV_LOGGING
+#define CONSOLE_NAME TName consoleName(Name())
+#define READER_NAME(x) TName readerName((x).IorName())
+#define WRITER_NAME(x) TName writerName((x).IowName())
+#else
+#define CONSOLE_NAME
+#define READER_NAME(x)
+#define WRITER_NAME(x)
+#endif
+
+const TInt KConsoleThreadMinHeapSize = 0x1000;
+const TInt KConsoleThreadMaxHeapSize = 0x1000000;
+
+CIoConsole* CIoConsole::NewLC(const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, const TIoConfig& aConfig, CIoConsole* aUnderlying, TUint aOptions)
+	{
+	CIoConsole* self = new(ELeave) CIoConsole(aConfig);
+	CleanupClosePushL(*self);
+	self->ConstructL(aImplementation, aTitle, aSize, aUnderlying, aOptions);
+	return self;
+	}
+
+CIoConsole::~CIoConsole()
+	{
+	// if the sub-thread is servicing a request of ours now, we have to kill it. Otherwise, we might hang
+	// when we try and cancel the request AO, if (for example) it's servicing a long-standing Create request.
+	if (iRequestAo && (iRequestAo->IsActive()) && (iServerThread.Handle()!=KNullHandle))
+		{
+		iServerThread.Kill(KErrCancel);
+		iThreadServer.Close(); // this won't be closed by the sub-thread, as we just killed it.
+		}
+	delete iThreadWatcher;
+	delete iRequestAo;
+	iRequestQueue.Close();
+	delete iImplementation;
+	delete iReader;
+	iConsole.Close();
+	delete iCreationTitle ;
+	iServerThread.Close();
+	}
+
+const TDesC& CIoConsole::Implementation() const
+	{
+	return *iImplementation;
+	}
+
+TBool CIoConsole::IsType(RIoHandle::TType aType) const
+	{
+	return ((aType == RIoHandle::EEndPoint) || (aType == RIoHandle::EConsole));
+	}
+
+void CIoConsole::HandleReaderDetached(MIoReader& aReader)
+	{
+	HandleReadWriterDetached(aReader);
+	}
+
+void CIoConsole::HandleWriterDetached(MIoWriter& aWriter)
+	{
+	HandleReadWriterDetached(aWriter);
+	}
+
+template <class T> void CIoConsole::HandleReadWriterDetached(T& aReadWriter)
+	{
+	// Remove pending requests originated from this reader / writer.
+	for (TInt i = (iRequestQueue.Count() - 1); i >= 0; --i)
+		{
+		TConsoleRequest* request = iRequestQueue[i];
+		if (request->OriginatedFrom(aReadWriter))
+			{
+			delete request;
+			iRequestQueue.Remove(i);
+			}
+		}
+
+	// If this reader / writer originated the request that's currently being process, abort it.
+	if (iRequestAo->CurrentRequest() && iRequestAo->CurrentRequest()->OriginatedFrom(aReadWriter))
+		{
+		iRequestAo->Abort();
+		}
+	}
+
+void CIoConsole::IorepReadL(MIoReader&)
+	{
+	if (!iReader->IsActive())
+		{
+		iReader->QueueRead();
+		}
+	}
+
+void CIoConsole::IorepReadKeyL(MIoReader& aReader)
+	{
+	IorepReadL(aReader);
+	}
+
+void CIoConsole::IorepSetConsoleModeL(RIoReadWriteHandle::TMode aMode, MIoReader& aReader)
+	{
+	NewRequest(new(ELeave)TConsoleSetModeRequest(aReader, *this, aMode));
+	}
+
+void CIoConsole::IowepWriteL(MIoWriter& aWriter)
+	{
+	NewRequest(new(ELeave)TConsoleWriteRequest(aWriter));
+	}
+
+void CIoConsole::IowepWriteCancel(MIoWriter&)
+	{
+	}
+
+void CIoConsole::IowepCursorPosL(MIoWriter& aWriter) const
+	{
+	NewRequest(new(ELeave)TConsoleCursorPosRequest(aWriter));
+	}
+
+void CIoConsole::IowepSetCursorPosAbsL(const TPoint& aPoint, MIoWriter& aWriter)
+	{
+	NewRequest(new(ELeave)TConsoleSetCursorPosAbsRequest(aWriter, aPoint));
+	}
+
+void CIoConsole::IowepSetCursorPosRelL(const TPoint& aPoint, MIoWriter& aWriter)
+	{
+	NewRequest(new(ELeave)TConsoleSetCursorPosRelRequest(aWriter, aPoint));
+	}
+
+void CIoConsole::IowepSetCursorHeightL(TInt aPercentage, MIoWriter& aWriter)
+	{
+	NewRequest(new(ELeave)TConsoleSetCursorHeightRequest(aWriter, aPercentage));
+	}
+
+void CIoConsole::IowepSetTitleL(MIoWriter& aWriter)
+	{
+	NewRequest(new(ELeave)TConsoleSetTitleRequest(aWriter));
+	}
+
+void CIoConsole::IowepClearScreenL(MIoWriter& aWriter)
+	{
+	NewRequest(new(ELeave)TConsoleClearScreenRequest(aWriter));
+	}
+
+void CIoConsole::IowepClearToEndOfLineL(MIoWriter& aWriter)
+	{
+	NewRequest(new(ELeave)TConsoleClearToEndOfLineRequest(aWriter));
+	}
+
+void CIoConsole::IowepSetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriter& aWriter)
+	{
+	NewRequest(new(ELeave)TConsoleSetAttributesRequest(aWriter, aAttributes, aForegroundColor, aBackgroundColor));
+	}
+
+void CIoConsole::IowepScreenSizeL(MIoWriter& aWriter) const
+	{
+	NewRequest(new(ELeave)TConsoleScreenSizeRequest(aWriter, iConfig));
+	}
+
+CIoConsole::CIoConsole(const TIoConfig& aConfig)
+	: iConfig(aConfig), iDetectedSize(-1, -1)
+	{
+	}
+
+void CIoConsole::ConstructL(const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, CIoConsole* aUnderlying, TUint aOptions)
+	{
+	LOG(CIoLog::Printf(_L("Console 0x%08x created"), this));
+	iCreationTitle = aTitle.AllocL();
+	iCreationSize = aSize;
+	
+	iRequestAo = new(ELeave)CConsoleRequest(*this);
+	
+	if (aImplementation.Length())
+		{
+		iImplementation = aImplementation.AllocL();
+		}
+	else
+		{
+		iImplementation = iConfig.ConsoleImplementation().AllocL();
+		}
+		
+	User::LeaveIfError(iConsole.Connect(CIoConsoleProxyServerNewL, iImplementation, *iImplementation, KDefaultStackSize, KConsoleThreadMinHeapSize, KConsoleThreadMaxHeapSize, iThreadServer, iServerThread));
+	iThreadWatcher = new(ELeave)CServerDeathWatcher(iThreadServer, iServerThread);
+	if (aOptions & RIoConsole::ELazyCreate)
+		{
+		User::LeaveIfError(iConsole.SetLazyConstruct());
+		}
+	if (iConfig.ConsoleSizeDetect())
+		{
+		User::LeaveIfError(iConsole.SetConsoleSizeDetect());
+		}
+	if (aUnderlying)
+		{
+		User::LeaveIfError(aUnderlying->Open());
+		CleanupClosePushL(*aUnderlying);
+		NewRequest(new(ELeave)TConsoleSetUnderlyingRequest(*aUnderlying));
+		CleanupStack::Pop();
+		}
+	NewRequest(new(ELeave)TConsoleCreateRequest(*this));
+		
+	iReader = CConsoleReader::NewL(*this);
+	}
+	
+void CIoConsole::CreateComplete(TInt aError)
+	{
+	iCreateStatus = aError;
+	}
+	
+void CIoConsole::NewRequest(TConsoleRequest* aRequest) const
+	{
+	ASSERT(aRequest);
+	TInt err = iRequestQueue.Append(aRequest);
+	if (err!=KErrNone)
+		{
+		aRequest->CompleteD(err);
+		return;
+		}
+
+	CheckQueue();
+	}
+	
+void CIoConsole::CheckQueue() const
+	{
+	if (iCreateStatus != KErrNone)
+		{
+		while (iRequestQueue.Count())
+			{
+			TConsoleRequest* req = iRequestQueue[0];
+			iRequestQueue.Remove(0);
+			req->CompleteD(iCreateStatus);
+			}
+		return;
+		}
+	if ((!iRequestAo->IsActive()) && (iRequestQueue.Count()))
+		{
+		iRequestAo->Service(iRequestQueue[0]);
+		iRequestQueue.Remove(0);
+		}
+	}
+	
+void CIoConsole::ConsoleDied()
+	{
+	iCreateStatus = KErrGeneral;
+
+	iReader = CConsoleReader::NewL(*this);
+	}
+
+void CIoConsole::ReadComplete(TInt aError)
+	{
+	MIoReader* foregroundReader = AttachedReader(0);
+	if (foregroundReader)
+		{
+		foregroundReader->IorReadKeyComplete(aError, 0, 0);
+		}
+	}
+
+void CIoConsole::ReadComplete(TUint aKeyCode, TUint aModifiers)
+	{
+	TInt index = 0;
+	MIoReader* foregroundReader = AttachedReader(index++);
+	MIoReader* reader = foregroundReader;
+	TBool keyHandled(EFalse);
+	while (reader)
+		{
+		if (reader->IorIsKeyCaptured(aKeyCode, aModifiers))
+			{
+			if (reader->IorReadPending())
+				{
+				TPtrC keyCodePtr((TUint16*)&aKeyCode, 1);
+				reader->IorReadBuf().Append(keyCodePtr);
+				reader->IorDataBuffered(1);
+				}
+			else
+				{
+				reader->IorReadKeyComplete(KErrNone, aKeyCode, aModifiers);
+				}
+			keyHandled = ETrue;
+			break;
+			}
+		reader = AttachedReader(index++);;
+		}
+
+	// Key not captured, so send to foreground (i.e. the first) reader.
+	if (!keyHandled && foregroundReader)
+		{
+		foregroundReader->IorReadKeyComplete(KErrNone, aKeyCode, aModifiers);
+		}
+
+	QueueReaderIfRequired();
+	}
+
+void CIoConsole::QueueReaderIfRequired()
+	{
+	TBool pendingReader(EFalse);
+	TInt index = 0;
+	MIoReader* reader = AttachedReader(index++);
+	while (reader)
+		{
+		if (reader->IorReadPending() || reader->IorReadKeyPending())
+			{
+			pendingReader = ETrue;
+			break;
+			}
+		reader = AttachedReader(index++);
+		}
+
+	if (pendingReader && !iReader->IsActive())
+		{
+		iReader->QueueRead();
+		}
+	else if (!pendingReader && iReader->IsActive())
+		{
+		iReader->Cancel();
+		}
+	}
+
+CIoConsole::CConsoleReader* CIoConsole::CConsoleReader::NewL(CIoConsole& aConsole)
+	{
+	return new(ELeave) CConsoleReader(aConsole);
+	}
+
+CIoConsole::CConsoleReader::~CConsoleReader()
+	{
+	Cancel();
+	}
+
+void CIoConsole::CConsoleReader::QueueRead()
+	{
+	iConsole.iConsole.Read(iKeyCodePckg, iKeyModifiersPckg, iStatus);
+	SetActive();
+	}
+
+CIoConsole::CConsoleReader::CConsoleReader(CIoConsole& aConsole)
+	: CActive(CActive::EPriorityStandard), iConsole(aConsole)
+	, iKeyCodePckg(iKeyCode), iKeyModifiersPckg(iKeyModifiers)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CIoConsole::CConsoleReader::RunL()
+	{
+	TInt err = iStatus.Int();
+	if (err==KErrServerTerminated)
+		{
+		iConsole.ConsoleDied();
+		err = KErrGeneral;
+		}
+	if (err)
+		{
+		iConsole.ReadComplete(err);
+		}
+	else
+		{
+		iConsole.ReadComplete(iKeyCode, iKeyModifiers);
+		}
+	}
+
+void CIoConsole::CConsoleReader::DoCancel()
+	{
+	iConsole.iConsole.ReadCancel();
+	}
+
+//______________________________________________________________________________
+//						TConsoleRequest
+void CIoConsole::TConsoleRequest::PrepareL()
+	{
+	}
+
+TBool CIoConsole::TConsoleRequest::OriginatedFrom(MIoReader&) const
+	{ 
+	return EFalse; 
+	}
+
+TBool CIoConsole::TConsoleRequest::OriginatedFrom(MIoWriter&) const
+	{
+	return EFalse;
+	}
+
+//______________________________________________________________________________
+//						TConsoleWriterRequest
+CIoConsole::TConsoleWriterRequest::TConsoleWriterRequest(MIoWriter& aWriter)
+	: iWriter(aWriter)
+	{
+	}
+
+TBool CIoConsole::TConsoleWriterRequest::OriginatedFrom(MIoWriter& aWriter) const
+	{
+	return (&iWriter == &aWriter);
+	}
+
+//______________________________________________________________________________
+//						TConsoleReaderRequest
+CIoConsole::TConsoleReaderRequest::TConsoleReaderRequest(MIoReader& aReader)
+	: iReader(aReader)
+	{
+	}
+
+TBool CIoConsole::TConsoleReaderRequest::OriginatedFrom(MIoReader& aReader) const
+	{
+	return (&iReader == &aReader);
+	}
+
+//______________________________________________________________________________
+//						TConsoleCreateRequest
+CIoConsole::TConsoleCreateRequest::TConsoleCreateRequest(CIoConsole& aOwner)
+	: iOwner(aOwner)
+	{
+	}
+
+void CIoConsole::TConsoleCreateRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.Create(*iOwner.iCreationTitle, iOwner.iCreationSize, aStatus);
+	}
+
+void CIoConsole::TConsoleCreateRequest::CompleteD(TInt aError)
+	{
+	iOwner.CreateComplete(aError);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleWriteRequest
+CIoConsole::TConsoleWriteRequest::TConsoleWriteRequest(MIoWriter& aWriter)
+	: TConsoleWriterRequest(aWriter), iBuf(NULL)
+	{
+	}
+
+void CIoConsole::TConsoleWriteRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	if (iWriter.IowIsStdErr())
+		{
+		aProxy.WriteStdErr(*iBuf, aStatus);
+		}
+	else
+		{
+		aProxy.Write(*iBuf, aStatus);
+		}
+	}
+
+void CIoConsole::TConsoleWriteRequest::PrepareL()
+	{
+	const TInt length = iWriter.IowWriteLength();
+	if (iBuf == NULL)
+		{
+		iBuf = HBufC::NewL(length);
+		}
+	else if (iBuf->Des().MaxLength() < length)
+		{
+		iBuf = iBuf->ReAllocL(length);
+		}
+
+	TPtr bufPtr(iBuf->Des());
+	bufPtr.Zero();
+	iWriter.IowWrite(bufPtr);
+
+	if (iWriter.IorwMode() == RIoReadWriteHandle::EText)
+		{
+		// Fix line endings (change LF to CRLF).
+		RArray<TInt> indicies(5);
+		CleanupClosePushL(indicies);
+		_LIT(KCarriageReturn, "\r");
+		for (TInt i = 0; i < length; ++i)
+			{
+			if ((*iBuf)[i] == '\n')
+				{
+				if ((i == 0) || ((*iBuf)[i - 1] != '\r'))
+					{
+					User::LeaveIfError(indicies.Append(i));
+					}
+				}
+			}
+		const TInt count = indicies.Count();
+		if (count > 0)
+			{
+			if (bufPtr.MaxLength() < (length + count))
+				{
+				iBuf = iBuf->ReAllocL(length + count);
+				bufPtr.Set(iBuf->Des());
+				}
+			for (TInt i = (count - 1); i >= 0; --i)
+				{
+				bufPtr.Insert(indicies[i], KCarriageReturn);
+				}
+			}
+		CleanupStack::PopAndDestroy(&indicies);
+		}
+	
+	}
+
+void CIoConsole::TConsoleWriteRequest::CompleteD(TInt aError)
+	{
+	delete iBuf;
+	iWriter.IowComplete(aError);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleCursorPosRequest
+CIoConsole::TConsoleCursorPosRequest::TConsoleCursorPosRequest(MIoWriter& aWriter)
+	: TConsoleWriterRequest(aWriter), iPosPckg(iPos)
+	{
+	}
+
+void CIoConsole::TConsoleCursorPosRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.CursorPos(iPosPckg, aStatus);
+	}
+
+void CIoConsole::TConsoleCursorPosRequest::CompleteD(TInt aError)
+	{
+	iWriter.IowCursorPos(aError, iPos);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleSetCursorPosAbsRequest
+CIoConsole::TConsoleSetCursorPosAbsRequest::TConsoleSetCursorPosAbsRequest(MIoWriter& aWriter, const TPoint& aPoint)
+	: TConsoleWriterRequest(aWriter), iPoint(aPoint)
+	{
+	}
+
+void CIoConsole::TConsoleSetCursorPosAbsRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.SetCursorPosAbs(iPoint, aStatus);	
+	}
+
+void CIoConsole::TConsoleSetCursorPosAbsRequest::CompleteD(TInt aError)
+	{
+	iWriter.IowSetCursorPosAbsComplete(aError);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleSetCursorPosRelRequest
+CIoConsole::TConsoleSetCursorPosRelRequest::TConsoleSetCursorPosRelRequest(MIoWriter& aWriter, const TPoint& aPoint)
+	: TConsoleWriterRequest(aWriter), iPoint(aPoint)
+	{
+	}
+
+void CIoConsole::TConsoleSetCursorPosRelRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.SetCursorPosRel(iPoint, aStatus);
+	}
+
+void CIoConsole::TConsoleSetCursorPosRelRequest::CompleteD(TInt aError)
+	{
+	iWriter.IowSetCursorPosRelComplete(aError);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleSetCursorHeightRequest
+CIoConsole::TConsoleSetCursorHeightRequest::TConsoleSetCursorHeightRequest(MIoWriter& aWriter, TInt aHeight)
+	: TConsoleWriterRequest(aWriter), iHeight(aHeight)
+	{
+	}	
+
+void CIoConsole::TConsoleSetCursorHeightRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.SetCursorHeight(iHeight, aStatus);
+	}
+
+void CIoConsole::TConsoleSetCursorHeightRequest::CompleteD(TInt aError)
+	{
+	iWriter.IowSetCursorHeightComplete(aError);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleSetTitleRequest
+CIoConsole::TConsoleSetTitleRequest::TConsoleSetTitleRequest(MIoWriter& aWriter)
+	: TConsoleWriterRequest(aWriter)
+	{
+	}
+
+void CIoConsole::TConsoleSetTitleRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.SetTitle(*iTitle, aStatus);
+	}
+
+void CIoConsole::TConsoleSetTitleRequest::PrepareL()
+	{
+	iTitle = iWriter.IowTitleLC();
+	CleanupStack::Pop(iTitle);
+	}
+
+void CIoConsole::TConsoleSetTitleRequest::CompleteD(TInt aError)
+	{
+	delete iTitle;
+	iWriter.IowSetTitleComplete(aError);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleClearScreenRequest
+CIoConsole::TConsoleClearScreenRequest::TConsoleClearScreenRequest(MIoWriter& aWriter)
+	: TConsoleWriterRequest(aWriter)
+	{
+	}
+
+void CIoConsole::TConsoleClearScreenRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.ClearScreen(aStatus);
+	}
+
+void CIoConsole::TConsoleClearScreenRequest::CompleteD(TInt aError)
+	{
+	iWriter.IowClearScreenComplete(aError);
+	delete this;
+	}
+
+		
+	
+
+//______________________________________________________________________________
+//						TConsoleClearToEndOfLineRequest
+CIoConsole::TConsoleClearToEndOfLineRequest::TConsoleClearToEndOfLineRequest(MIoWriter& aWriter)
+	: TConsoleWriterRequest(aWriter)
+	{
+	}
+
+void CIoConsole::TConsoleClearToEndOfLineRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.ClearToEndOfLine(aStatus);
+	}
+
+void CIoConsole::TConsoleClearToEndOfLineRequest::CompleteD(TInt aError)
+	{
+	iWriter.IowClearToEndOfLineComplete(aError);
+	delete this;
+	}
+
+		
+	
+
+//______________________________________________________________________________
+//						TConsoleScreenSizeRequest
+CIoConsole::TConsoleScreenSizeRequest::TConsoleScreenSizeRequest(MIoWriter& aWriter, const TIoConfig& aConfig)
+	: TConsoleWriterRequest(aWriter), iConfig(aConfig), iSizeBuf(iSize)
+	{
+	}
+
+void CIoConsole::TConsoleScreenSizeRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.GetScreenSize(iSizeBuf, aStatus);
+	}
+
+void CIoConsole::TConsoleScreenSizeRequest::CompleteD(TInt aError)
+	{
+	if (aError==KErrNone)
+		{
+		iSize.iWidth += iConfig.ConsoleSizeAdjustment().iWidth;
+		iSize.iHeight += iConfig.ConsoleSizeAdjustment().iHeight;
+		}
+	iWriter.IowScreenSize(aError, iSize);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleSetAttributesRequest
+CIoConsole::TConsoleSetAttributesRequest::TConsoleSetAttributesRequest(MIoWriter& aWriter, TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor)
+	: TConsoleWriterRequest(aWriter), iAttributes(aAttributes), iForegroundColor(aForegroundColor), iBackgroundColor(aBackgroundColor)
+	{
+	}
+
+void CIoConsole::TConsoleSetAttributesRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.SetAttributes(iAttributes, iForegroundColor, iBackgroundColor, aStatus);
+	}
+
+void CIoConsole::TConsoleSetAttributesRequest::CompleteD(TInt aError)
+	{
+	iWriter.IowSetAttributesComplete(aError);
+	delete this;
+	}
+
+		
+//______________________________________________________________________________
+//						TConsoleSetUnderlyingRequest
+CIoConsole::TConsoleSetUnderlyingRequest::TConsoleSetUnderlyingRequest(CIoConsole& aUnderlyingConsole)
+	: iConsole(aUnderlyingConsole)
+	{
+	}
+
+void CIoConsole::TConsoleSetUnderlyingRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	aProxy.SetUnderlyingConsole(iSession, aStatus);
+	}
+
+void CIoConsole::TConsoleSetUnderlyingRequest::PrepareL()
+	{
+	if (iConsole.iThreadServer.Handle())
+		{
+		User::LeaveIfError(iSession.Connect(iConsole.iThreadServer));
+		}
+	else
+		{
+		User::Leave(KErrBadHandle);
+		}	
+	}
+
+void CIoConsole::TConsoleSetUnderlyingRequest::CompleteD(TInt)
+	{
+	iSession.Close();
+	iConsole.Close();
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						TConsoleSetModeRequest
+CIoConsole::TConsoleSetModeRequest::TConsoleSetModeRequest(MIoReader& aReader,CIoConsole& aConsole, RIoReadWriteHandle::TMode aMode)
+	: TConsoleReaderRequest(aReader), iConsole(aConsole), iMode(aMode)
+	{
+	}
+
+void CIoConsole::TConsoleSetModeRequest::Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus)
+	{
+	iConsole.iReader->Cancel();
+	aProxy.SetConsoleMode(iMode, aStatus);
+	}
+
+void CIoConsole::TConsoleSetModeRequest::CompleteD(TInt aError)
+	{
+	iConsole.QueueReaderIfRequired();
+	iReader.IorSetConsoleModeComplete(aError);
+	delete this;
+	}
+
+//______________________________________________________________________________
+//						CConsoleRequest
+CIoConsole::CConsoleRequest::CConsoleRequest(CIoConsole& aConsole)
+	: CActive(EPriorityStandard), iConsole(aConsole)
+	{
+	CActiveScheduler::Add(this);
+	}
+		
+void CIoConsole::CConsoleRequest::Service(TConsoleRequest* aRequest)
+	{
+	ASSERT(!IsActive());
+	ASSERT(!iCurrentRequest);
+	TRAPD(err, aRequest->PrepareL());
+	if (err!=KErrNone)
+		{
+		Complete(aRequest, err);
+		return;
+		}
+	aRequest->Request(iConsole.iConsole, iStatus);
+	SetActive();
+	iCurrentRequest = aRequest;
+	}
+	
+void CIoConsole::CConsoleRequest::Complete(TConsoleRequest* aRequest, TInt aError)
+	{
+	if (aError == KErrServerTerminated)
+		{
+		// console has panicked.
+		iConsole.ConsoleDied();
+		// don't want to send KErrServerTerminated up to our (iosrv) clients, as it will
+		// make them think the iosrv has died.
+		aError = KErrGeneral;
+		}
+	if (aRequest)
+		{
+		aRequest->CompleteD(aError);
+		}
+	iConsole.CheckQueue();
+	}
+
+
+CIoConsole::CConsoleRequest::~CConsoleRequest()
+	{
+	Cancel();
+	}
+	
+void CIoConsole::CConsoleRequest::RunL()
+	{
+	TConsoleRequest* req = iCurrentRequest;
+	iCurrentRequest = NULL;
+	Complete(req, iStatus.Int());
+	}
+
+void CIoConsole::CConsoleRequest::DoCancel()
+	{
+	// request are handled synchronously on the server side, no cancelling is possible.
+	}
+
+const CIoConsole::TConsoleRequest* CIoConsole::CConsoleRequest::CurrentRequest() const
+	{
+	return iCurrentRequest;
+	}
+
+void CIoConsole::CConsoleRequest::Abort()
+	{
+	// We can't cancel a pending request (because they are handled synchronously on the server side),
+	// so instead we delete and NULL the associated request object. This active object will then
+	// continue to wait for the server to complete the request (as normal), but will take no further
+	// action. This is used when the originating MIoReader or MIoWriter object has been detached from
+	// the console and no longer exists.
+	ASSERT(IsActive());
+	ASSERT(iCurrentRequest);
+	delete iCurrentRequest;
+	iCurrentRequest = NULL;
+	}
+
+
+//______________________________________________________________________________
+//						CServerDeathWatcher
+CIoConsole::CServerDeathWatcher::CServerDeathWatcher(RServer2& aServer, RThread& aThread)
+	: CActive(CActive::EPriorityStandard), iServer(aServer), iThread(aThread)
+	{
+	CActiveScheduler::Add(this);
+	aThread.Logon(iStatus);
+	SetActive();
+	}
+	
+CIoConsole::CServerDeathWatcher::~CServerDeathWatcher()
+	{
+	Cancel();
+	}
+
+void CIoConsole::CServerDeathWatcher::RunL()
+	{
+	}
+
+void CIoConsole::CServerDeathWatcher::DoCancel()
+	{
+	iThread.LogonCancel(iStatus);
+	}
+
+//______________________________________________________________________________
+//						RIoConsoleProxy
+TInt RIoConsoleProxy::SetConsoleSizeDetect()
+	{
+	return SendReceive(ESetConsoleSizeDetect);
+	}
+	
+TInt RIoConsoleProxy::SetLazyConstruct()
+	{
+	return SendReceive(ESetLazyConstruct);
+	}
+	
+void RIoConsoleProxy::SetConsoleMode(RIoReadWriteHandle::TMode aMode, TRequestStatus& aStatus)
+	{
+	SendReceive(ESetConsoleMode, TIpcArgs(aMode), aStatus);
+	}
+	
+void RIoConsoleProxy::SetUnderlyingConsole(const RIoConsoleProxy& aUnderlyingSession, TRequestStatus& aStatus)
+	{
+	SendReceive(ESetUnderlyingConsole, TIpcArgs(aUnderlyingSession), aStatus);
+	}
+	
+TInt RIoConsoleProxy::OpenExisting()
+	{
+	return SendReceive(EOpenExistingConsole);
+	}
+
+void RIoConsoleProxy::WriteStdErr(const TDesC& aDescriptor, TRequestStatus& aStatus)
+	{
+	SendReceive(EWriteStdErr, TIpcArgs(&aDescriptor), aStatus);
+	}
+
+//______________________________________________________________________________
+//						CIoConsoleProxyServer
+CConsoleProxyServer* CIoConsoleProxyServerNewL(TAny* aParams)
+	{
+	const TDesC* dllName = (const TDesC*)aParams;
+	RLibrary lib;
+
+	User::LeaveIfError(lib.Load(*dllName));
+	CleanupClosePushL(lib);
+	if ((lib.Type()[1] == KSharedLibraryUid) && (lib.Type()[2] == KConsoleDllUid))
+		{
+		TConsoleCreateFunction entry = (TConsoleCreateFunction)lib.Lookup(1);
+		if (!entry) User::Leave(KErrNotSupported);
+		CleanupStack::Pop(&lib);
+		return CIoConsoleProxyServer::NewL(entry, lib);
+		}
+	else
+		{
+		User::Leave(KErrNotSupported);
+		return NULL; // ASSERT(Happy(compiler))
+		}
+	}
+	
+CIoConsoleProxyServer* CIoConsoleProxyServer::NewL(TConsoleCreateFunction aConsoleCreate, RLibrary& aConsoleLibrary)
+	{
+	CIoConsoleProxyServer* self = new CIoConsoleProxyServer(aConsoleCreate, aConsoleLibrary);
+	if (!self)
+		{
+		aConsoleLibrary.Close();
+		User::Leave(KErrNoMemory);
+		}
+	CleanupStack::PushL(self);
+	self->ConstructL(KNullDesC);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CIoConsoleProxyServer::CIoConsoleProxyServer(TConsoleCreateFunction aConsoleCreate, const RLibrary& aConsoleLibrary)
+	: CConsoleProxyServer(aConsoleCreate, CActive::EPriorityStandard)
+	, iConsoleLibrary(aConsoleLibrary)
+	{
+	}
+
+CSession2* CIoConsoleProxyServer::NewSessionL(const TVersion&,const RMessage2&) const
+	{
+	return new(ELeave)CIoConsoleProxySession(iConsoleCreate);
+	}
+	
+CIoConsoleProxyServer::~CIoConsoleProxyServer()
+	{
+	iConsoleLibrary.Close();
+	}
+	
+MProxiedConsole* CIoConsoleProxyServer::TheConsole() const
+	{
+	return iTheConsole;
+	}
+	
+void CIoConsoleProxyServer::SetTheConsole(MProxiedConsole* aConsole)
+	{
+	ASSERT(!iTheConsole);
+	iTheConsole = aConsole;
+	}
+
+//______________________________________________________________________________
+TSize DetectConsoleSize(CConsoleBase* aConsole)
+	{
+	TSize detectedSize;
+	aConsole->SetCursorHeight(0);
+	aConsole->ScreenSize(); // This used to be assigned to a variable, which was never used, but I'm not sure if calling ScreenSize() has side-effects so I'm leaving the call in
+	aConsole->SetCursorPosAbs(TPoint(0, 0));
+	_LIT(KSpace, " ");
+	for (TInt x = 0; ; ++x)
+		{
+		aConsole->Write(KSpace);
+		if (aConsole->CursorPos().iX == 0)
+			{
+			detectedSize.iWidth = x + 1;
+			break;
+			}
+		}
+	aConsole->SetCursorPosAbs(TPoint(0, 0));
+	TInt prevYPos = 0;
+	_LIT(KNewLine, "\r\n");
+	for (TInt y = 0; ; ++y)
+		{
+		aConsole->Write(KNewLine);
+		if (aConsole->CursorPos().iY == prevYPos)
+			{
+			detectedSize.iHeight = y;
+			break;
+			}
+		else
+			{
+			prevYPos = y;
+			}
+		}
+	aConsole->ClearScreen();
+	aConsole->SetCursorHeight(20);
+	return detectedSize;
+	}
+
+//______________________________________________________________________________
+//						CIoConsoleProxySession
+CIoConsoleProxySession::CIoConsoleProxySession(TConsoleCreateFunction aConsoleCreate)
+	: CConsoleProxySession(aConsoleCreate), iFlags(ESupportsStdErr)
+	{
+	// Assume ESupportsStdErr until proven otherwise
+	}
+
+CIoConsoleProxySession::~CIoConsoleProxySession()
+	{
+	delete iUnderlyingConsole;
+	}
+
+void CIoConsoleProxySession::ServiceL(const RMessage2& aMessage)
+	{
+	switch (aMessage.Function())
+		{
+	case RIoConsoleProxy::ESetConsoleSizeDetect:
+		if (iConsole) User::Leave(KErrNotReady); // too late!
+		SetFlag(EAutoDetectSize, ETrue);
+		aMessage.Complete(KErrNone);
+		return;
+	case RIoConsoleProxy::ESetLazyConstruct:
+		if (iConsole) User::Leave(KErrNotReady); // too late!
+		SetFlag(ELazy, ETrue);
+		aMessage.Complete(KErrNone);
+		return;
+	case RIoConsoleProxy::ESetConsoleMode:
+		SetModeL(aMessage);
+		return;
+	case RIoConsoleProxy::ESetUnderlyingConsole:
+		SetUnderlyingConsoleL(aMessage);
+		return;
+	case RIoConsoleProxy::EOpenExistingConsole:
+		OpenExistingL(aMessage);
+		return;	
+	case RConsoleProxy::EGetScreenSize:
+		if (GetFlag(EAutoDetectSize) && !GetFlag(ELazy))
+			{
+			DetectSizeL(aMessage);
+			return;
+			}
+		break;
+	case RIoConsoleProxy::EWriteStdErr:
+		{
+		RBuf buf;
+		CleanupClosePushL(buf);
+		buf.CreateL(aMessage.GetDesLengthL(0));
+		aMessage.ReadL(0, buf);
+		if (iFlags & ESupportsStdErr)
+			{
+			TInt err = ConsoleStdErr::Write(iConsole->Console(), buf);
+			if (err != KErrNone)
+				{
+				// Clearly it doesn't support it, clear the flag so we fall back to normal write and don't bother trying again
+				iFlags &= ~ESupportsStdErr;
+				}
+			}
+
+		if (!(iFlags & ESupportsStdErr))
+			{
+			iConsole->Console()->Write(buf);
+			}
+		CleanupStack::PopAndDestroy(&buf);
+		aMessage.Complete(KErrNone);
+		return;
+		}
+	default:
+		break;
+		}
+
+	CConsoleProxySession::ServiceL(aMessage);
+	}
+	
+MProxiedConsole* CIoConsoleProxySession::InstantiateConsoleL()
+	{
+	if (Server()->TheConsole()!=NULL)
+		{
+		// make sure that only 1 console is ever created in this server
+		User::Leave(KErrAlreadyExists);
+		}
+	MProxiedConsole* cons;
+	if (GetFlag(ELazy))
+		{
+		CLazyConsole* lazy = new(ELeave)CLazyConsole(iConsoleCreate, GetFlag(EAutoDetectSize));
+		CleanupStack::PushL(lazy);
+		cons = MProxiedConsole::DefaultL(lazy);
+		CleanupStack::Pop();
+		}
+	else
+		{
+		cons = CConsoleProxySession::InstantiateConsoleL();
+		}
+	
+	Server()->SetTheConsole(cons);
+	
+	if (iUnderlyingConsole)
+		{
+		TInt err = UnderlyingConsole::Set(cons->Console(), iUnderlyingConsole);
+		// if this succeeds, ownership of the underlying console has been taken
+		// if it didn't, we should delete it as it's not needed.
+		if (err!=KErrNone)
+			{
+			delete iUnderlyingConsole;
+			}
+		iUnderlyingConsole = NULL;
+		}
+	
+	return cons;	
+	}
+	
+void CIoConsoleProxySession::ConsoleCreatedL(MProxiedConsole* aConsole)
+	{
+	if (GetFlag(EAutoDetectSize) && !(GetFlag(ELazy)))
+		{
+		iDetectedSize = DetectConsoleSize(aConsole->Console());
+		}
+	}
+
+void CIoConsoleProxySession::DetectSizeL(const RMessage2& aMessage)
+	{
+	if (!iConsole) User::Leave(KErrNotReady);
+	
+	aMessage.WriteL(0, TPckg<TSize>(iDetectedSize));
+	aMessage.Complete(KErrNone);	
+	}
+
+void CIoConsoleProxySession::SetModeL(const RMessage2& aMessage)
+	{
+	if (!iConsole) User::Leave(KErrNotReady);
+	RIoReadWriteHandle::TMode mode = (RIoReadWriteHandle::TMode)aMessage.Int0();
+	TInt err = ConsoleMode::Set(iConsole->Console(), (mode == RIoReadWriteHandle::EBinary) ? ConsoleMode::EBinary : ConsoleMode::EText);
+	aMessage.Complete(err);
+	}
+
+void CIoConsoleProxySession::SetUnderlyingConsoleL(const RMessage2& aMessage)
+	{
+	if (iUnderlyingConsole) User::Leave(KErrAlreadyExists);
+	
+	RIoConsoleProxy underlyingSession;
+	RThread client;
+	aMessage.ClientL(client, EOwnerThread);
+	CleanupClosePushL(client);
+
+	underlyingSession.SetHandle(aMessage.Int0());
+	User::LeaveIfError(underlyingSession.Duplicate(client, EOwnerThread));
+	
+	CleanupClosePushL(underlyingSession);
+	User::LeaveIfError(underlyingSession.OpenExisting());
+	
+	CConsoleProxy* underlying = CWriteOnlyConsoleProxy::NewL(underlyingSession);
+	
+	CleanupStack::PopAndDestroy(2, &client); // we can close underlyingSession as it's been duplicated by CConsoleProxy::NewL
+	
+	if (iConsole && iConsole->Console())
+		{
+		CleanupStack::PushL(underlying);
+		User::LeaveIfError(UnderlyingConsole::Set(iConsole->Console(), underlying));
+		// ownership of underlying now taken.
+		CleanupStack::Pop();
+		}
+	else
+		{
+		// save it for when the console is instantiated
+		iUnderlyingConsole = underlying;
+		}
+	
+	aMessage.Complete(KErrNone);
+	}
+
+void CIoConsoleProxySession::OpenExistingL(const RMessage2& aMessage)
+	{
+	if (Server()->TheConsole()==NULL) User::Leave(KErrNotReady); // no console to connect to
+	
+	iConsole = Server()->TheConsole();
+	iConsole->Open();
+	aMessage.Complete(KErrNone);
+	}
+
+TBool CIoConsoleProxySession::GetFlag(TFlag aFlag)
+	{
+	return iFlags & aFlag ? (TBool)ETrue : EFalse;
+	}
+	
+void CIoConsoleProxySession::SetFlag(TFlag aFlag, TBool aSet)
+	{
+	if (aSet)
+		{
+		iFlags |= aFlag;
+		}
+	else
+		{
+		iFlags &= (~(TUint)aFlag);
+		}
+	}
+
+
+//______________________________________________________________________________
+//						CWriteOnlyConsoleProxy
+CConsoleProxy* CWriteOnlyConsoleProxy::NewL(const RConsoleProxy& aProxySession)
+	{
+	CWriteOnlyConsoleProxy* self = new(ELeave)CWriteOnlyConsoleProxy();
+	CleanupStack::PushL(self);
+	self->ConstructL(aProxySession);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CWriteOnlyConsoleProxy::CWriteOnlyConsoleProxy()
+	{
+	}
+
+void CWriteOnlyConsoleProxy::Read(TRequestStatus&)
+	{
+	User::Panic(KIoServerName, EPanicCannotReadFromUnderlyingConsole);
+	}
+
+void CWriteOnlyConsoleProxy::ReadCancel()
+	{
+	}
+
+TKeyCode CWriteOnlyConsoleProxy::KeyCode() const
+	{
+	return EKeyNull;
+	}
+
+
+TUint CWriteOnlyConsoleProxy::KeyModifiers() const
+	{
+	return 0;
+	}
+
+//______________________________________________________________________________
+//						CLazyConsole
+CLazyConsole::CLazyConsole(TConsoleCreateFunction aConsoleCreate, TBool aAutoDetectSize)
+	: iConsoleCreate(aConsoleCreate), iSizeAutoDetect(aAutoDetectSize)
+	{
+	}
+
+CLazyConsole::~CLazyConsole()
+	{
+	iTitle.Close();
+	delete iConsole;
+	}
+
+TInt CLazyConsole::Create(const TDesC &aTitle,TSize aSize)
+	{
+	iSize = aSize;
+	return iTitle.Create(aTitle);
+	}
+	
+TInt CLazyConsole::CheckCreated() const
+	{
+	if (iCreateError) return iCreateError;
+	if (iConsole) return KErrNone;
+	
+	TRAP(iCreateError, iConsole = iConsoleCreate());
+	if ((iCreateError==KErrNone) && (!iConsole))
+		{
+		iCreateError = KErrNoMemory;
+		}
+	if (iCreateError == KErrNone)
+		{
+		TName procName = RProcess().Name(); // econseik sets the process name to the console title...
+		iCreateError = iConsole->Create(iTitle, iSize);
+		User::RenameProcess(procName.Left(procName.Locate('['))); // ...so restore it just in case
+		}
+	if ((iCreateError == KErrNone) && iSizeAutoDetect)
+		{
+		iDetectedSize = DetectConsoleSize(iConsole);
+		}
+	if (iCreateError != KErrNone)
+		{
+		delete iConsole;
+		iConsole = NULL;
+		}
+	return iCreateError;
+	}
+
+void CLazyConsole::Read(TRequestStatus &aStatus)
+	{
+	TInt err = CheckCreated();
+	if (err)
+		{
+		TRequestStatus* stat = &aStatus;
+		User::RequestComplete(stat, err);
+		return;
+		}
+	iConsole->Read(aStatus);
+	}
+
+void CLazyConsole::ReadCancel()
+	{
+	if (iConsole)
+		{
+		iConsole->ReadCancel();
+		}
+	}
+
+void CLazyConsole::Write(const TDesC &aDes)
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		iConsole->Write(aDes);
+		}
+	}
+
+TPoint CLazyConsole::CursorPos() const
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->CursorPos();
+		}
+	return TPoint(0,0);
+	}
+
+void CLazyConsole::SetCursorPosAbs(const TPoint &aPoint)
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->SetCursorPosAbs(aPoint);
+		}
+	}
+
+void CLazyConsole::SetCursorPosRel(const TPoint &aPoint)
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->SetCursorPosRel(aPoint);
+		}
+	}
+
+void CLazyConsole::SetCursorHeight(TInt aPercentage)
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->SetCursorHeight(aPercentage);
+		}
+	}
+
+void CLazyConsole::SetTitle(const TDesC &aTitle)
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->SetTitle(aTitle);
+		}
+	}
+
+void CLazyConsole::ClearScreen()
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->ClearScreen();
+		}
+	}
+
+void CLazyConsole::ClearToEndOfLine()
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->ClearToEndOfLine();
+		}
+	}
+
+TSize CLazyConsole::ScreenSize() const
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		if (iSizeAutoDetect)
+			{
+			return iDetectedSize;
+			}
+		else
+			{
+			return iConsole->ScreenSize();
+			}
+		}
+	else
+		{
+		return TSize(0,0);
+		}
+	}
+
+TKeyCode CLazyConsole::KeyCode() const
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->KeyCode();
+		}
+	return EKeyNull;
+	}
+
+TUint CLazyConsole::KeyModifiers() const
+	{
+	if (CheckCreated() == KErrNone)
+		{
+		return iConsole->KeyModifiers();
+		}
+	return 0;
+	}
+
+TInt CLazyConsole::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	if (aExtensionId == LazyConsole::KLazyConsoleExtension)
+		{
+		TBool* constructed = (TBool*)a1;
+		*constructed = (iConsole != NULL);
+		return KErrNone;
+		}
+	else 
+		{
+		TInt err = CheckCreated();
+		if (err == KErrNone)
+			{
+			return ((CLazyConsole*)iConsole)->Extension_(aExtensionId, a0, a1);
+			}
+		return err;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/console.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,419 @@
+// console.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __CONSOLE_H__
+#define __CONSOLE_H__
+
+#include <e32base.h>
+#include <fshell/consoleproxy.h>
+#include "endpoint.h"
+#include "readwrite.h"
+
+class CLazyConsole;
+
+class RIoConsoleProxy : public RConsoleProxy
+	{
+public:
+	enum TOpCode
+		{
+		ESetConsoleSizeDetect = RConsoleProxy::EOpCodeCustomBase,
+		ESetLazyConstruct,
+		ESetConsoleMode,
+		ESetUnderlyingConsole,
+		EOpenExistingConsole,
+		EWriteStdErr,
+		};
+public:
+	TInt SetConsoleSizeDetect();
+	TInt SetLazyConstruct();
+	void SetConsoleMode(RIoReadWriteHandle::TMode aMode, TRequestStatus& aStatus);
+	void SetUnderlyingConsole(const RIoConsoleProxy& aUnderlyingSession, TRequestStatus& aStatus);
+	TInt OpenExisting();
+	void WriteStdErr(const TDesC& aDescriptor, TRequestStatus& aStatus);
+	};
+	
+class CIoConsole : public CIoEndPoint
+	{
+public:
+	static CIoConsole* NewLC(const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, const TIoConfig& aConfig, CIoConsole* aUnderlying, TUint aOptions);
+	~CIoConsole();
+	const TDesC& Implementation() const;
+public: // From CIoObject.
+	virtual TBool IsType(RIoHandle::TType aType) const;
+public: // From CIoEndPoint.
+	virtual void HandleReaderDetached(MIoReader& aReader);
+	virtual void HandleWriterDetached(MIoWriter& aWriter);
+public: // From MIoReadEndPoint.
+	virtual void IorepReadL(MIoReader& aReader);
+	virtual void IorepReadKeyL(MIoReader& aReader);
+	virtual void IorepSetConsoleModeL(RIoReadWriteHandle::TMode aMode, MIoReader& aReader);
+public: // From MIoWriteEndPoint.
+	virtual void IowepWriteL(MIoWriter& aWriter);
+	virtual void IowepWriteCancel(MIoWriter& aWriter);
+	virtual void IowepCursorPosL(MIoWriter& aWriter) const;
+	virtual void IowepSetCursorPosAbsL(const TPoint& aPoint, MIoWriter& aWriter);
+	virtual void IowepSetCursorPosRelL(const TPoint& aPoint, MIoWriter& aWriter);
+	virtual void IowepSetCursorHeightL(TInt aPercentage, MIoWriter& aWriter);
+	virtual void IowepSetTitleL(MIoWriter& aWriter);
+	virtual void IowepClearScreenL(MIoWriter& aWriter);
+	virtual void IowepClearToEndOfLineL(MIoWriter& aWriter);
+	virtual void IowepScreenSizeL(MIoWriter& aWriter) const;
+	virtual void IowepSetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriter& aWriter);
+protected:
+	CIoConsole(const TIoConfig& aConfig);
+private:
+	class TConsoleRequest;
+private:
+	void ConstructL(const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, CIoConsole* aUnderlying, TUint aOptions);
+	void ReadComplete(TInt aError);
+	void ReadComplete(TUint aKeyCode, TUint aModifiers);
+	void QueueReaderIfRequired();
+	void CreateComplete(TInt aError);
+	void NewRequest(TConsoleRequest* aRequest) const;
+	void CheckQueue() const;
+	void ConsoleDied();
+	template <class T> void HandleReadWriterDetached(T& aReadWriter);
+private:
+	class CConsoleReader : public CActive
+		{
+	public:
+		static CConsoleReader* NewL(CIoConsole& aConsole);
+		~CConsoleReader();
+		void QueueRead();
+	private:
+		CConsoleReader(CIoConsole& aConsole);
+	private: // From CActive.
+		virtual void RunL();
+		virtual void DoCancel();
+	private:
+		CIoConsole& iConsole;
+		TKeyCode iKeyCode;
+		TUint iKeyModifiers;
+		TPckg<TKeyCode> iKeyCodePckg;
+		TPckg<TUint> iKeyModifiersPckg;
+		};
+		
+	class TConsoleRequest
+		{
+	public:
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus) = 0;
+		virtual void PrepareL();
+		virtual void CompleteD(TInt aError) = 0;
+		virtual TBool OriginatedFrom(MIoReader& aReader) const;
+		virtual TBool OriginatedFrom(MIoWriter& aWriter) const;
+		};
+	
+	class TConsoleWriterRequest : public TConsoleRequest
+		{
+	protected:
+		TConsoleWriterRequest(MIoWriter& aWriter);
+	private: // From TConsoleRequest.
+		virtual TBool OriginatedFrom(MIoWriter& aWriter) const;
+	protected:
+		MIoWriter& iWriter;
+		};
+	
+	class TConsoleReaderRequest : public TConsoleRequest
+		{
+	protected:
+		TConsoleReaderRequest(MIoReader& aReader);
+	private: // From TConsoleRequest.
+		virtual TBool OriginatedFrom(MIoReader& aReader) const;
+	protected:
+		MIoReader& iReader;
+		};
+	
+	class TConsoleCreateRequest : public TConsoleRequest
+		{
+	public:
+		TConsoleCreateRequest(CIoConsole& aOwner);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+	private:
+		CIoConsole& iOwner;
+		};
+	
+	class TConsoleWriteRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleWriteRequest(MIoWriter& aWriter);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void PrepareL();
+		virtual void CompleteD(TInt aError);
+	private:
+		HBufC* iBuf;
+		};
+	
+	class TConsoleCursorPosRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleCursorPosRequest(MIoWriter& aWriter);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+	private:
+		TPoint iPos;
+		TPckg<TPoint> iPosPckg;
+		};
+		
+	class TConsoleSetCursorPosAbsRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleSetCursorPosAbsRequest(MIoWriter& aWriter, const TPoint& aPoint);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+	private:
+		TPoint iPoint;
+		};
+		
+	class TConsoleSetCursorPosRelRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleSetCursorPosRelRequest(MIoWriter& aWriter, const TPoint& aPoint);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+	private:
+		TPoint iPoint;
+		};
+	
+	class TConsoleSetCursorHeightRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleSetCursorHeightRequest(MIoWriter& aWriter, TInt aHeight);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+	private:
+		TInt iHeight;
+		};
+		
+	class TConsoleSetTitleRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleSetTitleRequest(MIoWriter& aWriter);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void PrepareL();
+		virtual void CompleteD(TInt aError);
+	private:
+		HBufC* iTitle;
+		};
+		
+	class TConsoleClearScreenRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleClearScreenRequest(MIoWriter& aWriter);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+		};
+	
+	class TConsoleClearToEndOfLineRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleClearToEndOfLineRequest(MIoWriter& aWriter);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+		};
+		
+	class TConsoleScreenSizeRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleScreenSizeRequest(MIoWriter& aWriter, const TIoConfig& aConfig);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+	private:
+		const TIoConfig& iConfig;
+		TSize iSize;
+		TPckg<TSize> iSizeBuf;
+		};
+		
+	class TConsoleSetAttributesRequest : public TConsoleWriterRequest
+		{
+	public:
+		TConsoleSetAttributesRequest(MIoWriter& aWriter, TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+	private:
+		TUint iAttributes;
+		ConsoleAttributes::TColor iForegroundColor;
+		ConsoleAttributes::TColor iBackgroundColor;
+		};
+		
+	class TConsoleSetUnderlyingRequest : public TConsoleRequest
+		{
+	public:
+		TConsoleSetUnderlyingRequest(CIoConsole& aUnderlyingConsole);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void PrepareL();
+		virtual void CompleteD(TInt aError);
+	private:
+		CIoConsole& iConsole;
+		RIoConsoleProxy iSession;
+		};
+	friend class TConsoleSetUnderlyingRequest;
+	
+	class TConsoleSetModeRequest : public TConsoleReaderRequest
+		{
+	public:
+		TConsoleSetModeRequest(MIoReader& aReader, CIoConsole& aConsole, RIoReadWriteHandle::TMode aMode);
+		virtual void Request(RIoConsoleProxy aProxy, TRequestStatus& aStatus);
+		virtual void CompleteD(TInt aError);
+	private:
+		CIoConsole& iConsole;
+		RIoReadWriteHandle::TMode iMode;
+		};
+	friend class TConsoleSetModeRequest;
+		
+	class CConsoleRequest : public CActive
+		{
+	public:
+		CConsoleRequest(CIoConsole& aConsole);
+		
+		void Service(TConsoleRequest* aRequest);
+		~CConsoleRequest();
+		const TConsoleRequest* CurrentRequest() const;
+		void Abort();
+	private:
+		void Complete(TConsoleRequest* aRequest, TInt aError);
+	private: // from CActive
+		virtual void RunL();
+		virtual void DoCancel();
+	private:
+		CIoConsole& iConsole;
+		TConsoleRequest* iCurrentRequest;
+		};
+		
+	class CServerDeathWatcher : public CActive
+		{
+	public:
+		CServerDeathWatcher(RServer2& aServer, RThread& aThread);
+		~CServerDeathWatcher();
+	private:
+		virtual void RunL();
+		virtual void DoCancel();
+	private:
+		RServer2& iServer;
+		RThread& iThread;
+		};
+	friend class TConsoleCreateRequest;
+	friend class CConsoleRequest;
+	friend class CConsoleReader;
+	friend class TConsoleDetectSizeRequest;
+protected:
+	const TIoConfig& iConfig;
+	RIoConsoleProxy iConsole;
+	CConsoleReader* iReader;
+	mutable TSize iDetectedSize;
+	mutable TBool iSizeDetected;
+	HBufC* iImplementation;
+	TSize iCreationSize;
+	HBufC* iCreationTitle;
+	TInt iCreateStatus;
+	mutable RArray<TConsoleRequest*> iRequestQueue;
+	CConsoleRequest* iRequestAo;
+	RServer2 iThreadServer;
+	RThread iServerThread;
+	CServerDeathWatcher* iThreadWatcher;
+	};
+	
+class CIoConsoleProxyServer : public CConsoleProxyServer
+	{
+public:
+	static CIoConsoleProxyServer* NewL(TConsoleCreateFunction aConsoleCreate, RLibrary& aConsoleLibrary);
+	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+	~CIoConsoleProxyServer();
+	MProxiedConsole* TheConsole() const;
+	void SetTheConsole(MProxiedConsole* aConsole);
+private:
+	CIoConsoleProxyServer(TConsoleCreateFunction aConsoleCreate, const RLibrary& aConsoleLibrary);
+private:
+	RLibrary iConsoleLibrary;
+	MProxiedConsole* iTheConsole;
+	};
+
+CConsoleProxyServer* CIoConsoleProxyServerNewL(TAny* aParams);
+
+class CIoConsoleProxySession : public CConsoleProxySession
+	{
+public:
+	CIoConsoleProxySession(TConsoleCreateFunction aConsoleCreate);
+	~CIoConsoleProxySession();
+public: // from CConsoleProxySession:
+	virtual void ServiceL(const RMessage2& aMessage);
+	virtual MProxiedConsole* InstantiateConsoleL();
+	virtual void ConsoleCreatedL(MProxiedConsole* aConsole);
+private:
+	enum TFlag
+		{
+		ELazy				= 0x01,
+		EAutoDetectSize		= 0x02,
+		ESupportsStdErr		= 0x04,
+		};
+private:
+	CIoConsoleProxyServer* Server() { return (CIoConsoleProxyServer*)CConsoleProxySession::Server();}
+	void DetectSizeL(const RMessage2& aMessage);
+	void SetModeL(const RMessage2& aMessage);
+	void SetUnderlyingConsoleL(const RMessage2& aMessage);
+	void OpenExistingL(const RMessage2& aMessage);
+	
+	TBool GetFlag(TFlag aFlag);
+	void SetFlag(TFlag aFlag, TBool aSet);
+private:
+	CConsoleProxy* iUnderlyingConsole;
+	TUint iFlags;
+	TSize iDetectedSize;
+	};
+	
+class CWriteOnlyConsoleProxy : public CConsoleProxy
+	{
+public:
+	static CConsoleProxy* NewL(const RConsoleProxy& aProxySession);
+public: // from CConsoleProxy:
+	virtual void Read(TRequestStatus &aStatus);
+	virtual void ReadCancel();
+	virtual TKeyCode KeyCode() const;
+	virtual TUint KeyModifiers() const;
+private:
+	CWriteOnlyConsoleProxy();
+	};
+	
+class CLazyConsole : public CConsoleBase
+	{
+public:
+	CLazyConsole(TConsoleCreateFunction aConsoleCreate, TBool aAutoDetectSize);
+	~CLazyConsole();
+public: // from CConsoleBase
+	virtual TInt Create(const TDesC &aTitle,TSize aSize);
+	virtual void Read(TRequestStatus &aStatus);
+	virtual void ReadCancel();
+	virtual void Write(const TDesC &aDes);
+	virtual TPoint CursorPos() const;
+	virtual void SetCursorPosAbs(const TPoint &aPoint);
+	virtual void SetCursorPosRel(const TPoint &aPoint);
+	virtual void SetCursorHeight(TInt aPercentage);
+	virtual void SetTitle(const TDesC &aTitle);
+	virtual void ClearScreen();
+	virtual void ClearToEndOfLine();
+	virtual TSize ScreenSize() const;
+	virtual TKeyCode KeyCode() const;
+	virtual TUint KeyModifiers() const;
+	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+private:
+	TInt CheckCreated() const;
+private:
+	TConsoleCreateFunction iConsoleCreate;
+	TBool iSizeAutoDetect;
+	RBuf iTitle;
+	TSize iSize;
+	mutable TSize iDetectedSize;
+	mutable TInt iCreateError;
+	mutable CConsoleBase* iConsole;
+	};
+
+#endif //__CONSOLE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/endpoint.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,210 @@
+// endpoint.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "server.h"
+#include "endpoint.h"
+#include "log.h"
+
+#ifdef IOSRV_LOGGING
+#define ENDPOINT_NAME TName endPointName(Name())
+#define READER_NAME(x) TName readerName((x).IorName())
+#define WRITER_NAME(x) TName writerName((x).IowName())
+#else
+#define ENDPOINT_NAME
+#define READER_NAME(x)
+#define WRITER_NAME(x)
+#endif
+
+CIoEndPoint::~CIoEndPoint()
+	{
+	ENDPOINT_NAME;
+	LOG(CIoLog::Printf(_L("End point \"%S\" (0x%08x) destroying"), &endPointName, this));
+	iAttachedReaders.Close();
+	}
+	
+TName CIoEndPoint::IoepName() const
+	{
+	return Name();
+	}
+	
+TBool CIoEndPoint::IoepIsType(RIoHandle::TType aType) const
+	{
+	return IsType(aType);
+	}
+
+void CIoEndPoint::IorepAttachL(MIoReader& aReader, RIoEndPoint::TReadMode aMode)
+	{
+	ENDPOINT_NAME;
+	READER_NAME(aReader);
+	LOG(CIoLog::Printf(_L("Attaching reader \"%S\" (0x%08x) to end point \"%S\" (0x%08x)"), &readerName, &aReader, &endPointName, this));
+	User::LeaveIfError(Open());
+	CleanupClosePushL(*this);
+	if (aMode == RIoEndPoint::EForeground)
+		{
+		User::LeaveIfError(iAttachedReaders.Insert(&aReader, 0));
+		}
+	else
+		{
+		User::LeaveIfError(iAttachedReaders.Append(&aReader));
+		}
+	TInt err = HandleReaderAttached(aReader);
+	if (err!=KErrNone)
+		{
+		TInt index = FindReader(aReader);
+		iAttachedReaders.Remove(index);
+		User::Leave(err);
+		}
+	if (aMode == RIoEndPoint::EForeground)
+		{
+		HandleForegroundReaderChanged();
+		}
+	CleanupStack::Pop(this);
+	}
+
+void CIoEndPoint::IorepDetach(MIoReader& aReader)
+	{
+	ENDPOINT_NAME;
+	READER_NAME(aReader);
+	TInt index = FindReader(aReader);
+	if (index >= 0)
+		{
+		LOG(CIoLog::Printf(_L("Detaching reader \"%S\" (0x%08x) from end point \"%S\" (0x%08x)"), &readerName, &aReader, &endPointName, this));
+		iAttachedReaders.Remove(index);
+		HandleReaderDetached(aReader);
+		if ((index == 0) && (iAttachedReaders.Count() > 0))
+			{
+			HandleForegroundReaderChanged();
+			}
+		Close();
+		}
+	else
+		{
+		LOG(CIoLog::Printf(_L("Reader \"%S\" (0x%08x) not attached to end point \"%S\" (0x%08x) - detach request ignored"), &readerName, &aReader, &endPointName, this));
+		}
+	}
+
+void CIoEndPoint::IorepSetForegroundReaderL(MIoReader& aReader)
+	{
+	TInt index = FindReader(aReader);
+	User::LeaveIfError(index);
+	if (index > 0)
+		{
+		iAttachedReaders.Remove(index);
+		iAttachedReaders.Insert(&aReader, 0); // Shouldn't fail due to the above removal.
+		HandleForegroundReaderChanged();
+		}
+	}
+
+TBool CIoEndPoint::IorepIsForegroundL(const MIoReader& aReader) const
+	{
+	TInt index = FindReader(aReader);
+	User::LeaveIfError(index);
+	return (index == 0);
+	}
+	
+void CIoEndPoint::IowepAttachL(MIoWriter& aWriter)
+	{
+	User::LeaveIfError(Open());
+	++iAttachedWriterCount;
+	ENDPOINT_NAME;
+	WRITER_NAME(aWriter);
+	LOG(CIoLog::Printf(_L("Attached writer \"%S\" (0x%08x) to end point \"%S\" (0x%08x) (%d writers now attached)"), &writerName, &aWriter, &endPointName, this, iAttachedWriterCount));
+	TInt err = HandleWriterAttached(aWriter);
+	if (err!=KErrNone)
+		{
+		--iAttachedWriterCount;
+		User::Leave(err);
+		}
+	}
+
+void CIoEndPoint::IowepDetach(MIoWriter& aWriter)
+	{
+	--iAttachedWriterCount;
+	ENDPOINT_NAME;
+	WRITER_NAME(aWriter);
+	LOG(CIoLog::Printf(_L("Detached writer \"%S\" (0x%08x) from end point \"%S\" (0x%08x) (%d writers now attached)"), &writerName, &aWriter, &endPointName, this, iAttachedWriterCount));
+	HandleWriterDetached(aWriter);
+	Close();
+	}
+
+TInt CIoEndPoint::HandleReaderAttached(MIoReader&)
+	{
+	return KErrNone;
+	}
+
+void CIoEndPoint::HandleReaderDetached(MIoReader&)
+	{
+	}
+	
+void CIoEndPoint::ForegroundReaderChanged()
+	{
+	}
+
+TInt CIoEndPoint::HandleWriterAttached(MIoWriter&)
+	{
+	return KErrNone;
+	}
+
+void CIoEndPoint::HandleWriterDetached(MIoWriter&)
+	{
+	}
+
+void CIoEndPoint::HandleForegroundReaderChanged()
+	{
+	MIoReader* fg = AttachedReader();
+	if (fg)
+		{
+		fg->IorReaderChange(RIoReadHandle::EGainedForeground);
+		}
+	ForegroundReaderChanged();
+	}
+
+CIoEndPoint::CIoEndPoint()
+	{
+	}
+
+TInt CIoEndPoint::NumAttachedReaders() const
+	{
+	return iAttachedReaders.Count();
+	}
+
+MIoReader* CIoEndPoint::AttachedReader(TInt aIndex)
+	{
+	if ((aIndex >= 0) && (aIndex < iAttachedReaders.Count()))
+		{
+		return iAttachedReaders[aIndex];
+		}
+	return NULL;
+	}
+
+TInt CIoEndPoint::NumAttachedWriters() const
+	{
+	return iAttachedWriterCount;
+	}
+
+TInt CIoEndPoint::FindReader(MIoReader& aReader) const
+	{
+	const TInt numReaders = iAttachedReaders.Count();
+	for (TInt i = 0; i < numReaders; ++i)
+		{
+		if (iAttachedReaders[i] == &aReader)
+			{
+			return i;
+			}
+		}
+	return KErrNotFound;
+	}
+
+TInt CIoEndPoint::FindReader(const MIoReader& aReader) const
+	{
+	return FindReader(const_cast<MIoReader&>(aReader));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/endpoint.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,57 @@
+// endpoint.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __ENDPOINT_H__
+#define __ENDPOINT_H__
+
+#include <e32base.h>
+#include "readwrite.h"
+
+
+class CIoEndPoint : public CIoObject, public MIoReadEndPoint, public MIoWriteEndPoint
+	{
+public:
+	~CIoEndPoint();
+public: // From MIoEndPoint:
+	virtual TName IoepName() const;
+	virtual TBool IoepIsType(RIoHandle::TType aType) const;
+public: // From MIoReadEndPoint.
+	virtual void IorepAttachL(MIoReader& aReader, RIoEndPoint::TReadMode aMode);
+	virtual void IorepDetach(MIoReader& aReader);
+	virtual void IorepSetForegroundReaderL(MIoReader& aReader);
+	virtual TBool IorepIsForegroundL(const MIoReader& aReader) const;
+private: // From MIoWriteEndPoint.
+	virtual void IowepAttachL(MIoWriter& aWriter);
+	virtual void IowepDetach(MIoWriter& aWriter);
+private: // New.
+	virtual TInt HandleReaderAttached(MIoReader& aReader);
+	virtual void HandleReaderDetached(MIoReader& aReader);
+	virtual void ForegroundReaderChanged();
+	virtual TInt HandleWriterAttached(MIoWriter& aWriter);
+	virtual void HandleWriterDetached(MIoWriter& aWriter);
+protected:
+	virtual void HandleForegroundReaderChanged();
+protected:
+	CIoEndPoint();
+	TInt NumAttachedReaders() const;
+	MIoReader* AttachedReader(TInt aIndex = 0);
+	TInt NumAttachedWriters() const;
+private:
+	TInt FindReader(MIoReader& aReader) const;
+	TInt FindReader(const MIoReader& aReader) const;
+private:
+	TInt iAttachedWriterCount;
+	RPointerArray<MIoReader> iAttachedReaders;
+	};
+
+#endif // __ENDPOINT_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/file.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,122 @@
+// file.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "file.h"
+#include "log.h"
+#include <fshell/ltkutils.h>
+
+CIoFile* CIoFile::NewLC(RFs& aFs, const TDesC& aName, RIoFile::TMode aMode)
+	{
+	CIoFile* self = new(ELeave) CIoFile();
+	CleanupClosePushL(*self);
+	self->ConstructL(aFs, aName, aMode);
+	return self;
+	}
+
+CIoFile::~CIoFile()
+	{
+	iFile.Close();
+	iTempReadBuf.Close();
+	}
+
+TBool CIoFile::IsType(RIoHandle::TType aType) const
+	{
+	return ((aType == RIoHandle::EEndPoint) || (aType == RIoHandle::EFile));
+	}
+
+void CIoFile::IorepReadL(MIoReader& aReader)
+	{
+	TInt fileSize;
+	User::LeaveIfError(iFile.Size(fileSize));
+	if (iPos < fileSize)
+		{
+		TDes& readBuf = aReader.IorReadBuf();
+		iTempReadBuf.Zero();
+		HBufC8* narrowBuf = HBufC8::NewLC(readBuf.MaxLength());
+		TPtr8 narrowBufPtr(narrowBuf->Des());
+		User::LeaveIfError(iFile.Read(narrowBufPtr, readBuf.MaxLength()));
+		iPos += narrowBuf->Length();
+		iTempReadBuf.AppendUtf8L(narrowBufPtr);
+		if (iPos >= fileSize)
+			{
+			iTempReadBuf.FinalizeUtf8();
+			}
+		readBuf.Copy(iTempReadBuf);
+		aReader.IorDataBuffered(readBuf.Length());
+		CleanupStack::PopAndDestroy(narrowBuf);
+		if (iPos >= fileSize)
+			{
+			aReader.IorReadComplete(KErrNone);
+			}
+		}
+	else
+		{
+		aReader.IorReadComplete(KErrEof);
+		}
+	}
+
+void CIoFile::IowepWriteL(MIoWriter& aWriter)
+	{
+	HBufC* buf = HBufC::NewLC(aWriter.IowWriteLength());
+	TPtr bufPtr(buf->Des());
+	aWriter.IowWrite(bufPtr);
+
+	// Convert to UTF-8
+	HBufC8* narrowBuf = LtkUtils::Utf8L(*buf);
+	TInt err = iFile.Write(*narrowBuf);
+	delete narrowBuf;
+	aWriter.IowComplete(err);
+	CleanupStack::PopAndDestroy(buf);
+	}
+
+void CIoFile::IowepWriteCancel(MIoWriter&)
+	{
+	}
+
+CIoFile::CIoFile()
+	{
+	}
+
+void CIoFile::ConstructL(RFs& aFs, const TDesC& aName, RIoFile::TMode aMode)
+	{
+	LOG(CIoLog::Printf(_L("Attempting to create file 0x%08x (\"%S\")"), this, &aName));
+	switch (aMode)
+		{
+		case RIoFile::ERead:
+			{
+			User::LeaveIfError(iFile.Open(aFs, aName, EFileRead));
+			break;
+			}
+		case RIoFile::EOverwrite:
+			{
+			User::LeaveIfError(iFile.Replace(aFs, aName, EFileWrite));
+			break;
+			}
+		case RIoFile::EAppend:
+			{
+			TInt err = iFile.Open(aFs, aName, EFileWrite);
+			if (err == KErrNotFound)
+				{
+				err = iFile.Create(aFs, aName, EFileWrite);
+				}
+			User::LeaveIfError(err);
+			TInt pos = 0;
+			User::LeaveIfError(iFile.Seek(ESeekEnd, pos));
+			break;
+			}
+		default:
+			{
+			User::Leave(KErrNotSupported);
+			}
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/file.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// file.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include <f32file.h>
+#include "endpoint.h"
+#include "readwrite.h"
+#include <fshell/descriptorutils.h>
+
+class CIoFile : public CIoEndPoint
+	{
+public:
+	static CIoFile* NewLC(RFs& aFs, const TDesC& aName, RIoFile::TMode aMode);
+	~CIoFile();
+public: // From CIoObject.
+	virtual TBool IsType(RIoHandle::TType aType) const;
+public: // From MIoReadEndPoint.
+	virtual void IorepReadL(MIoReader& aReader);
+public: // From MIoWriteEndPoint.
+	virtual void IowepWriteL(MIoWriter& aWriter);
+	virtual void IowepWriteCancel(MIoWriter& aWriter);
+private:
+	CIoFile();
+	void ConstructL(RFs& aFs, const TDesC& aName, RIoFile::TMode aMode);
+private:
+	RFile iFile;
+	TInt iPos;
+	LtkUtils::RLtkBuf iTempReadBuf;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/log.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,289 @@
+// log.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "log.h"
+#ifdef IOSRV_LOGGING
+
+#include "server.h"
+#include "clientserver.h"
+
+#ifndef IOSRV_LOGGING_USES_CLOGGER
+_LIT(KLogFileName, "c:\\logs\\iosrv.txt");
+_LIT8(KNewLine, "\r\n");
+#endif
+
+#if !defined(__WINS__) || defined (EKA2)
+CIoLog* gLog = NULL;
+#endif
+
+CIoLog* CIoLog::NewL(RFs& aFs)
+	{
+	CIoLog* self = new(ELeave) CIoLog(aFs);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CIoLog::~CIoLog()
+	{
+#ifdef IOSRV_LOGGING_USES_CLOGGER
+	iClogger.Close();
+#else
+	iFile.Close();
+#endif
+#if defined(__WINS__) && !defined(EKA2)
+	Dll::SetTls(NULL);
+#endif
+	}
+
+
+#define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
+#define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
+	
+const TDesC* CIoLog::StringifyError(TInt aError)
+	{
+	switch (aError)
+		{
+		CASE_RETURN_LIT(KErrNone);
+		CASE_RETURN_LIT(KErrNotFound);
+		CASE_RETURN_LIT(KErrGeneral);
+		CASE_RETURN_LIT(KErrCancel);
+		CASE_RETURN_LIT(KErrNoMemory);
+		CASE_RETURN_LIT(KErrNotSupported);
+		CASE_RETURN_LIT(KErrArgument);
+		CASE_RETURN_LIT(KErrBadHandle);
+		CASE_RETURN_LIT(KErrOverflow);
+		CASE_RETURN_LIT(KErrUnderflow);
+		CASE_RETURN_LIT(KErrAlreadyExists);
+		CASE_RETURN_LIT(KErrPathNotFound);
+		CASE_RETURN_LIT(KErrDied);
+		CASE_RETURN_LIT(KErrInUse);
+		CASE_RETURN_LIT(KErrServerTerminated);
+		CASE_RETURN_LIT(KErrServerBusy);
+		CASE_RETURN_LIT(KErrCompletion);
+		CASE_RETURN_LIT(KErrNotReady);
+		CASE_RETURN_LIT(KErrUnknown);
+		CASE_RETURN_LIT(KErrCorrupt);
+		CASE_RETURN_LIT(KErrAccessDenied);
+		CASE_RETURN_LIT(KErrLocked);
+		CASE_RETURN_LIT(KErrWrite);
+		CASE_RETURN_LIT(KErrDisMounted);
+		CASE_RETURN_LIT(KErrEof);
+		CASE_RETURN_LIT(KErrDiskFull);
+		CASE_RETURN_LIT(KErrBadDriver);
+		CASE_RETURN_LIT(KErrBadName);
+		CASE_RETURN_LIT(KErrCommsLineFail);
+		CASE_RETURN_LIT(KErrCommsFrame);
+		CASE_RETURN_LIT(KErrCommsOverrun);
+		CASE_RETURN_LIT(KErrCommsParity);
+		CASE_RETURN_LIT(KErrTimedOut);
+		CASE_RETURN_LIT(KErrCouldNotConnect);
+		CASE_RETURN_LIT(KErrCouldNotDisconnect);
+		CASE_RETURN_LIT(KErrDisconnected);
+		CASE_RETURN_LIT(KErrBadLibraryEntryPoint);
+		CASE_RETURN_LIT(KErrBadDescriptor);
+		CASE_RETURN_LIT(KErrAbort);
+		CASE_RETURN_LIT(KErrTooBig);
+		CASE_RETURN_LIT(KErrDivideByZero);
+		CASE_RETURN_LIT(KErrBadPower);
+		CASE_RETURN_LIT(KErrDirFull);
+		CASE_RETURN_LIT(KErrHardwareNotAvailable);
+#ifdef EKA2
+		CASE_RETURN_LIT(KErrPermissionDenied);
+#endif
+//		CASE_RETURN_LIT(KErrExtensionNotSupported);
+//		CASE_RETURN_LIT(KErrCommsBreak);
+		DEFAULT_RETURN_LIT("*** ERROR UNKNOWN ***");
+		}
+	}
+	
+const TDesC* CIoLog::StringifyOpcode(TInt aOpCode)
+	{
+	switch (aOpCode)
+		{
+		CASE_RETURN_LIT(EIoHandleClose);
+		CASE_RETURN_LIT(EIoHandleSetOwner);
+		CASE_RETURN_LIT(EIoHandleSetUnderlyingConsole);
+		CASE_RETURN_LIT(EIoHandleAttachedToConsole);
+		CASE_RETURN_LIT(EIoCreateReader);
+		CASE_RETURN_LIT(EIoOpenReaderByThreadId);
+		CASE_RETURN_LIT(EIoOpenReaderByExplicitThreadId);
+		CASE_RETURN_LIT(EIoDuplicateReader);
+		CASE_RETURN_LIT(EIoCreateWriter);
+		CASE_RETURN_LIT(EIoOpenWriterByThreadId);
+		CASE_RETURN_LIT(EIoOpenWriterByExplicitThreadId);
+		CASE_RETURN_LIT(EIoDuplicateWriter);
+		CASE_RETURN_LIT(EIoSetReadWriteMode);
+		CASE_RETURN_LIT(EIoSetReadMode);
+		CASE_RETURN_LIT(EIoSetReaderToForeground);
+		CASE_RETURN_LIT(EIoRead);
+		CASE_RETURN_LIT(EIoSetLineSeparator);
+		CASE_RETURN_LIT(EIoWrite);
+		CASE_RETURN_LIT(EIoReadCancel);
+		CASE_RETURN_LIT(EIoWriteCancel);
+		CASE_RETURN_LIT(EIoIsForegroundReader);
+		CASE_RETURN_LIT(EIoConsoleWaitForKey);
+		CASE_RETURN_LIT(EIoConsoleWaitForKeyCancel);
+		CASE_RETURN_LIT(EIoConsoleCaptureKey);
+		CASE_RETURN_LIT(EIoConsoleCancelCaptureKey);
+		CASE_RETURN_LIT(EIoConsoleCaptureAllKeys);
+		CASE_RETURN_LIT(EIoConsoleCancelCaptureAllKeys);
+		CASE_RETURN_LIT(EIoConsoleCursorPos);
+		CASE_RETURN_LIT(EIoConsoleSetCursorPosAbs);
+		CASE_RETURN_LIT(EIoConsoleSetCursorPosRel);
+		CASE_RETURN_LIT(EIoConsoleSetCursorHeight);
+		CASE_RETURN_LIT(EIoConsoleSetTitle);
+		CASE_RETURN_LIT(EIoConsoleClearScreen);
+		CASE_RETURN_LIT(EIoConsoleClearToEndOfLine);
+		CASE_RETURN_LIT(EIoConsoleScreenSize);
+		CASE_RETURN_LIT(EIoConsoleSetAttributes);
+		CASE_RETURN_LIT(EIoEndPointAttachReader);
+		CASE_RETURN_LIT(EIoEndPointAttachWriter);
+		CASE_RETURN_LIT(EIoEndPointSetForegroundReadHandle);
+		CASE_RETURN_LIT(EIoCreatePipe);
+		CASE_RETURN_LIT(EIoCreateConsole);
+		CASE_RETURN_LIT(EIoOpenConsole);
+		CASE_RETURN_LIT(EIoConsoleImplementation);
+		CASE_RETURN_LIT(EIoCreateFile);
+		CASE_RETURN_LIT(EIoCreateNull);
+		CASE_RETURN_LIT(EIoSetObjectName);
+		CASE_RETURN_LIT(EIoCreatePersistentConsole);
+		CASE_RETURN_LIT(EIoOpenPersistentConsoleByName);
+		CASE_RETURN_LIT(EIoPersistentConsoleAttachReadEndPoint);
+		CASE_RETURN_LIT(EIoPersistentConsoleAttachWriteEndPoint);
+		CASE_RETURN_LIT(EIoPersistentConsoleDetachReadEndPoint);
+		CASE_RETURN_LIT(EIoPersistentConsoleDetachWriteEndPoint);
+		CASE_RETURN_LIT(EIoPersistentConsoleNotifyReadDetach);
+		CASE_RETURN_LIT(EIoPersistentConsoleNotifyWriteDetach);
+		CASE_RETURN_LIT(EIoPersistentConsoleCancelNotifyReadDetach);
+		CASE_RETURN_LIT(EIoPersistentConsoleCancelNotifyWriteDetach);
+		CASE_RETURN_LIT(EIoHandleIsType);
+		CASE_RETURN_LIT(EIoHandleGetName);
+		CASE_RETURN_LIT(EIoHandleEquals);
+		CASE_RETURN_LIT(EIoReadHandleNotifyChange);
+		CASE_RETURN_LIT(EIoReadHandleCancelNotifyChange);
+		CASE_RETURN_LIT(EIoDuplicateReaderHandleFromThread);
+		CASE_RETURN_LIT(EIoDuplicateWriterHandleFromThread);
+		DEFAULT_RETURN_LIT("*** OPCODE UNKNOWN ***");
+		}
+	}
+
+class TOverflowTruncate : public TDes16Overflow
+	{
+public:
+	virtual void Overflow(TDes16&) {}
+	};
+
+class RMessageAccess : public RMsg
+	{
+public:
+	TInt Handle() const { return iHandle; }
+	};
+
+void CIoLog::StartServiceLC(const RMsg& aMessage)
+	{
+	CIoLog& self = Self();
+	ASSERT(!self.iInServiceL);
+	self.iScratchBuf.SetLength(0);
+	self.iScratchBuf = ClientNameL(aMessage);
+	CleanupStack::PushL(TCleanupItem(EndService, &self));
+	TOverflowTruncate overflow;
+	self.iScratchBuf.AppendFormat(_L(" requested %S (opcode: %d, message handle: %d)"), &overflow, StringifyOpcode(aMessage.Function()), aMessage.Function(), static_cast<const RMessageAccess&>(aMessage).Handle());
+	self.Write(self.iScratchBuf);
+	self.iInServiceL = ETrue;
+	}
+
+void CIoLog::EndService(TAny* aSelf)
+	{
+	CIoLog& self = *(static_cast<CIoLog*>(aSelf));
+	ASSERT(self.iInServiceL);
+	self.Write(KNullDesC);
+	self.iInServiceL = EFalse;
+	}
+
+void CIoLog::LogCompletion(const RMsg& aMessage, TInt aError)
+	{
+	TFullName threadName(_L("unknown"));
+	TRAP_IGNORE(threadName = ClientNameL(aMessage));
+	CIoLog& self = Self();
+	self.iScratchBuf.SetLength(0);
+	TOverflowTruncate overflow;
+	self.iScratchBuf.AppendFormat(_L("Completing %S's request (opcode: %S, message handle: %d) with %S(%d)"), &overflow, &threadName, StringifyOpcode(aMessage.Function()), static_cast<const RMessageAccess&>(aMessage).Handle(), StringifyError(aError), aError);
+	self.Write(self.iScratchBuf);
+	}
+
+void CIoLog::Write(const TDesC& aData)
+	{
+	CIoLog& self = Self();
+#ifdef IOSRV_LOGGING_USES_CLOGGER
+	if (aData.Length() == 0) return; // The trick of writing knulldesc to get a newline is not really appropriate with clogger
+	self.iClogger.Log(aData);
+#else
+	if (self.iFile.SubSessionHandle())
+		{
+		self.iNarrowBuf.Copy(aData.Left(self.iNarrowBuf.MaxLength() - KNewLine().Length() - 1));
+		if (self.iInServiceL)
+			{
+			self.iNarrowBuf.Insert(0, _L8("\t"));
+			}
+		self.iNarrowBuf.Append(KNewLine);
+		self.iFile.Write(self.iNarrowBuf);
+		self.iFile.Flush();
+		}
+#endif
+	}
+
+void CIoLog::Printf(TRefByValue<const TDesC> aFmt, ...)
+	{
+	TOverflowTruncate overflow;
+	VA_LIST list;
+	VA_START(list, aFmt);
+	CIoLog& self = Self();
+	self.iScratchBuf.SetLength(0);
+	self.iScratchBuf.AppendFormatList(aFmt, list, &overflow);
+	Write(self.iScratchBuf);
+	}
+
+CIoLog::CIoLog(RFs& aFs)
+	: iFs(aFs)
+	{
+	}
+
+void CIoLog::ConstructL()
+	{
+#ifdef IOSRV_LOGGING_USES_CLOGGER
+	_LIT(KIoSrvLog, "iosrv");
+	User::LeaveIfError(iClogger.Connect(KIoSrvLog));
+#else
+//	iFs.MkDirAll(KLogFileName);
+	/*User::LeaveIfError*/(iFile.Replace(iFs, KLogFileName, EFileWrite));
+#endif
+#if defined(__WINS__) && !defined(EKA2)
+	Dll::SetTls(this);
+#else
+	gLog = this;
+#endif
+	Write(KNullDesC);
+	Write(_L("New log created"));
+	}
+
+CIoLog& CIoLog::Self()
+	{
+#if defined(__WINS__) && !defined(EKA2)
+	return *(static_cast<CIoLog*>(Dll::Tls()));
+#else
+	return *gLog;
+#endif
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/log.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,72 @@
+// log.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __LOG_H__
+#define __LOG_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include "server.h"
+
+#ifdef _DEBUG
+//#define IOSRV_LOGGING
+#endif
+
+#ifdef IOSRV_LOGGING
+
+#ifdef IOSRV_LOGGING_USES_CLOGGER // This is defined in the mmp
+#include <fshell/clogger.h>
+#endif
+
+#define LOG(x) x
+#define OBJ_NAME(x) TName objName((x).Name())
+
+class CIoLog : public CBase
+	{
+public:
+	static CIoLog* NewL(RFs& aFs);
+	~CIoLog();
+	static void StartServiceLC(const RMsg& aMessage);
+	static void LogCompletion(const RMsg& aMessage, TInt aError);
+	static void Write(const TDesC& aData);
+	static void Printf(TRefByValue<const TDesC> aFmt, ...);
+	static const TDesC* StringifyError(TInt aError);
+	static const TDesC* StringifyOpcode(TInt aOpCode);
+private:
+	CIoLog(RFs& aFs);
+	void ConstructL();
+	static CIoLog& Self();
+	static void EndService(TAny* aSelf);
+private:
+	RFs& iFs;
+#ifdef IOSRV_LOGGING_USES_CLOGGER
+	RClogger iClogger;
+#else
+	RFile iFile;
+	TBuf8<0x100> iNarrowBuf;
+#endif
+	TBuf<0x100> iScratchBuf;
+	TBool iInServiceL;
+	};
+
+#if !defined(__WINS__) || defined (EKA2)
+extern CIoLog* gLog;
+#endif
+
+#else
+
+#define LOG(x)
+#define OBJ_NAME(x)
+
+#endif // IOSRV_LOGGING
+
+#endif // __LOG_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/null.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+// null.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "null.h"
+#include "log.h"
+
+CIoNull* CIoNull::NewLC()
+	{
+	CIoNull* self = new(ELeave) CIoNull();
+	LOG(CIoLog::Printf(_L("Null 0x%08x created"), self));
+	CleanupClosePushL(*self);
+	return self;
+	}
+
+CIoNull::~CIoNull()
+	{
+	}
+
+TBool CIoNull::IsType(RIoHandle::TType aType) const
+	{
+	return ((aType == RIoHandle::EEndPoint) || (aType == RIoHandle::ENull));
+	}
+
+void CIoNull::IorepReadL(MIoReader&)
+	{
+	User::Leave(KErrEof);
+	}
+
+void CIoNull::IowepWriteL(MIoWriter& aWriter)
+	{
+	aWriter.IowComplete(KErrNone);
+	}
+
+void CIoNull::IowepWriteCancel(MIoWriter&)
+	{
+	}
+
+CIoNull::CIoNull()
+	{
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/null.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// null.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include "endpoint.h"
+#include "readwrite.h"
+
+
+class CIoNull : public CIoEndPoint
+	{
+public:
+	static CIoNull* NewLC();
+	~CIoNull();
+public: // From CIoObject.
+	virtual TBool IsType(RIoHandle::TType aType) const;
+public: // From MIoReadEndPoint.
+	virtual void IorepReadL(MIoReader& aReader);
+public: // From MIoWriteEndPoint.
+	virtual void IowepWriteL(MIoWriter& aWriter);
+	virtual void IowepWriteCancel(MIoWriter& aWriter);
+private:
+	CIoNull();
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/object.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+// object.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "object.h"
+
+void CIoObject::SessionClosed(const CIoSession&)
+	{
+	}
+
+void CIoObject::ClosedBy(const CIoSession&)
+	{
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/object.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+// object.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include "iocli.h"
+
+class CIoSession;
+
+
+class CIoObject : public CObject
+	{
+public:
+	virtual TBool IsType(RIoHandle::TType aType) const = 0;
+	virtual void SessionClosed(const CIoSession& aSession);
+	virtual void ClosedBy(const CIoSession& aSession);
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/persistentconsole.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1189 @@
+// persistentconsole.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "persistentconsole.h"
+#include <e32hashtab.h>
+
+
+static void CleanupNullPointer(TAny* aPtrPtr)
+	{
+	*((TAny**)aPtrPtr) = NULL;
+	}
+	
+static void CleanupNullPointerPushL(TAny** aPtr)
+	{
+	CleanupStack::PushL(TCleanupItem(CleanupNullPointer, aPtr));
+	}
+	
+_LIT(KProxySuffix, "_proxy");
+
+//______________________________________________________________________________
+//						CIoPersistentConsole
+CIoPersistentConsole* CIoPersistentConsole::NewLC(const TDesC& aName, const TDesC& aTitle, CIoServer& aServer, const RMsg& aMessage)
+	{
+	CIoPersistentConsole* self = new(ELeave)CIoPersistentConsole(aServer);
+	CleanupClosePushL(*self);
+	self->ConstructL(aName, aTitle, aMessage);
+	return self;
+	}
+	
+TBool CIoPersistentConsole::CanConnectReaderL(const MIoReadEndPoint& aReader) const
+	{
+	// check that the candidate end point will not result in a circular connection of
+	// persistent consoles if it's connected to this one.
+	
+	RHashSet<TInt> chained; // addresses of CIoPersistentConsole's in any chain
+	CleanupClosePushL(chained);
+	chained.InsertL((TInt)this);
+	const MIoReadEndPoint* nextReader = &aReader;
+	while (nextReader && nextReader->IoepIsType(RIoHandle::EPersistentConsole))
+		{
+		const CIoPersistentConsole* next = (const CIoPersistentConsole*)nextReader;
+		if (chained.Find((TInt)next))
+			{
+			CleanupStack::PopAndDestroy();
+			return EFalse;
+			}
+		chained.InsertL((TInt)next);
+		nextReader = next->TransientReader();
+		}
+	CleanupStack::PopAndDestroy();
+	return ETrue;	
+	}
+	
+void CIoPersistentConsole::AttachTransientReaderL(MIoReadEndPoint& aReader, CIoSession* aDetachOnClose)
+	{
+	if (!CanConnectReaderL(aReader)) User::Leave(KErrCouldNotConnect);	
+		
+	if (iTransientReadEndPoint)
+		{
+		User::Leave(KErrInUse);
+		}
+		
+	
+	iTransientReadEndPoint = &aReader;
+	CleanupNullPointerPushL((TAny**)&iTransientReadEndPoint);
+	
+	TInt fgProxyPos = ReaderProxyIndex(AttachedReader());
+	if (fgProxyPos != KErrNotFound)
+		{
+		iTransientReadEndPoint->IorepAttachL(*iReaderProxies[fgProxyPos], RIoEndPoint::EForeground);
+		}
+	
+	TInt i = 0;
+	TRAPD(err, 
+		for (i=0; i<iReaderProxies.Count(); ++i)
+			{
+			if (i != fgProxyPos)
+				{
+				iTransientReadEndPoint->IorepAttachL(*iReaderProxies[i], RIoEndPoint::EBackground);
+				}
+			}
+		);
+		
+	if (err)
+		{
+		// deatch the readers the we successfully attached before failure
+		for (TInt j=0; j<i; ++j)
+			{
+			iTransientReadEndPoint->IorepDetach(*iReaderProxies[j]);
+			}
+		// also make sure that the foreground reader is deatched
+		if (fgProxyPos >= i)
+			{
+			iTransientReadEndPoint->IorepDetach(*iReaderProxies[fgProxyPos]);
+			}
+		User::Leave(err);
+		}
+	CleanupStack::Pop();
+	
+	iReadEndPointDetachOnClose = aDetachOnClose;
+		
+	// now foreward any outstanding read requests
+	for (TInt i=0; i<iReaderProxies.Count(); ++i)
+		{
+		iReaderProxies[i]->TransientReaderAttached(*iTransientReadEndPoint);
+		}
+		
+	MIoReader* fg = AttachedReader();
+	if (fg)
+		{
+		fg->IorReaderChange(RIoReadHandle::EGainedForeground | RIoReadHandle::EConsoleSizeChanged);
+		}
+	}
+	
+void CIoPersistentConsole::DetachTransientReader()
+	{
+	if (!iTransientReadEndPoint)
+		{
+		return;
+		}
+	MIoReadEndPoint* detaching = iTransientReadEndPoint;
+	iTransientReadEndPoint = NULL;
+
+	TInt fgReaderPos = ReaderProxyIndex(AttachedReader());
+	for (TInt i=0; i<iReaderProxies.Count(); ++i)
+		{
+		if (i!=fgReaderPos)
+			{
+			detaching->IorepDetach(*iReaderProxies[i]);
+			}
+		}
+	if (fgReaderPos!=KErrNotFound)
+		{
+		detaching->IorepDetach(*iReaderProxies[fgReaderPos]);
+		}
+	iReadEndPointDetachOnClose = NULL;
+
+	SendReadDetachNotifications();
+	}
+	
+const MIoReadEndPoint* CIoPersistentConsole::TransientReader() const
+	{
+	return iTransientReadEndPoint;
+	}	
+
+TBool CIoPersistentConsole::CanConnectWriterL(const MIoWriteEndPoint& aWriter) const
+	{
+	// check that the candidate end point will not result in a circular connection of
+	// persistent consoles if it's connected to this one.
+	
+	RHashSet<TInt> chained; // addresses of CIoPersistentConsole's in any chain
+	CleanupClosePushL(chained);
+	chained.InsertL((TInt)this);
+	const MIoWriteEndPoint* nextWriter = &aWriter;
+	while (nextWriter && nextWriter->IoepIsType(RIoHandle::EPersistentConsole))
+		{
+		const CIoPersistentConsole* next = (const CIoPersistentConsole*)nextWriter;
+		if (chained.Find((TInt)next))
+			{
+			CleanupStack::PopAndDestroy();
+			return EFalse;
+			}
+		chained.InsertL((TInt)next);
+		nextWriter = next->TransientWriter();
+		}
+	CleanupStack::PopAndDestroy();
+	return ETrue;	
+	}
+	
+void CIoPersistentConsole::AttachTransientWriterL(MIoWriteEndPoint& aWriter, CIoSession* aDetachOnClose)
+	{
+	if (!CanConnectWriterL(aWriter)) User::Leave(KErrCouldNotConnect);	
+	
+	if (iTransientWriteEndPoint)
+		{
+		User::Leave(KErrInUse);
+		}
+	iTransientWriteEndPoint = &aWriter;
+	CleanupNullPointerPushL((TAny**)&iTransientWriteEndPoint);
+	
+	TInt i = 0;
+	TRAPD(err, 
+		for (i=0; i<iWriterProxies.Count(); ++i)
+			{
+			iTransientWriteEndPoint->IowepAttachL(*iWriterProxies[i]);
+			}
+		);
+	if (err)
+		{
+		// deatch the writers the we successfully attached before failure
+		for (TInt j=0; j<i; ++j)
+			{
+			iWriterProxies[j]->TransientWriterDetach(*iTransientWriteEndPoint);
+			}
+		User::Leave(err);
+		}
+	CleanupStack::Pop();
+	
+	iWriteEndPointDetachOnClose = aDetachOnClose;
+	
+	TRAP_IGNORE(iTransientWriteEndPoint->IowepSetTitleL(iTitleSetter));
+	
+	for (TInt i=0; i<iWriterProxies.Count(); ++i)
+		{
+		iWriterProxies[i]->TransientWriterAttached(*iTransientWriteEndPoint);
+		}		
+	}
+	
+void CIoPersistentConsole::DetachTransientWriter()
+	{
+	if (!iTransientWriteEndPoint)
+		{
+		return;
+		}
+	MIoWriteEndPoint* detaching = iTransientWriteEndPoint;
+	iTransientWriteEndPoint = NULL;
+	for (TInt i=0; i<iWriterProxies.Count(); ++i)
+		{
+		iWriterProxies[i]->TransientWriterDetach(*detaching);
+		}
+	iWriteEndPointDetachOnClose = NULL;
+	
+	SendWriteDetachNotifications();
+	}
+	
+const MIoWriteEndPoint* CIoPersistentConsole::TransientWriter() const
+	{
+	return iTransientWriteEndPoint;
+	}
+	
+MIoWriteEndPoint* CIoPersistentConsole::TransientWriter()
+	{
+	return iTransientWriteEndPoint;
+	}
+	
+void CIoPersistentConsole::NotifyReadDetachL(const RMsg& aMessage)
+	{
+	if ((iReaderProxies.Count()==0) || !iTransientReadEndPoint)
+		{
+		Complete(aMessage, KErrNone);
+		}
+	else
+		{
+		iReadDetachNotifications.AppendL(aMessage);
+		}
+	}
+	
+void CIoPersistentConsole::CancelNotifyReadDetach(TRequestStatus* aClientStatus)
+	{
+	for (TInt i=0; i<iReadDetachNotifications.Count(); ++i)
+		{
+		if (iReadDetachNotifications[i].ClientStatus() == aClientStatus)
+			{
+			Complete(iReadDetachNotifications[i], KErrCancel);
+			iReadDetachNotifications.Remove(i);
+			return;
+			}
+		}
+	}
+	
+void CIoPersistentConsole::NotifyWriteDetachL(const RMsg& aMessage)
+	{
+	if ((iWriterProxies.Count()==0) || !iTransientWriteEndPoint)
+		{
+		Complete(aMessage, KErrNone);
+		}
+	else
+		{
+		iWriteDetachNotifications.AppendL(aMessage);
+		}
+	}
+	
+void CIoPersistentConsole::CancelNotifyWriteDetach(TRequestStatus* aClientStatus)
+	{
+	for (TInt i=0; i<iWriteDetachNotifications.Count(); ++i)
+		{
+		if (iWriteDetachNotifications[i].ClientStatus() == aClientStatus)
+			{
+			Complete(iWriteDetachNotifications[i], KErrCancel);
+			iWriteDetachNotifications.Remove(i);
+			return;
+			}
+		}
+	}
+	
+TName CIoPersistentConsole::TransientReaderName()
+	{
+	if (iTransientReadEndPoint)
+		{
+		return iTransientReadEndPoint->IoepName();
+		}
+	else
+		{
+		return KNullDesC();
+		}
+	}
+	
+TName CIoPersistentConsole::TransientWriterName()
+	{
+	if (iTransientWriteEndPoint)
+		{
+		return iTransientWriteEndPoint->IoepName();
+		}
+	else
+		{
+		return KNullDesC();
+		}
+	}
+	
+TThreadId CIoPersistentConsole::Creator()
+	{
+	return iCreator.Id();
+	}
+	
+TName CIoPersistentConsole::Name() const
+	{
+	return iName;
+	}
+
+TBool CIoPersistentConsole::IsType(RIoHandle::TType aType) const
+	{
+	if (aType == RIoHandle::EPersistentConsole)
+		{
+		return ETrue;
+		}
+	else
+		{
+		return CIoConsole::IsType(aType);
+		}
+	}
+	
+void CIoPersistentConsole::SessionClosed(const CIoSession& aSession)
+	{
+	if (&aSession == iReadEndPointDetachOnClose)
+		{
+		DetachTransientReader();
+		}
+	if (&aSession == iWriteEndPointDetachOnClose)
+		{
+		DetachTransientWriter();
+		}
+	}
+	
+void CIoPersistentConsole::ClosedBy(const CIoSession& aSession)
+	{
+	SessionClosed(aSession);
+	}
+	
+void CIoPersistentConsole::SendReadDetachNotifications()
+	{
+	for (TInt i=0; i<iReadDetachNotifications.Count(); ++i)
+		{
+		Complete(iReadDetachNotifications[i], KErrNone);
+		}
+	iReadDetachNotifications.Reset();
+	}
+	
+void CIoPersistentConsole::SendWriteDetachNotifications()
+	{
+	for (TInt i=0; i<iWriteDetachNotifications.Count(); ++i)
+		{
+		Complete(iWriteDetachNotifications[i], KErrNone);
+		}
+	iWriteDetachNotifications.Reset();
+	}
+
+//______________________________________________________________________________
+//		MIoReadEndPoint implementation - to handle reads from persistent side
+TInt CIoPersistentConsole::HandleReaderAttached(MIoReader& aReader)
+	{
+	TIoReaderProxy* proxy = new TIoReaderProxy(aReader, *this);
+	TInt err = proxy ? KErrNone : KErrNoMemory;
+	if (err==KErrNone)
+		{
+		err = iReaderProxies.Append(proxy);
+		}
+	
+	if ((err == KErrNone) && iTransientReadEndPoint)
+		{
+		TRAP(err, iTransientReadEndPoint->IorepAttachL(*proxy, RIoEndPoint::EBackground));
+		}
+
+	if (err != KErrNone)
+		{
+		TInt pos = ReaderProxyIndex(proxy);
+		if (pos!=KErrNotFound)
+			{
+			iReaderProxies.Remove(pos);
+			}
+		delete proxy;
+		}		
+	return err;
+	}
+	
+void CIoPersistentConsole::HandleReaderDetached(MIoReader& aReader)
+	{
+	TInt pos = ReaderProxyIndex(&aReader);
+	if (pos!=KErrNotFound)
+		{
+		if (iTransientReadEndPoint)
+			{
+			iTransientReadEndPoint->IorepDetach(*iReaderProxies[pos]);
+			}
+		delete iReaderProxies[pos];
+		iReaderProxies.Remove(pos);
+		
+		if (iReaderProxies.Count()==0)
+			{
+			SendReadDetachNotifications();
+			}
+		}
+	}
+	
+void CIoPersistentConsole::HandleForegroundReaderChanged()
+	{
+	if (iTransientReadEndPoint)
+		{
+		CIoEndPoint::HandleForegroundReaderChanged();
+		}
+	else
+		{
+		ForegroundReaderChanged();
+		}
+	}
+	
+void CIoPersistentConsole::ForegroundReaderChanged()
+	{
+	MIoReader* fgReader = AttachedReader();
+	if (iTransientReadEndPoint && fgReader)
+		{
+		TInt fgPos = ReaderProxyIndex(fgReader);
+		ASSERT(fgPos != KErrNotFound);
+		TRAPD(err, iTransientReadEndPoint->IorepSetForegroundReaderL(*iReaderProxies[fgPos]));
+		__ASSERT_ALWAYS(err == KErrNone, User::Invariant());
+		// this would only fail if this endpoints list of readers differs from the transient
+		// endpoints list; the two should always be kept in sync.
+		}
+	}
+	
+TInt CIoPersistentConsole::ReaderProxyIndex(MIoReader* aReader) const
+	{
+	for (TInt i=0; i<iReaderProxies.Count(); ++i)
+		{
+		if (&iReaderProxies[i]->ClientReader() == aReader)
+			{
+			return i;
+			}
+		}
+	return KErrNotFound;
+	}
+
+void CIoPersistentConsole::IorepReadL(MIoReader& aReader)
+	{
+	TInt pos = ReaderProxyIndex(&aReader);
+	ASSERT(pos!=KErrNotFound);
+	iReaderProxies[pos]->ReadL(iTransientReadEndPoint);
+	}
+
+void CIoPersistentConsole::IorepReadKeyL(MIoReader& aReader)
+	{
+	TInt pos = ReaderProxyIndex(&aReader);
+	ASSERT(pos!=KErrNotFound);
+	iReaderProxies[pos]->ReadKeyL(iTransientReadEndPoint);
+	}
+
+void CIoPersistentConsole::IorepSetConsoleModeL(RIoReadWriteHandle::TMode aMode, MIoReader& aReader)
+	{
+	iPersistentConsoleMode = aMode;
+	GetReaderProxy(&aReader).SetConsoleModeL(iTransientReadEndPoint, aMode);
+	}
+
+//______________________________________________________________________________
+//		MIoWriteEndPoint implementation - to handles writes from persistent side
+TInt CIoPersistentConsole::HandleWriterAttached(MIoWriter& aWriter)
+	{
+	// call from CIoEndPoint
+	TIoWriterProxy* proxy = new TIoWriterProxy(aWriter, *this);
+	TInt err = proxy ? KErrNone : KErrNoMemory;
+	if (err==KErrNone)
+		{
+		err = iWriterProxies.Append(proxy);
+		}
+	
+	if ((err == KErrNone) && iTransientWriteEndPoint)
+		{
+		TRAP(err, iTransientWriteEndPoint->IowepAttachL(*proxy));
+		}
+
+	if (err != KErrNone)
+		{
+		TInt pos = WriterProxyIndex(proxy);
+		if (pos!=KErrNotFound)
+			{
+			iWriterProxies.Remove(pos);
+			}
+		delete proxy;
+		}		
+	return err;
+	}
+	
+void CIoPersistentConsole::HandleWriterDetached(MIoWriter& aWriter)
+	{
+	TInt pos = WriterProxyIndex(&aWriter);
+	if (pos!=KErrNotFound)
+		{
+		if (iTransientWriteEndPoint)
+			{
+			iWriterProxies[pos]->TransientWriterDetach(*iTransientWriteEndPoint);
+			}
+		delete iWriterProxies[pos];
+		iWriterProxies.Remove(pos);
+		
+		if (iWriterProxies.Count()==0)
+			{
+			SendWriteDetachNotifications();
+			}
+		}
+		
+	}
+	
+TInt CIoPersistentConsole::WriterProxyIndex(MIoWriter* aWriter) const
+	{
+	for (TInt i=0; i<iWriterProxies.Count(); ++i)
+		{
+		if (&iWriterProxies[i]->ClientWriter() == aWriter)
+			{
+			return i;
+			}
+		}
+	return KErrNotFound;
+	}
+	
+CIoPersistentConsole::TIoWriterProxy& CIoPersistentConsole::GetWriterProxy(MIoWriter* aWriter) const
+	{
+	TInt pos = WriterProxyIndex(aWriter);
+	ASSERT(pos!=KErrNotFound);
+	return *iWriterProxies[pos];
+	}
+	
+CIoPersistentConsole::TIoReaderProxy& CIoPersistentConsole::GetReaderProxy(MIoReader* aWriter) const
+	{
+	TInt pos = ReaderProxyIndex(aWriter);
+	ASSERT(pos!=KErrNotFound);
+	return *iReaderProxies[pos];
+	}
+
+void CIoPersistentConsole::IowepWriteL(MIoWriter& aWriter)
+	{
+	TInt pos = WriterProxyIndex(&aWriter);
+	ASSERT(pos!=KErrNotFound);
+	iWriterProxies[pos]->WriteL(iTransientWriteEndPoint);
+
+	// move the proxy to the end of the array so that we service the writes 
+	// in the correct order when we get a write end point, or when the end
+	// point goes away and comes back
+	TIoWriterProxy* proxy(iWriterProxies[pos]);
+	iWriterProxies.Remove(pos);
+	iWriterProxies.Append(proxy);
+	}
+	
+void CIoPersistentConsole::IowepWriteCancel(MIoWriter& aWriter)
+	{
+	TInt pos = WriterProxyIndex(&aWriter);
+	ASSERT(pos!=KErrNotFound);
+	iWriterProxies[pos]->WriteCancel(iTransientWriteEndPoint);
+	}
+
+void CIoPersistentConsole::IowepCursorPosL(MIoWriter& aWriter) const
+	{
+	GetWriterProxy(&aWriter).GetCursorPosL(iTransientWriteEndPoint);
+	}
+
+void CIoPersistentConsole::IowepSetCursorPosAbsL(const TPoint& aPoint, MIoWriter& aWriter)
+	{
+	GetWriterProxy(&aWriter).SetCursorPosAbsL(aPoint, iTransientWriteEndPoint);
+	}
+
+void CIoPersistentConsole::IowepSetCursorPosRelL(const TPoint& aPoint, MIoWriter& aWriter)
+	{
+	GetWriterProxy(&aWriter).SetCursorPosRelL(aPoint, iTransientWriteEndPoint);
+	}
+
+void CIoPersistentConsole::IowepSetCursorHeightL(TInt aPercentage, MIoWriter& aWriter)
+	{
+	GetWriterProxy(&aWriter).SetCursorHeightL(aPercentage, iTransientWriteEndPoint);
+	// TODO cache cursor height
+	}
+
+void CIoPersistentConsole::IowepSetTitleL(MIoWriter& aWriter)
+	{
+	delete iTitle;
+	iTitle = NULL;
+	TRAP_IGNORE(iTitle = aWriter.IowTitleLC(); CleanupStack::Pop(iTitle)); // not much we can do if this fails
+	GetWriterProxy(&aWriter).SetTitleL(iTransientWriteEndPoint);
+	}
+
+void CIoPersistentConsole::IowepClearScreenL(MIoWriter& aWriter)
+	{
+	GetWriterProxy(&aWriter).ClearScreenL(iTransientWriteEndPoint);
+	}
+
+void CIoPersistentConsole::IowepClearToEndOfLineL(MIoWriter& aWriter)
+	{
+	GetWriterProxy(&aWriter).ClearToEndOfLineL(iTransientWriteEndPoint);
+	}
+
+void CIoPersistentConsole::IowepScreenSizeL(MIoWriter& aWriter) const
+	{
+	GetWriterProxy(&aWriter).GetScreenSizeL(iTransientWriteEndPoint);
+	}
+
+void CIoPersistentConsole::IowepSetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriter& aWriter)
+	{
+	GetWriterProxy(&aWriter).SetAttributesL(aAttributes, aForegroundColor, aBackgroundColor, iTransientWriteEndPoint);
+	}
+	
+CIoPersistentConsole::CIoPersistentConsole(CIoServer& aServer)
+	: CIoConsole(aServer.Config()), iServer(aServer), iTitleSetter(iTitle)
+	{
+	}
+	
+CIoPersistentConsole::~CIoPersistentConsole()
+	{
+	iServer.PersistentConsoleRemove(iName, *this);
+	SendReadDetachNotifications();
+	iReadDetachNotifications.Close();
+	SendWriteDetachNotifications();
+	iWriteDetachNotifications.Close();
+	
+	delete iTitle;
+	iWriterProxies.ResetAndDestroy();
+	iReaderProxies.ResetAndDestroy();
+	
+	iCreator.Close();
+	}
+
+_LIT(KPersistentConsoleImplementation, "<persistent console>");
+
+void CIoPersistentConsole::ConstructL(const TDesC& aName, const TDesC& aTitle, const RMsg& aMessage)
+	{
+	LOG(CIoLog::Printf(_L("Persistent console %S @ 0x%08x created"), &aName, this));
+	iName = aName.Left(KMaxName);
+	iServer.PersistentConsoleAddL(iName, *this);
+	iImplementation = KPersistentConsoleImplementation().AllocL();
+	iTitle = aTitle.AllocL();
+	aMessage.ClientL(iCreator);
+	}
+
+//______________________________________________________________________________
+//							TIoWriterProxy
+// MIoWriter proxy to service write requests from the transient side
+CIoPersistentConsole::TIoWriterProxy::TIoWriterProxy(MIoWriter& aWriter, CIoPersistentConsole& aOwner)
+	: iWriter(aWriter)
+	, iOwner(aOwner)
+	, iFlags(0)
+	{
+	}
+	
+TBool CIoPersistentConsole::TIoWriterProxy::GetFlag(TFlags aFlag)
+	{
+	return iFlags & aFlag;
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::SetFlag(TFlags aFlag)
+	{
+	iFlags |= aFlag;
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::ClearFlag(TFlags aFlag)
+	{
+	iFlags &= (~aFlag);
+	}
+	
+#define TRAP_OR(x, y) {TRAPD(err, x); if (err!=KErrNone) {y;} }
+	
+	
+void CIoPersistentConsole::TIoWriterProxy::TransientWriterAttached(MIoWriteEndPoint& aEndPoint)
+	{
+	if (GetFlag(EWritePending))
+		{
+		TRAP_OR(aEndPoint.IowepWriteL(*this), IowComplete(err));
+		}
+	if (GetFlag(EGetCursorPosPending))
+		{
+		TRAP_OR(aEndPoint.IowepCursorPosL(*this), IowCursorPos(err, TPoint(0,0)));
+		}
+	if (GetFlag(ESetCursorPosAbsPending))
+		{
+		TRAP_OR(aEndPoint.IowepSetCursorPosAbsL(iSetCursPosAbsPoint, *this), IowSetCursorPosAbsComplete(err));
+		}
+	if (GetFlag(ESetCursorPosRelPending))
+		{
+		TRAP_OR(aEndPoint.IowepSetCursorPosRelL(iSetCursPosRelPoint, *this), IowSetCursorPosRelComplete(err));
+		}
+	if (GetFlag(ESetCursorHeightPending))
+		{
+		TRAP_OR(aEndPoint.IowepSetCursorHeightL(iSetCursorHeight, *this), IowSetCursorHeightComplete(err));
+		}
+	if (GetFlag(ESetTitlePending))
+		{
+		TRAP_OR(aEndPoint.IowepSetTitleL(*this), IowSetTitleComplete(err));
+		}
+	if (GetFlag(EClearScreenPending))
+		{
+		TRAP_OR(aEndPoint.IowepClearScreenL(*this), IowClearScreenComplete(err));
+		}
+	if (GetFlag(EClearToEndOfLinePending))
+		{
+		TRAP_OR(aEndPoint.IowepClearToEndOfLineL(*this), IowClearToEndOfLineComplete(err));
+		}
+	if (GetFlag(EGetScreenSizePending))
+		{
+		TRAP_OR(aEndPoint.IowepScreenSizeL(*this), IowScreenSize(err, TSize(0,0)));
+		}
+	if (GetFlag(ESetAttributesPending))
+		{
+		TRAP_OR(aEndPoint.IowepSetAttributesL(iAttributes, iForegroundColor, iBackgroundColor, *this), IowSetAttributesComplete(err));
+		}
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::TransientWriterDetach(MIoWriteEndPoint& aEndPoint)
+	{
+	if (GetFlag(EDetaching)) return;
+	if (GetFlag(EWritePending))
+		{
+		aEndPoint.IowepWriteCancel(*this);
+		// leave the write pending so it is serviced when we get a new transient end point
+		}
+	aEndPoint.IowepDetach(*this);
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::WriteL(MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(EWritePending);
+	if (aEndPoint)
+		{
+		TRAPD(err, aEndPoint->IowepWriteL(*this));
+		if (err)
+			{
+			ClearFlag(EWritePending);
+			User::Leave(err);
+			}
+		}
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::WriteCancel(MIoWriteEndPoint* aEndPoint)
+	{
+	if (aEndPoint)
+		{
+		aEndPoint->IowepWriteCancel(*this);
+		}
+	ClearFlag(EWritePending);
+	}
+
+	
+MIoWriter& CIoPersistentConsole::TIoWriterProxy::ClientWriter() const
+	{
+	return iWriter;
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::GetCursorPosL(MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(EGetCursorPosPending);
+	if (aEndPoint)
+		{
+		aEndPoint->IowepCursorPosL(*this);
+		}
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::SetCursorPosAbsL(const TPoint& aPos, MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(ESetCursorPosAbsPending);
+	iSetCursPosAbsPoint = aPos;
+	if (aEndPoint)
+		{
+		aEndPoint->IowepSetCursorPosAbsL(iSetCursPosAbsPoint, *this);
+		}
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::SetCursorPosRelL(const TPoint& aPos, MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(ESetCursorPosRelPending);
+	iSetCursPosRelPoint = aPos;
+	if (aEndPoint)
+		{
+		aEndPoint->IowepSetCursorPosRelL(iSetCursPosRelPoint, *this);
+		}
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::SetCursorHeightL(TInt aPercentage, MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(ESetCursorHeightPending);
+	iSetCursorHeight = aPercentage;
+	if (aEndPoint)
+		{
+		aEndPoint->IowepSetCursorHeightL(iSetCursorHeight, *this);
+		}
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::SetTitleL(MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(ESetTitlePending);
+	if (aEndPoint)
+		{
+		aEndPoint->IowepSetTitleL(*this);
+		}
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::ClearScreenL(MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(EClearScreenPending);
+	if (aEndPoint)
+		{
+		aEndPoint->IowepClearScreenL(*this);
+		}
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::ClearToEndOfLineL(MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(EClearToEndOfLinePending);
+	if (aEndPoint)
+		{
+		aEndPoint->IowepClearToEndOfLineL(*this);
+		}
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::GetScreenSizeL(MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(EGetScreenSizePending);
+	if (aEndPoint)
+		{
+		aEndPoint->IowepScreenSizeL(*this);
+		}
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriteEndPoint* aEndPoint)
+	{
+	SetFlag(ESetAttributesPending);
+	iAttributes = aAttributes;
+	iForegroundColor = aForegroundColor;
+	iBackgroundColor = aBackgroundColor;
+	if (aEndPoint)
+		{
+		aEndPoint->IowepSetAttributesL(iAttributes, iForegroundColor, iBackgroundColor, *this);
+		}
+	}
+
+TInt CIoPersistentConsole::TIoWriterProxy::IowWriteLength() const
+	{
+	return iWriter.IowWriteLength();
+	}
+
+TInt CIoPersistentConsole::TIoWriterProxy::IowWrite(TDes& aBuf)
+	{
+	return iWriter.IowWrite(aBuf);
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::IowComplete(TInt aError)
+	{
+	if (aError == KErrNone)
+		{
+		iWriter.IowComplete(KErrNone);
+		ClearFlag(EWritePending);
+		}
+	else
+		{
+		SetFlag(EDetaching);
+		iOwner.DetachTransientWriter();
+		ClearFlag(EDetaching);
+		}
+	}
+
+TName CIoPersistentConsole::TIoWriterProxy::IowName()
+	{
+	TName name(iWriter.IowName());
+	if (name.Length() + KProxySuffix().Length() > name.MaxLength())
+		{
+		name.SetLength(name.MaxLength() - KProxySuffix().Length());
+		}
+	name.Append(KProxySuffix);
+	return name;
+	}
+
+RIoReadWriteHandle::TMode CIoPersistentConsole::TIoWriterProxy::IorwMode() const
+	{
+	return iWriter.IorwMode();
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::IowCursorPos(TInt aError, TPoint aPos)
+	{
+	ClearFlag(EGetCursorPosPending);
+	iWriter.IowCursorPos(aError, aPos);
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::IowSetCursorPosAbsComplete(TInt aError)
+	{
+	ClearFlag(ESetCursorPosAbsPending);
+	iWriter.IowSetCursorPosAbsComplete(aError);
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::IowSetCursorPosRelComplete(TInt aError)
+	{
+	ClearFlag(ESetCursorPosRelPending);
+	iWriter.IowSetCursorPosRelComplete(aError);
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::IowSetCursorHeightComplete(TInt aError)
+	{
+	ClearFlag(ESetCursorHeightPending);
+	iWriter.IowSetCursorHeightComplete(aError);
+	}
+	
+void CIoPersistentConsole::TIoWriterProxy::IowSetTitleComplete(TInt aError)
+	{
+	ClearFlag(ESetTitlePending);
+	iWriter.IowSetTitleComplete(aError);
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::IowClearScreenComplete(TInt aError)
+	{
+	ClearFlag(EClearScreenPending);
+	iWriter.IowClearScreenComplete(aError);
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::IowClearToEndOfLineComplete(TInt aError)
+	{
+	ClearFlag(EClearToEndOfLinePending);
+	iWriter.IowClearToEndOfLineComplete(aError);
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::IowScreenSize(TInt aError, TSize aSize)
+	{
+	ClearFlag(EGetScreenSizePending);
+	iWriter.IowScreenSize(aError, aSize);
+	}
+
+void CIoPersistentConsole::TIoWriterProxy::IowSetAttributesComplete(TInt aError)
+	{
+	ClearFlag(ESetAttributesPending);
+	iWriter.IowSetAttributesComplete(aError);
+	}
+	
+HBufC* CIoPersistentConsole::TIoWriterProxy::IowTitleLC()
+	{
+	return iWriter.IowTitleLC();
+	}
+
+//______________________________________________________________________________
+//							TIoReaderProxy
+//	MIoReader proxy - to service read requests from transient side
+CIoPersistentConsole::TIoReaderProxy::TIoReaderProxy(MIoReader& aReader, CIoPersistentConsole& aOwner)
+	: iReader(aReader), iOwner(aOwner), iDetaching(EFalse), iSetConsoleModePending(EFalse)
+	{
+	}
+	
+void CIoPersistentConsole::TIoReaderProxy::TransientReaderAttached(MIoReadEndPoint& aReader)
+	{
+	if (iReader.IorReadPending())
+		{
+		TRAPD(err, aReader.IorepReadL(*this));
+		if (err)
+			{
+			IorReadComplete(err);
+			}
+		}
+	if (iReader.IorReadKeyPending())
+		{
+		TRAPD(err, aReader.IorepReadKeyL(*this));
+		if (err)
+			{
+			IorReadKeyComplete(err, EKeyNull, 0);
+			}
+		}
+	if (iSetConsoleModePending)
+		{
+		TRAP_OR(aReader.IorepSetConsoleModeL(iSetConsoleMode, *this), IorSetConsoleModeComplete(err));
+		}
+	}
+	
+void CIoPersistentConsole::TIoReaderProxy::ReadL(MIoReadEndPoint* aEndPoint)
+	{
+	if (aEndPoint)
+		{
+		aEndPoint->IorepReadL(*this);
+		}
+	}
+	
+void CIoPersistentConsole::TIoReaderProxy::ReadKeyL(MIoReadEndPoint* aEndPoint)
+	{
+	if (aEndPoint)
+		{
+		aEndPoint->IorepReadKeyL(*this);
+		}
+	}
+	
+void CIoPersistentConsole::TIoReaderProxy::SetConsoleModeL(MIoReadEndPoint* aEndPoint, RIoReadWriteHandle::TMode aMode)
+	{
+	iSetConsoleModePending = ETrue;
+	iSetConsoleMode = aMode;
+	if (aEndPoint)
+		{
+		CleanupNullPointerPushL((TAny**)&iSetConsoleModePending);
+		aEndPoint->IorepSetConsoleModeL(iSetConsoleMode, *this);
+		CleanupStack::Pop();
+		}
+	}
+	
+MIoReader& CIoPersistentConsole::TIoReaderProxy::ClientReader() const
+	{
+	return iReader;
+	}
+
+RIoReadWriteHandle::TMode CIoPersistentConsole::TIoReaderProxy::IorwMode() const
+	{
+	return iReader.IorwMode();
+	}
+
+TBool CIoPersistentConsole::TIoReaderProxy::IorReadPending() const
+	{
+	return iReader.IorReadPending();
+	}
+
+TBool CIoPersistentConsole::TIoReaderProxy::IorReadKeyPending() const
+	{
+	return iReader.IorReadKeyPending();
+	}
+
+
+TDes& CIoPersistentConsole::TIoReaderProxy::IorReadBuf()
+	{
+	return iReader.IorReadBuf();
+	}
+
+void CIoPersistentConsole::TIoReaderProxy::IorDataBuffered(TInt aLength)
+	{
+	iReader.IorDataBuffered(aLength);
+	}
+
+TBool CIoPersistentConsole::TIoReaderProxy::IorDataIsBuffered() const
+	{
+	return iReader.IorDataIsBuffered();
+	}
+
+
+TBool CIoPersistentConsole::TIoReaderProxy::IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers)
+	{
+	return iReader.IorIsKeyCaptured(aKeyCode, aModifiers);
+	}
+
+void CIoPersistentConsole::TIoReaderProxy::IorReadComplete(TInt /*aError*/)
+	{
+	// indicates that the read end point will be providing no more data
+	// so detatch it
+	iDetaching = ETrue;
+	iOwner.DetachTransientReader();
+	iDetaching = EFalse;
+	}
+
+void CIoPersistentConsole::TIoReaderProxy::IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers)
+	{
+	if (aError == KErrEof)
+		{
+		// indicates that the read end point will be providing no more data
+		// so detatch it
+		iOwner.DetachTransientReader();
+		}
+	else
+		{
+		iReader.IorReadKeyComplete(aError, aKeyCode, aModifiers);
+		}
+	}
+
+TName CIoPersistentConsole::TIoReaderProxy::IorName()
+	{
+	TName name(iReader.IorName());
+	if (name.Length() + KProxySuffix().Length() > name.MaxLength())
+		{
+		name.SetLength(name.MaxLength() - KProxySuffix().Length());
+		}
+	name.Append(KProxySuffix);
+	return name;
+	}
+
+void CIoPersistentConsole::TIoReaderProxy::IorReaderChange(TUint aChange)
+	{
+	iReader.IorReaderChange(aChange);
+	}
+
+void CIoPersistentConsole::TIoReaderProxy::IorSetConsoleModeComplete(TInt aError)
+	{
+	iSetConsoleModePending = EFalse;
+	iReader.IorSetConsoleModeComplete(aError);
+	}
+
+//______________________________________________________________________________
+//						TConsoleTitleSetter
+TConsoleTitleSetter::TConsoleTitleSetter(HBufC*& aTitle)
+	: iTitle(aTitle)
+	{
+	}
+
+TInt TConsoleTitleSetter::IowWriteLength() const
+	{
+	ASSERT(0);
+	return 0;
+	}
+
+TInt TConsoleTitleSetter::IowWrite(TDes&)
+	{
+	ASSERT(0);
+	return 0;
+	}
+
+void TConsoleTitleSetter::IowComplete(TInt)
+	{
+	ASSERT(0);
+	}
+
+TName TConsoleTitleSetter::IowName()
+	{
+	ASSERT(0);
+	return TName();
+	}
+
+RIoReadWriteHandle::TMode TConsoleTitleSetter::IorwMode() const
+	{
+	ASSERT(0);
+	return RIoReadWriteHandle::EText;
+	}
+
+void TConsoleTitleSetter::IowCursorPos(TInt, TPoint)
+	{
+	ASSERT(0);
+	}
+
+void TConsoleTitleSetter::IowSetCursorPosAbsComplete(TInt)
+	{
+	ASSERT(0);
+	}
+
+void TConsoleTitleSetter::IowSetCursorPosRelComplete(TInt)
+	{
+	ASSERT(0);
+	}
+
+void TConsoleTitleSetter::IowSetCursorHeightComplete(TInt)
+	{
+	ASSERT(0);
+	}
+
+void TConsoleTitleSetter::IowSetTitleComplete(TInt)
+	{
+	}
+
+void TConsoleTitleSetter::IowClearScreenComplete(TInt)
+	{
+	ASSERT(0);
+	}
+
+void TConsoleTitleSetter::IowClearToEndOfLineComplete(TInt)
+	{
+	ASSERT(0);
+	}
+
+void TConsoleTitleSetter::IowScreenSize(TInt, TSize)
+	{
+	ASSERT(0);
+	}
+
+void TConsoleTitleSetter::IowSetAttributesComplete(TInt)
+	{
+	ASSERT(0);
+	}
+
+HBufC* TConsoleTitleSetter::IowTitleLC()
+	{
+	return iTitle->AllocLC();
+	}
+
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/persistentconsole.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,239 @@
+// persistentconsole.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __PERSISTENTCONSOLE_H__
+#define __PERSISTENTCONSOLE_H__
+
+#include <e32base.h>
+#include "console.h"
+
+class TConsoleTitleSetter : public MIoWriter
+	{
+public:
+	TConsoleTitleSetter(HBufC*& aTitle);
+private: //from MIoReadWriter:
+	virtual RIoReadWriteHandle::TMode IorwMode() const;
+private: //from MIoWriter:
+	virtual TInt IowWriteLength() const;
+	virtual TInt IowWrite(TDes& aBuf);
+	virtual void IowComplete(TInt aError);
+	virtual TName IowName();
+	virtual void IowCursorPos(TInt aError, TPoint aPos);
+	virtual void IowSetCursorPosAbsComplete(TInt aError);
+	virtual void IowSetCursorPosRelComplete(TInt aError);
+	virtual void IowSetCursorHeightComplete(TInt aError);
+	virtual void IowSetTitleComplete(TInt aError);
+	virtual void IowClearScreenComplete(TInt aError);
+	virtual void IowClearToEndOfLineComplete(TInt aError);
+	virtual void IowScreenSize(TInt aError, TSize aSize);
+	virtual void IowSetAttributesComplete(TInt aError);
+	virtual HBufC* IowTitleLC();
+private:
+	HBufC*& iTitle;
+	};
+
+
+class CIoPersistentConsole
+		: public CIoConsole
+	{
+	class TIoWriterProxy;
+	class TIoReaderProxy;
+public:
+	static CIoPersistentConsole* NewLC(const TDesC& aName, const TDesC& aTitle, CIoServer& aServer, const RMsg& aMessage);
+	virtual ~CIoPersistentConsole();
+	
+	TBool CanConnectReaderL(const MIoReadEndPoint& aReader) const;
+	void AttachTransientReaderL(MIoReadEndPoint& aReader, CIoSession* aDetachOnClose);
+	void DetachTransientReader();
+	const MIoReadEndPoint* TransientReader() const;
+	TBool CanConnectWriterL(const MIoWriteEndPoint& aWriter) const;
+	void AttachTransientWriterL(MIoWriteEndPoint& aWriter, CIoSession* aDetachOnClose);
+	void DetachTransientWriter();
+	const MIoWriteEndPoint* TransientWriter() const;
+	MIoWriteEndPoint* TransientWriter();
+	
+	void NotifyReadDetachL(const RMsg& aMessage);
+	void CancelNotifyReadDetach(TRequestStatus* aClientStatus);
+	void NotifyWriteDetachL(const RMsg& aMessage);
+	void CancelNotifyWriteDetach(TRequestStatus* aClientStatus);
+	
+	TName TransientReaderName();
+	TName TransientWriterName();
+	
+	TThreadId Creator();
+	
+	// From CObject:
+	virtual TName Name() const;
+	// From CIoObject.
+	virtual TBool IsType(RIoHandle::TType aType) const;
+	virtual void SessionClosed(const CIoSession& aSession);
+	virtual void ClosedBy(const CIoSession& aSession);
+	// From MIoReadEndPoint.
+	virtual void IorepReadL(MIoReader& aReader);
+	virtual void IorepReadKeyL(MIoReader& aReader);
+	virtual void IorepSetConsoleModeL(RIoReadWriteHandle::TMode aMode, MIoReader& aReader);
+	// From MIoWriteEndPoint.
+	virtual void IowepWriteL(MIoWriter& aWriter);
+	virtual void IowepWriteCancel(MIoWriter& aWriter);
+	virtual void IowepCursorPosL(MIoWriter& aWriter) const;
+	virtual void IowepSetCursorPosAbsL(const TPoint& aPoint, MIoWriter& aWriter);
+	virtual void IowepSetCursorPosRelL(const TPoint& aPoint, MIoWriter& aWriter);
+	virtual void IowepSetCursorHeightL(TInt aPercentage, MIoWriter& aWriter);
+	virtual void IowepSetTitleL(MIoWriter& aWriter);
+	virtual void IowepClearScreenL(MIoWriter& aWriter);
+	virtual void IowepClearToEndOfLineL(MIoWriter& aWriter);
+	virtual void IowepScreenSizeL(MIoWriter& aWriter) const;
+	virtual void IowepSetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriter& aWriter);
+private:
+	// from CIoEndPoint:
+	virtual TInt HandleReaderAttached(MIoReader& aReader);
+	virtual void HandleReaderDetached(MIoReader& aReader);
+	virtual void ForegroundReaderChanged();
+	virtual TInt HandleWriterAttached(MIoWriter& aWriter);
+	virtual void HandleWriterDetached(MIoWriter& aWriter);
+	virtual void HandleForegroundReaderChanged();
+	
+	void SendReadDetachNotifications();
+	void SendWriteDetachNotifications();
+	
+	TInt ReaderProxyIndex(MIoReader* aReader) const;
+	TInt WriterProxyIndex(MIoWriter* aWriter) const;
+	TIoWriterProxy& GetWriterProxy(MIoWriter* aWriter) const;
+	TIoReaderProxy& GetReaderProxy(MIoReader* aReader) const;
+private:
+	CIoPersistentConsole(CIoServer& aServer);
+	void ConstructL(const TDesC& aName, const TDesC& aTitle, const RMsg& aMessage);
+
+	class TIoWriterProxy : public MIoWriter
+		{
+	public:
+		TIoWriterProxy(MIoWriter& aWriter, CIoPersistentConsole& aOwner);
+		void TransientWriterAttached(MIoWriteEndPoint& aWriteEndPoint);
+		void TransientWriterDetach(MIoWriteEndPoint& aWriteEndPoint);
+		
+		void WriteL(MIoWriteEndPoint* aEndPoint);
+		void WriteCancel(MIoWriteEndPoint* aEndPoint);
+		MIoWriter& ClientWriter() const;
+		void GetCursorPosL(MIoWriteEndPoint* aEndPoint);
+		void SetCursorPosAbsL(const TPoint& aPos, MIoWriteEndPoint* aEndPoint);
+		void SetCursorPosRelL(const TPoint& aPos, MIoWriteEndPoint* aEndPoint);
+		void SetCursorHeightL(TInt aPercentage, MIoWriteEndPoint* aEndPoint);
+		void SetTitleL(MIoWriteEndPoint* aEndPoint);
+		void ClearScreenL(MIoWriteEndPoint* aEndPoint);
+		void ClearToEndOfLineL(MIoWriteEndPoint* aEndPoint);
+		void GetScreenSizeL(MIoWriteEndPoint* aEndPoint);
+		void SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriteEndPoint* aEndPoint);
+
+		// from MIoReadWriter
+		virtual RIoReadWriteHandle::TMode IorwMode() const;
+		
+		// from MIoWriter
+		virtual TInt IowWriteLength() const;
+		virtual TInt IowWrite(TDes& aBuf);
+		virtual void IowComplete(TInt aError);
+		virtual TName IowName();
+		virtual void IowCursorPos(TInt aError, TPoint aPos);
+		virtual void IowSetCursorPosAbsComplete(TInt aError);
+		virtual void IowSetCursorPosRelComplete(TInt aError);
+		virtual void IowSetCursorHeightComplete(TInt aError);
+		virtual void IowSetTitleComplete(TInt aError);
+		virtual void IowClearScreenComplete(TInt aError);
+		virtual void IowClearToEndOfLineComplete(TInt aError);
+		virtual void IowScreenSize(TInt aError, TSize aSize);
+		virtual void IowSetAttributesComplete(TInt aError);
+		virtual HBufC* IowTitleLC();
+	private:
+		enum TFlags
+			{
+			EWritePending			= 0x0001,
+			EGetCursorPosPending	= 0x0002,
+			ESetCursorPosAbsPending	= 0x0004,
+			ESetCursorPosRelPending	= 0x0008,
+			EClearScreenPending		= 0x0010,
+			EClearToEndOfLinePending= 0x0020,
+			EGetScreenSizePending	= 0x0040,
+			EDetaching				= 0x0080,
+			ESetCursorHeightPending = 0x0100,
+			ESetTitlePending		= 0x0200,
+			ESetAttributesPending	= 0x0400
+			};
+	private:
+		TBool GetFlag(TFlags aFlag);
+		void SetFlag(TFlags aFlag);
+		void ClearFlag(TFlags aFlag);
+	private:
+		MIoWriter& iWriter;
+		CIoPersistentConsole& iOwner;
+		TUint iFlags;
+		TPoint iSetCursPosAbsPoint;
+		TPoint iSetCursPosRelPoint;
+		TInt iSetCursorHeight;
+		TUint iAttributes;
+		ConsoleAttributes::TColor iForegroundColor;
+		ConsoleAttributes::TColor iBackgroundColor;
+		};
+		
+	class TIoReaderProxy : public MIoReader
+		{
+	public:
+		TIoReaderProxy(MIoReader& aReader, CIoPersistentConsole& aOwner);
+		void TransientReaderAttached(MIoReadEndPoint& aReader);
+		
+		void ReadL(MIoReadEndPoint* aEndPoint);
+		void ReadKeyL(MIoReadEndPoint* aEndPoint);
+		void SetConsoleModeL(MIoReadEndPoint* aEndPoint, RIoReadWriteHandle::TMode aMode);
+		MIoReader& ClientReader() const;
+
+		// from MIoReadWriter
+		virtual RIoReadWriteHandle::TMode IorwMode() const;
+		
+		// from MIoReader
+		virtual TBool IorReadPending() const;
+		virtual TBool IorReadKeyPending() const;
+		virtual TDes& IorReadBuf();
+		virtual void IorDataBuffered(TInt aLength);
+		virtual TBool IorDataIsBuffered() const;
+		virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers);
+		virtual void IorReadComplete(TInt aError);
+		virtual void IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers);
+		virtual TName IorName();
+		virtual void IorReaderChange(TUint aChange);
+		virtual void IorSetConsoleModeComplete(TInt aError);
+	private:
+		MIoReader& iReader;
+		CIoPersistentConsole& iOwner;
+		TBool iDetaching;
+		TBool iSetConsoleModePending;
+		RIoReadWriteHandle::TMode iSetConsoleMode;
+		};
+private:
+	CIoServer& iServer;
+	RThread iCreator;
+	TName iName; // name for the persistent console, used to identify it
+	HBufC* iTitle; // title for the console, passed to CConsoleBase::SetTitle
+	MIoReadEndPoint* iTransientReadEndPoint;
+	CIoSession* iReadEndPointDetachOnClose;
+	MIoWriteEndPoint* iTransientWriteEndPoint;
+	CIoSession* iWriteEndPointDetachOnClose;
+	
+	RPointerArray<TIoWriterProxy> iWriterProxies;
+	RPointerArray<TIoReaderProxy> iReaderProxies;
+	
+	RIoReadWriteHandle::TMode iPersistentConsoleMode;
+	
+	RArray<RMsg> iReadDetachNotifications;
+	RArray<RMsg> iWriteDetachNotifications;
+	
+	TConsoleTitleSetter iTitleSetter;
+	};
+	
+#endif //__PERSISTENTCONSOLE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/pipe.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,176 @@
+// pipe.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "server.h"
+#include "pipe.h"
+#include "log.h"
+
+#ifdef IOSRV_LOGGING
+#define PIPE_NAME TName pipeName(Name())
+#define READER_NAME(x) TName readerName((x).IorName())
+#define WRITER_NAME(x) TName writerName((x).IowName())
+#else
+#define PIPE_NAME
+#define READER_NAME(x)
+#define WRITER_NAME(x)
+#endif
+
+CIoPipe* CIoPipe::NewLC()
+	{
+	CIoPipe* self = new(ELeave) CIoPipe();
+	LOG(CIoLog::Printf(_L("Pipe 0x%08x created"), self));
+	CleanupClosePushL(*self);
+	return self;
+	}
+
+CIoPipe::~CIoPipe()
+	{
+	iPendingWriters.Close();
+	}
+
+TBool CIoPipe::IsType(RIoHandle::TType aType) const
+	{
+	return ((aType == RIoHandle::EEndPoint) || (aType == RIoHandle::EPipe));
+	}
+
+void CIoPipe::IorepReadL(MIoReader& aReader)
+	{
+	if (&aReader == AttachedReader())
+		{
+		CheckReady();
+		DoCopy();
+		}
+	}
+
+void CIoPipe::IowepWriteL(MIoWriter& aWriter)
+	{
+	User::LeaveIfError(iPendingWriters.Append(&aWriter));
+	CheckReady();
+	DoCopy();
+	}
+
+void CIoPipe::IowepWriteCancel(MIoWriter& aWriter)
+	{
+	const TInt numPendingWriters = iPendingWriters.Count();
+	for (TInt i = 0; i < numPendingWriters; ++i)
+		{
+		if (&aWriter == iPendingWriters[i])
+			{
+			iPendingWriters.Remove(i);
+			break;
+			}
+		}
+	}
+
+void CIoPipe::ForegroundReaderChanged()
+	{
+	DoCopy();
+	}
+
+void CIoPipe::HandleReaderDetached(MIoReader&)
+	{
+	CheckReady();
+	}
+
+void CIoPipe::HandleWriterDetached(MIoWriter& aWriter)
+	{
+	const TInt numPendingWriters = iPendingWriters.Count();
+	for (TInt i = 0; i < numPendingWriters; ++i)
+		{
+		if (&aWriter == iPendingWriters[i])
+			{
+			iPendingWriters.Remove(i);
+			break;
+			}
+		}
+	CheckReady();
+	}
+
+CIoPipe::CIoPipe()
+	{
+	}
+
+void CIoPipe::DoCopy()
+	{
+	if ((AttachedReader() == NULL) || !AttachedReader()->IorReadPending())
+		{
+		return;
+		}
+
+	READER_NAME(*AttachedReader());
+	TInt readBufOffset = 0;
+	TDes& readBuf = AttachedReader()->IorReadBuf();
+	TBool readBuffered(EFalse);
+
+	while (iPendingWriters.Count() > 0)
+		{
+		MIoWriter& writer = *(iPendingWriters[0]);
+		WRITER_NAME(writer);
+		const TInt lengthToWrite = writer.IowWriteLength();
+		const TInt length = Min(lengthToWrite, readBuf.MaxLength() - readBuf.Length());
+		TPtr readPtr(const_cast<TText*>(readBuf.Ptr()) + readBufOffset, 0, length);
+		TInt err = writer.IowWrite(readPtr);
+		if (err == KErrNone)
+			{
+			LOG(CIoLog::Printf(_L("Copied %d chars from writer \"%S\" (0x%08x) to reader \"%S\" (0x%08x)"), readPtr.Length(), &writerName, &writer, &readerName, AttachedReader()));
+			readBufOffset += readPtr.Length();
+			readBuf.SetLength(readBufOffset);
+			readBuffered = ETrue;
+			if (lengthToWrite == length)
+				{
+				LOG(CIoLog::Printf(_L("Writer \"%S\" (0x%08x) fully copied"), &writerName, &writer));
+				writer.IowComplete(KErrNone);
+				iPendingWriters.Remove(0);
+				}
+			else if (readBuf.MaxLength() == readBuf.Length())
+				{
+				LOG(CIoLog::Printf(_L("Read buffer full (\"%S\" 0x%08x)"), &readerName, AttachedReader()));
+				break;
+				}
+			}
+		else
+			{
+			LOG(CIoLog::Printf(_L("Failed to copy \"%S\" from writer \"%S\" (0x%08x) to reader \"%S\" (0x%08x): %S(%d)"), &readPtr, &writerName, &writer, &readerName, AttachedReader(), CIoLog::StringifyError(err), err));
+			writer.IowComplete(err);
+			}
+		}
+
+	if (readBuffered)
+		{
+		AttachedReader()->IorDataBuffered(readBuf.Length());
+		}
+	}
+
+void CIoPipe::CheckReady()
+	{
+	if ((NumAttachedWriters() == 0) && AttachedReader() && AttachedReader()->IorReadPending())
+		{
+		if (AttachedReader()->IorDataIsBuffered())
+			{
+			AttachedReader()->IorReadComplete(KErrNone);
+			}
+		else
+			{
+			AttachedReader()->IorReadComplete(KErrEof);
+			}
+		}
+	else if (AttachedReader() == NULL)
+		{
+		while (iPendingWriters.Count())
+			{
+			MIoWriter* writer = iPendingWriters[0];
+			iPendingWriters.Remove(0);
+			writer->IowComplete(KErrNotReady);
+			}
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/pipe.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+// pipe.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __PIPE_H__
+#define __PIPE_H__
+
+#include <e32base.h>
+#include "endpoint.h"
+#include "readwrite.h"
+
+
+class CIoPipe : public CIoEndPoint
+	{
+public:
+	static CIoPipe* NewLC();
+	~CIoPipe();
+public: // From CIoObject.
+	virtual TBool IsType(RIoHandle::TType aType) const;
+public: // From MIoReadEndPoint.
+	virtual void IorepReadL(MIoReader& aReader);
+public: // From MIoWriteEndPoint.
+	virtual void IowepWriteL(MIoWriter& aWriter);
+	virtual void IowepWriteCancel(MIoWriter& aWriter);
+private: // From CIoEndPoint.
+	virtual void HandleReaderDetached(MIoReader& aReader);
+	virtual void ForegroundReaderChanged();
+	virtual void HandleWriterDetached(MIoWriter& aWriter);
+private:
+	CIoPipe();
+	void DoCopy();
+	void CheckReady();
+private:
+	RPointerArray<MIoWriter> iPendingWriters;
+	};
+
+#endif // __PIPE_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/readwrite.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1223 @@
+// readwrite.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "server.h"
+#include "pipe.h"
+#include "console.h"
+#include "readwrite.h"
+#include "session.h"
+#include "log.h"
+#include "persistentconsole.h"
+
+_LIT(KNewLine, "\r\n");
+_LIT(KLf, "\n");
+
+#ifdef IOSRV_LOGGING
+#define OBJ_NAME(x) TName objName((x).Name())
+#else
+#define OBJ_NAME(x)
+#endif
+
+#define __ASSERT_RETURN(x, y) {if (!(x)) {{y;};return;}}
+
+
+static void CleanupNullMessage(TAny* aMsgPtr)
+	{
+	*((RMsg*)aMsgPtr) = RMsg();
+	}
+	
+static void CleanupNullMessagePushL(RMsg& aMsg)
+	{
+	CleanupStack::PushL(TCleanupItem(CleanupNullMessage, &aMsg));
+	}
+	
+
+//
+// MIoEndPoint.
+//
+
+TBool MIoEndPoint::IoepIsConsole() const
+	{
+	return IoepIsType(RIoHandle::EConsole);
+	}
+
+
+//
+// MIoReadEndPoint.
+//
+
+void MIoReadEndPoint::IorepReadKeyL(MIoReader&)
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+void MIoReadEndPoint::IorepSetConsoleModeL(RIoReadWriteHandle::TMode, MIoReader& aReader)
+	{
+	aReader.IorSetConsoleModeComplete(KErrNotSupported);
+	}
+
+TBool MIoReadEndPoint::AttachedToConsole(const MIoReadEndPoint* aEp)
+	{
+	if (!aEp) return EFalse;
+	if (aEp->IoepIsType(RIoHandle::EPersistentConsole))
+		{
+		CIoPersistentConsole* pcons = (CIoPersistentConsole*)aEp;
+		return AttachedToConsole(pcons->TransientReader());
+		}
+	else
+		{
+		return aEp->IoepIsConsole();
+		}
+	}
+
+
+//
+// MIoWriteEndPoint.
+//
+
+void MIoWriteEndPoint::IowepCursorPosL(MIoWriter& aWriter) const
+	{
+	TPoint pos = IowepCursorPos();
+	aWriter.IowCursorPos(KErrNone, pos);
+	}
+	
+void MIoWriteEndPoint::IowepSetCursorPosAbsL(const TPoint& aPoint, MIoWriter& aWriter)
+	{
+	IowepSetCursorPosAbs(aPoint);
+	aWriter.IowSetCursorPosAbsComplete(KErrNone);
+	}
+	
+void MIoWriteEndPoint::IowepSetCursorPosRelL(const TPoint& aPoint, MIoWriter& aWriter)
+	{
+	IowepSetCursorPosRel(aPoint);
+	aWriter.IowSetCursorPosRelComplete(KErrNone);
+	}
+	
+void MIoWriteEndPoint::IowepSetCursorHeightL(TInt aPercentage, MIoWriter& aWriter)
+	{
+	IowepSetCursorHeight(aPercentage);
+	aWriter.IowSetCursorHeightComplete(KErrNone);
+	}
+	
+void MIoWriteEndPoint::IowepSetTitleL(MIoWriter& aWriter)
+	{
+	HBufC* title = aWriter.IowTitleLC();
+	IowepSetTitle(*title);
+	CleanupStack::PopAndDestroy(title);
+	aWriter.IowSetTitleComplete(KErrNone);
+	}
+	
+void MIoWriteEndPoint::IowepClearScreenL(MIoWriter& aWriter)
+	{
+	IowepClearScreen();
+	aWriter.IowClearScreenComplete(KErrNone);
+	}
+	
+void MIoWriteEndPoint::IowepClearToEndOfLineL(MIoWriter& aWriter)
+	{
+	IowepClearToEndOfLine();
+	aWriter.IowClearToEndOfLineComplete(KErrNone);
+	}
+	
+void MIoWriteEndPoint::IowepScreenSizeL(MIoWriter& aWriter) const
+	{
+	TSize size = IowepScreenSize();
+	aWriter.IowScreenSize(KErrNone, size);
+	}
+
+void MIoWriteEndPoint::IowepSetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriter& aWriter)
+	{
+	IowepSetAttributes(aAttributes, aForegroundColor, aBackgroundColor);
+	aWriter.IowSetAttributesComplete(KErrNone);
+	}
+
+TPoint MIoWriteEndPoint::IowepCursorPos() const
+	{
+	return TPoint(0, 0);
+	}
+
+void MIoWriteEndPoint::IowepSetCursorPosAbs(const TPoint&)
+	{
+	}
+
+void MIoWriteEndPoint::IowepSetCursorPosRel(const TPoint&)
+	{
+	}
+
+void MIoWriteEndPoint::IowepSetCursorHeight(TInt)
+	{
+	}
+
+void MIoWriteEndPoint::IowepSetTitle(const TDesC&)
+	{
+	}
+
+void MIoWriteEndPoint::IowepClearScreen()
+	{
+	}
+
+void MIoWriteEndPoint::IowepClearToEndOfLine()
+	{
+	}
+
+TSize MIoWriteEndPoint::IowepScreenSize() const
+	{
+	return TSize(0, 0);
+	}
+
+void MIoWriteEndPoint::IowepSetAttributes(TUint, ConsoleAttributes::TColor, ConsoleAttributes::TColor)
+	{
+	}
+
+TBool MIoWriteEndPoint::AttachedToConsole(const MIoWriteEndPoint* aEp)
+	{
+	if (!aEp) return EFalse;
+	if (aEp->IoepIsType(RIoHandle::EPersistentConsole))
+		{
+		CIoPersistentConsole* pcons = (CIoPersistentConsole*)aEp;
+		return AttachedToConsole(pcons->TransientWriter());
+		}
+	else
+		{
+		return aEp->IoepIsConsole();
+		}
+
+	}
+
+//
+// CIoReadWriteObject.
+//
+
+TUint CIoReadWriteObject::Id() const
+	{
+	return iId;
+	}
+
+CIoReadWriteObject::CIoReadWriteObject(TUint aId)
+	: iId(aId), iOwningThreadId(0)
+	{
+	}
+
+void CIoReadWriteObject::SetOwnerL(TThreadId aOwningThread)
+	{
+	iOwningThreadId = aOwningThread;
+	}
+
+TInt CIoReadWriteObject::Open(TThreadId aOwningThread)
+	{
+	TInt err = CObject::Open();
+	if ((err==KErrNone) && (IsOwner(aOwningThread)))
+		{
+		iOpenedByOwner = ETrue;
+		}
+	return err;
+	}
+	
+void CIoReadWriteObject::SetModeL(const RMsg& aMessage)
+	{
+	TInt mode(aMessage.Int0());
+	if ((mode >= RIoWriteHandle::EText) && (mode <= RIoWriteHandle::EBinary))
+		{
+		iMode = static_cast<RIoWriteHandle::TMode>(mode);
+		Complete(aMessage, KErrNone);
+		}
+	else
+		{
+		Complete(aMessage, KErrNotSupported);
+		}
+	}
+
+void CIoReadWriteObject::DoDuplicateL(const CIoReadWriteObject& aDuplicate)
+	{
+	iConsole = aDuplicate.iConsole;
+	}
+
+TBool CIoReadWriteObject::IsOwner(TThreadId aOwningThread) const
+	{
+	return iOwningThreadId == aOwningThread;
+	}
+
+TBool CIoReadWriteObject::OpenedByOwner() const
+	{
+	return iOpenedByOwner;
+	}
+
+void CIoReadWriteObject::SetConsole(CIoConsole& aConsole)
+	{
+	iConsole = &aConsole;
+	}
+
+CIoConsole* CIoReadWriteObject::Console()
+	{
+	return iConsole;
+	}
+
+MIoEndPoint* CIoReadWriteObject::EndPoint()
+	{
+	return iEndPoint;
+	}
+
+const CIoConsole* CIoReadWriteObject::Console() const
+	{
+	return iConsole;
+	}
+
+#ifndef IOSRV_LOGGING
+void CIoReadWriteObject::Dump(const TDesC&) const
+	{
+	}
+#else
+void CIoReadWriteObject::Dump(const TDesC& aData) const
+	{
+	TBuf<80> out;
+	TBuf<16> ascii;
+	TInt dataIndex = 0;
+	TInt pos = 0;
+	do
+		{
+		out.Zero();
+		ascii.Zero();
+		out.AppendNumFixedWidthUC(pos, EHex, 8);
+		out.Append(_L(": "));
+		for (TInt i = 0; i < 16; ++i)
+			{
+			if (dataIndex < aData.Length())
+				{
+				TUint8 byte = (TUint8)aData[dataIndex++];
+				out.AppendNumFixedWidthUC(byte, EHex, 2);
+				out.Append(_L(" "));
+				if ((byte < 0x20) || (byte >= 0x7f) || byte == '%')
+					{
+					byte = '.';
+					}
+				ascii.Append(TChar(byte));
+				++pos;
+				}
+			else
+				{
+				out.Append(_L("   "));
+				}
+			}
+		out.Append(ascii);
+		CIoLog::Printf(out);
+		}
+		while (dataIndex < aData.Length());
+	}
+#endif
+
+
+//
+// CIoReadObject.
+//
+
+CIoReadObject* CIoReadObject::NewLC(TInt aId)
+	{
+	CIoReadObject* self = new(ELeave) CIoReadObject(aId);
+	LOG(CIoLog::Printf(_L("Read object 0x%08x created"), self));
+	CleanupClosePushL(*self);
+	return self;
+	}
+
+CIoReadObject::~CIoReadObject()
+	{
+	OBJ_NAME(*this);
+	LOG(CIoLog::Printf(_L("Read object \"%S\" (0x%08x) destroying"), &objName, this));
+	if (iEndPoint)
+		{
+		ReadEndPoint()->IorepDetach(*this);
+		}
+
+	CompleteIfPending(iReadMessage, KErrSessionClosed);
+	CompleteIfPending(iReadKeyMessage, KErrSessionClosed);
+	CompleteIfPending(iChangeNotifyMessage, KErrSessionClosed);
+
+	delete iBuf;
+	delete iLineSeparator;
+	iCapturedKeys.Close();
+	iKeyBuffer.Close();
+	}
+
+void CIoReadObject::DuplicateL(const CIoReadObject& aDuplicate)
+	{
+	DoDuplicateL(aDuplicate);
+	if (aDuplicate.iEndPoint)
+		{
+		AttachL(*aDuplicate.ReadEndPoint(), RIoEndPoint::EBackground);
+		}
+	}
+
+void CIoReadObject::AttachL(MIoReadEndPoint& aEndPoint, RIoEndPoint::TReadMode aMode)
+	{
+	if (iEndPoint)
+		{
+		ReadEndPoint()->IorepDetach(*this);
+		}
+
+	aEndPoint.IorepAttachL(*this, aMode);
+	iEndPoint = &aEndPoint;
+	}
+
+void CIoReadObject::SetReadMode(RIoReadHandle::TReadMode aMode)
+	{
+	iReadMode = aMode;
+	}
+
+void CIoReadObject::SetToForegroundL()
+	{
+	if (iEndPoint)
+		{
+		ReadEndPoint()->IorepSetForegroundReaderL(*this);
+		}
+	}
+
+TBool CIoReadObject::IsForegroundL() const
+	{
+	if (iEndPoint)
+		{
+		return ReadEndPoint()->IorepIsForegroundL(*this);
+		}
+	return EFalse;
+	}
+
+void CIoReadObject::ReadL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicReadWhenNotAttached));
+	__ASSERT_RETURN(!MessagePending(iReadMessage) && !MessagePending(iReadKeyMessage), PanicClient(aMessage, EPanicReadAlreadyPending));
+
+	const TInt maxReadLength = MaxDesLengthL(aMessage, 0);
+	AllocateBufferL(maxReadLength);
+	iReadMessage = aMessage;
+	iMaxReadLength = maxReadLength;
+
+	if (iCompleteErr)
+		{
+		if ((iCompleteErr == KErrEof) && (iBuf->Length() > 0))
+			{
+			// the end point has reached the end of the stream
+			// but we haven't finished processing the data in our buffer yet
+			TryToCompleteRead();
+			}
+		else
+			{
+			iReadMessage.Complete(iCompleteErr);
+			}
+		}
+	else
+		{
+		ProcessRead();
+		}
+	}
+
+void CIoReadObject::ReadCancel(const CIoSession& aSession)
+	{
+	if (MessagePending(iReadMessage) && (iReadMessage.Session() == static_cast<const CSession2*>(&aSession)))
+		{
+		Complete(iReadMessage, KErrCancel);
+		iBuf->Des().Zero();
+		}
+	}
+
+void CIoReadObject::ProcessRead()
+	{
+	ASSERT((MessagePending(iReadMessage) || MessagePending(iReadKeyMessage)) && !(MessagePending(iReadMessage) && MessagePending(iReadKeyMessage)));
+
+	if (MessagePending(iReadMessage))
+		{
+		if (iCompleteErr)
+			{
+			iReadMessage.Complete(iCompleteErr);
+			}
+		else
+			{
+			TryToCompleteRead();
+
+			if (IorReadPending())
+				{
+				TRAPD(err, ReadEndPoint()->IorepReadL(*this));
+				if (err)
+					{
+					Complete(iReadMessage, err);
+					}
+				else if (IorReadPending())
+					{
+					TryToCompleteRead();
+					}
+				}
+			}
+		}
+	else
+		{
+		if (iCompleteErr)
+			{
+			iReadKeyMessage.Complete(iCompleteErr);
+			}
+		else
+			{
+			if (iKeyBuffer.Count() > 0)
+				{
+				CompleteReadKey(KErrNone, iKeyBuffer[0]);
+				iKeyBuffer.Remove(0);
+				}
+			else
+				{
+				TRAPD(err, ReadEndPoint()->IorepReadKeyL(*this));
+				if (err)
+					{
+					Complete(iReadKeyMessage, err);
+					}
+				}
+			}
+		}
+	}
+
+void CIoReadObject::SetLineSeparatorL(const RMsg& aMessage)
+	{
+	HBufC* separator = HBufC::NewLC(DesLengthL(aMessage, 0));
+	TPtr ptr(separator->Des());
+	MessageReadL(aMessage, 0, ptr);
+	delete iLineSeparator;
+	iLineSeparator = separator;
+	CleanupStack::Pop(separator);
+	Complete(aMessage, KErrNone);
+	}
+
+void CIoReadObject::ReadKeyL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicReadKeyWhenNotAttached));
+	__ASSERT_RETURN(!MessagePending(iReadMessage) && !MessagePending(iReadKeyMessage), PanicClient(aMessage, EPanicReadAlreadyPending));
+
+	iReadKeyMessage = aMessage;
+
+	if (iCompleteErr)
+		{
+		iReadKeyMessage.Complete(iCompleteErr);
+		}
+	else
+		{
+		ProcessRead();
+		}
+	}
+
+void CIoReadObject::ReadKeyCancel(const CIoSession& aSession)
+	{
+	if (MessagePending(iReadKeyMessage) && (iReadKeyMessage.Session() == &aSession))
+		{
+		Complete(iReadKeyMessage, KErrCancel);
+		}
+	}
+
+void CIoReadObject::CaptureKeyL(const RMsg& aMessage)
+	{
+	User::LeaveIfError(iCapturedKeys.Append(TCapturedKey(aMessage.Int0(), aMessage.Int1(), aMessage.Int2())));
+	Complete(aMessage, KErrNone);
+	}
+
+void CIoReadObject::CancelCaptureKey(const RMsg& aMessage)
+	{
+	TCapturedKey capturedKey(aMessage.Int0(), aMessage.Int1(), aMessage.Int2());
+	const TInt numCapturedKeys = iCapturedKeys.Count();
+	for (TInt i = 0; i < numCapturedKeys; ++i)
+		{
+		const TCapturedKey& thisCapturedKey = iCapturedKeys[i];
+		if ((capturedKey.iKeyCode == thisCapturedKey.iKeyCode) && (capturedKey.iModifiers == thisCapturedKey.iModifiers) && (capturedKey.iModifierMask == thisCapturedKey.iModifierMask))
+			{
+			iCapturedKeys.Remove(i);
+			Complete(aMessage, KErrNone);
+			return;
+			}
+		}
+
+	Complete(aMessage, KErrNotFound);
+	}
+
+void CIoReadObject::CaptureAllKeys(const RMsg& aMessage)
+	{
+	iCaptureAllKeys = ETrue;
+	Complete(aMessage, KErrNone);
+	}
+
+void CIoReadObject::CancelCaptureAllKeys(const RMsg& aMessage)
+	{
+	iCaptureAllKeys = EFalse;
+	Complete(aMessage, KErrNone);
+	}
+	
+void CIoReadObject::NotifyChange(const RMsg& aMessage)
+	{
+	if (MessagePending(iChangeNotifyMessage))
+		{
+		Complete(aMessage, KErrAlreadyExists);
+		}
+	else
+		{
+		iChangeNotifyMessage = aMessage;
+		}
+	}
+	
+void CIoReadObject::CancelNotifyChange(const CIoSession& aSession)
+	{
+	if (MessagePending(iChangeNotifyMessage) && (iChangeNotifyMessage.Session() == static_cast<const CSession2*>(&aSession)))
+		{
+		Complete(iChangeNotifyMessage, KErrCancel);
+		}
+	}
+
+void CIoReadObject::CancelSetMode(const CIoSession& aSession)
+	{
+	if (MessagePending(iSetModeMessage) && (iSetModeMessage.Session() == static_cast<const CSession2*>(&aSession)))
+		{
+		Complete(iSetModeMessage, KErrCancel);
+		}
+	}
+
+TBool CIoReadObject::IsType(RIoHandle::TType aType) const
+	{
+	return ((aType == RIoHandle::EReadWriteObject) || (aType == RIoHandle::EReadObject));
+	}
+
+void CIoReadObject::SessionClosed(const CIoSession& aSession)
+	{
+	ReadCancel(aSession);
+	ReadKeyCancel(aSession);
+	CancelNotifyChange(aSession);
+	CancelSetMode(aSession);
+	}
+
+void CIoReadObject::SetModeL(const RMsg& aMessage)
+	{
+	TInt mode(aMessage.Int0());
+	if ((mode >= RIoWriteHandle::EText) && (mode <= RIoWriteHandle::EBinary))
+		{
+		if (ReadEndPoint() && ReadEndPoint()->IorepIsForegroundL(*this))
+			{
+			__ASSERT_RETURN(!MessagePending(iSetModeMessage), PanicClient(aMessage, EPanicSetModeAlreadyPending));
+			ReadEndPoint()->IorepSetConsoleModeL((RIoReadWriteHandle::TMode)mode, *this);
+			iSetModeMessage = aMessage;
+			}
+		else
+			{
+			Complete(aMessage, KErrNone);
+			}
+
+		iMode = static_cast<RIoWriteHandle::TMode>(mode);
+		}
+	else
+		{
+		Complete(aMessage, KErrNotSupported);
+		}
+	}
+
+RIoReadWriteHandle::TMode CIoReadObject::IorwMode() const
+	{
+	return iMode;
+	}
+
+TBool CIoReadObject::IorReadPending() const
+	{
+	return (MessagePending(iReadMessage));
+	}
+
+TBool CIoReadObject::IorReadKeyPending() const
+	{
+	return (MessagePending(iReadKeyMessage));
+	}
+
+TDes& CIoReadObject::IorReadBuf()
+	{
+	ASSERT((iMaxReadLength - iBuf->Length()) > 0);
+	iPtr.Set(const_cast<TText*>(iBuf->Des().Ptr()) + iBuf->Length(), 0, iMaxReadLength - iBuf->Length());
+	return iPtr;
+	}
+
+void CIoReadObject::IorDataBuffered(TInt aLength)
+	{
+	iBuf->Des().SetLength(iBuf->Length() + aLength);
+	TryToCompleteRead();
+	}
+
+TBool CIoReadObject::IorDataIsBuffered() const
+	{
+	return (iBuf->Length() > 0);
+	}
+
+TBool CIoReadObject::IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers)
+	{
+	if (iCaptureAllKeys)
+		{
+		return ETrue;
+		}
+	const TInt numCapturedKeys = iCapturedKeys.Count();
+	for (TInt i = 0; i < numCapturedKeys; ++i)
+		{
+		const TCapturedKey& thisCapturedKey = iCapturedKeys[i];
+		if ((aKeyCode == thisCapturedKey.iKeyCode) && ((aModifiers & thisCapturedKey.iModifierMask) == thisCapturedKey.iModifiers))
+			{
+			return ETrue;
+			}
+		}
+	return EFalse;
+	}
+
+void CIoReadObject::IorReadComplete(TInt aError)
+	{
+	if ((aError == KErrNone) || (aError==KErrEof))
+		{
+		CompleteRead(aError, iBuf->Length());
+		}
+	else
+		{
+		CompleteRead(aError, 0);
+		}
+	}
+
+void CIoReadObject::IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers)
+	{
+	RIoConsoleReadHandle::TConsoleKey consoleKey;
+	consoleKey.iKeyCode = aKeyCode;
+	consoleKey.iModifiers = aModifiers;
+	if (IorReadKeyPending())
+		{
+		CompleteReadKey(aError, consoleKey);
+		}
+	else
+		{
+		if (aError)
+			{
+			LOG(CIoLog::Printf(_L("Error in IorReadKeyComplete %d"), aError));
+			if (IorReadPending()) CompleteRead(aError, 0);
+			// What state are we in if neither IorReadKeyPending or IorReadPending are true? Should we be setting iCompleteErr?
+			}
+		else
+			{
+			iKeyBuffer.Append(consoleKey);
+			if (IorReadPending())
+				{
+				TryToCompleteRead();
+				}
+			}
+		}
+	}
+
+TName CIoReadObject::IorName()
+	{
+	return Name();
+	}
+	
+void CIoReadObject::IorReaderChange(TUint aChange)
+	{
+	if ((aChange == RIoReadHandle::EGainedForeground) && iEndPoint && ReadEndPoint()->IoepIsType(RIoHandle::EConsole))
+		{
+		ReadEndPoint()->IorepSetConsoleModeL(iMode, *this);
+		}
+
+	if (MessagePending(iChangeNotifyMessage))
+		{
+		TRAPD(err, MessageWriteL(iChangeNotifyMessage, 0, TPckg<TUint>(aChange)));
+		Complete(iChangeNotifyMessage, err);
+		}
+	}
+
+void CIoReadObject::IorSetConsoleModeComplete(TInt aError)
+	{
+	if (MessagePending(iSetModeMessage))
+		{
+		// The set mode request was explicitly requested, so complete it.
+		Complete(iSetModeMessage, aError);
+		}
+	else
+		{
+		// The set mode request was made because the read object has come to the foreground. If there was an error,
+		// report it via the next read request. However, only report errors when setting to binary mode. This is because
+		// every console must implicitly support text mode, but they may not support the extension interface and report
+		// KErrExtensionNotSupported even for text mode.
+
+		if (aError && (iMode == RIoReadWriteHandle::EBinary))
+			{
+			iCompleteErr = aError;
+			}
+		}
+	}
+
+CIoReadObject::CIoReadObject(TInt aId)
+	: CIoReadWriteObject(aId), iPtr(NULL, 0, 0)
+	{
+	}
+
+void CIoReadObject::AllocateBufferL(TInt aLength)
+	{
+	if (iBuf == NULL)
+		{
+		iBuf = HBufC::NewL(aLength);
+		}
+	else if (iBuf->Des().MaxLength() < aLength)
+		{
+		iBuf = iBuf->ReAllocL(aLength);
+		}
+	}
+
+void CIoReadObject::TryToCompleteRead()
+	{
+	if (iKeyBuffer.Count() > 0)
+		{
+		// There are buffered key events so copy them into the read buffer.
+		TDes& readBuf = IorReadBuf();
+		while (iKeyBuffer.Count())
+			{
+			const RIoConsoleReadHandle::TConsoleKey& consoleKey = iKeyBuffer[0];
+			if ((IorwMode() == RIoReadWriteHandle::EText) && (consoleKey.iKeyCode == EKeyEnter))
+				{
+				if ((readBuf.Length() + KNewLine().Length()) <= readBuf.MaxLength())
+					{
+					// If there's enough room, expand EKeyEnter into "\r\n" (otherwise RIoReadHandle::ELine reads won't complete).
+					readBuf.Append(KNewLine);
+					}
+				else if (readBuf.Length() < readBuf.MaxLength())
+					{
+					// Otherwise, just put in the raw code code in the read buffer like normal - the client might be reading into a TBuf<1> (fshell does this for example), in which case there will never be enough room for "\r\n".
+					TPtrC keyCodePtr((TUint16*)&consoleKey.iKeyCode, 1);
+					readBuf.Append(keyCodePtr);
+					}
+				else
+					{
+					break;
+					}
+				}
+			else
+				{
+				if (readBuf.Length() < readBuf.MaxLength())
+					{
+					TPtrC keyCodePtr((TUint16*)&consoleKey.iKeyCode, 1);
+					readBuf.Append(keyCodePtr);
+					}
+				else
+					{
+					break;
+					}
+				}
+			iKeyBuffer.Remove(0);
+			}
+		iBuf->Des().SetLength(iBuf->Length() + readBuf.Length());
+		}
+
+	switch (iReadMode)
+		{
+		case RIoReadHandle::EFull:
+			{
+			if (iBuf->Length() == iMaxReadLength)
+				{
+				CompleteRead(KErrNone, iMaxReadLength);
+				}
+			break;
+			}
+		case RIoReadHandle::ELine:
+			{
+			const TDesC* lineSeparator = iLineSeparator;
+			if (lineSeparator == NULL) lineSeparator = &KLf;
+
+			TInt pos = iBuf->Find(*lineSeparator);
+			if (pos >= 0)
+				{
+				CompleteRead(KErrNone, pos + lineSeparator->Length());
+				}
+			else if (iBuf->Length() == iMaxReadLength)
+				{
+				CompleteRead(KErrNone, iMaxReadLength);
+				}
+			else if ((iBuf->Length() > 0) && (iCompleteErr == KErrEof))
+				{
+				// the read end point has reached the end of the stream
+				// there is still some data remaining, but no new line
+				// to just send the last bit
+				CompleteRead(KErrNone, iBuf->Length());
+				}
+			break;
+			}
+		case RIoReadHandle::EOneOrMore:
+			{
+			if (iBuf->Length() > 0)
+				{
+				CompleteRead(KErrNone, iBuf->Length());
+				}
+			break;
+			}
+		}
+	}
+
+void CIoReadObject::CompleteRead(TInt aError, TInt aLength)
+	{
+	if (IorReadPending())
+		{
+		OBJ_NAME(*this);
+
+		if ((aError == KErrNone)||(aError == KErrEof))
+			{
+			LOG(CIoLog::Printf(_L("Read object \'%S\' writing %d characters"), &objName, aLength));
+			TPtrC ptr(iBuf->Des().Ptr(), aLength);
+			LOG(Dump(ptr));
+			TRAPD(err, MessageWriteL(iReadMessage, 0, ptr));
+			if (err == KErrNone)
+				{
+				iBuf->Des().Delete(0, aLength);
+				}
+			else
+				{
+				aError = err;
+				}
+			}
+		
+		LOG(CIoLog::Printf(_L("Read object \'%S\' completing read message with %d"), &objName, aError));
+		Complete(iReadMessage, aError);
+		}
+	else if (aError)
+		{
+		iCompleteErr = aError;
+		}
+	}
+
+void CIoReadObject::CompleteReadKey(TInt aError, RIoConsoleReadHandle::TConsoleKey& aConsoleKey)
+	{
+	if (aError == KErrNone)
+		{
+		TPckgC<RIoConsoleReadHandle::TConsoleKey> consoleKeyPckg(aConsoleKey);
+		TRAP(aError, MessageWriteL(iReadKeyMessage, 0, consoleKeyPckg));
+		}
+	Complete(iReadKeyMessage, aError);
+	}
+
+MIoReadEndPoint* CIoReadObject::ReadEndPoint() const
+	{
+	return static_cast<MIoReadEndPoint*>(iEndPoint);
+	}
+
+CIoReadObject::TCapturedKey::TCapturedKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers)
+	: iKeyCode(aKeyCode), iModifierMask(aModifierMask), iModifiers(aModifiers)
+	{
+	}
+
+
+//
+// CIoWriteObject.
+//
+
+CIoWriteObject* CIoWriteObject::NewLC(TInt aId)
+	{
+	CIoWriteObject* self = new(ELeave) CIoWriteObject(aId);
+	LOG(CIoLog::Printf(_L("Write object 0x%08x created"), self));
+	CleanupClosePushL(*self);
+	return self;
+	}
+
+CIoWriteObject::~CIoWriteObject()
+	{
+	OBJ_NAME(*this);
+	LOG(CIoLog::Printf(_L("Write object \"%S\" (0x%08x) destroying"), &objName, this));
+	if (iEndPoint)
+		{
+		WriteEndPoint()->IowepDetach(*this);
+		}
+
+	CompleteIfPending(iWriteMessage, KErrSessionClosed);
+	CompleteIfPending(iGetCursorPosMsg, KErrSessionClosed);
+	CompleteIfPending(iSetCursorPosAbsMsg, KErrSessionClosed);
+	CompleteIfPending(iSetCursorPosRelMsg, KErrSessionClosed);
+	CompleteIfPending(iSetCursorHeightMsg, KErrSessionClosed);
+	CompleteIfPending(iSetTitleMsg, KErrSessionClosed);
+	CompleteIfPending(iClearScreenMsg, KErrSessionClosed);
+	CompleteIfPending(iClearToEndOfLineMsg, KErrSessionClosed);
+	CompleteIfPending(iGetScreenSizeMsg, KErrSessionClosed);
+	CompleteIfPending(iSetAttributesMsg, KErrSessionClosed);
+	}
+
+void CIoWriteObject::DuplicateL(const CIoWriteObject& aDuplicate)
+	{
+	DoDuplicateL(aDuplicate);
+	if (aDuplicate.iEndPoint)
+		{
+		AttachL(*aDuplicate.WriteEndPoint());
+		}
+	iIsStdErr = aDuplicate.iIsStdErr;
+	}
+
+void CIoWriteObject::AttachL(MIoWriteEndPoint& aEndPoint)
+	{
+	if (iEndPoint)
+		{
+		WriteEndPoint()->IowepDetach(*this);
+		}
+
+	aEndPoint.IowepAttachL(*this);
+	iEndPoint = &aEndPoint;
+	}
+
+void CIoWriteObject::WriteL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicWriteWhenNotAttached));
+	__ASSERT_RETURN(!MessagePending(iWriteMessage), PanicClient(aMessage, EPanicWriteAlreadyPending));
+	iWriteMessage = aMessage;
+	iOffset = 0;
+	iWriteLength = DesLengthL(iWriteMessage, 0);
+	WriteEndPoint()->IowepWriteL(*this);
+	}
+
+void CIoWriteObject::WriteCancel(const CIoSession& aSession)
+	{
+	if (MessagePending(iWriteMessage) && (iWriteMessage.Session() == &aSession))
+		{
+		if (iEndPoint)
+			{
+			WriteEndPoint()->IowepWriteCancel(*this);
+			}
+		Complete(iWriteMessage, KErrCancel);
+		}
+	}
+
+TInt CIoWriteObject::IowWriteLength() const
+	{
+	ASSERT(MessagePending(iWriteMessage));
+	return (iWriteLength - iOffset);
+	}
+
+TInt CIoWriteObject::IowWrite(TDes& aBuf)
+	{
+	ASSERT(MessagePending(iWriteMessage));
+	ASSERT(aBuf.Length() <= (iWriteLength - iOffset));
+	OBJ_NAME(*this);
+	TRAPD(err, MessageReadL(iWriteMessage, 0, aBuf, iOffset));
+	if (err == KErrNone)
+		{
+		LOG(CIoLog::Printf(_L("Write object \'%S\' read %d characters"), &objName, aBuf.Length()));
+		LOG(Dump(aBuf));
+		iOffset += aBuf.Length();
+		}
+	else
+		{
+		LOG(CIoLog::Printf(_L("Write object \'%S\' failed to read: %d"), &objName, err));
+		}
+	return err;
+	}
+
+RIoReadWriteHandle::TMode CIoWriteObject::IowWriteMode() const
+	{
+	return iMode;
+	}
+	
+void CIoWriteObject::IowCursorPos(TInt aError, TPoint aPos)
+	{
+	TPckgC<TPoint> posPckg(aPos);
+	Complete(iGetCursorPosMsg, aError==KErrNone ? MessageWrite(iGetCursorPosMsg, 0, posPckg) : aError);
+	}
+
+void CIoWriteObject::IowSetCursorPosAbsComplete(TInt aError)
+	{
+	Complete(iSetCursorPosAbsMsg, aError);
+	}
+
+void CIoWriteObject::IowSetCursorPosRelComplete(TInt aError)
+	{
+	Complete(iSetCursorPosRelMsg, aError);
+	}
+	
+void CIoWriteObject::IowSetCursorHeightComplete(TInt aError)
+	{
+	Complete(iSetCursorHeightMsg, aError);
+	}
+	
+void CIoWriteObject::IowSetTitleComplete(TInt aError)
+	{
+	Complete(iSetTitleMsg, aError);
+	}
+	
+void CIoWriteObject::IowClearScreenComplete(TInt aError)
+	{
+	Complete(iClearScreenMsg, aError);
+	}
+
+void CIoWriteObject::IowClearToEndOfLineComplete(TInt aError)
+	{
+	Complete(iClearToEndOfLineMsg, aError);
+	}
+
+void CIoWriteObject::IowScreenSize(TInt aError, TSize aSize)
+	{
+	if ((aSize == TSize(0, 0)) && Console() && !iTriedConsoleScreenSize)
+		{
+		iTriedConsoleScreenSize = ETrue;
+		TRAPD(err, Console()->IowepScreenSizeL(*this));
+		if (err!=KErrNone)
+			{
+			Complete(iGetScreenSizeMsg, err);
+			}
+		return;
+		}
+	TPckgC<TSize> sizePckg(aSize);
+	Complete(iGetScreenSizeMsg, aError == KErrNone ? MessageWrite(iGetScreenSizeMsg, 0, sizePckg) : aError);
+	}
+
+void CIoWriteObject::IowSetAttributesComplete(TInt aError)
+	{
+	Complete(iSetAttributesMsg, aError);
+	}
+
+HBufC* CIoWriteObject::IowTitleLC()
+	{
+	HBufC* titleBuf = HBufC::NewLC(DesLengthL(iSetTitleMsg, 0));
+	TPtr titlePtr(titleBuf->Des());
+	MessageReadL(iSetTitleMsg, 0, titlePtr);
+	return titleBuf;
+	}
+
+void CIoWriteObject::CursorPosL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicCursorPosWhenNotAttached));
+	__ASSERT_RETURN(iGetCursorPosMsg.IsNull(), PanicClient(aMessage, EPanicCursorPosAlreadyPending));
+	iGetCursorPosMsg = aMessage;
+	CleanupNullMessagePushL(iGetCursorPosMsg);
+	WriteEndPoint()->IowepCursorPosL(*this);
+	CleanupStack::Pop(&iGetCursorPosMsg);
+	}
+
+void CIoWriteObject::SetCursorPosAbsL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicSetCursorPosAbsWhenNotAttached));
+	__ASSERT_RETURN(iSetCursorPosAbsMsg.IsNull(), PanicClient(aMessage, EPanicSetCursorPosAlreadyPending));
+	TPoint pos;
+	TPckg<TPoint> posPckg(pos);
+	MessageReadL(aMessage, 0, posPckg);
+	iSetCursorPosAbsMsg = aMessage;
+	CleanupNullMessagePushL(iSetCursorPosAbsMsg);
+	WriteEndPoint()->IowepSetCursorPosAbsL(pos, *this);
+	CleanupStack::Pop(&iSetCursorPosAbsMsg);
+	}
+
+void CIoWriteObject::SetCursorPosRelL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicSetCursorPosRelWhenNotAttached));
+	__ASSERT_RETURN(iSetCursorPosRelMsg.IsNull(), PanicClient(aMessage, EPanicSetCursorPosAlreadyPending));
+	TPoint pos;
+	TPckg<TPoint> posPckg(pos);
+	MessageReadL(aMessage, 0, posPckg);
+	iSetCursorPosRelMsg = aMessage;
+	CleanupNullMessagePushL(iSetCursorPosRelMsg);
+	WriteEndPoint()->IowepSetCursorPosRelL(pos, *this);
+	CleanupStack::Pop(&iSetCursorPosRelMsg);
+	}
+
+void CIoWriteObject::SetCursorHeightL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicSetCursorHeightWhenNotAttached));
+	__ASSERT_RETURN(iSetCursorHeightMsg.IsNull(), PanicClient(aMessage, EPanicSetCursorHeightAlreadyPending));
+	iSetCursorHeightMsg = aMessage;
+	CleanupNullMessagePushL(iSetCursorHeightMsg);
+	WriteEndPoint()->IowepSetCursorHeightL(aMessage.Int0(), *this);
+	CleanupStack::Pop(&iSetCursorHeightMsg);
+	}
+
+void CIoWriteObject::SetTitleL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicSetTitleWhenNotAttached));
+	__ASSERT_RETURN(iSetTitleMsg.IsNull(), PanicClient(aMessage, EPanicSetTitleAlreadyPending));
+	iSetTitleMsg = aMessage;
+	// if we leave here, the message will be completed by the framework. But we do want to null the message
+	// as it will no longer be valid.
+	CleanupNullMessagePushL(iSetTitleMsg);
+	WriteEndPoint()->IowepSetTitleL(*this);
+	CleanupStack::Pop(&iSetTitleMsg);
+	}
+
+void CIoWriteObject::ClearScreen(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicClearScreenWhenNotAttached));
+	__ASSERT_RETURN(iClearScreenMsg.IsNull(), PanicClient(aMessage, EPanicClearScreenAlreadyPending));
+	iClearScreenMsg = aMessage;
+	CleanupNullMessagePushL(iClearScreenMsg);
+	WriteEndPoint()->IowepClearScreenL(*this);
+	CleanupStack::Pop(&iClearScreenMsg);
+	}
+
+void CIoWriteObject::ClearToEndOfLine(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicClearToEndOfLineWhenNotAttached));
+	__ASSERT_RETURN(iClearToEndOfLineMsg.IsNull(), PanicClient(aMessage, EPanicClearToEndOfLineAlreadyPending));
+	iClearToEndOfLineMsg = aMessage;
+	CleanupNullMessagePushL(iClearToEndOfLineMsg);
+	WriteEndPoint()->IowepClearToEndOfLineL(*this);
+	CleanupStack::Pop(&iClearToEndOfLineMsg);
+	}
+
+void CIoWriteObject::ScreenSizeL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicScreenSizeWhenNotAttached));
+	__ASSERT_RETURN(iGetScreenSizeMsg.IsNull(), PanicClient(aMessage, EPanicScreenSizeAlreadyPending));
+	iGetScreenSizeMsg = aMessage;
+	CleanupNullMessagePushL(iGetScreenSizeMsg);
+	iTriedConsoleScreenSize = EFalse;
+	WriteEndPoint()->IowepScreenSizeL(*this);
+	CleanupStack::Pop(&iGetScreenSizeMsg);
+	}
+
+void CIoWriteObject::SetAttributesL(const RMsg& aMessage)
+	{
+	__ASSERT_RETURN(iEndPoint, PanicClient(aMessage, EPanicSetAttributesWhenNotAttached));
+	__ASSERT_RETURN(iSetAttributesMsg.IsNull(), PanicClient(aMessage, EPanicSetAttributesAlreadyPending));
+	iSetAttributesMsg = aMessage;
+	CleanupNullMessagePushL(iSetAttributesMsg);
+	WriteEndPoint()->IowepSetAttributesL((TUint)aMessage.Int0(), (ConsoleAttributes::TColor)aMessage.Int1(), (ConsoleAttributes::TColor)aMessage.Int2(), *this);
+	CleanupStack::Pop(&iSetAttributesMsg);
+	}
+
+TBool CIoWriteObject::IsType(RIoHandle::TType aType) const
+	{
+	return ((aType == RIoHandle::EReadWriteObject) || (aType == RIoHandle::EWriteObject));
+	}
+
+void CIoWriteObject::SessionClosed(const CIoSession& aSession)
+	{
+	WriteCancel(aSession);
+	}
+
+RIoReadWriteHandle::TMode CIoWriteObject::IorwMode() const
+	{
+	return iMode;
+	}
+
+void CIoWriteObject::IowComplete(TInt aError)
+	{
+	ASSERT(MessagePending(iWriteMessage));
+	Complete(iWriteMessage, aError);
+	iOffset = 0;
+	iWriteLength = 0;
+	}
+
+TName CIoWriteObject::IowName()
+	{
+	return Name();
+	}
+
+CIoWriteObject::CIoWriteObject(TInt aId)
+	: CIoReadWriteObject(aId)
+	{
+	}
+
+MIoWriteEndPoint* CIoWriteObject::WriteEndPoint() const
+	{
+	return static_cast<MIoWriteEndPoint*>(iEndPoint);
+	}
+
+void CIoWriteObject::SetIsStdErr(TBool aFlag)
+	{
+	iIsStdErr = aFlag;
+	}
+
+TBool CIoWriteObject::IowIsStdErr() const
+	{
+	return iIsStdErr;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/readwrite.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,287 @@
+// readwrite.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __READWRITE_H__
+#define __READWRITE_H__
+
+#include <e32base.h>
+#include "server.h"
+#include "iocli.h"
+#include "object.h"
+
+
+class CIoConsole;
+class CThreadOwner;
+
+class MIoReadWriter
+	{
+public:
+	virtual RIoReadWriteHandle::TMode IorwMode() const = 0;
+	};
+
+
+class MIoReader : public MIoReadWriter
+	{
+public:
+	virtual TBool IorReadPending() const = 0;
+	virtual TBool IorReadKeyPending() const = 0;
+	virtual TDes& IorReadBuf() = 0;
+	virtual void IorDataBuffered(TInt aLength) = 0;
+	virtual TBool IorDataIsBuffered() const = 0;
+	virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers) = 0;
+	virtual void IorReadComplete(TInt aError) = 0;
+	virtual void IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers) = 0;
+	virtual TName IorName() = 0;
+	virtual void IorReaderChange(TUint aChange) = 0;
+	virtual void IorSetConsoleModeComplete(TInt aError) = 0;
+	};
+
+
+class MIoWriter : public MIoReadWriter
+	{
+public:
+	virtual TInt IowWriteLength() const = 0;
+	virtual TInt IowWrite(TDes& aBuf) = 0;
+	virtual void IowComplete(TInt aError) = 0;
+	virtual TName IowName() = 0;
+	virtual void IowCursorPos(TInt aError, TPoint aPos) = 0;
+	virtual void IowSetCursorPosAbsComplete(TInt aError) = 0;
+	virtual void IowSetCursorPosRelComplete(TInt aError) = 0;
+	virtual void IowSetCursorHeightComplete(TInt aError) = 0;
+	virtual void IowSetTitleComplete(TInt aError) = 0;
+	virtual void IowClearScreenComplete(TInt aError) = 0;
+	virtual void IowClearToEndOfLineComplete(TInt aError) = 0;
+	virtual void IowScreenSize(TInt aError, TSize aSize) = 0;
+	virtual void IowSetAttributesComplete(TInt aError) = 0;
+	virtual HBufC* IowTitleLC() = 0;
+	virtual TBool IowIsStdErr() const { return EFalse; }
+	};
+
+
+class MIoEndPoint
+	{
+public:
+	TBool IoepIsConsole() const;
+	virtual TName IoepName() const = 0;
+	virtual TBool IoepIsType(RIoHandle::TType aType) const = 0;
+	};
+
+class MIoReadEndPoint : public MIoEndPoint
+	{
+public:
+	virtual void IorepAttachL(MIoReader& aReader, RIoEndPoint::TReadMode aMode) = 0;
+	virtual void IorepDetach(MIoReader& aReader) = 0;
+	virtual void IorepReadL(MIoReader& aReader) = 0;
+	virtual void IorepSetForegroundReaderL(MIoReader& aReader) = 0;
+	virtual TBool IorepIsForegroundL(const MIoReader& aReader) const = 0;
+	virtual void IorepReadKeyL(MIoReader& aReader);
+	virtual void IorepSetConsoleModeL(RIoReadWriteHandle::TMode aMode, MIoReader& aReader);
+	static TBool AttachedToConsole(const MIoReadEndPoint* aEndPoint);
+	};
+
+
+class MIoWriteEndPoint : public MIoEndPoint
+	{
+public:
+	virtual void IowepAttachL(MIoWriter& aReader) = 0;
+	virtual void IowepDetach(MIoWriter& aReader) = 0;
+	virtual void IowepWriteL(MIoWriter& aWriter) = 0;
+	virtual void IowepWriteCancel(MIoWriter& aWriter) = 0;
+	virtual void IowepCursorPosL(MIoWriter& aWriter) const;
+	virtual void IowepSetCursorPosAbsL(const TPoint& aPoint, MIoWriter& aWriter);
+	virtual void IowepSetCursorPosRelL(const TPoint& aPoint, MIoWriter& aWriter);
+	virtual void IowepSetCursorHeightL(TInt aPercentage, MIoWriter& aWriter);
+	virtual void IowepSetTitleL(MIoWriter& aWriter);
+	virtual void IowepClearScreenL(MIoWriter& aWriter);
+	virtual void IowepClearToEndOfLineL(MIoWriter& aWriter);
+	virtual void IowepScreenSizeL(MIoWriter& aWriter) const;
+	virtual void IowepSetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriter& aWriter);
+	static TBool AttachedToConsole(const MIoWriteEndPoint* aEndPoint);
+protected:
+	virtual TPoint IowepCursorPos() const;
+	virtual void IowepSetCursorPosAbs(const TPoint& aPoint);
+	virtual void IowepSetCursorPosRel(const TPoint& aPoint);
+	virtual void IowepSetCursorHeight(TInt aHeight);
+	virtual void IowepSetTitle(const TDesC& aTitle);
+	virtual void IowepClearScreen();
+	virtual void IowepClearToEndOfLine();
+	virtual TSize IowepScreenSize() const;
+	virtual void IowepSetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor);
+	};
+
+
+class CIoReadWriteObject : public CIoObject
+	{
+public:
+	TUint Id() const;
+	void SetOwnerL(TThreadId aOwningThread);
+	TInt Open(TThreadId aOwningThread);
+	void DoDuplicateL(const CIoReadWriteObject& aDuplicate);
+	TBool IsOwner(TThreadId aOwningThread) const;
+	TBool OpenedByOwner() const;
+	void SetConsole(CIoConsole& aConsole);
+	CIoConsole* Console();
+	const CIoConsole* Console() const;
+	MIoEndPoint* EndPoint();
+	virtual void SetModeL(const RMsg& aMessage);
+protected:
+	CIoReadWriteObject(TUint aId);
+	void Dump(const TDesC& aData) const;
+protected:
+	MIoEndPoint* iEndPoint;
+	RIoReadWriteHandle::TMode iMode;
+private:
+	const TUint iId;
+	TThreadId iOwningThreadId;
+	TBool iOpenedByOwner;
+	CIoConsole* iConsole;
+	};
+
+
+class CIoReadObject : public CIoReadWriteObject, public MIoReader
+	{
+public:
+	static CIoReadObject* NewLC(TInt aId);
+	virtual ~CIoReadObject();
+	void DuplicateL(const CIoReadObject& aDuplicate);
+	void AttachL(MIoReadEndPoint& aEndPoint, RIoEndPoint::TReadMode aMode);
+	void SetReadMode(RIoReadHandle::TReadMode aMode);
+	void SetToForegroundL();
+	TBool IsForegroundL() const;
+	void ReadL(const RMsg& aMessage);
+	void ReadCancel(const CIoSession& aSession);
+	void SetLineSeparatorL(const RMsg& aMessage);
+	void ReadKeyL(const RMsg& aMessage);
+	void ReadKeyCancel(const CIoSession& aSession);
+	void CaptureKeyL(const RMsg& aMessage);
+	void CancelCaptureKey(const RMsg& aMessage);
+	void CaptureAllKeys(const RMsg& aMessage);
+	void CancelCaptureAllKeys(const RMsg& aMessage);
+	void NotifyChange(const RMsg& aMessage);
+	void CancelNotifyChange(const CIoSession& aSession);
+public: // From CIoObject.
+	virtual TBool IsType(RIoHandle::TType aType) const;
+	virtual void SessionClosed(const CIoSession& aSession);
+public: // From CIoReadWriteObject.
+	virtual void SetModeL(const RMsg& aMessage);
+public: // From MIoReadWriter.
+	virtual RIoReadWriteHandle::TMode IorwMode() const;
+private: // From MIoReader.
+	virtual TBool IorReadPending() const;
+	virtual TBool IorReadKeyPending() const;
+	virtual TDes& IorReadBuf();
+	virtual void IorDataBuffered(TInt aLength);
+	virtual TBool IorDataIsBuffered() const;
+	virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifier);
+	virtual void IorReadComplete(TInt aError);
+	virtual void IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers);
+	virtual TName IorName();
+	virtual void IorReaderChange(TUint aChange);
+	virtual void IorSetConsoleModeComplete(TInt aError);
+private:
+	CIoReadObject(TInt aId);
+	void ProcessRead();
+	void AllocateBufferL(TInt aLength);
+	void TryToCompleteRead();
+	void CompleteRead(TInt aError, TInt aLength);
+	void CompleteReadKey(TInt aError, RIoConsoleReadHandle::TConsoleKey& aConsoleKey);
+	MIoReadEndPoint* ReadEndPoint() const;
+	void CancelSetMode(const CIoSession& aSession);
+private:
+	class TCapturedKey
+		{
+	public:
+		TCapturedKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers);
+	public:
+		TUint iKeyCode;
+		TUint iModifierMask;
+		TUint iModifiers;
+		};
+private:
+	RIoReadHandle::TReadMode iReadMode;
+	TInt iMaxReadLength;
+	RMsg iReadMessage;
+	RMsg iReadKeyMessage;
+	HBufC* iBuf;
+	TPtr iPtr;
+	HBufC* iLineSeparator; // NULL means use default "\n"
+	RArray<TCapturedKey> iCapturedKeys;
+	RArray<RIoConsoleReadHandle::TConsoleKey> iKeyBuffer;
+	TBool iCaptureAllKeys;
+	TInt iCompleteErr; // non-zero if we have completed reading
+	RMsg iChangeNotifyMessage;
+	RMsg iSetModeMessage;
+	};
+
+
+class CIoWriteObject : public CIoReadWriteObject, public MIoWriter
+	{
+public:
+	static CIoWriteObject* NewLC(TInt aId);
+	~CIoWriteObject();
+	void DuplicateL(const CIoWriteObject& aDuplicate);
+	void AttachL(MIoWriteEndPoint& aEndPoint);
+	void WriteL(const RMsg& aMessage);
+	void WriteCancel(const CIoSession& aSession);
+	void CursorPosL(const RMsg& aMessage);
+	void SetCursorPosAbsL(const RMsg& aMessage);
+	void SetCursorPosRelL(const RMsg& aMessage);
+	void SetCursorHeightL(const RMsg& aMessage);
+	void SetTitleL(const RMsg& aMessage);
+	void ClearScreen(const RMsg& aMessage);
+	void ClearToEndOfLine(const RMsg& aMessage);
+	void ScreenSizeL(const RMsg& aMessage);
+	void SetAttributesL(const RMsg& aMessage);
+	void SetIsStdErr(TBool aFlag);
+public: // From CIoObject.
+	virtual TBool IsType(RIoHandle::TType aType) const;
+	virtual void SessionClosed(const CIoSession& aSession);
+public: // From MIoReadWriter.
+	virtual RIoReadWriteHandle::TMode IorwMode() const;
+private: // From MIoWriter.
+	virtual TInt IowWriteLength() const;
+	virtual TInt IowWrite(TDes& aBuf);
+	virtual void IowComplete(TInt aError);
+	virtual TName IowName();
+	virtual RIoWriteHandle::TMode IowWriteMode() const;
+	virtual void IowCursorPos(TInt aError, TPoint aPos);
+	virtual void IowSetCursorPosAbsComplete(TInt aError);
+	virtual void IowSetCursorPosRelComplete(TInt aError);
+	virtual void IowSetCursorHeightComplete(TInt aError);
+	virtual void IowSetTitleComplete(TInt aError);
+	virtual void IowClearScreenComplete(TInt aError);
+	virtual void IowClearToEndOfLineComplete(TInt aError);
+	virtual void IowScreenSize(TInt aError, TSize aSize);
+	virtual void IowSetAttributesComplete(TInt aError);
+	virtual HBufC* IowTitleLC();
+	virtual TBool IowIsStdErr() const;
+private:
+	CIoWriteObject(TInt aId);
+	MIoWriteEndPoint* WriteEndPoint() const;
+protected:
+	TInt iOffset;
+	TInt iWriteLength;
+	RMsg iWriteMessage;
+	RMsg iGetCursorPosMsg;
+	RMsg iSetCursorPosAbsMsg;
+	RMsg iSetCursorPosRelMsg;
+	RMsg iSetCursorHeightMsg;
+	RMsg iSetTitleMsg;
+	RMsg iClearScreenMsg;
+	RMsg iClearToEndOfLineMsg;
+	RMsg iGetScreenSizeMsg;
+	RMsg iSetAttributesMsg;
+	TBool iTriedConsoleScreenSize;
+	TBool iIsStdErr;
+	};
+
+#endif // __READWRITE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/server.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,636 @@
+// server.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "server.h"
+#include "pipe.h"
+#include "console.h"
+#include "file.h"
+#include "null.h"
+#include "persistentconsole.h"
+#include "readwrite.h"
+#include "clientserver.h"
+#include "session.h"
+
+
+#ifndef EKA2
+
+//
+// TServerStart.
+//
+
+TServerStart::TServerStart()
+	{
+	}
+
+void TServerStart::SignalL()
+	{
+	RThread starter;
+	User::LeaveIfError(starter.Open(iId));
+	starter.RequestComplete(iStatus,KErrNone);
+	starter.Close();
+	}
+
+#endif
+
+
+//
+// CShutdownTimer.
+//
+
+CShutdownTimer::CShutdownTimer()
+	: CTimer(-1)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CShutdownTimer::ConstructL()
+	{
+	CTimer::ConstructL();
+	}
+
+void CShutdownTimer::Start()
+	{
+	After(KShutdownDelay);
+	}
+
+void CShutdownTimer::RunL()
+	{
+	CActiveScheduler::Stop();
+	}
+
+
+//
+// CIoServer.
+//
+
+CIoServer::CIoServer()
+#ifdef EKA2
+	: CServer2(0, ESharableSessions)
+#else
+	: CServer(0, ESharableSessions)
+#endif
+	{
+	
+	}
+
+#ifdef EKA2
+CServer2* CIoServer::NewLC()
+#else
+CServer* CIoServer::NewLC()
+#endif
+	{
+	CIoServer* self=new(ELeave) CIoServer;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CIoServer::~CIoServer()
+	{
+	if (iIoObjectContainerIndex)
+		{
+		iIoObjectContainerIndex->Remove(iIoObjectContainer);
+		}
+	delete iIoObjectContainerIndex;
+#ifdef IOSRV_LOGGING
+	delete iLog;
+#endif
+	}
+
+void CIoServer::ConstructL()
+	{
+#if defined (__WINS__) && !defined (EKA2)
+	RThread().SetPriority(EPriorityAbsoluteHigh);
+#else
+	RProcess().SetPriority(::EPriorityHigh);
+#endif
+	User::LeaveIfError(iFs.Connect());
+#ifdef IOSRV_LOGGING
+	iLog = CIoLog::NewL(iFs);
+#endif
+	iConfig.Init(); // Ignore error (defaults will be used).
+	StartL(KIoServerName);
+	iIoObjectContainerIndex = CObjectConIx::NewL();
+	iIoObjectContainer = iIoObjectContainerIndex->CreateL();
+	iShutdownTimer.ConstructL();
+	iShutdownTimer.Start();
+	}
+
+#ifdef EKA2
+	CSession2* CIoServer::NewSessionL(const TVersion&, const RMessage2&) const
+#else
+	CSharableSession* CIoServer::NewSessionL(const TVersion&) const
+#endif
+	{
+	CIoSession* session = new(ELeave) CIoSession();
+	LOG(CIoLog::Printf(_L("CIoSession 0x%08x created\r\n"), session));
+	return session;
+	}
+
+void CIoServer::AddSession()
+	{
+	++iSessionCount;
+	iShutdownTimer.Cancel();
+	}
+
+void CIoServer::DropSession()
+	{
+	if (--iSessionCount == 0)
+		{
+		iShutdownTimer.Start();
+		}
+	}
+
+CIoPipe& CIoServer::CreatePipeLC()
+	{
+	CIoPipe* pipe = CIoPipe::NewLC();
+	iIoObjectContainer->AddL(pipe);
+	return *pipe;
+	}
+
+CIoConsole& CIoServer::CreateConsoleLC(const TDesC& aImplementation, const TDesC& aTitle, TSize aSize, MIoWriteEndPoint* aUnderlyingConsole, TUint aOptions)
+	{
+	CIoConsole* underlying = NULL;
+	while (aUnderlyingConsole && aUnderlyingConsole->IoepIsType(RIoHandle::EPersistentConsole))
+		{
+		aUnderlyingConsole = ((CIoPersistentConsole*)aUnderlyingConsole)->TransientWriter();
+		}
+	if (aUnderlyingConsole && aUnderlyingConsole->IoepIsConsole())
+		{
+		underlying = (CIoConsole*)aUnderlyingConsole;
+		}
+		
+	CIoConsole* console = CIoConsole::NewLC(aImplementation, aTitle, aSize, iConfig, underlying, aOptions);
+	iIoObjectContainer->AddL(console);
+	return *console;
+	}
+
+CIoFile& CIoServer::CreateFileLC(const TDesC& aName, RIoFile::TMode aMode)
+	{
+	CIoFile* file = CIoFile::NewLC(iFs, aName, aMode);
+	iIoObjectContainer->AddL(file);
+	return *file;
+	}
+
+CIoNull& CIoServer::CreateNullLC()
+	{
+	CIoNull* null = CIoNull::NewLC();
+	iIoObjectContainer->AddL(null);
+	return *null;
+	}
+	
+CIoPersistentConsole& CIoServer::CreatePersistentConsoleLC(const TDesC& aName, const TDesC& aTitle, const RMsg& aMessage)
+	{
+	CIoPersistentConsole* pcons = CIoPersistentConsole::NewLC(aName, aTitle, *this, aMessage);
+	iIoObjectContainer->AddL(pcons);
+	return *pcons;
+	}
+
+
+CIoReadObject& CIoServer::CreateReadObjLC()
+	{
+	CIoReadObject* obj = CIoReadObject::NewLC(iNextReadObjId++);
+	iIoObjectContainer->AddL(obj);
+	return *obj;
+	}
+
+CIoWriteObject& CIoServer::CreateWriteObjLC()
+	{
+	CIoWriteObject* obj = CIoWriteObject::NewLC(iNextWriteObjId++);
+	iIoObjectContainer->AddL(obj);
+	return *obj;
+	}
+
+CIoReadObject* CIoServer::NextReadObj(TThreadId aOwningThread) const
+	{
+	return (CIoReadObject*)DoFindObj(RIoHandle::EReadObject, aOwningThread, ETrue);
+	}
+
+CIoReadWriteObject* CIoServer::DoFindObj(RIoHandle::TType aType, TThreadId aOwningThread, TBool aNext) const
+	{
+	CIoReadWriteObject* lastMatchingObj = NULL;
+	const TInt numObjs = iIoObjectContainer->Count();
+	for (TInt i = 0; i < numObjs; ++i)
+		{
+		CIoObject* obj = (CIoObject*)(*iIoObjectContainer)[i];
+		if (obj->IsType(aType))
+			{
+			CIoReadWriteObject* readWriteObj = (CIoReadWriteObject*)obj;
+			if (aNext && readWriteObj->IsOwner(aOwningThread) && !readWriteObj->OpenedByOwner())
+				{
+				// aNext==ETrue means we return the first matching object that isn't already opened by its owner
+				return readWriteObj;
+				}
+			else if (!aNext && readWriteObj->IsOwner(aOwningThread) && readWriteObj->OpenedByOwner())
+				{
+				// aNext==EFalse means we return the last matching object that *is* opened
+				lastMatchingObj = readWriteObj;
+				}
+			}
+		}
+	return lastMatchingObj;
+	}
+
+CIoWriteObject* CIoServer::NextWriteObj(TThreadId aOwningThread) const
+	{
+	return (CIoWriteObject*)DoFindObj(RIoHandle::EWriteObject, aOwningThread, ETrue);
+	}
+
+CIoReadObject* CIoServer::LastOpenedReadObj(TThreadId aOwningThread) const
+	{
+	return (CIoReadObject*)DoFindObj(RIoHandle::EReadObject, aOwningThread, EFalse);
+	}
+
+CIoWriteObject* CIoServer::LastOpenedWriteObj(TThreadId aOwningThread) const
+	{
+	return (CIoWriteObject*)DoFindObj(RIoHandle::EWriteObject, aOwningThread, EFalse);
+	}
+
+CIoPersistentConsole& CIoServer::FindPersistentConsoleL(const TDesC& aName)
+	{
+	const TInt numObjs = iIoObjectContainer->Count();
+	for (TInt i=0; i<numObjs; ++i)
+		{
+		CIoObject* obj = (CIoObject*)(*iIoObjectContainer)[i];
+		if (obj->IsType(RIoHandle::EPersistentConsole))
+			{
+			CIoPersistentConsole& pcons = (CIoPersistentConsole&)*obj;
+			if (pcons.Name().Compare(aName)==0)
+				{
+				return pcons;
+				}
+			}
+		}
+	User::Leave(KErrNotFound);
+	return *(CIoPersistentConsole*)1; // To keep the compiler happy.
+	}
+
+CIoObject* CIoServer::FindObjectByName(RIoHandle::TType aType, TInt& aFindHandle, const TDesC& aMatch, TName& aName) const
+	{
+	FOREVER
+		{
+		TInt err = iIoObjectContainer->FindByName(aFindHandle, aMatch, aName);
+		if (err == KErrNone)
+			{
+			CIoObject* obj = (CIoObject*)iIoObjectContainer->At(aFindHandle);
+			if (obj->IsType(aType))
+				{
+				return obj;
+				}
+			}
+		else
+			{
+			break;
+			}
+		}
+	return NULL;
+	}
+
+CIoObject& CIoServer::OpenObjectLC(TInt aFindHandle)
+	{
+	CIoObject* obj = (CIoObject*)iIoObjectContainer->At(aFindHandle);
+	if (obj)
+		{
+		User::LeaveIfError(obj->Open());
+		CleanupClosePushL(*obj);
+		return *obj;
+		}
+	User::Leave(KErrNotFound);
+	return *(CIoObject*)1; // To keep the compiler happy.
+	}
+	
+const TIoConfig& CIoServer::Config()
+	{
+	return iConfig;
+	}
+	
+void CIoServer::PersistentConsoleAddL(const TDesC16& aName, const CIoPersistentConsole& aCons)
+	{
+	if (iPersistentConsoleNames.Find(aName)!=NULL)
+		{
+		User::Leave(KErrAlreadyExists);
+		}
+	iPersistentConsoleNames.InsertL(&aName, &aCons);
+	}
+	
+void CIoServer::PersistentConsoleRemove(const TDesC16& aName, const CIoPersistentConsole& aCons)
+	{
+	if (iPersistentConsoleNames.Find(aName) == &aCons)
+		{
+		iPersistentConsoleNames.Remove(&aName);
+		}
+	}
+
+TInt CIoServer::RunError(TInt aError)
+	{
+	if (aError == KErrBadDescriptor)
+		{
+		PanicClient(Message(), EPanicBadDescriptor);
+		}
+	else if (aError == KErrBadHandle)
+		{
+		PanicClient(Message(), EPanicBadHandle);
+		}
+	else
+		{
+		LOG(CIoLog::LogCompletion(Message(), aError));
+		Complete(Message(), aError);
+		}
+
+	ReStart();
+	return KErrNone;
+	}
+
+
+//
+// Statics.
+//
+
+void PanicClient(const RMsg& aMessage, TIoPanicReason aReason)
+	{
+	aMessage.Panic(KIoServerName, aReason);
+	}
+
+#ifdef EKA2
+static void RunServerL()
+#else
+static void RunServerL(TServerStart& aStart)
+#endif
+	{
+	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+
+	CIoServer::NewLC();
+#ifdef EKA2
+	User::RenameThread(KIoServerName);
+	RProcess::Rendezvous(KErrNone);
+#else
+	User::LeaveIfError(RThread().Rename(KIoServerName));
+	aStart.SignalL();
+#endif
+	CActiveScheduler::Start();
+	CleanupStack::PopAndDestroy(2, scheduler);
+	}
+
+#ifdef EKA2
+static TInt RunServer()
+#else
+static TInt RunServer(TServerStart& aStart)
+#endif
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+	TInt r = KErrNoMemory;
+	if (cleanup)
+		{
+#ifdef EKA2
+		TRAP(r, RunServerL());
+#else
+		TRAP(r, RunServerL(aStart));
+#endif
+		delete cleanup;
+		}
+	__UHEAP_MARKEND;
+	return r;
+	}
+
+
+#if defined(__WINS__) && !defined(EKA2)
+
+static TInt ThreadFunction(TAny* aParms)
+	{
+	return RunServer(*static_cast<TServerStart*>(aParms));
+	}
+
+IMPORT_C TInt WinsMain();
+EXPORT_C TInt WinsMain()
+	{
+	return reinterpret_cast<TInt>(&ThreadFunction);
+	}
+
+TInt E32Dll(TDllReason)
+	{
+	return KErrNone;
+	}
+
+#else
+#ifdef EKA2
+
+TInt E32Main()
+	{
+	return RunServer();
+	}
+
+#else
+
+TInt TServerStart::GetCommand()
+	{
+	RProcess p;
+	if (p.CommandLineLength() != (sizeof(TServerStart) / sizeof(TText)))
+		{
+		return KErrGeneral;
+		}
+	TPtr ptr(reinterpret_cast<TText*>(this), 0, (sizeof(TServerStart) / sizeof(TText)));
+	p.CommandLine(ptr);
+	return KErrNone;
+	}
+
+TInt E32Main()
+	{
+	TServerStart start;
+	TInt r = start.GetCommand();
+	if (r == KErrNone)
+		{
+		r = RunServer(start);
+		}
+	return r;
+	}
+
+#endif
+#endif
+
+#ifndef EKA2
+const TAny* MessagePtr(const RMsg& aMessage, TInt aParam)
+	{
+	const TAny* ptr;
+	switch (aParam)
+		{
+		case 0:
+			{
+			ptr = aMessage.Ptr0();
+			break;
+			}
+		case 1:
+			{
+			ptr = aMessage.Ptr1();
+			break;
+			}
+		case 2:
+			{
+			ptr = aMessage.Ptr2();
+			break;
+			}
+		case 3:
+			{
+			ptr = aMessage.Ptr3();
+			break;
+			}
+		default:
+			{
+			ASSERT(EFalse);
+			ptr = NULL;
+			}
+		}
+	return ptr;
+	}
+#endif
+	
+TInt DesLengthL(const RMsg& aMessage, TInt aParam)	
+	{
+#ifdef EKA2
+	return aMessage.GetDesLengthL(aParam);
+#else
+	return aMessage.Client().GetDesLength(MessagePtr(aMessage, aParam));
+#endif
+	}
+	
+TInt MaxDesLengthL(const RMsg& aMessage, TInt aParam)
+	{
+#ifdef EKA2
+	return aMessage.GetDesMaxLengthL(aParam);
+#else
+	return aMessage.Client().GetDesMaxLength(MessagePtr(aMessage, aParam));
+#endif
+	}
+
+void MessageReadL(const RMsg& aMessage, TInt aParam, TDes8& aDes)
+	{
+#ifdef EKA2
+	aMessage.ReadL(aParam, aDes);
+#else
+	aMessage.ReadL(MessagePtr(aMessage, aParam), aDes);
+#endif
+	}
+
+void MessageReadL(const RMsg& aMessage, TInt aParam, TDes8& aDes, TInt aOffset)
+	{
+#ifdef EKA2
+	aMessage.ReadL(aParam, aDes, aOffset);
+#else
+	aMessage.ReadL(MessagePtr(aMessage, aParam), aDes, aOffset);
+#endif
+	}
+
+void MessageReadL(const RMsg& aMessage, TInt aParam, TDes16& aDes)
+	{
+#ifdef EKA2
+	aMessage.ReadL(aParam, aDes);
+#else
+	aMessage.ReadL(MessagePtr(aMessage, aParam), aDes);
+#endif
+	}
+
+void MessageReadL(const RMsg& aMessage, TInt aParam, TDes16& aDes, TInt aOffset)
+	{
+#ifdef EKA2
+	aMessage.ReadL(aParam, aDes, aOffset);
+#else
+	aMessage.ReadL(MessagePtr(aMessage, aParam), aDes, aOffset);
+#endif
+	}
+
+void MessageWriteL(const RMsg& aMessage, TInt aParam, const TDesC8& aDes)
+	{
+#ifdef EKA2
+	aMessage.WriteL(aParam, aDes);
+#else
+	aMessage.WriteL(MessagePtr(aMessage, aParam), aDes);
+#endif
+	}
+
+void MessageWriteL(const RMsg& aMessage, TInt aParam, const TDesC16& aDes)
+	{
+#ifdef EKA2
+	aMessage.WriteL(aParam, aDes);
+#else
+	aMessage.WriteL(MessagePtr(aMessage, aParam), aDes);
+#endif
+	}
+	
+TInt MessageWrite(const RMsg& aMessage, TInt aParam, const TDesC8& aDes)
+	{
+#ifdef EKA2
+	return aMessage.Write(aParam, aDes);
+#else
+	return aMessage.Write(MessagePtr(aMessage, aParam), aDes);
+#endif
+	}
+
+TInt MessageWrite(const RMsg& aMessage, TInt aParam, const TDesC16& aDes)
+	{
+#ifdef EKA2
+	return aMessage.Write(aParam, aDes);
+#else
+	return aMessage.Write(MessagePtr(aMessage, aParam), aDes);
+#endif
+	}
+
+TBool MessagePending(const RMsg& aMessage)
+	{
+#ifdef EKA2
+	return !aMessage.IsNull();
+#else
+	return aMessage != RMessagePtr();
+#endif
+	}
+
+TThreadId ClientThreadIdL(const RMsg& aMessage)
+	{
+	TThreadId clientThreadId;
+#ifdef EKA2
+	RThread clientThread;
+	aMessage.ClientL(clientThread);
+	clientThreadId = clientThread.Id();
+	clientThread.Close();
+#else
+	clientThreadId = aMessage.Client().Id();
+#endif
+	return clientThreadId;
+	}
+
+TFullName ClientNameL(const RMsg& aMessage)
+	{
+#ifdef EKA2
+	RThread clientThread;
+	aMessage.ClientL(clientThread);
+	TFullName clientName(clientThread.FullName());
+	clientThread.Close();
+	return clientName;
+#else
+	return aMessage.Client().FullName();
+#endif
+	}
+
+void Complete(const RMsg& aMessage, TInt aError)
+	{
+	LOG(CIoLog::LogCompletion(aMessage, aError));
+	aMessage.Complete(aError);
+	}
+
+void CompleteIfPending(const RMsg& aMessage, TInt aError)
+	{
+	if (MessagePending(aMessage))
+		{
+		Complete(aMessage, aError);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/server.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,176 @@
+// server.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SERVER_H__
+#define __SERVER_H__
+
+#ifdef EKA2
+#define RMsg RMessage2
+#else
+#define RMsg RMessage
+#endif
+
+#include <e32base.h>
+#include <f32file.h>
+#include <e32hashtab.h>
+#include "iocli.h"
+#include "clientserver.h"
+#include "log.h"
+#include "config.h"
+
+enum TIoPanicReason
+	{
+	EPanicBadDescriptor = 0,
+	EPanicBadHandle = 1,
+	EPanicUnknownOpcode = 2,
+	EPanicReadAlreadyPending = 3,
+	EPanicReadKeyAlreadyPending = 4,
+	EPanicReadWhenNotAttached = 5,
+	EPanicWriteAlreadyPending = 6,
+	EPanicWriteWhenNotAttached = 7,
+	EPanicReadKeyWhenNotAttached = 8,
+	EPanicCursorPosWhenNotAttached = 9,
+	EPanicSetCursorPosAbsWhenNotAttached = 10,
+	EPanicSetCursorPosRelWhenNotAttached = 11,
+	EPanicSetCursorHeightWhenNotAttached = 12,
+	EPanicSetTitleWhenNotAttached = 13,
+	EPanicClearScreenWhenNotAttached = 14,
+	EPanicClearToEndOfLineWhenNotAttached = 15,
+	EPanicScreenSizeWhenNotAttached = 16,
+	EPanicInvalidPipeId = 17,
+	EPanicSetConsoleModeWhenNotAttached = 18,
+	EPanicNotAnEndPoint = 19,
+	EPanicNotAPipe = 20,
+	EPanicNotAConsole = 21,
+	EPanicNotAReadWriteObject = 22,
+	EPanicNotAReadObject = 23,
+	EPanicNotAWriteObject = 24,
+	EPanicNotAPersistentConsole = 25,
+	EPanicNotAValidContainerType = 26,
+	EPanicFindNextWithNoFindFirst = 27,
+	EPanicOpenFoundWithNoFind = 28,
+	EPanicSetTitleAlreadyPending = 29,
+	EPanicCursorPosAlreadyPending = 30,
+	EPanicSetCursorPosAlreadyPending = 31,
+	EPanicSetCursorHeightAlreadyPending = 32,
+	EPanicClearScreenAlreadyPending = 33,
+	EPanicClearToEndOfLineAlreadyPending = 34, 
+	EPanicScreenSizeAlreadyPending = 35,
+	EPanicSetReadModeAlreadyPending = 36,
+	EPanicCannotReadFromUnderlyingConsole = 37,
+	EPanicSetAttributesWhenNotAttached = 38,
+	EPanicSetAttributesAlreadyPending = 39,
+	EPanicSetModeAlreadyPending = 40
+	};
+
+void PanicClient(const RMsg& aMessage, TIoPanicReason aReason);
+
+class CIoObject;
+class CIoLog;
+class CIoPipe;
+class CIoConsole;
+class CIoFile;
+class CIoNull;
+class CIoPersistentConsole;
+class CIoReadWriteObject;
+class CIoReadObject;
+class CIoWriteObject;
+class MIoWriteEndPoint;
+
+class CShutdownTimer : public CTimer
+	{
+	enum {KShutdownDelay = 0x2000000};
+public:
+	CShutdownTimer();
+	void ConstructL();
+	void Start();
+private:
+	void RunL();
+	};
+
+
+#ifdef EKA2
+class CIoServer : public CServer2
+#else
+class CIoServer : public CServer
+#endif
+	{
+public:
+#ifdef EKA2
+	static CServer2* NewLC();
+#else
+	static CServer* NewLC();
+#endif
+	~CIoServer();
+	void AddSession();
+	void DropSession();
+	CIoPipe& CreatePipeLC();
+	CIoConsole& CreateConsoleLC(const TDesC& aImplementation, const TDesC& aTitle, TSize aSize, MIoWriteEndPoint* aUnderlyingConsole, TUint aOptions);
+	CIoFile& CreateFileLC(const TDesC& aName, RIoFile::TMode aMode);
+	CIoNull& CreateNullLC();
+	CIoPersistentConsole& CreatePersistentConsoleLC(const TDesC& aName, const TDesC& aTitle, const RMsg& aMessage);
+	CIoReadObject& CreateReadObjLC();
+	CIoWriteObject& CreateWriteObjLC();
+	CIoReadObject* NextReadObj(TThreadId aOwningThread) const;
+	CIoWriteObject* NextWriteObj(TThreadId aOwningThread) const;
+	CIoReadObject* LastOpenedReadObj(TThreadId aOwningThread) const;
+	CIoWriteObject* LastOpenedWriteObj(TThreadId aOwningThread) const;
+	CIoPersistentConsole& FindPersistentConsoleL(const TDesC& aName);
+	CIoObject* FindObjectByName(RIoHandle::TType aType, TInt& aFindHandle, const TDesC& aMatch, TName& aName) const;
+	CIoObject& OpenObjectLC(TInt aFindHandle);
+	const TIoConfig& Config();
+	void PersistentConsoleAddL(const TDesC16& aName, const CIoPersistentConsole& aCons);
+	void PersistentConsoleRemove(const TDesC16& aName, const CIoPersistentConsole& aCons);
+private:
+	CIoServer();
+	void ConstructL();
+#ifdef EKA2
+	virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+#else
+	virtual CSharableSession* NewSessionL(const TVersion& aVersion) const;
+#endif
+	TInt RunError(TInt aError);
+	CIoReadWriteObject* DoFindObj(RIoHandle::TType aType, TThreadId aOwningThread, TBool aNext) const;
+private:
+	RFs iFs;
+	TInt iSessionCount;
+	CShutdownTimer iShutdownTimer;
+	CObjectConIx* iIoObjectContainerIndex; 
+	CObjectCon* iIoObjectContainer;
+	TUint iNextReadObjId;
+	TUint iNextWriteObjId;
+	TIoConfig iConfig;
+	RPtrHashMap<TDesC16, CIoPersistentConsole> iPersistentConsoleNames;
+#ifdef IOSRV_LOGGING
+	CIoLog* iLog;
+#endif
+	};
+
+	
+TInt DesLengthL(const RMsg& aMessage, TInt aParam);
+TInt MaxDesLengthL(const RMsg& aMessage, TInt aParam);
+void MessageReadL(const RMsg& aMessage, TInt aParam, TDes8& aDes);
+void MessageReadL(const RMsg& aMessage, TInt aParam, TDes8& aDes, TInt aOffset);
+void MessageReadL(const RMsg& aMessage, TInt aParam, TDes16& aDes);
+void MessageReadL(const RMsg& aMessage, TInt aParam, TDes16& aDes, TInt aOffset);
+void MessageWriteL(const RMsg& aMessage, TInt aParam, const TDesC8& aDes);
+void MessageWriteL(const RMsg& aMessage, TInt aParam, const TDesC16& aDes);
+TInt MessageWrite(const RMsg& aMessage, TInt aParam, const TDesC8& aDes);
+TInt MessageWrite(const RMsg& aMessage, TInt aParam, const TDesC16& aDes);
+TBool MessagePending(const RMsg& aMessage);
+TThreadId ClientThreadIdL(const RMsg& aMessage);
+TFullName ClientNameL(const RMsg& aMessage);
+void Complete(const RMsg& aMessage, TInt aError);
+void CompleteIfPending(const RMsg& aMessage, TInt aError);
+
+#endif // __SERVER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/session.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,797 @@
+// session.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "server.h"
+#include "pipe.h"
+#include "console.h"
+#include "file.h"
+#include "null.h"
+#include "persistentconsole.h"
+#include "readwrite.h"
+#include "clientserver.h"
+#include "session.h"
+
+
+CIoSession::CIoSession()
+	{
+	}
+
+CIoServer& CIoSession::Server()
+	{
+#ifdef EKA2
+	return *static_cast<CIoServer*>(const_cast<CServer2*>(CSession2::Server()));
+#else
+	return *static_cast<CIoServer*>(const_cast<CServer*>(CSharableSession::Server()));
+#endif
+	}
+
+#ifdef EKA2
+void CIoSession::CreateL()
+#else
+void CIoSession::CreateL(const CServer& aServer)
+#endif
+	{
+#ifndef EKA2
+	CSharableSession::CreateL(aServer);	// does not leave
+#endif
+	iHandles = CObjectIx::NewL();
+	Server().AddSession();
+	}
+
+CIoSession::~CIoSession()
+	{
+	delete iFindByNameMatch;
+	const TInt maxNumObjects = iHandles->Count();
+	for (TInt i = 0; i < maxNumObjects; ++i)
+		{
+		CIoObject* obj = static_cast<CIoObject*>((*iHandles)[i]);
+		if (obj != NULL)
+			{
+			obj->SessionClosed(*this);
+			}
+		}
+	Server().DropSession();
+	delete iHandles;
+	LOG(CIoLog::Printf(_L("CIoSession 0x%08x destroyed\r\n"), this));
+	}
+
+void CIoSession::ServiceL(const RMsg& aMessage)
+	{
+	LOG(CIoLog::StartServiceLC(aMessage));
+
+	switch (aMessage.Function())
+		{
+		case EIoHandleSetOwner:
+			{
+			TThreadId owningThread(aMessage.Int0());
+			FindReadWriteObjectL(aMessage.Int3(), aMessage).SetOwnerL(owningThread);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoHandleSetUnderlyingConsole:
+			{
+			FindReadWriteObjectL(aMessage.Int3(), aMessage).SetConsole(FindConsoleL(aMessage.Int0(), aMessage));
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoHandleAttachedToConsole:
+			{
+			CIoReadWriteObject& obj = FindReadWriteObjectL(aMessage.Int3(), aMessage);
+			if (obj.IsType(RIoHandle::EReadObject))
+				{
+				Complete(aMessage, MIoReadEndPoint::AttachedToConsole((MIoReadEndPoint*)obj.EndPoint()));
+				}
+			else
+				{
+				Complete(aMessage, MIoWriteEndPoint::AttachedToConsole((MIoWriteEndPoint*)obj.EndPoint()));
+				}
+			break;
+			}
+		case EIoCreateReader:
+			{
+			CIoReadObject& readObj = Server().CreateReadObjLC();
+			LOG(CIoLog::Printf(_L("id: %d"), readObj.Id()));
+			CreateHandleL(readObj, ETrue, aMessage);
+			break;
+			}
+		case EIoOpenReaderByThreadId:
+			{
+			TThreadId clientThreadId(ClientThreadIdL(aMessage));
+			CIoReadObject* readObj = Server().NextReadObj(clientThreadId);
+			if (readObj == NULL)
+				{
+				Complete(aMessage, KErrNotFound);
+				}
+			else
+				{
+#ifdef EKA2
+				LOG(CIoLog::Printf(_L("thread id: %Lu"), clientThreadId.Id()));
+#else
+				LOG(CIoLog::Printf(_L("thread id: %u"), clientThreadId));
+#endif
+				OBJ_NAME(*readObj);
+				LOG(CIoLog::Printf(_L("name: \"%S\""), &objName));
+				User::LeaveIfError(readObj->Open(clientThreadId));
+				CleanupClosePushL(*readObj);
+				CreateHandleL(*readObj, EFalse, aMessage);
+				CleanupStack::Pop();
+				}
+			break;
+			}
+		case EIoOpenReaderByExplicitThreadId:
+			{
+			TThreadId clientThreadId;
+			TPckg<TThreadId> clientThreadIdPckg(clientThreadId);
+			MessageReadL(aMessage, 0, clientThreadIdPckg);
+			CIoReadObject* readObj = Server().NextReadObj(clientThreadId);
+			if (readObj == NULL)
+				{
+				Complete(aMessage, KErrNotFound);
+				}
+			else
+				{
+#ifdef EKA2
+				LOG(CIoLog::Printf(_L("thread id: %Lu"), clientThreadId.Id()));
+#else
+				LOG(CIoLog::Printf(_L("thread id: %u"), clientThreadId));
+#endif
+				OBJ_NAME(*readObj);
+				LOG(CIoLog::Printf(_L("name: \"%S\""), &objName));
+				User::LeaveIfError(readObj->Open(clientThreadId));
+				CleanupClosePushL(*readObj);
+				CreateHandleL(*readObj, EFalse, aMessage);
+				CleanupStack::Pop();
+				}
+			break;
+			}
+		case EIoDuplicateReader:
+			{
+			CIoReadObject& readObj = FindReadObjectL(aMessage.Int3(), aMessage);
+			CIoReadObject& duplicateReadObj = FindReadObjectL(aMessage.Int0(), aMessage);
+			readObj.DuplicateL(duplicateReadObj);
+			LOG(CIoLog::Printf(_L("Duplicating read object 0x%08x (id: %d) from 0x%08x (id: %d)"), &readObj, readObj.Id(), &duplicateReadObj, duplicateReadObj.Id()));
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoDuplicateReaderHandleFromThread:
+			{
+			TThreadId threadId(aMessage.Int0());
+			CIoReadObject& readObj = FindReadObjectL(aMessage.Int3(), aMessage);
+			CIoReadObject* otherThreadObj = Server().LastOpenedReadObj(threadId);
+			if (otherThreadObj)
+				{
+				LOG(CIoLog::Printf(_L("Duplicating read object 0x%08x (id: %d) from 0x%08x (id: %d)"), &readObj, readObj.Id(), otherThreadObj, otherThreadObj->Id()));
+				readObj.DuplicateL(*otherThreadObj);
+				}
+			else
+				{
+				User::Leave(KErrNotFound);
+				}
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoCreateWriter:
+			{
+			CIoWriteObject& writeObj = Server().CreateWriteObjLC();
+			LOG(CIoLog::Printf(_L("id: %d"), writeObj.Id()));
+			CreateHandleL(writeObj, ETrue, aMessage);
+			break;
+			}
+		case EIoOpenWriterByThreadId:
+			{
+			TThreadId clientThreadId(ClientThreadIdL(aMessage));
+			CIoWriteObject* writeObj = Server().NextWriteObj(clientThreadId);
+			if (writeObj == NULL)
+				{
+				Complete(aMessage, KErrNotFound);
+				}
+			else
+				{
+				LOG(CIoLog::Printf(_L("thread id: %u"), TUint(clientThreadId)));
+				OBJ_NAME(*writeObj);
+				LOG(CIoLog::Printf(_L("name: \"%S\""), &objName));
+				User::LeaveIfError(writeObj->Open(clientThreadId));
+				CleanupClosePushL(*writeObj);				
+				CreateHandleL(*writeObj, EFalse, aMessage);
+				CleanupStack::Pop();
+				}
+			break;
+			}
+		case EIoOpenWriterByExplicitThreadId:
+			{
+			TThreadId clientThreadId;
+			TPckg<TThreadId> clientThreadIdPckg(clientThreadId);
+			MessageReadL(aMessage, 0, clientThreadIdPckg);
+			CIoWriteObject* writeObj = Server().NextWriteObj(clientThreadId);
+			if (writeObj == NULL)
+				{
+				Complete(aMessage, KErrNotFound);
+				}
+			else
+				{
+				LOG(CIoLog::Printf(_L("thread id: %u"), TUint(clientThreadId)));
+				OBJ_NAME(*writeObj);
+				LOG(CIoLog::Printf(_L("name: \"%S\""), &objName));
+				User::LeaveIfError(writeObj->Open(clientThreadId));
+				CleanupClosePushL(*writeObj);				
+				CreateHandleL(*writeObj, EFalse, aMessage);
+				CleanupStack::Pop();
+				}
+			break;
+			}
+		case EIoDuplicateWriter:
+			{
+			CIoWriteObject& writeObj = FindWriteObjectL(aMessage.Int3(), aMessage);
+			CIoWriteObject& duplicateWriteObj = FindWriteObjectL(aMessage.Int0(), aMessage);
+			writeObj.DuplicateL(duplicateWriteObj);
+			LOG(CIoLog::Printf(_L("Duplicating write object 0x%08x (id: %d) from 0x%08x (id: %d)"), &writeObj, writeObj.Id(), &duplicateWriteObj, duplicateWriteObj.Id()));
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoDuplicateWriterHandleFromThread:
+			{
+			TThreadId threadId(aMessage.Int0());
+			CIoWriteObject& writeObj = FindWriteObjectL(aMessage.Int3(), aMessage);
+			CIoWriteObject* otherThreadObj = Server().LastOpenedWriteObj(threadId);
+			if (otherThreadObj)
+				{
+				LOG(CIoLog::Printf(_L("Duplicating write object 0x%08x (id: %d) from 0x%08x (id: %d)"), &writeObj, writeObj.Id(), otherThreadObj, otherThreadObj->Id()));
+				writeObj.DuplicateL(*otherThreadObj);
+				}
+			else
+				{
+				User::Leave(KErrNotFound);
+				}
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoSetReadWriteMode:
+			{
+			FindReadWriteObjectL(aMessage.Int3(), aMessage).SetModeL(aMessage);
+			break;
+			}
+		case EIoSetReadMode:
+			{
+			TInt mode(aMessage.Int0());
+			if ((mode >= RIoReadHandle::EFull) && (mode <= RIoReadHandle::EOneOrMore))
+				{
+				FindReadObjectL(aMessage.Int3(), aMessage).SetReadMode((RIoReadHandle::TReadMode)mode);
+				Complete(aMessage, KErrNone);
+				}
+			else
+				{
+				Complete(aMessage, KErrNotSupported);
+				}
+			break;
+			}
+		case EIoSetReaderToForeground:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).SetToForegroundL();
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoRead:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).ReadL(aMessage);
+			break;
+			}
+		case EIoReadCancel:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).ReadCancel(*this);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoSetLineSeparator:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).SetLineSeparatorL(aMessage);
+			break;
+			}
+		case EIoWrite:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).WriteL(aMessage);
+			break;
+			}
+		case EIoWriteCancel:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).WriteCancel(*this);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoIsForegroundReader:
+			{
+			Complete(aMessage, FindReadObjectL(aMessage.Int3(), aMessage).IsForegroundL());
+			break;
+			}
+		case EIoConsoleWaitForKey:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).ReadKeyL(aMessage);
+			break;
+			}
+		case EIoConsoleWaitForKeyCancel:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).ReadKeyCancel(*this);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoConsoleCaptureKey:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).CaptureKeyL(aMessage);
+			break;
+			}
+		case EIoConsoleCancelCaptureKey:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).CancelCaptureKey(aMessage);
+			break;
+			}
+		case EIoConsoleCaptureAllKeys:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).CaptureAllKeys(aMessage);
+			break;
+			}
+		case EIoConsoleCancelCaptureAllKeys:
+			{
+			FindReadObjectL(aMessage.Int3(), aMessage).CancelCaptureAllKeys(aMessage);
+			break;
+			}
+		case EIoConsoleCursorPos:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).CursorPosL(aMessage);
+			break;
+			}
+		case EIoConsoleSetCursorPosAbs:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).SetCursorPosAbsL(aMessage);
+			break;
+			}
+		case EIoConsoleSetCursorPosRel:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).SetCursorPosRelL(aMessage);
+			break;
+			}
+		case EIoConsoleSetCursorHeight:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).SetCursorHeightL(aMessage);
+			break;
+			}
+		case EIoConsoleSetTitle:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).SetTitleL(aMessage);
+			break;
+			}
+		case EIoConsoleClearScreen:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).ClearScreen(aMessage);
+			break;
+			}
+		case EIoConsoleClearToEndOfLine:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).ClearToEndOfLine(aMessage);
+			break;
+			}
+		case EIoConsoleScreenSize:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).ScreenSizeL(aMessage);
+			break;
+			}
+		case EIoConsoleSetAttributes:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).SetAttributesL(aMessage);
+			break;
+			}
+		case EIoCreatePipe:
+			{
+			CIoPipe& pipe = Server().CreatePipeLC();
+			CreateHandleL(pipe, ETrue, aMessage);
+			break;
+			}
+		case EIoHandleClose:
+			{
+			const TInt handle = aMessage.Int3();
+			LOG(CIoLog::Printf(_L("handle: %d"), handle));
+			CIoObject* obj = (CIoObject*)iHandles->AtL(handle); // Leaves with KErrBadHandle if not found, which will result in client getting panic'd.
+			obj->ClosedBy(*this);
+			iHandles->Remove(handle);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoEndPointAttachReader:
+			{
+			CIoEndPoint& endPoint = FindEndPointL(aMessage.Int3(), aMessage);
+			CIoReadObject& readObj = FindReadObjectL(aMessage.Int0(), aMessage);
+			RIoEndPoint::TReadMode mode = (RIoEndPoint::TReadMode)aMessage.Int1();
+			LOG(CIoLog::Printf(_L("read obj id:      %d, address: 0x%08x"), readObj.Id(), &readObj));
+			LOG(CIoLog::Printf(_L("end point handle: %d, address: 0x%08x"), aMessage.Int3(), &endPoint));
+			readObj.AttachL(endPoint, mode);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoEndPointAttachWriter:
+			{
+			CIoEndPoint& endPoint = FindEndPointL(aMessage.Int3(), aMessage);
+			CIoWriteObject& writeObj = FindWriteObjectL(aMessage.Int0(), aMessage);
+			LOG(CIoLog::Printf(_L("write obj id:     %d, address: 0x%08x"), writeObj.Id(), &writeObj));
+			LOG(CIoLog::Printf(_L("end point handle: %d, address: 0x%08x"), aMessage.Int3(), &endPoint));
+			writeObj.AttachL(endPoint);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoEndPointSetForegroundReadHandle:
+			{
+			CIoEndPoint& endPoint = FindEndPointL(aMessage.Int3(), aMessage);
+			CIoReadObject& readObj = FindReadObjectL(aMessage.Int0(), aMessage);
+			LOG(CIoLog::Printf(_L("read obj id:      %d, address: 0x%08x"), readObj.Id(), &readObj));
+			LOG(CIoLog::Printf(_L("end point handle: %d, address: 0x%08x"), aMessage.Int3(), &endPoint));
+			endPoint.IorepSetForegroundReaderL(readObj);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoCreateConsole:
+			{
+			HBufC* titleBuf = HBufC::NewLC(DesLengthL(aMessage, 0));
+			TPtr titlePtr(titleBuf->Des());
+			MessageReadL(aMessage, 0, titlePtr);
+			TPckgBuf<TConsoleCreateParams> paramsPckg;
+			MessageReadL(aMessage, 1, paramsPckg);
+			HBufC* implBuf = HBufC::NewLC(DesLengthL(aMessage, 2));
+			TPtr implPtr(implBuf->Des());
+			MessageReadL(aMessage, 2, implPtr);
+			CIoConsole* underlyingCons = NULL;
+			if (paramsPckg().iUnderlyingConsoleHandle != KNullHandle)
+				{
+				underlyingCons = &FindConsoleL(paramsPckg().iUnderlyingConsoleHandle, aMessage);
+				}
+			CIoConsole& console = Server().CreateConsoleLC(*implBuf, *titleBuf, paramsPckg().iSize, underlyingCons, paramsPckg().iOptions);
+			CreateHandleL(console, ETrue, aMessage); //pops console
+			CleanupStack::PopAndDestroy(2, titleBuf);
+			break;
+			}
+		case EIoOpenConsole:
+			{
+			CIoConsole* console = FindReadWriteObjectL(aMessage.Int0(), aMessage).Console();
+			if (console)
+				{
+				User::LeaveIfError(console->Open());
+				CleanupClosePushL(*console);
+				CreateHandleL(*console, EFalse, aMessage);
+				CleanupStack::Pop();
+				}
+			else
+				{
+				Complete(aMessage, KErrNotFound);
+				}
+			break;
+			}
+		case EIoConsoleImplementation:
+			{
+			TInt clientDesLen = MaxDesLengthL(aMessage, 0);
+			const TDesC& impl(FindConsoleL(aMessage.Int3(), aMessage).Implementation());
+			MessageWriteL(aMessage, 0, impl.Left(clientDesLen));
+			Complete(aMessage, impl.Length() > clientDesLen ? KErrOverflow : KErrNone);
+			break;
+			}
+		case EIoCreateFile:
+			{
+			HBufC* fileNameBuf = HBufC::NewLC(DesLengthL(aMessage, 0));
+			TPtr fileNamePtr(fileNameBuf->Des());
+			MessageReadL(aMessage, 0, fileNamePtr);
+			CIoFile& file = Server().CreateFileLC(*fileNameBuf, (RIoFile::TMode)aMessage.Int1());
+			CreateHandleL(file, ETrue, aMessage);
+			CleanupStack::PopAndDestroy(fileNameBuf);
+			break;
+			}
+		case EIoCreateNull:
+			{
+			CIoNull& null = Server().CreateNullLC();
+			CreateHandleL(null, ETrue, aMessage);
+			break;
+			}
+		case EIoSetObjectName:
+			{
+			CObject* obj = iHandles->AtL(aMessage.Int0());
+			HBufC* name = HBufC::NewLC(DesLengthL(aMessage, 1));
+			TPtr namePtr(name->Des());
+			MessageReadL(aMessage, 1, namePtr);
+			LOG(CIoLog::Printf(_L("Setting object (handle: %d, address: 0x%08x) to \"%S\""), aMessage.Int0(), &obj, name));
+			TPtrC truncatedName(name->Left(KMaxName));
+			obj->SetName(&truncatedName);
+			CleanupStack::PopAndDestroy(name);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoCreatePersistentConsole:
+			{
+			HBufC* nameBuf = HBufC::NewLC(DesLengthL(aMessage, 1));
+			TPtr namePtr(nameBuf->Des());
+			MessageReadL(aMessage, 0, namePtr);
+			
+			HBufC* titleBuf = HBufC::NewLC(DesLengthL(aMessage, 0));
+			TPtr titlePtr(titleBuf->Des());
+			MessageReadL(aMessage, 1, titlePtr);
+
+			CIoPersistentConsole& pcons = Server().CreatePersistentConsoleLC(*nameBuf, *titleBuf, aMessage);
+			CreateHandleL(pcons, ETrue, aMessage);
+			CleanupStack::PopAndDestroy(2, nameBuf);
+			break;
+			}
+		case EIoOpenPersistentConsoleByName:
+			{
+			HBufC* nameBuf = HBufC::NewLC(DesLengthL(aMessage, 0));
+			TPtr namePtr(nameBuf->Des());
+			MessageReadL(aMessage, 0, namePtr);
+			
+			CIoPersistentConsole& pcons = Server().FindPersistentConsoleL(*nameBuf);
+			User::LeaveIfError(pcons.Open());
+			CleanupClosePushL(pcons);
+			CreateHandleL(pcons, EFalse, aMessage);
+			CleanupStack::Pop(&pcons);
+			CleanupStack::PopAndDestroy(nameBuf);
+			break;
+			};
+		case EIoPersistentConsoleAttachReadEndPoint:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			CIoEndPoint& endPoint = FindEndPointL(aMessage.Int0(), aMessage);
+			RIoPersistentConsole::TCloseBehaviour onClose = (RIoPersistentConsole::TCloseBehaviour)aMessage.Int1();
+			pcons.AttachTransientReaderL(endPoint, onClose == RIoPersistentConsole::EDetachOnHandleClose ? this : NULL);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoPersistentConsoleAttachWriteEndPoint:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			CIoEndPoint& endPoint = FindEndPointL(aMessage.Int0(), aMessage);
+			RIoPersistentConsole::TCloseBehaviour onClose = (RIoPersistentConsole::TCloseBehaviour)aMessage.Int1();
+			pcons.AttachTransientWriterL(endPoint, onClose == RIoPersistentConsole::EDetachOnHandleClose ? this : NULL);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoPersistentConsoleDetachReadEndPoint:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			pcons.DetachTransientReader();
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoPersistentConsoleDetachWriteEndPoint:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			pcons.DetachTransientWriter();
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoPersistentConsoleNotifyReadDetach:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			pcons.NotifyReadDetachL(aMessage);
+			break;
+			}
+		case EIoPersistentConsoleNotifyWriteDetach:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			pcons.NotifyWriteDetachL(aMessage);
+			break;
+			}
+		case EIoPersistentConsoleCancelNotifyReadDetach:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			pcons.CancelNotifyReadDetach((TRequestStatus*)aMessage.Int0());
+			break;
+			}
+		case EIoPersistentConsoleCancelNotifyWriteDetach:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			pcons.CancelNotifyWriteDetach((TRequestStatus*)aMessage.Int0());
+			break;
+			}
+		case EIoPersistentConsoleGetAttachedNames:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			MessageWriteL(aMessage, 0, pcons.TransientReaderName());
+			MessageWriteL(aMessage, 1, pcons.TransientWriterName());
+			Complete(aMessage, KErrNone);
+			break;
+			}		
+		case EIoPersistentConsoleGetCreatorThreadId:
+			{
+			CIoPersistentConsole& pcons = FindPersistentConsoleL(aMessage.Int3(), aMessage);
+			MessageWriteL(aMessage, 0, TPckg<TThreadId>(pcons.Creator()));
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoHandleIsType:
+			{
+			CIoObject& obj = FindObjectL(aMessage.Int3());
+			Complete(aMessage, obj.IsType((RIoHandle::TType)aMessage.Int0()));
+			break;
+			}
+		case EIoFindFirstHandle:
+			{
+			iFindByNameType = (RIoHandle::TType)aMessage.Int0();
+
+			delete iFindByNameMatch;
+			iFindByNameMatch = NULL;
+			iFindByNameMatch = HBufC::NewL(DesLengthL(aMessage, 1));
+			TPtr matchPtr(iFindByNameMatch->Des());
+			MessageReadL(aMessage, 1, matchPtr);
+
+			TName foundName;
+			iFindByNameHandle = 0;
+			CIoObject* obj = Server().FindObjectByName(iFindByNameType, iFindByNameHandle, *iFindByNameMatch, foundName);
+			if (obj)
+				{
+				MessageWriteL(aMessage, 2, TPckg<TInt>(iFindByNameHandle));
+				MessageWriteL(aMessage, 3, foundName);
+				Complete(aMessage, KErrNone);	
+				}
+			else
+				{
+				Complete(aMessage, KErrNotFound);	
+				}
+			break;
+			}
+		case EIoFindNextHandle:
+			{
+			if (!(iFindByNameMatch && iFindByNameHandle))
+				{
+				PanicClient(aMessage, EPanicFindNextWithNoFindFirst);
+				break;
+				}
+				
+			TName foundName;
+			CIoObject* obj = Server().FindObjectByName(iFindByNameType, iFindByNameHandle, *iFindByNameMatch, foundName);
+			if (obj)
+				{
+				MessageWriteL(aMessage, 0, TPckg<TInt>(iFindByNameHandle));
+				MessageWriteL(aMessage, 1, foundName);
+				Complete(aMessage, KErrNone);	
+				}
+			else
+				{
+				Complete(aMessage, KErrNotFound);	
+				}
+			break;
+			}
+		case EIoOpenFoundHandle:
+			{
+			if (!(iFindByNameMatch && iFindByNameHandle))
+				{
+				PanicClient(aMessage, EPanicOpenFoundWithNoFind);
+				break;
+				}
+			
+			CIoObject& obj = Server().OpenObjectLC(aMessage.Int0());
+			CreateHandleL(obj, EFalse, aMessage);
+			CleanupStack::Pop(&obj);
+			break;
+			}
+		case EIoHandleGetName:
+			{
+			CIoObject& obj = FindObjectL(aMessage.Int3());
+			TName name(obj.Name());
+			MessageWriteL(aMessage, 0, name.Left(MaxDesLengthL(aMessage, 0)));
+			Complete(aMessage, MaxDesLengthL(aMessage, 0) < name.Length() ? KErrOverflow : KErrNone);	
+			break;
+			};
+		case EIoHandleEquals:
+			{
+			CIoObject& tweedledee = FindObjectL(aMessage.Int3());
+			CIoObject& tweedledum = FindObjectL(aMessage.Int0());
+			Complete(aMessage, &tweedledee == &tweedledum);
+			break;
+			};
+		case EIoReadHandleNotifyChange:
+			{
+			CIoReadObject& readObj = FindReadObjectL(aMessage.Int3(), aMessage);
+			readObj.NotifyChange(aMessage);
+			break;
+			}
+		case EIoReadHandleCancelNotifyChange:
+			{
+			CIoReadObject& readObj = FindReadObjectL(aMessage.Int3(), aMessage);
+			readObj.CancelNotifyChange(*this);
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		case EIoSetIsStdErr:
+			{
+			FindWriteObjectL(aMessage.Int3(), aMessage).SetIsStdErr((TBool)aMessage.Int0());
+			Complete(aMessage, KErrNone);
+			break;
+			}
+		default:
+			{
+			PanicClient(aMessage, EPanicUnknownOpcode);
+			break;
+			}
+		}
+
+	LOG(CleanupStack::PopAndDestroy());
+	}
+
+void CIoSession::CreateHandleL(CObject& aObject, TBool aDoPop, const RMsg& aMessage)
+	{
+	const TInt handle = iHandles->AddL(&aObject);
+	if (aDoPop)
+		{
+		CleanupStack::Pop(&aObject);
+		}
+	TPckgC<TInt> handlePckg(handle);
+	TRAPD(err, MessageWriteL(aMessage, 3, handlePckg));
+	if (err)
+		{
+		iHandles->Remove(handle);
+		User::Leave(err);
+		}
+	LOG(CIoLog::Printf(_L("Created handle %d"), handle));
+	Complete(aMessage, err);
+	}
+	
+CIoObject& CIoSession::FindObjectL(TInt aHandle)
+	{
+	CIoObject* obj = static_cast<CIoObject*>(iHandles->AtL(aHandle));
+	return *obj;
+	}
+
+CIoEndPoint& CIoSession::FindEndPointL(TInt aHandle, const RMsg& aMessage)
+	{
+	CIoObject* obj = static_cast<CIoObject*>(iHandles->AtL(aHandle));
+	__ASSERT_ALWAYS(obj->IsType(RIoHandle::EEndPoint), PanicClient(aMessage, EPanicNotAnEndPoint));
+	return *static_cast<CIoEndPoint*>(obj);
+	}
+
+CIoPipe& CIoSession::FindPipeL(TInt aHandle, const RMsg& aMessage)
+	{
+	CIoObject* obj = static_cast<CIoObject*>(iHandles->AtL(aHandle));
+	__ASSERT_ALWAYS(obj->IsType(RIoHandle::EPipe), PanicClient(aMessage, EPanicNotAPipe));
+	return *static_cast<CIoPipe*>(obj);
+	}
+
+CIoConsole& CIoSession::FindConsoleL(TInt aHandle, const RMsg& aMessage)
+	{
+	CIoObject* obj = static_cast<CIoObject*>(iHandles->AtL(aHandle));
+	__ASSERT_ALWAYS(obj->IsType(RIoHandle::EConsole), PanicClient(aMessage, EPanicNotAConsole));
+	return *static_cast<CIoConsole*>(obj);
+	}
+	
+CIoPersistentConsole& CIoSession::FindPersistentConsoleL(TInt aHandle, const RMsg& aMessage)
+	{
+	CIoObject* obj = static_cast<CIoObject*>(iHandles->AtL(aHandle));
+	__ASSERT_ALWAYS(obj->IsType(RIoHandle::EPersistentConsole), PanicClient(aMessage, EPanicNotAPersistentConsole));
+	return *static_cast<CIoPersistentConsole*>(obj);
+	}
+
+CIoReadWriteObject& CIoSession::FindReadWriteObjectL(TInt aHandle, const RMsg& aMessage)
+	{
+	CIoObject* obj = static_cast<CIoObject*>(iHandles->AtL(aHandle));
+	__ASSERT_ALWAYS(obj->IsType(RIoHandle::EReadWriteObject), PanicClient(aMessage, EPanicNotAReadWriteObject));
+	return *static_cast<CIoReadWriteObject*>(obj);
+	}
+
+CIoReadObject& CIoSession::FindReadObjectL(TInt aHandle, const RMsg& aMessage)
+	{
+	CIoObject* obj = static_cast<CIoObject*>(iHandles->AtL(aHandle));
+	__ASSERT_ALWAYS(obj->IsType(RIoHandle::EReadObject), PanicClient(aMessage, EPanicNotAReadObject));
+	return *static_cast<CIoReadObject*>(obj);
+	}
+
+CIoWriteObject& CIoSession::FindWriteObjectL(TInt aHandle, const RMsg& aMessage)
+	{
+	CIoObject* obj = static_cast<CIoObject*>(iHandles->AtL(aHandle));
+	__ASSERT_ALWAYS(obj->IsType(RIoHandle::EWriteObject), PanicClient(aMessage, EPanicNotAWriteObject));
+	return *static_cast<CIoWriteObject*>(obj);
+	}
+
+void CIoSession::Complete(const RMsg& aMessage, TInt aError)
+	{
+	LOG(CIoLog::LogCompletion(aMessage, aError));
+	aMessage.Complete(aError);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/server/session.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,59 @@
+// session.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SESSION_H__
+#define __SESSION_H__
+
+#include <e32base.h>
+#include "readwrite.h"
+
+class CIoServer;
+
+#ifdef EKA2
+class CIoSession : public CSession2
+#else
+class CIoSession : public CSharableSession
+#endif
+	{
+public:
+	CIoSession();
+#ifdef EKA2
+	void CreateL();
+#else
+	void CreateL(const CServer& aServer);
+#endif
+private:
+	~CIoSession();
+	CIoServer& Server();
+	void ServiceL(const RMsg& aMessage);
+	void CreateHandleL(CObject& aObject, TBool aDoPop, const RMsg& aMessage);
+	CIoObject& FindObjectL(TInt aHandle);
+	CIoEndPoint& FindEndPointL(TInt aHandle, const RMsg& aMessage);
+	CIoPipe& FindPipeL(TInt aHandle, const RMsg& aMessage);
+	CIoConsole& FindConsoleL(TInt aHandle, const RMsg& aMessage);
+	CIoPersistentConsole& FindPersistentConsoleL(TInt aHandle, const RMsg& aMessage);
+	CIoReadWriteObject& FindReadWriteObjectL(TInt aHandle, const RMsg& aMessage);
+	CIoReadObject& FindReadObjectL(TInt aHandle, const RMsg& aMessage);
+	CIoWriteObject& FindWriteObjectL(TInt aHandle, const RMsg& aMessage);
+	void Complete(const RMsg& aMessage, TInt aError);
+	
+private:
+	CObjectIx* iHandles;
+#ifdef IOSRV_LOGGING
+	TName iName;
+#endif
+	RIoHandle::TType iFindByNameType;
+	TInt iFindByNameHandle;
+	HBufC* iFindByNameMatch;
+	};
+
+#endif // __SESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/tsrc/t1_newlineend.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4 @@
+A test file
+with several lines
+the last of which
+ends with a new line
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/tsrc/t2_nonewlineend.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4 @@
+A test file
+with several lines
+the last of which
+does not end with a new line
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/tsrc/t3_alloneline.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1 @@
+A test file which contains a some text that does not end in a new line.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/tsrc/t_ioread.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,162 @@
+// t_ioread.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+
+using namespace IoUtils;
+
+// enum corresponding to RIoReadHandle::TReadMode
+_LIT(KReadModeEnum, "full,line,oneormore");
+
+static const TInt KDefaultReadSize = 0x100;
+
+class CIoReadTest : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CIoReadTest();
+private:
+	CIoReadTest();
+	void ReadFileL();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TFileName2 iFile;
+	TInt iReadSize;
+	RIoReadHandle::TReadMode iReadMode;
+	RBuf iFileContents;
+	
+	RIoFile iIoFile;
+	RIoReadHandle iFileReader;
+	RBuf iReadBuf;
+	CTextBuffer* iFileBuffer;
+	};
+
+
+CCommandBase* CIoReadTest::NewLC()
+	{
+	CIoReadTest* self = new(ELeave) CIoReadTest();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CIoReadTest::~CIoReadTest()
+	{
+	iFileContents.Close();
+	iIoFile.Close();
+	iFileReader.Close();
+	iReadBuf.Close();
+	delete iFileBuffer;
+	}
+
+CIoReadTest::CIoReadTest()
+	: iReadSize(KDefaultReadSize)
+	{
+	}
+
+const TDesC& CIoReadTest::Name() const
+	{
+	_LIT(KName, "t_ioread");	
+	return KName;
+	}
+
+const TDesC& CIoReadTest::Description() const
+	{
+	_LIT(KDescription, "Test harness for iosrv file reading functionality");
+	return KDescription;
+	}
+	
+void CIoReadTest::ReadFileL()
+	{
+	RFile file;
+	LeaveIfErr(file.Open(Fs(), iFile, EFileRead | EFileShareExclusive), _L("Cannot open file '%S'"), &iFile);
+	CleanupClosePushL(file);
+	TInt fileSize;
+	User::LeaveIfError(file.Size(fileSize));
+	
+	RBuf8 contents;
+	contents.CreateL(fileSize);
+	CleanupClosePushL(contents);
+	User::LeaveIfError(file.Read(contents));
+	
+	// convert data to 16-bit which is how it'll come out of the io server
+	iFileContents.CreateL(fileSize);
+	iFileContents.Copy(contents); // copy & expand
+	CleanupStack::PopAndDestroy(2, &file); // contents, file
+	}
+
+void CIoReadTest::DoRunL()
+	{
+	// read the file into memory
+	ReadFileL();
+	
+	LeaveIfErr(iIoFile.Create(IoSession(), iFile, RIoFile::ERead), _L("Cannot create file end point for '%S'"), &iFile);
+	
+	iFileReader.CreateL(IoSession());
+	iIoFile.AttachL(iFileReader, RIoEndPoint::EForeground);
+	
+	iFileReader.SetReadModeL(iReadMode);
+	
+	iReadBuf.CreateL(iReadSize);
+	
+	
+	iFileBuffer = CTextBuffer::NewL(0x20);
+	TInt err;
+	do
+		{
+		iReadBuf.Zero();
+		err = iFileReader.Read(iReadBuf);
+		iFileBuffer->AppendL(iReadBuf);
+		} while (err == KErrNone);
+		
+	if (err!=KErrEof) LeaveIfErr(err, _L("Unexpected error from RIoReadHandle::Read"));
+	
+	TInt completion = 0;
+	if (iFileBuffer->Length() != iFileContents.Length())
+		{
+		PrintWarning(_L("Amount of data read from file (%d) differs from file size (%d)."), iFileBuffer->Length(), iFileContents.Length());
+		completion = 1;
+		}
+	if (iFileBuffer->Descriptor().Compare(iFileContents) != 0)
+		{
+		PrintWarning(_L("Data read from file differs from file contents."));
+		completion = 1;
+		}
+	Complete(completion);
+	}
+
+void CIoReadTest::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KFile, "file");
+	_LIT(KFileDescription, "File to test with");
+	aArguments.AppendFileNameL(iFile, KFile, KFileDescription);
+	}
+
+void CIoReadTest::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KReadSize, "size");
+	_LIT(KReadSizeDescription, "The size of each read to issue");
+	aOptions.AppendIntL(iReadSize, 's', KReadSize, KReadSizeDescription);
+	
+	_LIT(KReadMode, "mode");
+	_LIT(KReadModeDescription, "The type of read to issue");
+	aOptions.AppendEnumL((TInt&)iReadMode, 'm', KReadMode, KReadModeDescription, KReadModeEnum);
+	}
+
+
+EXE_BOILER_PLATE(CIoReadTest)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/tsrc/t_ioread.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+// t_ioread.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+target          t_ioread.exe
+targettype      exe
+uid             0x102835BE 0x1028719C
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          t_ioread.cpp
+
+library         euser.lib
+library         iocli.lib
+library			efsrv.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/iosrv/tsrc/t_ioread.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+#!fshell
+# t_ioread.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# test script for io server file read handles
+
+export REPORT_FAILURE "echo Failure at line ^$SCRIPT_LINE of ^$SCRIPT_NAME^^n^^n"
+
+t_ioread	t1_newlineend.txt	--size 1	--mode full		|| $REPORT_FAILURE
+t_ioread	t1_newlineend.txt	--size 1	--mode line		|| $REPORT_FAILURE
+t_ioread	t1_newlineend.txt	--size 1	--mode oneormore	|| $REPORT_FAILURE
+
+t_ioread	t1_newlineend.txt	--size 10	--mode full		|| $REPORT_FAILURE
+t_ioread	t1_newlineend.txt	--size 10	--mode line		|| $REPORT_FAILURE
+t_ioread	t1_newlineend.txt	--size 10	--mode oneormore	|| $REPORT_FAILURE
+
+t_ioread	t1_newlineend.txt	--size 1024	--mode full		|| $REPORT_FAILURE
+t_ioread	t1_newlineend.txt	--size 1024	--mode line		|| $REPORT_FAILURE
+t_ioread	t1_newlineend.txt	--size 1024	--mode oneormore	|| $REPORT_FAILURE
+
+t_ioread	t2_nonewlineend.txt	--size 1	--mode full		|| $REPORT_FAILURE
+t_ioread	t2_nonewlineend.txt	--size 1	--mode line		|| $REPORT_FAILURE
+t_ioread	t2_nonewlineend.txt	--size 1	--mode oneormore	|| $REPORT_FAILURE
+
+t_ioread	t2_nonewlineend.txt	--size 10	--mode full		|| $REPORT_FAILURE
+t_ioread	t2_nonewlineend.txt	--size 10	--mode line		|| $REPORT_FAILURE
+t_ioread	t2_nonewlineend.txt	--size 10	--mode oneormore	|| $REPORT_FAILURE
+              
+t_ioread	t2_nonewlineend.txt	--size 1024	--mode full		|| $REPORT_FAILURE
+t_ioread	t2_nonewlineend.txt	--size 1024	--mode line		|| $REPORT_FAILURE
+t_ioread	t2_nonewlineend.txt	--size 1024	--mode oneormore	|| $REPORT_FAILURE
+              
+t_ioread	t3_alloneline.txt	--size 1	--mode full		|| $REPORT_FAILURE
+t_ioread	t3_alloneline.txt	--size 1	--mode line		|| $REPORT_FAILURE
+t_ioread	t3_alloneline.txt	--size 1	--mode oneormore	|| $REPORT_FAILURE
+
+t_ioread	t3_alloneline.txt	--size 10	--mode full		|| $REPORT_FAILURE
+t_ioread	t3_alloneline.txt	--size 10	--mode line		|| $REPORT_FAILURE
+t_ioread	t3_alloneline.txt	--size 10	--mode oneormore	|| $REPORT_FAILURE
+              
+t_ioread	t3_alloneline.txt	--size 1024	--mode full		|| $REPORT_FAILURE
+t_ioread	t3_alloneline.txt	--size 1024	--mode line		|| $REPORT_FAILURE
+t_ioread	t3_alloneline.txt	--size 1024	--mode oneormore	|| $REPORT_FAILURE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/bmarm/lineeditorU.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+EXPORTS
+	__20TIoConsWriterAdaptorR21RIoConsoleWriteHandle @ 1 NONAME R3UNUSED ; TIoConsWriterAdaptor::TIoConsWriterAdaptor(RIoConsoleWriteHandle &)
+	Contents__C12TConsoleLine @ 2 NONAME R3UNUSED ; TConsoleLine::Contents(void) const
+	CursorBeginning__12TConsoleLine @ 3 NONAME R3UNUSED ; TConsoleLine::CursorBeginning(void)
+	CursorEnd__12TConsoleLine @ 4 NONAME R3UNUSED ; TConsoleLine::CursorEnd(void)
+	CursorLeft__12TConsoleLine @ 5 NONAME R3UNUSED ; TConsoleLine::CursorLeft(void)
+	CursorNextWord__12TConsoleLine @ 6 NONAME R3UNUSED ; TConsoleLine::CursorNextWord(void)
+	CursorPreviousWord__12TConsoleLine @ 7 NONAME R3UNUSED ; TConsoleLine::CursorPreviousWord(void)
+	CursorRight__12TConsoleLine @ 8 NONAME R3UNUSED ; TConsoleLine::CursorRight(void)
+	DeleteLeft__12TConsoleLine @ 9 NONAME R3UNUSED ; TConsoleLine::DeleteLeft(void)
+	DeleteRight__12TConsoleLine @ 10 NONAME R3UNUSED ; TConsoleLine::DeleteRight(void)
+	End__12TConsoleLine @ 11 NONAME R3UNUSED ; TConsoleLine::End(void)
+	HandleKey__11CLineEditorUiUi @ 12 NONAME R3UNUSED ; CLineEditor::HandleKey(unsigned int, unsigned int)
+	Insert__12TConsoleLineG5TChar @ 13 NONAME R3UNUSED ; TConsoleLine::Insert(TChar)
+	NewL__11CLineEditorR3RFsR22MAbstractConsoleWriterR19MLineEditorObserverR14MLineCompleter @ 14 NONAME ABSENT ; CLineEditor::NewL(RFs &, MAbstractConsoleWriter &, MLineEditorObserver &, MLineCompleter &)
+	NewL__11CLineEditorR3RFsR22MAbstractConsoleWriterR19MLineEditorObserverR14MLineCompleterRC7TDesC16 @ 15 NONAME ; CLineEditor::NewL(RFs &, MAbstractConsoleWriter &, MLineEditorObserver &, MLineCompleter &, TDesC16 const &)
+	Overwrite__12TConsoleLineG5TChar @ 16 NONAME R3UNUSED ; TConsoleLine::Overwrite(TChar)
+	PrintCompletionPossibilitiesL__12TConsoleLineRC7TDesC16 @ 17 NONAME R3UNUSED ; TConsoleLine::PrintCompletionPossibilitiesL(TDesC16 const &)
+	Redraw__12TConsoleLine @ 18 NONAME R3UNUSED ; TConsoleLine::Redraw(void)
+	ReinstatePromptAndUserInput__11CLineEditor @ 19 NONAME R3UNUSED ; CLineEditor::ReinstatePromptAndUserInput(void)
+	RemovePromptAndUserInput__11CLineEditor @ 20 NONAME R3UNUSED ; CLineEditor::RemovePromptAndUserInput(void)
+	Replace__12TConsoleLineRC7TDesC16 @ 21 NONAME R3UNUSED ; TConsoleLine::Replace(TDesC16 const &)
+	Replace__12TConsoleLineiRC7TDesC16 @ 22 NONAME R3UNUSED ; TConsoleLine::Replace(int, TDesC16 const &)
+	Start__11CLineEditorRC7TDesC16 @ 23 NONAME R3UNUSED ; CLineEditor::Start(TDesC16 const &)
+	Start__11CLineEditorRC7TDesC16T1 @ 24 NONAME R3UNUSED ; CLineEditor::Start(TDesC16 const &, TDesC16 const &)
+	Start__12TConsoleLineRC7TDesC16 @ 25 NONAME R3UNUSED ; TConsoleLine::Start(TDesC16 const &)
+	Start__12TConsoleLineRC7TDesC16T1 @ 26 NONAME R3UNUSED ; TConsoleLine::Start(TDesC16 const &, TDesC16 const &)
+	"_._11CLineEditor" @ 27 NONAME R3UNUSED ; CLineEditor::~CLineEditor(void)
+	__12TConsoleLineR8RConsole @ 28 NONAME R3UNUSED ; TConsoleLine::TConsoleLine(RConsole &)
+	__19TConsoleBaseAdaptorR12CConsoleBase @ 29 NONAME R3UNUSED ; TConsoleBaseAdaptor::TConsoleBaseAdaptor(CConsoleBase &)
+	ContentsToCursor__C12TConsoleLine @ 30 NONAME R3UNUSED ; TConsoleLine::ContentsToCursor(void) const
+	Redraw__11CLineEditor @ 31 NONAME R3UNUSED ; CLineEditor::Redraw(void)
+	Abort__11CLineEditor @ 32 NONAME R3UNUSED ; CLineEditor::Abort(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/bwins/lineeditoru.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+EXPORTS
+	??1CLineEditor@@UAE@XZ @ 1 NONAME ; CLineEditor::~CLineEditor(void)
+	?HandleKey@CLineEditor@@QAEXII@Z @ 2 NONAME ; void CLineEditor::HandleKey(unsigned int, unsigned int)
+	?NewL@CLineEditor@@SAPAV1@AAVRFs@@AAVMAbstractConsoleWriter@@AAVMLineEditorObserver@@AAVMLineCompleter@@@Z @ 3 NONAME ABSENT; class CLineEditor * CLineEditor::NewL(class RFs &, class MAbstractConsoleWriter &, class MLineEditorObserver &, class MLineCompleter &)
+	?Start@CLineEditor@@QAEXABVTDesC16@@@Z @ 4 NONAME ; void CLineEditor::Start(class TDesC16 const &)
+	??0TConsoleLine@@QAE@AAVRConsole@@@Z @ 5 NONAME ; TConsoleLine::TConsoleLine(class RConsole &)
+	?Contents@TConsoleLine@@QBE?AVTPtrC16@@XZ @ 6 NONAME ; class TPtrC16 TConsoleLine::Contents(void) const
+	?ContentsToCursor@TConsoleLine@@QBE?AVTPtrC16@@XZ @ 7 NONAME ; class TPtrC16 TConsoleLine::ContentsToCursor(void) const
+	?CursorBeginning@TConsoleLine@@QAEXXZ @ 8 NONAME ; void TConsoleLine::CursorBeginning(void)
+	?CursorEnd@TConsoleLine@@QAEXXZ @ 9 NONAME ; void TConsoleLine::CursorEnd(void)
+	?CursorLeft@TConsoleLine@@QAEXXZ @ 10 NONAME ; void TConsoleLine::CursorLeft(void)
+	?CursorNextWord@TConsoleLine@@QAEXXZ @ 11 NONAME ; void TConsoleLine::CursorNextWord(void)
+	?CursorPreviousWord@TConsoleLine@@QAEXXZ @ 12 NONAME ; void TConsoleLine::CursorPreviousWord(void)
+	?CursorRight@TConsoleLine@@QAEXXZ @ 13 NONAME ; void TConsoleLine::CursorRight(void)
+	?DeleteLeft@TConsoleLine@@QAEXXZ @ 14 NONAME ; void TConsoleLine::DeleteLeft(void)
+	?DeleteRight@TConsoleLine@@QAEXXZ @ 15 NONAME ; void TConsoleLine::DeleteRight(void)
+	?End@TConsoleLine@@QAEXXZ @ 16 NONAME ; void TConsoleLine::End(void)
+	?Insert@TConsoleLine@@QAEXVTChar@@@Z @ 17 NONAME ; void TConsoleLine::Insert(class TChar)
+	?Overwrite@TConsoleLine@@QAEXVTChar@@@Z @ 18 NONAME ; void TConsoleLine::Overwrite(class TChar)
+	?PrintCompletionPossibilitiesL@TConsoleLine@@QAEXABVTDesC16@@@Z @ 19 NONAME ; void TConsoleLine::PrintCompletionPossibilitiesL(class TDesC16 const &)
+	?Redraw@TConsoleLine@@QAEXXZ @ 20 NONAME ; void TConsoleLine::Redraw(void)
+	?Replace@TConsoleLine@@QAEXABVTDesC16@@@Z @ 21 NONAME ; void TConsoleLine::Replace(class TDesC16 const &)
+	?Replace@TConsoleLine@@QAEXHABVTDesC16@@@Z @ 22 NONAME ; void TConsoleLine::Replace(int, class TDesC16 const &)
+	?Start@TConsoleLine@@QAEXABVTDesC16@@@Z @ 23 NONAME ; void TConsoleLine::Start(class TDesC16 const &)
+	?NewL@CLineEditor@@SAPAV1@AAVRFs@@AAVMAbstractConsoleWriter@@AAVMLineEditorObserver@@AAVMLineCompleter@@ABVTDesC16@@@Z @ 24 NONAME ; class CLineEditor * CLineEditor::NewL(class RFs &, class MAbstractConsoleWriter &, class MLineEditorObserver &, class MLineCompleter &, class TDesC16 const &)
+	?ReinstatePromptAndUserInput@CLineEditor@@QAEXXZ @ 25 NONAME ; void CLineEditor::ReinstatePromptAndUserInput(void)
+	?RemovePromptAndUserInput@CLineEditor@@QAEXXZ @ 26 NONAME ; void CLineEditor::RemovePromptAndUserInput(void)
+	??0TIoConsWriterAdaptor@@QAE@AAVRIoConsoleWriteHandle@@@Z @ 27 NONAME ; TIoConsWriterAdaptor::TIoConsWriterAdaptor(class RIoConsoleWriteHandle &)
+	??0TConsoleBaseAdaptor@@QAE@AAVCConsoleBase@@@Z @ 28 NONAME ; TConsoleBaseAdaptor::TConsoleBaseAdaptor(class CConsoleBase &)
+	?Start@CLineEditor@@QAEXABVTDesC16@@0@Z @ 29 NONAME ; void CLineEditor::Start(class TDesC16 const &, class TDesC16 const &)
+	?Start@TConsoleLine@@QAEXABVTDesC16@@0@Z @ 30 NONAME ; void TConsoleLine::Start(class TDesC16 const &, class TDesC16 const &)
+	?Redraw@CLineEditor@@QAEXXZ @ 31 NONAME ; void CLineEditor::Redraw(void)
+	?Abort@CLineEditor@@QAEXXZ @ 32 NONAME ; void CLineEditor::Abort(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/eabi/lineeditoru.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,47 @@
+EXPORTS
+	_ZN11CLineEditor4NewLER3RFsR22MAbstractConsoleWriterR19MLineEditorObserverR14MLineCompleter @ 1 NONAME ABSENT
+	_ZN11CLineEditor5StartERK7TDesC16 @ 2 NONAME
+	_ZN11CLineEditor9HandleKeyEjj @ 3 NONAME
+	_ZN11CLineEditorD0Ev @ 4 NONAME
+	_ZN11CLineEditorD1Ev @ 5 NONAME
+	_ZN11CLineEditorD2Ev @ 6 NONAME
+	_ZTI11CLineEditor @ 7 NONAME ; #<TI>#
+	_ZTI12CLineHistory @ 8 NONAME ABSENT; #<TI>#
+	_ZTI12TConsoleLine @ 9 NONAME ; #<TI>#
+	_ZTV11CLineEditor @ 10 NONAME ; #<VT>#
+	_ZTV12CLineHistory @ 11 NONAME ABSENT; #<VT>#
+	_ZTV12TConsoleLine @ 12 NONAME ; #<VT>#
+	_ZN12TConsoleLine10CursorLeftEv @ 13 NONAME
+	_ZN12TConsoleLine10DeleteLeftEv @ 14 NONAME
+	_ZN12TConsoleLine11CursorRightEv @ 15 NONAME
+	_ZN12TConsoleLine11DeleteRightEv @ 16 NONAME
+	_ZN12TConsoleLine14CursorNextWordEv @ 17 NONAME
+	_ZN12TConsoleLine15CursorBeginningEv @ 18 NONAME
+	_ZN12TConsoleLine18CursorPreviousWordEv @ 19 NONAME
+	_ZN12TConsoleLine29PrintCompletionPossibilitiesLERK7TDesC16 @ 20 NONAME
+	_ZN12TConsoleLine3EndEv @ 21 NONAME
+	_ZN12TConsoleLine5StartERK7TDesC16 @ 22 NONAME
+	_ZN12TConsoleLine6InsertE5TChar @ 23 NONAME
+	_ZN12TConsoleLine6RedrawEv @ 24 NONAME
+	_ZN12TConsoleLine7ReplaceERK7TDesC16 @ 25 NONAME
+	_ZN12TConsoleLine7ReplaceEiRK7TDesC16 @ 26 NONAME
+	_ZN12TConsoleLine9CursorEndEv @ 27 NONAME
+	_ZN12TConsoleLine9OverwriteE5TChar @ 28 NONAME
+	_ZN12TConsoleLineC1ER8RConsole @ 29 NONAME
+	_ZN12TConsoleLineC2ER8RConsole @ 30 NONAME
+	_ZNK12TConsoleLine16ContentsToCursorEv @ 31 NONAME
+	_ZNK12TConsoleLine8ContentsEv @ 32 NONAME
+	_ZN11CLineEditor4NewLER3RFsR22MAbstractConsoleWriterR19MLineEditorObserverR14MLineCompleterRK7TDesC16 @ 33 NONAME
+	_ZN11CLineEditor24RemovePromptAndUserInputEv @ 34 NONAME
+	_ZN11CLineEditor27ReinstatePromptAndUserInputEv @ 35 NONAME
+	_ZN20TIoConsWriterAdaptorC1ER21RIoConsoleWriteHandle @ 36 NONAME
+	_ZN20TIoConsWriterAdaptorC2ER21RIoConsoleWriteHandle @ 37 NONAME
+	_ZTI20TIoConsWriterAdaptor @ 38 NONAME ; #<TI>#
+	_ZTV20TIoConsWriterAdaptor @ 39 NONAME ; #<VT>#
+	_ZN19TConsoleBaseAdaptorC1ER12CConsoleBase @ 40 NONAME
+	_ZN19TConsoleBaseAdaptorC2ER12CConsoleBase @ 41 NONAME
+	_ZN11CLineEditor5StartERK7TDesC16S2_ @ 42 NONAME
+	_ZN12TConsoleLine5StartERK7TDesC16S2_ @ 43 NONAME
+	_ZN11CLineEditor6RedrawEv @ 44 NONAME
+	_ZN11CLineEditor5AbortEv @ 45 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(lineeditor.iby)
+..\inc\line_editor.h			\epoc32\include\fshell\line_editor.h
+..\inc\line_editor_observer.h			\epoc32\include\fshell\line_editor_observer.h
+..\inc\abstract_console_writer.h	\epoc32\include\fshell\abstract_console_writer.h
+..\inc\iocons_writer.h			\epoc32\include\fshell\iocons_writer.h
+..\inc\cconsolebase_writer.h	\epoc32\include\fshell\cconsolebase_writer.h
+
+PRJ_MMPFILES
+.\lineeditor.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/group/lineeditor.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+// lineeditor.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef LINEEDITOR_IBY
+#define LINEEDITOR_IBY
+
+#include <fsh_config.iby>
+FSHELL_EXECUTABLE_FILE(lineeditor.dll)
+
+#endif //LINEEDITOR_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/group/lineeditor.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// lineeditor.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			lineeditor.dll
+targettype		DLL
+uid             0x1000008d FSHELL_UID_LINEEDITOR
+capability		FSHELL_CAP_MMP_MAX
+
+sourcepath		..\src
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			line_editor.cpp
+source			iocons_writer.cpp
+source			cconsolebase_writer.cpp
+
+library			euser.lib
+library			efsrv.lib
+library			iocli.lib
+
+deffile			lineeditor.def
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/inc/abstract_console_writer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// abstract_console_writer.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __ABSTRACT_CONSOLE_WRITER_H__
+#define __ABSTRACT_CONSOLE_WRITER_H__
+
+class MAbstractConsoleWriter
+	{
+public:
+	virtual TInt GetCursorPos(TPoint& aPos) const = 0;
+	virtual TInt SetCursorPosAbs(const TPoint& aPos) = 0;
+	virtual TInt SetCursorPosRel(const TPoint& aPos) = 0;
+	virtual TInt SetCursorHeight(TInt aPercentage) = 0;
+	virtual TInt SetTitle(const TDesC& aTitle) = 0;
+	virtual TInt ClearScreen() = 0;
+	virtual TInt ClearToEndOfLine() = 0;
+	virtual TInt GetScreenSize(TSize& aSize) const = 0;
+	virtual TInt Write(const TDesC& aDes) = 0;
+	};
+
+
+
+#endif //__ABSTRACT_CONSOLE_WRITER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/inc/cconsolebase_writer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// cconsolebase_writer.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __CCONSOLEBASE_WRITER_H__
+#define __CCONSOLEBASE_WRITER_H__
+
+#include <fshell/abstract_console_writer.h>
+class CConsoleBase;
+
+NONSHARABLE_CLASS(TConsoleBaseAdaptor) : public MAbstractConsoleWriter
+	{
+public:
+	IMPORT_C TConsoleBaseAdaptor(CConsoleBase& aConsole);
+
+	virtual TInt GetCursorPos(TPoint& aPos) const;
+	virtual TInt SetCursorPosAbs(const TPoint& aPos);
+	virtual TInt SetCursorPosRel(const TPoint& aPos);
+	virtual TInt SetCursorHeight(TInt aPercentage);
+	virtual TInt SetTitle(const TDesC& aTitle);
+	virtual TInt ClearScreen();
+	virtual TInt ClearToEndOfLine();
+	virtual TInt GetScreenSize(TSize& aSize) const;
+	virtual TInt Write(const TDesC& aDes);
+private:
+	CConsoleBase& iConsole;
+	};
+
+#endif //__CCONSOLEBASE_WRITER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/inc/iocons_writer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// iocons_writer.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __IOCONS_WRITER_H__
+#define __IOCONS_WRITER_H__
+
+#include <fshell/abstract_console_writer.h>
+class RIoConsoleWriteHandle;
+
+class TIoConsWriterAdaptor : public MAbstractConsoleWriter
+	{
+public:
+	IMPORT_C TIoConsWriterAdaptor(RIoConsoleWriteHandle& aWriteHandle);
+
+	virtual TInt GetCursorPos(TPoint& aPos) const;
+	virtual TInt SetCursorPosAbs(const TPoint& aPos);
+	virtual TInt SetCursorPosRel(const TPoint& aPos);
+	virtual TInt SetCursorHeight(TInt aPercentage);
+	virtual TInt SetTitle(const TDesC& aTitle);
+	virtual TInt ClearScreen();
+	virtual TInt ClearToEndOfLine();
+	virtual TInt GetScreenSize(TSize& aSize) const;
+	virtual TInt Write(const TDesC& aDes);
+private:
+	RIoConsoleWriteHandle& iWriteHandle;
+	};
+
+#endif //__IOCONS_WRITER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/inc/line_editor.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,203 @@
+// line_editor.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __LINE_EDITOR_H__
+#define __LINE_EDITOR_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32keys.h>
+#include <fshell/line_editor_observer.h>
+#include <fshell/abstract_console_writer.h>
+#include <fshell/ioutils.h>
+
+const TInt KMaxLineLength = 256;
+#define CTRL(x) ((x)-'a'+1)
+
+class CLineHistory;
+
+//
+// MConsoleScrollObserver.
+//
+
+class MConsoleScrollObserver
+	{
+public:
+	virtual void CsoHandleConsoleScrolled() = 0;
+	};
+	
+//
+// RConsole.
+//
+
+class RConsole
+	{
+public:
+	enum TCursorMode
+		{
+		EInsert,
+		EOverwrite
+		};
+public:
+	RConsole(MAbstractConsoleWriter& aStdout);
+	void Close();
+	void Start();
+	void Refresh();
+	void Write(const TDesC& aDes);
+	void SetCursorPosAbs(const TPoint& aPoint);
+	void SetCursorPosRel(const TPoint& aPoint);
+	void MoveCursorLeft();
+	void MoveCursorRight();
+	void NewLine();
+	void SetCursorMode(TCursorMode aMode);
+	void SetCursorVisible(TBool aVisible);
+	void ClearToEndOfLine();
+	void Clear();
+	TPoint PosFrom(const TPoint& aStartPos, TInt aLength) const;
+	TPoint CursorPos() const;
+	TInt AddObserver(MConsoleScrollObserver& aObserver);
+	void RemoveObserver(MConsoleScrollObserver& aObserver);
+	TSize Size() const;
+private:
+	void CursorLeft();
+	void CursorRight();
+	void LineFeed();
+	void CarriageReturn();
+	void NotifyScrollObservers();
+private:
+	TSize iSize;
+	MAbstractConsoleWriter& iStdout;
+	RPointerArray<MConsoleScrollObserver> iScrollObservers;
+	TPoint iCursorPos;
+	TCursorMode iCursorMode;
+	TBool iCursorVisible;
+	};
+
+
+//
+// TConsoleLine.
+//
+
+class TConsoleLine : public MConsoleScrollObserver
+	{
+public:
+	IMPORT_C TConsoleLine(RConsole& aConsole);
+	IMPORT_C void Start(const TDesC& aPrompt);
+	IMPORT_C void Start(const TDesC& aPrompt, const TDesC& aInitialInput);
+	IMPORT_C void Replace(const TDesC& aDes);
+	IMPORT_C void Replace(TInt aFrom, const TDesC& aDes);
+	IMPORT_C void Insert(TChar aChar);
+	IMPORT_C void Overwrite(TChar aChar);
+	IMPORT_C void Redraw();
+	IMPORT_C void End();
+	IMPORT_C void DeleteLeft();
+	IMPORT_C void DeleteRight();
+	IMPORT_C void CursorLeft();
+	IMPORT_C void CursorRight();
+	IMPORT_C void CursorPreviousWord();
+	IMPORT_C void CursorNextWord();
+	IMPORT_C void CursorBeginning();
+	IMPORT_C void CursorEnd();
+	IMPORT_C void PrintCompletionPossibilitiesL(const TDesC& aPossibilities);
+	IMPORT_C TPtrC Contents() const;
+	IMPORT_C TPtrC ContentsToCursor() const;
+public:
+	void Hide();
+	void Show();
+	void SetCursorPosition(TInt aPosition);
+	void Abort();
+private:
+	void Restart(const TDesC& aPrompt);
+private: // From MConsoleScrollObserver.
+	virtual void CsoHandleConsoleScrolled();
+private:
+	RConsole& iConsole;
+	TBuf<KMaxLineLength> iBuf;
+	TInt iPromptLength;
+	TInt iBufPos;
+	TPoint iStartPos;
+	TBool iStarted;
+	TBool iHidden;
+	};
+
+
+//
+// CLineEditor.
+//
+
+class CLineEditor : public CBase
+	{
+public:
+	IMPORT_C static CLineEditor* NewL(	RFs& aFs, 
+										MAbstractConsoleWriter& aStdout, 
+										MLineEditorObserver& aObserver, 
+										MLineCompleter& aCompleter,
+										const TDesC& aConsoleHistoryFile);
+	IMPORT_C ~CLineEditor();
+	IMPORT_C void HandleKey(TUint aKeyCode, TUint aModifiers);
+	IMPORT_C void Start(const TDesC& aPrompt);
+	IMPORT_C void Start(const TDesC& aPrompt, const TDesC& aInitialInput);
+	IMPORT_C void Abort();
+	
+	IMPORT_C void Redraw();
+	IMPORT_C void RemovePromptAndUserInput();
+	IMPORT_C void ReinstatePromptAndUserInput();
+private:
+	CLineEditor(MAbstractConsoleWriter& aStdout, MLineEditorObserver& aObserver, MLineCompleter& aCompleter);
+	void ConstructL(RFs& aFs, const TDesC& aConsoleHistoryFile);
+	void InsertChar(TChar aChar);
+	void HandleEnter();
+	void HandleBackspace();
+	void HandleTab();
+	void HandleTabL();
+	void HandleDelete();
+	void HandleLeftArrow();
+	void HandleRightArrow();
+	void HandleUpArrow();
+	void HandleDownArrow();
+	void HandlePreviousWord();
+	void HandleNextWord();
+	void HandleHome();
+	void HandleEnd();
+	void HandlePageUp();
+	void HandlePageDown();
+	void HandleInsert();
+	void HandleEscape();
+	void HandleF8Completion(); // DOS-style F8 line completion
+	void ReplaceLine(const TDesC& aNewLine);
+private:
+	enum TState
+		{
+		EIdle,
+		EEditing,
+		ERecallingHistory
+		};
+	enum TMode
+		{
+		EInsert,
+		EOverwrite
+		};
+private:
+	void SetState(TState aState);
+private:
+	MLineEditorObserver& iObserver;
+	MLineCompleter& iCompleter;
+	RConsole iConsole;
+	TConsoleLine iLine;
+	TBuf<KMaxLineLength> iLineBackup;
+	CLineHistory* iHistory;
+	TState iState;
+	TMode iMode;
+	};
+
+
+#endif // __LINE_EDITOR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/inc/line_editor_observer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// line_editor_observer.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __LINE_EDITOR_OBSERVER_H__
+#define __LINE_EDITOR_OBSERVER_H__
+
+#include <e32std.h>
+
+
+class CLineEditor;
+class TConsoleLine;
+
+
+//
+// MLineEditorObserver.
+//
+
+class MLineEditorObserver
+	{
+public:
+	virtual void LeoHandleLine(const TDesC& aLine) = 0;
+	};
+
+
+//
+// MLineCompleter.
+//
+
+class MLineCompleter
+	{
+public:
+	virtual void LcCompleteLineL(TConsoleLine& aLine, const TChar& aEscapeChar) = 0;
+	};
+
+
+#endif // __LINE_EDITOR_OBSERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/src/cconsolebase_writer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,76 @@
+// cconsolebase_writer.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include "cconsolebase_writer.h"
+#include <e32cons.h>
+
+//______________________________________________________________________________
+//						TConsoleBaseAdaptor
+EXPORT_C TConsoleBaseAdaptor::TConsoleBaseAdaptor(CConsoleBase& aConsole)
+	: iConsole(aConsole)
+	{
+	}
+
+TInt TConsoleBaseAdaptor::GetCursorPos(TPoint& aPos) const
+	{
+	aPos = iConsole.CursorPos();
+	return KErrNone;
+	}
+
+TInt TConsoleBaseAdaptor::SetCursorPosAbs(const TPoint& aPos)
+	{
+	iConsole.SetCursorPosAbs(aPos);
+	return KErrNone;
+	}
+
+TInt TConsoleBaseAdaptor::SetCursorPosRel(const TPoint& aPos)
+	{
+	iConsole.SetCursorPosRel(aPos);
+	return KErrNone;
+	}
+
+TInt TConsoleBaseAdaptor::SetCursorHeight(TInt aPercentage)
+	{
+	iConsole.SetCursorHeight(aPercentage);
+	return KErrNone;
+	}
+
+TInt TConsoleBaseAdaptor::SetTitle(const TDesC& aTitle)
+	{
+	iConsole.SetTitle(aTitle);
+	return KErrNone;
+	}
+
+TInt TConsoleBaseAdaptor::ClearScreen()
+	{
+	iConsole.ClearScreen();
+	return KErrNone;
+	}
+
+TInt TConsoleBaseAdaptor::ClearToEndOfLine()
+	{
+	iConsole.ClearToEndOfLine();
+	return KErrNone;
+	}
+
+TInt TConsoleBaseAdaptor::GetScreenSize(TSize& aSize) const
+	{
+	aSize = iConsole.ScreenSize();
+	return KErrNone;
+	}
+
+TInt TConsoleBaseAdaptor::Write(const TDesC& aDes)
+	{
+	iConsole.Write(aDes);
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/src/iocons_writer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,71 @@
+// iocons_writer.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include "iocons_writer.h"
+#include <fshell/iocli.h>
+
+//______________________________________________________________________________
+//						TIoConsWriterAdaptor
+EXPORT_C TIoConsWriterAdaptor::TIoConsWriterAdaptor(RIoConsoleWriteHandle& aWriteHandle)
+	: iWriteHandle(aWriteHandle)
+	{
+	}
+
+TInt TIoConsWriterAdaptor::GetCursorPos(TPoint& aPos) const
+	{
+	return iWriteHandle.GetCursorPos(aPos);
+	}
+
+
+TInt TIoConsWriterAdaptor::SetCursorPosAbs(const TPoint& aPos)
+	{
+	return iWriteHandle.SetCursorPosAbs(aPos);
+	}
+
+TInt TIoConsWriterAdaptor::SetCursorPosRel(const TPoint& aPos)
+	{
+	return iWriteHandle.SetCursorPosRel(aPos);
+	}
+
+TInt TIoConsWriterAdaptor::SetCursorHeight(TInt aPercentage)
+	{
+	return iWriteHandle.SetCursorHeight(aPercentage);
+	}
+
+TInt TIoConsWriterAdaptor::SetTitle(const TDesC& aTitle)
+	{
+	return iWriteHandle.SetTitle(aTitle);
+	}
+
+TInt TIoConsWriterAdaptor::ClearScreen()
+	{
+	return iWriteHandle.ClearScreen();
+	}
+
+TInt TIoConsWriterAdaptor::ClearToEndOfLine()
+	{
+	return iWriteHandle.ClearToEndOfLine();
+	}
+
+TInt TIoConsWriterAdaptor::GetScreenSize(TSize& aSize) const
+	{
+	return iWriteHandle.GetScreenSize(aSize);
+	}
+
+
+TInt TIoConsWriterAdaptor::Write(const TDesC& aDes)
+	{
+	return iWriteHandle.Write(aDes);
+	}
+
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/lineeditor/src/line_editor.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1341 @@
+// line_editor.cpp
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "line_editor.h"
+#include <f32file.h>
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+
+//
+// Constants.
+//
+
+_LIT(KSpace, " ");
+_LIT(KNewLine, "\r\n");
+_LIT(KBackspace, "\x08 \x08");
+
+
+//
+// RConsole.
+//
+
+RConsole::RConsole(MAbstractConsoleWriter& aStdout)
+	: iStdout(aStdout), iCursorPos(TPoint(0, 0)), iCursorMode(EInsert), iCursorVisible(EFalse)
+	{
+	iStdout.GetScreenSize(iSize);
+	SetCursorVisible(ETrue);
+	}
+
+void RConsole::Close()
+	{
+	iScrollObservers.Close();
+	}
+
+void RConsole::Start()
+	{
+	Refresh();
+	}
+	
+void RConsole::Refresh()
+	{
+	iStdout.GetScreenSize(iSize);
+	iStdout.GetCursorPos(iCursorPos);
+	}
+
+void RConsole::Write(const TDesC &aDes)
+	{
+	const TInt desLength = aDes.Length();
+	for (TInt i = 0; i < desLength; ++i)
+		{
+		switch(aDes[i])
+			{
+			case 0x00:	// Null.
+				break;
+			case 0x07:	// Bell.
+				break;
+			case 0x08:	// Backspace.
+			case 0x7f:	// Delete.
+				CursorLeft();
+				break;
+			case 0x09:	// Tab.
+			case 0x0b:	// Vertical tab.
+			case 0x0c:  // Form feed.
+				// These should already have been swallowed by CLineEditor::HandleKey.
+				ASSERT(FALSE);
+				break;
+			case 0x0a:
+				LineFeed();
+				break;
+			case 0x0d:
+				CarriageReturn();
+				break;
+			default:
+				CursorRight();
+			}
+		}
+	iStdout.Write(aDes);
+	}
+
+void RConsole::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	iCursorPos = aPoint;
+	iStdout.SetCursorPosAbs(aPoint);
+	}
+
+void RConsole::SetCursorPosRel(const TPoint& aPoint)
+	{
+	iCursorPos += aPoint;
+	iStdout.SetCursorPosRel(aPoint);
+	}
+
+void RConsole::MoveCursorLeft()
+	{
+	CursorLeft();
+	iStdout.SetCursorPosAbs(iCursorPos);
+	}
+
+void RConsole::MoveCursorRight()
+	{
+	CursorRight();
+	iStdout.SetCursorPosAbs(iCursorPos);
+	}
+
+void RConsole::SetCursorMode(TCursorMode aMode)
+	{
+	iCursorMode = aMode;
+	SetCursorVisible(iCursorVisible);
+	}
+
+void RConsole::SetCursorVisible(TBool aVisible)
+	{
+	iCursorVisible = aVisible;
+	iStdout.SetCursorHeight(iCursorVisible ? (iCursorMode == EInsert ? 20 : 100) : 0);
+	}
+	
+void RConsole::ClearToEndOfLine()
+	{
+	iStdout.ClearToEndOfLine();
+	// no affect on cursor position
+	}
+
+void RConsole::Clear()
+	{
+	iStdout.ClearScreen();
+	iCursorPos.iX = iCursorPos.iY = 0;
+	}
+
+TPoint RConsole::PosFrom(const TPoint& aStartPos, TInt aLength) const
+	{
+	// if the width is 0 we'll enter an infinite loop below.
+	if (iSize.iWidth == 0) return TPoint(aStartPos.iX + aLength, aStartPos.iY);
+	
+	TPoint endPos(aStartPos);
+	if (aLength > 0)
+		{
+		while (aLength)
+			{
+			const TInt min = Min(iSize.iWidth - endPos.iX, aLength);
+			aLength -= min;
+			if ((endPos.iX + min) < iSize.iWidth)
+				{
+				endPos.iX += min;
+				}
+			else
+				{
+				ASSERT((endPos.iX + min) == iSize.iWidth);
+				endPos.iX = 0;
+				++endPos.iY;
+				}
+			}
+		}
+	else
+		{
+		aLength = -aLength;
+		while (aLength)
+			{
+			const TInt min = Min(endPos.iX, aLength);
+			if (min == 0)
+				{
+				endPos.iX = (iSize.iWidth - 1);
+				--endPos.iY;
+				--aLength;
+				}
+			else 
+				{
+				endPos.iX -= min;
+				aLength -= min;
+				}
+			}
+		}
+	return endPos;
+	}
+
+TPoint RConsole::CursorPos() const
+	{
+	return iCursorPos;
+	}
+
+TInt RConsole::AddObserver(MConsoleScrollObserver& aObserver)
+	{
+	return iScrollObservers.Append(&aObserver);
+	}
+
+void RConsole::RemoveObserver(MConsoleScrollObserver& aObserver)
+	{
+	const TInt numObservers = iScrollObservers.Count();
+	for (TInt i = 0; i < numObservers; ++i)
+		{
+		if (iScrollObservers[i] == &aObserver)
+			{
+			iScrollObservers.Remove(i);
+			return;
+			}
+		}
+	ASSERT(EFalse);
+	}
+
+TSize RConsole::Size() const
+	{
+	return iSize;
+	}
+
+void RConsole::CursorLeft()
+	{
+	if (iCursorPos.iX > 0)
+		{
+		// Not yet reached beginning of line.
+		--iCursorPos.iX;
+		}
+	else if (iCursorPos.iY > 0)
+		{
+		// Reached beginning of line, so jump to end of line above.
+		iCursorPos.iX = (iSize.iWidth - 1);
+		--iCursorPos.iY;
+		}
+	}
+
+void RConsole::CursorRight()
+	{
+	if (iCursorPos.iX < (iSize.iWidth - 1))
+		{
+		// Not yet reached the end of the line.
+		++iCursorPos.iX;
+		}
+	else if (iCursorPos.iY < (iSize.iHeight - 1))
+		{
+		// Reached the end of the line and there's space below - jump to the beginning of the line below.
+		iCursorPos.iX = 0;
+		++iCursorPos.iY;
+		}
+	else
+		{
+		// Reached the end of the line and there's no space below - console will scroll up a line and jump to the beginning of the newly exposed line.
+		iCursorPos.iX = 0;
+		NotifyScrollObservers();
+		}
+	}
+
+void RConsole::LineFeed()
+	{
+	if (iCursorPos.iY < (iSize.iHeight - 1))
+		{
+		iCursorPos.iX = 0;
+		++iCursorPos.iY;
+		}
+	else
+		{
+		iCursorPos.iX = 0;
+		NotifyScrollObservers();
+		}
+	}
+
+void RConsole::CarriageReturn()
+	{
+	iCursorPos.iX = 0;
+	}
+
+void RConsole::NewLine()
+	{
+	iStdout.Write(KNewLine);
+	iCursorPos.iX = 0;
+	if (iCursorPos.iY < (iSize.iHeight - 1))
+		{
+		++iCursorPos.iY;
+		}
+	else
+		{
+		iCursorPos.iX = 0;
+		NotifyScrollObservers();
+		}
+	}
+
+void RConsole::NotifyScrollObservers()
+	{
+	const TInt numObservers = iScrollObservers.Count();
+	for (TInt i = 0; i < numObservers; ++i)
+		{
+		iScrollObservers[i]->CsoHandleConsoleScrolled();
+		}
+	}
+
+
+//
+// TConsoleLine.
+//
+
+EXPORT_C TConsoleLine::TConsoleLine(RConsole& aConsole)
+	: iConsole(aConsole), iPromptLength(0), iBufPos(0), iStartPos(aConsole.CursorPos()), iHidden(ETrue)
+	{
+	}
+
+EXPORT_C void TConsoleLine::Start(const TDesC& aPrompt)
+	{
+	Start(aPrompt, KNullDesC);
+	}
+
+EXPORT_C void TConsoleLine::Start(const TDesC& aPrompt, const TDesC& aInitialInput)
+	{
+	if (iStarted)
+		{
+		Restart(aPrompt);
+		return;
+		}
+
+	iStarted = ETrue;
+	if (!iHidden)
+		{
+		iConsole.AddObserver(*this);
+		}
+	iConsole.Start();
+	iBuf = aPrompt;
+	iBuf.Append(aInitialInput);
+	iPromptLength = aPrompt.Length();
+	iBufPos = iBuf.Length();
+	if (!iHidden)
+		{
+		Redraw();
+		iConsole.SetCursorVisible(ETrue);
+		}
+	}
+
+void TConsoleLine::Abort()
+	{
+	iStarted = EFalse;
+	iConsole.RemoveObserver(*this);
+	}
+
+void TConsoleLine::Restart(const TDesC& aPrompt)
+	{
+	// a) Hide the cursor.
+	// b) Move the cursor to the start of the line.
+	// c) Create a buffer that will fully overwrite the old line.
+	// d) Write the buffer to the console.
+	// e) Set the cursor to the end of the new prompt.
+	// f) Make the cursor visible again.
+	iConsole.SetCursorVisible(EFalse);
+	iConsole.SetCursorPosAbs(iStartPos);
+	const TInt origBufLength = iBuf.Length();
+	iBuf = aPrompt;
+	if (iBuf.Length() < origBufLength)
+		{
+		iBuf.AppendFill(' ', origBufLength - iBuf.Length());
+		}
+	iConsole.Write(iBuf);
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, aPrompt.Length()));
+	iBuf.SetLength(aPrompt.Length());
+	iBufPos = aPrompt.Length();
+	iConsole.SetCursorVisible(ETrue);
+	}
+
+EXPORT_C void TConsoleLine::Insert(TChar aChar)
+	{
+	TPtrC charDes((TUint16*)&aChar, 1);
+	const TInt availableSpace = iBuf.MaxLength() - iBuf.Length();
+	if (iBufPos < iBuf.Length())
+		{
+		if (availableSpace < 1)
+			{
+			iBuf.Delete(iBuf.Length() - 1, 1);
+			}
+		iBuf.Insert(iBufPos, charDes);
+		iConsole.SetCursorVisible(EFalse);
+		iConsole.Write(iBuf.Mid(iBufPos));
+		iConsole.SetCursorPosAbs(iConsole.PosFrom(iConsole.CursorPos(), iBufPos - iBuf.Length() + 1));
+		iConsole.SetCursorVisible(ETrue);
+		iBufPos++;
+		}
+	else
+		{
+		ASSERT(iBufPos == iBuf.Length());
+		if (availableSpace > 0)
+			{
+			++iBufPos;
+			iBuf.Append(charDes);
+			iConsole.Write(charDes);
+			}
+		}
+	}
+
+EXPORT_C void TConsoleLine::Overwrite(TChar aChar)
+	{
+	if (iBufPos < iBuf.MaxLength())
+		{
+		TPtrC charDes((TUint16*)&aChar, 1);
+		if (iBufPos < iBuf.Length())
+			{
+			iBuf.Replace(iBufPos++, 1, charDes);
+			}
+		else
+			{
+			ASSERT(iBufPos == iBuf.Length());
+			iBuf.Append(charDes);
+			++iBufPos;
+			}
+		iConsole.Write(charDes);
+		}
+	}
+
+EXPORT_C void TConsoleLine::Replace(const TDesC& aDes)
+	{
+	// a) Hide the cursor.
+	// b) Move the cursor to the start of the line (after the prompt).
+	// c) Create a buffer that will fully overwrite the old line.
+	// d) Write the buffer to the console.
+	// e) Set the cursor to the end of the new line contents.
+	// f) Make the cursor visible again.
+	iConsole.SetCursorVisible(EFalse);
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iPromptLength));
+	const TInt origBufLength = iBuf.Length() - iPromptLength;
+	iBuf.Delete(iPromptLength, origBufLength);
+	iBuf.Append(aDes);
+	if (aDes.Length() < origBufLength)
+		{
+		iBuf.AppendFill(' ', origBufLength - aDes.Length());
+		}
+	iConsole.Write(iBuf.Mid(iPromptLength));
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iPromptLength + aDes.Length()));
+	iBuf.SetLength(iPromptLength + aDes.Length());
+	iBufPos = iPromptLength + aDes.Length();
+	iConsole.SetCursorVisible(ETrue);
+	}
+
+EXPORT_C void TConsoleLine::Replace(TInt aFrom, const TDesC& aDes)
+	{
+	// a) Hide the cursor.
+	// b) Move the cursor to aFrom.
+	// c) Overwrite chars up to iBufPos.
+	// d) Insert remaining chars (if any).
+	// e) Make the cursor visible again.
+	aFrom += iPromptLength;
+	ASSERT(iBufPos >= aFrom);
+	iConsole.SetCursorVisible(EFalse);
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, aFrom));
+	const TInt desLength = aDes.Length();
+	const TInt numOverwriteChars = iBufPos - aFrom;
+	TInt lengthAdjust = 0;
+	if (numOverwriteChars > 0)
+		{
+		iBuf.Replace(aFrom, numOverwriteChars, aDes.Left(numOverwriteChars));
+		if (desLength < numOverwriteChars)
+			{
+			lengthAdjust = numOverwriteChars - desLength;
+			iBuf.AppendFill(' ', lengthAdjust);
+			iBufPos -= lengthAdjust;
+			}
+		}
+	const TInt numInsertChars = desLength - numOverwriteChars;
+	if (numInsertChars > 0)
+		{
+		iBuf.Insert(iBufPos, aDes.Mid(numOverwriteChars));
+		iBufPos += numInsertChars;
+		}
+	iConsole.Write(iBuf.Mid(aFrom));
+	iBuf.SetLength(iBuf.Length() - lengthAdjust);
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, aFrom + aDes.Length()));
+	iConsole.SetCursorVisible(ETrue);
+	}
+
+EXPORT_C void TConsoleLine::Redraw()
+	{
+	if (!iStarted) return;
+	iConsole.Refresh();
+	iStartPos = iConsole.CursorPos();
+	if (iStartPos.iX > 0)
+		{
+		iConsole.NewLine();
+		iStartPos = iConsole.CursorPos();
+		}
+	iConsole.Write(iBuf);
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iBufPos));
+	}
+
+EXPORT_C void TConsoleLine::End()
+	{
+	iStarted = EFalse;
+	if (!iHidden)
+		{
+		iConsole.RemoveObserver(*this);
+		if (iBufPos < iBuf.Length())
+			{
+			iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iBuf.Length()));
+			}
+		iConsole.NewLine();
+		}
+	}
+
+EXPORT_C void TConsoleLine::DeleteLeft()
+	{
+	if (iBufPos > iPromptLength)
+		{
+		iBuf.Delete(--iBufPos, 1);
+		iConsole.SetCursorVisible(EFalse);
+		if (iBufPos == iBuf.Length())
+			{
+			iConsole.Write(KBackspace);
+			}
+		else
+			{
+			iBuf.Append(KSpace);
+			iConsole.MoveCursorLeft();
+			TPoint cursorPos(iConsole.CursorPos());
+			iConsole.Write(iBuf.Mid(iBufPos));
+			iBuf.SetLength(iBuf.Length() - 1);
+			iConsole.SetCursorPosAbs(cursorPos);
+			}
+		iConsole.SetCursorVisible(ETrue);
+		}
+	}
+
+EXPORT_C void TConsoleLine::DeleteRight()
+	{
+	if (iBufPos < iBuf.Length())
+		{
+		iBuf.Delete(iBufPos, 1);
+		iConsole.SetCursorVisible(EFalse);
+		TPoint cursorPos(iConsole.CursorPos());
+		iBuf.Append(KSpace);
+		iConsole.Write(iBuf.Mid(iBufPos));
+		iBuf.SetLength(iBuf.Length() - 1);
+		iConsole.SetCursorPosAbs(cursorPos);
+		iConsole.SetCursorVisible(ETrue);
+		}
+	}
+
+EXPORT_C void TConsoleLine::CursorLeft()
+	{
+	if (iBufPos > iPromptLength)
+		{
+		--iBufPos;
+		iConsole.MoveCursorLeft();
+		}
+	}
+
+EXPORT_C void TConsoleLine::CursorRight()
+	{
+	if (iBufPos < iBuf.Length())
+		{
+		++iBufPos;
+		iConsole.MoveCursorRight();
+		}
+	}
+
+EXPORT_C void TConsoleLine::CursorPreviousWord()
+	{
+	TLex lex(iBuf);
+	lex.Inc(iBufPos - 1);
+	while ((lex.Offset() > iPromptLength) && lex.Peek().IsSpace())
+		{
+		lex.UnGet();
+		}
+	while ((lex.Offset() > iPromptLength) && !lex.Peek().IsSpace())
+		{
+		lex.UnGet();
+		}
+	lex.SkipSpace();
+	iBufPos = Max(iPromptLength, lex.Offset());
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iBufPos));
+	}
+
+EXPORT_C void TConsoleLine::CursorNextWord()
+	{
+	TLex lex(iBuf);
+	lex.Inc(iBufPos);
+	lex.SkipSpace();
+	lex.SkipCharacters();
+	iBufPos = lex.Offset();
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iBufPos));
+	}
+
+EXPORT_C void TConsoleLine::CursorBeginning()
+	{
+	iBufPos = iPromptLength;
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iPromptLength));
+	}
+
+EXPORT_C void TConsoleLine::CursorEnd()
+	{
+	iBufPos = iBuf.Length();
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iBuf.Length()));
+	}
+
+EXPORT_C void TConsoleLine::PrintCompletionPossibilitiesL(const TDesC& aPossibilities)
+	{
+	if (iBufPos < iBuf.Length())
+		{
+		iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iBuf.Length()));
+		}
+	iConsole.NewLine();
+	CTextFormatter* formatter = CTextFormatter::NewLC(iConsole.Size().iWidth);
+	formatter->ColumnizeL(0, 2, aPossibilities);
+	iConsole.Write(formatter->Descriptor());
+	CleanupStack::PopAndDestroy(formatter);
+	iStartPos = iConsole.CursorPos();
+	iConsole.Write(iBuf);
+	iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, iBufPos));
+	}
+
+EXPORT_C TPtrC TConsoleLine::Contents() const
+	{
+	return iBuf.Mid(iPromptLength);
+	}
+
+EXPORT_C TPtrC TConsoleLine::ContentsToCursor() const
+	{
+	return iBuf.Mid(iPromptLength, iBufPos - iPromptLength);
+	}
+
+void TConsoleLine::CsoHandleConsoleScrolled()
+	{
+	--iStartPos.iY;
+	}
+	
+void TConsoleLine::Hide()
+	{
+	if (iHidden) return;
+	iHidden = ETrue;
+	if (!iStarted) return;
+	iConsole.RemoveObserver(*this);
+	iConsole.SetCursorPosAbs(TPoint(0, iConsole.CursorPos().iY));
+	iConsole.ClearToEndOfLine();
+	iConsole.SetCursorVisible(EFalse);
+	}
+	
+void TConsoleLine::Show()
+	{
+	if (!iHidden) return;
+	iHidden = EFalse;
+	if (!iStarted) return;
+
+	iConsole.AddObserver(*this);
+	iConsole.Start();
+	Redraw();
+	iConsole.SetCursorVisible(ETrue);
+	}
+
+void TConsoleLine::SetCursorPosition(TInt aPosition)
+	{
+	TInt newPos = iPromptLength + aPosition;
+	if (newPos < iBuf.Length())
+		{
+		iBufPos = newPos;
+		iConsole.SetCursorPosAbs(iConsole.PosFrom(iStartPos, newPos));
+		}
+	}
+
+//
+// CLineHistory.
+//
+
+NONSHARABLE_CLASS(CLineHistory) : public CBase
+	{
+public:
+	enum TRecallType
+		{
+		ENext,
+		EPrevious,
+		EFirst,
+		ELast
+		};
+public:
+	static CLineHistory* NewL(RFs& aFs, TInt aMaximumSize, const TDesC& aFileName);
+	~CLineHistory();
+	void AddL(const TDesC& aLine, TInt aPos=0);
+	const TDesC& Recall(TRecallType aType);
+	const TDesC& RecallMatch(const TDesC& aMatch); // Always searches backwards
+	void Reset();
+private:
+	CLineHistory(RFs& aFs, TInt aMaximumSize, const TDesC& aFileName);
+	void ConstructL();
+	void RestoreL();
+	void StoreL();
+	TInt Find(const TDesC& aLine);
+	void ResetBackgroundWriter();
+	static TInt BackgroundWriterCallback(TAny* aSelf);
+	void DoBackgroundWriterCallback();
+private:
+	RFs& iFs;
+	const TInt iMaximumSize;
+	TFileName iFileName;
+	TInt iIndex;
+	RPointerArray<HBufC> iHistory;
+	CPeriodic* iBackgroundWriter;
+	TTime iLastChangedTime;
+	TTime iLastSyncedTime;
+	};
+
+CLineHistory* CLineHistory::NewL(RFs& aFs, TInt aMaximumSize, const TDesC& aFileName)
+	{
+	CLineHistory* self = new(ELeave) CLineHistory(aFs, aMaximumSize, aFileName);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CLineHistory::~CLineHistory()
+	{
+#ifdef EKA2
+	TRAP_IGNORE(StoreL());
+#else
+	TRAPD(err, StoreL());
+#endif
+	iHistory.ResetAndDestroy();
+	delete iBackgroundWriter;
+	}
+
+void CLineHistory::AddL(const TDesC& aLine, TInt aPos)
+	{
+	if (aLine.Length() > 0)
+		{
+		TInt index = Find(aLine);
+		if (index == 0)
+			{
+			// Already present and at begining - nothing to do.
+			}
+		else if (index > 0)
+			{
+			// Already present - move to beginning.
+			HBufC* line = iHistory[index];
+			iHistory.Remove(index);
+			iHistory.Insert(line, aPos); // Should not fail due to the above deletion.
+			iLastChangedTime.UniversalTime();
+			}
+		else 
+			{
+			if (iHistory.Count() == iMaximumSize)
+				{
+				// History at maximum size - throw away the oldest entry.
+				delete iHistory[iMaximumSize - 1];
+				iHistory.Remove(iMaximumSize - 1);
+				}
+			HBufC* line = aLine.AllocLC();
+			User::LeaveIfError(iHistory.Insert(line, aPos));
+			CleanupStack::Pop(line);
+			iLastChangedTime.UniversalTime();
+			}
+		}
+	iIndex = -1;
+	ResetBackgroundWriter();
+	}
+
+const TDesC& CLineHistory::Recall(TRecallType aType)
+	{
+	switch (aType)
+		{
+		case ENext:
+			{
+			if (iIndex >= 0)
+				{
+				--iIndex;
+				}
+			break;
+			}
+		case EPrevious:
+			{
+			if (iIndex < (iHistory.Count() - 1))
+				{
+				++iIndex;
+				}
+			break;
+			}
+		case EFirst:
+			{
+			iIndex = 0;
+			break;
+			}
+		case ELast:
+			{
+			iIndex = (iHistory.Count() - 1);
+			break;
+			}
+		default:
+			{
+			ASSERT(EFalse);
+			break;
+			}
+		}
+
+	if ((iIndex >= 0) && (iIndex < iHistory.Count()))
+		{
+		return *iHistory[iIndex];
+		}
+	else
+		{
+		return KNullDesC();
+		}
+	}
+
+CLineHistory::CLineHistory(RFs& aFs, TInt aMaximumSize, const TDesC& aFileName)
+	: iFs(aFs), iMaximumSize(aMaximumSize), iFileName(aFileName), iIndex(-1)
+	{
+	}
+
+void CLineHistory::ConstructL()
+	{
+	if (CActiveScheduler::Current())
+		{
+		// Line editor may be run without a scheduler, in which case we can't try using an AO.
+		iBackgroundWriter = CPeriodic::NewL(CActive::EPriorityStandard);
+		}
+
+	TRAPD(err, RestoreL());
+	if (err)
+		{
+		iHistory.ResetAndDestroy();
+		iFs.Delete(iFileName);
+		}
+	}
+
+void CLineHistory::RestoreL()
+	{
+	if (iFileName.Length() == 0) return;
+
+	RFile file;
+	TInt err = file.Open(iFs, iFileName, EFileRead);
+	if (err == KErrNone)
+		{
+		CleanupClosePushL(file);
+		TInt32 int32;
+		TPckg<TInt32> intPckg(int32);
+		User::LeaveIfError(file.Read(intPckg));
+		const TInt historyCount = Min(int32, iMaximumSize);
+		for (TInt i = 0; i < historyCount; ++i)
+			{
+			User::LeaveIfError(file.Read(intPckg));
+			iFs.Delete(KNullDesC);
+			HBufC* line = HBufC::NewLC(int32);
+			TPtr linePtr(line->Des());
+			TInt size = int32 * 2;
+			TPtr8 linePtr8((TUint8*)linePtr.Ptr(), 0, size);
+			User::LeaveIfError(file.Read(linePtr8, size));
+			linePtr.SetLength(int32);
+			User::LeaveIfError(iHistory.Append(line));
+			CleanupStack::Pop(line);
+			}
+		iLastSyncedTime.UniversalTime();
+		CleanupStack::PopAndDestroy(&file);
+		}
+	else if ((err == KErrNotFound) || (err == KErrPathNotFound))
+		{
+		// Ignore error - leave history empty.
+		}
+	else
+		{
+		User::Leave(err);
+		}
+	}
+
+void CLineHistory::StoreL()
+	{
+	if (iFileName.Length() == 0) return; // User clearly doesn't want to be persisted
+
+	TTime modified;
+	TInt err = iFs.Modified(iFileName, modified);
+	if (err == KErrNone && modified > iLastSyncedTime)
+		{
+		// Someone else has updated our history under our feet - have a stab at merging them
+		// For the moment we'll follow the algorithm of:
+		// * In newest-first order, insert anything in the history file that isn't in ours (maintaining the newest-first order)
+		// * Stop if we get to half the max history size, otherwise we'll risk reinserting stuff that we've just evicted, or something. Not quite sure that's totally correct but sounds fairly sensible.
+		CLineHistory* newerHistory = CLineHistory::NewL(iFs, iMaximumSize, iFileName);
+		newerHistory->iFileName.Zero(); // So newerHistory doesn't try and overwrite our history when we delete it
+		CleanupStack::PushL(newerHistory);
+		iLastSyncedTime.UniversalTime(); // Otherwise the AddLs below will go recursive...
+		const TInt historyCount = newerHistory->iHistory.Count();
+		TInt insertionPoint = 0;
+		for (TInt i = 0; i < historyCount; i++)
+			{
+			HBufC* line = newerHistory->iHistory[i];
+			TInt index = Find(*line);
+			if (index == KErrNotFound)
+				{
+				AddL(*line, insertionPoint);
+				insertionPoint++;
+				}
+			if (i >= iMaximumSize/2) break;
+			}
+		CleanupStack::PopAndDestroy(newerHistory);
+		}
+
+	iFs.MkDirAll(iFileName);
+	RFile file;
+	User::LeaveIfError(file.Replace(iFs, iFileName, EFileWrite));
+	CleanupClosePushL(file);
+	const TInt32 historyCount = iHistory.Count();
+	TPckgC<TInt32> countPckg(historyCount);
+	User::LeaveIfError(file.Write(countPckg));
+	for (TInt i = 0; i < historyCount; ++i)
+		{
+		const HBufC* line = iHistory[i];
+		const TInt32 length = line->Length();
+		TPckgC<TInt32> lengthPckg(length);
+		User::LeaveIfError(file.Write(lengthPckg));
+		TPtrC8 linePtr8((const TUint8*)line->Ptr(), length * 2);
+		User::LeaveIfError(file.Write(linePtr8));
+		}
+	CleanupStack::PopAndDestroy(&file);
+	iLastSyncedTime.UniversalTime();
+	}
+
+TInt CLineHistory::Find(const TDesC& aLine)
+	{
+	const TInt historyCount = iHistory.Count();
+	for (TInt i = 0; i < historyCount; ++i)
+		{
+		if (aLine == *iHistory[i])
+			{
+			return i;
+			}
+		}
+	return KErrNotFound;
+	}
+
+void CLineHistory::Reset()
+	{
+	iIndex = -1;
+	}
+
+const TDesC& CLineHistory::RecallMatch(const TDesC& aMatch)
+	{
+	const TInt historyCount = iHistory.Count();
+	TInt oldIndex = iIndex;
+	for (iIndex = iIndex+1; iIndex < historyCount; iIndex++)
+		{
+		const TDesC& line = *iHistory[iIndex];
+		if (line.Left(aMatch.Length()).CompareF(aMatch) == 0)
+			{
+			return line;
+			}
+		}
+	// If nothing found, restore iIndex to what it was
+	iIndex = oldIndex;
+	return KNullDesC;
+	}
+
+const static TInt KWriterPeriod = 10*1000*1000; // 10 seconds
+
+void CLineHistory::ResetBackgroundWriter()
+	{
+	if (iLastChangedTime.Int64() > iLastSyncedTime.Int64() + KWriterPeriod)
+		{
+		// For whatever reason (probably that the scheduler doesn't exist or isn't running) it's been ages since we last persisted the history
+		// but the background writer hasn't kicked in - so do it now
+		DoBackgroundWriterCallback();
+		}
+	else if (iBackgroundWriter)
+		{
+		iBackgroundWriter->Cancel();
+		iBackgroundWriter->Start(KWriterPeriod, KWriterPeriod, TCallBack(&BackgroundWriterCallback, this));
+		}
+	}
+
+TInt CLineHistory::BackgroundWriterCallback(TAny* aSelf)
+	{
+	static_cast<CLineHistory*>(aSelf)->DoBackgroundWriterCallback();
+	return KErrNone;
+	}
+
+void CLineHistory::DoBackgroundWriterCallback()
+	{
+	if (iBackgroundWriter) iBackgroundWriter->Cancel(); // No point the periodic going off repeatedly if nothing has actually changed. We'll restart it in ResetBackgroundWriter if the history actually changes
+
+	if (iLastChangedTime.Int64() > iLastSyncedTime.Int64())
+		{
+		TRAP_IGNORE(StoreL());
+		}
+	}
+
+//
+// CLineEditor.
+//
+	
+EXPORT_C CLineEditor* CLineEditor::NewL(RFs& aFs, 
+										MAbstractConsoleWriter& aStdout, 
+										MLineEditorObserver& aObserver, 
+										MLineCompleter& aCompleter,
+										const TDesC& aConsoleHistoryFile)
+	{
+	CLineEditor* self = new(ELeave) CLineEditor(aStdout, aObserver, aCompleter);
+	CleanupStack::PushL(self);
+	self->ConstructL(aFs, aConsoleHistoryFile);
+	CleanupStack::Pop(self);
+	return self;	
+	}
+
+
+EXPORT_C CLineEditor::~CLineEditor()
+	{
+	delete iHistory;
+	iConsole.Close();
+	}
+
+CLineEditor::CLineEditor(MAbstractConsoleWriter& aStdout, MLineEditorObserver& aObserver, MLineCompleter& aCompleter)
+	: iObserver(aObserver), iCompleter(aCompleter), iConsole(aStdout), iLine(iConsole)
+	{
+	}
+
+void CLineEditor::ConstructL(RFs& aFs, const TDesC& aConsoleHistoryFile)
+	{
+	iHistory = CLineHistory::NewL(aFs, 50, aConsoleHistoryFile);
+	}
+
+EXPORT_C void CLineEditor::HandleKey(TUint aKeyCode, TUint aModifiers)
+	{
+	iLine.Show();
+	TBool handled(EFalse);
+	if (aModifiers & EModifierFunc)
+		{
+		handled = ETrue;
+		switch (aKeyCode)
+			{
+			case 'b':
+			case EKeyLeftArrow:
+				{
+				HandlePreviousWord();
+				break;
+				}
+			case 'f':
+			case EKeyRightArrow:
+				{
+				HandleNextWord();
+				break;
+				}
+			default:
+				{
+				handled = EFalse;
+				}
+			}
+		}
+
+	if (!handled)
+		{
+		switch (aKeyCode)
+			{
+			case EKeyEnter:
+#ifdef FSHELL_PLATFORM_S60
+			case EKeyDevice3: // confirm key
+#endif
+				{
+				HandleEnter();
+				break;
+				}
+			case EKeyBackspace:
+				{
+				HandleBackspace();
+				break;
+				}
+			case EKeyTab:
+				{
+				HandleTab();
+				break;
+				};
+			case CTRL('d'):
+			case EKeyDelete:
+				{
+				HandleDelete();
+				break;
+				}
+			case CTRL('b'):
+			case EKeyLeftArrow:
+				{
+				HandleLeftArrow();
+				break;
+				}
+			case CTRL('f'):
+			case EKeyRightArrow:
+				{
+				HandleRightArrow();
+				break;
+				}
+			case CTRL('p'):
+			case EKeyUpArrow:
+				{
+				HandleUpArrow();
+				break;
+				}
+			case CTRL('n'):
+			case EKeyDownArrow:
+				{
+				HandleDownArrow();
+				break;
+				}
+			case CTRL('a'):
+			case EKeyHome:
+				{
+				HandleHome();
+				break;
+				}
+			case CTRL('e'):
+			case EKeyEnd:
+				{
+				HandleEnd();
+				break;
+				}
+			case EKeyPageUp:
+				{
+				HandlePageUp();
+				break;
+				}
+			case EKeyPageDown:
+				{
+				HandlePageDown();
+				break;
+				}
+			case EKeyInsert:
+				{
+				HandleInsert();
+				break;
+				}
+			case EKeyEscape:
+				{
+				HandleEscape();
+				break;
+				}
+			case EKeyF4:
+			case EKeyF8:
+				{
+				HandleF8Completion();
+				break;
+				}
+			default:
+				{
+				if ((aKeyCode >= EKeySpace) && (aKeyCode < ENonCharacterKeyBase)) 
+					{
+					InsertChar(aKeyCode);
+					}
+				break;
+				}
+			}
+		}
+	}
+
+EXPORT_C void CLineEditor::Start(const TDesC& aPrompt)
+	{
+	iLine.Start(aPrompt, KNullDesC);
+	}
+
+EXPORT_C void CLineEditor::Start(const TDesC& aPrompt, const TDesC& aInitialInput)
+	{
+	iLine.Start(aPrompt, aInitialInput);
+	}
+
+EXPORT_C void CLineEditor::Abort()
+	{
+	iLine.Abort();
+	}
+	
+EXPORT_C void CLineEditor::Redraw()
+	{
+	iLine.Redraw();
+	}
+	
+EXPORT_C void CLineEditor::RemovePromptAndUserInput()
+	{
+	iLine.Hide();
+	}
+	
+EXPORT_C void CLineEditor::ReinstatePromptAndUserInput()
+	{
+	iLine.Show();
+	}
+
+void CLineEditor::InsertChar(TChar aChar)
+	{
+	(iMode == EInsert) ? iLine.Insert(aChar) : iLine.Overwrite(aChar);
+	SetState(EEditing);
+	}
+
+void CLineEditor::HandleEnter()
+	{
+	if (iLine.Contents().Length() > 0)
+		{
+		iHistory->AddL(iLine.Contents());
+		}
+	iLine.End();
+	iObserver.LeoHandleLine(iLine.Contents());
+	SetState(EIdle);
+	}
+
+void CLineEditor::HandleBackspace()
+	{
+	SetState(EEditing);
+	iLine.DeleteLeft();
+	}
+
+void CLineEditor::HandleTab()
+	{
+	SetState(EEditing);
+#ifdef EKA2
+	TRAP_IGNORE(HandleTabL());
+#else
+	TRAPD(err, HandleTabL());
+#endif
+	}
+
+void CLineEditor::HandleTabL()
+	{
+	iCompleter.LcCompleteLineL(iLine, TChar('/'));
+	}
+
+void CLineEditor::HandleDelete()
+	{
+	SetState(EEditing);
+	iLine.DeleteRight();
+	}
+
+void CLineEditor::HandleLeftArrow()
+	{
+	SetState(EEditing);
+	iLine.CursorLeft();
+	}
+
+void CLineEditor::HandleRightArrow()
+	{
+	SetState(EEditing);
+	iLine.CursorRight();
+	}
+
+void CLineEditor::HandleUpArrow()
+	{
+	ReplaceLine(iHistory->Recall(CLineHistory::EPrevious));
+	}
+
+void CLineEditor::HandleDownArrow()
+	{
+	ReplaceLine(iHistory->Recall(CLineHistory::ENext));
+	}
+
+void CLineEditor::HandlePreviousWord()
+	{
+	SetState(EEditing);
+	iLine.CursorPreviousWord();
+	}
+
+void CLineEditor::HandleNextWord()
+	{
+	SetState(EEditing);
+	iLine.CursorNextWord();
+	}
+
+void CLineEditor::HandleHome()
+	{
+	SetState(EEditing);
+	iLine.CursorBeginning();
+	}
+
+void CLineEditor::HandleEnd()
+	{
+	SetState(EEditing);
+	iLine.CursorEnd();
+	}
+
+void CLineEditor::HandlePageUp()
+	{
+	ReplaceLine(iHistory->Recall(CLineHistory::ELast));
+	}
+
+void CLineEditor::HandlePageDown()
+	{
+	ReplaceLine(iHistory->Recall(CLineHistory::EFirst));
+	}
+
+void CLineEditor::HandleInsert()
+	{
+	SetState(EEditing);
+	if (iMode == EInsert)
+		{
+		iMode = EOverwrite;
+		iConsole.SetCursorMode(RConsole::EOverwrite);
+		}
+	else
+		{
+		iMode = EInsert;
+		iConsole.SetCursorMode(RConsole::EInsert);
+		}
+	}
+	
+void CLineEditor::HandleEscape()
+	{
+	SetState(EEditing);
+	iLine.Replace(KNullDesC);	
+	}
+
+
+void CLineEditor::ReplaceLine(const TDesC& aNewLine)
+	{
+	TPtrC newLine(aNewLine);
+
+	if (iState == EEditing)
+		{
+		if (aNewLine.Length() == 0)
+			{
+			return;
+			}
+		iLineBackup = iLine.Contents();
+		SetState(ERecallingHistory);
+		}
+	else if ((iState == ERecallingHistory) && (aNewLine.Length() == 0))
+		{
+		SetState(EEditing);
+		newLine.Set(iLineBackup);
+		}
+	else
+		{
+		SetState(ERecallingHistory);
+		}
+
+	iLine.Replace(newLine);
+	}
+
+void CLineEditor::SetState(TState aState)
+	{
+	if ((aState == EEditing) && (iState != EEditing))
+		{
+		iHistory->Reset();
+		}
+	iState = aState;
+	}
+
+void CLineEditor::HandleF8Completion()
+	{
+	// Search the history backwards for a line matching everything currently entered
+	TPtrC toMatch = iLine.ContentsToCursor();
+	TPtrC history = iHistory->RecallMatch(toMatch);
+	if (history.Length())
+		{
+		ReplaceLine(history);
+		iLine.SetCursorPosition(toMatch.Length());
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/BMARM/ltkutils-tcb.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,170 @@
+EXPORTS
+	RawPrint__8LtkUtilsRC6TDesC8 @ 1 NONAME R3UNUSED ; LtkUtils::RawPrint(TDesC8 const &)
+	GetFriendlyThreadName___8LtkUtilsG7RThreadRt4TBuf1i256 @ 2 NONAME R3UNUSED ; LtkUtils::GetFriendlyThreadName_(RThread, TBuf<256> &)
+	GetPubSubData__8LtkUtilsRi @ 3 NONAME R3UNUSED ABSENT ; LtkUtils::GetPubSubData(int &)
+	HexDumpL__8LtkUtilsRC6TDesC8 @ 4 NONAME R3UNUSED ; LtkUtils::HexDumpL(TDesC8 const &)
+	HexDumpToOutput__8LtkUtilsRC6TDesC8R14RIoWriteHandleRi @ 5 NONAME R3UNUSED ; LtkUtils::HexDumpToOutput(TDesC8 const &, RIoWriteHandle &, int &)
+	HexDumpToOutput___8LtkUtilsRC6TDesC8R14RIoWriteHandle @ 6 NONAME R3UNUSED ; LtkUtils::HexDumpToOutput_(TDesC8 const &, RIoWriteHandle &)
+	HexDumpToRDebug__8LtkUtilsRC6TDesC8 @ 7 NONAME R3UNUSED ; LtkUtils::HexDumpToRDebug(TDesC8 const &)
+	HexDumpToRDebug___8LtkUtilsRC6TDesC8Ri @ 8 NONAME R3UNUSED ; LtkUtils::HexDumpToRDebug_(TDesC8 const &, int &)
+	InjectRawKeyEvent__8LtkUtilsiii @ 9 NONAME R3UNUSED ; LtkUtils::InjectRawKeyEvent(int, int, int)
+	MakeHeapCellInvisible__8LtkUtilsPv @ 10 NONAME R3UNUSED ; LtkUtils::MakeHeapCellInvisible(void *)
+	MakeProcessNameFriendly___8LtkUtilsR6TDes16 @ 11 NONAME R3UNUSED ; LtkUtils::MakeProcessNameFriendly_(TDes16 &)
+	MakeThreadNameFriendly___8LtkUtilsRt4TBuf1i256 @ 12 NONAME R3UNUSED ; LtkUtils::MakeThreadNameFriendly_(TBuf<256> &)
+	GetFriendlyProcessName___8LtkUtilsRC8RProcessR6TDes16 @ 13 NONAME R3UNUSED ; LtkUtils::GetFriendlyProcessName_(RProcess const &, TDes16 &)
+	HexLexL___8LtkUtilsR6TLex16 @ 14 NONAME R3UNUSED ; LtkUtils::HexLexL_(TLex16 &)
+	ReplaceText___8LtkUtilsR6TDes16RC7TDesC16T2 @ 15 NONAME R3UNUSED ; LtkUtils::ReplaceText_(TDes16 &, TDesC16 const &, TDesC16 const &)
+	__Q28LtkUtils13TErrorContextRC7TDesC16 @ 16 NONAME R3UNUSED ; LtkUtils::TErrorContext::TErrorContext(TDesC16 const &)
+	AddMapFileL__Q28LtkUtils10CSymbolicsRC7TDesC16 @ 17 NONAME R3UNUSED ABSENT ; LtkUtils::CSymbolics::AddMapFileL(TDesC16 const &)
+	AsBoolL__CQ28LtkUtils6CValue @ 18 NONAME R3UNUSED ; LtkUtils::CValue::AsBoolL(void) const
+	AsBool__CQ28LtkUtils6CValueRi @ 19 NONAME R3UNUSED ; LtkUtils::CValue::AsBool(int &) const
+	AsBool__CQ28LtkUtils8CSetting @ 20 NONAME R3UNUSED ; LtkUtils::CSetting::AsBool(void) const
+	AsBool__CQ28LtkUtils8CSettingRi @ 21 NONAME R3UNUSED ; LtkUtils::CSetting::AsBool(int &) const
+	AsIntL__CQ28LtkUtils6CValue @ 22 NONAME R3UNUSED ; LtkUtils::CValue::AsIntL(void) const
+	AsInt__CQ28LtkUtils6CValueRi @ 23 NONAME R3UNUSED ; LtkUtils::CValue::AsInt(int &) const
+	AsInt__CQ28LtkUtils8CSetting @ 24 NONAME R3UNUSED ; LtkUtils::CSetting::AsInt(void) const
+	AsInt__CQ28LtkUtils8CSettingRi @ 25 NONAME R3UNUSED ; LtkUtils::CSetting::AsInt(int &) const
+	ClearL__Q28LtkUtils8CSetting @ 26 NONAME R3UNUSED ; LtkUtils::CSetting::ClearL(void)
+	Description__Q28LtkUtils8CSetting @ 27 NONAME R3UNUSED ; LtkUtils::CSetting::Description(void)
+	GetBool__Q28LtkUtils8CIniFileRC7TDesC16 @ 28 NONAME R3UNUSED ; LtkUtils::CIniFile::GetBool(TDesC16 const &)
+	GetIdsL__CQ28LtkUtils10CIniReaderRt6RArray1ZC7TPtrC16 @ 29 NONAME R3UNUSED ; LtkUtils::CIniReader::GetIdsL(RArray<TPtrC16 const> &) const
+	GetInt__Q28LtkUtils8CIniFileRC7TDesC16 @ 30 NONAME R3UNUSED ; LtkUtils::CIniFile::GetInt(TDesC16 const &)
+	GetSetting__Q28LtkUtils8CIniFileRC7TDesC16 @ 31 NONAME R3UNUSED ; LtkUtils::CIniFile::GetSetting(TDesC16 const &)
+	GetString__Q28LtkUtils8CIniFileRC7TDesC16 @ 32 NONAME R3UNUSED ; LtkUtils::CIniFile::GetString(TDesC16 const &)
+	GetValue__CQ28LtkUtils10CIniReaderRC7TDesC16 @ 33 NONAME R3UNUSED ; LtkUtils::CIniReader::GetValue(TDesC16 const &) const
+	GetValuesL__CQ28LtkUtils10CIniReaderRt13RPointerArray1ZCQ28LtkUtils6CValue @ 34 NONAME R3UNUSED ; LtkUtils::CIniReader::GetValuesL(RPointerArray<LtkUtils::CValue const> &) const
+	GetValuesL__Q28LtkUtils10CIniReaderRt13RPointerArray1ZQ28LtkUtils6CValue @ 35 NONAME R3UNUSED ; LtkUtils::CIniReader::GetValuesL(RPointerArray<LtkUtils::CValue> &)
+	HasPrefix__8LtkUtilsRC7TDesC16T1 @ 36 NONAME R3UNUSED ; LtkUtils::HasPrefix(TDesC16 const &, TDesC16 const &)
+	HasPrefix___8LtkUtilsRC6TDesC8T1 @ 37 NONAME R3UNUSED ; LtkUtils::HasPrefix_(TDesC8 const &, TDesC8 const &)
+	HexLexL__8LtkUtilsR5TLex8 @ 38 NONAME R3UNUSED ; LtkUtils::HexLexL(TLex8 &)
+	HexLex___8LtkUtilsR5TLex8RUi @ 39 NONAME R3UNUSED ; LtkUtils::HexLex_(TLex8 &, unsigned int &)
+	HexLex___8LtkUtilsR6TLex16RUi @ 40 NONAME R3UNUSED ; LtkUtils::HexLex_(TLex16 &, unsigned int &)
+	Id__CQ28LtkUtils6CValue @ 41 NONAME R3UNUSED ; LtkUtils::CValue::Id(void) const
+	IsSet__CQ28LtkUtils8CSetting @ 42 NONAME R3UNUSED ; LtkUtils::CSetting::IsSet(void) const
+	LineNumber__CQ28LtkUtils6CValue @ 43 NONAME R3UNUSED ; LtkUtils::CValue::LineNumber(void) const
+	LineNumber__Q28LtkUtils13TErrorContext @ 44 NONAME R3UNUSED ; LtkUtils::TErrorContext::LineNumber(void)
+	LookupL__Q28LtkUtils10CSymbolicsRC7TDesC16Ul @ 45 NONAME R3UNUSED ABSENT ; LtkUtils::CSymbolics::LookupL(TDesC16 const &, unsigned long)
+	LookupL__Q28LtkUtils10CSymbolicsUl @ 46 NONAME R3UNUSED ABSENT ; LtkUtils::CSymbolics::LookupL(unsigned long)
+	LookupL__Q28LtkUtils9CBsymFileUl @ 47 NONAME R3UNUSED ABSENT ; LtkUtils::CBsymFile::LookupL(unsigned long)
+	Lookup__Q28LtkUtils8CMapFileUlR6TDes16 @ 48 NONAME R3UNUSED ABSENT ; LtkUtils::CMapFile::Lookup(unsigned long, TDes16 &)
+	MatchifyL___8LtkUtilsP7HBufC16 @ 49 NONAME R3UNUSED ABSENT ; LtkUtils::MatchifyL_(HBufC16 *)
+	Name__Q28LtkUtils8CSetting @ 50 NONAME R3UNUSED ; LtkUtils::CSetting::Name(void)
+	NewLC__Q28LtkUtils6CValueRC7TDesC16T1GQ28LtkUtils13TErrorContext @ 51 NONAME ; LtkUtils::CValue::NewLC(TDesC16 const &, TDesC16 const &, LtkUtils::TErrorContext)
+	NewLC__Q28LtkUtils8CSettingQ28LtkUtils12TSettingTypeRC7TDesC16N42GQ28LtkUtils13TErrorContext @ 52 NONAME ; LtkUtils::CSetting::NewLC(LtkUtils::TSettingType, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, LtkUtils::TErrorContext)
+	NewL__Q28LtkUtils10CIniReaderRC7TDesC16GQ28LtkUtils13TErrorContext @ 53 NONAME ; LtkUtils::CIniReader::NewL(TDesC16 const &, LtkUtils::TErrorContext)
+	NewL__Q28LtkUtils6CValueRC7TDesC16T1GQ28LtkUtils13TErrorContext @ 54 NONAME ; LtkUtils::CValue::NewL(TDesC16 const &, TDesC16 const &, LtkUtils::TErrorContext)
+	NewL__Q28LtkUtils8CIniFileRC7TDesC16T1 @ 55 NONAME R3UNUSED ; LtkUtils::CIniFile::NewL(TDesC16 const &, TDesC16 const &)
+	NewL__Q28LtkUtils8CMapFileR3RFsRC7TDesC16 @ 56 NONAME R3UNUSED ABSENT ; LtkUtils::CMapFile::NewL(RFs &, TDesC16 const &)
+	NewL__Q28LtkUtils8CSettingQ28LtkUtils12TSettingTypeRC7TDesC16N42GQ28LtkUtils13TErrorContext @ 57 NONAME ; LtkUtils::CSetting::NewL(LtkUtils::TSettingType, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, LtkUtils::TErrorContext)
+	NewL__Q28LtkUtils9CBsymFileR3RFsRC7TDesC16 @ 58 NONAME R3UNUSED ABSENT ; LtkUtils::CBsymFile::NewL(RFs &, TDesC16 const &)
+	NextLine__Q28LtkUtils13TErrorContext @ 59 NONAME R3UNUSED ; LtkUtils::TErrorContext::NextLine(void)
+	ReadIniFileL__8LtkUtilsR13RIoReadHandleRQ28LtkUtils13MValueHandler @ 60 NONAME R3UNUSED ; LtkUtils::ReadIniFileL(RIoReadHandle &, LtkUtils::MValueHandler &)
+	ReadIniFileL__8LtkUtilsRC7TDesC16RQ28LtkUtils13MValueHandlerGQ28LtkUtils13TErrorContextQ28LtkUtils19TFileNotFoundAction @ 61 NONAME ; LtkUtils::ReadIniFileL(TDesC16 const &, LtkUtils::MValueHandler &, LtkUtils::TErrorContext, LtkUtils::TFileNotFoundAction)
+	RemoveValueL__Q28LtkUtils10CIniReaderRC7TDesC16 @ 62 NONAME R3UNUSED ; LtkUtils::CIniReader::RemoveValueL(TDesC16 const &)
+	SetFallbackMapFileDirL__Q28LtkUtils10CSymbolicsRC7TDesC16 @ 63 NONAME R3UNUSED ABSENT ; LtkUtils::CSymbolics::SetFallbackMapFileDirL(TDesC16 const &)
+	SetL__Q28LtkUtils6CValueRC7TDesC16GQ28LtkUtils13TErrorContext @ 64 NONAME ; LtkUtils::CValue::SetL(TDesC16 const &, LtkUtils::TErrorContext)
+	SetL__Q28LtkUtils8CIniFileRC7TDesC16T1 @ 65 NONAME R3UNUSED ; LtkUtils::CIniFile::SetL(TDesC16 const &, TDesC16 const &)
+	SetL__Q28LtkUtils8CIniFileRC7TDesC16i @ 66 NONAME R3UNUSED ; LtkUtils::CIniFile::SetL(TDesC16 const &, int)
+	SetL__Q28LtkUtils8CSettingRC7TDesC16GQ28LtkUtils13TErrorContext @ 67 NONAME ; LtkUtils::CSetting::SetL(TDesC16 const &, LtkUtils::TErrorContext)
+	SetL__Q28LtkUtils8CSettingi @ 68 NONAME R3UNUSED ; LtkUtils::CSetting::SetL(int)
+	SetValueL__Q28LtkUtils10CIniReaderRC7TDesC16T1 @ 69 NONAME R3UNUSED ; LtkUtils::CIniReader::SetValueL(TDesC16 const &, TDesC16 const &)
+	StringLC__Q28LtkUtils13TErrorContext @ 70 NONAME R3UNUSED ; LtkUtils::TErrorContext::StringLC(void)
+	Value__CQ28LtkUtils6CValue @ 71 NONAME R3UNUSED ; LtkUtils::CValue::Value(void) const
+	WriteIniFileL__8LtkUtilsRC7TDesC16RQ28LtkUtils10CIniReader @ 72 NONAME R3UNUSED ; LtkUtils::WriteIniFileL(TDesC16 const &, LtkUtils::CIniReader &)
+	WriteL__Q28LtkUtils8CIniFile @ 73 NONAME R3UNUSED ; LtkUtils::CIniFile::WriteL(void)
+	"_._Q28LtkUtils10CIniReader" @ 74 NONAME R3UNUSED ; LtkUtils::CIniReader::~CIniReader(void)
+	"_._Q28LtkUtils10CSymbolics" @ 75 NONAME R3UNUSED ABSENT ; LtkUtils::CSymbolics::~CSymbolics(void)
+	"_._Q28LtkUtils6CValue" @ 76 NONAME R3UNUSED ; LtkUtils::CValue::~CValue(void)
+	"_._Q28LtkUtils8CIniFile" @ 77 NONAME R3UNUSED ; LtkUtils::CIniFile::~CIniFile(void)
+	"_._Q28LtkUtils8CMapFile" @ 78 NONAME R3UNUSED ABSENT ; LtkUtils::CMapFile::~CMapFile(void)
+	"_._Q28LtkUtils8CSetting" @ 79 NONAME R3UNUSED ; LtkUtils::CSetting::~CSetting(void)
+	"_._Q28LtkUtils9CBsymFile" @ 80 NONAME R3UNUSED ABSENT ; LtkUtils::CBsymFile::~CBsymFile(void)
+	__Q28LtkUtils10CSymbolicsR3RFs @ 81 NONAME R3UNUSED ABSENT ; LtkUtils::CSymbolics::CSymbolics(RFs &)
+	__Q28LtkUtils13TErrorContext @ 82 NONAME R3UNUSED ; LtkUtils::TErrorContext::TErrorContext(void)
+	AddBsymFileL__Q28LtkUtils10CSymbolicsRC7TDesC16 @ 83 NONAME R3UNUSED ABSENT ; LtkUtils::CSymbolics::AddBsymFileL(TDesC16 const &)
+	AddMapFileL__Q28LtkUtils10CSymbolicsPQ28LtkUtils8CMapFile @ 84 NONAME R3UNUSED ABSENT ; LtkUtils::CSymbolics::AddMapFileL(LtkUtils::CMapFile *)
+	GetFileNameL__CQ28LtkUtils8CMapFileR6TDes16 @ 85 NONAME R3UNUSED ABSENT ; LtkUtils::CMapFile::GetFileNameL(TDes16 &) const
+	__Q28LtkUtils9RLtkBuf16P7HBufC16 @ 86 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::RLtkBuf16(HBufC16 *)
+	AppendFormatL__Q28LtkUtils9RLtkBuf16Gt11TRefByValue1ZC7TDesC16e @ 87 NONAME ; LtkUtils::RLtkBuf16::AppendFormatL(TRefByValue<TDesC16 const>,...)
+	AppendL__Q28LtkUtils8RLtkBuf8G5TChar @ 88 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::AppendL(TChar)
+	AppendL__Q28LtkUtils8RLtkBuf8RC6TDesC8 @ 89 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::AppendL(TDesC8 const &)
+	AppendL__Q28LtkUtils8RLtkBuf8RC7TDesC16 @ 90 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::AppendL(TDesC16 const &)
+	AppendL__Q28LtkUtils9RLtkBuf16G5TChar @ 91 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendL(TChar)
+	AppendL__Q28LtkUtils9RLtkBuf16RC6TDesC8 @ 92 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendL(TDesC8 const &)
+	AppendL__Q28LtkUtils9RLtkBuf16RC7TDesC16 @ 93 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendL(TDesC16 const &)
+	Assign__Q28LtkUtils8RLtkBuf8P6HBufC8 @ 94 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::Assign(HBufC8 *)
+	Assign__Q28LtkUtils9RLtkBuf16P7HBufC16 @ 95 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::Assign(HBufC16 *)
+	Close__Q28LtkUtils8RLtkBuf8 @ 96 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::Close(void)
+	Close__Q28LtkUtils9RLtkBuf16 @ 97 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::Close(void)
+	CreateLC__Q28LtkUtils8RLtkBuf8i @ 98 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CreateLC(int)
+	CreateLC__Q28LtkUtils9RLtkBuf16i @ 99 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CreateLC(int)
+	CreateL__Q28LtkUtils8RLtkBuf8i @ 100 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CreateL(int)
+	CreateL__Q28LtkUtils9RLtkBuf16i @ 101 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CreateL(int)
+	CreateMaxL__Q28LtkUtils8RLtkBuf8i @ 102 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CreateMaxL(int)
+	CreateMaxL__Q28LtkUtils9RLtkBuf16i @ 103 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CreateMaxL(int)
+	CreateMax__Q28LtkUtils8RLtkBuf8i @ 104 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CreateMax(int)
+	CreateMax__Q28LtkUtils9RLtkBuf16i @ 105 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CreateMax(int)
+	Create__Q28LtkUtils8RLtkBuf8i @ 106 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::Create(int)
+	Create__Q28LtkUtils9RLtkBuf16i @ 107 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::Create(int)
+	ReAllocL__Q28LtkUtils8RLtkBuf8i @ 108 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReAllocL(int)
+	ReAllocL__Q28LtkUtils9RLtkBuf16i @ 109 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReAllocL(int)
+	ReAlloc__Q28LtkUtils8RLtkBuf8i @ 110 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReAlloc(int)
+	ReAlloc__Q28LtkUtils9RLtkBuf16i @ 111 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReAlloc(int)
+	ReplaceAllL__Q28LtkUtils8RLtkBuf8RC6TDesC8T1 @ 112 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReplaceAllL(TDesC8 const &, TDesC8 const &)
+	ReplaceAllL__Q28LtkUtils9RLtkBuf16RC7TDesC16T1 @ 113 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReplaceAllL(TDesC16 const &, TDesC16 const &)
+	ReplaceL__Q28LtkUtils8RLtkBuf8iiRC6TDesC8 @ 114 NONAME ; LtkUtils::RLtkBuf8::ReplaceL(int, int, TDesC8 const &)
+	ReplaceL__Q28LtkUtils9RLtkBuf16iiRC7TDesC16 @ 115 NONAME ; LtkUtils::RLtkBuf16::ReplaceL(int, int, TDesC16 const &)
+	ReserveExtraL__Q28LtkUtils8RLtkBuf8i @ 116 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReserveExtraL(int)
+	ReserveExtraL__Q28LtkUtils9RLtkBuf16i @ 117 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReserveExtraL(int)
+	ReserveExtra__Q28LtkUtils8RLtkBuf8i @ 118 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReserveExtra(int)
+	ReserveExtra__Q28LtkUtils9RLtkBuf16i @ 119 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReserveExtra(int)
+	ToHBuf__Q28LtkUtils8RLtkBuf8 @ 120 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ToHBuf(void)
+	ToHBuf__Q28LtkUtils9RLtkBuf16 @ 121 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ToHBuf(void)
+	__Q28LtkUtils8RLtkBuf8 @ 122 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::RLtkBuf8(void)
+	__Q28LtkUtils8RLtkBuf8P6HBufC8 @ 123 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::RLtkBuf8(HBufC8 *)
+	__Q28LtkUtils9RLtkBuf16 @ 124 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::RLtkBuf16(void)
+	AppendFormatL__Q28LtkUtils8RLtkBuf8Gt11TRefByValue1ZC6TDesC8e @ 125 NONAME ; LtkUtils::RLtkBuf8::AppendFormatL(TRefByValue<TDesC8 const>,...)
+	GetHBuf__CQ28LtkUtils8RLtkBuf8 @ 126 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::GetHBuf(void) const
+	GetHBuf__CQ28LtkUtils9RLtkBuf16 @ 127 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::GetHBuf(void) const
+	GetHalInfoForValueL__8LtkUtilsiii @ 128 NONAME R3UNUSED ; LtkUtils::GetHalInfoForValueL(int, int, int)
+	GetHalInfoL__8LtkUtilsRt13RPointerArray1ZQ28LtkUtils13CHalAttribute @ 129 NONAME R3UNUSED ; LtkUtils::GetHalInfoL(RPointerArray<LtkUtils::CHalAttribute> &)
+	GetHalInfoL__8LtkUtilsi @ 130 NONAME R3UNUSED ; LtkUtils::GetHalInfoL(int)
+	GetHalInfoL__8LtkUtilsii @ 131 NONAME R3UNUSED ; LtkUtils::GetHalInfoL(int, int)
+	"_._Q28LtkUtils13CHalAttribute" @ 132 NONAME R3UNUSED ; LtkUtils::CHalAttribute::~CHalAttribute(void)
+	AppendUtf8L__Q28LtkUtils9RLtkBuf16RC6TDesC8 @ 133 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendUtf8L(TDesC8 const &)
+	AppendUtf8L__Q28LtkUtils9RLtkBuf16RC6TDesC8Ri @ 134 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendUtf8L(TDesC8 const &, int &)
+	CopyAsUtf8L__Q28LtkUtils8RLtkBuf8RC7TDesC16 @ 135 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CopyAsUtf8L(TDesC16 const &)
+	CopyFromUtf8L__Q28LtkUtils9RLtkBuf16RC6TDesC8 @ 136 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CopyFromUtf8L(TDesC8 const &)
+	DecodeUtf8L___8LtkUtilsRC6TDesC8 @ 137 NONAME R3UNUSED ; LtkUtils::DecodeUtf8L_(TDesC8 const &)
+	FinalizeUtf8__Q28LtkUtils9RLtkBuf16 @ 138 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::FinalizeUtf8(void)
+	FinalizeUtf8__Q28LtkUtils9RLtkBuf16Ri @ 139 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::FinalizeUtf8(int &)
+	Utf8L___8LtkUtilsRC7TDesC16 @ 140 NONAME R3UNUSED ; LtkUtils::Utf8L_(TDesC16 const &)
+	AllocatedSize__Q28LtkUtils16RAllocatorHelper @ 141 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocatedSize(void)
+	AllocationCount__Q28LtkUtils16RAllocatorHelper @ 142 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocationCount(void)
+	AllocatorAddress__CQ28LtkUtils16RAllocatorHelper @ 143 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocatorAddress(void) const
+	Close__Q28LtkUtils16RAllocatorHelper @ 144 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Close(void)
+	Close__Q28LtkUtils21RProxyAllocatorHelper @ 145 NONAME R3UNUSED ; LtkUtils::RProxyAllocatorHelper::Close(void)
+	CommittedSize__Q28LtkUtils16RAllocatorHelper @ 146 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::CommittedSize(void)
+	CountForCellType__Q28LtkUtils16RAllocatorHelperQ38LtkUtils16RAllocatorHelper17TExtendedCellType @ 147 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::CountForCellType(LtkUtils::RAllocatorHelper::TExtendedCellType)
+	CountUnusedPages__Q28LtkUtils16RAllocatorHelper @ 148 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::CountUnusedPages(void)
+	GetCellNestingLevel__Q28LtkUtils16RAllocatorHelperPvRi @ 149 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::GetCellNestingLevel(void *, int &)
+	CommittedFreeSpace__Q28LtkUtils16RAllocatorHelper @ 150 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::CommittedFreeSpace(void)
+	MaxCommittedSize__Q28LtkUtils16RAllocatorHelper @ 151 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::MaxCommittedSize(void)
+	MinCommittedSize__Q28LtkUtils16RAllocatorHelper @ 152 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::MinCommittedSize(void)
+	OpenChunkHeap__Q28LtkUtils21RProxyAllocatorHelperR13RMemoryAccessPv @ 153 NONAME R3UNUSED ; LtkUtils::RProxyAllocatorHelper::OpenChunkHeap(RMemoryAccess &, void *)
+	Open__Q28LtkUtils16RAllocatorHelperP10RAllocator @ 154 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Open(RAllocator *)
+	Open__Q28LtkUtils21RProxyAllocatorHelperR13RMemoryAccessUi @ 155 NONAME R3UNUSED ; LtkUtils::RProxyAllocatorHelper::Open(RMemoryAccess &, unsigned int)
+	RefreshDetails__Q28LtkUtils16RAllocatorHelper @ 156 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::RefreshDetails(void)
+	SetCellNestingLevel__Q28LtkUtils16RAllocatorHelperPvi @ 157 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::SetCellNestingLevel(void *, int)
+	SizeForCellType__Q28LtkUtils16RAllocatorHelperQ38LtkUtils16RAllocatorHelper17TExtendedCellType @ 158 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::SizeForCellType(LtkUtils::RAllocatorHelper::TExtendedCellType)
+	Walk__Q28LtkUtils16RAllocatorHelperPFPvQ38LtkUtils16RAllocatorHelper9TCellTypeUli_iPv @ 159 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Walk(int (*)(void *, LtkUtils::RAllocatorHelper::TCellType, unsigned long, int), void *)
+	Walk__Q28LtkUtils16RAllocatorHelperPFRQ28LtkUtils16RAllocatorHelperPvQ38LtkUtils16RAllocatorHelper17TExtendedCellTypeUli_iPv @ 160 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Walk(int (*)(LtkUtils::RAllocatorHelper &, void *, LtkUtils::RAllocatorHelper::TExtendedCellType, unsigned long, int), void *)
+	Walk__Q28LtkUtils16RAllocatorHelperPFRQ28LtkUtils16RAllocatorHelperPvQ38LtkUtils16RAllocatorHelper9TCellTypeUli_iPv @ 161 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Walk(int (*)(LtkUtils::RAllocatorHelper &, void *, LtkUtils::RAllocatorHelper::TCellType, unsigned long, int), void *)
+	__Q28LtkUtils16RAllocatorHelper @ 162 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::RAllocatorHelper(void)
+	__Q28LtkUtils21RProxyAllocatorHelper @ 163 NONAME R3UNUSED ; LtkUtils::RProxyAllocatorHelper::RProxyAllocatorHelper(void)
+	AllocCountForCell__CQ28LtkUtils16RAllocatorHelperPv @ 164 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocCountForCell(void *) const
+	AllocatorIsUdeb__CQ28LtkUtils16RAllocatorHelper @ 165 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocatorIsUdeb(void) const
+	FormatSize__8LtkUtilsR5TDes8x @ 166 NONAME ; LtkUtils::FormatSize(TDes8 &, long long)
+	FormatSize___8LtkUtilsR6TDes16x @ 167 NONAME ; LtkUtils::FormatSize_(TDes16 &, long long)
+	Description__CQ28LtkUtils16RAllocatorHelper @ 168 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Description(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/BMARM/ltkutils.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,184 @@
+EXPORTS
+	W32CrackL__8LtkUtilsv @ 1 NONAME R3UNUSED ; LtkUtils::W32CrackL(void)
+	GetFriendlyProcessName___8LtkUtilsRC8RProcessR6TDes16 @ 2 NONAME R3UNUSED ; LtkUtils::GetFriendlyProcessName_(RProcess const &, TDes16 &)
+	GetFriendlyThreadName___8LtkUtilsG7RThreadRt4TBuf1i256 @ 3 NONAME R3UNUSED ; LtkUtils::GetFriendlyThreadName_(RThread, TBuf<256> &)
+	GetFromClipboardL__8LtkUtilsP3RFs @ 4 NONAME R3UNUSED ; LtkUtils::GetFromClipboardL(RFs *)
+	GetPubSubData__8LtkUtilsRi @ 5 NONAME R3UNUSED ABSENT ; LtkUtils::GetPubSubData(int &)
+	HexDumpL__8LtkUtilsRC6TDesC8 @ 6 NONAME R3UNUSED ; LtkUtils::HexDumpL(TDesC8 const &)
+	HexDumpToOutput__8LtkUtilsRC6TDesC8R14RIoWriteHandleRi @ 7 NONAME R3UNUSED ; LtkUtils::HexDumpToOutput(TDesC8 const &, RIoWriteHandle &, int &)
+	HexDumpToOutput___8LtkUtilsRC6TDesC8R14RIoWriteHandle @ 8 NONAME R3UNUSED ; LtkUtils::HexDumpToOutput_(TDesC8 const &, RIoWriteHandle &)
+	HexDumpToRDebug__8LtkUtilsRC6TDesC8 @ 9 NONAME R3UNUSED ; LtkUtils::HexDumpToRDebug(TDesC8 const &)
+	HexDumpToRDebug___8LtkUtilsRC6TDesC8Ri @ 10 NONAME R3UNUSED ; LtkUtils::HexDumpToRDebug_(TDesC8 const &, int &)
+	InjectRawKeyEvent__8LtkUtilsiii @ 11 NONAME R3UNUSED ; LtkUtils::InjectRawKeyEvent(int, int, int)
+	MakeHeapCellInvisible__8LtkUtilsPv @ 12 NONAME R3UNUSED ; LtkUtils::MakeHeapCellInvisible(void *)
+	MakeProcessNameFriendly___8LtkUtilsR6TDes16 @ 13 NONAME R3UNUSED ; LtkUtils::MakeProcessNameFriendly_(TDes16 &)
+	MakeThreadNameFriendly___8LtkUtilsRt4TBuf1i256 @ 14 NONAME R3UNUSED ; LtkUtils::MakeThreadNameFriendly_(TBuf<256> &)
+	RawPrint__8LtkUtilsRC6TDesC8 @ 15 NONAME R3UNUSED ; LtkUtils::RawPrint(TDesC8 const &)
+	Rez8LC___8LtkUtilsRC7TDesC16P3RFsPP7HBufC16 @ 16 NONAME R3UNUSED ; LtkUtils::Rez8LC_(TDesC16 const &, RFs *, HBufC16 **)
+	Rez8L___8LtkUtilsRC7TDesC16P3RFsPP7HBufC16 @ 17 NONAME R3UNUSED ; LtkUtils::Rez8L_(TDesC16 const &, RFs *, HBufC16 **)
+	RezLC___8LtkUtilsRC7TDesC16P3RFsPP7HBufC16 @ 18 NONAME R3UNUSED ; LtkUtils::RezLC_(TDesC16 const &, RFs *, HBufC16 **)
+	RezL__8LtkUtilsRC7TDesC16P3RFsPP7HBufC16 @ 19 NONAME R3UNUSED ; LtkUtils::RezL(TDesC16 const &, RFs *, HBufC16 **)
+	CopyToClipboardL___8LtkUtilsRC7TDesC16P3RFs @ 20 NONAME R3UNUSED ; LtkUtils::CopyToClipboardL_(TDesC16 const &, RFs *)
+	W32CrackIsEnabled__8LtkUtilsv @ 21 NONAME R3UNUSED ; LtkUtils::W32CrackIsEnabled(void)
+	HexLexL___8LtkUtilsR6TLex16 @ 22 NONAME R3UNUSED ; LtkUtils::HexLexL_(TLex16 &)
+	ReplaceText___8LtkUtilsR6TDes16RC7TDesC16T2 @ 23 NONAME R3UNUSED ; LtkUtils::ReplaceText_(TDes16 &, TDesC16 const &, TDesC16 const &)
+	__Q28LtkUtils13TErrorContextRC7TDesC16 @ 24 NONAME R3UNUSED ; LtkUtils::TErrorContext::TErrorContext(TDesC16 const &)
+	AddMapFileL__Q28LtkUtils10CSymbolicsRC7TDesC16 @ 25 NONAME R3UNUSED ; LtkUtils::CSymbolics::AddMapFileL(TDesC16 const &)
+	AsBoolL__CQ28LtkUtils6CValue @ 26 NONAME R3UNUSED ; LtkUtils::CValue::AsBoolL(void) const
+	AsBool__CQ28LtkUtils6CValueRi @ 27 NONAME R3UNUSED ; LtkUtils::CValue::AsBool(int &) const
+	AsBool__CQ28LtkUtils8CSetting @ 28 NONAME R3UNUSED ; LtkUtils::CSetting::AsBool(void) const
+	AsBool__CQ28LtkUtils8CSettingRi @ 29 NONAME R3UNUSED ; LtkUtils::CSetting::AsBool(int &) const
+	AsIntL__CQ28LtkUtils6CValue @ 30 NONAME R3UNUSED ; LtkUtils::CValue::AsIntL(void) const
+	AsInt__CQ28LtkUtils6CValueRi @ 31 NONAME R3UNUSED ; LtkUtils::CValue::AsInt(int &) const
+	AsInt__CQ28LtkUtils8CSetting @ 32 NONAME R3UNUSED ; LtkUtils::CSetting::AsInt(void) const
+	AsInt__CQ28LtkUtils8CSettingRi @ 33 NONAME R3UNUSED ; LtkUtils::CSetting::AsInt(int &) const
+	ClearL__Q28LtkUtils8CSetting @ 34 NONAME R3UNUSED ; LtkUtils::CSetting::ClearL(void)
+	Description__Q28LtkUtils8CSetting @ 35 NONAME R3UNUSED ; LtkUtils::CSetting::Description(void)
+	GetBool__Q28LtkUtils8CIniFileRC7TDesC16 @ 36 NONAME R3UNUSED ; LtkUtils::CIniFile::GetBool(TDesC16 const &)
+	GetIdsL__CQ28LtkUtils10CIniReaderRt6RArray1ZC7TPtrC16 @ 37 NONAME R3UNUSED ; LtkUtils::CIniReader::GetIdsL(RArray<TPtrC16 const> &) const
+	GetInt__Q28LtkUtils8CIniFileRC7TDesC16 @ 38 NONAME R3UNUSED ; LtkUtils::CIniFile::GetInt(TDesC16 const &)
+	GetSetting__Q28LtkUtils8CIniFileRC7TDesC16 @ 39 NONAME R3UNUSED ; LtkUtils::CIniFile::GetSetting(TDesC16 const &)
+	GetString__Q28LtkUtils8CIniFileRC7TDesC16 @ 40 NONAME R3UNUSED ; LtkUtils::CIniFile::GetString(TDesC16 const &)
+	GetValue__CQ28LtkUtils10CIniReaderRC7TDesC16 @ 41 NONAME R3UNUSED ; LtkUtils::CIniReader::GetValue(TDesC16 const &) const
+	GetValuesL__CQ28LtkUtils10CIniReaderRt13RPointerArray1ZCQ28LtkUtils6CValue @ 42 NONAME R3UNUSED ; LtkUtils::CIniReader::GetValuesL(RPointerArray<LtkUtils::CValue const> &) const
+	GetValuesL__Q28LtkUtils10CIniReaderRt13RPointerArray1ZQ28LtkUtils6CValue @ 43 NONAME R3UNUSED ; LtkUtils::CIniReader::GetValuesL(RPointerArray<LtkUtils::CValue> &)
+	HasPrefix__8LtkUtilsRC7TDesC16T1 @ 44 NONAME R3UNUSED ; LtkUtils::HasPrefix(TDesC16 const &, TDesC16 const &)
+	HasPrefix___8LtkUtilsRC6TDesC8T1 @ 45 NONAME R3UNUSED ; LtkUtils::HasPrefix_(TDesC8 const &, TDesC8 const &)
+	HexLexL__8LtkUtilsR5TLex8 @ 46 NONAME R3UNUSED ; LtkUtils::HexLexL(TLex8 &)
+	HexLex___8LtkUtilsR5TLex8RUi @ 47 NONAME R3UNUSED ; LtkUtils::HexLex_(TLex8 &, unsigned int &)
+	HexLex___8LtkUtilsR6TLex16RUi @ 48 NONAME R3UNUSED ; LtkUtils::HexLex_(TLex16 &, unsigned int &)
+	Id__CQ28LtkUtils6CValue @ 49 NONAME R3UNUSED ; LtkUtils::CValue::Id(void) const
+	IsSet__CQ28LtkUtils8CSetting @ 50 NONAME R3UNUSED ; LtkUtils::CSetting::IsSet(void) const
+	LineNumber__CQ28LtkUtils6CValue @ 51 NONAME R3UNUSED ; LtkUtils::CValue::LineNumber(void) const
+	LineNumber__Q28LtkUtils13TErrorContext @ 52 NONAME R3UNUSED ; LtkUtils::TErrorContext::LineNumber(void)
+	LookupL__Q28LtkUtils10CSymbolicsRC7TDesC16Ul @ 53 NONAME R3UNUSED ; LtkUtils::CSymbolics::LookupL(TDesC16 const &, unsigned long)
+	LookupL__Q28LtkUtils10CSymbolicsUl @ 54 NONAME R3UNUSED ; LtkUtils::CSymbolics::LookupL(unsigned long)
+	LookupL__Q28LtkUtils9CBsymFileUl @ 55 NONAME R3UNUSED ; LtkUtils::CBsymFile::LookupL(unsigned long)
+	Lookup__Q28LtkUtils8CMapFileUlR6TDes16 @ 56 NONAME R3UNUSED ; LtkUtils::CMapFile::Lookup(unsigned long, TDes16 &)
+	MatchifyL___8LtkUtilsP7HBufC16 @ 57 NONAME R3UNUSED ABSENT ; LtkUtils::MatchifyL_(HBufC16 *)
+	Name__Q28LtkUtils8CSetting @ 58 NONAME R3UNUSED ; LtkUtils::CSetting::Name(void)
+	NewLC__Q28LtkUtils6CValueRC7TDesC16T1GQ28LtkUtils13TErrorContext @ 59 NONAME ; LtkUtils::CValue::NewLC(TDesC16 const &, TDesC16 const &, LtkUtils::TErrorContext)
+	NewLC__Q28LtkUtils8CSettingQ28LtkUtils12TSettingTypeRC7TDesC16N42GQ28LtkUtils13TErrorContext @ 60 NONAME ; LtkUtils::CSetting::NewLC(LtkUtils::TSettingType, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, LtkUtils::TErrorContext)
+	NewL__Q28LtkUtils10CIniReaderRC7TDesC16GQ28LtkUtils13TErrorContext @ 61 NONAME ; LtkUtils::CIniReader::NewL(TDesC16 const &, LtkUtils::TErrorContext)
+	NewL__Q28LtkUtils6CValueRC7TDesC16T1GQ28LtkUtils13TErrorContext @ 62 NONAME ; LtkUtils::CValue::NewL(TDesC16 const &, TDesC16 const &, LtkUtils::TErrorContext)
+	NewL__Q28LtkUtils8CIniFileRC7TDesC16T1 @ 63 NONAME R3UNUSED ; LtkUtils::CIniFile::NewL(TDesC16 const &, TDesC16 const &)
+	NewL__Q28LtkUtils8CMapFileR3RFsRC7TDesC16 @ 64 NONAME R3UNUSED ; LtkUtils::CMapFile::NewL(RFs &, TDesC16 const &)
+	NewL__Q28LtkUtils8CSettingQ28LtkUtils12TSettingTypeRC7TDesC16N42GQ28LtkUtils13TErrorContext @ 65 NONAME ; LtkUtils::CSetting::NewL(LtkUtils::TSettingType, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, TDesC16 const &, LtkUtils::TErrorContext)
+	NewL__Q28LtkUtils9CBsymFileR3RFsRC7TDesC16 @ 66 NONAME R3UNUSED ; LtkUtils::CBsymFile::NewL(RFs &, TDesC16 const &)
+	NextLine__Q28LtkUtils13TErrorContext @ 67 NONAME R3UNUSED ; LtkUtils::TErrorContext::NextLine(void)
+	ReadIniFileL__8LtkUtilsR13RIoReadHandleRQ28LtkUtils13MValueHandler @ 68 NONAME R3UNUSED ; LtkUtils::ReadIniFileL(RIoReadHandle &, LtkUtils::MValueHandler &)
+	ReadIniFileL__8LtkUtilsRC7TDesC16RQ28LtkUtils13MValueHandlerGQ28LtkUtils13TErrorContextQ28LtkUtils19TFileNotFoundAction @ 69 NONAME ; LtkUtils::ReadIniFileL(TDesC16 const &, LtkUtils::MValueHandler &, LtkUtils::TErrorContext, LtkUtils::TFileNotFoundAction)
+	RemoveValueL__Q28LtkUtils10CIniReaderRC7TDesC16 @ 70 NONAME R3UNUSED ; LtkUtils::CIniReader::RemoveValueL(TDesC16 const &)
+	SetFallbackMapFileDirL__Q28LtkUtils10CSymbolicsRC7TDesC16 @ 71 NONAME R3UNUSED ; LtkUtils::CSymbolics::SetFallbackMapFileDirL(TDesC16 const &)
+	SetL__Q28LtkUtils6CValueRC7TDesC16GQ28LtkUtils13TErrorContext @ 72 NONAME ; LtkUtils::CValue::SetL(TDesC16 const &, LtkUtils::TErrorContext)
+	SetL__Q28LtkUtils8CIniFileRC7TDesC16T1 @ 73 NONAME R3UNUSED ; LtkUtils::CIniFile::SetL(TDesC16 const &, TDesC16 const &)
+	SetL__Q28LtkUtils8CIniFileRC7TDesC16i @ 74 NONAME R3UNUSED ; LtkUtils::CIniFile::SetL(TDesC16 const &, int)
+	SetL__Q28LtkUtils8CSettingRC7TDesC16GQ28LtkUtils13TErrorContext @ 75 NONAME ; LtkUtils::CSetting::SetL(TDesC16 const &, LtkUtils::TErrorContext)
+	SetL__Q28LtkUtils8CSettingi @ 76 NONAME R3UNUSED ; LtkUtils::CSetting::SetL(int)
+	SetValueL__Q28LtkUtils10CIniReaderRC7TDesC16T1 @ 77 NONAME R3UNUSED ; LtkUtils::CIniReader::SetValueL(TDesC16 const &, TDesC16 const &)
+	StringLC__Q28LtkUtils13TErrorContext @ 78 NONAME R3UNUSED ; LtkUtils::TErrorContext::StringLC(void)
+	Value__CQ28LtkUtils6CValue @ 79 NONAME R3UNUSED ; LtkUtils::CValue::Value(void) const
+	WriteIniFileL__8LtkUtilsRC7TDesC16RQ28LtkUtils10CIniReader @ 80 NONAME R3UNUSED ; LtkUtils::WriteIniFileL(TDesC16 const &, LtkUtils::CIniReader &)
+	WriteL__Q28LtkUtils8CIniFile @ 81 NONAME R3UNUSED ; LtkUtils::CIniFile::WriteL(void)
+	"_._Q28LtkUtils10CIniReader" @ 82 NONAME R3UNUSED ; LtkUtils::CIniReader::~CIniReader(void)
+	"_._Q28LtkUtils10CSymbolics" @ 83 NONAME R3UNUSED ; LtkUtils::CSymbolics::~CSymbolics(void)
+	"_._Q28LtkUtils6CValue" @ 84 NONAME R3UNUSED ; LtkUtils::CValue::~CValue(void)
+	"_._Q28LtkUtils8CIniFile" @ 85 NONAME R3UNUSED ; LtkUtils::CIniFile::~CIniFile(void)
+	"_._Q28LtkUtils8CMapFile" @ 86 NONAME R3UNUSED ; LtkUtils::CMapFile::~CMapFile(void)
+	"_._Q28LtkUtils8CSetting" @ 87 NONAME R3UNUSED ; LtkUtils::CSetting::~CSetting(void)
+	"_._Q28LtkUtils9CBsymFile" @ 88 NONAME R3UNUSED ; LtkUtils::CBsymFile::~CBsymFile(void)
+	__Q28LtkUtils10CSymbolicsR3RFs @ 89 NONAME R3UNUSED ; LtkUtils::CSymbolics::CSymbolics(RFs &)
+	__Q28LtkUtils13TErrorContext @ 90 NONAME R3UNUSED ; LtkUtils::TErrorContext::TErrorContext(void)
+	AddBsymFileL__Q28LtkUtils10CSymbolicsRC7TDesC16 @ 91 NONAME R3UNUSED ; LtkUtils::CSymbolics::AddBsymFileL(TDesC16 const &)
+	AddMapFileL__Q28LtkUtils10CSymbolicsPQ28LtkUtils8CMapFile @ 92 NONAME R3UNUSED ; LtkUtils::CSymbolics::AddMapFileL(LtkUtils::CMapFile *)
+	Breakpoint__8LtkUtilsv @ 93 NONAME R3UNUSED ; LtkUtils::Breakpoint(void)
+	GetFileNameL__CQ28LtkUtils8CMapFileR6TDes16 @ 94 NONAME R3UNUSED ; LtkUtils::CMapFile::GetFileNameL(TDes16 &) const
+	BreakpointAddr__8LtkUtilsv @ 95 NONAME R3UNUSED ; LtkUtils::BreakpointAddr(void)
+	__Q28LtkUtils9RLtkBuf16P7HBufC16 @ 96 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::RLtkBuf16(HBufC16 *)
+	AppendFormatL__Q28LtkUtils8RLtkBuf8Gt11TRefByValue1ZC6TDesC8e @ 97 NONAME ; LtkUtils::RLtkBuf8::AppendFormatL(TRefByValue<TDesC8 const>,...)
+	AppendFormatL__Q28LtkUtils9RLtkBuf16Gt11TRefByValue1ZC7TDesC16e @ 98 NONAME ; LtkUtils::RLtkBuf16::AppendFormatL(TRefByValue<TDesC16 const>,...)
+	AppendL__Q28LtkUtils8RLtkBuf8G5TChar @ 99 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::AppendL(TChar)
+	AppendL__Q28LtkUtils8RLtkBuf8RC6TDesC8 @ 100 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::AppendL(TDesC8 const &)
+	AppendL__Q28LtkUtils8RLtkBuf8RC7TDesC16 @ 101 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::AppendL(TDesC16 const &)
+	AppendL__Q28LtkUtils9RLtkBuf16G5TChar @ 102 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendL(TChar)
+	AppendL__Q28LtkUtils9RLtkBuf16RC6TDesC8 @ 103 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendL(TDesC8 const &)
+	AppendL__Q28LtkUtils9RLtkBuf16RC7TDesC16 @ 104 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendL(TDesC16 const &)
+	Assign__Q28LtkUtils8RLtkBuf8P6HBufC8 @ 105 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::Assign(HBufC8 *)
+	Assign__Q28LtkUtils9RLtkBuf16P7HBufC16 @ 106 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::Assign(HBufC16 *)
+	Close__Q28LtkUtils8RLtkBuf8 @ 107 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::Close(void)
+	Close__Q28LtkUtils9RLtkBuf16 @ 108 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::Close(void)
+	CodesegOffsetFromSymbolNameL__Q28LtkUtils10CSymbolicsRC7TDesC16T1 @ 109 NONAME R3UNUSED ; LtkUtils::CSymbolics::CodesegOffsetFromSymbolNameL(TDesC16 const &, TDesC16 const &)
+	CompleteL__Q28LtkUtils10CSymbolicsRC7TDesC16R6TDes16R12CDesC16Array @ 110 NONAME ; LtkUtils::CSymbolics::CompleteL(TDesC16 const &, TDes16 &, CDesC16Array &)
+	CreateLC__Q28LtkUtils8RLtkBuf8i @ 111 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CreateLC(int)
+	CreateLC__Q28LtkUtils9RLtkBuf16i @ 112 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CreateLC(int)
+	CreateL__Q28LtkUtils8RLtkBuf8i @ 113 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CreateL(int)
+	CreateL__Q28LtkUtils9RLtkBuf16i @ 114 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CreateL(int)
+	CreateMaxL__Q28LtkUtils8RLtkBuf8i @ 115 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CreateMaxL(int)
+	CreateMaxL__Q28LtkUtils9RLtkBuf16i @ 116 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CreateMaxL(int)
+	CreateMax__Q28LtkUtils8RLtkBuf8i @ 117 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CreateMax(int)
+	CreateMax__Q28LtkUtils9RLtkBuf16i @ 118 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CreateMax(int)
+	Create__Q28LtkUtils8RLtkBuf8i @ 119 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::Create(int)
+	Create__Q28LtkUtils9RLtkBuf16i @ 120 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::Create(int)
+	ReAllocL__Q28LtkUtils8RLtkBuf8i @ 121 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReAllocL(int)
+	ReAllocL__Q28LtkUtils9RLtkBuf16i @ 122 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReAllocL(int)
+	ReAlloc__Q28LtkUtils8RLtkBuf8i @ 123 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReAlloc(int)
+	ReAlloc__Q28LtkUtils9RLtkBuf16i @ 124 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReAlloc(int)
+	ReplaceAllL__Q28LtkUtils8RLtkBuf8RC6TDesC8T1 @ 125 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReplaceAllL(TDesC8 const &, TDesC8 const &)
+	ReplaceAllL__Q28LtkUtils9RLtkBuf16RC7TDesC16T1 @ 126 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReplaceAllL(TDesC16 const &, TDesC16 const &)
+	ReplaceL__Q28LtkUtils8RLtkBuf8iiRC6TDesC8 @ 127 NONAME ; LtkUtils::RLtkBuf8::ReplaceL(int, int, TDesC8 const &)
+	ReplaceL__Q28LtkUtils9RLtkBuf16iiRC7TDesC16 @ 128 NONAME ; LtkUtils::RLtkBuf16::ReplaceL(int, int, TDesC16 const &)
+	ReserveExtraL__Q28LtkUtils8RLtkBuf8i @ 129 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReserveExtraL(int)
+	ReserveExtraL__Q28LtkUtils9RLtkBuf16i @ 130 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReserveExtraL(int)
+	ReserveExtra__Q28LtkUtils8RLtkBuf8i @ 131 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ReserveExtra(int)
+	ReserveExtra__Q28LtkUtils9RLtkBuf16i @ 132 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ReserveExtra(int)
+	ToHBuf__Q28LtkUtils8RLtkBuf8 @ 133 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::ToHBuf(void)
+	ToHBuf__Q28LtkUtils9RLtkBuf16 @ 134 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::ToHBuf(void)
+	__Q28LtkUtils8RLtkBuf8 @ 135 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::RLtkBuf8(void)
+	__Q28LtkUtils8RLtkBuf8P6HBufC8 @ 136 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::RLtkBuf8(HBufC8 *)
+	__Q28LtkUtils9RLtkBuf16 @ 137 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::RLtkBuf16(void)
+	GetHBuf__CQ28LtkUtils8RLtkBuf8 @ 138 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::GetHBuf(void) const
+	GetHBuf__CQ28LtkUtils9RLtkBuf16 @ 139 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::GetHBuf(void) const
+	GetHalInfoForValueL__8LtkUtilsiii @ 140 NONAME R3UNUSED ; LtkUtils::GetHalInfoForValueL(int, int, int)
+	GetHalInfoL__8LtkUtilsRt13RPointerArray1ZQ28LtkUtils13CHalAttribute @ 141 NONAME R3UNUSED ; LtkUtils::GetHalInfoL(RPointerArray<LtkUtils::CHalAttribute> &)
+	GetHalInfoL__8LtkUtilsi @ 142 NONAME R3UNUSED ; LtkUtils::GetHalInfoL(int)
+	GetHalInfoL__8LtkUtilsii @ 143 NONAME R3UNUSED ; LtkUtils::GetHalInfoL(int, int)
+	"_._Q28LtkUtils13CHalAttribute" @ 144 NONAME R3UNUSED ; LtkUtils::CHalAttribute::~CHalAttribute(void)
+	AppendUtf8L__Q28LtkUtils9RLtkBuf16RC6TDesC8 @ 145 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendUtf8L(TDesC8 const &)
+	AppendUtf8L__Q28LtkUtils9RLtkBuf16RC6TDesC8Ri @ 146 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::AppendUtf8L(TDesC8 const &, int &)
+	CopyAsUtf8L__Q28LtkUtils8RLtkBuf8RC7TDesC16 @ 147 NONAME R3UNUSED ; LtkUtils::RLtkBuf8::CopyAsUtf8L(TDesC16 const &)
+	CopyFromUtf8L__Q28LtkUtils9RLtkBuf16RC6TDesC8 @ 148 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::CopyFromUtf8L(TDesC8 const &)
+	DecodeUtf8L___8LtkUtilsRC6TDesC8 @ 149 NONAME R3UNUSED ; LtkUtils::DecodeUtf8L_(TDesC8 const &)
+	FinalizeUtf8__Q28LtkUtils9RLtkBuf16 @ 150 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::FinalizeUtf8(void)
+	FinalizeUtf8__Q28LtkUtils9RLtkBuf16Ri @ 151 NONAME R3UNUSED ; LtkUtils::RLtkBuf16::FinalizeUtf8(int &)
+	LookupL__Q28LtkUtils9CBsymFileRC7TDesC16i @ 152 NONAME R3UNUSED ; LtkUtils::CBsymFile::LookupL(TDesC16 const &, int)
+	Utf8L___8LtkUtilsRC7TDesC16 @ 153 NONAME R3UNUSED ; LtkUtils::Utf8L_(TDesC16 const &)
+	AllocCountForCell__CQ28LtkUtils16RAllocatorHelperPv @ 154 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocCountForCell(void *) const
+	AllocatedSize__Q28LtkUtils16RAllocatorHelper @ 155 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocatedSize(void)
+	AllocationCount__Q28LtkUtils16RAllocatorHelper @ 156 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocationCount(void)
+	AllocatorAddress__CQ28LtkUtils16RAllocatorHelper @ 157 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocatorAddress(void) const
+	Close__Q28LtkUtils16RAllocatorHelper @ 158 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Close(void)
+	Close__Q28LtkUtils21RProxyAllocatorHelper @ 159 NONAME R3UNUSED ; LtkUtils::RProxyAllocatorHelper::Close(void)
+	CommittedSize__Q28LtkUtils16RAllocatorHelper @ 160 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::CommittedSize(void)
+	CountForCellType__Q28LtkUtils16RAllocatorHelperQ38LtkUtils16RAllocatorHelper17TExtendedCellType @ 161 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::CountForCellType(LtkUtils::RAllocatorHelper::TExtendedCellType)
+	CountUnusedPages__Q28LtkUtils16RAllocatorHelper @ 162 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::CountUnusedPages(void)
+	GetCellNestingLevel__Q28LtkUtils16RAllocatorHelperPvRi @ 163 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::GetCellNestingLevel(void *, int &)
+	CommittedFreeSpace__Q28LtkUtils16RAllocatorHelper @ 164 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::CommittedFreeSpace(void)
+	MaxCommittedSize__Q28LtkUtils16RAllocatorHelper @ 165 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::MaxCommittedSize(void)
+	MinCommittedSize__Q28LtkUtils16RAllocatorHelper @ 166 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::MinCommittedSize(void)
+	OpenChunkHeap__Q28LtkUtils21RProxyAllocatorHelperR13RMemoryAccessPv @ 167 NONAME R3UNUSED ; LtkUtils::RProxyAllocatorHelper::OpenChunkHeap(RMemoryAccess &, void *)
+	Open__Q28LtkUtils16RAllocatorHelperP10RAllocator @ 168 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Open(RAllocator *)
+	Open__Q28LtkUtils21RProxyAllocatorHelperR13RMemoryAccessUi @ 169 NONAME R3UNUSED ; LtkUtils::RProxyAllocatorHelper::Open(RMemoryAccess &, unsigned int)
+	RefreshDetails__Q28LtkUtils16RAllocatorHelper @ 170 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::RefreshDetails(void)
+	SetCellNestingLevel__Q28LtkUtils16RAllocatorHelperPvi @ 171 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::SetCellNestingLevel(void *, int)
+	SizeForCellType__Q28LtkUtils16RAllocatorHelperQ38LtkUtils16RAllocatorHelper17TExtendedCellType @ 172 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::SizeForCellType(LtkUtils::RAllocatorHelper::TExtendedCellType)
+	Walk__Q28LtkUtils16RAllocatorHelperPFPvQ38LtkUtils16RAllocatorHelper9TCellTypeUli_iPv @ 173 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Walk(int (*)(void *, LtkUtils::RAllocatorHelper::TCellType, unsigned long, int), void *)
+	Walk__Q28LtkUtils16RAllocatorHelperPFRQ28LtkUtils16RAllocatorHelperPvQ38LtkUtils16RAllocatorHelper17TExtendedCellTypeUli_iPv @ 174 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Walk(int (*)(LtkUtils::RAllocatorHelper &, void *, LtkUtils::RAllocatorHelper::TExtendedCellType, unsigned long, int), void *)
+	Walk__Q28LtkUtils16RAllocatorHelperPFRQ28LtkUtils16RAllocatorHelperPvQ38LtkUtils16RAllocatorHelper9TCellTypeUli_iPv @ 175 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Walk(int (*)(LtkUtils::RAllocatorHelper &, void *, LtkUtils::RAllocatorHelper::TCellType, unsigned long, int), void *)
+	__Q28LtkUtils16RAllocatorHelper @ 176 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::RAllocatorHelper(void)
+	__Q28LtkUtils21RProxyAllocatorHelper @ 177 NONAME R3UNUSED ; LtkUtils::RProxyAllocatorHelper::RProxyAllocatorHelper(void)
+	AllocatorIsUdeb__CQ28LtkUtils16RAllocatorHelper @ 178 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::AllocatorIsUdeb(void) const
+	BreakpointPushL__8LtkUtilsv @ 179 NONAME R3UNUSED ; LtkUtils::BreakpointPushL(void)
+	FormatSize__8LtkUtilsR5TDes8x @ 180 NONAME ; LtkUtils::FormatSize(TDes8 &, long long)
+	FormatSize___8LtkUtilsR6TDes16x @ 181 NONAME ; LtkUtils::FormatSize_(TDes16 &, long long)
+	Description__CQ28LtkUtils16RAllocatorHelper @ 182 NONAME R3UNUSED ; LtkUtils::RAllocatorHelper::Description(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/bwins/ltkutils-tcb.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,155 @@
+EXPORTS
+	?GetPubSubData@LtkUtils@@YAPBUSKeyPair@1@AAH@Z @ 1 NONAME ABSENT ; struct LtkUtils::SKeyPair const * LtkUtils::GetPubSubData(int &)
+	?HexDumpL@LtkUtils@@YAPAVHBufC16@@ABVTDesC8@@@Z @ 2 NONAME ; class HBufC16 * LtkUtils::HexDumpL(class TDesC8 const &)
+	?HexDumpToOutput@LtkUtils@@YAXABVTDesC8@@AAVRIoWriteHandle@@@Z @ 3 NONAME ; void LtkUtils::HexDumpToOutput(class TDesC8 const &, class RIoWriteHandle &)
+	?HexDumpToOutput@LtkUtils@@YAXABVTDesC8@@AAVRIoWriteHandle@@AAH@Z @ 4 NONAME ; void LtkUtils::HexDumpToOutput(class TDesC8 const &, class RIoWriteHandle &, int &)
+	?HexDumpToRDebug@LtkUtils@@YAXABVTDesC8@@@Z @ 5 NONAME ; void LtkUtils::HexDumpToRDebug(class TDesC8 const &)
+	?HexDumpToRDebug@LtkUtils@@YAXABVTDesC8@@AAH@Z @ 6 NONAME ; void LtkUtils::HexDumpToRDebug(class TDesC8 const &, int &)
+	?InjectRawKeyEvent@LtkUtils@@YAHHHH@Z @ 7 NONAME ; int LtkUtils::InjectRawKeyEvent(int, int, int)
+	?MakeHeapCellInvisible@LtkUtils@@YAXPAX@Z @ 8 NONAME ; void LtkUtils::MakeHeapCellInvisible(void *)
+	?GetFriendlyThreadName@LtkUtils@@YAXVRThread@@AAV?$TBuf@$0BAA@@@@Z @ 9 NONAME ; void LtkUtils::GetFriendlyThreadName(class RThread, class TBuf<256> &)
+	?MakeThreadNameFriendly@LtkUtils@@YAXAAV?$TBuf@$0BAA@@@@Z @ 10 NONAME ; void LtkUtils::MakeThreadNameFriendly(class TBuf<256> &)
+	?RawPrint@LtkUtils@@YAXABVTDesC8@@@Z @ 11 NONAME ; void LtkUtils::RawPrint(class TDesC8 const &)
+	?GetFriendlyProcessName@LtkUtils@@YAXABVRProcess@@AAVTDes16@@@Z @ 12 NONAME ; void LtkUtils::GetFriendlyProcessName(class RProcess const &, class TDes16 &)
+	?MakeProcessNameFriendly@LtkUtils@@YAXAAVTDes16@@@Z @ 13 NONAME ; void LtkUtils::MakeProcessNameFriendly(class TDes16 &)
+	?HexLexL@LtkUtils@@YAIAAVTLex16@@@Z @ 14 NONAME ; unsigned int LtkUtils::HexLexL(class TLex16 &)
+	?ReplaceText@LtkUtils@@YAHAAVTDes16@@ABVTDesC16@@1@Z @ 15 NONAME ; int LtkUtils::ReplaceText(class TDes16 &, class TDesC16 const &, class TDesC16 const &)
+	??0TErrorContext@LtkUtils@@QAE@ABVTDesC16@@@Z @ 16 NONAME ; LtkUtils::TErrorContext::TErrorContext(class TDesC16 const &)
+	??0TErrorContext@LtkUtils@@QAE@XZ @ 17 NONAME ; LtkUtils::TErrorContext::TErrorContext(void)
+	??1CIniFile@LtkUtils@@UAE@XZ @ 18 NONAME ; LtkUtils::CIniFile::~CIniFile(void)
+	??1CIniReader@LtkUtils@@UAE@XZ @ 19 NONAME ; LtkUtils::CIniReader::~CIniReader(void)
+	??1CSetting@LtkUtils@@UAE@XZ @ 20 NONAME ; LtkUtils::CSetting::~CSetting(void)
+	??1CValue@LtkUtils@@UAE@XZ @ 21 NONAME ; LtkUtils::CValue::~CValue(void)
+	?AsBool@CSetting@LtkUtils@@QBEHXZ @ 22 NONAME ; int LtkUtils::CSetting::AsBool(void) const
+	?AsBool@CSetting@LtkUtils@@UBEHAAH@Z @ 23 NONAME ; int LtkUtils::CSetting::AsBool(int &) const
+	?AsBool@CValue@LtkUtils@@UBEHAAH@Z @ 24 NONAME ; int LtkUtils::CValue::AsBool(int &) const
+	?AsBoolL@CValue@LtkUtils@@QBEHXZ @ 25 NONAME ; int LtkUtils::CValue::AsBoolL(void) const
+	?AsInt@CSetting@LtkUtils@@QBEHXZ @ 26 NONAME ; int LtkUtils::CSetting::AsInt(void) const
+	?AsInt@CSetting@LtkUtils@@UBEHAAH@Z @ 27 NONAME ; int LtkUtils::CSetting::AsInt(int &) const
+	?AsInt@CValue@LtkUtils@@UBEHAAH@Z @ 28 NONAME ; int LtkUtils::CValue::AsInt(int &) const
+	?AsIntL@CValue@LtkUtils@@QBEHXZ @ 29 NONAME ; int LtkUtils::CValue::AsIntL(void) const
+	?GetBool@CIniFile@LtkUtils@@QAEHABVTDesC16@@@Z @ 30 NONAME ; int LtkUtils::CIniFile::GetBool(class TDesC16 const &)
+	?GetIdsL@CIniReader@LtkUtils@@QBEXAAV?$RArray@$$CBVTPtrC16@@@@@Z @ 31 NONAME ; void LtkUtils::CIniReader::GetIdsL(class RArray<class TPtrC16 const > &) const
+	?GetInt@CIniFile@LtkUtils@@QAEHABVTDesC16@@@Z @ 32 NONAME ; int LtkUtils::CIniFile::GetInt(class TDesC16 const &)
+	?GetSetting@CIniFile@LtkUtils@@QAEPAVCSetting@2@ABVTDesC16@@@Z @ 33 NONAME ; class LtkUtils::CSetting * LtkUtils::CIniFile::GetSetting(class TDesC16 const &)
+	?GetString@CIniFile@LtkUtils@@QAEABVTDesC16@@ABV3@@Z @ 34 NONAME ; class TDesC16 const & LtkUtils::CIniFile::GetString(class TDesC16 const &)
+	?GetValue@CIniReader@LtkUtils@@QBEPBVTDesC16@@ABV3@@Z @ 35 NONAME ; class TDesC16 const * LtkUtils::CIniReader::GetValue(class TDesC16 const &) const
+	?GetValuesL@CIniReader@LtkUtils@@QAEXAAV?$RPointerArray@VCValue@LtkUtils@@@@@Z @ 36 NONAME ; void LtkUtils::CIniReader::GetValuesL(class RPointerArray<class LtkUtils::CValue> &)
+	?GetValuesL@CIniReader@LtkUtils@@QBEXAAV?$RPointerArray@$$CBVCValue@LtkUtils@@@@@Z @ 37 NONAME ; void LtkUtils::CIniReader::GetValuesL(class RPointerArray<class LtkUtils::CValue const > &) const
+	?Id@CValue@LtkUtils@@QBEABVTDesC16@@XZ @ 38 NONAME ; class TDesC16 const & LtkUtils::CValue::Id(void) const
+	?IsSet@CSetting@LtkUtils@@QBEHXZ @ 39 NONAME ; int LtkUtils::CSetting::IsSet(void) const
+	?LineNumber@CValue@LtkUtils@@QBEHXZ @ 40 NONAME ; int LtkUtils::CValue::LineNumber(void) const
+	?LineNumber@TErrorContext@LtkUtils@@QAEHXZ @ 41 NONAME ; int LtkUtils::TErrorContext::LineNumber(void)
+	?NewL@CIniFile@LtkUtils@@SAPAV12@ABVTDesC16@@0@Z @ 42 NONAME ; class LtkUtils::CIniFile * LtkUtils::CIniFile::NewL(class TDesC16 const &, class TDesC16 const &)
+	?NewL@CIniReader@LtkUtils@@SAPAV12@ABVTDesC16@@VTErrorContext@2@@Z @ 43 NONAME ; class LtkUtils::CIniReader * LtkUtils::CIniReader::NewL(class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NewL@CSetting@LtkUtils@@SAPAV12@W4TSettingType@2@ABVTDesC16@@1111VTErrorContext@2@@Z @ 44 NONAME ; class LtkUtils::CSetting * LtkUtils::CSetting::NewL(enum LtkUtils::TSettingType, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NewL@CValue@LtkUtils@@SAPAV12@ABVTDesC16@@0VTErrorContext@2@@Z @ 45 NONAME ; class LtkUtils::CValue * LtkUtils::CValue::NewL(class TDesC16 const &, class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NewLC@CSetting@LtkUtils@@SAPAV12@W4TSettingType@2@ABVTDesC16@@1111VTErrorContext@2@@Z @ 46 NONAME ; class LtkUtils::CSetting * LtkUtils::CSetting::NewLC(enum LtkUtils::TSettingType, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NewLC@CValue@LtkUtils@@SAPAV12@ABVTDesC16@@0VTErrorContext@2@@Z @ 47 NONAME ; class LtkUtils::CValue * LtkUtils::CValue::NewLC(class TDesC16 const &, class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NextLine@TErrorContext@LtkUtils@@QAEXXZ @ 48 NONAME ; void LtkUtils::TErrorContext::NextLine(void)
+	?ReadIniFileL@LtkUtils@@YAXAAVRIoReadHandle@@AAVMValueHandler@1@@Z @ 49 NONAME ; void LtkUtils::ReadIniFileL(class RIoReadHandle &, class LtkUtils::MValueHandler &)
+	?ReadIniFileL@LtkUtils@@YAXABVTDesC16@@AAVMValueHandler@1@VTErrorContext@1@W4TFileNotFoundAction@1@@Z @ 50 NONAME ; void LtkUtils::ReadIniFileL(class TDesC16 const &, class LtkUtils::MValueHandler &, class LtkUtils::TErrorContext, enum LtkUtils::TFileNotFoundAction)
+	?SetL@CIniFile@LtkUtils@@QAEXABVTDesC16@@0@Z @ 51 NONAME ; void LtkUtils::CIniFile::SetL(class TDesC16 const &, class TDesC16 const &)
+	?SetL@CIniFile@LtkUtils@@QAEXABVTDesC16@@H@Z @ 52 NONAME ; void LtkUtils::CIniFile::SetL(class TDesC16 const &, int)
+	?SetL@CSetting@LtkUtils@@QAEXH@Z @ 53 NONAME ; void LtkUtils::CSetting::SetL(int)
+	?SetL@CSetting@LtkUtils@@UAEXABVTDesC16@@VTErrorContext@2@@Z @ 54 NONAME ; void LtkUtils::CSetting::SetL(class TDesC16 const &, class LtkUtils::TErrorContext)
+	?SetL@CValue@LtkUtils@@UAEXABVTDesC16@@VTErrorContext@2@@Z @ 55 NONAME ; void LtkUtils::CValue::SetL(class TDesC16 const &, class LtkUtils::TErrorContext)
+	?SetValueL@CIniReader@LtkUtils@@QAEXABVTDesC16@@0@Z @ 56 NONAME ; void LtkUtils::CIniReader::SetValueL(class TDesC16 const &, class TDesC16 const &)
+	?StringLC@TErrorContext@LtkUtils@@QAEABVTDesC16@@XZ @ 57 NONAME ; class TDesC16 const & LtkUtils::TErrorContext::StringLC(void)
+	?Value@CValue@LtkUtils@@QBEABVTDesC16@@XZ @ 58 NONAME ; class TDesC16 const & LtkUtils::CValue::Value(void) const
+	?WriteIniFileL@LtkUtils@@YAXABVTDesC16@@AAVCIniReader@1@@Z @ 59 NONAME ; void LtkUtils::WriteIniFileL(class TDesC16 const &, class LtkUtils::CIniReader &)
+	?WriteL@CIniFile@LtkUtils@@QAEXXZ @ 60 NONAME ; void LtkUtils::CIniFile::WriteL(void)
+	?Description@CSetting@LtkUtils@@QAEABVTDesC16@@XZ @ 61 NONAME ; class TDesC16 const & LtkUtils::CSetting::Description(void)
+	?Name@CSetting@LtkUtils@@QAEABVTDesC16@@XZ @ 62 NONAME ; class TDesC16 const & LtkUtils::CSetting::Name(void)
+	?ClearL@CSetting@LtkUtils@@QAEXXZ @ 63 NONAME ; void LtkUtils::CSetting::ClearL(void)
+	?RemoveValueL@CIniReader@LtkUtils@@QAEXABVTDesC16@@@Z @ 64 NONAME ; void LtkUtils::CIniReader::RemoveValueL(class TDesC16 const &)
+	?MatchifyL@LtkUtils@@YAPAVHBufC16@@PAV2@@Z @ 65 NONAME ABSENT ; class HBufC16 * LtkUtils::MatchifyL(class HBufC16 *)
+	??0RLtkBuf16@LtkUtils@@QAE@PAVHBufC16@@@Z @ 66 NONAME ; LtkUtils::RLtkBuf16::RLtkBuf16(class HBufC16 *)
+	??0RLtkBuf16@LtkUtils@@QAE@XZ @ 67 NONAME ; LtkUtils::RLtkBuf16::RLtkBuf16(void)
+	??0RLtkBuf8@LtkUtils@@QAE@PAVHBufC8@@@Z @ 68 NONAME ; LtkUtils::RLtkBuf8::RLtkBuf8(class HBufC8 *)
+	??0RLtkBuf8@LtkUtils@@QAE@XZ @ 69 NONAME ; LtkUtils::RLtkBuf8::RLtkBuf8(void)
+	?AppendFormatL@RLtkBuf16@LtkUtils@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 70 NONAME ; void LtkUtils::RLtkBuf16::AppendFormatL(class TRefByValue<class TDesC16 const >, ...)
+	?AppendFormatL@RLtkBuf8@LtkUtils@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 71 NONAME ; void LtkUtils::RLtkBuf8::AppendFormatL(class TRefByValue<class TDesC8 const >, ...)
+	?AppendL@RLtkBuf16@LtkUtils@@QAEXABVTDesC16@@@Z @ 72 NONAME ; void LtkUtils::RLtkBuf16::AppendL(class TDesC16 const &)
+	?AppendL@RLtkBuf16@LtkUtils@@QAEXABVTDesC8@@@Z @ 73 NONAME ; void LtkUtils::RLtkBuf16::AppendL(class TDesC8 const &)
+	?AppendL@RLtkBuf16@LtkUtils@@QAEXVTChar@@@Z @ 74 NONAME ; void LtkUtils::RLtkBuf16::AppendL(class TChar)
+	?AppendL@RLtkBuf8@LtkUtils@@QAEXABVTDesC16@@@Z @ 75 NONAME ; void LtkUtils::RLtkBuf8::AppendL(class TDesC16 const &)
+	?AppendL@RLtkBuf8@LtkUtils@@QAEXABVTDesC8@@@Z @ 76 NONAME ; void LtkUtils::RLtkBuf8::AppendL(class TDesC8 const &)
+	?AppendL@RLtkBuf8@LtkUtils@@QAEXVTChar@@@Z @ 77 NONAME ; void LtkUtils::RLtkBuf8::AppendL(class TChar)
+	?Assign@RLtkBuf16@LtkUtils@@QAEXPAVHBufC16@@@Z @ 78 NONAME ; void LtkUtils::RLtkBuf16::Assign(class HBufC16 *)
+	?Assign@RLtkBuf8@LtkUtils@@QAEXPAVHBufC8@@@Z @ 79 NONAME ; void LtkUtils::RLtkBuf8::Assign(class HBufC8 *)
+	?Close@RLtkBuf16@LtkUtils@@QAEXXZ @ 80 NONAME ; void LtkUtils::RLtkBuf16::Close(void)
+	?Close@RLtkBuf8@LtkUtils@@QAEXXZ @ 81 NONAME ; void LtkUtils::RLtkBuf8::Close(void)
+	?Create@RLtkBuf16@LtkUtils@@QAEHH@Z @ 82 NONAME ; int LtkUtils::RLtkBuf16::Create(int)
+	?Create@RLtkBuf8@LtkUtils@@QAEHH@Z @ 83 NONAME ; int LtkUtils::RLtkBuf8::Create(int)
+	?CreateL@RLtkBuf16@LtkUtils@@QAEXH@Z @ 84 NONAME ; void LtkUtils::RLtkBuf16::CreateL(int)
+	?CreateL@RLtkBuf8@LtkUtils@@QAEXH@Z @ 85 NONAME ; void LtkUtils::RLtkBuf8::CreateL(int)
+	?CreateLC@RLtkBuf16@LtkUtils@@QAEXH@Z @ 86 NONAME ; void LtkUtils::RLtkBuf16::CreateLC(int)
+	?CreateLC@RLtkBuf8@LtkUtils@@QAEXH@Z @ 87 NONAME ; void LtkUtils::RLtkBuf8::CreateLC(int)
+	?CreateMax@RLtkBuf16@LtkUtils@@QAEHH@Z @ 88 NONAME ; int LtkUtils::RLtkBuf16::CreateMax(int)
+	?CreateMax@RLtkBuf8@LtkUtils@@QAEHH@Z @ 89 NONAME ; int LtkUtils::RLtkBuf8::CreateMax(int)
+	?CreateMaxL@RLtkBuf16@LtkUtils@@QAEXH@Z @ 90 NONAME ; void LtkUtils::RLtkBuf16::CreateMaxL(int)
+	?CreateMaxL@RLtkBuf8@LtkUtils@@QAEXH@Z @ 91 NONAME ; void LtkUtils::RLtkBuf8::CreateMaxL(int)
+	?HasPrefix@LtkUtils@@YAHABVTDesC16@@0@Z @ 92 NONAME ; int LtkUtils::HasPrefix(class TDesC16 const &, class TDesC16 const &)
+	?HasPrefix@LtkUtils@@YAHABVTDesC8@@0@Z @ 93 NONAME ; int LtkUtils::HasPrefix(class TDesC8 const &, class TDesC8 const &)
+	?HexLex@LtkUtils@@YAHAAVTLex16@@AAI@Z @ 94 NONAME ; int LtkUtils::HexLex(class TLex16 &, unsigned int &)
+	?HexLex@LtkUtils@@YAHAAVTLex8@@AAI@Z @ 95 NONAME ; int LtkUtils::HexLex(class TLex8 &, unsigned int &)
+	?HexLexL@LtkUtils@@YAIAAVTLex8@@@Z @ 96 NONAME ; unsigned int LtkUtils::HexLexL(class TLex8 &)
+	?ReAlloc@RLtkBuf16@LtkUtils@@QAEHH@Z @ 97 NONAME ; int LtkUtils::RLtkBuf16::ReAlloc(int)
+	?ReAlloc@RLtkBuf8@LtkUtils@@QAEHH@Z @ 98 NONAME ; int LtkUtils::RLtkBuf8::ReAlloc(int)
+	?ReAllocL@RLtkBuf16@LtkUtils@@QAEXH@Z @ 99 NONAME ; void LtkUtils::RLtkBuf16::ReAllocL(int)
+	?ReAllocL@RLtkBuf8@LtkUtils@@QAEXH@Z @ 100 NONAME ; void LtkUtils::RLtkBuf8::ReAllocL(int)
+	?ReplaceAllL@RLtkBuf16@LtkUtils@@QAEXABVTDesC16@@0@Z @ 101 NONAME ; void LtkUtils::RLtkBuf16::ReplaceAllL(class TDesC16 const &, class TDesC16 const &)
+	?ReplaceAllL@RLtkBuf8@LtkUtils@@QAEXABVTDesC8@@0@Z @ 102 NONAME ; void LtkUtils::RLtkBuf8::ReplaceAllL(class TDesC8 const &, class TDesC8 const &)
+	?ReplaceL@RLtkBuf16@LtkUtils@@QAEXHHABVTDesC16@@@Z @ 103 NONAME ; void LtkUtils::RLtkBuf16::ReplaceL(int, int, class TDesC16 const &)
+	?ReplaceL@RLtkBuf8@LtkUtils@@QAEXHHABVTDesC8@@@Z @ 104 NONAME ; void LtkUtils::RLtkBuf8::ReplaceL(int, int, class TDesC8 const &)
+	?ReserveExtra@RLtkBuf16@LtkUtils@@QAEHH@Z @ 105 NONAME ; int LtkUtils::RLtkBuf16::ReserveExtra(int)
+	?ReserveExtra@RLtkBuf8@LtkUtils@@QAEHH@Z @ 106 NONAME ; int LtkUtils::RLtkBuf8::ReserveExtra(int)
+	?ReserveExtraL@RLtkBuf16@LtkUtils@@QAEXH@Z @ 107 NONAME ; void LtkUtils::RLtkBuf16::ReserveExtraL(int)
+	?ReserveExtraL@RLtkBuf8@LtkUtils@@QAEXH@Z @ 108 NONAME ; void LtkUtils::RLtkBuf8::ReserveExtraL(int)
+	?ToHBuf@RLtkBuf16@LtkUtils@@QAEPAVHBufC16@@XZ @ 109 NONAME ; class HBufC16 * LtkUtils::RLtkBuf16::ToHBuf(void)
+	?ToHBuf@RLtkBuf8@LtkUtils@@QAEPAVHBufC8@@XZ @ 110 NONAME ; class HBufC8 * LtkUtils::RLtkBuf8::ToHBuf(void)
+	??1CHalAttribute@LtkUtils@@UAE@XZ @ 111 NONAME ; LtkUtils::CHalAttribute::~CHalAttribute(void)
+	?GetHalInfoL@LtkUtils@@YAXAAV?$RPointerArray@VCHalAttribute@LtkUtils@@@@@Z @ 112 NONAME ; void LtkUtils::GetHalInfoL(class RPointerArray<class LtkUtils::CHalAttribute> &)
+	?GetHalInfoL@LtkUtils@@YAPAVCHalAttribute@1@HH@Z @ 113 NONAME ; class LtkUtils::CHalAttribute * LtkUtils::GetHalInfoL(int, int)
+	?GetHalInfoL@LtkUtils@@YAPAVCHalAttribute@1@H@Z @ 114 NONAME ; class LtkUtils::CHalAttribute * LtkUtils::GetHalInfoL(int)
+	?GetHalInfoForValueL@LtkUtils@@YAPAVCHalAttribute@1@HHH@Z @ 115 NONAME ; class LtkUtils::CHalAttribute * LtkUtils::GetHalInfoForValueL(int, int, int)
+	?GetHBuf@RLtkBuf8@LtkUtils@@QBEPAVHBufC8@@XZ @ 116 NONAME ; class HBufC8 * LtkUtils::RLtkBuf8::GetHBuf(void) const
+	?GetHBuf@RLtkBuf16@LtkUtils@@QBEPAVHBufC16@@XZ @ 117 NONAME ; class HBufC16 * LtkUtils::RLtkBuf16::GetHBuf(void) const
+	?CopyAsUtf8L@RLtkBuf8@LtkUtils@@QAEXABVTDesC16@@@Z @ 118 NONAME ; void LtkUtils::RLtkBuf8::CopyAsUtf8L(class TDesC16 const &)
+	?Utf8L@LtkUtils@@YAPAVHBufC8@@ABVTDesC16@@@Z @ 119 NONAME ; class HBufC8 * LtkUtils::Utf8L(class TDesC16 const &)
+	?AppendUtf8L@RLtkBuf16@LtkUtils@@QAEXABVTDesC8@@AAH@Z @ 120 NONAME ; void LtkUtils::RLtkBuf16::AppendUtf8L(class TDesC8 const &, int &)
+	?AppendUtf8L@RLtkBuf16@LtkUtils@@QAEXABVTDesC8@@@Z @ 121 NONAME ; void LtkUtils::RLtkBuf16::AppendUtf8L(class TDesC8 const &)
+	?DecodeUtf8L@LtkUtils@@YAPAVHBufC16@@ABVTDesC8@@@Z @ 122 NONAME ; class HBufC16 * LtkUtils::DecodeUtf8L(class TDesC8 const &)
+	?CopyFromUtf8L@RLtkBuf16@LtkUtils@@QAEXABVTDesC8@@@Z @ 123 NONAME ; void LtkUtils::RLtkBuf16::CopyFromUtf8L(class TDesC8 const &)
+	?FinalizeUtf8@RLtkBuf16@LtkUtils@@QAEXAAH@Z @ 124 NONAME ; void LtkUtils::RLtkBuf16::FinalizeUtf8(int &)
+	?FinalizeUtf8@RLtkBuf16@LtkUtils@@QAEHXZ @ 125 NONAME ; int LtkUtils::RLtkBuf16::FinalizeUtf8(void)
+	??0RAllocatorHelper@LtkUtils@@QAE@XZ @ 126 NONAME ; LtkUtils::RAllocatorHelper::RAllocatorHelper(void)
+	?Open@RProxyAllocatorHelper@LtkUtils@@QAEHAAVRMemoryAccess@@I@Z @ 127 NONAME ; int LtkUtils::RProxyAllocatorHelper::Open(class RMemoryAccess &, unsigned int)
+	?Open@RAllocatorHelper@LtkUtils@@QAEHPAVRAllocator@@@Z @ 128 NONAME ; int LtkUtils::RAllocatorHelper::Open(class RAllocator *)
+	??0RProxyAllocatorHelper@LtkUtils@@QAE@XZ @ 129 NONAME ; LtkUtils::RProxyAllocatorHelper::RProxyAllocatorHelper(void)
+	?Close@RAllocatorHelper@LtkUtils@@UAEXXZ @ 130 NONAME ; void LtkUtils::RAllocatorHelper::Close(void)
+	?SetCellNestingLevel@RAllocatorHelper@LtkUtils@@QAEHPAXH@Z @ 131 NONAME ; int LtkUtils::RAllocatorHelper::SetCellNestingLevel(void *, int)
+	?AllocationCount@RAllocatorHelper@LtkUtils@@QAEHXZ @ 132 NONAME ; int LtkUtils::RAllocatorHelper::AllocationCount(void)
+	?CommittedSize@RAllocatorHelper@LtkUtils@@QAEHXZ @ 133 NONAME ; int LtkUtils::RAllocatorHelper::CommittedSize(void)
+	?RefreshDetails@RAllocatorHelper@LtkUtils@@QAEHXZ @ 134 NONAME ; int LtkUtils::RAllocatorHelper::RefreshDetails(void)
+	?AllocatedSize@RAllocatorHelper@LtkUtils@@QAEHXZ @ 135 NONAME ; int LtkUtils::RAllocatorHelper::AllocatedSize(void)
+	?OpenChunkHeap@RProxyAllocatorHelper@LtkUtils@@QAEHAAVRMemoryAccess@@PAX@Z @ 136 NONAME ; int LtkUtils::RProxyAllocatorHelper::OpenChunkHeap(class RMemoryAccess &, void *)
+	?MaxCommittedSize@RAllocatorHelper@LtkUtils@@QAEHXZ @ 137 NONAME ; int LtkUtils::RAllocatorHelper::MaxCommittedSize(void)
+	?AllocCountForCell@RAllocatorHelper@LtkUtils@@QBEHPAX@Z @ 138 NONAME ; int LtkUtils::RAllocatorHelper::AllocCountForCell(void *) const
+	?CommittedFreeSpace@RAllocatorHelper@LtkUtils@@QAEHXZ @ 139 NONAME ; int LtkUtils::RAllocatorHelper::CommittedFreeSpace(void)
+	?CountUnusedPages@RAllocatorHelper@LtkUtils@@QAEHXZ @ 140 NONAME ; int LtkUtils::RAllocatorHelper::CountUnusedPages(void)
+	?Walk@RAllocatorHelper@LtkUtils@@QAEHP6AHPAXW4TCellType@12@KH@Z0@Z @ 141 NONAME ; int LtkUtils::RAllocatorHelper::Walk(int (*)(void *, enum LtkUtils::RAllocatorHelper::TCellType, unsigned long, int), void *)
+	?MinCommittedSize@RAllocatorHelper@LtkUtils@@QAEHXZ @ 142 NONAME ; int LtkUtils::RAllocatorHelper::MinCommittedSize(void)
+	?AllocatorAddress@RAllocatorHelper@LtkUtils@@QBEKXZ @ 143 NONAME ; unsigned long LtkUtils::RAllocatorHelper::AllocatorAddress(void) const
+	?GetCellNestingLevel@RAllocatorHelper@LtkUtils@@QAEHPAXAAH@Z @ 144 NONAME ; int LtkUtils::RAllocatorHelper::GetCellNestingLevel(void *, int &)
+	?Walk@RAllocatorHelper@LtkUtils@@QAEHP6AHAAV12@PAXW4TCellType@12@KH@Z1@Z @ 145 NONAME ; int LtkUtils::RAllocatorHelper::Walk(int (*)(class LtkUtils::RAllocatorHelper &, void *, enum LtkUtils::RAllocatorHelper::TCellType, unsigned long, int), void *)
+	?Walk@RAllocatorHelper@LtkUtils@@QAEHP6AHAAV12@PAXW4TExtendedCellType@12@KH@Z1@Z @ 146 NONAME ; int LtkUtils::RAllocatorHelper::Walk(int (*)(class LtkUtils::RAllocatorHelper &, void *, enum LtkUtils::RAllocatorHelper::TExtendedCellType, unsigned long, int), void *)
+	?SizeForCellType@RAllocatorHelper@LtkUtils@@QAEHW4TExtendedCellType@12@@Z @ 147 NONAME ; int LtkUtils::RAllocatorHelper::SizeForCellType(enum LtkUtils::RAllocatorHelper::TExtendedCellType)
+	?CountForCellType@RAllocatorHelper@LtkUtils@@QAEHW4TExtendedCellType@12@@Z @ 148 NONAME ; int LtkUtils::RAllocatorHelper::CountForCellType(enum LtkUtils::RAllocatorHelper::TExtendedCellType)
+	?Close@RProxyAllocatorHelper@LtkUtils@@UAEXXZ @ 149 NONAME ; void LtkUtils::RProxyAllocatorHelper::Close(void)
+	?AllocatorIsUdeb@RAllocatorHelper@LtkUtils@@QBEHXZ @ 150 NONAME ; int LtkUtils::RAllocatorHelper::AllocatorIsUdeb(void) const
+	?FormatSize@LtkUtils@@YAXAAVTDes8@@_J@Z @ 151 NONAME ; void LtkUtils::FormatSize(class TDes8 &, long long)
+	?FormatSize@LtkUtils@@YAXAAVTDes16@@_J@Z @ 152 NONAME ; void LtkUtils::FormatSize(class TDes16 &, long long)
+	?Description@RAllocatorHelper@LtkUtils@@QBEABVTDesC16@@XZ @ 153 NONAME ; class TDesC16 const & LtkUtils::RAllocatorHelper::Description(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/bwins/ltkutils.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,184 @@
+EXPORTS
+	?MakeHeapCellInvisible@LtkUtils@@YAXPAX@Z @ 1 NONAME ; void LtkUtils::MakeHeapCellInvisible(void *)
+	?InjectRawKeyEvent@LtkUtils@@YAHHHH@Z @ 2 NONAME ; int LtkUtils::InjectRawKeyEvent(int, int, int)
+	?HexDumpL@LtkUtils@@YAPAVHBufC16@@ABVTDesC8@@@Z @ 3 NONAME ; class HBufC16 * LtkUtils::HexDumpL(class TDesC8 const &)
+	?HexDumpToOutput@LtkUtils@@YAXABVTDesC8@@AAVRIoWriteHandle@@@Z @ 4 NONAME ; void LtkUtils::HexDumpToOutput(class TDesC8 const &, class RIoWriteHandle &)
+	?HexDumpToOutput@LtkUtils@@YAXABVTDesC8@@AAVRIoWriteHandle@@AAH@Z @ 5 NONAME ; void LtkUtils::HexDumpToOutput(class TDesC8 const &, class RIoWriteHandle &, int &)
+	?W32CrackL@LtkUtils@@YAXXZ @ 6 NONAME ; void LtkUtils::W32CrackL(void)
+	?GetPubSubData@LtkUtils@@YAPBUSKeyPair@1@AAH@Z @ 7 NONAME ABSENT ; struct LtkUtils::SKeyPair const * LtkUtils::GetPubSubData(int &)
+	?HexDumpToRDebug@LtkUtils@@YAXABVTDesC8@@@Z @ 8 NONAME ; void LtkUtils::HexDumpToRDebug(class TDesC8 const &)
+	?HexDumpToRDebug@LtkUtils@@YAXABVTDesC8@@AAH@Z @ 9 NONAME ; void LtkUtils::HexDumpToRDebug(class TDesC8 const &, int &)
+	?Rez8L@LtkUtils@@YAPAVHBufC8@@ABVTDesC16@@PAVRFs@@PAPAVHBufC16@@@Z @ 10 NONAME ; class HBufC8 * LtkUtils::Rez8L(class TDesC16 const &, class RFs *, class HBufC16 * *)
+	?RezL@LtkUtils@@YAPAVHBufC16@@ABVTDesC16@@PAVRFs@@PAPAV2@@Z @ 11 NONAME ; class HBufC16 * LtkUtils::RezL(class TDesC16 const &, class RFs *, class HBufC16 * *)
+	?Rez8LC@LtkUtils@@YAPAVHBufC8@@ABVTDesC16@@PAVRFs@@PAPAVHBufC16@@@Z @ 12 NONAME ; class HBufC8 * LtkUtils::Rez8LC(class TDesC16 const &, class RFs *, class HBufC16 * *)
+	?RezLC@LtkUtils@@YAPAVHBufC16@@ABVTDesC16@@PAVRFs@@PAPAV2@@Z @ 13 NONAME ; class HBufC16 * LtkUtils::RezLC(class TDesC16 const &, class RFs *, class HBufC16 * *)
+	?CopyToClipboardL@LtkUtils@@YAXABVTDesC16@@PAVRFs@@@Z @ 14 NONAME ; void LtkUtils::CopyToClipboardL(class TDesC16 const &, class RFs *)
+	?GetFromClipboardL@LtkUtils@@YAPAVHBufC16@@PAVRFs@@@Z @ 15 NONAME ; class HBufC16 * LtkUtils::GetFromClipboardL(class RFs *)
+	?GetFriendlyThreadName@LtkUtils@@YAXVRThread@@AAV?$TBuf@$0BAA@@@@Z @ 16 NONAME ; void LtkUtils::GetFriendlyThreadName(class RThread, class TBuf<256> &)
+	?MakeThreadNameFriendly@LtkUtils@@YAXAAV?$TBuf@$0BAA@@@@Z @ 17 NONAME ; void LtkUtils::MakeThreadNameFriendly(class TBuf<256> &)
+	?RawPrint@LtkUtils@@YAXABVTDesC8@@@Z @ 18 NONAME ; void LtkUtils::RawPrint(class TDesC8 const &)
+	?GetFriendlyProcessName@LtkUtils@@YAXABVRProcess@@AAVTDes16@@@Z @ 19 NONAME ; void LtkUtils::GetFriendlyProcessName(class RProcess const &, class TDes16 &)
+	?MakeProcessNameFriendly@LtkUtils@@YAXAAVTDes16@@@Z @ 20 NONAME ; void LtkUtils::MakeProcessNameFriendly(class TDes16 &)
+	?W32CrackIsEnabled@LtkUtils@@YAHXZ @ 21 NONAME ; int LtkUtils::W32CrackIsEnabled(void)
+	?HexLexL@LtkUtils@@YAIAAVTLex16@@@Z @ 22 NONAME ; unsigned int LtkUtils::HexLexL(class TLex16 &)
+	?ReplaceText@LtkUtils@@YAHAAVTDes16@@ABVTDesC16@@1@Z @ 23 NONAME ; int LtkUtils::ReplaceText(class TDes16 &, class TDesC16 const &, class TDesC16 const &)
+	??0TErrorContext@LtkUtils@@QAE@ABVTDesC16@@@Z @ 24 NONAME ; LtkUtils::TErrorContext::TErrorContext(class TDesC16 const &)
+	??0TErrorContext@LtkUtils@@QAE@XZ @ 25 NONAME ; LtkUtils::TErrorContext::TErrorContext(void)
+	??1CIniFile@LtkUtils@@UAE@XZ @ 26 NONAME ; LtkUtils::CIniFile::~CIniFile(void)
+	??1CIniReader@LtkUtils@@UAE@XZ @ 27 NONAME ; LtkUtils::CIniReader::~CIniReader(void)
+	??1CSetting@LtkUtils@@UAE@XZ @ 28 NONAME ; LtkUtils::CSetting::~CSetting(void)
+	??1CValue@LtkUtils@@UAE@XZ @ 29 NONAME ; LtkUtils::CValue::~CValue(void)
+	?AsBool@CSetting@LtkUtils@@QBEHXZ @ 30 NONAME ; int LtkUtils::CSetting::AsBool(void) const
+	?AsBool@CSetting@LtkUtils@@UBEHAAH@Z @ 31 NONAME ; int LtkUtils::CSetting::AsBool(int &) const
+	?AsBool@CValue@LtkUtils@@UBEHAAH@Z @ 32 NONAME ; int LtkUtils::CValue::AsBool(int &) const
+	?AsBoolL@CValue@LtkUtils@@QBEHXZ @ 33 NONAME ; int LtkUtils::CValue::AsBoolL(void) const
+	?AsInt@CSetting@LtkUtils@@QBEHXZ @ 34 NONAME ; int LtkUtils::CSetting::AsInt(void) const
+	?AsInt@CSetting@LtkUtils@@UBEHAAH@Z @ 35 NONAME ; int LtkUtils::CSetting::AsInt(int &) const
+	?AsInt@CValue@LtkUtils@@UBEHAAH@Z @ 36 NONAME ; int LtkUtils::CValue::AsInt(int &) const
+	?AsIntL@CValue@LtkUtils@@QBEHXZ @ 37 NONAME ; int LtkUtils::CValue::AsIntL(void) const
+	?GetBool@CIniFile@LtkUtils@@QAEHABVTDesC16@@@Z @ 38 NONAME ; int LtkUtils::CIniFile::GetBool(class TDesC16 const &)
+	?GetIdsL@CIniReader@LtkUtils@@QBEXAAV?$RArray@$$CBVTPtrC16@@@@@Z @ 39 NONAME ; void LtkUtils::CIniReader::GetIdsL(class RArray<class TPtrC16 const > &) const
+	?GetInt@CIniFile@LtkUtils@@QAEHABVTDesC16@@@Z @ 40 NONAME ; int LtkUtils::CIniFile::GetInt(class TDesC16 const &)
+	?GetSetting@CIniFile@LtkUtils@@QAEPAVCSetting@2@ABVTDesC16@@@Z @ 41 NONAME ; class LtkUtils::CSetting * LtkUtils::CIniFile::GetSetting(class TDesC16 const &)
+	?GetString@CIniFile@LtkUtils@@QAEABVTDesC16@@ABV3@@Z @ 42 NONAME ; class TDesC16 const & LtkUtils::CIniFile::GetString(class TDesC16 const &)
+	?GetValue@CIniReader@LtkUtils@@QBEPBVTDesC16@@ABV3@@Z @ 43 NONAME ; class TDesC16 const * LtkUtils::CIniReader::GetValue(class TDesC16 const &) const
+	?GetValuesL@CIniReader@LtkUtils@@QAEXAAV?$RPointerArray@VCValue@LtkUtils@@@@@Z @ 44 NONAME ; void LtkUtils::CIniReader::GetValuesL(class RPointerArray<class LtkUtils::CValue> &)
+	?GetValuesL@CIniReader@LtkUtils@@QBEXAAV?$RPointerArray@$$CBVCValue@LtkUtils@@@@@Z @ 45 NONAME ; void LtkUtils::CIniReader::GetValuesL(class RPointerArray<class LtkUtils::CValue const > &) const
+	?Id@CValue@LtkUtils@@QBEABVTDesC16@@XZ @ 46 NONAME ; class TDesC16 const & LtkUtils::CValue::Id(void) const
+	?IsSet@CSetting@LtkUtils@@QBEHXZ @ 47 NONAME ; int LtkUtils::CSetting::IsSet(void) const
+	?LineNumber@CValue@LtkUtils@@QBEHXZ @ 48 NONAME ; int LtkUtils::CValue::LineNumber(void) const
+	?LineNumber@TErrorContext@LtkUtils@@QAEHXZ @ 49 NONAME ; int LtkUtils::TErrorContext::LineNumber(void)
+	?NewL@CIniFile@LtkUtils@@SAPAV12@ABVTDesC16@@0@Z @ 50 NONAME ; class LtkUtils::CIniFile * LtkUtils::CIniFile::NewL(class TDesC16 const &, class TDesC16 const &)
+	?NewL@CIniReader@LtkUtils@@SAPAV12@ABVTDesC16@@VTErrorContext@2@@Z @ 51 NONAME ; class LtkUtils::CIniReader * LtkUtils::CIniReader::NewL(class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NewL@CSetting@LtkUtils@@SAPAV12@W4TSettingType@2@ABVTDesC16@@1111VTErrorContext@2@@Z @ 52 NONAME ; class LtkUtils::CSetting * LtkUtils::CSetting::NewL(enum LtkUtils::TSettingType, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NewL@CValue@LtkUtils@@SAPAV12@ABVTDesC16@@0VTErrorContext@2@@Z @ 53 NONAME ; class LtkUtils::CValue * LtkUtils::CValue::NewL(class TDesC16 const &, class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NewLC@CSetting@LtkUtils@@SAPAV12@W4TSettingType@2@ABVTDesC16@@1111VTErrorContext@2@@Z @ 54 NONAME ; class LtkUtils::CSetting * LtkUtils::CSetting::NewLC(enum LtkUtils::TSettingType, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NewLC@CValue@LtkUtils@@SAPAV12@ABVTDesC16@@0VTErrorContext@2@@Z @ 55 NONAME ; class LtkUtils::CValue * LtkUtils::CValue::NewLC(class TDesC16 const &, class TDesC16 const &, class LtkUtils::TErrorContext)
+	?NextLine@TErrorContext@LtkUtils@@QAEXXZ @ 56 NONAME ; void LtkUtils::TErrorContext::NextLine(void)
+	?ReadIniFileL@LtkUtils@@YAXAAVRIoReadHandle@@AAVMValueHandler@1@@Z @ 57 NONAME ; void LtkUtils::ReadIniFileL(class RIoReadHandle &, class LtkUtils::MValueHandler &)
+	?ReadIniFileL@LtkUtils@@YAXABVTDesC16@@AAVMValueHandler@1@VTErrorContext@1@W4TFileNotFoundAction@1@@Z @ 58 NONAME ; void LtkUtils::ReadIniFileL(class TDesC16 const &, class LtkUtils::MValueHandler &, class LtkUtils::TErrorContext, enum LtkUtils::TFileNotFoundAction)
+	?SetL@CIniFile@LtkUtils@@QAEXABVTDesC16@@0@Z @ 59 NONAME ; void LtkUtils::CIniFile::SetL(class TDesC16 const &, class TDesC16 const &)
+	?SetL@CIniFile@LtkUtils@@QAEXABVTDesC16@@H@Z @ 60 NONAME ; void LtkUtils::CIniFile::SetL(class TDesC16 const &, int)
+	?SetL@CSetting@LtkUtils@@QAEXH@Z @ 61 NONAME ; void LtkUtils::CSetting::SetL(int)
+	?SetL@CSetting@LtkUtils@@UAEXABVTDesC16@@VTErrorContext@2@@Z @ 62 NONAME ; void LtkUtils::CSetting::SetL(class TDesC16 const &, class LtkUtils::TErrorContext)
+	?SetL@CValue@LtkUtils@@UAEXABVTDesC16@@VTErrorContext@2@@Z @ 63 NONAME ; void LtkUtils::CValue::SetL(class TDesC16 const &, class LtkUtils::TErrorContext)
+	?SetValueL@CIniReader@LtkUtils@@QAEXABVTDesC16@@0@Z @ 64 NONAME ; void LtkUtils::CIniReader::SetValueL(class TDesC16 const &, class TDesC16 const &)
+	?StringLC@TErrorContext@LtkUtils@@QAEABVTDesC16@@XZ @ 65 NONAME ; class TDesC16 const & LtkUtils::TErrorContext::StringLC(void)
+	?Value@CValue@LtkUtils@@QBEABVTDesC16@@XZ @ 66 NONAME ; class TDesC16 const & LtkUtils::CValue::Value(void) const
+	?WriteIniFileL@LtkUtils@@YAXABVTDesC16@@AAVCIniReader@1@@Z @ 67 NONAME ; void LtkUtils::WriteIniFileL(class TDesC16 const &, class LtkUtils::CIniReader &)
+	?WriteL@CIniFile@LtkUtils@@QAEXXZ @ 68 NONAME ; void LtkUtils::CIniFile::WriteL(void)
+	?Description@CSetting@LtkUtils@@QAEABVTDesC16@@XZ @ 69 NONAME ; class TDesC16 const & LtkUtils::CSetting::Description(void)
+	?Name@CSetting@LtkUtils@@QAEABVTDesC16@@XZ @ 70 NONAME ; class TDesC16 const & LtkUtils::CSetting::Name(void)
+	?ClearL@CSetting@LtkUtils@@QAEXXZ @ 71 NONAME ; void LtkUtils::CSetting::ClearL(void)
+	?RemoveValueL@CIniReader@LtkUtils@@QAEXABVTDesC16@@@Z @ 72 NONAME ; void LtkUtils::CIniReader::RemoveValueL(class TDesC16 const &)
+	?MatchifyL@LtkUtils@@YAPAVHBufC16@@PAV2@@Z @ 73 NONAME ABSENT ; class HBufC16 * LtkUtils::MatchifyL(class HBufC16 *)
+	??1CBsymFile@LtkUtils@@UAE@XZ @ 74 NONAME ; LtkUtils::CBsymFile::~CBsymFile(void)
+	?LookupL@CBsymFile@LtkUtils@@QAE?AVTPtrC16@@K@Z @ 75 NONAME ; class TPtrC16 LtkUtils::CBsymFile::LookupL(unsigned long)
+	?NewL@CBsymFile@LtkUtils@@SAPAV12@AAVRFs@@ABVTDesC16@@@Z @ 76 NONAME ; class LtkUtils::CBsymFile * LtkUtils::CBsymFile::NewL(class RFs &, class TDesC16 const &)
+	?HasPrefix@LtkUtils@@YAHABVTDesC16@@0@Z @ 77 NONAME ; int LtkUtils::HasPrefix(class TDesC16 const &, class TDesC16 const &)
+	?HasPrefix@LtkUtils@@YAHABVTDesC8@@0@Z @ 78 NONAME ; int LtkUtils::HasPrefix(class TDesC8 const &, class TDesC8 const &)
+	?HexLex@LtkUtils@@YAHAAVTLex16@@AAI@Z @ 79 NONAME ; int LtkUtils::HexLex(class TLex16 &, unsigned int &)
+	?HexLex@LtkUtils@@YAHAAVTLex8@@AAI@Z @ 80 NONAME ; int LtkUtils::HexLex(class TLex8 &, unsigned int &)
+	?HexLexL@LtkUtils@@YAIAAVTLex8@@@Z @ 81 NONAME ; unsigned int LtkUtils::HexLexL(class TLex8 &)
+	??1CMapFile@LtkUtils@@UAE@XZ @ 82 NONAME ; LtkUtils::CMapFile::~CMapFile(void)
+	?NewL@CMapFile@LtkUtils@@SAPAV12@AAVRFs@@ABVTDesC16@@@Z @ 83 NONAME ; class LtkUtils::CMapFile * LtkUtils::CMapFile::NewL(class RFs &, class TDesC16 const &)
+	?Lookup@CMapFile@LtkUtils@@QAEXKAAVTDes16@@@Z @ 84 NONAME ; void LtkUtils::CMapFile::Lookup(unsigned long, class TDes16 &)
+	??0CSymbolics@LtkUtils@@QAE@AAVRFs@@@Z @ 85 NONAME ; LtkUtils::CSymbolics::CSymbolics(class RFs &)
+	??1CSymbolics@LtkUtils@@UAE@XZ @ 86 NONAME ; LtkUtils::CSymbolics::~CSymbolics(void)
+	?AddBsymFileL@CSymbolics@LtkUtils@@QAEXABVTDesC16@@@Z @ 87 NONAME ; void LtkUtils::CSymbolics::AddBsymFileL(class TDesC16 const &)
+	?AddMapFileL@CSymbolics@LtkUtils@@QAEXABVTDesC16@@@Z @ 88 NONAME ; void LtkUtils::CSymbolics::AddMapFileL(class TDesC16 const &)
+	?LookupL@CSymbolics@LtkUtils@@QAE?AVTPtrC16@@ABVTDesC16@@K@Z @ 89 NONAME ; class TPtrC16 LtkUtils::CSymbolics::LookupL(class TDesC16 const &, unsigned long)
+	?LookupL@CSymbolics@LtkUtils@@QAE?AVTPtrC16@@K@Z @ 90 NONAME ; class TPtrC16 LtkUtils::CSymbolics::LookupL(unsigned long)
+	?SetFallbackMapFileDirL@CSymbolics@LtkUtils@@QAEXABVTDesC16@@@Z @ 91 NONAME ; void LtkUtils::CSymbolics::SetFallbackMapFileDirL(class TDesC16 const &)
+	?AddMapFileL@CSymbolics@LtkUtils@@QAEXPAVCMapFile@2@@Z @ 92 NONAME ; void LtkUtils::CSymbolics::AddMapFileL(class LtkUtils::CMapFile *)
+	?GetFileNameL@CMapFile@LtkUtils@@QBEXAAVTDes16@@@Z @ 93 NONAME ; void LtkUtils::CMapFile::GetFileNameL(class TDes16 &) const
+	?Breakpoint@LtkUtils@@YAXXZ @ 94 NONAME ; void LtkUtils::Breakpoint(void)
+	?BreakpointAddr@LtkUtils@@YAKXZ @ 95 NONAME ; unsigned long LtkUtils::BreakpointAddr(void)
+	??0RLtkBuf16@LtkUtils@@QAE@PAVHBufC16@@@Z @ 96 NONAME ; LtkUtils::RLtkBuf16::RLtkBuf16(class HBufC16 *)
+	??0RLtkBuf16@LtkUtils@@QAE@XZ @ 97 NONAME ; LtkUtils::RLtkBuf16::RLtkBuf16(void)
+	??0RLtkBuf8@LtkUtils@@QAE@PAVHBufC8@@@Z @ 98 NONAME ; LtkUtils::RLtkBuf8::RLtkBuf8(class HBufC8 *)
+	??0RLtkBuf8@LtkUtils@@QAE@XZ @ 99 NONAME ; LtkUtils::RLtkBuf8::RLtkBuf8(void)
+	?AppendFormatL@RLtkBuf16@LtkUtils@@QAAXV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 100 NONAME ; void LtkUtils::RLtkBuf16::AppendFormatL(class TRefByValue<class TDesC16 const >, ...)
+	?AppendFormatL@RLtkBuf8@LtkUtils@@QAAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 101 NONAME ; void LtkUtils::RLtkBuf8::AppendFormatL(class TRefByValue<class TDesC8 const >, ...)
+	?AppendL@RLtkBuf16@LtkUtils@@QAEXABVTDesC16@@@Z @ 102 NONAME ; void LtkUtils::RLtkBuf16::AppendL(class TDesC16 const &)
+	?AppendL@RLtkBuf16@LtkUtils@@QAEXABVTDesC8@@@Z @ 103 NONAME ; void LtkUtils::RLtkBuf16::AppendL(class TDesC8 const &)
+	?AppendL@RLtkBuf8@LtkUtils@@QAEXABVTDesC16@@@Z @ 104 NONAME ; void LtkUtils::RLtkBuf8::AppendL(class TDesC16 const &)
+	?AppendL@RLtkBuf8@LtkUtils@@QAEXABVTDesC8@@@Z @ 105 NONAME ; void LtkUtils::RLtkBuf8::AppendL(class TDesC8 const &)
+	?Assign@RLtkBuf16@LtkUtils@@QAEXPAVHBufC16@@@Z @ 106 NONAME ; void LtkUtils::RLtkBuf16::Assign(class HBufC16 *)
+	?Assign@RLtkBuf8@LtkUtils@@QAEXPAVHBufC8@@@Z @ 107 NONAME ; void LtkUtils::RLtkBuf8::Assign(class HBufC8 *)
+	?Close@RLtkBuf16@LtkUtils@@QAEXXZ @ 108 NONAME ; void LtkUtils::RLtkBuf16::Close(void)
+	?Close@RLtkBuf8@LtkUtils@@QAEXXZ @ 109 NONAME ; void LtkUtils::RLtkBuf8::Close(void)
+	?Create@RLtkBuf16@LtkUtils@@QAEHH@Z @ 110 NONAME ; int LtkUtils::RLtkBuf16::Create(int)
+	?Create@RLtkBuf8@LtkUtils@@QAEHH@Z @ 111 NONAME ; int LtkUtils::RLtkBuf8::Create(int)
+	?CreateL@RLtkBuf16@LtkUtils@@QAEXH@Z @ 112 NONAME ; void LtkUtils::RLtkBuf16::CreateL(int)
+	?CreateL@RLtkBuf8@LtkUtils@@QAEXH@Z @ 113 NONAME ; void LtkUtils::RLtkBuf8::CreateL(int)
+	?CreateMax@RLtkBuf16@LtkUtils@@QAEHH@Z @ 114 NONAME ; int LtkUtils::RLtkBuf16::CreateMax(int)
+	?CreateMax@RLtkBuf8@LtkUtils@@QAEHH@Z @ 115 NONAME ; int LtkUtils::RLtkBuf8::CreateMax(int)
+	?CreateMaxL@RLtkBuf16@LtkUtils@@QAEXH@Z @ 116 NONAME ; void LtkUtils::RLtkBuf16::CreateMaxL(int)
+	?CreateMaxL@RLtkBuf8@LtkUtils@@QAEXH@Z @ 117 NONAME ; void LtkUtils::RLtkBuf8::CreateMaxL(int)
+	?ReAlloc@RLtkBuf16@LtkUtils@@QAEHH@Z @ 118 NONAME ; int LtkUtils::RLtkBuf16::ReAlloc(int)
+	?ReAlloc@RLtkBuf8@LtkUtils@@QAEHH@Z @ 119 NONAME ; int LtkUtils::RLtkBuf8::ReAlloc(int)
+	?ReAllocL@RLtkBuf16@LtkUtils@@QAEXH@Z @ 120 NONAME ; void LtkUtils::RLtkBuf16::ReAllocL(int)
+	?ReAllocL@RLtkBuf8@LtkUtils@@QAEXH@Z @ 121 NONAME ; void LtkUtils::RLtkBuf8::ReAllocL(int)
+	?ReplaceAllL@RLtkBuf16@LtkUtils@@QAEXABVTDesC16@@0@Z @ 122 NONAME ; void LtkUtils::RLtkBuf16::ReplaceAllL(class TDesC16 const &, class TDesC16 const &)
+	?ReplaceAllL@RLtkBuf8@LtkUtils@@QAEXABVTDesC8@@0@Z @ 123 NONAME ; void LtkUtils::RLtkBuf8::ReplaceAllL(class TDesC8 const &, class TDesC8 const &)
+	?ReplaceL@RLtkBuf16@LtkUtils@@QAEXHHABVTDesC16@@@Z @ 124 NONAME ; void LtkUtils::RLtkBuf16::ReplaceL(int, int, class TDesC16 const &)
+	?ReplaceL@RLtkBuf8@LtkUtils@@QAEXHHABVTDesC8@@@Z @ 125 NONAME ; void LtkUtils::RLtkBuf8::ReplaceL(int, int, class TDesC8 const &)
+	?ReserveExtra@RLtkBuf16@LtkUtils@@QAEHH@Z @ 126 NONAME ; int LtkUtils::RLtkBuf16::ReserveExtra(int)
+	?ReserveExtra@RLtkBuf8@LtkUtils@@QAEHH@Z @ 127 NONAME ; int LtkUtils::RLtkBuf8::ReserveExtra(int)
+	?ReserveExtraL@RLtkBuf16@LtkUtils@@QAEXH@Z @ 128 NONAME ; void LtkUtils::RLtkBuf16::ReserveExtraL(int)
+	?ReserveExtraL@RLtkBuf8@LtkUtils@@QAEXH@Z @ 129 NONAME ; void LtkUtils::RLtkBuf8::ReserveExtraL(int)
+	?ToHBuf@RLtkBuf16@LtkUtils@@QAEPAVHBufC16@@XZ @ 130 NONAME ; class HBufC16 * LtkUtils::RLtkBuf16::ToHBuf(void)
+	?ToHBuf@RLtkBuf8@LtkUtils@@QAEPAVHBufC8@@XZ @ 131 NONAME ; class HBufC8 * LtkUtils::RLtkBuf8::ToHBuf(void)
+	?CodesegOffsetFromSymbolNameL@CSymbolics@LtkUtils@@QAEKABVTDesC16@@0@Z @ 132 NONAME ; unsigned long LtkUtils::CSymbolics::CodesegOffsetFromSymbolNameL(class TDesC16 const &, class TDesC16 const &)
+	?CompleteL@CSymbolics@LtkUtils@@QAEXABVTDesC16@@AAVTDes16@@AAVCDesC16Array@@@Z @ 133 NONAME ; void LtkUtils::CSymbolics::CompleteL(class TDesC16 const &, class TDes16 &, class CDesC16Array &)
+	?CreateLC@RLtkBuf16@LtkUtils@@QAEXH@Z @ 134 NONAME ; void LtkUtils::RLtkBuf16::CreateLC(int)
+	?CreateLC@RLtkBuf8@LtkUtils@@QAEXH@Z @ 135 NONAME ; void LtkUtils::RLtkBuf8::CreateLC(int)
+	?AppendL@RLtkBuf16@LtkUtils@@QAEXVTChar@@@Z @ 136 NONAME ; void LtkUtils::RLtkBuf16::AppendL(class TChar)
+	?AppendL@RLtkBuf8@LtkUtils@@QAEXVTChar@@@Z @ 137 NONAME ; void LtkUtils::RLtkBuf8::AppendL(class TChar)
+	??1CHalAttribute@LtkUtils@@UAE@XZ @ 138 NONAME ; LtkUtils::CHalAttribute::~CHalAttribute(void)
+	?GetHalInfoL@LtkUtils@@YAPAVCHalAttribute@1@H@Z @ 139 NONAME ; class LtkUtils::CHalAttribute * LtkUtils::GetHalInfoL(int)
+	?GetHBuf@RLtkBuf8@LtkUtils@@QBEPAVHBufC8@@XZ @ 140 NONAME ; class HBufC8 * LtkUtils::RLtkBuf8::GetHBuf(void) const
+	?GetHalInfoL@LtkUtils@@YAXAAV?$RPointerArray@VCHalAttribute@LtkUtils@@@@@Z @ 141 NONAME ; void LtkUtils::GetHalInfoL(class RPointerArray<class LtkUtils::CHalAttribute> &)
+	?GetHalInfoForValueL@LtkUtils@@YAPAVCHalAttribute@1@HHH@Z @ 142 NONAME ; class LtkUtils::CHalAttribute * LtkUtils::GetHalInfoForValueL(int, int, int)
+	?GetHalInfoL@LtkUtils@@YAPAVCHalAttribute@1@HH@Z @ 143 NONAME ; class LtkUtils::CHalAttribute * LtkUtils::GetHalInfoL(int, int)
+	?GetHBuf@RLtkBuf16@LtkUtils@@QBEPAVHBufC16@@XZ @ 144 NONAME ; class HBufC16 * LtkUtils::RLtkBuf16::GetHBuf(void) const
+	?CopyAsUtf8L@RLtkBuf8@LtkUtils@@QAEXABVTDesC16@@@Z @ 145 NONAME ; void LtkUtils::RLtkBuf8::CopyAsUtf8L(class TDesC16 const &)
+	?Utf8L@LtkUtils@@YAPAVHBufC8@@ABVTDesC16@@@Z @ 146 NONAME ; class HBufC8 * LtkUtils::Utf8L(class TDesC16 const &)
+	?LookupL@CBsymFile@LtkUtils@@QAE?AVTPtrC16@@ABVTDesC16@@H@Z @ 147 NONAME ; class TPtrC16 LtkUtils::CBsymFile::LookupL(class TDesC16 const &, int)
+	?AppendUtf8L@RLtkBuf16@LtkUtils@@QAEXABVTDesC8@@@Z @ 148 NONAME ; void LtkUtils::RLtkBuf16::AppendUtf8L(class TDesC8 const &)
+	?AppendUtf8L@RLtkBuf16@LtkUtils@@QAEXABVTDesC8@@AAH@Z @ 149 NONAME ; void LtkUtils::RLtkBuf16::AppendUtf8L(class TDesC8 const &, int &)
+	?CopyFromUtf8L@RLtkBuf16@LtkUtils@@QAEXABVTDesC8@@@Z @ 150 NONAME ; void LtkUtils::RLtkBuf16::CopyFromUtf8L(class TDesC8 const &)
+	?FinalizeUtf8@RLtkBuf16@LtkUtils@@QAEHXZ @ 151 NONAME ; int LtkUtils::RLtkBuf16::FinalizeUtf8(void)
+	?FinalizeUtf8@RLtkBuf16@LtkUtils@@QAEXAAH@Z @ 152 NONAME ; void LtkUtils::RLtkBuf16::FinalizeUtf8(int &)
+	?DecodeUtf8L@LtkUtils@@YAPAVHBufC16@@ABVTDesC8@@@Z @ 153 NONAME ; class HBufC16 * LtkUtils::DecodeUtf8L(class TDesC8 const &)
+	??0RAllocatorHelper@LtkUtils@@QAE@XZ @ 154 NONAME ; LtkUtils::RAllocatorHelper::RAllocatorHelper(void)
+	?Open@RProxyAllocatorHelper@LtkUtils@@QAEHAAVRMemoryAccess@@I@Z @ 155 NONAME ; int LtkUtils::RProxyAllocatorHelper::Open(class RMemoryAccess &, unsigned int)
+	?Open@RAllocatorHelper@LtkUtils@@QAEHPAVRAllocator@@@Z @ 156 NONAME ; int LtkUtils::RAllocatorHelper::Open(class RAllocator *)
+	??0RProxyAllocatorHelper@LtkUtils@@QAE@XZ @ 157 NONAME ; LtkUtils::RProxyAllocatorHelper::RProxyAllocatorHelper(void)
+	?Close@RAllocatorHelper@LtkUtils@@UAEXXZ @ 158 NONAME ; void LtkUtils::RAllocatorHelper::Close(void)
+	?SetCellNestingLevel@RAllocatorHelper@LtkUtils@@QAEHPAXH@Z @ 159 NONAME ; int LtkUtils::RAllocatorHelper::SetCellNestingLevel(void *, int)
+	?AllocationCount@RAllocatorHelper@LtkUtils@@QAEHXZ @ 160 NONAME ; int LtkUtils::RAllocatorHelper::AllocationCount(void)
+	?CommittedSize@RAllocatorHelper@LtkUtils@@QAEHXZ @ 161 NONAME ; int LtkUtils::RAllocatorHelper::CommittedSize(void)
+	?RefreshDetails@RAllocatorHelper@LtkUtils@@QAEHXZ @ 162 NONAME ; int LtkUtils::RAllocatorHelper::RefreshDetails(void)
+	?AllocatedSize@RAllocatorHelper@LtkUtils@@QAEHXZ @ 163 NONAME ; int LtkUtils::RAllocatorHelper::AllocatedSize(void)
+	?OpenChunkHeap@RProxyAllocatorHelper@LtkUtils@@QAEHAAVRMemoryAccess@@PAX@Z @ 164 NONAME ; int LtkUtils::RProxyAllocatorHelper::OpenChunkHeap(class RMemoryAccess &, void *)
+	?MaxCommittedSize@RAllocatorHelper@LtkUtils@@QAEHXZ @ 165 NONAME ; int LtkUtils::RAllocatorHelper::MaxCommittedSize(void)
+	?AllocCountForCell@RAllocatorHelper@LtkUtils@@QBEHPAX@Z @ 166 NONAME ; int LtkUtils::RAllocatorHelper::AllocCountForCell(void *) const
+	?CommittedFreeSpace@RAllocatorHelper@LtkUtils@@QAEHXZ @ 167 NONAME ; int LtkUtils::RAllocatorHelper::CommittedFreeSpace(void)
+	?CountUnusedPages@RAllocatorHelper@LtkUtils@@QAEHXZ @ 168 NONAME ; int LtkUtils::RAllocatorHelper::CountUnusedPages(void)
+	?Walk@RAllocatorHelper@LtkUtils@@QAEHP6AHPAXW4TCellType@12@KH@Z0@Z @ 169 NONAME ; int LtkUtils::RAllocatorHelper::Walk(int (*)(void *, enum LtkUtils::RAllocatorHelper::TCellType, unsigned long, int), void *)
+	?MinCommittedSize@RAllocatorHelper@LtkUtils@@QAEHXZ @ 170 NONAME ; int LtkUtils::RAllocatorHelper::MinCommittedSize(void)
+	?AllocatorAddress@RAllocatorHelper@LtkUtils@@QBEKXZ @ 171 NONAME ; unsigned long LtkUtils::RAllocatorHelper::AllocatorAddress(void) const
+	?GetCellNestingLevel@RAllocatorHelper@LtkUtils@@QAEHPAXAAH@Z @ 172 NONAME ; int LtkUtils::RAllocatorHelper::GetCellNestingLevel(void *, int &)
+	?Walk@RAllocatorHelper@LtkUtils@@QAEHP6AHAAV12@PAXW4TCellType@12@KH@Z1@Z @ 173 NONAME ; int LtkUtils::RAllocatorHelper::Walk(int (*)(class LtkUtils::RAllocatorHelper &, void *, enum LtkUtils::RAllocatorHelper::TCellType, unsigned long, int), void *)
+	?Walk@RAllocatorHelper@LtkUtils@@QAEHP6AHAAV12@PAXW4TExtendedCellType@12@KH@Z1@Z @ 174 NONAME ; int LtkUtils::RAllocatorHelper::Walk(int (*)(class LtkUtils::RAllocatorHelper &, void *, enum LtkUtils::RAllocatorHelper::TExtendedCellType, unsigned long, int), void *)
+	?SizeForCellType@RAllocatorHelper@LtkUtils@@QAEHW4TExtendedCellType@12@@Z @ 175 NONAME ; int LtkUtils::RAllocatorHelper::SizeForCellType(enum LtkUtils::RAllocatorHelper::TExtendedCellType)
+	?CountForCellType@RAllocatorHelper@LtkUtils@@QAEHW4TExtendedCellType@12@@Z @ 176 NONAME ; int LtkUtils::RAllocatorHelper::CountForCellType(enum LtkUtils::RAllocatorHelper::TExtendedCellType)
+	?Close@RProxyAllocatorHelper@LtkUtils@@UAEXXZ @ 177 NONAME ; void LtkUtils::RProxyAllocatorHelper::Close(void)
+	?BreakpointPushL@LtkUtils@@YAXXZ @ 178 NONAME ; void LtkUtils::BreakpointPushL(void)
+	?AllocatorIsUdeb@RAllocatorHelper@LtkUtils@@QBEHXZ @ 179 NONAME ; int LtkUtils::RAllocatorHelper::AllocatorIsUdeb(void) const
+	?FormatSize@LtkUtils@@YAXAAVTDes8@@_J@Z @ 180 NONAME ; void LtkUtils::FormatSize(class TDes8 &, long long)
+	?FormatSize@LtkUtils@@YAXAAVTDes16@@_J@Z @ 181 NONAME ; void LtkUtils::FormatSize(class TDes16 &, long long)
+	?Description@RAllocatorHelper@LtkUtils@@QBEABVTDesC16@@XZ @ 182 NONAME ; class TDesC16 const & LtkUtils::RAllocatorHelper::Description(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/eabi/ltkutils-tcb.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,185 @@
+EXPORTS
+	_ZN8LtkUtils13GetPubSubDataERi @ 1 NONAME ABSENT
+	_ZN8LtkUtils15HexDumpToOutputERK6TDesC8R14RIoWriteHandle @ 2 NONAME
+	_ZN8LtkUtils15HexDumpToOutputERK6TDesC8R14RIoWriteHandleRi @ 3 NONAME
+	_ZN8LtkUtils15HexDumpToRDebugERK6TDesC8 @ 4 NONAME
+	_ZN8LtkUtils15HexDumpToRDebugERK6TDesC8Ri @ 5 NONAME
+	_ZN8LtkUtils17InjectRawKeyEventEiii @ 6 NONAME
+	_ZN8LtkUtils21MakeHeapCellInvisibleEPv @ 7 NONAME
+	_ZN8LtkUtils8HexDumpLERK6TDesC8 @ 8 NONAME
+	_ZN8LtkUtils21GetFriendlyThreadNameE7RThreadR4TBufILi256EE @ 9 NONAME
+	_ZN8LtkUtils22MakeThreadNameFriendlyER4TBufILi256EE @ 10 NONAME
+	_ZN8LtkUtils8RawPrintERK6TDesC8 @ 11 NONAME
+	_ZN8LtkUtils22GetFriendlyProcessNameERK8RProcessR6TDes16 @ 12 NONAME
+	_ZN8LtkUtils23MakeProcessNameFriendlyER6TDes16 @ 13 NONAME
+	_ZN8LtkUtils7HexLexLER6TLex16 @ 14 NONAME
+	_ZN8LtkUtils11ReplaceTextER6TDes16RK7TDesC16S4_ @ 15 NONAME
+	_ZN8LtkUtils10CIniReader10GetValuesLER13RPointerArrayINS_6CValueEE @ 16 NONAME
+	_ZN8LtkUtils10CIniReader4NewLERK7TDesC16NS_13TErrorContextE @ 17 NONAME
+	_ZN8LtkUtils10CIniReader9SetValueLERK7TDesC16S3_ @ 18 NONAME
+	_ZN8LtkUtils10CIniReaderD0Ev @ 19 NONAME
+	_ZN8LtkUtils10CIniReaderD1Ev @ 20 NONAME
+	_ZN8LtkUtils10CIniReaderD2Ev @ 21 NONAME
+	_ZN8LtkUtils12ReadIniFileLER13RIoReadHandleRNS_13MValueHandlerE @ 22 NONAME
+	_ZN8LtkUtils12ReadIniFileLERK7TDesC16RNS_13MValueHandlerENS_13TErrorContextENS_19TFileNotFoundActionE @ 23 NONAME
+	_ZN8LtkUtils13TErrorContext10LineNumberEv @ 24 NONAME
+	_ZN8LtkUtils13TErrorContext8NextLineEv @ 25 NONAME
+	_ZN8LtkUtils13TErrorContext8StringLCEv @ 26 NONAME
+	_ZN8LtkUtils13TErrorContextC1ERK7TDesC16 @ 27 NONAME
+	_ZN8LtkUtils13TErrorContextC1Ev @ 28 NONAME
+	_ZN8LtkUtils13TErrorContextC2ERK7TDesC16 @ 29 NONAME
+	_ZN8LtkUtils13TErrorContextC2Ev @ 30 NONAME
+	_ZN8LtkUtils13WriteIniFileLERK7TDesC16RNS_10CIniReaderE @ 31 NONAME
+	_ZN8LtkUtils6CValue4NewLERK7TDesC16S3_NS_13TErrorContextE @ 32 NONAME
+	_ZN8LtkUtils6CValue4SetLERK7TDesC16NS_13TErrorContextE @ 33 NONAME
+	_ZN8LtkUtils6CValue5NewLCERK7TDesC16S3_NS_13TErrorContextE @ 34 NONAME
+	_ZN8LtkUtils6CValueD0Ev @ 35 NONAME
+	_ZN8LtkUtils6CValueD1Ev @ 36 NONAME
+	_ZN8LtkUtils6CValueD2Ev @ 37 NONAME
+	_ZN8LtkUtils8CIniFile10GetSettingERK7TDesC16 @ 38 NONAME
+	_ZN8LtkUtils8CIniFile4NewLERK7TDesC16S3_ @ 39 NONAME
+	_ZN8LtkUtils8CIniFile4SetLERK7TDesC16S3_ @ 40 NONAME
+	_ZN8LtkUtils8CIniFile4SetLERK7TDesC16i @ 41 NONAME
+	_ZN8LtkUtils8CIniFile6GetIntERK7TDesC16 @ 42 NONAME
+	_ZN8LtkUtils8CIniFile6WriteLEv @ 43 NONAME
+	_ZN8LtkUtils8CIniFile7GetBoolERK7TDesC16 @ 44 NONAME
+	_ZN8LtkUtils8CIniFile9GetStringERK7TDesC16 @ 45 NONAME
+	_ZN8LtkUtils8CIniFileD0Ev @ 46 NONAME
+	_ZN8LtkUtils8CIniFileD1Ev @ 47 NONAME
+	_ZN8LtkUtils8CIniFileD2Ev @ 48 NONAME
+	_ZN8LtkUtils8CSetting4NewLENS_12TSettingTypeERK7TDesC16S4_S4_S4_S4_NS_13TErrorContextE @ 49 NONAME
+	_ZN8LtkUtils8CSetting4SetLERK7TDesC16NS_13TErrorContextE @ 50 NONAME
+	_ZN8LtkUtils8CSetting4SetLEi @ 51 NONAME
+	_ZN8LtkUtils8CSetting5NewLCENS_12TSettingTypeERK7TDesC16S4_S4_S4_S4_NS_13TErrorContextE @ 52 NONAME
+	_ZN8LtkUtils8CSettingD0Ev @ 53 NONAME
+	_ZN8LtkUtils8CSettingD1Ev @ 54 NONAME
+	_ZN8LtkUtils8CSettingD2Ev @ 55 NONAME
+	_ZNK8LtkUtils10CIniReader10GetValuesLER13RPointerArrayIKNS_6CValueEE @ 56 NONAME
+	_ZNK8LtkUtils10CIniReader7GetIdsLER6RArrayIK7TPtrC16E @ 57 NONAME
+	_ZNK8LtkUtils10CIniReader8GetValueERK7TDesC16 @ 58 NONAME
+	_ZNK8LtkUtils6CValue10LineNumberEv @ 59 NONAME
+	_ZNK8LtkUtils6CValue2IdEv @ 60 NONAME
+	_ZNK8LtkUtils6CValue5AsIntERi @ 61 NONAME
+	_ZNK8LtkUtils6CValue5ValueEv @ 62 NONAME
+	_ZNK8LtkUtils6CValue6AsBoolERi @ 63 NONAME
+	_ZNK8LtkUtils6CValue6AsIntLEv @ 64 NONAME
+	_ZNK8LtkUtils6CValue7AsBoolLEv @ 65 NONAME
+	_ZNK8LtkUtils8CSetting5AsIntERi @ 66 NONAME
+	_ZNK8LtkUtils8CSetting5AsIntEv @ 67 NONAME
+	_ZNK8LtkUtils8CSetting5IsSetEv @ 68 NONAME
+	_ZNK8LtkUtils8CSetting6AsBoolERi @ 69 NONAME
+	_ZNK8LtkUtils8CSetting6AsBoolEv @ 70 NONAME
+	_ZTIN8LtkUtils10CIniReaderE @ 71 NONAME
+	_ZTIN8LtkUtils6CValueE @ 72 NONAME
+	_ZTIN8LtkUtils8CIniFileE @ 73 NONAME
+	_ZTIN8LtkUtils8CSettingE @ 74 NONAME
+	_ZTVN8LtkUtils10CIniReaderE @ 75 NONAME
+	_ZTVN8LtkUtils6CValueE @ 76 NONAME
+	_ZTVN8LtkUtils8CIniFileE @ 77 NONAME
+	_ZTVN8LtkUtils8CSettingE @ 78 NONAME
+	_ZN8LtkUtils8CSetting11DescriptionEv @ 79 NONAME
+	_ZN8LtkUtils8CSetting4NameEv @ 80 NONAME
+	_ZN8LtkUtils10CIniReader12RemoveValueLERK7TDesC16 @ 81 NONAME
+	_ZN8LtkUtils8CSetting6ClearLEv @ 82 NONAME
+	_ZN8LtkUtils9MatchifyLEP7HBufC16 @ 83 NONAME ABSENT
+	_ZN8LtkUtils6HexLexER5TLex8Rj @ 84 NONAME
+	_ZN8LtkUtils6HexLexER6TLex16Rj @ 85 NONAME
+	_ZN8LtkUtils7HexLexLER5TLex8 @ 86 NONAME
+	_ZN8LtkUtils8RLtkBuf810CreateMaxLEi @ 87 NONAME
+	_ZN8LtkUtils8RLtkBuf811ReplaceAllLERK6TDesC8S3_ @ 88 NONAME
+	_ZN8LtkUtils8RLtkBuf812ReserveExtraEi @ 89 NONAME
+	_ZN8LtkUtils8RLtkBuf813AppendFormatLE11TRefByValueIK6TDesC8Ez @ 90 NONAME
+	_ZN8LtkUtils8RLtkBuf813ReserveExtraLEi @ 91 NONAME
+	_ZN8LtkUtils8RLtkBuf85CloseEv @ 92 NONAME
+	_ZN8LtkUtils8RLtkBuf86AssignEP6HBufC8 @ 93 NONAME
+	_ZN8LtkUtils8RLtkBuf86CreateEi @ 94 NONAME
+	_ZN8LtkUtils8RLtkBuf86ToHBufEv @ 95 NONAME
+	_ZN8LtkUtils8RLtkBuf87AppendLE5TChar @ 96 NONAME
+	_ZN8LtkUtils8RLtkBuf87AppendLERK6TDesC8 @ 97 NONAME
+	_ZN8LtkUtils8RLtkBuf87AppendLERK7TDesC16 @ 98 NONAME
+	_ZN8LtkUtils8RLtkBuf87CreateLEi @ 99 NONAME
+	_ZN8LtkUtils8RLtkBuf87ReAllocEi @ 100 NONAME
+	_ZN8LtkUtils8RLtkBuf88CreateLCEi @ 101 NONAME
+	_ZN8LtkUtils8RLtkBuf88ReAllocLEi @ 102 NONAME
+	_ZN8LtkUtils8RLtkBuf88ReplaceLEiiRK6TDesC8 @ 103 NONAME
+	_ZN8LtkUtils8RLtkBuf89CreateMaxEi @ 104 NONAME
+	_ZN8LtkUtils8RLtkBuf8C1EP6HBufC8 @ 105 NONAME
+	_ZN8LtkUtils8RLtkBuf8C1Ev @ 106 NONAME
+	_ZN8LtkUtils8RLtkBuf8C2EP6HBufC8 @ 107 NONAME
+	_ZN8LtkUtils8RLtkBuf8C2Ev @ 108 NONAME
+	_ZN8LtkUtils9HasPrefixERK6TDesC8S2_ @ 109 NONAME
+	_ZN8LtkUtils9HasPrefixERK7TDesC16S2_ @ 110 NONAME
+	_ZN8LtkUtils9RLtkBuf1610CreateMaxLEi @ 111 NONAME
+	_ZN8LtkUtils9RLtkBuf1611ReplaceAllLERK7TDesC16S3_ @ 112 NONAME
+	_ZN8LtkUtils9RLtkBuf1612ReserveExtraEi @ 113 NONAME
+	_ZN8LtkUtils9RLtkBuf1613AppendFormatLE11TRefByValueIK7TDesC16Ez @ 114 NONAME
+	_ZN8LtkUtils9RLtkBuf1613ReserveExtraLEi @ 115 NONAME
+	_ZN8LtkUtils9RLtkBuf165CloseEv @ 116 NONAME
+	_ZN8LtkUtils9RLtkBuf166AssignEP7HBufC16 @ 117 NONAME
+	_ZN8LtkUtils9RLtkBuf166CreateEi @ 118 NONAME
+	_ZN8LtkUtils9RLtkBuf166ToHBufEv @ 119 NONAME
+	_ZN8LtkUtils9RLtkBuf167AppendLE5TChar @ 120 NONAME
+	_ZN8LtkUtils9RLtkBuf167AppendLERK6TDesC8 @ 121 NONAME
+	_ZN8LtkUtils9RLtkBuf167AppendLERK7TDesC16 @ 122 NONAME
+	_ZN8LtkUtils9RLtkBuf167CreateLEi @ 123 NONAME
+	_ZN8LtkUtils9RLtkBuf167ReAllocEi @ 124 NONAME
+	_ZN8LtkUtils9RLtkBuf168CreateLCEi @ 125 NONAME
+	_ZN8LtkUtils9RLtkBuf168ReAllocLEi @ 126 NONAME
+	_ZN8LtkUtils9RLtkBuf168ReplaceLEiiRK7TDesC16 @ 127 NONAME
+	_ZN8LtkUtils9RLtkBuf169CreateMaxEi @ 128 NONAME
+	_ZN8LtkUtils9RLtkBuf16C1EP7HBufC16 @ 129 NONAME
+	_ZN8LtkUtils9RLtkBuf16C1Ev @ 130 NONAME
+	_ZN8LtkUtils9RLtkBuf16C2EP7HBufC16 @ 131 NONAME
+	_ZN8LtkUtils9RLtkBuf16C2Ev @ 132 NONAME
+	_ZNK8LtkUtils8RLtkBuf87GetHBufEv @ 133 NONAME
+	_ZNK8LtkUtils9RLtkBuf167GetHBufEv @ 134 NONAME
+	_ZN8LtkUtils11GetHalInfoLER13RPointerArrayINS_13CHalAttributeEE @ 135 NONAME
+	_ZN8LtkUtils11GetHalInfoLEi @ 136 NONAME
+	_ZN8LtkUtils11GetHalInfoLEii @ 137 NONAME
+	_ZN8LtkUtils13CHalAttributeD0Ev @ 138 NONAME
+	_ZN8LtkUtils13CHalAttributeD1Ev @ 139 NONAME
+	_ZN8LtkUtils13CHalAttributeD2Ev @ 140 NONAME
+	_ZN8LtkUtils19GetHalInfoForValueLEiii @ 141 NONAME
+	_ZN8LtkUtils5Utf8LERK7TDesC16 @ 142 NONAME
+	_ZN8LtkUtils8RLtkBuf811CopyAsUtf8LERK7TDesC16 @ 143 NONAME
+	_ZN8LtkUtils11DecodeUtf8LERK6TDesC8 @ 144 NONAME
+	_ZN8LtkUtils9RLtkBuf1611AppendUtf8LERK6TDesC8 @ 145 NONAME
+	_ZN8LtkUtils9RLtkBuf1611AppendUtf8LERK6TDesC8Ri @ 146 NONAME
+	_ZN8LtkUtils9RLtkBuf1612FinalizeUtf8ERi @ 147 NONAME
+	_ZN8LtkUtils9RLtkBuf1612FinalizeUtf8Ev @ 148 NONAME
+	_ZN8LtkUtils9RLtkBuf1613CopyFromUtf8LERK6TDesC8 @ 149 NONAME
+	_ZN8LtkUtils16RAllocatorHelper13AllocatedSizeEv @ 150 NONAME
+	_ZN8LtkUtils16RAllocatorHelper13CommittedSizeEv @ 151 NONAME
+	_ZN8LtkUtils16RAllocatorHelper18CommittedFreeSpaceEv @ 152 NONAME
+	_ZN8LtkUtils16RAllocatorHelper14RefreshDetailsEv @ 153 NONAME
+	_ZN8LtkUtils16RAllocatorHelper15AllocationCountEv @ 154 NONAME
+	_ZN8LtkUtils16RAllocatorHelper16CountUnusedPagesEv @ 155 NONAME
+	_ZN8LtkUtils16RAllocatorHelper16MaxCommittedSizeEv @ 156 NONAME
+	_ZN8LtkUtils16RAllocatorHelper19SetCellNestingLevelEPvi @ 157 NONAME
+	_ZN8LtkUtils16RAllocatorHelper4OpenEP10RAllocator @ 158 NONAME
+	_ZN8LtkUtils16RAllocatorHelper4WalkEPFiPvNS0_9TCellTypeEmiES1_ @ 159 NONAME
+	_ZN8LtkUtils16RAllocatorHelper5CloseEv @ 160 NONAME
+	_ZN8LtkUtils16RAllocatorHelperC1Ev @ 161 NONAME
+	_ZN8LtkUtils16RAllocatorHelperC2Ev @ 162 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelper13OpenChunkHeapER13RMemoryAccessPv @ 163 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelper4OpenER13RMemoryAccessj @ 164 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelperC1Ev @ 165 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelperC2Ev @ 166 NONAME
+	_ZNK8LtkUtils16RAllocatorHelper17AllocCountForCellEPv @ 167 NONAME
+	_ZTIN8LtkUtils16RAllocatorHelperE @ 168 NONAME
+	_ZTIN8LtkUtils21RProxyAllocatorHelperE @ 169 NONAME
+	_ZTVN8LtkUtils16RAllocatorHelperE @ 170 NONAME
+	_ZTVN8LtkUtils21RProxyAllocatorHelperE @ 171 NONAME
+	_ZN8LtkUtils16RAllocatorHelper16MinCommittedSizeEv @ 172 NONAME
+	_ZNK8LtkUtils16RAllocatorHelper16AllocatorAddressEv @ 173 NONAME
+	_ZN8LtkUtils16RAllocatorHelper19GetCellNestingLevelEPvRi @ 174 NONAME
+	_ZN8LtkUtils16RAllocatorHelper4WalkEPFiRS0_PvNS0_9TCellTypeEmiES2_ @ 175 NONAME
+	_ZN8LtkUtils16RAllocatorHelper4WalkEPFiRS0_PvNS0_17TExtendedCellTypeEmiES2_ @ 176 NONAME
+	_ZN8LtkUtils16RAllocatorHelper15SizeForCellTypeENS0_17TExtendedCellTypeE @ 177 NONAME
+	_ZN8LtkUtils16RAllocatorHelper16CountForCellTypeENS0_17TExtendedCellTypeE @ 178 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelper5CloseEv @ 179 NONAME
+	_ZNK8LtkUtils16RAllocatorHelper15AllocatorIsUdebEv @ 180 NONAME
+	_ZN8LtkUtils10FormatSizeER5TDes8x @ 181 NONAME
+	_ZN8LtkUtils10FormatSizeER6TDes16x @ 182 NONAME
+	_ZNK8LtkUtils16RAllocatorHelper11DescriptionEv @ 183 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/eabi/ltkutils.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,221 @@
+EXPORTS
+	_ZN8LtkUtils21MakeHeapCellInvisibleEPv @ 1 NONAME
+	_ZN8LtkUtils17InjectRawKeyEventEiii @ 2 NONAME
+	_ZN8LtkUtils15HexDumpToOutputERK6TDesC8R14RIoWriteHandle @ 3 NONAME
+	_ZN8LtkUtils8HexDumpLERK6TDesC8 @ 4 NONAME
+	_ZN8LtkUtils15HexDumpToOutputERK6TDesC8R14RIoWriteHandleRi @ 5 NONAME
+	_ZN8LtkUtils9W32CrackLEv @ 6 NONAME
+	_ZN8LtkUtils13GetPubSubDataERi @ 7 NONAME ABSENT
+	_ZN8LtkUtils15HexDumpToRDebugERK6TDesC8 @ 8 NONAME
+	_ZN8LtkUtils15HexDumpToRDebugERK6TDesC8Ri @ 9 NONAME
+	_ZN8LtkUtils4RezLERK7TDesC16P3RFsPP7HBufC16 @ 10 NONAME
+	_ZN8LtkUtils5Rez8LERK7TDesC16P3RFsPP7HBufC16 @ 11 NONAME
+	_ZN8LtkUtils5RezLCERK7TDesC16P3RFsPP7HBufC16 @ 12 NONAME
+	_ZN8LtkUtils6Rez8LCERK7TDesC16P3RFsPP7HBufC16 @ 13 NONAME
+	_ZN8LtkUtils21GetFriendlyThreadNameE7RThreadR4TBufILi256EE @ 14 NONAME
+	_ZN8LtkUtils22MakeThreadNameFriendlyER4TBufILi256EE @ 15 NONAME
+	_ZN8LtkUtils16CopyToClipboardLERK7TDesC16P3RFs @ 16 NONAME
+	_ZN8LtkUtils17GetFromClipboardLEP3RFs @ 17 NONAME
+	_ZN8LtkUtils8RawPrintERK6TDesC8 @ 18 NONAME
+	_ZN8LtkUtils22GetFriendlyProcessNameERK8RProcessR6TDes16 @ 19 NONAME
+	_ZN8LtkUtils23MakeProcessNameFriendlyER6TDes16 @ 20 NONAME
+	_ZN8LtkUtils17W32CrackIsEnabledEv @ 21 NONAME
+	_ZN8LtkUtils7HexLexLER6TLex16 @ 22 NONAME
+	_ZN8LtkUtils11ReplaceTextER6TDes16RK7TDesC16S4_ @ 23 NONAME
+	_ZN8LtkUtils10CIniReader10GetValuesLER13RPointerArrayINS_6CValueEE @ 24 NONAME
+	_ZN8LtkUtils10CIniReader4NewLERK7TDesC16NS_13TErrorContextE @ 25 NONAME
+	_ZN8LtkUtils10CIniReader9SetValueLERK7TDesC16S3_ @ 26 NONAME
+	_ZN8LtkUtils10CIniReaderD0Ev @ 27 NONAME
+	_ZN8LtkUtils10CIniReaderD1Ev @ 28 NONAME
+	_ZN8LtkUtils10CIniReaderD2Ev @ 29 NONAME
+	_ZN8LtkUtils12ReadIniFileLER13RIoReadHandleRNS_13MValueHandlerE @ 30 NONAME
+	_ZN8LtkUtils12ReadIniFileLERK7TDesC16RNS_13MValueHandlerENS_13TErrorContextENS_19TFileNotFoundActionE @ 31 NONAME
+	_ZN8LtkUtils13TErrorContext10LineNumberEv @ 32 NONAME
+	_ZN8LtkUtils13TErrorContext8NextLineEv @ 33 NONAME
+	_ZN8LtkUtils13TErrorContext8StringLCEv @ 34 NONAME
+	_ZN8LtkUtils13TErrorContextC1ERK7TDesC16 @ 35 NONAME
+	_ZN8LtkUtils13TErrorContextC1Ev @ 36 NONAME
+	_ZN8LtkUtils13TErrorContextC2ERK7TDesC16 @ 37 NONAME
+	_ZN8LtkUtils13TErrorContextC2Ev @ 38 NONAME
+	_ZN8LtkUtils13WriteIniFileLERK7TDesC16RNS_10CIniReaderE @ 39 NONAME
+	_ZN8LtkUtils6CValue4NewLERK7TDesC16S3_NS_13TErrorContextE @ 40 NONAME
+	_ZN8LtkUtils6CValue4SetLERK7TDesC16NS_13TErrorContextE @ 41 NONAME
+	_ZN8LtkUtils6CValue5NewLCERK7TDesC16S3_NS_13TErrorContextE @ 42 NONAME
+	_ZN8LtkUtils6CValueD0Ev @ 43 NONAME
+	_ZN8LtkUtils6CValueD1Ev @ 44 NONAME
+	_ZN8LtkUtils6CValueD2Ev @ 45 NONAME
+	_ZN8LtkUtils8CIniFile10GetSettingERK7TDesC16 @ 46 NONAME
+	_ZN8LtkUtils8CIniFile4NewLERK7TDesC16S3_ @ 47 NONAME
+	_ZN8LtkUtils8CIniFile4SetLERK7TDesC16S3_ @ 48 NONAME
+	_ZN8LtkUtils8CIniFile4SetLERK7TDesC16i @ 49 NONAME
+	_ZN8LtkUtils8CIniFile6GetIntERK7TDesC16 @ 50 NONAME
+	_ZN8LtkUtils8CIniFile6WriteLEv @ 51 NONAME
+	_ZN8LtkUtils8CIniFile7GetBoolERK7TDesC16 @ 52 NONAME
+	_ZN8LtkUtils8CIniFile9GetStringERK7TDesC16 @ 53 NONAME
+	_ZN8LtkUtils8CIniFileD0Ev @ 54 NONAME
+	_ZN8LtkUtils8CIniFileD1Ev @ 55 NONAME
+	_ZN8LtkUtils8CIniFileD2Ev @ 56 NONAME
+	_ZN8LtkUtils8CSetting4NewLENS_12TSettingTypeERK7TDesC16S4_S4_S4_S4_NS_13TErrorContextE @ 57 NONAME
+	_ZN8LtkUtils8CSetting4SetLERK7TDesC16NS_13TErrorContextE @ 58 NONAME
+	_ZN8LtkUtils8CSetting4SetLEi @ 59 NONAME
+	_ZN8LtkUtils8CSetting5NewLCENS_12TSettingTypeERK7TDesC16S4_S4_S4_S4_NS_13TErrorContextE @ 60 NONAME
+	_ZN8LtkUtils8CSettingD0Ev @ 61 NONAME
+	_ZN8LtkUtils8CSettingD1Ev @ 62 NONAME
+	_ZN8LtkUtils8CSettingD2Ev @ 63 NONAME
+	_ZNK8LtkUtils10CIniReader10GetValuesLER13RPointerArrayIKNS_6CValueEE @ 64 NONAME
+	_ZNK8LtkUtils10CIniReader7GetIdsLER6RArrayIK7TPtrC16E @ 65 NONAME
+	_ZNK8LtkUtils10CIniReader8GetValueERK7TDesC16 @ 66 NONAME
+	_ZNK8LtkUtils6CValue10LineNumberEv @ 67 NONAME
+	_ZNK8LtkUtils6CValue2IdEv @ 68 NONAME
+	_ZNK8LtkUtils6CValue5AsIntERi @ 69 NONAME
+	_ZNK8LtkUtils6CValue5ValueEv @ 70 NONAME
+	_ZNK8LtkUtils6CValue6AsBoolERi @ 71 NONAME
+	_ZNK8LtkUtils6CValue6AsIntLEv @ 72 NONAME
+	_ZNK8LtkUtils6CValue7AsBoolLEv @ 73 NONAME
+	_ZNK8LtkUtils8CSetting5AsIntERi @ 74 NONAME
+	_ZNK8LtkUtils8CSetting5AsIntEv @ 75 NONAME
+	_ZNK8LtkUtils8CSetting5IsSetEv @ 76 NONAME
+	_ZNK8LtkUtils8CSetting6AsBoolERi @ 77 NONAME
+	_ZNK8LtkUtils8CSetting6AsBoolEv @ 78 NONAME
+	_ZTIN8LtkUtils10CIniReaderE @ 79 NONAME
+	_ZTIN8LtkUtils6CValueE @ 80 NONAME
+	_ZTIN8LtkUtils8CIniFileE @ 81 NONAME
+	_ZTIN8LtkUtils8CSettingE @ 82 NONAME
+	_ZTVN8LtkUtils10CIniReaderE @ 83 NONAME
+	_ZTVN8LtkUtils6CValueE @ 84 NONAME
+	_ZTVN8LtkUtils8CIniFileE @ 85 NONAME
+	_ZTVN8LtkUtils8CSettingE @ 86 NONAME
+	_ZN8LtkUtils8CSetting11DescriptionEv @ 87 NONAME
+	_ZN8LtkUtils8CSetting4NameEv @ 88 NONAME
+	_ZN8LtkUtils10CIniReader12RemoveValueLERK7TDesC16 @ 89 NONAME
+	_ZN8LtkUtils8CSetting6ClearLEv @ 90 NONAME
+	_ZN8LtkUtils9MatchifyLEP7HBufC16 @ 91 NONAME ABSENT
+	_ZN8LtkUtils9CBsymFile4NewLER3RFsRK7TDesC16 @ 92 NONAME
+	_ZN8LtkUtils9CBsymFile7LookupLEm @ 93 NONAME
+	_ZN8LtkUtils9CBsymFileD0Ev @ 94 NONAME
+	_ZN8LtkUtils9CBsymFileD1Ev @ 95 NONAME
+	_ZN8LtkUtils9CBsymFileD2Ev @ 96 NONAME
+	_ZN8LtkUtils6HexLexER5TLex8Rj @ 97 NONAME
+	_ZN8LtkUtils6HexLexER6TLex16Rj @ 98 NONAME
+	_ZN8LtkUtils7HexLexLER5TLex8 @ 99 NONAME
+	_ZN8LtkUtils9HasPrefixERK6TDesC8S2_ @ 100 NONAME
+	_ZN8LtkUtils9HasPrefixERK7TDesC16S2_ @ 101 NONAME
+	_ZN8LtkUtils8CMapFile4NewLER3RFsRK7TDesC16 @ 102 NONAME
+	_ZN8LtkUtils8CMapFileD0Ev @ 103 NONAME
+	_ZN8LtkUtils8CMapFileD1Ev @ 104 NONAME
+	_ZN8LtkUtils8CMapFileD2Ev @ 105 NONAME
+	_ZN8LtkUtils10CSymbolics11AddMapFileLERK7TDesC16 @ 106 NONAME
+	_ZN8LtkUtils10CSymbolics12AddBsymFileLERK7TDesC16 @ 107 NONAME
+	_ZN8LtkUtils10CSymbolics22SetFallbackMapFileDirLERK7TDesC16 @ 108 NONAME
+	_ZN8LtkUtils10CSymbolics7LookupLERK7TDesC16m @ 109 NONAME
+	_ZN8LtkUtils10CSymbolics7LookupLEm @ 110 NONAME
+	_ZN8LtkUtils10CSymbolicsC2ER3RFs @ 111 NONAME
+	_ZN8LtkUtils10CSymbolicsD0Ev @ 112 NONAME
+	_ZN8LtkUtils10CSymbolicsD1Ev @ 113 NONAME
+	_ZN8LtkUtils10CSymbolicsD2Ev @ 114 NONAME
+	_ZN8LtkUtils8CMapFile6LookupEmR6TDes16 @ 115 NONAME
+	_ZN8LtkUtils10CSymbolicsC1ER3RFs @ 116 NONAME
+	_ZN8LtkUtils10CSymbolics11AddMapFileLEPNS_8CMapFileE @ 117 NONAME
+	_ZNK8LtkUtils8CMapFile12GetFileNameLER6TDes16 @ 118 NONAME
+	_ZN8LtkUtils10BreakpointEv @ 119 NONAME
+	_ZN8LtkUtils14BreakpointAddrEv @ 120 NONAME
+	_ZN8LtkUtils10CSymbolics28CodesegOffsetFromSymbolNameLERK7TDesC16S3_ @ 121 NONAME
+	_ZN8LtkUtils10CSymbolics9CompleteLERK7TDesC16R6TDes16R12CDesC16Array @ 122 NONAME
+	_ZN8LtkUtils8RLtkBuf810CreateMaxLEi @ 123 NONAME
+	_ZN8LtkUtils8RLtkBuf811ReplaceAllLERK6TDesC8S3_ @ 124 NONAME
+	_ZN8LtkUtils8RLtkBuf812ReserveExtraEi @ 125 NONAME
+	_ZN8LtkUtils8RLtkBuf813AppendFormatLE11TRefByValueIK6TDesC8Ez @ 126 NONAME
+	_ZN8LtkUtils8RLtkBuf813ReserveExtraLEi @ 127 NONAME
+	_ZN8LtkUtils8RLtkBuf85CloseEv @ 128 NONAME
+	_ZN8LtkUtils8RLtkBuf86AssignEP6HBufC8 @ 129 NONAME
+	_ZN8LtkUtils8RLtkBuf86CreateEi @ 130 NONAME
+	_ZN8LtkUtils8RLtkBuf86ToHBufEv @ 131 NONAME
+	_ZN8LtkUtils8RLtkBuf87AppendLE5TChar @ 132 NONAME
+	_ZN8LtkUtils8RLtkBuf87AppendLERK6TDesC8 @ 133 NONAME
+	_ZN8LtkUtils8RLtkBuf87AppendLERK7TDesC16 @ 134 NONAME
+	_ZN8LtkUtils8RLtkBuf87CreateLEi @ 135 NONAME
+	_ZN8LtkUtils8RLtkBuf87ReAllocEi @ 136 NONAME
+	_ZN8LtkUtils8RLtkBuf88CreateLCEi @ 137 NONAME
+	_ZN8LtkUtils8RLtkBuf88ReAllocLEi @ 138 NONAME
+	_ZN8LtkUtils8RLtkBuf88ReplaceLEiiRK6TDesC8 @ 139 NONAME
+	_ZN8LtkUtils8RLtkBuf89CreateMaxEi @ 140 NONAME
+	_ZN8LtkUtils8RLtkBuf8C1EP6HBufC8 @ 141 NONAME
+	_ZN8LtkUtils8RLtkBuf8C1Ev @ 142 NONAME
+	_ZN8LtkUtils8RLtkBuf8C2EP6HBufC8 @ 143 NONAME
+	_ZN8LtkUtils8RLtkBuf8C2Ev @ 144 NONAME
+	_ZN8LtkUtils9RLtkBuf1610CreateMaxLEi @ 145 NONAME
+	_ZN8LtkUtils9RLtkBuf1611ReplaceAllLERK7TDesC16S3_ @ 146 NONAME
+	_ZN8LtkUtils9RLtkBuf1612ReserveExtraEi @ 147 NONAME
+	_ZN8LtkUtils9RLtkBuf1613AppendFormatLE11TRefByValueIK7TDesC16Ez @ 148 NONAME
+	_ZN8LtkUtils9RLtkBuf1613ReserveExtraLEi @ 149 NONAME
+	_ZN8LtkUtils9RLtkBuf165CloseEv @ 150 NONAME
+	_ZN8LtkUtils9RLtkBuf166AssignEP7HBufC16 @ 151 NONAME
+	_ZN8LtkUtils9RLtkBuf166CreateEi @ 152 NONAME
+	_ZN8LtkUtils9RLtkBuf166ToHBufEv @ 153 NONAME
+	_ZN8LtkUtils9RLtkBuf167AppendLE5TChar @ 154 NONAME
+	_ZN8LtkUtils9RLtkBuf167AppendLERK6TDesC8 @ 155 NONAME
+	_ZN8LtkUtils9RLtkBuf167AppendLERK7TDesC16 @ 156 NONAME
+	_ZN8LtkUtils9RLtkBuf167CreateLEi @ 157 NONAME
+	_ZN8LtkUtils9RLtkBuf167ReAllocEi @ 158 NONAME
+	_ZN8LtkUtils9RLtkBuf168CreateLCEi @ 159 NONAME
+	_ZN8LtkUtils9RLtkBuf168ReAllocLEi @ 160 NONAME
+	_ZN8LtkUtils9RLtkBuf168ReplaceLEiiRK7TDesC16 @ 161 NONAME
+	_ZN8LtkUtils9RLtkBuf169CreateMaxEi @ 162 NONAME
+	_ZN8LtkUtils9RLtkBuf16C1EP7HBufC16 @ 163 NONAME
+	_ZN8LtkUtils9RLtkBuf16C1Ev @ 164 NONAME
+	_ZN8LtkUtils9RLtkBuf16C2EP7HBufC16 @ 165 NONAME
+	_ZN8LtkUtils9RLtkBuf16C2Ev @ 166 NONAME
+	_ZN8LtkUtils11GetHalInfoLER13RPointerArrayINS_13CHalAttributeEE @ 167 NONAME
+	_ZN8LtkUtils11GetHalInfoLEi @ 168 NONAME
+	_ZN8LtkUtils11GetHalInfoLEii @ 169 NONAME
+	_ZN8LtkUtils13CHalAttributeD0Ev @ 170 NONAME
+	_ZN8LtkUtils13CHalAttributeD1Ev @ 171 NONAME
+	_ZN8LtkUtils13CHalAttributeD2Ev @ 172 NONAME
+	_ZN8LtkUtils19GetHalInfoForValueLEiii @ 173 NONAME
+	_ZNK8LtkUtils8RLtkBuf87GetHBufEv @ 174 NONAME
+	_ZNK8LtkUtils9RLtkBuf167GetHBufEv @ 175 NONAME
+	_ZN8LtkUtils5Utf8LERK7TDesC16 @ 176 NONAME
+	_ZN8LtkUtils8RLtkBuf811CopyAsUtf8LERK7TDesC16 @ 177 NONAME
+	_ZN8LtkUtils9CBsymFile7LookupLERK7TDesC16i @ 178 NONAME
+	_ZN8LtkUtils9RLtkBuf1611AppendUtf8LERK6TDesC8 @ 179 NONAME
+	_ZN8LtkUtils9RLtkBuf1611AppendUtf8LERK6TDesC8Ri @ 180 NONAME
+	_ZN8LtkUtils9RLtkBuf1612FinalizeUtf8ERi @ 181 NONAME
+	_ZN8LtkUtils9RLtkBuf1612FinalizeUtf8Ev @ 182 NONAME
+	_ZN8LtkUtils9RLtkBuf1613CopyFromUtf8LERK6TDesC8 @ 183 NONAME
+	_ZN8LtkUtils11DecodeUtf8LERK6TDesC8 @ 184 NONAME
+	_ZN8LtkUtils16RAllocatorHelper13AllocatedSizeEv @ 185 NONAME
+	_ZN8LtkUtils16RAllocatorHelper13CommittedSizeEv @ 186 NONAME
+	_ZN8LtkUtils16RAllocatorHelper18CommittedFreeSpaceEv @ 187 NONAME
+	_ZN8LtkUtils16RAllocatorHelper14RefreshDetailsEv @ 188 NONAME
+	_ZN8LtkUtils16RAllocatorHelper15AllocationCountEv @ 189 NONAME
+	_ZN8LtkUtils16RAllocatorHelper16CountUnusedPagesEv @ 190 NONAME
+	_ZN8LtkUtils16RAllocatorHelper16MaxCommittedSizeEv @ 191 NONAME
+	_ZN8LtkUtils16RAllocatorHelper19SetCellNestingLevelEPvi @ 192 NONAME
+	_ZN8LtkUtils16RAllocatorHelper4OpenEP10RAllocator @ 193 NONAME
+	_ZN8LtkUtils16RAllocatorHelper4WalkEPFiPvNS0_9TCellTypeEmiES1_ @ 194 NONAME
+	_ZN8LtkUtils16RAllocatorHelper5CloseEv @ 195 NONAME
+	_ZN8LtkUtils16RAllocatorHelperC1Ev @ 196 NONAME
+	_ZN8LtkUtils16RAllocatorHelperC2Ev @ 197 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelper13OpenChunkHeapER13RMemoryAccessPv @ 198 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelper4OpenER13RMemoryAccessj @ 199 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelperC1Ev @ 200 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelperC2Ev @ 201 NONAME
+	_ZNK8LtkUtils16RAllocatorHelper17AllocCountForCellEPv @ 202 NONAME
+	_ZTIN8LtkUtils16RAllocatorHelperE @ 203 NONAME
+	_ZTIN8LtkUtils21RProxyAllocatorHelperE @ 204 NONAME
+	_ZTVN8LtkUtils16RAllocatorHelperE @ 205 NONAME
+	_ZTVN8LtkUtils21RProxyAllocatorHelperE @ 206 NONAME
+	_ZN8LtkUtils16RAllocatorHelper16MinCommittedSizeEv @ 207 NONAME
+	_ZNK8LtkUtils16RAllocatorHelper16AllocatorAddressEv @ 208 NONAME
+	_ZN8LtkUtils16RAllocatorHelper19GetCellNestingLevelEPvRi @ 209 NONAME
+	_ZN8LtkUtils16RAllocatorHelper4WalkEPFiRS0_PvNS0_9TCellTypeEmiES2_ @ 210 NONAME
+	_ZN8LtkUtils16RAllocatorHelper4WalkEPFiRS0_PvNS0_17TExtendedCellTypeEmiES2_ @ 211 NONAME
+	_ZN8LtkUtils16RAllocatorHelper15SizeForCellTypeENS0_17TExtendedCellTypeE @ 212 NONAME
+	_ZN8LtkUtils16RAllocatorHelper16CountForCellTypeENS0_17TExtendedCellTypeE @ 213 NONAME
+	_ZN8LtkUtils21RProxyAllocatorHelper5CloseEv @ 214 NONAME
+	_ZN8LtkUtils15BreakpointPushLEv @ 215 NONAME
+	_ZNK8LtkUtils16RAllocatorHelper15AllocatorIsUdebEv @ 216 NONAME
+	_ZN8LtkUtils10FormatSizeER5TDes8x @ 217 NONAME
+	_ZN8LtkUtils10FormatSizeER6TDes16x @ 218 NONAME
+	_ZNK8LtkUtils16RAllocatorHelper11DescriptionEv @ 219 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+prj_exports
+
+FSHELL_ROM_INCLUDE(ltkutils.iby)
+..\inc\ltkutils.h		\epoc32\include\fshell\ltkutils.h
+..\inc\ltkutils.inl		\epoc32\include\fshell\ltkutils.inl
+..\inc\stringhash.h		\epoc32\include\fshell\stringhash.h
+..\inc\settings.h		\epoc32\include\fshell\settings.h
+..\inc\bsym.h			\epoc32\include\fshell\bsym.h
+..\inc\descriptorutils.h	\epoc32\include\fshell\descriptorutils.h
+..\inc\heaputils.h		\epoc32\include\fshell\heaputils.h
+..\inc\ltkhal.h			\epoc32\include\fshell\ltkhal.h
+
+prj_mmpfiles
+
+ltkutils.mmp
+ltkutils-tcb.mmp
+
+prj_testmmpfiles
+
+..\tsrc\tstringhash.mmp
+..\tsrc\tsettings.mmp
+..\tsrc\tutf8.mmp
+..\tsrc\tallochelper.mmp
+
+prj_testexports
+
+..\tsrc\test1.idf		\epoc32\winscw\c\resource\test1.idf
+..\tsrc\test2.idf		\epoc32\winscw\c\resource\test2.idf
+..\tsrc\test1.ini		\epoc32\winscw\c\test1.ini
+..\tsrc\test2.ini		\epoc32\winscw\c\test2.ini
+..\tsrc\test3.ini		\epoc32\winscw\c\test3.ini
+..\tsrc\test4.ini		\epoc32\winscw\c\test4.ini
+..\tsrc\test5.ini		\epoc32\winscw\c\test5.ini
+..\tsrc\tset.script		\epoc32\winscw\c\tset.script
+..\tsrc\test6.ini		\epoc32\winscw\c\test6.ini
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/group/ltkutils-tcb.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+// ltkutils-tcb.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+target			ltkutils-tcb.dll
+targettype		dll
+uid				0x100000af FSHELL_UID_LTKUTILS_TCB
+
+capability		FSHELL_CAP_MMP_MAX
+
+nostrictdef
+
+#include <fshell/fsh_system_include.mmh>
+
+userinclude		..\inc
+
+sourcepath		..\src
+source			heaphackery.cpp
+source			proxyallocatorhelper.cpp
+source			keyinject.cpp
+source			hexdump.cpp 
+source			friendlynames.cpp
+source			descriptorJuggling.cpp
+source			settings.cpp
+source			ltkhal.cpp
+
+library 		euser.lib
+library			efsrv.lib
+library			iocli.lib
+library			hal.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/group/ltkutils.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,20 @@
+// ltkutils.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef LTKUTILS_IBY
+#define LTKUTILS_IBY
+
+#include <fsh_config.iby>
+
+FSHELL_EXECUTABLE_FILE(ltkutils.dll)
+FSHELL_EXECUTABLE_FILE(ltkutils-tcb.dll)
+
+#endif // LTKUTILS_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/group/ltkutils.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+// ltkutils.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+
+target			ltkutils.dll
+targettype		dll
+uid				0x100000af FSHELL_UID_LTKUTILS
+
+capability		FSHELL_CAP_MMP_NORMAL
+
+nostrictdef
+
+#include <fshell/fsh_system_include.mmh>
+
+userinclude		..\inc
+
+sourcepath		..\src
+source			heaphackery.cpp
+source			proxyallocatorhelper.cpp
+source			keyinject.cpp
+source			hexdump.cpp 
+source			w32crack.cpp
+source			friendlynames.cpp
+source			rez.cpp
+source			clipboard.cpp
+source			descriptorJuggling.cpp
+source			settings.cpp
+source			bsym.cpp
+source			mapfile.cpp
+source			symbolics.cpp
+source			bsymtree.cpp
+#ifdef ARMCC
+source			breakpoint.cia
+#endif
+source			breakpoint.cpp
+source			ltkhal.cpp
+
+library 		euser.lib
+library			iocli.lib
+library			efsrv.lib
+library			bafl.lib
+library			estor.lib
+library			hal.lib
+
+#ifdef FSHELL_WSERV_SUPPORT
+library			ws32.lib
+#endif
+
+//library			clogger.lib
+
+// Enable these 2 lines to check all the offset calculations in RAllocatorHelper are correct. Requires base_e32 source code to be installed
+//MACRO TEST_HYBRIDHEAP_ASSERTS
+//userinclude ..\..\..\..\sf\os\kernelhwsrv\kernel\eka\include
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/inc/bsym.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,100 @@
+// bsym.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_BSYM_H
+#define FSHELL_BSYM_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <fshell/ioutils.h>
+#include <fshell/stringhash.h>
+class CDesC16Array;
+
+namespace LtkUtils
+	{
+	class CMapFile;
+	class CBsymFile;
+	class RNode;
+
+	NONSHARABLE_CLASS(CSymbolics) : public CBase
+		{
+	public:
+		IMPORT_C CSymbolics(RFs& aFs);
+		IMPORT_C ~CSymbolics();
+		IMPORT_C void AddBsymFileL(const TDesC& aFileName);
+		IMPORT_C void AddMapFileL(const TDesC& aFileName);
+		IMPORT_C void AddMapFileL(CMapFile* aMapFile); // Takes ownership
+		IMPORT_C void SetFallbackMapFileDirL(const TDesC& aDir);
+
+		IMPORT_C TPtrC LookupL(TUint32 aRomAddress);
+		IMPORT_C TPtrC LookupL(const TDesC& aCodeseg, TUint32 aOffset); // Need to use memaccess or similar to get codeseg name
+
+		IMPORT_C void CompleteL(const TDesC& aCodeseg, TDes& aSymbolName, CDesC16Array& aSuggestions);
+		IMPORT_C TUint32 CodesegOffsetFromSymbolNameL(const TDesC& aCodeseg, const TDesC& aSymbolName);
+
+	private:
+		CMapFile* FindOrLoadMapFileL(const TDesC& aCodeseg);
+		RNode* TreeForCodesegL(const TDesC& aCodeseg);
+
+	private:
+		RFs& iFs;
+		RStringHash<CMapFile*> iCodeSegHash;
+		RPointerArray<CBsymFile> iBsyms;
+		TFileName iFallbackMapFileDir;
+		TBuf<256> iTempString;
+		RNode* iTabCompleteTree;
+		HBufC* iTabCompleteCodeseg;
+		};
+
+	NONSHARABLE_CLASS(CBsymFile) : public CBase
+		{
+	public:
+		IMPORT_C static CBsymFile* NewL(RFs& aFs, const TDesC& aFileName);
+		IMPORT_C ~CBsymFile();
+		IMPORT_C TPtrC LookupL(TUint32 aRomAddress);
+		IMPORT_C TPtrC LookupL(const TDesC& aCodesegName, TInt aOffset);
+
+		RNode* CreateCompletionTreeL(const TDesC& aCodesegName);
+
+	protected:
+		CBsymFile();
+
+	protected:
+		RFile iFile;
+		TUint iFileSize;
+		TUint32 iVersion;
+		TUint32 iCodesegOffset;
+		TUint32 iSymbolsOffset;
+		TUint32 iTokensOffset;
+		};
+
+	NONSHARABLE_CLASS(CMapFile) : public CBase
+		{
+	public:
+		IMPORT_C static CMapFile* NewL(RFs& aFs, const TDesC& aFileName);
+		IMPORT_C ~CMapFile();
+		IMPORT_C void Lookup(TUint32 aOffsetInCodeSeg, TDes& aResult);
+		IMPORT_C void GetFileNameL(TDes& aFileName) const;
+		RNode* CreateCompletionTreeL();
+
+	protected:
+		CMapFile();
+		void ConstructL(RFs& aFs, const TDesC& aFileName);
+		TBool GetNextLine(TPtrC8& aPtr);
+
+	protected:
+		RFile iFile;
+		RBuf8 iReadBuf;
+		TInt iTextOffset;
+		HBufC* iFileName;
+		};
+	}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/inc/descriptorutils.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,173 @@
+// descriptorutils.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_DESCRIPTORUTILS_H
+#define FSHELL_DESCRIPTORUTILS_H
+
+#include <e32std.h>
+
+namespace LtkUtils
+	{
+	class TUtf8State;
+
+	NONSHARABLE_CLASS(RLtkBuf16) : public TDes16
+		{
+	public:
+		IMPORT_C RLtkBuf16();
+		IMPORT_C RLtkBuf16(HBufC16* aBuf); // Takes ownership
+
+		// The new, useful functions that RBuf doesn't give you
+		IMPORT_C HBufC16* ToHBuf(); // Caller is responsible for deleting the result. This function Closes the RLtkBuf.
+		IMPORT_C HBufC16* GetHBuf() const;
+		IMPORT_C void AppendL(const TDesC16& aText);
+		IMPORT_C void AppendL(const TDesC8& aText);
+		IMPORT_C void AppendL(TChar aChar);
+		IMPORT_C void AppendFormatL(TRefByValue<const TDesC16> aFmt, ...);
+		IMPORT_C void ReplaceL(TInt aPos, TInt aLength, const TDesC16 &aDes);
+		IMPORT_C void ReplaceAllL(const TDesC& aFrom, const TDesC16& aTo);
+		IMPORT_C void ReserveExtraL(TInt aExtraCapacity);
+		IMPORT_C TInt ReserveExtra(TInt aExtraCapacity);
+		IMPORT_C void CreateLC(TInt aMaxLength);
+
+		/**
+		Leaves on OOM. Converts the argument aUtf8EncodedText from UTF-8 to the native UTF-16 and appends the result to this
+		descriptor. You can handle your data in chunks by calling AppendUtf8L repeatedly. You don't have to worry about UTF-8
+		sequences being split between chunks - fragmented end sequences are cached and will be reassembled if a further call
+		to AppendUtf8L is made with the rest of the bytes. Such sequences are not considered malformed unless (a) the next call
+		to AppendUtf8L doesn't produce a valid sequence, or (b) FinalizeUtf8 is called instead of a further append. Sequences 
+		that are decided to be malformed are replaced with the unicode replacement char U+FFFD. You are free to mix calls to
+		AppendUtf8L with other normal descriptor operations such as Delete, Insert or ReAlloc. You shouldn't however copy
+		the buffer or call any other Append functions without finalizing it first. Once you have finished appending UTF-8
+		you must call FinalizeUtf8().
+		*/
+		IMPORT_C void AppendUtf8L(const TDesC8& aUtf8EncodedText);
+
+		/**
+		Like the above, but returns by reference the index of the first byte of the first malformed sequence in aUtf8EncodedText (or
+		KErrNotFound if it was totally valid). Useful if you want to stop appending the minute you see a malformed sequence
+		and thus don't want to have to wait until you call FinalizeUtf8() to get that information.
+		*/
+		IMPORT_C void AppendUtf8L(const TDesC8& aUtf8EncodedText, TInt& aFirstBadBytePosition);
+
+		/**
+		Must be called at the end of a sequence of AppendUtf8L() calls. Clears all UTF-8 related state from the descriptor.
+		Returns KErrCorrupt if any malformed sequences were encountered in any of the AppendUtf8L() calls. You are free to
+		ignore this return code if you wish: malformed sequences get replaced with U+FFFD and the rest of the string continues
+		to be parsed. Returns KErrNone if there were no problems.
+		*/
+		IMPORT_C TInt FinalizeUtf8();
+
+		/**
+		Like the above, but returns by reference the index of the first byte of the first malformed sequence found cumulatively
+		across all invocations of AppendUtf8L(). aFirstBadBytePosition is set to KErrNotFound if the data was totally valid.
+		*/
+		IMPORT_C void FinalizeUtf8(TInt& aFirstBadBytePosition);
+
+
+		/**
+		Convenience method. Equivalent to:
+		this->Zero();
+		this->AppendUtf8L(aText);
+		User::LeaveIfError(this->FinalizeUtf8());
+		*/
+		IMPORT_C void CopyFromUtf8L(const TDesC8& aUtf8EncodedText);
+
+		// The usual RBuf-like APIs (for everything else, it just inherits from TDes16)
+		IMPORT_C TInt ReAlloc(TInt aMaxLength);
+		IMPORT_C void ReAllocL(TInt aMaxLength);
+		IMPORT_C void Assign(HBufC16* aBuf);
+		IMPORT_C TInt Create(TInt aMaxLength);
+		IMPORT_C void CreateL(TInt aMaxLength);
+		IMPORT_C TInt CreateMax(TInt aMaxLength);
+		IMPORT_C void CreateMaxL(TInt aMaxLength);
+		IMPORT_C void Close();
+
+	private:
+		TUtf8State* GetUtf8State() const;
+		void ClearUtf8State();
+
+	private:
+		HBufC16* iBuf;
+		};
+
+	NONSHARABLE_CLASS(RLtkBuf8) : public TDes8
+		{
+	public:
+		IMPORT_C RLtkBuf8();
+		IMPORT_C RLtkBuf8(HBufC8* aBuf); // Takes ownership
+
+		// The new, useful functions that RBuf doesn't give you
+		IMPORT_C HBufC8* ToHBuf(); // Caller is responsible for deleting the result. This function Closes the RLtkBuf.
+		IMPORT_C HBufC8* GetHBuf() const;
+		IMPORT_C void AppendL(const TDesC8& aText);
+		IMPORT_C void AppendL(const TDesC16& aText);
+		IMPORT_C void AppendL(TChar aChar);
+		IMPORT_C void AppendFormatL(TRefByValue<const TDesC8> aFmt, ...);
+		IMPORT_C void ReplaceL(TInt aPos, TInt aLength, const TDesC8& aDes);
+		IMPORT_C void ReplaceAllL(const TDesC8& aFrom, const TDesC8& aTo);
+		IMPORT_C void ReserveExtraL(TInt aExtraCapacity);
+		IMPORT_C TInt ReserveExtra(TInt aExtraCapacity);
+		IMPORT_C void CreateLC(TInt aMaxLength);
+		IMPORT_C void CopyAsUtf8L(const TDesC16& aString);
+
+		// The usual RBuf-like APIs (for everything else, it just inherits from TDes8)
+		IMPORT_C TInt ReAlloc(TInt aMaxLength);
+		IMPORT_C void ReAllocL(TInt aMaxLength);
+		IMPORT_C void Assign(HBufC8* aBuf);
+		IMPORT_C TInt Create(TInt aMaxLength);
+		IMPORT_C void CreateL(TInt aMaxLength);
+		IMPORT_C TInt CreateMax(TInt aMaxLength);
+		IMPORT_C void CreateMaxL(TInt aMaxLength);
+		IMPORT_C void Close();
+
+	private:
+		HBufC8* iBuf;
+		};
+
+	typedef RLtkBuf16 RLtkBuf;
+
+	/* Use this class for const static arrays of descriptors. Eg:
+	 *
+	 * const SLitC KData[] = 
+	 *     {
+	 *     DESC("A string"),
+	 *     DESC("Another string"),
+	 *     };
+	 *
+	 * You can treat the array items the same as TLitCs - ie most of the time they behave as descriptors but
+	 * sometimes you may need to use operator().
+	 */
+	struct SLitC
+		{
+		inline const TDesC* operator&() const { return reinterpret_cast<const TDesC*>(this); }
+		inline operator const TDesC&() const { return *reinterpret_cast<const TDesC*>(this); }
+		inline const TDesC& operator()() const { return *reinterpret_cast<const TDesC*>(this); }
+
+		TInt iLength;
+		const TUint16* iPtr;
+		};
+	struct SLitC8
+		{
+		inline const TDesC8* operator&() const { return reinterpret_cast<const TDesC8*>(this); }
+		inline operator const TDesC8&() const { return *reinterpret_cast<const TDesC8*>(this); }
+		inline const TDesC8& operator()() const { return *reinterpret_cast<const TDesC8*>(this); }
+
+		TInt iLength;
+		const TUint8* iPtr;
+		};
+
+#define DESC(x) { ((sizeof(L##x) / 2)-1) | 0x10000000, (const TUint16*) L##x }
+#define DESC8(x) { (sizeof(x) - 1) | 0x10000000, (const TUint8*)x }
+// 0x10000000 is EPtrC<<KShiftDesType
+
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/inc/heaputils.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,216 @@
+// heaputils.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef FSHELL_HEAP_UTILS_H
+#define FSHELL_HEAP_UTILS_H
+
+#include <e32cmn.h>
+
+#ifdef __KERNEL_MODE__
+class DThread;
+class DChunk;
+#else
+class RMemoryAccess;
+#endif // __KERNEL_MODE__
+
+#if defined(STANDALONE_ALLOCHELPER) || defined(__KERNEL_MODE__)
+#define HUIMPORT_C
+#define HUCLASS(x) NONSHARABLE_CLASS(x)
+#else
+#define HUIMPORT_C IMPORT_C
+#define HUCLASS(x) class x
+#endif
+
+namespace LtkUtils
+	{
+
+class THeapInfo;
+	
+HUCLASS(RAllocatorHelper) // class RAllocatorHelper
+	{
+public:
+	HUIMPORT_C RAllocatorHelper();
+#ifdef __KERNEL_MODE__
+	TInt OpenKernelHeap();
+#else
+	HUIMPORT_C TInt Open(RAllocator* aAllocator);
+#endif
+	HUIMPORT_C TInt SetCellNestingLevel(TAny* aCell, TInt aNestingLevel);
+	HUIMPORT_C TInt GetCellNestingLevel(TAny* aCell, TInt& aNestingLevel);
+	HUIMPORT_C TInt AllocCountForCell(TAny* aCell) const;
+	HUIMPORT_C TLinAddr AllocatorAddress() const;
+	HUIMPORT_C TInt RefreshDetails();
+	
+	HUIMPORT_C TInt CommittedSize();
+	HUIMPORT_C TInt AllocatedSize();
+	HUIMPORT_C TInt AllocationCount();
+	HUIMPORT_C TInt MaxCommittedSize();
+	HUIMPORT_C TInt MinCommittedSize();
+	HUIMPORT_C TInt CountUnusedPages();
+	HUIMPORT_C TInt CommittedFreeSpace();
+
+	enum TCellType
+		{
+		EAllocation, EFreeSpace, EBadness
+		};
+
+	enum TExtendedCellType
+		{
+		EAllocationMask = 0xFF,
+		EFreeMask = 0xFF00,
+		EBadnessMask = 0xFF000000,
+
+		EHeapAllocation = 1,
+		EDlaAllocation = 2,
+		EPageAllocation = 3,
+		ESlabAllocation = 4,
+		
+		EHeapFreeCell = 0x0100,
+		EDlaFreeCell = 0x0200,
+		// There is nothing 'free' in the page allocator
+		ESlabFreeCell = 0x0300, // Used to track free cells in partially-filled slabs
+		ESlabFreeSlab = 0x0400, // Used to track entirely empty slabs (that don't have a specific cell size)
+
+		EHeapBadFreeCellAddress = 0x01000000,
+		EHeapBadFreeCellSize = 0x02000000,
+		EHeapBadAllocatedCellSize = 0x03000000,
+		EHeapBadAllocatedCellAddress = 0x04000000,
+		};
+			
+	// TBool WalkFunc(TAny* aContext, TCellType aCellType, TLinAddr aCellPtr, TInt aCellLength)
+	// aCellPtr points to the start of the cell payload for allocated cells (unlike RHeap's walker, which points to the cell header)
+	// aCellLength is the payload length, ie what AllocLen(aCellPtr) would return
+	// return ETrue to continue walking, EFalse to stop the walk
+	typedef TBool (*TWalkFunc)(TAny*, TCellType, TLinAddr, TInt);
+	typedef TBool (*TWalkFunc2)(RAllocatorHelper&, TAny*, TCellType, TLinAddr, TInt);
+	typedef TBool (*TWalkFunc3)(RAllocatorHelper&, TAny*, TExtendedCellType, TLinAddr, TInt);
+	HUIMPORT_C TInt Walk(TWalkFunc aCallbackFn, TAny* aContext);
+	HUIMPORT_C TInt Walk(TWalkFunc2 aCallbackFn, TAny* aContext); // Like the other but the walk func gives you the RAllocatorHelper pointer too
+	HUIMPORT_C TInt Walk(TWalkFunc3 aCallbackFn, TAny* aContext); // Like the other but the walk func gives you more details about the allocation type
+	HUIMPORT_C TInt SizeForCellType(TExtendedCellType aType);
+	HUIMPORT_C TInt CountForCellType(TExtendedCellType aType);
+	HUIMPORT_C TBool AllocatorIsUdeb() const;
+	HUIMPORT_C const TDesC& Description() const;
+	HUIMPORT_C virtual void Close();
+
+#ifdef __KERNEL_MODE__
+	virtual DChunk* OpenUnderlyingChunk(); // Must be in CS
+	enum TType
+		{
+		ETypeUnknown,
+		ETypeRHeap,
+		ETypeRHybridHeap,
+		};
+	TType GetType() const; // This is for information only, nothing should care about the return value
+#endif
+
+protected:
+	TInt FinishConstruction();
+	TInt IdentifyAllocatorType(TBool aAllocatorIsUdeb);
+	TInt OpenChunkHeap(TLinAddr aChunkBase, TInt aChunkMaxSize);
+#ifndef __KERNEL_MODE__
+	static TInt EuserIsUdeb();
+#endif
+	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
+	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
+	virtual TInt TryLock();
+	virtual void TryUnlock();
+
+private:
+	TInt ReadWord(TLinAddr aLocation, TUint32& aResult) const;
+	TInt ReadByte(TLinAddr aLocation, TUint8& aResult) const;
+	TInt WriteWord(TLinAddr aLocation, TUint32 aWord);
+	TInt RefreshDetails(TUint aMask);
+	TInt DoRefreshDetails(TUint aMask);
+	TInt CheckValid(TUint aMask);
+	TInt DoWalk(TWalkFunc3 aCallbackFn, TAny* aContext);
+	TInt OldSkoolWalk(TWalkFunc3 aCallbackFn, TAny* aContext);
+	TInt NewHotnessWalk(TWalkFunc3 aCallbackFn, TAny* aContext);
+	static TBool DispatchClientWalkCallback(RAllocatorHelper& aHelper, TAny* aContext, TExtendedCellType aCellType, TLinAddr aCellPtr, TInt aCellLength);
+	static TBool WalkForStats(RAllocatorHelper& aSelf, TAny* aContext, TExtendedCellType aType, TLinAddr aCellPtr, TInt aCellLength);
+	TUint PageMapOperatorBrackets(unsigned ix, TInt& err) const;
+	TInt PageMapFind(TUint start, TUint bit, TInt& err);
+	TUint PageMapBits(unsigned ix, unsigned len, TInt& err);
+	TUint PagedDecode(TUint pos, TInt& err);
+	TInt TreeWalk(TUint32 aSlabRoot, TInt aSlabType, TWalkFunc3 aCallbackFn, TAny* aContext, TBool& shouldContinue);
+protected:
+	TLinAddr iAllocatorAddress;
+	enum TAllocatorType
+		{
+		EUnknown,
+		EAllocator,
+		EUrelOldRHeap,
+		EUdebOldRHeap,
+		EUrelHybridHeap,
+		EUdebHybridHeap,
+		};
+	TAllocatorType iAllocatorType;
+private:
+	THeapInfo* iInfo;
+	TUint iValidInfo;
+	TUint8* iTempSlabBitmap;
+	mutable TAny* iPageCache;
+	mutable TLinAddr iPageCacheAddr;
+#ifdef __KERNEL_MODE__
+	DChunk* iChunk;
+	//TUint iSpare[0];
+#else
+	TUint iSpare[1];
+#endif
+	};
+
+#ifdef __KERNEL_MODE__
+
+class RKernelSideAllocatorHelper : public RAllocatorHelper
+	{
+public:
+	RKernelSideAllocatorHelper();
+	TInt OpenUserHeap(TUint aThreadId, TLinAddr aAllocatorAddress, TBool aEuserIsUdeb);
+	virtual DChunk* OpenUnderlyingChunk(); // Must be in CS
+	virtual void Close();
+
+protected:
+	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
+	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
+	virtual TInt TryLock();
+	virtual void TryUnlock();
+private:
+	DThread* iThread;
+	};
+
+#else
+
+class RProxyAllocatorHelper : public RAllocatorHelper
+	{
+public:
+	HUIMPORT_C RProxyAllocatorHelper();
+	HUIMPORT_C TInt Open(RMemoryAccess& aMem, TUint aThreadId);
+	HUIMPORT_C TInt OpenChunkHeap(RMemoryAccess& aMem, TAny* aDChunkPtr);
+	HUIMPORT_C virtual void Close();
+
+protected:
+	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
+	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
+	virtual TInt TryLock();
+	virtual void TryUnlock();
+
+private:
+	RMemoryAccess* iMemoryAccess;
+	TUint iThreadId;
+	};
+
+#endif // __KERNEL_MODE__
+
+	} // namespace LtkUtils
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/inc/ltkhal.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+// ltkhal.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef LTKHAL_H
+#define LTKHAL_H
+
+#include <e32base.h>
+
+namespace LtkUtils
+	{
+	NONSHARABLE_CLASS(CHalAttribute) : public CBase
+		{
+	public:
+		CHalAttribute(TInt aAttribute, TInt aDeviceNumber, TInt aValue, TInt aError, const TDesC& aAttributeName, HBufC* aDescription);
+		IMPORT_C ~CHalAttribute();
+
+		TInt iAttribute;
+		TInt iDeviceNumber;
+		TInt iValue;
+		TInt iError; // If not KErrNone, iValue will not be valid
+		const TDesC& iAttributeName;
+		HBufC* iDescription;
+		};
+
+	IMPORT_C void GetHalInfoL(RPointerArray<CHalAttribute>& aAttributes);
+	IMPORT_C CHalAttribute* GetHalInfoL(TInt aAttribute);
+	IMPORT_C CHalAttribute* GetHalInfoL(TInt aDeviceNumber, TInt aAttribute);
+
+	IMPORT_C CHalAttribute* GetHalInfoForValueL(TInt aDeviceNumber, TInt aAttribute, TInt aValue);
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/inc/ltkutils.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,105 @@
+// ltkutils.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_UTILS
+#define FSHELL_UTILS
+
+#include <e32base.h>
+class RIoWriteHandle;
+class RFs;
+
+namespace LtkUtils
+	{
+	/* This function makes the object allocated at aPtr be ignored by __UHEAP_MARK/__UHEAP_MARK_END etc
+	 * This is useful for objects whose lifetime is carefully managed (ie they really aren't leaked) but have
+	 * no suitable place to be cleaned up. Objects stored in TLS are a good example.
+	 * Has no effect if run against a UREL euser.dll
+	 */
+	IMPORT_C void MakeHeapCellInvisible(TAny* aPtr);
+
+	IMPORT_C TInt InjectRawKeyEvent(TInt aScanCode, TInt aModifiers, TInt aRepeatCount);
+
+	IMPORT_C HBufC* HexDumpL(const TDesC8& aBuf);
+	IMPORT_C void HexDumpToOutput(const TDesC8& aBuf, RIoWriteHandle& aHandle);
+	IMPORT_C void HexDumpToOutput(const TDesC8& aBuf, RIoWriteHandle& aHandle, TInt& aOffset);
+	IMPORT_C void HexDumpToRDebug(const TDesC8& aBuf);
+	IMPORT_C void HexDumpToRDebug(const TDesC8& aBuf, TInt& aOffset);
+	IMPORT_C void RawPrint(const TDesC8& aDes); // 9.1 doesn't have the 8-bit overload
+
+	IMPORT_C void GetFriendlyThreadName(RThread aThread, TFullName& aFriendly);
+	IMPORT_C void MakeThreadNameFriendly(TFullName& aFullThreadName);
+	IMPORT_C void GetFriendlyProcessName(const RProcess& aProcess, TDes& aFriendly);
+	IMPORT_C void MakeProcessNameFriendly(TDes& aFullProcessName);
+
+	IMPORT_C TUint HexLexL(TLex16& aLex);
+	IMPORT_C TInt HexLex(TLex16& aLex, TUint& aResult);
+	IMPORT_C TUint HexLexL(TLex8& aLex);
+	IMPORT_C TInt HexLex(TLex8& aLex, TUint& aResult);
+
+	IMPORT_C TBool HasPrefix(const TDesC16& aDes, const TDesC16& aPrefix);
+	IMPORT_C TBool HasPrefix(const TDesC8& aDes, const TDesC8& aPrefix);
+
+	/* Replace all occurences of aFrom with aTo, in aDescriptor. Returns number of replacements,
+	 * or KErrOverflow if aDescriptor was not big enough to hold all the replacements
+	 */
+	IMPORT_C TInt ReplaceText(TDes& aDescriptor, const TDesC& aFrom, const TDesC& aTo);
+
+	IMPORT_C HBufC8* Utf8L(const TDesC& aString); // For more control see LtkUtils::RLtkBuf8::CopyAsUtf8L()
+	IMPORT_C HBufC16* DecodeUtf8L(const TDesC8& aUtf8EncodedText); // For more control see LtkUtils::RLtkBuf16::AppendUtf8L()
+
+	IMPORT_C void FormatSize(TDes16& aBuf, TInt64 aSizeInBytes);
+	IMPORT_C void FormatSize(TDes8& aBuf, TInt64 aSizeInBytes);
+
+	/* Some cleanup stack helper functions (defined in ltkutils.inl)
+	 */
+	template <class T>
+	inline void CleanupResetAndDestroyPushL(T& aRef);
+	template <class T>
+	inline void CleanupResetPushL(T& aRef);
+
+	/****
+	 * The functions below are not available if you're linking against ltkutils-tcb.dll. They
+	 * rely on being able to link against All -TCB dlls.
+	 ****/
+
+	/* W32CrackL loads our btrace-compatible wserv logging engine, dlogev.dll, into the existing wserv process. 
+	 * This enables Autometric to capture i/o events like key & pointer presses, and text drawn to screen.
+	 * It also enables btrace logging of windowgroup names. Does nothing if dlogev is already loaded.
+	 */
+	const TUid KW32CrackCategory = { 0x10003B20 };
+	const TInt KW32CrackKey = 0x102864C5;
+	IMPORT_C void W32CrackL();
+	IMPORT_C TBool W32CrackIsEnabled();
+
+	/* These functions convert a resource identifier (of the format given in the rez.exe docs) into
+	 * the localised equivalent.
+	 */
+	IMPORT_C HBufC* RezL(const TDesC& aIdentifier, RFs* aFs = NULL, HBufC** aError=NULL);
+	IMPORT_C HBufC* RezLC(const TDesC& aIdentifier, RFs* aFs = NULL, HBufC** aError=NULL);
+	IMPORT_C HBufC8* Rez8L(const TDesC& aIdentifier, RFs* aFs = NULL, HBufC** aError=NULL);
+	IMPORT_C HBufC8* Rez8LC(const TDesC& aIdentifier, RFs* aFs = NULL, HBufC** aError=NULL);
+
+	IMPORT_C void CopyToClipboardL(const TDesC& aText, RFs* aFs = NULL);
+	IMPORT_C HBufC* GetFromClipboardL(RFs* aFs = NULL);
+
+	
+	/* Programatically cause a breakpoint to occur. On emulator this translates to a call to __BREAKPOINT,
+	 * on target this will break if fdb is installed, otherwise will crash the thread.
+	 */
+	IMPORT_C void Breakpoint();
+
+	IMPORT_C void BreakpointPushL(); // Push a TCleanupItem onto the CleanupStack that calls LtkUtils::Breakpoint() if a leave occurs
+	IMPORT_C TLinAddr BreakpointAddr(); // Internal helper function, only for use by fdb.exe
+	}
+
+#include <fshell/ltkutils.inl>
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/inc/ltkutils.inl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// ltkutils.inl
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+namespace LtkUtils
+	{
+	template <class T>
+	class CleanupDestroy
+		{
+	public:
+		inline static void PushL(T& aRef) { CleanupStack::PushL(TCleanupItem(&Destroy, &aRef)); }
+	private:
+		static void Destroy(TAny *aPtr) { static_cast<T*>(aPtr)->ResetAndDestroy(); }
+		};
+		
+	template <class T>
+	class CleanupReset
+		{
+	public:
+		inline static void PushL(T& aRef) { CleanupStack::PushL(TCleanupItem(&Reset, &aRef)); }
+	private:
+		static void Reset(TAny *aPtr) { static_cast<T*>(aPtr)->Reset(); }
+		};
+		
+	template <class T>
+	inline void CleanupResetAndDestroyPushL(T& aRef) { CleanupDestroy<T>::PushL(aRef); }
+
+	template <class T>
+	inline void CleanupResetPushL(T& aRef) {CleanupReset<T>::PushL(aRef);}
+
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/inc/settings.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,223 @@
+// settings.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SETTINGSEDITOR_H__
+#define __SETTINGSEDITOR_H__
+
+#include <e32base.h>
+#include <e32hashtab.h>
+#include <fshell/ioutils.h>
+
+namespace LtkUtils
+	{
+	
+	_LIT(KSettingPanic, "FSHELL_settings");
+	enum TSettingPanic
+		{
+		EInvalidType,
+		ENotDefined,
+		};
+
+/**
+Class for encapsulating the context of an error within a text file that is being processed.
+
+Note, the valid lifetime of this class is tied to the lifetime of the decriptor it refers to.
+Often, this is a descriptor on the stack and so copies of this class must not be kept.
+*/
+class TErrorContext
+	{
+public:
+	IMPORT_C TErrorContext();
+	IMPORT_C TErrorContext(const TDesC& aFilename);
+	IMPORT_C void NextLine();
+	IMPORT_C TInt LineNumber();
+	IMPORT_C const TDesC& StringLC();
+private:
+	const TPtrC iFilename;
+	TInt iLineNumber;
+	};
+	
+class MValueHandler
+	{
+public:
+	virtual void HandleValueL(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext, TBool aOverwrite) = 0;
+	virtual void HandleCommentL(const TDesC& aComment, TErrorContext aErrorContext) = 0;
+	};
+	
+class CIniReader;
+
+enum TFileNotFoundAction
+	{
+	EFailIfFileNotFound,
+	ESucceedIfFileNotFound,
+	};
+	
+IMPORT_C void ReadIniFileL(const TDesC& aFilename, MValueHandler& aValueHandler, TErrorContext aErrorContext = TErrorContext(), TFileNotFoundAction aNotFoundAction = EFailIfFileNotFound);
+IMPORT_C void ReadIniFileL(RIoReadHandle& aReadHandle, MValueHandler& aValueHandler);
+IMPORT_C void WriteIniFileL(const TDesC& aFilename, CIniReader& aValues);
+
+class CValue : public CBase
+	{
+public:
+	IMPORT_C static CValue* NewL(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext = TErrorContext());
+	IMPORT_C static CValue* NewLC(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext = TErrorContext());
+	IMPORT_C ~CValue();
+	
+	IMPORT_C const TDesC& Id() const;
+	IMPORT_C const TDesC& Value() const;
+	IMPORT_C virtual void SetL(const TDesC& aNewValue, TErrorContext aErrorContext);
+	IMPORT_C TInt LineNumber() const;
+	IMPORT_C virtual TInt AsInt(TInt& aInt) const;
+	IMPORT_C virtual TInt AsBool(TBool& aBool) const;
+	IMPORT_C TInt AsIntL() const;
+	IMPORT_C TBool AsBoolL() const;
+	
+protected:
+	CValue(TErrorContext aErrorContext);
+	void ConstructL(const TDesC& aId, const TDesC& aValue);
+private:
+	RBuf iId;
+	RBuf iValue;
+protected:
+	TInt iLineNumber;
+	};
+
+/**
+Class for reading an fshell style INI file. This class is intended to be robust, and should always
+read the file even if it has errors in it.
+
+The class CIniFile is more strict and will validate the contents of the file as it is read.
+*/
+class CIniReader	: public CBase
+					, public MValueHandler
+	{
+public:
+	IMPORT_C static CIniReader* NewL(const TDesC& aFilename, TErrorContext aErrorContext = TErrorContext());
+	IMPORT_C ~CIniReader();
+	
+	IMPORT_C const TDesC* GetValue(const TDesC& aId) const;
+	IMPORT_C void GetValuesL(RPointerArray<CValue>& aValues);
+	IMPORT_C void GetValuesL(RPointerArray<const CValue>& aValues) const;
+	IMPORT_C void GetIdsL(RArray<const TPtrC>& aIds) const;
+	
+	IMPORT_C void SetValueL(const TDesC& aId, const TDesC& aValue);
+	IMPORT_C void RemoveValueL(const TDesC& aId);
+	
+	void AppendFirstLineL(IoUtils::CTextFormatter* aFormatter);
+protected: // from MValueHandler
+	virtual void HandleValueL(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext, TBool aOverwrite);
+	virtual void HandleCommentL(const TDesC& aComment, TErrorContext aErrorContext);
+protected:
+	virtual CValue* CreateValueLC(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext);
+	virtual void HandleFirstLineCommentL(const TDesC&, TErrorContext) {};
+	virtual TBool IncludeValue(const CValue*) const { return ETrue; }
+	virtual void DoRemoveL(CValue* aValue);
+	CIniReader();
+protected:
+	RPtrHashMap<TDesC, CValue> iValues;
+	RBuf iFirstLineComment;
+	};
+	
+enum TSettingType
+	{
+	ETypeEnum,
+	ETypeFilename,
+	ETypeString,
+	ETypeInteger,
+	ETypeBoolean,
+	};
+	
+class CSetting : public CValue
+	{
+public:
+	IMPORT_C static CSetting* NewL(TSettingType aType, const TDesC& aId, const TDesC& aName, const TDesC& aDescription, const TDesC& aDefault = KNullDesC, const TDesC& aEnumValues = KNullDesC, TErrorContext aErrorContext = TErrorContext());
+	IMPORT_C static CSetting* NewLC(TSettingType aType, const TDesC& aId, const TDesC& aName, const TDesC& aDescription, const TDesC& aDefault = KNullDesC, const TDesC& aEnumValues = KNullDesC, TErrorContext aErrorContext = TErrorContext());
+	IMPORT_C ~CSetting();
+	
+	IMPORT_C virtual void SetL(const TDesC& aNewValue, TErrorContext aErrorContext = TErrorContext());
+	IMPORT_C void SetL(TInt aNewValue);
+	IMPORT_C virtual TInt AsInt(TInt& aInt) const;
+	IMPORT_C virtual TInt AsBool(TBool& aBool) const;
+	IMPORT_C TInt AsInt() const;
+	IMPORT_C TBool AsBool() const;
+	
+	IMPORT_C TBool IsSet() const;
+	IMPORT_C void ClearL();
+	
+	IMPORT_C const TDesC& Name();
+	IMPORT_C const TDesC& Description();
+private:
+	CSetting(TSettingType aType);
+	void ConstructL(const TDesC& aId, const TDesC& aName, const TDesC& aDescription, const TDesC& aDefault, const TDesC& aEnumValues, TErrorContext aErrorContext = TErrorContext());
+	TInt ParseL(const TDesC& aValue, TErrorContext aErrorContext);
+private:
+	const TSettingType iType;
+	RBuf iName;
+	RBuf iDescription;
+	RBuf iDefault;
+	RBuf iEnumValues;
+	TInt iIntValue;
+	TInt iDefaultInt;
+	TBool iIsSet;
+	IoUtils::TEnum iEnum;
+	};
+	
+/**
+Class for validating an fshell style ini file. This class will fail (and reports useful errors) if the
+file is corrupt of invalid in any way. The file will be validated using an INI description file (IDF).
+*/
+class CIniFile : public CIniReader
+	{
+public:
+	/**
+	Read and validate an INI file.
+	
+	If an IDF file is given, it will be used to validate the INI file regardless of any #!iniedit
+	line at the start of the file. Also, if the INI file given does not exist, this function will
+	still succeed and can then be used to create the INI file by calling WriteIniFileL().
+	
+	If no IDF file is specified here, then an IDF file specified in the #!iniedit comment on the
+	first line will be used. Note, if the INI file does not exist this function will fail in this
+	case.
+	*/
+	IMPORT_C static CIniFile* NewL(const TDesC& aIniFile, const TDesC& aInfoFile = KNullDesC);
+	IMPORT_C ~CIniFile();
+	IMPORT_C CSetting* GetSetting(const TDesC& aId);
+	
+	IMPORT_C const TDesC& GetString(const TDesC& aId);
+	IMPORT_C TInt GetInt(const TDesC& aId);
+	IMPORT_C TBool GetBool(const TDesC& aId);
+	
+	IMPORT_C void SetL(const TDesC& aId, const TDesC& aString);
+	IMPORT_C void SetL(const TDesC& aId, TInt aInt);
+	
+	IMPORT_C void WriteL();
+	
+protected:// from CIniReader
+	virtual CValue* CreateValueLC(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext);
+	virtual void HandleFirstLineCommentL(const TDesC& aComment, TErrorContext aErrorContext);
+	virtual TBool IncludeValue(const CValue* aValue) const;
+	virtual void DoRemoveL(CValue* aValue);
+protected: // from MValueHandler
+	virtual void HandleValueL(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext, TBool aOverwrite);
+private:
+	CIniFile();
+	void ConstructL(const TDesC& aIniFile, const TDesC& aInfoFile);
+	void ReadInfoFileL(const TDesC& aFileName, TErrorContext aErrorContext);
+private:
+	CIniReader* iInfoFile;
+	RBuf iFilename;
+	};
+
+	} // namespace LtkUtils
+
+#endif //__SETTINGSEDITOR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/inc/stringhash.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,280 @@
+// stringhash.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_STRINGHASH_H
+#define FSHELL_STRINGHASH_H
+
+#include <e32hashtab.h>
+
+namespace LtkUtils
+	{
+	template <typename T> class TStringHashIter;
+	template <typename T> struct SHashVal { HBufC* iKey; T iValue; };
+	
+	template <typename T>
+	class RStringHash
+		{
+	public: // RHashMap-style
+		inline RStringHash();
+		inline T* Find(const TDesC& aKey);
+		inline T FindPtr(const TDesC& aKey); // Only use if T is a pointer
+		inline T& FindL(const TDesC& aKey);
+		inline T const* Find(const TDesC& aKey) const;
+		inline T const FindPtr(const TDesC& aKey) const; // Only use if T is a pointer
+		inline T const& FindL(const TDesC& aKey) const;
+		inline TInt Insert(const TDesC& aKey, const T& aValue);
+		inline void InsertL(const TDesC& aKey, const T& aValue);
+		inline TInt Remove(const TDesC& aKey);
+
+		inline TInt Count() const;
+		inline TInt Reserve(TInt aCount);
+		inline void ReserveL(TInt aCount);
+		inline void Close();
+
+	protected:
+		inline SHashVal<T>* DoFind(const TDesC& aKey);
+		inline SHashVal<T> const* DoFind(const TDesC& aKey) const;
+		friend class TStringHashIter<T>;
+
+		RHashMap<TDesC*, SHashVal<T> > iHash;
+		TAny* iSpare;
+		TAny* iSpare2;
+		};
+
+	template <typename T>
+	class TStringHashIter
+		{
+	public:
+		inline TStringHashIter(const RStringHash<T>& aHash);
+		inline const TDesC* CurrentKey() const;
+		inline const TDesC* NextKey();
+		inline T* CurrentValue();
+		inline const T* NextValue();
+		inline void RemoveCurrent();
+
+	private:
+		THashMapIter<TDesC*, SHashVal<T> > iIter;
+		};
+
+	inline TUint32 HashFn(TDesC* const& aKey);
+	inline TBool IdFn(TDesC* const& aFirst, TDesC* const& aSecond);
+	}
+
+
+// Nothing to see here, move along move along
+
+template <typename T>
+LtkUtils::RStringHash<T>::RStringHash()
+	: iHash(THashFunction32<TDesC*>(&HashFn), TIdentityRelation<TDesC*>(&IdFn)), iSpare(NULL), iSpare2(NULL)
+	{
+	}
+
+inline TUint32 LtkUtils::HashFn(TDesC* const& aKey)
+	{
+	return DefaultHash::Des16(*aKey);
+	}
+
+inline TBool LtkUtils::IdFn(TDesC* const& aFirst, TDesC* const& aSecond)
+	{
+	return DefaultIdentity::Des16(*aFirst, *aSecond);
+	}
+
+template <typename T>
+inline T* LtkUtils::RStringHash<T>::Find(const TDesC& aKey)
+	{
+	SHashVal<T>* res = DoFind(aKey);
+	if (res) return &res->iValue;
+	else return NULL;
+	}
+
+
+template <typename T>
+inline T LtkUtils::RStringHash<T>::FindPtr(const TDesC& aKey)
+	{
+	T* res = Find(aKey);
+	if (res) return *res;
+	else return NULL;
+	}
+
+
+template <typename T>
+inline T const* LtkUtils::RStringHash<T>::Find(const TDesC& aKey) const
+	{
+	SHashVal<T> const* res = DoFind(aKey);
+	if (res) return &res->iValue;
+	else return NULL;
+	}
+
+template <typename T>
+inline T const LtkUtils::RStringHash<T>::FindPtr(const TDesC& aKey) const
+	{
+	T const* res = Find(aKey);
+	if (res) return *res;
+	else return NULL;
+	}
+
+template <typename T>
+inline T& LtkUtils::RStringHash<T>::FindL(const TDesC& aKey)
+	{
+	T* res = Find(aKey);
+	if (!res) User::Leave(KErrNotFound);
+	return *res;
+	}
+
+template <typename T>
+inline T const& LtkUtils::RStringHash<T>::FindL(const TDesC& aKey) const
+	{
+	T const* res = Find(aKey);
+	if (!res) User::Leave(KErrNotFound);
+	return *res;
+	}
+
+template <typename T>
+TInt LtkUtils::RStringHash<T>::Insert(const TDesC& aKey, const T& aValue)
+	{
+	SHashVal<T>* valPtr = DoFind(aKey);
+	if (valPtr)
+		{
+		// Just update the value, no need to realloc anything
+		memcpy(&valPtr->iValue, &aValue, sizeof(T));
+		return KErrNone;
+		}
+
+	HBufC* buf = aKey.Alloc();
+	if (!buf) return KErrNoMemory;
+	// Avoid declaring an SHashVal<T> as that requires T to have a default constructor
+	TUint8 valBuf[sizeof(SHashVal<T>)];
+	SHashVal<T>& val = *reinterpret_cast<SHashVal<T>*>(valBuf);
+	val.iKey = buf;
+	memcpy(&val.iValue, &aValue, sizeof(T));
+	TInt err = iHash.Insert(buf, val);
+	if (err)
+		{
+		delete buf;
+		}
+	return err;
+	}
+
+template <typename T>
+inline TInt LtkUtils::RStringHash<T>::Remove(const TDesC& aKey)
+	{
+	SHashVal<T>* valPtr = DoFind(aKey);
+	if (valPtr)
+		{
+		HBufC* key = valPtr->iKey;
+		iHash.Remove(key);
+		delete key;
+		return KErrNone;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+
+template <typename T>
+inline void LtkUtils::RStringHash<T>::Close()
+	{
+	THashMapIter<TDesC*, SHashVal<T> > iter(iHash);
+	while (iter.NextValue() != NULL)
+		{
+		SHashVal<T>* current = const_cast<SHashVal<T>*>(iter.CurrentValue()); // const_cast not needed except on 9.1
+		HBufC* key = current->iKey;
+		iter.RemoveCurrent();
+		delete key;
+		}
+	iHash.Close();
+	}
+
+template <typename T>
+inline void LtkUtils::RStringHash<T>::InsertL(const TDesC& aKey, const T& aValue)
+	{
+	User::LeaveIfError(Insert(aKey, aValue));
+	}
+
+template <typename T>
+inline TInt LtkUtils::RStringHash<T>::Count() const
+	{
+	return iHash.Count();
+	}
+
+template <typename T>
+inline TInt LtkUtils::RStringHash<T>::Reserve(TInt aCount)
+	{
+	return iHash.Reserve(aCount);
+	}
+
+template <typename T>
+inline void LtkUtils::RStringHash<T>::ReserveL(TInt aCount)
+	{
+	User::LeaveIfError(Reserve(aCount));
+	}
+
+template <typename T>
+inline LtkUtils::SHashVal<T>* LtkUtils::RStringHash<T>::DoFind(const TDesC& aKey)
+	{
+	return iHash.Find(const_cast<TDesC*>(&aKey));
+	}
+
+template <typename T>
+inline LtkUtils::SHashVal<T> const* LtkUtils::RStringHash<T>::DoFind(const TDesC& aKey) const
+	{
+	return iHash.Find(const_cast<TDesC*>(&aKey));
+	}
+
+/// Iterator support
+
+template <typename T>
+inline const TDesC* LtkUtils::TStringHashIter<T>::CurrentKey() const
+	{
+	return *const_cast<TDesC**>(iIter.CurrentKey());
+	}
+
+template <typename T>
+inline const TDesC* LtkUtils::TStringHashIter<T>::NextKey()
+	{
+	return *const_cast<TDesC**>(iIter.NextKey());
+	}
+
+template <typename T>
+inline T* LtkUtils::TStringHashIter<T>::CurrentValue()
+	{
+	SHashVal<T>* val = const_cast<SHashVal<T>*>(iIter.CurrentValue()); // The const_cast isn't needed, except on 9.1
+	if (val) return &val->iValue;
+	return NULL;
+	}
+
+template <typename T>
+inline const T* LtkUtils::TStringHashIter<T>::NextValue()
+	{
+	const SHashVal<T>* val = iIter.NextValue();
+	if (val) return &val->iValue;
+	return NULL;
+	}
+
+template <typename T>
+inline void LtkUtils::TStringHashIter<T>::RemoveCurrent()
+	{
+	SHashVal<T>* val = iIter.CurrentValue();
+	if (val)
+		{
+		HBufC* key = val->iKey;
+		iIter.RemoveCurrent();
+		delete key;
+		}
+	}
+
+template <typename T>
+inline LtkUtils::TStringHashIter<T>::TStringHashIter(const RStringHash<T>& aHash)
+	: iIter(aHash.iHash)
+	{}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/breakpoint.cia	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+// breakpoint.cia
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <u32std.h>
+
+namespace LtkUtils
+	{
+	IMPORT_C void Breakpoint();
+	}
+
+EXPORT_C __NAKED__ void LtkUtils::Breakpoint()
+	{
+	asm(".word 0xE7F123F4 ");
+	__JUMP(,lr);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/breakpoint.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,47 @@
+// breakpoint.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ltkutils.h>
+
+#ifdef __WINS__
+
+EXPORT_C void LtkUtils::Breakpoint()
+	{
+	__BREAKPOINT()
+	}
+
+#elif defined(__GCCE__) || defined(__GCC32__)
+
+// This only gets compiled for GCC-based platforms, hence why it uses __attribute__ and not just __NAKED__
+#include <u32std.h>
+
+EXPORT_C __attribute__((__naked__)) void LtkUtils::Breakpoint()
+	{
+	asm(".word 0xE7F123F4 ");
+	__JUMP(,lr);
+	}
+
+#endif
+
+EXPORT_C TLinAddr LtkUtils::BreakpointAddr()
+	{
+	return (TLinAddr)&Breakpoint;
+	}
+
+void BreakpointCleanupItem(TAny*)
+	{
+	LtkUtils::Breakpoint();
+	}
+
+EXPORT_C void LtkUtils::BreakpointPushL()
+	{
+	CleanupStack::PushL(TCleanupItem(&BreakpointCleanupItem, NULL));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/bsym.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,590 @@
+// bsym.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/descriptorutils.h>
+#include <fshell/bsym.h>
+
+#include <fshell/iocli.h>
+using LtkUtils::CBsymFile;
+using namespace IoUtils;
+#include "bsymtree.h"
+using LtkUtils::RNode;
+
+#ifdef ASSERT
+#undef ASSERT
+#endif
+
+_LIT(KBsymPanic, "BSym");
+#define ASSERT(x) __ASSERT_ALWAYS(x, User::Panic(KBsymPanic, __LINE__))
+#define DEBUG_XY(x, y) RDebug::Printf(#x " = %d " #y " = %d", (int)(x), (int)(y))
+#define ASSERT_GE(x, y) if (!((x) >= (y))) { DEBUG_XY(x, y); ASSERT(x >= y); }
+#define ASSERT_GT(x, y) if (!((x) >  (y))) { DEBUG_XY(x, y); ASSERT(x >  y); }
+#define ASSERT_LE(x, y) if (!((x) <= (y))) { DEBUG_XY(x, y); ASSERT(x <= y); }
+#define ASSERT_LT(x, y) if (!((x) <  (y))) { DEBUG_XY(x, y); ASSERT(x <  y); }
+#define ASSERT_EQ(x, y) if (!((x) == (y))) { DEBUG_XY(x, y); ASSERT(x == y); }
+#define ASSERT_NE(x, y) if (!((x) != (y))) { DEBUG_XY(x, y); ASSERT(x != y); }
+
+#define LOG(args...)
+//#include <fshell/clogger.h>
+//#define LOG(args...) RClogger::Slog(args)
+
+enum TBsymVersion
+	{
+	EVersion1_0 = 0x00010000,
+	EVersion2_0 = 0x00020000,
+	EVersion2_1 = 0x00020001,
+	};
+static const TUint32 KMajorVersion = 0xFFFF0000;
+static const TUint32 KMinorVersion = 0x0000FFFF;
+static const TUint32 KMagic = ('B'<<24)|('S'<<16)|('Y'<<8)|'M';
+
+inline TUint32 fromBigEndian(TUint32 aVal)
+	{
+	TUint8* ptr = (TUint8*)&aVal;
+	return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
+	}
+
+inline TUint32 toBigEndian(TUint32 aVal)
+	{
+	return fromBigEndian(aVal); // Same thing really
+	}
+
+class TSymbol
+	{
+public:
+	TUint32 Address() const { return fromBigEndian(iData[0]); }
+	TUint32 Length() const { return fromBigEndian(iData[1]) & 0xFFFF; }
+	TUint32 NameOffset() const { return fromBigEndian(iData[2]); }
+	TUint32 NamePrefixIndex() const { return fromBigEndian(iData[1]) >> 16; }
+	
+	TSymbol(TUint32 aAddress) { iData[0] = toBigEndian(aAddress); }
+
+protected:
+	TUint32 iData[3];
+	};
+
+class TCodeSeg : public TSymbol
+	{
+public:
+	TUint32 SymbolStart() const { return fromBigEndian(iSymbolsStartIndex); }
+	TUint32 SymbolCount() const { return fromBigEndian(iData[1]); } // Code segs use the TSymbol 'length' field to store the number of symbols, *not* the length. To get the length of a codeseg, call CBsymFile::CodeSegLen(const TCodeSeg&)
+	TUint32 PrefixTableOffset() const { return fromBigEndian(iPrefixTableOffset); }
+	
+	TCodeSeg(TUint32 aAddress) : TSymbol(aAddress) {}
+private:
+	TUint32 iSymbolsStartIndex;
+	TUint32 iPrefixTableOffset;
+	};
+
+class TCodeAndSym
+	{
+public:
+	TCodeAndSym(const TCodeSeg* aCodeSeg, const TSymbol* aSymbol);
+	TCodeSeg iCodeSeg;
+	TSymbol iSymbol;
+	};
+
+NONSHARABLE_CLASS(CBsymFileImpl) : public CBsymFile
+	{
+public:
+	CBsymFileImpl();
+	~CBsymFileImpl();
+	void ConstructL(RFs& aFs, const TDesC& aFileName);
+	TPtrC DoLookupL(TUint32 aRomAddress);
+	TCodeAndSym DoLookup(TUint32 aAddress) const; // Only useful for ROM symbols files
+	void LoadSymbolNameL(const TSymbol* aSymbol, const TCodeSeg* aParentCodeSeg);
+	RNode* DoCreateCompletionTreeL(const TDesC& aCodesegName);
+	TPtrC DoLookupL(const TDesC& aCodesegName, TInt aOffset);
+
+private:
+	TUint32 UintL(TInt aOffset) const;
+	TUint32 UnalignedUintL(TInt aOffset) const;
+	TCodeSeg CodeSegL(TInt aIndex) const;
+	TSymbol SymbolL(TInt aIndex) const;
+
+	TUint32 CodesegSectionLengthL() const;
+	TUint32 SymbolsSectionLengthL() const;
+	TInt SymbolCountL() const;
+	TInt CodeSegCountL() const;
+	TInt TokenCountL() const;
+
+	void CreateCodesegHashIfNeededL();
+	TCodeAndSym DoCodesegLookup(const TCodeSeg& aCodeSeg, TUint32 aAddress) const;
+	HBufC* GetTokenL(TInt aToken) const;
+	HBufC* GetStringL(TUint32 aLocation, TBool aExpandTokens=ETrue) const;
+	TUint32 CodeSegLengthL(const TCodeSeg* aCodeSeg) const;
+
+	friend class TCodeSegKey;
+	friend class TSymbolKey;
+
+private:
+	LtkUtils::RLtkBuf iTempString;
+	LtkUtils::RStringHash<TCodeSeg> iCodeSegHash;
+	TInt iFileCacheOffset;
+	LtkUtils::RLtkBuf8 iFileCache;
+	};
+
+NONSHARABLE_CLASS(TCodeSegKey) : public TKey
+	{
+public:
+	TCodeSegKey(const CBsymFileImpl* aFile, TUint32 aAddress);
+	TInt Compare(TInt aLeft, TInt aRight) const;
+
+private:
+	const CBsymFileImpl* iFile;
+	TUint32 iAddress;
+	};
+
+NONSHARABLE_CLASS(TSymbolKey) : public TKey
+	{
+public:
+	TSymbolKey(const CBsymFileImpl* aFile, const TCodeSeg& aCodeSeg, TUint32 aAddress);
+	TInt Compare(TInt aLeft, TInt aRight) const;
+
+private:
+	const CBsymFileImpl* iFile;
+	const TCodeSeg& iCodeSeg;
+	TUint32 iAddress;
+	};
+
+EXPORT_C CBsymFile* CBsymFile::NewL(RFs& aFs, const TDesC& aFileName)
+	{
+	CBsymFileImpl* result = new (ELeave) CBsymFileImpl;
+	CleanupStack::PushL(result);
+	result->ConstructL(aFs, aFileName);
+	CleanupStack::Pop(result);
+	return result;
+	}
+
+EXPORT_C CBsymFile::~CBsymFile()
+	{
+	iFile.Close();
+	}
+
+EXPORT_C TPtrC CBsymFile::LookupL(TUint32 aAddress)
+	{
+	CBsymFileImpl* impl = static_cast<CBsymFileImpl*>(this); // We know we're actually a CBsymFileImpl
+	return impl->DoLookupL(aAddress);
+	}
+
+TPtrC CBsymFileImpl::DoLookupL(TUint32 aAddress)
+	{
+	iTempString.Zero();
+	TCodeAndSym res = DoLookup(aAddress);
+	if (res.iSymbol.Address())
+		{
+		LoadSymbolNameL(&res.iSymbol, &res.iCodeSeg);
+		iTempString.AppendFormatL(_L(" + 0x%x"), aAddress - res.iSymbol.Address());
+		}
+	return TPtrC(iTempString);
+	}
+
+CBsymFile::CBsymFile()
+	{
+	}
+
+CBsymFileImpl::CBsymFileImpl()
+	{
+	}
+
+CBsymFileImpl::~CBsymFileImpl()
+	{
+	iTempString.Close();
+	iCodeSegHash.Close();
+	iFileCache.Close();
+	}
+
+TUint32 CBsymFileImpl::UintL(TInt aOffset) const
+	{
+	ASSERT((aOffset & 3) == 0);
+	return UnalignedUintL(aOffset);
+	}
+
+TUint32 CBsymFileImpl::UnalignedUintL(TInt aOffset) const
+	{	
+	ASSERT_LE((TUint)aOffset+4, iFileSize);
+	TBuf8<4> buf;
+	TInt err = iFile.Read(aOffset, buf);
+	User::LeaveIfError(err);
+	return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]);
+	}
+
+#undef LeaveIfErr
+#define LeaveIfErr(args...) StaticLeaveIfErr(args)
+
+void CBsymFileImpl::ConstructL(RFs& aFs, const TDesC& aFileName)
+	{
+	iTempString.CreateL(256);
+	LeaveIfErr(iFile.Open(aFs, aFileName, EFileShareReadersOnly), _L("Couldn't open file %S"), &aFileName);
+	LeaveIfErr(iFile.Size(*reinterpret_cast<TInt*>(&iFileSize)), _L("Couldn't read file size"));
+	if (iFileSize < 5*4)
+		{
+		LeaveIfErr(KErrCorrupt, _L("%S is too small to be a bsym file"), &aFileName);
+		}
+	// Validate the data
+	if (UintL(0) != KMagic)
+		{
+		LeaveIfErr(KErrCorrupt, _L("%S is not a BSYM file."), &aFileName);
+		}
+	iVersion = UintL(4);
+	iCodesegOffset = UintL(8);
+	iSymbolsOffset = UintL(0x0C);
+	
+	TUint32 majorVersion = (iVersion&KMajorVersion);
+	if (majorVersion != EVersion1_0 && majorVersion != EVersion2_0)
+		{
+		LeaveIfErr(KErrNotSupported, _L("Unsupported bysm version v%d.%d in %S"), iVersion>>16, iVersion & KMinorVersion, &aFileName);
+		}
+	if (iVersion >= EVersion2_0)
+		{
+		iTokensOffset = UintL(0x10);
+		if (iTokensOffset + 4 > iFileSize || TokenCountL() > 128 || iTokensOffset + 4 + TokenCountL()*4 > iFileSize)
+			{
+			LeaveIfErr(KErrCorrupt, _L("Bad token offset %x or count"), iTokensOffset);
+			}
+		}
+	if (iVersion >= EVersion2_1)
+		{
+		TUint32 renamesOffset = UintL(0x14);
+		if (renamesOffset + 4 > iFileSize || renamesOffset + UintL(renamesOffset)*8 > iFileSize)
+			{
+			// UintL(renamesOffset)*8 is size of renames section
+			LeaveIfErr(KErrCorrupt, _L("Bad rename offset %x or count"), renamesOffset);
+			}
+		}
+	if (iCodesegOffset+4 > iFileSize || iCodesegOffset + CodesegSectionLengthL() > iFileSize)
+		{
+		LeaveIfErr(KErrCorrupt, _L("Bad codeseg offset %x or count"), iCodesegOffset);
+		}
+	if (iSymbolsOffset+4 > iFileSize || iSymbolsOffset + SymbolsSectionLengthL() > iFileSize)
+		{
+		LeaveIfErr(KErrCorrupt, _L("Bad symbols offset %x or count"), iSymbolsOffset);
+		}
+
+	// Don't construct the codeseg hash now, it takes too long and we only need it if we need to do completions
+	}
+
+TCodeSeg CBsymFileImpl::CodeSegL(TInt aIndex) const
+	{
+	TCodeSeg result(0);
+	const TInt fileIdx = iCodesegOffset + 4 + aIndex * sizeof(TCodeSeg);
+	if (fileIdx >= iFileCacheOffset && fileIdx + sizeof(TCodeSeg) <= iFileCacheOffset + iFileCache.Length())
+		{
+		Mem::Copy(&result, iFileCache.Ptr() + fileIdx - iFileCacheOffset, sizeof(TCodeSeg));
+		}
+	else
+		{
+		TPckg<TCodeSeg> pkg(result);
+		User::LeaveIfError(iFile.Read(fileIdx, pkg));
+		}
+	return result;
+	}
+	
+TSymbol CBsymFileImpl::SymbolL(TInt aIndex) const
+	{
+	TSymbol result(0);
+	const TInt fileIdx = iSymbolsOffset + 4 + aIndex * sizeof(TSymbol);
+	TPckg<TSymbol> pkg(result);
+	User::LeaveIfError(iFile.Read(fileIdx, pkg));
+	return result;
+	}
+	
+TUint32 CBsymFileImpl::CodesegSectionLengthL() const
+	{
+	return 4 + CodeSegCountL() * sizeof(TCodeSeg);
+	}
+
+TUint32 CBsymFileImpl::SymbolsSectionLengthL() const
+	{
+	return 4 + SymbolCountL() * sizeof(TSymbol);
+	}
+
+TInt CBsymFileImpl::SymbolCountL() const
+	{
+	return UintL(iSymbolsOffset);
+	}
+
+TInt CBsymFileImpl::CodeSegCountL() const
+	{
+	return UintL(iCodesegOffset);
+	}
+
+TUint32 CBsymFileImpl::CodeSegLengthL(const TCodeSeg* aCodeSeg) const
+	{
+	if (aCodeSeg->SymbolCount())
+		{
+		TSymbol lastSymbol = SymbolL(aCodeSeg->SymbolStart() + aCodeSeg->SymbolCount()-1);
+		return lastSymbol.Address() + lastSymbol.Length() - aCodeSeg->Address();
+		}
+	else
+		{
+		return 0;
+		}
+	}
+
+TCodeSegKey::TCodeSegKey(const CBsymFileImpl* aFile, TUint32 aAddress)
+	: TKey(), iFile(aFile), iAddress(aAddress)
+	{}
+
+TInt TCodeSegKey::Compare(TInt aLeft, TInt aRight) const
+	{
+	TUint32 left = aLeft == KIndexPtr ? iAddress : iFile->CodeSegL(aLeft).Address();
+	TUint32 right = aRight == KIndexPtr ? iAddress : iFile->CodeSegL(aRight).Address();
+	return (TInt)left - (TInt)right;
+	}
+
+
+TSymbolKey::TSymbolKey(const CBsymFileImpl* aFile, const TCodeSeg& aCodeSeg, TUint32 aAddress)
+	: TKey(), iFile(aFile), iCodeSeg(aCodeSeg), iAddress(aAddress)
+	{}
+
+TInt TSymbolKey::Compare(TInt aLeft, TInt aRight) const
+	{
+	TUint32 left = aLeft == KIndexPtr ? iAddress : iFile->SymbolL(iCodeSeg.SymbolStart() + aLeft).Address();
+	TUint32 right = aRight == KIndexPtr ? iAddress : iFile->SymbolL(iCodeSeg.SymbolStart() + aRight).Address();
+	return (TInt)left - (TInt)right;
+	}
+
+TCodeAndSym::TCodeAndSym(const TCodeSeg* aCodeSeg, const TSymbol* aSymbol)
+	: iCodeSeg(0), iSymbol(0)
+	{
+	if (aCodeSeg) iCodeSeg = *aCodeSeg;
+	if (aSymbol) iSymbol = *aSymbol;
+	}
+
+TCodeAndSym CBsymFileImpl::DoLookup(TUint32 aAddress) const
+	{
+	// Find codeseg (need to know this if the symbol has a name prefix)
+	TInt pos = 0;
+	TCodeSegKey codesegKey(this, aAddress);
+	TBool found = !User::BinarySearch(CodeSegCountL(), codesegKey, pos);
+	if (!found && pos != 0) pos--;
+	TCodeSeg codeseg = CodeSegL(pos);
+
+	if (aAddress >= codeseg.Address() && aAddress < codeseg.Address() + CodeSegLengthL(&codeseg))
+		{
+		return DoCodesegLookup(codeseg, aAddress);
+		}
+	return TCodeAndSym(NULL, NULL);
+	}
+
+EXPORT_C TPtrC CBsymFile::LookupL(const TDesC& aCodesegName, TInt aOffset)
+	{
+	return static_cast<CBsymFileImpl*>(this)->DoLookupL(aCodesegName, aOffset);
+	}
+
+TPtrC CBsymFileImpl::DoLookupL(const TDesC& aCodesegName, TInt aOffset)
+	{
+	CreateCodesegHashIfNeededL();
+	const TCodeSeg* codeseg = iCodeSegHash.Find(aCodesegName);
+	if (!codeseg) return TPtrC();
+	TUint32 addr = codeseg->Address() + aOffset;
+	TCodeAndSym res = DoCodesegLookup(*codeseg, addr);
+	iTempString.Zero();
+	if (res.iSymbol.Address())
+		{
+		LoadSymbolNameL(&res.iSymbol, &res.iCodeSeg);
+		iTempString.AppendFormatL(_L(" + 0x%x"), addr - res.iSymbol.Address());
+		}
+	return TPtrC(iTempString);
+	}
+
+TCodeAndSym CBsymFileImpl::DoCodesegLookup(const TCodeSeg& aCodeSeg, TUint32 aAddress) const
+	{
+	TInt pos = 0;
+	TSymbolKey symbolKey(this, aCodeSeg, aAddress);
+	TBool found = !User::BinarySearch(aCodeSeg.SymbolCount(), symbolKey, pos);
+	if (!found && pos != 0) pos--;
+	TSymbol symbol = SymbolL(aCodeSeg.SymbolStart() + pos);
+
+	if (aAddress >= symbol.Address() && aAddress < symbol.Address() + symbol.Length())
+		return TCodeAndSym(&aCodeSeg, &symbol);
+	// TODO: Handle cases where the address falls outside of any symbol but still within the code segment, ie when symbols in the symbol file are not contiguous. This does happen, maybe because of padding/alignment.
+	//qFatal("DoCodesegLookup with aAddress not within any symbol in aCodeSeg");
+	return TCodeAndSym(NULL, NULL);
+	}
+
+HBufC* CBsymFileImpl::GetStringL(TUint32 aLocation, TBool aExpandTokens) const
+	{
+	TPckgBuf<TUint8> len8;
+	User::LeaveIfError(iFile.Read(aLocation, len8));
+
+	TUint16 nameLen = (TUint16)len8();
+	aLocation++;
+	if (nameLen == 255)
+		{
+		TPckgBuf<TUint16> len16;
+		User::LeaveIfError(iFile.Read(aLocation, len16));
+		nameLen = len16() >> 8 | len16() << 8;
+		aLocation += 2;
+		}
+	RBuf8 temp;
+	CleanupClosePushL(temp);
+	temp.CreateL(nameLen);
+	User::LeaveIfError(iFile.Read(aLocation, temp));
+	LtkUtils::RLtkBuf res;
+	res.CreateL(nameLen);
+	res.Copy(temp);
+	CleanupStack::PopAndDestroy(&temp);
+	CleanupClosePushL(res);
+	if (aExpandTokens && iVersion >= EVersion2_0)
+		{
+		for (TInt i = res.Length() - 1; i >= 0; i--)
+			{
+			TUint16 val = res[i];
+			if (val >= 128)
+				{
+				HBufC* token = GetTokenL(val-128);
+				CleanupStack::PushL(token);
+				res.ReplaceL(i, 1, *token);
+				CleanupStack::PopAndDestroy(token);
+				}
+			}
+
+		}
+	CleanupStack::Pop(&res);
+	return res.ToHBuf();
+	}
+
+void CBsymFileImpl::LoadSymbolNameL(const TSymbol* aSymbol, const TCodeSeg* aParentCodeSeg)
+	{
+	TUint32 prefixIdx = aSymbol->NamePrefixIndex();
+	if (aParentCodeSeg && prefixIdx)
+		{
+		// Then the symbol name has a prefix that needs looking up separately in the codeseg 
+		TUint32 prefixLocation = aParentCodeSeg->PrefixTableOffset() + ((prefixIdx-1) * sizeof(TUint32));
+		// This location has the offset of the relevant string
+		HBufC* prefix = GetStringL(UnalignedUintL(prefixLocation));
+		CleanupStack::PushL(prefix);
+		iTempString.AppendL(*prefix);
+		CleanupStack::PopAndDestroy(prefix);
+		iTempString.AppendL(_L("::"));
+		}
+
+	TUint32 nameOffset = aSymbol->NameOffset();
+	HBufC* result = GetStringL(nameOffset);
+	CleanupStack::PushL(result);
+	iTempString.AppendL(*result);
+	CleanupStack::PopAndDestroy(result);
+	}
+
+TInt CBsymFileImpl::TokenCountL() const
+	{
+	if (iTokensOffset != 0)
+		{
+		return UintL(iTokensOffset);
+		}
+	else
+		{
+		return 0;
+		}
+	}
+
+HBufC* CBsymFileImpl::GetTokenL(TInt aToken) const
+	{
+	if (aToken >= TokenCountL())
+		{
+		LeaveIfErr(KErrCorrupt, _L("Request for token %d >= tokenCount %d"), aToken, TokenCountL());
+		}
+	TUint32 tokenOffset = UintL(iTokensOffset + 4 + 4*aToken);
+	return GetStringL(tokenOffset, EFalse);
+	}
+
+RNode* CBsymFile::CreateCompletionTreeL(const TDesC& aCodesegName)
+	{
+	return static_cast<CBsymFileImpl*>(this)->DoCreateCompletionTreeL(aCodesegName);
+	}
+
+RNode* CBsymFileImpl::DoCreateCompletionTreeL(const TDesC& aCodesegName)
+	{
+	CreateCodesegHashIfNeededL();
+	TCodeSeg* codeseg = iCodeSegHash.Find(aCodesegName);
+	if (!codeseg)
+		{
+		LOG(_L("Couldn't find %S in bsym's codeseg hash"), &aCodesegName);
+		return NULL;
+		}
+	RNode* result = RNode::NewL();
+	CleanupDeletePushL(result);
+
+	const TInt symbolcount = codeseg->SymbolCount();
+	const TUint32 symbolstart = codeseg->SymbolStart();
+	LOG("Constructing RNode with %d symbols", symbolcount);
+	for (TInt i = 0; i < symbolcount; i++)
+		{
+		TSymbol symbol = SymbolL(symbolstart + i);
+		iTempString.Zero();
+		LoadSymbolNameL(&symbol, codeseg);
+		iTempString.ReserveExtraL(1);
+		LOG(_L("Adding symbol %S @ 0x%08x"), &iTempString, symbol.Address() - codeseg->Address());
+		result->InsertStringL(iTempString.PtrZ(), symbol.Address() - codeseg->Address());
+		}
+	CleanupStack::Pop(result);
+	return result;
+	}
+
+void CBsymFileImpl::CreateCodesegHashIfNeededL()
+	{
+	if (iCodeSegHash.Count() > 0) return; // Already populated
+
+	const TInt count = CodeSegCountL();
+	iCodeSegHash.ReserveL(count);
+	// Cut down the number of IPC calls by preloading the whole codeseg area in one (since we know we'll need it all)
+	iFileCache.CreateL(4 + count * sizeof(TCodeSeg));
+	iFileCacheOffset = iCodesegOffset;
+	User::LeaveIfError(iFile.Read(iFileCacheOffset, iFileCache));
+	for (TInt i = 0; i < count; i++)
+		{
+		TCodeSeg codeseg = CodeSegL(i);
+		iTempString.Zero();
+		LoadSymbolNameL(&codeseg, NULL);
+		iTempString.Delete(0, iTempString.Length() - TParsePtrC(iTempString).NameAndExt().Length());
+
+		LOG(_L("Adding %S to codeseg hash"), &iTempString);
+		iCodeSegHash.InsertL(iTempString, codeseg);
+		if (iVersion < EVersion2_1)
+			{
+			// Fall back to some hacky guesses about possible renamed binaries
+			_LIT(KEuser, "euser_");
+			if (iTempString.Length() && iTempString[0] == '_')
+				{
+				TInt lastUnderscore = iTempString.LocateReverse('_');
+				if (lastUnderscore > 0)
+					{
+					iTempString.Delete(0, lastUnderscore + 1);
+					if (iTempString.Length()) iCodeSegHash.InsertL(iTempString, codeseg);
+					}
+				}
+			else if (iTempString.Left(KEuser().Length()) == KEuser)
+				{
+				// EUser appears to be a special case that some platforms do differently, as euser_variant.dll
+				iCodeSegHash.InsertL(_L("euser.dll"), codeseg);
+				}
+			}
+		}
+
+	if (iVersion >= EVersion2_1)
+		{
+		TUint32 renamesOffset = UintL(0x14);
+		const TInt renamesCount = UintL(renamesOffset);
+		for (TInt i = 0; i < renamesCount; i++)
+			{
+			TUint32 offset = renamesOffset + i*8;
+			TInt codesegIdx = UintL(offset);
+			TUint32 stringOffset = UintL(offset+4);
+			TCodeSeg codeseg = CodeSegL(codesegIdx);
+			GetStringL(stringOffset);
+			iCodeSegHash.InsertL(iTempString, codeseg);
+			}
+		}
+
+	iFileCache.Close();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/bsymtree.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,253 @@
+// bsymtree.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "bsymtree.h"
+#include <badesca.h>
+#include <fshell/descriptorutils.h>
+//#include <e32debug.h>
+
+using namespace LtkUtils;
+
+RNode* RNode::NewL()
+	{
+	RNode* top = new(ELeave) RNode(0);
+	CleanupDeletePushL(top);
+	top->iPtr = new(ELeave) RArray<RNode*>(8);
+	top->iHasChildArray = 1;
+	CleanupStack::Pop(top);
+	return top;
+	}
+
+RNode::RNode(char aLetter)
+	: iLetter(aLetter), iHasChildArray(0), iPad(0), iPtr(NULL)
+	{
+	}
+
+RNode* RNode::Sprog() const
+	{
+	ASSERT(!iHasChildArray);
+	ASSERT(iLetter != 0);
+	return reinterpret_cast<RNode*>(iPtr);
+	}
+
+RArray<RNode*>& RNode::Sprogs() const
+	{
+	ASSERT(iHasChildArray);
+	return *reinterpret_cast<RArray<RNode*>*>(iPtr);
+	}
+
+RNode* RNode::ChildForLetter(char aChild) const
+	{
+	if (iHasChildArray)
+		{
+		const TInt count = Sprogs().Count();
+		for (TInt i = 0; i < count; i++)
+			{
+			RNode* node = Sprogs()[i];
+			if (node->iLetter == aChild) return node;
+			}
+		}
+	else if (iLetter != 0) // null terminators use next for the value
+		{
+		RNode* child = Sprog();
+		if (child && child->iLetter == aChild) return child;
+		}
+	return NULL;
+	}
+
+RNode* RNode::AddChildL(char aChild)
+	{
+	RNode* node = new(ELeave) RNode(aChild);
+	CleanupStack::PushL(node);
+	if (!iHasChildArray)
+		{
+		if (iPtr == NULL)
+			{
+			// Easy
+			CleanupStack::Pop(node);
+			iPtr = node;
+			return node;
+			}
+		else
+			{
+			// Need to upgrade to a childArray
+			RArray<RNode*>* children = new(ELeave) RArray<RNode*>(8);
+			CleanupStack::PushL(children);
+			children->AppendL(reinterpret_cast<RNode*>(iPtr));
+			iPtr = children;
+			CleanupStack::Pop(children);
+			iHasChildArray = 1;
+			}
+		}
+	Sprogs().AppendL(node);
+	CleanupStack::Pop(node);
+	return node;
+	}
+
+void RNode::InsertStringL(const TUint16* aString, TInt aValue)
+	{
+	char letter = (char)*aString;
+	RNode* child = ChildForLetter(letter);
+	if (!child)
+		{
+		child = AddChildL(letter);
+		}
+		
+	if (letter == 0)
+		{
+		// If the letter was the null termination at the end, we're finished and just need to set the value
+		//ASSERT(child->iPtr == NULL); // There should never be a child of a null terminator (unless the same string has been inserted twice...)
+		// ^ Annoyingly there can be duplicate symbols that are only distinguished by information we've actually thrown away in the BSYM.
+		//   We will ignore such duplicate symbols. If this is a problem, someone feel free to fix it.
+		if (!child->iPtr)
+			{
+			child->iPtr = (TAny*)aValue;
+			}
+		}
+	else
+		{
+		aString++;
+		child->InsertStringL(aString, aValue);
+		}
+	}
+
+RNode* RNode::WalkToEndOfString(TUint16*& aString)
+	{
+	RNode* currentNode = this;
+	while (*aString)
+		{
+		RNode* child = currentNode->ChildForLetter((char)*aString);
+		if (!child) return currentNode;
+		currentNode = child;
+		aString++;
+		}
+	return currentNode;
+	}
+	
+RNode* RNode::TabFill(TUint16*& aString, const TUint16* aEnd)
+	{
+	// This function completes as far as the next choice point
+	// aString is a pointer into a buffer with plenty of space in it
+		
+	//Dump(); // DEBUG
+	if (!iHasChildArray && iLetter && iPtr && aString+1 < aEnd)
+		{
+		*aString = Sprog()->iLetter;
+		aString++;
+		*aString = 0;
+		return Sprog()->TabFill(aString, aEnd);
+		}
+	else
+		{
+		return this;
+		}
+	}
+
+void RNode::CompleteL(TDes& aPrefix, CDesC16Array& aResults)
+	{
+	TUint16* ptr = (TUint16*)aPrefix.PtrZ();
+	TUint16* end = ptr + aPrefix.MaxLength();
+	RNode* endNode = WalkToEndOfString(ptr);
+	if (ptr != aPrefix.Ptr() + aPrefix.Length()) return; // We failed to walk the whole of the string so we have nothing to suggest (the string is longer than anything in the tree)
+
+	endNode = endNode->TabFill(ptr, end);
+	TInt newLen = ptr - aPrefix.Ptr();
+	if (endNode->iLetter == 0 && newLen > 0) newLen--; // If ptr got as far as the null termination, we need to make our length one shorter
+	//RDebug::Printf("Setting aPrefix len to %d, len=%d maxlen=%d", newLen, aPrefix.Length(), aPrefix.MaxLength());
+	aPrefix.SetLength(newLen);
+
+	// Now that aPrefix has been completed with as much as didn't have any choices, fill aResults with the choices
+	RLtkBuf current;
+	current.CreateLC(256);
+	current.AppendL(aPrefix);
+	if (current.Length()) current.SetLength(current.Length()-1); // Remove endNode's char as DoCompleteOptionsL expects to do that bit
+	endNode->DoCompleteOptionsL(aResults, current);
+	// Make sure last string is included
+	aResults.AppendL(current);
+	CleanupStack::PopAndDestroy(&current);
+	aResults.Sort();
+	}
+	
+void RNode::DoCompleteOptionsL(CDesC16Array& aResults, RLtkBuf& aCurrent)
+	{
+	if (iLetter)
+		{
+		aCurrent.ReserveExtraL(1);
+		aCurrent.Append(TChar(iLetter));
+		}
+	TInt currentLen = aCurrent.Length();
+
+	if (iHasChildArray)
+		{
+		for (int i = 0; i < Sprogs().Count(); i++)
+			{
+			RNode* child = Sprogs()[i];
+			if (i > 0)
+				{
+				// A new prefix is in order
+				aResults.AppendL(aCurrent);
+				aCurrent.SetLength(currentLen);
+				}
+			child->DoCompleteOptionsL(aResults, aCurrent);
+			}
+		}
+	else if (iLetter != 0)
+		{
+		if (Sprog()) Sprog()->DoCompleteOptionsL(aResults, aCurrent);
+		}
+	}
+
+RNode::~RNode()
+	{
+	if (iHasChildArray)
+		{
+		RArray<RNode*>& children = Sprogs();
+		const TInt count = children.Count();
+		for (TInt i = 0; i < count; i++)
+			{
+			RNode* node = children[i];
+			delete node;
+			}
+		children.Close();
+		delete &children;
+		}
+	else if (iLetter != 0)
+		{
+		delete Sprog();
+		}
+	}
+
+/*
+#include <e32debug.h>
+void RNode::Dump() const
+	{
+	TInt sprogCount = Sprogs().Count();
+	for (int i = 0; i < sprogCount; i++)
+		{
+		RNode* child = Sprogs()[i];
+		RDebug::Printf("Sprog %i is letter %c", i, child->iLetter);
+		}
+	}
+*/
+
+TInt RNode::ValueForStringL(const TDesC& aString) const
+	{
+	const RNode* node = this;
+	for (TInt i = 0; i < aString.Length(); i++)
+		{
+		node = node->ChildForLetter(aString[i]);
+		if (!node) User::Leave(KErrNotFound);
+		}
+	node = node->ChildForLetter(0); // The null terminator node is the one with the value in
+	if (!node) User::Leave(KErrNotFound);
+	ASSERT(!node->iHasChildArray);
+	return reinterpret_cast<TInt>(node->iPtr);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/bsymtree.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,51 @@
+// bsymtree.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_BSYMTREE_H
+#define FSHELL_BSYMTREE_H
+
+#include <e32std.h>
+class CDesC16Array;
+
+namespace LtkUtils
+	{
+	class RLtkBuf16;
+
+	class RNode
+		{
+	public:
+		static RNode* NewL();
+		void InsertStringL(const TUint16* aString, TInt aValue=0);
+		~RNode();
+		void CompleteL(TDes& aPrefix, CDesC16Array& aResults);
+		TInt ValueForStringL(const TDesC& aString) const;
+
+	private:
+		RNode* ChildForLetter(char aChild) const;
+		RNode* AddChildL(char aChild);
+		RNode(char aLetter);
+		RNode* Sprog() const;
+		RArray<RNode*>& Sprogs() const;
+		RNode* WalkToEndOfString(TUint16*& aString);
+		RNode* TabFill(TUint16*& aString, const TUint16* aEnd);
+		void DoCompleteOptionsL(CDesC16Array& aResults, RLtkBuf16& aCurrent);
+		//void Dump() const; // Debug
+
+	private:
+		char iLetter;
+		char iHasChildArray;
+		short iPad;
+		TAny* iPtr; // Either an RNode* or an RArray<RNode*>*. Or a TInt for the value if (iLetter == 0 && !iHasChildArray)
+		};
+
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/clipboard.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,158 @@
+// clipboard.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ltkutils.h>
+#include <baclipb.h>
+#include <S32MEM.H>
+#include <S32UCMP.H>
+const TUid KClipboardUidTypePlainText = {268450333}; // from TXTETEXT.h
+
+// This could probably be optimised away, but I don't feel that confident
+NONSHARABLE_CLASS(TFieldMapExternalizer) : public MExternalizer<TStreamRef>
+	{
+public:
+	TFieldMapExternalizer(const CStoreMap& aMap);
+	void ExternalizeL(const TStreamRef& anObject,RWriteStream& aStream) const;
+private:
+	const CStoreMap* iMap;
+	};
+
+RFs OpenFsIfNeededLC(RFs* aFsPtr)
+	{
+	if (!aFsPtr)
+		{
+		RFs stackFs;
+		CleanupClosePushL(stackFs);
+		User::LeaveIfError(stackFs.Connect());
+		return stackFs;
+		}
+	else
+		{
+		CleanupStack::PushL((CBase*)NULL); // Just so the cleanup stack is the same depth in both cases - this is ok to destroy
+		return *aFsPtr;
+		}
+	}
+
+
+EXPORT_C void LtkUtils::CopyToClipboardL(const TDesC& aText, RFs* aFs)
+	{
+	/*
+	The simple way of implementing this is as follows. However this gives you a dependancy on etext.dll so is not desirable
+
+	CClipboard* cb = CClipboard::NewForWritingLC(FsL());
+	CPlainText* text = CPlainText::NewL();
+	CleanupStack::PushL(text);
+	text->InsertL(0, aText);
+	text->CopyToStoreL(cb->Store(), cb->StreamDictionary(), 0, text->DocumentLength());
+	cb->CommitL();
+	CleanupStack::PopAndDestroy(2, cb); // text, cb
+	*/
+
+	RFs fs = OpenFsIfNeededLC(aFs);
+	CClipboard* cb = CClipboard::NewForWritingLC(fs);
+	CStreamStore& store = cb->Store();
+	CStreamDictionary& dictionary = cb->StreamDictionary();
+	// Following adapted from CPlainText::DoCopyToStoreL
+	if (aText.Length())
+		{
+		CStoreMap* map=CStoreMap::NewLC(store);
+		//CopyComponentsL(aStore,*map,aPos,aLength);
+
+		// create custom externalizer over the map
+		TFieldMapExternalizer fMap(*map);
+		RStoreWriteStream stream(fMap);
+		TStreamId id=stream.CreateLC(store);
+		//CopyToStreamL(stream,aPos,aLength);
+		stream.WriteInt32L(aText.Length());
+		CBufFlat* textBuf = CBufFlat::NewL(256);
+		CleanupStack::PushL(textBuf);
+		textBuf->InsertL(0, TPtrC8((const TText8*)aText.Ptr(), aText.Size()));
+		RBufReadStream input_stream(*textBuf, 0);
+		TMemoryStreamUnicodeSource source(input_stream);
+		TUnicodeCompressor c;
+		c.CompressL(stream,source,KMaxTInt,aText.Length());
+		input_stream.Close();
+		stream.WriteUint8L(EFalse); // Indicating !fieldSetPresent
+		CleanupStack::PopAndDestroy(textBuf);
+		stream.CommitL();
+
+		dictionary.AssignL(KClipboardUidTypePlainText,id);
+		map->Reset();
+		CleanupStack::PopAndDestroy(2);
+		}
+	cb->CommitL();
+	CleanupStack::PopAndDestroy(cb);
+	CleanupStack::PopAndDestroy(); // stackfs
+	}
+
+EXPORT_C HBufC* LtkUtils::GetFromClipboardL(RFs* aFs)
+	{
+	/*
+	The simple way of implementing this is as follows. However this gives you a dependancy on etext.dll so is not desirable
+
+	CClipboard* cb = CClipboard::NewForReadingLC(FsL());
+	CPlainText* text = CPlainText::NewL();
+	CleanupStack::PushL(text);
+	text->PasteFromStoreL(cb->Store(), cb->StreamDictionary(), 0);
+	HBufC* res = HBufC::NewL(text->DocumentLength());
+	TPtr ptr(res->Des());
+	text->Extract(ptr, 0);
+	CleanupStack::PopAndDestroy(2, cb); // text, cb
+	return res;
+	*/
+
+	RFs fs = OpenFsIfNeededLC(aFs);
+	HBufC* result = NULL;
+	CClipboard* cb = CClipboard::NewForReadingLC(fs);
+	CStreamStore& store = cb->Store();
+	CStreamDictionary& dictionary = cb->StreamDictionary();
+
+	// Adapted from CPlainText::PasteFromStoreL, 
+	TStreamId id=dictionary.At(KClipboardUidTypePlainText);
+	if (id != KNullStreamId)
+		{
+		RStoreReadStream stream;
+		stream.OpenLC(store, id);
+		CBufSeg* buffer = CBufSeg::NewL(512);
+		CleanupStack::PushL(buffer);
+		TInt length = stream.ReadInt32L();
+		RBufWriteStream output_stream(*buffer);
+		TMemoryStreamUnicodeSink sink(output_stream);
+		TUnicodeExpander e;
+		e.ExpandL(sink,stream,length);
+		output_stream.CommitL();
+		output_stream.Close();
+
+		result = HBufC::NewMaxL(buffer->Size()/sizeof(TText));
+		TPtr8 ptr = TPtr8((TText8*)result->Ptr(), 0, buffer->Size());
+		buffer->Read(0, ptr);
+		
+		CleanupStack::PopAndDestroy(2, &stream); // buffer, stream
+		}
+
+	CleanupStack::PopAndDestroy(cb);
+	CleanupStack::PopAndDestroy(); // OpenFsIfNeededLC
+	if (!result) result = KNullDesC().AllocL();
+	return result;
+	}
+
+
+TFieldMapExternalizer::TFieldMapExternalizer(const CStoreMap& aMap)
+	: iMap(&aMap)
+	{}
+
+void TFieldMapExternalizer::ExternalizeL(const TStreamRef& aRef,RWriteStream& aStream) const
+// Write the stream id bound to aRef to aStream. If not bound, write KNullStreamId
+//
+	{
+	TSwizzleC<TAny> swizzle=aRef;
+	aStream<<iMap->At(swizzle);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/descriptorJuggling.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1018 @@
+// descriptorJuggling.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ltkutils.h>
+#include <fshell/descriptorutils.h>
+
+#include <u32std.h>
+const TUint16 KReplacementChar = 0xFFFD;
+const TUint16 KBom = 0xFEFF;
+_LIT8(KReplacementCharInUtf8, "\xEF\xBF\xBD");
+using namespace LtkUtils;
+
+// This class is used to track state between invocations of AppendUtf8L().
+namespace LtkUtils
+	{
+	class TUtf8State
+		{
+	public:
+		TUtf8State();
+
+	public:
+		TInt iFirstUnconvertedByte;
+		TInt iBytesConsumedSoFar;
+		TUint8 iUnconvertedBytesCount;
+		TUint8 iUnconvertedBytes[3]; // A UTF-8 sequence is a maximum of 4 bytes long so there can only be a max of 3 bytes unconverted
+		};
+	} // end namespace LtkUtils
+
+const TInt KStateCharCount = sizeof(LtkUtils::TUtf8State) / sizeof(TUint16);
+__ASSERT_COMPILE((sizeof(LtkUtils::TUtf8State) & 3) == 0);
+__ASSERT_COMPILE(KStateCharCount == 6); // Just checking I've done my maths right, it doesn't particularly have to be this size
+
+EXPORT_C TUint LtkUtils::HexLexL(TLex16& aLex)
+	{
+	TUint result;
+	User::LeaveIfError(HexLex(aLex, result));
+	return result;
+	}
+
+EXPORT_C TInt LtkUtils::HexLex(TLex16& aLex, TUint& aResult)
+	{
+	_LIT(KHexPrefix, "0x");
+	if (aLex.Remainder().Length() > 2)
+		{
+		TLexMark16 mark;
+		aLex.Mark(mark);
+		aLex.Inc(2);
+		TPtrC prefix(aLex.MarkedToken(mark));
+		if (prefix == KHexPrefix)
+			{
+			TInt err = aLex.Val(aResult, EHex);
+			if (err) aLex.UnGetToMark(mark); // Make sure we leave it at the original position if error
+			return err;
+			}
+		else
+			{
+			aLex.UnGetToMark(mark);
+			}
+		}
+	return aLex.Val(aResult, EDecimal);
+	}
+
+EXPORT_C TUint LtkUtils::HexLexL(TLex8& aLex)
+	{
+	TUint result;
+	User::LeaveIfError(HexLex(aLex, result));
+	return result;
+	}
+
+EXPORT_C TInt LtkUtils::HexLex(TLex8& aLex, TUint& aResult)
+	{
+	_LIT8(KHexPrefix, "0x");
+	if (aLex.Remainder().Length() > 2)
+		{
+		TLexMark8 mark;
+		aLex.Mark(mark);
+		aLex.Inc(2);
+		TPtrC8 prefix(aLex.MarkedToken(mark));
+		if (prefix == KHexPrefix)
+			{
+			TInt err = aLex.Val(aResult, EHex);
+			if (err) aLex.UnGetToMark(mark); // Make sure we leave it at the original position if error
+			return err;
+			}
+		else
+			{
+			aLex.UnGetToMark(mark);
+			}
+		}
+	return aLex.Val(aResult, EDecimal);
+	}
+
+EXPORT_C TInt LtkUtils::ReplaceText(TDes& aDescriptor, const TDesC& aFrom, const TDesC& aTo)
+	{
+	TInt numReplaced = 0;
+	TInt pos = 0;
+	const TInt lenDelta = -aFrom.Length() + aTo.Length();
+	while (ETrue)
+		{
+		TPtrC des(aDescriptor.Mid(pos));
+		TInt found = des.Find(aFrom);
+		if (found == KErrNotFound) break;
+		TInt idx = pos + found;
+		if (aDescriptor.Length() + lenDelta > aDescriptor.MaxLength()) return KErrOverflow;
+		aDescriptor.Replace(idx, aFrom.Length(), aTo);
+		pos = idx + aTo.Length();
+		numReplaced++;
+		}
+	return numReplaced;
+	}
+
+void EnsureCapacityL(HBufC*& aBuf, TInt aExtra)
+	{
+	if (aBuf->Length() + aExtra > aBuf->Des().MaxLength())
+		{
+		aBuf = aBuf->ReAllocL(aBuf->Length() + aExtra);
+		}
+	}
+
+EXPORT_C TBool LtkUtils::HasPrefix(const TDesC16& aDes, const TDesC16& aPrefix)
+	{
+	return aDes.Left(aPrefix.Length()) == aPrefix;
+	}
+
+EXPORT_C TBool LtkUtils::HasPrefix(const TDesC8& aDes, const TDesC8& aPrefix)
+	{
+	return aDes.Left(aPrefix.Length()) == aPrefix;
+	}
+
+#define KB *1024
+#define MB *1024*1024
+#define GB *1024*1024*1024
+
+EXPORT_C void LtkUtils::FormatSize(TDes16& aDes, TInt64 aSize)
+	{
+	_LIT(KBytes, " B");
+	_LIT(KKilobytes, " KB");
+	_LIT(KMegabytes, " MB");
+	_LIT(KGigabytes, " GB");
+
+	const TDesC* suff = &KBytes;
+	TReal n = aSize;
+	TInt factor = 1;
+
+	TInt64 absSize = aSize;
+	if (absSize < 0) absSize = -absSize;
+
+	if (absSize >= 1 GB)
+		{
+		suff = &KGigabytes;
+		factor = 1 GB;
+		}
+	else if (absSize >= 1 MB)
+		{
+		suff = &KMegabytes;
+		factor = 1 MB;
+		}
+	else if (absSize >= 1 KB)
+		{
+		suff = &KKilobytes;
+		factor = 1 KB;
+		}
+
+	n = n / (TReal)factor;
+	TBool wholeNumUnits = (absSize & (factor-1)) == 0; // ie aSize % factor == 0
+
+	TRealFormat fmt(aDes.MaxLength(), wholeNumUnits ? 0 : 2);
+	aDes.Num(n, fmt);
+	aDes.Append(*suff);
+	}
+
+
+EXPORT_C void LtkUtils::FormatSize(TDes8& aDes, TInt64 aSize)
+	{
+	TBuf<32> buf;
+	FormatSize(buf, aSize);
+	aDes.Copy(buf);
+	}
+
+
+
+// RLtkBuf follows
+
+inline TDesC16::TDesC16(TInt aType,TInt aLength)
+	:iLength(aLength|(aType<<KShiftDesType16))
+	{}
+
+inline TDes16::TDes16(TInt aType,TInt aLength,TInt aMaxLength)
+	: TDesC16(aType,aLength),iMaxLength(aMaxLength)
+	{}
+
+EXPORT_C LtkUtils::RLtkBuf16::RLtkBuf16()
+	: TDes16(EPtr,0,0), iBuf(NULL)
+	{
+	}
+
+EXPORT_C LtkUtils::RLtkBuf16::RLtkBuf16(HBufC16* aBuf)
+	{
+	if(aBuf)
+		{
+		//Create EBufCPtr type descriptor that points to aHBuf
+		// I'll take base_e32's word for it that this does the right thing...
+		new(this) TPtr16(aBuf->Des());
+		}
+	else
+		{
+		//Create zero-length RBuf16. It is EPtr type of descriptor that points to NULL.
+		new(this) RLtkBuf16();
+		}
+	}
+
+EXPORT_C HBufC16* LtkUtils::RLtkBuf16::ToHBuf()
+	{
+	// This transfers ownership
+	HBufC16* result = iBuf;
+	Assign(NULL);
+	return result;
+	}
+
+EXPORT_C HBufC16* LtkUtils::RLtkBuf16::GetHBuf() const
+	{
+	// This doesn't transfer ownership
+	return iBuf;
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf16::ReAlloc(TInt aMaxLength)
+	{
+	if (!aMaxLength) // Reallocation to zero length
+		{
+		Close();
+		return KErrNone;
+		}
+
+	if (!iBuf) // Reallocation from zero length
+		return Create(aMaxLength); 
+
+	// Need to maintain the UTF-8 state trickery
+	TUtf8State* oldState = GetUtf8State();
+	if (oldState)
+		{
+		TUtf8State state = *oldState;
+		HBufC16* newbuf = iBuf->ReAlloc(aMaxLength + KStateCharCount);
+		if (!newbuf) return KErrNoMemory;
+		Assign(newbuf); // This will set iMaxLength
+		iMaxLength = iMaxLength - KStateCharCount;
+		Mem::Copy((TAny*)(Ptr() + MaxLength()), &state, sizeof(TUtf8State));
+		}
+	else
+		{
+		HBufC16* newbuf = iBuf->ReAlloc(aMaxLength);
+		if (!newbuf) return KErrNoMemory;
+		Assign(newbuf);
+		}
+	return KErrNone;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::ReAllocL(TInt aMaxLength)
+	{
+	User::LeaveIfError(ReAlloc(aMaxLength));
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::Assign(HBufC16* aBuf)
+	{
+	new(this) RLtkBuf16(aBuf);
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf16::Create(TInt aMaxLength)
+	{
+	if (aMaxLength)
+		{
+		HBufC16* buf = HBufC16::New(aMaxLength);
+		if (!buf) return KErrNoMemory;
+		Assign(buf);
+		}
+	else
+		{
+		Assign(NULL);
+		}
+	return KErrNone;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::CreateL(TInt aMaxLength)
+	{
+	User::LeaveIfError(Create(aMaxLength));
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::CreateLC(TInt aMaxLength)
+	{
+	CleanupClosePushL(*this);
+	User::LeaveIfError(Create(aMaxLength));
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::Close()
+	{
+	delete iBuf;
+	Assign(NULL);
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::AppendL(const TDesC16& aText)
+	{
+	ReserveExtraL(aText.Length());
+	Append(aText);
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::AppendL(TChar aChar)
+	{
+	ReserveExtraL(1);
+	Append(aChar);
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::ReplaceAllL(const TDesC16& aFrom, const TDesC16& aTo)
+	{
+	//TInt numReplaced = 0;
+	TInt pos = 0;
+	const TInt lenDelta = -aFrom.Length() + aTo.Length();
+	while (ETrue)
+		{
+		TPtrC16 des(Mid(pos));
+		TInt found = des.Find(aFrom);
+		if (found == KErrNotFound) break;
+		TInt idx = pos + found;
+		TInt neededLen = Length() + lenDelta;
+		if (neededLen > MaxLength())
+			{
+			neededLen = Max(neededLen, MaxLength()*2);
+			ReAllocL(neededLen);
+			}
+		Replace(idx, aFrom.Length(), aTo);
+		pos = idx + aTo.Length();
+		//numReplaced++;
+		}
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::ReplaceL(TInt aPos, TInt aLength, const TDesC16 &aDes)
+	{
+	const TInt lenDelta = -aLength + aDes.Length();
+	ReserveExtraL(lenDelta);
+	Replace(aPos, aLength, aDes);
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf16::CreateMax(TInt aMaxLength)
+	{
+	TInt err = Create(aMaxLength);
+	if (!err) SetLength(aMaxLength);
+	return err;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::CreateMaxL(TInt aMaxLength)
+	{
+	User::LeaveIfError(CreateMax(aMaxLength));
+	}
+
+class TOverflowDetect : public TDes16Overflow
+	{
+public:
+	TOverflowDetect() : iOverflowed(EFalse) {}
+	virtual void Overflow(TDes16& /*aDes*/) { iOverflowed = ETrue; }
+
+	TBool iOverflowed;
+	};
+
+EXPORT_C void LtkUtils::RLtkBuf16::AppendFormatL(TRefByValue<const TDesC16> aFmt, ...)
+	{
+	TInt origLen = Length();
+	for (;;)
+		{
+		VA_LIST args;
+		VA_START(args, aFmt);
+		TOverflowDetect overflow;
+		AppendFormatList(aFmt, args, &overflow);
+		VA_END(args);
+		if (overflow.iOverflowed)
+			{
+			SetLength(origLen); // In case we got half-way through formatting
+			ReAllocL(Max(16, MaxLength() * 2));
+			// And go round again
+			}
+		else
+			{
+			// We're done, no overflow
+			break;
+			}
+		}
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::ReserveExtraL(TInt aExtraCapacity)
+	{
+	User::LeaveIfError(ReserveExtra(aExtraCapacity));
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf16::ReserveExtra(TInt aExtraCapacity)
+	{
+	if (Length() + aExtraCapacity > MaxLength())
+		{
+		TInt newlen = Max(Length() + aExtraCapacity, (MaxLength() * 3)/2);
+		return ReAlloc(newlen);
+		}
+	return KErrNone;
+	}
+
+inline TDesC8::TDesC8(TInt aType,TInt aLength)
+	:iLength(aLength|(aType<<KShiftDesType8))
+	{}
+
+inline TDes8::TDes8(TInt aType,TInt aLength,TInt aMaxLength)
+	: TDesC8(aType,aLength),iMaxLength(aMaxLength)
+	{}
+
+EXPORT_C LtkUtils::RLtkBuf8::RLtkBuf8()
+	: TDes8(EPtr,0,0), iBuf(NULL)
+	{
+	}
+
+EXPORT_C LtkUtils::RLtkBuf8::RLtkBuf8(HBufC8* aBuf)
+	{
+	if(aBuf)
+		{
+		//Create EBufCPtr type descriptor that points to aHBuf
+		// I'll take base_e32's word for it that this does the right thing...
+		new(this) TPtr8(aBuf->Des());
+		}
+	else
+		{
+		//Create zero-length RBuf8. It is EPtr type of descriptor that points to NULL.
+		new(this) RLtkBuf8();
+		}
+	}
+
+EXPORT_C HBufC8* LtkUtils::RLtkBuf8::ToHBuf()
+	{
+	// This transfers ownership
+	HBufC8* result = iBuf;
+	Assign(NULL);
+	return result;
+	}
+
+EXPORT_C HBufC8* LtkUtils::RLtkBuf8::GetHBuf() const
+	{
+	// This doesn't transfer ownership
+	return iBuf;
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf8::ReAlloc(TInt aMaxLength)
+	{
+	if (!aMaxLength) // Reallocation to zero length
+		{
+		Close();
+		return KErrNone;
+		}
+
+	if (!iBuf) // Reallocation from zero length
+		return Create(aMaxLength); 
+
+	HBufC8* newbuf = iBuf->ReAlloc(aMaxLength);
+	if (!newbuf) return KErrNoMemory;
+	Assign(newbuf);
+	return KErrNone;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::ReAllocL(TInt aMaxLength)
+	{
+	User::LeaveIfError(ReAlloc(aMaxLength));
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::Assign(HBufC8* aBuf)
+	{
+	new(this) RLtkBuf8(aBuf);
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf8::Create(TInt aMaxLength)
+	{
+	if (aMaxLength)
+		{
+		HBufC8* buf = HBufC8::New(aMaxLength);
+		if (!buf) return KErrNoMemory;
+		Assign(buf);
+		}
+	else
+		{
+		Assign(NULL);
+		}
+	return KErrNone;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::CreateL(TInt aMaxLength)
+	{
+	User::LeaveIfError(Create(aMaxLength));
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::CreateLC(TInt aMaxLength)
+	{
+	CleanupClosePushL(*this);
+	User::LeaveIfError(Create(aMaxLength));
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::Close()
+	{
+	delete iBuf;
+	Assign(NULL);
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::AppendL(const TDesC8& aText)
+	{
+	ReserveExtraL(aText.Length());
+	Append(aText);
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::AppendL(TChar aChar)
+	{
+	ReserveExtraL(1);
+	Append(aChar);
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::ReplaceAllL(const TDesC8& aFrom, const TDesC8& aTo)
+	{
+	//TInt numReplaced = 0;
+	TInt pos = 0;
+	const TInt lenDelta = -aFrom.Length() + aTo.Length();
+	while (ETrue)
+		{
+		TPtrC8 des(Mid(pos));
+		TInt found = des.Find(aFrom);
+		if (found == KErrNotFound) break;
+		TInt idx = pos + found;
+		TInt neededLen = Length() + lenDelta;
+		if (neededLen > MaxLength())
+			{
+			neededLen = Max(neededLen, MaxLength()*2);
+			ReAllocL(neededLen);
+			}
+		Replace(idx, aFrom.Length(), aTo);
+		pos = idx + aTo.Length();
+		//numReplaced++;
+		}
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::ReplaceL(TInt aPos, TInt aLength, const TDesC8& aDes)
+	{
+	const TInt lenDelta = -aLength + aDes.Length();
+	if (Length() + lenDelta > MaxLength())
+		{
+		ReAllocL(Length() + lenDelta);
+		}
+	Replace(aPos, aLength, aDes);
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf8::CreateMax(TInt aMaxLength)
+	{
+	TInt err = Create(aMaxLength);
+	if (!err) SetLength(aMaxLength);
+	return err;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::CreateMaxL(TInt aMaxLength)
+	{
+	User::LeaveIfError(CreateMax(aMaxLength));
+	}
+
+class TOverflowDetect8 : public TDes8Overflow
+	{
+public:
+	TOverflowDetect8() : iOverflowed(EFalse) {}
+	virtual void Overflow(TDes8& /*aDes*/) { iOverflowed = ETrue; }
+
+	TBool iOverflowed;
+	};
+
+EXPORT_C void LtkUtils::RLtkBuf8::AppendFormatL(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	TInt origLen = Length();
+	for (;;)
+		{
+		VA_LIST args;
+		VA_START(args, aFmt);
+		TOverflowDetect8 overflow;
+		AppendFormatList(aFmt, args, &overflow);
+		VA_END(args);
+		if (overflow.iOverflowed)
+			{
+			SetLength(origLen); // In case we got half-way through formatting
+			ReAllocL(Max(16, MaxLength() * 2));
+			// And go round again
+			}
+		else
+			{
+			// We're done, no overflow
+			break;
+			}
+		}
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::AppendL(const TDesC8& aText)
+	{
+	if (Length() + aText.Length() > MaxLength())
+		{
+		ReAllocL(Length() + aText.Length());
+		}
+	TPtr16 endBit((TUint16*)Ptr()+Length(), aText.Length(), aText.Length());
+	endBit.Copy(aText);
+	SetLength(Length() + aText.Length());
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::AppendL(const TDesC16& aText)
+	{
+	if (Length() + aText.Length() > MaxLength())
+		{
+		ReAllocL(Length() + aText.Length());
+		}
+	TPtr8 endBit((TUint8*)Ptr()+Length(), aText.Length(), aText.Length());
+	endBit.Copy(aText);
+	SetLength(Length() + aText.Length());
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::ReserveExtraL(TInt aExtraCapacity)
+	{
+	User::LeaveIfError(ReserveExtra(aExtraCapacity));
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf8::ReserveExtra(TInt aExtraCapacity)
+	{
+	if (Length() + aExtraCapacity > MaxLength())
+		{
+		TInt newlen = Max(Length() + aExtraCapacity, (MaxLength() * 3)/2);
+		return ReAlloc(newlen);
+		}
+	return KErrNone;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf8::CopyAsUtf8L(const TDesC16& aString)
+	{
+	// This algorithm is as per the unicode standard v5.2, section 3.9.
+	// Interestingly, byte sequences C0-C1 and F5-FF are completely unused in UTF-8.
+	// Means there won't be any telnet escape problems with 0xFFs...
+
+	// This function supports the full UTF-16 spec including surrogate pairs, even though the rest of the OS doesn't.
+
+	SetLength(0);
+	const TInt len = aString.Length();
+	ReserveExtraL(len); // First guess assumes it's ASCII
+	for (TInt i = 0; i < len; i++)
+		{
+		TUint16 ch = aString[i];
+		if (ch < 0x80)
+			{
+			// ASCII - one byte
+			AppendL(ch);
+			}
+		else if (ch < 0x800)
+			{
+			// 2 byte
+			TUint8 first = 0xC0 | ((ch & 0x7C0) >> 6);
+			TUint8 second = 0x80 | (ch & 0x3F);
+			AppendL(first);
+			AppendL(second);
+			}
+		else if (Rng(0xD800, (TInt)ch, 0xDBFF))
+			{
+			// Leading surrogate - a four byter
+			//const TUint32 LEAD_OFFSET = 0xD800 - (0x10000 >> 10);
+			const TUint32 SURROGATE_OFFSET = 0x10000u - (0xD800u << 10) - 0xDC00u;
+
+			if (i+1 < len && Rng(0xDC00, (TInt)aString[i+1], 0xDFFF))
+				{
+				TUint16 trailing = aString[i+1];
+				i++;
+				TUint32 fullCh = ((TUint32)ch << 10) + trailing + SURROGATE_OFFSET;
+				TUint8 first  = 0xF0 | ((fullCh & 0x1C0000) >> 18);
+				TUint8 second = 0x80 | ((fullCh & 0x030000) >> 16) | ((fullCh & 0xF000) >> 12);
+				TUint8 third  = 0x80 | ((fullCh & 0xFC0) >> 6);
+				TUint8 fourth = 0x80 | (fullCh & 0x3F);
+				AppendL(first);
+				AppendL(second);
+				AppendL(third);
+				AppendL(fourth);
+				}
+			else
+				{
+				// An orphaned leading surrogate - not allowed to just encode it blindly
+				AppendL(KReplacementCharInUtf8);
+				}
+			}
+		else if (Rng(0xDC00, (TInt)ch, 0xDFFF))
+			{
+			// Orphaned trailing surrogate
+			AppendL(KReplacementCharInUtf8);
+			}
+		else
+			{
+			//Anything else that fits in 16 bits is a three byter.
+			TUint8 first =  0xE0 | ((ch & 0xF000) >> 12);
+			TUint8 second = 0x80 | ((ch & 0xFC0) >> 6);
+			TUint8 third =  0x80 | (ch & 0x3F);
+			AppendL(first);
+			AppendL(second);
+			AppendL(third);
+			}
+		}
+	}
+
+EXPORT_C HBufC8* LtkUtils::Utf8L(const TDesC& aString)
+	{
+	RLtkBuf8 result;
+	CleanupClosePushL(result);
+	result.CopyAsUtf8L(aString);
+	CleanupStack::Pop(&result);
+	HBufC8* ptr = result.ToHBuf();
+	if (!ptr) ptr = HBufC8::NewL(1); // If aString was empty RLtkBuf won't bother creating an HBufC, but callers of this API would expect it
+	return ptr;
+	}
+
+EXPORT_C HBufC16* LtkUtils::DecodeUtf8L(const TDesC8& aUtf8EncodedText)
+	{
+	RLtkBuf16 result;
+	result.CreateLC(aUtf8EncodedText.Length());
+	result.CopyFromUtf8L(aUtf8EncodedText);
+	CleanupStack::Pop(&result);
+	return result.ToHBuf();
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::AppendUtf8L(const TDesC8& aUtf8EncodedText)
+	{
+	TInt dontCare;
+	AppendUtf8L(aUtf8EncodedText, dontCare);
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::CopyFromUtf8L(const TDesC8& aUtf8EncodedText)
+	{
+	ClearUtf8State(); // Just in case, somehow, some old state is lying around
+	Zero();
+	AppendUtf8L(aUtf8EncodedText);
+	User::LeaveIfError(FinalizeUtf8());
+	}
+
+TUtf8State::TUtf8State()
+	: iFirstUnconvertedByte(KErrNotFound), iBytesConsumedSoFar(0), iUnconvertedBytesCount(0)
+	{
+	}
+
+LtkUtils::TUtf8State* LtkUtils::RLtkBuf16::GetUtf8State() const
+	{
+	if (!iBuf) return NULL;
+	TInt hbufMaxLength = iBuf->Des().MaxLength();
+	TInt ourMaxLength = iMaxLength; // Ie the max length field from TDes16
+	if (hbufMaxLength == ourMaxLength + KStateCharCount)
+		{
+		// Then we have some state stashed Beyond The Bytes We Know
+		TUtf8State* state = (TUtf8State*)(Ptr() + ourMaxLength);
+		return state;
+		}
+	return NULL;
+	}
+
+void LtkUtils::RLtkBuf16::ClearUtf8State()
+	{
+	if (iBuf)
+		{
+		iMaxLength = iBuf->Des().MaxLength();
+		}
+	}
+
+EXPORT_C TInt LtkUtils::RLtkBuf16::FinalizeUtf8()
+	{
+	TInt firstBadBytePosition;
+	FinalizeUtf8(firstBadBytePosition);
+	return firstBadBytePosition == KErrNotFound ? KErrNone : KErrCorrupt;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::FinalizeUtf8(TInt& aFirstBadBytePosition)
+	{
+	TUtf8State* state = GetUtf8State();
+	if (!state)
+		{
+		aFirstBadBytePosition = KErrNotFound;
+		return;
+		}
+	TInt firstUnconvertedByte = state->iFirstUnconvertedByte;
+	if (state->iUnconvertedBytesCount != 0)
+		{
+		if (firstUnconvertedByte == KErrNotFound) firstUnconvertedByte = state->iBytesConsumedSoFar;
+		ClearUtf8State();
+		Append(KReplacementChar); // Can't fail or leave, we know there was enough space for the TUtf8State
+		}
+	else
+		{
+		ClearUtf8State();
+		}
+	aFirstBadBytePosition = firstUnconvertedByte;
+	}
+
+EXPORT_C void LtkUtils::RLtkBuf16::AppendUtf8L(const TDesC8& aText, TInt& aFirstBadBytePosition)
+	{
+	// This may not be the fastest algorithm, but it should hopefully be fairly easy to read and debug
+	// It's basically the inverse of RLtkBuf8::CopyAsUtf8L().
+	TUtf8State state;
+	TUtf8State* oldState = GetUtf8State();
+	if (oldState)
+		{
+		state = *oldState;
+		}
+	aFirstBadBytePosition = KErrNotFound;
+
+	const TInt textLen = aText.Length();
+	ReserveExtraL(textLen + KStateCharCount); // We will need at least this many characters, since a UTF-8 byte can never expand to less that 1 character.
+	TUint16* bufPtr = (TUint16*)Ptr() + Length();
+	TUint16* endPtr = (TUint16*)Ptr() + MaxLength();
+	const TInt initialLeftoverSize = state.iUnconvertedBytesCount;
+	TUint8 const* readPtr = initialLeftoverSize ? state.iUnconvertedBytes : aText.Ptr();
+	TUint8 const*const endFragmentPtr = (readPtr + state.iUnconvertedBytesCount);
+
+	for (TInt i = 0-state.iUnconvertedBytesCount; i < textLen; i++)
+		{
+		// Negative i means we're starting in the unconverted bytes left over from the last append
+		TUint8 ch = *readPtr++;
+		TInt validSequenceLength = 1;
+		TInt sequenceLength = 0;
+		// One of the benefits of UTF-8 is that you can know the sequence length just by looking at the first byte
+		if ((ch & 0x80) == 0) sequenceLength = 1;
+		else if ((ch & 0xE0) == 0xC0) sequenceLength = 2;
+		else if ((ch & 0xF0) == 0xE0) sequenceLength = 3;
+		else if ((ch & 0xF8) == 0xF0) sequenceLength = 4;
+		else
+			{
+			validSequenceLength = 0;
+			}
+
+		TUint32 fullchar = 0;
+		TInt availableSequenceLength = Min(sequenceLength, textLen - i);
+		if (i >= 0 && availableSequenceLength == sequenceLength)
+			{
+			// The normal case, no need to be careful about readptr
+			// This is the optimised code path
+			switch (sequenceLength)
+				{
+			case 0:
+				validSequenceLength = 0; // For optimisation purposes we don't bother setting this until now
+				break;
+			case 1:
+				fullchar = ch;
+				break;
+			case 2:
+				{
+				TUint8 second = *readPtr++;
+				if ((second & 0xC0) == 0x80) validSequenceLength++;
+				fullchar = ((ch & 0x1F) << 6) | (second & 0x3F);
+				break;
+				}
+			case 3:
+				{
+				TUint8 second = *readPtr++;
+				TUint8 third = *readPtr++;
+				if ((second & 0xC0) == 0x80)
+					{
+					validSequenceLength++;
+					if ((third & 0xC0) == 0x80) validSequenceLength++;
+					}
+				fullchar = ((ch & 0x0F) << 12) | ((second & 0x3F) << 6) | (third & 0x3F);
+				break;
+				}
+			case 4:
+				{
+				TUint8 second = *readPtr++;
+				TUint8 third = *readPtr++;
+				TUint8 fourth = *readPtr++;
+				if ((second & 0xC0) == 0x80)
+					{
+					validSequenceLength++;
+					if ((third & 0xC0) == 0x80)
+						{
+						validSequenceLength++;
+						if ((fourth & 0xC0) == 0x80) validSequenceLength++;
+						}
+					}
+				fullchar = ((ch & 0x07) << 18) | ((second & 0x3F) << 12) | ((third & 0x3F) << 6) | (fourth & 0x3F);
+				break;
+				}
+			default:
+				ASSERT(EFalse);
+				}
+
+			if (validSequenceLength != availableSequenceLength || validSequenceLength == 0)
+				{
+				// Failed sequence
+				fullchar = KReplacementChar;
+				if (state.iFirstUnconvertedByte == KErrNotFound)
+					{
+					// If we're still in the leftovers i will be negative and hopefully give us the right answer
+					state.iFirstUnconvertedByte = state.iBytesConsumedSoFar + state.iUnconvertedBytesCount + i;
+					}
+				if (aFirstBadBytePosition == KErrNotFound)
+					{
+					// Ugh i could be less than zero if we bailed in the leftovers. We'll say zero, even though that's strictly not correct
+					// Not a lot we can do because from the point of view of aFirstBadBytePosition we implicitly accepted the leftover bytes
+					// at the end of the previous AppendUtf8L() call
+					aFirstBadBytePosition = (i < 0) ? 0 : i;
+					}
+				if (validSequenceLength > 0) i += validSequenceLength-1; // No point testing the bytes we know to be valid following bytes, because they can't by definition be valid starting bytes (it would be within the spec to do so, but would mean we'd not be following best-practice regarding maximal subexpression replacement)
+				readPtr -= (availableSequenceLength - validSequenceLength); // Rewind readPtr over the additional bytes it read
+				}
+			else
+				{
+				i += sequenceLength-1; // Skip over the remaining chars in the sequence
+				}
+			}
+		else // Do it byte-by-byte and slowly
+			{	
+			// Validate as many bytes as we have available
+			TUint8 sequence[4];
+			sequence[0] = ch;
+			for (TInt j = 1; j < availableSequenceLength; j++)
+				{
+				if (readPtr == endFragmentPtr) readPtr = aText.Ptr();
+				sequence[j] = *readPtr++;
+				if ((sequence[j] & 0xC0) == 0x80)
+					{
+					validSequenceLength++;
+					}
+				else
+					{
+					break;
+					}
+				}
+			if (readPtr == endFragmentPtr) readPtr = aText.Ptr();
+
+			if (validSequenceLength != availableSequenceLength)
+				{
+				// Failed sequence
+				fullchar = KReplacementChar;
+				if (state.iFirstUnconvertedByte == KErrNotFound)
+					{
+					// If we're still in the leftovers i will be negative and hopefully give us the right answer
+					state.iFirstUnconvertedByte = state.iBytesConsumedSoFar + state.iUnconvertedBytesCount + i;
+					}
+				if (aFirstBadBytePosition == KErrNotFound)
+					{
+					// Ugh i could be less than zero if we bailed in the leftovers. We'll say zero, even though that's strictly not correct
+					// Not a lot we can do because from the point of view of aFirstBadBytePosition we implicitly accepted the leftover bytes
+					// at the end of the previous AppendUtf8L() call
+					aFirstBadBytePosition = (i < 0) ? 0 : i;
+					}
+				if (validSequenceLength > 0) i += validSequenceLength-1; // No point testing the bytes we know to be valid following bytes, because they can't by definition be valid starting bytes (it would be within the spec to do so, but would mean we'd not be following best-practice regarding maximal subexpression replacement)
+				}
+			else if (availableSequenceLength < sequenceLength)
+				{
+				// Then cache what we do have in the leftovers, that wasn't already 
+				TInt sequencePosNotFromLeftovers = 0;
+				if (i < 0)
+					{
+					sequencePosNotFromLeftovers = -i;
+					}
+				Mem::Copy(&state.iUnconvertedBytes[state.iUnconvertedBytesCount], &sequence[sequencePosNotFromLeftovers], availableSequenceLength-sequencePosNotFromLeftovers);
+				state.iUnconvertedBytesCount = availableSequenceLength;
+				i += availableSequenceLength-1; // Skip over the remaining chars in the sequence
+				continue;
+				}
+			else
+				{
+				// We've got everything, and it all validates
+				switch (sequenceLength)
+					{
+				case 1:
+					fullchar = ch;
+					break;
+				case 2:
+					fullchar = ((sequence[0] & 0x1F) << 6) | (sequence[1] & 0x3F);
+					break;
+				case 3:
+					fullchar = ((sequence[0] & 0x0F) << 12) | ((sequence[1] & 0x3F) << 6) | (sequence[2] & 0x3F);
+					break;
+				case 4:
+					fullchar = ((sequence[0] & 0x07) << 18) | ((sequence[1] & 0x3F) << 12) | ((sequence[2] & 0x3F) << 6) | (sequence[3] & 0x3F);
+					break;
+					}
+
+				state.iUnconvertedBytesCount = 0; // By definition we must have used up all the leftovers
+				i += sequenceLength-1; // Skip over the remaining chars in the sequence
+				}
+			}
+
+		if (fullchar == KBom && state.iBytesConsumedSoFar == 0 && (i + 1 - sequenceLength) <= 0)
+			{
+			// Byte order marks are ignored, so long as they're the first thing in the buffer (and this is the first buffer)
+			// Otherwise they are considered to be valid zero-width non-breaking spaces (ZWNBSPs)
+			continue;
+			}
+
+		// If we reach here we have a char to append
+		if (bufPtr == endPtr)
+			{
+			// if bufPtr equals endPtr we're at the end of the buffer and need to realloc it
+			SetLength(iMaxLength);
+			ReserveExtraL(1);
+			bufPtr = (TUint16*)Ptr() + Length();
+			endPtr = (TUint16*)Ptr() + MaxLength();
+			}
+		*bufPtr++ = fullchar;
+		}
+
+	// Finished handling all the bytes in aText, update some state
+	SetLength(bufPtr - Ptr());
+	TInt bytesAddedToLeftovers = state.iUnconvertedBytesCount - initialLeftoverSize;
+	state.iBytesConsumedSoFar += textLen - bytesAddedToLeftovers; // Bytes in the leftovers haven't technically been consumed yet
+	// Now save the state on the end of the buffer - any reallocs must have maintained the state, but there might not have been any state to start with
+	if (oldState == NULL)
+		{
+		ASSERT(iBuf == NULL || iMaxLength == iBuf->Des().MaxLength());
+		ReserveExtraL(KStateCharCount);
+		iMaxLength = iMaxLength - KStateCharCount;
+		}
+	Mem::Copy((TAny*)(Ptr() + iMaxLength), &state, sizeof(TUtf8State));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/friendlynames.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,137 @@
+// friendlynames.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ltkutils.h>
+
+EXPORT_C void LtkUtils::GetFriendlyThreadName(RThread aThread, TFullName& aFriendly)
+	{
+	aFriendly = aThread.FullName();
+	MakeThreadNameFriendly(aFriendly);
+	}
+		
+_LIT(KDoubleColon, "::");
+_LIT(KMain, "main");
+_LIT(KExtExe, ".exe");
+
+const static TInt KProcessUidLength = 8;
+const static TInt KProcessSequenceLength = 4;
+const static TInt KProcessSuffixLength = 2+KProcessUidLength+KProcessSequenceLength; // including []
+	
+EXPORT_C void LtkUtils::MakeThreadNameFriendly(TFullName& aFullThreadName)
+	{
+	TInt colonPos = aFullThreadName.Find(KDoubleColon);
+	TBool removeThreadName = EFalse;
+	TBool haveExeExt = EFalse;
+	
+	if (colonPos==KErrNotFound) return;
+	if (colonPos < KProcessSuffixLength) return;
+	if (aFullThreadName[colonPos-KProcessSuffixLength] != '[') return;
+	if (aFullThreadName[colonPos-KProcessSequenceLength-1] != ']') return;
+	
+	TPtrC sequenceNoStr(aFullThreadName.Mid(colonPos-KProcessSequenceLength, KProcessSequenceLength));
+	TLex lex(sequenceNoStr);
+	TInt sequenceNo;
+	if (lex.Val(sequenceNo)!=KErrNone) return;
+	if (lex.Remainder().Length()!=0) return;
+	
+	// see if the thread name is 'main'
+	TPtrC threadName(aFullThreadName.Mid(colonPos+2));
+	if (threadName.CompareF(KMain)==0)
+		{
+		removeThreadName = ETrue;
+		}
+		
+	// see if we have a .exe extension on the process
+	TPtrC processName(aFullThreadName.Left(colonPos - KProcessSuffixLength));
+	if (processName.Right(KExtExe().Length()).CompareF(KExtExe)==0)
+		{
+		haveExeExt = ETrue;
+		processName.Set(processName.Left(processName.Length() - KExtExe().Length()));
+		}
+	if (processName.CompareF(threadName)==0)
+		{
+		removeThreadName = ETrue;
+		}
+	
+	// we have now finished examining the name - remove from things from it
+	// starting from the end, so that we don't screw up the indices we're 
+	// about to use.
+	
+	if (removeThreadName)
+		{
+		aFullThreadName.SetLength(colonPos); // remove :: and thread name
+		}
+
+	// delete the process suffix
+	aFullThreadName.Delete(colonPos-KProcessSuffixLength, KProcessSuffixLength);
+	if (sequenceNo>1)
+		{
+		TBuf<7> sequenceStr;
+		sequenceStr.AppendFormat(_L("(%d)"), sequenceNo);
+		aFullThreadName.Insert(colonPos-KProcessSuffixLength, sequenceStr);
+		}
+	
+	if (haveExeExt)
+		{
+		aFullThreadName.Delete(colonPos-KProcessSuffixLength-KExtExe().Length(), KExtExe().Length());
+		}
+	}
+
+EXPORT_C void LtkUtils::GetFriendlyProcessName(const RProcess& aProcess, TDes& aFriendly)
+	{
+	aFriendly = aProcess.FullName();
+	MakeProcessNameFriendly(aFriendly);
+	}
+
+
+EXPORT_C void LtkUtils::MakeProcessNameFriendly(TDes& aFullProcessName)
+	{
+	TInt colonPos = aFullProcessName.Length();
+	TBool haveExeExt = EFalse;
+	
+	if (colonPos==KErrNotFound) return;
+	if (colonPos < KProcessSuffixLength) return;
+	if (aFullProcessName[colonPos-KProcessSuffixLength] != '[') return;
+	if (aFullProcessName[colonPos-KProcessSequenceLength-1] != ']') return;
+	
+	TPtrC sequenceNoStr(aFullProcessName.Mid(colonPos-KProcessSequenceLength, KProcessSequenceLength));
+	TLex lex(sequenceNoStr);
+	TInt sequenceNo;
+	if (lex.Val(sequenceNo)!=KErrNone) return;
+	if (lex.Remainder().Length()!=0) return;
+	
+	// see if we have a .exe extension on the process
+	TPtrC processName(aFullProcessName.Left(colonPos - KProcessSuffixLength));
+	if (processName.Right(KExtExe().Length()).CompareF(KExtExe)==0)
+		{
+		haveExeExt = ETrue;
+		processName.Set(processName.Left(processName.Length() - KExtExe().Length()));
+		}
+	
+	// we have now finished examining the name - remove from things from it
+	// starting from the end, so that we don't screw up the indices we're 
+	// about to use.
+	
+	// delete the process suffix
+	aFullProcessName.Delete(colonPos-KProcessSuffixLength, KProcessSuffixLength);
+	if (sequenceNo>1)
+		{
+		TBuf<7> sequenceStr;
+		sequenceStr.AppendFormat(_L("(%d)"), sequenceNo);
+		aFullProcessName.Insert(colonPos-KProcessSuffixLength, sequenceStr);
+		}
+	
+	if (haveExeExt)
+		{
+		aFullProcessName.Delete(colonPos-KProcessSuffixLength-KExtExe().Length(), KExtExe().Length());
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/heaphackery.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1678 @@
+// heaphackery.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifdef TEST_HYBRIDHEAP_ASSERTS
+#define private public
+#include <e32def.h>
+#include "slab.h"
+#include "page_alloc.h"
+#include "heap_hybrid.h"
+#endif
+
+#include "heaputils.h"
+
+#ifdef __KERNEL_MODE__
+
+#include <kern_priv.h>
+#define MEM Kern
+__ASSERT_COMPILE(sizeof(LtkUtils::RKernelSideAllocatorHelper) == 10*4);
+#define KERN_ENTER_CS() NKern::ThreadEnterCS()
+#define KERN_LEAVE_CS() NKern::ThreadLeaveCS()
+#define LOG(args...)
+#define HUEXPORT_C
+#else
+
+#include <e32std.h>
+#define MEM User
+#define KERN_ENTER_CS()
+#define KERN_LEAVE_CS()
+//#include <e32debug.h>
+//#define LOG(args...) RDebug::Printf(args)
+#define LOG(args...)
+
+#ifdef STANDALONE_ALLOCHELPER
+#define HUEXPORT_C
+#else
+#define HUEXPORT_C EXPORT_C
+#endif
+
+#endif // __KERNEL_MODE__
+
+using LtkUtils::RAllocatorHelper;
+const TUint KPageSize = 4096;
+__ASSERT_COMPILE(sizeof(RAllocatorHelper) == 9*4);
+
+// RAllocatorHelper
+
+HUEXPORT_C RAllocatorHelper::RAllocatorHelper()
+	: iAllocatorAddress(0), iAllocatorType(EUnknown), iInfo(NULL), iValidInfo(0), iTempSlabBitmap(NULL), iPageCache(NULL), iPageCacheAddr(0)
+#ifdef __KERNEL_MODE__
+	, iChunk(NULL)
+#endif
+	{
+	}
+
+namespace LtkUtils
+	{
+	class THeapInfo
+		{
+	public:
+		THeapInfo()
+			{
+			ClearStats();
+			}
+
+		void ClearStats()
+			{
+			memclr(this, sizeof(THeapInfo));
+			}
+
+		TInt iAllocatedSize; // number of bytes in allocated cells (excludes free cells, cell header overhead)
+		TInt iCommittedSize; // amount of memory actually committed (includes cell header overhead, gaps smaller than an MMU page)
+		TInt iAllocationCount; // number of allocations currently
+		TInt iMaxCommittedSize; // or thereabouts
+		TInt iMinCommittedSize;
+		TInt iUnusedPages;
+		TInt iCommittedFreeSpace;
+		// Heap-only stats
+		TInt iHeapFreeCellCount;
+		// Hybrid-only stats
+		TInt iDlaAllocsSize;
+		TInt iDlaAllocsCount;
+		TInt iDlaFreeSize;
+		TInt iDlaFreeCount;
+		TInt iSlabAllocsSize;
+		TInt iSlabAllocsCount;
+		TInt iPageAllocsSize;
+		TInt iPageAllocsCount;
+		TInt iSlabFreeCellSize;
+		TInt iSlabFreeCellCount;
+		TInt iSlabFreeSlabSize;
+		TInt iSlabFreeSlabCount;
+		};
+	}
+
+const TInt KTempBitmapSize = 256; // KMaxSlabPayload / mincellsize, technically. Close enough.
+
+#ifdef __KERNEL_MODE__
+
+TInt RAllocatorHelper::OpenKernelHeap()
+	{
+	_LIT(KName, "SvHeap");
+	NKern::ThreadEnterCS();
+	DObjectCon* chunkContainer = Kern::Containers()[EChunk];
+	chunkContainer->Wait();
+	const TInt chunkCount = chunkContainer->Count();
+	DChunk* foundChunk = NULL;
+	for(TInt i=0; i<chunkCount; i++)
+		{
+		DChunk* chunk = (DChunk*)(*chunkContainer)[i];
+		if (chunk->NameBuf() && chunk->NameBuf()->Find(KName) != KErrNotFound)
+			{
+			// Found it. No need to open it, we can be fairly confident the kernel heap isn't going to disappear from under us
+			foundChunk = chunk;
+			break;
+			}
+		}
+	iChunk = foundChunk;
+    chunkContainer->Signal();
+#ifdef __WINS__
+	TInt err = OpenChunkHeap((TLinAddr)foundChunk->Base(), 0); // It looks like DChunk::iBase/DChunk::iFixedBase should both be ok for the kernel chunk
+#else
+	// Copied from P::KernelInfo
+	const TRomHeader& romHdr=Epoc::RomHeader();
+	const TRomEntry* primaryEntry=(const TRomEntry*)Kern::SuperPage().iPrimaryEntry;
+	const TRomImageHeader* primaryImageHeader=(const TRomImageHeader*)primaryEntry->iAddressLin;
+	TLinAddr stack = romHdr.iKernDataAddress + Kern::RoundToPageSize(romHdr.iTotalSvDataSize);
+	TLinAddr heap = stack + Kern::RoundToPageSize(primaryImageHeader->iStackSize);
+	TInt err = OpenChunkHeap(heap, 0); // aChunkMaxSize is only used for trying the middle of the chunk for hybrid allocatorness, and the kernel heap doesn't use that (thankfully). So we can safely pass in zero.
+
+#endif
+	if (!err) err = FinishConstruction();
+	NKern::ThreadLeaveCS();
+	return err;
+	}
+
+#else
+
+HUEXPORT_C TInt RAllocatorHelper::Open(RAllocator* aAllocator)
+	{
+	iAllocatorAddress = (TLinAddr)aAllocator;
+	TInt udeb = EuserIsUdeb();
+	if (udeb < 0) return udeb; // error
+
+	TInt err = IdentifyAllocatorType(udeb);
+	if (!err)
+		{
+		err = FinishConstruction(); // Allocate everything up front
+		}
+	if (!err)
+		{
+		// We always stealth our own allocations, again to avoid tripping up allocator checks
+		SetCellNestingLevel(iInfo, -1);
+		SetCellNestingLevel(iTempSlabBitmap, -1);
+		SetCellNestingLevel(iPageCache, -1);
+		}
+	return err;
+	}
+
+#endif
+
+TInt RAllocatorHelper::FinishConstruction()
+	{
+	TInt err = KErrNone;
+	KERN_ENTER_CS();
+	if (!iInfo)
+		{
+		iInfo = new THeapInfo;
+		if (!iInfo) err = KErrNoMemory;
+		}
+	if (!err && !iTempSlabBitmap)
+		{
+		iTempSlabBitmap = (TUint8*)MEM::Alloc(KTempBitmapSize);
+		if (!iTempSlabBitmap) err = KErrNoMemory;
+		}
+	if (!err && !iPageCache)
+		{
+		iPageCache = MEM::Alloc(KPageSize);
+		if (!iPageCache) err = KErrNoMemory;
+		}
+
+	if (err)
+		{
+		delete iInfo;
+		iInfo = NULL;
+		MEM::Free(iTempSlabBitmap);
+		iTempSlabBitmap = NULL;
+		MEM::Free(iPageCache);
+		iPageCache = NULL;
+		}
+	KERN_LEAVE_CS();
+	return err;
+	}
+
+TInt RAllocatorHelper::ReadWord(TLinAddr aLocation, TUint32& aResult) const
+	{
+	// Check if we can satisfy the read from the cache
+	if (aLocation >= iPageCacheAddr)
+		{
+		TUint offset = aLocation - iPageCacheAddr;
+		if (offset < KPageSize)
+			{
+			aResult = ((TUint32*)iPageCache)[offset >> 2];
+			return KErrNone;
+			}
+		}
+
+	// If we reach here, not in page cache. Try and read in the new page
+	if (iPageCache)
+		{
+		TLinAddr pageAddr = aLocation & ~(KPageSize-1);
+		TInt err = ReadData(pageAddr, iPageCache, KPageSize);
+		if (!err)
+			{
+			iPageCacheAddr = pageAddr;
+			aResult = ((TUint32*)iPageCache)[(aLocation - iPageCacheAddr) >> 2];
+			return KErrNone;
+			}
+		}
+
+	// All else fails, try just reading it uncached
+	return ReadData(aLocation, &aResult, sizeof(TUint32));
+	}
+
+TInt RAllocatorHelper::ReadByte(TLinAddr aLocation, TUint8& aResult) const
+	{
+	// Like ReadWord but 8-bit
+
+	// Check if we can satisfy the read from the cache
+	if (aLocation >= iPageCacheAddr)
+		{
+		TUint offset = aLocation - iPageCacheAddr;
+		if (offset < KPageSize)
+			{
+			aResult = ((TUint8*)iPageCache)[offset];
+			return KErrNone;
+			}
+		}
+
+	// If we reach here, not in page cache. Try and read in the new page
+	if (iPageCache)
+		{
+		TLinAddr pageAddr = aLocation & ~(KPageSize-1);
+		TInt err = ReadData(pageAddr, iPageCache, KPageSize);
+		if (!err)
+			{
+			iPageCacheAddr = pageAddr;
+			aResult = ((TUint8*)iPageCache)[(aLocation - iPageCacheAddr)];
+			return KErrNone;
+			}
+		}
+
+	// All else fails, try just reading it uncached
+	return ReadData(aLocation, &aResult, sizeof(TUint8));
+	}
+
+
+TInt RAllocatorHelper::WriteWord(TLinAddr aLocation, TUint32 aWord)
+	{
+	// Invalidate the page cache if necessary
+	if (aLocation >= iPageCacheAddr && aLocation - iPageCacheAddr < KPageSize)
+		{
+		iPageCacheAddr = 0;
+		}
+
+	return WriteData(aLocation, &aWord, sizeof(TUint32));
+	}
+
+TInt RAllocatorHelper::ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const
+	{
+	// RAllocatorHelper base class impl is for allocators in same address space, so just copy it
+	memcpy(aResult, (const TAny*)aLocation, aSize);
+	return KErrNone;
+	}
+
+TInt RAllocatorHelper::WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize)
+	{
+	memcpy((TAny*)aLocation, aData, aSize);
+	return KErrNone;
+	}
+
+#ifdef __KERNEL_MODE__
+
+LtkUtils::RKernelSideAllocatorHelper::RKernelSideAllocatorHelper()
+	: iThread(NULL)
+	{}
+
+void LtkUtils::RKernelSideAllocatorHelper::Close()
+	{
+	NKern::ThreadEnterCS();
+	if (iThread)
+		{
+		iThread->Close(NULL);
+		}
+	iThread = NULL;
+	RAllocatorHelper::Close();
+	NKern::ThreadLeaveCS();
+	}
+
+TInt LtkUtils::RKernelSideAllocatorHelper::ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const
+	{
+	return Kern::ThreadRawRead(iThread, (const TAny*)aLocation, aResult, aSize);
+	}
+
+TInt LtkUtils::RKernelSideAllocatorHelper::WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize)
+	{
+	return Kern::ThreadRawWrite(iThread, (TAny*)aLocation, aData, aSize);
+	}
+
+TInt LtkUtils::RKernelSideAllocatorHelper::TryLock()
+	{
+	return KErrNotSupported;
+	}
+
+void LtkUtils::RKernelSideAllocatorHelper::TryUnlock()
+	{
+	// Not supported
+	}
+
+TInt LtkUtils::RKernelSideAllocatorHelper::OpenUserHeap(TUint aThreadId, TLinAddr aAllocatorAddress, TBool aEuserIsUdeb)
+	{
+	NKern::ThreadEnterCS();
+	DObjectCon* threads = Kern::Containers()[EThread];
+	threads->Wait();
+	iThread = Kern::ThreadFromId(aThreadId);
+	if (iThread && iThread->Open() != KErrNone)
+		{
+		// Failed to open
+		iThread = NULL;
+		}
+	threads->Signal();
+	NKern::ThreadLeaveCS();
+	if (!iThread) return KErrNotFound;
+	iAllocatorAddress = aAllocatorAddress;
+	TInt err = IdentifyAllocatorType(aEuserIsUdeb);
+	if (err) Close();
+	return err;
+	}
+
+#endif // __KERNEL_MODE__
+
+TInt RAllocatorHelper::OpenChunkHeap(TLinAddr aChunkBase, TInt aChunkMaxSize)
+	{
+	iAllocatorAddress = aChunkBase;
+#ifdef __KERNEL_MODE__
+	// Must be in CS
+	// Assumes that this only ever gets called for the kernel heap. Otherwise goes through RKernelSideAllocatorHelper::OpenUserHeap.
+	TInt udeb = EFalse; // We can't figure this out until after we've got the heap
+#else
+	// Assumes the chunk isn't the kernel heap. It's not a good idea to try messing with the kernel heap from user side...
+	TInt udeb = EuserIsUdeb();
+	if (udeb < 0) return udeb; // error
+#endif
+
+	TInt err = IdentifyAllocatorType(udeb);
+	if (err == KErrNone && iAllocatorType == EAllocator)
+		{
+		// We've no reason to assume it's an allocator because we don't know the iAllocatorAddress actually is an RAllocator*
+		err = KErrNotFound;
+		}
+	if (err)
+		{
+		TInt oldErr = err;
+		TAllocatorType oldType = iAllocatorType;
+		// Try middle of chunk, in case it's an RHybridHeap
+		iAllocatorAddress += aChunkMaxSize / 2;
+		err = IdentifyAllocatorType(udeb);
+		if (err || iAllocatorType == EAllocator)
+			{
+			// No better than before
+			iAllocatorAddress = aChunkBase;
+			iAllocatorType = oldType;
+			err = oldErr;
+			}
+		}
+#ifdef __KERNEL_MODE__
+	if (err == KErrNone)
+		{
+		// Now we know the allocator, we can figure out the udeb-ness
+		RAllocator* kernelAllocator = reinterpret_cast<RAllocator*>(iAllocatorAddress);
+		kernelAllocator->DebugFunction(RAllocator::ESetFail, (TAny*)9999, (TAny*)0); // Use an invalid fail reason - this should have no effect on the operation of the heap
+		TInt err = kernelAllocator->DebugFunction(7, NULL, NULL); // 7 is RAllocator::TAllocDebugOp::EGetFail
+		if (err == 9999)
+			{
+			// udeb new
+			udeb = ETrue;
+			}
+		else if (err == KErrNotSupported)
+			{
+			// Old heap - fall back to slightly nasty non-thread-safe method
+			kernelAllocator->DebugFunction(RAllocator::ESetFail, (TAny*)RAllocator::EFailNext, (TAny*)1);
+			TAny* res = Kern::Alloc(4);
+			if (res) udeb = ETrue;
+			Kern::Free(res);
+			}
+		else
+			{
+			// it's new urel
+			}
+
+		// Put everything back
+		kernelAllocator->DebugFunction(RAllocator::ESetFail, (TAny*)RAllocator::ENone, (TAny*)0);
+		// And update the type now we know the udeb-ness for certain
+		err = IdentifyAllocatorType(udeb);
+		}
+#endif
+	return err;
+	}
+
+
+// The guts of RAllocatorHelper
+
+enum TWhatToGet
+	{
+	ECommitted = 1,
+	EAllocated = 2,
+	ECount = 4,
+	EMaxSize = 8,
+	EUnusedPages = 16,
+	ECommittedFreeSpace = 32,
+	EMinSize = 64,
+	EHybridStats = 128,
+	};
+
+class RHackAllocator : public RAllocator
+	{
+public:
+	using RAllocator::iHandles;
+	using RAllocator::iTotalAllocSize;
+	using RAllocator::iCellCount;
+	};
+
+class RHackHeap : public RHeap
+	{
+public:
+	// Careful, only allowed to use things that are still in the new RHeap, and are still in the same place
+	using RHeap::iMaxLength;
+	using RHeap::iChunkHandle;
+	using RHeap::iLock;
+	using RHeap::iBase;
+	using RHeap::iAlign;
+	using RHeap::iTop;
+	};
+
+const TInt KChunkSizeOffset = 30*4;
+const TInt KPageMapOffset = 141*4;
+//const TInt KDlOnlyOffset = 33*4;
+const TInt KMallocStateOffset = 34*4;
+const TInt KMallocStateTopSizeOffset = 3*4;
+const TInt KMallocStateTopOffset = 5*4;
+const TInt KMallocStateSegOffset = 105*4;
+const TInt KUserHybridHeapSize = 186*4;
+const TInt KSparePageOffset = 167*4;
+const TInt KPartialPageOffset = 165*4;
+const TInt KFullSlabOffset = 166*4;
+const TInt KSlabAllocOffset = 172*4;
+const TInt KSlabParentOffset = 1*4;
+const TInt KSlabChild1Offset = 2*4;
+const TInt KSlabChild2Offset = 3*4;
+const TInt KSlabPayloadOffset = 4*4;
+const TInt KSlabsetSize = 4;
+
+#ifdef TEST_HYBRIDHEAP_ASSERTS
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iChunkSize) == KChunkSizeOffset);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iPageMap) == KPageMapOffset);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iGlobalMallocState) == KMallocStateOffset);
+__ASSERT_COMPILE(sizeof(malloc_state) == 107*4);
+__ASSERT_COMPILE(_FOFF(malloc_state, iTopSize) == KMallocStateTopSizeOffset);
+__ASSERT_COMPILE(_FOFF(malloc_state, iTop) == KMallocStateTopOffset);
+__ASSERT_COMPILE(_FOFF(malloc_state, iSeg) == KMallocStateSegOffset);
+__ASSERT_COMPILE(sizeof(RHybridHeap) == KUserHybridHeapSize);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iSparePage) == KSparePageOffset);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iPartialPage) == KPartialPageOffset);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iSlabAlloc) == KSlabAllocOffset);
+__ASSERT_COMPILE(_FOFF(slab, iParent) == KSlabParentOffset);
+__ASSERT_COMPILE(_FOFF(slab, iChild1) == KSlabChild1Offset);
+__ASSERT_COMPILE(_FOFF(slab, iChild2) == KSlabChild2Offset);
+__ASSERT_COMPILE(_FOFF(slab, iPayload) == KSlabPayloadOffset);
+__ASSERT_COMPILE(sizeof(slabset) == KSlabsetSize);
+#endif
+
+TInt RAllocatorHelper::TryLock()
+	{
+#ifdef __KERNEL_MODE__
+	NKern::ThreadEnterCS();
+	DMutex* m = *(DMutex**)(iAllocatorAddress + _FOFF(RHackHeap, iLock));
+	if (m) Kern::MutexWait(*m);
+	return KErrNone;
+#else
+	if (iAllocatorType != EUnknown && iAllocatorType != EAllocator)
+		{
+		RFastLock& lock = *reinterpret_cast<RFastLock*>(iAllocatorAddress + _FOFF(RHackHeap, iLock));
+		lock.Wait();
+		return KErrNone;
+		}
+	return KErrNotSupported;
+#endif
+	}
+
+void RAllocatorHelper::TryUnlock()
+	{
+#ifdef __KERNEL_MODE__
+	DMutex* m = *(DMutex**)(iAllocatorAddress + _FOFF(RHackHeap, iLock));
+	if (m) Kern::MutexSignal(*m);
+	NKern::ThreadLeaveCS();
+#else
+	if (iAllocatorType != EUnknown && iAllocatorType != EAllocator)
+		{
+		RFastLock& lock = *reinterpret_cast<RFastLock*>(iAllocatorAddress + _FOFF(RHackHeap, iLock));
+		lock.Signal();
+		}
+#endif
+	}
+
+HUEXPORT_C void RAllocatorHelper::Close()
+	{
+	KERN_ENTER_CS();
+	iAllocatorType = EUnknown;
+	iAllocatorAddress = 0;
+	delete iInfo;
+	iInfo = NULL;
+	iValidInfo = 0;
+	MEM::Free(iTempSlabBitmap);
+	iTempSlabBitmap = NULL;
+	MEM::Free(iPageCache);
+	iPageCache = NULL;
+	iPageCacheAddr = 0;
+	KERN_LEAVE_CS();
+	}
+
+TInt RAllocatorHelper::IdentifyAllocatorType(TBool aAllocatorIsUdeb)
+	{
+	iAllocatorType = EUnknown;
+
+	TUint32 handlesPtr = 0;
+	TInt err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iHandles), handlesPtr);
+
+	if (err) return err;
+	if (handlesPtr == iAllocatorAddress + _FOFF(RHackHeap, iChunkHandle) || handlesPtr == iAllocatorAddress + _FOFF(RHackHeap, iLock))
+		{
+		// It's an RHeap of some kind - I doubt any other RAllocator subclass will use iHandles in this way
+		TUint32 base = 0;
+		err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), base);
+		if (err) return err;
+		TInt objsize = (TInt)base - (TInt)iAllocatorAddress;
+		if (objsize <= 32*4)
+			{
+			// Old RHeap
+			iAllocatorType = aAllocatorIsUdeb ? EUdebOldRHeap : EUrelOldRHeap;
+			}
+		else
+			{
+			// new hybrid heap - bigger than the old one. Likewise figure out if udeb or urel.
+			iAllocatorType = aAllocatorIsUdeb ? EUdebHybridHeap : EUrelHybridHeap;
+			}
+		}
+	else
+		{
+		iAllocatorType = EAllocator;
+		}
+	return KErrNone;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::SetCellNestingLevel(TAny* aCell, TInt aNestingLevel)
+	{
+	TInt err = KErrNone;
+
+	switch (iAllocatorType)
+		{
+		case EUdebOldRHeap:
+		case EUdebHybridHeap:
+			// By this reckoning, they're in the same place amazingly
+			{
+			TLinAddr nestingAddr = (TLinAddr)aCell - 8;
+			err = WriteWord(nestingAddr, aNestingLevel);
+			break;
+			}
+		default:
+			break;
+		}
+	return err;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::GetCellNestingLevel(TAny* aCell, TInt& aNestingLevel)
+	{
+	switch (iAllocatorType)
+		{
+		case EUdebOldRHeap:
+		case EUdebHybridHeap:
+			// By this reckoning, they're in the same place amazingly
+			{
+			TLinAddr nestingAddr = (TLinAddr)aCell - 8;
+			return ReadWord(nestingAddr, (TUint32&)aNestingLevel);
+			}
+		default:
+			return KErrNotSupported;
+		}
+	}
+
+TInt RAllocatorHelper::RefreshDetails(TUint aMask)
+	{
+	TInt err = FinishConstruction();
+	if (err) return err;
+
+	// Invalidate the page cache
+	iPageCacheAddr = 0;
+
+	TryLock();
+	err = DoRefreshDetails(aMask);
+	TryUnlock();
+	return err;
+	}
+
+const TInt KHeapWalkStatsForOldHeap = (EUnusedPages|ECommittedFreeSpace);
+const TInt KHeapWalkStatsForNewHeap = (EAllocated|ECount|EUnusedPages|ECommittedFreeSpace|EHybridStats);
+
+TInt RAllocatorHelper::DoRefreshDetails(TUint aMask)
+	{
+	TInt err = KErrNotSupported;
+	switch (iAllocatorType)
+		{
+		case EUrelOldRHeap:
+		case EUdebOldRHeap:
+			{
+			if (aMask & ECommitted)
+				{
+				// The old RHeap::Size() used to use iTop - iBase, which was effectively chunkSize - sizeof(RHeap)
+				// I think that for CommittedSize we should include the size of the heap object, just as it includes
+				// the size of heap cell metadata and overhead. Plus it makes sure the committedsize is a multiple of the page size
+				TUint32 top = 0;
+				//TUint32 base = 0;
+				//err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), base);
+				//if (err) return err;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iTop), top);
+				if (err) return err;
+
+				//iInfo->iCommittedSize = top - base;
+				iInfo->iCommittedSize = top - iAllocatorAddress;
+				iValidInfo |= ECommitted;
+				}
+			if (aMask & EAllocated)
+				{
+				TUint32 allocSize = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iTotalAllocSize), allocSize);
+				if (err) return err;
+				iInfo->iAllocatedSize = allocSize;
+				iValidInfo |= EAllocated;
+				}
+			if (aMask & ECount)
+				{
+				TUint32 count = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iCellCount), count);
+				if (err) return err;
+				iInfo->iAllocationCount = count;
+				iValidInfo |= ECount;
+				}
+			if (aMask & EMaxSize)
+				{
+				TUint32 maxlen = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iMaxLength), maxlen);
+				if (err) return err;
+				iInfo->iMaxCommittedSize = maxlen;
+				iValidInfo |= EMaxSize;
+				}
+			if (aMask & EMinSize)
+				{
+				TUint32 minlen = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iMaxLength) - 4, minlen); // This isn't a typo! iMinLength is 4 bytes before iMaxLength, on old heap ONLY
+				if (err) return err;
+				iInfo->iMinCommittedSize = minlen;
+				iValidInfo |= EMinSize;
+				}
+			if (aMask & KHeapWalkStatsForOldHeap)
+				{
+				// Need a heap walk
+				iInfo->ClearStats();
+				iValidInfo = 0;
+				err = DoWalk(&WalkForStats, NULL);
+				if (err == KErrNone) iValidInfo |= KHeapWalkStatsForOldHeap;
+				}
+			return err;
+			}
+		case EUrelHybridHeap:
+		case EUdebHybridHeap:
+			{
+			TBool needWalk = EFalse;
+			if (aMask & ECommitted)
+				{
+				// RAllocator::Size uses iChunkSize - sizeof(RHybridHeap);
+				// We can't do exactly the same, because we can't calculate sizeof(RHybridHeap), only ROUND_UP(sizeof(RHybridHeap), iAlign)
+				// And if fact we don't bother and just use iChunkSize
+				TUint32 chunkSize = 0;
+				err = ReadWord(iAllocatorAddress + KChunkSizeOffset, chunkSize);
+				if (err) return err;
+				//TUint32 baseAddr = 0;
+				//err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), baseAddr);
+				//if (err) return err;
+				iInfo->iCommittedSize = chunkSize; // - (baseAddr - iAllocatorAddress);
+				iValidInfo |= ECommitted;
+				}
+			if (aMask & (EAllocated|ECount))
+				{
+				if (iAllocatorType == EUdebHybridHeap)
+					{
+					// Easy, just get them from the counter
+					TUint32 totalAlloc = 0;
+					err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iTotalAllocSize), totalAlloc);
+					if (err) return err;
+					iInfo->iAllocatedSize = totalAlloc;
+					iValidInfo |= EAllocated;
+
+					TUint32 cellCount = 0;
+					err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iCellCount), cellCount);
+					if (err) return err;
+					iInfo->iAllocationCount = cellCount;
+					iValidInfo |= ECount;
+					}
+				else
+					{
+					// A heap walk is needed
+					needWalk = ETrue;
+					}
+				}
+			if (aMask & EMaxSize)
+				{
+				TUint32 maxlen = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iMaxLength), maxlen);
+				if (err) return err;
+				iInfo->iMaxCommittedSize = maxlen;
+				iValidInfo |= EMaxSize;
+				}
+			if (aMask & EMinSize)
+				{
+				TUint32 minlen = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iAlign) + 4*4, minlen); // iMinLength is in different place to old RHeap
+				if (err) return err;
+				iInfo->iMinCommittedSize = minlen;
+				iValidInfo |= EMinSize;
+				}
+			if (aMask & (EUnusedPages|ECommittedFreeSpace|EHybridStats))
+				{
+				// EAllocated and ECount have already been taken care of above
+				needWalk = ETrue;
+				}
+
+			if (needWalk)
+				{
+				iInfo->ClearStats();
+				iValidInfo = 0;
+				err = DoWalk(&WalkForStats, NULL);
+				if (err == KErrNone) iValidInfo |= KHeapWalkStatsForNewHeap;
+				}
+			return err;
+			}
+		default:
+			return KErrNotSupported;
+		}
+	}
+
+TInt RAllocatorHelper::CheckValid(TUint aMask)
+	{
+	if ((iValidInfo & aMask) == aMask)
+		{
+		return KErrNone;
+		}
+	else
+		{
+		return RefreshDetails(aMask);
+		}
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::CommittedSize()
+	{
+	TInt err = CheckValid(ECommitted);
+	if (err) return err;
+	return iInfo->iCommittedSize;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::AllocatedSize()
+	{
+	TInt err = CheckValid(EAllocated);
+	if (err) return err;
+	return iInfo->iAllocatedSize;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::AllocationCount()
+	{
+	TInt err = CheckValid(ECount);
+	if (err) return err;
+	return iInfo->iAllocationCount;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::RefreshDetails()
+	{
+	return RefreshDetails(iValidInfo);
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::MaxCommittedSize()
+	{
+	TInt err = CheckValid(EMaxSize);
+	if (err) return err;
+	return iInfo->iMaxCommittedSize;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::MinCommittedSize()
+	{
+	TInt err = CheckValid(EMinSize);
+	if (err) return err;
+	return iInfo->iMinCommittedSize;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::AllocCountForCell(TAny* aCell) const
+	{
+	TUint32 allocCount = 0;
+	switch (iAllocatorType)
+		{
+		case EUdebOldRHeap:
+		case EUdebHybridHeap: // Both are in the same place, amazingly
+			{
+			TLinAddr allocCountAddr = (TLinAddr)aCell - 4;
+			TInt err = ReadWord(allocCountAddr, allocCount);
+			if (err) return err;
+			return (TInt)allocCount;
+			}
+		default:
+			return KErrNotSupported;
+		}
+	}
+
+struct SContext3
+	{
+	RAllocatorHelper::TWalkFunc3 iOrigWalkFn;
+	TAny* iOrigContext;
+	};
+
+TBool RAllocatorHelper::DispatchClientWalkCallback(RAllocatorHelper& aHelper, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellPtr, TInt aCellLength)
+	{
+	WalkForStats(aHelper, NULL, aCellType, aCellPtr, aCellLength);
+	SContext3* context = static_cast<SContext3*>(aContext);
+	return (*context->iOrigWalkFn)(aHelper, context->iOrigContext, aCellType, aCellPtr, aCellLength);
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::Walk(TWalkFunc3 aCallbackFn, TAny* aContext)
+	{
+	// Might as well take the opportunity of updating our stats at the same time as walking the heap for the client
+	SContext3 context = { aCallbackFn, aContext };
+
+	TInt err = FinishConstruction(); // In case this hasn't been done yet
+	if (err) return err;
+
+	TryLock();
+	err = DoWalk(&DispatchClientWalkCallback, &context);
+	TryUnlock();
+	return err;
+	}
+
+TInt RAllocatorHelper::DoWalk(TWalkFunc3 aCallbackFn, TAny* aContext)
+	{
+	TInt err = KErrNotSupported;
+	switch (iAllocatorType)
+		{
+		case EUdebOldRHeap:
+		case EUrelOldRHeap:
+			err = OldSkoolWalk(aCallbackFn, aContext);
+			break;
+		case EUrelHybridHeap:
+		case EUdebHybridHeap:
+			err = NewHotnessWalk(aCallbackFn, aContext);
+			break;
+		default:
+			err = KErrNotSupported;
+			break;
+		}
+	return err;
+	}
+
+struct SContext
+	{
+	RAllocatorHelper::TWalkFunc iOrigWalkFn;
+	TAny* iOrigContext;
+	};
+
+struct SContext2
+	{
+	RAllocatorHelper::TWalkFunc2 iOrigWalkFn;
+	TAny* iOrigContext;
+	};
+
+#define New2Old(aNew) (((aNew)&RAllocatorHelper::EAllocationMask) ? RAllocatorHelper::EAllocation : ((aNew)&RAllocatorHelper::EFreeMask) ? RAllocatorHelper::EFreeSpace : RAllocatorHelper::EBadness)
+
+TBool DispatchOldTWalkFuncCallback(RAllocatorHelper& /*aHelper*/, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellPtr, TInt aCellLength)
+	{
+	SContext* context = static_cast<SContext*>(aContext);
+	return (*context->iOrigWalkFn)(context->iOrigContext, New2Old(aCellType), aCellPtr, aCellLength);
+	}
+
+TBool DispatchOldTWalk2FuncCallback(RAllocatorHelper& aHelper, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellPtr, TInt aCellLength)
+	{
+	SContext2* context = static_cast<SContext2*>(aContext);
+	return (*context->iOrigWalkFn)(aHelper, context->iOrigContext, New2Old(aCellType), aCellPtr, aCellLength);
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::Walk(TWalkFunc aCallbackFn, TAny* aContext)
+	{
+	// For backwards compatability insert a compatability callback to map between the different types of callback that clients requested
+	SContext context = { aCallbackFn, aContext };
+	return Walk(&DispatchOldTWalkFuncCallback, &context);
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::Walk(TWalkFunc2 aCallbackFn, TAny* aContext)
+	{
+	SContext2 context = { aCallbackFn, aContext };
+	return Walk(&DispatchOldTWalk2FuncCallback, &context);
+	}
+
+
+TInt RAllocatorHelper::OldSkoolWalk(TWalkFunc3 aCallbackFn, TAny* aContext)
+	{
+	TLinAddr pC = 0;
+	TInt err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), pC); // pC = iBase; // allocated cells
+	if (err) return err;
+	TLinAddr pF = iAllocatorAddress + _FOFF(RHackHeap, iAlign) + 3*4; // pF = &iFree; // free cells
+
+	TLinAddr top = 0;
+	err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iTop), top);
+	if (err) return err;
+	const TInt KAllocatedCellHeaderSize = iAllocatorType == EUdebOldRHeap ? 12 : 4;
+	TInt minCell = 0;
+	err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iAlign) + 4, (TUint32&)minCell);
+	if (err) return err;
+	TInt align = 0;
+	err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iAlign), (TUint32&)align);
+	if (err) return err;
+
+	FOREVER
+		{
+		err = ReadWord(pF+4, pF); // pF = pF->next; // next free cell
+		if (err) return err;
+		TLinAddr pFnext = 0;
+		if (pF) err = ReadWord(pF + 4, pFnext);
+		if (err) return err;
+
+		if (!pF)
+			{
+			pF = top; // to make size checking work
+			}
+		else if (pF>=top || (pFnext && pFnext<=pF) )
+			{
+			// free cell pointer off the end or going backwards
+			//Unlock();
+			(*aCallbackFn)(*this, aContext, EHeapBadFreeCellAddress, pF, 0);
+			return KErrCorrupt;
+			}
+		else
+			{
+			TInt l; // = pF->len
+			err = ReadWord(pF, (TUint32&)l);
+			if (err) return err;
+			if (l<minCell || (l & (align-1)))
+				{
+				// free cell length invalid
+				//Unlock();
+				(*aCallbackFn)(*this, aContext, EHeapBadFreeCellSize, pF, l);
+				return KErrCorrupt;
+				}
+			}
+		while (pC!=pF)				// walk allocated cells up to next free cell
+			{
+			TInt l; // pC->len;
+			err = ReadWord(pC, (TUint32&)l);
+			if (err) return err;
+			if (l<minCell || (l & (align-1)))
+				{
+				// allocated cell length invalid
+				//Unlock();
+				(*aCallbackFn)(*this, aContext, EHeapBadAllocatedCellSize, pC, l);
+				return KErrCorrupt;
+				}
+			TBool shouldContinue = (*aCallbackFn)(*this, aContext, EHeapAllocation, pC + KAllocatedCellHeaderSize, l - KAllocatedCellHeaderSize);
+			if (!shouldContinue) return KErrNone;
+			
+			//SCell* pN = __NEXT_CELL(pC);
+			TLinAddr pN = pC + l;
+			if (pN > pF)
+				{
+				// cell overlaps next free cell
+				//Unlock();
+				(*aCallbackFn)(*this, aContext, EHeapBadAllocatedCellAddress, pC, l);
+				return KErrCorrupt;
+				}
+			pC = pN;
+			}
+		if (pF == top)
+			break;		// reached end of heap
+		TInt pFlen = 0;
+		err = ReadWord(pF, (TUint32&)pFlen);
+		if (err) return err;
+		pC = pF + pFlen; // pC = __NEXT_CELL(pF);	// step to next allocated cell
+		TBool shouldContinue = (*aCallbackFn)(*this, aContext, EHeapFreeCell, pF, pFlen);
+		if (!shouldContinue) return KErrNone;
+		}
+	return KErrNone;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::CountUnusedPages()
+	{
+	TInt err = CheckValid(EUnusedPages);
+	if (err) return err;
+	return iInfo->iUnusedPages;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::CommittedFreeSpace()
+	{
+	TInt err = CheckValid(ECommittedFreeSpace);
+	if (err) return err;
+	return iInfo->iCommittedFreeSpace;
+	}
+
+#define ROUND_DOWN(val, pow2) ((val) & ~((pow2)-1))
+#define ROUND_UP(val, pow2) ROUND_DOWN((val) + (pow2) - 1, (pow2))
+
+HUEXPORT_C TLinAddr RAllocatorHelper::AllocatorAddress() const
+	{
+	return iAllocatorAddress;
+	}
+
+TBool RAllocatorHelper::WalkForStats(RAllocatorHelper& aSelf, TAny* /*aContext*/, TExtendedCellType aType, TLinAddr aCellPtr, TInt aCellLength)
+	{
+	//ASSERT(aCellLength >= 0);
+	THeapInfo& info = *aSelf.iInfo;
+
+	TInt pagesSpanned = 0; // The number of pages that fit entirely inside the payload of this cell
+	if ((TUint)aCellLength > KPageSize)
+		{
+		TLinAddr nextPageAlignedAddr = ROUND_UP(aCellPtr, KPageSize);
+		pagesSpanned = ROUND_DOWN(aCellPtr + aCellLength - nextPageAlignedAddr, KPageSize) / KPageSize;
+		}
+
+	if (aSelf.iAllocatorType == EUrelOldRHeap || aSelf.iAllocatorType == EUdebOldRHeap)
+		{
+		if (aType & EFreeMask)
+			{
+			info.iUnusedPages += pagesSpanned;
+			info.iCommittedFreeSpace += aCellLength;
+			info.iHeapFreeCellCount++;
+			}
+		}
+	else
+		{
+		if (aType & EAllocationMask)
+			{
+			info.iAllocatedSize += aCellLength;
+			info.iAllocationCount++;
+			}
+		else if (aType & EFreeMask)
+			{
+			// I *think* that DLA will decommit pages from inside free cells...
+			TInt committedLen = aCellLength - (pagesSpanned * KPageSize);
+			info.iCommittedFreeSpace += committedLen;
+			}
+
+		switch (aType)
+			{
+			case EDlaAllocation:
+				info.iDlaAllocsSize += aCellLength;
+				info.iDlaAllocsCount++;
+				break;
+			case EPageAllocation:
+				info.iPageAllocsSize += aCellLength;
+				info.iPageAllocsCount++;
+				break;
+			case ESlabAllocation:
+				info.iSlabAllocsSize += aCellLength;
+				info.iSlabAllocsCount++;
+				break;
+			case EDlaFreeCell:
+				info.iDlaFreeSize += aCellLength;
+				info.iDlaFreeCount++;
+				break;
+			case ESlabFreeCell:
+				info.iSlabFreeCellSize += aCellLength;
+				info.iSlabFreeCellCount++;
+				break;
+			case ESlabFreeSlab:
+				info.iSlabFreeSlabSize += aCellLength;
+				info.iSlabFreeSlabCount++;
+				break;
+			default:
+				break;
+			}
+		}
+
+	return ETrue;
+	}
+
+#define PAGESHIFT 12
+
+TUint RAllocatorHelper::PageMapOperatorBrackets(unsigned ix, TInt& err) const
+	{
+	//return 1U&(iBase[ix>>3] >> (ix&7));
+	TUint32 basePtr = 0;
+	err = ReadWord(iAllocatorAddress + KPageMapOffset, basePtr);
+	if (err) return 0;
+
+	TUint8 res = 0;
+	err = ReadByte(basePtr + (ix >> 3), res);
+	if (err) return 0;
+
+	return 1U&(res >> (ix&7));
+	}
+
+
+TInt RAllocatorHelper::PageMapFind(TUint start, TUint bit, TInt& err)
+	{
+	TUint32 iNbits = 0;
+	err = ReadWord(iAllocatorAddress + KPageMapOffset + 4, iNbits);
+	if (err) return 0;
+
+	if (start<iNbits) do
+		{
+		//if ((*this)[start]==bit)
+		if (PageMapOperatorBrackets(start, err) == bit || err)
+			return start;
+		} while (++start<iNbits);
+	return -1;
+	}
+
+TUint RAllocatorHelper::PagedDecode(TUint pos, TInt& err)
+	{
+	unsigned bits = PageMapBits(pos,2,err);
+	if (err) return 0;
+	bits >>= 1;
+	if (bits == 0)
+		return 1;
+	bits = PageMapBits(pos+2,2,err);
+	if (err) return 0;
+	if ((bits & 1) == 0)
+		return 2 + (bits>>1);
+	else if ((bits>>1) == 0)
+		{
+		return PageMapBits(pos+4, 4,err);
+		}
+	else
+		{
+		return PageMapBits(pos+4, 18,err);
+		}
+	}
+
+TUint RAllocatorHelper::PageMapBits(unsigned ix, unsigned len, TInt& err)
+	{
+	int l=len;
+	unsigned val=0;
+	unsigned bit=0;
+	while (--l>=0)
+		{
+		//val |= (*this)[ix++]<<bit++;
+		val |= PageMapOperatorBrackets(ix++, err) << bit++;
+		if (err) return 0;
+		}
+	return val;
+	}
+
+enum TSlabType { ESlabFullInfo, ESlabPartialInfo, ESlabEmptyInfo };
+
+#ifndef TEST_HYBRIDHEAP_ASSERTS
+#define MAXSLABSIZE		56
+#define	SLABSHIFT		10
+#define	SLABSIZE		(1 << SLABSHIFT)
+const TInt KMaxSlabPayload = SLABSIZE - KSlabPayloadOffset;
+#endif
+
+TInt RAllocatorHelper::NewHotnessWalk(TWalkFunc3 aCallbackFn, TAny* aContext)
+	{
+	// RHybridHeap does paged, slab then DLA, so that's what we do too
+	// Remember Kernel RHybridHeaps don't even have the page and slab members
+
+	TUint32 basePtr;
+	TInt err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), basePtr);
+	if (err) return err;
+	if (basePtr < iAllocatorAddress + KUserHybridHeapSize)
+		{
+		// Must be a kernel one - don't do page and slab
+		}
+	else
+		{
+		// Paged
+		TUint32 membase = 0;
+		err = ReadWord(iAllocatorAddress + KPageMapOffset + 8, membase);
+		if (err) return err;
+
+		TBool shouldContinue = ETrue;
+		for (int ix = 0;(ix = PageMapFind(ix,1,err)) >= 0 && err == KErrNone;)
+			{
+			int npage = PagedDecode(ix, err);
+			if (err) return err;
+			// Introduce paged buffer to the walk function 
+			TLinAddr bfr = membase + (1 << (PAGESHIFT-1))*ix;
+			int len = npage << PAGESHIFT;
+			if ( (TUint)len > KPageSize )
+				{ // If buffer is not larger than one page it must be a slab page mapped into bitmap
+				if (iAllocatorType == EUdebHybridHeap)
+					{
+					bfr += 8;
+					len -= 8;
+					}
+				shouldContinue = (*aCallbackFn)(*this, aContext, EPageAllocation, bfr, len);
+				if (!shouldContinue) return KErrNone;
+				}
+			ix += (npage<<1);
+			}
+		if (err) return err;
+
+		// Slab
+		TUint32 sparePage = 0;
+		err = ReadWord(iAllocatorAddress + KSparePageOffset, sparePage);
+		if (err) return err;
+		if (sparePage)
+			{
+			//Walk(wi, iSparePage, iPageSize, EGoodFreeCell, ESlabSpare); // Introduce Slab spare page to the walk function 
+			// This counts as 4 spare slabs
+			for (TInt i = 0; i < 4; i++)
+				{
+				shouldContinue = (*aCallbackFn)(*this, aContext, ESlabFreeSlab, sparePage + SLABSIZE*i, SLABSIZE);
+				if (!shouldContinue) return KErrNone;
+				}
+			}
+
+		//TreeWalk(&iFullSlab, &SlabFullInfo, i, wi);
+		TInt err = TreeWalk(iAllocatorAddress + KFullSlabOffset, ESlabFullInfo, aCallbackFn, aContext, shouldContinue);
+		if (err || !shouldContinue) return err;
+		for (int ix = 0; ix < (MAXSLABSIZE>>2); ++ix)
+			{
+			TUint32 partialAddr = iAllocatorAddress + KSlabAllocOffset + ix*KSlabsetSize;
+			//TreeWalk(&iSlabAlloc[ix].iPartial, &SlabPartialInfo, i, wi);
+			err = TreeWalk(partialAddr, ESlabPartialInfo, aCallbackFn, aContext, shouldContinue);
+			if (err || !shouldContinue) return err;
+			}
+		//TreeWalk(&iPartialPage, &SlabEmptyInfo, i, wi);
+		TreeWalk(iAllocatorAddress + KPartialPageOffset, ESlabEmptyInfo, aCallbackFn, aContext, shouldContinue);
+		}
+
+	// DLA
+#define CHUNK_OVERHEAD (sizeof(TUint))
+#define CHUNK_ALIGN_MASK (7) 
+#define CHUNK2MEM(p)        ((TLinAddr)(p) + 8)
+#define MEM2CHUNK(mem)      ((TLinAddr)(p) - 8)
+/* chunk associated with aligned address A */
+#define ALIGN_OFFSET(A)\
+	((((TLinAddr)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
+	((8 - ((TLinAddr)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK))
+#define ALIGN_AS_CHUNK(A)   ((A) + ALIGN_OFFSET(CHUNK2MEM(A)))
+#define CINUSE_BIT 2
+#define INUSE_BITS 3
+
+	TUint32 topSize = 0;
+	err = ReadWord(iAllocatorAddress + KMallocStateOffset + KMallocStateTopSizeOffset, topSize);
+	if (err) return err;
+
+	TUint32 top = 0;
+	err = ReadWord(iAllocatorAddress + KMallocStateOffset + KMallocStateTopOffset, top);
+	if (err) return err;
+
+	TInt max = ((topSize-1) & ~CHUNK_ALIGN_MASK) - CHUNK_OVERHEAD;
+	if ( max < 0 )
+		max = 0;
+	
+	TBool shouldContinue = (*aCallbackFn)(*this, aContext, EDlaFreeCell, top, max);
+	if (!shouldContinue) return KErrNone;
+	
+	TUint32 mallocStateSegBase = 0;
+	err = ReadWord(iAllocatorAddress + KMallocStateOffset + KMallocStateSegOffset, mallocStateSegBase);
+	if (err) return err;
+
+	for (TLinAddr q = ALIGN_AS_CHUNK(mallocStateSegBase); q != top; /*q = NEXT_CHUNK(q)*/)
+		{
+		TUint32 qhead = 0;
+		err = ReadWord(q + 4, qhead);
+		if (err) return err;
+		//TInt sz = CHUNKSIZE(q);
+		TInt sz = qhead & ~(INUSE_BITS);
+		if (!(qhead & CINUSE_BIT))
+			{
+			//Walk(wi, CHUNK2MEM(q), sz, EGoodFreeCell, EDougLeaAllocator); // Introduce DL free buffer to the walk function 
+			shouldContinue = (*aCallbackFn)(*this, aContext, EDlaFreeCell, CHUNK2MEM(q), sz);
+			if (!shouldContinue) return KErrNone;
+			}
+		else
+			{
+			//Walk(wi, CHUNK2MEM(q), (sz- CHUNK_OVERHEAD), EGoodAllocatedCell, EDougLeaAllocator); // Introduce DL allocated buffer to the walk function 
+			TLinAddr addr = CHUNK2MEM(q);
+			TInt size = sz - CHUNK_OVERHEAD;
+			if (iAllocatorType == EUdebHybridHeap)
+				{
+				size -= 8;
+				addr += 8;
+				}
+			shouldContinue = (*aCallbackFn)(*this, aContext, EDlaAllocation, addr, size);
+			if (!shouldContinue) return KErrNone;
+			}
+		// This is q = NEXT_CHUNK(q) expanded
+		q = q + sz;
+		}
+	return KErrNone;
+	}
+
+TInt RAllocatorHelper::TreeWalk(TUint32 aSlabRoot, TInt aSlabType, TWalkFunc3 aCallbackFn, TAny* aContext, TBool& shouldContinue)
+	{
+	const TSlabType type = (TSlabType)aSlabType;
+
+	TUint32 s = 0;
+	TInt err = ReadWord(aSlabRoot, s);
+	if (err) return err;
+	//slab* s = *root;
+	if (!s)
+		return KErrNone;
+	
+	for (;;)
+		{
+		//slab* c;
+		//while ((c = s->iChild1) != 0)
+		//	s = c;		// walk down left side to end
+		TUint32 c;
+		for(;;)
+			{
+			err = ReadWord(s + KSlabChild1Offset, c);
+			if (err) return err;
+			if (c == 0) break;
+			else s = c;
+			}
+		for (;;)
+			{
+			//TODOf(s, i, wi);
+			//TODO __HEAP_CORRUPTED_TEST_STATIC
+			TUint32 h;
+			err = ReadWord(s, h); // = aSlab->iHeader;
+			if (err) return err;
+			TUint32 size = (h&0x0003f000)>>12; //SlabHeaderSize(h);
+			TUint debugheadersize = 0;
+			if (iAllocatorType == EUdebHybridHeap) debugheadersize = 8;
+			TUint32 usedCount = (((h&0x0ffc0000)>>18) + 4) / size; // (SlabHeaderUsedm4(h) + 4) / size;
+			switch (type)
+				{
+				case ESlabFullInfo:
+					{
+					TUint32 count = usedCount;
+					TUint32 i = 0;
+					while ( i < count )
+						{
+						TUint32 addr = s + KSlabPayloadOffset + i*size; //&aSlab->iPayload[i*size];
+						shouldContinue = (*aCallbackFn)(*this, aContext, ESlabAllocation, addr + debugheadersize, size - debugheadersize);
+						if (!shouldContinue) return KErrNone;
+						i++;
+						}
+					break;
+					}
+				case ESlabPartialInfo:
+					{
+					//TODO __HEAP_CORRUPTED_TEST_STATIC
+					TUint32 count = KMaxSlabPayload / size;
+					TUint32 freeOffset = (h & 0xff) << 2;
+					if (freeOffset == 0)
+						{
+						// TODO Shouldn't happen for a slab on the partial list
+						}
+					memset(iTempSlabBitmap, 1, KTempBitmapSize); // Everything defaults to in use
+					TUint wildernessCount = count - usedCount;
+					while (freeOffset)
+						{
+						wildernessCount--;
+						TInt idx = (freeOffset-KSlabPayloadOffset)/size;
+						LOG("iTempSlabBitmap freeOffset %d index %d", freeOffset, idx);
+						iTempSlabBitmap[idx] = 0; // Mark it as free
+
+						TUint32 addr = s + freeOffset;
+						TUint8 nextCell = 0;
+						err = ReadByte(addr, nextCell);
+						if (err) return err;
+						freeOffset = ((TUint32)nextCell) << 2;
+						}
+					memset(iTempSlabBitmap + count - wildernessCount, 0, wildernessCount); // Mark the wilderness as free
+					for (TInt i = 0; i < count; i++)
+						{
+						TLinAddr addr = s + KSlabPayloadOffset + i*size;
+						if (iTempSlabBitmap[i])
+							{
+							// In use
+							shouldContinue = (*aCallbackFn)(*this, aContext, ESlabAllocation, addr + debugheadersize, size - debugheadersize);
+							}
+						else
+							{
+							// Free
+							shouldContinue = (*aCallbackFn)(*this, aContext, ESlabFreeCell, addr, size);
+							}
+						if (!shouldContinue) return KErrNone;
+						}
+					break;
+					}
+				case ESlabEmptyInfo:
+					{
+					// Check which slabs of this page are empty
+					TUint32 pageAddr = ROUND_DOWN(s, KPageSize);
+					TUint32 headerForPage = 0;
+					err = ReadWord(pageAddr, headerForPage);
+					if (err) return err;
+					TUint32 slabHeaderPageMap = (headerForPage & 0x00000f00)>>8; // SlabHeaderPagemap(unsigned h)
+					for (TInt slabIdx = 0; slabIdx < 4; slabIdx++)
+						{
+						if (slabHeaderPageMap & (1<<slabIdx))
+							{
+							TUint32 addr = pageAddr + SLABSIZE*slabIdx + KSlabPayloadOffset; //&aSlab->iPayload[i*size];
+							shouldContinue = (*aCallbackFn)(*this, aContext, ESlabFreeSlab, addr, KMaxSlabPayload);
+							if (!shouldContinue) return KErrNone;
+							}
+						}
+					break;
+					}
+				}
+
+			//c = s->iChild2;
+			err = ReadWord(s + KSlabChild2Offset, c);
+			if (err) return err;
+
+			if (c)
+				{	// one step down right side, now try and walk down left
+				s = c;
+				break;
+				}
+			for (;;)
+				{	// loop to walk up right side
+				TUint32 pp = 0;
+				err = ReadWord(s + KSlabParentOffset, pp);
+				if (err) return err;
+				//slab** pp = s->iParent;
+				if (pp == aSlabRoot)
+					return KErrNone;
+#define SlabFor(x) ROUND_DOWN(x, SLABSIZE)
+				s = SlabFor(pp);
+				//if (pp == &s->iChild1)
+				if (pp == s + KSlabChild1Offset)
+					break;
+				}
+			}
+		}
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::SizeForCellType(TExtendedCellType aType)
+	{
+	if (aType & EBadnessMask) return KErrArgument;
+	if (aType == EAllocationMask) return AllocatedSize();
+
+	if (iAllocatorType == EUdebOldRHeap || iAllocatorType == EUrelOldRHeap)
+		{
+		switch (aType)
+			{
+			case EHeapAllocation:
+				return AllocatedSize();
+			case EHeapFreeCell:
+			case EFreeMask:
+				return CommittedFreeSpace();
+			default:
+				return KErrNotSupported;
+			}
+		}
+	else if (iAllocatorType == EUrelHybridHeap || iAllocatorType == EUdebHybridHeap)
+		{
+		TInt err = CheckValid(EHybridStats);
+		if (err) return err;
+
+		switch (aType)
+			{
+			case EHeapAllocation:
+			case EHeapFreeCell:
+				return KErrNotSupported;
+			case EDlaAllocation:
+				return iInfo->iDlaAllocsSize;
+			case EPageAllocation:
+				return iInfo->iPageAllocsSize;
+			case ESlabAllocation:
+				return iInfo->iSlabAllocsSize;
+			case EDlaFreeCell:
+				return iInfo->iDlaFreeSize;
+			case ESlabFreeCell:
+				return iInfo->iSlabFreeCellSize;
+			case ESlabFreeSlab:
+				return iInfo->iSlabFreeSlabSize;
+			case EFreeMask:
+				// Note this isn't the same as asking for CommittedFreeSpace(). SizeForCellType(EFreeMask) may include decommitted pages that lie inside a free cell
+				return iInfo->iDlaFreeSize + iInfo->iSlabFreeCellSize + iInfo->iSlabFreeSlabSize;
+			default:
+				return KErrNotSupported;
+			}
+		}
+	else
+		{
+		return KErrNotSupported;
+		}
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::CountForCellType(TExtendedCellType aType)
+	{
+	if (aType & EBadnessMask) return KErrArgument;
+	if (aType == EAllocationMask) return AllocationCount();
+
+	if (iAllocatorType == EUdebOldRHeap || iAllocatorType == EUrelOldRHeap)
+		{
+		switch (aType)
+			{
+			case EHeapAllocation:
+				return AllocationCount();
+			case EHeapFreeCell:
+			case EFreeMask:
+				{
+				TInt err = CheckValid(ECommittedFreeSpace);
+				if (err) return err;
+				return iInfo->iHeapFreeCellCount;
+				}
+			default:
+				return KErrNotSupported;
+			}
+		}
+	else if (iAllocatorType == EUrelHybridHeap || iAllocatorType == EUdebHybridHeap)
+		{
+		TInt err = CheckValid(EHybridStats);
+		if (err) return err;
+
+		switch (aType)
+			{
+			case EHeapAllocation:
+			case EHeapFreeCell:
+				return KErrNotSupported;
+			case EDlaAllocation:
+				return iInfo->iDlaAllocsCount;
+			case EPageAllocation:
+				return iInfo->iPageAllocsCount;
+			case ESlabAllocation:
+				return iInfo->iSlabAllocsCount;
+			case EDlaFreeCell:
+				return iInfo->iDlaFreeCount;
+			case ESlabFreeCell:
+				return iInfo->iSlabFreeCellCount;
+			case ESlabFreeSlab:
+				return iInfo->iSlabFreeSlabCount;
+			case EFreeMask:
+				// This isn't a hugely meaningful value, but if that's what they asked for...
+				return iInfo->iDlaFreeCount + iInfo->iSlabFreeCellCount + iInfo->iSlabFreeSlabCount;
+			default:
+				return KErrNotSupported;
+			}
+		}
+	else
+		{
+		return KErrNotSupported;
+		}
+	}
+
+HUEXPORT_C TBool LtkUtils::RAllocatorHelper::AllocatorIsUdeb() const
+	{
+	return iAllocatorType == EUdebOldRHeap || iAllocatorType == EUdebHybridHeap;
+	}
+
+
+HUEXPORT_C const TDesC& LtkUtils::RAllocatorHelper::Description() const
+	{
+	_LIT(KRHeap, "RHeap");
+	_LIT(KRHybridHeap, "RHybridHeap");
+	_LIT(KUnknown, "Unknown");
+	switch (iAllocatorType)
+		{
+		case EUrelOldRHeap:
+		case EUdebOldRHeap:
+			return KRHeap;
+		case EUrelHybridHeap:
+		case EUdebHybridHeap:
+			return KRHybridHeap;
+		case EAllocator:
+		case EUnknown:
+		default:
+			return KUnknown;
+		}
+	}
+
+#ifdef __KERNEL_MODE__
+
+DChunk* LtkUtils::RAllocatorHelper::OpenUnderlyingChunk()
+	{
+	// Enter and leave in CS and with no locks held. On exit the returned DChunk has been Open()ed.
+	TInt err = iChunk->Open();
+	if (err) return NULL;
+	return iChunk;
+	}
+
+DChunk* LtkUtils::RKernelSideAllocatorHelper::OpenUnderlyingChunk()
+	{
+	if (iAllocatorType != EUrelOldRHeap && iAllocatorType != EUdebOldRHeap && iAllocatorType != EUrelHybridHeap && iAllocatorType != EUdebHybridHeap) return NULL;
+	// Note RKernelSideAllocatorHelper doesn't use or access RAllocatorHelper::iChunk, because we figure out the chunk handle in a different way.
+	// It is for this reason that iChunk is private, to remove temptation
+	
+	// Enter and leave in CS and with no locks held. On exit the returned DChunk has been Open()ed.
+	TUint32 chunkHandle = 0;
+	TInt err = ReadData(iAllocatorAddress + _FOFF(RHackHeap, iChunkHandle), &chunkHandle, sizeof(TUint32));
+	if (err) return NULL;
+
+	NKern::LockSystem();
+	DChunk* result = (DChunk*)Kern::ObjectFromHandle(iThread, chunkHandle, EChunk);
+	if (result && result->Open() != KErrNone)
+		{
+		result = NULL;
+		}
+	NKern::UnlockSystem();
+	return result;
+	}
+
+LtkUtils::RAllocatorHelper::TType LtkUtils::RAllocatorHelper::GetType() const
+	{
+	switch (iAllocatorType)
+		{
+		case EUrelOldRHeap:
+		case EUdebOldRHeap:
+			return ETypeRHeap;
+		case EUrelHybridHeap:
+		case EUdebHybridHeap:
+			return ETypeRHybridHeap;
+		case EAllocator:
+		case EUnknown:
+		default:
+			return ETypeUnknown;
+		}
+	}
+
+#else
+
+TInt LtkUtils::RAllocatorHelper::EuserIsUdeb()
+	{
+	TAny* buf = User::Alloc(4096);
+	if (!buf) return KErrNoMemory;
+	RAllocator* dummyHeap = UserHeap::FixedHeap(buf, 4096, 4, ETrue);
+	if (!dummyHeap) return KErrNoMemory; // Don't think this can happen
+
+	dummyHeap->__DbgSetAllocFail(RAllocator::EFailNext, 1);
+	TAny* ptr = dummyHeap->Alloc(4);
+	// Because we specified singleThreaded=ETrue we can allow dummyHeap to just go out of scope here
+	User::Free(buf);
+
+	if (ptr)
+		{
+		// Clearly the __DbgSetAllocFail had no effect so we must be urel
+		// We don't need to free ptr because it came from the dummy heap
+		return EFalse;
+		}
+	else
+		{
+		return ETrue;
+		}
+	}
+
+#ifndef STANDALONE_ALLOCHELPER
+
+#include <fshell/ltkutils.h>
+HUEXPORT_C void LtkUtils::MakeHeapCellInvisible(TAny* aCell)
+	{
+	RAllocatorHelper helper;
+	TInt err = helper.Open(&User::Allocator());
+	if (err == KErrNone)
+		{
+		helper.SetCellNestingLevel(aCell, -1);
+		helper.Close();
+		}
+	}
+#endif // STANDALONE_ALLOCHELPER
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/hexdump.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,115 @@
+// hexdump.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ltkutils.h>
+#include <e32base.h>
+#include <fshell/iocli.h>
+#include <e32debug.h>
+
+static const TInt KLineSize = 16;
+// 00000000:  00 01 02 03 04 05 06 07 08  09 0A 0B 0C 0D 0E 0F  ................<CR><LF>
+// So line len is 8 + 3 + (3 * lineSize) + 1 + 1 + lineSize + 2
+static const TInt KTotalLen = 8 + 3 + (3 * KLineSize) + 1 + 1 + KLineSize + 2;
+
+void HexDumpLine(const TDesC8& aBuf, TDes& lineBuf, TInt aOffset)
+	{
+	TBuf<KLineSize> ascii;
+	lineBuf.NumFixedWidthUC(aOffset, EHex, 8);
+	_LIT(KColon, ":  ");
+	lineBuf.Append(KColon);
+	for (TInt i = 0; i < KLineSize; i++)
+		{
+		if (i < aBuf.Length())
+			{
+			TUint8 ch = aBuf[i];
+			lineBuf.AppendNumFixedWidthUC(ch, EHex, 2);
+			lineBuf.Append(' ');
+			if (ch < 32 || ch >= 128) ch = '.';
+			ascii.Append(ch);
+			}
+		else
+			{
+			_LIT(KFiller, "   ");
+			lineBuf.Append(KFiller);
+			}
+		if (i == 7) lineBuf.Append(' '); // The space between the two groups of 8
+		}
+	lineBuf.Append(' ');
+	lineBuf.Append(ascii);
+	lineBuf.Append('\r');
+	lineBuf.Append('\n');
+	}
+
+EXPORT_C HBufC* LtkUtils::HexDumpL(const TDesC8& aBuf)
+	{
+	TInt numLines = (aBuf.Length() + KLineSize-1) / KLineSize;
+	HBufC* result = HBufC::NewLC(numLines * KTotalLen);
+	TPtr resultPtr = result->Des();
+	for (TInt i = 0; i < aBuf.Length(); i += KLineSize)
+		{
+		TPtrC8 line = aBuf.Mid(i, Min(KLineSize, aBuf.Length()-i));
+		TPtr wptr((TUint16*)resultPtr.Ptr() + resultPtr.Length(), KTotalLen);
+		HexDumpLine(line, wptr, i);
+		resultPtr.SetLength(resultPtr.Length() + wptr.Length()); // MidTPtr doesn't update length of original
+		}
+	CleanupStack::Pop(result);
+	return result;
+	}
+
+EXPORT_C void LtkUtils::HexDumpToOutput(const TDesC8& aBuf, RIoWriteHandle& aHandle)
+	{
+	TInt offset = 0;
+	LtkUtils::HexDumpToOutput(aBuf, aHandle, offset);
+	}
+
+EXPORT_C void LtkUtils::HexDumpToOutput(const TDesC8& aBuf, RIoWriteHandle& aHandle, TInt& aOffset)
+	{
+	TBuf<KTotalLen> lineBuf;
+	const TInt len = aBuf.Length();
+	for (TInt i = 0; i < len; i += KLineSize)
+		{
+		TPtrC8 line = aBuf.Mid(i, Min(KLineSize, len-i));
+		HexDumpLine(line, lineBuf, aOffset+i);
+		aHandle.Write(lineBuf);
+		}
+	aOffset += len;
+	}
+
+EXPORT_C void LtkUtils::HexDumpToRDebug(const TDesC8& aBuf)
+	{
+	TInt offset = 0;
+	HexDumpToRDebug(aBuf, offset);
+	}
+
+EXPORT_C void LtkUtils::HexDumpToRDebug(const TDesC8& aBuf, TInt& aOffset)
+	{
+	TBuf<KTotalLen> lineBuf;
+	const TInt len = aBuf.Length();
+	for (TInt i = 0; i < len; i += KLineSize)
+		{
+		TPtrC8 line = aBuf.Mid(i, Min(KLineSize, len-i));
+		HexDumpLine(line, lineBuf, aOffset+i);
+		RDebug::RawPrint(lineBuf);
+		}
+	aOffset += len;
+	}
+
+EXPORT_C void LtkUtils::RawPrint(const TDesC8 &aDes)
+	{
+	TPtrC8 rem(aDes);
+	TBuf<256> buf;
+	while (rem.Length())
+		{
+		buf.Copy(rem.Left(256));
+		RDebug::RawPrint(buf);
+		rem.Set(rem.Mid(buf.Length()));
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/keyinject.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,75 @@
+// keyinject.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ltkutils.h>
+#include <e32event.h>
+#include <e32keys.h>
+#include <e32svr.h>
+
+EXPORT_C TInt LtkUtils::InjectRawKeyEvent(TInt aScanCode, TInt aModifiers, TInt /*aRepeatCount*/)
+	{
+	TInt err = KErrNone;
+	TRawEvent ev;
+
+	// Check for modifiers
+	if (!err && (aModifiers & EModifierCtrl))
+		{
+		ev.Set(TRawEvent::EKeyDown, EStdKeyLeftCtrl);
+		err = UserSvr::AddEvent(ev);
+		}
+	if (!err && (aModifiers & EModifierShift))
+		{
+		ev.Set(TRawEvent::EKeyDown, EStdKeyLeftShift);
+		err = UserSvr::AddEvent(ev);
+		}
+
+	// send the key down and up
+	if (!err)
+		{
+		ev.Set(TRawEvent::EKeyDown, aScanCode);
+		err = UserSvr::AddEvent(ev);
+		}
+	if (!err)
+		{
+		ev.Set(TRawEvent::EKeyUp, aScanCode);
+		err = UserSvr::AddEvent(ev);			
+		}
+
+	// generate repeats if necessary
+	/*
+	for (TInt i = 0; i < aRepeatCount; ii++)
+		{
+		ev.Set(TRawEvent::EKeyDown, aScanCode);
+		error = UserSvr::AddEvent(ev);
+		if (error == KErrNone)
+			{
+			ev.Set(TRawEvent::EKeyUp, sc);
+			error = UserSvr::AddEvent(ev);			
+			}
+		if (error != KErrNone)
+			break;			
+		}
+	*/
+
+	// Reset modifiers
+	if (!err && (aModifiers & EModifierShift))
+		{
+		ev.Set(TRawEvent::EKeyUp, EStdKeyLeftShift);
+		err = UserSvr::AddEvent(ev);
+		}
+	if (!err && (aModifiers & EModifierCtrl))
+		{
+		ev.Set(TRawEvent::EKeyUp, EStdKeyLeftCtrl);
+		err = UserSvr::AddEvent(ev);
+		}
+
+	return err;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/ltkhal.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,343 @@
+// ltkhal.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ltkhal.h>
+#include <fshell/descriptorutils.h>
+#include <HAL.h>
+
+LtkUtils::CHalAttribute::CHalAttribute(TInt aAttribute, TInt aDeviceNumber, TInt aValue, TInt aError, const TDesC& aAttributeName, HBufC* aDescription)
+	: iAttribute(aAttribute), iDeviceNumber(aDeviceNumber), iValue(aValue), iError(aError), iAttributeName(aAttributeName), iDescription(aDescription)
+	{
+	}
+
+EXPORT_C LtkUtils::CHalAttribute::~CHalAttribute()
+	{
+	delete iDescription;
+	}
+
+const LtkUtils::SLitC KHalNames[] =
+	{
+	DESC("EManufacturer"),
+	DESC("EManufacturerHardwareRev"),
+	DESC("EManufacturerSoftwareRev"),
+	DESC("EManufacturerSoftwareBuild"),
+	DESC("EModel"),
+	DESC("EMachineUid"),
+	DESC("EDeviceFamily"),
+	DESC("EDeviceFamilyRev"),
+	DESC("ECPU"),
+	DESC("ECPUArch"),
+	DESC("ECPUABI"),
+	DESC("ECPUSpeed"),
+	DESC("ESystemStartupReason"),
+	DESC("ESystemException"),
+	DESC("ESystemTickPeriod"),
+	DESC("EMemoryRAM"),
+	DESC("EMemoryRAMFree"),
+	DESC("EMemoryROM"),
+	DESC("EMemoryPageSize"),
+	DESC("EPowerGood"),
+	DESC("EPowerBatteryStatus"),
+	DESC("EPowerBackup"),
+	DESC("EPowerBackupStatus"),
+	DESC("EPowerExternal"),
+	DESC("EKeyboard"),
+	DESC("EKeyboardDeviceKeys"),
+	DESC("EKeyboardAppKeys"),
+	DESC("EKeyboardClick"),
+	DESC("EKeyboardClickState"),
+	DESC("EKeyboardClickVolume"),
+	DESC("EKeyboardClickVolumeMax"),
+	DESC("EDisplayXPixels"),
+	DESC("EDisplayYPixels"),
+	DESC("EDisplayXTwips"),
+	DESC("EDisplayYTwips"),
+	DESC("EDisplayColors"),
+	DESC("EDisplayState"),
+	DESC("EDisplayContrast"),
+	DESC("EDisplayContrastMax"),
+	DESC("EBacklight"),
+	DESC("EBacklightState"),
+	DESC("EPen"),
+	DESC("EPenX"),
+	DESC("EPenY"),
+	DESC("EPenDisplayOn"),
+	DESC("EPenClick"),
+	DESC("EPenClickState"),
+	DESC("EPenClickVolume"),
+	DESC("EPenClickVolumeMax"),
+	DESC("EMouse"),
+	DESC("EMouseX"),
+	DESC("EMouseY"),
+	DESC("EMouseState"),
+	DESC("EMouseSpeed"),
+	DESC("EMouseAcceleration"),
+	DESC("EMouseButtons"),
+	DESC("EMouseButtonState"),
+	DESC("ECaseState"),
+	DESC("ECaseSwitch"),
+	DESC("ECaseSwitchDisplayOn"),
+	DESC("ECaseSwitchDisplayOff"),
+	DESC("ELEDs"),
+	DESC("ELEDmask"),
+	DESC("EIntegratedPhone"),
+	DESC("EDisplayBrightness"),
+	DESC("EDisplayBrightnessMax"),
+	DESC("EKeyboardBacklightState"),
+	DESC("EAccessoryPower"),
+	DESC("ELanguageIndex"),
+	DESC("EKeyboardIndex"),
+	DESC("EMaxRAMDriveSize"),
+	DESC("EKeyboardState"),
+	DESC("ESystemDrive"),
+	DESC("EPenState"),
+	DESC("EDisplayIsMono"),
+	DESC("EDisplayIsPalettized"),
+	DESC("EDisplayBitsPerPixel"),
+	DESC("EDisplayNumModes"),
+	DESC("EDisplayMemoryAddress"),
+	DESC("EDisplayOffsetToFirstPixel"),
+	DESC("EDisplayOffsetBetweenLines"),
+	DESC("EDisplayPaletteEntry"),
+	DESC("EDisplayIsPixelOrderRGB"),
+	DESC("EDisplayIsPixelOrderLandscape"),
+	DESC("EDisplayMode"),
+	DESC("ESwitches"),
+	DESC("EDebugPort"),
+	DESC("ELocaleLoaded"),
+	DESC("EClipboardDrive"),
+	DESC("ECustomRestart"),
+	DESC("ECustomRestartReason"),
+	DESC("EDisplayNumberOfScreens"),
+	DESC("ENanoTickPeriod"),
+	DESC("EFastCounterFrequency"),
+	DESC("EFastCounterCountsUp"),
+	DESC("EPointer3D"),
+	DESC("EPointer3DZ/EPointer3DMaxProximity"),
+	DESC("EPointer3DThetaSupported"),
+	DESC("EPointer3DPhiSupported"),
+	DESC("EPointer3DRotationSupported"),
+	DESC("EPointer3DPressureSupported"),
+	DESC("EHardwareFloatingPoint"),
+	DESC("ETimeNonSecureOffset"),
+	DESC("EPersistStartupModeKernel"),
+	DESC("EMaximumCustomRestartReasons"),
+	DESC("EMaximumRestartStartupModes"),
+	DESC("ECustomResourceDrive"),
+	DESC("EPointer3DProximityStep"), 
+	DESC("EPointerMaxPointers"),
+	DESC("EPointerNumberOfPointers"),
+	DESC("EPointer3DMaxPressure"),
+	DESC("EPointer3DPressureStep"),
+	DESC("EPointer3DEnterHighPressureThreshold"),
+	DESC("EPointer3DExitHighPressureThreshold"),
+	DESC("EPointer3DEnterCloseProximityThreshold"),
+	DESC("EPointer3DExitCloseProximityThreshold"),
+	DESC("EDisplayMemoryHandle"),
+	DESC("ESerialNumber"),
+	DESC("ECpuProfilingDefaultInterruptBase"),
+	};
+const TInt KNumHalNames = sizeof(KHalNames) / sizeof(LtkUtils::SLitC);
+
+const TDesC* Stringify(TInt aHalAttribute, TInt aValue)
+	{
+	_LIT(KManufacturerEricsson, "Ericsson");
+	_LIT(KManufacturerMotorola, "Motorola");
+	_LIT(KManufacturerNokia, "Nokia");
+	_LIT(KManufacturerPanasonic, "Panasonic");
+	_LIT(KManufacturerPsion, "Psion");
+	_LIT(KManufacturerIntel, "Intel");
+	_LIT(KManufacturerCogent, "Cogent");
+	_LIT(KManufacturerCirrus, "Cirrus");
+	_LIT(KManufacturerLinkup, "Linkup");
+	_LIT(KCpuArm, "ARM");
+	_LIT(KCpuMCore, "MCore");
+	_LIT(KCpuX86, "x86");
+	_LIT(KCpuAbiArm4, "ARM4");
+	_LIT(KCpuAbiThumb, "THUMB");
+	_LIT(KCpuAbiArmI, "ARMI");
+	_LIT(KCpuAbiMCore, "MCore");
+	_LIT(KCpuAbiMsvc, "MSVC");
+	_LIT(KCpuAbiArm5T, "ARM5T");
+	_LIT(KCpuAbiX86, "x86");
+	_LIT(KStartupReasonCold, "Cold");
+	_LIT(KStartupReasonWarm, "Warm");
+	_LIT(KStartupReasonFault, "Fault");
+	_LIT(KUp, "Up");
+	_LIT(KDown, "Down");
+
+	switch (aHalAttribute)
+		{
+		case HALData::EManufacturer:
+			switch (aValue)
+				{
+				case HALData::EManufacturer_Ericsson:
+					return &KManufacturerEricsson;
+				case HALData::EManufacturer_Motorola:
+					return &KManufacturerMotorola;
+				case HALData::EManufacturer_Nokia:
+					return &KManufacturerNokia;
+				case HALData::EManufacturer_Panasonic:
+					return &KManufacturerPanasonic;
+				case HALData::EManufacturer_Psion:
+					return &KManufacturerPsion;	
+				case HALData::EManufacturer_Intel:
+					return &KManufacturerIntel;
+				case HALData::EManufacturer_Cogent:
+					return &KManufacturerCogent;
+				case HALData::EManufacturer_Cirrus:
+					return &KManufacturerCirrus;
+				case HALData::EManufacturer_Linkup:
+					return &KManufacturerLinkup;
+				default:
+					break;
+				}
+			break;
+		case HALData::ECPU:
+			switch (aValue)
+				{
+				case HALData::ECPU_ARM:
+					return &KCpuArm;
+				case HALData::ECPU_MCORE:
+					return &KCpuMCore;
+				case HALData::ECPU_X86:
+					return &KCpuX86;
+				default:
+					break;
+				}
+			break;
+		case HALData::ECPUABI:
+			switch (aValue)
+				{
+				case HALData::ECPUABI_ARM4:
+					return &KCpuAbiArm4;
+				case HALData::ECPUABI_ARMI:
+					return &KCpuAbiMCore;
+				case HALData::ECPUABI_THUMB:
+					return &KCpuAbiThumb;
+				case HALData::ECPUABI_MCORE:
+					return &KCpuAbiArmI;
+				case HALData::ECPUABI_MSVC:
+					return &KCpuAbiMsvc;
+				case HALData::ECPUABI_ARM5T:
+					return &KCpuAbiArm5T;
+				case HALData::ECPUABI_X86:
+					return &KCpuAbiX86;
+				default:
+					break;
+				}
+			break;
+		case HALData::ESystemStartupReason:
+			switch (aValue)
+				{
+				case HALData::ESystemStartupReason_Cold:
+					return &KStartupReasonCold;
+				case HALData::ESystemStartupReason_Warm:
+					return &KStartupReasonWarm;
+				case HALData::ESystemStartupReason_Fault:
+					return &KStartupReasonFault;
+				default:
+					break;
+				}
+			break;
+		case HALData::EFastCounterCountsUp:
+			if (aValue)
+				{
+				return &KUp;
+				}
+			else
+				{
+				return &KDown;
+				}
+		default:
+			break;
+		}
+
+	return NULL;
+	}
+
+
+
+
+EXPORT_C void LtkUtils::GetHalInfoL(RPointerArray<CHalAttribute>& aAttributes)
+	{
+	// Use GetAll to find out how many attributes we have
+	aAttributes.ResetAndDestroy();
+	HAL::SEntry* ents = NULL;
+	TInt numEntries = 0;
+	User::LeaveIfError(HAL::GetAll(numEntries, ents));
+	delete ents;
+
+	for (TInt i = 0; i < numEntries; i++)
+		{
+		// Now re-get them individually so we can get the error field
+		CHalAttribute* attrib = GetHalInfoL(i);
+		CleanupStack::PushL(attrib);
+		aAttributes.AppendL(attrib);
+		CleanupStack::Pop(attrib);
+		}
+	}
+
+EXPORT_C LtkUtils::CHalAttribute* LtkUtils::GetHalInfoL(TInt aAttribute)
+	{
+	return GetHalInfoL(0, aAttribute);
+	}
+
+EXPORT_C LtkUtils::CHalAttribute* LtkUtils::GetHalInfoL(TInt aDeviceNumber, TInt aAttribute)
+	{
+	TInt val = 0;
+	TInt err = HAL::Get((HALData::TAttribute)aAttribute, val);
+	CHalAttribute* attrib = NULL;
+	if (err == KErrNone)
+		{
+		attrib = GetHalInfoForValueL(aDeviceNumber, aAttribute, val);
+		}
+	else
+		{
+		const TDesC& attribName = aAttribute >= KNumHalNames ? KNullDesC() : KHalNames[aAttribute];
+		RLtkBuf buf;
+		buf.AppendFormatL(_L("HAL::Get() returned error %d"), err);
+		HBufC* bufc = buf.ToHBuf();
+		CleanupStack::PushL(bufc);
+		attrib = new(ELeave) CHalAttribute(aAttribute, aDeviceNumber, val, err, attribName, bufc);
+		CleanupStack::Pop(bufc);
+		}
+	return attrib;
+	}
+
+EXPORT_C LtkUtils::CHalAttribute* LtkUtils::GetHalInfoForValueL(TInt aDeviceNumber, TInt aAttribute, TInt aValue)
+	{
+	const TDesC& attribName = aAttribute >= KNumHalNames ? KNullDesC() : KHalNames[aAttribute];
+	RLtkBuf buf;
+	CleanupClosePushL(buf);
+	const TDesC* string = Stringify(aAttribute, aValue);
+	if (string) buf.AppendL(*string);
+	else
+		{
+		if ((aAttribute == HAL::ESystemDrive || aAttribute == HAL::EClipboardDrive) && aValue == -1)
+			{
+			// Emulator returns -1 for system drive...
+			buf.AppendL(_L("Unknown"));
+			}
+		}
+	if (buf.Length())
+		{
+		buf.AppendFormatL(_L(" (%d/0x%08x)"), aValue, aValue);
+		}
+	else
+		{
+		buf.AppendFormatL(_L("%d (0x%08x)"), aValue, aValue);
+		}
+
+	CHalAttribute* attrib = new(ELeave) CHalAttribute(aAttribute, aDeviceNumber, aValue, KErrNone, attribName, buf.GetHBuf());
+	CleanupStack::Pop(&buf); // attrib now owns its HBufC*
+	return attrib;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/mapfile.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,289 @@
+// mapfile.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/bsym.h>
+#include <fshell/ltkutils.h>
+#include "bsymtree.h"
+#include <fshell/descriptorutils.h>
+
+#include <fshell/iocli.h>
+using namespace LtkUtils;
+using namespace IoUtils;
+
+const TInt KSymbolGranularity = 256; // I have no idea...
+
+struct SSymbol
+	{
+	TUint iAddress;
+	TUint iLength;
+	HBufC8* iName;
+	};
+
+NONSHARABLE_CLASS(CMapFileImpl) : public CMapFile
+	{
+public:
+	CMapFileImpl();
+	~CMapFileImpl();
+	void ConstructL(RFs& aFs, const TDesC& aFileName);
+	void DoLookup(TUint32 aOffsetInCodeSeg, TDes& aResult);
+	RNode* DoCreateCompletionTreeL();
+
+private:
+	RArray<SSymbol> iSymbols;
+	};
+
+EXPORT_C CMapFile* CMapFile::NewL(RFs& aFs, const TDesC& aFileName)
+	{
+	CMapFileImpl* result = new (ELeave) CMapFileImpl;
+	CleanupStack::PushL(result);
+	//CleanupStack::PushL((CBase*)1); //DEBUG
+	result->ConstructL(aFs, aFileName);
+	//CleanupStack::Pop(); //DEBUG
+	CleanupStack::Pop(result);
+	return result;
+	}
+
+CMapFile::CMapFile()
+	{
+	}
+
+CMapFileImpl::CMapFileImpl()
+	: iSymbols(KSymbolGranularity, _FOFF(SSymbol, iAddress))
+	{
+	}
+
+CMapFileImpl::~CMapFileImpl()
+	{
+	const TInt count = iSymbols.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		delete iSymbols[i].iName;
+		}
+	iSymbols.Close();
+	}
+
+EXPORT_C CMapFile::~CMapFile()
+	{
+	iReadBuf.Close();
+	delete iFileName;
+	}
+
+#undef LeaveIfErr
+#define LeaveIfErr(args...) StaticLeaveIfErr(args)
+
+void CMapFileImpl::ConstructL(RFs& aFs, const TDesC& aFileName)
+	{
+	iFileName = aFileName.AllocL();
+	iReadBuf.CreateL(4096);
+	LeaveIfErr(iFile.Open(aFs, aFileName, EFileShareReadersOnly), _L("Couldn't open file %S"), &aFileName);
+
+	TPtrC8 line;
+	TBool rvct = EFalse;
+	_LIT8(KRvct, "ARM Linker, RVCT");
+	if (GetNextLine(line) && HasPrefix(line, KRvct)) rvct = ETrue;
+	TBool foundOffset = EFalse;
+	TInt linenum = 0; // for debugging
+
+	if (rvct)
+		{
+		TInt local = ETrue;
+		while (GetNextLine(line))
+			{
+			linenum++;
+			if (line.Length() == 0) continue;
+			_LIT8(KRVCTOffsetLine, "    Image$$ER_RO$$Base                       ");
+			if (!foundOffset)
+				{
+				if (HasPrefix(line, KRVCTOffsetLine))
+					{
+					TLex8 lex(line.Mid(KRVCTOffsetLine().Length()));
+					iTextOffset = HexLexL(lex);
+					foundOffset = ETrue;
+
+					// No go through any symbols we found before this, and correct their offsets
+					for (TInt i = 0; i < iSymbols.Count(); i++)
+						{
+						iSymbols[i].iAddress -= iTextOffset;
+						}
+					continue;
+					}
+				}
+
+			_LIT8(KGlobalSection, "    Global Symbols");
+			if (HasPrefix(line, KGlobalSection)) local = EFalse; // We've reached the global section, don't have to ignore so much stuff
+
+			SSymbol symbol;
+
+			// This is rather awkward, because there's no proper delimiting between symbol name and the next stuff
+			_LIT8(KSpaces, "   ");
+			if (line.Length() < 55) continue;
+			TInt foundSpaces = line.Mid(55).Find(KSpaces);
+			if (foundSpaces == KErrNotFound) continue;
+			TInt spp = 55 + foundSpaces - 10;
+			symbol.iName = line.Left(spp).AllocLC();
+			symbol.iName->Des().Trim();
+				
+			TLex8 lex(line);
+			lex.Inc(spp);
+			symbol.iAddress = HexLexL(lex) - iTextOffset;
+			lex.SkipSpace();
+			if (local)
+				{
+				// In local symbols section we have to worry about non-code stuff
+				_LIT8(KArm,   "ARM Code  ");
+				_LIT8(KThumb, "Thumb Code");
+				TPtrC8 type = lex.Remainder().Left(KThumb().Length());
+				if (type != KArm && type != KThumb)
+					{
+					CleanupStack::PopAndDestroy(symbol.iName);
+					continue;
+					}
+				}
+
+			lex.Inc(10); // Far enough to get over "ARM Code" or "Thumb Code"
+			lex.SkipSpace();
+			User::LeaveIfError(lex.Val(symbol.iLength));
+			if (symbol.iLength == 0)
+				{
+				CleanupStack::PopAndDestroy(symbol.iName);
+				continue; // todo thunks lie about their size...
+				}
+
+			User::LeaveIfError(iSymbols.Append(symbol));
+			CleanupStack::Pop(symbol.iName);
+			}
+		}
+	else
+		{
+		while (GetNextLine(line))
+			{
+			linenum++;
+			_LIT8(KGccTextOffsetLine, "Address of section .text set to ");
+			if (HasPrefix(line, KGccTextOffsetLine))
+				{
+				// GCCE style
+				TLex8 lex(line.Mid(KGccTextOffsetLine().Length()));
+				iTextOffset = HexLexL(lex);
+				continue;
+				}
+
+			_LIT8(KFin, ".fini");
+			if (line == KFin) break;
+			if (line.Length() < 16) continue;
+			TLex8 lex(line);
+			lex.Inc(16);
+			SSymbol symbol;
+			symbol.iLength = 4; // unless otherwise updated by the next symbol addr
+			TInt err = HexLex(lex, symbol.iAddress);
+			if (err) continue;
+			symbol.iAddress -= iTextOffset;
+			lex.SkipSpace();
+			if (lex.Offset() < 42) continue; // Code symbols have space up to column 42
+			symbol.iName = lex.Remainder().AllocLC();
+
+			User::LeaveIfError(iSymbols.Append(symbol));
+			CleanupStack::Pop(symbol.iName);
+			}
+		// GCCE doesn't even sort the symbols in its map file. Unbelievable! Or possibly even inconceivable!
+		iSymbols.SortUnsigned();
+		for (TInt i = 1; i < iSymbols.Count(); i++)
+			{
+			SSymbol& prevSymbol = iSymbols[i - 1];
+			prevSymbol.iLength = iSymbols[i].iAddress - prevSymbol.iAddress;
+			}
+		}
+	iFile.Close();
+	iReadBuf.Close();
+	}
+
+TBool CMapFile::GetNextLine(TPtrC8& aPtr)
+	{
+	_LIT8(KNewline, "\r\n");
+	iReadBuf.Delete(0, aPtr.Length());
+	if (HasPrefix(iReadBuf, KNewline)) iReadBuf.Delete(0, KNewline().Length());
+
+	TInt newline = iReadBuf.Find(KNewline);
+	if (newline != KErrNotFound)
+		{
+		aPtr.Set(iReadBuf.Left(newline));
+		return ETrue;
+		}
+	// Otherwise need to try reading some more from file
+	TPtr8 restOfDesc((TUint8*)iReadBuf.Ptr() + iReadBuf.Size(), 0, iReadBuf.MaxSize() - iReadBuf.Size());
+	TInt err = iFile.Read(restOfDesc);
+	if (err) restOfDesc.Zero();
+	iReadBuf.SetLength(iReadBuf.Length() + restOfDesc.Length());
+	
+	// Now re-try looking for newline
+	newline = iReadBuf.Find(KNewline);
+	if (newline != KErrNotFound)
+		{
+		aPtr.Set(iReadBuf.Left(newline + KNewline().Length()));
+		return ETrue;
+		}
+
+	// No more newlines, just return whatever's left in the buffer
+	aPtr.Set(iReadBuf);
+	return aPtr.Length() != 0; // And return whether it's worth having
+	}
+
+EXPORT_C void CMapFile::Lookup(TUint32 aOffsetInCodeSeg, TDes& aResult)
+	{
+	//TUint32 offset = aOffsetInCodeSeg & 0xFFFFFFFE; // Mask bottom bit as it just indicates thumb mode
+	CMapFileImpl* impl = static_cast<CMapFileImpl*>(this); // We know we're actually a CMapFileImpl
+	impl->DoLookup(aOffsetInCodeSeg, aResult);
+	}
+
+void CMapFileImpl::DoLookup(TUint32 aOffsetInCodeSeg, TDes& aResult)
+	{
+	TInt pos = 0;
+	SSymbol dummy; dummy.iAddress = aOffsetInCodeSeg;
+	TBool found = iSymbols.FindInUnsignedKeyOrder(dummy, pos) == KErrNone;
+	if (!found && pos != 0) pos--;
+
+	aResult.Zero();
+	const SSymbol& symbol = iSymbols[pos];
+	if (aOffsetInCodeSeg >= symbol.iAddress && aOffsetInCodeSeg < symbol.iAddress + symbol.iLength)
+		{
+		aResult.Copy(*symbol.iName);
+		aResult.AppendFormat(_L(" + 0x%x"), aOffsetInCodeSeg - symbol.iAddress);
+		}
+	}
+
+EXPORT_C void CMapFile::GetFileNameL(TDes& aFileName) const
+	{
+	aFileName.Copy(*iFileName);
+	}
+
+RNode* CMapFile::CreateCompletionTreeL()
+	{
+	CMapFileImpl* impl = static_cast<CMapFileImpl*>(this); // We know we're actually a CMapFileImpl
+	return impl->DoCreateCompletionTreeL();
+	}
+
+RNode* CMapFileImpl::DoCreateCompletionTreeL()
+	{
+	RNode* result = RNode::NewL();
+	CleanupDeletePushL(result);
+
+	RLtkBuf tempBuf;
+	tempBuf.CreateLC(256);
+	for (TInt i = 0; i < iSymbols.Count(); i++)
+		{
+		tempBuf.Zero();
+		tempBuf.AppendL(*iSymbols[i].iName);
+		tempBuf.ReserveExtraL(1);
+		result->InsertStringL(tempBuf.PtrZ(), iSymbols[i].iAddress);
+		}
+	CleanupStack::PopAndDestroy(&tempBuf);
+	CleanupStack::Pop(result);
+	return result;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/proxyallocatorhelper.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,116 @@
+// proxyallocatorhelper.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/heaputils.h>
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+__ASSERT_COMPILE(sizeof(LtkUtils::RProxyAllocatorHelper) == 11*4);
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+#include <fshell/memoryaccess.h>
+#endif
+
+EXPORT_C LtkUtils::RProxyAllocatorHelper::RProxyAllocatorHelper()
+	: RAllocatorHelper()
+	{
+	}
+
+EXPORT_C TInt LtkUtils::RProxyAllocatorHelper::Open(RMemoryAccess& aMem, TUint aThreadId)
+	{
+	iMemoryAccess = &aMem;
+	iThreadId = aThreadId;
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TUint8* allocatorAddress;
+	TInt err = iMemoryAccess->GetAllocatorAddress(iThreadId, allocatorAddress);
+	if (!err)
+		{
+		iAllocatorAddress = (TLinAddr)allocatorAddress;
+		TInt udeb = EuserIsUdeb();
+		if (udeb < 0) return udeb; // error
+		err = IdentifyAllocatorType(udeb);
+		}
+	return err;
+#else
+	return KErrNotSupported;
+#endif
+	}
+
+EXPORT_C TInt LtkUtils::RProxyAllocatorHelper::OpenChunkHeap(RMemoryAccess& aMem, TAny* aDChunkPtr)
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	iMemoryAccess = &aMem;
+
+	TChunkKernelInfo chunkInfo;
+	TPckg<TChunkKernelInfo> chunkInfoPckg(chunkInfo);
+	TInt err = iMemoryAccess->GetObjectInfo(EChunk, (TUint8*)aDChunkPtr, chunkInfoPckg);
+	if (err) return err;
+	RProcess process;
+	err = process.Open(chunkInfo.iControllingOwnerProcessId);
+	if (err == KErrNone)
+		{
+		TPckgBuf<TProcessKernelInfo> processInfo;
+		err = iMemoryAccess->GetObjectInfoByHandle(EProcess, RThread().Id(), process.Handle(), processInfo);
+		process.Close();
+		if (err == KErrNone)
+			{
+			iThreadId = processInfo().iFirstThreadId;
+			return RAllocatorHelper::OpenChunkHeap((TLinAddr)chunkInfo.iBase, chunkInfo.iMaxSize);
+			}
+		}
+	return err;
+#else
+	(void)aMem;
+	(void)aDChunkPtr;
+	return KErrNotSupported;
+#endif
+	}
+
+TInt LtkUtils::RProxyAllocatorHelper::ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	TThreadMemoryAccessParams params;
+	params.iId = iThreadId;
+	params.iAddr = (TUint8*)aLocation;
+	params.iSize = aSize;
+	TPtr8 ptr((TUint8*)aResult, aSize, aSize);
+	return iMemoryAccess->GetThreadMem(params, ptr);
+#else
+	return KErrNotSupported;
+#endif
+	}
+
+TInt LtkUtils::RProxyAllocatorHelper::WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize)
+	{
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+	const TPtrC8 ptr((const TUint8*)aData, aSize);
+	return iMemoryAccess->WriteMem(iThreadId, ptr, (TAny*)aLocation);
+#else
+	return KErrNotSupported;
+#endif
+	}
+
+TInt LtkUtils::RProxyAllocatorHelper::TryLock()
+	{
+	return KErrNotSupported;
+	}
+
+void LtkUtils::RProxyAllocatorHelper::TryUnlock()
+	{
+	// Not supported
+	}
+
+EXPORT_C void LtkUtils::RProxyAllocatorHelper::Close()
+	{
+	iMemoryAccess = NULL;
+	iThreadId = 0;
+	RAllocatorHelper::Close();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/rez.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,178 @@
+// rez.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/ltkutils.h>
+#include <f32file.h>
+#include <bautils.h>
+#include <barsc.h>
+
+// Horrible variadic macro to avoid leaving from within a variadic function, because GCCE doesn't like that
+#define LeaveIfErr(err, errBuf, fmt...) \
+	do \
+		{ \
+		TInt __err = (err); \
+		if (__err < 0 && errBuf) \
+			{ \
+			*errBuf = HBufC::NewL(512); \
+			FormatIntoBuf(*errBuf, fmt); \
+			} \
+		User::LeaveIfError(__err); \
+		} \
+		while (0)
+
+
+void FormatIntoBuf(HBufC* aErrBuf, TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+
+	TPtr ptr = aErrBuf->Des();
+	ptr.FormatList(aFmt, list);
+	VA_END(list);
+	}
+
+
+EXPORT_C HBufC8* LtkUtils::Rez8L(const TDesC& aIdentifier, RFs* aFs, HBufC** aErrBuf)
+	{
+	TPtrC id(aIdentifier);
+	if (aIdentifier.Left(2) != _L("R:"))
+		{
+		// Just return the string as-is, ie unlocalised
+		HBufC8* result = HBufC8::NewL(aIdentifier.Length());
+		result->Des().Copy(aIdentifier);
+		return result;
+		}
+
+	RFs stackfs;
+	if (!aFs)
+		{
+		CleanupClosePushL(stackfs);
+		LeaveIfErr(stackfs.Connect(), aErrBuf, _L("Couldn't connect to RFs"));
+		aFs = &stackfs;
+		}
+	else
+		{
+		CleanupStack::PushL((CBase*)NULL); // Just so the cleanup stack is the same depth in both cases - this is ok to destroy
+		}
+	RFs& fs = *aFs;
+
+	id.Set(id.Mid(2));
+	TInt colon = id.Locate(':');
+	if (colon == KErrNotFound || colon == 0)
+		{
+		LeaveIfErr(KErrArgument, aErrBuf, _L("Resource identifier must include a resource id - R:FILENAME:ID[:OFFSET]"));
+		}
+
+	TPtrC resname(id.Left(colon));
+	id.Set(id.Mid(colon+1));
+
+	colon = id.Locate(':');
+	TPtrC offset;
+	if (colon != KErrNotFound)
+		{
+		offset.Set(id.Mid(colon+1));
+		id.Set(id.Left(colon));
+		}
+
+	TFileName resFileName = resname;
+	resFileName.Insert(0, _L("\\Resource\\"));
+	resFileName.Append(_L(".rsc")); // Seems daft but you have to have this to keep Bafl happy
+	BaflUtils::NearestLanguageFile(fs, resFileName);
+
+	RResourceFile resFile;
+	CleanupClosePushL(resFile);
+	TRAPD(err, resFile.OpenL(fs, resFileName));
+	LeaveIfErr(err, aErrBuf, _L("Couldn't open resource file %S"), &resFileName);
+
+	TRAP(err, resFile.ConfirmSignatureL());
+	LeaveIfErr(err,  aErrBuf, _L("Failed to confirm signature"));
+
+	TBool hex = EFalse;
+	if (id.Left(2) == _L("0x"))
+		{
+		id.Set(id.Mid(2));
+		hex = ETrue;
+		}
+	TUint resourceId;
+	TLex lex(id);
+	LeaveIfErr(lex.Val(resourceId, hex ? EHex : EDecimal), aErrBuf, _L("Couldn't parse resource id from %S"), &id);
+
+	HBufC8* resdata = NULL;
+	TRAP(err, resdata = resFile.AllocReadL(resourceId));
+	LeaveIfErr(err, aErrBuf, _L("Couldn't read resource %d from %S"), resourceId, &resFileName);
+	CleanupStack::PushL(resdata);
+
+	TPtrC8 result(*resdata);
+	if (offset.Length())
+		{
+		char last = (char)offset[offset.Length() - 1];
+		if (last != 'd' && last != 'D')
+			{
+			LeaveIfErr(KErrArgument, aErrBuf, _L("Offset '%S' does not end in a 'd' or a 'D'. This is needed to indicate whether the actual target is 8-bit or 16-bit"), &offset);
+			}
+		TResourceReader reader;
+		reader.SetBuffer(resdata);
+		TLex lex(offset);
+		while (!lex.Eos())
+			{
+			TChar ch = lex.Get();
+			if (ch == 'd')
+				{
+				result.Set(reader.ReadTPtrC8());
+				}
+			else if (ch == 'D')
+				{
+				TPtrC16 wptr = reader.ReadTPtrC16();
+				result.Set(TPtrC8((TUint8*)wptr.Ptr(), wptr.Size()));
+				}
+			else
+				{
+				lex.UnGet();
+				TInt amountToSkip;
+				LeaveIfErr(lex.Val(amountToSkip), aErrBuf, _L("Error lexing offset"));
+				reader.Advance(amountToSkip);
+				}
+			}
+		}
+
+	HBufC8* resultBuf = result.AllocL();
+	CleanupStack::PopAndDestroy(3); // resData, resFile, fs
+	return resultBuf;
+	}
+
+EXPORT_C HBufC* LtkUtils::RezL(const TDesC& aIdentifier, RFs* aFs, HBufC** aErrBuf)
+	{
+	if (aIdentifier.Left(2) != _L("R:"))
+		{
+		// Just return the string as-is, ie unlocalised
+		return aIdentifier.AllocL();
+		}
+	HBufC8* buf8 = Rez8L(aIdentifier, aFs, aErrBuf);
+	CleanupStack::PushL(buf8);
+	TPtrC16 wptr((TUint16*)buf8->Ptr(), buf8->Size()/2);
+	HBufC* result = wptr.AllocL();
+	CleanupStack::PopAndDestroy(buf8);
+	return result;
+	}
+
+EXPORT_C HBufC* LtkUtils::RezLC(const TDesC& aIdentifier, RFs* aFs, HBufC** aErrBuf)
+	{
+	HBufC* res = RezL(aIdentifier, aFs, aErrBuf);
+	CleanupStack::PushL(res);
+	return res;
+	}
+
+EXPORT_C HBufC8* LtkUtils::Rez8LC(const TDesC& aIdentifier, RFs* aFs, HBufC** aErrBuf)
+	{
+	HBufC8* res = Rez8L(aIdentifier, aFs, aErrBuf);
+	CleanupStack::PushL(res);
+	return res;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/settings.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,892 @@
+// settings.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/settings.h>
+
+using namespace LtkUtils;
+	
+void Panic(TSettingPanic aReason)
+	{
+	User::Panic(KSettingPanic, aReason);
+	}
+
+void RemoveSpaces(TDes& aDes)
+	{
+	for (TInt i=aDes.Length()-1; i>=0; --i)
+		{
+		if (TChar(aDes[i]).IsSpace()) aDes.Delete(i, 1);
+		}
+	}
+	
+/*
+List of valid values for a boolean. Values interpreted as false, true, false, true, etc.
+i.e. even poitions are false, odd true.
+*/
+_LIT(KBoolValues, "0,1,off,on,no,yes,false,true");
+	
+
+void HandleLineL(const TDesC& aLine, MValueHandler& aValueHandler, TErrorContext aErrorContext)
+	{
+	if (aLine.Length() == 0) return;
+	if (aLine[0] == '#') // comment
+		{
+		aValueHandler.HandleCommentL(aLine.Mid(1), aErrorContext);
+		}
+	else
+		{
+		TLex lex(aLine);
+		lex.SkipSpaceAndMark();
+		lex.SkipCharacters();
+		TPtrC id(lex.MarkedToken());
+		lex.SkipSpace();
+		TPtrC value(lex.Remainder());
+		if (id.Length())
+			{
+			aValueHandler.HandleValueL(id, value, aErrorContext, EFalse);
+			}
+		}
+	}
+	
+
+	
+_LIT(KNewLine, "\n");
+
+EXPORT_C void LtkUtils::ReadIniFileL(const TDesC& aFilename, MValueHandler& aValueHandler, TErrorContext aErrorContext, TFileNotFoundAction aNotFoundAction)
+	{
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+	
+	IoUtils::TFileName2 fn(aFilename);
+	TInt err = fn.FindFile(fs);
+	if ((err == KErrNotFound) && (aNotFoundAction == ESucceedIfFileNotFound))
+		{
+		CleanupStack::PopAndDestroy(&fs);
+		return;
+		}
+	StaticLeaveIfErr(err, _L("%SCannot find file '%S'"), &aErrorContext, &fn);
+	
+	RFile file;
+	StaticLeaveIfErr(file.Open(fs, fn, EFileRead | EFileShareReadersOnly), _L("%SCannot open file '%S'"), &aErrorContext, &fn);
+	CleanupClosePushL(file);
+	
+	IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x40);
+	
+	TErrorContext context(fn);
+	TBuf8<0x40> readBuf;
+	do
+		{
+		TInt lineEnd;
+		do 
+			{
+			const TDesC& des(buf->Descriptor());
+			lineEnd = des.Find(KNewLine);
+			if (lineEnd != KErrNotFound)
+				{
+				TPtrC line(des.Left(lineEnd));
+				if (line.Length() > 0)
+					{
+					if (line[line.Length()-1] == '\r') line.Set(line.Left(line.Length()-1));
+					HandleLineL(line, aValueHandler, context);					
+					}
+				buf->Delete(0, lineEnd+1);
+				context.NextLine();
+				}
+			} while (lineEnd != KErrNotFound);
+		
+		
+		User::LeaveIfError(file.Read(readBuf));
+		buf->AppendL(readBuf);
+		}
+	while (readBuf.Length() > 0);
+	
+	
+	CleanupStack::PopAndDestroy(3, &fs); // buf, file, fs
+	}
+	
+EXPORT_C void LtkUtils::ReadIniFileL(RIoReadHandle& aReadHandle, MValueHandler& aValueHandler)
+	{
+	RBuf lineBuf;
+	lineBuf.CreateL(0x100);
+	CleanupClosePushL(lineBuf);
+	aReadHandle.SetReadModeL(RIoReadHandle::ELine);
+	TName name;
+	aReadHandle.ObjectNameL(name);
+	
+	TInt err;
+	TErrorContext context(name);
+	while ((err = aReadHandle.Read(lineBuf))==KErrNone)
+		{
+		HandleLineL(lineBuf, aValueHandler, context);
+		context.NextLine();
+		}
+	if (err!=KErrEof) User::LeaveIfError(err);
+	
+	CleanupStack::PopAndDestroy(&lineBuf);
+	}
+	
+TInt ValueLineNumberOrder(const CValue& aRodger, const CValue& aMinnie)
+	{
+	return aRodger.LineNumber() - aMinnie.LineNumber();
+	}
+	
+EXPORT_C void LtkUtils::WriteIniFileL(const TDesC& aFilename, CIniReader& aValues)
+	{
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+
+	RFile file;
+	StaticLeaveIfErr(file.Replace(fs, aFilename, EFileWrite | EFileShareExclusive), _L("Cannot open '%S' for writing"), &aFilename);
+	CleanupClosePushL(file);
+	
+
+	IoUtils::CTextFormatter* formatter = IoUtils::CTextFormatter::NewLC(KMaxTInt);
+	aValues.AppendFirstLineL(formatter);
+
+	RPointerArray<CValue> values;
+	CleanupClosePushL(values);
+	aValues.GetValuesL(values);
+	values.Sort(TLinearOrder<CValue>(ValueLineNumberOrder));
+	
+	IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x20);	
+	for (TInt i=0; i<values.Count(); ++i)
+		{
+		buf->AppendFormatL(_L("%S\t%S\r\n"), &values[i]->Id(), &values[i]->Value());
+		}
+
+	formatter->TabulateL(0, 4, buf->Descriptor(), IoUtils::EIgnoreAvailableWidth);
+	
+	User::LeaveIfError(file.Write(formatter->Collapse()));
+	
+	CleanupStack::PopAndDestroy(5, &fs); // fs, file, values, buf, formatter
+	}
+	
+//______________________________________________________________________________
+//						TErrorContext
+EXPORT_C TErrorContext::TErrorContext()
+	: iFilename(KNullDesC), iLineNumber(0)
+	{
+	}
+
+EXPORT_C TErrorContext::TErrorContext(const TDesC& aFilename)
+	: iFilename(aFilename), iLineNumber(1)
+	{
+	}
+
+EXPORT_C void TErrorContext::NextLine()
+	{
+	iLineNumber++;
+	}
+
+EXPORT_C TInt TErrorContext::LineNumber()
+	{
+	return iLineNumber;
+	}
+
+EXPORT_C const TDesC& TErrorContext::StringLC()
+	{
+	_LIT(KErrorContextFmt, "%S:%d: ");
+	if (iFilename.Length() && iLineNumber>0)
+		{
+		HBufC* string = HBufC::NewLC(iFilename.Length()+0x10);
+		string->Des().AppendFormat(KErrorContextFmt, &iFilename, iLineNumber);
+		return *string;
+		}
+	else
+		{
+		CleanupStack::PushL((void*)NULL);
+		return KNullDesC;
+		}
+	
+	}
+
+	
+//______________________________________________________________________________
+//						CValue
+EXPORT_C CValue* CValue::NewL(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext)
+	{
+	CValue* self = CValue::NewLC(aId, aValue, aErrorContext);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CValue* CValue::NewLC(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext)
+	{
+	CValue* self = new(ELeave)CValue(aErrorContext);
+	CleanupStack::PushL(self);
+	self->ConstructL(aId, aValue);
+	return self;
+	}
+
+EXPORT_C CValue::~CValue()
+	{
+	iId.Close();
+	iValue.Close();
+	}
+
+EXPORT_C const TDesC& CValue::Id() const
+	{
+	return iId;
+	}
+
+EXPORT_C const TDesC& CValue::Value() const
+	{
+	return iValue;
+	}
+
+EXPORT_C void CValue::SetL(const TDesC& aNewValue, TErrorContext aErrorContext)
+	{
+	if (iValue.MaxLength() < aNewValue.Length())
+		{
+		RBuf newValue;
+		newValue.CreateL(aNewValue.Length());
+		newValue.Swap(iValue);
+		newValue.Close();
+		}
+	if (aErrorContext.LineNumber() > 0) iLineNumber = aErrorContext.LineNumber();
+	iValue.Copy(aNewValue);
+	}
+	
+EXPORT_C TInt CValue::LineNumber() const
+	{
+	return iLineNumber;
+	}
+	
+EXPORT_C TInt CValue::AsInt(TInt& aInt) const
+	{
+	TLex lex(iValue);
+	TInt err = lex.Val(aInt);
+	if (err == KErrNone)
+		{
+		if (lex.Remainder().Length()) err = KErrArgument;
+		}
+	return err;
+	}
+
+EXPORT_C TInt CValue::AsBool(TBool& aBool) const
+	{
+	IoUtils::TEnum truth(KBoolValues);
+	TInt i;
+	TInt err = truth.Parse(iValue, i);
+	if (err==KErrNone)
+		{
+		aBool = i & 0x01;
+		}
+	return err;
+	}
+	
+EXPORT_C TInt CValue::AsIntL() const
+	{
+	TInt i;
+	StaticLeaveIfErr(AsInt(i), _L("'%S' value '%S' is not a valid integer"), &iId ,&iValue);
+	return i;
+	}
+	
+EXPORT_C TBool CValue::AsBoolL() const
+	{
+	TBool b;
+	StaticLeaveIfErr(AsBool(b), _L("'%S' value '%S' is not a valid boolean"), &iId, &iValue);
+	return b;
+	}
+
+
+CValue::CValue(TErrorContext aErrorContext)
+	: iLineNumber(aErrorContext.LineNumber())
+	{
+	}
+
+void CValue::ConstructL(const TDesC& aId, const TDesC& aValue)
+	{
+	iId.CreateL(aId);
+	iValue.CreateL(aValue);
+	}
+	
+//______________________________________________________________________________
+//						CIniReader
+EXPORT_C CIniReader* CIniReader::NewL(const TDesC& aFilename, TErrorContext aErrorContext)
+	{
+	CIniReader* self = new(ELeave)CIniReader();
+	CleanupStack::PushL(self);
+	ReadIniFileL(aFilename, *self, aErrorContext, EFailIfFileNotFound);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CIniReader::CIniReader()
+	{
+	}
+
+EXPORT_C CIniReader::~CIniReader()
+	{
+	TPtrHashMapIter<TDesC, CValue> iter(iValues);
+	while (iter.NextValue())
+		{
+		const CValue* val = iter.CurrentValue();
+		iter.RemoveCurrent();
+		delete val;
+		}
+	iValues.Close();
+	iFirstLineComment.Close();
+	}
+
+EXPORT_C const TDesC* CIniReader::GetValue(const TDesC& aId) const
+	{
+	const CValue* value = iValues.Find(aId);
+	if (value)
+		{
+		return &value->Value();
+		}
+	else
+		{
+		return NULL;
+		}
+	}
+
+
+EXPORT_C void CIniReader::GetValuesL(RPointerArray<CValue>& aValues)
+	{
+	TPtrHashMapIter<TDesC, CValue> iter(iValues);
+	while (iter.NextValue())
+		{
+		if (IncludeValue(iter.CurrentValue())) aValues.AppendL(iter.CurrentValue());
+		}
+	}
+	
+EXPORT_C void CIniReader::GetValuesL(RPointerArray<const CValue>& aValues) const
+	{
+	TPtrHashMapIter<TDesC, CValue> iter(iValues);
+	while (iter.NextValue())
+		{
+		if (IncludeValue(iter.CurrentValue())) aValues.AppendL(iter.CurrentValue());
+		}
+	}
+
+	
+EXPORT_C void CIniReader::GetIdsL(RArray<const TPtrC>& aIds) const
+	{
+	TPtrHashMapIter<TDesC, CValue> iter(iValues);
+	while (iter.NextValue())
+		{
+		aIds.AppendL(*iter.CurrentKey());
+		}
+	}
+	
+EXPORT_C void CIniReader::SetValueL(const TDesC& aId, const TDesC& aValue)
+	{
+	CValue* value = iValues.Find(aId);
+	if (value)
+		{
+		value->SetL(aValue, TErrorContext());
+		}
+	else
+		{
+		HandleValueL(aId, aValue, TErrorContext(), ETrue);
+		}
+	}
+	
+EXPORT_C void CIniReader::RemoveValueL(const TDesC& aId)
+	{
+	CValue* value = iValues.Find(aId);
+	if (value)
+		{
+		DoRemoveL(value);
+		}
+	}
+	
+void CIniReader::DoRemoveL(CValue* aValue)
+	{
+	iValues.Remove(&aValue->Id());
+	delete aValue;
+	}
+	
+void CIniReader::AppendFirstLineL(IoUtils::CTextFormatter* aFormatter)
+	{
+	if (iFirstLineComment.Length())
+		{
+		aFormatter->AppendFormatL(_L("#%S\r\n"), &iFirstLineComment);
+		}
+	}
+	
+void CIniReader::HandleValueL(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext, TBool aOverwrite)
+	{
+	CValue* value = iValues.Find(aId);
+	if (!value)
+		{
+		value = CreateValueLC(aId, aValue, aErrorContext);
+		iValues.InsertL(&value->Id(), value);
+		CleanupStack::Pop(value);
+		}
+	else
+		{
+		if (aOverwrite)
+			{
+			value->SetL(aValue, aErrorContext);
+			}
+		// else ignore the duplicate value
+		}
+	}
+	
+void CIniReader::HandleCommentL(const TDesC& aComment, TErrorContext aErrorContext)
+	{
+	if (aErrorContext.LineNumber() == 1)
+		{
+		iFirstLineComment.Close();
+		iFirstLineComment.CreateL(aComment);
+		HandleFirstLineCommentL(iFirstLineComment, aErrorContext);
+		}
+	}
+	
+CValue* CIniReader::CreateValueLC(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext)
+	{
+	return CValue::NewLC(aId, aValue, aErrorContext);
+	}
+
+//______________________________________________________________________________
+//						CSetting
+EXPORT_C CSetting* CSetting::NewL(TSettingType aType, const TDesC& aId, const TDesC& aName, const TDesC& aDescription, const TDesC& aDefault, const TDesC& aEnumValues, TErrorContext aErrorContext)
+	{
+	CSetting* self = CSetting::NewLC(aType, aId, aName, aDescription, aDefault, aEnumValues, aErrorContext);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+EXPORT_C CSetting* CSetting::NewLC(TSettingType aType, const TDesC& aId, const TDesC& aName, const TDesC& aDescription, const TDesC& aDefault, const TDesC& aEnumValues, TErrorContext aErrorContext)
+	{
+	CSetting* self = new(ELeave)CSetting(aType);
+	CleanupStack::PushL(self);
+	self->ConstructL(aId, aName, aDescription, aDefault, aEnumValues, aErrorContext);
+	return self;
+	}
+	
+EXPORT_C CSetting::~CSetting()
+	{
+	iName.Close();
+	iDescription.Close();
+	iEnumValues.Close();
+	iDefault.Close();
+	}
+
+EXPORT_C void CSetting::SetL(const TDesC& aNewValue, TErrorContext aErrorContext)
+	{
+	TInt value = ParseL(aNewValue, aErrorContext);
+	switch (iType)
+		{
+	case ETypeEnum:
+			{
+			CValue::SetL(iEnum.GetString(value), aErrorContext);
+			iIntValue = value;
+			}
+		break;
+	case ETypeFilename:
+	case ETypeString:
+		CValue::SetL(aNewValue, aErrorContext);
+		break;
+	case ETypeInteger:
+			{
+			CValue::SetL(aNewValue, aErrorContext);
+			iIntValue = value;
+			}
+		break;
+	case ETypeBoolean:
+			{
+			IoUtils::TEnum truth(KBoolValues);
+			TInt value = truth.ParseL(aNewValue); // even false, odd true
+			CValue::SetL(truth.GetString(value), aErrorContext);
+			iIntValue = (value & 0x01) ? (TBool)ETrue : EFalse;
+			}
+		break;
+		}
+	iIsSet = ETrue;
+	}
+	
+TInt CSetting::ParseL(const TDesC& aValue, TErrorContext aErrorContext)
+	{
+	switch (iType)
+		{
+	case ETypeEnum:
+			return iEnum.ParseL(aValue);
+	case ETypeFilename:
+	case ETypeString:
+		return 0;
+	case ETypeInteger:
+			{
+			TLex lex(aValue);
+			TInt value;
+			lex.SkipSpace();
+			StaticLeaveIfErr(lex.Val(value), _L("%S'%S' value '%S' is not a valid integer"), &aErrorContext.StringLC(), &Id(), &aValue);
+			lex.SkipSpace();
+			if (lex.Remainder().Length()) StaticLeaveIfErr(KErrArgument, _L("%S'%S' value '%S' is not a valid integer"), &aErrorContext.StringLC(), &Id(), &aValue);
+			return value;
+			}
+	case ETypeBoolean:
+			{
+			TInt value = iEnum.ParseL(aValue); // even false, odd true
+			return (value & 0x01) ? (TBool)ETrue : EFalse;
+			}
+		}
+	return 0;
+	}
+	
+_LIT(KIntFormat, "%d");
+	
+EXPORT_C void CSetting::SetL(TInt aNewValue)
+	{
+	switch (iType)
+		{
+	case ETypeEnum:
+			{
+			IoUtils::TEnum _enum(iEnumValues);
+			CValue::SetL(_enum.GetString(aNewValue), TErrorContext());
+			iIntValue = aNewValue;
+			}
+		break;
+	case ETypeFilename:
+	case ETypeString:
+	case ETypeInteger:
+			{
+			TBuf<0x10> buf;
+			buf.AppendFormat(KIntFormat, aNewValue);
+			CValue::SetL(buf, TErrorContext());
+			if (iType == ETypeInteger)
+				{
+				iIntValue = aNewValue;
+				}
+			}
+		break;
+	case ETypeBoolean:
+			{
+			CValue::SetL(iEnum.GetString(aNewValue ? 1 : 0), TErrorContext());
+			iIntValue = aNewValue;
+			}
+		break;
+		}
+	iIsSet = ETrue;
+	}
+	
+EXPORT_C TInt CSetting::AsInt(TInt& aInt) const
+	{
+	if (iType == ETypeEnum || iType == ETypeInteger)
+		{
+		aInt = AsInt();
+		return KErrNone;
+		}
+	else return CValue::AsInt(aInt);
+	}
+	
+EXPORT_C TInt CSetting::AsBool(TBool& aBool) const
+	{
+	if (iType == ETypeBoolean)
+		{
+		aBool = AsBool();
+		return KErrNone;
+		}
+	else return CValue::AsBool(aBool);
+	}
+
+EXPORT_C TInt CSetting::AsInt() const
+	{
+	__ASSERT_ALWAYS(iType == ETypeEnum || iType == ETypeInteger, Panic(EInvalidType));
+	return iIntValue;
+	}
+	
+EXPORT_C TBool CSetting::AsBool() const
+	{
+	__ASSERT_ALWAYS(iType == ETypeBoolean, Panic(EInvalidType));
+	return iIntValue;
+	}
+	
+EXPORT_C TBool CSetting::IsSet() const
+	{
+	return iIsSet;
+	}
+	
+EXPORT_C void CSetting::ClearL()
+	{
+	if (IsSet())
+		{
+		SetL(iDefault);
+		iIsSet = EFalse;
+		}
+	}
+	
+EXPORT_C const TDesC& CSetting::Name()
+	{
+	return iName;
+	}
+	
+EXPORT_C const TDesC& CSetting::Description()
+	{
+	return iDescription;
+	}
+
+CSetting::CSetting(TSettingType aType)
+	: CValue(TErrorContext()), iType(aType), iEnum(KNullDesC)
+	{
+	}
+
+void CSetting::ConstructL(const TDesC& aId, const TDesC& aName, const TDesC& aDescription, const TDesC& aDefault, const TDesC& aEnumValues, TErrorContext aErrorContext)
+	{
+	CValue::ConstructL(aId, KNullDesC);
+	iName.CreateL(aName);
+	iDescription.CreateL(aDescription);
+	
+	if (iType == ETypeEnum)
+		{
+		iEnumValues.CreateL(aEnumValues);
+		RemoveSpaces(iEnumValues);
+		new(&iEnum)IoUtils::TEnum(iEnumValues); // in-place construct
+		}
+	else if (iType == ETypeBoolean)
+		{
+		new(&iEnum)IoUtils::TEnum(KBoolValues);
+		}
+
+	iDefaultInt = ParseL(aDefault, aErrorContext);
+	iDefault.CreateL(aDefault);
+	
+	iIntValue = iDefaultInt;
+	CValue::SetL(iDefault, TErrorContext());
+	}
+
+	
+//______________________________________________________________________________
+//						CIniFile
+EXPORT_C CIniFile* CIniFile::NewL(const TDesC& aIniFile, const TDesC& aInfoFile)
+	{
+	CIniFile* self = new(ELeave)CIniFile();
+	CleanupStack::PushL(self);
+	self->ConstructL(aIniFile, aInfoFile);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CIniFile::~CIniFile()
+	{
+	delete iInfoFile;
+	iFilename.Close();
+	}
+
+EXPORT_C CSetting* CIniFile::GetSetting(const TDesC& aId)
+	{
+	return (CSetting*)iValues.Find(aId);
+	}
+	
+EXPORT_C const TDesC& CIniFile::GetString(const TDesC& aId)
+	{
+	CSetting* setting = GetSetting(aId);
+	__ASSERT_ALWAYS(setting, Panic(ENotDefined));
+	return setting->Value();
+	}
+	
+EXPORT_C TInt CIniFile::GetInt(const TDesC& aId)
+	{
+	CSetting* setting = GetSetting(aId);
+	__ASSERT_ALWAYS(setting, Panic(ENotDefined));
+	return setting->AsInt();
+	}
+	
+EXPORT_C TBool CIniFile::GetBool(const TDesC& aId)
+	{
+	CSetting* setting = GetSetting(aId);
+	__ASSERT_ALWAYS(setting, Panic(ENotDefined));
+	return setting->AsBool();
+	}
+	
+EXPORT_C void CIniFile::SetL(const TDesC& aId, const TDesC& aString)
+	{
+	CSetting* setting = GetSetting(aId);
+	__ASSERT_ALWAYS(setting, Panic(ENotDefined));
+	setting->SetL(aString, TErrorContext());
+	}
+	
+EXPORT_C void CIniFile::SetL(const TDesC& aId, TInt aInt)
+	{
+	CSetting* setting = GetSetting(aId);
+	__ASSERT_ALWAYS(setting, Panic(ENotDefined));
+	setting->SetL(aInt);
+	}
+
+CValue* CIniFile::CreateValueLC(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext)
+	{
+	ASSERT(0);
+	CSetting* setting = CSetting::NewLC(ETypeString, aId, aId, KNullDesC, KNullDesC, KNullDesC, aErrorContext);
+	setting->SetL(aValue, aErrorContext);
+	return setting;
+	}
+
+void CIniFile::HandleValueL(const TDesC& aId, const TDesC& aValue, TErrorContext aErrorContext, TBool aOverwrite)
+	{
+	if (!iInfoFile) StaticLeaveIfErr(KErrCorrupt, _L("%SNo description file has been specified"), &aErrorContext.StringLC());
+	CSetting* setting = GetSetting(aId);
+	if (setting)
+		{
+		if (setting->IsSet() && (!aOverwrite))
+			{
+			StaticLeaveIfErr(KErrAlreadyExists, _L("%Sid '%S' already defined on line %d"), &aErrorContext.StringLC(), &aId, setting->LineNumber());
+			}
+		setting->SetL(aValue, aErrorContext);
+		}
+	else
+		{
+		StaticLeaveIfErr(KErrCorrupt, _L("%Sid '%S' not recognised"), &aErrorContext.StringLC(), &aId);
+		}
+	}
+	
+_LIT(KFirstLineCommentMatch, "!iniedit ");
+_LIT(KOptionInfoFile, "-i");
+
+void CIniFile::HandleFirstLineCommentL(const TDesC& aComment, TErrorContext aErrorContext)
+	{
+	if (!iInfoFile)
+		{
+		if (aComment.Left(KFirstLineCommentMatch().Length()).CompareF(KFirstLineCommentMatch)==0)
+			{
+			//TODO see if we can do something better here, maybe reusing CCommandBase's option parsing?
+					// remove the matched string, without the wildcard
+			TLex lex(aComment.Mid(KFirstLineCommentMatch().Length()));
+			lex.SkipSpace();
+			while (!lex.Eos())
+				{
+				TPtrC next(lex.NextToken());
+				lex.SkipSpace();
+				if (next.Compare(KOptionInfoFile)==0 && !lex.Eos())
+					{
+					TPtrC infoFile(lex.NextToken());
+					lex.SkipSpace();
+					
+					ReadInfoFileL(infoFile, aErrorContext);					
+					}
+				}
+			}
+		}
+	}
+	
+TBool CIniFile::IncludeValue(const CValue* aValue) const
+	{
+	return ((const CSetting*)aValue)->IsSet();
+	}
+	
+void CIniFile::DoRemoveL(CValue* aValue)
+	{
+	static_cast<CSetting*>(aValue)->ClearL();
+	}
+
+CIniFile::CIniFile()
+	{
+	}
+	
+_LIT(KSpace, " ");
+
+void CIniFile::ConstructL(const TDesC& aIniFile, const TDesC& aInfoFile)
+	{
+	if (aInfoFile.Length()!=0)
+		{
+		ReadInfoFileL(aInfoFile, TErrorContext());
+		
+		}
+	ReadIniFileL(aIniFile, *this, TErrorContext(), aIniFile.Length() ? ESucceedIfFileNotFound : EFailIfFileNotFound);
+	iFilename.CreateL(aIniFile);
+	
+	if ((iFirstLineComment.Length()==0) && (aInfoFile.Length()!=0))
+		{
+		// construct the first line comment if it doesn't exist in the file, and we have an IDF file
+		iFirstLineComment.Close();
+		iFirstLineComment.CreateL(aInfoFile.Length() + KFirstLineCommentMatch().Length() + KOptionInfoFile().Length() + 1);
+		iFirstLineComment.Append(KFirstLineCommentMatch);
+		iFirstLineComment.Append(KOptionInfoFile);
+		iFirstLineComment.Append(KSpace);
+		iFirstLineComment.Append(aInfoFile);
+		}
+	}
+
+_LIT(KDot, ".");
+_LIT(KNameFmt, "%S.name");
+_LIT(KDescriptionFmt, "%S.description");
+_LIT(KEnumValuesFmt, "%S.values");
+_LIT(KDefaultFmt, "%S.default");
+_LIT(KTypeEnum, "enum,filename,string,integer,boolean");
+
+void CIniFile::ReadInfoFileL(const TDesC& aFilename, TErrorContext aErrorContext)
+	{
+	if (iInfoFile) return;
+	iInfoFile = CIniReader::NewL(aFilename, aErrorContext);
+	IoUtils::TEnum typeEnum(KTypeEnum);
+	IoUtils::CTextBuffer* idBuf = IoUtils::CTextBuffer::NewLC(8);
+	
+	RArray<const TPtrC> ids;
+	CleanupClosePushL(ids);
+	iInfoFile->GetIdsL(ids);
+	
+	for (TInt i=0; i<ids.Count(); ++i)
+		{
+		if (ids[i].Find(KDot) == KErrNotFound)
+			{
+			const TDesC& id = ids[i];
+			
+			TSettingType type = (TSettingType)typeEnum.ParseL(*iInfoFile->GetValue(id));
+			
+			idBuf->Reset();
+			idBuf->AppendFormatL(KNameFmt, &id);
+			const TDesC* name = iInfoFile->GetValue(idBuf->Descriptor());
+			
+			idBuf->Reset();
+			idBuf->AppendFormatL(KDescriptionFmt, &id);
+			const TDesC* description = iInfoFile->GetValue(idBuf->Descriptor());
+			
+			idBuf->Reset();
+			idBuf->AppendFormatL(KDefaultFmt, &id);
+			const TDesC* defaultValue = iInfoFile->GetValue(idBuf->Descriptor());
+			
+			const TDesC* enumValues = NULL;
+			if (type == ETypeEnum)
+				{
+				idBuf->Reset();
+				idBuf->AppendFormatL(KEnumValuesFmt, &id);
+				enumValues = iInfoFile->GetValue(idBuf->Descriptor());
+				if (!enumValues) StaticLeaveIfErr(KErrCorrupt, _L("%S: enum '%S' doesn't have any values specified (%S.values not defined)"), &aFilename, &id, &id);
+				}
+				
+			CSetting* setting = CSetting::NewLC(type, id, name ? *name : id, description ? *description : KNullDesC, defaultValue ? *defaultValue : KNullDesC, enumValues ? *enumValues : KNullDesC, aErrorContext);
+			iValues.InsertL(&setting->Id(), setting);
+			CleanupStack::Pop();			
+			}
+		}
+	
+	CleanupStack::PopAndDestroy(2, idBuf);// idBuf, ids
+	}
+	
+EXPORT_C void CIniFile::WriteL()
+	{
+	IoUtils::TFileName2 iniFile(iFilename);
+	
+	RFs fs; User::LeaveIfError(fs.Connect());
+	TInt err = iniFile.FindFile(fs);
+	
+	if (err==KErrNotFound)
+		{
+		if (iniFile.Length()==0) User::Leave(KErrBadName);
+		if (iniFile[0] != '\\') iniFile.Insert(0, _L("\\"));
+		iniFile.Insert(0, _L("C:"));
+		
+		err = fs.MkDirAll(iniFile);
+		if (err== KErrAlreadyExists) err=KErrNone;		
+		}
+
+	fs.Close();
+	User::LeaveIfError(err);
+	
+	WriteIniFileL(iniFile, *this);
+	}
+
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/symbolics.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,187 @@
+// symbolics.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/bsym.h>
+#include <fshell/ltkutils.h>
+#include <fshell/stringhash.h>
+#include <fshell/iocli.h>
+#include "bsymtree.h"
+
+using namespace LtkUtils;
+using namespace IoUtils;
+
+EXPORT_C CSymbolics::CSymbolics(RFs& aFs)
+	: iFs(aFs)
+	{
+	}
+
+EXPORT_C CSymbolics::~CSymbolics()
+	{
+	iBsyms.ResetAndDestroy();
+	TStringHashIter<CMapFile*> iter(iCodeSegHash);
+	while (iter.NextValue() != NULL)
+		{
+		CMapFile** file = iter.CurrentValue();
+		delete *file;
+		}
+	iCodeSegHash.Close();
+	delete iTabCompleteTree;
+	delete iTabCompleteCodeseg;
+	}
+
+EXPORT_C void CSymbolics::AddBsymFileL(const TDesC& aFileName)
+	{
+	CBsymFile* file = CBsymFile::NewL(iFs, aFileName);
+	TInt err = iBsyms.Append(file);
+	if (err)
+		{
+		delete file;
+		User::Leave(err);
+		}
+	}
+
+EXPORT_C void CSymbolics::AddMapFileL(const TDesC& aFileName)
+	{
+	CMapFile* file = CMapFile::NewL(iFs, aFileName);
+	CleanupStack::PushL(file);
+	AddMapFileL(file);
+	CleanupStack::Pop(file);
+	}
+
+EXPORT_C void CSymbolics::AddMapFileL(CMapFile* aMapFile)
+	{
+	aMapFile->GetFileNameL(iTempString);
+	TParsePtrC parse(iTempString);
+	TPtrC name = parse.Name(); // Don't use NameAndExt, that will include the .map!
+	TPtr namePtr((TUint16*)name.Ptr(), name.Length(), name.Length()); // Nasty but TParsePtr won't give us a non-const Name().
+	namePtr.LowerCase();
+	User::LeaveIfError(iCodeSegHash.Insert(namePtr, aMapFile));
+	}
+
+EXPORT_C void CSymbolics::SetFallbackMapFileDirL(const TDesC& aDir)
+	{
+	iFallbackMapFileDir = aDir;
+	}
+
+EXPORT_C TPtrC CSymbolics::LookupL(TUint32 aRomAddress)
+	{
+	for (TInt i = 0; i < iBsyms.Count(); i++)
+		{
+		TPtrC res = iBsyms[i]->LookupL(aRomAddress);
+		if (res.Length()) return res;
+		}
+	return TPtrC();
+	}
+
+EXPORT_C TPtrC CSymbolics::LookupL(const TDesC& aCodeseg, TUint32 aOffset)
+	{
+	CMapFile* mapFile = FindOrLoadMapFileL(aCodeseg);
+
+	iTempString.Zero();
+	if (mapFile)
+		{
+		mapFile->Lookup(aOffset, iTempString);
+		if (iTempString.Length())
+			{
+			iTempString.AppendFormat(_L(" (%S)"), &aCodeseg);
+			}
+		}
+	else
+		{
+		// Try BSYMs in case it's in ROFS
+		for (TInt i = 0; i < iBsyms.Count(); i++)
+			{
+			TPtrC res = iBsyms[i]->LookupL(aCodeseg, aOffset);
+			}
+		}
+	return TPtrC(iTempString);
+	}
+
+EXPORT_C void CSymbolics::CompleteL(const TDesC& aCodeseg, TDes& aSymbolName, CDesC16Array& aSuggestions)
+	{
+	RNode* tree = TreeForCodesegL(aCodeseg);
+	if (tree)
+		{
+		tree->CompleteL(aSymbolName, aSuggestions);
+		}
+	}
+
+RNode* CSymbolics::TreeForCodesegL(const TDesC& aCodeseg)
+	{
+	iTempString.Copy(aCodeseg);
+	iTempString.LowerCase();
+	if (iTabCompleteCodeseg && *iTabCompleteCodeseg != iTempString)
+		{
+		// If iTabCompleteCodeseg is set it means that iTabCompleteTree (if it's non-null) matches.
+		delete iTabCompleteCodeseg;
+		iTabCompleteCodeseg = NULL;
+		delete iTabCompleteTree;
+		iTabCompleteTree = NULL;
+		}
+	if (!iTabCompleteCodeseg) iTabCompleteCodeseg = iTempString.AllocL();
+
+	if (iTabCompleteTree == NULL)
+		{
+		for (TInt i = 0; i < iBsyms.Count(); i++)
+			{
+			RNode* tree = iBsyms[i]->CreateCompletionTreeL(*iTabCompleteCodeseg);
+			if (tree)
+				{
+				iTabCompleteTree = tree;
+				break;
+				}
+			}
+		}
+	// Try the map files now
+	if (iTabCompleteTree == NULL)
+		{
+		CMapFile* mapFile = FindOrLoadMapFileL(aCodeseg);
+		if (mapFile)
+			{
+			iTabCompleteTree = mapFile->CreateCompletionTreeL();
+			}
+		}
+	return iTabCompleteTree;
+	}
+
+EXPORT_C TUint32 CSymbolics::CodesegOffsetFromSymbolNameL(const TDesC& aCodeseg, const TDesC& aSymbolName)
+	{
+	RNode* tree = TreeForCodesegL(aCodeseg);
+	if (!tree) User::Leave(KErrNotFound);
+	return tree->ValueForStringL(aSymbolName);
+	}
+
+CMapFile* CSymbolics::FindOrLoadMapFileL(const TDesC& aCodeseg)
+	{
+	iTempString.Copy(aCodeseg);
+	iTempString.LowerCase();
+
+	// If it's already loaded, return it
+	CMapFile* mapFile = iCodeSegHash.FindPtr(iTempString);
+	if (mapFile) return mapFile;
+
+	if (iFallbackMapFileDir.Length() == 0) return NULL;
+	// Try loading the mapfile
+	TFileName2 fn = iFallbackMapFileDir;
+	fn.AppendComponentL(iTempString);
+	fn.Append(_L(".map"));
+	TEntry e;
+	if (iFs.Entry(fn, e) == KErrNone)
+		{
+		TRAPD(err, AddMapFileL(fn));
+		StaticLeaveIfErr(err, _L("Could not load map file %S"), &fn);
+		// AddMapFileL overwrites iTempString, so restore it (nasty but I object to wasting buffers on the stack...)
+		iTempString.Copy(aCodeseg);
+		iTempString.LowerCase();
+		return iCodeSegHash.FindPtr(iTempString);
+		}
+	return NULL;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/src/w32crack.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,122 @@
+// w32crack.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include <fshell/ltkutils.h>
+#include <e32base.h>
+#include <fshell/iocli.h>
+#include <w32std.h>
+#include <fshell/ioutils.h>
+#include <fshell/memoryaccess.h>
+
+//
+// LtkUtils::W32CrackL
+// loads the autometric logging engine, dlogev.dll, into wserv
+// enabling Autometric to monitor events from within wserv - key/pointer events, text drawn to screen etc
+//
+EXPORT_C void LtkUtils::W32CrackL()
+	{
+#ifndef FSHELL_WSERV_SUPPORT
+	User::Leave(KErrNotSupported);
+#else
+
+	// Check if P&S says it's already enabled, if so no need to do anything
+	if (W32CrackIsEnabled()) return;
+
+	_LIT(KWsIniFile, "z:\\system\\data\\wsini.ini");
+	_LIT(KCWsIniFile,"c:\\system\\data\\wsini.ini");
+	_LIT(KLogEv, "LOG EV\r\n");
+	
+	// Open z file
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+
+	RFile file;
+	User::LeaveIfError(file.Open(fs, KWsIniFile, EFileRead));
+	CleanupClosePushL(file);
+
+	TInt size;
+	User::LeaveIfError(file.Size(size));
+
+	RBuf8 buf;
+	buf.CreateL(size + KLogEv().Size());
+	CleanupClosePushL(buf);
+	User::LeaveIfError(file.Read(buf));
+	TPtrC16 wptr((TUint16*)buf.Ptr(), buf.Size()/2);
+	buf.Insert(2, TPtrC8((TUint8*)KLogEv().Ptr(), KLogEv().Size())); // +2 to get past the BOM
+	TInt err = KErrNone;
+	err = fs.MkDirAll(KCWsIniFile); // mkdir c:\system\data\ in case it is not exist
+	if((err != KErrNone) && (err != KErrAlreadyExists))
+		{
+		User::Leave(err);
+		}
+	User::LeaveIfError(file.Replace(fs, KCWsIniFile, EFileWrite));
+	User::LeaveIfError(file.Write(buf));
+	CleanupStack::PopAndDestroy(2, &file); // file, buf
+	
+	err = RMemoryAccess::LoadDriver();
+	if ((err != KErrNone) && (err != KErrAlreadyExists))
+		{
+		User::Leave(err);
+		}
+	
+	RMemoryAccess memAccess;
+	User::LeaveIfError(memAccess.Open());
+	CleanupClosePushL(memAccess);
+	
+	RWsSession ws;
+	User::LeaveIfError(ws.Connect(fs));
+	CleanupClosePushL(ws);
+
+#ifdef __WINS__
+	// On wins the binary isn't renamed
+	_LIT(KWservMatch, "wserv*.exe*");
+#else
+	_LIT(KWservMatch, "EwSrv.exe*");
+#endif
+	TFindProcess find(KWservMatch);
+	TFullName name;
+	User::LeaveIfError(find.Next(name));
+	
+	RProcess wservProc;
+	User::LeaveIfError(wservProc.Open(find));
+	if (wservProc.ExitType() != EExitPending)
+		{
+		// in case wserv kicks off the preferred implementation in a new process then kills itself
+		// (is one retry enough or should we be looping here?)
+		wservProc.Close();
+		User::LeaveIfError(find.Next(name));
+		User::LeaveIfError(wservProc.Open(find));
+		}
+	CleanupClosePushL(wservProc);
+	name = wservProc.FileName();
+	name[0] = 'c';
+	TPtrC8 narrowName = name.Collapse();
+	User::LeaveIfError(memAccess.InPlaceSetProcessFileName(wservProc, narrowName));
+
+	// Now tell wserv to reload its wsini.ini and enable logging
+	ws.LogCommand(RWsSession::ELoggingEnable);
+	ws.Flush();
+	
+	// cleanup
+	CleanupStack::PopAndDestroy(4, &fs);
+
+#endif // FSHELL_WSERV_SUPPORT
+	}
+
+EXPORT_C TBool LtkUtils::W32CrackIsEnabled()
+	{
+	TInt enabled = EFalse;
+	TInt err = RProperty::Get(KW32CrackCategory, KW32CrackKey, enabled);
+	return (err == KErrNone && enabled);
+	}
Binary file libraries/ltkutils/tsrc/Performance.xlsx has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/catcompare.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,24 @@
+#!fshell
+# catcompare.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# catcompare <repeatcount> <blocksize>
+export REPEATCOUNT $1
+export BLOCKSIZE $2
+export CAT "cat -e utf-8 -s $BLOCKSIZE E:\change_history.pod"
+export TUTF "cat -e ltk-utf-8 -s $BLOCKSIZE E:\change_history.pod"
+
+echo "Timing $CAT...^r^n"
+time -H -r $REPEATCOUNT "$CAT > /dev/null"
+
+echo "Timing $TUTF...^r^n"
+time -H -r $REPEATCOUNT "$TUTF > /dev/null"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tallochelper.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,219 @@
+// tallochelper.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#include <fshell/heaputils.h>
+#include <fshell/ltkutils.h>
+
+using namespace IoUtils;
+using LtkUtils::RAllocatorHelper;
+
+class CCmdTAllocHelper : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTAllocHelper();
+private:
+	CCmdTAllocHelper();
+	void PrintStats(const TDesC& aDesc);
+
+	void AllocL(TInt aSize, TInt aNumber=1);
+	void Free(TInt aNumber=1);
+	void FormatSize(TDes& aBuf, TInt64 aSize);
+	static TBool WalkCallback(RAllocatorHelper& aAlloc, TAny* aContext, RAllocatorHelper::TExtendedCellType aType, TLinAddr aAddress, TInt aLength);
+	static void RHeapWalkCallback(TAny* aContext, RHeap::TCellType aType, TAny* aCell, TInt aLength);
+
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	RAllocatorHelper iAlloc;
+	RArray<TAny*> iAllocations;
+	TBool iBytes;
+	TBool iWaitOnExit;
+
+	TInt iAllocationsAccordingToRHeapWalker;
+	};
+
+EXE_BOILER_PLATE(CCmdTAllocHelper)
+
+CCommandBase* CCmdTAllocHelper::NewLC()
+	{
+	CCmdTAllocHelper* self = new(ELeave) CCmdTAllocHelper();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTAllocHelper::~CCmdTAllocHelper()
+	{
+	iAlloc.Close();
+	Free(iAllocations.Count());
+	iAllocations.Close();
+	}
+
+CCmdTAllocHelper::CCmdTAllocHelper()
+	: CCommandBase(EManualComplete)
+	{
+	}
+
+const TDesC& CCmdTAllocHelper::Name() const
+	{
+	_LIT(KName, "tallochelper");	
+	return KName;
+	}
+
+const TDesC& CCmdTAllocHelper::Description() const
+	{
+	_LIT(KDescription, "Test code for RAllocatorHelper");
+	return KDescription;
+	}
+
+void CCmdTAllocHelper::ArgumentsL(RCommandArgumentList& /*aArguments*/)
+	{
+	}
+
+void CCmdTAllocHelper::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendBoolL(iBytes, 'b', _L("bytes"), _L("Display sizes in bytes rather than rounded off KB or MB"));
+	aOptions.AppendBoolL(iWaitOnExit, 'w', _L("wait"), _L("Wait indefinitely before exiting - for testing remote heap walking"));
+	}
+
+void CCmdTAllocHelper::DoRunL()
+	{
+	LeaveIfErr(iAlloc.Open(&User::Allocator()), _L("Couldn't open RAllocatorHelper"));
+	iAllocations.ReserveL(128);
+
+	Printf(_L("Udeb allocator=%d\r\n"), iAlloc.AllocatorIsUdeb());
+
+	PrintStats(_L("Initial stats"));
+	// And do an RHeap walk, just to compare
+	User::Allocator().DebugFunction(128, (TAny*)&RHeapWalkCallback, this);
+	Printf(_L("allocated size according to RHeap::Walk: %d\r\n"), iAllocationsAccordingToRHeapWalker);
+
+	AllocL(64*1024);
+	PrintStats(_L("Stats after 1 64K alloc"));
+	User::Allocator().DebugFunction(128, (TAny*)&RHeapWalkCallback, this); // debug
+
+
+	AllocL(4, 50);
+	PrintStats(_L("Stats after 50 small allocs"));
+
+	/*
+	// Open a new RAllocatorHelper cos the stats will be cached otherwise
+	RAllocatorHelper h; h.Open(&User::Allocator());
+	iAllocationsAccordingToRHeapWalker = 0;
+	User::Allocator().DebugFunction(128, (TAny*)&RHeapWalkCallback, this);
+	Printf(_L("allocated size according to RHeap::Walk: %d\r\n"), iAllocationsAccordingToRHeapWalker);
+	Printf(_L("iTotalAllocSize is %d\r\n"), h.AllocatedSize());
+	h.Close();
+	*/
+
+	if (!iWaitOnExit)
+		{
+		Free(50);
+		PrintStats(_L("Stats after freeing them"));
+		Complete();
+		}
+	}
+
+void CCmdTAllocHelper::PrintStats(const TDesC& aDesc)
+	{
+	iAlloc.RefreshDetails();
+	TBuf<16> allocSize, freeSize, dlaSize, slabSize, freeDlaSize, partiallyFreeSlabSize, freeSlabSize, pageSize;
+	FormatSize(allocSize, iAlloc.SizeForCellType(RAllocatorHelper::EAllocationMask));
+	FormatSize(freeSize, iAlloc.SizeForCellType(RAllocatorHelper::EFreeMask));
+	FormatSize(dlaSize, iAlloc.SizeForCellType(RAllocatorHelper::EDlaAllocation));
+	FormatSize(slabSize, iAlloc.SizeForCellType(RAllocatorHelper::ESlabAllocation));
+	FormatSize(freeDlaSize, iAlloc.SizeForCellType(RAllocatorHelper::EDlaFreeCell));
+	FormatSize(partiallyFreeSlabSize, iAlloc.SizeForCellType(RAllocatorHelper::ESlabFreeCell));
+	FormatSize(freeSlabSize, iAlloc.SizeForCellType(RAllocatorHelper::ESlabFreeSlab));
+	FormatSize(pageSize, iAlloc.SizeForCellType(RAllocatorHelper::EPageAllocation));
+
+	Printf(_L("\r\n%S:\r\n\
+Alloc: %d (%S), DLA: %d (%S) Slab: %d (%S) Paged: %d (%S)\r\n\
+Free: %d (%S), DLA: %d (%S) Slab: %d (%S) Free slabs: %d (%S)\r\n"), 
+		&aDesc, iAlloc.AllocationCount(), &allocSize,
+		iAlloc.CountForCellType(RAllocatorHelper::EDlaAllocation), &dlaSize,
+		iAlloc.CountForCellType(RAllocatorHelper::ESlabAllocation), &slabSize,
+		iAlloc.CountForCellType(RAllocatorHelper::EPageAllocation), &pageSize,
+		iAlloc.CountForCellType(RAllocatorHelper::EFreeMask), &freeSize,
+		iAlloc.CountForCellType(RAllocatorHelper::EDlaFreeCell), &freeDlaSize,
+		iAlloc.CountForCellType(RAllocatorHelper::ESlabFreeCell), &partiallyFreeSlabSize,
+		iAlloc.CountForCellType(RAllocatorHelper::ESlabFreeSlab), &freeSlabSize
+		);
+
+	iAlloc.Walk(&WalkCallback, this); // Check cell lengths match up
+	}
+
+void CCmdTAllocHelper::AllocL(TInt aSize, TInt aNumber)
+	{
+	while (aNumber--)
+		{
+		TAny* result = User::AllocL(aSize);
+		TInt err = iAllocations.Append(result);
+		if (err)
+			{
+			User::Free(result);
+			User::Leave(KErrNoMemory);
+			}
+		}
+	}
+
+void CCmdTAllocHelper::Free(TInt aNumber)
+	{
+	while (aNumber--)
+		{
+		TInt i = iAllocations.Count() - 1;
+		User::Free(iAllocations[i]);
+		iAllocations.Remove(i);
+		}
+	}
+
+void CCmdTAllocHelper::FormatSize(TDes& aBuf, TInt64 aSize)
+	{
+	if (iBytes)
+		{
+		aBuf.Num(aSize);
+		}
+	else
+		{
+		LtkUtils::FormatSize(aBuf, aSize);
+		}
+	}
+
+TBool CCmdTAllocHelper::WalkCallback(RAllocatorHelper& /*aAlloc*/, TAny* aContext, RAllocatorHelper::TExtendedCellType aType, TLinAddr aAddress, TInt aLength)
+	{
+	if (aType & RAllocatorHelper::EAllocationMask)
+		{
+		TInt lenFromAllocLen = User::AllocLen((TAny*)aAddress);
+		if (lenFromAllocLen != aLength)
+			{
+			static_cast<CCmdTAllocHelper*>(aContext)->PrintWarning(_L("Walker reports cell 0x%08x size %d but AllocLen says %d\r\n"), aAddress, aLength, lenFromAllocLen);
+			}
+		}
+
+	return ETrue; // Keep walking
+	}
+
+void CCmdTAllocHelper::RHeapWalkCallback(TAny* aContext, RHeap::TCellType aType, TAny* aCell, TInt aLength)
+	{
+	if (aType == RHeap::EGoodAllocatedCell)
+		{
+		CCmdTAllocHelper* self = static_cast<CCmdTAllocHelper*>(aContext);
+		self->iAllocationsAccordingToRHeapWalker += aLength;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tallochelper.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// tallochelper.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			tallochelper.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE 0
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			tallochelper.cpp
+
+library			euser.lib
+library			iocli.lib
+library			ltkutils.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/test1.idf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+# test1.idf
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Description:
+# Test Ini Description File
+
+integer			integer
+integer.name		An integer value
+integer.description	Something to test parsing of integers
+
+string			string
+string.name		A string
+string.description	A setting to text string handling
+
+file			filename
+file.name		A filename
+file.description	In order to test filename handing
+
+opt			enum
+opt.name		An enumeration
+opt.description		An option, yes or no
+opt.values		yes,no
+
+bool			boolean
+bool.name		A boolean
+bool.description	A test for boolean values
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/test1.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+#!iniedit -i \resource\test1.idf
+# test1.ini
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+integer	1
+string	hello
+file	c:\file.ext
+opt	y
+bool	true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/test2.idf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+# test2.idf
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Description:
+# Test Ini Description File
+
+options		enum
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/test2.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+#!iniedit -i \resource\test1.idf
+# test2.ini
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+integer	invalid
+string	hello
+file	c:\file.ext
+opt	y
+bool	1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/test3.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+#!iniedit -i \resource\test1.idf
+# test3.ini
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+integer	1
+string	hello
+file	c:\file.ext
+opt	fooey
+boolean no
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/test4.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+#!iniedit -i \resource\test1.idf
+# test4.ini
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+integer	1
+string	hello
+file	c:\file.ext
+opt	y
+string	redefined
+boolean 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/test5.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1 @@
+#!iniedit -i \resource\test2.idf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/test6.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+#!iniedit -i \resource\test1.idf
+# test6.ini
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+integer	1
+string	hello
+file	c:\file.ext
+opt	y
+bool	nope
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tset.script	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+#!fshell
+# tset.script
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+export REPORT_FAILURE "echo FAILED $SCRIPT_NAME:$SCRIPT_LINE^^n"
+export TO_NUL "2>&1 >NUL"
+tsettings read c:\test1.ini			$TO_NUL || $REPORT_FAILURE
+tsettings read c:\test2.ini 			$TO_NUL || $REPORT_FAILURE
+tsettings read c:\test3.ini 			$TO_NUL || $REPORT_FAILURE
+tsettings read c:\test4.ini 			$TO_NUL || $REPORT_FAILURE
+tsettings read c:\test5.ini 			$TO_NUL || $REPORT_FAILURE
+tsettings read c:\test6.ini 			$TO_NUL || $REPORT_FAILURE
+tsettings validate c:\test1.ini			$TO_NUL || $REPORT_FAILURE
+tsettings validate c:\test2.ini 		$TO_NUL && $REPORT_FAILURE
+tsettings validate c:\test3.ini			$TO_NUL && $REPORT_FAILURE
+tsettings validate c:\test4.ini			$TO_NUL && $REPORT_FAILURE
+tsettings validate c:\test5.ini			$TO_NUL && $REPORT_FAILURE
+tsettings validate c:\test6.ini			$TO_NUL && $REPORT_FAILURE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tsettings.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,134 @@
+// tsettings.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/settings.h>
+
+using namespace IoUtils;
+using namespace LtkUtils;
+
+class CCmdTSettings : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTSettings();
+private:
+	CCmdTSettings();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	enum 
+		{
+		ERead,
+		EValidate,
+		ERewrite,
+		} iTest;
+	TFileName2 iFilename;
+	
+	CIniReader* iReader;
+	CIniFile* iValidator;
+	};
+
+_LIT(KTests, "read,validate,rewrite");
+
+
+CCommandBase* CCmdTSettings::NewLC()
+	{
+	CCmdTSettings* self = new(ELeave) CCmdTSettings();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTSettings::~CCmdTSettings()
+	{
+	delete iReader;
+	delete iValidator;
+	}
+
+CCmdTSettings::CCmdTSettings()
+	{
+	}
+
+const TDesC& CCmdTSettings::Name() const
+	{
+	_LIT(KName, "tsettings");	
+	return KName;
+	}
+
+const TDesC& CCmdTSettings::Description() const
+	{
+	_LIT(KDescription, "Test command for LTK utils settings classes.");
+	return KDescription;
+	}
+
+void CCmdTSettings::DoRunL()
+	{
+	switch (iTest)
+		{
+	case ERead:
+		{
+		iReader = CIniReader::NewL(iFilename);
+		RPointerArray<CValue> values;
+		CleanupClosePushL(values);
+		iReader->GetValuesL(values);
+		for (TInt i=0; i<values.Count(); ++i)
+			{
+			Printf(_L("%S=%S\n"), &values[i]->Id(), &values[i]->Value());
+			}		
+		CleanupStack::PopAndDestroy(&values);
+		break;
+		}
+	case EValidate:
+		{
+		iValidator = CIniFile::NewL(iFilename);
+		RPointerArray<CValue> values;
+		CleanupClosePushL(values);
+		iValidator->GetValuesL(values);
+		for (TInt i=0; i<values.Count(); ++i)
+			{
+			Printf(_L("%S=%S\n"), &values[i]->Id(), &values[i]->Value());
+			}		
+		CleanupStack::PopAndDestroy(&values);
+		break;
+		}
+	case ERewrite:
+		{
+		iReader = CIniReader::NewL(iFilename);
+		WriteIniFileL(iFilename, *iReader);
+		break;
+		}
+		};
+	}
+
+void CCmdTSettings::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	_LIT(KTest, "test");
+	_LIT(KTestDescription, "Test to perform");
+	aArguments.AppendEnumL((TInt&)iTest, KTest, KTestDescription, KTests);
+	
+	_LIT(KIniFile, "inifile");
+	_LIT(KIniFileDescription, "The .ini file to test with");
+	aArguments.AppendFileNameL(iFilename, KIniFile, KIniFileDescription);
+	}
+
+void CCmdTSettings::OptionsL(RCommandOptionList& /*aOptions*/)
+	{
+	}
+
+
+EXE_BOILER_PLATE(CCmdTSettings)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tsettings.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// tsettings.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/fsh_system_include.mmh>
+
+target          tsettings.exe
+targettype      exe
+uid             0x102835BE 0x1028719a
+
+userinclude     .
+
+sourcepath      .
+source          tsettings.cpp
+
+library         euser.lib
+library         iocli.lib
+library			ltkutils.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tstringhash.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,118 @@
+// tstringhash.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/stringhash.h>
+
+using namespace IoUtils;
+using LtkUtils::RStringHash;
+using LtkUtils::TStringHashIter;
+
+class CCmdTstringhash : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdTstringhash();
+private:
+	CCmdTstringhash();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	};
+
+
+CCommandBase* CCmdTstringhash::NewLC()
+	{
+	CCmdTstringhash* self = new(ELeave) CCmdTstringhash();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdTstringhash::~CCmdTstringhash()
+	{
+	}
+
+CCmdTstringhash::CCmdTstringhash()
+	{
+	}
+
+const TDesC& CCmdTstringhash::Name() const
+	{
+	_LIT(KName, "tstringhash");	
+	return KName;
+	}
+
+const TDesC& CCmdTstringhash::Description() const
+	{
+	// ToDo: Write description text.
+	_LIT(KDescription, "To do.");
+	return KDescription;
+	}
+
+void CCmdTstringhash::ArgumentsL(RCommandArgumentList&)
+	{
+	}
+
+void CCmdTstringhash::OptionsL(RCommandOptionList&)
+	{
+	}
+
+
+EXE_BOILER_PLATE(CCmdTstringhash)
+
+void CCmdTstringhash::DoRunL()
+	{
+	RStringHash<TInt> hash;
+	CleanupClosePushL(hash);
+
+	TInt err = hash.Insert(_L("test"), 1);
+
+	LeaveIfErr(err, _L("Failed to insert item"));
+
+	TInt* res = hash.Find(_L("test"));
+
+	if (!res) LeaveIfErr(KErrGeneral, _L("Failed to find item"));
+	if (*res != 1) LeaveIfErr(KErrGeneral, _L("item returned %d instead of 1"), *res);
+
+	TInt n = 100;
+	while (n--)
+		{
+		hash.InsertL(_L("test"), n);
+		}
+
+	hash.ReserveL(100);
+
+	hash.InsertL(_L("a"), 6);
+	hash.InsertL(_L("b"), 6);
+	hash.InsertL(_L("aasdfasdf"), 66666666);
+	hash.InsertL(_L("lalala"), 66666);
+	hash.InsertL(_L("qqq"), 666);
+	hash.InsertL(_L(""), 0);
+	hash.InsertL(_L("12345"), 54321);
+
+	TStringHashIter<TInt> iter(hash);
+	while (iter.NextValue() != NULL)
+		{
+		const TDesC* k = iter.CurrentKey();
+		const TInt* v = iter.CurrentValue();
+		Printf(_L("Key %S has value %d\r\n"), k, *v);
+		}
+
+	CleanupStack::PopAndDestroy(&hash);
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tstringhash.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// tstringhash.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          tstringhash.exe
+targettype      exe
+uid             FSHELL_UID2_FSHELL_EXE 0x10272F03
+
+userinclude     .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      .
+source          tstringhash.cpp
+
+library         euser.lib
+library         iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tutf8.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,205 @@
+// tutf8.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#include <fshell/descriptorutils.h>
+
+using namespace IoUtils;
+using namespace LtkUtils;
+
+class CCmdtutf8 : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdtutf8();
+private:
+	CCmdtutf8();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	TFileName2 iFile;
+	TInt iBlockSize;
+	};
+
+EXE_BOILER_PLATE(CCmdtutf8)
+
+CCommandBase* CCmdtutf8::NewLC()
+	{
+	CCmdtutf8* self = new(ELeave) CCmdtutf8();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdtutf8::~CCmdtutf8()
+	{
+	}
+
+CCmdtutf8::CCmdtutf8()
+	{
+	}
+
+const TDesC& CCmdtutf8::Name() const
+	{
+	_LIT(KName, "tutf8");	
+	return KName;
+	}
+
+const TDesC& CCmdtutf8::Description() const
+	{
+	_LIT(KDescription, "Test for RLtkBuf8::CopyAsUtf8L() and RLtkBuf16::AppendUtf8L().");
+	return KDescription;
+	}
+
+void CCmdtutf8::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendFileNameL(iFile, _L("filename"), _L("If specified, parse this file as UTF-8 and print the results"), KValueTypeFlagOptional);
+	}
+
+void CCmdtutf8::OptionsL(RCommandOptionList& aOptions)
+	{
+	aOptions.AppendIntL(iBlockSize, 'b', _L("blocksize"), _L("block size for parsing the specified file"));
+	}
+
+void CCmdtutf8::DoRunL()
+	{
+	if (iFile.Length() == 0)
+		{
+		CleanupStack::PushL((CBase*)1); // Panicker
+		_LIT(KTest, "A \u03A9 \u8A9E \uFFFD \uFEFF \uD800 "); // The original UTF-16 string: A LowercaseOmega SomeGlyphOrOther ReplacementChar ZWNBSP UnmatchedLeadingSurrogate
+		_LIT8(KOut, "A \xCE\xA9 \xE8\xAA\x9E \xEF\xBF\xBD \xEF\xBB\xBF \xEF\xBF\xBD "); // What it should be in UTF-8
+		_LIT(KOutInUnicode, "A \u03A9 \u8A9E \uFFFD \uFEFF \uFFFD "); // Almost the same as the original, except that the UnmatchedSurrogate was transformed into ReplacementChar in UTF-8 so the last char here is U+FFFD
+		RLtkBuf8 buf;
+		buf.CopyAsUtf8L(KTest);
+		ASSERT(buf == KOut());
+		buf.Close();
+
+		RLtkBuf16 wbuf;
+		wbuf.AppendUtf8L(KOut().Left(6));
+		ASSERT(wbuf.Length() == 4); // Testing that only the 4 complete characters are in there
+		wbuf.AppendUtf8L(KNullDesC8());
+		ASSERT(wbuf.Length() == 4); // Testing that appending a null descriptor hasn't changed the length (or crashed)
+		TInt firstprob;
+		wbuf.FinalizeUtf8(firstprob);
+		ASSERT(firstprob == 5); // Correctly indentified the first invalid bit
+		_LIT(KFirstFrag, "A \u03A9 \uFFFD");
+		ASSERT(wbuf == KFirstFrag());
+		wbuf.SetLength(4);
+		wbuf.AppendUtf8L(KOut().Mid(5,1));
+		wbuf.ReAllocL(256); // Be really evil and realloc the buffer while we have fragmented bytes cached
+		ASSERT(wbuf == KOutInUnicode().Left(4));
+		wbuf.AppendUtf8L(KOut().Mid(6,1));
+		ASSERT(wbuf == KOutInUnicode().Left(4));
+		wbuf.AppendUtf8L(KOut().Mid(7,3));
+		ASSERT(wbuf == KOutInUnicode().Left(6));
+		wbuf.AppendUtf8L(KOut().Mid(10));
+		ASSERT(wbuf == KOutInUnicode());
+		wbuf.FinalizeUtf8(firstprob);
+		ASSERT(firstprob == KErrNotFound);
+		wbuf.Close();
+
+		_LIT8(KBomTest, "\xEF\xBB\xBF BB \xEF\xBB\xBF");
+		_LIT(KBomOutput, " BB \uFEFF");
+		wbuf.AppendUtf8L(KBomTest);
+		wbuf.FinalizeUtf8(firstprob);
+		ASSERT(wbuf == KBomOutput());
+		ASSERT(firstprob == KErrNotFound);
+		wbuf.Close();
+
+		wbuf.AppendUtf8L(KBomTest().Left(2));
+		wbuf.AppendUtf8L(KBomTest().Mid(2, 5));
+		wbuf.AppendUtf8L(KBomTest().Mid(7));
+		wbuf.FinalizeUtf8(firstprob);
+		ASSERT(wbuf == KBomOutput());
+		ASSERT(firstprob == KErrNotFound);
+		wbuf.Close();
+
+		// Maximal subexpression replacement test - Example taken from unicode standard section 3.9, table 3-8.
+		_LIT8(KInvalid, "\x61\xF1\x80\x80\xE1\x80\xC2\x62\x80\x63\x80\xBF\x64");
+		_LIT(KInvalidOutput, "\u0061\uFFFD\uFFFD\uFFFD\u0062\uFFFD\u0063\uFFFD\uFFFD\u0064"); // And this is how the standard recommends it is processed
+		wbuf.AppendUtf8L(KInvalid);
+		wbuf.FinalizeUtf8(firstprob);
+		ASSERT(wbuf == KInvalidOutput());
+		ASSERT(firstprob == 1);
+		wbuf.Close();
+
+		// Check that the first bad byte calculations are right
+		wbuf.AppendUtf8L(_L8(" \x61\xF1"), firstprob);
+		ASSERT(firstprob == KErrNotFound); // F1 is potentially valid
+		wbuf.AppendUtf8L(_L8("\x80\x80\xE1"), firstprob);
+		ASSERT(firstprob == 0); // Technically it's the -1th byte of what we just passed in, but we can only say zero
+		wbuf.FinalizeUtf8(firstprob);
+		ASSERT(firstprob == 2); // The overall first invalid byte was byte 1, the 0xF1
+		wbuf.Close();
+		CleanupStack::Pop(); // Panicker
+		}
+	else
+		{
+		RFile file;
+		LeaveIfErr(file.Open(FsL(), iFile, EFileRead), _L("Couldn't open file %S"), &iFile);
+		CleanupClosePushL(file);
+		TInt fileSize;
+		LeaveIfErr(file.Size(fileSize), _L("Couldn't get file size"));
+		RBuf8 nbuf;
+		nbuf.CreateL(iBlockSize ? iBlockSize : fileSize);
+		CleanupClosePushL(nbuf);
+		RLtkBuf buf;
+		CleanupClosePushL(buf);
+		TInt read = 0;
+		while (read < fileSize)
+			{
+			nbuf.Zero();
+			LeaveIfErr(file.Read(nbuf), _L("Couldn't read file"));
+			read += nbuf.Length();
+			buf.Zero();
+			buf.AppendUtf8L(nbuf);
+			Write(buf);
+			}
+		TInt unconverted;
+		buf.FinalizeUtf8(unconverted);
+		Printf(_L("First bad byte: %d\r\n"), unconverted);
+		Write(buf);
+
+		CleanupStack::PopAndDestroy(3, &file); // buf, nbuf, file
+		}
+	}
+
+/*
+This turned out to not actually make much difference, but it might be useful in future...
+
+static const TInt8 KFirstByteSequenceLengths[] = { // 40 chars per line
+	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
+	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
+	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
+	1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 
+	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
+	4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	};
+__ASSERT_COMPILE(sizeof(KFirstByteSequenceLengths) == 256);
+ASSERT(KFirstByteSequenceLengths[0x7F] == 1);
+ASSERT(KFirstByteSequenceLengths[0x80] == 0);
+ASSERT(KFirstByteSequenceLengths[0xC1] == 0);
+ASSERT(KFirstByteSequenceLengths[0xC2] == 2);
+ASSERT(KFirstByteSequenceLengths[0xDF] == 2);
+ASSERT(KFirstByteSequenceLengths[0xE0] == 3);
+ASSERT(KFirstByteSequenceLengths[0xEF] == 3);
+ASSERT(KFirstByteSequenceLengths[0xF0] == 4);
+ASSERT(KFirstByteSequenceLengths[0xF4] == 4);
+ASSERT(KFirstByteSequenceLengths[0xF5] == 0);
+ASSERT(KFirstByteSequenceLengths[0xFF] == 0);
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/ltkutils/tsrc/tutf8.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// tutf8.mmp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			tutf8.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE 0
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			tutf8.cpp
+
+library			euser.lib
+library			iocli.lib
+library			ltkutils.lib
+library			efsrv.lib
+
+EPOCHEAPSIZE	0x100000 0x1000000 // Cope with big files
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/DynamicDfcSupport.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,92 @@
+// DynamicDfcSupport.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "DynamicDfcSupport.h"
+
+#ifdef FSHELL_DYNAMICDFC_SUPPORT
+
+TInt TDynDfcQueWrapper::Create(TDynDfcQueWrapper*& aDfcQ, TInt aPriority, const TDesC& aBaseName)
+	{
+	TDynDfcQueWrapper* wrapper = new TDynDfcQueWrapper;
+	if (!wrapper) return KErrNoMemory;
+	TInt err = Kern::DynamicDfcQCreate(wrapper->iQueue, aPriority, aBaseName);
+	if (err)
+		{
+		delete wrapper;
+		}
+	else
+		{
+		aDfcQ = wrapper;
+		}
+	return err;
+	}
+
+void TDynDfcQueWrapper::Destroy()
+	{
+	delete this;
+	}
+
+TDynDfcQueWrapper::TDynDfcQueWrapper()
+	: iQueue(NULL)
+	{}
+
+TDynDfcQueWrapper::~TDynDfcQueWrapper()
+	{
+	iQueue->Destroy();
+	}
+
+#else
+
+TDynDfcQueWrapper::TDynDfcQueWrapper()
+	: iQueue(NULL), iKillDfc(ExitDfcThread, this, 7)
+	{}
+
+TInt TDynDfcQueWrapper::Create(TDynDfcQueWrapper*& aDfcQ, TInt aPriority, const TDesC& aBaseName)
+	{
+	TDynDfcQueWrapper* wrapper = new TDynDfcQueWrapper;
+	TInt nonce = 0;
+	TInt ret;
+	do
+		{
+		TBuf<64> buf;
+		buf.Copy(aBaseName);
+		buf.Append('-');
+		buf.AppendNum(nonce);
+		nonce++;
+		ret = Kern::DfcQCreate(wrapper->iQueue, aPriority, &buf);
+		} while (ret == KErrAlreadyExists);
+
+	if (ret == KErrNone)
+		{
+		wrapper->iKillDfc.SetDfcQ(wrapper->iQueue);
+		aDfcQ = wrapper;
+		}
+
+	return ret;
+	}
+
+void TDynDfcQueWrapper::Destroy()
+	{
+	iKillDfc.Enque(); 
+	}
+
+TDynDfcQueWrapper::~TDynDfcQueWrapper()
+	{
+	delete iQueue;
+	}
+
+void TDynDfcQueWrapper::ExitDfcThread(TAny* aSelf)
+	{
+	delete (TDynDfcQueWrapper*)aSelf;
+	Kern::Exit(KErrNone);
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/DynamicDfcSupport.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+// DynamicDfcSupport.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef DYNAMICDFCSUPPORT_H
+#define DYNAMICDFCSUPPORT_H
+
+#include <kernel.h>
+#include <fshell/common.mmh>
+
+#ifdef FSHELL_DYNAMICDFC_SUPPORT
+
+class TDynDfcQueWrapper
+	{
+public:
+	static TInt Create(TDynDfcQueWrapper*& aDfcQ, TInt aPriority, const TDesC& aBaseName);
+	void Destroy();
+	TDfcQue* Que() const { return iQueue; }
+
+private:
+	TDynDfcQueWrapper();
+	~TDynDfcQueWrapper();
+
+private:
+	TDynamicDfcQue* iQueue;
+	};
+
+#else
+
+class TDynDfcQueWrapper
+	{
+public:
+	static TInt Create(TDynDfcQueWrapper*& aDfcQ, TInt aPriority, const TDesC& aBaseName);
+	void Destroy();
+	TDfcQue* Que() const { return iQueue; }
+
+private:
+	TDynDfcQueWrapper();
+	~TDynDfcQueWrapper();
+	static void ExitDfcThread(TAny* aPtr);
+
+private:
+	TDfcQue* iQueue;
+	TDfc iKillDfc;
+	};
+
+#endif // FSHELL_DYNAMICDFC_SUPPORT
+
+#endif // DYNAMICDFCSUPPORT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/MemoryAccess.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3067 @@
+// MemoryAccess.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+//#include <m32std.h>
+#include <nkern.h>
+#include <kernel.h>
+#include <kern_priv.h>
+
+#include <fshell/common.mmh>
+
+#ifdef FSHELL_DOBJECTIX_SUPPORT
+#include "dobject.h" // To pick up my defn of DObjectIx/DObjectIxNinePointOneHack
+#endif
+
+#include <e32cmn.h>
+#include "memoryaccess.h"
+#include "PropertyAccess.h"
+#include "fdebuggerkernel.h"
+#include "DynamicDfcSupport.h"
+
+//define this to get log output
+/*#define DO_LOGGING
+
+#ifdef DO_LOGGING
+	#define DO_LOG(X) X
+#else
+	#define DO_LOG(X)
+#endif */
+
+const TInt KLocalBufferSize=4096;
+
+const TInt KMajorVersionNumber=1;
+const TInt KMinorVersionNumber=0;
+const TInt KBuildVersionNumber=0;
+_LIT(KMemAccessPanicCategory,"MemAccess");
+enum TMemAccessPanic
+	{
+	EMemAccessPanicBadContainerType,
+	EMemAccessMutexAlreadyHeld,
+	EMemAccessMutexNotHeld
+	};
+
+class DMemoryAccess;
+
+// DMemoryAccessFactory
+//
+NONSHARABLE_CLASS(DMemoryAccessFactory) : public DLogicalDevice
+    {
+public:
+    DMemoryAccessFactory();
+	~DMemoryAccessFactory();
+
+	TInt GetEventHandler(DDebuggerEventHandler*& aResult);
+	TInt GetDfcQue(TDfcQue*& aResult);
+	
+private:
+    TInt Install();                     //overriding pure virtual
+    void GetCaps(TDes8& aDes) const;    //overriding pure virtual
+    TInt Create(DLogicalChannelBase*& aChannel);         //overriding pure virtual
+	void Lock();
+	void Unlock();
+
+private:
+	DDebuggerEventHandler* iSharedEventHandler;
+	TDynDfcQueWrapper* iDfcQueWrapper;
+	NFastMutex iLock;
+    };
+
+
+// DECLARE_STANDARD_LDD
+//  Standard Extension Framework export
+DECLARE_STANDARD_EXTENSION()
+	{
+	return KErrNone;
+	}
+
+DECLARE_EXTENSION_LDD()
+	{
+	return new DMemoryAccessFactory();
+	}
+
+class DThreadChangeHandler;
+class DMsgQueue;
+
+// DMemoryAccess
+//
+NONSHARABLE_CLASS(DMemoryAccess) : public DLogicalChannel, public MDebuggerEventClient
+    {
+public:
+    DMemoryAccess();
+    ~DMemoryAccess();
+private:
+//Framework
+    TInt DoCreate(TInt aUnit,const TDesC* anInfo,const TVersion& aVer);
+	void HandleMsg(TMessageBase* aMsg);
+    void DoCancel(TInt aReqNo);
+    TInt DoRequest(TInt aReqNo,TRequestStatus aStatus,TAny* a1,TAny* a2);
+    TInt DoControl(TInt aFunction,TAny *a1,TAny *a2);
+//API
+    TInt GetThreadMem(TAny* aParams, TAny* aBuf);
+    TInt GetAllocatorAddress(TUint aId, TUint8*& aAddr, TBool aGetCurrentAllocator=EFalse); //TOMSCI If false, get the created allocator. If true, get the current one
+	TInt GetContainerCount(const TObjectType aObjectType, TUint& aCount);
+	TInt AcquireContainerMutex(const TObjectType aObjectType);
+	TInt ReleaseContainerMutex(const TObjectType aObjectType);
+	TInt GetObjectType(TUint8* aObjectPtr, TObjectType& aType);
+	TInt GetObjectInfo(TObjectType aObjectType, TInt aObjectIndexInContainer, TDes8* aKernelInfoBuf);
+	TInt GetObjectInfoByPtr(TObjectType aObjectType, TUint8* aObjectPtr, TDes8* aKernelInfoBuf);
+	TInt GetObjectInfoByName(TObjectType aObjectType, const TDesC8& aObjectName, TDes8* aKernelInfoBuf);
+	TInt GetObjectInfoByHandle(TObjectType aObjectType, TInt aThreadId, TInt aObjectHandle, TDes8* aKernelInfoBuf);
+	TInt GetObjectAddresses(TObjectType aObjectType, const TDesC8& aOwningProcess, TDes8* aKernelInfoBuf);
+	TInt GetChunkAddresses(TUint aControllingProcessId, TDes8* aKernelInfoBuf);
+	TInt AcquireCodeSegMutex();
+	TInt ReleaseCodeSegMutex();
+	TInt GetNextCodeSegInfo(TDes8* aCodeSegInfoBuf);
+	TInt ObjectDie(TObjectKillParamsBuf& aObjectKillParamsBuf);
+	TInt FindPtrInCodeSegments(TAny* aDllNamePtr, TAny* aPtr);
+	TInt GetHandleOwners(TAny* aObj, TAny* aOwnersBuf);
+	TInt GetThreadHandles(TInt aThreadId, TAny* aHandlesBuf);
+	TInt GetProcessHandles(TInt aProcessId, TAny* aHandlesBuf);
+	TInt SetThreadPriority(TInt aThreadHandle, TInt aPriority);
+	void NotifyThreadCreation(TRequestStatus* aStatus);
+	void CancelNotifyThreadCreation();
+	TInt SetPriorityOverride(TInt aPriority, TAny* aMatchString);
+	TInt SetCriticalFlags(TInt aThreadHandle, TUint aFlags);
+	TInt OpenThread(TUint aTid);
+//Helpers
+	void GetObjectInfo(DObject* aObject, TObjectKernelInfo& aInfo);
+	TInt GetObjectPositionInContainer(TUint8* aObjectPtr, DObjectCon& aContainer, TInt& aPosInContainer);
+	TInt GetThreadInfo(DThread* aThread, TDes8* aThreadInfoBuf);
+	TInt GetProcessInfo(DProcess* aProcess, TDes8* aProcessInfoBuf);
+	TInt GetChunkInfo(DChunk* aChunk, TDes8* aChunkInfoBuf);
+	TInt GetLibraryInfo(DLibrary* aLibrary, TDes8* aLibraryInfoBuf);
+	TInt GetSemaphoreInfo(DSemaphore* aSemaphore, TDes8* aLibraryInfoBuf);
+	TInt GetMutexInfo(DMutex* aMutex, TDes8* aLibraryInfoBuf);
+	TInt GetTimerInfo(DTimer* aTimer, TDes8* aTimerInfoBuf);
+	TInt GetServerInfo(DServer* aServer, TDes8* aServerInfoBuf);
+	TInt GetSessionInfo(DSession* aSession, TDes8* aSessionInfoBuf);
+	TInt GetLogicalDeviceInfo(DLogicalDevice* aLogicalDevice, TDes8* aLogicalDeviceInfoBuf);
+	TInt GetPhysicalDeviceInfo(DPhysicalDevice* aPhysicalDevice, TDes8* aPhysicalDeviceInfoBuf);
+	TInt GetLogicalChannelInfo(DLogicalChannel* aLogicalChannel, TDes8* aLogicalChannelInfoBuf);
+	TInt GetChangeNotifierInfo(DChangeNotifier* aChangeNotifier, TDes8* aChangeNotifierInfoBuf);
+	TInt GetUndertakerInfo(DUndertaker* aUndertaker, TDes8* aUndertakerInfoBuf);
+	TInt GetMsgQueueInfo(DMsgQueue* aMsgQueue, TDes8* aMsgQueueInfoBuf);
+//	TInt GetPropertyRefInfo(DPropertyRef* aPropertyRef, TDes8* aPropertyRefInfoBuf);
+	TInt GetCondVarInfo(DCondVar* aCondVar, TDes8* aCondVarInfoBuf);
+	TInt InPlaceObjectRename(TAny* aParamsBuf, TAny* aNewNamePtr);
+	TInt InPlaceSetProcessFileName(TAny* aParamsBuf, TAny* aNewNamePtr);
+	TLinAddr DoGetAllocatorAddress(DThread* aThread, TBool aGetCurrent);
+	TInt EnableHeapTracing(TUint aThreadId, TBool aEnable);
+	TInt DefragRam(TInt aPriority);
+	TInt EmptyRamZone(TInt aPriority, TUint aZone);
+	TInt GetRamZoneInfo(TUint aZone, TAny* aInfoPkg);
+	TInt SetProcessProperties(TInt aProcessHandle, TAny* aProperties);
+	TInt WriteShadowMemory(TLinAddr aAddress, TAny* aNewContents);
+	TInt FreeShadowMemory(TLinAddr aAddress, TInt aLength);
+	TInt DebuggerFn(TInt aFn, TAny* a1, TAny* a2);
+	TInt GetRegisters(TAny* a1, TAny* /*a2*/);
+	DThread* ThreadFromHandle(TInt aHandle);
+
+
+private: // From MDebuggerEventClient
+	void BreakpointHit(TDes& aPkg);
+
+private:
+	DThread* iClient;
+	TBool iLocks[ENumObjectTypes];
+	TBool iCodeSegLock;
+	DCodeSeg* iCurrentCodeSeg;
+	DThreadChangeHandler* iEventHandler;
+	DPropertyAccess* iPropertyAccess;
+	TAny* iClientBreakpointNotifyPkg;
+	TRequestStatus* iClientBreakpointNotifyStatus;
+	};
+
+
+NONSHARABLE_CLASS(DThreadChangeHandler) : public DKernelEventHandler
+	{
+public:
+	DThreadChangeHandler(DThread* aClientThread);
+	~DThreadChangeHandler();
+	static TUint Event(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aPrivateData);
+	TUint DoEvent(TKernelEvent aEvent, TAny* a1, TAny* a2);
+	void SetStatus(TRequestStatus* aStatus);
+
+private:
+	DThread* iThread;
+	TRequestStatus* iStatus;
+public:
+	TBuf8<256> iMatch;
+	TInt iPriorityToSet;
+	};
+
+// class DMemoryAccessFactory Implementation
+
+//
+//
+DMemoryAccessFactory::DMemoryAccessFactory()
+	{
+    iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
+	}
+
+// DMemoryAccessFactory::Create
+//
+TInt DMemoryAccessFactory::Create(DLogicalChannelBase*& aChannel)
+    {
+    aChannel=new DMemoryAccess();
+	if (aChannel==NULL)
+		return KErrNoMemory;
+	else
+		return KErrNone;
+    }
+
+// DMemoryAccessFactory::Install
+//
+TInt DMemoryAccessFactory::Install()
+    {
+    TInt err = SetName(&KMemoryAccessName);
+	if (err == KErrNone)
+		{
+		DDebuggerEventHandler* dontCare;
+		err = GetEventHandler(dontCare); // We call this to make sure the event handler is always running, so we can track creator info asap
+		}
+	return err;
+    }
+
+// DMemoryAccessFactory::GetCaps
+//
+void DMemoryAccessFactory::GetCaps(TDes8& /*aDes*/) const
+    {
+/*    TCapsMemoryAccessV01 b;
+    b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
+    aDes.FillZ(aDes.MaxLength());
+    aDes.Copy((TUint8*)&b,Min(aDes.MaxLength(),sizeof(b)));
+*/    } 
+
+
+// class DMemoryAccess Implementation
+
+// Ctor
+//
+DMemoryAccess::DMemoryAccess()
+    : DLogicalChannel()
+    {
+    //SetBehaviour(-1); //JR
+    }
+
+
+const TInt KMemAccessDfcThreadPriority = 27;
+
+// DMemoryAccess::DoCreate
+//  Check capabilities & version & start listening for events
+TInt DMemoryAccess::DoCreate(TInt /*aUnit*/,const TDesC* /*anInfo*/,const TVersion& aVer)
+    {
+	TInt ret=KErrNone;
+	
+	//Require Power Management to use this driver
+	//Not ideal, but better than nothing
+	//if(!Kern::CurrentThreadHasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by MEMORYACCESS.LDD (Memory Access for Task Managers)")))
+	//    return KErrPermissionDenied;
+    
+    if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
+    	{
+    	return KErrNotSupported;
+    	}
+    iClient=&Kern::CurrentThread();
+	iClient->Open();
+
+	TDfcQue* q = NULL;
+	ret = ((DMemoryAccessFactory*)iDevice)->GetDfcQue(q);
+
+	if (ret == KErrNone)
+		{
+    	SetDfcQ(q);
+    	iMsgQ.Receive();		
+		}
+
+    return ret;
+    }
+
+TInt DMemoryAccessFactory::GetDfcQue(TDfcQue*& aQue)
+	{
+	Lock();
+	if (iDfcQueWrapper)
+		{
+		aQue = iDfcQueWrapper->Que();
+		Unlock();
+		return KErrNone;
+		}
+	Unlock(); // Can't hold a fast mutex around DFC q creation
+
+	TDynDfcQueWrapper* wrapper = NULL;
+	_LIT(KDfcThreadName, "MemoryAccess-fshell");
+	TInt ret = TDynDfcQueWrapper::Create(wrapper, KMemAccessDfcThreadPriority, KDfcThreadName);
+	
+	if (ret == KErrNone)
+		{
+		Lock();
+		if (iDfcQueWrapper)
+			{
+			// Someone beat us to it while we weren't holding the lock
+			aQue = iDfcQueWrapper->Que();
+			Unlock();
+			wrapper->Destroy();
+			}
+		else
+			{
+			iDfcQueWrapper = wrapper;
+			aQue = iDfcQueWrapper->Que();
+			Unlock();
+			}
+		}
+	return ret;
+	}
+
+
+// dtor
+//
+DMemoryAccess::~DMemoryAccess()
+    {
+    //Clean up any mutexes that have been left open
+	DObjectCon* const * cons = Kern::Containers();
+    for (TInt ii=0;ii<ENumObjectTypes;++ii)
+    	{
+    	if (iLocks[ii])
+    		{
+			DObjectCon* container = cons[ii];
+			container->Signal();
+    		}
+    	}
+
+	DMutex* const codeSegLock = Kern::CodeSegLock();
+
+    if (iCodeSegLock && codeSegLock)
+		{
+		Kern::MutexSignal(*codeSegLock);
+		}
+
+	if (iClientBreakpointNotifyStatus)
+		{
+		// Hmm I'm sure there are some threading subtleties here that I'm missing
+		DDebuggerEventHandler* handler = NULL;
+		TInt err = ((DMemoryAccessFactory*)iDevice)->GetEventHandler(handler);
+		if (!err) handler->UnregisterForBreakpointNotification(this);
+		Kern::RequestComplete(iClient, iClientBreakpointNotifyStatus, KErrCancel);
+		}
+
+	if (iEventHandler)
+		{
+		NKern::ThreadEnterCS();
+		iEventHandler->Close();
+		NKern::ThreadLeaveCS();
+		}
+
+	delete iPropertyAccess;
+	if (iClient)
+		{
+		iClient->Close(NULL);
+		}
+	}
+   
+// DMemoryAccess::HandleMsg
+//  Called when user side sends us something
+void DMemoryAccess::HandleMsg(TMessageBase* aMsg)
+	{
+    TThreadMessage& m=*(TThreadMessage*)aMsg;
+
+    // Get message type
+    TInt id=m.iValue;
+
+    // Decode the message type and dispatch it to the relevent handler function...
+    
+    // A logical channel can be closed either explicitly by its user-side client,
+    // or implicitly if the client thread dies. In the latter case, the channel
+    // is closed in the context of the kernel supervisor thread. 
+
+    if (id==(TInt)ECloseMsg)
+        {
+        // Channel Close
+		// We don't actually have any async requests
+        //DoCancel(RMemoryAccess::EAllRequests); //JR
+        m.Complete(KErrNone, EFalse);
+        return;
+        }
+
+    // For all other message types, we check that the message is from the thread
+    // that created us.
+    if(m.Client()!=iClient)
+        {
+        Kern::ThreadKill(m.Client(),EExitPanic,ERequestFromWrongThread,KMemAccessPanicCategory);
+        m.Complete(KErrNone,ETrue);
+        return;
+        }
+    if (id==KMaxTInt)
+        {
+        // DoCancel
+        DoCancel(m.Int0());
+        m.Complete(KErrNone,ETrue);
+        return;
+        }
+    if (id<0)
+        {
+        // DoRequest
+        TRequestStatus* pS=(TRequestStatus*)m.Ptr0();
+        TInt r=DoRequest(~id, *pS, m.Ptr1(), m.Ptr2());
+        if (r!=KErrNone)
+            Kern::RequestComplete(iClient,pS,r);
+        m.Complete(KErrNone,ETrue);
+        }
+    else
+        {
+        // DoControl
+        TInt r=DoControl(id,m.Ptr0(),m.Ptr1());
+        m.Complete(r,ETrue);
+        }	
+	}
+
+// DMemoryAccess::DoRequest
+//  Handles async messages, called from HandleMsg
+TInt DMemoryAccess::DoRequest(TInt /*aReqNo*/, TRequestStatus /*aStatus*/, TAny* /*a1*/, TAny* /*a2*/)
+    {
+    return KErrNone;
+    }
+
+// DMemoryAccess::DoCancel
+//  Cancels async messages, called from HandleMsg
+void DMemoryAccess::DoCancel(TInt /*aReqNo*/)
+    {
+    }
+
+// DMemoryAccess::DoControl
+//  Handles sync messages, called from HandleMsg
+TInt DMemoryAccess::DoControl(TInt aFunction, TAny* a1, TAny* a2)
+    {
+	// Kern::Printf("[DMemoryAccess] ::DoControl; Function: %d", aFunction);
+    switch (aFunction)
+        {
+    case RMemoryAccess::EControlGetThreadMem:
+        return GetThreadMem(a1, a2);
+    case RMemoryAccess::EControlGetAllocatorAddress:
+        return GetAllocatorAddress((TUint)a1, *(TUint8**)a2);
+    case RMemoryAccess::EControlGetCurrentAllocatorAddress:
+        return GetAllocatorAddress((TUint)a1, *(TUint8**)a2, ETrue);
+    case RMemoryAccess::EControlFindPtrInCodeSegments:
+		return FindPtrInCodeSegments(a1, a2);
+    case RMemoryAccess::EControlGetHandleOwners:
+		return GetHandleOwners(a1, a2);
+    case RMemoryAccess::EControlGetThreadHandles:
+		return GetThreadHandles((TUint)a1, a2);
+    case RMemoryAccess::EControlGetProcessHandles:
+		return GetProcessHandles((TUint)a1, a2);
+	case RMemoryAccess::EControlForceCrash:
+		Kern::Fault("ForceCrash-QR3", 0);
+		return KErrNone;
+	case RMemoryAccess::EControlReboot:
+		Kern::Restart((TInt)a1);
+		return KErrNone;
+	case RMemoryAccess::EControlGetPropertyInt:
+	case RMemoryAccess::EControlGetPropertyDesc:
+	case RMemoryAccess::EControlSetPropertyInt:
+	case RMemoryAccess::EControlSetPropertyDesc:
+	case RMemoryAccess::EControlDeleteProperty:
+	case RMemoryAccess::EControlPropertyNotify:
+	case RMemoryAccess::EControlPropertyNotifyCancel:
+	case RMemoryAccess::EControlSubscribeToProperty:
+		if (!iPropertyAccess)
+			{
+			iPropertyAccess = new DPropertyAccess(iClient);
+			}
+		if (!iPropertyAccess) return KErrNoMemory;
+		return iPropertyAccess->HandleProperty(aFunction, a1, a2);
+	case RMemoryAccess::EControlSetThreadPriority:
+		return SetThreadPriority((TInt)a1, (TInt)a2);
+	case RMemoryAccess::EControlNotifyThreadCreation:
+		NotifyThreadCreation((TRequestStatus*)a1);
+		return KErrNone;
+	case RMemoryAccess::EControlCancelNotifyThreadCreation:
+		CancelNotifyThreadCreation();
+		return KErrNone;
+	case RMemoryAccess::EControlSetPriorityOverride:
+		return SetPriorityOverride((TInt)a1, a2);
+	case RMemoryAccess::EControlSetCriticalFlags:
+		return SetCriticalFlags((TInt)a1, (TUint)a2);
+	case RMemoryAccess::EControlInPlaceThreadRename:
+		{
+		DThread* thread = ThreadFromHandle((TInt)a1);
+		if (!thread) return 0;
+		TBuf<64> buf;
+		TInt err = Kern::ThreadDesRead(iClient, a2, buf, 0);
+		if (err)
+			{
+			thread->Close(NULL);
+			return err;
+			}
+		thread->iName->Copy(buf);
+		TLinAddr addr = (TLinAddr)thread->iName;
+		thread->Close(NULL);
+		return addr;
+		}
+	case RMemoryAccess::EControlInPlaceObjectRename:
+		return InPlaceObjectRename(a1, a2);
+	case RMemoryAccess::EControlInPlaceSetProcessFileName:
+		return InPlaceSetProcessFileName(a1, a2);
+	case RMemoryAccess::EControlOpenThread:
+		return OpenThread((TUint)a1);
+    case RMemoryAccess::EControlResetTimer:
+        return KErrNone;
+	case RMemoryAccess::EControlGetContainerCount:
+		return GetContainerCount(*(TObjectType*)&a1, *(TUint*)a2);
+	case RMemoryAccess::EControlAcquireContainerMutex:
+		return AcquireContainerMutex(*(TObjectType*)&a1);
+	case RMemoryAccess::EControlReleaseContainerMutex:
+		return ReleaseContainerMutex(*(TObjectType*)&a1);
+    case RMemoryAccess::EControlGetObjectType:
+    	return GetObjectType((TUint8*)a1, *(TObjectType*)a2);
+    case RMemoryAccess::EControlGetObjectInfo:
+		{
+		TObjectInfoByIndexParamsBuf params;
+		TInt err = Kern::ThreadDesRead(iClient,a1,params,0);
+		if (err == KErrNone)
+			{
+			err = GetObjectInfo(params().iObjectType, params().iObjectIndex, (TDes8*)a2);
+			}
+		return err;
+		}
+    case RMemoryAccess::EControlGetObjectInfoByPtr:
+		{
+		TObjectInfoByPtrParamsBuf params;
+		TInt err = Kern::ThreadDesRead(iClient,a1,params,0);
+		if (err == KErrNone)
+			{
+			err = GetObjectInfoByPtr(params().iObjectType, params().iObjectPtr, (TDes8*)a2);
+			}
+		return err;
+		}
+    case RMemoryAccess::EControlGetObjectInfoByName:
+		{
+		TObjectInfoByNameParamsBuf params;
+		TInt err = Kern::ThreadDesRead(iClient,a1,params,0);
+		if (err == KErrNone)
+			{
+			err = GetObjectInfoByName(params().iObjectType, params().iObjectName, (TDes8*)a2);
+			}
+		return err;
+		}
+    case RMemoryAccess::EControlGetObjectInfoByHandle:
+    	{
+		TObjectInfoByHandleParamsBuf params;
+		TInt err = Kern::ThreadDesRead(iClient,a1,params,0);
+		if (err == KErrNone)
+			{
+			err = GetObjectInfoByHandle(params().iObjectType, params().iThreadId, params().iObjectHandle, (TDes8*)a2);
+			}
+		return err;
+		}
+    case RMemoryAccess::EControlAcquireCodeSegMutex:
+    	return AcquireCodeSegMutex();
+    case RMemoryAccess::EControlReleaseCodeSegMutex:
+    	return ReleaseCodeSegMutex();
+    case RMemoryAccess::EControlGetNextCodeSegInfo:
+    	return GetNextCodeSegInfo((TDes8*)a1);
+    case RMemoryAccess::EControlObjectDie:
+    	{
+		TObjectKillParamsBuf params;
+		TInt err = Kern::ThreadDesRead(iClient,a1,params,0);
+		if (err == KErrNone)
+			{
+			err = ObjectDie(params);
+			}
+		return err;
+    	}
+    case RMemoryAccess::EControlGetObjectAddresses:
+		{
+		TGetObjectAddressesParamsBuf params;
+		TInt err = Kern::ThreadDesRead(iClient,a1,params,0);
+		if (err == KErrNone)
+			{
+			err = GetObjectAddresses(params().iObjectType,params().iOwningProcess,(TDes8*)a2);
+			}
+		return err;
+		}
+    case RMemoryAccess::EControlGetChunkAddresses:
+		{
+		TGetChunkAddressesParamsBuf params;
+		TInt err = Kern::ThreadDesRead(iClient,a1,params,0);
+		if (err == KErrNone)
+			{
+			err = GetChunkAddresses(params().iControllingProcessId,(TDes8*)a2);
+			}
+		return err;
+		}
+	case RMemoryAccess::EControlEnableHeapTracing:
+		return EnableHeapTracing((TUint)a1, (TBool)a2);
+	case RMemoryAccess::EControlDefragRam:
+		return DefragRam((TInt)a1);
+	case RMemoryAccess::EControlEmptyRamZone:
+		return EmptyRamZone((TInt)a1, (TUint)a2);
+	case RMemoryAccess::EControlGetRamZoneInfo:
+		return GetRamZoneInfo((TUint)a1, a2);
+	case RMemoryAccess::EControlSetProcessProperties:
+		return SetProcessProperties((TInt)a1, a2);
+	case RMemoryAccess::EControlWriteShadowMemory:
+		return WriteShadowMemory((TLinAddr)a1, a2);
+	case RMemoryAccess::EControlFreeShadowMemory:
+		return FreeShadowMemory((TLinAddr)a1, (TInt)a2);
+	case RMemoryAccess::EControlGetZombieDebugMode:
+	case RMemoryAccess::EControlSetZombieDebugMode:
+	case RMemoryAccess::EControlGetZombies:
+	case RMemoryAccess::EControlReleaseZombie:
+	case RMemoryAccess::EControlSuspendThread:
+	case RMemoryAccess::EControlNotifyBreakpoint:
+	case RMemoryAccess::EControlSetBreakpoint:
+	case RMemoryAccess::EControlSetBreakpointEnabled:
+	case RMemoryAccess::EControlClearBreakpoint:
+	case RMemoryAccess::EControlContinueFromBreakpoint:
+	case RMemoryAccess::EControlGetBreakpoints:
+	case RMemoryAccess::EControlCancelNotifyBreakpoint:
+	case RMemoryAccess::EControlRegisterPersistantBreakpoint:
+	case RMemoryAccess::EControlSetSymbolicBreakpoint:
+		return DebuggerFn(aFunction, a1, a2);
+	case RMemoryAccess::EControlWriteMem:
+		{
+		TAny* args[3];
+		TInt err = Kern::ThreadRawRead(iClient, a1, &args, 3*sizeof(TAny*));
+		if (err) return err;
+		TUint targetId = (TUint)args[0];
+		TAny* srcAddr = args[1];
+		TAny* destAddr = args[2];
+		Kern::Containers()[EThread]->Wait();
+		DThread* target = Kern::ThreadFromId(targetId);
+		if (target) target->Open();
+		Kern::Containers()[EThread]->Signal();
+		if (!target) return KErrNotFound;
+		TInt dataLen = Kern::ThreadGetDesLength(iClient, srcAddr);
+		if (dataLen <= 0) err = dataLen;
+		TAny* mem = NULL;
+		if (!err) mem = Kern::Alloc(dataLen);
+		if (!mem) err = KErrNoMemory;
+		TPtr8 bah((TUint8*)mem, 0, dataLen);
+		if (!err) err = Kern::ThreadDesRead(iClient, srcAddr, bah, dataLen);
+		if (!err) err = Kern::ThreadRawWrite(target, destAddr, mem, dataLen);
+		Kern::Free(mem);
+		target->Close(NULL);
+		return err;
+		}
+#ifdef FSHELL_BTRACE_SUPPORT // SetTextTraceMode went in at the same time as btrace, afaik
+	case RMemoryAccess::EControlSetTextTraceMode:
+		{
+		TUint traceMode = 0;
+		TInt err = Kern::ThreadRawRead(iClient, a1, &traceMode, sizeof(TUint));
+		if (!err)
+			{
+			TUint origMode = Kern::SetTextTraceMode(traceMode, (TUint)a2);
+			err = Kern::ThreadRawWrite(iClient, a1, &origMode, sizeof(TUint));
+			}
+		return err;
+		}
+#endif
+	case RMemoryAccess::EControlGetRegisters:
+		return GetRegisters(a1, a2);
+	case RMemoryAccess::EControlSetDebugPort:
+		Kern::SuperPage().iDebugPort = (TInt)a1;
+		return KErrNone;
+	case RMemoryAccess::EControlGetCreatorThread:
+		{
+		DDebuggerEventHandler* handler = NULL;
+		TInt err = ((DMemoryAccessFactory*)iDevice)->GetEventHandler(handler);
+		if (err) return err;
+		TUint creator = handler->GetCreatorThread((TUint)a1);
+		if (creator == 0)
+			{
+			err = KErrNotFound;
+			}
+		else
+			{
+			err = Kern::ThreadRawWrite(iClient, a2, &creator, sizeof(TUint));
+			}
+		return err;
+		}
+    default:
+        return KErrNotSupported;
+        }
+    }
+    
+// DMemoryAccess::GetThreadMem
+//  Gets a buffer of memory from a thread
+TInt DMemoryAccess::GetThreadMem(TAny* aParams, TAny* aBuf)
+	{
+    TThreadMemoryAccessParams params;
+	TPckg<TThreadMemoryAccessParams> paramsBuf(params);
+	TInt err = Kern::ThreadDesRead(iClient, aParams, paramsBuf, 0);
+	if (err) return err;
+
+	// Copy the memory in page-sized chunks, so we don't have to allocate a huge buffer kernel-side
+	TInt localBufSize = Min(params.iSize, KLocalBufferSize);
+	HBuf8* localBuf = HBuf8::New(localBufSize);
+	if (!localBuf) return KErrNoMemory;
+
+	Kern::Containers()[EThread]->Wait();
+	DThread* thread = Kern::ThreadFromId(params.iId);
+	if (thread) thread->Open();
+	Kern::Containers()[EThread]->Signal();
+	if (!thread)
+		{
+		delete localBuf;
+		return KErrNotFound;
+		}
+	
+	TInt bytesCopied = 0;
+	TUint8* localPtr = (TUint8*)localBuf->Ptr();
+	while (!err && bytesCopied < params.iSize)
+		{
+		TInt toCopy = Min(params.iSize - bytesCopied, localBufSize);
+		localBuf->SetLength(toCopy);
+		err = Kern::ThreadRawRead(thread, params.iAddr + bytesCopied, localPtr, toCopy);
+		if (err) break;
+		err = Kern::ThreadDesWrite(iClient, aBuf, *localBuf, bytesCopied, 0, NULL);
+		bytesCopied += toCopy;
+		}
+	delete localBuf;
+	thread->Close(NULL);
+	return err;
+	}
+
+// DMemoryAccess::GetHeapBase
+//  Gets the base addess of a thread's heap
+TInt DMemoryAccess::GetAllocatorAddress(TUint aId, TUint8*& aAddr, TBool aGetCurrent)
+    {
+    TInt err = KErrNone;
+   
+ 	//Acquire the threads container mutex
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon* threads = cons[EThread];
+	threads->Wait();
+
+	NKern::ThreadEnterCS();
+	DThread* thread = Kern::ThreadFromId(aId);
+	if (thread) thread->Open();
+    NKern::ThreadLeaveCS();
+
+    threads->Signal();
+
+    if (!thread)
+        err = KErrNotFound;
+
+	if (!err)
+		{
+		TLinAddr allocator = DoGetAllocatorAddress(thread, aGetCurrent);
+		thread->Close(NULL);
+		err = Kern::ThreadRawWrite(iClient, &aAddr, (TUint8*)&allocator, sizeof(TUint8*));
+    	}
+	return err;
+	}
+    
+TLinAddr DMemoryAccess::DoGetAllocatorAddress(DThread* aThread, TBool aGetCurrent)
+	{
+	RAllocator* allocator = NULL;
+
+	allocator = aGetCurrent ? aThread->iAllocator : aThread->iCreatedAllocator;
+	if (!allocator)
+		{
+		// Check if it's a kernel thread
+		Kern::Containers()[EProcess]->Wait();
+		DProcess* kernProc = Kern::ProcessFromId(1);
+		Kern::Containers()[EProcess]->Signal();
+		if (aThread->iOwningProcess == kernProc)
+			{
+			// GeorgeN's cunning approach - the kern DProcess is one of the first things allocated to the kern heap and the heap is page aligned, so rounding down the dprocess pointer will give you the RHeapK addresss
+			allocator = (RAllocator*)(Kern::RoundToPageSize((TLinAddr)kernProc) - Kern::RoundToPageSize(1));
+			}
+		}
+
+	return (TLinAddr)allocator;
+    }
+
+// DMemoryAccess::GetContainerCount
+//  Gets the object count of a kernel container specified by aObjectType
+TInt DMemoryAccess::GetContainerCount(const TObjectType aObjectType, TUint& aCount)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetContainerCount");
+	TInt err=KErrNone;
+	if (aObjectType<0 || aObjectType>= ENumObjectTypes)
+		{
+		Kern::ThreadKill(iClient,EExitPanic,EMemAccessPanicBadContainerType,KMemAccessPanicCategory);
+		}
+	
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon* container = cons[aObjectType];
+	container->Wait();
+	
+    TUint count=container->Count();
+    err = Kern::ThreadRawWrite(iClient, &aCount, (TUint8*)&count, sizeof(TUint));
+    
+    container->Signal();
+	// Kern::Printf("[DMemoryAccess] ::GetContainerCount returning %d; count %d",err,count);
+	return err;    	
+	}
+	
+// DMemoryAccess::AcquireContainerMutex
+//  Acquire a mutex on the specified kernel container
+//  Must be called before attempting to retrieve any info from the container
+//  Must only be called once per container
+TInt DMemoryAccess::AcquireContainerMutex(const TObjectType aObjectType)
+	{
+	// Kern::Printf("[DMemoryAccess] ::AcquireContainerMutex, object type %d", aObjectType);
+	TInt err=KErrNone;
+	if (aObjectType<0 || aObjectType>= ENumObjectTypes)
+		{ //Check this is a valid container type
+		Kern::ThreadKill(iClient,EExitPanic,EMemAccessPanicBadContainerType,KMemAccessPanicCategory);
+		err=KErrArgument;
+		}
+	else
+		{
+		//Make sure none of the containers are already locked
+		for (TInt ii=0; ii<ENumObjectTypes;ii++)
+			{
+			if (iLocks[ii])
+				{ //Check the lock on this container is not currently held
+				Kern::ThreadKill(iClient,EExitPanic,EMemAccessMutexAlreadyHeld,KMemAccessPanicCategory);
+				}		
+			}
+		
+		DObjectCon* const * cons = Kern::Containers();
+		DObjectCon* container = cons[aObjectType];
+		container->Wait();
+		
+		iLocks[aObjectType]=ETrue;
+		}
+	// Kern::Printf("[DMemoryAccess] ::AcquireContainerMutex returning %d", err);
+	return err;    	
+	}
+	
+// DMemoryAccess::ReleaseContainerMutex
+//  Releases a mutex on the specified kernel container
+//  Must only be called when the mutex on the container is already held
+TInt DMemoryAccess::ReleaseContainerMutex(const TObjectType aObjectType)
+	{
+	// Kern::Printf("[DMemoryAccess] ::ReleaseContainerMutex, object type %d", aObjectType);
+	TInt err=KErrNone;
+	if (aObjectType<0 || aObjectType>= ENumObjectTypes)
+		{ //Check this is a valid container type
+		Kern::ThreadKill(iClient,EExitPanic,EMemAccessPanicBadContainerType,KMemAccessPanicCategory);
+		err=KErrArgument;
+		}
+	if (!iLocks[aObjectType])
+		{ //Check the lock on this container is currently held
+		Kern::ThreadKill(iClient,EExitPanic,EMemAccessMutexNotHeld,KMemAccessPanicCategory);
+		err=KErrGeneral;
+		}
+
+	if (err==KErrNone)
+		{
+		DObjectCon* const * cons = Kern::Containers();
+		DObjectCon* container = cons[aObjectType];
+		__ASSERT_MUTEX(container->Lock());
+
+	    container->Signal();
+		iLocks[aObjectType]=EFalse;
+		}
+	// Kern::Printf("[DMemoryAccess] ::ReleaseContainerMutex returning %d", err);
+	return err;    	
+	}
+
+// DMemoryAccess::GetObjectInfo
+//  Utility function to extract generic info from a DObject
+void DMemoryAccess::GetObjectInfo(DObject* aObject, TObjectKernelInfo& aInfo)
+	{
+	//Kern::Printf("[DMemoryAccess] ::GetObjectInfo");
+	if (aObject)
+		{
+		aInfo.iAddressOfKernelObject=(TUint8*)aObject;
+		aObject->FullName(aInfo.iFullName);
+		aObject->Name(aInfo.iName);
+		aInfo.iAccessCount=aObject->AccessCount();
+		aInfo.iUniqueID=aObject->UniqueID();
+		aInfo.iProtection=aObject->Protection();
+		aInfo.iAddressOfKernelOwner=(TUint8*)aObject->Owner();			
+		}
+	//Kern::Printf("[DMemoryAccess] ::GetObjectInfo returning");
+	}
+
+// DMemoryAccess::GetObjectType
+//  Finds the type of a kernel side DObject pointer by iterating the kernel containers
+//  Requires that none of the kernel containers are already locked
+//  returns KErrNotFound if the object does not exist in any of the kernel's containers
+TInt DMemoryAccess::GetObjectType(TUint8* aObjectPtr, TObjectType& aType)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetObjectType");
+	TInt err=KErrNotFound;
+	//Make sure none of the containers are already locked
+	for (TInt ii=0; ii<ENumObjectTypes;ii++)
+		{
+		if (iLocks[ii])
+			{ //Check the lock on this container is not currently held
+			Kern::ThreadKill(iClient,EExitPanic,EMemAccessMutexAlreadyHeld,KMemAccessPanicCategory);
+			err=KErrGeneral;
+			}		
+		}
+
+	if (err==KErrNone || err==KErrNotFound)
+		{
+		// Kern::Printf("[DMemoryAccess] Looking for object 0x%08X",aObjectPtr);
+		for (TInt ii=EThread; ii<ENumObjectTypes; ii++)
+			{
+			TInt posInContainer=KErrNotFound;
+			DObjectCon* const * cons = Kern::Containers();
+			DObjectCon& container = *cons[ii];
+			container.Wait();
+			if (GetObjectPositionInContainer(aObjectPtr, container, posInContainer)==KErrNone)
+				{
+				// Kern::Printf("[DMemoryAccess] ::GetObjectType found type %d",ii);
+				err = Kern::ThreadRawWrite(iClient, &aType, (TUint8*)&ii, sizeof(TObjectType));
+				ii=ENumObjectTypes; //prevent further loop iterations
+				}
+			container.Signal();
+			}
+		}
+	// Kern::Printf("[DMemoryAccess] ::GetObjectType returning %d",err);
+	return err;
+	}
+
+// DMemoryAccess::ObjectPositionInContainer
+//  Finds the position in the aContainer of the aObjectPtr kernel object
+//  Returns KErrNone if found, KErrNotFound if not
+//  Position in container will be returned in aPosInContainer
+//  The container mutex corresponding to the specified container must be already locked
+TInt DMemoryAccess::GetObjectPositionInContainer(TUint8* aObjectPtr, DObjectCon& aContainer, TInt& aPosInContainer)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetObjectPositionInContainer");
+	TInt err=KErrNotFound;
+	aPosInContainer=KErrNotFound;
+	
+	for (TInt jj=0; jj<aContainer.Count();jj++)
+		{
+		DObject* obj = (DObject*)aContainer[jj];
+		if ((TUint8*)obj == aObjectPtr)
+			{
+			aPosInContainer=jj;
+			err=KErrNone;
+			continue;
+			}
+		}
+	// Kern::Printf("[DMemoryAccess] ::GetObjectPositionInContainer returning %d; position %d",err,aPosInContainer);
+	return err;
+	}
+
+// DMemoryAccess::GetObjectInfo
+//  Provides data about a kernel object
+//  aObjectType specifies the type of object
+//  aObjectIndexInContainer specifies the index of the required object in the respective kernel container
+//  aKernelInfoBuf provides a buffer to populate with info.  Should be a derived class of TObjectKernelInfo corresponding to the object type
+//  The appropriate kernel container must already be locked
+TInt DMemoryAccess::GetObjectInfo(TObjectType aObjectType, TInt aObjectIndexInContainer, TDes8* aKernelInfoBuf)
+	{
+	//Kern::Printf("[DMemoryAccess] ::GetObjectInfo");
+	TInt err=KErrNone;
+
+	TBool alreadyHeld = iLocks[aObjectType];
+	if (!alreadyHeld)
+		{
+		// Automatically grab the lock
+		DObjectCon* const * cons = Kern::Containers();
+		DObjectCon& container = *cons[aObjectType];
+		container.Wait();
+		iLocks[aObjectType] = ETrue;
+		}
+
+	if (!iLocks[aObjectType])
+		{ //Check the lock on this container is currently held
+		Kern::ThreadKill(iClient,EExitPanic,EMemAccessMutexNotHeld,KMemAccessPanicCategory);
+		//Kern::Printf("[DMemoryAccess] ::GetObjectInfo: No Lock!");
+		err=KErrGeneral;
+		}
+	else
+		{
+		DObjectCon* const * cons = Kern::Containers();
+		DObjectCon& container = *cons[aObjectType];
+		//Kern::Printf("[DMemoryAccess] ::GetObjectInfo: Asserting lock...");
+		__ASSERT_MUTEX(container.Lock());
+		//Kern::Printf("[DMemoryAccess] ::GetObjectInfo: Lock OK");
+
+		// Bounds check index: because we acquire and release the locks more, we risk the container changing size after the client has got the size
+		if (aObjectIndexInContainer >= container.Count())
+			{
+			err = KErrOverflow;
+			goto returnAndReleaseLock; // Not elegant, and in fact the first goto I've used in over 5 years
+			}
+
+		DObject* object = (DObject*)container[aObjectIndexInContainer];
+
+		//Get the object info according to its type
+		//Kern::Printf("[DMemoryAccess] ::GetObjectInfo: Calling specific function");
+		switch (aObjectType)
+			{
+		case EThread:
+			err=GetThreadInfo((DThread*)object, aKernelInfoBuf);
+			break;
+		case EProcess:
+			err=GetProcessInfo((DProcess*)object, aKernelInfoBuf);
+			break;
+		case EChunk:
+			err=GetChunkInfo((DChunk*)object, aKernelInfoBuf);
+			break;
+		case ELibrary:
+			err=GetLibraryInfo((DLibrary*)object, aKernelInfoBuf);
+			break;
+		case ESemaphore:
+			err=GetSemaphoreInfo((DSemaphore*)object, aKernelInfoBuf);
+			break;
+		case EMutex:
+			err=GetMutexInfo((DMutex*)object, aKernelInfoBuf);
+			break;
+		case ETimer:
+			err=GetTimerInfo((DTimer*)object, aKernelInfoBuf);
+			break;
+		case EServer:
+			err=GetServerInfo((DServer*)object, aKernelInfoBuf);
+			break;
+		case ESession:
+			err=GetSessionInfo((DSession*)object, aKernelInfoBuf);
+			break;
+		case ELogicalDevice:
+			err=GetLogicalDeviceInfo((DLogicalDevice*)object, aKernelInfoBuf);
+			break;
+		case EPhysicalDevice:
+			err=GetPhysicalDeviceInfo((DPhysicalDevice*)object, aKernelInfoBuf);
+			break;
+		case ELogicalChannel:
+			err=GetLogicalChannelInfo((DLogicalChannel*)object, aKernelInfoBuf);
+			break;
+		case EChangeNotifier:
+			err=GetChangeNotifierInfo((DChangeNotifier*)object, aKernelInfoBuf);
+			break;
+		case EUndertaker:
+			err=GetUndertakerInfo((DUndertaker*)object, aKernelInfoBuf);
+			break;
+		case EMsgQueue:	
+			err=GetMsgQueueInfo((DMsgQueue*)object, aKernelInfoBuf);
+			break;
+		case EPropertyRef:
+//			err=GetPropertyRefInfo((DPropertyRef*)object, aKernelInfoBuf);
+			break;
+		case ECondVar:
+			err=GetCondVarInfo((DCondVar*)object, aKernelInfoBuf);
+			break;
+		default:
+			err=KErrNotFound;
+			}
+		}
+returnAndReleaseLock:
+	if (!alreadyHeld)
+		{
+		// Release the lock if we grabbed it automatically
+		DObjectCon* const * cons = Kern::Containers();
+		DObjectCon& container = *cons[aObjectType];
+		container.Signal();
+		iLocks[aObjectType] = alreadyHeld;
+		}
+	//Kern::Printf("[DMemoryAccess] ::GetObjectInfo returning %d",err);
+	return err;    				
+	}
+	
+// DMemoryAccess::GetObjectInfoByPtr
+//  Provides data about a kernel object
+//  aObjectType specifies the type of object
+//  aObjectPtr specifies address of the required DObject in the kernel
+//  aKernelInfoBuf provides a buffer to populate with info.  Should be a derived class of TObjectKernelInfo corresponding to the object type
+//  No kernel container locks other than the one selected should be held
+TInt DMemoryAccess::GetObjectInfoByPtr(TObjectType aObjectType, TUint8* aObjectPtr, TDes8* aKernelInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetObjectInfoByPtr");
+	TInt posInContainer=KErrNotFound;
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon& container = *cons[aObjectType];
+	container.Wait();
+	TBool alreadyHeld = iLocks[aObjectType];
+	iLocks[aObjectType] = ETrue;
+	
+	TInt err=GetObjectPositionInContainer(aObjectPtr,container,posInContainer);
+
+	if (err==KErrNone)
+		err=GetObjectInfo(aObjectType, posInContainer, aKernelInfoBuf);
+	
+	container.Signal();
+	iLocks[aObjectType] = alreadyHeld;
+	return err;
+	}
+
+// DMemoryAccess::GetObjectInfoByName
+//  Provides data about a kernel object
+//  aObjectType specifies the type of object
+//  aObjectName specifies name of the required DObject in the kernel
+//  aKernelInfoBuf provides a buffer to populate with info.  Should be a derived class of TObjectKernelInfo corresponding to the object type
+//  No kernel container locks other than the one selected should be held
+TInt DMemoryAccess::GetObjectInfoByName(TObjectType aObjectType, const TDesC8& aObjectName, TDes8* aKernelInfoBuf)
+	{
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon& container = *cons[aObjectType];
+	container.Wait();
+	TBool alreadyHeld = iLocks[aObjectType];
+	iLocks[aObjectType] = ETrue;
+
+	TInt err = KErrNotFound;
+	for (TInt jj=0; jj<container.Count();jj++)
+		{
+		DObject* obj = (DObject*)container[jj];
+		TBuf8<KMaxFullName> fullName;
+		obj->FullName(fullName);
+		if (fullName == aObjectName)
+			{
+			err=GetObjectInfo(aObjectType, jj, aKernelInfoBuf);
+			break;
+			}
+		}
+	
+	container.Signal();
+	iLocks[aObjectType] = alreadyHeld;
+	return err;
+	}
+
+// DMemoryAccess::GetObjectInfoByHandle
+//  Provides data about a kernel object
+//  aObjectType specifies the type of object
+//  aThreadHandle specifies the user side handle of the thread in which context to find the required object
+//  aObjectHandle specifies the user side handle of the required object
+//  aKernelInfoBuf provides a buffer to populate with info.  Should be a derived class of TObjectKernelInfo corresponding to the object type
+//  No kernel container locks other than the one selected should be held
+TInt DMemoryAccess::GetObjectInfoByHandle(TObjectType aObjectType, TInt aThreadId, TInt aObjectHandle, TDes8* aKernelInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetObjectInfoByHandle");
+	TInt err=KErrNone;	
+
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon& container = *cons[EThread];
+	container.Wait();
+	NKern::ThreadEnterCS();
+	DThread* thread = Kern::ThreadFromId(aThreadId);
+    NKern::ThreadLeaveCS();
+	container.Signal();
+
+	if (!thread)
+		{
+		err=KErrNotFound;
+		}
+	else
+		{
+		DObject* object;
+
+		if (aObjectHandle == (KCurrentThreadHandle&~KHandleNoClose))
+			object = thread;
+		else if (aObjectHandle == (KCurrentProcessHandle&~KHandleNoClose))
+			object = thread->iOwningProcess;
+		else
+			{
+			NKern::ThreadEnterCS();
+			NKern::LockSystem();
+			object = thread->ObjectFromHandle(aObjectHandle,aObjectType);
+			NKern::UnlockSystem();
+			NKern::ThreadLeaveCS();
+			}
+
+		if (!object)
+			{
+			err=KErrNotFound;
+			}
+		else
+			{
+			err=GetObjectInfoByPtr(aObjectType, (TUint8*)object, aKernelInfoBuf);
+			}
+		}
+
+	return err;
+	}
+
+
+// DMemoryAccess::AcquireCodeSegMutex
+//  Acquires the code segment mutex
+TInt DMemoryAccess::AcquireCodeSegMutex()
+	{
+	// Kern::Printf("[DMemoryAccess] ::AcquireCodeSegMutex");
+	TInt err=KErrNone;
+
+	if (iCodeSegLock)
+		{ //Check the lock on code segs is not currently held
+		Kern::ThreadKill(iClient, EExitPanic, EMemAccessMutexAlreadyHeld, KMemAccessPanicCategory);
+		err = KErrAbort;
+		}
+
+	DMutex* const codeSegLock = Kern::CodeSegLock();
+
+	if (!err)
+		{
+		if (codeSegLock)
+			{
+			Kern::MutexWait(*codeSegLock);
+			iCodeSegLock = ETrue;
+			}
+		else
+			{
+			err = KErrNotFound;
+			}
+		}
+	// Kern::Printf("[DMemoryAccess] ::AcquireCodeSegMutex returning %d", err);
+	return err;    	
+	}
+
+TInt DMemoryAccess::GetObjectAddresses(TObjectType aObjectType, const TDesC8& aOwningProcess, TDes8* aKernelInfoBuf)
+	{
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon& container = *cons[aObjectType];
+	container.Wait();
+	TBool alreadyHeld = iLocks[aObjectType];
+	iLocks[aObjectType] = ETrue;
+
+	TInt maxLength = Kern::ThreadGetDesMaxLength(iClient, aKernelInfoBuf);
+	TInt err = KErrNone;
+	TInt offset = 0;
+
+	for (TInt jj=0;jj<container.Count();jj++)
+		{
+		if (offset >= maxLength)
+			{
+			err = KErrOverflow;
+			break;
+			}
+
+		TBool doAppend(EFalse);
+		DObject* obj = (DObject*)container[jj];
+		if (aOwningProcess.Length() > 0)
+			{
+			if (obj->Owner())
+				{
+				TBuf8<KMaxFullName> fullName;
+				obj->Owner()->FullName(fullName);
+				if (fullName.MatchF(aOwningProcess) == 0)
+					{
+					doAppend = ETrue;
+					}
+				}
+			}
+		else
+			{
+			doAppend = ETrue;
+			}
+
+
+		if (doAppend)
+			{
+			err = Kern::ThreadDesWrite(iClient, aKernelInfoBuf, TPtrC8((TUint8*)&obj, sizeof(TAny*)), offset, KChunkShiftBy0, iClient);
+			if (err)
+				{
+				break;
+				}
+			else
+				{
+				offset += sizeof(TAny*);
+				}
+			}
+		}
+	
+	container.Signal();
+	iLocks[aObjectType] = alreadyHeld;
+	return err;
+	}
+
+TInt DMemoryAccess::GetChunkAddresses(TUint aControllingProcessId, TDes8* aKernelInfoBuf)
+	{
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon& container = *cons[EChunk];
+	container.Wait();
+	TBool alreadyHeld = iLocks[EChunk];
+	iLocks[EChunk] = ETrue;
+
+	TInt maxLength = Kern::ThreadGetDesMaxLength(iClient, aKernelInfoBuf);
+	const TInt maxPtrs = maxLength / sizeof (TUint32*);
+	TInt err = KErrNone;
+
+	if (maxPtrs == 0)
+		{
+		err = KErrOverflow;
+		}
+	else
+		{
+		TInt offset = 0;
+
+		for (TInt jj=0;jj<container.Count();jj++)
+			{
+			DChunk* chunk = (DChunk*)container[jj];
+			if ((aControllingProcessId == KNullProcessId) || (chunk->iControllingOwner == aControllingProcessId))
+				{
+				err = Kern::ThreadDesWrite(iClient, aKernelInfoBuf, TPtrC8((TUint8*)&chunk, sizeof(TAny*)), offset, KChunkShiftBy0, iClient);
+				if (err)
+					{
+					break;
+					}
+				else
+					{
+					offset += sizeof(TAny*);
+					if (offset >= maxPtrs)
+						{
+						err = KErrOverflow;
+						break;
+						}
+					}
+				}
+			}
+		}
+	
+	container.Signal();
+	iLocks[EChunk] = alreadyHeld;
+	return err;
+	}
+
+
+// DMemoryAccess::ReleaseCodeSegMutex
+//  Releases the code segment mutex
+TInt DMemoryAccess::ReleaseCodeSegMutex()
+	{
+	// Kern::Printf("[DMemoryAccess] ::ReleaseCodeSegMutex");
+	TInt err=KErrNone;
+
+	if (!iCodeSegLock)
+		{ //Check the lock on code segs is not currently held
+		Kern::ThreadKill(iClient, EExitPanic, EMemAccessMutexNotHeld, KMemAccessPanicCategory);
+		err = KErrAbort;
+		}
+
+	DMutex* const codeSegLock = Kern::CodeSegLock();
+
+	if (!err)
+		{
+		if (codeSegLock)
+			{
+			Kern::MutexSignal(*codeSegLock);
+			iCodeSegLock = EFalse;
+			}
+		else
+			{
+			err = KErrNotFound;
+			}
+		}
+	// Kern::Printf("[DMemoryAccess] ::ReleaseCodeSegMutex returning %d", err);
+	return err;    	
+	}
+
+
+TInt DMemoryAccess::GetNextCodeSegInfo(TDes8* aCodeSegInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetNextCodeSegInfo");
+	TInt err = KErrNone;
+	
+	SDblQue* p = Kern::CodeSegList();
+	SDblQueLink* anchor=&p->iA;
+
+	if (!iCurrentCodeSeg)
+		{
+		iCurrentCodeSeg = _LOFF(anchor->iNext, DCodeSeg, iLink);
+		}
+
+	if (iCurrentCodeSeg->iLink.iNext != anchor)
+		{
+		iCurrentCodeSeg = _LOFF(iCurrentCodeSeg->iLink.iNext, DCodeSeg, iLink);
+		}
+	else
+		{
+		iCurrentCodeSeg = NULL;
+		err = KErrNotFound;
+		}
+		
+	if (!err)
+		{
+		//TCodeSegKernelInfoBuf* localInfoBuf = new TCodeSegKernelInfoBuf;
+		TPckgBuf<TTomsciCodeSegKernelInfo>* localInfoBuf = new TPckgBuf<TTomsciCodeSegKernelInfo>;
+		if (!localInfoBuf)
+			{
+			err = KErrNoMemory;
+			}
+		else
+			{	
+			//Get the code seg info
+			(*localInfoBuf)().iRunAddress = iCurrentCodeSeg->iRunAddress;
+			(*localInfoBuf)().iSize = iCurrentCodeSeg->iSize;
+			(*localInfoBuf)().iFileName = iCurrentCodeSeg->iFileName->Right((*localInfoBuf)().iFileName.MaxLength());
+			(*localInfoBuf)().iAccessCount = iCurrentCodeSeg->iAccessCount;
+			(*localInfoBuf)().iAddressOfKernelObject = (TUint8*)iCurrentCodeSeg;
+			(*localInfoBuf)().iName = iCurrentCodeSeg->iRootName;
+			(*localInfoBuf)().iDepCount = iCurrentCodeSeg->iDepCount;
+
+			//Copy the local info buffer into the client's address space
+		    err = Kern::ThreadDesWrite(iClient, aCodeSegInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);
+			delete localInfoBuf;
+			}
+		}
+
+	// Kern::Printf("[DMemoryAccess] ::GetNextCodeSegInfo returning %d", err);
+	return err;
+	}
+
+TInt DMemoryAccess::ObjectDie(TObjectKillParamsBuf& aObjectKillParamsBuf)
+	{
+	TInt err=KErrNone;
+	DObjectCon* const * cons = Kern::Containers();
+
+	switch(aObjectKillParamsBuf().iObjectType)
+		{
+	case EThread:
+		{
+		//Use the address of the kernel object ...
+		DThread* thread = (DThread*)aObjectKillParamsBuf().iObjectPtr;
+		//... unless the client has supplied an object ID
+		if (aObjectKillParamsBuf().iObjectId!=0)
+			{
+			DObjectCon& container = *cons[EThread];
+			container.Wait();
+			NKern::ThreadEnterCS();
+			thread = Kern::ThreadFromId(aObjectKillParamsBuf().iObjectId);
+		    NKern::ThreadLeaveCS();
+			container.Signal();
+			}
+		if (thread==NULL)
+			err=KErrNotFound;
+		else
+			Kern::ThreadKill(thread, aObjectKillParamsBuf().iType, aObjectKillParamsBuf().iReason, aObjectKillParamsBuf().iCategory);
+		break;
+		}
+	case EProcess:
+		{
+		//Use the address of the kernel object ...
+		DProcess* process = (DProcess*)aObjectKillParamsBuf().iObjectPtr;
+		//... unless the client has supplied an object ID
+		if (aObjectKillParamsBuf().iObjectId!=0)
+			{
+			DObjectCon& container = *cons[EProcess];
+			container.Wait();
+			NKern::ThreadEnterCS();
+			process = Kern::ProcessFromId(aObjectKillParamsBuf().iObjectId);
+		    NKern::ThreadLeaveCS();
+			container.Signal();
+			}
+		if (process==NULL)
+			err=KErrNotFound;
+		else
+			{
+			Kern::ThreadKill(process->FirstThread(), aObjectKillParamsBuf().iType, aObjectKillParamsBuf().iReason, aObjectKillParamsBuf().iCategory);
+			}
+		break;
+		}
+	default:
+		err=KErrNotSupported;
+		break;
+		}
+	return err;
+	}
+	
+	
+TInt DMemoryAccess::GetThreadInfo(DThread* aThread, TDes8* aThreadInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetThreadInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TThreadKernelInfoBuf* localInfoBuf = new TThreadKernelInfoBuf;	
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		TThreadKernelInfo& localInfo = (*localInfoBuf)();
+		GetObjectInfo(aThread, localInfo);
+		//Get the thread specific info
+		localInfo.iThreadId=aThread->iId;
+		localInfo.iAddressOfOwningProcess=(TUint8*)aThread->iOwningProcess;
+		localInfo.iThreadPriority = aThread->iDefaultPriority; // iDefaultPriority is more useful to know than iThreadPriority
+		localInfo.iUserStackSize = aThread->iUserStackSize;
+		localInfo.iFlags = aThread->iFlags;
+		localInfo.iSupervisorStack = (TLinAddr)aThread->iSupervisorStack;
+		localInfo.iSupervisorStackSize = aThread->iSupervisorStackSize;
+		localInfo.iUserStackLimit = aThread->iUserStackRunAddress;
+		localInfo.iNThreadSuspendCount = aThread->iNThread.iSuspendCount;
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aThreadInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+	    delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetProcessInfo(DProcess* aProcess, TDes8* aProcessInfoBuf)
+	{
+	//Kern::Printf("[DMemoryAccess] ::GetProcessInfo");
+	TInt err=KErrNone;
+
+	//construct local info buffer to populate
+	TProcessKernelInfoBuf* localInfoBuf = new TProcessKernelInfoBuf;
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		// Kern::Printf("DMemoryAccess::GetProcessInfo getting object info");
+		TProcessKernelInfo& localInfo = (*localInfoBuf)();
+		GetObjectInfo (aProcess, localInfo);
+		//Get the process specific info
+		localInfo.iProcessId = aProcess->iId;
+		localInfo.iPriority = aProcess->iPriority;
+		localInfo.iAddressOfOwningProcess = (TUint8*)aProcess->iOwningProcess;
+		localInfo.iCreatorId = aProcess->iCreatorId;
+		localInfo.iSecurityZone = aProcess->iSecurityZone;
+		localInfo.iUids = aProcess->iUids;
+		localInfo.iAttributes = aProcess->iAttributes;
+		localInfo.iFlags = aProcess->iFlags;
+		localInfo.iAddressOfDataBssStackChunk = (TUint8*)aProcess->iDataBssStackChunk;
+		TInt ii=0;
+	    SDblQueLink* pLink=aProcess->iThreadQ.First();
+		while ((pLink!=&aProcess->iThreadQ.iA) && (ii<KQueBufferLength))
+			 {
+			 DThread* pT=_LOFF(pLink,DThread,iProcessLink);
+			 localInfo.iThreadQ.iBuffer[ii]=(TUint8*)pT;
+			 pLink=pLink->iNext;
+			 ii++;
+			 }
+		localInfo.iThreadQ.iStartFrom=0;
+		localInfo.iThreadQ.iCount=ii;
+		localInfo.iProcessSecurityInfo=aProcess->iS;
+		localInfo.iProcessCreatorSecurityInfo=aProcess->iCreatorInfo;
+		HBuf* commandLine = aProcess->iCommandLine;
+		if (commandLine)
+			{
+			localInfo.iCommandLine = commandLine->Left(localInfo.iCommandLine.MaxLength());
+			}
+		memcpy(localInfo.iEnvironmentData, aProcess->iEnvironmentData, sizeof(TInt)*KNumEnvironmentSlots);
+		localInfo.iFirstThreadId = 0;
+		if (aProcess->FirstThread()) localInfo.iFirstThreadId = aProcess->FirstThread()->iId;
+
+		//Copy the local info buffer into the client's address space
+		// Kern::Printf("DMemoryAccess::GetProcessInfo writing back");
+	    err = Kern::ThreadDesWrite(iClient, aProcessInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;
+	}
+
+	
+TInt DMemoryAccess::GetChunkInfo(DChunk* aChunk, TDes8* aChunkInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetChunkInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TChunkKernelInfoBuf* localInfoBuf = new TChunkKernelInfoBuf;	
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		TChunkKernelInfo& localInfo = (*localInfoBuf)();
+		//Get the standard DObject info
+		GetObjectInfo (aChunk, localInfo);
+		//Get the chunk specific info
+		localInfo.iSize = aChunk->Size();
+		localInfo.iMaxSize = aChunk->MaxSize();
+		localInfo.iBase = aChunk->Base();
+		localInfo.iBottom = aChunk->Bottom();
+		localInfo.iTop = aChunk->Top();
+		localInfo.iAttributes = aChunk->iAttributes;
+		localInfo.iStartPos = aChunk->iStartPos;
+		localInfo.iControllingOwnerProcessId = aChunk->iControllingOwner;
+		localInfo.iRestrictions = aChunk->iRestrictions;
+		localInfo.iMapAttr = aChunk->iMapAttr;
+		localInfo.iChunkType = aChunk->iChunkType;
+		localInfo.iAddressOfOwningProcess = (TUint8*)aChunk->iOwningProcess;
+#ifdef FSHELL_FLEXIBLEMM_AWARE
+		if (localInfo.iBase == 0)
+			{
+			_LIT8(KKern, "ekern");
+			DProcess* proc = aChunk->iOwningProcess;
+			if (localInfo.iFullName.Left(KKern().Length()) != KKern && proc && proc->Open() == KErrNone)
+				{
+				// Probably shouldn't call ChunkUserBase for a non-user-owned chunk
+				localInfo.iBase = Kern::ChunkUserBase(aChunk, proc->FirstThread());
+				proc->Close(NULL);
+				}
+			}
+#endif
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aChunkInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+	
+TInt DMemoryAccess::GetLibraryInfo(DLibrary* aLibrary, TDes8* aLibraryInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetLibraryInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TLibraryKernelInfoBuf* localInfoBuf = new TLibraryKernelInfoBuf;	
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aLibrary, (*localInfoBuf)());
+		//Get the library specific info
+		(*localInfoBuf)().iMapCount = aLibrary->iMapCount;
+		(*localInfoBuf)().iState = aLibrary->iState;
+		(*localInfoBuf)().iAddressOfCodeSeg = (TUint8*)aLibrary->iCodeSeg;
+
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aLibraryInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetSemaphoreInfo(DSemaphore* aSemaphore, TDes8* aSemaphoreInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetSemaphoreInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TSemaphoreKernelInfoBuf* localInfoBuf = new TSemaphoreKernelInfoBuf;	
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aSemaphore, (*localInfoBuf)());
+		//Get the Semaphore specific info
+		(*localInfoBuf)().iCount = aSemaphore->iCount;
+		(*localInfoBuf)().iResetting = aSemaphore->iResetting;
+		TInt ii=0;
+	    SDblQueLink* pLink=aSemaphore->iSuspendedQ.First();
+		while ((pLink!=&aSemaphore->iSuspendedQ.iA) && (ii<KQueBufferLength))
+			 {
+			 DThread* pT=_LOFF(pLink,DThread,iWaitLink);
+			 (*localInfoBuf)().iSuspendedQ.iBuffer[ii]=(TUint8*)pT;
+			 pLink=pLink->iNext;
+			 ii++;
+			 }
+		(*localInfoBuf)().iSuspendedQ.iStartFrom=0;
+		(*localInfoBuf)().iSuspendedQ.iCount=ii;
+
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aSemaphoreInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetMutexInfo(DMutex* aMutex, TDes8* aMutexInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetMutexInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TMutexKernelInfoBuf* localInfoBuf = new TMutexKernelInfoBuf;	
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aMutex, (*localInfoBuf)());
+		//Get the Mutex specific info
+		(*localInfoBuf)().iHoldCount = aMutex->iHoldCount;
+		(*localInfoBuf)().iWaitCount = aMutex->iWaitCount;
+		(*localInfoBuf)().iResetting = aMutex->iResetting;
+		(*localInfoBuf)().iOrder = aMutex->iOrder;
+		TInt ii=0;
+	    SDblQueLink* pLink=aMutex->iSuspendedQ.First();
+		while ((pLink!=&aMutex->iSuspendedQ.iA) && (ii<KQueBufferLength))
+			 {
+			 DThread* pT=_LOFF(pLink,DThread,iWaitLink);
+			 (*localInfoBuf)().iSuspendedQ.iBuffer[ii]=(TUint8*)pT;
+			 pLink=pLink->iNext;
+			 ii++;
+			 }
+		(*localInfoBuf)().iSuspendedQ.iStartFrom=0;
+		(*localInfoBuf)().iSuspendedQ.iCount=ii;
+		ii=0;
+	    pLink=aMutex->iPendingQ.First();
+		while ((pLink!=&aMutex->iPendingQ.iA) && (ii<KQueBufferLength))
+			 {
+			 DThread* pT=_LOFF(pLink,DThread,iWaitLink);
+			 (*localInfoBuf)().iPendingQ.iBuffer[ii]=(TUint8*)pT;
+			 pLink=pLink->iNext;
+			 ii++;
+			 }
+		(*localInfoBuf)().iPendingQ.iStartFrom=0;
+		(*localInfoBuf)().iPendingQ.iCount=ii;
+
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aMutexInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetTimerInfo(DTimer* aTimer, TDes8* aTimerInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetTimerInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TTimerKernelInfoBuf* localInfoBuf = new TTimerKernelInfoBuf;	
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aTimer, (*localInfoBuf)());
+		//Get the timer specific info
+		(*localInfoBuf)().iState = aTimer->iTimer.iState;
+		(*localInfoBuf)().iType = aTimer->iTimer.iType;
+#if FSHELL_PLATFORM_SYMTB >= 92 || FSHELL_PLATFORM_FOUNDATION >= 3
+		(*localInfoBuf)().iClientStatus = NULL; //TOMSCI TEMP
+#else
+		(*localInfoBuf)().iClientStatus = (TLinAddr)aTimer->iTimer.iStatus;
+#endif
+
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aTimerInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetServerInfo(DServer* aServer, TDes8* aServerInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetServerInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TServerKernelInfoBuf* localInfoBuf = new TServerKernelInfoBuf;
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aServer, (*localInfoBuf)());
+		//Get the server specific info
+		(*localInfoBuf)().iAddressOfOwningThread = (TUint8*)aServer->iOwningThread;
+		(*localInfoBuf)().iOwningThreadId = aServer->iOwningThread->iId;
+		(*localInfoBuf)().iSessionType = aServer->iSessionType;
+		TInt ii=0;
+	    SDblQueLink* pLink=aServer->iSessionQ.First();
+		while ((pLink!=&aServer->iSessionQ.iA) && (ii<KQueBufferLength))
+			 {
+			 DSession* pT=_LOFF(pLink,DSession,iServerLink);
+			 (*localInfoBuf)().iSessionQ.iBuffer[ii]=(TUint8*)pT;
+			 pLink=pLink->iNext;
+			 ii++;
+			 }
+		(*localInfoBuf)().iSessionQ.iStartFrom=0;
+		(*localInfoBuf)().iSessionQ.iCount=ii;
+
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aServerInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetSessionInfo(DSession* aSession, TDes8* aSessionInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetSessionInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TSessionKernelInfoBuf* localInfoBuf = new TSessionKernelInfoBuf;
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aSession, (*localInfoBuf)());
+		//Get the session specific info
+		(*localInfoBuf)().iServer = (TUint8*)aSession->iServer;
+#if defined(FSHELL_PLATFORM_FOUNDATION) || defined(FSHELL_PLATFORM_SYMTB)
+		(*localInfoBuf)().iSessionPtr = (TAny*)aSession->iSessionCookie;
+#else
+		(*localInfoBuf)().iSessionPtr = (TAny*)aSession->iSessionPtr;
+#endif
+		(*localInfoBuf)().iTotalAccessCount = aSession->iTotalAccessCount;
+		(*localInfoBuf)().iSessionType = aSession->iSessionType;
+		(*localInfoBuf)().iSvrSessionType = aSession->iSvrSessionType;
+		(*localInfoBuf)().iMsgCount = aSession->iMsgCount;
+		(*localInfoBuf)().iMsgLimit = aSession->iMsgLimit;
+
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aSessionInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetLogicalDeviceInfo(DLogicalDevice* aLogicalDevice, TDes8* aLogicalDeviceInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetLogicalDeviceInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TLogicalDeviceKernelInfoBuf* localInfoBuf = new TLogicalDeviceKernelInfoBuf;
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{	
+		//Get the standard DObject info
+		GetObjectInfo (aLogicalDevice, (*localInfoBuf)());
+		//Get the logical device specific info
+		(*localInfoBuf)().iVersion = aLogicalDevice->iVersion;
+		(*localInfoBuf)().iParseMask = aLogicalDevice->iParseMask;
+		(*localInfoBuf)().iUnitsMask = aLogicalDevice->iUnitsMask;
+		(*localInfoBuf)().iOpenChannels = aLogicalDevice->iOpenChannels;
+
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aLogicalDeviceInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetPhysicalDeviceInfo(DPhysicalDevice* aPhysicalDevice, TDes8* aPhysicalDeviceInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetPhysicalDeviceInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TPhysicalDeviceKernelInfoBuf* localInfoBuf = new TPhysicalDeviceKernelInfoBuf;
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aPhysicalDevice, (*localInfoBuf)());
+		//Get the physical device specific info
+		(*localInfoBuf)().iVersion = aPhysicalDevice->iVersion;
+		(*localInfoBuf)().iUnitsMask = aPhysicalDevice->iUnitsMask;
+		(*localInfoBuf)().iAddressOfCodeSeg = (TUint8*)aPhysicalDevice->iCodeSeg;
+
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aPhysicalDeviceInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetLogicalChannelInfo(DLogicalChannel* aLogicalChannel, TDes8* aLogicalChannelInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetLogicalChannelInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TLogicalChannelKernelInfoBuf* localInfoBuf = new TLogicalChannelKernelInfoBuf;
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{	
+		//Get the standard DObject info
+		GetObjectInfo (aLogicalChannel, (*localInfoBuf)());
+		//Get the logical channel info
+		
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aLogicalChannelInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetChangeNotifierInfo(DChangeNotifier* aChangeNotifier, TDes8* aChangeNotifierInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetChangeNotifierInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TChangeNotifierKernelInfoBuf* localInfoBuf = new TChangeNotifierKernelInfoBuf;
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aChangeNotifier, (*localInfoBuf)());
+		//Get the change notifier specific info
+		(*localInfoBuf)().iChanges = aChangeNotifier->iChanges;
+		(*localInfoBuf)().iAddressOfThread = (TUint8*)aChangeNotifier->iThread;
+		
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aChangeNotifierInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetMsgQueueInfo(DMsgQueue* aMsgQueue, TDes8* aMsgQueueInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetUndertakerInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TMsgQueueKernelInfoBuf* localInfoBuf = new TMsgQueueKernelInfoBuf;	
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo((DObject*)aMsgQueue, (*localInfoBuf)());
+		//Get the specific info - highly fragile this!
+		const TInt KSizeOffset = sizeof(DObject)+(8*4);
+		(*localInfoBuf)().iMaxMsgLength = *(TUint16*)((TLinAddr)aMsgQueue + KSizeOffset);
+		
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aMsgQueueInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetUndertakerInfo(DUndertaker* aUndertaker, TDes8* aUndertakerInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetUndertakerInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TUndertakerKernelInfoBuf* localInfoBuf = new TUndertakerKernelInfoBuf;	
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{
+		//Get the standard DObject info
+		GetObjectInfo (aUndertaker, (*localInfoBuf)());
+		//Get the thread specific info
+		(*localInfoBuf)().iOwningThread = (TUint8*)aUndertaker->iOwningThread;
+		
+		//Copy the local info buffer into the client's address space
+	    err = Kern::ThreadDesWrite(iClient, aUndertakerInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::GetCondVarInfo(DCondVar* aCondVar, TDes8* aCondVarInfoBuf)
+	{
+	// Kern::Printf("[DMemoryAccess] ::GetCondVarInfo");
+	TInt err=KErrNone;
+	//construct local info buffer to populate
+	TCondVarKernelInfoBuf* localInfoBuf = new TCondVarKernelInfoBuf;
+	if (!localInfoBuf)
+		{
+		err=KErrNoMemory;
+		}
+	else
+		{	
+		//Get the standard DObject info
+		GetObjectInfo (aCondVar, (*localInfoBuf)());
+		//Get the cond var specific info
+		(*localInfoBuf)().iResetting = aCondVar->iResetting;
+		(*localInfoBuf)().iAddressOfMutex = (TUint8*)aCondVar->iMutex;
+		(*localInfoBuf)().iWaitCount = aCondVar->iWaitCount;
+		TInt ii=0;
+		SDblQueLink* pLink=aCondVar->iSuspendedQ.First();
+		while ((pLink!=&aCondVar->iSuspendedQ.iA) && (ii<KQueBufferLength))
+			 {
+			 DThread* pT=_LOFF(pLink,DThread,iWaitLink);
+			 (*localInfoBuf)().iSuspendedQ.iBuffer[ii]=(TUint8*)pT;
+			 pLink=pLink->iNext;
+			 ii++;
+			 }
+		(*localInfoBuf)().iSuspendedQ.iStartFrom=0;
+		(*localInfoBuf)().iSuspendedQ.iCount=ii;
+
+		//Copy the local info buffer into the client's address space
+		err = Kern::ThreadDesWrite(iClient, aCondVarInfoBuf, *localInfoBuf, 0, KTruncateToMaxLength, NULL);	
+		delete localInfoBuf;
+		}
+	return err;    		
+	}
+
+TInt DMemoryAccess::FindPtrInCodeSegments(TAny* aDllNamePtr, TAny* aPtr)
+	{
+	/*
+	// Iterate the code segments
+	TInt err = AcquireCodeSegMutex();
+	if (err) return err;
+	DCodeSeg* currentCodeSeg = NULL;
+
+	//BEGIN copied from GetNextCodeSegInfo
+	SDblQue* p = Kern::CodeSegList();
+	SDblQueLink* anchor=&p->iA;
+
+	currentCodeSeg = _LOFF(anchor->iNext, DCodeSeg, iLink);
+
+	while (currentCodeSeg)
+		{
+		if (currentCodeSeg->iLink.iNext != anchor)
+			{
+			currentCodeSeg = _LOFF(currentCodeSeg->iLink.iNext, DCodeSeg, iLink);
+			if ((TUint)aPtr >= currentCodeSeg->iRunAddress && (TUint)aPtr < currentCodeSeg->iRunAddress + currentCodeSeg->iSize)
+				{
+				// Found it
+				break;
+				}
+			}
+		else
+			{
+			// Not found any code seg matching
+			currentCodeSeg = NULL;
+			err = KErrNotFound;
+			}
+		}
+	//END copied from GetNextCodeSegInfo
+	ReleaseCodeSegMutex();
+	// End iterate
+	*/
+
+	Kern::MutexWait(*Kern::CodeSegLock());
+	DCodeSeg* currentCodeSeg = Kern::CodeSegFromAddress((TLinAddr)aPtr, iClient->iOwningProcess);
+	TInt err = KErrNone;
+	TInt offset = 0;
+	TBuf8<256> dllName;
+	if (currentCodeSeg)
+		{
+		dllName.Copy(*currentCodeSeg->iFileName);
+		offset = (TUint)aPtr - currentCodeSeg->iRunAddress; // This won't work on flexible memory model!
+		}
+	else
+		{
+		err = KErrNotFound;
+		}
+	Kern::MutexSignal(*Kern::CodeSegLock());
+
+	if (!err)
+		{
+		err = Kern::ThreadDesWrite(iClient, aDllNamePtr, dllName, 0, KTruncateToMaxLength, NULL);
+		}
+	return err ? err : offset;
+	}
+
+TInt DMemoryAccess::GetHandleOwners(TAny* aObj, TAny* aOwnersBuf)
+	{
+#ifdef FSHELL_DOBJECTIX_SUPPORT
+	TBuf8<256> buf;
+	
+	// Code adapted from ExecHandler::HandleInfo
+	DObject* pO=(DObject*)aObj;
+	TInt r = KErrNone;
+	/*
+	DThread& t = *iClient;
+	//TInt r=K::OpenObjectFromHandle(aHandle,pO);
+	//BEGIN this bit copied from K::OpenObjectFromHandle
+	TInt r=KErrBadHandle;
+	NKern::ThreadEnterCS();
+	NKern::LockSystem();
+	pO=t.ObjectFromHandle(aHandle);
+	if (pO)
+		r=pO->Open();
+	NKern::UnlockSystem();
+	if (r!=KErrNone)
+		{
+		pO=NULL;
+		NKern::ThreadLeaveCS();
+		}
+	//END
+	*/
+
+	if (r==KErrNone)
+		{
+		//DObjectIx::Wait(); //TOMSCI I can't call this frmo a device driver, why did the code I copied do it but none of the DMemoryAccess stuff that uses containers do it??
+		//DProcess* pCurrentProcess=TheCurrentThread->iOwningProcess;
+		//hinfo.iNumOpenInThread=TheCurrentThread->iHandles->Count(pO);
+		//hinfo.iNumOpenInProcess=pCurrentProcess->iHandles->Count(pO);
+
+		DObjectCon* const * cons=Kern::Containers();
+		DObjectCon& threads = *cons[EThread];
+		threads.Wait();
+		TInt c=threads.Count();
+		TInt i=0;
+		for (;i<c;i++)
+			{
+			DThread *pT=(DThread *)threads[i];
+			DObjectIx* handles = pT->iHandles;
+			if (handles) // maybe a nearly dead one hanging around
+				{
+				TInt rr=((DObjectIxNinePointTwoHack*)handles)->At(pO);
+				if (rr!=KErrNotFound)
+					{
+					TPckgBuf<TUint> idBuf(pT->iId);
+					if (buf.Length() + idBuf.Length() >= buf.MaxLength())
+						{
+						r = KErrOverflow;
+						break;
+						}
+					else
+						{
+						buf.Append(idBuf);
+						}
+					//++hinfo.iNumThreads;
+					//if (pT->iOwningProcess==pCurrentProcess)
+					//	++hinfo.iNumOpenInProcess;
+					}
+				}
+			}
+		threads.Signal();
+
+		DObjectCon& processes = *cons[EProcess];
+		processes.Wait();
+		c=processes.Count();
+		for (i=0;i<c;i++)
+			{
+			DProcess *pP=(DProcess *)processes[i];
+			DObjectIx* handles = pP->iHandles;
+			if (handles) // maybe a nearly dead one hanging around
+				{
+				TInt rr=((DObjectIxNinePointTwoHack*)handles)->At(pO);
+				if (rr!=KErrNotFound)
+					{
+					//++hinfo.iNumProcesses;
+					TPckgBuf<TUint> idBuf(pP->iId);
+					if (buf.Length() + idBuf.Length() >= buf.MaxLength())
+						{
+						r = KErrOverflow;
+						break;
+						}
+					else
+						{
+						buf.Append(idBuf);
+						}
+					}
+				}
+			}
+		processes.Signal();
+		//DObjectIx::Signal();
+
+
+		//DObjectIx::Signal();
+		//pO->Close(NULL);
+		//NKern::ThreadLeaveCS();
+		}
+	
+	TInt clientLen = Kern::ThreadGetDesMaxLength(iClient, aOwnersBuf);
+	if (clientLen < 0) return clientLen;
+	TInt writeErr = Kern::ThreadDesWrite(iClient, aOwnersBuf, buf, 0, KTruncateToMaxLength, NULL);
+	if (writeErr) return writeErr;
+	return (clientLen < buf.Length()) ? KErrOverflow : r;
+#else
+	return KErrNotSupported;
+#endif
+	}
+
+TInt DMemoryAccess::GetThreadHandles(TInt aThreadId, TAny* aHandlesBuf)
+	{
+#ifdef FSHELL_DOBJECTIX_SUPPORT
+	TInt maxLength = Kern::ThreadGetDesMaxLength(iClient, aHandlesBuf);
+	TInt err = KErrNone;
+
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon& container = *cons[EThread];
+	container.Wait();
+	NKern::ThreadEnterCS();
+	DThread* thread = Kern::ThreadFromId(aThreadId);
+	//TOMSCI FIXME we don't increment thread's ref count
+	NKern::ThreadLeaveCS();
+	container.Signal();
+	if (thread == NULL) 
+		{
+		return KErrNotFound;
+		}
+
+	// Note, this code is inherently dodgy because it doesn't claim DObjectIx::HandleMutex.
+	DObjectIxNinePointTwoHack* handles = (DObjectIxNinePointTwoHack*)thread->iHandles;
+	if (handles)
+		{
+		TInt offset = 0;
+
+		for (TInt i = 0; i < handles->Count(); ++i)
+			{
+			if (offset >= maxLength)
+				{
+				err = KErrOverflow;
+				break;
+				}
+			NKern::LockSystem();
+			DObject* obj = (*handles)[i];
+			NKern::UnlockSystem();
+			if (obj != NULL)
+				{
+				err = Kern::ThreadDesWrite(iClient, aHandlesBuf, TPtrC8((TUint8*)&obj, sizeof(TAny*)), offset, KChunkShiftBy0, iClient);
+				if (err)
+					{
+					break;
+					}
+				else
+					{
+					offset += sizeof(TAny*);
+					}
+				}
+			}
+		}
+
+	//TOMSCI What is this unlock doing here? TODO FIXME!!!
+	NKern::UnlockSystem();
+	return err;
+#else
+	return KErrNotSupported;
+#endif
+	}
+
+TInt DMemoryAccess::GetProcessHandles(TInt aProcessId, TAny* aHandlesBuf)
+	{
+#ifdef FSHELL_DOBJECTIX_SUPPORT
+	TInt maxLength = Kern::ThreadGetDesMaxLength(iClient, aHandlesBuf);
+	TInt err = KErrNone;
+
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon& container = *cons[EProcess];
+	container.Wait();
+	NKern::ThreadEnterCS();
+	DProcess* process = Kern::ProcessFromId(aProcessId);
+	NKern::ThreadLeaveCS();
+	container.Signal();
+	if (process == NULL) 
+		{
+		return KErrNotFound;
+		}
+
+	// Note, this code is inherently dodgy because it doesn't claim DObjectIx::HandleMutex.
+	DObjectIxNinePointTwoHack* handles = (DObjectIxNinePointTwoHack*)process->iHandles;
+	if (handles)
+		{
+		TInt offset = 0;
+
+		for (TInt i = 0; i < handles->Count(); ++i)
+			{
+			if (offset >= maxLength)
+				{
+				err = KErrOverflow;
+				break;
+				}
+			NKern::LockSystem();
+			DObject* obj = (*handles)[i];
+			NKern::UnlockSystem();
+			if (obj != NULL)
+				{
+				err = Kern::ThreadDesWrite(iClient, aHandlesBuf, TPtrC8((TUint8*)&obj, sizeof(TAny*)), offset, KChunkShiftBy0, iClient);
+				if (err)
+					{
+					break;
+					}
+				else
+					{
+					offset += sizeof(TAny*);
+					}
+				}
+			}
+		}
+
+	return err;
+#else
+	return KErrNotSupported;
+#endif
+	}
+
+TInt DMemoryAccess::SetCriticalFlags(TInt aThreadHandle, TUint aFlags)
+	{
+	NKern::LockSystem();
+	DThread* thread = (DThread*)Kern::ObjectFromHandle(iClient, aThreadHandle, EThread);
+	if (!thread) 
+		{
+		NKern::UnlockSystem();
+		return KErrNotFound;
+		}
+
+	const TUint32 clear =	KThreadFlagSystemPermanent | KThreadFlagSystemCritical |
+							KThreadFlagProcessPermanent | KThreadFlagProcessCritical;
+
+	TUint newFlags = (thread->iFlags&~clear) | aFlags;
+	thread->iFlags = newFlags;
+
+	NKern::UnlockSystem();
+	return KErrNone;
+	}
+
+// Enter and exit with system lock held
+TInt SetPri(DThread* aThread, TInt aPriority)
+	{
+	//Kern::SetThreadPriority(aPriority, aThread);
+
+	// Bypass limitation of Kern::SetThreadPriority on specifying relative priorities
+	if (aPriority<EThrdPriorityIdle || aPriority==-1 || aPriority==0 || aPriority>=KNumPriorities)
+		return KErrArgument;
+	aThread->SetThreadPriority(aPriority);
+	return KErrNone;
+	}
+
+TInt DMemoryAccess::SetThreadPriority(TInt aThreadHandle, TInt aPriority)
+	{
+	NKern::LockSystem();
+	DThread* thread = (DThread*)Kern::ObjectFromHandle(iClient, aThreadHandle, EThread);
+	if (!thread) 
+		{
+		NKern::UnlockSystem();
+		return KErrNotFound;
+		}
+
+	TInt err = SetPri(thread, aPriority);
+	NKern::UnlockSystem();
+	return err;
+	}
+
+void DMemoryAccess::NotifyThreadCreation(TRequestStatus* aStatus)
+	{
+	// TODO: Have this migrate to the shared event handler
+	TInt err = KErrNone;
+	TBool supported = DKernelEventHandler::DebugSupportEnabled();
+	if (!supported) err = KErrNotSupported;
+	if (!err && !iEventHandler)
+		{
+		iEventHandler = new DThreadChangeHandler(iClient);
+		if (iEventHandler)
+			{
+			iEventHandler->Add(DKernelEventHandler::EAppend);
+			}
+		else
+			{
+			err = KErrNoMemory;
+			}
+		}
+
+	if (err)
+		{
+		Kern::RequestComplete(iClient, aStatus, err);
+		}
+	else
+		{
+		iEventHandler->SetStatus(aStatus);
+		}
+	}
+
+void DMemoryAccess::CancelNotifyThreadCreation()
+	{
+	if (iEventHandler)
+		{
+		iEventHandler->SetStatus(NULL);
+		}
+	}
+
+TInt DMemoryAccess::SetPriorityOverride(TInt aPriority, TAny* aMatchString)
+	{
+	// TODO: Have this migrate to the shared event handler
+	// Or... just remove it. It's really odd code that could probably achieve its end goals in a much more sensible way.
+	TInt err = KErrNone;
+	if (!iEventHandler)
+		{
+		iEventHandler = new DThreadChangeHandler(iClient);
+		if (iEventHandler)
+			{
+			iEventHandler->Add(DKernelEventHandler::EAppend);
+			}
+		else
+			{
+			err = KErrNoMemory;
+			}
+		}
+	
+	// TODO: this isn't thread safe, as iEventHandler is already added... meh.
+	
+	if (!err)
+		{
+		iEventHandler->iPriorityToSet = aPriority;
+		err = Kern::ThreadDesRead(iClient, aMatchString, iEventHandler->iMatch,	0);
+		}
+	return err;
+	}
+
+TInt DMemoryAccess::OpenThread(TUint aThreadId)
+	{
+	NKern::ThreadEnterCS();
+	DObjectCon* threads = Kern::Containers()[EThread];
+	threads->Wait();
+	DThread* thread = Kern::ThreadFromId(aThreadId);
+	if (thread && thread->Open() != KErrNone)
+		{
+		// Failed to open
+		thread = NULL;
+		}
+	threads->Signal();
+
+	if (thread)
+		{
+		TInt res = Kern::MakeHandleAndOpen(iClient, thread);
+		thread->Close(NULL);
+		NKern::ThreadLeaveCS();
+		return res;
+		}
+	else
+		{
+		NKern::ThreadLeaveCS();
+		return KErrNotFound;
+		}
+	}
+
+DThreadChangeHandler::DThreadChangeHandler(DThread* aClientThread)
+	: DKernelEventHandler(&Event, this), iThread(aClientThread)
+	{
+	}
+
+DThreadChangeHandler::~DThreadChangeHandler()
+	{
+	}
+
+/*static*/ TUint DThreadChangeHandler::Event(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aPrivateData)
+	{
+	DThreadChangeHandler* self = static_cast<DThreadChangeHandler*>(aPrivateData);
+	return self->DoEvent(aEvent, a1, a2);
+	}
+
+TUint DThreadChangeHandler::DoEvent(TKernelEvent aEvent, TAny* a1, TAny* /*a2*/)
+	{
+	if (aEvent == EEventAddThread)
+		{
+		TRequestStatus* nullstat = NULL;
+		TRequestStatus* stat = (TRequestStatus*)NKern::SafeSwap(nullstat, (TAny*&)iStatus);
+		DThread* thread = static_cast<DThread*>(a1);
+		TBool notify = ETrue;
+
+		if (iPriorityToSet && iMatch.Length())
+			{
+			TBuf8<256> name;
+			thread->AppendFullName(name);
+			if (name.MatchF(iMatch) >= 0)
+				{
+				//Kern::Printf("Matched %O", thread);
+				NKern::LockSystem();
+				SetPri(thread, iPriorityToSet);
+				NKern::UnlockSystem();
+				}
+			else
+				{
+				// Not a thread we're interested in
+				notify = EFalse;
+				}
+			}
+		if (stat && notify)
+			{
+			TInt res = Kern::MakeHandleAndOpen(iThread, thread);
+			Kern::RequestComplete(iThread, stat, res);
+			}
+		}
+	return ERunNext;
+	}
+
+void DThreadChangeHandler::SetStatus(TRequestStatus* aStatus)
+	{
+	TRequestStatus* oldStat = (TRequestStatus*)NKern::SafeSwap(aStatus, (TAny*&)iStatus);
+	if (oldStat)
+		{
+		Kern::RequestComplete(iThread, oldStat, KErrCancel);
+		}
+	}
+
+TInt DMemoryAccess::InPlaceObjectRename(TAny* aParamsBuf, TAny* aNewNamePtr)
+	{
+	TObjectInfoByPtrParams params;
+	TPckg<TObjectInfoByPtrParams> paramsPkg(params);
+	TInt err = Kern::ThreadDesRead(iClient, aParamsBuf, paramsPkg, 0);
+	if (err) return err;
+
+	TKName newName;
+	err = Kern::ThreadDesRead(iClient, aNewNamePtr, newName, 0);
+	if (err) return err;
+
+	TInt posInContainer = KErrNotFound;
+	DObjectCon* const * cons = Kern::Containers();
+	DObjectCon& container = *cons[params.iObjectType];
+	container.Wait();
+	TBool alreadyHeld = iLocks[params.iObjectType];
+	iLocks[params.iObjectType] = ETrue;
+	
+	err = GetObjectPositionInContainer(params.iObjectPtr, container, posInContainer);
+
+	if (err == KErrNone)
+		{
+		DObject* obj = container[posInContainer];
+		obj->iName->Copy(newName);
+		}
+	container.Signal();
+	iLocks[params.iObjectType] = alreadyHeld;
+	return err;
+	}
+
+TInt DMemoryAccess::InPlaceSetProcessFileName(TAny* a1, TAny* aNewNamePtr)
+	{
+	NKern::LockSystem();
+	DProcess* process = (DProcess*)Kern::ObjectFromHandle(iClient, (TUint)a1, EProcess);
+	NKern::UnlockSystem();
+	if (!process) 
+		{
+		return KErrNotFound;
+		}
+	TBuf<256> filename;
+	TInt err = Kern::ThreadDesRead(iClient, aNewNamePtr, filename, 0);
+	if (err) return err;
+	//thread->iName->Copy(buf);
+#ifdef __WINS__
+	// Wins does 'optimisations' on the file name meaning an in-place copy will never work
+	HBuf* newName = HBuf8::New(filename);
+	if (!newName) return KErrNoMemory;
+	HBuf* oldName = (HBuf*)NKern::SafeSwap(newName, (TAny*&)process->iCodeSeg->iFileName);
+	delete oldName;
+#else
+	process->iCodeSeg->iFileName->Copy(filename);
+#endif
+	return KErrNone;
+	}
+
+class RHackAllocator : public RAllocator
+	{
+public:
+	using RAllocator::iFlags;
+	};
+
+TInt DMemoryAccess::EnableHeapTracing(TUint aThreadId, TBool aEnable)
+	{
+#ifndef FSHELL_BTRACE_SUPPORT
+	// If the kernel doesn't have btrace, the heap won't have instrumentation
+	(void)aThreadId;
+	(void)aEnable;
+	return KErrNotSupported;
+#else
+
+	DObjectCon* threads = Kern::Containers()[EThread];
+	NKern::ThreadEnterCS();
+	threads->Wait();
+	DThread* thread = Kern::ThreadFromId(aThreadId);
+	if (thread) thread->Open();
+    threads->Signal();
+    NKern::ThreadLeaveCS();
+
+	if (!thread) return KErrNotFound;
+	TLinAddr allocatorAddr = DoGetAllocatorAddress(thread, EFalse);
+	if (!allocatorAddr) 
+		{
+		thread->Close(NULL);
+		return KErrNotFound;
+		}
+
+	TLinAddr flagsAddr = allocatorAddr + _FOFF(RHackAllocator, iFlags);
+	TUint flags = 0;
+	TInt err = Kern::ThreadRawRead(thread, (void*)flagsAddr, &flags, sizeof(TUint));
+	if (!err)
+		{
+		if (aEnable) flags |= RAllocator::ETraceAllocs;
+		else flags &= ~(RAllocator::ETraceAllocs);
+		err = Kern::ThreadRawWrite(thread, (void*)flagsAddr, &flags, sizeof(TUint));
+		}
+	NKern::ThreadEnterCS();
+	thread->Close(NULL);
+    NKern::ThreadLeaveCS();
+	return err;
+#endif
+	}
+
+#if defined(FSHELL_RAMDEFRAG_SUPPORT) && !defined(__WINS__) // emulator platform.h doesn't have the ram defrag APIs
+
+TInt DMemoryAccess::DefragRam(TInt aPriority)
+	{
+	TInt priority = aPriority;
+	if (priority == -1) priority = TRamDefragRequest::KInheritPriority; // I know KInheritPriority is actually -1 anyway but better to be correctly typed
+	TRamDefragRequest request;
+	return request.DefragRam(priority);
+	}
+
+TInt DMemoryAccess::EmptyRamZone(TInt aPriority, TUint aZone)
+	{
+	TInt priority = aPriority;
+	if (priority == -1) priority = TRamDefragRequest::KInheritPriority; // I know KInheritPriority is actually -1 anyway but better to be correctly typed
+	TRamDefragRequest request;
+	return request.EmptyRamZone(aZone, priority);
+	}
+
+TInt DMemoryAccess::GetRamZoneInfo(TUint aZone, TAny* aInfoPkg)
+	{
+	SRamZonePageCount info;
+	TInt err = Epoc::GetRamZonePageCount(aZone, info);
+	if (err) return err;
+
+	TRamZoneInfo clientInf;
+	clientInf.iFreePages = info.iFreePages;
+	clientInf.iUnknownPages = info.iUnknownPages;
+	clientInf.iFixedPages = info.iFixedPages;
+	clientInf.iMovablePages = info.iMovablePages;
+	clientInf.iDiscardablePages = info.iDiscardablePages;
+	TPckg<TRamZoneInfo> clientPkg(clientInf);
+	err = Kern::ThreadDesWrite(iClient, aInfoPkg, clientPkg, 0, KTruncateToMaxLength, NULL);
+	return err;
+	}
+
+#else
+
+TInt DMemoryAccess::DefragRam(TInt /*aPriority*/)
+	{
+	return KErrNotSupported;
+	}
+
+TInt DMemoryAccess::EmptyRamZone(TInt /*aPriority*/, TUint /*aZone*/)
+	{
+	return KErrNotSupported;
+	}
+
+TInt DMemoryAccess::GetRamZoneInfo(TUint /*aZone*/, TAny* /*aInfoPkg*/)
+	{
+	return KErrNotSupported;
+	}
+
+#endif
+
+TCapabilitySet StoT(const SCapabilitySet& aCaps)
+	{
+	TCapabilitySet result;
+	result.SetEmpty();
+	memcpy(&result, &aCaps, sizeof(SCapabilitySet));
+	return result;
+	}
+	
+SCapabilitySet TtoS(const TCapabilitySet& aCaps)
+	{
+	SCapabilitySet result;
+	memcpy(&result, &aCaps, sizeof(SCapabilitySet));
+	return result;
+	}
+
+// Copied from DProcess::ConvertPriority
+TInt DProcessConvertPriority(TProcessPriority aPriority)
+	{
+	TInt p=-1;
+	switch(aPriority)
+		{
+		case EPriorityLow: p=EProcPriorityLow; break;
+		case EPriorityBackground: p=EProcPriorityBackground; break;
+		case EPriorityForeground: p=EProcPriorityForeground; break;
+		case EPriorityHigh: p=EProcPriorityHigh; break;
+		case EPriorityWindowServer: p=EProcPrioritySystemServer1; break;
+		case EPriorityFileServer: p=EProcPrioritySystemServer2; break;
+		case EPriorityRealTimeServer: p=EProcPriorityRealTimeServer; break;
+		case EPrioritySupervisor: p=EProcPrioritySystemServer3; break;
+		}
+	return p;
+	}
+
+TInt DMemoryAccess::SetProcessProperties(TInt aProcessHandle, TAny* aProperties)
+	{
+	TProcessProperties properties;
+	TPckg<TProcessProperties> pkg(properties);
+	TInt err = Kern::ThreadDesRead(iClient, aProperties, pkg, 0);
+	if (err) return err;
+
+	NKern::LockSystem();
+	DProcess* proc = (DProcess*)Kern::ObjectFromHandle(iClient, aProcessHandle, EProcess);
+	if (!proc) return KErrBadHandle;
+	proc->Open();
+	NKern::UnlockSystem();
+
+	if (properties.iSid != 0xFFFFFFFFu) proc->iS.iSecureId = properties.iSid;
+	if (properties.iVid != 0xFFFFFFFFu) proc->iS.iVendorId = properties.iVid;
+
+	// Why is there no way of converting from an SCapabilitySet to a TCapabilitySet?
+	TCapabilitySet caps = StoT(proc->iS.iCaps);
+	caps.Union(properties.iCapsToAdd);
+	caps.Remove(properties.iCapsToRemove);
+	SCapabilitySet newSet = TtoS(caps);
+	memcpy(&proc->iS.iCaps, &newSet, sizeof(SCapabilitySet));
+
+	if (properties.iProcessPriority)
+		{
+		TInt priority = DProcessConvertPriority((TProcessPriority)properties.iProcessPriority);
+		if (priority < 0) err = KErrArgument;
+		else proc->iPriority = priority; // Note this won't recalculate thread priorities
+		}
+
+	proc->Close(NULL);
+	return err;
+	}
+
+#ifndef FSHELL_COPYTOSHADOWMEMORY_SUPPORT
+// Not sure exactly when it was introduced. Somewhere between 9.1 and 9.3 or anywhere that used ARM7
+// If CopyToShadowMemory is available it MUST be used, on ARM7 or later, otherwise you'll get an exception
+#define NO_COPYTOSHADOWMEMORY
+#endif
+
+TInt DMemoryAccess::WriteShadowMemory(TLinAddr aAddress, TAny* aNewContents)
+	{
+#ifdef __WINS__
+	(void)aAddress;
+	(void)aNewContents;
+	return KErrNotSupported; // Shadowing not supported on emulator
+#else
+	TBuf8<32> newMem;
+	TInt len = Kern::ThreadGetDesLength(iClient, aNewContents);
+	if (len < 0) return len;
+	if (len > 32) return KErrTooBig; // API for CopyToShadowMemory says max 32 bytes, who are we to argue with hard-coded magic numbers (that aren't actually enforced afaics)
+
+	TInt err = Kern::ThreadDesRead(iClient, aNewContents, newMem, 0);
+	if (err) return err;
+
+#ifdef NO_COPYTOSHADOWMEMORY
+	// Can't check if the page is already shadowed, just error and go straight to trying to call AllocShadowPage
+	err = KErrArgument;
+#else
+	err = Epoc::CopyToShadowMemory(aAddress, (TLinAddr)newMem.Ptr(), newMem.Size());
+#endif
+	if (err == KErrArgument || err == KErrNotFound)
+		{
+		// The documentation *says* it will always be KErrArgument but Flexible memory model actually returns KErrNotFound
+		// Page (or pages) hasn't been shadowed yet
+		TLinAddr pageForStart = aAddress & ~(Kern::RoundToPageSize(1)-1);
+		TLinAddr pageForEnd = (aAddress + newMem.Size()) & ~(Kern::RoundToPageSize(1)-1);
+		err = Epoc::AllocShadowPage(pageForStart);
+		if ((err == KErrNone || err == KErrAlreadyExists) && pageForEnd != pageForStart)
+			{
+			// Maybe the area spans a page boundary and that was why the copy failed, so try allocing the end bit too
+			err = Epoc::AllocShadowPage(pageForEnd);
+			}
+
+		if (err == KErrNone || err == KErrAlreadyExists)
+			{
+			// Retry the copy
+#ifdef NO_COPYTOSHADOWMEMORY
+			memcpy((TAny*)aAddress, newMem.Ptr(), newMem.Size());
+			err = KErrNone;
+#else
+			err = Epoc::CopyToShadowMemory(aAddress, (TLinAddr)newMem.Ptr(), newMem.Size());
+#endif
+			}
+		}
+	return err;
+#endif // __WINS__
+	}
+
+TInt DMemoryAccess::FreeShadowMemory(TLinAddr aAddress, TInt aLength)
+	{
+#ifdef __WINS__
+	(void)aAddress;
+	(void)aLength;
+	return KErrNotSupported; // Shadowing not supported on emulator
+#else
+	const TInt pageSize = Kern::RoundToPageSize(1);
+	TLinAddr end = aAddress + aLength;
+	TLinAddr page = aAddress & ~(pageSize -1);
+	while (page < end)
+		{
+		Epoc::FreeShadowPage(page);
+		page += pageSize;
+		}
+	return KErrNone; // There aren't any errors that it's important or sensible to pass to the client
+#endif // __WINS__
+	}
+
+TInt DMemoryAccessFactory::GetEventHandler(DDebuggerEventHandler*& aResult)
+	{
+	if (!DKernelEventHandler::DebugSupportEnabled()) return KErrNotSupported;
+	
+	Lock();
+	if (iSharedEventHandler)
+		{
+		aResult = iSharedEventHandler;
+		Unlock();
+		return KErrNone;
+		}
+	Unlock(); // Can't hold fast mutex around allocs
+
+	TDfcQue* q = NULL;
+	TInt err = GetDfcQue(q);
+	if (err) return err;
+
+	DDebuggerEventHandler* handler = DDebuggerEventHandler::New(q);
+	if (!handler) return KErrNoMemory;
+	// We must NOT call anything that could fail from this point on - otherwise it is impossible to safely close the DDebuggerEventHandler (looks like a bug in constructing a DKernelEventHandler from DLogicalDevice::Install())
+	if (err != KErrNone)
+		{
+		handler->Close();
+		return err;
+		}
+	Lock();
+	if (iSharedEventHandler)
+		{
+		// Someone beat us to it
+		Unlock();
+		handler->Close();
+		}
+	else
+		{
+		iSharedEventHandler = handler;
+		Unlock();
+		}
+	aResult = iSharedEventHandler;
+
+	return KErrNone;
+	}
+
+void DMemoryAccessFactory::Lock()
+	{
+	NKern::FMWait(&iLock);
+	}
+
+void DMemoryAccessFactory::Unlock()
+	{
+	NKern::FMSignal(&iLock);
+	}
+
+TInt DMemoryAccess::DebuggerFn(TInt aFn, TAny* a1, TAny* a2)
+	{
+	DDebuggerEventHandler* handler = NULL;
+	TInt err = ((DMemoryAccessFactory*)iDevice)->GetEventHandler(handler);
+	if (err) return err;
+	
+	switch (aFn)
+		{
+		case RMemoryAccess::EControlGetZombieDebugMode:
+			return handler->GetZombieMode();
+		case RMemoryAccess::EControlSetZombieDebugMode:
+			{
+			TInt newmode = (TInt)a1;
+			TInt oldmode = handler->GetZombieMode();
+			if (newmode && !oldmode) iDevice->Open(); // Stops us getting unloaded
+			else if (!newmode && oldmode) iDevice->Close(NULL);
+			err = handler->SetZombieMode(newmode);
+			break;
+			}
+		case RMemoryAccess::EControlGetZombies:
+			{
+			HBuf* zoms = handler->GetZombieThreadIds();
+			if (zoms)
+				{
+				err = Kern::ThreadDesWrite(iClient, a1, *zoms, 0, KTruncateToMaxLength, NULL);
+				if (err == KErrNone || err == KErrOverflow) err = zoms->Length();
+				delete zoms;
+				}
+			else
+				{
+				err = KErrNoMemory;
+				}
+			break;
+			}
+		case RMemoryAccess::EControlReleaseZombie:
+			{
+			DThread* thread = ThreadFromHandle((TInt)a1);
+			if (!thread) return KErrBadHandle;
+			err = handler->ReleaseZombie(thread);
+			thread->Close(NULL);
+			break;
+			}
+		case RMemoryAccess::EControlSuspendThread:
+			{
+			DThread* thread = ThreadFromHandle((TInt)a1);
+			if (!thread) return KErrBadHandle;
+			err = handler->SuspendThread(thread);
+			thread->Close(NULL);
+			break;
+			}
+		case RMemoryAccess::EControlNotifyBreakpoint:
+			{
+			if (iClientBreakpointNotifyStatus) return KErrAlreadyExists;
+			iClientBreakpointNotifyPkg = a1;
+			iClientBreakpointNotifyStatus = (TRequestStatus*)a2;
+			err = handler->RegisterForBreakpointNotification(this);
+			if (err)
+				{
+				iClientBreakpointNotifyPkg = NULL;
+				iClientBreakpointNotifyStatus = NULL;
+				}
+			break;
+			}
+		case RMemoryAccess::EControlCancelNotifyBreakpoint:
+			{
+			iClientBreakpointNotifyPkg = NULL;
+			if (iClientBreakpointNotifyStatus)
+				{
+				handler->UnregisterForBreakpointNotification(this);
+				Kern::RequestComplete(iClient, iClientBreakpointNotifyStatus, KErrCancel);
+				}
+			break;
+			}
+		case RMemoryAccess::EControlSetBreakpoint:
+			{
+			DThread* thread = ThreadFromHandle((TInt)a1);
+			if (!thread) return KErrBadHandle;
+			TUint32 args[2];
+			RMemoryAccess::TPredicate cond;
+			err = Kern::ThreadRawRead(iClient, a2, args, sizeof(args));
+			if (!err && args[1]) err = Kern::ThreadRawRead(iClient, (TAny*)args[1], &cond, sizeof(RMemoryAccess::TPredicate));
+			if (!err) err = handler->SetBreakpoint(thread, args[0], cond);
+			thread->Close(NULL);
+			break;
+			}
+		case RMemoryAccess::EControlSetSymbolicBreakpoint:
+			{
+			TUint32 args[3];
+			err = Kern::ThreadRawRead(iClient, a1, args, sizeof(args));
+			if (err) return err;
+			DThread* thread = ThreadFromHandle(args[0]);
+			if (!thread) return KErrBadHandle;
+	
+			RMemoryAccess::TPredicate cond;
+			if (args[2] != 0) err = Kern::ThreadRawRead(iClient, (TAny*)args[2], &cond, sizeof(RMemoryAccess::TPredicate));
+			if (err)
+				{
+				thread->Close(NULL);
+				return err;
+				}
+			
+			TInt nameLen = Kern::ThreadGetDesLength(iClient, a2);
+			if (nameLen < 0) err = nameLen;
+			HBuf* codeseg = NULL;
+			if (!err)
+				{
+				codeseg = HBuf::New(nameLen);
+				if (!codeseg) err = KErrNoMemory;
+				}
+			if (!err) err = Kern::ThreadDesRead(iClient, a2, *codeseg, 0);
+			if (!err) err = handler->SetSymbolicBreakpoint(thread, codeseg, args[1], cond);
+			
+			if (err < 0) delete codeseg;
+			thread->Close(NULL);
+			break;
+			}
+		case RMemoryAccess::EControlSetBreakpointEnabled:
+			return handler->SetBreakpointEnabled((TInt)a1, (TBool)a2);
+		case RMemoryAccess::EControlClearBreakpoint:
+			return handler->ClearBreakpoint((TInt)a1);
+		case RMemoryAccess::EControlContinueFromBreakpoint:
+			{
+			DThread* thread = ThreadFromHandle((TInt)a1);
+			if (!thread) return KErrBadHandle;
+			err = handler->ContinueFromBreakpoint(thread, 0);
+			thread->Close(NULL);
+			break;
+			}
+		case RMemoryAccess::EControlGetBreakpoints:
+			{
+			HBuf* breakpoints = handler->GetBreakpoints();
+			if (breakpoints)
+				{
+				err = Kern::ThreadDesWrite(iClient, a1, *breakpoints, 0, KTruncateToMaxLength, NULL);
+				if (err == KErrNone || err == KErrOverflow) err = breakpoints->Length();
+				delete breakpoints;
+				}
+			else
+				{
+				err = KErrNoMemory;
+				}
+			break;
+			}
+		case RMemoryAccess::EControlRegisterPersistantBreakpoint:
+			return handler->RegisterPersistantBreakpoint(iClient, (TLinAddr)a1);
+		default:
+			err = KErrNotSupported;
+		}
+	return err;
+	}
+
+DThread* DMemoryAccess::ThreadFromHandle(TInt aHandle)
+	{
+	if (aHandle == KCurrentThreadHandle)
+		{
+		iClient->Open();
+		return iClient;
+		}
+	else
+		{
+		NKern::LockSystem();
+		DThread* thread = (DThread*)Kern::ObjectFromHandle(iClient, aHandle, EThread);
+		if (thread) thread->Open();
+		NKern::UnlockSystem();
+		return thread;
+		}
+	}
+
+DMemoryAccessFactory::~DMemoryAccessFactory()
+	{
+	if (iSharedEventHandler)
+		{
+		iSharedEventHandler->SetZombieMode(0); // This is needed because its iAccessCount is incremented while threads are blocked in its Event function, therefore Close will otherwise never get to the destructor (Which is what otherwise calls CompleteZombies)
+		iSharedEventHandler->Close();
+		iSharedEventHandler = NULL;
+		}
+	if (iDfcQueWrapper)
+		{
+		iDfcQueWrapper->Destroy();
+		}
+	}
+
+TInt DMemoryAccess::GetRegisters(TAny* a1, TAny* /*a2*/)
+	{
+	TUint32 args[4];
+	TInt err = Kern::ThreadRawRead(iClient, a1, &args[0], sizeof(args));
+	if (err) return err;
+	TInt threadHandle = args[0];
+	TBool userMode = args[1];
+	TAny* regBuf = (TAny*)args[2];
+	TAny* validPtr = (TAny*)args[3];
+
+	DThread* thread = ThreadFromHandle(threadHandle);
+	if (!thread) return KErrBadHandle;
+	TUint32 regs[32];
+	TUint32 valid = 0;
+
+#if !defined(__WINS__) && !defined(FSHELL_9_1_SUPPORT) // win32 ekern doesn't even export this API let alone implement it
+	if (!thread->iSupervisorStack)
+		{
+		// Thread has not only died but has got as far as deallocating its supervisor stack - in which case we can't
+		// get the registers, and moreover NKern::ThreadGetXXXContext will crash if we try
+		thread->Close(NULL);
+		return KErrDied;
+		}
+	if (userMode)
+		{
+		NKern::ThreadGetUserContext(&thread->iNThread, &regs[0], valid);
+		}
+	else
+		{
+		NKern::ThreadGetSystemContext(&thread->iNThread, &regs[0], valid);
+		}
+#else
+	(void)userMode;
+#endif
+
+	thread->Close(NULL);
+	TPckg<TUint32[32]> regsPkg(regs);
+	err = Kern::ThreadDesWrite(iClient, regBuf, regsPkg, 0);
+	if (err) return err;
+	err = Kern::ThreadRawWrite(iClient, validPtr, &valid, sizeof(TUint32));
+	return err;
+	}
+
+void DMemoryAccess::BreakpointHit(TDes& aPkg)
+	{
+	TRequestStatus* stat = (TRequestStatus*)NKern::SafeSwap(NULL, (TAny*&)iClientBreakpointNotifyStatus);
+	if (stat)
+		{
+		// Can't see how we could get here with it being null, but still
+		TInt err = Kern::ThreadDesWrite(iClient, iClientBreakpointNotifyPkg, aPkg, 0);
+		Kern::RequestComplete(iClient, stat, err);
+		iClientBreakpointNotifyPkg = NULL;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/MemoryAccess.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// MemoryAccess.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __FSHELL_MEMORYACCESS_IBY__
+#define __FSHELL_MEMORYACCESS_IBY__
+
+#include <fsh_config.iby>
+FSHELL_DEVICE_DRIVER(memoryaccess-fshell.ldd)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/MemoryAccess.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,60 @@
+// MemoryAccess.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+FSHELL_TRACE_KERNEL_INCLUDE(..\..\..\..\)
+
+#include <kernel/kern_ext.mmh>
+
+target		memoryaccess-fshell.ldd
+targettype	ldd
+
+uid			0x100000af FSHELL_UID_MEMORYACCESS
+
+capability	all
+
+userinclude	.
+
+sourcepath	.
+source		memoryaccess.cpp
+source		propertyaccess.cpp
+source		fdebuggerkernel.cpp
+source		DynamicDfcSupport.cpp
+#if defined(GCCE)
+source		hwbreak_cia.cpp
+#elif defined(ARMCC)
+source		hwbreak.cia
+#endif
+
+#ifdef EABI
+source		TrkNextInstructionAfterPC.cpp
+#endif
+
+#ifdef FSHELL_DOBJECTIX_SUPPORT
+// These are needed because on >= 9.2 DObjectIx is no longer exported
+MACRO DOBJECT_TEST_CODE
+source		objectix.cpp
+#endif
+
+library		ekern.lib
+
+nostrictdef
+deffile		.\~\memoryaccess.def
+
+epocallowdlldata
+
+start wins
+win32_headers
+end
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/PropertyAccess.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,277 @@
+// PropertyAccess.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+#include <e32cmn.h>
+#include <fshell/extrabtrace.h>
+
+#include <kernel.h>
+#include <kern_priv.h>
+#include "memoryaccess.h"
+#include "PropertyAccess.h"
+
+DPropertyAccess::DPropertyAccess(DThread* aClient)
+	: iClient(aClient)
+	{
+	}
+
+TInt DPropertyAccess::HandleProperty(TInt aFunction, TAny* aParams, TAny* aVal)
+	{
+	return DoHandleProperty(iClient, aFunction, aParams, aVal);
+	}
+
+TInt DPropertyAccess::DoHandleProperty(DThread* aClient, TInt aFunction, TAny* aParams, TAny* aVal)
+	{
+	if (aFunction == RMemoryAccess::EControlPropertyNotify)
+		{
+		if (iNotifyClientStatus) return KErrAlreadyExists;
+		iNotifyClientStatus = (TRequestStatus*)aVal;
+		iClientNotifyPtr = aParams;
+		return KErrNone;
+		}
+	else if (aFunction == RMemoryAccess::EControlPropertyNotifyCancel)
+		{
+		CancelNotifys();
+		return KErrNone;
+		}
+
+	TInt err;
+	TProp clientParams;
+	err = Kern::ThreadRawRead(aClient, aParams, &clientParams, sizeof(TProp));
+	if (err)
+		{
+		return err;
+		}
+	//Kern::Printf("HandleProperty %d, iDefine=%d iCat=0x%x iKey=%d", aFunction, clientParams.iDefine, clientParams.iCategory, clientParams.iKey);
+
+	NKern::ThreadEnterCS();
+	RPropertyRef property;
+	err = property.Open(clientParams.iCategory, clientParams.iKey);
+	//Kern::Printf("HandleProperty Open ret=%d", err);
+	if (!err)
+		{
+		// Check if it exists but isn't defined (and if it isn't, treat it the same as if it didn't exist)
+		TPropertyStatus stat;
+		NKern::LockSystem();
+		TBool defined = property.GetStatus(stat);
+		NKern::UnlockSystem();
+		if (!defined)
+			{
+			property.Close();
+			err = KErrNotFound;
+			}
+		}
+
+	if (err == KErrNotFound && clientParams.iDefine && (aFunction == RMemoryAccess::EControlSetPropertyDesc || aFunction == RMemoryAccess::EControlSetPropertyInt))
+		{
+		err = property.Attach(clientParams.iCategory, clientParams.iKey);
+		TInt attr = (aFunction == RMemoryAccess::EControlSetPropertyInt) ? RProperty::EInt : RProperty::EByteArray;
+		_LIT_SECURITY_POLICY_PASS(KPass);
+		if (!err) err = property.Define(attr, KPass, KPass);
+		}
+	NKern::ThreadLeaveCS();
+	if (err)
+		{
+		return err;
+		}
+
+	switch (aFunction)
+		{
+		case RMemoryAccess::EControlGetPropertyInt:
+			{
+			TInt val;
+			err = property.Get(val);
+			if (!err)
+				{
+				TPckg<TInt> valBuf(val);
+				err = Kern::ThreadDesWrite(aClient, aVal, valBuf, 0);
+				}
+			break;
+			}
+		case RMemoryAccess::EControlGetPropertyDesc:
+			{
+			err = Kern::ThreadGetDesMaxLength(aClient, aVal);
+			TInt size = err;
+			if (size < 0) break;
+			
+			NKern::ThreadEnterCS();
+			HBuf8* buf = HBuf8::New(size);
+			if (!buf)
+				{
+				err = KErrNoMemory;
+				NKern::ThreadLeaveCS();
+				break;
+				}
+			err = property.Get(*buf);
+			if (!err || err == KErrOverflow)
+				{
+				TInt writeerr = Kern::ThreadDesWrite(aClient, aVal, *buf, 0, NULL);
+				if (writeerr) err = writeerr;
+				}
+			delete buf;
+			NKern::ThreadLeaveCS();
+			if (err == KErrOverflow)
+				{
+				NKern::LockSystem();
+				TPropertyStatus status;
+				property.GetStatus(status);
+				NKern::UnlockSystem();
+
+				clientParams.iActualSize = status.iSize;
+				err = Kern::ThreadRawWrite(aClient, aParams, (TAny*)&clientParams, sizeof(TProp));
+				}
+			break;
+			}
+		case RMemoryAccess::EControlSetPropertyInt:
+			{
+			err = property.Set((TInt)aVal);
+			break;
+			}
+		case RMemoryAccess::EControlSetPropertyDesc:
+			{
+			err = Kern::ThreadGetDesLength(aClient, aVal);
+			TInt size = err;
+			if (size < 0) break;
+			
+			NKern::ThreadEnterCS();
+			HBuf8* buf = HBuf8::New(size);
+			if (!buf)
+				{
+				err = KErrNoMemory;
+				NKern::ThreadLeaveCS();
+				break;
+				}
+			buf->SetLength(size);
+			err = Kern::ThreadDesRead(aClient, aVal, *buf, 0);
+			if (!err)
+				{
+				err = property.Set(*buf);
+				}
+			delete buf;
+			NKern::ThreadLeaveCS();
+			break;
+			}
+		case RMemoryAccess::EControlDeleteProperty:
+			NKern::ThreadEnterCS();
+			err = property.Delete();
+			NKern::ThreadLeaveCS();
+			break;
+		case RMemoryAccess::EControlSubscribeToProperty:
+			{
+			TBool useBtrace = (TBool)aVal;
+			TNotifyRequest* req = new TNotifyRequest(&PropertyChanged, clientParams.iCategory, clientParams.iKey, this, useBtrace);
+			err = req->iProperty.Attach(clientParams.iCategory, clientParams.iKey); // Allow non-existant properties
+			if (!err)
+				{
+				err = req->iProperty.Subscribe(req->iRequest);
+				if (err)
+					{
+					// Don't think this will ever happen
+					req->iProperty.Close();
+					req->iRequest.iPtr = NULL;
+					}
+				}
+			if (err)
+				{
+				delete req;
+				}
+			else
+				{
+				iRequests.Add(&req->iLink);
+				}
+			}
+			break;			
+		default:
+			break;
+		}
+
+	NKern::ThreadEnterCS();
+	property.Close();
+	NKern::ThreadLeaveCS();
+	return err;
+	}
+
+DPropertyAccess::~DPropertyAccess()
+	{
+	CancelNotifys();
+	}
+
+void DPropertyAccess::CancelNotifys()
+	{
+	for (SDblQueLink* link = iRequests.First(); link != NULL && link != &iRequests.iA;)
+		{
+		TNotifyRequest* request = _LOFF(link, TNotifyRequest, iLink);
+		link=link->iNext; // Do this before anything else because we'll be deleting the TNotifyRequest
+		request->iProperty.Cancel(request->iRequest);
+		request->iProperty.Close();
+		delete request;
+		}
+
+	if (iNotifyClientStatus)
+		{
+		Kern::RequestComplete(iClient, iNotifyClientStatus, KErrCancel);
+		}
+	iClientNotifyPtr = NULL;
+	}
+
+void DPropertyAccess::PropertyChanged(TAny* aPtr, TInt aReason)
+	{
+	TNotifyRequest* req = static_cast<TNotifyRequest*>(aPtr);
+	req->iPropertyAccess->DoPropertyChanged(*req, aReason);
+	}
+
+void DPropertyAccess::DoPropertyChanged(TNotifyRequest& aRequest, TInt aReason)
+	{
+	// First, rerequest
+	if (aReason == KErrNone)
+		{
+		aRequest.iProperty.Subscribe(aRequest.iRequest);
+		}
+	// Then try and notify
+	if (iNotifyClientStatus && !aRequest.iBtrace)
+		{
+		TPropNotifyResult result;
+		result.iCategory = aRequest.iCat.iUid;
+		result.iKey = aRequest.iKey;
+		result.iMissedChanges = iMissedChanges;
+		result.iError = aReason;
+		iMissedChanges = 0; // No need to lock/safeswap because we run in the context of the pubsub DFC
+		TInt err = Kern::ThreadRawWrite(iClient, iClientNotifyPtr, &result, sizeof(TPropNotifyResult));
+		Kern::RequestComplete(iClient, iNotifyClientStatus, err);
+		}
+	else if (aRequest.iBtrace)
+		{
+#ifdef FSHELL_TRACE_SUPPORT
+		TUint cat = aRequest.iCat.iUid;
+		TUint key = aRequest.iKey;
+
+		TInt intVal;
+		TInt err = aRequest.iProperty.Get(intVal);
+		if (err == KErrNone)
+			{
+			BTrace12(ExtraBTrace::EPubSub, ExtraBTrace::EPubSubIntPropertyChanged, cat, key, intVal);
+			}
+		else if (err == KErrArgument)
+			{
+			TBuf8<KMaxBTraceDataArray> buf; // No point using larger buffer, as this is the max we can output over btrace (80 bytes)
+			err = aRequest.iProperty.Get(buf);
+			if (err == KErrNone || err == KErrOverflow)
+				{
+				BTraceN(ExtraBTrace::EPubSub, ExtraBTrace::EPubSubDataPropertyChanged, cat, key, buf.Ptr(), buf.Length());
+				}
+			}
+#endif
+		}
+	else
+		{
+		iMissedChanges++;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/PropertyAccess.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,61 @@
+// PropertyAccess.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef PROPERTYACCESS_H
+#define PROPERTYACCESS_H
+
+#include <kernel.h>
+#include <kern_priv.h>
+
+class TNotifyRequest;
+
+NONSHARABLE_CLASS(DPropertyAccess) : public DBase
+	{
+public:
+	DPropertyAccess(DThread* aThread);
+	~DPropertyAccess();
+	TInt HandleProperty(TInt aFunction, TAny* aParams, TAny* aVal);
+	TInt DoHandleProperty(DThread* aClient, TInt aFunction, TAny* aParams, TAny* aVal);
+
+private:
+	TInt GetAllPropertiesFrom(DThread* aClient, RPropertyRef& property, TAny* aVal);
+	void CancelNotifys();
+	static void PropertyChanged(TAny* aPtr, TInt aReason);
+	void DoPropertyChanged(TNotifyRequest& aRequest, TInt aReason);
+	TInt SetupNotifyAll(DThread* aClient, TAny* aParams, TAny* aVal);
+	TInt SetupNotifyAll(TBool aBtrace, const TDesC8& aUserRequestsBuf);
+
+private:
+	DThread* iClient;
+	SDblQue iRequests;
+	TRequestStatus* iNotifyClientStatus;
+	TAny* iClientNotifyPtr;
+	TInt iMissedChanges;
+	};
+
+class TNotifyRequest
+	{
+public:
+	TNotifyRequest(TPropertyCompleteFn aCompleteFn, TUid aCat, TInt aKey, DPropertyAccess* aPropertyAccess, TBool aBtrace)
+		: iRequest(aCompleteFn, this), iPropertyAccess(aPropertyAccess), iBtrace(aBtrace), iCat(aCat), iKey(aKey)
+		{}
+public:
+	RPropertyRef iProperty;
+	TPropertySubsRequest iRequest;
+	DPropertyAccess* iPropertyAccess;
+	SDblQueLink iLink;
+	TBool iBtrace; // If set, don't use iNotifyClientStatus/iClientNotifyPtr/iMissedChanges, just use BTrace
+	// Lame, no way of getting these from the RPropertyRef
+	TUid iCat;
+	TInt iKey;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/TrkNextInstructionAfterPC.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2145 @@
+// TrkNextInstructionAfterPC.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "fdebuggerkernel.h"
+
+//BEGIN TOMSCI
+#include <kernel/arm/arm.h>
+
+#define LOG_MSG(x)
+#define LOG_MSG2(x,y)
+#define LOG_MSG3(x,y,z)
+#define iChannel this // Saves rewriting a whole load
+#define ReturnIfError(x) { TInt y = (x); if (KErrNone != y) return y; }
+
+#ifdef ASSERT
+#undef ASSERT
+#endif
+#ifdef __WINS__
+#define ASSERT(x) __ASSERT_ALWAYS((x), Kern::Fault("TRKNIAPC Assertion failed: " #x, __LINE__))
+#else
+#define ASSERT(x) if (!(x)) { Kern::Printf("TRKNIAPC Assertion failed @ %d: " #x, __LINE__); NKern::Sleep(NKern::TimerTicks(5000)); }
+#endif
+
+TInt DDebuggerEventHandler::ReadKernelRegisterValue(DThread* aThread, TInt aRegister, TUint32& aResult)
+	{
+	TUint32 regs[32];
+	TUint32 valid = 0;
+	NKern::ThreadGetUserContext(&aThread->iNThread, &regs[0], valid);
+	if (valid & (1<<aRegister))
+		{
+		aResult = regs[aRegister];
+		return KErrNone;
+		}
+	else
+		{
+		return KErrNotSupported;
+		}
+	}
+
+TInt DDebuggerEventHandler::DoReadMemory(DThread* aThread, TLinAddr aAddress, TInt aLength, TDes8& aResult)
+	{
+	// First check if this address is something we've overwritten with a software breakpoint - if so, return the stored value instead
+	ASSERT(aLength == 4 || aLength == 2);
+	if (aResult.MaxLength() < aLength) return KErrArgument;
+	
+	// Check for a breakpoint covering this region
+	SBreakpoint* b = FindBreakpointByAddress(aAddress & ~1);
+	if (b && b->iOrigInstruction.Length() > 0)
+		{
+		ASSERT(b->iOrigInstruction.Length() == aLength); // Otherwise we've trying to read an ARM instruction from somewhere we have a thumb breakpoint (or vice versa)
+		aResult.Copy(b->iOrigInstruction);
+		return KErrNone;
+		}
+	
+	TInt err = Kern::ThreadRawRead(aThread, (void*)aAddress, (void*)aResult.Ptr(), aLength);
+	if (err == KErrNone) aResult.SetLength(aLength);
+	return err;
+	}
+
+namespace Debug {
+	enum TArchitectureMode
+	{
+	/** Represents the ARM CPU architecture. */
+	EArmMode = 1,
+	/** Represents the Thumb CPU architecture. */
+	EThumbMode = 2,
+	/**
+	  Represents the Thumb2 CPU architecture.
+	  @prototype
+	  */
+	EThumb2EEMode = 3
+	};
+}
+using namespace Debug;
+typedef TUint32 T4ByteRegisterValue;
+
+//END TOMSCI
+
+
+// Register definitions
+#define SP_REGISTER			13
+#define LINK_REGISTER		14
+#define PC_REGISTER			15
+#define STATUS_REGISTER		16
+
+/*
+// ARM instruction bitmasks
+#define ARM_OPCODE(x)		(((TUint32)(x) & 0x0E000000) >> 25)
+
+// Generic instruction defines
+#define ARM_RM(x)				((TUint32)(x) & 0x0000000F)			// bit 0- 4
+#define ARM_RS(x)				(((TUint32)(x) & 0x00000F00) >> 8)	// bit 8-11
+#define ARM_RD(x)				(((TUint32)(x) & 0x0000F000) >> 12)	// bit 12-15
+#define ARM_RN(x)				(((TUint32)(x) & 0x000F0000) >> 16)	// bit 16-19
+#define ARM_LOAD(x)				(((TUint32)(x) & 0x00100000) >> 20)	// bit 20
+
+// Data processing instruction defines
+#define ARM_DATA_SHIFT(x)		(((TUint32)(x) & 0x00000060) >> 5) 	// bit 5- 6
+#define ARM_DATA_C(x)			(((TUint32)(x) & 0x00000F80) >> 7) 	// bit 7-11
+#define ARM_DATA_IMM(x)			((TUint32)(x) & 0x000000FF)			// bit 0-7
+#define ARM_DATA_ROT(x)			(((TUint32)(x) & 0x00000F00) >> 8) 	// bit 8-11
+
+// Single date transfer instruction defines
+#define ARM_SINGLE_IMM(x)		((TUint32)(x) & 0x00000FFF)			// bit 0-11
+#define ARM_SINGLE_BYTE(x)		(((TUint32)(x) & 0x00400000) >> 22)	// bit 22
+#define ARM_SINGLE_U(x)			(((TUint32)(x) & 0x00800000) >> 23)	// bit 23
+#define ARM_SINGLE_PRE(x)		(((TUint32)(x) & 0x01000000) >> 24)	// bit 24
+
+// Block data transfer instruction defines
+#define ARM_BLOCK_REGLIST(x)	((TUint32)(x) & 0x0000FFFF)		// bit 0-15
+#define ARM_BLOCK_U(x)			(((TUint32)(x) & 0x00800000) >> 23)	// bit 23
+#define ARM_BLOCK_PRE(x)		(((TUint32)(x) & 0x01000000) >> 24)	// bit 24
+
+// Branch instruction defines
+#define ARM_B_ADDR(x)			((x & 0x00800000) ? ((TUint32)(x) & 0x00FFFFFF | 0xFF000000) : (TUint32)(x) & 0x00FFFFFF)
+#define ARM_INSTR_B_DEST(x,a)	(ARM_B_ADDR(x) << 2) + ((TUint32)(a) + 8)
+
+#define ARM_CARRY_BIT			0x20000000	// bit 30
+
+
+// Thumb instruction bitmasks
+#define THUMB_OPCODE(x)		(((TUint16)(x) & 0xF800) >> 11)
+#define THUMB_INST_7_15(x)	(((TUint16)(x) & 0xFF80) >> 7)
+#define THUMB_INST_8_15(x)	(((TUint16)(x) & 0xFF00) >> 8)
+*/
+
+TUint32 IsBitSet(const TUint32 aBitset, const TUint8 aNum)
+	{
+	return (aBitset & (1 << aNum) );
+	}
+
+// 
+// BitCount
+//
+// Count number of bits in aVal
+TUint32 BitCount(const TUint32 aVal)
+	{
+	TUint32 num = 0;
+
+	for(TInt i = 0; i < 32; i++)
+		{
+		if ((1 << i) & aVal)
+			{
+			num++;
+			}
+		}
+	return num;
+	}
+
+//
+// Thumb2 opcode decoding
+//
+// Special data instructions and branch and exchange.
+//
+// Returns Opcode as defined in ARM ARM DDI0406A, section A6.2.3
+TUint16 t2opcode16special(const TUint16 aInst)
+	{
+	TUint8 aVal = (aInst & 0x03C0) >> 5;
+
+	return aVal;
+	}
+
+
+// Thumb2 opcode decoding instructions
+// 
+// Returns Opcode as defined in ARM ARM DDI0406A, section A6.2
+// 16-bit Thumb instruction encoding
+TUint16 t2opcode16(const TUint16 aInst)
+{
+	TUint16 aVal = (aInst & 0xFC00) >> 9;
+
+	return aVal;
+}
+
+// ARM opcode decoding functions
+TUint32 arm_opcode(const TUint32 aInst)
+{
+// #define ARM_OPCODE(x)		(((TUint32)(x) & 0x0E000000) >> 25)
+
+	TUint32 aVal = ((aInst) & 0x0E000000) >> 25;
+
+	return aVal;
+}
+
+TUint32  arm_rm(const TUint32 aInst)
+{
+//#define ARM_RM(x)				((TUint32)(x) & 0x0000000F)			// bit 0- 4
+
+	TUint32 aVal = (aInst) & 0x0000000F;
+
+	return aVal;
+}
+
+TUint32  arm_rs(const TUint32 aInst)
+{
+//#define ARM_RS(x)				(((TUint32)(x) & 0x00000F00) >> 8)	// bit 8-11
+
+	TUint32 aVal = ((aInst) & 0x00000F00) >> 8;
+
+	return aVal;
+}
+
+TUint32  arm_rd(const TUint32 aInst)
+{
+//#define ARM_RD(x)				(((TUint32)(x) & 0x0000F000) >> 12)	// bit 12-15
+
+	TUint32 aVal = ((aInst) & 0x0000F000) >> 12;
+
+	return aVal;
+}
+
+TUint32  arm_rn(const TUint32 aInst)
+{
+//#define ARM_RN(x)				(((TUint32)(x) & 0x000F0000) >> 16)	// bit 16-19
+
+	TUint32 aVal = ((aInst) & 0x000F0000) >> 16;
+
+	return aVal;
+}
+
+TUint32 arm_load(const TUint32 aInst)
+{
+//#define ARM_LOAD(x)				(((TUint32)(x) & 0x00100000) >> 20)	// bit 20
+
+	TUint32 aVal = ((aInst) & 0x00100000) >> 20;
+
+	return aVal;
+}
+
+// Data processing instruction defines
+TUint32 arm_data_shift(const TUint32 aInst)
+{
+//#define ARM_DATA_SHIFT(x)		(((TUint32)(x) & 0x00000060) >> 5) 	// bit 5- 6
+	
+	TUint32 aVal = ((aInst) & 0x00000060) >> 5;
+
+	return aVal;
+}
+
+TUint32 arm_data_c(const TUint32 aInst)
+{
+//#define ARM_DATA_C(x)			(((TUint32)(x) & 0x00000F80) >> 7) 	// bit 7-11
+
+	TUint32 aVal = ((aInst) & 0x00000F80) >> 7;
+
+	return aVal;
+}
+
+TUint32 arm_data_imm(const TUint32 aInst)
+{
+//#define ARM_DATA_IMM(x)			((TUint32)(x) & 0x000000FF)			// bit 0-7
+
+	TUint32 aVal = (aInst) & 0x000000FF;
+
+	return aVal;
+}
+
+TUint32 arm_data_rot(const TUint32 aInst)
+{
+//#define ARM_DATA_ROT(x)			(((TUint32)(x) & 0x00000F00) >> 8) 	// bit 8-11
+
+	TUint32 aVal = ((aInst) & 0x00000F00) >> 8;
+
+	return aVal;
+}
+
+// Single date transfer instruction defines
+TUint32 arm_single_imm(const TUint32 aInst)
+{
+//#define ARM_SINGLE_IMM(x)		((TUint32)(x) & 0x00000FFF)			// bit 0-11
+
+	TUint32 aVal = (aInst) & 0x00000FFF;
+
+	return aVal;
+}
+
+TUint32 arm_single_byte(const TUint32 aInst)
+{
+//#define ARM_SINGLE_BYTE(x)		(((TUint32)(x) & 0x00400000) >> 22)	// bit 22
+
+	TUint32 aVal = ((aInst) & 0x00400000) >> 22;
+
+	return aVal;
+}
+
+TUint32 arm_single_u(const TUint32 aInst)
+{
+//#define ARM_SINGLE_U(x)			(((TUint32)(x) & 0x00800000) >> 23)	// bit 23
+
+	TUint32 aVal = ((aInst) & 0x00800000) >> 23;
+
+	return aVal;
+}
+
+TUint32 arm_single_pre(const TUint32 aInst)
+{
+//#define ARM_SINGLE_PRE(x)		(((TUint32)(x) & 0x01000000) >> 24)	// bit 24
+
+	TUint32 aVal = ((aInst) & 0x01000000) >> 24;
+
+	return aVal;
+}
+
+// Block data transfer instruction defines
+TUint32 arm_block_reglist(const TUint32 aInst)
+{
+//#define ARM_BLOCK_REGLIST(x)	((TUint32)(x) & 0x0000FFFF)		// bit 0-15
+
+	TUint32 aVal = (aInst) & 0x0000FFFF;
+
+	return aVal;
+}
+
+TUint32 arm_block_u(const TUint32 aInst)
+{
+//#define ARM_BLOCK_U(x)			(((TUint32)(x) & 0x00800000) >> 23)	// bit 23
+
+	TUint32 aVal = ((aInst) & 0x00800000) >> 23;
+
+	return aVal;
+}
+
+TUint32 arm_block_pre(const TUint32 aInst)
+{
+//#define ARM_BLOCK_PRE(x)		(((TUint32)(x) & 0x01000000) >> 24)	// bit 24
+
+	TUint32 aVal = ((aInst) & 0x01000000) >> 24;
+
+	return aVal;
+}
+
+// Branch instruction defines
+TUint32 arm_b_addr(const TUint32 aInst)
+{
+//#define ARM_B_ADDR(x)			((x & 0x00800000) ? ((TUint32)(x) & 0x00FFFFFF | 0xFF000000) : (TUint32)(x) & 0x00FFFFFF)
+
+	TUint32 aVal = ((aInst & 0x00800000) ? ((TUint32)(aInst) & 0x00FFFFFF | 0xFF000000) : (TUint32)(aInst) & 0x00FFFFFF);
+
+	return aVal;
+}
+
+TUint32 arm_instr_b_dest(const TUint32 aInst, TUint32& aAddress)
+{
+//#define ARM_INSTR_B_DEST(x,a)	(ARM_B_ADDR(x) << 2) + ((TUint32)(a) + 8)
+
+	TUint32 aVal = (arm_b_addr(aInst) << 2) + ((TUint32)(aAddress) + 8);
+
+	return aVal;
+}
+
+TUint32 thumb_b_addr(const TUint32 aInst)
+{
+//#define THUMB_B_ADDR(x) ((x & 0x0400) ? ((((TUint32)(x) & 0x07FF)<<11) | (((TUint32)(x) & 0x07FF0000)>>16) | 0xFFC00000) :\
+                                            ((TUint32)(x) & 0x07FF)<<11) | (((TUint32)(x) & 0x07FF0000)>>16)
+
+	TUint32 aVal = ((((TUint32)(aInst) & 0x07FF)<<11) | ((TUint32)(aInst) & 0x07FF0000)>>16);
+
+	return ((aInst & 0x0400) ? (aVal | 0xFFC00000) : aVal);
+}
+
+TUint32 thumb_instr_b_dest(const TUint32 aInst, TUint32& aAddress)
+{
+//#define THUMB_INSTR_B_DEST(x,a)	(THUMB_B_ADDR(x) << 1) + ((TUint32)(a) + 4)
+
+	TUint32 aVal = (thumb_b_addr(aInst) << 1) + ((TUint32)(aAddress) + 4);
+
+	return aVal;
+}
+
+TUint32 arm_carry_bit(void)
+{
+//#define ARM_CARRY_BIT			0x20000000	// bit 30
+
+	TUint32 aVal = 0x20000000;
+
+	return aVal;
+}
+
+// Thumb instruction bitmasks
+TUint16 thumb_opcode(const TUint16 aInst)
+{
+//	#define THUMB_OPCODE(x)		(((TUint16)(x) & 0xF800) >> 11)
+
+	TUint16 aVal = ((aInst) & 0xF800) >> 11;
+
+	return aVal;
+}
+
+TUint16 thumb_inst_7_15(const TUint16 aInst)
+{
+//	#define THUMB_INST_7_15(x)	(((TUint16)(x) & 0xFF80) >> 7)
+
+	TUint16 aVal = ((aInst) & 0xFF80) >> 7;
+
+	return aVal;
+}
+
+TUint16 thumb_inst_8_15(const TUint16 aInst)
+{
+//	#define THUMB_INST_8_15(x)	(((TUint16)(x) & 0xFF00) >> 8)
+
+	TUint16 aVal = ((aInst) & 0xFF00) >> 8;
+
+	return aVal;
+}
+
+
+
+TBool IsExecuted(TUint8 aCondition ,TUint32 aStatusRegister)
+{
+	LOG_MSG("DRMDStepping::IsExecuted()");
+
+	TBool N = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000008;
+	TBool Z = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000004;
+	TBool C = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000002;
+	TBool V = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000001;
+
+	switch(aCondition)
+	{
+		case 0:
+			return Z;
+		case 1:
+			return !Z;
+		case 2:
+			return C;
+		case 3:
+			return !C;
+		case 4:
+			return N;
+		case 5:
+			return !N;
+		case 6:
+			return V;
+		case 7:
+			return !V;
+		case 8:
+			return (C && !Z);
+		case 9:
+			return (!C || Z);
+		case 10:
+			return (N == V);
+		case 11:
+			return (N != V);
+		case 12:
+			return ((N == V) && !Z);
+		case 13:
+			return (Z || (N != V));
+		case 14:
+		case 15:
+			return ETrue;
+	}
+	
+	return EFalse;
+}
+
+TBool DDebuggerEventHandler::IsPreviousInstructionMovePCToLR(DThread *aThread)
+{
+	TInt err = KErrNone;
+	
+	// there are several types of instructions that modify the PC that aren't
+	// designated as linked or non linked branches.  the way gcc generates the
+	// code can tell us whether or not these instructions are to be treated as
+	// linked branches.  the main cases are bx and any type of mov or load or
+	// arithmatic operation that changes the PC.  if these are really just
+	// function calls that will return, gcc will generate a mov	lr, pc
+	// instruction as the previous instruction.  note that this is just for arm
+	// and armi
+	
+	// get the address of the previous instruction
+	TUint32 address = 0;
+	//err = iChannel->ReadKernelRegisterValue(aThread, PC_REGISTER, address);
+	err = ReadKernelRegisterValue(aThread, PC_REGISTER, address);
+	if(err != KErrNone)
+	{
+		LOG_MSG2("Non-zero error code discarded: %d", err);
+	}
+	address -= 4;
+
+	TBuf8<4> previousInstruction;
+	err = DoReadMemory(aThread, address, 4, previousInstruction);
+	if (KErrNone != err)
+	{
+		LOG_MSG2("Error %d reading memory at address %x", address);
+		return EFalse;
+	}
+
+	const TUint32 movePCToLRIgnoringCondition = 0x01A0E00F;
+
+	TUint32 inst = *(TUint32 *)previousInstruction.Ptr();
+	
+	if ((inst & 0x0FFFFFFF) == movePCToLRIgnoringCondition)
+	{
+		return ETrue;
+	}
+		
+	return EFalse;
+}
+
+void DecodeDataProcessingInstruction(TUint8 aOpcode, TUint32 aOp1, TUint32 aOp2, TUint32 aStatusRegister, TUint32 &aBreakAddress)
+{
+	LOG_MSG("DRMDStepping::DecodeDataProcessingInstruction()");
+
+	switch(aOpcode)
+	{
+		case 0:
+		{
+			// AND
+			aBreakAddress = aOp1 & aOp2;
+			break;
+		}
+		case 1:
+		{
+			// EOR
+			aBreakAddress = aOp1 ^ aOp2;
+			break;
+		}
+		case 2:
+		{
+			// SUB
+			aBreakAddress = aOp1 - aOp2;
+			break;
+		}
+		case 3:
+		{
+			// RSB
+			aBreakAddress = aOp2 - aOp1;
+			break;
+		}
+		case 4:
+		{
+			// ADD
+			aBreakAddress = aOp1 + aOp2;
+			break;
+		}
+		case 5:
+		{
+			// ADC
+			aBreakAddress = aOp1 + aOp2 + (aStatusRegister & arm_carry_bit()) ? 1 : 0;
+			break;
+		}
+		case 6:
+		{
+			// SBC
+			aBreakAddress = aOp1 - aOp2 - (aStatusRegister & arm_carry_bit()) ? 0 : 1;
+			break;
+		}
+		case 7:
+		{
+			// RSC
+			aBreakAddress = aOp2 - aOp1 - (aStatusRegister & arm_carry_bit()) ? 0 : 1;
+			break;
+		}
+		case 12:
+		{
+			// ORR
+			aBreakAddress = aOp1 | aOp2;
+			break;
+		}
+		case 13:
+		{
+			// MOV
+			aBreakAddress = aOp2;
+			break;
+		}
+		case 14:
+		{
+			// BIC
+			aBreakAddress = aOp1 & ~aOp2;
+			break;
+		}
+		case 15:
+		{
+			// MVN
+			aBreakAddress = ~aOp2;
+			break;
+		}
+	}
+}
+
+
+// Returns the current instruction bitpattern (either 32-bits or 16-bits) if possible
+//BEGIN TOMSCI who was smoking crack while writing this?
+
+TInt DDebuggerEventHandler::CurrentInstructionArm(DThread* aThread, TUint32& aInstruction)
+	{
+	TUint32 pc;	
+	ReturnIfError(CurrentPC(aThread,pc));
+	TBuf8<4> buf;
+	ReturnIfError(DoReadMemory(aThread, pc, 4, buf));
+	aInstruction = *(TUint32*)buf.Ptr();
+	return KErrNone;
+	}
+
+TInt DDebuggerEventHandler::CurrentInstructionThumb(DThread* aThread, TUint32& aInstruction)
+	{
+	TUint32 pc;	
+	ReturnIfError(CurrentPC(aThread,pc));
+	TBuf8<2> buf;
+	ReturnIfError(DoReadMemory(aThread, pc, 2, buf));
+	aInstruction = *(TUint16*)buf.Ptr();
+	return KErrNone;
+	}
+
+/*
+TInt DDebuggerEventHandler::CurrentInstruction(DThread* aThread, TUint32& aInstruction)
+	{
+	LOG_MSG("DRMDStepping::CurrentInstruction");
+
+	// What is the current PC?
+	TUint32 pc;	
+	ReturnIfError(CurrentPC(aThread,pc));
+
+	
+	// Read it one byte at a time to ensure alignment doesn't matter
+	TUint32 inst = 0;
+	for(TInt i=3;i>=0;i--)
+		{
+
+		TBuf8<1> instruction;
+		TInt err = iChannel->DoReadMemory(aThread, (pc+i), 1, instruction); 
+		if (KErrNone != err)
+			{
+			LOG_MSG2("DRMDStepping::CurrentInstruction : Failed to read memory at current PC: return 0x%08x",pc);
+			return err;
+			}
+
+		inst = (inst << 8) | (*(TUint8 *)instruction.Ptr());
+		}
+
+	aInstruction = inst;
+
+	LOG_MSG2("DRMDStepping::CurrentInstruction 0x%08x", aInstruction);
+
+	return KErrNone;
+	}
+END TOMSCI*/
+
+// Determines architecture mode from the supplied cpsr
+TInt CurrentArchMode(const TUint32 aCpsr, Debug::TArchitectureMode& aMode)
+	{
+// Thumb2 work will depend on having a suitable cpu architecture to compile for...
+#ifdef ECpuJf
+	// State table as per ARM ARM DDI0406A, section A.2.5.1
+	if(aCpsr & ECpuJf)
+		{
+		if (aCpsr & ECpuThumb)
+			{
+			// ThumbEE (Thumb2)
+			aMode = Debug::EThumb2EEMode;
+			}
+		else
+			{
+			// Jazelle mode - not supported
+			return KErrNotSupported;
+			}
+		}
+	else
+#endif
+		{
+		if (aCpsr & ECpuThumb)
+			{
+			// Thumb mode
+			aMode = Debug::EThumbMode;
+			}
+		else
+			{
+			// ARM mode
+			aMode = Debug::EArmMode;
+			}
+		}
+
+	return KErrNone;
+	}
+
+//
+// DRMDStepping::PCAfterInstructionExecutes
+//
+// Note, this function pretty much ignores all the arguments except for aThread.
+// The arguments continue to exist so that the function has the same prototype as
+// the original from Nokia. In the long term this function will be re-factored
+// to remove obsolete parameters.
+//
+TUint32 DDebuggerEventHandler::PCAfterInstructionExecutes(DThread *aThread, TUint32 aCurrentPC, TUint32 aStatusRegister, TInt aInstSize, /*TBool aStepInto,*/ TUint32 &aNewRangeEnd, TBool &aChangingModes)
+{
+	LOG_MSG("DRMDStepping::PCAfterInstructionExecutes()");
+
+	// by default we will set the breakpoint at the next instruction
+	TUint32 breakAddress = aCurrentPC + aInstSize;
+
+	TInt err = KErrNone;
+
+	// determine the architecture
+    TUint32 cpuid;
+   	asm("mrc p15, 0, cpuid, c0, c0, 0 ");
+	LOG_MSG2("DRMDStepping::PCAfterInstructionExecutes() - cpuid = 0x%08x\n",cpuid);
+
+    cpuid >>= 8;
+    cpuid &= 0xFF;
+
+	// determine the architecture mode for the current instruction
+	TArchitectureMode mode = EArmMode;	// Default assumption is ARM 
+
+	// Now we must examine the CPSR to read the T and J bits. See ARM ARM DDI0406A, section B1.3.3
+	TUint32 cpsr;
+
+	ReturnIfError(CurrentCPSR(aThread,cpsr));
+	LOG_MSG2("DRMDStepping::PCAfterInstructionExecutes() - cpsr = 0x%08x\n",cpsr);
+
+	aStatusRegister = cpsr; // The passed-in value of aStatusRegister is ignored, but I can't be bothered to change all the code below. -Tomsci
+	
+	// Determine the mode
+	ReturnIfError(CurrentArchMode(cpsr,mode));
+
+	// Decode instruction based on current CPU mode
+	switch(mode)
+	{
+		case Debug::EArmMode:
+		{
+			// Obtain the current instruction bit pattern
+			TUint32 inst;
+			ReturnIfError(CurrentInstructionArm(aThread,inst));
+			
+			LOG_MSG2("Current instruction: %x", inst);
+
+			// check the conditions to see if this will actually get executed
+			if (IsExecuted(((inst>>28) & 0x0000000F), aStatusRegister)) 
+			{
+				switch(arm_opcode(inst)) // bits 27-25
+				{
+					case 0:
+					{
+						switch((inst & 0x00000010) >> 4) // bit 4
+						{
+							case 0:
+							{
+								switch((inst & 0x01800000) >> 23) // bits 24-23
+								{
+									case 2:
+									{
+										// move to/from status register.  pc updates not allowed
+										// or TST, TEQ, CMP, CMN which don't modify the PC
+										break;
+									}
+									default:
+									{
+										// Data processing immediate shift
+										if (arm_rd(inst) == PC_REGISTER)
+										{
+											TUint32 rn = aCurrentPC + 8;
+											if (arm_rn(inst) != PC_REGISTER) // bits 19-16
+											{
+												err = iChannel->ReadKernelRegisterValue(aThread, arm_rn(inst), rn);
+												if(err != KErrNone)
+												{
+													LOG_MSG2("Non-zero error code discarded: %d", err);
+												}
+											}
+
+											TUint32 shifter = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
+
+											DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
+										}
+										break;
+									}
+								}
+								break;
+							}					
+							case 1:
+							{
+								switch((inst & 0x00000080) >> 7) // bit 7
+								{
+									case 0:
+									{
+										switch((inst & 0x01900000) >> 20) // bits 24-23 and bit 20
+										{
+											case 0x10:
+											{
+												// from figure 3-3
+												switch((inst & 0x000000F0) >> 4) // bits 7-4
+												{
+													case 1:
+													{
+														if (((inst & 0x00400000) >> 22) == 0) // bit 22
+														{
+															// BX
+															// this is a strange case.  normally this is used in the epilogue to branch the the link
+															// register.  sometimes it is used to call a function, and the LR is stored in the previous
+															// instruction.  since what we want to do is different for the two cases when stepping over,
+															// we need to read the previous instruction to see what we should do
+															err = iChannel->ReadKernelRegisterValue(aThread, (inst & 0x0000000F), breakAddress);
+															if(err != KErrNone)
+															{
+																LOG_MSG2("Non-zero error code discarded: %d", err);
+															}
+
+															if ((breakAddress & 0x00000001) == 1)
+															{
+																aChangingModes = ETrue;
+															}
+
+															breakAddress &= 0xFFFFFFFE;
+														}
+														break;
+													}
+													case 3:
+													{
+														// BLX
+														{
+															err = iChannel->ReadKernelRegisterValue(aThread, (inst & 0x0000000F), breakAddress);
+															if(err != KErrNone)
+															{
+																LOG_MSG2("Non-zero error code discarded: %d", err);
+															}
+
+															if ((breakAddress & 0x00000001) == 1)
+															{
+																aChangingModes = ETrue;
+															}
+															
+															breakAddress &= 0xFFFFFFFE;
+														}
+														break;
+													}
+													default:
+													{
+														// either doesn't modify the PC or it is illegal to
+														break;
+													}
+												}
+												break;
+											}
+											default:
+											{
+												// Data processing register shift
+												if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
+												{
+													// TST, TEQ, CMP, CMN don't modify the PC
+												}
+												else if (arm_rd(inst) == PC_REGISTER)
+												{
+													// destination register is the PC
+													TUint32 rn = aCurrentPC + 8;
+													if (arm_rn(inst) != PC_REGISTER) // bits 19-16
+													{
+														err = iChannel->ReadKernelRegisterValue(aThread, arm_rn(inst), rn);
+														if(err != KErrNone)
+														{
+															LOG_MSG2("Non-zero error code discarded: %d", err);
+														}
+													}
+													
+													TUint32 shifter = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
+													
+													DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
+												}
+												break;
+											}
+										}
+										break;
+									}
+									default:
+									{
+										// from figure 3-2, updates to the PC illegal
+										break;
+									}
+								}
+								break;
+							}
+						}
+						break;
+					}
+					case 1:
+					{
+						if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
+						{
+							// cannot modify the PC
+							break;
+						}
+						else if (arm_rd(inst) == PC_REGISTER)
+						{
+							// destination register is the PC
+							TUint32 rn;
+							err = iChannel->ReadKernelRegisterValue(aThread, arm_rn(inst), rn); // bits 19-16
+							if(err != KErrNone)
+							{
+								LOG_MSG2("Non-zero error code discarded: %d", err);
+							}
+							TUint32 shifter = ((arm_data_imm(inst) >> arm_data_rot(inst)) | (arm_data_imm(inst) << (32 - arm_data_rot(inst)))) & 0xffffffff;
+
+							DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
+						}
+						break;
+					}
+					case 2:
+					{
+						// load/store immediate offset
+						if (arm_load(inst)) // bit 20
+						{
+							// loading a register from memory
+							if (arm_rd(inst) == PC_REGISTER)
+							{
+								// loading the PC register
+								TUint32 base;
+								err = iChannel->ReadKernelRegisterValue(aThread, arm_rn(inst), base);
+								if(err != KErrNone)
+								{
+									LOG_MSG2("Non-zero error code discarded: %d", err);
+								}
+
+								/* Note: At runtime the PC would be 8 further on
+								 */
+								if (arm_rn(inst) == PC_REGISTER)
+								{
+									base = aCurrentPC + 8;
+								}
+
+								TUint32 offset = 0;
+					    		
+					    		if (arm_single_pre(inst))
+					    		{
+					    			// Pre-indexing
+					    			offset = arm_single_imm(inst);
+									
+									if (arm_single_u(inst))
+									{
+							    		base += offset;
+									}
+									else
+									{
+							    		base -= offset;
+									}
+								}
+
+								TBuf8<4> destination;
+								err = iChannel->DoReadMemory(aThread, base, 4, destination);
+								
+								if (KErrNone == err)
+								{
+									breakAddress = *(TUint32 *)destination.Ptr();
+								
+									if ((breakAddress & 0x00000001) == 1)
+									{
+										aChangingModes = ETrue;
+									}								
+									breakAddress &= 0xFFFFFFFE;
+								}
+								else
+								{
+									LOG_MSG("Error reading memory in decoding step instruction");
+								}
+							}
+						}	
+						break;
+					}
+					case 3:
+					{
+						if (((inst & 0xF0000000) != 0xF0000000) && ((inst & 0x00000010) == 0))
+						{
+							// load/store register offset
+							if (arm_load(inst)) // bit 20
+							{
+								// loading a register from memory
+								if (arm_rd(inst) == PC_REGISTER)
+								{
+									// loading the PC register
+									TUint32 base = 0;
+									if(arm_rn(inst) == PC_REGISTER)
+									{
+										base = aCurrentPC + 8;
+									}
+									else
+									{
+										err = iChannel->ReadKernelRegisterValue(aThread, arm_rn(inst), base);
+										if(err != KErrNone)
+										{
+											LOG_MSG2("Non-zero error code discarded: %d", err);
+										}
+									}
+
+									TUint32 offset = 0;
+
+									if (arm_single_pre(inst))
+									{
+										offset = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
+
+										if (arm_single_u(inst))
+										{
+											base += offset;
+										}
+										else
+										{
+											base -= offset;
+										}
+									}
+
+									TBuf8<4> destination;
+									err = iChannel->DoReadMemory(aThread, base, 4, destination);
+
+									if (KErrNone == err)
+									{
+										breakAddress = *(TUint32 *)destination.Ptr();
+
+										if ((breakAddress & 0x00000001) == 1)
+										{
+											aChangingModes = ETrue;
+										}								
+										breakAddress &= 0xFFFFFFFE;
+									}
+									else
+									{
+										LOG_MSG("Error reading memory in decoding step instruction");
+									}
+								}
+							}	
+						}
+						break;
+					}
+					case 4:
+					{
+						if ((inst & 0xF0000000) != 0xF0000000)
+						{
+							// load/store multiple
+							if (arm_load(inst)) // bit 20
+							{
+								// loading a register from memory
+								if (((inst & 0x00008000) >> 15))
+								{
+									// loading the PC register
+									TInt offset = 0;	
+									if (arm_block_u(inst))
+									{
+										TUint32 reglist = arm_block_reglist(inst);
+										offset = BitCount(reglist) * 4 - 4;
+										if (arm_block_pre(inst))
+											offset += 4;
+									}
+									else if (arm_block_pre(inst))
+									{
+										offset = -4;
+									}
+										
+									TUint32 temp = 0;
+									err = iChannel->ReadKernelRegisterValue(aThread, arm_rn(inst), temp);
+									if(err != KErrNone)
+									{
+										LOG_MSG2("Non-zero error code discarded: %d", err);
+									}
+									
+									temp += offset;
+
+									TBuf8<4> destination;
+									err = iChannel->DoReadMemory(aThread, temp, 4, destination);
+									
+									if (KErrNone == err)
+									{
+										breakAddress = *(TUint32 *)destination.Ptr();
+										if ((breakAddress & 0x00000001) == 1)
+										{
+											aChangingModes = ETrue;
+										}
+										breakAddress &= 0xFFFFFFFE;
+									}
+									else
+									{
+										LOG_MSG("Error reading memory in decoding step instruction");
+									}
+								}
+							}					
+						}
+						break;
+					}
+					case 5:
+					{
+						if ((inst & 0xF0000000) == 0xF0000000)
+						{
+							// BLX
+							{
+								breakAddress = (TUint32)arm_instr_b_dest(inst, aCurrentPC);
+
+								// Unconditionally change into Thumb mode
+								aChangingModes = ETrue;
+								
+								breakAddress &= 0xFFFFFFFE;
+							}
+						}
+						else
+						{
+							if ((inst & 0x01000000)) // bit 24
+							{
+								// BL
+								{
+									breakAddress = (TUint32)arm_instr_b_dest(inst, aCurrentPC);
+								}
+							}
+							else
+							{
+								// B
+								breakAddress = (TUint32)arm_instr_b_dest(inst, aCurrentPC);
+							}
+						}
+						break;
+					}
+				}	
+			}
+		}
+		break;
+
+		case Debug::EThumbMode:
+		{
+			// Thumb Mode
+			//
+			// Notes: This now includes the extra code
+			// required to decode V6T2 instructions
+			
+			LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Thumb Instruction");
+
+			TUint16 inst;
+
+			// Obtain the current instruction bit pattern
+			TUint32 inst32;
+			ReturnIfError(CurrentInstructionThumb(aThread,inst32));
+
+			inst = static_cast<TUint16>(inst32 & 0xFFFF);
+
+			LOG_MSG2("Current Thumb instruction: 0x%x", inst);
+
+			// v6T2 instructions
+
+// Note: v6T2 decoding is only enabled for DEBUG builds or if using an
+// an ARM_V6T2 supporting build system. At the time of writing, no
+// ARM_V6T2 supporting build system exists, so the stepping code cannot
+// be said to be known to work. Hence it is not run for release builds
+
+			TBool use_v6t2_decodings = EFalse;
+
+#if defined(DEBUG) || defined(__ARMV6T2__)
+			use_v6t2_decodings = ETrue;
+
+#endif
+			// coverity[dead_error_line]
+			if (use_v6t2_decodings)
+			{
+				// 16-bit encodings
+	 
+				// A6.2.5 Misc 16-bit instructions
+				// DONE Compare and branch on zero (page A8-66)
+				// If then hints
+
+				// ARM ARM DDI0406A - section A8.6.27 CBNZ, CBZ
+				//
+				// Compare and branch on Nonzero and Compare and Branch on Zero.
+				if ((inst & 0xF500) == 0xB100)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.27 CBNZ, CBZ");
+
+					// Decoding as per ARM ARM description
+					TUint32 op = (inst & 0x0800) >> 11;
+					TUint32 i = (inst & 0x0200) >> 9;
+					TUint32 imm5 = (inst & 0x00F8) >> 3;
+					TUint32 Rn = inst & 0x0007;
+
+					TUint32 imm32 = (i << 6) | (imm5 << 1);
+
+					// Obtain value for register Rn
+					TUint32 RnVal = 0;
+					ReturnIfError(RegisterValue(aThread,Rn,RnVal));
+
+					if (op)
+						{
+						// nonzero
+						if (RnVal != 0x0)
+							{
+							// Branch
+							breakAddress = aCurrentPC + imm32;
+							}
+						}
+					else
+						{
+						// zero
+						if (RnVal == 0x0)
+							{
+							// Branch
+							breakAddress = aCurrentPC + imm32;
+							}
+						}
+				}
+
+				// ARM ARM DDI0406A - section A8.6.50 IT
+				//
+				// If Then instruction
+				if ((inst & 0xFF00) == 0xBF00)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.50 IT");
+
+					// Decoding as per ARM ARM description
+					TUint32 firstcond = inst & 0x00F0 >> 4;
+					TUint32 mask = inst & 0x000F;
+
+					if (firstcond == 0xF)
+					{
+						// unpredictable
+						LOG_MSG("ARM ARM DDI0406A - section A8.6.50 IT - Unpredictable");
+						break;
+					}
+
+					if ((firstcond == 0xE) && (BitCount(mask) != 1))
+					{
+						// unpredictable
+						LOG_MSG("ARM ARM DDI0406A - section A8.6.50 IT - Unpredictable");
+						break;
+					}
+
+					// should check if 'in-it-block'
+					LOG_MSG("Cannot step IT instructions.");
+
+					// all the conds are as per Table A8-1 (i.e. the usual 16 cases)
+					// no idea how to decode the it block 'after-the-fact'
+					// so probably need to treat instructions in the it block
+					// as 'may' be executed. So breakpoints at both possible locations
+					// depending on whether the instruction is executed or not.
+
+					// also, how do we know if we have hit a breakpoint whilst 'in' an it block?
+					// can we check the status registers to find out?
+					//
+					// see arm arm page 390.
+					//
+					// seems to depend on the itstate field. this also says what the condition code
+					// actually is, and how many instructions are left in the itblock.
+					// perhaps we can just totally ignore this state, and always do the two-instruction
+					// breakpoint thing? Not if there is any possibility that the address target
+					// would be invalid for the non-taken branch address...
+				}
+
+
+				// 32-bit encodings.
+				//
+
+				// Load word A6-23
+				// Data processing instructions a6-28
+				// 
+
+				// ARM ARM DDI0406A - section A8.6.26
+				if (inst32 & 0xFFF0FFFF == 0xE3C08F00)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.26 - BXJ is not supported");
+
+					// Decoding as per ARM ARM description
+					// TUint32 Rm = inst32 & 0x000F0000;	// not needed yet
+				}
+
+				// return from exception... SUBS PC,LR. page b6-25
+				//
+				// ARM ARM DDi046A - section B6.1.13 - SUBS PC,LR
+				//
+				// Encoding T1
+				if (inst32 & 0xFFFFFF00 == 0xF3DE8F00)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section B6.1.13 - SUBS PC,LR Encoding T1");
+
+					// Decoding as per ARM ARM description
+					TUint32 imm8 = inst32 & 0x000000FF;
+					TUint32 imm32 = imm8;
+
+					// TUint32 register_form = EFalse;	// not needed for this decoding
+					// TUint32 opcode = 0x2;	// SUB	// not needed for this decoding
+					TUint32 n = 14;
+
+					// Obtain LR
+					TUint32 lrVal;
+					ReturnIfError(RegisterValue(aThread,n,lrVal));
+
+					TUint32 operand2 = imm32;	// always for Encoding T1
+					
+					TUint32 result = lrVal - operand2;
+					
+					breakAddress = result;
+				}
+				
+				// ARM ARM DDI0406A - section A8.6.16 - B
+				//
+				// Branch Encoding T3
+				if (inst32 & 0xF800D000 == 0xF0008000)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.16 - B Encoding T3");
+
+					// Decoding as per ARM ARM description
+					TUint32 S = inst32 & 0x04000000 >> 26;
+					// TUint32 cond = inst32 & 0x03C00000 >> 22;	// not needed for this decoding
+					TUint32 imm6 = inst32 & 0x003F0000 >> 16;
+					TUint32 J1 = inst32 & 0x00002000 >> 13;
+					TUint32 J2 = inst32 & 0x00000800 >> 11;
+					TUint32 imm11 = inst32 & 0x000007FF;
+
+					TUint32 imm32 = S ? 0xFFFFFFFF : 0 ;
+					imm32 = (imm32 << 1) | J2;
+					imm32 = (imm32 << 1) | J1;
+					imm32 = (imm32 << 6) | imm6;
+					imm32 = (imm32 << 11) | imm11;
+					imm32 = (imm32 << 1) | 0;
+
+					breakAddress = aCurrentPC + imm32;
+				}
+
+				// ARM ARM DDI0406A - section A8.6.16 - B
+				//
+				// Branch Encoding T4
+				if (inst32 & 0xF800D000 == 0xF0009000)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.16 - B");
+
+					// Decoding as per ARM ARM description
+					TUint32 S = inst32 & 0x04000000 >> 26;
+					TUint32 imm10 = inst32 & 0x03FF0000 >> 16;
+					TUint32 J1 = inst32 & 0x00002000 >> 12;
+					TUint32 J2 = inst32 & 0x00000800 >> 11;
+					TUint32 imm11 = inst32 & 0x000003FF;
+
+					TUint32 I1 = !(J1 ^ S);
+					TUint32 I2 = !(J2 ^ S);
+
+					TUint32 imm32 = S ? 0xFFFFFFFF : 0;
+					imm32 = (imm32 << 1) | S;
+					imm32 = (imm32 << 1) | I1;
+					imm32 = (imm32 << 1) | I2;
+					imm32 = (imm32 << 10) | imm10;
+					imm32 = (imm32 << 11) | imm11;
+					imm32 = (imm32 << 1) | 0;
+
+					breakAddress = aCurrentPC + imm32;
+				}
+
+
+				// ARM ARM DDI0406A - section A8.6.225 - TBB, TBH
+				//
+				// Table Branch Byte, Table Branch Halfword
+				if (inst32 & 0xFFF0FFE0 == 0xE8D0F000)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.225 TBB,TBH Encoding T1");
+
+					// Decoding as per ARM ARM description
+					TUint32 Rn = inst32 & 0x000F0000 >> 16;
+					TUint32 H = inst32 & 0x00000010 >> 4;
+					TUint32 Rm = inst32 & 0x0000000F;
+
+					// Unpredictable?
+					if (Rm == 13 || Rm == 15)
+					{
+						LOG_MSG("ARM ARM DDI0406A - section A8.6.225 TBB,TBH Encoding T1 - Unpredictable");
+						break;
+					}
+
+					TUint32 halfwords;
+					TUint32 address;
+					ReturnIfError(RegisterValue(aThread,Rn,address));
+
+					TUint32 offset;
+					ReturnIfError(RegisterValue(aThread,Rm,offset));
+
+					if (H)
+					{
+
+						address += offset << 1;
+					}
+					else
+					{
+						address += offset;
+					}
+
+					ReturnIfError(ReadMem32(aThread,address,halfwords));
+
+					breakAddress = aCurrentPC + 2*halfwords;
+					break;
+				}
+
+				// ARM ARM DDI0406A - section A8.6.55 - LDMDB, LDMEA
+				//
+				// LDMDB Encoding T1
+				if (inst32 & 0xFFD02000 == 0xE9100000)
+				{
+					LOG_MSG("ARM ARM DDI0406 - section A8.6.55 LDMDB Encoding T1");
+
+					// Decoding as per ARM ARM description
+					// TUint32 W = inst32 & 0x00200000 >> 21;	// Not needed for this encoding
+					TUint32 Rn = inst32 & 0x000F0000 >> 16;
+					TUint32 P = inst32 & 0x00008000 >> 15;
+					TUint32 M = inst32 & 0x00004000 >> 14;
+					TUint32 registers = inst32 & 0x00001FFF;
+
+					//TBool wback = (W == 1);	// not needed for this encoding
+
+					// Unpredictable?
+					if (Rn == 15 || BitCount(registers) < 2 || ((P == 1) && (M==1)))
+					{
+						LOG_MSG("ARM ARM DDI0406 - section A8.6.55 LDMDB Encoding T1 - Unpredictable");
+						break;
+					}
+
+					TUint32 address;
+					ReturnIfError(RegisterValue(aThread,Rn,address));
+
+					address -= 4*BitCount(registers);
+
+					for(TInt i=0; i<15; i++)
+					{
+						if (IsBitSet(registers,i))
+						{
+							address +=4;
+						}
+					}
+
+					if (IsBitSet(registers,15))
+					{
+						TUint32 RnVal = 0;
+						ReturnIfError(ReadMem32(aThread,address,RnVal));
+
+						breakAddress = RnVal;
+					}
+					break;
+				}
+
+				// ARM ARM DDI0406A - section A8.6.121 POP
+				//
+				// POP.W Encoding T2
+				if (inst32 & 0xFFFF2000 == 0xE8BD0000)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.121 POP Encoding T2");
+
+					// Decoding as per ARM ARM description
+					TUint32 registers = inst32 & 0x00001FFF;
+					TUint32 P = inst32 & 0x00008000;
+					TUint32 M = inst32 & 0x00004000;
+
+					// Unpredictable?
+					if ( (BitCount(registers)<2) || ((P == 1)&&(M == 1)) )
+					{
+						LOG_MSG("ARM ARM DDI0406A - section A8.6.121 POP Encoding T2 - Unpredictable");
+						break;
+					}
+
+					TUint32 address;
+					ReturnIfError(RegisterValue(aThread,13,address));
+					
+					for(TInt i=0; i< 15; i++)
+					{
+						if (IsBitSet(registers,i))
+						{
+							address += 4;
+						}
+					}
+
+					// Is the PC written?
+					if (IsBitSet(registers,15))
+					{
+						// Yes
+						ReturnIfError(ReadMem32(aThread,address,breakAddress));
+					}
+				}
+
+				// POP Encoding T3
+				if (inst32 & 0xFFFF0FFFF == 0xF85D0B04)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.121 POP Encoding T3");
+
+					// Decoding as per ARM ARM description
+					TUint32 Rt = inst32 & 0x0000F000 >> 12;
+					TUint32 registers = 1 << Rt;
+
+					// Unpredictable?
+					if (Rt == 13 || Rt == 15)
+					{
+						LOG_MSG("ARM ARM DDI0406A - section A8.6.121 POP Encoding T3 - Unpredictable");
+						break;
+					}
+					
+					TUint32 address;
+					ReturnIfError(RegisterValue(aThread,13,address));
+					
+					for(TInt i=0; i< 15; i++)
+					{
+						if (IsBitSet(registers,i))
+						{
+							address += 4;
+						}
+					}
+
+					// Is the PC written?
+					if (IsBitSet(registers,15))
+					{
+						// Yes
+						ReturnIfError(ReadMem32(aThread,address,breakAddress));
+					}
+
+					break;
+				}
+
+				// ARM ARM DDI0406A - section A8.6.53 LDM
+				//
+				// Load Multiple Encoding T2 
+				if ((inst32 & 0xFFD02000) == 0xE8900000)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section A8.6.53 LDM Encoding T2");
+
+					// Decoding as per ARM ARM description
+					TUint32 W = inst32 & 0x0020000 >> 21;
+					TUint32 Rn = inst32 & 0x000F0000 >> 16;
+					TUint32 P = inst32 & 0x00008000 >> 15;
+					TUint32 M = inst32 & 0x00004000 >> 14;
+					TUint32 registers = inst32 & 0x0000FFFF;
+					TUint32 register_list = inst32 & 0x00001FFF;
+				
+					// POP?
+					if ( (W == 1) && (Rn == 13) )
+					{
+						// POP instruction
+						LOG_MSG("ARM ARM DDI0406A - section A8.6.53 LDM Encoding T2 - POP");
+					}
+
+					// Unpredictable?
+					if (Rn == 15 || BitCount(register_list) < 2 || ((P == 1) && (M == 1)) )
+					{
+						LOG_MSG("ARM ARM DDI0406A - section A8.6.53 LDM Encoding T2 - Unpredictable");
+						break;
+					}
+					
+					TUint32 RnVal;
+					ReturnIfError(RegisterValue(aThread,Rn,RnVal));
+
+					TUint32 address = RnVal;
+
+					// Calculate offset of address
+					for(TInt i = 0; i < 15; i++)
+					{
+						if (IsBitSet(registers,i))
+						{
+							address += 4;
+						}
+					}
+
+					// Does it load the PC?
+					if (IsBitSet(registers,15))
+					{
+						// Obtain the value loaded into the PC
+						ReturnIfError(ReadMem32(aThread,address,breakAddress));
+					}
+					break;
+
+				}
+
+				// ARM ARM DDI0406A - section B6.1.8 RFE
+				//
+				// Return From Exception Encoding T1 RFEDB
+				if ((inst32 & 0xFFD0FFFF) == 0xE810C000)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section B6.1.8 RFE Encoding T1");
+
+					// Decoding as per ARM ARM description
+					// TUint32 W = (inst32 & 0x00200000) >> 21;	// not needed for this encoding
+					TUint32 Rn = (inst32 & 0x000F0000) >> 16;
+					
+					// TBool wback = (W == 1);	// not needed for this encoding
+					TBool increment = EFalse;
+					TBool wordhigher = EFalse;
+
+					// Do calculation
+					if (Rn == 15)
+					{
+						// Unpredictable 
+						LOG_MSG("ARM ARM DDI0406A - section B6.1.8 RFE Encoding T1 - Unpredictable");
+						break;
+					}
+
+					TUint32 RnVal = 0;
+					ReturnIfError(RegisterValue(aThread,Rn,RnVal));
+
+					TUint32 address = 0;
+					ReturnIfError(ReadMem32(aThread,RnVal,address));
+
+					if (increment)
+					{
+						address -= 8;
+					}
+
+					if (wordhigher)
+					{
+						address += 4;
+					}				
+
+					breakAddress = address;
+					break;
+				}
+
+				// Return From Exception Encoding T2 RFEIA
+				if ((inst32 & 0xFFD0FFFF) == 0xE990C000)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section B6.1.8 RFE Encoding T2");
+
+					// Decoding as per ARM ARM description
+					// TUint32 W = (inst32 & 0x00200000) >> 21;	// not needed for this encoding
+					TUint32 Rn = (inst32 & 0x000F0000) >> 16;
+					
+					// TBool wback = (W == 1);	// not needed for this encoding
+					TBool increment = ETrue;
+					TBool wordhigher = EFalse;
+
+					// Do calculation
+					if (Rn == 15)
+					{
+						// Unpredictable 
+						LOG_MSG("ARM ARM DDI0406A - section B6.1.8 RFE Encoding T2 - Unpredictable");
+						break;
+					}
+
+					TUint32 RnVal = 0;
+					ReturnIfError(RegisterValue(aThread,Rn,RnVal));
+
+					TUint32 address = 0;
+					ReturnIfError(ReadMem32(aThread,RnVal,address));
+
+					if (increment)
+					{
+						address -= 8;
+					}
+
+					if (wordhigher)
+					{
+						address += 4;
+					}				
+
+					breakAddress = RnVal;
+					break;
+				}
+
+				// Return From Exception Encoding A1 RFE<amode>
+				if ((inst32 & 0xFE50FFFF) == 0xF8100A00)
+				{
+					LOG_MSG("ARM ARM DDI0406A - section B6.1.8 RFE Encoding A1");
+
+					// Decoding as per ARM ARM description
+					TUint32 P = (inst32 & 0x01000000) >> 24;
+					TUint32 U = (inst32 & 0x00800000) >> 23;
+					// TUint32 W = (inst32 & 0x00200000) >> 21; // not needed for this encoding
+					TUint32 Rn = (inst32 & 0x000F0000) >> 16;	
+					
+					// TBool wback = (W == 1);	// not needed for this encoding
+					TBool increment = (U == 1);
+					TBool wordhigher = (P == U);
+
+					// Do calculation
+					if (Rn == 15)
+					{
+						// Unpredictable 
+						LOG_MSG("ARM ARM DDI0406A - section B6.1.8 RFE Encoding A1 - Unpredictable");
+						break;
+					}
+
+					TUint32 RnVal = 0;
+					ReturnIfError(RegisterValue(aThread,Rn,RnVal));
+
+					TUint32 address = 0;
+					ReturnIfError(ReadMem32(aThread,RnVal,address));
+
+					if (increment)
+					{
+						address -= 8;
+					}
+
+					if (wordhigher)
+					{
+						address += 4;
+					}				
+
+					breakAddress = address;
+					break;
+				}
+			}
+
+			// v4T/v5T/v6T instructions
+			switch(thumb_opcode(inst))
+			{		
+				case 0x08:
+				{
+					// Data-processing. See ARM ARM DDI0406A, section A6-8, A6.2.2.
+
+					if ((thumb_inst_7_15(inst) == 0x08F))
+					{
+						// BLX(2)
+						err = iChannel->ReadKernelRegisterValue(aThread, ((inst & 0x0078) >> 3), breakAddress);
+						if(err != KErrNone)
+						{
+							LOG_MSG2("Non-zero error code discarded: %d", err);
+						}
+
+						if ((breakAddress & 0x00000001) == 0)
+						{
+							aChangingModes = ETrue;
+						}
+						
+						breakAddress &= 0xFFFFFFFE;
+
+						// Report how we decoded this instruction
+						LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as BLX (2)");
+					}
+					else if (thumb_inst_7_15(inst) == 0x08E)
+					{
+						// BX
+						err = iChannel->ReadKernelRegisterValue(aThread, ((inst & 0x0078) >> 3), breakAddress);
+						if(err != KErrNone)
+						{
+							LOG_MSG2("Non-zero error code discarded: %d", err);
+						}
+
+						if ((breakAddress & 0x00000001) == 0)
+						{
+							aChangingModes = ETrue;
+						}
+						
+						breakAddress &= 0xFFFFFFFE;
+
+						// Report how we decoded this instruction
+						LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as BX");
+					}
+					else if ((thumb_inst_8_15(inst) == 0x46) && ((inst & 0x87) == 0x87))
+					{
+						// MOV with PC as the destination
+						err = iChannel->ReadKernelRegisterValue(aThread, ((inst & 0x0078) >> 3), breakAddress);
+						if(err != KErrNone)
+						{
+							LOG_MSG2("Non-zero error code discarded: %d", err);
+						}
+
+						// Report how we decoded this instruction
+						LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as MOV with PC as the destination");
+					}
+					else if ((thumb_inst_8_15(inst) == 0x44) && ((inst & 0x87) == 0x87))
+					{
+						// ADD with PC as the destination
+						err = iChannel->ReadKernelRegisterValue(aThread, ((inst & 0x0078) >> 3), breakAddress);
+						if(err != KErrNone)
+						{
+							LOG_MSG2("Non-zero error code discarded: %d", err);
+						}
+						breakAddress += aCurrentPC + 4; // +4 because we need to use the PC+4 according to ARM ARM DDI0406A, section A6.1.2.
+
+						// Report how we decoded this instruction
+						LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as ADD with PC as the destination");
+					}
+					break;
+				}
+				case 0x13:
+				{
+					// Load/Store single data item. See ARM ARM DDI0406A, section A6-10
+
+					//This instruction doesn't modify the PC.
+
+					//if (thumb_inst_8_15(inst) == 0x9F)
+					//{
+						// LDR(4) with the PC as the destination
+					//	breakAddress = ReadRegister(aThread, SP_REGISTER) + (4 * (inst & 0x00FF));
+					//}
+
+					// Report how we decoded this instruction
+					LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as This instruction doesn't modify the PC.");
+					break;
+				}
+				case 0x17:
+				{	
+					// Misc 16-bit instruction. See ARM ARM DDI0406A, section A6-11
+
+					if (thumb_inst_8_15(inst) == 0xBD)
+					{
+						// POP with the PC in the list
+						TUint32 regList = (inst & 0x00FF);
+						TInt offset = 0;
+						err = iChannel->ReadKernelRegisterValue(aThread,  SP_REGISTER, (T4ByteRegisterValue&)offset);
+						if(err != KErrNone)
+						{
+							LOG_MSG2("Non-zero error code discarded: %d", err);
+						}
+						offset += (BitCount(regList) * 4);
+
+						TBuf8<4> destination;
+						err = iChannel->DoReadMemory(aThread, offset, 4, destination);
+						
+						if (KErrNone == err)
+						{
+							breakAddress = *(TUint32 *)destination.Ptr();
+
+							if ((breakAddress & 0x00000001) == 0)
+							{
+								aChangingModes = ETrue;
+							}
+
+							breakAddress &= 0xFFFFFFFE;
+						}
+						else
+						{
+							LOG_MSG("Error reading memory in decoding step instruction");
+						}
+
+						// Report how we decoded this instruction
+						LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as POP with the PC in the list");
+					}
+					break;
+				}
+				case 0x1A:
+				case 0x1B:
+				{	
+					// Conditional branch, and supervisor call. See ARM ARM DDI0406A, section A6-13
+
+					if (thumb_inst_8_15(inst) < 0xDE)
+					{
+						// B(1) conditional branch
+						if (IsExecuted(((inst & 0x0F00) >> 8), aStatusRegister))
+						{
+							TUint32 offset = ((inst & 0x000000FF) << 1);
+							if (offset & 0x00000100)
+							{
+								offset |= 0xFFFFFF00;
+							}
+							
+							breakAddress = aCurrentPC + 4 + offset;
+
+							// Report how we decoded this instruction
+							LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as B(1) conditional branch");
+						}
+					}
+					break;
+				}
+				case 0x1C:
+				{
+					// Unconditional branch, See ARM ARM DDI0406A, section A8-44.
+
+					// B(2) unconditional branch
+					TUint32 offset = (inst & 0x000007FF) << 1;
+					if (offset & 0x00000800)
+					{
+						offset |= 0xFFFFF800;
+					}
+					
+					breakAddress = aCurrentPC + 4 + offset;
+
+					// Report how we decoded this instruction
+					LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as B(2) unconditional branch");
+
+					break;
+				}
+				case 0x1D:
+				{
+					if (!(inst & 0x0001))
+					{
+						// BLX(1)
+						err = iChannel->ReadKernelRegisterValue(aThread, LINK_REGISTER, breakAddress);
+						if(err != KErrNone)
+						{
+							LOG_MSG2("Non-zero error code discarded: %d", err);
+						}
+						breakAddress +=  ((inst & 0x07FF) << 1);
+						if ((breakAddress & 0x00000001) == 0)
+						{
+							aChangingModes = ETrue;
+						}
+
+						breakAddress &= 0xFFFFFFFC;
+
+						// Report how we decoded this instruction
+						LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as BLX(1)");
+
+					}
+					break;
+				}
+				case 0x1E:
+				{
+                    // Check for ARMv7 CPU
+                    if(cpuid == 0xC0)
+                    {
+    					// BL/BLX 32-bit instruction
+	    				aNewRangeEnd += 4;
+
+						breakAddress = (TUint32)thumb_instr_b_dest(inst32, aCurrentPC);
+
+            			if((inst32 >> 27) == 0x1D)
+            			{
+            			    // BLX(1)
+    						if ((breakAddress & 0x00000001) == 0)
+	    					{
+		    					aChangingModes = ETrue;
+			    			}
+    
+	    					breakAddress &= 0xFFFFFFFC;
+
+    						// Report how we decoded this instruction
+	    					LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as 32-bit BLX(1)");
+                        }
+                        else
+                        {                            
+    					    // Report how we decoded this instruction
+	        				LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: 32-bit BL instruction");
+                        }
+        				LOG_MSG2(" 32-bit BL/BLX instruction: breakAddress = 0x%X", breakAddress);
+                    }            
+                    else
+                    {
+					    // BL/BLX prefix - destination is encoded in this and the next instruction
+					    aNewRangeEnd += 2;
+
+					    // Report how we decoded this instruction
+					    LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: BL/BLX prefix - destination is encoded in this and the next instruction");
+                    }
+
+
+					break;
+				}
+				case 0x1F:
+				{
+					{
+						// BL
+						err = iChannel->ReadKernelRegisterValue(aThread, LINK_REGISTER, breakAddress);
+						if(err != KErrNone)
+						{
+							LOG_MSG2("Non-zero error code discarded: %d", err);
+						}
+						breakAddress += ((inst & 0x07FF) << 1);
+
+						// Report how we decoded this instruction
+						LOG_MSG("DRMDStepping::PCAfterInstructionExecutes: Decoded as BL");
+					}
+					break;
+				}
+				default:
+					{
+						// Don't know any better at this point!
+						LOG_MSG("DRMDStepping::PCAfterInstructionExecutes:- default to next instruction");
+					}
+					break;
+			}
+		}
+		break;
+		
+		case Debug::EThumb2EEMode:
+		{
+			// Not yet supported
+			LOG_MSG("DRMDStepping::PCAfterInstructionExecutes - Debug::EThumb2Mode is not supported");
+
+		}
+		break;
+
+		default:
+			LOG_MSG("DRMDStepping::PCAfterInstructionExecutes - Cannot determine CPU mode architecture");
+	}	
+
+	LOG_MSG2("DRMDStepping::PCAfterInstructionExecutes : return 0x%08x",breakAddress);
+	return breakAddress;
+}
+
+// Obtain a 32-bit memory value with minimum fuss
+TInt DDebuggerEventHandler::ReadMem32(DThread* aThread, const TUint32 aAddress, TUint32& aValue)
+	{
+	TBuf8<4> valBuf;
+	TInt err = iChannel->DoReadMemory(aThread, aAddress, 4, valBuf);
+	if (err != KErrNone)
+		{
+		LOG_MSG2("DRMDStepping::ReadMem32 failed to read memory at 0x%08x", aAddress);
+		return err;
+		}
+
+	aValue = *(TUint32 *)valBuf.Ptr();
+
+	return KErrNone;
+	}
+
+// Obtain a 16-bit memory value with minimum fuss
+TInt DDebuggerEventHandler::ReadMem16(DThread* aThread, const TUint32 aAddress, TUint16& aValue)
+	{
+	TBuf8<2> valBuf;
+	TInt err = iChannel->DoReadMemory(aThread, aAddress, 2, valBuf);
+	if (err != KErrNone)
+		{
+		LOG_MSG2("DRMDStepping::ReadMem16 failed to read memory at 0x%08x", aAddress);
+		return err;
+		}
+
+	aValue = *(TUint16 *)valBuf.Ptr();
+
+	return KErrNone;
+	}
+
+/*TOMSCI
+// Obtain a 16-bit memory value with minimum fuss
+TInt DRMDStepping::ReadMem8(DThread* aThread, const TUint32 aAddress, TUint8& aValue)
+	{
+	TBuf8<1> valBuf;
+	TInt err = iChannel->DoReadMemory(aThread, aAddress, 1, valBuf);
+	if (err != KErrNone)
+		{
+		LOG_MSG2("DRMDStepping::ReadMem8 failed to read memory at 0x%08x", aAddress);
+		return err;
+		}
+
+	aValue = *(TUint8 *)valBuf.Ptr();
+
+	return KErrNone;
+	}
+END TOMSCI*/
+
+// Obtain a core register value with minimum fuss
+TInt DDebuggerEventHandler::RegisterValue(DThread *aThread, const TUint32 aKernelRegisterId, TUint32 &aValue)
+	{
+	TInt err = iChannel->ReadKernelRegisterValue(aThread, aKernelRegisterId, aValue);
+	if(err != KErrNone)
+		{
+		LOG_MSG3("DRMDStepping::RegisterValue failed to read register %d err = %d", aKernelRegisterId, err);
+		}
+		return err;
+	}
+
+
+// Encodings from ARM ARM DDI0406A, section 9.2.1
+enum TThumb2EEOpcode
+{
+	EThumb2HDP,		// Handler Branch with Parameter
+	EThumb2UNDEF,	// UNDEFINED
+	EThumb2HB,		// Handler Branch, Handler Branch with Link
+	EThumb2HBLP,	// Handle Branch with Link and Parameter
+	EThumb2LDRF,	// Load Register from a frame
+	EThumb2CHKA,	// Check Array
+	EThumb2LDRL,	// Load Register from a literal pool
+	EThumb2LDRA,	// Load Register (array operations)
+	EThumb2STR		// Store Register to a frame
+};
+
+TUint32 DDebuggerEventHandler::ShiftedRegValue(DThread *aThread, TUint32 aInstruction, TUint32 aCurrentPC, TUint32 aStatusRegister)
+{
+	LOG_MSG("DRM_DebugChannel::ShiftedRegValue()");
+
+	TUint32 shift = 0;
+	if (aInstruction & 0x10)	// bit 4
+	{
+		shift = (arm_rs(aInstruction) == PC_REGISTER ? aCurrentPC + 8 : aStatusRegister) & 0xFF;
+	}
+	else
+	{
+		shift = arm_data_c(aInstruction);
+	}
+	
+	TInt rm = arm_rm(aInstruction);
+	
+	TUint32 res = 0;
+	if(rm == PC_REGISTER)
+	{
+		res = aCurrentPC + ((aInstruction & 0x10) ? 12 : 8);
+	}
+	else
+	{
+		TInt err = iChannel->ReadKernelRegisterValue(aThread, rm, res);
+		if(err != KErrNone)
+		{
+			LOG_MSG2("DRMDStepping::ShiftedRegValue - Non-zero error code discarded: %d", err);
+		}
+	}
+
+	switch(arm_data_shift(aInstruction))
+	{
+		case 0:			// LSL
+		{
+			res = shift >= 32 ? 0 : res << shift;
+			break;
+		}
+		case 1:			// LSR
+		{
+			res = shift >= 32 ? 0 : res >> shift;
+			break;
+		}
+		case 2:			// ASR
+		{
+			if (shift >= 32)
+			shift = 31;
+			res = ((res & 0x80000000L) ? ~((~res) >> shift) : res >> shift);
+			break;
+		}
+		case 3:			// ROR/RRX
+		{
+			shift &= 31;
+			if (shift == 0)
+			{
+				res = (res >> 1) | ((aStatusRegister & arm_carry_bit()) ? 0x80000000L : 0);
+			}
+			else
+			{
+				res = (res >> shift) | (res << (32 - shift));
+			}
+			break;
+    	}
+    }
+
+  	return res & 0xFFFFFFFF;
+}
+
+//
+// DRMDStepping::CurrentPC
+//
+// 
+//
+TInt DDebuggerEventHandler::CurrentPC(DThread* aThread, TUint32& aPC)
+	{
+	LOG_MSG("DRMDStepping::CurrentPC");
+
+	TInt err = iChannel->ReadKernelRegisterValue(aThread, PC_REGISTER, aPC);
+	if(err != KErrNone)
+		{
+		// We don't know the current PC for this thread!
+		LOG_MSG("DRMDStepping::CurrentPC - Failed to read the current PC");
+		
+		return KErrGeneral;
+		}
+
+	LOG_MSG2("DRMDStepping::CurrentPC 0x%08x", aPC);
+
+	return KErrNone;
+	}
+
+TInt DDebuggerEventHandler::CurrentCPSR(DThread* aThread, TUint32& aCPSR)
+	{
+	LOG_MSG("DRMDStepping::CurrentCPSR");
+
+	TInt err = iChannel->ReadKernelRegisterValue(aThread, STATUS_REGISTER, aCPSR);
+	if(err != KErrNone)
+		{
+		// We don't know the current PC for this thread!
+		LOG_MSG("DRMDStepping::CurrentPC - Failed to read the current CPSR");
+		
+		return KErrGeneral;
+		}
+
+	LOG_MSG2("DRMDStepping::CurrentCPSR 0x%08x", aCPSR);
+	
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+prj_exports
+FSHELL_ROM_INCLUDE2(memoryaccess.iby, memoryaccess-fshell.iby)
+
+#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
+
+memoryaccess.h       fshell/memoryaccess.h
+
+prj_mmpfiles
+
+memoryaccess.mmp
+
+#endif // FSHELL_MEMORY_ACCESS_SUPPORT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/bmarm/memoryaccess.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	CreateLogicalDevice__Fv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/bwins/memoryaccess.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?CreateLogicalDevice@@YAPAVDLogicalDevice@@XZ @ 1 NONAME ; class DLogicalDevice * CreateLogicalDevice(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/dobject.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,204 @@
+// dobject.h
+// 
+// Copyright (c) 1998 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+/** 
+@file
+@internalTechnology
+*/
+
+#ifndef __DOBJECT_H__
+#define __DOBJECT_H__
+
+#ifdef _DEBUG
+// In DEBUG builds use linear growth by 1 to aid kernel heap checking
+#else
+const TInt KObjectConMinSize=8;
+#endif
+const TInt KObjectIxGranularity=8;
+const TInt KObjectIndexMask=0x7fff;
+const TInt KObjectMaxIndex=0x7fff;
+const TInt KObjectInstanceShift=16;
+const TInt KObjectInstanceMask=0x3fff;
+const TInt KObjectIxMaxHandles=0x8000;
+
+inline TInt index(TInt aHandle)
+	{return(aHandle&KObjectIndexMask);}
+inline TInt instance(TInt aHandle)
+	{return((aHandle>>KObjectInstanceShift)&KObjectInstanceMask);}
+inline TInt instanceLimit(TInt& aCount)
+	{return ((aCount&KObjectInstanceMask)==0) ? ((++aCount)&KObjectInstanceMask) : aCount&KObjectInstanceMask;}
+inline TInt makeHandle(TInt aIndex, TInt aInstance)
+	{return((TInt)((aInstance<<KObjectInstanceShift)|aIndex));}
+
+enum TDObjectPanic
+	{
+	EObjObjectStillReferenced,
+	EObjNegativeAccessCount,
+	EObjRemoveObjectNotFound,
+	EObjRemoveContainerNotFound,
+	EObjRemoveBadHandle,
+	EObjFindBadHandle,
+	EObjFindIndexOutOfRange,
+	EDObjectConDestroyed,
+	EArrayIndexOutOfRange,
+	EObjInconsistent,
+	};
+
+inline void Panic(TDObjectPanic aPanic)
+	{ Kern::Fault("DOBJECT",aPanic); }
+
+
+//BEGIN TOMSCI
+// This is needed because on 9.1 the DObjectIx header is defined as IMPORT_C
+#undef IMPORT_C
+#define IMPORT_C
+#define DObjectIx DObjectIxNinePointTwoHack // So that we're not redefining DObjectIx
+
+NONSHARABLE_CLASS(DObjectIx) : public DBase
+	{
+public:
+	enum {ENoClose=KHandleNoClose,ELocalHandle=0x40000000};
+public:
+	IMPORT_C static DObjectIx* New(TAny* aPtr);
+	IMPORT_C ~DObjectIx();
+	IMPORT_C TInt Add(DObject* aObj, TInt& aHandle);
+	IMPORT_C TInt Remove(TInt aHandle, DObject*& aObject, TAny*& aPtr);
+	IMPORT_C DObject* At(TInt aHandle,TInt aUniqueID);
+	IMPORT_C DObject* At(TInt aHandle);
+	IMPORT_C TInt At(DObject* aObject);
+	IMPORT_C TInt Count(DObject* aObject);
+	IMPORT_C DObject* operator[](TInt aIndex);
+	TInt LastHandle();
+	static void Wait();
+	static void Signal();
+	inline TInt Count();
+	inline TInt ActiveCount();
+protected:
+	IMPORT_C DObjectIx(TAny* aPtr);
+private:
+	void UpdateState();
+private:
+	TInt iNextInstance;
+	TInt iAllocated;		// Max entries before realloc needed
+	TInt iCount;			// Points to at least 1 above the highest active index
+	TInt iActiveCount;		// Number of actual entries in the index
+	SDObjectIxRec* iObjects;
+	TAny* iPtr;
+	TInt iFree;				// The index of the first free slot or -1.
+	TInt iUpdateDisabled;   // If >0, disables: iCount update, reorder of the free list and memory shrinking.
+public:
+	static DMutex* HandleMutex;
+public:
+	friend void PreprocessHandler();
+	friend class DThread;
+	friend class K;
+	friend class Monitor;
+	};
+
+inline TInt DObjectIx::Count()
+	{return iCount;}
+inline TInt DObjectIx::ActiveCount()
+	{return iActiveCount;}
+
+#undef DObjectIx
+	
+//
+// Include these in a header file
+//
+
+__ASSERT_COMPILE(sizeof(DObject) == 6*4 || sizeof(DObject) == 8*4); // We can't cope if the size changes again!
+#define DOBJECT_PADDING TUint64 _padding
+const TBool KCompiledUsingOldDefinition = sizeof(DObject) == 6*4;
+#define ADD_PADDING(type, variablePtr) (*reinterpret_cast<type*>((TUint8*)variablePtr + sizeof(TUint64)))
+#define SUBTRACT_PADDING(type, variablePtr) (*reinterpret_cast<type*>((TUint8*)variablePtr - sizeof(TUint64)))
+
+
+template <class T>
+class TemplatedPadder
+	{
+public:
+	inline static T& AddPadding(T* aPtr)
+		{
+		return ADD_PADDING(T, aPtr);
+		}
+	inline static T& SubtractPadding(T* aPtr)
+		{
+		return SUBTRACT_PADDING(T, aPtr);
+		}
+	};
+
+template <class T>
+inline T& AddPadding(T* aPtr)
+	{
+	return TemplatedPadder<T>::AddPadding(aPtr);
+	}
+
+template <class T>
+inline T& SubtractPadding(T* aPtr)
+	{
+	return TemplatedPadder<T>::SubtractPadding(aPtr);
+	}
+
+TBool CalculateDObjectSize(); // returns false if unable to determine 
+extern TBool gRunningWithOldDefinition;
+
+/* The SAFE_MEMBER macro exists because DObject grew by 64 bits between 9.1 and 9.2, therefore to write a 
+ * DObject-derived class (such as a DLogicalChannel in an LDD) that can be compiled on one but also works on the
+ * other requires that you be very careful accessing member data of your DObject-derived objects, because the 
+ * offsets are different on the two OS releases. This macro abstracts the differences away by calculating when
+ * an 8 byte correction needs to be applied to where the compiler thinks the variable is versus where the runtime
+ * knows it is. By necessity, it has a weird definition, that relies on the above helper macros and also on
+ * CalculateDObjectSize being called at some point before the first time any code using SAFE_MACRO is run.
+ * It is recommended that for an LDD, you call it from within your DECLARE_EXTENSION_LDD before doing anything
+ * else.
+ * 
+ * SAFE_MEMBER can only be used to access member data of DObject-derived classes, and should be used in ALL 
+ * places where the instance variables are used or set, this includes instance variables of the superclass and
+ * instance variables in DObject-derived objects you define yourself. Accesses to instance variables of DObject
+ * itself must NOT use this macro, since the DObject variable offsets do not change. In order to make sure your
+ * class is large enough and that the macro can be used consistantly, you must include a DOBJECT_PADDING at 
+ * the *end* of all of your DObject subclass definition. You won't get any warning if you forget to do this,
+ * It will just crash. Likewise if you use SAFE_MEMBER to access the member data of the DObject itself.
+ * 
+ * In other words:
+ * DO use SAFE_MEMBER to access the member data of DMyClassThatIsDerivedFromDObject
+ * DO use SAFE_MEMBER to access the member data of DLogicalChannel/DLogicalDevice/DThread etc
+ * DON'T use it to access the member data of DObject itself
+ * ALWAYS include a DOBJECT_PADDING at the end of your DMyDObjectDerivedClass - ie after any other member data
+ * 
+ */
+
+#define SAFE_MEMBER(variable) ( \
+	(KCompiledUsingOldDefinition && gRunningWithOldDefinition) ? variable : ( \
+	(KCompiledUsingOldDefinition && !gRunningWithOldDefinition) ? AddPadding(&variable) : ( \
+	(!KCompiledUsingOldDefinition && gRunningWithOldDefinition) ? SubtractPadding(&variable) : ( \
+	/* running and compiling with new-definition DObject */ variable ))))
+
+/* Old definition that doesn't require templating to work, (so is callable from non-C++). A consequence is you
+ * have to explicitly give the type of the variable.
+ */
+//#define SAFE_MEMBER(type, variable) ( \
+//	(KCompiledUsingOldDefinition && gRunningWithOldDefinition) ? variable : ( \
+//	(KCompiledUsingOldDefinition && !gRunningWithOldDefinition) ? ADD_PADDING(type, &variable) : ( \
+//	(!KCompiledUsingOldDefinition && gRunningWithOldDefinition) ? SUBTRACT_PADDING(type, &variable) : ( \
+//	/* running and compiling with new-definition DObject */ variable ))))
+
+
+/* These macros are equivalent to _FOFF and _LOFF and should be used whenever
+ * f refers to a member variable that you would need to use SAFE_MEMBER on
+ */
+#define _SAFE_FOFF(c,f)			(((TInt)&  SAFE_MEMBER((((c *)0x1000)->f) )  )-0x1000)
+#define _SAFE_LOFF(p,T,f) ((T*)(((TUint8*)(p))-_SAFE_FOFF(T,f)))
+
+//END TOMSCI
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/eabi/memoryaccess.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z19CreateLogicalDevicev @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/fdebuggerkernel.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1642 @@
+// fdebuggerkernel.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "fdebuggerkernel.h"
+#include "DynamicDfcSupport.h"
+#ifdef __MARM__
+#	include <arm/arm.h>
+#	if defined(FSHELL_ARM11XX_SUPPORT) || defined(FSHELL_ARM_MEM_MAPPED_DEBUG)
+//#		ifndef __MEMMODEL_MULTIPLE__
+//#			error "FSHELL_ARM11XX_SUPPORT is only supported on platforms using the multiple memory model!"
+//#		endif
+#	include <multiple/memmodel.h>
+#	endif
+#endif
+#include "memoryaccess.h"
+
+#if !defined(__EABI__) && defined(FSHELL_ARM_MEM_MAPPED_DEBUG)
+#undef FSHELL_ARM_MEM_MAPPED_DEBUG
+#endif
+
+#ifdef ASSERT
+#undef ASSERT
+#endif
+#ifdef __WINS__
+#define ASSERT(x) __ASSERT_ALWAYS((x), Kern::Fault("Assertion failed: " #x, __LINE__))
+#else
+#define ASSERT(x) if (!(x)) { Kern::Printf("Assertion failed @ %d: " #x, __LINE__); NKern::Sleep(NKern::TimerTicks(5000)); }
+#endif
+
+#define ASSERT_LOCKED() ASSERT(Kern::CurrentThread().iNThread.iHeldFastMutex == &iLock)
+#define ASSERT_UNLOCKED() ASSERT(Kern::CurrentThread().iNThread.iHeldFastMutex == NULL)
+#define ASSERT_BREAKPOINT_LOCKED() ASSERT(iBreakpointMutex->iCleanup.iThread == &Kern::CurrentThread());
+#define ASSERT_BREAKPOINT_UNLOCKED() ASSERT(iBreakpointMutex->iCleanup.iThread != &Kern::CurrentThread());
+
+//#define LOG(args...) Kern::Printf(args)
+#define LOG(args...)
+
+void MCR_SetContextIdBrp(TInt aRegister, TUint aContextId);
+void MCR_SetBreakpointPair(TInt aRegister, TUint aBvrValue, TUint aBcrValue);
+TUint MRC_ReadBcr(TInt aRegister);
+TUint32 GetDscr();
+void MCR_SetDscr(TUint32 aVal);
+TUint32 GetDsar();
+TUint32 GetDrar();
+TUint32 GetContextId();
+void Dsb();
+void Isb();
+void Imb();
+
+enum TMemMappedDebugAddresses
+	{
+	EDscrOffset = 0x88,
+	EBvrOffset = 0x100,
+	EBcrOffset = 0x140,
+	ELockAccessOffset = 0xFB0,
+	EAuthStatusOffset = 0xFB8,
+	};
+
+
+DDebuggerEventHandler* DDebuggerEventHandler::New(TDfcQue* aQue)
+	{
+	// This is backwards from the usual constructor, 2nd phase construction pattern because I can't do anything that could
+	// error after creating a DKernelEventHandler, because we get called from DLogicalDevice::Install(). So the stuff that would normally
+	// be done as 2nd-phase construction is done first
+
+	DMutex* breakpointMutex = NULL;
+	TInt err = Kern::MutexCreate(breakpointMutex, _L("FDebuggerBreakpointMutex"), KMutexOrdGeneral5); // No special reason for using 5
+	if (err) return NULL;
+
+	DDebuggerEventHandler* self = new DDebuggerEventHandler(aQue);
+	if (self)
+		{
+		self->iBreakpointMutex = breakpointMutex;
+		self->Add();
+		}
+	else
+		{
+		breakpointMutex->Close(NULL);
+		}
+	return self;
+	}
+
+DDebuggerEventHandler::DDebuggerEventHandler(TDfcQue* aQue)
+	: DKernelEventHandler(&Event, this), iNextBreakpointId(1), iHandleCodesegRemovedDfc(&HandleCodesegRemoved, this, aQue, 0)
+	{
+#if defined(FSHELL_ARM11XX_SUPPORT) || defined(FSHELL_ARM_MEM_MAPPED_DEBUG)
+	iFreeHwBreakpoints = 0x3F; // BRPs 0,1,2,3,4,5 (at a minimum) are supported on ARM11xx or later
+#endif
+	}
+
+/*static*/ TUint DDebuggerEventHandler::Event(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aPrivateData)
+	{
+	DDebuggerEventHandler* self = static_cast<DDebuggerEventHandler*>(aPrivateData);
+	return self->DoEvent(aEvent, a1, a2);
+	}
+
+TUint DDebuggerEventHandler::DoEvent(TKernelEvent aEvent, TAny* a1, TAny* a2)
+	{
+	//if (aEvent != EEventUserTrace) Kern::Printf("fdbk: Event %d a1=%d a2=%d", aEvent, a1, a2);
+
+	if (aEvent == EEventKillThread)
+		{
+#ifdef __MARM__
+		LOG("Thread %x %O with contextId %x killed", &Kern::CurrentThread().iNThread, &Kern::CurrentThread(), GetContextId());
+#endif
+		if (iZombieMode == EAllExits || (iZombieMode == EAbnormalExit && Kern::CurrentThread().iExitType != EExitKill))
+			{
+			// The thread in question is Kern::CurrentThread()
+			Zombify();
+			}
+		RemoveAllHardwareBreakpointsForThread(&Kern::CurrentThread()); // The thread ID could get reused so make sure we clean up
+		}
+	else if (aEvent == EEventHwExc)
+		{
+		// Breakpoint?
+#ifdef __MARM__
+		TArmExcInfo* info = (TArmExcInfo*)a1;
+		LOG("fdbk: Exception excCode=%d addr=0x%08x", info->iExcCode, info->iR15);
+		SBreakpoint* b = NULL;
+		TLinAddr excAddr = info->iR15 & ~1;
+		BreakpointLock();
+		if (info->iExcCode == 0)
+			{
+			// EArmExceptionPrefetchAbort - Could be a HW breakpoint
+			b = FindHardwareBreakpoint(&Kern::CurrentThread(), excAddr);
+			}
+		else if (info->iExcCode == 2)
+			{
+			// EArmExceptionUndefinedOpcode - SW breakpoint?
+			b = FindBreakpointByAddress(excAddr);
+			}
+		
+		LOG("fdbk: Found breakpoint %d", b ? b->iBreakpointId : -1);
+
+		if (b == NULL)
+			{
+			// Not one of ours, we should allow it to blow up (or be handled by someone else)
+			// It could of course be a thread hitting a breakpoint we've just removed, in which case I'm not sure what we can do other than let
+			// the thread crash... hopefully this won't happen in practice!
+			BreakpointUnlock();
+			return ERunNext;
+			}
+
+		TBool shouldBreak = b->MatchesThread(&Kern::CurrentThread()); // Check if it's the wrong thread
+		if (b->iFlags & SBreakpoint::ETempContinue)
+			{
+			// It's a temporary break-at-next-instruction used while continuing a thread.
+			if (shouldBreak)
+				{
+				// Excellent, we have sucessfully continued from a breakpoint. Restore the original, clear the temp (and any threads waiting on it), resume this thread and we're done
+				SBreakpoint* orig = b->iRealBreakpoint;
+				if (orig->IsHardware()) ClearBreakpoint(b, ETrue); // Clear HW first 
+				TInt err = KErrNone;
+				if ((orig->iFlags & SBreakpoint::EDisabled) == SBreakpoint::EDisabledDuringContinue)
+					{
+					// Only resume it if it hasn't been disabled for some other reason in the meantime
+					err = ApplyBreakpoint(orig);
+					}
+
+				if (err)
+					{
+					Kern::Printf("fdbk: failed to re-enable breakpoint id %d", orig->iBreakpointId);
+					// What to do?
+					}
+				else
+					{
+					// Clear the disabled flag
+					orig->iFlags &= ~SBreakpoint::EDisabledDuringContinue;
+					}
+
+				if (!orig->IsHardware()) ClearBreakpoint(b, ETrue);
+				BreakpointUnlock();
+				return (TUint)EExcHandled;
+				}
+			else
+				{
+				// Any other threads unlucky enough to hit our temp breakpoint will just have to wait until we see our target thread - otherwise
+				// we'll end up with temp breakpoints for the temp breakpoints and the universe will implode.
+				BreakpointUnlock();
+				Zombify(excAddr);
+				return (TUint)EExcHandled;
+				}
+			}
+		TInt id = b->iBreakpointId;
+		BreakpointUnlock();
+		if (shouldBreak)
+			{
+			// TODO should we suspend the thread rather than semaphoring it, to be more efficient?
+			if (iBreakpointNotifyClient)
+				{
+				RMemoryAccess::TBreakpointNotification notif;
+				notif.iThreadId = Kern::CurrentThread().iId;
+				notif.iBreakpointId = id;
+				notif.iAddress = excAddr;
+				TPckg<RMemoryAccess::TBreakpointNotification> pkg(notif);
+				// We shouldn't really pass blobs of data...
+				iBreakpointNotifyClient->BreakpointHit(pkg);
+				}
+			Zombify(excAddr);
+			}
+		else
+			{
+			TInt err = ContinueFromBreakpoint(&Kern::CurrentThread(), excAddr);
+			if (err) return ERunNext; // If we failed to continue, we shouldn't pretend we've handled it
+			}
+		return (TUint)DKernelEventHandler::EExcHandled;
+#else
+		(void)a1;
+#endif
+		}
+	else if (aEvent == EEventRemoveCodeSeg)
+		{
+		DCodeSeg* codeseg = (DCodeSeg*)a1;
+		DProcess* proc = (DProcess*)a2;
+		// We can't scan the breakpoint list at this point, because we'd need to call BreakpointLock() and 
+		// we're currently holding the codeseg lock. So queue a DFC.
+		SRemovedCodeseg* removed = new SRemovedCodeseg;
+		if (removed)
+			{
+			removed->iCodeseg = codeseg;
+			removed->iProcess = proc;
+			Lock();
+			iRemovedCodesegs.Add(&removed->iLink);
+			Unlock();
+			NKern::ThreadEnterCS();
+			iHandleCodesegRemovedDfc.Enque();
+			NKern::ThreadLeaveCS();
+			}
+		}
+	else if (aEvent == EEventRemoveThread)
+		{
+		DThread* thread = (DThread*)a1;
+		TCreatorInfo dummy(thread->iId, 0);
+		BreakpointLock(); // It's not actually breakpoint related but never mind
+		TInt found = iCreatorInfo.FindInUnsignedKeyOrder(dummy);
+		if (found != KErrNotFound)
+			{
+			iCreatorInfo.Remove(found);
+			}
+		BreakpointUnlock();
+		}
+	else if (aEvent == EEventRemoveProcess)
+		{
+		// In case a thread dies before creating its first thread, try to remove the creator info we stashed
+		DProcess* proc = (DProcess*)a1;
+		TCreatorInfo dummy(proc->iId, 0);
+		BreakpointLock();
+		TInt found = iCreatorInfo.FindInUnsignedKeyOrder(dummy);
+		if (found != KErrNotFound)
+			{
+			iCreatorInfo.Remove(found);
+			}
+		BreakpointUnlock();
+		}
+	else if (aEvent == EEventAddProcess)
+		{
+		// We need to use EEventAddProcess as well as EEventAddThread, because EEventAddThread doesn't do the special check for the creator not being the current thread, meaning for process creation the main thread always appears to have been created by the loader and not be the person who created the process
+		// Remember the process for when we come to add the thread
+		DProcess* process = (DProcess*)a1;
+		DThread* creator = (DThread*)a2;
+		BreakpointLock();
+		TCreatorInfo threadInfo(process->iId, creator->iId);
+		TInt err = iCreatorInfo.InsertInUnsignedKeyOrder(threadInfo);
+		if (err)
+			{
+			LOG("Failed to InsertInUnsignedKeyOrder err=%d", err);
+			}
+		BreakpointUnlock();
+		}
+	else if (aEvent == EEventAddThread)
+		{
+		DThread* thread = (DThread*)a1;
+		DThread* creator = (DThread*)a2;
+		TCreatorInfo threadInfo(thread->iId, creator->iId);
+
+		BreakpointLock(); // It's not actually breakpoint related but never mind
+		if (thread->Owner() != creator->Owner())
+			{
+			// This means we're probably the first thread of a new process, and our 'creator' is the loader thread. Use the info we stashed earlier about the process's creator instead
+			TCreatorInfo dummy(((DProcess*)thread->Owner())->iId, 0);
+			TInt found = iCreatorInfo.FindInUnsignedKeyOrder(dummy);
+			if (found != KErrNotFound)
+				{
+				threadInfo.iCreatorThreadId = iCreatorInfo[found].iCreatorThreadId;
+				// We don't need to track the process creator for anything else
+				iCreatorInfo.Remove(found);
+				}
+			}
+		TInt err = iCreatorInfo.InsertInUnsignedKeyOrder(threadInfo);
+		if (err)
+			{
+			LOG("Failed to InsertInUnsignedKeyOrder err=%d", err);
+			}
+		BreakpointUnlock();
+		}
+	return ERunNext;
+	}
+
+TInt DDebuggerEventHandler::Zombify(TLinAddr aBreakpointAddr)
+	{
+	// The purpose of this code is to prevent dying threads from taking down their address space, so that we can still poke at their memory
+	// Currently, it is also used to pause a thread on a breakpoint
+	SZombie zom; // zombies go on the stack of the thread that is being halted. That way avoids having to alloc.
+	zom.iThread = &Kern::CurrentThread();
+	zom.iBlocker = NULL;
+	zom.iBreakpointAddress = aBreakpointAddr;
+	TBuf8<32> semName;
+	semName.Append(_L8("ThreadZombiefier-"));
+	semName.AppendNum((TUint)zom.iThread->iId);
+	NKern::ThreadEnterCS();
+	TInt err = Kern::SemaphoreCreate(zom.iBlocker, semName, 0);
+	if (err)
+		{
+		NKern::ThreadLeaveCS();
+		return err;
+		}
+	Lock();
+	iZombies.Add(&zom.iLink);
+	iZombieCount++;
+	Unlock();
+	zom.iThread->Open(); // So no-one is tempted to destroy it
+	NKern::ThreadLeaveCS();
+	Kern::SemaphoreWait(*zom.iBlocker);
+	// The above blocks until a "fdb detach" or equivalent has happened, at which point we'll get signalled on this semaphore and should clean up
+	zom.iBlocker->Close(NULL);
+	zom.iThread->Close(NULL);
+	return KErrNone;
+	}
+
+TInt DDebuggerEventHandler::GetZombieMode()
+	{
+	Lock();
+	TInt res = iZombieMode;
+	Unlock();
+	return res;
+	}
+
+TInt DDebuggerEventHandler::SetZombieMode(TInt aMode)
+	{
+	Lock();
+	iZombieMode = (TZombieMode)aMode;
+	Unlock();
+	if (aMode == EDisabled)
+		{
+		ClearAllBreakpoints(); // This is not exactly obvious, but unblocking a zombie that's blocked on a breakpoint necessarily means you have to remove the breakpoint
+		CompleteZombies();
+		}
+	
+	return KErrNone;
+	}
+
+void DDebuggerEventHandler::CompleteZombies()
+	{
+	ASSERT_UNLOCKED();
+	// enter and exit with lock not held
+	for (;;)
+		{
+		Lock();
+		SDblQueLink* link = iZombies.IsEmpty() ? NULL : iZombies.First();
+		if (!link)
+			{
+			Unlock();
+			break;
+			}
+		SZombie* zom = _LOFF(link, SZombie, iLink);
+		ReleaseZombieAndUnlock(zom);
+		}
+	}
+
+void DDebuggerEventHandler::UnsuspendThread(SZombie* aZombie)
+	{
+	Kern::ThreadResume(*aZombie->iThread);
+	aZombie->iThread->Close(NULL);
+	delete aZombie;
+	}
+
+TInt DDebuggerEventHandler::SuspendThread(DThread* aThread)
+	{
+	// This is the only case where an SZombie goes on the heap - usually they are created in the context of their thread so go on that thread's stack
+	SZombie* zom = new SZombie;
+	if (!zom) return KErrNoMemory;
+	zom->iThread = aThread;
+	zom->iThread->Open();
+	zom->iBlocker = NULL;
+	Lock();
+	iZombies.Add(&zom->iLink);
+	iZombieCount++;
+	Unlock();
+	Kern::ThreadSuspend(*zom->iThread, 1);
+	return KErrNone;
+	}
+
+void DDebuggerEventHandler::Lock()
+	{
+	NKern::FMWait(&iLock);
+	}
+
+void DDebuggerEventHandler::Unlock()
+	{
+	NKern::FMSignal(&iLock);
+	}
+
+DDebuggerEventHandler::~DDebuggerEventHandler()
+	{
+	// The call to SetZombieMode below is actually pretty pointless: the kernel increments our access count while calling
+	// our Event function, which means DKernelEventHandler::Close will never get as far as our destructor
+	// while we are blocking on zombies.
+	SetZombieMode(EDisabled); // This frees up any outstanding zombies via CompleteZombies()
+
+	iHandleCodesegRemovedDfc.Cancel();
+
+	if (iCodeModifierInited)
+		{
+#ifdef __EPOC32__
+		DebugSupport::CloseCodeModifier();
+#endif
+		}
+
+	if (iBreakpointMutex)
+		{
+		iBreakpointMutex->Close(NULL);
+		}
+#ifdef FSHELL_ARM_MEM_MAPPED_DEBUG
+	if (iDebugRegistersChunk)
+		{
+		iDebugRegistersChunk->Close(NULL);
+		}
+#endif
+	iCreatorInfo.Close();
+	}
+
+HBuf* DDebuggerEventHandler::GetZombieThreadIds()
+	{
+	TInt count = iZombieCount;
+	TInt size = count*sizeof(RMemoryAccess::TZombieInfo);
+	HBuf* result = HBuf::New(size);
+	if (!result) return NULL;
+	result->SetLength(size);
+	RMemoryAccess::TZombieInfo* ptr = (RMemoryAccess::TZombieInfo*)result->Ptr();
+	Lock();
+	TInt i = 0;
+	for (SDblQueLink* link = iZombies.First(); link != NULL && link != &iZombies.iA && i < count; i++, link=link->iNext)
+		{
+		SZombie& zom = *_LOFF(link, SZombie, iLink);
+		ptr[i].iThreadId = zom.iThread->iId;
+		ptr[i].iFlags = 0;
+		if (zom.iBlocker == NULL) ptr[i].iFlags |= RMemoryAccess::TZombieInfo::ESuspended;
+		else if (zom.iBreakpointAddress != 0) ptr[i].iFlags |= RMemoryAccess::TZombieInfo::EBreakpoint;
+		}
+	Unlock();
+	return result;
+	}
+
+DDebuggerEventHandler::SZombie* DDebuggerEventHandler::FindZombie(DThread* aThread)
+	{
+	// Enter and leave locked
+	ASSERT_LOCKED();
+	for (SDblQueLink* link = iZombies.First(); link != NULL && link != &iZombies.iA; link=link->iNext)
+		{
+		SZombie* zom = _LOFF(link, SZombie, iLink);
+		if (zom->iThread == aThread)
+			{
+			return zom;
+			}
+		}
+	return NULL;
+	}
+
+TInt DDebuggerEventHandler::ReleaseZombie(DThread* aThread)
+	{
+	ASSERT_UNLOCKED();
+	Lock();
+	SZombie* found = FindZombie(aThread);
+	if (found)
+		{
+		if (found->iBreakpointAddress)
+			{
+			// It's actually paused on a breakpoint, so we need to do a continue instead
+			Unlock();
+			return ContinueFromBreakpoint(aThread, 0);
+			}
+		else
+			{
+			ReleaseZombieAndUnlock(found);
+			return KErrNone;
+			}
+		}
+	else
+		{
+		Unlock();
+		return KErrNotFound;
+		}
+	}
+
+void DDebuggerEventHandler::ReleaseZombieAndUnlock(SZombie* aZombie)
+	{
+	ASSERT_LOCKED();
+	ReleaseZombie(aZombie);
+	Unlock();
+	}
+
+void DDebuggerEventHandler::ReleaseZombie(SZombie* aZombie)
+	{
+	ASSERT_LOCKED();
+	aZombie->iLink.Deque();
+	iZombieCount--;
+	if (aZombie->iBlocker)
+		{
+		Kern::SemaphoreSignal(*aZombie->iBlocker);
+		}
+	else
+		{
+		UnsuspendThread(aZombie);
+		}
+	}
+
+TInt DDebuggerEventHandler::RegisterForBreakpointNotification(MDebuggerEventClient* aClient)
+	{
+	Lock();
+	TInt err = KErrAlreadyExists;
+	if (iBreakpointNotifyClient == NULL || iBreakpointNotifyClient == aClient)
+		{
+		err = KErrNone;
+		iBreakpointNotifyClient = aClient;
+		}
+	Unlock();
+	return err;
+	}
+
+void DDebuggerEventHandler::UnregisterForBreakpointNotification(MDebuggerEventClient* aClient)
+	{
+	Lock();
+	if (aClient == iBreakpointNotifyClient)
+		{
+		iBreakpointNotifyClient = NULL;
+		}
+	Unlock();
+	}
+
+TInt DDebuggerEventHandler::SetBreakpoint(DThread* aThread, TLinAddr aAddress, const RMemoryAccess::TPredicate& aCondition)
+	{
+	TInt codemodifierErr = KErrNone;
+	if (!iCodeModifierInited)
+		{
+#ifdef __EPOC32__
+		TUint caps;
+		const TInt KMaxBreakpoints = 32;
+		codemodifierErr = DebugSupport::InitialiseCodeModifier(caps, KMaxBreakpoints);
+#else
+		codemodifierErr = KErrNotSupported;
+#endif
+		if (!codemodifierErr) iCodeModifierInited = ETrue;
+		// It's not necessarily fatal that we can't init the code modifier - we may still be able to set a H/W breakpoint
+		}
+
+	SBreakpoint* b = new SBreakpoint(aThread, iNextBreakpointId, aAddress, aCondition); // iNextBreakpointId gets incremented later
+	if (!b) return KErrNoMemory;
+
+	// Get the codeseg for this address
+	Kern::AccessCode();
+	b->iCodeSeg = Kern::CodeSegFromAddress(b->iAddress, b->iThread->iOwningProcess);
+	Kern::EndAccessCode();
+
+	BreakpointLock();
+	
+	// Check if there's already a HW breakpoint for this thread and address - we don't allow duplicates, just for sanity's sake
+	SBreakpoint* existingHwBreakpoint = FindHardwareBreakpoint(b->iThread, b->iAddress);
+	if (existingHwBreakpoint)
+		{
+		BreakpointUnlock();
+		delete b;
+		return KErrAlreadyExists;
+		}
+
+	TBreakpointPolicy policy = EWhatever;
+	// Check if we already have a breakpoint for this address. Because all software breakpoints are global, if we add repeated breakpoints on the same address (but on threads in different processes) DebugSupport will happily allow it and create nested nastyness
+	SBreakpoint* existingBreakpoint = FindBreakpointByAddress(b->iAddress);
+	if (existingBreakpoint)	policy = EHardwareOnly; // To prevent another SW breakpoint at this location. Multiple HW breakpoints are fine because they're per-thread
+	if (codemodifierErr != KErrNone) policy = EHardwareOnly; // If we failed to init code modifier, can only do h/w
+
+	iBreakpoints.Add(&b->iLink);
+	TInt err = ApplyBreakpoint(b, policy);
+	if (err && existingBreakpoint)
+		{
+		// If we couldn't set a HW breakpoint, no worries, fall back to relying on the existing SW breakpoint
+		b->iRealBreakpoint = existingBreakpoint;
+		err = KErrNone;
+		}
+
+	if (err < 0)
+		{
+		b->iLink.Deque();
+		delete b;
+		}
+	else
+		{
+		iNextBreakpointId++; // Now we know we're actually using it
+		}
+
+	BreakpointUnlock();
+	if (err)
+		{
+		return err;
+		}
+	else
+		{
+		TInt result = b->iBreakpointId;
+		if (b->IsHardware()) result |= RMemoryAccess::TBreakpointInfo::EHardware;
+		return result;
+		}
+	}
+
+TInt DDebuggerEventHandler::SetSymbolicBreakpoint(DThread* aThread, HBuf* aCodesegName, TUint32 aOffset, const RMemoryAccess::TPredicate& aCondition)
+	{
+	// See if the codeseg is currently loaded
+	Kern::AccessCode();
+	SDblQue* list = Kern::CodeSegList();
+	for (SDblQueLink* link = list->First(); link != &list->iA; link = link->iNext)
+		{
+		DCodeSeg* codeSeg = _LOFF(link, DCodeSeg, iLink);
+		if (codeSeg->iRootName == *aCodesegName)
+			{
+			TUint addr = codeSeg->iRunAddress + aOffset;
+			Kern::EndAccessCode();
+			TInt res = SetBreakpoint(aThread, addr, aCondition);
+			if (res >= KErrNone) delete aCodesegName;
+			return res;
+			}
+		}
+	Kern::EndAccessCode();
+	// If we get here, codeseg isn't currently loaded so need to create it as a pending breakpoint
+
+	SBreakpoint* b = new SBreakpoint(aThread, iNextBreakpointId++, aOffset, aCondition);
+	if (!b) return KErrNoMemory;
+	b->iCodeSeg = aCodesegName;
+	b->iFlags |= SBreakpoint::EDisabledPendingCodesegLoad;
+	BreakpointLock();
+	iBreakpoints.Add(&b->iLink);
+	BreakpointUnlock();
+	return KErrNone;
+	}
+
+TInt DDebuggerEventHandler::ApplyBreakpoint(SBreakpoint* aBreakpoint, TBreakpointPolicy aPolicy)
+	{
+	ASSERT_BREAKPOINT_LOCKED();
+	// These magic constants don't appear to be defined anywhere, they're just undefined instructions that will cause an exception that we can then handle
+	const TUint32 KArmBreakPoint = 0xE7F123F4;
+	const TUint16 KThumbBreakPoint = 0xDE56;
+	TUint32 inst = KArmBreakPoint;
+	TInt instSize = 4;
+	if (aBreakpoint->iFlags & SBreakpoint::EThumb)
+		{
+		inst = KThumbBreakPoint;
+		instSize = 2;
+		}
+
+#ifdef __EPOC32__
+	// Before modifying stuff, save the original instruction (needed for ReadInstructions())
+	TInt err = Kern::ThreadRawRead(aBreakpoint->iThread, (TAny*)aBreakpoint->iAddress, (TAny*)aBreakpoint->iOrigInstruction.Ptr(), instSize);
+	if (!err)
+		{
+		aBreakpoint->iOrigInstruction.SetLength(instSize);
+		if (aPolicy != ESoftwareOnly)
+			{
+			err = ApplyHardwareBreakpoint(aBreakpoint);
+			// If we manage to set a hardware breakpoint, we don't need to call ModifyCode
+			if (err == KErrNone)
+				{
+				LOG("HW breakpoint set ok");
+				aBreakpoint->iFlags |= SBreakpoint::EHardware;
+				}
+			else
+				{
+				Kern::Printf("Failed to set hardware breakpoint - %d", err);
+				}
+			}
+
+		if (aPolicy != EHardwareOnly && !aBreakpoint->IsHardware())
+			{
+			// Last check that we don't conflict with another breakpoint
+			err = (FindBreakpointByAddress(aBreakpoint->iAddress) == NULL ? KErrNone : KErrAlreadyExists);
+			if (!err) err = DebugSupport::ModifyCode(aBreakpoint->iThread, aBreakpoint->iAddress, instSize, inst, DebugSupport::EBreakpointGlobal);
+			if (err > 0) err = KErrNone; // Really don't care about what the breakpoint type is
+			}
+		}
+#else
+	TInt err = KErrNotSupported;
+	(void)aPolicy;
+#endif
+	return err;
+	}
+
+DDebuggerEventHandler::SBreakpoint* DDebuggerEventHandler::FindBreakpointByAddress(/*DThread* aThread,*/ TLinAddr aAddress)
+	{
+	// Enter and leave holding lock
+	// This only finds 'real' breakpoints, ie ones which have a ModifyCode outstanding, or are persistant. (NOT hardware breakpoints)
+	ASSERT_BREAKPOINT_LOCKED();
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA; link=link->iNext)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		if (/*b->iThread == aThread &&*/ b->iAddress == aAddress && (b->HasModifiedCode() || (b->iFlags & SBreakpoint::EPersistant)))
+			{
+			return b;
+			}
+		}
+	return NULL;
+	}
+
+DDebuggerEventHandler::SBreakpoint* DDebuggerEventHandler::FindHardwareBreakpoint(DThread* aThread, TLinAddr aAddress)
+	{
+	// Enter and leave holding lock
+	ASSERT_BREAKPOINT_LOCKED();
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA; link=link->iNext)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		if (b->iThread == aThread && b->iAddress == aAddress && b->IsHardware())
+			{
+			return b;
+			}
+		}
+	return NULL;
+	}
+
+DDebuggerEventHandler::SBreakpoint* DDebuggerEventHandler::FindBreakpointById(TInt aId)
+	{
+	// Enter and leave holding lock
+	ASSERT_BREAKPOINT_LOCKED();
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA; link=link->iNext)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		if (b->iBreakpointId == aId)
+			{
+			return b;
+			}
+		}
+	return NULL;
+	}
+
+DDebuggerEventHandler::SBreakpoint* DDebuggerEventHandler::FindBreakpointUsingHardwareContextRegister(TInt aRegister)
+	{
+	// Enter and leave holding lock
+	ASSERT_BREAKPOINT_LOCKED();
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA; link=link->iNext)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		if (b->IsHardware() && b->iHardwareBreakpointContextReg == aRegister)
+			{
+			return b;
+			}
+		}
+	return NULL;
+	}
+
+TInt DDebuggerEventHandler::SetBreakpointEnabled(TInt aBreakpointId, TBool aFlag)
+	{
+	BreakpointLock();
+	SBreakpoint* b = FindBreakpointById(aBreakpointId);
+	if (!b)
+		{
+		BreakpointUnlock();
+		return KErrNotFound;
+		}
+
+	TInt err = KErrNone;
+	if (aFlag)
+		{
+		if (b->iFlags & SBreakpoint::EDisabled == SBreakpoint::EDisabledByUser)
+			{
+			// Provided it's not disabled for any reason other than the user asked for it, re-enable it
+			err = ApplyBreakpoint(b);
+			if (err == KErrNone) b->iFlags |= ~SBreakpoint::EDisabledByUser;
+			}
+		else
+			{
+			err = KErrNotReady;
+			}
+		}
+	else
+		{
+		if (!(b->iFlags & SBreakpoint::EDisabled))
+			{
+			// If it's not already disabled for any reason, disable it
+			UnapplyBreakpoint(b);
+			}
+		b->iFlags |= SBreakpoint::EDisabledByUser;
+		}
+	BreakpointUnlock();
+	return KErrNone;
+	}
+
+TInt DDebuggerEventHandler::ClearBreakpoint(TInt aBreakpointId)
+	{
+	BreakpointLock();
+	SBreakpoint* b = FindBreakpointById(aBreakpointId);
+	if (!b)
+		{
+		BreakpointUnlock();
+		return KErrNotFound;
+		}
+
+	ClearBreakpoint(b);
+	BreakpointUnlock();
+	return KErrNone;
+	}
+
+void DDebuggerEventHandler::ClearBreakpoint(SBreakpoint* aBreakpoint, TBool aResumeAllBlocked /*=EFalse*/)
+	{
+	// enter and leave locked
+	ASSERT_BREAKPOINT_LOCKED();
+	TLinAddr addr = aBreakpoint->iAddress;
+	aBreakpoint->iLink.Deque();
+	UnapplyBreakpoint(aBreakpoint);
+	delete aBreakpoint;
+
+	if (aResumeAllBlocked)
+		{
+		Lock();
+		for (SDblQueLink* link = iZombies.First(); link != NULL && link != &iZombies.iA; link=link->iNext)
+			{
+			SZombie* zom = _LOFF(link, SZombie, iLink);
+			if (zom->iBreakpointAddress == addr)
+				{
+				ReleaseZombie(zom);
+				}
+			}
+		Unlock();
+		}
+	}
+
+void DDebuggerEventHandler::UnapplyBreakpoint(SBreakpoint* aBreakpoint)
+	{
+#ifdef __EABI__
+	if (aBreakpoint->HasModifiedCode())
+		{
+		DebugSupport::RestoreCode(aBreakpoint->iThread, aBreakpoint->iAddress);
+		HandleRestoreCode(aBreakpoint->iAddress);
+		}
+	if (aBreakpoint->IsHardware())
+		{
+#ifdef __SMP__
+		TInt num = NKern::NumberOfCpus();
+		TUint32 origAffinity = 0;
+		for (TInt i = 0; i < num; i++)
+			{
+			TUint32 affinity = NKern::ThreadSetCpuAffinity(&Kern::CurrentThread().iNThread, i);
+			if (i == 0) origAffinity = affinity;
+			DoClearHardwareBreakpoint(aBreakpoint);
+			}
+		NKern::ThreadSetCpuAffinity(&Kern::CurrentThread().iNThread, origAffinity);
+#else
+		DoClearHardwareBreakpoint(aBreakpoint);
+#endif // __SMP__
+		iFreeHwBreakpoints |= (1 << aBreakpoint->iHardwareBreakpointId);
+		}
+#else
+	(void)aBreakpoint;
+#endif // __EABI__
+	}
+
+#ifdef __EABI__
+void DDebuggerEventHandler::DoClearHardwareBreakpoint(SBreakpoint* aBreakpoint)
+	{
+	TUint32 bcr = ReadBcr(aBreakpoint->iHardwareBreakpointId);
+	bcr = bcr & ~1; // Clear the enabled bit
+	SetBreakpointPair(aBreakpoint->iHardwareBreakpointId, 0, bcr);
+	}
+#endif
+
+void DDebuggerEventHandler::ClearAllBreakpoints()
+	{
+	ASSERT_UNLOCKED();
+	ASSERT_BREAKPOINT_UNLOCKED();
+	// enter and exit with lock not held
+	BreakpointLock();
+	for (;;)
+		{
+		SDblQueLink* link = iBreakpoints.IsEmpty() ? NULL : iBreakpoints.First();
+		if (!link)
+			{
+			break;
+			}
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		ClearBreakpoint(b);
+		}
+	BreakpointUnlock();
+	}
+
+TInt DDebuggerEventHandler::ContinueFromBreakpoint(DThread* aThread, TLinAddr aExceptionAddress)
+	{
+	// First find the SZombie
+	SZombie* zombie = NULL;
+	TLinAddr breakpointAddr = 0;
+	// If aExceptionAddress is non-zero, it means we're being called from inside the exception handler and we haven't actually created a zombie
+	if (aExceptionAddress)
+		{
+		breakpointAddr = aExceptionAddress;
+		}
+	else
+		{
+		Lock();
+		zombie = FindZombie(aThread);
+		if (!zombie)
+			{
+			Unlock();
+			return KErrNotFound;
+			}
+		else if (zombie->iBreakpointAddress == 0)
+			{
+			// It's a zombie but not one on a breakpoint
+			Unlock();
+			return KErrNotReady;
+			}
+		// Deque early while we still hold lock, twiddle the pointers so the deque in ReleaseZombieAndUnlock won't break
+		zombie->iLink.Deque();
+		zombie->iLink.iPrev = &zombie->iLink;
+		zombie->iLink.iNext = &zombie->iLink;
+		breakpointAddr = zombie->iBreakpointAddress;
+		Unlock();
+		}
+
+	BreakpointLock();
+	SBreakpoint* breakpoint = FindHardwareBreakpoint(aThread, breakpointAddr);
+	if (breakpoint == NULL) breakpoint = FindBreakpointByAddress(breakpointAddr);
+	// This could be null if someone has already cleared the breakpoint
+	if (!breakpoint)
+		{
+		BreakpointUnlock();
+		if (zombie)
+			{
+			Lock();
+			ReleaseZombieAndUnlock(zombie);
+			}
+		return KErrNone;
+		}
+	// the above logic doesn't handle if someone has cleared a persistant breakpoint that aThread is on - but if
+	// the user has done that then they're on their own.
+	// (Mitigated by us not listing persistant breakpoints in the GetBreakpoints fn)
+	if (breakpoint->iFlags & SBreakpoint::EPersistant)
+		{
+		// It's a persistant breakpoint, so we don't actually want to clear the breakpoint we just need to modify the PC to step over the break instruction
+		TLinAddr breakAddress = breakpoint->iAddress;
+		TInt err = SetProgramCounter(aThread, breakAddress + 4);
+		BreakpointUnlock();
+		if (!err && zombie)
+			{
+			Lock();
+			ReleaseZombieAndUnlock(zombie);
+			}
+		return err;
+		}
+
+	TInt err = MoveBreakpointToNextInstructionForThread(aThread, breakpoint); // When this gets hit it will take care of restoring the breakpoint back to what it should be
+	if (err)
+		{
+		Kern::Printf("fdbk: Error returned from MoveBreakpointToNextInstructionForThread %d", err);
+		}
+
+	BreakpointUnlock();
+	if (!err && zombie)
+		{
+		Lock();
+		ReleaseZombieAndUnlock(zombie);
+		}
+	return err;
+	}
+
+HBuf* DDebuggerEventHandler::GetBreakpoints()
+	{
+	TInt count = 0;
+	BreakpointLock();
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA; link=link->iNext)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		if (b->iFlags & SBreakpoint::EPersistant) continue;
+		count++;
+		}
+	TInt size = count*sizeof(RMemoryAccess::TBreakpointInfo);
+	HBuf* result = HBuf::New(size);
+	if (!result)
+		{
+		BreakpointUnlock();
+		return NULL;
+		}
+	result->SetLength(size);
+	RMemoryAccess::TBreakpointInfo* ptr = (RMemoryAccess::TBreakpointInfo*)result->Ptr();
+	RMemoryAccess::TBreakpointInfo* end = ptr + count;
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA && ptr < end; link=link->iNext)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		if (b->iFlags & SBreakpoint::EPersistant) continue; // We don't talk about persistant breakpoints, since they're an implementation detail of LtkUtils::Breakpoint() really
+		ptr->iThreadId = b->iThread->iId;
+		ptr->iBreakpointId = b->iBreakpointId;
+		ptr->iAddress = b->iAddress;
+		ptr->iFlags = 0;
+		if (b->iFlags & SBreakpoint::EDisabledPendingCodesegLoad) ptr->iFlags |= RMemoryAccess::TBreakpointInfo::EPending;
+		if (!(b->iFlags & SBreakpoint::EDisabledByUser)) ptr->iFlags |= RMemoryAccess::TBreakpointInfo::EEnabled;
+		if (b->IsHardware()) ptr->iFlags |= RMemoryAccess::TBreakpointInfo::EHardware;
+		ptr->iCondition = b->iCondition;
+		ptr++;
+		}
+	BreakpointUnlock();
+	return result;
+	}
+
+TInt DDebuggerEventHandler::RegisterPersistantBreakpoint(DThread* /*aThread*/, TLinAddr aAddress)
+	{
+	RMemoryAccess::TPredicate condition; // Default args means 'always pass'
+	SBreakpoint* b = new SBreakpoint(NULL, iNextBreakpointId, aAddress, condition); //  The thread is null to say any thread should trigger the breakpoint (ie truly global)
+	if (!b) return KErrNoMemory;
+	b->iFlags |= SBreakpoint::EPersistant;
+
+	BreakpointLock();
+	SBreakpoint* existingBreakpoint = FindBreakpointByAddress(b->iAddress);
+	if (existingBreakpoint)
+		{
+		BreakpointUnlock();
+		delete b;
+		return KErrAlreadyExists;
+		}
+
+	// No need to call ModifyCode because persistant breakpoints are ones that hard-code the invalid instruction
+	iBreakpoints.Add(&b->iLink);
+	BreakpointUnlock();
+	iNextBreakpointId++;
+	return KErrNone;
+	}
+
+TInt DDebuggerEventHandler::SetProgramCounter(DThread* aThread, TLinAddr aAddress)
+	{
+	// This can hold the breakpoint lock or not, doesn't care
+
+#if !defined(__WINS__) && !defined(FSHELL_9_1_SUPPORT) // win32 ekern doesn't even export this API let alone implement it
+	TUint32 regs[32];
+	TUint32 valid = 0;
+	NKern::ThreadGetUserContext(&aThread->iNThread, &regs[0], valid);
+	if (!(valid & (1<<15))) return KErrNotSupported; // If we can't read it, we can't set it
+	regs[15] = aAddress;
+	NKern::ThreadSetUserContext(&aThread->iNThread, &regs[0]);
+	return KErrNone;
+#else
+	(void)aThread;
+	(void)aAddress;
+	return KErrNotSupported;
+#endif
+	}
+
+void DDebuggerEventHandler::HandleRestoreCode(TLinAddr aAddress)
+	{
+	ASSERT_BREAKPOINT_LOCKED();
+	// This function is to update any shadow breakpoints that were relying on this address having been modified
+	// We can't promote any breakpoint that's marked as pending, we need to start tracking the breakpoint address
+	// as an offset to the codeseg run address before we can do that.
+	SBreakpoint* newRealBreakpoint = NULL;
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA; link=link->iNext)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		if (b->iAddress == aAddress && !b->IsHardware() && !(b->iFlags & SBreakpoint::EDisabled) && (b->iRealBreakpoint))
+			{
+			if (newRealBreakpoint == NULL)
+				{
+				// b is the new real one
+				b->iRealBreakpoint = NULL;
+				TInt err = ApplyBreakpoint(b, ESoftwareOnly);
+				if (err)
+					{
+					// Oh dear...
+					b->iFlags |= SBreakpoint::EDisabledPendingCodesegLoad;
+					b->iCodeSeg = NULL; // This saves me having to think what state to put it in - NULL means the breakpoint is dead forever
+					}
+				else
+					{
+					newRealBreakpoint = b;
+					}
+				}
+			else
+				{
+				b->iRealBreakpoint = newRealBreakpoint;
+				}
+			}
+		}
+	}
+
+void DDebuggerEventHandler::BreakpointLock()
+	{
+	NKern::ThreadEnterCS();
+	Kern::MutexWait(*iBreakpointMutex);
+	}
+
+void DDebuggerEventHandler::BreakpointUnlock()
+	{
+	Kern::MutexSignal(*iBreakpointMutex);
+	NKern::ThreadLeaveCS();
+	}
+
+TBool DDebuggerEventHandler::SBreakpoint::HasModifiedCode() const
+	{
+	return !(iFlags & EDisabled)
+		&& !(iFlags & EPersistant)
+		&& !IsHardware()
+		&& iRealBreakpoint == NULL;
+	}
+
+TBool DDebuggerEventHandler::SBreakpoint::IsHardware() const
+	{
+	return (iFlags & EHardware);
+	}
+
+void DDebuggerEventHandler::HandleCodesegRemoved(TAny* aPtr)
+	{
+	static_cast<DDebuggerEventHandler*>(aPtr)->DoHandleCodesegRemoved();
+	}
+
+void DDebuggerEventHandler::DoHandleCodesegRemoved()
+	{
+	for (;;)
+		{
+		Lock();
+		SDblQueLink* link = iRemovedCodesegs.GetFirst();
+		Unlock();
+		if (!link) break;
+		SRemovedCodeseg* r = _LOFF(link, SRemovedCodeseg, iLink);
+
+		// Check for breakpoints that have been removed by the oh-so-helpful CodeModifier
+		BreakpointLock();
+		for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA; link=link->iNext)
+			{
+			SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+			if (b->iCodeSeg == r->iCodeseg && b->iThread->iOwningProcess == r->iProcess && b->HasModifiedCode())
+				{
+				DCodeSeg* codeSeg = static_cast<DCodeSeg*>(b->iCodeSeg);
+				TBool hadModifiedCode = b->HasModifiedCode();
+				b->iFlags |= SBreakpoint::EDisabledPendingCodesegLoad;
+				HBuf* codesegName = HBuf::New(codeSeg->iRootName.Length());
+				if (codesegName)
+					{
+					// If it's null, we'll just never be able to reenable the breakpoint
+					codesegName->Copy(codeSeg->iRootName);
+					}
+				TInt codesegOffset = b->iAddress - codeSeg->iRunAddress;
+				b->iCodeSeg = codesegName;
+				if (hadModifiedCode)
+					{
+					HandleRestoreCode(b->iAddress);
+					}
+				b->iAddress = codesegOffset; // Pending breakpoints use iAddress to store the codeseg offset
+				}
+			}
+		BreakpointUnlock();
+		delete r;
+		}
+	}
+
+DDebuggerEventHandler::SBreakpoint::SBreakpoint(DThread* aThread, TInt aBreakpointId, TLinAddr aAddress, const RMemoryAccess::TPredicate& aCondition)
+	: iThread(aThread), iBreakpointId(aBreakpointId), iAddress(aAddress&~1), iCodeSeg(NULL), iFlags(0), iRealBreakpoint(NULL), iHardwareBreakpointId(-1), iHardwareBreakpointContextReg(-1), iMatch(NULL), iCondition(aCondition)
+	{
+	if (aAddress & 1) iFlags |= EThumb;
+	if (iThread)
+		{
+		iThread->Open();
+		iFlags |= EThreadSpecific;
+		}
+	}
+
+DDebuggerEventHandler::SBreakpoint::~SBreakpoint()
+	{
+	if (iThread) iThread->Close(NULL);
+	delete iMatch;
+	if (iFlags & SBreakpoint::EDisabledPendingCodesegLoad) delete (HBuf*)iCodeSeg;
+	}
+
+TInt DDebuggerEventHandler::ReadInstructions(DThread* aThread, TLinAddr aAddress, TInt aLength, TDes8& aData)
+	{
+	if (aLength > aData.MaxSize()) return KErrArgument;
+	TInt err = Kern::ThreadRawRead(aThread, (TAny*)aAddress, (TAny*)aData.Ptr(), aLength);
+	if (err) return err;
+	aData.SetLength(aLength);
+
+	// Now check if any of that data had breakpoints in that mean we've not read the real instruction values
+	BreakpointLock();
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA; link=link->iNext)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		if (b->iAddress >= aAddress && b->iAddress < aAddress + aLength && b->iOrigInstruction.Length())
+			{
+			TInt size = b->iFlags & SBreakpoint::EThumb ? 2 : 4;
+			TPtr8 instrBuf((TUint8*)aData.Ptr() + (b->iAddress - aAddress), size, size);
+			instrBuf.Copy(b->iOrigInstruction);
+			}
+		}
+	BreakpointUnlock();
+	return KErrNone;
+	}
+
+TInt DDebuggerEventHandler::ApplyHardwareBreakpoint(SBreakpoint* aBreakpoint)
+	{
+	ASSERT_BREAKPOINT_LOCKED();
+
+	// First, check the context registers and see if we have one for this thread
+	TInt contextReg = 0;
+	SBreakpoint* breakUsingFour = FindBreakpointUsingHardwareContextRegister(4);
+	SBreakpoint* breakUsingFive = FindBreakpointUsingHardwareContextRegister(5);
+	if (breakUsingFour && aBreakpoint->iThread == breakUsingFour->iThread) contextReg = 4;
+	if (breakUsingFive && aBreakpoint->iThread == breakUsingFive->iThread) contextReg = 5;
+
+	if (contextReg == 0 && breakUsingFour == NULL)
+		{
+		// Noone is using 4
+		contextReg = 4;
+		}
+
+	if (contextReg == 0 && breakUsingFive == NULL)
+		{
+		contextReg = 5;
+		}
+
+	LOG("fdbk: Using context reg %d", contextReg);
+	if (contextReg == 0) return KErrOverflow; // No free context registers
+
+	// Now find a free breakpoint reg
+	TInt breakreg = -1;
+	if (iFreeHwBreakpoints & 8) breakreg = 3;
+	if (iFreeHwBreakpoints & 4) breakreg = 2;
+	if (iFreeHwBreakpoints & 2) breakreg = 1;
+	if (iFreeHwBreakpoints & 1) breakreg = 0;
+
+	if (breakreg == -1) return KErrOverflow;
+	aBreakpoint->iHardwareBreakpointId = breakreg;
+
+	TInt err = KErrNone;
+#ifdef __SMP__
+	// Have to apply to every CPU in turn
+	const TInt num = NKern::NumberOfCpus();
+	TUint32 origAffinity = 0;
+	LOG("Applying breakpoint to all %d CPUs...", num);
+	for (TInt i = 0; i < num; i++)
+		{
+		TUint32 affinity = NKern::ThreadSetCpuAffinity(&Kern::CurrentThread().iNThread, i);
+		if (i == 0) origAffinity = affinity;
+		err = DoApplyHardwareBreakpoint(aBreakpoint, contextReg);
+		if (err)
+			{
+			// Disable the breakpoint on any CPUs we successfully applied it on
+			for (TInt j = 0; j < i; j++)
+				{
+				NKern::ThreadSetCpuAffinity(&Kern::CurrentThread().iNThread, j);
+				DoClearHardwareBreakpoint(aBreakpoint);
+				}
+			break;
+			}
+		}
+	// Restore original affinity
+	NKern::ThreadSetCpuAffinity(&Kern::CurrentThread().iNThread, origAffinity);
+#else
+	err = DoApplyHardwareBreakpoint(aBreakpoint, contextReg);
+#endif
+	if (err == KErrNone)
+		{
+		iFreeHwBreakpoints &= ~(1<<breakreg);
+		}
+	return err;
+	}
+
+TInt DDebuggerEventHandler::DoApplyHardwareBreakpoint(SBreakpoint* aBreakpoint, TInt aContextReg)
+	{
+#if defined(__EABI__)
+
+#if defined(FSHELL_ARM_MEM_MAPPED_DEBUG)
+	if (iDebugRegistersChunk == NULL)
+		{
+		// Need to setup mapping for debug registers
+		TUint drar = GetDrar();
+		TUint dsar = GetDsar();
+		//Kern::Printf("drar=0x%08x dsar=0x%08x", drar, dsar);
+		if ((dsar & 3) != 3)
+			{
+			Kern::Printf("fdbk: DSAR enabled bits are not set - aborting");
+			return KErrNotSupported;
+			}
+		TPhysAddr physAddr = (drar & ~3) + (dsar & ~3); // We don't check validity of DRAR, TI set it incorrectly to 0x0 (invalid) on 3530
+		if (physAddr == 0x52011000) physAddr = 0x54011000; // TI got this wrong too...
+		const TInt KDebugRegSize = 0x10000; // 64K so we can reach DBGEN on 3530
+		TUint attrib;
+		new(&attrib) TMappingAttributes2(/*EMemAttNormalUncached*/ EMemAttStronglyOrdered, EFalse, ETrue);
+		TInt err = DPlatChunkHw::New(iDebugRegistersChunk, physAddr, KDebugRegSize, attrib);
+		if (err < 0)
+			{
+			Kern::Printf("fdbk: Error mapping debug registers - %d", err);
+			return err;
+			}
+		LOG("debug registers from 0x%08x mapped at 0x%08x", physAddr, iDebugRegistersChunk->LinearAddress());
+		}
+#endif
+
+#if defined(FSHELL_ARM11XX_SUPPORT) || defined(FSHELL_ARM_MEM_MAPPED_DEBUG)
+	// First. check debug status register (DSCR) to check that monitor mode is enabled (and thus that the BCRs are writeable)
+	TUint dscr = GetDscr();
+	//Kern::Printf("dscr=0x%08x", dscr);
+#ifdef FSHELL_ARM_MEM_MAPPED_DEBUG
+	// Check for DBGEN (via authstatus register) too, we need it
+	TUint authStatus = *(TUint32*)(iDebugRegistersChunk->LinearAddress() + 0xFB8);
+	LOG("authStatus = 0x%08x", authStatus);
+	if ((authStatus & 1) == 0)
+		{
+		// DBGEN not enabled - try the magic barely documented 3530 way of setting it
+		LOG("Setting Lock Access Register");
+		WriteRegister(ELockAccessOffset, 0xC5ACCE55);
+
+		Kern::Printf("Reading CONTROL_SEC_EMU from 0x48002A64...");
+		TUint attrib;
+		new(&attrib) TMappingAttributes2(/*EMemAttNormalUncached*/ EMemAttStronglyOrdered, EFalse, ETrue);
+		DPlatChunkHw* crazyOmapRegs = NULL;
+		DPlatChunkHw::New(crazyOmapRegs, 0x48002000, 0x1000, attrib);
+		TUint32 controlsecemu = *(TUint32*)(crazyOmapRegs->LinearAddress() + 0xa64);
+		Kern::Printf("CONTROL_SEC_EMU = 0x%08x", controlsecemu);
+
+		Kern::Printf("Trying 3530 approach to enabling DBGEN...");
+		TUint32 volatile * dbgenWord = (TUint32*)(iDebugRegistersChunk->LinearAddress() + 0xc030);
+		Kern::Printf("DBGEN word = 0x%08x", *dbgenWord);
+		*dbgenWord |= (1 << 13); // Set bit 13 of 0x5401d030 is how you do it, apparently
+		//*dbgenWord = 0xFFFFFFFF;
+		// Now do as ASM says and DSB, poll for DSCR (or just wait a bit) then ISB
+		Dsb();
+		Kern::Printf("Wasting time waiting for dbgen....");
+		Isb();
+		Kern::Printf("DBGEN word is now 0x%08x", *dbgenWord);
+		authStatus = *(TUint32*)(iDebugRegistersChunk->LinearAddress() + 0xFB8);
+		Kern::Printf("authStatus is now 0x%08x", authStatus);
+		}
+#endif
+	if ((dscr & 0xC000) != 0x8000)
+		{
+		// Set bits [15:14] to b10
+		dscr = (dscr & ~0xC000) | 0x8000;
+		//Kern::Printf("Setting monitor mode in DSCR...");
+		SetDscr(dscr); // If there's a JTAG doing halt-mode debugging this is gonna crash. Oh well.
+		}
+	dscr = GetDscr();
+	//Kern::Printf("dscr from MCR=0x%08x", dscr);		
+
+#else
+	// Is ARM, but not ARM11 or A8
+	(void)aBreakpoint;
+	(void)aContextReg;
+	return KErrNotSupported;
+#endif
+	
+	TUint32 contextId = GetArmContextIdForThread(aBreakpoint->iThread);
+	
+	//Kern::Printf("fdbk: fdb thinks contextId is 0x%08x", contextId);
+	//return KErrNotSupported; //DEBUG
+
+	SetContextIdBrp(aContextReg, contextId);
+
+	// Now need to construct the BCR register value
+	const TUint32 KArmBcr = 0x001001E5;
+	//const TUint32 KArmBcr = 0x000001E5; // DEBUG disable context match
+	//TUint32 bcr = ReadBcr(aBreakReg);
+	TUint32 bcr = KArmBcr;
+	bcr |= aContextReg << 16;
+	if (aBreakpoint->iFlags & SBreakpoint::EThumb)
+		{
+		const TUint32 KByteSelectMask = 0x1E0;
+		// These assume a little-endian world
+		const TUint32 KMiddleOfWordThumbByteSelect = 0x180; // [8:5] = b1100
+		const TUint32 KWordAlignedThumbByteSelect = 0x060; // [8:5] = b0011
+		bcr = bcr & ~KByteSelectMask;
+		if (aBreakpoint->iAddress & 2)
+			{
+			bcr |= KMiddleOfWordThumbByteSelect;
+			}
+		else
+			{
+			bcr |= KWordAlignedThumbByteSelect;
+			}
+		}
+
+	SetBreakpointPair(aBreakpoint->iHardwareBreakpointId, aBreakpoint->iAddress & ~3, bcr);
+	return KErrNone;
+	
+#else
+	(void)aBreakpoint;
+	(void)aContextReg;
+	return KErrNotSupported;
+#endif
+	}
+
+TUint32 DDebuggerEventHandler::GetArmContextIdForThread(DThread* aThread)
+	{
+#if (defined(FSHELL_ARM11XX_SUPPORT) || defined(FSHELL_ARM_MEM_MAPPED_DEBUG)) && defined(__MARM__)
+	// This is according to TScheduler::Reschedule (gulp)
+	TUint asid = static_cast<DMemModelProcess*>(aThread->iOwningProcess)->iOsAsid;
+	//TUint32 result = (((TUint32)&aThread->iNThread >> 6) << 8) | asid;
+	TUint32 result = (TUint32)&aThread->iNThread;
+	result = (result << 2) & ~0xFF;
+	result |= (asid & 0xFF);
+	return result;
+#else
+	(void)aThread;
+	return 0;
+#endif
+	}
+
+#ifdef FSHELL_ARM_MEM_MAPPED_DEBUG
+
+TUint32 DDebuggerEventHandler::ReadRegister(TInt aRegisterOffset)
+	{
+	return *(TUint32*)(iDebugRegistersChunk->LinearAddress() + aRegisterOffset);
+	}
+
+void DDebuggerEventHandler::WriteRegister(TInt aRegisterOffset, TUint32 aValue)
+	{
+	TUint32* reg = (TUint32*)(iDebugRegistersChunk->LinearAddress() + aRegisterOffset);
+	*reg = aValue;
+	}
+
+#endif // FSHELL_ARM_MEM_MAPPED_DEBUG
+
+#ifdef __EABI__
+
+void DDebuggerEventHandler::SetDscr(TUint32 aVal)
+	{
+#ifdef FSHELL_ARM_MEM_MAPPED_DEBUG
+	TUint32* dscrAddr = (TUint32*)(iDebugRegistersChunk->LinearAddress() + EDscrOffset);
+	*dscrAddr = aVal;
+#else
+	MCR_SetDscr(aVal);
+#endif
+	}
+
+void DDebuggerEventHandler::SetBreakpointPair(TInt aRegister, TUint aBvrValue, TUint aBcrValue)
+	{
+	LOG("fdbk: SetBreakpointPair(reg=%d, bvr=0x%08x, bcr=0x%08x)", aRegister, aBvrValue, aBcrValue);
+#ifdef FSHELL_ARM_MEM_MAPPED_DEBUG
+	// This is the sequence the ARM ARM recommends
+	TUint32* bcrAddr = (TUint32*)(iDebugRegistersChunk->LinearAddress() + EBcrOffset + aRegister*4);
+	TUint32* bvrAddr = (TUint32*)(iDebugRegistersChunk->LinearAddress() + EBvrOffset + aRegister*4);
+
+	// Disable the breakpoint
+	//*bcrAddr = 0;
+	//Imb();
+	*bvrAddr = aBvrValue;
+	*bcrAddr = aBcrValue;
+#else
+	MCR_SetBreakpointPair(aRegister, aBvrValue, aBcrValue);
+#endif
+	Imb();
+	}
+
+TUint DDebuggerEventHandler::ReadBcr(TInt aRegister)
+	{
+//#ifdef FSHELL_ARM_MEM_MAPPED_DEBUG
+//	TUint32* bcrAddr = (TUint32*)(iDebugRegistersChunk->LinearAddress() + EBcrOffset + aRegister*4);
+//	return *bcrAddr;
+//#else
+	return MRC_ReadBcr(aRegister);
+//#endif
+	}
+
+void DDebuggerEventHandler::SetContextIdBrp(TInt aRegister, TUint aContextId)
+	{
+#ifdef FSHELL_ARM_MEM_MAPPED_DEBUG
+	// This is according to "ARM 13.3.9. CP14 c80-c85, Breakpoint Control Registers (BCR)"
+	const TUint KContextIdBCR = 0x003001E7;
+	SetBreakpointPair(aRegister, aContextId, KContextIdBCR);
+#else
+	LOG("SetContextIdBrp %d 0x%08x", aRegister, aContextId);
+	MCR_SetContextIdBrp(aRegister, aContextId);
+	Imb();
+#endif
+	}
+
+#endif
+
+void DDebuggerEventHandler::RemoveAllHardwareBreakpointsForThread(DThread* aThread)
+	{
+	BreakpointLock();
+	for (SDblQueLink* link = iBreakpoints.First(); link != NULL && link != &iBreakpoints.iA;)
+		{
+		SBreakpoint* b = _LOFF(link, SBreakpoint, iLink);
+		link=link->iNext; // Do this before potentially calling ClearBreakpoint, because that will delete the breakpoint, invalidating link
+		if (b->IsHardware() && b->MatchesThread(aThread))
+			{
+			ClearBreakpoint(b);
+			}
+		}
+	BreakpointUnlock();
+	}
+
+TInt DDebuggerEventHandler::MoveBreakpointToNextInstructionForThread(DThread* aThread, SBreakpoint* aBreakpoint)
+	{
+#ifdef __EABI__
+	ASSERT_BREAKPOINT_LOCKED();
+	TUint32 notUsed = 0;
+	TBool aModeChange = EFalse;
+	TLinAddr nextAddr = PCAfterInstructionExecutes(aThread, aBreakpoint->iAddress, notUsed, aBreakpoint->iFlags & SBreakpoint::EThumb ? 2 : 4, notUsed, aModeChange);
+	LOG("fdbk: Next instruction after %x is %x", aBreakpoint->iAddress, nextAddr);
+
+	RMemoryAccess::TPredicate alwaysPass;
+	SBreakpoint* temp = new SBreakpoint(aThread, iNextBreakpointId, nextAddr, alwaysPass);
+	if (!temp) return KErrNoMemory;
+	iBreakpoints.Add(&temp->iLink);
+
+	const TBool hw = aBreakpoint->IsHardware();
+	if (hw) UnapplyBreakpoint(aBreakpoint); // If it's hardware, it's ok to unapply it before adding the temp one because hw breakpoints are thread-specific. For software, we want the new one in place before we remove this one to make sure we don't miss stuff
+
+	TInt err = ApplyBreakpoint(temp, hw ? EHardwareOnly : ESoftwareOnly);
+	if (err)
+		{
+		// This really shouldn't fail if hw - we still have the lock and we know there's a free BRP cos we just unapplied aBreakpoint
+		temp->iLink.Deque();
+		delete temp;
+		return err;
+		}
+
+	if (!hw) UnapplyBreakpoint(aBreakpoint);
+
+	aBreakpoint->iFlags |= SBreakpoint::EDisabledDuringContinue;
+	temp->iFlags |= SBreakpoint::ETempContinue;
+	temp->iRealBreakpoint = aBreakpoint;
+	iNextBreakpointId++;
+
+	return KErrNone;
+#else
+	(void)aThread;
+	(void)aBreakpoint;
+	return KErrNotSupported;
+#endif
+	}
+
+
+void DDebuggerEventHandler::SBreakpoint::SetThreadMatchPattern(HBuf* aMatch)
+	{
+	ASSERT(iMatch == NULL);
+	ASSERT(iThread == NULL);
+	ASSERT((iFlags & EThreadSpecific) == 0);
+	iMatch = aMatch;
+	}
+
+TBool DDebuggerEventHandler::SBreakpoint::MatchesThread(DThread* aThread) const
+	{
+	TBool match = EFalse;
+
+	if (iFlags & EThreadSpecific)
+		{
+		match = (aThread == iThread);
+		}
+	else if (iMatch == NULL)
+		{
+		match = ETrue;
+		}
+	else
+		{
+		TFullName threadName;
+		aThread->FullName(threadName);
+		match = threadName.MatchF(*iMatch);
+		}
+
+	if (match && iCondition.HasConditions())
+		{
+#ifdef __MARM__
+		TUint32 regs[32];
+		TUint32 valid = 0;
+		NKern::ThreadGetUserContext(&aThread->iNThread, &regs[0], valid);
+		match = iCondition.SatisfiesConditions(regs);
+#endif
+		}
+	return match;
+	}
+
+//
+
+const TUint32 KOpMask = 0xF;
+
+TBool RMemoryAccess::TPredicate::SatisfiesConditions(TUint32* aRegisterSet) const
+	{
+	for (TInt slot = 0; slot < KNumSlots; slot++)
+		{
+		TInt slotShift = slot * 8;
+		TUint32 opAndReg = (iOp >> slotShift) & 0xFF;
+		TOp op = (TOp)(opAndReg & KOpMask);
+		TInt reg = opAndReg >> 4;
+		TBool match = Test(op, aRegisterSet[reg], iVals[slot]);
+		if (!match) return EFalse;
+		}
+	return ETrue;
+	}
+
+TBool RMemoryAccess::TPredicate::Test(TOp aOperation, TUint32 aCurrentValue, TUint32 aStoredValue)
+	{
+	LOG("Testing op %d %u against %u", aOperation, aCurrentValue, aStoredValue);
+
+	switch (aOperation)
+		{
+		case ENothing:
+			return ETrue;
+		case EEq:
+		case ESignedEq:
+			return (aCurrentValue == aStoredValue);
+		case ENe:
+		case ESignedNe:
+			return (aCurrentValue != aStoredValue);
+		case ELt:
+			return (aCurrentValue < aStoredValue);
+		case ELe:
+			return (aCurrentValue <= aStoredValue);
+		case EGt:
+			return (aCurrentValue > aStoredValue);
+		case EGe:
+			return (aCurrentValue >= aStoredValue);
+		case ESignedLt:
+			return ((TInt32)aCurrentValue < (TInt32)aStoredValue);
+		case ESignedLe:
+			return ((TInt32)aCurrentValue <= (TInt32)aStoredValue);
+		case ESignedGt:
+			return ((TInt32)aCurrentValue > (TInt32)aStoredValue);
+		case ESignedGe:
+			return ((TInt32)aCurrentValue >= (TInt32)aStoredValue);
+		}
+	return EFalse; // Compiler shutter-upper
+	}
+
+TUint DDebuggerEventHandler::GetCreatorThread(TUint aThreadId)
+	{
+	TCreatorInfo dummy(aThreadId, 0);
+	TUint result = 0;
+	BreakpointLock();
+	TInt found = iCreatorInfo.FindInUnsignedKeyOrder(dummy);
+	if (found != KErrNotFound)
+		{
+		result = iCreatorInfo[found].iCreatorThreadId;
+		}
+	BreakpointUnlock();
+	return result;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/fdebuggerkernel.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,213 @@
+// fdebuggerkernel.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FDEBUGGERKERNEL_H
+#define FDEBUGGERKERNEL_H
+
+#include <nkern.h>
+#include <kernel.h>
+#include <kern_priv.h>
+
+#include <fshell/common.mmh>
+#include "memoryaccess.h"
+class TDynDfcQueWrapper;
+
+class MDebuggerEventClient
+	{
+public:
+	virtual void BreakpointHit(TDes& aPkg) =0;
+	};
+
+NONSHARABLE_CLASS(DDebuggerEventHandler) : public DKernelEventHandler
+	{
+public:
+	static DDebuggerEventHandler* New(TDfcQue* aQue);
+
+	TInt GetZombieMode();
+	TInt SetZombieMode(TInt aMode);
+	HBuf* GetZombieThreadIds();
+	TInt ReleaseZombie(DThread* aThread);
+	TInt SuspendThread(DThread* aThread);
+
+	TInt RegisterForBreakpointNotification(MDebuggerEventClient* aClient);
+	void UnregisterForBreakpointNotification(MDebuggerEventClient* aClient);
+
+	TInt SetBreakpoint(DThread* aThread, TLinAddr aAddress, const RMemoryAccess::TPredicate& aCondition);
+	TInt SetSymbolicBreakpoint(DThread* aThread, HBuf* aCodesegName, TUint32 aOffset, const RMemoryAccess::TPredicate& aCondition);
+	TInt RegisterPersistantBreakpoint(DThread* aThread, TLinAddr aAddress);
+	TInt SetBreakpointEnabled(TInt aBreakpointId, TBool aEnabled);
+	TInt ClearBreakpoint(TInt aBreakpointId);
+	TInt ContinueFromBreakpoint(DThread* aThread, TLinAddr aExceptionAddress);
+	HBuf* GetBreakpoints();
+
+	TUint GetCreatorThread(TUint aThreadId); // Returns 0 if not known
+
+private:
+	DDebuggerEventHandler(TDfcQue* aQue);
+	~DDebuggerEventHandler();
+	static TUint Event(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aPrivateData);
+	TUint DoEvent(TKernelEvent aEvent, TAny* a1, TAny* a2);
+	void CompleteZombies();
+	void Lock();
+	void Unlock();
+	void BreakpointLock();
+	void BreakpointUnlock();
+	struct SZombie;
+	SZombie* FindZombie(DThread* aThread);
+	void ReleaseZombie(SZombie* aZombie);
+	void ReleaseZombieAndUnlock(SZombie* aZombie);
+	void UnsuspendThread(SZombie* aZombie);
+	TInt Zombify(TLinAddr aBreakpointAddr=0);
+	struct SBreakpoint;
+	SBreakpoint* FindBreakpointByAddress(/*DThread* aThread,*/ TLinAddr aAddress);
+	SBreakpoint* FindBreakpointById(TInt aId);
+	SBreakpoint* FindBreakpointUsingHardwareContextRegister(TInt aRegister);
+	SBreakpoint* FindHardwareBreakpoint(DThread* aThread, TLinAddr aAddress);
+	enum TBreakpointPolicy
+		{
+		EWhatever,
+		EHardwareOnly,
+		ESoftwareOnly,
+		};
+	TInt ApplyBreakpoint(SBreakpoint* aBreakpoint, TBreakpointPolicy aPolicy=EWhatever);
+	void UnapplyBreakpoint(SBreakpoint* aBreakpoint);
+	void ClearBreakpoint(SBreakpoint* aBreakpoint, TBool aResumeAllBlocked=EFalse);
+	TInt SetProgramCounter(DThread* aThread, TLinAddr aAddress);
+	void ClearAllBreakpoints();
+	void RemoveAllHardwareBreakpointsForThread(DThread* aThread);
+	void HandleRestoreCode(TLinAddr aAddress);
+	static void HandleCodesegRemoved(TAny* aPtr);
+	void DoHandleCodesegRemoved();
+	TInt ReadInstructions(DThread* aThread, TLinAddr aAddress, TInt aLength, TDes8& aData);
+	TInt ApplyHardwareBreakpoint(SBreakpoint* aBreakpoint);
+	TInt DoApplyHardwareBreakpoint(SBreakpoint* aBreakpoint, TInt aContextReg);
+	static TUint32 GetArmContextIdForThread(DThread* aThread);
+	TInt MoveBreakpointToNextInstructionForThread(DThread* aThread, SBreakpoint* aBreakpoint);
+#ifdef __EABI__
+	void DoClearHardwareBreakpoint(SBreakpoint* aBreakpoint);
+	void SetDscr(TUint32 aVal);
+	void SetBreakpointPair(TInt aRegister, TUint aBvrValue, TUint aBcrValue);
+	TUint ReadBcr(TInt aRegister);
+	void SetContextIdBrp(TInt aRegister, TUint aContextId);
+
+	// Ones from the-TLA-that-dare-not-speak-its-name
+	TInt ReadKernelRegisterValue(DThread* aThread, TInt aRegister, TUint32& aResult);
+	TInt DoReadMemory(DThread* aThread, TLinAddr aAddress, TInt aLength, TDes8& aResult);
+	TBool IsPreviousInstructionMovePCToLR(DThread *aThread);
+	TInt CurrentInstructionArm(DThread* aThread, TUint32& aInstruction);
+	TInt CurrentInstructionThumb(DThread* aThread, TUint32& aInstruction);
+	TUint32 PCAfterInstructionExecutes(DThread *aThread, TUint32 aCurrentPC, TUint32 /*aStatusRegister*/, TInt aInstSize, TUint32 &aNewRangeEnd, TBool &aChangingModes);
+	TUint32 ShiftedRegValue(DThread *aThread, TUint32 aInstruction, TUint32 aCurrentPC, TUint32 aStatusRegister);
+	TInt CurrentPC(DThread* aThread, TUint32& aPC);
+	TInt CurrentCPSR(DThread* aThread, TUint32& aCPSR);
+	TInt ReadMem32(DThread* aThread, const TUint32 aAddress, TUint32& aValue);
+	TInt ReadMem16(DThread* aThread, const TUint32 aAddress, TUint16& aValue);
+	TInt RegisterValue(DThread *aThread, const TUint32 aKernelRegisterId, TUint32 &aValue);
+#endif
+
+#ifdef FSHELL_ARM_MEM_MAPPED_DEBUG
+	TUint32 ReadRegister(TInt aRegisterOffset);
+	void WriteRegister(TInt aRegisterOffset, TUint32 aValue);
+#endif
+
+private:
+	enum TZombieMode
+		{
+		EDisabled = 0,
+		EAbnormalExit = 1,
+		EAllExits = 2,
+		};
+	TZombieMode iZombieMode;
+	
+	struct SZombie
+		{
+		DThread* iThread;
+		SDblQueLink iLink;
+		DSemaphore* iBlocker; // Null if thread manually suspended via SuspendThread
+		TLinAddr iBreakpointAddress; // > 0 if the thread is blocked on a breakpoint
+		};
+	SDblQue iZombies;
+	TInt iZombieCount;
+	NFastMutex iLock; // For iZombies and other non-breakpoint-related structures
+
+	struct SBreakpoint
+		{
+		SBreakpoint(DThread* aThread, TInt aBreakpointId, TLinAddr aAddress, const RMemoryAccess::TPredicate& aCondition);
+		void SetThreadMatchPattern(HBuf* aMatch);
+		TBool MatchesThread(DThread* aThread) const;
+		~SBreakpoint(); // Note this DOESNT deque from the breakpoint list - do that first!
+
+		TBool HasModifiedCode() const;
+		TBool IsHardware() const;
+
+		DThread* iThread;
+		TInt iBreakpointId;
+		TLinAddr iAddress; // If the breakpoint is pending, this is actually the codeseg offset
+		TBuf8<4> iOrigInstruction;
+		SDblQueLink iLink;
+		TAny* iCodeSeg; // If the breakpoint is pending, an HBuf* which is the name of the codeseg. For a persistant breakpoint, NULL. For anything that HasModifiedCode(), the DCodeSeg* that the address is in
+		enum TFlags
+			{
+			EDisabledPendingCodesegLoad = 1,
+			EDisabledByUser = 2,
+			EDisabledDuringContinue = 4,
+			EDisabled = EDisabledPendingCodesegLoad|EDisabledByUser|EDisabledDuringContinue,
+
+			EPersistant = 8, // Meaning the actual code has an invalid instruction, so hasn't been ModifyCoded, so we should resume to the next instruction.
+			EThumb = 16,
+			EHardware = 32, // Implies EThreadSpecific
+			ETempContinue = 64,
+			EThreadSpecific = 128, // Only match a single specified thread.
+			};
+		TUint iFlags;
+		SBreakpoint* iRealBreakpoint; // If iFlags&ETempContinue, points to the breakpoint we're temping for. Otherwise, this indicates that the breakpoint hasn't called ModifyCode because (currently) there is another breakpoint (in a different thread) at the same address that has done it for us.
+		TInt iHardwareBreakpointId; // Only relevant if iFlags&EHardware
+		TInt iHardwareBreakpointContextReg; // Ditto. Value is either 4 or 5
+		//TInt iContinueCount;
+		HBuf* iMatch;
+		RMemoryAccess::TPredicate iCondition;
+
+	private:
+		SBreakpoint(); // No copying allowed
+		};
+	TBool iCodeModifierInited;
+	SDblQue iBreakpoints;
+	TInt iNextBreakpointId;
+	MDebuggerEventClient* iBreakpointNotifyClient;
+	/* Rules for the breakpoint lock: Any manipulation of iBreakpoints, or of any breakpoint on the iBreakpoints list, must be protected by this lock.
+	 * Ditto iFreeHwBreakpoints. SBreakpoint objects not on the list can be manipulated without needing the lock held
+	 */
+	DMutex* iBreakpointMutex;
+	TDfc iHandleCodesegRemovedDfc;
+	struct SRemovedCodeseg
+		{
+		DProcess* iProcess;
+		DCodeSeg* iCodeseg;
+		SDblQueLink iLink;
+		};
+	SDblQue iRemovedCodesegs; // Protected by iLock
+	TUint32 iFreeHwBreakpoints;
+	DPlatChunkHw* iDebugRegistersChunk;
+
+	class TCreatorInfo
+		{
+	public:
+		TCreatorInfo(TUint aThreadId, TUint aCreatorThreadId)
+			: iThreadId(aThreadId), iCreatorThreadId(aCreatorThreadId)
+			{}
+
+		TUint iThreadId;
+		TUint iCreatorThreadId;
+		};
+	RArray<TCreatorInfo> iCreatorInfo;
+	};
+
+#endif // FDEBUGGERKERNEL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/hwbreak.cia	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,223 @@
+// hwbreak.cia
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+#include <u32std.h>
+
+#define READ_BCR(cond, n, resultreg) asm("MRC"#cond" p14,0,"#resultreg",c0,c"#n",5")
+#define WRITE_BCR(n, valuereg) asm("MCR p14,0,"#valuereg",c0,c"#n",5")
+#define WRITE_BVR(n, valuereg) asm("MCR p14,0,"#valuereg",c0,c"#n",4")
+
+#ifdef __GCCE__
+#ifdef __NAKED__
+#undef __NAKED__
+#endif
+#define __NAKED__ __attribute__((__naked__))
+#endif
+
+__NAKED__ void MCR_SetContextIdBrp(TInt /*aRegister*/, TUint /*aContextId*/)
+	{
+	asm("ldr r2, KContextIdBCR");
+	
+	// Use BVR 4 or 5 as appropriate
+	asm("cmp r0, #4");
+	asm("beq usefour");
+	
+	// otherwise use 5
+	WRITE_BVR(5, r1);
+	WRITE_BCR(5, r2);
+	asm("b contextdone");
+	
+	asm("usefour:");
+	WRITE_BVR(4, r1);
+	WRITE_BCR(4, r2);
+	
+	asm("contextdone:");
+	__JUMP(,lr);
+	
+	// These are according to "ARM 13.3.9. CP14 c80-c85, Breakpoint Control Registers (BCR)"
+	asm("KContextIdBCR:");
+	asm(".word 0x003001E7");
+	}
+
+__NAKED__ TUint MRC_ReadBcr(TInt /*aRegister*/)
+	{
+	// Switch on aRegister
+	asm("cmp r0, #0");
+	READ_BCR(eq, 0, r0);
+	__JUMP(eq, lr);
+
+	asm("cmp r0, #1");
+	READ_BCR(eq, 1, r0);
+	__JUMP(eq, lr);
+
+	asm("cmp r0, #2");
+	READ_BCR(eq, 2, r0);
+	__JUMP(eq, lr);
+
+	asm("cmp r0, #3");
+	READ_BCR(eq, 3, r0);
+	__JUMP(eq, lr);
+
+	asm("cmp r0, #4");
+	READ_BCR(eq, 4, r0);
+	__JUMP(eq, lr);
+
+	asm("cmp r0, #5");
+	READ_BCR(eq, 5, r0);
+	__JUMP(eq, lr);
+	
+	// Shouldn't get here, compiler shutter-upper
+#ifdef __GCCE__
+	return 0;
+#else
+	__JUMP(, lr);
+#endif
+	}
+	
+__NAKED__ void MCR_SetBreakpointPair(TInt /*aRegister*/, TUint /*aBvrValue*/, TUint /*aBcrValue*/ )
+	{
+	// Switch on aRegister
+	asm("cmp r0, #0");
+	asm("beq zero");
+	asm("cmp r0, #1");
+	asm("beq one");
+	asm("cmp r0, #2");
+	asm("beq two");
+	asm("cmp r0, #3");
+	asm("beq three");
+	
+	// If we reach here it's an error...
+	asm("b done");
+	
+	asm("zero:");
+	WRITE_BVR(0, r1);
+	WRITE_BCR(0, r2);
+	asm("b done");
+	
+	asm("one:");
+	WRITE_BVR(1, r1);
+	WRITE_BCR(1, r2);
+	asm("b done");
+	
+	asm("two:");
+	WRITE_BVR(2, r1);
+	WRITE_BCR(2, r2);
+	asm("b done");
+	
+	asm("three:");
+	WRITE_BVR(3, r1);
+	WRITE_BCR(4, r2);
+	asm("b done");
+	
+	asm("done:");
+	__JUMP(,lr);
+	}
+
+__NAKED__ TUint32 GetDscr()
+	{
+	asm("MRC p14,0,r0,c0,c1,0");
+	__JUMP(,lr);
+	}
+	
+__NAKED__ TUint32 GetDrar()
+	{
+	// Read Debug ROM Address Register
+	asm("MRC p14, 0, r0, c1, c0, 0");
+	__JUMP(,lr);
+	}
+
+__NAKED__ TUint32 GetDsar()
+	{
+	// Read Debug Self Address Offset Register
+	asm("MRC p14, 0, r0, c2, c0, 0");
+	__JUMP(,lr);
+	}
+
+__NAKED__ void MCR_SetDscr(TUint32 /*aVal*/)
+	{
+	asm("MCR p14,0,r0,c0,c1,0");
+	__JUMP(,lr);
+	}
+
+__NAKED__ TUint32 GetContextId()
+	{
+	asm("MRC p15, 0, r0, c13, c0, 1");
+	__JUMP(,lr);
+	}
+
+__NAKED__ void Dsb()
+	{
+	asm("Dsb:");
+	// Data Sync Barrier
+	// From the various definitions of ARM_DSBxx in cpudefs.h
+#if defined(FSHELL_ARM11XX_SUPPORT)
+	asm("mcr p15, 0, r0, c7, c10, 4 ")
+#elif defined(FSHELL_ARM_MEM_MAPPED_DEBUG)
+	asm("nop"); // Shut up complaints about branches to non-code symbols
+	asm(".word %a0" : : "i" ((TInt)(0xf57ff04f)));
+#endif
+	__JUMP(,lr);
+	}
+
+__NAKED__ void Isb()
+	{
+	asm("Isb:");
+	// Instruction Sync Barrier
+	// From the various definitions of ARM_ISBxx in cpudefs.h
+
+#if defined(FSHELL_ARM11XX_SUPPORT)
+	asm("mcr p15, 0, r0, c7, c5, 4 ")
+#elif defined(FSHELL_ARM_MEM_MAPPED_DEBUG)
+	asm("nop"); // Shut up complaints about branches to non-code symbols
+	asm(".word %a0" : : "i" ((TInt)(0xf57ff06f)));
+#endif
+	__JUMP(,lr);
+	}
+
+__NAKED__ void Imb()
+	{
+	// Instruction Memory Barrier
+	asm("push {r14}");
+	asm("bl Dsb");
+	asm("bl Isb");
+	asm("pop {r14}");
+	__JUMP(,lr);
+	}
+
+
+#if 0
+__NAKED__ void SetIvaBrp(TUint /*aAddress*/, TBool /*aUseContextIdFive*/, TInt /*aRegister*/ )
+	{
+	asm("cmp r1, #0");
+	// r3 gets the BCR value
+	asm("ldreq r3, KIvaBcrLinkedToFour");
+	asm("ldrne r3, KIvaBcrLinkedToFive");
+	asm("b DoSetIvaBrp"); // DoSetIvaBrp handles the return
+	
+	asm("KIvaBcrLinkedToFour:");
+	asm(".word 0x001401E5");
+	asm("KIvaBcrLinkedToFive:");
+	asm(".word 0x001501E5");
+	}	
+
+__NAKED__ void UnsetBrp(TInt /*aRegister*/)
+	{
+	asm("mov r2, r0");
+	asm("mov r1, #0");
+	asm("mov r0, #0");
+	asm("ldr r3, KIvaBcrDisabled");
+	asm("b DoSetIvaBrp");
+	
+	asm("KIvaBcrDisabled:");
+	asm(".word 0x001401E4");
+	}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/hwbreak_cia.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,12 @@
+// hwbreak_cia.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "hwbreak.cia"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/memoryaccess.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1065 @@
+// memoryaccess.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __MemoryAccess_H__
+#define __MemoryAccess_H__
+
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
+#include <u32std.h>
+
+_LIT(KMemoryAccessName,"memoryAccess-fshell");
+
+typedef TBuf8<KMaxFullName> TFullName8;
+typedef TBuf8<KMaxFileName> TFileName8;
+
+//size of buffer used for returning queues
+const TInt KQueBufferLength = 1024; 
+
+//Buffer used to pass pointer arrays, of pointers to kernel side objects
+class TPointerArrayBuffer
+	{
+public:
+	TUint8* iBuffer[KQueBufferLength];  //buffer holding up to KQueBufferLength items of the array or queue
+	TUint iStartFrom; //the point in the array to start from
+	TUint iCount; //the total number of entries written into iBuffer.  If KMaxTInt, there are more available
+	};
+
+//
+//Structures used for communication with driver
+//
+
+class RProcess;
+
+class TObjectInfoByIndexParams
+	{
+public:
+	TObjectType iObjectType;
+	TUint iObjectIndex;
+	};
+typedef TPckgBuf<TObjectInfoByIndexParams> TObjectInfoByIndexParamsBuf;
+
+class TObjectInfoByPtrParams
+	{
+public:
+	TObjectType iObjectType;
+	TUint8* iObjectPtr;	
+	};
+typedef TPckgBuf<TObjectInfoByPtrParams> TObjectInfoByPtrParamsBuf;
+
+class TObjectInfoByNameParams
+	{
+public:
+	TObjectType iObjectType;
+	TBuf8<KMaxFullName> iObjectName;
+	};
+typedef TPckgBuf<TObjectInfoByNameParams> TObjectInfoByNameParamsBuf;
+
+class TObjectInfoByHandleParams
+	{
+public:
+	TObjectType iObjectType;
+	TInt iThreadId;	
+	TInt iObjectHandle;	
+	};
+typedef TPckgBuf<TObjectInfoByHandleParams> TObjectInfoByHandleParamsBuf;
+	
+class TThreadMemoryAccessParams
+	{
+public:
+	TUint iId;
+	const TUint8* iAddr;
+	TInt iSize;
+	};
+typedef TPckgBuf<TThreadMemoryAccessParams> TThreadMemoryAccessParamsBuf;
+
+class TObjectKillParams
+	{
+public:
+	TObjectType iObjectType;
+	TUint iObjectId;
+	TUint8* iObjectPtr;	
+	TExitType iType;
+	TInt iReason;
+	TFullName8 iCategory;
+	};
+typedef TPckgBuf<TObjectKillParams> TObjectKillParamsBuf;
+
+class TGetObjectAddressesParams
+	{
+public:
+	TObjectType iObjectType;
+	TFullName8 iOwningProcess;
+	};
+typedef TPckgBuf<TGetObjectAddressesParams> TGetObjectAddressesParamsBuf;
+
+class TGetChunkAddressesParams
+	{
+public:
+	TUint iControllingProcessId;
+	};
+typedef TPckgBuf<TGetChunkAddressesParams> TGetChunkAddressesParamsBuf;
+
+class TObjectKernelInfo
+	{
+public:
+	TUint8* iAddressOfKernelObject;
+	TFullName8 iName;
+	TFullName8 iFullName;
+	TInt iAccessCount;
+	TInt iUniqueID;
+	TUint iProtection;
+	TUint8* iAddressOfKernelOwner;
+	};
+typedef TPckgBuf<TObjectKernelInfo> TObjectKernelInfoBuf;
+
+class TThreadKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TUint iThreadId;
+	TUint8* iAddressOfOwningProcess;
+	TInt iThreadPriority;
+	TInt iUserStackSize;
+	TUint32 iFlags;
+	TLinAddr iSupervisorStack;
+	TInt iSupervisorStackSize;
+	TLinAddr iUserStackLimit;
+	TInt iNThreadSuspendCount;
+	inline TLinAddr UserStackBase() const { return iUserStackLimit + iUserStackSize; }
+	};
+typedef TPckgBuf<TThreadKernelInfo> TThreadKernelInfoBuf;
+
+const TInt KNumEnvironmentSlots = 16;
+
+class TProcessKernelInfo : public TObjectKernelInfo
+	{ 
+public:
+	TUint iProcessId;
+	TInt iPriority;
+	TUint8* iAddressOfOwningProcess;
+	TUint iCreatorId;
+	TUint iSecurityZone;
+	TUidType iUids;
+	TInt iAttributes;
+	TUint8* iAddressOfDataBssStackChunk;
+	TPointerArrayBuffer iThreadQ;
+	SSecurityInfo iProcessSecurityInfo;
+	SSecurityInfo iProcessCreatorSecurityInfo;
+	TBuf8<256> iCommandLine;
+	TUint32 iFlags;
+	TInt iEnvironmentData[KNumEnvironmentSlots];
+	TUint iFirstThreadId;
+	};
+typedef TPckgBuf<TProcessKernelInfo> TProcessKernelInfoBuf;	 
+
+class TChunkKernelInfo : public TObjectKernelInfo
+	{ 
+public:
+	TInt iSize;
+	TInt iMaxSize;
+	TUint8* iBase;
+	TInt iBottom;
+	TInt iTop;
+	TInt iAttributes;
+	TInt iStartPos;
+	TUint iControllingOwnerProcessId;
+	TUint iRestrictions;
+	TUint iMapAttr;
+	TUint iChunkType;
+	TUint8* iAddressOfOwningProcess;
+	};
+typedef TPckgBuf<TChunkKernelInfo> TChunkKernelInfoBuf;	 
+
+class TLibraryKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TInt iMapCount;
+	TUint8 iState;
+	TUint8* iAddressOfCodeSeg;
+	};
+typedef TPckgBuf<TLibraryKernelInfo> TLibraryKernelInfoBuf;	 
+
+class TSemaphoreKernelInfo : public TObjectKernelInfo
+	{ 
+public:
+	TInt iCount;
+	TUint8 iResetting;
+	TPointerArrayBuffer iSuspendedQ;
+	};
+typedef TPckgBuf<TSemaphoreKernelInfo> TSemaphoreKernelInfoBuf;	 
+
+class TMutexKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TInt iHoldCount;
+	TInt iWaitCount;
+	TUint8 iResetting;
+	TUint8 iOrder;
+	TPointerArrayBuffer iSuspendedQ;
+	TPointerArrayBuffer iPendingQ;
+	};
+typedef TPckgBuf<TMutexKernelInfo> TMutexKernelInfoBuf;	 
+
+class TTimerKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TUint8 iState;
+	TUint8 iType;
+	TLinAddr iClientStatus;
+	};
+typedef TPckgBuf<TTimerKernelInfo> TTimerKernelInfoBuf;	 
+
+class TServerKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TUint8*	iAddressOfOwningThread;
+	TUint8 iSessionType;
+	TPointerArrayBuffer iSessionQ;
+	TUint iOwningThreadId;
+	};
+typedef TPckgBuf<TServerKernelInfo> TServerKernelInfoBuf;	 
+
+class TSessionKernelInfo : public TObjectKernelInfo
+	{ 
+public:
+	TUint8*	iServer;
+	TAny* 	iSessionPtr;
+	TUint16	iTotalAccessCount;
+	TUint8 iSessionType;
+	TUint8 iSvrSessionType;
+	TInt iMsgCount;
+	TInt iMsgLimit;
+	};
+typedef TPckgBuf<TSessionKernelInfo> TSessionKernelInfoBuf;	 
+
+class TLogicalDeviceKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TVersion iVersion;
+	TUint iParseMask;
+	TUint iUnitsMask;
+	TInt iOpenChannels;
+	};
+typedef TPckgBuf<TLogicalDeviceKernelInfo> TLogicalDeviceKernelInfoBuf;	 
+
+class TPhysicalDeviceKernelInfo : public TObjectKernelInfo
+	{ 
+public:
+	TVersion iVersion;
+	TUint iUnitsMask;
+	TUint8* iAddressOfCodeSeg;
+	};
+typedef TPckgBuf<TPhysicalDeviceKernelInfo> TPhysicalDeviceKernelInfoBuf;	 
+
+class TLogicalChannelKernelInfo : public TObjectKernelInfo
+	{
+public:
+	};
+typedef TPckgBuf<TLogicalChannelKernelInfo> TLogicalChannelKernelInfoBuf;	 
+
+class TChangeNotifierKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TUint iChanges;
+	TUint8* iAddressOfThread;
+	};
+typedef TPckgBuf<TChangeNotifierKernelInfo> TChangeNotifierKernelInfoBuf;	 
+
+class TUndertakerKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TUint8* iOwningThread;
+	};
+typedef TPckgBuf<TUndertakerKernelInfo> TUndertakerKernelInfoBuf;	 
+
+class TMsgQueueKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TUint iMaxMsgLength;
+	};
+typedef TPckgBuf<TMsgQueueKernelInfo> TMsgQueueKernelInfoBuf;	 
+
+class TPropertyRefKernelInfo : public TObjectKernelInfo
+	{
+public:
+	};
+typedef TPckgBuf<TPropertyRefKernelInfo> TPropertyRefKernelInfoBuf;	 
+
+class TCondVarKernelInfo : public TObjectKernelInfo
+	{
+public:
+	TUint8 iResetting;
+	TUint8* iAddressOfMutex;
+	TInt iWaitCount;
+	TPointerArrayBuffer iSuspendedQ;
+	};
+typedef TPckgBuf<TCondVarKernelInfo> TCondVarKernelInfoBuf;	 
+
+class TCodeSegKernelInfo
+	{
+public:
+	TUint32 iRunAddress;
+	TInt iSize;
+	TFileName8 iFileName;
+	};
+typedef TPckgBuf<TCodeSegKernelInfo> TCodeSegKernelInfoBuf;	 
+
+class TTomsciCodeSegKernelInfo : public TCodeSegKernelInfo
+	{
+public:
+	TUint8* iAddressOfKernelObject;
+	TFullName8 iName;
+	TInt iAccessCount;
+	TInt iDepCount;
+	};
+
+class TProp
+	{
+public:
+	TUid iCategory;
+	TUint iKey;
+	TInt iActualSize; // Return value, only used when getting a descriptor property
+	TBool iDefine;
+	};
+
+class TPropNotifyResult
+	{
+public:
+	TUint iCategory;
+	TUint iKey;
+	TInt iMissedChanges;
+	TInt iError;
+	};
+
+class TRamZoneInfo
+	{
+public:
+	TUint iFreePages;
+	TUint iUnknownPages;
+	TUint iFixedPages;
+	TUint iMovablePages;
+	TUint iDiscardablePages;
+	};
+
+class TProcessProperties
+	{
+public:
+	TProcessProperties() : iSid(0xFFFFFFFFu), iVid(0xFFFFFFFFu), /*iHeapMin(0), iHeapMax(0), iStackSize(0),*/ iProcessPriority(0)
+		{
+		iCapsToAdd.SetEmpty();
+		iCapsToRemove.SetEmpty();
+		}
+
+	TCapabilitySet iCapsToAdd;
+	TCapabilitySet iCapsToRemove;
+	TUint iSid;
+	TUint iVid;
+	//TUint iHeapMin;
+	//TUint iHeapMax;
+	//TUint iStackSize;
+	TInt iProcessPriority;
+	};
+
+// class RMemoryAccess
+//  User side communication interface to Memory Access driver.
+//  Provides access to arbitrary kernel objects, memory, and some basic object manipulation.
+//  For use in debugging tools only!  Do not include in a release ROM.
+class RMemoryAccess : public RBusLogicalChannel
+	{
+public:
+	enum TControl
+		{
+		EControlGetThreadMem,
+		EControlGetAllocatorAddress,
+		EControlResetTimer,
+		EControlGetContainerCount,
+		EControlAcquireContainerMutex,
+		EControlReleaseContainerMutex,
+		EControlGetObjectType,
+		EControlGetObjectInfo,
+		EControlGetObjectInfoByPtr,
+		EControlGetObjectInfoByHandle,
+		EControlAcquireCodeSegMutex,
+		EControlReleaseCodeSegMutex,
+		EControlGetNextCodeSegInfo,
+		EControlObjectDie,
+		EControlGetObjectInfoByName,
+		EControlGetObjectAddresses,
+		EControlGetChunkAddresses,
+		EControlGetCurrentAllocatorAddress,
+		EControlFindPtrInCodeSegments,
+		EControlGetHandleOwners,
+		EControlForceCrash,
+		EControlGetPropertyInt,
+		EControlGetPropertyDesc,
+		EControlSetPropertyInt,
+		EControlSetPropertyDesc,
+		EControlDeleteProperty,
+		EControlSetThreadPriority,
+		EControlNotifyThreadCreation,
+		EControlCancelNotifyThreadCreation,
+		EControlSetPriorityOverride,
+		EControlSetCriticalFlags,
+		EControlOpenThread,
+		EControlGetThreadHandles,
+		EControlGetProcessHandles,
+		EControlInPlaceThreadRename,
+		ERemoved1, //EControlGetBinaryPropertyKernelLocation
+		EControlInPlaceObjectRename,
+		EControlInPlaceSetProcessFileName,
+		ERemoved2, //EControlGetAllProperties,
+		ERemoved3, //EControlSetupMassPropertyNotify,
+		ERemoved4, //EControlMassPropertyNotifyStart,
+		ERemoved5, //EControlMassPropertyNotifyStop,
+		EControlEnableHeapTracing,
+		EControlDefragRam,
+		EControlEmptyRamZone,
+		EControlGetRamZoneInfo,
+		EControlSetProcessProperties,
+		EControlWriteShadowMemory,
+		EControlFreeShadowMemory,
+		EControlSetZombieDebugMode,
+		EControlWriteMem,
+		EControlSetTextTraceMode,
+		EControlGetRegisters,
+		EControlGetZombies,
+		EControlGetZombieDebugMode,
+		EControlReleaseZombie,
+		EControlSuspendThread,
+		EControlNotifyBreakpoint,
+		EControlSetBreakpoint,
+		EControlSetBreakpointEnabled,
+		EControlClearBreakpoint,
+		EControlContinueFromBreakpoint,
+		EControlGetBreakpoints,
+		EControlCancelNotifyBreakpoint,
+		EControlRegisterPersistantBreakpoint,
+		EControlSetSymbolicBreakpoint,
+		EControlSetDebugPort,
+		EControlReboot,
+		EControlGetCreatorThread,
+		EControlPropertyNotify,
+		EControlPropertyNotifyCancel,
+		EControlSubscribeToProperty,
+		ENumRequests,  // Add new commands above this line
+        };
+public:
+	static TInt LoadDriver();
+	static void CloseDriver();
+
+public:
+	//Open the driver
+	TInt Open();
+	//Deprecated.
+	TInt ResetTimer();
+	//Read memory from the context of a thread
+	TInt GetThreadMem(const TThreadMemoryAccessParamsBuf& aParams, TDes8& aBuf);
+	//Get the address of the allocator of a thread
+	TInt GetAllocatorAddress(TUint aThreadId, TUint8*& aAddressOfKernelObject);
+	TInt GetCurrentAllocatorAddress(TUint aThreadId, TUint8*& aAddressOfKernelObject);
+	TInt FindAddressInCodeSegments(TFullName8& aDllName, TAny* aPtr);
+	TInt GetHandleOwners(TAny* aKernelObjectPtr, TDes8& aOwnersBuf);
+	TInt GetThreadHandles(TUint aThreadId, TDes8& aHandlesBuf);
+	TInt GetProcessHandles(TUint aProcessId, TDes8& aHandlesBuf);
+	void ForceCrash();
+	void Reboot(TInt aReason);
+
+	//Get the number of objects in a specified kernel container
+	TInt GetContainerCount (const TObjectType aObjectType, TUint& aCount);
+	//Wait on the mutex of a specified kernel container
+	TInt AcquireContainerMutex (const TObjectType aObjectType);
+	//Signal the mutex of a specified kernel container
+	TInt ReleaseContainerMutex (const TObjectType aObjectType);
+	//Get the type of a DObject* object in the kernel
+	TInt GetObjectType (TUint8* aKernelObjectAddr, TObjectType& aObjectType);
+	//Get info about a kernel object, referenced by position in its container.  Call AcquireContainerMutex before calling.
+	TInt GetObjectInfo (TObjectType aObjectType, TUint aIndexInKernelContainer, TDes8& aObjectInfoBuf);
+	//Get info about a kernel object specified as a DObject*
+	TInt GetObjectInfo (TObjectType aObjectType, TUint8* aAddressOfKernelObject, TDes8& aObjectInfoBuf);
+	//Get info about a kernel object specified by name.
+	TInt GetObjectInfo (TObjectType aObjectType, const TDesC& aObjectName, TDes8& aObjectInfoBuf);
+	//Get info about a kernel object specified as a user side handle	
+	TInt GetObjectInfoByHandle (TObjectType aObjectType, TInt aThreadId, TInt aObjectHandle, TDes8& aObjectInfoBuf);
+	//Wait on the kernel's code seg mutex
+	TInt AcquireCodeSegMutex();
+	//Signal the kernel's code seg mutex
+	TInt ReleaseCodeSegMutex();
+	//Get info about the next code seg.  Call repeatedly to iterate all code segs.  Call AcquireCodeSegMutex before calling.
+	TInt GetNextCodeSegInfo(TDes8& aCodeSegInfoBuf);
+	//Kill an object.  aObyType should be a thread or process.  Either an objectId (user side handle) _OR_ objectPtr (kernel side DObject*) should be provided.
+	TInt ObjectDie(TObjectType aObjType, TUint aObjectId, TUint8* aObjectPtr, TExitType aType, TInt aReason, const TDesC& aCategory);
+	//Pack the addresses of all the kernel objects of the specified type belonging to the specified process into the supplied buffer.
+	//Returns KErrOverflow if the buffer isn't big enough to hold all the addresses. aOwningProcess may contain '?' and '*' wild characters.
+	TInt GetObjectAddresses(TObjectType aObjType, const TDesC& aOwningProcess, TDes8& aAddressBuffer);
+	//Pack the addresses of all the chunks with a the specified controlling process id into the supplied buffer.
+	//Returns KErrOverflow if the buffer isn't big enough to hold all the addresses. Note, this interface allows global chunks (which have
+	//a NULL owner pointers, hence can't be found using RMemoryAccess::GetObjectAddresses) that were created by a particular process to be found.
+	TInt GetChunkAddresses(TUint aControllingProcessId, TDes8& aAddressBuffer);
+
+	TInt GetProperty(TUid aCategory, TUint aKey, TInt& aValue);
+	TInt GetProperty(TUid aCategory, TUint aKey, TDes8& aValue, TInt& aActualSize);
+	TInt SetProperty(TUid aCategory, TUint aKey, TInt aValue, TBool aDefineIfNotSet=EFalse);
+	TInt SetProperty(TUid aCategory, TUint aKey, const TDesC8& aValue, TBool aDefineIfNotSet=EFalse);
+	TInt DeleteProperty(TUid aCategory, TUint aKey);
+	TInt SubscribeToProperty(TUid aCategory, TUint aKey, TBool aOutputToBtrace); // If aOutputToBtrace is false, use NotifyPropertyChange to get details
+
+	void NotifyPropertyChange(TPropNotifyResult& aResult, TRequestStatus& aStatus);
+	void CancelPropertyChange();
+
+	TInt RThreadForceOpen(RThread& aThread, TUint aId);
+	TInt SetThreadPriority(RThread& aThread, TInt aPriority);
+	void NotifyThreadCreation(TRequestStatus& aStatus);
+	void CancelNotifyThreadCreation();
+	TInt SetPriorityOverride(TInt aPriority, const TDesC8& aMatchString); // any thread that is created that matches the wildcard string aMatchString is given thread priority aPriority
+	TInt SetThreadCriticalFlags(RThread& aThread, TUint aFlags);
+	TLinAddr InPlaceThreadRename(RThread& aThread, const TDesC8& aNewName);
+	TInt InPlaceObjectRename(TObjectType aObjectType, TUint8* aAddressOfKernelObject, const TDesC8& aNewName);
+	TInt InPlaceSetProcessFileName(RProcess& aProcess, const TDesC8& aNewName);
+	TInt SetProcessProperties(RProcess& aProcess, const TProcessProperties& aProperties);
+	TInt WriteShadowMemory(TLinAddr aAddress, const TDesC8& aNewContents);
+	TInt FreeShadowMemory(TLinAddr aAddress, TInt aLen);
+	TInt SetDebugPort(TInt aPort);
+	TUint GetThreadCreatorId(TUint aThreadId);
+
+	TInt EnableHeapTracing(TUint aThreadId, TBool aEnable);
+	TInt DefragRam(TInt aPriority);
+	TInt EmptyRamZone(TUint aZone, TInt aPriority);
+	TInt GetRamZoneInfo(TUint aZone, TDes8& aInfoPkg);
+
+	// Debugger APIs
+	TInt GetZombieDebugMode();
+	TInt SetZombieDebugMode(TInt aMode);
+	class TZombieInfo
+		{
+	public:
+		TUint iThreadId;
+		enum TFlags { ESuspended = 1, EBreakpoint = 2 };
+		TUint iFlags;
+		};
+	TInt GetZombies(TDes8& aResultBuf); // buffer full of TZombieInfos
+	TInt WriteMem(TUint aThreadId, const TDesC8& aMem, TAny* aAddr);
+	TInt SetTextTraceMode(TUint& aMode, TUint aMask);
+	TInt GetRegisters(RThread& aThread, TBool aUserMode, TDes8& aRegBuf, TUint32& aValid);
+	TInt ReleaseZombie(RThread& aThread);
+	TInt SuspendThread(RThread& aThread); // To resume, call ReleaseZombie
+
+	class TBreakpointNotification
+		{
+	public:
+		TUint iThreadId;
+		TInt iBreakpointId;
+		TLinAddr iAddress;
+		};
+
+	class TPredicate
+		{
+	public:
+		enum { KNumSlots = 4 };
+		enum TOp
+			{
+			ENothing = 0,
+			EEq, ENe, ELt, ELe, EGt, EGe, ESignedEq, ESignedNe, ESignedLt, ESignedLe, ESignedGt, ESignedGe,
+			};
+		TPredicate() : iOp(0) {}
+		TBool HasConditions() const { return iOp != 0; }
+
+#ifdef __KERNEL_MODE__
+		TBool SatisfiesConditions(TUint32* aRegisterSet) const;
+	private:
+		static TBool Test(TOp aOperation, TUint32 aCurrentValue, TUint32 aStoredValue);
+#else
+		TInt AddCondition(TOp aOperation, TInt aRegNum, TUint32 aValue);
+		void Description(TDes& aBuf);
+#endif
+
+	private:
+		TUint32 iOp; // 8 bits for each, of which top 4 is reg that the relevant iVals is to be compared against, bottom 4 is the comparison operation (one of TOp)
+		TUint32 iVals[KNumSlots];
+		};
+
+	void NotifyBreakpoint(TPckg<TBreakpointNotification>& aPkg, TRequestStatus& aStatus);
+	void CancelNotifyBreakpoint();
+	//TInt SetBreakpoint(TLinAddr aAddress); // Global, all threads (except caller and the memaccess DFC thread). Returns breakpoint ID or an error code
+	TInt SetBreakpoint(RThread& aThread, TLinAddr aAddress, TPredicate* aCondition = NULL); // Returns breakpoint ID or an error code. Breakpoint ID may be OR'd with TBreakpointInfo::EHardware if a hardware breakpoint was sucessfully set
+	TInt SetSymbolicBreakpoint(RThread& aThread, const TDesC8& aCodeseg, TUint aOffset, TPredicate* aCondition = NULL);
+	TInt RegisterPersistantBreakpoint(TLinAddr aAddress);
+	TInt SetBreakpointEnabled(TInt aBreakpointId, TBool aEnabled);
+	TInt ClearBreakpoint(TInt aBreakpointId); // Removes it completely. Doesn't resume anything waiting on it though
+	TInt ContinueFromBreakpoint(RThread& aThread); // aThread must be waiting on a breakpoint otherwise KErrNotReady
+
+	class TBreakpointInfo
+		{
+	public:
+		TUint iThreadId;
+		TInt iBreakpointId;
+		TLinAddr iAddress;
+		enum TFlags
+			{
+			EPending = 1,
+			EEnabled = 2, // Enabled by user, that is. It could still be pending and thus not actually going to case a break at this point in time
+			EHardware = 0x40000000,
+			};
+		TUint32 iFlags;
+		TPredicate iCondition;
+		};
+	TInt GetBreakpoints(TDes8& aBuf); // buffer full of TBreakpointInfos
+	};
+
+#ifndef __KERNEL_MODE__
+// Inline implementations of user side interface
+
+inline TInt RMemoryAccess::LoadDriver()
+	{	return User::LoadLogicalDevice(KMemoryAccessName);	}
+inline void RMemoryAccess::CloseDriver()
+	{	User::FreeLogicalDevice(KMemoryAccessName);	}
+inline TInt RMemoryAccess::Open()
+	{	return DoCreate(KMemoryAccessName,TVersion(1,0,0),KNullUnit,NULL,NULL); 	}
+inline TInt RMemoryAccess::GetThreadMem(const TThreadMemoryAccessParamsBuf& aParams, TDes8& aBuf)
+	{	return DoControl(EControlGetThreadMem, (TAny*)&aParams, (TAny*)&aBuf);	}
+inline TInt RMemoryAccess::GetAllocatorAddress(TUint aThreadId, TUint8*& aAddressOfKernelObject)
+	{	return DoControl(EControlGetAllocatorAddress, (TAny*)aThreadId, &aAddressOfKernelObject);	}
+// This returns the current allocator (User::Allocator) as opposed to the one created in SThreadCreateInfo
+inline TInt RMemoryAccess::GetCurrentAllocatorAddress(TUint aThreadId, TUint8*& aAddressOfKernelObject)
+	{	return DoControl(EControlGetCurrentAllocatorAddress, (TAny*)aThreadId, &aAddressOfKernelObject);	}
+inline TInt RMemoryAccess::FindAddressInCodeSegments(TFullName8& aDllName, TAny* aPtr)
+	{	return DoControl(EControlFindPtrInCodeSegments, (TAny*)&aDllName, aPtr);	}
+inline TInt RMemoryAccess::GetHandleOwners(TAny* aHandle, TDes8& aOwnersBuf)
+	{	return DoControl(EControlGetHandleOwners, (TAny*)aHandle, (TAny*)&aOwnersBuf);	}
+inline TInt RMemoryAccess::GetThreadHandles(TUint aThreadId, TDes8& aHandlesBuf)
+	{	return DoControl(EControlGetThreadHandles, (TAny*)aThreadId, &aHandlesBuf);	}
+inline TInt RMemoryAccess::GetProcessHandles(TUint aProcessId, TDes8& aHandlesBuf)
+	{	return DoControl(EControlGetProcessHandles, (TAny*)aProcessId, &aHandlesBuf);	}
+inline void RMemoryAccess::ForceCrash()
+	{	DoControl(EControlForceCrash);	}
+inline void RMemoryAccess::Reboot(TInt aReason)
+	{	DoControl(EControlReboot, (TAny*)aReason); }
+inline TInt RMemoryAccess::ResetTimer()
+	{	return DoControl(EControlResetTimer, NULL, NULL);	}
+inline TInt RMemoryAccess::GetContainerCount (const TObjectType aObjectType, TUint& aCount)
+	{	return DoControl(EControlGetContainerCount, (TAny*)aObjectType, (TAny*)&aCount);	}
+inline TInt RMemoryAccess::AcquireContainerMutex (const TObjectType aObjectType)	{	return DoControl(EControlAcquireContainerMutex, (TAny*)aObjectType, NULL);		}
+inline TInt RMemoryAccess::ReleaseContainerMutex (const TObjectType aObjectType)
+	{	return DoControl(EControlReleaseContainerMutex, (TAny*)aObjectType, NULL);		}
+inline TInt RMemoryAccess::GetObjectType (TUint8* aKernelObjectAddr, TObjectType& aObjectType)
+	{	return DoControl(EControlGetObjectType, (TAny*)aKernelObjectAddr, (TAny*)&aObjectType);	}
+inline TInt RMemoryAccess::GetObjectInfo (TObjectType aObjectType, TUint aIndexInKernelContainer, TDes8& aObjectInfoBuf)
+	{	
+	TObjectInfoByIndexParamsBuf params;
+	params().iObjectType=aObjectType;
+	params().iObjectIndex=aIndexInKernelContainer;
+	return DoControl(EControlGetObjectInfo, (TAny*)&params, (TAny*)&aObjectInfoBuf);	
+	}
+inline TInt RMemoryAccess::GetObjectInfo (TObjectType aObjectType, TUint8* aAddressOfKernelObject, TDes8& aObjectInfoBuf)
+	{
+	TObjectInfoByPtrParamsBuf params;
+	params().iObjectType=aObjectType;
+	params().iObjectPtr=aAddressOfKernelObject;	
+	return DoControl(EControlGetObjectInfoByPtr, (TAny*)&params, (TAny*)&aObjectInfoBuf);	
+	}
+inline TInt RMemoryAccess::GetObjectInfo (TObjectType aObjectType, const TDesC& aObjectName, TDes8& aObjectInfoBuf)
+	{
+	TObjectInfoByNameParamsBuf params;
+	params().iObjectType=aObjectType;
+	params().iObjectName.Copy(aObjectName);	
+	return DoControl(EControlGetObjectInfoByName, (TAny*)&params, (TAny*)&aObjectInfoBuf);	
+	}
+inline TInt RMemoryAccess::GetObjectInfoByHandle (TObjectType aObjectType, TInt aThreadId, TInt aObjectHandle, TDes8& aObjectInfoBuf)
+	{
+	TObjectInfoByHandleParamsBuf params;
+	params().iObjectType=aObjectType;
+	params().iThreadId=aThreadId;	
+	params().iObjectHandle=aObjectHandle;	
+	return DoControl(EControlGetObjectInfoByHandle, (TAny*)&params, (TAny*)&aObjectInfoBuf);	
+	}
+inline TInt RMemoryAccess::AcquireCodeSegMutex()
+	{	return DoControl(EControlAcquireCodeSegMutex, NULL, NULL);		}
+inline TInt RMemoryAccess::ReleaseCodeSegMutex()
+	{	return DoControl(EControlReleaseCodeSegMutex, NULL, NULL);		}
+inline TInt RMemoryAccess::GetNextCodeSegInfo(TDes8& aCodeSegInfoBuf)
+	{	return DoControl(EControlGetNextCodeSegInfo, (TAny*)&aCodeSegInfoBuf, NULL);	}
+inline TInt RMemoryAccess::ObjectDie(TObjectType aObjType, TUint aObjectId, TUint8* aObjectPtr, TExitType aType, TInt aReason, const TDesC& aCategory)
+	{
+	TObjectKillParamsBuf params;
+	params().iObjectType=aObjType;
+	params().iObjectId=aObjectId;
+	params().iObjectPtr=aObjectPtr;	
+	params().iType=aType;
+	params().iReason=aReason;
+	params().iCategory.Copy(aCategory);
+	return DoControl(EControlObjectDie, (TAny*)&params, NULL);	
+	}
+inline TInt RMemoryAccess::GetObjectAddresses(TObjectType aObjType, const TDesC& aOwningProcess, TDes8& aAddressBuffer)
+	{
+	TGetObjectAddressesParamsBuf params;
+	params().iObjectType=aObjType;
+	params().iOwningProcess.Copy(aOwningProcess);
+	return DoControl(EControlGetObjectAddresses, (TAny*)&params, (TAny*)&aAddressBuffer);	
+	}
+inline TInt RMemoryAccess::GetChunkAddresses(TUint aControllingProcessId, TDes8& aAddressBuffer)
+	{
+	TGetChunkAddressesParamsBuf params;
+	params().iControllingProcessId=aControllingProcessId;
+	return DoControl(EControlGetChunkAddresses, (TAny*)&params, (TAny*)&aAddressBuffer);	
+	}
+	
+inline TInt RMemoryAccess::GetProperty(TUid aCategory, TUint aKey, TInt& aValue)
+	{
+	TProp params;
+	params.iCategory = aCategory;
+	params.iKey = aKey;
+	params.iDefine = EFalse;
+
+	TPckg<TInt> res(aValue);
+
+	return DoControl(EControlGetPropertyInt, (TAny*)&params, (TAny*)&res);
+	}
+
+inline TInt RMemoryAccess::GetProperty(TUid aCategory, TUint aKey, TDes8& aValue, TInt& aActualSize)
+	{
+	TProp params;
+	params.iCategory = aCategory;
+	params.iKey = aKey;
+	params.iDefine = EFalse;
+
+	TInt err = DoControl(EControlGetPropertyDesc, (TAny*)&params, (TAny*)&aValue);
+	if (err == KErrOverflow)
+		{
+		aActualSize = params.iActualSize;
+		}
+	return err;
+	}
+
+inline TInt RMemoryAccess::SetProperty(TUid aCategory, TUint aKey, TInt aValue, TBool aDefineIfNotSet)
+	{
+	TProp params;
+	params.iCategory = aCategory;
+	params.iKey = aKey;
+	params.iDefine = aDefineIfNotSet;
+
+	return DoControl(EControlSetPropertyInt, (TAny*)&params, (TAny*)aValue);
+	}
+
+inline TInt RMemoryAccess::SetProperty(TUid aCategory, TUint aKey, const TDesC8& aValue, TBool aDefineIfNotSet)
+	{
+	TProp params;
+	params.iCategory = aCategory;
+	params.iKey = aKey;
+	params.iDefine = aDefineIfNotSet;
+
+	return DoControl(EControlSetPropertyDesc, (TAny*)&params, (TAny*)&aValue);
+	}
+
+inline TInt RMemoryAccess::DeleteProperty(TUid aCategory, TUint aKey)
+	{
+	TProp params;
+	params.iCategory = aCategory;
+	params.iKey = aKey;
+	params.iDefine = EFalse;
+
+	return DoControl(EControlDeleteProperty, (TAny*)&params, NULL);
+	}
+
+inline void RMemoryAccess::NotifyPropertyChange(TPropNotifyResult& aResult, TRequestStatus& aStatus)
+	{
+	aStatus = KRequestPending;
+	TInt err = DoControl(EControlPropertyNotify, (TAny*)&aResult, (TAny*)&aStatus);
+	if (err)
+		{
+		TRequestStatus* ffs = &aStatus;
+		User::RequestComplete(ffs, err);
+		}
+	}
+
+inline void RMemoryAccess::CancelPropertyChange()
+	{
+	DoControl(EControlPropertyNotifyCancel, NULL, NULL);
+	}
+
+inline TInt RMemoryAccess::SubscribeToProperty(TUid aCategory, TUint aKey, TBool aOutputToBtrace)
+	{
+	TProp params;
+	params.iCategory = aCategory;
+	params.iKey = aKey;
+	params.iDefine = EFalse;
+	return DoControl(EControlSubscribeToProperty, (TAny*)&params, (TAny*)aOutputToBtrace);
+	}
+
+inline TInt RMemoryAccess::SetThreadPriority(RThread& aThread, TInt aPriority)
+	{
+	return DoControl(EControlSetThreadPriority, (TAny*)aThread.Handle(), (TAny*)aPriority);
+	}
+
+inline void RMemoryAccess::NotifyThreadCreation(TRequestStatus& aStatus)
+	{
+	aStatus = KRequestPending;
+	TRequestStatus* stat = &aStatus;
+	TInt err = DoControl(EControlNotifyThreadCreation, stat, NULL);
+	if (err) User::RequestComplete(stat, err);
+	}
+
+inline void RMemoryAccess::CancelNotifyThreadCreation()
+	{
+	DoControl(EControlCancelNotifyThreadCreation);
+	}
+
+inline TInt RMemoryAccess::SetPriorityOverride(TInt aPriority, const TDesC8& aMatchString)
+	{
+	return DoControl(EControlSetPriorityOverride, (TAny*)aPriority, (TAny*)&aMatchString);
+	}
+
+inline TInt RMemoryAccess::SetThreadCriticalFlags(RThread& aThread, TUint aFlags)
+	{
+	return DoControl(EControlSetCriticalFlags, (TAny*)aThread.Handle(), (TAny*)aFlags);
+	}
+
+inline TInt RMemoryAccess::RThreadForceOpen(RThread& aThread, TUint aId)
+	{
+	TInt handle = DoControl(EControlOpenThread, (TAny*)aId, NULL);
+	if (handle < 0) return handle; // error
+	aThread.SetHandle(handle);
+	return KErrNone;
+	}
+
+inline TLinAddr RMemoryAccess::InPlaceThreadRename(RThread& aThread, const TDesC8& aNewName)
+	{
+	return DoControl(EControlInPlaceThreadRename, (TAny*)aThread.Handle(), (TAny*)&aNewName);
+	}
+
+inline TInt RMemoryAccess::InPlaceObjectRename(TObjectType aObjectType, TUint8* aAddressOfKernelObject, const TDesC8& aNewName)
+	{
+	TObjectInfoByPtrParamsBuf params;
+	params().iObjectType = aObjectType;
+	params().iObjectPtr = aAddressOfKernelObject;
+	return DoControl(EControlInPlaceObjectRename, (TAny*)&params, (TAny*)&aNewName);
+	}
+
+inline TInt RMemoryAccess::InPlaceSetProcessFileName(RProcess& aProcess, const TDesC8& aNewName)
+	{
+	return DoControl(EControlInPlaceSetProcessFileName, (TAny*)aProcess.Handle(), (TAny*)&aNewName);
+	}
+
+inline TInt RMemoryAccess::EnableHeapTracing(TUint aThreadId, TBool aEnable)
+	{
+	return DoControl(EControlEnableHeapTracing, (TAny*)aThreadId, (TAny*)aEnable);
+	}
+
+inline TInt RMemoryAccess::DefragRam(TInt aPriority)
+	{
+	return DoControl(EControlDefragRam, (TAny*)aPriority, NULL);
+	}
+
+inline TInt RMemoryAccess::EmptyRamZone(TUint aZone, TInt aPriority)
+	{
+	return DoControl(EControlEmptyRamZone, (TAny*)aPriority, (TAny*)aZone);
+	}
+
+inline TInt RMemoryAccess::GetRamZoneInfo(TUint aZone, TDes8& aInfoPkg)
+	{
+	return DoControl(EControlGetRamZoneInfo, (TAny*)aZone, &aInfoPkg);
+	}
+
+inline TInt RMemoryAccess::SetProcessProperties(RProcess& aProcess, const TProcessProperties& aProperties)
+	{
+	const TPckgC<TProcessProperties> props(aProperties);
+	return DoControl(EControlSetProcessProperties, (TAny*)aProcess.Handle(), (TAny*)&props);
+	}
+
+inline TInt RMemoryAccess::WriteShadowMemory(TLinAddr aAddress, const TDesC8& aNewContents)
+	{
+	return DoControl(EControlWriteShadowMemory, (TAny*)aAddress, (TAny*)&aNewContents);
+	}
+
+inline TInt RMemoryAccess::FreeShadowMemory(TLinAddr aAddress, TInt aLen)
+	{
+	return DoControl(EControlFreeShadowMemory, (TAny*)aAddress, (TAny*)aLen);
+	}
+
+inline TInt RMemoryAccess::SetZombieDebugMode(TInt aMode)
+	{
+	return DoControl(EControlSetZombieDebugMode, (TAny*)aMode, NULL);
+	}
+
+inline TInt RMemoryAccess::GetZombieDebugMode()
+	{
+	return DoControl(EControlGetZombieDebugMode, NULL, NULL);
+	}
+
+inline TInt RMemoryAccess::WriteMem(TUint aThreadId, const TDesC8& aMem, TAny* aAddr)
+	{
+	TAny* args[3];
+	args[0] = (TAny*)aThreadId;
+	args[1] = (TAny*)&aMem;
+	args[2] = aAddr;
+	return DoControl(EControlWriteMem, &args[0], NULL);
+	}
+
+inline TInt RMemoryAccess::SetTextTraceMode(TUint& aMode, TUint aMask)
+	{
+	return DoControl(EControlSetTextTraceMode, (TAny*)&aMode, (TAny*)aMask);
+	}
+
+inline TInt RMemoryAccess::GetRegisters(RThread& aThread, TBool aUserMode, TDes8& aRegBuf, TUint32& aValid)
+	{
+	TUint32 args[4];
+	args[0] = aThread.Handle();
+	args[1] = aUserMode;
+	args[2] = (TUint32)&aRegBuf;
+	args[3] = (TUint32)&aValid;
+	return DoControl(EControlGetRegisters, (TAny*)&args[0], NULL);
+	}
+
+inline TInt RMemoryAccess::GetZombies(TDes8& aResultBuf)
+	{
+	return DoControl(EControlGetZombies, (TAny*)&aResultBuf, NULL);
+	}
+
+inline TInt RMemoryAccess::ReleaseZombie(RThread& aThread)
+	{
+	return DoControl(EControlReleaseZombie, (TAny*)aThread.Handle(), NULL);
+	}
+
+inline TInt RMemoryAccess::SuspendThread(RThread& aThread)
+	{
+	return DoControl(EControlSuspendThread, (TAny*)aThread.Handle(), NULL);
+	}
+
+inline void RMemoryAccess::NotifyBreakpoint(TPckg<TBreakpointNotification>& aPkg, TRequestStatus& aStatus)
+	{
+	TRequestStatus* stat = &aStatus;
+	TInt err = DoControl(EControlNotifyBreakpoint, &aPkg, stat);
+	if (err) User::RequestComplete(stat, err);
+	}
+
+inline void RMemoryAccess::CancelNotifyBreakpoint()
+	{
+	DoControl(EControlCancelNotifyBreakpoint, NULL, NULL);
+	}
+	
+inline TInt RMemoryAccess::SetBreakpoint(RThread& aThread, TLinAddr aAddress, RMemoryAccess::TPredicate* aCondition /*=NULL*/)
+	{
+	TUint32 args[2] = { aAddress, (TUint32)aCondition };
+	return DoControl(EControlSetBreakpoint, (TAny*)aThread.Handle(), (TAny*)&args[0]);
+	}
+
+inline TInt RMemoryAccess::SetSymbolicBreakpoint(RThread& aThread, const TDesC8& aCodeseg, TUint aOffset, RMemoryAccess::TPredicate* aCondition /*=NULL*/)
+	{
+	TUint32 args[3] = { aThread.Handle(), aOffset, (TUint32)aCondition };
+	return DoControl(EControlSetSymbolicBreakpoint, (TAny*)&args[0], (TAny*)&aCodeseg);
+	}
+
+inline TInt RMemoryAccess::SetBreakpointEnabled(TInt aBreakpointId, TBool aEnabled)
+	{
+	return DoControl(EControlSetBreakpointEnabled, (TAny*)aBreakpointId, (TAny*)aEnabled);
+	}
+
+inline TInt RMemoryAccess::ClearBreakpoint(TInt aBreakpointId)
+	{
+	return DoControl(EControlClearBreakpoint, (TAny*)aBreakpointId, NULL);
+	}
+
+inline TInt RMemoryAccess::ContinueFromBreakpoint(RThread& aThread)
+	{
+	return DoControl(EControlContinueFromBreakpoint, (TAny*)aThread.Handle());
+	}
+
+inline TInt RMemoryAccess::GetBreakpoints(TDes8& aBuf)
+	{
+	return DoControl(EControlGetBreakpoints, &aBuf);
+	}
+
+inline TInt RMemoryAccess::RegisterPersistantBreakpoint(TLinAddr aAddress)
+	{
+	// aAddress is implicitly in the current thread
+	return DoControl(EControlRegisterPersistantBreakpoint, (TAny*)aAddress, NULL);
+	}
+
+inline TInt RMemoryAccess::TPredicate::AddCondition(TOp aOperation, TInt aRegNum, TUint32 aValue)
+	{
+	if (aRegNum < 0 || aRegNum > 15) return KErrArgument;
+
+	TInt freeSlot = 0;
+	while (((iOp >> (freeSlot*8)) & 0xF) != ENothing)
+		{
+		freeSlot++;
+		if (freeSlot >= KNumSlots) return KErrOverflow;
+		}
+
+	TInt slotShift = freeSlot * 8;
+	TUint32 slotMask = 0xFF << slotShift;
+	iOp = (iOp & ~slotMask) | (aOperation << slotShift) | (aRegNum << (slotShift+4));
+	iVals[freeSlot] = aValue;
+	return KErrNone;
+	}
+
+inline void RMemoryAccess::TPredicate::Description(TDes& aBuf)
+	{
+	TInt origLen = aBuf.Length();
+	for (TInt slot = 0; slot < KNumSlots; slot++)
+		{
+		TInt slotShift = slot * 8;
+		TUint32 opAndReg = (iOp >> slotShift) & 0xFF;
+		TOp op = (TOp)(opAndReg & 0xF);
+		if (op == ENothing) break;
+		TInt reg = opAndReg >> 4;
+
+		aBuf.AppendFormat(_L("r%d"), reg);
+		switch(op)
+			{
+			case EEq:
+			case ESignedEq:
+				aBuf.Append(_L("==")); break;
+			case ENe:
+			case ESignedNe:
+				aBuf.Append(_L("!=")); break;
+			case ELt:
+			case ESignedLt:
+				aBuf.Append('<'); break;
+			case ELe:
+			case ESignedLe:
+				aBuf.Append(_L("<=")); break;
+			case EGt:
+			case ESignedGt:
+				aBuf.Append('>'); break;
+			case EGe:
+			case ESignedGe:
+				aBuf.Append(_L(">=")); break;
+			default:
+				break;
+			}
+		if (op >= ESignedEq)
+			{
+			aBuf.AppendFormat(_L("%d,"), (TInt)iVals[slot]);
+			}
+		else
+			{
+			aBuf.AppendFormat(_L("%uu,"), iVals[slot]);
+			}
+		}
+	if (aBuf.Length() > origLen) aBuf.SetLength(aBuf.Length() - 1); // Chomp final comma
+	}
+
+inline TInt RMemoryAccess::SetDebugPort(TInt aPort)
+	{
+	return DoControl(EControlSetDebugPort, (TAny*)aPort, NULL);
+	}
+
+inline TUint RMemoryAccess::GetThreadCreatorId(TUint aThreadId)
+	{
+	TUint result = 0;
+	/*TInt err =*/ DoControl(EControlGetCreatorThread, (TAny*)aThreadId, &result);
+	return result;
+	}
+
+#endif //__KERNEL_MODE__
+
+#endif //__MemoryAccess_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/memoryaccess/objectix.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,513 @@
+// objectix.cpp
+// 
+// Copyright (c) 1994 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+/** 
+@file
+@internalTechnology
+*/
+
+#include <kern_priv.h>
+#include "dobject.h"
+#define DObjectIx DObjectIxNinePointTwoHack // So that we're not redefining DObjectIx
+
+/**	Creates a new kernel object index.
+
+	@param	aPtr	Value to pass to Close() when objects are closed due to index deletion.
+
+	@return	The pointer to the new index, NULL if out of memory.
+
+    @pre    Calling thread must be in a critical section.
+    @pre    No fast mutex can be held.
+	@pre	Call in a thread context.
+ */
+DObjectIx *DObjectIx::New(TAny* aPtr)
+	{
+	return new DObjectIx(aPtr);
+	}
+
+#ifndef DOBJECT_TEST_CODE
+void DObjectIx::Wait()
+	{
+	Kern::MutexWait(*HandleMutex);
+	}
+
+void DObjectIx::Signal()
+	{
+	Kern::MutexSignal(*HandleMutex);
+	}
+#endif
+
+
+/**	Construct a kernel object index
+ */
+DObjectIx::DObjectIx(TAny *aPtr)
+	: iNextInstance(1), iPtr(aPtr), iFree(-1)
+	{
+	}
+
+
+/**	Destroys a kernel object index.
+
+	Any objects in the index are closed. The iPtr member of the index is passed
+	as the parameter to Close() for each object.
+
+    @pre    Calling thread must be in a critical section.
+    @pre    No fast mutex can be held.
+	@pre	Call in a thread context.
+ */
+DObjectIx::~DObjectIx()
+	{
+	// We have to be very careful here. Calling Close() on the objects in the array
+	// may result in other entries being removed from the array before we delete
+	// them here, and may result in the array being ReAlloc()ed, corrupting the removed
+	// entries, hence we must check the iCount value each time round the loop.	
+	TInt i=-1;
+	while(++i<iCount)
+		{
+		SDObjectIxRec* pS=iObjects+i;
+		DObject *pO=pS->obj;
+		if (pO)
+			{
+			--iActiveCount;
+			pS->obj=NULL;	// invalidate entry after closing it
+			pO->Close(iPtr);
+			}
+		}
+	SDObjectIxRec* pR=iObjects;
+	iObjects=NULL;
+	delete pR;
+	}
+
+
+/**	Adds a kernel object to an index and return a handle.
+
+	@param	aObj	Pointer to the object to add
+	@param	aHandle	Place to write returned handle to
+	
+	@return	KErrNone, if operation successful;
+	        KErrNoMemory, if there was insufficient memory to expand the array.
+
+    @pre    Calling thread must be in a critical section.
+    @pre    No fast mutex can be held.
+	@pre	Call in a thread context.
+	@pre	DObject::HandleMutex held
+ */
+TInt DObjectIx::Add(DObject* anObj, TInt& aHandle)
+	{
+	//Check preconditions(debug build only)
+	__ASSERT_CRITICAL;
+	__ASSERT_NO_FAST_MUTEX;
+
+	TInt index=iFree; //iFree contains the index of the first empty slot or -1 if there is no such.
+	if (index<0) //Check if the free list is empty
+		{
+		// The free list is empty, so more slots must be allocated.
+		if (iCount==KObjectIxMaxHandles)
+ 			return KErrNoMemory;
+		
+		//Those are internal checking of the object consistency
+		__ASSERT_DEBUG(iAllocated==iCount,Panic(EObjInconsistent));
+		__ASSERT_DEBUG(iAllocated==iActiveCount,Panic(EObjInconsistent));
+		
+		//Double allocated memory
+		TInt newAlloc=iAllocated ? 2*iAllocated : KObjectIxGranularity;
+		if(newAlloc>KObjectIxMaxHandles)
+ 			newAlloc=KObjectIxMaxHandles;
+		TInt r=Kern::SafeReAlloc((TAny*&)iObjects,iAllocated*sizeof(SDObjectIxRec),newAlloc*sizeof(SDObjectIxRec));
+		if (r)
+			return r;
+		//NOTE: There is no need to initialize newly allocated memory (e.g. to zero iObjects) as it all goes
+		//beyond iCount and will be not considered when search in At(...) or operator[]() methods. 
+		//As the free list is initially ordered, each slot goes through the states as follows:
+		// - Created as the part of the free list beyond iCount. - uninitialized and not searched in any method.
+		// - In use  - initialized.
+		// - The part of the free list within iCount - initialized to zero.
+		//Also bear in mind that UpdateState() does not reorder free list beyond iCount but keeps it preserverd.
+
+		iAllocated=newAlloc;		   //Update the number of allocated slots
+		iUpdateDisabled = iAllocated/2;//The number of Remove() calls before the object update(free list,iCount,..)
+
+		//Connect all newly allocated slots into the list and set 'index' to point to the first one.
+		SDObjectIxRec* pA = (SDObjectIxRec*)iObjects;
+		index=newAlloc-1;
+		pA[index].nextEmpty = -1;
+		while (iCount <= --index) 
+			pA[index].nextEmpty=index+1;
+		index++;
+		}
+
+	//At this point, 'index' variable points to the slot that will be used for the new entry.
+	//It also represents the first element in the list of empty slots.
+
+	SDObjectIxRec *pS=iObjects+index; // pS points to the object that will be used for the new entry.
+	iFree=pS->nextEmpty;			  // Update iFree to point to the next empty slot. 
+	
+	NKern::LockSystem();
+
+	//Initialize data of the new element of the array.
+	pS->obj=anObj;
+	pS->str.uniqueID=(TUint16)anObj->UniqueID();
+	pS->str.instance=(TUint16)instanceLimit(iNextInstance);
+	
+	iNextInstance++;
+	
+	if (index>=iCount)	//Update iCount to points to the slot after the last in use.
+		iCount=index+1;
+	
+	++iActiveCount;
+
+	NKern::UnlockSystem();
+
+	//Internal checking of the object consistency
+	__ASSERT_DEBUG( (iFree==-1 && iAllocated==iCount && iAllocated==iActiveCount)
+				  ||(iFree!=-1 && iAllocated>iActiveCount),Panic(EObjInconsistent));
+	
+	aHandle=makeHandle(index,pS->str.instance);
+	return KErrNone;
+  }
+
+
+/**	Removes a kernel object from an index by handle.
+
+	Returns a pointer to the object removed and the parameter to pass to Close().
+
+	@param	aHandle	Handle to object to be removed.
+	@param	aObj	Place to write pointer to the object to add.
+	@param	aPtr	Place to write parameter to be passed to Close().
+	
+	@return	KErrNone, if operation successful;
+	        KErrBadHandle, if the supplied handle was invalid.
+
+    @pre    Calling thread must be in a critical section.
+    @pre    No fast mutex can be held.
+	@pre	Call in a thread context.
+	@pre	DObject::HandleMutex held.
+ */
+TInt DObjectIx::Remove(TInt aHandle, DObject*& aObj, TAny*& aPtr)
+	{
+	//Check preconditions(debug build only)
+	__ASSERT_CRITICAL;
+	__ASSERT_NO_FAST_MUTEX;
+
+	TInt i=index(aHandle);
+	
+	if (i >= iCount)
+		return KErrBadHandle;
+
+	SDObjectIxRec* pR=iObjects+i;
+	DObject *pO=pR->obj;
+	if (!pO || pR->str.instance!=instance(aHandle) || pR->str.uniqueID!=pO->UniqueID())
+		return KErrBadHandle;
+
+	NKern::LockSystem();
+	pR->obj=NULL;
+	--iActiveCount;
+	NKern::UnlockSystem();
+	
+	if(iActiveCount)
+		{	
+		// Add the entry onto the free list
+		pR->nextEmpty=iFree;
+		iFree=i;
+
+		if(iUpdateDisabled) 
+			iUpdateDisabled--; //Count down till state update is enabled again.
+
+		if (									 //Update the states(HWM, resort free list & memory shrink) if:
+			(!iUpdateDisabled) &&				 //There were a number of Remove() calls since the last ReAlloc
+			(iAllocated>=2*KObjectIxGranularity))//Allocated memory is above the limit.
+			{
+			UpdateState();
+			iUpdateDisabled = iAllocated/2;//The number of Remove() calls before the next update comes.
+			}
+		}
+	else
+		{
+		//There is no any CObject left. Reset the object to initial state (except iNextInstance)
+		delete iObjects;
+		iObjects=NULL;
+		iAllocated=0;
+		iCount=0;
+		iFree=-1;		  //Empty free list
+		}
+
+	//This is internal checking of the object consistency
+	__ASSERT_DEBUG( (iFree==-1 && iAllocated==iCount && iAllocated==iActiveCount)
+				  ||(iFree!=-1 && iAllocated>iActiveCount),Panic(EObjInconsistent));
+	
+	aObj=pO;
+	aPtr=iPtr;
+	return KErrNone;
+  }
+
+
+// Private method which:
+//1. Reorders free list.
+//2. Updates iCount. This is the only place where HWM is decreased, while it can be increased during AddL().
+//3. Shrinks the heap memory (pointed by iObjects) if it can be at least halved.
+//The function is entered with at least one occupied slot in iObjects array.
+//The array is searched from its end. Special care is given to the  case where
+//iCount is less then KObjectIxGranularity as the size of the arrey does not go below it.
+//Note: HighWaterMark (HWM) is a term used for iCount.
+void DObjectIx::UpdateState()
+	{
+	TBool toShrink = EFalse;
+	TBool foundFreeBelowLimit = EFalse;//Used to handle spacial case when HWM is below the minimum alloc. limit
+	TInt newHWM = 0;
+
+	//Start from the HWM as all slots beyond are free and sorted already.
+	TInt current = iCount;
+	TInt prevFreeSlot = iCount == iAllocated ? -1 : iCount;
+	while (--current>=0)
+		{
+		if (iObjects[current].obj)
+			{
+			//This is the slot with the valid entry. Check if this is the last in the array.
+			if(!newHWM)
+				{
+				//This is the first occupied slot we found => It is new HWM.
+				newHWM=current+1;
+				if (current < iAllocated/2)
+					{
+					//At this point we decide to shrink memory.
+					toShrink = ETrue;
+					//Once we find HWM and decide to shrink, all slots after that point should be removed
+					//from the free list as that memory will be freed. The exception is the case when HWM is below
+					//the minimum of allocated memory (8 slots as the moment).
+					if((current >= KObjectIxGranularity) || (!foundFreeBelowLimit))
+						prevFreeSlot = -1; //The next free slot to find will be the last one in the list.
+					}
+				}
+			}
+		else
+			{
+			//This is the free slot.
+			if ((!newHWM) && (!foundFreeBelowLimit) &&(current<KObjectIxGranularity))
+				{
+				//The special case. 
+				//We just reached the first free slot below minimum alloc. size and still we found no occupied slots.
+				iObjects[current].nextEmpty = -1; //This will be the end of free list.
+				foundFreeBelowLimit = ETrue; //Mark that we found the special case
+				}
+			else
+				{
+				iObjects[current].nextEmpty = prevFreeSlot;//Link the empty slot in the free list.
+				}
+			prevFreeSlot = current;
+			}
+		}
+
+	iCount = newHWM;
+	iFree = prevFreeSlot;
+
+	if (toShrink)
+		{
+		//Do not reallocate less then the initial value.
+		TInt newAlloc = Max(newHWM,KObjectIxGranularity);
+		//Update member data and re-allocate memory. ReAlloc cannot return NULL as we are asking for less memory.
+		Kern::SafeReAlloc((TAny*&)iObjects,iAllocated*sizeof(SDObjectIxRec),newAlloc*sizeof(SDObjectIxRec));
+		iAllocated = newAlloc;
+		}
+	}
+
+
+/** Counts the number of times an object appears in this index.
+
+	@param	aObject	Object whose occurrences are to be counted.
+
+	@return	Number of times aObject appears in the index.
+
+    @pre    Calling thread must be in a critical section.
+    @pre    No fast mutex can be held.
+	@pre	Call in a thread context.
+	@pre	DObject::HandleMutex held
+ */
+TInt DObjectIx::Count(DObject* aObject)
+	{
+	//Check preconditions(debug build only)
+	__ASSERT_CRITICAL;
+	__ASSERT_NO_FAST_MUTEX;
+
+	TInt c=0;
+	if (iCount)
+		{
+		SDObjectIxRec* pS=iObjects;
+		SDObjectIxRec* pE=pS+iCount;
+		do
+			{
+			if (pS->obj==aObject)
+				c++;
+			} while (++pS<pE);
+		}
+	return c;
+	}
+
+
+#ifndef __DOBJECT_MACHINE_CODED__
+/**	Looks up an object in the index by handle.
+	
+	The object must be of a specified type (specified by container ID)
+
+	@param	aHandle		Handle to look up.
+	@param	aUniqueID	Unique ID (container ID) that object should have.
+	
+	@return	Pointer to object or NULL if handle invalid.
+
+	@pre	Call in a thread context.
+	@pre    System lock must be held.
+ */
+DObject* DObjectIx::At(TInt aHandle, TInt aUniqueID)
+	{
+	__ASSERT_SYSTEM_LOCK; //Check preconditions (debug build only)
+	TInt i=index(aHandle);
+	if (i>=iCount)
+		return(NULL);
+	SDObjectIxRec *pS=iObjects+i;
+	if (pS->str.instance!=instance(aHandle) || pS->str.uniqueID!=aUniqueID)
+		return(NULL);
+	return(pS->obj);
+	}
+
+
+/**	Looks up an object in the index by handle.
+
+	The object may be of any type.
+
+	@param	aHandle		Handle to look up.
+	
+	@return	Pointer to object or NULL if handle invalid.
+
+	@pre	Call in a thread context.
+	@pre    System lock must be held.
+ */
+DObject* DObjectIx::At(TInt aHandle)
+	{
+	__ASSERT_SYSTEM_LOCK; //Check preconditions (debug build only)
+	TInt i=index(aHandle);
+	if (i>=iCount)
+		return NULL;
+	SDObjectIxRec *pS=iObjects+i;
+	if (pS->str.instance!=instance(aHandle))
+		return NULL;
+	return pS->obj;
+	}
+#endif
+
+
+/**	Looks up an object in the index by object pointer.
+
+	Returns a handle to the object.
+
+	@param	aObj	Pointer to the object to look up.
+	
+	@return	Handle to object (always >0);
+	        KErrNotFound, if object not present in index.
+
+    @pre    Calling thread must be in a critical section.
+    @pre    No fast mutex can be held.
+	@pre	Call in a thread context.
+	@pre	DObject::HandleMutex held.
+ */
+TInt DObjectIx::At(DObject* aObj)
+	{
+	//Check preconditions(debug build only)
+	__ASSERT_CRITICAL;
+	__ASSERT_NO_FAST_MUTEX;
+
+	if (iCount)
+		{
+		SDObjectIxRec* pS=iObjects;
+		SDObjectIxRec* pE=pS+iCount;
+		TInt i=0;
+		while(pS<pE && pS->obj!=aObj)
+			pS++, i++;
+		if (pS<pE)
+			return(makeHandle(i,pS->str.instance));
+		}
+	return KErrNotFound;
+	}
+
+
+#ifndef __DOBJECT_MACHINE_CODED__
+/** Finds the object at a specific position in the index array.
+
+	@param	aIndex	Index into array.
+	
+	@return	Pointer to the object at that position (could be NULL).
+
+	@pre	Call in a thread context. 
+    @pre    System lock must be held.
+ */
+DObject* DObjectIx::operator[](TInt aIndex)
+	{
+	__ASSERT_SYSTEM_LOCK; //Check preconditions (debug build only)
+	__ASSERT_ALWAYS(aIndex>=0 && aIndex<iCount,Panic(EArrayIndexOutOfRange));
+	return iObjects[aIndex].obj;
+	}
+#else
+GLDEF_C void PanicDObjectIxIndexOutOfRange(void)
+	{
+	Panic(EArrayIndexOutOfRange);
+	}
+#endif
+
+TInt DObjectIx::LastHandle()
+//
+// Return the last valid handle
+// Must wait on HandleMutex before calling this.
+//
+	{
+	//Check preconditions(debug build only)
+	__ASSERT_CRITICAL;
+	__ASSERT_NO_FAST_MUTEX;
+
+	if (iActiveCount)
+		{
+		SDObjectIxRec* p=iObjects+iCount;
+		while(--p>=iObjects && !p->obj) {}
+		return makeHandle(p-iObjects,p->str.instance);
+		}
+	return 0;
+	}
+
+//
+// Include these in exactly one CPP file somewhere
+//
+
+extern TBool gRunningWithOldDefinition = ETrue;
+
+NONSHARABLE_CLASS(DObjectWithPaddingOnly) : public DObject
+	{
+public:
+	DOBJECT_PADDING;
+	};
+
+TBool CalculateDObjectSize()
+	{
+	DObjectWithPaddingOnly* obj = new DObjectWithPaddingOnly;
+	if (!obj) return EFalse;
+	
+	// objectId points to the mem location where iObjectId will be. So if running on a system with the new size DOBject it will always be non-zero (because objectIds are set in the DObject constructor, and are always non-zero), but if running on earlier systems it will be zero because DBase zero-fills the object
+	TUint64& objectId = *reinterpret_cast<TUint64*>((TUint8*)&obj->iName + sizeof(HBuf*));
+	
+	if (objectId != 0)
+		{
+		//Kern::Printf("Detected MemoryAccess is running with new larger DObject");
+		gRunningWithOldDefinition = EFalse;
+		}
+	else
+		{
+		//Kern::Printf("Detected MemoryAccess is running with old-format DObject");		
+		}
+	obj->Close(NULL);
+	return ETrue;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/BMARM/LoggingAllocatorU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	Install__17RLoggingAllocator @ 1 NONAME R3UNUSED ; RLoggingAllocator::Install(void)
+	Uninstall__17RLoggingAllocator @ 2 NONAME R3UNUSED ; RLoggingAllocator::Uninstall(void)
+	Install__17RLoggingAllocatorUi @ 3 NONAME R3UNUSED ; RLoggingAllocator::Install(unsigned int)
+	New__17RLoggingAllocatorUiP10RAllocatorRP17RLoggingAllocator @ 4 NONAME R3UNUSED ; RLoggingAllocator::New(unsigned int, RAllocator *, RLoggingAllocator *&)
+	StaticTraceAlloc__17RLoggingAllocatorP10RAllocatorPvi @ 5 NONAME R3UNUSED ; RLoggingAllocator::StaticTraceAlloc(RAllocator *, void *, int)
+	StaticTraceFree__17RLoggingAllocatorP10RAllocatorPv @ 6 NONAME R3UNUSED ; RLoggingAllocator::StaticTraceFree(RAllocator *, void *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/BMARM/QR3U.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+EXPORTS
+	__10RProxyHeapR13RMemoryAccessUi @ 1 NONAME R3UNUSED ; RProxyHeap::RProxyHeap(RMemoryAccess &, unsigned int)
+	AddCaptureL__12CKeyCapturerP17MCaptureInterfaceiiii @ 2 NONAME ; CKeyCapturer::AddCaptureL(MCaptureInterface *, int, int, int, int)
+	AddLongCaptureL__12CKeyCapturerP17MCaptureInterfaceiii @ 3 NONAME ; CKeyCapturer::AddLongCaptureL(MCaptureInterface *, int, int, int)
+	AddLongCaptureL__12CKeyCapturerP17MCaptureInterfaceiiii @ 4 NONAME ; CKeyCapturer::AddLongCaptureL(MCaptureInterface *, int, int, int, int)
+	ChangeProperty__16CPropertyManagerUiUi @ 5 NONAME R3UNUSED ; CPropertyManager::ChangeProperty(unsigned int, unsigned int)
+	Count__C17CKernelObjectList @ 6 NONAME R3UNUSED ; CKernelObjectList::Count(void) const
+	DeleteCapturer__12CKeyCapturer @ 7 NONAME R3UNUSED ; CKeyCapturer::DeleteCapturer(void)
+	DumpAllInfoL__17CKernelObjectListR8RClogger @ 8 NONAME R3UNUSED ; CKernelObjectList::DumpAllInfoL(RClogger &)
+	DumpHeapL__10RProxyHeapR5RFile @ 9 NONAME R3UNUSED ; RProxyHeap::DumpHeapL(RFile &)
+	DumpHeapToFileL__10RProxyHeapRC7TDesC16 @ 10 NONAME R3UNUSED ; RProxyHeap::DumpHeapToFileL(TDesC16 const &)
+	DumpHeapToSuitableFileInDirectoryL__10RProxyHeapRt4TBuf1i256 @ 11 NONAME R3UNUSED ; RProxyHeap::DumpHeapToSuitableFileInDirectoryL(TBuf<256> &)
+	GetCapturerL__12CKeyCapturer @ 12 NONAME R3UNUSED ; CKeyCapturer::GetCapturerL(void)
+	GetHeapDetailsL__10RProxyHeapR12THeapDetails @ 13 NONAME R3UNUSED ; RProxyHeap::GetHeapDetailsL(THeapDetails &)
+	GetHeapDetailsL__FR12THeapDetailsR10RProxyHeap @ 14 NONAME R3UNUSED ; GetHeapDetailsL(THeapDetails &, RProxyHeap &)
+	GetInfoByIdL__17CKernelObjectListiiR6RBuf16T3 @ 15 NONAME ; CKernelObjectList::GetInfoByIdL(int, int, RBuf16 &, RBuf16 &)
+	GetInfoByIndexL__17CKernelObjectListiiR6RBuf16T3 @ 16 NONAME ; CKernelObjectList::GetInfoByIndexL(int, int, RBuf16 &, RBuf16 &)
+	GetInfoL__17CKernelObjectListiR6RBuf16T2 @ 17 NONAME ; CKernelObjectList::GetInfoL(int, RBuf16 &, RBuf16 &)
+	GetQikListBoxModel__17CKernelObjectList @ 18 NONAME R3UNUSED ; CKernelObjectList::GetQikListBoxModel(void)
+	GetScanCodeOfLastEvent__12CKeyCapturer @ 19 NONAME R3UNUSED ; CKeyCapturer::GetScanCodeOfLastEvent(void)
+	GetValueL__16CPropertyManager @ 20 NONAME R3UNUSED ; CPropertyManager::GetValueL(void)
+	GetVerboseInfoL__17CKernelObjectListiR6RBuf16T2 @ 21 NONAME ; CKernelObjectList::GetVerboseInfoL(int, RBuf16 &, RBuf16 &)
+	IsCaptured__12CKeyCaptureri @ 22 NONAME R3UNUSED ; CKeyCapturer::IsCaptured(int)
+	IsCaptured__12CKeyCaptureriRi @ 23 NONAME R3UNUSED ; CKeyCapturer::IsCaptured(int, int &)
+	NewL__16CPropertyManagerG9TCallBack @ 24 NONAME ; CPropertyManager::NewL(TCallBack)
+	NewL__17CKernelObjectListP13RMemoryAccess @ 25 NONAME R3UNUSED ; CKernelObjectList::NewL(RMemoryAccess *)
+	PopCapturesL__12CKeyCapturer @ 26 NONAME R3UNUSED ; CKeyCapturer::PopCapturesL(void)
+	PushCurrentCapturesL__12CKeyCapturer @ 27 NONAME R3UNUSED ; CKeyCapturer::PushCurrentCapturesL(void)
+	ReadCell__10RProxyHeapPQ25RHeap5SCellT1 @ 28 NONAME R3UNUSED ABSENT ; RProxyHeap::ReadCell(RHeap::SCell *, RHeap::SCell *)
+	RefreshDataL__17CKernelObjectListi @ 29 NONAME R3UNUSED ; CKernelObjectList::RefreshDataL(int)
+	RemoveCapture__12CKeyCapturerP17MCaptureInterfacei @ 30 NONAME R3UNUSED ; CKeyCapturer::RemoveCapture(MCaptureInterface *, int)
+	SetCurrentType__17CKernelObjectList17TKernelObjectType @ 31 NONAME R3UNUSED ; CKernelObjectList::SetCurrentType(TKernelObjectType)
+	SetInfoChangedCallback__17CKernelObjectListiRC9TCallBack @ 32 NONAME R3UNUSED ; CKernelObjectList::SetInfoChangedCallback(int, TCallBack const &)
+	SetPropertyFromStringL__16CPropertyManagerRC7TDesC16 @ 33 NONAME R3UNUSED ; CPropertyManager::SetPropertyFromStringL(TDesC16 const &)
+	StartNotifierProxyThreadFunction__FPv @ 34 NONAME R3UNUSED ; StartNotifierProxyThreadFunction(void *)
+	Walk__10RProxyHeapRiT1 @ 35 NONAME R3UNUSED ABSENT ; RProxyHeap::Walk(int &, int &)
+	AddCaptureL__12CKeyCapturerP17MCaptureInterfaceii @ 36 NONAME ; CKeyCapturer::AddCaptureL(MCaptureInterface *, int, int)
+	ExeNameForSid__FUiR6RBuf16 @ 37 NONAME R3UNUSED ; ExeNameForSid(unsigned int, RBuf16 &)
+	ProxyWalk__10RProxyHeapPvQ25RHeap9TCellTypeT1i @ 38 NONAME ABSENT ; RProxyHeap::ProxyWalk(void *, RHeap::TCellType, void *, int)
+	NotifierProxyIsRunning__Fv @ 39 NONAME R3UNUSED ; NotifierProxyIsRunning(void)
+	ShutdownProxyNotifier__Fv @ 40 NONAME R3UNUSED ; ShutdownProxyNotifier(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/bwins/LoggingAllocatorU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	?Install@RLoggingAllocator@@SAHXZ @ 1 NONAME ; int RLoggingAllocator::Install(void)
+	?Uninstall@RLoggingAllocator@@SAHXZ @ 2 NONAME ; int RLoggingAllocator::Uninstall(void)
+	?StaticTraceAlloc@RLoggingAllocator@@SAXPAVRAllocator@@PAXH@Z @ 3 NONAME ; void RLoggingAllocator::StaticTraceAlloc(class RAllocator *, void *, int)
+	?StaticTraceFree@RLoggingAllocator@@SAXPAVRAllocator@@PAX@Z @ 4 NONAME ; void RLoggingAllocator::StaticTraceFree(class RAllocator *, void *)
+	?Install@RLoggingAllocator@@SAHI@Z @ 5 NONAME ; int RLoggingAllocator::Install(unsigned int)
+	?New@RLoggingAllocator@@SAHIPAVRAllocator@@AAPAV1@@Z @ 6 NONAME ; int RLoggingAllocator::New(unsigned int, class RAllocator *, class RLoggingAllocator * &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/bwins/QR3U.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+EXPORTS
+	??0RProxyHeap@@QAE@AAVRMemoryAccess@@I@Z @ 1 NONAME ; RProxyHeap::RProxyHeap(class RMemoryAccess &, unsigned int)
+	?GetHeapDetailsL@@YAXAAVTHeapDetails@@AAVRProxyHeap@@@Z @ 2 NONAME ; void GetHeapDetailsL(class THeapDetails &, class RProxyHeap &)
+	?ReadCell@RProxyHeap@@QAEXPAUSCell@RHeap@@0@Z @ 3 NONAME ABSENT ; void RProxyHeap::ReadCell(struct RHeap::SCell *, struct RHeap::SCell *)
+	?Walk@RProxyHeap@@QAEXAAH0@Z @ 4 NONAME ABSENT; void RProxyHeap::Walk(int &, int &)
+	?ChangeProperty@CPropertyManager@@QAEHII@Z @ 5 NONAME ; int CPropertyManager::ChangeProperty(unsigned int, unsigned int)
+	?GetValueL@CPropertyManager@@QAEPAVHBufC16@@XZ @ 6 NONAME ; class HBufC16 * CPropertyManager::GetValueL(void)
+	?NewL@CPropertyManager@@SAPAV1@VTCallBack@@@Z @ 7 NONAME ; class CPropertyManager * CPropertyManager::NewL(class TCallBack)
+	?SetPropertyFromStringL@CPropertyManager@@QAEXABVTDesC16@@@Z @ 8 NONAME ; void CPropertyManager::SetPropertyFromStringL(class TDesC16 const &)
+	?AddCaptureL@CKeyCapturer@@QAEXPAVMCaptureInterface@@HH@Z @ 9 NONAME ; void CKeyCapturer::AddCaptureL(class MCaptureInterface *, int, int)
+	?DeleteCapturer@CKeyCapturer@@SAXXZ @ 10 NONAME ; void CKeyCapturer::DeleteCapturer(void)
+	?GetCapturerL@CKeyCapturer@@SAPAV1@XZ @ 11 NONAME ; class CKeyCapturer * CKeyCapturer::GetCapturerL(void)
+	?IsCaptured@CKeyCapturer@@QAEHH@Z @ 12 NONAME ; int CKeyCapturer::IsCaptured(int)
+	?PopCapturesL@CKeyCapturer@@QAEXXZ @ 13 NONAME ; void CKeyCapturer::PopCapturesL(void)
+	?PushCurrentCapturesL@CKeyCapturer@@QAEXXZ @ 14 NONAME ; void CKeyCapturer::PushCurrentCapturesL(void)
+	?RemoveCapture@CKeyCapturer@@QAEXPAVMCaptureInterface@@H@Z @ 15 NONAME ; void CKeyCapturer::RemoveCapture(class MCaptureInterface *, int)
+	?AddLongCaptureL@CKeyCapturer@@QAEXPAVMCaptureInterface@@HHH@Z @ 16 NONAME ; void CKeyCapturer::AddLongCaptureL(class MCaptureInterface *, int, int, int)
+	?GetScanCodeOfLastEvent@CKeyCapturer@@QAEHXZ @ 17 NONAME ; int CKeyCapturer::GetScanCodeOfLastEvent(void)
+	?DumpHeapL@RProxyHeap@@QAEXAAVRFile@@@Z @ 18 NONAME ; void RProxyHeap::DumpHeapL(class RFile &)
+	?DumpHeapToFileL@RProxyHeap@@QAEXABVTDesC16@@@Z @ 19 NONAME ; void RProxyHeap::DumpHeapToFileL(class TDesC16 const &)
+	?DumpHeapToSuitableFileInDirectoryL@RProxyHeap@@QAEXAAV?$TBuf@$0BAA@@@@Z @ 20 NONAME ; void RProxyHeap::DumpHeapToSuitableFileInDirectoryL(class TBuf<256> &)
+	?GetHeapDetailsL@RProxyHeap@@QAEXAAVTHeapDetails@@@Z @ 21 NONAME ; void RProxyHeap::GetHeapDetailsL(class THeapDetails &)
+	?Count@CKernelObjectList@@QBEHXZ @ 22 NONAME ; int CKernelObjectList::Count(void) const
+	?DumpAllInfoL@CKernelObjectList@@QAEXAAVRClogger@@@Z @ 23 NONAME ; void CKernelObjectList::DumpAllInfoL(class RClogger &)
+	?GetInfoL@CKernelObjectList@@QAEXHAAVRBuf16@@0@Z @ 24 NONAME ; void CKernelObjectList::GetInfoL(int, class RBuf16 &, class RBuf16 &)
+	?GetQikListBoxModel@CKernelObjectList@@QAEPAVMQikListBoxModel@@XZ @ 25 NONAME ; class MQikListBoxModel * CKernelObjectList::GetQikListBoxModel(void)
+	?GetVerboseInfoL@CKernelObjectList@@QAEXHAAVRBuf16@@0@Z @ 26 NONAME ; void CKernelObjectList::GetVerboseInfoL(int, class RBuf16 &, class RBuf16 &)
+	?NewL@CKernelObjectList@@SAPAV1@PAVRMemoryAccess@@@Z @ 27 NONAME ; class CKernelObjectList * CKernelObjectList::NewL(class RMemoryAccess *)
+	?RefreshDataL@CKernelObjectList@@QAEXH@Z @ 28 NONAME ; void CKernelObjectList::RefreshDataL(int)
+	?SetCurrentType@CKernelObjectList@@QAEXW4TKernelObjectType@@@Z @ 29 NONAME ; void CKernelObjectList::SetCurrentType(enum TKernelObjectType)
+	?SetInfoChangedCallback@CKernelObjectList@@QAEXHABVTCallBack@@@Z @ 30 NONAME ; void CKernelObjectList::SetInfoChangedCallback(int, class TCallBack const &)
+	?GetInfoByIdL@CKernelObjectList@@QAEXHHAAVRBuf16@@0@Z @ 31 NONAME ; void CKernelObjectList::GetInfoByIdL(int, int, class RBuf16 &, class RBuf16 &)
+	?AddCaptureL@CKeyCapturer@@QAEXPAVMCaptureInterface@@HHHH@Z @ 32 NONAME ; void CKeyCapturer::AddCaptureL(class MCaptureInterface *, int, int, int, int)
+	?AddLongCaptureL@CKeyCapturer@@QAEXPAVMCaptureInterface@@HHHH@Z @ 33 NONAME ; void CKeyCapturer::AddLongCaptureL(class MCaptureInterface *, int, int, int, int)
+	?IsCaptured@CKeyCapturer@@QAEHHAAH@Z @ 34 NONAME ; int CKeyCapturer::IsCaptured(int, int &)
+	?GetInfoByIndexL@CKernelObjectList@@QAEHHHAAVRBuf16@@0@Z @ 35 NONAME ; int CKernelObjectList::GetInfoByIndexL(int, int, class RBuf16 &, class RBuf16 &)
+	?NotifierProxyIsRunning@@YAHXZ @ 36 NONAME ; int NotifierProxyIsRunning(void)
+	?ShutdownProxyNotifier@@YAHXZ @ 37 NONAME ; int ShutdownProxyNotifier(void)
+	?StartNotifierProxyThreadFunction@@YAHPAX@Z @ 38 NONAME ; int StartNotifierProxyThreadFunction(void *)
+	?ExeNameForSid@@YAHIAAVRBuf16@@@Z @ 39 NONAME ; int ExeNameForSid(unsigned int, class RBuf16 &)
+	?ProxyWalk@RProxyHeap@@QAEXPAXW4TCellType@RHeap@@0H@Z @ 40 NONAME ABSENT ; void RProxyHeap::ProxyWalk(void *, enum RHeap::TCellType, void *, int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/eabi/LoggingAllocatorU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	_ZN17RLoggingAllocator7InstallEv @ 1 NONAME
+	_ZN17RLoggingAllocator9UninstallEv @ 2 NONAME
+	_ZN17RLoggingAllocator15StaticTraceFreeEP10RAllocatorPv @ 3 NONAME
+	_ZN17RLoggingAllocator16StaticTraceAllocEP10RAllocatorPvi @ 4 NONAME
+	_ZN17RLoggingAllocator7InstallEj @ 5 NONAME
+	_ZN17RLoggingAllocator3NewEjP10RAllocatorRPS_ @ 6 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/eabi/QR3U.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,43 @@
+EXPORTS
+	_Z15GetHeapDetailsLR12THeapDetailsR10RProxyHeap @ 1 NONAME
+	_ZN10RProxyHeap4WalkERiS0_ @ 2 NONAME ABSENT
+	_ZN10RProxyHeap8ReadCellEPN5RHeap5SCellES2_ @ 3 NONAME ABSENT
+	_ZN10RProxyHeapC1ER13RMemoryAccessj @ 4 NONAME
+	_ZN10RProxyHeapC2ER13RMemoryAccessj @ 5 NONAME
+	_ZN16CPropertyManager14ChangePropertyEjj @ 6 NONAME
+	_ZN16CPropertyManager22SetPropertyFromStringLERK7TDesC16 @ 7 NONAME
+	_ZN16CPropertyManager4NewLE9TCallBack @ 8 NONAME
+	_ZN16CPropertyManager9GetValueLEv @ 9 NONAME
+	_ZN12CKeyCapturer10IsCapturedEi @ 10 NONAME
+	_ZN12CKeyCapturer11AddCaptureLEP17MCaptureInterfaceii @ 11 NONAME
+	_ZN12CKeyCapturer12GetCapturerLEv @ 12 NONAME
+	_ZN12CKeyCapturer12PopCapturesLEv @ 13 NONAME
+	_ZN12CKeyCapturer13RemoveCaptureEP17MCaptureInterfacei @ 14 NONAME
+	_ZN12CKeyCapturer14DeleteCapturerEv @ 15 NONAME
+	_ZN12CKeyCapturer20PushCurrentCapturesLEv @ 16 NONAME
+	_ZN12CKeyCapturer15AddLongCaptureLEP17MCaptureInterfaceiii @ 17 NONAME
+	_ZN12CKeyCapturer22GetScanCodeOfLastEventEv @ 18 NONAME
+	_ZN10RProxyHeap15DumpHeapToFileLERK7TDesC16 @ 19 NONAME
+	_ZN10RProxyHeap15GetHeapDetailsLER12THeapDetails @ 20 NONAME
+	_ZN10RProxyHeap34DumpHeapToSuitableFileInDirectoryLER4TBufILi256EE @ 21 NONAME
+	_ZN10RProxyHeap9DumpHeapLER5RFile @ 22 NONAME
+	_ZN17CKernelObjectList12DumpAllInfoLER8RClogger @ 23 NONAME
+	_ZN17CKernelObjectList12RefreshDataLEi @ 24 NONAME
+	_ZN17CKernelObjectList14SetCurrentTypeE17TKernelObjectType @ 25 NONAME
+	_ZN17CKernelObjectList15GetVerboseInfoLEiR6RBuf16S1_ @ 26 NONAME
+	_ZN17CKernelObjectList18GetQikListBoxModelEv @ 27 NONAME
+	_ZN17CKernelObjectList22SetInfoChangedCallbackEiRK9TCallBack @ 28 NONAME
+	_ZN17CKernelObjectList4NewLEP13RMemoryAccess @ 29 NONAME
+	_ZN17CKernelObjectList8GetInfoLEiR6RBuf16S1_ @ 30 NONAME
+	_ZNK17CKernelObjectList5CountEv @ 31 NONAME
+	_ZN17CKernelObjectList12GetInfoByIdLEiiR6RBuf16S1_ @ 32 NONAME
+	_ZN12CKeyCapturer11AddCaptureLEP17MCaptureInterfaceiiii @ 33 NONAME
+	_ZN12CKeyCapturer15AddLongCaptureLEP17MCaptureInterfaceiiii @ 34 NONAME
+	_ZN12CKeyCapturer10IsCapturedEiRi @ 35 NONAME
+	_ZN17CKernelObjectList15GetInfoByIndexLEiiR6RBuf16S1_ @ 36 NONAME
+	_Z21ShutdownProxyNotifierv @ 37 NONAME
+	_Z22NotifierProxyIsRunningv @ 38 NONAME
+	_Z32StartNotifierProxyThreadFunctionPv @ 39 NONAME
+	_Z13ExeNameForSidjR6RBuf16 @ 40 NONAME
+	_ZN10RProxyHeap9ProxyWalkEPvN5RHeap9TCellTypeES0_i @ 41 NONAME ABSENT
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/group/LoggingAllocator.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// LoggingAllocator.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			LoggingAllocator.dll
+TARGETTYPE		DLL
+UID				0x1000008D FSHELL_UID_LOGGINGALLOCATOR
+
+CAPABILITY		FSHELL_CAP_MMP_NORMAL
+
+#include <fshell/fsh_system_include.mmh>
+SOURCEPATH		..\src
+USERINCLUDE		..\inc
+SOURCE			LoggingAllocator.cpp
+
+// Specifies import libraries
+FSHELL_TRACE_LIBRARY
+LIBRARY			euser.lib
+LIBRARY			ltkutils.lib
+//LIBRARY		efsrv.lib
+//LIBRARY		clogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(qr3.iby)
+
+#ifdef FSHELL_QR3_SUPPORT
+PRJ_EXPORTS
+..\inc\QR3Dll.h			fshell/QR3Dll.h
+..\inc\QR3ProductPlugin.h	fshell/QR3ProductPlugin.h
+
+PRJ_MMPFILES
+qr3.mmp
+#endif // FSHELL_QR3_SUPPORT
+
+#ifdef FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR
+PRJ_EXPORTS
+..\inc\LoggingAllocator.h	fshell/LoggingAllocator.h
+
+PRJ_MMPFILES
+loggingallocator.mmp
+sandbox.mmp
+#endif // FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/group/qr3.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// qr3.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef QR3_IBY
+#define QR3_IBY
+
+#include <fsh_config.iby>
+
+#ifdef FSHELL_QR3_SUPPORT
+
+FSHELL_EXECUTABLE_FILE(qr3.dll)
+
+#ifdef FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR
+FSHELL_EXECUTABLE_FILE(QR3Sandbox.exe)
+FSHELL_EXECUTABLE_FILE(LoggingAllocator.dll)
+#endif
+
+#endif
+
+#endif // QR3_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/group/qr3.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,61 @@
+// qr3.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			QR3.dll
+TARGETTYPE		DLL
+UID				0x1000008D FSHELL_UID_QR3
+
+CAPABILITY		FSHELL_CAP_MMP_NORMAL
+
+#include <fshell/fsh_system_include.mmh>
+
+USERINCLUDE		..\inc
+SOURCEPATH		..\src
+SOURCE			heap.cpp
+SOURCE			propertywatcher.cpp
+SOURCE			keycapture.cpp
+SOURCE			objectlist.cpp
+SOURCE			NotifierProxy.cpp
+SOURCE			KernLbxModel.cpp
+SOURCE			openfilesListboxdata.cpp
+SOURCE			serverlistboxdata.cpp
+SOURCE			threadListboxdata.cpp
+SOURCE			featreglistboxdata.cpp
+SOURCE			hallistboxdata.cpp
+SOURCE			utils.cpp
+SOURCE			sandbox.cpp
+#ifdef FSHELL_WSERV_SUPPORT
+SOURCE			wglistboxdata.cpp
+#endif
+SOURCE			msgqlistboxdata.cpp mutexlistboxdata.cpp
+SOURCE			semaphorelistboxdata.cpp timerlistboxdata.cpp
+
+#ifdef FSHELL_PLATFORM_UIQ
+MACRO			INCLUDE_UIQ_DEFINITIONS
+#endif
+
+LIBRARY			euser.lib
+LIBRARY			efsrv.lib
+LIBRARY			clogger.lib
+LIBRARY			hal.lib ecom.lib
+LIBRARY			ltkutils.lib
+
+#ifdef FSHELL_WSERV_SUPPORT
+LIBRARY			ws32.lib
+LIBRARY			gdi.lib
+#endif
+
+#ifdef FSHELL_APPARC_SUPPORT
+LIBRARY			apparc.lib apgrfx.lib apmime.lib 
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/group/sandbox.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// sandbox.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			QR3Sandbox.exe
+TARGETTYPE		exe
+UID				0 FSHELL_UID_QR3SANDBOX
+
+CAPABILITY      FSHELL_CAP_MMP_NORMAL
+
+USERINCLUDE ..\inc
+#include <fshell/fsh_system_include.mmh>
+
+SOURCE ..\src\sandbox.cpp
+
+MACRO SERVER
+
+LIBRARY euser.lib ecom.lib apmime.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/inc/KernLbxModel.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,285 @@
+// KernLbxModel.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef KERNLBXMODEL_H
+#define KERNLBXMODEL_H
+
+#include <e32hashtab.h>
+
+#include <W32STD.H>
+
+class CKernListBoxData;
+class TObjectKernelInfo;
+class TThreadKernelInfo;
+class CUndertaker;
+class CDlgProcessInfo;
+class RMemoryAccess;
+class CApaWindowGroupName;
+class RClogger;
+class MKernListBoxDataDelegate;
+class RWsSession;
+
+NONSHARABLE_CLASS(CKernListBoxModel) : public CBase, public TSwap, public TKey
+	{
+public: // External interface
+	CKernListBoxModel(RMemoryAccess& aMemAccess);
+	~CKernListBoxModel();
+	void ConstructL();
+	void SetCurrentListL(TInt aCurrentList);
+	TInt GetCurrentList() const;
+	void RefreshDataL(TInt aIndex=-1); // -1 means refresh all
+
+	void DumpToCloggerL(RClogger& aClogger);
+	void CloseAllThreadHandles();
+	void SummaryInfoL(TDes& aBuf);
+	void Sort(TLinearOrder<CKernListBoxData> aOrder);
+	void SetInfoChangedCallback(TInt aIndex, const TCallBack& aCallback);
+
+public:
+	TInt Count() const;
+	TInt ItemIdIndex(TInt aItemId) const;
+	CKernListBoxData* RetrieveDataL(TInt aItemIndex);
+	CKernListBoxData* RetrieveDataLC(TInt aItemIndex);
+	virtual void ModelBeginUpdateLC();
+	virtual void ModelEndUpdateL();
+	virtual void RemoveAllDataL();
+	virtual void DataUpdatedL(TInt aIndex);
+	virtual void RemoveDataL(TInt aItemIndex);
+	virtual void Sort();
+
+
+protected: // From TSwap,TKey
+	void Swap(TInt aLeft,TInt aRight) const;
+	void WtfSwap(TInt aLeft,TInt aRight); // How on earth can Swap be const??
+	TInt Compare(TInt aLeft,TInt aRight) const;
+
+public: // For helpers to use, not for public use by client
+	void ThreadDiedL(TInt aHandle);
+	virtual void NewKernDataL(TInt aType, TObjectKernelInfo* aInfo); // aInfo ownership transferred at END of function
+	RMemoryAccess& MemAccess() { return iMemAccess; }
+
+protected:
+	void DoNewKernDataL(TInt aType, TObjectKernelInfo* aInfo, MKernListBoxDataDelegate* aDelegate);
+
+protected:
+	RPointerArray<CKernListBoxData> iItemData;
+
+private:
+	TInt iCurrentList;
+	RArray<TInt> iThreadHandleArray;
+	CUndertaker* iUnd;
+	TLinearOrder<CKernListBoxData> iSort;
+	RWsSession* iWsSession; // Needed to keep the window group data objects valid
+	RBuf iTempBuf1, iTempBuf2; // So that calls to FormatL don't need to allocate so much
+	TCallBack iInfoChangedCallback;
+	CKernListBoxData* iCallbackData;
+	RMemoryAccess& iMemAccess;
+	friend class CKernListBoxData;
+	};
+
+class MKernListBoxDataDelegate
+	{
+public:
+	virtual void DataObjectAboutToDestruct(CKernListBoxData* aData) =0;
+	virtual void FormatChangedL(CKernListBoxData* aData, const TDesC& aTitle, const TDesC& aInfo) =0;
+	virtual TPtrC NameForSortPurposes() const =0;
+	};
+
+
+NONSHARABLE_CLASS(CKernListBoxData) : public CBase
+	{
+public:
+	CKernListBoxData(CKernListBoxModel* aModel);
+	~CKernListBoxData();
+	void FormatL(TObjectKernelInfo* aInfo, RBuf& aTempBuf1, RBuf& aTempBuf2);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+
+	TInt ExeNameForSid(TUint aSid, RBuf& aName);
+
+public:
+	void Open();
+	void Close();
+	//TInt RefCount() const;
+	TInt ItemId() const;
+	void SetItemId(TInt aItemId);
+	void ConstructL();
+	void SetDelegate(MKernListBoxDataDelegate* aOwner);
+	MKernListBoxDataDelegate* Delegate();
+	const MKernListBoxDataDelegate* Delegate() const;
+	CKernListBoxModel& Model();
+
+public: // Things for the dialog to use
+	virtual TBool SupportsCommand(TInt aCommand);
+	void KillL();
+	void InfoForDialogL(RBuf& aTitle, RBuf& aText, TBool aRefresh); // Pass in false to use cached values if available
+	TAny* GetHandleL();
+	
+protected:
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+
+public:
+	TInt iType;
+	TObjectKernelInfo* iInfo; // Either a TObjectKernelInfo* or a SOpenFile* etc
+private:
+	TInt iItemId;
+	MKernListBoxDataDelegate* iDelegate;
+	TInt iRefCount;
+	CKernListBoxModel* iModel; // This is necessary so we can figure out who the parent of a process is, but it does mean a particualar instance can only be used by one model at once (which is not an issue for us)
+	};
+
+NONSHARABLE_CLASS(COpenFilesListBoxData) : public CKernListBoxData
+	{
+public:
+	COpenFilesListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	};
+	
+NONSHARABLE_CLASS(CThreadsListBoxData) : public CKernListBoxData
+	{
+public:
+	CThreadsListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	virtual TBool SupportsCommand(TInt aCommand);
+	};
+
+NONSHARABLE_CLASS(CFeatRegListBoxData) : public CKernListBoxData
+	{
+public:
+	CFeatRegListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	};
+	
+NONSHARABLE_CLASS(CServerListBoxData) : public CKernListBoxData
+	{
+public:
+	CServerListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	virtual TBool SupportsCommand(TInt aCommand);
+	};
+
+NONSHARABLE_CLASS(CHalListBoxData) : public CKernListBoxData
+	{
+public:
+	CHalListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	};
+
+NONSHARABLE_CLASS(CWindowGroupListBoxData) : public CKernListBoxData
+	{
+public:
+	CWindowGroupListBoxData(CKernListBoxModel* aModel);
+	~CWindowGroupListBoxData();
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	};
+
+NONSHARABLE_CLASS(CMsgQueListBoxData) : public CKernListBoxData
+	{
+public:
+	CMsgQueListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	};
+
+NONSHARABLE_CLASS(CMutexListBoxData) : public CKernListBoxData
+	{
+public:
+	CMutexListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	};
+
+NONSHARABLE_CLASS(CSemaphoreListBoxData) : public CKernListBoxData
+	{
+public:
+	CSemaphoreListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	};
+
+NONSHARABLE_CLASS(CTimerListBoxData) : public CKernListBoxData
+	{
+public:
+	CTimerListBoxData(CKernListBoxModel* aModel);
+	virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId);
+	virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count);
+	virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp);
+	};
+
+NONSHARABLE_CLASS(CUndertaker) : public CActive
+	{
+public:
+	CUndertaker(CKernListBoxModel& aModel);
+	~CUndertaker();
+	void RunL();
+	void DoCancel();
+	void Register();
+
+	CKernListBoxModel& iModel;
+	RUndertaker iUnd;
+	TInt iHandle;
+	};
+
+struct SHalInfo
+	{
+	TInt iProperties;
+	TInt iValue;
+	TInt iAttribute;
+	};
+
+struct SWgInfo
+	{
+	TInt iHandle;
+	CApaWindowGroupName* iName;
+	RWsSession* iSession; // Doesn't really belong here (as it will be the same for all objects) but it means the data objects don't have to have a handle to it
+	};
+
+struct SDataType
+	{
+	TBuf<256> iMime; // 256 is KMaxDataTypeLength
+	TFileName iRecog;
+	TFileName iApp;
+	TUid iAppUid;
+	};
+
+struct SOpenFile
+	{
+	TFileName iName;
+	TInt iNumThreads;
+	TFixedArray<TThreadId, 10> iThreadIds;
+	};
+
+struct SFeature
+	{
+	TInt iFeature;
+	TInt iErr;
+	TUint32 iInfo;
+	};
+
+_LIT(Klf, "\n");
+_LIT(Klflf, "\n\n");
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/inc/LoggingAllocator.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,135 @@
+// LoggingAllocator.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef LOGGING_ALLOCATOR_H
+#define LOGGING_ALLOCATOR_H
+
+#include <e32cmn.h>
+#include <fshell/clogger.h>
+#include <fshell/heaputils.h>
+using LtkUtils::RAllocatorHelper;
+
+NONSHARABLE_CLASS(RLoggingAllocator) : public RAllocator
+	{
+public:
+	IMPORT_C static TInt Install();
+	IMPORT_C static TInt Install(TUint aFlags);
+	IMPORT_C static TInt Uninstall();
+
+	// These don't require you to actually link against RLoggingAllocator
+	inline static TInt Install_WeakLink(TUint aFlags=0);
+	inline static TInt Uninstall_WeakLink();
+
+	// Doesn't require the allocator to be installed, just dumps a stacktrace frame for the given cell
+	static IMPORT_C void StaticTraceAlloc(RAllocator* aAllocator, TAny* aCellPtr, TInt aRequestedSize);
+	static IMPORT_C void StaticTraceFree(RAllocator* aAllocator, TAny* aCellPtr);
+
+	// Create a new logging allocator without changing the current User::Allocator
+	IMPORT_C static TInt New(TUint aFlags, RAllocator* aOrigAllocator, RLoggingAllocator*& aResult);
+
+	enum TFlags
+		{
+		EScribbleFrees = 1,
+		EDeferFree = 2,
+		EDeferFreeAndCheckScribbles = EDeferFree | EScribbleFrees,
+		EOldFormatLogging = 4, // Use Symbian-defined BTrace::EAlloc and BTrace::ETest1 rather than the new range atrace defines extending THeap
+		};
+	
+	static const TInt KTempDisableLogging = 0x10286F5E;
+
+	static TAny* DisableLogging()
+		{
+		TAny* result = NULL;
+		User::Allocator().DebugFunction(KTempDisableLogging, &result);
+		return result;
+		}
+
+	static void RestoreLogging(TAny* aAllocator)
+		{
+		if (aAllocator)
+			{
+			User::SwitchAllocator((RAllocator*)aAllocator);
+			}
+		}
+
+protected:
+	TAny* Alloc(TInt aSize);
+	void Free(TAny* aPtr);
+	TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0);
+	TInt AllocLen(const TAny* aCell) const;
+	TInt Compress();
+	void Reset();
+	TInt AllocSize(TInt& aTotalAllocSize) const;
+	TInt Available(TInt& aBiggestBlock) const;
+	TInt DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL);
+
+private:
+	RLoggingAllocator(TUint aFlags);
+	static TBool HeavenWalk(LtkUtils::RAllocatorHelper& aHelper, TAny* aPtr, RAllocatorHelper::TCellType aType, TLinAddr aCell, TInt aLen);
+
+	static TBool TraceExistingAllocs(TAny* aContext, RAllocatorHelper::TCellType aType, TLinAddr aCell, TInt aLen);
+	inline void TraceAlloc(RAllocator* aAllocator, TAny* aCellPtr, TInt aRequestedSize);
+	inline void TraceFree(RAllocator* aAllocator, TAny* aCellPtr, TBool aCellIsAlreadyFreed=EFalse);
+	inline void TraceRealloc(TAny *aNewPtr, TAny* aOldPtr, TInt aNewRequestedSize);
+	void DoTraceAllocEvent(RAllocator* aAllocator, TAny* aCellPtr, TInt aEvent, TInt aRequestedSize, TAny* aOldPtr=NULL); // RequestedSize only relevant for aEvent==EHeapAlloc or EHeapReAlloc, aOldPtr only for realloc
+	void CheckDeferredFrees();
+	void Destroy();
+	virtual ~RLoggingAllocator(); // Made this virtual to shut up GCCE (even GCC 4 complains about this)
+
+public:
+	RAllocator* iA; // The original allocator
+
+private:
+	TInt iBreakOnAllocCount; // Useful when running in a debugger
+#ifndef __KERNEL_MODE__
+	RLibrary iLib; // Needed to keep the plugin DLL loaded past the time when ecom is cleaned up
+#endif
+	TUint iFlags;
+	RFastLock iLock; // For locking around iFlags and iDeferredFrees
+	struct SDeferredFreeCell { void* iPtr; TInt iLen; };
+	RArray<SDeferredFreeCell> iDeferredFrees;
+	TUint iPid;
+	RAllocatorHelper iHelper;
+	};
+
+inline TInt RLoggingAllocator::Install_WeakLink(TUint aFlags)
+	{
+	const TInt KInstallOrdinal = 5; // Happily this is the same on bwins and eabi (and probably bmarm if I get round to rebuilding it)
+	RLibrary lib;
+	TInt err = lib.Load(_L("loggingallocator"));
+	if (err) return err;
+
+	typedef TInt (*InstallFn)(TUint);
+	InstallFn InstallLoggingAllocator = (InstallFn)lib.Lookup(KInstallOrdinal);
+	if (!InstallLoggingAllocator) err = KErrBadLibraryEntryPoint;
+
+	if (!err) err = InstallLoggingAllocator(aFlags);
+	lib.Close(); // If the allocator installed itself, it makes sure to keep itself loaded via an RLibrary of its own
+	return err;
+	}
+
+inline TInt RLoggingAllocator::Uninstall_WeakLink()
+	{
+	const TInt KUninstallOrdinal = 2; // Happily this is the same on bwins and eabi (and probably bmarm if I get round to rebuilding it)
+	RLibrary lib;
+	TInt err = lib.Load(_L("loggingallocator"));
+	if (err) return err;
+
+	typedef TInt (*UninstallFn)();
+	UninstallFn UninstallLoggingAllocator = (UninstallFn)lib.Lookup(KUninstallOrdinal);
+	if (!UninstallLoggingAllocator) err = KErrBadLibraryEntryPoint;
+
+	if (!err) err = UninstallLoggingAllocator();
+	lib.Close(); // If the allocator installed itself, it makes sure to keep itself loaded via an RLibrary of its own
+	return err;
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/inc/NotifierProxy.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,143 @@
+// NotifierProxy.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <e32base.h>
+#include <fshell/memoryaccess.h>
+#include <W32STD.H>
+
+class CRedrawer;
+class CLine;
+class CPanicDialogWatcher;
+
+NONSHARABLE_CLASS(CNotifierProxyServer) : public CServer2
+	{
+public:
+	CNotifierProxyServer();
+	void ConstructL();
+	~CNotifierProxyServer();
+
+	void InfoPrint(const TDesC& aText, TUint aClientId);
+	void DoWservInitiatedRedraw(const TRect& aRect);
+	RWsSession& WsSession();
+
+protected:
+	CSession2* NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const;
+
+private:
+	void SetupWindowL();
+	void DisplayAndStartTimer();
+	static TInt StaticTick(TAny* aSelf);
+	void Tick();
+	void RecalculateWindow();
+	TRect BoxForLine(TInt aLineIndex);
+
+private:
+	RMemoryAccess iMemAccess;
+	TBool iProxying;
+	//RBuf iInfoPrintText;
+	CPeriodic* iPeriodic;
+	CFont* iFont;
+	RPointerArray<CLine> iText;
+	CPanicDialogWatcher* iUndertaker;
+	//
+	RWsSession iWs;
+	RWindowGroup iWg;
+	RWindow iWin;
+	CWsScreenDevice* iScreenDevice;
+	CWindowGc* iGc;
+	CRedrawer* iRedrawer;
+	};
+
+class RRealNotifier : public RNotifier
+	{
+public:
+	TInt Connect();
+	};
+
+NONSHARABLE_CLASS(CNotifierProxySession) : public CSession2
+	{
+public:
+	void ConstructL();
+
+protected:
+	void ServiceL(const RMessage2 &aMessage);
+	void Disconnect(const RMessage2 &aMessage);
+
+private:
+	CNotifierProxyServer& Server();
+	const CNotifierProxyServer& Server() const;
+
+private:
+	RRealNotifier iRealNotifier;
+	};
+
+NONSHARABLE_CLASS(CAsyncWaiter) : public CActive
+	{
+public:
+	CAsyncWaiter(RRealNotifier& aRealNotifier, const RMessage2& aMessage);
+	~CAsyncWaiter();
+	void ForwardMessageL();
+
+protected:
+	void RunL();
+	void DoCancel();
+
+private:
+	RRealNotifier& iRealNotifier;
+	const RMessage2 iMsg;
+	RBuf8 iBuf;
+	RBuf16 iWideBuf;
+	RBuf8 iResponseBuf;
+	TPtrC iTempPtrs[4];
+	};
+
+NONSHARABLE_CLASS(CRedrawer) : public CActive
+	{
+public:
+	CRedrawer(CNotifierProxyServer& aServer);
+	void Go();
+	~CRedrawer();
+
+private:
+	void RunL();
+	void DoCancel();
+
+private:
+	CNotifierProxyServer& iServer;
+	};
+
+NONSHARABLE_CLASS(CLine) : public CBase
+	{
+public:
+	CLine(const TDesC& aText, TUint aClientId);
+
+	TBuf<100> iText;
+	TUint iClientId;
+	//TTime iTimeOfPrint;
+	};
+
+NONSHARABLE_CLASS(CPanicDialogWatcher) : public CActive
+	{
+public:
+	CPanicDialogWatcher(CNotifierProxyServer& aServer);
+	void ConstructL();
+	~CPanicDialogWatcher();
+protected:
+	void RunL();
+	void DoCancel();
+
+private:
+	RUndertaker iUndertaker;
+	CNotifierProxyServer& iServer;
+	TInt iThreadHandle;
+	TFullName iTempName;
+	//TExitCategoryName iTempCategory;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/inc/QR3Dll.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,247 @@
+// QR3Dll.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef QR3DLL_H
+#define QR3DLL_H
+
+#include <e32base.h>
+#include <e32property.h>
+#include <fshell/common.mmh>
+
+class RFile;
+class RMemoryAccess;
+
+
+// Deprecated, use RProxyAllocatorHelper instead
+// Break dependancy on analyseheap
+class THeapDetails
+	{
+public:
+	/** Base address of the heap. Not very useful. */
+	TUint8* iBase;
+	/** First free cell on the heap. Not very useful either. */
+	TUint8* iFirstFree;
+	/** Top address of the heap. Not very useful. */
+	TUint8* iTop;
+	/** Size of heap. This includes free space. */
+	TInt iSize;
+	/** Size of a heap cell header. This is not directly useful, but is necessary
+	    when calculating the amount of free space. */
+	TInt iCellHeaderSize;
+	/** Total allocated space in the heap. This excludes cell headers. */
+	TInt iTotalAllocSize;
+	/** Number of allocated cells on the heap. */
+	TInt iCellCount;
+	/** Returns the amount of free space on the heap. This is the size of the heap,
+	    minus the free space, minus the space occupied by the heap cell headers. */
+	inline TInt FreeSpace() 
+		{
+		return iSize - iTotalAllocSize - (iCellHeaderSize * iCellCount);
+		}
+	};
+
+// Deprecated, use RProxyAllocatorHelper instead
+class TTomsciHeapDetails : public THeapDetails
+	{
+public:
+	TInt iMaxSize;
+	TInt iMinSize;
+	TInt iNumUnusedPages;
+	TInt iFragmentedSpaceNotInPages; // size of the free space minus iNumUnusedPages*KPageSize
+	};
+
+// Deprecated, use RProxyAllocatorHelper instead
+class RProxyHeap : public RHeap
+	{
+public:
+#ifdef FSHELL_ANALYSEHEAP_SUPPORT
+	TInt MinLength() { return iMinLength; }
+	TInt MaxLength() { return iMaxLength; }
+	using RHeap::iFree;
+	using RHeap::iTop;
+	using RHeap::GetAddress;
+#endif
+	using RAllocator::iCellCount;
+	using RAllocator::iTotalAllocSize;
+
+	IMPORT_C RProxyHeap(RMemoryAccess& aMem, TUint aThreadId);
+
+	IMPORT_C void GetHeapDetailsL(THeapDetails& aDetails);
+	IMPORT_C void DumpHeapToSuitableFileInDirectoryL(TFileName& aName); // pass in directory path in aName, it returns the file name
+	IMPORT_C void DumpHeapToFileL(const TDesC& aFileName);
+	IMPORT_C void DumpHeapL(RFile& aDumpFile);
+
+
+public:
+	RMemoryAccess& iMem;
+	TUint iThreadId;
+	TUint iPadding[6];
+	};
+
+IMPORT_C void GetHeapDetailsL(THeapDetails& aDetails, RProxyHeap& heap); // Deprecated, use RProxyAllocatorHelper instead
+
+NONSHARABLE_CLASS(CPropertyManager) : public CActive
+	{
+public:
+	IMPORT_C static CPropertyManager* NewL(TCallBack aCallback);
+	IMPORT_C void SetPropertyFromStringL(const TDesC& aString);
+	IMPORT_C HBufC* GetValueL();
+	IMPORT_C TInt ChangeProperty(TUint aCategory, TUint aKey);
+
+	inline TInt Category() { return iCat; }
+	inline TInt Key() { return iKey; }
+
+	~CPropertyManager();
+
+private:
+	void RunL();
+	void DoCancel();
+	CPropertyManager(TCallBack aCallback);
+	void Watch();
+
+private:
+	RProperty iProperty;
+	RProperty::TType iPropertyType;
+	TUint iCat;
+	TUint iKey;
+	TCallBack iChangedFn;
+	};
+
+//////// Key capturing stuff
+
+// The simple interface for people who only want simple callbacks equivalent to EEventKey events.
+class MCaptureInterface
+	{
+public:
+	virtual void CapturedKeyPressedL(TInt aIdentifier)=0;
+	};
+
+/*
+class MDetailedCaptureInterface : public MCaptureInterface
+	{
+public:
+	// If you implement both overloads of CapturedKeyPressedL, this one will be called {before,after} the simple one above
+	virtual void CapturedKeyPressedL(TInt aIdentifier, const TKeyEvent& aKeyEvent, TEventCode aType)=0;
+	};
+*/
+
+struct SCapture;
+
+NONSHARABLE_CLASS(CKeyCapturer) : public CActive
+	{
+public:
+	IMPORT_C static CKeyCapturer* GetCapturerL();
+	IMPORT_C static void DeleteCapturer();
+	IMPORT_C void AddCaptureL(MCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode);
+	IMPORT_C void AddCaptureL(MCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode, TInt aScanCode, TInt aCapturePriority);
+	IMPORT_C void AddLongCaptureL(MCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode, TInt aScanCode); // Annoying as it is, the scan code is required to sucessfully perform a long capture across window groups
+	IMPORT_C void AddLongCaptureL(MCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode, TInt aScanCode, TInt aCapturePriority);
+	//void AddCaptureL(MDetailedCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode); // Can't do a long capture and get detailed info back - it's too confusing to support
+	IMPORT_C void RemoveCapture(MCaptureInterface* aClient, TInt aIdentifier);
+	IMPORT_C TInt IsCaptured(TInt aIdentifier); // Returns the keycode it's captured as
+	IMPORT_C TInt IsCaptured(TInt aIdentifier, TBool& aIsLong);
+	IMPORT_C void PushCurrentCapturesL(); // Removes all current captures. They may be restored by calling PopCapturesL(). This function may be called repeatedly, you must call Pop once for each push
+	IMPORT_C void PopCapturesL();
+	IMPORT_C TInt GetScanCodeOfLastEvent(); // This is only usefully called from within CapturedKeyPressedL
+
+	~CKeyCapturer();
+	void RunL();
+	void DoCancel();
+	TInt RunError(TInt aError);
+
+private:
+	static CKeyCapturer* NewLC();
+	CKeyCapturer();
+	void ConstructL();
+	void CancelCapture(SCapture& cap);
+	void AddCaptureL(SCapture& cap);
+	void RemoveDummyForCapture(const SCapture& aCapture);
+
+private:
+	enum
+		{
+		EOpaquePadding1 = 12,
+		EOpaquePadding2 = 8,
+		};
+	// Data structures are not exposed
+	TUint8 iOpaque1[EOpaquePadding1];
+	TUint8 iOpaque2[EOpaquePadding2];
+	TAny* iOpaque3; 
+	TAny* iOpaque4;
+	TInt32 iUsedSpareKeys; // Used for doing long captures
+	TInt iLastEventScanCode;
+	};
+
+#ifdef FSHELL_QR3_SUPPORT_LOGGINGALLOCATOR
+#include <fshell/LoggingAllocator.h> // Old definition was in this header, so for compatibility pull it in
+#endif
+
+enum TKernelObjectType
+	{
+	EListProcess,
+	EListThread,
+	EListChunk,
+	EListServer,
+	EListCodeSeg,
+	EListHal,
+	EListWindowGroups,
+	EListMimeTypes,
+	EListOpenFiles,
+	EListFeatureReg,
+	EListMessageQueue,
+	EListMutex,
+	EListSemaphore,
+	EListTimer,
+	};
+
+class MQikListBoxModel;
+class CKernListBoxModel;
+class RClogger;
+
+NONSHARABLE_CLASS(CKernelObjectList) : public CBase
+	{
+public:
+	IMPORT_C static CKernelObjectList* NewL(RMemoryAccess* aMemAccess); // aMemAccess can be null
+	~CKernelObjectList();
+
+	IMPORT_C void SetCurrentType(TKernelObjectType aType);
+	IMPORT_C void RefreshDataL(TInt aIndex=-1); // -1 means refresh all
+	IMPORT_C MQikListBoxModel* GetQikListBoxModel(); // Returns an object suitable for controlling a UIQ3 list box.
+	IMPORT_C void SetInfoChangedCallback(TInt aIndex, const TCallBack& aCallback); // Sets up a callback that will be completed whenever the model detects that aIndex's entry is out of date. Clunky, should be replaced with something neater...
+
+	IMPORT_C TInt Count() const;
+	
+	// Following two functions are deprecated in favour of GetInfoByIndexL
+	IMPORT_C void GetInfoL(TInt aIndex, RBuf& aTitle, RBuf& aInfo); // aInfo is a one-liner
+	IMPORT_C void GetVerboseInfoL(TInt aIndex, RBuf& aTitle, RBuf& aInfo); // aInfo is multi-line, formatted with LFs
+	
+	IMPORT_C TInt GetInfoByIndexL(TInt aIndex, TBool aVerbose, RBuf& aTitle, RBuf& aInfo); // Returns the item id if supported by the current type
+	IMPORT_C void GetInfoByIdL(TInt aId, TBool aVerbose, RBuf& aTitle, RBuf& aInfo); // Looks up by id rather than index. Id is specific to the current type - for threads it is thread ID, for others it may be arbitrary
+
+	IMPORT_C void DumpAllInfoL(RClogger& aClogger);
+
+private:
+	CKernelObjectList(RMemoryAccess* aMemAccess);
+	void ConstructL();
+
+private:
+	RMemoryAccess* iMemAccess;
+	CKernListBoxModel* iModel;
+	TKernelObjectType iCurrent;
+	};
+
+IMPORT_C TInt StartNotifierProxyThreadFunction(TAny*);
+IMPORT_C TInt ShutdownProxyNotifier();
+IMPORT_C TBool NotifierProxyIsRunning();
+
+IMPORT_C TInt ExeNameForSid(TUint aSid, RBuf& aBuf);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/inc/QR3ProductPlugin.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,116 @@
+// QR3ProductPlugin.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef QR3PRODUCTPLUGIN_H
+#define QR3PRODUCTPLUGIN_H
+
+enum TPluginEnumValues
+	{
+	// More types will be added to this as we support more plugins.
+	// Anyone writing a plugin will be assigned a set of EPluginx values that they should use.
+	// This is to avoid conflicts
+
+	EPlugin1CommandsOrControls = 0x3000,
+	EPlugin1Tabs = 0x3490,
+	EPlugin1Max = 0x3499,
+
+	EPlugin2CommandsOrControls = 0x3500,
+	EPlugin2Tabs = 0x3990,
+	EPlugin2Max = 0x3999,
+
+	EPluginMax = 0x9999
+	};
+
+#define KQr3ProductPluginEcomUid 0x102831C5
+
+#ifdef __cplusplus
+// We reuse this file as an HRH as well, so we have to escape everything for when we're being run by rcomp
+
+#include <e32base.h>
+#include <COECOBS.H> // TCoeEvent
+#include <COEDEF.H> // For key handling stuff
+#include <W32STD.H> // Ditto
+
+class CQikMultiPageViewBase;
+class CQikCommand;
+class CCoeControl;
+
+class MProductPluginV1 // This corresponds to version 1 in your ECOM rss file
+	{
+	// Do not add any virtual functions to this class! If you need to do that, create a new class MProductPluginV2 
+	// that derives from MProductPluginV1 and add them there. This ensures BC between plugin versions. If you do, be
+	// sure to update CDefaultProductPlugin to not call through to plugins too old to support the new methods.
+	// Or better yet talk to me first! -Tom
+public:
+	enum TError
+		{
+		ECouldntSetDebugPort,
+		};
+
+	enum TValueType
+		{
+		EHal,
+		EKey,
+		EFeature,
+		};
+
+	// Non-UI device attributes
+	virtual TPtrC8 TraceFlagName(TInt aWord, TInt aBit)=0;
+	virtual void FormatValue(TDes& aDes, TValueType aType, TInt aAttrib, TInt aVal)=0;
+	virtual TUint32 GetDeviceType()=0;
+	virtual TBool HandleErrorL(TError aType, TInt aErr)=0; // Return ETrue to handle.
+	virtual TBool ConsumeMemoryKeys(TBool aDisk, TDes& aCheckboxName, TInt& aUpKeyCode, TInt& aDownKeyCode, TInt& aLogKeyCode)=0;
+	virtual void Release(TBool aAppIsShuttingDown)=0; // aAppIsShuttingDown may be useful for things with complex interactions with CEikonEnv
+
+	// View related functions
+	virtual TKeyResponse OfferKeyEventL(TKeyEvent& aEvent, TEventCode aCode)=0;
+	virtual void DoViewConstructL(CQikMultiPageViewBase* aParentView)=0;
+	virtual TBool DoDynInitOrDeleteCommandL(CQikCommand*& aCommand, const CCoeControl& aControlAddingCommands)=0;
+	virtual void DoHandleControlEventL(CCoeControl *aControl, MCoeControlObserver::TCoeEvent aEventType)=0;
+
+	virtual void RefreshTabL(TInt aTab)=0;
+	};
+
+class MProductPluginV2 : public MProductPluginV1
+	{
+public:
+	virtual void EnablePanicChecking(TBool aEnable)=0; // This function should disable any device-specific crash capture behaviour that may be invoked as a result of calls to User::Panic. This is because QResources is about to call code that might panic, but it should continue regardless and not (eg) cause the phone to reboot on debug builds.
+	virtual TBool PanicCheckingIsEnabled()=0;
+	};
+
+class MProductPluginV3 : public MProductPluginV2
+	{
+public:
+	virtual void GetFeatureUidsL(RArray<TUid>& aUids)=0; // Populates aUids with any device-specific entries in feature registry
+	};
+
+class MProductPluginV4 : public MProductPluginV3
+	{
+public:
+	virtual TBool ConsumeMemoryKeys(TBool aDisk, TDes& aCheckboxName, TInt& aUpKeyCode, TInt& aUpScanCode, TInt& aDownKeyCode, TInt& aDownScanCode, TInt& aLogKeyCode, TInt& aLogScanCode)=0;
+	};
+
+/*
+ * MProductPlugin is always typedef'd to the latest plugin version
+ * This means that plugin writers can always derive from MProductPlugin,
+ * and not usually have to worry about it, but you get the BC advantages of
+ * versioning. If there is a new version which you don't want to implement when
+ * you rebuild your plugin, then just change the declaration to explicitly derive
+ * from the old version (eg change "class Cx : public CBase, public MProductPlugin" to 
+ * "class Cx : public CBase, public MProductPluginV1"
+ *
+ * Remember that what you derive from must match the version number in your ecom rss
+ * file! (Strictly speaking, the rss version num must be <= the class derived)
+ */
+typedef MProductPluginV4 MProductPlugin;
+
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/inc/QResources3.hrh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,217 @@
+// QResources3.hrh
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef QResources3_HRH
+#define QResources3_HRH
+
+
+#include <fshell/QR3ProductPlugin.h>
+
+/**
+Identifies the value for the commands in the application.
+Commands shall first start on 0x1000.
+Values before 0x1000 is reserved for commands in the framework.
+*/
+enum TQResources3Command
+	{
+	EQResources3NewCmd = 0x1000,
+	EQResources3SaveCmd,
+	EQResources3DeleteCmd,
+	EQResources3DeleteHardwareCmd,
+
+	ECmdRefresh,
+	ECmdPoll,
+
+	// These must be the same order as TKernelObjectType
+	ECmdProcesses,
+	ECmdThreads,
+	ECmdChunks,
+	ECmdServers,
+	ECmdCodeSegs,
+	ECmdHal,
+	ECmdWindowGroups,
+	ECmdMimeTypes,
+	ECmdOpenFiles,
+	ECmdFeatureReg,
+	ECmdMessageQueue,
+	ECmdMutex,
+	ECmdSemaphore,
+	ECmdTimer,
+
+	ECmdKill,
+	ECmdHandleInfo,
+	ECmdPing,
+	ECmdClogger,
+	//ECmdCloggerApply,
+	//ECmdCloggerSave,
+	ECmdCloggerReset,
+	ECmdCloseHandles,
+	ECmdCloggerDetails,
+	ECmdCloggerConfigBuffers,
+	ECmdCancel,
+	ECmdDumpHeap,
+	ECmdSetPriority,
+	ECmdSetCritical,
+
+	ECmdInstallFlogger,
+	ECmdUninstallFlogger,
+	
+	ECmdGoToTab,
+	ECmdSortBy,
+	ECmdSortByName,
+	ECmdSortById,
+	
+	ECmdMiscUsefulEcomUids,
+	ECmdMiscNukeApparc,
+
+	ELastCmd
+	};
+
+/**
+Define groups for commands which is seperated with dividers in menu
+*/
+enum TQResources3CommandGroupId
+	{
+	EQResources3DefaultCmdGroupId,
+	//EQResources3EditCmdGroupId,
+	//EQResources3DeleteCmdGroupId,
+
+	EGroupKernLists,
+	EGroupTabs,
+	EGroupSortBy,
+	EGroupCloggerCheckboxes
+	};
+	
+/**
+Unique controls in list and detail view.
+*/
+enum TQResources3Control
+	{
+	EQResources3ListViewListCtrl,
+	EQResources3ListViewPage,
+	
+	EChunkLbx,
+	EChunkLabel,
+
+	//ECloggerContainer,
+	EKTraceContainer,
+	//EMemoryContainer,
+	//EDiskContainer,
+	//EMiscContainer,
+
+	ECloggerRotate,
+	ECloggerRotateAndSend,
+	ECloggerSaveSettings,
+	ECloggerBufferLog,
+	ECloggerRDebug,
+	ECloggerAutoRotate,
+	ECloggerCopyLogsToD,
+	ECloggerEditTags,
+	ECloggerResetSettings,	
+	ECloggerCompressRotate,
+	ECloggerOverlay,
+	ECloggerRedirectRDebug,
+	ECloggerBluetooth,
+	ECloggerWriteToFile,
+	ECloggerSetNumBuffers,
+	ECloggerSetBufferSize,
+	ECloggerSetNumRotates,
+
+	EKTraceBitsStart,
+	EKTraceBitsEnd = 400, // FFS resource files don't support calculation in enums?? //EKTraceBitsStart + 288, //9*32,
+
+	EDlgProcessInfoName,
+	ECloggerTagsLbx,
+
+	EMemoryFree,
+	EMemoryConsuming,
+	EMemoryUseAllocator,
+	EMemoryConsume,
+	EMemoryInfoPrint,
+	EMemoryIgnoreQmm,
+	EMemoryReallyIgnore,
+	EMemoryFreeUp,
+
+	EDiskFree,
+	EDiskConsuming,
+	EDiskConsume,
+	EDiskInfoPrint,
+	EDiskFreeUp,
+
+	EDiskExtFree,
+	EDiskExtConsuming,
+	EDiskExtConsume,
+	EDiskExtInfoPrint,
+
+	ECloggerTagView,
+	ETopLbx,
+
+	EMiscDebugPort,
+	EMiscPSCategory,
+	EMiscPSKey,
+	EMiscPSValue,
+	EMiscPSInfoPrint,
+	EMiscPSLog,
+	EMiscTimedScreenshot,
+	EMiscTriggeredScreenshot,
+	EMiscScreenMode,
+	EMiscPartialRedraw,
+	EMiscEcomListing,
+	EMiscUseNotifierProxy,
+
+	EConfigureKeyCaptures,
+	EKeyCapturesPageId,
+	
+	EKeyCapturesStart,
+	EKeyCaptureScreenshot = EKeyCapturesStart,
+	EKeyForceCrash,
+	EKeyEatMeUp,
+	EKeyEatMeDown,
+	EKeyLogMe,
+	//EKeyShowCloggerOverlay,
+	EKeyToggleProfiler,
+	EKeyRotateClogger,
+	EKeyCapturesEnd,
+
+	EKeyCaptureDialogText,
+	ECriticalDlgList,
+	EPrioritySetAbsolute,
+	EPrioritySetRelative,
+
+	// These double as command ids for the commands that indicate "go to this tab"
+	// Thus they have slightly strange IDs
+	ETabsStart = 0x2000,
+	ETabChunks = ETabsStart,
+	ETabClogger,
+	ETabKTrace,
+	ETabMemory,
+	ETabDisk,
+	ETabTop,
+	ETabMisc,
+	ETabPS,
+	ETabsEnd,
+
+	ECtPlaceholderEditor, // control type
+	ECtSettingsDialogContents, // control type
+	ECtForTheLoveOfGodAllIWantIsAnEdwin,
+
+	// Remember everything between 0x3000 and 0x10000 is reserved for product plugins
+
+	ELastItem = 0x10000
+	};
+
+#define KTRACE_BIT_ID(word, bit) (EKTraceBitsStart + 9 + word*32 + bit)
+#define KTRACE_WORD_ID(word) (EKTraceBitsStart + word)
+#define KTRACE_WORD_FROM_ID(id) ((id - KTRACE_BIT_ID(0, 0)) / 32)
+#define KTRACE_BIT_FROM_ID(id) (id - KTRACE_BIT_ID(KTRACE_WORD_FROM_ID(id), 0))
+
+#endif // QResources3_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/inc/Utils.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,105 @@
+// Utils.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <fshell/QR3ProductPlugin.h>
+#include <fshell/qr3dll.h>
+
+void HR(TDes& aDes, TInt64 aSize); // Human readable formatting of aSize as a memory size (eg 1500 -> "1.46 KB")
+void HR(TDes8& aDes, TInt64 aSize); 
+
+TPtrC ToString(TProcessPriority aPriority);
+TPtrC ToString(TThreadPriority aPriority);
+TPtrC ToString(TExitType aType);
+HBufC* ToStringL(SCapabilitySet& aCaps);
+TPtrC ToString(User::TCritical aCritical);
+TPtrC ToStringHal(TInt aHalAttribute);
+void ToStringHalVal(TDes& aDes, TInt aHalAttribute, TInt aHalValue);
+
+void PrettyName(TInt aType, TDes& aName); // aType is a TKernelObjectType
+
+//extern const char*const* KKTraceFlags[];
+TPtrC8 TraceFlagName(TInt aWord, TInt aBit);
+
+extern char const* const* const KCloggerTags[];
+
+//extern const char* KFileServerTraceFlags[];
+
+class CEcomWatcher;
+
+NONSHARABLE_CLASS(CDefaultProductPlugin) : public CBase, public MProductPlugin
+	{
+public:
+	static void LoadProductPluginL();
+	~CDefaultProductPlugin();
+
+	// From MProductPluginV1
+	TPtrC8 TraceFlagName(TInt aWord, TInt aBit);
+	void FormatValue(TDes& aDes, TValueType aType, TInt aAttrib, TInt aVal);
+	TUint32 GetDeviceType();
+	TBool HandleErrorL(TError aType, TInt aErr);
+	TKeyResponse OfferKeyEventL(TKeyEvent& aEvent, TEventCode aType);
+	void RefreshTabL(TInt aTab);
+	TBool DoDynInitOrDeleteCommandL(CQikCommand*& aCommand, const CCoeControl& aControlAddingCommands);
+	void DoViewConstructL(CQikMultiPageViewBase* aParentView);
+	void DoHandleControlEventL(CCoeControl *aControl, MCoeControlObserver::TCoeEvent aEventType);
+	TBool ConsumeMemoryKeys(TBool aDisk, TDes& aCheckboxName, TInt& aUpKeyCode, TInt& aDownKeyCode, TInt& aLogKeyCode);
+	void Release(TBool aAppIsShuttingDown);
+
+	// From MProductPluginV2
+	void EnablePanicChecking(TBool aEnable);
+	TBool PanicCheckingIsEnabled();
+
+	// From MProductPluginV3
+	void GetFeatureUidsL(RArray<TUid>& aUids);
+
+	// From MProductPluginV4
+	TBool ConsumeMemoryKeys(TBool aDisk, TDes& aCheckboxName, TInt& aUpKeyCode, TInt& aUpScanCode, TInt& aDownKeyCode, TInt& aDownScanCode, TInt& aLogKeyCode, TInt& aLogScanCode);
+	
+	// Internal
+	void EcomChangedL();
+	void ConstructL();
+	void DestroyPlugins();
+	void RescanPluginsL();
+	void LoadPluginL(TUid aImplUid, TInt aVersion);
+	void DisablePanicCheckPushL(); // Disables panic checks, pushes an item onto the cleanupstack that restores them
+	static void EnablePanicCheck(TAny* aSelf);
+
+private:
+	REComSession iEcom;
+	RImplInfoPtrArray iEcomPluginList;
+	RPointerArray<MProductPlugin> iPlugins;
+	MProductPluginV1* iPluginForThisDevice; // Not owned, may be NULL. Is explicitly typed to be MProductPluginV1 to remind people they have to check the version before calling any non-V1 functions
+	TInt iPluginForThisDeviceVersion; // Will be 0 if iPluginForThisDevice == NULL
+	RArray<TUid> iPluginDestructors;	
+	TCallBack iPluginsChangedCallback;
+	CEcomWatcher* iEcomChangeWatcher;
+	CQikMultiPageViewBase* iParentView;
+	TBool iShuttingDown;
+	};
+
+#ifdef __DLL__
+#define gPlugin ((CDefaultProductPlugin*)Dll::Tls())
+#else
+extern CDefaultProductPlugin* gPlugin;
+#endif
+
+void StartProfilerL();
+TBool IsProfilerRunning();
+void StopProfiler();
+
+TUint CriticalToFlags(User::TCritical aCrit);
+User::TCritical FlagsToCritical(TUint aFlags);
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/inc/sandbox.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+// sandbox.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <e32base.h>
+#include <APMSTD.H>
+
+class RMemoryAccess;
+
+namespace Sandbox
+	{
+	void GetRecogniserInfoL(TUid aImplementationUid, RArray<TDataType>& aMimeTypes);
+	void GetDllNameFromEcomUidL(RMemoryAccess& aMemAccess, TUid aUid, TFileName& aFileName);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/KernLbxModel.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1370 @@
+// KernLbxModel.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/memoryaccess.h>
+#include "QResources3.hrh"
+#include <HAL.h>
+#include <fshell/common.mmh>
+#include <fshell/clogger.h>
+
+#ifdef FSHELL_APPARC_SUPPORT
+#include <apgcli.h>
+#include <APGWGNAM.H>
+#include <APMREC.H>
+#endif
+#ifdef FSHELL_WSERV_SUPPPORT
+#include <W32STD.H>
+#endif
+
+#include <fshell/ltkutils.h>
+#include "sandbox.h"
+
+using namespace LtkUtils;
+
+CKernListBoxData::CKernListBoxData(CKernListBoxModel* aModel)
+	: /*CQikListBoxData(),*/ iModel(aModel)
+	{
+	}
+
+CKernListBoxData::~CKernListBoxData()
+	{
+	if (iDelegate)
+		{
+		iDelegate->DataObjectAboutToDestruct(this);
+		}
+	delete iInfo;
+	}
+
+
+CKernListBoxModel::CKernListBoxModel(RMemoryAccess& aMemoryAccess)
+	: iSort(NULL), iMemAccess(aMemoryAccess)
+	{
+	}
+
+void CKernListBoxModel::ConstructL()
+	{
+	iUnd = new(ELeave) CUndertaker(*this);
+	iUnd->Register();
+#ifdef FSHELL_WSERV_SUPPORT
+	iWsSession = new (ELeave) RWsSession;
+	TInt err = iWsSession->Connect();
+	if (err != KErrNone)
+		{
+		delete iWsSession;
+		iWsSession = NULL;
+		// Null pointer is used to indicate wserv not present
+		}
+#endif
+	iTempBuf1.CreateL(256);
+	iTempBuf2.CreateL(256);
+	}
+
+TInt CKernListBoxModel::Count() const
+	{
+	return iItemData.Count();
+	}
+
+TInt CKernListBoxModel::ItemIdIndex(TInt aItemId) const
+	{
+	const TInt count = iItemData.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		if (iItemData[i]->ItemId() == aItemId)
+			return i;
+		}
+	return KErrNotFound;
+	}
+
+CKernListBoxData* CKernListBoxModel::RetrieveDataL(TInt aItemIndex)
+	{
+	iItemData[aItemIndex]->Open();
+	return iItemData[aItemIndex];
+	}
+
+CKernListBoxData* CKernListBoxModel::RetrieveDataLC(TInt aItemIndex)
+	{
+	CKernListBoxData* data = iItemData[aItemIndex];
+	data->Open();
+	CleanupClosePushL(*data);
+	return data;
+	}
+
+void CKernListBoxModel::RemoveAllDataL()
+	{
+	const TInt count = iItemData.Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		iItemData[i]->Close();
+		}
+	iItemData.Reset();
+	}
+
+void CKernListBoxModel::ModelBeginUpdateLC()
+	{
+	}
+
+void CKernListBoxModel::ModelEndUpdateL()
+	{
+	}
+
+void CKernListBoxModel::DataUpdatedL(TInt /*aIndex*/)
+	{
+	}
+
+TInt CKernListBoxModel::Compare(TInt aLeft, TInt aRight) const
+	{
+	const CKernListBoxData* left = iItemData[aLeft];
+	const CKernListBoxData* right = iItemData[aRight];
+	return (*iSort)(left, right);
+	}
+
+void CKernListBoxModel::Swap(TInt aLeft,TInt aRight) const
+	{
+	const_cast<CKernListBoxModel*>(this)->WtfSwap(aLeft, aRight);
+	}
+
+void CKernListBoxModel::WtfSwap(TInt aLeft,TInt aRight)
+	{
+	CKernListBoxData* temp = iItemData[aLeft];
+	iItemData[aLeft] = iItemData[aRight];
+	iItemData[aRight] = temp;
+	}
+
+void CKernListBoxModel::RemoveDataL(TInt aItemIndex)
+	{
+	iItemData[aItemIndex]->Close();
+	iItemData.Remove(aItemIndex);
+	}
+
+void CKernListBoxModel::SetCurrentListL(TInt aCurrentList)
+	{
+	if (iCurrentList != aCurrentList)
+		{
+		RemoveAllDataL();
+		}
+	iCurrentList = aCurrentList;
+	}
+
+TInt CKernListBoxModel::GetCurrentList() const
+	{
+	return iCurrentList;
+	}
+
+void CKernListBoxModel::NewKernDataL(TInt aType, TObjectKernelInfo* aInfo)
+	{
+	DoNewKernDataL(aType, aInfo, NULL);
+	}
+
+void CKernListBoxModel::DoNewKernDataL(TInt aType, TObjectKernelInfo* aInfo, MKernListBoxDataDelegate* aDelegate)
+	{
+	CKernListBoxData* data;
+	switch (aType)
+		{
+	case EListOpenFiles:
+		data = new(ELeave) COpenFilesListBoxData(this);
+		break;
+	case EListThread:
+		data = new(ELeave) CThreadsListBoxData(this);
+		break;
+	case EListFeatureReg:
+		data = new(ELeave) CFeatRegListBoxData(this);
+		break;
+	case EListServer:
+		data = new(ELeave) CServerListBoxData(this);
+		break;
+	case EListHal:
+		data = new(ELeave) CHalListBoxData(this);
+		break;
+	case EListWindowGroups:
+#ifdef FSHELL_WSERV_SUPPORT
+		data = new(ELeave) CWindowGroupListBoxData(this);
+#else
+		data = NULL; // Compiler shutter upper
+		User::Leave(KErrNotSupported);
+#endif
+		break;
+	case EListMessageQueue:
+		data = new(ELeave) CMsgQueListBoxData(this);
+		break;
+	case EListMutex:
+		data = new(ELeave) CMutexListBoxData(this);
+		break;
+	case EListSemaphore:
+		data = new(ELeave) CSemaphoreListBoxData(this);
+		break;
+	case EListTimer:
+		data = new(ELeave) CTimerListBoxData(this);
+		break;
+	default:
+		data = new(ELeave) CKernListBoxData(this);
+		break;
+		}
+	
+	data->SetDelegate(aDelegate);
+	CleanupStack::PushL(data);
+	data->iType = aType;
+	data->ConstructL();
+
+	data->FormatL(aInfo, iTempBuf1, iTempBuf2);
+
+	iItemData.AppendL(data);
+	CleanupStack::Pop(data);
+	data->Open(); // open for model
+
+	//data->Open(); // open for return
+	data->iInfo = aInfo;
+	//return data;
+	}
+
+
+// This function is used for the list box items
+void CKernListBoxData::FormatL(TObjectKernelInfo* aInfo, RBuf& aTempBuf1, RBuf& aTempBuf2)
+	{
+	RBuf& name = aTempBuf1;
+	RBuf& more = aTempBuf2;
+	name.Zero();
+	more.Zero();
+
+	TInt itemId = (TInt)aInfo; // By default use the ptr unless the type can suggest anything better
+	DoFormatL(aInfo, aTempBuf1, aTempBuf2, itemId);
+	SetItemId(itemId);
+
+	if (iDelegate)
+		{
+		iDelegate->FormatChangedL(this, name, more);
+		}
+	}
+
+
+void CKernListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId)
+	{
+	switch (iType)
+		{
+	case EListChunk:
+		{
+		TChunkKernelInfo& info = *(TChunkKernelInfo*)aInfo;
+		name.Copy(info.iFullName);
+		PrettyName(iType, name);
+		TBuf<16> size, maxSize;
+		HR(size, info.iSize);
+		HR(maxSize, info.iMaxSize);
+		more.Format(_L("Size %S / %S"), &size, &maxSize);
+		break;
+		}
+	case EListProcess:
+		{
+		TProcessKernelInfo& info = *(TProcessKernelInfo*)aInfo;
+		name.Copy(info.iFullName);
+		PrettyName(iType, name);
+		TUint pid = info.iProcessId;
+		TUint sid = info.iProcessSecurityInfo.iSecureId;
+		TExitType exitType = EExitPending;
+		RProcess proc;
+		if (proc.Open(pid) == KErrNone)
+			{
+			exitType = proc.ExitType();
+			}
+		if (exitType == EExitPending)
+			{
+			more.Format(_L("Pid %i Sid 0x%x"), pid, sid);
+			}
+		else
+			{
+			TExitCategoryName cat = proc.ExitCategory();
+			more.Format(_L("Pid %i %S %i Sid 0x%x"), pid, &cat, proc.ExitReason(), sid);
+			}
+		proc.Close();
+		itemId = pid;
+		break;
+		}
+	case EListCodeSeg:
+		{
+		TTomsciCodeSegKernelInfo& info = *reinterpret_cast<TTomsciCodeSegKernelInfo*>(aInfo);
+		name.Copy(info.iName);
+
+		TBuf<16> size;
+		HR(size, info.iSize);
+		more.Format(_L("Size %S Ref count %i"), &size, info.iAccessCount);
+		break;
+		}
+	case EListMimeTypes:
+		{
+		SDataType& info = *reinterpret_cast<SDataType*>(aInfo);
+		name.Copy(info.iMime);
+		more.Format(_L("From: %S"), &info.iRecog);
+		break;
+		}
+	default:
+		break;
+		}
+	
+	}
+
+void CKernListBoxModel::DumpToCloggerL(RClogger& clogger)
+	{
+	TInt count = Count();
+
+#ifdef __WINS__
+	clogger.Log("NOTE: This data is from a WINS[CW] build so is not representative of a real device!");
+#endif
+
+	for (TInt i = 0; i < count; i++)
+		{
+		CKernListBoxData* data = static_cast<CKernListBoxData*>(RetrieveDataLC(i));
+		data->DumpToCloggerL(clogger, i, count);
+		CleanupStack::PopAndDestroy(data);
+		}
+	}
+
+void CKernListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt count)
+	{
+	_LIT8(KChunkDesc,"Chunk;FullName;Size;(SizeHumanReadable);MaxSize;(MaxSizeHumanReadable);CreatorPid;BaseAddr");
+	_LIT8(KChunkFmt,"Chunk;%S;%i;(%S);%i;(%S);%i;%08x");
+
+	_LIT8(KProcessDesc,"Process;FullName;Pid;Priority;(PriorityHumanReadable);Sid;Vid;CreatorSid;CreatorName;Capabilities;(CapsHumanReadable);ExitStatus;ExitCategory;ExitReason;FixedProcess;DProcessAddr");
+	_LIT8(KProcessFmt,"Process;%S;%i;%i;(%S);%x;%x;%x;%S;%x;(%S);%S;%S;%i;%S;%08x");
+
+	_LIT8(KCodesegDesc,"CodeSeg;FileName;Size;(SizeHumanReadable);RefCount;DepCount");
+	_LIT8(KCodesegFmt,"CodeSeg;%S;%i;%S;%i;%i");
+
+	_LIT(KMimeDesc,"MimeType;Name;Recogniser;AppUid;AppName");
+	_LIT(KMimeFmt, "MimeType;%S;%S;%x;%S");
+
+	CKernListBoxData* data = this;
+	TObjectKernelInfo* aInfo = data->iInfo;
+
+	switch (iType)
+		{
+	case EListChunk:
+		{
+		if (i == 0) clogger.Log(KChunkDesc);
+		if (i == 0)
+			{
+			// Also log free at the start, so we can tally up mem losses
+			TInt freeRam = -1, totalRam = -1;
+			TBuf8<16> free, total;
+			HAL::Get(HAL::EMemoryRAMFree, freeRam);
+			HAL::Get(HAL::EMemoryRAM, totalRam);
+			HR(free, freeRam);
+			HR(total, totalRam);
+			_LIT8(KFree, "FREE");
+			clogger.Log(KChunkFmt, &KFree, freeRam, &free, totalRam, &total, 0);
+			}
+
+		TChunkKernelInfo& info = *(TChunkKernelInfo*)aInfo;
+		TBuf8<16> size, maxSize;
+		HR(size, info.iSize);
+		HR(maxSize, info.iMaxSize);
+		clogger.Log(KChunkFmt, &info.iFullName, info.iSize, &size, info.iMaxSize, &maxSize, info.iControllingOwnerProcessId, info.iBase);
+
+		if (i == count-1)
+			{
+			// Also print out free RAM at end, so we can see if mem usage changed much during
+			TInt freeRam = -1, totalRam = -1;
+			TBuf8<16> free, total;
+			HAL::Get(HAL::EMemoryRAMFree, freeRam);
+			HAL::Get(HAL::EMemoryRAM, totalRam);
+			HR(free, freeRam);
+			HR(total, totalRam);
+			_LIT8(KFree, "FREE");
+			clogger.Log(KChunkFmt, &KFree, freeRam, &free, totalRam, &total, 0);
+			}
+		break;
+		}
+	case EListProcess:
+		{
+		if (i == 0) clogger.Log(KProcessDesc);
+		TProcessKernelInfo& info = *(TProcessKernelInfo*)aInfo;
+
+		TBuf<16> priority16 = ToString((TProcessPriority)info.iPriority);
+		TPtr8 priority = priority16.Collapse();
+		HBufC* caps16 = ToStringL(info.iProcessSecurityInfo.iCaps);
+		TPtr8 caps(caps16->Des().Collapse());
+		TPtrC exitStatus;
+		TInt exitReason = 0;
+		TExitCategoryName exitCategory;
+		RProcess handle;
+		if (handle.Open(info.iProcessId) == KErrNone)
+			{
+			exitStatus.Set(ToString(handle.ExitType()));
+			exitCategory = handle.ExitCategory();
+			exitReason = handle.ExitReason();
+			handle.Close();
+			}
+		TBuf8<16> exitStatus8;
+		exitStatus8.Copy(exitStatus);
+		TPtrC8 exitCategory8 = exitCategory.Collapse();
+		RBuf creatorName;
+		data->ExeNameForSid(info.iProcessCreatorSecurityInfo.iSecureId, creatorName);
+		TPtrC8 creatorName8 = creatorName.Collapse();
+		TBool fixed = info.iAttributes & 1; // TMemModelProcessAttributes::EFixedAddress
+		_LIT8(KFixed, "FIXED");
+		TPtrC8 fixedPtr = fixed ? KFixed() : KNullDesC8();
+		clogger.Log(KProcessFmt, &info.iFullName, info.iProcessId, info.iPriority, &priority, info.iProcessSecurityInfo.iSecureId, info.iProcessSecurityInfo.iVendorId, info.iProcessCreatorSecurityInfo.iSecureId, &creatorName8, info.iProcessSecurityInfo.iCaps[0], &caps, &exitStatus8, &exitCategory8, exitReason, &fixedPtr, info.iAddressOfKernelObject);
+		creatorName.Close();
+		delete caps16;
+		break;
+		}
+	case EListCodeSeg:
+		{
+		if (i == 0) clogger.Log(KCodesegDesc);
+		TTomsciCodeSegKernelInfo& info = *reinterpret_cast<TTomsciCodeSegKernelInfo*>(aInfo);
+		TBuf8<16> size;
+		HR(size, info.iSize);
+		clogger.Log(KCodesegFmt, &info.iName, info.iSize, &size, info.iAccessCount, info.iDepCount);
+		break;
+		}
+	case EListMimeTypes:
+		{
+		if (i == 0) clogger.Log(KMimeDesc);
+		SDataType& info = *reinterpret_cast<SDataType*>(aInfo);
+		clogger.Log(KMimeFmt, &info.iMime, &info.iRecog, info.iAppUid, &info.iApp);
+		break;
+		}
+	default:
+		break;
+		}
+	}
+
+void CKernListBoxData::InfoForDialogL(RBuf& aTitle, RBuf& aText, TBool aRefresh)
+	{
+	if (aRefresh)
+		{
+		// Figure out our index in the model
+		TInt index = iModel->ItemIdIndex(ItemId());
+		iModel->RefreshDataL(index);
+		}
+
+	aTitle.Zero();
+	aText.Zero();
+
+	if (aTitle.MaxLength() < 256)
+		{
+		aTitle.ReAllocL(256);
+		}
+	if (aText.MaxLength() < 1024)
+		{
+		aText.ReAllocL(1024);
+		}
+
+	RBuf& inf = aText;
+	TBuf<256>* name = new(ELeave) TBuf<256>;
+	CleanupStack::PushL(name);
+	DoInfoForDialogL(aTitle, inf, name);
+	CleanupStack::PopAndDestroy(name);
+	}
+
+void AppendProcessFlags(TDes& aBuf, TUint32 aFlags)
+	{
+	TInt len = aBuf.Length();
+
+	// 9.1/9.2 doesn't have these, it's easier to redefine them to the correct value than make all the code conditional
+	const TUint KThreadFlagRealtime = 0x00000040;
+	const TUint KThreadFlagRealtimeTest = 0x00000080;
+
+#define IF_MATCH(aBuf, aFlags, aFlag) if (aFlags&aFlag) { aBuf.Append(_L( #aFlag )); aBuf.Append('|'); }
+	IF_MATCH(aBuf, aFlags, KThreadFlagProcessCritical)
+	IF_MATCH(aBuf, aFlags, KThreadFlagProcessPermanent)
+	IF_MATCH(aBuf, aFlags, KThreadFlagSystemCritical)
+	IF_MATCH(aBuf, aFlags, KThreadFlagSystemPermanent)
+	IF_MATCH(aBuf, aFlags, KThreadFlagOriginal)
+	IF_MATCH(aBuf, aFlags, KThreadFlagLastChance)
+	IF_MATCH(aBuf, aFlags, KThreadFlagRealtime)
+	IF_MATCH(aBuf, aFlags, KThreadFlagRealtimeTest)
+	IF_MATCH(aBuf, aFlags, KProcessFlagPriorityControl)
+	IF_MATCH(aBuf, aFlags, KProcessFlagJustInTime)
+	if (aBuf.Length() > len)
+		{
+		// Remove trailing |
+		aBuf.SetLength(aBuf.Length() - 1);
+		}
+	}
+
+void CKernListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* aTemp)
+	{
+	TDes* name = aTemp;
+	switch (iType)
+		{
+		case EListProcess:
+			{
+			TProcessKernelInfo& info = *(TProcessKernelInfo*)iInfo;
+			RProcess process;
+			TInt err = process.Open(info.iProcessId);
+			CleanupClosePushL(process);
+
+			_LIT(KInfo, "Process info");
+			aTitle.Copy(KInfo);
+			inf.Copy(iInfo->iFullName);
+			if (!err)
+				{
+				inf.Append(Klf);
+				inf.Append(process.FileName());
+				}
+			if (info.iCommandLine.Length())
+				{
+				inf.Append(' ');
+				//aTemp->Copy(info.iCommandLine);
+				// Command line args are generally 16-bit descriptors even though they're represented in 8-bit kernel-side
+				TPtrC widePtr((const TUint16*)info.iCommandLine.Ptr(), info.iCommandLine.Size()/2);
+				inf.Append(widePtr);
+				}
+
+			//_LIT8(KProcessDesc, "Process\tFullName\tPid\tPriority\t(PriorityHumanReadable)\tSid\tVid\tCapabilities\t(CapsHumanReadable)\tExitStatus\tExitCategory\tExitReason");
+
+			_LIT(KProcess, "\n\nPid: %i %S\nSid: 0x%x Vid: 0x%x");
+			_LIT(KPriority, "\nPriority: %i (%S)");
+			_LIT(KOtherStuff, "\nCreator Sid: 0x%x (%S)\n\nCapabilities: %S");
+			_LIT(KKern, "\nKernel object address: 0x%08x");
+			_LIT(KFlags, "\nFlags: 0x%x (");
+			_LIT(KDied, "\n\nDied with: %S %S %i");
+
+			HBufC* caps = ToStringL(info.iProcessSecurityInfo.iCaps);
+			TUint creatorSid = info.iProcessCreatorSecurityInfo.iSecureId;
+			TBool fixed = info.iAttributes & 1; // TMemModelProcessAttributes::EFixedAddress
+			_LIT(KFixed, "(fixed process)");
+			TPtrC fixedPtr = fixed ? KFixed() : KNullDesC();
+			inf.AppendFormat(KProcess, info.iProcessId, &fixedPtr, info.iProcessSecurityInfo.iSecureId, info.iProcessSecurityInfo.iVendorId);
+			if (!err)
+				{
+				TPtrC priority = ToString(process.Priority());
+				inf.AppendFormat(KPriority, process.Priority(), &priority);
+				}
+			inf.AppendFormat(KKern, info.iAddressOfKernelObject);
+			if (info.iFlags)
+				{
+				inf.AppendFormat(KFlags, info.iFlags);
+				AppendProcessFlags(inf, info.iFlags);
+				inf.Append(')');
+				}
+
+			RBuf parentName;
+			ExeNameForSid(creatorSid, parentName);
+
+			inf.AppendFormat(KOtherStuff, creatorSid, &parentName, caps);
+			delete caps;
+			parentName.Close();
+
+			if (!err && process.ExitType() != EExitPending)
+				{
+				TPtrC exitStatus;
+				TInt exitReason = 0;
+				TExitCategoryName exitCategory;
+				exitStatus.Set(ToString(process.ExitType()));
+				if (process.ExitType() == EExitPanic)
+					{
+					exitCategory = process.ExitCategory();
+					}
+				exitReason = process.ExitReason();
+				inf.AppendFormat(KDied, &exitStatus, &exitCategory, exitReason);
+				}
+			CleanupStack::PopAndDestroy(&process);
+			break;
+			}
+		case EListChunk:
+			{
+			TChunkKernelInfo& info = *(TChunkKernelInfo*)iInfo;
+			_LIT(KInfo, "Chunk info");
+			aTitle.Copy(KInfo);
+			inf.Copy(iInfo->iFullName);
+			inf.Append(Klflf);
+
+			TBuf<16> size, maxSize;
+			HR(size, info.iSize);
+			HR(maxSize, info.iMaxSize);
+
+			RProcess creator;
+			TInt err = creator.Open(info.iControllingOwnerProcessId);
+			if (!err) 
+				{
+				*name = creator.FullName();
+				PrettyName(EListProcess, *name);
+				creator.Close();
+				}
+			_LIT(KKern, "Kernel object address: 0x%08x\n");
+			_LIT(KChunk, "Base: 0x%08x\nSize: %S\nMax Size: %S\nCreator pid: %i (%S)");
+			inf.AppendFormat(KKern, info.iAddressOfKernelObject);
+			inf.AppendFormat(KChunk, info.iBase, &size, &maxSize, info.iControllingOwnerProcessId, name);
+			break;
+			}
+		case EListCodeSeg:
+			{
+			TTomsciCodeSegKernelInfo& info = *reinterpret_cast<TTomsciCodeSegKernelInfo*>(iInfo);
+			_LIT(KInfo, "Code segment info");
+			aTitle.Copy(KInfo);
+			inf.Copy(info.iName);
+			inf.Append(Klflf);
+
+			TBuf<16> size;
+			HR(size, info.iSize);
+			_LIT(KCodesegFmt, "File name: %S\nSize %S\nRef count %i\nDependancy count %i\nRun address 0x%08x");
+			aTemp->Copy(info.iFileName);
+			inf.AppendFormat(KCodesegFmt, aTemp, &size, info.iAccessCount, info.iDepCount, info.iRunAddress);
+			break;
+			}
+		case EListMimeTypes:
+			{
+			SDataType& info = *reinterpret_cast<SDataType*>(iInfo);
+			_LIT(KInfo, "Mime type info");
+			aTitle.Copy(KInfo);
+
+			inf.AppendFormat(_L("%S\n\n%S\nApp UID: 0x%x\n%S"), &info.iMime, &info.iRecog, info.iAppUid, &info.iApp);
+			break;
+			}
+		default:
+			break;
+		}
+	}
+
+void CKernListBoxModel::SummaryInfoL(TDes& aBuf)
+	{
+	switch (iCurrentList)
+		{
+		case EListProcess:
+			{
+			_LIT(KFmt, "%i processes");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListThread:
+			{
+			_LIT(KFmt, "%i threads");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListChunk:
+			{
+			_LIT(KFmt, "%i chunks, free %S/%S");
+			TInt freeRam = -1, totalRam = -1;
+			TBuf<16> free, total;
+			HAL::Get(HAL::EMemoryRAMFree, freeRam);
+			HAL::Get(HAL::EMemoryRAM, totalRam);
+			HR(free, freeRam);
+			HR(total, totalRam);
+			aBuf.Format(KFmt, Count(), &free, &total);
+			break;
+			}
+		case EListCodeSeg:
+			{
+			_LIT(KFmt, "%i code segments");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListHal:
+			{
+			_LIT(KFmt, "%i HAL attributes");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListWindowGroups:
+			{
+			_LIT(KFmt, "%i window groups");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListMimeTypes:
+			{
+			_LIT(KFmt, "%i mime types");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListOpenFiles:
+			{
+			_LIT(KFmt, "%i open files");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListFeatureReg:
+			{
+			_LIT(KFmt, "%i features in registry");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListServer:
+			{
+			_LIT(KFmt, "%i servers");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListMessageQueue:
+			{
+			_LIT(KFmt, "%i message queues");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListMutex:
+			{
+			_LIT(KFmt, "%i mutexes");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListSemaphore:
+			{
+			_LIT(KFmt, "%i semaphores");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		case EListTimer:
+			{
+			_LIT(KFmt, "%i timers");
+			aBuf.Format(KFmt, Count());
+			break;
+			}
+		default:
+			break;
+		}
+	}
+
+TBool CKernListBoxData::SupportsCommand(TInt aCommand)
+	{
+	switch (aCommand)
+		{
+		case ECmdPoll:
+		case ECmdHandleInfo:
+			{
+			if (iType == EListProcess || iType == EListChunk) return ETrue;
+			break;
+			}
+		case ECmdKill:
+			{
+			if (iType == EListProcess) return ETrue;
+			break;
+			}
+		default:
+			break;
+		}
+	return EFalse;
+	}
+
+void CKernListBoxData::KillL()
+	{
+	TUint8* addr = iInfo->iAddressOfKernelObject;
+	RMemoryAccess& mem = iModel->MemAccess();
+	User::LeaveIfError(mem.ObjectDie(iType == EListThread ? EThread : EProcess, 0, addr, EExitKill, 666999, KNullDesC));
+	// The undertaker should cause an update via ThreadDiedL
+	}
+
+TAny* CKernListBoxData::GetHandleL()
+	{
+	return iInfo->iAddressOfKernelObject;
+	}
+
+TInt CKernListBoxData::ExeNameForSid(TUint aSid, RBuf& aName)
+	{
+	// First try our list
+	TInt lserr = KErrNotFound;
+	if (aName.Create(256) != KErrNone) lserr = KErrNoMemory;
+	if (iModel && aName.MaxLength())
+		{
+		for (TInt i = 0; i < iModel->iItemData.Count(); i++)
+			{
+			CKernListBoxData* data = static_cast<CKernListBoxData*>(iModel->iItemData[i]);
+			TProcessKernelInfo* pinfo = static_cast<TProcessKernelInfo*>(data->iInfo);
+			if (data->iType == EListProcess && pinfo->iProcessSecurityInfo.iSecureId == aSid)
+				{
+				lserr = KErrNone;
+				aName.Copy(pinfo->iName);
+				PrettyName(EListProcess, aName);
+				break;
+				}
+			}
+		}
+#ifdef FSHELL_APPARC_SUPPORT
+	if (lserr == KErrNotFound)
+		{
+		// Didn't find the process in our process list. Must have already closed. Try
+		// apparc as a fallback - will only work for fully-fledged applications
+		RApaLsSession ls;
+		TInt lserr = ls.Connect();
+		TApaAppInfo* appinfo = new TApaAppInfo;
+		if (!appinfo ) lserr = KErrNoMemory;
+		if (!lserr)
+			{
+			lserr = ls.GetAppInfo(*appinfo , TUid::Uid(aSid));
+			}
+		if (!lserr)
+			{
+			TInt slash = appinfo->iFullName.LocateReverse('\\');
+			aName.Copy(appinfo->iFullName.Mid(slash+1));
+			}
+		delete appinfo;
+		ls.Close();
+		}
+#endif
+
+	if (aName.Length() == 0 && aSid == 0x10205c44)
+		{
+		// Special case this because sysstart isn't running & isn't an app, and appears
+		// enough as parent to be worth special-casing
+		aName.Copy(_L("SysStart"));
+		lserr = KErrNone;
+		}
+	return lserr;
+	}
+
+void CKernListBoxModel::ThreadDiedL(TInt aHandle)
+	{
+	RThread thread;
+	thread.SetHandle(aHandle);
+	TThreadId id = thread.Id();
+	iThreadHandleArray.Append(aHandle);
+
+	if (iCurrentList == EListThread)
+		{
+		TInt idx = ItemIdIndex(id);
+		if (idx != KErrNotFound)
+			{
+			ModelBeginUpdateLC();
+			CKernListBoxData* data = static_cast<CKernListBoxData*>(iItemData[idx]);
+			data->FormatL(data->iInfo, iTempBuf1, iTempBuf2); // Thread death info isn't stored in iInfo, so no need to update it
+			DataUpdatedL(idx);
+			ModelEndUpdateL();
+
+			if (iInfoChangedCallback.iFunction != NULL && data == iCallbackData)
+				{
+				iInfoChangedCallback.CallBack();
+				}
+
+			}
+		else
+			{
+			// We don't have an entry for this thread id. Oh well, just storing it in the tid list will guarantee it will still be there when the user hits refresh
+			}
+		}
+	else if (iCurrentList == EListProcess)
+		{
+		RProcess p;
+		if (thread.Process(p) == KErrNone)
+			{
+			TProcessId id = p.Id();
+			TInt idx = ItemIdIndex(id);
+			p.Close();
+			if (idx != KErrNotFound)
+				{
+				ModelBeginUpdateLC();
+				CKernListBoxData* data = static_cast<CKernListBoxData*>(iItemData[idx]);
+				data->FormatL(data->iInfo, iTempBuf1, iTempBuf2); // Process death info isn't stored in iInfo, so no need to update it
+				DataUpdatedL(idx);
+				ModelEndUpdateL();
+				if (iInfoChangedCallback.iFunction != NULL && data == iCallbackData)
+					{
+					iInfoChangedCallback.CallBack();
+					}
+
+				}
+			}
+		}
+	}
+
+void CKernListBoxModel::CloseAllThreadHandles()
+	{
+	for (TInt i = 0; i < iThreadHandleArray.Count(); i++)
+		{
+		RThread t;
+		t.SetHandle(iThreadHandleArray[i]);
+		t.Close();
+		}
+	iThreadHandleArray.Reset();
+	}
+
+CKernListBoxModel::~CKernListBoxModel()
+	{
+	CloseAllThreadHandles();
+	delete iUnd;
+#ifdef FSHELL_WSERV_SUPPORT
+	if (iWsSession)
+		{
+		iWsSession->Close();
+		delete iWsSession;
+		}
+#endif
+	iTempBuf1.Close();
+	iTempBuf2.Close();
+
+	for (TInt i = iItemData.Count()-1; i >= 0; i--)
+		{
+		iItemData[i]->Close();
+		}
+	iItemData.Close();
+	}
+
+CUndertaker::CUndertaker(CKernListBoxModel& aModel)
+	: CActive(EPriorityStandard), iModel(aModel)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CUndertaker::~CUndertaker()
+	{
+	Cancel();
+	iUnd.Close();
+	}
+
+void CUndertaker::Register()
+	{
+	TInt err = KErrNone;
+	if (!iUnd.Handle())
+		{
+		err = iUnd.Create();
+		}
+	if (!err)
+		{
+		iUnd.Logon(iStatus, iHandle);
+		SetActive();
+		}
+	}
+
+void CUndertaker::RunL()
+	{
+	if (iStatus == KErrDied)
+		{
+		iModel.ThreadDiedL(iHandle);
+		Register();
+		}
+	}
+
+void CUndertaker::DoCancel()
+	{
+	iUnd.LogonCancel();
+	}
+
+void CKernListBoxModel::RefreshDataL(TInt aIndex)
+	{
+	if (iCurrentList == EListWindowGroups && !iWsSession)
+		{
+		User::Leave(KErrNotSupported);
+		}
+
+	// Change some names so the code is the same
+	RMemoryAccess& mem(iMemAccess);
+	CKernListBoxModel& model(*this);
+
+	if (iCurrentList == EListCodeSeg)
+		{
+		// Code segs don't support random access
+		aIndex = -1;
+		}
+
+	if (aIndex == -1)
+		{
+		model.RemoveAllDataL();
+		}
+	model.ModelBeginUpdateLC();
+	
+	TObjectType type = EProcess; // Just set it to something to shut up compiler
+	switch (iCurrentList) {
+	case EListProcess: type = EProcess; break;
+	case EListThread: type = EThread; break;
+	case EListChunk: type = EChunk; break;
+	case EListServer: type = EServer; break;
+	case EListMessageQueue: type = EMsgQueue; break;
+	case EListMutex: type = EMutex; break;
+	case EListSemaphore: type = ESemaphore; break;
+	case EListTimer: type = ETimer; break;
+	default: break;
+		}
+
+	TPtr8 buf(0,0);
+	TObjectKernelInfo* info = NULL;
+	CKernListBoxData* data = NULL;
+	if (aIndex != -1)
+		{
+		data = static_cast<CKernListBoxData*>(model.RetrieveDataL(aIndex));
+		CleanupClosePushL(*data);
+		}
+
+	if (iCurrentList == EListCodeSeg)
+		{
+		mem.AcquireCodeSegMutex();
+		TTomsciCodeSegKernelInfo* inf = new(ELeave) TTomsciCodeSegKernelInfo;
+		info = reinterpret_cast<TObjectKernelInfo*>(inf); // These aren't actually related classes, just convenient
+		buf.Set(TPckg<TTomsciCodeSegKernelInfo>(*inf));
+		while (mem.GetNextCodeSegInfo(buf) == KErrNone)
+			{
+			TRAPD(err, model.NewKernDataL(iCurrentList, info));
+			if (err)
+				{
+				break;
+				}
+			inf = NULL;
+			inf = new(ELeave) TTomsciCodeSegKernelInfo;
+			buf.Set(TPckg<TTomsciCodeSegKernelInfo>(*inf));
+			info = reinterpret_cast<TObjectKernelInfo*>(inf); // These aren't actually related classes, just convenient
+			}
+		delete inf;
+		mem.ReleaseCodeSegMutex();
+		}
+	else if (iCurrentList == EListHal)
+		{
+		// HAL isn't actually a kernel container type but from the PoV of this app it is treated similarly
+		//HAL::SEntry* entry = new(ELeave) HAL::SEntry;
+		if (aIndex == -1)
+			{
+			HAL::SEntry* ents = NULL;
+			TInt numEntries = 0;
+			User::LeaveIfError(HAL::GetAll(numEntries, ents));
+			CleanupDeletePushL(ents);
+			for (TInt i = 0; i < numEntries; i++)
+				{
+				SHalInfo* entry = new(ELeave) SHalInfo;
+				entry->iProperties = ents[i].iProperties;
+				entry->iValue = ents[i].iValue;
+				entry->iAttribute = i;
+				CleanupDeletePushL(entry);
+				model.NewKernDataL(iCurrentList, reinterpret_cast<TObjectKernelInfo*>(entry));
+				CleanupStack::Pop(entry);
+				}
+			CleanupStack::PopAndDestroy(ents);
+			}
+		else
+			{
+			SHalInfo* entry = reinterpret_cast<SHalInfo*>(data->iInfo);
+			/*TInt err =*/ HAL::Get((HAL::TAttribute)entry->iAttribute, entry->iValue); // Nothing needs to be done if this fails
+			}
+		}
+	else if (iCurrentList == EListWindowGroups)
+		{
+#if defined(FSHELL_WSERV_SUPPORT) && defined(FSHELL_APPARC_SUPPORT)
+		if (aIndex == -1)
+			{
+			CArrayFixFlat<TInt>* wgIds = new(ELeave) CArrayFixFlat<TInt>(16);
+			CleanupStack::PushL(wgIds);
+			User::LeaveIfError(iWsSession->WindowGroupList(0, wgIds));
+			TInt numEntries = wgIds->Count();
+			for (TInt i = 0; i < numEntries; i++)
+				{
+				TInt handle = (*wgIds)[i];
+				CApaWindowGroupName* name = CApaWindowGroupName::NewLC(*iWsSession, handle);
+				SWgInfo* info = new(ELeave) SWgInfo;
+				CleanupStack::PushL(info);
+				info->iHandle = handle;
+				info->iName = name;
+				info->iSession = iWsSession;
+				model.NewKernDataL(iCurrentList, reinterpret_cast<TObjectKernelInfo*>(info));
+				CleanupStack::Pop(2, name); // info, name
+				}
+			CleanupStack::PopAndDestroy(wgIds);
+			}
+		else
+			{
+			SWgInfo* info = reinterpret_cast<SWgInfo*>(data->iInfo);
+			info->iName->ConstructFromWgIdL(info->iHandle);
+			}
+#endif
+		}
+	else if (iCurrentList == EListMimeTypes)
+		{
+		if (aIndex == -1)
+			{
+#ifdef FSHELL_APPARC_SUPPORT
+			RApaLsSession apparc;
+			User::LeaveIfError(apparc.Connect());
+			CleanupClosePushL(apparc);
+			RImplInfoPtrArray array;
+			CleanupResetAndDestroyPushL(array);
+			REComSession::ListImplementationsL(TUid::Uid(0x101F7D87), array); // Recognisers ECOM interface UID
+			TFileName* dllNamePtr = new(ELeave)TFileName;
+			CleanupStack::PushL(dllNamePtr);
+			TFileName& dllName = *dllNamePtr;
+			RArray<TDataType> mimeTypes;
+			CleanupClosePushL(mimeTypes);
+			gPlugin->DisablePanicCheckPushL();
+			for (TInt i = 0; i < array.Count(); i++)
+				{
+				dllName = _L("UnknownDll");
+				
+				TRAP_IGNORE(Sandbox::GetDllNameFromEcomUidL(mem, array[i]->ImplementationUid(), dllName));
+				mimeTypes.Reset();
+				Sandbox::GetRecogniserInfoL(array[i]->ImplementationUid(), mimeTypes);
+
+				TInt count = mimeTypes.Count();
+				for (TInt j = 0; j < count; j++)
+					{
+					SDataType* info = new(ELeave) SDataType;
+					CleanupStack::PushL(info);
+					info->iMime.Copy(mimeTypes[j].Des8());
+					info->iRecog = dllName;
+					
+					TInt err = apparc.AppForDataType(mimeTypes[j], info->iAppUid);
+					if (!err)
+						{
+						TApaAppInfo appInfo;
+						err = apparc.GetAppInfo(appInfo, info->iAppUid);
+						if (!err)
+							{
+							info->iApp = appInfo.iFullName;
+							}
+						}
+					model.NewKernDataL(iCurrentList, reinterpret_cast<TObjectKernelInfo*>(info));
+					CleanupStack::Pop(info);
+					}
+				}
+			CleanupStack::PopAndDestroy(); // reenables panic checks
+			CleanupStack::PopAndDestroy(4, &apparc); // mimeTypes, dllNamePtr, array, apparc
+#else
+			User::Leave(KErrNotSupported);
+#endif
+			}
+		else
+			{
+			// No refreshing necessary for mime types
+			}
+		}
+	else if (iCurrentList == EListOpenFiles)
+		{
+		if (aIndex == -1)
+			{
+			RPtrHashMap<TDesC, SOpenFile> fileMap;
+			CleanupClosePushL(fileMap);
+			RFs fs;
+			User::LeaveIfError(fs.Connect());
+			CleanupClosePushL(fs);
+			TOpenFileScan scan(fs);
+			CFileList* fileList = NULL;
+			FOREVER
+				{
+				scan.NextL(fileList);
+				if (fileList == NULL)
+					{
+					break;
+					}
+				CleanupStack::PushL(fileList);
+				const TInt numOpenFiles = fileList->Count();
+				for (TInt i = 0; i < numOpenFiles; i++)
+					{
+					const TEntry& entry = (*fileList)[i];
+					// See if we already have an SOpenFile for this filename
+					SOpenFile* info = fileMap.Find(entry.iName);
+					if (info)
+						{
+						if (info->iNumThreads < info->iThreadIds.Count())
+							{
+							info->iThreadIds[info->iNumThreads] = scan.ThreadId();
+							}
+						info->iNumThreads++; // Increment iNumThreads regardless - so we can see how many threads there actually are, rather than how many we can store
+						CKernListBoxData* data = static_cast<CKernListBoxData*>(model.RetrieveDataLC(model.ItemIdIndex((TInt)info)));
+						data->FormatL(reinterpret_cast<TObjectKernelInfo*>(info), iTempBuf1, iTempBuf2); // now we've updated the number of threads, that will have changed the Format view
+						CleanupStack::PopAndDestroy(data);
+						}
+					else
+						{
+						SOpenFile* info = new(ELeave) SOpenFile;
+						CleanupStack::PushL(info);
+						info->iName = entry.iName;
+						info->iNumThreads = 1;
+						info->iThreadIds[0] = scan.ThreadId();
+						model.NewKernDataL(iCurrentList, reinterpret_cast<TObjectKernelInfo*>(info));
+						CleanupStack::Pop(info);
+						fileMap.InsertL(&info->iName, info);
+						}
+					}
+				CleanupStack::PopAndDestroy(fileList);
+				fileList = NULL;
+				}
+			CleanupStack::PopAndDestroy(2, &fileMap); // fileMap, fs
+			}
+		else
+			{
+			// No refreshing possible for open files
+			}
+		}
+	else if (iCurrentList == EListFeatureReg)
+		{
+		// Can't link directly against featreg.dll because it doesn't exist on generic 9.1
+		RLibrary featLib;
+		TInt err = featLib.Load(_L("featreg.dll"));
+		if (err) return; // No feature registry, no features!
+
+		#ifdef __WINS__
+			#define KQueryOrdinal 9
+		#else
+			#define KQueryOrdinal 4
+		#endif
+
+		typedef TInt (*QueryFn)(TUid, TUint32&);
+		QueryFn Query = (QueryFn)featLib.Lookup(KQueryOrdinal);
+
+		if (aIndex == -1)
+			{
+			RArray<TUid> features;
+			CleanupClosePushL(features);
+			gPlugin->GetFeatureUidsL(features);
+
+			for (TInt i = 0; i < features.Count(); i++)
+				{
+				SFeature* info = new(ELeave) SFeature;
+				CleanupStack::PushL(info);
+				info->iFeature = features[i].iUid;
+				info->iErr = Query(features[i], info->iInfo);
+				model.NewKernDataL(iCurrentList, reinterpret_cast<TObjectKernelInfo*>(info));
+				CleanupStack::Pop(info);
+				}
+			CleanupStack::PopAndDestroy(&features);
+			}
+		else
+			{
+			SFeature* info = reinterpret_cast<SFeature*>(data->iInfo);
+			info->iErr = Query(TUid::Uid(info->iFeature), info->iInfo);
+			}
+		featLib.Close();
+		}
+	else
+		{
+		// Generic code that works for all first-class Kernel objects (ie processes, threads, chunks. Despite appearances, code segs are not first-class kernel objects).
+
+		TInt sizeofObjectBuf = 0;
+		switch(iCurrentList)
+			{
+			case EListProcess:
+				sizeofObjectBuf = sizeof(TProcessKernelInfo); break;
+			case EListThread:
+				sizeofObjectBuf = sizeof(TThreadKernelInfo); break;
+			case EListChunk:
+				sizeofObjectBuf = sizeof(TChunkKernelInfo); break;
+			case EListServer:
+				sizeofObjectBuf = sizeof(TServerKernelInfo); break;
+			case EListMessageQueue:
+				sizeofObjectBuf = sizeof(TMsgQueueKernelInfo); break;
+			case EListMutex:
+				sizeofObjectBuf = sizeof(TMutexKernelInfo); break;
+			case EListSemaphore:
+				sizeofObjectBuf = sizeof(TSemaphoreKernelInfo); break;
+			case EListTimer:
+				sizeofObjectBuf = sizeof(TTimerKernelInfo); break;
+			default:
+				User::Panic(_L("QR3 Missing type"), iCurrentList);
+			}
+
+		if (aIndex == -1)
+			{
+			// Be paranoid about releasing the mutexes, to avoid the risk of deadlocking. Only likely if we were looking through the chunk container AND needed to grow our chunk in NewKernDataL, but err on the side of caution
+			//mem.AcquireContainerMutex(type);
+			TUint count;
+			mem.GetContainerCount(type, count);
+			//mem.ReleaseContainerMutex(type);
+			for (TUint i = 0; i < count; i++)
+				{
+				info = (TObjectKernelInfo*)User::AllocZL(sizeofObjectBuf);
+				buf.Set((TUint8*)info, sizeofObjectBuf, sizeofObjectBuf);
+
+				CleanupStack::PushL(info);
+				// Don't need to grab the lock any more
+				//mem.AcquireContainerMutex(type);
+				TInt err = mem.GetObjectInfo(type, i, buf);
+				//mem.ReleaseContainerMutex(type);
+				if (err == KErrNone)
+					{
+					model.NewKernDataL(iCurrentList, info);
+					CleanupStack::Pop(info);
+					}
+				else
+					{
+					CleanupStack::PopAndDestroy(info);
+					}
+				}
+			}
+		else
+			{
+			buf.Set((TUint8*)data->iInfo, sizeofObjectBuf, sizeofObjectBuf);
+			mem.GetObjectInfo(type, data->iInfo->iAddressOfKernelObject, buf); // Nothing required on error
+			}
+		}
+	
+	if (aIndex != -1)
+		{
+		data->FormatL(data->iInfo, iTempBuf1, iTempBuf2);
+		model.DataUpdatedL(aIndex);
+		CleanupStack::PopAndDestroy(data);
+		}
+	model.Sort(); // We can't do this in NewKernDataL because the things we sort on aren't setup until FormatL
+	model.ModelEndUpdateL();
+
+	if (iInfoChangedCallback.iFunction != NULL && (aIndex == -1 || data == iCallbackData))
+		{
+		iInfoChangedCallback.CallBack();
+		}
+	}
+
+void CKernListBoxModel::Sort(TLinearOrder<CKernListBoxData> aOrder)
+	{
+	iSort = aOrder;
+	Sort();
+	}
+
+void CKernListBoxModel::Sort()
+	{
+	if (iSort)
+		{
+		User::QuickSort(Count(), *this, *this);
+		}
+	}
+
+void CKernListBoxModel::SetInfoChangedCallback(TInt aIndex, const TCallBack& aCallback)
+	{
+	iInfoChangedCallback = aCallback;
+	if (aCallback.iFunction)
+		{
+		iCallbackData = iItemData[aIndex];
+		iCallbackData->Open();
+		}
+	else
+		{
+		iCallbackData->Close();
+		iCallbackData = NULL;
+		}
+	}
+
+void CKernListBoxData::Open()
+	{
+	iRefCount++;
+	}
+
+void CKernListBoxData::Close()
+	{
+	iRefCount--;
+	if (iRefCount == 0)
+		delete this;
+	}
+
+void CKernListBoxData::SetDelegate(MKernListBoxDataDelegate* aDelegate)
+	{
+	iDelegate = aDelegate;
+	}
+
+MKernListBoxDataDelegate* CKernListBoxData::Delegate()
+	{
+	return iDelegate;
+	}
+
+const MKernListBoxDataDelegate* CKernListBoxData::Delegate() const
+	{
+	return iDelegate;
+	}
+
+TInt CKernListBoxData::ItemId() const
+	{
+	return iItemId;
+	}
+
+void CKernListBoxData::SetItemId(TInt aItemId)
+	{
+	iItemId = aItemId;
+	}
+
+void CKernListBoxData::ConstructL()
+	{
+	}
+
+CKernListBoxModel& CKernListBoxData::Model()
+	{
+	return *iModel;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/LoggingAllocator.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,515 @@
+// LoggingAllocator.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/LoggingAllocator.h>
+#include <fshell/extrabtrace.h>
+//#include <e32debug.h>
+
+//#define LOG(args...) RDebug::Printf(args)
+#define LOG(args...)
+
+// Subcategories for use with BTrace::ETest1 when EOldFormatLogging is defined
+enum TSubCategories
+	{
+	EAlloc,
+	EAllocCont,
+	EAllocHeaven, // AllocHeaven means "This cell has leaked"
+	EAllocHeavenData,
+	EFree,
+	EFreeCont,
+	EFreeCellCorrupted,
+	};
+
+const TInt KHeapCategory = 14; // BTrace::EHeap
+enum THeap
+	{
+	EHeapCreate,
+	EHeapChunkCreate,
+	EHeapAlloc,
+	EHeapReAlloc,
+	EHeapFree,
+	// My additions go after this
+	ELoggingAllocatorInstalled = 128,
+	EHeapPrimingFinished,
+	EHeapExtendedAlloc,
+	EHeapExtendedFree,
+	EHeapExtendedRealloc,
+	};
+
+const TInt KUidUninstallLoggingAllocator = 0x10285BAB;
+const TInt KMaxDeferredFrees = 100;
+
+RLoggingAllocator::RLoggingAllocator(TUint aFlags)
+	: RAllocator(), iA(NULL), iBreakOnAllocCount(0), iFlags(aFlags)
+	{
+	if (iFlags & EDeferFree) iFlags |= EScribbleFrees; // The only reason (currently) why you defer them is to do the check, which requires them to be scribbled
+	iPid = RProcess().Id(); // Cache this to save a few exec calls
+	}
+
+void RLoggingAllocator::Free(TAny* aPtr)
+	{
+	if (!aPtr) return; // Don't care about tracing attempts to free the null pointer (this is what rheap does too)
+	TraceFree(iA, aPtr);
+	TInt allocLen = AllocLen(aPtr);
+
+	if (iFlags & EScribbleFrees)
+		{
+		// Don't scribble after calling free - the heap might have been shrunk meaning we'd crash
+		memset(aPtr, 0xDF, allocLen);
+		}
+	if (iFlags & EDeferFree)
+		{
+		CheckDeferredFrees();
+		iLock.Wait();
+		if (iDeferredFrees.Count() == KMaxDeferredFrees)
+			{
+			iA->Free(iDeferredFrees[0].iPtr);
+			iDeferredFrees.Remove(0);
+			}
+		SDeferredFreeCell cell = {aPtr, allocLen};
+		iDeferredFrees.Append(cell); // Can't fail because we preallocate the memory
+		iLock.Signal();
+		}
+	else
+		{
+		iA->Free(aPtr);
+		}
+
+	if (iFlags & EOldFormatLogging)
+		{
+		BTrace8(KHeapCategory, EHeapFree, iA, aPtr);
+		}
+	}
+
+TAny* RLoggingAllocator::Alloc(TInt aSize)
+	{
+	CheckDeferredFrees();
+	TAny* cellPtr = iA->Alloc(aSize);
+	TraceAlloc(iA, cellPtr, aSize);
+	if (cellPtr && (iFlags & EOldFormatLogging))
+		{
+		TUint32 remainder[] = { AllocLen(cellPtr), aSize };
+		BTraceN(KHeapCategory, EHeapAlloc, iA, cellPtr, remainder, sizeof(remainder));
+		}
+	return cellPtr;
+	}
+
+void RLoggingAllocator::DoTraceAllocEvent(RAllocator* aAllocator, TAny* aCellPtr, TInt aAllocEvent, TInt aRequestedSize, TAny* aOldPtr)
+	{
+	// Important we don't reference iA in this function, only aAllocator
+	TUint32 t = 0;
+	TUint32* sp = &t;
+	TThreadStackInfo stackInfo;
+	TInt err = RThread().StackInfo(stackInfo);
+	if (err == KErrNone && (iFlags & EOldFormatLogging))
+		{
+		if (aAllocEvent != EHeapAlloc && aAllocEvent != EHeapFree) return; // We don't do stacktraces for reallocs in the old format
+		TBuf8<KMaxBTraceDataArray> buf;
+		const TInt KNumBtraceFrames = 2;
+		for (TInt i = 0; i < KNumBtraceFrames; ++i)
+			{
+			while (((TUint32)sp < (TUint32)stackInfo.iBase) && (buf.Size() <= (buf.MaxSize() - 4)))
+				{
+				if ((*sp >= 0x70000000) && (*sp <= 0x8fffffff)) // Is this a valid ROM or RAM address? Note, the address ranges are for the 2GB EKA2 memory map.
+					{
+					buf.Append(TPtrC8((TUint8*)sp, 4));
+					}
+				++sp;
+				}
+			if (buf.Size() > 0)
+				{
+				TUint8 subcat = (aAllocEvent == EHeapAlloc) ? EAlloc : EFree;
+				BTraceN(BTrace::ETest1, i == 0 ? subcat : subcat+1, (TUint)RThread().Id().Id(), aCellPtr, buf.Ptr(), buf.Size());
+				buf.Zero();
+				}
+			}
+		buf.FillZ(); // To avoid leaving a bunch of addresses kicking around on the stack to be misinterpretted later on.
+		}
+	else if (err == KErrNone)
+		{
+		// New format
+		const TInt KBufSize = 160;
+		TUint8 buf[KBufSize];
+		TUint32* ptr = (TUint32*)buf;
+		TUint32 const*const end = (TUint32*)(buf + KBufSize);
+		// uint 0 is aAllocator, argument a1 to BTraceBig below
+		*(ptr++) = (TLinAddr)aCellPtr; // uint 1
+		TBool alreadyFreed = (aAllocEvent == EHeapFree && aRequestedSize == -1); // Can't call AllocLen on a freed cell (we only catch the frees from ReAlloc after the cell's already been deallocated)
+		 // uint 2 is cell size, unless it's not a valid cell in which case it's zero (for a failed NULL alloc) or -1 for a free that's already been freed
+		if (alreadyFreed)
+			{
+			*(ptr++) = 0xFFFFFFFFu;
+			}
+		else if (aCellPtr == NULL)
+			{
+			*(ptr++) = 0;
+			}
+		else
+			{
+			*(ptr++) = aAllocator->AllocLen(aCellPtr);
+			}
+		*(ptr++) = (aAllocEvent == EHeapFree) ? 0xFFFFFFFFu : aRequestedSize; // uint 3
+		*(ptr++) = (TUint)RThread().Id(); // uint 4
+		*(ptr++) = iPid; // uint 5
+		if (aAllocEvent == EHeapReAlloc) *(ptr++) = (TUint)aOldPtr; // uint 6, for reallocs only
+		while (((TUint32)sp < (TUint32)stackInfo.iBase) && ptr != end)
+			{
+			TUint addr = *sp;
+			if ((addr >= 0x70000000) && (addr <= 0x8fffffff)) // Is this a valid ROM or RAM address? Note, the address ranges are for the 2GB EKA2 memory map.
+				{
+				*(ptr++) = addr;
+				}
+			sp++;
+			}
+		TUint8 subcat;
+		switch (aAllocEvent)
+			{
+			case EHeapAlloc: subcat = EHeapExtendedAlloc; break;
+			case EHeapFree: subcat = EHeapExtendedFree; break;
+			case EHeapReAlloc: subcat = EHeapExtendedRealloc; break;
+			default:
+				return; // Shouldn't get this
+			}
+		BTraceBig(KHeapCategory, subcat, aAllocator, buf, (TLinAddr)ptr - (TLinAddr)buf);
+		Mem::FillZ(buf, KBufSize); // To avoid leaving a bunch of addresses kicking around on the stack to be misinterpretted later on.
+		}
+
+#ifdef _DEBUG
+	if (iBreakOnAllocCount && iHelper.AllocCountForCell(aCellPtr) == iBreakOnAllocCount)
+		{
+		iBreakOnAllocCount = *&iBreakOnAllocCount; // Something to break on
+		}
+#endif
+	}
+
+EXPORT_C void RLoggingAllocator::StaticTraceAlloc(RAllocator* aAllocator, TAny* aCellPtr, TInt aRequestedSize)
+	{
+	RLoggingAllocator(0).TraceAlloc(aAllocator, aCellPtr, aRequestedSize);
+	//if (iFlags & EOldFormatLogging)
+	//	{
+	//	TUint32 remainder[] = { aAllocator->AllocLen(aCellPtr), aRequestedSize };
+	//	BTraceN(KHeapCategory, EHeapAlloc, aAllocator, aCellPtr, remainder, sizeof(remainder));
+	//	}
+	}
+
+EXPORT_C void RLoggingAllocator::StaticTraceFree(RAllocator* aAllocator, TAny* aCellPtr)
+	{
+	RLoggingAllocator(0).TraceFree(aAllocator, aCellPtr);
+	//if (iFlags & EOldFormatLogging)
+	//	{
+	//	BTrace8(KHeapCategory, EHeapFree, aAllocator, aCellPtr);
+	//	}
+	}
+
+TAny* RLoggingAllocator::ReAlloc(TAny* aPtr, TInt aSize, TInt aMode)
+	{
+	TAny* res = iA->ReAlloc(aPtr, aSize, aMode);
+	if (res != aPtr)
+		{
+		// If the realloc has actually reallocated, we need to trace the free, to be compatible with how RHeap does it.
+		if (res && aPtr)
+			{
+			// It is technically legal to call ReAlloc passing in a null pointer - it behaves the same as alloc
+			TraceFree(iA, aPtr, ETrue);
+			if (iFlags & EOldFormatLogging)
+				{
+				BTrace8(KHeapCategory, EHeapFree, iA, aPtr);
+				}
+			}
+		}
+	TraceRealloc(res, aPtr, aSize);
+	if (res && (iFlags & EOldFormatLogging))
+		{
+		TUint32 remainder [] = { AllocLen(res), aSize, (TUint32)aPtr };
+		BTraceN(KHeapCategory, EHeapReAlloc, iA, res, remainder, sizeof(remainder));
+		}
+	return res;
+	}
+
+TInt RLoggingAllocator::AllocLen(const TAny* aCell) const
+	{
+	return iA->AllocLen(aCell);
+	}
+
+TInt RLoggingAllocator::Compress()
+	{
+	return iA->Compress();
+	}
+
+void RLoggingAllocator::Reset()
+	{
+	iA->Reset();
+	}
+
+TInt RLoggingAllocator::AllocSize(TInt& aTotalAllocSize) const
+	{
+	return iA->AllocSize(aTotalAllocSize);
+	}
+
+TInt RLoggingAllocator::Available(TInt& aBiggestBlock) const
+	{
+	return iA->Available(aBiggestBlock);
+	}
+
+
+TInt RLoggingAllocator::DebugFunction(TInt aFunc, TAny* a1, TAny* a2)
+	{
+	LOG("LA: DebugFunction %d", aFunc);
+	if (aFunc == RAllocator::EMarkEnd)
+		{
+		// First we need to work out the nesting level of the underlying heap, even though we don't have a pointer
+		// to said underlying heap. So allocate a cell, and pull the nest level out from there.
+		// If that returns an error, it's not a udeb heap so we don't continue
+		TAny* testAlloc = iA->Alloc(4);
+		if (testAlloc)
+			{
+			TInt nestingLevel;
+			TInt err = iHelper.GetCellNestingLevel(testAlloc, nestingLevel);
+			iA->Free(testAlloc);
+			if (!err)
+				{
+				LOG("LA: Doing walk, nestinglevel = %d", nestingLevel);
+				iHelper.Walk(&HeavenWalk, (TAny*)nestingLevel);
+				// It doesn't actually matter what Walk returns, either the data got written or it didn't
+				}
+			}
+		
+		// Actually do the real markEnd that does more than just output the allocHeavens
+		return iA->DebugFunction(aFunc, a1, a2);
+		}
+#ifndef __KERNEL_MODE__
+	else if (aFunc == KUidUninstallLoggingAllocator)
+		{
+		RAllocator* current = &User::Allocator();
+		if (current == this)
+			{
+			User::SwitchAllocator(iA);
+			Destroy();
+			return KErrNone;
+			}
+		else
+			{
+			return KErrNotFound;
+			}
+		}
+#endif
+	else if (aFunc == KTempDisableLogging)
+		{
+		RAllocator** result = (RAllocator**)a1;
+		*result = &User::Allocator();
+		User::SwitchAllocator(iA);
+		return KErrNone;
+		}
+	else
+		{
+		return iA->DebugFunction(aFunc, a1, a2);
+		}
+	}
+
+TBool RLoggingAllocator::TraceExistingAllocs(TAny* aContext, RAllocatorHelper::TCellType aType, TLinAddr aCell, TInt aLen)
+	{
+	RLoggingAllocator* self = (RLoggingAllocator*)aContext;
+	if (aType == RAllocatorHelper::EAllocation)
+		{
+		TAny* cellPtr = (TAny*)aCell;
+		if (self->iFlags & EOldFormatLogging)
+			{
+			TUint32 remainder[] = { aLen, aLen };
+			BTraceN(KHeapCategory, EHeapAlloc, self->iA, cellPtr, remainder, sizeof(remainder));
+			}
+		else
+			{
+			TUint32 remainder[] = { aLen, aLen, RThread().Id(), self->iPid };
+			TUint8 subcat = EHeapExtendedAlloc;
+			BTraceN(KHeapCategory, subcat, self->iA, cellPtr, remainder, sizeof(remainder));
+			}
+		}
+	return ETrue; // Keep going
+	}
+
+EXPORT_C TInt RLoggingAllocator::Install()
+	{
+	return Install(0);
+	}
+
+EXPORT_C TInt RLoggingAllocator::Install(TUint aFlags)
+	{
+	RLoggingAllocator* dontCareResult = NULL;
+	return New(aFlags, NULL, dontCareResult);
+	}
+
+EXPORT_C TInt RLoggingAllocator::New(TUint aFlags, RAllocator* aOrigAllocator, RLoggingAllocator*& aResult)
+	{
+	LOG("RLoggingAllocator::Install %x", aFlags);
+	RLoggingAllocator* a = new RLoggingAllocator(aFlags);
+	if (!a) return KErrNoMemory;
+
+	TInt err = a->iLib.Load(_L("LoggingAllocator"));
+	if (err)
+		{
+		LOG("LA: Failed to RLibrary load ourselves");
+		a->Destroy();
+		return err;
+		}
+
+	err = a->iLock.CreateLocal();
+	if (err)
+		{
+		LOG("LA: Failed to create lock");
+		a->Destroy();
+		return err;
+		}
+	if (aFlags & EDeferFree)
+		{
+		err = a->iDeferredFrees.Reserve(KMaxDeferredFrees);
+		if (err)
+			{
+			LOG("LA: No mem to reserve deferred free list");
+			a->Destroy();
+			return err;
+			}
+		}
+
+	// Do this *before* switching the allocator, in case we're using atrace which means it will have to alloc for the first trace
+	BTrace12(KHeapCategory, (TUint)ELoggingAllocatorInstalled, aOrigAllocator ? aOrigAllocator : &User::Allocator(), TUint(RThread().Id()), a->iPid);
+
+	// Ditto
+	err = a->iHelper.Open(aOrigAllocator ? aOrigAllocator : &User::Allocator());
+	LOG("LA: RAllocatorHelper Open returned %d", err);
+
+	RAllocator* old = aOrigAllocator;
+	if (old == NULL)
+		{
+		// If the caller passed in an allocator, we shouldn't switch the default allocator
+		old = User::SwitchAllocator(a);
+		}
+	a->iA = old;
+
+	if (!err)
+		{
+		//err = a->DebugFunction(RHeap::EWalk, (TAny*)&TraceExistingAllocs, a);
+		err = a->iHelper.Walk(TraceExistingAllocs, a);
+		}
+	LOG("LA: HeapWalk returned %d", err);
+	if (err == KErrNone)
+		{
+		BTrace12(KHeapCategory, (TUint)EHeapPrimingFinished, a->iA, TUint(RThread().Id()), a->iPid);
+		}
+	a->iHelper.SetCellNestingLevel(a, -1); // This is so we are immune from being included in any leak detection (because we have to leak the allocator in order that that it is still in use when the markend happens)
+	aResult = a;
+	return KErrNone;
+	}
+
+EXPORT_C TInt RLoggingAllocator::Uninstall()
+	{
+	return User::Allocator().DebugFunction(KUidUninstallLoggingAllocator, NULL, NULL);
+	}
+
+void TraceAllocHeaven(TAny* aCell, TInt aLen)
+	{
+	TUint threadId = (TUint)RThread().Id().Id();
+	BTrace12(BTrace::ETest1, EAllocHeaven, threadId, aCell, aLen);
+	BTraceN(BTrace::ETest1, EAllocHeavenData, threadId, aCell, aCell, aLen);
+	}
+
+TBool RLoggingAllocator::HeavenWalk(RAllocatorHelper& aHelper, TAny* aPtr, RAllocatorHelper::TCellType aType, TLinAddr aCell, TInt aLen)
+	{
+	// If iA wasn't an RHeap (and more specifically, a UDEB RHeap) then we ensure this function does not get called. 
+	// Therefore we can safely assume that it is
+
+	// This function taken from RHeap::WalkCheckCell
+	
+	TInt nestingLevel = reinterpret_cast<TInt>(aPtr);
+
+	switch(aType)
+		{
+		case RHeap::EGoodAllocatedCell:
+			{
+			TInt cellLevel;
+			if (aHelper.GetCellNestingLevel((TAny*)aCell, cellLevel) == KErrNone && cellLevel == nestingLevel)
+				{
+				TraceAllocHeaven((TAny*)aCell, aLen);
+				}
+			break;
+			}
+		default:
+			break;
+		}
+	return ETrue;
+	}
+
+_LIT(KPan, "LoggingAllocator");
+
+void RLoggingAllocator::CheckDeferredFrees()
+	{
+	if ((iFlags & EDeferFreeAndCheckScribbles) != EDeferFreeAndCheckScribbles) return; // Both bits of EDeferFreeAndCheckScribbles must be set for us to be able to check
+
+	iLock.Wait();
+	const TInt n = iDeferredFrees.Count();
+	for (TInt i = 0; i < n; i++)
+		{
+		const TUint* ptr = (const TUint*)iDeferredFrees[i].iPtr;
+		const TUint* end = (const TUint*)((TLinAddr)ptr + Min(16, iDeferredFrees[i].iLen)); // Check the first few words
+		if (iA->AllocLen(ptr) != iDeferredFrees[i].iLen)
+			{
+			// Then the length of the cell has been corrupted
+			iLock.Signal();
+			User::Panic(KPan, (TUint)ptr);
+			}
+		while (ptr != end)
+			{
+			//RDebug::Printf("Checking %x", ptr);
+			if (*ptr != 0xDFDFDFDF)
+				{
+				// Someone is using this cell after it's been 'deleted'
+				//TODO btrace this
+				iLock.Signal();
+				User::Panic(KPan, (TUint)iDeferredFrees[i].iPtr);
+				}
+			ptr++;
+			}
+		}
+	iLock.Signal();
+	}
+
+RLoggingAllocator::~RLoggingAllocator()
+	{
+	// We must not be the current allocator when this is called!
+	__ASSERT_ALWAYS(&User::Allocator() != this, User::Panic(KPan, 1));
+	iLock.Close();
+	iDeferredFrees.Close();
+	iLib.Close();
+	iHelper.Close();
+	}
+
+void RLoggingAllocator::Destroy()
+	{
+	// Keep the lib around until after the destructor has finished, otherwise you risk the DLL being unloaded midway through the destructor chain
+	RLibrary lib = iLib;
+	iLib.SetHandle(0);
+	delete this;
+	lib.Close();
+	}
+
+inline void RLoggingAllocator::TraceFree(RAllocator* aAllocator, TAny* aCellPtr, TBool aCellIsAlreadyFreed)
+	{
+	DoTraceAllocEvent(aAllocator, aCellPtr, EHeapFree, aCellIsAlreadyFreed ? -1 : 0);
+	}
+
+inline void RLoggingAllocator::TraceAlloc(RAllocator* aAllocator, TAny* aCellPtr, TInt aRequestedSize)
+	{
+	DoTraceAllocEvent(aAllocator, aCellPtr, EHeapAlloc, aRequestedSize);
+	}
+
+inline void RLoggingAllocator::TraceRealloc(TAny *aNewPtr, TAny* aOldPtr, TInt aNewRequestedSize)
+	{
+	DoTraceAllocEvent(iA, aNewPtr, EHeapReAlloc, aNewRequestedSize, aOldPtr);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/NotifierProxy.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,699 @@
+// NotifierProxy.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/common.mmh>
+#include <e32notif.h>
+#include <e32ver.h>
+
+#ifndef FSHELL_WSERV_SUPPORT
+
+EXPORT_C TInt StartNotifierProxyThreadFunction(TAny*)
+	{
+	return KErrNotSupported;
+	}
+
+EXPORT_C TInt ShutdownProxyNotifier()
+	{
+	return KErrNotSupported;
+	}
+
+EXPORT_C TBool NotifierProxyIsRunning()
+	{
+	return EFalse;
+	}
+
+#else
+
+#include "NotifierProxy.h"
+#include <fshell/clogger.h>
+#include "utils.h"
+
+_LIT(KRealNotifierServerName,   "RealNtfyr");
+_LIT8(KRealNotifierServerName8, "RealNtfyr");
+
+#define LeaveIfErr(_err, _args...) \
+	do \
+		{ \
+		if (_err < 0) \
+			{ \
+			RClogger::Slog(_args); \
+			User::Leave(_err); \
+			} \
+		} \
+		while (0)
+
+const TInt KShutdownProxy = 1000;
+const TInt KPingProxy = 1001;
+const TInt KInfoPrintTime = 2000000; // 2 seconds
+
+TInt RRealNotifier::Connect()
+	{
+	return CreateSession(KRealNotifierServerName, TVersion(KNotifierMajorVersionNumber,KNotifierMinorVersionNumber,KNotifierBuildVersionNumber),-1);
+	}
+
+CNotifierProxyServer::CNotifierProxyServer()
+	: CServer2(0, ESharableSessions)
+	{
+	}
+
+void CNotifierProxyServer::ConstructL()
+	{
+	//__DEBUGGER();
+	SetupWindowL();
+	TFontSpec spec(_L("Roman"), 12);
+	LeaveIfErr(iScreenDevice->GetNearestFontInPixels(iFont, spec), _L("Couldn't find a suitable font"));
+	iPeriodic = CPeriodic::NewL(CActive::EPriorityStandard);
+	iText.ReserveL(8);
+	iUndertaker = new(ELeave) CPanicDialogWatcher(*this);
+	iUndertaker->ConstructL();
+
+	StartL(KRealNotifierServerName); // We start with the name of what we're going to rename the real notifier to, this way we ensure that the following code can only be run by one thread at once
+
+	RMemoryAccess::LoadDriver();
+	LeaveIfErr(iMemAccess.Open(), _L("Couldn't open mem access"));
+
+	TServerKernelInfoBuf buf;
+	TInt err = iMemAccess.GetObjectInfo(EServer, _L("!Notifier"), buf);
+	User::LeaveIfError(err);
+	TUint8* realServer = buf().iAddressOfKernelObject;
+	err = iMemAccess.GetObjectInfo(EServer, KRealNotifierServerName, buf);
+	User::LeaveIfError(err);
+	TUint8* myServer = buf().iAddressOfKernelObject;
+
+	// Should really have some kind of swap operation here...
+	iMemAccess.InPlaceObjectRename(EServer, realServer, KRealNotifierServerName8);
+	iMemAccess.InPlaceObjectRename(EServer, myServer, _L8("!Notifier"));
+	iProxying = ETrue;
+	}
+
+CNotifierProxyServer::~CNotifierProxyServer()
+	{
+	delete iRedrawer;
+	//delete iAnimationTimer;
+	//delete iBitmap;
+	//delete iDsa;
+	delete iScreenDevice;
+	delete iGc;
+	iWin.Close();
+	iWg.Close();
+	iWs.Close();
+	delete iPeriodic;
+	iText.ResetAndDestroy();
+	delete iUndertaker;
+
+	if (iProxying)
+		{
+		TServerKernelInfoBuf buf;
+		TInt err = iMemAccess.GetObjectInfo(EServer, KRealNotifierServerName, buf);
+		if (!err)
+			{
+			TUint8* realServer = buf().iAddressOfKernelObject;
+			iMemAccess.InPlaceObjectRename(EServer, realServer, _L8("!Notifier"));
+			// Temporarily both us and the real server will have name !Notifier. When we finish destructing, we'll clean up and the system should be back in the state it was
+			}
+		}
+	iMemAccess.Close();
+	RMemoryAccess::CloseDriver();
+	}
+
+CSession2* CNotifierProxyServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const
+	{
+	CNotifierProxySession* res = new(ELeave) CNotifierProxySession();
+	CleanupStack::PushL(res);
+	res->ConstructL();
+	CleanupStack::Pop(res);
+	return res;
+	}
+
+void CNotifierProxySession::ConstructL()
+	{
+	User::LeaveIfError(iRealNotifier.Connect());
+	}
+
+CNotifierProxyServer& CNotifierProxySession::Server()
+	{
+	return *const_cast<CNotifierProxyServer*>(static_cast<const CNotifierProxyServer*>(CSession2::Server()));
+	}
+
+const CNotifierProxyServer& CNotifierProxySession::Server() const
+	{
+	return *static_cast<const CNotifierProxyServer*>(CSession2::Server());
+	}
+
+void CNotifierProxySession::ServiceL(const RMessage2 &aMessage)
+	{
+	switch (aMessage.Function())
+		{
+		case ENotifierInfoPrint:
+			{
+			//__DEBUGGER();
+			RBuf buf;
+			CleanupClosePushL(buf);
+			buf.CreateL(aMessage.GetDesLengthL(0));
+			aMessage.ReadL(0, buf);
+			RThread client;
+			TInt err = aMessage.Client(client);
+			TUint clientId = 0;
+			if (!err) clientId = client.Id();
+			client.Close();
+			Server().InfoPrint(buf, clientId);
+			CleanupStack::PopAndDestroy(&buf);
+			aMessage.Complete(KErrNone);
+			break;
+			}
+		case EStartNotifier:
+			{
+			TUid notifierUid = TUid::Uid(aMessage.Int0());
+			RBuf8 buf, responseBuf;
+			CleanupClosePushL(buf);
+			buf.CreateL(aMessage.GetDesLengthL(1));
+			aMessage.ReadL(1, buf);
+			TInt res = KErrNone;
+			if (aMessage.Ptr2())
+				{
+				CleanupClosePushL(responseBuf);
+				responseBuf.CreateL(aMessage.GetDesMaxLengthL(2));
+				res = iRealNotifier.StartNotifier(notifierUid, buf, responseBuf);
+				if (res == KErrNone || responseBuf.Length())
+					{
+					aMessage.WriteL(2, responseBuf);
+					}
+				CleanupStack::PopAndDestroy(&responseBuf);
+				}
+			else
+				{
+				res = iRealNotifier.StartNotifier(notifierUid, buf);
+				}
+			CleanupStack::PopAndDestroy(&buf);
+			aMessage.Complete(res);
+			break;
+			}
+		case EStartNotifierFromSpecifiedDll:
+		case EStartNotifierFromSpecifiedDllAndGetResponse:
+			aMessage.Complete(KErrNotSupported); // This is what the docs say - god knows why the client bothers to pass it through
+			break;
+		case ECancelNotifier:
+			{
+			TUid notifierUid = TUid::Uid(aMessage.Int0());
+			TInt res = iRealNotifier.CancelNotifier(notifierUid);
+			aMessage.Complete(res);
+			break;
+			}
+		case EUpdateNotifier:
+			{
+			TUid notifierUid = TUid::Uid(aMessage.Int0());
+			RBuf8 buf, responseBuf;
+			CleanupClosePushL(buf);
+			buf.CreateL(aMessage.GetDesLengthL(1));
+			aMessage.ReadL(1, buf);
+			CleanupClosePushL(responseBuf);
+			responseBuf.CreateL(aMessage.GetDesMaxLengthL(2));
+			TInt res = iRealNotifier.UpdateNotifier(notifierUid, buf, responseBuf);
+			if (res == KErrNone || responseBuf.Length())
+				{
+				aMessage.WriteL(2, responseBuf);
+				}
+			CleanupStack::PopAndDestroy(&responseBuf);
+			CleanupStack::PopAndDestroy(&buf);
+			aMessage.Complete(res);
+			break;
+			}
+		case EUpdateNotifierAndGetResponse:
+		case EStartNotifierAndGetResponse:
+		case ENotifierNotify:
+			{
+			CAsyncWaiter* waiter = new(ELeave) CAsyncWaiter(iRealNotifier, aMessage);
+			waiter->ForwardMessageL();
+			break;
+			}
+		case ENotifierNotifyCancel:
+			iRealNotifier.NotifyCancel();
+			aMessage.Complete(KErrNone);
+			break;
+		case KShutdownProxy:
+			CActiveScheduler::Stop();
+			break;
+		case KPingProxy:
+			aMessage.Complete(KErrNone);
+			break;
+		default:
+			__DEBUGGER();
+			aMessage.Complete(KErrNotSupported);
+		}
+	}
+
+void CNotifierProxySession::Disconnect(const RMessage2 &aMessage)
+	{
+	iRealNotifier.Close();
+	//TODO Need to wait for any CAsyncWaiters to be completed? If so, do it here and defer the super call until that time
+	CSession2::Disconnect(aMessage);
+	}
+
+CAsyncWaiter::CAsyncWaiter(RRealNotifier& aRealNotifier, const RMessage2& aMessage)
+	: CActive(CActive::EPriorityStandard), iRealNotifier(aRealNotifier), iMsg(aMessage)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CAsyncWaiter::~CAsyncWaiter()
+	{
+	iBuf.Close();
+	iWideBuf.Close();
+	iResponseBuf.Close();
+	}
+
+void CAsyncWaiter::ForwardMessageL()
+	{
+	switch (iMsg.Function())
+		{
+		case EUpdateNotifierAndGetResponse:
+			{
+			TUid notifierUid = TUid::Uid(iMsg.Int0());
+			iBuf.CreateL(iMsg.GetDesLengthL(1));
+			iMsg.ReadL(1, iBuf);
+			iResponseBuf.CreateL(iMsg.GetDesMaxLengthL(2));
+			iRealNotifier.UpdateNotifierAndGetResponse(iStatus, notifierUid, iBuf, iResponseBuf);
+			SetActive();
+			break;
+			}
+		case EStartNotifierAndGetResponse:
+			{
+			TUid notifierUid = TUid::Uid(iMsg.Int0());
+			iBuf.CreateL(iMsg.GetDesLengthL(1));
+			iMsg.ReadL(1, iBuf);
+			iResponseBuf.CreateL(iMsg.GetDesMaxLengthL(2));
+			iRealNotifier.StartNotifierAndGetResponse(iStatus, notifierUid, iBuf, iResponseBuf);
+			SetActive();
+			break;
+			}
+		case ENotifierNotify:
+			{
+			// iWideBuf is the combined buffer
+			iWideBuf.CreateL(iMsg.GetDesLengthL(1));
+			iMsg.ReadL(1, iWideBuf);
+			// iResponseBuf is the button val
+			iResponseBuf.CreateMaxL(sizeof(TInt));
+			TInt comboLineLen = iMsg.Int2();
+			TInt comboButLen = iMsg.Int3();
+			const TUint16* ptr = iWideBuf.Ptr();
+			iTempPtrs[0].Set(ptr, comboLineLen >> 16);
+			ptr += iTempPtrs[0].Length();
+			iTempPtrs[1].Set(ptr, comboLineLen & 0xFFFF);
+			ptr += iTempPtrs[1].Length();
+			iTempPtrs[2].Set(ptr, comboButLen >> 16);
+			ptr += iTempPtrs[2].Length();
+			iTempPtrs[3].Set(ptr, comboButLen & 0xFFFF);
+			
+			iRealNotifier.Notify(iTempPtrs[0], iTempPtrs[1], iTempPtrs[2], iTempPtrs[3], *(TInt*)iResponseBuf.Ptr(), iStatus);
+			SetActive();
+			break;
+			}
+		default:
+			__DEBUGGER();
+		}
+	}
+
+void CAsyncWaiter::RunL()
+	{
+	TInt res = iStatus.Int();
+	switch (iMsg.Function())
+		{
+		case EUpdateNotifierAndGetResponse:
+		case EStartNotifierAndGetResponse:
+			if (res == KErrNone || iResponseBuf.Length())
+				{
+				TInt err = iMsg.Write(2, iResponseBuf);
+				if (err)
+					{
+					res = err;
+					}
+				}
+			iMsg.Complete(res);
+			break;
+		case ENotifierNotify:
+			{
+			TInt err = iMsg.Write(0, iResponseBuf);
+			if (err) res = err;
+			iMsg.Complete(res);
+			break;
+			}
+		default:
+			__DEBUGGER();
+			User::Leave(KErrNotSupported);
+		}
+	delete this; // Our work here is done
+	}
+
+void CAsyncWaiter::DoCancel()
+	{
+	// We never call Cancel on our waiters
+	}
+
+void MainL()
+	{
+	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+	CNotifierProxyServer* server = new(ELeave) CNotifierProxyServer;
+	CleanupStack::PushL(server);
+	server->ConstructL();
+	CActiveScheduler::Start();
+	CleanupStack::PopAndDestroy(2, scheduler); // server, scheduler
+	}
+
+EXPORT_C TInt StartNotifierProxyThreadFunction(TAny*)
+	{
+	TInt err = KErrNoMemory;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (cleanup)
+		{
+		TRAP(err, MainL());
+		delete cleanup;
+		}
+	return err;
+	}
+
+class RDebugNotifier : public RNotifier
+	{
+public:
+	TInt ShutdownProxy()
+		{
+		return SendReceive(KShutdownProxy, TIpcArgs());
+		}
+	TInt PingProxy()
+		{
+		return SendReceive(KPingProxy, TIpcArgs());
+		}
+	};
+
+EXPORT_C TInt ShutdownProxyNotifier()
+	{
+	RDebugNotifier notifier;
+	TInt err = notifier.Connect();
+	if (err == KErrNotFound)
+		{
+		// Oh dear, !Notifier isn't running. Meaning we renamed it then crashed, probably. Try renaming the real one
+		RMemoryAccess::LoadDriver();
+		RMemoryAccess mem;
+		err = mem.Open();
+		if (err) return err;
+		TServerKernelInfoBuf buf;
+		TInt err = mem.GetObjectInfo(EServer, KRealNotifierServerName, buf);
+		if (!err)
+			{
+			TUint8* realServer = buf().iAddressOfKernelObject;
+			mem.InPlaceObjectRename(EServer, realServer, _L8("!Notifier"));
+			}
+		mem.Close();
+		return err;
+		}
+
+	err = notifier.ShutdownProxy();
+	if (err == KErrServerTerminated) err = KErrNone; // It's expected to get KErrServerTerminated, because we deliberately don't complete the message. This way the client is more likely to get the completion once the server has actually gone, and not slightly before
+	notifier.Close();
+
+	return err;
+	}
+
+EXPORT_C TBool NotifierProxyIsRunning()
+	{
+	RDebugNotifier notifier;
+	TInt err = notifier.Connect();
+	if (err) return EFalse; // Not even original notifier is running?!
+	err = notifier.PingProxy();
+	notifier.Close();
+	return err == KErrNone; // The real proxy will return KErrNotSupported in this scenario
+	}
+
+
+void CNotifierProxyServer::SetupWindowL()
+	{
+	//__DEBUGGER();
+	LeaveIfErr(iWs.Connect(), _L("Couldn't connect to windowserver"));
+	//iWs.SetAutoFlush(ETrue);
+	iRedrawer = new(ELeave) CRedrawer(*this);
+	iRedrawer->Go();
+
+	iScreenDevice = new(ELeave) CWsScreenDevice(iWs);
+	LeaveIfErr(iScreenDevice->Construct(), _L("Couldn't construct screen device")); // User default screen number
+	LeaveIfErr(iScreenDevice->CreateContext(iGc), _L("Couldn't create gc"));
+	iWg = RWindowGroup(iWs);
+	LeaveIfErr(iWg.Construct(2, EFalse), _L("Couldn't construct windowgroup"));
+	iWin = RWindow(iWs);
+	LeaveIfErr(iWin.Construct(iWg, (TUint32)this), _L("Couldn't construct window"));
+
+	iWin.SetBackgroundColor(KRgbBlack);
+	iWg.SetOrdinalPosition(0, 1000); // 1000 is ECoeWinPriorityAlwaysAtFront, but I don't want the dependancy on a cone header
+	TRect rect(TPoint(), TSize(iScreenDevice->SizeInPixels().iWidth, 50));
+	iWin.SetExtent(rect.iTl, rect.Size());
+	iWin.SetVisible(EFalse);
+	iWin.Activate();
+	iWs.Flush();
+	
+	//iBitmap = new(ELeave) CFbsBitmap;
+	//LeaveIfErr(iBitmap->Create(iScreenDevice->SizeInPixels(), EColor16MU), _L("Couldn't create bitmap"));
+	//iDsa = CDirectScreenAccess::NewL(iWs, *iScreenDevice, iWin, *this);
+	}
+
+void CNotifierProxyServer::DoWservInitiatedRedraw(const TRect& /*aRect*/)
+	{
+	//__DEBUGGER();
+	// This code based on CCoeControl::HandleRedrawEvent
+	//iWin.BeginRedraw(aRect);
+	iWin.BeginRedraw(TRect(TPoint(), iWin.Size()));
+	iGc->Activate(iWin);
+
+	iGc->UseFont(iFont);
+	iGc->SetPenColor(KRgbGreen);
+	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
+	iGc->SetBrushColor(KRgbBlack);
+	for (TInt i = 0; i < iText.Count(); i++)
+		{
+		TPoint drawPoint(0, iFont->FontMaxAscent() + i * iFont->FontLineGap());
+		if (drawPoint.iY > iWin.Size().iHeight)
+			{
+			// We've more to draw than we have room. Bail.
+			break;
+			}
+		//iGc->DrawText(iText[i]->iText, drawPoint);
+		iGc->DrawText(iText[i]->iText, BoxForLine(i), iFont->FontMaxAscent());
+		}
+	iGc->DiscardFont();
+	iGc->Deactivate();
+	iWin.EndRedraw();
+	}
+
+TRect CNotifierProxyServer::BoxForLine(TInt aLineIndex)
+	{
+	TRect textBox = TRect(0, aLineIndex * iFont->FontLineGap(), iWin.Size().iWidth, (aLineIndex+1) * iFont->FontLineGap());
+	return textBox;
+	}
+
+RWsSession& CNotifierProxyServer::WsSession()
+	{
+	return iWs;
+	}
+
+void CNotifierProxyServer::InfoPrint(const TDesC& aText, TUint aClientId)
+	{
+	TPtrC text(aText);
+	TInt newline = aText.Locate('\n');
+	if (newline != KErrNotFound)
+		{
+		// UIQ supported 2-line infoprints so some code puts a newline in - if so split it up and treat as two calls
+		TPtrC first = aText.Left(newline);
+		TPtrC second = aText.Mid(newline+1);
+		InfoPrint(first, aClientId);
+		//InfoPrint(second, aClientId);
+		text.Set(second); // Drop through at this point - prevents recursing if there are many newlines (also stops more than one newline from being recognised)
+		}
+
+	CLine* line = new CLine(text, aClientId);
+	if (!line) return; // OOM
+
+	// Check if client should be getting frequent flyer miles, if so limit it
+	for (TInt i = iText.Count() - 1; i >= 0; i--)
+		{
+		CLine* line = iText[i];
+		if (aClientId && aClientId == line->iClientId && text.Left(6) == line->iText.Left(6))
+			{
+			iText.Remove(i);
+			// And restart timer if the one we've just removed was at index zero, ie about to be removed anyway (otherwise timer will remove the new one sooner at the time when the old one was due)
+			if (i == 0) iPeriodic->Cancel(); // (cancelling it here will cause it to be restarted in DisplayAndStartTimer)
+			}
+		}
+
+	TInt err = iText.Append(line);
+	if (err)
+		{
+		delete line;
+		}
+	else
+		{
+		RecalculateWindow();
+		iWin.Invalidate();
+		DisplayAndStartTimer();
+		iWs.Flush();
+		}
+	}
+
+CRedrawer::CRedrawer(CNotifierProxyServer& aServer) 
+	: CActive(CActive::EPriorityStandard), iServer(aServer)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CRedrawer::Go()
+	{
+	if (!IsActive())
+		{
+		iServer.WsSession().RedrawReady(&iStatus);
+		SetActive();
+		}
+	}
+
+void CRedrawer::RunL()
+	{
+	TWsRedrawEvent redrawEvent;
+	iServer.WsSession().GetRedraw(redrawEvent);
+	TRect rect=redrawEvent.Rect();
+	
+	iServer.DoWservInitiatedRedraw(rect);
+	Go();
+	iServer.WsSession().Flush();
+	}
+
+void CRedrawer::DoCancel()
+	{
+	iServer.WsSession().RedrawReadyCancel();
+	}
+
+CRedrawer::~CRedrawer()
+	{
+	Cancel();
+	}
+
+void CNotifierProxyServer::RecalculateWindow()
+	{
+	// Grow or shrink the window if needed to display all the text we have
+	TInt numLines = iText.Count();
+	
+	const TInt KMaxWindowHeight = 200;
+	TInt newHeight = Min(BoxForLine(0).Height() * numLines, KMaxWindowHeight); // Don't exceed our defined max height
+	TInt currentHeight = iWin.Size().iHeight;
+	if (newHeight != currentHeight)
+		{
+		iWin.SetSize(TSize(iWin.Size().iWidth, newHeight));
+		}
+	}
+
+TInt CNotifierProxyServer::StaticTick(TAny* aSelf)
+	{
+	static_cast<CNotifierProxyServer*>(aSelf)->Tick();
+	return 0;
+	}
+
+void CNotifierProxyServer::Tick()
+	{
+	// Remove 1 line from the top of the infoprint each time the timer fires, if nothing left hide the window
+	if (iText.Count())
+		{
+		iText.Remove(0);
+		}
+
+	if (iText.Count() == 0)
+		{
+		iWin.SetVisible(EFalse);
+		iPeriodic->Cancel(); // No need for further ticks
+		}
+	else
+		{
+		RecalculateWindow();
+		iWin.Invalidate();
+		}
+	iWs.Flush();
+	}
+	
+void CNotifierProxyServer::DisplayAndStartTimer()
+	{
+	if (iText.Count())
+		{
+		iWin.SetVisible(ETrue);
+		if (!iPeriodic->IsActive())
+			{
+			iPeriodic->Start(KInfoPrintTime, KInfoPrintTime, TCallBack(&StaticTick, this));
+			}
+		}
+	}
+
+CLine::CLine(const TDesC& aText, TUint aClientId)
+	: iText(aText), iClientId(aClientId)
+	{
+	//iTimeOfPrint.UniversalTime();
+	}
+
+CPanicDialogWatcher::CPanicDialogWatcher(CNotifierProxyServer& aServer)
+	: CActive(CActive::EPriorityStandard), iServer(aServer)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CPanicDialogWatcher::ConstructL()
+	{
+	User::LeaveIfError(iUndertaker.Create());
+	iUndertaker.Logon(iStatus, iThreadHandle);
+	SetActive();
+	}
+
+CPanicDialogWatcher::~CPanicDialogWatcher()
+	{
+	Cancel();
+	iUndertaker.Close();
+	}
+
+void CPanicDialogWatcher::RunL()
+	{
+	TInt threadHandle = iThreadHandle;
+	iUndertaker.Logon(iStatus, iThreadHandle);
+	SetActive();
+
+	RThread thread;
+	thread.SetHandle(threadHandle);
+	iTempName = thread.FullName();
+	PrettyName(EListThread, iTempName);
+	if (thread.ExitType() == EExitPanic)
+		{
+		TExitCategoryName cat = thread.ExitCategory();
+		TBuf<256> buf;
+		buf.Format(_L("Panic: %S %d from %S"), &cat, thread.ExitReason(), &iTempName);
+		iServer.InfoPrint(buf, 0);
+		}
+	else if (thread.ExitType() == EExitKill)
+		{
+		TBuf<256> buf;
+		buf.Format(_L("Kill %d: Tid %d %S"), thread.ExitReason(), TUint(thread.Id()), &iTempName);
+		iServer.InfoPrint(buf, 0);
+		}
+	else if (thread.ExitType() == EExitTerminate)
+		{
+		TBuf<256> buf;
+		buf.Format(_L("Terminate %d: Tid %d %S"), thread.ExitReason(), TUint(thread.Id()), &iTempName);
+		iServer.InfoPrint(buf, 0);
+		}
+	thread.Close();
+	}
+
+void CPanicDialogWatcher::DoCancel()
+	{
+	iUndertaker.LogonCancel();
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/Utils.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1216 @@
+// Utils.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#define __INCLUDE_ALL_SUPPORTED_CAPABILITIES__
+#define __INCLUDE_CAPABILITY_NAMES__
+
+#include <e32base.h>
+#include "Utils.h"
+#include <HAL.h>
+#include <eikenv.h>
+
+#ifdef INCLUDE_UIQ_DEFINITIONS
+#include <DeviceKeys.h>
+#endif
+
+#include <fshell/memoryaccess.h>
+#include <fshell/ltkutils.h>
+
+/* TomS: These don't seem to be used any more
+//#include <featureUIDs.h>
+namespace NFeature
+	{
+	// default present
+	const TUid KFax = {0x10279806};
+	const TUid KPrint = {0x10279807};
+	const TUid KBluetooth = {0x10279808};
+	const TUid KInfrared = {0x10279809};
+	const TUid KMmc = {0x1027980a};
+	const TUid KUsb = {0x1027980b};
+	const TUid KObex = {0x1027980c};
+	const TUid KRtpRtcp = {0x1027980d};
+	const TUid KSip = {0x1027980f};
+	const TUid KOmaDataSync	= {0x10279810};
+	const TUid KOmaDeviceManagement = {0x10279811};
+	const TUid KIPQoS = {0x10279812};
+	const TUid KNetworkQoS = {0x10279813};
+	const TUid KIPSec = {0x10279814};
+	const TUid KDhcp = {0x10279815};
+	const TUid KConnectivity = {0x10279816};	// PC Connectivity
+
+	// default not-present
+	const TUid KLocation = {0x10281818};
+	const TUid KMobileIP = {0x10281819};
+	const TUid KOfflineMode = {0x1028181A};
+	const TUid KDRM = {0x1028181B};
+	const TUid KOmaDsHostServers = {0x10282663};
+	}
+*/
+
+#ifdef __DLL__
+#define gPlugin ((CDefaultProductPlugin*)Dll::Tls())
+#else
+CDefaultProductPlugin* gPlugin = NULL;
+#endif
+
+// GCC has issues with the CASE_LIT definition that ran along the same lines as CASE_LIT2 below - more than 8 CASE_LITs in one switch made the compiler blow up
+#define CASE_LIT(name) case name: { const TText16* KName = (const TText16*) L ## #name; return TPtrC(KName); }
+#define CASE_LIT2(val, name) case val: { _LIT(KName, name); return TPtrC(KName); }
+
+
+void HR(TDes& aDes, TInt64 aSize)
+	{
+	// This functionality has been moved into ltkutils
+	LtkUtils::FormatSize(aDes, aSize);
+	}
+
+void HR(TDes8& aDes, TInt64 aSize)
+	{
+	LtkUtils::FormatSize(aDes, aSize);
+	}
+
+TPtrC ToString(TProcessPriority aPriority)
+	{
+	switch(aPriority)
+		{
+		CASE_LIT(EPriorityLow);
+		CASE_LIT(EPriorityBackground);
+		CASE_LIT(EPriorityForeground);
+		CASE_LIT(EPriorityHigh);
+		CASE_LIT(EPriorityWindowServer);
+		CASE_LIT(EPriorityFileServer);
+		CASE_LIT(EPriorityRealTimeServer);
+		CASE_LIT(EPrioritySupervisor);
+		default:
+			return TPtrC();
+		}
+	}
+
+TPtrC ToString(TThreadPriority aPriority)
+	{
+	// Redefine these here - easiest way of making sure this builds and works on all 9.x baselines
+	enum TPrioritiesThatArentIn91 
+		{
+		EPriorityAbsoluteLowNormal=150,
+		EPriorityAbsoluteBackgroundNormal=250,
+		EPriorityAbsoluteForegroundNormal=350,
+		EPriorityAbsoluteHighNormal=450,
+		EPriorityAbsoluteHigh=500,
+		EPriorityAbsoluteRealTime1=810,
+		EPriorityAbsoluteRealTime2=820,
+		EPriorityAbsoluteRealTime3=830,
+		EPriorityAbsoluteRealTime4=840,
+		EPriorityAbsoluteRealTime5=850,
+		EPriorityAbsoluteRealTime6=860,
+		EPriorityAbsoluteRealTime7=870, 
+		EPriorityAbsoluteRealTime8=880
+		};
+
+	switch((TInt)aPriority)
+		{
+		CASE_LIT(EPriorityNull);
+		CASE_LIT(EPriorityMuchLess);
+		CASE_LIT(EPriorityLess);
+		CASE_LIT(EPriorityNormal);
+		CASE_LIT(EPriorityMore);
+		CASE_LIT(EPriorityMuchMore);
+		CASE_LIT(EPriorityAbsoluteVeryLow);
+		CASE_LIT(EPriorityAbsoluteLow);
+		CASE_LIT(EPriorityAbsoluteBackground);
+		CASE_LIT(EPriorityAbsoluteForeground);
+		CASE_LIT(EPriorityAbsoluteHigh);
+		CASE_LIT(EPriorityRealTime);
+		CASE_LIT(EPriorityAbsoluteLowNormal);
+		CASE_LIT(EPriorityAbsoluteBackgroundNormal);
+		CASE_LIT(EPriorityAbsoluteForegroundNormal);
+		CASE_LIT(EPriorityAbsoluteHighNormal);
+		CASE_LIT(EPriorityAbsoluteRealTime1);
+		CASE_LIT(EPriorityAbsoluteRealTime2);
+		CASE_LIT(EPriorityAbsoluteRealTime3);
+		CASE_LIT(EPriorityAbsoluteRealTime4);
+		CASE_LIT(EPriorityAbsoluteRealTime5);
+		CASE_LIT(EPriorityAbsoluteRealTime6);
+		CASE_LIT(EPriorityAbsoluteRealTime7);
+		CASE_LIT(EPriorityAbsoluteRealTime8);
+		default:
+			return TPtrC();
+		}
+	}
+
+HBufC* ToStringL(SCapabilitySet& aCaps)
+	{
+	//TODO
+	//_LIT8(KUnknown, "Unknown");
+	//return KUnknown().AllocL();
+
+	__ASSERT_COMPILE(ECapability_Limit < 32);
+	_LIT(KAll, "All");
+	_LIT(KAllMinusTCB, "All -Tcb");
+	_LIT(KNone, "None");
+	if (aCaps[0] == AllSupportedCapabilities[0])
+		{
+		return KAll().AllocL();
+		}
+	else if (aCaps[0] == (AllSupportedCapabilities[0] & ~(1 << ECapabilityTCB)))
+		{
+		return KAllMinusTCB().AllocL();
+		}
+	else if (aCaps[0] == 0)
+		{
+		return KNone().AllocL();
+		}
+	else
+		{
+		HBufC8* res = HBufC8::NewLC(512); // Easily enough room for all the capability names
+		TPtr8 ptr = res->Des();
+		for (TInt bit = 0; bit < ECapability_Limit; bit++)
+			{
+			if (aCaps[0] & (1 << bit))
+				{
+				ptr.Append(TPtrC8((TUint8*)CapabilityNames[bit]));
+				ptr.Append(' ');
+				}
+			}
+		ptr.SetLength(ptr.Length()-1); // Remove trailing space
+		HBufC* res16 = HBufC::NewL(ptr.Length());
+		res16->Des().Copy(ptr);
+		CleanupStack::PopAndDestroy(res);
+		return res16;
+		}
+	}
+
+TPtrC ToString(TExitType aType)
+	{
+	switch (aType)
+		{
+		CASE_LIT2(EExitKill, "Kill");
+		CASE_LIT2(EExitTerminate, "Terminate");
+		CASE_LIT2(EExitPanic, "Panic");
+		CASE_LIT2(EExitPending, "Pending");
+		default:
+			return TPtrC();
+		}
+	}
+
+TPtrC ToString(User::TCritical aCritical)
+	{
+	switch (aCritical)
+		{
+		CASE_LIT2(User::ENotCritical, "Not critical");
+		CASE_LIT2(User::EProcessCritical, "Process critical");
+		CASE_LIT2(User::EProcessPermanent, "Process permanent");
+		CASE_LIT2(User::ESystemCritical, "System critical");
+		CASE_LIT2(User::ESystemPermanent, "System permanent");
+		default:
+			return TPtrC();
+		}
+	}
+
+// These lines must all be terminated by a blank string, ""
+// First item must be the description of the word, and must be <= 16 characters
+static char const *const w0[] = /* kernel debugging */ { "Word 0", "khardware", "kboot", "kserver", "kmmu", "ksemaphore", "ksched", "kproc", "kexec", "kdebugger", "kthread", "kdll", "kipc", "kpbus1", "kpbus", "kpbusdrv", "kpower", "ktiming", "kevent", "kobject", "kdfc", "kextension", "ksched2", "klocdrv", "kfail", "kthread2", "kdevice", "kmemtrace", "kdma", "kmmu2", "knkern", "kscratch", "kpanic", "" };
+static char const *const w1[] = /* kernel debugging */ { "Word 1", "kusb", "kusbpsl", "knetwork1", "knetwork2", "ksound1", "kusbhost", "kusbotg", "kusbjournal", "kusbho", "kresmanager", "kiic", "khcr", "" };
+static char const *const w2[] = /* kernel behaviour */ { "Word 2", "kallthreadssystem", "ktestfast", "ktestlatency", "kdebugmonitordisable", "kcrashmonitordisable", "" };
+static char const *const w3[] = /* kernel behaviour */  { "Word 3", "kuserheaptrace", "" };
+static char const *const w4[] = /* file server debug*/ { "" };
+static char const *const w5[] = /* file server debug*/ { "" };
+static char const *const w6[] = /* licensee specific*/ { "Word 6", "Bit 0", "Bit 1", "Bit 2", "Bit 3", "Bit 4", "Bit 5", "Bit 6", "Bit 7", "Bit 8", "Bit 9", "Bit 10", "Bit 11", "Bit 12", "Bit 13", "Bit 14", "Bit 15", "Bit 16", "Bit 17", "Bit 18", "Bit 19", "Bit 20", "Bit 21", "Bit 22", "Bit 23", "Bit 24", "Bit 25", "Bit 26", "Bit 27", "Bit 28", "Bit 29", "Bit 30", "Bit 31", "" };
+static char const *const w7[] = /* licensee specific*/ { "Word 7", "Bit 0", "Bit 1", "Bit 2", "Bit 3", "Bit 4", "Bit 5", "Bit 6", "Bit 7", "Bit 8", "Bit 9", "Bit 10", "Bit 11", "Bit 12", "Bit 13", "Bit 14", "Bit 15", "Bit 16", "Bit 17", "Bit 18", "Bit 19", "Bit 20", "Bit 21", "Bit 22", "Bit 23", "Bit 24", "Bit 25", "Bit 26", "Bit 27", "Bit 28", "Bit 29", "Bit 30", "Bit 31", "" };
+static char const *const fs[] = /* file server debug*/ { "File server", "kfsys", "kfserv", "kfldr", "kalloc", "klffs", "kiso9660", "kntfs", "krofs", "kthrd", "kcache", "kcompfs", ""};
+
+static char const*const*const KKTraceFlags[] = { w0, w1, w2, w3, w4, w5, w6, w7, fs };
+
+TPtrC8 TraceFlagName(TInt aWord, TInt aBit)
+	{
+	return gPlugin->TraceFlagName(aWord, aBit);
+	}
+
+TPtrC8 CDefaultProductPlugin::TraceFlagName(TInt aWord, TInt aBit)
+	{
+	if (iPluginForThisDevice)
+		{
+		return iPluginForThisDevice->TraceFlagName(aWord, aBit);
+		}
+
+	if (aBit == 0 && *KKTraceFlags[aWord][aBit] == 0)
+		{
+		// Special-case this because the caller expects to be able to test whether the first bit name is empty to decide whether the word is empty, and our data structure doesn't let you do that any more
+		return TPtrC8();
+		}
+
+	aBit++; // Because we use -1 to mean the word title, and the bits go from 0-32, whereas in the array the title is at index 0 and the bits go from 1 to 33
+	return TPtrC8((const TUint8*)KKTraceFlags[aWord][aBit]);
+	}
+
+// Format is tag name, followed by the names of the bits, starting from bit 0. Terminate with a "" and remember you only have 32 bits to play with!
+//const char* qres[] = { "QResources3", "Bit0", "Bit1", "Bit2", "" };
+//const char* sentinel[] = {"Sentinel", "MemoryEvent", "AppSwitch", "QMemoryManager", "" };
+static char const *const clogger[] = {"Clogger", "Log SetEnabled", "Log new tags", "Log disks", "Log new rdebuggers", ""};
+static char const *const kernel[] = {"Kern::Printf", "<unused>", "Kern::Printf", "Platsec diagnostics", ""};
+static char const *const wserv[] = {"Wserv", "Important", "Intermediate", "Everything else", ""};
+static char const *const fallback[] = {"", "Bit 0", "Bit 1", "Bit 2", "Bit 3", "Bit 4", "Bit 5", "Bit 6", "Bit 7", "Bit 8", "Bit 9", "Bit 10", "Bit 11", "Bit 12", "Bit 13", "Bit 14", "Bit 15", "Bit 16", "Bit 17", "Bit 18", "Bit 19", "Bit 20", "Bit 21", "Bit 22", "Bit 23", "Bit 24", "Bit 25", "Bit 26", "Bit 27", "Bit 28", "Bit 29", "Bit 30", "Bit 31", "" };
+
+extern char const* const* const KCloggerTags[] = {clogger, kernel, wserv, /*fallback must be the last in the list!*/fallback};
+
+#ifdef __WINS__
+#define WCHAR_TYPE TUint16
+#else
+#define WCHAR_TYPE wchar_t
+#endif
+
+WCHAR_TYPE const*const KHalAtrributes[] = {
+	L"EManufacturer",
+	L"EManufacturerHardwareRev",
+	L"EManufacturerSoftwareRev",
+	L"EManufacturerSoftwareBuild",
+	L"EModel",
+	L"EMachineUid",
+	L"EDeviceFamily",
+	L"EDeviceFamilyRev",
+	L"ECPU",
+	L"ECPUArch",
+	L"ECPUABI",
+	L"ECPUSpeed",
+	L"ESystemStartupReason",
+	L"ESystemException",
+	L"ESystemTickPeriod",
+	L"EMemoryRAM",
+	L"EMemoryRAMFree",
+	L"EMemoryROM",
+	L"EMemoryPageSize",
+	L"EPowerGood",
+	L"EPowerBatteryStatus",
+	L"EPowerBackup",
+	L"EPowerBackupStatus",
+	L"EPowerExternal",
+	L"EKeyboard",
+	L"EKeyboardDeviceKeys",
+	L"EKeyboardAppKeys",
+	L"EKeyboardClick",
+	L"EKeyboardClickState",
+	L"EKeyboardClickVolume",
+	L"EKeyboardClickVolumeMax",
+	L"EDisplayXPixels",
+	L"EDisplayYPixels",
+	L"EDisplayXTwips",
+	L"EDisplayYTwips",
+	L"EDisplayColors",
+	L"EDisplayState",
+	L"EDisplayContrast",
+	L"EDisplayContrastMax",
+	L"EBacklight",
+	L"EBacklightState",
+	L"EPen",
+	L"EPenX",
+	L"EPenY",
+	L"EPenDisplayOn",
+	L"EPenClick",
+	L"EPenClickState",
+	L"EPenClickVolume",
+	L"EPenClickVolumeMax",
+	L"EMouse",
+	L"EMouseX",
+	L"EMouseY",
+	L"EMouseState",
+	L"EMouseSpeed",
+	L"EMouseAcceleration",
+	L"EMouseButtons",
+	L"EMouseButtonState",
+	L"ECaseState",
+	L"ECaseSwitch",
+	L"ECaseSwitchDisplayOn",
+	L"ECaseSwitchDisplayOff",
+	L"ELEDs",
+	L"ELEDmask",
+	L"EIntegratedPhone",
+	L"EDisplayBrightness",
+	L"EDisplayBrightnessMax",
+	L"EKeyboardBacklightState",
+	L"EAccessoryPower",
+	L"ELanguageIndex",
+	L"EKeyboardIndex",
+	L"EMaxRAMDriveSize",
+	L"EKeyboardState",
+	L"ESystemDrive",
+	L"EPenState",
+	L"EDisplayIsMono",
+	L"EDisplayIsPalettized",
+	L"EDisplayBitsPerPixel",
+	L"EDisplayNumModes",
+	L"EDisplayMemoryAddress",
+	L"EDisplayOffsetToFirstPixel",
+	L"EDisplayOffsetBetweenLines",
+	L"EDisplayPaletteEntry",
+	L"EDisplayIsPixelOrderRGB",
+	L"EDisplayIsPixelOrderLandscape",
+	L"EDisplayMode",
+	L"ESwitches",
+	L"EDebugPort",
+	L"ELocaleLoaded",
+	L"EClipboardDrive",
+	L"ECustomRestart",
+	L"ECustomRestartReason",
+	L"EDisplayNumberOfScreens",
+	L"ENanoTickPeriod",
+	L"EFastCounterFrequency",
+	L"EFastCounterCountsUp",
+	L"EPointer3D",
+	L"EPointer3DZ",
+	L"EPointer3DThetaSupported",
+	L"EPointer3DPhiSupported",
+	L"EPointer3DRotationSupported",
+	L"EPointer3DPressureSupported",
+	L"EHardwareFloatingPoint",
+	L"ECustomResourceDrive",
+	};
+const TInt KNumHalAttributes = sizeof(KHalAtrributes) / sizeof(TUint16*);
+
+TPtrC ToStringHal(TInt aHalAttribute)
+	{
+	if (aHalAttribute >= KNumHalAttributes)
+		{
+		return TPtrC();
+		}
+	else
+		{
+		return TPtrC((TUint16*)KHalAtrributes[aHalAttribute]);
+		}
+	}
+
+void ToStringHalVal(TDes& aDes, TInt aHalAttribute, TInt aHalValue)
+	{
+	gPlugin->FormatValue(aDes, MProductPlugin::EHal, aHalAttribute, aHalValue);
+	}
+
+const TPtrC ToStringUid(TInt aVal)
+	{
+	switch(aVal)
+		{
+		CASE_LIT2(0x10279806, "KFax");
+		CASE_LIT2(0x10279807, "KPrint");
+		CASE_LIT2(0x10279808, "KBluetooth");
+		CASE_LIT2(0x10279809, "KInfrared");
+		CASE_LIT2(0x1027980a, "KMmc");
+		CASE_LIT2(0x1027980b, "KUsb");
+		CASE_LIT2(0x1027980c, "KObex");
+		CASE_LIT2(0x1027980d, "KRtpRtcp");
+		CASE_LIT2(0x1027980f, "KSip");
+		CASE_LIT2(0x10279810, "KOmaDataSync");
+		CASE_LIT2(0x10279811, "KOmaDeviceManagement");
+		CASE_LIT2(0x10279812, "KIPQoS");
+		CASE_LIT2(0x10279813, "KNetworkQoS");
+		CASE_LIT2(0x10279814, "KIPSec");
+		CASE_LIT2(0x10279815, "KDhcp");
+		CASE_LIT2(0x10279816, "KConnectivity");
+		CASE_LIT2(0x10281818, "KLocation");
+		CASE_LIT2(0x10281819, "KMobileIP");
+		CASE_LIT2(0x1028181A, "KOfflineMode");
+		CASE_LIT2(0x1028181B, "KDRM");
+		CASE_LIT2(0x10282663, "KOmaDsHostServers");
+		default: return TPtrC();
+		}
+	}
+
+TPtrC KeyName(TInt aKeyCode);
+
+void CDefaultProductPlugin::FormatValue(TDes& aDes, TValueType aType, TInt aAttrib, TInt aVal)
+	{
+	aDes.SetLength(0);
+	// Give product a chance to handle it
+	if (iPluginForThisDevice)
+		{
+		iPluginForThisDevice->FormatValue(aDes, aType, aAttrib, aVal);
+		if (aDes.Length()) return;
+		}
+
+	if (aType == MProductPlugin::EHal)
+		{
+		const TInt aHalAttribute = aAttrib;
+		const TInt aHalValue = aVal;
+		TBool hex = EFalse;
+		switch (aHalAttribute)
+			{
+			case HAL::EManufacturer:
+				{
+				switch (aHalValue)
+					{
+				case HAL::EManufacturer_Ericsson:
+					aDes = _L("Ericsson"); return;
+				case HAL::EManufacturer_Motorola:
+					aDes = _L("Motorola"); return;
+				case HAL::EManufacturer_Nokia:
+					aDes = _L("Nokia"); return;
+				case HAL::EManufacturer_Panasonic:
+					aDes = _L("Panasonic"); return;
+				case HAL::EManufacturer_Psion:
+					aDes = _L("Psion"); return;
+				case HAL::EManufacturer_Intel:
+					aDes = _L("Intel"); return;
+				case HAL::EManufacturer_Cogent:
+					aDes = _L("Cogent"); return;
+				case HAL::EManufacturer_Cirrus:
+					aDes = _L("Cirrus"); return;
+				case HAL::EManufacturer_Linkup:
+					aDes = _L("Linkup"); return;
+				case HAL::EManufacturer_TexasInstruments:
+					aDes = _L("TI"); return;
+				default:
+					hex = ETrue;
+					break;
+					}
+				break;
+				}
+			case HAL::EMemoryRAM:
+			case HAL::EMemoryRAMFree:
+			case HAL::EMemoryROM:
+			case HAL::EMemoryPageSize:
+			case HAL::EMaxRAMDriveSize:
+				HR(aDes, aHalValue);
+				return;
+			case HAL::ECPU:
+				switch (aHalValue)
+					{
+					case HAL::ECPU_ARM:
+						aDes = _L("ARM"); return;
+					case HAL::ECPU_MCORE:
+						aDes = _L("MCORE"); return;
+					case HAL::ECPU_X86:
+						aDes = _L("x86"); return;
+					default:
+						break;
+					}
+				break;
+			case HAL::EModel:
+			case HAL::EMachineUid:
+			case HAL::ELEDmask:
+			case HAL::EDisplayMemoryAddress:
+				hex = ETrue;
+				break;
+			case HAL::EDeviceFamily:
+				hex = ETrue;
+				break;
+			case HAL::ESystemDrive:
+			case HAL::EClipboardDrive:
+				if (aHalValue == -1)
+					{
+					// Emulator returns -1 for system drive...
+					aDes = _L("Unknown");
+					return;
+					}
+				aDes.SetLength(1);
+				aDes[0] = 'A' + aHalValue;
+				return;
+			default:
+				break;
+			}
+
+		// Fall back if nothing recognised it
+		if (hex)
+			{
+			aDes.Format(_L("0x%x"), aHalValue);
+			}
+		else
+			{
+			aDes.Format(_L("%i"), aHalValue);
+			}
+		} 
+	else if (aType == MProductPlugin::EKey)
+		{
+		const TInt aKeyCode = aVal;
+		TPtrC name = KeyName(aKeyCode);
+		if (name.Length())
+			{
+			aDes = name;
+			}
+		else
+			{
+			if ((aKeyCode >= 'a' && aKeyCode <= 'z') || (aKeyCode >= '0' && aKeyCode <= '9') || aKeyCode == '*' || aKeyCode == '#')
+				{
+				aDes.Append((TChar)aKeyCode);
+				}
+			else
+				{
+				aDes.AppendFormat(_L("Keycode 0x%x"), aKeyCode);
+				}
+			}
+		}
+	else if (aType == MProductPlugin::EFeature)
+		{
+		aDes = ToStringUid(aAttrib);
+		}
+	}
+
+void PrettyName(TInt aType, TDes& aName)
+	{
+	switch (aType)
+		{
+		case EListProcess:
+			{
+			// name is too long, lose the uid
+			TInt open = aName.LocateReverse('[');
+			TInt close = aName.LocateReverse(']');
+			if (open != KErrNotFound && close > open)
+				{
+				aName.Delete(open, close-open+1);
+				}
+			// Lose the nonce if its 0001
+			_LIT(KOne, "0001");
+			if (aName.Right(4) == KOne)
+				{
+				aName.SetLength(aName.Length() - 4);
+				}
+			else
+				{
+				_LIT(KSeparator, " ");
+				aName.Insert(aName.Length() - 4, KSeparator);
+				}
+			break;
+			}
+		case EListChunk:
+			{
+			// name is too long, as it can be based on thread fullname, ie procname[uid]nonce::threadname::$STK
+			// lose the uid and the nonce
+			TInt open = aName.Locate('[');
+			TInt colon = aName.Locate(':');
+			if (open != KErrNotFound && colon > open)
+				{
+				aName.Delete(open, colon-open);
+				}
+			break;
+			}
+		case EListThread:
+			{
+			// Algorithm is:
+			// Given a aName xxx(.exe)?\[uid\]nonce::(!)?yyy
+			// if yyy == xxx (case insensitive compare) then just display yyy (with exclamation mark if present)
+			// else display xxx::yyy
+
+			// Find the :: that splits thread and process name
+			_LIT(KDoubleColon, "::");
+			TInt colon = aName.Find(KDoubleColon);
+			if (colon == KErrNotFound)
+				{
+				// It's not a thread name
+				return;
+				}
+
+			// Remove .exe if present immediately before [uid]
+			TInt brak = aName.Left(colon).LocateReverse('[');
+			_LIT(KExe, ".exe");
+			if (brak >= 5 && aName.Mid(brak-4, 4).CompareF(KExe) == 0)
+				{
+				aName.Delete(brak-4, 4);
+				brak -= 4;
+				colon -= 4;
+				}
+
+			TPtrC procaName = brak >=0 ? aName.Left(brak) : aName.Left(colon);
+			TPtrC threadaName = aName.Mid(colon+2);
+			TPtrC realThreadaName = threadaName.Length() && threadaName[0] == '!' ? threadaName.Mid(1) : threadaName;
+			if (procaName.CompareF(realThreadaName) == 0)
+				{
+				aName.Delete(0, colon+2);
+				}
+			else if (brak >= 0)
+				{
+				aName.Delete(brak, colon-brak);
+				}
+			break;
+			}
+		case EListWindowGroups:
+			{
+			// Window group names aren't supposed to be proper strings, so make them friendlier
+			TInt nullPos = aName.Locate(TChar(0));
+			while (nullPos >= 0)
+				{
+				aName[nullPos] = '.';
+				nullPos = aName.Locate(TChar(0));
+				}
+			break;
+			}
+		default:
+			break;
+		}
+	}
+
+#ifdef FSHELL_SAMPLINGPROFILER_SUPPORT
+#include <profiler.h>
+
+void StartProfilerL()
+	{
+	_LIT(KProfiler,"Profiler.exe");
+	_LIT(KStartnoui,"start -noui");
+	TInt err = Profiler::Start();
+	if (err == KErrNotFound)
+		{
+		RProcess p;
+		err = p.Create(KProfiler, KStartnoui); 
+		User::LeaveIfError(err);
+		p.Resume();
+		p.Close();
+		}
+	User::LeaveIfError(err);
+	}
+
+TBool IsProfilerRunning()
+	{
+	_LIT(KProfiler,"Profiler.exe*");
+
+	TBool running = EFalse;
+	TFindProcess f(KProfiler);
+	TFullName n;
+	while (f.Next(n) == KErrNone)
+		{
+		// Have to iterate all the Profiler RProcesses to see if any of em are still running
+		RProcess p;
+		if (p.Open(f) == KErrNone)
+			{
+			TExitType exitType = p.ExitType();
+			p.Close();
+			if (exitType == EExitPending)
+				{
+				running = ETrue;
+				break;
+				}
+			}
+		}
+	return running;
+	}
+
+void StopProfiler()
+	{
+	Profiler::Unload();
+	}
+
+#else
+void StartProfilerL()
+	{
+	User::Leave(KErrNotSupported);
+	}
+
+TBool IsProfilerRunning()
+	{
+	return EFalse;
+	}
+
+void StopProfiler()
+	{
+	}
+#endif
+	
+TUint CriticalToFlags(User::TCritical aCrit)
+	{
+	switch (aCrit)
+		{
+		case User::ESystemPermanent:
+			return KThreadFlagSystemPermanent;
+		case User::ESystemCritical:
+			return KThreadFlagSystemCritical;
+		case User::EProcessPermanent:
+			return KThreadFlagProcessPermanent;
+		case User::EProcessCritical:
+			return KThreadFlagProcessCritical;
+		default:
+			return 0;
+		}
+	}
+
+User::TCritical FlagsToCritical(TUint aFlags)
+	{
+	aFlags = aFlags & (KThreadFlagSystemPermanent | KThreadFlagSystemCritical | KThreadFlagProcessPermanent | KThreadFlagProcessCritical);
+	switch (aFlags)
+		{
+		case KThreadFlagSystemPermanent:
+			return User::ESystemPermanent;
+		case KThreadFlagSystemCritical:
+			return User::ESystemCritical;
+		case KThreadFlagProcessPermanent:
+			return User::EProcessPermanent;
+		case KThreadFlagProcessCritical:
+			return User::EProcessCritical;
+		default:
+			return User::ENotCritical;
+		}
+	}
+
+TUint32 CDefaultProductPlugin::GetDeviceType()
+	{
+	TUint32 res = 0; // EUnknownDevice;
+	if (iPluginForThisDevice)
+		{
+		res = iPluginForThisDevice->GetDeviceType();
+		}
+	return res;
+	}
+
+TBool CDefaultProductPlugin::HandleErrorL(MProductPlugin::TError aType, TInt aErr)
+	{
+	TBool handled = EFalse;
+	if (iPluginForThisDevice)
+		{
+		handled = iPluginForThisDevice->HandleErrorL(aType, aErr);
+		}
+	return handled;
+	}
+
+TKeyResponse CDefaultProductPlugin::OfferKeyEventL(TKeyEvent& aEvent, TEventCode aType)
+	{
+	if (iPluginForThisDevice)
+		{
+		return iPluginForThisDevice->OfferKeyEventL(aEvent, aType);
+		}
+	return EKeyWasNotConsumed;
+	}
+
+TBool CDefaultProductPlugin::DoDynInitOrDeleteCommandL(CQikCommand*& aCommand, const CCoeControl& aControlAddingCommands)
+	{
+	if (iPluginForThisDevice)
+		{
+		return iPluginForThisDevice->DoDynInitOrDeleteCommandL(aCommand, aControlAddingCommands);
+		}
+	return EFalse;
+	}
+
+void CDefaultProductPlugin::RefreshTabL(TInt aTab)
+	{
+	if (iPluginForThisDevice)
+		{
+		iPluginForThisDevice->RefreshTabL(aTab);
+		}
+	}
+
+void CDefaultProductPlugin::LoadProductPluginL()
+	{
+	ASSERT(!gPlugin);
+	
+	CDefaultProductPlugin* plugin = new(ELeave) CDefaultProductPlugin;
+	plugin->ConstructL();
+
+#ifdef __DLL__
+	Dll::SetTls(plugin);
+#else
+	gPlugin = plugin;
+#endif
+	}
+
+void CDefaultProductPlugin::EnablePanicChecking(TBool aEnable)
+	{
+	if (iPluginForThisDeviceVersion > 1)
+		{
+		static_cast<MProductPluginV2*>(iPluginForThisDevice)->EnablePanicChecking(aEnable);
+		}
+	}
+
+TBool CDefaultProductPlugin::PanicCheckingIsEnabled()
+	{
+	if (iPluginForThisDeviceVersion > 1)
+		{
+		return static_cast<MProductPluginV2*>(iPluginForThisDevice)->PanicCheckingIsEnabled();
+		}
+	return EFalse;
+	}
+
+void CDefaultProductPlugin::DisablePanicCheckPushL()
+	{
+	if (PanicCheckingIsEnabled())
+		{
+		CleanupStack::PushL(TCleanupItem(&EnablePanicCheck, this));
+		EnablePanicChecking(EFalse);
+		}
+	else
+		{
+		// This is a no-op cleanup item, since nothing needs doing if panic checks aren't on in the first place
+		CBase* nullItem = NULL;
+		CleanupStack::PushL(nullItem);
+		}
+	}
+
+void CDefaultProductPlugin::EnablePanicCheck(TAny* aSelf)
+	{
+	static_cast<CDefaultProductPlugin*>(aSelf)->EnablePanicChecking(ETrue);
+	}
+
+NONSHARABLE_CLASS(CEcomWatcher) : public CActive
+	{
+public:
+	CEcomWatcher(REComSession& aSession, CDefaultProductPlugin& aSomething)
+		: CActive(EPriorityStandard), iSession(aSession), iSomething(aSomething)
+		{
+		CActiveScheduler::Add(this);
+		iSession.NotifyOnChange(iStatus);
+		SetActive();
+		}
+
+	~CEcomWatcher() { Cancel();	}
+
+private:
+	void RunL()
+		{
+		if (iStatus == KErrNone)
+			{
+			iSession.NotifyOnChange(iStatus);
+			SetActive();
+			}
+		iSomething.EcomChangedL();
+		}
+
+	void DoCancel() { iSession.CancelNotifyOnChange(iStatus); }
+
+private:
+	REComSession& iSession;
+	CDefaultProductPlugin& iSomething;
+	};
+
+void CDefaultProductPlugin::ConstructL()
+	{
+	//gPlugin->iPluginForThisDevice = CZebraPlugin::NewL();
+	//gPlugin->iPlugins.AppendL(gPlugin->iPluginForThisDevice);
+
+#ifndef __DLL__
+	// When running as a DLL, we don't want to mess about loading plugins
+	iEcom = REComSession::OpenL();
+	iEcomChangeWatcher = new(ELeave) CEcomWatcher(iEcom, *this);
+	RescanPluginsL();
+#endif
+	}
+
+void CDefaultProductPlugin::DestroyPlugins()
+	{
+	for (TInt i = 0; i < iPlugins.Count(); i++)
+		{
+		iPlugins[i]->Release(iShuttingDown);
+		}
+	iPlugins.Reset();
+
+	for (TInt i = 0; i < iPluginDestructors.Count(); i++)
+		{
+		REComSession::DestroyedImplementation(iPluginDestructors[i]);
+		}
+	iPluginDestructors.Reset();
+	iEcomPluginList.ResetAndDestroy();
+	iPluginForThisDevice = NULL;
+	iPluginForThisDeviceVersion = 0;
+	}
+
+void CDefaultProductPlugin::RescanPluginsL()
+	{
+	DestroyPlugins();
+	TUid KUid = {KQr3ProductPluginEcomUid};
+	REComSession::ListImplementationsL(KUid, iEcomPluginList);
+	for (TInt i = 0; i < iEcomPluginList.Count(); i++)
+		{
+		TRAP_IGNORE(LoadPluginL(iEcomPluginList[i]->ImplementationUid(), iEcomPluginList[i]->Version()));
+		// One dodgy plugin shouldn't prevent everything else loading
+		}
+	}
+
+void CDefaultProductPlugin::LoadPluginL(TUid aImplUid, TInt aVersion)
+	{
+	//__DEBUGGER();
+	TUid uid;
+	MProductPlugin* plugin = reinterpret_cast<MProductPlugin*>(REComSession::CreateImplementationL(aImplUid, uid));
+	// OK so yes it would be easier to keep the destructor key with the plugin...
+	TInt err = iPlugins.Append(plugin);
+	if (!err)
+		{
+		err = iPluginDestructors.Append(uid);
+		if (err)
+			{
+			// need to remove from iPlugins so that iPlugins and iPluginDestructors are in sync
+			iPlugins.Remove(iPlugins.Count()-1);
+			}
+		}
+	if (err)
+		{
+		plugin->Release(EFalse);
+		REComSession::DestroyedImplementation(uid);
+		User::Leave(err);
+		}
+		
+	TUint32 devType = plugin->GetDeviceType();
+	TUint32 currentDevType = iPluginForThisDevice ? iPluginForThisDevice->GetDeviceType() : 0;
+	if (devType > currentDevType)
+		{
+		iPluginForThisDevice = plugin;
+		iPluginForThisDeviceVersion = aVersion;
+		if (iParentView)
+			{
+			plugin->DoViewConstructL(iParentView);
+			}
+		}
+	}
+
+void CDefaultProductPlugin::EcomChangedL()
+	{
+	// Remove and reread all plugins
+	RescanPluginsL();
+	//PluginsChangedL(ETrue);
+	}
+
+CDefaultProductPlugin::~CDefaultProductPlugin()
+	{
+	//__DEBUGGER();
+	DestroyPlugins();
+	delete iEcomChangeWatcher;
+	iEcom.Close();
+	}
+
+void CDefaultProductPlugin::DoViewConstructL(CQikMultiPageViewBase* aParentView)
+	{
+	iParentView = aParentView;
+	if (iPluginForThisDevice)
+		{
+		iPluginForThisDevice->DoViewConstructL(aParentView);
+		}
+	}
+
+void CDefaultProductPlugin::DoHandleControlEventL(CCoeControl *aControl, MCoeControlObserver::TCoeEvent aEventType)
+	{
+	if (iPluginForThisDevice)
+		{
+		iPluginForThisDevice->DoHandleControlEventL(aControl, aEventType);
+		}
+	}
+
+TBool CDefaultProductPlugin::ConsumeMemoryKeys(TBool aDisk, TDes& aCheckboxName, TInt& aUpKeyCode, TInt& aDownKeyCode, TInt& aLogKeyCode)
+	{
+	TInt upscan, downscan, logscan;
+	return ConsumeMemoryKeys(aDisk, aCheckboxName, aUpKeyCode, upscan, aDownKeyCode, downscan, aLogKeyCode, logscan);
+	}
+
+TBool CDefaultProductPlugin::ConsumeMemoryKeys(TBool aDisk, TDes& aCheckboxName, TInt& aUpKeyCode, TInt& aUpScanCode, TInt& aDownKeyCode, TInt& aDownScanCode, TInt& aLogKeyCode, TInt& aLogScanCode)
+	{
+	// Set up defaults here. Device plugins are welcome to modify them
+	TBool display = ETrue;
+	if (aDisk)
+		{
+		aCheckboxName = _L("Use 2-way nav to consume disk");
+		}
+	else
+		{
+		aCheckboxName = _L("Use 2-way nav to consume RAM");
+		}
+#ifdef INCLUDE_UIQ_DEFINITIONS
+	aUpKeyCode = EDeviceKeyTwoWayUp;
+	aUpScanCode = EStdDeviceKeyTwoWayUp;
+	aDownKeyCode = EDeviceKeyTwoWayDown;
+	aDownScanCode = EStdDeviceKeyTwoWayDown;
+	aLogKeyCode = EDeviceKeyAction;
+	aLogScanCode = EStdDeviceKeyAction;
+#else
+	aUpKeyCode = EKeyUpArrow;
+	aUpScanCode = EStdKeyUpArrow;
+	aDownKeyCode = EKeyDownArrow;
+	aDownScanCode = EStdKeyDownArrow;
+	aLogKeyCode = EKeyEnter;
+	aLogScanCode = EStdKeyEnter;
+#endif
+	
+	if (iPluginForThisDevice && iPluginForThisDeviceVersion > 3)
+		{
+		// Supports the scancode-aware interface
+		display = static_cast<MProductPluginV4*>(iPluginForThisDevice)->ConsumeMemoryKeys(aDisk, aCheckboxName, aUpKeyCode, aUpScanCode, aDownKeyCode, aDownScanCode, aLogKeyCode, aLogScanCode);
+		}
+	else if (iPluginForThisDevice)
+		{
+		aUpScanCode = 0;
+		aDownScanCode = 0;
+		aLogScanCode = 0;
+		display = iPluginForThisDevice->ConsumeMemoryKeys(aDisk, aCheckboxName, aUpKeyCode, aDownKeyCode, aLogKeyCode);
+		}
+	return display;
+	}
+
+void CDefaultProductPlugin::Release(TBool aAppIsShuttingDown)
+	{
+	iShuttingDown = aAppIsShuttingDown;
+	delete this;
+	}
+
+void CDefaultProductPlugin::GetFeatureUidsL(RArray<TUid>& aUids)
+	{
+	const TUid KDefaultFeatures[] = 
+		{
+		/* KFax */ {0x10279806},
+		/* KPrint */ {0x10279807},
+		/* KBluetooth */ {0x10279808},
+		/* KInfrared */ {0x10279809},
+		/* KMmc */ {0x1027980a},
+		/* KUsb */ {0x1027980b},
+		/* KObex */ {0x1027980c},
+		/* KRtpRtcp */ {0x1027980d},
+		/* KSip */ {0x1027980f},
+		/* KOmaDataSync */ {0x10279810},
+		/* KOmaDeviceManagement */ {0x10279811},
+		/* KIPQoS */ {0x10279812},
+		/* KNetworkQoS */ {0x10279813},
+		/* KIPSec */ {0x10279814},
+		/* KDhcp */ {0x10279815},
+		/* KConnectivity */ {0x10279816},
+		/* KLocation */ {0x10281818},
+		/* KMobileIP */ {0x10281819},
+		/* KOfflineMode */ {0x1028181A},
+		/* KDRM */ {0x1028181B},
+		/* KOmaDsHostServers */ {0x10282663},
+		};
+	const TInt KNumFeatures = sizeof(KDefaultFeatures) / sizeof(TUid);
+	for (TInt i = 0; i < KNumFeatures; i++)
+		{
+		aUids.AppendL(KDefaultFeatures[i]);
+		}
+
+	if (iPluginForThisDeviceVersion > 2)
+		{
+		static_cast<MProductPluginV3*>(iPluginForThisDevice)->GetFeatureUidsL(aUids);
+		}
+	}
+
+TPtrC KeyName(TInt aKeyCode)
+	{
+	enum TStuffNotDefinedInAllReleases
+		{
+		EKeyDevice20 = EKeyApplication1F + 1,
+		EKeyDevice21,
+		EKeyDevice22,
+		EKeyDevice23,
+		EKeyDevice24,
+		EKeyDevice25,
+		EKeyDevice26,
+		EKeyDevice27,
+		EKeyApplication20,
+		EKeyApplication21,
+		EKeyApplication22,
+		EKeyApplication23,
+		EKeyApplication24,
+		EKeyApplication25,
+		EKeyApplication26,
+		EKeyApplication27,
+		};
+
+	switch(aKeyCode)
+		{
+#ifdef INCLUDE_UIQ_DEFINITIONS
+		CASE_LIT2(EDeviceKeyTwoWayUp, "2-way up");
+		CASE_LIT2(EDeviceKeyTwoWayDown, "2-way down");
+		CASE_LIT2(EDeviceKeyFourWayUp, "4-way up");
+		CASE_LIT2(EDeviceKeyFourWayDown, "4-way down");
+		CASE_LIT2(EDeviceKeyFourWayLeft, "4-way left");
+		CASE_LIT2(EDeviceKeyFourWayRight, "4-way right");
+		CASE_LIT2(EDeviceKeyAction, "Confirm");
+		CASE_LIT2(EDeviceKeyHomeScreen, "Home key");
+		CASE_LIT2(EDeviceKeyCameraFocusLock, "Camera focus");
+		CASE_LIT2(EDeviceKeyCameraShutter, "Camer shutter");
+		CASE_LIT2(EDeviceKeyLock, "Key lock");
+		CASE_LIT2(EDeviceKeyMultimedia, "Multimedia key");
+		CASE_LIT2(EDeviceKeyIncVolume, "Volume up");
+		CASE_LIT2(EDeviceKeyDecVolume, "Volume down");
+		CASE_LIT2(EDeviceKeyPower, "Power");
+		CASE_LIT2(EDeviceKeyVideoCall, "Video Call");
+#else
+		// These are things that have the same value as UIQ definitions above, thus we can't include them twice in the switch
+		CASE_LIT(EKeyDevice1);
+		CASE_LIT(EKeyDevice2);
+		CASE_LIT(EKeyDevice4);
+		CASE_LIT(EKeyDevice5);
+		CASE_LIT(EKeyDevice6);
+		CASE_LIT(EKeyDevice7);
+		CASE_LIT(EKeyDevice8);
+		CASE_LIT(EKeyDeviceD);
+		CASE_LIT(EKeyApplication1);
+		CASE_LIT(EKeyApplication3);
+		CASE_LIT(EKeyApplication5);
+#endif
+		CASE_LIT2(EKeyBackspace, "Backspace");
+		CASE_LIT2(EKeyEnter, "Return");
+		CASE_LIT2(EKeySpace, "Space");
+		CASE_LIT2(EKeyLeftArrow, "Left arrow");
+		CASE_LIT2(EKeyRightArrow, "Right arrow");
+		CASE_LIT2(EKeyUpArrow, "Up arrow");
+		CASE_LIT2(EKeyDownArrow, "Down arrow");
+		CASE_LIT2(EKeyYes, "GREEN key");
+		CASE_LIT2(EKeyNo, "RED key");
+		CASE_LIT(EKeyDevice0);
+		CASE_LIT(EKeyDevice3);
+		CASE_LIT(EKeyDevice9);
+		CASE_LIT(EKeyDeviceA);
+		CASE_LIT(EKeyDeviceB);
+		CASE_LIT(EKeyDeviceC);
+		CASE_LIT(EKeyDeviceE);
+		CASE_LIT(EKeyDeviceF);
+#ifdef FSHELL_PLATFORM_S60
+		CASE_LIT2(EKeyApplication0, "Menu");
+#else
+		CASE_LIT(EKeyApplication0);
+#endif
+		CASE_LIT(EKeyApplication2);
+		CASE_LIT(EKeyApplication4);
+		CASE_LIT(EKeyApplication6);
+		CASE_LIT(EKeyApplication7);
+		CASE_LIT(EKeyApplication8);
+		CASE_LIT(EKeyApplication9);
+		CASE_LIT(EKeyApplicationA);
+		CASE_LIT(EKeyApplicationB);
+		CASE_LIT(EKeyApplicationC);
+		CASE_LIT(EKeyApplicationD);
+		CASE_LIT(EKeyApplicationE);
+		CASE_LIT(EKeyApplicationF);
+		CASE_LIT(EKeyDevice10);
+		CASE_LIT(EKeyDevice11);
+		CASE_LIT(EKeyDevice12);
+		CASE_LIT(EKeyDevice13);
+		CASE_LIT(EKeyDevice14);
+		CASE_LIT(EKeyDevice15);
+		CASE_LIT(EKeyDevice16);
+		CASE_LIT(EKeyDevice17);
+		CASE_LIT(EKeyDevice18);
+		CASE_LIT(EKeyDevice19);
+		CASE_LIT(EKeyDevice1A);
+		CASE_LIT(EKeyDevice1B);
+		CASE_LIT(EKeyDevice1C);
+		CASE_LIT(EKeyDevice1D);
+		CASE_LIT(EKeyDevice1E);
+		CASE_LIT(EKeyDevice1F);
+		CASE_LIT(EKeyApplication10);
+		CASE_LIT(EKeyApplication11);
+		CASE_LIT(EKeyApplication12);
+		CASE_LIT(EKeyApplication13);
+		CASE_LIT(EKeyApplication14);
+		CASE_LIT(EKeyApplication15);
+		CASE_LIT(EKeyApplication16);
+		CASE_LIT(EKeyApplication17);
+		CASE_LIT(EKeyApplication18);
+		CASE_LIT(EKeyApplication19);
+		CASE_LIT(EKeyApplication1A);
+		CASE_LIT(EKeyApplication1B);
+		CASE_LIT(EKeyApplication1C);
+		CASE_LIT(EKeyApplication1D);
+		CASE_LIT(EKeyApplication1E);
+		CASE_LIT(EKeyApplication1F);
+		CASE_LIT(EKeyDevice20);
+		CASE_LIT(EKeyDevice21);
+		CASE_LIT(EKeyDevice22);
+		CASE_LIT(EKeyDevice23);
+		CASE_LIT(EKeyDevice24);
+		CASE_LIT(EKeyDevice25);
+		CASE_LIT(EKeyDevice26);
+		CASE_LIT(EKeyDevice27);
+		CASE_LIT(EKeyApplication20);
+		CASE_LIT(EKeyApplication21);
+		CASE_LIT(EKeyApplication22);
+		CASE_LIT(EKeyApplication23);
+		CASE_LIT(EKeyApplication24);
+		CASE_LIT(EKeyApplication25);
+		CASE_LIT(EKeyApplication26);
+		CASE_LIT(EKeyApplication27);
+		default:
+			return TPtrC();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/featreglistboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,51 @@
+// featreglistboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+
+CFeatRegListBoxData::CFeatRegListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CFeatRegListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
+	{
+	SFeature& info = *reinterpret_cast<SFeature*>(aInfo);
+	more.Format(_L("Value: %i Info: %i"), info.iErr, info.iInfo);
+	gPlugin->FormatValue(name, MProductPlugin::EFeature, info.iFeature, 0);
+	}
+
+void CFeatRegListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	_LIT(KFeatureDesc,"Feature;Uid;Name;Value;Info");
+	_LIT(KFeatureFmt, "Feature;0x%x;%S;%i;%i");
+
+	if (i == 0) clogger.Log(KFeatureDesc);
+	SFeature& info = *reinterpret_cast<SFeature*>(iInfo);
+	TBuf<256> buf;
+	gPlugin->FormatValue(buf, MProductPlugin::EFeature, info.iFeature, 0);
+	clogger.Log(KFeatureFmt, info.iFeature, &buf, info.iErr, info.iInfo);
+	}
+
+void CFeatRegListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* /*name*/)
+	{
+	SFeature& info = *reinterpret_cast<SFeature*>(iInfo);
+
+	_LIT(KInfo, "Feature info");
+	aTitle.Copy(KInfo);
+
+	gPlugin->FormatValue(inf, MProductPlugin::EFeature, info.iFeature, 0);
+	_LIT(KFeatureFmt, "\n0x%x\n\nFeature present: %i\n(Additional info: %i)");
+
+	inf.AppendFormat(KFeatureFmt, info.iFeature, info.iErr, info.iInfo);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/halListboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+// halListboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+#include <HAL.h>
+
+CHalListBoxData::CHalListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CHalListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId)
+	{
+	SHalInfo& info = *reinterpret_cast<SHalInfo*>(aInfo);
+	name.Copy(ToStringHal(info.iAttribute));
+	ToStringHalVal(more, info.iAttribute, info.iValue);
+	if (info.iProperties & HAL::EEntryDynamic)
+		{
+		more.Append(_L(" (Dynamic)"));
+		}
+	itemId = info.iAttribute;
+	}
+
+void CHalListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	_LIT(KHalDesc,"HAL;Number;Name;Value;ValueHumanReadable;Flags");
+	_LIT(KHalFmt,"HAL;%i;%S;%i;%S;%i");
+
+	if (i == 0) clogger.Log(KHalDesc);
+	SHalInfo& info = *reinterpret_cast<SHalInfo*>(iInfo);
+	TPtrC name = ToStringHal(info.iAttribute);
+	RBuf val;
+	val.CreateL(256);
+	ToStringHalVal(val, info.iAttribute, info.iValue);
+	clogger.Log(KHalFmt, info.iAttribute, &name, info.iValue, &val, info.iProperties);
+	val.Close();
+	}
+
+void CHalListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* /*aName*/)
+	{
+	SHalInfo& info = *reinterpret_cast<SHalInfo*>(iInfo);
+	_LIT(KInfo, "HAL info");
+	aTitle.Copy(KInfo);
+	TPtrC name = ToStringHal(info.iAttribute);
+	RBuf val;
+	val.CreateL(256);
+	ToStringHalVal(val, info.iAttribute, info.iValue);
+	_LIT(KHalFmt, "%S\n%S\n\n(Id: %i Val: %i/0x%x)");
+	inf.Format(KHalFmt, &name, &val, info.iAttribute, info.iValue, info.iValue);
+	val.Close();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/heap.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,247 @@
+// heap.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/qr3dll.h>
+#include <fshell/memoryaccess.h>
+#include <f32file.h>
+
+EXPORT_C RProxyHeap::RProxyHeap(RMemoryAccess& aMem, TUint aThreadId)
+	: RHeap(), iMem(aMem), iThreadId(aThreadId)
+	{
+	}
+
+EXPORT_C void /*CHeapAnalyser::*/ GetHeapDetailsL(THeapDetails& aDetails, RProxyHeap& heap)
+	{
+	// This function retained for BC reasons
+	heap.GetHeapDetailsL(aDetails);
+	}
+
+EXPORT_C void RProxyHeap::GetHeapDetailsL(THeapDetails& aDetails)
+	{
+#ifdef FSHELL_ANALYSEHEAP_SUPPORT
+	RProxyHeap& heap = *this;
+	RMemoryAccess& iMemoryAccess = heap.iMem;
+	TUint aThreadId = heap.iThreadId;
+
+	TUint8* allocatorAddress;
+	User::LeaveIfError(iMemoryAccess.GetAllocatorAddress(aThreadId, allocatorAddress));
+	
+	TThreadMemoryAccessParams params;
+	params.iId = aThreadId;
+	params.iAddr = allocatorAddress;
+	params.iSize = sizeof(RHeap);
+	TPckg<RHeap> heapPckg(heap);
+	User::LeaveIfError(iMemoryAccess.GetThreadMem(params, heapPckg));
+	
+	// Base address of the heap
+	aDetails.iBase = heap.Base(); // inline, returns member variable
+	// First free cell address in the heap
+	aDetails.iFirstFree = (TUint8*)heap.iFree.next; // direct read from member variable
+	// Top address of the heap
+	aDetails.iTop = heap.iTop;
+	// Size of heap
+	aDetails.iSize = heap.Size(); // inline, returns member variables (after simple maths)
+	
+	// Heap cell header size
+	#ifdef UREL_E32
+	aDetails.iCellHeaderSize = sizeof(RHeap::SCell*);
+	#elif UDEB_E32
+	aDetails.iCellHeaderSize = sizeof(RHeap::SDebugCell); // If allocator's UDEB-ness matches ours
+	#else // match E32 and our own UDEB/URELness
+	aDetails.iCellHeaderSize = RHeap::EAllocCellSize; // If allocator is urel and we're not
+	#endif
+	
+	aDetails.iTotalAllocSize = heap.iTotalAllocSize;
+
+	aDetails.iCellCount = heap.iCellCount;
+#else
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+//BEGIN pinched directly from anaylseheapremote
+
+_LIT(KLitUnderscore, "_");
+_LIT(KLitHeap, ".heap");
+_LIT(KLitDash, "-");
+_LIT(KLitIllegals, ":@[]{}%");
+	
+#define AH_DEBUG(x)
+#define AH_DEBUGINT(x,y)
+
+EXPORT_C void RProxyHeap::DumpHeapToSuitableFileInDirectoryL(TFileName& aName)
+	{
+	TUint aThreadId = iThreadId;
+
+	AH_DEBUG("Dumping to file");
+	RThread theThread;
+	User::LeaveIfError(theThread.Open(aThreadId));
+	CleanupClosePushL(theThread);
+	AH_DEBUG("Opened thread");
+
+	//BaflUtils::
+	// create a filename <location>\threadName_threadId.heap
+	TFileName& theFileName(aName);
+	const TInt fullNameLengthToTake = theFileName.MaxLength() - theFileName.Length() - KLitHeap().Length() - KLitUnderscore().Length() - 4; // 4 for thread ID number
+	TFullName cleanedName = theThread.FullName().Left(fullNameLengthToTake);
+	for (TInt whichIllegal = 0;whichIllegal < KLitIllegals().Length(); whichIllegal++)
+		{
+		TChar thisIllegal = KLitIllegals()[whichIllegal];
+		TInt where;
+		while ((where = cleanedName.Locate(thisIllegal)) != KErrNotFound)
+			cleanedName.Replace(where,1,KLitDash());
+		}
+	theFileName.Append(cleanedName);
+	theFileName.Append(KLitUnderscore);
+	theFileName.AppendNum(theThread.Id());
+	theFileName.Append(KLitHeap);
+	//RDebug::Print(_L("The filename is %S"), &theFileName);
+	CleanupStack::PopAndDestroy(); // theThread
+	AH_DEBUG("Constructed filename");
+	DumpHeapToFileL(theFileName);
+	}
+
+EXPORT_C void RProxyHeap::DumpHeapToFileL(const TDesC& aFileName)
+	{
+	AH_DEBUG("Dumping to arbitrary file");
+	// Open the file
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+	AH_DEBUG("Connected to F32");
+	TInt err = fs.Delete(aFileName);
+	if (err != KErrNotFound && err != KErrNone)
+		User::Leave(err);
+	AH_DEBUG("File deleted");
+	RFile f;
+	User::LeaveIfError(f.Create(fs,aFileName,EFileWrite));
+	CleanupClosePushL(f);
+	AH_DEBUG("File created");
+	DumpHeapL(f);
+	AH_DEBUG("Heap dump appeared to succeed");
+	User::LeaveIfError(f.Flush());
+	AH_DEBUG("File flushed");
+	CleanupStack::PopAndDestroy(2); // f, fs
+	}
+
+static void DumpCodeSegsL(RMemoryAccess& aMem, RFile& aDumpFile);
+
+EXPORT_C void RProxyHeap::DumpHeapL(RFile& aDumpFile)
+	{
+	TUint aThreadId = iThreadId;
+	// get the thread
+	RThread thread;
+	AH_DEBUG("Opening thread");
+	User::LeaveIfError(thread.Open(aThreadId));
+	AH_DEBUG("Opened thread");
+	
+	THeapDetails heapDetails;
+	GetHeapDetailsL(heapDetails);
+	
+	// write out the heap file in the version 3 format documented in the 'docs' folder.
+	
+	// 4 bytes: file format version number (Not present for version 1, number found would be heap base & therefore v.big, >1000)	
+	TInt version = 3;
+	AH_DEBUG("Dumping version");
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&version, 4)));
+	
+	// 4 bytes: thread ID
+	AH_DEBUG("Dumping thread ID");
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&aThreadId, 4)));
+	
+	// 4 bytes: owning process - appears unused
+	AH_DEBUG("Dumping owning process");
+	TInt nothing = 0;
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&nothing, 4)));
+	
+	// 4 bytes: length of thread name
+	AH_DEBUG("Dumping thread name length");
+	TName threadName = thread.FullName();
+	TInt threadNameLength = threadName.Length();
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&threadNameLength, 4)));
+	
+	// a bytes: thread name
+	AH_DEBUG("Dumping thread name");
+	HBufC8* asciiName = HBufC8::NewLC(threadNameLength);
+	asciiName->Des().Copy(threadName);
+	User::LeaveIfError(aDumpFile.Write(*asciiName));
+	CleanupStack::PopAndDestroy(asciiName);
+	
+
+	// 4 bytes: base address of the heap
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&heapDetails.iBase, 4)));
+	// 4 bytes: first free cell address in the heap
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&heapDetails.iFirstFree, 4)));
+	// 4 bytes: top address of the heap
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&heapDetails.iTop, 4)));
+	// 4 bytes: cell header size
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&heapDetails.iCellHeaderSize, 4)));
+	// 4 bytes: heap size (n)
+	User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&heapDetails.iSize, 4)));
+	
+	// n bytes: heap contents
+	// Need to read this across the process boundary
+	// We need to copy in several chunks as memoryaccess_eka2 cannot currently
+	// copy > 4096 bytes in one go.
+	// But this number is not advertised by the memoryaccess_eka2 interface,
+	// so we will have to be a bit careful in case it changes in future versions.
+	const TInt KChunkSize = 4096;
+	AH_DEBUG("Allocating heap storage buffer");
+	HBufC8* heapBig = HBufC8::NewLC(KChunkSize);
+	TPtr8 myPtr = heapBig->Des();
+	TUint8* currentPointer = heapDetails.iBase;
+	TUint8* endPointer = currentPointer + heapDetails.iSize;
+	TThreadMemoryAccessParams paramsForHeap;
+	paramsForHeap.iId = aThreadId;
+	while (currentPointer < endPointer)
+		{
+		AH_DEBUGINT("Copying heap from %d", currentPointer);
+		paramsForHeap.iAddr = currentPointer;
+		paramsForHeap.iSize = Min(KChunkSize, (endPointer - currentPointer));
+		AH_DEBUGINT("Length to copy %d", paramsForHeap.iSize);
+		User::LeaveIfError(iMem.GetThreadMem(paramsForHeap, myPtr));
+		AH_DEBUG("Writing some heap");	
+		User::LeaveIfError(aDumpFile.Write(*heapBig));
+		currentPointer += heapBig->Length();
+		}
+	CleanupStack::PopAndDestroy(heapBig);
+	
+	// Now output the code segment details
+	iMem.AcquireCodeSegMutex();
+	TRAPD(err,DumpCodeSegsL(iMem, aDumpFile));
+	iMem.ReleaseCodeSegMutex();
+	User::LeaveIfError(err);
+	}
+	
+void DumpCodeSegsL(RMemoryAccess& aMem, RFile& aDumpFile)
+	{
+	TCodeSegKernelInfo info;
+	TPckg<TCodeSegKernelInfo> infoPckg(info);
+	while (aMem.GetNextCodeSegInfo(infoPckg))
+		{
+		// 4 bytes: Code segment run address
+		AH_DEBUG("Dumping code seg run address");
+		
+		User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&info.iRunAddress, 4)));
+		// 4 bytes: Code segment size
+		AH_DEBUG("Dumping code seg size");
+		User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&info.iSize, 4)));
+		// 4 bytes: Code segment filename length
+		AH_DEBUG("Dumping code seg filename length");
+		TInt nameLength = info.iFileName.Length();
+		User::LeaveIfError(aDumpFile.Write(TPtrC8((TUint8*)&nameLength, 4)));
+		// 4 bytes: Code segment filename length
+		AH_DEBUG("Dumping code seg filename length");
+		User::LeaveIfError(aDumpFile.Write(info.iFileName));
+		}
+	}
+
+//END nicked
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/keycapture.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,503 @@
+// keycapture.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/qr3dll.h>
+
+class RWsSession;
+class RWindowGroup;
+
+#include <fshell/common.mmh>
+#ifdef FSHELL_WSERV_SUPPORT
+#include <w32std.h>
+#endif
+
+//#define KEYCAPTURE_DEBUG(args...) RDebug::Printf(args)
+#define KEYCAPTURE_DEBUG(args...) 
+
+enum
+	{
+	ELongCapture = 1,
+	ECaptureIsDummy = 2,
+	ECaptureIsKeyUpDown = 4,
+	};
+
+struct SCapture
+	{
+	MCaptureInterface* iClient;
+	TInt iIdentifier;
+	TInt iOriginalCode; // This is the code we were actually passed in.
+	TInt iCaptureCode; // This is the key code we call capture on. This will be the same as iOriginalCode for a normal capture. For a long capture, it will be a virtual key. For an up-and-down, it will be the scan code equivalent of iOriginalCode
+	TInt32 iCaptureHandle;
+	TUint32 iFlags;
+	TInt iPriority;
+	};
+
+#define iWs (*reinterpret_cast<RWsSession*>(iOpaque1))
+#define iWg (*reinterpret_cast<RWindowGroup*>(iOpaque2))
+#define iCaptures (*reinterpret_cast<CArrayFixFlat<SCapture>**>(&iOpaque3))
+#define iPushList (*reinterpret_cast<CArrayPtrFlat<CArrayFixFlat<SCapture> >**>(&iOpaque4))
+#define KSpareKeysMask 0xF
+
+#define KSpareKeyRange EKeyF9 // We use the range F9-F12 inclusive as that seems to be about the only range that I can find not being used by UIQ or licensees
+
+CKeyCapturer::CKeyCapturer()
+	: CActive(CActive::EPriorityUserInput)
+	, iUsedSpareKeys(0)
+	{
+	}
+
+void CKeyCapturer::ConstructL()
+	{
+#ifdef FSHELL_WSERV_SUPPORT
+	__ASSERT_COMPILE(sizeof(RWsSession) == EOpaquePadding1);
+	__ASSERT_COMPILE(sizeof(RWindowGroup) == EOpaquePadding2);
+	User::LeaveIfError(iWs.Connect());
+	iWg = RWindowGroup(iWs);
+	User::LeaveIfError(iWg.Construct((TUint32)this, EFalse));
+	iWg.SetOrdinalPosition(-1,-1); // This appears to be needed to solve a race condition whereby someone creates a new window (or window group, or something) at roughly the same time as we do, which prevents the other window from coming to the foreground
+	User::LeaveIfError(iWg.SetName(_L("CKeyCapturerWindowGroup"))); // To ease debugging in wserv
+
+	iCaptures = new(ELeave) CArrayFixFlat<SCapture>(8);
+	iPushList = new(ELeave) CArrayPtrFlat<CArrayFixFlat<SCapture> >(8);
+
+	CActiveScheduler::Add(this);
+	iWs.EventReady(&iStatus);
+	SetActive();
+#else
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+EXPORT_C void CKeyCapturer::AddCaptureL(MCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode)
+	{
+	AddCaptureL(aClient, aIdentifier, aKeyCode, 0, KMaxTInt);
+	}
+
+EXPORT_C void CKeyCapturer::AddCaptureL(MCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode, TInt aScanCode, TInt aCapturePriority)
+	{
+	if (aKeyCode == 0 || !aClient) User::Leave(KErrArgument);
+	RemoveCapture(aClient, aIdentifier); // Just in case it's already been set
+
+	SCapture cap;
+	cap.iClient = aClient;
+	cap.iIdentifier = aIdentifier;
+	cap.iCaptureCode = aKeyCode;
+	cap.iOriginalCode = aKeyCode;
+	cap.iFlags = 0;
+	cap.iPriority = aCapturePriority;
+
+	AddCaptureL(cap);
+
+	if (aScanCode)
+		{
+		// If we've been passed a scan code, use it to capture the keyup and keydown events too
+		SCapture upanddownCap;
+		upanddownCap.iClient = NULL;
+		upanddownCap.iIdentifier = -1;
+		upanddownCap.iCaptureCode = aScanCode;
+		upanddownCap.iOriginalCode = aScanCode;
+		upanddownCap.iFlags = ECaptureIsDummy | ECaptureIsKeyUpDown;
+		upanddownCap.iPriority = aCapturePriority;
+
+		TRAPD(err, AddCaptureL(upanddownCap));
+		if (err)
+			{
+			CancelCapture(cap);
+			iCaptures->Delete(iCaptures->Count()-1);
+			User::Leave(err);
+			}
+		}
+	}
+
+EXPORT_C void CKeyCapturer::AddLongCaptureL(MCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode, TInt aScanCode)
+	{
+	AddLongCaptureL(aClient, aIdentifier, aKeyCode, aScanCode, KMaxTInt);
+	}
+
+EXPORT_C void CKeyCapturer::AddLongCaptureL(MCaptureInterface* aClient, TInt aIdentifier, TInt aKeyCode, TInt aScanCode, TInt aCapturePriority)
+	{
+	if (aKeyCode == 0 || aScanCode == 0 || !aClient) User::Leave(KErrArgument);
+	RemoveCapture(aClient, aIdentifier); // Just in case it's already been set
+
+	SCapture cap;
+	cap.iClient = aClient;
+	cap.iIdentifier = aIdentifier;
+	cap.iCaptureCode = 0; // Is filled in later
+	cap.iOriginalCode = aKeyCode;
+	cap.iFlags = ELongCapture;
+	cap.iPriority = aCapturePriority;
+
+	AddCaptureL(cap);
+	
+	// In order to get repeat events (and, by extension, long key presses) the key events
+	// must be going to the window group that's capturing the long press. Therefore,
+	// we also need to capture the key events even if we don't have any client for that
+	// key.
+	//
+	// Of course, this isn't documented anywhere.
+	SCapture keyCap;
+	keyCap.iClient = NULL; // So that no action is taken when a short press occurs
+	keyCap.iIdentifier = -1;
+	keyCap.iCaptureCode = aKeyCode;
+	keyCap.iOriginalCode = aKeyCode;
+	keyCap.iFlags = ECaptureIsDummy;
+	keyCap.iPriority = aCapturePriority;
+	
+	TRAPD(err, AddCaptureL(keyCap));
+	if (err)
+		{
+		CancelCapture(cap);
+		iCaptures->Delete(iCaptures->Count()-1);
+		User::Leave(err);
+		}
+
+	// And finally, do a upanddown capture as well, for good measure (TODO do this for normal captures as well, but need the scancode... grr.
+	SCapture upanddownCap;
+	upanddownCap.iClient = NULL;
+	upanddownCap.iIdentifier = -1;
+	upanddownCap.iCaptureCode = aScanCode;
+	upanddownCap.iOriginalCode = aScanCode;
+	upanddownCap.iFlags = ECaptureIsDummy | ECaptureIsKeyUpDown;
+	upanddownCap.iPriority = aCapturePriority;
+
+	TRAP(err, AddCaptureL(upanddownCap));
+	if (err)
+		{
+		CancelCapture(keyCap);
+		iCaptures->Delete(iCaptures->Count()-1);
+		CancelCapture(cap);
+		iCaptures->Delete(iCaptures->Count()-1);
+		User::Leave(err);
+		}
+	}
+
+void CKeyCapturer::AddCaptureL(SCapture& cap)
+	{
+#ifdef FSHELL_WSERV_SUPPORT
+	TBool isLong = (cap.iFlags & ELongCapture);
+	TBool isUpDown = (cap.iFlags & ECaptureIsKeyUpDown);
+	//ASSERT(iFlags & (ELongCapture | ECaptureIsKeyUpDown) == 0); // Can't be both a long capture and an up-down
+
+	if (isLong && iUsedSpareKeys == KSpareKeysMask)
+		{
+		// No more keys available to remap as long key presses
+		User::Leave(KErrOverflow);
+		}
+
+	if (cap.iPriority == KMaxTInt) cap.iPriority = KMaxTInt-1; // Internally somewhere wserv adds one to the priority, and KMaxTInt+1 is KMinTInt...
+
+	KEYCAPTURE_DEBUG("KC: AddCapture ident=%d on key=%d, long=%d, updown=%d, dummy=%d)", cap.iIdentifier, cap.iOriginalCode, isLong, isUpDown, cap.iFlags&ECaptureIsDummy);
+
+	iCaptures->SetReserveL(iCaptures->Count() + 1); // So that the AppendL later cannot fail
+	if (isLong)
+		{
+		TInt spareKey = -1; // There's a cleaner way to work this out, but since there's only 4, what's the point?
+		if ((iUsedSpareKeys & 1) == 0) spareKey = 0;
+		else if ((iUsedSpareKeys & 2) == 0) spareKey = 1;
+		else if ((iUsedSpareKeys & 4) == 0) spareKey = 2;
+		else if ((iUsedSpareKeys & 8) == 0) spareKey = 3;
+		ASSERT(spareKey != -1); // Otherwise the check at the top should have caught this case
+		cap.iCaptureCode = KSpareKeyRange + spareKey;
+		
+		cap.iCaptureHandle = iWg.CaptureLongKey(cap.iOriginalCode, cap.iCaptureCode, 0, 0, cap.iPriority, ELongCaptureWaitShort);
+		User::LeaveIfError(cap.iCaptureHandle);
+		iUsedSpareKeys |= 1 << spareKey;
+		}
+	else if (isUpDown)
+		{
+		cap.iCaptureHandle = iWg.CaptureKeyUpAndDowns(cap.iCaptureCode, 0, 0, cap.iPriority);
+		User::LeaveIfError(cap.iCaptureHandle);
+		}
+	else
+		{
+		cap.iCaptureHandle = iWg.CaptureKey(cap.iCaptureCode, 0, 0, cap.iPriority);
+		User::LeaveIfError(cap.iCaptureHandle);
+		}
+	iCaptures->AppendL(cap);
+#else
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+EXPORT_C void CKeyCapturer::RemoveCapture(MCaptureInterface* aClient, TInt aIdentifier)
+	{
+	// Linear search thru iCaptures
+	for (TInt i = 0; i < iCaptures->Count(); i++)
+		{
+		SCapture cap = iCaptures->operator[](i); // Copy cap so we can use it after it's been deleted below
+		if (cap.iIdentifier == aIdentifier)
+			{
+			ASSERT(cap.iClient == aClient);
+			(void)aClient; // For urel aClient is unused
+			
+			CancelCapture(cap);
+			iCaptures->Delete(i);
+			RemoveDummyForCapture(cap);
+			break;
+			}
+		}
+	}
+
+void CKeyCapturer::CancelCapture(SCapture& cap)
+	{
+#ifdef FSHELL_WSERV_SUPPORT
+	KEYCAPTURE_DEBUG("KC: CancelCapture ident=%d, captureCode=%d, flags=%d", cap.iIdentifier, cap.iCaptureCode, cap.iFlags);
+	if (cap.iFlags & ELongCapture)
+		{
+		iWg.CancelCaptureLongKey(cap.iCaptureHandle);
+		TInt bit = cap.iCaptureCode - KSpareKeyRange;
+		iUsedSpareKeys &= ~(1<<bit);
+		}
+	else if (cap.iFlags & ECaptureIsKeyUpDown)
+		{
+		iWg.CancelCaptureKeyUpAndDowns(cap.iCaptureHandle);
+		}
+	else
+		{
+		iWg.CancelCaptureKey(cap.iCaptureHandle);
+		}
+#endif
+	}
+
+CKeyCapturer::~CKeyCapturer()
+	{
+	Cancel();
+
+	for (TInt i = 0; i < iCaptures->Count(); i++)
+		{
+		SCapture& cap = iCaptures->operator[](i);
+		CancelCapture(cap);
+		}
+	delete iCaptures;
+	iPushList->ResetAndDestroy();
+	delete iPushList;
+#ifdef FSHELL_WSERV_SUPPORT
+	iWg.Close();
+	iWs.Close();
+#endif
+	}
+
+void CKeyCapturer::RunL()
+	{
+#ifdef FSHELL_WSERV_SUPPORT
+	TWsEvent e;
+	iWs.GetEvent(e);
+
+	iWs.EventReady(&iStatus);
+	SetActive();
+
+	if (e.Type() == EEventKey || e.Type() == EEventKeyDown || e.Type() == EEventKeyUp)
+		{
+		TInt code = e.Key()->iCode;
+		TInt scanCode = e.Key()->iScanCode;
+		KEYCAPTURE_DEBUG("KC: Received key event (type=%d, key=%d, scan=%d, rep=%d)", e.Type(), code, scanCode, e.Key()->iRepeats);
+
+		SCapture* foundDummyCapture = NULL;
+		
+		// Linear search thru iCaptures
+		for (TInt i = 0; i < iCaptures->Count(); i++)
+			{
+			SCapture& cap = iCaptures->operator[](i);
+			
+			TBool match;
+			if (e.Type() == EEventKeyDown || e.Type() == EEventKeyUp)
+				{
+				match = (scanCode == cap.iCaptureCode) && (cap.iFlags & ECaptureIsKeyUpDown);
+				}
+			else
+				{
+				match = (code == cap.iCaptureCode) && !(cap.iFlags & ECaptureIsKeyUpDown);
+				}
+				
+			if (match)
+				{
+				TBool dummy = cap.iFlags & ECaptureIsDummy;
+				if (cap.iClient && !dummy)
+					{
+					iLastEventScanCode = e.Key()->iScanCode;
+					KEYCAPTURE_DEBUG("KC: Sending event ident=%d to client", cap.iIdentifier);
+					cap.iClient->CapturedKeyPressedL(cap.iIdentifier);
+					iLastEventScanCode = 0;
+					}
+				if (dummy)
+					{
+					// If it's a dummy capture tied to a particular long key press, then we want to keep looking just in case there's something else that has genuinely captured the key
+					// Also we remember the dummy in case we don't find any other capture, because we need to forward on uncaptured dummies
+					foundDummyCapture = &cap;
+					}
+				else
+					{
+					foundDummyCapture = NULL;
+					break;
+					}
+				}
+			}
+		if (foundDummyCapture)
+			{
+			KEYCAPTURE_DEBUG("KC: Capture is dummy, passing on to frontmost windowgroup");
+			TInt foc = iWs.GetFocusWindowGroup();
+			if (foc != iWg.Identifier())
+				{
+				// Send the event on being sure not to pass it back to ourselves!
+				iWs.SendEventToWindowGroup(foc, e);
+				}
+			}
+		}
+#endif
+	}
+
+TInt CKeyCapturer::RunError(TInt /*aError*/)
+	{
+	return KErrNone; // Don't care if our client left from its call to CapturedKeyPressedL
+	}
+
+void CKeyCapturer::DoCancel()
+	{
+#ifdef FSHELL_WSERV_SUPPORT
+	iWs.EventReadyCancel();
+#endif
+	}
+
+#ifdef __EXE__
+	CKeyCapturer* gCapturer = NULL;
+#endif
+
+EXPORT_C CKeyCapturer* CKeyCapturer::GetCapturerL()
+	{
+	CKeyCapturer* ref = NULL;
+
+#ifdef __EXE__
+	if (!gCapturer)
+		{
+		gCapturer = CKeyCapturer::NewLC();
+		CleanupStack::Pop();
+		}
+	ref = gCapturer;
+#else
+	ref = (CKeyCapturer*)Dll::Tls();
+	if (!ref)
+		{
+		ref = CKeyCapturer::NewLC();
+		User::LeaveIfError(Dll::SetTls(ref));
+		CleanupStack::Pop(ref);
+		}
+#endif
+	return ref;
+	}
+
+EXPORT_C void CKeyCapturer::DeleteCapturer()
+	{
+#ifdef __EXE__
+	delete gCapturer;
+	gCapturer = NULL;
+#else
+	CKeyCapturer* ref = (CKeyCapturer*)Dll::Tls();
+	delete ref;
+	Dll::SetTls(NULL);
+	//Dll::FreeTls();
+#endif
+	}
+
+CKeyCapturer* CKeyCapturer::NewLC()
+	{
+	CKeyCapturer* res = new(ELeave) CKeyCapturer;
+	CleanupStack::PushL(res);
+	res->ConstructL();
+	return res;
+	}
+
+EXPORT_C void CKeyCapturer::PushCurrentCapturesL()
+	{
+	CArrayFixFlat<SCapture>* newList = new(ELeave) CArrayFixFlat<SCapture>(8);
+	iPushList->AppendL(iCaptures);
+	// Now cancel everything in currentList to leave a clean slate
+	for (TInt i = 0; i < iCaptures->Count(); i++)
+		{
+		SCapture& cap = iCaptures->operator[](i);
+		CancelCapture(cap);
+		}
+	iCaptures = newList;
+	}
+
+EXPORT_C void CKeyCapturer::PopCapturesL()
+	{
+	//__ASSERT_ALWAYS(iPushList->Count() >= 1, User::Invariant());
+	KEYCAPTURE_DEBUG("KC: Popping captures");
+
+	// Cancel everything in the current list
+	for (TInt i = 0; i < iCaptures->Count(); i++)
+		{
+		SCapture& cap = iCaptures->operator[](i);
+		CancelCapture(cap);
+		}
+	iCaptures->Reset(); // Transfer everything to iCaptures one by one, to allow for the (admittedly unlikely) possibility that any individual capture could fail
+
+	CArrayFixFlat<SCapture>* newList = (*iPushList)[iPushList->Count()-1];
+	for (TInt i = newList->Count() - 1; i >= 0 ; i--)
+		{
+		SCapture& cap = newList->operator[](i);
+		AddCaptureL(cap);
+		newList->Delete(i); // When it's been sucessfully captured into iCaptures, remove if from newList
+		}
+	iPushList->Delete(iPushList->Count() - 1);
+	delete newList;
+	KEYCAPTURE_DEBUG("KC: Finished restoring previous captures");
+	}
+
+EXPORT_C TInt CKeyCapturer::IsCaptured(TInt aIdentifier)
+	{
+	TBool dontCare;
+	return IsCaptured(aIdentifier, dontCare);
+	}
+
+EXPORT_C TInt CKeyCapturer::IsCaptured(TInt aIdentifier, TBool& aIsLong)
+	{
+	for (TInt i = 0; i < iCaptures->Count(); i++)
+		{
+		SCapture& cap = iCaptures->operator[](i);
+		if (cap.iIdentifier == aIdentifier && !(cap.iFlags & ECaptureIsDummy))
+			{
+			aIsLong = cap.iFlags & ELongCapture;
+			return cap.iOriginalCode;
+			}
+		}
+	return 0;
+	}
+
+EXPORT_C TInt CKeyCapturer::GetScanCodeOfLastEvent()
+	{
+	return iLastEventScanCode;
+	}
+
+void CKeyCapturer::RemoveDummyForCapture(const SCapture& aCapture)
+	{
+	for (TInt i = 0; i < iCaptures->Count(); i++)
+		{
+		SCapture cap = iCaptures->operator[](i);
+		TUint32 matchFlags = ECaptureIsDummy;
+		if (aCapture.iFlags & ELongCapture)
+			{
+			// Nothing to do - the match flags for a long press are ECaptureIsDummy and that's it
+			}
+		else
+			{
+			// A dummy for a short press is an upAndDown one
+			matchFlags |= ECaptureIsKeyUpDown;
+			}
+		if ((cap.iFlags & matchFlags) && (cap.iOriginalCode == aCapture.iOriginalCode))
+			{
+			CancelCapture(cap);
+			iCaptures->Delete(i);
+			RemoveDummyForCapture(cap); // Just in case the long press had a dummy (being the short press) which would then ALSO have a dummy (the upanddown)
+			break;
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/msgqlistboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+// msgqlistboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+#include <fshell/qr3dll.h>
+#include "QResources3.hrh"
+
+CMsgQueListBoxData::CMsgQueListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CMsgQueListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
+	{
+	TMsgQueueKernelInfo& info = *(TMsgQueueKernelInfo*)aInfo;
+	name.Copy(info.iFullName);
+	PrettyName(iType, name);
+
+	more.Format(_L("Message max size=%u"), info.iMaxMsgLength);
+	}
+
+void CMsgQueListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	TMsgQueueKernelInfo& info = *(TMsgQueueKernelInfo*)iInfo;
+	_LIT8(KDesc,"MsgQ;KernObjAddr;FullName;AccessCount;MsgLength");
+	_LIT8(KFmt,"MsgQ;%x;%S;%d;%d");
+	
+	if (i == 0) clogger.Log(KDesc);
+	clogger.Log(KFmt, info.iAddressOfKernelObject, &info.iFullName, info.iAccessCount, info.iMaxMsgLength);
+	}
+
+void CMsgQueListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* /*aTemp*/)
+	{
+	TMsgQueueKernelInfo& info = *(TMsgQueueKernelInfo*)iInfo;
+	_LIT(KInfo, "Message queue info");
+	aTitle.Copy(KInfo);
+
+	inf.Copy(iInfo->iFullName);
+	inf.Append(Klflf);
+	
+	inf.AppendFormat(_L("Kernel object address: 0x%08x\n"), info.iAddressOfKernelObject);
+	inf.AppendFormat(_L("Message max size: %u\n"), info.iMaxMsgLength);
+	inf.AppendFormat(_L("Access count: %u"), info.iAccessCount);
+	//inf.AppendFormat(_L("Kernel owner address:  0x%08x\n"), info.iAddressOfKernelOwner);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/mutexlistboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,94 @@
+// mutexlistboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+#include <fshell/qr3dll.h>
+#include "QResources3.hrh"
+
+CMutexListBoxData::CMutexListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CMutexListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
+	{
+	TMutexKernelInfo& info = *(TMutexKernelInfo*)aInfo;
+	name.Copy(info.iFullName);
+	PrettyName(iType, name);
+
+	more.Format(_L("Order=%d Held=%d Waiting=%d"), info.iOrder, info.iHoldCount, info.iWaitCount);
+	}
+
+void CMutexListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	TMutexKernelInfo& info = *(TMutexKernelInfo*)iInfo;
+	_LIT8(KDesc,"Mutex;KernObjAddr;FullName;AccessCount;HoldCount;WaitCount;Order");
+	_LIT8(KFmt, "Mutex;%x;%S;%d;%x;%u");
+	
+	if (i == 0) clogger.Log(KDesc);
+	clogger.Log(KFmt, info.iAddressOfKernelObject, &info.iFullName, info.iAccessCount, info.iHoldCount, info.iWaitCount, info.iOrder);
+	}
+
+#define CASE_LIT2(val, name) case val: { _LIT(KName, #name); return KName; }
+
+const TDesC& Name(TUint8 aOrder)
+	{
+	switch (aOrder)
+		{
+		CASE_LIT2(0xff, KMutexOrdNone);
+		CASE_LIT2(0xfe, KMutexOrdUser);
+		CASE_LIT2(0xf7, KMutexOrdGeneral7);
+		CASE_LIT2(0xf6, KMutexOrdGeneral6);
+		CASE_LIT2(0xf5, KMutexOrdGeneral5);
+		CASE_LIT2(0xf4, KMutexOrdGeneral4);
+		CASE_LIT2(0xf3, KMutexOrdGeneral3);
+		CASE_LIT2(0xf2, KMutexOrdGeneral2);
+		CASE_LIT2(0xf1, KMutexOrdGeneral1);
+		CASE_LIT2(0xf0, KMutexOrdGeneral0);
+		CASE_LIT2(0x60, KMutexOrdCodeSegLock);
+		CASE_LIT2(0x5e, KMutexOrdPubSub2);
+		CASE_LIT2(0x5c, KMutexOrdDemandPaging);
+		CASE_LIT2(0x58, KMutexOrdPowerMgr);
+		CASE_LIT2(0x50, KMutexOrdPubSub);
+		CASE_LIT2(0x48, KMutexOrdProcessLock);
+		CASE_LIT2(0x47, KMutexOrdDebug);
+		CASE_LIT2(0x40, KMutexOrdTimer);
+		CASE_LIT2(0x38, KMutexOrdObjectCon2);
+		CASE_LIT2(0x30, KMutexOrdHandle);
+		CASE_LIT2(0x28, KMutexOrdObjectCon);
+		CASE_LIT2(0x20, KMutexOrdMachineConfig);
+		CASE_LIT2(0x10, KMutexOrdHwChunk);
+		CASE_LIT2(0x08, KMutexOrdKernelHeap);
+		CASE_LIT2(0x01, KMutexOrdRamAlloc);
+		default:
+			_LIT(KHuh, "?");
+			return KHuh;
+		}
+	}
+
+void CMutexListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* /*aTemp*/)
+	{
+	TMutexKernelInfo& info = *(TMutexKernelInfo*)iInfo;
+	_LIT(KInfo, "Mutex info");
+	aTitle.Copy(KInfo);
+
+	inf.Copy(iInfo->iFullName);
+	inf.Append(Klflf);
+	
+	inf.AppendFormat(_L("Kernel object address: 0x%08x\n"), info.iAddressOfKernelObject);
+	TPtrC ord = Name(info.iOrder);
+	inf.AppendFormat(_L("Order: 0x%02x (%S)\n"), info.iOrder, &ord);
+	inf.AppendFormat(_L("Access count: %u\n"), info.iAccessCount);
+	inf.AppendFormat(_L("Hold count: %d\nWaiting count: %d"), info.iHoldCount, info.iWaitCount);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/objectlist.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,201 @@
+// objectlist.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/qr3dll.h>
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <e32uid.h>
+#include <fshell/common.mmh>
+#include <apgcli.h>
+
+EXPORT_C CKernelObjectList* CKernelObjectList::NewL(RMemoryAccess* aMemAccess)
+	{
+	CKernelObjectList* self = new(ELeave) CKernelObjectList(aMemAccess);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C void CKernelObjectList::SetCurrentType(TKernelObjectType aType)
+	{
+	iCurrent = aType;
+	TRAP_IGNORE(iModel->SetCurrentListL(iCurrent));
+	}
+
+EXPORT_C void CKernelObjectList::RefreshDataL(TInt aIndex)
+	{
+	iModel->RefreshDataL(aIndex);
+	}
+
+EXPORT_C MQikListBoxModel* CKernelObjectList::GetQikListBoxModel()
+	{
+	return NULL;
+	}
+
+EXPORT_C TInt CKernelObjectList::Count() const
+	{
+	return iModel->Count();
+	}
+
+EXPORT_C void CKernelObjectList::GetInfoL(TInt aIndex, RBuf& aTitle, RBuf& aInfo)
+	{
+	GetInfoByIndexL(aIndex, EFalse, aTitle, aInfo);
+	}
+
+EXPORT_C void CKernelObjectList::GetVerboseInfoL(TInt aIndex, RBuf& aTitle, RBuf& aInfo)
+	{
+	GetInfoByIndexL(aIndex, ETrue, aTitle, aInfo);
+	}
+
+EXPORT_C void CKernelObjectList::GetInfoByIdL(TInt aId, TBool aVerbose, RBuf& aTitle, RBuf& aInfo)
+	{
+	TInt idx = iModel->ItemIdIndex(aId);
+	User::LeaveIfError(idx);
+
+	GetInfoByIndexL(idx, aVerbose, aTitle, aInfo);
+	}
+
+EXPORT_C TInt CKernelObjectList::GetInfoByIndexL(TInt aIndex, TBool aVerbose, RBuf& aTitle, RBuf& aInfo)
+	{
+	CKernListBoxData* data = static_cast<CKernListBoxData*>(iModel->RetrieveDataL(aIndex));
+	CleanupClosePushL(*data);
+	if (aVerbose)
+		{
+		data->InfoForDialogL(aTitle, aInfo, EFalse);
+		}
+	else
+		{
+		data->FormatL(data->iInfo, aTitle, aInfo);
+		}
+	TInt res = data->ItemId();
+	CleanupStack::PopAndDestroy(data);
+	return res;
+	}
+
+EXPORT_C void CKernelObjectList::DumpAllInfoL(RClogger& aClogger)
+	{
+	TInt n = Count();
+	for (TInt i = 0; i < Count(); i++)
+		{
+		CKernListBoxData* data = static_cast<CKernListBoxData*>(iModel->RetrieveDataL(i));
+		CleanupClosePushL(*data);
+		data->DumpToCloggerL(aClogger, i, n);
+		CleanupStack::PopAndDestroy(data);
+		}
+	}
+
+CKernelObjectList::CKernelObjectList(RMemoryAccess* aMemAccess)
+	: iMemAccess(aMemAccess)
+	{
+	}
+
+void CKernelObjectList::ConstructL()
+	{
+	CDefaultProductPlugin::LoadProductPluginL(); // A bit nasty but reduces the amount of refactoring needed!
+	iModel = new(ELeave) CKernListBoxModel(*iMemAccess);
+	CleanupStack::PushL(iModel);
+	iModel->ConstructL();
+	CleanupStack::Pop(iModel);
+	}
+
+EXPORT_C void CKernelObjectList::SetInfoChangedCallback(TInt aIndex, const TCallBack& aCallback)
+	{
+	iModel->SetInfoChangedCallback(aIndex, aCallback);
+	}
+
+CKernelObjectList::~CKernelObjectList()
+	{
+	delete iModel;
+	delete gPlugin;
+	}
+
+
+void GetNameFromApparcL(TUint aSid, RBuf& aName);
+void GetNameFromFsL(TUint aSid, RBuf& aName);
+
+EXPORT_C TInt ExeNameForSid(TUint aSid, RBuf& aName)
+	{
+	TInt err = KErrNone;
+	if (aName.MaxLength() < 256) 
+		{
+		err = aName.Create(256);
+		}
+	if (err) return err;
+
+	if (aSid == 0x10205c44)
+		{
+		// Special case this because sysstart isn't running & isn't an app, and appears
+		// enough as parent to be worth special-casing
+		aName.Copy(_L("SysStart"));
+		return KErrNone;
+		}
+
+	TBuf<12> pattern;
+	pattern.Num(aSid, EHex);
+	pattern.Insert(0, _L("*["));
+	pattern.Append(_L("]*"));
+	TFindProcess findproc(pattern);
+	TInt found = findproc.Next(*reinterpret_cast<TFullName*>(&aName));
+	if (found == KErrNone)
+		{
+		aName.SetLength(aName.Length()-14); // Remove the [12345678]0001
+		return found;
+		}
+
+	TRAP(err, GetNameFromApparcL(aSid, aName));
+	if (err == KErrNone) return KErrNone;
+
+	// Failing all that go to the file system directly
+	TRAP(err, GetNameFromFsL(aSid, aName));
+	return err;
+	}
+
+void GetNameFromApparcL(TUint aSid, RBuf& aName)
+	{
+#ifdef FSHELL_APPARC_SUPPORT
+	// Didn't find the process in the process list. So not running. Try
+	// apparc as a fallback - will only work for fully-fledged applications
+	TApaAppInfo* appinfo = new (ELeave) TApaAppInfo;
+	CleanupStack::PushL(appinfo);
+	RApaLsSession ls;
+	CleanupClosePushL(ls);
+	User::LeaveIfError(ls.Connect());
+	User::LeaveIfError(ls.GetAppInfo(*appinfo, TUid::Uid(aSid)));
+	TInt slash = appinfo->iFullName.LocateReverse('\\');
+	aName.Copy(appinfo->iFullName.Mid(slash+1));
+	CleanupStack::PopAndDestroy(2, appinfo); // ls, appinfo
+#else
+	User::Leave(KErrNotSupported);
+#endif
+	}
+
+void GetNameFromFsL(TUint aSid, RBuf& aName)
+	{
+	// Finally, fall back to the file system. This can be slow which is why we try the other options first
+	RFs fs;
+	CleanupClosePushL(fs);
+	User::LeaveIfError(fs.Connect());
+	TUidType uids(KExecutableImageUid, KNullUid, TUid::Uid(aSid));
+	CDir* dir = NULL;
+	User::LeaveIfError(fs.GetDir(_L("Z:\\sys\\bin\\"), uids, ESortNone, dir));
+	if (dir && dir->Count())
+		{
+		aName.Copy((*dir)[0].iName);
+		delete dir;
+		}
+	else
+		{
+		delete dir;
+		User::Leave(KErrNotFound);
+		}
+	CleanupStack::PopAndDestroy(&fs);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/openfilesListboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,108 @@
+// openfilesListboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+
+COpenFilesListBoxData::COpenFilesListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void COpenFilesListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
+	{
+	SOpenFile& info = *reinterpret_cast<SOpenFile*>(aInfo);
+
+	if (info.iNumThreads)
+		{
+		if (info.iNumThreads > 1)
+			{
+			more.Format(_L("(%i) "), info.iNumThreads);
+			}
+		
+		RThread t;
+		TInt err = Model().MemAccess().RThreadForceOpen(t, info.iThreadIds[0]);
+		if (err)
+			{
+			more.AppendFormat(_L("Thread Id: %i err: %i"), TUint(info.iThreadIds[0]), err);
+			}
+		else
+			{
+			name.Copy(t.FullName()); // Reuse 'name' here, saves allocating another buffer
+			t.Close();
+			PrettyName(EListThread, name);
+			more.Append(name);
+			}
+		}
+	name.Copy(info.iName);
+	}
+
+void COpenFilesListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	_LIT(KFileDesc,"OpenFile;Name;ThreadId;ThreadName");
+	_LIT(KFileFmt, "OpenFile;%S;%i;%S");
+
+	if (i == 0) clogger.Log(KFileDesc);
+	SOpenFile& info = *reinterpret_cast<SOpenFile*>(iInfo);
+	RBuf val;
+	val.CreateL(256);
+	for (TInt j = 0; j < Min(info.iNumThreads, info.iThreadIds.Count()); j++)
+		{
+		val.Zero();
+		RThread t;
+		TInt err = t.Open(info.iThreadIds[j]);
+		if (err)
+			{
+			val.Format(_L("Err: %i"), err);
+			}
+		else
+			{
+			val.Copy(t.FullName());
+			}
+		t.Close();
+		clogger.Log(KFileFmt, &info.iName, TUint(info.iThreadIds[j]), &val);
+		}
+	val.Close();
+	}
+
+void COpenFilesListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* name)
+	{
+	inf.ReAllocL(1024); // Maybe need a bit more room for file list
+	SOpenFile& info = *reinterpret_cast<SOpenFile*>(iInfo);
+	_LIT(KInfo, "%i thread(s) using this file");
+	aTitle.Format(KInfo, info.iNumThreads);
+
+	inf.Append(info.iName);
+	inf.Append('\n');
+	inf.Append('\n');
+	for (TInt i = 0; i < Min(info.iNumThreads, info.iThreadIds.Count()); i++)
+		{
+		RThread t;
+		TInt err = t.Open(info.iThreadIds[i]);
+		if (err)
+			{
+			name->Format(_L("Couldn't open thread: %i"), err);
+			}
+		else
+			{
+			name->Copy(t.FullName());
+			}
+		t.Close();
+		inf.AppendFormat(_L("Thread ID: %i\n%S\n\n"), TUint(info.iThreadIds[i]), name);
+		}
+	TInt numTruncated = info.iNumThreads - info.iThreadIds.Count();
+	if (numTruncated > 0)
+		{
+		inf.AppendFormat(_L("And %i other thread(s)...\n\n"), numTruncated);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/propertywatcher.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,196 @@
+// propertywatcher.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <fshell/qr3dll.h>
+
+EXPORT_C CPropertyManager* CPropertyManager::NewL(TCallBack aCallback)
+	{
+	CPropertyManager* self = new(ELeave) CPropertyManager(aCallback);
+	return self;
+	}
+
+EXPORT_C void CPropertyManager::SetPropertyFromStringL(const TDesC& /*aString*/)
+	{
+	}
+
+EXPORT_C HBufC* CPropertyManager::GetValueL()
+	{
+	if (!iProperty.Handle()) User::Leave(KErrNotReady);
+
+	TInt err = KErrNone;
+	if (iPropertyType == RProperty::ETypeLimit)
+		{
+		// First time called, need to figure out what type the property is
+		TInt propInt;
+		//TBuf8<1> propBuf8;
+		
+		err = iProperty.Get(propInt);
+		if (err == KErrNotFound)
+			{
+			return NULL;
+			}
+		if (err == KErrPermissionDenied)
+			{
+			User::Leave(err);
+			}
+
+		if (err != KErrArgument)
+			{
+			iPropertyType = RProperty::EInt;
+			}
+		else
+			{
+			//err = iProperty.Get(propBuf8);
+			//if (err == 
+			// Just assume it's binary, for now
+			iPropertyType = RProperty::EByteArray;
+			}
+		}
+
+	switch (iPropertyType)
+		{
+		case RProperty::EInt:
+			{
+			TInt val;
+			TInt err = iProperty.Get(val);
+			if (err == KErrNone)
+				{
+				HBufC* res = HBufC::NewL(15);
+				res->Des().Format(_L("%i"), val);
+				return res;
+				}
+			else if (err == KErrArgument)
+				{
+				// Someone's redefined the property as a different type
+				iPropertyType = RProperty::ETypeLimit;
+				return GetValueL();
+				}
+			else if (err == KErrNotFound)
+				{
+				// property deleted or undefined
+				return NULL;
+				}
+			else
+				{
+				User::Leave(err);
+				}
+			break;
+			}
+		case RProperty::EByteArray:
+			{
+			for (TInt size = 512; /*Nothing*/; size *= 2)
+				{
+				HBufC8* val = HBufC8::NewL(size);
+				TPtr8 ptr = val->Des();
+				TInt err = iProperty.Get(ptr);
+				if (err == KErrNone)
+					{
+
+					_LIT(KBinary, "Binary:");
+					CleanupStack::PushL(val);
+					HBufC* res = HBufC::NewL(val->Length() * 4 + KBinary().Length());
+					TPtr ptr = res->Des();
+					//ptr.Append(KBinary);
+					for (TInt i = 0; i < val->Length(); i++)
+						{
+						if (i % 8 == 0) ptr.Append('\n');
+						if (i % 4 == 0 && i != 0) ptr.Append(' ');
+						TBuf<2> numBuf;
+						numBuf.NumFixedWidthUC((*val)[i], EHex, 2);
+						ptr.Append(numBuf);
+						//ptr.AppendFormat(_L("%02x"), (TUint)(*val)[i]);
+						}
+					CleanupStack::PopAndDestroy(val);
+					return res;
+					}
+				else
+					{
+					delete val;
+					}
+
+				if (err == KErrOverflow)
+					{
+					// Try with bigger buffer
+					continue;
+					}
+				else if (err == KErrArgument)
+					{
+					// Someone's redefined the property as a different type
+					iPropertyType = RProperty::ETypeLimit;
+					return GetValueL();
+					}
+				else if (err == KErrNotFound)
+					{
+					// property deleted or undefined
+					return NULL;
+					}
+				else
+					{
+					User::Leave(err);
+					}
+				}
+			}
+		default:
+			break;
+		}
+	return NULL; // To satisfy compiler
+	}
+
+EXPORT_C TInt CPropertyManager::ChangeProperty(TUint aCategory, TUint aKey)
+	{
+	Cancel();
+	iPropertyType = RProperty::ETypeLimit;
+	iCat = aCategory;
+	iKey = aKey;
+
+	iProperty.Close();
+	TInt err = iProperty.Attach(TUid::Uid(aCategory), aKey);
+	if (!err)
+		{
+		Watch();
+		}
+	return err;
+	}
+
+void CPropertyManager::Watch()
+	{
+	if (!IsActive())
+		{
+		iProperty.Subscribe(iStatus);
+		SetActive();
+		}
+	}
+
+void CPropertyManager::RunL()
+	{
+	if (!iStatus.Int())
+		{
+		Watch();
+		}
+	iChangedFn.CallBack();
+	}
+
+void CPropertyManager::DoCancel()
+	{
+	iProperty.Cancel();
+	}
+
+CPropertyManager::CPropertyManager(TCallBack aCallback)
+	: CActive(CActive::EPriorityStandard), iPropertyType(RProperty::ETypeLimit), iChangedFn(aCallback)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CPropertyManager::~CPropertyManager()
+	{
+	Cancel();
+	iProperty.Close();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/sandbox.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,226 @@
+// sandbox.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <e32base.h>
+#include "sandbox.h"
+#include <APMREC.H>
+#include <fshell/memoryaccess.h>
+
+enum TMsg
+	{
+	EGetRecog,
+	EGetRecog2,
+	ECloseServer,
+	EGetVTablePtr,
+	EMaxArgs,
+	};
+
+#ifndef SERVER
+
+
+class RSandboxSession : public RSessionBase
+	{
+public:
+	TInt Connect(const TDesC& aServerName)
+		{
+		return CreateSession(aServerName, TVersion(0,0,0));
+		}
+
+	TInt GetRecogniserInfo(TUid aImplementationUid, RArray<TDataType>& aMimeTypes)
+		{
+		TInt size = SendReceive(EGetRecog, TIpcArgs(aImplementationUid.iUid));
+		if (size < 0) return size;
+		TInt err = aMimeTypes.Reserve(size/sizeof(TDataType));
+		if (err) return err;
+		RBuf8 buf;
+		err = buf.Create(size);
+		if (err) return err;
+		err = SendReceive(EGetRecog2, TIpcArgs(&buf));
+		if (err) { buf.Close(); return err; }
+
+		const TDataType* ptr = (const TDataType*)buf.Ptr();
+		for (TInt i = 0; i < size/sizeof(TDataType); i++)
+			{
+			err = aMimeTypes.Append(ptr[i]);
+			if (err) break;
+			}
+		buf.Close();
+		return err;
+		}
+
+	TInt GetVTablePtrFromEcomUid(TUid aUid, TAny*& vtablePtr)
+		{
+		TPckgBuf<TAny*> pkg(NULL);
+		TInt err = SendReceive(EGetVTablePtr, TIpcArgs(aUid.iUid, &pkg));
+		if (err) return err;
+		vtablePtr = pkg();
+		return KErrNone;
+		}
+
+	void Byebye()
+		{
+		SendReceive(ECloseServer);
+		}
+	};
+
+#define GETSESSIONL(process, session)										\
+	RProcess process;														\
+	User::LeaveIfError(process.Create(_L("QR3Sandbox.exe"), KNullDesC));	\
+	TRequestStatus stat;													\
+	process.Rendezvous(stat);												\
+	process.Resume();														\
+	User::WaitForRequest(stat);												\
+																			\
+	RSandboxSession session;												\
+	User::LeaveIfError(session.Connect(sandbox.FullName()));
+
+
+void Sandbox::GetRecogniserInfoL(TUid aImplementationUid, RArray<TDataType>& aMimeTypes)
+	{
+	GETSESSIONL(sandbox, sess);
+
+	User::LeaveIfError(sess.GetRecogniserInfo(aImplementationUid, aMimeTypes));
+
+	sess.Byebye();
+	sandbox.Close();
+	}
+
+void Sandbox::GetDllNameFromEcomUidL(RMemoryAccess& aMemAccess, TUid aUid, TFileName& aFileName)
+	{
+	// Try and instanciate object and figure out what DLL it belongs to by looking up its vtable pointer
+	// We do the instanciation in a separate process so as to avoid worrying about cleanup or side-effects of instanciation
+
+	GETSESSIONL(sandbox, sess);
+
+	TAny* vtablePtr = NULL;
+	TInt err = sess.GetVTablePtrFromEcomUid(aUid, vtablePtr);
+
+	TFullName8 dllName;
+	if (!err)
+		{
+		err = aMemAccess.FindAddressInCodeSegments(dllName, vtablePtr);
+		}
+	sess.Byebye(); // We have to call FindAddressInCodeSegments before sandbox exits, because when it does the code segment will most likely be unloaded!
+	sandbox.Close();
+	User::LeaveIfError(err);
+	
+	aFileName.Copy(dllName);
+	}
+
+
+#else
+
+#include <e32property.h>
+#include <ecom/ecom.h>
+
+void GoL();
+
+class CSandboxSession : public CSession2
+	{
+	void ServiceL(const RMessage2 &aMessage);
+	RBuf8 iBuf;
+	};
+
+class CSandboxServer : public CServer2
+	{
+public:
+	CSandboxServer() : CServer2(0,ESharableSessions) {}
+
+protected:
+	CSession2* NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const
+		{
+		return new(ELeave) CSandboxSession();
+		}
+	};
+
+
+TInt E32Main()
+	{
+	User::SetJustInTime(EFalse); // Don't want to debug problems in the sandbox
+
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+	TRAPD(err, GoL());
+	return err;
+	}
+
+void GoL()
+	{
+	CActiveScheduler* s=new(ELeave) CActiveScheduler;
+	CActiveScheduler::Install(s);
+	CSandboxServer* server = new(ELeave) CSandboxServer();
+	// Scope the TFullName
+		{
+		TFullName serverName = RProcess().FullName();
+		server->StartL(serverName);
+		}
+	RProcess::Rendezvous(KErrNone);
+	CActiveScheduler::Start();
+	}
+
+void CSandboxSession::ServiceL(const RMessage2 &aMessage)
+	{
+	if (aMessage.Function() >= EMaxArgs)
+		{
+		aMessage.Complete(KErrArgument);
+		return;
+		}
+
+	if (aMessage.Function() == EGetRecog2)
+		{
+		aMessage.WriteL(0, iBuf);
+		iBuf.Close();
+		aMessage.Complete(KErrNone);
+		}
+	else if (aMessage.Function() == EGetRecog)
+		{
+		if (iBuf.MaxLength() == 0)
+			{
+			iBuf.ReAllocL(1024); // Must be > sizeof(TDataType) otherwise the reallocating logic below is flawed
+			}
+		TUid uid = TUid::Uid(aMessage.Int0());
+		TUid destructorKey;
+		CApaDataRecognizerType* rec = static_cast<CApaDataRecognizerType*>(REComSession::CreateImplementationL(uid, destructorKey));
+		TInt count = rec->MimeTypesCount();
+		for (TInt j = 0; j < count; j++)
+			{
+			TDataType type = rec->SupportedDataTypeL(j);
+			TPckg<TDataType> buf(type);
+			if (iBuf.Length() + buf.Length() >= iBuf.MaxLength())
+				{
+				iBuf.ReAllocL(iBuf.MaxLength() * 2);
+				}
+			iBuf.Append(buf);
+			}
+
+		aMessage.Complete(iBuf.Size());
+		}
+	else if (aMessage.Function() == ECloseServer)
+		{
+		aMessage.Complete(KErrNone);
+		CActiveScheduler::Stop();
+		}
+	else if (aMessage.Function() == EGetVTablePtr)
+		{
+		TUid destructorKey;
+		TAny* obj = NULL;
+		obj = REComSession::CreateImplementationL(TUid::Uid(aMessage.Int0()), destructorKey);
+		TAny* vtablePtr = *((TAny**)obj);	
+		TPckg<TAny*> res(vtablePtr);
+		aMessage.WriteL(1, res);
+		aMessage.Complete(KErrNone);
+		}
+	else
+		{
+		ASSERT(0);
+		}
+	}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/semaphorelistboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,55 @@
+// semaphorelistboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+#include <fshell/qr3dll.h>
+#include "QResources3.hrh"
+
+CSemaphoreListBoxData::CSemaphoreListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CSemaphoreListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
+	{
+	TSemaphoreKernelInfo& info = *(TSemaphoreKernelInfo*)aInfo;
+	name.Copy(info.iFullName);
+	PrettyName(iType, name);
+
+	more.Format(_L("Count=%d"), info.iCount);
+	}
+
+void CSemaphoreListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	TSemaphoreKernelInfo& info = *(TSemaphoreKernelInfo*)iInfo;
+	_LIT8(KDesc,"Semaphore;KernObjAddr;FullName;AccessCount;Count");
+	_LIT8(KFmt, "Semaphore;%x;%S;%d;%d");
+	
+	if (i == 0) clogger.Log(KDesc);
+	clogger.Log(KFmt, info.iAddressOfKernelObject, &info.iFullName, info.iAccessCount, info.iCount);
+	}
+
+void CSemaphoreListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* /*aTemp*/)
+	{
+	TSemaphoreKernelInfo& info = *(TSemaphoreKernelInfo*)iInfo;
+	_LIT(KInfo, "Semaphore info");
+	aTitle.Copy(KInfo);
+
+	inf.Copy(iInfo->iFullName);
+	inf.Append(Klflf);
+	
+	inf.AppendFormat(_L("Kernel object address: 0x%08x\n"), info.iAddressOfKernelObject);
+	inf.AppendFormat(_L("Access count: %u\n"), info.iAccessCount);
+	inf.AppendFormat(_L("Count: %d"), info.iCount);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/serverlistboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,67 @@
+// serverlistboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+#include <fshell/qr3dll.h>
+#include "QResources3.hrh"
+
+CServerListBoxData::CServerListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CServerListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
+	{
+	TServerKernelInfo& info = *(TServerKernelInfo*)aInfo;
+	name.Copy(info.iFullName);
+	PrettyName(iType, name);
+
+	more.Format(_L("%d sessions"), info.iSessionQ.iCount);
+	}
+
+void CServerListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	TServerKernelInfo& info = *(TServerKernelInfo*)iInfo;
+	_LIT8(KServerDesc,"Server;FullName;SessionCount;OwnerThreadId");
+	_LIT8(KServerFmt,"Server;%S;%i;%u");
+	
+	if (i == 0) clogger.Log(KServerDesc);
+	clogger.Log(KServerFmt, &info.iFullName, info.iSessionQ.iCount, info.iOwningThreadId);
+	}
+
+void CServerListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* aTemp)
+	{
+	TServerKernelInfo& info = *(TServerKernelInfo*)iInfo;
+	_LIT(KInfo, "Server info");
+	aTitle.Copy(KInfo);
+
+	inf.Copy(iInfo->iFullName);
+	inf.Append(Klflf);
+	
+	inf.AppendFormat(_L("Server thread: %u"), info.iOwningThreadId);
+	RThread owner;
+	TInt err = Model().MemAccess().RThreadForceOpen(owner, info.iOwningThreadId);
+	if (!err)
+		{
+		*aTemp = owner.FullName();
+		inf.AppendFormat(_L(" (%S)"), aTemp);
+		owner.Close();
+		}
+	inf.AppendFormat(_L("\n%d sessions"), info.iSessionQ.iCount);
+	}
+
+TBool CServerListBoxData::SupportsCommand(TInt /*aCommand*/)
+	{
+	return EFalse;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/threadListboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,204 @@
+// threadListboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+#include <fshell/qr3dll.h>
+#include "QResources3.hrh"
+#include <fshell/heaputils.h>
+
+CThreadsListBoxData::CThreadsListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CThreadsListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId)
+	{
+	TThreadKernelInfo& info = *(TThreadKernelInfo*)aInfo;
+	name.Copy(info.iFullName);
+	PrettyName(iType, name);
+
+	TUint tid = info.iThreadId;
+	TExitType exitType = EExitPending;
+	RThread thread;
+	if (Model().MemAccess().RThreadForceOpen(thread, tid) == KErrNone)
+		{
+		exitType = thread.ExitType();
+		}
+	if (exitType == EExitPending)
+		{
+		more.Format(_L("Tid %i"), tid);
+		}
+	else
+		{
+		TExitCategoryName cat = thread.ExitCategory();
+		more.Format(_L("Tid %i %S %i"), tid, &cat, thread.ExitReason());
+		}
+	thread.Close();
+	itemId = tid;
+	}
+
+void CThreadsListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	_LIT8(KThreadDesc,"Thread;FullName;Tid;Priority;(PriorityHumanReadable);ParentPid;StackSize;(StackSizeHumanReadable);HeapSize;(HeapSizeHumanReadable);MinHeapSize;(MinHumanReadable);UnusedPages;LostBytes;(LostBytesHumanReadable);ExitStatus;ExitCategory;ExitReason;KernObjAddr");
+	_LIT8(KThreadFmt,"Thread;%S;%i;%i;(%S);%i;%i;(%S);%i;(%S);%i;(%S);%i;%i;(%S);%S;%S;%i;%x");
+	//                                                    ^ HeapSizeHumanReadable
+	if (i == 0) clogger.Log(KThreadDesc);
+	TThreadKernelInfo& info = *(TThreadKernelInfo*)iInfo;
+
+	TBuf<16> priority16 = ToString((TThreadPriority)info.iThreadPriority);
+	TPtr8 priority = priority16.Collapse();
+	
+	LtkUtils::RProxyAllocatorHelper allocHelper;
+	User::LeaveIfError(allocHelper.Open(Model().MemAccess(), info.iThreadId));
+	TBuf8<16> heapSize, minHeap, lostBytes, stackSize;
+	HR(heapSize, allocHelper.CommittedSize());
+	HR(stackSize, info.iUserStackSize);
+	HR(minHeap, allocHelper.MinCommittedSize());
+	TInt lostBytesCount = allocHelper.CommittedFreeSpace();
+	HR(lostBytes, lostBytesCount);
+	TInt parentPid = 0; //TODO
+	TPtrC exitStatus;
+	TInt exitReason = 0;
+	TExitCategoryName exitCategory;
+	RThread handle;
+	if (Model().MemAccess().RThreadForceOpen(handle, info.iThreadId) == KErrNone)
+		{
+		exitStatus.Set(ToString(handle.ExitType()));
+		exitCategory = handle.ExitCategory();
+		exitReason = handle.ExitReason();
+		handle.Close();
+		}
+	TBuf8<16> exitStatus8;
+	exitStatus8.Copy(exitStatus);
+	TPtrC8 exitCategory8 = exitCategory.Collapse();
+	clogger.Log(KThreadFmt, &info.iFullName, info.iThreadId, info.iThreadPriority, &priority, parentPid, info.iUserStackSize, &stackSize, allocHelper.CommittedSize(), &heapSize, allocHelper.MinCommittedSize(), &minHeap, allocHelper.CountUnusedPages(), lostBytesCount, &lostBytes, &exitStatus8, &exitCategory8, exitReason, info.iAddressOfKernelObject);
+	allocHelper.Close();
+	}
+
+void CThreadsListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* aTemp)
+	{
+	TThreadKernelInfo& info = *(TThreadKernelInfo*)iInfo;
+	RThread thread;
+	RProcess process;
+	TInt err = Model().MemAccess().RThreadForceOpen(thread, info.iThreadId);
+	if (!err)
+		{
+		err = thread.Process(process);
+		}
+	TUint processId = err;
+	if (!err)
+		{
+		processId = (TUint)process.Id();
+		}
+	CleanupClosePushL(thread);
+	CleanupClosePushL(process);
+
+	_LIT(KInfo, "Thread info");
+	aTitle.Copy(KInfo);
+	inf.Copy(iInfo->iFullName);
+	inf.Append(Klflf);
+	
+	_LIT(KThread, "Tid: %d Pid: %d Kern Priority: %d\nPriority: %d (%S)\nProc Priority: %d (%S)");
+	_LIT(KCritical, "\n%S");
+	_LIT(KCreator, "\nCreator thread id: %d (%S)");
+	_LIT(KKern, "\nKernel object address: 0x%08x");
+	_LIT(KStack, "\n\nUser stack size: %S");
+	_LIT(KHeap, "\nAllocator: 0x%08x\nHeap size: %S (%d)\nMin/Max: %S/%S\nUnused: %S Usable: %S");
+	_LIT(KDied, "\n\nDied with: %S %S %i");
+
+	TThreadPriority threadPriority = (TThreadPriority)err;
+	TProcessPriority processPriority = (TProcessPriority)err;
+	TPtrC priority = _L("?");
+	TPtrC priorityP = _L("?");
+	if (!err)
+		{
+		threadPriority = thread.Priority();
+		priority.Set(ToString(threadPriority));
+		processPriority = process.Priority();
+		priorityP.Set(ToString(processPriority));
+		}
+	LtkUtils::RProxyAllocatorHelper allocHelper;
+	User::LeaveIfError(allocHelper.Open(Model().MemAccess(), info.iThreadId));
+	TBuf<16> heapSize, minHeap, maxHeap, unusedMem, reclaimableMem, stackSize;
+	HR(heapSize, allocHelper.CommittedSize());
+	HR(stackSize, info.iUserStackSize);
+	HR(minHeap, allocHelper.MinCommittedSize());
+	HR(maxHeap, allocHelper.MaxCommittedSize());
+	HR(unusedMem, allocHelper.CommittedFreeSpace());
+	HR(reclaimableMem, allocHelper.CountUnusedPages() * 4096);
+	inf.AppendFormat(KThread, info.iThreadId, processId, info.iThreadPriority, threadPriority, &priority, processPriority, &priorityP);
+
+	TUint creatorTid = Model().MemAccess().GetThreadCreatorId(info.iThreadId);
+	if (creatorTid != 0)
+		{
+		RThread creator;
+		TInt err = Model().MemAccess().RThreadForceOpen(creator, creatorTid);
+		*aTemp = _L("?");
+		if (err == KErrNone)
+			{
+			*aTemp = creator.FullName();
+			PrettyName(iType, *aTemp);
+			creator.Close();
+			}
+		inf.AppendFormat(KCreator, creatorTid, aTemp);
+		}
+
+	User::TCritical crit = User::ENotCritical;
+	if (!err)
+		{
+		crit = User::Critical(thread);
+		}
+	if (crit != User::ENotCritical)
+		{
+		TPtrC critical = ToString(crit);
+		inf.AppendFormat(KCritical, &critical);
+		}
+	inf.AppendFormat(KKern, info.iAddressOfKernelObject);
+
+	inf.AppendFormat(KStack, &stackSize);
+	inf.AppendFormat(KHeap, allocHelper.AllocatorAddress(), &heapSize, allocHelper.CommittedSize(), &minHeap, &maxHeap, &unusedMem, &reclaimableMem);
+	allocHelper.Close();
+	if (err == KErrNone && thread.ExitType() != EExitPending)
+		{
+		TPtrC exitStatus;
+		TInt exitReason = 0;
+		TExitCategoryName exitCategory;
+		exitStatus.Set(ToString(thread.ExitType()));
+		if (thread.ExitType() == EExitPanic)
+			{
+			exitCategory = thread.ExitCategory();
+			}
+		exitReason = thread.ExitReason();
+		inf.AppendFormat(KDied, &exitStatus, &exitCategory, exitReason);
+		}
+	CleanupStack::PopAndDestroy(2, &thread);
+	}
+
+TBool CThreadsListBoxData::SupportsCommand(TInt aCommand)
+	{
+	switch (aCommand)
+		{
+		case ECmdHandleInfo:
+		case ECmdKill:
+		case ECmdDumpHeap:
+		case ECmdSetCritical:
+		case ECmdSetPriority:
+		case ECmdPoll:
+			return ETrue;
+		default:
+			return EFalse;
+		}
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/timerlistboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,89 @@
+// timerlistboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+#include <fshell/qr3dll.h>
+#include "QResources3.hrh"
+
+CTimerListBoxData::CTimerListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CTimerListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
+	{
+	TTimerKernelInfo& info = *(TTimerKernelInfo*)aInfo;
+	name.Copy(info.iFullName);
+	PrettyName(iType, name);
+
+	more.Format(_L("Client status=0x%08x"), info.iClientStatus);
+	}
+
+void CTimerListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	TTimerKernelInfo& info = *(TTimerKernelInfo*)iInfo;
+	_LIT8(KDesc,"Timer;KernObjAddr;FullName;AccessCount;State;Type;TReqStat");
+	_LIT8(KFmt, "Timer;%x;%S;%d;%d;%d;%x");
+	
+	if (i == 0) clogger.Log(KDesc);
+	clogger.Log(KFmt, info.iAddressOfKernelObject, &info.iFullName, info.iAccessCount, info.iState, info.iType, info.iClientStatus);
+	}
+
+#define CASE_LIT2(val, name) case val: { _LIT(KName, #name); return KName; }
+
+const TDesC& Type(TUint8 aType)
+	{
+	switch (aType)
+		{
+		CASE_LIT2(1, ERelative);
+		CASE_LIT2(2, EAbsolute);
+		CASE_LIT2(4, ELocked);
+		CASE_LIT2(8, EHighRes);
+		CASE_LIT2(16, EInactivity);
+		default:
+			_LIT(KHuh, "?");
+			return KHuh;
+		}
+	}
+
+const TDesC& State(TUint8 aState)
+	{
+	switch (aState)
+		{
+		CASE_LIT2(0, EIdle);
+		CASE_LIT2(1, EWaiting);
+		CASE_LIT2(2, EWaitHighRes);
+		default:
+			_LIT(KHuh, "?");
+			return KHuh;
+		}
+	}
+
+void CTimerListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* /*aTemp*/)
+	{
+	TTimerKernelInfo& info = *(TTimerKernelInfo*)iInfo;
+	_LIT(KInfo, "Timer info");
+	aTitle.Copy(KInfo);
+
+	inf.Copy(iInfo->iFullName);
+	inf.Append(Klflf);
+	
+	inf.AppendFormat(_L("Kernel object address: 0x%08x\n"), info.iAddressOfKernelObject);
+	inf.AppendFormat(_L("Access count: %u\n"), info.iAccessCount);
+	const TDesC& type = Type(info.iType);
+	inf.AppendFormat(_L("Type: %d (%S)\n"), info.iType, &type);
+	const TDesC& state = State(info.iState);
+	inf.AppendFormat(_L("State: %d (%S)\n"), info.iState, &state);
+	inf.AppendFormat(_L("TRequestStatus: 0x%08x"), info.iClientStatus);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/qr3/src/wglistboxdata.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,107 @@
+// wglistboxdata.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "KernLbxModel.h"
+#include "Utils.h"
+#include <fshell/clogger.h>
+#include <fshell/memoryaccess.h>
+#include <fshell/common.mmh>
+
+
+#ifdef FSHELL_APPARC_SUPPORT
+#include <apgcli.h>
+#include <APGWGNAM.H>
+#include <APMREC.H>
+#endif
+#ifndef FSHELL_WSERV_SUPPPORT
+#include <W32STD.H>
+#endif
+
+CWindowGroupListBoxData::CWindowGroupListBoxData(CKernListBoxModel* aModel)
+	: CKernListBoxData(aModel)
+	{
+	}
+
+void CWindowGroupListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
+	{
+	SWgInfo& info = *reinterpret_cast<SWgInfo*>(aInfo);
+	CApaWindowGroupName* wgName = info.iName;
+	name.Copy(wgName->Caption());
+	_LIT(KUnnamed, "<Untitled window group>");
+	if (name.Length() == 0) name.Copy(KUnnamed);
+
+	TThreadId tid;
+	TInt res = info.iSession->GetWindowGroupClientThreadId(info.iHandle, tid);
+	if (res == KErrNone)
+		{
+		res = tid;
+		}
+	more.Format(_L("Busy=%i System=%i Tid=%i"), wgName->IsBusy(), wgName->IsSystem(), res);
+	}
+
+void CWindowGroupListBoxData::DumpToCloggerL(RClogger& clogger, TInt i, TInt /*count*/)
+	{
+	_LIT(KWgDesc,"WindowGroup;RawName;OwnerThreadId;System;Busy;Hidden");
+	_LIT(KWgFmt,"WindowGroup;%S;%i;%i;%i;%i");
+
+	if (i == 0) clogger.Log(KWgDesc);
+	SWgInfo& info = *reinterpret_cast<SWgInfo*>(iInfo);
+	CApaWindowGroupName* wg = info.iName;
+	TPtrC name = wg->WindowGroupName();
+	TBuf<256> temp = name;
+	PrettyName(EListWindowGroups, temp);
+	RBuf val;
+	val.CreateL(256);
+	TThreadId tid;
+	TInt res = info.iSession->GetWindowGroupClientThreadId(info.iHandle, tid);
+	if (res == KErrNone)
+		{
+		res = tid;
+		}
+
+	clogger.Log(KWgFmt, &temp, res, wg->IsSystem(), wg->IsBusy(), wg->Hidden());
+	val.Close();
+	}
+
+void CWindowGroupListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* name)
+	{
+	SWgInfo& info = *reinterpret_cast<SWgInfo*>(iInfo);
+	_LIT(KInfo, "Window group info");
+	aTitle.Copy(KInfo);
+	CApaWindowGroupName* wg = info.iName;
+	*name = wg->WindowGroupName();
+	PrettyName(EListWindowGroups, *name);
+
+	inf.Append(*name);
+	TThreadId tid;
+	TInt res = info.iSession->GetWindowGroupClientThreadId(info.iHandle, tid);
+	inf.AppendFormat(_L("\n\nOwner thread: %i"), res == KErrNone ? (TInt)tid : res);
+	RThread thread;
+	if (res == KErrNone)
+		{
+		res = thread.Open(tid);
+		}
+	if (res == KErrNone)
+		{
+		*name = thread.FullName();
+		PrettyName(EListThread, *name);
+		inf.AppendFormat(_L(" (%S)"), name);
+		}
+	inf.AppendFormat(_L("\nBusy=%i System=%i Hidden=%i"), wg->IsBusy(), wg->IsSystem(), wg->Hidden());
+	}
+
+CWindowGroupListBoxData::~CWindowGroupListBoxData()
+	{
+	if (iInfo)
+		{
+		delete reinterpret_cast<SWgInfo*>(iInfo)->iName;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/bwins/spcreu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,101 @@
+EXPORTS
+	?ParseTUintHex@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 1 NONAME ; int TRegExArg::ParseTUintHex(class TDesC8 const &, void *)
+	?ParseTUint32@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 2 NONAME ; int TRegExArg::ParseTUint32(class TDesC8 const &, void *)
+	?GlobalReplaceL@CRegEx@@QBEHABVTDesC8@@AAVTDes8@@@Z @ 3 NONAME ; int CRegEx::GlobalReplaceL(class TDesC8 const &, class TDes8 &) const
+	?FindAndConsumeL@CRegEx@@QBEHAAVTDes8@@@Z @ 4 NONAME ; int CRegEx::FindAndConsumeL(class TDes8 &) const
+	?ParseTUint8Hex@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 5 NONAME ; int TRegExArg::ParseTUint8Hex(class TDesC8 const &, void *)
+	??0TRegExArg@@QAE@PAVTChar@@P6AHABVTDesC8@@PAX@Z@Z @ 6 NONAME ; TRegExArg::TRegExArg(class TChar *, int (*)(class TDesC8 const &, void *))
+	??0TRegExArg@@QAE@PAJ@Z @ 7 NONAME ; TRegExArg::TRegExArg(long *)
+	??0TRegExArg@@QAE@PAJP6AHABVTDesC8@@PAX@Z@Z @ 8 NONAME ; TRegExArg::TRegExArg(long *, int (*)(class TDesC8 const &, void *))
+	??0TRegExOptions@@QAE@XZ @ 9 NONAME ; TRegExOptions::TRegExOptions(void)
+	?PartialMatchL@CRegEx@@QBEHABVTDesC8@@ABVTRegExArg@@11@Z @ 10 NONAME ; int CRegEx::PartialMatchL(class TDesC8 const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	?DoMatchL@CRegEx@@QBEHABVTDesC8@@W4TAnchor@1@AAHABV?$RPointerArray@$$CBVTRegExArg@@@@@Z @ 11 NONAME ; int CRegEx::DoMatchL(class TDesC8 const &, enum CRegEx::TAnchor, int &, class RPointerArray<class TRegExArg const > const &) const
+	?ParseTReal32@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 12 NONAME ; int TRegExArg::ParseTReal32(class TDesC8 const &, void *)
+	??0TRegExArg@@QAE@PAVTPtrC8@@P6AHABVTDesC8@@PAX@Z@Z @ 13 NONAME ; TRegExArg::TRegExArg(class TPtrC8 *, int (*)(class TDesC8 const &, void *))
+	??0TRegExArg@@QAE@PAE@Z @ 14 NONAME ; TRegExArg::TRegExArg(unsigned char *)
+	?ParseTInt16@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 15 NONAME ; int TRegExArg::ParseTInt16(class TDesC8 const &, void *)
+	?FindAndConsumeL@CRegEx@@QBEHAAVTDes8@@ABVTRegExArg@@111@Z @ 16 NONAME ; int CRegEx::FindAndConsumeL(class TDes8 &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	?FullMatchL@CRegEx@@QBEHABVTDesC8@@ABVTRegExArg@@@Z @ 17 NONAME ; int CRegEx::FullMatchL(class TDesC8 const &, class TRegExArg const &) const
+	?FindAndConsumeL@CRegEx@@QBEHAAVTDes8@@ABVTRegExArg@@11@Z @ 18 NONAME ; int CRegEx::FindAndConsumeL(class TDes8 &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	??0TRegExArg@@QAE@PAMP6AHABVTDesC8@@PAX@Z@Z @ 19 NONAME ; TRegExArg::TRegExArg(float *, int (*)(class TDesC8 const &, void *))
+	??0TRegExArg@@QAE@PACP6AHABVTDesC8@@PAX@Z@Z @ 20 NONAME ; TRegExArg::TRegExArg(signed char *, int (*)(class TDesC8 const &, void *))
+	??0TRegExArg@@QAE@PAVTDes8@@P6AHABVTDesC8@@PAX@Z@Z @ 21 NONAME ; TRegExArg::TRegExArg(class TDes8 *, int (*)(class TDesC8 const &, void *))
+	?FullMatchL@CRegEx@@QBEHABVTDesC8@@ABVTRegExArg@@111@Z @ 22 NONAME ; int CRegEx::FullMatchL(class TDesC8 const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	?ExtractL@CRegEx@@QBEHABVTDesC8@@0AAVTDes8@@@Z @ 23 NONAME ; int CRegEx::ExtractL(class TDesC8 const &, class TDesC8 const &, class TDes8 &) const
+	??0TRegExArg@@QAE@PAVTChar@@@Z @ 24 NONAME ; TRegExArg::TRegExArg(class TChar *)
+	?ParseTInt@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 25 NONAME ; int TRegExArg::ParseTInt(class TDesC8 const &, void *)
+	?ReplaceL@CRegEx@@QBEHABVTDesC8@@AAVTDes8@@@Z @ 26 NONAME ; int CRegEx::ReplaceL(class TDesC8 const &, class TDes8 &) const
+	?ParseTInt32@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 27 NONAME ; int TRegExArg::ParseTInt32(class TDesC8 const &, void *)
+	??0TRegExArg@@QAE@PAG@Z @ 28 NONAME ; TRegExArg::TRegExArg(unsigned short *)
+	?ParseTInt64Hex@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 29 NONAME ; int TRegExArg::ParseTInt64Hex(class TDesC8 const &, void *)
+	?FullMatchL@CRegEx@@QBEHABVTDesC8@@@Z @ 30 NONAME ; int CRegEx::FullMatchL(class TDesC8 const &) const
+	??0TRegExArg@@QAE@PAK@Z @ 31 NONAME ; TRegExArg::TRegExArg(unsigned long *)
+	?PartialMatchL@CRegEx@@QBEHABVTDesC8@@ABVTRegExArg@@111@Z @ 32 NONAME ; int CRegEx::PartialMatchL(class TDesC8 const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	??0TRegExArg@@QAE@PAIP6AHABVTDesC8@@PAX@Z@Z @ 33 NONAME ; TRegExArg::TRegExArg(unsigned int *, int (*)(class TDesC8 const &, void *))
+	??0TRegExArg@@QAE@PANP6AHABVTDesC8@@PAX@Z@Z @ 34 NONAME ; TRegExArg::TRegExArg(double *, int (*)(class TDesC8 const &, void *))
+	?ParseTReal64@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 35 NONAME ; int TRegExArg::ParseTReal64(class TDesC8 const &, void *)
+	?ParseTUint16Octal@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 36 NONAME ; int TRegExArg::ParseTUint16Octal(class TDesC8 const &, void *)
+	?PartialMatchL@CRegEx@@QBEHABVTDesC8@@ABVTRegExArg@@1@Z @ 37 NONAME ; int CRegEx::PartialMatchL(class TDesC8 const &, class TRegExArg const &, class TRegExArg const &) const
+	?FindAndConsumeL@CRegEx@@QBEHAAVTDes8@@ABVTRegExArg@@1@Z @ 38 NONAME ; int CRegEx::FindAndConsumeL(class TDes8 &, class TRegExArg const &, class TRegExArg const &) const
+	?DoMatchL@CRegEx@@QBEHABVTDesC8@@W4TAnchor@1@AAHABVTRegExArg@@333@Z @ 39 NONAME ; int CRegEx::DoMatchL(class TDesC8 const &, enum CRegEx::TAnchor, int &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	?ConsumeL@CRegEx@@QBEHAAVTDes8@@ABVTRegExArg@@1@Z @ 40 NONAME ; int CRegEx::ConsumeL(class TDes8 &, class TRegExArg const &, class TRegExArg const &) const
+	??0TRegExArg@@QAE@PAFP6AHABVTDesC8@@PAX@Z@Z @ 41 NONAME ; TRegExArg::TRegExArg(short *, int (*)(class TDesC8 const &, void *))
+	??0TRegExArg@@QAE@PAN@Z @ 42 NONAME ; TRegExArg::TRegExArg(double *)
+	?FindAndConsumeL@CRegEx@@QBEHAAVTDes8@@ABVTRegExArg@@@Z @ 43 NONAME ; int CRegEx::FindAndConsumeL(class TDes8 &, class TRegExArg const &) const
+	??0TRegExArg@@QAE@PAGP6AHABVTDesC8@@PAX@Z@Z @ 44 NONAME ; TRegExArg::TRegExArg(unsigned short *, int (*)(class TDesC8 const &, void *))
+	?DoMatchL@CRegEx@@QBEHABVTDesC8@@W4TAnchor@1@AAHABVTRegExArg@@@Z @ 45 NONAME ; int CRegEx::DoMatchL(class TDesC8 const &, enum CRegEx::TAnchor, int &, class TRegExArg const &) const
+	?ParseTInt8@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 46 NONAME ; int TRegExArg::ParseTInt8(class TDesC8 const &, void *)
+	?ParseTInt64Radix@TRegExArg@@CAHABVTDesC8@@PAXW4TRadix@@@Z @ 47 NONAME ; int TRegExArg::ParseTInt64Radix(class TDesC8 const &, void *, enum TRadix)
+	?ParseTInt64@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 48 NONAME ; int TRegExArg::ParseTInt64(class TDesC8 const &, void *)
+	??0TRegExArg@@QAE@PAM@Z @ 49 NONAME ; TRegExArg::TRegExArg(float *)
+	?ParseTUint@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 50 NONAME ; int TRegExArg::ParseTUint(class TDesC8 const &, void *)
+	?DoMatchL@CRegEx@@QBEHABVTDesC8@@W4TAnchor@1@AAH@Z @ 51 NONAME ; int CRegEx::DoMatchL(class TDesC8 const &, enum CRegEx::TAnchor, int &) const
+	??1CRegEx@@UAE@XZ @ 52 NONAME ; CRegEx::~CRegEx(void)
+	?Study@CRegEx@@QAEXXZ @ 53 NONAME ; void CRegEx::Study(void)
+	?ParseTUint32Octal@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 54 NONAME ; int TRegExArg::ParseTUint32Octal(class TDesC8 const &, void *)
+	?DoMatchL@CRegEx@@QBEHABVTDesC8@@W4TAnchor@1@AAHABVTRegExArg@@3@Z @ 55 NONAME ; int CRegEx::DoMatchL(class TDesC8 const &, enum CRegEx::TAnchor, int &, class TRegExArg const &, class TRegExArg const &) const
+	?PartialMatchL@CRegEx@@QBEHABVTDesC8@@ABVTRegExArg@@@Z @ 56 NONAME ; int CRegEx::PartialMatchL(class TDesC8 const &, class TRegExArg const &) const
+	?NumberOfCapturingGroups@CRegEx@@QBEHXZ @ 57 NONAME ; int CRegEx::NumberOfCapturingGroups(void) const
+	?ParseNull@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 58 NONAME ; int TRegExArg::ParseNull(class TDesC8 const &, void *)
+	?ParseTUint16@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 59 NONAME ; int TRegExArg::ParseTUint16(class TDesC8 const &, void *)
+	?NewL@CRegEx@@SAPAV1@ABVTDesC8@@ABVTRegExOptions@@@Z @ 60 NONAME ; class CRegEx * CRegEx::NewL(class TDesC8 const &, class TRegExOptions const &)
+	?ParseTUint16Radix@TRegExArg@@CAHABVTDesC8@@PAXW4TRadix@@@Z @ 61 NONAME ; int TRegExArg::ParseTUint16Radix(class TDesC8 const &, void *, enum TRadix)
+	?ParseTChar@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 62 NONAME ; int TRegExArg::ParseTChar(class TDesC8 const &, void *)
+	?ParseTUintOctal@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 63 NONAME ; int TRegExArg::ParseTUintOctal(class TDesC8 const &, void *)
+	?ConsumeL@CRegEx@@QBEHAAVTDes8@@ABVTRegExArg@@111@Z @ 64 NONAME ; int CRegEx::ConsumeL(class TDes8 &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	?NewlineMode@CRegEx@@SAHH@Z @ 65 NONAME ; int CRegEx::NewlineMode(int)
+	?ParseTUintRadix@TRegExArg@@CAHABVTDesC8@@PAXW4TRadix@@@Z @ 66 NONAME ; int TRegExArg::ParseTUintRadix(class TDesC8 const &, void *, enum TRadix)
+	?ParseTUint8Octal@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 67 NONAME ; int TRegExArg::ParseTUint8Octal(class TDesC8 const &, void *)
+	?NewLC@CRegEx@@SAPAV1@ABVTDesC8@@@Z @ 68 NONAME ; class CRegEx * CRegEx::NewLC(class TDesC8 const &)
+	?ParseTDes8@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 69 NONAME ; int TRegExArg::ParseTDes8(class TDesC8 const &, void *)
+	??0TRegExArg@@QAE@PAI@Z @ 70 NONAME ; TRegExArg::TRegExArg(unsigned int *)
+	?PartialMatchL@CRegEx@@QBEHABVTDesC8@@@Z @ 71 NONAME ; int CRegEx::PartialMatchL(class TDesC8 const &) const
+	?ParseTUint8@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 72 NONAME ; int TRegExArg::ParseTUint8(class TDesC8 const &, void *)
+	??0TRegExArg@@QAE@PAKP6AHABVTDesC8@@PAX@Z@Z @ 73 NONAME ; TRegExArg::TRegExArg(unsigned long *, int (*)(class TDesC8 const &, void *))
+	?ParseTInt64Octal@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 74 NONAME ; int TRegExArg::ParseTInt64Octal(class TDesC8 const &, void *)
+	?ConsumeL@CRegEx@@QBEHAAVTDes8@@ABVTRegExArg@@@Z @ 75 NONAME ; int CRegEx::ConsumeL(class TDes8 &, class TRegExArg const &) const
+	?ParseTUint8Radix@TRegExArg@@CAHABVTDesC8@@PAXW4TRadix@@@Z @ 76 NONAME ; int TRegExArg::ParseTUint8Radix(class TDesC8 const &, void *, enum TRadix)
+	?ParseTUint32Hex@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 77 NONAME ; int TRegExArg::ParseTUint32Hex(class TDesC8 const &, void *)
+	??0TRegExArg@@QAE@PAH@Z @ 78 NONAME ; TRegExArg::TRegExArg(int *)
+	?ConsumeL@CRegEx@@QBEHAAVTDes8@@@Z @ 79 NONAME ; int CRegEx::ConsumeL(class TDes8 &) const
+	?ParseTUint16Hex@TRegExArg@@SAHABVTDesC8@@PAX@Z @ 80 NONAME ; int TRegExArg::ParseTUint16Hex(class TDesC8 const &, void *)
+	??0TRegExArg@@QAE@PA_J@Z @ 81 NONAME ; TRegExArg::TRegExArg(long long *)
+	?NewL@CRegEx@@SAPAV1@ABVTDesC8@@@Z @ 82 NONAME ; class CRegEx * CRegEx::NewL(class TDesC8 const &)
+	?FullMatchL@CRegEx@@QBEHABVTDesC8@@ABVTRegExArg@@11@Z @ 83 NONAME ; int CRegEx::FullMatchL(class TDesC8 const &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	?FullMatchL@CRegEx@@QBEHABVTDesC8@@ABVTRegExArg@@1@Z @ 84 NONAME ; int CRegEx::FullMatchL(class TDesC8 const &, class TRegExArg const &, class TRegExArg const &) const
+	?QuoteMetaL@CRegEx@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 85 NONAME ; class HBufC8 * CRegEx::QuoteMetaL(class TDesC8 const &)
+	??0TRegExArg@@QAE@PAVTDes8@@@Z @ 86 NONAME ; TRegExArg::TRegExArg(class TDes8 *)
+	?ConsumeL@CRegEx@@QBEHAAVTDes8@@ABVTRegExArg@@11@Z @ 87 NONAME ; int CRegEx::ConsumeL(class TDes8 &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	?NewLC@CRegEx@@SAPAV1@ABVTDesC8@@ABVTRegExOptions@@@Z @ 88 NONAME ; class CRegEx * CRegEx::NewLC(class TDesC8 const &, class TRegExOptions const &)
+	??0TRegExArg@@QAE@PAC@Z @ 89 NONAME ; TRegExArg::TRegExArg(signed char *)
+	??0TRegExArg@@QAE@PAVTPtrC8@@@Z @ 90 NONAME ; TRegExArg::TRegExArg(class TPtrC8 *)
+	??0TRegExArg@@QAE@PAF@Z @ 91 NONAME ; TRegExArg::TRegExArg(short *)
+	??0TRegExArg@@QAE@PAEP6AHABVTDesC8@@PAX@Z@Z @ 92 NONAME ; TRegExArg::TRegExArg(unsigned char *, int (*)(class TDesC8 const &, void *))
+	?ParseTPtrC8@TRegExArg@@CAHABVTDesC8@@PAX@Z @ 93 NONAME ; int TRegExArg::ParseTPtrC8(class TDesC8 const &, void *)
+	?DoMatchL@CRegEx@@QBEHABVTDesC8@@W4TAnchor@1@AAHABVTRegExArg@@33@Z @ 94 NONAME ; int CRegEx::DoMatchL(class TDesC8 const &, enum CRegEx::TAnchor, int &, class TRegExArg const &, class TRegExArg const &, class TRegExArg const &) const
+	??0TRegExOptions@@QAE@I@Z @ 95 NONAME ; TRegExOptions::TRegExOptions(unsigned int)
+	?ParseTUint32Radix@TRegExArg@@CAHABVTDesC8@@PAXW4TRadix@@@Z @ 96 NONAME ; int TRegExArg::ParseTUint32Radix(class TDesC8 const &, void *, enum TRadix)
+	??0TRegExArg@@QAE@PA_JP6AHABVTDesC8@@PAX@Z@Z @ 97 NONAME ; TRegExArg::TRegExArg(long long *, int (*)(class TDesC8 const &, void *))
+	??0TRegExArg@@QAE@PAHP6AHABVTDesC8@@PAX@Z@Z @ 98 NONAME ; TRegExArg::TRegExArg(int *, int (*)(class TDesC8 const &, void *))
+	?NewL@CRegEx@@SAPAV1@ABVTDesC16@@ABVTRegExOptions@@@Z @ 99 NONAME ; class CRegEx * CRegEx::NewL(class TDesC16 const &, class TRegExOptions const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/eabi/spcreu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,74 @@
+EXPORTS
+	_ZN13TRegExOptionsC1Ej @ 1 NONAME
+	_ZN13TRegExOptionsC1Ev @ 2 NONAME
+	_ZN13TRegExOptionsC2Ej @ 3 NONAME
+	_ZN13TRegExOptionsC2Ev @ 4 NONAME
+	_ZN6CRegEx10QuoteMetaLERK6TDesC8 @ 5 NONAME
+	_ZN6CRegEx11NewlineModeEi @ 6 NONAME
+	_ZN6CRegEx4NewLERK6TDesC8 @ 7 NONAME
+	_ZN6CRegEx4NewLERK6TDesC8RK13TRegExOptions @ 8 NONAME
+	_ZN6CRegEx5NewLCERK6TDesC8 @ 9 NONAME
+	_ZN6CRegEx5NewLCERK6TDesC8RK13TRegExOptions @ 10 NONAME
+	_ZN6CRegEx5StudyEv @ 11 NONAME
+	_ZN6CRegExD0Ev @ 12 NONAME
+	_ZN6CRegExD1Ev @ 13 NONAME
+	_ZN6CRegExD2Ev @ 14 NONAME
+	_ZN9TRegExArg10ParseTCharERK6TDesC8Pv @ 15 NONAME
+	_ZN9TRegExArg10ParseTDes8ERK6TDesC8Pv @ 16 NONAME
+	_ZN9TRegExArg10ParseTInt8ERK6TDesC8Pv @ 17 NONAME
+	_ZN9TRegExArg10ParseTUintERK6TDesC8Pv @ 18 NONAME
+	_ZN9TRegExArg11ParseTInt16ERK6TDesC8Pv @ 19 NONAME
+	_ZN9TRegExArg11ParseTInt32ERK6TDesC8Pv @ 20 NONAME
+	_ZN9TRegExArg11ParseTInt64ERK6TDesC8Pv @ 21 NONAME
+	_ZN9TRegExArg11ParseTPtrC8ERK6TDesC8Pv @ 22 NONAME
+	_ZN9TRegExArg11ParseTUint8ERK6TDesC8Pv @ 23 NONAME
+	_ZN9TRegExArg12ParseTReal32ERK6TDesC8Pv @ 24 NONAME
+	_ZN9TRegExArg12ParseTReal64ERK6TDesC8Pv @ 25 NONAME
+	_ZN9TRegExArg12ParseTUint16ERK6TDesC8Pv @ 26 NONAME
+	_ZN9TRegExArg12ParseTUint32ERK6TDesC8Pv @ 27 NONAME
+	_ZN9TRegExArg13ParseTUintHexERK6TDesC8Pv @ 28 NONAME
+	_ZN9TRegExArg14ParseTInt64HexERK6TDesC8Pv @ 29 NONAME
+	_ZN9TRegExArg14ParseTUint8HexERK6TDesC8Pv @ 30 NONAME
+	_ZN9TRegExArg15ParseTUint16HexERK6TDesC8Pv @ 31 NONAME
+	_ZN9TRegExArg15ParseTUint32HexERK6TDesC8Pv @ 32 NONAME
+	_ZN9TRegExArg15ParseTUintOctalERK6TDesC8Pv @ 33 NONAME
+	_ZN9TRegExArg16ParseTInt64OctalERK6TDesC8Pv @ 34 NONAME
+	_ZN9TRegExArg16ParseTUint8OctalERK6TDesC8Pv @ 35 NONAME
+	_ZN9TRegExArg17ParseTUint16OctalERK6TDesC8Pv @ 36 NONAME
+	_ZN9TRegExArg17ParseTUint32OctalERK6TDesC8Pv @ 37 NONAME
+	_ZN9TRegExArg9ParseNullERK6TDesC8Pv @ 38 NONAME
+	_ZN9TRegExArg9ParseTIntERK6TDesC8Pv @ 39 NONAME
+	_ZNK6CRegEx10FullMatchLERK6TDesC8 @ 40 NONAME
+	_ZNK6CRegEx10FullMatchLERK6TDesC8RK9TRegExArg @ 41 NONAME
+	_ZNK6CRegEx10FullMatchLERK6TDesC8RK9TRegExArgS5_ @ 42 NONAME
+	_ZNK6CRegEx10FullMatchLERK6TDesC8RK9TRegExArgS5_S5_ @ 43 NONAME
+	_ZNK6CRegEx10FullMatchLERK6TDesC8RK9TRegExArgS5_S5_S5_ @ 44 NONAME
+	_ZNK6CRegEx13PartialMatchLERK6TDesC8 @ 45 NONAME
+	_ZNK6CRegEx13PartialMatchLERK6TDesC8RK9TRegExArg @ 46 NONAME
+	_ZNK6CRegEx13PartialMatchLERK6TDesC8RK9TRegExArgS5_ @ 47 NONAME
+	_ZNK6CRegEx13PartialMatchLERK6TDesC8RK9TRegExArgS5_S5_ @ 48 NONAME
+	_ZNK6CRegEx13PartialMatchLERK6TDesC8RK9TRegExArgS5_S5_S5_ @ 49 NONAME
+	_ZNK6CRegEx14GlobalReplaceLERK6TDesC8R5TDes8 @ 50 NONAME
+	_ZNK6CRegEx15FindAndConsumeLER5TDes8 @ 51 NONAME
+	_ZNK6CRegEx15FindAndConsumeLER5TDes8RK9TRegExArg @ 52 NONAME
+	_ZNK6CRegEx15FindAndConsumeLER5TDes8RK9TRegExArgS4_ @ 53 NONAME
+	_ZNK6CRegEx15FindAndConsumeLER5TDes8RK9TRegExArgS4_S4_ @ 54 NONAME
+	_ZNK6CRegEx15FindAndConsumeLER5TDes8RK9TRegExArgS4_S4_S4_ @ 55 NONAME
+	_ZNK6CRegEx23NumberOfCapturingGroupsEv @ 56 NONAME
+	_ZNK6CRegEx8ConsumeLER5TDes8 @ 57 NONAME
+	_ZNK6CRegEx8ConsumeLER5TDes8RK9TRegExArg @ 58 NONAME
+	_ZNK6CRegEx8ConsumeLER5TDes8RK9TRegExArgS4_ @ 59 NONAME
+	_ZNK6CRegEx8ConsumeLER5TDes8RK9TRegExArgS4_S4_ @ 60 NONAME
+	_ZNK6CRegEx8ConsumeLER5TDes8RK9TRegExArgS4_S4_S4_ @ 61 NONAME
+	_ZNK6CRegEx8DoMatchLERK6TDesC8NS_7TAnchorERi @ 62 NONAME
+	_ZNK6CRegEx8DoMatchLERK6TDesC8NS_7TAnchorERiRK13RPointerArrayIK9TRegExArgE @ 63 NONAME
+	_ZNK6CRegEx8DoMatchLERK6TDesC8NS_7TAnchorERiRK9TRegExArg @ 64 NONAME
+	_ZNK6CRegEx8DoMatchLERK6TDesC8NS_7TAnchorERiRK9TRegExArgS7_ @ 65 NONAME
+	_ZNK6CRegEx8DoMatchLERK6TDesC8NS_7TAnchorERiRK9TRegExArgS7_S7_ @ 66 NONAME
+	_ZNK6CRegEx8DoMatchLERK6TDesC8NS_7TAnchorERiRK9TRegExArgS7_S7_S7_ @ 67 NONAME
+	_ZNK6CRegEx8ExtractLERK6TDesC8S2_R5TDes8 @ 68 NONAME
+	_ZNK6CRegEx8ReplaceLERK6TDesC8R5TDes8 @ 69 NONAME
+	_ZTI6CRegEx @ 70 NONAME ; #<TI>#
+	_ZTV6CRegEx @ 71 NONAME ; #<VT>#
+	_ZN6CRegEx4NewLERK7TDesC16RK13TRegExOptions @ 72 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/grep/Grep.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,111 @@
+# Grep.cif
+# 
+# Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+==name grep
+
+==short-description
+
+Unix-style grep with full Regular Expression support.
+
+==argument string pattern
+
+The pattern to be matched. To escape Regex special characters use '\'.
+
+==option bool i ignore-case
+
+Ignore case distinctions.
+
+==option bool v invert-match
+
+Print lines that do B<not> match.
+
+==option bool c count
+
+Don't print the lines that match, just count them and print the total at the end. If used with C<--invert-match>, counts the number of non-matching lines.
+
+==option bool u unicode
+
+Run the search in unicode (UTF-8) mode rather than assuming ASCII. Possibly slower.
+
+==long-description
+
+Prints to C<stdout> any lines of C<stdin> that match a particular pattern. Uses the PCRE library.
+
+==see-also
+
+L<match|match>
+
+==copyright
+
+The grep command itself is copyright (c) 2009 - 2010 Accenture. All rights reserved.
+
+The copyright notice for the PCRE library follows:
+
+			   Copyright (c) 1997-2008 University of Cambridge
+
+	-----------------------------------------------------------------------------
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are met:
+
+		* Redistributions of source code must retain the above copyright notice,
+		  this list of conditions and the following disclaimer.
+
+		* 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.
+
+		* Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+	AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+	ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+	LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+	CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
+	-----------------------------------------------------------------------------
+
+The copyright notice for the C++ wrappers to PCRE library follows:
+
+	Copyright (c) 2005 - 2006, Google Inc.
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are
+	met:
+
+		* Redistributions of source code must retain the above copyright
+	notice, this list of conditions and the following disclaimer.
+		* 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.
+		* Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+	LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+	A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+	OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+	LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+	OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/grep/Grep.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,160 @@
+// Grep.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+#include <fshell/descriptorutils.h>
+#include <fshell/pcre/cregex.h>
+
+using namespace IoUtils;
+using namespace LtkUtils;
+
+class CCmdGrep : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdGrep();
+private:
+	CCmdGrep();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	HBufC* iPattern;
+	TBool iIgnoreCase;
+	TBool iInvertMatch;
+	TBool iCount;
+	TBool iUnicode;
+
+	RLtkBuf8 iNarrowBuf;
+	CRegEx* iRegex;
+	};
+
+EXE_BOILER_PLATE(CCmdGrep)
+
+CCommandBase* CCmdGrep::NewLC()
+	{
+	CCmdGrep* self = new(ELeave) CCmdGrep();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdGrep::~CCmdGrep()
+	{
+	delete iPattern;
+	delete iRegex;
+	iNarrowBuf.Close();
+	}
+
+CCmdGrep::CCmdGrep()
+	{
+	}
+
+const TDesC& CCmdGrep::Name() const
+	{
+	_LIT(KName, "grep");	
+	return KName;
+	}
+
+void CCmdGrep::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	aArguments.AppendStringL(iPattern, _L("pattern"));
+	}
+
+void CCmdGrep::OptionsL(RCommandOptionList& aOptions)
+	{
+	_LIT(KCmdGrepOptIgnoreCase, "ignore-case");
+	_LIT(KCmdGrepOptInvertMatch, "invert-match");
+	_LIT(KCmdGrepOptCount, "count");
+	_LIT(KCmdGrepOptUnicode, "unicode");
+	aOptions.AppendBoolL(iIgnoreCase, KCmdGrepOptIgnoreCase);
+	aOptions.AppendBoolL(iInvertMatch, KCmdGrepOptInvertMatch);
+	aOptions.AppendBoolL(iCount, KCmdGrepOptCount);
+	aOptions.AppendBoolL(iUnicode, KCmdGrepOptUnicode);
+	}
+
+void CCmdGrep::DoRunL()
+	{
+	TRegExOptions options(EPcreExtended|EPcreNewlineAny);
+	if (iUnicode)
+		{
+		iNarrowBuf.CopyAsUtf8L(*iPattern);
+		options.SetUtf8(ETrue);
+		}
+	else
+		{
+		iNarrowBuf.AppendL(*iPattern);
+		}
+	if (iIgnoreCase) options.SetCaseless(ETrue);
+
+	iRegex = CRegEx::NewL(iNarrowBuf, options);
+
+	Stdin().SetReadMode(RIoReadHandle::ELine);
+	TBuf<0x100> line;
+	TInt count = 0;
+	while (Stdin().Read(line) == KErrNone)
+		{
+		iNarrowBuf.Zero();
+		if (iUnicode)
+			{
+			iNarrowBuf.CopyAsUtf8L(line);
+			}
+		else
+			{
+			iNarrowBuf.AppendL(line);
+			}
+
+		TBool matches = iRegex->PartialMatchL(iNarrowBuf);
+
+		if (iInvertMatch)
+			{
+			matches = !matches;
+			}
+		if (matches)
+			{
+			if (iCount)
+				{
+				count++;
+				}
+			else
+				{
+				Write(line);
+				}
+			}
+		}
+
+	if (iCount)
+		{
+		Printf(_L("Count = %d"), count);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/grep/Grep.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,48 @@
+// Grep.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include <fshell/common.mmh>
+
+target			fshell_grep.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_GREP
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+systeminclude	/epoc32/include/fshell/pcre
+
+sourcepath		.
+source			Grep.cpp
+
+library			euser.lib
+library			iocli.lib
+library			ltkutils.lib spcre.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/group/ToDo.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,13 @@
+SPCRE
+
+Currently, it is mostly a direct port of Google's C++ wrapper
+around PCRE for Symbian so there is still quite a bit lacking.
+
+* Add Locale support
+* Support more PCRE options in TRegExArg
+* Refactor to use more templates and less macros in TRegExArg.
+* Full UCS2 support and not just UTF8. Unfortunately, this may slow things down
+  as PCRE doesn't support this natively so some wastefull conversion will have
+  to take place.
+* Port unit tests over to TEF. Will get rid of lots of code duplication.
+* Include CRadix parsing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,53 @@
+// bld.inf
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+
+PRJ_EXPORTS
+..\group\spcre.iby            \epoc32\rom\include\spcre.iby
+
+..\inc\cregex.h               \epoc32\include\fshell\pcre\cregex.h
+..\inc\cregex.inl             \epoc32\include\fshell\pcre\cregex.inl
+..\inc\tregexarg.h            \epoc32\include\fshell\pcre\tregexarg.h
+..\inc\tregexarg.inl          \epoc32\include\fshell\pcre\tregexarg.inl
+..\inc\tregexoptions.h        \epoc32\include\fshell\pcre\tregexoptions.h
+..\inc\tregexoptions.inl      \epoc32\include\fshell\pcre\tregexoptions.inl
+
+..\grep\grep.cif              z:\resource\cif\fshell\grep.cif
+
+
+PRJ_MMPFILES
+spcre.mmp
+..\libpcre\group\libpcre.mmp
+..\grep\grep.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/group/spcre.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// spcre.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __SPCRE_IBY__
+#define __SPCRE_IBY__
+
+#include <fsh_config.iby>
+
+FSHELL_EXECUTABLE_FILE(spcre.dll)
+FSHELL_EXECUTABLE_FILE(libpcre.dll)
+FSHELL_EXECUTABLE_FILE(fshell_grep.exe)
+FSHELL_COMMAND_INFO_FILE(fshell,grep.cif)
+
+//#define SPCRE_TEST
+#ifdef SPCRE_TEST
+FSHELL_EXECUTABLE_FILE(spcreconsole.exe)
+#endif // SPCRE_TEST
+#undef SPCRE_TEST
+
+#endif // __SPCRE_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/group/spcre.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,57 @@
+// spcre.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+#include <fshell/common.mmh>
+
+target				spcre.dll
+targettype			dll
+uid					0x1000008d FSHELL_UID_SPCRE
+
+capability			FSHELL_CAP_MMP_NORMAL
+
+macro				HAVE_CONFIG_H
+macro				SUPPORT_UTF8
+
+systeminclude		/epoc32/include
+systeminclude		/epoc32/include/libc
+systeminclude		/epoc32/include/fshell/pcre
+
+userinclude			../inc
+userinclude			../libpcre/inc
+
+sourcepath			../src
+
+source				cregex.cpp
+source				tregexoptions.cpp
+source				tregexarg.cpp
+
+library				euser.lib
+library				libpcre.lib
+library				ltkutils.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/inc/cregex.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,792 @@
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+
+// Heavily refactored for Symbian OS by Accenture.
+
+#ifndef CREGEX_H_
+#define CREGXX_H_
+
+#include <e32base.h>
+#include "tregexoptions.h"
+
+// Forward declarations
+class TRegExArg;
+struct real_pcre;
+typedef struct real_pcre pcre;
+struct pcre_extra;
+
+// Errors
+
+/** Base offset for CRegEx Errors */
+const TInt KErrRegExBase 									= -20000;
+
+/** Base offset for RegEx pattern compile errors */
+const TInt KErrRegExCompileBase 							= KErrRegExBase;
+
+/** \ at end of pattern */
+const TInt KErrRegExCmpBackslashAtEOP 						= KErrRegExCompileBase - 1;
+/** \c at end of pattern */
+const TInt KErrRegExCmpBackslashCAtEOP 						= KErrRegExCompileBase - 2;
+/** unrecognized character follows \ */
+const TInt KErrRegExCmpUnrecCharAftBackslash				= KErrRegExCompileBase - 3;
+/** numbers out of order in {} quantifier */
+const TInt KErrRegExCmpNumsOutOfOrderInBraceQuantifier		= KErrRegExCompileBase - 4;
+/** number too big in {} quantifier */
+const TInt KErrRegExCmpNumTooBigInBraceQuantifier			= KErrRegExCompileBase - 5;
+/** missing terminating ] for character class */
+const TInt KErrRegExCmpMissingTermBracketInCharClass		= KErrRegExCompileBase - 6;
+/** invalid escape sequence in character class */
+const TInt KErrRegExCmpInvalidEscapeSeqInCharClass			= KErrRegExCompileBase - 7;
+/** range out of order in character class */
+const TInt KErrRegExCmpRangeOutOfOrderInCharClass			= KErrRegExCompileBase - 8;
+/** nothing to repeat */
+const TInt KErrRegExCmpNothingToRepeat						= KErrRegExCompileBase - 9;
+/** operand of unlimited repeat could match the empty string - no longer used */
+const TInt KErrRegExCmpUnused01								= KErrRegExCompileBase - 10;
+/** internal error: unexpected repeat */
+const TInt KErrRegExCmpUnexpectedRepeat						= KErrRegExCompileBase - 11;
+/** unrecognized character after (? or (?-\0t */
+const TInt KErrRegExCmpUnexpectedCharAftParenthQuest		= KErrRegExCompileBase - 12;
+/** POSIX named classes are supported only within a class */
+const TInt KErrRegExCmpPosixNamedSupportedWithinClass		= KErrRegExCompileBase - 13;
+/** missing ) */
+const TInt KErrRegExCmpMissingCloseParenth					= KErrRegExCompileBase - 14;
+/** reference to non-existent subpattern */
+const TInt KErrRegExCmpRefNonExistSubpattern				= KErrRegExCompileBase - 15;
+/** internal error: erroffset passed as NULL */
+const TInt KErrRegExCmpErrOffsetNull						= KErrRegExCompileBase - 16;
+/** unknown option bit(s) set */
+const TInt KErrRegExCmpUnknownOptionBitsSet					= KErrRegExCompileBase - 17;
+/** missing ) after comment */
+const TInt KErrRegExCmpMissingCloseParenthAftComment		= KErrRegExCompileBase - 18;
+/** parentheses nested too deeply - no longer used */
+const TInt KErrRegExCmpUnused02								= KErrRegExCompileBase - 19;
+/** regular expression is too large */
+const TInt KErrRegExCmpExprTooLarge							= KErrRegExCompileBase - 20;
+/** failed to get memory */
+const TInt KErrRegExCmpFailedGetMemory						= KErrRegExCompileBase - 21;
+/** unmatched parentheses */
+const TInt KErrRegExCmpUnmatchedParenth						= KErrRegExCompileBase - 22;
+/** internal error: code overflow */
+const TInt KErrRegExCmpCodeOverflow							= KErrRegExCompileBase - 23;
+/** unrecognized character after (?< */
+const TInt KErrRegExCmpUnRecogCharAftParenthQuestAngle		= KErrRegExCompileBase - 24;
+/** lookbehind assertion is not fixed length*/
+const TInt KErrRegExCmpLookbehindAssertNotFixedLen			= KErrRegExCompileBase - 25;
+/** malformed number or name after (?( */
+const TInt KErrRegExCmpMalformedAftParenthQuestParenth		= KErrRegExCompileBase - 26;
+/** conditional group contains more than two branches */
+const TInt KErrRegExCmpCondGroupMoreThanTwoBranches			= KErrRegExCompileBase - 27;
+/** assertion expected after (?(\0 */
+const TInt KErrRegExCmpAssertExpAftParenthQuestParent		= KErrRegExCompileBase - 28;
+/** (?R or (?[+-]digits must be followed by ) */
+const TInt KErrRegExCmpMustFollowedByCloseParenth			= KErrRegExCompileBase - 29;
+/** unknown POSIX class name */
+const TInt KErrRegExCmpUnknownPosixClassName				= KErrRegExCompileBase - 30;
+/** POSIX collating elements are not supported */
+const TInt KErrRegExCmpPosixCollElemsNotSupported			= KErrRegExCompileBase - 31;
+/** this version of PCRE is not compiled with PCRE_UTF8 support */
+const TInt KErrRegExCmpNotCompiledWithUtf8Support			= KErrRegExCompileBase - 32;
+/** spare error - no longer user  */
+const TInt KErrRegExCmpUnused03								= KErrRegExCompileBase - 33;
+/** character value in \x{...} sequence is too large */
+const TInt KErrRegExCmpCharValueInBackslashXSeqTooLarge		= KErrRegExCompileBase - 34;
+/** invalid condition (?(0) */
+const TInt KErrRegExCmpInvalidCondition						= KErrRegExCompileBase - 35;
+/** \C not allowed in lookbehind assertion */
+const TInt KErrRegExCmpBackslashCNotAllowedinLookbehind		= KErrRegExCompileBase - 36;
+/** PCRE does not support \L, \l, \N, \U, or \u\0 */
+const TInt KErrRegExCmpLNUEscapeSeqNotSupported				= KErrRegExCompileBase - 37;
+/** number after (?C is > 255 */
+const TInt KErrRegExCmpNumAftParenthQuestCIsGreatherThan	= KErrRegExCompileBase - 38;
+/** closing ) for (?C expected\ */
+const TInt KErrRegExCmpCloseParenthAftParenthQuestCExp		= KErrRegExCompileBase - 39;
+/** recursive call could loop indefinitely */
+const TInt KErrRegExCmpRecuriveCallLoopIndef				= KErrRegExCompileBase - 40;
+/** unrecognized character after (?P */
+const TInt KErrRegExCmpUnrecCharaftParenthQuestP			= KErrRegExCompileBase - 41;
+/** syntax error in subpattern name (missing terminator) */
+const TInt KErrRegExCmpSyntaxInSubpatternName				= KErrRegExCompileBase - 42;
+/** two named subpatterns have the same name */
+const TInt KErrRegExCmpTwoSubpatternsHaveSameName			= KErrRegExCompileBase - 43;
+/** invalid UTF-8 string */
+const TInt KErrRegExCmpInvalidUtf8String					= KErrRegExCompileBase - 44;
+/** support for \P, \p, and \X has not been compiled */
+const TInt KErrRegExCmpSupportForEscapeSeqNotCompiled		= KErrRegExCompileBase - 45;
+/** malformed \P or \p sequence */
+const TInt KErrRegExCmpMalformedBackslashPSeq				= KErrRegExCompileBase - 46;
+/** unknown property name after \P or \p */
+const TInt KErrRegExCmpUnknownPropNameAftBackslashPSeq		= KErrRegExCompileBase - 47;
+/** subpattern name is too long. Default max = 32 chars. See MAX_NAME_SIZE */
+const TInt KErrRegExCmpSubpatternNameTooLong				= KErrRegExCompileBase - 48;
+/** subpattern name is too long. Default max = 10000. See MAX_NAME_COUNT */
+const TInt KErrRegExCmpTooManyNamesSubpatterns				= KErrRegExCompileBase - 49;
+/** repeated subpattern is too long - no longer used */
+const TInt KErrRegExCmpUnused04								= KErrRegExCompileBase - 50;
+/** octal value is greater than \\377 (not in UTF-8 mode) */
+const TInt KErrRegExCmpOctalValueGreatherThan377			= KErrRegExCompileBase - 51;
+/** internal error: overran compiling workspace */
+const TInt KErrRegExCmpOverranCompilingSpace				= KErrRegExCompileBase - 52;
+/** internal error: previously-checked referenced subpattern not found */
+const TInt KErrRegExCmpCheckedSubpatternNotFound			= KErrRegExCompileBase - 53;
+/** DEFINE group contains more than one branch */
+const TInt KErrRegExCmpDefineGroupMoreThanOneBranch			= KErrRegExCompileBase - 54;
+/** repeating a DEFINE group is not allowed */
+const TInt KErrRegExCmpRepeatingDefineGroupNotAllowed		= KErrRegExCompileBase - 55;
+/** inconsistent NEWLINE options */
+const TInt KErrRegExCmpInconsistantNewlineOpts				= KErrRegExCompileBase - 56;
+/** \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number */
+const TInt KErrRegExCmpBackslashGNotFollowed				= KErrRegExCompileBase - 57;
+/** a numbered reference must not be zero */
+const TInt KErrRegExCmpNumberedRefIsZero					= KErrRegExCompileBase - 58;
+/** (*VERB) with an argument is not supported */
+const TInt KErrRegExCmpAsteriskVerbWithArgNotSupported		= KErrRegExCompileBase - 59;
+/** (*VERB) not recognized */
+const TInt KErrRegExCmpAsteriskVerbNotRecog					= KErrRegExCompileBase - 60;
+/** number is too big */
+const TInt KErrRegExCmpNumTooBig							= KErrRegExCompileBase - 61;
+/** subpattern name expected */
+const TInt KErrRegExCmpSubpatternNameExp					= KErrRegExCompileBase - 62;
+/** digit expected after (?+ */
+const TInt KErrRegExCmpDigitExpAftParenthQuestPlus			= KErrRegExCompileBase - 63;
+/** ] is an invalid data character in JavaScript compatibility mode */
+const TInt KErrRegExCloseBracketInvalidInJSCompatMode		= KErrRegExCompileBase - 64;
+
+/** Base offset for RegEx pattern general errors */
+const TInt KErrRegExGeneralBase 							= KErrRegExCompileBase - 512;
+
+/** Zero Matches */
+const TInt KErrRegExZeroMatches								= KErrRegExGeneralBase - 1;
+
+/** Regular expression has fewer capturing groups than number of args passed in */
+const TInt KErrRegExFewerCaptureGroupsThanArgs				= KErrRegExGeneralBase - 2;
+
+/** Failed to parse argument, e.g. the supplied argument does not have enough capacity */
+const TInt KErrRegExFailedToParseArg						= KErrRegExGeneralBase - 3;
+
+/** The modifiable descriptor supplied to recieve output does not have a large enough maximum length */
+const TInt KErrRegExOutputTooBig							= KErrRegExGeneralBase - 4;
+
+/** Invalid rewrite pattern */
+const TInt KErrRegExInvalidRewritePattern					= KErrRegExGeneralBase - 5;
+
+/** Error with one of the backslash substitutions in the supplied rewrite string */
+const TInt KErrRegExBadBackslashSubsitution					= KErrRegExGeneralBase - 6;
+
+// Panic Codes
+_LIT(KRegExPanic, "CRegEx");
+
+/**
+ * Internal CRegEx panics (Debug only)
+ */
+enum TRegExPanic
+	{
+	EInvalidMatchResults,
+	EUnexpectedRetValFromPcre,
+	EVectorTooSmall,
+	EInvalidNumArgs
+	};
+
+/*
+ * Newlines are indicated by a single LF character.
+ * @see KNewLineCr
+ * @see KNewLineCrLf
+ * @see KNewLineAnyCrLf
+ * @see KNewLineAny 
+ */
+static const TInt KNewLineLf = 10;
+/*
+ * Newlines are indicated by a single CR character.
+ * @see KNewLineLf
+ * @see KNewLineCrLf
+ * @see KNewLineAnyCrLf
+ * @see KNewLineAny 
+ */
+static const TInt KNewLineCr = 13;
+
+/* 
+ * Newlines are indicated by the two-character CRLF sequence.
+ * @see KNewLineCr
+ * @see KNewLineLf 
+ * @see KNewLineAnyCrLf
+ * @see KNewLineAny
+ */
+static const TInt KNewLineCrLf = 3338;
+
+/*
+ * Newlines are indicated by any of the following:
+ * - A single CR character.
+ * - A single LF character.
+ * - The two-character CRLF sequence. 
+ * @see KNewLineLf
+ * @see KNewLineCr
+ * @see KNewLineCrLf 
+ * @see KNewLineAny
+ */
+static const TInt KNewLineAnyCrLf = -2;
+
+/*
+ * Newlines are indicated by any Unicode sequence:
+ * - A single CR character.
+ * - A single LF character.
+ * - The two-character CRLF sequence. 
+ * - A single VT character (vertical tab, U+000B).
+ * - A single FF character (formfeed, U+000C).
+ * - A single NEL character (next line, U+0085).
+ * - A single LS character (line separator, U+2028). 
+ * - A single PS character (paragraph separator, U+2029).
+ * The last two are recognized only in UTF-8 mode. 
+ * @see KNewLineLf
+ * @see KNewLineCr
+ * @see KNewLineCrLf
+ * @see KNewLineAnyCrLf
+ */
+static const TInt KNewLineAny = -1;
+
+/**
+ * Symbian C++ interface to the pcre regular-expression library. This class, its
+ * supporting classes and most of the following documentation is largely based
+ * on or taken from the C++ wrapper included with source distributions of PCRE
+ * to which all credit should be given.
+ * 
+ * CRegEx supports
+ * Perl-style regular expressions (with extensions like \d, \w, \s,
+ * ...).
+ *
+ * NOTE: These following examples make liberal use of _L8() purely for clarity
+ * and not because it is recommend. In fact, it is strongly discouraged
+ * in favour of _LIT8() as per the standard Symbian coding conventions.
+ * -----------------------------------------------------------------------
+ * REGEXP SYNTAX:
+ *
+ * This module is part of the pcre library and hence supports its syntax
+ * for regular expressions.
+ *
+ * The syntax is pretty similar to Perl's.  For those not familiar
+ * with Perl's regular expressions, here are some examples of the most
+ * commonly used extensions:
+ *
+ *   "hello (\\w+) world"  -- \w matches a "word" character
+ *   "version (\\d+)"      -- \d matches a digit
+ *   "hello\\s+world"      -- \s matches any whitespace character
+ *   "\\b(\\w+)\\b"        -- \b matches empty string at a word boundary
+ *   "(?i)hello"           -- (?i) turns on case-insensitive matching
+ *
+ * -----------------------------------------------------------------------
+ * MATCHING INTERFACE:
+ *
+ * The FullMatchL() operation checks that supplied text matches a
+ * supplied pattern exactly.
+ *
+ * Example: successful match
+ * @code
+ *    CRegEx* re = CRegEx::NewLC(_L8("h.*o"));
+ *    re->FullMatchL(_L8("hello"));
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * 
+ * Example: unsuccessful match (requires full match):
+ * @code
+ *    CRegEx* re = CRegEx::NewLC(_L8("e"));
+ *    !re->FullMatchL(_L8("hello"));
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ *
+ * -----------------------------------------------------------------------
+ * MATCHING WITH SUB-STRING EXTRACTION:
+ *
+ * You can supply extra pointer arguments to extract matched subpieces.
+ *
+ * Example: extracts "ruby" into "s" and 1234 into "i"
+ * @code
+ *    TInt i;
+ *    TBuf<4> s;
+ *    CRegEx* re = CRegEx::NewLC(_L8("(\\w+):(\\d+)"));
+ *    re->FullMatchL(_L8("ruby:1234"), &s, &i);
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ *
+ * Example: does not try to extract any extra sub-patterns
+ * @code
+ *    re->FullMatchL(_L8("ruby:1234"), &s);
+ * @endcode
+ * 
+ * Example: does not try to extract into NULL
+ * @code
+ *    re->FullMatchL(_L8("ruby:1234"), NULL, &i);
+ * @endcode
+ * 
+ * Example: integer overflow causes failure
+ * @code
+ *    !re.FullMatchL(_L8("ruby:1234567891234"), NULL, &i);
+ * @endcode
+ * 
+ * Example: fails because there aren't enough sub-patterns:
+ * @code
+ *    TBuf<4> s;
+ *    CRegEx* re = CRegEx::NewLC(_L8("\\w+:\\d+"));
+ *    !re->FullMatchL(_L8("ruby:1234"), &s);
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * 
+ * Example: fails because string cannot be stored in integer
+ * @code
+ *    TInt i;
+ *    CRegEx* re = CRegEx::NewLC(_L8("(.*)"));
+ *    !re->FullMatchL(_L8("ruby"), &i);
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode 
+ *
+ * The provided pointer arguments can be pointers to any scalar numeric
+ * type, or one of
+ *    TDes8        (matched piece is copied to descriptor)
+ *    TPtrC8	   (matched piece is pointed to by)
+ *    T            (where "TBool T::ParseFrom(const TDesC8&)" exists)
+ *    NULL         (the corresponding matched sub-pattern is not copied)
+ *
+ * CAVEAT: An optional sub-pattern that does not exist in the matched
+ * string is assigned the empty string.  Therefore, the following will
+ * return false (because the empty string is not a valid number):
+ * @code
+ *    TInt number;
+ *    CRegEx* re = CRegEx::NewLC(_L8("abc"));
+ *    re->FullMatchL(_L8("[a-z]+(\\d+)?"), &number);
+ *    CleanupStack::PopAndDestroy(re); 
+ * @endcode
+ *
+ * -----------------------------------------------------------------------
+ * DO_MATCH
+ *
+ * The matching interface supports at most 4 arguments per call.
+ * If you need more, consider using the more general interface
+ * CRegEx::DoMatchL().
+ *
+ * -----------------------------------------------------------------------
+ * PARTIAL MATCHES
+ *
+ * You can use the PartialMatchL() operation when you want the pattern
+ * to match any substring of the text.
+ *
+ * Example: simple search for a string:
+ * @code
+ *    CRegEx* re = CRegEx::NewLC(_L8("ell"));
+ *    re->PartialMatchL(_L8("hello"));
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * 
+ * Example: find first number in a string:
+ * @code
+ *    TInt number;
+ *    CRegEx* re = CRegEx::NewLC(_L8("(\\d+)"));
+ *    re->PartialMatchL(_L8("x*100 + 20"), &number);
+ *    ASSERT(number == 100);
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ *
+ * -----------------------------------------------------------------------
+ * UTF-8 AND THE MATCHING INTERFACE:
+ *
+ * By default, pattern and text are plain text, one byte per character.
+ * The UTF8 flag, passed to the constructor, causes both pattern
+ * and string to be treated as UTF-8 text, still a byte stream but
+ * potentially multiple bytes per character. In practice, the text
+ * is likelier to be UTF-8 than the pattern, but the match returned
+ * may depend on the UTF8 flag, so always use it when matching
+ * UTF8 text.  E.g., "." will match one byte normally but with UTF8
+ * set may match up to three bytes of a multi-byte character.
+ *
+ * Example:
+ * @code
+ *    TRegExOptions options;
+ *    options.SetUtf8(ETrue);
+ *    CRegEx* re = CRegEx::NewLC(utf8Pattern);
+ *    re->FullMatchL(utf8String);
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * NOTE: The UTF8 option is ignored if libpcre was not compiled with the
+ *       SUPPORT_UTF8 macro.
+ *
+ * -----------------------------------------------------------------------
+ * PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
+ *
+ * SPCRE defines some modifiers to change the behavior of the regular
+ * expression engine.
+ * The C++ wrapper defines an auxiliary class, TRegExOptions, as a vehicle
+ * to pass such modifiers to a CRegEx class.
+ *
+ * Currently, the following modifiers are supported
+ *
+ *    modifier              description               Perl corresponding
+ *
+ *    EPcreCaseless         case insensitive match    /i
+ *    EPcreMultiline        multiple lines match      /m
+ *    EPcreDotAll           dot matches newlines      /s
+ *    EPcreDollarEndOnly    $ matches only at end     N/A
+ *    EPcreExtra            strict escape parsing     N/A
+ *    EPcreExtended         ignore whitespaces        /x
+ *    EPcreUtf8             handles UTF8 chars        built-in
+ *    EPcreUngreedy         reverses * and *?         N/A
+ *    EPcreNoAutoCapture    disables matching parens  N/A (*)
+ *
+ * (For a full account on how each modifier works, please check the
+ * PCRE API reference manual).
+ *
+ * (*) Both Perl and PCRE allow non matching parentheses by means of the
+ * "?:" modifier within the pattern itself. e.g. (?:ab|cd) does not
+ * capture, while (ab|cd) does.
+ *
+ * For each modifier, there are two member functions whose name is made
+ * out of the modifier , without the "EPcre" prefix. For
+ * instance, EPcreCaseless is handled by
+ *    TBool Caseless(),
+ * which returns ETrue if the modifier is set, and
+ *    TRegExOptions SetCaseless(TBool),
+ * which sets or unsets the modifier.
+ *
+ * Moreover, PCRE_EXTRA_MATCH_LIMIT can be accessed through the
+ * SetMatchLimit() and MatchLimit() member functions.
+ * Setting the match limit to a non-zero value will limit the executation of
+ * SPCRE to keep it from doing bad things like blowing the stack or taking
+ * an eternity to return a result.  A value of 5000 is good enough to stop
+ * stack blowup in a 2MB thread stack.  Setting MathLimit to zero will
+ * disable match limiting.  Alternately, you can set MatchLimitRecursion()
+ * which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much SPCRE
+ * recurses.  MatchLimit() caps the number of matches pcre does;
+ * MatchLimitRecursion() caps the depth of recursion.
+ *
+ * Normally, to pass one or more modifiers to a CRegEx class, you declare
+ * a TRegExOptions object, set the appropriate options, and pass this
+ * object to a CRegEx constructor. Example:
+ *
+ * @code
+ *    TRegExOptions opt;
+ *    opt.setCaseless(ETrue);
+ *    CRegEx* re = CRegEx::NewLC(_L8("HELLO"), opt);
+ *    if(re->PartialMatchL(_L8("hello world"))) ...
+ * @endcode
+ *
+ * -----------------------------------------------------------------------
+ * SCANNING TEXT INCREMENTALLY
+ *
+ * The ConsumeL() operation may be useful if you want to repeatedly
+ * match regular expressions at the front of a string and skip over
+ * them as they match.  This requires use of the "StringPiece" type,
+ * which represents a sub-range of a real string.  Like RE, StringPiece
+ * is defined in the pcrecpp namespace.
+ *
+ * Example: read lines of the form "var = value" from a string.
+ * @code
+ *    TBuf8<KContentLength> contents;
+ *    // fill contents somehow
+ *    TBuf8<KMaxVarLength> var;
+ *    TInt value;
+ *    CRegEx* re = CRegEx::NewLC(_L8("(\\w+) = (\\d+)\n"));
+ *    while(re->ConsumeL(contents, &var, &value))
+ *    	{
+ *    	...
+ *    	}
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * 
+ * Each successful call to ConsumeL will set "var/value", and also
+ * advance "contents" so it points past the matched text.
+ *
+ * The FindAndConsumeL() operation is similar to ConsumeL() but does not
+ * anchor your match at the beginning of the string.  For example, you
+ * could extract all words from a string by repeatedly calling
+ * @code
+ *    TBuf8<KContentLength> contents;
+ *    // fill contents somehow
+ *    TBuf8<KMaxWordLength> word;
+ *    TInt value;
+ *    CRegEx* re = CRegEx::NewLC(_L8("(\\w+)"));
+ *    while(re->FindAndConsumeL(contents, &word))
+ *    	{
+ *    	...
+ *    	}
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * -----------------------------------------------------------------------
+ * PARSING HEX/OCTAL NUMBERS
+ *
+ * By default, if you pass a pointer to a numeric value, the
+ * corresponding text is interpreted as a base-10 number.  You can
+ * instead wrap the pointer with a call to one of the operators Hex(),
+ * or Octal() to interpret the text in another base.  
+ *
+ * Example:
+ * @code
+ *    TInt a, b;
+ *    CRegEx* re = CRegEx::NewLC(_L8("(.*) (.*)"));
+ *    re->FullMatchL(_L8("100 40"), Hex(&a), Octal(&b));
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * will leave 64 in a and b.
+ *
+ * -----------------------------------------------------------------------
+ * REPLACING PARTS OF STRINGS
+ *
+ * You can replace the first match of aPattern in aString with
+ * aRewrite.  Within aRewrite, backslash-escaped digits (\1 to \9)
+ * can be used to insert text matching corresponding parenthesized
+ * group from the pattern.  \0 in aRewrite refers to the entire
+ * matching text.  E.g.,
+ * @code
+ *    _LIT8(KYabbaDabbaDoo, "yabba dabba doo"); 
+ *    TBuf8<20> s;
+ *    CRegEx* re = CRegEx::NewLC(_L8("b+");
+ *    re->ReplaceL(KYabbaDabbaDoo(), s);
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * will leave "s" containing "yada dabba doo".  The result is ETrue if
+ * the pattern matches and a replacement occurs, or Efalse otherwise.
+ *
+ * GlobalReplaceL() is like Replace:(), except that it replaces all
+ * occurrences of the pattern in the string with the rewrite.
+ * Replacements are not subject to re-matching.  E.g.,
+ * @code
+ *    _LIT8(KYabbaDabbaDoo, "yabba dabba doo"); 
+ *    TBuf8<20> s;
+ *    CRegEx* re = CRegEx::NewLC(_L8("b+");
+ *    re->GlobalReplaceL(_L8("d"), s);
+ *    CleanupStack::PopAndDestroy(re);
+ * @endcode
+ * will leave "s" containing "yada dada doo".  It returns the number
+ * of replacements made.
+ *
+ * ExtractL() is like Replace(), except that if the pattern matches,
+ * aRewrite is copied into aOut (an additional argument) with
+ * substitutions.  The non-matching portions of aText are ignored.
+ * Returns ETrue if a match occurred and the extraction happened
+ * successfully.  If no match occurs, the string is left unaffected.
+ */
+class CRegEx : public CBase
+	{
+public:
+	// Type of match (TODO: Should be restructured as part of TRegExOptions)
+	enum TAnchor
+		{
+		EUnanchored,		/** No anchoring */
+		EAnchorStart,		/** Anchor at start only */
+		EAnchorBoth			/** Anchor at start and end */
+		};
+	
+public:
+	IMPORT_C static CRegEx* NewL(const TDesC8& aPattern);
+	IMPORT_C static CRegEx* NewL(const TDesC8& aPattern, const TRegExOptions& aOptions);
+	IMPORT_C static CRegEx* NewLC(const TDesC8& aPattern);
+	IMPORT_C static CRegEx* NewLC(const TDesC8& aPattern, const TRegExOptions& aOptions);
+
+	IMPORT_C static CRegEx* NewL(const TDesC16& aPattern, const TRegExOptions& aOptions);
+	
+	IMPORT_C ~CRegEx();
+	
+	inline const TDesC8& Pattern() const;
+	inline TInt Error() const;
+
+	IMPORT_C TBool FullMatchL(const TDesC8& aText) const;
+	
+	IMPORT_C TBool FullMatchL(const TDesC8& aText,
+			  const TRegExArg& aArg1) const;
+	
+	IMPORT_C TBool FullMatchL(const TDesC8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2) const;
+	
+	IMPORT_C TBool FullMatchL(const TDesC8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3) const;
+	
+	IMPORT_C TBool FullMatchL(const TDesC8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3,
+			  const TRegExArg& aArg4) const;	
+	
+	IMPORT_C TBool PartialMatchL(const TDesC8& aText) const;
+	
+	IMPORT_C TBool PartialMatchL(const TDesC8& aText,
+			  const TRegExArg& aArg1) const;
+	
+	IMPORT_C TBool PartialMatchL(const TDesC8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2) const;
+	
+	IMPORT_C TBool PartialMatchL(const TDesC8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3) const;
+	
+	IMPORT_C TBool PartialMatchL(const TDesC8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3,
+			  const TRegExArg& aArg4) const;
+	
+	IMPORT_C TBool DoMatchL(const TDesC8& aText,
+			  TAnchor aAnchor,
+			  TInt&	aConsumed) const;
+	
+	IMPORT_C TBool DoMatchL(const TDesC8& aText,
+			  TAnchor aAnchor,
+			  TInt&	aConsumed,
+			  const TRegExArg& aArg1) const;
+	
+	IMPORT_C TBool DoMatchL(const TDesC8& aText,
+			  TAnchor aAnchor,
+			  TInt&	aConsumed,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2) const;
+	
+	IMPORT_C TBool DoMatchL(const TDesC8& aText,
+			  TAnchor aAnchor,
+			  TInt&	aConsumed,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3) const;
+	
+	IMPORT_C TBool DoMatchL(const TDesC8& aText,
+			  TAnchor aAnchor,
+			  TInt&	aConsumed,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3,
+			  const TRegExArg& aArg4) const;
+	
+	IMPORT_C TBool DoMatchL(const TDesC8& aText,
+			  TAnchor aAnchor,
+			  TInt&	aConsumed,			
+			  const RPointerArray<const TRegExArg>& aArgs) const;
+	
+	
+	IMPORT_C TBool ConsumeL(TDes8& aText) const;
+	
+	IMPORT_C TBool ConsumeL(TDes8& aText,
+			  const TRegExArg& aArg1) const;
+	
+	IMPORT_C TBool ConsumeL(TDes8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2) const;
+	
+	IMPORT_C TBool ConsumeL(TDes8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3) const;
+	
+	IMPORT_C TBool ConsumeL(TDes8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3,
+			  const TRegExArg& aArg4) const;
+	
+	IMPORT_C TBool FindAndConsumeL(TDes8& aText) const;
+	
+	IMPORT_C TBool FindAndConsumeL(TDes8& aText,
+			  const TRegExArg& aArg1) const;
+	
+	IMPORT_C TBool FindAndConsumeL(TDes8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2) const;
+	
+	IMPORT_C TBool FindAndConsumeL(TDes8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3) const;
+	
+	IMPORT_C TBool FindAndConsumeL(TDes8& aText,
+			  const TRegExArg& aArg1,
+			  const TRegExArg& aArg2,
+			  const TRegExArg& aArg3,
+			  const TRegExArg& aArg4) const;
+	
+	IMPORT_C TBool ReplaceL(const TDesC8& aRewrite, TDes8& aString) const;
+	
+	IMPORT_C TInt GlobalReplaceL(const TDesC8& aRewrite, TDes8& aString) const;
+	
+	IMPORT_C TBool ExtractL(const TDesC8& aRewrite, const TDesC8& aText, TDes8& aOut) const;
+
+	IMPORT_C static TInt NewlineMode(TInt aOptions);
+	
+	IMPORT_C static HBufC8* QuoteMetaL(const TDesC8& aUnquoted);
+
+	IMPORT_C TInt NumberOfCapturingGroups() const;
+	
+	IMPORT_C void Study();	
+
+private:
+	CRegEx();
+	CRegEx(const TRegExOptions& aOptions);
+	
+	void ConstructL(const TDesC8& aPattern);
+	void ConstructL(const TDesC16& aPattern);
+	void CommonConstructL();
+	
+	pcre* CompileL(TAnchor anchor);
+	void Cleanup();
+
+	TInt TryMatch(const TDesC8& aText,
+			   TInt aStartPos,
+			   TAnchor aAnchor,
+			   TInt* aVector,
+			   TInt aVectorSize) const;
+	
+
+	TBool Rewrite(TDes8& aOut,
+			   const TDesC8& aRewrite,
+			   const TDesC8& aText,
+			   TInt* aVector,
+			   TInt aVectorSize,
+			   TInt aMatches) const;
+	
+	TBool DoMatchImpl(const TDesC8& aText,
+				   TAnchor aAnchor,
+				   TInt& aConsumed,
+				   const RPointerArray<const TRegExArg>& aArgs,
+				   TInt* aVector,
+				   TInt aVectorSize) const;
+	
+
+	static void Panic(TRegExPanic aPanic);
+
+	mutable TInt					iErrorCode;		// Error code for the alst unsuccessful operation.
+	TInt							iErrorOffset;	// Offset in pattern where error was detected
+	HBufC8*							iPattern;		// Regular expression pattern
+	TRegExOptions					iOptions;		// Options used to compile RE pattern.
+	pcre*							iReFull;		// For full matches
+	pcre*							iRePartial;		// For partial matches
+	pcre_extra*						iExtraPartial;	// Study Data for iRePartial
+	TRegExArg*						iNoArg;			// Default argument
+	};
+	
+#include <cregex.inl>
+#endif /* CREGEX_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/inc/cregex.inl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,55 @@
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+
+// Heavily refactored for Symbian OS by Accenture.
+
+#ifndef CREGEX_INL_
+#define CREGEX_INL_
+
+	/**
+	 *  The string specification for this regular expression.
+	 *  @return aPattern the string specification for this regular expression.
+	 */
+	inline const TDesC8& CRegEx::Pattern() const
+		{
+		return *iPattern;
+		}
+	
+	/*
+	 * The error code for the last unsuccsessful operation.
+	 * @return the error code for the last unsuccsessful operation.
+	 */
+	inline TInt CRegEx::Error() const
+		{
+		return iErrorCode;
+		}
+#endif /* CREGEX_INL_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/inc/tregexarg.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,123 @@
+// tregexarg.h
+//
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// Heavily refactored for Symbian OS by Accenture.
+
+#ifndef TREGEXARG_H_
+#define TREGEXARG_H_
+
+#include <e32base.h>
+
+class TRegExArg
+	{
+ public:
+	 // Empty constructor so we can declare arrays of TRegExArg
+	  TRegExArg();
+
+	 // Constructor specially designed for NULL arguments
+	 inline TRegExArg(TAny*);
+
+	 typedef TBool (*Parser)(const TDesC8& aString, TAny* aDestination);
+	 
+// Type-specific parsers
+#define PCRE_MAKE_PARSER(type,name)															\
+	IMPORT_C TRegExArg(type* aType) : iArg(aType), iParser(name) { }						\
+	IMPORT_C TRegExArg(type* aType, Parser aParser) : iArg(aType), iParser(aParser) { }	
+	
+	PCRE_MAKE_PARSER(TChar,				ParseTChar)
+	PCRE_MAKE_PARSER(TInt8,				ParseTInt8)
+	PCRE_MAKE_PARSER(TInt16,			ParseTInt16)
+	PCRE_MAKE_PARSER(TInt32,			ParseTInt32)
+	PCRE_MAKE_PARSER(TInt64,			ParseTInt64)
+	PCRE_MAKE_PARSER(TInt,				ParseTInt)
+	PCRE_MAKE_PARSER(TUint8,			ParseTUint8)
+	PCRE_MAKE_PARSER(TUint16,			ParseTUint16)
+	PCRE_MAKE_PARSER(TUint32,			ParseTUint32)
+	PCRE_MAKE_PARSER(TUint,				ParseTUint)
+	PCRE_MAKE_PARSER(TReal32,			ParseTReal32)
+	PCRE_MAKE_PARSER(TReal64,			ParseTReal64)
+	PCRE_MAKE_PARSER(TDes8,				ParseTDes8)
+	PCRE_MAKE_PARSER(TPtrC8,			ParseTPtrC8)
+	
+	#undef PCRE_MAKE_PARSER
+
+	// Generic constructors
+	template <class T> inline TRegExArg(T*, Parser aParser);
+	template <class T> inline TRegExArg(T* aArg);	
+	
+	// TBuf constructors - cannot seem to nest the template parameters
+	template <TInt S>
+	inline TRegExArg(TBuf8<S>* aArg, Parser aParser);
+	template <TInt S>
+	inline TRegExArg(TBuf8<S>* aArg);
+	
+	// Parse the data
+	inline TBool Parse(const TDesC8& aString) const;
+
+private:
+	TAny*         iArg;
+	Parser        iParser; // Pointer to parsing function
+	
+	IMPORT_C static TBool ParseNull			(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTChar		(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTInt8		(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTInt16		(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTInt32		(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTInt			(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTReal32		(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTReal64		(const TDesC8& aString, TAny* aDestination); 
+	IMPORT_C static TBool ParseTDes8		(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTDes16		(const TDesC8& aString, TAny* aDestination);
+	IMPORT_C static TBool ParseTPtrC8		(const TDesC8& aString, TAny* aDestination);
+
+#define PCRE_DECLARE_INTEGER_PARSER(name)															\
+private:																							\
+	IMPORT_C static TBool Parse ## name(const TDesC8& aString, TAny* aDestination);					\
+	IMPORT_C static TBool Parse ## name ## Radix(													\
+				const TDesC8& aString, TAny* aDestination, TRadix aRadix);							\
+public:																								\
+	IMPORT_C static TBool Parse ## name ## Hex(const TDesC8& aString, TAny* aDestination);			\
+	IMPORT_C static TBool Parse ## name ## Octal(const TDesC8& aString, TAny* aDestination);		\
+
+	PCRE_DECLARE_INTEGER_PARSER(TInt64)
+	PCRE_DECLARE_INTEGER_PARSER(TUint8)
+	PCRE_DECLARE_INTEGER_PARSER(TUint16)
+	PCRE_DECLARE_INTEGER_PARSER(TUint32)
+	PCRE_DECLARE_INTEGER_PARSER(TUint)	
+
+#undef PCRE_DECLARE_INTEGER_PARSER
+	};
+
+#include "tregexarg.inl"
+
+#endif /* TREGEXARG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/inc/tregexarg.inl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,91 @@
+// tregexarg.inl
+//
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// Heavily refactored for Symbian OS by Accenture.
+
+#ifndef TREGEXARG_INL_
+#define TREGEXARG_INL_
+
+template <class T>
+class TRegExMatchObject {
+ public:
+  static inline TBool Parse(const TDesC8& aString, TAny* aDestination) {
+    if (aDestination == NULL) return ETrue;
+    T* object = reinterpret_cast<T*>(aDestination);
+    return object->ParseFrom(aString);
+  }
+};
+
+template <class T>
+inline TRegExArg::TRegExArg(T* aArg)
+		: iArg(aArg), iParser(TRegExMatchObject<T>::Parse)
+		{}	
+
+template <TInt S>
+/*inline TRegExArg::TRegExArg(TBuf8<S>* aArg, Parser aParser)
+	: iArg(aArg), iParser(aParser)
+	{}
+*/
+//template <TInt S>
+inline TRegExArg::TRegExArg(TBuf8<S>* aArg)
+	: iArg(aArg), iParser(ParseNull)
+	{}
+
+
+inline TRegExArg::TRegExArg() : iArg(NULL), iParser(ParseNull) { }
+
+inline TRegExArg::TRegExArg(TAny* aArg) : iArg(aArg), iParser(ParseNull) { }
+
+inline TBool TRegExArg::Parse(const TDesC8& aString) const
+	{
+	return (*iParser)(aString, iArg);
+	}	
+
+
+
+// This part of the parser, appropriate only for ints, deals with bases
+#define MAKE_INTEGER_PARSER(type)		 							\
+inline TRegExArg Hex(type* aType) { 								\
+    return TRegExArg(aType, TRegExArg::Parse ## type ## Hex); }		\
+inline TRegExArg Octal(type* aType) {								\
+    return TRegExArg(aType, TRegExArg::Parse ## type ## Octal); }
+
+MAKE_INTEGER_PARSER(TInt64)
+MAKE_INTEGER_PARSER(TUint8)
+MAKE_INTEGER_PARSER(TUint16)
+MAKE_INTEGER_PARSER(TUint32)
+MAKE_INTEGER_PARSER(TUint)
+
+#undef MAKE_INTEGER_PARSER
+
+#endif /* TREGEXARG_INL_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/inc/tregexoptions.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,113 @@
+// tregexoptions.h
+//
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// Heavily refactored for Symbian OS by Accenture.
+
+#ifndef TREGEXOPTIONS_H_
+#define TREGEXOPTIONS_H_
+
+#include <e32base.h>
+
+enum TRegExOptionFlags
+	{
+	EPcreCaseless 			= 0x00000001,
+	EPcreMultiline 			= 0x00000002,
+	EPcreDotAll 			= 0x00000004,
+	EPcreExtended 			= 0x00000008,
+	EPcreAnchored 			= 0x00000010,
+	EPcreDollarEndOnly 		= 0x00000020,
+	EPcreExtra 				= 0x00000040,
+	EPcreNotBol 			= 0x00000080,
+	EPcreNotEol 			= 0x00000100,
+	EPcreUngreedy 			= 0x00000200,
+	EPcreNotEmpty 			= 0x00000400,
+	EPcreUtf8 				= 0x00000800,
+	EPcreNoAutoCapture		= 0x00001000,
+	EPcreNoUtf8Check 		= 0x00002000,
+	EPcreAutoCallout 		= 0x00004000,
+	EPcrePartial 			= 0x00008000,
+	EPcreDfaShortest 		= 0x00010000,
+	EPcreDfaRestart 		= 0x00020000,
+	EPcreFirstline 			= 0x00040000,
+	EPcreDupnames 			= 0x00080000,
+	EPcreNewlineCr 			= 0x00100000,
+	EPcreNewlineLf 			= 0x00200000,
+	EPcreNewlineCrLf 		= 0x00300000,
+	EPcreNewlineAny			= 0x00400000,
+	EPcreNewlineAnyCrLf 	= 0x00500000,
+	EPcreBsrAnyCrLf 		= 0x00800000,
+	EPcreBsrUnicode 		= 0x01000000,
+	EPcreJavascriptCompat 	= 0x02000000
+	};
+
+class TRegExOptions
+	{
+public:
+	IMPORT_C TRegExOptions();
+	IMPORT_C TRegExOptions(TUint aOptionFlags);
+	
+	// Getters / Setters
+	inline TInt MatchLimit() const;
+	inline TRegExOptions SetMatchLimit(TInt aLimit);
+	inline TInt MatchLimitRecursion() const;
+	inline TRegExOptions SetMatchLimitRecursion(TInt aLimit);
+	inline TInt AllOptions() const;
+	inline TRegExOptions SetAllOptions(TInt aOptions);
+	
+	inline TBool Caseless() const;
+	inline TRegExOptions SetCaseless(TBool aCaseLess);
+	inline TBool Multiline() const;
+	inline TRegExOptions SetMultiline(TBool aMultiline);
+	inline TBool DotAll() const;
+	inline TRegExOptions SetDotAll(TBool aDotAll);
+	inline TBool Extended() const;
+	inline TRegExOptions SetExtended(TBool aExtended);
+	inline TBool DollarEndOnly() const;
+	inline TRegExOptions SetDollarEndOnly(TBool aDollarEndOnly);
+	inline TBool Extra() const;
+	inline TRegExOptions SetExtra(TBool aSetExtra);
+	inline TBool Ungreedy() const;
+	inline TRegExOptions SetUngreedy(TBool aUngreedy);
+	inline TBool Utf8() const;
+	inline TRegExOptions SetUtf8(TBool aUtf8);
+	inline TBool NoAutoCapture() const;
+	inline TRegExOptions SetNoAutoCapture(TBool aAutoCapture);
+	
+private:
+	  TInt iMatchLimit;
+	  TInt iMatchLimitRecursion;
+	  TUint iAllOptions;
+	};
+
+#include "tregexoptions.inl"
+#endif /* TREGEXOPTIONS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/inc/tregexoptions.inl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,179 @@
+// tregexoptions.inl
+//
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// Heavily refactored for Symbian OS by Accenture.
+
+#ifndef TREGEXOPTIONS_INL_
+#define TREGEXOPTIONS_INL_
+
+#define PCRE_SET_OR_CLEAR(b, o) \
+    if (b) iAllOptions |= (o); else iAllOptions &= ~(o);
+
+#define PCRE_IS_SET(o)  \
+        (iAllOptions & o) == o
+
+inline TInt TRegExOptions::MatchLimit() const
+	{
+	return iMatchLimit;
+	}
+
+inline TRegExOptions TRegExOptions::SetMatchLimit(TInt aLimit)
+	{
+	iMatchLimit = aLimit;
+	return *this;
+	}
+
+inline TInt TRegExOptions::MatchLimitRecursion() const
+	{
+	return iMatchLimitRecursion;
+	}
+
+inline TRegExOptions TRegExOptions::SetMatchLimitRecursion(TInt aLimit)
+	{
+	iMatchLimitRecursion = aLimit;
+	return *this;
+	}
+
+inline TInt TRegExOptions::AllOptions() const
+	{
+	return iAllOptions;
+	}
+
+inline TRegExOptions TRegExOptions::SetAllOptions(TInt aOptions)
+	{
+	iAllOptions = aOptions;
+	return *this;
+	}
+	
+inline TBool TRegExOptions::Caseless() const
+	{
+	return PCRE_IS_SET(EPcreCaseless);
+	}
+
+inline TRegExOptions TRegExOptions::SetCaseless(TBool aCaseLess)
+	{
+	PCRE_SET_OR_CLEAR(aCaseLess, EPcreCaseless);
+	return *this;
+	}
+
+inline TBool TRegExOptions::Multiline() const
+	{
+	return PCRE_IS_SET(EPcreMultiline);
+	}
+
+inline TRegExOptions TRegExOptions::SetMultiline(TBool aMultiline)
+	{
+	PCRE_SET_OR_CLEAR(aMultiline, EPcreMultiline);
+	return *this;
+	}
+
+inline TBool TRegExOptions::DotAll() const
+	{
+	return PCRE_IS_SET(EPcreDotAll);
+	}
+
+inline TRegExOptions TRegExOptions::SetDotAll(TBool aDotAll)
+	{
+	PCRE_SET_OR_CLEAR(aDotAll, EPcreDotAll);
+	return *this;
+	}
+
+inline TBool TRegExOptions::Extended() const
+	{
+	return PCRE_IS_SET(EPcreExtended);
+	}
+
+inline TRegExOptions TRegExOptions::SetExtended(TBool aExtended)
+	{
+	PCRE_SET_OR_CLEAR(aExtended, EPcreExtended);
+	return *this;
+	}
+
+inline TBool TRegExOptions::DollarEndOnly() const
+	{
+	return PCRE_IS_SET(EPcreDollarEndOnly);
+	}
+
+inline TRegExOptions TRegExOptions::SetDollarEndOnly(TBool aDollarEndOnly)
+	{
+	PCRE_SET_OR_CLEAR(aDollarEndOnly, EPcreDollarEndOnly);
+	return *this;
+	}
+
+inline TBool TRegExOptions::Extra() const
+	{
+	return PCRE_IS_SET(EPcreExtra);
+	}
+
+inline TRegExOptions TRegExOptions::SetExtra(TBool aSetExtra)
+	{
+	PCRE_SET_OR_CLEAR(aSetExtra, EPcreExtra);
+	return *this;
+	}
+
+inline TBool TRegExOptions::Ungreedy() const
+	{
+	return PCRE_IS_SET(EPcreUngreedy);
+	}
+
+inline TRegExOptions TRegExOptions::SetUngreedy(TBool aUngreedy)
+	{
+	PCRE_SET_OR_CLEAR(aUngreedy, EPcreUngreedy);
+	return *this;
+	}
+
+inline TBool TRegExOptions::Utf8() const
+	{
+	return PCRE_IS_SET(EPcreUtf8);
+	}
+
+inline TRegExOptions TRegExOptions::SetUtf8(TBool aUtf8)
+	{
+	PCRE_SET_OR_CLEAR(aUtf8, EPcreUtf8);
+	return *this;
+	}
+
+inline TBool TRegExOptions::NoAutoCapture() const
+	{
+	return PCRE_IS_SET(EPcreNoAutoCapture);
+	}
+
+inline TRegExOptions TRegExOptions::SetNoAutoCapture(TBool aAutoCapture)
+	{
+	PCRE_SET_OR_CLEAR(aAutoCapture, EPcreNoAutoCapture);
+	return *this;
+	}
+
+#undef PCRE_IS_SET
+#undef PCRE_SET_OR_CLEAR
+#endif /* TREGEXOPTIONS_INL_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/bwins/libpcreu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+EXPORTS
+	pcre_callout @ 1 NONAME
+	pcre_compile @ 2 NONAME
+	pcre_compile2 @ 3 NONAME
+	pcre_config @ 4 NONAME
+	pcre_exec @ 5 NONAME
+	pcre_free @ 6 NONAME
+	pcre_fullinfo @ 7 NONAME
+	pcre_info @ 8 NONAME
+	pcre_malloc @ 9 NONAME
+	pcre_stack_free @ 10 NONAME
+	pcre_stack_malloc @ 11 NONAME
+	pcre_study @ 12 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/eabi/libpcreu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,14 @@
+EXPORTS
+	pcre_callout @ 1 NONAME
+	pcre_compile @ 2 NONAME
+	pcre_compile2 @ 3 NONAME
+	pcre_config @ 4 NONAME
+	pcre_exec @ 5 NONAME
+	pcre_free @ 6 NONAME
+	pcre_fullinfo @ 7 NONAME
+	pcre_info @ 8 NONAME
+	pcre_malloc @ 9 NONAME
+	pcre_stack_free @ 10 NONAME
+	pcre_stack_malloc @ 11 NONAME
+	pcre_study @ 12 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// bld.inf
+//
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+libpcre.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/group/libpcre.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,64 @@
+// libpcre.mmp
+//
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+#include <fshell/common.mmh>
+
+target          libpcre.dll
+targettype      dll
+uid		        0x1000008d FSHELL_UID_LIBPCRE
+
+capability	    FSHELL_CAP_MMP_NORMAL
+
+macro 		    HAVE_CONFIG_H
+
+systeminclude   \epoc32\include \epoc32\include\libc
+userinclude     ..\inc
+userinclude     ..\pcre
+
+sourcepath      ..\src
+source          pcredllmain.cpp pcre_chartables.c
+
+sourcepath      ..\pcre 
+source          pcre_compile.c
+source          pcre_config.c
+source          pcre_exec.c
+source          pcre_fullinfo.c
+source          pcre_info.c
+source          pcre_newline.c
+source          pcre_ord2utf8.c
+source          pcre_tables.c
+source          pcre_try_flipped.c
+source          pcre_ucd.c
+source          pcre_valid_utf8.c
+source          pcre_xclass.c
+source          pcre_study.c
+
+library         euser.lib
+library         estlib.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/inc/config.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,318 @@
+#include <e32def.h>
+#ifndef _PCRE_CONFIG_H
+#define _PCRE_CONFIG_H
+
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+
+/* On Unix-like systems config.h.in is converted by "configure" into config.h.
+Some other environments also support the use of "configure". PCRE is written in
+Standard C, but there are a few non-standard things it can cope with, allowing
+it to run on SunOS4 and other "close to standard" systems.
+
+If you are going to build PCRE "by hand" on a system without "configure" you
+should copy the distributed config.h.generic to config.h, and then set up the
+macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to
+all of your compile commands, so that config.h is included at the start of
+every source.
+
+Alternatively, you can avoid editing by using -D on the compiler command line
+to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H.
+
+PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
+HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
+them both to 0; an emulation function will be used. */
+
+/* By default, the \R escape sequence matches any Unicode line ending
+   character or sequence of characters. If BSR_ANYCRLF is defined, this is
+   changed so that backslash-R matches only CR, LF, or CRLF. The build- time
+   default can be overridden by the user of PCRE at runtime. On systems that
+   support it, "configure" can be used to override the default. */
+/* #undef BSR_ANYCRLF */
+
+/* If you are compiling for a system that uses EBCDIC instead of ASCII
+   character codes, define this macro as 1. On systems that can use
+   "configure", this can be done via --enable-ebcdic. */
+/* #undef EBCDIC */
+
+/* Define to 1 if you have the `bcopy' function. */
+#ifndef HAVE_BCOPY
+#define HAVE_BCOPY 1
+#endif
+
+/* Define to 1 if you have the <bits/type_traits.h> header file. */
+/* #undef HAVE_BITS_TYPE_TRAITS_H */
+
+/* Define to 1 if you have the <bzlib.h> header file. */
+#ifndef HAVE_BZLIB_H
+#define HAVE_BZLIB_H 0
+#endif
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#ifndef HAVE_DIRENT_H
+#define HAVE_DIRENT_H 0
+#endif
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#ifndef HAVE_DLFCN_H
+#define HAVE_DLFCN_H 0
+#endif
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#ifndef HAVE_INTTYPES_H
+#define HAVE_INTTYPES_H 0
+#endif
+
+/* Define to 1 if you have the <limits.h> header file. */
+#ifndef HAVE_LIMITS_H
+#define HAVE_LIMITS_H 1
+#endif
+
+/* Define to 1 if the system has the type `long long'. */
+#ifndef HAVE_LONG_LONG
+#define HAVE_LONG_LONG 1
+#endif
+
+/* Define to 1 if you have the `memmove' function. */
+#ifndef HAVE_MEMMOVE
+#define HAVE_MEMMOVE 1
+#endif
+
+/* Define to 1 if you have the <memory.h> header file. */
+#ifndef HAVE_MEMORY_H
+#define HAVE_MEMORY_H 0
+#endif
+
+/* Define to 1 if you have the <readline/history.h> header file. */
+#ifndef HAVE_READLINE_HISTORY_H
+#define HAVE_READLINE_HISTORY_H 0
+#endif
+
+/* Define to 1 if you have the <readline/readline.h> header file. */
+#ifndef HAVE_READLINE_READLINE_H
+#define HAVE_READLINE_READLINE_H 0
+#endif
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H 0
+#endif
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#ifndef HAVE_STDLIB_H
+#define HAVE_STDLIB_H 1
+#endif
+
+/* Define to 1 if you have the `strerror' function. */
+#ifndef HAVE_STRERROR
+#define HAVE_STRERROR 1
+#endif
+
+/* Define to 1 if you have the <string> header file. */
+#ifndef HAVE_STRING
+#define HAVE_STRING 1
+#endif
+
+/* Define to 1 if you have the <strings.h> header file. */
+#ifndef HAVE_STRINGS_H
+#define HAVE_STRINGS_H 0
+#endif
+
+/* Define to 1 if you have the <string.h> header file. */
+#ifndef HAVE_STRING_H
+#define HAVE_STRING_H 1
+#endif
+
+/* Define to 1 if you have the `strtoll' function. */
+/* #undef HAVE_STRTOLL */
+
+/* Define to 1 if you have the `strtoq' function. */
+#ifndef HAVE_STRTOQ
+#define HAVE_STRTOQ 1
+#endif
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#ifndef HAVE_SYS_STAT_H
+#define HAVE_SYS_STAT_H 1
+#endif
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#ifndef HAVE_SYS_TYPES_H
+#define HAVE_SYS_TYPES_H 1
+#endif
+
+/* Define to 1 if you have the <type_traits.h> header file. */
+/* #undef HAVE_TYPE_TRAITS_H */
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#ifndef HAVE_UNISTD_H
+#define HAVE_UNISTD_H 1
+#endif
+
+/* Define to 1 if the system has the type `unsigned long long'. */
+#ifndef HAVE_UNSIGNED_LONG_LONG
+#define HAVE_UNSIGNED_LONG_LONG 1
+#endif
+
+/* Define to 1 if you have the <windows.h> header file. */
+/* #undef HAVE_WINDOWS_H */
+
+/* Define to 1 if you have the <zlib.h> header file. */
+#ifndef HAVE_ZLIB_H
+#define HAVE_ZLIB_H 0
+#endif
+
+/* Define to 1 if you have the `_strtoi64' function. */
+/* #undef HAVE__STRTOI64 */
+
+/* The value of LINK_SIZE determines the number of bytes used to store links
+   as offsets within the compiled regex. The default is 2, which allows for
+   compiled patterns up to 64K long. This covers the vast majority of cases.
+   However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows
+   for longer patterns in extreme cases. On systems that support it,
+   "configure" can be used to override this default. */
+#ifndef LINK_SIZE
+#define LINK_SIZE 2
+#endif
+
+/* The value of MATCH_LIMIT determines the default number of times the
+   internal match() function can be called during a single execution of
+   pcre_exec(). There is a runtime interface for setting a different limit.
+   The limit exists in order to catch runaway regular expressions that take
+   for ever to determine that they do not match. The default is set very large
+   so that it does not accidentally catch legitimate cases. On systems that
+   support it, "configure" can be used to override this default default. */
+#ifndef MATCH_LIMIT
+#define MATCH_LIMIT 10000000
+#endif
+
+/* The above limit applies to all calls of match(), whether or not they
+   increase the recursion depth. In some environments it is desirable to limit
+   the depth of recursive calls of match() more strictly, in order to restrict
+   the maximum amount of stack (or heap, if NO_RECURSE is defined) that is
+   used. The value of MATCH_LIMIT_RECURSION applies only to recursive calls of
+   match(). To have any useful effect, it must be less than the value of
+   MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT. There is
+   a runtime method for setting a different limit. On systems that support it,
+   "configure" can be used to override the default. */
+#ifndef MATCH_LIMIT_RECURSION
+#define MATCH_LIMIT_RECURSION MATCH_LIMIT
+#endif
+
+/* This limit is parameterized just in case anybody ever wants to change it.
+   Care must be taken if it is increased, because it guards against integer
+   overflow caused by enormously large patterns. */
+#ifndef MAX_NAME_COUNT
+#define MAX_NAME_COUNT 10000
+#endif
+
+/* This limit is parameterized just in case anybody ever wants to change it.
+   Care must be taken if it is increased, because it guards against integer
+   overflow caused by enormously large patterns. */
+#ifndef MAX_NAME_SIZE
+#define MAX_NAME_SIZE 32
+#endif
+
+/* The value of NEWLINE determines the newline character sequence. On systems
+   that support it, "configure" can be used to override the default, which is
+   10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or -2
+   (ANYCRLF). */
+#ifndef NEWLINE
+#define NEWLINE 10
+#endif
+
+/* PCRE uses recursive function calls to handle backtracking while matching.
+   This can sometimes be a problem on systems that have stacks of limited
+   size. Define NO_RECURSE to get a version that doesn't use recursion in the
+   match() function; instead it creates its own stack by steam using
+   pcre_recurse_malloc() to obtain memory from the heap. For more detail, see
+   the comments and other stuff just above the match() function. On systems
+   that support it, "configure" can be used to set this in the Makefile (use
+   --disable-stack-for-recursion). */
+#define NO_RECURSE
+
+/* Name of package */
+#define PACKAGE "pcre"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "PCRE"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "PCRE 7.8"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "pcre"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "7.8"
+
+
+/* If you are compiling for a system other than a Unix-like system or
+   Win32, and it needs some magic to be inserted before the definition
+   of a function that is exported by the library, define this macro to
+   contain the relevant magic. If you do not define this macro, it
+   defaults to "extern" for a C compiler and "extern C" for a C++
+   compiler on non-Win32 systems. This macro apears at the start of
+   every exported function that is part of the external API. It does
+   not appear on functions that are "external" in the C sense, but
+   which are internal to the library. */
+
+/* Define if linking statically (TODO: make nice with Libtool) */
+/* #undef PCRE_STATIC */
+
+
+/* When calling PCRE via the POSIX interface, additional working storage is
+   required for holding the pointers to capturing substrings because PCRE
+   requires three integers per substring, whereas the POSIX interface provides
+   only two. If the number of expected substrings is small, the wrapper
+   function uses space on the stack, because this is faster than using
+   malloc() for each call. The threshold above which the stack is no longer
+   used is defined by POSIX_MALLOC_THRESHOLD. On systems that support it,
+   "configure" can be used to override this default. */
+#ifndef POSIX_MALLOC_THRESHOLD
+#define POSIX_MALLOC_THRESHOLD 10
+#endif
+
+/* Define to 1 if you have the ANSI C header files. */
+#ifndef STDC_HEADERS
+#define STDC_HEADERS 1
+#endif
+
+/* Define to allow pcregrep to be linked with libbz2, so that it is able to
+   handle .bz2 files. */
+ #undef SUPPORT_LIBBZ2 
+
+/* Define to allow pcretest to be linked with libreadline. */
+ #undef SUPPORT_LIBREADLINE 
+
+/* Define to allow pcregrep to be linked with libz, so that it is able to
+   handle .gz files. */
+ #undef SUPPORT_LIBZ 
+
+/* Define to enable support for Unicode properties */
+#define SUPPORT_UCP 
+
+/* Define to enable support for the UTF-8 Unicode encoding. */
+#define SUPPORT_UTF8
+
+/* Version number of package */
+#ifndef VERSION
+#define VERSION "7.8"
+#endif
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+#define PCRE_EXP_DECL IMPORT_C
+#define PCRE_EXP_DEFN EXPORT_C
+
+typedef TInt BOOL;
+
+#endif //_PCRE_CONFIG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/inc/pcre.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,310 @@
+/*************************************************
+*       Perl-Compatible Regular Expressions      *
+*************************************************/
+
+/* This is the public header file for the PCRE library, to be #included by
+applications that call the PCRE functions.
+
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _PCRE_H
+#define _PCRE_H
+
+/* The current PCRE version information. */
+
+#define PCRE_MAJOR          7
+#define PCRE_MINOR          8
+#define PCRE_PRERELEASE     
+#define PCRE_DATE           2008-09-05
+
+/* When an application links to a PCRE DLL in Windows, the symbols that are
+imported have to be identified as such. When building PCRE, the appropriate
+export setting is defined in pcre_internal.h, which includes this file. So we
+don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC)
+#  ifndef PCRE_EXP_DECL
+#    define PCRE_EXP_DECL  extern __declspec(dllimport)
+#  endif
+#  ifdef __cplusplus
+#    ifndef PCRECPP_EXP_DECL
+#      define PCRECPP_EXP_DECL  extern __declspec(dllimport)
+#    endif
+#    ifndef PCRECPP_EXP_DEFN
+#      define PCRECPP_EXP_DEFN  __declspec(dllimport)
+#    endif
+#  endif
+#endif
+
+/* By default, we use the standard "extern" declarations. */
+
+#ifndef PCRE_EXP_DECL
+#  ifdef __cplusplus
+#    define PCRE_EXP_DECL  extern "C"
+#  else
+#    define PCRE_EXP_DECL  extern
+#  endif
+#endif
+
+#ifdef __cplusplus
+#  ifndef PCRECPP_EXP_DECL
+#    define PCRECPP_EXP_DECL  extern
+#  endif
+#  ifndef PCRECPP_EXP_DEFN
+#    define PCRECPP_EXP_DEFN
+#  endif
+#endif
+
+/* Have to include stdlib.h in order to ensure that size_t is defined;
+it is needed here for malloc. */
+
+#include <stdlib.h>
+
+/* Allow for C++ users */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Options */
+
+#define PCRE_CASELESS           0x00000001
+#define PCRE_MULTILINE          0x00000002
+#define PCRE_DOTALL             0x00000004
+#define PCRE_EXTENDED           0x00000008
+#define PCRE_ANCHORED           0x00000010
+#define PCRE_DOLLAR_ENDONLY     0x00000020
+#define PCRE_EXTRA              0x00000040
+#define PCRE_NOTBOL             0x00000080
+#define PCRE_NOTEOL             0x00000100
+#define PCRE_UNGREEDY           0x00000200
+#define PCRE_NOTEMPTY           0x00000400
+#define PCRE_UTF8               0x00000800
+#define PCRE_NO_AUTO_CAPTURE    0x00001000
+#define PCRE_NO_UTF8_CHECK      0x00002000
+#define PCRE_AUTO_CALLOUT       0x00004000
+#define PCRE_PARTIAL            0x00008000
+#define PCRE_DFA_SHORTEST       0x00010000
+#define PCRE_DFA_RESTART        0x00020000
+#define PCRE_FIRSTLINE          0x00040000
+#define PCRE_DUPNAMES           0x00080000
+#define PCRE_NEWLINE_CR         0x00100000
+#define PCRE_NEWLINE_LF         0x00200000
+#define PCRE_NEWLINE_CRLF       0x00300000
+#define PCRE_NEWLINE_ANY        0x00400000
+#define PCRE_NEWLINE_ANYCRLF    0x00500000
+#define PCRE_BSR_ANYCRLF        0x00800000
+#define PCRE_BSR_UNICODE        0x01000000
+#define PCRE_JAVASCRIPT_COMPAT  0x02000000
+
+/* Exec-time and get/set-time error codes */
+
+#define PCRE_ERROR_NOMATCH         (-1)
+#define PCRE_ERROR_NULL            (-2)
+#define PCRE_ERROR_BADOPTION       (-3)
+#define PCRE_ERROR_BADMAGIC        (-4)
+#define PCRE_ERROR_UNKNOWN_OPCODE  (-5)
+#define PCRE_ERROR_UNKNOWN_NODE    (-5)  /* For backward compatibility */
+#define PCRE_ERROR_NOMEMORY        (-6)
+#define PCRE_ERROR_NOSUBSTRING     (-7)
+#define PCRE_ERROR_MATCHLIMIT      (-8)
+#define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */
+#define PCRE_ERROR_BADUTF8        (-10)
+#define PCRE_ERROR_BADUTF8_OFFSET (-11)
+#define PCRE_ERROR_PARTIAL        (-12)
+#define PCRE_ERROR_BADPARTIAL     (-13)
+#define PCRE_ERROR_INTERNAL       (-14)
+#define PCRE_ERROR_BADCOUNT       (-15)
+#define PCRE_ERROR_DFA_UITEM      (-16)
+#define PCRE_ERROR_DFA_UCOND      (-17)
+#define PCRE_ERROR_DFA_UMLIMIT    (-18)
+#define PCRE_ERROR_DFA_WSSIZE     (-19)
+#define PCRE_ERROR_DFA_RECURSE    (-20)
+#define PCRE_ERROR_RECURSIONLIMIT (-21)
+#define PCRE_ERROR_NULLWSLIMIT    (-22)  /* No longer actually used */
+#define PCRE_ERROR_BADNEWLINE     (-23)
+
+/* Request types for pcre_fullinfo() */
+
+#define PCRE_INFO_OPTIONS            0
+#define PCRE_INFO_SIZE               1
+#define PCRE_INFO_CAPTURECOUNT       2
+#define PCRE_INFO_BACKREFMAX         3
+#define PCRE_INFO_FIRSTBYTE          4
+#define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */
+#define PCRE_INFO_FIRSTTABLE         5
+#define PCRE_INFO_LASTLITERAL        6
+#define PCRE_INFO_NAMEENTRYSIZE      7
+#define PCRE_INFO_NAMECOUNT          8
+#define PCRE_INFO_NAMETABLE          9
+#define PCRE_INFO_STUDYSIZE         10
+#define PCRE_INFO_DEFAULT_TABLES    11
+#define PCRE_INFO_OKPARTIAL         12
+#define PCRE_INFO_JCHANGED          13
+#define PCRE_INFO_HASCRORLF         14
+
+/* Request types for pcre_config(). Do not re-arrange, in order to remain
+compatible. */
+
+#define PCRE_CONFIG_UTF8                    0
+#define PCRE_CONFIG_NEWLINE                 1
+#define PCRE_CONFIG_LINK_SIZE               2
+#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3
+#define PCRE_CONFIG_MATCH_LIMIT             4
+#define PCRE_CONFIG_STACKRECURSE            5
+#define PCRE_CONFIG_UNICODE_PROPERTIES      6
+#define PCRE_CONFIG_MATCH_LIMIT_RECURSION   7
+#define PCRE_CONFIG_BSR                     8
+
+/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
+these bits, just add new ones on the end, in order to remain compatible. */
+
+#define PCRE_EXTRA_STUDY_DATA             0x0001
+#define PCRE_EXTRA_MATCH_LIMIT            0x0002
+#define PCRE_EXTRA_CALLOUT_DATA           0x0004
+#define PCRE_EXTRA_TABLES                 0x0008
+#define PCRE_EXTRA_MATCH_LIMIT_RECURSION  0x0010
+
+/* Types */
+
+struct real_pcre;                 /* declaration; the definition is private  */
+typedef struct real_pcre pcre;
+
+/* When PCRE is compiled as a C++ library, the subject pointer type can be
+replaced with a custom type. For conventional use, the public interface is a
+const char *. */
+
+#ifndef PCRE_SPTR
+#define PCRE_SPTR const char *
+#endif
+
+/* The structure for passing additional data to pcre_exec(). This is defined in
+such as way as to be extensible. Always add new fields at the end, in order to
+remain compatible. */
+
+typedef struct pcre_extra {
+  unsigned long int flags;        /* Bits for which fields are set */
+  void *study_data;               /* Opaque data from pcre_study() */
+  unsigned long int match_limit;  /* Maximum number of calls to match() */
+  void *callout_data;             /* Data passed back in callouts */
+  const unsigned char *tables;    /* Pointer to character tables */
+  unsigned long int match_limit_recursion; /* Max recursive calls to match() */
+} pcre_extra;
+
+/* The structure for passing out data via the pcre_callout_function. We use a
+structure so that new fields can be added on the end in future versions,
+without changing the API of the function, thereby allowing old clients to work
+without modification. */
+
+typedef struct pcre_callout_block {
+  int          version;           /* Identifies version of block */
+  /* ------------------------ Version 0 ------------------------------- */
+  int          callout_number;    /* Number compiled into pattern */
+  int         *offset_vector;     /* The offset vector */
+  PCRE_SPTR    subject;           /* The subject being matched */
+  int          subject_length;    /* The length of the subject */
+  int          start_match;       /* Offset to start of this match attempt */
+  int          current_position;  /* Where we currently are in the subject */
+  int          capture_top;       /* Max current capture */
+  int          capture_last;      /* Most recently closed capture */
+  void        *callout_data;      /* Data passed in with the call */
+  /* ------------------- Added for Version 1 -------------------------- */
+  int          pattern_position;  /* Offset to next item in the pattern */
+  int          next_item_length;  /* Length of next item in the pattern */
+  /* ------------------------------------------------------------------ */
+} pcre_callout_block;
+
+/* Indirection for store get and free functions. These can be set to
+alternative malloc/free functions if required. Special ones are used in the
+non-recursive case for "frames". There is also an optional callout function
+that is triggered by the (?) regex item. For Virtual Pascal, these definitions
+have to take another form. */
+
+#ifdef VPCOMPAT
+PCRE_EXP_DECL void *pcre_malloc(size_t);
+PCRE_EXP_DECL void  pcre_free(void *);
+PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
+PCRE_EXP_DECL void  pcre_stack_free(void *);
+PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
+#elif defined(__SYMBIAN32__)
+PCRE_EXP_DECL void *pcre_malloc(size_t);
+PCRE_EXP_DECL void  pcre_free(void *);
+PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
+PCRE_EXP_DECL void  pcre_stack_free(void *);
+PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
+#else
+PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
+PCRE_EXP_DECL void  (*pcre_free)(void *);
+PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
+PCRE_EXP_DECL void  (*pcre_stack_free)(void *);
+PCRE_EXP_DECL int   (*pcre_callout)(pcre_callout_block *);
+#endif
+
+/* Exported PCRE functions */
+
+PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
+                  const unsigned char *);
+PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
+                  int *, const unsigned char *);
+PCRE_EXP_DECL int  pcre_config(int, void *);
+PCRE_EXP_DECL int  pcre_copy_named_substring(const pcre *, const char *,
+                  int *, int, const char *, char *, int);
+PCRE_EXP_DECL int  pcre_copy_substring(const char *, int *, int, int, char *,
+                  int);
+PCRE_EXP_DECL int  pcre_dfa_exec(const pcre *, const pcre_extra *,
+                  const char *, int, int, int, int *, int , int *, int);
+PCRE_EXP_DECL int  pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
+                   int, int, int, int *, int);
+PCRE_EXP_DECL void pcre_free_substring(const char *);
+PCRE_EXP_DECL void pcre_free_substring_list(const char **);
+PCRE_EXP_DECL int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
+                  void *);
+PCRE_EXP_DECL int  pcre_get_named_substring(const pcre *, const char *,
+                  int *, int, const char *, const char **);
+PCRE_EXP_DECL int  pcre_get_stringnumber(const pcre *, const char *);
+PCRE_EXP_DECL int  pcre_get_stringtable_entries(const pcre *, const char *,
+                  char **, char **);
+PCRE_EXP_DECL int  pcre_get_substring(const char *, int *, int, int,
+                  const char **);
+PCRE_EXP_DECL int  pcre_get_substring_list(const char *, int *, int,
+                  const char ***);
+PCRE_EXP_DECL int  pcre_info(const pcre *, int *, int *);
+PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
+PCRE_EXP_DECL int  pcre_refcount(pcre *, int);
+PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
+PCRE_EXP_DECL const char *pcre_version(void);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif
+
+#endif /* End of pcre.h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/inc/pcre_printint.src	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,512 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains a PCRE private debugging function for printing out the
+internal form of a compiled regular expression, along with some supporting
+local functions. This source file is used in two places:
+
+(1) It is #included by pcre_compile.c when it is compiled in debugging mode
+(DEBUG defined in pcre_internal.h). It is not included in production compiles.
+
+(2) It is always #included by pcretest.c, which can be asked to print out a
+compiled regex for debugging purposes. */
+
+
+/* Macro that decides whether a character should be output as a literal or in
+hexadecimal. We don't use isprint() because that can vary from system to system
+(even without the use of locales) and we want the output always to be the same,
+for testing purposes. This macro is used in pcretest as well as in this file. */
+
+#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
+
+/* The table of operator names. */
+
+static const char *OP_names[] = { OP_NAME_LIST };
+
+
+
+/*************************************************
+*       Print single- or multi-byte character    *
+*************************************************/
+
+static int
+print_char(FILE *f, uschar *ptr, BOOL utf8)
+{
+int c = *ptr;
+
+#ifndef SUPPORT_UTF8
+utf8 = utf8;  /* Avoid compiler warning */
+if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
+return 0;
+
+#else
+if (!utf8 || (c & 0xc0) != 0xc0)
+  {
+  if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
+  return 0;
+  }
+else
+  {
+  int i;
+  int a = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */
+  int s = 6*a;
+  c = (c & _pcre_utf8_table3[a]) << s;
+  for (i = 1; i <= a; i++)
+    {
+    /* This is a check for malformed UTF-8; it should only occur if the sanity
+    check has been turned off. Rather than swallow random bytes, just stop if
+    we hit a bad one. Print it with \X instead of \x as an indication. */
+
+    if ((ptr[i] & 0xc0) != 0x80)
+      {
+      fprintf(f, "\\X{%x}", c);
+      return i - 1;
+      }
+
+    /* The byte is OK */
+
+    s -= 6;
+    c |= (ptr[i] & 0x3f) << s;
+    }
+  if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);
+  return a;
+  }
+#endif
+}
+
+
+
+/*************************************************
+*          Find Unicode property name            *
+*************************************************/
+
+static const char *
+get_ucpname(int ptype, int pvalue)
+{
+#ifdef SUPPORT_UCP
+int i;
+for (i = _pcre_utt_size - 1; i >= 0; i--)
+  {
+  if (ptype == _pcre_utt[i].type && pvalue == _pcre_utt[i].value) break;
+  }
+return (i >= 0)? _pcre_utt_names + _pcre_utt[i].name_offset : "??";
+#else
+/* It gets harder and harder to shut off unwanted compiler warnings. */
+ptype = ptype * pvalue;
+return (ptype == pvalue)? "??" : "??";
+#endif
+}
+
+
+
+/*************************************************
+*         Print compiled regex                   *
+*************************************************/
+
+/* Make this function work for a regex with integers either byte order.
+However, we assume that what we are passed is a compiled regex. The
+print_lengths flag controls whether offsets and lengths of items are printed.
+They can be turned off from pcretest so that automatic tests on bytecode can be
+written that do not depend on the value of LINK_SIZE. */
+
+static void
+pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
+{
+real_pcre *re = (real_pcre *)external_re;
+uschar *codestart, *code;
+BOOL utf8;
+
+unsigned int options = re->options;
+int offset = re->name_table_offset;
+int count = re->name_count;
+int size = re->name_entry_size;
+
+if (re->magic_number != MAGIC_NUMBER)
+  {
+  offset = ((offset << 8) & 0xff00) | ((offset >> 8) & 0xff);
+  count = ((count << 8) & 0xff00) | ((count >> 8) & 0xff);
+  size = ((size << 8) & 0xff00) | ((size >> 8) & 0xff);
+  options = ((options << 24) & 0xff000000) |
+            ((options <<  8) & 0x00ff0000) |
+            ((options >>  8) & 0x0000ff00) |
+            ((options >> 24) & 0x000000ff);
+  }
+
+code = codestart = (uschar *)re + offset + count * size;
+utf8 = (options & PCRE_UTF8) != 0;
+
+for(;;)
+  {
+  uschar *ccode;
+  int c;
+  int extra = 0;
+
+  if (print_lengths)
+    fprintf(f, "%3d ", (int)(code - codestart));
+  else
+    fprintf(f, "    ");
+
+  switch(*code)
+    {
+    case OP_END:
+    fprintf(f, "    %s\n", OP_names[*code]);
+    fprintf(f, "------------------------------------------------------------------\n");
+    return;
+
+    case OP_OPT:
+    fprintf(f, " %.2x %s", code[1], OP_names[*code]);
+    break;
+
+    case OP_CHAR:
+    fprintf(f, "    ");
+    do
+      {
+      code++;
+      code += 1 + print_char(f, code, utf8);
+      }
+    while (*code == OP_CHAR);
+    fprintf(f, "\n");
+    continue;
+
+    case OP_CHARNC:
+    fprintf(f, " NC ");
+    do
+      {
+      code++;
+      code += 1 + print_char(f, code, utf8);
+      }
+    while (*code == OP_CHARNC);
+    fprintf(f, "\n");
+    continue;
+
+    case OP_CBRA:
+    case OP_SCBRA:
+    if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+      else fprintf(f, "    ");
+    fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));
+    break;
+
+    case OP_BRA:
+    case OP_SBRA:
+    case OP_KETRMAX:
+    case OP_KETRMIN:
+    case OP_ALT:
+    case OP_KET:
+    case OP_ASSERT:
+    case OP_ASSERT_NOT:
+    case OP_ASSERTBACK:
+    case OP_ASSERTBACK_NOT:
+    case OP_ONCE:
+    case OP_COND:
+    case OP_SCOND:
+    case OP_REVERSE:
+    if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+      else fprintf(f, "    ");
+    fprintf(f, "%s", OP_names[*code]);
+    break;
+
+    case OP_CREF:
+    fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
+    break;
+
+    case OP_RREF:
+    c = GET2(code, 1);
+    if (c == RREF_ANY)
+      fprintf(f, "    Cond recurse any");
+    else
+      fprintf(f, "    Cond recurse %d", c);
+    break;
+
+    case OP_DEF:
+    fprintf(f, "    Cond def");
+    break;
+
+    case OP_STAR:
+    case OP_MINSTAR:
+    case OP_POSSTAR:
+    case OP_PLUS:
+    case OP_MINPLUS:
+    case OP_POSPLUS:
+    case OP_QUERY:
+    case OP_MINQUERY:
+    case OP_POSQUERY:
+    case OP_TYPESTAR:
+    case OP_TYPEMINSTAR:
+    case OP_TYPEPOSSTAR:
+    case OP_TYPEPLUS:
+    case OP_TYPEMINPLUS:
+    case OP_TYPEPOSPLUS:
+    case OP_TYPEQUERY:
+    case OP_TYPEMINQUERY:
+    case OP_TYPEPOSQUERY:
+    fprintf(f, "    ");
+    if (*code >= OP_TYPESTAR)
+      {
+      fprintf(f, "%s", OP_names[code[1]]);
+      if (code[1] == OP_PROP || code[1] == OP_NOTPROP)
+        {
+        fprintf(f, " %s ", get_ucpname(code[2], code[3]));
+        extra = 2;
+        }
+      }
+    else extra = print_char(f, code+1, utf8);
+    fprintf(f, "%s", OP_names[*code]);
+    break;
+
+    case OP_EXACT:
+    case OP_UPTO:
+    case OP_MINUPTO:
+    case OP_POSUPTO:
+    fprintf(f, "    ");
+    extra = print_char(f, code+3, utf8);
+    fprintf(f, "{");
+    if (*code != OP_EXACT) fprintf(f, "0,");
+    fprintf(f, "%d}", GET2(code,1));
+    if (*code == OP_MINUPTO) fprintf(f, "?");
+      else if (*code == OP_POSUPTO) fprintf(f, "+");
+    break;
+
+    case OP_TYPEEXACT:
+    case OP_TYPEUPTO:
+    case OP_TYPEMINUPTO:
+    case OP_TYPEPOSUPTO:
+    fprintf(f, "    %s", OP_names[code[3]]);
+    if (code[3] == OP_PROP || code[3] == OP_NOTPROP)
+      {
+      fprintf(f, " %s ", get_ucpname(code[4], code[5]));
+      extra = 2;
+      }
+    fprintf(f, "{");
+    if (*code != OP_TYPEEXACT) fprintf(f, "0,");
+    fprintf(f, "%d}", GET2(code,1));
+    if (*code == OP_TYPEMINUPTO) fprintf(f, "?");
+      else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");
+    break;
+
+    case OP_NOT:
+    c = code[1];
+    if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);
+      else fprintf(f, "    [^\\x%02x]", c);
+    break;
+
+    case OP_NOTSTAR:
+    case OP_NOTMINSTAR:
+    case OP_NOTPOSSTAR:
+    case OP_NOTPLUS:
+    case OP_NOTMINPLUS:
+    case OP_NOTPOSPLUS:
+    case OP_NOTQUERY:
+    case OP_NOTMINQUERY:
+    case OP_NOTPOSQUERY:
+    c = code[1];
+    if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);
+      else fprintf(f, "    [^\\x%02x]", c);
+    fprintf(f, "%s", OP_names[*code]);
+    break;
+
+    case OP_NOTEXACT:
+    case OP_NOTUPTO:
+    case OP_NOTMINUPTO:
+    case OP_NOTPOSUPTO:
+    c = code[3];
+    if (PRINTABLE(c)) fprintf(f, "    [^%c]{", c);
+      else fprintf(f, "    [^\\x%02x]{", c);
+    if (*code != OP_NOTEXACT) fprintf(f, "0,");
+    fprintf(f, "%d}", GET2(code,1));
+    if (*code == OP_NOTMINUPTO) fprintf(f, "?");
+      else if (*code == OP_NOTPOSUPTO) fprintf(f, "+");
+    break;
+
+    case OP_RECURSE:
+    if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+      else fprintf(f, "    ");
+    fprintf(f, "%s", OP_names[*code]);
+    break;
+
+    case OP_REF:
+    fprintf(f, "    \\%d", GET2(code,1));
+    ccode = code + _pcre_OP_lengths[*code];
+    goto CLASS_REF_REPEAT;
+
+    case OP_CALLOUT:
+    fprintf(f, "    %s %d %d %d", OP_names[*code], code[1], GET(code,2),
+      GET(code, 2 + LINK_SIZE));
+    break;
+
+    case OP_PROP:
+    case OP_NOTPROP:
+    fprintf(f, "    %s %s", OP_names[*code], get_ucpname(code[1], code[2]));
+    break;
+
+    /* OP_XCLASS can only occur in UTF-8 mode. However, there's no harm in
+    having this code always here, and it makes it less messy without all those
+    #ifdefs. */
+
+    case OP_CLASS:
+    case OP_NCLASS:
+    case OP_XCLASS:
+      {
+      int i, min, max;
+      BOOL printmap;
+
+      fprintf(f, "    [");
+
+      if (*code == OP_XCLASS)
+        {
+        extra = GET(code, 1);
+        ccode = code + LINK_SIZE + 1;
+        printmap = (*ccode & XCL_MAP) != 0;
+        if ((*ccode++ & XCL_NOT) != 0) fprintf(f, "^");
+        }
+      else
+        {
+        printmap = TRUE;
+        ccode = code + 1;
+        }
+
+      /* Print a bit map */
+
+      if (printmap)
+        {
+        for (i = 0; i < 256; i++)
+          {
+          if ((ccode[i/8] & (1 << (i&7))) != 0)
+            {
+            int j;
+            for (j = i+1; j < 256; j++)
+              if ((ccode[j/8] & (1 << (j&7))) == 0) break;
+            if (i == '-' || i == ']') fprintf(f, "\\");
+            if (PRINTABLE(i)) fprintf(f, "%c", i);
+              else fprintf(f, "\\x%02x", i);
+            if (--j > i)
+              {
+              if (j != i + 1) fprintf(f, "-");
+              if (j == '-' || j == ']') fprintf(f, "\\");
+              if (PRINTABLE(j)) fprintf(f, "%c", j);
+                else fprintf(f, "\\x%02x", j);
+              }
+            i = j;
+            }
+          }
+        ccode += 32;
+        }
+
+      /* For an XCLASS there is always some additional data */
+
+      if (*code == OP_XCLASS)
+        {
+        int ch;
+        while ((ch = *ccode++) != XCL_END)
+          {
+          if (ch == XCL_PROP)
+            {
+            int ptype = *ccode++;
+            int pvalue = *ccode++;
+            fprintf(f, "\\p{%s}", get_ucpname(ptype, pvalue));
+            }
+          else if (ch == XCL_NOTPROP)
+            {
+            int ptype = *ccode++;
+            int pvalue = *ccode++;
+            fprintf(f, "\\P{%s}", get_ucpname(ptype, pvalue));
+            }
+          else
+            {
+            ccode += 1 + print_char(f, ccode, TRUE);
+            if (ch == XCL_RANGE)
+              {
+              fprintf(f, "-");
+              ccode += 1 + print_char(f, ccode, TRUE);
+              }
+            }
+          }
+        }
+
+      /* Indicate a non-UTF8 class which was created by negation */
+
+      fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");
+
+      /* Handle repeats after a class or a back reference */
+
+      CLASS_REF_REPEAT:
+      switch(*ccode)
+        {
+        case OP_CRSTAR:
+        case OP_CRMINSTAR:
+        case OP_CRPLUS:
+        case OP_CRMINPLUS:
+        case OP_CRQUERY:
+        case OP_CRMINQUERY:
+        fprintf(f, "%s", OP_names[*ccode]);
+        extra += _pcre_OP_lengths[*ccode];
+        break;
+
+        case OP_CRRANGE:
+        case OP_CRMINRANGE:
+        min = GET2(ccode,1);
+        max = GET2(ccode,3);
+        if (max == 0) fprintf(f, "{%d,}", min);
+        else fprintf(f, "{%d,%d}", min, max);
+        if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
+        extra += _pcre_OP_lengths[*ccode];
+        break;
+
+        /* Do nothing if it's not a repeat; this code stops picky compilers
+        warning about the lack of a default code path. */
+
+        default:
+        break;
+        }
+      }
+    break;
+
+    /* Anything else is just an item with no data*/
+
+    default:
+    fprintf(f, "    %s", OP_names[*code]);
+    break;
+    }
+
+  code += _pcre_OP_lengths[*code] + extra;
+  fprintf(f, "\n");
+  }
+}
+
+/* End of pcre_printint.src */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/132html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,296 @@
+#! /usr/bin/perl -w
+
+# Script to turn PCRE man pages into HTML
+
+
+# Subroutine to handle font changes and other escapes
+
+sub do_line {
+my($s) = $_[0];
+
+$s =~ s/</&#60;/g;                   # Deal with < and >
+$s =~ s/>/&#62;/g;
+$s =~ s"\\fI(.*?)\\f[RP]"<i>$1</i>"g;
+$s =~ s"\\fB(.*?)\\f[RP]"<b>$1</b>"g;
+$s =~ s"\\e"\\"g;
+$s =~ s/(?<=Copyright )\(c\)/&copy;/g;
+$s;
+}
+
+# Subroutine to ensure not in a paragraph
+
+sub end_para {
+if ($inpara)
+  {
+  print TEMP "</PRE>\n" if ($inpre);
+  print TEMP "</P>\n";
+  }
+$inpara = $inpre = 0;
+$wrotetext = 0;
+}
+
+# Subroutine to start a new paragraph
+
+sub new_para {
+&end_para();
+print TEMP "<P>\n";
+$inpara = 1;
+}
+
+
+# Main program
+
+$innf = 0;
+$inpara = 0;
+$inpre = 0;
+$wrotetext = 0;
+$toc = 0;
+$ref = 1;
+
+while ($#ARGV >= 0 && $ARGV[0] =~ /^-/)
+  {
+  $toc = 1 if $ARGV[0] eq "-toc";
+  shift;
+  }
+
+# Initial output to STDOUT
+
+print <<End ;
+<html>
+<head>
+<title>$ARGV[0] specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>$ARGV[0] man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+End
+
+print "<ul>\n" if ($toc);
+
+open(TEMP, ">/tmp/$$") || die "Can't open /tmp/$$ for output\n";
+
+while (<STDIN>)
+  {
+  # Handle lines beginning with a dot
+
+  if (/^\./)
+    {
+    # Some of the PCRE man pages used to contain instances of .br. However,
+    # they should have all been removed because they cause trouble in some
+    # (other) automated systems that translate man pages to HTML. Complain if
+    # we find .br or .in (another macro that is deprecated).
+
+    if (/^\.br/ || /^\.in/)
+      {
+      print STDERR "\n*** Deprecated macro encountered - rewrite needed\n";
+      print STDERR "*** $_\n";
+      die "*** Processing abandoned\n";
+      }
+
+    # Instead of .br, relevent "literal" sections are enclosed in .nf/.fi.
+
+    elsif (/^\.nf/)
+      {
+      $innf = 1;
+      }
+
+    elsif (/^\.fi/)
+      {
+      $innf = 0;
+      }
+
+    # Handling .sp is subtle. If it is inside a literal section, do nothing if
+    # the next line is a non literal text line; similarly, if not inside a
+    # literal section, do nothing if a literal follows. The point being that
+    # the <pre> and </pre> that delimit literal sections will do the spacing.
+    # Always skip if no previous output.
+
+    elsif (/^\.sp/)
+      {
+      if ($wrotetext)
+        {
+        $_ = <STDIN>;
+        if ($inpre)
+          {
+          print TEMP "\n" if (/^[\s.]/);
+          }
+        else
+          {
+          print TEMP "<br>\n<br>\n" if (!/^[\s.]/);
+          }
+        redo;    # Now process the lookahead line we just read
+        }
+      }
+    elsif (/^\.TP/ || /^\.PP/ || /^\.P/)
+      {
+      &new_para();
+      }
+    elsif (/^\.SH\s*("?)(.*)\1/)
+      {
+      # Ignore the NAME section
+      if ($2 =~ /^NAME\b/)
+        {
+        <STDIN>;
+        next;
+        }
+
+      &end_para();
+      my($title) = &do_line($2);
+      if ($toc)
+        {
+        printf("<li><a name=\"TOC%d\" href=\"#SEC%d\">$title</a>\n",
+          $ref, $ref);
+        printf TEMP ("<br><a name=\"SEC%d\" href=\"#TOC1\">$title</a><br>\n",
+          $ref, $ref);
+        $ref++;
+        }
+      else
+        {
+        print TEMP "<br><b>\n$title\n</b><br>\n";
+        }
+      }
+    elsif (/^\.SS\s*("?)(.*)\1/)
+      {
+      &end_para();
+      my($title) = &do_line($2);
+      print TEMP "<br><b>\n$title\n</b><br>\n";
+      }
+    elsif (/^\.B\s*(.*)/)
+      {
+      &new_para() if (!$inpara);
+      $_ = &do_line($1);
+      s/"(.*?)"/$1/g;
+      print TEMP "<b>$_</b>\n";
+      $wrotetext = 1;
+      }
+    elsif (/^\.I\s*(.*)/)
+      {
+      &new_para() if (!$inpara);
+      $_ = &do_line($1);
+      s/"(.*?)"/$1/g;
+      print TEMP "<i>$_</i>\n";
+      $wrotetext = 1;
+      }
+
+    # A comment that starts "HREF" takes the next line as a name that
+    # is turned into a hyperlink, using the text given, which might be
+    # in a special font. If it ends in () or (digits) or punctuation, they
+    # aren't part of the link.
+
+    elsif (/^\.\\"\s*HREF/)
+      {
+      $_=<STDIN>;
+      chomp;
+      $_ = &do_line($_);
+      $_ =~ s/\s+$//;
+      $_ =~ /^(?:<.>)?([^<(]+)(?:\(\))?(?:<\/.>)?(?:\(\d+\))?[.,;:]?$/;
+      print TEMP "<a href=\"$1.html\">$_</a>\n";
+      }
+
+    # A comment that starts "HTML" inserts literal HTML
+
+    elsif (/^\.\\"\s*HTML\s*(.*)/)
+      {
+      print TEMP $1;
+      }
+
+    # A comment that starts < inserts that HTML at the end of the
+    # *next* input line - so as not to get a newline between them.
+
+    elsif (/^\.\\"\s*(<.*>)/)
+      {
+      my($markup) = $1;
+      $_=<STDIN>;
+      chomp;
+      $_ = &do_line($_);
+      $_ =~ s/\s+$//;
+      print TEMP "$_$markup\n";
+      }
+
+    # A comment that starts JOIN joins the next two lines together, with one
+    # space between them. Then that line is processed. This is used in some
+    # displays where two lines are needed for the "man" version. JOINSH works
+    # the same, except that it assumes this is a shell command, so removes
+    # continuation backslashes.
+
+    elsif (/^\.\\"\s*JOIN(SH)?/)
+      {
+      my($one,$two);
+      $one = <STDIN>;
+      $two = <STDIN>;
+      $one =~ s/\s*\\e\s*$// if (defined($1));
+      chomp($one);
+      $two =~ s/^\s+//;
+      $_ = "$one $two";
+      redo;            # Process the joined lines
+      }
+
+    # Ignore anything not recognized
+
+    next;
+    }
+
+  # Line does not begin with a dot. Replace blank lines with new paragraphs
+
+  if (/^\s*$/)
+    {
+    &end_para() if ($wrotetext);
+    next;
+    }
+
+  # Convert fonts changes and output an ordinary line. Ensure that indented
+  # lines are marked as literal.
+
+  $_ = &do_line($_);
+  &new_para() if (!$inpara);
+
+  if (/^\s/)
+    {
+    if (!$inpre)
+      {
+      print TEMP "<pre>\n";
+      $inpre = 1;
+      }
+    }
+  elsif ($inpre)
+    {
+    print TEMP "</pre>\n";
+    $inpre = 0;
+    }
+
+  # Add <br> to the end of a non-literal line if we are within .nf/.fi
+
+  $_ .= "<br>\n" if (!$inpre && $innf);
+
+  print TEMP;
+  $wrotetext = 1;
+  }
+
+# The TOC, if present, will have been written - terminate it
+
+print "</ul>\n" if ($toc);
+
+# Copy the remainder to the standard output
+
+close(TEMP);
+open(TEMP, "/tmp/$$") || die "Can't open /tmp/$$ for input\n";
+
+print while (<TEMP>);
+
+print <<End ;
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+End
+
+close(TEMP);
+unlink("/tmp/$$");
+
+# End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/AUTHORS	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+THE MAIN PCRE LIBRARY
+---------------------
+
+Written by:       Philip Hazel
+Email local part: ph10
+Email domain:     cam.ac.uk
+
+University of Cambridge Computing Service,
+Cambridge, England.
+
+Copyright (c) 1997-2008 University of Cambridge
+All rights reserved
+
+
+THE C++ WRAPPER LIBRARY
+-----------------------
+
+Written by:       Google Inc.
+
+Copyright (c) 2007-2008 Google Inc
+All rights reserved
+
+####
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/CMakeLists.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,541 @@
+# CMakeLists.txt
+#
+#
+# This file allows building PCRE with the CMake configuration and build
+# tool. Download CMake in source or binary form from http://www.cmake.org/
+#
+# Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
+# Refined and expanded by Daniel Richard G. <skunk@iSKUNK.ORG>
+# 2007-09-14 mod by Sheri so 7.4 supported configuration options can be entered
+# 2007-09-19 Adjusted by PH to retain previous default settings
+# 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre
+#            (b) Ensure pcretest and pcregrep link with the local library,
+#                not a previously-installed one.
+#            (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and
+#                PCRE_SUPPORT_LIBBZ2.
+# 2008-01-20 Brought up to date to include several new features by Christian
+#            Ehrlicher.
+# 2008-01-22 Sheri added options for backward compatibility of library names when
+#            building with minGW:
+#            if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to
+#            be built without "lib" as prefix. (The libraries will be named pcre.dll,
+#            pcreposix.dll and pcrecpp.dll).
+#            if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to
+#            be built with suffix of "-0.dll". (The libraries will be named
+#            libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names
+#            built by default with Configure and Make.
+# 2008-01-23 PH removed the automatic build of pcredemo.
+# 2008-04-22 PH modified READLINE support so it finds NCURSES when needed.
+# 2008-07-03 PH updated for revised UCP property support (change of files)
+
+PROJECT(PCRE C CXX)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6)
+
+SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) # for FindReadline.cmake
+
+# external packages
+FIND_PACKAGE( BZip2 )
+FIND_PACKAGE( ZLIB )
+FIND_PACKAGE( Readline )
+
+# Configuration checks
+
+INCLUDE(CheckIncludeFile)
+INCLUDE(CheckIncludeFileCXX)
+INCLUDE(CheckFunctionExists)
+INCLUDE(CheckTypeSize)
+
+CHECK_INCLUDE_FILE(dirent.h     HAVE_DIRENT_H)
+CHECK_INCLUDE_FILE(sys/stat.h   HAVE_SYS_STAT_H)
+CHECK_INCLUDE_FILE(sys/types.h  HAVE_SYS_TYPES_H)
+CHECK_INCLUDE_FILE(unistd.h     HAVE_UNISTD_H)
+CHECK_INCLUDE_FILE(windows.h    HAVE_WINDOWS_H)
+
+CHECK_INCLUDE_FILE_CXX(type_traits.h            HAVE_TYPE_TRAITS_H)
+CHECK_INCLUDE_FILE_CXX(bits/type_traits.h       HAVE_BITS_TYPE_TRAITS_H)
+
+CHECK_FUNCTION_EXISTS(bcopy     HAVE_BCOPY)
+CHECK_FUNCTION_EXISTS(memmove   HAVE_MEMMOVE)
+CHECK_FUNCTION_EXISTS(strerror  HAVE_STRERROR)
+CHECK_FUNCTION_EXISTS(strtoll   HAVE_STRTOLL)
+CHECK_FUNCTION_EXISTS(strtoq    HAVE_STRTOQ)
+CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
+
+CHECK_TYPE_SIZE("long long"             LONG_LONG)
+CHECK_TYPE_SIZE("unsigned long long"    UNSIGNED_LONG_LONG)
+
+# User-configurable options
+#
+# (Note: CMakeSetup displays these in alphabetical order, regardless of
+# the order we use here)
+
+SET(BUILD_SHARED_LIBS OFF CACHE BOOL
+    "Build shared libraries instead of static ones.")
+
+OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
+
+SET(PCRE_EBCDIC OFF CACHE BOOL
+    "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)")
+
+SET(PCRE_LINK_SIZE "2" CACHE STRING
+    "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.")
+
+SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING
+    "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.")
+
+SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING
+    "Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.")
+
+SET(PCRE_NEWLINE "LF" CACHE STRING
+    "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).")
+
+SET(PCRE_NO_RECURSE OFF CACHE BOOL
+    "If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.")
+
+SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING
+    "Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.")
+
+SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
+    "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")
+
+SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL
+    "Enable support for the Unicode UTF-8 encoding.")
+
+SET(PCRE_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL
+    "ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks")
+
+
+IF (MINGW)
+  OPTION(NON_STANDARD_LIB_PREFIX
+         "ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
+         OFF)
+
+  OPTION(NON_STANDARD_LIB_SUFFIX
+         "ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
+         OFF)
+ENDIF(MINGW)
+
+# bzip2 lib
+IF(BZIP2_FOUND)
+  OPTION (PCRE_SUPPORT_LIBBZ2 "Enable support for linking pcregrep with libbz2." ON)
+ENDIF(BZIP2_FOUND)
+IF(PCRE_SUPPORT_LIBBZ2)
+  INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
+ENDIF(PCRE_SUPPORT_LIBBZ2)
+
+# zlib
+IF(ZLIB_FOUND)
+  OPTION (PCRE_SUPPORT_LIBZ "Enable support for linking pcregrep with libz." ON)
+ENDIF(ZLIB_FOUND)
+IF(PCRE_SUPPORT_LIBZ)
+  INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
+ENDIF(PCRE_SUPPORT_LIBZ)
+
+# readline lib
+IF(READLINE_FOUND)
+  OPTION (PCRE_SUPPORT_LIBREADLINE  "Enable support for linking pcretest with libreadline." ON)
+ENDIF(READLINE_FOUND)
+IF(PCRE_SUPPORT_LIBREADLINE)
+  INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
+ENDIF(PCRE_SUPPORT_LIBREADLINE)
+
+# Prepare build configuration
+
+SET(pcre_have_type_traits 0)
+SET(pcre_have_bits_type_traits 0)
+
+IF(HAVE_TYPE_TRAITS_H)
+        SET(pcre_have_type_traits 1)
+ENDIF(HAVE_TYPE_TRAITS_H)
+
+IF(HAVE_BITS_TYPE_TRAITS_H)
+        SET(pcre_have_bits_type_traits 1)
+ENDIF(HAVE_BITS_TYPE_TRAITS_H)
+
+SET(pcre_have_long_long 0)
+SET(pcre_have_ulong_long 0)
+
+IF(HAVE_LONG_LONG)
+        SET(pcre_have_long_long 1)
+ENDIF(HAVE_LONG_LONG)
+
+IF(HAVE_UNSIGNED_LONG_LONG)
+        SET(pcre_have_ulong_long 1)
+ENDIF(HAVE_UNSIGNED_LONG_LONG)
+
+IF(NOT BUILD_SHARED_LIBS)
+        SET(PCRE_STATIC 1)
+ENDIF(NOT BUILD_SHARED_LIBS)
+
+IF(PCRE_SUPPORT_BSR_ANYCRLF)
+        SET(BSR_ANYCRLF 1)
+ENDIF(PCRE_SUPPORT_BSR_ANYCRLF)
+
+IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
+        SET(SUPPORT_UTF8 1)
+ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
+
+IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
+        SET(SUPPORT_UCP 1)
+ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
+
+# This next one used to contain
+#       SET(PCRETEST_LIBS ${READLINE_LIBRARY})
+# but I was advised to add the NCURSES test as well, along with
+# some modifications to cmake/FindReadline.cmake which should
+# make it possible to override the default if necessary. PH
+
+IF(PCRE_SUPPORT_LIBREADLINE)
+        SET(SUPPORT_LIBREADLINE 1)
+        SET(PCRETEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
+ENDIF(PCRE_SUPPORT_LIBREADLINE)
+
+IF(PCRE_SUPPORT_LIBZ)
+        SET(SUPPORT_LIBZ 1)
+        SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${ZLIB_LIBRARIES})
+ENDIF(PCRE_SUPPORT_LIBZ)
+
+IF(PCRE_SUPPORT_LIBBZ2)
+        SET(SUPPORT_LIBBZ2 1)
+        SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${BZIP2_LIBRARIES})
+ENDIF(PCRE_SUPPORT_LIBBZ2)
+
+SET(NEWLINE "")
+
+IF(PCRE_NEWLINE STREQUAL "LF")
+        SET(NEWLINE "10")
+ENDIF(PCRE_NEWLINE STREQUAL "LF")
+IF(PCRE_NEWLINE STREQUAL "CR")
+        SET(NEWLINE "13")
+ENDIF(PCRE_NEWLINE STREQUAL "CR")
+IF(PCRE_NEWLINE STREQUAL "CRLF")
+        SET(NEWLINE "3338")
+ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
+IF(PCRE_NEWLINE STREQUAL "ANY")
+        SET(NEWLINE "-1")
+ENDIF(PCRE_NEWLINE STREQUAL "ANY")
+IF(PCRE_NEWLINE STREQUAL "ANYCRLF")
+        SET(NEWLINE "-2")
+ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF")
+
+IF(NEWLINE STREQUAL "")
+        MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
+ENDIF(NEWLINE STREQUAL "")
+
+IF(PCRE_EBCDIC)
+        SET(EBCDIC 1)
+ENDIF(PCRE_EBCDIC)
+
+IF(PCRE_NO_RECURSE)
+        SET(NO_RECURSE 1)
+ENDIF(PCRE_NO_RECURSE)
+
+# Output files
+
+CONFIGURE_FILE(config-cmake.h.in
+               ${CMAKE_BINARY_DIR}/config.h
+               @ONLY)
+
+CONFIGURE_FILE(pcre.h.generic
+               ${CMAKE_BINARY_DIR}/pcre.h
+               COPYONLY)
+
+# What about pcre-config and libpcre.pc?
+
+IF(PCRE_BUILD_PCRECPP)
+        CONFIGURE_FILE(pcre_stringpiece.h.in
+                       ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
+                       @ONLY)
+
+        CONFIGURE_FILE(pcrecpparg.h.in
+                       ${CMAKE_BINARY_DIR}/pcrecpparg.h
+                       @ONLY)
+ENDIF(PCRE_BUILD_PCRECPP)
+
+# Character table generation
+
+OPTION(PCRE_REBUILD_CHARTABLES "Rebuild char tables" OFF)
+IF(PCRE_REBUILD_CHARTABLES)
+  ADD_EXECUTABLE(dftables dftables.c)
+
+  GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION)
+
+  ADD_CUSTOM_COMMAND(
+    COMMENT "Generating character tables (pcre_chartables.c) for current locale"
+    DEPENDS dftables
+    COMMAND ${DFTABLES_EXE}
+    ARGS        ${CMAKE_BINARY_DIR}/pcre_chartables.c
+    OUTPUT      ${CMAKE_BINARY_DIR}/pcre_chartables.c
+  )
+ELSE(PCRE_REBUILD_CHARTABLES)
+  CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/pcre_chartables.c.dist
+                    ${CMAKE_BINARY_DIR}/pcre_chartables.c
+                    COPYONLY)
+ENDIF(PCRE_REBUILD_CHARTABLES)
+
+# Source code
+
+SET(PCRE_HEADERS ${CMAKE_BINARY_DIR}/pcre.h)
+
+SET(PCRE_SOURCES
+  ${CMAKE_BINARY_DIR}/pcre_chartables.c
+  pcre_compile.c
+  pcre_config.c
+  pcre_dfa_exec.c
+  pcre_exec.c
+  pcre_fullinfo.c
+  pcre_get.c
+  pcre_globals.c
+  pcre_info.c
+  pcre_newline.c
+  pcre_maketables.c
+  pcre_ord2utf8.c
+  pcre_refcount.c
+  pcre_study.c
+  pcre_tables.c
+  pcre_try_flipped.c
+  pcre_ucd.c
+  pcre_valid_utf8.c
+  pcre_version.c
+  pcre_xclass.c
+)
+
+SET(PCREPOSIX_HEADERS pcreposix.h)
+
+SET(PCREPOSIX_SOURCES pcreposix.c)
+
+SET(PCRECPP_HEADERS
+  pcrecpp.h
+  pcre_scanner.h
+  ${CMAKE_BINARY_DIR}/pcrecpparg.h
+  ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
+)
+
+SET(PCRECPP_SOURCES
+        pcrecpp.cc
+        pcre_scanner.cc
+        pcre_stringpiece.cc
+)
+
+# Build setup
+
+ADD_DEFINITIONS(-DHAVE_CONFIG_H)
+
+IF(MSVC)
+        ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
+ENDIF(MSVC)
+
+SET(CMAKE_INCLUDE_CURRENT_DIR 1)
+# needed to make sure to not link debug libs
+# against release libs and vice versa
+IF(WIN32)
+  SET(CMAKE_DEBUG_POSTFIX "d")
+ENDIF(WIN32)
+
+# Libraries
+# pcre
+ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES} ${CMAKE_BINARY_DIR}/config.h)
+ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
+TARGET_LINK_LIBRARIES(pcreposix pcre)
+IF(MINGW AND NOT PCRE_STATIC)
+  IF(NON_STANDARD_LIB_PREFIX)
+    SET_TARGET_PROPERTIES(pcre pcreposix
+                        PROPERTIES PREFIX ""
+    )
+  ENDIF(NON_STANDARD_LIB_PREFIX)
+
+  IF(NON_STANDARD_LIB_SUFFIX)
+    SET_TARGET_PROPERTIES(pcre pcreposix
+                        PROPERTIES SUFFIX "-0.dll"
+    )
+  ENDIF(NON_STANDARD_LIB_SUFFIX)
+ENDIF(MINGW AND NOT PCRE_STATIC)
+
+
+# pcrecpp
+IF(PCRE_BUILD_PCRECPP)
+  ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
+  TARGET_LINK_LIBRARIES(pcrecpp pcre)
+
+  IF(MINGW AND NOT PCRE_STATIC)
+    IF(NON_STANDARD_LIB_PREFIX)
+      SET_TARGET_PROPERTIES(pcrecpp
+                            PROPERTIES PREFIX ""
+      )
+    ENDIF(NON_STANDARD_LIB_PREFIX)
+
+    IF(NON_STANDARD_LIB_SUFFIX)
+      SET_TARGET_PROPERTIES(pcrecpp
+                          PROPERTIES SUFFIX "-0.dll"
+      )
+    ENDIF(NON_STANDARD_LIB_SUFFIX)
+  ENDIF(MINGW AND NOT PCRE_STATIC)
+ENDIF(PCRE_BUILD_PCRECPP)
+
+
+# Executables
+
+ADD_EXECUTABLE(pcretest pcretest.c)
+TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS})
+
+ADD_EXECUTABLE(pcregrep pcregrep.c)
+TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})
+
+# Removed by PH (2008-01-23) because pcredemo shouldn't really be built
+# automatically, and it gave trouble in some environments anyway.
+# ADD_EXECUTABLE(pcredemo pcredemo.c)
+# TARGET_LINK_LIBRARIES(pcredemo pcreposix)
+# IF(NOT BUILD_SHARED_LIBS)
+#     # make sure to not use declspec(dllimport) in static mode on windows
+#         SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")
+# ENDIF(NOT BUILD_SHARED_LIBS)
+
+IF(PCRE_BUILD_PCRECPP)
+        ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
+        TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp)
+IF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
+SET_TARGET_PROPERTIES(pcrecpp
+                        PROPERTIES PREFIX ""
+)
+ENDIF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
+
+
+        ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc)
+        TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp)
+
+        ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc)
+        TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
+ENDIF(PCRE_BUILD_PCRECPP)
+
+# Testing
+
+ENABLE_TESTING()
+
+GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
+GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
+
+# Write out a CTest configuration file that sets some needed environment
+# variables for the test scripts.
+#
+FILE(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.ctest
+"# This is a generated file.
+SET(ENV{srcdir} ${CMAKE_SOURCE_DIR})
+SET(ENV{pcregrep} ${PCREGREP_EXE})
+SET(ENV{pcretest} ${PCRETEST_EXE})
+")
+
+IF(UNIX)
+        ADD_TEST(pcre_test      ${CMAKE_SOURCE_DIR}/RunTest)
+        ADD_TEST(pcre_grep_test ${CMAKE_SOURCE_DIR}/RunGrepTest)
+ENDIF(UNIX)
+IF(WIN32)
+        ADD_TEST(pcre_test cmd /C ${CMAKE_SOURCE_DIR}/RunTest.bat)
+ENDIF(WIN32)
+
+GET_TARGET_PROPERTY(PCRECPP_UNITTEST_EXE
+                    pcrecpp_unittest
+                    DEBUG_LOCATION)
+
+GET_TARGET_PROPERTY(PCRE_SCANNER_UNITTEST_EXE
+                    pcre_scanner_unittest
+                    DEBUG_LOCATION)
+
+GET_TARGET_PROPERTY(PCRE_STRINGPIECE_UNITTEST_EXE
+                    pcre_stringpiece_unittest
+                    DEBUG_LOCATION)
+
+ADD_TEST(pcrecpp_test          ${PCRECPP_UNITTEST_EXE})
+ADD_TEST(pcre_scanner_test     ${PCRE_SCANNER_UNITTEST_EXE})
+ADD_TEST(pcre_stringpiece_test ${PCRE_STRINGPIECE_UNITTEST_EXE})
+
+# Installation
+
+SET(CMAKE_INSTALL_ALWAYS 1)
+
+INSTALL(TARGETS pcre pcreposix pcregrep pcretest
+        RUNTIME DESTINATION bin
+        LIBRARY DESTINATION lib
+        ARCHIVE DESTINATION lib)
+
+INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
+
+FILE(GLOB html ${CMAKE_SOURCE_DIR}/doc/html/*.html)
+FILE(GLOB man1 ${CMAKE_SOURCE_DIR}/doc/*.1)
+FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3)
+
+IF(PCRE_BUILD_PCRECPP)
+        INSTALL(TARGETS pcrecpp
+                RUNTIME DESTINATION bin
+                LIBRARY DESTINATION lib
+                ARCHIVE DESTINATION lib)
+        INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
+ELSE(PCRE_BUILD_PCRECPP)
+        # Remove pcrecpp.3
+        FOREACH(man ${man3})
+                GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
+                IF(NOT man_tmp STREQUAL "pcrecpp.3")
+                        SET(man3_new ${man3} ${man})
+                ENDIF(NOT man_tmp STREQUAL "pcrecpp.3")
+        ENDFOREACH(man ${man3})
+        SET(man3 ${man3_new})
+ENDIF(PCRE_BUILD_PCRECPP)
+
+
+INSTALL(FILES ${man1} DESTINATION man/man1)
+INSTALL(FILES ${man3} DESTINATION man/man3)
+INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
+
+# help, only for nice output
+IF(BUILD_SHARED_LIBS)
+  SET(BUILD_STATIC_LIBS OFF)
+ELSE(BUILD_SHARED_LIBS)
+  SET(BUILD_STATIC_LIBS ON)
+ENDIF(BUILD_SHARED_LIBS)
+
+MESSAGE(STATUS "")
+MESSAGE(STATUS "")
+MESSAGE(STATUS "PCRE configuration summary:")
+MESSAGE(STATUS "")
+MESSAGE(STATUS "  Install prefix .................. : " ${CMAKE_INSTALL_PREFIX})
+MESSAGE(STATUS "  C compiler ...................... : " ${CMAKE_C_COMPILER})
+MESSAGE(STATUS "  C++ compiler .................... : " ${CMAKE_CXX_COMPILER})
+MESSAGE(STATUS "  C compiler flags ................ : " ${CMAKE_C_FLAGS})   #FIXME
+MESSAGE(STATUS "  C++ compiler flags .............. : " ${CMAKE_CXX_FLAGS}) #FIXME
+MESSAGE(STATUS "")
+MESSAGE(STATUS "  Build C++ library ............... : " ${PCRE_BUILD_PCRECPP})
+MESSAGE(STATUS "  Enable UTF-8 support ............ : " ${PCRE_SUPPORT_UNICODE_PROPERTIES})
+MESSAGE(STATUS "  Unicode properties .............. : " ${PCRE_SUPPORT_UNICODE_PROPERTIES})
+MESSAGE(STATUS "  Newline char/sequence ........... : " ${PCRE_NEWLINE})
+MESSAGE(STATUS "  \\R matches only ANYCRLF ......... : " ${PCRE_SUPPORT_BSR_ANYCRLF})
+MESSAGE(STATUS "  EBCDIC coding ................... : " ${PCRE_EBCDIC})
+MESSAGE(STATUS "  Rebuild char tables ............. : " ${PCRE_REBUILD_CHARTABLES})
+MESSAGE(STATUS "  No stack recursion .............. : " ${PCRE_NO_RECURSE})
+MESSAGE(STATUS "  POSIX mem threshold ............. : " ${PCRE_POSIX_MALLOC_THRESHOLD})
+MESSAGE(STATUS "  Internal link size .............. : " ${PCRE_LINK_SIZE})
+MESSAGE(STATUS "  Match limit ..................... : " ${PCRE_MATCH_LIMIT})
+MESSAGE(STATUS "  Match limit recursion ........... : " ${PCRE_MATCH_LIMIT_RECURSION})
+MESSAGE(STATUS "  Build shared libs ............... : " ${BUILD_SHARED_LIBS})
+MESSAGE(STATUS "  Build static libs ............... : " ${BUILD_STATIC_LIBS})
+IF(ZLIB_FOUND)
+  MESSAGE(STATUS "  Link pcregrep with libz ......... : " ${PCRE_SUPPORT_LIBZ})
+ELSE(ZLIB_FOUND)
+  MESSAGE(STATUS "  Link pcregrep with libz ......... : None" )
+ENDIF(ZLIB_FOUND)
+IF(BZIP2_FOUND)
+  MESSAGE(STATUS "  Link pcregrep with libbz2 ....... : " ${PCRE_SUPPORT_LIBBZ2})
+ELSE(BZIP2_FOUND)
+  MESSAGE(STATUS "  Link pcregrep with libbz2 ....... : None" )
+ENDIF(BZIP2_FOUND)
+IF(NOT PCRE_SUPPORT_LIBREADLINE)
+  MESSAGE(STATUS "  Link pcretest with libreadline .. : None" )
+ELSE(NOT PCRE_SUPPORT_LIBREADLINE)
+  MESSAGE(STATUS "  Link pcretest with libreadline .. : " ${PCRE_SUPPORT_LIBREADLINE})
+ENDIF(NOT PCRE_SUPPORT_LIBREADLINE)
+IF(MINGW AND NOT PCRE_STATIC)
+  MESSAGE(STATUS "  Non-standard dll names (prefix) . : " ${NON_STANDARD_LIB_PREFIX})
+  MESSAGE(STATUS "  Non-standard dll names (suffix) . : " ${NON_STANDARD_LIB_SUFFIX})
+ENDIF(MINGW AND NOT PCRE_STATIC)
+MESSAGE(STATUS "")
+
+# end CMakeLists.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/COPYING	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,5 @@
+PCRE LICENCE
+
+Please see the file LICENCE in the PCRE distribution for licensing details.
+
+End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/ChangeLog	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3386 @@
+ChangeLog for PCRE
+------------------
+
+Version 7.8 05-Sep-08
+---------------------
+
+1.  Replaced UCP searching code with optimized version as implemented for Ad
+    Muncher (http://www.admuncher.com/) by Peter Kankowski. This uses a two-
+    stage table and inline lookup instead of a function, giving speed ups of 2
+    to 5 times on some simple patterns that I tested. Permission was given to
+    distribute the MultiStage2.py script that generates the tables (it's not in
+    the tarball, but is in the Subversion repository).
+
+2.  Updated the Unicode datatables to Unicode 5.1.0. This adds yet more
+    scripts.
+
+3.  Change 12 for 7.7 introduced a bug in pcre_study() when a pattern contained
+    a group with a zero qualifier. The result of the study could be incorrect,
+    or the function might crash, depending on the pattern.
+
+4.  Caseless matching was not working for non-ASCII characters in back
+    references. For example, /(\x{de})\1/8i was not matching \x{de}\x{fe}.
+    It now works when Unicode Property Support is available.
+
+5.  In pcretest, an escape such as \x{de} in the data was always generating
+    a UTF-8 string, even in non-UTF-8 mode. Now it generates a single byte in
+    non-UTF-8 mode. If the value is greater than 255, it gives a warning about
+    truncation.
+
+6.  Minor bugfix in pcrecpp.cc (change "" == ... to NULL == ...).
+
+7.  Added two (int) casts to pcregrep when printing the difference of two
+    pointers, in case they are 64-bit values.
+
+8.  Added comments about Mac OS X stack usage to the pcrestack man page and to
+    test 2 if it fails.
+
+9.  Added PCRE_CALL_CONVENTION just before the names of all exported functions,
+    and a #define of that name to empty if it is not externally set. This is to
+    allow users of MSVC to set it if necessary.
+
+10. The PCRE_EXP_DEFN macro which precedes exported functions was missing from
+    the convenience functions in the pcre_get.c source file.
+
+11. An option change at the start of a pattern that had top-level alternatives
+    could cause overwriting and/or a crash. This command provoked a crash in
+    some environments:
+
+      printf "/(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]/8\n" | pcretest
+
+    This potential security problem was recorded as CVE-2008-2371.
+
+12. For a pattern where the match had to start at the beginning or immediately
+    after a newline (e.g /.*anything/ without the DOTALL flag), pcre_exec() and
+    pcre_dfa_exec() could read past the end of the passed subject if there was
+    no match. To help with detecting such bugs (e.g. with valgrind), I modified
+    pcretest so that it places the subject at the end of its malloc-ed buffer.
+
+13. The change to pcretest in 12 above threw up a couple more cases when pcre_
+    exec() might read past the end of the data buffer in UTF-8 mode.
+
+14. A similar bug to 7.3/2 existed when the PCRE_FIRSTLINE option was set and
+    the data contained the byte 0x85 as part of a UTF-8 character within its
+    first line. This applied both to normal and DFA matching.
+
+15. Lazy qualifiers were not working in some cases in UTF-8 mode. For example,
+    /^[^d]*?$/8 failed to match "abc".
+
+16. Added a missing copyright notice to pcrecpp_internal.h.
+
+17. Make it more clear in the documentation that values returned from
+    pcre_exec() in ovector are byte offsets, not character counts.
+
+18. Tidied a few places to stop certain compilers from issuing warnings.
+
+19. Updated the Virtual Pascal + BCC files to compile the latest v7.7, as
+    supplied by Stefan Weber. I made a further small update for 7.8 because
+    there is a change of source arrangements: the pcre_searchfuncs.c module is
+    replaced by pcre_ucd.c.
+
+
+Version 7.7 07-May-08
+---------------------
+
+1.  Applied Craig's patch to sort out a long long problem: "If we can't convert
+    a string to a long long, pretend we don't even have a long long." This is
+    done by checking for the strtoq, strtoll, and _strtoi64 functions.
+
+2.  Applied Craig's patch to pcrecpp.cc to restore ABI compatibility with
+    pre-7.6 versions, which defined a global no_arg variable instead of putting
+    it in the RE class. (See also #8 below.)
+
+3.  Remove a line of dead code, identified by coverity and reported by Nuno
+    Lopes.
+
+4.  Fixed two related pcregrep bugs involving -r with --include or --exclude:
+
+    (1) The include/exclude patterns were being applied to the whole pathnames
+        of files, instead of just to the final components.
+
+    (2) If there was more than one level of directory, the subdirectories were
+        skipped unless they satisfied the include/exclude conditions. This is
+        inconsistent with GNU grep (and could even be seen as contrary to the
+        pcregrep specification - which I improved to make it absolutely clear).
+        The action now is always to scan all levels of directory, and just
+        apply the include/exclude patterns to regular files.
+
+5.  Added the --include_dir and --exclude_dir patterns to pcregrep, and used
+    --exclude_dir in the tests to avoid scanning .svn directories.
+
+6.  Applied Craig's patch to the QuoteMeta function so that it escapes the
+    NUL character as backslash + 0 rather than backslash + NUL, because PCRE
+    doesn't support NULs in patterns.
+
+7.  Added some missing "const"s to declarations of static tables in
+    pcre_compile.c and pcre_dfa_exec.c.
+
+8.  Applied Craig's patch to pcrecpp.cc to fix a problem in OS X that was
+    caused by fix #2  above. (Subsequently also a second patch to fix the
+    first patch. And a third patch - this was a messy problem.)
+
+9.  Applied Craig's patch to remove the use of push_back().
+
+10. Applied Alan Lehotsky's patch to add REG_STARTEND support to the POSIX
+    matching function regexec().
+
+11. Added support for the Oniguruma syntax \g<name>, \g<n>, \g'name', \g'n',
+    which, however, unlike Perl's \g{...}, are subroutine calls, not back
+    references. PCRE supports relative numbers with this syntax (I don't think
+    Oniguruma does).
+
+12. Previously, a group with a zero repeat such as (...){0} was completely
+    omitted from the compiled regex. However, this means that if the group
+    was called as a subroutine from elsewhere in the pattern, things went wrong
+    (an internal error was given). Such groups are now left in the compiled
+    pattern, with a new opcode that causes them to be skipped at execution
+    time.
+
+13. Added the PCRE_JAVASCRIPT_COMPAT option. This makes the following changes
+    to the way PCRE behaves:
+
+    (a) A lone ] character is dis-allowed (Perl treats it as data).
+
+    (b) A back reference to an unmatched subpattern matches an empty string
+        (Perl fails the current match path).
+
+    (c) A data ] in a character class must be notated as \] because if the
+        first data character in a class is ], it defines an empty class. (In
+        Perl it is not possible to have an empty class.) The empty class []
+        never matches; it forces failure and is equivalent to (*FAIL) or (?!).
+        The negative empty class [^] matches any one character, independently
+        of the DOTALL setting.
+
+14. A pattern such as /(?2)[]a()b](abc)/ which had a forward reference to a
+    non-existent subpattern following a character class starting with ']' and
+    containing () gave an internal compiling error instead of "reference to
+    non-existent subpattern". Fortunately, when the pattern did exist, the
+    compiled code was correct. (When scanning forwards to check for the
+    existencd of the subpattern, it was treating the data ']' as terminating
+    the class, so got the count wrong. When actually compiling, the reference
+    was subsequently set up correctly.)
+
+15. The "always fail" assertion (?!) is optimzed to (*FAIL) by pcre_compile;
+    it was being rejected as not supported by pcre_dfa_exec(), even though
+    other assertions are supported. I have made pcre_dfa_exec() support
+    (*FAIL).
+
+16. The implementation of 13c above involved the invention of a new opcode,
+    OP_ALLANY, which is like OP_ANY but doesn't check the /s flag. Since /s
+    cannot be changed at match time, I realized I could make a small
+    improvement to matching performance by compiling OP_ALLANY instead of
+    OP_ANY for "." when DOTALL was set, and then removing the runtime tests
+    on the OP_ANY path.
+
+17. Compiling pcretest on Windows with readline support failed without the
+    following two fixes: (1) Make the unistd.h include conditional on
+    HAVE_UNISTD_H; (2) #define isatty and fileno as _isatty and _fileno.
+
+18. Changed CMakeLists.txt and cmake/FindReadline.cmake to arrange for the
+    ncurses library to be included for pcretest when ReadLine support is
+    requested, but also to allow for it to be overridden. This patch came from
+    Daniel Bergström.
+
+19. There was a typo in the file ucpinternal.h where f0_rangeflag was defined
+    as 0x00f00000 instead of 0x00800000. Luckily, this would not have caused
+    any errors with the current Unicode tables. Thanks to Peter Kankowski for
+    spotting this.
+
+
+Version 7.6 28-Jan-08
+---------------------
+
+1.  A character class containing a very large number of characters with
+    codepoints greater than 255 (in UTF-8 mode, of course) caused a buffer
+    overflow.
+
+2.  Patch to cut out the "long long" test in pcrecpp_unittest when
+    HAVE_LONG_LONG is not defined.
+
+3.  Applied Christian Ehrlicher's patch to update the CMake build files to
+    bring them up to date and include new features. This patch includes:
+
+    - Fixed PH's badly added libz and libbz2 support.
+    - Fixed a problem with static linking.
+    - Added pcredemo. [But later removed - see 7 below.]
+    - Fixed dftables problem and added an option.
+    - Added a number of HAVE_XXX tests, including HAVE_WINDOWS_H and
+        HAVE_LONG_LONG.
+    - Added readline support for pcretest.
+    - Added an listing of the option settings after cmake has run.
+
+4.  A user submitted a patch to Makefile that makes it easy to create
+    "pcre.dll" under mingw when using Configure/Make. I added stuff to
+    Makefile.am that cause it to include this special target, without
+    affecting anything else. Note that the same mingw target plus all
+    the other distribution libraries and programs are now supported
+    when configuring with CMake (see 6 below) instead of with
+    Configure/Make.
+
+5.  Applied Craig's patch that moves no_arg into the RE class in the C++ code.
+    This is an attempt to solve the reported problem "pcrecpp::no_arg is not
+    exported in the Windows port". It has not yet been confirmed that the patch
+    solves the problem, but it does no harm.
+
+6.  Applied Sheri's patch to CMakeLists.txt to add NON_STANDARD_LIB_PREFIX and
+    NON_STANDARD_LIB_SUFFIX for dll names built with mingw when configured
+    with CMake, and also correct the comment about stack recursion.
+
+7.  Remove the automatic building of pcredemo from the ./configure system and
+    from CMakeLists.txt. The whole idea of pcredemo.c is that it is an example
+    of a program that users should build themselves after PCRE is installed, so
+    building it automatically is not really right. What is more, it gave
+    trouble in some build environments.
+
+8.  Further tidies to CMakeLists.txt from Sheri and Christian.
+
+
+Version 7.5 10-Jan-08
+---------------------
+
+1.  Applied a patch from Craig: "This patch makes it possible to 'ignore'
+    values in parens when parsing an RE using the C++ wrapper."
+
+2.  Negative specials like \S did not work in character classes in UTF-8 mode.
+    Characters greater than 255 were excluded from the class instead of being
+    included.
+
+3.  The same bug as (2) above applied to negated POSIX classes such as
+    [:^space:].
+
+4.  PCRECPP_STATIC was referenced in pcrecpp_internal.h, but nowhere was it
+    defined or documented. It seems to have been a typo for PCRE_STATIC, so
+    I have changed it.
+
+5.  The construct (?&) was not diagnosed as a syntax error (it referenced the
+    first named subpattern) and a construct such as (?&a) would reference the
+    first named subpattern whose name started with "a" (in other words, the
+    length check was missing). Both these problems are fixed. "Subpattern name
+    expected" is now given for (?&) (a zero-length name), and this patch also
+    makes it give the same error for \k'' (previously it complained that that
+    was a reference to a non-existent subpattern).
+
+6.  The erroneous patterns (?+-a) and (?-+a) give different error messages;
+    this is right because (?- can be followed by option settings as well as by
+    digits. I have, however, made the messages clearer.
+
+7.  Patterns such as (?(1)a|b) (a pattern that contains fewer subpatterns
+    than the number used in the conditional) now cause a compile-time error.
+    This is actually not compatible with Perl, which accepts such patterns, but
+    treats the conditional as always being FALSE (as PCRE used to), but it
+    seems to me that giving a diagnostic is better.
+
+8.  Change "alphameric" to the more common word "alphanumeric" in comments
+    and messages.
+
+9.  Fix two occurrences of "backslash" in comments that should have been
+    "backspace".
+
+10. Remove two redundant lines of code that can never be obeyed (their function
+    was moved elsewhere).
+
+11. The program that makes PCRE's Unicode character property table had a bug
+    which caused it to generate incorrect table entries for sequences of
+    characters that have the same character type, but are in different scripts.
+    It amalgamated them into a single range, with the script of the first of
+    them. In other words, some characters were in the wrong script. There were
+    thirteen such cases, affecting characters in the following ranges:
+
+      U+002b0 - U+002c1
+      U+0060c - U+0060d
+      U+0061e - U+00612
+      U+0064b - U+0065e
+      U+0074d - U+0076d
+      U+01800 - U+01805
+      U+01d00 - U+01d77
+      U+01d9b - U+01dbf
+      U+0200b - U+0200f
+      U+030fc - U+030fe
+      U+03260 - U+0327f
+      U+0fb46 - U+0fbb1
+      U+10450 - U+1049d
+
+12. The -o option (show only the matching part of a line) for pcregrep was not
+    compatible with GNU grep in that, if there was more than one match in a
+    line, it showed only the first of them. It now behaves in the same way as
+    GNU grep.
+
+13. If the -o and -v options were combined for pcregrep, it printed a blank
+    line for every non-matching line. GNU grep prints nothing, and pcregrep now
+    does the same. The return code can be used to tell if there were any
+    non-matching lines.
+
+14. Added --file-offsets and --line-offsets to pcregrep.
+
+15. The pattern (?=something)(?R) was not being diagnosed as a potentially
+    infinitely looping recursion. The bug was that positive lookaheads were not
+    being skipped when checking for a possible empty match (negative lookaheads
+    and both kinds of lookbehind were skipped).
+
+16. Fixed two typos in the Windows-only code in pcregrep.c, and moved the
+    inclusion of <windows.h> to before rather than after the definition of
+    INVALID_FILE_ATTRIBUTES (patch from David Byron).
+
+17. Specifying a possessive quantifier with a specific limit for a Unicode
+    character property caused pcre_compile() to compile bad code, which led at
+    runtime to PCRE_ERROR_INTERNAL (-14). Examples of patterns that caused this
+    are: /\p{Zl}{2,3}+/8 and /\p{Cc}{2}+/8. It was the possessive "+" that
+    caused the error; without that there was no problem.
+
+18. Added --enable-pcregrep-libz and --enable-pcregrep-libbz2.
+
+19. Added --enable-pcretest-libreadline.
+
+20. In pcrecpp.cc, the variable 'count' was incremented twice in
+    RE::GlobalReplace(). As a result, the number of replacements returned was
+    double what it should be. I removed one of the increments, but Craig sent a
+    later patch that removed the other one (the right fix) and added unit tests
+    that check the return values (which was not done before).
+
+21. Several CMake things:
+
+    (1) Arranged that, when cmake is used on Unix, the libraries end up with
+        the names libpcre and libpcreposix, not just pcre and pcreposix.
+
+    (2) The above change means that pcretest and pcregrep are now correctly
+        linked with the newly-built libraries, not previously installed ones.
+
+    (3) Added PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, PCRE_SUPPORT_LIBBZ2.
+
+22. In UTF-8 mode, with newline set to "any", a pattern such as .*a.*=.b.*
+    crashed when matching a string such as a\x{2029}b (note that \x{2029} is a
+    UTF-8 newline character). The key issue is that the pattern starts .*;
+    this means that the match must be either at the beginning, or after a
+    newline. The bug was in the code for advancing after a failed match and
+    checking that the new position followed a newline. It was not taking
+    account of UTF-8 characters correctly.
+
+23. PCRE was behaving differently from Perl in the way it recognized POSIX
+    character classes. PCRE was not treating the sequence [:...:] as a
+    character class unless the ... were all letters. Perl, however, seems to
+    allow any characters between [: and :], though of course it rejects as
+    unknown any "names" that contain non-letters, because all the known class
+    names consist only of letters. Thus, Perl gives an error for [[:1234:]],
+    for example, whereas PCRE did not - it did not recognize a POSIX character
+    class. This seemed a bit dangerous, so the code has been changed to be
+    closer to Perl. The behaviour is not identical to Perl, because PCRE will
+    diagnose an unknown class for, for example, [[:l\ower:]] where Perl will
+    treat it as [[:lower:]]. However, PCRE does now give "unknown" errors where
+    Perl does, and where it didn't before.
+
+24. Rewrite so as to remove the single use of %n from pcregrep because in some
+    Windows environments %n is disabled by default.
+
+
+Version 7.4 21-Sep-07
+---------------------
+
+1.  Change 7.3/28 was implemented for classes by looking at the bitmap. This
+    means that a class such as [\s] counted as "explicit reference to CR or
+    LF". That isn't really right - the whole point of the change was to try to
+    help when there was an actual mention of one of the two characters. So now
+    the change happens only if \r or \n (or a literal CR or LF) character is
+    encountered.
+
+2.  The 32-bit options word was also used for 6 internal flags, but the numbers
+    of both had grown to the point where there were only 3 bits left.
+    Fortunately, there was spare space in the data structure, and so I have
+    moved the internal flags into a new 16-bit field to free up more option
+    bits.
+
+3.  The appearance of (?J) at the start of a pattern set the DUPNAMES option,
+    but did not set the internal JCHANGED flag - either of these is enough to
+    control the way the "get" function works - but the PCRE_INFO_JCHANGED
+    facility is supposed to tell if (?J) was ever used, so now (?J) at the
+    start sets both bits.
+
+4.  Added options (at build time, compile time, exec time) to change \R from
+    matching any Unicode line ending sequence to just matching CR, LF, or CRLF.
+
+5.  doc/pcresyntax.html was missing from the distribution.
+
+6.  Put back the definition of PCRE_ERROR_NULLWSLIMIT, for backward
+    compatibility, even though it is no longer used.
+
+7.  Added macro for snprintf to pcrecpp_unittest.cc and also for strtoll and
+    strtoull to pcrecpp.cc to select the available functions in WIN32 when the
+    windows.h file is present (where different names are used). [This was
+    reversed later after testing - see 16 below.]
+
+8.  Changed all #include <config.h> to #include "config.h". There were also
+    some further <pcre.h> cases that I changed to "pcre.h".
+
+9.  When pcregrep was used with the --colour option, it missed the line ending
+    sequence off the lines that it output.
+
+10. It was pointed out to me that arrays of string pointers cause lots of
+    relocations when a shared library is dynamically loaded. A technique of
+    using a single long string with a table of offsets can drastically reduce
+    these. I have refactored PCRE in four places to do this. The result is
+    dramatic:
+
+      Originally:                          290
+      After changing UCP table:            187
+      After changing error message table:   43
+      After changing table of "verbs"       36
+      After changing table of Posix names   22
+
+    Thanks to the folks working on Gregex for glib for this insight.
+
+11. --disable-stack-for-recursion caused compiling to fail unless -enable-
+    unicode-properties was also set.
+
+12. Updated the tests so that they work when \R is defaulted to ANYCRLF.
+
+13. Added checks for ANY and ANYCRLF to pcrecpp.cc where it previously
+    checked only for CRLF.
+
+14. Added casts to pcretest.c to avoid compiler warnings.
+
+15. Added Craig's patch to various pcrecpp modules to avoid compiler warnings.
+
+16. Added Craig's patch to remove the WINDOWS_H tests, that were not working,
+    and instead check for _strtoi64 explicitly, and avoid the use of snprintf()
+    entirely. This removes changes made in 7 above.
+
+17. The CMake files have been updated, and there is now more information about
+    building with CMake in the NON-UNIX-USE document.
+
+
+Version 7.3 28-Aug-07
+---------------------
+
+ 1. In the rejigging of the build system that eventually resulted in 7.1, the
+    line "#include <pcre.h>" was included in pcre_internal.h. The use of angle
+    brackets there is not right, since it causes compilers to look for an
+    installed pcre.h, not the version that is in the source that is being
+    compiled (which of course may be different). I have changed it back to:
+
+      #include "pcre.h"
+
+    I have a vague recollection that the change was concerned with compiling in
+    different directories, but in the new build system, that is taken care of
+    by the VPATH setting the Makefile.
+
+ 2. The pattern .*$ when run in not-DOTALL UTF-8 mode with newline=any failed
+    when the subject happened to end in the byte 0x85 (e.g. if the last
+    character was \x{1ec5}). *Character* 0x85 is one of the "any" newline
+    characters but of course it shouldn't be taken as a newline when it is part
+    of another character. The bug was that, for an unlimited repeat of . in
+    not-DOTALL UTF-8 mode, PCRE was advancing by bytes rather than by
+    characters when looking for a newline.
+
+ 3. A small performance improvement in the DOTALL UTF-8 mode .* case.
+
+ 4. Debugging: adjusted the names of opcodes for different kinds of parentheses
+    in debug output.
+
+ 5. Arrange to use "%I64d" instead of "%lld" and "%I64u" instead of "%llu" for
+    long printing in the pcrecpp unittest when running under MinGW.
+
+ 6. ESC_K was left out of the EBCDIC table.
+
+ 7. Change 7.0/38 introduced a new limit on the number of nested non-capturing
+    parentheses; I made it 1000, which seemed large enough. Unfortunately, the
+    limit also applies to "virtual nesting" when a pattern is recursive, and in
+    this case 1000 isn't so big. I have been able to remove this limit at the
+    expense of backing off one optimization in certain circumstances. Normally,
+    when pcre_exec() would call its internal match() function recursively and
+    immediately return the result unconditionally, it uses a "tail recursion"
+    feature to save stack. However, when a subpattern that can match an empty
+    string has an unlimited repetition quantifier, it no longer makes this
+    optimization. That gives it a stack frame in which to save the data for
+    checking that an empty string has been matched. Previously this was taken
+    from the 1000-entry workspace that had been reserved. So now there is no
+    explicit limit, but more stack is used.
+
+ 8. Applied Daniel's patches to solve problems with the import/export magic
+    syntax that is required for Windows, and which was going wrong for the
+    pcreposix and pcrecpp parts of the library. These were overlooked when this
+    problem was solved for the main library.
+
+ 9. There were some crude static tests to avoid integer overflow when computing
+    the size of patterns that contain repeated groups with explicit upper
+    limits. As the maximum quantifier is 65535, the maximum group length was
+    set at 30,000 so that the product of these two numbers did not overflow a
+    32-bit integer. However, it turns out that people want to use groups that
+    are longer than 30,000 bytes (though not repeat them that many times).
+    Change 7.0/17 (the refactoring of the way the pattern size is computed) has
+    made it possible to implement the integer overflow checks in a much more
+    dynamic way, which I have now done. The artificial limitation on group
+    length has been removed - we now have only the limit on the total length of
+    the compiled pattern, which depends on the LINK_SIZE setting.
+
+10. Fixed a bug in the documentation for get/copy named substring when
+    duplicate names are permitted. If none of the named substrings are set, the
+    functions return PCRE_ERROR_NOSUBSTRING (7); the doc said they returned an
+    empty string.
+
+11. Because Perl interprets \Q...\E at a high level, and ignores orphan \E
+    instances, patterns such as [\Q\E] or [\E] or even [^\E] cause an error,
+    because the ] is interpreted as the first data character and the
+    terminating ] is not found. PCRE has been made compatible with Perl in this
+    regard. Previously, it interpreted [\Q\E] as an empty class, and [\E] could
+    cause memory overwriting.
+
+10. Like Perl, PCRE automatically breaks an unlimited repeat after an empty
+    string has been matched (to stop an infinite loop). It was not recognizing
+    a conditional subpattern that could match an empty string if that
+    subpattern was within another subpattern. For example, it looped when
+    trying to match  (((?(1)X|))*)  but it was OK with  ((?(1)X|)*)  where the
+    condition was not nested. This bug has been fixed.
+
+12. A pattern like \X?\d or \P{L}?\d in non-UTF-8 mode could cause a backtrack
+    past the start of the subject in the presence of bytes with the top bit
+    set, for example "\x8aBCD".
+
+13. Added Perl 5.10 experimental backtracking controls (*FAIL), (*F), (*PRUNE),
+    (*SKIP), (*THEN), (*COMMIT), and (*ACCEPT).
+
+14. Optimized (?!) to (*FAIL).
+
+15. Updated the test for a valid UTF-8 string to conform to the later RFC 3629.
+    This restricts code points to be within the range 0 to 0x10FFFF, excluding
+    the "low surrogate" sequence 0xD800 to 0xDFFF. Previously, PCRE allowed the
+    full range 0 to 0x7FFFFFFF, as defined by RFC 2279. Internally, it still
+    does: it's just the validity check that is more restrictive.
+
+16. Inserted checks for integer overflows during escape sequence (backslash)
+    processing, and also fixed erroneous offset values for syntax errors during
+    backslash processing.
+
+17. Fixed another case of looking too far back in non-UTF-8 mode (cf 12 above)
+    for patterns like [\PPP\x8a]{1,}\x80 with the subject "A\x80".
+
+18. An unterminated class in a pattern like (?1)\c[ with a "forward reference"
+    caused an overrun.
+
+19. A pattern like (?:[\PPa*]*){8,} which had an "extended class" (one with
+    something other than just ASCII characters) inside a group that had an
+    unlimited repeat caused a loop at compile time (while checking to see
+    whether the group could match an empty string).
+
+20. Debugging a pattern containing \p or \P could cause a crash. For example,
+    [\P{Any}] did so. (Error in the code for printing property names.)
+
+21. An orphan \E inside a character class could cause a crash.
+
+22. A repeated capturing bracket such as (A)? could cause a wild memory
+    reference during compilation.
+
+23. There are several functions in pcre_compile() that scan along a compiled
+    expression for various reasons (e.g. to see if it's fixed length for look
+    behind). There were bugs in these functions when a repeated \p or \P was
+    present in the pattern. These operators have additional parameters compared
+    with \d, etc, and these were not being taken into account when moving along
+    the compiled data. Specifically:
+
+    (a) A item such as \p{Yi}{3} in a lookbehind was not treated as fixed
+        length.
+
+    (b) An item such as \pL+ within a repeated group could cause crashes or
+        loops.
+
+    (c) A pattern such as \p{Yi}+(\P{Yi}+)(?1) could give an incorrect
+        "reference to non-existent subpattern" error.
+
+    (d) A pattern like (\P{Yi}{2}\277)? could loop at compile time.
+
+24. A repeated \S or \W in UTF-8 mode could give wrong answers when multibyte
+    characters were involved (for example /\S{2}/8g with "A\x{a3}BC").
+
+25. Using pcregrep in multiline, inverted mode (-Mv) caused it to loop.
+
+26. Patterns such as [\P{Yi}A] which include \p or \P and just one other
+    character were causing crashes (broken optimization).
+
+27. Patterns such as (\P{Yi}*\277)* (group with possible zero repeat containing
+    \p or \P) caused a compile-time loop.
+
+28. More problems have arisen in unanchored patterns when CRLF is a valid line
+    break. For example, the unstudied pattern [\r\n]A does not match the string
+    "\r\nA" because change 7.0/46 below moves the current point on by two
+    characters after failing to match at the start. However, the pattern \nA
+    *does* match, because it doesn't start till \n, and if [\r\n]A is studied,
+    the same is true. There doesn't seem any very clean way out of this, but
+    what I have chosen to do makes the common cases work: PCRE now takes note
+    of whether there can be an explicit match for \r or \n anywhere in the
+    pattern, and if so, 7.0/46 no longer applies. As part of this change,
+    there's a new PCRE_INFO_HASCRORLF option for finding out whether a compiled
+    pattern has explicit CR or LF references.
+
+29. Added (*CR) etc for changing newline setting at start of pattern.
+
+
+Version 7.2 19-Jun-07
+---------------------
+
+ 1. If the fr_FR locale cannot be found for test 3, try the "french" locale,
+    which is apparently normally available under Windows.
+
+ 2. Re-jig the pcregrep tests with different newline settings in an attempt
+    to make them independent of the local environment's newline setting.
+
+ 3. Add code to configure.ac to remove -g from the CFLAGS default settings.
+
+ 4. Some of the "internals" tests were previously cut out when the link size
+    was not 2, because the output contained actual offsets. The recent new
+    "Z" feature of pcretest means that these can be cut out, making the tests
+    usable with all link sizes.
+
+ 5. Implemented Stan Switzer's goto replacement for longjmp() when not using
+    stack recursion. This gives a massive performance boost under BSD, but just
+    a small improvement under Linux. However, it saves one field in the frame
+    in all cases.
+
+ 6. Added more features from the forthcoming Perl 5.10:
+
+    (a) (?-n) (where n is a string of digits) is a relative subroutine or
+        recursion call. It refers to the nth most recently opened parentheses.
+
+    (b) (?+n) is also a relative subroutine call; it refers to the nth next
+        to be opened parentheses.
+
+    (c) Conditions that refer to capturing parentheses can be specified
+        relatively, for example, (?(-2)... or (?(+3)...
+
+    (d) \K resets the start of the current match so that everything before
+        is not part of it.
+
+    (e) \k{name} is synonymous with \k<name> and \k'name' (.NET compatible).
+
+    (f) \g{name} is another synonym - part of Perl 5.10's unification of
+        reference syntax.
+
+    (g) (?| introduces a group in which the numbering of parentheses in each
+        alternative starts with the same number.
+
+    (h) \h, \H, \v, and \V match horizontal and vertical whitespace.
+
+ 7. Added two new calls to pcre_fullinfo(): PCRE_INFO_OKPARTIAL and
+    PCRE_INFO_JCHANGED.
+
+ 8. A pattern such as  (.*(.)?)*  caused pcre_exec() to fail by either not
+    terminating or by crashing. Diagnosed by Viktor Griph; it was in the code
+    for detecting groups that can match an empty string.
+
+ 9. A pattern with a very large number of alternatives (more than several
+    hundred) was running out of internal workspace during the pre-compile
+    phase, where pcre_compile() figures out how much memory will be needed. A
+    bit of new cunning has reduced the workspace needed for groups with
+    alternatives. The 1000-alternative test pattern now uses 12 bytes of
+    workspace instead of running out of the 4096 that are available.
+
+10. Inserted some missing (unsigned int) casts to get rid of compiler warnings.
+
+11. Applied patch from Google to remove an optimization that didn't quite work.
+    The report of the bug said:
+
+      pcrecpp::RE("a*").FullMatch("aaa") matches, while
+      pcrecpp::RE("a*?").FullMatch("aaa") does not, and
+      pcrecpp::RE("a*?\\z").FullMatch("aaa") does again.
+
+12. If \p or \P was used in non-UTF-8 mode on a character greater than 127
+    it matched the wrong number of bytes.
+
+
+Version 7.1 24-Apr-07
+---------------------
+
+ 1. Applied Bob Rossi and Daniel G's patches to convert the build system to one
+    that is more "standard", making use of automake and other Autotools. There
+    is some re-arrangement of the files and adjustment of comments consequent
+    on this.
+
+ 2. Part of the patch fixed a problem with the pcregrep tests. The test of -r
+    for recursive directory scanning broke on some systems because the files
+    are not scanned in any specific order and on different systems the order
+    was different. A call to "sort" has been inserted into RunGrepTest for the
+    approprate test as a short-term fix. In the longer term there may be an
+    alternative.
+
+ 3. I had an email from Eric Raymond about problems translating some of PCRE's
+    man pages to HTML (despite the fact that I distribute HTML pages, some
+    people do their own conversions for various reasons). The problems
+    concerned the use of low-level troff macros .br and .in. I have therefore
+    removed all such uses from the man pages (some were redundant, some could
+    be replaced by .nf/.fi pairs). The 132html script that I use to generate
+    HTML has been updated to handle .nf/.fi and to complain if it encounters
+    .br or .in.
+
+ 4. Updated comments in configure.ac that get placed in config.h.in and also
+    arranged for config.h to be included in the distribution, with the name
+    config.h.generic, for the benefit of those who have to compile without
+    Autotools (compare pcre.h, which is now distributed as pcre.h.generic).
+
+ 5. Updated the support (such as it is) for Virtual Pascal, thanks to Stefan
+    Weber: (1) pcre_internal.h was missing some function renames; (2) updated
+    makevp.bat for the current PCRE, using the additional files
+    makevp_c.txt, makevp_l.txt, and pcregexp.pas.
+
+ 6. A Windows user reported a minor discrepancy with test 2, which turned out
+    to be caused by a trailing space on an input line that had got lost in his
+    copy. The trailing space was an accident, so I've just removed it.
+
+ 7. Add -Wl,-R... flags in pcre-config.in for *BSD* systems, as I'm told
+    that is needed.
+
+ 8. Mark ucp_table (in ucptable.h) and ucp_gentype (in pcre_ucp_searchfuncs.c)
+    as "const" (a) because they are and (b) because it helps the PHP
+    maintainers who have recently made a script to detect big data structures
+    in the php code that should be moved to the .rodata section. I remembered
+    to update Builducptable as well, so it won't revert if ucptable.h is ever
+    re-created.
+
+ 9. Added some extra #ifdef SUPPORT_UTF8 conditionals into pcretest.c,
+    pcre_printint.src, pcre_compile.c, pcre_study.c, and pcre_tables.c, in
+    order to be able to cut out the UTF-8 tables in the latter when UTF-8
+    support is not required. This saves 1.5-2K of code, which is important in
+    some applications.
+
+    Later: more #ifdefs are needed in pcre_ord2utf8.c and pcre_valid_utf8.c
+    so as not to refer to the tables, even though these functions will never be
+    called when UTF-8 support is disabled. Otherwise there are problems with a
+    shared library.
+
+10. Fixed two bugs in the emulated memmove() function in pcre_internal.h:
+
+    (a) It was defining its arguments as char * instead of void *.
+
+    (b) It was assuming that all moves were upwards in memory; this was true
+        a long time ago when I wrote it, but is no longer the case.
+
+    The emulated memove() is provided for those environments that have neither
+    memmove() nor bcopy(). I didn't think anyone used it these days, but that
+    is clearly not the case, as these two bugs were recently reported.
+
+11. The script PrepareRelease is now distributed: it calls 132html, CleanTxt,
+    and Detrail to create the HTML documentation, the .txt form of the man
+    pages, and it removes trailing spaces from listed files. It also creates
+    pcre.h.generic and config.h.generic from pcre.h and config.h. In the latter
+    case, it wraps all the #defines with #ifndefs. This script should be run
+    before "make dist".
+
+12. Fixed two fairly obscure bugs concerned with quantified caseless matching
+    with Unicode property support.
+
+    (a) For a maximizing quantifier, if the two different cases of the
+        character were of different lengths in their UTF-8 codings (there are
+        some cases like this - I found 11), and the matching function had to
+        back up over a mixture of the two cases, it incorrectly assumed they
+        were both the same length.
+
+    (b) When PCRE was configured to use the heap rather than the stack for
+        recursion during matching, it was not correctly preserving the data for
+        the other case of a UTF-8 character when checking ahead for a match
+        while processing a minimizing repeat. If the check also involved
+        matching a wide character, but failed, corruption could cause an
+        erroneous result when trying to check for a repeat of the original
+        character.
+
+13. Some tidying changes to the testing mechanism:
+
+    (a) The RunTest script now detects the internal link size and whether there
+        is UTF-8 and UCP support by running ./pcretest -C instead of relying on
+        values substituted by "configure". (The RunGrepTest script already did
+        this for UTF-8.) The configure.ac script no longer substitutes the
+        relevant variables.
+
+    (b) The debugging options /B and /D in pcretest show the compiled bytecode
+        with length and offset values. This means that the output is different
+        for different internal link sizes. Test 2 is skipped for link sizes
+        other than 2 because of this, bypassing the problem. Unfortunately,
+        there was also a test in test 3 (the locale tests) that used /B and
+        failed for link sizes other than 2. Rather than cut the whole test out,
+        I have added a new /Z option to pcretest that replaces the length and
+        offset values with spaces. This is now used to make test 3 independent
+        of link size. (Test 2 will be tidied up later.)
+
+14. If erroroffset was passed as NULL to pcre_compile, it provoked a
+    segmentation fault instead of returning the appropriate error message.
+
+15. In multiline mode when the newline sequence was set to "any", the pattern
+    ^$ would give a match between the \r and \n of a subject such as "A\r\nB".
+    This doesn't seem right; it now treats the CRLF combination as the line
+    ending, and so does not match in that case. It's only a pattern such as ^$
+    that would hit this one: something like ^ABC$ would have failed after \r
+    and then tried again after \r\n.
+
+16. Changed the comparison command for RunGrepTest from "diff -u" to "diff -ub"
+    in an attempt to make files that differ only in their line terminators
+    compare equal. This works on Linux.
+
+17. Under certain error circumstances pcregrep might try to free random memory
+    as it exited. This is now fixed, thanks to valgrind.
+
+19. In pcretest, if the pattern /(?m)^$/g<any> was matched against the string
+    "abc\r\n\r\n", it found an unwanted second match after the second \r. This
+    was because its rules for how to advance for /g after matching an empty
+    string at the end of a line did not allow for this case. They now check for
+    it specially.
+
+20. pcretest is supposed to handle patterns and data of any length, by
+    extending its buffers when necessary. It was getting this wrong when the
+    buffer for a data line had to be extended.
+
+21. Added PCRE_NEWLINE_ANYCRLF which is like ANY, but matches only CR, LF, or
+    CRLF as a newline sequence.
+
+22. Code for handling Unicode properties in pcre_dfa_exec() wasn't being cut
+    out by #ifdef SUPPORT_UCP. This did no harm, as it could never be used, but
+    I have nevertheless tidied it up.
+
+23. Added some casts to kill warnings from HP-UX ia64 compiler.
+
+24. Added a man page for pcre-config.
+
+
+Version 7.0 19-Dec-06
+---------------------
+
+ 1. Fixed a signed/unsigned compiler warning in pcre_compile.c, shown up by
+    moving to gcc 4.1.1.
+
+ 2. The -S option for pcretest uses setrlimit(); I had omitted to #include
+    sys/time.h, which is documented as needed for this function. It doesn't
+    seem to matter on Linux, but it showed up on some releases of OS X.
+
+ 3. It seems that there are systems where bytes whose values are greater than
+    127 match isprint() in the "C" locale. The "C" locale should be the
+    default when a C program starts up. In most systems, only ASCII printing
+    characters match isprint(). This difference caused the output from pcretest
+    to vary, making some of the tests fail. I have changed pcretest so that:
+
+    (a) When it is outputting text in the compiled version of a pattern, bytes
+        other than 32-126 are always shown as hex escapes.
+
+    (b) When it is outputting text that is a matched part of a subject string,
+        it does the same, unless a different locale has been set for the match
+        (using the /L modifier). In this case, it uses isprint() to decide.
+
+ 4. Fixed a major bug that caused incorrect computation of the amount of memory
+    required for a compiled pattern when options that changed within the
+    pattern affected the logic of the preliminary scan that determines the
+    length. The relevant options are -x, and -i in UTF-8 mode. The result was
+    that the computed length was too small. The symptoms of this bug were
+    either the PCRE error "internal error: code overflow" from pcre_compile(),
+    or a glibc crash with a message such as "pcretest: free(): invalid next
+    size (fast)". Examples of patterns that provoked this bug (shown in
+    pcretest format) are:
+
+      /(?-x: )/x
+      /(?x)(?-x: \s*#\s*)/
+      /((?i)[\x{c0}])/8
+      /(?i:[\x{c0}])/8
+
+    HOWEVER: Change 17 below makes this fix obsolete as the memory computation
+    is now done differently.
+
+ 5. Applied patches from Google to: (a) add a QuoteMeta function to the C++
+    wrapper classes; (b) implement a new function in the C++ scanner that is
+    more efficient than the old way of doing things because it avoids levels of
+    recursion in the regex matching; (c) add a paragraph to the documentation
+    for the FullMatch() function.
+
+ 6. The escape sequence \n was being treated as whatever was defined as
+    "newline". Not only was this contrary to the documentation, which states
+    that \n is character 10 (hex 0A), but it also went horribly wrong when
+    "newline" was defined as CRLF. This has been fixed.
+
+ 7. In pcre_dfa_exec.c the value of an unsigned integer (the variable called c)
+    was being set to -1 for the "end of line" case (supposedly a value that no
+    character can have). Though this value is never used (the check for end of
+    line is "zero bytes in current character"), it caused compiler complaints.
+    I've changed it to 0xffffffff.
+
+ 8. In pcre_version.c, the version string was being built by a sequence of
+    C macros that, in the event of PCRE_PRERELEASE being defined as an empty
+    string (as it is for production releases) called a macro with an empty
+    argument. The C standard says the result of this is undefined. The gcc
+    compiler treats it as an empty string (which was what was wanted) but it is
+    reported that Visual C gives an error. The source has been hacked around to
+    avoid this problem.
+
+ 9. On the advice of a Windows user, included <io.h> and <fcntl.h> in Windows
+    builds of pcretest, and changed the call to _setmode() to use _O_BINARY
+    instead of 0x8000. Made all the #ifdefs test both _WIN32 and WIN32 (not all
+    of them did).
+
+10. Originally, pcretest opened its input and output without "b"; then I was
+    told that "b" was needed in some environments, so it was added for release
+    5.0 to both the input and output. (It makes no difference on Unix-like
+    systems.) Later I was told that it is wrong for the input on Windows. I've
+    now abstracted the modes into two macros, to make it easier to fiddle with
+    them, and removed "b" from the input mode under Windows.
+
+11. Added pkgconfig support for the C++ wrapper library, libpcrecpp.
+
+12. Added -help and --help to pcretest as an official way of being reminded
+    of the options.
+
+13. Removed some redundant semicolons after macro calls in pcrecpparg.h.in
+    and pcrecpp.cc because they annoy compilers at high warning levels.
+
+14. A bit of tidying/refactoring in pcre_exec.c in the main bumpalong loop.
+
+15. Fixed an occurrence of == in configure.ac that should have been = (shell
+    scripts are not C programs :-) and which was not noticed because it works
+    on Linux.
+
+16. pcretest is supposed to handle any length of pattern and data line (as one
+    line or as a continued sequence of lines) by extending its input buffer if
+    necessary. This feature was broken for very long pattern lines, leading to
+    a string of junk being passed to pcre_compile() if the pattern was longer
+    than about 50K.
+
+17. I have done a major re-factoring of the way pcre_compile() computes the
+    amount of memory needed for a compiled pattern. Previously, there was code
+    that made a preliminary scan of the pattern in order to do this. That was
+    OK when PCRE was new, but as the facilities have expanded, it has become
+    harder and harder to keep it in step with the real compile phase, and there
+    have been a number of bugs (see for example, 4 above). I have now found a
+    cunning way of running the real compile function in a "fake" mode that
+    enables it to compute how much memory it would need, while actually only
+    ever using a few hundred bytes of working memory and without too many
+    tests of the mode. This should make future maintenance and development
+    easier. A side effect of this work is that the limit of 200 on the nesting
+    depth of parentheses has been removed (though this was never a serious
+    limitation, I suspect). However, there is a downside: pcre_compile() now
+    runs more slowly than before (30% or more, depending on the pattern). I
+    hope this isn't a big issue. There is no effect on runtime performance.
+
+18. Fixed a minor bug in pcretest: if a pattern line was not terminated by a
+    newline (only possible for the last line of a file) and it was a
+    pattern that set a locale (followed by /Lsomething), pcretest crashed.
+
+19. Added additional timing features to pcretest. (1) The -tm option now times
+    matching only, not compiling. (2) Both -t and -tm can be followed, as a
+    separate command line item, by a number that specifies the number of
+    repeats to use when timing. The default is 50000; this gives better
+    precision, but takes uncomfortably long for very large patterns.
+
+20. Extended pcre_study() to be more clever in cases where a branch of a
+    subpattern has no definite first character. For example, (a*|b*)[cd] would
+    previously give no result from pcre_study(). Now it recognizes that the
+    first character must be a, b, c, or d.
+
+21. There was an incorrect error "recursive call could loop indefinitely" if
+    a subpattern (or the entire pattern) that was being tested for matching an
+    empty string contained only one non-empty item after a nested subpattern.
+    For example, the pattern (?>\x{100}*)\d(?R) provoked this error
+    incorrectly, because the \d was being skipped in the check.
+
+22. The pcretest program now has a new pattern option /B and a command line
+    option -b, which is equivalent to adding /B to every pattern. This causes
+    it to show the compiled bytecode, without the additional information that
+    -d shows. The effect of -d is now the same as -b with -i (and similarly, /D
+    is the same as /B/I).
+
+23. A new optimization is now able automatically to treat some sequences such
+    as a*b as a*+b. More specifically, if something simple (such as a character
+    or a simple class like \d) has an unlimited quantifier, and is followed by
+    something that cannot possibly match the quantified thing, the quantifier
+    is automatically "possessified".
+
+24. A recursive reference to a subpattern whose number was greater than 39
+    went wrong under certain circumstances in UTF-8 mode. This bug could also
+    have affected the operation of pcre_study().
+
+25. Realized that a little bit of performance could be had by replacing
+    (c & 0xc0) == 0xc0 with c >= 0xc0 when processing UTF-8 characters.
+
+26. Timing data from pcretest is now shown to 4 decimal places instead of 3.
+
+27. Possessive quantifiers such as a++ were previously implemented by turning
+    them into atomic groups such as ($>a+). Now they have their own opcodes,
+    which improves performance. This includes the automatically created ones
+    from 23 above.
+
+28. A pattern such as (?=(\w+))\1: which simulates an atomic group using a
+    lookahead was broken if it was not anchored. PCRE was mistakenly expecting
+    the first matched character to be a colon. This applied both to named and
+    numbered groups.
+
+29. The ucpinternal.h header file was missing its idempotency #ifdef.
+
+30. I was sent a "project" file called libpcre.a.dev which I understand makes
+    building PCRE on Windows easier, so I have included it in the distribution.
+
+31. There is now a check in pcretest against a ridiculously large number being
+    returned by pcre_exec() or pcre_dfa_exec(). If this happens in a /g or /G
+    loop, the loop is abandoned.
+
+32. Forward references to subpatterns in conditions such as (?(2)...) where
+    subpattern 2 is defined later cause pcre_compile() to search forwards in
+    the pattern for the relevant set of parentheses. This search went wrong
+    when there were unescaped parentheses in a character class, parentheses
+    escaped with \Q...\E, or parentheses in a #-comment in /x mode.
+
+33. "Subroutine" calls and backreferences were previously restricted to
+    referencing subpatterns earlier in the regex. This restriction has now
+    been removed.
+
+34. Added a number of extra features that are going to be in Perl 5.10. On the
+    whole, these are just syntactic alternatives for features that PCRE had
+    previously implemented using the Python syntax or my own invention. The
+    other formats are all retained for compatibility.
+
+    (a) Named groups can now be defined as (?<name>...) or (?'name'...) as well
+        as (?P<name>...). The new forms, as well as being in Perl 5.10, are
+        also .NET compatible.
+
+    (b) A recursion or subroutine call to a named group can now be defined as
+        (?&name) as well as (?P>name).
+
+    (c) A backreference to a named group can now be defined as \k<name> or
+        \k'name' as well as (?P=name). The new forms, as well as being in Perl
+        5.10, are also .NET compatible.
+
+    (d) A conditional reference to a named group can now use the syntax
+        (?(<name>) or (?('name') as well as (?(name).
+
+    (e) A "conditional group" of the form (?(DEFINE)...) can be used to define
+        groups (named and numbered) that are never evaluated inline, but can be
+        called as "subroutines" from elsewhere. In effect, the DEFINE condition
+        is always false. There may be only one alternative in such a group.
+
+    (f) A test for recursion can be given as (?(R1).. or (?(R&name)... as well
+        as the simple (?(R). The condition is true only if the most recent
+        recursion is that of the given number or name. It does not search out
+        through the entire recursion stack.
+
+    (g) The escape \gN or \g{N} has been added, where N is a positive or
+        negative number, specifying an absolute or relative reference.
+
+35. Tidied to get rid of some further signed/unsigned compiler warnings and
+    some "unreachable code" warnings.
+
+36. Updated the Unicode property tables to Unicode version 5.0.0. Amongst other
+    things, this adds five new scripts.
+
+37. Perl ignores orphaned \E escapes completely. PCRE now does the same.
+    There were also incompatibilities regarding the handling of \Q..\E inside
+    character classes, for example with patterns like [\Qa\E-\Qz\E] where the
+    hyphen was adjacent to \Q or \E. I hope I've cleared all this up now.
+
+38. Like Perl, PCRE detects when an indefinitely repeated parenthesized group
+    matches an empty string, and forcibly breaks the loop. There were bugs in
+    this code in non-simple cases. For a pattern such as  ^(a()*)*  matched
+    against  aaaa  the result was just "a" rather than "aaaa", for example. Two
+    separate and independent bugs (that affected different cases) have been
+    fixed.
+
+39. Refactored the code to abolish the use of different opcodes for small
+    capturing bracket numbers. This is a tidy that I avoided doing when I
+    removed the limit on the number of capturing brackets for 3.5 back in 2001.
+    The new approach is not only tidier, it makes it possible to reduce the
+    memory needed to fix the previous bug (38).
+
+40. Implemented PCRE_NEWLINE_ANY to recognize any of the Unicode newline
+    sequences (http://unicode.org/unicode/reports/tr18/) as "newline" when
+    processing dot, circumflex, or dollar metacharacters, or #-comments in /x
+    mode.
+
+41. Add \R to match any Unicode newline sequence, as suggested in the Unicode
+    report.
+
+42. Applied patch, originally from Ari Pollak, modified by Google, to allow
+    copy construction and assignment in the C++ wrapper.
+
+43. Updated pcregrep to support "--newline=any". In the process, I fixed a
+    couple of bugs that could have given wrong results in the "--newline=crlf"
+    case.
+
+44. Added a number of casts and did some reorganization of signed/unsigned int
+    variables following suggestions from Dair Grant. Also renamed the variable
+    "this" as "item" because it is a C++ keyword.
+
+45. Arranged for dftables to add
+
+      #include "pcre_internal.h"
+
+    to pcre_chartables.c because without it, gcc 4.x may remove the array
+    definition from the final binary if PCRE is built into a static library and
+    dead code stripping is activated.
+
+46. For an unanchored pattern, if a match attempt fails at the start of a
+    newline sequence, and the newline setting is CRLF or ANY, and the next two
+    characters are CRLF, advance by two characters instead of one.
+
+
+Version 6.7 04-Jul-06
+---------------------
+
+ 1. In order to handle tests when input lines are enormously long, pcretest has
+    been re-factored so that it automatically extends its buffers when
+    necessary. The code is crude, but this _is_ just a test program. The
+    default size has been increased from 32K to 50K.
+
+ 2. The code in pcre_study() was using the value of the re argument before
+    testing it for NULL. (Of course, in any sensible call of the function, it
+    won't be NULL.)
+
+ 3. The memmove() emulation function in pcre_internal.h, which is used on
+    systems that lack both memmove() and bcopy() - that is, hardly ever -
+    was missing a "static" storage class specifier.
+
+ 4. When UTF-8 mode was not set, PCRE looped when compiling certain patterns
+    containing an extended class (one that cannot be represented by a bitmap
+    because it contains high-valued characters or Unicode property items, e.g.
+    [\pZ]). Almost always one would set UTF-8 mode when processing such a
+    pattern, but PCRE should not loop if you do not (it no longer does).
+    [Detail: two cases were found: (a) a repeated subpattern containing an
+    extended class; (b) a recursive reference to a subpattern that followed a
+    previous extended class. It wasn't skipping over the extended class
+    correctly when UTF-8 mode was not set.]
+
+ 5. A negated single-character class was not being recognized as fixed-length
+    in lookbehind assertions such as (?<=[^f]), leading to an incorrect
+    compile error "lookbehind assertion is not fixed length".
+
+ 6. The RunPerlTest auxiliary script was showing an unexpected difference
+    between PCRE and Perl for UTF-8 tests. It turns out that it is hard to
+    write a Perl script that can interpret lines of an input file either as
+    byte characters or as UTF-8, which is what "perltest" was being required to
+    do for the non-UTF-8 and UTF-8 tests, respectively. Essentially what you
+    can't do is switch easily at run time between having the "use utf8;" pragma
+    or not. In the end, I fudged it by using the RunPerlTest script to insert
+    "use utf8;" explicitly for the UTF-8 tests.
+
+ 7. In multiline (/m) mode, PCRE was matching ^ after a terminating newline at
+    the end of the subject string, contrary to the documentation and to what
+    Perl does. This was true of both matching functions. Now it matches only at
+    the start of the subject and immediately after *internal* newlines.
+
+ 8. A call of pcre_fullinfo() from pcretest to get the option bits was passing
+    a pointer to an int instead of a pointer to an unsigned long int. This
+    caused problems on 64-bit systems.
+
+ 9. Applied a patch from the folks at Google to pcrecpp.cc, to fix "another
+    instance of the 'standard' template library not being so standard".
+
+10. There was no check on the number of named subpatterns nor the maximum
+    length of a subpattern name. The product of these values is used to compute
+    the size of the memory block for a compiled pattern. By supplying a very
+    long subpattern name and a large number of named subpatterns, the size
+    computation could be caused to overflow. This is now prevented by limiting
+    the length of names to 32 characters, and the number of named subpatterns
+    to 10,000.
+
+11. Subpatterns that are repeated with specific counts have to be replicated in
+    the compiled pattern. The size of memory for this was computed from the
+    length of the subpattern and the repeat count. The latter is limited to
+    65535, but there was no limit on the former, meaning that integer overflow
+    could in principle occur. The compiled length of a repeated subpattern is
+    now limited to 30,000 bytes in order to prevent this.
+
+12. Added the optional facility to have named substrings with the same name.
+
+13. Added the ability to use a named substring as a condition, using the
+    Python syntax: (?(name)yes|no). This overloads (?(R)... and names that
+    are numbers (not recommended). Forward references are permitted.
+
+14. Added forward references in named backreferences (if you see what I mean).
+
+15. In UTF-8 mode, with the PCRE_DOTALL option set, a quantified dot in the
+    pattern could run off the end of the subject. For example, the pattern
+    "(?s)(.{1,5})"8 did this with the subject "ab".
+
+16. If PCRE_DOTALL or PCRE_MULTILINE were set, pcre_dfa_exec() behaved as if
+    PCRE_CASELESS was set when matching characters that were quantified with ?
+    or *.
+
+17. A character class other than a single negated character that had a minimum
+    but no maximum quantifier - for example [ab]{6,} - was not handled
+    correctly by pce_dfa_exec(). It would match only one character.
+
+18. A valid (though odd) pattern that looked like a POSIX character
+    class but used an invalid character after [ (for example [[,abc,]]) caused
+    pcre_compile() to give the error "Failed: internal error: code overflow" or
+    in some cases to crash with a glibc free() error. This could even happen if
+    the pattern terminated after [[ but there just happened to be a sequence of
+    letters, a binary zero, and a closing ] in the memory that followed.
+
+19. Perl's treatment of octal escapes in the range \400 to \777 has changed
+    over the years. Originally (before any Unicode support), just the bottom 8
+    bits were taken. Thus, for example, \500 really meant \100. Nowadays the
+    output from "man perlunicode" includes this:
+
+      The regular expression compiler produces polymorphic opcodes.  That
+      is, the pattern adapts to the data and automatically switches to
+      the Unicode character scheme when presented with Unicode data--or
+      instead uses a traditional byte scheme when presented with byte
+      data.
+
+    Sadly, a wide octal escape does not cause a switch, and in a string with
+    no other multibyte characters, these octal escapes are treated as before.
+    Thus, in Perl, the pattern  /\500/ actually matches \100 but the pattern
+    /\500|\x{1ff}/ matches \500 or \777 because the whole thing is treated as a
+    Unicode string.
+
+    I have not perpetrated such confusion in PCRE. Up till now, it took just
+    the bottom 8 bits, as in old Perl. I have now made octal escapes with
+    values greater than \377 illegal in non-UTF-8 mode. In UTF-8 mode they
+    translate to the appropriate multibyte character.
+
+29. Applied some refactoring to reduce the number of warnings from Microsoft
+    and Borland compilers. This has included removing the fudge introduced
+    seven years ago for the OS/2 compiler (see 2.02/2 below) because it caused
+    a warning about an unused variable.
+
+21. PCRE has not included VT (character 0x0b) in the set of whitespace
+    characters since release 4.0, because Perl (from release 5.004) does not.
+    [Or at least, is documented not to: some releases seem to be in conflict
+    with the documentation.] However, when a pattern was studied with
+    pcre_study() and all its branches started with \s, PCRE still included VT
+    as a possible starting character. Of course, this did no harm; it just
+    caused an unnecessary match attempt.
+
+22. Removed a now-redundant internal flag bit that recorded the fact that case
+    dependency changed within the pattern. This was once needed for "required
+    byte" processing, but is no longer used. This recovers a now-scarce options
+    bit. Also moved the least significant internal flag bit to the most-
+    significant bit of the word, which was not previously used (hangover from
+    the days when it was an int rather than a uint) to free up another bit for
+    the future.
+
+23. Added support for CRLF line endings as well as CR and LF. As well as the
+    default being selectable at build time, it can now be changed at runtime
+    via the PCRE_NEWLINE_xxx flags. There are now options for pcregrep to
+    specify that it is scanning data with non-default line endings.
+
+24. Changed the definition of CXXLINK to make it agree with the definition of
+    LINK in the Makefile, by replacing LDFLAGS to CXXFLAGS.
+
+25. Applied Ian Taylor's patches to avoid using another stack frame for tail
+    recursions. This makes a big different to stack usage for some patterns.
+
+26. If a subpattern containing a named recursion or subroutine reference such
+    as (?P>B) was quantified, for example (xxx(?P>B)){3}, the calculation of
+    the space required for the compiled pattern went wrong and gave too small a
+    value. Depending on the environment, this could lead to "Failed: internal
+    error: code overflow at offset 49" or "glibc detected double free or
+    corruption" errors.
+
+27. Applied patches from Google (a) to support the new newline modes and (b) to
+    advance over multibyte UTF-8 characters in GlobalReplace.
+
+28. Change free() to pcre_free() in pcredemo.c. Apparently this makes a
+    difference for some implementation of PCRE in some Windows version.
+
+29. Added some extra testing facilities to pcretest:
+
+    \q<number>   in a data line sets the "match limit" value
+    \Q<number>   in a data line sets the "match recursion limt" value
+    -S <number>  sets the stack size, where <number> is in megabytes
+
+    The -S option isn't available for Windows.
+
+
+Version 6.6 06-Feb-06
+---------------------
+
+ 1. Change 16(a) for 6.5 broke things, because PCRE_DATA_SCOPE was not defined
+    in pcreposix.h. I have copied the definition from pcre.h.
+
+ 2. Change 25 for 6.5 broke compilation in a build directory out-of-tree
+    because pcre.h is no longer a built file.
+
+ 3. Added Jeff Friedl's additional debugging patches to pcregrep. These are
+    not normally included in the compiled code.
+
+
+Version 6.5 01-Feb-06
+---------------------
+
+ 1. When using the partial match feature with pcre_dfa_exec(), it was not
+    anchoring the second and subsequent partial matches at the new starting
+    point. This could lead to incorrect results. For example, with the pattern
+    /1234/, partially matching against "123" and then "a4" gave a match.
+
+ 2. Changes to pcregrep:
+
+    (a) All non-match returns from pcre_exec() were being treated as failures
+        to match the line. Now, unless the error is PCRE_ERROR_NOMATCH, an
+        error message is output. Some extra information is given for the
+        PCRE_ERROR_MATCHLIMIT and PCRE_ERROR_RECURSIONLIMIT errors, which are
+        probably the only errors that are likely to be caused by users (by
+        specifying a regex that has nested indefinite repeats, for instance).
+        If there are more than 20 of these errors, pcregrep is abandoned.
+
+    (b) A binary zero was treated as data while matching, but terminated the
+        output line if it was written out. This has been fixed: binary zeroes
+        are now no different to any other data bytes.
+
+    (c) Whichever of the LC_ALL or LC_CTYPE environment variables is set is
+        used to set a locale for matching. The --locale=xxxx long option has
+        been added (no short equivalent) to specify a locale explicitly on the
+        pcregrep command, overriding the environment variables.
+
+    (d) When -B was used with -n, some line numbers in the output were one less
+        than they should have been.
+
+    (e) Added the -o (--only-matching) option.
+
+    (f) If -A or -C was used with -c (count only), some lines of context were
+        accidentally printed for the final match.
+
+    (g) Added the -H (--with-filename) option.
+
+    (h) The combination of options -rh failed to suppress file names for files
+        that were found from directory arguments.
+
+    (i) Added the -D (--devices) and -d (--directories) options.
+
+    (j) Added the -F (--fixed-strings) option.
+
+    (k) Allow "-" to be used as a file name for -f as well as for a data file.
+
+    (l) Added the --colo(u)r option.
+
+    (m) Added Jeffrey Friedl's -S testing option, but within #ifdefs so that it
+        is not present by default.
+
+ 3. A nasty bug was discovered in the handling of recursive patterns, that is,
+    items such as (?R) or (?1), when the recursion could match a number of
+    alternatives. If it matched one of the alternatives, but subsequently,
+    outside the recursion, there was a failure, the code tried to back up into
+    the recursion. However, because of the way PCRE is implemented, this is not
+    possible, and the result was an incorrect result from the match.
+
+    In order to prevent this happening, the specification of recursion has
+    been changed so that all such subpatterns are automatically treated as
+    atomic groups. Thus, for example, (?R) is treated as if it were (?>(?R)).
+
+ 4. I had overlooked the fact that, in some locales, there are characters for
+    which isalpha() is true but neither isupper() nor islower() are true. In
+    the fr_FR locale, for instance, the \xAA and \xBA characters (ordmasculine
+    and ordfeminine) are like this. This affected the treatment of \w and \W
+    when they appeared in character classes, but not when they appeared outside
+    a character class. The bit map for "word" characters is now created
+    separately from the results of isalnum() instead of just taking it from the
+    upper, lower, and digit maps. (Plus the underscore character, of course.)
+
+ 5. The above bug also affected the handling of POSIX character classes such as
+    [[:alpha:]] and [[:alnum:]]. These do not have their own bit maps in PCRE's
+    permanent tables. Instead, the bit maps for such a class were previously
+    created as the appropriate unions of the upper, lower, and digit bitmaps.
+    Now they are created by subtraction from the [[:word:]] class, which has
+    its own bitmap.
+
+ 6. The [[:blank:]] character class matches horizontal, but not vertical space.
+    It is created by subtracting the vertical space characters (\x09, \x0a,
+    \x0b, \x0c) from the [[:space:]] bitmap. Previously, however, the
+    subtraction was done in the overall bitmap for a character class, meaning
+    that a class such as [\x0c[:blank:]] was incorrect because \x0c would not
+    be recognized. This bug has been fixed.
+
+ 7. Patches from the folks at Google:
+
+      (a) pcrecpp.cc: "to handle a corner case that may or may not happen in
+      real life, but is still worth protecting against".
+
+      (b) pcrecpp.cc: "corrects a bug when negative radixes are used with
+      regular expressions".
+
+      (c) pcre_scanner.cc: avoid use of std::count() because not all systems
+      have it.
+
+      (d) Split off pcrecpparg.h from pcrecpp.h and had the former built by
+      "configure" and the latter not, in order to fix a problem somebody had
+      with compiling the Arg class on HP-UX.
+
+      (e) Improve the error-handling of the C++ wrapper a little bit.
+
+      (f) New tests for checking recursion limiting.
+
+ 8. The pcre_memmove() function, which is used only if the environment does not
+    have a standard memmove() function (and is therefore rarely compiled),
+    contained two bugs: (a) use of int instead of size_t, and (b) it was not
+    returning a result (though PCRE never actually uses the result).
+
+ 9. In the POSIX regexec() interface, if nmatch is specified as a ridiculously
+    large number - greater than INT_MAX/(3*sizeof(int)) - REG_ESPACE is
+    returned instead of calling malloc() with an overflowing number that would
+    most likely cause subsequent chaos.
+
+10. The debugging option of pcretest was not showing the NO_AUTO_CAPTURE flag.
+
+11. The POSIX flag REG_NOSUB is now supported. When a pattern that was compiled
+    with this option is matched, the nmatch and pmatch options of regexec() are
+    ignored.
+
+12. Added REG_UTF8 to the POSIX interface. This is not defined by POSIX, but is
+    provided in case anyone wants to the the POSIX interface with UTF-8
+    strings.
+
+13. Added CXXLDFLAGS to the Makefile parameters to provide settings only on the
+    C++ linking (needed for some HP-UX environments).
+
+14. Avoid compiler warnings in get_ucpname() when compiled without UCP support
+    (unused parameter) and in the pcre_printint() function (omitted "default"
+    switch label when the default is to do nothing).
+
+15. Added some code to make it possible, when PCRE is compiled as a C++
+    library, to replace subject pointers for pcre_exec() with a smart pointer
+    class, thus making it possible to process discontinuous strings.
+
+16. The two macros PCRE_EXPORT and PCRE_DATA_SCOPE are confusing, and perform
+    much the same function. They were added by different people who were trying
+    to make PCRE easy to compile on non-Unix systems. It has been suggested
+    that PCRE_EXPORT be abolished now that there is more automatic apparatus
+    for compiling on Windows systems. I have therefore replaced it with
+    PCRE_DATA_SCOPE. This is set automatically for Windows; if not set it
+    defaults to "extern" for C or "extern C" for C++, which works fine on
+    Unix-like systems. It is now possible to override the value of PCRE_DATA_
+    SCOPE with something explicit in config.h. In addition:
+
+    (a) pcreposix.h still had just "extern" instead of either of these macros;
+        I have replaced it with PCRE_DATA_SCOPE.
+
+    (b) Functions such as _pcre_xclass(), which are internal to the library,
+        but external in the C sense, all had PCRE_EXPORT in their definitions.
+        This is apparently wrong for the Windows case, so I have removed it.
+        (It makes no difference on Unix-like systems.)
+
+17. Added a new limit, MATCH_LIMIT_RECURSION, which limits the depth of nesting
+    of recursive calls to match(). This is different to MATCH_LIMIT because
+    that limits the total number of calls to match(), not all of which increase
+    the depth of recursion. Limiting the recursion depth limits the amount of
+    stack (or heap if NO_RECURSE is set) that is used. The default can be set
+    when PCRE is compiled, and changed at run time. A patch from Google adds
+    this functionality to the C++ interface.
+
+18. Changes to the handling of Unicode character properties:
+
+    (a) Updated the table to Unicode 4.1.0.
+
+    (b) Recognize characters that are not in the table as "Cn" (undefined).
+
+    (c) I revised the way the table is implemented to a much improved format
+        which includes recognition of ranges. It now supports the ranges that
+        are defined in UnicodeData.txt, and it also amalgamates other
+        characters into ranges. This has reduced the number of entries in the
+        table from around 16,000 to around 3,000, thus reducing its size
+        considerably. I realized I did not need to use a tree structure after
+        all - a binary chop search is just as efficient. Having reduced the
+        number of entries, I extended their size from 6 bytes to 8 bytes to
+        allow for more data.
+
+    (d) Added support for Unicode script names via properties such as \p{Han}.
+
+19. In UTF-8 mode, a backslash followed by a non-Ascii character was not
+    matching that character.
+
+20. When matching a repeated Unicode property with a minimum greater than zero,
+    (for example \pL{2,}), PCRE could look past the end of the subject if it
+    reached it while seeking the minimum number of characters. This could
+    happen only if some of the characters were more than one byte long, because
+    there is a check for at least the minimum number of bytes.
+
+21. Refactored the implementation of \p and \P so as to be more general, to
+    allow for more different types of property in future. This has changed the
+    compiled form incompatibly. Anybody with saved compiled patterns that use
+    \p or \P will have to recompile them.
+
+22. Added "Any" and "L&" to the supported property types.
+
+23. Recognize \x{...} as a code point specifier, even when not in UTF-8 mode,
+    but give a compile time error if the value is greater than 0xff.
+
+24. The man pages for pcrepartial, pcreprecompile, and pcre_compile2 were
+    accidentally not being installed or uninstalled.
+
+25. The pcre.h file was built from pcre.h.in, but the only changes that were
+    made were to insert the current release number. This seemed silly, because
+    it made things harder for people building PCRE on systems that don't run
+    "configure". I have turned pcre.h into a distributed file, no longer built
+    by "configure", with the version identification directly included. There is
+    no longer a pcre.h.in file.
+
+    However, this change necessitated a change to the pcre-config script as
+    well. It is built from pcre-config.in, and one of the substitutions was the
+    release number. I have updated configure.ac so that ./configure now finds
+    the release number by grepping pcre.h.
+
+26. Added the ability to run the tests under valgrind.
+
+
+Version 6.4 05-Sep-05
+---------------------
+
+ 1. Change 6.0/10/(l) to pcregrep introduced a bug that caused separator lines
+    "--" to be printed when multiple files were scanned, even when none of the
+    -A, -B, or -C options were used. This is not compatible with Gnu grep, so I
+    consider it to be a bug, and have restored the previous behaviour.
+
+ 2. A couple of code tidies to get rid of compiler warnings.
+
+ 3. The pcretest program used to cheat by referring to symbols in the library
+    whose names begin with _pcre_. These are internal symbols that are not
+    really supposed to be visible externally, and in some environments it is
+    possible to suppress them. The cheating is now confined to including
+    certain files from the library's source, which is a bit cleaner.
+
+ 4. Renamed pcre.in as pcre.h.in to go with pcrecpp.h.in; it also makes the
+    file's purpose clearer.
+
+ 5. Reorganized pcre_ucp_findchar().
+
+
+Version 6.3 15-Aug-05
+---------------------
+
+ 1. The file libpcre.pc.in did not have general read permission in the tarball.
+
+ 2. There were some problems when building without C++ support:
+
+    (a) If C++ support was not built, "make install" and "make test" still
+        tried to test it.
+
+    (b) There were problems when the value of CXX was explicitly set. Some
+        changes have been made to try to fix these, and ...
+
+    (c) --disable-cpp can now be used to explicitly disable C++ support.
+
+    (d) The use of @CPP_OBJ@ directly caused a blank line preceded by a
+        backslash in a target when C++ was disabled. This confuses some
+        versions of "make", apparently. Using an intermediate variable solves
+        this. (Same for CPP_LOBJ.)
+
+ 3. $(LINK_FOR_BUILD) now includes $(CFLAGS_FOR_BUILD) and $(LINK)
+    (non-Windows) now includes $(CFLAGS) because these flags are sometimes
+    necessary on certain architectures.
+
+ 4. Added a setting of -export-symbols-regex to the link command to remove
+    those symbols that are exported in the C sense, but actually are local
+    within the library, and not documented. Their names all begin with
+    "_pcre_". This is not a perfect job, because (a) we have to except some
+    symbols that pcretest ("illegally") uses, and (b) the facility isn't always
+    available (and never for static libraries). I have made a note to try to
+    find a way round (a) in the future.
+
+
+Version 6.2 01-Aug-05
+---------------------
+
+ 1. There was no test for integer overflow of quantifier values. A construction
+    such as {1111111111111111} would give undefined results. What is worse, if
+    a minimum quantifier for a parenthesized subpattern overflowed and became
+    negative, the calculation of the memory size went wrong. This could have
+    led to memory overwriting.
+
+ 2. Building PCRE using VPATH was broken. Hopefully it is now fixed.
+
+ 3. Added "b" to the 2nd argument of fopen() in dftables.c, for non-Unix-like
+    operating environments where this matters.
+
+ 4. Applied Giuseppe Maxia's patch to add additional features for controlling
+    PCRE options from within the C++ wrapper.
+
+ 5. Named capturing subpatterns were not being correctly counted when a pattern
+    was compiled. This caused two problems: (a) If there were more than 100
+    such subpatterns, the calculation of the memory needed for the whole
+    compiled pattern went wrong, leading to an overflow error. (b) Numerical
+    back references of the form \12, where the number was greater than 9, were
+    not recognized as back references, even though there were sufficient
+    previous subpatterns.
+
+ 6. Two minor patches to pcrecpp.cc in order to allow it to compile on older
+    versions of gcc, e.g. 2.95.4.
+
+
+Version 6.1 21-Jun-05
+---------------------
+
+ 1. There was one reference to the variable "posix" in pcretest.c that was not
+    surrounded by "#if !defined NOPOSIX".
+
+ 2. Make it possible to compile pcretest without DFA support, UTF8 support, or
+    the cross-check on the old pcre_info() function, for the benefit of the
+    cut-down version of PCRE that is currently imported into Exim.
+
+ 3. A (silly) pattern starting with (?i)(?-i) caused an internal space
+    allocation error. I've done the easy fix, which wastes 2 bytes for sensible
+    patterns that start (?i) but I don't think that matters. The use of (?i) is
+    just an example; this all applies to the other options as well.
+
+ 4. Since libtool seems to echo the compile commands it is issuing, the output
+    from "make" can be reduced a bit by putting "@" in front of each libtool
+    compile command.
+
+ 5. Patch from the folks at Google for configure.in to be a bit more thorough
+    in checking for a suitable C++ installation before trying to compile the
+    C++ stuff. This should fix a reported problem when a compiler was present,
+    but no suitable headers.
+
+ 6. The man pages all had just "PCRE" as their title. I have changed them to
+    be the relevant file name. I have also arranged that these names are
+    retained in the file doc/pcre.txt, which is a concatenation in text format
+    of all the man pages except the little individual ones for each function.
+
+ 7. The NON-UNIX-USE file had not been updated for the different set of source
+    files that come with release 6. I also added a few comments about the C++
+    wrapper.
+
+
+Version 6.0 07-Jun-05
+---------------------
+
+ 1. Some minor internal re-organization to help with my DFA experiments.
+
+ 2. Some missing #ifdef SUPPORT_UCP conditionals in pcretest and printint that
+    didn't matter for the library itself when fully configured, but did matter
+    when compiling without UCP support, or within Exim, where the ucp files are
+    not imported.
+
+ 3. Refactoring of the library code to split up the various functions into
+    different source modules. The addition of the new DFA matching code (see
+    below) to a single monolithic source would have made it really too
+    unwieldy, quite apart from causing all the code to be include in a
+    statically linked application, when only some functions are used. This is
+    relevant even without the DFA addition now that patterns can be compiled in
+    one application and matched in another.
+
+    The downside of splitting up is that there have to be some external
+    functions and data tables that are used internally in different modules of
+    the library but which are not part of the API. These have all had their
+    names changed to start with "_pcre_" so that they are unlikely to clash
+    with other external names.
+
+ 4. Added an alternate matching function, pcre_dfa_exec(), which matches using
+    a different (DFA) algorithm. Although it is slower than the original
+    function, it does have some advantages for certain types of matching
+    problem.
+
+ 5. Upgrades to pcretest in order to test the features of pcre_dfa_exec(),
+    including restarting after a partial match.
+
+ 6. A patch for pcregrep that defines INVALID_FILE_ATTRIBUTES if it is not
+    defined when compiling for Windows was sent to me. I have put it into the
+    code, though I have no means of testing or verifying it.
+
+ 7. Added the pcre_refcount() auxiliary function.
+
+ 8. Added the PCRE_FIRSTLINE option. This constrains an unanchored pattern to
+    match before or at the first newline in the subject string. In pcretest,
+    the /f option on a pattern can be used to set this.
+
+ 9. A repeated \w when used in UTF-8 mode with characters greater than 256
+    would behave wrongly. This has been present in PCRE since release 4.0.
+
+10. A number of changes to the pcregrep command:
+
+    (a) Refactored how -x works; insert ^(...)$ instead of setting
+        PCRE_ANCHORED and checking the length, in preparation for adding
+        something similar for -w.
+
+    (b) Added the -w (match as a word) option.
+
+    (c) Refactored the way lines are read and buffered so as to have more
+        than one at a time available.
+
+    (d) Implemented a pcregrep test script.
+
+    (e) Added the -M (multiline match) option. This allows patterns to match
+        over several lines of the subject. The buffering ensures that at least
+        8K, or the rest of the document (whichever is the shorter) is available
+        for matching (and similarly the previous 8K for lookbehind assertions).
+
+    (f) Changed the --help output so that it now says
+
+          -w, --word-regex(p)
+
+        instead of two lines, one with "regex" and the other with "regexp"
+        because that confused at least one person since the short forms are the
+        same. (This required a bit of code, as the output is generated
+        automatically from a table. It wasn't just a text change.)
+
+    (g) -- can be used to terminate pcregrep options if the next thing isn't an
+        option but starts with a hyphen. Could be a pattern or a path name
+        starting with a hyphen, for instance.
+
+    (h) "-" can be given as a file name to represent stdin.
+
+    (i) When file names are being printed, "(standard input)" is used for
+        the standard input, for compatibility with GNU grep. Previously
+        "<stdin>" was used.
+
+    (j) The option --label=xxx can be used to supply a name to be used for
+        stdin when file names are being printed. There is no short form.
+
+    (k) Re-factored the options decoding logic because we are going to add
+        two more options that take data. Such options can now be given in four
+        different ways, e.g. "-fname", "-f name", "--file=name", "--file name".
+
+    (l) Added the -A, -B, and -C options for requesting that lines of context
+        around matches be printed.
+
+    (m) Added the -L option to print the names of files that do not contain
+        any matching lines, that is, the complement of -l.
+
+    (n) The return code is 2 if any file cannot be opened, but pcregrep does
+        continue to scan other files.
+
+    (o) The -s option was incorrectly implemented. For compatibility with other
+        greps, it now suppresses the error message for a non-existent or non-
+        accessible file (but not the return code). There is a new option called
+        -q that suppresses the output of matching lines, which was what -s was
+        previously doing.
+
+    (p) Added --include and --exclude options to specify files for inclusion
+        and exclusion when recursing.
+
+11. The Makefile was not using the Autoconf-supported LDFLAGS macro properly.
+    Hopefully, it now does.
+
+12. Missing cast in pcre_study().
+
+13. Added an "uninstall" target to the makefile.
+
+14. Replaced "extern" in the function prototypes in Makefile.in with
+    "PCRE_DATA_SCOPE", which defaults to 'extern' or 'extern "C"' in the Unix
+    world, but is set differently for Windows.
+
+15. Added a second compiling function called pcre_compile2(). The only
+    difference is that it has an extra argument, which is a pointer to an
+    integer error code. When there is a compile-time failure, this is set
+    non-zero, in addition to the error test pointer being set to point to an
+    error message. The new argument may be NULL if no error number is required
+    (but then you may as well call pcre_compile(), which is now just a
+    wrapper). This facility is provided because some applications need a
+    numeric error indication, but it has also enabled me to tidy up the way
+    compile-time errors are handled in the POSIX wrapper.
+
+16. Added VPATH=.libs to the makefile; this should help when building with one
+    prefix path and installing with another. (Or so I'm told by someone who
+    knows more about this stuff than I do.)
+
+17. Added a new option, REG_DOTALL, to the POSIX function regcomp(). This
+    passes PCRE_DOTALL to the pcre_compile() function, making the "." character
+    match everything, including newlines. This is not POSIX-compatible, but
+    somebody wanted the feature. From pcretest it can be activated by using
+    both the P and the s flags.
+
+18. AC_PROG_LIBTOOL appeared twice in Makefile.in. Removed one.
+
+19. libpcre.pc was being incorrectly installed as executable.
+
+20. A couple of places in pcretest check for end-of-line by looking for '\n';
+    it now also looks for '\r' so that it will work unmodified on Windows.
+
+21. Added Google's contributed C++ wrapper to the distribution.
+
+22. Added some untidy missing memory free() calls in pcretest, to keep
+    Electric Fence happy when testing.
+
+
+
+Version 5.0 13-Sep-04
+---------------------
+
+ 1. Internal change: literal characters are no longer packed up into items
+    containing multiple characters in a single byte-string. Each character
+    is now matched using a separate opcode. However, there may be more than one
+    byte in the character in UTF-8 mode.
+
+ 2. The pcre_callout_block structure has two new fields: pattern_position and
+    next_item_length. These contain the offset in the pattern to the next match
+    item, and its length, respectively.
+
+ 3. The PCRE_AUTO_CALLOUT option for pcre_compile() requests the automatic
+    insertion of callouts before each pattern item. Added the /C option to
+    pcretest to make use of this.
+
+ 4. On the advice of a Windows user, the lines
+
+      #if defined(_WIN32) || defined(WIN32)
+      _setmode( _fileno( stdout ), 0x8000 );
+      #endif  /* defined(_WIN32) || defined(WIN32) */
+
+    have been added to the source of pcretest. This apparently does useful
+    magic in relation to line terminators.
+
+ 5. Changed "r" and "w" in the calls to fopen() in pcretest to "rb" and "wb"
+    for the benefit of those environments where the "b" makes a difference.
+
+ 6. The icc compiler has the same options as gcc, but "configure" doesn't seem
+    to know about it. I have put a hack into configure.in that adds in code
+    to set GCC=yes if CC=icc. This seems to end up at a point in the
+    generated configure script that is early enough to affect the setting of
+    compiler options, which is what is needed, but I have no means of testing
+    whether it really works. (The user who reported this had patched the
+    generated configure script, which of course I cannot do.)
+
+    LATER: After change 22 below (new libtool files), the configure script
+    seems to know about icc (and also ecc). Therefore, I have commented out
+    this hack in configure.in.
+
+ 7. Added support for pkg-config (2 patches were sent in).
+
+ 8. Negated POSIX character classes that used a combination of internal tables
+    were completely broken. These were [[:^alpha:]], [[:^alnum:]], and
+    [[:^ascii]]. Typically, they would match almost any characters. The other
+    POSIX classes were not broken in this way.
+
+ 9. Matching the pattern "\b.*?" against "ab cd", starting at offset 1, failed
+    to find the match, as PCRE was deluded into thinking that the match had to
+    start at the start point or following a newline. The same bug applied to
+    patterns with negative forward assertions or any backward assertions
+    preceding ".*" at the start, unless the pattern required a fixed first
+    character. This was a failing pattern: "(?!.bcd).*". The bug is now fixed.
+
+10. In UTF-8 mode, when moving forwards in the subject after a failed match
+    starting at the last subject character, bytes beyond the end of the subject
+    string were read.
+
+11. Renamed the variable "class" as "classbits" to make life easier for C++
+    users. (Previously there was a macro definition, but it apparently wasn't
+    enough.)
+
+12. Added the new field "tables" to the extra data so that tables can be passed
+    in at exec time, or the internal tables can be re-selected. This allows
+    a compiled regex to be saved and re-used at a later time by a different
+    program that might have everything at different addresses.
+
+13. Modified the pcre-config script so that, when run on Solaris, it shows a
+    -R library as well as a -L library.
+
+14. The debugging options of pcretest (-d on the command line or D on a
+    pattern) showed incorrect output for anything following an extended class
+    that contained multibyte characters and which was followed by a quantifier.
+
+15. Added optional support for general category Unicode character properties
+    via the \p, \P, and \X escapes. Unicode property support implies UTF-8
+    support. It adds about 90K to the size of the library. The meanings of the
+    inbuilt class escapes such as \d and \s have NOT been changed.
+
+16. Updated pcredemo.c to include calls to free() to release the memory for the
+    compiled pattern.
+
+17. The generated file chartables.c was being created in the source directory
+    instead of in the building directory. This caused the build to fail if the
+    source directory was different from the building directory, and was
+    read-only.
+
+18. Added some sample Win commands from Mark Tetrode into the NON-UNIX-USE
+    file. No doubt somebody will tell me if they don't make sense... Also added
+    Dan Mooney's comments about building on OpenVMS.
+
+19. Added support for partial matching via the PCRE_PARTIAL option for
+    pcre_exec() and the \P data escape in pcretest.
+
+20. Extended pcretest with 3 new pattern features:
+
+    (i)   A pattern option of the form ">rest-of-line" causes pcretest to
+          write the compiled pattern to the file whose name is "rest-of-line".
+          This is a straight binary dump of the data, with the saved pointer to
+          the character tables forced to be NULL. The study data, if any, is
+          written too. After writing, pcretest reads a new pattern.
+
+    (ii)  If, instead of a pattern, "<rest-of-line" is given, pcretest reads a
+          compiled pattern from the given file. There must not be any
+          occurrences of "<" in the file name (pretty unlikely); if there are,
+          pcretest will instead treat the initial "<" as a pattern delimiter.
+          After reading in the pattern, pcretest goes on to read data lines as
+          usual.
+
+    (iii) The F pattern option causes pcretest to flip the bytes in the 32-bit
+          and 16-bit fields in a compiled pattern, to simulate a pattern that
+          was compiled on a host of opposite endianness.
+
+21. The pcre-exec() function can now cope with patterns that were compiled on
+    hosts of opposite endianness, with this restriction:
+
+      As for any compiled expression that is saved and used later, the tables
+      pointer field cannot be preserved; the extra_data field in the arguments
+      to pcre_exec() should be used to pass in a tables address if a value
+      other than the default internal tables were used at compile time.
+
+22. Calling pcre_exec() with a negative value of the "ovecsize" parameter is
+    now diagnosed as an error. Previously, most of the time, a negative number
+    would have been treated as zero, but if in addition "ovector" was passed as
+    NULL, a crash could occur.
+
+23. Updated the files ltmain.sh, config.sub, config.guess, and aclocal.m4 with
+    new versions from the libtool 1.5 distribution (the last one is a copy of
+    a file called libtool.m4). This seems to have fixed the need to patch
+    "configure" to support Darwin 1.3 (which I used to do). However, I still
+    had to patch ltmain.sh to ensure that ${SED} is set (it isn't on my
+    workstation).
+
+24. Changed the PCRE licence to be the more standard "BSD" licence.
+
+
+Version 4.5 01-Dec-03
+---------------------
+
+ 1. There has been some re-arrangement of the code for the match() function so
+    that it can be compiled in a version that does not call itself recursively.
+    Instead, it keeps those local variables that need separate instances for
+    each "recursion" in a frame on the heap, and gets/frees frames whenever it
+    needs to "recurse". Keeping track of where control must go is done by means
+    of setjmp/longjmp. The whole thing is implemented by a set of macros that
+    hide most of the details from the main code, and operates only if
+    NO_RECURSE is defined while compiling pcre.c. If PCRE is built using the
+    "configure" mechanism, "--disable-stack-for-recursion" turns on this way of
+    operating.
+
+    To make it easier for callers to provide specially tailored get/free
+    functions for this usage, two new functions, pcre_stack_malloc, and
+    pcre_stack_free, are used. They are always called in strict stacking order,
+    and the size of block requested is always the same.
+
+    The PCRE_CONFIG_STACKRECURSE info parameter can be used to find out whether
+    PCRE has been compiled to use the stack or the heap for recursion. The
+    -C option of pcretest uses this to show which version is compiled.
+
+    A new data escape \S, is added to pcretest; it causes the amounts of store
+    obtained and freed by both kinds of malloc/free at match time to be added
+    to the output.
+
+ 2. Changed the locale test to use "fr_FR" instead of "fr" because that's
+    what's available on my current Linux desktop machine.
+
+ 3. When matching a UTF-8 string, the test for a valid string at the start has
+    been extended. If start_offset is not zero, PCRE now checks that it points
+    to a byte that is the start of a UTF-8 character. If not, it returns
+    PCRE_ERROR_BADUTF8_OFFSET (-11). Note: the whole string is still checked;
+    this is necessary because there may be backward assertions in the pattern.
+    When matching the same subject several times, it may save resources to use
+    PCRE_NO_UTF8_CHECK on all but the first call if the string is long.
+
+ 4. The code for checking the validity of UTF-8 strings has been tightened so
+    that it rejects (a) strings containing 0xfe or 0xff bytes and (b) strings
+    containing "overlong sequences".
+
+ 5. Fixed a bug (appearing twice) that I could not find any way of exploiting!
+    I had written "if ((digitab[*p++] && chtab_digit) == 0)" where the "&&"
+    should have been "&", but it just so happened that all the cases this let
+    through by mistake were picked up later in the function.
+
+ 6. I had used a variable called "isblank" - this is a C99 function, causing
+    some compilers to warn. To avoid this, I renamed it (as "blankclass").
+
+ 7. Cosmetic: (a) only output another newline at the end of pcretest if it is
+    prompting; (b) run "./pcretest /dev/null" at the start of the test script
+    so the version is shown; (c) stop "make test" echoing "./RunTest".
+
+ 8. Added patches from David Burgess to enable PCRE to run on EBCDIC systems.
+
+ 9. The prototype for memmove() for systems that don't have it was using
+    size_t, but the inclusion of the header that defines size_t was later. I've
+    moved the #includes for the C headers earlier to avoid this.
+
+10. Added some adjustments to the code to make it easier to compiler on certain
+    special systems:
+
+      (a) Some "const" qualifiers were missing.
+      (b) Added the macro EXPORT before all exported functions; by default this
+          is defined to be empty.
+      (c) Changed the dftables auxiliary program (that builds chartables.c) so
+          that it reads its output file name as an argument instead of writing
+          to the standard output and assuming this can be redirected.
+
+11. In UTF-8 mode, if a recursive reference (e.g. (?1)) followed a character
+    class containing characters with values greater than 255, PCRE compilation
+    went into a loop.
+
+12. A recursive reference to a subpattern that was within another subpattern
+    that had a minimum quantifier of zero caused PCRE to crash. For example,
+    (x(y(?2))z)? provoked this bug with a subject that got as far as the
+    recursion. If the recursively-called subpattern itself had a zero repeat,
+    that was OK.
+
+13. In pcretest, the buffer for reading a data line was set at 30K, but the
+    buffer into which it was copied (for escape processing) was still set at
+    1024, so long lines caused crashes.
+
+14. A pattern such as /[ab]{1,3}+/ failed to compile, giving the error
+    "internal error: code overflow...". This applied to any character class
+    that was followed by a possessive quantifier.
+
+15. Modified the Makefile to add libpcre.la as a prerequisite for
+    libpcreposix.la because I was told this is needed for a parallel build to
+    work.
+
+16. If a pattern that contained .* following optional items at the start was
+    studied, the wrong optimizing data was generated, leading to matching
+    errors. For example, studying /[ab]*.*c/ concluded, erroneously, that any
+    matching string must start with a or b or c. The correct conclusion for
+    this pattern is that a match can start with any character.
+
+
+Version 4.4 13-Aug-03
+---------------------
+
+ 1. In UTF-8 mode, a character class containing characters with values between
+    127 and 255 was not handled correctly if the compiled pattern was studied.
+    In fixing this, I have also improved the studying algorithm for such
+    classes (slightly).
+
+ 2. Three internal functions had redundant arguments passed to them. Removal
+    might give a very teeny performance improvement.
+
+ 3. Documentation bug: the value of the capture_top field in a callout is *one
+    more than* the number of the hightest numbered captured substring.
+
+ 4. The Makefile linked pcretest and pcregrep with -lpcre, which could result
+    in incorrectly linking with a previously installed version. They now link
+    explicitly with libpcre.la.
+
+ 5. configure.in no longer needs to recognize Cygwin specially.
+
+ 6. A problem in pcre.in for Windows platforms is fixed.
+
+ 7. If a pattern was successfully studied, and the -d (or /D) flag was given to
+    pcretest, it used to include the size of the study block as part of its
+    output. Unfortunately, the structure contains a field that has a different
+    size on different hardware architectures. This meant that the tests that
+    showed this size failed. As the block is currently always of a fixed size,
+    this information isn't actually particularly useful in pcretest output, so
+    I have just removed it.
+
+ 8. Three pre-processor statements accidentally did not start in column 1.
+    Sadly, there are *still* compilers around that complain, even though
+    standard C has not required this for well over a decade. Sigh.
+
+ 9. In pcretest, the code for checking callouts passed small integers in the
+    callout_data field, which is a void * field. However, some picky compilers
+    complained about the casts involved for this on 64-bit systems. Now
+    pcretest passes the address of the small integer instead, which should get
+    rid of the warnings.
+
+10. By default, when in UTF-8 mode, PCRE now checks for valid UTF-8 strings at
+    both compile and run time, and gives an error if an invalid UTF-8 sequence
+    is found. There is a option for disabling this check in cases where the
+    string is known to be correct and/or the maximum performance is wanted.
+
+11. In response to a bug report, I changed one line in Makefile.in from
+
+        -Wl,--out-implib,.libs/lib@WIN_PREFIX@pcreposix.dll.a \
+    to
+        -Wl,--out-implib,.libs/@WIN_PREFIX@libpcreposix.dll.a \
+
+    to look similar to other lines, but I have no way of telling whether this
+    is the right thing to do, as I do not use Windows. No doubt I'll get told
+    if it's wrong...
+
+
+Version 4.3 21-May-03
+---------------------
+
+1. Two instances of @WIN_PREFIX@ omitted from the Windows targets in the
+   Makefile.
+
+2. Some refactoring to improve the quality of the code:
+
+   (i)   The utf8_table... variables are now declared "const".
+
+   (ii)  The code for \cx, which used the "case flipping" table to upper case
+         lower case letters, now just substracts 32. This is ASCII-specific,
+         but the whole concept of \cx is ASCII-specific, so it seems
+         reasonable.
+
+   (iii) PCRE was using its character types table to recognize decimal and
+         hexadecimal digits in the pattern. This is silly, because it handles
+         only 0-9, a-f, and A-F, but the character types table is locale-
+         specific, which means strange things might happen. A private
+         table is now used for this - though it costs 256 bytes, a table is
+         much faster than multiple explicit tests. Of course, the standard
+         character types table is still used for matching digits in subject
+         strings against \d.
+
+   (iv)  Strictly, the identifier ESC_t is reserved by POSIX (all identifiers
+         ending in _t are). So I've renamed it as ESC_tee.
+
+3. The first argument for regexec() in the POSIX wrapper should have been
+   defined as "const".
+
+4. Changed pcretest to use malloc() for its buffers so that they can be
+   Electric Fenced for debugging.
+
+5. There were several places in the code where, in UTF-8 mode, PCRE would try
+   to read one or more bytes before the start of the subject string. Often this
+   had no effect on PCRE's behaviour, but in some circumstances it could
+   provoke a segmentation fault.
+
+6. A lookbehind at the start of a pattern in UTF-8 mode could also cause PCRE
+   to try to read one or more bytes before the start of the subject string.
+
+7. A lookbehind in a pattern matched in non-UTF-8 mode on a PCRE compiled with
+   UTF-8 support could misbehave in various ways if the subject string
+   contained bytes with the 0x80 bit set and the 0x40 bit unset in a lookbehind
+   area. (PCRE was not checking for the UTF-8 mode flag, and trying to move
+   back over UTF-8 characters.)
+
+
+Version 4.2 14-Apr-03
+---------------------
+
+1. Typo "#if SUPPORT_UTF8" instead of "#ifdef SUPPORT_UTF8" fixed.
+
+2. Changes to the building process, supplied by Ronald Landheer-Cieslak
+     [ON_WINDOWS]: new variable, "#" on non-Windows platforms
+     [NOT_ON_WINDOWS]: new variable, "#" on Windows platforms
+     [WIN_PREFIX]: new variable, "cyg" for Cygwin
+     * Makefile.in: use autoconf substitution for OBJEXT, EXEEXT, BUILD_OBJEXT
+       and BUILD_EXEEXT
+     Note: automatic setting of the BUILD variables is not yet working
+     set CPPFLAGS and BUILD_CPPFLAGS (but don't use yet) - should be used at
+       compile-time but not at link-time
+     [LINK]: use for linking executables only
+     make different versions for Windows and non-Windows
+     [LINKLIB]: new variable, copy of UNIX-style LINK, used for linking
+       libraries
+     [LINK_FOR_BUILD]: new variable
+     [OBJEXT]: use throughout
+     [EXEEXT]: use throughout
+     <winshared>: new target
+     <wininstall>: new target
+     <dftables.o>: use native compiler
+     <dftables>: use native linker
+     <install>: handle Windows platform correctly
+     <clean>: ditto
+     <check>: ditto
+     copy DLL to top builddir before testing
+
+   As part of these changes, -no-undefined was removed again. This was reported
+   to give trouble on HP-UX 11.0, so getting rid of it seems like a good idea
+   in any case.
+
+3. Some tidies to get rid of compiler warnings:
+
+   . In the match_data structure, match_limit was an unsigned long int, whereas
+     match_call_count was an int. I've made them both unsigned long ints.
+
+   . In pcretest the fact that a const uschar * doesn't automatically cast to
+     a void * provoked a warning.
+
+   . Turning on some more compiler warnings threw up some "shadow" variables
+     and a few more missing casts.
+
+4. If PCRE was complied with UTF-8 support, but called without the PCRE_UTF8
+   option, a class that contained a single character with a value between 128
+   and 255 (e.g. /[\xFF]/) caused PCRE to crash.
+
+5. If PCRE was compiled with UTF-8 support, but called without the PCRE_UTF8
+   option, a class that contained several characters, but with at least one
+   whose value was between 128 and 255 caused PCRE to crash.
+
+
+Version 4.1 12-Mar-03
+---------------------
+
+1. Compiling with gcc -pedantic found a couple of places where casts were
+needed, and a string in dftables.c that was longer than standard compilers are
+required to support.
+
+2. Compiling with Sun's compiler found a few more places where the code could
+be tidied up in order to avoid warnings.
+
+3. The variables for cross-compiling were called HOST_CC and HOST_CFLAGS; the
+first of these names is deprecated in the latest Autoconf in favour of the name
+CC_FOR_BUILD, because "host" is typically used to mean the system on which the
+compiled code will be run. I can't find a reference for HOST_CFLAGS, but by
+analogy I have changed it to CFLAGS_FOR_BUILD.
+
+4. Added -no-undefined to the linking command in the Makefile, because this is
+apparently helpful for Windows. To make it work, also added "-L. -lpcre" to the
+linking step for the pcreposix library.
+
+5. PCRE was failing to diagnose the case of two named groups with the same
+name.
+
+6. A problem with one of PCRE's optimizations was discovered. PCRE remembers a
+literal character that is needed in the subject for a match, and scans along to
+ensure that it is present before embarking on the full matching process. This
+saves time in cases of nested unlimited repeats that are never going to match.
+Problem: the scan can take a lot of time if the subject is very long (e.g.
+megabytes), thus penalizing straightforward matches. It is now done only if the
+amount of subject to be scanned is less than 1000 bytes.
+
+7. A lesser problem with the same optimization is that it was recording the
+first character of an anchored pattern as "needed", thus provoking a search
+right along the subject, even when the first match of the pattern was going to
+fail. The "needed" character is now not set for anchored patterns, unless it
+follows something in the pattern that is of non-fixed length. Thus, it still
+fulfils its original purpose of finding quick non-matches in cases of nested
+unlimited repeats, but isn't used for simple anchored patterns such as /^abc/.
+
+
+Version 4.0 17-Feb-03
+---------------------
+
+1. If a comment in an extended regex that started immediately after a meta-item
+extended to the end of string, PCRE compiled incorrect data. This could lead to
+all kinds of weird effects. Example: /#/ was bad; /()#/ was bad; /a#/ was not.
+
+2. Moved to autoconf 2.53 and libtool 1.4.2.
+
+3. Perl 5.8 no longer needs "use utf8" for doing UTF-8 things. Consequently,
+the special perltest8 script is no longer needed - all the tests can be run
+from a single perltest script.
+
+4. From 5.004, Perl has not included the VT character (0x0b) in the set defined
+by \s. It has now been removed in PCRE. This means it isn't recognized as
+whitespace in /x regexes too, which is the same as Perl. Note that the POSIX
+class [:space:] *does* include VT, thereby creating a mess.
+
+5. Added the class [:blank:] (a GNU extension from Perl 5.8) to match only
+space and tab.
+
+6. Perl 5.005 was a long time ago. It's time to amalgamate the tests that use
+its new features into the main test script, reducing the number of scripts.
+
+7. Perl 5.8 has changed the meaning of patterns like /a(?i)b/. Earlier versions
+were backward compatible, and made the (?i) apply to the whole pattern, as if
+/i were given. Now it behaves more logically, and applies the option setting
+only to what follows. PCRE has been changed to follow suit. However, if it
+finds options settings right at the start of the pattern, it extracts them into
+the global options, as before. Thus, they show up in the info data.
+
+8. Added support for the \Q...\E escape sequence. Characters in between are
+treated as literals. This is slightly different from Perl in that $ and @ are
+also handled as literals inside the quotes. In Perl, they will cause variable
+interpolation. Note the following examples:
+
+    Pattern            PCRE matches      Perl matches
+
+    \Qabc$xyz\E        abc$xyz           abc followed by the contents of $xyz
+    \Qabc\$xyz\E       abc\$xyz          abc\$xyz
+    \Qabc\E\$\Qxyz\E   abc$xyz           abc$xyz
+
+For compatibility with Perl, \Q...\E sequences are recognized inside character
+classes as well as outside them.
+
+9. Re-organized 3 code statements in pcretest to avoid "overflow in
+floating-point constant arithmetic" warnings from a Microsoft compiler. Added a
+(size_t) cast to one statement in pcretest and one in pcreposix to avoid
+signed/unsigned warnings.
+
+10. SunOS4 doesn't have strtoul(). This was used only for unpicking the -o
+option for pcretest, so I've replaced it by a simple function that does just
+that job.
+
+11. pcregrep was ending with code 0 instead of 2 for the commands "pcregrep" or
+"pcregrep -".
+
+12. Added "possessive quantifiers" ?+, *+, ++, and {,}+ which come from Sun's
+Java package. This provides some syntactic sugar for simple cases of what my
+documentation calls "once-only subpatterns". A pattern such as x*+ is the same
+as (?>x*). In other words, if what is inside (?>...) is just a single repeated
+item, you can use this simplified notation. Note that only makes sense with
+greedy quantifiers. Consequently, the use of the possessive quantifier forces
+greediness, whatever the setting of the PCRE_UNGREEDY option.
+
+13. A change of greediness default within a pattern was not taking effect at
+the current level for patterns like /(b+(?U)a+)/. It did apply to parenthesized
+subpatterns that followed. Patterns like /b+(?U)a+/ worked because the option
+was abstracted outside.
+
+14. PCRE now supports the \G assertion. It is true when the current matching
+position is at the start point of the match. This differs from \A when the
+starting offset is non-zero. Used with the /g option of pcretest (or similar
+code), it works in the same way as it does for Perl's /g option. If all
+alternatives of a regex begin with \G, the expression is anchored to the start
+match position, and the "anchored" flag is set in the compiled expression.
+
+15. Some bugs concerning the handling of certain option changes within patterns
+have been fixed. These applied to options other than (?ims). For example,
+"a(?x: b c )d" did not match "XabcdY" but did match "Xa b c dY". It should have
+been the other way round. Some of this was related to change 7 above.
+
+16. PCRE now gives errors for /[.x.]/ and /[=x=]/ as unsupported POSIX
+features, as Perl does. Previously, PCRE gave the warnings only for /[[.x.]]/
+and /[[=x=]]/. PCRE now also gives an error for /[:name:]/ because it supports
+POSIX classes only within a class (e.g. /[[:alpha:]]/).
+
+17. Added support for Perl's \C escape. This matches one byte, even in UTF8
+mode. Unlike ".", it always matches newline, whatever the setting of
+PCRE_DOTALL. However, PCRE does not permit \C to appear in lookbehind
+assertions. Perl allows it, but it doesn't (in general) work because it can't
+calculate the length of the lookbehind. At least, that's the case for Perl
+5.8.0 - I've been told they are going to document that it doesn't work in
+future.
+
+18. Added an error diagnosis for escapes that PCRE does not support: these are
+\L, \l, \N, \P, \p, \U, \u, and \X.
+
+19. Although correctly diagnosing a missing ']' in a character class, PCRE was
+reading past the end of the pattern in cases such as /[abcd/.
+
+20. PCRE was getting more memory than necessary for patterns with classes that
+contained both POSIX named classes and other characters, e.g. /[[:space:]abc/.
+
+21. Added some code, conditional on #ifdef VPCOMPAT, to make life easier for
+compiling PCRE for use with Virtual Pascal.
+
+22. Small fix to the Makefile to make it work properly if the build is done
+outside the source tree.
+
+23. Added a new extension: a condition to go with recursion. If a conditional
+subpattern starts with (?(R) the "true" branch is used if recursion has
+happened, whereas the "false" branch is used only at the top level.
+
+24. When there was a very long string of literal characters (over 255 bytes
+without UTF support, over 250 bytes with UTF support), the computation of how
+much memory was required could be incorrect, leading to segfaults or other
+strange effects.
+
+25. PCRE was incorrectly assuming anchoring (either to start of subject or to
+start of line for a non-DOTALL pattern) when a pattern started with (.*) and
+there was a subsequent back reference to those brackets. This meant that, for
+example, /(.*)\d+\1/ failed to match "abc123bc". Unfortunately, it isn't
+possible to check for precisely this case. All we can do is abandon the
+optimization if .* occurs inside capturing brackets when there are any back
+references whatsoever. (See below for a better fix that came later.)
+
+26. The handling of the optimization for finding the first character of a
+non-anchored pattern, and for finding a character that is required later in the
+match were failing in some cases. This didn't break the matching; it just
+failed to optimize when it could. The way this is done has been re-implemented.
+
+27. Fixed typo in error message for invalid (?R item (it said "(?p").
+
+28. Added a new feature that provides some of the functionality that Perl
+provides with (?{...}). The facility is termed a "callout". The way it is done
+in PCRE is for the caller to provide an optional function, by setting
+pcre_callout to its entry point. Like pcre_malloc and pcre_free, this is a
+global variable. By default it is unset, which disables all calling out. To get
+the function called, the regex must include (?C) at appropriate points. This
+is, in fact, equivalent to (?C0), and any number <= 255 may be given with (?C).
+This provides a means of identifying different callout points. When PCRE
+reaches such a point in the regex, if pcre_callout has been set, the external
+function is called. It is provided with data in a structure called
+pcre_callout_block, which is defined in pcre.h. If the function returns 0,
+matching continues; if it returns a non-zero value, the match at the current
+point fails. However, backtracking will occur if possible. [This was changed
+later and other features added - see item 49 below.]
+
+29. pcretest is upgraded to test the callout functionality. It provides a
+callout function that displays information. By default, it shows the start of
+the match and the current position in the text. There are some new data escapes
+to vary what happens:
+
+    \C+         in addition, show current contents of captured substrings
+    \C-         do not supply a callout function
+    \C!n        return 1 when callout number n is reached
+    \C!n!m      return 1 when callout number n is reached for the mth time
+
+30. If pcregrep was called with the -l option and just a single file name, it
+output "<stdin>" if a match was found, instead of the file name.
+
+31. Improve the efficiency of the POSIX API to PCRE. If the number of capturing
+slots is less than POSIX_MALLOC_THRESHOLD, use a block on the stack to pass to
+pcre_exec(). This saves a malloc/free per call. The default value of
+POSIX_MALLOC_THRESHOLD is 10; it can be changed by --with-posix-malloc-threshold
+when configuring.
+
+32. The default maximum size of a compiled pattern is 64K. There have been a
+few cases of people hitting this limit. The code now uses macros to handle the
+storing of links as offsets within the compiled pattern. It defaults to 2-byte
+links, but this can be changed to 3 or 4 bytes by --with-link-size when
+configuring. Tests 2 and 5 work only with 2-byte links because they output
+debugging information about compiled patterns.
+
+33. Internal code re-arrangements:
+
+(a) Moved the debugging function for printing out a compiled regex into
+    its own source file (printint.c) and used #include to pull it into
+    pcretest.c and, when DEBUG is defined, into pcre.c, instead of having two
+    separate copies.
+
+(b) Defined the list of op-code names for debugging as a macro in
+    internal.h so that it is next to the definition of the opcodes.
+
+(c) Defined a table of op-code lengths for simpler skipping along compiled
+    code. This is again a macro in internal.h so that it is next to the
+    definition of the opcodes.
+
+34. Added support for recursive calls to individual subpatterns, along the
+lines of Robin Houston's patch (but implemented somewhat differently).
+
+35. Further mods to the Makefile to help Win32. Also, added code to pcregrep to
+allow it to read and process whole directories in Win32. This code was
+contributed by Lionel Fourquaux; it has not been tested by me.
+
+36. Added support for named subpatterns. The Python syntax (?P<name>...) is
+used to name a group. Names consist of alphanumerics and underscores, and must
+be unique. Back references use the syntax (?P=name) and recursive calls use
+(?P>name) which is a PCRE extension to the Python extension. Groups still have
+numbers. The function pcre_fullinfo() can be used after compilation to extract
+a name/number map. There are three relevant calls:
+
+  PCRE_INFO_NAMEENTRYSIZE        yields the size of each entry in the map
+  PCRE_INFO_NAMECOUNT            yields the number of entries
+  PCRE_INFO_NAMETABLE            yields a pointer to the map.
+
+The map is a vector of fixed-size entries. The size of each entry depends on
+the length of the longest name used. The first two bytes of each entry are the
+group number, most significant byte first. There follows the corresponding
+name, zero terminated. The names are in alphabetical order.
+
+37. Make the maximum literal string in the compiled code 250 for the non-UTF-8
+case instead of 255. Making it the same both with and without UTF-8 support
+means that the same test output works with both.
+
+38. There was a case of malloc(0) in the POSIX testing code in pcretest. Avoid
+calling malloc() with a zero argument.
+
+39. Change 25 above had to resort to a heavy-handed test for the .* anchoring
+optimization. I've improved things by keeping a bitmap of backreferences with
+numbers 1-31 so that if .* occurs inside capturing brackets that are not in
+fact referenced, the optimization can be applied. It is unlikely that a
+relevant occurrence of .* (i.e. one which might indicate anchoring or forcing
+the match to follow \n) will appear inside brackets with a number greater than
+31, but if it does, any back reference > 31 suppresses the optimization.
+
+40. Added a new compile-time option PCRE_NO_AUTO_CAPTURE. This has the effect
+of disabling numbered capturing parentheses. Any opening parenthesis that is
+not followed by ? behaves as if it were followed by ?: but named parentheses
+can still be used for capturing (and they will acquire numbers in the usual
+way).
+
+41. Redesigned the return codes from the match() function into yes/no/error so
+that errors can be passed back from deep inside the nested calls. A malloc
+failure while inside a recursive subpattern call now causes the
+PCRE_ERROR_NOMEMORY return instead of quietly going wrong.
+
+42. It is now possible to set a limit on the number of times the match()
+function is called in a call to pcre_exec(). This facility makes it possible to
+limit the amount of recursion and backtracking, though not in a directly
+obvious way, because the match() function is used in a number of different
+circumstances. The count starts from zero for each position in the subject
+string (for non-anchored patterns). The default limit is, for compatibility, a
+large number, namely 10 000 000. You can change this in two ways:
+
+(a) When configuring PCRE before making, you can use --with-match-limit=n
+    to set a default value for the compiled library.
+
+(b) For each call to pcre_exec(), you can pass a pcre_extra block in which
+    a different value is set. See 45 below.
+
+If the limit is exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
+
+43. Added a new function pcre_config(int, void *) to enable run-time extraction
+of things that can be changed at compile time. The first argument specifies
+what is wanted and the second points to where the information is to be placed.
+The current list of available information is:
+
+  PCRE_CONFIG_UTF8
+
+The output is an integer that is set to one if UTF-8 support is available;
+otherwise it is set to zero.
+
+  PCRE_CONFIG_NEWLINE
+
+The output is an integer that it set to the value of the code that is used for
+newline. It is either LF (10) or CR (13).
+
+  PCRE_CONFIG_LINK_SIZE
+
+The output is an integer that contains the number of bytes used for internal
+linkage in compiled expressions. The value is 2, 3, or 4. See item 32 above.
+
+  PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+
+The output is an integer that contains the threshold above which the POSIX
+interface uses malloc() for output vectors. See item 31 above.
+
+  PCRE_CONFIG_MATCH_LIMIT
+
+The output is an unsigned integer that contains the default limit of the number
+of match() calls in a pcre_exec() execution. See 42 above.
+
+44. pcretest has been upgraded by the addition of the -C option. This causes it
+to extract all the available output from the new pcre_config() function, and to
+output it. The program then exits immediately.
+
+45. A need has arisen to pass over additional data with calls to pcre_exec() in
+order to support additional features. One way would have been to define
+pcre_exec2() (for example) with extra arguments, but this would not have been
+extensible, and would also have required all calls to the original function to
+be mapped to the new one. Instead, I have chosen to extend the mechanism that
+is used for passing in "extra" data from pcre_study().
+
+The pcre_extra structure is now exposed and defined in pcre.h. It currently
+contains the following fields:
+
+  flags         a bitmap indicating which of the following fields are set
+  study_data    opaque data from pcre_study()
+  match_limit   a way of specifying a limit on match() calls for a specific
+                  call to pcre_exec()
+  callout_data  data for callouts (see 49 below)
+
+The flag bits are also defined in pcre.h, and are
+
+  PCRE_EXTRA_STUDY_DATA
+  PCRE_EXTRA_MATCH_LIMIT
+  PCRE_EXTRA_CALLOUT_DATA
+
+The pcre_study() function now returns one of these new pcre_extra blocks, with
+the actual study data pointed to by the study_data field, and the
+PCRE_EXTRA_STUDY_DATA flag set. This can be passed directly to pcre_exec() as
+before. That is, this change is entirely upwards-compatible and requires no
+change to existing code.
+
+If you want to pass in additional data to pcre_exec(), you can either place it
+in a pcre_extra block provided by pcre_study(), or create your own pcre_extra
+block.
+
+46. pcretest has been extended to test the PCRE_EXTRA_MATCH_LIMIT feature. If a
+data string contains the escape sequence \M, pcretest calls pcre_exec() several
+times with different match limits, until it finds the minimum value needed for
+pcre_exec() to complete. The value is then output. This can be instructive; for
+most simple matches the number is quite small, but for pathological cases it
+gets very large very quickly.
+
+47. There's a new option for pcre_fullinfo() called PCRE_INFO_STUDYSIZE. It
+returns the size of the data block pointed to by the study_data field in a
+pcre_extra block, that is, the value that was passed as the argument to
+pcre_malloc() when PCRE was getting memory in which to place the information
+created by pcre_study(). The fourth argument should point to a size_t variable.
+pcretest has been extended so that this information is shown after a successful
+pcre_study() call when information about the compiled regex is being displayed.
+
+48. Cosmetic change to Makefile: there's no need to have / after $(DESTDIR)
+because what follows is always an absolute path. (Later: it turns out that this
+is more than cosmetic for MinGW, because it doesn't like empty path
+components.)
+
+49. Some changes have been made to the callout feature (see 28 above):
+
+(i)  A callout function now has three choices for what it returns:
+
+       0  =>  success, carry on matching
+     > 0  =>  failure at this point, but backtrack if possible
+     < 0  =>  serious error, return this value from pcre_exec()
+
+     Negative values should normally be chosen from the set of PCRE_ERROR_xxx
+     values. In particular, returning PCRE_ERROR_NOMATCH forces a standard
+     "match failed" error. The error number PCRE_ERROR_CALLOUT is reserved for
+     use by callout functions. It will never be used by PCRE itself.
+
+(ii) The pcre_extra structure (see 45 above) has a void * field called
+     callout_data, with corresponding flag bit PCRE_EXTRA_CALLOUT_DATA. The
+     pcre_callout_block structure has a field of the same name. The contents of
+     the field passed in the pcre_extra structure are passed to the callout
+     function in the corresponding field in the callout block. This makes it
+     easier to use the same callout-containing regex from multiple threads. For
+     testing, the pcretest program has a new data escape
+
+       \C*n        pass the number n (may be negative) as callout_data
+
+     If the callout function in pcretest receives a non-zero value as
+     callout_data, it returns that value.
+
+50. Makefile wasn't handling CFLAGS properly when compiling dftables. Also,
+there were some redundant $(CFLAGS) in commands that are now specified as
+$(LINK), which already includes $(CFLAGS).
+
+51. Extensions to UTF-8 support are listed below. These all apply when (a) PCRE
+has been compiled with UTF-8 support *and* pcre_compile() has been compiled
+with the PCRE_UTF8 flag. Patterns that are compiled without that flag assume
+one-byte characters throughout. Note that case-insensitive matching applies
+only to characters whose values are less than 256. PCRE doesn't support the
+notion of cases for higher-valued characters.
+
+(i)   A character class whose characters are all within 0-255 is handled as
+      a bit map, and the map is inverted for negative classes. Previously, a
+      character > 255 always failed to match such a class; however it should
+      match if the class was a negative one (e.g. [^ab]). This has been fixed.
+
+(ii)  A negated character class with a single character < 255 is coded as
+      "not this character" (OP_NOT). This wasn't working properly when the test
+      character was multibyte, either singly or repeated.
+
+(iii) Repeats of multibyte characters are now handled correctly in UTF-8
+      mode, for example: \x{100}{2,3}.
+
+(iv)  The character escapes \b, \B, \d, \D, \s, \S, \w, and \W (either
+      singly or repeated) now correctly test multibyte characters. However,
+      PCRE doesn't recognize any characters with values greater than 255 as
+      digits, spaces, or word characters. Such characters always match \D, \S,
+      and \W, and never match \d, \s, or \w.
+
+(v)   Classes may now contain characters and character ranges with values
+      greater than 255. For example: [ab\x{100}-\x{400}].
+
+(vi)  pcregrep now has a --utf-8 option (synonym -u) which makes it call
+      PCRE in UTF-8 mode.
+
+52. The info request value PCRE_INFO_FIRSTCHAR has been renamed
+PCRE_INFO_FIRSTBYTE because it is a byte value. However, the old name is
+retained for backwards compatibility. (Note that LASTLITERAL is also a byte
+value.)
+
+53. The single man page has become too large. I have therefore split it up into
+a number of separate man pages. These also give rise to individual HTML pages;
+these are now put in a separate directory, and there is an index.html page that
+lists them all. Some hyperlinking between the pages has been installed.
+
+54. Added convenience functions for handling named capturing parentheses.
+
+55. Unknown escapes inside character classes (e.g. [\M]) and escapes that
+aren't interpreted therein (e.g. [\C]) are literals in Perl. This is now also
+true in PCRE, except when the PCRE_EXTENDED option is set, in which case they
+are faulted.
+
+56. Introduced HOST_CC and HOST_CFLAGS which can be set in the environment when
+calling configure. These values are used when compiling the dftables.c program
+which is run to generate the source of the default character tables. They
+default to the values of CC and CFLAGS. If you are cross-compiling PCRE,
+you will need to set these values.
+
+57. Updated the building process for Windows DLL, as provided by Fred Cox.
+
+
+Version 3.9 02-Jan-02
+---------------------
+
+1. A bit of extraneous text had somehow crept into the pcregrep documentation.
+
+2. If --disable-static was given, the building process failed when trying to
+build pcretest and pcregrep. (For some reason it was using libtool to compile
+them, which is not right, as they aren't part of the library.)
+
+
+Version 3.8 18-Dec-01
+---------------------
+
+1. The experimental UTF-8 code was completely screwed up. It was packing the
+bytes in the wrong order. How dumb can you get?
+
+
+Version 3.7 29-Oct-01
+---------------------
+
+1. In updating pcretest to check change 1 of version 3.6, I screwed up.
+This caused pcretest, when used on the test data, to segfault. Unfortunately,
+this didn't happen under Solaris 8, where I normally test things.
+
+2. The Makefile had to be changed to make it work on BSD systems, where 'make'
+doesn't seem to recognize that ./xxx and xxx are the same file. (This entry
+isn't in ChangeLog distributed with 3.7 because I forgot when I hastily made
+this fix an hour or so after the initial 3.7 release.)
+
+
+Version 3.6 23-Oct-01
+---------------------
+
+1. Crashed with /(sens|respons)e and \1ibility/ and "sense and sensibility" if
+offsets passed as NULL with zero offset count.
+
+2. The config.guess and config.sub files had not been updated when I moved to
+the latest autoconf.
+
+
+Version 3.5 15-Aug-01
+---------------------
+
+1. Added some missing #if !defined NOPOSIX conditionals in pcretest.c that
+had been forgotten.
+
+2. By using declared but undefined structures, we can avoid using "void"
+definitions in pcre.h while keeping the internal definitions of the structures
+private.
+
+3. The distribution is now built using autoconf 2.50 and libtool 1.4. From a
+user point of view, this means that both static and shared libraries are built
+by default, but this can be individually controlled. More of the work of
+handling this static/shared cases is now inside libtool instead of PCRE's make
+file.
+
+4. The pcretest utility is now installed along with pcregrep because it is
+useful for users (to test regexs) and by doing this, it automatically gets
+relinked by libtool. The documentation has been turned into a man page, so
+there are now .1, .txt, and .html versions in /doc.
+
+5. Upgrades to pcregrep:
+   (i)   Added long-form option names like gnu grep.
+   (ii)  Added --help to list all options with an explanatory phrase.
+   (iii) Added -r, --recursive to recurse into sub-directories.
+   (iv)  Added -f, --file to read patterns from a file.
+
+6. pcre_exec() was referring to its "code" argument before testing that
+argument for NULL (and giving an error if it was NULL).
+
+7. Upgraded Makefile.in to allow for compiling in a different directory from
+the source directory.
+
+8. Tiny buglet in pcretest: when pcre_fullinfo() was called to retrieve the
+options bits, the pointer it was passed was to an int instead of to an unsigned
+long int. This mattered only on 64-bit systems.
+
+9. Fixed typo (3.4/1) in pcre.h again. Sigh. I had changed pcre.h (which is
+generated) instead of pcre.in, which it its source. Also made the same change
+in several of the .c files.
+
+10. A new release of gcc defines printf() as a macro, which broke pcretest
+because it had an ifdef in the middle of a string argument for printf(). Fixed
+by using separate calls to printf().
+
+11. Added --enable-newline-is-cr and --enable-newline-is-lf to the configure
+script, to force use of CR or LF instead of \n in the source. On non-Unix
+systems, the value can be set in config.h.
+
+12. The limit of 200 on non-capturing parentheses is a _nesting_ limit, not an
+absolute limit. Changed the text of the error message to make this clear, and
+likewise updated the man page.
+
+13. The limit of 99 on the number of capturing subpatterns has been removed.
+The new limit is 65535, which I hope will not be a "real" limit.
+
+
+Version 3.4 22-Aug-00
+---------------------
+
+1. Fixed typo in pcre.h: unsigned const char * changed to const unsigned char *.
+
+2. Diagnose condition (?(0) as an error instead of crashing on matching.
+
+
+Version 3.3 01-Aug-00
+---------------------
+
+1. If an octal character was given, but the value was greater than \377, it
+was not getting masked to the least significant bits, as documented. This could
+lead to crashes in some systems.
+
+2. Perl 5.6 (if not earlier versions) accepts classes like [a-\d] and treats
+the hyphen as a literal. PCRE used to give an error; it now behaves like Perl.
+
+3. Added the functions pcre_free_substring() and pcre_free_substring_list().
+These just pass their arguments on to (pcre_free)(), but they are provided
+because some uses of PCRE bind it to non-C systems that can call its functions,
+but cannot call free() or pcre_free() directly.
+
+4. Add "make test" as a synonym for "make check". Corrected some comments in
+the Makefile.
+
+5. Add $(DESTDIR)/ in front of all the paths in the "install" target in the
+Makefile.
+
+6. Changed the name of pgrep to pcregrep, because Solaris has introduced a
+command called pgrep for grepping around the active processes.
+
+7. Added the beginnings of support for UTF-8 character strings.
+
+8. Arranged for the Makefile to pass over the settings of CC, CFLAGS, and
+RANLIB to ./ltconfig so that they are used by libtool. I think these are all
+the relevant ones. (AR is not passed because ./ltconfig does its own figuring
+out for the ar command.)
+
+
+Version 3.2 12-May-00
+---------------------
+
+This is purely a bug fixing release.
+
+1. If the pattern /((Z)+|A)*/ was matched agained ZABCDEFG it matched Z instead
+of ZA. This was just one example of several cases that could provoke this bug,
+which was introduced by change 9 of version 2.00. The code for breaking
+infinite loops after an iteration that matches an empty string was't working
+correctly.
+
+2. The pcretest program was not imitating Perl correctly for the pattern /a*/g
+when matched against abbab (for example). After matching an empty string, it
+wasn't forcing anchoring when setting PCRE_NOTEMPTY for the next attempt; this
+caused it to match further down the string than it should.
+
+3. The code contained an inclusion of sys/types.h. It isn't clear why this
+was there because it doesn't seem to be needed, and it causes trouble on some
+systems, as it is not a Standard C header. It has been removed.
+
+4. Made 4 silly changes to the source to avoid stupid compiler warnings that
+were reported on the Macintosh. The changes were from
+
+  while ((c = *(++ptr)) != 0 && c != '\n');
+to
+  while ((c = *(++ptr)) != 0 && c != '\n') ;
+
+Totally extraordinary, but if that's what it takes...
+
+5. PCRE is being used in one environment where neither memmove() nor bcopy() is
+available. Added HAVE_BCOPY and an autoconf test for it; if neither
+HAVE_MEMMOVE nor HAVE_BCOPY is set, use a built-in emulation function which
+assumes the way PCRE uses memmove() (always moving upwards).
+
+6. PCRE is being used in one environment where strchr() is not available. There
+was only one use in pcre.c, and writing it out to avoid strchr() probably gives
+faster code anyway.
+
+
+Version 3.1 09-Feb-00
+---------------------
+
+The only change in this release is the fixing of some bugs in Makefile.in for
+the "install" target:
+
+(1) It was failing to install pcreposix.h.
+
+(2) It was overwriting the pcre.3 man page with the pcreposix.3 man page.
+
+
+Version 3.0 01-Feb-00
+---------------------
+
+1. Add support for the /+ modifier to perltest (to output $` like it does in
+pcretest).
+
+2. Add support for the /g modifier to perltest.
+
+3. Fix pcretest so that it behaves even more like Perl for /g when the pattern
+matches null strings.
+
+4. Fix perltest so that it doesn't do unwanted things when fed an empty
+pattern. Perl treats empty patterns specially - it reuses the most recent
+pattern, which is not what we want. Replace // by /(?#)/ in order to avoid this
+effect.
+
+5. The POSIX interface was broken in that it was just handing over the POSIX
+captured string vector to pcre_exec(), but (since release 2.00) PCRE has
+required a bigger vector, with some working space on the end. This means that
+the POSIX wrapper now has to get and free some memory, and copy the results.
+
+6. Added some simple autoconf support, placing the test data and the
+documentation in separate directories, re-organizing some of the
+information files, and making it build pcre-config (a GNU standard). Also added
+libtool support for building PCRE as a shared library, which is now the
+default.
+
+7. Got rid of the leading zero in the definition of PCRE_MINOR because 08 and
+09 are not valid octal constants. Single digits will be used for minor values
+less than 10.
+
+8. Defined REG_EXTENDED and REG_NOSUB as zero in the POSIX header, so that
+existing programs that set these in the POSIX interface can use PCRE without
+modification.
+
+9. Added a new function, pcre_fullinfo() with an extensible interface. It can
+return all that pcre_info() returns, plus additional data. The pcre_info()
+function is retained for compatibility, but is considered to be obsolete.
+
+10. Added experimental recursion feature (?R) to handle one common case that
+Perl 5.6 will be able to do with (?p{...}).
+
+11. Added support for POSIX character classes like [:alpha:], which Perl is
+adopting.
+
+
+Version 2.08 31-Aug-99
+----------------------
+
+1. When startoffset was not zero and the pattern began with ".*", PCRE was not
+trying to match at the startoffset position, but instead was moving forward to
+the next newline as if a previous match had failed.
+
+2. pcretest was not making use of PCRE_NOTEMPTY when repeating for /g and /G,
+and could get into a loop if a null string was matched other than at the start
+of the subject.
+
+3. Added definitions of PCRE_MAJOR and PCRE_MINOR to pcre.h so the version can
+be distinguished at compile time, and for completeness also added PCRE_DATE.
+
+5. Added Paul Sokolovsky's minor changes to make it easy to compile a Win32 DLL
+in GnuWin32 environments.
+
+
+Version 2.07 29-Jul-99
+----------------------
+
+1. The documentation is now supplied in plain text form and HTML as well as in
+the form of man page sources.
+
+2. C++ compilers don't like assigning (void *) values to other pointer types.
+In particular this affects malloc(). Although there is no problem in Standard
+C, I've put in casts to keep C++ compilers happy.
+
+3. Typo on pcretest.c; a cast of (unsigned char *) in the POSIX regexec() call
+should be (const char *).
+
+4. If NOPOSIX is defined, pcretest.c compiles without POSIX support. This may
+be useful for non-Unix systems who don't want to bother with the POSIX stuff.
+However, I haven't made this a standard facility. The documentation doesn't
+mention it, and the Makefile doesn't support it.
+
+5. The Makefile now contains an "install" target, with editable destinations at
+the top of the file. The pcretest program is not installed.
+
+6. pgrep -V now gives the PCRE version number and date.
+
+7. Fixed bug: a zero repetition after a literal string (e.g. /abcde{0}/) was
+causing the entire string to be ignored, instead of just the last character.
+
+8. If a pattern like /"([^\\"]+|\\.)*"/ is applied in the normal way to a
+non-matching string, it can take a very, very long time, even for strings of
+quite modest length, because of the nested recursion. PCRE now does better in
+some of these cases. It does this by remembering the last required literal
+character in the pattern, and pre-searching the subject to ensure it is present
+before running the real match. In other words, it applies a heuristic to detect
+some types of certain failure quickly, and in the above example, if presented
+with a string that has no trailing " it gives "no match" very quickly.
+
+9. A new runtime option PCRE_NOTEMPTY causes null string matches to be ignored;
+other alternatives are tried instead.
+
+
+Version 2.06 09-Jun-99
+----------------------
+
+1. Change pcretest's output for amount of store used to show just the code
+space, because the remainder (the data block) varies in size between 32-bit and
+64-bit systems.
+
+2. Added an extra argument to pcre_exec() to supply an offset in the subject to
+start matching at. This allows lookbehinds to work when searching for multiple
+occurrences in a string.
+
+3. Added additional options to pcretest for testing multiple occurrences:
+
+   /+   outputs the rest of the string that follows a match
+   /g   loops for multiple occurrences, using the new startoffset argument
+   /G   loops for multiple occurrences by passing an incremented pointer
+
+4. PCRE wasn't doing the "first character" optimization for patterns starting
+with \b or \B, though it was doing it for other lookbehind assertions. That is,
+it wasn't noticing that a match for a pattern such as /\bxyz/ has to start with
+the letter 'x'. On long subject strings, this gives a significant speed-up.
+
+
+Version 2.05 21-Apr-99
+----------------------
+
+1. Changed the type of magic_number from int to long int so that it works
+properly on 16-bit systems.
+
+2. Fixed a bug which caused patterns starting with .* not to work correctly
+when the subject string contained newline characters. PCRE was assuming
+anchoring for such patterns in all cases, which is not correct because .* will
+not pass a newline unless PCRE_DOTALL is set. It now assumes anchoring only if
+DOTALL is set at top level; otherwise it knows that patterns starting with .*
+must be retried after every newline in the subject.
+
+
+Version 2.04 18-Feb-99
+----------------------
+
+1. For parenthesized subpatterns with repeats whose minimum was zero, the
+computation of the store needed to hold the pattern was incorrect (too large).
+If such patterns were nested a few deep, this could multiply and become a real
+problem.
+
+2. Added /M option to pcretest to show the memory requirement of a specific
+pattern. Made -m a synonym of -s (which does this globally) for compatibility.
+
+3. Subpatterns of the form (regex){n,m} (i.e. limited maximum) were being
+compiled in such a way that the backtracking after subsequent failure was
+pessimal. Something like (a){0,3} was compiled as (a)?(a)?(a)? instead of
+((a)((a)(a)?)?)? with disastrous performance if the maximum was of any size.
+
+
+Version 2.03 02-Feb-99
+----------------------
+
+1. Fixed typo and small mistake in man page.
+
+2. Added 4th condition (GPL supersedes if conflict) and created separate
+LICENCE file containing the conditions.
+
+3. Updated pcretest so that patterns such as /abc\/def/ work like they do in
+Perl, that is the internal \ allows the delimiter to be included in the
+pattern. Locked out the use of \ as a delimiter. If \ immediately follows
+the final delimiter, add \ to the end of the pattern (to test the error).
+
+4. Added the convenience functions for extracting substrings after a successful
+match. Updated pcretest to make it able to test these functions.
+
+
+Version 2.02 14-Jan-99
+----------------------
+
+1. Initialized the working variables associated with each extraction so that
+their saving and restoring doesn't refer to uninitialized store.
+
+2. Put dummy code into study.c in order to trick the optimizer of the IBM C
+compiler for OS/2 into generating correct code. Apparently IBM isn't going to
+fix the problem.
+
+3. Pcretest: the timing code wasn't using LOOPREPEAT for timing execution
+calls, and wasn't printing the correct value for compiling calls. Increased the
+default value of LOOPREPEAT, and the number of significant figures in the
+times.
+
+4. Changed "/bin/rm" in the Makefile to "-rm" so it works on Windows NT.
+
+5. Renamed "deftables" as "dftables" to get it down to 8 characters, to avoid
+a building problem on Windows NT with a FAT file system.
+
+
+Version 2.01 21-Oct-98
+----------------------
+
+1. Changed the API for pcre_compile() to allow for the provision of a pointer
+to character tables built by pcre_maketables() in the current locale. If NULL
+is passed, the default tables are used.
+
+
+Version 2.00 24-Sep-98
+----------------------
+
+1. Since the (>?) facility is in Perl 5.005, don't require PCRE_EXTRA to enable
+it any more.
+
+2. Allow quantification of (?>) groups, and make it work correctly.
+
+3. The first character computation wasn't working for (?>) groups.
+
+4. Correct the implementation of \Z (it is permitted to match on the \n at the
+end of the subject) and add 5.005's \z, which really does match only at the
+very end of the subject.
+
+5. Remove the \X "cut" facility; Perl doesn't have it, and (?> is neater.
+
+6. Remove the ability to specify CASELESS, MULTILINE, DOTALL, and
+DOLLAR_END_ONLY at runtime, to make it possible to implement the Perl 5.005
+localized options. All options to pcre_study() were also removed.
+
+7. Add other new features from 5.005:
+
+   $(?<=           positive lookbehind
+   $(?<!           negative lookbehind
+   (?imsx-imsx)    added the unsetting capability
+                   such a setting is global if at outer level; local otherwise
+   (?imsx-imsx:)   non-capturing groups with option setting
+   (?(cond)re|re)  conditional pattern matching
+
+   A backreference to itself in a repeated group matches the previous
+   captured string.
+
+8. General tidying up of studying (both automatic and via "study")
+consequential on the addition of new assertions.
+
+9. As in 5.005, unlimited repeated groups that could match an empty substring
+are no longer faulted at compile time. Instead, the loop is forcibly broken at
+runtime if any iteration does actually match an empty substring.
+
+10. Include the RunTest script in the distribution.
+
+11. Added tests from the Perl 5.005_02 distribution. This showed up a few
+discrepancies, some of which were old and were also with respect to 5.004. They
+have now been fixed.
+
+
+Version 1.09 28-Apr-98
+----------------------
+
+1. A negated single character class followed by a quantifier with a minimum
+value of one (e.g.  [^x]{1,6}  ) was not compiled correctly. This could lead to
+program crashes, or just wrong answers. This did not apply to negated classes
+containing more than one character, or to minima other than one.
+
+
+Version 1.08 27-Mar-98
+----------------------
+
+1. Add PCRE_UNGREEDY to invert the greediness of quantifiers.
+
+2. Add (?U) and (?X) to set PCRE_UNGREEDY and PCRE_EXTRA respectively. The
+latter must appear before anything that relies on it in the pattern.
+
+
+Version 1.07 16-Feb-98
+----------------------
+
+1. A pattern such as /((a)*)*/ was not being diagnosed as in error (unlimited
+repeat of a potentially empty string).
+
+
+Version 1.06 23-Jan-98
+----------------------
+
+1. Added Markus Oberhumer's little patches for C++.
+
+2. Literal strings longer than 255 characters were broken.
+
+
+Version 1.05 23-Dec-97
+----------------------
+
+1. Negated character classes containing more than one character were failing if
+PCRE_CASELESS was set at run time.
+
+
+Version 1.04 19-Dec-97
+----------------------
+
+1. Corrected the man page, where some "const" qualifiers had been omitted.
+
+2. Made debugging output print "{0,xxx}" instead of just "{,xxx}" to agree with
+input syntax.
+
+3. Fixed memory leak which occurred when a regex with back references was
+matched with an offsets vector that wasn't big enough. The temporary memory
+that is used in this case wasn't being freed if the match failed.
+
+4. Tidied pcretest to ensure it frees memory that it gets.
+
+5. Temporary memory was being obtained in the case where the passed offsets
+vector was exactly big enough.
+
+6. Corrected definition of offsetof() from change 5 below.
+
+7. I had screwed up change 6 below and broken the rules for the use of
+setjmp(). Now fixed.
+
+
+Version 1.03 18-Dec-97
+----------------------
+
+1. A erroneous regex with a missing opening parenthesis was correctly
+diagnosed, but PCRE attempted to access brastack[-1], which could cause crashes
+on some systems.
+
+2. Replaced offsetof(real_pcre, code) by offsetof(real_pcre, code[0]) because
+it was reported that one broken compiler failed on the former because "code" is
+also an independent variable.
+
+3. The erroneous regex a[]b caused an array overrun reference.
+
+4. A regex ending with a one-character negative class (e.g. /[^k]$/) did not
+fail on data ending with that character. (It was going on too far, and checking
+the next character, typically a binary zero.) This was specific to the
+optimized code for single-character negative classes.
+
+5. Added a contributed patch from the TIN world which does the following:
+
+  + Add an undef for memmove, in case the the system defines a macro for it.
+
+  + Add a definition of offsetof(), in case there isn't one. (I don't know
+    the reason behind this - offsetof() is part of the ANSI standard - but
+    it does no harm).
+
+  + Reduce the ifdef's in pcre.c using macro DPRINTF, thereby eliminating
+    most of the places where whitespace preceded '#'. I have given up and
+    allowed the remaining 2 cases to be at the margin.
+
+  + Rename some variables in pcre to eliminate shadowing. This seems very
+    pedantic, but does no harm, of course.
+
+6. Moved the call to setjmp() into its own function, to get rid of warnings
+from gcc -Wall, and avoided calling it at all unless PCRE_EXTRA is used.
+
+7. Constructs such as \d{8,} were compiling into the equivalent of
+\d{8}\d{0,65527} instead of \d{8}\d* which didn't make much difference to the
+outcome, but in this particular case used more store than had been allocated,
+which caused the bug to be discovered because it threw up an internal error.
+
+8. The debugging code in both pcre and pcretest for outputting the compiled
+form of a regex was going wrong in the case of back references followed by
+curly-bracketed repeats.
+
+
+Version 1.02 12-Dec-97
+----------------------
+
+1. Typos in pcre.3 and comments in the source fixed.
+
+2. Applied a contributed patch to get rid of places where it used to remove
+'const' from variables, and fixed some signed/unsigned and uninitialized
+variable warnings.
+
+3. Added the "runtest" target to Makefile.
+
+4. Set default compiler flag to -O2 rather than just -O.
+
+
+Version 1.01 19-Nov-97
+----------------------
+
+1. PCRE was failing to diagnose unlimited repeat of empty string for patterns
+like /([ab]*)*/, that is, for classes with more than one character in them.
+
+2. Likewise, it wasn't diagnosing patterns with "once-only" subpatterns, such
+as /((?>a*))*/ (a PCRE_EXTRA facility).
+
+
+Version 1.00 18-Nov-97
+----------------------
+
+1. Added compile-time macros to support systems such as SunOS4 which don't have
+memmove() or strerror() but have other things that can be used instead.
+
+2. Arranged that "make clean" removes the executables.
+
+
+Version 0.99 27-Oct-97
+----------------------
+
+1. Fixed bug in code for optimizing classes with only one character. It was
+initializing a 32-byte map regardless, which could cause it to run off the end
+of the memory it had got.
+
+2. Added, conditional on PCRE_EXTRA, the proposed (?>REGEX) construction.
+
+
+Version 0.98 22-Oct-97
+----------------------
+
+1. Fixed bug in code for handling temporary memory usage when there are more
+back references than supplied space in the ovector. This could cause segfaults.
+
+
+Version 0.97 21-Oct-97
+----------------------
+
+1. Added the \X "cut" facility, conditional on PCRE_EXTRA.
+
+2. Optimized negated single characters not to use a bit map.
+
+3. Brought error texts together as macro definitions; clarified some of them;
+fixed one that was wrong - it said "range out of order" when it meant "invalid
+escape sequence".
+
+4. Changed some char * arguments to const char *.
+
+5. Added PCRE_NOTBOL and PCRE_NOTEOL (from POSIX).
+
+6. Added the POSIX-style API wrapper in pcreposix.a and testing facilities in
+pcretest.
+
+
+Version 0.96 16-Oct-97
+----------------------
+
+1. Added a simple "pgrep" utility to the distribution.
+
+2. Fixed an incompatibility with Perl: "{" is now treated as a normal character
+unless it appears in one of the precise forms "{ddd}", "{ddd,}", or "{ddd,ddd}"
+where "ddd" means "one or more decimal digits".
+
+3. Fixed serious bug. If a pattern had a back reference, but the call to
+pcre_exec() didn't supply a large enough ovector to record the related
+identifying subpattern, the match always failed. PCRE now remembers the number
+of the largest back reference, and gets some temporary memory in which to save
+the offsets during matching if necessary, in order to ensure that
+backreferences always work.
+
+4. Increased the compatibility with Perl in a number of ways:
+
+  (a) . no longer matches \n by default; an option PCRE_DOTALL is provided
+      to request this handling. The option can be set at compile or exec time.
+
+  (b) $ matches before a terminating newline by default; an option
+      PCRE_DOLLAR_ENDONLY is provided to override this (but not in multiline
+      mode). The option can be set at compile or exec time.
+
+  (c) The handling of \ followed by a digit other than 0 is now supposed to be
+      the same as Perl's. If the decimal number it represents is less than 10
+      or there aren't that many previous left capturing parentheses, an octal
+      escape is read. Inside a character class, it's always an octal escape,
+      even if it is a single digit.
+
+  (d) An escaped but undefined alphabetic character is taken as a literal,
+      unless PCRE_EXTRA is set. Currently this just reserves the remaining
+      escapes.
+
+  (e) {0} is now permitted. (The previous item is removed from the compiled
+      pattern).
+
+5. Changed all the names of code files so that the basic parts are no longer
+than 10 characters, and abolished the teeny "globals.c" file.
+
+6. Changed the handling of character classes; they are now done with a 32-byte
+bit map always.
+
+7. Added the -d and /D options to pcretest to make it possible to look at the
+internals of compilation without having to recompile pcre.
+
+
+Version 0.95 23-Sep-97
+----------------------
+
+1. Fixed bug in pre-pass concerning escaped "normal" characters such as \x5c or
+\x20 at the start of a run of normal characters. These were being treated as
+real characters, instead of the source characters being re-checked.
+
+
+Version 0.94 18-Sep-97
+----------------------
+
+1. The functions are now thread-safe, with the caveat that the global variables
+containing pointers to malloc() and free() or alternative functions are the
+same for all threads.
+
+2. Get pcre_study() to generate a bitmap of initial characters for non-
+anchored patterns when this is possible, and use it if passed to pcre_exec().
+
+
+Version 0.93 15-Sep-97
+----------------------
+
+1. /(b)|(:+)/ was computing an incorrect first character.
+
+2. Add pcre_study() to the API and the passing of pcre_extra to pcre_exec(),
+but not actually doing anything yet.
+
+3. Treat "-" characters in classes that cannot be part of ranges as literals,
+as Perl does (e.g. [-az] or [az-]).
+
+4. Set the anchored flag if a branch starts with .* or .*? because that tests
+all possible positions.
+
+5. Split up into different modules to avoid including unneeded functions in a
+compiled binary. However, compile and exec are still in one module. The "study"
+function is split off.
+
+6. The character tables are now in a separate module whose source is generated
+by an auxiliary program - but can then be edited by hand if required. There are
+now no calls to isalnum(), isspace(), isdigit(), isxdigit(), tolower() or
+toupper() in the code.
+
+7. Turn the malloc/free funtions variables into pcre_malloc and pcre_free and
+make them global. Abolish the function for setting them, as the caller can now
+set them directly.
+
+
+Version 0.92 11-Sep-97
+----------------------
+
+1. A repeat with a fixed maximum and a minimum of 1 for an ordinary character
+(e.g. /a{1,3}/) was broken (I mis-optimized it).
+
+2. Caseless matching was not working in character classes if the characters in
+the pattern were in upper case.
+
+3. Make ranges like [W-c] work in the same way as Perl for caseless matching.
+
+4. Make PCRE_ANCHORED public and accept as a compile option.
+
+5. Add an options word to pcre_exec() and accept PCRE_ANCHORED and
+PCRE_CASELESS at run time. Add escapes \A and \I to pcretest to cause it to
+pass them.
+
+6. Give an error if bad option bits passed at compile or run time.
+
+7. Add PCRE_MULTILINE at compile and exec time, and (?m) as well. Add \M to
+pcretest to cause it to pass that flag.
+
+8. Add pcre_info(), to get the number of identifying subpatterns, the stored
+options, and the first character, if set.
+
+9. Recognize C+ or C{n,m} where n >= 1 as providing a fixed starting character.
+
+
+Version 0.91 10-Sep-97
+----------------------
+
+1. PCRE was failing to diagnose unlimited repeats of subpatterns that could
+match the empty string as in /(a*)*/. It was looping and ultimately crashing.
+
+2. PCRE was looping on encountering an indefinitely repeated back reference to
+a subpattern that had matched an empty string, e.g. /(a|)\1*/. It now does what
+Perl does - treats the match as successful.
+
+****
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/CleanTxt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,113 @@
+#! /usr/bin/perl -w
+
+# Script to take the output of nroff -man and remove all the backspacing and
+# the page footers and the screen commands etc so that it is more usefully
+# readable online. In fact, in the latest nroff, intermediate footers don't
+# seem to be generated any more.
+
+$blankcount = 0;
+$lastwascut = 0;
+$firstheader = 1;
+
+# Input on STDIN; output to STDOUT.
+
+while (<STDIN>)
+  {
+  s/\x1b\[\d+m//g;   # Remove screen controls "ESC [ number m"
+  s/.\x8//g;         # Remove "char, backspace"
+
+  # Handle header lines. Retain only the first one we encounter, but remove
+  # the blank line that follows. Any others (e.g. at end of document) and the
+  # following blank line are dropped.
+
+  if (/^PCRE(\w*)\(([13])\)\s+PCRE\1\(\2\)$/)
+    {
+    if ($firstheader)
+      {
+      $firstheader = 0;
+      print;
+      $lastprinted = $_;
+      $lastwascut = 0;
+      }
+    $_=<STDIN>;       # Remove a blank that follows
+    next;
+    }
+
+  # Count runs of empty lines
+
+  if (/^\s*$/)
+    {
+    $blankcount++;
+    $lastwascut = 0;
+    next;
+    }
+
+  # If a chunk of lines has been cut out (page footer) and the next line
+  # has a different indentation, put back one blank line.
+
+  if ($lastwascut && $blankcount < 1 && defined($lastprinted))
+    {
+    ($a) = $lastprinted =~ /^(\s*)/;
+    ($b) = $_ =~ /^(\s*)/;
+    $blankcount++ if ($a ne $b);
+    }
+
+  # We get here only when we have a non-blank line in hand. If it was preceded
+  # by 3 or more blank lines, read the next 3 lines and see if they are blank.
+  # If so, remove all 7 lines, and remember that we have just done a cut.
+
+  if ($blankcount >= 3)
+    {
+    for ($i = 0; $i < 3; $i++)
+      {
+      $next[$i] = <STDIN>;
+      $next[$i] = "" if !defined $next[$i];
+      $next[$i] =~ s/\x1b\[\d+m//g;   # Remove screen controls "ESC [ number m"
+      $next[$i] =~ s/.\x8//g;         # Remove "char, backspace"
+      }
+
+    # Cut out chunks of the form <3 blanks><non-blank><3 blanks>
+
+    if ($next[0] =~ /^\s*$/ &&
+        $next[1] =~ /^\s*$/ &&
+        $next[2] =~ /^\s*$/)
+      {
+      $blankcount -= 3;
+      $lastwascut = 1;
+      }
+
+    # Otherwise output the saved blanks, the current, and the next three
+    # lines. Remember the last printed line.
+
+    else
+      {
+      for ($i = 0; $i < $blankcount; $i++) { print "\n"; }
+      print;
+      for ($i = 0; $i < 3; $i++)
+        {
+        $next[$i] =~ s/.\x8//g;
+        print $next[$i];
+        $lastprinted = $_;
+        }
+      $lastwascut = 0;
+      $blankcount = 0;
+      }
+    }
+
+  # This non-blank line is not preceded by 3 or more blank lines. Output
+  # any blanks there are, and the line. Remember it. Force two blank lines
+  # before headings.
+
+  else
+    {
+    $blankcount = 2 if /^\S/ && !/^Last updated/ && !/^Copyright/ &&
+      defined($lastprinted);
+    for ($i = 0; $i < $blankcount; $i++) { print "\n"; }
+    print;
+    $lastprinted = $_;
+    $lastwascut = 0;
+    $blankcount = 0;
+    }
+  }
+
+# End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/Detrail	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+# This is a script for removing trailing whitespace from lines in files that
+# are listed on the command line.
+
+# This subroutine does the work for one file.
+
+sub detrail {
+my($file) = $_[0];
+my($changed) = 0;
+open(IN, "$file") || die "Can't open $file for input";
+@lines = <IN>;
+close(IN);
+foreach (@lines)
+  {
+  if (/\s+\n$/)
+    {
+    s/\s+\n$/\n/;
+    $changed = 1;
+    }
+  }
+if ($changed)
+  {
+  open(OUT, ">$file") || die "Can't open $file for output";
+  print OUT @lines;
+  close(OUT);
+  }
+}
+
+# This is the main program
+
+$, = "";   # Output field separator
+for ($i = 0; $i < @ARGV; $i++) { &detrail($ARGV[$i]); }
+
+# End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/HACKING	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,418 @@
+Technical Notes about PCRE
+--------------------------
+
+These are very rough technical notes that record potentially useful information 
+about PCRE internals.
+
+Historical note 1
+-----------------
+
+Many years ago I implemented some regular expression functions to an algorithm
+suggested by Martin Richards. These were not Unix-like in form, and were quite
+restricted in what they could do by comparison with Perl. The interesting part
+about the algorithm was that the amount of space required to hold the compiled
+form of an expression was known in advance. The code to apply an expression did
+not operate by backtracking, as the original Henry Spencer code and current
+Perl code does, but instead checked all possibilities simultaneously by keeping
+a list of current states and checking all of them as it advanced through the
+subject string. In the terminology of Jeffrey Friedl's book, it was a "DFA
+algorithm", though it was not a traditional Finite State Machine (FSM). When
+the pattern was all used up, all remaining states were possible matches, and
+the one matching the longest subset of the subject string was chosen. This did
+not necessarily maximize the individual wild portions of the pattern, as is
+expected in Unix and Perl-style regular expressions.
+
+Historical note 2
+-----------------
+
+By contrast, the code originally written by Henry Spencer (which was
+subsequently heavily modified for Perl) compiles the expression twice: once in
+a dummy mode in order to find out how much store will be needed, and then for
+real. (The Perl version probably doesn't do this any more; I'm talking about
+the original library.) The execution function operates by backtracking and
+maximizing (or, optionally, minimizing in Perl) the amount of the subject that
+matches individual wild portions of the pattern. This is an "NFA algorithm" in
+Friedl's terminology.
+
+OK, here's the real stuff
+-------------------------
+
+For the set of functions that form the "basic" PCRE library (which are
+unrelated to those mentioned above), I tried at first to invent an algorithm
+that used an amount of store bounded by a multiple of the number of characters
+in the pattern, to save on compiling time. However, because of the greater
+complexity in Perl regular expressions, I couldn't do this. In any case, a
+first pass through the pattern is helpful for other reasons. 
+
+Computing the memory requirement: how it was
+--------------------------------------------
+
+Up to and including release 6.7, PCRE worked by running a very degenerate first
+pass to calculate a maximum store size, and then a second pass to do the real
+compile - which might use a bit less than the predicted amount of memory. The
+idea was that this would turn out faster than the Henry Spencer code because
+the first pass is degenerate and the second pass can just store stuff straight
+into the vector, which it knows is big enough.
+
+Computing the memory requirement: how it is
+-------------------------------------------
+
+By the time I was working on a potential 6.8 release, the degenerate first pass
+had become very complicated and hard to maintain. Indeed one of the early
+things I did for 6.8 was to fix Yet Another Bug in the memory computation. Then
+I had a flash of inspiration as to how I could run the real compile function in
+a "fake" mode that enables it to compute how much memory it would need, while
+actually only ever using a few hundred bytes of working memory, and without too
+many tests of the mode that might slow it down. So I re-factored the compiling
+functions to work this way. This got rid of about 600 lines of source. It
+should make future maintenance and development easier. As this was such a major 
+change, I never released 6.8, instead upping the number to 7.0 (other quite 
+major changes are also present in the 7.0 release).
+
+A side effect of this work is that the previous limit of 200 on the nesting
+depth of parentheses was removed. However, there is a downside: pcre_compile()
+runs more slowly than before (30% or more, depending on the pattern) because it
+is doing a full analysis of the pattern. My hope is that this is not a big
+issue.
+
+Traditional matching function
+-----------------------------
+
+The "traditional", and original, matching function is called pcre_exec(), and 
+it implements an NFA algorithm, similar to the original Henry Spencer algorithm 
+and the way that Perl works. Not surprising, since it is intended to be as 
+compatible with Perl as possible. This is the function most users of PCRE will 
+use most of the time.
+
+Supplementary matching function
+-------------------------------
+
+From PCRE 6.0, there is also a supplementary matching function called 
+pcre_dfa_exec(). This implements a DFA matching algorithm that searches 
+simultaneously for all possible matches that start at one point in the subject 
+string. (Going back to my roots: see Historical Note 1 above.) This function 
+intreprets the same compiled pattern data as pcre_exec(); however, not all the 
+facilities are available, and those that are do not always work in quite the 
+same way. See the user documentation for details.
+
+The algorithm that is used for pcre_dfa_exec() is not a traditional FSM, 
+because it may have a number of states active at one time. More work would be 
+needed at compile time to produce a traditional FSM where only one state is 
+ever active at once. I believe some other regex matchers work this way.
+
+
+Format of compiled patterns
+---------------------------
+
+The compiled form of a pattern is a vector of bytes, containing items of
+variable length. The first byte in an item is an opcode, and the length of the
+item is either implicit in the opcode or contained in the data bytes that
+follow it. 
+
+In many cases below LINK_SIZE data values are specified for offsets within the 
+compiled pattern. The default value for LINK_SIZE is 2, but PCRE can be
+compiled to use 3-byte or 4-byte values for these offsets (impairing the
+performance). This is necessary only when patterns whose compiled length is
+greater than 64K are going to be processed. In this description, we assume the
+"normal" compilation options. Data values that are counts (e.g. for
+quantifiers) are always just two bytes long.
+
+A list of the opcodes follows:
+
+Opcodes with no following data
+------------------------------
+
+These items are all just one byte long
+
+  OP_END                 end of pattern
+  OP_ANY                 match any one character other than newline
+  OP_ALLANY              match any one character, including newline
+  OP_ANYBYTE             match any single byte, even in UTF-8 mode
+  OP_SOD                 match start of data: \A
+  OP_SOM,                start of match (subject + offset): \G
+  OP_SET_SOM,            set start of match (\K) 
+  OP_CIRC                ^ (start of data, or after \n in multiline)
+  OP_NOT_WORD_BOUNDARY   \W
+  OP_WORD_BOUNDARY       \w
+  OP_NOT_DIGIT           \D
+  OP_DIGIT               \d
+  OP_NOT_HSPACE          \H
+  OP_HSPACE              \h  
+  OP_NOT_WHITESPACE      \S
+  OP_WHITESPACE          \s
+  OP_NOT_VSPACE          \V
+  OP_VSPACE              \v  
+  OP_NOT_WORDCHAR        \W
+  OP_WORDCHAR            \w
+  OP_EODN                match end of data or \n at end: \Z
+  OP_EOD                 match end of data: \z
+  OP_DOLL                $ (end of data, or before \n in multiline)
+  OP_EXTUNI              match an extended Unicode character 
+  OP_ANYNL               match any Unicode newline sequence 
+  
+  OP_ACCEPT              )
+  OP_COMMIT              ) 
+  OP_FAIL                ) These are Perl 5.10's "backtracking     
+  OP_PRUNE               ) control verbs".                         
+  OP_SKIP                )
+  OP_THEN                )
+  
+
+Repeating single characters
+---------------------------
+
+The common repeats (*, +, ?) when applied to a single character use the
+following opcodes:
+
+  OP_STAR
+  OP_MINSTAR
+  OP_POSSTAR 
+  OP_PLUS
+  OP_MINPLUS
+  OP_POSPLUS 
+  OP_QUERY
+  OP_MINQUERY
+  OP_POSQUERY 
+
+In ASCII mode, these are two-byte items; in UTF-8 mode, the length is variable.
+Those with "MIN" in their name are the minimizing versions. Those with "POS" in 
+their names are possessive versions. Each is followed by the character that is
+to be repeated. Other repeats make use of
+
+  OP_UPTO
+  OP_MINUPTO
+  OP_POSUPTO 
+  OP_EXACT
+
+which are followed by a two-byte count (most significant first) and the
+repeated character. OP_UPTO matches from 0 to the given number. A repeat with a
+non-zero minimum and a fixed maximum is coded as an OP_EXACT followed by an
+OP_UPTO (or OP_MINUPTO or OPT_POSUPTO).
+
+
+Repeating character types
+-------------------------
+
+Repeats of things like \d are done exactly as for single characters, except
+that instead of a character, the opcode for the type is stored in the data
+byte. The opcodes are:
+
+  OP_TYPESTAR
+  OP_TYPEMINSTAR
+  OP_TYPEPOSSTAR 
+  OP_TYPEPLUS
+  OP_TYPEMINPLUS
+  OP_TYPEPOSPLUS 
+  OP_TYPEQUERY
+  OP_TYPEMINQUERY
+  OP_TYPEPOSQUERY 
+  OP_TYPEUPTO
+  OP_TYPEMINUPTO
+  OP_TYPEPOSUPTO 
+  OP_TYPEEXACT
+
+
+Match by Unicode property
+-------------------------
+
+OP_PROP and OP_NOTPROP are used for positive and negative matches of a 
+character by testing its Unicode property (the \p and \P escape sequences).
+Each is followed by two bytes that encode the desired property as a type and a 
+value.
+
+Repeats of these items use the OP_TYPESTAR etc. set of opcodes, followed by 
+three bytes: OP_PROP or OP_NOTPROP and then the desired property type and 
+value.
+
+
+Matching literal characters
+---------------------------
+
+The OP_CHAR opcode is followed by a single character that is to be matched 
+casefully. For caseless matching, OP_CHARNC is used. In UTF-8 mode, the 
+character may be more than one byte long. (Earlier versions of PCRE used 
+multi-character strings, but this was changed to allow some new features to be 
+added.)
+
+
+Character classes
+-----------------
+
+If there is only one character, OP_CHAR or OP_CHARNC is used for a positive
+class, and OP_NOT for a negative one (that is, for something like [^a]).
+However, in UTF-8 mode, the use of OP_NOT applies only to characters with
+values < 128, because OP_NOT is confined to single bytes.
+
+Another set of repeating opcodes (OP_NOTSTAR etc.) are used for a repeated,
+negated, single-character class. The normal ones (OP_STAR etc.) are used for a
+repeated positive single-character class.
+
+When there's more than one character in a class and all the characters are less
+than 256, OP_CLASS is used for a positive class, and OP_NCLASS for a negative
+one. In either case, the opcode is followed by a 32-byte bit map containing a 1
+bit for every character that is acceptable. The bits are counted from the least
+significant end of each byte.
+
+The reason for having both OP_CLASS and OP_NCLASS is so that, in UTF-8 mode,
+subject characters with values greater than 256 can be handled correctly. For
+OP_CLASS they don't match, whereas for OP_NCLASS they do.
+
+For classes containing characters with values > 255, OP_XCLASS is used. It
+optionally uses a bit map (if any characters lie within it), followed by a list
+of pairs and single characters. There is a flag character than indicates
+whether it's a positive or a negative class.
+
+
+Back references
+---------------
+
+OP_REF is followed by two bytes containing the reference number.
+
+
+Repeating character classes and back references
+-----------------------------------------------
+
+Single-character classes are handled specially (see above). This section
+applies to OP_CLASS and OP_REF. In both cases, the repeat information follows
+the base item. The matching code looks at the following opcode to see if it is
+one of
+
+  OP_CRSTAR
+  OP_CRMINSTAR
+  OP_CRPLUS
+  OP_CRMINPLUS
+  OP_CRQUERY
+  OP_CRMINQUERY
+  OP_CRRANGE
+  OP_CRMINRANGE
+
+All but the last two are just single-byte items. The others are followed by
+four bytes of data, comprising the minimum and maximum repeat counts. There are 
+no special possessive opcodes for these repeats; a possessive repeat is 
+compiled into an atomic group.
+
+
+Brackets and alternation
+------------------------
+
+A pair of non-capturing (round) brackets is wrapped round each expression at
+compile time, so alternation always happens in the context of brackets.
+
+[Note for North Americans: "bracket" to some English speakers, including
+myself, can be round, square, curly, or pointy. Hence this usage.]
+
+Non-capturing brackets use the opcode OP_BRA. Originally PCRE was limited to 99
+capturing brackets and it used a different opcode for each one. From release
+3.5, the limit was removed by putting the bracket number into the data for
+higher-numbered brackets. From release 7.0 all capturing brackets are handled
+this way, using the single opcode OP_CBRA.
+
+A bracket opcode is followed by LINK_SIZE bytes which give the offset to the
+next alternative OP_ALT or, if there aren't any branches, to the matching
+OP_KET opcode. Each OP_ALT is followed by LINK_SIZE bytes giving the offset to
+the next one, or to the OP_KET opcode. For capturing brackets, the bracket 
+number immediately follows the offset, always as a 2-byte item.
+
+OP_KET is used for subpatterns that do not repeat indefinitely, while
+OP_KETRMIN and OP_KETRMAX are used for indefinite repetitions, minimally or
+maximally respectively. All three are followed by LINK_SIZE bytes giving (as a
+positive number) the offset back to the matching bracket opcode.
+
+If a subpattern is quantified such that it is permitted to match zero times, it
+is preceded by one of OP_BRAZERO, OP_BRAMINZERO, or OP_SKIPZERO. These are
+single-byte opcodes that tell the matcher that skipping the following
+subpattern entirely is a valid branch. In the case of the first two, not 
+skipping the pattern is also valid (greedy and non-greedy). The third is used 
+when a pattern has the quantifier {0,0}. It cannot be entirely discarded, 
+because it may be called as a subroutine from elsewhere in the regex.
+
+A subpattern with an indefinite maximum repetition is replicated in the
+compiled data its minimum number of times (or once with OP_BRAZERO if the
+minimum is zero), with the final copy terminating with OP_KETRMIN or OP_KETRMAX
+as appropriate.
+
+A subpattern with a bounded maximum repetition is replicated in a nested
+fashion up to the maximum number of times, with OP_BRAZERO or OP_BRAMINZERO
+before each replication after the minimum, so that, for example, (abc){2,5} is
+compiled as (abc)(abc)((abc)((abc)(abc)?)?)?, except that each bracketed group 
+has the same number.
+
+When a repeated subpattern has an unbounded upper limit, it is checked to see 
+whether it could match an empty string. If this is the case, the opcode in the 
+final replication is changed to OP_SBRA or OP_SCBRA. This tells the matcher
+that it needs to check for matching an empty string when it hits OP_KETRMIN or
+OP_KETRMAX, and if so, to break the loop.
+
+
+Assertions
+----------
+
+Forward assertions are just like other subpatterns, but starting with one of
+the opcodes OP_ASSERT or OP_ASSERT_NOT. Backward assertions use the opcodes
+OP_ASSERTBACK and OP_ASSERTBACK_NOT, and the first opcode inside the assertion
+is OP_REVERSE, followed by a two byte count of the number of characters to move
+back the pointer in the subject string. When operating in UTF-8 mode, the count
+is a character count rather than a byte count. A separate count is present in
+each alternative of a lookbehind assertion, allowing them to have different
+fixed lengths.
+
+
+Once-only (atomic) subpatterns
+------------------------------
+
+These are also just like other subpatterns, but they start with the opcode
+OP_ONCE. The check for matching an empty string in an unbounded repeat is 
+handled entirely at runtime, so there is just this one opcode.
+
+
+Conditional subpatterns
+-----------------------
+
+These are like other subpatterns, but they start with the opcode OP_COND, or
+OP_SCOND for one that might match an empty string in an unbounded repeat. If
+the condition is a back reference, this is stored at the start of the
+subpattern using the opcode OP_CREF followed by two bytes containing the
+reference number. If the condition is "in recursion" (coded as "(?(R)"), or "in
+recursion of group x" (coded as "(?(Rx)"), the group number is stored at the
+start of the subpattern using the opcode OP_RREF, and a value of zero for "the
+whole pattern". For a DEFINE condition, just the single byte OP_DEF is used (it
+has no associated data). Otherwise, a conditional subpattern always starts with
+one of the assertions.
+
+
+Recursion
+---------
+
+Recursion either matches the current regex, or some subexpression. The opcode
+OP_RECURSE is followed by an value which is the offset to the starting bracket
+from the start of the whole pattern. From release 6.5, OP_RECURSE is 
+automatically wrapped inside OP_ONCE brackets (because otherwise some patterns 
+broke it). OP_RECURSE is also used for "subroutine" calls, even though they 
+are not strictly a recursion.
+
+
+Callout
+-------
+
+OP_CALLOUT is followed by one byte of data that holds a callout number in the
+range 0 to 254 for manual callouts, or 255 for an automatic callout. In both 
+cases there follows a two-byte value giving the offset in the pattern to the
+start of the following item, and another two-byte item giving the length of the
+next item.
+
+
+Changing options
+----------------
+
+If any of the /i, /m, or /s options are changed within a pattern, an OP_OPT
+opcode is compiled, followed by one byte containing the new settings of these
+flags. If there are several alternatives, there is an occurrence of OP_OPT at
+the start of all those following the first options change, to set appropriate
+options for the start of the alternative. Immediately after the end of the
+group there is another such item to reset the flags to their previous values. A
+change of flag right at the very start of the pattern can be handled entirely
+at compile time, and so does not cause anything to be put into the compiled
+data.
+
+Philip Hazel
+April 2008
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/INSTALL	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,237 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/LICENCE	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,68 @@
+PCRE LICENCE
+------------
+
+PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+Release 7 of PCRE is distributed under the terms of the "BSD" licence, as
+specified below. The documentation for PCRE, supplied in the "doc"
+directory, is distributed under the same terms as the software itself.
+
+The basic library functions are written in C and are freestanding. Also
+included in the distribution is a set of C++ wrapper functions.
+
+
+THE BASIC LIBRARY FUNCTIONS
+---------------------------
+
+Written by:       Philip Hazel
+Email local part: ph10
+Email domain:     cam.ac.uk
+
+University of Cambridge Computing Service,
+Cambridge, England.
+
+Copyright (c) 1997-2008 University of Cambridge
+All rights reserved.
+
+
+THE C++ WRAPPER FUNCTIONS
+-------------------------
+
+Contributed by:   Google Inc.
+
+Copyright (c) 2007-2008, Google Inc.
+All rights reserved.
+
+
+THE "BSD" LICENCE
+-----------------
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge nor the name of Google
+      Inc. nor the names of their contributors may be used to endorse or
+      promote products derived from this software without specific prior
+      written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/Makefile.am	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,390 @@
+## Process this file with automake to produce Makefile.in.
+
+dist_doc_DATA = \
+  doc/pcre.txt \
+  doc/pcre-config.txt \
+  doc/pcregrep.txt \
+  doc/pcretest.txt \
+  AUTHORS \
+  COPYING \
+  ChangeLog \
+  LICENCE \
+  NEWS \
+  README
+
+dist_html_DATA = \
+  doc/html/index.html \
+  doc/html/pcre.html \
+  doc/html/pcre-config.html \
+  doc/html/pcre_compile.html \
+  doc/html/pcre_compile2.html \
+  doc/html/pcre_config.html \
+  doc/html/pcre_copy_named_substring.html \
+  doc/html/pcre_copy_substring.html \
+  doc/html/pcre_dfa_exec.html \
+  doc/html/pcre_exec.html \
+  doc/html/pcre_free_substring.html \
+  doc/html/pcre_free_substring_list.html \
+  doc/html/pcre_fullinfo.html \
+  doc/html/pcre_get_named_substring.html \
+  doc/html/pcre_get_stringnumber.html \
+  doc/html/pcre_get_stringtable_entries.html \
+  doc/html/pcre_get_substring.html \
+  doc/html/pcre_get_substring_list.html \
+  doc/html/pcre_info.html \
+  doc/html/pcre_maketables.html \
+  doc/html/pcre_refcount.html \
+  doc/html/pcre_study.html \
+  doc/html/pcre_version.html \
+  doc/html/pcreapi.html \
+  doc/html/pcrebuild.html \
+  doc/html/pcrecallout.html \
+  doc/html/pcrecompat.html \
+  doc/html/pcregrep.html \
+  doc/html/pcrematching.html \
+  doc/html/pcrepartial.html \
+  doc/html/pcrepattern.html \
+  doc/html/pcreperform.html \
+  doc/html/pcreposix.html \
+  doc/html/pcreprecompile.html \
+  doc/html/pcresample.html \
+  doc/html/pcrestack.html \
+  doc/html/pcresyntax.html \
+  doc/html/pcretest.html
+
+pcrecpp_html = doc/html/pcrecpp.html
+dist_noinst_DATA = $(pcrecpp_html)
+
+if WITH_PCRE_CPP
+html_DATA = $(pcrecpp_html)
+endif
+
+# The Libtool libraries to install.  We'll add to this later.
+lib_LTLIBRARIES =
+
+# Unit tests you want to run when people type 'make check'.
+# TESTS is for binary unit tests, check_SCRIPTS for script-based tests
+TESTS =
+check_SCRIPTS =
+dist_noinst_SCRIPTS =
+
+# Some of the binaries we make are to be installed, and others are
+# (non-user-visible) helper programs needed to build libpcre.
+bin_PROGRAMS =
+noinst_PROGRAMS =
+
+# Additional files to delete on 'make clean' and 'make maintainer-clean'.
+CLEANFILES =
+MAINTAINERCLEANFILES =
+
+# Additional files to bundle with the distribution, over and above what
+# the Autotools include by default.
+EXTRA_DIST =
+
+# These files contain maintenance information
+EXTRA_DIST += \
+  doc/perltest.txt \
+  NON-UNIX-USE \
+  HACKING
+
+# These files are used in the preparation of a release
+EXTRA_DIST += \
+  PrepareRelease \
+  CleanTxt \
+  Detrail \
+  132html \
+  doc/index.html.src
+
+# These files are to do with building for Virtual Pascal
+EXTRA_DIST += \
+  makevp.bat \
+  makevp_c.txt \
+  makevp_l.txt \
+  pcregexp.pas
+
+# These files are usable versions of pcre.h and config.h that are distributed
+# for the benefit of people who are building PCRE manually, without the
+# Autotools support.
+EXTRA_DIST += \
+  pcre.h.generic \
+  config.h.generic
+
+pcre.h.generic: configure.ac
+	rm -f $@
+	cp -p pcre.h $@
+
+MAINTAINERCLEANFILES += pcre.h.generic
+
+# These are the header files we'll install. We do not distribute pcre.h because
+# it is generated from pcre.h.in.
+nodist_include_HEADERS = \
+  pcre.h
+include_HEADERS = \
+  pcreposix.h
+
+# These additional headers will be be installed if C++ support is enabled. We
+# do not distribute pcrecpparg.h or pcre_stringpiece.h, as these are generated
+# from corresponding .h.in files (which we do distribute).
+if WITH_PCRE_CPP
+nodist_include_HEADERS += \
+  pcrecpparg.h \
+  pcre_stringpiece.h
+include_HEADERS += \
+  pcrecpp.h \
+  pcre_scanner.h
+endif # WITH_PCRE_CPP
+
+bin_SCRIPTS = pcre-config
+
+## ---------------------------------------------------------------
+## The dftables program is used to rebuild character tables before compiling
+## PCRE, if --enable-rebuild-chartables is specified. It is not a user-visible
+## program. The default (when --enable-rebuild-chartables is not specified) is
+## to copy a distributed set of tables that are defined for ASCII code. In this
+## case, dftables is not needed.
+
+if WITH_REBUILD_CHARTABLES
+
+noinst_PROGRAMS += dftables
+dftables_SOURCES = dftables.c
+
+pcre_chartables.c: dftables$(EXEEXT)
+	./dftables$(EXEEXT) $@
+else
+
+pcre_chartables.c: $(srcdir)/pcre_chartables.c.dist
+	rm -f $@
+	$(LN_S) $(srcdir)/pcre_chartables.c.dist $@
+
+endif # WITH_REBUILD_CHARTABLES
+
+
+## The main pcre library
+lib_LTLIBRARIES += libpcre.la
+libpcre_la_SOURCES = \
+  pcre_compile.c \
+  pcre_config.c \
+  pcre_dfa_exec.c \
+  pcre_exec.c \
+  pcre_fullinfo.c \
+  pcre_get.c \
+  pcre_globals.c \
+  pcre_info.c \
+  pcre_internal.h \
+  pcre_maketables.c \
+  pcre_newline.c \
+  pcre_ord2utf8.c \
+  pcre_refcount.c \
+  pcre_study.c \
+  pcre_tables.c \
+  pcre_try_flipped.c \
+  pcre_ucd.c \
+  pcre_valid_utf8.c \
+  pcre_version.c \
+  pcre_xclass.c \
+  ucp.h
+
+## This file is generated as part of the building process, so don't distribute.
+nodist_libpcre_la_SOURCES = \
+  pcre_chartables.c
+
+# The pcre_printint.src file is #included by some source files, so it must be
+# distributed. The pcre_chartables.c.dist file is the default version of
+# pcre_chartables.c, used unless --enable-rebuild-chartables is specified.
+EXTRA_DIST += pcre_printint.src pcre_chartables.c.dist
+
+libpcre_la_LDFLAGS = $(EXTRA_LIBPCRE_LDFLAGS)
+
+CLEANFILES += pcre_chartables.c
+
+## A version of the main pcre library that has a posix re API.
+lib_LTLIBRARIES += libpcreposix.la
+libpcreposix_la_SOURCES = \
+  pcreposix.c
+libpcreposix_la_LDFLAGS = $(EXTRA_LIBPCREPOSIX_LDFLAGS)
+libpcreposix_la_LIBADD = libpcre.la
+
+## There's a C++ library as well.
+if WITH_PCRE_CPP
+
+lib_LTLIBRARIES += libpcrecpp.la
+libpcrecpp_la_SOURCES = \
+  pcrecpp_internal.h \
+  pcrecpp.cc \
+  pcre_scanner.cc \
+  pcre_stringpiece.cc
+libpcrecpp_la_LDFLAGS = $(EXTRA_LIBPCRECPP_LDFLAGS)
+libpcrecpp_la_LIBADD = libpcre.la
+
+TESTS += pcrecpp_unittest
+noinst_PROGRAMS += pcrecpp_unittest
+pcrecpp_unittest_SOURCES = pcrecpp_unittest.cc
+pcrecpp_unittest_LDADD = libpcrecpp.la
+
+TESTS += pcre_scanner_unittest
+noinst_PROGRAMS += pcre_scanner_unittest
+pcre_scanner_unittest_SOURCES = pcre_scanner_unittest.cc
+pcre_scanner_unittest_LDADD = libpcrecpp.la
+
+TESTS += pcre_stringpiece_unittest
+noinst_PROGRAMS += pcre_stringpiece_unittest
+pcre_stringpiece_unittest_SOURCES = pcre_stringpiece_unittest.cc
+pcre_stringpiece_unittest_LDADD = libpcrecpp.la
+
+endif # WITH_PCRE_CPP
+
+## The main unit tests
+
+# Each unit test is a binary plus a script that runs that binary in various
+# ways. We install these test binaries in case folks find it helpful.
+
+TESTS += RunTest
+dist_noinst_SCRIPTS += RunTest
+EXTRA_DIST += RunTest.bat
+bin_PROGRAMS += pcretest
+pcretest_SOURCES = pcretest.c
+pcretest_LDADD = libpcreposix.la
+
+TESTS += RunGrepTest
+dist_noinst_SCRIPTS += RunGrepTest
+bin_PROGRAMS += pcregrep
+pcregrep_SOURCES = pcregrep.c
+pcregrep_LDADD = libpcreposix.la
+
+EXTRA_DIST += \
+  testdata/grepinput \
+  testdata/grepinput8 \
+  testdata/grepinputv \
+  testdata/grepinputx \
+  testdata/greplist \
+  testdata/grepoutput \
+  testdata/grepoutput8 \
+  testdata/grepoutputN \
+  testdata/testinput1 \
+  testdata/testinput2 \
+  testdata/testinput3 \
+  testdata/testinput4 \
+  testdata/testinput5 \
+  testdata/testinput6 \
+  testdata/testinput7 \
+  testdata/testinput8 \
+  testdata/testinput9 \
+  testdata/testinput10 \
+  testdata/testoutput1 \
+  testdata/testoutput2 \
+  testdata/testoutput3 \
+  testdata/testoutput4 \
+  testdata/testoutput5 \
+  testdata/testoutput6 \
+  testdata/testoutput7 \
+  testdata/testoutput8 \
+  testdata/testoutput9 \
+  testdata/testoutput10 \
+  testdata/wintestinput3 \
+  testdata/wintestoutput3 \
+  perltest.pl
+
+CLEANFILES += \
+	testsavedregex \
+	teststderr \
+	testtry \
+        testNinput
+
+
+# PCRE demonstration program. No longer built automatcally. The point is that
+# the users should build it themselves. So just distribute the source.
+# noinst_PROGRAMS += pcredemo
+# pcredemo_SOURCES = pcredemo.c
+# pcredemo_LDADD = libpcre.la
+
+EXTRA_DIST += pcredemo.c
+
+
+## Utility rules, documentation, etc.
+
+# A compatibility line, the old build system worked with 'make test'
+test: check ;
+
+
+# A PCRE user submitted the following addition, saying that it "will allow
+# anyone using the 'mingw32' compiler to simply type 'make pcre.dll' and get a
+# nice DLL for Windows use". (It is used by the pcre.dll target.)
+DLL_OBJS= pcre_compile.o pcre_config.o \
+	pcre_dfa_exec.o pcre_exec.o pcre_fullinfo.o pcre_get.o \
+	pcre_globals.o pcre_info.o pcre_maketables.o \
+	pcre_newline.o pcre_ord2utf8.o pcre_refcount.o \
+	pcre_study.o pcre_tables.o pcre_try_flipped.o \
+	pcre_ucd.o pcre_valid_utf8.o pcre_version.o \
+	pcre_chartables.o \
+	pcre_xclass.o
+
+# A PCRE user submitted the following addition, saying that it "will allow
+# anyone using the 'mingw32' compiler to simply type 'make pcre.dll' and get a
+# nice DLL for Windows use".
+pcre.dll: $(DLL_OBJS)
+	$(CC) -shared -o pcre.dll -Wl,"--strip-all" -Wl,"--export-all-symbols" $(DLL_OBJS)
+
+
+# We have .pc files for pkg-config users.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libpcre.pc
+if WITH_PCRE_CPP
+pkgconfig_DATA += libpcrecpp.pc
+endif
+
+dist_man_MANS = \
+  doc/pcre.3 \
+  doc/pcre-config.1 \
+  doc/pcre_compile.3 \
+  doc/pcre_compile2.3 \
+  doc/pcre_config.3 \
+  doc/pcre_copy_named_substring.3 \
+  doc/pcre_copy_substring.3 \
+  doc/pcre_dfa_exec.3 \
+  doc/pcre_exec.3 \
+  doc/pcre_free_substring.3 \
+  doc/pcre_free_substring_list.3 \
+  doc/pcre_fullinfo.3 \
+  doc/pcre_get_named_substring.3 \
+  doc/pcre_get_stringnumber.3 \
+  doc/pcre_get_stringtable_entries.3 \
+  doc/pcre_get_substring.3 \
+  doc/pcre_get_substring_list.3 \
+  doc/pcre_info.3 \
+  doc/pcre_maketables.3 \
+  doc/pcre_refcount.3 \
+  doc/pcre_study.3 \
+  doc/pcre_version.3 \
+  doc/pcreapi.3 \
+  doc/pcrebuild.3 \
+  doc/pcrecallout.3 \
+  doc/pcrecompat.3 \
+  doc/pcregrep.1 \
+  doc/pcrematching.3 \
+  doc/pcrepartial.3 \
+  doc/pcrepattern.3 \
+  doc/pcreperform.3 \
+  doc/pcreposix.3 \
+  doc/pcreprecompile.3 \
+  doc/pcresample.3 \
+  doc/pcrestack.3 \
+  doc/pcresyntax.3 \
+  doc/pcretest.1
+
+pcrecpp_man = doc/pcrecpp.3
+EXTRA_DIST += $(pcrecpp_man)
+
+if WITH_PCRE_CPP
+man_MANS = $(pcrecpp_man)
+endif
+
+## CMake support
+
+EXTRA_DIST += \
+  cmake/COPYING-CMAKE-SCRIPTS \
+  cmake/FindPackageHandleStandardArgs.cmake \
+  cmake/FindReadline.cmake \
+  CMakeLists.txt \
+  config-cmake.h.in
+
+## end Makefile.am
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/Makefile.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1433 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  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.
+
+@SET_MAKE@
+
+
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+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 = :
+build_triplet = @build@
+host_triplet = @host@
+TESTS = $(am__EXEEXT_2) RunTest RunGrepTest
+bin_PROGRAMS = pcretest$(EXEEXT) pcregrep$(EXEEXT)
+noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
+
+# These additional headers will be be installed if C++ support is enabled. We
+# do not distribute pcrecpparg.h or pcre_stringpiece.h, as these are generated
+# from corresponding .h.in files (which we do distribute).
+@WITH_PCRE_CPP_TRUE@am__append_1 = \
+@WITH_PCRE_CPP_TRUE@  pcrecpparg.h \
+@WITH_PCRE_CPP_TRUE@  pcre_stringpiece.h
+
+@WITH_PCRE_CPP_TRUE@am__append_2 = \
+@WITH_PCRE_CPP_TRUE@  pcrecpp.h \
+@WITH_PCRE_CPP_TRUE@  pcre_scanner.h
+
+@WITH_REBUILD_CHARTABLES_TRUE@am__append_3 = dftables
+@WITH_PCRE_CPP_TRUE@am__append_4 = libpcrecpp.la
+@WITH_PCRE_CPP_TRUE@am__append_5 = pcrecpp_unittest \
+@WITH_PCRE_CPP_TRUE@	pcre_scanner_unittest \
+@WITH_PCRE_CPP_TRUE@	pcre_stringpiece_unittest
+@WITH_PCRE_CPP_TRUE@am__append_6 = pcrecpp_unittest \
+@WITH_PCRE_CPP_TRUE@	pcre_scanner_unittest \
+@WITH_PCRE_CPP_TRUE@	pcre_stringpiece_unittest
+@WITH_PCRE_CPP_TRUE@am__append_7 = libpcrecpp.pc
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(am__include_HEADERS_DIST) \
+	$(dist_doc_DATA) $(dist_html_DATA) $(dist_man_MANS) \
+	$(dist_noinst_DATA) $(dist_noinst_SCRIPTS) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/config.h.in $(srcdir)/libpcre.pc.in \
+	$(srcdir)/libpcrecpp.pc.in $(srcdir)/pcre-config.in \
+	$(srcdir)/pcre.h.in $(srcdir)/pcre_stringpiece.h.in \
+	$(srcdir)/pcrecpparg.h.in $(top_srcdir)/configure AUTHORS \
+	COPYING ChangeLog INSTALL NEWS config.guess config.sub depcomp \
+	install-sh ltmain.sh missing
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES = libpcre.pc libpcrecpp.pc pcre-config pcre.h \
+	pcre_stringpiece.h pcrecpparg.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
+	"$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \
+	"$(DESTDIR)$(man3dir)" "$(DESTDIR)$(docdir)" \
+	"$(DESTDIR)$(htmldir)" "$(DESTDIR)$(htmldir)" \
+	"$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)" \
+	"$(DESTDIR)$(includedir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libpcre_la_LIBADD =
+am_libpcre_la_OBJECTS = pcre_compile.lo pcre_config.lo \
+	pcre_dfa_exec.lo pcre_exec.lo pcre_fullinfo.lo pcre_get.lo \
+	pcre_globals.lo pcre_info.lo pcre_maketables.lo \
+	pcre_newline.lo pcre_ord2utf8.lo pcre_refcount.lo \
+	pcre_study.lo pcre_tables.lo pcre_try_flipped.lo pcre_ucd.lo \
+	pcre_valid_utf8.lo pcre_version.lo pcre_xclass.lo
+nodist_libpcre_la_OBJECTS = pcre_chartables.lo
+libpcre_la_OBJECTS = $(am_libpcre_la_OBJECTS) \
+	$(nodist_libpcre_la_OBJECTS)
+libpcre_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(libpcre_la_LDFLAGS) $(LDFLAGS) -o $@
+@WITH_PCRE_CPP_TRUE@libpcrecpp_la_DEPENDENCIES = libpcre.la
+am__libpcrecpp_la_SOURCES_DIST = pcrecpp_internal.h pcrecpp.cc \
+	pcre_scanner.cc pcre_stringpiece.cc
+@WITH_PCRE_CPP_TRUE@am_libpcrecpp_la_OBJECTS = pcrecpp.lo \
+@WITH_PCRE_CPP_TRUE@	pcre_scanner.lo pcre_stringpiece.lo
+libpcrecpp_la_OBJECTS = $(am_libpcrecpp_la_OBJECTS)
+libpcrecpp_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(libpcrecpp_la_LDFLAGS) $(LDFLAGS) -o $@
+@WITH_PCRE_CPP_TRUE@am_libpcrecpp_la_rpath = -rpath $(libdir)
+libpcreposix_la_DEPENDENCIES = libpcre.la
+am_libpcreposix_la_OBJECTS = pcreposix.lo
+libpcreposix_la_OBJECTS = $(am_libpcreposix_la_OBJECTS)
+libpcreposix_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(libpcreposix_la_LDFLAGS) $(LDFLAGS) -o $@
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+@WITH_REBUILD_CHARTABLES_TRUE@am__EXEEXT_1 = dftables$(EXEEXT)
+@WITH_PCRE_CPP_TRUE@am__EXEEXT_2 = pcrecpp_unittest$(EXEEXT) \
+@WITH_PCRE_CPP_TRUE@	pcre_scanner_unittest$(EXEEXT) \
+@WITH_PCRE_CPP_TRUE@	pcre_stringpiece_unittest$(EXEEXT)
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
+am__dftables_SOURCES_DIST = dftables.c
+@WITH_REBUILD_CHARTABLES_TRUE@am_dftables_OBJECTS =  \
+@WITH_REBUILD_CHARTABLES_TRUE@	dftables.$(OBJEXT)
+dftables_OBJECTS = $(am_dftables_OBJECTS)
+dftables_LDADD = $(LDADD)
+am__pcre_scanner_unittest_SOURCES_DIST = pcre_scanner_unittest.cc
+@WITH_PCRE_CPP_TRUE@am_pcre_scanner_unittest_OBJECTS =  \
+@WITH_PCRE_CPP_TRUE@	pcre_scanner_unittest.$(OBJEXT)
+pcre_scanner_unittest_OBJECTS = $(am_pcre_scanner_unittest_OBJECTS)
+@WITH_PCRE_CPP_TRUE@pcre_scanner_unittest_DEPENDENCIES =  \
+@WITH_PCRE_CPP_TRUE@	libpcrecpp.la
+am__pcre_stringpiece_unittest_SOURCES_DIST =  \
+	pcre_stringpiece_unittest.cc
+@WITH_PCRE_CPP_TRUE@am_pcre_stringpiece_unittest_OBJECTS =  \
+@WITH_PCRE_CPP_TRUE@	pcre_stringpiece_unittest.$(OBJEXT)
+pcre_stringpiece_unittest_OBJECTS =  \
+	$(am_pcre_stringpiece_unittest_OBJECTS)
+@WITH_PCRE_CPP_TRUE@pcre_stringpiece_unittest_DEPENDENCIES =  \
+@WITH_PCRE_CPP_TRUE@	libpcrecpp.la
+am__pcrecpp_unittest_SOURCES_DIST = pcrecpp_unittest.cc
+@WITH_PCRE_CPP_TRUE@am_pcrecpp_unittest_OBJECTS =  \
+@WITH_PCRE_CPP_TRUE@	pcrecpp_unittest.$(OBJEXT)
+pcrecpp_unittest_OBJECTS = $(am_pcrecpp_unittest_OBJECTS)
+@WITH_PCRE_CPP_TRUE@pcrecpp_unittest_DEPENDENCIES = libpcrecpp.la
+am_pcregrep_OBJECTS = pcregrep.$(OBJEXT)
+pcregrep_OBJECTS = $(am_pcregrep_OBJECTS)
+pcregrep_DEPENDENCIES = libpcreposix.la
+am_pcretest_OBJECTS = pcretest.$(OBJEXT)
+pcretest_OBJECTS = $(am_pcretest_OBJECTS)
+pcretest_DEPENDENCIES = libpcreposix.la
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(bin_SCRIPTS) $(dist_noinst_SCRIPTS)
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+SOURCES = $(libpcre_la_SOURCES) $(nodist_libpcre_la_SOURCES) \
+	$(libpcrecpp_la_SOURCES) $(libpcreposix_la_SOURCES) \
+	$(dftables_SOURCES) $(pcre_scanner_unittest_SOURCES) \
+	$(pcre_stringpiece_unittest_SOURCES) \
+	$(pcrecpp_unittest_SOURCES) $(pcregrep_SOURCES) \
+	$(pcretest_SOURCES)
+DIST_SOURCES = $(libpcre_la_SOURCES) $(am__libpcrecpp_la_SOURCES_DIST) \
+	$(libpcreposix_la_SOURCES) $(am__dftables_SOURCES_DIST) \
+	$(am__pcre_scanner_unittest_SOURCES_DIST) \
+	$(am__pcre_stringpiece_unittest_SOURCES_DIST) \
+	$(am__pcrecpp_unittest_SOURCES_DIST) $(pcregrep_SOURCES) \
+	$(pcretest_SOURCES)
+man1dir = $(mandir)/man1
+man3dir = $(mandir)/man3
+NROFF = nroff
+MANS = $(dist_man_MANS) $(man_MANS)
+dist_docDATA_INSTALL = $(INSTALL_DATA)
+dist_htmlDATA_INSTALL = $(INSTALL_DATA)
+htmlDATA_INSTALL = $(INSTALL_DATA)
+pkgconfigDATA_INSTALL = $(INSTALL_DATA)
+DATA = $(dist_doc_DATA) $(dist_html_DATA) $(dist_noinst_DATA) \
+	$(html_DATA) $(pkgconfig_DATA)
+am__include_HEADERS_DIST = pcreposix.h pcrecpp.h pcre_scanner.h
+includeHEADERS_INSTALL = $(INSTALL_HEADER)
+nodist_includeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(include_HEADERS) $(nodist_include_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d $(distdir) \
+    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr $(distdir); }; }
+DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2 $(distdir).zip
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+EXTRA_LIBPCRECPP_LDFLAGS = @EXTRA_LIBPCRECPP_LDFLAGS@
+EXTRA_LIBPCREPOSIX_LDFLAGS = @EXTRA_LIBPCREPOSIX_LDFLAGS@
+EXTRA_LIBPCRE_LDFLAGS = @EXTRA_LIBPCRE_LDFLAGS@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+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@
+MKDIR_P = @MKDIR_P@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+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@
+PCRE_DATE = @PCRE_DATE@
+PCRE_MAJOR = @PCRE_MAJOR@
+PCRE_MINOR = @PCRE_MINOR@
+PCRE_PRERELEASE = @PCRE_PRERELEASE@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pcre_have_bits_type_traits = @pcre_have_bits_type_traits@
+pcre_have_long_long = @pcre_have_long_long@
+pcre_have_type_traits = @pcre_have_type_traits@
+pcre_have_ulong_long = @pcre_have_ulong_long@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+dist_doc_DATA = \
+  doc/pcre.txt \
+  doc/pcre-config.txt \
+  doc/pcregrep.txt \
+  doc/pcretest.txt \
+  AUTHORS \
+  COPYING \
+  ChangeLog \
+  LICENCE \
+  NEWS \
+  README
+
+dist_html_DATA = \
+  doc/html/index.html \
+  doc/html/pcre.html \
+  doc/html/pcre-config.html \
+  doc/html/pcre_compile.html \
+  doc/html/pcre_compile2.html \
+  doc/html/pcre_config.html \
+  doc/html/pcre_copy_named_substring.html \
+  doc/html/pcre_copy_substring.html \
+  doc/html/pcre_dfa_exec.html \
+  doc/html/pcre_exec.html \
+  doc/html/pcre_free_substring.html \
+  doc/html/pcre_free_substring_list.html \
+  doc/html/pcre_fullinfo.html \
+  doc/html/pcre_get_named_substring.html \
+  doc/html/pcre_get_stringnumber.html \
+  doc/html/pcre_get_stringtable_entries.html \
+  doc/html/pcre_get_substring.html \
+  doc/html/pcre_get_substring_list.html \
+  doc/html/pcre_info.html \
+  doc/html/pcre_maketables.html \
+  doc/html/pcre_refcount.html \
+  doc/html/pcre_study.html \
+  doc/html/pcre_version.html \
+  doc/html/pcreapi.html \
+  doc/html/pcrebuild.html \
+  doc/html/pcrecallout.html \
+  doc/html/pcrecompat.html \
+  doc/html/pcregrep.html \
+  doc/html/pcrematching.html \
+  doc/html/pcrepartial.html \
+  doc/html/pcrepattern.html \
+  doc/html/pcreperform.html \
+  doc/html/pcreposix.html \
+  doc/html/pcreprecompile.html \
+  doc/html/pcresample.html \
+  doc/html/pcrestack.html \
+  doc/html/pcresyntax.html \
+  doc/html/pcretest.html
+
+pcrecpp_html = doc/html/pcrecpp.html
+dist_noinst_DATA = $(pcrecpp_html)
+@WITH_PCRE_CPP_TRUE@html_DATA = $(pcrecpp_html)
+
+# The Libtool libraries to install.  We'll add to this later.
+lib_LTLIBRARIES = libpcre.la libpcreposix.la $(am__append_4)
+check_SCRIPTS =
+dist_noinst_SCRIPTS = RunTest RunGrepTest
+
+# Additional files to delete on 'make clean' and 'make maintainer-clean'.
+CLEANFILES = pcre_chartables.c testsavedregex teststderr testtry \
+	testNinput
+MAINTAINERCLEANFILES = pcre.h.generic
+
+# Additional files to bundle with the distribution, over and above what
+# the Autotools include by default.
+
+# These files contain maintenance information
+
+# These files are used in the preparation of a release
+
+# These files are to do with building for Virtual Pascal
+
+# These files are usable versions of pcre.h and config.h that are distributed
+# for the benefit of people who are building PCRE manually, without the
+# Autotools support.
+
+# The pcre_printint.src file is #included by some source files, so it must be
+# distributed. The pcre_chartables.c.dist file is the default version of
+# pcre_chartables.c, used unless --enable-rebuild-chartables is specified.
+
+# PCRE demonstration program. No longer built automatcally. The point is that
+# the users should build it themselves. So just distribute the source.
+# noinst_PROGRAMS += pcredemo
+# pcredemo_SOURCES = pcredemo.c
+# pcredemo_LDADD = libpcre.la
+EXTRA_DIST = doc/perltest.txt NON-UNIX-USE HACKING PrepareRelease \
+	CleanTxt Detrail 132html doc/index.html.src makevp.bat \
+	makevp_c.txt makevp_l.txt pcregexp.pas pcre.h.generic \
+	config.h.generic pcre_printint.src pcre_chartables.c.dist \
+	RunTest.bat testdata/grepinput testdata/grepinput8 \
+	testdata/grepinputv testdata/grepinputx testdata/greplist \
+	testdata/grepoutput testdata/grepoutput8 testdata/grepoutputN \
+	testdata/testinput1 testdata/testinput2 testdata/testinput3 \
+	testdata/testinput4 testdata/testinput5 testdata/testinput6 \
+	testdata/testinput7 testdata/testinput8 testdata/testinput9 \
+	testdata/testinput10 testdata/testoutput1 testdata/testoutput2 \
+	testdata/testoutput3 testdata/testoutput4 testdata/testoutput5 \
+	testdata/testoutput6 testdata/testoutput7 testdata/testoutput8 \
+	testdata/testoutput9 testdata/testoutput10 \
+	testdata/wintestinput3 testdata/wintestoutput3 perltest.pl \
+	pcredemo.c $(pcrecpp_man) cmake/COPYING-CMAKE-SCRIPTS \
+	cmake/FindPackageHandleStandardArgs.cmake \
+	cmake/FindReadline.cmake CMakeLists.txt config-cmake.h.in
+
+# These are the header files we'll install. We do not distribute pcre.h because
+# it is generated from pcre.h.in.
+nodist_include_HEADERS = pcre.h $(am__append_1)
+include_HEADERS = pcreposix.h $(am__append_2)
+bin_SCRIPTS = pcre-config
+@WITH_REBUILD_CHARTABLES_TRUE@dftables_SOURCES = dftables.c
+libpcre_la_SOURCES = \
+  pcre_compile.c \
+  pcre_config.c \
+  pcre_dfa_exec.c \
+  pcre_exec.c \
+  pcre_fullinfo.c \
+  pcre_get.c \
+  pcre_globals.c \
+  pcre_info.c \
+  pcre_internal.h \
+  pcre_maketables.c \
+  pcre_newline.c \
+  pcre_ord2utf8.c \
+  pcre_refcount.c \
+  pcre_study.c \
+  pcre_tables.c \
+  pcre_try_flipped.c \
+  pcre_ucd.c \
+  pcre_valid_utf8.c \
+  pcre_version.c \
+  pcre_xclass.c \
+  ucp.h
+
+nodist_libpcre_la_SOURCES = \
+  pcre_chartables.c
+
+libpcre_la_LDFLAGS = $(EXTRA_LIBPCRE_LDFLAGS)
+libpcreposix_la_SOURCES = \
+  pcreposix.c
+
+libpcreposix_la_LDFLAGS = $(EXTRA_LIBPCREPOSIX_LDFLAGS)
+libpcreposix_la_LIBADD = libpcre.la
+@WITH_PCRE_CPP_TRUE@libpcrecpp_la_SOURCES = \
+@WITH_PCRE_CPP_TRUE@  pcrecpp_internal.h \
+@WITH_PCRE_CPP_TRUE@  pcrecpp.cc \
+@WITH_PCRE_CPP_TRUE@  pcre_scanner.cc \
+@WITH_PCRE_CPP_TRUE@  pcre_stringpiece.cc
+
+@WITH_PCRE_CPP_TRUE@libpcrecpp_la_LDFLAGS = $(EXTRA_LIBPCRECPP_LDFLAGS)
+@WITH_PCRE_CPP_TRUE@libpcrecpp_la_LIBADD = libpcre.la
+@WITH_PCRE_CPP_TRUE@pcrecpp_unittest_SOURCES = pcrecpp_unittest.cc
+@WITH_PCRE_CPP_TRUE@pcrecpp_unittest_LDADD = libpcrecpp.la
+@WITH_PCRE_CPP_TRUE@pcre_scanner_unittest_SOURCES = pcre_scanner_unittest.cc
+@WITH_PCRE_CPP_TRUE@pcre_scanner_unittest_LDADD = libpcrecpp.la
+@WITH_PCRE_CPP_TRUE@pcre_stringpiece_unittest_SOURCES = pcre_stringpiece_unittest.cc
+@WITH_PCRE_CPP_TRUE@pcre_stringpiece_unittest_LDADD = libpcrecpp.la
+pcretest_SOURCES = pcretest.c
+pcretest_LDADD = libpcreposix.la
+pcregrep_SOURCES = pcregrep.c
+pcregrep_LDADD = libpcreposix.la
+
+# A PCRE user submitted the following addition, saying that it "will allow
+# anyone using the 'mingw32' compiler to simply type 'make pcre.dll' and get a
+# nice DLL for Windows use". (It is used by the pcre.dll target.)
+DLL_OBJS = pcre_compile.o pcre_config.o \
+	pcre_dfa_exec.o pcre_exec.o pcre_fullinfo.o pcre_get.o \
+	pcre_globals.o pcre_info.o pcre_maketables.o \
+	pcre_newline.o pcre_ord2utf8.o pcre_refcount.o \
+	pcre_study.o pcre_tables.o pcre_try_flipped.o \
+	pcre_ucd.o pcre_valid_utf8.o pcre_version.o \
+	pcre_chartables.o \
+	pcre_xclass.o
+
+
+# We have .pc files for pkg-config users.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libpcre.pc $(am__append_7)
+dist_man_MANS = \
+  doc/pcre.3 \
+  doc/pcre-config.1 \
+  doc/pcre_compile.3 \
+  doc/pcre_compile2.3 \
+  doc/pcre_config.3 \
+  doc/pcre_copy_named_substring.3 \
+  doc/pcre_copy_substring.3 \
+  doc/pcre_dfa_exec.3 \
+  doc/pcre_exec.3 \
+  doc/pcre_free_substring.3 \
+  doc/pcre_free_substring_list.3 \
+  doc/pcre_fullinfo.3 \
+  doc/pcre_get_named_substring.3 \
+  doc/pcre_get_stringnumber.3 \
+  doc/pcre_get_stringtable_entries.3 \
+  doc/pcre_get_substring.3 \
+  doc/pcre_get_substring_list.3 \
+  doc/pcre_info.3 \
+  doc/pcre_maketables.3 \
+  doc/pcre_refcount.3 \
+  doc/pcre_study.3 \
+  doc/pcre_version.3 \
+  doc/pcreapi.3 \
+  doc/pcrebuild.3 \
+  doc/pcrecallout.3 \
+  doc/pcrecompat.3 \
+  doc/pcregrep.1 \
+  doc/pcrematching.3 \
+  doc/pcrepartial.3 \
+  doc/pcrepattern.3 \
+  doc/pcreperform.3 \
+  doc/pcreposix.3 \
+  doc/pcreprecompile.3 \
+  doc/pcresample.3 \
+  doc/pcrestack.3 \
+  doc/pcresyntax.3 \
+  doc/pcretest.1
+
+pcrecpp_man = doc/pcrecpp.3
+@WITH_PCRE_CPP_TRUE@man_MANS = $(pcrecpp_man)
+all: config.h
+	$(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .cc .lo .o .obj
+am--refresh:
+	@:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
+	      cd $(srcdir) && $(AUTOMAKE) --gnu  \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    echo ' $(SHELL) ./config.status'; \
+	    $(SHELL) ./config.status;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	$(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+config.h: stamp-h1
+	@if test ! -f $@; then \
+	  rm -f stamp-h1; \
+	  $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+	else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+	@rm -f stamp-h1
+	cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps)
+	cd $(top_srcdir) && $(AUTOHEADER)
+	rm -f stamp-h1
+	touch $@
+
+distclean-hdr:
+	-rm -f config.h stamp-h1
+libpcre.pc: $(top_builddir)/config.status $(srcdir)/libpcre.pc.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+libpcrecpp.pc: $(top_builddir)/config.status $(srcdir)/libpcrecpp.pc.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+pcre-config: $(top_builddir)/config.status $(srcdir)/pcre-config.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+pcre.h: $(top_builddir)/config.status $(srcdir)/pcre.h.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+pcre_stringpiece.h: $(top_builddir)/config.status $(srcdir)/pcre_stringpiece.h.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+pcrecpparg.h: $(top_builddir)/config.status $(srcdir)/pcrecpparg.h.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-libLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+	done
+
+clean-libLTLIBRARIES:
+	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+	@list='$(lib_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
+libpcre.la: $(libpcre_la_OBJECTS) $(libpcre_la_DEPENDENCIES)
+	$(libpcre_la_LINK) -rpath $(libdir) $(libpcre_la_OBJECTS) $(libpcre_la_LIBADD) $(LIBS)
+libpcrecpp.la: $(libpcrecpp_la_OBJECTS) $(libpcrecpp_la_DEPENDENCIES)
+	$(libpcrecpp_la_LINK) $(am_libpcrecpp_la_rpath) $(libpcrecpp_la_OBJECTS) $(libpcrecpp_la_LIBADD) $(LIBS)
+libpcreposix.la: $(libpcreposix_la_OBJECTS) $(libpcreposix_la_DEPENDENCIES)
+	$(libpcreposix_la_LINK) -rpath $(libdir) $(libpcreposix_la_OBJECTS) $(libpcreposix_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	     || test -f $$p1 \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+
+clean-noinstPROGRAMS:
+	@list='$(noinst_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+dftables$(EXEEXT): $(dftables_OBJECTS) $(dftables_DEPENDENCIES)
+	@rm -f dftables$(EXEEXT)
+	$(LINK) $(dftables_OBJECTS) $(dftables_LDADD) $(LIBS)
+pcre_scanner_unittest$(EXEEXT): $(pcre_scanner_unittest_OBJECTS) $(pcre_scanner_unittest_DEPENDENCIES)
+	@rm -f pcre_scanner_unittest$(EXEEXT)
+	$(CXXLINK) $(pcre_scanner_unittest_OBJECTS) $(pcre_scanner_unittest_LDADD) $(LIBS)
+pcre_stringpiece_unittest$(EXEEXT): $(pcre_stringpiece_unittest_OBJECTS) $(pcre_stringpiece_unittest_DEPENDENCIES)
+	@rm -f pcre_stringpiece_unittest$(EXEEXT)
+	$(CXXLINK) $(pcre_stringpiece_unittest_OBJECTS) $(pcre_stringpiece_unittest_LDADD) $(LIBS)
+pcrecpp_unittest$(EXEEXT): $(pcrecpp_unittest_OBJECTS) $(pcrecpp_unittest_DEPENDENCIES)
+	@rm -f pcrecpp_unittest$(EXEEXT)
+	$(CXXLINK) $(pcrecpp_unittest_OBJECTS) $(pcrecpp_unittest_LDADD) $(LIBS)
+pcregrep$(EXEEXT): $(pcregrep_OBJECTS) $(pcregrep_DEPENDENCIES)
+	@rm -f pcregrep$(EXEEXT)
+	$(LINK) $(pcregrep_OBJECTS) $(pcregrep_LDADD) $(LIBS)
+pcretest$(EXEEXT): $(pcretest_OBJECTS) $(pcretest_DEPENDENCIES)
+	@rm -f pcretest$(EXEEXT)
+	$(LINK) $(pcretest_OBJECTS) $(pcretest_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f $$d$$p; then \
+	    f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	    echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	    $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-binSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dftables.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_chartables.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_compile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_config.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_dfa_exec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_exec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_fullinfo.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_get.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_globals.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_info.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_maketables.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_newline.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_ord2utf8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_refcount.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_scanner.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_scanner_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_stringpiece.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_stringpiece_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_study.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_tables.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_try_flipped.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_ucd.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_valid_utf8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_version.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcre_xclass.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcrecpp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcrecpp_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcregrep.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcreposix.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcretest.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+.cc.o:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+@am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+install-man1: $(man1_MANS) $(man_MANS)
+	@$(NORMAL_INSTALL)
+	test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+	@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
+	  case "$$i" in \
+	    *.1*) list="$$list $$i" ;; \
+	  esac; \
+	done; \
+	for i in $$list; do \
+	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+	  else file=$$i; fi; \
+	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    1*) ;; \
+	    *) ext='1' ;; \
+	  esac; \
+	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
+	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+	  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+	  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
+	done
+uninstall-man1:
+	@$(NORMAL_UNINSTALL)
+	@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
+	  case "$$i" in \
+	    *.1*) list="$$list $$i" ;; \
+	  esac; \
+	done; \
+	for i in $$list; do \
+	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    1*) ;; \
+	    *) ext='1' ;; \
+	  esac; \
+	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
+	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+	  echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
+	  rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
+	done
+install-man3: $(man3_MANS) $(man_MANS)
+	@$(NORMAL_INSTALL)
+	test -z "$(man3dir)" || $(MKDIR_P) "$(DESTDIR)$(man3dir)"
+	@list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
+	  case "$$i" in \
+	    *.3*) list="$$list $$i" ;; \
+	  esac; \
+	done; \
+	for i in $$list; do \
+	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+	  else file=$$i; fi; \
+	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    3*) ;; \
+	    *) ext='3' ;; \
+	  esac; \
+	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
+	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+	  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
+	  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst"; \
+	done
+uninstall-man3:
+	@$(NORMAL_UNINSTALL)
+	@list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
+	  case "$$i" in \
+	    *.3*) list="$$list $$i" ;; \
+	  esac; \
+	done; \
+	for i in $$list; do \
+	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    3*) ;; \
+	    *) ext='3' ;; \
+	  esac; \
+	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
+	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+	  echo " rm -f '$(DESTDIR)$(man3dir)/$$inst'"; \
+	  rm -f "$(DESTDIR)$(man3dir)/$$inst"; \
+	done
+install-dist_docDATA: $(dist_doc_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)"
+	@list='$(dist_doc_DATA)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(dist_docDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(docdir)/$$f'"; \
+	  $(dist_docDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(docdir)/$$f"; \
+	done
+
+uninstall-dist_docDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(dist_doc_DATA)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(docdir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(docdir)/$$f"; \
+	done
+install-dist_htmlDATA: $(dist_html_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"
+	@list='$(dist_html_DATA)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(dist_htmlDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
+	  $(dist_htmlDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
+	done
+
+uninstall-dist_htmlDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(dist_html_DATA)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(htmldir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(htmldir)/$$f"; \
+	done
+install-htmlDATA: $(html_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"
+	@list='$(html_DATA)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(htmlDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
+	  $(htmlDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
+	done
+
+uninstall-htmlDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(html_DATA)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(htmldir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(htmldir)/$$f"; \
+	done
+install-pkgconfigDATA: $(pkgconfig_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
+	@list='$(pkgconfig_DATA)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(pkgconfigDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
+	  $(pkgconfigDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgconfigdir)/$$f"; \
+	done
+
+uninstall-pkgconfigDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkgconfig_DATA)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(pkgconfigdir)/$$f"; \
+	done
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
+	  $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(includedir)/$$f"; \
+	done
+install-nodist_includeHEADERS: $(nodist_include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(nodist_include_HEADERS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(nodist_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
+	  $(nodist_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
+	done
+
+uninstall-nodist_includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(nodist_include_HEADERS)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(includedir)/$$f"; \
+	done
+
+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; nonemtpy = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(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; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	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; nonempty = 1; } \
+	      END { if (nonempty) { 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
+
+check-TESTS: $(TESTS)
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[	 ]'; \
+	srcdir=$(srcdir); export srcdir; \
+	list=' $(TESTS) '; \
+	if test -n "$$list"; then \
+	  for tst in $$list; do \
+	    if test -f ./$$tst; then dir=./; \
+	    elif test -f $$tst; then dir=; \
+	    else dir="$(srcdir)/"; fi; \
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *$$ws$$tst$$ws*) \
+		xpass=`expr $$xpass + 1`; \
+		failed=`expr $$failed + 1`; \
+		echo "XPASS: $$tst"; \
+	      ;; \
+	      *) \
+		echo "PASS: $$tst"; \
+	      ;; \
+	      esac; \
+	    elif test $$? -ne 77; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *$$ws$$tst$$ws*) \
+		xfail=`expr $$xfail + 1`; \
+		echo "XFAIL: $$tst"; \
+	      ;; \
+	      *) \
+		failed=`expr $$failed + 1`; \
+		echo "FAIL: $$tst"; \
+	      ;; \
+	      esac; \
+	    else \
+	      skip=`expr $$skip + 1`; \
+	      echo "SKIP: $$tst"; \
+	    fi; \
+	  done; \
+	  if test "$$failed" -eq 0; then \
+	    if test "$$xfail" -eq 0; then \
+	      banner="All $$all tests passed"; \
+	    else \
+	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
+	    fi; \
+	  else \
+	    if test "$$xpass" -eq 0; then \
+	      banner="$$failed of $$all tests failed"; \
+	    else \
+	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+	    fi; \
+	  fi; \
+	  dashes="$$banner"; \
+	  skipped=""; \
+	  if test "$$skip" -ne 0; then \
+	    skipped="($$skip tests were not run)"; \
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$skipped"; \
+	  fi; \
+	  report=""; \
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$report"; \
+	  fi; \
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
+	  echo "$$dashes"; \
+	  echo "$$banner"; \
+	  test -z "$$skipped" || echo "$$skipped"; \
+	  test -z "$$report" || echo "$$report"; \
+	  echo "$$dashes"; \
+	  test "$$failed" -eq 0; \
+	else :; fi
+
+distdir: $(DISTFILES)
+	$(am__remove_distdir)
+	test -d $(distdir) || mkdir $(distdir)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    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
+	-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 $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r $(distdir)
+dist-gzip: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
+dist-bzip2: distdir
+	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+	$(am__remove_distdir)
+
+dist-lzma: distdir
+	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+	$(am__remove_distdir)
+
+dist-tarZ: distdir
+	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+	$(am__remove_distdir)
+
+dist-shar: distdir
+	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+	$(am__remove_distdir)
+dist-zip: distdir
+	-rm -f $(distdir).zip
+	zip -rq $(distdir).zip $(distdir)
+	$(am__remove_distdir)
+
+dist dist-all: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+	-rm -f $(distdir).zip
+	zip -rq $(distdir).zip $(distdir)
+	$(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
+	case '$(DIST_ARCHIVES)' in \
+	*.tar.gz*) \
+	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+	*.tar.bz2*) \
+	  bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+	*.tar.lzma*) \
+	  unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+	*.tar.Z*) \
+	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+	*.shar.gz*) \
+	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+	*.zip*) \
+	  unzip $(distdir).zip ;;\
+	esac
+	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 | sed -e 's,^[^:\\/]:[\\/],/,'` \
+	  && 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 ../.. && umask 077 && mkdir "$$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 \
+	  && rm -rf $(DIST_ARCHIVES) \
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+	$(am__remove_distdir)
+	@(echo "$(distdir) archives ready for distribution: "; \
+	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$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_SCRIPTS)
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(MANS) $(DATA) \
+		$(HEADERS) config.h
+install-binPROGRAMS: install-libLTLIBRARIES
+
+installdirs:
+	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+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_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(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."
+	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
+	clean-libtool clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-hdr distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-dist_docDATA install-dist_htmlDATA \
+	install-htmlDATA install-includeHEADERS install-man \
+	install-nodist_includeHEADERS install-pkgconfigDATA
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS install-binSCRIPTS \
+	install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man: install-man1 install-man3
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf $(top_srcdir)/autom4te.cache
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+	uninstall-dist_docDATA uninstall-dist_htmlDATA \
+	uninstall-htmlDATA uninstall-includeHEADERS \
+	uninstall-libLTLIBRARIES uninstall-man \
+	uninstall-nodist_includeHEADERS uninstall-pkgconfigDATA
+
+uninstall-man: uninstall-man1 uninstall-man3
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \
+	clean clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
+	clean-libtool clean-noinstPROGRAMS ctags dist dist-all \
+	dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ dist-zip \
+	distcheck distclean distclean-compile distclean-generic \
+	distclean-hdr distclean-libtool distclean-tags distcleancheck \
+	distdir distuninstallcheck dvi dvi-am html html-am info \
+	info-am install install-am install-binPROGRAMS \
+	install-binSCRIPTS install-data install-data-am \
+	install-dist_docDATA install-dist_htmlDATA install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-htmlDATA install-includeHEADERS \
+	install-info install-info-am install-libLTLIBRARIES \
+	install-man install-man1 install-man3 \
+	install-nodist_includeHEADERS install-pdf install-pdf-am \
+	install-pkgconfigDATA install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-binPROGRAMS \
+	uninstall-binSCRIPTS uninstall-dist_docDATA \
+	uninstall-dist_htmlDATA uninstall-htmlDATA \
+	uninstall-includeHEADERS uninstall-libLTLIBRARIES \
+	uninstall-man uninstall-man1 uninstall-man3 \
+	uninstall-nodist_includeHEADERS uninstall-pkgconfigDATA
+
+
+pcre.h.generic: configure.ac
+	rm -f $@
+	cp -p pcre.h $@
+
+@WITH_REBUILD_CHARTABLES_TRUE@pcre_chartables.c: dftables$(EXEEXT)
+@WITH_REBUILD_CHARTABLES_TRUE@	./dftables$(EXEEXT) $@
+
+@WITH_REBUILD_CHARTABLES_FALSE@pcre_chartables.c: $(srcdir)/pcre_chartables.c.dist
+@WITH_REBUILD_CHARTABLES_FALSE@	rm -f $@
+@WITH_REBUILD_CHARTABLES_FALSE@	$(LN_S) $(srcdir)/pcre_chartables.c.dist $@
+
+# A compatibility line, the old build system worked with 'make test'
+test: check ;
+
+# A PCRE user submitted the following addition, saying that it "will allow
+# anyone using the 'mingw32' compiler to simply type 'make pcre.dll' and get a
+# nice DLL for Windows use".
+pcre.dll: $(DLL_OBJS)
+	$(CC) -shared -o pcre.dll -Wl,"--strip-all" -Wl,"--export-all-symbols" $(DLL_OBJS)
+# 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:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/NEWS	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,423 @@
+News about PCRE releases
+------------------------
+
+
+Release 7.8 05-Sep-08
+---------------------
+
+More bug fixes, plus a performance improvement in Unicode character property
+lookup.
+
+
+Release 7.7 07-May-08
+---------------------
+
+This is once again mainly a bug-fix release, but there are a couple of new
+features.
+
+
+Release 7.6 28-Jan-08
+---------------------
+
+The main reason for having this release so soon after 7.5 is because it fixes a
+potential buffer overflow problem in pcre_compile() when run in UTF-8 mode. In
+addition, the CMake configuration files have been brought up to date.
+
+
+Release 7.5 10-Jan-08
+---------------------
+
+This is mainly a bug-fix release. However the ability to link pcregrep with
+libz or libbz2 and the ability to link pcretest with libreadline have been
+added. Also the --line-offsets and --file-offsets options were added to
+pcregrep.
+
+
+Release 7.4 21-Sep-07
+---------------------
+
+The only change of specification is the addition of options to control whether
+\R matches any Unicode line ending (the default) or just CR, LF, and CRLF.
+Otherwise, the changes are bug fixes and a refactoring to reduce the number of
+relocations needed in a shared library. There have also been some documentation
+updates, in particular, some more information about using CMake to build PCRE
+has been added to the NON-UNIX-USE file.
+
+
+Release 7.3 28-Aug-07
+---------------------
+
+Most changes are bug fixes. Some that are not:
+
+1. There is some support for Perl 5.10's experimental "backtracking control
+   verbs" such as (*PRUNE).
+
+2. UTF-8 checking is now as per RFC 3629 instead of RFC 2279; this is more
+   restrictive in the strings it accepts.
+
+3. Checking for potential integer overflow has been made more dynamic, and as a
+   consequence there is no longer a hard limit on the size of a subpattern that
+   has a limited repeat count.
+
+4. When CRLF is a valid line-ending sequence, pcre_exec() and pcre_dfa_exec()
+   no longer advance by two characters instead of one when an unanchored match
+   fails at CRLF if there are explicit CR or LF matches within the pattern.
+   This gets rid of some anomalous effects that previously occurred.
+
+5. Some PCRE-specific settings for varying the newline options at the start of
+   a pattern have been added.
+
+
+Release 7.2 19-Jun-07
+---------------------
+
+WARNING: saved patterns that were compiled by earlier versions of PCRE must be
+recompiled for use with 7.2 (necessitated by the addition of \K, \h, \H, \v,
+and \V).
+
+Correction to the notes for 7.1: the note about shared libraries for Windows is
+wrong. Previously, three libraries were built, but each could function
+independently. For example, the pcreposix library also included all the
+functions from the basic pcre library. The change is that the three libraries
+are no longer independent. They are like the Unix libraries. To use the
+pcreposix functions, for example, you need to link with both the pcreposix and
+the basic pcre library.
+
+Some more features from Perl 5.10 have been added:
+
+  (?-n) and (?+n) relative references for recursion and subroutines.
+
+  (?(-n) and (?(+n) relative references as conditions.
+
+  \k{name} and \g{name} are synonyms for \k<name>.
+
+  \K to reset the start of the matched string; for example, (foo)\Kbar
+  matches bar preceded by foo, but only sets bar as the matched string.
+
+  (?| introduces a group where the capturing parentheses in each alternative
+  start from the same number; for example, (?|(abc)|(xyz)) sets capturing
+  parentheses number 1 in both cases.
+
+  \h, \H, \v, \V match horizontal and vertical whitespace, respectively.
+
+
+Release 7.1 24-Apr-07
+---------------------
+
+There is only one new feature in this release: a linebreak setting of
+PCRE_NEWLINE_ANYCRLF. It is a cut-down version of PCRE_NEWLINE_ANY, which
+recognizes only CRLF, CR, and LF as linebreaks.
+
+A few bugs are fixed (see ChangeLog for details), but the major change is a
+complete re-implementation of the build system. This now has full Autotools
+support and so is now "standard" in some sense. It should help with compiling
+PCRE in a wide variety of environments.
+
+NOTE: when building shared libraries for Windows, three dlls are now built,
+called libpcre, libpcreposix, and libpcrecpp. Previously, everything was
+included in a single dll.
+
+Another important change is that the dftables auxiliary program is no longer
+compiled and run at "make" time by default. Instead, a default set of character
+tables (assuming ASCII coding) is used. If you want to use dftables to generate
+the character tables as previously, add --enable-rebuild-chartables to the
+"configure" command. You must do this if you are compiling PCRE to run on a
+system that uses EBCDIC code.
+
+There is a discussion about character tables in the README file. The default is
+not to use dftables so that that there is no problem when cross-compiling.
+
+
+Release 7.0 19-Dec-06
+---------------------
+
+This release has a new major number because there have been some internal
+upheavals to facilitate the addition of new optimizations and other facilities,
+and to make subsequent maintenance and extension easier. Compilation is likely
+to be a bit slower, but there should be no major effect on runtime performance.
+Previously compiled patterns are NOT upwards compatible with this release. If
+you have saved compiled patterns from a previous release, you will have to
+re-compile them. Important changes that are visible to users are:
+
+1. The Unicode property tables have been updated to Unicode 5.0.0, which adds
+   some more scripts.
+
+2. The option PCRE_NEWLINE_ANY causes PCRE to recognize any Unicode newline
+   sequence as a newline.
+
+3. The \R escape matches a single Unicode newline sequence as a single unit.
+
+4. New features that will appear in Perl 5.10 are now in PCRE. These include
+   alternative Perl syntax for named parentheses, and Perl syntax for
+   recursion.
+
+5. The C++ wrapper interface has been extended by the addition of a
+   QuoteMeta function and the ability to allow copy construction and
+   assignment.
+
+For a complete list of changes, see the ChangeLog file.
+
+
+Release 6.7 04-Jul-06
+---------------------
+
+The main additions to this release are the ability to use the same name for
+multiple sets of parentheses, and support for CRLF line endings in both the
+library and pcregrep (and in pcretest for testing).
+
+Thanks to Ian Taylor, the stack usage for many kinds of pattern has been
+significantly reduced for certain subject strings.
+
+
+Release 6.5 01-Feb-06
+---------------------
+
+Important changes in this release:
+
+1. A number of new features have been added to pcregrep.
+
+2. The Unicode property tables have been updated to Unicode 4.1.0, and the
+   supported properties have been extended with script names such as "Arabic",
+   and the derived properties "Any" and "L&". This has necessitated a change to
+   the interal format of compiled patterns. Any saved compiled patterns that
+   use \p or \P must be recompiled.
+
+3. The specification of recursion in patterns has been changed so that all
+   recursive subpatterns are automatically treated as atomic groups. Thus, for
+   example, (?R) is treated as if it were (?>(?R)). This is necessary because
+   otherwise there are situations where recursion does not work.
+
+See the ChangeLog for a complete list of changes, which include a number of bug
+fixes and tidies.
+
+
+Release 6.0 07-Jun-05
+---------------------
+
+The release number has been increased to 6.0 because of the addition of several
+major new pieces of functionality.
+
+A new function, pcre_dfa_exec(), which implements pattern matching using a DFA
+algorithm, has been added. This has a number of advantages for certain cases,
+though it does run more slowly, and lacks the ability to capture substrings. On
+the other hand, it does find all matches, not just the first, and it works
+better for partial matching. The pcrematching man page discusses the
+differences.
+
+The pcretest program has been enhanced so that it can make use of the new
+pcre_dfa_exec() matching function and the extra features it provides.
+
+The distribution now includes a C++ wrapper library. This is built
+automatically if a C++ compiler is found. The pcrecpp man page discusses this
+interface.
+
+The code itself has been re-organized into many more files, one for each
+function, so it no longer requires everything to be linked in when static
+linkage is used. As a consequence, some internal functions have had to have
+their names exposed. These functions all have names starting with _pcre_. They
+are undocumented, and are not intended for use by outside callers.
+
+The pcregrep program has been enhanced with new functionality such as
+multiline-matching and options for output more matching context. See the
+ChangeLog for a complete list of changes to the library and the utility
+programs.
+
+
+Release 5.0 13-Sep-04
+---------------------
+
+The licence under which PCRE is released has been changed to the more
+conventional "BSD" licence.
+
+In the code, some bugs have been fixed, and there are also some major changes
+in this release (which is why I've increased the number to 5.0). Some changes
+are internal rearrangements, and some provide a number of new facilities. The
+new features are:
+
+1. There's an "automatic callout" feature that inserts callouts before every
+   item in the regex, and there's a new callout field that gives the position
+   in the pattern - useful for debugging and tracing.
+
+2. The extra_data structure can now be used to pass in a set of character
+   tables at exec time. This is useful if compiled regex are saved and re-used
+   at a later time when the tables may not be at the same address. If the
+   default internal tables are used, the pointer saved with the compiled
+   pattern is now set to NULL, which means that you don't need to do anything
+   special unless you are using custom tables.
+
+3. It is possible, with some restrictions on the content of the regex, to
+   request "partial" matching. A special return code is given if all of the
+   subject string matched part of the regex. This could be useful for testing
+   an input field as it is being typed.
+
+4. There is now some optional support for Unicode character properties, which
+   means that the patterns items such as \p{Lu} and \X can now be used. Only
+   the general category properties are supported. If PCRE is compiled with this
+   support, an additional 90K data structure is include, which increases the
+   size of the library dramatically.
+
+5. There is support for saving compiled patterns and re-using them later.
+
+6. There is support for running regular expressions that were compiled on a
+   different host with the opposite endianness.
+
+7. The pcretest program has been extended to accommodate the new features.
+
+The main internal rearrangement is that sequences of literal characters are no
+longer handled as strings. Instead, each character is handled on its own. This
+makes some UTF-8 handling easier, and makes the support of partial matching
+possible. Compiled patterns containing long literal strings will be larger as a
+result of this change; I hope that performance will not be much affected.
+
+
+Release 4.5 01-Dec-03
+---------------------
+
+Again mainly a bug-fix and tidying release, with only a couple of new features:
+
+1. It's possible now to compile PCRE so that it does not use recursive
+function calls when matching. Instead it gets memory from the heap. This slows
+things down, but may be necessary on systems with limited stacks.
+
+2. UTF-8 string checking has been tightened to reject overlong sequences and to
+check that a starting offset points to the start of a character. Failure of the
+latter returns a new error code: PCRE_ERROR_BADUTF8_OFFSET.
+
+3. PCRE can now be compiled for systems that use EBCDIC code.
+
+
+Release 4.4 21-Aug-03
+---------------------
+
+This is mainly a bug-fix and tidying release. The only new feature is that PCRE
+checks UTF-8 strings for validity by default. There is an option to suppress
+this, just in case anybody wants that teeny extra bit of performance.
+
+
+Releases 4.1 - 4.3
+------------------
+
+Sorry, I forgot about updating the NEWS file for these releases. Please take a
+look at ChangeLog.
+
+
+Release 4.0 17-Feb-03
+---------------------
+
+There have been a lot of changes for the 4.0 release, adding additional
+functionality and mending bugs. Below is a list of the highlights of the new
+functionality. For full details of these features, please consult the
+documentation. For a complete list of changes, see the ChangeLog file.
+
+1. Support for Perl's \Q...\E escapes.
+
+2. "Possessive quantifiers" ?+, *+, ++, and {,}+ which come from Sun's Java
+package. They provide some syntactic sugar for simple cases of "atomic
+grouping".
+
+3. Support for the \G assertion. It is true when the current matching position
+is at the start point of the match.
+
+4. A new feature that provides some of the functionality that Perl provides
+with (?{...}). The facility is termed a "callout". The way it is done in PCRE
+is for the caller to provide an optional function, by setting pcre_callout to
+its entry point. To get the function called, the regex must include (?C) at
+appropriate points.
+
+5. Support for recursive calls to individual subpatterns. This makes it really
+easy to get totally confused.
+
+6. Support for named subpatterns. The Python syntax (?P<name>...) is used to
+name a group.
+
+7. Several extensions to UTF-8 support; it is now fairly complete. There is an
+option for pcregrep to make it operate in UTF-8 mode.
+
+8. The single man page has been split into a number of separate man pages.
+These also give rise to individual HTML pages which are put in a separate
+directory. There is an index.html page that lists them all. Some hyperlinking
+between the pages has been installed.
+
+
+Release 3.5 15-Aug-01
+---------------------
+
+1. The configuring system has been upgraded to use later versions of autoconf
+and libtool. By default it builds both a shared and a static library if the OS
+supports it. You can use --disable-shared or --disable-static on the configure
+command if you want only one of them.
+
+2. The pcretest utility is now installed along with pcregrep because it is
+useful for users (to test regexs) and by doing this, it automatically gets
+relinked by libtool. The documentation has been turned into a man page, so
+there are now .1, .txt, and .html versions in /doc.
+
+3. Upgrades to pcregrep:
+   (i)   Added long-form option names like gnu grep.
+   (ii)  Added --help to list all options with an explanatory phrase.
+   (iii) Added -r, --recursive to recurse into sub-directories.
+   (iv)  Added -f, --file to read patterns from a file.
+
+4. Added --enable-newline-is-cr and --enable-newline-is-lf to the configure
+script, to force use of CR or LF instead of \n in the source. On non-Unix
+systems, the value can be set in config.h.
+
+5. The limit of 200 on non-capturing parentheses is a _nesting_ limit, not an
+absolute limit. Changed the text of the error message to make this clear, and
+likewise updated the man page.
+
+6. The limit of 99 on the number of capturing subpatterns has been removed.
+The new limit is 65535, which I hope will not be a "real" limit.
+
+
+Release 3.3 01-Aug-00
+---------------------
+
+There is some support for UTF-8 character strings. This is incomplete and
+experimental. The documentation describes what is and what is not implemented.
+Otherwise, this is just a bug-fixing release.
+
+
+Release 3.0 01-Feb-00
+---------------------
+
+1. A "configure" script is now used to configure PCRE for Unix systems. It
+builds a Makefile, a config.h file, and the pcre-config script.
+
+2. PCRE is built as a shared library by default.
+
+3. There is support for POSIX classes such as [:alpha:].
+
+5. There is an experimental recursion feature.
+
+----------------------------------------------------------------------------
+          IMPORTANT FOR THOSE UPGRADING FROM VERSIONS BEFORE 2.00
+
+Please note that there has been a change in the API such that a larger
+ovector is required at matching time, to provide some additional workspace.
+The new man page has details. This change was necessary in order to support
+some of the new functionality in Perl 5.005.
+
+          IMPORTANT FOR THOSE UPGRADING FROM VERSION 2.00
+
+Another (I hope this is the last!) change has been made to the API for the
+pcre_compile() function. An additional argument has been added to make it
+possible to pass over a pointer to character tables built in the current
+locale by pcre_maketables(). To use the default tables, this new arguement
+should be passed as NULL.
+
+          IMPORTANT FOR THOSE UPGRADING FROM VERSION 2.05
+
+Yet another (and again I hope this really is the last) change has been made
+to the API for the pcre_exec() function. An additional argument has been
+added to make it possible to start the match other than at the start of the
+subject string. This is important if there are lookbehinds. The new man
+page has the details, but you just want to convert existing programs, all
+you need to do is to stick in a new fifth argument to pcre_exec(), with a
+value of zero. For example, change
+
+  pcre_exec(pattern, extra, subject, length, options, ovec, ovecsize)
+to
+  pcre_exec(pattern, extra, subject, length, 0, options, ovec, ovecsize)
+
+****
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/NON-UNIX-USE	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,441 @@
+Compiling PCRE on non-Unix systems
+----------------------------------
+
+This document contains the following sections:
+
+  General
+  Generic instructions for the PCRE C library
+  The C++ wrapper functions
+  Building for virtual Pascal
+  Stack size in Windows environments
+  Linking programs in Windows environments
+  Comments about Win32 builds
+  Building PCRE on Windows with CMake
+  Use of relative paths with CMake on Windows
+  Testing with runtest.bat
+  Building under Windows with BCC5.5
+  Building PCRE on OpenVMS
+
+
+GENERAL
+
+I (Philip Hazel) have no experience of Windows or VMS sytems and how their
+libraries work. The items in the PCRE distribution and Makefile that relate to
+anything other than Unix-like systems are untested by me.
+
+There are some other comments and files in the Contrib directory on the ftp
+site that you may find useful. See
+
+  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib
+
+If you want to compile PCRE for a non-Unix system (especially for a system that
+does not support "configure" and "make" files), note that the basic PCRE
+library consists entirely of code written in Standard C, and so should compile
+successfully on any system that has a Standard C compiler and library. The C++
+wrapper functions are a separate issue (see below).
+
+The PCRE distribution includes a "configure" file for use by the Configure/Make
+build system, as found in many Unix-like environments. There is also support
+support for CMake, which some users prefer, in particular in Windows
+environments. There are some instructions for CMake under Windows in the
+section entitled "Building PCRE with CMake" below. CMake can also be used to
+build PCRE in Unix-like systems.
+
+
+GENERIC INSTRUCTIONS FOR THE PCRE C LIBRARY
+
+The following are generic comments about building the PCRE C library "by hand".
+
+ (1) Copy or rename the file config.h.generic as config.h, and edit the macro
+     settings that it contains to whatever is appropriate for your environment.
+     In particular, if you want to force a specific value for newline, you can
+     define the NEWLINE macro. When you compile any of the PCRE modules, you
+     must specify -DHAVE_CONFIG_H to your compiler so that config.h is included
+     in the sources.
+
+     An alternative approach is not to edit config.h, but to use -D on the
+     compiler command line to make any changes that you need to the
+     configuration options. In this case -DHAVE_CONFIG_H must not be set.
+
+     NOTE: There have been occasions when the way in which certain parameters
+     in config.h are used has changed between releases. (In the configure/make
+     world, this is handled automatically.) When upgrading to a new release,
+     you are strongly advised to review config.h.generic before re-using what
+     you had previously.
+
+ (2) Copy or rename the file pcre.h.generic as pcre.h.
+
+ (3) EITHER:
+       Copy or rename file pcre_chartables.c.dist as pcre_chartables.c.
+
+     OR:
+       Compile dftables.c as a stand-alone program (using -DHAVE_CONFIG_H if
+       you have set up config.h), and then run it with the single argument
+       "pcre_chartables.c". This generates a set of standard character tables
+       and writes them to that file. The tables are generated using the default
+       C locale for your system. If you want to use a locale that is specified
+       by LC_xxx environment variables, add the -L option to the dftables
+       command. You must use this method if you are building on a system that
+       uses EBCDIC code.
+
+     The tables in pcre_chartables.c are defaults. The caller of PCRE can
+     specify alternative tables at run time.
+
+ (4) Ensure that you have the following header files:
+
+       pcre_internal.h
+       ucp.h
+
+ (5) Also ensure that you have the following file, which is #included as source
+     when building a debugging version of PCRE, and is also used by pcretest.
+
+       pcre_printint.src
+
+ (6) Compile the following source files, setting -DHAVE_CONFIG_H as a compiler
+     option if you have set up config.h with your configuration, or else use
+     other -D settings to change the configuration as required.
+
+       pcre_chartables.c
+       pcre_compile.c
+       pcre_config.c
+       pcre_dfa_exec.c
+       pcre_exec.c
+       pcre_fullinfo.c
+       pcre_get.c
+       pcre_globals.c
+       pcre_info.c
+       pcre_maketables.c
+       pcre_newline.c
+       pcre_ord2utf8.c
+       pcre_refcount.c
+       pcre_study.c
+       pcre_tables.c
+       pcre_try_flipped.c
+       pcre_ucd.c
+       pcre_valid_utf8.c
+       pcre_version.c
+       pcre_xclass.c
+
+     Make sure that you include -I. in the compiler command (or equivalent for
+     an unusual compiler) so that all included PCRE header files are first
+     sought in the current directory. Otherwise you run the risk of picking up
+     a previously-installed file from somewhere else.
+
+ (7) Now link all the compiled code into an object library in whichever form
+     your system keeps such libraries. This is the basic PCRE C library. If
+     your system has static and shared libraries, you may have to do this once
+     for each type.
+
+ (8) Similarly, compile pcreposix.c (remembering -DHAVE_CONFIG_H if necessary)
+     and link the result (on its own) as the pcreposix library.
+
+ (9) Compile the test program pcretest.c (again, don't forget -DHAVE_CONFIG_H).
+     This needs the functions in the pcre and pcreposix libraries when linking.
+     It also needs the pcre_printint.src source file, which it #includes.
+
+(10) Run pcretest on the testinput files in the testdata directory, and check
+     that the output matches the corresponding testoutput files. Note that the
+     supplied files are in Unix format, with just LF characters as line
+     terminators. You may need to edit them to change this if your system uses
+     a different convention. If you are using Windows, you probably should use
+     the wintestinput3 file instead of testinput3 (and the corresponding output
+     file). This is a locale test; wintestinput3 sets the locale to "french"
+     rather than "fr_FR", and there some minor output differences.
+
+(11) If you want to use the pcregrep command, compile and link pcregrep.c; it
+     uses only the basic PCRE library (it does not need the pcreposix library).
+
+
+THE C++ WRAPPER FUNCTIONS
+
+The PCRE distribution also contains some C++ wrapper functions and tests,
+contributed by Google Inc. On a system that can use "configure" and "make",
+the functions are automatically built into a library called pcrecpp. It should
+be straightforward to compile the .cc files manually on other systems. The
+files called xxx_unittest.cc are test programs for each of the corresponding
+xxx.cc files.
+
+
+BUILDING FOR VIRTUAL PASCAL
+
+A script for building PCRE using Borland's C++ compiler for use with VPASCAL
+was contributed by Alexander Tokarev. Stefan Weber updated the script and added
+additional files. The following files in the distribution are for building PCRE
+for use with VP/Borland: makevp_c.txt, makevp_l.txt, makevp.bat, pcregexp.pas.
+
+
+STACK SIZE IN WINDOWS ENVIRONMENTS
+
+The default processor stack size of 1Mb in some Windows environments is too
+small for matching patterns that need much recursion. In particular, test 2 may
+fail because of this. Normally, running out of stack causes a crash, but there
+have been cases where the test program has just died silently. See your linker
+documentation for how to increase stack size if you experience problems. The
+Linux default of 8Mb is a reasonable choice for the stack, though even that can
+be too small for some pattern/subject combinations.
+
+PCRE has a compile configuration option to disable the use of stack for
+recursion so that heap is used instead. However, pattern matching is
+significantly slower when this is done. There is more about stack usage in the
+"pcrestack" documentation.
+
+
+LINKING PROGRAMS IN WINDOWS ENVIRONMENTS
+
+If you want to statically link a program against a PCRE library in the form of
+a non-dll .a file, you must define PCRE_STATIC before including pcre.h,
+otherwise the pcre_malloc() and pcre_free() exported functions will be declared
+__declspec(dllimport), with unwanted results.
+
+
+CALLING CONVENTIONS IN WINDOWS ENVIRONMENTS
+
+It is possible to compile programs to use different calling conventions using
+MSVC. Search the web for "calling conventions" for more information. To make it
+easier to change the calling convention for the exported functions in the
+PCRE library, the macro PCRE_CALL_CONVENTION is present in all the external
+definitions. It can be set externally when compiling (e.g. in CFLAGS). If it is
+not set, it defaults to empty; the default calling convention is then used
+(which is what is wanted most of the time).
+
+
+COMMENTS ABOUT WIN32 BUILDS (see also "BUILDING PCRE WITH CMAKE" below)
+
+There are two ways of building PCRE using the "configure, make, make install"
+paradigm on Windows systems: using MinGW or using Cygwin. These are not at all
+the same thing; they are completely different from each other. There is also
+support for building using CMake, which some users find a more straightforward
+way of building PCRE under Windows. However, the tests are not run
+automatically when CMake is used.
+
+The MinGW home page (http://www.mingw.org/) says this:
+
+  MinGW: A collection of freely available and freely distributable Windows
+  specific header files and import libraries combined with GNU toolsets that
+  allow one to produce native Windows programs that do not rely on any
+  3rd-party C runtime DLLs.
+
+The Cygwin home page (http://www.cygwin.com/) says this:
+
+  Cygwin is a Linux-like environment for Windows. It consists of two parts:
+
+  . A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing
+    substantial Linux API functionality
+
+  . A collection of tools which provide Linux look and feel.
+
+  The Cygwin DLL currently works with all recent, commercially released x86 32
+  bit and 64 bit versions of Windows, with the exception of Windows CE.
+
+On both MinGW and Cygwin, PCRE should build correctly using:
+
+  ./configure && make && make install
+
+This should create two libraries called libpcre and libpcreposix, and, if you
+have enabled building the C++ wrapper, a third one called libpcrecpp. These are
+independent libraries: when you like with libpcreposix or libpcrecpp you must
+also link with libpcre, which contains the basic functions. (Some earlier
+releases of PCRE included the basic libpcre functions in libpcreposix. This no
+longer happens.)
+
+A user submitted a special-purpose patch that makes it easy to create
+"pcre.dll" under mingw32 using the "msys" environment. It provides "pcre.dll"
+as a special target. If you use this target, no other files are built, and in
+particular, the pcretest and pcregrep programs are not built. An example of how
+this might be used is:
+
+  ./configure --enable-utf --disable-cpp CFLAGS="-03 -s"; make pcre.dll
+
+Using Cygwin's compiler generates libraries and executables that depend on
+cygwin1.dll. If a library that is generated this way is distributed,
+cygwin1.dll has to be distributed as well. Since cygwin1.dll is under the GPL
+licence, this forces not only PCRE to be under the GPL, but also the entire
+application. A distributor who wants to keep their own code proprietary must
+purchase an appropriate Cygwin licence.
+
+MinGW has no such restrictions. The MinGW compiler generates a library or
+executable that can run standalone on Windows without any third party dll or
+licensing issues.
+
+But there is more complication:
+
+If a Cygwin user uses the -mno-cygwin Cygwin gcc flag, what that really does is
+to tell Cygwin's gcc to use the MinGW gcc. Cygwin's gcc is only acting as a
+front end to MinGW's gcc (if you install Cygwin's gcc, you get both Cygwin's
+gcc and MinGW's gcc). So, a user can:
+
+. Build native binaries by using MinGW or by getting Cygwin and using
+  -mno-cygwin.
+
+. Build binaries that depend on cygwin1.dll by using Cygwin with the normal
+  compiler flags.
+
+The test files that are supplied with PCRE are in Unix format, with LF
+characters as line terminators. It may be necessary to change the line
+terminators in order to get some of the tests to work. We hope to improve
+things in this area in future.
+
+
+BUILDING PCRE ON WINDOWS WITH CMAKE
+
+CMake is an alternative build facility that can be used instead of the
+traditional Unix "configure". CMake version 2.4.7 supports Borland makefiles,
+MinGW makefiles, MSYS makefiles, NMake makefiles, UNIX makefiles, Visual Studio
+6, Visual Studio 7, Visual Studio 8, and Watcom W8. The following instructions
+were contributed by a PCRE user.
+
+1.  Download CMake 2.4.7 or above from http://www.cmake.org/, install and ensure
+    that cmake\bin is on your path.
+
+2.  Unzip (retaining folder structure) the PCRE source tree into a source
+    directory such as C:\pcre.
+
+3.  Create a new, empty build directory: C:\pcre\build\
+
+4.  Run CMakeSetup from the Shell envirornment of your build tool, e.g., Msys
+    for Msys/MinGW or Visual Studio Command Prompt for VC/VC++
+
+5.  Enter C:\pcre\pcre-xx and C:\pcre\build for the source and build
+    directories, respectively
+
+6.  Hit the "Configure" button.
+
+7.  Select the particular IDE / build tool that you are using (Visual Studio,
+    MSYS makefiles, MinGW makefiles, etc.)
+
+8.  The GUI will then list several configuration options. This is where you can
+    enable UTF-8 support, etc.
+
+9.  Hit "Configure" again. The adjacent "OK" button should now be active.
+
+10. Hit "OK".
+
+11. The build directory should now contain a usable build system, be it a
+    solution file for Visual Studio, makefiles for MinGW, etc.
+
+
+USE OF RELATIVE PATHS WITH CMAKE ON WINDOWS
+
+A PCRE user comments as follows:
+
+I thought that others may want to know the current state of
+CMAKE_USE_RELATIVE_PATHS support on Windows.
+
+Here it is:
+-- AdditionalIncludeDirectories is only partially modified (only the
+first path - see below)
+-- Only some of the contained file paths are modified - shown below for
+pcre.vcproj
+-- It properly modifies
+
+I am sure CMake people can fix that if they want to. Until then one will
+need to replace existing absolute paths in project files with relative
+paths manually (e.g. from VS) - relative to project file location. I did
+just that before being told to try CMAKE_USE_RELATIVE_PATHS. Not a big
+deal.
+
+AdditionalIncludeDirectories="E:\builds\pcre\build;E:\builds\pcre\pcre-7.5;"
+AdditionalIncludeDirectories=".;E:\builds\pcre\pcre-7.5;"
+
+RelativePath="pcre.h">
+RelativePath="pcre_chartables.c">
+RelativePath="pcre_chartables.c.rule">
+
+
+TESTING WITH RUNTEST.BAT
+
+1. Copy RunTest.bat into the directory where pcretest.exe has been created.
+
+2. Edit RunTest.bat and insert a line that indentifies the relative location of
+   the pcre source, e.g.:
+
+   set srcdir=..\pcre-7.4-RC3
+
+3. Run RunTest.bat from a command shell environment. Test outputs will
+   automatically be compared to expected results, and discrepancies will
+   identified in the console output.
+
+4. To test pcrecpp, run pcrecpp_unittest.exe, pcre_stringpiece_unittest.exe and
+   pcre_scanner_unittest.exe.
+
+
+BUILDING UNDER WINDOWS WITH BCC5.5
+
+Michael Roy sent these comments about building PCRE under Windows with BCC5.5:
+
+  Some of the core BCC libraries have a version of PCRE from 1998 built in,
+  which can lead to pcre_exec() giving an erroneous PCRE_ERROR_NULL from a
+  version mismatch. I'm including an easy workaround below, if you'd like to
+  include it in the non-unix instructions:
+
+  When linking a project with BCC5.5, pcre.lib must be included before any of
+  the libraries cw32.lib, cw32i.lib, cw32mt.lib, and cw32mti.lib on the command
+  line.
+
+
+BUILDING PCRE ON OPENVMS
+
+Dan Mooney sent the following comments about building PCRE on OpenVMS. They
+relate to an older version of PCRE that used fewer source files, so the exact
+commands will need changing. See the current list of source files above.
+
+"It was quite easy to compile and link the library. I don't have a formal
+make file but the attached file [reproduced below] contains the OpenVMS DCL
+commands I used to build the library. I had to add #define
+POSIX_MALLOC_THRESHOLD 10 to pcre.h since it was not defined anywhere.
+
+The library was built on:
+O/S: HP OpenVMS v7.3-1
+Compiler: Compaq C v6.5-001-48BCD
+Linker: vA13-01
+
+The test results did not match 100% due to the issues you mention in your
+documentation regarding isprint(), iscntrl(), isgraph() and ispunct(). I
+modified some of the character tables temporarily and was able to get the
+results to match. Tests using the fr locale did not match since I don't have
+that locale loaded. The study size was always reported to be 3 less than the
+value in the standard test output files."
+
+=========================
+$! This DCL procedure builds PCRE on OpenVMS
+$!
+$! I followed the instructions in the non-unix-use file in the distribution.
+$!
+$ COMPILE == "CC/LIST/NOMEMBER_ALIGNMENT/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES
+$ COMPILE DFTABLES.C
+$ LINK/EXE=DFTABLES.EXE DFTABLES.OBJ
+$ RUN DFTABLES.EXE/OUTPUT=CHARTABLES.C
+$ COMPILE MAKETABLES.C
+$ COMPILE GET.C
+$ COMPILE STUDY.C
+$! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
+$! did not seem to be defined anywhere.
+$! I edited pcre.h and added #DEFINE SUPPORT_UTF8 to enable UTF8 support.
+$ COMPILE PCRE.C
+$ LIB/CREATE PCRE MAKETABLES.OBJ, GET.OBJ, STUDY.OBJ, PCRE.OBJ
+$! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
+$! did not seem to be defined anywhere.
+$ COMPILE PCREPOSIX.C
+$ LIB/CREATE PCREPOSIX PCREPOSIX.OBJ
+$ COMPILE PCRETEST.C
+$ LINK/EXE=PCRETEST.EXE PCRETEST.OBJ, PCRE/LIB, PCREPOSIX/LIB
+$! C programs that want access to command line arguments must be
+$! defined as a symbol
+$ PCRETEST :== "$ SYS$ROADSUSERS:[DMOONEY.REGEXP]PCRETEST.EXE"
+$! Arguments must be enclosed in quotes.
+$ PCRETEST "-C"
+$! Test results:
+$!
+$!   The test results did not match 100%. The functions isprint(), iscntrl(),
+$!   isgraph() and ispunct() on OpenVMS must not produce the same results
+$!   as the system that built the test output files provided with the
+$!   distribution.
+$!
+$!   The study size did not match and was always 3 less on OpenVMS.
+$!
+$!   Locale could not be set to fr
+$!
+=========================
+
+Last Updated: 05 September 2008
+****
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/PrepareRelease	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,214 @@
+#/bin/sh
+
+# Script to prepare the files for building a PCRE release. It does some
+# processing of the documentation, detrails files, and creates pcre.h.generic
+# and config.h.generic (for use by builders who can't run ./configure).
+
+# You must run this script before runnning "make dist". It makes use of the
+# following files:
+
+# 132html     A Perl script that converts a .1 or .3 man page into HTML. It
+#             is called from MakeRelease. It "knows" the relevant troff
+#             constructs that are used in the PCRE man pages.
+
+# CleanTxt    A Perl script that cleans up the output of "nroff -man" by
+#             removing backspaces and other redundant text so as to produce
+#             a readable .txt file.
+
+# Detrail     A Perl script that removes trailing spaces from files.
+
+# doc/index.html.src
+#             A file that is copied as index.html into the doc/html directory
+#             when the HTML documentation is built. It works like this so that
+#             doc/html can be deleted and re-created from scratch.
+
+
+# First, sort out the documentation
+
+cd doc
+echo Processing documentation
+
+# Make Text form of the documentation. It needs some mangling to make it
+# tidy for online reading. Concatenate all the .3 stuff, but omit the
+# individual function pages.
+
+cat <<End >pcre.txt
+-----------------------------------------------------------------------------
+This file contains a concatenation of the PCRE man pages, converted to plain
+text format for ease of searching with a text editor, or for use on systems
+that do not have a man page processor. The small individual files that give
+synopses of each function in the library have not been included. There are
+separate text files for the pcregrep and pcretest commands.
+-----------------------------------------------------------------------------
+
+
+End
+
+echo "Making pcre.txt"
+for file in pcre pcrebuild pcrematching pcreapi pcrecallout pcrecompat \
+            pcrepattern pcresyntax pcrepartial pcreprecompile \
+            pcreperform pcreposix pcrecpp pcresample pcrestack ; do
+  echo "  Processing $file.3"
+  nroff -c -man $file.3 >$file.rawtxt
+  ../CleanTxt <$file.rawtxt >>pcre.txt
+  /bin/rm $file.rawtxt
+  echo "------------------------------------------------------------------------------" >>pcre.txt
+  if [ "$file" != "pcresample" ] ; then
+    echo " " >>pcre.txt
+    echo " " >>pcre.txt
+  fi
+done
+
+# The three commands
+for file in pcretest pcregrep pcre-config ; do
+  echo Making $file.txt
+  nroff -c -man $file.1 >$file.rawtxt
+  ../CleanTxt <$file.rawtxt >$file.txt
+  /bin/rm $file.rawtxt
+done
+
+
+# Make HTML form of the documentation.
+
+echo "Making HTML documentation"
+/bin/rm html/*
+cp index.html.src html/index.html
+
+for file in *.1 ; do
+  base=`basename $file .1`
+  echo "  Making $base.html"
+  ../132html -toc $base <$file >html/$base.html
+done
+
+# Exclude table of contents for function summaries. It seems that expr
+# forces an anchored regex. Also exclude them for small pages that have
+# only one section.
+for file in *.3 ; do
+  base=`basename $file .3`
+  toc=-toc
+  if [ `expr $base : '.*_'` -ne 0 ] ; then toc="" ; fi
+  if [ "$base" = "pcresample" ] || \
+     [ "$base" = "pcrestack" ]  || \
+     [ "$base" = "pcrecompat" ] || \
+     [ "$base" = "pcreperform" ] ; then
+    toc=""
+  fi
+  echo "  Making $base.html"
+  ../132html $toc $base <$file >html/$base.html
+  if [ $? != 0 ] ; then exit 1; fi
+done
+
+# End of documentation processing
+
+cd ..
+echo Documentation done
+
+# These files are detrailed; do not detrail the test data because there may be
+# significant trailing spaces. The configure files are also omitted from the
+# detrailing.
+
+files="\
+  Makefile.am \
+  Makefile.in \
+  configure.ac \
+  README \
+  LICENCE \
+  COPYING \
+  AUTHORS \
+  NEWS \
+  NON-UNIX-USE \
+  INSTALL \
+  132html \
+  CleanTxt \
+  Detrail \
+  ChangeLog \
+  CMakeLists.txt \
+  RunGrepTest \
+  RunTest \
+  RunTest.bat \
+  pcre-config.in \
+  libpcre.pc.in \
+  libpcrecpp.pc.in \
+  config.h.in \
+  pcre_printint.src \
+  pcre_chartables.c.dist \
+  pcredemo.c \
+  pcregrep.c \
+  pcretest.c \
+  dftables.c \
+  pcreposix.c \
+  pcreposix.h \
+  pcre.h.in \
+  pcre_internal.h
+  pcre_compile.c \
+  pcre_config.c \
+  pcre_dfa_exec.c \
+  pcre_exec.c \
+  pcre_fullinfo.c \
+  pcre_get.c \
+  pcre_globals.c \
+  pcre_info.c \
+  pcre_maketables.c \
+  pcre_newline.c \
+  pcre_ord2utf8.c \
+  pcre_refcount.c \
+  pcre_study.c \
+  pcre_tables.c \
+  pcre_try_flipped.c \
+  pcre_ucp_searchfuncs.c \
+  pcre_valid_utf8.c \
+  pcre_version.c \
+  pcre_xclass.c \
+  pcre_scanner.cc \
+  pcre_scanner.h \
+  pcre_scanner_unittest.cc \
+  pcrecpp.cc \
+  pcrecpp.h \
+  pcrecpparg.h.in \
+  pcrecpp_unittest.cc \
+  pcre_stringpiece.cc \
+  pcre_stringpiece.h.in \
+  pcre_stringpiece_unittest.cc \
+  perltest.pl \
+  ucp.h \
+  ucpinternal.h \
+  ucptable.h \
+  makevp.bat \
+  pcre.def \
+  libpcre.def \
+  libpcreposix.def"
+
+echo Detrailing
+./Detrail $files doc/p* doc/html/*
+
+echo Doing basic configure to get default pcre.h and config.h
+# This is in case the caller has set aliases (as I do - PH)
+unset cp ls mv rm
+./configure >/dev/null
+
+echo Converting pcre.h and config.h to generic forms
+cp -f pcre.h pcre.h.generic
+
+perl <<'END'
+  open(IN, "<config.h") || die "Can't open config.h: $!\n";
+  open(OUT, ">config.h.generic") || die "Can't open config.h.generic: $!\n";
+  while (<IN>)
+    {
+    if (/^#define\s(?!PACKAGE)(\w+)/)
+      {
+      print OUT "#ifndef $1\n";
+      print OUT;
+      print OUT "#endif\n";
+      }
+    else
+      {
+      print OUT;
+      }
+    }
+  close IN;
+  close OUT;
+END
+
+echo Done
+
+#End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/README	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,756 @@
+README file for PCRE (Perl-compatible regular expression library)
+-----------------------------------------------------------------
+
+The latest release of PCRE is always available in three alternative formats
+from:
+
+  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xxx.tar.gz
+  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xxx.tar.bz2
+  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xxx.zip
+
+There is a mailing list for discussion about the development of PCRE at
+
+  pcre-dev@exim.org
+
+Please read the NEWS file if you are upgrading from a previous release.
+The contents of this README file are:
+
+  The PCRE APIs
+  Documentation for PCRE
+  Contributions by users of PCRE
+  Building PCRE on non-Unix systems
+  Building PCRE on Unix-like systems
+  Retrieving configuration information on Unix-like systems
+  Shared libraries on Unix-like systems
+  Cross-compiling on Unix-like systems
+  Using HP's ANSI C++ compiler (aCC)
+  Making new tarballs
+  Testing PCRE
+  Character tables
+  File manifest
+
+
+The PCRE APIs
+-------------
+
+PCRE is written in C, and it has its own API. The distribution also includes a
+set of C++ wrapper functions (see the pcrecpp man page for details), courtesy
+of Google Inc.
+
+In addition, there is a set of C wrapper functions that are based on the POSIX
+regular expression API (see the pcreposix man page). These end up in the
+library called libpcreposix. Note that this just provides a POSIX calling
+interface to PCRE; the regular expressions themselves still follow Perl syntax
+and semantics. The POSIX API is restricted, and does not give full access to
+all of PCRE's facilities.
+
+The header file for the POSIX-style functions is called pcreposix.h. The
+official POSIX name is regex.h, but I did not want to risk possible problems
+with existing files of that name by distributing it that way. To use PCRE with
+an existing program that uses the POSIX API, pcreposix.h will have to be
+renamed or pointed at by a link.
+
+If you are using the POSIX interface to PCRE and there is already a POSIX regex
+library installed on your system, as well as worrying about the regex.h header
+file (as mentioned above), you must also take care when linking programs to
+ensure that they link with PCRE's libpcreposix library. Otherwise they may pick
+up the POSIX functions of the same name from the other library.
+
+One way of avoiding this confusion is to compile PCRE with the addition of
+-Dregcomp=PCREregcomp (and similarly for the other POSIX functions) to the
+compiler flags (CFLAGS if you are using "configure" -- see below). This has the
+effect of renaming the functions so that the names no longer clash. Of course,
+you have to do the same thing for your applications, or write them using the
+new names.
+
+
+Documentation for PCRE
+----------------------
+
+If you install PCRE in the normal way on a Unix-like system, you will end up
+with a set of man pages whose names all start with "pcre". The one that is just
+called "pcre" lists all the others. In addition to these man pages, the PCRE
+documentation is supplied in two other forms:
+
+  1. There are files called doc/pcre.txt, doc/pcregrep.txt, and
+     doc/pcretest.txt in the source distribution. The first of these is a
+     concatenation of the text forms of all the section 3 man pages except
+     those that summarize individual functions. The other two are the text
+     forms of the section 1 man pages for the pcregrep and pcretest commands.
+     These text forms are provided for ease of scanning with text editors or
+     similar tools. They are installed in <prefix>/share/doc/pcre, where
+     <prefix> is the installation prefix (defaulting to /usr/local).
+
+  2. A set of files containing all the documentation in HTML form, hyperlinked
+     in various ways, and rooted in a file called index.html, is distributed in
+     doc/html and installed in <prefix>/share/doc/pcre/html.
+
+
+Contributions by users of PCRE
+------------------------------
+
+You can find contributions from PCRE users in the directory
+
+  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib
+
+There is a README file giving brief descriptions of what they are. Some are
+complete in themselves; others are pointers to URLs containing relevant files.
+Some of this material is likely to be well out-of-date. Several of the earlier
+contributions provided support for compiling PCRE on various flavours of
+Windows (I myself do not use Windows). Nowadays there is more Windows support
+in the standard distribution, so these contibutions have been archived.
+
+
+Building PCRE on non-Unix systems
+---------------------------------
+
+For a non-Unix system, please read the comments in the file NON-UNIX-USE,
+though if your system supports the use of "configure" and "make" you may be
+able to build PCRE in the same way as for Unix-like systems. PCRE can also be
+configured in many platform environments using the GUI facility of CMake's
+CMakeSetup. It creates Makefiles, solution files, etc.
+
+PCRE has been compiled on many different operating systems. It should be
+straightforward to build PCRE on any system that has a Standard C compiler and
+library, because it uses only Standard C functions.
+
+
+Building PCRE on Unix-like systems
+----------------------------------
+
+If you are using HP's ANSI C++ compiler (aCC), please see the special note
+in the section entitled "Using HP's ANSI C++ compiler (aCC)" below.
+
+The following instructions assume the use of the widely used "configure, make,
+make install" process. There is also support for CMake in the PCRE
+distribution; there are some comments about using CMake in the NON-UNIX-USE
+file, though it can also be used in Unix-like systems.
+
+To build PCRE on a Unix-like system, first run the "configure" command from the
+PCRE distribution directory, with your current directory set to the directory
+where you want the files to be created. This command is a standard GNU
+"autoconf" configuration script, for which generic instructions are supplied in
+the file INSTALL.
+
+Most commonly, people build PCRE within its own distribution directory, and in
+this case, on many systems, just running "./configure" is sufficient. However,
+the usual methods of changing standard defaults are available. For example:
+
+CFLAGS='-O2 -Wall' ./configure --prefix=/opt/local
+
+specifies that the C compiler should be run with the flags '-O2 -Wall' instead
+of the default, and that "make install" should install PCRE under /opt/local
+instead of the default /usr/local.
+
+If you want to build in a different directory, just run "configure" with that
+directory as current. For example, suppose you have unpacked the PCRE source
+into /source/pcre/pcre-xxx, but you want to build it in /build/pcre/pcre-xxx:
+
+cd /build/pcre/pcre-xxx
+/source/pcre/pcre-xxx/configure
+
+PCRE is written in C and is normally compiled as a C library. However, it is
+possible to build it as a C++ library, though the provided building apparatus
+does not have any features to support this.
+
+There are some optional features that can be included or omitted from the PCRE
+library. You can read more about them in the pcrebuild man page.
+
+. If you want to suppress the building of the C++ wrapper library, you can add
+  --disable-cpp to the "configure" command. Otherwise, when "configure" is run,
+  it will try to find a C++ compiler and C++ header files, and if it succeeds,
+  it will try to build the C++ wrapper.
+
+. If you want to make use of the support for UTF-8 character strings in PCRE,
+  you must add --enable-utf8 to the "configure" command. Without it, the code
+  for handling UTF-8 is not included in the library. (Even when included, it
+  still has to be enabled by an option at run time.)
+
+. If, in addition to support for UTF-8 character strings, you want to include
+  support for the \P, \p, and \X sequences that recognize Unicode character
+  properties, you must add --enable-unicode-properties to the "configure"
+  command. This adds about 30K to the size of the library (in the form of a
+  property table); only the basic two-letter properties such as Lu are
+  supported.
+
+. You can build PCRE to recognize either CR or LF or the sequence CRLF or any
+  of the preceding, or any of the Unicode newline sequences as indicating the
+  end of a line. Whatever you specify at build time is the default; the caller
+  of PCRE can change the selection at run time. The default newline indicator
+  is a single LF character (the Unix standard). You can specify the default
+  newline indicator by adding --enable-newline-is-cr or --enable-newline-is-lf
+  or --enable-newline-is-crlf or --enable-newline-is-anycrlf or
+  --enable-newline-is-any to the "configure" command, respectively.
+
+  If you specify --enable-newline-is-cr or --enable-newline-is-crlf, some of
+  the standard tests will fail, because the lines in the test files end with
+  LF. Even if the files are edited to change the line endings, there are likely
+  to be some failures. With --enable-newline-is-anycrlf or
+  --enable-newline-is-any, many tests should succeed, but there may be some
+  failures.
+
+. By default, the sequence \R in a pattern matches any Unicode line ending
+  sequence. This is independent of the option specifying what PCRE considers to
+  be the end of a line (see above). However, the caller of PCRE can restrict \R
+  to match only CR, LF, or CRLF. You can make this the default by adding
+  --enable-bsr-anycrlf to the "configure" command (bsr = "backslash R").
+
+. When called via the POSIX interface, PCRE uses malloc() to get additional
+  storage for processing capturing parentheses if there are more than 10 of
+  them in a pattern. You can increase this threshold by setting, for example,
+
+  --with-posix-malloc-threshold=20
+
+  on the "configure" command.
+
+. PCRE has a counter that can be set to limit the amount of resources it uses.
+  If the limit is exceeded during a match, the match fails. The default is ten
+  million. You can change the default by setting, for example,
+
+  --with-match-limit=500000
+
+  on the "configure" command. This is just the default; individual calls to
+  pcre_exec() can supply their own value. There is more discussion on the
+  pcreapi man page.
+
+. There is a separate counter that limits the depth of recursive function calls
+  during a matching process. This also has a default of ten million, which is
+  essentially "unlimited". You can change the default by setting, for example,
+
+  --with-match-limit-recursion=500000
+
+  Recursive function calls use up the runtime stack; running out of stack can
+  cause programs to crash in strange ways. There is a discussion about stack
+  sizes in the pcrestack man page.
+
+. The default maximum compiled pattern size is around 64K. You can increase
+  this by adding --with-link-size=3 to the "configure" command. You can
+  increase it even more by setting --with-link-size=4, but this is unlikely
+  ever to be necessary. Increasing the internal link size will reduce
+  performance.
+
+. You can build PCRE so that its internal match() function that is called from
+  pcre_exec() does not call itself recursively. Instead, it uses memory blocks
+  obtained from the heap via the special functions pcre_stack_malloc() and
+  pcre_stack_free() to save data that would otherwise be saved on the stack. To
+  build PCRE like this, use
+
+  --disable-stack-for-recursion
+
+  on the "configure" command. PCRE runs more slowly in this mode, but it may be
+  necessary in environments with limited stack sizes. This applies only to the
+  pcre_exec() function; it does not apply to pcre_dfa_exec(), which does not
+  use deeply nested recursion. There is a discussion about stack sizes in the
+  pcrestack man page.
+
+. For speed, PCRE uses four tables for manipulating and identifying characters
+  whose code point values are less than 256. By default, it uses a set of
+  tables for ASCII encoding that is part of the distribution. If you specify
+
+  --enable-rebuild-chartables
+
+  a program called dftables is compiled and run in the default C locale when
+  you obey "make". It builds a source file called pcre_chartables.c. If you do
+  not specify this option, pcre_chartables.c is created as a copy of
+  pcre_chartables.c.dist. See "Character tables" below for further information.
+
+. It is possible to compile PCRE for use on systems that use EBCDIC as their
+  default character code (as opposed to ASCII) by specifying
+
+  --enable-ebcdic
+
+  This automatically implies --enable-rebuild-chartables (see above).
+
+. It is possible to compile pcregrep to use libz and/or libbz2, in order to
+  read .gz and .bz2 files (respectively), by specifying one or both of
+
+  --enable-pcregrep-libz
+  --enable-pcregrep-libbz2
+
+  Of course, the relevant libraries must be installed on your system.
+
+. It is possible to compile pcretest so that it links with the libreadline
+  library, by specifying
+
+  --enable-pcretest-libreadline
+
+  If this is done, when pcretest's input is from a terminal, it reads it using
+  the readline() function. This provides line-editing and history facilities.
+  Note that libreadline is GPL-licenced, so if you distribute a binary of
+  pcretest linked in this way, there may be licensing issues.
+
+  Setting this option causes the -lreadline option to be added to the pcretest
+  build. In many operating environments with a sytem-installed readline
+  library this is sufficient. However, in some environments (e.g. if an
+  unmodified distribution version of readline is in use), it may be necessary
+  to specify something like LIBS="-lncurses" as well. This is because, to quote
+  the readline INSTALL, "Readline uses the termcap functions, but does not link
+  with the termcap or curses library itself, allowing applications which link
+  with readline the to choose an appropriate library."
+
+The "configure" script builds the following files for the basic C library:
+
+. Makefile is the makefile that builds the library
+. config.h contains build-time configuration options for the library
+. pcre.h is the public PCRE header file
+. pcre-config is a script that shows the settings of "configure" options
+. libpcre.pc is data for the pkg-config command
+. libtool is a script that builds shared and/or static libraries
+. RunTest is a script for running tests on the basic C library
+. RunGrepTest is a script for running tests on the pcregrep command
+
+Versions of config.h and pcre.h are distributed in the PCRE tarballs under
+the names config.h.generic and pcre.h.generic. These are provided for the
+benefit of those who have to built PCRE without the benefit of "configure". If
+you use "configure", the .generic versions are not used.
+
+If a C++ compiler is found, the following files are also built:
+
+. libpcrecpp.pc is data for the pkg-config command
+. pcrecpparg.h is a header file for programs that call PCRE via the C++ wrapper
+. pcre_stringpiece.h is the header for the C++ "stringpiece" functions
+
+The "configure" script also creates config.status, which is an executable
+script that can be run to recreate the configuration, and config.log, which
+contains compiler output from tests that "configure" runs.
+
+Once "configure" has run, you can run "make". It builds two libraries, called
+libpcre and libpcreposix, a test program called pcretest, and the pcregrep
+command. If a C++ compiler was found on your system, "make" also builds the C++
+wrapper library, which is called libpcrecpp, and some test programs called
+pcrecpp_unittest, pcre_scanner_unittest, and pcre_stringpiece_unittest.
+Building the C++ wrapper can be disabled by adding --disable-cpp to the
+"configure" command.
+
+The command "make check" runs all the appropriate tests. Details of the PCRE
+tests are given below in a separate section of this document.
+
+You can use "make install" to install PCRE into live directories on your
+system. The following are installed (file names are all relative to the
+<prefix> that is set when "configure" is run):
+
+  Commands (bin):
+    pcretest
+    pcregrep
+    pcre-config
+
+  Libraries (lib):
+    libpcre
+    libpcreposix
+    libpcrecpp (if C++ support is enabled)
+
+  Configuration information (lib/pkgconfig):
+    libpcre.pc
+    libpcrecpp.pc (if C++ support is enabled)
+
+  Header files (include):
+    pcre.h
+    pcreposix.h
+    pcre_scanner.h      )
+    pcre_stringpiece.h  ) if C++ support is enabled
+    pcrecpp.h           )
+    pcrecpparg.h        )
+
+  Man pages (share/man/man{1,3}):
+    pcregrep.1
+    pcretest.1
+    pcre.3
+    pcre*.3 (lots more pages, all starting "pcre")
+
+  HTML documentation (share/doc/pcre/html):
+    index.html
+    *.html (lots more pages, hyperlinked from index.html)
+
+  Text file documentation (share/doc/pcre):
+    AUTHORS
+    COPYING
+    ChangeLog
+    LICENCE
+    NEWS
+    README
+    pcre.txt       (a concatenation of the man(3) pages)
+    pcretest.txt   the pcretest man page
+    pcregrep.txt   the pcregrep man page
+
+If you want to remove PCRE from your system, you can run "make uninstall".
+This removes all the files that "make install" installed. However, it does not
+remove any directories, because these are often shared with other programs.
+
+
+Retrieving configuration information on Unix-like systems
+---------------------------------------------------------
+
+Running "make install" installs the command pcre-config, which can be used to
+recall information about the PCRE configuration and installation. For example:
+
+  pcre-config --version
+
+prints the version number, and
+
+  pcre-config --libs
+
+outputs information about where the library is installed. This command can be
+included in makefiles for programs that use PCRE, saving the programmer from
+having to remember too many details.
+
+The pkg-config command is another system for saving and retrieving information
+about installed libraries. Instead of separate commands for each library, a
+single command is used. For example:
+
+  pkg-config --cflags pcre
+
+The data is held in *.pc files that are installed in a directory called
+<prefix>/lib/pkgconfig.
+
+
+Shared libraries on Unix-like systems
+-------------------------------------
+
+The default distribution builds PCRE as shared libraries and static libraries,
+as long as the operating system supports shared libraries. Shared library
+support relies on the "libtool" script which is built as part of the
+"configure" process.
+
+The libtool script is used to compile and link both shared and static
+libraries. They are placed in a subdirectory called .libs when they are newly
+built. The programs pcretest and pcregrep are built to use these uninstalled
+libraries (by means of wrapper scripts in the case of shared libraries). When
+you use "make install" to install shared libraries, pcregrep and pcretest are
+automatically re-built to use the newly installed shared libraries before being
+installed themselves. However, the versions left in the build directory still
+use the uninstalled libraries.
+
+To build PCRE using static libraries only you must use --disable-shared when
+configuring it. For example:
+
+./configure --prefix=/usr/gnu --disable-shared
+
+Then run "make" in the usual way. Similarly, you can use --disable-static to
+build only shared libraries.
+
+
+Cross-compiling on Unix-like systems
+------------------------------------
+
+You can specify CC and CFLAGS in the normal way to the "configure" command, in
+order to cross-compile PCRE for some other host. However, you should NOT
+specify --enable-rebuild-chartables, because if you do, the dftables.c source
+file is compiled and run on the local host, in order to generate the inbuilt
+character tables (the pcre_chartables.c file). This will probably not work,
+because dftables.c needs to be compiled with the local compiler, not the cross
+compiler.
+
+When --enable-rebuild-chartables is not specified, pcre_chartables.c is created
+by making a copy of pcre_chartables.c.dist, which is a default set of tables
+that assumes ASCII code. Cross-compiling with the default tables should not be
+a problem.
+
+If you need to modify the character tables when cross-compiling, you should
+move pcre_chartables.c.dist out of the way, then compile dftables.c by hand and
+run it on the local host to make a new version of pcre_chartables.c.dist.
+Then when you cross-compile PCRE this new version of the tables will be used.
+
+
+Using HP's ANSI C++ compiler (aCC)
+----------------------------------
+
+Unless C++ support is disabled by specifying the "--disable-cpp" option of the
+"configure" script, you must include the "-AA" option in the CXXFLAGS
+environment variable in order for the C++ components to compile correctly.
+
+Also, note that the aCC compiler on PA-RISC platforms may have a defect whereby
+needed libraries fail to get included when specifying the "-AA" compiler
+option. If you experience unresolved symbols when linking the C++ programs,
+use the workaround of specifying the following environment variable prior to
+running the "configure" script:
+
+  CXXLDFLAGS="-lstd_v2 -lCsup_v2"
+
+
+Making new tarballs
+-------------------
+
+The command "make dist" creates three PCRE tarballs, in tar.gz, tar.bz2, and
+zip formats. The command "make distcheck" does the same, but then does a trial
+build of the new distribution to ensure that it works.
+
+If you have modified any of the man page sources in the doc directory, you
+should first run the PrepareRelease script before making a distribution. This
+script creates the .txt and HTML forms of the documentation from the man pages.
+
+
+Testing PCRE
+------------
+
+To test the basic PCRE library on a Unix system, run the RunTest script that is
+created by the configuring process. There is also a script called RunGrepTest
+that tests the options of the pcregrep command. If the C++ wrapper library is
+built, three test programs called pcrecpp_unittest, pcre_scanner_unittest, and
+pcre_stringpiece_unittest are also built.
+
+Both the scripts and all the program tests are run if you obey "make check" or
+"make test". For other systems, see the instructions in NON-UNIX-USE.
+
+The RunTest script runs the pcretest test program (which is documented in its
+own man page) on each of the testinput files in the testdata directory in
+turn, and compares the output with the contents of the corresponding testoutput
+files. A file called testtry is used to hold the main output from pcretest
+(testsavedregex is also used as a working file). To run pcretest on just one of
+the test files, give its number as an argument to RunTest, for example:
+
+  RunTest 2
+
+The first test file can also be fed directly into the perltest.pl script to
+check that Perl gives the same results. The only difference you should see is
+in the first few lines, where the Perl version is given instead of the PCRE
+version.
+
+The second set of tests check pcre_fullinfo(), pcre_info(), pcre_study(),
+pcre_copy_substring(), pcre_get_substring(), pcre_get_substring_list(), error
+detection, and run-time flags that are specific to PCRE, as well as the POSIX
+wrapper API. It also uses the debugging flags to check some of the internals of
+pcre_compile().
+
+If you build PCRE with a locale setting that is not the standard C locale, the
+character tables may be different (see next paragraph). In some cases, this may
+cause failures in the second set of tests. For example, in a locale where the
+isprint() function yields TRUE for characters in the range 128-255, the use of
+[:isascii:] inside a character class defines a different set of characters, and
+this shows up in this test as a difference in the compiled code, which is being
+listed for checking. Where the comparison test output contains [\x00-\x7f] the
+test will contain [\x00-\xff], and similarly in some other cases. This is not a
+bug in PCRE.
+
+The third set of tests checks pcre_maketables(), the facility for building a
+set of character tables for a specific locale and using them instead of the
+default tables. The tests make use of the "fr_FR" (French) locale. Before
+running the test, the script checks for the presence of this locale by running
+the "locale" command. If that command fails, or if it doesn't include "fr_FR"
+in the list of available locales, the third test cannot be run, and a comment
+is output to say why. If running this test produces instances of the error
+
+  ** Failed to set locale "fr_FR"
+
+in the comparison output, it means that locale is not available on your system,
+despite being listed by "locale". This does not mean that PCRE is broken.
+
+[If you are trying to run this test on Windows, you may be able to get it to
+work by changing "fr_FR" to "french" everywhere it occurs. Alternatively, use
+RunTest.bat. The version of RunTest.bat included with PCRE 7.4 and above uses
+Windows versions of test 2. More info on using RunTest.bat is included in the
+document entitled NON-UNIX-USE.]
+
+The fourth test checks the UTF-8 support. It is not run automatically unless
+PCRE is built with UTF-8 support. To do this you must set --enable-utf8 when
+running "configure". This file can be also fed directly to the perltest script,
+provided you are running Perl 5.8 or higher. (For Perl 5.6, a small patch,
+commented in the script, can be be used.)
+
+The fifth test checks error handling with UTF-8 encoding, and internal UTF-8
+features of PCRE that are not relevant to Perl.
+
+The sixth test checks the support for Unicode character properties. It it not
+run automatically unless PCRE is built with Unicode property support. To to
+this you must set --enable-unicode-properties when running "configure".
+
+The seventh, eighth, and ninth tests check the pcre_dfa_exec() alternative
+matching function, in non-UTF-8 mode, UTF-8 mode, and UTF-8 mode with Unicode
+property support, respectively. The eighth and ninth tests are not run
+automatically unless PCRE is build with the relevant support.
+
+
+Character tables
+----------------
+
+For speed, PCRE uses four tables for manipulating and identifying characters
+whose code point values are less than 256. The final argument of the
+pcre_compile() function is a pointer to a block of memory containing the
+concatenated tables. A call to pcre_maketables() can be used to generate a set
+of tables in the current locale. If the final argument for pcre_compile() is
+passed as NULL, a set of default tables that is built into the binary is used.
+
+The source file called pcre_chartables.c contains the default set of tables. By
+default, this is created as a copy of pcre_chartables.c.dist, which contains
+tables for ASCII coding. However, if --enable-rebuild-chartables is specified
+for ./configure, a different version of pcre_chartables.c is built by the
+program dftables (compiled from dftables.c), which uses the ANSI C character
+handling functions such as isalnum(), isalpha(), isupper(), islower(), etc. to
+build the table sources. This means that the default C locale which is set for
+your system will control the contents of these default tables. You can change
+the default tables by editing pcre_chartables.c and then re-building PCRE. If
+you do this, you should take care to ensure that the file does not get
+automatically re-generated. The best way to do this is to move
+pcre_chartables.c.dist out of the way and replace it with your customized
+tables.
+
+When the dftables program is run as a result of --enable-rebuild-chartables,
+it uses the default C locale that is set on your system. It does not pay
+attention to the LC_xxx environment variables. In other words, it uses the
+system's default locale rather than whatever the compiling user happens to have
+set. If you really do want to build a source set of character tables in a
+locale that is specified by the LC_xxx variables, you can run the dftables
+program by hand with the -L option. For example:
+
+  ./dftables -L pcre_chartables.c.special
+
+The first two 256-byte tables provide lower casing and case flipping functions,
+respectively. The next table consists of three 32-byte bit maps which identify
+digits, "word" characters, and white space, respectively. These are used when
+building 32-byte bit maps that represent character classes for code points less
+than 256.
+
+The final 256-byte table has bits indicating various character types, as
+follows:
+
+    1   white space character
+    2   letter
+    4   decimal digit
+    8   hexadecimal digit
+   16   alphanumeric or '_'
+  128   regular expression metacharacter or binary zero
+
+You should not alter the set of characters that contain the 128 bit, as that
+will cause PCRE to malfunction.
+
+
+File manifest
+-------------
+
+The distribution should contain the following files:
+
+(A) Source files of the PCRE library functions and their headers:
+
+  dftables.c              auxiliary program for building pcre_chartables.c
+                            when --enable-rebuild-chartables is specified
+
+  pcre_chartables.c.dist  a default set of character tables that assume ASCII
+                            coding; used, unless --enable-rebuild-chartables is
+                            specified, by copying to pcre_chartables.c
+
+  pcreposix.c             )
+  pcre_compile.c          )
+  pcre_config.c           )
+  pcre_dfa_exec.c         )
+  pcre_exec.c             )
+  pcre_fullinfo.c         )
+  pcre_get.c              ) sources for the functions in the library,
+  pcre_globals.c          )   and some internal functions that they use
+  pcre_info.c             )
+  pcre_maketables.c       )
+  pcre_newline.c          )
+  pcre_ord2utf8.c         )
+  pcre_refcount.c         )
+  pcre_study.c            )
+  pcre_tables.c           )
+  pcre_try_flipped.c      )
+  pcre_ucd.c              )
+  pcre_valid_utf8.c       )
+  pcre_version.c          )
+  pcre_xclass.c           )
+  pcre_printint.src       ) debugging function that is #included in pcretest,
+                          )   and can also be #included in pcre_compile()
+  pcre.h.in               template for pcre.h when built by "configure"
+  pcreposix.h             header for the external POSIX wrapper API
+  pcre_internal.h         header for internal use
+  ucp.h                   header for Unicode property handling
+
+  config.h.in             template for config.h, which is built by "configure"
+
+  pcrecpp.h               public header file for the C++ wrapper
+  pcrecpparg.h.in         template for another C++ header file
+  pcre_scanner.h          public header file for C++ scanner functions
+  pcrecpp.cc              )
+  pcre_scanner.cc         ) source for the C++ wrapper library
+
+  pcre_stringpiece.h.in   template for pcre_stringpiece.h, the header for the
+                            C++ stringpiece functions
+  pcre_stringpiece.cc     source for the C++ stringpiece functions
+
+(B) Source files for programs that use PCRE:
+
+  pcredemo.c              simple demonstration of coding calls to PCRE
+  pcregrep.c              source of a grep utility that uses PCRE
+  pcretest.c              comprehensive test program
+
+(C) Auxiliary files:
+
+  132html                 script to turn "man" pages into HTML
+  AUTHORS                 information about the author of PCRE
+  ChangeLog               log of changes to the code
+  CleanTxt                script to clean nroff output for txt man pages
+  Detrail                 script to remove trailing spaces
+  HACKING                 some notes about the internals of PCRE
+  INSTALL                 generic installation instructions
+  LICENCE                 conditions for the use of PCRE
+  COPYING                 the same, using GNU's standard name
+  Makefile.in             ) template for Unix Makefile, which is built by
+                          )   "configure"
+  Makefile.am             ) the automake input that was used to create
+                          )   Makefile.in
+  NEWS                    important changes in this release
+  NON-UNIX-USE            notes on building PCRE on non-Unix systems
+  PrepareRelease          script to make preparations for "make dist"
+  README                  this file
+  RunTest                 a Unix shell script for running tests
+  RunGrepTest             a Unix shell script for pcregrep tests
+  aclocal.m4              m4 macros (generated by "aclocal")
+  config.guess            ) files used by libtool,
+  config.sub              )   used only when building a shared library
+  configure               a configuring shell script (built by autoconf)
+  configure.ac            ) the autoconf input that was used to build
+                          )   "configure" and config.h
+  depcomp                 ) script to find program dependencies, generated by
+                          )   automake
+  doc/*.3                 man page sources for the PCRE functions
+  doc/*.1                 man page sources for pcregrep and pcretest
+  doc/index.html.src      the base HTML page
+  doc/html/*              HTML documentation
+  doc/pcre.txt            plain text version of the man pages
+  doc/pcretest.txt        plain text documentation of test program
+  doc/perltest.txt        plain text documentation of Perl test program
+  install-sh              a shell script for installing files
+  libpcre.pc.in           template for libpcre.pc for pkg-config
+  libpcrecpp.pc.in        template for libpcrecpp.pc for pkg-config
+  ltmain.sh               file used to build a libtool script
+  missing                 ) common stub for a few missing GNU programs while
+                          )   installing, generated by automake
+  mkinstalldirs           script for making install directories
+  perltest.pl             Perl test program
+  pcre-config.in          source of script which retains PCRE information
+  pcrecpp_unittest.cc          )
+  pcre_scanner_unittest.cc     ) test programs for the C++ wrapper
+  pcre_stringpiece_unittest.cc )
+  testdata/testinput*     test data for main library tests
+  testdata/testoutput*    expected test results
+  testdata/grep*          input and output for pcregrep tests
+
+(D) Auxiliary files for cmake support
+
+  cmake/COPYING-CMAKE-SCRIPTS
+  cmake/FindPackageHandleStandardArgs.cmake
+  cmake/FindReadline.cmake
+  CMakeLists.txt
+  config-cmake.h.in
+
+(E) Auxiliary files for VPASCAL
+
+  makevp.bat
+  makevp_c.txt
+  makevp_l.txt
+  pcregexp.pas
+
+(F) Auxiliary files for building PCRE "by hand"
+
+  pcre.h.generic          ) a version of the public PCRE header file
+                          )   for use in non-"configure" environments
+  config.h.generic        ) a version of config.h for use in non-"configure"
+                          )   environments
+
+(F) Miscellaneous
+
+  RunTest.bat            a script for running tests under Windows
+
+Philip Hazel
+Email local part: ph10
+Email domain: cam.ac.uk
+Last updated: 05 September 2008
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/RunGrepTest	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,277 @@
+#! /bin/sh
+
+# Run pcregrep tests. The assumption is that the PCRE tests check the library
+# itself. What we are checking here is the file handling and options that are
+# supported by pcregrep.
+
+# Set the C locale, so that sort(1) behaves predictably.
+LC_ALL=C
+export LC_ALL
+
+pcregrep=`pwd`/pcregrep
+
+echo " "
+echo "Testing pcregrep"
+$pcregrep -V
+
+cf="diff -ub"
+valgrind=
+
+while [ $# -gt 0 ] ; do
+  case $1 in
+    valgrind) valgrind="valgrind -q --leak-check=no";;
+    *) echo "Unknown argument $1"; exit 1;;
+  esac
+  shift
+done
+
+# If PCRE has been built in a directory other than the source directory, and
+# this test is being run from "make check" as usual, then $(srcdir) will be
+# set. If not, set it to the current directory. We then arrange to run the
+# pcregrep command in the source directory so that the file names that appear
+# in the output are always the same.
+
+if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then
+  srcdir=.
+fi
+
+# Check for the availability of UTF-8 support
+
+./pcretest -C | ./pcregrep "No UTF-8 support" >/dev/null
+utf8=$?
+
+echo "---------------------------- Test 1 ------------------------------" >testtry
+(cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 2 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep '^PATTERN' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 3 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 4 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -ic PATTERN ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 5 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 6 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 7 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 8 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 9 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
+echo "RC=$?" >>testtry
+
+echo "---------------------------- Test 10 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtry
+echo "RC=$?" >>testtry
+
+echo "---------------------------- Test 11 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -vn pattern ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 12 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -ix pattern ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 13 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 14 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 15 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep 'abc^*' ./testdata/grepinput) 2>>testtry >>testtry
+
+echo "---------------------------- Test 16 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep abc ./testdata/grepinput ./testdata/nonexistfile) 2>>testtry >>testtry
+
+echo "---------------------------- Test 17 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -M 'the\noutput' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 18 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 19 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -Mix 'Pattern' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 20 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 21 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -nA3 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 22 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -nB3 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 23 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -C3 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 24 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -A9 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 25 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -nB9 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 26 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -A9 -B9 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 27 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -A10 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 28 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -nB10 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 29 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -C12 -B10 'four' ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 30 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 31 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 32 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 33 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep 'fox' ./testdata/grepnonexist) >>testtry 2>&1
+echo "RC=$?" >>testtry
+
+echo "---------------------------- Test 34 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -s 'fox' ./testdata/grepnonexist) >>testtry 2>&1
+echo "RC=$?" >>testtry
+
+echo "---------------------------- Test 35 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --exclude_dir='^\.' 'fox' ./testdata) >>testtry
+echo "RC=$?" >>testtry
+
+echo "---------------------------- Test 36 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude 'grepinput$' --exclude_dir='^\.' 'fox' ./testdata | sort) >>testtry
+echo "RC=$?" >>testtry
+
+echo "---------------------------- Test 37 -----------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep  '^(a+)*\d' ./testdata/grepinput) >>testtry 2>teststderr
+echo "RC=$?" >>testtry
+echo "======== STDERR ========" >>testtry
+cat teststderr >>testtry
+
+echo "---------------------------- Test 38 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep '>\x00<' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 39 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -A1 'before the binary zero' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 40 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -B1 'after the binary zero' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 41 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 41 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 42 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -on 'before|zero|after' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 43 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -on -e before -e zero -e after ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 44 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 45 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -e abc -e '(unclosed' ./testdata/grepinput) 2>>testtry >>testtry
+
+echo "---------------------------- Test 46 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -Fx "AB.VE
+elephant" ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 47 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -F "AB.VE
+elephant" ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 48 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -F -e DATA -e "AB.VE
+elephant" ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 49 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtry
+
+echo "---------------------------- Test 50 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep -Mv "brown\sfox" ./testdata/grepinputv) >>testtry
+
+echo "---------------------------- Test 51 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep --colour=always jumps ./testdata/grepinputv) >>testtry
+
+echo "---------------------------- Test 52 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtry
+
+echo "---------------------------- Test 53 ------------------------------" >>testtry
+(cd $srcdir; $valgrind $pcregrep --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtry
+
+# Now compare the results.
+
+$cf $srcdir/testdata/grepoutput testtry
+if [ $? != 0 ] ; then exit 1; fi
+
+
+# These tests require UTF-8 support
+
+if [ $utf8 -ne 0 ] ; then
+  echo "Testing pcregrep UTF-8 features"
+
+  echo "---------------------------- Test U1 ------------------------------" >testtry
+  (cd $srcdir; $valgrind $pcregrep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtry
+
+  echo "---------------------------- Test U2 ------------------------------" >>testtry
+  (cd $srcdir; $valgrind $pcregrep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtry
+
+  $cf $srcdir/testdata/grepoutput8 testtry
+  if [ $? != 0 ] ; then exit 1; fi
+
+else
+  echo "Skipping pcregrep UTF-8 tests: no UTF-8 support in PCRE library"
+fi
+
+
+# We go to some contortions to try to ensure that the tests for the various
+# newline settings will work in environments where the normal newline sequence
+# is not \n. Do not use exported files, whose line endings might be changed.
+# Instead, create an input file using printf so that its contents are exactly
+# what we want. Note the messy fudge to get printf to write a string that
+# starts with a hyphen.
+
+echo "Testing pcregrep newline settings"
+printf "abc\rdef\r\nghi\njkl" >testNinput
+
+printf "%c--------------------------- Test N1 ------------------------------\r\n" - >testtry
+$valgrind $pcregrep -n -N CR "^(abc|def|ghi|jkl)" testNinput >>testtry
+
+printf "%c--------------------------- Test N2 ------------------------------\r\n" - >>testtry
+$valgrind $pcregrep -n --newline=crlf "^(abc|def|ghi|jkl)" testNinput >>testtry
+
+printf "%c--------------------------- Test N3 ------------------------------\r\n" - >>testtry
+pattern=`printf 'def\rjkl'`
+$valgrind $pcregrep -n --newline=cr -F "$pattern" testNinput >>testtry
+
+printf "%c--------------------------- Test N4 ------------------------------\r\n" - >>testtry
+pattern=`printf 'xxx\r\njkl'`
+$valgrind $pcregrep -n --newline=crlf -F "$pattern" testNinput >>testtry
+
+printf "%c--------------------------- Test N5 ------------------------------\r\n" - >>testtry
+$valgrind $pcregrep -n --newline=any "^(abc|def|ghi|jkl)" testNinput >>testtry
+
+printf "%c--------------------------- Test N6 ------------------------------\r\n" - >>testtry
+$valgrind $pcregrep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinput >>testtry
+
+$cf $srcdir/testdata/grepoutputN testtry
+if [ $? != 0 ] ; then exit 1; fi
+
+exit 0
+
+# End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/RunTest	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,292 @@
+#! /bin/sh
+
+# Run PCRE tests.
+
+valgrind=
+
+# Set up a suitable "diff" command for comparison. Some systems
+# have a diff that lacks a -u option. Try to deal with this.
+
+if diff -u /dev/null /dev/null; then cf="diff -u"; else cf="diff"; fi
+
+# Find the test data
+
+testdata=testdata
+if [ -n "$srcdir" -a -d "$srcdir" ] ; then
+  testdata="$srcdir/testdata"
+fi
+
+# Find which optional facilities are available
+
+case `./pcretest -C | ./pcregrep 'Internal link size'` in
+  *2) link_size=2;;
+  *3) link_size=3;;
+  *4) link_size=4;;
+   *) echo "Failed to find internal link size"; exit 1;;
+esac
+
+./pcretest -C | ./pcregrep 'No UTF-8 support' >/dev/null
+utf8=$?
+
+./pcretest -C | ./pcregrep 'No Unicode properties support' >/dev/null
+ucp=$?
+
+# Select which tests to run; for those that are explicitly requested, check
+# that the necessary optional facilities are available.
+
+do1=no
+do2=no
+do3=no
+do4=no
+do5=no
+do6=no
+do7=no
+do8=no
+do9=no
+do10=no
+
+while [ $# -gt 0 ] ; do
+  case $1 in
+    1) do1=yes;;
+    2) do2=yes;;
+    3) do3=yes;;
+    4) do4=yes;;
+    5) do5=yes;;
+    6) do6=yes;;
+    7) do7=yes;;
+    8) do8=yes;;
+    9) do9=yes;;
+   10) do10=yes;;
+   valgrind) valgrind="valgrind -q";;
+    *) echo "Unknown test number $1"; exit 1;;
+  esac
+  shift
+done
+
+if [ $utf8 -eq 0 ] ; then
+  if [ $do4 = yes ] ; then
+    echo "Can't run test 4 because UTF-8 support is not configured"
+    exit 1
+  fi
+  if [ $do5 = yes ] ; then
+    echo "Can't run test 5 because UTF-8 support is not configured"
+    exit 1
+  fi
+  if [ $do8 = yes ] ; then
+    echo "Can't run test 8 because UTF-8 support is not configured"
+    exit 1
+  fi
+fi
+
+if [ $ucp -eq 0 ] ; then
+  if [ $do6 = yes ] ; then
+    echo "Can't run test 6 because Unicode property support is not configured"
+    exit 1
+  fi
+  if [ $do9 = yes ] ; then
+    echo "Can't run test 9 because Unicode property support is not configured"
+    exit 1
+  fi
+  if [ $do10 = yes ] ; then
+    echo "Can't run test 10 because Unicode property support is not configured"
+    exit 1
+  fi
+fi
+
+if [ $link_size -ne 2 ] ; then
+  if [ $do10 = yes ] ; then
+    echo "Can't run test 10 because the link size ($link_size) is not 2"
+    exit 1
+  fi
+fi
+
+# If no specific tests were requested, select all that are relevant.
+
+if [ $do1 = no -a $do2 = no -a $do3 = no -a $do4 = no -a \
+     $do5 = no -a $do6 = no -a $do7 = no -a $do8 = no -a \
+     $do9 = no -a $do10 = no ] ; then
+  do1=yes
+  do2=yes
+  do3=yes
+  if [ $utf8 -ne 0 ] ; then do4=yes; fi
+  if [ $utf8 -ne 0 ] ; then do5=yes; fi
+  if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do6=yes; fi
+  do7=yes
+  if [ $utf8 -ne 0 ] ; then do8=yes; fi
+  if [ $utf8 -ne 0 -a $ucp -ne 0 ] ; then do9=yes; fi
+  if [ $link_size -eq 2 -a $ucp -ne 0 ] ; then do10=yes; fi
+fi
+
+# Show which release
+
+echo ""
+echo PCRE C library tests
+./pcretest /dev/null
+
+# Primary test, Perl-compatible
+
+if [ $do1 = yes ] ; then
+  echo "Test 1: main functionality (Perl compatible)"
+  $valgrind ./pcretest -q $testdata/testinput1 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput1 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else exit 1
+  fi
+  echo "OK"
+fi
+
+# PCRE tests that are not Perl-compatible - API & error tests, mostly
+
+if [ $do2 = yes ] ; then
+  echo "Test 2: API and error handling (not Perl compatible)"
+  $valgrind ./pcretest -q $testdata/testinput2 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput2 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else
+    echo " "
+    echo "** Test 2 requires a lot of stack. If it has crashed with a"
+    echo "** segmentation fault, it may be that you do not have enough"
+    echo "** stack available by default. Please see the 'pcrestack' man"
+    echo "** page for a discussion of PCRE's stack usage."
+    echo " "
+    exit 1
+  fi
+  echo "OK"
+fi
+
+# Locale-specific tests, provided that either the "fr_FR" or the "french"
+# locale is available. The former is the Unix-like standard; the latter is
+# for Windows.
+
+if [ $do3 = yes ] ; then
+  locale -a | grep '^fr_FR$' >/dev/null
+  if [ $? -eq 0 ] ; then
+    locale=fr_FR
+    infile=$testdata/testinput3
+    outfile=$testdata/testoutput3
+  else
+    locale -a | grep '^french$' >/dev/null
+    if [ $? -eq 0 ] ; then
+      locale=french
+      sed 's/fr_FR/french/' $testdata/testinput3 >test3input
+      sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
+      infile=test3input
+      outfile=test3output
+    else
+      locale=
+    fi
+  fi
+
+  if [ "$locale" != "" ] ; then
+    echo "Test 3: locale-specific features (using '$locale' locale)"
+    $valgrind ./pcretest -q $infile testtry
+    if [ $? = 0 ] ; then
+      $cf $outfile testtry
+      if [ $? != 0 ] ; then
+        echo " "
+        echo "Locale test did not run entirely successfully."
+        echo "This usually means that there is a problem with the locale"
+        echo "settings rather than a bug in PCRE."
+      else
+      echo "OK"
+      fi
+    else exit 1
+    fi
+  else
+    echo "Cannot test locale-specific features - neither the 'fr_FR' nor the"
+    echo "'french' locale exists, or the \"locale\" command is not available"
+    echo "to check for them."
+    echo " "
+  fi
+fi
+
+# Additional tests for UTF8 support
+
+if [ $do4 = yes ] ; then
+  echo "Test 4: UTF-8 support (Perl compatible)"
+  $valgrind ./pcretest -q $testdata/testinput4 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput4 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else exit 1
+  fi
+  echo "OK"
+fi
+
+if [ $do5 = yes ] ; then
+  echo "Test 5: API and internals for UTF-8 support (not Perl compatible)"
+  $valgrind ./pcretest -q $testdata/testinput5 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput5 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else exit 1
+  fi
+  echo "OK"
+fi
+
+if [ $do6 = yes ] ; then
+  echo "Test 6: Unicode property support"
+  $valgrind ./pcretest -q $testdata/testinput6 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput6 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else exit 1
+  fi
+  echo "OK"
+fi
+
+# Tests for DFA matching support
+
+if [ $do7 = yes ] ; then
+  echo "Test 7: DFA matching"
+  $valgrind ./pcretest -q -dfa $testdata/testinput7 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput7 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else exit 1
+  fi
+  echo "OK"
+fi
+
+if [ $do8 = yes ] ; then
+  echo "Test 8: DFA matching with UTF-8"
+  $valgrind ./pcretest -q -dfa $testdata/testinput8 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput8 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else exit 1
+  fi
+  echo "OK"
+fi
+
+if [ $do9 = yes ] ; then
+  echo "Test 9: DFA matching with Unicode properties"
+  $valgrind ./pcretest -q -dfa $testdata/testinput9 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput9 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else exit 1
+  fi
+  echo "OK"
+fi
+
+# Test of internal offsets and code sizes. This test is run only when there
+# is Unicode property support and the link size is 2. The actual tests are
+# mostly the same as in some of the above, but in this test we inspect some
+# offsets and sizes that require a known link size. This is a doublecheck for
+# the maintainer, just in case something changes unexpectely.
+
+if [ $do10 = yes ] ; then
+  echo "Test 10: Internal offsets and code size tests"
+  $valgrind ./pcretest -q $testdata/testinput10 testtry
+  if [ $? = 0 ] ; then
+    $cf $testdata/testoutput10 testtry
+    if [ $? != 0 ] ; then exit 1; fi
+  else exit 1
+  fi
+  echo "OK"
+fi
+
+# End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/RunTest.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+@rem  This file was contributed by Ralf Junker, and touched up by
+@rem  Daniel Richard G. Test 10 added by Philip H.
+@rem  Philip H also changed test 3 to use "wintest" files.
+@rem
+@rem  MS Windows batch file to run pcretest on testfiles with the correct
+@rem  options.
+@rem
+@rem  Output is written to a newly created subfolder named "testdata".
+
+setlocal
+
+if [%srcdir%]==[]   set srcdir=.
+if [%pcretest%]==[] set pcretest=pcretest
+
+if not exist testout md testout
+
+%pcretest% -q      %srcdir%\testdata\testinput1 > testout\testoutput1
+%pcretest% -q      %srcdir%\testdata\testinput2 > testout\testoutput2
+@rem %pcretest% -q      %srcdir%\testdata\testinput3 > testout\testoutput3
+%pcretest% -q      %srcdir%\testdata\wintestinput3 > testout\wintestoutput3
+%pcretest% -q      %srcdir%\testdata\testinput4 > testout\testoutput4
+%pcretest% -q      %srcdir%\testdata\testinput5 > testout\testoutput5
+%pcretest% -q      %srcdir%\testdata\testinput6 > testout\testoutput6
+%pcretest% -q -dfa %srcdir%\testdata\testinput7 > testout\testoutput7
+%pcretest% -q -dfa %srcdir%\testdata\testinput8 > testout\testoutput8
+%pcretest% -q -dfa %srcdir%\testdata\testinput9 > testout\testoutput9
+%pcretest% -q      %srcdir%\testdata\testinput10 > testout\testoutput10
+
+fc /n %srcdir%\testdata\testoutput1 testout\testoutput1
+fc /n %srcdir%\testdata\testoutput2 testout\testoutput2
+rem fc /n %srcdir%\testdata\testoutput3 testout\testoutput3
+fc /n %srcdir%\testdata\wintestoutput3 testout\wintestoutput3
+fc /n %srcdir%\testdata\testoutput4 testout\testoutput4
+fc /n %srcdir%\testdata\testoutput5 testout\testoutput5
+fc /n %srcdir%\testdata\testoutput6 testout\testoutput6
+fc /n %srcdir%\testdata\testoutput7 testout\testoutput7
+fc /n %srcdir%\testdata\testoutput8 testout\testoutput8
+fc /n %srcdir%\testdata\testoutput9 testout\testoutput9
+fc /n %srcdir%\testdata\testoutput10 testout\testoutput10
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/aclocal.m4	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,7560 @@
+# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008  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.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(AC_AUTOCONF_VERSION, [2.61],,
+[m4_warning([this file was generated for autoconf 2.61.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+
+# serial 52 AC_PROG_LIBTOOL
+
+
+# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+# -----------------------------------------------------------
+# If this macro is not defined by Autoconf, define it here.
+m4_ifdef([AC_PROVIDE_IFELSE],
+         [],
+         [m4_define([AC_PROVIDE_IFELSE],
+	         [m4_ifdef([AC_PROVIDE_$1],
+		           [$2], [$3])])])
+
+
+# AC_PROG_LIBTOOL
+# ---------------
+AC_DEFUN([AC_PROG_LIBTOOL],
+[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+  AC_PROVIDE_IFELSE([AC_PROG_CXX],
+    [AC_LIBTOOL_CXX],
+    [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+  ])])
+dnl And a similar setup for Fortran 77 support
+  AC_PROVIDE_IFELSE([AC_PROG_F77],
+    [AC_LIBTOOL_F77],
+    [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+])])
+
+dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+  AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+    [AC_LIBTOOL_GCJ],
+    [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+      [AC_LIBTOOL_GCJ],
+      [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+	[AC_LIBTOOL_GCJ],
+      [ifdef([AC_PROG_GCJ],
+	     [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+       ifdef([A][M_PROG_GCJ],
+	     [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+       ifdef([LT_AC_PROG_GCJ],
+	     [define([LT_AC_PROG_GCJ],
+		defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+])])# AC_PROG_LIBTOOL
+
+
+# _AC_PROG_LIBTOOL
+# ----------------
+AC_DEFUN([_AC_PROG_LIBTOOL],
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_GCJ])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_PROG_LIBTOOL
+
+
+# AC_LIBTOOL_SETUP
+# ----------------
+AC_DEFUN([AC_LIBTOOL_SETUP],
+[AC_PREREQ(2.50)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([AC_PROG_LN_S])dnl
+AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+AC_REQUIRE([AC_OBJEXT])dnl
+AC_REQUIRE([AC_EXEEXT])dnl
+dnl
+AC_LIBTOOL_SYS_MAX_CMD_LEN
+AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+AC_LIBTOOL_OBJDIR
+
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+_LT_AC_PROG_ECHO_BACKSLASH
+
+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
+
+# 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']
+
+# 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'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_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 MSVC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+AC_CHECK_TOOL(AR, ar, false)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(STRIP, strip, :)
+
+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 "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+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 "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+_LT_CC_BASENAME([$compiler])
+
+# 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
+
+_LT_REQUIRED_DARWIN_CHECKS
+
+AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+enable_win32_dll=yes, enable_win32_dll=no)
+
+AC_ARG_ENABLE([libtool-lock],
+    [AC_HELP_STRING([--disable-libtool-lock],
+	[avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+AC_ARG_WITH([pic],
+    [AC_HELP_STRING([--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
+
+# Check if we have a version mismatch between libtool.m4 and ltmain.sh.
+#
+# Note:  This should be in AC_LIBTOOL_SETUP, _after_ $ltmain have been defined.
+#        We also should do it _before_ AC_LIBTOOL_LANG_C_CONFIG that actually
+#        calls AC_LIBTOOL_CONFIG and creates libtool.
+#
+_LT_VERSION_CHECK
+
+# Use C for the default configuration in the libtool script
+tagname=
+AC_LIBTOOL_LANG_C_CONFIG
+_LT_AC_TAGCONFIG
+])# AC_LIBTOOL_SETUP
+
+
+# _LT_VERSION_CHECK
+# -----------------
+AC_DEFUN([_LT_VERSION_CHECK],
+[AC_MSG_CHECKING([for correct ltmain.sh version])
+if test "x$ltmain" = "x" ; then
+  AC_MSG_RESULT(no)
+  AC_MSG_ERROR([
+
+*** @<:@Gentoo@:>@ sanity check failed! ***
+*** \$ltmain is not defined, please check the patch for consistency! ***
+])
+fi
+gentoo_lt_version="1.5.26"
+gentoo_ltmain_version=`sed -n '/^[[ 	]]*VERSION=/{s/^[[ 	]]*VERSION=//;p;q;}' "$ltmain"`
+if test "x$gentoo_lt_version" != "x$gentoo_ltmain_version" ; then
+  AC_MSG_RESULT(no)
+  AC_MSG_ERROR([
+
+*** @<:@Gentoo@:>@ sanity check failed! ***
+*** libtool.m4 and ltmain.sh have a version mismatch! ***
+*** (libtool.m4 = $gentoo_lt_version, ltmain.sh = $gentoo_ltmain_version) ***
+
+Please run:
+
+  libtoolize --copy --force
+
+if appropriate, please contact the maintainer of this
+package (or your distribution) for help.
+])
+else
+  AC_MSG_RESULT(yes)
+fi
+])# _LT_VERSION_CHECK
+
+
+# _LT_AC_SYS_COMPILER
+# -------------------
+AC_DEFUN([_LT_AC_SYS_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_AC_SYS_COMPILER
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+AC_DEFUN([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+AC_DEFUN([_LT_COMPILER_BOILERPLATE],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+AC_DEFUN([_LT_LINKER_BOILERPLATE],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# --------------------------
+# Check for some things on darwin
+AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+   # By default we will add the -single_module flag. You can override
+   # by either setting the environment variable LT_MULTI_MODULE
+   # non-empty at configure time, or by adding -multi_module to the
+   # link flags.
+   echo "int foo(void){return 1;}" > conftest.c
+   $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+     -dynamiclib ${wl}-single_module conftest.c
+   if test -f libconftest.dylib; then
+     lt_cv_apple_cc_single_mod=yes
+     rm -rf libconftest.dylib*
+   fi
+   rm conftest.c
+      fi])
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+   [lt_cv_ld_exported_symbols_list=yes],
+   [lt_cv_ld_exported_symbols_list=no])
+   LDFLAGS="$save_LDFLAGS"
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[0123]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*)
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+   10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+   10.[[012]]*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+   10.*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}"
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil="~$DSYMUTIL \$lib || :"
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
+
+# _LT_AC_SYS_LIBPATH_AIX
+# ----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_AC_SYS_LIBPATH_AIX
+
+
+# _LT_AC_SHELL_INIT(ARG)
+# ----------------------
+AC_DEFUN([_LT_AC_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+	     [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+	 [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_AC_SHELL_INIT
+
+
+# _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],
+[_LT_AC_SHELL_INIT([
+# 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.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+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.
+
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    IFS="$lt_save_ifs"
+    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="$lt_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)
+])])# _LT_AC_PROG_ECHO_BACKSLASH
+
+
+# _LT_AC_LOCK
+# -----------
+AC_DEFUN([_LT_AC_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+    [AC_HELP_STRING([--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
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *ELF-32*)
+      HPUX_IA64_MODE="32"
+      ;;
+    *ELF-64*)
+      HPUX_IA64_MODE="64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+   if test "$lt_cv_prog_gnu_ld" = yes; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -melf32bsmip"
+      ;;
+    *N32*)
+      LD="${LD-ld} -melf32bmipn32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -melf64bmip"
+      ;;
+    esac
+   else
+    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
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *32-bit*)
+      case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_i386_fbsd"
+          ;;
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_i386"
+          ;;
+        ppc64-*linux*|powerpc64-*linux*)
+          LD="${LD-ld} -m elf32ppclinux"
+          ;;
+        s390x-*linux*)
+          LD="${LD-ld} -m elf_s390"
+          ;;
+        sparc64-*linux*)
+          LD="${LD-ld} -m elf32_sparc"
+          ;;
+      esac
+      ;;
+    *64-bit*)
+      case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_x86_64_fbsd"
+          ;;
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        ppc*-*linux*|powerpc*-*linux*)
+          LD="${LD-ld} -m elf64ppc"
+          ;;
+        s390*-*linux*)
+          LD="${LD-ld} -m elf64_s390"
+          ;;
+        sparc*-*linux*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+      esac
+      ;;
+    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_PUSH(C)
+     AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  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
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+        if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+AC_PROVIDE_IFELSE([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)
+  ;;
+  ])
+esac
+
+need_locks="$enable_libtool_lock"
+
+])# _LT_AC_LOCK
+
+
+# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+[AC_REQUIRE([LT_AC_PROG_SED])
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+  ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $rm conftest*
+])
+
+if test x"[$]$2" = xyes; then
+    ifelse([$5], , :, [$5])
+else
+    ifelse([$6], , :, [$6])
+fi
+])# AC_LIBTOOL_COMPILER_OPTION
+
+
+# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                          [ACTION-SUCCESS], [ACTION-FAILURE])
+# ------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $rm -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+    ifelse([$4], , :, [$4])
+else
+    ifelse([$5], , :, [$5])
+fi
+])# AC_LIBTOOL_LINKER_OPTION
+
+
+# AC_LIBTOOL_SYS_MAX_CMD_LEN
+# --------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+[# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ 	]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+	       = "XX$teststring") >/dev/null 2>&1 &&
+	      new_result=`expr "X$teststring" : ".*" 2>&1` &&
+	      lt_cv_sys_max_cmd_len=$new_result &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on massive
+      # amounts of additional arguments before passing them to the linker.
+      # It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
+
+# _LT_AC_CHECK_DLFCN
+# ------------------
+AC_DEFUN([_LT_AC_CHECK_DLFCN],
+[AC_CHECK_HEADERS(dlfcn.h)dnl
+])# _LT_AC_CHECK_DLFCN
+
+
+# _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],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  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); */
+    }
+  else
+    puts (dlerror ());
+
+    exit (status);
+}]
+EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_dlunknown|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],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+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
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+   ;;
+
+  *)
+    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="-ldld"],
+	[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="-ldld"])
+	      ])
+	    ])
+	  ])
+	])
+      ])
+    ;;
+  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"
+    wl=$lt_prog_compiler_wl 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
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      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_LIBTOOL_PROG_CC_C_O([TAGNAME])
+# ---------------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler
+AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && 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
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+])
+])# AC_LIBTOOL_PROG_CC_C_O
+
+
+# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+# -----------------------------------------
+# Check to see if we can do hard links to lock some files if needed
+AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+[AC_REQUIRE([_LT_AC_LOCK])dnl
+
+hard_links="nottested"
+if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = 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
+])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+
+# AC_LIBTOOL_OBJDIR
+# -----------------
+AC_DEFUN([AC_LIBTOOL_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+])# AC_LIBTOOL_OBJDIR
+
+
+# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+# ----------------------------------------------
+# Check hardcoding attributes.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_AC_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+   test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
+   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != 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 "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_AC_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_AC_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = 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
+])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
+
+
+# AC_LIBTOOL_SYS_LIB_STRIP
+# ------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+[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
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         old_striplib="$STRIP -S"
+         AC_MSG_RESULT([yes])
+       else
+  AC_MSG_RESULT([no])
+fi
+       ;;
+   *)
+  AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+])# AC_LIBTOOL_SYS_LIB_STRIP
+
+
+# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+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"
+m4_if($1,[],[
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`echo $lt_search_path_spec`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[[4-9]]*)
+  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}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    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}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+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}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[[45]]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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"
+  # 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
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $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
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  m4_if([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) 
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[123]]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  # Handle Gentoo/FreeBSD as it was Linux
+  case $host_vendor in
+    gentoo)
+      version_type=linux ;;
+    *)
+      version_type=freebsd-$objformat ;;
+  esac
+
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+    linux)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+      soname_spec='${libname}${release}${shared_ext}$major'
+      need_lib_prefix=no
+      need_version=no
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[[3-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      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}"
+  hardcode_into_libs=yes
+  ;;
+
+# 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* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # 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}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  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
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  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"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${shared_ext}$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.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec],
+[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"])
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec],
+[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"])
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+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_SYS_DYNAMIC_LINKER
+
+
+# _LT_AC_TAGCONFIG
+# ----------------
+AC_DEFUN([_LT_AC_TAGCONFIG],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_ARG_WITH([tags],
+    [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+        [include additional configurations @<:@automatic@:>@])],
+    [tagnames="$withval"])
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+  if test ! -f "${ofile}"; then
+    AC_MSG_WARN([output file `$ofile' does not exist])
+  fi
+
+  if test -z "$LTCC"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+    if test -z "$LTCC"; then
+      AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+    else
+      AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+    fi
+  fi
+  if test -z "$LTCFLAGS"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+  fi
+
+  # Extract list of available tagged configurations in $ofile.
+  # Note that this assumes the entire list is on one line.
+  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+  for tagname in $tagnames; do
+    IFS="$lt_save_ifs"
+    # Check whether tagname contains only valid characters
+    case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+    "") ;;
+    *)  AC_MSG_ERROR([invalid tag name: $tagname])
+	;;
+    esac
+
+    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+    then
+      AC_MSG_ERROR([tag name \"$tagname\" already exists])
+    fi
+
+    # Update the list of available tags.
+    if test -n "$tagname"; then
+      echo appending configuration tag \"$tagname\" to $ofile
+
+      case $tagname in
+      CXX)
+	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+	    (test "X$CXX" != "Xg++"))) ; then
+	  AC_LIBTOOL_LANG_CXX_CONFIG
+	else
+	  tagname=""
+	fi
+	;;
+
+      F77)
+	if test -n "$F77" && test "X$F77" != "Xno"; then
+	  AC_LIBTOOL_LANG_F77_CONFIG
+	else
+	  tagname=""
+	fi
+	;;
+
+      GCJ)
+	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+	  AC_LIBTOOL_LANG_GCJ_CONFIG
+	else
+	  tagname=""
+	fi
+	;;
+
+      RC)
+	AC_LIBTOOL_LANG_RC_CONFIG
+	;;
+
+      *)
+	AC_MSG_ERROR([Unsupported tag name: $tagname])
+	;;
+      esac
+
+      # Append the new tag name to the list of available tags.
+      if test -n "$tagname" ; then
+      available_tags="$available_tags $tagname"
+    fi
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  # Now substitute the updated list of available tags.
+  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+    mv "${ofile}T" "$ofile"
+    chmod +x "$ofile"
+  else
+    rm -f "${ofile}T"
+    AC_MSG_ERROR([unable to update list of available tagged configurations.])
+  fi
+fi
+])# _LT_AC_TAGCONFIG
+
+
+# AC_LIBTOOL_DLOPEN
+# -----------------
+# enable checks for dlopen support
+AC_DEFUN([AC_LIBTOOL_DLOPEN],
+ [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_DLOPEN
+
+
+# AC_LIBTOOL_WIN32_DLL
+# --------------------
+# declare package support for building win32 DLLs
+AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_WIN32_DLL
+
+
+# AC_ENABLE_SHARED([DEFAULT])
+# ---------------------------
+# implement the --enable-shared flag
+# 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],
+    [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+	[build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+    [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.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+])# AC_ENABLE_SHARED
+
+
+# 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_DISABLE_SHARED
+
+
+# AC_ENABLE_STATIC([DEFAULT])
+# ---------------------------
+# implement the --enable-static flag
+# 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],
+    [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+	[build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+    [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.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+])# AC_ENABLE_STATIC
+
+
+# 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_DISABLE_STATIC
+
+
+# AC_ENABLE_FAST_INSTALL([DEFAULT])
+# ---------------------------------
+# implement the --enable-fast-install flag
+# 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],
+    [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [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.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+])# AC_ENABLE_FAST_INSTALL
+
+
+# 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_DISABLE_FAST_INSTALL
+
+
+# AC_LIBTOOL_PICMODE([MODE])
+# --------------------------
+# implement the --with-pic flag
+# 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_LIBTOOL_PICMODE
+
+
+# AC_PROG_EGREP
+# -------------
+# This is predefined starting with Autoconf 2.54, so this conditional
+# definition can be removed once we require Autoconf 2.54 or later.
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+   [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])
+ EGREP=$ac_cv_prog_egrep
+ AC_SUBST([EGREP])
+])])
+
+
+# AC_PATH_TOOL_PREFIX
+# -------------------
+# find a file program which can recognize shared library
+AC_DEFUN([AC_PATH_TOOL_PREFIX],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+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_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+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
+    IFS="$lt_save_ifs"
+    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@gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_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_TOOL_PREFIX
+
+
+# AC_PATH_MAGIC
+# -------------
+# find a file program which can recognize a shared library
+AC_DEFUN([AC_PATH_MAGIC],
+[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$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_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# AC_PATH_MAGIC
+
+
+# AC_PROG_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([AC_PROG_LD],
+[AC_ARG_WITH([gnu-ld],
+    [AC_HELP_STRING([--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([LT_AC_PROG_SED])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])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 $CC])
+  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.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname 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
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    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 variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_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
+
+
+# AC_PROG_LD_GNU
+# --------------
+AC_DEFUN([AC_PROG_LD_GNU],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+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 lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# AC_PROG_LD_GNU
+
+
+# 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
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+])# AC_PROG_LD_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 recognize 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 extended 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
+aix[[4-9]]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[[45]]*)
+  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*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  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|DragonFly)/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_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    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_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  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
+  ;;
+
+nto-qnx*)
+  lt_cv_deplibs_check_method=unknown
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  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
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+])# AC_DEPLIBS_CHECK_METHOD
+
+
+# AC_PROG_NM
+# ----------
+# find the pathname to a BSD-compatible name lister
+AC_DEFUN([AC_PROG_NM],
+[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_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
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    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
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi])
+NM="$lt_cv_path_NM"
+])# AC_PROG_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* | *-*-darwin*)
+  # These system don't have libm, or don't need it
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  ;;
+esac
+])# AC_CHECK_LIBM
+
+
+# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+# -----------------------------------
+# 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
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY 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_CONVENIENCE
+
+
+# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+# -----------------------------------
+# 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
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY 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 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, lt_dlinit,
+  [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"
+])# AC_LIBLTDL_INSTALLABLE
+
+
+# AC_LIBTOOL_CXX
+# --------------
+# enable support for C++ libraries
+AC_DEFUN([AC_LIBTOOL_CXX],
+[AC_REQUIRE([_LT_AC_LANG_CXX])
+])# AC_LIBTOOL_CXX
+
+
+# _LT_AC_LANG_CXX
+# ---------------
+AC_DEFUN([_LT_AC_LANG_CXX],
+[AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+])# _LT_AC_LANG_CXX
+
+# _LT_AC_PROG_CXXCPP
+# ------------------
+AC_DEFUN([_LT_AC_PROG_CXXCPP],
+[
+AC_REQUIRE([AC_PROG_CXX])
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+fi
+])# _LT_AC_PROG_CXXCPP
+
+# AC_LIBTOOL_F77
+# --------------
+# enable support for Fortran 77 libraries
+AC_DEFUN([AC_LIBTOOL_F77],
+[AC_REQUIRE([_LT_AC_LANG_F77])
+])# AC_LIBTOOL_F77
+
+
+# _LT_AC_LANG_F77
+# ---------------
+AC_DEFUN([_LT_AC_LANG_F77],
+[AC_REQUIRE([AC_PROG_F77])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+])# _LT_AC_LANG_F77
+
+
+# AC_LIBTOOL_GCJ
+# --------------
+# enable support for GCJ libraries
+AC_DEFUN([AC_LIBTOOL_GCJ],
+[AC_REQUIRE([_LT_AC_LANG_GCJ])
+])# AC_LIBTOOL_GCJ
+
+
+# _LT_AC_LANG_GCJ
+# ---------------
+AC_DEFUN([_LT_AC_LANG_GCJ],
+[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+	 [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+	   [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+])# _LT_AC_LANG_GCJ
+
+
+# AC_LIBTOOL_RC
+# -------------
+# enable support for Windows resource files
+AC_DEFUN([AC_LIBTOOL_RC],
+[AC_REQUIRE([LT_AC_PROG_RC])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+])# AC_LIBTOOL_RC
+
+
+# AC_LIBTOOL_LANG_C_CONFIG
+# ------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+[lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF
+
+# Report which library types will actually be built
+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
+  ;;
+
+aix[[4-9]]*)
+  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])
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_C_CONFIG
+
+
+# AC_LIBTOOL_LANG_CXX_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+[AC_LANG_PUSH(C++)
+AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Dependencies to place before and after the object being linked:
+_LT_AC_TAGVAR(predep_objects, $1)=
+_LT_AC_TAGVAR(postdep_objects, $1)=
+_LT_AC_TAGVAR(predeps, $1)=
+_LT_AC_TAGVAR(postdeps, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_LD=$LD
+lt_save_GCC=$GCC
+GCC=$GXX
+lt_save_with_gnu_ld=$with_gnu_ld
+lt_save_path_LD=$lt_cv_path_LD
+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+  lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+else
+  $as_unset lt_cv_prog_gnu_ld
+fi
+if test -n "${lt_cv_path_LDCXX+set}"; then
+  lt_cv_path_LD=$lt_cv_path_LDCXX
+else
+  $as_unset lt_cv_path_LD
+fi
+test -z "${LDCXX+set}" || LD=$LDCXX
+CC=${CXX-"c++"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# We don't want -fno-exception wen compiling C++ code, so set the
+# no_builtin_flag separately
+if test "$GXX" = yes; then
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+else
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+fi
+
+if test "$GXX" = yes; then
+  # Set up default GNU C++ configuration
+
+  AC_PROG_LD
+
+  # Check if GNU C++ uses GNU ld as the underlying linker, since the
+  # archiving commands below assume that GNU ld is being used.
+  if test "$with_gnu_ld" = yes; then
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+    #     investigate it a little bit more. (MM)
+    wlarc='${wl}'
+
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+	grep 'no-whole-archive' > /dev/null; then
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    with_gnu_ld=no
+    wlarc=
+
+    # A generic and very simple default shared library creation
+    # command for GNU C++ for the case where it uses the native
+    # linker, instead of GNU ld.  If possible, this setting should
+    # overridden to take advantage of the native linker features on
+    # the platform it is being used on.
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+  fi
+
+  # Commands to make compiler produce verbose output that lists
+  # what "hidden" libraries, object files and flags are used when
+  # linking a shared library.
+  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+else
+  GXX=no
+  with_gnu_ld=no
+  wlarc=
+fi
+
+# PORTME: fill in a description of your system's C++ link characteristics
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+case $host_os in
+  aix3*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  aix[[4-9]]*)
+    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]].*|aix[[5-9]]*)
+	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.
+
+    _LT_AC_TAGVAR(archive_cmds, $1)=''
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+    if test "$GXX" = yes; then
+      case $host_os in aix4.[[012]]|aix4.[[012]].*)
+      # We only want to do this on AIX 4.2 and lower, the check
+      # below for broken collect2 doesn't work under 4.3+
+	collect2name=`${CC} -print-prog-name=collect2`
+	if test -f "$collect2name" && \
+	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	then
+	  # We have reworked collect2
+	  :
+	else
+	  # We have old collect2
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=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
+	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+	fi
+	;;
+      esac
+      shared_flag='-shared'
+      if test "$aix_use_runtimelinking" = yes; then
+	shared_flag="$shared_flag "'${wl}-G'
+      fi
+    else
+      # not using gcc
+      if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	shared_flag='-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 does not export symbols beginning with
+    # underscore (_), so it is better to generate a list of symbols to export.
+    _LT_AC_TAGVAR(always_export_symbols, $1)=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.
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+      # Determine the default libpath from the value encoded in an empty executable.
+      _LT_AC_SYS_LIBPATH_AIX
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+     else
+      if test "$host_cpu" = ia64; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+      else
+	# Determine the default libpath from the value encoded in an empty executable.
+	_LT_AC_SYS_LIBPATH_AIX
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	# Warning - without using the other run time loading flags,
+	# -berok will link without error, but may produce a broken library.
+	_LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	# Exported symbols can be pulled into shared objects from archives
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+	# This is similar to how AIX traditionally builds its shared libraries.
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+      fi
+    fi
+    ;;
+
+  beos*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+
+  chorus*)
+    case $cc_basename in
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+    # as there is no search path for DLLs.
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+    _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+    _LT_AC_TAGVAR(always_export_symbols, $1)=no
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+    if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      # If the export-symbols file already is a .def file (1st line
+      # is EXPORTS), use it as is; otherwise, prepend...
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	cp $export_symbols $output_objdir/$soname.def;
+      else
+	echo EXPORTS > $output_objdir/$soname.def;
+	cat $export_symbols >> $output_objdir/$soname.def;
+      fi~
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+  ;;
+      darwin* | rhapsody*)
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+      if test "$GXX" = yes ; then
+      output_verbose_link_cmd='echo'
+      _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+      if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+      fi
+      else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
+          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+          ;;
+      esac
+      fi
+        ;;
+
+  dgux*)
+    case $cc_basename in
+      ec++*)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      ghcx*)
+	# Green Hills C++ Compiler
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+  freebsd[[12]]*)
+    # C++ shared libraries reported to be fairly broken before switch to ELF
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  freebsd-elf*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    ;;
+  freebsd* | dragonfly*)
+    # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+    # conventions
+    _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+    ;;
+  gnu*)
+    ;;
+  hpux9*)
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+				# but as the default
+				# location of the library.
+
+    case $cc_basename in
+    CC*)
+      # FIXME: insert proper C++ library support
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    aCC*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      #
+      # There doesn't appear to be a way to prevent this compiler from
+      # explicitly linking system object files so we need to strip them
+      # from the output so that they don't get included in the library
+      # dependencies.
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      ;;
+    *)
+      if test "$GXX" = yes; then
+        _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+        # FIXME: insert proper C++ library support
+        _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+    ;;
+  hpux10*|hpux11*)
+    if test $with_gnu_ld = no; then
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+      case $host_cpu in
+      hppa*64*|ia64*) ;;
+      *)
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        ;;
+      esac
+    fi
+    case $host_cpu in
+    hppa*64*|ia64*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+    *)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+					      # but as the default
+					      # location of the library.
+      ;;
+    esac
+
+    case $cc_basename in
+      CC*)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      aCC*)
+	case $host_cpu in
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	esac
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes; then
+	  if test $with_gnu_ld = no; then
+	    case $host_cpu in
+	    hppa*64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    ia64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    *)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    esac
+	  fi
+	else
+	  # FIXME: insert proper C++ library support
+	  _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+    esac
+    ;;
+  interix[[3-9]]*)
+    _LT_AC_TAGVAR(hardcode_direct, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+    # Instead, shared libraries are loaded at an image base (0x10000000 by
+    # default) and relocated if they conflict, which is a slow very memory
+    # consuming and fragmenting process.  To avoid this, we pick a random,
+    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    ;;
+  irix5* | irix6*)
+    case $cc_basename in
+      CC*)
+	# SGI C++
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	# Archives containing C++ object files must be created using
+	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	# necessary to make sure instantiated templates are included
+	# in the archive.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	;;
+      *)
+	if test "$GXX" = yes; then
+	  if test "$with_gnu_ld" = no; then
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $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
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+	  fi
+	fi
+	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+	;;
+    esac
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+    ;;
+  linux* | k*bsd*-gnu)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	_LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+	# Archives containing C++ object files must be created using
+	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+	;;
+      icpc*)
+	# Intel C++
+	with_gnu_ld=yes
+	# version 8.0 and above of icpc choke on multiply defined symbols
+	# if we add $predep_objects and $postdep_objects, however 7.1 and
+	# earlier do not add the objects themselves.
+	case `$CC -V 2>&1` in
+	*"Version 7."*)
+  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+  	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  ;;
+	*)  # Version 8.0 or newer
+	  tmp_idyn=
+	  case $host_cpu in
+	    ia64*) tmp_idyn=' -i_dynamic';;
+	  esac
+  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  ;;
+	esac
+	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	;;
+      pgCC* | pgcpp*)
+        # Portland Group C++ compiler
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+  	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+        ;;
+      cxx*)
+	# Compaq C++
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+	runpath_var=LD_RUN_PATH
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C++ 5.9
+	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+
+	  # Not sure whether something based on
+	  # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	  # would be better.
+	  output_verbose_link_cmd='echo'
+
+	  # Archives containing C++ object files must be created using
+	  # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	  # necessary to make sure instantiated templates are included
+	  # in the archive.
+	  _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	  ;;
+	esac
+	;;
+    esac
+    ;;
+  lynxos*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  m88k*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  mvs*)
+    case $cc_basename in
+      cxx*)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    fi
+    # Workaround some broken pre-1.5 toolchains
+    output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+    ;;
+  openbsd2*)
+    # C++ shared libraries are fairly broken
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  openbsd*)
+    if test -f /usr/libexec/ld.so; then
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      fi
+      output_verbose_link_cmd='echo'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+  osf3*)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	_LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Archives containing C++ object files must be created using
+	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+
+	;;
+      RCC*)
+	# Rational C++ 2.4.1
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      cxx*)
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $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'
+
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	  # Commands to make compiler produce verbose output that lists
+	  # what "hidden" libraries, object files and flags are used when
+	  # linking a shared library.
+	  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+	else
+	  # FIXME: insert proper C++ library support
+	  _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+    esac
+    ;;
+  osf4* | osf5*)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	_LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Archives containing C++ object files must be created using
+	# the KAI C++ compiler.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+	;;
+      RCC*)
+	# Rational C++ 2.4.1
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      cxx*)
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	  echo "-hidden">> $lib.exp~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $rm $lib.exp'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	 _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $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'
+
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	  # Commands to make compiler produce verbose output that lists
+	  # what "hidden" libraries, object files and flags are used when
+	  # linking a shared library.
+	  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+	else
+	  # FIXME: insert proper C++ library support
+	  _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+    esac
+    ;;
+  psos*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  sunos4*)
+    case $cc_basename in
+      CC*)
+	# Sun C++ 4.x
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      lcc*)
+	# Lucid
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+  solaris*)
+    case $cc_basename in
+      CC*)
+	# Sun C++ 4.2, 5.x and Centerline C++
+        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+	_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	case $host_os in
+	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  *)
+	    # The compiler driver will combine and reorder linker options,
+	    # but understands `-z linker_flag'.
+	    # Supported since Solaris 2.6 (maybe 2.5.1?)
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	    ;;
+	esac
+	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+	output_verbose_link_cmd='echo'
+
+	# Archives containing C++ object files must be created using
+	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	# necessary to make sure instantiated templates are included
+	# in the archive.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	;;
+      gcx*)
+	# Green Hills C++ Compiler
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+	# The C++ compiler must be used to create the archive.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	;;
+      *)
+	# GNU C++ compiler with Solaris linker
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	  if $CC --version | grep -v '^2\.7' > /dev/null; then
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+	  else
+	    # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	    # platform.
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+	  fi
+
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	  case $host_os in
+	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  *)
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	    ;;
+	  esac
+	fi
+	;;
+    esac
+    ;;
+  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  sysv5* | sco3.2v5* | sco5v6*)
+    # Note: We can NOT use -z defs as we might desire, because we do not
+    # link with -lc, and that would cause any symbols used from libc to
+    # always be unresolved, which means just about no library would
+    # ever link correctly.  If we're not using GNU ld we use -z text
+    # though, which does catch some bad symbols but isn't as heavy-handed
+    # as -z defs.
+    # For security reasons, it is highly recommended that you always
+    # use absolute paths for naming shared libraries, and exclude the
+    # DT_RUNPATH tag from executables and libraries.  But doing so
+    # requires that you compile everything twice, which is a pain.
+    # So that behaviour is only enabled if SCOABSPATH is set to a
+    # non-empty value in the environment.  Most likely only useful for
+    # creating official distributions of packages.
+    # This is a hack until libtool officially supports absolute path
+    # names for shared libraries.
+    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+    _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  tandem*)
+    case $cc_basename in
+      NCC*)
+	# NonStop-UX NCC 3.20
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+  vxworks*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  *)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+esac
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_AC_TAGVAR(GCC, $1)="$GXX"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_POSTDEP_PREDEP($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC=$lt_save_CC
+LDCXX=$LD
+LD=$lt_save_LD
+GCC=$lt_save_GCC
+with_gnu_ldcxx=$with_gnu_ld
+with_gnu_ld=$lt_save_with_gnu_ld
+lt_cv_path_LDCXX=$lt_cv_path_LD
+lt_cv_path_LD=$lt_save_path_LD
+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+])# AC_LIBTOOL_LANG_CXX_CONFIG
+
+# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+# ------------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+int a;
+void foo (void) { a = 0; }
+EOF
+],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+EOF
+],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+EOF
+],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  # The `*' in the case matches for architectures that use `case' in
+  # $output_verbose_cmd can trigger glob expansion during the loop
+  # eval without this substitution.
+  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+
+  for p in `eval $output_verbose_link_cmd`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" \
+	  || test $p = "-R"; then
+	 prev=$p
+	 continue
+       else
+	 prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 case $p in
+	 -L* | -R*)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+	     _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	   else
+	     _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+	   _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+	 else
+	   _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+	 fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+	   _LT_AC_TAGVAR(predep_objects, $1)="$p"
+	 else
+	   _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+	 fi
+       else
+	 if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+	   _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+	 else
+	   _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$rm -f confest.$objext
+
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+  _LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_AC_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+# PORTME: override above test on systems where it is broken
+ifelse([$1],[CXX],
+[case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_AC_TAGVAR(predep_objects,$1)=
+  _LT_AC_TAGVAR(postdep_objects,$1)=
+  _LT_AC_TAGVAR(postdeps,$1)=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+    #
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+])
+case " $_LT_AC_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+])# AC_LIBTOOL_POSTDEP_PREDEP
+
+# AC_LIBTOOL_LANG_F77_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+[AC_REQUIRE([AC_PROG_F77])
+AC_LANG_PUSH(Fortran 77)
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="\
+      program t
+      end
+"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${F77-"f77"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+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
+  ;;
+aix[[4-9]]*)
+  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])
+
+_LT_AC_TAGVAR(GCC, $1)="$G77"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_F77_CONFIG
+
+
+# AC_LIBTOOL_LANG_GCJ_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_GCJ_CONFIG
+
+
+# AC_LIBTOOL_LANG_RC_CONFIG
+# -------------------------
+# Ensure that the configuration vars for the Windows resource compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_RC_CONFIG
+
+
+# AC_LIBTOOL_CONFIG([TAGNAME])
+# ----------------------------
+# If TAGNAME is not passed, then create an initial libtool script
+# with a default configuration from the untagged config vars.  Otherwise
+# add code to config.status for appending the configuration named by
+# TAGNAME from the matching tagged config vars.
+AC_DEFUN([AC_LIBTOOL_CONFIG],
+[# The else 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
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # 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 AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    _LT_AC_TAGVAR(compiler, $1) \
+    _LT_AC_TAGVAR(CC, $1) \
+    _LT_AC_TAGVAR(LD, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+    _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+    _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+    _LT_AC_TAGVAR(old_archive_cmds, $1) \
+    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+    _LT_AC_TAGVAR(predep_objects, $1) \
+    _LT_AC_TAGVAR(postdep_objects, $1) \
+    _LT_AC_TAGVAR(predeps, $1) \
+    _LT_AC_TAGVAR(postdeps, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \
+    _LT_AC_TAGVAR(archive_cmds, $1) \
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+    _LT_AC_TAGVAR(postinstall_cmds, $1) \
+    _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+    _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+    _LT_AC_TAGVAR(no_undefined_flag, $1) \
+    _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+    _LT_AC_TAGVAR(hardcode_automatic, $1) \
+    _LT_AC_TAGVAR(module_cmds, $1) \
+    _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+    _LT_AC_TAGVAR(fix_srcfile_path, $1) \
+    _LT_AC_TAGVAR(exclude_expsyms, $1) \
+    _LT_AC_TAGVAR(include_expsyms, $1); do
+
+    case $var in
+    _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+    _LT_AC_TAGVAR(archive_cmds, $1) | \
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+    _LT_AC_TAGVAR(module_cmds, $1) | \
+    _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+    _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_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
+
+  case $lt_echo in
+  *'\[$]0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
+    ;;
+  esac
+
+ifelse([$1], [],
+  [cfgfile="${ofile}T"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  $rm -f "$cfgfile"
+  AC_MSG_NOTICE([creating $ofile])],
+  [cfgfile="$ofile"])
+
+  cat <<__EOF__ >> "$cfgfile"
+ifelse([$1], [],
+[#! $SHELL
+
+# `$echo "$cfgfile" | 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, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e 1s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### BEGIN LIBTOOL CONFIG],
+[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+
+# 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=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
+# A language-specific compiler.
+CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
+
+# Is the compiler the GNU C compiler?
+with_gcc=$_LT_AC_TAGVAR(GCC, $1)
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
+
+# 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=$lt_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="$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_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
+
+# 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_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
+
+# 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_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+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_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
+
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
+
+# 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_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
+
+# 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_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_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=$_LT_AC_TAGVAR(hardcode_action, $1)
+
+# 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_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
+
+# 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=$_LT_AC_TAGVAR(link_all_deplibs, $1)
+
+# 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=$lt_fix_srcfile_path
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
+
+# 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_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
+
+# Symbols that must always be exported.
+include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
+
+ifelse([$1],[],
+[# ### END LIBTOOL CONFIG],
+[# ### END LIBTOOL TAG CONFIG: $tagname])
+
+__EOF__
+
+ifelse([$1],[], [
+  case $host_os in
+  aix3*)
+    cat <<\EOF >> "$cfgfile"
+
+# 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
+
+  # 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" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" || \
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+])
+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.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+])# AC_LIBTOOL_CONFIG
+
+
+# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+
+_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+  AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
+
+
+# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+# ---------------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([LT_AC_PROG_SED])
+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 from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# 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 an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_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
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
+  fi
+  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+linux* | k*bsd*-gnu)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDGIRSTW]]'
+    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris*)
+  symcode='[[BDRT]]'
+  ;;
+sco3.2v5*)
+  symcode='[[DT]]'
+  ;;
+sysv4.2uw2*)
+  symcode='[[DT]]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_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.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # 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 grep ' nm_test_var$' "$nlist" >/dev/null; then
+	if grep ' 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_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+	  cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[[]] =
+{
+EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+	  cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_save_LIBS="$LIBS"
+	  lt_save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS="$lt_save_LIBS"
+	  CFLAGS="$lt_save_CFLAGS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+    fi
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf 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
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
+
+# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+# ---------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+ ifelse([$1],[CXX],[
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+    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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+      ;;
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32*)
+      # 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).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+      ;;
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	;;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	;;
+      esac
+      ;;
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[[4-9]]*)
+	# All AIX code is PIC.
+	if test "$host_cpu" = ia64; then
+	  # AIX 5 now supports IA64 processor
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	else
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+	fi
+	;;
+      chorus*)
+	case $cc_basename in
+	cxch68*)
+	  # Green Hills C++ Compiler
+	  # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+	  ;;
+	esac
+	;;
+       darwin*)
+         # PIC is the default on this platform
+         # Common symbols not allowed in MH_DYLIB files
+         case $cc_basename in
+           xlc*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           ;;
+         esac
+       ;;
+      dgux*)
+	case $cc_basename in
+	  ec++*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    ;;
+	  ghcx*)
+	    # Green Hills C++ Compiler
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      freebsd* | dragonfly*)
+	# FreeBSD uses GNU C++
+	;;
+      hpux9* | hpux10* | hpux11*)
+	case $cc_basename in
+	  CC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    if test "$host_cpu" != ia64; then
+	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	    fi
+	    ;;
+	  aCC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    case $host_cpu in
+	    hppa*64*|ia64*)
+	      # +Z the default
+	      ;;
+	    *)
+	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	      ;;
+	    esac
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
+      irix5* | irix6* | nonstopux*)
+	case $cc_basename in
+	  CC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    # CC pic flag -KPIC is the default.
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      linux* | k*bsd*-gnu)
+	case $cc_basename in
+	  KCC*)
+	    # KAI C++ Compiler
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	    ;;
+	  icpc* | ecpc*)
+	    # Intel C++
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	    ;;
+	  pgCC* | pgcpp*)
+	    # Portland Group C++ compiler.
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	  cxx*)
+	    # Compaq C++
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+      lynxos*)
+	;;
+      m88k*)
+	;;
+      mvs*)
+	case $cc_basename in
+	  cxx*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      netbsd*)
+	;;
+      osf3* | osf4* | osf5*)
+	case $cc_basename in
+	  KCC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+	    ;;
+	  RCC*)
+	    # Rational C++ 2.4.1
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  cxx*)
+	    # Digital/Compaq C++
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      psos*)
+	;;
+      solaris*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	    ;;
+	  gcx*)
+	    # Green Hills C++ Compiler
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sunos4*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.x
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	  lcc*)
+	    # Lucid
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      tandem*)
+	case $cc_basename in
+	  NCC*)
+	    # NonStop-UX NCC 3.20
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	esac
+	;;
+      vxworks*)
+	;;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+	;;
+    esac
+  fi
+],
+[
+  if test "$GCC" = yes; then
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | 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).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	;;
+      esac
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      else
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | cygwin* | 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).
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC (with -KPIC) is the default.
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    newsos6)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc*)
+	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      ccc*)
+        _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+        # All Alpha code is PIC.
+        _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+        ;;
+      *)
+        case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # All OSF/1 code is PIC.
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    rdos*)
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    solaris*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    unicos*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+
+    uts4*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+    esac
+  fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+  AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1),
+    [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+    [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+     "" | " "*) ;;
+     *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+     esac],
+    [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+     _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+    ;;
+  *)
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+    ;;
+esac
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+  _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+  $lt_tmp_static_flag,
+  [],
+  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+])
+
+
+# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+# ------------------------------------
+# See if the linker supports building shared libraries.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ifelse([$1],[CXX],[
+  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix[[4-9]]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+    else
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+  ;;
+  cygwin* | mingw*)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+  ;;
+  *)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+],[
+  runpath_var=
+  _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+  _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_AC_TAGVAR(archive_cmds, $1)=
+  _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+  _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+  _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+  _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+  _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+  _LT_AC_TAGVAR(module_cmds, $1)=
+  _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+  _LT_AC_TAGVAR(always_export_symbols, $1)=no
+  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$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
+  _LT_AC_TAGVAR(include_expsyms, $1)=
+  # exclude_expsyms can be an extended regexp 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'.
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+  # 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.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  _LT_CC_BASENAME([$compiler])
+  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
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[[3-9]]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	_LT_AC_TAGVAR(ld_shlibs, $1)=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
+      fi
+      ;;
+
+    amigaos*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$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)'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+
+      # Samuel A. Falvo II <kc5tja@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't use
+      # them.
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+      # as there is no search path for DLLs.
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(always_export_symbols, $1)=no
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    interix[[3-9]]*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | k*bsd*-gnu)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	tmp_addflag=
+	case $cc_basename,$host_cpu in
+	pgcc*)				# Portland Group C compiler
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	*)
+	  tmp_sharedflag='-shared' ;;
+	esac
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+	if test $supports_anon_versioning = yes; then
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+	  $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	fi
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+	_LT_AC_TAGVAR(ld_shlibs, $1)=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 | grep ': supported targets:.* elf' > /dev/null; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+	  else
+	    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+
+    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
+      runpath_var=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$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.
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	_LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+      fi
+      ;;
+
+    aix[[4-9]]*)
+      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
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+	  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+	else
+	  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+	fi
+	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]].*|aix[[5-9]]*)
+	  for ld_flag in $LDFLAGS; do
+  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+  	    aix_use_runtimelinking=yes
+  	    break
+  	  fi
+	  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.
+
+      _LT_AC_TAGVAR(archive_cmds, $1)=''
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[[012]]|aix4.[[012]].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" && \
+  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	  then
+  	  # We have reworked collect2
+  	  :
+	  else
+  	  # We have old collect2
+  	  _LT_AC_TAGVAR(hardcode_direct, $1)=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
+  	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+  	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+  	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+  	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-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 does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      _LT_AC_TAGVAR(always_export_symbols, $1)=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.
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       _LT_AC_SYS_LIBPATH_AIX
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+	if test "$host_cpu" = ia64; then
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	  _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an empty executable.
+	 _LT_AC_SYS_LIBPATH_AIX
+	 _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$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)'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      # see comment about different semantics on the GNU ld section
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    bsdi[[45]]*)
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+      ;;
+
+    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.
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$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.
+      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+      # FIXME: Should let the user specify the lib program.
+      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[[012]])
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[[012]])
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+    if test "$GCC" = yes ; then
+    	output_verbose_link_cmd='echo'
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
+         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    freebsd1*)
+      _LT_AC_TAGVAR(ld_shlibs, $1)=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*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$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'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	_LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+	  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	  ;;
+	*)
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$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'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    newsos6)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+	     _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	     ;;
+	   *)
+	     _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+        fi
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    os2*)
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(archive_cmds, $1)='$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'
+      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$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
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$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
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$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'
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      else
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$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'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$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 ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    solaris*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+	wlarc=''
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$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'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      case $host_os in
+      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+ 	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=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.
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+        ;;
+	motorola)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4.3*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    esac
+  fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+  # Assume -lc should be added
+  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $_LT_AC_TAGVAR(archive_cmds, $1) 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])
+      $rm conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+	pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+        _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+        if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+        then
+	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+        else
+	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+        fi
+        _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+      ;;
+    esac
+  fi
+  ;;
+esac
+])# AC_LIBTOOL_PROG_LD_SHLIBS
+
+
+# _LT_AC_FILE_LTDLL_C
+# -------------------
+# Be careful that the start marker always follows a newline.
+AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+# /* 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 */
+])# _LT_AC_FILE_LTDLL_C
+
+
+# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+# ---------------------------------
+AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
+
+
+# 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])
+
+AC_DEFUN([LT_AC_PROG_GCJ],
+[AC_CHECK_TOOL(GCJ, gcj, no)
+  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+  AC_SUBST(GCJFLAGS)
+])
+
+AC_DEFUN([LT_AC_PROG_RC],
+[AC_CHECK_TOOL(RC, windres, no)
+])
+
+
+# Cheap backport of AS_EXECUTABLE_P and required macros
+# from Autoconf 2.59; we should not use $as_executable_p directly.
+
+# _AS_TEST_PREPARE
+# ----------------
+m4_ifndef([_AS_TEST_PREPARE],
+[m4_defun([_AS_TEST_PREPARE],
+[if test -x / >/dev/null 2>&1; then
+  as_executable_p='test -x'
+else
+  as_executable_p='test -f'
+fi
+])])# _AS_TEST_PREPARE
+
+# AS_EXECUTABLE_P
+# ---------------
+# Check whether a file is executable.
+m4_ifndef([AS_EXECUTABLE_P],
+[m4_defun([AS_EXECUTABLE_P],
+[AS_REQUIRE([_AS_TEST_PREPARE])dnl
+$as_executable_p $1[]dnl
+])])# AS_EXECUTABLE_P
+
+# 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_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if AS_EXECUTABLE_P(["$as_dir/$lt_ac_prog$ac_exec_ext"]); then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007  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.
+
+# 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.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.10'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.10.1], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.10.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005  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.
+
+# 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.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
+# 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.
+
+# serial 8
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+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])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+# 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.
+
+# serial 9
+
+# 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], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$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
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  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
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # 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.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/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=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    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],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --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])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# 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.
+
+#serial 3
+
+# _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.
+  # Grep'ing the whole file is not good either: AIX grep has a line
+  # limit of 2048, but all sed's we know have understand at least 4000.
+  if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+    dirpart=`AS_DIRNAME("$mf")`
+  else
+    continue
+  fi
+  # Extract the definition of DEPDIR, am__include, and am__quote
+  # from the Makefile without running `make'.
+  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  am__include=`sed -n 's/^am__include = //p' < "$mf"`
+  test -z "am__include" && continue
+  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n 's/^U = //p' < "$mf"`
+  # Find all dependency output files, they are included files with
+  # $(DEPDIR) in their names.  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 "
+    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/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"])
+])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008 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.
+
+# serial 13
+
+# 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.
+
+# 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_PREREQ([2.60])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+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
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])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_PROG_INSTALL_SH
+AM_PROG_INSTALL_STRIP
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# 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
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+              [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+	      		     [_AM_PROG_TAR([v7])])])
+_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
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                  [_AM_DEPENDENCIES(OBJC)],
+                  [define([AC_PROG_OBJC],
+                          defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])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],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005  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.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005  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.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes.	            -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005  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.
+
+# serial 3
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo done
+.PHONY: am__doit
+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
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
+# 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.
+
+# serial 5
+
+# 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
+AC_REQUIRE_AUX_FILE([missing])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
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  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.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005  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.
+
+# serial 3
+
+# _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.    -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# 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.
+
+# serial 4
+
+# 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)])
+
+# Copyright (C) 2001, 2003, 2005  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.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# 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="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006  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.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  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.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/cmake/COPYING-CMAKE-SCRIPTS	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products 
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/cmake/FindPackageHandleStandardArgs.cmake	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,58 @@
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... )
+#    This macro is intended to be used in FindXXX.cmake modules files.
+#    It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and
+#    it also sets the <UPPERCASED_NAME>_FOUND variable.
+#    The package is found if all variables listed are TRUE.
+#    Example:
+#
+#    FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
+#
+#    LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and 
+#    LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
+#    If it is not found and REQUIRED was used, it fails with FATAL_ERROR, 
+#    independent whether QUIET was used or not.
+#    If it is found, the location is reported using the VAR1 argument, so 
+#    here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out.
+#    If the second argument is DEFAULT_MSG, the message in the failure case will 
+#    be "Could NOT find LibXml2", if you don't like this message you can specify
+#    your own custom failure message there.
+
+MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 )
+
+  IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
+    IF (${_NAME}_FIND_REQUIRED)
+      SET(_FAIL_MESSAGE "Could not find REQUIRED package ${_NAME}")
+    ELSE (${_NAME}_FIND_REQUIRED)
+      SET(_FAIL_MESSAGE "Could not find OPTIONAL package ${_NAME}")
+    ENDIF (${_NAME}_FIND_REQUIRED)
+  ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
+    SET(_FAIL_MESSAGE "${_FAIL_MSG}")
+  ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
+
+  STRING(TOUPPER ${_NAME} _NAME_UPPER)
+
+  SET(${_NAME_UPPER}_FOUND TRUE)
+  IF(NOT ${_VAR1})
+    SET(${_NAME_UPPER}_FOUND FALSE)
+  ENDIF(NOT ${_VAR1})
+
+  FOREACH(_CURRENT_VAR ${ARGN})
+    IF(NOT ${_CURRENT_VAR})
+      SET(${_NAME_UPPER}_FOUND FALSE)
+    ENDIF(NOT ${_CURRENT_VAR})
+  ENDFOREACH(_CURRENT_VAR)
+
+  IF (${_NAME_UPPER}_FOUND)
+    IF (NOT ${_NAME}_FIND_QUIETLY)
+        MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}")
+    ENDIF (NOT ${_NAME}_FIND_QUIETLY)
+  ELSE (${_NAME_UPPER}_FOUND)
+    IF (${_NAME}_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}")
+    ELSE (${_NAME}_FIND_REQUIRED)
+      IF (NOT ${_NAME}_FIND_QUIETLY)
+        MESSAGE(STATUS "${_FAIL_MESSAGE}")
+      ENDIF (NOT ${_NAME}_FIND_QUIETLY)
+    ENDIF (${_NAME}_FIND_REQUIRED)
+  ENDIF (${_NAME_UPPER}_FOUND)
+ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/cmake/FindReadline.cmake	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+# from http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/FindReadline.cmake
+# http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/COPYING-CMAKE-SCRIPTS
+# --> BSD licensed
+#
+# GNU Readline library finder
+if(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY)
+  set(READLINE_FOUND TRUE)
+else(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY)
+  FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h
+    /usr/include/readline
+  )
+  
+# 2008-04-22 The next clause used to read like this:
+#
+#  FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
+#        FIND_LIBRARY(NCURSES_LIBRARY NAMES ncurses )
+#        include(FindPackageHandleStandardArgs)
+#        FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG NCURSES_LIBRARY READLINE_INCLUDE_DIR READLINE_LIBRARY )
+#
+# I was advised to modify it such that it will find an ncurses library if
+# required, but not if one was explicitly given, that is, it allows the
+# default to be overridden. PH 
+
+  FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
+        include(FindPackageHandleStandardArgs)
+        FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY )
+
+  MARK_AS_ADVANCED(READLINE_INCLUDE_DIR READLINE_LIBRARY)
+endif(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/config-cmake.h.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,44 @@
+/* config.h for CMake builds */
+
+#cmakedefine HAVE_DIRENT_H 1
+#cmakedefine HAVE_SYS_STAT_H 1
+#cmakedefine HAVE_SYS_TYPES_H 1
+#cmakedefine HAVE_UNISTD_H 1
+#cmakedefine HAVE_WINDOWS_H 1
+
+#cmakedefine HAVE_TYPE_TRAITS_H 1
+#cmakedefine HAVE_BITS_TYPE_TRAITS_H 1
+
+#cmakedefine HAVE_BCOPY 1
+#cmakedefine HAVE_MEMMOVE 1
+#cmakedefine HAVE_STRERROR 1
+#cmakedefine HAVE_STRTOLL 1
+#cmakedefine HAVE_STRTOQ 1
+#cmakedefine HAVE__STRTOI64 1
+
+#cmakedefine PCRE_STATIC 1
+
+#cmakedefine SUPPORT_UTF8 1
+#cmakedefine SUPPORT_UCP 1
+#cmakedefine EBCDIC 1
+#cmakedefine BSR_ANYCRLF 1
+#cmakedefine NO_RECURSE 1
+
+#cmakedefine HAVE_LONG_LONG 1
+#cmakedefine HAVE_UNSIGNED_LONG_LONG 1
+
+#cmakedefine SUPPORT_LIBBZ2 1
+#cmakedefine SUPPORT_LIBZ 1
+#cmakedefine SUPPORT_LIBREADLINE 1
+
+#define NEWLINE			@NEWLINE@
+#define POSIX_MALLOC_THRESHOLD	@PCRE_POSIX_MALLOC_THRESHOLD@
+#define LINK_SIZE		@PCRE_LINK_SIZE@
+#define MATCH_LIMIT		@PCRE_MATCH_LIMIT@
+#define MATCH_LIMIT_RECURSION	@PCRE_MATCH_LIMIT_RECURSION@
+
+
+#define MAX_NAME_SIZE	32
+#define MAX_NAME_COUNT	10000
+
+/* end config.h for CMake builds */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/config.guess	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1545 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
+
+timestamp='2008-01-23'
+
+# 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., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, 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 Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# 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@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 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 ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # 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
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+	for c in cc gcc c89 c99 ; do
+	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
+	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 ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@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
+
+if [ "${UNAME_SYSTEM}" = "Linux" ] ; then
+	eval $set_cc_for_build
+	cat << EOF > $dummy.c
+	#include <features.h>
+	#ifdef __UCLIBC__
+	# ifdef __UCLIBC_CONFIG_VERSION__
+	LIBC=uclibc __UCLIBC_CONFIG_VERSION__
+	# else
+	LIBC=uclibc
+	# endif
+	#else
+	LIBC=gnu
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep LIBC= | sed -e 's: ::g'`
+fi
+
+# 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.
+	#
+	# Note: NetBSD doesn't particularly care about the vendor
+	# portion of the name.  We always set it to "unknown".
+	sysctl="sysctl -n hw.machine_arch"
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	case "${UNAME_MACHINE_ARCH}" in
+	    armeb) machine=armeb-unknown ;;
+	    arm*) machine=arm-unknown ;;
+	    sh3el) machine=shl-unknown ;;
+	    sh3eb) machine=sh-unknown ;;
+	    sh5el) machine=sh5le-unknown ;;
+	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE_ARCH}" in
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+		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
+	# Debian GNU/NetBSD machines have a different userland, and
+	# thus, need a distinct triplet. However, they do not need
+	# kernel version information, so it can be replaced with a
+	# suitable tag, in the style of linux-gnu.
+	case "${UNAME_VERSION}" in
+	    Debian*)
+		release='-gnu'
+		;;
+	    *)
+		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		;;
+	esac
+	# 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 ;;
+    *:OpenBSD:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+	exit ;;
+    *:ekkoBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+	exit ;;
+    *:SolidBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+	exit ;;
+    macppc:MirBSD:*:*)
+	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    *:MirBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    alpha:OSF1:*:*)
+	case $UNAME_RELEASE in
+	*4.0)
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+		;;
+	*5.*)
+	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		;;
+	esac
+	# According to Compaq, /usr/sbin/psrinfo has been available on
+	# OSF/1 and Tru64 systems produced since 1995.  I hope that
+	# covers most systems running today.  This code pipes the CPU
+	# types through head -n 1, so we only detect the type of CPU 0.
+	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+	case "$ALPHA_CPU_TYPE" in
+	    "EV4 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV4.5 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "LCA4 (21066/21068)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV5 (21164)")
+		UNAME_MACHINE="alphaev5" ;;
+	    "EV5.6 (21164A)")
+		UNAME_MACHINE="alphaev56" ;;
+	    "EV5.6 (21164PC)")
+		UNAME_MACHINE="alphapca56" ;;
+	    "EV5.7 (21164PC)")
+		UNAME_MACHINE="alphapca57" ;;
+	    "EV6 (21264)")
+		UNAME_MACHINE="alphaev6" ;;
+	    "EV6.7 (21264A)")
+		UNAME_MACHINE="alphaev67" ;;
+	    "EV6.8CB (21264C)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8AL (21264B)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8CX (21264D)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.9A (21264/EV69A)")
+		UNAME_MACHINE="alphaev69" ;;
+	    "EV7 (21364)")
+		UNAME_MACHINE="alphaev7" ;;
+	    "EV7.9 (21364A)")
+		UNAME_MACHINE="alphaev79" ;;
+	esac
+	# A Pn.n version is a patched version.
+	# 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.
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit ;;
+    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 ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-unknown-sysv4
+	exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-morphos
+	exit ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit ;;
+    *:z/VM:*:*)
+	echo s390-ibm-zvmoe
+	exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+	exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+	echo arm-unknown-riscos
+	exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee@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 ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit ;;
+    DRS?6000:unix:4.0:6*)
+	echo sparc-icl-nx6
+	exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+	case `/usr/bin/uname -p` in
+	    sparc) echo sparc-icl-nx7; exit ;;
+	esac ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    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 ;;
+    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 ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(sed 1q /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 ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit ;;
+    # 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 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+	echo m68k-apple-machten${UNAME_RELEASE}
+	exit ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit ;;
+    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 -o $dummy $dummy.c &&
+	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+	  SYSTEM_NAME=`$dummy $dummyarg` &&
+	    { echo "$SYSTEM_NAME"; exit; }
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit ;;
+    Motorola:PowerMAX_OS:*:*)
+	echo powerpc-motorola-powermax
+	exit ;;
+    Motorola:*:4.3:PL8-*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit ;;
+    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 ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit ;;
+    ????????: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 ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+	echo i386-ibm-aix
+	exit ;;
+    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 ;;
+    *: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
+		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+		then
+			echo "$SYSTEM_NAME"
+		else
+			echo rs6000-ibm-aix3.2.5
+		fi
+	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 ;;
+    *:AIX:*:[456])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | 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 ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit ;;
+    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])
+		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" ;;
+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+		fi
+		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 -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+		    test -z "$HP_ARCH" && HP_ARCH=hppa
+		fi ;;
+	esac
+	if [ ${HP_ARCH} = "hppa2.0w" ]
+	then
+	    eval $set_cc_for_build
+
+	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+	    # generating 64-bit code.  GNU and HP use different nomenclature:
+	    #
+	    # $ CC_FOR_BUILD=cc ./config.guess
+	    # => hppa2.0w-hp-hpux11.23
+	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+	    # => hppa64-hp-hpux11.23
+
+	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+		grep __LP64__ >/dev/null
+	    then
+		HP_ARCH="hppa2.0w"
+	    else
+		HP_ARCH="hppa64"
+	    fi
+	fi
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit ;;
+    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 -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+		{ echo "$SYSTEM_NAME"; exit; }
+	echo unknown-hitachi-hiuxwe2
+	exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit ;;
+    i*86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-unknown-osf1
+	fi
+	exit ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    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 ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    *:UNICOS/mp:*:*)
+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    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 ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:FreeBSD:*:*)
+	case ${UNAME_MACHINE} in
+	    pc98)
+		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    amd64)
+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    *)
+		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	esac
+	exit ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit ;;
+    *:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit ;;
+    i*:windows32*:*)
+    	# uname -m includes "-pc" on this system.
+    	echo ${UNAME_MACHINE}-mingw32
+	exit ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit ;;
+    *:Interix*:[3456]*)
+    	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    EM64T | authenticamd)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+	echo i${UNAME_MACHINE}-pc-mks
+	exit ;;
+    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 i586-pc-interix
+	exit ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+	echo x86_64-unknown-cygwin
+	exit ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-unknown-cygwin
+	exit ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    *:GNU:*:*)
+	# the GNU system
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit ;;
+    *:GNU/*:*:*)
+	# other systems with GNU libc and userland
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	exit ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit ;;
+    arm*:Linux:*:*)
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	else
+	    echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+	fi
+	exit ;;
+    avr32*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    cris:Linux:*:*)
+	echo cris-axis-linux-${LIBC}
+	exit ;;
+    crisv32:Linux:*:*)
+	echo crisv32-axis-linux-${LIBC}
+	exit ;;
+    frv:Linux:*:*)
+    	echo frv-unknown-linux-${LIBC}
+	exit ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    mips:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef mips
+	#undef mipsel
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mipsel
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=mips
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+	;;
+    mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef mips64
+	#undef mips64el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mips64el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=mips64
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+	;;
+    or32:Linux:*:*)
+	echo or32-unknown-linux-${LIBC}
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-${LIBC}
+	exit ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-${LIBC}
+	exit ;;
+    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="gnulibc1" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    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-${LIBC} ;;
+	  PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+	  *)    echo hppa-unknown-linux-${LIBC} ;;
+	esac
+	exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-${LIBC}
+	exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux
+	exit ;;
+    sh64*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    vax:Linux:*:*)
+	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+	exit ;;
+    x86_64:Linux:*:*)
+	echo x86_64-unknown-linux-${LIBC}
+	exit ;;
+    xtensa*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    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.
+	# Set LC_ALL=C to ensure ld outputs messages in English.
+	ld_supported_targets=`cd /; LC_ALL=C 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-${LIBC}"
+		;;
+	  a.out-i386-linux)
+		echo "${UNAME_MACHINE}-pc-linux-${LIBC}aout"
+		exit ;;
+	  coff-i386)
+		echo "${UNAME_MACHINE}-pc-linux-${LIBC}coff"
+		exit ;;
+	  "")
+		# Either a pre-BFD a.out linker (linux-gnuoldld) or
+		# one that does not give us useful --help.
+		echo "${UNAME_MACHINE}-pc-linux-${LIBC}oldld"
+		exit ;;
+	esac
+	# This should get integrated into the C code below, but now we hack
+	if [ "$LIBC" != "gnu" ] ; then echo "$TENTATIVE" && exit 0 ; fi
+	# Determine whether the default compiler is a.out or elf
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <features.h>
+	#ifdef __ELF__
+	# ifdef __GLIBC__
+	#  if __GLIBC__ >= 2
+	LIBC=gnu
+	#  else
+	LIBC=gnulibc1
+	#  endif
+	# else
+	LIBC=gnulibc1
+	# endif
+	#else
+	#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+	LIBC=gnu
+	#else
+	LIBC=gnuaout
+	#endif
+	#endif
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^LIBC/{
+		s: ::g
+		p
+	    }'`"
+	test x"${LIBC}" != x && {
+		echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+		exit
+	}
+	test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+	;;
+    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 ;;
+    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 ;;
+    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 ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-unknown-stop
+	exit ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-unknown-atheos
+	exit ;;
+    i*86:syllable:*:*)
+	echo ${UNAME_MACHINE}-pc-syllable
+	exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    i*86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit ;;
+    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 ;;
+    i*86:*:5:[678]*)
+    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	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 ;;
+    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|grep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit ;;
+    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 ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit ;;
+    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 ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+	echo m68k-convergent-sysv
+	exit ;;
+    M680?0:D-NIX:5.3:*)
+	echo m68k-diab-dnix
+	exit ;;
+    M68*:*:R3V[5678]*:*)
+	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*: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; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    rs6000:LynxOS:2.*:*)
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    *: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 ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes@openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit ;;
+    *:*:*:FTX*)
+	# From seanf@swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit ;;
+    i*86:VOS:*:*)
+	# From Paul.Green@stratus.com.
+	echo ${UNAME_MACHINE}-stratus-vos
+	exit ;;
+    *:VOS:*:*)
+	# From Paul.Green@stratus.com.
+	echo hppa1.1-stratus-vos
+	exit ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit ;;
+    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 ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-6:SUPER-UX:*:*)
+	echo sx6-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-7:SUPER-UX:*:*)
+	echo sx7-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8:SUPER-UX:*:*)
+	echo sx8-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-nec-superux${UNAME_RELEASE}
+	exit ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Darwin:*:*)
+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+	case $UNAME_PROCESSOR in
+	    unknown) UNAME_PROCESSOR=powerpc ;;
+	esac
+	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+	exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	UNAME_PROCESSOR=`uname -p`
+	if test "$UNAME_PROCESSOR" = "x86"; then
+		UNAME_PROCESSOR=i386
+		UNAME_MACHINE=pc
+	fi
+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+	exit ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+	echo nse-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit ;;
+    *: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 ;;
+    *:TOPS-10:*:*)
+	echo pdp10-unknown-tops10
+	exit ;;
+    *:TENEX:*:*)
+	echo pdp10-unknown-tenex
+	exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+	echo pdp10-dec-tops20
+	exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+	echo pdp10-xkl-tops20
+	exit ;;
+    *:TOPS-20:*:*)
+	echo pdp10-unknown-tops20
+	exit ;;
+    *:ITS:*:*)
+	echo pdp10-unknown-its
+	exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+	exit ;;
+    *:DragonFly:*:*)
+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit ;;
+    *:*VMS:*:*)
+    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	case "${UNAME_MACHINE}" in
+	    A*) echo alpha-dec-vms ; exit ;;
+	    I*) echo ia64-dec-vms ; exit ;;
+	    V*) echo vax-dec-vms ; exit ;;
+	esac ;;
+    *:XENIX:*:SysV)
+	echo i386-pc-xenix
+	exit ;;
+    i*86:skyos:*:*)
+	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+	exit ;;
+    i*86:rdos:*:*)
+	echo ${UNAME_MACHINE}-pc-rdos
+	exit ;;
+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\n"); 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 -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+	{ echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# 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 ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit ;;
+    c34*)
+	echo c34-convex-bsd
+	exit ;;
+    c38*)
+	echo c38-convex-bsd
+	exit ;;
+    c4*)
+	echo c4-convex-bsd
+	exit ;;
+    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
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+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@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:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/config.h.generic	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,307 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+
+/* On Unix-like systems config.h.in is converted by "configure" into config.h.
+Some other environments also support the use of "configure". PCRE is written in
+Standard C, but there are a few non-standard things it can cope with, allowing
+it to run on SunOS4 and other "close to standard" systems.
+
+If you are going to build PCRE "by hand" on a system without "configure" you
+should copy the distributed config.h.generic to config.h, and then set up the
+macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to
+all of your compile commands, so that config.h is included at the start of
+every source.
+
+Alternatively, you can avoid editing by using -D on the compiler command line
+to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H.
+
+PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
+HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
+them both to 0; an emulation function will be used. */
+
+/* By default, the \R escape sequence matches any Unicode line ending
+   character or sequence of characters. If BSR_ANYCRLF is defined, this is
+   changed so that backslash-R matches only CR, LF, or CRLF. The build- time
+   default can be overridden by the user of PCRE at runtime. On systems that
+   support it, "configure" can be used to override the default. */
+/* #undef BSR_ANYCRLF */
+
+/* If you are compiling for a system that uses EBCDIC instead of ASCII
+   character codes, define this macro as 1. On systems that can use
+   "configure", this can be done via --enable-ebcdic. */
+/* #undef EBCDIC */
+
+/* Define to 1 if you have the `bcopy' function. */
+#ifndef HAVE_BCOPY
+#define HAVE_BCOPY 1
+#endif
+
+/* Define to 1 if you have the <bits/type_traits.h> header file. */
+/* #undef HAVE_BITS_TYPE_TRAITS_H */
+
+/* Define to 1 if you have the <bzlib.h> header file. */
+#ifndef HAVE_BZLIB_H
+#define HAVE_BZLIB_H 1
+#endif
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#ifndef HAVE_DIRENT_H
+#define HAVE_DIRENT_H 1
+#endif
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#ifndef HAVE_DLFCN_H
+#define HAVE_DLFCN_H 1
+#endif
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#ifndef HAVE_INTTYPES_H
+#define HAVE_INTTYPES_H 1
+#endif
+
+/* Define to 1 if you have the <limits.h> header file. */
+#ifndef HAVE_LIMITS_H
+#define HAVE_LIMITS_H 1
+#endif
+
+/* Define to 1 if the system has the type `long long'. */
+#ifndef HAVE_LONG_LONG
+#define HAVE_LONG_LONG 1
+#endif
+
+/* Define to 1 if you have the `memmove' function. */
+#ifndef HAVE_MEMMOVE
+#define HAVE_MEMMOVE 1
+#endif
+
+/* Define to 1 if you have the <memory.h> header file. */
+#ifndef HAVE_MEMORY_H
+#define HAVE_MEMORY_H 1
+#endif
+
+/* Define to 1 if you have the <readline/history.h> header file. */
+#ifndef HAVE_READLINE_HISTORY_H
+#define HAVE_READLINE_HISTORY_H 1
+#endif
+
+/* Define to 1 if you have the <readline/readline.h> header file. */
+#ifndef HAVE_READLINE_READLINE_H
+#define HAVE_READLINE_READLINE_H 1
+#endif
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H 1
+#endif
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#ifndef HAVE_STDLIB_H
+#define HAVE_STDLIB_H 1
+#endif
+
+/* Define to 1 if you have the `strerror' function. */
+#ifndef HAVE_STRERROR
+#define HAVE_STRERROR 1
+#endif
+
+/* Define to 1 if you have the <string> header file. */
+#ifndef HAVE_STRING
+#define HAVE_STRING 1
+#endif
+
+/* Define to 1 if you have the <strings.h> header file. */
+#ifndef HAVE_STRINGS_H
+#define HAVE_STRINGS_H 1
+#endif
+
+/* Define to 1 if you have the <string.h> header file. */
+#ifndef HAVE_STRING_H
+#define HAVE_STRING_H 1
+#endif
+
+/* Define to 1 if you have the `strtoll' function. */
+/* #undef HAVE_STRTOLL */
+
+/* Define to 1 if you have the `strtoq' function. */
+#ifndef HAVE_STRTOQ
+#define HAVE_STRTOQ 1
+#endif
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#ifndef HAVE_SYS_STAT_H
+#define HAVE_SYS_STAT_H 1
+#endif
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#ifndef HAVE_SYS_TYPES_H
+#define HAVE_SYS_TYPES_H 1
+#endif
+
+/* Define to 1 if you have the <type_traits.h> header file. */
+/* #undef HAVE_TYPE_TRAITS_H */
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#ifndef HAVE_UNISTD_H
+#define HAVE_UNISTD_H 1
+#endif
+
+/* Define to 1 if the system has the type `unsigned long long'. */
+#ifndef HAVE_UNSIGNED_LONG_LONG
+#define HAVE_UNSIGNED_LONG_LONG 1
+#endif
+
+/* Define to 1 if you have the <windows.h> header file. */
+/* #undef HAVE_WINDOWS_H */
+
+/* Define to 1 if you have the <zlib.h> header file. */
+#ifndef HAVE_ZLIB_H
+#define HAVE_ZLIB_H 1
+#endif
+
+/* Define to 1 if you have the `_strtoi64' function. */
+/* #undef HAVE__STRTOI64 */
+
+/* The value of LINK_SIZE determines the number of bytes used to store links
+   as offsets within the compiled regex. The default is 2, which allows for
+   compiled patterns up to 64K long. This covers the vast majority of cases.
+   However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows
+   for longer patterns in extreme cases. On systems that support it,
+   "configure" can be used to override this default. */
+#ifndef LINK_SIZE
+#define LINK_SIZE 2
+#endif
+
+/* The value of MATCH_LIMIT determines the default number of times the
+   internal match() function can be called during a single execution of
+   pcre_exec(). There is a runtime interface for setting a different limit.
+   The limit exists in order to catch runaway regular expressions that take
+   for ever to determine that they do not match. The default is set very large
+   so that it does not accidentally catch legitimate cases. On systems that
+   support it, "configure" can be used to override this default default. */
+#ifndef MATCH_LIMIT
+#define MATCH_LIMIT 10000000
+#endif
+
+/* The above limit applies to all calls of match(), whether or not they
+   increase the recursion depth. In some environments it is desirable to limit
+   the depth of recursive calls of match() more strictly, in order to restrict
+   the maximum amount of stack (or heap, if NO_RECURSE is defined) that is
+   used. The value of MATCH_LIMIT_RECURSION applies only to recursive calls of
+   match(). To have any useful effect, it must be less than the value of
+   MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT. There is
+   a runtime method for setting a different limit. On systems that support it,
+   "configure" can be used to override the default. */
+#ifndef MATCH_LIMIT_RECURSION
+#define MATCH_LIMIT_RECURSION MATCH_LIMIT
+#endif
+
+/* This limit is parameterized just in case anybody ever wants to change it.
+   Care must be taken if it is increased, because it guards against integer
+   overflow caused by enormously large patterns. */
+#ifndef MAX_NAME_COUNT
+#define MAX_NAME_COUNT 10000
+#endif
+
+/* This limit is parameterized just in case anybody ever wants to change it.
+   Care must be taken if it is increased, because it guards against integer
+   overflow caused by enormously large patterns. */
+#ifndef MAX_NAME_SIZE
+#define MAX_NAME_SIZE 32
+#endif
+
+/* The value of NEWLINE determines the newline character sequence. On systems
+   that support it, "configure" can be used to override the default, which is
+   10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or -2
+   (ANYCRLF). */
+#ifndef NEWLINE
+#define NEWLINE 10
+#endif
+
+/* PCRE uses recursive function calls to handle backtracking while matching.
+   This can sometimes be a problem on systems that have stacks of limited
+   size. Define NO_RECURSE to get a version that doesn't use recursion in the
+   match() function; instead it creates its own stack by steam using
+   pcre_recurse_malloc() to obtain memory from the heap. For more detail, see
+   the comments and other stuff just above the match() function. On systems
+   that support it, "configure" can be used to set this in the Makefile (use
+   --disable-stack-for-recursion). */
+/* #undef NO_RECURSE */
+
+/* Name of package */
+#define PACKAGE "pcre"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "PCRE"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "PCRE 7.8"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "pcre"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "7.8"
+
+
+/* If you are compiling for a system other than a Unix-like system or
+   Win32, and it needs some magic to be inserted before the definition
+   of a function that is exported by the library, define this macro to
+   contain the relevant magic. If you do not define this macro, it
+   defaults to "extern" for a C compiler and "extern C" for a C++
+   compiler on non-Win32 systems. This macro apears at the start of
+   every exported function that is part of the external API. It does
+   not appear on functions that are "external" in the C sense, but
+   which are internal to the library. */
+/* #undef PCRE_EXP_DEFN */
+
+/* Define if linking statically (TODO: make nice with Libtool) */
+/* #undef PCRE_STATIC */
+
+/* When calling PCRE via the POSIX interface, additional working storage is
+   required for holding the pointers to capturing substrings because PCRE
+   requires three integers per substring, whereas the POSIX interface provides
+   only two. If the number of expected substrings is small, the wrapper
+   function uses space on the stack, because this is faster than using
+   malloc() for each call. The threshold above which the stack is no longer
+   used is defined by POSIX_MALLOC_THRESHOLD. On systems that support it,
+   "configure" can be used to override this default. */
+#ifndef POSIX_MALLOC_THRESHOLD
+#define POSIX_MALLOC_THRESHOLD 10
+#endif
+
+/* Define to 1 if you have the ANSI C header files. */
+#ifndef STDC_HEADERS
+#define STDC_HEADERS 1
+#endif
+
+/* Define to allow pcregrep to be linked with libbz2, so that it is able to
+   handle .bz2 files. */
+/* #undef SUPPORT_LIBBZ2 */
+
+/* Define to allow pcretest to be linked with libreadline. */
+/* #undef SUPPORT_LIBREADLINE */
+
+/* Define to allow pcregrep to be linked with libz, so that it is able to
+   handle .gz files. */
+/* #undef SUPPORT_LIBZ */
+
+/* Define to enable support for Unicode properties */
+/* #undef SUPPORT_UCP */
+
+/* Define to enable support for the UTF-8 Unicode encoding. */
+/* #undef SUPPORT_UTF8 */
+
+/* Version number of package */
+#ifndef VERSION
+#define VERSION "7.8"
+#endif
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/config.h.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,242 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+
+/* On Unix-like systems config.h.in is converted by "configure" into config.h.
+Some other environments also support the use of "configure". PCRE is written in
+Standard C, but there are a few non-standard things it can cope with, allowing
+it to run on SunOS4 and other "close to standard" systems.
+
+If you are going to build PCRE "by hand" on a system without "configure" you
+should copy the distributed config.h.generic to config.h, and then set up the
+macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to
+all of your compile commands, so that config.h is included at the start of
+every source.
+
+Alternatively, you can avoid editing by using -D on the compiler command line
+to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H.
+
+PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
+HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
+them both to 0; an emulation function will be used. */
+
+/* By default, the \R escape sequence matches any Unicode line ending
+   character or sequence of characters. If BSR_ANYCRLF is defined, this is
+   changed so that backslash-R matches only CR, LF, or CRLF. The build- time
+   default can be overridden by the user of PCRE at runtime. On systems that
+   support it, "configure" can be used to override the default. */
+#undef BSR_ANYCRLF
+
+/* If you are compiling for a system that uses EBCDIC instead of ASCII
+   character codes, define this macro as 1. On systems that can use
+   "configure", this can be done via --enable-ebcdic. */
+#undef EBCDIC
+
+/* Define to 1 if you have the `bcopy' function. */
+#undef HAVE_BCOPY
+
+/* Define to 1 if you have the <bits/type_traits.h> header file. */
+#undef HAVE_BITS_TYPE_TRAITS_H
+
+/* Define to 1 if you have the <bzlib.h> header file. */
+#undef HAVE_BZLIB_H
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if the system has the type `long long'. */
+#undef HAVE_LONG_LONG
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <readline/history.h> header file. */
+#undef HAVE_READLINE_HISTORY_H
+
+/* Define to 1 if you have the <readline/readline.h> header file. */
+#undef HAVE_READLINE_READLINE_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 `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the <string> header file. */
+#undef HAVE_STRING
+
+/* 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 `strtoll' function. */
+#undef HAVE_STRTOLL
+
+/* Define to 1 if you have the `strtoq' function. */
+#undef HAVE_STRTOQ
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <type_traits.h> header file. */
+#undef HAVE_TYPE_TRAITS_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if the system has the type `unsigned long long'. */
+#undef HAVE_UNSIGNED_LONG_LONG
+
+/* Define to 1 if you have the <windows.h> header file. */
+#undef HAVE_WINDOWS_H
+
+/* Define to 1 if you have the <zlib.h> header file. */
+#undef HAVE_ZLIB_H
+
+/* Define to 1 if you have the `_strtoi64' function. */
+#undef HAVE__STRTOI64
+
+/* The value of LINK_SIZE determines the number of bytes used to store links
+   as offsets within the compiled regex. The default is 2, which allows for
+   compiled patterns up to 64K long. This covers the vast majority of cases.
+   However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows
+   for longer patterns in extreme cases. On systems that support it,
+   "configure" can be used to override this default. */
+#undef LINK_SIZE
+
+/* The value of MATCH_LIMIT determines the default number of times the
+   internal match() function can be called during a single execution of
+   pcre_exec(). There is a runtime interface for setting a different limit.
+   The limit exists in order to catch runaway regular expressions that take
+   for ever to determine that they do not match. The default is set very large
+   so that it does not accidentally catch legitimate cases. On systems that
+   support it, "configure" can be used to override this default default. */
+#undef MATCH_LIMIT
+
+/* The above limit applies to all calls of match(), whether or not they
+   increase the recursion depth. In some environments it is desirable to limit
+   the depth of recursive calls of match() more strictly, in order to restrict
+   the maximum amount of stack (or heap, if NO_RECURSE is defined) that is
+   used. The value of MATCH_LIMIT_RECURSION applies only to recursive calls of
+   match(). To have any useful effect, it must be less than the value of
+   MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT. There is
+   a runtime method for setting a different limit. On systems that support it,
+   "configure" can be used to override the default. */
+#undef MATCH_LIMIT_RECURSION
+
+/* This limit is parameterized just in case anybody ever wants to change it.
+   Care must be taken if it is increased, because it guards against integer
+   overflow caused by enormously large patterns. */
+#undef MAX_NAME_COUNT
+
+/* This limit is parameterized just in case anybody ever wants to change it.
+   Care must be taken if it is increased, because it guards against integer
+   overflow caused by enormously large patterns. */
+#undef MAX_NAME_SIZE
+
+/* The value of NEWLINE determines the newline character sequence. On systems
+   that support it, "configure" can be used to override the default, which is
+   10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), -1 (ANY), or -2
+   (ANYCRLF). */
+#undef NEWLINE
+
+/* PCRE uses recursive function calls to handle backtracking while matching.
+   This can sometimes be a problem on systems that have stacks of limited
+   size. Define NO_RECURSE to get a version that doesn't use recursion in the
+   match() function; instead it creates its own stack by steam using
+   pcre_recurse_malloc() to obtain memory from the heap. For more detail, see
+   the comments and other stuff just above the match() function. On systems
+   that support it, "configure" can be used to set this in the Makefile (use
+   --disable-stack-for-recursion). */
+#undef NO_RECURSE
+
+/* 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
+
+
+/* If you are compiling for a system other than a Unix-like system or
+   Win32, and it needs some magic to be inserted before the definition
+   of a function that is exported by the library, define this macro to
+   contain the relevant magic. If you do not define this macro, it
+   defaults to "extern" for a C compiler and "extern C" for a C++
+   compiler on non-Win32 systems. This macro apears at the start of
+   every exported function that is part of the external API. It does
+   not appear on functions that are "external" in the C sense, but
+   which are internal to the library. */
+#undef PCRE_EXP_DEFN
+
+/* Define if linking statically (TODO: make nice with Libtool) */
+#undef PCRE_STATIC
+
+/* When calling PCRE via the POSIX interface, additional working storage is
+   required for holding the pointers to capturing substrings because PCRE
+   requires three integers per substring, whereas the POSIX interface provides
+   only two. If the number of expected substrings is small, the wrapper
+   function uses space on the stack, because this is faster than using
+   malloc() for each call. The threshold above which the stack is no longer
+   used is defined by POSIX_MALLOC_THRESHOLD. On systems that support it,
+   "configure" can be used to override this default. */
+#undef POSIX_MALLOC_THRESHOLD
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to allow pcregrep to be linked with libbz2, so that it is able to
+   handle .bz2 files. */
+#undef SUPPORT_LIBBZ2
+
+/* Define to allow pcretest to be linked with libreadline. */
+#undef SUPPORT_LIBREADLINE
+
+/* Define to allow pcregrep to be linked with libz, so that it is able to
+   handle .gz files. */
+#undef SUPPORT_LIBZ
+
+/* Define to enable support for Unicode properties */
+#undef SUPPORT_UCP
+
+/* Define to enable support for the UTF-8 Unicode encoding. */
+#undef SUPPORT_UTF8
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/config.sub	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1676 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
+
+timestamp='2008-01-16'
+
+# 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., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, 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@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# 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@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 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 ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # 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 ;;
+
+    * )
+       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* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    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 | -knuth | -cray)
+		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
+		;;
+	-sco6)
+		os=-sco5v6
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-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/'`
+		;;
+	-sco5v6*)
+		# 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] \
+	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+	| am33_2.0 \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+	| bfin \
+	| c4x | clipper \
+	| d10v | d30v | dlx | dsp16xx | dvp \
+	| fido | fr30 | frv \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| i370 | i860 | i960 | ia64 \
+	| ip2k | iq2000 \
+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
+	| maxq | mb | microblaze | mcore | mep \
+	| mips | mipsbe | mipseb | mipsel | mipsle \
+	| mips16 \
+	| mips64 | mips64el \
+	| mips64vr | mips64vrel \
+	| mips64orion | mips64orionel \
+	| mips64vr4100 | mips64vr4100el \
+	| mips64vr4300 | mips64vr4300el \
+	| mips64vr5000 | mips64vr5000el \
+	| mips64vr5900 | mips64vr5900el \
+	| mipsisa32 | mipsisa32el \
+	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa64 | mipsisa64el \
+	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64sb1 | mipsisa64sb1el \
+	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipstx39 | mipstx39el \
+	| mn10200 | mn10300 \
+	| mt \
+	| msp430 \
+	| nios | nios2 \
+	| ns16k | ns32k \
+	| or32 \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| pyramid \
+	| score \
+	| sh | sh[1234] | sh[24]a | sh[24]a*eb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh64 | sh64le \
+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+	| spu | strongarm \
+	| tahoe | thumb | tic4x | tic80 | tron \
+	| v850 | v850e \
+	| we32k \
+	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| 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)
+		;;
+	ms1)
+		basic_machine=mt-unknown
+		;;
+
+	# 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]-* \
+	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+	| avr-* | avr32-* \
+	| bfin-* | bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| clipper-* | craynv-* | cydra-* \
+	| d10v-* | d30v-* | dlx-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| ip2k-* | iq2000-* \
+	| m32c-* | m32r-* | m32rle-* \
+	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* \
+	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+	| mips16-* \
+	| mips64-* | mips64el-* \
+	| mips64vr-* | mips64vrel-* \
+	| mips64orion-* | mips64orionel-* \
+	| mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* \
+	| mips64vr5000-* | mips64vr5000el-* \
+	| mips64vr5900-* | mips64vr5900el-* \
+	| mipsisa32-* | mipsisa32el-* \
+	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa64-* | mipsisa64el-* \
+	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64sb1-* | mipsisa64sb1el-* \
+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
+	| mt-* \
+	| msp430-* \
+	| nios-* | nios2-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| pyramid-* \
+	| romp-* | rs6000-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]a*eb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+	| sparclite-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+	| tahoe-* | thumb-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+	| tron-* \
+	| v850-* | v850e-* | vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa*-* \
+	| ymp-* \
+	| z8k-*)
+		;;
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
+		;;
+	# 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
+		;;
+    	abacus)
+		basic_machine=abacus-unknown
+		;;
+	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
+		;;
+	amd64)
+		basic_machine=x86_64-pc
+		;;
+	amd64-*)
+		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	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
+		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	c90)
+		basic_machine=c90-cray
+		os=-unicos
+		;;
+	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 | j90)
+		basic_machine=j90-cray
+		os=-unicos
+		;;
+	craynv)
+		basic_machine=craynv-cray
+		os=-unicosmp
+		;;
+	cr16)
+		basic_machine=cr16-unknown
+		os=-elf
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	crisv32 | crisv32-* | etraxfs*)
+		basic_machine=crisv32-axis
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	crx)
+		basic_machine=crx-unknown
+		os=-elf
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	decsystem10* | dec10*)
+		basic_machine=pdp10-dec
+		os=-tops10
+		;;
+	decsystem20* | dec20*)
+		basic_machine=pdp10-dec
+		os=-tops20
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	djgpp)
+		basic_machine=i586-pc
+		os=-msdosdjgpp
+		;;
+	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
+		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	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
+		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mipsEE* | ee | ps2)
+		basic_machine=mips64r5900el-scei
+		case $os in
+		    -linux*)
+			;;
+		    *)
+			os=-elf
+			;;
+		esac
+		;;
+	iop)
+		basic_machine=mipsel-scei
+		os=-irx
+		;;
+	dvp)
+		basic_machine=dvp-scei
+		os=-elf
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	morphos)
+		basic_machine=powerpc-unknown
+		os=-morphos
+		;;
+	msdos)
+		basic_machine=i386-pc
+		os=-msdos
+		;;
+	ms1-*)
+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		;;
+	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
+		;;
+	openrisc | openrisc-*)
+		basic_machine=or32-unknown
+		;;
+	os400)
+		basic_machine=powerpc-ibm
+		os=-os400
+		;;
+	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
+		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+	pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pc98)
+		basic_machine=i386-pc
+		;;
+	pc98-*)
+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium | p5 | k5 | k6 | nexgen | viac3)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon | athlon_*)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2 | pentiumiii | pentium3)
+		basic_machine=i686-pc
+		;;
+	pentium4)
+		basic_machine=i786-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium4-*)
+		basic_machine=i786-`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
+		;;
+	rdos)
+		basic_machine=i386-pc
+		os=-rdos
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	s390 | s390-*)
+		basic_machine=s390-ibm
+		;;
+	s390x | s390x-*)
+		basic_machine=s390x-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sb1)
+		basic_machine=mipsisa64sb1-unknown
+		;;
+	sb1el)
+		basic_machine=mipsisa64sb1el-unknown
+		;;
+	sde)
+		basic_machine=mipsisa32-sde
+		os=-elf
+		;;
+	sei)
+		basic_machine=mips-sei
+		os=-seiux
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sh5el)
+		basic_machine=sh5le-unknown
+		;;
+	sh64)
+		basic_machine=sh64-unknown
+		;;
+	sparclite-wrs | simso-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=alphaev5-cray
+		os=-unicos
+		;;
+	t90)
+		basic_machine=t90-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tic55x | c55x*)
+		basic_machine=tic55x-unknown
+		os=-coff
+		;;
+	tic6x | c6x*)
+		basic_machine=tic6x-unknown
+		os=-coff
+		;;
+	tile*)
+		basic_machine=tile-unknown
+		os=-linux-gnu
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	toad1)
+		basic_machine=pdp10-xkl
+		os=-tops20
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	tpf)
+		basic_machine=s390x-ibm
+		os=-tpf
+		;;
+	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
+		;;
+	xbox)
+		basic_machine=i686-pc
+		os=-mingw32
+		;;
+	xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	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
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	mmix)
+		basic_machine=mmix-knuth
+		;;
+	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
+		;;
+	sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+		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
+		;;
+	*-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* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -openbsd* | -solidbsd* \
+	      | -ekkobsd* | -kfreebsd* | -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* | -linux-newlib* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -irx*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i*86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto-qnx*)
+		;;
+	-nto*)
+		os=`echo $os | sed -e 's|nto|nto-qnx|'`
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux-dietlibc)
+		os=-linux-dietlibc
+		;;
+	-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
+		;;
+        -os400*)
+		os=-os400
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-atheos*)
+		os=-atheos
+		;;
+	-syllable*)
+		os=-syllable
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-nova*)
+		os=-rtmk-nova
+		;;
+	-ns2 )
+		os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+        -tpf*)
+		os=-tpf
+		;;
+	-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
+		;;
+	-aros*)
+		os=-aros
+		;;
+	-kaos*)
+		os=-kaos
+		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
+	-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
+        score-*)
+		os=-elf
+		;;
+        spu-*)
+		os=-elf
+		;;
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+        c4x-* | tic4x-*)
+        	os=-coff
+		;;
+	# This must come before the *-dec entry.
+	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
+		;;
+        mep-*)
+		os=-elf
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	or32-*)
+		os=-coff
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-haiku)
+		os=-haiku
+		;;
+	*-ibm)
+		os=-aix
+		;;
+    	*-knuth)
+		os=-mmixware
+		;;
+	*-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
+				;;
+			-os400*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-tpf*)
+				vendor=ibm
+				;;
+			-vxsim* | -vxworks* | -windiss*)
+				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
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/configure	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,24388 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.61 for PCRE 7.8.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006 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 more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+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+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# 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
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+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
+IFS=$as_save_IFS
+
+     ;;
+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_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+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 -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; 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'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+if test "x$CONFIG_SHELL" = x; then
+  if (eval ":") 2>/dev/null; then
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+
+  if test $as_have_required = yes && 	 (eval ":
+(as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=\$LINENO
+  as_lineno_2=\$LINENO
+  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+  :
+else
+  as_candidate_shells=
+    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=.
+  case $as_dir in
+	 /*)
+	   for as_base in sh bash ksh sh5; do
+	     as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+	   done;;
+       esac
+done
+IFS=$as_save_IFS
+
+
+      for as_shell in $as_candidate_shells $SHELL; do
+	 # Try only shells that exist, to save several forks.
+	 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		{ ("$as_shell") 2> /dev/null <<\_ASEOF
+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+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+  CONFIG_SHELL=$as_shell
+	       as_have_required=yes
+	       if { "$as_shell" 2> /dev/null <<\_ASEOF
+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+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+  (exit $1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+  break
+fi
+
+fi
+
+      done
+
+      if test "x$CONFIG_SHELL" != x; then
+  for as_var in BASH_ENV ENV
+        do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+        done
+        export CONFIG_SHELL
+        exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+    if test $as_have_required = no; then
+  echo This script requires a shell more modern than all the
+      echo shells that I found on your system.  Please install a
+      echo modern shell, or manually run the script under such a
+      echo shell if you do have one.
+      { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+  echo No shell found that supports shell functions.
+  echo Please tell autoconf@gnu.org about your system,
+  echo including any error possibly output before this
+  echo message
+}
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # 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 after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, 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
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\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 sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir
+fi
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s='ln -s'
+  # ... but there are two gotchas:
+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+  # In both cases, we have to default to `cp -p'.
+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+    as_ln_s='cp -p'
+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$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+        test -d "$1/.";
+      else
+	case $1 in
+        -*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval 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="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+
+# 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.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+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.
+
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    IFS="$lt_save_ifs"
+    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="$lt_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
+
+
+
+
+tagnames=${tagnames+${tagnames},}CXX
+
+tagnames=${tagnames+${tagnames},}F77
+
+exec 7<&0 </dev/null 6>&1
+
+# 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`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Identity of this package.
+PACKAGE_NAME='PCRE'
+PACKAGE_TARNAME='pcre'
+PACKAGE_VERSION='7.8'
+PACKAGE_STRING='PCRE 7.8'
+PACKAGE_BUGREPORT=''
+
+ac_unique_file="pcre.h.in"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef 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
+datarootdir
+datadir
+sysconfdir
+sharedstatedir
+localstatedir
+includedir
+oldincludedir
+docdir
+infodir
+htmldir
+dvidir
+pdfdir
+psdir
+libdir
+localedir
+mandir
+DEFS
+ECHO_C
+ECHO_N
+ECHO_T
+LIBS
+build_alias
+host_alias
+target_alias
+INSTALL_PROGRAM
+INSTALL_SCRIPT
+INSTALL_DATA
+am__isrc
+CYGPATH_W
+PACKAGE
+VERSION
+ACLOCAL
+AUTOCONF
+AUTOMAKE
+AUTOHEADER
+MAKEINFO
+install_sh
+STRIP
+INSTALL_STRIP_PROGRAM
+mkdir_p
+AWK
+SET_MAKE
+am__leading_dot
+AMTAR
+am__tar
+am__untar
+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
+CXX
+CXXFLAGS
+ac_ct_CXX
+CXXDEPMODE
+am__fastdepCXX_TRUE
+am__fastdepCXX_FALSE
+build
+build_cpu
+build_vendor
+build_os
+host
+host_cpu
+host_vendor
+host_os
+SED
+GREP
+EGREP
+LN_S
+ECHO
+AR
+RANLIB
+DSYMUTIL
+NMEDIT
+DLLTOOL
+AS
+OBJDUMP
+CPP
+CXXCPP
+F77
+FFLAGS
+ac_ct_F77
+LIBTOOL
+PCRE_MAJOR
+PCRE_MINOR
+PCRE_PRERELEASE
+PCRE_DATE
+pcre_have_type_traits
+pcre_have_bits_type_traits
+WITH_PCRE_CPP_TRUE
+WITH_PCRE_CPP_FALSE
+WITH_REBUILD_CHARTABLES_TRUE
+WITH_REBUILD_CHARTABLES_FALSE
+pcre_have_long_long
+pcre_have_ulong_long
+EXTRA_LIBPCRE_LDFLAGS
+EXTRA_LIBPCREPOSIX_LDFLAGS
+EXTRA_LIBPCRECPP_LDFLAGS
+DISTCHECK_CONFIGURE_FLAGS
+LIBOBJS
+LTLIBOBJS'
+ac_subst_files=''
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CXX
+CXXFLAGS
+CCC
+CPP
+CXXCPP
+F77
+FFLAGS'
+
+
+# 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.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+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
+
+  case $ac_option in
+  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)	ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -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)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$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 ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -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'`
+    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 ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$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 ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    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 ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$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'`
+    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; }; }
+    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 directory names.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; }
+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
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  { echo "$as_me: error: Working directory cannot be determined" >&2
+   { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  { echo "$as_me: error: pwd does not report name of working directory" >&2
+   { (exit 1); exit 1; }; }
+
+
+# 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 the parent directory.
+  ac_confdir=`$as_dirname -- "$0" ||
+$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
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+   { (exit 1); exit 1; }; }
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2
+   { (exit 1); exit 1; }; }
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# 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 PCRE 7.8 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 \`..']
+
+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]
+  --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]
+  --datarootdir=DIR      read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR          read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR          info documentation [DATAROOTDIR/info]
+  --localedir=DIR        locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR           man documentation [DATAROOTDIR/man]
+  --docdir=DIR           documentation root [DATAROOTDIR/doc/pcre]
+  --htmldir=DIR          html documentation [DOCDIR]
+  --dvidir=DIR           dvi documentation [DOCDIR]
+  --pdfdir=DIR           pdf documentation [DOCDIR]
+  --psdir=DIR            ps documentation [DOCDIR]
+_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]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of PCRE 7.8:";;
+   esac
+  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 build
+  --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)
+  --disable-cpp           disable C++ support
+  --enable-rebuild-chartables
+                          rebuild character tables in current locale
+  --enable-utf8           enable UTF-8 support
+  --enable-unicode-properties
+                          enable Unicode properties support (implies
+                          --enable-utf8)
+  --enable-newline-is-cr  use CR as newline character
+  --enable-newline-is-lf  use LF as newline character (default)
+  --enable-newline-is-crlf
+                          use CRLF as newline sequence
+  --enable-newline-is-anycrlf
+                          use CR, LF, or CRLF as newline sequence
+  --enable-newline-is-any use any valid Unicode newline sequence
+  --enable-bsr-anycrlf    \R matches only CR, LF, CRLF by default
+  --enable-ebcdic         assume EBCDIC coding rather than ASCII; use this
+                          only in (uncommon) EBCDIC environments; it implies
+                          --enable-rebuild-chartables
+  --disable-stack-for-recursion
+                          don't use stack recursion when matching
+  --enable-pcregrep-libz  link pcregrep with libz to handle .gz files
+  --enable-pcregrep-libbz2
+                          link pcregrep with libbz2 to handle .bz2 files
+  --enable-pcretest-libreadline
+                          link pcretest with libreadline
+
+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]
+  --with-tags[=TAGS]      include additional configurations [automatic]
+  --with-posix-malloc-threshold=NBYTES
+                          threshold for POSIX malloc usage (default=10)
+  --with-link-size=N      internal link size (2, 3, or 4 allowed; default=2)
+  --with-match-limit=N    default limit on internal looping (default=10000000)
+  --with-match-limit-recursion=N
+                          default limit on internal recursion
+                          (default=MATCH_LIMIT)
+
+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>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
+  CPP         C preprocessor
+  CXXCPP      C++ preprocessor
+  F77         Fortran 77 compiler command
+  FFLAGS      Fortran 77 compiler flags
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" || continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested 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
+    else
+      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+PCRE configure 7.8
+generated by GNU Autoconf 2.61
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006 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
+fi
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by PCRE $as_me 7.8, which was
+generated by GNU Autoconf 2.61.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+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`
+/usr/bin/hostinfo      = `(/usr/bin/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
+IFS=$as_save_IFS
+
+} >&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_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_arg'"
+      ;;
+    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: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+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,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+	"s/'\''/'\''\\\\'\'''\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=\$$ac_var
+	case $ac_val in
+	*\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	esac
+	echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      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.conftest.* &&
+    rm -f -r 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 -f -r conftest* 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 -n "$CONFIG_SITE"; then
+  set x "$CONFIG_SITE"
+elif test "x$prefix" != xNONE; then
+  set x "$prefix/share/config.site" "$prefix/etc/config.site"
+else
+  set x "$ac_default_prefix/share/config.site" \
+	"$ac_default_prefix/etc/config.site"
+fi
+shift
+for ac_site_file
+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 $ac_precious_vars; 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
+
+
+
+am__api_version='1.10'
+
+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
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# 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"
+# OS/2's system install, which has a completely different semantic
+# ./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/* | \
+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+  /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 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+
+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.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    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 -f 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
+
+{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
+echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in mkdir gmkdir; do
+	 for ac_exec_ext in '' $ac_executable_extensions; do
+	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+	     'mkdir (GNU coreutils) '* | \
+	     'mkdir (coreutils) '* | \
+	     'mkdir (fileutils) '4.1*)
+	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+	       break 3;;
+	   esac
+	 done
+       done
+done
+IFS=$as_save_IFS
+
+fi
+
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    test -d ./--version && rmdir ./--version
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5
+echo "${ECHO_T}$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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 x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$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
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if 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
+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='pcre'
+ VERSION='7.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"}
+
+install_sh=${install_sh-"\$(SHELL) $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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+
+# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just
+# "-g" for any other compiler. There doesn't seem to be a standard way of
+# getting rid of the -g (which I don't think is needed for a production
+# library). This fudge seems to achieve the necessary. First, we remember the
+# externally set values of CFLAGS and CXXFLAGS. Then call the AC_PROG_CC and
+# AC_PROG_CXX macros to find the compilers - if CFLAGS and CXXFLAGS are not
+# set, they will be set to Autoconf's defaults. Afterwards, if the original
+# values were not set, remove the -g from the Autoconf defaults.
+# (PH 02-May-07)
+
+remember_set_CFLAGS="$CFLAGS"
+remember_set_CXXFLAGS="$CXXFLAGS"
+
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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.exe
+  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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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.exe
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+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`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* 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 file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; }
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+#
+# List of possible output files, starting from the most likely.
+# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
+# only as a last resort.  b.out is created by i960 compilers.
+ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
+#
+# The IRIX 6 linker writes into existing files which may not be
+# executable, retaining their permissions.  Remove them first so a
+# subsequent execution test works.
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
+	break;;
+    * )
+	break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+
+{ echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6; }
+if test -z "$ac_file"; then
+  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
+
+# Check that 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'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 that 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 | *.map | *.inf | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;
+    *) 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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+{ 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
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	CFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+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 ISO C89" >&5
+echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* 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;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+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
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_c89=$ac_arg
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6; } ;;
+  xno)
+    { echo "$as_me:$LINENO: result: unsupported" >&5
+echo "${ECHO_T}unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+
+
+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
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo done
+.PHONY: am__doit
+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 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
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  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
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # 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.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/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=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    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=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  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_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+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_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+echo "${ECHO_T}$ac_ct_CXX" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+echo "$as_me:$LINENO: checking for C++ compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+{ 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_cxx_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
+GXX=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	CXXFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+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
+
+depcc="$CXX"  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_CXX_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
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_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
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # 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.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/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=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+fi
+
+
+
+if test "x$remember_set_CFLAGS" = "x"
+then
+  if test "$CFLAGS" = "-g -O2"
+  then
+    CFLAGS="-O2"
+  elif test "$CFLAGS" = "-g"
+  then
+    CFLAGS=""
+  fi
+fi
+
+if test "x$remember_set_CXXFLAGS" = "x"
+then
+  if test "$CXXFLAGS" = "-g -O2"
+  then
+    CXXFLAGS="-O2"
+  elif test "$CXXFLAGS" = "-g"
+  then
+    CXXFLAGS=""
+  fi
+fi
+
+# AC_PROG_CXX will return "g++" even if no c++ compiler is installed.
+# Check for that case, and just disable c++ code if g++ doesn't run.
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	CXX=""; CXXCP=""; CXXFLAGS=""
+fi
+
+rm -f core conftest.err 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
+
+
+# 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"
+# OS/2's system install, which has a completely different semantic
+# ./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/* | \
+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+  /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 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+
+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.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    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'
+
+
+
+# Check whether --enable-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.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_shared=yes
+fi
+
+
+# Check whether --enable-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.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_static=yes
+fi
+
+
+# Check whether --enable-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.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_fast_install=yes
+fi
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+echo "$as_me: error: cannot run $SHELL $ac_aux_dir/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_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  { { 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=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_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; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+echo "$as_me: error: invalid value of canonical build" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ 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
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+echo "$as_me: error: invalid value of canonical host" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+{ 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_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if { test -f "$as_dir/$lt_ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$lt_ac_prog$ac_exec_ext"; }; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+
+fi
+
+SED=$lt_cv_path_SED
+
+{ echo "$as_me:$LINENO: result: $SED" >&5
+echo "${ECHO_T}$SED" >&6; }
+
+{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # Extract the first word of "grep ggrep" to use in msg output
+if test -z "$GREP"; then
+set dummy grep ggrep; ac_prog_name=$2
+if test "${ac_cv_path_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_GREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in grep ggrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+    # Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_GREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+GREP="$ac_cv_path_GREP"
+if test -z "$GREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
+if test "${ac_cv_path_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_path_EGREP="$GREP -E"
+   else
+     # Extract the first word of "egrep" to use in msg output
+if test -z "$EGREP"; then
+set dummy egrep; ac_prog_name=$2
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_EGREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in egrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+    # Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_EGREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+EGREP="$ac_cv_path_EGREP"
+if test -z "$EGREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+
+   fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+
+# Check whether --with-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 $CC" >&5
+echo $ECHO_N "checking for ld used by $CC... $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.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname 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
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    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 variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_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 lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+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
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+{ 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
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_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
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    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
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
+echo "${ECHO_T}$lt_cv_path_NM" >&6; }
+NM="$lt_cv_path_NM"
+
+{ 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 recognize dependent libraries" >&5
+echo $ECHO_N "checking how to recognize 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 extended 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
+aix[4-9]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  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*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  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|DragonFly)/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_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    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_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  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
+  ;;
+
+nto-qnx*)
+  lt_cv_deplibs_check_method=unknown
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  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
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+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
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check whether --enable-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
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > 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
+    *ELF-32*)
+      HPUX_IA64_MODE="32"
+      ;;
+    *ELF-64*)
+      HPUX_IA64_MODE="64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line 5014 "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
+   if test "$lt_cv_prog_gnu_ld" = yes; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -melf32bsmip"
+      ;;
+    *N32*)
+      LD="${LD-ld} -melf32bmipn32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -melf64bmip"
+      ;;
+    esac
+   else
+    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
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > 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.o` in
+    *32-bit*)
+      case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_i386_fbsd"
+          ;;
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_i386"
+          ;;
+        ppc64-*linux*|powerpc64-*linux*)
+          LD="${LD-ld} -m elf32ppclinux"
+          ;;
+        s390x-*linux*)
+          LD="${LD-ld} -m elf_s390"
+          ;;
+        sparc64-*linux*)
+          LD="${LD-ld} -m elf32_sparc"
+          ;;
+      esac
+      ;;
+    *64-bit*)
+      case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_x86_64_fbsd"
+          ;;
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        ppc*-*linux*|powerpc*-*linux*)
+          LD="${LD-ld} -m elf64ppc"
+          ;;
+        s390*-*linux*)
+          LD="${LD-ld} -m elf64_s390"
+          ;;
+        sparc*-*linux*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+      esac
+      ;;
+    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
+/* 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      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
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > 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.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+        if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; 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_DLLTOOL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  { echo "$as_me:$LINENO: result: $DLLTOOL" >&5
+echo "${ECHO_T}$DLLTOOL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; 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_DLLTOOL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_DLLTOOL" >&5
+echo "${ECHO_T}$ac_ct_DLLTOOL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_DLLTOOL" = x; then
+    DLLTOOL="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    DLLTOOL=$ac_ct_DLLTOOL
+  fi
+else
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
+set dummy ${ac_tool_prefix}as; 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_AS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AS"; then
+  ac_cv_prog_AS="$AS" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AS="${ac_tool_prefix}as"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+AS=$ac_cv_prog_AS
+if test -n "$AS"; then
+  { echo "$as_me:$LINENO: result: $AS" >&5
+echo "${ECHO_T}$AS" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AS"; then
+  ac_ct_AS=$AS
+  # Extract the first word of "as", so it can be a program name with args.
+set dummy as; 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_AS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_AS"; then
+  ac_cv_prog_ac_ct_AS="$ac_ct_AS" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AS="as"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AS=$ac_cv_prog_ac_ct_AS
+if test -n "$ac_ct_AS"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_AS" >&5
+echo "${ECHO_T}$ac_ct_AS" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_AS" = x; then
+    AS="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    AS=$ac_ct_AS
+  fi
+else
+  AS="$ac_cv_prog_AS"
+fi
+
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; 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_OBJDUMP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { echo "$as_me:$LINENO: result: $OBJDUMP" >&5
+echo "${ECHO_T}$OBJDUMP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; 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_OBJDUMP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5
+echo "${ECHO_T}$ac_ct_OBJDUMP" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    OBJDUMP=$ac_ct_OBJDUMP
+  fi
+else
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+  ;;
+
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+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
+/* 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 { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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 nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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
+/* 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 { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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 nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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
+
+
+{ 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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* 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
+/* 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.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))
+      return 2;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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.conftest.* 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 { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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 { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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:$ac_c_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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 -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_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; }
+if test -z "$CXXCPP"; then
+  if test "${ac_cv_prog_CXXCPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+      # Double quotes because CXXCPP needs to be expanded
+    for CXXCPP in "$CXX -E" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_cxx_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
+/* 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 { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.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 nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.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_CXXCPP=$CXXCPP
+
+fi
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ echo "$as_me:$LINENO: result: $CXXCPP" >&5
+echo "${ECHO_T}$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_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
+/* 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 { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.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 nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.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 \"$CXXCPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+fi
+
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn
+  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_F77+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$F77"; then
+  ac_cv_prog_F77="$F77" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+F77=$ac_cv_prog_F77
+if test -n "$F77"; then
+  { echo "$as_me:$LINENO: result: $F77" >&5
+echo "${ECHO_T}$F77" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+    test -n "$F77" && break
+  done
+fi
+if test -z "$F77"; then
+  ac_ct_F77=$F77
+  for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn
+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_F77+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_F77"; then
+  ac_cv_prog_ac_ct_F77="$ac_ct_F77" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_F77="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_F77=$ac_cv_prog_ac_ct_F77
+if test -n "$ac_ct_F77"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_F77" >&5
+echo "${ECHO_T}$ac_ct_F77" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+  test -n "$ac_ct_F77" && break
+done
+
+  if test "x$ac_ct_F77" = x; then
+    F77=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    F77=$ac_ct_F77
+  fi
+fi
+
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO: checking for Fortran 77 compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file.  (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6; }
+if test "${ac_cv_f77_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+      program main
+#ifndef __GNUC__
+       choke me
+#endif
+
+      end
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_f77_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FFLAGS+set}
+ac_save_FFLAGS=$FFLAGS
+FFLAGS=
+{ echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5
+echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_f77_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  FFLAGS=-g
+cat >conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_f77_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_prog_f77_g=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5
+echo "${ECHO_T}$ac_cv_prog_f77_g" >&6; }
+if test "$ac_test_FFLAGS" = set; then
+  FFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_f77_g = yes; then
+  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+    FFLAGS="-g -O2"
+  else
+    FFLAGS="-g"
+  fi
+else
+  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+    FFLAGS="-O2"
+  else
+    FFLAGS=
+  fi
+fi
+
+G77=`test $ac_compiler_gnu = yes && echo yes`
+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
+
+
+
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+# find the maximum length of command line arguments
+{ echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
+echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6; }
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+    i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ 	]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
+	       = "XX$teststring") >/dev/null 2>&1 &&
+	      new_result=`expr "X$teststring" : ".*" 2>&1` &&
+	      lt_cv_sys_max_cmd_len=$new_result &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on massive
+      # amounts of additional arguments before passing them to the linker.
+      # It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
+echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6; }
+else
+  { echo "$as_me:$LINENO: result: none" >&5
+echo "${ECHO_T}none" >&6; }
+fi
+
+
+
+
+
+# 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 from $compiler object" >&5
+echo $ECHO_N "checking command to parse $NM output from $compiler object... $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 an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_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
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+linux* | k*bsd*-gnu)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDGIRSTW]'
+    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris*)
+  symcode='[BDRT]'
+  ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_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.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # 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 grep ' nm_test_var$' "$nlist" >/dev/null; then
+	if grep ' 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_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+	  cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+	  cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_save_LIBS="$LIBS"
+	  lt_save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$lt_prog_compiler_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="$lt_save_LIBS"
+	  CFLAGS="$lt_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 -rf 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
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; 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 objdir" >&5
+echo $ECHO_N "checking for objdir... $ECHO_C" >&6; }
+if test "${lt_cv_objdir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
+echo "${ECHO_T}$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+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
+
+# 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'
+
+# 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'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_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 MSVC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; 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_AR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { echo "$as_me:$LINENO: result: $AR" >&5
+echo "${ECHO_T}$AR" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; 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_AR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AR="ar"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
+echo "${ECHO_T}$ac_ct_AR" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
+IFS=$as_save_IFS
+
+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
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+
+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 "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+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 "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# 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_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    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@gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_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_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    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@gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_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
+
+
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; 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_DSYMUTIL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { echo "$as_me:$LINENO: result: $DSYMUTIL" >&5
+echo "${ECHO_T}$DSYMUTIL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; 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_DSYMUTIL+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_DSYMUTIL" >&5
+echo "${ECHO_T}$ac_ct_DSYMUTIL" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; 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_NMEDIT+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { echo "$as_me:$LINENO: result: $NMEDIT" >&5
+echo "${ECHO_T}$NMEDIT" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; 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_NMEDIT+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { echo "$as_me:$LINENO: result: $ac_ct_NMEDIT" >&5
+echo "${ECHO_T}$ac_ct_NMEDIT" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+
+    { echo "$as_me:$LINENO: checking for -single_module linker flag" >&5
+echo $ECHO_N "checking for -single_module linker flag... $ECHO_C" >&6; }
+if test "${lt_cv_apple_cc_single_mod+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+   # By default we will add the -single_module flag. You can override
+   # by either setting the environment variable LT_MULTI_MODULE
+   # non-empty at configure time, or by adding -multi_module to the
+   # link flags.
+   echo "int foo(void){return 1;}" > conftest.c
+   $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+     -dynamiclib ${wl}-single_module conftest.c
+   if test -f libconftest.dylib; then
+     lt_cv_apple_cc_single_mod=yes
+     rm -rf libconftest.dylib*
+   fi
+   rm conftest.c
+      fi
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_apple_cc_single_mod" >&5
+echo "${ECHO_T}$lt_cv_apple_cc_single_mod" >&6; }
+    { echo "$as_me:$LINENO: checking for -exported_symbols_list linker flag" >&5
+echo $ECHO_N "checking for -exported_symbols_list linker flag... $ECHO_C" >&6; }
+if test "${lt_cv_ld_exported_symbols_list+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  lt_cv_ld_exported_symbols_list=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	lt_cv_ld_exported_symbols_list=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_ld_exported_symbols_list" >&5
+echo "${ECHO_T}$lt_cv_ld_exported_symbols_list" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[0123])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*)
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+   10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+   10.[012]*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+   10.*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}"
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil="~$DSYMUTIL \$lib || :"
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+
+
+enable_dlopen=no
+enable_win32_dll=yes
+
+# Check whether --enable-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
+
+
+# Check whether --with-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
+
+# Check if we have a version mismatch between libtool.m4 and ltmain.sh.
+#
+# Note:  This should be in AC_LIBTOOL_SETUP, _after_ $ltmain have been defined.
+#        We also should do it _before_ AC_LIBTOOL_LANG_C_CONFIG that actually
+#        calls AC_LIBTOOL_CONFIG and creates libtool.
+#
+{ echo "$as_me:$LINENO: checking for correct ltmain.sh version" >&5
+echo $ECHO_N "checking for correct ltmain.sh version... $ECHO_C" >&6; }
+if test "x$ltmain" = "x" ; then
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+  { { echo "$as_me:$LINENO: error:
+
+*** [Gentoo] sanity check failed! ***
+*** \$ltmain is not defined, please check the patch for consistency! ***
+" >&5
+echo "$as_me: error:
+
+*** [Gentoo] sanity check failed! ***
+*** \$ltmain is not defined, please check the patch for consistency! ***
+" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+gentoo_lt_version="1.5.26"
+gentoo_ltmain_version=`sed -n '/^[ 	]*VERSION=/{s/^[ 	]*VERSION=//;p;q;}' "$ltmain"`
+if test "x$gentoo_lt_version" != "x$gentoo_ltmain_version" ; then
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+  { { echo "$as_me:$LINENO: error:
+
+*** [Gentoo] sanity check failed! ***
+*** libtool.m4 and ltmain.sh have a version mismatch! ***
+*** (libtool.m4 = $gentoo_lt_version, ltmain.sh = $gentoo_ltmain_version) ***
+
+Please run:
+
+  libtoolize --copy --force
+
+if appropriate, please contact the maintainer of this
+package (or your distribution) for help.
+" >&5
+echo "$as_me: error:
+
+*** [Gentoo] sanity check failed! ***
+*** libtool.m4 and ltmain.sh have a version mismatch! ***
+*** (libtool.m4 = $gentoo_lt_version, ltmain.sh = $gentoo_ltmain_version) ***
+
+Please run:
+
+  libtoolize --copy --force
+
+if appropriate, please contact the maintainer of this
+package (or your distribution) for help.
+" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+fi
+
+
+# Use C for the default configuration in the libtool script
+tagname=
+lt_save_CC="$CC"
+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
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm -r conftest*
+
+
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+
+{ 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; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+  ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:7944: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:7948: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+{ 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 "$GCC" = yes; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    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_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | 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).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
+
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='-fPIC'
+	;;
+      esac
+      ;;
+
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      else
+	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         lt_prog_compiler_pic='-qnocommon'
+         lt_prog_compiler_wl='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | cygwin* | 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_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-KPIC'
+	lt_prog_compiler_static='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fpic'
+	lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      *)
+        case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    rdos*)
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic='-Kconform_pic'
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
+
+{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic" >&6; }
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+
+{ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_pic_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_pic_works=no
+  ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:8234: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:8238: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_static_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works=yes
+     fi
+   fi
+   $rm -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
+
+{ 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_prog_compiler_c_o+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:8338: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:8342: \$? = $ac_status" >&5
+   if (exit $ac_status) && 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
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6; }
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_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
+
+{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
+
+  runpath_var=
+  allow_undefined_flag=
+  enable_shared_with_static_runtimes=no
+  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_libdir_flag_spec=
+  hardcode_libdir_flag_spec_ld=
+  hardcode_libdir_separator=
+  hardcode_direct=no
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  link_all_deplibs=unknown
+  hardcode_automatic=no
+  module_cmds=
+  module_expsym_cmds=
+  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 extended regexp 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_|_GLOBAL__F[ID]_.*'
+  # 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.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+  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
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  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}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	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
+      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
+
+      # Samuel A. Falvo II <kc5tja@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't use
+      # them.
+      ld_shlibs=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag=unsupported
+	# Joseph Beckenbach <jrb3@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*)
+      # _LT_AC_TAGVAR(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=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	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;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | k*bsd*-gnu)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	tmp_addflag=
+	case $cc_basename,$host_cpu in
+	pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	*)
+	  tmp_sharedflag='-shared' ;;
+	esac
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+	if test $supports_anon_versioning = yes; then
+	  archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+	  $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	fi
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    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 $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'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | grep '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 | grep ': 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
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+	  else
+	    ld_shlibs=no
+	  fi
+	;;
+      esac
+      ;;
+
+    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 | grep ': 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" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    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 "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      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
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	fi
+	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].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+  	    aix_use_runtimelinking=yes
+  	    break
+  	  fi
+	  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.
+
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" && \
+  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	  then
+  	  # We have reworked collect2
+  	  :
+	  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'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+  	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-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 does not export symbols beginning with
+      # underscore (_), 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'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+       hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${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 $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an empty executable.
+	 cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag=' ${wl}-bernotok'
+	  allow_undefined_flag=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec='$convenience'
+	  archive_cmds_need_lc=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_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
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
+
+    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
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # 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"`'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[012])
+         allow_undefined_flag='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[012])
+               allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      archive_cmds_need_lc=no
+      hardcode_direct=no
+      hardcode_automatic=yes
+      hardcode_shlibpath_var=unsupported
+      whole_archive_flag_spec=''
+      link_all_deplibs=yes
+    if test "$GCC" = yes ; then
+    	output_verbose_link_cmd='echo'
+        archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
+         module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         ld_shlibs=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    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* | dragonfly*)
+      archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	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'
+      fi
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator=:
+
+	hardcode_direct=yes
+	export_dynamic_flag_spec='${wl}-E'
+
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_libdir_flag_spec_ld='+b $libdir'
+	  hardcode_direct=no
+	  hardcode_shlibpath_var=no
+	  ;;
+	*)
+	  hardcode_direct=yes
+	  export_dynamic_flag_spec='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    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'
+      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_ld='-rpath $libdir'
+      fi
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      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*)
+      if test -f /usr/libexec/ld.so; then
+	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'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  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
+      else
+	ld_shlibs=no
+      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 "%s %s\\n" -exported_symbol "\$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 ${output_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=:
+      ;;
+
+    solaris*)
+      no_undefined_flag=' -z text'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+	wlarc=''
+	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'
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+ 	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      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'
+      ;;
+
+    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*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag='${wl}-z,text'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag='${wl}-z,text'
+      allow_undefined_flag='${wl}-z,nodefs'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      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
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
+
+  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; }
+      $rm conftest*
+      echo "$lt_simple_compile_test_code" > 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); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl
+	pic_flag=$lt_prog_compiler_pic
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_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
+	  archive_cmds_need_lc=no
+        else
+	  archive_cmds_need_lc=yes
+        fi
+        allow_undefined_flag=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      { echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
+echo "${ECHO_T}$archive_cmds_need_lc" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+{ 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=
+shrext_cmds=".so"
+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"
+
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[lt_foo]++; }
+  if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`echo $lt_search_path_spec`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  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}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    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}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+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}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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"
+  # 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
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $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
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  # Handle Gentoo/FreeBSD as it was Linux
+  case $host_vendor in
+    gentoo)
+      version_type=linux ;;
+    *)
+      version_type=freebsd-$objformat ;;
+  esac
+
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+    linux)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+      soname_spec='${libname}${release}${shared_ext}$major'
+      need_lib_prefix=no
+      need_version=no
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      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}"
+  hardcode_into_libs=yes
+  ;;
+
+# 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* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # 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}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  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
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  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"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${shared_ext}$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.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  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
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+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
+
+{ 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" || \
+   test "X$hardcode_automatic" = "Xyes" ; 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 "$_LT_AC_TAGVAR(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; }
+
+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
+
+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
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         old_striplib="$STRIP -S"
+         { 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
+       ;;
+   *)
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+    ;;
+  esac
+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
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      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
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+   ;;
+
+  *)
+    { 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define shl_load innocuous_shl_load
+
+/* 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
+
+#undef shl_load
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+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
+#endif
+
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      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="-ldld"
+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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define dlopen innocuous_dlopen
+
+/* 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
+
+#undef dlopen
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+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
+#endif
+
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      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="-ldld"
+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"
+    wl=$lt_prog_compiler_wl 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 10715 "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); */
+    }
+  else
+    puts (dlerror ());
+
+    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; ) >&5 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_dlunknown|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
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      { 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 10815 "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); */
+    }
+  else
+    puts (dlerror ());
+
+    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; ) >&5 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_dlunknown|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
+
+
+# Report which library types will actually be built
+{ 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
+  ;;
+
+aix[4-9]*)
+  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; }
+
+# The else 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
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # 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 AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler \
+    CC \
+    LD \
+    lt_prog_compiler_wl \
+    lt_prog_compiler_pic \
+    lt_prog_compiler_static \
+    lt_prog_compiler_no_builtin_flag \
+    export_dynamic_flag_spec \
+    thread_safe_flag_spec \
+    whole_archive_flag_spec \
+    enable_shared_with_static_runtimes \
+    old_archive_cmds \
+    old_archive_from_new_cmds \
+    predep_objects \
+    postdep_objects \
+    predeps \
+    postdeps \
+    compiler_lib_search_path \
+    compiler_lib_search_dirs \
+    archive_cmds \
+    archive_expsym_cmds \
+    postinstall_cmds \
+    postuninstall_cmds \
+    old_archive_from_expsyms_cmds \
+    allow_undefined_flag \
+    no_undefined_flag \
+    export_symbols_cmds \
+    hardcode_libdir_flag_spec \
+    hardcode_libdir_flag_spec_ld \
+    hardcode_libdir_separator \
+    hardcode_automatic \
+    module_cmds \
+    module_expsym_cmds \
+    lt_cv_prog_compiler_c_o \
+    fix_srcfile_path \
+    exclude_expsyms \
+    include_expsyms; do
+
+    case $var in
+    old_archive_cmds | \
+    old_archive_from_new_cmds | \
+    archive_cmds | \
+    archive_expsym_cmds | \
+    module_cmds | \
+    module_expsym_cmds | \
+    old_archive_from_expsyms_cmds | \
+    export_symbols_cmds | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_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
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="${ofile}T"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  $rm -f "$cfgfile"
+  { echo "$as_me:$LINENO: creating $ofile" >&5
+echo "$as_me: creating $ofile" >&6;}
+
+  cat <<__EOF__ >> "$cfgfile"
+#! $SHELL
+
+# `$echo "$cfgfile" | 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, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e 1s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### 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=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
+# A language-specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# 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=$lt_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="$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_lt_prog_compiler_wl
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# 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_lt_prog_compiler_static
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_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 used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps
+
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# 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_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_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
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# 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${shared_ext} 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
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic
+
+# 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=$lt_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 >> "$cfgfile"
+
+# 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
+
+  # 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" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" || \
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+
+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.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+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
+
+CC="$lt_save_CC"
+
+
+# Check whether --with-tags was given.
+if test "${with_tags+set}" = set; then
+  withval=$with_tags; tagnames="$withval"
+fi
+
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+  if test ! -f "${ofile}"; then
+    { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5
+echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;}
+  fi
+
+  if test -z "$LTCC"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+    if test -z "$LTCC"; then
+      { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5
+echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;}
+    else
+      { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5
+echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
+    fi
+  fi
+  if test -z "$LTCFLAGS"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+  fi
+
+  # Extract list of available tagged configurations in $ofile.
+  # Note that this assumes the entire list is on one line.
+  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+  for tagname in $tagnames; do
+    IFS="$lt_save_ifs"
+    # Check whether tagname contains only valid characters
+    case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in
+    "") ;;
+    *)  { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5
+echo "$as_me: error: invalid tag name: $tagname" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+    esac
+
+    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+    then
+      { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5
+echo "$as_me: error: tag name \"$tagname\" already exists" >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+
+    # Update the list of available tags.
+    if test -n "$tagname"; then
+      echo appending configuration tag \"$tagname\" to $ofile
+
+      case $tagname in
+      CXX)
+	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+	    (test "X$CXX" != "Xg++"))) ; then
+	  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+
+
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_flag_spec_ld_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
+hardcode_automatic_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
+
+# Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
+compiler_lib_search_dirs_CXX=
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm -r conftest*
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_LD=$LD
+lt_save_GCC=$GCC
+GCC=$GXX
+lt_save_with_gnu_ld=$with_gnu_ld
+lt_save_path_LD=$lt_cv_path_LD
+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+  lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+else
+  $as_unset lt_cv_prog_gnu_ld
+fi
+if test -n "${lt_cv_path_LDCXX+set}"; then
+  lt_cv_path_LD=$lt_cv_path_LDCXX
+else
+  $as_unset lt_cv_path_LD
+fi
+test -z "${LDCXX+set}" || LD=$LDCXX
+CC=${CXX-"c++"}
+compiler=$CC
+compiler_CXX=$CC
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# We don't want -fno-exception wen compiling C++ code, so set the
+# no_builtin_flag separately
+if test "$GXX" = yes; then
+  lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+else
+  lt_prog_compiler_no_builtin_flag_CXX=
+fi
+
+if test "$GXX" = yes; then
+  # Set up default GNU C++ configuration
+
+
+# Check whether --with-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 $CC" >&5
+echo $ECHO_N "checking for ld used by $CC... $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.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname 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
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    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 variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_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 lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+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
+
+
+
+  # Check if GNU C++ uses GNU ld as the underlying linker, since the
+  # archiving commands below assume that GNU ld is being used.
+  if test "$with_gnu_ld" = yes; then
+    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+    #     investigate it a little bit more. (MM)
+    wlarc='${wl}'
+
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+	grep 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec_CXX=
+    fi
+  else
+    with_gnu_ld=no
+    wlarc=
+
+    # A generic and very simple default shared library creation
+    # command for GNU C++ for the case where it uses the native
+    # linker, instead of GNU ld.  If possible, this setting should
+    # overridden to take advantage of the native linker features on
+    # the platform it is being used on.
+    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+  fi
+
+  # Commands to make compiler produce verbose output that lists
+  # what "hidden" libraries, object files and flags are used when
+  # linking a shared library.
+  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+else
+  GXX=no
+  with_gnu_ld=no
+  wlarc=
+fi
+
+# PORTME: fill in a description of your system's C++ link characteristics
+{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
+ld_shlibs_CXX=yes
+case $host_os in
+  aix3*)
+    # FIXME: insert proper C++ library support
+    ld_shlibs_CXX=no
+    ;;
+  aix[4-9]*)
+    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].*|aix[5-9]*)
+	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.
+
+    archive_cmds_CXX=''
+    hardcode_direct_CXX=yes
+    hardcode_libdir_separator_CXX=':'
+    link_all_deplibs_CXX=yes
+
+    if test "$GXX" = yes; then
+      case $host_os in aix4.[012]|aix4.[012].*)
+      # We only want to do this on AIX 4.2 and lower, the check
+      # below for broken collect2 doesn't work under 4.3+
+	collect2name=`${CC} -print-prog-name=collect2`
+	if test -f "$collect2name" && \
+	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	then
+	  # We have reworked collect2
+	  :
+	else
+	  # We have old collect2
+	  hardcode_direct_CXX=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_CXX=yes
+	  hardcode_libdir_flag_spec_CXX='-L$libdir'
+	  hardcode_libdir_separator_CXX=
+	fi
+	;;
+      esac
+      shared_flag='-shared'
+      if test "$aix_use_runtimelinking" = yes; then
+	shared_flag="$shared_flag "'${wl}-G'
+      fi
+    else
+      # not using gcc
+      if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	shared_flag='-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 does not export symbols beginning with
+    # underscore (_), so it is better to generate a list of symbols to export.
+    always_export_symbols_CXX=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_CXX='-berok'
+      # Determine the default libpath from the value encoded in an empty executable.
+      cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+      hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+      archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+     else
+      if test "$host_cpu" = ia64; then
+	hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+	allow_undefined_flag_CXX="-z nodefs"
+	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+      else
+	# Determine the default libpath from the value encoded in an empty executable.
+	cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	# Warning - without using the other run time loading flags,
+	# -berok will link without error, but may produce a broken library.
+	no_undefined_flag_CXX=' ${wl}-bernotok'
+	allow_undefined_flag_CXX=' ${wl}-berok'
+	# Exported symbols can be pulled into shared objects from archives
+	whole_archive_flag_spec_CXX='$convenience'
+	archive_cmds_need_lc_CXX=yes
+	# This is similar to how AIX traditionally builds its shared libraries.
+	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+      fi
+    fi
+    ;;
+
+  beos*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+      allow_undefined_flag_CXX=unsupported
+      # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    else
+      ld_shlibs_CXX=no
+    fi
+    ;;
+
+  chorus*)
+    case $cc_basename in
+      *)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+    esac
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+    # as there is no search path for DLLs.
+    hardcode_libdir_flag_spec_CXX='-L$libdir'
+    allow_undefined_flag_CXX=unsupported
+    always_export_symbols_CXX=no
+    enable_shared_with_static_runtimes_CXX=yes
+
+    if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+      archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      # If the export-symbols file already is a .def file (1st line
+      # is EXPORTS), use it as is; otherwise, prepend...
+      archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	cp $export_symbols $output_objdir/$soname.def;
+      else
+	echo EXPORTS > $output_objdir/$soname.def;
+	cat $export_symbols >> $output_objdir/$soname.def;
+      fi~
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+    else
+      ld_shlibs_CXX=no
+    fi
+  ;;
+      darwin* | rhapsody*)
+      archive_cmds_need_lc_CXX=no
+      hardcode_direct_CXX=no
+      hardcode_automatic_CXX=yes
+      hardcode_shlibpath_var_CXX=unsupported
+      whole_archive_flag_spec_CXX=''
+      link_all_deplibs_CXX=yes
+      allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+      if test "$GXX" = yes ; then
+      output_verbose_link_cmd='echo'
+      archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+      module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+      module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+      if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+        archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+        archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+      fi
+      else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+          archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
+          module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         ld_shlibs_CXX=no
+          ;;
+      esac
+      fi
+        ;;
+
+  dgux*)
+    case $cc_basename in
+      ec++*)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      ghcx*)
+	# Green Hills C++ Compiler
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+    esac
+    ;;
+  freebsd[12]*)
+    # C++ shared libraries reported to be fairly broken before switch to ELF
+    ld_shlibs_CXX=no
+    ;;
+  freebsd-elf*)
+    archive_cmds_need_lc_CXX=no
+    ;;
+  freebsd* | dragonfly*)
+    # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+    # conventions
+    ld_shlibs_CXX=yes
+    ;;
+  gnu*)
+    ;;
+  hpux9*)
+    hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+    hardcode_libdir_separator_CXX=:
+    export_dynamic_flag_spec_CXX='${wl}-E'
+    hardcode_direct_CXX=yes
+    hardcode_minus_L_CXX=yes # Not in the search PATH,
+				# but as the default
+				# location of the library.
+
+    case $cc_basename in
+    CC*)
+      # FIXME: insert proper C++ library support
+      ld_shlibs_CXX=no
+      ;;
+    aCC*)
+      archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      #
+      # There doesn't appear to be a way to prevent this compiler from
+      # explicitly linking system object files so we need to strip them
+      # from the output so that they don't get included in the library
+      # dependencies.
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      ;;
+    *)
+      if test "$GXX" = yes; then
+        archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+      fi
+      ;;
+    esac
+    ;;
+  hpux10*|hpux11*)
+    if test $with_gnu_ld = no; then
+      hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_CXX=:
+
+      case $host_cpu in
+      hppa*64*|ia64*) ;;
+      *)
+	export_dynamic_flag_spec_CXX='${wl}-E'
+        ;;
+      esac
+    fi
+    case $host_cpu in
+    hppa*64*|ia64*)
+      hardcode_direct_CXX=no
+      hardcode_shlibpath_var_CXX=no
+      ;;
+    *)
+      hardcode_direct_CXX=yes
+      hardcode_minus_L_CXX=yes # Not in the search PATH,
+					      # but as the default
+					      # location of the library.
+      ;;
+    esac
+
+    case $cc_basename in
+      CC*)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      aCC*)
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	esac
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes; then
+	  if test $with_gnu_ld = no; then
+	    case $host_cpu in
+	    hppa*64*)
+	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    ia64*)
+	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    *)
+	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    esac
+	  fi
+	else
+	  # FIXME: insert proper C++ library support
+	  ld_shlibs_CXX=no
+	fi
+	;;
+    esac
+    ;;
+  interix[3-9]*)
+    hardcode_direct_CXX=no
+    hardcode_shlibpath_var_CXX=no
+    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+    export_dynamic_flag_spec_CXX='${wl}-E'
+    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+    # Instead, shared libraries are loaded at an image base (0x10000000 by
+    # default) and relocated if they conflict, which is a slow very memory
+    # consuming and fragmenting process.  To avoid this, we pick a random,
+    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+    archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    ;;
+  irix5* | irix6*)
+    case $cc_basename in
+      CC*)
+	# SGI C++
+	archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	# Archives containing C++ object files must be created using
+	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	# necessary to make sure instantiated templates are included
+	# in the archive.
+	old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	;;
+      *)
+	if test "$GXX" = yes; then
+	  if test "$with_gnu_ld" = no; then
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $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
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+	  fi
+	fi
+	link_all_deplibs_CXX=yes
+	;;
+    esac
+    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator_CXX=:
+    ;;
+  linux* | k*bsd*-gnu)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+	hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir'
+	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+	# Archives containing C++ object files must be created using
+	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+	;;
+      icpc*)
+	# Intel C++
+	with_gnu_ld=yes
+	# version 8.0 and above of icpc choke on multiply defined symbols
+	# if we add $predep_objects and $postdep_objects, however 7.1 and
+	# earlier do not add the objects themselves.
+	case `$CC -V 2>&1` in
+	*"Version 7."*)
+  	  archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+  	  archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  ;;
+	*)  # Version 8.0 or newer
+	  tmp_idyn=
+	  case $host_cpu in
+	    ia64*) tmp_idyn=' -i_dynamic';;
+	  esac
+  	  archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  ;;
+	esac
+	archive_cmds_need_lc_CXX=no
+	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	;;
+      pgCC* | pgcpp*)
+        # Portland Group C++ compiler
+	archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+  	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+
+	hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+        ;;
+      cxx*)
+	# Compaq C++
+	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+	runpath_var=LD_RUN_PATH
+	hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+	hardcode_libdir_separator_CXX=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C++ 5.9
+	  no_undefined_flag_CXX=' -zdefs'
+	  archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	  hardcode_libdir_flag_spec_CXX='-R$libdir'
+	  whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+
+	  # Not sure whether something based on
+	  # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	  # would be better.
+	  output_verbose_link_cmd='echo'
+
+	  # Archives containing C++ object files must be created using
+	  # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	  # necessary to make sure instantiated templates are included
+	  # in the archive.
+	  old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	  ;;
+	esac
+	;;
+    esac
+    ;;
+  lynxos*)
+    # FIXME: insert proper C++ library support
+    ld_shlibs_CXX=no
+    ;;
+  m88k*)
+    # FIXME: insert proper C++ library support
+    ld_shlibs_CXX=no
+    ;;
+  mvs*)
+    case $cc_basename in
+      cxx*)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+    esac
+    ;;
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds_CXX='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+      wlarc=
+      hardcode_libdir_flag_spec_CXX='-R$libdir'
+      hardcode_direct_CXX=yes
+      hardcode_shlibpath_var_CXX=no
+    fi
+    # Workaround some broken pre-1.5 toolchains
+    output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+    ;;
+  openbsd2*)
+    # C++ shared libraries are fairly broken
+    ld_shlibs_CXX=no
+    ;;
+  openbsd*)
+    if test -f /usr/libexec/ld.so; then
+      hardcode_direct_CXX=yes
+      hardcode_shlibpath_var_CXX=no
+      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	export_dynamic_flag_spec_CXX='${wl}-E'
+	whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      fi
+      output_verbose_link_cmd='echo'
+    else
+      ld_shlibs_CXX=no
+    fi
+    ;;
+  osf3*)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	hardcode_libdir_separator_CXX=:
+
+	# Archives containing C++ object files must be created using
+	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+
+	;;
+      RCC*)
+	# Rational C++ 2.4.1
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      cxx*)
+	allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	hardcode_libdir_separator_CXX=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	  archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $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_CXX='${wl}-rpath ${wl}$libdir'
+	  hardcode_libdir_separator_CXX=:
+
+	  # Commands to make compiler produce verbose output that lists
+	  # what "hidden" libraries, object files and flags are used when
+	  # linking a shared library.
+	  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+	else
+	  # FIXME: insert proper C++ library support
+	  ld_shlibs_CXX=no
+	fi
+	;;
+    esac
+    ;;
+  osf4* | osf5*)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	hardcode_libdir_separator_CXX=:
+
+	# Archives containing C++ object files must be created using
+	# the KAI C++ compiler.
+	old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
+	;;
+      RCC*)
+	# Rational C++ 2.4.1
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      cxx*)
+	allow_undefined_flag_CXX=' -expect_unresolved \*'
+	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	  echo "-hidden">> $lib.exp~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $rm $lib.exp'
+
+	hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+	hardcode_libdir_separator_CXX=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $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_CXX='${wl}-rpath ${wl}$libdir'
+	  hardcode_libdir_separator_CXX=:
+
+	  # Commands to make compiler produce verbose output that lists
+	  # what "hidden" libraries, object files and flags are used when
+	  # linking a shared library.
+	  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+	else
+	  # FIXME: insert proper C++ library support
+	  ld_shlibs_CXX=no
+	fi
+	;;
+    esac
+    ;;
+  psos*)
+    # FIXME: insert proper C++ library support
+    ld_shlibs_CXX=no
+    ;;
+  sunos4*)
+    case $cc_basename in
+      CC*)
+	# Sun C++ 4.x
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      lcc*)
+	# Lucid
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+    esac
+    ;;
+  solaris*)
+    case $cc_basename in
+      CC*)
+	# Sun C++ 4.2, 5.x and Centerline C++
+        archive_cmds_need_lc_CXX=yes
+	no_undefined_flag_CXX=' -zdefs'
+	archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	hardcode_libdir_flag_spec_CXX='-R$libdir'
+	hardcode_shlibpath_var_CXX=no
+	case $host_os in
+	  solaris2.[0-5] | solaris2.[0-5].*) ;;
+	  *)
+	    # The compiler driver will combine and reorder linker options,
+	    # but understands `-z linker_flag'.
+	    # Supported since Solaris 2.6 (maybe 2.5.1?)
+	    whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
+	    ;;
+	esac
+	link_all_deplibs_CXX=yes
+
+	output_verbose_link_cmd='echo'
+
+	# Archives containing C++ object files must be created using
+	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	# necessary to make sure instantiated templates are included
+	# in the archive.
+	old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	;;
+      gcx*)
+	# Green Hills C++ Compiler
+	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+	# The C++ compiler must be used to create the archive.
+	old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	;;
+      *)
+	# GNU C++ compiler with Solaris linker
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+	  if $CC --version | grep -v '^2\.7' > /dev/null; then
+	    archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+	  else
+	    # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	    # platform.
+	    archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+	  fi
+
+	  hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	  case $host_os in
+	  solaris2.[0-5] | solaris2.[0-5].*) ;;
+	  *)
+	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	    ;;
+	  esac
+	fi
+	;;
+    esac
+    ;;
+  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+    no_undefined_flag_CXX='${wl}-z,text'
+    archive_cmds_need_lc_CXX=no
+    hardcode_shlibpath_var_CXX=no
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  sysv5* | sco3.2v5* | sco5v6*)
+    # Note: We can NOT use -z defs as we might desire, because we do not
+    # link with -lc, and that would cause any symbols used from libc to
+    # always be unresolved, which means just about no library would
+    # ever link correctly.  If we're not using GNU ld we use -z text
+    # though, which does catch some bad symbols but isn't as heavy-handed
+    # as -z defs.
+    # For security reasons, it is highly recommended that you always
+    # use absolute paths for naming shared libraries, and exclude the
+    # DT_RUNPATH tag from executables and libraries.  But doing so
+    # requires that you compile everything twice, which is a pain.
+    # So that behaviour is only enabled if SCOABSPATH is set to a
+    # non-empty value in the environment.  Most likely only useful for
+    # creating official distributions of packages.
+    # This is a hack until libtool officially supports absolute path
+    # names for shared libraries.
+    no_undefined_flag_CXX='${wl}-z,text'
+    allow_undefined_flag_CXX='${wl}-z,nodefs'
+    archive_cmds_need_lc_CXX=no
+    hardcode_shlibpath_var_CXX=no
+    hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+    hardcode_libdir_separator_CXX=':'
+    link_all_deplibs_CXX=yes
+    export_dynamic_flag_spec_CXX='${wl}-Bexport'
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  tandem*)
+    case $cc_basename in
+      NCC*)
+	# NonStop-UX NCC 3.20
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+    esac
+    ;;
+  vxworks*)
+    # FIXME: insert proper C++ library support
+    ld_shlibs_CXX=no
+    ;;
+  *)
+    # FIXME: insert proper C++ library support
+    ld_shlibs_CXX=no
+    ;;
+esac
+{ echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
+echo "${ECHO_T}$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+GCC_CXX="$GXX"
+LD_CXX="$LD"
+
+cat > conftest.$ac_ext <<EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+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
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  # The `*' in the case matches for architectures that use `case' in
+  # $output_verbose_cmd can trigger glob expansion during the loop
+  # eval without this substitution.
+  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+
+  for p in `eval $output_verbose_link_cmd`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" \
+	  || test $p = "-R"; then
+	 prev=$p
+	 continue
+       else
+	 prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 case $p in
+	 -L* | -R*)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$compiler_lib_search_path_CXX"; then
+	     compiler_lib_search_path_CXX="${prev}${p}"
+	   else
+	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$postdeps_CXX"; then
+	   postdeps_CXX="${prev}${p}"
+	 else
+	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+	 fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$predep_objects_CXX"; then
+	   predep_objects_CXX="$p"
+	 else
+	   predep_objects_CXX="$predep_objects_CXX $p"
+	 fi
+       else
+	 if test -z "$postdep_objects_CXX"; then
+	   postdep_objects_CXX="$p"
+	 else
+	   postdep_objects_CXX="$postdep_objects_CXX $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling CXX test program"
+fi
+
+$rm -f confest.$objext
+
+compiler_lib_search_dirs_CXX=
+if test -n "$compiler_lib_search_path_CXX"; then
+  compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+# PORTME: override above test on systems where it is broken
+case $host_os in
+interix[3-9]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  predep_objects_CXX=
+  postdep_objects_CXX=
+  postdeps_CXX=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+    #
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+
+lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
+
+{ 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; }
+
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    lt_prog_compiler_wl_CXX='-Wl,'
+    lt_prog_compiler_static_CXX='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_CXX='-Bstatic'
+      fi
+      ;;
+    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_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+      ;;
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32*)
+      # 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).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_CXX='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      lt_prog_compiler_pic_CXX=
+      ;;
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_CXX=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	;;
+      *)
+	lt_prog_compiler_pic_CXX='-fPIC'
+	;;
+      esac
+      ;;
+    *)
+      lt_prog_compiler_pic_CXX='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[4-9]*)
+	# All AIX code is PIC.
+	if test "$host_cpu" = ia64; then
+	  # AIX 5 now supports IA64 processor
+	  lt_prog_compiler_static_CXX='-Bstatic'
+	else
+	  lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+	fi
+	;;
+      chorus*)
+	case $cc_basename in
+	cxch68*)
+	  # Green Hills C++ Compiler
+	  # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+	  ;;
+	esac
+	;;
+       darwin*)
+         # PIC is the default on this platform
+         # Common symbols not allowed in MH_DYLIB files
+         case $cc_basename in
+           xlc*)
+           lt_prog_compiler_pic_CXX='-qnocommon'
+           lt_prog_compiler_wl_CXX='-Wl,'
+           ;;
+         esac
+       ;;
+      dgux*)
+	case $cc_basename in
+	  ec++*)
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    ;;
+	  ghcx*)
+	    # Green Hills C++ Compiler
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      freebsd* | dragonfly*)
+	# FreeBSD uses GNU C++
+	;;
+      hpux9* | hpux10* | hpux11*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    if test "$host_cpu" != ia64; then
+	      lt_prog_compiler_pic_CXX='+Z'
+	    fi
+	    ;;
+	  aCC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    case $host_cpu in
+	    hppa*64*|ia64*)
+	      # +Z the default
+	      ;;
+	    *)
+	      lt_prog_compiler_pic_CXX='+Z'
+	      ;;
+	    esac
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
+      irix5* | irix6* | nonstopux*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    # CC pic flag -KPIC is the default.
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      linux* | k*bsd*-gnu)
+	case $cc_basename in
+	  KCC*)
+	    # KAI C++ Compiler
+	    lt_prog_compiler_wl_CXX='--backend -Wl,'
+	    lt_prog_compiler_pic_CXX='-fPIC'
+	    ;;
+	  icpc* | ecpc*)
+	    # Intel C++
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-static'
+	    ;;
+	  pgCC* | pgcpp*)
+	    # Portland Group C++ compiler.
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-fpic'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	  cxx*)
+	    # Compaq C++
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    lt_prog_compiler_pic_CXX=
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      lt_prog_compiler_pic_CXX='-KPIC'
+	      lt_prog_compiler_static_CXX='-Bstatic'
+	      lt_prog_compiler_wl_CXX='-Qoption ld '
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+      lynxos*)
+	;;
+      m88k*)
+	;;
+      mvs*)
+	case $cc_basename in
+	  cxx*)
+	    lt_prog_compiler_pic_CXX='-W c,exportall'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      netbsd*)
+	;;
+      osf3* | osf4* | osf5*)
+	case $cc_basename in
+	  KCC*)
+	    lt_prog_compiler_wl_CXX='--backend -Wl,'
+	    ;;
+	  RCC*)
+	    # Rational C++ 2.4.1
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  cxx*)
+	    # Digital/Compaq C++
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    lt_prog_compiler_pic_CXX=
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      psos*)
+	;;
+      solaris*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    lt_prog_compiler_wl_CXX='-Qoption ld '
+	    ;;
+	  gcx*)
+	    # Green Hills C++ Compiler
+	    lt_prog_compiler_pic_CXX='-PIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sunos4*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.x
+	    lt_prog_compiler_pic_CXX='-pic'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	  lcc*)
+	    # Lucid
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      tandem*)
+	case $cc_basename in
+	  NCC*)
+	    # NonStop-UX NCC 3.20
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	esac
+	;;
+      vxworks*)
+	;;
+      *)
+	lt_prog_compiler_can_build_shared_CXX=no
+	;;
+    esac
+  fi
+
+{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6; }
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+
+{ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_pic_works_CXX=no
+  ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13216: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:13220: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_CXX=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+    case $lt_prog_compiler_pic_CXX in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+     esac
+else
+    lt_prog_compiler_pic_CXX=
+     lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_CXX=
+    ;;
+  *)
+    lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+    ;;
+esac
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
+{ echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_static_works_CXX=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_CXX=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_CXX=yes
+     fi
+   fi
+   $rm -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+    :
+else
+    lt_prog_compiler_static_CXX=
+fi
+
+
+{ 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_prog_compiler_c_o_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13320: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:13324: \$? = $ac_status" >&5
+   if (exit $ac_status) && 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
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = 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
+
+{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
+
+  export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix[4-9]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+    else
+      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    export_symbols_cmds_CXX="$ltdll_cmds"
+  ;;
+  cygwin* | mingw*)
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+  ;;
+  *)
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+
+{ echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
+echo "${ECHO_T}$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_CXX=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_CXX 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; }
+      $rm conftest*
+      echo "$lt_simple_compile_test_code" > 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); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_CXX
+	pic_flag=$lt_prog_compiler_pic_CXX
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+        allow_undefined_flag_CXX=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc_CXX=no
+        else
+	  archive_cmds_need_lc_CXX=yes
+        fi
+        allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+{ 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=
+shrext_cmds=".so"
+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"
+
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  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}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    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}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+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}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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"
+  # 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
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $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
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  # Handle Gentoo/FreeBSD as it was Linux
+  case $host_vendor in
+    gentoo)
+      version_type=linux ;;
+    *)
+      version_type=freebsd-$objformat ;;
+  esac
+
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+    linux)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+      soname_spec='${libname}${release}${shared_ext}$major'
+      need_lib_prefix=no
+      need_version=no
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      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}"
+  hardcode_into_libs=yes
+  ;;
+
+# 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* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # 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}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  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
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  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"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${shared_ext}$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.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  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
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+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
+
+{ 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_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" || \
+   test -n "$runpath_var_CXX" || \
+   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct_CXX" != 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 "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+     test "$hardcode_minus_L_CXX" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_CXX=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_CXX=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_CXX=unsupported
+fi
+{ echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5
+echo "${ECHO_T}$hardcode_action_CXX" >&6; }
+
+if test "$hardcode_action_CXX" = 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
+
+
+# The else 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
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # 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 AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_CXX \
+    CC_CXX \
+    LD_CXX \
+    lt_prog_compiler_wl_CXX \
+    lt_prog_compiler_pic_CXX \
+    lt_prog_compiler_static_CXX \
+    lt_prog_compiler_no_builtin_flag_CXX \
+    export_dynamic_flag_spec_CXX \
+    thread_safe_flag_spec_CXX \
+    whole_archive_flag_spec_CXX \
+    enable_shared_with_static_runtimes_CXX \
+    old_archive_cmds_CXX \
+    old_archive_from_new_cmds_CXX \
+    predep_objects_CXX \
+    postdep_objects_CXX \
+    predeps_CXX \
+    postdeps_CXX \
+    compiler_lib_search_path_CXX \
+    compiler_lib_search_dirs_CXX \
+    archive_cmds_CXX \
+    archive_expsym_cmds_CXX \
+    postinstall_cmds_CXX \
+    postuninstall_cmds_CXX \
+    old_archive_from_expsyms_cmds_CXX \
+    allow_undefined_flag_CXX \
+    no_undefined_flag_CXX \
+    export_symbols_cmds_CXX \
+    hardcode_libdir_flag_spec_CXX \
+    hardcode_libdir_flag_spec_ld_CXX \
+    hardcode_libdir_separator_CXX \
+    hardcode_automatic_CXX \
+    module_cmds_CXX \
+    module_expsym_cmds_CXX \
+    lt_cv_prog_compiler_c_o_CXX \
+    fix_srcfile_path_CXX \
+    exclude_expsyms_CXX \
+    include_expsyms_CXX; do
+
+    case $var in
+    old_archive_cmds_CXX | \
+    old_archive_from_new_cmds_CXX | \
+    archive_cmds_CXX | \
+    archive_expsym_cmds_CXX | \
+    module_cmds_CXX | \
+    module_expsym_cmds_CXX | \
+    old_archive_from_expsyms_cmds_CXX | \
+    export_symbols_cmds_CXX | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_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
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="$ofile"
+
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# 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=$archive_cmds_need_lc_CXX
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
+# A language-specific compiler.
+CC=$lt_compiler_CXX
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_CXX
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_CXX
+
+# 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=$lt_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="$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_lt_prog_compiler_wl_CXX
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# 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_lt_prog_compiler_static_CXX
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX
+
+# 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_CXX
+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_CXX
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_CXX
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_CXX
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_CXX
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_CXX
+
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+
+# 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_CXX
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
+
+# 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_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_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_CXX
+
+# 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_CXX
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_CXX
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_CXX
+
+# 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_CXX
+
+# 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=$lt_fix_srcfile_path
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
+
+# 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_CXX
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+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.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+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
+
+CC=$lt_save_CC
+LDCXX=$LD
+LD=$lt_save_LD
+GCC=$lt_save_GCC
+with_gnu_ldcxx=$with_gnu_ld
+with_gnu_ld=$lt_save_with_gnu_ld
+lt_cv_path_LDCXX=$lt_cv_path_LD
+lt_cv_path_LD=$lt_save_path_LD
+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+
+	else
+	  tagname=""
+	fi
+	;;
+
+      F77)
+	if test -n "$F77" && test "X$F77" != "Xno"; then
+
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+
+
+archive_cmds_need_lc_F77=no
+allow_undefined_flag_F77=
+always_export_symbols_F77=no
+archive_expsym_cmds_F77=
+export_dynamic_flag_spec_F77=
+hardcode_direct_F77=no
+hardcode_libdir_flag_spec_F77=
+hardcode_libdir_flag_spec_ld_F77=
+hardcode_libdir_separator_F77=
+hardcode_minus_L_F77=no
+hardcode_automatic_F77=no
+module_cmds_F77=
+module_expsym_cmds_F77=
+link_all_deplibs_F77=unknown
+old_archive_cmds_F77=$old_archive_cmds
+no_undefined_flag_F77=
+whole_archive_flag_spec_F77=
+enable_shared_with_static_runtimes_F77=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+objext_F77=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="\
+      program t
+      end
+"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm -r conftest*
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${F77-"f77"}
+compiler=$CC
+compiler_F77=$CC
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+{ 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
+  ;;
+aix[4-9]*)
+  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; }
+
+GCC_F77="$G77"
+LD_F77="$LD"
+
+lt_prog_compiler_wl_F77=
+lt_prog_compiler_pic_F77=
+lt_prog_compiler_static_F77=
+
+{ 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 "$GCC" = yes; then
+    lt_prog_compiler_wl_F77='-Wl,'
+    lt_prog_compiler_static_F77='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_F77='-Bstatic'
+      fi
+      ;;
+
+    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_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | 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).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_F77='-fno-common'
+      ;;
+
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_F77=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_F77=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_F77='-fPIC'
+	;;
+      esac
+      ;;
+
+    *)
+      lt_prog_compiler_pic_F77='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_F77='-Bstatic'
+      else
+	lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         lt_prog_compiler_pic_F77='-qnocommon'
+         lt_prog_compiler_wl_F77='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | cygwin* | 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_prog_compiler_pic_F77='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_F77='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc*)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-KPIC'
+	lt_prog_compiler_static_F77='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-fpic'
+	lt_prog_compiler_static_F77='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_F77='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_F77='-non_shared'
+        ;;
+      *)
+        case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic_F77='-KPIC'
+	  lt_prog_compiler_static_F77='-Bstatic'
+	  lt_prog_compiler_wl_F77='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic_F77='-KPIC'
+	  lt_prog_compiler_static_F77='-Bstatic'
+	  lt_prog_compiler_wl_F77=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
+
+    rdos*)
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	lt_prog_compiler_wl_F77='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl_F77='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl_F77='-Qoption ld '
+      lt_prog_compiler_pic_F77='-PIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic_F77='-Kconform_pic'
+	lt_prog_compiler_static_F77='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_can_build_shared_F77=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic_F77='-pic'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared_F77=no
+      ;;
+    esac
+  fi
+
+{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6; }
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_F77"; then
+
+{ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_pic_works_F77+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_pic_works_F77=no
+  ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_F77"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:14916: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:14920: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_F77=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_F77" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_F77" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_F77" = xyes; then
+    case $lt_prog_compiler_pic_F77 in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
+     esac
+else
+    lt_prog_compiler_pic_F77=
+     lt_prog_compiler_can_build_shared_F77=no
+fi
+
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_F77=
+    ;;
+  *)
+    lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
+    ;;
+esac
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
+{ echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_static_works_F77+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_static_works_F77=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_F77=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_F77=yes
+     fi
+   fi
+   $rm -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_F77" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works_F77" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_F77" = xyes; then
+    :
+else
+    lt_prog_compiler_static_F77=
+fi
+
+
+{ 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_prog_compiler_c_o_F77+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o_F77=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:15020: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:15024: \$? = $ac_status" >&5
+   if (exit $ac_status) && 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
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_F77=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6; }
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_F77" = 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
+
+{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
+
+  runpath_var=
+  allow_undefined_flag_F77=
+  enable_shared_with_static_runtimes_F77=no
+  archive_cmds_F77=
+  archive_expsym_cmds_F77=
+  old_archive_From_new_cmds_F77=
+  old_archive_from_expsyms_cmds_F77=
+  export_dynamic_flag_spec_F77=
+  whole_archive_flag_spec_F77=
+  thread_safe_flag_spec_F77=
+  hardcode_libdir_flag_spec_F77=
+  hardcode_libdir_flag_spec_ld_F77=
+  hardcode_libdir_separator_F77=
+  hardcode_direct_F77=no
+  hardcode_minus_L_F77=no
+  hardcode_shlibpath_var_F77=unsupported
+  link_all_deplibs_F77=unknown
+  hardcode_automatic_F77=no
+  module_cmds_F77=
+  module_expsym_cmds_F77=
+  always_export_symbols_F77=no
+  export_symbols_cmds_F77='$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_F77=
+  # exclude_expsyms can be an extended regexp 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_F77='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # 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.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+  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
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs_F77=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec_F77='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+	whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec_F77=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs_F77=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
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds_F77='$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_F77='-L$libdir'
+      hardcode_minus_L_F77=yes
+
+      # Samuel A. Falvo II <kc5tja@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't use
+      # them.
+      ld_shlibs_F77=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag_F77=unsupported
+	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      allow_undefined_flag_F77=unsupported
+      always_export_symbols_F77=no
+      enable_shared_with_static_runtimes_F77=yes
+      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    interix[3-9]*)
+      hardcode_direct_F77=no
+      hardcode_shlibpath_var_F77=no
+      hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec_F77='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | k*bsd*-gnu)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	tmp_addflag=
+	case $cc_basename,$host_cpu in
+	pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	*)
+	  tmp_sharedflag='-shared' ;;
+	esac
+	archive_cmds_F77='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+	if test $supports_anon_versioning = yes; then
+	  archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+	  $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	fi
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+	ld_shlibs_F77=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 | grep ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs_F77=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+	    archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+	    archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+	  else
+	    ld_shlibs_F77=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs_F77" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec_F77=
+      export_dynamic_flag_spec_F77=
+      whole_archive_flag_spec_F77=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_F77=unsupported
+      always_export_symbols_F77=yes
+      archive_expsym_cmds_F77='$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_F77=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct_F77=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      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
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+	  export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	fi
+	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].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+  	    aix_use_runtimelinking=yes
+  	    break
+  	  fi
+	  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.
+
+      archive_cmds_F77=''
+      hardcode_direct_F77=yes
+      hardcode_libdir_separator_F77=':'
+      link_all_deplibs_F77=yes
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" && \
+  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	  then
+  	  # We have reworked collect2
+  	  :
+	  else
+  	  # We have old collect2
+  	  hardcode_direct_F77=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_F77=yes
+  	  hardcode_libdir_flag_spec_F77='-L$libdir'
+  	  hardcode_libdir_separator_F77=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+  	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-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 does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_F77=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_F77='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat >conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+       hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+	archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag_F77="-z nodefs"
+	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an empty executable.
+	 cat >conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag_F77=' ${wl}-bernotok'
+	  allow_undefined_flag_F77=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec_F77='$convenience'
+	  archive_cmds_need_lc_F77=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds_F77='$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_F77='-L$libdir'
+      hardcode_minus_L_F77=yes
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs_F77=no
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec_F77=-rdynamic
+      ;;
+
+    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_F77=' '
+      allow_undefined_flag_F77=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_F77='$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_F77='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_F77='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_F77=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[012])
+         allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[012])
+               allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      archive_cmds_need_lc_F77=no
+      hardcode_direct_F77=no
+      hardcode_automatic_F77=yes
+      hardcode_shlibpath_var_F77=unsupported
+      whole_archive_flag_spec_F77=''
+      link_all_deplibs_F77=yes
+    if test "$GCC" = yes ; then
+    	output_verbose_link_cmd='echo'
+        archive_cmds_F77="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        module_cmds_F77="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        archive_expsym_cmds_F77="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        module_expsym_cmds_F77="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
+         module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         ld_shlibs_F77=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs_F77=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_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds_F77='$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'
+      fi
+      hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      hardcode_direct_F77=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_F77=yes
+      export_dynamic_flag_spec_F77='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_F77=:
+
+	hardcode_direct_F77=yes
+	export_dynamic_flag_spec_F77='${wl}-E'
+
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L_F77=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_F77=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_libdir_flag_spec_ld_F77='+b $libdir'
+	  hardcode_direct_F77=no
+	  hardcode_shlibpath_var_F77=no
+	  ;;
+	*)
+	  hardcode_direct_F77=yes
+	  export_dynamic_flag_spec_F77='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_F77=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$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'
+      else
+	archive_cmds_F77='$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_ld_F77='-rpath $libdir'
+      fi
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      link_all_deplibs_F77=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    newsos6)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct_F77=yes
+	hardcode_shlibpath_var_F77=no
+	if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec_F77='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec_F77='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+        fi
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_minus_L_F77=yes
+      allow_undefined_flag_F77=unsupported
+      archive_cmds_F77='$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_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_F77='$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_F77=' -expect_unresolved \*'
+	archive_cmds_F77='$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_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_F77='$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_F77='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag_F77=' -expect_unresolved \*'
+	archive_cmds_F77='$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_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$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 ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec_F77='-rpath $libdir'
+      fi
+      hardcode_libdir_separator_F77=:
+      ;;
+
+    solaris*)
+      no_undefined_flag_F77=' -z text'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+	wlarc=''
+	archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	archive_expsym_cmds_F77='$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'
+      fi
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_shlibpath_var_F77=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+ 	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec_F77='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs_F77=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_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_F77=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds_F77='$CC -r -o $output$reload_objs'
+	  hardcode_direct_F77=no
+        ;;
+	motorola)
+	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_F77=no
+      export_dynamic_flag_spec_F77='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var_F77=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs_F77=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_F77='${wl}-z,text'
+      archive_cmds_need_lc_F77=no
+      hardcode_shlibpath_var_F77=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag_F77='${wl}-z,text'
+      allow_undefined_flag_F77='${wl}-z,nodefs'
+      archive_cmds_need_lc_F77=no
+      hardcode_shlibpath_var_F77=no
+      hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      hardcode_libdir_separator_F77=':'
+      link_all_deplibs_F77=yes
+      export_dynamic_flag_spec_F77='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    *)
+      ld_shlibs_F77=no
+      ;;
+    esac
+  fi
+
+{ echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
+echo "${ECHO_T}$ld_shlibs_F77" >&6; }
+test "$ld_shlibs_F77" = no && can_build_shared=no
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_F77" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_F77=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_F77 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; }
+      $rm conftest*
+      echo "$lt_simple_compile_test_code" > 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); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_F77
+	pic_flag=$lt_prog_compiler_pic_F77
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_F77
+        allow_undefined_flag_F77=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc_F77=no
+        else
+	  archive_cmds_need_lc_F77=yes
+        fi
+        allow_undefined_flag_F77=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+{ 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=
+shrext_cmds=".so"
+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"
+
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  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}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    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}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+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}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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"
+  # 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
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $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
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  # Handle Gentoo/FreeBSD as it was Linux
+  case $host_vendor in
+    gentoo)
+      version_type=linux ;;
+    *)
+      version_type=freebsd-$objformat ;;
+  esac
+
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+    linux)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+      soname_spec='${libname}${release}${shared_ext}$major'
+      need_lib_prefix=no
+      need_version=no
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      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}"
+  hardcode_into_libs=yes
+  ;;
+
+# 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* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # 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}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  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
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  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"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${shared_ext}$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.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  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
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+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
+
+{ 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_F77=
+if test -n "$hardcode_libdir_flag_spec_F77" || \
+   test -n "$runpath_var_F77" || \
+   test "X$hardcode_automatic_F77" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct_F77" != 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 "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
+     test "$hardcode_minus_L_F77" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_F77=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_F77=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_F77=unsupported
+fi
+{ echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
+echo "${ECHO_T}$hardcode_action_F77" >&6; }
+
+if test "$hardcode_action_F77" = 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
+
+
+# The else 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
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # 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 AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_F77 \
+    CC_F77 \
+    LD_F77 \
+    lt_prog_compiler_wl_F77 \
+    lt_prog_compiler_pic_F77 \
+    lt_prog_compiler_static_F77 \
+    lt_prog_compiler_no_builtin_flag_F77 \
+    export_dynamic_flag_spec_F77 \
+    thread_safe_flag_spec_F77 \
+    whole_archive_flag_spec_F77 \
+    enable_shared_with_static_runtimes_F77 \
+    old_archive_cmds_F77 \
+    old_archive_from_new_cmds_F77 \
+    predep_objects_F77 \
+    postdep_objects_F77 \
+    predeps_F77 \
+    postdeps_F77 \
+    compiler_lib_search_path_F77 \
+    compiler_lib_search_dirs_F77 \
+    archive_cmds_F77 \
+    archive_expsym_cmds_F77 \
+    postinstall_cmds_F77 \
+    postuninstall_cmds_F77 \
+    old_archive_from_expsyms_cmds_F77 \
+    allow_undefined_flag_F77 \
+    no_undefined_flag_F77 \
+    export_symbols_cmds_F77 \
+    hardcode_libdir_flag_spec_F77 \
+    hardcode_libdir_flag_spec_ld_F77 \
+    hardcode_libdir_separator_F77 \
+    hardcode_automatic_F77 \
+    module_cmds_F77 \
+    module_expsym_cmds_F77 \
+    lt_cv_prog_compiler_c_o_F77 \
+    fix_srcfile_path_F77 \
+    exclude_expsyms_F77 \
+    include_expsyms_F77; do
+
+    case $var in
+    old_archive_cmds_F77 | \
+    old_archive_from_new_cmds_F77 | \
+    archive_cmds_F77 | \
+    archive_expsym_cmds_F77 | \
+    module_cmds_F77 | \
+    module_expsym_cmds_F77 | \
+    old_archive_from_expsyms_cmds_F77 | \
+    export_symbols_cmds_F77 | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_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
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="$ofile"
+
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# 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=$archive_cmds_need_lc_F77
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
+# A language-specific compiler.
+CC=$lt_compiler_F77
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_F77
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_F77
+
+# 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=$lt_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="$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_lt_prog_compiler_wl_F77
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_F77
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
+
+# 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_lt_prog_compiler_static_F77
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77
+
+# 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_F77
+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_F77
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_F77
+archive_expsym_cmds=$lt_archive_expsym_cmds_F77
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_F77
+module_expsym_cmds=$lt_module_expsym_cmds_F77
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_F77
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_F77
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_F77
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_F77
+
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_F77
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_F77
+
+# 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_F77
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_F77
+
+# 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_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_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_F77
+
+# 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_F77
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_F77
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_F77
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_F77
+
+# 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_F77
+
+# 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=$lt_fix_srcfile_path
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_F77
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_F77
+
+# 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_F77
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_F77
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+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.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+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
+
+CC="$lt_save_CC"
+
+	else
+	  tagname=""
+	fi
+	;;
+
+      GCJ)
+	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+objext_GCJ=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm -r conftest*
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+compiler_GCJ=$CC
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+archive_cmds_need_lc_GCJ=no
+
+old_archive_cmds_GCJ=$old_archive_cmds
+
+
+lt_prog_compiler_no_builtin_flag_GCJ=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
+
+
+{ 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; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+  ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:17240: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:17244: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+lt_prog_compiler_wl_GCJ=
+lt_prog_compiler_pic_GCJ=
+lt_prog_compiler_static_GCJ=
+
+{ 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 "$GCC" = yes; then
+    lt_prog_compiler_wl_GCJ='-Wl,'
+    lt_prog_compiler_static_GCJ='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_GCJ='-Bstatic'
+      fi
+      ;;
+
+    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_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | 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).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_GCJ='-fno-common'
+      ;;
+
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_GCJ=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_GCJ=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_GCJ='-fPIC'
+	;;
+      esac
+      ;;
+
+    *)
+      lt_prog_compiler_pic_GCJ='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_GCJ='-Bstatic'
+      else
+	lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         lt_prog_compiler_pic_GCJ='-qnocommon'
+         lt_prog_compiler_wl_GCJ='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | cygwin* | 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).
+
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_GCJ='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_GCJ='-non_shared'
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc*)
+	lt_prog_compiler_wl_GCJ='-Wl,'
+	lt_prog_compiler_pic_GCJ='-KPIC'
+	lt_prog_compiler_static_GCJ='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl_GCJ='-Wl,'
+	lt_prog_compiler_pic_GCJ='-fpic'
+	lt_prog_compiler_static_GCJ='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_GCJ='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_GCJ='-non_shared'
+        ;;
+      *)
+        case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic_GCJ='-KPIC'
+	  lt_prog_compiler_static_GCJ='-Bstatic'
+	  lt_prog_compiler_wl_GCJ='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic_GCJ='-KPIC'
+	  lt_prog_compiler_static_GCJ='-Bstatic'
+	  lt_prog_compiler_wl_GCJ=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_GCJ='-non_shared'
+      ;;
+
+    rdos*)
+      lt_prog_compiler_static_GCJ='-non_shared'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	lt_prog_compiler_wl_GCJ='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl_GCJ='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl_GCJ='-Qoption ld '
+      lt_prog_compiler_pic_GCJ='-PIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic_GCJ='-Kconform_pic'
+	lt_prog_compiler_static_GCJ='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_can_build_shared_GCJ=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic_GCJ='-pic'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared_GCJ=no
+      ;;
+    esac
+  fi
+
+{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6; }
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_GCJ"; then
+
+{ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_pic_works_GCJ+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_pic_works_GCJ=no
+  ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:17530: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:17534: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_GCJ=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_GCJ" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_GCJ" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_GCJ" = xyes; then
+    case $lt_prog_compiler_pic_GCJ in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
+     esac
+else
+    lt_prog_compiler_pic_GCJ=
+     lt_prog_compiler_can_build_shared_GCJ=no
+fi
+
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_GCJ=
+    ;;
+  *)
+    lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
+    ;;
+esac
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\"
+{ echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
+if test "${lt_cv_prog_compiler_static_works_GCJ+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_static_works_GCJ=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_GCJ=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_GCJ=yes
+     fi
+   fi
+   $rm -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_GCJ" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_static_works_GCJ" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_GCJ" = xyes; then
+    :
+else
+    lt_prog_compiler_static_GCJ=
+fi
+
+
+{ 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_prog_compiler_c_o_GCJ+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_prog_compiler_c_o_GCJ=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:17634: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:17638: \$? = $ac_status" >&5
+   if (exit $ac_status) && 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
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_GCJ=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+
+fi
+{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6; }
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_GCJ" = 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
+
+{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
+
+  runpath_var=
+  allow_undefined_flag_GCJ=
+  enable_shared_with_static_runtimes_GCJ=no
+  archive_cmds_GCJ=
+  archive_expsym_cmds_GCJ=
+  old_archive_From_new_cmds_GCJ=
+  old_archive_from_expsyms_cmds_GCJ=
+  export_dynamic_flag_spec_GCJ=
+  whole_archive_flag_spec_GCJ=
+  thread_safe_flag_spec_GCJ=
+  hardcode_libdir_flag_spec_GCJ=
+  hardcode_libdir_flag_spec_ld_GCJ=
+  hardcode_libdir_separator_GCJ=
+  hardcode_direct_GCJ=no
+  hardcode_minus_L_GCJ=no
+  hardcode_shlibpath_var_GCJ=unsupported
+  link_all_deplibs_GCJ=unknown
+  hardcode_automatic_GCJ=no
+  module_cmds_GCJ=
+  module_expsym_cmds_GCJ=
+  always_export_symbols_GCJ=no
+  export_symbols_cmds_GCJ='$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_GCJ=
+  # exclude_expsyms can be an extended regexp 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_GCJ='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # 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.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+  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
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs_GCJ=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+	whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	whole_archive_flag_spec_GCJ=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs_GCJ=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
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds_GCJ='$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_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+
+      # Samuel A. Falvo II <kc5tja@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't use
+      # them.
+      ld_shlibs_GCJ=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag_GCJ=unsupported
+	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      allow_undefined_flag_GCJ=unsupported
+      always_export_symbols_GCJ=no
+      enable_shared_with_static_runtimes_GCJ=yes
+      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    interix[3-9]*)
+      hardcode_direct_GCJ=no
+      hardcode_shlibpath_var_GCJ=no
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec_GCJ='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | k*bsd*-gnu)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	tmp_addflag=
+	case $cc_basename,$host_cpu in
+	pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	*)
+	  tmp_sharedflag='-shared' ;;
+	esac
+	archive_cmds_GCJ='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+	if test $supports_anon_versioning = yes; then
+	  archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+	  $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	fi
+      else
+	ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+	ld_shlibs_GCJ=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 | grep ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs_GCJ=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+	    archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+	    archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+	  else
+	    ld_shlibs_GCJ=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_GCJ=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs_GCJ" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec_GCJ=
+      export_dynamic_flag_spec_GCJ=
+      whole_archive_flag_spec_GCJ=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_GCJ=unsupported
+      always_export_symbols_GCJ=yes
+      archive_expsym_cmds_GCJ='$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_GCJ=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct_GCJ=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      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
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+	  export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+	fi
+	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].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+  	    aix_use_runtimelinking=yes
+  	    break
+  	  fi
+	  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.
+
+      archive_cmds_GCJ=''
+      hardcode_direct_GCJ=yes
+      hardcode_libdir_separator_GCJ=':'
+      link_all_deplibs_GCJ=yes
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" && \
+  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	  then
+  	  # We have reworked collect2
+  	  :
+	  else
+  	  # We have old collect2
+  	  hardcode_direct_GCJ=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_GCJ=yes
+  	  hardcode_libdir_flag_spec_GCJ='-L$libdir'
+  	  hardcode_libdir_separator_GCJ=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+  	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-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 does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_GCJ=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_GCJ='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+       hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+	archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag_GCJ="-z nodefs"
+	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an empty executable.
+	 cat >conftest.$ac_ext <<_ACEOF
+/* 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 { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag_GCJ=' ${wl}-bernotok'
+	  allow_undefined_flag_GCJ=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec_GCJ='$convenience'
+	  archive_cmds_need_lc_GCJ=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds_GCJ='$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_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs_GCJ=no
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec_GCJ=-rdynamic
+      ;;
+
+    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_GCJ=' '
+      allow_undefined_flag_GCJ=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_GCJ='$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_GCJ='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_GCJ='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_GCJ=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[012])
+         allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[012])
+               allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      archive_cmds_need_lc_GCJ=no
+      hardcode_direct_GCJ=no
+      hardcode_automatic_GCJ=yes
+      hardcode_shlibpath_var_GCJ=unsupported
+      whole_archive_flag_spec_GCJ=''
+      link_all_deplibs_GCJ=yes
+    if test "$GCC" = yes ; then
+    	output_verbose_link_cmd='echo'
+        archive_cmds_GCJ="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        module_cmds_GCJ="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        archive_expsym_cmds_GCJ="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        module_expsym_cmds_GCJ="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
+         module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         ld_shlibs_GCJ=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs_GCJ=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_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds_GCJ='$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'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      hardcode_direct_GCJ=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_GCJ=yes
+      export_dynamic_flag_spec_GCJ='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_GCJ=:
+
+	hardcode_direct_GCJ=yes
+	export_dynamic_flag_spec_GCJ='${wl}-E'
+
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L_GCJ=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_GCJ=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
+	  hardcode_direct_GCJ=no
+	  hardcode_shlibpath_var_GCJ=no
+	  ;;
+	*)
+	  hardcode_direct_GCJ=yes
+	  export_dynamic_flag_spec_GCJ='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_GCJ=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds_GCJ='$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'
+      else
+	archive_cmds_GCJ='$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_ld_GCJ='-rpath $libdir'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      link_all_deplibs_GCJ=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    newsos6)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct_GCJ=yes
+	hardcode_shlibpath_var_GCJ=no
+	if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec_GCJ='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec_GCJ='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+        fi
+      else
+	ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+      allow_undefined_flag_GCJ=unsupported
+      archive_cmds_GCJ='$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_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_GCJ='$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_GCJ=' -expect_unresolved \*'
+	archive_cmds_GCJ='$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_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_GCJ='$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_GCJ='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag_GCJ=' -expect_unresolved \*'
+	archive_cmds_GCJ='$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_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$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 ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
+      fi
+      hardcode_libdir_separator_GCJ=:
+      ;;
+
+    solaris*)
+      no_undefined_flag_GCJ=' -z text'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+	wlarc=''
+	archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	archive_expsym_cmds_GCJ='$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'
+      fi
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+ 	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs_GCJ=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_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_GCJ=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds_GCJ='$CC -r -o $output$reload_objs'
+	  hardcode_direct_GCJ=no
+        ;;
+	motorola)
+	  archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_GCJ=no
+      export_dynamic_flag_spec_GCJ='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var_GCJ=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs_GCJ=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_GCJ='${wl}-z,text'
+      archive_cmds_need_lc_GCJ=no
+      hardcode_shlibpath_var_GCJ=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag_GCJ='${wl}-z,text'
+      allow_undefined_flag_GCJ='${wl}-z,nodefs'
+      archive_cmds_need_lc_GCJ=no
+      hardcode_shlibpath_var_GCJ=no
+      hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      hardcode_libdir_separator_GCJ=':'
+      link_all_deplibs_GCJ=yes
+      export_dynamic_flag_spec_GCJ='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    *)
+      ld_shlibs_GCJ=no
+      ;;
+    esac
+  fi
+
+{ echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5
+echo "${ECHO_T}$ld_shlibs_GCJ" >&6; }
+test "$ld_shlibs_GCJ" = no && can_build_shared=no
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_GCJ" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_GCJ=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_GCJ 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; }
+      $rm conftest*
+      echo "$lt_simple_compile_test_code" > 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); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_GCJ
+	pic_flag=$lt_prog_compiler_pic_GCJ
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
+        allow_undefined_flag_GCJ=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc_GCJ=no
+        else
+	  archive_cmds_need_lc_GCJ=yes
+        fi
+        allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+{ 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=
+shrext_cmds=".so"
+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"
+
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  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}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    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}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+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}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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"
+  # 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
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $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
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  # Handle Gentoo/FreeBSD as it was Linux
+  case $host_vendor in
+    gentoo)
+      version_type=linux ;;
+    *)
+      version_type=freebsd-$objformat ;;
+  esac
+
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+    linux)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+      soname_spec='${libname}${release}${shared_ext}$major'
+      need_lib_prefix=no
+      need_version=no
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      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}"
+  hardcode_into_libs=yes
+  ;;
+
+# 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* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # 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}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  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
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  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"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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}${shared_ext}$versuffix ${libname}${shared_ext}$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.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$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
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  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
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"
+fi
+
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"
+fi
+
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+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
+
+{ 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_GCJ=
+if test -n "$hardcode_libdir_flag_spec_GCJ" || \
+   test -n "$runpath_var_GCJ" || \
+   test "X$hardcode_automatic_GCJ" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct_GCJ" != 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 "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
+     test "$hardcode_minus_L_GCJ" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_GCJ=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_GCJ=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_GCJ=unsupported
+fi
+{ echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5
+echo "${ECHO_T}$hardcode_action_GCJ" >&6; }
+
+if test "$hardcode_action_GCJ" = 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
+
+
+# The else 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
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # 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 AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_GCJ \
+    CC_GCJ \
+    LD_GCJ \
+    lt_prog_compiler_wl_GCJ \
+    lt_prog_compiler_pic_GCJ \
+    lt_prog_compiler_static_GCJ \
+    lt_prog_compiler_no_builtin_flag_GCJ \
+    export_dynamic_flag_spec_GCJ \
+    thread_safe_flag_spec_GCJ \
+    whole_archive_flag_spec_GCJ \
+    enable_shared_with_static_runtimes_GCJ \
+    old_archive_cmds_GCJ \
+    old_archive_from_new_cmds_GCJ \
+    predep_objects_GCJ \
+    postdep_objects_GCJ \
+    predeps_GCJ \
+    postdeps_GCJ \
+    compiler_lib_search_path_GCJ \
+    compiler_lib_search_dirs_GCJ \
+    archive_cmds_GCJ \
+    archive_expsym_cmds_GCJ \
+    postinstall_cmds_GCJ \
+    postuninstall_cmds_GCJ \
+    old_archive_from_expsyms_cmds_GCJ \
+    allow_undefined_flag_GCJ \
+    no_undefined_flag_GCJ \
+    export_symbols_cmds_GCJ \
+    hardcode_libdir_flag_spec_GCJ \
+    hardcode_libdir_flag_spec_ld_GCJ \
+    hardcode_libdir_separator_GCJ \
+    hardcode_automatic_GCJ \
+    module_cmds_GCJ \
+    module_expsym_cmds_GCJ \
+    lt_cv_prog_compiler_c_o_GCJ \
+    fix_srcfile_path_GCJ \
+    exclude_expsyms_GCJ \
+    include_expsyms_GCJ; do
+
+    case $var in
+    old_archive_cmds_GCJ | \
+    old_archive_from_new_cmds_GCJ | \
+    archive_cmds_GCJ | \
+    archive_expsym_cmds_GCJ | \
+    module_cmds_GCJ | \
+    module_expsym_cmds_GCJ | \
+    old_archive_from_expsyms_cmds_GCJ | \
+    export_symbols_cmds_GCJ | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_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
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="$ofile"
+
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# 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=$archive_cmds_need_lc_GCJ
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
+# A language-specific compiler.
+CC=$lt_compiler_GCJ
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_GCJ
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_GCJ
+
+# 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=$lt_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="$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_lt_prog_compiler_wl_GCJ
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_GCJ
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
+
+# 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_lt_prog_compiler_static_GCJ
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ
+
+# 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_GCJ
+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_GCJ
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_GCJ
+archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_GCJ
+module_expsym_cmds=$lt_module_expsym_cmds_GCJ
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_GCJ
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_GCJ
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_GCJ
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_GCJ
+
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_GCJ
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
+
+# 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_GCJ
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_GCJ
+
+# 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_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_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_GCJ
+
+# 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_GCJ
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_GCJ
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_GCJ
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_GCJ
+
+# 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_GCJ
+
+# 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=$lt_fix_srcfile_path
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_GCJ
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_GCJ
+
+# 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_GCJ
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_GCJ
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+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.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+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
+
+CC="$lt_save_CC"
+
+	else
+	  tagname=""
+	fi
+	;;
+
+      RC)
+
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+objext_RC=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm -r conftest*
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+compiler_RC=$CC
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+lt_cv_prog_compiler_c_o_RC=yes
+
+# The else 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
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # 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 AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_RC \
+    CC_RC \
+    LD_RC \
+    lt_prog_compiler_wl_RC \
+    lt_prog_compiler_pic_RC \
+    lt_prog_compiler_static_RC \
+    lt_prog_compiler_no_builtin_flag_RC \
+    export_dynamic_flag_spec_RC \
+    thread_safe_flag_spec_RC \
+    whole_archive_flag_spec_RC \
+    enable_shared_with_static_runtimes_RC \
+    old_archive_cmds_RC \
+    old_archive_from_new_cmds_RC \
+    predep_objects_RC \
+    postdep_objects_RC \
+    predeps_RC \
+    postdeps_RC \
+    compiler_lib_search_path_RC \
+    compiler_lib_search_dirs_RC \
+    archive_cmds_RC \
+    archive_expsym_cmds_RC \
+    postinstall_cmds_RC \
+    postuninstall_cmds_RC \
+    old_archive_from_expsyms_cmds_RC \
+    allow_undefined_flag_RC \
+    no_undefined_flag_RC \
+    export_symbols_cmds_RC \
+    hardcode_libdir_flag_spec_RC \
+    hardcode_libdir_flag_spec_ld_RC \
+    hardcode_libdir_separator_RC \
+    hardcode_automatic_RC \
+    module_cmds_RC \
+    module_expsym_cmds_RC \
+    lt_cv_prog_compiler_c_o_RC \
+    fix_srcfile_path_RC \
+    exclude_expsyms_RC \
+    include_expsyms_RC; do
+
+    case $var in
+    old_archive_cmds_RC | \
+    old_archive_from_new_cmds_RC | \
+    archive_cmds_RC | \
+    archive_expsym_cmds_RC | \
+    module_cmds_RC | \
+    module_expsym_cmds_RC | \
+    old_archive_from_expsyms_cmds_RC | \
+    export_symbols_cmds_RC | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_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
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="$ofile"
+
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# 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=$archive_cmds_need_lc_RC
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
+# A language-specific compiler.
+CC=$lt_compiler_RC
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_RC
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_RC
+
+# 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=$lt_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="$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_lt_prog_compiler_wl_RC
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_RC
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
+
+# 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_lt_prog_compiler_static_RC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC
+
+# 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_RC
+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_RC
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_RC
+archive_expsym_cmds=$lt_archive_expsym_cmds_RC
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_RC
+module_expsym_cmds=$lt_module_expsym_cmds_RC
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_RC
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_RC
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_RC
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_RC
+
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_RC
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_RC
+
+# 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_RC
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_RC
+
+# 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_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_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_RC
+
+# 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_RC
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_RC
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_RC
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_RC
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_RC
+
+# 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_RC
+
+# 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=$lt_fix_srcfile_path
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_RC
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_RC
+
+# 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_RC
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_RC
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+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.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+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
+
+CC="$lt_save_CC"
+
+	;;
+
+      *)
+	{ { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5
+echo "$as_me: error: Unsupported tag name: $tagname" >&2;}
+   { (exit 1); exit 1; }; }
+	;;
+      esac
+
+      # Append the new tag name to the list of available tags.
+      if test -n "$tagname" ; then
+      available_tags="$available_tags $tagname"
+    fi
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  # Now substitute the updated list of available tags.
+  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+    mv "${ofile}T" "$ofile"
+    chmod +x "$ofile"
+  else
+    rm -f "${ofile}T"
+    { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5
+echo "$as_me: error: unable to update list of available tagged configurations." >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+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 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
+
+
+PCRE_MAJOR="7"
+PCRE_MINOR="8"
+PCRE_PRERELEASE=""
+PCRE_DATE="2008-09-05"
+
+
+
+
+
+
+# Set a more sensible default value for $(htmldir).
+if test "x$htmldir" = 'x${docdir}'
+then
+  htmldir='${docdir}/html'
+fi
+
+# Handle --disable-cpp
+# Check whether --enable-cpp was given.
+if test "${enable_cpp+set}" = set; then
+  enableval=$enable_cpp;
+else
+  enable_cpp=yes
+fi
+
+
+# Handle --enable-rebuild-chartables
+# Check whether --enable-rebuild-chartables was given.
+if test "${enable_rebuild_chartables+set}" = set; then
+  enableval=$enable_rebuild_chartables;
+else
+  enable_rebuild_chartables=no
+fi
+
+
+# Handle --enable-utf8 (disabled by default)
+# Check whether --enable-utf8 was given.
+if test "${enable_utf8+set}" = set; then
+  enableval=$enable_utf8;
+else
+  enable_utf8=unset
+fi
+
+
+# Handle --enable-unicode-properties
+# Check whether --enable-unicode-properties was given.
+if test "${enable_unicode_properties+set}" = set; then
+  enableval=$enable_unicode_properties;
+else
+  enable_unicode_properties=no
+fi
+
+
+# Handle --enable-newline=NL
+
+# Separate newline options
+ac_pcre_newline=lf
+# Check whether --enable-newline-is-cr was given.
+if test "${enable_newline_is_cr+set}" = set; then
+  enableval=$enable_newline_is_cr; ac_pcre_newline=cr
+fi
+
+# Check whether --enable-newline-is-lf was given.
+if test "${enable_newline_is_lf+set}" = set; then
+  enableval=$enable_newline_is_lf; ac_pcre_newline=lf
+fi
+
+# Check whether --enable-newline-is-crlf was given.
+if test "${enable_newline_is_crlf+set}" = set; then
+  enableval=$enable_newline_is_crlf; ac_pcre_newline=crlf
+fi
+
+# Check whether --enable-newline-is-anycrlf was given.
+if test "${enable_newline_is_anycrlf+set}" = set; then
+  enableval=$enable_newline_is_anycrlf; ac_pcre_newline=anycrlf
+fi
+
+# Check whether --enable-newline-is-any was given.
+if test "${enable_newline_is_any+set}" = set; then
+  enableval=$enable_newline_is_any; ac_pcre_newline=any
+fi
+
+enable_newline="$ac_pcre_newline"
+
+# Handle --enable-bsr-anycrlf
+# Check whether --enable-bsr-anycrlf was given.
+if test "${enable_bsr_anycrlf+set}" = set; then
+  enableval=$enable_bsr_anycrlf;
+else
+  enable_bsr_anycrlf=no
+fi
+
+
+# Handle --enable-ebcdic
+# Check whether --enable-ebcdic was given.
+if test "${enable_ebcdic+set}" = set; then
+  enableval=$enable_ebcdic;
+else
+  enable_ebcdic=no
+fi
+
+
+# Handle --disable-stack-for-recursion
+# Check whether --enable-stack-for-recursion was given.
+if test "${enable_stack_for_recursion+set}" = set; then
+  enableval=$enable_stack_for_recursion;
+else
+  enable_stack_for_recursion=yes
+fi
+
+
+# Handle --enable-pcregrep-libz
+# Check whether --enable-pcregrep-libz was given.
+if test "${enable_pcregrep_libz+set}" = set; then
+  enableval=$enable_pcregrep_libz;
+else
+  enable_pcregrep_libz=no
+fi
+
+
+# Handle --enable-pcregrep-libbz2
+# Check whether --enable-pcregrep-libbz2 was given.
+if test "${enable_pcregrep_libbz2+set}" = set; then
+  enableval=$enable_pcregrep_libbz2;
+else
+  enable_pcregrep_libbz2=no
+fi
+
+
+# Handle --enable-pcretest-libreadline
+# Check whether --enable-pcretest-libreadline was given.
+if test "${enable_pcretest_libreadline+set}" = set; then
+  enableval=$enable_pcretest_libreadline;
+else
+  enable_pcretest_libreadline=no
+fi
+
+
+# Handle --with-posix-malloc-threshold=NBYTES
+
+# Check whether --with-posix-malloc-threshold was given.
+if test "${with_posix_malloc_threshold+set}" = set; then
+  withval=$with_posix_malloc_threshold;
+else
+  with_posix_malloc_threshold=10
+fi
+
+
+# Handle --with-link-size=N
+
+# Check whether --with-link-size was given.
+if test "${with_link_size+set}" = set; then
+  withval=$with_link_size;
+else
+  with_link_size=2
+fi
+
+
+# Handle --with-match-limit=N
+
+# Check whether --with-match-limit was given.
+if test "${with_match_limit+set}" = set; then
+  withval=$with_match_limit;
+else
+  with_match_limit=10000000
+fi
+
+
+# Handle --with-match-limit_recursion=N
+#
+# Note: In config.h, the default is to define MATCH_LIMIT_RECURSION
+# symbolically as MATCH_LIMIT, which in turn is defined to be some numeric
+# value (e.g. 10000000). MATCH_LIMIT_RECURSION can otherwise be set to some
+# different numeric value (or even the same numeric value as MATCH_LIMIT,
+# though no longer defined in terms of the latter).
+#
+
+# Check whether --with-match-limit-recursion was given.
+if test "${with_match_limit_recursion+set}" = set; then
+  withval=$with_match_limit_recursion;
+else
+  with_match_limit_recursion=MATCH_LIMIT
+fi
+
+
+# Make sure that if enable_unicode_properties was set, that UTF-8 support
+# is enabled.
+#
+if test "x$enable_unicode_properties" = "xyes"
+then
+  if test "x$enable_utf8" = "xno"
+  then
+    { { echo "$as_me:$LINENO: error: support for Unicode properties requires UTF-8 support" >&5
+echo "$as_me: error: support for Unicode properties requires UTF-8 support" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+  enable_utf8=yes
+fi
+
+if test "x$enable_utf8" = "xunset"
+then
+  enable_utf8=no
+fi
+
+# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
+#
+if test "x$enable_ebcdic" = "xyes"
+then
+  enable_rebuild_chartables=yes
+fi
+
+# Convert the newline identifier into the appropriate integer value.
+case "$enable_newline" in
+  lf)      ac_pcre_newline_value=10   ;;
+  cr)      ac_pcre_newline_value=13   ;;
+  crlf)    ac_pcre_newline_value=3338 ;;
+  anycrlf) ac_pcre_newline_value=-2   ;;
+  any)     ac_pcre_newline_value=-1   ;;
+  *)
+  { { echo "$as_me:$LINENO: error: invalid argument \"$enable_newline\" to --enable-newline option" >&5
+echo "$as_me: error: invalid argument \"$enable_newline\" to --enable-newline option" >&2;}
+   { (exit 1); exit 1; }; }
+  ;;
+esac
+
+# Check argument to --with-link-size
+case "$with_link_size" in
+  2|3|4) ;;
+  *)
+  { { echo "$as_me:$LINENO: error: invalid argument \"$with_link_size\" to --with-link-size option" >&5
+echo "$as_me: error: invalid argument \"$with_link_size\" to --with-link-size option" >&2;}
+   { (exit 1); exit 1; }; }
+  ;;
+esac
+
+
+
+
+# Checks for header files.
+{ 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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* 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
+/* 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.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))
+      return 2;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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.conftest.* 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
+
+
+
+
+
+
+for ac_header in limits.h sys/types.h sys/stat.h dirent.h windows.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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:$ac_c_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+
+
+# The files below are C++ header files.
+pcre_have_type_traits="0"
+pcre_have_bits_type_traits="0"
+if test "x$enable_cpp" = "xyes" -a -n "$CXX"
+then
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+# Older versions of pcre defined pcrecpp::no_arg, but in new versions
+# it's called pcrecpp::RE::no_arg.  For backwards ABI compatibility,
+# we want to make one an alias for the other.  Different systems do
+# this in different ways.  Some systems, for instance, can do it via
+# a linker flag: -alias (for os x 10.5) or -i (for os x <=10.4).
+OLD_LDFLAGS="$LDFLAGS"
+for flag in "-alias,__ZN7pcrecpp2RE6no_argE,__ZN7pcrecpp6no_argE" \
+            "-i__ZN7pcrecpp6no_argE:__ZN7pcrecpp2RE6no_argE"; do
+  { echo "$as_me:$LINENO: checking for alias support in the linker" >&5
+echo $ECHO_N "checking for alias support in the linker... $ECHO_C" >&6; }
+  LDFLAGS="$OLD_LDFLAGS -Wl,$flag"
+  # We try to run the linker with this new ld flag.  If the link fails,
+  # we give up and remove the new flag from LDFLAGS.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+namespace pcrecpp {
+                                    class RE { static int no_arg; };
+                                    int RE::no_arg;
+                                  }
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; };
+                  EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS -Wl,$flag";
+                  break;
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	{ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+done
+LDFLAGS="$OLD_LDFLAGS"
+
+# We could be more clever here, given we're doing AC_SUBST with this
+# (eg set a var to be the name of the include file we want). But we're not
+# so it's easy to change back to 'regular' autoconf vars if we needed to.
+
+
+for ac_header in string
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.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:$ac_cxx_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+ pcre_have_cpp_headers="1"
+else
+  pcre_have_cpp_headers="0"
+fi
+
+done
+
+
+for ac_header in bits/type_traits.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.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:$ac_cxx_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+ pcre_have_bits_type_traits="1"
+else
+  pcre_have_bits_type_traits="0"
+fi
+
+done
+
+
+for ac_header in type_traits.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.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:$ac_cxx_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+ pcre_have_type_traits="1"
+else
+  pcre_have_type_traits="0"
+fi
+
+done
+
+
+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
+# Using AC_SUBST eliminates the need to include config.h in a public .h file
+
+
+
+# Conditional compilation
+ if test "x$enable_cpp" = "xyes"; then
+  WITH_PCRE_CPP_TRUE=
+  WITH_PCRE_CPP_FALSE='#'
+else
+  WITH_PCRE_CPP_TRUE='#'
+  WITH_PCRE_CPP_FALSE=
+fi
+
+ if test "x$enable_rebuild_chartables" = "xyes"; then
+  WITH_REBUILD_CHARTABLES_TRUE=
+  WITH_REBUILD_CHARTABLES_FALSE='#'
+else
+  WITH_REBUILD_CHARTABLES_TRUE='#'
+  WITH_REBUILD_CHARTABLES_FALSE=
+fi
+
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+{ 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
+/* 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 cs;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *pcpcc;
+  char **ppc;
+  /* 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";
+  pcpcc = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++pcpcc;
+  ppc = (char**) pcpcc;
+  pcpcc = (char const *const *) ppc;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+    if (s) return 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;
+    if (!foo) return 0;
+  }
+  return !cs[0] && !zero.x;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef size_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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 int
+_ACEOF
+
+fi
+
+
+pcre_have_strotolonglong=0
+
+
+
+for ac_func in strtoq strtoll _strtoi64
+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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* 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
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+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
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+ pcre_have_strotolonglong="1"; break
+fi
+done
+
+# If we can't convert a string to a long long, pretend we don't even
+# have a long long.
+if test $pcre_have_strotolonglong = "0"; then
+   pcre_have_long_long="0"
+   pcre_have_ulong_long="0"
+else
+  { echo "$as_me:$LINENO: checking for long long" >&5
+echo $ECHO_N "checking for long long... $ECHO_C" >&6; }
+if test "${ac_cv_type_long_long+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef long long ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_long_long=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_long_long=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5
+echo "${ECHO_T}$ac_cv_type_long_long" >&6; }
+if test $ac_cv_type_long_long = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_LONG_LONG 1
+_ACEOF
+
+pcre_have_long_long="1"
+else
+  pcre_have_long_long="0"
+fi
+
+  { echo "$as_me:$LINENO: checking for unsigned long long" >&5
+echo $ECHO_N "checking for unsigned long long... $ECHO_C" >&6; }
+if test "${ac_cv_type_unsigned_long_long+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef unsigned long long ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_unsigned_long_long=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_unsigned_long_long=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_unsigned_long_long" >&5
+echo "${ECHO_T}$ac_cv_type_unsigned_long_long" >&6; }
+if test $ac_cv_type_unsigned_long_long = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UNSIGNED_LONG_LONG 1
+_ACEOF
+
+pcre_have_ulong_long="1"
+else
+  pcre_have_ulong_long="0"
+fi
+
+fi
+
+
+
+# Checks for library functions.
+
+
+
+
+for ac_func in bcopy memmove strerror
+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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* 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
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+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
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+
+
+# Check for the availability of libz (aka zlib)
+
+
+for ac_header in zlib.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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:$ac_c_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+ HAVE_ZLIB_H=1
+fi
+
+done
+
+{ echo "$as_me:$LINENO: checking for gzopen in -lz" >&5
+echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6; }
+if test "${ac_cv_lib_z_gzopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lz  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gzopen ();
+int
+main ()
+{
+return gzopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_z_gzopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_z_gzopen=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzopen" >&5
+echo "${ECHO_T}$ac_cv_lib_z_gzopen" >&6; }
+if test $ac_cv_lib_z_gzopen = yes; then
+  HAVE_LIBZ=1
+fi
+
+
+# Check for the availability of libbz2
+
+
+for ac_header in bzlib.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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:$ac_c_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+ HAVE_BZLIB_H=1
+fi
+
+done
+
+{ echo "$as_me:$LINENO: checking for BZ2_bzopen in -lbz2" >&5
+echo $ECHO_N "checking for BZ2_bzopen in -lbz2... $ECHO_C" >&6; }
+if test "${ac_cv_lib_bz2_BZ2_bzopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbz2  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char BZ2_bzopen ();
+int
+main ()
+{
+return BZ2_bzopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_bz2_BZ2_bzopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_bz2_BZ2_bzopen=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_bz2_BZ2_bzopen" >&5
+echo "${ECHO_T}$ac_cv_lib_bz2_BZ2_bzopen" >&6; }
+if test $ac_cv_lib_bz2_BZ2_bzopen = yes; then
+  HAVE_LIBBZ2=1
+fi
+
+
+# Check for the availabiity of libreadline
+
+
+for ac_header in readline/readline.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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:$ac_c_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+ HAVE_READLINE_H=1
+fi
+
+done
+
+
+for ac_header in readline/history.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+/* 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 { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; 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 core conftest.err 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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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 && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.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:$ac_c_preproc_warn_flag 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 compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  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: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&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;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&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
+ HAVE_HISTORY_H=1
+fi
+
+done
+
+{ echo "$as_me:$LINENO: checking for readline in -lreadline" >&5
+echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6; }
+if test "${ac_cv_lib_readline_readline+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lreadline  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char readline ();
+int
+main ()
+{
+return readline ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 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); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_readline_readline=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_readline_readline=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5
+echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6; }
+if test $ac_cv_lib_readline_readline = yes; then
+  HAVE_LIB_READLINE=1
+fi
+
+
+# This facilitates -ansi builds under Linux
+
+if test "x$enable_shared" = "xno" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define PCRE_STATIC 1
+_ACEOF
+
+fi
+
+# Here is where pcre specific defines are handled
+
+if test "$enable_utf8" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define SUPPORT_UTF8
+_ACEOF
+
+fi
+
+if test "$enable_unicode_properties" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define SUPPORT_UCP
+_ACEOF
+
+fi
+
+if test "$enable_stack_for_recursion" = "no"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_RECURSE
+_ACEOF
+
+fi
+
+if test "$enable_pcregrep_libz" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define SUPPORT_LIBZ
+_ACEOF
+
+fi
+
+if test "$enable_pcregrep_libbz2" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define SUPPORT_LIBBZ2
+_ACEOF
+
+fi
+
+if test "$enable_pcretest_libreadline" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define SUPPORT_LIBREADLINE
+_ACEOF
+
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define NEWLINE $ac_pcre_newline_value
+_ACEOF
+
+
+if test "$enable_bsr_anycrlf" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define BSR_ANYCRLF
+_ACEOF
+
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define LINK_SIZE $with_link_size
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define POSIX_MALLOC_THRESHOLD $with_posix_malloc_threshold
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define MATCH_LIMIT $with_match_limit
+_ACEOF
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define MATCH_LIMIT_RECURSION $with_match_limit_recursion
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define MAX_NAME_SIZE 32
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define MAX_NAME_COUNT 10000
+_ACEOF
+
+
+
+
+
+if test "$enable_ebcdic" = "yes"; then
+
+cat >>confdefs.h <<_ACEOF
+#define EBCDIC
+_ACEOF
+
+fi
+
+# Platform specific issues
+NO_UNDEFINED=
+EXPORT_ALL_SYMBOLS=
+case $host_os in
+  cygwin* | mingw* )
+    if test X"$enable_shared" = Xyes; then
+      NO_UNDEFINED="-no-undefined"
+      EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
+    fi
+    ;;
+esac
+
+# The extra LDFLAGS for each particular library
+# (Note: The libpcre*_version bits are m4 variables, assigned above)
+
+EXTRA_LIBPCRE_LDFLAGS="$EXTRA_LIBPCRE_LDFLAGS \
+                       $NO_UNDEFINED -version-info 0:1:0"
+
+EXTRA_LIBPCREPOSIX_LDFLAGS="$EXTRA_LIBPCREPOSIX_LDFLAGS \
+                            $NO_UNDEFINED -version-info 0:0:0"
+
+EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS \
+                          $NO_UNDEFINED -version-info 0:0:0 \
+                          $EXPORT_ALL_SYMBOLS"
+
+
+
+
+
+# When we run 'make distcheck', use these arguments.
+DISTCHECK_CONFIGURE_FLAGS="--enable-cpp --enable-unicode-properties"
+
+
+# Check that, if --enable-pcregrep-libz or --enable-pcregrep-libbz2 is
+# specified, the relevant library is available. If so, add it to LIBS.
+
+if test "$enable_pcregrep_libz" = "yes"; then
+  if test "$HAVE_ZLIB_H" != "1"; then
+    echo "** Cannot --enable-pcregrep-libz because zlib.h was not found"
+    exit 1
+  fi
+  if test "$HAVE_LIBZ" != "1"; then
+    echo "** Cannot --enable-pcregrep-libz because libz was not found"
+    exit 1
+  fi
+  if test "$LIBS" = ""; then LIBS=-lz; else LIBS="$LIBS -lz"; fi
+fi
+
+if test "$enable_pcregrep_libbz2" = "yes"; then
+  if test "$HAVE_BZLIB_H" != "1"; then
+    echo "** Cannot --enable-pcregrep-libbz2 because bzlib.h was not found"
+    exit 1
+  fi
+  if test "$HAVE_LIBBZ2" != "1"; then
+    echo "** Cannot --enable-pcregrep-libbz2 because libbz2 was not found"
+    exit 1
+  fi
+  if test "$LIBS" = ""; then LIBS=-lbz2; else LIBS="$LIBS -lbz2"; fi
+fi
+
+# Similarly for --enable-pcretest-readline
+
+if test "$enable_pcretest_libreadline" = "yes"; then
+  if test "$HAVE_READLINE_H" != "1"; then
+    echo "** Cannot --enable-pcretest-readline because readline/readline.h was not found."
+    exit 1
+  fi
+  if test "$HAVE_HISTORY_H" != "1"; then
+    echo "** Cannot --enable-pcretest-readline because readline/history.h was not found."
+    exit 1
+  fi
+  if test "$LIBS" = ""; then LIBS=-lreadline; else LIBS="$LIBS -lreadline"; fi
+fi
+
+# Produce these files, in addition to config.h.
+ac_config_files="$ac_config_files Makefile libpcre.pc libpcrecpp.pc pcre-config pcre.h pcre_stringpiece.h pcrecpparg.h"
+
+
+# Make the generated script files executable.
+ac_config_commands="$ac_config_commands script-chmod"
+
+
+# Make sure that pcre_chartables.c is removed in case the method for
+# creating it was changed by reconfiguration.
+ac_config_commands="$ac_config_commands delete-old-chartables"
+
+
+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, we kill variables containing newlines.
+# 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.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}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 "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     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 "$as_me:$LINENO: updating cache $cache_file" >&5
+echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  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}'
+
+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_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$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
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${WITH_PCRE_CPP_TRUE}" && test -z "${WITH_PCRE_CPP_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"WITH_PCRE_CPP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"WITH_PCRE_CPP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${WITH_REBUILD_CHARTABLES_TRUE}" && test -z "${WITH_REBUILD_CHARTABLES_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"WITH_REBUILD_CHARTABLES\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"WITH_REBUILD_CHARTABLES\" 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 more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+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+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# 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
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+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
+IFS=$as_save_IFS
+
+     ;;
+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_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+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 -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; 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'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # 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 after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, 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
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\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 sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir
+fi
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s='ln -s'
+  # ... but there are two gotchas:
+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+  # In both cases, we have to default to `cp -p'.
+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+    as_ln_s='cp -p'
+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$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+        test -d "$1/.";
+      else
+	case $1 in
+        -*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval 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="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+
+# Save the log message, to keep $[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by PCRE $as_me 7.8, which was
+generated by GNU Autoconf 2.61.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+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 and configuration settings, 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@gnu.org>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+PCRE config.status 7.8
+configured by $0, generated by GNU Autoconf 2.61,
+  with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2006 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+_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
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    echo "$ac_cs_version"; exit ;;
+  --debug | --debu | --deb | --de | --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;;
+  --he | --h)
+    # Conflict between --help and --header
+    { 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 ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) { 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"
+     ac_need_defaults=false ;;
+
+  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 CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+  CONFIG_SHELL=$SHELL
+  export CONFIG_SHELL
+  exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "libpcre.pc") CONFIG_FILES="$CONFIG_FILES libpcre.pc" ;;
+    "libpcrecpp.pc") CONFIG_FILES="$CONFIG_FILES libpcrecpp.pc" ;;
+    "pcre-config") CONFIG_FILES="$CONFIG_FILES pcre-config" ;;
+    "pcre.h") CONFIG_FILES="$CONFIG_FILES pcre.h" ;;
+    "pcre_stringpiece.h") CONFIG_FILES="$CONFIG_FILES pcre_stringpiece.h" ;;
+    "pcrecpparg.h") CONFIG_FILES="$CONFIG_FILES pcrecpparg.h" ;;
+    "script-chmod") CONFIG_COMMANDS="$CONFIG_COMMANDS script-chmod" ;;
+    "delete-old-chartables") CONFIG_COMMANDS="$CONFIG_COMMANDS delete-old-chartables" ;;
+
+  *) { { 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 against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$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 "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} ||
+{
+   echo "$me: cannot create a temporary directory in ." >&2
+   { (exit 1); exit 1; }
+}
+
+#
+# Set up the sed scripts for 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
+
+_ACEOF
+
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
+SHELL!$SHELL$ac_delim
+PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim
+PACKAGE_NAME!$PACKAGE_NAME$ac_delim
+PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim
+PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim
+PACKAGE_STRING!$PACKAGE_STRING$ac_delim
+PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim
+exec_prefix!$exec_prefix$ac_delim
+prefix!$prefix$ac_delim
+program_transform_name!$program_transform_name$ac_delim
+bindir!$bindir$ac_delim
+sbindir!$sbindir$ac_delim
+libexecdir!$libexecdir$ac_delim
+datarootdir!$datarootdir$ac_delim
+datadir!$datadir$ac_delim
+sysconfdir!$sysconfdir$ac_delim
+sharedstatedir!$sharedstatedir$ac_delim
+localstatedir!$localstatedir$ac_delim
+includedir!$includedir$ac_delim
+oldincludedir!$oldincludedir$ac_delim
+docdir!$docdir$ac_delim
+infodir!$infodir$ac_delim
+htmldir!$htmldir$ac_delim
+dvidir!$dvidir$ac_delim
+pdfdir!$pdfdir$ac_delim
+psdir!$psdir$ac_delim
+libdir!$libdir$ac_delim
+localedir!$localedir$ac_delim
+mandir!$mandir$ac_delim
+DEFS!$DEFS$ac_delim
+ECHO_C!$ECHO_C$ac_delim
+ECHO_N!$ECHO_N$ac_delim
+ECHO_T!$ECHO_T$ac_delim
+LIBS!$LIBS$ac_delim
+build_alias!$build_alias$ac_delim
+host_alias!$host_alias$ac_delim
+target_alias!$target_alias$ac_delim
+INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
+INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
+INSTALL_DATA!$INSTALL_DATA$ac_delim
+am__isrc!$am__isrc$ac_delim
+CYGPATH_W!$CYGPATH_W$ac_delim
+PACKAGE!$PACKAGE$ac_delim
+VERSION!$VERSION$ac_delim
+ACLOCAL!$ACLOCAL$ac_delim
+AUTOCONF!$AUTOCONF$ac_delim
+AUTOMAKE!$AUTOMAKE$ac_delim
+AUTOHEADER!$AUTOHEADER$ac_delim
+MAKEINFO!$MAKEINFO$ac_delim
+install_sh!$install_sh$ac_delim
+STRIP!$STRIP$ac_delim
+INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim
+mkdir_p!$mkdir_p$ac_delim
+AWK!$AWK$ac_delim
+SET_MAKE!$SET_MAKE$ac_delim
+am__leading_dot!$am__leading_dot$ac_delim
+AMTAR!$AMTAR$ac_delim
+am__tar!$am__tar$ac_delim
+am__untar!$am__untar$ac_delim
+CC!$CC$ac_delim
+CFLAGS!$CFLAGS$ac_delim
+LDFLAGS!$LDFLAGS$ac_delim
+CPPFLAGS!$CPPFLAGS$ac_delim
+ac_ct_CC!$ac_ct_CC$ac_delim
+EXEEXT!$EXEEXT$ac_delim
+OBJEXT!$OBJEXT$ac_delim
+DEPDIR!$DEPDIR$ac_delim
+am__include!$am__include$ac_delim
+am__quote!$am__quote$ac_delim
+AMDEP_TRUE!$AMDEP_TRUE$ac_delim
+AMDEP_FALSE!$AMDEP_FALSE$ac_delim
+AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim
+CCDEPMODE!$CCDEPMODE$ac_delim
+am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim
+am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim
+CXX!$CXX$ac_delim
+CXXFLAGS!$CXXFLAGS$ac_delim
+ac_ct_CXX!$ac_ct_CXX$ac_delim
+CXXDEPMODE!$CXXDEPMODE$ac_delim
+am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim
+am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim
+build!$build$ac_delim
+build_cpu!$build_cpu$ac_delim
+build_vendor!$build_vendor$ac_delim
+build_os!$build_os$ac_delim
+host!$host$ac_delim
+host_cpu!$host_cpu$ac_delim
+host_vendor!$host_vendor$ac_delim
+host_os!$host_os$ac_delim
+SED!$SED$ac_delim
+GREP!$GREP$ac_delim
+EGREP!$EGREP$ac_delim
+LN_S!$LN_S$ac_delim
+ECHO!$ECHO$ac_delim
+AR!$AR$ac_delim
+RANLIB!$RANLIB$ac_delim
+DSYMUTIL!$DSYMUTIL$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+CEOF$ac_eof
+_ACEOF
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
+NMEDIT!$NMEDIT$ac_delim
+DLLTOOL!$DLLTOOL$ac_delim
+AS!$AS$ac_delim
+OBJDUMP!$OBJDUMP$ac_delim
+CPP!$CPP$ac_delim
+CXXCPP!$CXXCPP$ac_delim
+F77!$F77$ac_delim
+FFLAGS!$FFLAGS$ac_delim
+ac_ct_F77!$ac_ct_F77$ac_delim
+LIBTOOL!$LIBTOOL$ac_delim
+PCRE_MAJOR!$PCRE_MAJOR$ac_delim
+PCRE_MINOR!$PCRE_MINOR$ac_delim
+PCRE_PRERELEASE!$PCRE_PRERELEASE$ac_delim
+PCRE_DATE!$PCRE_DATE$ac_delim
+pcre_have_type_traits!$pcre_have_type_traits$ac_delim
+pcre_have_bits_type_traits!$pcre_have_bits_type_traits$ac_delim
+WITH_PCRE_CPP_TRUE!$WITH_PCRE_CPP_TRUE$ac_delim
+WITH_PCRE_CPP_FALSE!$WITH_PCRE_CPP_FALSE$ac_delim
+WITH_REBUILD_CHARTABLES_TRUE!$WITH_REBUILD_CHARTABLES_TRUE$ac_delim
+WITH_REBUILD_CHARTABLES_FALSE!$WITH_REBUILD_CHARTABLES_FALSE$ac_delim
+pcre_have_long_long!$pcre_have_long_long$ac_delim
+pcre_have_ulong_long!$pcre_have_ulong_long$ac_delim
+EXTRA_LIBPCRE_LDFLAGS!$EXTRA_LIBPCRE_LDFLAGS$ac_delim
+EXTRA_LIBPCREPOSIX_LDFLAGS!$EXTRA_LIBPCREPOSIX_LDFLAGS$ac_delim
+EXTRA_LIBPCRECPP_LDFLAGS!$EXTRA_LIBPCRECPP_LDFLAGS$ac_delim
+DISTCHECK_CONFIGURE_FLAGS!$DISTCHECK_CONFIGURE_FLAGS$ac_delim
+LIBOBJS!$LIBOBJS$ac_delim
+LTLIBOBJS!$LTLIBOBJS$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 28; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+:end
+s/|#_!!_#|//g
+CEOF$ac_eof
+_ACEOF
+
+
+# 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
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+fi # test -n "$CONFIG_FILES"
+
+
+for ac_tag in  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
+echo "$as_me: error: Invalid tag $ac_tag." >&2;}
+   { (exit 1); exit 1; }; };;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+   { (exit 1); exit 1; }; };;
+      esac
+      ac_file_inputs="$ac_file_inputs $ac_f"
+    done
+
+    # 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.  */
+    configure_input="Generated from "`IFS=:
+	  echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    fi
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin";;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$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'`
+  { as_dir="$ac_dir"
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$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'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+case `sed -n '/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+' $ac_file_inputs` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+    s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF
+  sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s&@configure_input@&$configure_input&;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out"; rm -f "$tmp/out";;
+  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
+  esac
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+_ACEOF
+
+# Transform confdefs.h into a sed script `conftest.defines', that
+# substitutes the proper values into config.h.in to produce config.h.
+rm -f conftest.defines conftest.tail
+# First, append a space to every undef/define line, to ease matching.
+echo 's/$/ /' >conftest.defines
+# Then, protect against being on the right side of a sed subst, or in
+# an unquoted here document, in config.status.  If some macros were
+# called several times there might be several #defines for the same
+# symbol, which is useless.  But do not sort them, since the last
+# AC_DEFINE must be honored.
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
+# NAME is the cpp macro being defined, VALUE is the value it is being given.
+# PARAMS is the parameter list in the macro definition--in most cases, it's
+# just an empty string.
+ac_dA='s,^\\([	 #]*\\)[^	 ]*\\([	 ]*'
+ac_dB='\\)[	 (].*,\\1define\\2'
+ac_dC=' '
+ac_dD=' ,'
+
+uniq confdefs.h |
+  sed -n '
+	t rset
+	:rset
+	s/^[	 ]*#[	 ]*define[	 ][	 ]*//
+	t ok
+	d
+	:ok
+	s/[\\&,]/\\&/g
+	s/^\('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
+	s/^\('"$ac_word_re"'\)[	 ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
+  ' >>conftest.defines
+
+# Remove the space that was appended to ease matching.
+# Then replace #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.
+# (The regexp can be short, since the line contains either #define or #undef.)
+echo 's/ $//
+s,^[	 #]*u.*,/* & */,' >>conftest.defines
+
+# Break up conftest.defines:
+ac_max_sed_lines=50
+
+# First sed command is:	 sed -f defines.sed $ac_file_inputs >"$tmp/out1"
+# Second one is:	 sed -f defines.sed "$tmp/out1" >"$tmp/out2"
+# Third one will be:	 sed -f defines.sed "$tmp/out2" >"$tmp/out1"
+# et cetera.
+ac_in='$ac_file_inputs'
+ac_out='"$tmp/out1"'
+ac_nxt='"$tmp/out2"'
+
+while :
+do
+  # Write a here document:
+    cat >>$CONFIG_STATUS <<_ACEOF
+    # First, check the format of the line:
+    cat >"\$tmp/defines.sed" <<\\CEOF
+/^[	 ]*#[	 ]*undef[	 ][	 ]*$ac_word_re[	 ]*\$/b def
+/^[	 ]*#[	 ]*define[	 ][	 ]*$ac_word_re[(	 ]/b def
+b
+:def
+_ACEOF
+  sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+    sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
+  ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
+  sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
+  grep . conftest.tail >/dev/null || break
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines conftest.tail
+
+echo "ac_result=$ac_in" >>$CONFIG_STATUS
+cat >>$CONFIG_STATUS <<\_ACEOF
+  if test x"$ac_file" != x-; then
+    echo "/* $configure_input  */" >"$tmp/config.h"
+    cat "$ac_result" >>"$tmp/config.h"
+    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
+      rm -f $ac_file
+      mv "$tmp/config.h" $ac_file
+    fi
+  else
+    echo "/* $configure_input  */"
+    cat "$ac_result"
+  fi
+  rm -f "$tmp/out12"
+# Compute $ac_file's index in $config_headers.
+_am_arg=$ac_file
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$_am_arg" : 'X\(//\)[^/]' \| \
+	 X"$_am_arg" : 'X\(//\)$' \| \
+	 X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { echo "$as_me:$LINENO: executing $ac_file commands" >&5
+echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) 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.
+  # Grep'ing the whole file is not good either: AIX grep has a line
+  # limit of 2048, but all sed's we know have understand at least 4000.
+  if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+    dirpart=`$as_dirname -- "$mf" ||
+$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
+  # Extract the definition of DEPDIR, am__include, and am__quote
+  # from the Makefile without running `make'.
+  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  am__include=`sed -n 's/^am__include = //p' < "$mf"`
+  test -z "am__include" && continue
+  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n 's/^U = //p' < "$mf"`
+  # Find all dependency output files, they are included files with
+  # $(DEPDIR) in their names.  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 "
+    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/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_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'`
+    { as_dir=$dirpart/$fdir
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$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'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
+    # echo "creating $dirpart/$file"
+    echo '# dummy' > "$dirpart/$file"
+  done
+done
+ ;;
+    "script-chmod":C) chmod a+x pcre-config ;;
+    "delete-old-chartables":C) rm -f pcre_chartables.c ;;
+
+  esac
+done # for ac_tag
+
+
+{ (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
+
+
+# Print out a nice little message after configure is run displaying your
+# chosen options.
+
+cat <<EOF
+
+$PACKAGE-$VERSION configuration summary:
+
+    Install prefix .................. : ${prefix}
+    C preprocessor .................. : ${CPP}
+    C compiler ...................... : ${CC}
+    C++ preprocessor ................ : ${CXXCPP}
+    C++ compiler .................... : ${CXX}
+    Linker .......................... : ${LD}
+    C preprocessor flags ............ : ${CPPFLAGS}
+    C compiler flags ................ : ${CFLAGS}
+    C++ compiler flags .............. : ${CXXFLAGS}
+    Linker flags .................... : ${LDFLAGS}
+    Extra libraries ................. : ${LIBS}
+
+    Build C++ library ............... : ${enable_cpp}
+    Enable UTF-8 support ............ : ${enable_utf8}
+    Unicode properties .............. : ${enable_unicode_properties}
+    Newline char/sequence ........... : ${enable_newline}
+    \R matches only ANYCRLF ......... : ${enable_bsr_anycrlf}
+    EBCDIC coding ................... : ${enable_ebcdic}
+    Rebuild char tables ............. : ${enable_rebuild_chartables}
+    Use stack recursion ............. : ${enable_stack_for_recursion}
+    POSIX mem threshold ............. : ${with_posix_malloc_threshold}
+    Internal link size .............. : ${with_link_size}
+    Match limit ..................... : ${with_match_limit}
+    Match limit recursion ........... : ${with_match_limit_recursion}
+    Build shared libs ............... : ${enable_shared}
+    Build static libs ............... : ${enable_static}
+    Link pcregrep with libz ......... : ${enable_pcregrep_libz}
+    Link pcregrep with libbz2 ....... : ${enable_pcregrep_libbz2}
+    Link pcretest with libreadline .. : ${enable_pcretest_libreadline}
+
+EOF
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/configure.ac	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,641 @@
+dnl Process this file with autoconf to produce a configure script.
+
+dnl NOTE FOR MAINTAINERS: Do not use major or minor version numbers with
+dnl leading zeros, because they may be treated as octal constants. The
+dnl PCRE_PRERELEASE feature is for identifying release candidates. It might
+dnl be defined as -RC2, for example. For real releases, it should be defined
+dnl empty.
+
+m4_define(pcre_major, [7])
+m4_define(pcre_minor, [8])
+m4_define(pcre_prerelease, [])
+m4_define(pcre_date, [2008-09-05])
+
+# Libtool shared library interface versions (current:revision:age)
+m4_define(libpcre_version, [0:1:0])
+m4_define(libpcreposix_version, [0:0:0])
+m4_define(libpcrecpp_version, [0:0:0])
+
+AC_PREREQ(2.57)
+AC_INIT(PCRE, pcre_major.pcre_minor[]pcre_prerelease, , pcre)
+AC_CONFIG_SRCDIR([pcre.h.in])
+AM_INIT_AUTOMAKE([dist-bzip2 dist-zip])
+AC_CONFIG_HEADERS(config.h)
+
+# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just
+# "-g" for any other compiler. There doesn't seem to be a standard way of
+# getting rid of the -g (which I don't think is needed for a production
+# library). This fudge seems to achieve the necessary. First, we remember the
+# externally set values of CFLAGS and CXXFLAGS. Then call the AC_PROG_CC and
+# AC_PROG_CXX macros to find the compilers - if CFLAGS and CXXFLAGS are not
+# set, they will be set to Autoconf's defaults. Afterwards, if the original
+# values were not set, remove the -g from the Autoconf defaults.
+# (PH 02-May-07)
+
+remember_set_CFLAGS="$CFLAGS"
+remember_set_CXXFLAGS="$CXXFLAGS"
+
+AC_PROG_CC
+AC_PROG_CXX
+
+if test "x$remember_set_CFLAGS" = "x"
+then
+  if test "$CFLAGS" = "-g -O2"
+  then
+    CFLAGS="-O2"
+  elif test "$CFLAGS" = "-g"
+  then
+    CFLAGS=""
+  fi
+fi
+
+if test "x$remember_set_CXXFLAGS" = "x"
+then
+  if test "$CXXFLAGS" = "-g -O2"
+  then
+    CXXFLAGS="-O2"
+  elif test "$CXXFLAGS" = "-g"
+  then
+    CXXFLAGS=""
+  fi
+fi
+
+# AC_PROG_CXX will return "g++" even if no c++ compiler is installed.
+# Check for that case, and just disable c++ code if g++ doesn't run.
+AC_LANG_PUSH(C++)
+AC_COMPILE_IFELSE(AC_LANG_PROGRAM([],[]),, CXX=""; CXXCP=""; CXXFLAGS="")
+AC_LANG_POP
+
+AC_PROG_INSTALL
+AC_LIBTOOL_WIN32_DLL
+AC_PROG_LIBTOOL
+AC_PROG_LN_S
+
+PCRE_MAJOR="pcre_major"
+PCRE_MINOR="pcre_minor"
+PCRE_PRERELEASE="pcre_prerelease"
+PCRE_DATE="pcre_date"
+
+AC_SUBST(PCRE_MAJOR)
+AC_SUBST(PCRE_MINOR)
+AC_SUBST(PCRE_PRERELEASE)
+AC_SUBST(PCRE_DATE)
+
+# Set a more sensible default value for $(htmldir).
+if test "x$htmldir" = 'x${docdir}'
+then
+  htmldir='${docdir}/html'
+fi
+
+# Handle --disable-cpp
+AC_ARG_ENABLE(cpp,
+              AS_HELP_STRING([--disable-cpp],
+                             [disable C++ support]),
+              , enable_cpp=yes)
+
+# Handle --enable-rebuild-chartables
+AC_ARG_ENABLE(rebuild-chartables,
+              AS_HELP_STRING([--enable-rebuild-chartables],
+                             [rebuild character tables in current locale]),
+              , enable_rebuild_chartables=no)
+
+# Handle --enable-utf8 (disabled by default)
+AC_ARG_ENABLE(utf8,
+              AS_HELP_STRING([--enable-utf8],
+                             [enable UTF-8 support]),
+              , enable_utf8=unset)
+
+# Handle --enable-unicode-properties
+AC_ARG_ENABLE(unicode-properties,
+              AS_HELP_STRING([--enable-unicode-properties],
+                             [enable Unicode properties support (implies --enable-utf8)]),
+              , enable_unicode_properties=no)
+
+# Handle --enable-newline=NL
+dnl AC_ARG_ENABLE(newline,
+dnl               AS_HELP_STRING([--enable-newline=NL],
+dnl                              [use NL as newline (lf, cr, crlf, anycrlf, any; default=lf)]),
+dnl               , enable_newline=lf)
+
+# Separate newline options
+ac_pcre_newline=lf
+AC_ARG_ENABLE(newline-is-cr,
+              AS_HELP_STRING([--enable-newline-is-cr],
+                             [use CR as newline character]),
+              ac_pcre_newline=cr)
+AC_ARG_ENABLE(newline-is-lf,
+              AS_HELP_STRING([--enable-newline-is-lf],
+                             [use LF as newline character (default)]),
+              ac_pcre_newline=lf)
+AC_ARG_ENABLE(newline-is-crlf,
+              AS_HELP_STRING([--enable-newline-is-crlf],
+                             [use CRLF as newline sequence]),
+              ac_pcre_newline=crlf)
+AC_ARG_ENABLE(newline-is-anycrlf,
+              AS_HELP_STRING([--enable-newline-is-anycrlf],
+                             [use CR, LF, or CRLF as newline sequence]),
+              ac_pcre_newline=anycrlf)
+AC_ARG_ENABLE(newline-is-any,
+              AS_HELP_STRING([--enable-newline-is-any],
+                             [use any valid Unicode newline sequence]),
+              ac_pcre_newline=any)
+enable_newline="$ac_pcre_newline"
+
+# Handle --enable-bsr-anycrlf
+AC_ARG_ENABLE(bsr-anycrlf,
+              AS_HELP_STRING([--enable-bsr-anycrlf],
+                             [\R matches only CR, LF, CRLF by default]),
+              , enable_bsr_anycrlf=no)
+
+# Handle --enable-ebcdic
+AC_ARG_ENABLE(ebcdic,
+              AS_HELP_STRING([--enable-ebcdic],
+                             [assume EBCDIC coding rather than ASCII; use this only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
+              , enable_ebcdic=no)
+
+# Handle --disable-stack-for-recursion
+AC_ARG_ENABLE(stack-for-recursion,
+              AS_HELP_STRING([--disable-stack-for-recursion],
+                             [don't use stack recursion when matching]),
+              , enable_stack_for_recursion=yes)
+
+# Handle --enable-pcregrep-libz
+AC_ARG_ENABLE(pcregrep-libz,
+              AS_HELP_STRING([--enable-pcregrep-libz],
+                             [link pcregrep with libz to handle .gz files]),
+              , enable_pcregrep_libz=no)
+
+# Handle --enable-pcregrep-libbz2
+AC_ARG_ENABLE(pcregrep-libbz2,
+              AS_HELP_STRING([--enable-pcregrep-libbz2],
+                             [link pcregrep with libbz2 to handle .bz2 files]),
+              , enable_pcregrep_libbz2=no)
+
+# Handle --enable-pcretest-libreadline
+AC_ARG_ENABLE(pcretest-libreadline,
+              AS_HELP_STRING([--enable-pcretest-libreadline],
+                             [link pcretest with libreadline]),
+              , enable_pcretest_libreadline=no)
+
+# Handle --with-posix-malloc-threshold=NBYTES
+AC_ARG_WITH(posix-malloc-threshold,
+            AS_HELP_STRING([--with-posix-malloc-threshold=NBYTES],
+                           [threshold for POSIX malloc usage (default=10)]),
+            , with_posix_malloc_threshold=10)
+
+# Handle --with-link-size=N
+AC_ARG_WITH(link-size,
+            AS_HELP_STRING([--with-link-size=N],
+                           [internal link size (2, 3, or 4 allowed; default=2)]),
+            , with_link_size=2)
+
+# Handle --with-match-limit=N
+AC_ARG_WITH(match-limit,
+            AS_HELP_STRING([--with-match-limit=N],
+                           [default limit on internal looping (default=10000000)]),
+            , with_match_limit=10000000)
+
+# Handle --with-match-limit_recursion=N
+#
+# Note: In config.h, the default is to define MATCH_LIMIT_RECURSION
+# symbolically as MATCH_LIMIT, which in turn is defined to be some numeric
+# value (e.g. 10000000). MATCH_LIMIT_RECURSION can otherwise be set to some
+# different numeric value (or even the same numeric value as MATCH_LIMIT,
+# though no longer defined in terms of the latter).
+#
+AC_ARG_WITH(match-limit-recursion,
+            AS_HELP_STRING([--with-match-limit-recursion=N],
+                           [default limit on internal recursion (default=MATCH_LIMIT)]),
+            , with_match_limit_recursion=MATCH_LIMIT)
+
+# Make sure that if enable_unicode_properties was set, that UTF-8 support
+# is enabled.
+#
+if test "x$enable_unicode_properties" = "xyes"
+then
+  if test "x$enable_utf8" = "xno"
+  then
+    AC_MSG_ERROR([support for Unicode properties requires UTF-8 support])
+  fi
+  enable_utf8=yes
+fi
+
+if test "x$enable_utf8" = "xunset"
+then
+  enable_utf8=no
+fi
+
+# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
+#
+if test "x$enable_ebcdic" = "xyes"
+then
+  enable_rebuild_chartables=yes
+fi
+
+# Convert the newline identifier into the appropriate integer value.
+case "$enable_newline" in
+  lf)      ac_pcre_newline_value=10   ;;
+  cr)      ac_pcre_newline_value=13   ;;
+  crlf)    ac_pcre_newline_value=3338 ;;
+  anycrlf) ac_pcre_newline_value=-2   ;;
+  any)     ac_pcre_newline_value=-1   ;;
+  *)
+  AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
+  ;;
+esac
+
+# Check argument to --with-link-size
+case "$with_link_size" in
+  2|3|4) ;;
+  *)
+  AC_MSG_ERROR([invalid argument \"$with_link_size\" to --with-link-size option])
+  ;;
+esac
+
+AH_TOP([
+/* On Unix-like systems config.h.in is converted by "configure" into config.h.
+Some other environments also support the use of "configure". PCRE is written in
+Standard C, but there are a few non-standard things it can cope with, allowing
+it to run on SunOS4 and other "close to standard" systems.
+
+If you are going to build PCRE "by hand" on a system without "configure" you
+should copy the distributed config.h.generic to config.h, and then set up the
+macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to
+all of your compile commands, so that config.h is included at the start of
+every source.
+
+Alternatively, you can avoid editing by using -D on the compiler command line
+to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H.
+
+PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
+HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
+them both to 0; an emulation function will be used. */])
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h windows.h)
+
+# The files below are C++ header files.
+pcre_have_type_traits="0"
+pcre_have_bits_type_traits="0"
+if test "x$enable_cpp" = "xyes" -a -n "$CXX"
+then
+AC_LANG_PUSH(C++)
+
+# Older versions of pcre defined pcrecpp::no_arg, but in new versions
+# it's called pcrecpp::RE::no_arg.  For backwards ABI compatibility,
+# we want to make one an alias for the other.  Different systems do
+# this in different ways.  Some systems, for instance, can do it via
+# a linker flag: -alias (for os x 10.5) or -i (for os x <=10.4).
+OLD_LDFLAGS="$LDFLAGS"
+for flag in "-alias,__ZN7pcrecpp2RE6no_argE,__ZN7pcrecpp6no_argE" \
+            "-i__ZN7pcrecpp6no_argE:__ZN7pcrecpp2RE6no_argE"; do
+  AC_MSG_CHECKING([for alias support in the linker])
+  LDFLAGS="$OLD_LDFLAGS -Wl,$flag"
+  # We try to run the linker with this new ld flag.  If the link fails,
+  # we give up and remove the new flag from LDFLAGS.
+  AC_LINK_IFELSE(AC_LANG_PROGRAM([namespace pcrecpp {
+                                    class RE { static int no_arg; };
+                                    int RE::no_arg;
+                                  }],
+                                 []),
+                 [AC_MSG_RESULT([yes]);
+                  EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS -Wl,$flag";
+                  break;],
+                 AC_MSG_RESULT([no]))
+done
+LDFLAGS="$OLD_LDFLAGS"
+
+# We could be more clever here, given we're doing AC_SUBST with this
+# (eg set a var to be the name of the include file we want). But we're not
+# so it's easy to change back to 'regular' autoconf vars if we needed to.
+AC_CHECK_HEADERS(string, [pcre_have_cpp_headers="1"],
+                         [pcre_have_cpp_headers="0"])
+AC_CHECK_HEADERS(bits/type_traits.h, [pcre_have_bits_type_traits="1"],
+                                     [pcre_have_bits_type_traits="0"])
+AC_CHECK_HEADERS(type_traits.h, [pcre_have_type_traits="1"],
+                                [pcre_have_type_traits="0"])
+
+AC_LANG_POP
+fi
+# Using AC_SUBST eliminates the need to include config.h in a public .h file
+AC_SUBST(pcre_have_type_traits)
+AC_SUBST(pcre_have_bits_type_traits)
+
+# Conditional compilation
+AM_CONDITIONAL(WITH_PCRE_CPP, test "x$enable_cpp" = "xyes")
+AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes")
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+AC_C_CONST
+AC_TYPE_SIZE_T
+
+pcre_have_strotolonglong=0
+AC_CHECK_FUNCS(strtoq strtoll _strtoi64, [pcre_have_strotolonglong="1"; break])
+# If we can't convert a string to a long long, pretend we don't even
+# have a long long.
+if test $pcre_have_strotolonglong = "0"; then
+   pcre_have_long_long="0"
+   pcre_have_ulong_long="0"
+else
+  AC_CHECK_TYPES([long long],
+                 [pcre_have_long_long="1"],
+                 [pcre_have_long_long="0"])
+  AC_CHECK_TYPES([unsigned long long],
+                 [pcre_have_ulong_long="1"],
+                 [pcre_have_ulong_long="0"])
+fi
+AC_SUBST(pcre_have_long_long)
+AC_SUBST(pcre_have_ulong_long)
+
+# Checks for library functions.
+
+AC_CHECK_FUNCS(bcopy memmove strerror)
+
+# Check for the availability of libz (aka zlib)
+
+AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
+AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])
+
+# Check for the availability of libbz2
+
+AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
+AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
+
+# Check for the availabiity of libreadline
+
+AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
+AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
+AC_CHECK_LIB([readline], [readline], [HAVE_LIB_READLINE=1])
+
+# This facilitates -ansi builds under Linux
+dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
+
+if test "x$enable_shared" = "xno" ; then
+  AC_DEFINE([PCRE_STATIC], [1], [
+    Define if linking statically (TODO: make nice with Libtool)])
+fi
+
+# Here is where pcre specific defines are handled
+
+if test "$enable_utf8" = "yes"; then
+  AC_DEFINE([SUPPORT_UTF8], [], [
+    Define to enable support for the UTF-8 Unicode encoding.])
+fi
+
+if test "$enable_unicode_properties" = "yes"; then
+  AC_DEFINE([SUPPORT_UCP], [], [
+    Define to enable support for Unicode properties])
+fi
+
+if test "$enable_stack_for_recursion" = "no"; then
+  AC_DEFINE([NO_RECURSE], [], [
+    PCRE uses recursive function calls to handle backtracking while
+    matching. This can sometimes be a problem on systems that have
+    stacks of limited size. Define NO_RECURSE to get a version that
+    doesn't use recursion in the match() function; instead it creates
+    its own stack by steam using pcre_recurse_malloc() to obtain memory
+    from the heap. For more detail, see the comments and other stuff
+    just above the match() function. On systems that support it,
+    "configure" can be used to set this in the Makefile
+    (use --disable-stack-for-recursion).])
+fi
+
+if test "$enable_pcregrep_libz" = "yes"; then
+  AC_DEFINE([SUPPORT_LIBZ], [], [
+    Define to allow pcregrep to be linked with libz, so that it is
+    able to handle .gz files.])
+fi
+
+if test "$enable_pcregrep_libbz2" = "yes"; then
+  AC_DEFINE([SUPPORT_LIBBZ2], [], [
+    Define to allow pcregrep to be linked with libbz2, so that it is
+    able to handle .bz2 files.])
+fi
+
+if test "$enable_pcretest_libreadline" = "yes"; then
+  AC_DEFINE([SUPPORT_LIBREADLINE], [], [
+    Define to allow pcretest to be linked with libreadline.])
+fi
+
+AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [
+  The value of NEWLINE determines the newline character sequence. On
+  systems that support it, "configure" can be used to override the
+  default, which is 10. The possible values are 10 (LF), 13 (CR),
+  3338 (CRLF), -1 (ANY), or -2 (ANYCRLF).])
+
+if test "$enable_bsr_anycrlf" = "yes"; then
+  AC_DEFINE([BSR_ANYCRLF], [], [
+    By default, the \R escape sequence matches any Unicode line ending
+    character or sequence of characters. If BSR_ANYCRLF is defined, this is
+    changed so that backslash-R matches only CR, LF, or CRLF. The build-
+    time default can be overridden by the user of PCRE at runtime. On
+    systems that support it, "configure" can be used to override the
+    default.])
+fi
+
+AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
+  The value of LINK_SIZE determines the number of bytes used to store
+  links as offsets within the compiled regex. The default is 2, which
+  allows for compiled patterns up to 64K long. This covers the vast
+  majority of cases. However, PCRE can also be compiled to use 3 or 4
+  bytes instead. This allows for longer patterns in extreme cases. On
+  systems that support it, "configure" can be used to override this default.])
+
+AC_DEFINE_UNQUOTED([POSIX_MALLOC_THRESHOLD], [$with_posix_malloc_threshold], [
+  When calling PCRE via the POSIX interface, additional working storage
+  is required for holding the pointers to capturing substrings because
+  PCRE requires three integers per substring, whereas the POSIX
+  interface provides only two. If the number of expected substrings is
+  small, the wrapper function uses space on the stack, because this is
+  faster than using malloc() for each call. The threshold above which
+  the stack is no longer used is defined by POSIX_MALLOC_THRESHOLD. On
+  systems that support it, "configure" can be used to override this
+  default.])
+
+AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [
+  The value of MATCH_LIMIT determines the default number of times the
+  internal match() function can be called during a single execution of
+  pcre_exec(). There is a runtime interface for setting a different
+  limit. The limit exists in order to catch runaway regular
+  expressions that take for ever to determine that they do not match.
+  The default is set very large so that it does not accidentally catch
+  legitimate cases. On systems that support it, "configure" can be
+  used to override this default default.])
+
+AC_DEFINE_UNQUOTED([MATCH_LIMIT_RECURSION], [$with_match_limit_recursion], [
+  The above limit applies to all calls of match(), whether or not they
+  increase the recursion depth. In some environments it is desirable
+  to limit the depth of recursive calls of match() more strictly, in
+  order to restrict the maximum amount of stack (or heap, if
+  NO_RECURSE is defined) that is used. The value of
+  MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To
+  have any useful effect, it must be less than the value of
+  MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT.
+  There is a runtime method for setting a different limit. On systems
+  that support it, "configure" can be used to override the default.])
+
+AC_DEFINE([MAX_NAME_SIZE], [32], [
+  This limit is parameterized just in case anybody ever wants to
+  change it. Care must be taken if it is increased, because it guards
+  against integer overflow caused by enormously large patterns.])
+
+AC_DEFINE([MAX_NAME_COUNT], [10000], [
+  This limit is parameterized just in case anybody ever wants to
+  change it. Care must be taken if it is increased, because it guards
+  against integer overflow caused by enormously large patterns.])
+
+AH_VERBATIM([PCRE_EXP_DEFN], [
+/* If you are compiling for a system other than a Unix-like system or
+   Win32, and it needs some magic to be inserted before the definition
+   of a function that is exported by the library, define this macro to
+   contain the relevant magic. If you do not define this macro, it
+   defaults to "extern" for a C compiler and "extern C" for a C++
+   compiler on non-Win32 systems. This macro apears at the start of
+   every exported function that is part of the external API. It does
+   not appear on functions that are "external" in the C sense, but
+   which are internal to the library. */
+#undef PCRE_EXP_DEFN])
+
+if test "$enable_ebcdic" = "yes"; then
+  AC_DEFINE_UNQUOTED([EBCDIC], [], [
+    If you are compiling for a system that uses EBCDIC instead of ASCII
+    character codes, define this macro as 1. On systems that can use
+    "configure", this can be done via --enable-ebcdic.])
+fi
+
+# Platform specific issues
+NO_UNDEFINED=
+EXPORT_ALL_SYMBOLS=
+case $host_os in
+  cygwin* | mingw* )
+    if test X"$enable_shared" = Xyes; then
+      NO_UNDEFINED="-no-undefined"
+      EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
+    fi
+    ;;
+esac
+
+# The extra LDFLAGS for each particular library
+# (Note: The libpcre*_version bits are m4 variables, assigned above)
+
+EXTRA_LIBPCRE_LDFLAGS="$EXTRA_LIBPCRE_LDFLAGS \
+                       $NO_UNDEFINED -version-info libpcre_version"
+
+EXTRA_LIBPCREPOSIX_LDFLAGS="$EXTRA_LIBPCREPOSIX_LDFLAGS \
+                            $NO_UNDEFINED -version-info libpcreposix_version"
+
+EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS \
+                          $NO_UNDEFINED -version-info libpcrecpp_version \
+                          $EXPORT_ALL_SYMBOLS"
+
+AC_SUBST(EXTRA_LIBPCRE_LDFLAGS)
+AC_SUBST(EXTRA_LIBPCREPOSIX_LDFLAGS)
+AC_SUBST(EXTRA_LIBPCRECPP_LDFLAGS)
+
+# When we run 'make distcheck', use these arguments.
+DISTCHECK_CONFIGURE_FLAGS="--enable-cpp --enable-unicode-properties"
+AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
+
+# Check that, if --enable-pcregrep-libz or --enable-pcregrep-libbz2 is
+# specified, the relevant library is available. If so, add it to LIBS.
+
+if test "$enable_pcregrep_libz" = "yes"; then
+  if test "$HAVE_ZLIB_H" != "1"; then
+    echo "** Cannot --enable-pcregrep-libz because zlib.h was not found"
+    exit 1
+  fi
+  if test "$HAVE_LIBZ" != "1"; then
+    echo "** Cannot --enable-pcregrep-libz because libz was not found"
+    exit 1
+  fi
+  if test "$LIBS" = ""; then LIBS=-lz; else LIBS="$LIBS -lz"; fi
+fi
+
+if test "$enable_pcregrep_libbz2" = "yes"; then
+  if test "$HAVE_BZLIB_H" != "1"; then
+    echo "** Cannot --enable-pcregrep-libbz2 because bzlib.h was not found"
+    exit 1
+  fi
+  if test "$HAVE_LIBBZ2" != "1"; then
+    echo "** Cannot --enable-pcregrep-libbz2 because libbz2 was not found"
+    exit 1
+  fi
+  if test "$LIBS" = ""; then LIBS=-lbz2; else LIBS="$LIBS -lbz2"; fi
+fi
+
+# Similarly for --enable-pcretest-readline
+
+if test "$enable_pcretest_libreadline" = "yes"; then
+  if test "$HAVE_READLINE_H" != "1"; then
+    echo "** Cannot --enable-pcretest-readline because readline/readline.h was not found."
+    exit 1
+  fi
+  if test "$HAVE_HISTORY_H" != "1"; then
+    echo "** Cannot --enable-pcretest-readline because readline/history.h was not found."
+    exit 1
+  fi
+  if test "$LIBS" = ""; then LIBS=-lreadline; else LIBS="$LIBS -lreadline"; fi
+fi
+
+# Produce these files, in addition to config.h.
+AC_CONFIG_FILES(
+	Makefile
+	libpcre.pc
+	libpcrecpp.pc
+	pcre-config
+	pcre.h
+	pcre_stringpiece.h
+	pcrecpparg.h
+)
+
+# Make the generated script files executable.
+AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre-config])
+
+# Make sure that pcre_chartables.c is removed in case the method for
+# creating it was changed by reconfiguration.
+AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre_chartables.c])
+
+AC_OUTPUT
+
+# Print out a nice little message after configure is run displaying your
+# chosen options.
+
+cat <<EOF
+
+$PACKAGE-$VERSION configuration summary:
+
+    Install prefix .................. : ${prefix}
+    C preprocessor .................. : ${CPP}
+    C compiler ...................... : ${CC}
+    C++ preprocessor ................ : ${CXXCPP}
+    C++ compiler .................... : ${CXX}
+    Linker .......................... : ${LD}
+    C preprocessor flags ............ : ${CPPFLAGS}
+    C compiler flags ................ : ${CFLAGS}
+    C++ compiler flags .............. : ${CXXFLAGS}
+    Linker flags .................... : ${LDFLAGS}
+    Extra libraries ................. : ${LIBS}
+
+    Build C++ library ............... : ${enable_cpp}
+    Enable UTF-8 support ............ : ${enable_utf8}
+    Unicode properties .............. : ${enable_unicode_properties}
+    Newline char/sequence ........... : ${enable_newline}
+    \R matches only ANYCRLF ......... : ${enable_bsr_anycrlf}
+    EBCDIC coding ................... : ${enable_ebcdic}
+    Rebuild char tables ............. : ${enable_rebuild_chartables}
+    Use stack recursion ............. : ${enable_stack_for_recursion}
+    POSIX mem threshold ............. : ${with_posix_malloc_threshold}
+    Internal link size .............. : ${with_link_size}
+    Match limit ..................... : ${with_match_limit}
+    Match limit recursion ........... : ${with_match_limit_recursion}
+    Build shared libs ............... : ${enable_shared}
+    Build static libs ............... : ${enable_static}
+    Link pcregrep with libz ......... : ${enable_pcregrep_libz}
+    Link pcregrep with libbz2 ....... : ${enable_pcregrep_libbz2}
+    Link pcretest with libreadline .. : ${enable_pcretest_libreadline}
+
+EOF
+
+dnl end configure.ac
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/depcomp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,589 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2007-03-29.01
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, 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@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+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
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+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.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
+  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.  In older versions, 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.
+  # Version 6 uses the directory in both cases.
+  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$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
+    "$@" -Wc,-M
+  else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
+    "$@" -M
+  fi
+  stat=$?
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  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,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+    # That's a tab and a space in the [].
+    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$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"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  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$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add `dependent.h:' lines.
+    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
+  else
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
+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
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mechanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space 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 preprocessed 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'.
+  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
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $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 $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # 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 ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -*|$object)
+      ;;
+    *)
+      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 preprocessed 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 -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [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 preprocessed 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
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/dftables.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,199 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This is a freestanding support program to generate a file containing
+character tables for PCRE. The tables are built according to the current
+locale. Now that pcre_maketables is a function visible to the outside world, we
+make use of its code from here in order to be consistent. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <locale.h>
+
+#include "pcre_internal.h"
+
+#define DFTABLES          /* pcre_maketables.c notices this */
+#include "pcre_maketables.c"
+
+
+int main(int argc, char **argv)
+{
+FILE *f;
+int i = 1;
+const unsigned char *tables;
+const unsigned char *base_of_tables;
+
+/* By default, the default C locale is used rather than what the building user
+happens to have set. However, if the -L option is given, set the locale from
+the LC_xxx environment variables. */
+
+if (argc > 1 && strcmp(argv[1], "-L") == 0)
+  {
+  setlocale(LC_ALL, "");        /* Set from environment variables */
+  i++;
+  }
+
+if (argc < i + 1)
+  {
+  fprintf(stderr, "dftables: one filename argument is required\n");
+  return 1;
+  }
+
+tables = pcre_maketables();
+base_of_tables = tables;
+
+f = fopen(argv[i], "wb");
+if (f == NULL)
+  {
+  fprintf(stderr, "dftables: failed to open %s for writing\n", argv[1]);
+  return 1;
+  }
+
+/* There are several fprintf() calls here, because gcc in pedantic mode
+complains about the very long string otherwise. */
+
+fprintf(f,
+  "/*************************************************\n"
+  "*      Perl-Compatible Regular Expressions       *\n"
+  "*************************************************/\n\n"
+  "/* This file was automatically written by the dftables auxiliary\n"
+  "program. It contains character tables that are used when no external\n"
+  "tables are passed to PCRE by the application that calls it. The tables\n"
+  "are used only for characters whose code values are less than 256.\n\n");
+fprintf(f,
+  "The following #includes are present because without them gcc 4.x may remove\n"
+  "the array definition from the final binary if PCRE is built into a static\n"
+  "library and dead code stripping is activated. This leads to link errors.\n"
+  "Pulling in the header ensures that the array gets flagged as \"someone\n"
+  "outside this compilation unit might reference this\" and so it will always\n"
+  "be supplied to the linker. */\n\n"
+  "#ifdef HAVE_CONFIG_H\n"
+  "#include \"config.h\"\n"
+  "#endif\n\n"
+  "#include \"pcre_internal.h\"\n\n");
+fprintf(f,
+  "const unsigned char _pcre_default_tables[] = {\n\n"
+  "/* This table is a lower casing table. */\n\n");
+
+fprintf(f, "  ");
+for (i = 0; i < 256; i++)
+  {
+  if ((i & 7) == 0 && i != 0) fprintf(f, "\n  ");
+  fprintf(f, "%3d", *tables++);
+  if (i != 255) fprintf(f, ",");
+  }
+fprintf(f, ",\n\n");
+
+fprintf(f, "/* This table is a case flipping table. */\n\n");
+
+fprintf(f, "  ");
+for (i = 0; i < 256; i++)
+  {
+  if ((i & 7) == 0 && i != 0) fprintf(f, "\n  ");
+  fprintf(f, "%3d", *tables++);
+  if (i != 255) fprintf(f, ",");
+  }
+fprintf(f, ",\n\n");
+
+fprintf(f,
+  "/* This table contains bit maps for various character classes.\n"
+  "Each map is 32 bytes long and the bits run from the least\n"
+  "significant end of each byte. The classes that have their own\n"
+  "maps are: space, xdigit, digit, upper, lower, word, graph\n"
+  "print, punct, and cntrl. Other classes are built from combinations. */\n\n");
+
+fprintf(f, "  ");
+for (i = 0; i < cbit_length; i++)
+  {
+  if ((i & 7) == 0 && i != 0)
+    {
+    if ((i & 31) == 0) fprintf(f, "\n");
+    fprintf(f, "\n  ");
+    }
+  fprintf(f, "0x%02x", *tables++);
+  if (i != cbit_length - 1) fprintf(f, ",");
+  }
+fprintf(f, ",\n\n");
+
+fprintf(f,
+  "/* This table identifies various classes of character by individual bits:\n"
+  "  0x%02x   white space character\n"
+  "  0x%02x   letter\n"
+  "  0x%02x   decimal digit\n"
+  "  0x%02x   hexadecimal digit\n"
+  "  0x%02x   alphanumeric or '_'\n"
+  "  0x%02x   regular expression metacharacter or binary zero\n*/\n\n",
+  ctype_space, ctype_letter, ctype_digit, ctype_xdigit, ctype_word,
+  ctype_meta);
+
+fprintf(f, "  ");
+for (i = 0; i < 256; i++)
+  {
+  if ((i & 7) == 0 && i != 0)
+    {
+    fprintf(f, " /* ");
+    if (isprint(i-8)) fprintf(f, " %c -", i-8);
+      else fprintf(f, "%3d-", i-8);
+    if (isprint(i-1)) fprintf(f, " %c ", i-1);
+      else fprintf(f, "%3d", i-1);
+    fprintf(f, " */\n  ");
+    }
+  fprintf(f, "0x%02x", *tables++);
+  if (i != 255) fprintf(f, ",");
+  }
+
+fprintf(f, "};/* ");
+if (isprint(i-8)) fprintf(f, " %c -", i-8);
+  else fprintf(f, "%3d-", i-8);
+if (isprint(i-1)) fprintf(f, " %c ", i-1);
+  else fprintf(f, "%3d", i-1);
+fprintf(f, " */\n\n/* End of pcre_chartables.c */\n");
+
+fclose(f);
+free((void *)base_of_tables);
+return 0;
+}
+
+/* End of dftables.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/index.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,140 @@
+<html>
+<!-- This is a manually maintained file that is the root of the HTML version of
+     the PCRE documentation. When the HTML documents are built from the man
+     page versions, the entire doc/html directory is emptied, this file is then
+     copied into doc/html/index.html, and the remaining files therein are
+     created by the 132html script.
+-->
+<head>
+<title>PCRE specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>Perl-compatible Regular Expressions (PCRE)</h1>
+<p>
+The HTML documentation for PCRE comprises the following pages:
+</p>
+
+<table>
+<tr><td><a href="pcre.html">pcre</a></td>
+    <td>&nbsp;&nbsp;Introductory page</td></tr>
+
+<tr><td><a href="pcre-config.html">pcre-config</a></td>
+    <td>&nbsp;&nbsp;Information about the installation configuration</td></tr>
+
+<tr><td><a href="pcreapi.html">pcreapi</a></td>
+    <td>&nbsp;&nbsp;PCRE's native API</td></tr>
+
+<tr><td><a href="pcrebuild.html">pcrebuild</a></td>
+    <td>&nbsp;&nbsp;Options for building PCRE</td></tr>
+
+<tr><td><a href="pcrecallout.html">pcrecallout</a></td>
+    <td>&nbsp;&nbsp;The <i>callout</i> facility</td></tr>
+
+<tr><td><a href="pcrecompat.html">pcrecompat</a></td>
+    <td>&nbsp;&nbsp;Compability with Perl</td></tr>
+
+<tr><td><a href="pcrecpp.html">pcrecpp</a></td>
+    <td>&nbsp;&nbsp;The C++ wrapper for the PCRE library</td></tr>
+
+<tr><td><a href="pcregrep.html">pcregrep</a></td>
+    <td>&nbsp;&nbsp;The <b>pcregrep</b> command</td></tr>
+
+<tr><td><a href="pcrematching.html">pcrematching</a></td>
+    <td>&nbsp;&nbsp;Discussion of the two matching algorithms</td></tr>
+
+<tr><td><a href="pcrepartial.html">pcrepartial</a></td>
+    <td>&nbsp;&nbsp;Using PCRE for partial matching</td></tr>
+
+<tr><td><a href="pcrepattern.html">pcrepattern</a></td>
+    <td>&nbsp;&nbsp;Specification of the regular expressions supported by PCRE</td></tr>
+
+<tr><td><a href="pcreperform.html">pcreperform</a></td>
+    <td>&nbsp;&nbsp;Some comments on performance</td></tr>
+
+<tr><td><a href="pcreposix.html">pcreposix</a></td>
+    <td>&nbsp;&nbsp;The POSIX API to the PCRE library</td></tr>
+
+<tr><td><a href="pcreprecompile.html">pcreprecompile</a></td>
+    <td>&nbsp;&nbsp;How to save and re-use compiled patterns</td></tr>
+
+<tr><td><a href="pcresample.html">pcresample</a></td>
+    <td>&nbsp;&nbsp;Description of the sample program</td></tr>
+
+<tr><td><a href="pcrestack.html">pcrestack</a></td>
+    <td>&nbsp;&nbsp;Discussion of PCRE's stack usage</td></tr>
+
+<tr><td><a href="pcresyntax.html">pcresyntax</a></td>
+    <td>&nbsp;&nbsp;Syntax quick-reference summary</td></tr>
+
+<tr><td><a href="pcretest.html">pcretest</a></td>
+    <td>&nbsp;&nbsp;The <b>pcretest</b> command for testing PCRE</td></tr>
+</table>
+
+<p>
+There are also individual pages that summarize the interface for each function
+in the library:
+</p>
+
+<table>
+
+<tr><td><a href="pcre_compile.html">pcre_compile</a></td>
+    <td>&nbsp;&nbsp;Compile a regular expression</td></tr>
+
+<tr><td><a href="pcre_compile2.html">pcre_compile2</a></td>
+    <td>&nbsp;&nbsp;Compile a regular expression (alternate interface)</td></tr>
+
+<tr><td><a href="pcre_config.html">pcre_config</a></td>
+    <td>&nbsp;&nbsp;Show build-time configuration options</td></tr>
+
+<tr><td><a href="pcre_copy_named_substring.html">pcre_copy_named_substring</a></td>
+    <td>&nbsp;&nbsp;Extract named substring into given buffer</td></tr>
+
+<tr><td><a href="pcre_copy_substring.html">pcre_copy_substring</a></td>
+    <td>&nbsp;&nbsp;Extract numbered substring into given buffer</td></tr>
+
+<tr><td><a href="pcre_dfa_exec.html">pcre_dfa_exec</a></td>
+    <td>&nbsp;&nbsp;Match a compiled pattern to a subject string
+    (DFA algorithm; <i>not</i> Perl compatible)</td></tr>
+
+<tr><td><a href="pcre_exec.html">pcre_exec</a></td>
+    <td>&nbsp;&nbsp;Match a compiled pattern to a subject string
+    (Perl compatible)</td></tr>
+
+<tr><td><a href="pcre_free_substring.html">pcre_free_substring</a></td>
+    <td>&nbsp;&nbsp;Free extracted substring</td></tr>
+
+<tr><td><a href="pcre_free_substring_list.html">pcre_free_substring_list</a></td>
+    <td>&nbsp;&nbsp;Free list of extracted substrings</td></tr>
+
+<tr><td><a href="pcre_fullinfo.html">pcre_fullinfo</a></td>
+    <td>&nbsp;&nbsp;Extract information about a pattern</td></tr>
+
+<tr><td><a href="pcre_get_named_substring.html">pcre_get_named_substring</a></td>
+    <td>&nbsp;&nbsp;Extract named substring into new memory</td></tr>
+
+<tr><td><a href="pcre_get_stringnumber.html">pcre_get_stringnumber</a></td>
+    <td>&nbsp;&nbsp;Convert captured string name to number</td></tr>
+
+<tr><td><a href="pcre_get_substring.html">pcre_get_substring</a></td>
+    <td>&nbsp;&nbsp;Extract numbered substring into new memory</td></tr>
+
+<tr><td><a href="pcre_get_substring_list.html">pcre_get_substring_list</a></td>
+    <td>&nbsp;&nbsp;Extract all substrings into new memory</td></tr>
+
+<tr><td><a href="pcre_info.html">pcre_info</a></td>
+    <td>&nbsp;&nbsp;Obsolete information extraction function</td></tr>
+
+<tr><td><a href="pcre_maketables.html">pcre_maketables</a></td>
+    <td>&nbsp;&nbsp;Build character tables in current locale</td></tr>
+
+<tr><td><a href="pcre_refcount.html">pcre_refcount</a></td>
+    <td>&nbsp;&nbsp;Maintain reference count in compiled pattern</td></tr>
+
+<tr><td><a href="pcre_study.html">pcre_study</a></td>
+    <td>&nbsp;&nbsp;Study a compiled pattern</td></tr>
+
+<tr><td><a href="pcre_version.html">pcre_version</a></td>
+    <td>&nbsp;&nbsp;Return PCRE version and release date</td></tr>
+</table>
+
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre-config.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,88 @@
+<html>
+<head>
+<title>pcre-config specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre-config man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
+<li><a name="TOC2" href="#SEC2">DESCRIPTION</a>
+<li><a name="TOC3" href="#SEC3">OPTIONS</a>
+<li><a name="TOC4" href="#SEC4">SEE ALSO</a>
+<li><a name="TOC5" href="#SEC5">AUTHOR</a>
+<li><a name="TOC6" href="#SEC6">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
+<P>
+<b>pcre-config  [--prefix] [--exec-prefix] [--version] [--libs]</b>
+<b>[--libs-posix] [--cflags] [--cflags-posix]</b>
+</P>
+<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
+<P>
+<b>pcre-config</b> returns the configuration of the installed PCRE
+libraries and the options required to compile a program to use them.
+</P>
+<br><a name="SEC3" href="#TOC1">OPTIONS</a><br>
+<P>
+<b>--prefix</b>
+Writes the directory prefix used in the PCRE installation for architecture
+independent files (<i>/usr</i> on many systems, <i>/usr/local</i> on some
+systems) to the standard output.
+</P>
+<P>
+<b>--exec-prefix</b>
+Writes the directory prefix used in the PCRE installation for architecture
+dependent files (normally the same as <b>--prefix</b>) to the standard output.
+</P>
+<P>
+<b>--version</b>
+Writes the version number of the installed PCRE libraries to the standard
+output.
+</P>
+<P>
+<b>--libs</b>
+Writes to the standard output the command line options required to link
+with PCRE (<b>-lpcre</b> on many systems).
+</P>
+<P>
+<b>--libs-posix</b>
+Writes to the standard output the command line options required to link with
+the PCRE posix emulation library (<b>-lpcreposix</b> <b>-lpcre</b> on many
+systems).
+</P>
+<P>
+<b>--cflags</b>
+Writes to the standard output the command line options required to compile
+files that use PCRE (this may include some <b>-I</b> options, but is blank on
+many systems).
+</P>
+<P>
+<b>--cflags-posix</b>
+Writes to the standard output the command line options required to compile
+files that use the PCRE posix emulation library (this may include some <b>-I</b>
+options, but is blank on many systems).
+</P>
+<br><a name="SEC4" href="#TOC1">SEE ALSO</a><br>
+<P>
+<b>pcre(3)</b>
+</P>
+<br><a name="SEC5" href="#TOC1">AUTHOR</a><br>
+<P>
+This manual page was originally written by Mark Baker for the Debian GNU/Linux
+system. It has been slightly revised as a generic PCRE man page.
+</P>
+<br><a name="SEC6" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 18 April 2007
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,304 @@
+<html>
+<head>
+<title>pcre specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">INTRODUCTION</a>
+<li><a name="TOC2" href="#SEC2">USER DOCUMENTATION</a>
+<li><a name="TOC3" href="#SEC3">LIMITATIONS</a>
+<li><a name="TOC4" href="#SEC4">UTF-8 AND UNICODE PROPERTY SUPPORT</a>
+<li><a name="TOC5" href="#SEC5">AUTHOR</a>
+<li><a name="TOC6" href="#SEC6">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">INTRODUCTION</a><br>
+<P>
+The PCRE library is a set of functions that implement regular expression
+pattern matching using the same syntax and semantics as Perl, with just a few
+differences. Certain features that appeared in Python and PCRE before they
+appeared in Perl are also available using the Python syntax. There is also some
+support for certain .NET and Oniguruma syntax items, and there is an option for
+requesting some minor changes that give better JavaScript compatibility.
+</P>
+<P>
+The current implementation of PCRE (release 7.x) corresponds approximately with
+Perl 5.10, including support for UTF-8 encoded strings and Unicode general
+category properties. However, UTF-8 and Unicode support has to be explicitly
+enabled; it is not the default. The Unicode tables correspond to Unicode
+release 5.0.0.
+</P>
+<P>
+In addition to the Perl-compatible matching function, PCRE contains an
+alternative matching function that matches the same compiled patterns in a
+different way. In certain circumstances, the alternative function has some
+advantages. For a discussion of the two matching algorithms, see the
+<a href="pcrematching.html"><b>pcrematching</b></a>
+page.
+</P>
+<P>
+PCRE is written in C and released as a C library. A number of people have
+written wrappers and interfaces of various kinds. In particular, Google Inc.
+have provided a comprehensive C++ wrapper. This is now included as part of the
+PCRE distribution. The
+<a href="pcrecpp.html"><b>pcrecpp</b></a>
+page has details of this interface. Other people's contributions can be found
+in the <i>Contrib</i> directory at the primary FTP site, which is:
+<a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre">ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre</a>
+</P>
+<P>
+Details of exactly which Perl regular expression features are and are not
+supported by PCRE are given in separate documents. See the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+and
+<a href="pcrecompat.html"><b>pcrecompat</b></a>
+pages. There is a syntax summary in the
+<a href="pcresyntax.html"><b>pcresyntax</b></a>
+page.
+</P>
+<P>
+Some features of PCRE can be included, excluded, or changed when the library is
+built. The
+<a href="pcre_config.html"><b>pcre_config()</b></a>
+function makes it possible for a client to discover which features are
+available. The features themselves are described in the
+<a href="pcrebuild.html"><b>pcrebuild</b></a>
+page. Documentation about building PCRE for various operating systems can be
+found in the <b>README</b> file in the source distribution.
+</P>
+<P>
+The library contains a number of undocumented internal functions and data
+tables that are used by more than one of the exported external functions, but
+which are not intended for use by external callers. Their names all begin with
+"_pcre_", which hopefully will not provoke any name clashes. In some
+environments, it is possible to control which external symbols are exported
+when a shared library is built, and in these cases the undocumented symbols are
+not exported.
+</P>
+<br><a name="SEC2" href="#TOC1">USER DOCUMENTATION</a><br>
+<P>
+The user documentation for PCRE comprises a number of different sections. In
+the "man" format, each of these is a separate "man page". In the HTML format,
+each is a separate page, linked from the index page. In the plain text format,
+all the sections are concatenated, for ease of searching. The sections are as
+follows:
+<pre>
+  pcre              this document
+  pcre-config       show PCRE installation configuration information
+  pcreapi           details of PCRE's native C API
+  pcrebuild         options for building PCRE
+  pcrecallout       details of the callout feature
+  pcrecompat        discussion of Perl compatibility
+  pcrecpp           details of the C++ wrapper
+  pcregrep          description of the <b>pcregrep</b> command
+  pcrematching      discussion of the two matching algorithms
+  pcrepartial       details of the partial matching facility
+  pcrepattern       syntax and semantics of supported regular expressions
+  pcresyntax        quick syntax reference
+  pcreperform       discussion of performance issues
+  pcreposix         the POSIX-compatible C API
+  pcreprecompile    details of saving and re-using precompiled patterns
+  pcresample        discussion of the sample program
+  pcrestack         discussion of stack usage
+  pcretest          description of the <b>pcretest</b> testing command
+</pre>
+In addition, in the "man" and HTML formats, there is a short page for each
+C library function, listing its arguments and results.
+</P>
+<br><a name="SEC3" href="#TOC1">LIMITATIONS</a><br>
+<P>
+There are some size limitations in PCRE but it is hoped that they will never in
+practice be relevant.
+</P>
+<P>
+The maximum length of a compiled pattern is 65539 (sic) bytes if PCRE is
+compiled with the default internal linkage size of 2. If you want to process
+regular expressions that are truly enormous, you can compile PCRE with an
+internal linkage size of 3 or 4 (see the <b>README</b> file in the source
+distribution and the
+<a href="pcrebuild.html"><b>pcrebuild</b></a>
+documentation for details). In these cases the limit is substantially larger.
+However, the speed of execution is slower.
+</P>
+<P>
+All values in repeating quantifiers must be less than 65536.
+</P>
+<P>
+There is no limit to the number of parenthesized subpatterns, but there can be
+no more than 65535 capturing subpatterns.
+</P>
+<P>
+The maximum length of name for a named subpattern is 32 characters, and the
+maximum number of named subpatterns is 10000.
+</P>
+<P>
+The maximum length of a subject string is the largest positive number that an
+integer variable can hold. However, when using the traditional matching
+function, PCRE uses recursion to handle subpatterns and indefinite repetition.
+This means that the available stack space may limit the size of a subject
+string that can be processed by certain patterns. For a discussion of stack
+issues, see the
+<a href="pcrestack.html"><b>pcrestack</b></a>
+documentation.
+<a name="utf8support"></a></P>
+<br><a name="SEC4" href="#TOC1">UTF-8 AND UNICODE PROPERTY SUPPORT</a><br>
+<P>
+From release 3.3, PCRE has had some support for character strings encoded in
+the UTF-8 format. For release 4.0 this was greatly extended to cover most
+common requirements, and in release 5.0 additional support for Unicode general
+category properties was added.
+</P>
+<P>
+In order process UTF-8 strings, you must build PCRE to include UTF-8 support in
+the code, and, in addition, you must call
+<a href="pcre_compile.html"><b>pcre_compile()</b></a>
+with the PCRE_UTF8 option flag. When you do this, both the pattern and any
+subject strings that are matched against it are treated as UTF-8 strings
+instead of just strings of bytes.
+</P>
+<P>
+If you compile PCRE with UTF-8 support, but do not use it at run time, the
+library will be a bit bigger, but the additional run time overhead is limited
+to testing the PCRE_UTF8 flag occasionally, so should not be very big.
+</P>
+<P>
+If PCRE is built with Unicode character property support (which implies UTF-8
+support), the escape sequences \p{..}, \P{..}, and \X are supported.
+The available properties that can be tested are limited to the general
+category properties such as Lu for an upper case letter or Nd for a decimal
+number, the Unicode script names such as Arabic or Han, and the derived
+properties Any and L&. A full list is given in the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+documentation. Only the short names for properties are supported. For example,
+\p{L} matches a letter. Its Perl synonym, \p{Letter}, is not supported.
+Furthermore, in Perl, many properties may optionally be prefixed by "Is", for
+compatibility with Perl 5.6. PCRE does not support this.
+<a name="utf8strings"></a></P>
+<br><b>
+Validity of UTF-8 strings
+</b><br>
+<P>
+When you set the PCRE_UTF8 flag, the strings passed as patterns and subjects
+are (by default) checked for validity on entry to the relevant functions. From
+release 7.3 of PCRE, the check is according the rules of RFC 3629, which are
+themselves derived from the Unicode specification. Earlier releases of PCRE
+followed the rules of RFC 2279, which allows the full range of 31-bit values (0
+to 0x7FFFFFFF). The current check allows only values in the range U+0 to
+U+10FFFF, excluding U+D800 to U+DFFF.
+</P>
+<P>
+The excluded code points are the "Low Surrogate Area" of Unicode, of which the
+Unicode Standard says this: "The Low Surrogate Area does not contain any
+character assignments, consequently no character code charts or namelists are
+provided for this area. Surrogates are reserved for use with UTF-16 and then
+must be used in pairs." The code points that are encoded by UTF-16 pairs are
+available as independent code points in the UTF-8 encoding. (In other words,
+the whole surrogate thing is a fudge for UTF-16 which unfortunately messes up
+UTF-8.)
+</P>
+<P>
+If an invalid UTF-8 string is passed to PCRE, an error return
+(PCRE_ERROR_BADUTF8) is given. In some situations, you may already know that
+your strings are valid, and therefore want to skip these checks in order to
+improve performance. If you set the PCRE_NO_UTF8_CHECK flag at compile time or
+at run time, PCRE assumes that the pattern or subject it is given
+(respectively) contains only valid UTF-8 codes. In this case, it does not
+diagnose an invalid UTF-8 string.
+</P>
+<P>
+If you pass an invalid UTF-8 string when PCRE_NO_UTF8_CHECK is set, what
+happens depends on why the string is invalid. If the string conforms to the
+"old" definition of UTF-8 (RFC 2279), it is processed as a string of characters
+in the range 0 to 0x7FFFFFFF. In other words, apart from the initial validity
+test, PCRE (when in UTF-8 mode) handles strings according to the more liberal
+rules of RFC 2279. However, if the string does not even conform to RFC 2279,
+the result is undefined. Your program may crash.
+</P>
+<P>
+If you want to process strings of values in the full range 0 to 0x7FFFFFFF,
+encoded in a UTF-8-like manner as per the old RFC, you can set
+PCRE_NO_UTF8_CHECK to bypass the more restrictive test. However, in this
+situation, you will have to apply your own validity check.
+</P>
+<br><b>
+General comments about UTF-8 mode
+</b><br>
+<P>
+1. An unbraced hexadecimal escape sequence (such as \xb3) matches a two-byte
+UTF-8 character if the value is greater than 127.
+</P>
+<P>
+2. Octal numbers up to \777 are recognized, and match two-byte UTF-8
+characters for values greater than \177.
+</P>
+<P>
+3. Repeat quantifiers apply to complete UTF-8 characters, not to individual
+bytes, for example: \x{100}{3}.
+</P>
+<P>
+4. The dot metacharacter matches one UTF-8 character instead of a single byte.
+</P>
+<P>
+5. The escape sequence \C can be used to match a single byte in UTF-8 mode,
+but its use can lead to some strange effects. This facility is not available in
+the alternative matching function, <b>pcre_dfa_exec()</b>.
+</P>
+<P>
+6. The character escapes \b, \B, \d, \D, \s, \S, \w, and \W correctly
+test characters of any code value, but the characters that PCRE recognizes as
+digits, spaces, or word characters remain the same set as before, all with
+values less than 256. This remains true even when PCRE includes Unicode
+property support, because to do otherwise would slow down PCRE in many common
+cases. If you really want to test for a wider sense of, say, "digit", you
+must use Unicode property tests such as \p{Nd}.
+</P>
+<P>
+7. Similarly, characters that match the POSIX named character classes are all
+low-valued characters.
+</P>
+<P>
+8. However, the Perl 5.10 horizontal and vertical whitespace matching escapes
+(\h, \H, \v, and \V) do match all the appropriate Unicode characters.
+</P>
+<P>
+9. Case-insensitive matching applies only to characters whose values are less
+than 128, unless PCRE is built with Unicode property support. Even when Unicode
+property support is available, PCRE still uses its own character tables when
+checking the case of low-valued characters, so as not to degrade performance.
+The Unicode property information is used only for characters with higher
+values. Even when Unicode property support is available, PCRE supports
+case-insensitive matching only when there is a one-to-one mapping between a
+letter's cases. There are a small number of many-to-one mappings in Unicode;
+these are not supported by PCRE.
+</P>
+<br><a name="SEC5" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<P>
+Putting an actual email address here seems to have been a spam magnet, so I've
+taken it away. If you want to email me, use my two initials, followed by the
+two digits 10, at the domain cam.ac.uk.
+</P>
+<br><a name="SEC6" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 12 April 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_compile.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,89 @@
+<html>
+<head>
+<title>pcre_compile specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_compile man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function compiles a regular expression into an internal form. It is the
+same as <b>pcre_compile2()</b>, except for the absence of the <i>errorcodeptr</i>
+argument. Its arguments are:
+<pre>
+  <i>pattern</i>       A zero-terminated string containing the
+                  regular expression to be compiled
+  <i>options</i>       Zero or more option bits
+  <i>errptr</i>        Where to put an error message
+  <i>erroffset</i>     Offset in pattern where error was found
+  <i>tableptr</i>      Pointer to character tables, or NULL to
+                  use the built-in default
+</pre>
+The option bits are:
+<pre>
+  PCRE_ANCHORED           Force pattern anchoring
+  PCRE_AUTO_CALLOUT       Compile automatic callouts
+  PCRE_BSR_ANYCRLF        \R matches only CR, LF, or CRLF
+  PCRE_BSR_UNICODE        \R matches all Unicode line endings
+  PCRE_CASELESS           Do caseless matching
+  PCRE_DOLLAR_ENDONLY     $ not to match newline at end
+  PCRE_DOTALL             . matches anything including NL
+  PCRE_DUPNAMES           Allow duplicate names for subpatterns
+  PCRE_EXTENDED           Ignore whitespace and # comments
+  PCRE_EXTRA              PCRE extra features
+                            (not much use currently)
+  PCRE_FIRSTLINE          Force matching to be before newline
+  PCRE_JAVASCRIPT_COMPAT  JavaScript compatibility
+  PCRE_MULTILINE          ^ and $ match newlines within data
+  PCRE_NEWLINE_ANY        Recognize any Unicode newline sequence
+  PCRE_NEWLINE_ANYCRLF    Recognize CR, LF, and CRLF as newline
+                            sequences
+  PCRE_NEWLINE_CR         Set CR as the newline sequence
+  PCRE_NEWLINE_CRLF       Set CRLF as the newline sequence
+  PCRE_NEWLINE_LF         Set LF as the newline sequence
+  PCRE_NO_AUTO_CAPTURE    Disable numbered capturing paren-
+                            theses (named ones available)
+  PCRE_UNGREEDY           Invert greediness of quantifiers
+  PCRE_UTF8               Run in UTF-8 mode
+  PCRE_NO_UTF8_CHECK      Do not check the pattern for UTF-8
+                            validity (only relevant if
+                            PCRE_UTF8 is set)
+</pre>
+PCRE must be built with UTF-8 support in order to use PCRE_UTF8 and
+PCRE_NO_UTF8_CHECK.
+</P>
+<P>
+The yield of the function is a pointer to a private data structure that
+contains the compiled pattern, or NULL if an error was detected. Note that
+compiling regular expressions with one version of PCRE for use with a different
+version is not guaranteed to work and may cause crashes.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_compile2.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,89 @@
+<html>
+<head>
+<title>pcre_compile2 specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_compile2 man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>pcre *pcre_compile2(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>int *<i>errorcodeptr</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function compiles a regular expression into an internal form. It is the
+same as <b>pcre_compile()</b>, except for the addition of the <i>errorcodeptr</i>
+argument. The arguments are:
+</P>
+<P>
+<pre>
+  <i>pattern</i>       A zero-terminated string containing the
+                  regular expression to be compiled
+  <i>options</i>       Zero or more option bits
+  <i>errorcodeptr</i>  Where to put an error code
+  <i>errptr</i>        Where to put an error message
+  <i>erroffset</i>     Offset in pattern where error was found
+  <i>tableptr</i>      Pointer to character tables, or NULL to
+                  use the built-in default
+</pre>
+The option bits are:
+<pre>
+  PCRE_ANCHORED         Force pattern anchoring
+  PCRE_AUTO_CALLOUT     Compile automatic callouts
+  PCRE_CASELESS         Do caseless matching
+  PCRE_DOLLAR_ENDONLY   $ not to match newline at end
+  PCRE_DOTALL           . matches anything including NL
+  PCRE_DUPNAMES         Allow duplicate names for subpatterns
+  PCRE_EXTENDED         Ignore whitespace and # comments
+  PCRE_EXTRA            PCRE extra features
+                          (not much use currently)
+  PCRE_FIRSTLINE        Force matching to be before newline
+  PCRE_MULTILINE        ^ and $ match newlines within data
+  PCRE_NEWLINE_ANY      Recognize any Unicode newline sequence
+  PCRE_NEWLINE_ANYCRLF  Recognize CR, LF, and CRLF as newline sequences
+  PCRE_NEWLINE_CR       Set CR as the newline sequence
+  PCRE_NEWLINE_CRLF     Set CRLF as the newline sequence
+  PCRE_NEWLINE_LF       Set LF as the newline sequence
+  PCRE_NO_AUTO_CAPTURE  Disable numbered capturing paren-
+                          theses (named ones available)
+  PCRE_UNGREEDY         Invert greediness of quantifiers
+  PCRE_UTF8             Run in UTF-8 mode
+  PCRE_NO_UTF8_CHECK    Do not check the pattern for UTF-8
+                          validity (only relevant if
+                          PCRE_UTF8 is set)
+</pre>
+PCRE must be built with UTF-8 support in order to use PCRE_UTF8 and
+PCRE_NO_UTF8_CHECK.
+</P>
+<P>
+The yield of the function is a pointer to a private data structure that
+contains the compiled pattern, or NULL if an error was detected. Note that
+compiling regular expressions with one version of PCRE for use with a different
+version is not guaranteed to work and may cause crashes.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_config.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,70 @@
+<html>
+<head>
+<title>pcre_config specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_config man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function makes it possible for a client program to find out which optional
+features are available in the version of the PCRE library it is using. Its
+arguments are as follows:
+<pre>
+  <i>what</i>     A code specifying what information is required
+  <i>where</i>    Points to where to put the data
+</pre>
+The available codes are:
+<pre>
+  PCRE_CONFIG_LINK_SIZE     Internal link size: 2, 3, or 4
+  PCRE_CONFIG_MATCH_LIMIT   Internal resource limit
+  PCRE_CONFIG_MATCH_LIMIT_RECURSION
+                            Internal recursion depth limit
+  PCRE_CONFIG_NEWLINE       Value of the default newline sequence:
+                                13 (0x000d)    for CR
+                                10 (0x000a)    for LF
+                              3338 (0x0d0a)    for CRLF
+                                -2             for ANYCRLF
+                                -1             for ANY
+  PCRE_CONFIG_BSR           Indicates what \R matches by default:
+                                 0             all Unicode line endings
+                                 1             CR, LF, or CRLF only
+  PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+                            Threshold of return slots, above
+                              which <b>malloc()</b> is used by
+                              the POSIX API
+  PCRE_CONFIG_STACKRECURSE  Recursion implementation (1=stack 0=heap)
+  PCRE_CONFIG_UTF8          Availability of UTF-8 support (1=yes 0=no)
+  PCRE_CONFIG_UNICODE_PROPERTIES
+                            Availability of Unicode property support
+                              (1=yes 0=no)
+</pre>
+The function yields 0 on success or PCRE_ERROR_BADOPTION otherwise.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_copy_named_substring.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,53 @@
+<html>
+<head>
+<title>pcre_copy_named_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_copy_named_substring man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_copy_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>char *<i>buffer</i>, int <i>buffersize</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a captured substring, identified
+by name, into a given buffer. The arguments are:
+<pre>
+  <i>code</i>          Pattern that was successfully matched
+  <i>subject</i>       Subject that has been successfully matched
+  <i>ovector</i>       Offset vector that <b>pcre_exec()</b> used
+  <i>stringcount</i>   Value returned by <b>pcre_exec()</b>
+  <i>stringname</i>    Name of the required substring
+  <i>buffer</i>        Buffer to receive the string
+  <i>buffersize</i>    Size of buffer
+</pre>
+The yield is the length of the substring, PCRE_ERROR_NOMEMORY if the buffer was
+too small, or PCRE_ERROR_NOSUBSTRING if the string name is invalid.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_copy_substring.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,51 @@
+<html>
+<head>
+<title>pcre_copy_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_copy_substring man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_copy_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
+<b>int <i>buffersize</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a captured substring into a given
+buffer. The arguments are:
+<pre>
+  <i>subject</i>       Subject that has been successfully matched
+  <i>ovector</i>       Offset vector that <b>pcre_exec()</b> used
+  <i>stringcount</i>   Value returned by <b>pcre_exec()</b>
+  <i>stringnumber</i>  Number of the required substring
+  <i>buffer</i>        Buffer to receive the string
+  <i>buffersize</i>    Size of buffer
+</pre>
+The yield is the length of the string, PCRE_ERROR_NOMEMORY if the buffer was
+too small, or PCRE_ERROR_NOSUBSTRING if the string number is invalid.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_dfa_exec.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,97 @@
+<html>
+<head>
+<title>pcre_dfa_exec specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_dfa_exec man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_dfa_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>,</b>
+<b>int *<i>workspace</i>, int <i>wscount</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function matches a compiled regular expression against a given subject
+string, using an alternative matching algorithm that scans the subject string
+just once (<i>not</i> Perl-compatible). Note that the main, Perl-compatible,
+matching function is <b>pcre_exec()</b>. The arguments for this function are:
+<pre>
+  <i>code</i>         Points to the compiled pattern
+  <i>extra</i>        Points to an associated <b>pcre_extra</b> structure,
+                 or is NULL
+  <i>subject</i>      Points to the subject string
+  <i>length</i>       Length of the subject string, in bytes
+  <i>startoffset</i>  Offset in bytes in the subject at which to
+                 start matching
+  <i>options</i>      Option bits
+  <i>ovector</i>      Points to a vector of ints for result offsets
+  <i>ovecsize</i>     Number of elements in the vector
+  <i>workspace</i>    Points to a vector of ints used as working space
+  <i>wscount</i>      Number of elements in the vector
+</pre>
+The options are:
+<pre>
+  PCRE_ANCHORED      Match only at the first position
+  PCRE_BSR_ANYCRLF   \R matches only CR, LF, or CRLF
+  PCRE_BSR_UNICODE   \R matches all Unicode line endings
+  PCRE_NEWLINE_ANY   Recognize any Unicode newline sequence
+  PCRE_NEWLINE_ANYCRLF  Recognize CR, LF, and CRLF as newline sequences
+  PCRE_NEWLINE_CR    Set CR as the newline sequence
+  PCRE_NEWLINE_CRLF  Set CRLF as the newline sequence
+  PCRE_NEWLINE_LF    Set LF as the newline sequence
+  PCRE_NOTBOL        Subject is not the beginning of a line
+  PCRE_NOTEOL        Subject is not the end of a line
+  PCRE_NOTEMPTY      An empty string is not a valid match
+  PCRE_NO_UTF8_CHECK Do not check the subject for UTF-8
+                       validity (only relevant if PCRE_UTF8
+                       was set at compile time)
+  PCRE_PARTIAL       Return PCRE_ERROR_PARTIAL for a partial match
+  PCRE_DFA_SHORTEST  Return only the shortest match
+  PCRE_DFA_RESTART   This is a restart after a partial match
+</pre>
+There are restrictions on what may appear in a pattern when using this matching
+function. Details are given in the
+<a href="pcrematching.html"><b>pcrematching</b></a>
+documentation.
+</P>
+<P>
+A <b>pcre_extra</b> structure contains the following fields:
+<pre>
+  <i>flags</i>        Bits indicating which fields are set
+  <i>study_data</i>   Opaque data from <b>pcre_study()</b>
+  <i>match_limit</i>  Limit on internal resource use
+  <i>match_limit_recursion</i>  Limit on internal recursion depth
+  <i>callout_data</i> Opaque data passed back to callouts
+  <i>tables</i>       Points to character tables or is NULL
+</pre>
+The flag bits are PCRE_EXTRA_STUDY_DATA, PCRE_EXTRA_MATCH_LIMIT,
+PCRE_EXTRA_MATCH_LIMIT_RECURSION, PCRE_EXTRA_CALLOUT_DATA, and
+PCRE_EXTRA_TABLES. For this matching function, the <i>match_limit</i> and
+<i>match_limit_recursion</i> fields are not used, and must not be set.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_exec.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,90 @@
+<html>
+<head>
+<title>pcre_exec specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_exec man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function matches a compiled regular expression against a given subject
+string, using a matching algorithm that is similar to Perl's. It returns
+offsets to captured substrings. Its arguments are:
+<pre>
+  <i>code</i>         Points to the compiled pattern
+  <i>extra</i>        Points to an associated <b>pcre_extra</b> structure,
+                 or is NULL
+  <i>subject</i>      Points to the subject string
+  <i>length</i>       Length of the subject string, in bytes
+  <i>startoffset</i>  Offset in bytes in the subject at which to
+                 start matching
+  <i>options</i>      Option bits
+  <i>ovector</i>      Points to a vector of ints for result offsets
+  <i>ovecsize</i>     Number of elements in the vector (a multiple of 3)
+</pre>
+The options are:
+<pre>
+  PCRE_ANCHORED      Match only at the first position
+  PCRE_BSR_ANYCRLF   \R matches only CR, LF, or CRLF
+  PCRE_BSR_UNICODE   \R matches all Unicode line endings
+  PCRE_NEWLINE_ANY   Recognize any Unicode newline sequence
+  PCRE_NEWLINE_ANYCRLF  Recognize CR, LF, and CRLF as newline sequences
+  PCRE_NEWLINE_CR    Set CR as the newline sequence
+  PCRE_NEWLINE_CRLF  Set CRLF as the newline sequence
+  PCRE_NEWLINE_LF    Set LF as the newline sequence
+  PCRE_NOTBOL        Subject is not the beginning of a line
+  PCRE_NOTEOL        Subject is not the end of a line
+  PCRE_NOTEMPTY      An empty string is not a valid match
+  PCRE_NO_UTF8_CHECK Do not check the subject for UTF-8
+                       validity (only relevant if PCRE_UTF8
+                       was set at compile time)
+  PCRE_PARTIAL       Return PCRE_ERROR_PARTIAL for a partial match
+</pre>
+There are restrictions on what may appear in a pattern when partial matching is
+requested. For details, see the
+<a href="pcrepartial.html"><b>pcrepartial</b></a>
+page.
+</P>
+<P>
+A <b>pcre_extra</b> structure contains the following fields:
+<pre>
+  <i>flags</i>        Bits indicating which fields are set
+  <i>study_data</i>   Opaque data from <b>pcre_study()</b>
+  <i>match_limit</i>  Limit on internal resource use
+  <i>match_limit_recursion</i>  Limit on internal recursion depth
+  <i>callout_data</i> Opaque data passed back to callouts
+  <i>tables</i>       Points to character tables or is NULL
+</pre>
+The flag bits are PCRE_EXTRA_STUDY_DATA, PCRE_EXTRA_MATCH_LIMIT,
+PCRE_EXTRA_MATCH_LIMIT_RECURSION, PCRE_EXTRA_CALLOUT_DATA, and
+PCRE_EXTRA_TABLES.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_free_substring.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+<html>
+<head>
+<title>pcre_free_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_free_substring man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>void pcre_free_substring(const char *<i>stringptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for freeing the store obtained by a previous
+call to <b>pcre_get_substring()</b> or <b>pcre_get_named_substring()</b>. Its
+only argument is a pointer to the string.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_free_substring_list.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+<html>
+<head>
+<title>pcre_free_substring_list specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_free_substring_list man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>void pcre_free_substring_list(const char **<i>stringptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for freeing the store obtained by a previous
+call to <b>pcre_get_substring_list()</b>. Its only argument is a pointer to the
+list of string pointers.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_fullinfo.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,72 @@
+<html>
+<head>
+<title>pcre_fullinfo specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_fullinfo man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function returns information about a compiled pattern. Its arguments are:
+<pre>
+  <i>code</i>                      Compiled regular expression
+  <i>extra</i>                     Result of <b>pcre_study()</b> or NULL
+  <i>what</i>                      What information is required
+  <i>where</i>                     Where to put the information
+</pre>
+The following information is available:
+<pre>
+  PCRE_INFO_BACKREFMAX      Number of highest back reference
+  PCRE_INFO_CAPTURECOUNT    Number of capturing subpatterns
+  PCRE_INFO_DEFAULT_TABLES  Pointer to default tables
+  PCRE_INFO_FIRSTBYTE       Fixed first byte for a match, or
+                              -1 for start of string
+                                 or after newline, or
+                              -2 otherwise
+  PCRE_INFO_FIRSTTABLE      Table of first bytes (after studying)
+  PCRE_INFO_JCHANGED        Return 1 if (?J) or (?-J) was used
+  PCRE_INFO_LASTLITERAL     Literal last byte required
+  PCRE_INFO_NAMECOUNT       Number of named subpatterns
+  PCRE_INFO_NAMEENTRYSIZE   Size of name table entry
+  PCRE_INFO_NAMETABLE       Pointer to name table
+  PCRE_INFO_OKPARTIAL       Return 1 if partial matching can be tried
+  PCRE_INFO_OPTIONS         Option bits used for compilation
+  PCRE_INFO_SIZE            Size of compiled pattern
+  PCRE_INFO_STUDYSIZE       Size of study data
+</pre>
+The yield of the function is zero on success or:
+<pre>
+  PCRE_ERROR_NULL           the argument <i>code</i> was NULL
+                            the argument <i>where</i> was NULL
+  PCRE_ERROR_BADMAGIC       the "magic number" was not found
+  PCRE_ERROR_BADOPTION      the value of <i>what</i> was invalid
+</PRE>
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_get_named_substring.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,55 @@
+<html>
+<head>
+<title>pcre_get_named_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_get_named_substring man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a captured substring by name. The
+arguments are:
+<pre>
+  <i>code</i>          Compiled pattern
+  <i>subject</i>       Subject that has been successfully matched
+  <i>ovector</i>       Offset vector that <b>pcre_exec()</b> used
+  <i>stringcount</i>   Value returned by <b>pcre_exec()</b>
+  <i>stringname</i>    Name of the required substring
+  <i>stringptr</i>     Where to put the string pointer
+</pre>
+The memory in which the substring is placed is obtained by calling
+<b>pcre_malloc()</b>. The convenience function <b>pcre_free_substring()</b> can
+be used to free it when it is no longer needed. The yield of the function is
+the length of the extracted substring, PCRE_ERROR_NOMEMORY if sufficient memory
+could not be obtained, or PCRE_ERROR_NOSUBSTRING if the string name is invalid.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_get_stringnumber.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,49 @@
+<html>
+<head>
+<title>pcre_get_stringnumber specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_get_stringnumber man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This convenience function finds the number of a named substring capturing
+parenthesis in a compiled pattern. Its arguments are:
+<pre>
+  <i>code</i>    Compiled regular expression
+  <i>name</i>    Name whose number is required
+</pre>
+The yield of the function is the number of the parenthesis if the name is
+found, or PCRE_ERROR_NOSUBSTRING otherwise. When duplicate names are allowed
+(PCRE_DUPNAMES is set), it is not defined which of the numbers is returned by
+<b>pcre_get_stringnumber()</b>. You can obtain the complete list by calling
+<b>pcre_get_stringtable_entries()</b>.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_get_stringtable_entries.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+<html>
+<head>
+<title>pcre_get_stringtable_entries specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_get_stringtable_entries man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_stringtable_entries(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>, char **<i>first</i>, char **<i>last</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This convenience function finds, for a compiled pattern, the first and last
+entries for a given name in the table that translates capturing parenthesis
+names into numbers. When names are required to be unique (PCRE_DUPNAMES is
+<i>not</i> set), it is usually easier to use <b>pcre_get_stringnumber()</b>
+instead.
+<pre>
+  <i>code</i>    Compiled regular expression
+  <i>name</i>    Name whose entries required
+  <i>first</i>   Where to return a pointer to the first entry
+  <i>last</i>    Where to return a pointer to the last entry
+</pre>
+The yield of the function is the length of each entry, or
+PCRE_ERROR_NOSUBSTRING if none are found.
+</P>
+<P>
+There is a complete description of the PCRE native API, including the format of
+the table entries, in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page, and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_get_substring.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,53 @@
+<html>
+<head>
+<title>pcre_get_substring specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_get_substring man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a captured substring. The
+arguments are:
+<pre>
+  <i>subject</i>       Subject that has been successfully matched
+  <i>ovector</i>       Offset vector that <b>pcre_exec()</b> used
+  <i>stringcount</i>   Value returned by <b>pcre_exec()</b>
+  <i>stringnumber</i>  Number of the required substring
+  <i>stringptr</i>     Where to put the string pointer
+</pre>
+The memory in which the substring is placed is obtained by calling
+<b>pcre_malloc()</b>. The convenience function <b>pcre_free_substring()</b> can
+be used to free it when it is no longer needed. The yield of the function is
+the length of the substring, PCRE_ERROR_NOMEMORY if sufficient memory could not
+be obtained, or PCRE_ERROR_NOSUBSTRING if the string number is invalid.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_get_substring_list.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,53 @@
+<html>
+<head>
+<title>pcre_get_substring_list specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_get_substring_list man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_get_substring_list(const char *<i>subject</i>,</b>
+<b>int *<i>ovector</i>, int <i>stringcount</i>, const char ***<i>listptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This is a convenience function for extracting a list of all the captured
+substrings. The arguments are:
+<pre>
+  <i>subject</i>       Subject that has been successfully matched
+  <i>ovector</i>       Offset vector that <b>pcre_exec</b> used
+  <i>stringcount</i>   Value returned by <b>pcre_exec</b>
+  <i>listptr</i>       Where to put a pointer to the list
+</pre>
+The memory in which the substrings and the list are placed is obtained by
+calling <b>pcre_malloc()</b>. The convenience function
+<b>pcre_free_substring_list()</b> can be used to free it when it is no longer
+needed. A pointer to a list of pointers is put in the variable whose address is
+in <i>listptr</i>. The list is terminated by a NULL pointer. The yield of the
+function is zero on success or PCRE_ERROR_NOMEMORY if sufficient memory could
+not be obtained.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_info.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+<html>
+<head>
+<title>pcre_info specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_info man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
+<b>*<i>firstcharptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function is obsolete. You should be using <b>pcre_fullinfo()</b> instead.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_maketables.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+<html>
+<head>
+<title>pcre_maketables specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_maketables man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>const unsigned char *pcre_maketables(void);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function builds a set of character tables for character values less than
+256. These can be passed to <b>pcre_compile()</b> to override PCRE's internal,
+built-in tables (which were made by <b>pcre_maketables()</b> when PCRE was
+compiled). You might want to do this if you are using a non-standard locale.
+The function yields a pointer to the tables.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_refcount.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+<html>
+<head>
+<title>pcre_refcount specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_refcount man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>int pcre_refcount(pcre *<i>code</i>, int <i>adjust</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function is used to maintain a reference count inside a data block that
+contains a compiled pattern. Its arguments are:
+<pre>
+  <i>code</i>                      Compiled regular expression
+  <i>adjust</i>                    Adjustment to reference value
+</pre>
+The yield of the function is the adjusted reference value, which is constrained
+to lie between 0 and 65535.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_study.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+<html>
+<head>
+<title>pcre_study specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_study man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function studies a compiled pattern, to see if additional information can
+be extracted that might speed up matching. Its arguments are:
+<pre>
+  <i>code</i>       A compiled regular expression
+  <i>options</i>    Options for <b>pcre_study()</b>
+  <i>errptr</i>     Where to put an error message
+</pre>
+If the function succeeds, it returns a value that can be passed to
+<b>pcre_exec()</b> via its <i>extra</i> argument.
+</P>
+<P>
+If the function returns NULL, either it could not find any additional
+information, or there was an error. You can tell the difference by looking at
+the error value. It is NULL in first case.
+</P>
+<P>
+There are currently no options defined; the value of the second argument should
+always be zero.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcre_version.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+<html>
+<head>
+<title>pcre_version specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcre_version man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+SYNOPSIS
+</b><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>char *pcre_version(void);</b>
+</P>
+<br><b>
+DESCRIPTION
+</b><br>
+<P>
+This function returns a character string that gives the version number of the
+PCRE library and the date of its release.
+</P>
+<P>
+There is a complete description of the PCRE native API in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page and a description of the POSIX API in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+page.
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcreapi.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1985 @@
+<html>
+<head>
+<title>pcreapi specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcreapi man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE NATIVE API</a>
+<li><a name="TOC2" href="#SEC2">PCRE API OVERVIEW</a>
+<li><a name="TOC3" href="#SEC3">NEWLINES</a>
+<li><a name="TOC4" href="#SEC4">MULTITHREADING</a>
+<li><a name="TOC5" href="#SEC5">SAVING PRECOMPILED PATTERNS FOR LATER USE</a>
+<li><a name="TOC6" href="#SEC6">CHECKING BUILD-TIME OPTIONS</a>
+<li><a name="TOC7" href="#SEC7">COMPILING A PATTERN</a>
+<li><a name="TOC8" href="#SEC8">COMPILATION ERROR CODES</a>
+<li><a name="TOC9" href="#SEC9">STUDYING A PATTERN</a>
+<li><a name="TOC10" href="#SEC10">LOCALE SUPPORT</a>
+<li><a name="TOC11" href="#SEC11">INFORMATION ABOUT A PATTERN</a>
+<li><a name="TOC12" href="#SEC12">OBSOLETE INFO FUNCTION</a>
+<li><a name="TOC13" href="#SEC13">REFERENCE COUNTS</a>
+<li><a name="TOC14" href="#SEC14">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a>
+<li><a name="TOC15" href="#SEC15">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a>
+<li><a name="TOC16" href="#SEC16">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a>
+<li><a name="TOC17" href="#SEC17">DUPLICATE SUBPATTERN NAMES</a>
+<li><a name="TOC18" href="#SEC18">FINDING ALL POSSIBLE MATCHES</a>
+<li><a name="TOC19" href="#SEC19">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a>
+<li><a name="TOC20" href="#SEC20">SEE ALSO</a>
+<li><a name="TOC21" href="#SEC21">AUTHOR</a>
+<li><a name="TOC22" href="#SEC22">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE NATIVE API</a><br>
+<P>
+<b>#include &#60;pcre.h&#62;</b>
+</P>
+<P>
+<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<P>
+<b>pcre *pcre_compile2(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>int *<i>errorcodeptr</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<P>
+<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>);</b>
+</P>
+<P>
+<b>int pcre_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
+</P>
+<P>
+<b>int pcre_dfa_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>,</b>
+<b>int *<i>workspace</i>, int <i>wscount</i>);</b>
+</P>
+<P>
+<b>int pcre_copy_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>char *<i>buffer</i>, int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre_copy_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
+<b>int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre_get_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<P>
+<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>);</b>
+</P>
+<P>
+<b>int pcre_get_stringtable_entries(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>, char **<i>first</i>, char **<i>last</i>);</b>
+</P>
+<P>
+<b>int pcre_get_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<P>
+<b>int pcre_get_substring_list(const char *<i>subject</i>,</b>
+<b>int *<i>ovector</i>, int <i>stringcount</i>, const char ***<i>listptr</i>);</b>
+</P>
+<P>
+<b>void pcre_free_substring(const char *<i>stringptr</i>);</b>
+</P>
+<P>
+<b>void pcre_free_substring_list(const char **<i>stringptr</i>);</b>
+</P>
+<P>
+<b>const unsigned char *pcre_maketables(void);</b>
+</P>
+<P>
+<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
+<b>*<i>firstcharptr</i>);</b>
+</P>
+<P>
+<b>int pcre_refcount(pcre *<i>code</i>, int <i>adjust</i>);</b>
+</P>
+<P>
+<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+<b>char *pcre_version(void);</b>
+</P>
+<P>
+<b>void *(*pcre_malloc)(size_t);</b>
+</P>
+<P>
+<b>void (*pcre_free)(void *);</b>
+</P>
+<P>
+<b>void *(*pcre_stack_malloc)(size_t);</b>
+</P>
+<P>
+<b>void (*pcre_stack_free)(void *);</b>
+</P>
+<P>
+<b>int (*pcre_callout)(pcre_callout_block *);</b>
+</P>
+<br><a name="SEC2" href="#TOC1">PCRE API OVERVIEW</a><br>
+<P>
+PCRE has its own native API, which is described in this document. There are
+also some wrapper functions that correspond to the POSIX regular expression
+API. These are described in the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+documentation. Both of these APIs define a set of C function calls. A C++
+wrapper is distributed with PCRE. It is documented in the
+<a href="pcrecpp.html"><b>pcrecpp</b></a>
+page.
+</P>
+<P>
+The native API C function prototypes are defined in the header file
+<b>pcre.h</b>, and on Unix systems the library itself is called <b>libpcre</b>.
+It can normally be accessed by adding <b>-lpcre</b> to the command for linking
+an application that uses PCRE. The header file defines the macros PCRE_MAJOR
+and PCRE_MINOR to contain the major and minor release numbers for the library.
+Applications can use these to include support for different releases of PCRE.
+</P>
+<P>
+The functions <b>pcre_compile()</b>, <b>pcre_compile2()</b>, <b>pcre_study()</b>,
+and <b>pcre_exec()</b> are used for compiling and matching regular expressions
+in a Perl-compatible manner. A sample program that demonstrates the simplest
+way of using them is provided in the file called <i>pcredemo.c</i> in the source
+distribution. The
+<a href="pcresample.html"><b>pcresample</b></a>
+documentation describes how to compile and run it.
+</P>
+<P>
+A second matching function, <b>pcre_dfa_exec()</b>, which is not
+Perl-compatible, is also provided. This uses a different algorithm for the
+matching. The alternative algorithm finds all possible matches (at a given
+point in the subject), and scans the subject just once. However, this algorithm
+does not return captured substrings. A description of the two matching
+algorithms and their advantages and disadvantages is given in the
+<a href="pcrematching.html"><b>pcrematching</b></a>
+documentation.
+</P>
+<P>
+In addition to the main compiling and matching functions, there are convenience
+functions for extracting captured substrings from a subject string that is
+matched by <b>pcre_exec()</b>. They are:
+<pre>
+  <b>pcre_copy_substring()</b>
+  <b>pcre_copy_named_substring()</b>
+  <b>pcre_get_substring()</b>
+  <b>pcre_get_named_substring()</b>
+  <b>pcre_get_substring_list()</b>
+  <b>pcre_get_stringnumber()</b>
+  <b>pcre_get_stringtable_entries()</b>
+</pre>
+<b>pcre_free_substring()</b> and <b>pcre_free_substring_list()</b> are also
+provided, to free the memory used for extracted strings.
+</P>
+<P>
+The function <b>pcre_maketables()</b> is used to build a set of character tables
+in the current locale for passing to <b>pcre_compile()</b>, <b>pcre_exec()</b>,
+or <b>pcre_dfa_exec()</b>. This is an optional facility that is provided for
+specialist use. Most commonly, no special tables are passed, in which case
+internal tables that are generated when PCRE is built are used.
+</P>
+<P>
+The function <b>pcre_fullinfo()</b> is used to find out information about a
+compiled pattern; <b>pcre_info()</b> is an obsolete version that returns only
+some of the available information, but is retained for backwards compatibility.
+The function <b>pcre_version()</b> returns a pointer to a string containing the
+version of PCRE and its date of release.
+</P>
+<P>
+The function <b>pcre_refcount()</b> maintains a reference count in a data block
+containing a compiled pattern. This is provided for the benefit of
+object-oriented applications.
+</P>
+<P>
+The global variables <b>pcre_malloc</b> and <b>pcre_free</b> initially contain
+the entry points of the standard <b>malloc()</b> and <b>free()</b> functions,
+respectively. PCRE calls the memory management functions via these variables,
+so a calling program can replace them if it wishes to intercept the calls. This
+should be done before calling any PCRE functions.
+</P>
+<P>
+The global variables <b>pcre_stack_malloc</b> and <b>pcre_stack_free</b> are also
+indirections to memory management functions. These special functions are used
+only when PCRE is compiled to use the heap for remembering data, instead of
+recursive function calls, when running the <b>pcre_exec()</b> function. See the
+<a href="pcrebuild.html"><b>pcrebuild</b></a>
+documentation for details of how to do this. It is a non-standard way of
+building PCRE, for use in environments that have limited stacks. Because of the
+greater use of memory management, it runs more slowly. Separate functions are
+provided so that special-purpose external code can be used for this case. When
+used, these functions are always called in a stack-like manner (last obtained,
+first freed), and always for memory blocks of the same size. There is a
+discussion about PCRE's stack usage in the
+<a href="pcrestack.html"><b>pcrestack</b></a>
+documentation.
+</P>
+<P>
+The global variable <b>pcre_callout</b> initially contains NULL. It can be set
+by the caller to a "callout" function, which PCRE will then call at specified
+points during a matching operation. Details are given in the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation.
+<a name="newlines"></a></P>
+<br><a name="SEC3" href="#TOC1">NEWLINES</a><br>
+<P>
+PCRE supports five different conventions for indicating line breaks in
+strings: a single CR (carriage return) character, a single LF (linefeed)
+character, the two-character sequence CRLF, any of the three preceding, or any
+Unicode newline sequence. The Unicode newline sequences are the three just
+mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,
+U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
+(paragraph separator, U+2029).
+</P>
+<P>
+Each of the first three conventions is used by at least one operating system as
+its standard newline sequence. When PCRE is built, a default can be specified.
+The default default is LF, which is the Unix standard. When PCRE is run, the
+default can be overridden, either when a pattern is compiled, or when it is
+matched.
+</P>
+<P>
+At compile time, the newline convention can be specified by the <i>options</i>
+argument of <b>pcre_compile()</b>, or it can be specified by special text at the
+start of the pattern itself; this overrides any other settings. See the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+page for details of the special character sequences.
+</P>
+<P>
+In the PCRE documentation the word "newline" is used to mean "the character or
+pair of characters that indicate a line break". The choice of newline
+convention affects the handling of the dot, circumflex, and dollar
+metacharacters, the handling of #-comments in /x mode, and, when CRLF is a
+recognized line ending sequence, the match position advancement for a
+non-anchored pattern. There is more detail about this in the
+<a href="#execoptions">section on <b>pcre_exec()</b> options</a>
+below.
+</P>
+<P>
+The choice of newline convention does not affect the interpretation of
+the \n or \r escape sequences, nor does it affect what \R matches, which is
+controlled in a similar way, but by separate options.
+</P>
+<br><a name="SEC4" href="#TOC1">MULTITHREADING</a><br>
+<P>
+The PCRE functions can be used in multi-threading applications, with the
+proviso that the memory management functions pointed to by <b>pcre_malloc</b>,
+<b>pcre_free</b>, <b>pcre_stack_malloc</b>, and <b>pcre_stack_free</b>, and the
+callout function pointed to by <b>pcre_callout</b>, are shared by all threads.
+</P>
+<P>
+The compiled form of a regular expression is not altered during matching, so
+the same compiled pattern can safely be used by several threads at once.
+</P>
+<br><a name="SEC5" href="#TOC1">SAVING PRECOMPILED PATTERNS FOR LATER USE</a><br>
+<P>
+The compiled form of a regular expression can be saved and re-used at a later
+time, possibly by a different program, and even on a host other than the one on
+which it was compiled. Details are given in the
+<a href="pcreprecompile.html"><b>pcreprecompile</b></a>
+documentation. However, compiling a regular expression with one version of PCRE
+for use with a different version is not guaranteed to work and may cause
+crashes.
+</P>
+<br><a name="SEC6" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>
+<P>
+<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+The function <b>pcre_config()</b> makes it possible for a PCRE client to
+discover which optional features have been compiled into the PCRE library. The
+<a href="pcrebuild.html"><b>pcrebuild</b></a>
+documentation has more details about these optional features.
+</P>
+<P>
+The first argument for <b>pcre_config()</b> is an integer, specifying which
+information is required; the second argument is a pointer to a variable into
+which the information is placed. The following information is available:
+<pre>
+  PCRE_CONFIG_UTF8
+</pre>
+The output is an integer that is set to one if UTF-8 support is available;
+otherwise it is set to zero.
+<pre>
+  PCRE_CONFIG_UNICODE_PROPERTIES
+</pre>
+The output is an integer that is set to one if support for Unicode character
+properties is available; otherwise it is set to zero.
+<pre>
+  PCRE_CONFIG_NEWLINE
+</pre>
+The output is an integer whose value specifies the default character sequence
+that is recognized as meaning "newline". The four values that are supported
+are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF, and -1 for ANY. The
+default should normally be the standard sequence for your operating system.
+<pre>
+  PCRE_CONFIG_BSR
+</pre>
+The output is an integer whose value indicates what character sequences the \R
+escape sequence matches by default. A value of 0 means that \R matches any
+Unicode line ending sequence; a value of 1 means that \R matches only CR, LF,
+or CRLF. The default can be overridden when a pattern is compiled or matched.
+<pre>
+  PCRE_CONFIG_LINK_SIZE
+</pre>
+The output is an integer that contains the number of bytes used for internal
+linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values
+allow larger regular expressions to be compiled, at the expense of slower
+matching. The default value of 2 is sufficient for all but the most massive
+patterns, since it allows the compiled pattern to be up to 64K in size.
+<pre>
+  PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+</pre>
+The output is an integer that contains the threshold above which the POSIX
+interface uses <b>malloc()</b> for output vectors. Further details are given in
+the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+documentation.
+<pre>
+  PCRE_CONFIG_MATCH_LIMIT
+</pre>
+The output is an integer that gives the default limit for the number of
+internal matching function calls in a <b>pcre_exec()</b> execution. Further
+details are given with <b>pcre_exec()</b> below.
+<pre>
+  PCRE_CONFIG_MATCH_LIMIT_RECURSION
+</pre>
+The output is an integer that gives the default limit for the depth of
+recursion when calling the internal matching function in a <b>pcre_exec()</b>
+execution. Further details are given with <b>pcre_exec()</b> below.
+<pre>
+  PCRE_CONFIG_STACKRECURSE
+</pre>
+The output is an integer that is set to one if internal recursion when running
+<b>pcre_exec()</b> is implemented by recursive function calls that use the stack
+to remember their state. This is the usual way that PCRE is compiled. The
+output is zero if PCRE was compiled to use blocks of data on the heap instead
+of recursive function calls. In this case, <b>pcre_stack_malloc</b> and
+<b>pcre_stack_free</b> are called to manage memory blocks on the heap, thus
+avoiding the use of the stack.
+</P>
+<br><a name="SEC7" href="#TOC1">COMPILING A PATTERN</a><br>
+<P>
+<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+<b>pcre *pcre_compile2(const char *<i>pattern</i>, int <i>options</i>,</b>
+<b>int *<i>errorcodeptr</i>,</b>
+<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
+<b>const unsigned char *<i>tableptr</i>);</b>
+</P>
+<P>
+Either of the functions <b>pcre_compile()</b> or <b>pcre_compile2()</b> can be
+called to compile a pattern into an internal form. The only difference between
+the two interfaces is that <b>pcre_compile2()</b> has an additional argument,
+<i>errorcodeptr</i>, via which a numerical error code can be returned.
+</P>
+<P>
+The pattern is a C string terminated by a binary zero, and is passed in the
+<i>pattern</i> argument. A pointer to a single block of memory that is obtained
+via <b>pcre_malloc</b> is returned. This contains the compiled code and related
+data. The <b>pcre</b> type is defined for the returned block; this is a typedef
+for a structure whose contents are not externally defined. It is up to the
+caller to free the memory (via <b>pcre_free</b>) when it is no longer required.
+</P>
+<P>
+Although the compiled code of a PCRE regex is relocatable, that is, it does not
+depend on memory location, the complete <b>pcre</b> data block is not
+fully relocatable, because it may contain a copy of the <i>tableptr</i>
+argument, which is an address (see below).
+</P>
+<P>
+The <i>options</i> argument contains various bit settings that affect the
+compilation. It should be zero if no options are required. The available
+options are described below. Some of them, in particular, those that are
+compatible with Perl, can also be set and unset from within the pattern (see
+the detailed description in the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+documentation). For these options, the contents of the <i>options</i> argument
+specifies their initial settings at the start of compilation and execution. The
+PCRE_ANCHORED and PCRE_NEWLINE_<i>xxx</i> options can be set at the time of
+matching as well as at compile time.
+</P>
+<P>
+If <i>errptr</i> is NULL, <b>pcre_compile()</b> returns NULL immediately.
+Otherwise, if compilation of a pattern fails, <b>pcre_compile()</b> returns
+NULL, and sets the variable pointed to by <i>errptr</i> to point to a textual
+error message. This is a static string that is part of the library. You must
+not try to free it. The offset from the start of the pattern to the character
+where the error was discovered is placed in the variable pointed to by
+<i>erroffset</i>, which must not be NULL. If it is, an immediate error is given.
+</P>
+<P>
+If <b>pcre_compile2()</b> is used instead of <b>pcre_compile()</b>, and the
+<i>errorcodeptr</i> argument is not NULL, a non-zero error code number is
+returned via this argument in the event of an error. This is in addition to the
+textual error message. Error codes and messages are listed below.
+</P>
+<P>
+If the final argument, <i>tableptr</i>, is NULL, PCRE uses a default set of
+character tables that are built when PCRE is compiled, using the default C
+locale. Otherwise, <i>tableptr</i> must be an address that is the result of a
+call to <b>pcre_maketables()</b>. This value is stored with the compiled
+pattern, and used again by <b>pcre_exec()</b>, unless another table pointer is
+passed to it. For more discussion, see the section on locale support below.
+</P>
+<P>
+This code fragment shows a typical straightforward call to <b>pcre_compile()</b>:
+<pre>
+  pcre *re;
+  const char *error;
+  int erroffset;
+  re = pcre_compile(
+    "^A.*Z",          /* the pattern */
+    0,                /* default options */
+    &error,           /* for error message */
+    &erroffset,       /* for error offset */
+    NULL);            /* use default character tables */
+</pre>
+The following names for option bits are defined in the <b>pcre.h</b> header
+file:
+<pre>
+  PCRE_ANCHORED
+</pre>
+If this bit is set, the pattern is forced to be "anchored", that is, it is
+constrained to match only at the first matching point in the string that is
+being searched (the "subject string"). This effect can also be achieved by
+appropriate constructs in the pattern itself, which is the only way to do it in
+Perl.
+<pre>
+  PCRE_AUTO_CALLOUT
+</pre>
+If this bit is set, <b>pcre_compile()</b> automatically inserts callout items,
+all with number 255, before each pattern item. For discussion of the callout
+facility, see the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation.
+<pre>
+  PCRE_BSR_ANYCRLF
+  PCRE_BSR_UNICODE
+</pre>
+These options (which are mutually exclusive) control what the \R escape
+sequence matches. The choice is either to match only CR, LF, or CRLF, or to
+match any Unicode newline sequence. The default is specified when PCRE is
+built. It can be overridden from within the pattern, or by setting an option
+when a compiled pattern is matched.
+<pre>
+  PCRE_CASELESS
+</pre>
+If this bit is set, letters in the pattern match both upper and lower case
+letters. It is equivalent to Perl's /i option, and it can be changed within a
+pattern by a (?i) option setting. In UTF-8 mode, PCRE always understands the
+concept of case for characters whose values are less than 128, so caseless
+matching is always possible. For characters with higher values, the concept of
+case is supported if PCRE is compiled with Unicode property support, but not
+otherwise. If you want to use caseless matching for characters 128 and above,
+you must ensure that PCRE is compiled with Unicode property support as well as
+with UTF-8 support.
+<pre>
+  PCRE_DOLLAR_ENDONLY
+</pre>
+If this bit is set, a dollar metacharacter in the pattern matches only at the
+end of the subject string. Without this option, a dollar also matches
+immediately before a newline at the end of the string (but not before any other
+newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is set.
+There is no equivalent to this option in Perl, and no way to set it within a
+pattern.
+<pre>
+  PCRE_DOTALL
+</pre>
+If this bit is set, a dot metacharater in the pattern matches all characters,
+including those that indicate newline. Without it, a dot does not match when
+the current position is at a newline. This option is equivalent to Perl's /s
+option, and it can be changed within a pattern by a (?s) option setting. A
+negative class such as [^a] always matches newline characters, independent of
+the setting of this option.
+<pre>
+  PCRE_DUPNAMES
+</pre>
+If this bit is set, names used to identify capturing subpatterns need not be
+unique. This can be helpful for certain types of pattern when it is known that
+only one instance of the named subpattern can ever be matched. There are more
+details of named subpatterns below; see also the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+documentation.
+<pre>
+  PCRE_EXTENDED
+</pre>
+If this bit is set, whitespace data characters in the pattern are totally
+ignored except when escaped or inside a character class. Whitespace does not
+include the VT character (code 11). In addition, characters between an
+unescaped # outside a character class and the next newline, inclusive, are also
+ignored. This is equivalent to Perl's /x option, and it can be changed within a
+pattern by a (?x) option setting.
+</P>
+<P>
+This option makes it possible to include comments inside complicated patterns.
+Note, however, that this applies only to data characters. Whitespace characters
+may never appear within special character sequences in a pattern, for example
+within the sequence (?( which introduces a conditional subpattern.
+<pre>
+  PCRE_EXTRA
+</pre>
+This option was invented in order to turn on additional functionality of PCRE
+that is incompatible with Perl, but it is currently of very little use. When
+set, any backslash in a pattern that is followed by a letter that has no
+special meaning causes an error, thus reserving these combinations for future
+expansion. By default, as in Perl, a backslash followed by a letter with no
+special meaning is treated as a literal. (Perl can, however, be persuaded to
+give a warning for this.) There are at present no other features controlled by
+this option. It can also be set by a (?X) option setting within a pattern.
+<pre>
+  PCRE_FIRSTLINE
+</pre>
+If this option is set, an unanchored pattern is required to match before or at
+the first newline in the subject string, though the matched text may continue
+over the newline.
+<pre>
+  PCRE_JAVASCRIPT_COMPAT
+</pre>
+If this option is set, PCRE's behaviour is changed in some ways so that it is
+compatible with JavaScript rather than Perl. The changes are as follows:
+</P>
+<P>
+(1) A lone closing square bracket in a pattern causes a compile-time error,
+because this is illegal in JavaScript (by default it is treated as a data
+character). Thus, the pattern AB]CD becomes illegal when this option is set.
+</P>
+<P>
+(2) At run time, a back reference to an unset subpattern group matches an empty
+string (by default this causes the current matching alternative to fail). A
+pattern such as (\1)(a) succeeds when this option is set (assuming it can find
+an "a" in the subject), whereas it fails by default, for Perl compatibility.
+<pre>
+  PCRE_MULTILINE
+</pre>
+By default, PCRE treats the subject string as consisting of a single line of
+characters (even if it actually contains newlines). The "start of line"
+metacharacter (^) matches only at the start of the string, while the "end of
+line" metacharacter ($) matches only at the end of the string, or before a
+terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
+Perl.
+</P>
+<P>
+When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
+match immediately following or immediately before internal newlines in the
+subject string, respectively, as well as at the very start and end. This is
+equivalent to Perl's /m option, and it can be changed within a pattern by a
+(?m) option setting. If there are no newlines in a subject string, or no
+occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.
+<pre>
+  PCRE_NEWLINE_CR
+  PCRE_NEWLINE_LF
+  PCRE_NEWLINE_CRLF
+  PCRE_NEWLINE_ANYCRLF
+  PCRE_NEWLINE_ANY
+</pre>
+These options override the default newline definition that was chosen when PCRE
+was built. Setting the first or the second specifies that a newline is
+indicated by a single character (CR or LF, respectively). Setting
+PCRE_NEWLINE_CRLF specifies that a newline is indicated by the two-character
+CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies that any of the three
+preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
+that any Unicode newline sequence should be recognized. The Unicode newline
+sequences are the three just mentioned, plus the single characters VT (vertical
+tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
+separator, U+2028), and PS (paragraph separator, U+2029). The last two are
+recognized only in UTF-8 mode.
+</P>
+<P>
+The newline setting in the options word uses three bits that are treated
+as a number, giving eight possibilities. Currently only six are used (default
+plus the five values above). This means that if you set more than one newline
+option, the combination may or may not be sensible. For example,
+PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but
+other combinations may yield unused numbers and cause an error.
+</P>
+<P>
+The only time that a line break is specially recognized when compiling a
+pattern is if PCRE_EXTENDED is set, and an unescaped # outside a character
+class is encountered. This indicates a comment that lasts until after the next
+line break sequence. In other circumstances, line break sequences are treated
+as literal data, except that in PCRE_EXTENDED mode, both CR and LF are treated
+as whitespace characters and are therefore ignored.
+</P>
+<P>
+The newline option that is set at compile time becomes the default that is used
+for <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, but it can be overridden.
+<pre>
+  PCRE_NO_AUTO_CAPTURE
+</pre>
+If this option is set, it disables the use of numbered capturing parentheses in
+the pattern. Any opening parenthesis that is not followed by ? behaves as if it
+were followed by ?: but named parentheses can still be used for capturing (and
+they acquire numbers in the usual way). There is no equivalent of this option
+in Perl.
+<pre>
+  PCRE_UNGREEDY
+</pre>
+This option inverts the "greediness" of the quantifiers so that they are not
+greedy by default, but become greedy if followed by "?". It is not compatible
+with Perl. It can also be set by a (?U) option setting within the pattern.
+<pre>
+  PCRE_UTF8
+</pre>
+This option causes PCRE to regard both the pattern and the subject as strings
+of UTF-8 characters instead of single-byte character strings. However, it is
+available only when PCRE is built to include UTF-8 support. If not, the use
+of this option provokes an error. Details of how this option changes the
+behaviour of PCRE are given in the
+<a href="pcre.html#utf8support">section on UTF-8 support</a>
+in the main
+<a href="pcre.html"><b>pcre</b></a>
+page.
+<pre>
+  PCRE_NO_UTF8_CHECK
+</pre>
+When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
+automatically checked. There is a discussion about the
+<a href="pcre.html#utf8strings">validity of UTF-8 strings</a>
+in the main
+<a href="pcre.html"><b>pcre</b></a>
+page. If an invalid UTF-8 sequence of bytes is found, <b>pcre_compile()</b>
+returns an error. If you already know that your pattern is valid, and you want
+to skip this check for performance reasons, you can set the PCRE_NO_UTF8_CHECK
+option. When it is set, the effect of passing an invalid UTF-8 string as a
+pattern is undefined. It may cause your program to crash. Note that this option
+can also be passed to <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, to suppress
+the UTF-8 validity checking of subject strings.
+</P>
+<br><a name="SEC8" href="#TOC1">COMPILATION ERROR CODES</a><br>
+<P>
+The following table lists the error codes than may be returned by
+<b>pcre_compile2()</b>, along with the error messages that may be returned by
+both compiling functions. As PCRE has developed, some error codes have fallen
+out of use. To avoid confusion, they have not been re-used.
+<pre>
+   0  no error
+   1  \ at end of pattern
+   2  \c at end of pattern
+   3  unrecognized character follows \
+   4  numbers out of order in {} quantifier
+   5  number too big in {} quantifier
+   6  missing terminating ] for character class
+   7  invalid escape sequence in character class
+   8  range out of order in character class
+   9  nothing to repeat
+  10  [this code is not in use]
+  11  internal error: unexpected repeat
+  12  unrecognized character after (? or (?-
+  13  POSIX named classes are supported only within a class
+  14  missing )
+  15  reference to non-existent subpattern
+  16  erroffset passed as NULL
+  17  unknown option bit(s) set
+  18  missing ) after comment
+  19  [this code is not in use]
+  20  regular expression is too large
+  21  failed to get memory
+  22  unmatched parentheses
+  23  internal error: code overflow
+  24  unrecognized character after (?&#60;
+  25  lookbehind assertion is not fixed length
+  26  malformed number or name after (?(
+  27  conditional group contains more than two branches
+  28  assertion expected after (?(
+  29  (?R or (?[+-]digits must be followed by )
+  30  unknown POSIX class name
+  31  POSIX collating elements are not supported
+  32  this version of PCRE is not compiled with PCRE_UTF8 support
+  33  [this code is not in use]
+  34  character value in \x{...} sequence is too large
+  35  invalid condition (?(0)
+  36  \C not allowed in lookbehind assertion
+  37  PCRE does not support \L, \l, \N, \U, or \u
+  38  number after (?C is &#62; 255
+  39  closing ) for (?C expected
+  40  recursive call could loop indefinitely
+  41  unrecognized character after (?P
+  42  syntax error in subpattern name (missing terminator)
+  43  two named subpatterns have the same name
+  44  invalid UTF-8 string
+  45  support for \P, \p, and \X has not been compiled
+  46  malformed \P or \p sequence
+  47  unknown property name after \P or \p
+  48  subpattern name is too long (maximum 32 characters)
+  49  too many named subpatterns (maximum 10000)
+  50  [this code is not in use]
+  51  octal value is greater than \377 (not in UTF-8 mode)
+  52  internal error: overran compiling workspace
+  53  internal error: previously-checked referenced subpattern not found
+  54  DEFINE group contains more than one branch
+  55  repeating a DEFINE group is not allowed
+  56  inconsistent NEWLINE options
+  57  \g is not followed by a braced, angle-bracketed, or quoted
+        name/number or by a plain number
+  58  a numbered reference must not be zero
+  59  (*VERB) with an argument is not supported
+  60  (*VERB) not recognized
+  61  number is too big
+  62  subpattern name expected
+  63  digit expected after (?+
+  64  ] is an invalid data character in JavaScript compatibility mode
+</pre>
+The numbers 32 and 10000 in errors 48 and 49 are defaults; different values may
+be used if the limits were changed when PCRE was built.
+</P>
+<br><a name="SEC9" href="#TOC1">STUDYING A PATTERN</a><br>
+<P>
+<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i></b>
+<b>const char **<i>errptr</i>);</b>
+</P>
+<P>
+If a compiled pattern is going to be used several times, it is worth spending
+more time analyzing it in order to speed up the time taken for matching. The
+function <b>pcre_study()</b> takes a pointer to a compiled pattern as its first
+argument. If studying the pattern produces additional information that will
+help speed up matching, <b>pcre_study()</b> returns a pointer to a
+<b>pcre_extra</b> block, in which the <i>study_data</i> field points to the
+results of the study.
+</P>
+<P>
+The returned value from <b>pcre_study()</b> can be passed directly to
+<b>pcre_exec()</b>. However, a <b>pcre_extra</b> block also contains other
+fields that can be set by the caller before the block is passed; these are
+described
+<a href="#extradata">below</a>
+in the section on matching a pattern.
+</P>
+<P>
+If studying the pattern does not produce any additional information
+<b>pcre_study()</b> returns NULL. In that circumstance, if the calling program
+wants to pass any of the other fields to <b>pcre_exec()</b>, it must set up its
+own <b>pcre_extra</b> block.
+</P>
+<P>
+The second argument of <b>pcre_study()</b> contains option bits. At present, no
+options are defined, and this argument should always be zero.
+</P>
+<P>
+The third argument for <b>pcre_study()</b> is a pointer for an error message. If
+studying succeeds (even if no data is returned), the variable it points to is
+set to NULL. Otherwise it is set to point to a textual error message. This is a
+static string that is part of the library. You must not try to free it. You
+should test the error pointer for NULL after calling <b>pcre_study()</b>, to be
+sure that it has run successfully.
+</P>
+<P>
+This is a typical call to <b>pcre_study</b>():
+<pre>
+  pcre_extra *pe;
+  pe = pcre_study(
+    re,             /* result of pcre_compile() */
+    0,              /* no options exist */
+    &error);        /* set to NULL or points to a message */
+</pre>
+At present, studying a pattern is useful only for non-anchored patterns that do
+not have a single fixed starting character. A bitmap of possible starting
+bytes is created.
+<a name="localesupport"></a></P>
+<br><a name="SEC10" href="#TOC1">LOCALE SUPPORT</a><br>
+<P>
+PCRE handles caseless matching, and determines whether characters are letters,
+digits, or whatever, by reference to a set of tables, indexed by character
+value. When running in UTF-8 mode, this applies only to characters with codes
+less than 128. Higher-valued codes never match escapes such as \w or \d, but
+can be tested with \p if PCRE is built with Unicode character property
+support. The use of locales with Unicode is discouraged. If you are handling
+characters with codes greater than 128, you should either use UTF-8 and
+Unicode, or use locales, but not try to mix the two.
+</P>
+<P>
+PCRE contains an internal set of tables that are used when the final argument
+of <b>pcre_compile()</b> is NULL. These are sufficient for many applications.
+Normally, the internal tables recognize only ASCII characters. However, when
+PCRE is built, it is possible to cause the internal tables to be rebuilt in the
+default "C" locale of the local system, which may cause them to be different.
+</P>
+<P>
+The internal tables can always be overridden by tables supplied by the
+application that calls PCRE. These may be created in a different locale from
+the default. As more and more applications change to using Unicode, the need
+for this locale support is expected to die away.
+</P>
+<P>
+External tables are built by calling the <b>pcre_maketables()</b> function,
+which has no arguments, in the relevant locale. The result can then be passed
+to <b>pcre_compile()</b> or <b>pcre_exec()</b> as often as necessary. For
+example, to build and use tables that are appropriate for the French locale
+(where accented characters with values greater than 128 are treated as letters),
+the following code could be used:
+<pre>
+  setlocale(LC_CTYPE, "fr_FR");
+  tables = pcre_maketables();
+  re = pcre_compile(..., tables);
+</pre>
+The locale name "fr_FR" is used on Linux and other Unix-like systems; if you
+are using Windows, the name for the French locale is "french".
+</P>
+<P>
+When <b>pcre_maketables()</b> runs, the tables are built in memory that is
+obtained via <b>pcre_malloc</b>. It is the caller's responsibility to ensure
+that the memory containing the tables remains available for as long as it is
+needed.
+</P>
+<P>
+The pointer that is passed to <b>pcre_compile()</b> is saved with the compiled
+pattern, and the same tables are used via this pointer by <b>pcre_study()</b>
+and normally also by <b>pcre_exec()</b>. Thus, by default, for any single
+pattern, compilation, studying and matching all happen in the same locale, but
+different patterns can be compiled in different locales.
+</P>
+<P>
+It is possible to pass a table pointer or NULL (indicating the use of the
+internal tables) to <b>pcre_exec()</b>. Although not intended for this purpose,
+this facility could be used to match a pattern in a different locale from the
+one in which it was compiled. Passing table pointers at run time is discussed
+below in the section on matching a pattern.
+</P>
+<br><a name="SEC11" href="#TOC1">INFORMATION ABOUT A PATTERN</a><br>
+<P>
+<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>int <i>what</i>, void *<i>where</i>);</b>
+</P>
+<P>
+The <b>pcre_fullinfo()</b> function returns information about a compiled
+pattern. It replaces the obsolete <b>pcre_info()</b> function, which is
+nevertheless retained for backwards compability (and is documented below).
+</P>
+<P>
+The first argument for <b>pcre_fullinfo()</b> is a pointer to the compiled
+pattern. The second argument is the result of <b>pcre_study()</b>, or NULL if
+the pattern was not studied. The third argument specifies which piece of
+information is required, and the fourth argument is a pointer to a variable
+to receive the data. The yield of the function is zero for success, or one of
+the following negative numbers:
+<pre>
+  PCRE_ERROR_NULL       the argument <i>code</i> was NULL
+                        the argument <i>where</i> was NULL
+  PCRE_ERROR_BADMAGIC   the "magic number" was not found
+  PCRE_ERROR_BADOPTION  the value of <i>what</i> was invalid
+</pre>
+The "magic number" is placed at the start of each compiled pattern as an simple
+check against passing an arbitrary memory pointer. Here is a typical call of
+<b>pcre_fullinfo()</b>, to obtain the length of the compiled pattern:
+<pre>
+  int rc;
+  size_t length;
+  rc = pcre_fullinfo(
+    re,               /* result of pcre_compile() */
+    pe,               /* result of pcre_study(), or NULL */
+    PCRE_INFO_SIZE,   /* what is required */
+    &length);         /* where to put the data */
+</pre>
+The possible values for the third argument are defined in <b>pcre.h</b>, and are
+as follows:
+<pre>
+  PCRE_INFO_BACKREFMAX
+</pre>
+Return the number of the highest back reference in the pattern. The fourth
+argument should point to an <b>int</b> variable. Zero is returned if there are
+no back references.
+<pre>
+  PCRE_INFO_CAPTURECOUNT
+</pre>
+Return the number of capturing subpatterns in the pattern. The fourth argument
+should point to an <b>int</b> variable.
+<pre>
+  PCRE_INFO_DEFAULT_TABLES
+</pre>
+Return a pointer to the internal default character tables within PCRE. The
+fourth argument should point to an <b>unsigned char *</b> variable. This
+information call is provided for internal use by the <b>pcre_study()</b>
+function. External callers can cause PCRE to use its internal tables by passing
+a NULL table pointer.
+<pre>
+  PCRE_INFO_FIRSTBYTE
+</pre>
+Return information about the first byte of any matched string, for a
+non-anchored pattern. The fourth argument should point to an <b>int</b>
+variable. (This option used to be called PCRE_INFO_FIRSTCHAR; the old name is
+still recognized for backwards compatibility.)
+</P>
+<P>
+If there is a fixed first byte, for example, from a pattern such as
+(cat|cow|coyote), its value is returned. Otherwise, if either
+<br>
+<br>
+(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
+starts with "^", or
+<br>
+<br>
+(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
+(if it were set, the pattern would be anchored),
+<br>
+<br>
+-1 is returned, indicating that the pattern matches only at the start of a
+subject string or after any newline within the string. Otherwise -2 is
+returned. For anchored patterns, -2 is returned.
+<pre>
+  PCRE_INFO_FIRSTTABLE
+</pre>
+If the pattern was studied, and this resulted in the construction of a 256-bit
+table indicating a fixed set of bytes for the first byte in any matching
+string, a pointer to the table is returned. Otherwise NULL is returned. The
+fourth argument should point to an <b>unsigned char *</b> variable.
+<pre>
+  PCRE_INFO_HASCRORLF
+</pre>
+Return 1 if the pattern contains any explicit matches for CR or LF characters,
+otherwise 0. The fourth argument should point to an <b>int</b> variable. An
+explicit match is either a literal CR or LF character, or \r or \n.
+<pre>
+  PCRE_INFO_JCHANGED
+</pre>
+Return 1 if the (?J) or (?-J) option setting is used in the pattern, otherwise
+0. The fourth argument should point to an <b>int</b> variable. (?J) and
+(?-J) set and unset the local PCRE_DUPNAMES option, respectively.
+<pre>
+  PCRE_INFO_LASTLITERAL
+</pre>
+Return the value of the rightmost literal byte that must exist in any matched
+string, other than at its start, if such a byte has been recorded. The fourth
+argument should point to an <b>int</b> variable. If there is no such byte, -1 is
+returned. For anchored patterns, a last literal byte is recorded only if it
+follows something of variable length. For example, for the pattern
+/^a\d+z\d+/ the returned value is "z", but for /^a\dz\d/ the returned value
+is -1.
+<pre>
+  PCRE_INFO_NAMECOUNT
+  PCRE_INFO_NAMEENTRYSIZE
+  PCRE_INFO_NAMETABLE
+</pre>
+PCRE supports the use of named as well as numbered capturing parentheses. The
+names are just an additional way of identifying the parentheses, which still
+acquire numbers. Several convenience functions such as
+<b>pcre_get_named_substring()</b> are provided for extracting captured
+substrings by name. It is also possible to extract the data directly, by first
+converting the name to a number in order to access the correct pointers in the
+output vector (described with <b>pcre_exec()</b> below). To do the conversion,
+you need to use the name-to-number map, which is described by these three
+values.
+</P>
+<P>
+The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives
+the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each
+entry; both of these return an <b>int</b> value. The entry size depends on the
+length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first
+entry of the table (a pointer to <b>char</b>). The first two bytes of each entry
+are the number of the capturing parenthesis, most significant byte first. The
+rest of the entry is the corresponding name, zero terminated. The names are in
+alphabetical order. When PCRE_DUPNAMES is set, duplicate names are in order of
+their parentheses numbers. For example, consider the following pattern (assume
+PCRE_EXTENDED is set, so white space - including newlines - is ignored):
+<pre>
+  (?&#60;date&#62; (?&#60;year&#62;(\d\d)?\d\d) - (?&#60;month&#62;\d\d) - (?&#60;day&#62;\d\d) )
+</pre>
+There are four named subpatterns, so the table has four entries, and each entry
+in the table is eight bytes long. The table is as follows, with non-printing
+bytes shows in hexadecimal, and undefined bytes shown as ??:
+<pre>
+  00 01 d  a  t  e  00 ??
+  00 05 d  a  y  00 ?? ??
+  00 04 m  o  n  t  h  00
+  00 02 y  e  a  r  00 ??
+</pre>
+When writing code to extract data from named subpatterns using the
+name-to-number map, remember that the length of the entries is likely to be
+different for each compiled pattern.
+<pre>
+  PCRE_INFO_OKPARTIAL
+</pre>
+Return 1 if the pattern can be used for partial matching, otherwise 0. The
+fourth argument should point to an <b>int</b> variable. The
+<a href="pcrepartial.html"><b>pcrepartial</b></a>
+documentation lists the restrictions that apply to patterns when partial
+matching is used.
+<pre>
+  PCRE_INFO_OPTIONS
+</pre>
+Return a copy of the options with which the pattern was compiled. The fourth
+argument should point to an <b>unsigned long int</b> variable. These option bits
+are those specified in the call to <b>pcre_compile()</b>, modified by any
+top-level option settings at the start of the pattern itself. In other words,
+they are the options that will be in force when matching starts. For example,
+if the pattern /(?im)abc(?-i)d/ is compiled with the PCRE_EXTENDED option, the
+result is PCRE_CASELESS, PCRE_MULTILINE, and PCRE_EXTENDED.
+</P>
+<P>
+A pattern is automatically anchored by PCRE if all of its top-level
+alternatives begin with one of the following:
+<pre>
+  ^     unless PCRE_MULTILINE is set
+  \A    always
+  \G    always
+  .*    if PCRE_DOTALL is set and there are no back references to the subpattern in which .* appears
+</pre>
+For such patterns, the PCRE_ANCHORED bit is set in the options returned by
+<b>pcre_fullinfo()</b>.
+<pre>
+  PCRE_INFO_SIZE
+</pre>
+Return the size of the compiled pattern, that is, the value that was passed as
+the argument to <b>pcre_malloc()</b> when PCRE was getting memory in which to
+place the compiled data. The fourth argument should point to a <b>size_t</b>
+variable.
+<pre>
+  PCRE_INFO_STUDYSIZE
+</pre>
+Return the size of the data block pointed to by the <i>study_data</i> field in
+a <b>pcre_extra</b> block. That is, it is the value that was passed to
+<b>pcre_malloc()</b> when PCRE was getting memory into which to place the data
+created by <b>pcre_study()</b>. The fourth argument should point to a
+<b>size_t</b> variable.
+</P>
+<br><a name="SEC12" href="#TOC1">OBSOLETE INFO FUNCTION</a><br>
+<P>
+<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
+<b>*<i>firstcharptr</i>);</b>
+</P>
+<P>
+The <b>pcre_info()</b> function is now obsolete because its interface is too
+restrictive to return all the available data about a compiled pattern. New
+programs should use <b>pcre_fullinfo()</b> instead. The yield of
+<b>pcre_info()</b> is the number of capturing subpatterns, or one of the
+following negative numbers:
+<pre>
+  PCRE_ERROR_NULL       the argument <i>code</i> was NULL
+  PCRE_ERROR_BADMAGIC   the "magic number" was not found
+</pre>
+If the <i>optptr</i> argument is not NULL, a copy of the options with which the
+pattern was compiled is placed in the integer it points to (see
+PCRE_INFO_OPTIONS above).
+</P>
+<P>
+If the pattern is not anchored and the <i>firstcharptr</i> argument is not NULL,
+it is used to pass back information about the first character of any matched
+string (see PCRE_INFO_FIRSTBYTE above).
+</P>
+<br><a name="SEC13" href="#TOC1">REFERENCE COUNTS</a><br>
+<P>
+<b>int pcre_refcount(pcre *<i>code</i>, int <i>adjust</i>);</b>
+</P>
+<P>
+The <b>pcre_refcount()</b> function is used to maintain a reference count in the
+data block that contains a compiled pattern. It is provided for the benefit of
+applications that operate in an object-oriented manner, where different parts
+of the application may be using the same compiled pattern, but you want to free
+the block when they are all done.
+</P>
+<P>
+When a pattern is compiled, the reference count field is initialized to zero.
+It is changed only by calling this function, whose action is to add the
+<i>adjust</i> value (which may be positive or negative) to it. The yield of the
+function is the new value. However, the value of the count is constrained to
+lie between 0 and 65535, inclusive. If the new value is outside these limits,
+it is forced to the appropriate limit value.
+</P>
+<P>
+Except when it is zero, the reference count is not correctly preserved if a
+pattern is compiled on one host and then transferred to a host whose byte-order
+is different. (This seems a highly unlikely scenario.)
+</P>
+<br><a name="SEC14" href="#TOC1">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a><br>
+<P>
+<b>int pcre_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
+</P>
+<P>
+The function <b>pcre_exec()</b> is called to match a subject string against a
+compiled pattern, which is passed in the <i>code</i> argument. If the
+pattern has been studied, the result of the study should be passed in the
+<i>extra</i> argument. This function is the main matching facility of the
+library, and it operates in a Perl-like manner. For specialist use there is
+also an alternative matching function, which is described
+<a href="#dfamatch">below</a>
+in the section about the <b>pcre_dfa_exec()</b> function.
+</P>
+<P>
+In most applications, the pattern will have been compiled (and optionally
+studied) in the same process that calls <b>pcre_exec()</b>. However, it is
+possible to save compiled patterns and study data, and then use them later
+in different processes, possibly even on different hosts. For a discussion
+about this, see the
+<a href="pcreprecompile.html"><b>pcreprecompile</b></a>
+documentation.
+</P>
+<P>
+Here is an example of a simple call to <b>pcre_exec()</b>:
+<pre>
+  int rc;
+  int ovector[30];
+  rc = pcre_exec(
+    re,             /* result of pcre_compile() */
+    NULL,           /* we didn't study the pattern */
+    "some string",  /* the subject string */
+    11,             /* the length of the subject string */
+    0,              /* start at offset 0 in the subject */
+    0,              /* default options */
+    ovector,        /* vector of integers for substring information */
+    30);            /* number of elements (NOT size in bytes) */
+<a name="extradata"></a></PRE>
+</P>
+<br><b>
+Extra data for <b>pcre_exec()</b>
+</b><br>
+<P>
+If the <i>extra</i> argument is not NULL, it must point to a <b>pcre_extra</b>
+data block. The <b>pcre_study()</b> function returns such a block (when it
+doesn't return NULL), but you can also create one for yourself, and pass
+additional information in it. The <b>pcre_extra</b> block contains the following
+fields (not necessarily in this order):
+<pre>
+  unsigned long int <i>flags</i>;
+  void *<i>study_data</i>;
+  unsigned long int <i>match_limit</i>;
+  unsigned long int <i>match_limit_recursion</i>;
+  void *<i>callout_data</i>;
+  const unsigned char *<i>tables</i>;
+</pre>
+The <i>flags</i> field is a bitmap that specifies which of the other fields
+are set. The flag bits are:
+<pre>
+  PCRE_EXTRA_STUDY_DATA
+  PCRE_EXTRA_MATCH_LIMIT
+  PCRE_EXTRA_MATCH_LIMIT_RECURSION
+  PCRE_EXTRA_CALLOUT_DATA
+  PCRE_EXTRA_TABLES
+</pre>
+Other flag bits should be set to zero. The <i>study_data</i> field is set in the
+<b>pcre_extra</b> block that is returned by <b>pcre_study()</b>, together with
+the appropriate flag bit. You should not set this yourself, but you may add to
+the block by setting the other fields and their corresponding flag bits.
+</P>
+<P>
+The <i>match_limit</i> field provides a means of preventing PCRE from using up a
+vast amount of resources when running patterns that are not going to match,
+but which have a very large number of possibilities in their search trees. The
+classic example is the use of nested unlimited repeats.
+</P>
+<P>
+Internally, PCRE uses a function called <b>match()</b> which it calls repeatedly
+(sometimes recursively). The limit set by <i>match_limit</i> is imposed on the
+number of times this function is called during a match, which has the effect of
+limiting the amount of backtracking that can take place. For patterns that are
+not anchored, the count restarts from zero for each position in the subject
+string.
+</P>
+<P>
+The default value for the limit can be set when PCRE is built; the default
+default is 10 million, which handles all but the most extreme cases. You can
+override the default by suppling <b>pcre_exec()</b> with a <b>pcre_extra</b>
+block in which <i>match_limit</i> is set, and PCRE_EXTRA_MATCH_LIMIT is set in
+the <i>flags</i> field. If the limit is exceeded, <b>pcre_exec()</b> returns
+PCRE_ERROR_MATCHLIMIT.
+</P>
+<P>
+The <i>match_limit_recursion</i> field is similar to <i>match_limit</i>, but
+instead of limiting the total number of times that <b>match()</b> is called, it
+limits the depth of recursion. The recursion depth is a smaller number than the
+total number of calls, because not all calls to <b>match()</b> are recursive.
+This limit is of use only if it is set smaller than <i>match_limit</i>.
+</P>
+<P>
+Limiting the recursion depth limits the amount of stack that can be used, or,
+when PCRE has been compiled to use memory on the heap instead of the stack, the
+amount of heap memory that can be used.
+</P>
+<P>
+The default value for <i>match_limit_recursion</i> can be set when PCRE is
+built; the default default is the same value as the default for
+<i>match_limit</i>. You can override the default by suppling <b>pcre_exec()</b>
+with a <b>pcre_extra</b> block in which <i>match_limit_recursion</i> is set, and
+PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in the <i>flags</i> field. If the limit
+is exceeded, <b>pcre_exec()</b> returns PCRE_ERROR_RECURSIONLIMIT.
+</P>
+<P>
+The <i>pcre_callout</i> field is used in conjunction with the "callout" feature,
+which is described in the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation.
+</P>
+<P>
+The <i>tables</i> field is used to pass a character tables pointer to
+<b>pcre_exec()</b>; this overrides the value that is stored with the compiled
+pattern. A non-NULL value is stored with the compiled pattern only if custom
+tables were supplied to <b>pcre_compile()</b> via its <i>tableptr</i> argument.
+If NULL is passed to <b>pcre_exec()</b> using this mechanism, it forces PCRE's
+internal tables to be used. This facility is helpful when re-using patterns
+that have been saved after compiling with an external set of tables, because
+the external tables might be at a different address when <b>pcre_exec()</b> is
+called. See the
+<a href="pcreprecompile.html"><b>pcreprecompile</b></a>
+documentation for a discussion of saving compiled patterns for later use.
+<a name="execoptions"></a></P>
+<br><b>
+Option bits for <b>pcre_exec()</b>
+</b><br>
+<P>
+The unused bits of the <i>options</i> argument for <b>pcre_exec()</b> must be
+zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEWLINE_<i>xxx</i>,
+PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK and PCRE_PARTIAL.
+<pre>
+  PCRE_ANCHORED
+</pre>
+The PCRE_ANCHORED option limits <b>pcre_exec()</b> to matching at the first
+matching position. If a pattern was compiled with PCRE_ANCHORED, or turned out
+to be anchored by virtue of its contents, it cannot be made unachored at
+matching time.
+<pre>
+  PCRE_BSR_ANYCRLF
+  PCRE_BSR_UNICODE
+</pre>
+These options (which are mutually exclusive) control what the \R escape
+sequence matches. The choice is either to match only CR, LF, or CRLF, or to
+match any Unicode newline sequence. These options override the choice that was
+made or defaulted when the pattern was compiled.
+<pre>
+  PCRE_NEWLINE_CR
+  PCRE_NEWLINE_LF
+  PCRE_NEWLINE_CRLF
+  PCRE_NEWLINE_ANYCRLF
+  PCRE_NEWLINE_ANY
+</pre>
+These options override the newline definition that was chosen or defaulted when
+the pattern was compiled. For details, see the description of
+<b>pcre_compile()</b> above. During matching, the newline choice affects the
+behaviour of the dot, circumflex, and dollar metacharacters. It may also alter
+the way the match position is advanced after a match failure for an unanchored
+pattern.
+</P>
+<P>
+When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is set, and a
+match attempt for an unanchored pattern fails when the current position is at a
+CRLF sequence, and the pattern contains no explicit matches for CR or LF
+characters, the match position is advanced by two characters instead of one, in
+other words, to after the CRLF.
+</P>
+<P>
+The above rule is a compromise that makes the most common cases work as
+expected. For example, if the pattern is .+A (and the PCRE_DOTALL option is not
+set), it does not match the string "\r\nA" because, after failing at the
+start, it skips both the CR and the LF before retrying. However, the pattern
+[\r\n]A does match that string, because it contains an explicit CR or LF
+reference, and so advances only by one character after the first failure.
+</P>
+<P>
+An explicit match for CR of LF is either a literal appearance of one of those
+characters, or one of the \r or \n escape sequences. Implicit matches such as
+[^X] do not count, nor does \s (which includes CR and LF in the characters
+that it matches).
+</P>
+<P>
+Notwithstanding the above, anomalous effects may still occur when CRLF is a
+valid newline sequence and explicit \r or \n escapes appear in the pattern.
+<pre>
+  PCRE_NOTBOL
+</pre>
+This option specifies that first character of the subject string is not the
+beginning of a line, so the circumflex metacharacter should not match before
+it. Setting this without PCRE_MULTILINE (at compile time) causes circumflex
+never to match. This option affects only the behaviour of the circumflex
+metacharacter. It does not affect \A.
+<pre>
+  PCRE_NOTEOL
+</pre>
+This option specifies that the end of the subject string is not the end of a
+line, so the dollar metacharacter should not match it nor (except in multiline
+mode) a newline immediately before it. Setting this without PCRE_MULTILINE (at
+compile time) causes dollar never to match. This option affects only the
+behaviour of the dollar metacharacter. It does not affect \Z or \z.
+<pre>
+  PCRE_NOTEMPTY
+</pre>
+An empty string is not considered to be a valid match if this option is set. If
+there are alternatives in the pattern, they are tried. If all the alternatives
+match the empty string, the entire match fails. For example, if the pattern
+<pre>
+  a?b?
+</pre>
+is applied to a string not beginning with "a" or "b", it matches the empty
+string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
+valid, so PCRE searches further into the string for occurrences of "a" or "b".
+</P>
+<P>
+Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case
+of a pattern match of the empty string within its <b>split()</b> function, and
+when using the /g modifier. It is possible to emulate Perl's behaviour after
+matching a null string by first trying the match again at the same offset with
+PCRE_NOTEMPTY and PCRE_ANCHORED, and then if that fails by advancing the
+starting offset (see below) and trying an ordinary match again. There is some
+code that demonstrates how to do this in the <i>pcredemo.c</i> sample program.
+<pre>
+  PCRE_NO_UTF8_CHECK
+</pre>
+When PCRE_UTF8 is set at compile time, the validity of the subject as a UTF-8
+string is automatically checked when <b>pcre_exec()</b> is subsequently called.
+The value of <i>startoffset</i> is also checked to ensure that it points to the
+start of a UTF-8 character. There is a discussion about the validity of UTF-8
+strings in the
+<a href="pcre.html#utf8strings">section on UTF-8 support</a>
+in the main
+<a href="pcre.html"><b>pcre</b></a>
+page. If an invalid UTF-8 sequence of bytes is found, <b>pcre_exec()</b> returns
+the error PCRE_ERROR_BADUTF8. If <i>startoffset</i> contains an invalid value,
+PCRE_ERROR_BADUTF8_OFFSET is returned.
+</P>
+<P>
+If you already know that your subject is valid, and you want to skip these
+checks for performance reasons, you can set the PCRE_NO_UTF8_CHECK option when
+calling <b>pcre_exec()</b>. You might want to do this for the second and
+subsequent calls to <b>pcre_exec()</b> if you are making repeated calls to find
+all the matches in a single subject string. However, you should be sure that
+the value of <i>startoffset</i> points to the start of a UTF-8 character. When
+PCRE_NO_UTF8_CHECK is set, the effect of passing an invalid UTF-8 string as a
+subject, or a value of <i>startoffset</i> that does not point to the start of a
+UTF-8 character, is undefined. Your program may crash.
+<pre>
+  PCRE_PARTIAL
+</pre>
+This option turns on the partial matching feature. If the subject string fails
+to match the pattern, but at some point during the matching process the end of
+the subject was reached (that is, the subject partially matches the pattern and
+the failure to match occurred only because there were not enough subject
+characters), <b>pcre_exec()</b> returns PCRE_ERROR_PARTIAL instead of
+PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is used, there are restrictions on what
+may appear in the pattern. These are discussed in the
+<a href="pcrepartial.html"><b>pcrepartial</b></a>
+documentation.
+</P>
+<br><b>
+The string to be matched by <b>pcre_exec()</b>
+</b><br>
+<P>
+The subject string is passed to <b>pcre_exec()</b> as a pointer in
+<i>subject</i>, a length (in bytes) in <i>length</i>, and a starting byte offset
+in <i>startoffset</i>. In UTF-8 mode, the byte offset must point to the start of
+a UTF-8 character. Unlike the pattern string, the subject may contain binary
+zero bytes. When the starting offset is zero, the search for a match starts at
+the beginning of the subject, and this is by far the most common case.
+</P>
+<P>
+A non-zero starting offset is useful when searching for another match in the
+same subject by calling <b>pcre_exec()</b> again after a previous success.
+Setting <i>startoffset</i> differs from just passing over a shortened string and
+setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
+lookbehind. For example, consider the pattern
+<pre>
+  \Biss\B
+</pre>
+which finds occurrences of "iss" in the middle of words. (\B matches only if
+the current position in the subject is not a word boundary.) When applied to
+the string "Mississipi" the first call to <b>pcre_exec()</b> finds the first
+occurrence. If <b>pcre_exec()</b> is called again with just the remainder of the
+subject, namely "issipi", it does not match, because \B is always false at the
+start of the subject, which is deemed to be a word boundary. However, if
+<b>pcre_exec()</b> is passed the entire string again, but with <i>startoffset</i>
+set to 4, it finds the second occurrence of "iss" because it is able to look
+behind the starting point to discover that it is preceded by a letter.
+</P>
+<P>
+If a non-zero starting offset is passed when the pattern is anchored, one
+attempt to match at the given offset is made. This can only succeed if the
+pattern does not require the match to be at the start of the subject.
+</P>
+<br><b>
+How <b>pcre_exec()</b> returns captured substrings
+</b><br>
+<P>
+In general, a pattern matches a certain portion of the subject, and in
+addition, further substrings from the subject may be picked out by parts of the
+pattern. Following the usage in Jeffrey Friedl's book, this is called
+"capturing" in what follows, and the phrase "capturing subpattern" is used for
+a fragment of a pattern that picks out a substring. PCRE supports several other
+kinds of parenthesized subpattern that do not cause substrings to be captured.
+</P>
+<P>
+Captured substrings are returned to the caller via a vector of integers whose
+address is passed in <i>ovector</i>. The number of elements in the vector is
+passed in <i>ovecsize</i>, which must be a non-negative number. <b>Note</b>: this
+argument is NOT the size of <i>ovector</i> in bytes.
+</P>
+<P>
+The first two-thirds of the vector is used to pass back captured substrings,
+each substring using a pair of integers. The remaining third of the vector is
+used as workspace by <b>pcre_exec()</b> while matching capturing subpatterns,
+and is not available for passing back information. The number passed in
+<i>ovecsize</i> should always be a multiple of three. If it is not, it is
+rounded down.
+</P>
+<P>
+When a match is successful, information about captured substrings is returned
+in pairs of integers, starting at the beginning of <i>ovector</i>, and
+continuing up to two-thirds of its length at the most. The first element of
+each pair is set to the byte offset of the first character in a substring, and
+the second is set to the byte offset of the first character after the end of a
+substring. <b>Note</b>: these values are always byte offsets, even in UTF-8
+mode. They are not character counts.
+</P>
+<P>
+The first pair of integers, <i>ovector[0]</i> and <i>ovector[1]</i>, identify the
+portion of the subject string matched by the entire pattern. The next pair is
+used for the first capturing subpattern, and so on. The value returned by
+<b>pcre_exec()</b> is one more than the highest numbered pair that has been set.
+For example, if two substrings have been captured, the returned value is 3. If
+there are no capturing subpatterns, the return value from a successful match is
+1, indicating that just the first pair of offsets has been set.
+</P>
+<P>
+If a capturing subpattern is matched repeatedly, it is the last portion of the
+string that it matched that is returned.
+</P>
+<P>
+If the vector is too small to hold all the captured substring offsets, it is
+used as far as possible (up to two-thirds of its length), and the function
+returns a value of zero. If the substring offsets are not of interest,
+<b>pcre_exec()</b> may be called with <i>ovector</i> passed as NULL and
+<i>ovecsize</i> as zero. However, if the pattern contains back references and
+the <i>ovector</i> is not big enough to remember the related substrings, PCRE
+has to get additional memory for use during matching. Thus it is usually
+advisable to supply an <i>ovector</i>.
+</P>
+<P>
+The <b>pcre_info()</b> function can be used to find out how many capturing
+subpatterns there are in a compiled pattern. The smallest size for
+<i>ovector</i> that will allow for <i>n</i> captured substrings, in addition to
+the offsets of the substring matched by the whole pattern, is (<i>n</i>+1)*3.
+</P>
+<P>
+It is possible for capturing subpattern number <i>n+1</i> to match some part of
+the subject when subpattern <i>n</i> has not been used at all. For example, if
+the string "abc" is matched against the pattern (a|(z))(bc) the return from the
+function is 4, and subpatterns 1 and 3 are matched, but 2 is not. When this
+happens, both values in the offset pairs corresponding to unused subpatterns
+are set to -1.
+</P>
+<P>
+Offset values that correspond to unused subpatterns at the end of the
+expression are also set to -1. For example, if the string "abc" is matched
+against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not matched. The
+return from the function is 2, because the highest used capturing subpattern
+number is 1. However, you can refer to the offsets for the second and third
+capturing subpatterns if you wish (assuming the vector is large enough, of
+course).
+</P>
+<P>
+Some convenience functions are provided for extracting the captured substrings
+as separate strings. These are described below.
+<a name="errorlist"></a></P>
+<br><b>
+Error return values from <b>pcre_exec()</b>
+</b><br>
+<P>
+If <b>pcre_exec()</b> fails, it returns a negative number. The following are
+defined in the header file:
+<pre>
+  PCRE_ERROR_NOMATCH        (-1)
+</pre>
+The subject string did not match the pattern.
+<pre>
+  PCRE_ERROR_NULL           (-2)
+</pre>
+Either <i>code</i> or <i>subject</i> was passed as NULL, or <i>ovector</i> was
+NULL and <i>ovecsize</i> was not zero.
+<pre>
+  PCRE_ERROR_BADOPTION      (-3)
+</pre>
+An unrecognized bit was set in the <i>options</i> argument.
+<pre>
+  PCRE_ERROR_BADMAGIC       (-4)
+</pre>
+PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
+the case when it is passed a junk pointer and to detect when a pattern that was
+compiled in an environment of one endianness is run in an environment with the
+other endianness. This is the error that PCRE gives when the magic number is
+not present.
+<pre>
+  PCRE_ERROR_UNKNOWN_OPCODE (-5)
+</pre>
+While running the pattern match, an unknown item was encountered in the
+compiled pattern. This error could be caused by a bug in PCRE or by overwriting
+of the compiled pattern.
+<pre>
+  PCRE_ERROR_NOMEMORY       (-6)
+</pre>
+If a pattern contains back references, but the <i>ovector</i> that is passed to
+<b>pcre_exec()</b> is not big enough to remember the referenced substrings, PCRE
+gets a block of memory at the start of matching to use for this purpose. If the
+call via <b>pcre_malloc()</b> fails, this error is given. The memory is
+automatically freed at the end of matching.
+<pre>
+  PCRE_ERROR_NOSUBSTRING    (-7)
+</pre>
+This error is used by the <b>pcre_copy_substring()</b>,
+<b>pcre_get_substring()</b>, and <b>pcre_get_substring_list()</b> functions (see
+below). It is never returned by <b>pcre_exec()</b>.
+<pre>
+  PCRE_ERROR_MATCHLIMIT     (-8)
+</pre>
+The backtracking limit, as specified by the <i>match_limit</i> field in a
+<b>pcre_extra</b> structure (or defaulted) was reached. See the description
+above.
+<pre>
+  PCRE_ERROR_CALLOUT        (-9)
+</pre>
+This error is never generated by <b>pcre_exec()</b> itself. It is provided for
+use by callout functions that want to yield a distinctive error code. See the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation for details.
+<pre>
+  PCRE_ERROR_BADUTF8        (-10)
+</pre>
+A string that contains an invalid UTF-8 byte sequence was passed as a subject.
+<pre>
+  PCRE_ERROR_BADUTF8_OFFSET (-11)
+</pre>
+The UTF-8 byte sequence that was passed as a subject was valid, but the value
+of <i>startoffset</i> did not point to the beginning of a UTF-8 character.
+<pre>
+  PCRE_ERROR_PARTIAL        (-12)
+</pre>
+The subject string did not match, but it did match partially. See the
+<a href="pcrepartial.html"><b>pcrepartial</b></a>
+documentation for details of partial matching.
+<pre>
+  PCRE_ERROR_BADPARTIAL     (-13)
+</pre>
+The PCRE_PARTIAL option was used with a compiled pattern containing items that
+are not supported for partial matching. See the
+<a href="pcrepartial.html"><b>pcrepartial</b></a>
+documentation for details of partial matching.
+<pre>
+  PCRE_ERROR_INTERNAL       (-14)
+</pre>
+An unexpected internal error has occurred. This error could be caused by a bug
+in PCRE or by overwriting of the compiled pattern.
+<pre>
+  PCRE_ERROR_BADCOUNT       (-15)
+</pre>
+This error is given if the value of the <i>ovecsize</i> argument is negative.
+<pre>
+  PCRE_ERROR_RECURSIONLIMIT (-21)
+</pre>
+The internal recursion limit, as specified by the <i>match_limit_recursion</i>
+field in a <b>pcre_extra</b> structure (or defaulted) was reached. See the
+description above.
+<pre>
+  PCRE_ERROR_BADNEWLINE     (-23)
+</pre>
+An invalid combination of PCRE_NEWLINE_<i>xxx</i> options was given.
+</P>
+<P>
+Error numbers -16 to -20 and -22 are not used by <b>pcre_exec()</b>.
+</P>
+<br><a name="SEC15" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a><br>
+<P>
+<b>int pcre_copy_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
+<b>int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre_get_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, int <i>stringnumber</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<P>
+<b>int pcre_get_substring_list(const char *<i>subject</i>,</b>
+<b>int *<i>ovector</i>, int <i>stringcount</i>, const char ***<i>listptr</i>);</b>
+</P>
+<P>
+Captured substrings can be accessed directly by using the offsets returned by
+<b>pcre_exec()</b> in <i>ovector</i>. For convenience, the functions
+<b>pcre_copy_substring()</b>, <b>pcre_get_substring()</b>, and
+<b>pcre_get_substring_list()</b> are provided for extracting captured substrings
+as new, separate, zero-terminated strings. These functions identify substrings
+by number. The next section describes functions for extracting named
+substrings.
+</P>
+<P>
+A substring that contains a binary zero is correctly extracted and has a
+further zero added on the end, but the result is not, of course, a C string.
+However, you can process such a string by referring to the length that is
+returned by <b>pcre_copy_substring()</b> and <b>pcre_get_substring()</b>.
+Unfortunately, the interface to <b>pcre_get_substring_list()</b> is not adequate
+for handling strings containing binary zeros, because the end of the final
+string is not independently indicated.
+</P>
+<P>
+The first three arguments are the same for all three of these functions:
+<i>subject</i> is the subject string that has just been successfully matched,
+<i>ovector</i> is a pointer to the vector of integer offsets that was passed to
+<b>pcre_exec()</b>, and <i>stringcount</i> is the number of substrings that were
+captured by the match, including the substring that matched the entire regular
+expression. This is the value returned by <b>pcre_exec()</b> if it is greater
+than zero. If <b>pcre_exec()</b> returned zero, indicating that it ran out of
+space in <i>ovector</i>, the value passed as <i>stringcount</i> should be the
+number of elements in the vector divided by three.
+</P>
+<P>
+The functions <b>pcre_copy_substring()</b> and <b>pcre_get_substring()</b>
+extract a single substring, whose number is given as <i>stringnumber</i>. A
+value of zero extracts the substring that matched the entire pattern, whereas
+higher values extract the captured substrings. For <b>pcre_copy_substring()</b>,
+the string is placed in <i>buffer</i>, whose length is given by
+<i>buffersize</i>, while for <b>pcre_get_substring()</b> a new block of memory is
+obtained via <b>pcre_malloc</b>, and its address is returned via
+<i>stringptr</i>. The yield of the function is the length of the string, not
+including the terminating zero, or one of these error codes:
+<pre>
+  PCRE_ERROR_NOMEMORY       (-6)
+</pre>
+The buffer was too small for <b>pcre_copy_substring()</b>, or the attempt to get
+memory failed for <b>pcre_get_substring()</b>.
+<pre>
+  PCRE_ERROR_NOSUBSTRING    (-7)
+</pre>
+There is no substring whose number is <i>stringnumber</i>.
+</P>
+<P>
+The <b>pcre_get_substring_list()</b> function extracts all available substrings
+and builds a list of pointers to them. All this is done in a single block of
+memory that is obtained via <b>pcre_malloc</b>. The address of the memory block
+is returned via <i>listptr</i>, which is also the start of the list of string
+pointers. The end of the list is marked by a NULL pointer. The yield of the
+function is zero if all went well, or the error code
+<pre>
+  PCRE_ERROR_NOMEMORY       (-6)
+</pre>
+if the attempt to get the memory block failed.
+</P>
+<P>
+When any of these functions encounter a substring that is unset, which can
+happen when capturing subpattern number <i>n+1</i> matches some part of the
+subject, but subpattern <i>n</i> has not been used at all, they return an empty
+string. This can be distinguished from a genuine zero-length substring by
+inspecting the appropriate offset in <i>ovector</i>, which is negative for unset
+substrings.
+</P>
+<P>
+The two convenience functions <b>pcre_free_substring()</b> and
+<b>pcre_free_substring_list()</b> can be used to free the memory returned by
+a previous call of <b>pcre_get_substring()</b> or
+<b>pcre_get_substring_list()</b>, respectively. They do nothing more than call
+the function pointed to by <b>pcre_free</b>, which of course could be called
+directly from a C program. However, PCRE is used in some situations where it is
+linked via a special interface to another programming language that cannot use
+<b>pcre_free</b> directly; it is for these cases that the functions are
+provided.
+</P>
+<br><a name="SEC16" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a><br>
+<P>
+<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>);</b>
+</P>
+<P>
+<b>int pcre_copy_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>char *<i>buffer</i>, int <i>buffersize</i>);</b>
+</P>
+<P>
+<b>int pcre_get_named_substring(const pcre *<i>code</i>,</b>
+<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
+<b>int <i>stringcount</i>, const char *<i>stringname</i>,</b>
+<b>const char **<i>stringptr</i>);</b>
+</P>
+<P>
+To extract a substring by name, you first have to find associated number.
+For example, for this pattern
+<pre>
+  (a+)b(?&#60;xxx&#62;\d+)...
+</pre>
+the number of the subpattern called "xxx" is 2. If the name is known to be
+unique (PCRE_DUPNAMES was not set), you can find the number from the name by
+calling <b>pcre_get_stringnumber()</b>. The first argument is the compiled
+pattern, and the second is the name. The yield of the function is the
+subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no subpattern of
+that name.
+</P>
+<P>
+Given the number, you can extract the substring directly, or use one of the
+functions described in the previous section. For convenience, there are also
+two functions that do the whole job.
+</P>
+<P>
+Most of the arguments of <b>pcre_copy_named_substring()</b> and
+<b>pcre_get_named_substring()</b> are the same as those for the similarly named
+functions that extract by number. As these are described in the previous
+section, they are not re-described here. There are just two differences:
+</P>
+<P>
+First, instead of a substring number, a substring name is given. Second, there
+is an extra argument, given at the start, which is a pointer to the compiled
+pattern. This is needed in order to gain access to the name-to-number
+translation table.
+</P>
+<P>
+These functions call <b>pcre_get_stringnumber()</b>, and if it succeeds, they
+then call <b>pcre_copy_substring()</b> or <b>pcre_get_substring()</b>, as
+appropriate. <b>NOTE:</b> If PCRE_DUPNAMES is set and there are duplicate names,
+the behaviour may not be what you want (see the next section).
+</P>
+<br><a name="SEC17" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>
+<P>
+<b>int pcre_get_stringtable_entries(const pcre *<i>code</i>,</b>
+<b>const char *<i>name</i>, char **<i>first</i>, char **<i>last</i>);</b>
+</P>
+<P>
+When a pattern is compiled with the PCRE_DUPNAMES option, names for subpatterns
+are not required to be unique. Normally, patterns with duplicate names are such
+that in any one match, only one of the named subpatterns participates. An
+example is shown in the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+documentation.
+</P>
+<P>
+When duplicates are present, <b>pcre_copy_named_substring()</b> and
+<b>pcre_get_named_substring()</b> return the first substring corresponding to
+the given name that is set. If none are set, PCRE_ERROR_NOSUBSTRING (-7) is
+returned; no data is returned. The <b>pcre_get_stringnumber()</b> function
+returns one of the numbers that are associated with the name, but it is not
+defined which it is.
+</P>
+<P>
+If you want to get full details of all captured substrings for a given name,
+you must use the <b>pcre_get_stringtable_entries()</b> function. The first
+argument is the compiled pattern, and the second is the name. The third and
+fourth are pointers to variables which are updated by the function. After it
+has run, they point to the first and last entries in the name-to-number table
+for the given name. The function itself returns the length of each entry, or
+PCRE_ERROR_NOSUBSTRING (-7) if there are none. The format of the table is
+described above in the section entitled <i>Information about a pattern</i>.
+Given all the relevant entries for the name, you can extract each of their
+numbers, and hence the captured data, if any.
+</P>
+<br><a name="SEC18" href="#TOC1">FINDING ALL POSSIBLE MATCHES</a><br>
+<P>
+The traditional matching function uses a similar algorithm to Perl, which stops
+when it finds the first match, starting at a given point in the subject. If you
+want to find all possible matches, or the longest possible match, consider
+using the alternative matching function (see below) instead. If you cannot use
+the alternative function, but still need to find all possible matches, you
+can kludge it up by making use of the callout facility, which is described in
+the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation.
+</P>
+<P>
+What you have to do is to insert a callout right at the end of the pattern.
+When your callout function is called, extract and save the current matched
+substring. Then return 1, which forces <b>pcre_exec()</b> to backtrack and try
+other alternatives. Ultimately, when it runs out of matches, <b>pcre_exec()</b>
+will yield PCRE_ERROR_NOMATCH.
+<a name="dfamatch"></a></P>
+<br><a name="SEC19" href="#TOC1">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a><br>
+<P>
+<b>int pcre_dfa_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
+<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
+<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>,</b>
+<b>int *<i>workspace</i>, int <i>wscount</i>);</b>
+</P>
+<P>
+The function <b>pcre_dfa_exec()</b> is called to match a subject string against
+a compiled pattern, using a matching algorithm that scans the subject string
+just once, and does not backtrack. This has different characteristics to the
+normal algorithm, and is not compatible with Perl. Some of the features of PCRE
+patterns are not supported. Nevertheless, there are times when this kind of
+matching can be useful. For a discussion of the two matching algorithms, see
+the
+<a href="pcrematching.html"><b>pcrematching</b></a>
+documentation.
+</P>
+<P>
+The arguments for the <b>pcre_dfa_exec()</b> function are the same as for
+<b>pcre_exec()</b>, plus two extras. The <i>ovector</i> argument is used in a
+different way, and this is described below. The other common arguments are used
+in the same way as for <b>pcre_exec()</b>, so their description is not repeated
+here.
+</P>
+<P>
+The two additional arguments provide workspace for the function. The workspace
+vector should contain at least 20 elements. It is used for keeping track of
+multiple paths through the pattern tree. More workspace will be needed for
+patterns and subjects where there are a lot of potential matches.
+</P>
+<P>
+Here is an example of a simple call to <b>pcre_dfa_exec()</b>:
+<pre>
+  int rc;
+  int ovector[10];
+  int wspace[20];
+  rc = pcre_dfa_exec(
+    re,             /* result of pcre_compile() */
+    NULL,           /* we didn't study the pattern */
+    "some string",  /* the subject string */
+    11,             /* the length of the subject string */
+    0,              /* start at offset 0 in the subject */
+    0,              /* default options */
+    ovector,        /* vector of integers for substring information */
+    10,             /* number of elements (NOT size in bytes) */
+    wspace,         /* working space vector */
+    20);            /* number of elements (NOT size in bytes) */
+</PRE>
+</P>
+<br><b>
+Option bits for <b>pcre_dfa_exec()</b>
+</b><br>
+<P>
+The unused bits of the <i>options</i> argument for <b>pcre_dfa_exec()</b> must be
+zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEWLINE_<i>xxx</i>,
+PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK, PCRE_PARTIAL,
+PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last three of these are
+the same as for <b>pcre_exec()</b>, so their description is not repeated here.
+<pre>
+  PCRE_PARTIAL
+</pre>
+This has the same general effect as it does for <b>pcre_exec()</b>, but the
+details are slightly different. When PCRE_PARTIAL is set for
+<b>pcre_dfa_exec()</b>, the return code PCRE_ERROR_NOMATCH is converted into
+PCRE_ERROR_PARTIAL if the end of the subject is reached, there have been no
+complete matches, but there is still at least one matching possibility. The
+portion of the string that provided the partial match is set as the first
+matching string.
+<pre>
+  PCRE_DFA_SHORTEST
+</pre>
+Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to stop as
+soon as it has found one match. Because of the way the alternative algorithm
+works, this is necessarily the shortest possible match at the first possible
+matching point in the subject string.
+<pre>
+  PCRE_DFA_RESTART
+</pre>
+When <b>pcre_dfa_exec()</b> is called with the PCRE_PARTIAL option, and returns
+a partial match, it is possible to call it again, with additional subject
+characters, and have it continue with the same match. The PCRE_DFA_RESTART
+option requests this action; when it is set, the <i>workspace</i> and
+<i>wscount</i> options must reference the same vector as before because data
+about the match so far is left in them after a partial match. There is more
+discussion of this facility in the
+<a href="pcrepartial.html"><b>pcrepartial</b></a>
+documentation.
+</P>
+<br><b>
+Successful returns from <b>pcre_dfa_exec()</b>
+</b><br>
+<P>
+When <b>pcre_dfa_exec()</b> succeeds, it may have matched more than one
+substring in the subject. Note, however, that all the matches from one run of
+the function start at the same point in the subject. The shorter matches are
+all initial substrings of the longer matches. For example, if the pattern
+<pre>
+  &#60;.*&#62;
+</pre>
+is matched against the string
+<pre>
+  This is &#60;something&#62; &#60;something else&#62; &#60;something further&#62; no more
+</pre>
+the three matched strings are
+<pre>
+  &#60;something&#62;
+  &#60;something&#62; &#60;something else&#62;
+  &#60;something&#62; &#60;something else&#62; &#60;something further&#62;
+</pre>
+On success, the yield of the function is a number greater than zero, which is
+the number of matched substrings. The substrings themselves are returned in
+<i>ovector</i>. Each string uses two elements; the first is the offset to the
+start, and the second is the offset to the end. In fact, all the strings have
+the same start offset. (Space could have been saved by giving this only once,
+but it was decided to retain some compatibility with the way <b>pcre_exec()</b>
+returns data, even though the meaning of the strings is different.)
+</P>
+<P>
+The strings are returned in reverse order of length; that is, the longest
+matching string is given first. If there were too many matches to fit into
+<i>ovector</i>, the yield of the function is zero, and the vector is filled with
+the longest matches.
+</P>
+<br><b>
+Error returns from <b>pcre_dfa_exec()</b>
+</b><br>
+<P>
+The <b>pcre_dfa_exec()</b> function returns a negative number when it fails.
+Many of the errors are the same as for <b>pcre_exec()</b>, and these are
+described
+<a href="#errorlist">above.</a>
+There are in addition the following errors that are specific to
+<b>pcre_dfa_exec()</b>:
+<pre>
+  PCRE_ERROR_DFA_UITEM      (-16)
+</pre>
+This return is given if <b>pcre_dfa_exec()</b> encounters an item in the pattern
+that it does not support, for instance, the use of \C or a back reference.
+<pre>
+  PCRE_ERROR_DFA_UCOND      (-17)
+</pre>
+This return is given if <b>pcre_dfa_exec()</b> encounters a condition item that
+uses a back reference for the condition, or a test for recursion in a specific
+group. These are not supported.
+<pre>
+  PCRE_ERROR_DFA_UMLIMIT    (-18)
+</pre>
+This return is given if <b>pcre_dfa_exec()</b> is called with an <i>extra</i>
+block that contains a setting of the <i>match_limit</i> field. This is not
+supported (it is meaningless).
+<pre>
+  PCRE_ERROR_DFA_WSSIZE     (-19)
+</pre>
+This return is given if <b>pcre_dfa_exec()</b> runs out of space in the
+<i>workspace</i> vector.
+<pre>
+  PCRE_ERROR_DFA_RECURSE    (-20)
+</pre>
+When a recursive subpattern is processed, the matching function calls itself
+recursively, using private vectors for <i>ovector</i> and <i>workspace</i>. This
+error is given if the output vector is not large enough. This should be
+extremely rare, as a vector of size 1000 is used.
+</P>
+<br><a name="SEC20" href="#TOC1">SEE ALSO</a><br>
+<P>
+<b>pcrebuild</b>(3), <b>pcrecallout</b>(3), <b>pcrecpp(3)</b>(3),
+<b>pcrematching</b>(3), <b>pcrepartial</b>(3), <b>pcreposix</b>(3),
+<b>pcreprecompile</b>(3), <b>pcresample</b>(3), <b>pcrestack</b>(3).
+</P>
+<br><a name="SEC21" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC22" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 24 August 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcrebuild.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,340 @@
+<html>
+<head>
+<title>pcrebuild specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcrebuild man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE BUILD-TIME OPTIONS</a>
+<li><a name="TOC2" href="#SEC2">C++ SUPPORT</a>
+<li><a name="TOC3" href="#SEC3">UTF-8 SUPPORT</a>
+<li><a name="TOC4" href="#SEC4">UNICODE CHARACTER PROPERTY SUPPORT</a>
+<li><a name="TOC5" href="#SEC5">CODE VALUE OF NEWLINE</a>
+<li><a name="TOC6" href="#SEC6">WHAT \R MATCHES</a>
+<li><a name="TOC7" href="#SEC7">BUILDING SHARED AND STATIC LIBRARIES</a>
+<li><a name="TOC8" href="#SEC8">POSIX MALLOC USAGE</a>
+<li><a name="TOC9" href="#SEC9">HANDLING VERY LARGE PATTERNS</a>
+<li><a name="TOC10" href="#SEC10">AVOIDING EXCESSIVE STACK USAGE</a>
+<li><a name="TOC11" href="#SEC11">LIMITING PCRE RESOURCE USAGE</a>
+<li><a name="TOC12" href="#SEC12">CREATING CHARACTER TABLES AT BUILD TIME</a>
+<li><a name="TOC13" href="#SEC13">USING EBCDIC CODE</a>
+<li><a name="TOC14" href="#SEC14">PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT</a>
+<li><a name="TOC15" href="#SEC15">PCRETEST OPTION FOR LIBREADLINE SUPPORT</a>
+<li><a name="TOC16" href="#SEC16">SEE ALSO</a>
+<li><a name="TOC17" href="#SEC17">AUTHOR</a>
+<li><a name="TOC18" href="#SEC18">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE BUILD-TIME OPTIONS</a><br>
+<P>
+This document describes the optional features of PCRE that can be selected when
+the library is compiled. It assumes use of the <b>configure</b> script, where
+the optional features are selected or deselected by providing options to
+<b>configure</b> before running the <b>make</b> command. However, the same
+options can be selected in both Unix-like and non-Unix-like environments using
+the GUI facility of <b>CMakeSetup</b> if you are using <b>CMake</b> instead of
+<b>configure</b> to build PCRE.
+</P>
+<P>
+The complete list of options for <b>configure</b> (which includes the standard
+ones such as the selection of the installation directory) can be obtained by
+running
+<pre>
+  ./configure --help
+</pre>
+The following sections include descriptions of options whose names begin with
+--enable or --disable. These settings specify changes to the defaults for the
+<b>configure</b> command. Because of the way that <b>configure</b> works,
+--enable and --disable always come in pairs, so the complementary option always
+exists as well, but as it specifies the default, it is not described.
+</P>
+<br><a name="SEC2" href="#TOC1">C++ SUPPORT</a><br>
+<P>
+By default, the <b>configure</b> script will search for a C++ compiler and C++
+header files. If it finds them, it automatically builds the C++ wrapper library
+for PCRE. You can disable this by adding
+<pre>
+  --disable-cpp
+</pre>
+to the <b>configure</b> command.
+</P>
+<br><a name="SEC3" href="#TOC1">UTF-8 SUPPORT</a><br>
+<P>
+To build PCRE with support for UTF-8 character strings, add
+<pre>
+  --enable-utf8
+</pre>
+to the <b>configure</b> command. Of itself, this does not make PCRE treat
+strings as UTF-8. As well as compiling PCRE with this option, you also have
+have to set the PCRE_UTF8 option when you call the <b>pcre_compile()</b>
+function.
+</P>
+<br><a name="SEC4" href="#TOC1">UNICODE CHARACTER PROPERTY SUPPORT</a><br>
+<P>
+UTF-8 support allows PCRE to process character values greater than 255 in the
+strings that it handles. On its own, however, it does not provide any
+facilities for accessing the properties of such characters. If you want to be
+able to use the pattern escapes \P, \p, and \X, which refer to Unicode
+character properties, you must add
+<pre>
+  --enable-unicode-properties
+</pre>
+to the <b>configure</b> command. This implies UTF-8 support, even if you have
+not explicitly requested it.
+</P>
+<P>
+Including Unicode property support adds around 30K of tables to the PCRE
+library. Only the general category properties such as <i>Lu</i> and <i>Nd</i> are
+supported. Details are given in the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+documentation.
+</P>
+<br><a name="SEC5" href="#TOC1">CODE VALUE OF NEWLINE</a><br>
+<P>
+By default, PCRE interprets character 10 (linefeed, LF) as indicating the end
+of a line. This is the normal newline character on Unix-like systems. You can
+compile PCRE to use character 13 (carriage return, CR) instead, by adding
+<pre>
+  --enable-newline-is-cr
+</pre>
+to the <b>configure</b> command. There is also a --enable-newline-is-lf option,
+which explicitly specifies linefeed as the newline character.
+<br>
+<br>
+Alternatively, you can specify that line endings are to be indicated by the two
+character sequence CRLF. If you want this, add
+<pre>
+  --enable-newline-is-crlf
+</pre>
+to the <b>configure</b> command. There is a fourth option, specified by
+<pre>
+  --enable-newline-is-anycrlf
+</pre>
+which causes PCRE to recognize any of the three sequences CR, LF, or CRLF as
+indicating a line ending. Finally, a fifth option, specified by
+<pre>
+  --enable-newline-is-any
+</pre>
+causes PCRE to recognize any Unicode newline sequence.
+</P>
+<P>
+Whatever line ending convention is selected when PCRE is built can be
+overridden when the library functions are called. At build time it is
+conventional to use the standard for your operating system.
+</P>
+<br><a name="SEC6" href="#TOC1">WHAT \R MATCHES</a><br>
+<P>
+By default, the sequence \R in a pattern matches any Unicode newline sequence,
+whatever has been selected as the line ending sequence. If you specify
+<pre>
+  --enable-bsr-anycrlf
+</pre>
+the default is changed so that \R matches only CR, LF, or CRLF. Whatever is
+selected when PCRE is built can be overridden when the library functions are
+called.
+</P>
+<br><a name="SEC7" href="#TOC1">BUILDING SHARED AND STATIC LIBRARIES</a><br>
+<P>
+The PCRE building process uses <b>libtool</b> to build both shared and static
+Unix libraries by default. You can suppress one of these by adding one of
+<pre>
+  --disable-shared
+  --disable-static
+</pre>
+to the <b>configure</b> command, as required.
+</P>
+<br><a name="SEC8" href="#TOC1">POSIX MALLOC USAGE</a><br>
+<P>
+When PCRE is called through the POSIX interface (see the
+<a href="pcreposix.html"><b>pcreposix</b></a>
+documentation), additional working storage is required for holding the pointers
+to capturing substrings, because PCRE requires three integers per substring,
+whereas the POSIX interface provides only two. If the number of expected
+substrings is small, the wrapper function uses space on the stack, because this
+is faster than using <b>malloc()</b> for each call. The default threshold above
+which the stack is no longer used is 10; it can be changed by adding a setting
+such as
+<pre>
+  --with-posix-malloc-threshold=20
+</pre>
+to the <b>configure</b> command.
+</P>
+<br><a name="SEC9" href="#TOC1">HANDLING VERY LARGE PATTERNS</a><br>
+<P>
+Within a compiled pattern, offset values are used to point from one part to
+another (for example, from an opening parenthesis to an alternation
+metacharacter). By default, two-byte values are used for these offsets, leading
+to a maximum size for a compiled pattern of around 64K. This is sufficient to
+handle all but the most gigantic patterns. Nevertheless, some people do want to
+process enormous patterns, so it is possible to compile PCRE to use three-byte
+or four-byte offsets by adding a setting such as
+<pre>
+  --with-link-size=3
+</pre>
+to the <b>configure</b> command. The value given must be 2, 3, or 4. Using
+longer offsets slows down the operation of PCRE because it has to load
+additional bytes when handling them.
+</P>
+<br><a name="SEC10" href="#TOC1">AVOIDING EXCESSIVE STACK USAGE</a><br>
+<P>
+When matching with the <b>pcre_exec()</b> function, PCRE implements backtracking
+by making recursive calls to an internal function called <b>match()</b>. In
+environments where the size of the stack is limited, this can severely limit
+PCRE's operation. (The Unix environment does not usually suffer from this
+problem, but it may sometimes be necessary to increase the maximum stack size.
+There is a discussion in the
+<a href="pcrestack.html"><b>pcrestack</b></a>
+documentation.) An alternative approach to recursion that uses memory from the
+heap to remember data, instead of using recursive function calls, has been
+implemented to work round the problem of limited stack size. If you want to
+build a version of PCRE that works this way, add
+<pre>
+  --disable-stack-for-recursion
+</pre>
+to the <b>configure</b> command. With this configuration, PCRE will use the
+<b>pcre_stack_malloc</b> and <b>pcre_stack_free</b> variables to call memory
+management functions. By default these point to <b>malloc()</b> and
+<b>free()</b>, but you can replace the pointers so that your own functions are
+used.
+</P>
+<P>
+Separate functions are provided rather than using <b>pcre_malloc</b> and
+<b>pcre_free</b> because the usage is very predictable: the block sizes
+requested are always the same, and the blocks are always freed in reverse
+order. A calling program might be able to implement optimized functions that
+perform better than <b>malloc()</b> and <b>free()</b>. PCRE runs noticeably more
+slowly when built in this way. This option affects only the <b>pcre_exec()</b>
+function; it is not relevant for the the <b>pcre_dfa_exec()</b> function.
+</P>
+<br><a name="SEC11" href="#TOC1">LIMITING PCRE RESOURCE USAGE</a><br>
+<P>
+Internally, PCRE has a function called <b>match()</b>, which it calls repeatedly
+(sometimes recursively) when matching a pattern with the <b>pcre_exec()</b>
+function. By controlling the maximum number of times this function may be
+called during a single matching operation, a limit can be placed on the
+resources used by a single call to <b>pcre_exec()</b>. The limit can be changed
+at run time, as described in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation. The default is 10 million, but this can be changed by adding a
+setting such as
+<pre>
+  --with-match-limit=500000
+</pre>
+to the <b>configure</b> command. This setting has no effect on the
+<b>pcre_dfa_exec()</b> matching function.
+</P>
+<P>
+In some environments it is desirable to limit the depth of recursive calls of
+<b>match()</b> more strictly than the total number of calls, in order to
+restrict the maximum amount of stack (or heap, if --disable-stack-for-recursion
+is specified) that is used. A second limit controls this; it defaults to the
+value that is set for --with-match-limit, which imposes no additional
+constraints. However, you can set a lower limit by adding, for example,
+<pre>
+  --with-match-limit-recursion=10000
+</pre>
+to the <b>configure</b> command. This value can also be overridden at run time.
+</P>
+<br><a name="SEC12" href="#TOC1">CREATING CHARACTER TABLES AT BUILD TIME</a><br>
+<P>
+PCRE uses fixed tables for processing characters whose code values are less
+than 256. By default, PCRE is built with a set of tables that are distributed
+in the file <i>pcre_chartables.c.dist</i>. These tables are for ASCII codes
+only. If you add
+<pre>
+  --enable-rebuild-chartables
+</pre>
+to the <b>configure</b> command, the distributed tables are no longer used.
+Instead, a program called <b>dftables</b> is compiled and run. This outputs the
+source for new set of tables, created in the default locale of your C runtime
+system. (This method of replacing the tables does not work if you are cross
+compiling, because <b>dftables</b> is run on the local host. If you need to
+create alternative tables when cross compiling, you will have to do so "by
+hand".)
+</P>
+<br><a name="SEC13" href="#TOC1">USING EBCDIC CODE</a><br>
+<P>
+PCRE assumes by default that it will run in an environment where the character
+code is ASCII (or Unicode, which is a superset of ASCII). This is the case for
+most computer operating systems. PCRE can, however, be compiled to run in an
+EBCDIC environment by adding
+<pre>
+  --enable-ebcdic
+</pre>
+to the <b>configure</b> command. This setting implies
+--enable-rebuild-chartables. You should only use it if you know that you are in
+an EBCDIC environment (for example, an IBM mainframe operating system).
+</P>
+<br><a name="SEC14" href="#TOC1">PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT</a><br>
+<P>
+By default, <b>pcregrep</b> reads all files as plain text. You can build it so
+that it recognizes files whose names end in <b>.gz</b> or <b>.bz2</b>, and reads
+them with <b>libz</b> or <b>libbz2</b>, respectively, by adding one or both of
+<pre>
+  --enable-pcregrep-libz
+  --enable-pcregrep-libbz2
+</pre>
+to the <b>configure</b> command. These options naturally require that the
+relevant libraries are installed on your system. Configuration will fail if
+they are not.
+</P>
+<br><a name="SEC15" href="#TOC1">PCRETEST OPTION FOR LIBREADLINE SUPPORT</a><br>
+<P>
+If you add
+<pre>
+  --enable-pcretest-libreadline
+</pre>
+to the <b>configure</b> command, <b>pcretest</b> is linked with the
+<b>libreadline</b> library, and when its input is from a terminal, it reads it
+using the <b>readline()</b> function. This provides line-editing and history
+facilities. Note that <b>libreadline</b> is GPL-licenced, so if you distribute a
+binary of <b>pcretest</b> linked in this way, there may be licensing issues.
+</P>
+<P>
+Setting this option causes the <b>-lreadline</b> option to be added to the
+<b>pcretest</b> build. In many operating environments with a sytem-installed
+<b>libreadline</b> this is sufficient. However, in some environments (e.g.
+if an unmodified distribution version of readline is in use), some extra
+configuration may be necessary. The INSTALL file for <b>libreadline</b> says
+this:
+<pre>
+  "Readline uses the termcap functions, but does not link with the
+  termcap or curses library itself, allowing applications which link
+  with readline the to choose an appropriate library."
+</pre>
+If your environment has not been set up so that an appropriate library is
+automatically included, you may need to add something like
+<pre>
+  LIBS="-ncurses"
+</pre>
+immediately before the <b>configure</b> command.
+</P>
+<br><a name="SEC16" href="#TOC1">SEE ALSO</a><br>
+<P>
+<b>pcreapi</b>(3), <b>pcre_config</b>(3).
+</P>
+<br><a name="SEC17" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC18" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 13 April 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcrecallout.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,201 @@
+<html>
+<head>
+<title>pcrecallout specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcrecallout man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE CALLOUTS</a>
+<li><a name="TOC2" href="#SEC2">MISSING CALLOUTS</a>
+<li><a name="TOC3" href="#SEC3">THE CALLOUT INTERFACE</a>
+<li><a name="TOC4" href="#SEC4">RETURN VALUES</a>
+<li><a name="TOC5" href="#SEC5">AUTHOR</a>
+<li><a name="TOC6" href="#SEC6">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE CALLOUTS</a><br>
+<P>
+<b>int (*pcre_callout)(pcre_callout_block *);</b>
+</P>
+<P>
+PCRE provides a feature called "callout", which is a means of temporarily
+passing control to the caller of PCRE in the middle of pattern matching. The
+caller of PCRE provides an external function by putting its entry point in the
+global variable <i>pcre_callout</i>. By default, this variable contains NULL,
+which disables all calling out.
+</P>
+<P>
+Within a regular expression, (?C) indicates the points at which the external
+function is to be called. Different callout points can be identified by putting
+a number less than 256 after the letter C. The default value is zero.
+For example, this pattern has two callout points:
+<pre>
+  (?C1)abc(?C2)def
+</pre>
+If the PCRE_AUTO_CALLOUT option bit is set when <b>pcre_compile()</b> is called,
+PCRE automatically inserts callouts, all with number 255, before each item in
+the pattern. For example, if PCRE_AUTO_CALLOUT is used with the pattern
+<pre>
+  A(\d{2}|--)
+</pre>
+it is processed as if it were
+<br>
+<br>
+(?C255)A(?C255)((?C255)\d{2}(?C255)|(?C255)-(?C255)-(?C255))(?C255)
+<br>
+<br>
+Notice that there is a callout before and after each parenthesis and
+alternation bar. Automatic callouts can be used for tracking the progress of
+pattern matching. The
+<a href="pcretest.html"><b>pcretest</b></a>
+command has an option that sets automatic callouts; when it is used, the output
+indicates how the pattern is matched. This is useful information when you are
+trying to optimize the performance of a particular pattern.
+</P>
+<br><a name="SEC2" href="#TOC1">MISSING CALLOUTS</a><br>
+<P>
+You should be aware that, because of optimizations in the way PCRE matches
+patterns, callouts sometimes do not happen. For example, if the pattern is
+<pre>
+  ab(?C4)cd
+</pre>
+PCRE knows that any matching string must contain the letter "d". If the subject
+string is "abyz", the lack of "d" means that matching doesn't ever start, and
+the callout is never reached. However, with "abyd", though the result is still
+no match, the callout is obeyed.
+</P>
+<br><a name="SEC3" href="#TOC1">THE CALLOUT INTERFACE</a><br>
+<P>
+During matching, when PCRE reaches a callout point, the external function
+defined by <i>pcre_callout</i> is called (if it is set). This applies to both
+the <b>pcre_exec()</b> and the <b>pcre_dfa_exec()</b> matching functions. The
+only argument to the callout function is a pointer to a <b>pcre_callout</b>
+block. This structure contains the following fields:
+<pre>
+  int          <i>version</i>;
+  int          <i>callout_number</i>;
+  int         *<i>offset_vector</i>;
+  const char  *<i>subject</i>;
+  int          <i>subject_length</i>;
+  int          <i>start_match</i>;
+  int          <i>current_position</i>;
+  int          <i>capture_top</i>;
+  int          <i>capture_last</i>;
+  void        *<i>callout_data</i>;
+  int          <i>pattern_position</i>;
+  int          <i>next_item_length</i>;
+</pre>
+The <i>version</i> field is an integer containing the version number of the
+block format. The initial version was 0; the current version is 1. The version
+number will change again in future if additional fields are added, but the
+intention is never to remove any of the existing fields.
+</P>
+<P>
+The <i>callout_number</i> field contains the number of the callout, as compiled
+into the pattern (that is, the number after ?C for manual callouts, and 255 for
+automatically generated callouts).
+</P>
+<P>
+The <i>offset_vector</i> field is a pointer to the vector of offsets that was
+passed by the caller to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>. When
+<b>pcre_exec()</b> is used, the contents can be inspected in order to extract
+substrings that have been matched so far, in the same way as for extracting
+substrings after a match has completed. For <b>pcre_dfa_exec()</b> this field is
+not useful.
+</P>
+<P>
+The <i>subject</i> and <i>subject_length</i> fields contain copies of the values
+that were passed to <b>pcre_exec()</b>.
+</P>
+<P>
+The <i>start_match</i> field normally contains the offset within the subject at
+which the current match attempt started. However, if the escape sequence \K
+has been encountered, this value is changed to reflect the modified starting
+point. If the pattern is not anchored, the callout function may be called
+several times from the same point in the pattern for different starting points
+in the subject.
+</P>
+<P>
+The <i>current_position</i> field contains the offset within the subject of the
+current match pointer.
+</P>
+<P>
+When the <b>pcre_exec()</b> function is used, the <i>capture_top</i> field
+contains one more than the number of the highest numbered captured substring so
+far. If no substrings have been captured, the value of <i>capture_top</i> is
+one. This is always the case when <b>pcre_dfa_exec()</b> is used, because it
+does not support captured substrings.
+</P>
+<P>
+The <i>capture_last</i> field contains the number of the most recently captured
+substring. If no substrings have been captured, its value is -1. This is always
+the case when <b>pcre_dfa_exec()</b> is used.
+</P>
+<P>
+The <i>callout_data</i> field contains a value that is passed to
+<b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> specifically so that it can be
+passed back in callouts. It is passed in the <i>pcre_callout</i> field of the
+<b>pcre_extra</b> data structure. If no such data was passed, the value of
+<i>callout_data</i> in a <b>pcre_callout</b> block is NULL. There is a
+description of the <b>pcre_extra</b> structure in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<P>
+The <i>pattern_position</i> field is present from version 1 of the
+<i>pcre_callout</i> structure. It contains the offset to the next item to be
+matched in the pattern string.
+</P>
+<P>
+The <i>next_item_length</i> field is present from version 1 of the
+<i>pcre_callout</i> structure. It contains the length of the next item to be
+matched in the pattern string. When the callout immediately precedes an
+alternation bar, a closing parenthesis, or the end of the pattern, the length
+is zero. When the callout precedes an opening parenthesis, the length is that
+of the entire subpattern.
+</P>
+<P>
+The <i>pattern_position</i> and <i>next_item_length</i> fields are intended to
+help in distinguishing between different automatic callouts, which all have the
+same callout number. However, they are set for all callouts.
+</P>
+<br><a name="SEC4" href="#TOC1">RETURN VALUES</a><br>
+<P>
+The external callout function returns an integer to PCRE. If the value is zero,
+matching proceeds as normal. If the value is greater than zero, matching fails
+at the current point, but the testing of other matching possibilities goes
+ahead, just as if a lookahead assertion had failed. If the value is less than
+zero, the match is abandoned, and <b>pcre_exec()</b> (or <b>pcre_dfa_exec()</b>)
+returns the negative value.
+</P>
+<P>
+Negative values should normally be chosen from the set of PCRE_ERROR_xxx
+values. In particular, PCRE_ERROR_NOMATCH forces a standard "no match" failure.
+The error number PCRE_ERROR_CALLOUT is reserved for use by callout functions;
+it will never be used by PCRE itself.
+</P>
+<br><a name="SEC5" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC6" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 29 May 2007
+<br>
+Copyright &copy; 1997-2007 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcrecompat.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,179 @@
+<html>
+<head>
+<title>pcrecompat specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcrecompat man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+DIFFERENCES BETWEEN PCRE AND PERL
+</b><br>
+<P>
+This document describes the differences in the ways that PCRE and Perl handle
+regular expressions. The differences described here are mainly with respect to
+Perl 5.8, though PCRE versions 7.0 and later contain some features that are
+expected to be in the forthcoming Perl 5.10.
+</P>
+<P>
+1. PCRE has only a subset of Perl's UTF-8 and Unicode support. Details of what
+it does have are given in the
+<a href="pcre.html#utf8support">section on UTF-8 support</a>
+in the main
+<a href="pcre.html"><b>pcre</b></a>
+page.
+</P>
+<P>
+2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits
+them, but they do not mean what you might think. For example, (?!a){3} does
+not assert that the next three characters are not "a". It just asserts that the
+next character is not "a" three times.
+</P>
+<P>
+3. Capturing subpatterns that occur inside negative lookahead assertions are
+counted, but their entries in the offsets vector are never set. Perl sets its
+numerical variables from any such patterns that are matched before the
+assertion fails to match something (thereby succeeding), but only if the
+negative lookahead assertion contains just one branch.
+</P>
+<P>
+4. Though binary zero characters are supported in the subject string, they are
+not allowed in a pattern string because it is passed as a normal C string,
+terminated by zero. The escape sequence \0 can be used in the pattern to
+represent a binary zero.
+</P>
+<P>
+5. The following Perl escape sequences are not supported: \l, \u, \L,
+\U, and \N. In fact these are implemented by Perl's general string-handling
+and are not part of its pattern matching engine. If any of these are
+encountered by PCRE, an error is generated.
+</P>
+<P>
+6. The Perl escape sequences \p, \P, and \X are supported only if PCRE is
+built with Unicode character property support. The properties that can be
+tested with \p and \P are limited to the general category properties such as
+Lu and Nd, script names such as Greek or Han, and the derived properties Any
+and L&.
+</P>
+<P>
+7. PCRE does support the \Q...\E escape for quoting substrings. Characters in
+between are treated as literals. This is slightly different from Perl in that $
+and @ are also handled as literals inside the quotes. In Perl, they cause
+variable interpolation (but of course PCRE does not have variables). Note the
+following examples:
+<pre>
+    Pattern            PCRE matches      Perl matches
+
+    \Qabc$xyz\E        abc$xyz           abc followed by the contents of $xyz
+    \Qabc\$xyz\E       abc\$xyz          abc\$xyz
+    \Qabc\E\$\Qxyz\E   abc$xyz           abc$xyz
+</pre>
+The \Q...\E sequence is recognized both inside and outside character classes.
+</P>
+<P>
+8. Fairly obviously, PCRE does not support the (?{code}) and (??{code})
+constructions. However, there is support for recursive patterns. This is not
+available in Perl 5.8, but will be in Perl 5.10. Also, the PCRE "callout"
+feature allows an external function to be called during pattern matching. See
+the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation for details.
+</P>
+<P>
+9. Subpatterns that are called recursively or as "subroutines" are always
+treated as atomic groups in PCRE. This is like Python, but unlike Perl.
+</P>
+<P>
+10. There are some differences that are concerned with the settings of captured
+strings when part of a pattern is repeated. For example, matching "aba" against
+the pattern /^(a(b)?)+$/ in Perl leaves $2 unset, but in PCRE it is set to "b".
+</P>
+<P>
+11. PCRE does support Perl 5.10's backtracking verbs (*ACCEPT), (*FAIL), (*F),
+(*COMMIT), (*PRUNE), (*SKIP), and (*THEN), but only in the forms without an
+argument. PCRE does not support (*MARK). If (*ACCEPT) is within capturing
+parentheses, PCRE does not set that capture group; this is different to Perl.
+</P>
+<P>
+12. PCRE provides some extensions to the Perl regular expression facilities.
+Perl 5.10 will include new features that are not in earlier versions, some of
+which (such as named parentheses) have been in PCRE for some time. This list is
+with respect to Perl 5.10:
+<br>
+<br>
+(a) Although lookbehind assertions must match fixed length strings, each
+alternative branch of a lookbehind assertion can match a different length of
+string. Perl requires them all to have the same length.
+<br>
+<br>
+(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $
+meta-character matches only at the very end of the string.
+<br>
+<br>
+(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special
+meaning is faulted. Otherwise, like Perl, the backslash is quietly ignored.
+(Perl can be made to issue a warning.)
+<br>
+<br>
+(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is
+inverted, that is, by default they are not greedy, but if followed by a
+question mark they are.
+<br>
+<br>
+(e) PCRE_ANCHORED can be used at matching time to force a pattern to be tried
+only at the first matching position in the subject string.
+<br>
+<br>
+(f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and PCRE_NO_AUTO_CAPTURE
+options for <b>pcre_exec()</b> have no Perl equivalents.
+<br>
+<br>
+(g) The \R escape sequence can be restricted to match only CR, LF, or CRLF
+by the PCRE_BSR_ANYCRLF option.
+<br>
+<br>
+(h) The callout facility is PCRE-specific.
+<br>
+<br>
+(i) The partial matching facility is PCRE-specific.
+<br>
+<br>
+(j) Patterns compiled by PCRE can be saved and re-used at a later time, even on
+different hosts that have the other endianness.
+<br>
+<br>
+(k) The alternative matching function (<b>pcre_dfa_exec()</b>) matches in a
+different way and is not Perl-compatible.
+<br>
+<br>
+(l) PCRE recognizes some special sequences such as (*CR) at the start of
+a pattern that set overall options that cannot be changed within the pattern.
+</P>
+<br><b>
+AUTHOR
+</b><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><b>
+REVISION
+</b><br>
+<P>
+Last updated: 11 September 2007
+<br>
+Copyright &copy; 1997-2007 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcrecpp.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,365 @@
+<html>
+<head>
+<title>pcrecpp specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcrecpp man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS OF C++ WRAPPER</a>
+<li><a name="TOC2" href="#SEC2">DESCRIPTION</a>
+<li><a name="TOC3" href="#SEC3">MATCHING INTERFACE</a>
+<li><a name="TOC4" href="#SEC4">QUOTING METACHARACTERS</a>
+<li><a name="TOC5" href="#SEC5">PARTIAL MATCHES</a>
+<li><a name="TOC6" href="#SEC6">UTF-8 AND THE MATCHING INTERFACE</a>
+<li><a name="TOC7" href="#SEC7">PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE</a>
+<li><a name="TOC8" href="#SEC8">SCANNING TEXT INCREMENTALLY</a>
+<li><a name="TOC9" href="#SEC9">PARSING HEX/OCTAL/C-RADIX NUMBERS</a>
+<li><a name="TOC10" href="#SEC10">REPLACING PARTS OF STRINGS</a>
+<li><a name="TOC11" href="#SEC11">AUTHOR</a>
+<li><a name="TOC12" href="#SEC12">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS OF C++ WRAPPER</a><br>
+<P>
+<b>#include &#60;pcrecpp.h&#62;</b>
+</P>
+<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
+<P>
+The C++ wrapper for PCRE was provided by Google Inc. Some additional
+functionality was added by Giuseppe Maxia. This brief man page was constructed
+from the notes in the <i>pcrecpp.h</i> file, which should be consulted for
+further details.
+</P>
+<br><a name="SEC3" href="#TOC1">MATCHING INTERFACE</a><br>
+<P>
+The "FullMatch" operation checks that supplied text matches a supplied pattern
+exactly. If pointer arguments are supplied, it copies matched sub-strings that
+match sub-patterns into them.
+<pre>
+  Example: successful match
+     pcrecpp::RE re("h.*o");
+     re.FullMatch("hello");
+
+  Example: unsuccessful match (requires full match):
+     pcrecpp::RE re("e");
+     !re.FullMatch("hello");
+
+  Example: creating a temporary RE object:
+     pcrecpp::RE("h.*o").FullMatch("hello");
+</pre>
+You can pass in a "const char*" or a "string" for "text". The examples below
+tend to use a const char*. You can, as in the different examples above, store
+the RE object explicitly in a variable or use a temporary RE object. The
+examples below use one mode or the other arbitrarily. Either could correctly be
+used for any of these examples.
+</P>
+<P>
+You must supply extra pointer arguments to extract matched subpieces.
+<pre>
+  Example: extracts "ruby" into "s" and 1234 into "i"
+     int i;
+     string s;
+     pcrecpp::RE re("(\\w+):(\\d+)");
+     re.FullMatch("ruby:1234", &s, &i);
+
+  Example: does not try to extract any extra sub-patterns
+     re.FullMatch("ruby:1234", &s);
+
+  Example: does not try to extract into NULL
+     re.FullMatch("ruby:1234", NULL, &i);
+
+  Example: integer overflow causes failure
+     !re.FullMatch("ruby:1234567891234", NULL, &i);
+
+  Example: fails because there aren't enough sub-patterns:
+     !pcrecpp::RE("\\w+:\\d+").FullMatch("ruby:1234", &s);
+
+  Example: fails because string cannot be stored in integer
+     !pcrecpp::RE("(.*)").FullMatch("ruby", &i);
+</pre>
+The provided pointer arguments can be pointers to any scalar numeric
+type, or one of:
+<pre>
+   string        (matched piece is copied to string)
+   StringPiece   (StringPiece is mutated to point to matched piece)
+   T             (where "bool T::ParseFrom(const char*, int)" exists)
+   NULL          (the corresponding matched sub-pattern is not copied)
+</pre>
+The function returns true iff all of the following conditions are satisfied:
+<pre>
+  a. "text" matches "pattern" exactly;
+
+  b. The number of matched sub-patterns is &#62;= number of supplied
+     pointers;
+
+  c. The "i"th argument has a suitable type for holding the
+     string captured as the "i"th sub-pattern. If you pass in
+     void * NULL for the "i"th argument, or a non-void * NULL
+     of the correct type, or pass fewer arguments than the
+     number of sub-patterns, "i"th captured sub-pattern is
+     ignored.
+</pre>
+CAVEAT: An optional sub-pattern that does not exist in the matched
+string is assigned the empty string. Therefore, the following will
+return false (because the empty string is not a valid number):
+<pre>
+   int number;
+   pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
+</pre>
+The matching interface supports at most 16 arguments per call.
+If you need more, consider using the more general interface
+<b>pcrecpp::RE::DoMatch</b>. See <b>pcrecpp.h</b> for the signature for
+<b>DoMatch</b>.
+</P>
+<br><a name="SEC4" href="#TOC1">QUOTING METACHARACTERS</a><br>
+<P>
+You can use the "QuoteMeta" operation to insert backslashes before all
+potentially meaningful characters in a string. The returned string, used as a
+regular expression, will exactly match the original string.
+<pre>
+  Example:
+     string quoted = RE::QuoteMeta(unquoted);
+</pre>
+Note that it's legal to escape a character even if it has no special meaning in
+a regular expression -- so this function does that. (This also makes it
+identical to the perl function of the same name; see "perldoc -f quotemeta".)
+For example, "1.5-2.0?" becomes "1\.5\-2\.0\?".
+</P>
+<br><a name="SEC5" href="#TOC1">PARTIAL MATCHES</a><br>
+<P>
+You can use the "PartialMatch" operation when you want the pattern
+to match any substring of the text.
+<pre>
+  Example: simple search for a string:
+     pcrecpp::RE("ell").PartialMatch("hello");
+
+  Example: find first number in a string:
+     int number;
+     pcrecpp::RE re("(\\d+)");
+     re.PartialMatch("x*100 + 20", &number);
+     assert(number == 100);
+</PRE>
+</P>
+<br><a name="SEC6" href="#TOC1">UTF-8 AND THE MATCHING INTERFACE</a><br>
+<P>
+By default, pattern and text are plain text, one byte per character. The UTF8
+flag, passed to the constructor, causes both pattern and string to be treated
+as UTF-8 text, still a byte stream but potentially multiple bytes per
+character. In practice, the text is likelier to be UTF-8 than the pattern, but
+the match returned may depend on the UTF8 flag, so always use it when matching
+UTF8 text. For example, "." will match one byte normally but with UTF8 set may
+match up to three bytes of a multi-byte character.
+<pre>
+  Example:
+     pcrecpp::RE_Options options;
+     options.set_utf8();
+     pcrecpp::RE re(utf8_pattern, options);
+     re.FullMatch(utf8_string);
+
+  Example: using the convenience function UTF8():
+     pcrecpp::RE re(utf8_pattern, pcrecpp::UTF8());
+     re.FullMatch(utf8_string);
+</pre>
+NOTE: The UTF8 flag is ignored if pcre was not configured with the
+<pre>
+      --enable-utf8 flag.
+</PRE>
+</P>
+<br><a name="SEC7" href="#TOC1">PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE</a><br>
+<P>
+PCRE defines some modifiers to change the behavior of the regular expression
+engine. The C++ wrapper defines an auxiliary class, RE_Options, as a vehicle to
+pass such modifiers to a RE class. Currently, the following modifiers are
+supported:
+<pre>
+   modifier              description               Perl corresponding
+
+   PCRE_CASELESS         case insensitive match      /i
+   PCRE_MULTILINE        multiple lines match        /m
+   PCRE_DOTALL           dot matches newlines        /s
+   PCRE_DOLLAR_ENDONLY   $ matches only at end       N/A
+   PCRE_EXTRA            strict escape parsing       N/A
+   PCRE_EXTENDED         ignore whitespaces          /x
+   PCRE_UTF8             handles UTF8 chars          built-in
+   PCRE_UNGREEDY         reverses * and *?           N/A
+   PCRE_NO_AUTO_CAPTURE  disables capturing parens   N/A (*)
+</pre>
+(*) Both Perl and PCRE allow non capturing parentheses by means of the
+"?:" modifier within the pattern itself. e.g. (?:ab|cd) does not
+capture, while (ab|cd) does.
+</P>
+<P>
+For a full account on how each modifier works, please check the
+PCRE API reference page.
+</P>
+<P>
+For each modifier, there are two member functions whose name is made
+out of the modifier in lowercase, without the "PCRE_" prefix. For
+instance, PCRE_CASELESS is handled by
+<pre>
+  bool caseless()
+</pre>
+which returns true if the modifier is set, and
+<pre>
+  RE_Options & set_caseless(bool)
+</pre>
+which sets or unsets the modifier. Moreover, PCRE_EXTRA_MATCH_LIMIT can be
+accessed through the <b>set_match_limit()</b> and <b>match_limit()</b> member
+functions. Setting <i>match_limit</i> to a non-zero value will limit the
+execution of pcre to keep it from doing bad things like blowing the stack or
+taking an eternity to return a result. A value of 5000 is good enough to stop
+stack blowup in a 2MB thread stack. Setting <i>match_limit</i> to zero disables
+match limiting. Alternatively, you can call <b>match_limit_recursion()</b>
+which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much PCRE
+recurses. <b>match_limit()</b> limits the number of matches PCRE does;
+<b>match_limit_recursion()</b> limits the depth of internal recursion, and
+therefore the amount of stack that is used.
+</P>
+<P>
+Normally, to pass one or more modifiers to a RE class, you declare
+a <i>RE_Options</i> object, set the appropriate options, and pass this
+object to a RE constructor. Example:
+<pre>
+   RE_options opt;
+   opt.set_caseless(true);
+   if (RE("HELLO", opt).PartialMatch("hello world")) ...
+</pre>
+RE_options has two constructors. The default constructor takes no arguments and
+creates a set of flags that are off by default. The optional parameter
+<i>option_flags</i> is to facilitate transfer of legacy code from C programs.
+This lets you do
+<pre>
+   RE(pattern,
+     RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
+</pre>
+However, new code is better off doing
+<pre>
+   RE(pattern,
+     RE_Options().set_caseless(true).set_multiline(true))
+       .PartialMatch(str);
+</pre>
+If you are going to pass one of the most used modifiers, there are some
+convenience functions that return a RE_Options class with the
+appropriate modifier already set: <b>CASELESS()</b>, <b>UTF8()</b>,
+<b>MULTILINE()</b>, <b>DOTALL</b>(), and <b>EXTENDED()</b>.
+</P>
+<P>
+If you need to set several options at once, and you don't want to go through
+the pains of declaring a RE_Options object and setting several options, there
+is a parallel method that give you such ability on the fly. You can concatenate
+several <b>set_xxxxx()</b> member functions, since each of them returns a
+reference to its class object. For example, to pass PCRE_CASELESS,
+PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one statement, you may write:
+<pre>
+   RE(" ^ xyz \\s+ .* blah$",
+     RE_Options()
+       .set_caseless(true)
+       .set_extended(true)
+       .set_multiline(true)).PartialMatch(sometext);
+
+</PRE>
+</P>
+<br><a name="SEC8" href="#TOC1">SCANNING TEXT INCREMENTALLY</a><br>
+<P>
+The "Consume" operation may be useful if you want to repeatedly
+match regular expressions at the front of a string and skip over
+them as they match. This requires use of the "StringPiece" type,
+which represents a sub-range of a real string. Like RE, StringPiece
+is defined in the pcrecpp namespace.
+<pre>
+  Example: read lines of the form "var = value" from a string.
+     string contents = ...;                 // Fill string somehow
+     pcrecpp::StringPiece input(contents);  // Wrap in a StringPiece
+</PRE>
+</P>
+<P>
+<pre>
+     string var;
+     int value;
+     pcrecpp::RE re("(\\w+) = (\\d+)\n");
+     while (re.Consume(&input, &var, &value)) {
+       ...;
+     }
+</pre>
+Each successful call to "Consume" will set "var/value", and also
+advance "input" so it points past the matched text.
+</P>
+<P>
+The "FindAndConsume" operation is similar to "Consume" but does not
+anchor your match at the beginning of the string. For example, you
+could extract all words from a string by repeatedly calling
+<pre>
+  pcrecpp::RE("(\\w+)").FindAndConsume(&input, &word)
+</PRE>
+</P>
+<br><a name="SEC9" href="#TOC1">PARSING HEX/OCTAL/C-RADIX NUMBERS</a><br>
+<P>
+By default, if you pass a pointer to a numeric value, the
+corresponding text is interpreted as a base-10 number. You can
+instead wrap the pointer with a call to one of the operators Hex(),
+Octal(), or CRadix() to interpret the text in another base. The
+CRadix operator interprets C-style "0" (base-8) and "0x" (base-16)
+prefixes, but defaults to base-10.
+<pre>
+  Example:
+    int a, b, c, d;
+    pcrecpp::RE re("(.*) (.*) (.*) (.*)");
+    re.FullMatch("100 40 0100 0x40",
+                 pcrecpp::Octal(&a), pcrecpp::Hex(&b),
+                 pcrecpp::CRadix(&c), pcrecpp::CRadix(&d));
+</pre>
+will leave 64 in a, b, c, and d.
+</P>
+<br><a name="SEC10" href="#TOC1">REPLACING PARTS OF STRINGS</a><br>
+<P>
+You can replace the first match of "pattern" in "str" with "rewrite".
+Within "rewrite", backslash-escaped digits (\1 to \9) can be
+used to insert text matching corresponding parenthesized group
+from the pattern. \0 in "rewrite" refers to the entire matching
+text. For example:
+<pre>
+  string s = "yabba dabba doo";
+  pcrecpp::RE("b+").Replace("d", &s);
+</pre>
+will leave "s" containing "yada dabba doo". The result is true if the pattern
+matches and a replacement occurs, false otherwise.
+</P>
+<P>
+<b>GlobalReplace</b> is like <b>Replace</b> except that it replaces all
+occurrences of the pattern in the string with the rewrite. Replacements are
+not subject to re-matching. For example:
+<pre>
+  string s = "yabba dabba doo";
+  pcrecpp::RE("b+").GlobalReplace("d", &s);
+</pre>
+will leave "s" containing "yada dada doo". It returns the number of
+replacements made.
+</P>
+<P>
+<b>Extract</b> is like <b>Replace</b>, except that if the pattern matches,
+"rewrite" is copied into "out" (an additional argument) with substitutions.
+The non-matching portions of "text" are ignored. Returns true iff a match
+occurred and the extraction happened successfully;  if no match occurs, the
+string is left unaffected.
+</P>
+<br><a name="SEC11" href="#TOC1">AUTHOR</a><br>
+<P>
+The C++ wrapper was contributed by Google Inc.
+<br>
+Copyright &copy; 2007 Google Inc.
+<br>
+</P>
+<br><a name="SEC12" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 12 November 2007
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcregrep.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,516 @@
+<html>
+<head>
+<title>pcregrep specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcregrep man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
+<li><a name="TOC2" href="#SEC2">DESCRIPTION</a>
+<li><a name="TOC3" href="#SEC3">SUPPORT FOR COMPRESSED FILES</a>
+<li><a name="TOC4" href="#SEC4">OPTIONS</a>
+<li><a name="TOC5" href="#SEC5">ENVIRONMENT VARIABLES</a>
+<li><a name="TOC6" href="#SEC6">NEWLINES</a>
+<li><a name="TOC7" href="#SEC7">OPTIONS COMPATIBILITY</a>
+<li><a name="TOC8" href="#SEC8">OPTIONS WITH DATA</a>
+<li><a name="TOC9" href="#SEC9">MATCHING ERRORS</a>
+<li><a name="TOC10" href="#SEC10">DIAGNOSTICS</a>
+<li><a name="TOC11" href="#SEC11">SEE ALSO</a>
+<li><a name="TOC12" href="#SEC12">AUTHOR</a>
+<li><a name="TOC13" href="#SEC13">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
+<P>
+<b>pcregrep [options] [long options] [pattern] [path1 path2 ...]</b>
+</P>
+<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
+<P>
+<b>pcregrep</b> searches files for character patterns, in the same way as other
+grep commands do, but it uses the PCRE regular expression library to support
+patterns that are compatible with the regular expressions of Perl 5. See
+<a href="pcrepattern.html"><b>pcrepattern</b>(3)</a>
+for a full description of syntax and semantics of the regular expressions
+that PCRE supports.
+</P>
+<P>
+Patterns, whether supplied on the command line or in a separate file, are given
+without delimiters. For example:
+<pre>
+  pcregrep Thursday /etc/motd
+</pre>
+If you attempt to use delimiters (for example, by surrounding a pattern with
+slashes, as is common in Perl scripts), they are interpreted as part of the
+pattern. Quotes can of course be used to delimit patterns on the command line
+because they are interpreted by the shell, and indeed they are required if a
+pattern contains white space or shell metacharacters.
+</P>
+<P>
+The first argument that follows any option settings is treated as the single
+pattern to be matched when neither <b>-e</b> nor <b>-f</b> is present.
+Conversely, when one or both of these options are used to specify patterns, all
+arguments are treated as path names. At least one of <b>-e</b>, <b>-f</b>, or an
+argument pattern must be provided.
+</P>
+<P>
+If no files are specified, <b>pcregrep</b> reads the standard input. The
+standard input can also be referenced by a name consisting of a single hyphen.
+For example:
+<pre>
+  pcregrep some-pattern /file1 - /file3
+</pre>
+By default, each line that matches a pattern is copied to the standard
+output, and if there is more than one file, the file name is output at the
+start of each line, followed by a colon. However, there are options that can
+change how <b>pcregrep</b> behaves. In particular, the <b>-M</b> option makes it
+possible to search for patterns that span line boundaries. What defines a line
+boundary is controlled by the <b>-N</b> (<b>--newline</b>) option.
+</P>
+<P>
+Patterns are limited to 8K or BUFSIZ characters, whichever is the greater.
+BUFSIZ is defined in <b>&#60;stdio.h&#62;</b>. When there is more than one pattern
+(specified by the use of <b>-e</b> and/or <b>-f</b>), each pattern is applied to
+each line in the order in which they are defined, except that all the <b>-e</b>
+patterns are tried before the <b>-f</b> patterns. As soon as one pattern matches
+(or fails to match when <b>-v</b> is used), no further patterns are considered.
+</P>
+<P>
+When <b>--only-matching</b>, <b>--file-offsets</b>, or <b>--line-offsets</b>
+is used, the output is the part of the line that matched (either shown
+literally, or as an offset). In this case, scanning resumes immediately
+following the match, so that further matches on the same line can be found.
+If there are multiple patterns, they are all tried on the remainder of the
+line. However, patterns that follow the one that matched are not tried on the
+earlier part of the line.
+</P>
+<P>
+If the <b>LC_ALL</b> or <b>LC_CTYPE</b> environment variable is set,
+<b>pcregrep</b> uses the value to set a locale when calling the PCRE library.
+The <b>--locale</b> option can be used to override this.
+</P>
+<br><a name="SEC3" href="#TOC1">SUPPORT FOR COMPRESSED FILES</a><br>
+<P>
+It is possible to compile <b>pcregrep</b> so that it uses <b>libz</b> or
+<b>libbz2</b> to read files whose names end in <b>.gz</b> or <b>.bz2</b>,
+respectively. You can find out whether your binary has support for one or both
+of these file types by running it with the <b>--help</b> option. If the
+appropriate support is not present, files are treated as plain text. The
+standard input is always so treated.
+</P>
+<br><a name="SEC4" href="#TOC1">OPTIONS</a><br>
+<P>
+<b>--</b>
+This terminate the list of options. It is useful if the next item on the
+command line starts with a hyphen but is not an option. This allows for the
+processing of patterns and filenames that start with hyphens.
+</P>
+<P>
+<b>-A</b> <i>number</i>, <b>--after-context=</b><i>number</i>
+Output <i>number</i> lines of context after each matching line. If filenames
+and/or line numbers are being output, a hyphen separator is used instead of a
+colon for the context lines. A line containing "--" is output between each
+group of lines, unless they are in fact contiguous in the input file. The value
+of <i>number</i> is expected to be relatively small. However, <b>pcregrep</b>
+guarantees to have up to 8K of following text available for context output.
+</P>
+<P>
+<b>-B</b> <i>number</i>, <b>--before-context=</b><i>number</i>
+Output <i>number</i> lines of context before each matching line. If filenames
+and/or line numbers are being output, a hyphen separator is used instead of a
+colon for the context lines. A line containing "--" is output between each
+group of lines, unless they are in fact contiguous in the input file. The value
+of <i>number</i> is expected to be relatively small. However, <b>pcregrep</b>
+guarantees to have up to 8K of preceding text available for context output.
+</P>
+<P>
+<b>-C</b> <i>number</i>, <b>--context=</b><i>number</i>
+Output <i>number</i> lines of context both before and after each matching line.
+This is equivalent to setting both <b>-A</b> and <b>-B</b> to the same value.
+</P>
+<P>
+<b>-c</b>, <b>--count</b>
+Do not output individual lines; instead just output a count of the number of
+lines that would otherwise have been output. If several files are given, a
+count is output for each of them. In this mode, the <b>-A</b>, <b>-B</b>, and
+<b>-C</b> options are ignored.
+</P>
+<P>
+<b>--colour</b>, <b>--color</b>
+If this option is given without any data, it is equivalent to "--colour=auto".
+If data is required, it must be given in the same shell item, separated by an
+equals sign.
+</P>
+<P>
+<b>--colour=</b><i>value</i>, <b>--color=</b><i>value</i>
+This option specifies under what circumstances the part of a line that matched
+a pattern should be coloured in the output. The value may be "never" (the
+default), "always", or "auto". In the latter case, colouring happens only if
+the standard output is connected to a terminal. The colour can be specified by
+setting the environment variable PCREGREP_COLOUR or PCREGREP_COLOR. The value
+of this variable should be a string of two numbers, separated by a semicolon.
+They are copied directly into the control string for setting colour on a
+terminal, so it is your responsibility to ensure that they make sense. If
+neither of the environment variables is set, the default is "1;31", which gives
+red.
+</P>
+<P>
+<b>-D</b> <i>action</i>, <b>--devices=</b><i>action</i>
+If an input path is not a regular file or a directory, "action" specifies how
+it is to be processed. Valid values are "read" (the default) or "skip"
+(silently skip the path).
+</P>
+<P>
+<b>-d</b> <i>action</i>, <b>--directories=</b><i>action</i>
+If an input path is a directory, "action" specifies how it is to be processed.
+Valid values are "read" (the default), "recurse" (equivalent to the <b>-r</b>
+option), or "skip" (silently skip the path). In the default case, directories
+are read as if they were ordinary files. In some operating systems the effect
+of reading a directory like this is an immediate end-of-file.
+</P>
+<P>
+<b>-e</b> <i>pattern</i>, <b>--regex=</b><i>pattern</i>, <b>--regexp=</b><i>pattern</i>
+Specify a pattern to be matched. This option can be used multiple times in
+order to specify several patterns. It can also be used as a way of specifying a
+single pattern that starts with a hyphen. When <b>-e</b> is used, no argument
+pattern is taken from the command line; all arguments are treated as file
+names. There is an overall maximum of 100 patterns. They are applied to each
+line in the order in which they are defined until one matches (or fails to
+match if <b>-v</b> is used). If <b>-f</b> is used with <b>-e</b>, the command line
+patterns are matched first, followed by the patterns from the file, independent
+of the order in which these options are specified. Note that multiple use of
+<b>-e</b> is not the same as a single pattern with alternatives. For example,
+X|Y finds the first character in a line that is X or Y, whereas if the two
+patterns are given separately, <b>pcregrep</b> finds X if it is present, even if
+it follows Y in the line. It finds Y only if there is no X in the line. This
+really matters only if you are using <b>-o</b> to show the part(s) of the line
+that matched.
+</P>
+<P>
+<b>--exclude</b>=<i>pattern</i>
+When <b>pcregrep</b> is searching the files in a directory as a consequence of
+the <b>-r</b> (recursive search) option, any regular files whose names match the
+pattern are excluded. Subdirectories are not excluded by this option; they are
+searched recursively, subject to the <b>--exclude_dir</b> and
+<b>--include_dir</b> options. The pattern is a PCRE regular expression, and is
+matched against the final component of the file name (not the entire path). If
+a file name matches both <b>--include</b> and <b>--exclude</b>, it is excluded.
+There is no short form for this option.
+</P>
+<P>
+<b>--exclude_dir</b>=<i>pattern</i>
+When <b>pcregrep</b> is searching the contents of a directory as a consequence
+of the <b>-r</b> (recursive search) option, any subdirectories whose names match
+the pattern are excluded. (Note that the \fP--exclude\fP option does not affect
+subdirectories.) The pattern is a PCRE regular expression, and is matched
+against the final component of the name (not the entire path). If a
+subdirectory name matches both <b>--include_dir</b> and <b>--exclude_dir</b>, it
+is excluded. There is no short form for this option.
+</P>
+<P>
+<b>-F</b>, <b>--fixed-strings</b>
+Interpret each pattern as a list of fixed strings, separated by newlines,
+instead of as a regular expression. The <b>-w</b> (match as a word) and <b>-x</b>
+(match whole line) options can be used with <b>-F</b>. They apply to each of the
+fixed strings. A line is selected if any of the fixed strings are found in it
+(subject to <b>-w</b> or <b>-x</b>, if present).
+</P>
+<P>
+<b>-f</b> <i>filename</i>, <b>--file=</b><i>filename</i>
+Read a number of patterns from the file, one per line, and match them against
+each line of input. A data line is output if any of the patterns match it. The
+filename can be given as "-" to refer to the standard input. When <b>-f</b> is
+used, patterns specified on the command line using <b>-e</b> may also be
+present; they are tested before the file's patterns. However, no other pattern
+is taken from the command line; all arguments are treated as file names. There
+is an overall maximum of 100 patterns. Trailing white space is removed from
+each line, and blank lines are ignored. An empty file contains no patterns and
+therefore matches nothing. See also the comments about multiple patterns versus
+a single pattern with alternatives in the description of <b>-e</b> above.
+</P>
+<P>
+<b>--file-offsets</b>
+Instead of showing lines or parts of lines that match, show each match as an
+offset from the start of the file and a length, separated by a comma. In this
+mode, no context is shown. That is, the <b>-A</b>, <b>-B</b>, and <b>-C</b>
+options are ignored. If there is more than one match in a line, each of them is
+shown separately. This option is mutually exclusive with <b>--line-offsets</b>
+and <b>--only-matching</b>.
+</P>
+<P>
+<b>-H</b>, <b>--with-filename</b>
+Force the inclusion of the filename at the start of output lines when searching
+a single file. By default, the filename is not shown in this case. For matching
+lines, the filename is followed by a colon and a space; for context lines, a
+hyphen separator is used. If a line number is also being output, it follows the
+file name without a space.
+</P>
+<P>
+<b>-h</b>, <b>--no-filename</b>
+Suppress the output filenames when searching multiple files. By default,
+filenames are shown when multiple files are searched. For matching lines, the
+filename is followed by a colon and a space; for context lines, a hyphen
+separator is used. If a line number is also being output, it follows the file
+name without a space.
+</P>
+<P>
+<b>--help</b>
+Output a help message, giving brief details of the command options and file
+type support, and then exit.
+</P>
+<P>
+<b>-i</b>, <b>--ignore-case</b>
+Ignore upper/lower case distinctions during comparisons.
+</P>
+<P>
+<b>--include</b>=<i>pattern</i>
+When <b>pcregrep</b> is searching the files in a directory as a consequence of
+the <b>-r</b> (recursive search) option, only those regular files whose names
+match the pattern are included. Subdirectories are always included and searched
+recursively, subject to the \fP--include_dir\fP and <b>--exclude_dir</b>
+options. The pattern is a PCRE regular expression, and is matched against the
+final component of the file name (not the entire path). If a file name matches
+both <b>--include</b> and <b>--exclude</b>, it is excluded. There is no short
+form for this option.
+</P>
+<P>
+<b>--include_dir</b>=<i>pattern</i>
+When <b>pcregrep</b> is searching the contents of a directory as a consequence
+of the <b>-r</b> (recursive search) option, only those subdirectories whose
+names match the pattern are included. (Note that the <b>--include</b> option
+does not affect subdirectories.) The pattern is a PCRE regular expression, and
+is matched against the final component of the name (not the entire path). If a
+subdirectory name matches both <b>--include_dir</b> and <b>--exclude_dir</b>, it
+is excluded. There is no short form for this option.
+</P>
+<P>
+<b>-L</b>, <b>--files-without-match</b>
+Instead of outputting lines from the files, just output the names of the files
+that do not contain any lines that would have been output. Each file name is
+output once, on a separate line.
+</P>
+<P>
+<b>-l</b>, <b>--files-with-matches</b>
+Instead of outputting lines from the files, just output the names of the files
+containing lines that would have been output. Each file name is output
+once, on a separate line. Searching stops as soon as a matching line is found
+in a file.
+</P>
+<P>
+<b>--label</b>=<i>name</i>
+This option supplies a name to be used for the standard input when file names
+are being output. If not supplied, "(standard input)" is used. There is no
+short form for this option.
+</P>
+<P>
+<b>--line-offsets</b>
+Instead of showing lines or parts of lines that match, show each match as a
+line number, the offset from the start of the line, and a length. The line
+number is terminated by a colon (as usual; see the <b>-n</b> option), and the
+offset and length are separated by a comma. In this mode, no context is shown.
+That is, the <b>-A</b>, <b>-B</b>, and <b>-C</b> options are ignored. If there is
+more than one match in a line, each of them is shown separately. This option is
+mutually exclusive with <b>--file-offsets</b> and <b>--only-matching</b>.
+</P>
+<P>
+<b>--locale</b>=<i>locale-name</i>
+This option specifies a locale to be used for pattern matching. It overrides
+the value in the <b>LC_ALL</b> or <b>LC_CTYPE</b> environment variables. If no
+locale is specified, the PCRE library's default (usually the "C" locale) is
+used. There is no short form for this option.
+</P>
+<P>
+<b>-M</b>, <b>--multiline</b>
+Allow patterns to match more than one line. When this option is given, patterns
+may usefully contain literal newline characters and internal occurrences of ^
+and $ characters. The output for any one match may consist of more than one
+line. When this option is set, the PCRE library is called in "multiline" mode.
+There is a limit to the number of lines that can be matched, imposed by the way
+that <b>pcregrep</b> buffers the input file as it scans it. However,
+<b>pcregrep</b> ensures that at least 8K characters or the rest of the document
+(whichever is the shorter) are available for forward matching, and similarly
+the previous 8K characters (or all the previous characters, if fewer than 8K)
+are guaranteed to be available for lookbehind assertions.
+</P>
+<P>
+<b>-N</b> <i>newline-type</i>, <b>--newline=</b><i>newline-type</i>
+The PCRE library supports five different conventions for indicating
+the ends of lines. They are the single-character sequences CR (carriage return)
+and LF (linefeed), the two-character sequence CRLF, an "anycrlf" convention,
+which recognizes any of the preceding three types, and an "any" convention, in
+which any Unicode line ending sequence is assumed to end a line. The Unicode
+sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF
+(formfeed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and
+PS (paragraph separator, U+2029).
+<br>
+<br>
+When the PCRE library is built, a default line-ending sequence is specified.
+This is normally the standard sequence for the operating system. Unless
+otherwise specified by this option, <b>pcregrep</b> uses the library's default.
+The possible values for this option are CR, LF, CRLF, ANYCRLF, or ANY. This
+makes it possible to use <b>pcregrep</b> on files that have come from other
+environments without having to modify their line endings. If the data that is
+being scanned does not agree with the convention set by this option,
+<b>pcregrep</b> may behave in strange ways.
+</P>
+<P>
+<b>-n</b>, <b>--line-number</b>
+Precede each output line by its line number in the file, followed by a colon
+and a space for matching lines or a hyphen and a space for context lines. If
+the filename is also being output, it precedes the line number. This option is
+forced if <b>--line-offsets</b> is used.
+</P>
+<P>
+<b>-o</b>, <b>--only-matching</b>
+Show only the part of the line that matched a pattern. In this mode, no
+context is shown. That is, the <b>-A</b>, <b>-B</b>, and <b>-C</b> options are
+ignored. If there is more than one match in a line, each of them is shown
+separately. If <b>-o</b> is combined with <b>-v</b> (invert the sense of the
+match to find non-matching lines), no output is generated, but the return code
+is set appropriately. This option is mutually exclusive with
+<b>--file-offsets</b> and <b>--line-offsets</b>.
+</P>
+<P>
+<b>-q</b>, <b>--quiet</b>
+Work quietly, that is, display nothing except error messages. The exit
+status indicates whether or not any matches were found.
+</P>
+<P>
+<b>-r</b>, <b>--recursive</b>
+If any given path is a directory, recursively scan the files it contains,
+taking note of any <b>--include</b> and <b>--exclude</b> settings. By default, a
+directory is read as a normal file; in some operating systems this gives an
+immediate end-of-file. This option is a shorthand for setting the <b>-d</b>
+option to "recurse".
+</P>
+<P>
+<b>-s</b>, <b>--no-messages</b>
+Suppress error messages about non-existent or unreadable files. Such files are
+quietly skipped. However, the return code is still 2, even if matches were
+found in other files.
+</P>
+<P>
+<b>-u</b>, <b>--utf-8</b>
+Operate in UTF-8 mode. This option is available only if PCRE has been compiled
+with UTF-8 support. Both patterns and subject lines must be valid strings of
+UTF-8 characters.
+</P>
+<P>
+<b>-V</b>, <b>--version</b>
+Write the version numbers of <b>pcregrep</b> and the PCRE library that is being
+used to the standard error stream.
+</P>
+<P>
+<b>-v</b>, <b>--invert-match</b>
+Invert the sense of the match, so that lines which do <i>not</i> match any of
+the patterns are the ones that are found.
+</P>
+<P>
+<b>-w</b>, <b>--word-regex</b>, <b>--word-regexp</b>
+Force the patterns to match only whole words. This is equivalent to having \b
+at the start and end of the pattern.
+</P>
+<P>
+<b>-x</b>, <b>--line-regex</b>, <b>--line-regexp</b>
+Force the patterns to be anchored (each must start matching at the beginning of
+a line) and in addition, require them to match entire lines. This is
+equivalent to having ^ and $ characters at the start and end of each
+alternative branch in every pattern.
+</P>
+<br><a name="SEC5" href="#TOC1">ENVIRONMENT VARIABLES</a><br>
+<P>
+The environment variables <b>LC_ALL</b> and <b>LC_CTYPE</b> are examined, in that
+order, for a locale. The first one that is set is used. This can be overridden
+by the <b>--locale</b> option. If no locale is set, the PCRE library's default
+(usually the "C" locale) is used.
+</P>
+<br><a name="SEC6" href="#TOC1">NEWLINES</a><br>
+<P>
+The <b>-N</b> (<b>--newline</b>) option allows <b>pcregrep</b> to scan files with
+different newline conventions from the default. However, the setting of this
+option does not affect the way in which <b>pcregrep</b> writes information to
+the standard error and output streams. It uses the string "\n" in C
+<b>printf()</b> calls to indicate newlines, relying on the C I/O library to
+convert this to an appropriate sequence if the output is sent to a file.
+</P>
+<br><a name="SEC7" href="#TOC1">OPTIONS COMPATIBILITY</a><br>
+<P>
+The majority of short and long forms of <b>pcregrep</b>'s options are the same
+as in the GNU <b>grep</b> program. Any long option of the form
+<b>--xxx-regexp</b> (GNU terminology) is also available as <b>--xxx-regex</b>
+(PCRE terminology). However, the <b>--locale</b>, <b>-M</b>, <b>--multiline</b>,
+<b>-u</b>, and <b>--utf-8</b> options are specific to <b>pcregrep</b>.
+</P>
+<br><a name="SEC8" href="#TOC1">OPTIONS WITH DATA</a><br>
+<P>
+There are four different ways in which an option with data can be specified.
+If a short form option is used, the data may follow immediately, or in the next
+command line item. For example:
+<pre>
+  -f/some/file
+  -f /some/file
+</pre>
+If a long form option is used, the data may appear in the same command line
+item, separated by an equals character, or (with one exception) it may appear
+in the next command line item. For example:
+<pre>
+  --file=/some/file
+  --file /some/file
+</pre>
+Note, however, that if you want to supply a file name beginning with ~ as data
+in a shell command, and have the shell expand ~ to a home directory, you must
+separate the file name from the option, because the shell does not treat ~
+specially unless it is at the start of an item.
+</P>
+<P>
+The exception to the above is the <b>--colour</b> (or <b>--color</b>) option,
+for which the data is optional. If this option does have data, it must be given
+in the first form, using an equals character. Otherwise it will be assumed that
+it has no data.
+</P>
+<br><a name="SEC9" href="#TOC1">MATCHING ERRORS</a><br>
+<P>
+It is possible to supply a regular expression that takes a very long time to
+fail to match certain lines. Such patterns normally involve nested indefinite
+repeats, for example: (a+)*\d when matched against a line of a's with no final
+digit. The PCRE matching function has a resource limit that causes it to abort
+in these circumstances. If this happens, <b>pcregrep</b> outputs an error
+message and the line that caused the problem to the standard error stream. If
+there are more than 20 such errors, <b>pcregrep</b> gives up.
+</P>
+<br><a name="SEC10" href="#TOC1">DIAGNOSTICS</a><br>
+<P>
+Exit status is 0 if any matches were found, 1 if no matches were found, and 2
+for syntax errors and non-existent or inacessible files (even if matches were
+found in other files) or too many matching errors. Using the <b>-s</b> option to
+suppress error messages about inaccessble files does not affect the return
+code.
+</P>
+<br><a name="SEC11" href="#TOC1">SEE ALSO</a><br>
+<P>
+<b>pcrepattern</b>(3), <b>pcretest</b>(1).
+</P>
+<br><a name="SEC12" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC13" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 08 March 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcrematching.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,224 @@
+<html>
+<head>
+<title>pcrematching specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcrematching man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE MATCHING ALGORITHMS</a>
+<li><a name="TOC2" href="#SEC2">REGULAR EXPRESSIONS AS TREES</a>
+<li><a name="TOC3" href="#SEC3">THE STANDARD MATCHING ALGORITHM</a>
+<li><a name="TOC4" href="#SEC4">THE ALTERNATIVE MATCHING ALGORITHM</a>
+<li><a name="TOC5" href="#SEC5">ADVANTAGES OF THE ALTERNATIVE ALGORITHM</a>
+<li><a name="TOC6" href="#SEC6">DISADVANTAGES OF THE ALTERNATIVE ALGORITHM</a>
+<li><a name="TOC7" href="#SEC7">AUTHOR</a>
+<li><a name="TOC8" href="#SEC8">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE MATCHING ALGORITHMS</a><br>
+<P>
+This document describes the two different algorithms that are available in PCRE
+for matching a compiled regular expression against a given subject string. The
+"standard" algorithm is the one provided by the <b>pcre_exec()</b> function.
+This works in the same was as Perl's matching function, and provides a
+Perl-compatible matching operation.
+</P>
+<P>
+An alternative algorithm is provided by the <b>pcre_dfa_exec()</b> function;
+this operates in a different way, and is not Perl-compatible. It has advantages
+and disadvantages compared with the standard algorithm, and these are described
+below.
+</P>
+<P>
+When there is only one possible way in which a given subject string can match a
+pattern, the two algorithms give the same answer. A difference arises, however,
+when there are multiple possibilities. For example, if the pattern
+<pre>
+  ^&#60;.*&#62;
+</pre>
+is matched against the string
+<pre>
+  &#60;something&#62; &#60;something else&#62; &#60;something further&#62;
+</pre>
+there are three possible answers. The standard algorithm finds only one of
+them, whereas the alternative algorithm finds all three.
+</P>
+<br><a name="SEC2" href="#TOC1">REGULAR EXPRESSIONS AS TREES</a><br>
+<P>
+The set of strings that are matched by a regular expression can be represented
+as a tree structure. An unlimited repetition in the pattern makes the tree of
+infinite size, but it is still a tree. Matching the pattern to a given subject
+string (from a given starting point) can be thought of as a search of the tree.
+There are two ways to search a tree: depth-first and breadth-first, and these
+correspond to the two matching algorithms provided by PCRE.
+</P>
+<br><a name="SEC3" href="#TOC1">THE STANDARD MATCHING ALGORITHM</a><br>
+<P>
+In the terminology of Jeffrey Friedl's book "Mastering Regular
+Expressions", the standard algorithm is an "NFA algorithm". It conducts a
+depth-first search of the pattern tree. That is, it proceeds along a single
+path through the tree, checking that the subject matches what is required. When
+there is a mismatch, the algorithm tries any alternatives at the current point,
+and if they all fail, it backs up to the previous branch point in the tree, and
+tries the next alternative branch at that level. This often involves backing up
+(moving to the left) in the subject string as well. The order in which
+repetition branches are tried is controlled by the greedy or ungreedy nature of
+the quantifier.
+</P>
+<P>
+If a leaf node is reached, a matching string has been found, and at that point
+the algorithm stops. Thus, if there is more than one possible match, this
+algorithm returns the first one that it finds. Whether this is the shortest,
+the longest, or some intermediate length depends on the way the greedy and
+ungreedy repetition quantifiers are specified in the pattern.
+</P>
+<P>
+Because it ends up with a single path through the tree, it is relatively
+straightforward for this algorithm to keep track of the substrings that are
+matched by portions of the pattern in parentheses. This provides support for
+capturing parentheses and back references.
+</P>
+<br><a name="SEC4" href="#TOC1">THE ALTERNATIVE MATCHING ALGORITHM</a><br>
+<P>
+This algorithm conducts a breadth-first search of the tree. Starting from the
+first matching point in the subject, it scans the subject string from left to
+right, once, character by character, and as it does this, it remembers all the
+paths through the tree that represent valid matches. In Friedl's terminology,
+this is a kind of "DFA algorithm", though it is not implemented as a
+traditional finite state machine (it keeps multiple states active
+simultaneously).
+</P>
+<P>
+The scan continues until either the end of the subject is reached, or there are
+no more unterminated paths. At this point, terminated paths represent the
+different matching possibilities (if there are none, the match has failed).
+Thus, if there is more than one possible match, this algorithm finds all of
+them, and in particular, it finds the longest. In PCRE, there is an option to
+stop the algorithm after the first match (which is necessarily the shortest)
+has been found.
+</P>
+<P>
+Note that all the matches that are found start at the same point in the
+subject. If the pattern
+<pre>
+  cat(er(pillar)?)
+</pre>
+is matched against the string "the caterpillar catchment", the result will be
+the three strings "cat", "cater", and "caterpillar" that start at the fourth
+character of the subject. The algorithm does not automatically move on to find
+matches that start at later positions.
+</P>
+<P>
+There are a number of features of PCRE regular expressions that are not
+supported by the alternative matching algorithm. They are as follows:
+</P>
+<P>
+1. Because the algorithm finds all possible matches, the greedy or ungreedy
+nature of repetition quantifiers is not relevant. Greedy and ungreedy
+quantifiers are treated in exactly the same way. However, possessive
+quantifiers can make a difference when what follows could also match what is
+quantified, for example in a pattern like this:
+<pre>
+  ^a++\w!
+</pre>
+This pattern matches "aaab!" but not "aaa!", which would be matched by a
+non-possessive quantifier. Similarly, if an atomic group is present, it is
+matched as if it were a standalone pattern at the current point, and the
+longest match is then "locked in" for the rest of the overall pattern.
+</P>
+<P>
+2. When dealing with multiple paths through the tree simultaneously, it is not
+straightforward to keep track of captured substrings for the different matching
+possibilities, and PCRE's implementation of this algorithm does not attempt to
+do this. This means that no captured substrings are available.
+</P>
+<P>
+3. Because no substrings are captured, back references within the pattern are
+not supported, and cause errors if encountered.
+</P>
+<P>
+4. For the same reason, conditional expressions that use a backreference as the
+condition or test for a specific group recursion are not supported.
+</P>
+<P>
+5. Because many paths through the tree may be active, the \K escape sequence,
+which resets the start of the match when encountered (but may be on some paths
+and not on others), is not supported. It causes an error if encountered.
+</P>
+<P>
+6. Callouts are supported, but the value of the <i>capture_top</i> field is
+always 1, and the value of the <i>capture_last</i> field is always -1.
+</P>
+<P>
+7. The \C escape sequence, which (in the standard algorithm) matches a single
+byte, even in UTF-8 mode, is not supported because the alternative algorithm
+moves through the subject string one character at a time, for all active paths
+through the tree.
+</P>
+<P>
+8. Except for (*FAIL), the backtracking control verbs such as (*PRUNE) are not
+supported. (*FAIL) is supported, and behaves like a failing negative assertion.
+</P>
+<br><a name="SEC5" href="#TOC1">ADVANTAGES OF THE ALTERNATIVE ALGORITHM</a><br>
+<P>
+Using the alternative matching algorithm provides the following advantages:
+</P>
+<P>
+1. All possible matches (at a single point in the subject) are automatically
+found, and in particular, the longest match is found. To find more than one
+match using the standard algorithm, you have to do kludgy things with
+callouts.
+</P>
+<P>
+2. There is much better support for partial matching. The restrictions on the
+content of the pattern that apply when using the standard algorithm for partial
+matching do not apply to the alternative algorithm. For non-anchored patterns,
+the starting position of a partial match is available.
+</P>
+<P>
+3. Because the alternative algorithm scans the subject string just once, and
+never needs to backtrack, it is possible to pass very long subject strings to
+the matching function in several pieces, checking for partial matching each
+time.
+</P>
+<br><a name="SEC6" href="#TOC1">DISADVANTAGES OF THE ALTERNATIVE ALGORITHM</a><br>
+<P>
+The alternative algorithm suffers from a number of disadvantages:
+</P>
+<P>
+1. It is substantially slower than the standard algorithm. This is partly
+because it has to search for all possible matches, but is also because it is
+less susceptible to optimization.
+</P>
+<P>
+2. Capturing parentheses and back references are not supported.
+</P>
+<P>
+3. Although atomic groups are supported, their use does not provide the
+performance advantage that it does for the standard algorithm.
+</P>
+<br><a name="SEC7" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC8" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 19 April 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcrepartial.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,242 @@
+<html>
+<head>
+<title>pcrepartial specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcrepartial man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PARTIAL MATCHING IN PCRE</a>
+<li><a name="TOC2" href="#SEC2">RESTRICTED PATTERNS FOR PCRE_PARTIAL</a>
+<li><a name="TOC3" href="#SEC3">EXAMPLE OF PARTIAL MATCHING USING PCRETEST</a>
+<li><a name="TOC4" href="#SEC4">MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()</a>
+<li><a name="TOC5" href="#SEC5">AUTHOR</a>
+<li><a name="TOC6" href="#SEC6">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PARTIAL MATCHING IN PCRE</a><br>
+<P>
+In normal use of PCRE, if the subject string that is passed to
+<b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> matches as far as it goes, but is
+too short to match the entire pattern, PCRE_ERROR_NOMATCH is returned. There
+are circumstances where it might be helpful to distinguish this case from other
+cases in which there is no match.
+</P>
+<P>
+Consider, for example, an application where a human is required to type in data
+for a field with specific formatting requirements. An example might be a date
+in the form <i>ddmmmyy</i>, defined by this pattern:
+<pre>
+  ^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$
+</pre>
+If the application sees the user's keystrokes one by one, and can check that
+what has been typed so far is potentially valid, it is able to raise an error
+as soon as a mistake is made, possibly beeping and not reflecting the
+character that has been typed. This immediate feedback is likely to be a better
+user interface than a check that is delayed until the entire string has been
+entered.
+</P>
+<P>
+PCRE supports the concept of partial matching by means of the PCRE_PARTIAL
+option, which can be set when calling <b>pcre_exec()</b> or
+<b>pcre_dfa_exec()</b>. When this flag is set for <b>pcre_exec()</b>, the return
+code PCRE_ERROR_NOMATCH is converted into PCRE_ERROR_PARTIAL if at any time
+during the matching process the last part of the subject string matched part of
+the pattern. Unfortunately, for non-anchored matching, it is not possible to
+obtain the position of the start of the partial match. No captured data is set
+when PCRE_ERROR_PARTIAL is returned.
+</P>
+<P>
+When PCRE_PARTIAL is set for <b>pcre_dfa_exec()</b>, the return code
+PCRE_ERROR_NOMATCH is converted into PCRE_ERROR_PARTIAL if the end of the
+subject is reached, there have been no complete matches, but there is still at
+least one matching possibility. The portion of the string that provided the
+partial match is set as the first matching string.
+</P>
+<P>
+Using PCRE_PARTIAL disables one of PCRE's optimizations. PCRE remembers the
+last literal byte in a pattern, and abandons matching immediately if such a
+byte is not present in the subject string. This optimization cannot be used
+for a subject string that might match only partially.
+</P>
+<br><a name="SEC2" href="#TOC1">RESTRICTED PATTERNS FOR PCRE_PARTIAL</a><br>
+<P>
+Because of the way certain internal optimizations are implemented in the
+<b>pcre_exec()</b> function, the PCRE_PARTIAL option cannot be used with all
+patterns. These restrictions do not apply when <b>pcre_dfa_exec()</b> is used.
+For <b>pcre_exec()</b>, repeated single characters such as
+<pre>
+  a{2,4}
+</pre>
+and repeated single metasequences such as
+<pre>
+  \d+
+</pre>
+are not permitted if the maximum number of occurrences is greater than one.
+Optional items such as \d? (where the maximum is one) are permitted.
+Quantifiers with any values are permitted after parentheses, so the invalid
+examples above can be coded thus:
+<pre>
+  (a){2,4}
+  (\d)+
+</pre>
+These constructions run more slowly, but for the kinds of application that are
+envisaged for this facility, this is not felt to be a major restriction.
+</P>
+<P>
+If PCRE_PARTIAL is set for a pattern that does not conform to the restrictions,
+<b>pcre_exec()</b> returns the error code PCRE_ERROR_BADPARTIAL (-13).
+You can use the PCRE_INFO_OKPARTIAL call to <b>pcre_fullinfo()</b> to find out
+if a compiled pattern can be used for partial matching.
+</P>
+<br><a name="SEC3" href="#TOC1">EXAMPLE OF PARTIAL MATCHING USING PCRETEST</a><br>
+<P>
+If the escape sequence \P is present in a <b>pcretest</b> data line, the
+PCRE_PARTIAL flag is used for the match. Here is a run of <b>pcretest</b> that
+uses the date example quoted above:
+<pre>
+    re&#62; /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
+  data&#62; 25jun04\P
+   0: 25jun04
+   1: jun
+  data&#62; 25dec3\P
+  Partial match
+  data&#62; 3ju\P
+  Partial match
+  data&#62; 3juj\P
+  No match
+  data&#62; j\P
+  No match
+</pre>
+The first data string is matched completely, so <b>pcretest</b> shows the
+matched substrings. The remaining four strings do not match the complete
+pattern, but the first two are partial matches. The same test, using
+<b>pcre_dfa_exec()</b> matching (by means of the \D escape sequence), produces
+the following output:
+<pre>
+    re&#62; /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
+  data&#62; 25jun04\P\D
+   0: 25jun04
+  data&#62; 23dec3\P\D
+  Partial match: 23dec3
+  data&#62; 3ju\P\D
+  Partial match: 3ju
+  data&#62; 3juj\P\D
+  No match
+  data&#62; j\P\D
+  No match
+</pre>
+Notice that in this case the portion of the string that was matched is made
+available.
+</P>
+<br><a name="SEC4" href="#TOC1">MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()</a><br>
+<P>
+When a partial match has been found using <b>pcre_dfa_exec()</b>, it is possible
+to continue the match by providing additional subject data and calling
+<b>pcre_dfa_exec()</b> again with the same compiled regular expression, this
+time setting the PCRE_DFA_RESTART option. You must also pass the same working
+space as before, because this is where details of the previous partial match
+are stored. Here is an example using <b>pcretest</b>, using the \R escape
+sequence to set the PCRE_DFA_RESTART option (\P and \D are as above):
+<pre>
+    re&#62; /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
+  data&#62; 23ja\P\D
+  Partial match: 23ja
+  data&#62; n05\R\D
+   0: n05
+</pre>
+The first call has "23ja" as the subject, and requests partial matching; the
+second call has "n05" as the subject for the continued (restarted) match.
+Notice that when the match is complete, only the last part is shown; PCRE does
+not retain the previously partially-matched string. It is up to the calling
+program to do that if it needs to.
+</P>
+<P>
+You can set PCRE_PARTIAL with PCRE_DFA_RESTART to continue partial matching
+over multiple segments. This facility can be used to pass very long subject
+strings to <b>pcre_dfa_exec()</b>. However, some care is needed for certain
+types of pattern.
+</P>
+<P>
+1. If the pattern contains tests for the beginning or end of a line, you need
+to pass the PCRE_NOTBOL or PCRE_NOTEOL options, as appropriate, when the
+subject string for any call does not contain the beginning or end of a line.
+</P>
+<P>
+2. If the pattern contains backward assertions (including \b or \B), you need
+to arrange for some overlap in the subject strings to allow for this. For
+example, you could pass the subject in chunks that are 500 bytes long, but in
+a buffer of 700 bytes, with the starting offset set to 200 and the previous 200
+bytes at the start of the buffer.
+</P>
+<P>
+3. Matching a subject string that is split into multiple segments does not
+always produce exactly the same result as matching over one single long string.
+The difference arises when there are multiple matching possibilities, because a
+partial match result is given only when there are no completed matches in a
+call to <b>pcre_dfa_exec()</b>. This means that as soon as the shortest match has
+been found, continuation to a new subject segment is no longer possible.
+Consider this <b>pcretest</b> example:
+<pre>
+    re&#62; /dog(sbody)?/
+  data&#62; do\P\D
+  Partial match: do
+  data&#62; gsb\R\P\D
+   0: g
+  data&#62; dogsbody\D
+   0: dogsbody
+   1: dog
+</pre>
+The pattern matches the words "dog" or "dogsbody". When the subject is
+presented in several parts ("do" and "gsb" being the first two) the match stops
+when "dog" has been found, and it is not possible to continue. On the other
+hand, if "dogsbody" is presented as a single string, both matches are found.
+</P>
+<P>
+Because of this phenomenon, it does not usually make sense to end a pattern
+that is going to be matched in this way with a variable repeat.
+</P>
+<P>
+4. Patterns that contain alternatives at the top level which do not all
+start with the same pattern item may not work as expected. For example,
+consider this pattern:
+<pre>
+  1234|3789
+</pre>
+If the first part of the subject is "ABC123", a partial match of the first
+alternative is found at offset 3. There is no partial match for the second
+alternative, because such a match does not start at the same point in the
+subject string. Attempting to continue with the string "789" does not yield a
+match because only those alternatives that match at one point in the subject
+are remembered. The problem arises because the start of the second alternative
+matches within the first alternative. There is no problem with anchored
+patterns or patterns such as:
+<pre>
+  1234|ABCD
+</pre>
+where no string can be a partial match for both alternatives.
+</P>
+<br><a name="SEC5" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC6" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 04 June 2007
+<br>
+Copyright &copy; 1997-2007 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcrepattern.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2247 @@
+<html>
+<head>
+<title>pcrepattern specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcrepattern man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE REGULAR EXPRESSION DETAILS</a>
+<li><a name="TOC2" href="#SEC2">NEWLINE CONVENTIONS</a>
+<li><a name="TOC3" href="#SEC3">CHARACTERS AND METACHARACTERS</a>
+<li><a name="TOC4" href="#SEC4">BACKSLASH</a>
+<li><a name="TOC5" href="#SEC5">CIRCUMFLEX AND DOLLAR</a>
+<li><a name="TOC6" href="#SEC6">FULL STOP (PERIOD, DOT)</a>
+<li><a name="TOC7" href="#SEC7">MATCHING A SINGLE BYTE</a>
+<li><a name="TOC8" href="#SEC8">SQUARE BRACKETS AND CHARACTER CLASSES</a>
+<li><a name="TOC9" href="#SEC9">POSIX CHARACTER CLASSES</a>
+<li><a name="TOC10" href="#SEC10">VERTICAL BAR</a>
+<li><a name="TOC11" href="#SEC11">INTERNAL OPTION SETTING</a>
+<li><a name="TOC12" href="#SEC12">SUBPATTERNS</a>
+<li><a name="TOC13" href="#SEC13">DUPLICATE SUBPATTERN NUMBERS</a>
+<li><a name="TOC14" href="#SEC14">NAMED SUBPATTERNS</a>
+<li><a name="TOC15" href="#SEC15">REPETITION</a>
+<li><a name="TOC16" href="#SEC16">ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS</a>
+<li><a name="TOC17" href="#SEC17">BACK REFERENCES</a>
+<li><a name="TOC18" href="#SEC18">ASSERTIONS</a>
+<li><a name="TOC19" href="#SEC19">CONDITIONAL SUBPATTERNS</a>
+<li><a name="TOC20" href="#SEC20">COMMENTS</a>
+<li><a name="TOC21" href="#SEC21">RECURSIVE PATTERNS</a>
+<li><a name="TOC22" href="#SEC22">SUBPATTERNS AS SUBROUTINES</a>
+<li><a name="TOC23" href="#SEC23">ONIGURUMA SUBROUTINE SYNTAX</a>
+<li><a name="TOC24" href="#SEC24">CALLOUTS</a>
+<li><a name="TOC25" href="#SEC25">BACKTRACKING CONTROL</a>
+<li><a name="TOC26" href="#SEC26">SEE ALSO</a>
+<li><a name="TOC27" href="#SEC27">AUTHOR</a>
+<li><a name="TOC28" href="#SEC28">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE REGULAR EXPRESSION DETAILS</a><br>
+<P>
+The syntax and semantics of the regular expressions that are supported by PCRE
+are described in detail below. There is a quick-reference syntax summary in the
+<a href="pcresyntax.html"><b>pcresyntax</b></a>
+page. PCRE tries to match Perl syntax and semantics as closely as it can. PCRE
+also supports some alternative regular expression syntax (which does not
+conflict with the Perl syntax) in order to provide some compatibility with
+regular expressions in Python, .NET, and Oniguruma.
+</P>
+<P>
+Perl's regular expressions are described in its own documentation, and
+regular expressions in general are covered in a number of books, some of which
+have copious examples. Jeffrey Friedl's "Mastering Regular Expressions",
+published by O'Reilly, covers regular expressions in great detail. This
+description of PCRE's regular expressions is intended as reference material.
+</P>
+<P>
+The original operation of PCRE was on strings of one-byte characters. However,
+there is now also support for UTF-8 character strings. To use this, you must
+build PCRE to include UTF-8 support, and then call <b>pcre_compile()</b> with
+the PCRE_UTF8 option. How this affects pattern matching is mentioned in several
+places below. There is also a summary of UTF-8 features in the
+<a href="pcre.html#utf8support">section on UTF-8 support</a>
+in the main
+<a href="pcre.html"><b>pcre</b></a>
+page.
+</P>
+<P>
+The remainder of this document discusses the patterns that are supported by
+PCRE when its main matching function, <b>pcre_exec()</b>, is used.
+From release 6.0, PCRE offers a second matching function,
+<b>pcre_dfa_exec()</b>, which matches using a different algorithm that is not
+Perl-compatible. Some of the features discussed below are not available when
+<b>pcre_dfa_exec()</b> is used. The advantages and disadvantages of the
+alternative function, and how it differs from the normal function, are
+discussed in the
+<a href="pcrematching.html"><b>pcrematching</b></a>
+page.
+</P>
+<br><a name="SEC2" href="#TOC1">NEWLINE CONVENTIONS</a><br>
+<P>
+PCRE supports five different conventions for indicating line breaks in
+strings: a single CR (carriage return) character, a single LF (linefeed)
+character, the two-character sequence CRLF, any of the three preceding, or any
+Unicode newline sequence. The
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page has
+<a href="pcreapi.html#newlines">further discussion</a>
+about newlines, and shows how to set the newline convention in the
+<i>options</i> arguments for the compiling and matching functions.
+</P>
+<P>
+It is also possible to specify a newline convention by starting a pattern
+string with one of the following five sequences:
+<pre>
+  (*CR)        carriage return
+  (*LF)        linefeed
+  (*CRLF)      carriage return, followed by linefeed
+  (*ANYCRLF)   any of the three above
+  (*ANY)       all Unicode newline sequences
+</pre>
+These override the default and the options given to <b>pcre_compile()</b>. For
+example, on a Unix system where LF is the default newline sequence, the pattern
+<pre>
+  (*CR)a.b
+</pre>
+changes the convention to CR. That pattern matches "a\nb" because LF is no
+longer a newline. Note that these special settings, which are not
+Perl-compatible, are recognized only at the very start of a pattern, and that
+they must be in upper case. If more than one of them is present, the last one
+is used.
+</P>
+<P>
+The newline convention does not affect what the \R escape sequence matches. By
+default, this is any Unicode newline sequence, for Perl compatibility. However,
+this can be changed; see the description of \R in the section entitled
+<a href="#newlineseq">"Newline sequences"</a>
+below. A change of \R setting can be combined with a change of newline
+convention.
+</P>
+<br><a name="SEC3" href="#TOC1">CHARACTERS AND METACHARACTERS</a><br>
+<P>
+A regular expression is a pattern that is matched against a subject string from
+left to right. Most characters stand for themselves in a pattern, and match the
+corresponding characters in the subject. As a trivial example, the pattern
+<pre>
+  The quick brown fox
+</pre>
+matches a portion of a subject string that is identical to itself. When
+caseless matching is specified (the PCRE_CASELESS option), letters are matched
+independently of case. In UTF-8 mode, PCRE always understands the concept of
+case for characters whose values are less than 128, so caseless matching is
+always possible. For characters with higher values, the concept of case is
+supported if PCRE is compiled with Unicode property support, but not otherwise.
+If you want to use caseless matching for characters 128 and above, you must
+ensure that PCRE is compiled with Unicode property support as well as with
+UTF-8 support.
+</P>
+<P>
+The power of regular expressions comes from the ability to include alternatives
+and repetitions in the pattern. These are encoded in the pattern by the use of
+<i>metacharacters</i>, which do not stand for themselves but instead are
+interpreted in some special way.
+</P>
+<P>
+There are two different sets of metacharacters: those that are recognized
+anywhere in the pattern except within square brackets, and those that are
+recognized within square brackets. Outside square brackets, the metacharacters
+are as follows:
+<pre>
+  \      general escape character with several uses
+  ^      assert start of string (or line, in multiline mode)
+  $      assert end of string (or line, in multiline mode)
+  .      match any character except newline (by default)
+  [      start character class definition
+  |      start of alternative branch
+  (      start subpattern
+  )      end subpattern
+  ?      extends the meaning of (
+         also 0 or 1 quantifier
+         also quantifier minimizer
+  *      0 or more quantifier
+  +      1 or more quantifier
+         also "possessive quantifier"
+  {      start min/max quantifier
+</pre>
+Part of a pattern that is in square brackets is called a "character class". In
+a character class the only metacharacters are:
+<pre>
+  \      general escape character
+  ^      negate the class, but only if the first character
+  -      indicates character range
+  [      POSIX character class (only if followed by POSIX syntax)
+  ]      terminates the character class
+</pre>
+The following sections describe the use of each of the metacharacters.
+</P>
+<br><a name="SEC4" href="#TOC1">BACKSLASH</a><br>
+<P>
+The backslash character has several uses. Firstly, if it is followed by a
+non-alphanumeric character, it takes away any special meaning that character
+may have. This use of backslash as an escape character applies both inside and
+outside character classes.
+</P>
+<P>
+For example, if you want to match a * character, you write \* in the pattern.
+This escaping action applies whether or not the following character would
+otherwise be interpreted as a metacharacter, so it is always safe to precede a
+non-alphanumeric with backslash to specify that it stands for itself. In
+particular, if you want to match a backslash, you write \\.
+</P>
+<P>
+If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the
+pattern (other than in a character class) and characters between a # outside
+a character class and the next newline are ignored. An escaping backslash can
+be used to include a whitespace or # character as part of the pattern.
+</P>
+<P>
+If you want to remove the special meaning from a sequence of characters, you
+can do so by putting them between \Q and \E. This is different from Perl in
+that $ and @ are handled as literals in \Q...\E sequences in PCRE, whereas in
+Perl, $ and @ cause variable interpolation. Note the following examples:
+<pre>
+  Pattern            PCRE matches   Perl matches
+
+  \Qabc$xyz\E        abc$xyz        abc followed by the contents of $xyz
+  \Qabc\$xyz\E       abc\$xyz       abc\$xyz
+  \Qabc\E\$\Qxyz\E   abc$xyz        abc$xyz
+</pre>
+The \Q...\E sequence is recognized both inside and outside character classes.
+<a name="digitsafterbackslash"></a></P>
+<br><b>
+Non-printing characters
+</b><br>
+<P>
+A second use of backslash provides a way of encoding non-printing characters
+in patterns in a visible manner. There is no restriction on the appearance of
+non-printing characters, apart from the binary zero that terminates a pattern,
+but when a pattern is being prepared by text editing, it is usually easier to
+use one of the following escape sequences than the binary character it
+represents:
+<pre>
+  \a        alarm, that is, the BEL character (hex 07)
+  \cx       "control-x", where x is any character
+  \e        escape (hex 1B)
+  \f        formfeed (hex 0C)
+  \n        linefeed (hex 0A)
+  \r        carriage return (hex 0D)
+  \t        tab (hex 09)
+  \ddd      character with octal code ddd, or backreference
+  \xhh      character with hex code hh
+  \x{hhh..} character with hex code hhh..
+</pre>
+The precise effect of \cx is as follows: if x is a lower case letter, it
+is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
+Thus \cz becomes hex 1A, but \c{ becomes hex 3B, while \c; becomes hex
+7B.
+</P>
+<P>
+After \x, from zero to two hexadecimal digits are read (letters can be in
+upper or lower case). Any number of hexadecimal digits may appear between \x{
+and }, but the value of the character code must be less than 256 in non-UTF-8
+mode, and less than 2**31 in UTF-8 mode. That is, the maximum value in
+hexadecimal is 7FFFFFFF. Note that this is bigger than the largest Unicode code
+point, which is 10FFFF.
+</P>
+<P>
+If characters other than hexadecimal digits appear between \x{ and }, or if
+there is no terminating }, this form of escape is not recognized. Instead, the
+initial \x will be interpreted as a basic hexadecimal escape, with no
+following digits, giving a character whose value is zero.
+</P>
+<P>
+Characters whose value is less than 256 can be defined by either of the two
+syntaxes for \x. There is no difference in the way they are handled. For
+example, \xdc is exactly the same as \x{dc}.
+</P>
+<P>
+After \0 up to two further octal digits are read. If there are fewer than two
+digits, just those that are present are used. Thus the sequence \0\x\07
+specifies two binary zeros followed by a BEL character (code value 7). Make
+sure you supply two digits after the initial zero if the pattern character that
+follows is itself an octal digit.
+</P>
+<P>
+The handling of a backslash followed by a digit other than 0 is complicated.
+Outside a character class, PCRE reads it and any following digits as a decimal
+number. If the number is less than 10, or if there have been at least that many
+previous capturing left parentheses in the expression, the entire sequence is
+taken as a <i>back reference</i>. A description of how this works is given
+<a href="#backreferences">later,</a>
+following the discussion of
+<a href="#subpattern">parenthesized subpatterns.</a>
+</P>
+<P>
+Inside a character class, or if the decimal number is greater than 9 and there
+have not been that many capturing subpatterns, PCRE re-reads up to three octal
+digits following the backslash, and uses them to generate a data character. Any
+subsequent digits stand for themselves. In non-UTF-8 mode, the value of a
+character specified in octal must be less than \400. In UTF-8 mode, values up
+to \777 are permitted. For example:
+<pre>
+  \040   is another way of writing a space
+  \40    is the same, provided there are fewer than 40 previous capturing subpatterns
+  \7     is always a back reference
+  \11    might be a back reference, or another way of writing a tab
+  \011   is always a tab
+  \0113  is a tab followed by the character "3"
+  \113   might be a back reference, otherwise the character with octal code 113
+  \377   might be a back reference, otherwise the byte consisting entirely of 1 bits
+  \81    is either a back reference, or a binary zero followed by the two characters "8" and "1"
+</pre>
+Note that octal values of 100 or greater must not be introduced by a leading
+zero, because no more than three octal digits are ever read.
+</P>
+<P>
+All the sequences that define a single character value can be used both inside
+and outside character classes. In addition, inside a character class, the
+sequence \b is interpreted as the backspace character (hex 08), and the
+sequences \R and \X are interpreted as the characters "R" and "X",
+respectively. Outside a character class, these sequences have different
+meanings
+<a href="#uniextseq">(see below).</a>
+</P>
+<br><b>
+Absolute and relative back references
+</b><br>
+<P>
+The sequence \g followed by an unsigned or a negative number, optionally
+enclosed in braces, is an absolute or relative back reference. A named back
+reference can be coded as \g{name}. Back references are discussed
+<a href="#backreferences">later,</a>
+following the discussion of
+<a href="#subpattern">parenthesized subpatterns.</a>
+</P>
+<br><b>
+Absolute and relative subroutine calls
+</b><br>
+<P>
+For compatibility with Oniguruma, the non-Perl syntax \g followed by a name or
+a number enclosed either in angle brackets or single quotes, is an alternative
+syntax for referencing a subpattern as a "subroutine". Details are discussed
+<a href="#onigurumasubroutines">later.</a>
+Note that \g{...} (Perl syntax) and \g&#60;...&#62; (Oniguruma syntax) are <i>not</i>
+synonymous. The former is a back reference; the latter is a subroutine call.
+</P>
+<br><b>
+Generic character types
+</b><br>
+<P>
+Another use of backslash is for specifying generic character types. The
+following are always recognized:
+<pre>
+  \d     any decimal digit
+  \D     any character that is not a decimal digit
+  \h     any horizontal whitespace character
+  \H     any character that is not a horizontal whitespace character
+  \s     any whitespace character
+  \S     any character that is not a whitespace character
+  \v     any vertical whitespace character
+  \V     any character that is not a vertical whitespace character
+  \w     any "word" character
+  \W     any "non-word" character
+</pre>
+Each pair of escape sequences partitions the complete set of characters into
+two disjoint sets. Any given character matches one, and only one, of each pair.
+</P>
+<P>
+These character type sequences can appear both inside and outside character
+classes. They each match one character of the appropriate type. If the current
+matching point is at the end of the subject string, all of them fail, since
+there is no character to match.
+</P>
+<P>
+For compatibility with Perl, \s does not match the VT character (code 11).
+This makes it different from the the POSIX "space" class. The \s characters
+are HT (9), LF (10), FF (12), CR (13), and space (32). If "use locale;" is
+included in a Perl script, \s may match the VT character. In PCRE, it never
+does.
+</P>
+<P>
+In UTF-8 mode, characters with values greater than 128 never match \d, \s, or
+\w, and always match \D, \S, and \W. This is true even when Unicode
+character property support is available. These sequences retain their original
+meanings from before UTF-8 support was available, mainly for efficiency
+reasons.
+</P>
+<P>
+The sequences \h, \H, \v, and \V are Perl 5.10 features. In contrast to the
+other sequences, these do match certain high-valued codepoints in UTF-8 mode.
+The horizontal space characters are:
+<pre>
+  U+0009     Horizontal tab
+  U+0020     Space
+  U+00A0     Non-break space
+  U+1680     Ogham space mark
+  U+180E     Mongolian vowel separator
+  U+2000     En quad
+  U+2001     Em quad
+  U+2002     En space
+  U+2003     Em space
+  U+2004     Three-per-em space
+  U+2005     Four-per-em space
+  U+2006     Six-per-em space
+  U+2007     Figure space
+  U+2008     Punctuation space
+  U+2009     Thin space
+  U+200A     Hair space
+  U+202F     Narrow no-break space
+  U+205F     Medium mathematical space
+  U+3000     Ideographic space
+</pre>
+The vertical space characters are:
+<pre>
+  U+000A     Linefeed
+  U+000B     Vertical tab
+  U+000C     Formfeed
+  U+000D     Carriage return
+  U+0085     Next line
+  U+2028     Line separator
+  U+2029     Paragraph separator
+</PRE>
+</P>
+<P>
+A "word" character is an underscore or any character less than 256 that is a
+letter or digit. The definition of letters and digits is controlled by PCRE's
+low-valued character tables, and may vary if locale-specific matching is taking
+place (see
+<a href="pcreapi.html#localesupport">"Locale support"</a>
+in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page). For example, in a French locale such as "fr_FR" in Unix-like systems,
+or "french" in Windows, some character codes greater than 128 are used for
+accented letters, and these are matched by \w. The use of locales with Unicode
+is discouraged.
+<a name="newlineseq"></a></P>
+<br><b>
+Newline sequences
+</b><br>
+<P>
+Outside a character class, by default, the escape sequence \R matches any
+Unicode newline sequence. This is a Perl 5.10 feature. In non-UTF-8 mode \R is
+equivalent to the following:
+<pre>
+  (?&#62;\r\n|\n|\x0b|\f|\r|\x85)
+</pre>
+This is an example of an "atomic group", details of which are given
+<a href="#atomicgroup">below.</a>
+This particular group matches either the two-character sequence CR followed by
+LF, or one of the single characters LF (linefeed, U+000A), VT (vertical tab,
+U+000B), FF (formfeed, U+000C), CR (carriage return, U+000D), or NEL (next
+line, U+0085). The two-character sequence is treated as a single unit that
+cannot be split.
+</P>
+<P>
+In UTF-8 mode, two additional characters whose codepoints are greater than 255
+are added: LS (line separator, U+2028) and PS (paragraph separator, U+2029).
+Unicode character property support is not needed for these characters to be
+recognized.
+</P>
+<P>
+It is possible to restrict \R to match only CR, LF, or CRLF (instead of the
+complete set of Unicode line endings) by setting the option PCRE_BSR_ANYCRLF
+either at compile time or when the pattern is matched. (BSR is an abbrevation
+for "backslash R".) This can be made the default when PCRE is built; if this is
+the case, the other behaviour can be requested via the PCRE_BSR_UNICODE option.
+It is also possible to specify these settings by starting a pattern string with
+one of the following sequences:
+<pre>
+  (*BSR_ANYCRLF)   CR, LF, or CRLF only
+  (*BSR_UNICODE)   any Unicode newline sequence
+</pre>
+These override the default and the options given to <b>pcre_compile()</b>, but
+they can be overridden by options given to <b>pcre_exec()</b>. Note that these
+special settings, which are not Perl-compatible, are recognized only at the
+very start of a pattern, and that they must be in upper case. If more than one
+of them is present, the last one is used. They can be combined with a change of
+newline convention, for example, a pattern can start with:
+<pre>
+  (*ANY)(*BSR_ANYCRLF)
+</pre>
+Inside a character class, \R matches the letter "R".
+<a name="uniextseq"></a></P>
+<br><b>
+Unicode character properties
+</b><br>
+<P>
+When PCRE is built with Unicode character property support, three additional
+escape sequences that match characters with specific properties are available.
+When not in UTF-8 mode, these sequences are of course limited to testing
+characters whose codepoints are less than 256, but they do work in this mode.
+The extra escape sequences are:
+<pre>
+  \p{<i>xx</i>}   a character with the <i>xx</i> property
+  \P{<i>xx</i>}   a character without the <i>xx</i> property
+  \X       an extended Unicode sequence
+</pre>
+The property names represented by <i>xx</i> above are limited to the Unicode
+script names, the general category properties, and "Any", which matches any
+character (including newline). Other properties such as "InMusicalSymbols" are
+not currently supported by PCRE. Note that \P{Any} does not match any
+characters, so always causes a match failure.
+</P>
+<P>
+Sets of Unicode characters are defined as belonging to certain scripts. A
+character from one of these sets can be matched using a script name. For
+example:
+<pre>
+  \p{Greek}
+  \P{Han}
+</pre>
+Those that are not part of an identified script are lumped together as
+"Common". The current list of scripts is:
+</P>
+<P>
+Arabic,
+Armenian,
+Balinese,
+Bengali,
+Bopomofo,
+Braille,
+Buginese,
+Buhid,
+Canadian_Aboriginal,
+Cherokee,
+Common,
+Coptic,
+Cuneiform,
+Cypriot,
+Cyrillic,
+Deseret,
+Devanagari,
+Ethiopic,
+Georgian,
+Glagolitic,
+Gothic,
+Greek,
+Gujarati,
+Gurmukhi,
+Han,
+Hangul,
+Hanunoo,
+Hebrew,
+Hiragana,
+Inherited,
+Kannada,
+Katakana,
+Kharoshthi,
+Khmer,
+Lao,
+Latin,
+Limbu,
+Linear_B,
+Malayalam,
+Mongolian,
+Myanmar,
+New_Tai_Lue,
+Nko,
+Ogham,
+Old_Italic,
+Old_Persian,
+Oriya,
+Osmanya,
+Phags_Pa,
+Phoenician,
+Runic,
+Shavian,
+Sinhala,
+Syloti_Nagri,
+Syriac,
+Tagalog,
+Tagbanwa,
+Tai_Le,
+Tamil,
+Telugu,
+Thaana,
+Thai,
+Tibetan,
+Tifinagh,
+Ugaritic,
+Yi.
+</P>
+<P>
+Each character has exactly one general category property, specified by a
+two-letter abbreviation. For compatibility with Perl, negation can be specified
+by including a circumflex between the opening brace and the property name. For
+example, \p{^Lu} is the same as \P{Lu}.
+</P>
+<P>
+If only one letter is specified with \p or \P, it includes all the general
+category properties that start with that letter. In this case, in the absence
+of negation, the curly brackets in the escape sequence are optional; these two
+examples have the same effect:
+<pre>
+  \p{L}
+  \pL
+</pre>
+The following general category property codes are supported:
+<pre>
+  C     Other
+  Cc    Control
+  Cf    Format
+  Cn    Unassigned
+  Co    Private use
+  Cs    Surrogate
+
+  L     Letter
+  Ll    Lower case letter
+  Lm    Modifier letter
+  Lo    Other letter
+  Lt    Title case letter
+  Lu    Upper case letter
+
+  M     Mark
+  Mc    Spacing mark
+  Me    Enclosing mark
+  Mn    Non-spacing mark
+
+  N     Number
+  Nd    Decimal number
+  Nl    Letter number
+  No    Other number
+
+  P     Punctuation
+  Pc    Connector punctuation
+  Pd    Dash punctuation
+  Pe    Close punctuation
+  Pf    Final punctuation
+  Pi    Initial punctuation
+  Po    Other punctuation
+  Ps    Open punctuation
+
+  S     Symbol
+  Sc    Currency symbol
+  Sk    Modifier symbol
+  Sm    Mathematical symbol
+  So    Other symbol
+
+  Z     Separator
+  Zl    Line separator
+  Zp    Paragraph separator
+  Zs    Space separator
+</pre>
+The special property L& is also supported: it matches a character that has
+the Lu, Ll, or Lt property, in other words, a letter that is not classified as
+a modifier or "other".
+</P>
+<P>
+The Cs (Surrogate) property applies only to characters in the range U+D800 to
+U+DFFF. Such characters are not valid in UTF-8 strings (see RFC 3629) and so
+cannot be tested by PCRE, unless UTF-8 validity checking has been turned off
+(see the discussion of PCRE_NO_UTF8_CHECK in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+page).
+</P>
+<P>
+The long synonyms for these properties that Perl supports (such as \p{Letter})
+are not supported by PCRE, nor is it permitted to prefix any of these
+properties with "Is".
+</P>
+<P>
+No character that is in the Unicode table has the Cn (unassigned) property.
+Instead, this property is assumed for any code point that is not in the
+Unicode table.
+</P>
+<P>
+Specifying caseless matching does not affect these escape sequences. For
+example, \p{Lu} always matches only upper case letters.
+</P>
+<P>
+The \X escape matches any number of Unicode characters that form an extended
+Unicode sequence. \X is equivalent to
+<pre>
+  (?&#62;\PM\pM*)
+</pre>
+That is, it matches a character without the "mark" property, followed by zero
+or more characters with the "mark" property, and treats the sequence as an
+atomic group
+<a href="#atomicgroup">(see below).</a>
+Characters with the "mark" property are typically accents that affect the
+preceding character. None of them have codepoints less than 256, so in
+non-UTF-8 mode \X matches any one character.
+</P>
+<P>
+Matching characters by Unicode property is not fast, because PCRE has to search
+a structure that contains data for over fifteen thousand characters. That is
+why the traditional escape sequences such as \d and \w do not use Unicode
+properties in PCRE.
+<a name="resetmatchstart"></a></P>
+<br><b>
+Resetting the match start
+</b><br>
+<P>
+The escape sequence \K, which is a Perl 5.10 feature, causes any previously
+matched characters not to be included in the final matched sequence. For
+example, the pattern:
+<pre>
+  foo\Kbar
+</pre>
+matches "foobar", but reports that it has matched "bar". This feature is
+similar to a lookbehind assertion
+<a href="#lookbehind">(described below).</a>
+However, in this case, the part of the subject before the real match does not
+have to be of fixed length, as lookbehind assertions do. The use of \K does
+not interfere with the setting of
+<a href="#subpattern">captured substrings.</a>
+For example, when the pattern
+<pre>
+  (foo)\Kbar
+</pre>
+matches "foobar", the first substring is still set to "foo".
+<a name="smallassertions"></a></P>
+<br><b>
+Simple assertions
+</b><br>
+<P>
+The final use of backslash is for certain simple assertions. An assertion
+specifies a condition that has to be met at a particular point in a match,
+without consuming any characters from the subject string. The use of
+subpatterns for more complicated assertions is described
+<a href="#bigassertions">below.</a>
+The backslashed assertions are:
+<pre>
+  \b     matches at a word boundary
+  \B     matches when not at a word boundary
+  \A     matches at the start of the subject
+  \Z     matches at the end of the subject
+          also matches before a newline at the end of the subject
+  \z     matches only at the end of the subject
+  \G     matches at the first matching position in the subject
+</pre>
+These assertions may not appear in character classes (but note that \b has a
+different meaning, namely the backspace character, inside a character class).
+</P>
+<P>
+A word boundary is a position in the subject string where the current character
+and the previous character do not both match \w or \W (i.e. one matches
+\w and the other matches \W), or the start or end of the string if the
+first or last character matches \w, respectively.
+</P>
+<P>
+The \A, \Z, and \z assertions differ from the traditional circumflex and
+dollar (described in the next section) in that they only ever match at the very
+start and end of the subject string, whatever options are set. Thus, they are
+independent of multiline mode. These three assertions are not affected by the
+PCRE_NOTBOL or PCRE_NOTEOL options, which affect only the behaviour of the
+circumflex and dollar metacharacters. However, if the <i>startoffset</i>
+argument of <b>pcre_exec()</b> is non-zero, indicating that matching is to start
+at a point other than the beginning of the subject, \A can never match. The
+difference between \Z and \z is that \Z matches before a newline at the end
+of the string as well as at the very end, whereas \z matches only at the end.
+</P>
+<P>
+The \G assertion is true only when the current matching position is at the
+start point of the match, as specified by the <i>startoffset</i> argument of
+<b>pcre_exec()</b>. It differs from \A when the value of <i>startoffset</i> is
+non-zero. By calling <b>pcre_exec()</b> multiple times with appropriate
+arguments, you can mimic Perl's /g option, and it is in this kind of
+implementation where \G can be useful.
+</P>
+<P>
+Note, however, that PCRE's interpretation of \G, as the start of the current
+match, is subtly different from Perl's, which defines it as the end of the
+previous match. In Perl, these can be different when the previously matched
+string was empty. Because PCRE does just one match at a time, it cannot
+reproduce this behaviour.
+</P>
+<P>
+If all the alternatives of a pattern begin with \G, the expression is anchored
+to the starting match position, and the "anchored" flag is set in the compiled
+regular expression.
+</P>
+<br><a name="SEC5" href="#TOC1">CIRCUMFLEX AND DOLLAR</a><br>
+<P>
+Outside a character class, in the default matching mode, the circumflex
+character is an assertion that is true only if the current matching point is
+at the start of the subject string. If the <i>startoffset</i> argument of
+<b>pcre_exec()</b> is non-zero, circumflex can never match if the PCRE_MULTILINE
+option is unset. Inside a character class, circumflex has an entirely different
+meaning
+<a href="#characterclass">(see below).</a>
+</P>
+<P>
+Circumflex need not be the first character of the pattern if a number of
+alternatives are involved, but it should be the first thing in each alternative
+in which it appears if the pattern is ever to match that branch. If all
+possible alternatives start with a circumflex, that is, if the pattern is
+constrained to match only at the start of the subject, it is said to be an
+"anchored" pattern. (There are also other constructs that can cause a pattern
+to be anchored.)
+</P>
+<P>
+A dollar character is an assertion that is true only if the current matching
+point is at the end of the subject string, or immediately before a newline
+at the end of the string (by default). Dollar need not be the last character of
+the pattern if a number of alternatives are involved, but it should be the last
+item in any branch in which it appears. Dollar has no special meaning in a
+character class.
+</P>
+<P>
+The meaning of dollar can be changed so that it matches only at the very end of
+the string, by setting the PCRE_DOLLAR_ENDONLY option at compile time. This
+does not affect the \Z assertion.
+</P>
+<P>
+The meanings of the circumflex and dollar characters are changed if the
+PCRE_MULTILINE option is set. When this is the case, a circumflex matches
+immediately after internal newlines as well as at the start of the subject
+string. It does not match after a newline that ends the string. A dollar
+matches before any newlines in the string, as well as at the very end, when
+PCRE_MULTILINE is set. When newline is specified as the two-character
+sequence CRLF, isolated CR and LF characters do not indicate newlines.
+</P>
+<P>
+For example, the pattern /^abc$/ matches the subject string "def\nabc" (where
+\n represents a newline) in multiline mode, but not otherwise. Consequently,
+patterns that are anchored in single line mode because all branches start with
+^ are not anchored in multiline mode, and a match for circumflex is possible
+when the <i>startoffset</i> argument of <b>pcre_exec()</b> is non-zero. The
+PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is set.
+</P>
+<P>
+Note that the sequences \A, \Z, and \z can be used to match the start and
+end of the subject in both modes, and if all branches of a pattern start with
+\A it is always anchored, whether or not PCRE_MULTILINE is set.
+</P>
+<br><a name="SEC6" href="#TOC1">FULL STOP (PERIOD, DOT)</a><br>
+<P>
+Outside a character class, a dot in the pattern matches any one character in
+the subject string except (by default) a character that signifies the end of a
+line. In UTF-8 mode, the matched character may be more than one byte long.
+</P>
+<P>
+When a line ending is defined as a single character, dot never matches that
+character; when the two-character sequence CRLF is used, dot does not match CR
+if it is immediately followed by LF, but otherwise it matches all characters
+(including isolated CRs and LFs). When any Unicode line endings are being
+recognized, dot does not match CR or LF or any of the other line ending
+characters.
+</P>
+<P>
+The behaviour of dot with regard to newlines can be changed. If the PCRE_DOTALL
+option is set, a dot matches any one character, without exception. If the
+two-character sequence CRLF is present in the subject string, it takes two dots
+to match it.
+</P>
+<P>
+The handling of dot is entirely independent of the handling of circumflex and
+dollar, the only relationship being that they both involve newlines. Dot has no
+special meaning in a character class.
+</P>
+<br><a name="SEC7" href="#TOC1">MATCHING A SINGLE BYTE</a><br>
+<P>
+Outside a character class, the escape sequence \C matches any one byte, both
+in and out of UTF-8 mode. Unlike a dot, it always matches any line-ending
+characters. The feature is provided in Perl in order to match individual bytes
+in UTF-8 mode. Because it breaks up UTF-8 characters into individual bytes,
+what remains in the string may be a malformed UTF-8 string. For this reason,
+the \C escape sequence is best avoided.
+</P>
+<P>
+PCRE does not allow \C to appear in lookbehind assertions
+<a href="#lookbehind">(described below),</a>
+because in UTF-8 mode this would make it impossible to calculate the length of
+the lookbehind.
+<a name="characterclass"></a></P>
+<br><a name="SEC8" href="#TOC1">SQUARE BRACKETS AND CHARACTER CLASSES</a><br>
+<P>
+An opening square bracket introduces a character class, terminated by a closing
+square bracket. A closing square bracket on its own is not special. If a
+closing square bracket is required as a member of the class, it should be the
+first data character in the class (after an initial circumflex, if present) or
+escaped with a backslash.
+</P>
+<P>
+A character class matches a single character in the subject. In UTF-8 mode, the
+character may occupy more than one byte. A matched character must be in the set
+of characters defined by the class, unless the first character in the class
+definition is a circumflex, in which case the subject character must not be in
+the set defined by the class. If a circumflex is actually required as a member
+of the class, ensure it is not the first character, or escape it with a
+backslash.
+</P>
+<P>
+For example, the character class [aeiou] matches any lower case vowel, while
+[^aeiou] matches any character that is not a lower case vowel. Note that a
+circumflex is just a convenient notation for specifying the characters that
+are in the class by enumerating those that are not. A class that starts with a
+circumflex is not an assertion: it still consumes a character from the subject
+string, and therefore it fails if the current pointer is at the end of the
+string.
+</P>
+<P>
+In UTF-8 mode, characters with values greater than 255 can be included in a
+class as a literal string of bytes, or by using the \x{ escaping mechanism.
+</P>
+<P>
+When caseless matching is set, any letters in a class represent both their
+upper case and lower case versions, so for example, a caseless [aeiou] matches
+"A" as well as "a", and a caseless [^aeiou] does not match "A", whereas a
+caseful version would. In UTF-8 mode, PCRE always understands the concept of
+case for characters whose values are less than 128, so caseless matching is
+always possible. For characters with higher values, the concept of case is
+supported if PCRE is compiled with Unicode property support, but not otherwise.
+If you want to use caseless matching for characters 128 and above, you must
+ensure that PCRE is compiled with Unicode property support as well as with
+UTF-8 support.
+</P>
+<P>
+Characters that might indicate line breaks are never treated in any special way
+when matching character classes, whatever line-ending sequence is in use, and
+whatever setting of the PCRE_DOTALL and PCRE_MULTILINE options is used. A class
+such as [^a] always matches one of these characters.
+</P>
+<P>
+The minus (hyphen) character can be used to specify a range of characters in a
+character class. For example, [d-m] matches any letter between d and m,
+inclusive. If a minus character is required in a class, it must be escaped with
+a backslash or appear in a position where it cannot be interpreted as
+indicating a range, typically as the first or last character in the class.
+</P>
+<P>
+It is not possible to have the literal character "]" as the end character of a
+range. A pattern such as [W-]46] is interpreted as a class of two characters
+("W" and "-") followed by a literal string "46]", so it would match "W46]" or
+"-46]". However, if the "]" is escaped with a backslash it is interpreted as
+the end of range, so [W-\]46] is interpreted as a class containing a range
+followed by two other characters. The octal or hexadecimal representation of
+"]" can also be used to end a range.
+</P>
+<P>
+Ranges operate in the collating sequence of character values. They can also be
+used for characters specified numerically, for example [\000-\037]. In UTF-8
+mode, ranges can include characters whose values are greater than 255, for
+example [\x{100}-\x{2ff}].
+</P>
+<P>
+If a range that includes letters is used when caseless matching is set, it
+matches the letters in either case. For example, [W-c] is equivalent to
+[][\\^_`wxyzabc], matched caselessly, and in non-UTF-8 mode, if character
+tables for a French locale are in use, [\xc8-\xcb] matches accented E
+characters in both cases. In UTF-8 mode, PCRE supports the concept of case for
+characters with values greater than 128 only when it is compiled with Unicode
+property support.
+</P>
+<P>
+The character types \d, \D, \p, \P, \s, \S, \w, and \W may also appear
+in a character class, and add the characters that they match to the class. For
+example, [\dABCDEF] matches any hexadecimal digit. A circumflex can
+conveniently be used with the upper case character types to specify a more
+restricted set of characters than the matching lower case type. For example,
+the class [^\W_] matches any letter or digit, but not underscore.
+</P>
+<P>
+The only metacharacters that are recognized in character classes are backslash,
+hyphen (only where it can be interpreted as specifying a range), circumflex
+(only at the start), opening square bracket (only when it can be interpreted as
+introducing a POSIX class name - see the next section), and the terminating
+closing square bracket. However, escaping other non-alphanumeric characters
+does no harm.
+</P>
+<br><a name="SEC9" href="#TOC1">POSIX CHARACTER CLASSES</a><br>
+<P>
+Perl supports the POSIX notation for character classes. This uses names
+enclosed by [: and :] within the enclosing square brackets. PCRE also supports
+this notation. For example,
+<pre>
+  [01[:alpha:]%]
+</pre>
+matches "0", "1", any alphabetic character, or "%". The supported class names
+are
+<pre>
+  alnum    letters and digits
+  alpha    letters
+  ascii    character codes 0 - 127
+  blank    space or tab only
+  cntrl    control characters
+  digit    decimal digits (same as \d)
+  graph    printing characters, excluding space
+  lower    lower case letters
+  print    printing characters, including space
+  punct    printing characters, excluding letters and digits
+  space    white space (not quite the same as \s)
+  upper    upper case letters
+  word     "word" characters (same as \w)
+  xdigit   hexadecimal digits
+</pre>
+The "space" characters are HT (9), LF (10), VT (11), FF (12), CR (13), and
+space (32). Notice that this list includes the VT character (code 11). This
+makes "space" different to \s, which does not include VT (for Perl
+compatibility).
+</P>
+<P>
+The name "word" is a Perl extension, and "blank" is a GNU extension from Perl
+5.8. Another Perl extension is negation, which is indicated by a ^ character
+after the colon. For example,
+<pre>
+  [12[:^digit:]]
+</pre>
+matches "1", "2", or any non-digit. PCRE (and Perl) also recognize the POSIX
+syntax [.ch.] and [=ch=] where "ch" is a "collating element", but these are not
+supported, and an error is given if they are encountered.
+</P>
+<P>
+In UTF-8 mode, characters with values greater than 128 do not match any of
+the POSIX character classes.
+</P>
+<br><a name="SEC10" href="#TOC1">VERTICAL BAR</a><br>
+<P>
+Vertical bar characters are used to separate alternative patterns. For example,
+the pattern
+<pre>
+  gilbert|sullivan
+</pre>
+matches either "gilbert" or "sullivan". Any number of alternatives may appear,
+and an empty alternative is permitted (matching the empty string). The matching
+process tries each alternative in turn, from left to right, and the first one
+that succeeds is used. If the alternatives are within a subpattern
+<a href="#subpattern">(defined below),</a>
+"succeeds" means matching the rest of the main pattern as well as the
+alternative in the subpattern.
+</P>
+<br><a name="SEC11" href="#TOC1">INTERNAL OPTION SETTING</a><br>
+<P>
+The settings of the PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
+PCRE_EXTENDED options (which are Perl-compatible) can be changed from within
+the pattern by a sequence of Perl option letters enclosed between "(?" and ")".
+The option letters are
+<pre>
+  i  for PCRE_CASELESS
+  m  for PCRE_MULTILINE
+  s  for PCRE_DOTALL
+  x  for PCRE_EXTENDED
+</pre>
+For example, (?im) sets caseless, multiline matching. It is also possible to
+unset these options by preceding the letter with a hyphen, and a combined
+setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and
+PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also
+permitted. If a letter appears both before and after the hyphen, the option is
+unset.
+</P>
+<P>
+The PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and PCRE_EXTRA can be
+changed in the same way as the Perl-compatible options by using the characters
+J, U and X respectively.
+</P>
+<P>
+When an option change occurs at top level (that is, not inside subpattern
+parentheses), the change applies to the remainder of the pattern that follows.
+If the change is placed right at the start of a pattern, PCRE extracts it into
+the global options (and it will therefore show up in data extracted by the
+<b>pcre_fullinfo()</b> function).
+</P>
+<P>
+An option change within a subpattern (see below for a description of
+subpatterns) affects only that part of the current pattern that follows it, so
+<pre>
+  (a(?i)b)c
+</pre>
+matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).
+By this means, options can be made to have different settings in different
+parts of the pattern. Any changes made in one alternative do carry on
+into subsequent branches within the same subpattern. For example,
+<pre>
+  (a(?i)b|c)
+</pre>
+matches "ab", "aB", "c", and "C", even though when matching "C" the first
+branch is abandoned before the option setting. This is because the effects of
+option settings happen at compile time. There would be some very weird
+behaviour otherwise.
+</P>
+<P>
+<b>Note:</b> There are other PCRE-specific options that can be set by the
+application when the compile or match functions are called. In some cases the
+pattern can contain special leading sequences to override what the application
+has set or what has been defaulted. Details are given in the section entitled
+<a href="#newlineseq">"Newline sequences"</a>
+above.
+<a name="subpattern"></a></P>
+<br><a name="SEC12" href="#TOC1">SUBPATTERNS</a><br>
+<P>
+Subpatterns are delimited by parentheses (round brackets), which can be nested.
+Turning part of a pattern into a subpattern does two things:
+<br>
+<br>
+1. It localizes a set of alternatives. For example, the pattern
+<pre>
+  cat(aract|erpillar|)
+</pre>
+matches one of the words "cat", "cataract", or "caterpillar". Without the
+parentheses, it would match "cataract", "erpillar" or an empty string.
+<br>
+<br>
+2. It sets up the subpattern as a capturing subpattern. This means that, when
+the whole pattern matches, that portion of the subject string that matched the
+subpattern is passed back to the caller via the <i>ovector</i> argument of
+<b>pcre_exec()</b>. Opening parentheses are counted from left to right (starting
+from 1) to obtain numbers for the capturing subpatterns.
+</P>
+<P>
+For example, if the string "the red king" is matched against the pattern
+<pre>
+  the ((red|white) (king|queen))
+</pre>
+the captured substrings are "red king", "red", and "king", and are numbered 1,
+2, and 3, respectively.
+</P>
+<P>
+The fact that plain parentheses fulfil two functions is not always helpful.
+There are often times when a grouping subpattern is required without a
+capturing requirement. If an opening parenthesis is followed by a question mark
+and a colon, the subpattern does not do any capturing, and is not counted when
+computing the number of any subsequent capturing subpatterns. For example, if
+the string "the white queen" is matched against the pattern
+<pre>
+  the ((?:red|white) (king|queen))
+</pre>
+the captured substrings are "white queen" and "queen", and are numbered 1 and
+2. The maximum number of capturing subpatterns is 65535.
+</P>
+<P>
+As a convenient shorthand, if any option settings are required at the start of
+a non-capturing subpattern, the option letters may appear between the "?" and
+the ":". Thus the two patterns
+<pre>
+  (?i:saturday|sunday)
+  (?:(?i)saturday|sunday)
+</pre>
+match exactly the same set of strings. Because alternative branches are tried
+from left to right, and options are not reset until the end of the subpattern
+is reached, an option setting in one branch does affect subsequent branches, so
+the above patterns match "SUNDAY" as well as "Saturday".
+</P>
+<br><a name="SEC13" href="#TOC1">DUPLICATE SUBPATTERN NUMBERS</a><br>
+<P>
+Perl 5.10 introduced a feature whereby each alternative in a subpattern uses
+the same numbers for its capturing parentheses. Such a subpattern starts with
+(?| and is itself a non-capturing subpattern. For example, consider this
+pattern:
+<pre>
+  (?|(Sat)ur|(Sun))day
+</pre>
+Because the two alternatives are inside a (?| group, both sets of capturing
+parentheses are numbered one. Thus, when the pattern matches, you can look
+at captured substring number one, whichever alternative matched. This construct
+is useful when you want to capture part, but not all, of one of a number of
+alternatives. Inside a (?| group, parentheses are numbered as usual, but the
+number is reset at the start of each branch. The numbers of any capturing
+buffers that follow the subpattern start after the highest number used in any
+branch. The following example is taken from the Perl documentation.
+The numbers underneath show in which buffer the captured content will be
+stored.
+<pre>
+  # before  ---------------branch-reset----------- after
+  / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
+  # 1            2         2  3        2     3     4
+</pre>
+A backreference or a recursive call to a numbered subpattern always refers to
+the first one in the pattern with the given number.
+</P>
+<P>
+An alternative approach to using this "branch reset" feature is to use
+duplicate named subpatterns, as described in the next section.
+</P>
+<br><a name="SEC14" href="#TOC1">NAMED SUBPATTERNS</a><br>
+<P>
+Identifying capturing parentheses by number is simple, but it can be very hard
+to keep track of the numbers in complicated regular expressions. Furthermore,
+if an expression is modified, the numbers may change. To help with this
+difficulty, PCRE supports the naming of subpatterns. This feature was not
+added to Perl until release 5.10. Python had the feature earlier, and PCRE
+introduced it at release 4.0, using the Python syntax. PCRE now supports both
+the Perl and the Python syntax.
+</P>
+<P>
+In PCRE, a subpattern can be named in one of three ways: (?&#60;name&#62;...) or
+(?'name'...) as in Perl, or (?P&#60;name&#62;...) as in Python. References to capturing
+parentheses from other parts of the pattern, such as
+<a href="#backreferences">backreferences,</a>
+<a href="#recursion">recursion,</a>
+and
+<a href="#conditions">conditions,</a>
+can be made by name as well as by number.
+</P>
+<P>
+Names consist of up to 32 alphanumeric characters and underscores. Named
+capturing parentheses are still allocated numbers as well as names, exactly as
+if the names were not present. The PCRE API provides function calls for
+extracting the name-to-number translation table from a compiled pattern. There
+is also a convenience function for extracting a captured substring by name.
+</P>
+<P>
+By default, a name must be unique within a pattern, but it is possible to relax
+this constraint by setting the PCRE_DUPNAMES option at compile time. This can
+be useful for patterns where only one instance of the named parentheses can
+match. Suppose you want to match the name of a weekday, either as a 3-letter
+abbreviation or as the full name, and in both cases you want to extract the
+abbreviation. This pattern (ignoring the line breaks) does the job:
+<pre>
+  (?&#60;DN&#62;Mon|Fri|Sun)(?:day)?|
+  (?&#60;DN&#62;Tue)(?:sday)?|
+  (?&#60;DN&#62;Wed)(?:nesday)?|
+  (?&#60;DN&#62;Thu)(?:rsday)?|
+  (?&#60;DN&#62;Sat)(?:urday)?
+</pre>
+There are five capturing substrings, but only one is ever set after a match.
+(An alternative way of solving this problem is to use a "branch reset"
+subpattern, as described in the previous section.)
+</P>
+<P>
+The convenience function for extracting the data by name returns the substring
+for the first (and in this example, the only) subpattern of that name that
+matched. This saves searching to find which numbered subpattern it was. If you
+make a reference to a non-unique named subpattern from elsewhere in the
+pattern, the one that corresponds to the lowest number is used. For further
+details of the interfaces for handling named subpatterns, see the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<br><a name="SEC15" href="#TOC1">REPETITION</a><br>
+<P>
+Repetition is specified by quantifiers, which can follow any of the following
+items:
+<pre>
+  a literal data character
+  the dot metacharacter
+  the \C escape sequence
+  the \X escape sequence (in UTF-8 mode with Unicode properties)
+  the \R escape sequence
+  an escape such as \d that matches a single character
+  a character class
+  a back reference (see next section)
+  a parenthesized subpattern (unless it is an assertion)
+</pre>
+The general repetition quantifier specifies a minimum and maximum number of
+permitted matches, by giving the two numbers in curly brackets (braces),
+separated by a comma. The numbers must be less than 65536, and the first must
+be less than or equal to the second. For example:
+<pre>
+  z{2,4}
+</pre>
+matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special
+character. If the second number is omitted, but the comma is present, there is
+no upper limit; if the second number and the comma are both omitted, the
+quantifier specifies an exact number of required matches. Thus
+<pre>
+  [aeiou]{3,}
+</pre>
+matches at least 3 successive vowels, but may match many more, while
+<pre>
+  \d{8}
+</pre>
+matches exactly 8 digits. An opening curly bracket that appears in a position
+where a quantifier is not allowed, or one that does not match the syntax of a
+quantifier, is taken as a literal character. For example, {,6} is not a
+quantifier, but a literal string of four characters.
+</P>
+<P>
+In UTF-8 mode, quantifiers apply to UTF-8 characters rather than to individual
+bytes. Thus, for example, \x{100}{2} matches two UTF-8 characters, each of
+which is represented by a two-byte sequence. Similarly, when Unicode property
+support is available, \X{3} matches three Unicode extended sequences, each of
+which may be several bytes long (and they may be of different lengths).
+</P>
+<P>
+The quantifier {0} is permitted, causing the expression to behave as if the
+previous item and the quantifier were not present. This may be useful for
+subpatterns that are referenced as
+<a href="#subpatternsassubroutines">subroutines</a>
+from elsewhere in the pattern. Items other than subpatterns that have a {0}
+quantifier are omitted from the compiled pattern.
+</P>
+<P>
+For convenience, the three most common quantifiers have single-character
+abbreviations:
+<pre>
+  *    is equivalent to {0,}
+  +    is equivalent to {1,}
+  ?    is equivalent to {0,1}
+</pre>
+It is possible to construct infinite loops by following a subpattern that can
+match no characters with a quantifier that has no upper limit, for example:
+<pre>
+  (a?)*
+</pre>
+Earlier versions of Perl and PCRE used to give an error at compile time for
+such patterns. However, because there are cases where this can be useful, such
+patterns are now accepted, but if any repetition of the subpattern does in fact
+match no characters, the loop is forcibly broken.
+</P>
+<P>
+By default, the quantifiers are "greedy", that is, they match as much as
+possible (up to the maximum number of permitted times), without causing the
+rest of the pattern to fail. The classic example of where this gives problems
+is in trying to match comments in C programs. These appear between /* and */
+and within the comment, individual * and / characters may appear. An attempt to
+match C comments by applying the pattern
+<pre>
+  /\*.*\*/
+</pre>
+to the string
+<pre>
+  /* first comment */  not comment  /* second comment */
+</pre>
+fails, because it matches the entire string owing to the greediness of the .*
+item.
+</P>
+<P>
+However, if a quantifier is followed by a question mark, it ceases to be
+greedy, and instead matches the minimum number of times possible, so the
+pattern
+<pre>
+  /\*.*?\*/
+</pre>
+does the right thing with the C comments. The meaning of the various
+quantifiers is not otherwise changed, just the preferred number of matches.
+Do not confuse this use of question mark with its use as a quantifier in its
+own right. Because it has two uses, it can sometimes appear doubled, as in
+<pre>
+  \d??\d
+</pre>
+which matches one digit by preference, but can match two if that is the only
+way the rest of the pattern matches.
+</P>
+<P>
+If the PCRE_UNGREEDY option is set (an option that is not available in Perl),
+the quantifiers are not greedy by default, but individual ones can be made
+greedy by following them with a question mark. In other words, it inverts the
+default behaviour.
+</P>
+<P>
+When a parenthesized subpattern is quantified with a minimum repeat count that
+is greater than 1 or with a limited maximum, more memory is required for the
+compiled pattern, in proportion to the size of the minimum or maximum.
+</P>
+<P>
+If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent
+to Perl's /s) is set, thus allowing the dot to match newlines, the pattern is
+implicitly anchored, because whatever follows will be tried against every
+character position in the subject string, so there is no point in retrying the
+overall match at any position after the first. PCRE normally treats such a
+pattern as though it were preceded by \A.
+</P>
+<P>
+In cases where it is known that the subject string contains no newlines, it is
+worth setting PCRE_DOTALL in order to obtain this optimization, or
+alternatively using ^ to indicate anchoring explicitly.
+</P>
+<P>
+However, there is one situation where the optimization cannot be used. When .*
+is inside capturing parentheses that are the subject of a backreference
+elsewhere in the pattern, a match at the start may fail where a later one
+succeeds. Consider, for example:
+<pre>
+  (.*)abc\1
+</pre>
+If the subject is "xyz123abc123" the match point is the fourth character. For
+this reason, such a pattern is not implicitly anchored.
+</P>
+<P>
+When a capturing subpattern is repeated, the value captured is the substring
+that matched the final iteration. For example, after
+<pre>
+  (tweedle[dume]{3}\s*)+
+</pre>
+has matched "tweedledum tweedledee" the value of the captured substring is
+"tweedledee". However, if there are nested capturing subpatterns, the
+corresponding captured values may have been set in previous iterations. For
+example, after
+<pre>
+  /(a|(b))+/
+</pre>
+matches "aba" the value of the second captured substring is "b".
+<a name="atomicgroup"></a></P>
+<br><a name="SEC16" href="#TOC1">ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS</a><br>
+<P>
+With both maximizing ("greedy") and minimizing ("ungreedy" or "lazy")
+repetition, failure of what follows normally causes the repeated item to be
+re-evaluated to see if a different number of repeats allows the rest of the
+pattern to match. Sometimes it is useful to prevent this, either to change the
+nature of the match, or to cause it fail earlier than it otherwise might, when
+the author of the pattern knows there is no point in carrying on.
+</P>
+<P>
+Consider, for example, the pattern \d+foo when applied to the subject line
+<pre>
+  123456bar
+</pre>
+After matching all 6 digits and then failing to match "foo", the normal
+action of the matcher is to try again with only 5 digits matching the \d+
+item, and then with 4, and so on, before ultimately failing. "Atomic grouping"
+(a term taken from Jeffrey Friedl's book) provides the means for specifying
+that once a subpattern has matched, it is not to be re-evaluated in this way.
+</P>
+<P>
+If we use atomic grouping for the previous example, the matcher gives up
+immediately on failing to match "foo" the first time. The notation is a kind of
+special parenthesis, starting with (?&#62; as in this example:
+<pre>
+  (?&#62;\d+)foo
+</pre>
+This kind of parenthesis "locks up" the  part of the pattern it contains once
+it has matched, and a failure further into the pattern is prevented from
+backtracking into it. Backtracking past it to previous items, however, works as
+normal.
+</P>
+<P>
+An alternative description is that a subpattern of this type matches the string
+of characters that an identical standalone pattern would match, if anchored at
+the current point in the subject string.
+</P>
+<P>
+Atomic grouping subpatterns are not capturing subpatterns. Simple cases such as
+the above example can be thought of as a maximizing repeat that must swallow
+everything it can. So, while both \d+ and \d+? are prepared to adjust the
+number of digits they match in order to make the rest of the pattern match,
+(?&#62;\d+) can only match an entire sequence of digits.
+</P>
+<P>
+Atomic groups in general can of course contain arbitrarily complicated
+subpatterns, and can be nested. However, when the subpattern for an atomic
+group is just a single repeated item, as in the example above, a simpler
+notation, called a "possessive quantifier" can be used. This consists of an
+additional + character following a quantifier. Using this notation, the
+previous example can be rewritten as
+<pre>
+  \d++foo
+</pre>
+Note that a possessive quantifier can be used with an entire group, for
+example:
+<pre>
+  (abc|xyz){2,3}+
+</pre>
+Possessive quantifiers are always greedy; the setting of the PCRE_UNGREEDY
+option is ignored. They are a convenient notation for the simpler forms of
+atomic group. However, there is no difference in the meaning of a possessive
+quantifier and the equivalent atomic group, though there may be a performance
+difference; possessive quantifiers should be slightly faster.
+</P>
+<P>
+The possessive quantifier syntax is an extension to the Perl 5.8 syntax.
+Jeffrey Friedl originated the idea (and the name) in the first edition of his
+book. Mike McCloskey liked it, so implemented it when he built Sun's Java
+package, and PCRE copied it from there. It ultimately found its way into Perl
+at release 5.10.
+</P>
+<P>
+PCRE has an optimization that automatically "possessifies" certain simple
+pattern constructs. For example, the sequence A+B is treated as A++B because
+there is no point in backtracking into a sequence of A's when B must follow.
+</P>
+<P>
+When a pattern contains an unlimited repeat inside a subpattern that can itself
+be repeated an unlimited number of times, the use of an atomic group is the
+only way to avoid some failing matches taking a very long time indeed. The
+pattern
+<pre>
+  (\D+|&#60;\d+&#62;)*[!?]
+</pre>
+matches an unlimited number of substrings that either consist of non-digits, or
+digits enclosed in &#60;&#62;, followed by either ! or ?. When it matches, it runs
+quickly. However, if it is applied to
+<pre>
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+</pre>
+it takes a long time before reporting failure. This is because the string can
+be divided between the internal \D+ repeat and the external * repeat in a
+large number of ways, and all have to be tried. (The example uses [!?] rather
+than a single character at the end, because both PCRE and Perl have an
+optimization that allows for fast failure when a single character is used. They
+remember the last single character that is required for a match, and fail early
+if it is not present in the string.) If the pattern is changed so that it uses
+an atomic group, like this:
+<pre>
+  ((?&#62;\D+)|&#60;\d+&#62;)*[!?]
+</pre>
+sequences of non-digits cannot be broken, and failure happens quickly.
+<a name="backreferences"></a></P>
+<br><a name="SEC17" href="#TOC1">BACK REFERENCES</a><br>
+<P>
+Outside a character class, a backslash followed by a digit greater than 0 (and
+possibly further digits) is a back reference to a capturing subpattern earlier
+(that is, to its left) in the pattern, provided there have been that many
+previous capturing left parentheses.
+</P>
+<P>
+However, if the decimal number following the backslash is less than 10, it is
+always taken as a back reference, and causes an error only if there are not
+that many capturing left parentheses in the entire pattern. In other words, the
+parentheses that are referenced need not be to the left of the reference for
+numbers less than 10. A "forward back reference" of this type can make sense
+when a repetition is involved and the subpattern to the right has participated
+in an earlier iteration.
+</P>
+<P>
+It is not possible to have a numerical "forward back reference" to a subpattern
+whose number is 10 or more using this syntax because a sequence such as \50 is
+interpreted as a character defined in octal. See the subsection entitled
+"Non-printing characters"
+<a href="#digitsafterbackslash">above</a>
+for further details of the handling of digits following a backslash. There is
+no such problem when named parentheses are used. A back reference to any
+subpattern is possible using named parentheses (see below).
+</P>
+<P>
+Another way of avoiding the ambiguity inherent in the use of digits following a
+backslash is to use the \g escape sequence, which is a feature introduced in
+Perl 5.10. This escape must be followed by an unsigned number or a negative
+number, optionally enclosed in braces. These examples are all identical:
+<pre>
+  (ring), \1
+  (ring), \g1
+  (ring), \g{1}
+</pre>
+An unsigned number specifies an absolute reference without the ambiguity that
+is present in the older syntax. It is also useful when literal digits follow
+the reference. A negative number is a relative reference. Consider this
+example:
+<pre>
+  (abc(def)ghi)\g{-1}
+</pre>
+The sequence \g{-1} is a reference to the most recently started capturing
+subpattern before \g, that is, is it equivalent to \2. Similarly, \g{-2}
+would be equivalent to \1. The use of relative references can be helpful in
+long patterns, and also in patterns that are created by joining together
+fragments that contain references within themselves.
+</P>
+<P>
+A back reference matches whatever actually matched the capturing subpattern in
+the current subject string, rather than anything matching the subpattern
+itself (see
+<a href="#subpatternsassubroutines">"Subpatterns as subroutines"</a>
+below for a way of doing that). So the pattern
+<pre>
+  (sens|respons)e and \1ibility
+</pre>
+matches "sense and sensibility" and "response and responsibility", but not
+"sense and responsibility". If caseful matching is in force at the time of the
+back reference, the case of letters is relevant. For example,
+<pre>
+  ((?i)rah)\s+\1
+</pre>
+matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
+capturing subpattern is matched caselessly.
+</P>
+<P>
+There are several different ways of writing back references to named
+subpatterns. The .NET syntax \k{name} and the Perl syntax \k&#60;name&#62; or
+\k'name' are supported, as is the Python syntax (?P=name). Perl 5.10's unified
+back reference syntax, in which \g can be used for both numeric and named
+references, is also supported. We could rewrite the above example in any of
+the following ways:
+<pre>
+  (?&#60;p1&#62;(?i)rah)\s+\k&#60;p1&#62;
+  (?'p1'(?i)rah)\s+\k{p1}
+  (?P&#60;p1&#62;(?i)rah)\s+(?P=p1)
+  (?&#60;p1&#62;(?i)rah)\s+\g{p1}
+</pre>
+A subpattern that is referenced by name may appear in the pattern before or
+after the reference.
+</P>
+<P>
+There may be more than one back reference to the same subpattern. If a
+subpattern has not actually been used in a particular match, any back
+references to it always fail. For example, the pattern
+<pre>
+  (a|(bc))\2
+</pre>
+always fails if it starts to match "a" rather than "bc". Because there may be
+many capturing parentheses in a pattern, all digits following the backslash are
+taken as part of a potential back reference number. If the pattern continues
+with a digit character, some delimiter must be used to terminate the back
+reference. If the PCRE_EXTENDED option is set, this can be whitespace.
+Otherwise an empty comment (see
+<a href="#comments">"Comments"</a>
+below) can be used.
+</P>
+<P>
+A back reference that occurs inside the parentheses to which it refers fails
+when the subpattern is first used, so, for example, (a\1) never matches.
+However, such references can be useful inside repeated subpatterns. For
+example, the pattern
+<pre>
+  (a|b\1)+
+</pre>
+matches any number of "a"s and also "aba", "ababbaa" etc. At each iteration of
+the subpattern, the back reference matches the character string corresponding
+to the previous iteration. In order for this to work, the pattern must be such
+that the first iteration does not need to match the back reference. This can be
+done using alternation, as in the example above, or by a quantifier with a
+minimum of zero.
+<a name="bigassertions"></a></P>
+<br><a name="SEC18" href="#TOC1">ASSERTIONS</a><br>
+<P>
+An assertion is a test on the characters following or preceding the current
+matching point that does not actually consume any characters. The simple
+assertions coded as \b, \B, \A, \G, \Z, \z, ^ and $ are described
+<a href="#smallassertions">above.</a>
+</P>
+<P>
+More complicated assertions are coded as subpatterns. There are two kinds:
+those that look ahead of the current position in the subject string, and those
+that look behind it. An assertion subpattern is matched in the normal way,
+except that it does not cause the current matching position to be changed.
+</P>
+<P>
+Assertion subpatterns are not capturing subpatterns, and may not be repeated,
+because it makes no sense to assert the same thing several times. If any kind
+of assertion contains capturing subpatterns within it, these are counted for
+the purposes of numbering the capturing subpatterns in the whole pattern.
+However, substring capturing is carried out only for positive assertions,
+because it does not make sense for negative assertions.
+</P>
+<br><b>
+Lookahead assertions
+</b><br>
+<P>
+Lookahead assertions start with (?= for positive assertions and (?! for
+negative assertions. For example,
+<pre>
+  \w+(?=;)
+</pre>
+matches a word followed by a semicolon, but does not include the semicolon in
+the match, and
+<pre>
+  foo(?!bar)
+</pre>
+matches any occurrence of "foo" that is not followed by "bar". Note that the
+apparently similar pattern
+<pre>
+  (?!foo)bar
+</pre>
+does not find an occurrence of "bar" that is preceded by something other than
+"foo"; it finds any occurrence of "bar" whatsoever, because the assertion
+(?!foo) is always true when the next three characters are "bar". A
+lookbehind assertion is needed to achieve the other effect.
+</P>
+<P>
+If you want to force a matching failure at some point in a pattern, the most
+convenient way to do it is with (?!) because an empty string always matches, so
+an assertion that requires there not to be an empty string must always fail.
+<a name="lookbehind"></a></P>
+<br><b>
+Lookbehind assertions
+</b><br>
+<P>
+Lookbehind assertions start with (?&#60;= for positive assertions and (?&#60;! for
+negative assertions. For example,
+<pre>
+  (?&#60;!foo)bar
+</pre>
+does find an occurrence of "bar" that is not preceded by "foo". The contents of
+a lookbehind assertion are restricted such that all the strings it matches must
+have a fixed length. However, if there are several top-level alternatives, they
+do not all have to have the same fixed length. Thus
+<pre>
+  (?&#60;=bullock|donkey)
+</pre>
+is permitted, but
+<pre>
+  (?&#60;!dogs?|cats?)
+</pre>
+causes an error at compile time. Branches that match different length strings
+are permitted only at the top level of a lookbehind assertion. This is an
+extension compared with Perl (at least for 5.8), which requires all branches to
+match the same length of string. An assertion such as
+<pre>
+  (?&#60;=ab(c|de))
+</pre>
+is not permitted, because its single top-level branch can match two different
+lengths, but it is acceptable if rewritten to use two top-level branches:
+<pre>
+  (?&#60;=abc|abde)
+</pre>
+In some cases, the Perl 5.10 escape sequence \K
+<a href="#resetmatchstart">(see above)</a>
+can be used instead of a lookbehind assertion; this is not restricted to a
+fixed-length.
+</P>
+<P>
+The implementation of lookbehind assertions is, for each alternative, to
+temporarily move the current position back by the fixed length and then try to
+match. If there are insufficient characters before the current position, the
+assertion fails.
+</P>
+<P>
+PCRE does not allow the \C escape (which matches a single byte in UTF-8 mode)
+to appear in lookbehind assertions, because it makes it impossible to calculate
+the length of the lookbehind. The \X and \R escapes, which can match
+different numbers of bytes, are also not permitted.
+</P>
+<P>
+Possessive quantifiers can be used in conjunction with lookbehind assertions to
+specify efficient matching at the end of the subject string. Consider a simple
+pattern such as
+<pre>
+  abcd$
+</pre>
+when applied to a long string that does not match. Because matching proceeds
+from left to right, PCRE will look for each "a" in the subject and then see if
+what follows matches the rest of the pattern. If the pattern is specified as
+<pre>
+  ^.*abcd$
+</pre>
+the initial .* matches the entire string at first, but when this fails (because
+there is no following "a"), it backtracks to match all but the last character,
+then all but the last two characters, and so on. Once again the search for "a"
+covers the entire string, from right to left, so we are no better off. However,
+if the pattern is written as
+<pre>
+  ^.*+(?&#60;=abcd)
+</pre>
+there can be no backtracking for the .*+ item; it can match only the entire
+string. The subsequent lookbehind assertion does a single test on the last four
+characters. If it fails, the match fails immediately. For long strings, this
+approach makes a significant difference to the processing time.
+</P>
+<br><b>
+Using multiple assertions
+</b><br>
+<P>
+Several assertions (of any sort) may occur in succession. For example,
+<pre>
+  (?&#60;=\d{3})(?&#60;!999)foo
+</pre>
+matches "foo" preceded by three digits that are not "999". Notice that each of
+the assertions is applied independently at the same point in the subject
+string. First there is a check that the previous three characters are all
+digits, and then there is a check that the same three characters are not "999".
+This pattern does <i>not</i> match "foo" preceded by six characters, the first
+of which are digits and the last three of which are not "999". For example, it
+doesn't match "123abcfoo". A pattern to do that is
+<pre>
+  (?&#60;=\d{3}...)(?&#60;!999)foo
+</pre>
+This time the first assertion looks at the preceding six characters, checking
+that the first three are digits, and then the second assertion checks that the
+preceding three characters are not "999".
+</P>
+<P>
+Assertions can be nested in any combination. For example,
+<pre>
+  (?&#60;=(?&#60;!foo)bar)baz
+</pre>
+matches an occurrence of "baz" that is preceded by "bar" which in turn is not
+preceded by "foo", while
+<pre>
+  (?&#60;=\d{3}(?!999)...)foo
+</pre>
+is another pattern that matches "foo" preceded by three digits and any three
+characters that are not "999".
+<a name="conditions"></a></P>
+<br><a name="SEC19" href="#TOC1">CONDITIONAL SUBPATTERNS</a><br>
+<P>
+It is possible to cause the matching process to obey a subpattern
+conditionally or to choose between two alternative subpatterns, depending on
+the result of an assertion, or whether a previous capturing subpattern matched
+or not. The two possible forms of conditional subpattern are
+<pre>
+  (?(condition)yes-pattern)
+  (?(condition)yes-pattern|no-pattern)
+</pre>
+If the condition is satisfied, the yes-pattern is used; otherwise the
+no-pattern (if present) is used. If there are more than two alternatives in the
+subpattern, a compile-time error occurs.
+</P>
+<P>
+There are four kinds of condition: references to subpatterns, references to
+recursion, a pseudo-condition called DEFINE, and assertions.
+</P>
+<br><b>
+Checking for a used subpattern by number
+</b><br>
+<P>
+If the text between the parentheses consists of a sequence of digits, the
+condition is true if the capturing subpattern of that number has previously
+matched. An alternative notation is to precede the digits with a plus or minus
+sign. In this case, the subpattern number is relative rather than absolute.
+The most recently opened parentheses can be referenced by (?(-1), the next most
+recent by (?(-2), and so on. In looping constructs it can also make sense to
+refer to subsequent groups with constructs such as (?(+2).
+</P>
+<P>
+Consider the following pattern, which contains non-significant white space to
+make it more readable (assume the PCRE_EXTENDED option) and to divide it into
+three parts for ease of discussion:
+<pre>
+  ( \( )?    [^()]+    (?(1) \) )
+</pre>
+The first part matches an optional opening parenthesis, and if that
+character is present, sets it as the first captured substring. The second part
+matches one or more characters that are not parentheses. The third part is a
+conditional subpattern that tests whether the first set of parentheses matched
+or not. If they did, that is, if subject started with an opening parenthesis,
+the condition is true, and so the yes-pattern is executed and a closing
+parenthesis is required. Otherwise, since no-pattern is not present, the
+subpattern matches nothing. In other words, this pattern matches a sequence of
+non-parentheses, optionally enclosed in parentheses.
+</P>
+<P>
+If you were embedding this pattern in a larger one, you could use a relative
+reference:
+<pre>
+  ...other stuff... ( \( )?    [^()]+    (?(-1) \) ) ...
+</pre>
+This makes the fragment independent of the parentheses in the larger pattern.
+</P>
+<br><b>
+Checking for a used subpattern by name
+</b><br>
+<P>
+Perl uses the syntax (?(&#60;name&#62;)...) or (?('name')...) to test for a used
+subpattern by name. For compatibility with earlier versions of PCRE, which had
+this facility before Perl, the syntax (?(name)...) is also recognized. However,
+there is a possible ambiguity with this syntax, because subpattern names may
+consist entirely of digits. PCRE looks first for a named subpattern; if it
+cannot find one and the name consists entirely of digits, PCRE looks for a
+subpattern of that number, which must be greater than zero. Using subpattern
+names that consist entirely of digits is not recommended.
+</P>
+<P>
+Rewriting the above example to use a named subpattern gives this:
+<pre>
+  (?&#60;OPEN&#62; \( )?    [^()]+    (?(&#60;OPEN&#62;) \) )
+
+</PRE>
+</P>
+<br><b>
+Checking for pattern recursion
+</b><br>
+<P>
+If the condition is the string (R), and there is no subpattern with the name R,
+the condition is true if a recursive call to the whole pattern or any
+subpattern has been made. If digits or a name preceded by ampersand follow the
+letter R, for example:
+<pre>
+  (?(R3)...) or (?(R&name)...)
+</pre>
+the condition is true if the most recent recursion is into the subpattern whose
+number or name is given. This condition does not check the entire recursion
+stack.
+</P>
+<P>
+At "top level", all these recursion test conditions are false. Recursive
+patterns are described below.
+</P>
+<br><b>
+Defining subpatterns for use by reference only
+</b><br>
+<P>
+If the condition is the string (DEFINE), and there is no subpattern with the
+name DEFINE, the condition is always false. In this case, there may be only one
+alternative in the subpattern. It is always skipped if control reaches this
+point in the pattern; the idea of DEFINE is that it can be used to define
+"subroutines" that can be referenced from elsewhere. (The use of "subroutines"
+is described below.) For example, a pattern to match an IPv4 address could be
+written like this (ignore whitespace and line breaks):
+<pre>
+  (?(DEFINE) (?&#60;byte&#62; 2[0-4]\d | 25[0-5] | 1\d\d | [1-9]?\d) )
+  \b (?&byte) (\.(?&byte)){3} \b
+</pre>
+The first part of the pattern is a DEFINE group inside which a another group
+named "byte" is defined. This matches an individual component of an IPv4
+address (a number less than 256). When matching takes place, this part of the
+pattern is skipped because DEFINE acts like a false condition.
+</P>
+<P>
+The rest of the pattern uses references to the named group to match the four
+dot-separated components of an IPv4 address, insisting on a word boundary at
+each end.
+</P>
+<br><b>
+Assertion conditions
+</b><br>
+<P>
+If the condition is not in any of the above formats, it must be an assertion.
+This may be a positive or negative lookahead or lookbehind assertion. Consider
+this pattern, again containing non-significant white space, and with the two
+alternatives on the second line:
+<pre>
+  (?(?=[^a-z]*[a-z])
+  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} )
+</pre>
+The condition is a positive lookahead assertion that matches an optional
+sequence of non-letters followed by a letter. In other words, it tests for the
+presence of at least one letter in the subject. If a letter is found, the
+subject is matched against the first alternative; otherwise it is matched
+against the second. This pattern matches strings in one of the two forms
+dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.
+<a name="comments"></a></P>
+<br><a name="SEC20" href="#TOC1">COMMENTS</a><br>
+<P>
+The sequence (?# marks the start of a comment that continues up to the next
+closing parenthesis. Nested parentheses are not permitted. The characters
+that make up a comment play no part in the pattern matching at all.
+</P>
+<P>
+If the PCRE_EXTENDED option is set, an unescaped # character outside a
+character class introduces a comment that continues to immediately after the
+next newline in the pattern.
+<a name="recursion"></a></P>
+<br><a name="SEC21" href="#TOC1">RECURSIVE PATTERNS</a><br>
+<P>
+Consider the problem of matching a string in parentheses, allowing for
+unlimited nested parentheses. Without the use of recursion, the best that can
+be done is to use a pattern that matches up to some fixed depth of nesting. It
+is not possible to handle an arbitrary nesting depth.
+</P>
+<P>
+For some time, Perl has provided a facility that allows regular expressions to
+recurse (amongst other things). It does this by interpolating Perl code in the
+expression at run time, and the code can refer to the expression itself. A Perl
+pattern using code interpolation to solve the parentheses problem can be
+created like this:
+<pre>
+  $re = qr{\( (?: (?&#62;[^()]+) | (?p{$re}) )* \)}x;
+</pre>
+The (?p{...}) item interpolates Perl code at run time, and in this case refers
+recursively to the pattern in which it appears.
+</P>
+<P>
+Obviously, PCRE cannot support the interpolation of Perl code. Instead, it
+supports special syntax for recursion of the entire pattern, and also for
+individual subpattern recursion. After its introduction in PCRE and Python,
+this kind of recursion was introduced into Perl at release 5.10.
+</P>
+<P>
+A special item that consists of (? followed by a number greater than zero and a
+closing parenthesis is a recursive call of the subpattern of the given number,
+provided that it occurs inside that subpattern. (If not, it is a "subroutine"
+call, which is described in the next section.) The special item (?R) or (?0) is
+a recursive call of the entire regular expression.
+</P>
+<P>
+In PCRE (like Python, but unlike Perl), a recursive subpattern call is always
+treated as an atomic group. That is, once it has matched some of the subject
+string, it is never re-entered, even if it contains untried alternatives and
+there is a subsequent matching failure.
+</P>
+<P>
+This PCRE pattern solves the nested parentheses problem (assume the
+PCRE_EXTENDED option is set so that white space is ignored):
+<pre>
+  \( ( (?&#62;[^()]+) | (?R) )* \)
+</pre>
+First it matches an opening parenthesis. Then it matches any number of
+substrings which can either be a sequence of non-parentheses, or a recursive
+match of the pattern itself (that is, a correctly parenthesized substring).
+Finally there is a closing parenthesis.
+</P>
+<P>
+If this were part of a larger pattern, you would not want to recurse the entire
+pattern, so instead you could use this:
+<pre>
+  ( \( ( (?&#62;[^()]+) | (?1) )* \) )
+</pre>
+We have put the pattern into parentheses, and caused the recursion to refer to
+them instead of the whole pattern.
+</P>
+<P>
+In a larger pattern, keeping track of parenthesis numbers can be tricky. This
+is made easier by the use of relative references. (A Perl 5.10 feature.)
+Instead of (?1) in the pattern above you can write (?-2) to refer to the second
+most recently opened parentheses preceding the recursion. In other words, a
+negative number counts capturing parentheses leftwards from the point at which
+it is encountered.
+</P>
+<P>
+It is also possible to refer to subsequently opened parentheses, by writing
+references such as (?+2). However, these cannot be recursive because the
+reference is not inside the parentheses that are referenced. They are always
+"subroutine" calls, as described in the next section.
+</P>
+<P>
+An alternative approach is to use named parentheses instead. The Perl syntax
+for this is (?&name); PCRE's earlier syntax (?P&#62;name) is also supported. We
+could rewrite the above example as follows:
+<pre>
+  (?&#60;pn&#62; \( ( (?&#62;[^()]+) | (?&pn) )* \) )
+</pre>
+If there is more than one subpattern with the same name, the earliest one is
+used.
+</P>
+<P>
+This particular example pattern that we have been looking at contains nested
+unlimited repeats, and so the use of atomic grouping for matching strings of
+non-parentheses is important when applying the pattern to strings that do not
+match. For example, when this pattern is applied to
+<pre>
+  (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
+</pre>
+it yields "no match" quickly. However, if atomic grouping is not used,
+the match runs for a very long time indeed because there are so many different
+ways the + and * repeats can carve up the subject, and all have to be tested
+before failure can be reported.
+</P>
+<P>
+At the end of a match, the values set for any capturing subpatterns are those
+from the outermost level of the recursion at which the subpattern value is set.
+If you want to obtain intermediate values, a callout function can be used (see
+below and the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation). If the pattern above is matched against
+<pre>
+  (ab(cd)ef)
+</pre>
+the value for the capturing parentheses is "ef", which is the last value taken
+on at the top level. If additional parentheses are added, giving
+<pre>
+  \( ( ( (?&#62;[^()]+) | (?R) )* ) \)
+     ^                        ^
+     ^                        ^
+</pre>
+the string they capture is "ab(cd)ef", the contents of the top level
+parentheses. If there are more than 15 capturing parentheses in a pattern, PCRE
+has to obtain extra memory to store data during a recursion, which it does by
+using <b>pcre_malloc</b>, freeing it via <b>pcre_free</b> afterwards. If no
+memory can be obtained, the match fails with the PCRE_ERROR_NOMEMORY error.
+</P>
+<P>
+Do not confuse the (?R) item with the condition (R), which tests for recursion.
+Consider this pattern, which matches text in angle brackets, allowing for
+arbitrary nesting. Only digits are allowed in nested brackets (that is, when
+recursing), whereas any characters are permitted at the outer level.
+<pre>
+  &#60; (?: (?(R) \d++  | [^&#60;&#62;]*+) | (?R)) * &#62;
+</pre>
+In this pattern, (?(R) is the start of a conditional subpattern, with two
+different alternatives for the recursive and non-recursive cases. The (?R) item
+is the actual recursive call.
+<a name="subpatternsassubroutines"></a></P>
+<br><a name="SEC22" href="#TOC1">SUBPATTERNS AS SUBROUTINES</a><br>
+<P>
+If the syntax for a recursive subpattern reference (either by number or by
+name) is used outside the parentheses to which it refers, it operates like a
+subroutine in a programming language. The "called" subpattern may be defined
+before or after the reference. A numbered reference can be absolute or
+relative, as in these examples:
+<pre>
+  (...(absolute)...)...(?2)...
+  (...(relative)...)...(?-1)...
+  (...(?+1)...(relative)...
+</pre>
+An earlier example pointed out that the pattern
+<pre>
+  (sens|respons)e and \1ibility
+</pre>
+matches "sense and sensibility" and "response and responsibility", but not
+"sense and responsibility". If instead the pattern
+<pre>
+  (sens|respons)e and (?1)ibility
+</pre>
+is used, it does match "sense and responsibility" as well as the other two
+strings. Another example is given in the discussion of DEFINE above.
+</P>
+<P>
+Like recursive subpatterns, a "subroutine" call is always treated as an atomic
+group. That is, once it has matched some of the subject string, it is never
+re-entered, even if it contains untried alternatives and there is a subsequent
+matching failure.
+</P>
+<P>
+When a subpattern is used as a subroutine, processing options such as
+case-independence are fixed when the subpattern is defined. They cannot be
+changed for different calls. For example, consider this pattern:
+<pre>
+  (abc)(?i:(?-1))
+</pre>
+It matches "abcabc". It does not match "abcABC" because the change of
+processing option does not affect the called subpattern.
+<a name="onigurumasubroutines"></a></P>
+<br><a name="SEC23" href="#TOC1">ONIGURUMA SUBROUTINE SYNTAX</a><br>
+<P>
+For compatibility with Oniguruma, the non-Perl syntax \g followed by a name or
+a number enclosed either in angle brackets or single quotes, is an alternative
+syntax for referencing a subpattern as a subroutine, possibly recursively. Here
+are two of the examples used above, rewritten using this syntax:
+<pre>
+  (?&#60;pn&#62; \( ( (?&#62;[^()]+) | \g&#60;pn&#62; )* \) )
+  (sens|respons)e and \g'1'ibility
+</pre>
+PCRE supports an extension to Oniguruma: if a number is preceded by a
+plus or a minus sign it is taken as a relative reference. For example:
+<pre>
+  (abc)(?i:\g&#60;-1&#62;)
+</pre>
+Note that \g{...} (Perl syntax) and \g&#60;...&#62; (Oniguruma syntax) are <i>not</i>
+synonymous. The former is a back reference; the latter is a subroutine call.
+</P>
+<br><a name="SEC24" href="#TOC1">CALLOUTS</a><br>
+<P>
+Perl has a feature whereby using the sequence (?{...}) causes arbitrary Perl
+code to be obeyed in the middle of matching a regular expression. This makes it
+possible, amongst other things, to extract different substrings that match the
+same pair of parentheses when there is a repetition.
+</P>
+<P>
+PCRE provides a similar feature, but of course it cannot obey arbitrary Perl
+code. The feature is called "callout". The caller of PCRE provides an external
+function by putting its entry point in the global variable <i>pcre_callout</i>.
+By default, this variable contains NULL, which disables all calling out.
+</P>
+<P>
+Within a regular expression, (?C) indicates the points at which the external
+function is to be called. If you want to identify different callout points, you
+can put a number less than 256 after the letter C. The default value is zero.
+For example, this pattern has two callout points:
+<pre>
+  (?C1)abc(?C2)def
+</pre>
+If the PCRE_AUTO_CALLOUT flag is passed to <b>pcre_compile()</b>, callouts are
+automatically installed before each item in the pattern. They are all numbered
+255.
+</P>
+<P>
+During matching, when PCRE reaches a callout point (and <i>pcre_callout</i> is
+set), the external function is called. It is provided with the number of the
+callout, the position in the pattern, and, optionally, one item of data
+originally supplied by the caller of <b>pcre_exec()</b>. The callout function
+may cause matching to proceed, to backtrack, or to fail altogether. A complete
+description of the interface to the callout function is given in the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation.
+</P>
+<br><a name="SEC25" href="#TOC1">BACKTRACKING CONTROL</a><br>
+<P>
+Perl 5.10 introduced a number of "Special Backtracking Control Verbs", which
+are described in the Perl documentation as "experimental and subject to change
+or removal in a future version of Perl". It goes on to say: "Their usage in
+production code should be noted to avoid problems during upgrades." The same
+remarks apply to the PCRE features described in this section.
+</P>
+<P>
+Since these verbs are specifically related to backtracking, most of them can be
+used only when the pattern is to be matched using <b>pcre_exec()</b>, which uses
+a backtracking algorithm. With the exception of (*FAIL), which behaves like a
+failing negative assertion, they cause an error if encountered by
+<b>pcre_dfa_exec()</b>.
+</P>
+<P>
+The new verbs make use of what was previously invalid syntax: an opening
+parenthesis followed by an asterisk. In Perl, they are generally of the form
+(*VERB:ARG) but PCRE does not support the use of arguments, so its general
+form is just (*VERB). Any number of these verbs may occur in a pattern. There
+are two kinds:
+</P>
+<br><b>
+Verbs that act immediately
+</b><br>
+<P>
+The following verbs act as soon as they are encountered:
+<pre>
+   (*ACCEPT)
+</pre>
+This verb causes the match to end successfully, skipping the remainder of the
+pattern. When inside a recursion, only the innermost pattern is ended
+immediately. PCRE differs from Perl in what happens if the (*ACCEPT) is inside
+capturing parentheses. In Perl, the data so far is captured: in PCRE no data is
+captured. For example:
+<pre>
+  A(A|B(*ACCEPT)|C)D
+</pre>
+This matches "AB", "AAD", or "ACD", but when it matches "AB", no data is
+captured.
+<pre>
+  (*FAIL) or (*F)
+</pre>
+This verb causes the match to fail, forcing backtracking to occur. It is
+equivalent to (?!) but easier to read. The Perl documentation notes that it is
+probably useful only when combined with (?{}) or (??{}). Those are, of course,
+Perl features that are not present in PCRE. The nearest equivalent is the
+callout feature, as for example in this pattern:
+<pre>
+  a+(?C)(*FAIL)
+</pre>
+A match with the string "aaaa" always fails, but the callout is taken before
+each backtrack happens (in this example, 10 times).
+</P>
+<br><b>
+Verbs that act after backtracking
+</b><br>
+<P>
+The following verbs do nothing when they are encountered. Matching continues
+with what follows, but if there is no subsequent match, a failure is forced.
+The verbs differ in exactly what kind of failure occurs.
+<pre>
+  (*COMMIT)
+</pre>
+This verb causes the whole match to fail outright if the rest of the pattern
+does not match. Even if the pattern is unanchored, no further attempts to find
+a match by advancing the start point take place. Once (*COMMIT) has been
+passed, <b>pcre_exec()</b> is committed to finding a match at the current
+starting point, or not at all. For example:
+<pre>
+  a+(*COMMIT)b
+</pre>
+This matches "xxaab" but not "aacaab". It can be thought of as a kind of
+dynamic anchor, or "I've started, so I must finish."
+<pre>
+  (*PRUNE)
+</pre>
+This verb causes the match to fail at the current position if the rest of the
+pattern does not match. If the pattern is unanchored, the normal "bumpalong"
+advance to the next starting character then happens. Backtracking can occur as
+usual to the left of (*PRUNE), or when matching to the right of (*PRUNE), but
+if there is no match to the right, backtracking cannot cross (*PRUNE).
+In simple cases, the use of (*PRUNE) is just an alternative to an atomic
+group or possessive quantifier, but there are some uses of (*PRUNE) that cannot
+be expressed in any other way.
+<pre>
+  (*SKIP)
+</pre>
+This verb is like (*PRUNE), except that if the pattern is unanchored, the
+"bumpalong" advance is not to the next character, but to the position in the
+subject where (*SKIP) was encountered. (*SKIP) signifies that whatever text
+was matched leading up to it cannot be part of a successful match. Consider:
+<pre>
+  a+(*SKIP)b
+</pre>
+If the subject is "aaaac...", after the first match attempt fails (starting at
+the first character in the string), the starting point skips on to start the
+next attempt at "c". Note that a possessive quantifer does not have the same
+effect in this example; although it would suppress backtracking during the
+first match attempt, the second attempt would start at the second character
+instead of skipping on to "c".
+<pre>
+  (*THEN)
+</pre>
+This verb causes a skip to the next alternation if the rest of the pattern does
+not match. That is, it cancels pending backtracking, but only within the
+current alternation. Its name comes from the observation that it can be used
+for a pattern-based if-then-else block:
+<pre>
+  ( COND1 (*THEN) FOO | COND2 (*THEN) BAR | COND3 (*THEN) BAZ ) ...
+</pre>
+If the COND1 pattern matches, FOO is tried (and possibly further items after
+the end of the group if FOO succeeds); on failure the matcher skips to the
+second alternative and tries COND2, without backtracking into COND1. If (*THEN)
+is used outside of any alternation, it acts exactly like (*PRUNE).
+</P>
+<br><a name="SEC26" href="#TOC1">SEE ALSO</a><br>
+<P>
+<b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrematching</b>(3), <b>pcre</b>(3).
+</P>
+<br><a name="SEC27" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC28" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 19 April 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcreperform.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,173 @@
+<html>
+<head>
+<title>pcreperform specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcreperform man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+PCRE PERFORMANCE
+</b><br>
+<P>
+Two aspects of performance are discussed below: memory usage and processing
+time. The way you express your pattern as a regular expression can affect both
+of them.
+</P>
+<br><b>
+MEMORY USAGE
+</b><br>
+<P>
+Patterns are compiled by PCRE into a reasonably efficient byte code, so that
+most simple patterns do not use much memory. However, there is one case where
+memory usage can be unexpectedly large. When a parenthesized subpattern has a
+quantifier with a minimum greater than 1 and/or a limited maximum, the whole
+subpattern is repeated in the compiled code. For example, the pattern
+<pre>
+  (abc|def){2,4}
+</pre>
+is compiled as if it were
+<pre>
+  (abc|def)(abc|def)((abc|def)(abc|def)?)?
+</pre>
+(Technical aside: It is done this way so that backtrack points within each of
+the repetitions can be independently maintained.)
+</P>
+<P>
+For regular expressions whose quantifiers use only small numbers, this is not
+usually a problem. However, if the numbers are large, and particularly if such
+repetitions are nested, the memory usage can become an embarrassment. For
+example, the very simple pattern
+<pre>
+  ((ab){1,1000}c){1,3}
+</pre>
+uses 51K bytes when compiled. When PCRE is compiled with its default internal
+pointer size of two bytes, the size limit on a compiled pattern is 64K, and
+this is reached with the above pattern if the outer repetition is increased
+from 3 to 4. PCRE can be compiled to use larger internal pointers and thus
+handle larger compiled patterns, but it is better to try to rewrite your
+pattern to use less memory if you can.
+</P>
+<P>
+One way of reducing the memory usage for such patterns is to make use of PCRE's
+<a href="pcrepattern.html#subpatternsassubroutines">"subroutine"</a>
+facility. Re-writing the above pattern as
+<pre>
+  ((ab)(?2){0,999}c)(?1){0,2}
+</pre>
+reduces the memory requirements to 18K, and indeed it remains under 20K even
+with the outer repetition increased to 100. However, this pattern is not
+exactly equivalent, because the "subroutine" calls are treated as
+<a href="pcrepattern.html#atomicgroup">atomic groups</a>
+into which there can be no backtracking if there is a subsequent matching
+failure. Therefore, PCRE cannot do this kind of rewriting automatically.
+Furthermore, there is a noticeable loss of speed when executing the modified
+pattern. Nevertheless, if the atomic grouping is not a problem and the loss of
+speed is acceptable, this kind of rewriting will allow you to process patterns
+that PCRE cannot otherwise handle.
+</P>
+<br><b>
+PROCESSING TIME
+</b><br>
+<P>
+Certain items in regular expression patterns are processed more efficiently
+than others. It is more efficient to use a character class like [aeiou] than a
+set of single-character alternatives such as (a|e|i|o|u). In general, the
+simplest construction that provides the required behaviour is usually the most
+efficient. Jeffrey Friedl's book contains a lot of useful general discussion
+about optimizing regular expressions for efficient performance. This document
+contains a few observations about PCRE.
+</P>
+<P>
+Using Unicode character properties (the \p, \P, and \X escapes) is slow,
+because PCRE has to scan a structure that contains data for over fifteen
+thousand characters whenever it needs a character's property. If you can find
+an alternative pattern that does not use character properties, it will probably
+be faster.
+</P>
+<P>
+When a pattern begins with .* not in parentheses, or in parentheses that are
+not the subject of a backreference, and the PCRE_DOTALL option is set, the
+pattern is implicitly anchored by PCRE, since it can match only at the start of
+a subject string. However, if PCRE_DOTALL is not set, PCRE cannot make this
+optimization, because the . metacharacter does not then match a newline, and if
+the subject string contains newlines, the pattern may match from the character
+immediately following one of them instead of from the very start. For example,
+the pattern
+<pre>
+  .*second
+</pre>
+matches the subject "first\nand second" (where \n stands for a newline
+character), with the match starting at the seventh character. In order to do
+this, PCRE has to retry the match starting after every newline in the subject.
+</P>
+<P>
+If you are using such a pattern with subject strings that do not contain
+newlines, the best performance is obtained by setting PCRE_DOTALL, or starting
+the pattern with ^.* or ^.*? to indicate explicit anchoring. That saves PCRE
+from having to scan along the subject looking for a newline to restart at.
+</P>
+<P>
+Beware of patterns that contain nested indefinite repeats. These can take a
+long time to run when applied to a string that does not match. Consider the
+pattern fragment
+<pre>
+  ^(a+)*
+</pre>
+This can match "aaaa" in 16 different ways, and this number increases very
+rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4
+times, and for each of those cases other than 0 or 4, the + repeats can match
+different numbers of times.) When the remainder of the pattern is such that the
+entire match is going to fail, PCRE has in principle to try every possible
+variation, and this can take an extremely long time, even for relatively short
+strings.
+</P>
+<P>
+An optimization catches some of the more simple cases such as
+<pre>
+  (a+)*b
+</pre>
+where a literal character follows. Before embarking on the standard matching
+procedure, PCRE checks that there is a "b" later in the subject string, and if
+there is not, it fails the match immediately. However, when there is no
+following literal this optimization cannot be used. You can see the difference
+by comparing the behaviour of
+<pre>
+  (a+)*\d
+</pre>
+with the pattern above. The former gives a failure almost instantly when
+applied to a whole line of "a" characters, whereas the latter takes an
+appreciable time with strings longer than about 20 characters.
+</P>
+<P>
+In many cases, the solution to this kind of performance issue is to use an
+atomic group or a possessive quantifier.
+</P>
+<br><b>
+AUTHOR
+</b><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><b>
+REVISION
+</b><br>
+<P>
+Last updated: 06 March 2007
+<br>
+Copyright &copy; 1997-2007 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcreposix.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,260 @@
+<html>
+<head>
+<title>pcreposix specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcreposix man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS OF POSIX API</a>
+<li><a name="TOC2" href="#SEC2">DESCRIPTION</a>
+<li><a name="TOC3" href="#SEC3">COMPILING A PATTERN</a>
+<li><a name="TOC4" href="#SEC4">MATCHING NEWLINE CHARACTERS</a>
+<li><a name="TOC5" href="#SEC5">MATCHING A PATTERN</a>
+<li><a name="TOC6" href="#SEC6">ERROR MESSAGES</a>
+<li><a name="TOC7" href="#SEC7">MEMORY USAGE</a>
+<li><a name="TOC8" href="#SEC8">AUTHOR</a>
+<li><a name="TOC9" href="#SEC9">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS OF POSIX API</a><br>
+<P>
+<b>#include &#60;pcreposix.h&#62;</b>
+</P>
+<P>
+<b>int regcomp(regex_t *<i>preg</i>, const char *<i>pattern</i>,</b>
+<b>int <i>cflags</i>);</b>
+</P>
+<P>
+<b>int regexec(regex_t *<i>preg</i>, const char *<i>string</i>,</b>
+<b>size_t <i>nmatch</i>, regmatch_t <i>pmatch</i>[], int <i>eflags</i>);</b>
+</P>
+<P>
+<b>size_t regerror(int <i>errcode</i>, const regex_t *<i>preg</i>,</b>
+<b>char *<i>errbuf</i>, size_t <i>errbuf_size</i>);</b>
+</P>
+<P>
+<b>void regfree(regex_t *<i>preg</i>);</b>
+</P>
+<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
+<P>
+This set of functions provides a POSIX-style API to the PCRE regular expression
+package. See the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation for a description of PCRE's native API, which contains much
+additional functionality.
+</P>
+<P>
+The functions described here are just wrapper functions that ultimately call
+the PCRE native API. Their prototypes are defined in the <b>pcreposix.h</b>
+header file, and on Unix systems the library itself is called
+<b>pcreposix.a</b>, so can be accessed by adding <b>-lpcreposix</b> to the
+command for linking an application that uses them. Because the POSIX functions
+call the native ones, it is also necessary to add <b>-lpcre</b>.
+</P>
+<P>
+I have implemented only those option bits that can be reasonably mapped to PCRE
+native options. In addition, the option REG_EXTENDED is defined with the value
+zero. This has no effect, but since programs that are written to the POSIX
+interface often use it, this makes it easier to slot in PCRE as a replacement
+library. Other POSIX options are not even defined.
+</P>
+<P>
+When PCRE is called via these functions, it is only the API that is POSIX-like
+in style. The syntax and semantics of the regular expressions themselves are
+still those of Perl, subject to the setting of various PCRE options, as
+described below. "POSIX-like in style" means that the API approximates to the
+POSIX definition; it is not fully POSIX-compatible, and in multi-byte encoding
+domains it is probably even less compatible.
+</P>
+<P>
+The header for these functions is supplied as <b>pcreposix.h</b> to avoid any
+potential clash with other POSIX libraries. It can, of course, be renamed or
+aliased as <b>regex.h</b>, which is the "correct" name. It provides two
+structure types, <i>regex_t</i> for compiled internal forms, and
+<i>regmatch_t</i> for returning captured substrings. It also defines some
+constants whose names start with "REG_"; these are used for setting options and
+identifying error codes.
+</P>
+<P>
+</P>
+<br><a name="SEC3" href="#TOC1">COMPILING A PATTERN</a><br>
+<P>
+The function <b>regcomp()</b> is called to compile a pattern into an
+internal form. The pattern is a C string terminated by a binary zero, and
+is passed in the argument <i>pattern</i>. The <i>preg</i> argument is a pointer
+to a <b>regex_t</b> structure that is used as a base for storing information
+about the compiled regular expression.
+</P>
+<P>
+The argument <i>cflags</i> is either zero, or contains one or more of the bits
+defined by the following macros:
+<pre>
+  REG_DOTALL
+</pre>
+The PCRE_DOTALL option is set when the regular expression is passed for
+compilation to the native function. Note that REG_DOTALL is not part of the
+POSIX standard.
+<pre>
+  REG_ICASE
+</pre>
+The PCRE_CASELESS option is set when the regular expression is passed for
+compilation to the native function.
+<pre>
+  REG_NEWLINE
+</pre>
+The PCRE_MULTILINE option is set when the regular expression is passed for
+compilation to the native function. Note that this does <i>not</i> mimic the
+defined POSIX behaviour for REG_NEWLINE (see the following section).
+<pre>
+  REG_NOSUB
+</pre>
+The PCRE_NO_AUTO_CAPTURE option is set when the regular expression is passed
+for compilation to the native function. In addition, when a pattern that is
+compiled with this flag is passed to <b>regexec()</b> for matching, the
+<i>nmatch</i> and <i>pmatch</i> arguments are ignored, and no captured strings
+are returned.
+<pre>
+  REG_UTF8
+</pre>
+The PCRE_UTF8 option is set when the regular expression is passed for
+compilation to the native function. This causes the pattern itself and all data
+strings used for matching it to be treated as UTF-8 strings. Note that REG_UTF8
+is not part of the POSIX standard.
+</P>
+<P>
+In the absence of these flags, no options are passed to the native function.
+This means the the regex is compiled with PCRE default semantics. In
+particular, the way it handles newline characters in the subject string is the
+Perl way, not the POSIX way. Note that setting PCRE_MULTILINE has only
+<i>some</i> of the effects specified for REG_NEWLINE. It does not affect the way
+newlines are matched by . (they aren't) or by a negative class such as [^a]
+(they are).
+</P>
+<P>
+The yield of <b>regcomp()</b> is zero on success, and non-zero otherwise. The
+<i>preg</i> structure is filled in on success, and one member of the structure
+is public: <i>re_nsub</i> contains the number of capturing subpatterns in
+the regular expression. Various error codes are defined in the header file.
+</P>
+<br><a name="SEC4" href="#TOC1">MATCHING NEWLINE CHARACTERS</a><br>
+<P>
+This area is not simple, because POSIX and Perl take different views of things.
+It is not possible to get PCRE to obey POSIX semantics, but then PCRE was never
+intended to be a POSIX engine. The following table lists the different
+possibilities for matching newline characters in PCRE:
+<pre>
+                          Default   Change with
+
+  . matches newline          no     PCRE_DOTALL
+  newline matches [^a]       yes    not changeable
+  $ matches \n at end        yes    PCRE_DOLLARENDONLY
+  $ matches \n in middle     no     PCRE_MULTILINE
+  ^ matches \n in middle     no     PCRE_MULTILINE
+</pre>
+This is the equivalent table for POSIX:
+<pre>
+                          Default   Change with
+
+  . matches newline          yes    REG_NEWLINE
+  newline matches [^a]       yes    REG_NEWLINE
+  $ matches \n at end        no     REG_NEWLINE
+  $ matches \n in middle     no     REG_NEWLINE
+  ^ matches \n in middle     no     REG_NEWLINE
+</pre>
+PCRE's behaviour is the same as Perl's, except that there is no equivalent for
+PCRE_DOLLAR_ENDONLY in Perl. In both PCRE and Perl, there is no way to stop
+newline from matching [^a].
+</P>
+<P>
+The default POSIX newline handling can be obtained by setting PCRE_DOTALL and
+PCRE_DOLLAR_ENDONLY, but there is no way to make PCRE behave exactly as for the
+REG_NEWLINE action.
+</P>
+<br><a name="SEC5" href="#TOC1">MATCHING A PATTERN</a><br>
+<P>
+The function <b>regexec()</b> is called to match a compiled pattern <i>preg</i>
+against a given <i>string</i>, which is by default terminated by a zero byte
+(but see REG_STARTEND below), subject to the options in <i>eflags</i>. These can
+be:
+<pre>
+  REG_NOTBOL
+</pre>
+The PCRE_NOTBOL option is set when calling the underlying PCRE matching
+function.
+<pre>
+  REG_NOTEOL
+</pre>
+The PCRE_NOTEOL option is set when calling the underlying PCRE matching
+function.
+<pre>
+  REG_STARTEND
+</pre>
+The string is considered to start at <i>string</i> + <i>pmatch[0].rm_so</i> and
+to have a terminating NUL located at <i>string</i> + <i>pmatch[0].rm_eo</i>
+(there need not actually be a NUL at that location), regardless of the value of
+<i>nmatch</i>. This is a BSD extension, compatible with but not specified by
+IEEE Standard 1003.2 (POSIX.2), and should be used with caution in software
+intended to be portable to other systems. Note that a non-zero <i>rm_so</i> does
+not imply REG_NOTBOL; REG_STARTEND affects only the location of the string, not
+how it is matched.
+</P>
+<P>
+If the pattern was compiled with the REG_NOSUB flag, no data about any matched
+strings is returned. The <i>nmatch</i> and <i>pmatch</i> arguments of
+<b>regexec()</b> are ignored.
+</P>
+<P>
+Otherwise,the portion of the string that was matched, and also any captured
+substrings, are returned via the <i>pmatch</i> argument, which points to an
+array of <i>nmatch</i> structures of type <i>regmatch_t</i>, containing the
+members <i>rm_so</i> and <i>rm_eo</i>. These contain the offset to the first
+character of each substring and the offset to the first character after the end
+of each substring, respectively. The 0th element of the vector relates to the
+entire portion of <i>string</i> that was matched; subsequent elements relate to
+the capturing subpatterns of the regular expression. Unused entries in the
+array have both structure members set to -1.
+</P>
+<P>
+A successful match yields a zero return; various error codes are defined in the
+header file, of which REG_NOMATCH is the "expected" failure code.
+</P>
+<br><a name="SEC6" href="#TOC1">ERROR MESSAGES</a><br>
+<P>
+The <b>regerror()</b> function maps a non-zero errorcode from either
+<b>regcomp()</b> or <b>regexec()</b> to a printable message. If <i>preg</i> is not
+NULL, the error should have arisen from the use of that structure. A message
+terminated by a binary zero is placed in <i>errbuf</i>. The length of the
+message, including the zero, is limited to <i>errbuf_size</i>. The yield of the
+function is the size of buffer needed to hold the whole message.
+</P>
+<br><a name="SEC7" href="#TOC1">MEMORY USAGE</a><br>
+<P>
+Compiling a regular expression causes memory to be allocated and associated
+with the <i>preg</i> structure. The function <b>regfree()</b> frees all such
+memory, after which <i>preg</i> may no longer be used as a compiled expression.
+</P>
+<br><a name="SEC8" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC9" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 05 April 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcreprecompile.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,148 @@
+<html>
+<head>
+<title>pcreprecompile specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcreprecompile man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SAVING AND RE-USING PRECOMPILED PCRE PATTERNS</a>
+<li><a name="TOC2" href="#SEC2">SAVING A COMPILED PATTERN</a>
+<li><a name="TOC3" href="#SEC3">RE-USING A PRECOMPILED PATTERN</a>
+<li><a name="TOC4" href="#SEC4">COMPATIBILITY WITH DIFFERENT PCRE RELEASES</a>
+<li><a name="TOC5" href="#SEC5">AUTHOR</a>
+<li><a name="TOC6" href="#SEC6">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SAVING AND RE-USING PRECOMPILED PCRE PATTERNS</a><br>
+<P>
+If you are running an application that uses a large number of regular
+expression patterns, it may be useful to store them in a precompiled form
+instead of having to compile them every time the application is run.
+If you are not using any private character tables (see the
+<a href="pcre_maketables.html"><b>pcre_maketables()</b></a>
+documentation), this is relatively straightforward. If you are using private
+tables, it is a little bit more complicated.
+</P>
+<P>
+If you save compiled patterns to a file, you can copy them to a different host
+and run them there. This works even if the new host has the opposite endianness
+to the one on which the patterns were compiled. There may be a small
+performance penalty, but it should be insignificant. However, compiling regular
+expressions with one version of PCRE for use with a different version is not
+guaranteed to work and may cause crashes.
+</P>
+<br><a name="SEC2" href="#TOC1">SAVING A COMPILED PATTERN</a><br>
+<P>
+The value returned by <b>pcre_compile()</b> points to a single block of memory
+that holds the compiled pattern and associated data. You can find the length of
+this block in bytes by calling <b>pcre_fullinfo()</b> with an argument of
+PCRE_INFO_SIZE. You can then save the data in any appropriate manner. Here is
+sample code that compiles a pattern and writes it to a file. It assumes that
+the variable <i>fd</i> refers to a file that is open for output:
+<pre>
+  int erroroffset, rc, size;
+  char *error;
+  pcre *re;
+
+  re = pcre_compile("my pattern", 0, &error, &erroroffset, NULL);
+  if (re == NULL) { ... handle errors ... }
+  rc = pcre_fullinfo(re, NULL, PCRE_INFO_SIZE, &size);
+  if (rc &#60; 0) { ... handle errors ... }
+  rc = fwrite(re, 1, size, fd);
+  if (rc != size) { ... handle errors ... }
+</pre>
+In this example, the bytes that comprise the compiled pattern are copied
+exactly. Note that this is binary data that may contain any of the 256 possible
+byte values. On systems that make a distinction between binary and non-binary
+data, be sure that the file is opened for binary output.
+</P>
+<P>
+If you want to write more than one pattern to a file, you will have to devise a
+way of separating them. For binary data, preceding each pattern with its length
+is probably the most straightforward approach. Another possibility is to write
+out the data in hexadecimal instead of binary, one pattern to a line.
+</P>
+<P>
+Saving compiled patterns in a file is only one possible way of storing them for
+later use. They could equally well be saved in a database, or in the memory of
+some daemon process that passes them via sockets to the processes that want
+them.
+</P>
+<P>
+If the pattern has been studied, it is also possible to save the study data in
+a similar way to the compiled pattern itself. When studying generates
+additional information, <b>pcre_study()</b> returns a pointer to a
+<b>pcre_extra</b> data block. Its format is defined in the
+<a href="pcreapi.html#extradata">section on matching a pattern</a>
+in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation. The <i>study_data</i> field points to the binary study data, and
+this is what you must save (not the <b>pcre_extra</b> block itself). The length
+of the study data can be obtained by calling <b>pcre_fullinfo()</b> with an
+argument of PCRE_INFO_STUDYSIZE. Remember to check that <b>pcre_study()</b> did
+return a non-NULL value before trying to save the study data.
+</P>
+<br><a name="SEC3" href="#TOC1">RE-USING A PRECOMPILED PATTERN</a><br>
+<P>
+Re-using a precompiled pattern is straightforward. Having reloaded it into main
+memory, you pass its pointer to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> in
+the usual way. This should work even on another host, and even if that host has
+the opposite endianness to the one where the pattern was compiled.
+</P>
+<P>
+However, if you passed a pointer to custom character tables when the pattern
+was compiled (the <i>tableptr</i> argument of <b>pcre_compile()</b>), you must
+now pass a similar pointer to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>,
+because the value saved with the compiled pattern will obviously be nonsense. A
+field in a <b>pcre_extra()</b> block is used to pass this data, as described in
+the
+<a href="pcreapi.html#extradata">section on matching a pattern</a>
+in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<P>
+If you did not provide custom character tables when the pattern was compiled,
+the pointer in the compiled pattern is NULL, which causes <b>pcre_exec()</b> to
+use PCRE's internal tables. Thus, you do not need to take any special action at
+run time in this case.
+</P>
+<P>
+If you saved study data with the compiled pattern, you need to create your own
+<b>pcre_extra</b> data block and set the <i>study_data</i> field to point to the
+reloaded study data. You must also set the PCRE_EXTRA_STUDY_DATA bit in the
+<i>flags</i> field to indicate that study data is present. Then pass the
+<b>pcre_extra</b> block to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> in the
+usual way.
+</P>
+<br><a name="SEC4" href="#TOC1">COMPATIBILITY WITH DIFFERENT PCRE RELEASES</a><br>
+<P>
+In general, it is safest to recompile all saved patterns when you update to a
+new PCRE release, though not all updates actually require this. Recompiling is
+definitely needed for release 7.2.
+</P>
+<br><a name="SEC5" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC6" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 13 June 2007
+<br>
+Copyright &copy; 1997-2007 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcresample.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,96 @@
+<html>
+<head>
+<title>pcresample specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcresample man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+PCRE SAMPLE PROGRAM
+</b><br>
+<P>
+A simple, complete demonstration program, to get you started with using PCRE,
+is supplied in the file <i>pcredemo.c</i> in the PCRE distribution.
+</P>
+<P>
+The program compiles the regular expression that is its first argument, and
+matches it against the subject string in its second argument. No PCRE options
+are set, and default character tables are used. If matching succeeds, the
+program outputs the portion of the subject that matched, together with the
+contents of any captured substrings.
+</P>
+<P>
+If the -g option is given on the command line, the program then goes on to
+check for further matches of the same regular expression in the same subject
+string. The logic is a little bit tricky because of the possibility of matching
+an empty string. Comments in the code explain what is going on.
+</P>
+<P>
+If PCRE is installed in the standard include and library directories for your
+system, you should be able to compile the demonstration program using this
+command:
+<pre>
+  gcc -o pcredemo pcredemo.c -lpcre
+</pre>
+If PCRE is installed elsewhere, you may need to add additional options to the
+command line. For example, on a Unix-like system that has PCRE installed in
+<i>/usr/local</i>, you can compile the demonstration program using a command
+like this:
+<pre>
+  gcc -o pcredemo -I/usr/local/include pcredemo.c -L/usr/local/lib -lpcre
+</pre>
+Once you have compiled the demonstration program, you can run simple tests like
+this:
+<pre>
+  ./pcredemo 'cat|dog' 'the cat sat on the mat'
+  ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
+</pre>
+Note that there is a much more comprehensive test program, called
+<a href="pcretest.html"><b>pcretest</b>,</a>
+which supports many more facilities for testing regular expressions and the
+PCRE library. The <b>pcredemo</b> program is provided as a simple coding
+example.
+</P>
+<P>
+On some operating systems (e.g. Solaris), when PCRE is not installed in the
+standard library directory, you may get an error like this when you try to run
+<b>pcredemo</b>:
+<pre>
+  ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
+</pre>
+This is caused by the way shared library support works on those systems. You
+need to add
+<pre>
+  -R/usr/local/lib
+</pre>
+(for example) to the compile command to get round this problem.
+</P>
+<br><b>
+AUTHOR
+</b><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><b>
+REVISION
+</b><br>
+<P>
+Last updated: 23 January 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcrestack.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,172 @@
+<html>
+<head>
+<title>pcrestack specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcrestack man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<br><b>
+PCRE DISCUSSION OF STACK USAGE
+</b><br>
+<P>
+When you call <b>pcre_exec()</b>, it makes use of an internal function called
+<b>match()</b>. This calls itself recursively at branch points in the pattern,
+in order to remember the state of the match so that it can back up and try a
+different alternative if the first one fails. As matching proceeds deeper and
+deeper into the tree of possibilities, the recursion depth increases.
+</P>
+<P>
+Not all calls of <b>match()</b> increase the recursion depth; for an item such
+as a* it may be called several times at the same level, after matching
+different numbers of a's. Furthermore, in a number of cases where the result of
+the recursive call would immediately be passed back as the result of the
+current call (a "tail recursion"), the function is just restarted instead.
+</P>
+<P>
+The <b>pcre_dfa_exec()</b> function operates in an entirely different way, and
+hardly uses recursion at all. The limit on its complexity is the amount of
+workspace it is given. The comments that follow do NOT apply to
+<b>pcre_dfa_exec()</b>; they are relevant only for <b>pcre_exec()</b>.
+</P>
+<P>
+You can set limits on the number of times that <b>match()</b> is called, both in
+total and recursively. If the limit is exceeded, an error occurs. For details,
+see the
+<a href="pcreapi.html#extradata">section on extra data for <b>pcre_exec()</b></a>
+in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<P>
+Each time that <b>match()</b> is actually called recursively, it uses memory
+from the process stack. For certain kinds of pattern and data, very large
+amounts of stack may be needed, despite the recognition of "tail recursion".
+You can often reduce the amount of recursion, and therefore the amount of stack
+used, by modifying the pattern that is being matched. Consider, for example,
+this pattern:
+<pre>
+  ([^&#60;]|&#60;(?!inet))+
+</pre>
+It matches from wherever it starts until it encounters "&#60;inet" or the end of
+the data, and is the kind of pattern that might be used when processing an XML
+file. Each iteration of the outer parentheses matches either one character that
+is not "&#60;" or a "&#60;" that is not followed by "inet". However, each time a
+parenthesis is processed, a recursion occurs, so this formulation uses a stack
+frame for each matched character. For a long string, a lot of stack is
+required. Consider now this rewritten pattern, which matches exactly the same
+strings:
+<pre>
+  ([^&#60;]++|&#60;(?!inet))+
+</pre>
+This uses very much less stack, because runs of characters that do not contain
+"&#60;" are "swallowed" in one item inside the parentheses. Recursion happens only
+when a "&#60;" character that is not followed by "inet" is encountered (and we
+assume this is relatively rare). A possessive quantifier is used to stop any
+backtracking into the runs of non-"&#60;" characters, but that is not related to
+stack usage.
+</P>
+<P>
+This example shows that one way of avoiding stack problems when matching long
+subject strings is to write repeated parenthesized subpatterns to match more
+than one character whenever possible.
+</P>
+<br><b>
+Compiling PCRE to use heap instead of stack
+</b><br>
+<P>
+In environments where stack memory is constrained, you might want to compile
+PCRE to use heap memory instead of stack for remembering back-up points. This
+makes it run a lot more slowly, however. Details of how to do this are given in
+the
+<a href="pcrebuild.html"><b>pcrebuild</b></a>
+documentation. When built in this way, instead of using the stack, PCRE obtains
+and frees memory by calling the functions that are pointed to by the
+<b>pcre_stack_malloc</b> and <b>pcre_stack_free</b> variables. By default, these
+point to <b>malloc()</b> and <b>free()</b>, but you can replace the pointers to
+cause PCRE to use your own functions. Since the block sizes are always the
+same, and are always freed in reverse order, it may be possible to implement
+customized memory handlers that are more efficient than the standard functions.
+</P>
+<br><b>
+Limiting PCRE's stack usage
+</b><br>
+<P>
+PCRE has an internal counter that can be used to limit the depth of recursion,
+and thus cause <b>pcre_exec()</b> to give an error code before it runs out of
+stack. By default, the limit is very large, and unlikely ever to operate. It
+can be changed when PCRE is built, and it can also be set when
+<b>pcre_exec()</b> is called. For details of these interfaces, see the
+<a href="pcrebuild.html"><b>pcrebuild</b></a>
+and
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<P>
+As a very rough rule of thumb, you should reckon on about 500 bytes per
+recursion. Thus, if you want to limit your stack usage to 8Mb, you
+should set the limit at 16000 recursions. A 64Mb stack, on the other hand, can
+support around 128000 recursions. The <b>pcretest</b> test program has a command
+line option (<b>-S</b>) that can be used to increase the size of its stack.
+</P>
+<br><b>
+Changing stack size in Unix-like systems
+</b><br>
+<P>
+In Unix-like environments, there is not often a problem with the stack unless
+very long strings are involved, though the default limit on stack size varies
+from system to system. Values from 8Mb to 64Mb are common. You can find your
+default limit by running the command:
+<pre>
+  ulimit -s
+</pre>
+Unfortunately, the effect of running out of stack is often SIGSEGV, though
+sometimes a more explicit error message is given. You can normally increase the
+limit on stack size by code such as this:
+<pre>
+  struct rlimit rlim;
+  getrlimit(RLIMIT_STACK, &rlim);
+  rlim.rlim_cur = 100*1024*1024;
+  setrlimit(RLIMIT_STACK, &rlim);
+</pre>
+This reads the current limits (soft and hard) using <b>getrlimit()</b>, then
+attempts to increase the soft limit to 100Mb using <b>setrlimit()</b>. You must
+do this before calling <b>pcre_exec()</b>.
+</P>
+<br><b>
+Changing stack size in Mac OS X
+</b><br>
+<P>
+Using <b>setrlimit()</b>, as described above, should also work on Mac OS X. It
+is also possible to set a stack size when linking a program. There is a
+discussion about stack sizes in Mac OS X at this web site:
+<a href="http://developer.apple.com/qa/qa2005/qa1419.html">http://developer.apple.com/qa/qa2005/qa1419.html.</a>
+</P>
+<br><b>
+AUTHOR
+</b><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><b>
+REVISION
+</b><br>
+<P>
+Last updated: 09 July 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcresyntax.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,457 @@
+<html>
+<head>
+<title>pcresyntax specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcresyntax man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">PCRE REGULAR EXPRESSION SYNTAX SUMMARY</a>
+<li><a name="TOC2" href="#SEC2">QUOTING</a>
+<li><a name="TOC3" href="#SEC3">CHARACTERS</a>
+<li><a name="TOC4" href="#SEC4">CHARACTER TYPES</a>
+<li><a name="TOC5" href="#SEC5">GENERAL CATEGORY PROPERTY CODES FOR \p and \P</a>
+<li><a name="TOC6" href="#SEC6">SCRIPT NAMES FOR \p AND \P</a>
+<li><a name="TOC7" href="#SEC7">CHARACTER CLASSES</a>
+<li><a name="TOC8" href="#SEC8">QUANTIFIERS</a>
+<li><a name="TOC9" href="#SEC9">ANCHORS AND SIMPLE ASSERTIONS</a>
+<li><a name="TOC10" href="#SEC10">MATCH POINT RESET</a>
+<li><a name="TOC11" href="#SEC11">ALTERNATION</a>
+<li><a name="TOC12" href="#SEC12">CAPTURING</a>
+<li><a name="TOC13" href="#SEC13">ATOMIC GROUPS</a>
+<li><a name="TOC14" href="#SEC14">COMMENT</a>
+<li><a name="TOC15" href="#SEC15">OPTION SETTING</a>
+<li><a name="TOC16" href="#SEC16">LOOKAHEAD AND LOOKBEHIND ASSERTIONS</a>
+<li><a name="TOC17" href="#SEC17">BACKREFERENCES</a>
+<li><a name="TOC18" href="#SEC18">SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)</a>
+<li><a name="TOC19" href="#SEC19">CONDITIONAL PATTERNS</a>
+<li><a name="TOC20" href="#SEC20">BACKTRACKING CONTROL</a>
+<li><a name="TOC21" href="#SEC21">NEWLINE CONVENTIONS</a>
+<li><a name="TOC22" href="#SEC22">WHAT \R MATCHES</a>
+<li><a name="TOC23" href="#SEC23">CALLOUTS</a>
+<li><a name="TOC24" href="#SEC24">SEE ALSO</a>
+<li><a name="TOC25" href="#SEC25">AUTHOR</a>
+<li><a name="TOC26" href="#SEC26">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">PCRE REGULAR EXPRESSION SYNTAX SUMMARY</a><br>
+<P>
+The full syntax and semantics of the regular expressions that are supported by
+PCRE are described in the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+documentation. This document contains just a quick-reference summary of the
+syntax.
+</P>
+<br><a name="SEC2" href="#TOC1">QUOTING</a><br>
+<P>
+<pre>
+  \x         where x is non-alphanumeric is a literal x
+  \Q...\E    treat enclosed characters as literal
+</PRE>
+</P>
+<br><a name="SEC3" href="#TOC1">CHARACTERS</a><br>
+<P>
+<pre>
+  \a         alarm, that is, the BEL character (hex 07)
+  \cx        "control-x", where x is any character
+  \e         escape (hex 1B)
+  \f         formfeed (hex 0C)
+  \n         newline (hex 0A)
+  \r         carriage return (hex 0D)
+  \t         tab (hex 09)
+  \ddd       character with octal code ddd, or backreference
+  \xhh       character with hex code hh
+  \x{hhh..}  character with hex code hhh..
+</PRE>
+</P>
+<br><a name="SEC4" href="#TOC1">CHARACTER TYPES</a><br>
+<P>
+<pre>
+  .          any character except newline;
+               in dotall mode, any character whatsoever
+  \C         one byte, even in UTF-8 mode (best avoided)
+  \d         a decimal digit
+  \D         a character that is not a decimal digit
+  \h         a horizontal whitespace character
+  \H         a character that is not a horizontal whitespace character
+  \p{<i>xx</i>}     a character with the <i>xx</i> property
+  \P{<i>xx</i>}     a character without the <i>xx</i> property
+  \R         a newline sequence
+  \s         a whitespace character
+  \S         a character that is not a whitespace character
+  \v         a vertical whitespace character
+  \V         a character that is not a vertical whitespace character
+  \w         a "word" character
+  \W         a "non-word" character
+  \X         an extended Unicode sequence
+</pre>
+In PCRE, \d, \D, \s, \S, \w, and \W recognize only ASCII characters.
+</P>
+<br><a name="SEC5" href="#TOC1">GENERAL CATEGORY PROPERTY CODES FOR \p and \P</a><br>
+<P>
+<pre>
+  C          Other
+  Cc         Control
+  Cf         Format
+  Cn         Unassigned
+  Co         Private use
+  Cs         Surrogate
+
+  L          Letter
+  Ll         Lower case letter
+  Lm         Modifier letter
+  Lo         Other letter
+  Lt         Title case letter
+  Lu         Upper case letter
+  L&         Ll, Lu, or Lt
+
+  M          Mark
+  Mc         Spacing mark
+  Me         Enclosing mark
+  Mn         Non-spacing mark
+
+  N          Number
+  Nd         Decimal number
+  Nl         Letter number
+  No         Other number
+
+  P          Punctuation
+  Pc         Connector punctuation
+  Pd         Dash punctuation
+  Pe         Close punctuation
+  Pf         Final punctuation
+  Pi         Initial punctuation
+  Po         Other punctuation
+  Ps         Open punctuation
+
+  S          Symbol
+  Sc         Currency symbol
+  Sk         Modifier symbol
+  Sm         Mathematical symbol
+  So         Other symbol
+
+  Z          Separator
+  Zl         Line separator
+  Zp         Paragraph separator
+  Zs         Space separator
+</PRE>
+</P>
+<br><a name="SEC6" href="#TOC1">SCRIPT NAMES FOR \p AND \P</a><br>
+<P>
+Arabic,
+Armenian,
+Balinese,
+Bengali,
+Bopomofo,
+Braille,
+Buginese,
+Buhid,
+Canadian_Aboriginal,
+Cherokee,
+Common,
+Coptic,
+Cuneiform,
+Cypriot,
+Cyrillic,
+Deseret,
+Devanagari,
+Ethiopic,
+Georgian,
+Glagolitic,
+Gothic,
+Greek,
+Gujarati,
+Gurmukhi,
+Han,
+Hangul,
+Hanunoo,
+Hebrew,
+Hiragana,
+Inherited,
+Kannada,
+Katakana,
+Kharoshthi,
+Khmer,
+Lao,
+Latin,
+Limbu,
+Linear_B,
+Malayalam,
+Mongolian,
+Myanmar,
+New_Tai_Lue,
+Nko,
+Ogham,
+Old_Italic,
+Old_Persian,
+Oriya,
+Osmanya,
+Phags_Pa,
+Phoenician,
+Runic,
+Shavian,
+Sinhala,
+Syloti_Nagri,
+Syriac,
+Tagalog,
+Tagbanwa,
+Tai_Le,
+Tamil,
+Telugu,
+Thaana,
+Thai,
+Tibetan,
+Tifinagh,
+Ugaritic,
+Yi.
+</P>
+<br><a name="SEC7" href="#TOC1">CHARACTER CLASSES</a><br>
+<P>
+<pre>
+  [...]       positive character class
+  [^...]      negative character class
+  [x-y]       range (can be used for hex characters)
+  [[:xxx:]]   positive POSIX named set
+  [[:^xxx:]]  negative POSIX named set
+
+  alnum       alphanumeric
+  alpha       alphabetic
+  ascii       0-127
+  blank       space or tab
+  cntrl       control character
+  digit       decimal digit
+  graph       printing, excluding space
+  lower       lower case letter
+  print       printing, including space
+  punct       printing, excluding alphanumeric
+  space       whitespace
+  upper       upper case letter
+  word        same as \w
+  xdigit      hexadecimal digit
+</pre>
+In PCRE, POSIX character set names recognize only ASCII characters. You can use
+\Q...\E inside a character class.
+</P>
+<br><a name="SEC8" href="#TOC1">QUANTIFIERS</a><br>
+<P>
+<pre>
+  ?           0 or 1, greedy
+  ?+          0 or 1, possessive
+  ??          0 or 1, lazy
+  *           0 or more, greedy
+  *+          0 or more, possessive
+  *?          0 or more, lazy
+  +           1 or more, greedy
+  ++          1 or more, possessive
+  +?          1 or more, lazy
+  {n}         exactly n
+  {n,m}       at least n, no more than m, greedy
+  {n,m}+      at least n, no more than m, possessive
+  {n,m}?      at least n, no more than m, lazy
+  {n,}        n or more, greedy
+  {n,}+       n or more, possessive
+  {n,}?       n or more, lazy
+</PRE>
+</P>
+<br><a name="SEC9" href="#TOC1">ANCHORS AND SIMPLE ASSERTIONS</a><br>
+<P>
+<pre>
+  \b          word boundary
+  \B          not a word boundary
+  ^           start of subject
+               also after internal newline in multiline mode
+  \A          start of subject
+  $           end of subject
+               also before newline at end of subject
+               also before internal newline in multiline mode
+  \Z          end of subject
+               also before newline at end of subject
+  \z          end of subject
+  \G          first matching position in subject
+</PRE>
+</P>
+<br><a name="SEC10" href="#TOC1">MATCH POINT RESET</a><br>
+<P>
+<pre>
+  \K          reset start of match
+</PRE>
+</P>
+<br><a name="SEC11" href="#TOC1">ALTERNATION</a><br>
+<P>
+<pre>
+  expr|expr|expr...
+</PRE>
+</P>
+<br><a name="SEC12" href="#TOC1">CAPTURING</a><br>
+<P>
+<pre>
+  (...)          capturing group
+  (?&#60;name&#62;...)   named capturing group (Perl)
+  (?'name'...)   named capturing group (Perl)
+  (?P&#60;name&#62;...)  named capturing group (Python)
+  (?:...)        non-capturing group
+  (?|...)        non-capturing group; reset group numbers for
+                  capturing groups in each alternative
+</PRE>
+</P>
+<br><a name="SEC13" href="#TOC1">ATOMIC GROUPS</a><br>
+<P>
+<pre>
+  (?&#62;...)        atomic, non-capturing group
+</PRE>
+</P>
+<br><a name="SEC14" href="#TOC1">COMMENT</a><br>
+<P>
+<pre>
+  (?#....)       comment (not nestable)
+</PRE>
+</P>
+<br><a name="SEC15" href="#TOC1">OPTION SETTING</a><br>
+<P>
+<pre>
+  (?i)           caseless
+  (?J)           allow duplicate names
+  (?m)           multiline
+  (?s)           single line (dotall)
+  (?U)           default ungreedy (lazy)
+  (?x)           extended (ignore white space)
+  (?-...)        unset option(s)
+</PRE>
+</P>
+<br><a name="SEC16" href="#TOC1">LOOKAHEAD AND LOOKBEHIND ASSERTIONS</a><br>
+<P>
+<pre>
+  (?=...)        positive look ahead
+  (?!...)        negative look ahead
+  (?&#60;=...)       positive look behind
+  (?&#60;!...)       negative look behind
+</pre>
+Each top-level branch of a look behind must be of a fixed length.
+</P>
+<br><a name="SEC17" href="#TOC1">BACKREFERENCES</a><br>
+<P>
+<pre>
+  \n             reference by number (can be ambiguous)
+  \gn            reference by number
+  \g{n}          reference by number
+  \g{-n}         relative reference by number
+  \k&#60;name&#62;       reference by name (Perl)
+  \k'name'       reference by name (Perl)
+  \g{name}       reference by name (Perl)
+  \k{name}       reference by name (.NET)
+  (?P=name)      reference by name (Python)
+</PRE>
+</P>
+<br><a name="SEC18" href="#TOC1">SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)</a><br>
+<P>
+<pre>
+  (?R)           recurse whole pattern
+  (?n)           call subpattern by absolute number
+  (?+n)          call subpattern by relative number
+  (?-n)          call subpattern by relative number
+  (?&name)       call subpattern by name (Perl)
+  (?P&#62;name)      call subpattern by name (Python)
+  \g&#60;name&#62;       call subpattern by name (Oniguruma)
+  \g'name'       call subpattern by name (Oniguruma)
+  \g&#60;n&#62;          call subpattern by absolute number (Oniguruma)
+  \g'n'          call subpattern by absolute number (Oniguruma)
+  \g&#60;+n&#62;         call subpattern by relative number (PCRE extension)
+  \g'+n'         call subpattern by relative number (PCRE extension)
+  \g&#60;-n&#62;         call subpattern by relative number (PCRE extension)
+  \g'-n'         call subpattern by relative number (PCRE extension)
+</PRE>
+</P>
+<br><a name="SEC19" href="#TOC1">CONDITIONAL PATTERNS</a><br>
+<P>
+<pre>
+  (?(condition)yes-pattern)
+  (?(condition)yes-pattern|no-pattern)
+
+  (?(n)...       absolute reference condition
+  (?(+n)...      relative reference condition
+  (?(-n)...      relative reference condition
+  (?(&#60;name&#62;)...  named reference condition (Perl)
+  (?('name')...  named reference condition (Perl)
+  (?(name)...    named reference condition (PCRE)
+  (?(R)...       overall recursion condition
+  (?(Rn)...      specific group recursion condition
+  (?(R&name)...  specific recursion condition
+  (?(DEFINE)...  define subpattern for reference
+  (?(assert)...  assertion condition
+</PRE>
+</P>
+<br><a name="SEC20" href="#TOC1">BACKTRACKING CONTROL</a><br>
+<P>
+The following act immediately they are reached:
+<pre>
+  (*ACCEPT)      force successful match
+  (*FAIL)        force backtrack; synonym (*F)
+</pre>
+The following act only when a subsequent match failure causes a backtrack to
+reach them. They all force a match failure, but they differ in what happens
+afterwards. Those that advance the start-of-match point do so only if the
+pattern is not anchored.
+<pre>
+  (*COMMIT)      overall failure, no advance of starting point
+  (*PRUNE)       advance to next starting character
+  (*SKIP)        advance start to current matching position
+  (*THEN)        local failure, backtrack to next alternation
+</PRE>
+</P>
+<br><a name="SEC21" href="#TOC1">NEWLINE CONVENTIONS</a><br>
+<P>
+These are recognized only at the very start of the pattern or after a
+(*BSR_...) option.
+<pre>
+  (*CR)
+  (*LF)
+  (*CRLF)
+  (*ANYCRLF)
+  (*ANY)
+</PRE>
+</P>
+<br><a name="SEC22" href="#TOC1">WHAT \R MATCHES</a><br>
+<P>
+These are recognized only at the very start of the pattern or after a
+(*...) option that sets the newline convention.
+<pre>
+  (*BSR_ANYCRLF)
+  (*BSR_UNICODE)
+</PRE>
+</P>
+<br><a name="SEC23" href="#TOC1">CALLOUTS</a><br>
+<P>
+<pre>
+  (?C)      callout
+  (?Cn)     callout with data n
+</PRE>
+</P>
+<br><a name="SEC24" href="#TOC1">SEE ALSO</a><br>
+<P>
+<b>pcrepattern</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3),
+<b>pcrematching</b>(3), <b>pcre</b>(3).
+</P>
+<br><a name="SEC25" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC26" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 09 April 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/html/pcretest.html	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,706 @@
+<html>
+<head>
+<title>pcretest specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>pcretest man page</h1>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
+<p>
+This page is part of the PCRE HTML documentation. It was generated automatically
+from the original man page. If there is any nonsense in it, please consult the
+man page, in case the conversion went wrong.
+<br>
+<ul>
+<li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
+<li><a name="TOC2" href="#SEC2">OPTIONS</a>
+<li><a name="TOC3" href="#SEC3">DESCRIPTION</a>
+<li><a name="TOC4" href="#SEC4">PATTERN MODIFIERS</a>
+<li><a name="TOC5" href="#SEC5">DATA LINES</a>
+<li><a name="TOC6" href="#SEC6">THE ALTERNATIVE MATCHING FUNCTION</a>
+<li><a name="TOC7" href="#SEC7">DEFAULT OUTPUT FROM PCRETEST</a>
+<li><a name="TOC8" href="#SEC8">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a>
+<li><a name="TOC9" href="#SEC9">RESTARTING AFTER A PARTIAL MATCH</a>
+<li><a name="TOC10" href="#SEC10">CALLOUTS</a>
+<li><a name="TOC11" href="#SEC11">NON-PRINTING CHARACTERS</a>
+<li><a name="TOC12" href="#SEC12">SAVING AND RELOADING COMPILED PATTERNS</a>
+<li><a name="TOC13" href="#SEC13">SEE ALSO</a>
+<li><a name="TOC14" href="#SEC14">AUTHOR</a>
+<li><a name="TOC15" href="#SEC15">REVISION</a>
+</ul>
+<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
+<P>
+<b>pcretest [options] [source] [destination]</b>
+<br>
+<br>
+<b>pcretest</b> was written as a test program for the PCRE regular expression
+library itself, but it can also be used for experimenting with regular
+expressions. This document describes the features of the test program; for
+details of the regular expressions themselves, see the
+<a href="pcrepattern.html"><b>pcrepattern</b></a>
+documentation. For details of the PCRE library function calls and their
+options, see the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<br><a name="SEC2" href="#TOC1">OPTIONS</a><br>
+<P>
+<b>-b</b>
+Behave as if each regex has the <b>/B</b> (show bytecode) modifier; the internal
+form is output after compilation.
+</P>
+<P>
+<b>-C</b>
+Output the version number of the PCRE library, and all available information
+about the optional features that are included, and then exit.
+</P>
+<P>
+<b>-d</b>
+Behave as if each regex has the <b>/D</b> (debug) modifier; the internal
+form and information about the compiled pattern is output after compilation;
+<b>-d</b> is equivalent to <b>-b -i</b>.
+</P>
+<P>
+<b>-dfa</b>
+Behave as if each data line contains the \D escape sequence; this causes the
+alternative matching function, <b>pcre_dfa_exec()</b>, to be used instead of the
+standard <b>pcre_exec()</b> function (more detail is given below).
+</P>
+<P>
+<b>-help</b>
+Output a brief summary these options and then exit.
+</P>
+<P>
+<b>-i</b>
+Behave as if each regex has the <b>/I</b> modifier; information about the
+compiled pattern is given after compilation.
+</P>
+<P>
+<b>-m</b>
+Output the size of each compiled pattern after it has been compiled. This is
+equivalent to adding <b>/M</b> to each regular expression. For compatibility
+with earlier versions of pcretest, <b>-s</b> is a synonym for <b>-m</b>.
+</P>
+<P>
+<b>-o</b> <i>osize</i>
+Set the number of elements in the output vector that is used when calling
+<b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> to be <i>osize</i>. The default value
+is 45, which is enough for 14 capturing subexpressions for <b>pcre_exec()</b> or
+22 different matches for <b>pcre_dfa_exec()</b>. The vector size can be
+changed for individual matching calls by including \O in the data line (see
+below).
+</P>
+<P>
+<b>-p</b>
+Behave as if each regex has the <b>/P</b> modifier; the POSIX wrapper API is
+used to call PCRE. None of the other options has any effect when <b>-p</b> is
+set.
+</P>
+<P>
+<b>-q</b>
+Do not output the version number of <b>pcretest</b> at the start of execution.
+</P>
+<P>
+<b>-S</b> <i>size</i>
+On Unix-like systems, set the size of the runtime stack to <i>size</i>
+megabytes.
+</P>
+<P>
+<b>-t</b>
+Run each compile, study, and match many times with a timer, and output
+resulting time per compile or match (in milliseconds). Do not set <b>-m</b> with
+<b>-t</b>, because you will then get the size output a zillion times, and the
+timing will be distorted. You can control the number of iterations that are
+used for timing by following <b>-t</b> with a number (as a separate item on the
+command line). For example, "-t 1000" would iterate 1000 times. The default is
+to iterate 500000 times.
+</P>
+<P>
+<b>-tm</b>
+This is like <b>-t</b> except that it times only the matching phase, not the
+compile or study phases.
+</P>
+<br><a name="SEC3" href="#TOC1">DESCRIPTION</a><br>
+<P>
+If <b>pcretest</b> is given two filename arguments, it reads from the first and
+writes to the second. If it is given only one filename argument, it reads from
+that file and writes to stdout. Otherwise, it reads from stdin and writes to
+stdout, and prompts for each line of input, using "re&#62;" to prompt for regular
+expressions, and "data&#62;" to prompt for data lines.
+</P>
+<P>
+When <b>pcretest</b> is built, a configuration option can specify that it should
+be linked with the <b>libreadline</b> library. When this is done, if the input
+is from a terminal, it is read using the <b>readline()</b> function. This
+provides line-editing and history facilities. The output from the <b>-help</b>
+option states whether or not <b>readline()</b> will be used.
+</P>
+<P>
+The program handles any number of sets of input on a single input file. Each
+set starts with a regular expression, and continues with any number of data
+lines to be matched against the pattern.
+</P>
+<P>
+Each data line is matched separately and independently. If you want to do
+multi-line matches, you have to use the \n escape sequence (or \r or \r\n,
+etc., depending on the newline setting) in a single line of input to encode the
+newline sequences. There is no limit on the length of data lines; the input
+buffer is automatically extended if it is too small.
+</P>
+<P>
+An empty line signals the end of the data lines, at which point a new regular
+expression is read. The regular expressions are given enclosed in any
+non-alphanumeric delimiters other than backslash, for example:
+<pre>
+  /(a|bc)x+yz/
+</pre>
+White space before the initial delimiter is ignored. A regular expression may
+be continued over several input lines, in which case the newline characters are
+included within it. It is possible to include the delimiter within the pattern
+by escaping it, for example
+<pre>
+  /abc\/def/
+</pre>
+If you do so, the escape and the delimiter form part of the pattern, but since
+delimiters are always non-alphanumeric, this does not affect its interpretation.
+If the terminating delimiter is immediately followed by a backslash, for
+example,
+<pre>
+  /abc/\
+</pre>
+then a backslash is added to the end of the pattern. This is done to provide a
+way of testing the error condition that arises if a pattern finishes with a
+backslash, because
+<pre>
+  /abc\/
+</pre>
+is interpreted as the first line of a pattern that starts with "abc/", causing
+pcretest to read the next line as a continuation of the regular expression.
+</P>
+<br><a name="SEC4" href="#TOC1">PATTERN MODIFIERS</a><br>
+<P>
+A pattern may be followed by any number of modifiers, which are mostly single
+characters. Following Perl usage, these are referred to below as, for example,
+"the <b>/i</b> modifier", even though the delimiter of the pattern need not
+always be a slash, and no slash is used when writing modifiers. Whitespace may
+appear between the final pattern delimiter and the first modifier, and between
+the modifiers themselves.
+</P>
+<P>
+The <b>/i</b>, <b>/m</b>, <b>/s</b>, and <b>/x</b> modifiers set the PCRE_CASELESS,
+PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively, when
+<b>pcre_compile()</b> is called. These four modifier letters have the same
+effect as they do in Perl. For example:
+<pre>
+  /caseless/i
+</pre>
+The following table shows additional modifiers for setting PCRE options that do
+not correspond to anything in Perl:
+<pre>
+  <b>/A</b>              PCRE_ANCHORED
+  <b>/C</b>              PCRE_AUTO_CALLOUT
+  <b>/E</b>              PCRE_DOLLAR_ENDONLY
+  <b>/f</b>              PCRE_FIRSTLINE
+  <b>/J</b>              PCRE_DUPNAMES
+  <b>/N</b>              PCRE_NO_AUTO_CAPTURE
+  <b>/U</b>              PCRE_UNGREEDY
+  <b>/X</b>              PCRE_EXTRA
+  <b>/&#60;JS&#62;</b>           PCRE_JAVASCRIPT_COMPAT
+  <b>/&#60;cr&#62;</b>           PCRE_NEWLINE_CR
+  <b>/&#60;lf&#62;</b>           PCRE_NEWLINE_LF
+  <b>/&#60;crlf&#62;</b>         PCRE_NEWLINE_CRLF
+  <b>/&#60;anycrlf&#62;</b>      PCRE_NEWLINE_ANYCRLF
+  <b>/&#60;any&#62;</b>          PCRE_NEWLINE_ANY
+  <b>/&#60;bsr_anycrlf&#62;</b>  PCRE_BSR_ANYCRLF
+  <b>/&#60;bsr_unicode&#62;</b>  PCRE_BSR_UNICODE
+</pre>
+Those specifying line ending sequences are literal strings as shown, but the
+letters can be in either case. This example sets multiline matching with CRLF
+as the line ending sequence:
+<pre>
+  /^abc/m&#60;crlf&#62;
+</pre>
+Details of the meanings of these PCRE options are given in the
+<a href="pcreapi.html"><b>pcreapi</b></a>
+documentation.
+</P>
+<br><b>
+Finding all matches in a string
+</b><br>
+<P>
+Searching for all possible matches within each subject string can be requested
+by the <b>/g</b> or <b>/G</b> modifier. After finding a match, PCRE is called
+again to search the remainder of the subject string. The difference between
+<b>/g</b> and <b>/G</b> is that the former uses the <i>startoffset</i> argument to
+<b>pcre_exec()</b> to start searching at a new point within the entire string
+(which is in effect what Perl does), whereas the latter passes over a shortened
+substring. This makes a difference to the matching process if the pattern
+begins with a lookbehind assertion (including \b or \B).
+</P>
+<P>
+If any call to <b>pcre_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches an
+empty string, the next call is done with the PCRE_NOTEMPTY and PCRE_ANCHORED
+flags set in order to search for another, non-empty, match at the same point.
+If this second match fails, the start offset is advanced by one, and the normal
+match is retried. This imitates the way Perl handles such cases when using the
+<b>/g</b> modifier or the <b>split()</b> function.
+</P>
+<br><b>
+Other modifiers
+</b><br>
+<P>
+There are yet more modifiers for controlling the way <b>pcretest</b>
+operates.
+</P>
+<P>
+The <b>/+</b> modifier requests that as well as outputting the substring that
+matched the entire pattern, pcretest should in addition output the remainder of
+the subject string. This is useful for tests where the subject contains
+multiple copies of the same substring.
+</P>
+<P>
+The <b>/B</b> modifier is a debugging feature. It requests that <b>pcretest</b>
+output a representation of the compiled byte code after compilation. Normally
+this information contains length and offset values; however, if <b>/Z</b> is
+also present, this data is replaced by spaces. This is a special feature for
+use in the automatic test scripts; it ensures that the same output is generated
+for different internal link sizes.
+</P>
+<P>
+The <b>/L</b> modifier must be followed directly by the name of a locale, for
+example,
+<pre>
+  /pattern/Lfr_FR
+</pre>
+For this reason, it must be the last modifier. The given locale is set,
+<b>pcre_maketables()</b> is called to build a set of character tables for the
+locale, and this is then passed to <b>pcre_compile()</b> when compiling the
+regular expression. Without an <b>/L</b> modifier, NULL is passed as the tables
+pointer; that is, <b>/L</b> applies only to the expression on which it appears.
+</P>
+<P>
+The <b>/I</b> modifier requests that <b>pcretest</b> output information about the
+compiled pattern (whether it is anchored, has a fixed first character, and
+so on). It does this by calling <b>pcre_fullinfo()</b> after compiling a
+pattern. If the pattern is studied, the results of that are also output.
+</P>
+<P>
+The <b>/D</b> modifier is a PCRE debugging feature, and is equivalent to
+<b>/BI</b>, that is, both the <b>/B</b> and the <b>/I</b> modifiers.
+</P>
+<P>
+The <b>/F</b> modifier causes <b>pcretest</b> to flip the byte order of the
+fields in the compiled pattern that contain 2-byte and 4-byte numbers. This
+facility is for testing the feature in PCRE that allows it to execute patterns
+that were compiled on a host with a different endianness. This feature is not
+available when the POSIX interface to PCRE is being used, that is, when the
+<b>/P</b> pattern modifier is specified. See also the section about saving and
+reloading compiled patterns below.
+</P>
+<P>
+The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the
+expression has been compiled, and the results used when the expression is
+matched.
+</P>
+<P>
+The <b>/M</b> modifier causes the size of memory block used to hold the compiled
+pattern to be output.
+</P>
+<P>
+The <b>/P</b> modifier causes <b>pcretest</b> to call PCRE via the POSIX wrapper
+API rather than its native API. When this is done, all other modifiers except
+<b>/i</b>, <b>/m</b>, and <b>/+</b> are ignored. REG_ICASE is set if <b>/i</b> is
+present, and REG_NEWLINE is set if <b>/m</b> is present. The wrapper functions
+force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.
+</P>
+<P>
+The <b>/8</b> modifier causes <b>pcretest</b> to call PCRE with the PCRE_UTF8
+option set. This turns on support for UTF-8 character handling in PCRE,
+provided that it was compiled with this support enabled. This modifier also
+causes any non-printing characters in output strings to be printed using the
+\x{hh...} notation if they are valid UTF-8 sequences.
+</P>
+<P>
+If the <b>/?</b> modifier is used with <b>/8</b>, it causes <b>pcretest</b> to
+call <b>pcre_compile()</b> with the PCRE_NO_UTF8_CHECK option, to suppress the
+checking of the string for UTF-8 validity.
+</P>
+<br><a name="SEC5" href="#TOC1">DATA LINES</a><br>
+<P>
+Before each data line is passed to <b>pcre_exec()</b>, leading and trailing
+whitespace is removed, and it is then scanned for \ escapes. Some of these are
+pretty esoteric features, intended for checking out some of the more
+complicated features of PCRE. If you are just testing "ordinary" regular
+expressions, you probably don't need any of these. The following escapes are
+recognized:
+<pre>
+  \a         alarm (BEL, \x07)
+  \b         backspace (\x08)
+  \e         escape (\x27)
+  \f         formfeed (\x0c)
+  \n         newline (\x0a)
+  \qdd       set the PCRE_MATCH_LIMIT limit to dd (any number of digits)
+  \r         carriage return (\x0d)
+  \t         tab (\x09)
+  \v         vertical tab (\x0b)
+  \nnn       octal character (up to 3 octal digits)
+  \xhh       hexadecimal character (up to 2 hex digits)
+  \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode
+  \A         pass the PCRE_ANCHORED option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \B         pass the PCRE_NOTBOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \Cdd       call pcre_copy_substring() for substring dd after a successful match (number less than 32)
+  \Cname     call pcre_copy_named_substring() for substring "name" after a successful match (name termin-
+               ated by next non alphanumeric character)
+  \C+        show the current captured substrings at callout time
+  \C-        do not supply a callout function
+  \C!n       return 1 instead of 0 when callout number n is reached
+  \C!n!m     return 1 instead of 0 when callout number n is reached for the nth time
+  \C*n       pass the number n (may be negative) as callout data; this is used as the callout return value
+  \D         use the <b>pcre_dfa_exec()</b> match function
+  \F         only shortest match for <b>pcre_dfa_exec()</b>
+  \Gdd       call pcre_get_substring() for substring dd after a successful match (number less than 32)
+  \Gname     call pcre_get_named_substring() for substring "name" after a successful match (name termin-
+               ated by next non-alphanumeric character)
+  \L         call pcre_get_substringlist() after a successful match
+  \M         discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings
+  \N         pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \Odd       set the size of the output vector passed to <b>pcre_exec()</b> to dd (any number of digits)
+  \P         pass the PCRE_PARTIAL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \Qdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd (any number of digits)
+  \R         pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b>
+  \S         output details of memory get/free calls during matching
+  \Z         pass the PCRE_NOTEOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \?         pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \&#62;dd       start the match at offset dd (any number of digits);
+               this sets the <i>startoffset</i> argument for <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \&#60;cr&#62;      pass the PCRE_NEWLINE_CR option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \&#60;lf&#62;      pass the PCRE_NEWLINE_LF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \&#60;crlf&#62;    pass the PCRE_NEWLINE_CRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+  \&#60;any&#62;     pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
+</pre>
+The escapes that specify line ending sequences are literal strings, exactly as
+shown. No more than one newline setting should be present in any data line.
+</P>
+<P>
+A backslash followed by anything else just escapes the anything else. If
+the very last character is a backslash, it is ignored. This gives a way of
+passing an empty line as data, since a real empty line terminates the data
+input.
+</P>
+<P>
+If \M is present, <b>pcretest</b> calls <b>pcre_exec()</b> several times, with
+different values in the <i>match_limit</i> and <i>match_limit_recursion</i>
+fields of the <b>pcre_extra</b> data structure, until it finds the minimum
+numbers for each parameter that allow <b>pcre_exec()</b> to complete. The
+<i>match_limit</i> number is a measure of the amount of backtracking that takes
+place, and checking it out can be instructive. For most simple matches, the
+number is quite small, but for patterns with very large numbers of matching
+possibilities, it can become large very quickly with increasing length of
+subject string. The <i>match_limit_recursion</i> number is a measure of how much
+stack (or, if PCRE is compiled with NO_RECURSE, how much heap) memory is needed
+to complete the match attempt.
+</P>
+<P>
+When \O is used, the value specified may be higher or lower than the size set
+by the <b>-O</b> command line option (or defaulted to 45); \O applies only to
+the call of <b>pcre_exec()</b> for the line in which it appears.
+</P>
+<P>
+If the <b>/P</b> modifier was present on the pattern, causing the POSIX wrapper
+API to be used, the only option-setting sequences that have any effect are \B
+and \Z, causing REG_NOTBOL and REG_NOTEOL, respectively, to be passed to
+<b>regexec()</b>.
+</P>
+<P>
+The use of \x{hh...} to represent UTF-8 characters is not dependent on the use
+of the <b>/8</b> modifier on the pattern. It is recognized always. There may be
+any number of hexadecimal digits inside the braces. The result is from one to
+six bytes, encoded according to the original UTF-8 rules of RFC 2279. This
+allows for values in the range 0 to 0x7FFFFFFF. Note that not all of those are
+valid Unicode code points, or indeed valid UTF-8 characters according to the
+later rules in RFC 3629.
+</P>
+<br><a name="SEC6" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
+<P>
+By default, <b>pcretest</b> uses the standard PCRE matching function,
+<b>pcre_exec()</b> to match each data line. From release 6.0, PCRE supports an
+alternative matching function, <b>pcre_dfa_test()</b>, which operates in a
+different way, and has some restrictions. The differences between the two
+functions are described in the
+<a href="pcrematching.html"><b>pcrematching</b></a>
+documentation.
+</P>
+<P>
+If a data line contains the \D escape sequence, or if the command line
+contains the <b>-dfa</b> option, the alternative matching function is called.
+This function finds all possible matches at a given point. If, however, the \F
+escape sequence is present in the data line, it stops after the first match is
+found. This is always the shortest possible match.
+</P>
+<br><a name="SEC7" href="#TOC1">DEFAULT OUTPUT FROM PCRETEST</a><br>
+<P>
+This section describes the output when the normal matching function,
+<b>pcre_exec()</b>, is being used.
+</P>
+<P>
+When a match succeeds, pcretest outputs the list of captured substrings that
+<b>pcre_exec()</b> returns, starting with number 0 for the string that matched
+the whole pattern. Otherwise, it outputs "No match" or "Partial match"
+when <b>pcre_exec()</b> returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL,
+respectively, and otherwise the PCRE negative error number. Here is an example
+of an interactive <b>pcretest</b> run.
+<pre>
+  $ pcretest
+  PCRE version 7.0 30-Nov-2006
+
+    re&#62; /^abc(\d+)/
+  data&#62; abc123
+   0: abc123
+   1: 123
+  data&#62; xyz
+  No match
+</pre>
+Note that unset capturing substrings that are not followed by one that is set
+are not returned by <b>pcre_exec()</b>, and are not shown by <b>pcretest</b>. In
+the following example, there are two capturing substrings, but when the first
+data line is matched, the second, unset substring is not shown. An "internal"
+unset substring is shown as "&#60;unset&#62;", as for the second data line.
+<pre>
+    re&#62; /(a)|(b)/
+  data&#62; a
+   0: a
+   1: a
+  data&#62; b
+   0: b
+   1: &#60;unset&#62;
+   2: b
+</pre>
+If the strings contain any non-printing characters, they are output as \0x
+escapes, or as \x{...} escapes if the <b>/8</b> modifier was present on the
+pattern. See below for the definition of non-printing characters. If the
+pattern has the <b>/+</b> modifier, the output for substring 0 is followed by
+the the rest of the subject string, identified by "0+" like this:
+<pre>
+    re&#62; /cat/+
+  data&#62; cataract
+   0: cat
+   0+ aract
+</pre>
+If the pattern has the <b>/g</b> or <b>/G</b> modifier, the results of successive
+matching attempts are output in sequence, like this:
+<pre>
+    re&#62; /\Bi(\w\w)/g
+  data&#62; Mississippi
+   0: iss
+   1: ss
+   0: iss
+   1: ss
+   0: ipp
+   1: pp
+</pre>
+"No match" is output only if the first match attempt fails.
+</P>
+<P>
+If any of the sequences <b>\C</b>, <b>\G</b>, or <b>\L</b> are present in a
+data line that is successfully matched, the substrings extracted by the
+convenience functions are output with C, G, or L after the string number
+instead of a colon. This is in addition to the normal full list. The string
+length (that is, the return from the extraction function) is given in
+parentheses after each string for <b>\C</b> and <b>\G</b>.
+</P>
+<P>
+Note that whereas patterns can be continued over several lines (a plain "&#62;"
+prompt is used for continuations), data lines may not. However newlines can be
+included in data by means of the \n escape (or \r, \r\n, etc., depending on
+the newline sequence setting).
+</P>
+<br><a name="SEC8" href="#TOC1">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a><br>
+<P>
+When the alternative matching function, <b>pcre_dfa_exec()</b>, is used (by
+means of the \D escape sequence or the <b>-dfa</b> command line option), the
+output consists of a list of all the matches that start at the first point in
+the subject where there is at least one match. For example:
+<pre>
+    re&#62; /(tang|tangerine|tan)/
+  data&#62; yellow tangerine\D
+   0: tangerine
+   1: tang
+   2: tan
+</pre>
+(Using the normal matching function on this data finds only "tang".) The
+longest matching string is always given first (and numbered zero).
+</P>
+<P>
+If <b>/g</b> is present on the pattern, the search for further matches resumes
+at the end of the longest match. For example:
+<pre>
+    re&#62; /(tang|tangerine|tan)/g
+  data&#62; yellow tangerine and tangy sultana\D
+   0: tangerine
+   1: tang
+   2: tan
+   0: tang
+   1: tan
+   0: tan
+</pre>
+Since the matching function does not support substring capture, the escape
+sequences that are concerned with captured substrings are not relevant.
+</P>
+<br><a name="SEC9" href="#TOC1">RESTARTING AFTER A PARTIAL MATCH</a><br>
+<P>
+When the alternative matching function has given the PCRE_ERROR_PARTIAL return,
+indicating that the subject partially matched the pattern, you can restart the
+match with additional subject data by means of the \R escape sequence. For
+example:
+<pre>
+    re&#62; /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
+  data&#62; 23ja\P\D
+  Partial match: 23ja
+  data&#62; n05\R\D
+   0: n05
+</pre>
+For further information about partial matching, see the
+<a href="pcrepartial.html"><b>pcrepartial</b></a>
+documentation.
+</P>
+<br><a name="SEC10" href="#TOC1">CALLOUTS</a><br>
+<P>
+If the pattern contains any callout requests, <b>pcretest</b>'s callout function
+is called during matching. This works with both matching functions. By default,
+the called function displays the callout number, the start and current
+positions in the text at the callout time, and the next pattern item to be
+tested. For example, the output
+<pre>
+  ---&#62;pqrabcdef
+    0    ^  ^     \d
+</pre>
+indicates that callout number 0 occurred for a match attempt starting at the
+fourth character of the subject string, when the pointer was at the seventh
+character of the data, and when the next pattern item was \d. Just one
+circumflex is output if the start and current positions are the same.
+</P>
+<P>
+Callouts numbered 255 are assumed to be automatic callouts, inserted as a
+result of the <b>/C</b> pattern modifier. In this case, instead of showing the
+callout number, the offset in the pattern, preceded by a plus, is output. For
+example:
+<pre>
+    re&#62; /\d?[A-E]\*/C
+  data&#62; E*
+  ---&#62;E*
+   +0 ^      \d?
+   +3 ^      [A-E]
+   +8 ^^     \*
+  +10 ^ ^
+   0: E*
+</pre>
+The callout function in <b>pcretest</b> returns zero (carry on matching) by
+default, but you can use a \C item in a data line (as described above) to
+change this.
+</P>
+<P>
+Inserting callouts can be helpful when using <b>pcretest</b> to check
+complicated regular expressions. For further information about callouts, see
+the
+<a href="pcrecallout.html"><b>pcrecallout</b></a>
+documentation.
+</P>
+<br><a name="SEC11" href="#TOC1">NON-PRINTING CHARACTERS</a><br>
+<P>
+When <b>pcretest</b> is outputting text in the compiled version of a pattern,
+bytes other than 32-126 are always treated as non-printing characters are are
+therefore shown as hex escapes.
+</P>
+<P>
+When <b>pcretest</b> is outputting text that is a matched part of a subject
+string, it behaves in the same way, unless a different locale has been set for
+the pattern (using the <b>/L</b> modifier). In this case, the <b>isprint()</b>
+function to distinguish printing and non-printing characters.
+</P>
+<br><a name="SEC12" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>
+<P>
+The facilities described in this section are not available when the POSIX
+inteface to PCRE is being used, that is, when the <b>/P</b> pattern modifier is
+specified.
+</P>
+<P>
+When the POSIX interface is not in use, you can cause <b>pcretest</b> to write a
+compiled pattern to a file, by following the modifiers with &#62; and a file name.
+For example:
+<pre>
+  /pattern/im &#62;/some/file
+</pre>
+See the
+<a href="pcreprecompile.html"><b>pcreprecompile</b></a>
+documentation for a discussion about saving and re-using compiled patterns.
+</P>
+<P>
+The data that is written is binary. The first eight bytes are the length of the
+compiled pattern data followed by the length of the optional study data, each
+written as four bytes in big-endian order (most significant byte first). If
+there is no study data (either the pattern was not studied, or studying did not
+return any data), the second length is zero. The lengths are followed by an
+exact copy of the compiled pattern. If there is additional study data, this
+follows immediately after the compiled pattern. After writing the file,
+<b>pcretest</b> expects to read a new pattern.
+</P>
+<P>
+A saved pattern can be reloaded into <b>pcretest</b> by specifing &#60; and a file
+name instead of a pattern. The name of the file must not contain a &#60; character,
+as otherwise <b>pcretest</b> will interpret the line as a pattern delimited by &#60;
+characters.
+For example:
+<pre>
+   re&#62; &#60;/some/file
+  Compiled regex loaded from /some/file
+  No study data
+</pre>
+When the pattern has been loaded, <b>pcretest</b> proceeds to read data lines in
+the usual way.
+</P>
+<P>
+You can copy a file written by <b>pcretest</b> to a different host and reload it
+there, even if the new host has opposite endianness to the one on which the
+pattern was compiled. For example, you can compile on an i86 machine and run on
+a SPARC machine.
+</P>
+<P>
+File names for saving and reloading can be absolute or relative, but note that
+the shell facility of expanding a file name that starts with a tilde (~) is not
+available.
+</P>
+<P>
+The ability to save and reload files in <b>pcretest</b> is intended for testing
+and experimentation. It is not intended for production use because only a
+single pattern can be written to a file. Furthermore, there is no facility for
+supplying custom character tables for use with a reloaded pattern. If the
+original pattern was compiled with custom tables, an attempt to match a subject
+string using a reloaded pattern is likely to cause <b>pcretest</b> to crash.
+Finally, if you attempt to load a file that is not in the correct format, the
+result is undefined.
+</P>
+<br><a name="SEC13" href="#TOC1">SEE ALSO</a><br>
+<P>
+<b>pcre</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrematching</b>(3),
+<b>pcrepartial</b>(d), <b>pcrepattern</b>(3), <b>pcreprecompile</b>(3).
+</P>
+<br><a name="SEC14" href="#TOC1">AUTHOR</a><br>
+<P>
+Philip Hazel
+<br>
+University Computing Service
+<br>
+Cambridge CB2 3QH, England.
+<br>
+</P>
+<br><a name="SEC15" href="#TOC1">REVISION</a><br>
+<P>
+Last updated: 12 April 2008
+<br>
+Copyright &copy; 1997-2008 University of Cambridge.
+<br>
+<p>
+Return to the <a href="index.html">PCRE index page</a>.
+</p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/index.html.src	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,140 @@
+<html>
+<!-- This is a manually maintained file that is the root of the HTML version of 
+     the PCRE documentation. When the HTML documents are built from the man 
+     page versions, the entire doc/html directory is emptied, this file is then 
+     copied into doc/html/index.html, and the remaining files therein are 
+     created by the 132html script.
+-->      
+<head>
+<title>PCRE specification</title>
+</head>
+<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
+<h1>Perl-compatible Regular Expressions (PCRE)</h1>
+<p>
+The HTML documentation for PCRE comprises the following pages:
+</p>
+
+<table>
+<tr><td><a href="pcre.html">pcre</a></td>
+    <td>&nbsp;&nbsp;Introductory page</td></tr>
+
+<tr><td><a href="pcre-config.html">pcre-config</a></td>
+    <td>&nbsp;&nbsp;Information about the installation configuration</td></tr>
+
+<tr><td><a href="pcreapi.html">pcreapi</a></td>
+    <td>&nbsp;&nbsp;PCRE's native API</td></tr>
+
+<tr><td><a href="pcrebuild.html">pcrebuild</a></td>
+    <td>&nbsp;&nbsp;Options for building PCRE</td></tr>
+
+<tr><td><a href="pcrecallout.html">pcrecallout</a></td>
+    <td>&nbsp;&nbsp;The <i>callout</i> facility</td></tr>
+
+<tr><td><a href="pcrecompat.html">pcrecompat</a></td>
+    <td>&nbsp;&nbsp;Compability with Perl</td></tr>
+
+<tr><td><a href="pcrecpp.html">pcrecpp</a></td>
+    <td>&nbsp;&nbsp;The C++ wrapper for the PCRE library</td></tr>
+
+<tr><td><a href="pcregrep.html">pcregrep</a></td>
+    <td>&nbsp;&nbsp;The <b>pcregrep</b> command</td></tr>
+
+<tr><td><a href="pcrematching.html">pcrematching</a></td>
+    <td>&nbsp;&nbsp;Discussion of the two matching algorithms</td></tr>
+
+<tr><td><a href="pcrepartial.html">pcrepartial</a></td>
+    <td>&nbsp;&nbsp;Using PCRE for partial matching</td></tr>
+
+<tr><td><a href="pcrepattern.html">pcrepattern</a></td>
+    <td>&nbsp;&nbsp;Specification of the regular expressions supported by PCRE</td></tr>
+
+<tr><td><a href="pcreperform.html">pcreperform</a></td>
+    <td>&nbsp;&nbsp;Some comments on performance</td></tr>
+
+<tr><td><a href="pcreposix.html">pcreposix</a></td>
+    <td>&nbsp;&nbsp;The POSIX API to the PCRE library</td></tr>
+
+<tr><td><a href="pcreprecompile.html">pcreprecompile</a></td>
+    <td>&nbsp;&nbsp;How to save and re-use compiled patterns</td></tr>
+
+<tr><td><a href="pcresample.html">pcresample</a></td>
+    <td>&nbsp;&nbsp;Description of the sample program</td></tr>
+
+<tr><td><a href="pcrestack.html">pcrestack</a></td>
+    <td>&nbsp;&nbsp;Discussion of PCRE's stack usage</td></tr>
+
+<tr><td><a href="pcresyntax.html">pcresyntax</a></td>
+    <td>&nbsp;&nbsp;Syntax quick-reference summary</td></tr>
+
+<tr><td><a href="pcretest.html">pcretest</a></td>
+    <td>&nbsp;&nbsp;The <b>pcretest</b> command for testing PCRE</td></tr>
+</table>
+
+<p>
+There are also individual pages that summarize the interface for each function 
+in the library:
+</p>
+
+<table>    
+
+<tr><td><a href="pcre_compile.html">pcre_compile</a></td>
+    <td>&nbsp;&nbsp;Compile a regular expression</td></tr>
+
+<tr><td><a href="pcre_compile2.html">pcre_compile2</a></td>
+    <td>&nbsp;&nbsp;Compile a regular expression (alternate interface)</td></tr>
+
+<tr><td><a href="pcre_config.html">pcre_config</a></td>
+    <td>&nbsp;&nbsp;Show build-time configuration options</td></tr>
+
+<tr><td><a href="pcre_copy_named_substring.html">pcre_copy_named_substring</a></td>
+    <td>&nbsp;&nbsp;Extract named substring into given buffer</td></tr>
+
+<tr><td><a href="pcre_copy_substring.html">pcre_copy_substring</a></td>
+    <td>&nbsp;&nbsp;Extract numbered substring into given buffer</td></tr>
+
+<tr><td><a href="pcre_dfa_exec.html">pcre_dfa_exec</a></td>
+    <td>&nbsp;&nbsp;Match a compiled pattern to a subject string
+    (DFA algorithm; <i>not</i> Perl compatible)</td></tr>
+
+<tr><td><a href="pcre_exec.html">pcre_exec</a></td>
+    <td>&nbsp;&nbsp;Match a compiled pattern to a subject string
+    (Perl compatible)</td></tr>
+
+<tr><td><a href="pcre_free_substring.html">pcre_free_substring</a></td>
+    <td>&nbsp;&nbsp;Free extracted substring</td></tr>
+
+<tr><td><a href="pcre_free_substring_list.html">pcre_free_substring_list</a></td>
+    <td>&nbsp;&nbsp;Free list of extracted substrings</td></tr>
+
+<tr><td><a href="pcre_fullinfo.html">pcre_fullinfo</a></td>
+    <td>&nbsp;&nbsp;Extract information about a pattern</td></tr>
+
+<tr><td><a href="pcre_get_named_substring.html">pcre_get_named_substring</a></td>
+    <td>&nbsp;&nbsp;Extract named substring into new memory</td></tr>
+
+<tr><td><a href="pcre_get_stringnumber.html">pcre_get_stringnumber</a></td>
+    <td>&nbsp;&nbsp;Convert captured string name to number</td></tr>
+
+<tr><td><a href="pcre_get_substring.html">pcre_get_substring</a></td>
+    <td>&nbsp;&nbsp;Extract numbered substring into new memory</td></tr>
+
+<tr><td><a href="pcre_get_substring_list.html">pcre_get_substring_list</a></td>
+    <td>&nbsp;&nbsp;Extract all substrings into new memory</td></tr>
+
+<tr><td><a href="pcre_info.html">pcre_info</a></td>
+    <td>&nbsp;&nbsp;Obsolete information extraction function</td></tr>
+
+<tr><td><a href="pcre_maketables.html">pcre_maketables</a></td>
+    <td>&nbsp;&nbsp;Build character tables in current locale</td></tr>
+    
+<tr><td><a href="pcre_refcount.html">pcre_refcount</a></td>
+    <td>&nbsp;&nbsp;Maintain reference count in compiled pattern</td></tr>
+
+<tr><td><a href="pcre_study.html">pcre_study</a></td>
+    <td>&nbsp;&nbsp;Study a compiled pattern</td></tr>
+
+<tr><td><a href="pcre_version.html">pcre_version</a></td>
+    <td>&nbsp;&nbsp;Return PCRE version and release date</td></tr>
+</table>
+
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre-config.1	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,73 @@
+.TH PCRE-CONFIG 1
+.SH NAME
+pcre-config - program to return PCRE configuration
+.SH SYNOPSIS
+.rs
+.sp
+.B pcre-config  [--prefix] [--exec-prefix] [--version] [--libs]
+.ti +5n
+.B              [--libs-posix] [--cflags] [--cflags-posix]
+.
+.
+.SH DESCRIPTION
+.rs
+.sp
+\fBpcre-config\fP returns the configuration of the installed PCRE
+libraries and the options required to compile a program to use them.
+.
+.
+.SH OPTIONS
+.rs
+.TP 10
+\fB--prefix\fP
+Writes the directory prefix used in the PCRE installation for architecture
+independent files (\fI/usr\fP on many systems, \fI/usr/local\fP on some
+systems) to the standard output.
+.TP 10
+\fB--exec-prefix\fP
+Writes the directory prefix used in the PCRE installation for architecture
+dependent files (normally the same as \fB--prefix\fP) to the standard output.
+.TP 10
+\fB--version\fP
+Writes the version number of the installed PCRE libraries to the standard
+output.
+.TP 10
+\fB--libs\fP
+Writes to the standard output the command line options required to link
+with PCRE (\fB-lpcre\fP on many systems).
+.TP 10
+\fB--libs-posix\fP
+Writes to the standard output the command line options required to link with
+the PCRE posix emulation library (\fB-lpcreposix\fP \fB-lpcre\fP on many
+systems).
+.TP 10
+\fB--cflags\fP
+Writes to the standard output the command line options required to compile
+files that use PCRE (this may include some \fB-I\fP options, but is blank on
+many systems).
+.TP 10
+\fB--cflags-posix\fP
+Writes to the standard output the command line options required to compile
+files that use the PCRE posix emulation library (this may include some \fB-I\fP
+options, but is blank on many systems).
+.
+.
+.SH "SEE ALSO"
+.rs
+.sp
+\fBpcre(3)\fP
+.
+.
+.SH AUTHOR
+.rs
+.sp
+This manual page was originally written by Mark Baker for the Debian GNU/Linux
+system. It has been slightly revised as a generic PCRE man page.
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 18 April 2007
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre-config.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,67 @@
+PCRE-CONFIG(1)                                                  PCRE-CONFIG(1)
+
+
+
+NAME
+       pcre-config - program to return PCRE configuration
+
+SYNOPSIS
+
+       pcre-config [--prefix] [--exec-prefix] [--version] [--libs]
+            [--libs-posix] [--cflags] [--cflags-posix]
+
+
+DESCRIPTION
+
+       pcre-config  returns  the configuration of the installed PCRE libraries
+       and the options required to compile a program to use them.
+
+
+OPTIONS
+
+       --prefix  Writes the directory prefix used in the PCRE installation for
+                 architecture   independent   files  (/usr  on  many  systems,
+                 /usr/local on some systems) to the standard output.
+
+       --exec-prefix
+                 Writes the directory prefix used in the PCRE installation for
+                 architecture  dependent files (normally the same as --prefix)
+                 to the standard output.
+
+       --version Writes the version number of the installed PCRE libraries  to
+                 the standard output.
+
+       --libs    Writes  to  the  standard  output  the  command  line options
+                 required to link with PCRE (-lpcre on many systems).
+
+       --libs-posix
+                 Writes to  the  standard  output  the  command  line  options
+                 required  to  link  with  the  PCRE  posix  emulation library
+                 (-lpcreposix -lpcre on many systems).
+
+       --cflags  Writes to  the  standard  output  the  command  line  options
+                 required  to  compile  files  that use PCRE (this may include
+                 some -I options, but is blank on many systems).
+
+       --cflags-posix
+                 Writes to  the  standard  output  the  command  line  options
+                 required  to  compile files that use the PCRE posix emulation
+                 library (this may include some -I options, but  is  blank  on
+                 many systems).
+
+
+SEE ALSO
+
+       pcre(3)
+
+
+AUTHOR
+
+       This  manual  page  was originally written by Mark Baker for the Debian
+       GNU/Linux system. It has been slightly revised as a  generic  PCRE  man
+       page.
+
+
+REVISION
+
+       Last updated: 18 April 2007
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,294 @@
+.TH PCRE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH INTRODUCTION
+.rs
+.sp
+The PCRE library is a set of functions that implement regular expression
+pattern matching using the same syntax and semantics as Perl, with just a few
+differences. Certain features that appeared in Python and PCRE before they
+appeared in Perl are also available using the Python syntax. There is also some
+support for certain .NET and Oniguruma syntax items, and there is an option for
+requesting some minor changes that give better JavaScript compatibility.
+.P
+The current implementation of PCRE (release 7.x) corresponds approximately with
+Perl 5.10, including support for UTF-8 encoded strings and Unicode general
+category properties. However, UTF-8 and Unicode support has to be explicitly
+enabled; it is not the default. The Unicode tables correspond to Unicode
+release 5.0.0.
+.P
+In addition to the Perl-compatible matching function, PCRE contains an
+alternative matching function that matches the same compiled patterns in a
+different way. In certain circumstances, the alternative function has some
+advantages. For a discussion of the two matching algorithms, see the
+.\" HREF
+\fBpcrematching\fP
+.\"
+page.
+.P
+PCRE is written in C and released as a C library. A number of people have
+written wrappers and interfaces of various kinds. In particular, Google Inc.
+have provided a comprehensive C++ wrapper. This is now included as part of the
+PCRE distribution. The
+.\" HREF
+\fBpcrecpp\fP
+.\"
+page has details of this interface. Other people's contributions can be found
+in the \fIContrib\fR directory at the primary FTP site, which is:
+.sp
+.\" HTML <a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre">
+.\" </a>
+ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre
+.P
+Details of exactly which Perl regular expression features are and are not
+supported by PCRE are given in separate documents. See the
+.\" HREF
+\fBpcrepattern\fR
+.\"
+and
+.\" HREF
+\fBpcrecompat\fR
+.\"
+pages. There is a syntax summary in the
+.\" HREF
+\fBpcresyntax\fR
+.\"
+page.
+.P
+Some features of PCRE can be included, excluded, or changed when the library is
+built. The
+.\" HREF
+\fBpcre_config()\fR
+.\"
+function makes it possible for a client to discover which features are
+available. The features themselves are described in the
+.\" HREF
+\fBpcrebuild\fP
+.\"
+page. Documentation about building PCRE for various operating systems can be
+found in the \fBREADME\fP file in the source distribution.
+.P
+The library contains a number of undocumented internal functions and data
+tables that are used by more than one of the exported external functions, but
+which are not intended for use by external callers. Their names all begin with
+"_pcre_", which hopefully will not provoke any name clashes. In some
+environments, it is possible to control which external symbols are exported
+when a shared library is built, and in these cases the undocumented symbols are
+not exported.
+.
+.
+.SH "USER DOCUMENTATION"
+.rs
+.sp
+The user documentation for PCRE comprises a number of different sections. In
+the "man" format, each of these is a separate "man page". In the HTML format,
+each is a separate page, linked from the index page. In the plain text format,
+all the sections are concatenated, for ease of searching. The sections are as
+follows:
+.sp
+  pcre              this document
+  pcre-config       show PCRE installation configuration information
+  pcreapi           details of PCRE's native C API
+  pcrebuild         options for building PCRE
+  pcrecallout       details of the callout feature
+  pcrecompat        discussion of Perl compatibility
+  pcrecpp           details of the C++ wrapper
+  pcregrep          description of the \fBpcregrep\fP command
+  pcrematching      discussion of the two matching algorithms
+  pcrepartial       details of the partial matching facility
+.\" JOIN
+  pcrepattern       syntax and semantics of supported
+                      regular expressions
+  pcresyntax        quick syntax reference
+  pcreperform       discussion of performance issues
+  pcreposix         the POSIX-compatible C API
+  pcreprecompile    details of saving and re-using precompiled patterns
+  pcresample        discussion of the sample program
+  pcrestack         discussion of stack usage
+  pcretest          description of the \fBpcretest\fP testing command
+.sp
+In addition, in the "man" and HTML formats, there is a short page for each
+C library function, listing its arguments and results.
+.
+.
+.SH LIMITATIONS
+.rs
+.sp
+There are some size limitations in PCRE but it is hoped that they will never in
+practice be relevant.
+.P
+The maximum length of a compiled pattern is 65539 (sic) bytes if PCRE is
+compiled with the default internal linkage size of 2. If you want to process
+regular expressions that are truly enormous, you can compile PCRE with an
+internal linkage size of 3 or 4 (see the \fBREADME\fP file in the source
+distribution and the
+.\" HREF
+\fBpcrebuild\fP
+.\"
+documentation for details). In these cases the limit is substantially larger.
+However, the speed of execution is slower.
+.P
+All values in repeating quantifiers must be less than 65536.
+.P
+There is no limit to the number of parenthesized subpatterns, but there can be
+no more than 65535 capturing subpatterns.
+.P
+The maximum length of name for a named subpattern is 32 characters, and the
+maximum number of named subpatterns is 10000.
+.P
+The maximum length of a subject string is the largest positive number that an
+integer variable can hold. However, when using the traditional matching
+function, PCRE uses recursion to handle subpatterns and indefinite repetition.
+This means that the available stack space may limit the size of a subject
+string that can be processed by certain patterns. For a discussion of stack
+issues, see the
+.\" HREF
+\fBpcrestack\fP
+.\"
+documentation.
+.
+.\" HTML <a name="utf8support"></a>
+.
+.
+.SH "UTF-8 AND UNICODE PROPERTY SUPPORT"
+.rs
+.sp
+From release 3.3, PCRE has had some support for character strings encoded in
+the UTF-8 format. For release 4.0 this was greatly extended to cover most
+common requirements, and in release 5.0 additional support for Unicode general
+category properties was added.
+.P
+In order process UTF-8 strings, you must build PCRE to include UTF-8 support in
+the code, and, in addition, you must call
+.\" HREF
+\fBpcre_compile()\fP
+.\"
+with the PCRE_UTF8 option flag. When you do this, both the pattern and any
+subject strings that are matched against it are treated as UTF-8 strings
+instead of just strings of bytes.
+.P
+If you compile PCRE with UTF-8 support, but do not use it at run time, the
+library will be a bit bigger, but the additional run time overhead is limited
+to testing the PCRE_UTF8 flag occasionally, so should not be very big.
+.P
+If PCRE is built with Unicode character property support (which implies UTF-8
+support), the escape sequences \ep{..}, \eP{..}, and \eX are supported.
+The available properties that can be tested are limited to the general
+category properties such as Lu for an upper case letter or Nd for a decimal
+number, the Unicode script names such as Arabic or Han, and the derived
+properties Any and L&. A full list is given in the
+.\" HREF
+\fBpcrepattern\fP
+.\"
+documentation. Only the short names for properties are supported. For example,
+\ep{L} matches a letter. Its Perl synonym, \ep{Letter}, is not supported.
+Furthermore, in Perl, many properties may optionally be prefixed by "Is", for
+compatibility with Perl 5.6. PCRE does not support this.
+.
+.\" HTML <a name="utf8strings"></a>
+.
+.SS "Validity of UTF-8 strings"
+.rs
+.sp
+When you set the PCRE_UTF8 flag, the strings passed as patterns and subjects
+are (by default) checked for validity on entry to the relevant functions. From
+release 7.3 of PCRE, the check is according the rules of RFC 3629, which are
+themselves derived from the Unicode specification. Earlier releases of PCRE
+followed the rules of RFC 2279, which allows the full range of 31-bit values (0
+to 0x7FFFFFFF). The current check allows only values in the range U+0 to
+U+10FFFF, excluding U+D800 to U+DFFF.
+.P
+The excluded code points are the "Low Surrogate Area" of Unicode, of which the
+Unicode Standard says this: "The Low Surrogate Area does not contain any
+character assignments, consequently no character code charts or namelists are
+provided for this area. Surrogates are reserved for use with UTF-16 and then
+must be used in pairs." The code points that are encoded by UTF-16 pairs are
+available as independent code points in the UTF-8 encoding. (In other words,
+the whole surrogate thing is a fudge for UTF-16 which unfortunately messes up
+UTF-8.)
+.P
+If an invalid UTF-8 string is passed to PCRE, an error return
+(PCRE_ERROR_BADUTF8) is given. In some situations, you may already know that
+your strings are valid, and therefore want to skip these checks in order to
+improve performance. If you set the PCRE_NO_UTF8_CHECK flag at compile time or
+at run time, PCRE assumes that the pattern or subject it is given
+(respectively) contains only valid UTF-8 codes. In this case, it does not
+diagnose an invalid UTF-8 string.
+.P
+If you pass an invalid UTF-8 string when PCRE_NO_UTF8_CHECK is set, what
+happens depends on why the string is invalid. If the string conforms to the
+"old" definition of UTF-8 (RFC 2279), it is processed as a string of characters
+in the range 0 to 0x7FFFFFFF. In other words, apart from the initial validity
+test, PCRE (when in UTF-8 mode) handles strings according to the more liberal
+rules of RFC 2279. However, if the string does not even conform to RFC 2279,
+the result is undefined. Your program may crash.
+.P
+If you want to process strings of values in the full range 0 to 0x7FFFFFFF,
+encoded in a UTF-8-like manner as per the old RFC, you can set
+PCRE_NO_UTF8_CHECK to bypass the more restrictive test. However, in this
+situation, you will have to apply your own validity check.
+.
+.SS "General comments about UTF-8 mode"
+.rs
+.sp
+1. An unbraced hexadecimal escape sequence (such as \exb3) matches a two-byte
+UTF-8 character if the value is greater than 127.
+.P
+2. Octal numbers up to \e777 are recognized, and match two-byte UTF-8
+characters for values greater than \e177.
+.P
+3. Repeat quantifiers apply to complete UTF-8 characters, not to individual
+bytes, for example: \ex{100}{3}.
+.P
+4. The dot metacharacter matches one UTF-8 character instead of a single byte.
+.P
+5. The escape sequence \eC can be used to match a single byte in UTF-8 mode,
+but its use can lead to some strange effects. This facility is not available in
+the alternative matching function, \fBpcre_dfa_exec()\fP.
+.P
+6. The character escapes \eb, \eB, \ed, \eD, \es, \eS, \ew, and \eW correctly
+test characters of any code value, but the characters that PCRE recognizes as
+digits, spaces, or word characters remain the same set as before, all with
+values less than 256. This remains true even when PCRE includes Unicode
+property support, because to do otherwise would slow down PCRE in many common
+cases. If you really want to test for a wider sense of, say, "digit", you
+must use Unicode property tests such as \ep{Nd}.
+.P
+7. Similarly, characters that match the POSIX named character classes are all
+low-valued characters.
+.P
+8. However, the Perl 5.10 horizontal and vertical whitespace matching escapes
+(\eh, \eH, \ev, and \eV) do match all the appropriate Unicode characters.
+.P
+9. Case-insensitive matching applies only to characters whose values are less
+than 128, unless PCRE is built with Unicode property support. Even when Unicode
+property support is available, PCRE still uses its own character tables when
+checking the case of low-valued characters, so as not to degrade performance.
+The Unicode property information is used only for characters with higher
+values. Even when Unicode property support is available, PCRE supports
+case-insensitive matching only when there is a one-to-one mapping between a
+letter's cases. There are a small number of many-to-one mappings in Unicode;
+these are not supported by PCRE.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.P
+Putting an actual email address here seems to have been a spam magnet, so I've
+taken it away. If you want to email me, use my two initials, followed by the
+two digits 10, at the domain cam.ac.uk.
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 12 April 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,6616 @@
+-----------------------------------------------------------------------------
+This file contains a concatenation of the PCRE man pages, converted to plain
+text format for ease of searching with a text editor, or for use on systems
+that do not have a man page processor. The small individual files that give
+synopses of each function in the library have not been included. There are
+separate text files for the pcregrep and pcretest commands.
+-----------------------------------------------------------------------------
+
+
+PCRE(3)                                                                PCRE(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+INTRODUCTION
+
+       The  PCRE  library is a set of functions that implement regular expres-
+       sion pattern matching using the same syntax and semantics as Perl, with
+       just  a  few  differences. Certain features that appeared in Python and
+       PCRE before they appeared in Perl are also available using  the  Python
+       syntax.  There is also some support for certain .NET and Oniguruma syn-
+       tax items, and there is an option for  requesting  some  minor  changes
+       that give better JavaScript compatibility.
+
+       The  current  implementation of PCRE (release 7.x) corresponds approxi-
+       mately with Perl 5.10, including support for UTF-8 encoded strings  and
+       Unicode general category properties. However, UTF-8 and Unicode support
+       has to be explicitly enabled; it is not the default. The Unicode tables
+       correspond to Unicode release 5.0.0.
+
+       In  addition to the Perl-compatible matching function, PCRE contains an
+       alternative matching function that matches the same  compiled  patterns
+       in  a different way. In certain circumstances, the alternative function
+       has some advantages. For a discussion of the two  matching  algorithms,
+       see the pcrematching page.
+
+       PCRE  is  written  in C and released as a C library. A number of people
+       have written wrappers and interfaces of various kinds.  In  particular,
+       Google  Inc.   have  provided  a comprehensive C++ wrapper. This is now
+       included as part of the PCRE distribution. The pcrecpp page has details
+       of  this  interface.  Other  people's contributions can be found in the
+       Contrib directory at the primary FTP site, which is:
+
+       ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre
+
+       Details of exactly which Perl regular expression features are  and  are
+       not supported by PCRE are given in separate documents. See the pcrepat-
+       tern and pcrecompat pages. There is a syntax summary in the  pcresyntax
+       page.
+
+       Some  features  of  PCRE can be included, excluded, or changed when the
+       library is built. The pcre_config() function makes it  possible  for  a
+       client  to  discover  which  features are available. The features them-
+       selves are described in the pcrebuild page. Documentation about  build-
+       ing  PCRE for various operating systems can be found in the README file
+       in the source distribution.
+
+       The library contains a number of undocumented  internal  functions  and
+       data  tables  that  are  used by more than one of the exported external
+       functions, but which are not intended  for  use  by  external  callers.
+       Their  names  all begin with "_pcre_", which hopefully will not provoke
+       any name clashes. In some environments, it is possible to control which
+       external  symbols  are  exported when a shared library is built, and in
+       these cases the undocumented symbols are not exported.
+
+
+USER DOCUMENTATION
+
+       The user documentation for PCRE comprises a number  of  different  sec-
+       tions.  In the "man" format, each of these is a separate "man page". In
+       the HTML format, each is a separate page, linked from the  index  page.
+       In  the  plain text format, all the sections are concatenated, for ease
+       of searching. The sections are as follows:
+
+         pcre              this document
+         pcre-config       show PCRE installation configuration information
+         pcreapi           details of PCRE's native C API
+         pcrebuild         options for building PCRE
+         pcrecallout       details of the callout feature
+         pcrecompat        discussion of Perl compatibility
+         pcrecpp           details of the C++ wrapper
+         pcregrep          description of the pcregrep command
+         pcrematching      discussion of the two matching algorithms
+         pcrepartial       details of the partial matching facility
+         pcrepattern       syntax and semantics of supported
+                             regular expressions
+         pcresyntax        quick syntax reference
+         pcreperform       discussion of performance issues
+         pcreposix         the POSIX-compatible C API
+         pcreprecompile    details of saving and re-using precompiled patterns
+         pcresample        discussion of the sample program
+         pcrestack         discussion of stack usage
+         pcretest          description of the pcretest testing command
+
+       In  addition,  in the "man" and HTML formats, there is a short page for
+       each C library function, listing its arguments and results.
+
+
+LIMITATIONS
+
+       There are some size limitations in PCRE but it is hoped that they  will
+       never in practice be relevant.
+
+       The  maximum  length of a compiled pattern is 65539 (sic) bytes if PCRE
+       is compiled with the default internal linkage size of 2. If you want to
+       process  regular  expressions  that are truly enormous, you can compile
+       PCRE with an internal linkage size of 3 or 4 (see the  README  file  in
+       the  source  distribution and the pcrebuild documentation for details).
+       In these cases the limit is substantially larger.  However,  the  speed
+       of execution is slower.
+
+       All values in repeating quantifiers must be less than 65536.
+
+       There is no limit to the number of parenthesized subpatterns, but there
+       can be no more than 65535 capturing subpatterns.
+
+       The maximum length of name for a named subpattern is 32 characters, and
+       the maximum number of named subpatterns is 10000.
+
+       The  maximum  length of a subject string is the largest positive number
+       that an integer variable can hold. However, when using the  traditional
+       matching function, PCRE uses recursion to handle subpatterns and indef-
+       inite repetition.  This means that the available stack space may  limit
+       the size of a subject string that can be processed by certain patterns.
+       For a discussion of stack issues, see the pcrestack documentation.
+
+
+UTF-8 AND UNICODE PROPERTY SUPPORT
+
+       From release 3.3, PCRE has  had  some  support  for  character  strings
+       encoded  in the UTF-8 format. For release 4.0 this was greatly extended
+       to cover most common requirements, and in release 5.0  additional  sup-
+       port for Unicode general category properties was added.
+
+       In  order  process  UTF-8 strings, you must build PCRE to include UTF-8
+       support in the code, and, in addition,  you  must  call  pcre_compile()
+       with  the PCRE_UTF8 option flag. When you do this, both the pattern and
+       any subject strings that are matched against it are  treated  as  UTF-8
+       strings instead of just strings of bytes.
+
+       If  you compile PCRE with UTF-8 support, but do not use it at run time,
+       the library will be a bit bigger, but the additional run time  overhead
+       is limited to testing the PCRE_UTF8 flag occasionally, so should not be
+       very big.
+
+       If PCRE is built with Unicode character property support (which implies
+       UTF-8  support),  the  escape sequences \p{..}, \P{..}, and \X are sup-
+       ported.  The available properties that can be tested are limited to the
+       general  category  properties such as Lu for an upper case letter or Nd
+       for a decimal number, the Unicode script names such as Arabic  or  Han,
+       and  the  derived  properties  Any  and L&. A full list is given in the
+       pcrepattern documentation. Only the short names for properties are sup-
+       ported.  For example, \p{L} matches a letter. Its Perl synonym, \p{Let-
+       ter}, is not supported.  Furthermore,  in  Perl,  many  properties  may
+       optionally  be  prefixed by "Is", for compatibility with Perl 5.6. PCRE
+       does not support this.
+
+   Validity of UTF-8 strings
+
+       When you set the PCRE_UTF8 flag, the strings  passed  as  patterns  and
+       subjects are (by default) checked for validity on entry to the relevant
+       functions. From release 7.3 of PCRE, the check is according  the  rules
+       of  RFC  3629, which are themselves derived from the Unicode specifica-
+       tion. Earlier releases of PCRE followed the rules of  RFC  2279,  which
+       allows  the  full range of 31-bit values (0 to 0x7FFFFFFF). The current
+       check allows only values in the range U+0 to U+10FFFF, excluding U+D800
+       to U+DFFF.
+
+       The  excluded  code  points are the "Low Surrogate Area" of Unicode, of
+       which the Unicode Standard says this: "The Low Surrogate Area does  not
+       contain  any  character  assignments,  consequently  no  character code
+       charts or namelists are provided for this area. Surrogates are reserved
+       for  use  with  UTF-16 and then must be used in pairs." The code points
+       that are encoded by UTF-16 pairs  are  available  as  independent  code
+       points  in  the  UTF-8  encoding.  (In other words, the whole surrogate
+       thing is a fudge for UTF-16 which unfortunately messes up UTF-8.)
+
+       If an  invalid  UTF-8  string  is  passed  to  PCRE,  an  error  return
+       (PCRE_ERROR_BADUTF8) is given. In some situations, you may already know
+       that your strings are valid, and therefore want to skip these checks in
+       order to improve performance. If you set the PCRE_NO_UTF8_CHECK flag at
+       compile time or at run time, PCRE assumes that the pattern  or  subject
+       it  is  given  (respectively)  contains only valid UTF-8 codes. In this
+       case, it does not diagnose an invalid UTF-8 string.
+
+       If you pass an invalid UTF-8 string  when  PCRE_NO_UTF8_CHECK  is  set,
+       what  happens  depends on why the string is invalid. If the string con-
+       forms to the "old" definition of UTF-8 (RFC 2279), it is processed as a
+       string  of  characters  in  the  range 0 to 0x7FFFFFFF. In other words,
+       apart from the initial validity test, PCRE (when in UTF-8 mode) handles
+       strings  according  to  the more liberal rules of RFC 2279. However, if
+       the string does not even conform to RFC 2279, the result is  undefined.
+       Your program may crash.
+
+       If  you  want  to  process  strings  of  values  in the full range 0 to
+       0x7FFFFFFF, encoded in a UTF-8-like manner as per the old RFC, you  can
+       set PCRE_NO_UTF8_CHECK to bypass the more restrictive test. However, in
+       this situation, you will have to apply your own validity check.
+
+   General comments about UTF-8 mode
+
+       1. An unbraced hexadecimal escape sequence (such  as  \xb3)  matches  a
+       two-byte UTF-8 character if the value is greater than 127.
+
+       2.  Octal  numbers  up to \777 are recognized, and match two-byte UTF-8
+       characters for values greater than \177.
+
+       3. Repeat quantifiers apply to complete UTF-8 characters, not to  indi-
+       vidual bytes, for example: \x{100}{3}.
+
+       4.  The dot metacharacter matches one UTF-8 character instead of a sin-
+       gle byte.
+
+       5. The escape sequence \C can be used to match a single byte  in  UTF-8
+       mode,  but  its  use can lead to some strange effects. This facility is
+       not available in the alternative matching function, pcre_dfa_exec().
+
+       6. The character escapes \b, \B, \d, \D, \s, \S, \w, and  \W  correctly
+       test  characters of any code value, but the characters that PCRE recog-
+       nizes as digits, spaces, or word characters  remain  the  same  set  as
+       before, all with values less than 256. This remains true even when PCRE
+       includes Unicode property support, because to do otherwise  would  slow
+       down  PCRE in many common cases. If you really want to test for a wider
+       sense of, say, "digit", you must use Unicode  property  tests  such  as
+       \p{Nd}.
+
+       7.  Similarly,  characters that match the POSIX named character classes
+       are all low-valued characters.
+
+       8. However, the Perl 5.10 horizontal and vertical  whitespace  matching
+       escapes (\h, \H, \v, and \V) do match all the appropriate Unicode char-
+       acters.
+
+       9. Case-insensitive matching applies only to  characters  whose  values
+       are  less than 128, unless PCRE is built with Unicode property support.
+       Even when Unicode property support is available, PCRE  still  uses  its
+       own  character  tables when checking the case of low-valued characters,
+       so as not to degrade performance.  The Unicode property information  is
+       used only for characters with higher values. Even when Unicode property
+       support is available, PCRE supports case-insensitive matching only when
+       there  is  a  one-to-one  mapping between a letter's cases. There are a
+       small number of many-to-one mappings in Unicode;  these  are  not  sup-
+       ported by PCRE.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+       Putting  an actual email address here seems to have been a spam magnet,
+       so I've taken it away. If you want to email me, use  my  two  initials,
+       followed by the two digits 10, at the domain cam.ac.uk.
+
+
+REVISION
+
+       Last updated: 12 April 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCREBUILD(3)                                                      PCREBUILD(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE BUILD-TIME OPTIONS
+
+       This  document  describes  the  optional  features  of PCRE that can be
+       selected when the library is compiled. It assumes use of the  configure
+       script,  where the optional features are selected or deselected by pro-
+       viding options to configure before running the make  command.  However,
+       the  same  options  can be selected in both Unix-like and non-Unix-like
+       environments using the GUI facility of  CMakeSetup  if  you  are  using
+       CMake instead of configure to build PCRE.
+
+       The complete list of options for configure (which includes the standard
+       ones such as the  selection  of  the  installation  directory)  can  be
+       obtained by running
+
+         ./configure --help
+
+       The  following  sections  include  descriptions  of options whose names
+       begin with --enable or --disable. These settings specify changes to the
+       defaults  for  the configure command. Because of the way that configure
+       works, --enable and --disable always come in pairs, so  the  complemen-
+       tary  option always exists as well, but as it specifies the default, it
+       is not described.
+
+
+C++ SUPPORT
+
+       By default, the configure script will search for a C++ compiler and C++
+       header files. If it finds them, it automatically builds the C++ wrapper
+       library for PCRE. You can disable this by adding
+
+         --disable-cpp
+
+       to the configure command.
+
+
+UTF-8 SUPPORT
+
+       To build PCRE with support for UTF-8 character strings, add
+
+         --enable-utf8
+
+       to the configure command. Of itself, this  does  not  make  PCRE  treat
+       strings  as UTF-8. As well as compiling PCRE with this option, you also
+       have have to set the PCRE_UTF8 option when you call the  pcre_compile()
+       function.
+
+
+UNICODE CHARACTER PROPERTY SUPPORT
+
+       UTF-8  support allows PCRE to process character values greater than 255
+       in the strings that it handles. On its own, however, it does  not  pro-
+       vide any facilities for accessing the properties of such characters. If
+       you want to be able to use the pattern escapes \P, \p,  and  \X,  which
+       refer to Unicode character properties, you must add
+
+         --enable-unicode-properties
+
+       to  the configure command. This implies UTF-8 support, even if you have
+       not explicitly requested it.
+
+       Including Unicode property support adds around 30K  of  tables  to  the
+       PCRE  library.  Only  the general category properties such as Lu and Nd
+       are supported. Details are given in the pcrepattern documentation.
+
+
+CODE VALUE OF NEWLINE
+
+       By default, PCRE interprets character 10 (linefeed, LF)  as  indicating
+       the  end  of  a line. This is the normal newline character on Unix-like
+       systems. You can compile PCRE to use character 13 (carriage return, CR)
+       instead, by adding
+
+         --enable-newline-is-cr
+
+       to  the  configure  command.  There  is  also  a --enable-newline-is-lf
+       option, which explicitly specifies linefeed as the newline character.
+
+       Alternatively, you can specify that line endings are to be indicated by
+       the two character sequence CRLF. If you want this, add
+
+         --enable-newline-is-crlf
+
+       to the configure command. There is a fourth option, specified by
+
+         --enable-newline-is-anycrlf
+
+       which  causes  PCRE  to recognize any of the three sequences CR, LF, or
+       CRLF as indicating a line ending. Finally, a fifth option, specified by
+
+         --enable-newline-is-any
+
+       causes PCRE to recognize any Unicode newline sequence.
+
+       Whatever  line  ending convention is selected when PCRE is built can be
+       overridden when the library functions are called. At build time  it  is
+       conventional to use the standard for your operating system.
+
+
+WHAT \R MATCHES
+
+       By  default,  the  sequence \R in a pattern matches any Unicode newline
+       sequence, whatever has been selected as the line  ending  sequence.  If
+       you specify
+
+         --enable-bsr-anycrlf
+
+       the  default  is changed so that \R matches only CR, LF, or CRLF. What-
+       ever is selected when PCRE is built can be overridden when the  library
+       functions are called.
+
+
+BUILDING SHARED AND STATIC LIBRARIES
+
+       The  PCRE building process uses libtool to build both shared and static
+       Unix libraries by default. You can suppress one of these by adding  one
+       of
+
+         --disable-shared
+         --disable-static
+
+       to the configure command, as required.
+
+
+POSIX MALLOC USAGE
+
+       When PCRE is called through the POSIX interface (see the pcreposix doc-
+       umentation), additional working storage is  required  for  holding  the
+       pointers  to capturing substrings, because PCRE requires three integers
+       per substring, whereas the POSIX interface provides only  two.  If  the
+       number of expected substrings is small, the wrapper function uses space
+       on the stack, because this is faster than using malloc() for each call.
+       The default threshold above which the stack is no longer used is 10; it
+       can be changed by adding a setting such as
+
+         --with-posix-malloc-threshold=20
+
+       to the configure command.
+
+
+HANDLING VERY LARGE PATTERNS
+
+       Within a compiled pattern, offset values are used  to  point  from  one
+       part  to another (for example, from an opening parenthesis to an alter-
+       nation metacharacter). By default, two-byte values are used  for  these
+       offsets,  leading  to  a  maximum size for a compiled pattern of around
+       64K. This is sufficient to handle all but the most  gigantic  patterns.
+       Nevertheless,  some  people do want to process enormous patterns, so it
+       is possible to compile PCRE to use three-byte or four-byte  offsets  by
+       adding a setting such as
+
+         --with-link-size=3
+
+       to  the  configure  command.  The value given must be 2, 3, or 4. Using
+       longer offsets slows down the operation of PCRE because it has to  load
+       additional bytes when handling them.
+
+
+AVOIDING EXCESSIVE STACK USAGE
+
+       When matching with the pcre_exec() function, PCRE implements backtrack-
+       ing by making recursive calls to an internal function  called  match().
+       In  environments  where  the size of the stack is limited, this can se-
+       verely limit PCRE's operation. (The Unix environment does  not  usually
+       suffer from this problem, but it may sometimes be necessary to increase
+       the maximum stack size.  There is a discussion in the  pcrestack  docu-
+       mentation.)  An alternative approach to recursion that uses memory from
+       the heap to remember data, instead of using recursive  function  calls,
+       has  been  implemented to work round the problem of limited stack size.
+       If you want to build a version of PCRE that works this way, add
+
+         --disable-stack-for-recursion
+
+       to the configure command. With this configuration, PCRE  will  use  the
+       pcre_stack_malloc  and pcre_stack_free variables to call memory manage-
+       ment functions. By default these point to malloc() and free(), but  you
+       can replace the pointers so that your own functions are used.
+
+       Separate  functions  are  provided  rather  than  using pcre_malloc and
+       pcre_free because the  usage  is  very  predictable:  the  block  sizes
+       requested  are  always  the  same,  and  the blocks are always freed in
+       reverse order. A calling program might be able to  implement  optimized
+       functions  that  perform  better  than  malloc()  and free(). PCRE runs
+       noticeably more slowly when built in this way. This option affects only
+       the   pcre_exec()   function;   it   is   not   relevant  for  the  the
+       pcre_dfa_exec() function.
+
+
+LIMITING PCRE RESOURCE USAGE
+
+       Internally, PCRE has a function called match(), which it calls  repeat-
+       edly   (sometimes   recursively)  when  matching  a  pattern  with  the
+       pcre_exec() function. By controlling the maximum number of  times  this
+       function  may be called during a single matching operation, a limit can
+       be placed on the resources used by a single call  to  pcre_exec().  The
+       limit  can be changed at run time, as described in the pcreapi documen-
+       tation. The default is 10 million, but this can be changed by adding  a
+       setting such as
+
+         --with-match-limit=500000
+
+       to   the   configure  command.  This  setting  has  no  effect  on  the
+       pcre_dfa_exec() matching function.
+
+       In some environments it is desirable to limit the  depth  of  recursive
+       calls of match() more strictly than the total number of calls, in order
+       to restrict the maximum amount of stack (or heap,  if  --disable-stack-
+       for-recursion is specified) that is used. A second limit controls this;
+       it defaults to the value that  is  set  for  --with-match-limit,  which
+       imposes  no  additional constraints. However, you can set a lower limit
+       by adding, for example,
+
+         --with-match-limit-recursion=10000
+
+       to the configure command. This value can  also  be  overridden  at  run
+       time.
+
+
+CREATING CHARACTER TABLES AT BUILD TIME
+
+       PCRE  uses fixed tables for processing characters whose code values are
+       less than 256. By default, PCRE is built with a set of tables that  are
+       distributed  in  the  file pcre_chartables.c.dist. These tables are for
+       ASCII codes only. If you add
+
+         --enable-rebuild-chartables
+
+       to the configure command, the distributed tables are  no  longer  used.
+       Instead,  a  program  called dftables is compiled and run. This outputs
+       the source for new set of tables, created in the default locale of your
+       C runtime system. (This method of replacing the tables does not work if
+       you are cross compiling, because dftables is run on the local host.  If
+       you  need  to  create alternative tables when cross compiling, you will
+       have to do so "by hand".)
+
+
+USING EBCDIC CODE
+
+       PCRE assumes by default that it will run in an  environment  where  the
+       character  code  is  ASCII  (or Unicode, which is a superset of ASCII).
+       This is the case for most computer operating systems.  PCRE  can,  how-
+       ever, be compiled to run in an EBCDIC environment by adding
+
+         --enable-ebcdic
+
+       to the configure command. This setting implies --enable-rebuild-charta-
+       bles. You should only use it if you know that  you  are  in  an  EBCDIC
+       environment (for example, an IBM mainframe operating system).
+
+
+PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT
+
+       By default, pcregrep reads all files as plain text. You can build it so
+       that it recognizes files whose names end in .gz or .bz2, and reads them
+       with libz or libbz2, respectively, by adding one or both of
+
+         --enable-pcregrep-libz
+         --enable-pcregrep-libbz2
+
+       to the configure command. These options naturally require that the rel-
+       evant libraries are installed on your system. Configuration  will  fail
+       if they are not.
+
+
+PCRETEST OPTION FOR LIBREADLINE SUPPORT
+
+       If you add
+
+         --enable-pcretest-libreadline
+
+       to  the  configure  command,  pcretest  is  linked with the libreadline
+       library, and when its input is from a terminal, it reads it  using  the
+       readline() function. This provides line-editing and history facilities.
+       Note that libreadline is GPL-licenced, so if you distribute a binary of
+       pcretest linked in this way, there may be licensing issues.
+
+       Setting  this  option  causes  the -lreadline option to be added to the
+       pcretest build. In many operating environments with  a  sytem-installed
+       libreadline this is sufficient. However, in some environments (e.g.  if
+       an unmodified distribution version of readline is in use),  some  extra
+       configuration  may  be necessary. The INSTALL file for libreadline says
+       this:
+
+         "Readline uses the termcap functions, but does not link with the
+         termcap or curses library itself, allowing applications which link
+         with readline the to choose an appropriate library."
+
+       If your environment has not been set up so that an appropriate  library
+       is automatically included, you may need to add something like
+
+         LIBS="-ncurses"
+
+       immediately before the configure command.
+
+
+SEE ALSO
+
+       pcreapi(3), pcre_config(3).
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 13 April 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCREMATCHING(3)                                                PCREMATCHING(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE MATCHING ALGORITHMS
+
+       This document describes the two different algorithms that are available
+       in PCRE for matching a compiled regular expression against a given sub-
+       ject  string.  The  "standard"  algorithm  is  the  one provided by the
+       pcre_exec() function.  This works in the same was  as  Perl's  matching
+       function, and provides a Perl-compatible matching operation.
+
+       An  alternative  algorithm is provided by the pcre_dfa_exec() function;
+       this operates in a different way, and is not  Perl-compatible.  It  has
+       advantages  and disadvantages compared with the standard algorithm, and
+       these are described below.
+
+       When there is only one possible way in which a given subject string can
+       match  a pattern, the two algorithms give the same answer. A difference
+       arises, however, when there are multiple possibilities. For example, if
+       the pattern
+
+         ^<.*>
+
+       is matched against the string
+
+         <something> <something else> <something further>
+
+       there are three possible answers. The standard algorithm finds only one
+       of them, whereas the alternative algorithm finds all three.
+
+
+REGULAR EXPRESSIONS AS TREES
+
+       The set of strings that are matched by a regular expression can be rep-
+       resented  as  a  tree structure. An unlimited repetition in the pattern
+       makes the tree of infinite size, but it is still a tree.  Matching  the
+       pattern  to a given subject string (from a given starting point) can be
+       thought of as a search of the tree.  There are two  ways  to  search  a
+       tree:  depth-first  and  breadth-first, and these correspond to the two
+       matching algorithms provided by PCRE.
+
+
+THE STANDARD MATCHING ALGORITHM
+
+       In the terminology of Jeffrey Friedl's book "Mastering Regular  Expres-
+       sions",  the  standard  algorithm  is an "NFA algorithm". It conducts a
+       depth-first search of the pattern tree. That is, it  proceeds  along  a
+       single path through the tree, checking that the subject matches what is
+       required. When there is a mismatch, the algorithm  tries  any  alterna-
+       tives  at  the  current point, and if they all fail, it backs up to the
+       previous branch point in the  tree,  and  tries  the  next  alternative
+       branch  at  that  level.  This often involves backing up (moving to the
+       left) in the subject string as well.  The  order  in  which  repetition
+       branches  are  tried  is controlled by the greedy or ungreedy nature of
+       the quantifier.
+
+       If a leaf node is reached, a matching string has  been  found,  and  at
+       that  point the algorithm stops. Thus, if there is more than one possi-
+       ble match, this algorithm returns the first one that it finds.  Whether
+       this  is the shortest, the longest, or some intermediate length depends
+       on the way the greedy and ungreedy repetition quantifiers are specified
+       in the pattern.
+
+       Because  it  ends  up  with a single path through the tree, it is rela-
+       tively straightforward for this algorithm to keep  track  of  the  sub-
+       strings  that  are  matched  by portions of the pattern in parentheses.
+       This provides support for capturing parentheses and back references.
+
+
+THE ALTERNATIVE MATCHING ALGORITHM
+
+       This algorithm conducts a breadth-first search of  the  tree.  Starting
+       from  the  first  matching  point  in the subject, it scans the subject
+       string from left to right, once, character by character, and as it does
+       this,  it remembers all the paths through the tree that represent valid
+       matches. In Friedl's terminology, this is a kind  of  "DFA  algorithm",
+       though  it is not implemented as a traditional finite state machine (it
+       keeps multiple states active simultaneously).
+
+       The scan continues until either the end of the subject is  reached,  or
+       there  are  no more unterminated paths. At this point, terminated paths
+       represent the different matching possibilities (if there are none,  the
+       match  has  failed).   Thus,  if there is more than one possible match,
+       this algorithm finds all of them, and in particular, it finds the long-
+       est.  In PCRE, there is an option to stop the algorithm after the first
+       match (which is necessarily the shortest) has been found.
+
+       Note that all the matches that are found start at the same point in the
+       subject. If the pattern
+
+         cat(er(pillar)?)
+
+       is  matched  against the string "the caterpillar catchment", the result
+       will be the three strings "cat", "cater", and "caterpillar" that  start
+       at the fourth character of the subject. The algorithm does not automat-
+       ically move on to find matches that start at later positions.
+
+       There are a number of features of PCRE regular expressions that are not
+       supported by the alternative matching algorithm. They are as follows:
+
+       1.  Because  the  algorithm  finds  all possible matches, the greedy or
+       ungreedy nature of repetition quantifiers is not relevant.  Greedy  and
+       ungreedy quantifiers are treated in exactly the same way. However, pos-
+       sessive quantifiers can make a difference when what follows could  also
+       match what is quantified, for example in a pattern like this:
+
+         ^a++\w!
+
+       This  pattern matches "aaab!" but not "aaa!", which would be matched by
+       a non-possessive quantifier. Similarly, if an atomic group is  present,
+       it  is matched as if it were a standalone pattern at the current point,
+       and the longest match is then "locked in" for the rest of  the  overall
+       pattern.
+
+       2. When dealing with multiple paths through the tree simultaneously, it
+       is not straightforward to keep track of  captured  substrings  for  the
+       different  matching  possibilities,  and  PCRE's implementation of this
+       algorithm does not attempt to do this. This means that no captured sub-
+       strings are available.
+
+       3.  Because no substrings are captured, back references within the pat-
+       tern are not supported, and cause errors if encountered.
+
+       4. For the same reason, conditional expressions that use  a  backrefer-
+       ence  as  the  condition or test for a specific group recursion are not
+       supported.
+
+       5. Because many paths through the tree may be  active,  the  \K  escape
+       sequence, which resets the start of the match when encountered (but may
+       be on some paths and not on others), is not  supported.  It  causes  an
+       error if encountered.
+
+       6.  Callouts  are  supported, but the value of the capture_top field is
+       always 1, and the value of the capture_last field is always -1.
+
+       7. The \C escape sequence, which (in the standard algorithm) matches  a
+       single  byte, even in UTF-8 mode, is not supported because the alterna-
+       tive algorithm moves through the subject  string  one  character  at  a
+       time, for all active paths through the tree.
+
+       8.  Except for (*FAIL), the backtracking control verbs such as (*PRUNE)
+       are not supported. (*FAIL) is supported, and  behaves  like  a  failing
+       negative assertion.
+
+
+ADVANTAGES OF THE ALTERNATIVE ALGORITHM
+
+       Using  the alternative matching algorithm provides the following advan-
+       tages:
+
+       1. All possible matches (at a single point in the subject) are automat-
+       ically  found,  and  in particular, the longest match is found. To find
+       more than one match using the standard algorithm, you have to do kludgy
+       things with callouts.
+
+       2.  There is much better support for partial matching. The restrictions
+       on the content of the pattern that apply when using the standard  algo-
+       rithm  for  partial matching do not apply to the alternative algorithm.
+       For non-anchored patterns, the starting position of a partial match  is
+       available.
+
+       3.  Because  the  alternative  algorithm  scans the subject string just
+       once, and never needs to backtrack, it is possible to  pass  very  long
+       subject  strings  to  the matching function in several pieces, checking
+       for partial matching each time.
+
+
+DISADVANTAGES OF THE ALTERNATIVE ALGORITHM
+
+       The alternative algorithm suffers from a number of disadvantages:
+
+       1. It is substantially slower than  the  standard  algorithm.  This  is
+       partly  because  it has to search for all possible matches, but is also
+       because it is less susceptible to optimization.
+
+       2. Capturing parentheses and back references are not supported.
+
+       3. Although atomic groups are supported, their use does not provide the
+       performance advantage that it does for the standard algorithm.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 19 April 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCREAPI(3)                                                          PCREAPI(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE NATIVE API
+
+       #include <pcre.h>
+
+       pcre *pcre_compile(const char *pattern, int options,
+            const char **errptr, int *erroffset,
+            const unsigned char *tableptr);
+
+       pcre *pcre_compile2(const char *pattern, int options,
+            int *errorcodeptr,
+            const char **errptr, int *erroffset,
+            const unsigned char *tableptr);
+
+       pcre_extra *pcre_study(const pcre *code, int options,
+            const char **errptr);
+
+       int pcre_exec(const pcre *code, const pcre_extra *extra,
+            const char *subject, int length, int startoffset,
+            int options, int *ovector, int ovecsize);
+
+       int pcre_dfa_exec(const pcre *code, const pcre_extra *extra,
+            const char *subject, int length, int startoffset,
+            int options, int *ovector, int ovecsize,
+            int *workspace, int wscount);
+
+       int pcre_copy_named_substring(const pcre *code,
+            const char *subject, int *ovector,
+            int stringcount, const char *stringname,
+            char *buffer, int buffersize);
+
+       int pcre_copy_substring(const char *subject, int *ovector,
+            int stringcount, int stringnumber, char *buffer,
+            int buffersize);
+
+       int pcre_get_named_substring(const pcre *code,
+            const char *subject, int *ovector,
+            int stringcount, const char *stringname,
+            const char **stringptr);
+
+       int pcre_get_stringnumber(const pcre *code,
+            const char *name);
+
+       int pcre_get_stringtable_entries(const pcre *code,
+            const char *name, char **first, char **last);
+
+       int pcre_get_substring(const char *subject, int *ovector,
+            int stringcount, int stringnumber,
+            const char **stringptr);
+
+       int pcre_get_substring_list(const char *subject,
+            int *ovector, int stringcount, const char ***listptr);
+
+       void pcre_free_substring(const char *stringptr);
+
+       void pcre_free_substring_list(const char **stringptr);
+
+       const unsigned char *pcre_maketables(void);
+
+       int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
+            int what, void *where);
+
+       int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
+
+       int pcre_refcount(pcre *code, int adjust);
+
+       int pcre_config(int what, void *where);
+
+       char *pcre_version(void);
+
+       void *(*pcre_malloc)(size_t);
+
+       void (*pcre_free)(void *);
+
+       void *(*pcre_stack_malloc)(size_t);
+
+       void (*pcre_stack_free)(void *);
+
+       int (*pcre_callout)(pcre_callout_block *);
+
+
+PCRE API OVERVIEW
+
+       PCRE has its own native API, which is described in this document. There
+       are also some wrapper functions that correspond to  the  POSIX  regular
+       expression  API.  These  are  described in the pcreposix documentation.
+       Both of these APIs define a set of C function calls. A C++  wrapper  is
+       distributed with PCRE. It is documented in the pcrecpp page.
+
+       The  native  API  C  function prototypes are defined in the header file
+       pcre.h, and on Unix systems the library itself is called  libpcre.   It
+       can normally be accessed by adding -lpcre to the command for linking an
+       application  that  uses  PCRE.  The  header  file  defines  the  macros
+       PCRE_MAJOR  and  PCRE_MINOR to contain the major and minor release num-
+       bers for the library.  Applications can use these  to  include  support
+       for different releases of PCRE.
+
+       The   functions   pcre_compile(),  pcre_compile2(),  pcre_study(),  and
+       pcre_exec() are used for compiling and matching regular expressions  in
+       a  Perl-compatible  manner. A sample program that demonstrates the sim-
+       plest way of using them is provided in the file  called  pcredemo.c  in
+       the  source distribution. The pcresample documentation describes how to
+       compile and run it.
+
+       A second matching function, pcre_dfa_exec(), which is not Perl-compati-
+       ble,  is  also provided. This uses a different algorithm for the match-
+       ing. The alternative algorithm finds all possible matches (at  a  given
+       point  in  the subject), and scans the subject just once. However, this
+       algorithm does not return captured substrings. A description of the two
+       matching  algorithms and their advantages and disadvantages is given in
+       the pcrematching documentation.
+
+       In addition to the main compiling and  matching  functions,  there  are
+       convenience functions for extracting captured substrings from a subject
+       string that is matched by pcre_exec(). They are:
+
+         pcre_copy_substring()
+         pcre_copy_named_substring()
+         pcre_get_substring()
+         pcre_get_named_substring()
+         pcre_get_substring_list()
+         pcre_get_stringnumber()
+         pcre_get_stringtable_entries()
+
+       pcre_free_substring() and pcre_free_substring_list() are also provided,
+       to free the memory used for extracted strings.
+
+       The  function  pcre_maketables()  is  used  to build a set of character
+       tables  in  the  current  locale   for   passing   to   pcre_compile(),
+       pcre_exec(),  or  pcre_dfa_exec(). This is an optional facility that is
+       provided for specialist use.  Most  commonly,  no  special  tables  are
+       passed,  in  which case internal tables that are generated when PCRE is
+       built are used.
+
+       The function pcre_fullinfo() is used to find out  information  about  a
+       compiled  pattern; pcre_info() is an obsolete version that returns only
+       some of the available information, but is retained for  backwards  com-
+       patibility.   The function pcre_version() returns a pointer to a string
+       containing the version of PCRE and its date of release.
+
+       The function pcre_refcount() maintains a  reference  count  in  a  data
+       block  containing  a compiled pattern. This is provided for the benefit
+       of object-oriented applications.
+
+       The global variables pcre_malloc and pcre_free  initially  contain  the
+       entry  points  of  the  standard malloc() and free() functions, respec-
+       tively. PCRE calls the memory management functions via these variables,
+       so  a  calling  program  can replace them if it wishes to intercept the
+       calls. This should be done before calling any PCRE functions.
+
+       The global variables pcre_stack_malloc  and  pcre_stack_free  are  also
+       indirections  to  memory  management functions. These special functions
+       are used only when PCRE is compiled to use  the  heap  for  remembering
+       data, instead of recursive function calls, when running the pcre_exec()
+       function. See the pcrebuild documentation for  details  of  how  to  do
+       this.  It  is  a non-standard way of building PCRE, for use in environ-
+       ments that have limited stacks. Because of the greater  use  of  memory
+       management,  it  runs  more  slowly. Separate functions are provided so
+       that special-purpose external code can be  used  for  this  case.  When
+       used,  these  functions  are always called in a stack-like manner (last
+       obtained, first freed), and always for memory blocks of the same  size.
+       There  is  a discussion about PCRE's stack usage in the pcrestack docu-
+       mentation.
+
+       The global variable pcre_callout initially contains NULL. It can be set
+       by  the  caller  to  a "callout" function, which PCRE will then call at
+       specified points during a matching operation. Details are given in  the
+       pcrecallout documentation.
+
+
+NEWLINES
+
+       PCRE  supports five different conventions for indicating line breaks in
+       strings: a single CR (carriage return) character, a  single  LF  (line-
+       feed) character, the two-character sequence CRLF, any of the three pre-
+       ceding, or any Unicode newline sequence. The Unicode newline  sequences
+       are  the  three just mentioned, plus the single characters VT (vertical
+       tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS  (line
+       separator, U+2028), and PS (paragraph separator, U+2029).
+
+       Each  of  the first three conventions is used by at least one operating
+       system as its standard newline sequence. When PCRE is built, a  default
+       can  be  specified.  The default default is LF, which is the Unix stan-
+       dard. When PCRE is run, the default can be overridden,  either  when  a
+       pattern is compiled, or when it is matched.
+
+       At compile time, the newline convention can be specified by the options
+       argument of pcre_compile(), or it can be specified by special  text  at
+       the start of the pattern itself; this overrides any other settings. See
+       the pcrepattern page for details of the special character sequences.
+
+       In the PCRE documentation the word "newline" is used to mean "the char-
+       acter  or pair of characters that indicate a line break". The choice of
+       newline convention affects the handling of  the  dot,  circumflex,  and
+       dollar metacharacters, the handling of #-comments in /x mode, and, when
+       CRLF is a recognized line ending sequence, the match position  advance-
+       ment for a non-anchored pattern. There is more detail about this in the
+       section on pcre_exec() options below.
+
+       The choice of newline convention does not affect the interpretation  of
+       the  \n  or  \r  escape  sequences, nor does it affect what \R matches,
+       which is controlled in a similar way, but by separate options.
+
+
+MULTITHREADING
+
+       The PCRE functions can be used in  multi-threading  applications,  with
+       the  proviso  that  the  memory  management  functions  pointed  to  by
+       pcre_malloc, pcre_free, pcre_stack_malloc, and pcre_stack_free, and the
+       callout function pointed to by pcre_callout, are shared by all threads.
+
+       The compiled form of a regular expression is not altered during  match-
+       ing, so the same compiled pattern can safely be used by several threads
+       at once.
+
+
+SAVING PRECOMPILED PATTERNS FOR LATER USE
+
+       The compiled form of a regular expression can be saved and re-used at a
+       later  time,  possibly by a different program, and even on a host other
+       than the one on which  it  was  compiled.  Details  are  given  in  the
+       pcreprecompile  documentation.  However, compiling a regular expression
+       with one version of PCRE for use with a different version is not  guar-
+       anteed to work and may cause crashes.
+
+
+CHECKING BUILD-TIME OPTIONS
+
+       int pcre_config(int what, void *where);
+
+       The  function pcre_config() makes it possible for a PCRE client to dis-
+       cover which optional features have been compiled into the PCRE library.
+       The  pcrebuild documentation has more details about these optional fea-
+       tures.
+
+       The first argument for pcre_config() is an  integer,  specifying  which
+       information is required; the second argument is a pointer to a variable
+       into which the information is  placed.  The  following  information  is
+       available:
+
+         PCRE_CONFIG_UTF8
+
+       The  output is an integer that is set to one if UTF-8 support is avail-
+       able; otherwise it is set to zero.
+
+         PCRE_CONFIG_UNICODE_PROPERTIES
+
+       The output is an integer that is set to  one  if  support  for  Unicode
+       character properties is available; otherwise it is set to zero.
+
+         PCRE_CONFIG_NEWLINE
+
+       The  output  is  an integer whose value specifies the default character
+       sequence that is recognized as meaning "newline". The four values  that
+       are supported are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF,
+       and -1 for ANY. The default should normally be  the  standard  sequence
+       for your operating system.
+
+         PCRE_CONFIG_BSR
+
+       The output is an integer whose value indicates what character sequences
+       the \R escape sequence matches by default. A value of 0 means  that  \R
+       matches  any  Unicode  line ending sequence; a value of 1 means that \R
+       matches only CR, LF, or CRLF. The default can be overridden when a pat-
+       tern is compiled or matched.
+
+         PCRE_CONFIG_LINK_SIZE
+
+       The  output  is  an  integer that contains the number of bytes used for
+       internal linkage in compiled regular expressions. The value is 2, 3, or
+       4.  Larger  values  allow larger regular expressions to be compiled, at
+       the expense of slower matching. The default value of  2  is  sufficient
+       for  all  but  the  most massive patterns, since it allows the compiled
+       pattern to be up to 64K in size.
+
+         PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+
+       The output is an integer that contains the threshold  above  which  the
+       POSIX  interface  uses malloc() for output vectors. Further details are
+       given in the pcreposix documentation.
+
+         PCRE_CONFIG_MATCH_LIMIT
+
+       The output is an integer that gives the default limit for the number of
+       internal  matching  function  calls in a pcre_exec() execution. Further
+       details are given with pcre_exec() below.
+
+         PCRE_CONFIG_MATCH_LIMIT_RECURSION
+
+       The output is an integer that gives the default limit for the depth  of
+       recursion  when calling the internal matching function in a pcre_exec()
+       execution. Further details are given with pcre_exec() below.
+
+         PCRE_CONFIG_STACKRECURSE
+
+       The output is an integer that is set to one if internal recursion  when
+       running pcre_exec() is implemented by recursive function calls that use
+       the stack to remember their state. This is the usual way that  PCRE  is
+       compiled. The output is zero if PCRE was compiled to use blocks of data
+       on the  heap  instead  of  recursive  function  calls.  In  this  case,
+       pcre_stack_malloc  and  pcre_stack_free  are  called  to  manage memory
+       blocks on the heap, thus avoiding the use of the stack.
+
+
+COMPILING A PATTERN
+
+       pcre *pcre_compile(const char *pattern, int options,
+            const char **errptr, int *erroffset,
+            const unsigned char *tableptr);
+
+       pcre *pcre_compile2(const char *pattern, int options,
+            int *errorcodeptr,
+            const char **errptr, int *erroffset,
+            const unsigned char *tableptr);
+
+       Either of the functions pcre_compile() or pcre_compile2() can be called
+       to compile a pattern into an internal form. The only difference between
+       the two interfaces is that pcre_compile2() has an additional  argument,
+       errorcodeptr, via which a numerical error code can be returned.
+
+       The pattern is a C string terminated by a binary zero, and is passed in
+       the pattern argument. A pointer to a single block  of  memory  that  is
+       obtained  via  pcre_malloc is returned. This contains the compiled code
+       and related data. The pcre type is defined for the returned block; this
+       is a typedef for a structure whose contents are not externally defined.
+       It is up to the caller to free the memory (via pcre_free) when it is no
+       longer required.
+
+       Although  the compiled code of a PCRE regex is relocatable, that is, it
+       does not depend on memory location, the complete pcre data block is not
+       fully  relocatable, because it may contain a copy of the tableptr argu-
+       ment, which is an address (see below).
+
+       The options argument contains various bit settings that affect the com-
+       pilation.  It  should be zero if no options are required. The available
+       options are described below. Some of them, in  particular,  those  that
+       are  compatible  with  Perl,  can also be set and unset from within the
+       pattern (see the detailed description  in  the  pcrepattern  documenta-
+       tion).  For  these options, the contents of the options argument speci-
+       fies their initial settings at the start of compilation and  execution.
+       The  PCRE_ANCHORED  and PCRE_NEWLINE_xxx options can be set at the time
+       of matching as well as at compile time.
+
+       If errptr is NULL, pcre_compile() returns NULL immediately.  Otherwise,
+       if  compilation  of  a  pattern fails, pcre_compile() returns NULL, and
+       sets the variable pointed to by errptr to point to a textual error mes-
+       sage. This is a static string that is part of the library. You must not
+       try to free it. The offset from the start of the pattern to the charac-
+       ter where the error was discovered is placed in the variable pointed to
+       by erroffset, which must not be NULL. If it is, an immediate  error  is
+       given.
+
+       If  pcre_compile2()  is  used instead of pcre_compile(), and the error-
+       codeptr argument is not NULL, a non-zero error code number is  returned
+       via  this argument in the event of an error. This is in addition to the
+       textual error message. Error codes and messages are listed below.
+
+       If the final argument, tableptr, is NULL, PCRE uses a  default  set  of
+       character  tables  that  are  built  when  PCRE  is compiled, using the
+       default C locale. Otherwise, tableptr must be an address  that  is  the
+       result  of  a  call to pcre_maketables(). This value is stored with the
+       compiled pattern, and used again by pcre_exec(), unless  another  table
+       pointer is passed to it. For more discussion, see the section on locale
+       support below.
+
+       This code fragment shows a typical straightforward  call  to  pcre_com-
+       pile():
+
+         pcre *re;
+         const char *error;
+         int erroffset;
+         re = pcre_compile(
+           "^A.*Z",          /* the pattern */
+           0,                /* default options */
+           &error,           /* for error message */
+           &erroffset,       /* for error offset */
+           NULL);            /* use default character tables */
+
+       The  following  names  for option bits are defined in the pcre.h header
+       file:
+
+         PCRE_ANCHORED
+
+       If this bit is set, the pattern is forced to be "anchored", that is, it
+       is  constrained to match only at the first matching point in the string
+       that is being searched (the "subject string"). This effect can also  be
+       achieved  by appropriate constructs in the pattern itself, which is the
+       only way to do it in Perl.
+
+         PCRE_AUTO_CALLOUT
+
+       If this bit is set, pcre_compile() automatically inserts callout items,
+       all  with  number  255, before each pattern item. For discussion of the
+       callout facility, see the pcrecallout documentation.
+
+         PCRE_BSR_ANYCRLF
+         PCRE_BSR_UNICODE
+
+       These options (which are mutually exclusive) control what the \R escape
+       sequence  matches.  The choice is either to match only CR, LF, or CRLF,
+       or to match any Unicode newline sequence. The default is specified when
+       PCRE is built. It can be overridden from within the pattern, or by set-
+       ting an option when a compiled pattern is matched.
+
+         PCRE_CASELESS
+
+       If this bit is set, letters in the pattern match both upper  and  lower
+       case  letters.  It  is  equivalent  to  Perl's /i option, and it can be
+       changed within a pattern by a (?i) option setting. In UTF-8 mode,  PCRE
+       always  understands the concept of case for characters whose values are
+       less than 128, so caseless matching is always possible. For  characters
+       with  higher  values,  the concept of case is supported if PCRE is com-
+       piled with Unicode property support, but not otherwise. If you want  to
+       use  caseless  matching  for  characters 128 and above, you must ensure
+       that PCRE is compiled with Unicode property support  as  well  as  with
+       UTF-8 support.
+
+         PCRE_DOLLAR_ENDONLY
+
+       If  this bit is set, a dollar metacharacter in the pattern matches only
+       at the end of the subject string. Without this option,  a  dollar  also
+       matches  immediately before a newline at the end of the string (but not
+       before any other newlines). The PCRE_DOLLAR_ENDONLY option  is  ignored
+       if  PCRE_MULTILINE  is  set.   There is no equivalent to this option in
+       Perl, and no way to set it within a pattern.
+
+         PCRE_DOTALL
+
+       If this bit is set, a dot metacharater in the pattern matches all char-
+       acters,  including  those that indicate newline. Without it, a dot does
+       not match when the current position is at a  newline.  This  option  is
+       equivalent  to Perl's /s option, and it can be changed within a pattern
+       by a (?s) option setting. A negative class such as [^a] always  matches
+       newline characters, independent of the setting of this option.
+
+         PCRE_DUPNAMES
+
+       If  this  bit is set, names used to identify capturing subpatterns need
+       not be unique. This can be helpful for certain types of pattern when it
+       is  known  that  only  one instance of the named subpattern can ever be
+       matched. There are more details of named subpatterns  below;  see  also
+       the pcrepattern documentation.
+
+         PCRE_EXTENDED
+
+       If  this  bit  is  set,  whitespace  data characters in the pattern are
+       totally ignored except when escaped or inside a character class. White-
+       space does not include the VT character (code 11). In addition, charac-
+       ters between an unescaped # outside a character class and the next new-
+       line,  inclusive,  are  also  ignored.  This is equivalent to Perl's /x
+       option, and it can be changed within a pattern by a  (?x)  option  set-
+       ting.
+
+       This  option  makes  it possible to include comments inside complicated
+       patterns.  Note, however, that this applies only  to  data  characters.
+       Whitespace   characters  may  never  appear  within  special  character
+       sequences in a pattern, for  example  within  the  sequence  (?(  which
+       introduces a conditional subpattern.
+
+         PCRE_EXTRA
+
+       This  option  was invented in order to turn on additional functionality
+       of PCRE that is incompatible with Perl, but it  is  currently  of  very
+       little  use. When set, any backslash in a pattern that is followed by a
+       letter that has no special meaning  causes  an  error,  thus  reserving
+       these  combinations  for  future  expansion.  By default, as in Perl, a
+       backslash followed by a letter with no special meaning is treated as  a
+       literal.  (Perl can, however, be persuaded to give a warning for this.)
+       There are at present no other features controlled by  this  option.  It
+       can also be set by a (?X) option setting within a pattern.
+
+         PCRE_FIRSTLINE
+
+       If  this  option  is  set,  an  unanchored pattern is required to match
+       before or at the first  newline  in  the  subject  string,  though  the
+       matched text may continue over the newline.
+
+         PCRE_JAVASCRIPT_COMPAT
+
+       If this option is set, PCRE's behaviour is changed in some ways so that
+       it is compatible with JavaScript rather than Perl. The changes  are  as
+       follows:
+
+       (1)  A  lone  closing square bracket in a pattern causes a compile-time
+       error, because this is illegal in JavaScript (by default it is  treated
+       as a data character). Thus, the pattern AB]CD becomes illegal when this
+       option is set.
+
+       (2) At run time, a back reference to an unset subpattern group  matches
+       an  empty  string (by default this causes the current matching alterna-
+       tive to fail). A pattern such as (\1)(a) succeeds when this  option  is
+       set  (assuming  it can find an "a" in the subject), whereas it fails by
+       default, for Perl compatibility.
+
+         PCRE_MULTILINE
+
+       By default, PCRE treats the subject string as consisting  of  a  single
+       line  of characters (even if it actually contains newlines). The "start
+       of line" metacharacter (^) matches only at the  start  of  the  string,
+       while  the  "end  of line" metacharacter ($) matches only at the end of
+       the string, or before a terminating newline (unless PCRE_DOLLAR_ENDONLY
+       is set). This is the same as Perl.
+
+       When  PCRE_MULTILINE  it  is set, the "start of line" and "end of line"
+       constructs match immediately following or immediately  before  internal
+       newlines  in  the  subject string, respectively, as well as at the very
+       start and end. This is equivalent to Perl's /m option, and  it  can  be
+       changed within a pattern by a (?m) option setting. If there are no new-
+       lines in a subject string, or no occurrences of ^ or $  in  a  pattern,
+       setting PCRE_MULTILINE has no effect.
+
+         PCRE_NEWLINE_CR
+         PCRE_NEWLINE_LF
+         PCRE_NEWLINE_CRLF
+         PCRE_NEWLINE_ANYCRLF
+         PCRE_NEWLINE_ANY
+
+       These  options  override the default newline definition that was chosen
+       when PCRE was built. Setting the first or the second specifies  that  a
+       newline  is  indicated  by a single character (CR or LF, respectively).
+       Setting PCRE_NEWLINE_CRLF specifies that a newline is indicated by  the
+       two-character  CRLF  sequence.  Setting  PCRE_NEWLINE_ANYCRLF specifies
+       that any of the three preceding sequences should be recognized. Setting
+       PCRE_NEWLINE_ANY  specifies that any Unicode newline sequence should be
+       recognized. The Unicode newline sequences are the three just mentioned,
+       plus  the  single  characters  VT (vertical tab, U+000B), FF (formfeed,
+       U+000C), NEL (next line, U+0085), LS (line separator, U+2028),  and  PS
+       (paragraph  separator,  U+2029).  The  last  two are recognized only in
+       UTF-8 mode.
+
+       The newline setting in the  options  word  uses  three  bits  that  are
+       treated as a number, giving eight possibilities. Currently only six are
+       used (default plus the five values above). This means that if  you  set
+       more  than one newline option, the combination may or may not be sensi-
+       ble. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to
+       PCRE_NEWLINE_CRLF,  but other combinations may yield unused numbers and
+       cause an error.
+
+       The only time that a line break is specially recognized when  compiling
+       a  pattern  is  if  PCRE_EXTENDED  is set, and an unescaped # outside a
+       character class is encountered. This indicates  a  comment  that  lasts
+       until  after the next line break sequence. In other circumstances, line
+       break  sequences  are  treated  as  literal  data,   except   that   in
+       PCRE_EXTENDED mode, both CR and LF are treated as whitespace characters
+       and are therefore ignored.
+
+       The newline option that is set at compile time becomes the default that
+       is  used for pcre_exec() and pcre_dfa_exec(), but it can be overridden.
+
+         PCRE_NO_AUTO_CAPTURE
+
+       If this option is set, it disables the use of numbered capturing paren-
+       theses  in the pattern. Any opening parenthesis that is not followed by
+       ? behaves as if it were followed by ?: but named parentheses can  still
+       be  used  for  capturing  (and  they acquire numbers in the usual way).
+       There is no equivalent of this option in Perl.
+
+         PCRE_UNGREEDY
+
+       This option inverts the "greediness" of the quantifiers  so  that  they
+       are  not greedy by default, but become greedy if followed by "?". It is
+       not compatible with Perl. It can also be set by a (?U)  option  setting
+       within the pattern.
+
+         PCRE_UTF8
+
+       This  option  causes PCRE to regard both the pattern and the subject as
+       strings of UTF-8 characters instead of single-byte  character  strings.
+       However,  it is available only when PCRE is built to include UTF-8 sup-
+       port. If not, the use of this option provokes an error. Details of  how
+       this  option  changes the behaviour of PCRE are given in the section on
+       UTF-8 support in the main pcre page.
+
+         PCRE_NO_UTF8_CHECK
+
+       When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
+       automatically  checked.  There  is  a  discussion about the validity of
+       UTF-8 strings in the main pcre page. If an invalid  UTF-8  sequence  of
+       bytes  is  found,  pcre_compile() returns an error. If you already know
+       that your pattern is valid, and you want to skip this check for perfor-
+       mance  reasons,  you  can set the PCRE_NO_UTF8_CHECK option. When it is
+       set, the effect of passing an invalid UTF-8  string  as  a  pattern  is
+       undefined.  It  may  cause your program to crash. Note that this option
+       can also be passed to pcre_exec() and pcre_dfa_exec(), to suppress  the
+       UTF-8 validity checking of subject strings.
+
+
+COMPILATION ERROR CODES
+
+       The  following  table  lists  the  error  codes than may be returned by
+       pcre_compile2(), along with the error messages that may be returned  by
+       both  compiling functions. As PCRE has developed, some error codes have
+       fallen out of use. To avoid confusion, they have not been re-used.
+
+          0  no error
+          1  \ at end of pattern
+          2  \c at end of pattern
+          3  unrecognized character follows \
+          4  numbers out of order in {} quantifier
+          5  number too big in {} quantifier
+          6  missing terminating ] for character class
+          7  invalid escape sequence in character class
+          8  range out of order in character class
+          9  nothing to repeat
+         10  [this code is not in use]
+         11  internal error: unexpected repeat
+         12  unrecognized character after (? or (?-
+         13  POSIX named classes are supported only within a class
+         14  missing )
+         15  reference to non-existent subpattern
+         16  erroffset passed as NULL
+         17  unknown option bit(s) set
+         18  missing ) after comment
+         19  [this code is not in use]
+         20  regular expression is too large
+         21  failed to get memory
+         22  unmatched parentheses
+         23  internal error: code overflow
+         24  unrecognized character after (?<
+         25  lookbehind assertion is not fixed length
+         26  malformed number or name after (?(
+         27  conditional group contains more than two branches
+         28  assertion expected after (?(
+         29  (?R or (?[+-]digits must be followed by )
+         30  unknown POSIX class name
+         31  POSIX collating elements are not supported
+         32  this version of PCRE is not compiled with PCRE_UTF8 support
+         33  [this code is not in use]
+         34  character value in \x{...} sequence is too large
+         35  invalid condition (?(0)
+         36  \C not allowed in lookbehind assertion
+         37  PCRE does not support \L, \l, \N, \U, or \u
+         38  number after (?C is > 255
+         39  closing ) for (?C expected
+         40  recursive call could loop indefinitely
+         41  unrecognized character after (?P
+         42  syntax error in subpattern name (missing terminator)
+         43  two named subpatterns have the same name
+         44  invalid UTF-8 string
+         45  support for \P, \p, and \X has not been compiled
+         46  malformed \P or \p sequence
+         47  unknown property name after \P or \p
+         48  subpattern name is too long (maximum 32 characters)
+         49  too many named subpatterns (maximum 10000)
+         50  [this code is not in use]
+         51  octal value is greater than \377 (not in UTF-8 mode)
+         52  internal error: overran compiling workspace
+         53  internal  error:  previously-checked  referenced  subpattern  not
+       found
+         54  DEFINE group contains more than one branch
+         55  repeating a DEFINE group is not allowed
+         56  inconsistent NEWLINE options
+         57  \g is not followed by a braced, angle-bracketed, or quoted
+               name/number or by a plain number
+         58  a numbered reference must not be zero
+         59  (*VERB) with an argument is not supported
+         60  (*VERB) not recognized
+         61  number is too big
+         62  subpattern name expected
+         63  digit expected after (?+
+         64  ] is an invalid data character in JavaScript compatibility mode
+
+       The  numbers  32  and 10000 in errors 48 and 49 are defaults; different
+       values may be used if the limits were changed when PCRE was built.
+
+
+STUDYING A PATTERN
+
+       pcre_extra *pcre_study(const pcre *code, int options
+            const char **errptr);
+
+       If a compiled pattern is going to be used several times,  it  is  worth
+       spending more time analyzing it in order to speed up the time taken for
+       matching. The function pcre_study() takes a pointer to a compiled  pat-
+       tern as its first argument. If studying the pattern produces additional
+       information that will help speed up matching,  pcre_study()  returns  a
+       pointer  to a pcre_extra block, in which the study_data field points to
+       the results of the study.
+
+       The  returned  value  from  pcre_study()  can  be  passed  directly  to
+       pcre_exec().  However,  a  pcre_extra  block also contains other fields
+       that can be set by the caller before the block  is  passed;  these  are
+       described below in the section on matching a pattern.
+
+       If  studying  the  pattern  does not produce any additional information
+       pcre_study() returns NULL. In that circumstance, if the calling program
+       wants  to  pass  any of the other fields to pcre_exec(), it must set up
+       its own pcre_extra block.
+
+       The second argument of pcre_study() contains option bits.  At  present,
+       no options are defined, and this argument should always be zero.
+
+       The  third argument for pcre_study() is a pointer for an error message.
+       If studying succeeds (even if no data is  returned),  the  variable  it
+       points  to  is  set  to NULL. Otherwise it is set to point to a textual
+       error message. This is a static string that is part of the library. You
+       must  not  try  to  free it. You should test the error pointer for NULL
+       after calling pcre_study(), to be sure that it has run successfully.
+
+       This is a typical call to pcre_study():
+
+         pcre_extra *pe;
+         pe = pcre_study(
+           re,             /* result of pcre_compile() */
+           0,              /* no options exist */
+           &error);        /* set to NULL or points to a message */
+
+       At present, studying a pattern is useful only for non-anchored patterns
+       that  do not have a single fixed starting character. A bitmap of possi-
+       ble starting bytes is created.
+
+
+LOCALE SUPPORT
+
+       PCRE handles caseless matching, and determines whether  characters  are
+       letters,  digits, or whatever, by reference to a set of tables, indexed
+       by character value. When running in UTF-8 mode, this  applies  only  to
+       characters  with  codes  less than 128. Higher-valued codes never match
+       escapes such as \w or \d, but can be tested with \p if  PCRE  is  built
+       with  Unicode  character property support. The use of locales with Uni-
+       code is discouraged. If you are handling characters with codes  greater
+       than  128, you should either use UTF-8 and Unicode, or use locales, but
+       not try to mix the two.
+
+       PCRE contains an internal set of tables that are used  when  the  final
+       argument  of  pcre_compile()  is  NULL.  These  are sufficient for many
+       applications.  Normally, the internal tables recognize only ASCII char-
+       acters. However, when PCRE is built, it is possible to cause the inter-
+       nal tables to be rebuilt in the default "C" locale of the local system,
+       which may cause them to be different.
+
+       The  internal tables can always be overridden by tables supplied by the
+       application that calls PCRE. These may be created in a different locale
+       from  the  default.  As more and more applications change to using Uni-
+       code, the need for this locale support is expected to die away.
+
+       External tables are built by calling  the  pcre_maketables()  function,
+       which  has no arguments, in the relevant locale. The result can then be
+       passed to pcre_compile() or pcre_exec()  as  often  as  necessary.  For
+       example,  to  build  and use tables that are appropriate for the French
+       locale (where accented characters with  values  greater  than  128  are
+       treated as letters), the following code could be used:
+
+         setlocale(LC_CTYPE, "fr_FR");
+         tables = pcre_maketables();
+         re = pcre_compile(..., tables);
+
+       The  locale  name "fr_FR" is used on Linux and other Unix-like systems;
+       if you are using Windows, the name for the French locale is "french".
+
+       When pcre_maketables() runs, the tables are built  in  memory  that  is
+       obtained  via  pcre_malloc. It is the caller's responsibility to ensure
+       that the memory containing the tables remains available for as long  as
+       it is needed.
+
+       The pointer that is passed to pcre_compile() is saved with the compiled
+       pattern, and the same tables are used via this pointer by  pcre_study()
+       and normally also by pcre_exec(). Thus, by default, for any single pat-
+       tern, compilation, studying and matching all happen in the same locale,
+       but different patterns can be compiled in different locales.
+
+       It  is  possible to pass a table pointer or NULL (indicating the use of
+       the internal tables) to pcre_exec(). Although  not  intended  for  this
+       purpose,  this facility could be used to match a pattern in a different
+       locale from the one in which it was compiled. Passing table pointers at
+       run time is discussed below in the section on matching a pattern.
+
+
+INFORMATION ABOUT A PATTERN
+
+       int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
+            int what, void *where);
+
+       The  pcre_fullinfo() function returns information about a compiled pat-
+       tern. It replaces the obsolete pcre_info() function, which is neverthe-
+       less retained for backwards compability (and is documented below).
+
+       The  first  argument  for  pcre_fullinfo() is a pointer to the compiled
+       pattern. The second argument is the result of pcre_study(), or NULL  if
+       the  pattern  was not studied. The third argument specifies which piece
+       of information is required, and the fourth argument is a pointer  to  a
+       variable  to  receive  the  data. The yield of the function is zero for
+       success, or one of the following negative numbers:
+
+         PCRE_ERROR_NULL       the argument code was NULL
+                               the argument where was NULL
+         PCRE_ERROR_BADMAGIC   the "magic number" was not found
+         PCRE_ERROR_BADOPTION  the value of what was invalid
+
+       The "magic number" is placed at the start of each compiled  pattern  as
+       an  simple check against passing an arbitrary memory pointer. Here is a
+       typical call of pcre_fullinfo(), to obtain the length of  the  compiled
+       pattern:
+
+         int rc;
+         size_t length;
+         rc = pcre_fullinfo(
+           re,               /* result of pcre_compile() */
+           pe,               /* result of pcre_study(), or NULL */
+           PCRE_INFO_SIZE,   /* what is required */
+           &length);         /* where to put the data */
+
+       The  possible  values for the third argument are defined in pcre.h, and
+       are as follows:
+
+         PCRE_INFO_BACKREFMAX
+
+       Return the number of the highest back reference  in  the  pattern.  The
+       fourth  argument  should  point to an int variable. Zero is returned if
+       there are no back references.
+
+         PCRE_INFO_CAPTURECOUNT
+
+       Return the number of capturing subpatterns in the pattern.  The  fourth
+       argument should point to an int variable.
+
+         PCRE_INFO_DEFAULT_TABLES
+
+       Return  a pointer to the internal default character tables within PCRE.
+       The fourth argument should point to an unsigned char *  variable.  This
+       information call is provided for internal use by the pcre_study() func-
+       tion. External callers can cause PCRE to use  its  internal  tables  by
+       passing a NULL table pointer.
+
+         PCRE_INFO_FIRSTBYTE
+
+       Return  information  about  the first byte of any matched string, for a
+       non-anchored pattern. The fourth argument should point to an int  vari-
+       able.  (This option used to be called PCRE_INFO_FIRSTCHAR; the old name
+       is still recognized for backwards compatibility.)
+
+       If there is a fixed first byte, for example, from  a  pattern  such  as
+       (cat|cow|coyote), its value is returned. Otherwise, if either
+
+       (a)  the pattern was compiled with the PCRE_MULTILINE option, and every
+       branch starts with "^", or
+
+       (b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not
+       set (if it were set, the pattern would be anchored),
+
+       -1  is  returned, indicating that the pattern matches only at the start
+       of a subject string or after any newline within the  string.  Otherwise
+       -2 is returned. For anchored patterns, -2 is returned.
+
+         PCRE_INFO_FIRSTTABLE
+
+       If  the pattern was studied, and this resulted in the construction of a
+       256-bit table indicating a fixed set of bytes for the first byte in any
+       matching  string, a pointer to the table is returned. Otherwise NULL is
+       returned. The fourth argument should point to an unsigned char *  vari-
+       able.
+
+         PCRE_INFO_HASCRORLF
+
+       Return  1  if  the  pattern  contains any explicit matches for CR or LF
+       characters, otherwise 0. The fourth argument should  point  to  an  int
+       variable.  An explicit match is either a literal CR or LF character, or
+       \r or \n.
+
+         PCRE_INFO_JCHANGED
+
+       Return 1 if the (?J) or (?-J) option setting is used  in  the  pattern,
+       otherwise  0. The fourth argument should point to an int variable. (?J)
+       and (?-J) set and unset the local PCRE_DUPNAMES option, respectively.
+
+         PCRE_INFO_LASTLITERAL
+
+       Return the value of the rightmost literal byte that must exist  in  any
+       matched  string,  other  than  at  its  start,  if such a byte has been
+       recorded. The fourth argument should point to an int variable. If there
+       is  no such byte, -1 is returned. For anchored patterns, a last literal
+       byte is recorded only if it follows something of variable  length.  For
+       example, for the pattern /^a\d+z\d+/ the returned value is "z", but for
+       /^a\dz\d/ the returned value is -1.
+
+         PCRE_INFO_NAMECOUNT
+         PCRE_INFO_NAMEENTRYSIZE
+         PCRE_INFO_NAMETABLE
+
+       PCRE supports the use of named as well as numbered capturing  parenthe-
+       ses.  The names are just an additional way of identifying the parenthe-
+       ses, which still acquire numbers. Several convenience functions such as
+       pcre_get_named_substring()  are  provided  for extracting captured sub-
+       strings by name. It is also possible to extract the data  directly,  by
+       first  converting  the  name to a number in order to access the correct
+       pointers in the output vector (described with pcre_exec() below). To do
+       the  conversion,  you  need  to  use  the  name-to-number map, which is
+       described by these three values.
+
+       The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT
+       gives the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size
+       of each entry; both of these  return  an  int  value.  The  entry  size
+       depends  on the length of the longest name. PCRE_INFO_NAMETABLE returns
+       a pointer to the first entry of the table  (a  pointer  to  char).  The
+       first two bytes of each entry are the number of the capturing parenthe-
+       sis, most significant byte first. The rest of the entry is  the  corre-
+       sponding  name,  zero  terminated. The names are in alphabetical order.
+       When PCRE_DUPNAMES is set, duplicate names are in order of their paren-
+       theses  numbers.  For  example,  consider the following pattern (assume
+       PCRE_EXTENDED is  set,  so  white  space  -  including  newlines  -  is
+       ignored):
+
+         (?<date> (?<year>(\d\d)?\d\d) -
+         (?<month>\d\d) - (?<day>\d\d) )
+
+       There  are  four  named subpatterns, so the table has four entries, and
+       each entry in the table is eight bytes long. The table is  as  follows,
+       with non-printing bytes shows in hexadecimal, and undefined bytes shown
+       as ??:
+
+         00 01 d  a  t  e  00 ??
+         00 05 d  a  y  00 ?? ??
+         00 04 m  o  n  t  h  00
+         00 02 y  e  a  r  00 ??
+
+       When writing code to extract data  from  named  subpatterns  using  the
+       name-to-number  map,  remember that the length of the entries is likely
+       to be different for each compiled pattern.
+
+         PCRE_INFO_OKPARTIAL
+
+       Return 1 if the pattern can be used for partial matching, otherwise  0.
+       The  fourth  argument  should point to an int variable. The pcrepartial
+       documentation lists the restrictions that apply to patterns  when  par-
+       tial matching is used.
+
+         PCRE_INFO_OPTIONS
+
+       Return  a  copy of the options with which the pattern was compiled. The
+       fourth argument should point to an unsigned long  int  variable.  These
+       option bits are those specified in the call to pcre_compile(), modified
+       by any top-level option settings at the start of the pattern itself. In
+       other  words,  they are the options that will be in force when matching
+       starts. For example, if the pattern /(?im)abc(?-i)d/ is  compiled  with
+       the  PCRE_EXTENDED option, the result is PCRE_CASELESS, PCRE_MULTILINE,
+       and PCRE_EXTENDED.
+
+       A pattern is automatically anchored by PCRE if  all  of  its  top-level
+       alternatives begin with one of the following:
+
+         ^     unless PCRE_MULTILINE is set
+         \A    always
+         \G    always
+         .*    if PCRE_DOTALL is set and there are no back
+                 references to the subpattern in which .* appears
+
+       For such patterns, the PCRE_ANCHORED bit is set in the options returned
+       by pcre_fullinfo().
+
+         PCRE_INFO_SIZE
+
+       Return the size of the compiled pattern, that is, the  value  that  was
+       passed as the argument to pcre_malloc() when PCRE was getting memory in
+       which to place the compiled data. The fourth argument should point to a
+       size_t variable.
+
+         PCRE_INFO_STUDYSIZE
+
+       Return the size of the data block pointed to by the study_data field in
+       a pcre_extra block. That is,  it  is  the  value  that  was  passed  to
+       pcre_malloc() when PCRE was getting memory into which to place the data
+       created by pcre_study(). The fourth argument should point to  a  size_t
+       variable.
+
+
+OBSOLETE INFO FUNCTION
+
+       int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
+
+       The  pcre_info()  function is now obsolete because its interface is too
+       restrictive to return all the available data about a compiled  pattern.
+       New   programs   should  use  pcre_fullinfo()  instead.  The  yield  of
+       pcre_info() is the number of capturing subpatterns, or one of the  fol-
+       lowing negative numbers:
+
+         PCRE_ERROR_NULL       the argument code was NULL
+         PCRE_ERROR_BADMAGIC   the "magic number" was not found
+
+       If  the  optptr  argument is not NULL, a copy of the options with which
+       the pattern was compiled is placed in the integer  it  points  to  (see
+       PCRE_INFO_OPTIONS above).
+
+       If  the  pattern  is  not anchored and the firstcharptr argument is not
+       NULL, it is used to pass back information about the first character  of
+       any matched string (see PCRE_INFO_FIRSTBYTE above).
+
+
+REFERENCE COUNTS
+
+       int pcre_refcount(pcre *code, int adjust);
+
+       The  pcre_refcount()  function is used to maintain a reference count in
+       the data block that contains a compiled pattern. It is provided for the
+       benefit  of  applications  that  operate  in an object-oriented manner,
+       where different parts of the application may be using the same compiled
+       pattern, but you want to free the block when they are all done.
+
+       When a pattern is compiled, the reference count field is initialized to
+       zero.  It is changed only by calling this function, whose action is  to
+       add  the  adjust  value  (which may be positive or negative) to it. The
+       yield of the function is the new value. However, the value of the count
+       is  constrained to lie between 0 and 65535, inclusive. If the new value
+       is outside these limits, it is forced to the appropriate limit value.
+
+       Except when it is zero, the reference count is not correctly  preserved
+       if  a  pattern  is  compiled on one host and then transferred to a host
+       whose byte-order is different. (This seems a highly unlikely scenario.)
+
+
+MATCHING A PATTERN: THE TRADITIONAL FUNCTION
+
+       int pcre_exec(const pcre *code, const pcre_extra *extra,
+            const char *subject, int length, int startoffset,
+            int options, int *ovector, int ovecsize);
+
+       The  function pcre_exec() is called to match a subject string against a
+       compiled pattern, which is passed in the code argument. If the  pattern
+       has been studied, the result of the study should be passed in the extra
+       argument. This function is the main matching facility of  the  library,
+       and it operates in a Perl-like manner. For specialist use there is also
+       an alternative matching function, which is described below in the  sec-
+       tion about the pcre_dfa_exec() function.
+
+       In  most applications, the pattern will have been compiled (and option-
+       ally studied) in the same process that calls pcre_exec().  However,  it
+       is possible to save compiled patterns and study data, and then use them
+       later in different processes, possibly even on different hosts.  For  a
+       discussion about this, see the pcreprecompile documentation.
+
+       Here is an example of a simple call to pcre_exec():
+
+         int rc;
+         int ovector[30];
+         rc = pcre_exec(
+           re,             /* result of pcre_compile() */
+           NULL,           /* we didn't study the pattern */
+           "some string",  /* the subject string */
+           11,             /* the length of the subject string */
+           0,              /* start at offset 0 in the subject */
+           0,              /* default options */
+           ovector,        /* vector of integers for substring information */
+           30);            /* number of elements (NOT size in bytes) */
+
+   Extra data for pcre_exec()
+
+       If  the  extra argument is not NULL, it must point to a pcre_extra data
+       block. The pcre_study() function returns such a block (when it  doesn't
+       return  NULL), but you can also create one for yourself, and pass addi-
+       tional information in it. The pcre_extra block contains  the  following
+       fields (not necessarily in this order):
+
+         unsigned long int flags;
+         void *study_data;
+         unsigned long int match_limit;
+         unsigned long int match_limit_recursion;
+         void *callout_data;
+         const unsigned char *tables;
+
+       The  flags  field  is a bitmap that specifies which of the other fields
+       are set. The flag bits are:
+
+         PCRE_EXTRA_STUDY_DATA
+         PCRE_EXTRA_MATCH_LIMIT
+         PCRE_EXTRA_MATCH_LIMIT_RECURSION
+         PCRE_EXTRA_CALLOUT_DATA
+         PCRE_EXTRA_TABLES
+
+       Other flag bits should be set to zero. The study_data field is  set  in
+       the  pcre_extra  block  that is returned by pcre_study(), together with
+       the appropriate flag bit. You should not set this yourself, but you may
+       add  to  the  block by setting the other fields and their corresponding
+       flag bits.
+
+       The match_limit field provides a means of preventing PCRE from using up
+       a  vast amount of resources when running patterns that are not going to
+       match, but which have a very large number  of  possibilities  in  their
+       search  trees.  The  classic  example  is  the  use of nested unlimited
+       repeats.
+
+       Internally, PCRE uses a function called match() which it calls  repeat-
+       edly  (sometimes  recursively). The limit set by match_limit is imposed
+       on the number of times this function is called during  a  match,  which
+       has  the  effect  of  limiting the amount of backtracking that can take
+       place. For patterns that are not anchored, the count restarts from zero
+       for each position in the subject string.
+
+       The  default  value  for  the  limit can be set when PCRE is built; the
+       default default is 10 million, which handles all but the  most  extreme
+       cases.  You  can  override  the  default by suppling pcre_exec() with a
+       pcre_extra    block    in    which    match_limit    is    set,     and
+       PCRE_EXTRA_MATCH_LIMIT  is  set  in  the  flags  field. If the limit is
+       exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
+
+       The match_limit_recursion field is similar to match_limit, but  instead
+       of limiting the total number of times that match() is called, it limits
+       the depth of recursion. The recursion depth is a  smaller  number  than
+       the  total number of calls, because not all calls to match() are recur-
+       sive.  This limit is of use only if it is set smaller than match_limit.
+
+       Limiting  the  recursion  depth  limits the amount of stack that can be
+       used, or, when PCRE has been compiled to use memory on the heap instead
+       of the stack, the amount of heap memory that can be used.
+
+       The  default  value  for  match_limit_recursion can be set when PCRE is
+       built; the default default  is  the  same  value  as  the  default  for
+       match_limit.  You can override the default by suppling pcre_exec() with
+       a  pcre_extra  block  in  which  match_limit_recursion  is   set,   and
+       PCRE_EXTRA_MATCH_LIMIT_RECURSION  is  set  in  the  flags field. If the
+       limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.
+
+       The pcre_callout field is used in conjunction with the  "callout"  fea-
+       ture, which is described in the pcrecallout documentation.
+
+       The  tables  field  is  used  to  pass  a  character  tables pointer to
+       pcre_exec(); this overrides the value that is stored with the  compiled
+       pattern.  A  non-NULL value is stored with the compiled pattern only if
+       custom tables were supplied to pcre_compile() via  its  tableptr  argu-
+       ment.  If NULL is passed to pcre_exec() using this mechanism, it forces
+       PCRE's internal tables to be used. This facility is  helpful  when  re-
+       using  patterns  that  have been saved after compiling with an external
+       set of tables, because the external tables  might  be  at  a  different
+       address  when  pcre_exec() is called. See the pcreprecompile documenta-
+       tion for a discussion of saving compiled patterns for later use.
+
+   Option bits for pcre_exec()
+
+       The unused bits of the options argument for pcre_exec() must  be  zero.
+       The  only  bits  that  may  be set are PCRE_ANCHORED, PCRE_NEWLINE_xxx,
+       PCRE_NOTBOL,   PCRE_NOTEOL,   PCRE_NOTEMPTY,   PCRE_NO_UTF8_CHECK   and
+       PCRE_PARTIAL.
+
+         PCRE_ANCHORED
+
+       The  PCRE_ANCHORED  option  limits pcre_exec() to matching at the first
+       matching position. If a pattern was  compiled  with  PCRE_ANCHORED,  or
+       turned  out to be anchored by virtue of its contents, it cannot be made
+       unachored at matching time.
+
+         PCRE_BSR_ANYCRLF
+         PCRE_BSR_UNICODE
+
+       These options (which are mutually exclusive) control what the \R escape
+       sequence  matches.  The choice is either to match only CR, LF, or CRLF,
+       or to match any Unicode newline sequence. These  options  override  the
+       choice that was made or defaulted when the pattern was compiled.
+
+         PCRE_NEWLINE_CR
+         PCRE_NEWLINE_LF
+         PCRE_NEWLINE_CRLF
+         PCRE_NEWLINE_ANYCRLF
+         PCRE_NEWLINE_ANY
+
+       These  options  override  the  newline  definition  that  was chosen or
+       defaulted when the pattern was compiled. For details, see the  descrip-
+       tion  of  pcre_compile()  above.  During  matching,  the newline choice
+       affects the behaviour of the dot, circumflex,  and  dollar  metacharac-
+       ters.  It may also alter the way the match position is advanced after a
+       match failure for an unanchored pattern.
+
+       When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF,  or  PCRE_NEWLINE_ANY  is
+       set,  and a match attempt for an unanchored pattern fails when the cur-
+       rent position is at a  CRLF  sequence,  and  the  pattern  contains  no
+       explicit  matches  for  CR  or  LF  characters,  the  match position is
+       advanced by two characters instead of one, in other words, to after the
+       CRLF.
+
+       The above rule is a compromise that makes the most common cases work as
+       expected. For example, if the  pattern  is  .+A  (and  the  PCRE_DOTALL
+       option is not set), it does not match the string "\r\nA" because, after
+       failing at the start, it skips both the CR and the LF before  retrying.
+       However,  the  pattern  [\r\n]A does match that string, because it con-
+       tains an explicit CR or LF reference, and so advances only by one char-
+       acter after the first failure.
+
+       An explicit match for CR of LF is either a literal appearance of one of
+       those characters, or one of the \r or  \n  escape  sequences.  Implicit
+       matches  such  as [^X] do not count, nor does \s (which includes CR and
+       LF in the characters that it matches).
+
+       Notwithstanding the above, anomalous effects may still occur when  CRLF
+       is a valid newline sequence and explicit \r or \n escapes appear in the
+       pattern.
+
+         PCRE_NOTBOL
+
+       This option specifies that first character of the subject string is not
+       the  beginning  of  a  line, so the circumflex metacharacter should not
+       match before it. Setting this without PCRE_MULTILINE (at compile  time)
+       causes  circumflex  never to match. This option affects only the behav-
+       iour of the circumflex metacharacter. It does not affect \A.
+
+         PCRE_NOTEOL
+
+       This option specifies that the end of the subject string is not the end
+       of  a line, so the dollar metacharacter should not match it nor (except
+       in multiline mode) a newline immediately before it. Setting this  with-
+       out PCRE_MULTILINE (at compile time) causes dollar never to match. This
+       option affects only the behaviour of the dollar metacharacter. It  does
+       not affect \Z or \z.
+
+         PCRE_NOTEMPTY
+
+       An empty string is not considered to be a valid match if this option is
+       set. If there are alternatives in the pattern, they are tried.  If  all
+       the  alternatives  match  the empty string, the entire match fails. For
+       example, if the pattern
+
+         a?b?
+
+       is applied to a string not beginning with "a" or "b",  it  matches  the
+       empty  string at the start of the subject. With PCRE_NOTEMPTY set, this
+       match is not valid, so PCRE searches further into the string for occur-
+       rences of "a" or "b".
+
+       Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a spe-
+       cial case of a pattern match of the empty  string  within  its  split()
+       function,  and  when  using  the /g modifier. It is possible to emulate
+       Perl's behaviour after matching a null string by first trying the match
+       again at the same offset with PCRE_NOTEMPTY and PCRE_ANCHORED, and then
+       if that fails by advancing the starting offset (see below)  and  trying
+       an ordinary match again. There is some code that demonstrates how to do
+       this in the pcredemo.c sample program.
+
+         PCRE_NO_UTF8_CHECK
+
+       When PCRE_UTF8 is set at compile time, the validity of the subject as a
+       UTF-8  string is automatically checked when pcre_exec() is subsequently
+       called.  The value of startoffset is also checked  to  ensure  that  it
+       points  to  the start of a UTF-8 character. There is a discussion about
+       the validity of UTF-8 strings in the section on UTF-8  support  in  the
+       main  pcre  page.  If  an  invalid  UTF-8  sequence  of bytes is found,
+       pcre_exec() returns the error PCRE_ERROR_BADUTF8. If  startoffset  con-
+       tains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is returned.
+
+       If  you  already  know that your subject is valid, and you want to skip
+       these   checks   for   performance   reasons,   you   can    set    the
+       PCRE_NO_UTF8_CHECK  option  when calling pcre_exec(). You might want to
+       do this for the second and subsequent calls to pcre_exec() if  you  are
+       making  repeated  calls  to  find  all  the matches in a single subject
+       string. However, you should be  sure  that  the  value  of  startoffset
+       points  to  the  start of a UTF-8 character. When PCRE_NO_UTF8_CHECK is
+       set, the effect of passing an invalid UTF-8 string as a subject,  or  a
+       value  of startoffset that does not point to the start of a UTF-8 char-
+       acter, is undefined. Your program may crash.
+
+         PCRE_PARTIAL
+
+       This option turns on the  partial  matching  feature.  If  the  subject
+       string  fails to match the pattern, but at some point during the match-
+       ing process the end of the subject was reached (that  is,  the  subject
+       partially  matches  the  pattern and the failure to match occurred only
+       because there were not enough subject characters), pcre_exec()  returns
+       PCRE_ERROR_PARTIAL  instead of PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is
+       used, there are restrictions on what may appear in the  pattern.  These
+       are discussed in the pcrepartial documentation.
+
+   The string to be matched by pcre_exec()
+
+       The  subject string is passed to pcre_exec() as a pointer in subject, a
+       length (in bytes) in length, and a starting byte offset in startoffset.
+       In UTF-8 mode, the byte offset must point to the start of a UTF-8 char-
+       acter. Unlike the pattern string, the subject may contain  binary  zero
+       bytes.  When the starting offset is zero, the search for a match starts
+       at the beginning of the subject, and this is by  far  the  most  common
+       case.
+
+       A  non-zero  starting offset is useful when searching for another match
+       in the same subject by calling pcre_exec() again after a previous  suc-
+       cess.   Setting  startoffset differs from just passing over a shortened
+       string and setting PCRE_NOTBOL in the case of  a  pattern  that  begins
+       with any kind of lookbehind. For example, consider the pattern
+
+         \Biss\B
+
+       which  finds  occurrences  of "iss" in the middle of words. (\B matches
+       only if the current position in the subject is not  a  word  boundary.)
+       When  applied  to the string "Mississipi" the first call to pcre_exec()
+       finds the first occurrence. If pcre_exec() is called  again  with  just
+       the  remainder  of  the  subject,  namely  "issipi", it does not match,
+       because \B is always false at the start of the subject, which is deemed
+       to  be  a  word  boundary. However, if pcre_exec() is passed the entire
+       string again, but with startoffset set to 4, it finds the second occur-
+       rence  of "iss" because it is able to look behind the starting point to
+       discover that it is preceded by a letter.
+
+       If a non-zero starting offset is passed when the pattern  is  anchored,
+       one attempt to match at the given offset is made. This can only succeed
+       if the pattern does not require the match to be at  the  start  of  the
+       subject.
+
+   How pcre_exec() returns captured substrings
+
+       In  general, a pattern matches a certain portion of the subject, and in
+       addition, further substrings from the subject  may  be  picked  out  by
+       parts  of  the  pattern.  Following the usage in Jeffrey Friedl's book,
+       this is called "capturing" in what follows, and the  phrase  "capturing
+       subpattern"  is  used for a fragment of a pattern that picks out a sub-
+       string. PCRE supports several other kinds of  parenthesized  subpattern
+       that do not cause substrings to be captured.
+
+       Captured substrings are returned to the caller via a vector of integers
+       whose address is passed in ovector. The number of elements in the  vec-
+       tor  is  passed in ovecsize, which must be a non-negative number. Note:
+       this argument is NOT the size of ovector in bytes.
+
+       The first two-thirds of the vector is used to pass back  captured  sub-
+       strings,  each  substring using a pair of integers. The remaining third
+       of the vector is used as workspace by pcre_exec() while  matching  cap-
+       turing  subpatterns, and is not available for passing back information.
+       The number passed in ovecsize should always be a multiple of three.  If
+       it is not, it is rounded down.
+
+       When  a  match  is successful, information about captured substrings is
+       returned in pairs of integers, starting at the  beginning  of  ovector,
+       and  continuing  up  to two-thirds of its length at the most. The first
+       element of each pair is set to the byte offset of the  first  character
+       in  a  substring, and the second is set to the byte offset of the first
+       character after the end of a substring. Note: these values  are  always
+       byte offsets, even in UTF-8 mode. They are not character counts.
+
+       The  first  pair  of  integers, ovector[0] and ovector[1], identify the
+       portion of the subject string matched by the entire pattern.  The  next
+       pair  is  used for the first capturing subpattern, and so on. The value
+       returned by pcre_exec() is one more than the highest numbered pair that
+       has  been  set.  For example, if two substrings have been captured, the
+       returned value is 3. If there are no capturing subpatterns, the  return
+       value from a successful match is 1, indicating that just the first pair
+       of offsets has been set.
+
+       If a capturing subpattern is matched repeatedly, it is the last portion
+       of the string that it matched that is returned.
+
+       If  the vector is too small to hold all the captured substring offsets,
+       it is used as far as possible (up to two-thirds of its length), and the
+       function  returns  a value of zero. If the substring offsets are not of
+       interest, pcre_exec() may be called with ovector  passed  as  NULL  and
+       ovecsize  as zero. However, if the pattern contains back references and
+       the ovector is not big enough to remember the related substrings,  PCRE
+       has  to  get additional memory for use during matching. Thus it is usu-
+       ally advisable to supply an ovector.
+
+       The pcre_info() function can be used to find  out  how  many  capturing
+       subpatterns  there  are  in  a  compiled pattern. The smallest size for
+       ovector that will allow for n captured substrings, in addition  to  the
+       offsets of the substring matched by the whole pattern, is (n+1)*3.
+
+       It  is  possible for capturing subpattern number n+1 to match some part
+       of the subject when subpattern n has not been used at all. For example,
+       if  the  string  "abc"  is  matched against the pattern (a|(z))(bc) the
+       return from the function is 4, and subpatterns 1 and 3 are matched, but
+       2  is  not.  When  this happens, both values in the offset pairs corre-
+       sponding to unused subpatterns are set to -1.
+
+       Offset values that correspond to unused subpatterns at the end  of  the
+       expression  are  also  set  to  -1. For example, if the string "abc" is
+       matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are  not
+       matched.  The  return  from the function is 2, because the highest used
+       capturing subpattern number is 1. However, you can refer to the offsets
+       for  the  second  and third capturing subpatterns if you wish (assuming
+       the vector is large enough, of course).
+
+       Some convenience functions are provided  for  extracting  the  captured
+       substrings as separate strings. These are described below.
+
+   Error return values from pcre_exec()
+
+       If  pcre_exec()  fails, it returns a negative number. The following are
+       defined in the header file:
+
+         PCRE_ERROR_NOMATCH        (-1)
+
+       The subject string did not match the pattern.
+
+         PCRE_ERROR_NULL           (-2)
+
+       Either code or subject was passed as NULL,  or  ovector  was  NULL  and
+       ovecsize was not zero.
+
+         PCRE_ERROR_BADOPTION      (-3)
+
+       An unrecognized bit was set in the options argument.
+
+         PCRE_ERROR_BADMAGIC       (-4)
+
+       PCRE  stores a 4-byte "magic number" at the start of the compiled code,
+       to catch the case when it is passed a junk pointer and to detect when a
+       pattern that was compiled in an environment of one endianness is run in
+       an environment with the other endianness. This is the error  that  PCRE
+       gives when the magic number is not present.
+
+         PCRE_ERROR_UNKNOWN_OPCODE (-5)
+
+       While running the pattern match, an unknown item was encountered in the
+       compiled pattern. This error could be caused by a bug  in  PCRE  or  by
+       overwriting of the compiled pattern.
+
+         PCRE_ERROR_NOMEMORY       (-6)
+
+       If  a  pattern contains back references, but the ovector that is passed
+       to pcre_exec() is not big enough to remember the referenced substrings,
+       PCRE  gets  a  block of memory at the start of matching to use for this
+       purpose. If the call via pcre_malloc() fails, this error is given.  The
+       memory is automatically freed at the end of matching.
+
+         PCRE_ERROR_NOSUBSTRING    (-7)
+
+       This  error is used by the pcre_copy_substring(), pcre_get_substring(),
+       and  pcre_get_substring_list()  functions  (see  below).  It  is  never
+       returned by pcre_exec().
+
+         PCRE_ERROR_MATCHLIMIT     (-8)
+
+       The  backtracking  limit,  as  specified  by the match_limit field in a
+       pcre_extra structure (or defaulted) was reached.  See  the  description
+       above.
+
+         PCRE_ERROR_CALLOUT        (-9)
+
+       This error is never generated by pcre_exec() itself. It is provided for
+       use by callout functions that want to yield a distinctive  error  code.
+       See the pcrecallout documentation for details.
+
+         PCRE_ERROR_BADUTF8        (-10)
+
+       A  string  that contains an invalid UTF-8 byte sequence was passed as a
+       subject.
+
+         PCRE_ERROR_BADUTF8_OFFSET (-11)
+
+       The UTF-8 byte sequence that was passed as a subject was valid, but the
+       value  of startoffset did not point to the beginning of a UTF-8 charac-
+       ter.
+
+         PCRE_ERROR_PARTIAL        (-12)
+
+       The subject string did not match, but it did match partially.  See  the
+       pcrepartial documentation for details of partial matching.
+
+         PCRE_ERROR_BADPARTIAL     (-13)
+
+       The  PCRE_PARTIAL  option  was  used with a compiled pattern containing
+       items that are not supported for partial matching. See the  pcrepartial
+       documentation for details of partial matching.
+
+         PCRE_ERROR_INTERNAL       (-14)
+
+       An  unexpected  internal error has occurred. This error could be caused
+       by a bug in PCRE or by overwriting of the compiled pattern.
+
+         PCRE_ERROR_BADCOUNT       (-15)
+
+       This error is given if the value of the ovecsize argument is  negative.
+
+         PCRE_ERROR_RECURSIONLIMIT (-21)
+
+       The internal recursion limit, as specified by the match_limit_recursion
+       field in a pcre_extra structure (or defaulted)  was  reached.  See  the
+       description above.
+
+         PCRE_ERROR_BADNEWLINE     (-23)
+
+       An invalid combination of PCRE_NEWLINE_xxx options was given.
+
+       Error numbers -16 to -20 and -22 are not used by pcre_exec().
+
+
+EXTRACTING CAPTURED SUBSTRINGS BY NUMBER
+
+       int pcre_copy_substring(const char *subject, int *ovector,
+            int stringcount, int stringnumber, char *buffer,
+            int buffersize);
+
+       int pcre_get_substring(const char *subject, int *ovector,
+            int stringcount, int stringnumber,
+            const char **stringptr);
+
+       int pcre_get_substring_list(const char *subject,
+            int *ovector, int stringcount, const char ***listptr);
+
+       Captured  substrings  can  be  accessed  directly  by using the offsets
+       returned by pcre_exec() in  ovector.  For  convenience,  the  functions
+       pcre_copy_substring(),    pcre_get_substring(),    and    pcre_get_sub-
+       string_list() are provided for extracting captured substrings  as  new,
+       separate,  zero-terminated strings. These functions identify substrings
+       by number. The next section describes functions  for  extracting  named
+       substrings.
+
+       A  substring that contains a binary zero is correctly extracted and has
+       a further zero added on the end, but the result is not, of course, a  C
+       string.   However,  you  can  process such a string by referring to the
+       length that is  returned  by  pcre_copy_substring()  and  pcre_get_sub-
+       string().  Unfortunately, the interface to pcre_get_substring_list() is
+       not adequate for handling strings containing binary zeros, because  the
+       end of the final string is not independently indicated.
+
+       The  first  three  arguments  are the same for all three of these func-
+       tions: subject is the subject string that has  just  been  successfully
+       matched, ovector is a pointer to the vector of integer offsets that was
+       passed to pcre_exec(), and stringcount is the number of substrings that
+       were  captured  by  the match, including the substring that matched the
+       entire regular expression. This is the value returned by pcre_exec() if
+       it  is greater than zero. If pcre_exec() returned zero, indicating that
+       it ran out of space in ovector, the value passed as stringcount  should
+       be the number of elements in the vector divided by three.
+
+       The  functions pcre_copy_substring() and pcre_get_substring() extract a
+       single substring, whose number is given as  stringnumber.  A  value  of
+       zero  extracts  the  substring that matched the entire pattern, whereas
+       higher values  extract  the  captured  substrings.  For  pcre_copy_sub-
+       string(),  the  string  is  placed  in buffer, whose length is given by
+       buffersize, while for pcre_get_substring() a new  block  of  memory  is
+       obtained  via  pcre_malloc,  and its address is returned via stringptr.
+       The yield of the function is the length of the  string,  not  including
+       the terminating zero, or one of these error codes:
+
+         PCRE_ERROR_NOMEMORY       (-6)
+
+       The  buffer  was too small for pcre_copy_substring(), or the attempt to
+       get memory failed for pcre_get_substring().
+
+         PCRE_ERROR_NOSUBSTRING    (-7)
+
+       There is no substring whose number is stringnumber.
+
+       The pcre_get_substring_list()  function  extracts  all  available  sub-
+       strings  and  builds  a list of pointers to them. All this is done in a
+       single block of memory that is obtained via pcre_malloc. The address of
+       the  memory  block  is returned via listptr, which is also the start of
+       the list of string pointers. The end of the list is marked  by  a  NULL
+       pointer.  The  yield  of  the function is zero if all went well, or the
+       error code
+
+         PCRE_ERROR_NOMEMORY       (-6)
+
+       if the attempt to get the memory block failed.
+
+       When any of these functions encounter a substring that is unset,  which
+       can  happen  when  capturing subpattern number n+1 matches some part of
+       the subject, but subpattern n has not been used at all, they return  an
+       empty string. This can be distinguished from a genuine zero-length sub-
+       string by inspecting the appropriate offset in ovector, which is  nega-
+       tive for unset substrings.
+
+       The  two convenience functions pcre_free_substring() and pcre_free_sub-
+       string_list() can be used to free the memory  returned  by  a  previous
+       call  of  pcre_get_substring()  or  pcre_get_substring_list(),  respec-
+       tively. They do nothing more than  call  the  function  pointed  to  by
+       pcre_free,  which  of course could be called directly from a C program.
+       However, PCRE is used in some situations where it is linked via a  spe-
+       cial   interface  to  another  programming  language  that  cannot  use
+       pcre_free directly; it is for these cases that the functions  are  pro-
+       vided.
+
+
+EXTRACTING CAPTURED SUBSTRINGS BY NAME
+
+       int pcre_get_stringnumber(const pcre *code,
+            const char *name);
+
+       int pcre_copy_named_substring(const pcre *code,
+            const char *subject, int *ovector,
+            int stringcount, const char *stringname,
+            char *buffer, int buffersize);
+
+       int pcre_get_named_substring(const pcre *code,
+            const char *subject, int *ovector,
+            int stringcount, const char *stringname,
+            const char **stringptr);
+
+       To  extract a substring by name, you first have to find associated num-
+       ber.  For example, for this pattern
+
+         (a+)b(?<xxx>\d+)...
+
+       the number of the subpattern called "xxx" is 2. If the name is known to
+       be unique (PCRE_DUPNAMES was not set), you can find the number from the
+       name by calling pcre_get_stringnumber(). The first argument is the com-
+       piled pattern, and the second is the name. The yield of the function is
+       the subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if  there  is  no
+       subpattern of that name.
+
+       Given the number, you can extract the substring directly, or use one of
+       the functions described in the previous section. For convenience, there
+       are also two functions that do the whole job.
+
+       Most    of    the    arguments   of   pcre_copy_named_substring()   and
+       pcre_get_named_substring() are the same  as  those  for  the  similarly
+       named  functions  that extract by number. As these are described in the
+       previous section, they are not re-described here. There  are  just  two
+       differences:
+
+       First,  instead  of a substring number, a substring name is given. Sec-
+       ond, there is an extra argument, given at the start, which is a pointer
+       to  the compiled pattern. This is needed in order to gain access to the
+       name-to-number translation table.
+
+       These functions call pcre_get_stringnumber(), and if it succeeds,  they
+       then  call  pcre_copy_substring() or pcre_get_substring(), as appropri-
+       ate. NOTE: If PCRE_DUPNAMES is set and there are duplicate  names,  the
+       behaviour may not be what you want (see the next section).
+
+
+DUPLICATE SUBPATTERN NAMES
+
+       int pcre_get_stringtable_entries(const pcre *code,
+            const char *name, char **first, char **last);
+
+       When  a  pattern  is  compiled with the PCRE_DUPNAMES option, names for
+       subpatterns are not required to  be  unique.  Normally,  patterns  with
+       duplicate  names  are such that in any one match, only one of the named
+       subpatterns participates. An example is shown in the pcrepattern  docu-
+       mentation.
+
+       When    duplicates   are   present,   pcre_copy_named_substring()   and
+       pcre_get_named_substring() return the first substring corresponding  to
+       the  given  name  that  is set. If none are set, PCRE_ERROR_NOSUBSTRING
+       (-7) is returned; no  data  is  returned.  The  pcre_get_stringnumber()
+       function  returns one of the numbers that are associated with the name,
+       but it is not defined which it is.
+
+       If you want to get full details of all captured substrings for a  given
+       name,  you  must  use  the pcre_get_stringtable_entries() function. The
+       first argument is the compiled pattern, and the second is the name. The
+       third  and  fourth  are  pointers to variables which are updated by the
+       function. After it has run, they point to the first and last entries in
+       the  name-to-number  table  for  the  given  name.  The function itself
+       returns the length of each entry,  or  PCRE_ERROR_NOSUBSTRING  (-7)  if
+       there  are none. The format of the table is described above in the sec-
+       tion entitled Information about a  pattern.   Given  all  the  relevant
+       entries  for the name, you can extract each of their numbers, and hence
+       the captured data, if any.
+
+
+FINDING ALL POSSIBLE MATCHES
+
+       The traditional matching function uses a  similar  algorithm  to  Perl,
+       which stops when it finds the first match, starting at a given point in
+       the subject. If you want to find all possible matches, or  the  longest
+       possible  match,  consider using the alternative matching function (see
+       below) instead. If you cannot use the alternative function,  but  still
+       need  to  find all possible matches, you can kludge it up by making use
+       of the callout facility, which is described in the pcrecallout documen-
+       tation.
+
+       What you have to do is to insert a callout right at the end of the pat-
+       tern.  When your callout function is called, extract and save the  cur-
+       rent  matched  substring.  Then  return  1, which forces pcre_exec() to
+       backtrack and try other alternatives. Ultimately, when it runs  out  of
+       matches, pcre_exec() will yield PCRE_ERROR_NOMATCH.
+
+
+MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
+
+       int pcre_dfa_exec(const pcre *code, const pcre_extra *extra,
+            const char *subject, int length, int startoffset,
+            int options, int *ovector, int ovecsize,
+            int *workspace, int wscount);
+
+       The  function  pcre_dfa_exec()  is  called  to  match  a subject string
+       against a compiled pattern, using a matching algorithm that  scans  the
+       subject  string  just  once, and does not backtrack. This has different
+       characteristics to the normal algorithm, and  is  not  compatible  with
+       Perl.  Some  of the features of PCRE patterns are not supported. Never-
+       theless, there are times when this kind of matching can be useful.  For
+       a discussion of the two matching algorithms, see the pcrematching docu-
+       mentation.
+
+       The arguments for the pcre_dfa_exec() function  are  the  same  as  for
+       pcre_exec(), plus two extras. The ovector argument is used in a differ-
+       ent way, and this is described below. The other  common  arguments  are
+       used  in  the  same way as for pcre_exec(), so their description is not
+       repeated here.
+
+       The two additional arguments provide workspace for  the  function.  The
+       workspace  vector  should  contain at least 20 elements. It is used for
+       keeping  track  of  multiple  paths  through  the  pattern  tree.  More
+       workspace  will  be  needed for patterns and subjects where there are a
+       lot of potential matches.
+
+       Here is an example of a simple call to pcre_dfa_exec():
+
+         int rc;
+         int ovector[10];
+         int wspace[20];
+         rc = pcre_dfa_exec(
+           re,             /* result of pcre_compile() */
+           NULL,           /* we didn't study the pattern */
+           "some string",  /* the subject string */
+           11,             /* the length of the subject string */
+           0,              /* start at offset 0 in the subject */
+           0,              /* default options */
+           ovector,        /* vector of integers for substring information */
+           10,             /* number of elements (NOT size in bytes) */
+           wspace,         /* working space vector */
+           20);            /* number of elements (NOT size in bytes) */
+
+   Option bits for pcre_dfa_exec()
+
+       The unused bits of the options argument  for  pcre_dfa_exec()  must  be
+       zero.  The  only  bits  that  may  be  set are PCRE_ANCHORED, PCRE_NEW-
+       LINE_xxx, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY,  PCRE_NO_UTF8_CHECK,
+       PCRE_PARTIAL, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last
+       three of these are the same as for pcre_exec(), so their description is
+       not repeated here.
+
+         PCRE_PARTIAL
+
+       This  has  the  same general effect as it does for pcre_exec(), but the
+       details  are  slightly  different.  When  PCRE_PARTIAL   is   set   for
+       pcre_dfa_exec(),  the  return code PCRE_ERROR_NOMATCH is converted into
+       PCRE_ERROR_PARTIAL if the end of the subject  is  reached,  there  have
+       been no complete matches, but there is still at least one matching pos-
+       sibility. The portion of the string that provided the partial match  is
+       set as the first matching string.
+
+         PCRE_DFA_SHORTEST
+
+       Setting  the  PCRE_DFA_SHORTEST option causes the matching algorithm to
+       stop as soon as it has found one match. Because of the way the alterna-
+       tive  algorithm  works, this is necessarily the shortest possible match
+       at the first possible matching point in the subject string.
+
+         PCRE_DFA_RESTART
+
+       When pcre_dfa_exec()  is  called  with  the  PCRE_PARTIAL  option,  and
+       returns  a  partial  match, it is possible to call it again, with addi-
+       tional subject characters, and have it continue with  the  same  match.
+       The  PCRE_DFA_RESTART  option requests this action; when it is set, the
+       workspace and wscount options must reference the same vector as  before
+       because  data  about  the  match so far is left in them after a partial
+       match. There is more discussion of this  facility  in  the  pcrepartial
+       documentation.
+
+   Successful returns from pcre_dfa_exec()
+
+       When  pcre_dfa_exec()  succeeds, it may have matched more than one sub-
+       string in the subject. Note, however, that all the matches from one run
+       of  the  function  start  at the same point in the subject. The shorter
+       matches are all initial substrings of the longer matches. For  example,
+       if the pattern
+
+         <.*>
+
+       is matched against the string
+
+         This is <something> <something else> <something further> no more
+
+       the three matched strings are
+
+         <something>
+         <something> <something else>
+         <something> <something else> <something further>
+
+       On  success,  the  yield of the function is a number greater than zero,
+       which is the number of matched substrings.  The  substrings  themselves
+       are  returned  in  ovector. Each string uses two elements; the first is
+       the offset to the start, and the second is the offset to  the  end.  In
+       fact,  all  the  strings  have the same start offset. (Space could have
+       been saved by giving this only once, but it was decided to retain  some
+       compatibility  with  the  way pcre_exec() returns data, even though the
+       meaning of the strings is different.)
+
+       The strings are returned in reverse order of length; that is, the long-
+       est  matching  string is given first. If there were too many matches to
+       fit into ovector, the yield of the function is zero, and the vector  is
+       filled with the longest matches.
+
+   Error returns from pcre_dfa_exec()
+
+       The  pcre_dfa_exec()  function returns a negative number when it fails.
+       Many of the errors are the same  as  for  pcre_exec(),  and  these  are
+       described  above.   There are in addition the following errors that are
+       specific to pcre_dfa_exec():
+
+         PCRE_ERROR_DFA_UITEM      (-16)
+
+       This return is given if pcre_dfa_exec() encounters an item in the  pat-
+       tern  that  it  does not support, for instance, the use of \C or a back
+       reference.
+
+         PCRE_ERROR_DFA_UCOND      (-17)
+
+       This return is given if pcre_dfa_exec()  encounters  a  condition  item
+       that  uses  a back reference for the condition, or a test for recursion
+       in a specific group. These are not supported.
+
+         PCRE_ERROR_DFA_UMLIMIT    (-18)
+
+       This return is given if pcre_dfa_exec() is called with an  extra  block
+       that contains a setting of the match_limit field. This is not supported
+       (it is meaningless).
+
+         PCRE_ERROR_DFA_WSSIZE     (-19)
+
+       This return is given if  pcre_dfa_exec()  runs  out  of  space  in  the
+       workspace vector.
+
+         PCRE_ERROR_DFA_RECURSE    (-20)
+
+       When  a  recursive subpattern is processed, the matching function calls
+       itself recursively, using private vectors for  ovector  and  workspace.
+       This  error  is  given  if  the output vector is not large enough. This
+       should be extremely rare, as a vector of size 1000 is used.
+
+
+SEE ALSO
+
+       pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3),  pcrepar-
+       tial(3),  pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 24 August 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCRECALLOUT(3)                                                  PCRECALLOUT(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE CALLOUTS
+
+       int (*pcre_callout)(pcre_callout_block *);
+
+       PCRE provides a feature called "callout", which is a means of temporar-
+       ily passing control to the caller of PCRE  in  the  middle  of  pattern
+       matching.  The  caller of PCRE provides an external function by putting
+       its entry point in the global variable pcre_callout. By  default,  this
+       variable contains NULL, which disables all calling out.
+
+       Within  a  regular  expression,  (?C) indicates the points at which the
+       external function is to be called.  Different  callout  points  can  be
+       identified  by  putting  a number less than 256 after the letter C. The
+       default value is zero.  For  example,  this  pattern  has  two  callout
+       points:
+
+         (?C1)abc(?C2)def
+
+       If  the  PCRE_AUTO_CALLOUT  option  bit  is  set when pcre_compile() is
+       called, PCRE automatically  inserts  callouts,  all  with  number  255,
+       before  each  item in the pattern. For example, if PCRE_AUTO_CALLOUT is
+       used with the pattern
+
+         A(\d{2}|--)
+
+       it is processed as if it were
+
+       (?C255)A(?C255)((?C255)\d{2}(?C255)|(?C255)-(?C255)-(?C255))(?C255)
+
+       Notice that there is a callout before and after  each  parenthesis  and
+       alternation  bar.  Automatic  callouts  can  be  used  for tracking the
+       progress of pattern matching. The pcretest command has an  option  that
+       sets  automatic callouts; when it is used, the output indicates how the
+       pattern is matched. This is useful information when you are  trying  to
+       optimize the performance of a particular pattern.
+
+
+MISSING CALLOUTS
+
+       You  should  be  aware  that,  because of optimizations in the way PCRE
+       matches patterns, callouts sometimes do not happen. For example, if the
+       pattern is
+
+         ab(?C4)cd
+
+       PCRE knows that any matching string must contain the letter "d". If the
+       subject string is "abyz", the lack of "d" means that  matching  doesn't
+       ever  start,  and  the  callout is never reached. However, with "abyd",
+       though the result is still no match, the callout is obeyed.
+
+
+THE CALLOUT INTERFACE
+
+       During matching, when PCRE reaches a callout point, the external  func-
+       tion  defined by pcre_callout is called (if it is set). This applies to
+       both the pcre_exec() and the pcre_dfa_exec()  matching  functions.  The
+       only  argument  to  the callout function is a pointer to a pcre_callout
+       block. This structure contains the following fields:
+
+         int          version;
+         int          callout_number;
+         int         *offset_vector;
+         const char  *subject;
+         int          subject_length;
+         int          start_match;
+         int          current_position;
+         int          capture_top;
+         int          capture_last;
+         void        *callout_data;
+         int          pattern_position;
+         int          next_item_length;
+
+       The version field is an integer containing the version  number  of  the
+       block  format. The initial version was 0; the current version is 1. The
+       version number will change again in future  if  additional  fields  are
+       added, but the intention is never to remove any of the existing fields.
+
+       The callout_number field contains the number of the  callout,  as  com-
+       piled  into  the pattern (that is, the number after ?C for manual call-
+       outs, and 255 for automatically generated callouts).
+
+       The offset_vector field is a pointer to the vector of offsets that  was
+       passed   by   the   caller  to  pcre_exec()  or  pcre_dfa_exec().  When
+       pcre_exec() is used, the contents can be inspected in order to  extract
+       substrings  that  have  been  matched  so  far,  in the same way as for
+       extracting substrings after a match has completed. For  pcre_dfa_exec()
+       this field is not useful.
+
+       The subject and subject_length fields contain copies of the values that
+       were passed to pcre_exec().
+
+       The start_match field normally contains the offset within  the  subject
+       at  which  the  current  match  attempt started. However, if the escape
+       sequence \K has been encountered, this value is changed to reflect  the
+       modified  starting  point.  If the pattern is not anchored, the callout
+       function may be called several times from the same point in the pattern
+       for different starting points in the subject.
+
+       The  current_position  field  contains the offset within the subject of
+       the current match pointer.
+
+       When the pcre_exec() function is used, the capture_top  field  contains
+       one  more than the number of the highest numbered captured substring so
+       far. If no substrings have been captured, the value of  capture_top  is
+       one.  This  is always the case when pcre_dfa_exec() is used, because it
+       does not support captured substrings.
+
+       The capture_last field contains the number of the  most  recently  cap-
+       tured  substring. If no substrings have been captured, its value is -1.
+       This is always the case when pcre_dfa_exec() is used.
+
+       The callout_data field contains a value that is passed  to  pcre_exec()
+       or  pcre_dfa_exec() specifically so that it can be passed back in call-
+       outs. It is passed in the pcre_callout field  of  the  pcre_extra  data
+       structure.  If  no such data was passed, the value of callout_data in a
+       pcre_callout block is NULL. There is a description  of  the  pcre_extra
+       structure in the pcreapi documentation.
+
+       The  pattern_position field is present from version 1 of the pcre_call-
+       out structure. It contains the offset to the next item to be matched in
+       the pattern string.
+
+       The  next_item_length field is present from version 1 of the pcre_call-
+       out structure. It contains the length of the next item to be matched in
+       the  pattern  string. When the callout immediately precedes an alterna-
+       tion bar, a closing parenthesis, or the end of the pattern, the  length
+       is  zero.  When the callout precedes an opening parenthesis, the length
+       is that of the entire subpattern.
+
+       The pattern_position and next_item_length fields are intended  to  help
+       in  distinguishing between different automatic callouts, which all have
+       the same callout number. However, they are set for all callouts.
+
+
+RETURN VALUES
+
+       The external callout function returns an integer to PCRE. If the  value
+       is  zero,  matching  proceeds  as  normal. If the value is greater than
+       zero, matching fails at the current point, but  the  testing  of  other
+       matching possibilities goes ahead, just as if a lookahead assertion had
+       failed. If the value is less than zero, the  match  is  abandoned,  and
+       pcre_exec() (or pcre_dfa_exec()) returns the negative value.
+
+       Negative   values   should   normally   be   chosen  from  the  set  of
+       PCRE_ERROR_xxx values. In particular, PCRE_ERROR_NOMATCH forces a stan-
+       dard  "no  match"  failure.   The  error  number  PCRE_ERROR_CALLOUT is
+       reserved for use by callout functions; it will never be  used  by  PCRE
+       itself.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 29 May 2007
+       Copyright (c) 1997-2007 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCRECOMPAT(3)                                                    PCRECOMPAT(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+DIFFERENCES BETWEEN PCRE AND PERL
+
+       This  document describes the differences in the ways that PCRE and Perl
+       handle regular expressions. The differences described here  are  mainly
+       with  respect  to  Perl 5.8, though PCRE versions 7.0 and later contain
+       some features that are expected to be in the forthcoming Perl 5.10.
+
+       1. PCRE has only a subset of Perl's UTF-8 and Unicode support.  Details
+       of  what  it does have are given in the section on UTF-8 support in the
+       main pcre page.
+
+       2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl
+       permits  them,  but they do not mean what you might think. For example,
+       (?!a){3} does not assert that the next three characters are not "a". It
+       just asserts that the next character is not "a" three times.
+
+       3.  Capturing  subpatterns  that occur inside negative lookahead asser-
+       tions are counted, but their entries in the offsets  vector  are  never
+       set.  Perl sets its numerical variables from any such patterns that are
+       matched before the assertion fails to match something (thereby succeed-
+       ing),  but  only  if the negative lookahead assertion contains just one
+       branch.
+
+       4. Though binary zero characters are supported in the  subject  string,
+       they are not allowed in a pattern string because it is passed as a nor-
+       mal C string, terminated by zero. The escape sequence \0 can be used in
+       the pattern to represent a binary zero.
+
+       5.  The  following Perl escape sequences are not supported: \l, \u, \L,
+       \U, and \N. In fact these are implemented by Perl's general string-han-
+       dling  and are not part of its pattern matching engine. If any of these
+       are encountered by PCRE, an error is generated.
+
+       6. The Perl escape sequences \p, \P, and \X are supported only if  PCRE
+       is  built  with Unicode character property support. The properties that
+       can be tested with \p and \P are limited to the general category  prop-
+       erties  such  as  Lu and Nd, script names such as Greek or Han, and the
+       derived properties Any and L&.
+
+       7. PCRE does support the \Q...\E escape for quoting substrings. Charac-
+       ters  in  between  are  treated as literals. This is slightly different
+       from Perl in that $ and @ are  also  handled  as  literals  inside  the
+       quotes.  In Perl, they cause variable interpolation (but of course PCRE
+       does not have variables). Note the following examples:
+
+           Pattern            PCRE matches      Perl matches
+
+           \Qabc$xyz\E        abc$xyz           abc followed by the
+                                                  contents of $xyz
+           \Qabc\$xyz\E       abc\$xyz          abc\$xyz
+           \Qabc\E\$\Qxyz\E   abc$xyz           abc$xyz
+
+       The \Q...\E sequence is recognized both inside  and  outside  character
+       classes.
+
+       8. Fairly obviously, PCRE does not support the (?{code}) and (??{code})
+       constructions. However, there is support for recursive  patterns.  This
+       is  not available in Perl 5.8, but will be in Perl 5.10. Also, the PCRE
+       "callout" feature allows an external function to be called during  pat-
+       tern matching. See the pcrecallout documentation for details.
+
+       9.  Subpatterns  that  are  called  recursively or as "subroutines" are
+       always treated as atomic groups in  PCRE.  This  is  like  Python,  but
+       unlike Perl.
+
+       10.  There are some differences that are concerned with the settings of
+       captured strings when part of  a  pattern  is  repeated.  For  example,
+       matching  "aba"  against  the  pattern  /^(a(b)?)+$/  in Perl leaves $2
+       unset, but in PCRE it is set to "b".
+
+       11.  PCRE  does  support  Perl  5.10's  backtracking  verbs  (*ACCEPT),
+       (*FAIL),  (*F),  (*COMMIT), (*PRUNE), (*SKIP), and (*THEN), but only in
+       the forms without an  argument.  PCRE  does  not  support  (*MARK).  If
+       (*ACCEPT)  is within capturing parentheses, PCRE does not set that cap-
+       ture group; this is different to Perl.
+
+       12. PCRE provides some extensions to the Perl regular expression facil-
+       ities.   Perl  5.10  will  include new features that are not in earlier
+       versions, some of which (such as named parentheses) have been  in  PCRE
+       for some time. This list is with respect to Perl 5.10:
+
+       (a)  Although  lookbehind  assertions  must match fixed length strings,
+       each alternative branch of a lookbehind assertion can match a different
+       length of string. Perl requires them all to have the same length.
+
+       (b)  If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $
+       meta-character matches only at the very end of the string.
+
+       (c) If PCRE_EXTRA is set, a backslash followed by a letter with no spe-
+       cial meaning is faulted. Otherwise, like Perl, the backslash is quietly
+       ignored.  (Perl can be made to issue a warning.)
+
+       (d) If PCRE_UNGREEDY is set, the greediness of the  repetition  quanti-
+       fiers is inverted, that is, by default they are not greedy, but if fol-
+       lowed by a question mark they are.
+
+       (e) PCRE_ANCHORED can be used at matching time to force a pattern to be
+       tried only at the first matching position in the subject string.
+
+       (f)  The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and PCRE_NO_AUTO_CAP-
+       TURE options for pcre_exec() have no Perl equivalents.
+
+       (g) The \R escape sequence can be restricted to match only CR,  LF,  or
+       CRLF by the PCRE_BSR_ANYCRLF option.
+
+       (h) The callout facility is PCRE-specific.
+
+       (i) The partial matching facility is PCRE-specific.
+
+       (j) Patterns compiled by PCRE can be saved and re-used at a later time,
+       even on different hosts that have the other endianness.
+
+       (k) The alternative matching function (pcre_dfa_exec())  matches  in  a
+       different way and is not Perl-compatible.
+
+       (l)  PCRE  recognizes some special sequences such as (*CR) at the start
+       of a pattern that set overall options that cannot be changed within the
+       pattern.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 11 September 2007
+       Copyright (c) 1997-2007 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCREPATTERN(3)                                                  PCREPATTERN(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE REGULAR EXPRESSION DETAILS
+
+       The  syntax and semantics of the regular expressions that are supported
+       by PCRE are described in detail below. There is a quick-reference  syn-
+       tax summary in the pcresyntax page. PCRE tries to match Perl syntax and
+       semantics as closely as it can. PCRE  also  supports  some  alternative
+       regular  expression  syntax (which does not conflict with the Perl syn-
+       tax) in order to provide some compatibility with regular expressions in
+       Python, .NET, and Oniguruma.
+
+       Perl's  regular expressions are described in its own documentation, and
+       regular expressions in general are covered in a number of  books,  some
+       of  which  have  copious  examples. Jeffrey Friedl's "Mastering Regular
+       Expressions", published by  O'Reilly,  covers  regular  expressions  in
+       great  detail.  This  description  of  PCRE's  regular  expressions  is
+       intended as reference material.
+
+       The original operation of PCRE was on strings of  one-byte  characters.
+       However,  there is now also support for UTF-8 character strings. To use
+       this, you must build PCRE to  include  UTF-8  support,  and  then  call
+       pcre_compile()  with  the  PCRE_UTF8  option.  How this affects pattern
+       matching is mentioned in several places below. There is also a  summary
+       of  UTF-8  features  in  the  section on UTF-8 support in the main pcre
+       page.
+
+       The remainder of this document discusses the  patterns  that  are  sup-
+       ported  by  PCRE when its main matching function, pcre_exec(), is used.
+       From  release  6.0,   PCRE   offers   a   second   matching   function,
+       pcre_dfa_exec(),  which matches using a different algorithm that is not
+       Perl-compatible. Some of the features discussed below are not available
+       when  pcre_dfa_exec()  is used. The advantages and disadvantages of the
+       alternative function, and how it differs from the normal function,  are
+       discussed in the pcrematching page.
+
+
+NEWLINE CONVENTIONS
+
+       PCRE  supports five different conventions for indicating line breaks in
+       strings: a single CR (carriage return) character, a  single  LF  (line-
+       feed) character, the two-character sequence CRLF, any of the three pre-
+       ceding, or any Unicode newline sequence. The pcreapi page  has  further
+       discussion  about newlines, and shows how to set the newline convention
+       in the options arguments for the compiling and matching functions.
+
+       It is also possible to specify a newline convention by starting a  pat-
+       tern string with one of the following five sequences:
+
+         (*CR)        carriage return
+         (*LF)        linefeed
+         (*CRLF)      carriage return, followed by linefeed
+         (*ANYCRLF)   any of the three above
+         (*ANY)       all Unicode newline sequences
+
+       These override the default and the options given to pcre_compile(). For
+       example, on a Unix system where LF is the default newline sequence, the
+       pattern
+
+         (*CR)a.b
+
+       changes the convention to CR. That pattern matches "a\nb" because LF is
+       no longer a newline. Note that these special settings,  which  are  not
+       Perl-compatible,  are  recognized  only at the very start of a pattern,
+       and that they must be in upper case.  If  more  than  one  of  them  is
+       present, the last one is used.
+
+       The  newline  convention  does  not  affect what the \R escape sequence
+       matches. By default, this is any Unicode  newline  sequence,  for  Perl
+       compatibility.  However, this can be changed; see the description of \R
+       in the section entitled "Newline sequences" below. A change of \R  set-
+       ting can be combined with a change of newline convention.
+
+
+CHARACTERS AND METACHARACTERS
+
+       A  regular  expression  is  a pattern that is matched against a subject
+       string from left to right. Most characters stand for  themselves  in  a
+       pattern,  and  match  the corresponding characters in the subject. As a
+       trivial example, the pattern
+
+         The quick brown fox
+
+       matches a portion of a subject string that is identical to itself. When
+       caseless  matching is specified (the PCRE_CASELESS option), letters are
+       matched independently of case. In UTF-8 mode, PCRE  always  understands
+       the  concept  of case for characters whose values are less than 128, so
+       caseless matching is always possible. For characters with  higher  val-
+       ues,  the concept of case is supported if PCRE is compiled with Unicode
+       property support, but not otherwise.   If  you  want  to  use  caseless
+       matching  for  characters  128  and above, you must ensure that PCRE is
+       compiled with Unicode property support as well as with UTF-8 support.
+
+       The power of regular expressions comes  from  the  ability  to  include
+       alternatives  and  repetitions in the pattern. These are encoded in the
+       pattern by the use of metacharacters, which do not stand for themselves
+       but instead are interpreted in some special way.
+
+       There  are  two different sets of metacharacters: those that are recog-
+       nized anywhere in the pattern except within square brackets, and  those
+       that  are  recognized  within square brackets. Outside square brackets,
+       the metacharacters are as follows:
+
+         \      general escape character with several uses
+         ^      assert start of string (or line, in multiline mode)
+         $      assert end of string (or line, in multiline mode)
+         .      match any character except newline (by default)
+         [      start character class definition
+         |      start of alternative branch
+         (      start subpattern
+         )      end subpattern
+         ?      extends the meaning of (
+                also 0 or 1 quantifier
+                also quantifier minimizer
+         *      0 or more quantifier
+         +      1 or more quantifier
+                also "possessive quantifier"
+         {      start min/max quantifier
+
+       Part of a pattern that is in square brackets  is  called  a  "character
+       class". In a character class the only metacharacters are:
+
+         \      general escape character
+         ^      negate the class, but only if the first character
+         -      indicates character range
+         [      POSIX character class (only if followed by POSIX
+                  syntax)
+         ]      terminates the character class
+
+       The  following sections describe the use of each of the metacharacters.
+
+
+BACKSLASH
+
+       The backslash character has several uses. Firstly, if it is followed by
+       a  non-alphanumeric  character,  it takes away any special meaning that
+       character may have. This  use  of  backslash  as  an  escape  character
+       applies both inside and outside character classes.
+
+       For  example,  if  you want to match a * character, you write \* in the
+       pattern.  This escaping action applies whether  or  not  the  following
+       character  would  otherwise be interpreted as a metacharacter, so it is
+       always safe to precede a non-alphanumeric  with  backslash  to  specify
+       that  it stands for itself. In particular, if you want to match a back-
+       slash, you write \\.
+
+       If a pattern is compiled with the PCRE_EXTENDED option,  whitespace  in
+       the  pattern (other than in a character class) and characters between a
+       # outside a character class and the next newline are ignored. An escap-
+       ing  backslash  can  be  used to include a whitespace or # character as
+       part of the pattern.
+
+       If you want to remove the special meaning from a  sequence  of  charac-
+       ters,  you can do so by putting them between \Q and \E. This is differ-
+       ent from Perl in that $ and  @  are  handled  as  literals  in  \Q...\E
+       sequences  in  PCRE, whereas in Perl, $ and @ cause variable interpola-
+       tion. Note the following examples:
+
+         Pattern            PCRE matches   Perl matches
+
+         \Qabc$xyz\E        abc$xyz        abc followed by the
+                                             contents of $xyz
+         \Qabc\$xyz\E       abc\$xyz       abc\$xyz
+         \Qabc\E\$\Qxyz\E   abc$xyz        abc$xyz
+
+       The \Q...\E sequence is recognized both inside  and  outside  character
+       classes.
+
+   Non-printing characters
+
+       A second use of backslash provides a way of encoding non-printing char-
+       acters in patterns in a visible manner. There is no restriction on  the
+       appearance  of non-printing characters, apart from the binary zero that
+       terminates a pattern, but when a pattern  is  being  prepared  by  text
+       editing,  it  is  usually  easier  to  use  one of the following escape
+       sequences than the binary character it represents:
+
+         \a        alarm, that is, the BEL character (hex 07)
+         \cx       "control-x", where x is any character
+         \e        escape (hex 1B)
+         \f        formfeed (hex 0C)
+         \n        linefeed (hex 0A)
+         \r        carriage return (hex 0D)
+         \t        tab (hex 09)
+         \ddd      character with octal code ddd, or backreference
+         \xhh      character with hex code hh
+         \x{hhh..} character with hex code hhh..
+
+       The precise effect of \cx is as follows: if x is a lower  case  letter,
+       it  is converted to upper case. Then bit 6 of the character (hex 40) is
+       inverted.  Thus \cz becomes hex 1A, but \c{ becomes hex 3B,  while  \c;
+       becomes hex 7B.
+
+       After  \x, from zero to two hexadecimal digits are read (letters can be
+       in upper or lower case). Any number of hexadecimal  digits  may  appear
+       between  \x{  and  },  but the value of the character code must be less
+       than 256 in non-UTF-8 mode, and less than 2**31 in UTF-8 mode. That is,
+       the  maximum value in hexadecimal is 7FFFFFFF. Note that this is bigger
+       than the largest Unicode code point, which is 10FFFF.
+
+       If characters other than hexadecimal digits appear between \x{  and  },
+       or if there is no terminating }, this form of escape is not recognized.
+       Instead, the initial \x will be  interpreted  as  a  basic  hexadecimal
+       escape,  with  no  following  digits, giving a character whose value is
+       zero.
+
+       Characters whose value is less than 256 can be defined by either of the
+       two  syntaxes  for  \x. There is no difference in the way they are han-
+       dled. For example, \xdc is exactly the same as \x{dc}.
+
+       After \0 up to two further octal digits are read. If  there  are  fewer
+       than  two  digits,  just  those  that  are  present  are used. Thus the
+       sequence \0\x\07 specifies two binary zeros followed by a BEL character
+       (code  value 7). Make sure you supply two digits after the initial zero
+       if the pattern character that follows is itself an octal digit.
+
+       The handling of a backslash followed by a digit other than 0 is compli-
+       cated.  Outside a character class, PCRE reads it and any following dig-
+       its as a decimal number. If the number is less than  10,  or  if  there
+       have been at least that many previous capturing left parentheses in the
+       expression, the entire  sequence  is  taken  as  a  back  reference.  A
+       description  of how this works is given later, following the discussion
+       of parenthesized subpatterns.
+
+       Inside a character class, or if the decimal number is  greater  than  9
+       and  there have not been that many capturing subpatterns, PCRE re-reads
+       up to three octal digits following the backslash, and uses them to gen-
+       erate  a data character. Any subsequent digits stand for themselves. In
+       non-UTF-8 mode, the value of a character specified  in  octal  must  be
+       less  than  \400.  In  UTF-8 mode, values up to \777 are permitted. For
+       example:
+
+         \040   is another way of writing a space
+         \40    is the same, provided there are fewer than 40
+                   previous capturing subpatterns
+         \7     is always a back reference
+         \11    might be a back reference, or another way of
+                   writing a tab
+         \011   is always a tab
+         \0113  is a tab followed by the character "3"
+         \113   might be a back reference, otherwise the
+                   character with octal code 113
+         \377   might be a back reference, otherwise
+                   the byte consisting entirely of 1 bits
+         \81    is either a back reference, or a binary zero
+                   followed by the two characters "8" and "1"
+
+       Note that octal values of 100 or greater must not be  introduced  by  a
+       leading zero, because no more than three octal digits are ever read.
+
+       All the sequences that define a single character value can be used both
+       inside and outside character classes. In addition, inside  a  character
+       class,  the  sequence \b is interpreted as the backspace character (hex
+       08), and the sequences \R and \X are interpreted as the characters  "R"
+       and  "X", respectively. Outside a character class, these sequences have
+       different meanings (see below).
+
+   Absolute and relative back references
+
+       The sequence \g followed by an unsigned or a negative  number,  option-
+       ally  enclosed  in braces, is an absolute or relative back reference. A
+       named back reference can be coded as \g{name}. Back references are dis-
+       cussed later, following the discussion of parenthesized subpatterns.
+
+   Absolute and relative subroutine calls
+
+       For  compatibility with Oniguruma, the non-Perl syntax \g followed by a
+       name or a number enclosed either in angle brackets or single quotes, is
+       an  alternative  syntax for referencing a subpattern as a "subroutine".
+       Details are discussed later.   Note  that  \g{...}  (Perl  syntax)  and
+       \g<...>  (Oniguruma  syntax)  are  not synonymous. The former is a back
+       reference; the latter is a subroutine call.
+
+   Generic character types
+
+       Another use of backslash is for specifying generic character types. The
+       following are always recognized:
+
+         \d     any decimal digit
+         \D     any character that is not a decimal digit
+         \h     any horizontal whitespace character
+         \H     any character that is not a horizontal whitespace character
+         \s     any whitespace character
+         \S     any character that is not a whitespace character
+         \v     any vertical whitespace character
+         \V     any character that is not a vertical whitespace character
+         \w     any "word" character
+         \W     any "non-word" character
+
+       Each pair of escape sequences partitions the complete set of characters
+       into two disjoint sets. Any given character matches one, and only  one,
+       of each pair.
+
+       These character type sequences can appear both inside and outside char-
+       acter classes. They each match one character of the  appropriate  type.
+       If  the current matching point is at the end of the subject string, all
+       of them fail, since there is no character to match.
+
+       For compatibility with Perl, \s does not match the VT  character  (code
+       11).   This makes it different from the the POSIX "space" class. The \s
+       characters are HT (9), LF (10), FF (12), CR (13), and  space  (32).  If
+       "use locale;" is included in a Perl script, \s may match the VT charac-
+       ter. In PCRE, it never does.
+
+       In UTF-8 mode, characters with values greater than 128 never match  \d,
+       \s, or \w, and always match \D, \S, and \W. This is true even when Uni-
+       code character property support is available.  These  sequences  retain
+       their original meanings from before UTF-8 support was available, mainly
+       for efficiency reasons.
+
+       The sequences \h, \H, \v, and \V are Perl 5.10 features. In contrast to
+       the  other  sequences, these do match certain high-valued codepoints in
+       UTF-8 mode.  The horizontal space characters are:
+
+         U+0009     Horizontal tab
+         U+0020     Space
+         U+00A0     Non-break space
+         U+1680     Ogham space mark
+         U+180E     Mongolian vowel separator
+         U+2000     En quad
+         U+2001     Em quad
+         U+2002     En space
+         U+2003     Em space
+         U+2004     Three-per-em space
+         U+2005     Four-per-em space
+         U+2006     Six-per-em space
+         U+2007     Figure space
+         U+2008     Punctuation space
+         U+2009     Thin space
+         U+200A     Hair space
+         U+202F     Narrow no-break space
+         U+205F     Medium mathematical space
+         U+3000     Ideographic space
+
+       The vertical space characters are:
+
+         U+000A     Linefeed
+         U+000B     Vertical tab
+         U+000C     Formfeed
+         U+000D     Carriage return
+         U+0085     Next line
+         U+2028     Line separator
+         U+2029     Paragraph separator
+
+       A "word" character is an underscore or any character less than 256 that
+       is  a  letter  or  digit.  The definition of letters and digits is con-
+       trolled by PCRE's low-valued character tables, and may vary if  locale-
+       specific  matching is taking place (see "Locale support" in the pcreapi
+       page). For example, in a French locale such  as  "fr_FR"  in  Unix-like
+       systems,  or "french" in Windows, some character codes greater than 128
+       are used for accented letters, and these are matched by \w. The use  of
+       locales with Unicode is discouraged.
+
+   Newline sequences
+
+       Outside  a  character class, by default, the escape sequence \R matches
+       any Unicode newline sequence. This is a Perl 5.10 feature. In non-UTF-8
+       mode \R is equivalent to the following:
+
+         (?>\r\n|\n|\x0b|\f|\r|\x85)
+
+       This  is  an  example  of an "atomic group", details of which are given
+       below.  This particular group matches either the two-character sequence
+       CR  followed  by  LF,  or  one  of  the single characters LF (linefeed,
+       U+000A), VT (vertical tab, U+000B), FF (formfeed, U+000C), CR (carriage
+       return, U+000D), or NEL (next line, U+0085). The two-character sequence
+       is treated as a single unit that cannot be split.
+
+       In UTF-8 mode, two additional characters whose codepoints  are  greater
+       than 255 are added: LS (line separator, U+2028) and PS (paragraph sepa-
+       rator, U+2029).  Unicode character property support is not  needed  for
+       these characters to be recognized.
+
+       It is possible to restrict \R to match only CR, LF, or CRLF (instead of
+       the complete set  of  Unicode  line  endings)  by  setting  the  option
+       PCRE_BSR_ANYCRLF either at compile time or when the pattern is matched.
+       (BSR is an abbrevation for "backslash R".) This can be made the default
+       when  PCRE  is  built;  if this is the case, the other behaviour can be
+       requested via the PCRE_BSR_UNICODE option.   It  is  also  possible  to
+       specify  these  settings  by  starting a pattern string with one of the
+       following sequences:
+
+         (*BSR_ANYCRLF)   CR, LF, or CRLF only
+         (*BSR_UNICODE)   any Unicode newline sequence
+
+       These override the default and the options given to pcre_compile(), but
+       they can be overridden by options given to pcre_exec(). Note that these
+       special settings, which are not Perl-compatible, are recognized only at
+       the  very  start  of a pattern, and that they must be in upper case. If
+       more than one of them is present, the last one is  used.  They  can  be
+       combined  with  a  change of newline convention, for example, a pattern
+       can start with:
+
+         (*ANY)(*BSR_ANYCRLF)
+
+       Inside a character class, \R matches the letter "R".
+
+   Unicode character properties
+
+       When PCRE is built with Unicode character property support, three addi-
+       tional  escape sequences that match characters with specific properties
+       are available.  When not in UTF-8 mode, these sequences are  of  course
+       limited  to  testing characters whose codepoints are less than 256, but
+       they do work in this mode.  The extra escape sequences are:
+
+         \p{xx}   a character with the xx property
+         \P{xx}   a character without the xx property
+         \X       an extended Unicode sequence
+
+       The property names represented by xx above are limited to  the  Unicode
+       script names, the general category properties, and "Any", which matches
+       any character (including newline). Other properties such as "InMusical-
+       Symbols"  are  not  currently supported by PCRE. Note that \P{Any} does
+       not match any characters, so always causes a match failure.
+
+       Sets of Unicode characters are defined as belonging to certain scripts.
+       A  character from one of these sets can be matched using a script name.
+       For example:
+
+         \p{Greek}
+         \P{Han}
+
+       Those that are not part of an identified script are lumped together  as
+       "Common". The current list of scripts is:
+
+       Arabic,  Armenian,  Balinese,  Bengali,  Bopomofo,  Braille,  Buginese,
+       Buhid,  Canadian_Aboriginal,  Cherokee,  Common,   Coptic,   Cuneiform,
+       Cypriot, Cyrillic, Deseret, Devanagari, Ethiopic, Georgian, Glagolitic,
+       Gothic, Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew,  Hira-
+       gana,  Inherited,  Kannada,  Katakana,  Kharoshthi,  Khmer, Lao, Latin,
+       Limbu,  Linear_B,  Malayalam,  Mongolian,  Myanmar,  New_Tai_Lue,  Nko,
+       Ogham,  Old_Italic,  Old_Persian, Oriya, Osmanya, Phags_Pa, Phoenician,
+       Runic,  Shavian,  Sinhala,  Syloti_Nagri,  Syriac,  Tagalog,  Tagbanwa,
+       Tai_Le, Tamil, Telugu, Thaana, Thai, Tibetan, Tifinagh, Ugaritic, Yi.
+
+       Each  character has exactly one general category property, specified by
+       a two-letter abbreviation. For compatibility with Perl, negation can be
+       specified  by  including a circumflex between the opening brace and the
+       property name. For example, \p{^Lu} is the same as \P{Lu}.
+
+       If only one letter is specified with \p or \P, it includes all the gen-
+       eral  category properties that start with that letter. In this case, in
+       the absence of negation, the curly brackets in the escape sequence  are
+       optional; these two examples have the same effect:
+
+         \p{L}
+         \pL
+
+       The following general category property codes are supported:
+
+         C     Other
+         Cc    Control
+         Cf    Format
+         Cn    Unassigned
+         Co    Private use
+         Cs    Surrogate
+
+         L     Letter
+         Ll    Lower case letter
+         Lm    Modifier letter
+         Lo    Other letter
+         Lt    Title case letter
+         Lu    Upper case letter
+
+         M     Mark
+         Mc    Spacing mark
+         Me    Enclosing mark
+         Mn    Non-spacing mark
+
+         N     Number
+         Nd    Decimal number
+         Nl    Letter number
+         No    Other number
+
+         P     Punctuation
+         Pc    Connector punctuation
+         Pd    Dash punctuation
+         Pe    Close punctuation
+         Pf    Final punctuation
+         Pi    Initial punctuation
+         Po    Other punctuation
+         Ps    Open punctuation
+
+         S     Symbol
+         Sc    Currency symbol
+         Sk    Modifier symbol
+         Sm    Mathematical symbol
+         So    Other symbol
+
+         Z     Separator
+         Zl    Line separator
+         Zp    Paragraph separator
+         Zs    Space separator
+
+       The  special property L& is also supported: it matches a character that
+       has the Lu, Ll, or Lt property, in other words, a letter  that  is  not
+       classified as a modifier or "other".
+
+       The  Cs  (Surrogate)  property  applies only to characters in the range
+       U+D800 to U+DFFF. Such characters are not valid in UTF-8  strings  (see
+       RFC 3629) and so cannot be tested by PCRE, unless UTF-8 validity check-
+       ing has been turned off (see the discussion  of  PCRE_NO_UTF8_CHECK  in
+       the pcreapi page).
+
+       The  long  synonyms  for  these  properties that Perl supports (such as
+       \p{Letter}) are not supported by PCRE, nor is it  permitted  to  prefix
+       any of these properties with "Is".
+
+       No character that is in the Unicode table has the Cn (unassigned) prop-
+       erty.  Instead, this property is assumed for any code point that is not
+       in the Unicode table.
+
+       Specifying  caseless  matching  does not affect these escape sequences.
+       For example, \p{Lu} always matches only upper case letters.
+
+       The \X escape matches any number of Unicode  characters  that  form  an
+       extended Unicode sequence. \X is equivalent to
+
+         (?>\PM\pM*)
+
+       That  is,  it matches a character without the "mark" property, followed
+       by zero or more characters with the "mark"  property,  and  treats  the
+       sequence  as  an  atomic group (see below).  Characters with the "mark"
+       property are typically accents that  affect  the  preceding  character.
+       None  of  them  have  codepoints less than 256, so in non-UTF-8 mode \X
+       matches any one character.
+
+       Matching characters by Unicode property is not fast, because  PCRE  has
+       to  search  a  structure  that  contains data for over fifteen thousand
+       characters. That is why the traditional escape sequences such as \d and
+       \w do not use Unicode properties in PCRE.
+
+   Resetting the match start
+
+       The escape sequence \K, which is a Perl 5.10 feature, causes any previ-
+       ously matched characters not  to  be  included  in  the  final  matched
+       sequence. For example, the pattern:
+
+         foo\Kbar
+
+       matches  "foobar",  but reports that it has matched "bar". This feature
+       is similar to a lookbehind assertion (described  below).   However,  in
+       this  case, the part of the subject before the real match does not have
+       to be of fixed length, as lookbehind assertions do. The use of \K  does
+       not  interfere  with  the setting of captured substrings.  For example,
+       when the pattern
+
+         (foo)\Kbar
+
+       matches "foobar", the first substring is still set to "foo".
+
+   Simple assertions
+
+       The final use of backslash is for certain simple assertions. An  asser-
+       tion  specifies a condition that has to be met at a particular point in
+       a match, without consuming any characters from the subject string.  The
+       use  of subpatterns for more complicated assertions is described below.
+       The backslashed assertions are:
+
+         \b     matches at a word boundary
+         \B     matches when not at a word boundary
+         \A     matches at the start of the subject
+         \Z     matches at the end of the subject
+                 also matches before a newline at the end of the subject
+         \z     matches only at the end of the subject
+         \G     matches at the first matching position in the subject
+
+       These assertions may not appear in character classes (but note that  \b
+       has a different meaning, namely the backspace character, inside a char-
+       acter class).
+
+       A word boundary is a position in the subject string where  the  current
+       character  and  the previous character do not both match \w or \W (i.e.
+       one matches \w and the other matches \W), or the start or  end  of  the
+       string if the first or last character matches \w, respectively.
+
+       The  \A,  \Z,  and \z assertions differ from the traditional circumflex
+       and dollar (described in the next section) in that they only ever match
+       at  the  very start and end of the subject string, whatever options are
+       set. Thus, they are independent of multiline mode. These  three  asser-
+       tions are not affected by the PCRE_NOTBOL or PCRE_NOTEOL options, which
+       affect only the behaviour of the circumflex and dollar  metacharacters.
+       However,  if the startoffset argument of pcre_exec() is non-zero, indi-
+       cating that matching is to start at a point other than the beginning of
+       the  subject,  \A  can never match. The difference between \Z and \z is
+       that \Z matches before a newline at the end of the string as well as at
+       the very end, whereas \z matches only at the end.
+
+       The  \G assertion is true only when the current matching position is at
+       the start point of the match, as specified by the startoffset  argument
+       of  pcre_exec().  It  differs  from \A when the value of startoffset is
+       non-zero. By calling pcre_exec() multiple times with appropriate  argu-
+       ments, you can mimic Perl's /g option, and it is in this kind of imple-
+       mentation where \G can be useful.
+
+       Note, however, that PCRE's interpretation of \G, as the  start  of  the
+       current match, is subtly different from Perl's, which defines it as the
+       end of the previous match. In Perl, these can  be  different  when  the
+       previously  matched  string was empty. Because PCRE does just one match
+       at a time, it cannot reproduce this behaviour.
+
+       If all the alternatives of a pattern begin with \G, the  expression  is
+       anchored to the starting match position, and the "anchored" flag is set
+       in the compiled regular expression.
+
+
+CIRCUMFLEX AND DOLLAR
+
+       Outside a character class, in the default matching mode, the circumflex
+       character  is  an  assertion  that is true only if the current matching
+       point is at the start of the subject string. If the  startoffset  argu-
+       ment  of  pcre_exec()  is  non-zero,  circumflex can never match if the
+       PCRE_MULTILINE option is unset. Inside a  character  class,  circumflex
+       has an entirely different meaning (see below).
+
+       Circumflex  need  not be the first character of the pattern if a number
+       of alternatives are involved, but it should be the first thing in  each
+       alternative  in  which  it appears if the pattern is ever to match that
+       branch. If all possible alternatives start with a circumflex, that  is,
+       if  the  pattern  is constrained to match only at the start of the sub-
+       ject, it is said to be an "anchored" pattern.  (There  are  also  other
+       constructs that can cause a pattern to be anchored.)
+
+       A  dollar  character  is  an assertion that is true only if the current
+       matching point is at the end of  the  subject  string,  or  immediately
+       before a newline at the end of the string (by default). Dollar need not
+       be the last character of the pattern if a number  of  alternatives  are
+       involved,  but  it  should  be  the last item in any branch in which it
+       appears. Dollar has no special meaning in a character class.
+
+       The meaning of dollar can be changed so that it  matches  only  at  the
+       very  end  of  the string, by setting the PCRE_DOLLAR_ENDONLY option at
+       compile time. This does not affect the \Z assertion.
+
+       The meanings of the circumflex and dollar characters are changed if the
+       PCRE_MULTILINE  option  is  set.  When  this  is the case, a circumflex
+       matches immediately after internal newlines as well as at the start  of
+       the  subject  string.  It  does not match after a newline that ends the
+       string. A dollar matches before any newlines in the string, as well  as
+       at  the very end, when PCRE_MULTILINE is set. When newline is specified
+       as the two-character sequence CRLF, isolated CR and  LF  characters  do
+       not indicate newlines.
+
+       For  example, the pattern /^abc$/ matches the subject string "def\nabc"
+       (where \n represents a newline) in multiline mode, but  not  otherwise.
+       Consequently,  patterns  that  are anchored in single line mode because
+       all branches start with ^ are not anchored in  multiline  mode,  and  a
+       match  for  circumflex  is  possible  when  the startoffset argument of
+       pcre_exec() is non-zero. The PCRE_DOLLAR_ENDONLY option is  ignored  if
+       PCRE_MULTILINE is set.
+
+       Note  that  the sequences \A, \Z, and \z can be used to match the start
+       and end of the subject in both modes, and if all branches of a  pattern
+       start  with  \A it is always anchored, whether or not PCRE_MULTILINE is
+       set.
+
+
+FULL STOP (PERIOD, DOT)
+
+       Outside a character class, a dot in the pattern matches any one charac-
+       ter  in  the subject string except (by default) a character that signi-
+       fies the end of a line. In UTF-8 mode, the  matched  character  may  be
+       more than one byte long.
+
+       When  a line ending is defined as a single character, dot never matches
+       that character; when the two-character sequence CRLF is used, dot  does
+       not  match  CR  if  it  is immediately followed by LF, but otherwise it
+       matches all characters (including isolated CRs and LFs). When any  Uni-
+       code  line endings are being recognized, dot does not match CR or LF or
+       any of the other line ending characters.
+
+       The behaviour of dot with regard to newlines can  be  changed.  If  the
+       PCRE_DOTALL  option  is  set,  a dot matches any one character, without
+       exception. If the two-character sequence CRLF is present in the subject
+       string, it takes two dots to match it.
+
+       The  handling of dot is entirely independent of the handling of circum-
+       flex and dollar, the only relationship being  that  they  both  involve
+       newlines. Dot has no special meaning in a character class.
+
+
+MATCHING A SINGLE BYTE
+
+       Outside a character class, the escape sequence \C matches any one byte,
+       both in and out of UTF-8 mode. Unlike a  dot,  it  always  matches  any
+       line-ending  characters.  The  feature  is provided in Perl in order to
+       match individual bytes in UTF-8 mode. Because it breaks up UTF-8  char-
+       acters  into individual bytes, what remains in the string may be a mal-
+       formed UTF-8 string. For this reason, the \C escape  sequence  is  best
+       avoided.
+
+       PCRE  does  not  allow \C to appear in lookbehind assertions (described
+       below), because in UTF-8 mode this would make it impossible  to  calcu-
+       late the length of the lookbehind.
+
+
+SQUARE BRACKETS AND CHARACTER CLASSES
+
+       An opening square bracket introduces a character class, terminated by a
+       closing square bracket. A closing square bracket on its own is not spe-
+       cial. If a closing square bracket is required as a member of the class,
+       it should be the first data character in the class  (after  an  initial
+       circumflex, if present) or escaped with a backslash.
+
+       A  character  class matches a single character in the subject. In UTF-8
+       mode, the character may occupy more than one byte. A matched  character
+       must be in the set of characters defined by the class, unless the first
+       character in the class definition is a circumflex, in  which  case  the
+       subject  character  must  not  be in the set defined by the class. If a
+       circumflex is actually required as a member of the class, ensure it  is
+       not the first character, or escape it with a backslash.
+
+       For  example, the character class [aeiou] matches any lower case vowel,
+       while [^aeiou] matches any character that is not a  lower  case  vowel.
+       Note that a circumflex is just a convenient notation for specifying the
+       characters that are in the class by enumerating those that are  not.  A
+       class  that starts with a circumflex is not an assertion: it still con-
+       sumes a character from the subject string, and therefore  it  fails  if
+       the current pointer is at the end of the string.
+
+       In  UTF-8 mode, characters with values greater than 255 can be included
+       in a class as a literal string of bytes, or by using the  \x{  escaping
+       mechanism.
+
+       When  caseless  matching  is set, any letters in a class represent both
+       their upper case and lower case versions, so for  example,  a  caseless
+       [aeiou]  matches  "A"  as well as "a", and a caseless [^aeiou] does not
+       match "A", whereas a caseful version would. In UTF-8 mode, PCRE  always
+       understands  the  concept  of case for characters whose values are less
+       than 128, so caseless matching is always possible. For characters  with
+       higher  values,  the  concept  of case is supported if PCRE is compiled
+       with Unicode property support, but not otherwise.  If you want  to  use
+       caseless  matching  for  characters 128 and above, you must ensure that
+       PCRE is compiled with Unicode property support as well  as  with  UTF-8
+       support.
+
+       Characters  that  might  indicate  line breaks are never treated in any
+       special way  when  matching  character  classes,  whatever  line-ending
+       sequence  is  in  use,  and  whatever  setting  of  the PCRE_DOTALL and
+       PCRE_MULTILINE options is used. A class such as [^a] always matches one
+       of these characters.
+
+       The  minus (hyphen) character can be used to specify a range of charac-
+       ters in a character  class.  For  example,  [d-m]  matches  any  letter
+       between  d  and  m,  inclusive.  If  a minus character is required in a
+       class, it must be escaped with a backslash  or  appear  in  a  position
+       where  it cannot be interpreted as indicating a range, typically as the
+       first or last character in the class.
+
+       It is not possible to have the literal character "]" as the end charac-
+       ter  of a range. A pattern such as [W-]46] is interpreted as a class of
+       two characters ("W" and "-") followed by a literal string "46]", so  it
+       would  match  "W46]"  or  "-46]". However, if the "]" is escaped with a
+       backslash it is interpreted as the end of range, so [W-\]46] is  inter-
+       preted  as a class containing a range followed by two other characters.
+       The octal or hexadecimal representation of "]" can also be used to  end
+       a range.
+
+       Ranges  operate in the collating sequence of character values. They can
+       also  be  used  for  characters  specified  numerically,  for   example
+       [\000-\037].  In UTF-8 mode, ranges can include characters whose values
+       are greater than 255, for example [\x{100}-\x{2ff}].
+
+       If a range that includes letters is used when caseless matching is set,
+       it matches the letters in either case. For example, [W-c] is equivalent
+       to [][\\^_`wxyzabc], matched caselessly,  and  in  non-UTF-8  mode,  if
+       character  tables  for  a French locale are in use, [\xc8-\xcb] matches
+       accented E characters in both cases. In UTF-8 mode, PCRE  supports  the
+       concept  of  case for characters with values greater than 128 only when
+       it is compiled with Unicode property support.
+
+       The character types \d, \D, \p, \P, \s, \S, \w, and \W may also  appear
+       in  a  character  class,  and add the characters that they match to the
+       class. For example, [\dABCDEF] matches any hexadecimal digit. A circum-
+       flex  can  conveniently  be used with the upper case character types to
+       specify a more restricted set of characters  than  the  matching  lower
+       case  type.  For example, the class [^\W_] matches any letter or digit,
+       but not underscore.
+
+       The only metacharacters that are recognized in  character  classes  are
+       backslash,  hyphen  (only  where  it can be interpreted as specifying a
+       range), circumflex (only at the start), opening  square  bracket  (only
+       when  it can be interpreted as introducing a POSIX class name - see the
+       next section), and the terminating  closing  square  bracket.  However,
+       escaping other non-alphanumeric characters does no harm.
+
+
+POSIX CHARACTER CLASSES
+
+       Perl supports the POSIX notation for character classes. This uses names
+       enclosed by [: and :] within the enclosing square brackets.  PCRE  also
+       supports this notation. For example,
+
+         [01[:alpha:]%]
+
+       matches "0", "1", any alphabetic character, or "%". The supported class
+       names are
+
+         alnum    letters and digits
+         alpha    letters
+         ascii    character codes 0 - 127
+         blank    space or tab only
+         cntrl    control characters
+         digit    decimal digits (same as \d)
+         graph    printing characters, excluding space
+         lower    lower case letters
+         print    printing characters, including space
+         punct    printing characters, excluding letters and digits
+         space    white space (not quite the same as \s)
+         upper    upper case letters
+         word     "word" characters (same as \w)
+         xdigit   hexadecimal digits
+
+       The "space" characters are HT (9), LF (10), VT (11), FF (12), CR  (13),
+       and  space  (32). Notice that this list includes the VT character (code
+       11). This makes "space" different to \s, which does not include VT (for
+       Perl compatibility).
+
+       The  name  "word"  is  a Perl extension, and "blank" is a GNU extension
+       from Perl 5.8. Another Perl extension is negation, which  is  indicated
+       by a ^ character after the colon. For example,
+
+         [12[:^digit:]]
+
+       matches  "1", "2", or any non-digit. PCRE (and Perl) also recognize the
+       POSIX syntax [.ch.] and [=ch=] where "ch" is a "collating element", but
+       these are not supported, and an error is given if they are encountered.
+
+       In UTF-8 mode, characters with values greater than 128 do not match any
+       of the POSIX character classes.
+
+
+VERTICAL BAR
+
+       Vertical  bar characters are used to separate alternative patterns. For
+       example, the pattern
+
+         gilbert|sullivan
+
+       matches either "gilbert" or "sullivan". Any number of alternatives  may
+       appear,  and  an  empty  alternative  is  permitted (matching the empty
+       string). The matching process tries each alternative in turn, from left
+       to  right, and the first one that succeeds is used. If the alternatives
+       are within a subpattern (defined below), "succeeds" means matching  the
+       rest  of the main pattern as well as the alternative in the subpattern.
+
+
+INTERNAL OPTION SETTING
+
+       The settings of the  PCRE_CASELESS,  PCRE_MULTILINE,  PCRE_DOTALL,  and
+       PCRE_EXTENDED  options  (which are Perl-compatible) can be changed from
+       within the pattern by  a  sequence  of  Perl  option  letters  enclosed
+       between "(?" and ")".  The option letters are
+
+         i  for PCRE_CASELESS
+         m  for PCRE_MULTILINE
+         s  for PCRE_DOTALL
+         x  for PCRE_EXTENDED
+
+       For example, (?im) sets caseless, multiline matching. It is also possi-
+       ble to unset these options by preceding the letter with a hyphen, and a
+       combined  setting and unsetting such as (?im-sx), which sets PCRE_CASE-
+       LESS and PCRE_MULTILINE while unsetting PCRE_DOTALL and  PCRE_EXTENDED,
+       is  also  permitted.  If  a  letter  appears  both before and after the
+       hyphen, the option is unset.
+
+       The PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and  PCRE_EXTRA
+       can  be changed in the same way as the Perl-compatible options by using
+       the characters J, U and X respectively.
+
+       When an option change occurs at top level (that is, not inside  subpat-
+       tern  parentheses),  the change applies to the remainder of the pattern
+       that follows.  If the change is placed right at the start of a pattern,
+       PCRE extracts it into the global options (and it will therefore show up
+       in data extracted by the pcre_fullinfo() function).
+
+       An option change within a subpattern (see below for  a  description  of
+       subpatterns) affects only that part of the current pattern that follows
+       it, so
+
+         (a(?i)b)c
+
+       matches abc and aBc and no other strings (assuming PCRE_CASELESS is not
+       used).   By  this means, options can be made to have different settings
+       in different parts of the pattern. Any changes made in one  alternative
+       do  carry  on  into subsequent branches within the same subpattern. For
+       example,
+
+         (a(?i)b|c)
+
+       matches "ab", "aB", "c", and "C", even though  when  matching  "C"  the
+       first  branch  is  abandoned before the option setting. This is because
+       the effects of option settings happen at compile time. There  would  be
+       some very weird behaviour otherwise.
+
+       Note:  There  are  other  PCRE-specific  options that can be set by the
+       application when the compile or match functions  are  called.  In  some
+       cases  the  pattern  can  contain special leading sequences to override
+       what the application has set or what has been  defaulted.  Details  are
+       given in the section entitled "Newline sequences" above.
+
+
+SUBPATTERNS
+
+       Subpatterns are delimited by parentheses (round brackets), which can be
+       nested.  Turning part of a pattern into a subpattern does two things:
+
+       1. It localizes a set of alternatives. For example, the pattern
+
+         cat(aract|erpillar|)
+
+       matches one of the words "cat", "cataract", or  "caterpillar".  Without
+       the  parentheses,  it  would  match  "cataract", "erpillar" or an empty
+       string.
+
+       2. It sets up the subpattern as  a  capturing  subpattern.  This  means
+       that,  when  the  whole  pattern  matches,  that portion of the subject
+       string that matched the subpattern is passed back to the caller via the
+       ovector  argument  of pcre_exec(). Opening parentheses are counted from
+       left to right (starting from 1) to obtain  numbers  for  the  capturing
+       subpatterns.
+
+       For  example,  if the string "the red king" is matched against the pat-
+       tern
+
+         the ((red|white) (king|queen))
+
+       the captured substrings are "red king", "red", and "king", and are num-
+       bered 1, 2, and 3, respectively.
+
+       The  fact  that  plain  parentheses  fulfil two functions is not always
+       helpful.  There are often times when a grouping subpattern is  required
+       without  a capturing requirement. If an opening parenthesis is followed
+       by a question mark and a colon, the subpattern does not do any  captur-
+       ing,  and  is  not  counted when computing the number of any subsequent
+       capturing subpatterns. For example, if the string "the white queen"  is
+       matched against the pattern
+
+         the ((?:red|white) (king|queen))
+
+       the captured substrings are "white queen" and "queen", and are numbered
+       1 and 2. The maximum number of capturing subpatterns is 65535.
+
+       As a convenient shorthand, if any option settings are required  at  the
+       start  of  a  non-capturing  subpattern,  the option letters may appear
+       between the "?" and the ":". Thus the two patterns
+
+         (?i:saturday|sunday)
+         (?:(?i)saturday|sunday)
+
+       match exactly the same set of strings. Because alternative branches are
+       tried  from  left  to right, and options are not reset until the end of
+       the subpattern is reached, an option setting in one branch does  affect
+       subsequent  branches,  so  the above patterns match "SUNDAY" as well as
+       "Saturday".
+
+
+DUPLICATE SUBPATTERN NUMBERS
+
+       Perl 5.10 introduced a feature whereby each alternative in a subpattern
+       uses  the same numbers for its capturing parentheses. Such a subpattern
+       starts with (?| and is itself a non-capturing subpattern. For  example,
+       consider this pattern:
+
+         (?|(Sat)ur|(Sun))day
+
+       Because  the two alternatives are inside a (?| group, both sets of cap-
+       turing parentheses are numbered one. Thus, when  the  pattern  matches,
+       you  can  look  at captured substring number one, whichever alternative
+       matched. This construct is useful when you want to  capture  part,  but
+       not all, of one of a number of alternatives. Inside a (?| group, paren-
+       theses are numbered as usual, but the number is reset at the  start  of
+       each  branch. The numbers of any capturing buffers that follow the sub-
+       pattern start after the highest number used in any branch. The  follow-
+       ing  example  is taken from the Perl documentation.  The numbers under-
+       neath show in which buffer the captured content will be stored.
+
+         # before  ---------------branch-reset----------- after
+         / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
+         # 1            2         2  3        2     3     4
+
+       A backreference or a recursive call to  a  numbered  subpattern  always
+       refers to the first one in the pattern with the given number.
+
+       An  alternative approach to using this "branch reset" feature is to use
+       duplicate named subpatterns, as described in the next section.
+
+
+NAMED SUBPATTERNS
+
+       Identifying capturing parentheses by number is simple, but  it  can  be
+       very  hard  to keep track of the numbers in complicated regular expres-
+       sions. Furthermore, if an  expression  is  modified,  the  numbers  may
+       change.  To help with this difficulty, PCRE supports the naming of sub-
+       patterns. This feature was not added to Perl until release 5.10. Python
+       had  the  feature earlier, and PCRE introduced it at release 4.0, using
+       the Python syntax. PCRE now supports both the Perl and the Python  syn-
+       tax.
+
+       In  PCRE,  a subpattern can be named in one of three ways: (?<name>...)
+       or (?'name'...) as in Perl, or (?P<name>...) as in  Python.  References
+       to capturing parentheses from other parts of the pattern, such as back-
+       references, recursion, and conditions, can be made by name as  well  as
+       by number.
+
+       Names  consist  of  up  to  32 alphanumeric characters and underscores.
+       Named capturing parentheses are still  allocated  numbers  as  well  as
+       names,  exactly as if the names were not present. The PCRE API provides
+       function calls for extracting the name-to-number translation table from
+       a compiled pattern. There is also a convenience function for extracting
+       a captured substring by name.
+
+       By default, a name must be unique within a pattern, but it is  possible
+       to relax this constraint by setting the PCRE_DUPNAMES option at compile
+       time. This can be useful for patterns where only one  instance  of  the
+       named  parentheses  can  match. Suppose you want to match the name of a
+       weekday, either as a 3-letter abbreviation or as the full name, and  in
+       both cases you want to extract the abbreviation. This pattern (ignoring
+       the line breaks) does the job:
+
+         (?<DN>Mon|Fri|Sun)(?:day)?|
+         (?<DN>Tue)(?:sday)?|
+         (?<DN>Wed)(?:nesday)?|
+         (?<DN>Thu)(?:rsday)?|
+         (?<DN>Sat)(?:urday)?
+
+       There are five capturing substrings, but only one is ever set  after  a
+       match.  (An alternative way of solving this problem is to use a "branch
+       reset" subpattern, as described in the previous section.)
+
+       The convenience function for extracting the data by  name  returns  the
+       substring  for  the first (and in this example, the only) subpattern of
+       that name that matched. This saves searching  to  find  which  numbered
+       subpattern  it  was. If you make a reference to a non-unique named sub-
+       pattern from elsewhere in the pattern, the one that corresponds to  the
+       lowest  number  is used. For further details of the interfaces for han-
+       dling named subpatterns, see the pcreapi documentation.
+
+
+REPETITION
+
+       Repetition is specified by quantifiers, which can  follow  any  of  the
+       following items:
+
+         a literal data character
+         the dot metacharacter
+         the \C escape sequence
+         the \X escape sequence (in UTF-8 mode with Unicode properties)
+         the \R escape sequence
+         an escape such as \d that matches a single character
+         a character class
+         a back reference (see next section)
+         a parenthesized subpattern (unless it is an assertion)
+
+       The  general repetition quantifier specifies a minimum and maximum num-
+       ber of permitted matches, by giving the two numbers in  curly  brackets
+       (braces),  separated  by  a comma. The numbers must be less than 65536,
+       and the first must be less than or equal to the second. For example:
+
+         z{2,4}
+
+       matches "zz", "zzz", or "zzzz". A closing brace on its  own  is  not  a
+       special  character.  If  the second number is omitted, but the comma is
+       present, there is no upper limit; if the second number  and  the  comma
+       are  both omitted, the quantifier specifies an exact number of required
+       matches. Thus
+
+         [aeiou]{3,}
+
+       matches at least 3 successive vowels, but may match many more, while
+
+         \d{8}
+
+       matches exactly 8 digits. An opening curly bracket that  appears  in  a
+       position  where a quantifier is not allowed, or one that does not match
+       the syntax of a quantifier, is taken as a literal character. For  exam-
+       ple, {,6} is not a quantifier, but a literal string of four characters.
+
+       In UTF-8 mode, quantifiers apply to UTF-8  characters  rather  than  to
+       individual bytes. Thus, for example, \x{100}{2} matches two UTF-8 char-
+       acters, each of which is represented by a two-byte sequence. Similarly,
+       when Unicode property support is available, \X{3} matches three Unicode
+       extended sequences, each of which may be several bytes long  (and  they
+       may be of different lengths).
+
+       The quantifier {0} is permitted, causing the expression to behave as if
+       the previous item and the quantifier were not present. This may be use-
+       ful  for  subpatterns that are referenced as subroutines from elsewhere
+       in the pattern. Items other than subpatterns that have a {0} quantifier
+       are omitted from the compiled pattern.
+
+       For  convenience, the three most common quantifiers have single-charac-
+       ter abbreviations:
+
+         *    is equivalent to {0,}
+         +    is equivalent to {1,}
+         ?    is equivalent to {0,1}
+
+       It is possible to construct infinite loops by  following  a  subpattern
+       that can match no characters with a quantifier that has no upper limit,
+       for example:
+
+         (a?)*
+
+       Earlier versions of Perl and PCRE used to give an error at compile time
+       for  such  patterns. However, because there are cases where this can be
+       useful, such patterns are now accepted, but if any  repetition  of  the
+       subpattern  does in fact match no characters, the loop is forcibly bro-
+       ken.
+
+       By default, the quantifiers are "greedy", that is, they match  as  much
+       as  possible  (up  to  the  maximum number of permitted times), without
+       causing the rest of the pattern to fail. The classic example  of  where
+       this gives problems is in trying to match comments in C programs. These
+       appear between /* and */ and within the comment,  individual  *  and  /
+       characters  may  appear. An attempt to match C comments by applying the
+       pattern
+
+         /\*.*\*/
+
+       to the string
+
+         /* first comment */  not comment  /* second comment */
+
+       fails, because it matches the entire string owing to the greediness  of
+       the .*  item.
+
+       However,  if  a quantifier is followed by a question mark, it ceases to
+       be greedy, and instead matches the minimum number of times possible, so
+       the pattern
+
+         /\*.*?\*/
+
+       does  the  right  thing with the C comments. The meaning of the various
+       quantifiers is not otherwise changed,  just  the  preferred  number  of
+       matches.   Do  not  confuse this use of question mark with its use as a
+       quantifier in its own right. Because it has two uses, it can  sometimes
+       appear doubled, as in
+
+         \d??\d
+
+       which matches one digit by preference, but can match two if that is the
+       only way the rest of the pattern matches.
+
+       If the PCRE_UNGREEDY option is set (an option that is not available  in
+       Perl),  the  quantifiers are not greedy by default, but individual ones
+       can be made greedy by following them with a  question  mark.  In  other
+       words, it inverts the default behaviour.
+
+       When  a  parenthesized  subpattern  is quantified with a minimum repeat
+       count that is greater than 1 or with a limited maximum, more memory  is
+       required  for  the  compiled  pattern, in proportion to the size of the
+       minimum or maximum.
+
+       If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equiv-
+       alent  to  Perl's  /s) is set, thus allowing the dot to match newlines,
+       the pattern is implicitly anchored, because whatever  follows  will  be
+       tried  against every character position in the subject string, so there
+       is no point in retrying the overall match at  any  position  after  the
+       first.  PCRE  normally treats such a pattern as though it were preceded
+       by \A.
+
+       In cases where it is known that the subject  string  contains  no  new-
+       lines,  it  is  worth setting PCRE_DOTALL in order to obtain this opti-
+       mization, or alternatively using ^ to indicate anchoring explicitly.
+
+       However, there is one situation where the optimization cannot be  used.
+       When  .*   is  inside  capturing  parentheses that are the subject of a
+       backreference elsewhere in the pattern, a match at the start  may  fail
+       where a later one succeeds. Consider, for example:
+
+         (.*)abc\1
+
+       If  the subject is "xyz123abc123" the match point is the fourth charac-
+       ter. For this reason, such a pattern is not implicitly anchored.
+
+       When a capturing subpattern is repeated, the value captured is the sub-
+       string that matched the final iteration. For example, after
+
+         (tweedle[dume]{3}\s*)+
+
+       has matched "tweedledum tweedledee" the value of the captured substring
+       is "tweedledee". However, if there are  nested  capturing  subpatterns,
+       the  corresponding captured values may have been set in previous itera-
+       tions. For example, after
+
+         /(a|(b))+/
+
+       matches "aba" the value of the second captured substring is "b".
+
+
+ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS
+
+       With both maximizing ("greedy") and minimizing ("ungreedy"  or  "lazy")
+       repetition,  failure  of what follows normally causes the repeated item
+       to be re-evaluated to see if a different number of repeats  allows  the
+       rest  of  the pattern to match. Sometimes it is useful to prevent this,
+       either to change the nature of the match, or to cause it  fail  earlier
+       than  it otherwise might, when the author of the pattern knows there is
+       no point in carrying on.
+
+       Consider, for example, the pattern \d+foo when applied to  the  subject
+       line
+
+         123456bar
+
+       After matching all 6 digits and then failing to match "foo", the normal
+       action of the matcher is to try again with only 5 digits  matching  the
+       \d+  item,  and  then  with  4,  and  so on, before ultimately failing.
+       "Atomic grouping" (a term taken from Jeffrey  Friedl's  book)  provides
+       the  means for specifying that once a subpattern has matched, it is not
+       to be re-evaluated in this way.
+
+       If we use atomic grouping for the previous example, the  matcher  gives
+       up  immediately  on failing to match "foo" the first time. The notation
+       is a kind of special parenthesis, starting with (?> as in this example:
+
+         (?>\d+)foo
+
+       This  kind  of  parenthesis "locks up" the  part of the pattern it con-
+       tains once it has matched, and a failure further into  the  pattern  is
+       prevented  from  backtracking into it. Backtracking past it to previous
+       items, however, works as normal.
+
+       An alternative description is that a subpattern of  this  type  matches
+       the  string  of  characters  that an identical standalone pattern would
+       match, if anchored at the current point in the subject string.
+
+       Atomic grouping subpatterns are not capturing subpatterns. Simple cases
+       such as the above example can be thought of as a maximizing repeat that
+       must swallow everything it can. So, while both \d+ and  \d+?  are  pre-
+       pared  to  adjust  the number of digits they match in order to make the
+       rest of the pattern match, (?>\d+) can only match an entire sequence of
+       digits.
+
+       Atomic  groups in general can of course contain arbitrarily complicated
+       subpatterns, and can be nested. However, when  the  subpattern  for  an
+       atomic group is just a single repeated item, as in the example above, a
+       simpler notation, called a "possessive quantifier" can  be  used.  This
+       consists  of  an  additional  + character following a quantifier. Using
+       this notation, the previous example can be rewritten as
+
+         \d++foo
+
+       Note that a possessive quantifier can be used with an entire group, for
+       example:
+
+         (abc|xyz){2,3}+
+
+       Possessive   quantifiers   are   always  greedy;  the  setting  of  the
+       PCRE_UNGREEDY option is ignored. They are a convenient notation for the
+       simpler  forms  of atomic group. However, there is no difference in the
+       meaning of a possessive quantifier and  the  equivalent  atomic  group,
+       though  there  may  be a performance difference; possessive quantifiers
+       should be slightly faster.
+
+       The possessive quantifier syntax is an extension to the Perl  5.8  syn-
+       tax.   Jeffrey  Friedl  originated the idea (and the name) in the first
+       edition of his book. Mike McCloskey liked it, so implemented it when he
+       built  Sun's Java package, and PCRE copied it from there. It ultimately
+       found its way into Perl at release 5.10.
+
+       PCRE has an optimization that automatically "possessifies" certain sim-
+       ple  pattern  constructs.  For  example, the sequence A+B is treated as
+       A++B because there is no point in backtracking into a sequence  of  A's
+       when B must follow.
+
+       When  a  pattern  contains an unlimited repeat inside a subpattern that
+       can itself be repeated an unlimited number of  times,  the  use  of  an
+       atomic  group  is  the  only way to avoid some failing matches taking a
+       very long time indeed. The pattern
+
+         (\D+|<\d+>)*[!?]
+
+       matches an unlimited number of substrings that either consist  of  non-
+       digits,  or  digits  enclosed in <>, followed by either ! or ?. When it
+       matches, it runs quickly. However, if it is applied to
+
+         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+       it takes a long time before reporting  failure.  This  is  because  the
+       string  can be divided between the internal \D+ repeat and the external
+       * repeat in a large number of ways, and all  have  to  be  tried.  (The
+       example  uses  [!?]  rather than a single character at the end, because
+       both PCRE and Perl have an optimization that allows  for  fast  failure
+       when  a single character is used. They remember the last single charac-
+       ter that is required for a match, and fail early if it is  not  present
+       in  the  string.)  If  the pattern is changed so that it uses an atomic
+       group, like this:
+
+         ((?>\D+)|<\d+>)*[!?]
+
+       sequences of non-digits cannot be broken, and failure happens  quickly.
+
+
+BACK REFERENCES
+
+       Outside a character class, a backslash followed by a digit greater than
+       0 (and possibly further digits) is a back reference to a capturing sub-
+       pattern  earlier  (that is, to its left) in the pattern, provided there
+       have been that many previous capturing left parentheses.
+
+       However, if the decimal number following the backslash is less than 10,
+       it  is  always  taken  as a back reference, and causes an error only if
+       there are not that many capturing left parentheses in the  entire  pat-
+       tern.  In  other words, the parentheses that are referenced need not be
+       to the left of the reference for numbers less than 10. A "forward  back
+       reference"  of  this  type can make sense when a repetition is involved
+       and the subpattern to the right has participated in an  earlier  itera-
+       tion.
+
+       It  is  not  possible to have a numerical "forward back reference" to a
+       subpattern whose number is 10 or  more  using  this  syntax  because  a
+       sequence  such  as  \50 is interpreted as a character defined in octal.
+       See the subsection entitled "Non-printing characters" above for further
+       details  of  the  handling of digits following a backslash. There is no
+       such problem when named parentheses are used. A back reference  to  any
+       subpattern is possible using named parentheses (see below).
+
+       Another  way  of  avoiding  the ambiguity inherent in the use of digits
+       following a backslash is to use the \g escape sequence, which is a fea-
+       ture  introduced  in  Perl  5.10.  This  escape  must be followed by an
+       unsigned number or a negative number, optionally  enclosed  in  braces.
+       These examples are all identical:
+
+         (ring), \1
+         (ring), \g1
+         (ring), \g{1}
+
+       An  unsigned number specifies an absolute reference without the ambigu-
+       ity that is present in the older syntax. It is also useful when literal
+       digits follow the reference. A negative number is a relative reference.
+       Consider this example:
+
+         (abc(def)ghi)\g{-1}
+
+       The sequence \g{-1} is a reference to the most recently started captur-
+       ing  subpattern  before \g, that is, is it equivalent to \2. Similarly,
+       \g{-2} would be equivalent to \1. The use of relative references can be
+       helpful  in  long  patterns,  and  also in patterns that are created by
+       joining together fragments that contain references within themselves.
+
+       A back reference matches whatever actually matched the  capturing  sub-
+       pattern  in  the  current subject string, rather than anything matching
+       the subpattern itself (see "Subpatterns as subroutines" below for a way
+       of doing that). So the pattern
+
+         (sens|respons)e and \1ibility
+
+       matches  "sense and sensibility" and "response and responsibility", but
+       not "sense and responsibility". If caseful matching is in force at  the
+       time  of the back reference, the case of letters is relevant. For exam-
+       ple,
+
+         ((?i)rah)\s+\1
+
+       matches "rah rah" and "RAH RAH", but not "RAH  rah",  even  though  the
+       original capturing subpattern is matched caselessly.
+
+       There  are  several  different ways of writing back references to named
+       subpatterns. The .NET syntax \k{name} and the Perl syntax  \k<name>  or
+       \k'name'  are supported, as is the Python syntax (?P=name). Perl 5.10's
+       unified back reference syntax, in which \g can be used for both numeric
+       and  named  references,  is  also supported. We could rewrite the above
+       example in any of the following ways:
+
+         (?<p1>(?i)rah)\s+\k<p1>
+         (?'p1'(?i)rah)\s+\k{p1}
+         (?P<p1>(?i)rah)\s+(?P=p1)
+         (?<p1>(?i)rah)\s+\g{p1}
+
+       A subpattern that is referenced by  name  may  appear  in  the  pattern
+       before or after the reference.
+
+       There  may be more than one back reference to the same subpattern. If a
+       subpattern has not actually been used in a particular match,  any  back
+       references to it always fail. For example, the pattern
+
+         (a|(bc))\2
+
+       always  fails if it starts to match "a" rather than "bc". Because there
+       may be many capturing parentheses in a pattern,  all  digits  following
+       the  backslash  are taken as part of a potential back reference number.
+       If the pattern continues with a digit character, some delimiter must be
+       used  to  terminate  the back reference. If the PCRE_EXTENDED option is
+       set, this can be whitespace.  Otherwise an  empty  comment  (see  "Com-
+       ments" below) can be used.
+
+       A  back reference that occurs inside the parentheses to which it refers
+       fails when the subpattern is first used, so, for example,  (a\1)  never
+       matches.   However,  such references can be useful inside repeated sub-
+       patterns. For example, the pattern
+
+         (a|b\1)+
+
+       matches any number of "a"s and also "aba", "ababbaa" etc. At each iter-
+       ation  of  the  subpattern,  the  back  reference matches the character
+       string corresponding to the previous iteration. In order  for  this  to
+       work,  the  pattern must be such that the first iteration does not need
+       to match the back reference. This can be done using alternation, as  in
+       the example above, or by a quantifier with a minimum of zero.
+
+
+ASSERTIONS
+
+       An  assertion  is  a  test on the characters following or preceding the
+       current matching point that does not actually consume  any  characters.
+       The  simple  assertions  coded  as  \b, \B, \A, \G, \Z, \z, ^ and $ are
+       described above.
+
+       More complicated assertions are coded as  subpatterns.  There  are  two
+       kinds:  those  that  look  ahead of the current position in the subject
+       string, and those that look  behind  it.  An  assertion  subpattern  is
+       matched  in  the  normal way, except that it does not cause the current
+       matching position to be changed.
+
+       Assertion subpatterns are not capturing subpatterns,  and  may  not  be
+       repeated,  because  it  makes no sense to assert the same thing several
+       times. If any kind of assertion contains capturing  subpatterns  within
+       it,  these are counted for the purposes of numbering the capturing sub-
+       patterns in the whole pattern.  However, substring capturing is carried
+       out  only  for  positive assertions, because it does not make sense for
+       negative assertions.
+
+   Lookahead assertions
+
+       Lookahead assertions start with (?= for positive assertions and (?! for
+       negative assertions. For example,
+
+         \w+(?=;)
+
+       matches  a word followed by a semicolon, but does not include the semi-
+       colon in the match, and
+
+         foo(?!bar)
+
+       matches any occurrence of "foo" that is not  followed  by  "bar".  Note
+       that the apparently similar pattern
+
+         (?!foo)bar
+
+       does  not  find  an  occurrence  of "bar" that is preceded by something
+       other than "foo"; it finds any occurrence of "bar" whatsoever,  because
+       the assertion (?!foo) is always true when the next three characters are
+       "bar". A lookbehind assertion is needed to achieve the other effect.
+
+       If you want to force a matching failure at some point in a pattern, the
+       most  convenient  way  to  do  it  is with (?!) because an empty string
+       always matches, so an assertion that requires there not to be an  empty
+       string must always fail.
+
+   Lookbehind assertions
+
+       Lookbehind  assertions start with (?<= for positive assertions and (?<!
+       for negative assertions. For example,
+
+         (?<!foo)bar
+
+       does find an occurrence of "bar" that is not  preceded  by  "foo".  The
+       contents  of  a  lookbehind  assertion are restricted such that all the
+       strings it matches must have a fixed length. However, if there are sev-
+       eral  top-level  alternatives,  they  do  not all have to have the same
+       fixed length. Thus
+
+         (?<=bullock|donkey)
+
+       is permitted, but
+
+         (?<!dogs?|cats?)
+
+       causes an error at compile time. Branches that match  different  length
+       strings  are permitted only at the top level of a lookbehind assertion.
+       This is an extension compared with  Perl  (at  least  for  5.8),  which
+       requires  all branches to match the same length of string. An assertion
+       such as
+
+         (?<=ab(c|de))
+
+       is not permitted, because its single top-level  branch  can  match  two
+       different  lengths,  but  it is acceptable if rewritten to use two top-
+       level branches:
+
+         (?<=abc|abde)
+
+       In some cases, the Perl 5.10 escape sequence \K (see above) can be used
+       instead  of  a lookbehind assertion; this is not restricted to a fixed-
+       length.
+
+       The implementation of lookbehind assertions is, for  each  alternative,
+       to  temporarily  move the current position back by the fixed length and
+       then try to match. If there are insufficient characters before the cur-
+       rent position, the assertion fails.
+
+       PCRE does not allow the \C escape (which matches a single byte in UTF-8
+       mode) to appear in lookbehind assertions, because it makes it  impossi-
+       ble  to  calculate the length of the lookbehind. The \X and \R escapes,
+       which can match different numbers of bytes, are also not permitted.
+
+       Possessive quantifiers can  be  used  in  conjunction  with  lookbehind
+       assertions  to  specify  efficient  matching  at the end of the subject
+       string. Consider a simple pattern such as
+
+         abcd$
+
+       when applied to a long string that does  not  match.  Because  matching
+       proceeds from left to right, PCRE will look for each "a" in the subject
+       and then see if what follows matches the rest of the  pattern.  If  the
+       pattern is specified as
+
+         ^.*abcd$
+
+       the  initial .* matches the entire string at first, but when this fails
+       (because there is no following "a"), it backtracks to match all but the
+       last  character,  then all but the last two characters, and so on. Once
+       again the search for "a" covers the entire string, from right to  left,
+       so we are no better off. However, if the pattern is written as
+
+         ^.*+(?<=abcd)
+
+       there  can  be  no backtracking for the .*+ item; it can match only the
+       entire string. The subsequent lookbehind assertion does a  single  test
+       on  the last four characters. If it fails, the match fails immediately.
+       For long strings, this approach makes a significant difference  to  the
+       processing time.
+
+   Using multiple assertions
+
+       Several assertions (of any sort) may occur in succession. For example,
+
+         (?<=\d{3})(?<!999)foo
+
+       matches  "foo" preceded by three digits that are not "999". Notice that
+       each of the assertions is applied independently at the  same  point  in
+       the  subject  string.  First  there  is a check that the previous three
+       characters are all digits, and then there is  a  check  that  the  same
+       three characters are not "999".  This pattern does not match "foo" pre-
+       ceded by six characters, the first of which are  digits  and  the  last
+       three  of  which  are not "999". For example, it doesn't match "123abc-
+       foo". A pattern to do that is
+
+         (?<=\d{3}...)(?<!999)foo
+
+       This time the first assertion looks at the  preceding  six  characters,
+       checking that the first three are digits, and then the second assertion
+       checks that the preceding three characters are not "999".
+
+       Assertions can be nested in any combination. For example,
+
+         (?<=(?<!foo)bar)baz
+
+       matches an occurrence of "baz" that is preceded by "bar" which in  turn
+       is not preceded by "foo", while
+
+         (?<=\d{3}(?!999)...)foo
+
+       is  another pattern that matches "foo" preceded by three digits and any
+       three characters that are not "999".
+
+
+CONDITIONAL SUBPATTERNS
+
+       It is possible to cause the matching process to obey a subpattern  con-
+       ditionally  or to choose between two alternative subpatterns, depending
+       on the result of an assertion, or whether a previous capturing  subpat-
+       tern  matched  or not. The two possible forms of conditional subpattern
+       are
+
+         (?(condition)yes-pattern)
+         (?(condition)yes-pattern|no-pattern)
+
+       If the condition is satisfied, the yes-pattern is used;  otherwise  the
+       no-pattern  (if  present)  is used. If there are more than two alterna-
+       tives in the subpattern, a compile-time error occurs.
+
+       There are four kinds of condition: references  to  subpatterns,  refer-
+       ences to recursion, a pseudo-condition called DEFINE, and assertions.
+
+   Checking for a used subpattern by number
+
+       If  the  text between the parentheses consists of a sequence of digits,
+       the condition is true if the capturing subpattern of  that  number  has
+       previously  matched.  An  alternative notation is to precede the digits
+       with a plus or minus sign. In this case, the subpattern number is rela-
+       tive rather than absolute.  The most recently opened parentheses can be
+       referenced by (?(-1), the next most recent by (?(-2),  and  so  on.  In
+       looping constructs it can also make sense to refer to subsequent groups
+       with constructs such as (?(+2).
+
+       Consider the following pattern, which  contains  non-significant  white
+       space to make it more readable (assume the PCRE_EXTENDED option) and to
+       divide it into three parts for ease of discussion:
+
+         ( \( )?    [^()]+    (?(1) \) )
+
+       The first part matches an optional opening  parenthesis,  and  if  that
+       character is present, sets it as the first captured substring. The sec-
+       ond part matches one or more characters that are not  parentheses.  The
+       third part is a conditional subpattern that tests whether the first set
+       of parentheses matched or not. If they did, that is, if subject started
+       with an opening parenthesis, the condition is true, and so the yes-pat-
+       tern is executed and a  closing  parenthesis  is  required.  Otherwise,
+       since  no-pattern  is  not  present, the subpattern matches nothing. In
+       other words,  this  pattern  matches  a  sequence  of  non-parentheses,
+       optionally enclosed in parentheses.
+
+       If  you  were  embedding  this pattern in a larger one, you could use a
+       relative reference:
+
+         ...other stuff... ( \( )?    [^()]+    (?(-1) \) ) ...
+
+       This makes the fragment independent of the parentheses  in  the  larger
+       pattern.
+
+   Checking for a used subpattern by name
+
+       Perl  uses  the  syntax  (?(<name>)...) or (?('name')...) to test for a
+       used subpattern by name. For compatibility  with  earlier  versions  of
+       PCRE,  which  had this facility before Perl, the syntax (?(name)...) is
+       also recognized. However, there is a possible ambiguity with this  syn-
+       tax,  because  subpattern  names  may  consist entirely of digits. PCRE
+       looks first for a named subpattern; if it cannot find one and the  name
+       consists  entirely  of digits, PCRE looks for a subpattern of that num-
+       ber, which must be greater than zero. Using subpattern names that  con-
+       sist entirely of digits is not recommended.
+
+       Rewriting the above example to use a named subpattern gives this:
+
+         (?<OPEN> \( )?    [^()]+    (?(<OPEN>) \) )
+
+
+   Checking for pattern recursion
+
+       If the condition is the string (R), and there is no subpattern with the
+       name R, the condition is true if a recursive call to the whole  pattern
+       or any subpattern has been made. If digits or a name preceded by amper-
+       sand follow the letter R, for example:
+
+         (?(R3)...) or (?(R&name)...)
+
+       the condition is true if the most recent recursion is into the  subpat-
+       tern  whose  number or name is given. This condition does not check the
+       entire recursion stack.
+
+       At "top level", all these recursion test conditions are  false.  Recur-
+       sive patterns are described below.
+
+   Defining subpatterns for use by reference only
+
+       If  the  condition  is  the string (DEFINE), and there is no subpattern
+       with the name DEFINE, the condition is  always  false.  In  this  case,
+       there  may  be  only  one  alternative  in the subpattern. It is always
+       skipped if control reaches this point  in  the  pattern;  the  idea  of
+       DEFINE  is that it can be used to define "subroutines" that can be ref-
+       erenced from elsewhere. (The use of "subroutines" is described  below.)
+       For  example,  a pattern to match an IPv4 address could be written like
+       this (ignore whitespace and line breaks):
+
+         (?(DEFINE) (?<byte> 2[0-4]\d | 25[0-5] | 1\d\d | [1-9]?\d) )
+         \b (?&byte) (\.(?&byte)){3} \b
+
+       The first part of the pattern is a DEFINE group inside which a  another
+       group  named "byte" is defined. This matches an individual component of
+       an IPv4 address (a number less than 256). When  matching  takes  place,
+       this  part  of  the pattern is skipped because DEFINE acts like a false
+       condition.
+
+       The rest of the pattern uses references to the named group to match the
+       four  dot-separated  components of an IPv4 address, insisting on a word
+       boundary at each end.
+
+   Assertion conditions
+
+       If the condition is not in any of the above  formats,  it  must  be  an
+       assertion.   This may be a positive or negative lookahead or lookbehind
+       assertion. Consider  this  pattern,  again  containing  non-significant
+       white space, and with the two alternatives on the second line:
+
+         (?(?=[^a-z]*[a-z])
+         \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} )
+
+       The  condition  is  a  positive  lookahead  assertion  that  matches an
+       optional sequence of non-letters followed by a letter. In other  words,
+       it  tests  for the presence of at least one letter in the subject. If a
+       letter is found, the subject is matched against the first  alternative;
+       otherwise  it  is  matched  against  the  second.  This pattern matches
+       strings in one of the two forms dd-aaa-dd or dd-dd-dd,  where  aaa  are
+       letters and dd are digits.
+
+
+COMMENTS
+
+       The  sequence (?# marks the start of a comment that continues up to the
+       next closing parenthesis. Nested parentheses  are  not  permitted.  The
+       characters  that make up a comment play no part in the pattern matching
+       at all.
+
+       If the PCRE_EXTENDED option is set, an unescaped # character outside  a
+       character  class  introduces  a  comment  that continues to immediately
+       after the next newline in the pattern.
+
+
+RECURSIVE PATTERNS
+
+       Consider the problem of matching a string in parentheses, allowing  for
+       unlimited  nested  parentheses.  Without the use of recursion, the best
+       that can be done is to use a pattern that  matches  up  to  some  fixed
+       depth  of  nesting.  It  is not possible to handle an arbitrary nesting
+       depth.
+
+       For some time, Perl has provided a facility that allows regular expres-
+       sions  to recurse (amongst other things). It does this by interpolating
+       Perl code in the expression at run time, and the code can refer to  the
+       expression itself. A Perl pattern using code interpolation to solve the
+       parentheses problem can be created like this:
+
+         $re = qr{\( (?: (?>[^()]+) | (?p{$re}) )* \)}x;
+
+       The (?p{...}) item interpolates Perl code at run time, and in this case
+       refers recursively to the pattern in which it appears.
+
+       Obviously, PCRE cannot support the interpolation of Perl code. Instead,
+       it supports special syntax for recursion of  the  entire  pattern,  and
+       also  for  individual  subpattern  recursion. After its introduction in
+       PCRE and Python, this kind of recursion was  introduced  into  Perl  at
+       release 5.10.
+
+       A  special  item  that consists of (? followed by a number greater than
+       zero and a closing parenthesis is a recursive call of the subpattern of
+       the  given  number, provided that it occurs inside that subpattern. (If
+       not, it is a "subroutine" call, which is described  in  the  next  sec-
+       tion.)  The special item (?R) or (?0) is a recursive call of the entire
+       regular expression.
+
+       In PCRE (like Python, but unlike Perl), a recursive subpattern call  is
+       always treated as an atomic group. That is, once it has matched some of
+       the subject string, it is never re-entered, even if it contains untried
+       alternatives and there is a subsequent matching failure.
+
+       This  PCRE  pattern  solves  the nested parentheses problem (assume the
+       PCRE_EXTENDED option is set so that white space is ignored):
+
+         \( ( (?>[^()]+) | (?R) )* \)
+
+       First it matches an opening parenthesis. Then it matches any number  of
+       substrings  which  can  either  be  a sequence of non-parentheses, or a
+       recursive match of the pattern itself (that is, a  correctly  parenthe-
+       sized substring).  Finally there is a closing parenthesis.
+
+       If  this  were  part of a larger pattern, you would not want to recurse
+       the entire pattern, so instead you could use this:
+
+         ( \( ( (?>[^()]+) | (?1) )* \) )
+
+       We have put the pattern into parentheses, and caused the  recursion  to
+       refer to them instead of the whole pattern.
+
+       In  a  larger  pattern,  keeping  track  of  parenthesis numbers can be
+       tricky. This is made easier by the use of relative references. (A  Perl
+       5.10  feature.)   Instead  of  (?1)  in the pattern above you can write
+       (?-2) to refer to the second most recently opened parentheses preceding
+       the  recursion.  In  other  words,  a  negative number counts capturing
+       parentheses leftwards from the point at which it is encountered.
+
+       It is also possible to refer to  subsequently  opened  parentheses,  by
+       writing  references  such  as (?+2). However, these cannot be recursive
+       because the reference is not inside the  parentheses  that  are  refer-
+       enced.  They  are  always  "subroutine" calls, as described in the next
+       section.
+
+       An alternative approach is to use named parentheses instead.  The  Perl
+       syntax  for  this  is (?&name); PCRE's earlier syntax (?P>name) is also
+       supported. We could rewrite the above example as follows:
+
+         (?<pn> \( ( (?>[^()]+) | (?&pn) )* \) )
+
+       If there is more than one subpattern with the same name,  the  earliest
+       one is used.
+
+       This  particular  example pattern that we have been looking at contains
+       nested unlimited repeats, and so the use of atomic grouping for  match-
+       ing  strings  of non-parentheses is important when applying the pattern
+       to strings that do not match. For example, when this pattern is applied
+       to
+
+         (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
+
+       it  yields "no match" quickly. However, if atomic grouping is not used,
+       the match runs for a very long time indeed because there  are  so  many
+       different  ways  the  + and * repeats can carve up the subject, and all
+       have to be tested before failure can be reported.
+
+       At the end of a match, the values set for any capturing subpatterns are
+       those from the outermost level of the recursion at which the subpattern
+       value is set.  If you want to obtain  intermediate  values,  a  callout
+       function  can be used (see below and the pcrecallout documentation). If
+       the pattern above is matched against
+
+         (ab(cd)ef)
+
+       the value for the capturing parentheses is  "ef",  which  is  the  last
+       value  taken  on at the top level. If additional parentheses are added,
+       giving
+
+         \( ( ( (?>[^()]+) | (?R) )* ) \)
+            ^                        ^
+            ^                        ^
+
+       the string they capture is "ab(cd)ef", the contents of  the  top  level
+       parentheses.  If there are more than 15 capturing parentheses in a pat-
+       tern, PCRE has to obtain extra memory to store data during a recursion,
+       which  it  does  by  using pcre_malloc, freeing it via pcre_free after-
+       wards. If  no  memory  can  be  obtained,  the  match  fails  with  the
+       PCRE_ERROR_NOMEMORY error.
+
+       Do  not  confuse  the (?R) item with the condition (R), which tests for
+       recursion.  Consider this pattern, which matches text in  angle  brack-
+       ets,  allowing for arbitrary nesting. Only digits are allowed in nested
+       brackets (that is, when recursing), whereas any characters are  permit-
+       ted at the outer level.
+
+         < (?: (?(R) \d++  | [^<>]*+) | (?R)) * >
+
+       In  this  pattern, (?(R) is the start of a conditional subpattern, with
+       two different alternatives for the recursive and  non-recursive  cases.
+       The (?R) item is the actual recursive call.
+
+
+SUBPATTERNS AS SUBROUTINES
+
+       If the syntax for a recursive subpattern reference (either by number or
+       by name) is used outside the parentheses to which it refers,  it  oper-
+       ates  like a subroutine in a programming language. The "called" subpat-
+       tern may be defined before or after the reference. A numbered reference
+       can be absolute or relative, as in these examples:
+
+         (...(absolute)...)...(?2)...
+         (...(relative)...)...(?-1)...
+         (...(?+1)...(relative)...
+
+       An earlier example pointed out that the pattern
+
+         (sens|respons)e and \1ibility
+
+       matches  "sense and sensibility" and "response and responsibility", but
+       not "sense and responsibility". If instead the pattern
+
+         (sens|respons)e and (?1)ibility
+
+       is used, it does match "sense and responsibility" as well as the  other
+       two  strings.  Another  example  is  given  in the discussion of DEFINE
+       above.
+
+       Like recursive subpatterns, a "subroutine" call is always treated as an
+       atomic  group. That is, once it has matched some of the subject string,
+       it is never re-entered, even if it contains  untried  alternatives  and
+       there is a subsequent matching failure.
+
+       When  a  subpattern is used as a subroutine, processing options such as
+       case-independence are fixed when the subpattern is defined. They cannot
+       be changed for different calls. For example, consider this pattern:
+
+         (abc)(?i:(?-1))
+
+       It  matches  "abcabc". It does not match "abcABC" because the change of
+       processing option does not affect the called subpattern.
+
+
+ONIGURUMA SUBROUTINE SYNTAX
+
+       For compatibility with Oniguruma, the non-Perl syntax \g followed by  a
+       name or a number enclosed either in angle brackets or single quotes, is
+       an alternative syntax for referencing a  subpattern  as  a  subroutine,
+       possibly  recursively. Here are two of the examples used above, rewrit-
+       ten using this syntax:
+
+         (?<pn> \( ( (?>[^()]+) | \g<pn> )* \) )
+         (sens|respons)e and \g'1'ibility
+
+       PCRE supports an extension to Oniguruma: if a number is preceded  by  a
+       plus or a minus sign it is taken as a relative reference. For example:
+
+         (abc)(?i:\g<-1>)
+
+       Note  that \g{...} (Perl syntax) and \g<...> (Oniguruma syntax) are not
+       synonymous. The former is a back reference; the latter is a  subroutine
+       call.
+
+
+CALLOUTS
+
+       Perl has a feature whereby using the sequence (?{...}) causes arbitrary
+       Perl code to be obeyed in the middle of matching a regular  expression.
+       This makes it possible, amongst other things, to extract different sub-
+       strings that match the same pair of parentheses when there is a repeti-
+       tion.
+
+       PCRE provides a similar feature, but of course it cannot obey arbitrary
+       Perl code. The feature is called "callout". The caller of PCRE provides
+       an  external function by putting its entry point in the global variable
+       pcre_callout.  By default, this variable contains NULL, which  disables
+       all calling out.
+
+       Within  a  regular  expression,  (?C) indicates the points at which the
+       external function is to be called. If you want  to  identify  different
+       callout  points, you can put a number less than 256 after the letter C.
+       The default value is zero.  For example, this pattern has  two  callout
+       points:
+
+         (?C1)abc(?C2)def
+
+       If the PCRE_AUTO_CALLOUT flag is passed to pcre_compile(), callouts are
+       automatically installed before each item in the pattern. They  are  all
+       numbered 255.
+
+       During matching, when PCRE reaches a callout point (and pcre_callout is
+       set), the external function is called. It is provided with  the  number
+       of  the callout, the position in the pattern, and, optionally, one item
+       of data originally supplied by the caller of pcre_exec().  The  callout
+       function  may cause matching to proceed, to backtrack, or to fail alto-
+       gether. A complete description of the interface to the callout function
+       is given in the pcrecallout documentation.
+
+
+BACKTRACKING CONTROL
+
+       Perl  5.10 introduced a number of "Special Backtracking Control Verbs",
+       which are described in the Perl documentation as "experimental and sub-
+       ject  to  change or removal in a future version of Perl". It goes on to
+       say: "Their usage in production code should be noted to avoid  problems
+       during upgrades." The same remarks apply to the PCRE features described
+       in this section.
+
+       Since these verbs are specifically related  to  backtracking,  most  of
+       them  can  be  used  only  when  the  pattern  is  to  be matched using
+       pcre_exec(), which uses a backtracking algorithm. With the exception of
+       (*FAIL), which behaves like a failing negative assertion, they cause an
+       error if encountered by pcre_dfa_exec().
+
+       The new verbs make use of what was previously invalid syntax: an  open-
+       ing parenthesis followed by an asterisk. In Perl, they are generally of
+       the form (*VERB:ARG) but PCRE does not support the use of arguments, so
+       its  general  form is just (*VERB). Any number of these verbs may occur
+       in a pattern. There are two kinds:
+
+   Verbs that act immediately
+
+       The following verbs act as soon as they are encountered:
+
+          (*ACCEPT)
+
+       This verb causes the match to end successfully, skipping the  remainder
+       of  the pattern. When inside a recursion, only the innermost pattern is
+       ended immediately. PCRE differs  from  Perl  in  what  happens  if  the
+       (*ACCEPT)  is inside capturing parentheses. In Perl, the data so far is
+       captured: in PCRE no data is captured. For example:
+
+         A(A|B(*ACCEPT)|C)D
+
+       This matches "AB", "AAD", or "ACD", but when it matches "AB",  no  data
+       is captured.
+
+         (*FAIL) or (*F)
+
+       This  verb  causes the match to fail, forcing backtracking to occur. It
+       is equivalent to (?!) but easier to read. The Perl documentation  notes
+       that  it  is  probably  useful only when combined with (?{}) or (??{}).
+       Those are, of course, Perl features that are not present in  PCRE.  The
+       nearest  equivalent is the callout feature, as for example in this pat-
+       tern:
+
+         a+(?C)(*FAIL)
+
+       A match with the string "aaaa" always fails, but the callout  is  taken
+       before each backtrack happens (in this example, 10 times).
+
+   Verbs that act after backtracking
+
+       The following verbs do nothing when they are encountered. Matching con-
+       tinues with what follows, but if there is no subsequent match, a  fail-
+       ure  is  forced.   The  verbs  differ  in  exactly what kind of failure
+       occurs.
+
+         (*COMMIT)
+
+       This verb causes the whole match to fail outright if the  rest  of  the
+       pattern  does  not match. Even if the pattern is unanchored, no further
+       attempts to find a match by advancing the start point take place.  Once
+       (*COMMIT)  has been passed, pcre_exec() is committed to finding a match
+       at the current starting point, or not at all. For example:
+
+         a+(*COMMIT)b
+
+       This matches "xxaab" but not "aacaab". It can be thought of as  a  kind
+       of dynamic anchor, or "I've started, so I must finish."
+
+         (*PRUNE)
+
+       This  verb causes the match to fail at the current position if the rest
+       of the pattern does not match. If the pattern is unanchored, the normal
+       "bumpalong"  advance to the next starting character then happens. Back-
+       tracking can occur as usual to the left of (*PRUNE), or  when  matching
+       to  the right of (*PRUNE), but if there is no match to the right, back-
+       tracking cannot cross (*PRUNE).  In simple cases, the use  of  (*PRUNE)
+       is just an alternative to an atomic group or possessive quantifier, but
+       there are some uses of (*PRUNE) that cannot be expressed in  any  other
+       way.
+
+         (*SKIP)
+
+       This  verb  is like (*PRUNE), except that if the pattern is unanchored,
+       the "bumpalong" advance is not to the next character, but to the  posi-
+       tion  in  the  subject where (*SKIP) was encountered. (*SKIP) signifies
+       that whatever text was matched leading up to it cannot  be  part  of  a
+       successful match. Consider:
+
+         a+(*SKIP)b
+
+       If  the  subject  is  "aaaac...",  after  the first match attempt fails
+       (starting at the first character in the  string),  the  starting  point
+       skips on to start the next attempt at "c". Note that a possessive quan-
+       tifer does not have the same effect in this example; although it  would
+       suppress  backtracking  during  the  first  match  attempt,  the second
+       attempt would start at the second character instead of skipping  on  to
+       "c".
+
+         (*THEN)
+
+       This verb causes a skip to the next alternation if the rest of the pat-
+       tern does not match. That is, it cancels pending backtracking, but only
+       within  the  current  alternation.  Its name comes from the observation
+       that it can be used for a pattern-based if-then-else block:
+
+         ( COND1 (*THEN) FOO | COND2 (*THEN) BAR | COND3 (*THEN) BAZ ) ...
+
+       If the COND1 pattern matches, FOO is tried (and possibly further  items
+       after  the  end  of  the group if FOO succeeds); on failure the matcher
+       skips to the second alternative and tries COND2,  without  backtracking
+       into  COND1.  If  (*THEN)  is  used outside of any alternation, it acts
+       exactly like (*PRUNE).
+
+
+SEE ALSO
+
+       pcreapi(3), pcrecallout(3), pcrematching(3), pcre(3).
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 19 April 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCRESYNTAX(3)                                                    PCRESYNTAX(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE REGULAR EXPRESSION SYNTAX SUMMARY
+
+       The  full syntax and semantics of the regular expressions that are sup-
+       ported by PCRE are described in  the  pcrepattern  documentation.  This
+       document contains just a quick-reference summary of the syntax.
+
+
+QUOTING
+
+         \x         where x is non-alphanumeric is a literal x
+         \Q...\E    treat enclosed characters as literal
+
+
+CHARACTERS
+
+         \a         alarm, that is, the BEL character (hex 07)
+         \cx        "control-x", where x is any character
+         \e         escape (hex 1B)
+         \f         formfeed (hex 0C)
+         \n         newline (hex 0A)
+         \r         carriage return (hex 0D)
+         \t         tab (hex 09)
+         \ddd       character with octal code ddd, or backreference
+         \xhh       character with hex code hh
+         \x{hhh..}  character with hex code hhh..
+
+
+CHARACTER TYPES
+
+         .          any character except newline;
+                      in dotall mode, any character whatsoever
+         \C         one byte, even in UTF-8 mode (best avoided)
+         \d         a decimal digit
+         \D         a character that is not a decimal digit
+         \h         a horizontal whitespace character
+         \H         a character that is not a horizontal whitespace character
+         \p{xx}     a character with the xx property
+         \P{xx}     a character without the xx property
+         \R         a newline sequence
+         \s         a whitespace character
+         \S         a character that is not a whitespace character
+         \v         a vertical whitespace character
+         \V         a character that is not a vertical whitespace character
+         \w         a "word" character
+         \W         a "non-word" character
+         \X         an extended Unicode sequence
+
+       In PCRE, \d, \D, \s, \S, \w, and \W recognize only ASCII characters.
+
+
+GENERAL CATEGORY PROPERTY CODES FOR \p and \P
+
+         C          Other
+         Cc         Control
+         Cf         Format
+         Cn         Unassigned
+         Co         Private use
+         Cs         Surrogate
+
+         L          Letter
+         Ll         Lower case letter
+         Lm         Modifier letter
+         Lo         Other letter
+         Lt         Title case letter
+         Lu         Upper case letter
+         L&         Ll, Lu, or Lt
+
+         M          Mark
+         Mc         Spacing mark
+         Me         Enclosing mark
+         Mn         Non-spacing mark
+
+         N          Number
+         Nd         Decimal number
+         Nl         Letter number
+         No         Other number
+
+         P          Punctuation
+         Pc         Connector punctuation
+         Pd         Dash punctuation
+         Pe         Close punctuation
+         Pf         Final punctuation
+         Pi         Initial punctuation
+         Po         Other punctuation
+         Ps         Open punctuation
+
+         S          Symbol
+         Sc         Currency symbol
+         Sk         Modifier symbol
+         Sm         Mathematical symbol
+         So         Other symbol
+
+         Z          Separator
+         Zl         Line separator
+         Zp         Paragraph separator
+         Zs         Space separator
+
+
+SCRIPT NAMES FOR \p AND \P
+
+       Arabic,  Armenian,  Balinese,  Bengali,  Bopomofo,  Braille,  Buginese,
+       Buhid,  Canadian_Aboriginal,  Cherokee,  Common,   Coptic,   Cuneiform,
+       Cypriot, Cyrillic, Deseret, Devanagari, Ethiopic, Georgian, Glagolitic,
+       Gothic, Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew,  Hira-
+       gana,  Inherited,  Kannada,  Katakana,  Kharoshthi,  Khmer, Lao, Latin,
+       Limbu,  Linear_B,  Malayalam,  Mongolian,  Myanmar,  New_Tai_Lue,  Nko,
+       Ogham,  Old_Italic,  Old_Persian, Oriya, Osmanya, Phags_Pa, Phoenician,
+       Runic,  Shavian,  Sinhala,  Syloti_Nagri,  Syriac,  Tagalog,  Tagbanwa,
+       Tai_Le, Tamil, Telugu, Thaana, Thai, Tibetan, Tifinagh, Ugaritic, Yi.
+
+
+CHARACTER CLASSES
+
+         [...]       positive character class
+         [^...]      negative character class
+         [x-y]       range (can be used for hex characters)
+         [[:xxx:]]   positive POSIX named set
+         [[:^xxx:]]  negative POSIX named set
+
+         alnum       alphanumeric
+         alpha       alphabetic
+         ascii       0-127
+         blank       space or tab
+         cntrl       control character
+         digit       decimal digit
+         graph       printing, excluding space
+         lower       lower case letter
+         print       printing, including space
+         punct       printing, excluding alphanumeric
+         space       whitespace
+         upper       upper case letter
+         word        same as \w
+         xdigit      hexadecimal digit
+
+       In PCRE, POSIX character set names recognize only ASCII characters. You
+       can use \Q...\E inside a character class.
+
+
+QUANTIFIERS
+
+         ?           0 or 1, greedy
+         ?+          0 or 1, possessive
+         ??          0 or 1, lazy
+         *           0 or more, greedy
+         *+          0 or more, possessive
+         *?          0 or more, lazy
+         +           1 or more, greedy
+         ++          1 or more, possessive
+         +?          1 or more, lazy
+         {n}         exactly n
+         {n,m}       at least n, no more than m, greedy
+         {n,m}+      at least n, no more than m, possessive
+         {n,m}?      at least n, no more than m, lazy
+         {n,}        n or more, greedy
+         {n,}+       n or more, possessive
+         {n,}?       n or more, lazy
+
+
+ANCHORS AND SIMPLE ASSERTIONS
+
+         \b          word boundary
+         \B          not a word boundary
+         ^           start of subject
+                      also after internal newline in multiline mode
+         \A          start of subject
+         $           end of subject
+                      also before newline at end of subject
+                      also before internal newline in multiline mode
+         \Z          end of subject
+                      also before newline at end of subject
+         \z          end of subject
+         \G          first matching position in subject
+
+
+MATCH POINT RESET
+
+         \K          reset start of match
+
+
+ALTERNATION
+
+         expr|expr|expr...
+
+
+CAPTURING
+
+         (...)          capturing group
+         (?<name>...)   named capturing group (Perl)
+         (?'name'...)   named capturing group (Perl)
+         (?P<name>...)  named capturing group (Python)
+         (?:...)        non-capturing group
+         (?|...)        non-capturing group; reset group numbers for
+                         capturing groups in each alternative
+
+
+ATOMIC GROUPS
+
+         (?>...)        atomic, non-capturing group
+
+
+COMMENT
+
+         (?#....)       comment (not nestable)
+
+
+OPTION SETTING
+
+         (?i)           caseless
+         (?J)           allow duplicate names
+         (?m)           multiline
+         (?s)           single line (dotall)
+         (?U)           default ungreedy (lazy)
+         (?x)           extended (ignore white space)
+         (?-...)        unset option(s)
+
+
+LOOKAHEAD AND LOOKBEHIND ASSERTIONS
+
+         (?=...)        positive look ahead
+         (?!...)        negative look ahead
+         (?<=...)       positive look behind
+         (?<!...)       negative look behind
+
+       Each top-level branch of a look behind must be of a fixed length.
+
+
+BACKREFERENCES
+
+         \n             reference by number (can be ambiguous)
+         \gn            reference by number
+         \g{n}          reference by number
+         \g{-n}         relative reference by number
+         \k<name>       reference by name (Perl)
+         \k'name'       reference by name (Perl)
+         \g{name}       reference by name (Perl)
+         \k{name}       reference by name (.NET)
+         (?P=name)      reference by name (Python)
+
+
+SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)
+
+         (?R)           recurse whole pattern
+         (?n)           call subpattern by absolute number
+         (?+n)          call subpattern by relative number
+         (?-n)          call subpattern by relative number
+         (?&name)       call subpattern by name (Perl)
+         (?P>name)      call subpattern by name (Python)
+         \g<name>       call subpattern by name (Oniguruma)
+         \g'name'       call subpattern by name (Oniguruma)
+         \g<n>          call subpattern by absolute number (Oniguruma)
+         \g'n'          call subpattern by absolute number (Oniguruma)
+         \g<+n>         call subpattern by relative number (PCRE extension)
+         \g'+n'         call subpattern by relative number (PCRE extension)
+         \g<-n>         call subpattern by relative number (PCRE extension)
+         \g'-n'         call subpattern by relative number (PCRE extension)
+
+
+CONDITIONAL PATTERNS
+
+         (?(condition)yes-pattern)
+         (?(condition)yes-pattern|no-pattern)
+
+         (?(n)...       absolute reference condition
+         (?(+n)...      relative reference condition
+         (?(-n)...      relative reference condition
+         (?(<name>)...  named reference condition (Perl)
+         (?('name')...  named reference condition (Perl)
+         (?(name)...    named reference condition (PCRE)
+         (?(R)...       overall recursion condition
+         (?(Rn)...      specific group recursion condition
+         (?(R&name)...  specific recursion condition
+         (?(DEFINE)...  define subpattern for reference
+         (?(assert)...  assertion condition
+
+
+BACKTRACKING CONTROL
+
+       The following act immediately they are reached:
+
+         (*ACCEPT)      force successful match
+         (*FAIL)        force backtrack; synonym (*F)
+
+       The following act only when a subsequent match failure causes  a  back-
+       track to reach them. They all force a match failure, but they differ in
+       what happens afterwards. Those that advance the start-of-match point do
+       so only if the pattern is not anchored.
+
+         (*COMMIT)      overall failure, no advance of starting point
+         (*PRUNE)       advance to next starting character
+         (*SKIP)        advance start to current matching position
+         (*THEN)        local failure, backtrack to next alternation
+
+
+NEWLINE CONVENTIONS
+
+       These  are  recognized only at the very start of the pattern or after a
+       (*BSR_...) option.
+
+         (*CR)
+         (*LF)
+         (*CRLF)
+         (*ANYCRLF)
+         (*ANY)
+
+
+WHAT \R MATCHES
+
+       These are recognized only at the very start of the pattern or  after  a
+       (*...) option that sets the newline convention.
+
+         (*BSR_ANYCRLF)
+         (*BSR_UNICODE)
+
+
+CALLOUTS
+
+         (?C)      callout
+         (?Cn)     callout with data n
+
+
+SEE ALSO
+
+       pcrepattern(3), pcreapi(3), pcrecallout(3), pcrematching(3), pcre(3).
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 09 April 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCREPARTIAL(3)                                                  PCREPARTIAL(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PARTIAL MATCHING IN PCRE
+
+       In  normal  use  of  PCRE,  if  the  subject  string  that is passed to
+       pcre_exec() or pcre_dfa_exec() matches as far as it goes,  but  is  too
+       short  to  match  the  entire  pattern, PCRE_ERROR_NOMATCH is returned.
+       There are circumstances where it might be helpful to  distinguish  this
+       case from other cases in which there is no match.
+
+       Consider, for example, an application where a human is required to type
+       in data for a field with specific formatting requirements.  An  example
+       might be a date in the form ddmmmyy, defined by this pattern:
+
+         ^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$
+
+       If the application sees the user's keystrokes one by one, and can check
+       that what has been typed so far is potentially valid,  it  is  able  to
+       raise  an  error as soon as a mistake is made, possibly beeping and not
+       reflecting the character that has been typed. This  immediate  feedback
+       is  likely  to  be a better user interface than a check that is delayed
+       until the entire string has been entered.
+
+       PCRE supports the concept of partial matching by means of the PCRE_PAR-
+       TIAL   option,   which   can   be   set  when  calling  pcre_exec()  or
+       pcre_dfa_exec(). When this flag is set for pcre_exec(), the return code
+       PCRE_ERROR_NOMATCH  is converted into PCRE_ERROR_PARTIAL if at any time
+       during the matching process the last part of the subject string matched
+       part  of  the  pattern. Unfortunately, for non-anchored matching, it is
+       not possible to obtain the position of the start of the partial  match.
+       No captured data is set when PCRE_ERROR_PARTIAL is returned.
+
+       When   PCRE_PARTIAL   is  set  for  pcre_dfa_exec(),  the  return  code
+       PCRE_ERROR_NOMATCH is converted into PCRE_ERROR_PARTIAL if the  end  of
+       the  subject is reached, there have been no complete matches, but there
+       is still at least one matching possibility. The portion of  the  string
+       that provided the partial match is set as the first matching string.
+
+       Using PCRE_PARTIAL disables one of PCRE's optimizations. PCRE remembers
+       the last literal byte in a pattern, and abandons  matching  immediately
+       if  such a byte is not present in the subject string. This optimization
+       cannot be used for a subject string that might match only partially.
+
+
+RESTRICTED PATTERNS FOR PCRE_PARTIAL
+
+       Because of the way certain internal optimizations  are  implemented  in
+       the  pcre_exec()  function, the PCRE_PARTIAL option cannot be used with
+       all patterns. These restrictions do not apply when  pcre_dfa_exec()  is
+       used.  For pcre_exec(), repeated single characters such as
+
+         a{2,4}
+
+       and repeated single metasequences such as
+
+         \d+
+
+       are  not permitted if the maximum number of occurrences is greater than
+       one.  Optional items such as \d? (where the maximum is one) are permit-
+       ted.   Quantifiers  with any values are permitted after parentheses, so
+       the invalid examples above can be coded thus:
+
+         (a){2,4}
+         (\d)+
+
+       These constructions run more slowly, but for the kinds  of  application
+       that  are  envisaged  for this facility, this is not felt to be a major
+       restriction.
+
+       If PCRE_PARTIAL is set for a pattern  that  does  not  conform  to  the
+       restrictions,  pcre_exec() returns the error code PCRE_ERROR_BADPARTIAL
+       (-13).  You can use the PCRE_INFO_OKPARTIAL call to pcre_fullinfo()  to
+       find out if a compiled pattern can be used for partial matching.
+
+
+EXAMPLE OF PARTIAL MATCHING USING PCRETEST
+
+       If  the  escape  sequence  \P  is  present in a pcretest data line, the
+       PCRE_PARTIAL flag is used for the match. Here is a run of pcretest that
+       uses the date example quoted above:
+
+           re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
+         data> 25jun04\P
+          0: 25jun04
+          1: jun
+         data> 25dec3\P
+         Partial match
+         data> 3ju\P
+         Partial match
+         data> 3juj\P
+         No match
+         data> j\P
+         No match
+
+       The  first  data  string  is  matched completely, so pcretest shows the
+       matched substrings. The remaining four strings do not  match  the  com-
+       plete  pattern,  but  the first two are partial matches. The same test,
+       using pcre_dfa_exec() matching (by means of the  \D  escape  sequence),
+       produces the following output:
+
+           re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
+         data> 25jun04\P\D
+          0: 25jun04
+         data> 23dec3\P\D
+         Partial match: 23dec3
+         data> 3ju\P\D
+         Partial match: 3ju
+         data> 3juj\P\D
+         No match
+         data> j\P\D
+         No match
+
+       Notice  that in this case the portion of the string that was matched is
+       made available.
+
+
+MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()
+
+       When a partial match has been found using pcre_dfa_exec(), it is possi-
+       ble  to  continue  the  match  by providing additional subject data and
+       calling pcre_dfa_exec() again with the same  compiled  regular  expres-
+       sion, this time setting the PCRE_DFA_RESTART option. You must also pass
+       the same working space as before, because this is where details of  the
+       previous  partial  match are stored. Here is an example using pcretest,
+       using the \R escape sequence to set the PCRE_DFA_RESTART option (\P and
+       \D are as above):
+
+           re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
+         data> 23ja\P\D
+         Partial match: 23ja
+         data> n05\R\D
+          0: n05
+
+       The  first  call has "23ja" as the subject, and requests partial match-
+       ing; the second call  has  "n05"  as  the  subject  for  the  continued
+       (restarted)  match.   Notice  that when the match is complete, only the
+       last part is shown; PCRE does  not  retain  the  previously  partially-
+       matched  string. It is up to the calling program to do that if it needs
+       to.
+
+       You can set PCRE_PARTIAL  with  PCRE_DFA_RESTART  to  continue  partial
+       matching over multiple segments. This facility can be used to pass very
+       long subject strings to pcre_dfa_exec(). However, some care  is  needed
+       for certain types of pattern.
+
+       1.  If  the  pattern contains tests for the beginning or end of a line,
+       you need to pass the PCRE_NOTBOL or PCRE_NOTEOL options,  as  appropri-
+       ate,  when  the subject string for any call does not contain the begin-
+       ning or end of a line.
+
+       2. If the pattern contains backward assertions (including  \b  or  \B),
+       you  need  to  arrange for some overlap in the subject strings to allow
+       for this. For example, you could pass the subject in  chunks  that  are
+       500  bytes long, but in a buffer of 700 bytes, with the starting offset
+       set to 200 and the previous 200 bytes at the start of the buffer.
+
+       3. Matching a subject string that is split into multiple segments  does
+       not  always produce exactly the same result as matching over one single
+       long string.  The difference arises when there  are  multiple  matching
+       possibilities,  because a partial match result is given only when there
+       are no completed matches in a call to pcre_dfa_exec(). This means  that
+       as  soon  as  the  shortest match has been found, continuation to a new
+       subject segment is no longer possible.  Consider this pcretest example:
+
+           re> /dog(sbody)?/
+         data> do\P\D
+         Partial match: do
+         data> gsb\R\P\D
+          0: g
+         data> dogsbody\D
+          0: dogsbody
+          1: dog
+
+       The  pattern matches the words "dog" or "dogsbody". When the subject is
+       presented in several parts ("do" and "gsb" being  the  first  two)  the
+       match  stops  when "dog" has been found, and it is not possible to con-
+       tinue. On the other hand,  if  "dogsbody"  is  presented  as  a  single
+       string, both matches are found.
+
+       Because  of  this  phenomenon,  it does not usually make sense to end a
+       pattern that is going to be matched in this way with a variable repeat.
+
+       4. Patterns that contain alternatives at the top level which do not all
+       start with the same pattern item may not work as expected. For example,
+       consider this pattern:
+
+         1234|3789
+
+       If  the  first  part of the subject is "ABC123", a partial match of the
+       first alternative is found at offset 3. There is no partial  match  for
+       the second alternative, because such a match does not start at the same
+       point in the subject string. Attempting to  continue  with  the  string
+       "789" does not yield a match because only those alternatives that match
+       at one point in the subject are remembered. The problem arises  because
+       the  start  of the second alternative matches within the first alterna-
+       tive. There is no problem with anchored patterns or patterns such as:
+
+         1234|ABCD
+
+       where no string can be a partial match for both alternatives.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 04 June 2007
+       Copyright (c) 1997-2007 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCREPRECOMPILE(3)                                            PCREPRECOMPILE(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+SAVING AND RE-USING PRECOMPILED PCRE PATTERNS
+
+       If  you  are running an application that uses a large number of regular
+       expression patterns, it may be useful to store them  in  a  precompiled
+       form  instead  of  having to compile them every time the application is
+       run.  If you are not  using  any  private  character  tables  (see  the
+       pcre_maketables()  documentation),  this is relatively straightforward.
+       If you are using private tables, it is a little bit more complicated.
+
+       If you save compiled patterns to a file, you can copy them to a differ-
+       ent  host  and  run them there. This works even if the new host has the
+       opposite endianness to the one on which  the  patterns  were  compiled.
+       There  may  be a small performance penalty, but it should be insignifi-
+       cant. However, compiling regular expressions with one version  of  PCRE
+       for  use  with  a  different  version is not guaranteed to work and may
+       cause crashes.
+
+
+SAVING A COMPILED PATTERN
+       The value returned by pcre_compile() points to a single block of memory
+       that  holds  the compiled pattern and associated data. You can find the
+       length of this block in bytes by calling pcre_fullinfo() with an  argu-
+       ment  of  PCRE_INFO_SIZE. You can then save the data in any appropriate
+       manner. Here is sample code that compiles a pattern and writes it to  a
+       file. It assumes that the variable fd refers to a file that is open for
+       output:
+
+         int erroroffset, rc, size;
+         char *error;
+         pcre *re;
+
+         re = pcre_compile("my pattern", 0, &error, &erroroffset, NULL);
+         if (re == NULL) { ... handle errors ... }
+         rc = pcre_fullinfo(re, NULL, PCRE_INFO_SIZE, &size);
+         if (rc < 0) { ... handle errors ... }
+         rc = fwrite(re, 1, size, fd);
+         if (rc != size) { ... handle errors ... }
+
+       In this example, the bytes  that  comprise  the  compiled  pattern  are
+       copied  exactly.  Note that this is binary data that may contain any of
+       the 256 possible byte  values.  On  systems  that  make  a  distinction
+       between binary and non-binary data, be sure that the file is opened for
+       binary output.
+
+       If you want to write more than one pattern to a file, you will have  to
+       devise  a  way of separating them. For binary data, preceding each pat-
+       tern with its length is probably  the  most  straightforward  approach.
+       Another  possibility is to write out the data in hexadecimal instead of
+       binary, one pattern to a line.
+
+       Saving compiled patterns in a file is only one possible way of  storing
+       them  for later use. They could equally well be saved in a database, or
+       in the memory of some daemon process that passes them  via  sockets  to
+       the processes that want them.
+
+       If  the pattern has been studied, it is also possible to save the study
+       data in a similar way to the compiled  pattern  itself.  When  studying
+       generates  additional  information, pcre_study() returns a pointer to a
+       pcre_extra data block. Its format is defined in the section on matching
+       a  pattern in the pcreapi documentation. The study_data field points to
+       the binary study data,  and  this  is  what  you  must  save  (not  the
+       pcre_extra  block itself). The length of the study data can be obtained
+       by calling pcre_fullinfo() with  an  argument  of  PCRE_INFO_STUDYSIZE.
+       Remember  to check that pcre_study() did return a non-NULL value before
+       trying to save the study data.
+
+
+RE-USING A PRECOMPILED PATTERN
+
+       Re-using a precompiled pattern is straightforward. Having  reloaded  it
+       into   main   memory,   you   pass   its   pointer  to  pcre_exec()  or
+       pcre_dfa_exec() in the usual way. This  should  work  even  on  another
+       host,  and  even  if  that  host has the opposite endianness to the one
+       where the pattern was compiled.
+
+       However, if you passed a pointer to custom character  tables  when  the
+       pattern  was  compiled  (the  tableptr argument of pcre_compile()), you
+       must now pass a similar  pointer  to  pcre_exec()  or  pcre_dfa_exec(),
+       because  the  value  saved  with the compiled pattern will obviously be
+       nonsense. A field in a pcre_extra() block is used to pass this data, as
+       described  in the section on matching a pattern in the pcreapi documen-
+       tation.
+
+       If you did not provide custom character tables  when  the  pattern  was
+       compiled,  the  pointer  in  the compiled pattern is NULL, which causes
+       pcre_exec() to use PCRE's internal tables. Thus, you  do  not  need  to
+       take any special action at run time in this case.
+
+       If  you  saved study data with the compiled pattern, you need to create
+       your own pcre_extra data block and set the study_data field to point to
+       the  reloaded  study  data. You must also set the PCRE_EXTRA_STUDY_DATA
+       bit in the flags field to indicate that study  data  is  present.  Then
+       pass  the  pcre_extra  block  to  pcre_exec() or pcre_dfa_exec() in the
+       usual way.
+
+
+COMPATIBILITY WITH DIFFERENT PCRE RELEASES
+
+       In general, it is safest to  recompile  all  saved  patterns  when  you
+       update  to  a new PCRE release, though not all updates actually require
+       this. Recompiling is definitely needed for release 7.2.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 13 June 2007
+       Copyright (c) 1997-2007 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCREPERFORM(3)                                                  PCREPERFORM(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE PERFORMANCE
+
+       Two  aspects  of performance are discussed below: memory usage and pro-
+       cessing time. The way you express your pattern as a regular  expression
+       can affect both of them.
+
+
+MEMORY USAGE
+
+       Patterns are compiled by PCRE into a reasonably efficient byte code, so
+       that most simple patterns do not use much memory. However, there is one
+       case where memory usage can be unexpectedly large. When a parenthesized
+       subpattern has a quantifier with a minimum greater than 1 and/or a lim-
+       ited  maximum,  the  whole subpattern is repeated in the compiled code.
+       For example, the pattern
+
+         (abc|def){2,4}
+
+       is compiled as if it were
+
+         (abc|def)(abc|def)((abc|def)(abc|def)?)?
+
+       (Technical aside: It is done this way so that backtrack  points  within
+       each of the repetitions can be independently maintained.)
+
+       For  regular expressions whose quantifiers use only small numbers, this
+       is not usually a problem. However, if the numbers are large,  and  par-
+       ticularly  if  such repetitions are nested, the memory usage can become
+       an embarrassment. For example, the very simple pattern
+
+         ((ab){1,1000}c){1,3}
+
+       uses 51K bytes when compiled. When PCRE is compiled  with  its  default
+       internal  pointer  size of two bytes, the size limit on a compiled pat-
+       tern is 64K, and this is reached with the above pattern  if  the  outer
+       repetition is increased from 3 to 4. PCRE can be compiled to use larger
+       internal pointers and thus handle larger compiled patterns, but  it  is
+       better to try to rewrite your pattern to use less memory if you can.
+
+       One  way  of reducing the memory usage for such patterns is to make use
+       of PCRE's "subroutine" facility. Re-writing the above pattern as
+
+         ((ab)(?2){0,999}c)(?1){0,2}
+
+       reduces the memory requirements to 18K, and indeed it remains under 20K
+       even  with the outer repetition increased to 100. However, this pattern
+       is not exactly equivalent, because the "subroutine" calls  are  treated
+       as  atomic groups into which there can be no backtracking if there is a
+       subsequent matching failure. Therefore, PCRE cannot  do  this  kind  of
+       rewriting  automatically.   Furthermore,  there is a noticeable loss of
+       speed when executing the modified pattern. Nevertheless, if the  atomic
+       grouping  is  not  a  problem and the loss of speed is acceptable, this
+       kind of rewriting will allow you to process patterns that  PCRE  cannot
+       otherwise handle.
+
+
+PROCESSING TIME
+
+       Certain  items  in regular expression patterns are processed more effi-
+       ciently than others. It is more efficient to use a character class like
+       [aeiou]   than   a   set   of  single-character  alternatives  such  as
+       (a|e|i|o|u). In general, the simplest construction  that  provides  the
+       required behaviour is usually the most efficient. Jeffrey Friedl's book
+       contains a lot of useful general discussion  about  optimizing  regular
+       expressions  for  efficient  performance.  This document contains a few
+       observations about PCRE.
+
+       Using Unicode character properties (the \p,  \P,  and  \X  escapes)  is
+       slow,  because PCRE has to scan a structure that contains data for over
+       fifteen thousand characters whenever it needs a  character's  property.
+       If  you  can  find  an  alternative pattern that does not use character
+       properties, it will probably be faster.
+
+       When a pattern begins with .* not in  parentheses,  or  in  parentheses
+       that are not the subject of a backreference, and the PCRE_DOTALL option
+       is set, the pattern is implicitly anchored by PCRE, since it can  match
+       only  at  the start of a subject string. However, if PCRE_DOTALL is not
+       set, PCRE cannot make this optimization, because  the  .  metacharacter
+       does  not then match a newline, and if the subject string contains new-
+       lines, the pattern may match from the character  immediately  following
+       one of them instead of from the very start. For example, the pattern
+
+         .*second
+
+       matches  the subject "first\nand second" (where \n stands for a newline
+       character), with the match starting at the seventh character. In  order
+       to do this, PCRE has to retry the match starting after every newline in
+       the subject.
+
+       If you are using such a pattern with subject strings that do  not  con-
+       tain newlines, the best performance is obtained by setting PCRE_DOTALL,
+       or starting the pattern with ^.* or ^.*? to indicate  explicit  anchor-
+       ing.  That saves PCRE from having to scan along the subject looking for
+       a newline to restart at.
+
+       Beware of patterns that contain nested indefinite  repeats.  These  can
+       take  a  long time to run when applied to a string that does not match.
+       Consider the pattern fragment
+
+         ^(a+)*
+
+       This can match "aaaa" in 16 different ways, and this  number  increases
+       very  rapidly  as the string gets longer. (The * repeat can match 0, 1,
+       2, 3, or 4 times, and for each of those cases other than 0 or 4, the  +
+       repeats  can  match  different numbers of times.) When the remainder of
+       the pattern is such that the entire match is going to fail, PCRE has in
+       principle  to  try  every  possible  variation,  and  this  can take an
+       extremely long time, even for relatively short strings.
+
+       An optimization catches some of the more simple cases such as
+
+         (a+)*b
+
+       where a literal character follows. Before  embarking  on  the  standard
+       matching  procedure,  PCRE checks that there is a "b" later in the sub-
+       ject string, and if there is not, it fails the match immediately.  How-
+       ever,  when  there  is no following literal this optimization cannot be
+       used. You can see the difference by comparing the behaviour of
+
+         (a+)*\d
+
+       with the pattern above. The former gives  a  failure  almost  instantly
+       when  applied  to  a  whole  line of "a" characters, whereas the latter
+       takes an appreciable time with strings longer than about 20 characters.
+
+       In many cases, the solution to this kind of performance issue is to use
+       an atomic group or a possessive quantifier.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 06 March 2007
+       Copyright (c) 1997-2007 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCREPOSIX(3)                                                      PCREPOSIX(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions.
+
+
+SYNOPSIS OF POSIX API
+
+       #include <pcreposix.h>
+
+       int regcomp(regex_t *preg, const char *pattern,
+            int cflags);
+
+       int regexec(regex_t *preg, const char *string,
+            size_t nmatch, regmatch_t pmatch[], int eflags);
+
+       size_t regerror(int errcode, const regex_t *preg,
+            char *errbuf, size_t errbuf_size);
+
+       void regfree(regex_t *preg);
+
+
+DESCRIPTION
+
+       This  set  of  functions provides a POSIX-style API to the PCRE regular
+       expression package. See the pcreapi documentation for a description  of
+       PCRE's native API, which contains much additional functionality.
+
+       The functions described here are just wrapper functions that ultimately
+       call  the  PCRE  native  API.  Their  prototypes  are  defined  in  the
+       pcreposix.h  header  file,  and  on  Unix systems the library itself is
+       called pcreposix.a, so can be accessed by  adding  -lpcreposix  to  the
+       command  for  linking  an application that uses them. Because the POSIX
+       functions call the native ones, it is also necessary to add -lpcre.
+
+       I have implemented only those option bits that can be reasonably mapped
+       to PCRE native options. In addition, the option REG_EXTENDED is defined
+       with the value zero. This has no effect, but since  programs  that  are
+       written  to  the  POSIX interface often use it, this makes it easier to
+       slot in PCRE as a replacement library. Other POSIX options are not even
+       defined.
+
+       When  PCRE  is  called  via these functions, it is only the API that is
+       POSIX-like in style. The syntax and semantics of  the  regular  expres-
+       sions  themselves  are  still  those of Perl, subject to the setting of
+       various PCRE options, as described below. "POSIX-like in  style"  means
+       that  the  API  approximates  to  the POSIX definition; it is not fully
+       POSIX-compatible, and in multi-byte encoding  domains  it  is  probably
+       even less compatible.
+
+       The  header for these functions is supplied as pcreposix.h to avoid any
+       potential clash with other POSIX  libraries.  It  can,  of  course,  be
+       renamed or aliased as regex.h, which is the "correct" name. It provides
+       two structure types, regex_t for  compiled  internal  forms,  and  reg-
+       match_t  for  returning  captured substrings. It also defines some con-
+       stants whose names start  with  "REG_";  these  are  used  for  setting
+       options and identifying error codes.
+
+
+COMPILING A PATTERN
+
+       The  function regcomp() is called to compile a pattern into an internal
+       form. The pattern is a C string terminated by a  binary  zero,  and  is
+       passed  in  the  argument  pattern. The preg argument is a pointer to a
+       regex_t structure that is used as a base for storing information  about
+       the compiled regular expression.
+
+       The argument cflags is either zero, or contains one or more of the bits
+       defined by the following macros:
+
+         REG_DOTALL
+
+       The PCRE_DOTALL option is set when the regular expression is passed for
+       compilation to the native function. Note that REG_DOTALL is not part of
+       the POSIX standard.
+
+         REG_ICASE
+
+       The PCRE_CASELESS option is set when the regular expression  is  passed
+       for compilation to the native function.
+
+         REG_NEWLINE
+
+       The  PCRE_MULTILINE option is set when the regular expression is passed
+       for compilation to the native function. Note that this does  not  mimic
+       the  defined  POSIX  behaviour  for REG_NEWLINE (see the following sec-
+       tion).
+
+         REG_NOSUB
+
+       The PCRE_NO_AUTO_CAPTURE option is set when the regular  expression  is
+       passed for compilation to the native function. In addition, when a pat-
+       tern that is compiled with this flag is passed to regexec() for  match-
+       ing,  the  nmatch  and  pmatch  arguments  are ignored, and no captured
+       strings are returned.
+
+         REG_UTF8
+
+       The PCRE_UTF8 option is set when the regular expression is  passed  for
+       compilation  to the native function. This causes the pattern itself and
+       all data strings used for matching it to be treated as  UTF-8  strings.
+       Note that REG_UTF8 is not part of the POSIX standard.
+
+       In  the  absence  of  these  flags, no options are passed to the native
+       function.  This means the the  regex  is  compiled  with  PCRE  default
+       semantics.  In particular, the way it handles newline characters in the
+       subject string is the Perl way, not the POSIX way.  Note  that  setting
+       PCRE_MULTILINE  has only some of the effects specified for REG_NEWLINE.
+       It does not affect the way newlines are matched by . (they  aren't)  or
+       by a negative class such as [^a] (they are).
+
+       The  yield of regcomp() is zero on success, and non-zero otherwise. The
+       preg structure is filled in on success, and one member of the structure
+       is  public: re_nsub contains the number of capturing subpatterns in the
+       regular expression. Various error codes are defined in the header file.
+
+
+MATCHING NEWLINE CHARACTERS
+
+       This area is not simple, because POSIX and Perl take different views of
+       things.  It is not possible to get PCRE to obey  POSIX  semantics,  but
+       then  PCRE was never intended to be a POSIX engine. The following table
+       lists the different possibilities for matching  newline  characters  in
+       PCRE:
+
+                                 Default   Change with
+
+         . matches newline          no     PCRE_DOTALL
+         newline matches [^a]       yes    not changeable
+         $ matches \n at end        yes    PCRE_DOLLARENDONLY
+         $ matches \n in middle     no     PCRE_MULTILINE
+         ^ matches \n in middle     no     PCRE_MULTILINE
+
+       This is the equivalent table for POSIX:
+
+                                 Default   Change with
+
+         . matches newline          yes    REG_NEWLINE
+         newline matches [^a]       yes    REG_NEWLINE
+         $ matches \n at end        no     REG_NEWLINE
+         $ matches \n in middle     no     REG_NEWLINE
+         ^ matches \n in middle     no     REG_NEWLINE
+
+       PCRE's behaviour is the same as Perl's, except that there is no equiva-
+       lent for PCRE_DOLLAR_ENDONLY in Perl. In both PCRE and Perl,  there  is
+       no way to stop newline from matching [^a].
+
+       The   default  POSIX  newline  handling  can  be  obtained  by  setting
+       PCRE_DOTALL and PCRE_DOLLAR_ENDONLY, but there is no way to  make  PCRE
+       behave exactly as for the REG_NEWLINE action.
+
+
+MATCHING A PATTERN
+
+       The  function  regexec()  is  called  to  match a compiled pattern preg
+       against a given string, which is by default terminated by a  zero  byte
+       (but  see  REG_STARTEND below), subject to the options in eflags. These
+       can be:
+
+         REG_NOTBOL
+
+       The PCRE_NOTBOL option is set when calling the underlying PCRE matching
+       function.
+
+         REG_NOTEOL
+
+       The PCRE_NOTEOL option is set when calling the underlying PCRE matching
+       function.
+
+         REG_STARTEND
+
+       The string is considered to start at string +  pmatch[0].rm_so  and  to
+       have  a terminating NUL located at string + pmatch[0].rm_eo (there need
+       not actually be a NUL at that location), regardless  of  the  value  of
+       nmatch.  This  is a BSD extension, compatible with but not specified by
+       IEEE Standard 1003.2 (POSIX.2), and should  be  used  with  caution  in
+       software intended to be portable to other systems. Note that a non-zero
+       rm_so does not imply REG_NOTBOL; REG_STARTEND affects only the location
+       of the string, not how it is matched.
+
+       If  the pattern was compiled with the REG_NOSUB flag, no data about any
+       matched strings  is  returned.  The  nmatch  and  pmatch  arguments  of
+       regexec() are ignored.
+
+       Otherwise,the portion of the string that was matched, and also any cap-
+       tured substrings, are returned via the pmatch argument, which points to
+       an  array  of nmatch structures of type regmatch_t, containing the mem-
+       bers rm_so and rm_eo. These contain the offset to the  first  character
+       of  each  substring and the offset to the first character after the end
+       of each substring, respectively. The 0th element of the vector  relates
+       to  the  entire portion of string that was matched; subsequent elements
+       relate to the capturing subpatterns of the regular  expression.  Unused
+       entries in the array have both structure members set to -1.
+
+       A  successful  match  yields  a  zero  return;  various error codes are
+       defined in the header file, of  which  REG_NOMATCH  is  the  "expected"
+       failure code.
+
+
+ERROR MESSAGES
+
+       The regerror() function maps a non-zero errorcode from either regcomp()
+       or regexec() to a printable message. If preg is  not  NULL,  the  error
+       should have arisen from the use of that structure. A message terminated
+       by a binary zero is placed  in  errbuf.  The  length  of  the  message,
+       including  the  zero, is limited to errbuf_size. The yield of the func-
+       tion is the size of buffer needed to hold the whole message.
+
+
+MEMORY USAGE
+
+       Compiling a regular expression causes memory to be allocated and  asso-
+       ciated  with  the preg structure. The function regfree() frees all such
+       memory, after which preg may no longer be used as  a  compiled  expres-
+       sion.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 05 April 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+
+
+PCRECPP(3)                                                          PCRECPP(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions.
+
+
+SYNOPSIS OF C++ WRAPPER
+
+       #include <pcrecpp.h>
+
+
+DESCRIPTION
+
+       The  C++  wrapper  for PCRE was provided by Google Inc. Some additional
+       functionality was added by Giuseppe Maxia. This brief man page was con-
+       structed  from  the  notes  in the pcrecpp.h file, which should be con-
+       sulted for further details.
+
+
+MATCHING INTERFACE
+
+       The "FullMatch" operation checks that supplied text matches a  supplied
+       pattern  exactly.  If pointer arguments are supplied, it copies matched
+       sub-strings that match sub-patterns into them.
+
+         Example: successful match
+            pcrecpp::RE re("h.*o");
+            re.FullMatch("hello");
+
+         Example: unsuccessful match (requires full match):
+            pcrecpp::RE re("e");
+            !re.FullMatch("hello");
+
+         Example: creating a temporary RE object:
+            pcrecpp::RE("h.*o").FullMatch("hello");
+
+       You can pass in a "const char*" or a "string" for "text". The  examples
+       below  tend to use a const char*. You can, as in the different examples
+       above, store the RE object explicitly in a variable or use a  temporary
+       RE  object.  The  examples below use one mode or the other arbitrarily.
+       Either could correctly be used for any of these examples.
+
+       You must supply extra pointer arguments to extract matched subpieces.
+
+         Example: extracts "ruby" into "s" and 1234 into "i"
+            int i;
+            string s;
+            pcrecpp::RE re("(\\w+):(\\d+)");
+            re.FullMatch("ruby:1234", &s, &i);
+
+         Example: does not try to extract any extra sub-patterns
+            re.FullMatch("ruby:1234", &s);
+
+         Example: does not try to extract into NULL
+            re.FullMatch("ruby:1234", NULL, &i);
+
+         Example: integer overflow causes failure
+            !re.FullMatch("ruby:1234567891234", NULL, &i);
+
+         Example: fails because there aren't enough sub-patterns:
+            !pcrecpp::RE("\\w+:\\d+").FullMatch("ruby:1234", &s);
+
+         Example: fails because string cannot be stored in integer
+            !pcrecpp::RE("(.*)").FullMatch("ruby", &i);
+
+       The provided pointer arguments can be pointers to  any  scalar  numeric
+       type, or one of:
+
+          string        (matched piece is copied to string)
+          StringPiece   (StringPiece is mutated to point to matched piece)
+          T             (where "bool T::ParseFrom(const char*, int)" exists)
+          NULL          (the corresponding matched sub-pattern is not copied)
+
+       The  function returns true iff all of the following conditions are sat-
+       isfied:
+
+         a. "text" matches "pattern" exactly;
+
+         b. The number of matched sub-patterns is >= number of supplied
+            pointers;
+
+         c. The "i"th argument has a suitable type for holding the
+            string captured as the "i"th sub-pattern. If you pass in
+            void * NULL for the "i"th argument, or a non-void * NULL
+            of the correct type, or pass fewer arguments than the
+            number of sub-patterns, "i"th captured sub-pattern is
+            ignored.
+
+       CAVEAT: An optional sub-pattern that does  not  exist  in  the  matched
+       string  is  assigned  the  empty  string. Therefore, the following will
+       return false (because the empty string is not a valid number):
+
+          int number;
+          pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
+
+       The matching interface supports at most 16 arguments per call.  If  you
+       need    more,    consider    using    the    more   general   interface
+       pcrecpp::RE::DoMatch. See pcrecpp.h for the signature for DoMatch.
+
+
+QUOTING METACHARACTERS
+
+       You can use the "QuoteMeta" operation to insert backslashes before  all
+       potentially  meaningful  characters  in  a string. The returned string,
+       used as a regular expression, will exactly match the original string.
+
+         Example:
+            string quoted = RE::QuoteMeta(unquoted);
+
+       Note that it's legal to escape a character even if it  has  no  special
+       meaning  in  a  regular expression -- so this function does that. (This
+       also makes it identical to the perl function  of  the  same  name;  see
+       "perldoc    -f    quotemeta".)    For   example,   "1.5-2.0?"   becomes
+       "1\.5\-2\.0\?".
+
+
+PARTIAL MATCHES
+
+       You can use the "PartialMatch" operation when you want the  pattern  to
+       match any substring of the text.
+
+         Example: simple search for a string:
+            pcrecpp::RE("ell").PartialMatch("hello");
+
+         Example: find first number in a string:
+            int number;
+            pcrecpp::RE re("(\\d+)");
+            re.PartialMatch("x*100 + 20", &number);
+            assert(number == 100);
+
+
+UTF-8 AND THE MATCHING INTERFACE
+
+       By  default,  pattern  and text are plain text, one byte per character.
+       The UTF8 flag, passed to  the  constructor,  causes  both  pattern  and
+       string to be treated as UTF-8 text, still a byte stream but potentially
+       multiple bytes per character. In practice, the text is likelier  to  be
+       UTF-8  than  the pattern, but the match returned may depend on the UTF8
+       flag, so always use it when matching UTF8 text. For example,  "."  will
+       match  one  byte normally but with UTF8 set may match up to three bytes
+       of a multi-byte character.
+
+         Example:
+            pcrecpp::RE_Options options;
+            options.set_utf8();
+            pcrecpp::RE re(utf8_pattern, options);
+            re.FullMatch(utf8_string);
+
+         Example: using the convenience function UTF8():
+            pcrecpp::RE re(utf8_pattern, pcrecpp::UTF8());
+            re.FullMatch(utf8_string);
+
+       NOTE: The UTF8 flag is ignored if pcre was not configured with the
+             --enable-utf8 flag.
+
+
+PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
+
+       PCRE defines some modifiers to  change  the  behavior  of  the  regular
+       expression   engine.  The  C++  wrapper  defines  an  auxiliary  class,
+       RE_Options, as a vehicle to pass such modifiers to  a  RE  class.  Cur-
+       rently, the following modifiers are supported:
+
+          modifier              description               Perl corresponding
+
+          PCRE_CASELESS         case insensitive match      /i
+          PCRE_MULTILINE        multiple lines match        /m
+          PCRE_DOTALL           dot matches newlines        /s
+          PCRE_DOLLAR_ENDONLY   $ matches only at end       N/A
+          PCRE_EXTRA            strict escape parsing       N/A
+          PCRE_EXTENDED         ignore whitespaces          /x
+          PCRE_UTF8             handles UTF8 chars          built-in
+          PCRE_UNGREEDY         reverses * and *?           N/A
+          PCRE_NO_AUTO_CAPTURE  disables capturing parens   N/A (*)
+
+       (*)  Both Perl and PCRE allow non capturing parentheses by means of the
+       "?:" modifier within the pattern itself. e.g. (?:ab|cd) does  not  cap-
+       ture, while (ab|cd) does.
+
+       For  a  full  account on how each modifier works, please check the PCRE
+       API reference page.
+
+       For each modifier, there are two member functions whose  name  is  made
+       out  of  the  modifier  in  lowercase,  without the "PCRE_" prefix. For
+       instance, PCRE_CASELESS is handled by
+
+         bool caseless()
+
+       which returns true if the modifier is set, and
+
+         RE_Options & set_caseless(bool)
+
+       which sets or unsets the modifier. Moreover, PCRE_EXTRA_MATCH_LIMIT can
+       be  accessed  through  the  set_match_limit()  and match_limit() member
+       functions. Setting match_limit to a non-zero value will limit the  exe-
+       cution  of pcre to keep it from doing bad things like blowing the stack
+       or taking an eternity to return a result.  A  value  of  5000  is  good
+       enough  to stop stack blowup in a 2MB thread stack. Setting match_limit
+       to  zero  disables  match  limiting.  Alternatively,   you   can   call
+       match_limit_recursion()  which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to
+       limit how much  PCRE  recurses.  match_limit()  limits  the  number  of
+       matches PCRE does; match_limit_recursion() limits the depth of internal
+       recursion, and therefore the amount of stack that is used.
+
+       Normally, to pass one or more modifiers to a RE class,  you  declare  a
+       RE_Options object, set the appropriate options, and pass this object to
+       a RE constructor. Example:
+
+          RE_options opt;
+          opt.set_caseless(true);
+          if (RE("HELLO", opt).PartialMatch("hello world")) ...
+
+       RE_options has two constructors. The default constructor takes no argu-
+       ments  and creates a set of flags that are off by default. The optional
+       parameter option_flags is to facilitate transfer of legacy code from  C
+       programs.  This lets you do
+
+          RE(pattern,
+            RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
+
+       However, new code is better off doing
+
+          RE(pattern,
+            RE_Options().set_caseless(true).set_multiline(true))
+              .PartialMatch(str);
+
+       If you are going to pass one of the most used modifiers, there are some
+       convenience functions that return a RE_Options class with the appropri-
+       ate  modifier  already  set: CASELESS(), UTF8(), MULTILINE(), DOTALL(),
+       and EXTENDED().
+
+       If you need to set several options at once, and you don't  want  to  go
+       through  the pains of declaring a RE_Options object and setting several
+       options, there is a parallel method that give you such ability  on  the
+       fly.  You  can  concatenate several set_xxxxx() member functions, since
+       each of them returns a reference to its class object. For  example,  to
+       pass  PCRE_CASELESS, PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one
+       statement, you may write:
+
+          RE(" ^ xyz \\s+ .* blah$",
+            RE_Options()
+              .set_caseless(true)
+              .set_extended(true)
+              .set_multiline(true)).PartialMatch(sometext);
+
+
+SCANNING TEXT INCREMENTALLY
+
+       The "Consume" operation may be useful if you want to  repeatedly  match
+       regular expressions at the front of a string and skip over them as they
+       match. This requires use of the "StringPiece" type, which represents  a
+       sub-range  of  a  real  string.  Like RE, StringPiece is defined in the
+       pcrecpp namespace.
+
+         Example: read lines of the form "var = value" from a string.
+            string contents = ...;                 // Fill string somehow
+            pcrecpp::StringPiece input(contents);  // Wrap in a StringPiece
+
+            string var;
+            int value;
+            pcrecpp::RE re("(\\w+) = (\\d+)\n");
+            while (re.Consume(&input, &var, &value)) {
+              ...;
+            }
+
+       Each successful call  to  "Consume"  will  set  "var/value",  and  also
+       advance "input" so it points past the matched text.
+
+       The  "FindAndConsume"  operation  is  similar to "Consume" but does not
+       anchor your match at the beginning of  the  string.  For  example,  you
+       could extract all words from a string by repeatedly calling
+
+         pcrecpp::RE("(\\w+)").FindAndConsume(&input, &word)
+
+
+PARSING HEX/OCTAL/C-RADIX NUMBERS
+
+       By default, if you pass a pointer to a numeric value, the corresponding
+       text is interpreted as a base-10  number.  You  can  instead  wrap  the
+       pointer with a call to one of the operators Hex(), Octal(), or CRadix()
+       to interpret the text in another base. The CRadix  operator  interprets
+       C-style  "0"  (base-8)  and  "0x"  (base-16)  prefixes, but defaults to
+       base-10.
+
+         Example:
+           int a, b, c, d;
+           pcrecpp::RE re("(.*) (.*) (.*) (.*)");
+           re.FullMatch("100 40 0100 0x40",
+                        pcrecpp::Octal(&a), pcrecpp::Hex(&b),
+                        pcrecpp::CRadix(&c), pcrecpp::CRadix(&d));
+
+       will leave 64 in a, b, c, and d.
+
+
+REPLACING PARTS OF STRINGS
+
+       You can replace the first match of "pattern" in "str"  with  "rewrite".
+       Within  "rewrite",  backslash-escaped  digits (\1 to \9) can be used to
+       insert text matching corresponding parenthesized group  from  the  pat-
+       tern. \0 in "rewrite" refers to the entire matching text. For example:
+
+         string s = "yabba dabba doo";
+         pcrecpp::RE("b+").Replace("d", &s);
+
+       will  leave  "s" containing "yada dabba doo". The result is true if the
+       pattern matches and a replacement occurs, false otherwise.
+
+       GlobalReplace is like Replace except that it replaces  all  occurrences
+       of  the  pattern  in  the string with the rewrite. Replacements are not
+       subject to re-matching. For example:
+
+         string s = "yabba dabba doo";
+         pcrecpp::RE("b+").GlobalReplace("d", &s);
+
+       will leave "s" containing "yada dada doo". It  returns  the  number  of
+       replacements made.
+
+       Extract  is like Replace, except that if the pattern matches, "rewrite"
+       is copied into "out" (an additional argument) with substitutions.   The
+       non-matching  portions  of "text" are ignored. Returns true iff a match
+       occurred and the extraction happened successfully;  if no match occurs,
+       the string is left unaffected.
+
+
+AUTHOR
+
+       The C++ wrapper was contributed by Google Inc.
+       Copyright (c) 2007 Google Inc.
+
+
+REVISION
+
+       Last updated: 12 November 2007
+------------------------------------------------------------------------------
+
+
+PCRESAMPLE(3)                                                    PCRESAMPLE(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE SAMPLE PROGRAM
+
+       A simple, complete demonstration program, to get you started with using
+       PCRE, is supplied in the file pcredemo.c in the PCRE distribution.
+
+       The program compiles the regular expression that is its first argument,
+       and  matches  it  against the subject string in its second argument. No
+       PCRE options are set, and default character tables are used. If  match-
+       ing  succeeds,  the  program  outputs  the  portion of the subject that
+       matched, together with the contents of any captured substrings.
+
+       If the -g option is given on the command line, the program then goes on
+       to check for further matches of the same regular expression in the same
+       subject string. The logic is a little bit tricky because of the  possi-
+       bility  of  matching an empty string. Comments in the code explain what
+       is going on.
+
+       If PCRE is installed in the standard include  and  library  directories
+       for  your  system, you should be able to compile the demonstration pro-
+       gram using this command:
+
+         gcc -o pcredemo pcredemo.c -lpcre
+
+       If PCRE is installed elsewhere, you may need to add additional  options
+       to  the  command line. For example, on a Unix-like system that has PCRE
+       installed in /usr/local, you  can  compile  the  demonstration  program
+       using a command like this:
+
+         gcc -o pcredemo -I/usr/local/include pcredemo.c \
+             -L/usr/local/lib -lpcre
+
+       Once  you  have  compiled the demonstration program, you can run simple
+       tests like this:
+
+         ./pcredemo 'cat|dog' 'the cat sat on the mat'
+         ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
+
+       Note that there is a  much  more  comprehensive  test  program,  called
+       pcretest,  which  supports  many  more  facilities  for testing regular
+       expressions and the PCRE library. The pcredemo program is provided as a
+       simple coding example.
+
+       On some operating systems (e.g. Solaris), when PCRE is not installed in
+       the standard library directory, you may get an error like this when you
+       try to run pcredemo:
+
+         ld.so.1:  a.out:  fatal:  libpcre.so.0:  open failed: No such file or
+       directory
+
+       This is caused by the way shared library support works  on  those  sys-
+       tems. You need to add
+
+         -R/usr/local/lib
+
+       (for example) to the compile command to get round this problem.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 23 January 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+PCRESTACK(3)                                                      PCRESTACK(3)
+
+
+NAME
+       PCRE - Perl-compatible regular expressions
+
+
+PCRE DISCUSSION OF STACK USAGE
+
+       When  you call pcre_exec(), it makes use of an internal function called
+       match(). This calls itself recursively at branch points in the pattern,
+       in  order to remember the state of the match so that it can back up and
+       try a different alternative if the first one fails.  As  matching  pro-
+       ceeds  deeper  and deeper into the tree of possibilities, the recursion
+       depth increases.
+
+       Not all calls of match() increase the recursion depth; for an item such
+       as  a* it may be called several times at the same level, after matching
+       different numbers of a's. Furthermore, in a number of cases  where  the
+       result  of  the  recursive call would immediately be passed back as the
+       result of the current call (a "tail recursion"), the function  is  just
+       restarted instead.
+
+       The pcre_dfa_exec() function operates in an entirely different way, and
+       hardly uses recursion at all. The limit on its complexity is the amount
+       of  workspace  it  is  given.  The comments that follow do NOT apply to
+       pcre_dfa_exec(); they are relevant only for pcre_exec().
+
+       You can set limits on the number of times that match() is called,  both
+       in  total  and  recursively. If the limit is exceeded, an error occurs.
+       For details, see the section on  extra  data  for  pcre_exec()  in  the
+       pcreapi documentation.
+
+       Each  time  that match() is actually called recursively, it uses memory
+       from the process stack. For certain kinds of  pattern  and  data,  very
+       large  amounts of stack may be needed, despite the recognition of "tail
+       recursion".  You can often reduce the amount of recursion,  and  there-
+       fore  the  amount of stack used, by modifying the pattern that is being
+       matched. Consider, for example, this pattern:
+
+         ([^<]|<(?!inet))+
+
+       It matches from wherever it starts until it encounters "<inet"  or  the
+       end  of  the  data,  and is the kind of pattern that might be used when
+       processing an XML file. Each iteration of the outer parentheses matches
+       either  one  character that is not "<" or a "<" that is not followed by
+       "inet". However, each time a  parenthesis  is  processed,  a  recursion
+       occurs, so this formulation uses a stack frame for each matched charac-
+       ter. For a long string, a lot of stack is required. Consider  now  this
+       rewritten pattern, which matches exactly the same strings:
+
+         ([^<]++|<(?!inet))+
+
+       This  uses very much less stack, because runs of characters that do not
+       contain "<" are "swallowed" in one item inside the parentheses.  Recur-
+       sion  happens  only when a "<" character that is not followed by "inet"
+       is encountered (and we assume this is relatively  rare).  A  possessive
+       quantifier  is  used  to stop any backtracking into the runs of non-"<"
+       characters, but that is not related to stack usage.
+
+       This example shows that one way of avoiding stack problems when  match-
+       ing long subject strings is to write repeated parenthesized subpatterns
+       to match more than one character whenever possible.
+
+   Compiling PCRE to use heap instead of stack
+
+       In environments where stack memory is constrained, you  might  want  to
+       compile  PCRE to use heap memory instead of stack for remembering back-
+       up points. This makes it run a lot more slowly, however. Details of how
+       to do this are given in the pcrebuild documentation. When built in this
+       way, instead of using the stack, PCRE obtains and frees memory by call-
+       ing  the  functions  that  are  pointed to by the pcre_stack_malloc and
+       pcre_stack_free variables. By default,  these  point  to  malloc()  and
+       free(),  but you can replace the pointers to cause PCRE to use your own
+       functions. Since the block sizes are always the same,  and  are  always
+       freed in reverse order, it may be possible to implement customized mem-
+       ory handlers that are more efficient than the standard functions.
+
+   Limiting PCRE's stack usage
+
+       PCRE has an internal counter that can be used to  limit  the  depth  of
+       recursion,  and  thus cause pcre_exec() to give an error code before it
+       runs out of stack. By default, the limit is very  large,  and  unlikely
+       ever  to operate. It can be changed when PCRE is built, and it can also
+       be set when pcre_exec() is called. For details of these interfaces, see
+       the pcrebuild and pcreapi documentation.
+
+       As a very rough rule of thumb, you should reckon on about 500 bytes per
+       recursion. Thus, if you want to limit your  stack  usage  to  8Mb,  you
+       should  set  the  limit at 16000 recursions. A 64Mb stack, on the other
+       hand, can support around 128000 recursions. The pcretest  test  program
+       has a command line option (-S) that can be used to increase the size of
+       its stack.
+
+   Changing stack size in Unix-like systems
+
+       In Unix-like environments, there is not often a problem with the  stack
+       unless  very  long  strings  are  involved, though the default limit on
+       stack size varies from system to system. Values from 8Mb  to  64Mb  are
+       common. You can find your default limit by running the command:
+
+         ulimit -s
+
+       Unfortunately,  the  effect  of  running out of stack is often SIGSEGV,
+       though sometimes a more explicit error message is given. You  can  nor-
+       mally increase the limit on stack size by code such as this:
+
+         struct rlimit rlim;
+         getrlimit(RLIMIT_STACK, &rlim);
+         rlim.rlim_cur = 100*1024*1024;
+         setrlimit(RLIMIT_STACK, &rlim);
+
+       This  reads  the current limits (soft and hard) using getrlimit(), then
+       attempts to increase the soft limit to  100Mb  using  setrlimit().  You
+       must do this before calling pcre_exec().
+
+   Changing stack size in Mac OS X
+
+       Using setrlimit(), as described above, should also work on Mac OS X. It
+       is also possible to set a stack size when linking a program. There is a
+       discussion   about   stack  sizes  in  Mac  OS  X  at  this  web  site:
+       http://developer.apple.com/qa/qa2005/qa1419.html.
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 09 July 2008
+       Copyright (c) 1997-2008 University of Cambridge.
+------------------------------------------------------------------------------
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_compile.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,77 @@
+.TH PCRE_COMPILE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B pcre *pcre_compile(const char *\fIpattern\fP, int \fIoptions\fP,
+.ti +5n
+.B const char **\fIerrptr\fP, int *\fIerroffset\fP,
+.ti +5n
+.B const unsigned char *\fItableptr\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function compiles a regular expression into an internal form. It is the
+same as \fBpcre_compile2()\fP, except for the absence of the \fIerrorcodeptr\fP
+argument. Its arguments are:
+.sp
+  \fIpattern\fR       A zero-terminated string containing the
+                  regular expression to be compiled
+  \fIoptions\fR       Zero or more option bits
+  \fIerrptr\fR        Where to put an error message
+  \fIerroffset\fR     Offset in pattern where error was found
+  \fItableptr\fR      Pointer to character tables, or NULL to
+                  use the built-in default
+.sp
+The option bits are:
+.sp
+  PCRE_ANCHORED           Force pattern anchoring
+  PCRE_AUTO_CALLOUT       Compile automatic callouts
+  PCRE_BSR_ANYCRLF        \eR matches only CR, LF, or CRLF
+  PCRE_BSR_UNICODE        \eR matches all Unicode line endings
+  PCRE_CASELESS           Do caseless matching
+  PCRE_DOLLAR_ENDONLY     $ not to match newline at end
+  PCRE_DOTALL             . matches anything including NL
+  PCRE_DUPNAMES           Allow duplicate names for subpatterns
+  PCRE_EXTENDED           Ignore whitespace and # comments
+  PCRE_EXTRA              PCRE extra features
+                            (not much use currently)
+  PCRE_FIRSTLINE          Force matching to be before newline
+  PCRE_JAVASCRIPT_COMPAT  JavaScript compatibility
+  PCRE_MULTILINE          ^ and $ match newlines within data
+  PCRE_NEWLINE_ANY        Recognize any Unicode newline sequence
+  PCRE_NEWLINE_ANYCRLF    Recognize CR, LF, and CRLF as newline
+                            sequences
+  PCRE_NEWLINE_CR         Set CR as the newline sequence
+  PCRE_NEWLINE_CRLF       Set CRLF as the newline sequence
+  PCRE_NEWLINE_LF         Set LF as the newline sequence
+  PCRE_NO_AUTO_CAPTURE    Disable numbered capturing paren-
+                            theses (named ones available)
+  PCRE_UNGREEDY           Invert greediness of quantifiers
+  PCRE_UTF8               Run in UTF-8 mode
+  PCRE_NO_UTF8_CHECK      Do not check the pattern for UTF-8
+                            validity (only relevant if
+                            PCRE_UTF8 is set)
+.sp
+PCRE must be built with UTF-8 support in order to use PCRE_UTF8 and
+PCRE_NO_UTF8_CHECK.
+.P
+The yield of the function is a pointer to a private data structure that
+contains the compiled pattern, or NULL if an error was detected. Note that
+compiling regular expressions with one version of PCRE for use with a different
+version is not guaranteed to work and may cause crashes.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fR
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_compile2.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,77 @@
+.TH PCRE_COMPILE2 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B pcre *pcre_compile2(const char *\fIpattern\fP, int \fIoptions\fP,
+.ti +5n
+.B int *\fIerrorcodeptr\fP,
+.ti +5n
+.B const char **\fIerrptr\fP, int *\fIerroffset\fP,
+.ti +5n
+.B const unsigned char *\fItableptr\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function compiles a regular expression into an internal form. It is the
+same as \fBpcre_compile()\fP, except for the addition of the \fIerrorcodeptr\fP
+argument. The arguments are:
+
+.sp
+  \fIpattern\fR       A zero-terminated string containing the
+                  regular expression to be compiled
+  \fIoptions\fR       Zero or more option bits
+  \fIerrorcodeptr\fP  Where to put an error code
+  \fIerrptr\fR        Where to put an error message
+  \fIerroffset\fR     Offset in pattern where error was found
+  \fItableptr\fR      Pointer to character tables, or NULL to
+                  use the built-in default
+.sp
+The option bits are:
+.sp
+  PCRE_ANCHORED         Force pattern anchoring
+  PCRE_AUTO_CALLOUT     Compile automatic callouts
+  PCRE_CASELESS         Do caseless matching
+  PCRE_DOLLAR_ENDONLY   $ not to match newline at end
+  PCRE_DOTALL           . matches anything including NL
+  PCRE_DUPNAMES         Allow duplicate names for subpatterns
+  PCRE_EXTENDED         Ignore whitespace and # comments
+  PCRE_EXTRA            PCRE extra features
+                          (not much use currently)
+  PCRE_FIRSTLINE        Force matching to be before newline
+  PCRE_MULTILINE        ^ and $ match newlines within data
+  PCRE_NEWLINE_ANY      Recognize any Unicode newline sequence
+  PCRE_NEWLINE_ANYCRLF  Recognize CR, LF, and CRLF as newline sequences
+  PCRE_NEWLINE_CR       Set CR as the newline sequence
+  PCRE_NEWLINE_CRLF     Set CRLF as the newline sequence
+  PCRE_NEWLINE_LF       Set LF as the newline sequence
+  PCRE_NO_AUTO_CAPTURE  Disable numbered capturing paren-
+                          theses (named ones available)
+  PCRE_UNGREEDY         Invert greediness of quantifiers
+  PCRE_UTF8             Run in UTF-8 mode
+  PCRE_NO_UTF8_CHECK    Do not check the pattern for UTF-8
+                          validity (only relevant if
+                          PCRE_UTF8 is set)
+.sp
+PCRE must be built with UTF-8 support in order to use PCRE_UTF8 and
+PCRE_NO_UTF8_CHECK.
+.P
+The yield of the function is a pointer to a private data structure that
+contains the compiled pattern, or NULL if an error was detected. Note that
+compiling regular expressions with one version of PCRE for use with a different
+version is not guaranteed to work and may cause crashes.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fR
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_config.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,57 @@
+.TH PCRE_CONFIG 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_config(int \fIwhat\fP, void *\fIwhere\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function makes it possible for a client program to find out which optional
+features are available in the version of the PCRE library it is using. Its
+arguments are as follows:
+.sp
+  \fIwhat\fR     A code specifying what information is required
+  \fIwhere\fR    Points to where to put the data
+.sp
+The available codes are:
+.sp
+  PCRE_CONFIG_LINK_SIZE     Internal link size: 2, 3, or 4
+  PCRE_CONFIG_MATCH_LIMIT   Internal resource limit
+  PCRE_CONFIG_MATCH_LIMIT_RECURSION
+                            Internal recursion depth limit
+  PCRE_CONFIG_NEWLINE       Value of the default newline sequence:
+                                13 (0x000d)    for CR
+                                10 (0x000a)    for LF
+                              3338 (0x0d0a)    for CRLF
+                                -2             for ANYCRLF
+                                -1             for ANY
+  PCRE_CONFIG_BSR           Indicates what \eR matches by default:
+                                 0             all Unicode line endings
+                                 1             CR, LF, or CRLF only
+  PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+                            Threshold of return slots, above
+                              which \fBmalloc()\fR is used by
+                              the POSIX API
+  PCRE_CONFIG_STACKRECURSE  Recursion implementation (1=stack 0=heap)
+  PCRE_CONFIG_UTF8          Availability of UTF-8 support (1=yes 0=no)
+  PCRE_CONFIG_UNICODE_PROPERTIES
+                            Availability of Unicode property support
+                              (1=yes 0=no)
+.sp
+The function yields 0 on success or PCRE_ERROR_BADOPTION otherwise.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fR
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fR
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_copy_named_substring.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,43 @@
+.TH PCRE_COPY_NAMED_SUBSTRING 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_copy_named_substring(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, const char *\fIstringname\fP,
+.ti +5n
+.B char *\fIbuffer\fP, int \fIbuffersize\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a captured substring, identified
+by name, into a given buffer. The arguments are:
+.sp
+  \fIcode\fP          Pattern that was successfully matched
+  \fIsubject\fP       Subject that has been successfully matched
+  \fIovector\fP       Offset vector that \fBpcre_exec()\fP used
+  \fIstringcount\fP   Value returned by \fBpcre_exec()\fP
+  \fIstringname\fP    Name of the required substring
+  \fIbuffer\fP        Buffer to receive the string
+  \fIbuffersize\fP    Size of buffer
+.sp
+The yield is the length of the substring, PCRE_ERROR_NOMEMORY if the buffer was
+too small, or PCRE_ERROR_NOSUBSTRING if the string name is invalid.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_copy_substring.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+.TH PCRE_COPY_SUBSTRING 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_copy_substring(const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, int \fIstringnumber\fP, char *\fIbuffer\fP,
+.ti +5n
+.B int \fIbuffersize\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a captured substring into a given
+buffer. The arguments are:
+.sp
+  \fIsubject\fP       Subject that has been successfully matched
+  \fIovector\fP       Offset vector that \fBpcre_exec()\fP used
+  \fIstringcount\fP   Value returned by \fBpcre_exec()\fP
+  \fIstringnumber\fP  Number of the required substring
+  \fIbuffer\fP        Buffer to receive the string
+  \fIbuffersize\fP    Size of buffer
+.sp
+The yield is the length of the string, PCRE_ERROR_NOMEMORY if the buffer was
+too small, or PCRE_ERROR_NOSUBSTRING if the string number is invalid.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_dfa_exec.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,88 @@
+.TH PCRE_DFA_EXEC 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_dfa_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
+.ti +5n
+.B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP,
+.ti +5n
+.B int *\fIworkspace\fP, int \fIwscount\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function matches a compiled regular expression against a given subject
+string, using an alternative matching algorithm that scans the subject string
+just once (\fInot\fP Perl-compatible). Note that the main, Perl-compatible,
+matching function is \fBpcre_exec()\fP. The arguments for this function are:
+.sp
+  \fIcode\fP         Points to the compiled pattern
+  \fIextra\fP        Points to an associated \fBpcre_extra\fP structure,
+                 or is NULL
+  \fIsubject\fP      Points to the subject string
+  \fIlength\fP       Length of the subject string, in bytes
+  \fIstartoffset\fP  Offset in bytes in the subject at which to
+                 start matching
+  \fIoptions\fP      Option bits
+  \fIovector\fP      Points to a vector of ints for result offsets
+  \fIovecsize\fP     Number of elements in the vector
+  \fIworkspace\fP    Points to a vector of ints used as working space
+  \fIwscount\fP      Number of elements in the vector
+.sp
+The options are:
+.sp
+  PCRE_ANCHORED      Match only at the first position
+  PCRE_BSR_ANYCRLF   \eR matches only CR, LF, or CRLF
+  PCRE_BSR_UNICODE   \eR matches all Unicode line endings
+  PCRE_NEWLINE_ANY   Recognize any Unicode newline sequence
+  PCRE_NEWLINE_ANYCRLF  Recognize CR, LF, and CRLF as newline sequences
+  PCRE_NEWLINE_CR    Set CR as the newline sequence
+  PCRE_NEWLINE_CRLF  Set CRLF as the newline sequence
+  PCRE_NEWLINE_LF    Set LF as the newline sequence
+  PCRE_NOTBOL        Subject is not the beginning of a line
+  PCRE_NOTEOL        Subject is not the end of a line
+  PCRE_NOTEMPTY      An empty string is not a valid match
+  PCRE_NO_UTF8_CHECK Do not check the subject for UTF-8
+                       validity (only relevant if PCRE_UTF8
+                       was set at compile time)
+  PCRE_PARTIAL       Return PCRE_ERROR_PARTIAL for a partial match
+  PCRE_DFA_SHORTEST  Return only the shortest match
+  PCRE_DFA_RESTART   This is a restart after a partial match
+.sp
+There are restrictions on what may appear in a pattern when using this matching
+function. Details are given in the
+.\" HREF
+\fBpcrematching\fP
+.\"
+documentation.
+.P
+A \fBpcre_extra\fP structure contains the following fields:
+.sp
+  \fIflags\fP        Bits indicating which fields are set
+  \fIstudy_data\fP   Opaque data from \fBpcre_study()\fP
+  \fImatch_limit\fP  Limit on internal resource use
+  \fImatch_limit_recursion\fP  Limit on internal recursion depth
+  \fIcallout_data\fP Opaque data passed back to callouts
+  \fItables\fP       Points to character tables or is NULL
+.sp
+The flag bits are PCRE_EXTRA_STUDY_DATA, PCRE_EXTRA_MATCH_LIMIT,
+PCRE_EXTRA_MATCH_LIMIT_RECURSION, PCRE_EXTRA_CALLOUT_DATA, and
+PCRE_EXTRA_TABLES. For this matching function, the \fImatch_limit\fP and
+\fImatch_limit_recursion\fP fields are not used, and must not be set.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_exec.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,80 @@
+.TH PCRE_EXEC 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
+.ti +5n
+.B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function matches a compiled regular expression against a given subject
+string, using a matching algorithm that is similar to Perl's. It returns
+offsets to captured substrings. Its arguments are:
+.sp
+  \fIcode\fP         Points to the compiled pattern
+  \fIextra\fP        Points to an associated \fBpcre_extra\fP structure,
+                 or is NULL
+  \fIsubject\fP      Points to the subject string
+  \fIlength\fP       Length of the subject string, in bytes
+  \fIstartoffset\fP  Offset in bytes in the subject at which to
+                 start matching
+  \fIoptions\fP      Option bits
+  \fIovector\fP      Points to a vector of ints for result offsets
+  \fIovecsize\fP     Number of elements in the vector (a multiple of 3)
+.sp
+The options are:
+.sp
+  PCRE_ANCHORED      Match only at the first position
+  PCRE_BSR_ANYCRLF   \eR matches only CR, LF, or CRLF
+  PCRE_BSR_UNICODE   \eR matches all Unicode line endings
+  PCRE_NEWLINE_ANY   Recognize any Unicode newline sequence
+  PCRE_NEWLINE_ANYCRLF  Recognize CR, LF, and CRLF as newline sequences
+  PCRE_NEWLINE_CR    Set CR as the newline sequence
+  PCRE_NEWLINE_CRLF  Set CRLF as the newline sequence
+  PCRE_NEWLINE_LF    Set LF as the newline sequence
+  PCRE_NOTBOL        Subject is not the beginning of a line
+  PCRE_NOTEOL        Subject is not the end of a line
+  PCRE_NOTEMPTY      An empty string is not a valid match
+  PCRE_NO_UTF8_CHECK Do not check the subject for UTF-8
+                       validity (only relevant if PCRE_UTF8
+                       was set at compile time)
+  PCRE_PARTIAL       Return PCRE_ERROR_PARTIAL for a partial match
+.sp
+There are restrictions on what may appear in a pattern when partial matching is
+requested. For details, see the
+.\" HREF
+\fBpcrepartial\fP
+.\"
+page.
+.P
+A \fBpcre_extra\fP structure contains the following fields:
+.sp
+  \fIflags\fP        Bits indicating which fields are set
+  \fIstudy_data\fP   Opaque data from \fBpcre_study()\fP
+  \fImatch_limit\fP  Limit on internal resource use
+  \fImatch_limit_recursion\fP  Limit on internal recursion depth
+  \fIcallout_data\fP Opaque data passed back to callouts
+  \fItables\fP       Points to character tables or is NULL
+.sp
+The flag bits are PCRE_EXTRA_STUDY_DATA, PCRE_EXTRA_MATCH_LIMIT,
+PCRE_EXTRA_MATCH_LIMIT_RECURSION, PCRE_EXTRA_CALLOUT_DATA, and
+PCRE_EXTRA_TABLES.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_free_substring.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+.TH PCRE_FREE_SUBSTRING 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B void pcre_free_substring(const char *\fIstringptr\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for freeing the store obtained by a previous
+call to \fBpcre_get_substring()\fP or \fBpcre_get_named_substring()\fP. Its
+only argument is a pointer to the string.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_free_substring_list.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+.TH PCRE_FREE_SUBSTRING_LIST 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B void pcre_free_substring_list(const char **\fIstringptr\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for freeing the store obtained by a previous
+call to \fBpcre_get_substring_list()\fP. Its only argument is a pointer to the
+list of string pointers.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_fullinfo.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,59 @@
+.TH PCRE_FULLINFO 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_fullinfo(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B int \fIwhat\fP, void *\fIwhere\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function returns information about a compiled pattern. Its arguments are:
+.sp
+  \fIcode\fP                      Compiled regular expression
+  \fIextra\fP                     Result of \fBpcre_study()\fP or NULL
+  \fIwhat\fP                      What information is required
+  \fIwhere\fP                     Where to put the information
+.sp
+The following information is available:
+.sp
+  PCRE_INFO_BACKREFMAX      Number of highest back reference
+  PCRE_INFO_CAPTURECOUNT    Number of capturing subpatterns
+  PCRE_INFO_DEFAULT_TABLES  Pointer to default tables
+  PCRE_INFO_FIRSTBYTE       Fixed first byte for a match, or
+                              -1 for start of string
+                                 or after newline, or
+                              -2 otherwise
+  PCRE_INFO_FIRSTTABLE      Table of first bytes (after studying)
+  PCRE_INFO_JCHANGED        Return 1 if (?J) or (?-J) was used
+  PCRE_INFO_LASTLITERAL     Literal last byte required
+  PCRE_INFO_NAMECOUNT       Number of named subpatterns
+  PCRE_INFO_NAMEENTRYSIZE   Size of name table entry
+  PCRE_INFO_NAMETABLE       Pointer to name table
+  PCRE_INFO_OKPARTIAL       Return 1 if partial matching can be tried
+  PCRE_INFO_OPTIONS         Option bits used for compilation
+  PCRE_INFO_SIZE            Size of compiled pattern
+  PCRE_INFO_STUDYSIZE       Size of study data
+.sp
+The yield of the function is zero on success or:
+.sp
+  PCRE_ERROR_NULL           the argument \fIcode\fP was NULL
+                            the argument \fIwhere\fP was NULL
+  PCRE_ERROR_BADMAGIC       the "magic number" was not found
+  PCRE_ERROR_BADOPTION      the value of \fIwhat\fP was invalid
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_get_named_substring.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+.TH PCRE_GET_NAMED_SUBSTRING 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_get_named_substring(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, const char *\fIstringname\fP,
+.ti +5n
+.B const char **\fIstringptr\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a captured substring by name. The
+arguments are:
+.sp
+  \fIcode\fP          Compiled pattern
+  \fIsubject\fP       Subject that has been successfully matched
+  \fIovector\fP       Offset vector that \fBpcre_exec()\fP used
+  \fIstringcount\fP   Value returned by \fBpcre_exec()\fP
+  \fIstringname\fP    Name of the required substring
+  \fIstringptr\fP     Where to put the string pointer
+.sp
+The memory in which the substring is placed is obtained by calling
+\fBpcre_malloc()\fP. The convenience function \fBpcre_free_substring()\fP can
+be used to free it when it is no longer needed. The yield of the function is
+the length of the extracted substring, PCRE_ERROR_NOMEMORY if sufficient memory
+could not be obtained, or PCRE_ERROR_NOSUBSTRING if the string name is invalid.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_get_stringnumber.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+.TH PCRE_GET_STRINGNUMBER 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_get_stringnumber(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIname\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This convenience function finds the number of a named substring capturing
+parenthesis in a compiled pattern. Its arguments are:
+.sp
+  \fIcode\fP    Compiled regular expression
+  \fIname\fP    Name whose number is required
+.sp
+The yield of the function is the number of the parenthesis if the name is
+found, or PCRE_ERROR_NOSUBSTRING otherwise. When duplicate names are allowed
+(PCRE_DUPNAMES is set), it is not defined which of the numbers is returned by
+\fBpcre_get_stringnumber()\fP. You can obtain the complete list by calling
+\fBpcre_get_stringtable_entries()\fP.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_get_stringtable_entries.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+.TH PCRE_GET_STRINGTABLE_ENTRIES 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_get_stringtable_entries(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIname\fP, char **\fIfirst\fP, char **\fIlast\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This convenience function finds, for a compiled pattern, the first and last
+entries for a given name in the table that translates capturing parenthesis
+names into numbers. When names are required to be unique (PCRE_DUPNAMES is
+\fInot\fP set), it is usually easier to use \fBpcre_get_stringnumber()\fP
+instead.
+.sp
+  \fIcode\fP    Compiled regular expression
+  \fIname\fP    Name whose entries required
+  \fIfirst\fP   Where to return a pointer to the first entry
+  \fIlast\fP    Where to return a pointer to the last entry
+.sp
+The yield of the function is the length of each entry, or
+PCRE_ERROR_NOSUBSTRING if none are found.
+.P
+There is a complete description of the PCRE native API, including the format of
+the table entries, in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page, and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_get_substring.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+.TH PCRE_GET_SUBSTRING 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, int \fIstringnumber\fP,
+.ti +5n
+.B const char **\fIstringptr\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a captured substring. The
+arguments are:
+.sp
+  \fIsubject\fP       Subject that has been successfully matched
+  \fIovector\fP       Offset vector that \fBpcre_exec()\fP used
+  \fIstringcount\fP   Value returned by \fBpcre_exec()\fP
+  \fIstringnumber\fP  Number of the required substring
+  \fIstringptr\fP     Where to put the string pointer
+.sp
+The memory in which the substring is placed is obtained by calling
+\fBpcre_malloc()\fP. The convenience function \fBpcre_free_substring()\fP can
+be used to free it when it is no longer needed. The yield of the function is
+the length of the substring, PCRE_ERROR_NOMEMORY if sufficient memory could not
+be obtained, or PCRE_ERROR_NOSUBSTRING if the string number is invalid.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_get_substring_list.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,41 @@
+.TH PCRE_GET_SUBSTRING_LIST 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_get_substring_list(const char *\fIsubject\fP,
+.ti +5n
+.B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"
+.
+.SH DESCRIPTION
+.rs
+.sp
+This is a convenience function for extracting a list of all the captured
+substrings. The arguments are:
+.sp
+  \fIsubject\fP       Subject that has been successfully matched
+  \fIovector\fP       Offset vector that \fBpcre_exec\fP used
+  \fIstringcount\fP   Value returned by \fBpcre_exec\fP
+  \fIlistptr\fP       Where to put a pointer to the list
+.sp
+The memory in which the substrings and the list are placed is obtained by
+calling \fBpcre_malloc()\fP. The convenience function
+\fBpcre_free_substring_list()\fP can be used to free it when it is no longer
+needed. A pointer to a list of pointers is put in the variable whose address is
+in \fIlistptr\fP. The list is terminated by a NULL pointer. The yield of the
+function is zero on success or PCRE_ERROR_NOMEMORY if sufficient memory could
+not be obtained.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_info.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+.TH PCRE_INFO 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_info(const pcre *\fIcode\fP, int *\fIoptptr\fP, int
+.B *\fIfirstcharptr\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function is obsolete. You should be using \fBpcre_fullinfo()\fP instead.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_maketables.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+.TH PCRE_MAKETABLES 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B const unsigned char *pcre_maketables(void);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function builds a set of character tables for character values less than
+256. These can be passed to \fBpcre_compile()\fP to override PCRE's internal,
+built-in tables (which were made by \fBpcre_maketables()\fP when PCRE was
+compiled). You might want to do this if you are using a non-standard locale.
+The function yields a pointer to the tables.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_refcount.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+.TH PCRE_REFCOUNT 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B int pcre_refcount(pcre *\fIcode\fP, int \fIadjust\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function is used to maintain a reference count inside a data block that
+contains a compiled pattern. Its arguments are:
+.sp
+  \fIcode\fP                      Compiled regular expression
+  \fIadjust\fP                    Adjustment to reference value
+.sp
+The yield of the function is the adjusted reference value, which is constrained
+to lie between 0 and 65535.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_study.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+.TH PCRE_STUDY 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B pcre_extra *pcre_study(const pcre *\fIcode\fP, int \fIoptions\fP,
+.ti +5n
+.B const char **\fIerrptr\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function studies a compiled pattern, to see if additional information can
+be extracted that might speed up matching. Its arguments are:
+.sp
+  \fIcode\fP       A compiled regular expression
+  \fIoptions\fP    Options for \fBpcre_study()\fP
+  \fIerrptr\fP     Where to put an error message
+.sp
+If the function succeeds, it returns a value that can be passed to
+\fBpcre_exec()\fP via its \fIextra\fP argument.
+.P
+If the function returns NULL, either it could not find any additional
+information, or there was an error. You can tell the difference by looking at
+the error value. It is NULL in first case.
+.P
+There are currently no options defined; the value of the second argument should
+always be zero.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcre_version.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+.TH PCRE_VERSION 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH SYNOPSIS
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B char *pcre_version(void);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This function returns a character string that gives the version number of the
+PCRE library and the date of its release.
+.P
+There is a complete description of the PCRE native API in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page and a description of the POSIX API in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+page.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcreapi.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1983 @@
+.TH PCREAPI 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE NATIVE API"
+.rs
+.sp
+.B #include <pcre.h>
+.PP
+.SM
+.B pcre *pcre_compile(const char *\fIpattern\fP, int \fIoptions\fP,
+.ti +5n
+.B const char **\fIerrptr\fP, int *\fIerroffset\fP,
+.ti +5n
+.B const unsigned char *\fItableptr\fP);
+.PP
+.B pcre *pcre_compile2(const char *\fIpattern\fP, int \fIoptions\fP,
+.ti +5n
+.B int *\fIerrorcodeptr\fP,
+.ti +5n
+.B const char **\fIerrptr\fP, int *\fIerroffset\fP,
+.ti +5n
+.B const unsigned char *\fItableptr\fP);
+.PP
+.B pcre_extra *pcre_study(const pcre *\fIcode\fP, int \fIoptions\fP,
+.ti +5n
+.B const char **\fIerrptr\fP);
+.PP
+.B int pcre_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
+.ti +5n
+.B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);
+.PP
+.B int pcre_dfa_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
+.ti +5n
+.B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP,
+.ti +5n
+.B int *\fIworkspace\fP, int \fIwscount\fP);
+.PP
+.B int pcre_copy_named_substring(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, const char *\fIstringname\fP,
+.ti +5n
+.B char *\fIbuffer\fP, int \fIbuffersize\fP);
+.PP
+.B int pcre_copy_substring(const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, int \fIstringnumber\fP, char *\fIbuffer\fP,
+.ti +5n
+.B int \fIbuffersize\fP);
+.PP
+.B int pcre_get_named_substring(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, const char *\fIstringname\fP,
+.ti +5n
+.B const char **\fIstringptr\fP);
+.PP
+.B int pcre_get_stringnumber(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIname\fP);
+.PP
+.B int pcre_get_stringtable_entries(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIname\fP, char **\fIfirst\fP, char **\fIlast\fP);
+.PP
+.B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, int \fIstringnumber\fP,
+.ti +5n
+.B const char **\fIstringptr\fP);
+.PP
+.B int pcre_get_substring_list(const char *\fIsubject\fP,
+.ti +5n
+.B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"
+.PP
+.B void pcre_free_substring(const char *\fIstringptr\fP);
+.PP
+.B void pcre_free_substring_list(const char **\fIstringptr\fP);
+.PP
+.B const unsigned char *pcre_maketables(void);
+.PP
+.B int pcre_fullinfo(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B int \fIwhat\fP, void *\fIwhere\fP);
+.PP
+.B int pcre_info(const pcre *\fIcode\fP, int *\fIoptptr\fP, int
+.B *\fIfirstcharptr\fP);
+.PP
+.B int pcre_refcount(pcre *\fIcode\fP, int \fIadjust\fP);
+.PP
+.B int pcre_config(int \fIwhat\fP, void *\fIwhere\fP);
+.PP
+.B char *pcre_version(void);
+.PP
+.B void *(*pcre_malloc)(size_t);
+.PP
+.B void (*pcre_free)(void *);
+.PP
+.B void *(*pcre_stack_malloc)(size_t);
+.PP
+.B void (*pcre_stack_free)(void *);
+.PP
+.B int (*pcre_callout)(pcre_callout_block *);
+.
+.
+.SH "PCRE API OVERVIEW"
+.rs
+.sp
+PCRE has its own native API, which is described in this document. There are
+also some wrapper functions that correspond to the POSIX regular expression
+API. These are described in the
+.\" HREF
+\fBpcreposix\fP
+.\"
+documentation. Both of these APIs define a set of C function calls. A C++
+wrapper is distributed with PCRE. It is documented in the
+.\" HREF
+\fBpcrecpp\fP
+.\"
+page.
+.P
+The native API C function prototypes are defined in the header file
+\fBpcre.h\fP, and on Unix systems the library itself is called \fBlibpcre\fP.
+It can normally be accessed by adding \fB-lpcre\fP to the command for linking
+an application that uses PCRE. The header file defines the macros PCRE_MAJOR
+and PCRE_MINOR to contain the major and minor release numbers for the library.
+Applications can use these to include support for different releases of PCRE.
+.P
+The functions \fBpcre_compile()\fP, \fBpcre_compile2()\fP, \fBpcre_study()\fP,
+and \fBpcre_exec()\fP are used for compiling and matching regular expressions
+in a Perl-compatible manner. A sample program that demonstrates the simplest
+way of using them is provided in the file called \fIpcredemo.c\fP in the source
+distribution. The
+.\" HREF
+\fBpcresample\fP
+.\"
+documentation describes how to compile and run it.
+.P
+A second matching function, \fBpcre_dfa_exec()\fP, which is not
+Perl-compatible, is also provided. This uses a different algorithm for the
+matching. The alternative algorithm finds all possible matches (at a given
+point in the subject), and scans the subject just once. However, this algorithm
+does not return captured substrings. A description of the two matching
+algorithms and their advantages and disadvantages is given in the
+.\" HREF
+\fBpcrematching\fP
+.\"
+documentation.
+.P
+In addition to the main compiling and matching functions, there are convenience
+functions for extracting captured substrings from a subject string that is
+matched by \fBpcre_exec()\fP. They are:
+.sp
+  \fBpcre_copy_substring()\fP
+  \fBpcre_copy_named_substring()\fP
+  \fBpcre_get_substring()\fP
+  \fBpcre_get_named_substring()\fP
+  \fBpcre_get_substring_list()\fP
+  \fBpcre_get_stringnumber()\fP
+  \fBpcre_get_stringtable_entries()\fP
+.sp
+\fBpcre_free_substring()\fP and \fBpcre_free_substring_list()\fP are also
+provided, to free the memory used for extracted strings.
+.P
+The function \fBpcre_maketables()\fP is used to build a set of character tables
+in the current locale for passing to \fBpcre_compile()\fP, \fBpcre_exec()\fP,
+or \fBpcre_dfa_exec()\fP. This is an optional facility that is provided for
+specialist use. Most commonly, no special tables are passed, in which case
+internal tables that are generated when PCRE is built are used.
+.P
+The function \fBpcre_fullinfo()\fP is used to find out information about a
+compiled pattern; \fBpcre_info()\fP is an obsolete version that returns only
+some of the available information, but is retained for backwards compatibility.
+The function \fBpcre_version()\fP returns a pointer to a string containing the
+version of PCRE and its date of release.
+.P
+The function \fBpcre_refcount()\fP maintains a reference count in a data block
+containing a compiled pattern. This is provided for the benefit of
+object-oriented applications.
+.P
+The global variables \fBpcre_malloc\fP and \fBpcre_free\fP initially contain
+the entry points of the standard \fBmalloc()\fP and \fBfree()\fP functions,
+respectively. PCRE calls the memory management functions via these variables,
+so a calling program can replace them if it wishes to intercept the calls. This
+should be done before calling any PCRE functions.
+.P
+The global variables \fBpcre_stack_malloc\fP and \fBpcre_stack_free\fP are also
+indirections to memory management functions. These special functions are used
+only when PCRE is compiled to use the heap for remembering data, instead of
+recursive function calls, when running the \fBpcre_exec()\fP function. See the
+.\" HREF
+\fBpcrebuild\fP
+.\"
+documentation for details of how to do this. It is a non-standard way of
+building PCRE, for use in environments that have limited stacks. Because of the
+greater use of memory management, it runs more slowly. Separate functions are
+provided so that special-purpose external code can be used for this case. When
+used, these functions are always called in a stack-like manner (last obtained,
+first freed), and always for memory blocks of the same size. There is a
+discussion about PCRE's stack usage in the
+.\" HREF
+\fBpcrestack\fP
+.\"
+documentation.
+.P
+The global variable \fBpcre_callout\fP initially contains NULL. It can be set
+by the caller to a "callout" function, which PCRE will then call at specified
+points during a matching operation. Details are given in the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation.
+.
+.
+.\" HTML <a name="newlines"></a>
+.SH NEWLINES
+.rs
+.sp
+PCRE supports five different conventions for indicating line breaks in
+strings: a single CR (carriage return) character, a single LF (linefeed)
+character, the two-character sequence CRLF, any of the three preceding, or any
+Unicode newline sequence. The Unicode newline sequences are the three just
+mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,
+U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
+(paragraph separator, U+2029).
+.P
+Each of the first three conventions is used by at least one operating system as
+its standard newline sequence. When PCRE is built, a default can be specified.
+The default default is LF, which is the Unix standard. When PCRE is run, the
+default can be overridden, either when a pattern is compiled, or when it is
+matched.
+.P
+At compile time, the newline convention can be specified by the \fIoptions\fP
+argument of \fBpcre_compile()\fP, or it can be specified by special text at the
+start of the pattern itself; this overrides any other settings. See the
+.\" HREF
+\fBpcrepattern\fP
+.\"
+page for details of the special character sequences.
+.P
+In the PCRE documentation the word "newline" is used to mean "the character or
+pair of characters that indicate a line break". The choice of newline
+convention affects the handling of the dot, circumflex, and dollar
+metacharacters, the handling of #-comments in /x mode, and, when CRLF is a
+recognized line ending sequence, the match position advancement for a
+non-anchored pattern. There is more detail about this in the
+.\" HTML <a href="#execoptions">
+.\" </a>
+section on \fBpcre_exec()\fP options
+.\"
+below.
+.P
+The choice of newline convention does not affect the interpretation of
+the \en or \er escape sequences, nor does it affect what \eR matches, which is
+controlled in a similar way, but by separate options.
+.
+.
+.SH MULTITHREADING
+.rs
+.sp
+The PCRE functions can be used in multi-threading applications, with the
+proviso that the memory management functions pointed to by \fBpcre_malloc\fP,
+\fBpcre_free\fP, \fBpcre_stack_malloc\fP, and \fBpcre_stack_free\fP, and the
+callout function pointed to by \fBpcre_callout\fP, are shared by all threads.
+.P
+The compiled form of a regular expression is not altered during matching, so
+the same compiled pattern can safely be used by several threads at once.
+.
+.
+.SH "SAVING PRECOMPILED PATTERNS FOR LATER USE"
+.rs
+.sp
+The compiled form of a regular expression can be saved and re-used at a later
+time, possibly by a different program, and even on a host other than the one on
+which it was compiled. Details are given in the
+.\" HREF
+\fBpcreprecompile\fP
+.\"
+documentation. However, compiling a regular expression with one version of PCRE
+for use with a different version is not guaranteed to work and may cause
+crashes.
+.
+.
+.SH "CHECKING BUILD-TIME OPTIONS"
+.rs
+.sp
+.B int pcre_config(int \fIwhat\fP, void *\fIwhere\fP);
+.PP
+The function \fBpcre_config()\fP makes it possible for a PCRE client to
+discover which optional features have been compiled into the PCRE library. The
+.\" HREF
+\fBpcrebuild\fP
+.\"
+documentation has more details about these optional features.
+.P
+The first argument for \fBpcre_config()\fP is an integer, specifying which
+information is required; the second argument is a pointer to a variable into
+which the information is placed. The following information is available:
+.sp
+  PCRE_CONFIG_UTF8
+.sp
+The output is an integer that is set to one if UTF-8 support is available;
+otherwise it is set to zero.
+.sp
+  PCRE_CONFIG_UNICODE_PROPERTIES
+.sp
+The output is an integer that is set to one if support for Unicode character
+properties is available; otherwise it is set to zero.
+.sp
+  PCRE_CONFIG_NEWLINE
+.sp
+The output is an integer whose value specifies the default character sequence
+that is recognized as meaning "newline". The four values that are supported
+are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF, and -1 for ANY. The
+default should normally be the standard sequence for your operating system.
+.sp
+  PCRE_CONFIG_BSR
+.sp
+The output is an integer whose value indicates what character sequences the \eR
+escape sequence matches by default. A value of 0 means that \eR matches any
+Unicode line ending sequence; a value of 1 means that \eR matches only CR, LF,
+or CRLF. The default can be overridden when a pattern is compiled or matched.
+.sp
+  PCRE_CONFIG_LINK_SIZE
+.sp
+The output is an integer that contains the number of bytes used for internal
+linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values
+allow larger regular expressions to be compiled, at the expense of slower
+matching. The default value of 2 is sufficient for all but the most massive
+patterns, since it allows the compiled pattern to be up to 64K in size.
+.sp
+  PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
+.sp
+The output is an integer that contains the threshold above which the POSIX
+interface uses \fBmalloc()\fP for output vectors. Further details are given in
+the
+.\" HREF
+\fBpcreposix\fP
+.\"
+documentation.
+.sp
+  PCRE_CONFIG_MATCH_LIMIT
+.sp
+The output is an integer that gives the default limit for the number of
+internal matching function calls in a \fBpcre_exec()\fP execution. Further
+details are given with \fBpcre_exec()\fP below.
+.sp
+  PCRE_CONFIG_MATCH_LIMIT_RECURSION
+.sp
+The output is an integer that gives the default limit for the depth of
+recursion when calling the internal matching function in a \fBpcre_exec()\fP
+execution. Further details are given with \fBpcre_exec()\fP below.
+.sp
+  PCRE_CONFIG_STACKRECURSE
+.sp
+The output is an integer that is set to one if internal recursion when running
+\fBpcre_exec()\fP is implemented by recursive function calls that use the stack
+to remember their state. This is the usual way that PCRE is compiled. The
+output is zero if PCRE was compiled to use blocks of data on the heap instead
+of recursive function calls. In this case, \fBpcre_stack_malloc\fP and
+\fBpcre_stack_free\fP are called to manage memory blocks on the heap, thus
+avoiding the use of the stack.
+.
+.
+.SH "COMPILING A PATTERN"
+.rs
+.sp
+.B pcre *pcre_compile(const char *\fIpattern\fP, int \fIoptions\fP,
+.ti +5n
+.B const char **\fIerrptr\fP, int *\fIerroffset\fP,
+.ti +5n
+.B const unsigned char *\fItableptr\fP);
+.sp
+.B pcre *pcre_compile2(const char *\fIpattern\fP, int \fIoptions\fP,
+.ti +5n
+.B int *\fIerrorcodeptr\fP,
+.ti +5n
+.B const char **\fIerrptr\fP, int *\fIerroffset\fP,
+.ti +5n
+.B const unsigned char *\fItableptr\fP);
+.P
+Either of the functions \fBpcre_compile()\fP or \fBpcre_compile2()\fP can be
+called to compile a pattern into an internal form. The only difference between
+the two interfaces is that \fBpcre_compile2()\fP has an additional argument,
+\fIerrorcodeptr\fP, via which a numerical error code can be returned.
+.P
+The pattern is a C string terminated by a binary zero, and is passed in the
+\fIpattern\fP argument. A pointer to a single block of memory that is obtained
+via \fBpcre_malloc\fP is returned. This contains the compiled code and related
+data. The \fBpcre\fP type is defined for the returned block; this is a typedef
+for a structure whose contents are not externally defined. It is up to the
+caller to free the memory (via \fBpcre_free\fP) when it is no longer required.
+.P
+Although the compiled code of a PCRE regex is relocatable, that is, it does not
+depend on memory location, the complete \fBpcre\fP data block is not
+fully relocatable, because it may contain a copy of the \fItableptr\fP
+argument, which is an address (see below).
+.P
+The \fIoptions\fP argument contains various bit settings that affect the
+compilation. It should be zero if no options are required. The available
+options are described below. Some of them, in particular, those that are
+compatible with Perl, can also be set and unset from within the pattern (see
+the detailed description in the
+.\" HREF
+\fBpcrepattern\fP
+.\"
+documentation). For these options, the contents of the \fIoptions\fP argument
+specifies their initial settings at the start of compilation and execution. The
+PCRE_ANCHORED and PCRE_NEWLINE_\fIxxx\fP options can be set at the time of
+matching as well as at compile time.
+.P
+If \fIerrptr\fP is NULL, \fBpcre_compile()\fP returns NULL immediately.
+Otherwise, if compilation of a pattern fails, \fBpcre_compile()\fP returns
+NULL, and sets the variable pointed to by \fIerrptr\fP to point to a textual
+error message. This is a static string that is part of the library. You must
+not try to free it. The offset from the start of the pattern to the character
+where the error was discovered is placed in the variable pointed to by
+\fIerroffset\fP, which must not be NULL. If it is, an immediate error is given.
+.P
+If \fBpcre_compile2()\fP is used instead of \fBpcre_compile()\fP, and the
+\fIerrorcodeptr\fP argument is not NULL, a non-zero error code number is
+returned via this argument in the event of an error. This is in addition to the
+textual error message. Error codes and messages are listed below.
+.P
+If the final argument, \fItableptr\fP, is NULL, PCRE uses a default set of
+character tables that are built when PCRE is compiled, using the default C
+locale. Otherwise, \fItableptr\fP must be an address that is the result of a
+call to \fBpcre_maketables()\fP. This value is stored with the compiled
+pattern, and used again by \fBpcre_exec()\fP, unless another table pointer is
+passed to it. For more discussion, see the section on locale support below.
+.P
+This code fragment shows a typical straightforward call to \fBpcre_compile()\fP:
+.sp
+  pcre *re;
+  const char *error;
+  int erroffset;
+  re = pcre_compile(
+    "^A.*Z",          /* the pattern */
+    0,                /* default options */
+    &error,           /* for error message */
+    &erroffset,       /* for error offset */
+    NULL);            /* use default character tables */
+.sp
+The following names for option bits are defined in the \fBpcre.h\fP header
+file:
+.sp
+  PCRE_ANCHORED
+.sp
+If this bit is set, the pattern is forced to be "anchored", that is, it is
+constrained to match only at the first matching point in the string that is
+being searched (the "subject string"). This effect can also be achieved by
+appropriate constructs in the pattern itself, which is the only way to do it in
+Perl.
+.sp
+  PCRE_AUTO_CALLOUT
+.sp
+If this bit is set, \fBpcre_compile()\fP automatically inserts callout items,
+all with number 255, before each pattern item. For discussion of the callout
+facility, see the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation.
+.sp
+  PCRE_BSR_ANYCRLF
+  PCRE_BSR_UNICODE
+.sp
+These options (which are mutually exclusive) control what the \eR escape
+sequence matches. The choice is either to match only CR, LF, or CRLF, or to
+match any Unicode newline sequence. The default is specified when PCRE is
+built. It can be overridden from within the pattern, or by setting an option
+when a compiled pattern is matched.
+.sp
+  PCRE_CASELESS
+.sp
+If this bit is set, letters in the pattern match both upper and lower case
+letters. It is equivalent to Perl's /i option, and it can be changed within a
+pattern by a (?i) option setting. In UTF-8 mode, PCRE always understands the
+concept of case for characters whose values are less than 128, so caseless
+matching is always possible. For characters with higher values, the concept of
+case is supported if PCRE is compiled with Unicode property support, but not
+otherwise. If you want to use caseless matching for characters 128 and above,
+you must ensure that PCRE is compiled with Unicode property support as well as
+with UTF-8 support.
+.sp
+  PCRE_DOLLAR_ENDONLY
+.sp
+If this bit is set, a dollar metacharacter in the pattern matches only at the
+end of the subject string. Without this option, a dollar also matches
+immediately before a newline at the end of the string (but not before any other
+newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is set.
+There is no equivalent to this option in Perl, and no way to set it within a
+pattern.
+.sp
+  PCRE_DOTALL
+.sp
+If this bit is set, a dot metacharater in the pattern matches all characters,
+including those that indicate newline. Without it, a dot does not match when
+the current position is at a newline. This option is equivalent to Perl's /s
+option, and it can be changed within a pattern by a (?s) option setting. A
+negative class such as [^a] always matches newline characters, independent of
+the setting of this option.
+.sp
+  PCRE_DUPNAMES
+.sp
+If this bit is set, names used to identify capturing subpatterns need not be
+unique. This can be helpful for certain types of pattern when it is known that
+only one instance of the named subpattern can ever be matched. There are more
+details of named subpatterns below; see also the
+.\" HREF
+\fBpcrepattern\fP
+.\"
+documentation.
+.sp
+  PCRE_EXTENDED
+.sp
+If this bit is set, whitespace data characters in the pattern are totally
+ignored except when escaped or inside a character class. Whitespace does not
+include the VT character (code 11). In addition, characters between an
+unescaped # outside a character class and the next newline, inclusive, are also
+ignored. This is equivalent to Perl's /x option, and it can be changed within a
+pattern by a (?x) option setting.
+.P
+This option makes it possible to include comments inside complicated patterns.
+Note, however, that this applies only to data characters. Whitespace characters
+may never appear within special character sequences in a pattern, for example
+within the sequence (?( which introduces a conditional subpattern.
+.sp
+  PCRE_EXTRA
+.sp
+This option was invented in order to turn on additional functionality of PCRE
+that is incompatible with Perl, but it is currently of very little use. When
+set, any backslash in a pattern that is followed by a letter that has no
+special meaning causes an error, thus reserving these combinations for future
+expansion. By default, as in Perl, a backslash followed by a letter with no
+special meaning is treated as a literal. (Perl can, however, be persuaded to
+give a warning for this.) There are at present no other features controlled by
+this option. It can also be set by a (?X) option setting within a pattern.
+.sp
+  PCRE_FIRSTLINE
+.sp
+If this option is set, an unanchored pattern is required to match before or at
+the first newline in the subject string, though the matched text may continue
+over the newline.
+.sp
+  PCRE_JAVASCRIPT_COMPAT
+.sp
+If this option is set, PCRE's behaviour is changed in some ways so that it is
+compatible with JavaScript rather than Perl. The changes are as follows:
+.P
+(1) A lone closing square bracket in a pattern causes a compile-time error,
+because this is illegal in JavaScript (by default it is treated as a data
+character). Thus, the pattern AB]CD becomes illegal when this option is set.
+.P
+(2) At run time, a back reference to an unset subpattern group matches an empty
+string (by default this causes the current matching alternative to fail). A
+pattern such as (\e1)(a) succeeds when this option is set (assuming it can find
+an "a" in the subject), whereas it fails by default, for Perl compatibility.
+.sp
+  PCRE_MULTILINE
+.sp
+By default, PCRE treats the subject string as consisting of a single line of
+characters (even if it actually contains newlines). The "start of line"
+metacharacter (^) matches only at the start of the string, while the "end of
+line" metacharacter ($) matches only at the end of the string, or before a
+terminating newline (unless PCRE_DOLLAR_ENDONLY is set). This is the same as
+Perl.
+.P
+When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs
+match immediately following or immediately before internal newlines in the
+subject string, respectively, as well as at the very start and end. This is
+equivalent to Perl's /m option, and it can be changed within a pattern by a
+(?m) option setting. If there are no newlines in a subject string, or no
+occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.
+.sp
+  PCRE_NEWLINE_CR
+  PCRE_NEWLINE_LF
+  PCRE_NEWLINE_CRLF
+  PCRE_NEWLINE_ANYCRLF
+  PCRE_NEWLINE_ANY
+.sp
+These options override the default newline definition that was chosen when PCRE
+was built. Setting the first or the second specifies that a newline is
+indicated by a single character (CR or LF, respectively). Setting
+PCRE_NEWLINE_CRLF specifies that a newline is indicated by the two-character
+CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies that any of the three
+preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
+that any Unicode newline sequence should be recognized. The Unicode newline
+sequences are the three just mentioned, plus the single characters VT (vertical
+tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
+separator, U+2028), and PS (paragraph separator, U+2029). The last two are
+recognized only in UTF-8 mode.
+.P
+The newline setting in the options word uses three bits that are treated
+as a number, giving eight possibilities. Currently only six are used (default
+plus the five values above). This means that if you set more than one newline
+option, the combination may or may not be sensible. For example,
+PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but
+other combinations may yield unused numbers and cause an error.
+.P
+The only time that a line break is specially recognized when compiling a
+pattern is if PCRE_EXTENDED is set, and an unescaped # outside a character
+class is encountered. This indicates a comment that lasts until after the next
+line break sequence. In other circumstances, line break sequences are treated
+as literal data, except that in PCRE_EXTENDED mode, both CR and LF are treated
+as whitespace characters and are therefore ignored.
+.P
+The newline option that is set at compile time becomes the default that is used
+for \fBpcre_exec()\fP and \fBpcre_dfa_exec()\fP, but it can be overridden.
+.sp
+  PCRE_NO_AUTO_CAPTURE
+.sp
+If this option is set, it disables the use of numbered capturing parentheses in
+the pattern. Any opening parenthesis that is not followed by ? behaves as if it
+were followed by ?: but named parentheses can still be used for capturing (and
+they acquire numbers in the usual way). There is no equivalent of this option
+in Perl.
+.sp
+  PCRE_UNGREEDY
+.sp
+This option inverts the "greediness" of the quantifiers so that they are not
+greedy by default, but become greedy if followed by "?". It is not compatible
+with Perl. It can also be set by a (?U) option setting within the pattern.
+.sp
+  PCRE_UTF8
+.sp
+This option causes PCRE to regard both the pattern and the subject as strings
+of UTF-8 characters instead of single-byte character strings. However, it is
+available only when PCRE is built to include UTF-8 support. If not, the use
+of this option provokes an error. Details of how this option changes the
+behaviour of PCRE are given in the
+.\" HTML <a href="pcre.html#utf8support">
+.\" </a>
+section on UTF-8 support
+.\"
+in the main
+.\" HREF
+\fBpcre\fP
+.\"
+page.
+.sp
+  PCRE_NO_UTF8_CHECK
+.sp
+When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
+automatically checked. There is a discussion about the
+.\" HTML <a href="pcre.html#utf8strings">
+.\" </a>
+validity of UTF-8 strings
+.\"
+in the main
+.\" HREF
+\fBpcre\fP
+.\"
+page. If an invalid UTF-8 sequence of bytes is found, \fBpcre_compile()\fP
+returns an error. If you already know that your pattern is valid, and you want
+to skip this check for performance reasons, you can set the PCRE_NO_UTF8_CHECK
+option. When it is set, the effect of passing an invalid UTF-8 string as a
+pattern is undefined. It may cause your program to crash. Note that this option
+can also be passed to \fBpcre_exec()\fP and \fBpcre_dfa_exec()\fP, to suppress
+the UTF-8 validity checking of subject strings.
+.
+.
+.SH "COMPILATION ERROR CODES"
+.rs
+.sp
+The following table lists the error codes than may be returned by
+\fBpcre_compile2()\fP, along with the error messages that may be returned by
+both compiling functions. As PCRE has developed, some error codes have fallen
+out of use. To avoid confusion, they have not been re-used.
+.sp
+   0  no error
+   1  \e at end of pattern
+   2  \ec at end of pattern
+   3  unrecognized character follows \e
+   4  numbers out of order in {} quantifier
+   5  number too big in {} quantifier
+   6  missing terminating ] for character class
+   7  invalid escape sequence in character class
+   8  range out of order in character class
+   9  nothing to repeat
+  10  [this code is not in use]
+  11  internal error: unexpected repeat
+  12  unrecognized character after (? or (?-
+  13  POSIX named classes are supported only within a class
+  14  missing )
+  15  reference to non-existent subpattern
+  16  erroffset passed as NULL
+  17  unknown option bit(s) set
+  18  missing ) after comment
+  19  [this code is not in use]
+  20  regular expression is too large
+  21  failed to get memory
+  22  unmatched parentheses
+  23  internal error: code overflow
+  24  unrecognized character after (?<
+  25  lookbehind assertion is not fixed length
+  26  malformed number or name after (?(
+  27  conditional group contains more than two branches
+  28  assertion expected after (?(
+  29  (?R or (?[+-]digits must be followed by )
+  30  unknown POSIX class name
+  31  POSIX collating elements are not supported
+  32  this version of PCRE is not compiled with PCRE_UTF8 support
+  33  [this code is not in use]
+  34  character value in \ex{...} sequence is too large
+  35  invalid condition (?(0)
+  36  \eC not allowed in lookbehind assertion
+  37  PCRE does not support \eL, \el, \eN, \eU, or \eu
+  38  number after (?C is > 255
+  39  closing ) for (?C expected
+  40  recursive call could loop indefinitely
+  41  unrecognized character after (?P
+  42  syntax error in subpattern name (missing terminator)
+  43  two named subpatterns have the same name
+  44  invalid UTF-8 string
+  45  support for \eP, \ep, and \eX has not been compiled
+  46  malformed \eP or \ep sequence
+  47  unknown property name after \eP or \ep
+  48  subpattern name is too long (maximum 32 characters)
+  49  too many named subpatterns (maximum 10000)
+  50  [this code is not in use]
+  51  octal value is greater than \e377 (not in UTF-8 mode)
+  52  internal error: overran compiling workspace
+  53  internal error: previously-checked referenced subpattern not found
+  54  DEFINE group contains more than one branch
+  55  repeating a DEFINE group is not allowed
+  56  inconsistent NEWLINE options
+  57  \eg is not followed by a braced, angle-bracketed, or quoted
+        name/number or by a plain number
+  58  a numbered reference must not be zero
+  59  (*VERB) with an argument is not supported
+  60  (*VERB) not recognized
+  61  number is too big
+  62  subpattern name expected
+  63  digit expected after (?+
+  64  ] is an invalid data character in JavaScript compatibility mode
+.sp
+The numbers 32 and 10000 in errors 48 and 49 are defaults; different values may
+be used if the limits were changed when PCRE was built.
+.
+.
+.SH "STUDYING A PATTERN"
+.rs
+.sp
+.B pcre_extra *pcre_study(const pcre *\fIcode\fP, int \fIoptions\fP
+.ti +5n
+.B const char **\fIerrptr\fP);
+.PP
+If a compiled pattern is going to be used several times, it is worth spending
+more time analyzing it in order to speed up the time taken for matching. The
+function \fBpcre_study()\fP takes a pointer to a compiled pattern as its first
+argument. If studying the pattern produces additional information that will
+help speed up matching, \fBpcre_study()\fP returns a pointer to a
+\fBpcre_extra\fP block, in which the \fIstudy_data\fP field points to the
+results of the study.
+.P
+The returned value from \fBpcre_study()\fP can be passed directly to
+\fBpcre_exec()\fP. However, a \fBpcre_extra\fP block also contains other
+fields that can be set by the caller before the block is passed; these are
+described
+.\" HTML <a href="#extradata">
+.\" </a>
+below
+.\"
+in the section on matching a pattern.
+.P
+If studying the pattern does not produce any additional information
+\fBpcre_study()\fP returns NULL. In that circumstance, if the calling program
+wants to pass any of the other fields to \fBpcre_exec()\fP, it must set up its
+own \fBpcre_extra\fP block.
+.P
+The second argument of \fBpcre_study()\fP contains option bits. At present, no
+options are defined, and this argument should always be zero.
+.P
+The third argument for \fBpcre_study()\fP is a pointer for an error message. If
+studying succeeds (even if no data is returned), the variable it points to is
+set to NULL. Otherwise it is set to point to a textual error message. This is a
+static string that is part of the library. You must not try to free it. You
+should test the error pointer for NULL after calling \fBpcre_study()\fP, to be
+sure that it has run successfully.
+.P
+This is a typical call to \fBpcre_study\fP():
+.sp
+  pcre_extra *pe;
+  pe = pcre_study(
+    re,             /* result of pcre_compile() */
+    0,              /* no options exist */
+    &error);        /* set to NULL or points to a message */
+.sp
+At present, studying a pattern is useful only for non-anchored patterns that do
+not have a single fixed starting character. A bitmap of possible starting
+bytes is created.
+.
+.
+.\" HTML <a name="localesupport"></a>
+.SH "LOCALE SUPPORT"
+.rs
+.sp
+PCRE handles caseless matching, and determines whether characters are letters,
+digits, or whatever, by reference to a set of tables, indexed by character
+value. When running in UTF-8 mode, this applies only to characters with codes
+less than 128. Higher-valued codes never match escapes such as \ew or \ed, but
+can be tested with \ep if PCRE is built with Unicode character property
+support. The use of locales with Unicode is discouraged. If you are handling
+characters with codes greater than 128, you should either use UTF-8 and
+Unicode, or use locales, but not try to mix the two.
+.P
+PCRE contains an internal set of tables that are used when the final argument
+of \fBpcre_compile()\fP is NULL. These are sufficient for many applications.
+Normally, the internal tables recognize only ASCII characters. However, when
+PCRE is built, it is possible to cause the internal tables to be rebuilt in the
+default "C" locale of the local system, which may cause them to be different.
+.P
+The internal tables can always be overridden by tables supplied by the
+application that calls PCRE. These may be created in a different locale from
+the default. As more and more applications change to using Unicode, the need
+for this locale support is expected to die away.
+.P
+External tables are built by calling the \fBpcre_maketables()\fP function,
+which has no arguments, in the relevant locale. The result can then be passed
+to \fBpcre_compile()\fP or \fBpcre_exec()\fP as often as necessary. For
+example, to build and use tables that are appropriate for the French locale
+(where accented characters with values greater than 128 are treated as letters),
+the following code could be used:
+.sp
+  setlocale(LC_CTYPE, "fr_FR");
+  tables = pcre_maketables();
+  re = pcre_compile(..., tables);
+.sp
+The locale name "fr_FR" is used on Linux and other Unix-like systems; if you
+are using Windows, the name for the French locale is "french".
+.P
+When \fBpcre_maketables()\fP runs, the tables are built in memory that is
+obtained via \fBpcre_malloc\fP. It is the caller's responsibility to ensure
+that the memory containing the tables remains available for as long as it is
+needed.
+.P
+The pointer that is passed to \fBpcre_compile()\fP is saved with the compiled
+pattern, and the same tables are used via this pointer by \fBpcre_study()\fP
+and normally also by \fBpcre_exec()\fP. Thus, by default, for any single
+pattern, compilation, studying and matching all happen in the same locale, but
+different patterns can be compiled in different locales.
+.P
+It is possible to pass a table pointer or NULL (indicating the use of the
+internal tables) to \fBpcre_exec()\fP. Although not intended for this purpose,
+this facility could be used to match a pattern in a different locale from the
+one in which it was compiled. Passing table pointers at run time is discussed
+below in the section on matching a pattern.
+.
+.
+.SH "INFORMATION ABOUT A PATTERN"
+.rs
+.sp
+.B int pcre_fullinfo(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B int \fIwhat\fP, void *\fIwhere\fP);
+.PP
+The \fBpcre_fullinfo()\fP function returns information about a compiled
+pattern. It replaces the obsolete \fBpcre_info()\fP function, which is
+nevertheless retained for backwards compability (and is documented below).
+.P
+The first argument for \fBpcre_fullinfo()\fP is a pointer to the compiled
+pattern. The second argument is the result of \fBpcre_study()\fP, or NULL if
+the pattern was not studied. The third argument specifies which piece of
+information is required, and the fourth argument is a pointer to a variable
+to receive the data. The yield of the function is zero for success, or one of
+the following negative numbers:
+.sp
+  PCRE_ERROR_NULL       the argument \fIcode\fP was NULL
+                        the argument \fIwhere\fP was NULL
+  PCRE_ERROR_BADMAGIC   the "magic number" was not found
+  PCRE_ERROR_BADOPTION  the value of \fIwhat\fP was invalid
+.sp
+The "magic number" is placed at the start of each compiled pattern as an simple
+check against passing an arbitrary memory pointer. Here is a typical call of
+\fBpcre_fullinfo()\fP, to obtain the length of the compiled pattern:
+.sp
+  int rc;
+  size_t length;
+  rc = pcre_fullinfo(
+    re,               /* result of pcre_compile() */
+    pe,               /* result of pcre_study(), or NULL */
+    PCRE_INFO_SIZE,   /* what is required */
+    &length);         /* where to put the data */
+.sp
+The possible values for the third argument are defined in \fBpcre.h\fP, and are
+as follows:
+.sp
+  PCRE_INFO_BACKREFMAX
+.sp
+Return the number of the highest back reference in the pattern. The fourth
+argument should point to an \fBint\fP variable. Zero is returned if there are
+no back references.
+.sp
+  PCRE_INFO_CAPTURECOUNT
+.sp
+Return the number of capturing subpatterns in the pattern. The fourth argument
+should point to an \fBint\fP variable.
+.sp
+  PCRE_INFO_DEFAULT_TABLES
+.sp
+Return a pointer to the internal default character tables within PCRE. The
+fourth argument should point to an \fBunsigned char *\fP variable. This
+information call is provided for internal use by the \fBpcre_study()\fP
+function. External callers can cause PCRE to use its internal tables by passing
+a NULL table pointer.
+.sp
+  PCRE_INFO_FIRSTBYTE
+.sp
+Return information about the first byte of any matched string, for a
+non-anchored pattern. The fourth argument should point to an \fBint\fP
+variable. (This option used to be called PCRE_INFO_FIRSTCHAR; the old name is
+still recognized for backwards compatibility.)
+.P
+If there is a fixed first byte, for example, from a pattern such as
+(cat|cow|coyote), its value is returned. Otherwise, if either
+.sp
+(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
+starts with "^", or
+.sp
+(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set
+(if it were set, the pattern would be anchored),
+.sp
+-1 is returned, indicating that the pattern matches only at the start of a
+subject string or after any newline within the string. Otherwise -2 is
+returned. For anchored patterns, -2 is returned.
+.sp
+  PCRE_INFO_FIRSTTABLE
+.sp
+If the pattern was studied, and this resulted in the construction of a 256-bit
+table indicating a fixed set of bytes for the first byte in any matching
+string, a pointer to the table is returned. Otherwise NULL is returned. The
+fourth argument should point to an \fBunsigned char *\fP variable.
+.sp
+  PCRE_INFO_HASCRORLF
+.sp
+Return 1 if the pattern contains any explicit matches for CR or LF characters,
+otherwise 0. The fourth argument should point to an \fBint\fP variable. An
+explicit match is either a literal CR or LF character, or \er or \en.
+.sp
+  PCRE_INFO_JCHANGED
+.sp
+Return 1 if the (?J) or (?-J) option setting is used in the pattern, otherwise
+0. The fourth argument should point to an \fBint\fP variable. (?J) and
+(?-J) set and unset the local PCRE_DUPNAMES option, respectively.
+.sp
+  PCRE_INFO_LASTLITERAL
+.sp
+Return the value of the rightmost literal byte that must exist in any matched
+string, other than at its start, if such a byte has been recorded. The fourth
+argument should point to an \fBint\fP variable. If there is no such byte, -1 is
+returned. For anchored patterns, a last literal byte is recorded only if it
+follows something of variable length. For example, for the pattern
+/^a\ed+z\ed+/ the returned value is "z", but for /^a\edz\ed/ the returned value
+is -1.
+.sp
+  PCRE_INFO_NAMECOUNT
+  PCRE_INFO_NAMEENTRYSIZE
+  PCRE_INFO_NAMETABLE
+.sp
+PCRE supports the use of named as well as numbered capturing parentheses. The
+names are just an additional way of identifying the parentheses, which still
+acquire numbers. Several convenience functions such as
+\fBpcre_get_named_substring()\fP are provided for extracting captured
+substrings by name. It is also possible to extract the data directly, by first
+converting the name to a number in order to access the correct pointers in the
+output vector (described with \fBpcre_exec()\fP below). To do the conversion,
+you need to use the name-to-number map, which is described by these three
+values.
+.P
+The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives
+the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each
+entry; both of these return an \fBint\fP value. The entry size depends on the
+length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first
+entry of the table (a pointer to \fBchar\fP). The first two bytes of each entry
+are the number of the capturing parenthesis, most significant byte first. The
+rest of the entry is the corresponding name, zero terminated. The names are in
+alphabetical order. When PCRE_DUPNAMES is set, duplicate names are in order of
+their parentheses numbers. For example, consider the following pattern (assume
+PCRE_EXTENDED is set, so white space - including newlines - is ignored):
+.sp
+.\" JOIN
+  (?<date> (?<year>(\ed\ed)?\ed\ed) -
+  (?<month>\ed\ed) - (?<day>\ed\ed) )
+.sp
+There are four named subpatterns, so the table has four entries, and each entry
+in the table is eight bytes long. The table is as follows, with non-printing
+bytes shows in hexadecimal, and undefined bytes shown as ??:
+.sp
+  00 01 d  a  t  e  00 ??
+  00 05 d  a  y  00 ?? ??
+  00 04 m  o  n  t  h  00
+  00 02 y  e  a  r  00 ??
+.sp
+When writing code to extract data from named subpatterns using the
+name-to-number map, remember that the length of the entries is likely to be
+different for each compiled pattern.
+.sp
+  PCRE_INFO_OKPARTIAL
+.sp
+Return 1 if the pattern can be used for partial matching, otherwise 0. The
+fourth argument should point to an \fBint\fP variable. The
+.\" HREF
+\fBpcrepartial\fP
+.\"
+documentation lists the restrictions that apply to patterns when partial
+matching is used.
+.sp
+  PCRE_INFO_OPTIONS
+.sp
+Return a copy of the options with which the pattern was compiled. The fourth
+argument should point to an \fBunsigned long int\fP variable. These option bits
+are those specified in the call to \fBpcre_compile()\fP, modified by any
+top-level option settings at the start of the pattern itself. In other words,
+they are the options that will be in force when matching starts. For example,
+if the pattern /(?im)abc(?-i)d/ is compiled with the PCRE_EXTENDED option, the
+result is PCRE_CASELESS, PCRE_MULTILINE, and PCRE_EXTENDED.
+.P
+A pattern is automatically anchored by PCRE if all of its top-level
+alternatives begin with one of the following:
+.sp
+  ^     unless PCRE_MULTILINE is set
+  \eA    always
+  \eG    always
+.\" JOIN
+  .*    if PCRE_DOTALL is set and there are no back
+          references to the subpattern in which .* appears
+.sp
+For such patterns, the PCRE_ANCHORED bit is set in the options returned by
+\fBpcre_fullinfo()\fP.
+.sp
+  PCRE_INFO_SIZE
+.sp
+Return the size of the compiled pattern, that is, the value that was passed as
+the argument to \fBpcre_malloc()\fP when PCRE was getting memory in which to
+place the compiled data. The fourth argument should point to a \fBsize_t\fP
+variable.
+.sp
+  PCRE_INFO_STUDYSIZE
+.sp
+Return the size of the data block pointed to by the \fIstudy_data\fP field in
+a \fBpcre_extra\fP block. That is, it is the value that was passed to
+\fBpcre_malloc()\fP when PCRE was getting memory into which to place the data
+created by \fBpcre_study()\fP. The fourth argument should point to a
+\fBsize_t\fP variable.
+.
+.
+.SH "OBSOLETE INFO FUNCTION"
+.rs
+.sp
+.B int pcre_info(const pcre *\fIcode\fP, int *\fIoptptr\fP, int
+.B *\fIfirstcharptr\fP);
+.PP
+The \fBpcre_info()\fP function is now obsolete because its interface is too
+restrictive to return all the available data about a compiled pattern. New
+programs should use \fBpcre_fullinfo()\fP instead. The yield of
+\fBpcre_info()\fP is the number of capturing subpatterns, or one of the
+following negative numbers:
+.sp
+  PCRE_ERROR_NULL       the argument \fIcode\fP was NULL
+  PCRE_ERROR_BADMAGIC   the "magic number" was not found
+.sp
+If the \fIoptptr\fP argument is not NULL, a copy of the options with which the
+pattern was compiled is placed in the integer it points to (see
+PCRE_INFO_OPTIONS above).
+.P
+If the pattern is not anchored and the \fIfirstcharptr\fP argument is not NULL,
+it is used to pass back information about the first character of any matched
+string (see PCRE_INFO_FIRSTBYTE above).
+.
+.
+.SH "REFERENCE COUNTS"
+.rs
+.sp
+.B int pcre_refcount(pcre *\fIcode\fP, int \fIadjust\fP);
+.PP
+The \fBpcre_refcount()\fP function is used to maintain a reference count in the
+data block that contains a compiled pattern. It is provided for the benefit of
+applications that operate in an object-oriented manner, where different parts
+of the application may be using the same compiled pattern, but you want to free
+the block when they are all done.
+.P
+When a pattern is compiled, the reference count field is initialized to zero.
+It is changed only by calling this function, whose action is to add the
+\fIadjust\fP value (which may be positive or negative) to it. The yield of the
+function is the new value. However, the value of the count is constrained to
+lie between 0 and 65535, inclusive. If the new value is outside these limits,
+it is forced to the appropriate limit value.
+.P
+Except when it is zero, the reference count is not correctly preserved if a
+pattern is compiled on one host and then transferred to a host whose byte-order
+is different. (This seems a highly unlikely scenario.)
+.
+.
+.SH "MATCHING A PATTERN: THE TRADITIONAL FUNCTION"
+.rs
+.sp
+.B int pcre_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
+.ti +5n
+.B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);
+.P
+The function \fBpcre_exec()\fP is called to match a subject string against a
+compiled pattern, which is passed in the \fIcode\fP argument. If the
+pattern has been studied, the result of the study should be passed in the
+\fIextra\fP argument. This function is the main matching facility of the
+library, and it operates in a Perl-like manner. For specialist use there is
+also an alternative matching function, which is described
+.\" HTML <a href="#dfamatch">
+.\" </a>
+below
+.\"
+in the section about the \fBpcre_dfa_exec()\fP function.
+.P
+In most applications, the pattern will have been compiled (and optionally
+studied) in the same process that calls \fBpcre_exec()\fP. However, it is
+possible to save compiled patterns and study data, and then use them later
+in different processes, possibly even on different hosts. For a discussion
+about this, see the
+.\" HREF
+\fBpcreprecompile\fP
+.\"
+documentation.
+.P
+Here is an example of a simple call to \fBpcre_exec()\fP:
+.sp
+  int rc;
+  int ovector[30];
+  rc = pcre_exec(
+    re,             /* result of pcre_compile() */
+    NULL,           /* we didn't study the pattern */
+    "some string",  /* the subject string */
+    11,             /* the length of the subject string */
+    0,              /* start at offset 0 in the subject */
+    0,              /* default options */
+    ovector,        /* vector of integers for substring information */
+    30);            /* number of elements (NOT size in bytes) */
+.
+.\" HTML <a name="extradata"></a>
+.SS "Extra data for \fBpcre_exec()\fR"
+.rs
+.sp
+If the \fIextra\fP argument is not NULL, it must point to a \fBpcre_extra\fP
+data block. The \fBpcre_study()\fP function returns such a block (when it
+doesn't return NULL), but you can also create one for yourself, and pass
+additional information in it. The \fBpcre_extra\fP block contains the following
+fields (not necessarily in this order):
+.sp
+  unsigned long int \fIflags\fP;
+  void *\fIstudy_data\fP;
+  unsigned long int \fImatch_limit\fP;
+  unsigned long int \fImatch_limit_recursion\fP;
+  void *\fIcallout_data\fP;
+  const unsigned char *\fItables\fP;
+.sp
+The \fIflags\fP field is a bitmap that specifies which of the other fields
+are set. The flag bits are:
+.sp
+  PCRE_EXTRA_STUDY_DATA
+  PCRE_EXTRA_MATCH_LIMIT
+  PCRE_EXTRA_MATCH_LIMIT_RECURSION
+  PCRE_EXTRA_CALLOUT_DATA
+  PCRE_EXTRA_TABLES
+.sp
+Other flag bits should be set to zero. The \fIstudy_data\fP field is set in the
+\fBpcre_extra\fP block that is returned by \fBpcre_study()\fP, together with
+the appropriate flag bit. You should not set this yourself, but you may add to
+the block by setting the other fields and their corresponding flag bits.
+.P
+The \fImatch_limit\fP field provides a means of preventing PCRE from using up a
+vast amount of resources when running patterns that are not going to match,
+but which have a very large number of possibilities in their search trees. The
+classic example is the use of nested unlimited repeats.
+.P
+Internally, PCRE uses a function called \fBmatch()\fP which it calls repeatedly
+(sometimes recursively). The limit set by \fImatch_limit\fP is imposed on the
+number of times this function is called during a match, which has the effect of
+limiting the amount of backtracking that can take place. For patterns that are
+not anchored, the count restarts from zero for each position in the subject
+string.
+.P
+The default value for the limit can be set when PCRE is built; the default
+default is 10 million, which handles all but the most extreme cases. You can
+override the default by suppling \fBpcre_exec()\fP with a \fBpcre_extra\fP
+block in which \fImatch_limit\fP is set, and PCRE_EXTRA_MATCH_LIMIT is set in
+the \fIflags\fP field. If the limit is exceeded, \fBpcre_exec()\fP returns
+PCRE_ERROR_MATCHLIMIT.
+.P
+The \fImatch_limit_recursion\fP field is similar to \fImatch_limit\fP, but
+instead of limiting the total number of times that \fBmatch()\fP is called, it
+limits the depth of recursion. The recursion depth is a smaller number than the
+total number of calls, because not all calls to \fBmatch()\fP are recursive.
+This limit is of use only if it is set smaller than \fImatch_limit\fP.
+.P
+Limiting the recursion depth limits the amount of stack that can be used, or,
+when PCRE has been compiled to use memory on the heap instead of the stack, the
+amount of heap memory that can be used.
+.P
+The default value for \fImatch_limit_recursion\fP can be set when PCRE is
+built; the default default is the same value as the default for
+\fImatch_limit\fP. You can override the default by suppling \fBpcre_exec()\fP
+with a \fBpcre_extra\fP block in which \fImatch_limit_recursion\fP is set, and
+PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in the \fIflags\fP field. If the limit
+is exceeded, \fBpcre_exec()\fP returns PCRE_ERROR_RECURSIONLIMIT.
+.P
+The \fIpcre_callout\fP field is used in conjunction with the "callout" feature,
+which is described in the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation.
+.P
+The \fItables\fP field is used to pass a character tables pointer to
+\fBpcre_exec()\fP; this overrides the value that is stored with the compiled
+pattern. A non-NULL value is stored with the compiled pattern only if custom
+tables were supplied to \fBpcre_compile()\fP via its \fItableptr\fP argument.
+If NULL is passed to \fBpcre_exec()\fP using this mechanism, it forces PCRE's
+internal tables to be used. This facility is helpful when re-using patterns
+that have been saved after compiling with an external set of tables, because
+the external tables might be at a different address when \fBpcre_exec()\fP is
+called. See the
+.\" HREF
+\fBpcreprecompile\fP
+.\"
+documentation for a discussion of saving compiled patterns for later use.
+.
+.\" HTML <a name="execoptions"></a>
+.SS "Option bits for \fBpcre_exec()\fP"
+.rs
+.sp
+The unused bits of the \fIoptions\fP argument for \fBpcre_exec()\fP must be
+zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEWLINE_\fIxxx\fP,
+PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK and PCRE_PARTIAL.
+.sp
+  PCRE_ANCHORED
+.sp
+The PCRE_ANCHORED option limits \fBpcre_exec()\fP to matching at the first
+matching position. If a pattern was compiled with PCRE_ANCHORED, or turned out
+to be anchored by virtue of its contents, it cannot be made unachored at
+matching time.
+.sp
+  PCRE_BSR_ANYCRLF
+  PCRE_BSR_UNICODE
+.sp
+These options (which are mutually exclusive) control what the \eR escape
+sequence matches. The choice is either to match only CR, LF, or CRLF, or to
+match any Unicode newline sequence. These options override the choice that was
+made or defaulted when the pattern was compiled.
+.sp
+  PCRE_NEWLINE_CR
+  PCRE_NEWLINE_LF
+  PCRE_NEWLINE_CRLF
+  PCRE_NEWLINE_ANYCRLF
+  PCRE_NEWLINE_ANY
+.sp
+These options override the newline definition that was chosen or defaulted when
+the pattern was compiled. For details, see the description of
+\fBpcre_compile()\fP above. During matching, the newline choice affects the
+behaviour of the dot, circumflex, and dollar metacharacters. It may also alter
+the way the match position is advanced after a match failure for an unanchored
+pattern.
+.P
+When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is set, and a
+match attempt for an unanchored pattern fails when the current position is at a
+CRLF sequence, and the pattern contains no explicit matches for CR or LF
+characters, the match position is advanced by two characters instead of one, in
+other words, to after the CRLF.
+.P
+The above rule is a compromise that makes the most common cases work as
+expected. For example, if the pattern is .+A (and the PCRE_DOTALL option is not
+set), it does not match the string "\er\enA" because, after failing at the
+start, it skips both the CR and the LF before retrying. However, the pattern
+[\er\en]A does match that string, because it contains an explicit CR or LF
+reference, and so advances only by one character after the first failure.
+.P
+An explicit match for CR of LF is either a literal appearance of one of those
+characters, or one of the \er or \en escape sequences. Implicit matches such as
+[^X] do not count, nor does \es (which includes CR and LF in the characters
+that it matches).
+.P
+Notwithstanding the above, anomalous effects may still occur when CRLF is a
+valid newline sequence and explicit \er or \en escapes appear in the pattern.
+.sp
+  PCRE_NOTBOL
+.sp
+This option specifies that first character of the subject string is not the
+beginning of a line, so the circumflex metacharacter should not match before
+it. Setting this without PCRE_MULTILINE (at compile time) causes circumflex
+never to match. This option affects only the behaviour of the circumflex
+metacharacter. It does not affect \eA.
+.sp
+  PCRE_NOTEOL
+.sp
+This option specifies that the end of the subject string is not the end of a
+line, so the dollar metacharacter should not match it nor (except in multiline
+mode) a newline immediately before it. Setting this without PCRE_MULTILINE (at
+compile time) causes dollar never to match. This option affects only the
+behaviour of the dollar metacharacter. It does not affect \eZ or \ez.
+.sp
+  PCRE_NOTEMPTY
+.sp
+An empty string is not considered to be a valid match if this option is set. If
+there are alternatives in the pattern, they are tried. If all the alternatives
+match the empty string, the entire match fails. For example, if the pattern
+.sp
+  a?b?
+.sp
+is applied to a string not beginning with "a" or "b", it matches the empty
+string at the start of the subject. With PCRE_NOTEMPTY set, this match is not
+valid, so PCRE searches further into the string for occurrences of "a" or "b".
+.P
+Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a special case
+of a pattern match of the empty string within its \fBsplit()\fP function, and
+when using the /g modifier. It is possible to emulate Perl's behaviour after
+matching a null string by first trying the match again at the same offset with
+PCRE_NOTEMPTY and PCRE_ANCHORED, and then if that fails by advancing the
+starting offset (see below) and trying an ordinary match again. There is some
+code that demonstrates how to do this in the \fIpcredemo.c\fP sample program.
+.sp
+  PCRE_NO_UTF8_CHECK
+.sp
+When PCRE_UTF8 is set at compile time, the validity of the subject as a UTF-8
+string is automatically checked when \fBpcre_exec()\fP is subsequently called.
+The value of \fIstartoffset\fP is also checked to ensure that it points to the
+start of a UTF-8 character. There is a discussion about the validity of UTF-8
+strings in the
+.\" HTML <a href="pcre.html#utf8strings">
+.\" </a>
+section on UTF-8 support
+.\"
+in the main
+.\" HREF
+\fBpcre\fP
+.\"
+page. If an invalid UTF-8 sequence of bytes is found, \fBpcre_exec()\fP returns
+the error PCRE_ERROR_BADUTF8. If \fIstartoffset\fP contains an invalid value,
+PCRE_ERROR_BADUTF8_OFFSET is returned.
+.P
+If you already know that your subject is valid, and you want to skip these
+checks for performance reasons, you can set the PCRE_NO_UTF8_CHECK option when
+calling \fBpcre_exec()\fP. You might want to do this for the second and
+subsequent calls to \fBpcre_exec()\fP if you are making repeated calls to find
+all the matches in a single subject string. However, you should be sure that
+the value of \fIstartoffset\fP points to the start of a UTF-8 character. When
+PCRE_NO_UTF8_CHECK is set, the effect of passing an invalid UTF-8 string as a
+subject, or a value of \fIstartoffset\fP that does not point to the start of a
+UTF-8 character, is undefined. Your program may crash.
+.sp
+  PCRE_PARTIAL
+.sp
+This option turns on the partial matching feature. If the subject string fails
+to match the pattern, but at some point during the matching process the end of
+the subject was reached (that is, the subject partially matches the pattern and
+the failure to match occurred only because there were not enough subject
+characters), \fBpcre_exec()\fP returns PCRE_ERROR_PARTIAL instead of
+PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is used, there are restrictions on what
+may appear in the pattern. These are discussed in the
+.\" HREF
+\fBpcrepartial\fP
+.\"
+documentation.
+.
+.SS "The string to be matched by \fBpcre_exec()\fP"
+.rs
+.sp
+The subject string is passed to \fBpcre_exec()\fP as a pointer in
+\fIsubject\fP, a length (in bytes) in \fIlength\fP, and a starting byte offset
+in \fIstartoffset\fP. In UTF-8 mode, the byte offset must point to the start of
+a UTF-8 character. Unlike the pattern string, the subject may contain binary
+zero bytes. When the starting offset is zero, the search for a match starts at
+the beginning of the subject, and this is by far the most common case.
+.P
+A non-zero starting offset is useful when searching for another match in the
+same subject by calling \fBpcre_exec()\fP again after a previous success.
+Setting \fIstartoffset\fP differs from just passing over a shortened string and
+setting PCRE_NOTBOL in the case of a pattern that begins with any kind of
+lookbehind. For example, consider the pattern
+.sp
+  \eBiss\eB
+.sp
+which finds occurrences of "iss" in the middle of words. (\eB matches only if
+the current position in the subject is not a word boundary.) When applied to
+the string "Mississipi" the first call to \fBpcre_exec()\fP finds the first
+occurrence. If \fBpcre_exec()\fP is called again with just the remainder of the
+subject, namely "issipi", it does not match, because \eB is always false at the
+start of the subject, which is deemed to be a word boundary. However, if
+\fBpcre_exec()\fP is passed the entire string again, but with \fIstartoffset\fP
+set to 4, it finds the second occurrence of "iss" because it is able to look
+behind the starting point to discover that it is preceded by a letter.
+.P
+If a non-zero starting offset is passed when the pattern is anchored, one
+attempt to match at the given offset is made. This can only succeed if the
+pattern does not require the match to be at the start of the subject.
+.
+.SS "How \fBpcre_exec()\fP returns captured substrings"
+.rs
+.sp
+In general, a pattern matches a certain portion of the subject, and in
+addition, further substrings from the subject may be picked out by parts of the
+pattern. Following the usage in Jeffrey Friedl's book, this is called
+"capturing" in what follows, and the phrase "capturing subpattern" is used for
+a fragment of a pattern that picks out a substring. PCRE supports several other
+kinds of parenthesized subpattern that do not cause substrings to be captured.
+.P
+Captured substrings are returned to the caller via a vector of integers whose
+address is passed in \fIovector\fP. The number of elements in the vector is
+passed in \fIovecsize\fP, which must be a non-negative number. \fBNote\fP: this
+argument is NOT the size of \fIovector\fP in bytes.
+.P
+The first two-thirds of the vector is used to pass back captured substrings,
+each substring using a pair of integers. The remaining third of the vector is
+used as workspace by \fBpcre_exec()\fP while matching capturing subpatterns,
+and is not available for passing back information. The number passed in
+\fIovecsize\fP should always be a multiple of three. If it is not, it is
+rounded down.
+.P
+When a match is successful, information about captured substrings is returned
+in pairs of integers, starting at the beginning of \fIovector\fP, and
+continuing up to two-thirds of its length at the most. The first element of
+each pair is set to the byte offset of the first character in a substring, and
+the second is set to the byte offset of the first character after the end of a
+substring. \fBNote\fP: these values are always byte offsets, even in UTF-8
+mode. They are not character counts.
+.P
+The first pair of integers, \fIovector[0]\fP and \fIovector[1]\fP, identify the
+portion of the subject string matched by the entire pattern. The next pair is
+used for the first capturing subpattern, and so on. The value returned by
+\fBpcre_exec()\fP is one more than the highest numbered pair that has been set.
+For example, if two substrings have been captured, the returned value is 3. If
+there are no capturing subpatterns, the return value from a successful match is
+1, indicating that just the first pair of offsets has been set.
+.P
+If a capturing subpattern is matched repeatedly, it is the last portion of the
+string that it matched that is returned.
+.P
+If the vector is too small to hold all the captured substring offsets, it is
+used as far as possible (up to two-thirds of its length), and the function
+returns a value of zero. If the substring offsets are not of interest,
+\fBpcre_exec()\fP may be called with \fIovector\fP passed as NULL and
+\fIovecsize\fP as zero. However, if the pattern contains back references and
+the \fIovector\fP is not big enough to remember the related substrings, PCRE
+has to get additional memory for use during matching. Thus it is usually
+advisable to supply an \fIovector\fP.
+.P
+The \fBpcre_info()\fP function can be used to find out how many capturing
+subpatterns there are in a compiled pattern. The smallest size for
+\fIovector\fP that will allow for \fIn\fP captured substrings, in addition to
+the offsets of the substring matched by the whole pattern, is (\fIn\fP+1)*3.
+.P
+It is possible for capturing subpattern number \fIn+1\fP to match some part of
+the subject when subpattern \fIn\fP has not been used at all. For example, if
+the string "abc" is matched against the pattern (a|(z))(bc) the return from the
+function is 4, and subpatterns 1 and 3 are matched, but 2 is not. When this
+happens, both values in the offset pairs corresponding to unused subpatterns
+are set to -1.
+.P
+Offset values that correspond to unused subpatterns at the end of the
+expression are also set to -1. For example, if the string "abc" is matched
+against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not matched. The
+return from the function is 2, because the highest used capturing subpattern
+number is 1. However, you can refer to the offsets for the second and third
+capturing subpatterns if you wish (assuming the vector is large enough, of
+course).
+.P
+Some convenience functions are provided for extracting the captured substrings
+as separate strings. These are described below.
+.
+.\" HTML <a name="errorlist"></a>
+.SS "Error return values from \fBpcre_exec()\fP"
+.rs
+.sp
+If \fBpcre_exec()\fP fails, it returns a negative number. The following are
+defined in the header file:
+.sp
+  PCRE_ERROR_NOMATCH        (-1)
+.sp
+The subject string did not match the pattern.
+.sp
+  PCRE_ERROR_NULL           (-2)
+.sp
+Either \fIcode\fP or \fIsubject\fP was passed as NULL, or \fIovector\fP was
+NULL and \fIovecsize\fP was not zero.
+.sp
+  PCRE_ERROR_BADOPTION      (-3)
+.sp
+An unrecognized bit was set in the \fIoptions\fP argument.
+.sp
+  PCRE_ERROR_BADMAGIC       (-4)
+.sp
+PCRE stores a 4-byte "magic number" at the start of the compiled code, to catch
+the case when it is passed a junk pointer and to detect when a pattern that was
+compiled in an environment of one endianness is run in an environment with the
+other endianness. This is the error that PCRE gives when the magic number is
+not present.
+.sp
+  PCRE_ERROR_UNKNOWN_OPCODE (-5)
+.sp
+While running the pattern match, an unknown item was encountered in the
+compiled pattern. This error could be caused by a bug in PCRE or by overwriting
+of the compiled pattern.
+.sp
+  PCRE_ERROR_NOMEMORY       (-6)
+.sp
+If a pattern contains back references, but the \fIovector\fP that is passed to
+\fBpcre_exec()\fP is not big enough to remember the referenced substrings, PCRE
+gets a block of memory at the start of matching to use for this purpose. If the
+call via \fBpcre_malloc()\fP fails, this error is given. The memory is
+automatically freed at the end of matching.
+.sp
+  PCRE_ERROR_NOSUBSTRING    (-7)
+.sp
+This error is used by the \fBpcre_copy_substring()\fP,
+\fBpcre_get_substring()\fP, and \fBpcre_get_substring_list()\fP functions (see
+below). It is never returned by \fBpcre_exec()\fP.
+.sp
+  PCRE_ERROR_MATCHLIMIT     (-8)
+.sp
+The backtracking limit, as specified by the \fImatch_limit\fP field in a
+\fBpcre_extra\fP structure (or defaulted) was reached. See the description
+above.
+.sp
+  PCRE_ERROR_CALLOUT        (-9)
+.sp
+This error is never generated by \fBpcre_exec()\fP itself. It is provided for
+use by callout functions that want to yield a distinctive error code. See the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation for details.
+.sp
+  PCRE_ERROR_BADUTF8        (-10)
+.sp
+A string that contains an invalid UTF-8 byte sequence was passed as a subject.
+.sp
+  PCRE_ERROR_BADUTF8_OFFSET (-11)
+.sp
+The UTF-8 byte sequence that was passed as a subject was valid, but the value
+of \fIstartoffset\fP did not point to the beginning of a UTF-8 character.
+.sp
+  PCRE_ERROR_PARTIAL        (-12)
+.sp
+The subject string did not match, but it did match partially. See the
+.\" HREF
+\fBpcrepartial\fP
+.\"
+documentation for details of partial matching.
+.sp
+  PCRE_ERROR_BADPARTIAL     (-13)
+.sp
+The PCRE_PARTIAL option was used with a compiled pattern containing items that
+are not supported for partial matching. See the
+.\" HREF
+\fBpcrepartial\fP
+.\"
+documentation for details of partial matching.
+.sp
+  PCRE_ERROR_INTERNAL       (-14)
+.sp
+An unexpected internal error has occurred. This error could be caused by a bug
+in PCRE or by overwriting of the compiled pattern.
+.sp
+  PCRE_ERROR_BADCOUNT       (-15)
+.sp
+This error is given if the value of the \fIovecsize\fP argument is negative.
+.sp
+  PCRE_ERROR_RECURSIONLIMIT (-21)
+.sp
+The internal recursion limit, as specified by the \fImatch_limit_recursion\fP
+field in a \fBpcre_extra\fP structure (or defaulted) was reached. See the
+description above.
+.sp
+  PCRE_ERROR_BADNEWLINE     (-23)
+.sp
+An invalid combination of PCRE_NEWLINE_\fIxxx\fP options was given.
+.P
+Error numbers -16 to -20 and -22 are not used by \fBpcre_exec()\fP.
+.
+.
+.SH "EXTRACTING CAPTURED SUBSTRINGS BY NUMBER"
+.rs
+.sp
+.B int pcre_copy_substring(const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, int \fIstringnumber\fP, char *\fIbuffer\fP,
+.ti +5n
+.B int \fIbuffersize\fP);
+.PP
+.B int pcre_get_substring(const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, int \fIstringnumber\fP,
+.ti +5n
+.B const char **\fIstringptr\fP);
+.PP
+.B int pcre_get_substring_list(const char *\fIsubject\fP,
+.ti +5n
+.B int *\fIovector\fP, int \fIstringcount\fP, "const char ***\fIlistptr\fP);"
+.PP
+Captured substrings can be accessed directly by using the offsets returned by
+\fBpcre_exec()\fP in \fIovector\fP. For convenience, the functions
+\fBpcre_copy_substring()\fP, \fBpcre_get_substring()\fP, and
+\fBpcre_get_substring_list()\fP are provided for extracting captured substrings
+as new, separate, zero-terminated strings. These functions identify substrings
+by number. The next section describes functions for extracting named
+substrings.
+.P
+A substring that contains a binary zero is correctly extracted and has a
+further zero added on the end, but the result is not, of course, a C string.
+However, you can process such a string by referring to the length that is
+returned by \fBpcre_copy_substring()\fP and \fBpcre_get_substring()\fP.
+Unfortunately, the interface to \fBpcre_get_substring_list()\fP is not adequate
+for handling strings containing binary zeros, because the end of the final
+string is not independently indicated.
+.P
+The first three arguments are the same for all three of these functions:
+\fIsubject\fP is the subject string that has just been successfully matched,
+\fIovector\fP is a pointer to the vector of integer offsets that was passed to
+\fBpcre_exec()\fP, and \fIstringcount\fP is the number of substrings that were
+captured by the match, including the substring that matched the entire regular
+expression. This is the value returned by \fBpcre_exec()\fP if it is greater
+than zero. If \fBpcre_exec()\fP returned zero, indicating that it ran out of
+space in \fIovector\fP, the value passed as \fIstringcount\fP should be the
+number of elements in the vector divided by three.
+.P
+The functions \fBpcre_copy_substring()\fP and \fBpcre_get_substring()\fP
+extract a single substring, whose number is given as \fIstringnumber\fP. A
+value of zero extracts the substring that matched the entire pattern, whereas
+higher values extract the captured substrings. For \fBpcre_copy_substring()\fP,
+the string is placed in \fIbuffer\fP, whose length is given by
+\fIbuffersize\fP, while for \fBpcre_get_substring()\fP a new block of memory is
+obtained via \fBpcre_malloc\fP, and its address is returned via
+\fIstringptr\fP. The yield of the function is the length of the string, not
+including the terminating zero, or one of these error codes:
+.sp
+  PCRE_ERROR_NOMEMORY       (-6)
+.sp
+The buffer was too small for \fBpcre_copy_substring()\fP, or the attempt to get
+memory failed for \fBpcre_get_substring()\fP.
+.sp
+  PCRE_ERROR_NOSUBSTRING    (-7)
+.sp
+There is no substring whose number is \fIstringnumber\fP.
+.P
+The \fBpcre_get_substring_list()\fP function extracts all available substrings
+and builds a list of pointers to them. All this is done in a single block of
+memory that is obtained via \fBpcre_malloc\fP. The address of the memory block
+is returned via \fIlistptr\fP, which is also the start of the list of string
+pointers. The end of the list is marked by a NULL pointer. The yield of the
+function is zero if all went well, or the error code
+.sp
+  PCRE_ERROR_NOMEMORY       (-6)
+.sp
+if the attempt to get the memory block failed.
+.P
+When any of these functions encounter a substring that is unset, which can
+happen when capturing subpattern number \fIn+1\fP matches some part of the
+subject, but subpattern \fIn\fP has not been used at all, they return an empty
+string. This can be distinguished from a genuine zero-length substring by
+inspecting the appropriate offset in \fIovector\fP, which is negative for unset
+substrings.
+.P
+The two convenience functions \fBpcre_free_substring()\fP and
+\fBpcre_free_substring_list()\fP can be used to free the memory returned by
+a previous call of \fBpcre_get_substring()\fP or
+\fBpcre_get_substring_list()\fP, respectively. They do nothing more than call
+the function pointed to by \fBpcre_free\fP, which of course could be called
+directly from a C program. However, PCRE is used in some situations where it is
+linked via a special interface to another programming language that cannot use
+\fBpcre_free\fP directly; it is for these cases that the functions are
+provided.
+.
+.
+.SH "EXTRACTING CAPTURED SUBSTRINGS BY NAME"
+.rs
+.sp
+.B int pcre_get_stringnumber(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIname\fP);
+.PP
+.B int pcre_copy_named_substring(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, const char *\fIstringname\fP,
+.ti +5n
+.B char *\fIbuffer\fP, int \fIbuffersize\fP);
+.PP
+.B int pcre_get_named_substring(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIsubject\fP, int *\fIovector\fP,
+.ti +5n
+.B int \fIstringcount\fP, const char *\fIstringname\fP,
+.ti +5n
+.B const char **\fIstringptr\fP);
+.PP
+To extract a substring by name, you first have to find associated number.
+For example, for this pattern
+.sp
+  (a+)b(?<xxx>\ed+)...
+.sp
+the number of the subpattern called "xxx" is 2. If the name is known to be
+unique (PCRE_DUPNAMES was not set), you can find the number from the name by
+calling \fBpcre_get_stringnumber()\fP. The first argument is the compiled
+pattern, and the second is the name. The yield of the function is the
+subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if there is no subpattern of
+that name.
+.P
+Given the number, you can extract the substring directly, or use one of the
+functions described in the previous section. For convenience, there are also
+two functions that do the whole job.
+.P
+Most of the arguments of \fBpcre_copy_named_substring()\fP and
+\fBpcre_get_named_substring()\fP are the same as those for the similarly named
+functions that extract by number. As these are described in the previous
+section, they are not re-described here. There are just two differences:
+.P
+First, instead of a substring number, a substring name is given. Second, there
+is an extra argument, given at the start, which is a pointer to the compiled
+pattern. This is needed in order to gain access to the name-to-number
+translation table.
+.P
+These functions call \fBpcre_get_stringnumber()\fP, and if it succeeds, they
+then call \fBpcre_copy_substring()\fP or \fBpcre_get_substring()\fP, as
+appropriate. \fBNOTE:\fP If PCRE_DUPNAMES is set and there are duplicate names,
+the behaviour may not be what you want (see the next section).
+.
+.
+.SH "DUPLICATE SUBPATTERN NAMES"
+.rs
+.sp
+.B int pcre_get_stringtable_entries(const pcre *\fIcode\fP,
+.ti +5n
+.B const char *\fIname\fP, char **\fIfirst\fP, char **\fIlast\fP);
+.PP
+When a pattern is compiled with the PCRE_DUPNAMES option, names for subpatterns
+are not required to be unique. Normally, patterns with duplicate names are such
+that in any one match, only one of the named subpatterns participates. An
+example is shown in the
+.\" HREF
+\fBpcrepattern\fP
+.\"
+documentation.
+.P
+When duplicates are present, \fBpcre_copy_named_substring()\fP and
+\fBpcre_get_named_substring()\fP return the first substring corresponding to
+the given name that is set. If none are set, PCRE_ERROR_NOSUBSTRING (-7) is
+returned; no data is returned. The \fBpcre_get_stringnumber()\fP function
+returns one of the numbers that are associated with the name, but it is not
+defined which it is.
+.P
+If you want to get full details of all captured substrings for a given name,
+you must use the \fBpcre_get_stringtable_entries()\fP function. The first
+argument is the compiled pattern, and the second is the name. The third and
+fourth are pointers to variables which are updated by the function. After it
+has run, they point to the first and last entries in the name-to-number table
+for the given name. The function itself returns the length of each entry, or
+PCRE_ERROR_NOSUBSTRING (-7) if there are none. The format of the table is
+described above in the section entitled \fIInformation about a pattern\fP.
+Given all the relevant entries for the name, you can extract each of their
+numbers, and hence the captured data, if any.
+.
+.
+.SH "FINDING ALL POSSIBLE MATCHES"
+.rs
+.sp
+The traditional matching function uses a similar algorithm to Perl, which stops
+when it finds the first match, starting at a given point in the subject. If you
+want to find all possible matches, or the longest possible match, consider
+using the alternative matching function (see below) instead. If you cannot use
+the alternative function, but still need to find all possible matches, you
+can kludge it up by making use of the callout facility, which is described in
+the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation.
+.P
+What you have to do is to insert a callout right at the end of the pattern.
+When your callout function is called, extract and save the current matched
+substring. Then return 1, which forces \fBpcre_exec()\fP to backtrack and try
+other alternatives. Ultimately, when it runs out of matches, \fBpcre_exec()\fP
+will yield PCRE_ERROR_NOMATCH.
+.
+.
+.\" HTML <a name="dfamatch"></a>
+.SH "MATCHING A PATTERN: THE ALTERNATIVE FUNCTION"
+.rs
+.sp
+.B int pcre_dfa_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
+.ti +5n
+.B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
+.ti +5n
+.B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP,
+.ti +5n
+.B int *\fIworkspace\fP, int \fIwscount\fP);
+.P
+The function \fBpcre_dfa_exec()\fP is called to match a subject string against
+a compiled pattern, using a matching algorithm that scans the subject string
+just once, and does not backtrack. This has different characteristics to the
+normal algorithm, and is not compatible with Perl. Some of the features of PCRE
+patterns are not supported. Nevertheless, there are times when this kind of
+matching can be useful. For a discussion of the two matching algorithms, see
+the
+.\" HREF
+\fBpcrematching\fP
+.\"
+documentation.
+.P
+The arguments for the \fBpcre_dfa_exec()\fP function are the same as for
+\fBpcre_exec()\fP, plus two extras. The \fIovector\fP argument is used in a
+different way, and this is described below. The other common arguments are used
+in the same way as for \fBpcre_exec()\fP, so their description is not repeated
+here.
+.P
+The two additional arguments provide workspace for the function. The workspace
+vector should contain at least 20 elements. It is used for keeping track of
+multiple paths through the pattern tree. More workspace will be needed for
+patterns and subjects where there are a lot of potential matches.
+.P
+Here is an example of a simple call to \fBpcre_dfa_exec()\fP:
+.sp
+  int rc;
+  int ovector[10];
+  int wspace[20];
+  rc = pcre_dfa_exec(
+    re,             /* result of pcre_compile() */
+    NULL,           /* we didn't study the pattern */
+    "some string",  /* the subject string */
+    11,             /* the length of the subject string */
+    0,              /* start at offset 0 in the subject */
+    0,              /* default options */
+    ovector,        /* vector of integers for substring information */
+    10,             /* number of elements (NOT size in bytes) */
+    wspace,         /* working space vector */
+    20);            /* number of elements (NOT size in bytes) */
+.
+.SS "Option bits for \fBpcre_dfa_exec()\fP"
+.rs
+.sp
+The unused bits of the \fIoptions\fP argument for \fBpcre_dfa_exec()\fP must be
+zero. The only bits that may be set are PCRE_ANCHORED, PCRE_NEWLINE_\fIxxx\fP,
+PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK, PCRE_PARTIAL,
+PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last three of these are
+the same as for \fBpcre_exec()\fP, so their description is not repeated here.
+.sp
+  PCRE_PARTIAL
+.sp
+This has the same general effect as it does for \fBpcre_exec()\fP, but the
+details are slightly different. When PCRE_PARTIAL is set for
+\fBpcre_dfa_exec()\fP, the return code PCRE_ERROR_NOMATCH is converted into
+PCRE_ERROR_PARTIAL if the end of the subject is reached, there have been no
+complete matches, but there is still at least one matching possibility. The
+portion of the string that provided the partial match is set as the first
+matching string.
+.sp
+  PCRE_DFA_SHORTEST
+.sp
+Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to stop as
+soon as it has found one match. Because of the way the alternative algorithm
+works, this is necessarily the shortest possible match at the first possible
+matching point in the subject string.
+.sp
+  PCRE_DFA_RESTART
+.sp
+When \fBpcre_dfa_exec()\fP is called with the PCRE_PARTIAL option, and returns
+a partial match, it is possible to call it again, with additional subject
+characters, and have it continue with the same match. The PCRE_DFA_RESTART
+option requests this action; when it is set, the \fIworkspace\fP and
+\fIwscount\fP options must reference the same vector as before because data
+about the match so far is left in them after a partial match. There is more
+discussion of this facility in the
+.\" HREF
+\fBpcrepartial\fP
+.\"
+documentation.
+.
+.SS "Successful returns from \fBpcre_dfa_exec()\fP"
+.rs
+.sp
+When \fBpcre_dfa_exec()\fP succeeds, it may have matched more than one
+substring in the subject. Note, however, that all the matches from one run of
+the function start at the same point in the subject. The shorter matches are
+all initial substrings of the longer matches. For example, if the pattern
+.sp
+  <.*>
+.sp
+is matched against the string
+.sp
+  This is <something> <something else> <something further> no more
+.sp
+the three matched strings are
+.sp
+  <something>
+  <something> <something else>
+  <something> <something else> <something further>
+.sp
+On success, the yield of the function is a number greater than zero, which is
+the number of matched substrings. The substrings themselves are returned in
+\fIovector\fP. Each string uses two elements; the first is the offset to the
+start, and the second is the offset to the end. In fact, all the strings have
+the same start offset. (Space could have been saved by giving this only once,
+but it was decided to retain some compatibility with the way \fBpcre_exec()\fP
+returns data, even though the meaning of the strings is different.)
+.P
+The strings are returned in reverse order of length; that is, the longest
+matching string is given first. If there were too many matches to fit into
+\fIovector\fP, the yield of the function is zero, and the vector is filled with
+the longest matches.
+.
+.SS "Error returns from \fBpcre_dfa_exec()\fP"
+.rs
+.sp
+The \fBpcre_dfa_exec()\fP function returns a negative number when it fails.
+Many of the errors are the same as for \fBpcre_exec()\fP, and these are
+described
+.\" HTML <a href="#errorlist">
+.\" </a>
+above.
+.\"
+There are in addition the following errors that are specific to
+\fBpcre_dfa_exec()\fP:
+.sp
+  PCRE_ERROR_DFA_UITEM      (-16)
+.sp
+This return is given if \fBpcre_dfa_exec()\fP encounters an item in the pattern
+that it does not support, for instance, the use of \eC or a back reference.
+.sp
+  PCRE_ERROR_DFA_UCOND      (-17)
+.sp
+This return is given if \fBpcre_dfa_exec()\fP encounters a condition item that
+uses a back reference for the condition, or a test for recursion in a specific
+group. These are not supported.
+.sp
+  PCRE_ERROR_DFA_UMLIMIT    (-18)
+.sp
+This return is given if \fBpcre_dfa_exec()\fP is called with an \fIextra\fP
+block that contains a setting of the \fImatch_limit\fP field. This is not
+supported (it is meaningless).
+.sp
+  PCRE_ERROR_DFA_WSSIZE     (-19)
+.sp
+This return is given if \fBpcre_dfa_exec()\fP runs out of space in the
+\fIworkspace\fP vector.
+.sp
+  PCRE_ERROR_DFA_RECURSE    (-20)
+.sp
+When a recursive subpattern is processed, the matching function calls itself
+recursively, using private vectors for \fIovector\fP and \fIworkspace\fP. This
+error is given if the output vector is not large enough. This should be
+extremely rare, as a vector of size 1000 is used.
+.
+.
+.SH "SEE ALSO"
+.rs
+.sp
+\fBpcrebuild\fP(3), \fBpcrecallout\fP(3), \fBpcrecpp(3)\fP(3),
+\fBpcrematching\fP(3), \fBpcrepartial\fP(3), \fBpcreposix\fP(3),
+\fBpcreprecompile\fP(3), \fBpcresample\fP(3), \fBpcrestack\fP(3).
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 24 August 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcrebuild.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,327 @@
+.TH PCREBUILD 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE BUILD-TIME OPTIONS"
+.rs
+.sp
+This document describes the optional features of PCRE that can be selected when
+the library is compiled. It assumes use of the \fBconfigure\fP script, where
+the optional features are selected or deselected by providing options to
+\fBconfigure\fP before running the \fBmake\fP command. However, the same
+options can be selected in both Unix-like and non-Unix-like environments using
+the GUI facility of \fBCMakeSetup\fP if you are using \fBCMake\fP instead of
+\fBconfigure\fP to build PCRE.
+.P
+The complete list of options for \fBconfigure\fP (which includes the standard
+ones such as the selection of the installation directory) can be obtained by
+running
+.sp
+  ./configure --help
+.sp
+The following sections include descriptions of options whose names begin with
+--enable or --disable. These settings specify changes to the defaults for the
+\fBconfigure\fP command. Because of the way that \fBconfigure\fP works,
+--enable and --disable always come in pairs, so the complementary option always
+exists as well, but as it specifies the default, it is not described.
+.
+.SH "C++ SUPPORT"
+.rs
+.sp
+By default, the \fBconfigure\fP script will search for a C++ compiler and C++
+header files. If it finds them, it automatically builds the C++ wrapper library
+for PCRE. You can disable this by adding
+.sp
+  --disable-cpp
+.sp
+to the \fBconfigure\fP command.
+.
+.SH "UTF-8 SUPPORT"
+.rs
+.sp
+To build PCRE with support for UTF-8 character strings, add
+.sp
+  --enable-utf8
+.sp
+to the \fBconfigure\fP command. Of itself, this does not make PCRE treat
+strings as UTF-8. As well as compiling PCRE with this option, you also have
+have to set the PCRE_UTF8 option when you call the \fBpcre_compile()\fP
+function.
+.
+.SH "UNICODE CHARACTER PROPERTY SUPPORT"
+.rs
+.sp
+UTF-8 support allows PCRE to process character values greater than 255 in the
+strings that it handles. On its own, however, it does not provide any
+facilities for accessing the properties of such characters. If you want to be
+able to use the pattern escapes \eP, \ep, and \eX, which refer to Unicode
+character properties, you must add
+.sp
+  --enable-unicode-properties
+.sp
+to the \fBconfigure\fP command. This implies UTF-8 support, even if you have
+not explicitly requested it.
+.P
+Including Unicode property support adds around 30K of tables to the PCRE
+library. Only the general category properties such as \fILu\fP and \fINd\fP are
+supported. Details are given in the
+.\" HREF
+\fBpcrepattern\fP
+.\"
+documentation.
+.
+.SH "CODE VALUE OF NEWLINE"
+.rs
+.sp
+By default, PCRE interprets character 10 (linefeed, LF) as indicating the end
+of a line. This is the normal newline character on Unix-like systems. You can
+compile PCRE to use character 13 (carriage return, CR) instead, by adding
+.sp
+  --enable-newline-is-cr
+.sp
+to the \fBconfigure\fP command. There is also a --enable-newline-is-lf option,
+which explicitly specifies linefeed as the newline character.
+.sp
+Alternatively, you can specify that line endings are to be indicated by the two
+character sequence CRLF. If you want this, add
+.sp
+  --enable-newline-is-crlf
+.sp
+to the \fBconfigure\fP command. There is a fourth option, specified by
+.sp
+  --enable-newline-is-anycrlf
+.sp
+which causes PCRE to recognize any of the three sequences CR, LF, or CRLF as
+indicating a line ending. Finally, a fifth option, specified by
+.sp
+  --enable-newline-is-any
+.sp
+causes PCRE to recognize any Unicode newline sequence.
+.P
+Whatever line ending convention is selected when PCRE is built can be
+overridden when the library functions are called. At build time it is
+conventional to use the standard for your operating system.
+.
+.SH "WHAT \eR MATCHES"
+.rs
+.sp
+By default, the sequence \eR in a pattern matches any Unicode newline sequence,
+whatever has been selected as the line ending sequence. If you specify
+.sp
+  --enable-bsr-anycrlf
+.sp
+the default is changed so that \eR matches only CR, LF, or CRLF. Whatever is
+selected when PCRE is built can be overridden when the library functions are
+called.
+.
+.SH "BUILDING SHARED AND STATIC LIBRARIES"
+.rs
+.sp
+The PCRE building process uses \fBlibtool\fP to build both shared and static
+Unix libraries by default. You can suppress one of these by adding one of
+.sp
+  --disable-shared
+  --disable-static
+.sp
+to the \fBconfigure\fP command, as required.
+.
+.SH "POSIX MALLOC USAGE"
+.rs
+.sp
+When PCRE is called through the POSIX interface (see the
+.\" HREF
+\fBpcreposix\fP
+.\"
+documentation), additional working storage is required for holding the pointers
+to capturing substrings, because PCRE requires three integers per substring,
+whereas the POSIX interface provides only two. If the number of expected
+substrings is small, the wrapper function uses space on the stack, because this
+is faster than using \fBmalloc()\fP for each call. The default threshold above
+which the stack is no longer used is 10; it can be changed by adding a setting
+such as
+.sp
+  --with-posix-malloc-threshold=20
+.sp
+to the \fBconfigure\fP command.
+.
+.SH "HANDLING VERY LARGE PATTERNS"
+.rs
+.sp
+Within a compiled pattern, offset values are used to point from one part to
+another (for example, from an opening parenthesis to an alternation
+metacharacter). By default, two-byte values are used for these offsets, leading
+to a maximum size for a compiled pattern of around 64K. This is sufficient to
+handle all but the most gigantic patterns. Nevertheless, some people do want to
+process enormous patterns, so it is possible to compile PCRE to use three-byte
+or four-byte offsets by adding a setting such as
+.sp
+  --with-link-size=3
+.sp
+to the \fBconfigure\fP command. The value given must be 2, 3, or 4. Using
+longer offsets slows down the operation of PCRE because it has to load
+additional bytes when handling them.
+.
+.SH "AVOIDING EXCESSIVE STACK USAGE"
+.rs
+.sp
+When matching with the \fBpcre_exec()\fP function, PCRE implements backtracking
+by making recursive calls to an internal function called \fBmatch()\fP. In
+environments where the size of the stack is limited, this can severely limit
+PCRE's operation. (The Unix environment does not usually suffer from this
+problem, but it may sometimes be necessary to increase the maximum stack size.
+There is a discussion in the
+.\" HREF
+\fBpcrestack\fP
+.\"
+documentation.) An alternative approach to recursion that uses memory from the
+heap to remember data, instead of using recursive function calls, has been
+implemented to work round the problem of limited stack size. If you want to
+build a version of PCRE that works this way, add
+.sp
+  --disable-stack-for-recursion
+.sp
+to the \fBconfigure\fP command. With this configuration, PCRE will use the
+\fBpcre_stack_malloc\fP and \fBpcre_stack_free\fP variables to call memory
+management functions. By default these point to \fBmalloc()\fP and
+\fBfree()\fP, but you can replace the pointers so that your own functions are
+used.
+.P
+Separate functions are provided rather than using \fBpcre_malloc\fP and
+\fBpcre_free\fP because the usage is very predictable: the block sizes
+requested are always the same, and the blocks are always freed in reverse
+order. A calling program might be able to implement optimized functions that
+perform better than \fBmalloc()\fP and \fBfree()\fP. PCRE runs noticeably more
+slowly when built in this way. This option affects only the \fBpcre_exec()\fP
+function; it is not relevant for the the \fBpcre_dfa_exec()\fP function.
+.
+.SH "LIMITING PCRE RESOURCE USAGE"
+.rs
+.sp
+Internally, PCRE has a function called \fBmatch()\fP, which it calls repeatedly
+(sometimes recursively) when matching a pattern with the \fBpcre_exec()\fP
+function. By controlling the maximum number of times this function may be
+called during a single matching operation, a limit can be placed on the
+resources used by a single call to \fBpcre_exec()\fP. The limit can be changed
+at run time, as described in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation. The default is 10 million, but this can be changed by adding a
+setting such as
+.sp
+  --with-match-limit=500000
+.sp
+to the \fBconfigure\fP command. This setting has no effect on the
+\fBpcre_dfa_exec()\fP matching function.
+.P
+In some environments it is desirable to limit the depth of recursive calls of
+\fBmatch()\fP more strictly than the total number of calls, in order to
+restrict the maximum amount of stack (or heap, if --disable-stack-for-recursion
+is specified) that is used. A second limit controls this; it defaults to the
+value that is set for --with-match-limit, which imposes no additional
+constraints. However, you can set a lower limit by adding, for example,
+.sp
+  --with-match-limit-recursion=10000
+.sp
+to the \fBconfigure\fP command. This value can also be overridden at run time.
+.
+.SH "CREATING CHARACTER TABLES AT BUILD TIME"
+.rs
+.sp
+PCRE uses fixed tables for processing characters whose code values are less
+than 256. By default, PCRE is built with a set of tables that are distributed
+in the file \fIpcre_chartables.c.dist\fP. These tables are for ASCII codes
+only. If you add
+.sp
+  --enable-rebuild-chartables
+.sp
+to the \fBconfigure\fP command, the distributed tables are no longer used.
+Instead, a program called \fBdftables\fP is compiled and run. This outputs the
+source for new set of tables, created in the default locale of your C runtime
+system. (This method of replacing the tables does not work if you are cross
+compiling, because \fBdftables\fP is run on the local host. If you need to
+create alternative tables when cross compiling, you will have to do so "by
+hand".)
+.
+.SH "USING EBCDIC CODE"
+.rs
+.sp
+PCRE assumes by default that it will run in an environment where the character
+code is ASCII (or Unicode, which is a superset of ASCII). This is the case for
+most computer operating systems. PCRE can, however, be compiled to run in an
+EBCDIC environment by adding
+.sp
+  --enable-ebcdic
+.sp
+to the \fBconfigure\fP command. This setting implies
+--enable-rebuild-chartables. You should only use it if you know that you are in
+an EBCDIC environment (for example, an IBM mainframe operating system).
+.
+.SH "PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT"
+.rs
+.sp
+By default, \fBpcregrep\fP reads all files as plain text. You can build it so
+that it recognizes files whose names end in \fB.gz\fP or \fB.bz2\fP, and reads
+them with \fBlibz\fP or \fBlibbz2\fP, respectively, by adding one or both of
+.sp
+  --enable-pcregrep-libz
+  --enable-pcregrep-libbz2
+.sp
+to the \fBconfigure\fP command. These options naturally require that the
+relevant libraries are installed on your system. Configuration will fail if
+they are not.
+.
+.SH "PCRETEST OPTION FOR LIBREADLINE SUPPORT"
+.rs
+.sp
+If you add
+.sp
+  --enable-pcretest-libreadline
+.sp
+to the \fBconfigure\fP command, \fBpcretest\fP is linked with the
+\fBlibreadline\fP library, and when its input is from a terminal, it reads it
+using the \fBreadline()\fP function. This provides line-editing and history
+facilities. Note that \fBlibreadline\fP is GPL-licenced, so if you distribute a
+binary of \fBpcretest\fP linked in this way, there may be licensing issues.
+.P
+Setting this option causes the \fB-lreadline\fP option to be added to the
+\fBpcretest\fP build. In many operating environments with a sytem-installed
+\fBlibreadline\fP this is sufficient. However, in some environments (e.g.
+if an unmodified distribution version of readline is in use), some extra
+configuration may be necessary. The INSTALL file for \fBlibreadline\fP says
+this:
+.sp
+  "Readline uses the termcap functions, but does not link with the
+  termcap or curses library itself, allowing applications which link
+  with readline the to choose an appropriate library."
+.sp
+If your environment has not been set up so that an appropriate library is
+automatically included, you may need to add something like
+.sp
+  LIBS="-ncurses"
+.sp
+immediately before the \fBconfigure\fP command.
+.
+.
+.SH "SEE ALSO"
+.rs
+.sp
+\fBpcreapi\fP(3), \fBpcre_config\fP(3).
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 13 April 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcrecallout.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,177 @@
+.TH PCRECALLOUT 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE CALLOUTS"
+.rs
+.sp
+.B int (*pcre_callout)(pcre_callout_block *);
+.PP
+PCRE provides a feature called "callout", which is a means of temporarily
+passing control to the caller of PCRE in the middle of pattern matching. The
+caller of PCRE provides an external function by putting its entry point in the
+global variable \fIpcre_callout\fP. By default, this variable contains NULL,
+which disables all calling out.
+.P
+Within a regular expression, (?C) indicates the points at which the external
+function is to be called. Different callout points can be identified by putting
+a number less than 256 after the letter C. The default value is zero.
+For example, this pattern has two callout points:
+.sp
+  (?C1)abc(?C2)def
+.sp
+If the PCRE_AUTO_CALLOUT option bit is set when \fBpcre_compile()\fP is called,
+PCRE automatically inserts callouts, all with number 255, before each item in
+the pattern. For example, if PCRE_AUTO_CALLOUT is used with the pattern
+.sp
+  A(\ed{2}|--)
+.sp
+it is processed as if it were
+.sp
+(?C255)A(?C255)((?C255)\ed{2}(?C255)|(?C255)-(?C255)-(?C255))(?C255)
+.sp
+Notice that there is a callout before and after each parenthesis and
+alternation bar. Automatic callouts can be used for tracking the progress of
+pattern matching. The
+.\" HREF
+\fBpcretest\fP
+.\"
+command has an option that sets automatic callouts; when it is used, the output
+indicates how the pattern is matched. This is useful information when you are
+trying to optimize the performance of a particular pattern.
+.
+.
+.SH "MISSING CALLOUTS"
+.rs
+.sp
+You should be aware that, because of optimizations in the way PCRE matches
+patterns, callouts sometimes do not happen. For example, if the pattern is
+.sp
+  ab(?C4)cd
+.sp
+PCRE knows that any matching string must contain the letter "d". If the subject
+string is "abyz", the lack of "d" means that matching doesn't ever start, and
+the callout is never reached. However, with "abyd", though the result is still
+no match, the callout is obeyed.
+.
+.
+.SH "THE CALLOUT INTERFACE"
+.rs
+.sp
+During matching, when PCRE reaches a callout point, the external function
+defined by \fIpcre_callout\fP is called (if it is set). This applies to both
+the \fBpcre_exec()\fP and the \fBpcre_dfa_exec()\fP matching functions. The
+only argument to the callout function is a pointer to a \fBpcre_callout\fP
+block. This structure contains the following fields:
+.sp
+  int          \fIversion\fP;
+  int          \fIcallout_number\fP;
+  int         *\fIoffset_vector\fP;
+  const char  *\fIsubject\fP;
+  int          \fIsubject_length\fP;
+  int          \fIstart_match\fP;
+  int          \fIcurrent_position\fP;
+  int          \fIcapture_top\fP;
+  int          \fIcapture_last\fP;
+  void        *\fIcallout_data\fP;
+  int          \fIpattern_position\fP;
+  int          \fInext_item_length\fP;
+.sp
+The \fIversion\fP field is an integer containing the version number of the
+block format. The initial version was 0; the current version is 1. The version
+number will change again in future if additional fields are added, but the
+intention is never to remove any of the existing fields.
+.P
+The \fIcallout_number\fP field contains the number of the callout, as compiled
+into the pattern (that is, the number after ?C for manual callouts, and 255 for
+automatically generated callouts).
+.P
+The \fIoffset_vector\fP field is a pointer to the vector of offsets that was
+passed by the caller to \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP. When
+\fBpcre_exec()\fP is used, the contents can be inspected in order to extract
+substrings that have been matched so far, in the same way as for extracting
+substrings after a match has completed. For \fBpcre_dfa_exec()\fP this field is
+not useful.
+.P
+The \fIsubject\fP and \fIsubject_length\fP fields contain copies of the values
+that were passed to \fBpcre_exec()\fP.
+.P
+The \fIstart_match\fP field normally contains the offset within the subject at
+which the current match attempt started. However, if the escape sequence \eK
+has been encountered, this value is changed to reflect the modified starting
+point. If the pattern is not anchored, the callout function may be called
+several times from the same point in the pattern for different starting points
+in the subject.
+.P
+The \fIcurrent_position\fP field contains the offset within the subject of the
+current match pointer.
+.P
+When the \fBpcre_exec()\fP function is used, the \fIcapture_top\fP field
+contains one more than the number of the highest numbered captured substring so
+far. If no substrings have been captured, the value of \fIcapture_top\fP is
+one. This is always the case when \fBpcre_dfa_exec()\fP is used, because it
+does not support captured substrings.
+.P
+The \fIcapture_last\fP field contains the number of the most recently captured
+substring. If no substrings have been captured, its value is -1. This is always
+the case when \fBpcre_dfa_exec()\fP is used.
+.P
+The \fIcallout_data\fP field contains a value that is passed to
+\fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP specifically so that it can be
+passed back in callouts. It is passed in the \fIpcre_callout\fP field of the
+\fBpcre_extra\fP data structure. If no such data was passed, the value of
+\fIcallout_data\fP in a \fBpcre_callout\fP block is NULL. There is a
+description of the \fBpcre_extra\fP structure in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation.
+.P
+The \fIpattern_position\fP field is present from version 1 of the
+\fIpcre_callout\fP structure. It contains the offset to the next item to be
+matched in the pattern string.
+.P
+The \fInext_item_length\fP field is present from version 1 of the
+\fIpcre_callout\fP structure. It contains the length of the next item to be
+matched in the pattern string. When the callout immediately precedes an
+alternation bar, a closing parenthesis, or the end of the pattern, the length
+is zero. When the callout precedes an opening parenthesis, the length is that
+of the entire subpattern.
+.P
+The \fIpattern_position\fP and \fInext_item_length\fP fields are intended to
+help in distinguishing between different automatic callouts, which all have the
+same callout number. However, they are set for all callouts.
+.
+.
+.SH "RETURN VALUES"
+.rs
+.sp
+The external callout function returns an integer to PCRE. If the value is zero,
+matching proceeds as normal. If the value is greater than zero, matching fails
+at the current point, but the testing of other matching possibilities goes
+ahead, just as if a lookahead assertion had failed. If the value is less than
+zero, the match is abandoned, and \fBpcre_exec()\fP (or \fBpcre_dfa_exec()\fP)
+returns the negative value.
+.P
+Negative values should normally be chosen from the set of PCRE_ERROR_xxx
+values. In particular, PCRE_ERROR_NOMATCH forces a standard "no match" failure.
+The error number PCRE_ERROR_CALLOUT is reserved for use by callout functions;
+it will never be used by PCRE itself.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 29 May 2007
+Copyright (c) 1997-2007 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcrecompat.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,148 @@
+.TH PCRECOMPAT 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "DIFFERENCES BETWEEN PCRE AND PERL"
+.rs
+.sp
+This document describes the differences in the ways that PCRE and Perl handle
+regular expressions. The differences described here are mainly with respect to
+Perl 5.8, though PCRE versions 7.0 and later contain some features that are
+expected to be in the forthcoming Perl 5.10.
+.P
+1. PCRE has only a subset of Perl's UTF-8 and Unicode support. Details of what
+it does have are given in the
+.\" HTML <a href="pcre.html#utf8support">
+.\" </a>
+section on UTF-8 support
+.\"
+in the main
+.\" HREF
+\fBpcre\fP
+.\"
+page.
+.P
+2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl permits
+them, but they do not mean what you might think. For example, (?!a){3} does
+not assert that the next three characters are not "a". It just asserts that the
+next character is not "a" three times.
+.P
+3. Capturing subpatterns that occur inside negative lookahead assertions are
+counted, but their entries in the offsets vector are never set. Perl sets its
+numerical variables from any such patterns that are matched before the
+assertion fails to match something (thereby succeeding), but only if the
+negative lookahead assertion contains just one branch.
+.P
+4. Though binary zero characters are supported in the subject string, they are
+not allowed in a pattern string because it is passed as a normal C string,
+terminated by zero. The escape sequence \e0 can be used in the pattern to
+represent a binary zero.
+.P
+5. The following Perl escape sequences are not supported: \el, \eu, \eL,
+\eU, and \eN. In fact these are implemented by Perl's general string-handling
+and are not part of its pattern matching engine. If any of these are
+encountered by PCRE, an error is generated.
+.P
+6. The Perl escape sequences \ep, \eP, and \eX are supported only if PCRE is
+built with Unicode character property support. The properties that can be
+tested with \ep and \eP are limited to the general category properties such as
+Lu and Nd, script names such as Greek or Han, and the derived properties Any
+and L&.
+.P
+7. PCRE does support the \eQ...\eE escape for quoting substrings. Characters in
+between are treated as literals. This is slightly different from Perl in that $
+and @ are also handled as literals inside the quotes. In Perl, they cause
+variable interpolation (but of course PCRE does not have variables). Note the
+following examples:
+.sp
+    Pattern            PCRE matches      Perl matches
+.sp
+.\" JOIN
+    \eQabc$xyz\eE        abc$xyz           abc followed by the
+                                           contents of $xyz
+    \eQabc\e$xyz\eE       abc\e$xyz          abc\e$xyz
+    \eQabc\eE\e$\eQxyz\eE   abc$xyz           abc$xyz
+.sp
+The \eQ...\eE sequence is recognized both inside and outside character classes.
+.P
+8. Fairly obviously, PCRE does not support the (?{code}) and (??{code})
+constructions. However, there is support for recursive patterns. This is not
+available in Perl 5.8, but will be in Perl 5.10. Also, the PCRE "callout"
+feature allows an external function to be called during pattern matching. See
+the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation for details.
+.P
+9. Subpatterns that are called recursively or as "subroutines" are always
+treated as atomic groups in PCRE. This is like Python, but unlike Perl.
+.P
+10. There are some differences that are concerned with the settings of captured
+strings when part of a pattern is repeated. For example, matching "aba" against
+the pattern /^(a(b)?)+$/ in Perl leaves $2 unset, but in PCRE it is set to "b".
+.P
+11. PCRE does support Perl 5.10's backtracking verbs (*ACCEPT), (*FAIL), (*F),
+(*COMMIT), (*PRUNE), (*SKIP), and (*THEN), but only in the forms without an
+argument. PCRE does not support (*MARK). If (*ACCEPT) is within capturing
+parentheses, PCRE does not set that capture group; this is different to Perl.
+.P
+12. PCRE provides some extensions to the Perl regular expression facilities.
+Perl 5.10 will include new features that are not in earlier versions, some of
+which (such as named parentheses) have been in PCRE for some time. This list is
+with respect to Perl 5.10:
+.sp
+(a) Although lookbehind assertions must match fixed length strings, each
+alternative branch of a lookbehind assertion can match a different length of
+string. Perl requires them all to have the same length.
+.sp
+(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $
+meta-character matches only at the very end of the string.
+.sp
+(c) If PCRE_EXTRA is set, a backslash followed by a letter with no special
+meaning is faulted. Otherwise, like Perl, the backslash is quietly ignored.
+(Perl can be made to issue a warning.)
+.sp
+(d) If PCRE_UNGREEDY is set, the greediness of the repetition quantifiers is
+inverted, that is, by default they are not greedy, but if followed by a
+question mark they are.
+.sp
+(e) PCRE_ANCHORED can be used at matching time to force a pattern to be tried
+only at the first matching position in the subject string.
+.sp
+(f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, and PCRE_NO_AUTO_CAPTURE
+options for \fBpcre_exec()\fP have no Perl equivalents.
+.sp
+(g) The \eR escape sequence can be restricted to match only CR, LF, or CRLF
+by the PCRE_BSR_ANYCRLF option.
+.sp
+(h) The callout facility is PCRE-specific.
+.sp
+(i) The partial matching facility is PCRE-specific.
+.sp
+(j) Patterns compiled by PCRE can be saved and re-used at a later time, even on
+different hosts that have the other endianness.
+.sp
+(k) The alternative matching function (\fBpcre_dfa_exec()\fP) matches in a
+different way and is not Perl-compatible.
+.sp
+(l) PCRE recognizes some special sequences such as (*CR) at the start of
+a pattern that set overall options that cannot be changed within the pattern.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 11 September 2007
+Copyright (c) 1997-2007 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcrecpp.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,342 @@
+.TH PCRECPP 3
+.SH NAME
+PCRE - Perl-compatible regular expressions.
+.SH "SYNOPSIS OF C++ WRAPPER"
+.rs
+.sp
+.B #include <pcrecpp.h>
+.
+.SH DESCRIPTION
+.rs
+.sp
+The C++ wrapper for PCRE was provided by Google Inc. Some additional
+functionality was added by Giuseppe Maxia. This brief man page was constructed
+from the notes in the \fIpcrecpp.h\fP file, which should be consulted for
+further details.
+.
+.
+.SH "MATCHING INTERFACE"
+.rs
+.sp
+The "FullMatch" operation checks that supplied text matches a supplied pattern
+exactly. If pointer arguments are supplied, it copies matched sub-strings that
+match sub-patterns into them.
+.sp
+  Example: successful match
+     pcrecpp::RE re("h.*o");
+     re.FullMatch("hello");
+.sp
+  Example: unsuccessful match (requires full match):
+     pcrecpp::RE re("e");
+     !re.FullMatch("hello");
+.sp
+  Example: creating a temporary RE object:
+     pcrecpp::RE("h.*o").FullMatch("hello");
+.sp
+You can pass in a "const char*" or a "string" for "text". The examples below
+tend to use a const char*. You can, as in the different examples above, store
+the RE object explicitly in a variable or use a temporary RE object. The
+examples below use one mode or the other arbitrarily. Either could correctly be
+used for any of these examples.
+.P
+You must supply extra pointer arguments to extract matched subpieces.
+.sp
+  Example: extracts "ruby" into "s" and 1234 into "i"
+     int i;
+     string s;
+     pcrecpp::RE re("(\e\ew+):(\e\ed+)");
+     re.FullMatch("ruby:1234", &s, &i);
+.sp
+  Example: does not try to extract any extra sub-patterns
+     re.FullMatch("ruby:1234", &s);
+.sp
+  Example: does not try to extract into NULL
+     re.FullMatch("ruby:1234", NULL, &i);
+.sp
+  Example: integer overflow causes failure
+     !re.FullMatch("ruby:1234567891234", NULL, &i);
+.sp
+  Example: fails because there aren't enough sub-patterns:
+     !pcrecpp::RE("\e\ew+:\e\ed+").FullMatch("ruby:1234", &s);
+.sp
+  Example: fails because string cannot be stored in integer
+     !pcrecpp::RE("(.*)").FullMatch("ruby", &i);
+.sp
+The provided pointer arguments can be pointers to any scalar numeric
+type, or one of:
+.sp
+   string        (matched piece is copied to string)
+   StringPiece   (StringPiece is mutated to point to matched piece)
+   T             (where "bool T::ParseFrom(const char*, int)" exists)
+   NULL          (the corresponding matched sub-pattern is not copied)
+.sp
+The function returns true iff all of the following conditions are satisfied:
+.sp
+  a. "text" matches "pattern" exactly;
+.sp
+  b. The number of matched sub-patterns is >= number of supplied
+     pointers;
+.sp
+  c. The "i"th argument has a suitable type for holding the
+     string captured as the "i"th sub-pattern. If you pass in
+     void * NULL for the "i"th argument, or a non-void * NULL
+     of the correct type, or pass fewer arguments than the
+     number of sub-patterns, "i"th captured sub-pattern is
+     ignored.
+.sp
+CAVEAT: An optional sub-pattern that does not exist in the matched
+string is assigned the empty string. Therefore, the following will
+return false (because the empty string is not a valid number):
+.sp
+   int number;
+   pcrecpp::RE::FullMatch("abc", "[a-z]+(\e\ed+)?", &number);
+.sp
+The matching interface supports at most 16 arguments per call.
+If you need more, consider using the more general interface
+\fBpcrecpp::RE::DoMatch\fP. See \fBpcrecpp.h\fP for the signature for
+\fBDoMatch\fP.
+.
+.SH "QUOTING METACHARACTERS"
+.rs
+.sp
+You can use the "QuoteMeta" operation to insert backslashes before all
+potentially meaningful characters in a string. The returned string, used as a
+regular expression, will exactly match the original string.
+.sp
+  Example:
+     string quoted = RE::QuoteMeta(unquoted);
+.sp
+Note that it's legal to escape a character even if it has no special meaning in
+a regular expression -- so this function does that. (This also makes it
+identical to the perl function of the same name; see "perldoc -f quotemeta".)
+For example, "1.5-2.0?" becomes "1\e.5\e-2\e.0\e?".
+.
+.SH "PARTIAL MATCHES"
+.rs
+.sp
+You can use the "PartialMatch" operation when you want the pattern
+to match any substring of the text.
+.sp
+  Example: simple search for a string:
+     pcrecpp::RE("ell").PartialMatch("hello");
+.sp
+  Example: find first number in a string:
+     int number;
+     pcrecpp::RE re("(\e\ed+)");
+     re.PartialMatch("x*100 + 20", &number);
+     assert(number == 100);
+.
+.
+.SH "UTF-8 AND THE MATCHING INTERFACE"
+.rs
+.sp
+By default, pattern and text are plain text, one byte per character. The UTF8
+flag, passed to the constructor, causes both pattern and string to be treated
+as UTF-8 text, still a byte stream but potentially multiple bytes per
+character. In practice, the text is likelier to be UTF-8 than the pattern, but
+the match returned may depend on the UTF8 flag, so always use it when matching
+UTF8 text. For example, "." will match one byte normally but with UTF8 set may
+match up to three bytes of a multi-byte character.
+.sp
+  Example:
+     pcrecpp::RE_Options options;
+     options.set_utf8();
+     pcrecpp::RE re(utf8_pattern, options);
+     re.FullMatch(utf8_string);
+.sp
+  Example: using the convenience function UTF8():
+     pcrecpp::RE re(utf8_pattern, pcrecpp::UTF8());
+     re.FullMatch(utf8_string);
+.sp
+NOTE: The UTF8 flag is ignored if pcre was not configured with the
+      --enable-utf8 flag.
+.
+.
+.SH "PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE"
+.rs
+.sp
+PCRE defines some modifiers to change the behavior of the regular expression
+engine. The C++ wrapper defines an auxiliary class, RE_Options, as a vehicle to
+pass such modifiers to a RE class. Currently, the following modifiers are
+supported:
+.sp
+   modifier              description               Perl corresponding
+.sp
+   PCRE_CASELESS         case insensitive match      /i
+   PCRE_MULTILINE        multiple lines match        /m
+   PCRE_DOTALL           dot matches newlines        /s
+   PCRE_DOLLAR_ENDONLY   $ matches only at end       N/A
+   PCRE_EXTRA            strict escape parsing       N/A
+   PCRE_EXTENDED         ignore whitespaces          /x
+   PCRE_UTF8             handles UTF8 chars          built-in
+   PCRE_UNGREEDY         reverses * and *?           N/A
+   PCRE_NO_AUTO_CAPTURE  disables capturing parens   N/A (*)
+.sp
+(*) Both Perl and PCRE allow non capturing parentheses by means of the
+"?:" modifier within the pattern itself. e.g. (?:ab|cd) does not
+capture, while (ab|cd) does.
+.P
+For a full account on how each modifier works, please check the
+PCRE API reference page.
+.P
+For each modifier, there are two member functions whose name is made
+out of the modifier in lowercase, without the "PCRE_" prefix. For
+instance, PCRE_CASELESS is handled by
+.sp
+  bool caseless()
+.sp
+which returns true if the modifier is set, and
+.sp
+  RE_Options & set_caseless(bool)
+.sp
+which sets or unsets the modifier. Moreover, PCRE_EXTRA_MATCH_LIMIT can be
+accessed through the \fBset_match_limit()\fR and \fBmatch_limit()\fR member
+functions. Setting \fImatch_limit\fR to a non-zero value will limit the
+execution of pcre to keep it from doing bad things like blowing the stack or
+taking an eternity to return a result. A value of 5000 is good enough to stop
+stack blowup in a 2MB thread stack. Setting \fImatch_limit\fR to zero disables
+match limiting. Alternatively, you can call \fBmatch_limit_recursion()\fP
+which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much PCRE
+recurses. \fBmatch_limit()\fP limits the number of matches PCRE does;
+\fBmatch_limit_recursion()\fP limits the depth of internal recursion, and
+therefore the amount of stack that is used.
+.P
+Normally, to pass one or more modifiers to a RE class, you declare
+a \fIRE_Options\fR object, set the appropriate options, and pass this
+object to a RE constructor. Example:
+.sp
+   RE_options opt;
+   opt.set_caseless(true);
+   if (RE("HELLO", opt).PartialMatch("hello world")) ...
+.sp
+RE_options has two constructors. The default constructor takes no arguments and
+creates a set of flags that are off by default. The optional parameter
+\fIoption_flags\fR is to facilitate transfer of legacy code from C programs.
+This lets you do
+.sp
+   RE(pattern,
+     RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
+.sp
+However, new code is better off doing
+.sp
+   RE(pattern,
+     RE_Options().set_caseless(true).set_multiline(true))
+       .PartialMatch(str);
+.sp
+If you are going to pass one of the most used modifiers, there are some
+convenience functions that return a RE_Options class with the
+appropriate modifier already set: \fBCASELESS()\fR, \fBUTF8()\fR,
+\fBMULTILINE()\fR, \fBDOTALL\fR(), and \fBEXTENDED()\fR.
+.P
+If you need to set several options at once, and you don't want to go through
+the pains of declaring a RE_Options object and setting several options, there
+is a parallel method that give you such ability on the fly. You can concatenate
+several \fBset_xxxxx()\fR member functions, since each of them returns a
+reference to its class object. For example, to pass PCRE_CASELESS,
+PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one statement, you may write:
+.sp
+   RE(" ^ xyz \e\es+ .* blah$",
+     RE_Options()
+       .set_caseless(true)
+       .set_extended(true)
+       .set_multiline(true)).PartialMatch(sometext);
+.sp
+.
+.
+.SH "SCANNING TEXT INCREMENTALLY"
+.rs
+.sp
+The "Consume" operation may be useful if you want to repeatedly
+match regular expressions at the front of a string and skip over
+them as they match. This requires use of the "StringPiece" type,
+which represents a sub-range of a real string. Like RE, StringPiece
+is defined in the pcrecpp namespace.
+.sp
+  Example: read lines of the form "var = value" from a string.
+     string contents = ...;                 // Fill string somehow
+     pcrecpp::StringPiece input(contents);  // Wrap in a StringPiece
+
+     string var;
+     int value;
+     pcrecpp::RE re("(\e\ew+) = (\e\ed+)\en");
+     while (re.Consume(&input, &var, &value)) {
+       ...;
+     }
+.sp
+Each successful call to "Consume" will set "var/value", and also
+advance "input" so it points past the matched text.
+.P
+The "FindAndConsume" operation is similar to "Consume" but does not
+anchor your match at the beginning of the string. For example, you
+could extract all words from a string by repeatedly calling
+.sp
+  pcrecpp::RE("(\e\ew+)").FindAndConsume(&input, &word)
+.
+.
+.SH "PARSING HEX/OCTAL/C-RADIX NUMBERS"
+.rs
+.sp
+By default, if you pass a pointer to a numeric value, the
+corresponding text is interpreted as a base-10 number. You can
+instead wrap the pointer with a call to one of the operators Hex(),
+Octal(), or CRadix() to interpret the text in another base. The
+CRadix operator interprets C-style "0" (base-8) and "0x" (base-16)
+prefixes, but defaults to base-10.
+.sp
+  Example:
+    int a, b, c, d;
+    pcrecpp::RE re("(.*) (.*) (.*) (.*)");
+    re.FullMatch("100 40 0100 0x40",
+                 pcrecpp::Octal(&a), pcrecpp::Hex(&b),
+                 pcrecpp::CRadix(&c), pcrecpp::CRadix(&d));
+.sp
+will leave 64 in a, b, c, and d.
+.
+.
+.SH "REPLACING PARTS OF STRINGS"
+.rs
+.sp
+You can replace the first match of "pattern" in "str" with "rewrite".
+Within "rewrite", backslash-escaped digits (\e1 to \e9) can be
+used to insert text matching corresponding parenthesized group
+from the pattern. \e0 in "rewrite" refers to the entire matching
+text. For example:
+.sp
+  string s = "yabba dabba doo";
+  pcrecpp::RE("b+").Replace("d", &s);
+.sp
+will leave "s" containing "yada dabba doo". The result is true if the pattern
+matches and a replacement occurs, false otherwise.
+.P
+\fBGlobalReplace\fP is like \fBReplace\fP except that it replaces all
+occurrences of the pattern in the string with the rewrite. Replacements are
+not subject to re-matching. For example:
+.sp
+  string s = "yabba dabba doo";
+  pcrecpp::RE("b+").GlobalReplace("d", &s);
+.sp
+will leave "s" containing "yada dada doo". It returns the number of
+replacements made.
+.P
+\fBExtract\fP is like \fBReplace\fP, except that if the pattern matches,
+"rewrite" is copied into "out" (an additional argument) with substitutions.
+The non-matching portions of "text" are ignored. Returns true iff a match
+occurred and the extraction happened successfully;  if no match occurs, the
+string is left unaffected.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+The C++ wrapper was contributed by Google Inc.
+Copyright (c) 2007 Google Inc.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 12 November 2007
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcregrep.1	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,463 @@
+.TH PCREGREP 1
+.SH NAME
+pcregrep - a grep with Perl-compatible regular expressions.
+.SH SYNOPSIS
+.B pcregrep [options] [long options] [pattern] [path1 path2 ...]
+.
+.SH DESCRIPTION
+.rs
+.sp
+\fBpcregrep\fP searches files for character patterns, in the same way as other
+grep commands do, but it uses the PCRE regular expression library to support
+patterns that are compatible with the regular expressions of Perl 5. See
+.\" HREF
+\fBpcrepattern\fP(3)
+.\"
+for a full description of syntax and semantics of the regular expressions
+that PCRE supports.
+.P
+Patterns, whether supplied on the command line or in a separate file, are given
+without delimiters. For example:
+.sp
+  pcregrep Thursday /etc/motd
+.sp
+If you attempt to use delimiters (for example, by surrounding a pattern with
+slashes, as is common in Perl scripts), they are interpreted as part of the
+pattern. Quotes can of course be used to delimit patterns on the command line
+because they are interpreted by the shell, and indeed they are required if a
+pattern contains white space or shell metacharacters.
+.P
+The first argument that follows any option settings is treated as the single
+pattern to be matched when neither \fB-e\fP nor \fB-f\fP is present.
+Conversely, when one or both of these options are used to specify patterns, all
+arguments are treated as path names. At least one of \fB-e\fP, \fB-f\fP, or an
+argument pattern must be provided.
+.P
+If no files are specified, \fBpcregrep\fP reads the standard input. The
+standard input can also be referenced by a name consisting of a single hyphen.
+For example:
+.sp
+  pcregrep some-pattern /file1 - /file3
+.sp
+By default, each line that matches a pattern is copied to the standard
+output, and if there is more than one file, the file name is output at the
+start of each line, followed by a colon. However, there are options that can
+change how \fBpcregrep\fP behaves. In particular, the \fB-M\fP option makes it
+possible to search for patterns that span line boundaries. What defines a line
+boundary is controlled by the \fB-N\fP (\fB--newline\fP) option.
+.P
+Patterns are limited to 8K or BUFSIZ characters, whichever is the greater.
+BUFSIZ is defined in \fB<stdio.h>\fP. When there is more than one pattern
+(specified by the use of \fB-e\fP and/or \fB-f\fP), each pattern is applied to
+each line in the order in which they are defined, except that all the \fB-e\fP
+patterns are tried before the \fB-f\fP patterns. As soon as one pattern matches
+(or fails to match when \fB-v\fP is used), no further patterns are considered.
+.P
+When \fB--only-matching\fP, \fB--file-offsets\fP, or \fB--line-offsets\fP
+is used, the output is the part of the line that matched (either shown
+literally, or as an offset). In this case, scanning resumes immediately
+following the match, so that further matches on the same line can be found.
+If there are multiple patterns, they are all tried on the remainder of the
+line. However, patterns that follow the one that matched are not tried on the
+earlier part of the line.
+.P
+If the \fBLC_ALL\fP or \fBLC_CTYPE\fP environment variable is set,
+\fBpcregrep\fP uses the value to set a locale when calling the PCRE library.
+The \fB--locale\fP option can be used to override this.
+.
+.SH "SUPPORT FOR COMPRESSED FILES"
+.rs
+.sp
+It is possible to compile \fBpcregrep\fP so that it uses \fBlibz\fP or
+\fBlibbz2\fP to read files whose names end in \fB.gz\fP or \fB.bz2\fP,
+respectively. You can find out whether your binary has support for one or both
+of these file types by running it with the \fB--help\fP option. If the
+appropriate support is not present, files are treated as plain text. The
+standard input is always so treated.
+.
+.SH OPTIONS
+.rs
+.TP 10
+\fB--\fP
+This terminate the list of options. It is useful if the next item on the
+command line starts with a hyphen but is not an option. This allows for the
+processing of patterns and filenames that start with hyphens.
+.TP
+\fB-A\fP \fInumber\fP, \fB--after-context=\fP\fInumber\fP
+Output \fInumber\fP lines of context after each matching line. If filenames
+and/or line numbers are being output, a hyphen separator is used instead of a
+colon for the context lines. A line containing "--" is output between each
+group of lines, unless they are in fact contiguous in the input file. The value
+of \fInumber\fP is expected to be relatively small. However, \fBpcregrep\fP
+guarantees to have up to 8K of following text available for context output.
+.TP
+\fB-B\fP \fInumber\fP, \fB--before-context=\fP\fInumber\fP
+Output \fInumber\fP lines of context before each matching line. If filenames
+and/or line numbers are being output, a hyphen separator is used instead of a
+colon for the context lines. A line containing "--" is output between each
+group of lines, unless they are in fact contiguous in the input file. The value
+of \fInumber\fP is expected to be relatively small. However, \fBpcregrep\fP
+guarantees to have up to 8K of preceding text available for context output.
+.TP
+\fB-C\fP \fInumber\fP, \fB--context=\fP\fInumber\fP
+Output \fInumber\fP lines of context both before and after each matching line.
+This is equivalent to setting both \fB-A\fP and \fB-B\fP to the same value.
+.TP
+\fB-c\fP, \fB--count\fP
+Do not output individual lines; instead just output a count of the number of
+lines that would otherwise have been output. If several files are given, a
+count is output for each of them. In this mode, the \fB-A\fP, \fB-B\fP, and
+\fB-C\fP options are ignored.
+.TP
+\fB--colour\fP, \fB--color\fP
+If this option is given without any data, it is equivalent to "--colour=auto".
+If data is required, it must be given in the same shell item, separated by an
+equals sign.
+.TP
+\fB--colour=\fP\fIvalue\fP, \fB--color=\fP\fIvalue\fP
+This option specifies under what circumstances the part of a line that matched
+a pattern should be coloured in the output. The value may be "never" (the
+default), "always", or "auto". In the latter case, colouring happens only if
+the standard output is connected to a terminal. The colour can be specified by
+setting the environment variable PCREGREP_COLOUR or PCREGREP_COLOR. The value
+of this variable should be a string of two numbers, separated by a semicolon.
+They are copied directly into the control string for setting colour on a
+terminal, so it is your responsibility to ensure that they make sense. If
+neither of the environment variables is set, the default is "1;31", which gives
+red.
+.TP
+\fB-D\fP \fIaction\fP, \fB--devices=\fP\fIaction\fP
+If an input path is not a regular file or a directory, "action" specifies how
+it is to be processed. Valid values are "read" (the default) or "skip"
+(silently skip the path).
+.TP
+\fB-d\fP \fIaction\fP, \fB--directories=\fP\fIaction\fP
+If an input path is a directory, "action" specifies how it is to be processed.
+Valid values are "read" (the default), "recurse" (equivalent to the \fB-r\fP
+option), or "skip" (silently skip the path). In the default case, directories
+are read as if they were ordinary files. In some operating systems the effect
+of reading a directory like this is an immediate end-of-file.
+.TP
+\fB-e\fP \fIpattern\fP, \fB--regex=\fP\fIpattern\fP, \fB--regexp=\fP\fIpattern\fP
+Specify a pattern to be matched. This option can be used multiple times in
+order to specify several patterns. It can also be used as a way of specifying a
+single pattern that starts with a hyphen. When \fB-e\fP is used, no argument
+pattern is taken from the command line; all arguments are treated as file
+names. There is an overall maximum of 100 patterns. They are applied to each
+line in the order in which they are defined until one matches (or fails to
+match if \fB-v\fP is used). If \fB-f\fP is used with \fB-e\fP, the command line
+patterns are matched first, followed by the patterns from the file, independent
+of the order in which these options are specified. Note that multiple use of
+\fB-e\fP is not the same as a single pattern with alternatives. For example,
+X|Y finds the first character in a line that is X or Y, whereas if the two
+patterns are given separately, \fBpcregrep\fP finds X if it is present, even if
+it follows Y in the line. It finds Y only if there is no X in the line. This
+really matters only if you are using \fB-o\fP to show the part(s) of the line
+that matched.
+.TP
+\fB--exclude\fP=\fIpattern\fP
+When \fBpcregrep\fP is searching the files in a directory as a consequence of
+the \fB-r\fP (recursive search) option, any regular files whose names match the
+pattern are excluded. Subdirectories are not excluded by this option; they are
+searched recursively, subject to the \fB--exclude_dir\fP and
+\fB--include_dir\fP options. The pattern is a PCRE regular expression, and is
+matched against the final component of the file name (not the entire path). If
+a file name matches both \fB--include\fP and \fB--exclude\fP, it is excluded.
+There is no short form for this option.
+.TP
+\fB--exclude_dir\fP=\fIpattern\fP
+When \fBpcregrep\fP is searching the contents of a directory as a consequence
+of the \fB-r\fP (recursive search) option, any subdirectories whose names match
+the pattern are excluded. (Note that the \fP--exclude\fP option does not affect
+subdirectories.) The pattern is a PCRE regular expression, and is matched
+against the final component of the name (not the entire path). If a
+subdirectory name matches both \fB--include_dir\fP and \fB--exclude_dir\fP, it
+is excluded. There is no short form for this option.
+.TP
+\fB-F\fP, \fB--fixed-strings\fP
+Interpret each pattern as a list of fixed strings, separated by newlines,
+instead of as a regular expression. The \fB-w\fP (match as a word) and \fB-x\fP
+(match whole line) options can be used with \fB-F\fP. They apply to each of the
+fixed strings. A line is selected if any of the fixed strings are found in it
+(subject to \fB-w\fP or \fB-x\fP, if present).
+.TP
+\fB-f\fP \fIfilename\fP, \fB--file=\fP\fIfilename\fP
+Read a number of patterns from the file, one per line, and match them against
+each line of input. A data line is output if any of the patterns match it. The
+filename can be given as "-" to refer to the standard input. When \fB-f\fP is
+used, patterns specified on the command line using \fB-e\fP may also be
+present; they are tested before the file's patterns. However, no other pattern
+is taken from the command line; all arguments are treated as file names. There
+is an overall maximum of 100 patterns. Trailing white space is removed from
+each line, and blank lines are ignored. An empty file contains no patterns and
+therefore matches nothing. See also the comments about multiple patterns versus
+a single pattern with alternatives in the description of \fB-e\fP above.
+.TP
+\fB--file-offsets\fP
+Instead of showing lines or parts of lines that match, show each match as an
+offset from the start of the file and a length, separated by a comma. In this
+mode, no context is shown. That is, the \fB-A\fP, \fB-B\fP, and \fB-C\fP
+options are ignored. If there is more than one match in a line, each of them is
+shown separately. This option is mutually exclusive with \fB--line-offsets\fP
+and \fB--only-matching\fP.
+.TP
+\fB-H\fP, \fB--with-filename\fP
+Force the inclusion of the filename at the start of output lines when searching
+a single file. By default, the filename is not shown in this case. For matching
+lines, the filename is followed by a colon and a space; for context lines, a
+hyphen separator is used. If a line number is also being output, it follows the
+file name without a space.
+.TP
+\fB-h\fP, \fB--no-filename\fP
+Suppress the output filenames when searching multiple files. By default,
+filenames are shown when multiple files are searched. For matching lines, the
+filename is followed by a colon and a space; for context lines, a hyphen
+separator is used. If a line number is also being output, it follows the file
+name without a space.
+.TP
+\fB--help\fP
+Output a help message, giving brief details of the command options and file
+type support, and then exit.
+.TP
+\fB-i\fP, \fB--ignore-case\fP
+Ignore upper/lower case distinctions during comparisons.
+.TP
+\fB--include\fP=\fIpattern\fP
+When \fBpcregrep\fP is searching the files in a directory as a consequence of
+the \fB-r\fP (recursive search) option, only those regular files whose names
+match the pattern are included. Subdirectories are always included and searched
+recursively, subject to the \fP--include_dir\fP and \fB--exclude_dir\fP
+options. The pattern is a PCRE regular expression, and is matched against the
+final component of the file name (not the entire path). If a file name matches
+both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no short
+form for this option.
+.TP
+\fB--include_dir\fP=\fIpattern\fP
+When \fBpcregrep\fP is searching the contents of a directory as a consequence
+of the \fB-r\fP (recursive search) option, only those subdirectories whose
+names match the pattern are included. (Note that the \fB--include\fP option
+does not affect subdirectories.) The pattern is a PCRE regular expression, and
+is matched against the final component of the name (not the entire path). If a
+subdirectory name matches both \fB--include_dir\fP and \fB--exclude_dir\fP, it
+is excluded. There is no short form for this option.
+.TP
+\fB-L\fP, \fB--files-without-match\fP
+Instead of outputting lines from the files, just output the names of the files
+that do not contain any lines that would have been output. Each file name is
+output once, on a separate line.
+.TP
+\fB-l\fP, \fB--files-with-matches\fP
+Instead of outputting lines from the files, just output the names of the files
+containing lines that would have been output. Each file name is output
+once, on a separate line. Searching stops as soon as a matching line is found
+in a file.
+.TP
+\fB--label\fP=\fIname\fP
+This option supplies a name to be used for the standard input when file names
+are being output. If not supplied, "(standard input)" is used. There is no
+short form for this option.
+.TP
+\fB--line-offsets\fP
+Instead of showing lines or parts of lines that match, show each match as a
+line number, the offset from the start of the line, and a length. The line
+number is terminated by a colon (as usual; see the \fB-n\fP option), and the
+offset and length are separated by a comma. In this mode, no context is shown.
+That is, the \fB-A\fP, \fB-B\fP, and \fB-C\fP options are ignored. If there is
+more than one match in a line, each of them is shown separately. This option is
+mutually exclusive with \fB--file-offsets\fP and \fB--only-matching\fP.
+.TP
+\fB--locale\fP=\fIlocale-name\fP
+This option specifies a locale to be used for pattern matching. It overrides
+the value in the \fBLC_ALL\fP or \fBLC_CTYPE\fP environment variables. If no
+locale is specified, the PCRE library's default (usually the "C" locale) is
+used. There is no short form for this option.
+.TP
+\fB-M\fP, \fB--multiline\fP
+Allow patterns to match more than one line. When this option is given, patterns
+may usefully contain literal newline characters and internal occurrences of ^
+and $ characters. The output for any one match may consist of more than one
+line. When this option is set, the PCRE library is called in "multiline" mode.
+There is a limit to the number of lines that can be matched, imposed by the way
+that \fBpcregrep\fP buffers the input file as it scans it. However,
+\fBpcregrep\fP ensures that at least 8K characters or the rest of the document
+(whichever is the shorter) are available for forward matching, and similarly
+the previous 8K characters (or all the previous characters, if fewer than 8K)
+are guaranteed to be available for lookbehind assertions.
+.TP
+\fB-N\fP \fInewline-type\fP, \fB--newline=\fP\fInewline-type\fP
+The PCRE library supports five different conventions for indicating
+the ends of lines. They are the single-character sequences CR (carriage return)
+and LF (linefeed), the two-character sequence CRLF, an "anycrlf" convention,
+which recognizes any of the preceding three types, and an "any" convention, in
+which any Unicode line ending sequence is assumed to end a line. The Unicode
+sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF
+(formfeed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and
+PS (paragraph separator, U+2029).
+.sp
+When the PCRE library is built, a default line-ending sequence is specified.
+This is normally the standard sequence for the operating system. Unless
+otherwise specified by this option, \fBpcregrep\fP uses the library's default.
+The possible values for this option are CR, LF, CRLF, ANYCRLF, or ANY. This
+makes it possible to use \fBpcregrep\fP on files that have come from other
+environments without having to modify their line endings. If the data that is
+being scanned does not agree with the convention set by this option,
+\fBpcregrep\fP may behave in strange ways.
+.TP
+\fB-n\fP, \fB--line-number\fP
+Precede each output line by its line number in the file, followed by a colon
+and a space for matching lines or a hyphen and a space for context lines. If
+the filename is also being output, it precedes the line number. This option is
+forced if \fB--line-offsets\fP is used.
+.TP
+\fB-o\fP, \fB--only-matching\fP
+Show only the part of the line that matched a pattern. In this mode, no
+context is shown. That is, the \fB-A\fP, \fB-B\fP, and \fB-C\fP options are
+ignored. If there is more than one match in a line, each of them is shown
+separately. If \fB-o\fP is combined with \fB-v\fP (invert the sense of the
+match to find non-matching lines), no output is generated, but the return code
+is set appropriately. This option is mutually exclusive with
+\fB--file-offsets\fP and \fB--line-offsets\fP.
+.TP
+\fB-q\fP, \fB--quiet\fP
+Work quietly, that is, display nothing except error messages. The exit
+status indicates whether or not any matches were found.
+.TP
+\fB-r\fP, \fB--recursive\fP
+If any given path is a directory, recursively scan the files it contains,
+taking note of any \fB--include\fP and \fB--exclude\fP settings. By default, a
+directory is read as a normal file; in some operating systems this gives an
+immediate end-of-file. This option is a shorthand for setting the \fB-d\fP
+option to "recurse".
+.TP
+\fB-s\fP, \fB--no-messages\fP
+Suppress error messages about non-existent or unreadable files. Such files are
+quietly skipped. However, the return code is still 2, even if matches were
+found in other files.
+.TP
+\fB-u\fP, \fB--utf-8\fP
+Operate in UTF-8 mode. This option is available only if PCRE has been compiled
+with UTF-8 support. Both patterns and subject lines must be valid strings of
+UTF-8 characters.
+.TP
+\fB-V\fP, \fB--version\fP
+Write the version numbers of \fBpcregrep\fP and the PCRE library that is being
+used to the standard error stream.
+.TP
+\fB-v\fP, \fB--invert-match\fP
+Invert the sense of the match, so that lines which do \fInot\fP match any of
+the patterns are the ones that are found.
+.TP
+\fB-w\fP, \fB--word-regex\fP, \fB--word-regexp\fP
+Force the patterns to match only whole words. This is equivalent to having \eb
+at the start and end of the pattern.
+.TP
+\fB-x\fP, \fB--line-regex\fP, \fB--line-regexp\fP
+Force the patterns to be anchored (each must start matching at the beginning of
+a line) and in addition, require them to match entire lines. This is
+equivalent to having ^ and $ characters at the start and end of each
+alternative branch in every pattern.
+.
+.
+.SH "ENVIRONMENT VARIABLES"
+.rs
+.sp
+The environment variables \fBLC_ALL\fP and \fBLC_CTYPE\fP are examined, in that
+order, for a locale. The first one that is set is used. This can be overridden
+by the \fB--locale\fP option. If no locale is set, the PCRE library's default
+(usually the "C" locale) is used.
+.
+.
+.SH "NEWLINES"
+.rs
+.sp
+The \fB-N\fP (\fB--newline\fP) option allows \fBpcregrep\fP to scan files with
+different newline conventions from the default. However, the setting of this
+option does not affect the way in which \fBpcregrep\fP writes information to
+the standard error and output streams. It uses the string "\en" in C
+\fBprintf()\fP calls to indicate newlines, relying on the C I/O library to
+convert this to an appropriate sequence if the output is sent to a file.
+.
+.
+.SH "OPTIONS COMPATIBILITY"
+.rs
+.sp
+The majority of short and long forms of \fBpcregrep\fP's options are the same
+as in the GNU \fBgrep\fP program. Any long option of the form
+\fB--xxx-regexp\fP (GNU terminology) is also available as \fB--xxx-regex\fP
+(PCRE terminology). However, the \fB--locale\fP, \fB-M\fP, \fB--multiline\fP,
+\fB-u\fP, and \fB--utf-8\fP options are specific to \fBpcregrep\fP.
+.
+.
+.SH "OPTIONS WITH DATA"
+.rs
+.sp
+There are four different ways in which an option with data can be specified.
+If a short form option is used, the data may follow immediately, or in the next
+command line item. For example:
+.sp
+  -f/some/file
+  -f /some/file
+.sp
+If a long form option is used, the data may appear in the same command line
+item, separated by an equals character, or (with one exception) it may appear
+in the next command line item. For example:
+.sp
+  --file=/some/file
+  --file /some/file
+.sp
+Note, however, that if you want to supply a file name beginning with ~ as data
+in a shell command, and have the shell expand ~ to a home directory, you must
+separate the file name from the option, because the shell does not treat ~
+specially unless it is at the start of an item.
+.P
+The exception to the above is the \fB--colour\fP (or \fB--color\fP) option,
+for which the data is optional. If this option does have data, it must be given
+in the first form, using an equals character. Otherwise it will be assumed that
+it has no data.
+.
+.
+.SH "MATCHING ERRORS"
+.rs
+.sp
+It is possible to supply a regular expression that takes a very long time to
+fail to match certain lines. Such patterns normally involve nested indefinite
+repeats, for example: (a+)*\ed when matched against a line of a's with no final
+digit. The PCRE matching function has a resource limit that causes it to abort
+in these circumstances. If this happens, \fBpcregrep\fP outputs an error
+message and the line that caused the problem to the standard error stream. If
+there are more than 20 such errors, \fBpcregrep\fP gives up.
+.
+.
+.SH DIAGNOSTICS
+.rs
+.sp
+Exit status is 0 if any matches were found, 1 if no matches were found, and 2
+for syntax errors and non-existent or inacessible files (even if matches were
+found in other files) or too many matching errors. Using the \fB-s\fP option to
+suppress error messages about inaccessble files does not affect the return
+code.
+.
+.
+.SH "SEE ALSO"
+.rs
+.sp
+\fBpcrepattern\fP(3), \fBpcretest\fP(1).
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 08 March 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcregrep.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,498 @@
+PCREGREP(1)                                                        PCREGREP(1)
+
+
+NAME
+       pcregrep - a grep with Perl-compatible regular expressions.
+
+
+SYNOPSIS
+       pcregrep [options] [long options] [pattern] [path1 path2 ...]
+
+
+DESCRIPTION
+
+       pcregrep  searches  files  for  character  patterns, in the same way as
+       other grep commands do, but it uses the PCRE regular expression library
+       to support patterns that are compatible with the regular expressions of
+       Perl 5. See pcrepattern(3) for a full description of syntax and  seman-
+       tics of the regular expressions that PCRE supports.
+
+       Patterns,  whether  supplied on the command line or in a separate file,
+       are given without delimiters. For example:
+
+         pcregrep Thursday /etc/motd
+
+       If you attempt to use delimiters (for example, by surrounding a pattern
+       with  slashes,  as  is common in Perl scripts), they are interpreted as
+       part of the pattern. Quotes can of course be used to  delimit  patterns
+       on  the  command  line  because  they are interpreted by the shell, and
+       indeed they are required if a pattern contains  white  space  or  shell
+       metacharacters.
+
+       The  first  argument that follows any option settings is treated as the
+       single pattern to be matched when neither -e nor -f is  present.   Con-
+       versely,  when  one  or  both of these options are used to specify pat-
+       terns, all arguments are treated as path names. At least one of -e, -f,
+       or an argument pattern must be provided.
+
+       If no files are specified, pcregrep reads the standard input. The stan-
+       dard input can also be referenced by a  name  consisting  of  a  single
+       hyphen.  For example:
+
+         pcregrep some-pattern /file1 - /file3
+
+       By  default, each line that matches a pattern is copied to the standard
+       output, and if there is more than one file, the file name is output  at
+       the start of each line, followed by a colon. However, there are options
+       that can change how pcregrep behaves.  In  particular,  the  -M  option
+       makes  it  possible  to  search for patterns that span line boundaries.
+       What defines a line  boundary  is  controlled  by  the  -N  (--newline)
+       option.
+
+       Patterns  are  limited  to  8K  or  BUFSIZ characters, whichever is the
+       greater.  BUFSIZ is defined in <stdio.h>. When there is more  than  one
+       pattern (specified by the use of -e and/or -f), each pattern is applied
+       to each line in the order in which they are defined,  except  that  all
+       the  -e  patterns are tried before the -f patterns. As soon as one pat-
+       tern matches (or fails to match when -v is used), no  further  patterns
+       are considered.
+
+       When  --only-matching,  --file-offsets,  or --line-offsets is used, the
+       output is the part of the line that matched (either shown literally, or
+       as an offset). In this case, scanning resumes immediately following the
+       match, so that further matches on the same line can be found.  If there
+       are multiple patterns, they are all tried on the remainder of the line.
+       However, patterns that follow the one that matched are not tried on the
+       earlier part of the line.
+
+       If  the  LC_ALL  or LC_CTYPE environment variable is set, pcregrep uses
+       the value to set a locale when calling the PCRE library.  The  --locale
+       option can be used to override this.
+
+
+SUPPORT FOR COMPRESSED FILES
+
+       It  is  possible  to compile pcregrep so that it uses libz or libbz2 to
+       read files whose names end in .gz or .bz2, respectively. You  can  find
+       out whether your binary has support for one or both of these file types
+       by running it with the --help option. If the appropriate support is not
+       present,  files are treated as plain text. The standard input is always
+       so treated.
+
+
+OPTIONS
+
+       --        This terminate the list of options. It is useful if the  next
+                 item  on  the command line starts with a hyphen but is not an
+                 option. This allows for the processing of patterns and  file-
+                 names that start with hyphens.
+
+       -A number, --after-context=number
+                 Output  number  lines of context after each matching line. If
+                 filenames and/or line numbers are being output, a hyphen sep-
+                 arator  is  used  instead of a colon for the context lines. A
+                 line containing "--" is output between each group  of  lines,
+                 unless  they  are  in  fact contiguous in the input file. The
+                 value of number is expected to be relatively small.  However,
+                 pcregrep guarantees to have up to 8K of following text avail-
+                 able for context output.
+
+       -B number, --before-context=number
+                 Output number lines of context before each matching line.  If
+                 filenames and/or line numbers are being output, a hyphen sep-
+                 arator is used instead of a colon for the  context  lines.  A
+                 line  containing  "--" is output between each group of lines,
+                 unless they are in fact contiguous in  the  input  file.  The
+                 value  of number is expected to be relatively small. However,
+                 pcregrep guarantees to have up to 8K of preceding text avail-
+                 able for context output.
+
+       -C number, --context=number
+                 Output  number  lines  of  context both before and after each
+                 matching line.  This is equivalent to setting both -A and  -B
+                 to the same value.
+
+       -c, --count
+                 Do  not  output individual lines; instead just output a count
+                 of the number of lines that would otherwise have been output.
+                 If  several  files  are  given, a count is output for each of
+                 them. In this mode, the -A, -B, and -C options are ignored.
+
+       --colour, --color
+                 If this option is given without any data, it is equivalent to
+                 "--colour=auto".   If  data  is required, it must be given in
+                 the same shell item, separated by an equals sign.
+
+       --colour=value, --color=value
+                 This option specifies under what circumstances the part of  a
+                 line that matched a pattern should be coloured in the output.
+                 The value may be "never" (the default), "always", or  "auto".
+                 In  the  latter  case, colouring happens only if the standard
+                 output is connected to a terminal. The colour can  be  speci-
+                 fied  by  setting the environment variable PCREGREP_COLOUR or
+                 PCREGREP_COLOR. The value of this variable should be a string
+                 of  two  numbers,  separated by a semicolon.  They are copied
+                 directly into the control string for setting colour on a ter-
+                 minal,  so it is your responsibility to ensure that they make
+                 sense. If neither of the environment variables  is  set,  the
+                 default is "1;31", which gives red.
+
+       -D action, --devices=action
+                 If  an  input  path  is  not  a  regular file or a directory,
+                 "action" specifies how it is to be  processed.  Valid  values
+                 are  "read" (the default) or "skip" (silently skip the path).
+
+       -d action, --directories=action
+                 If an input path is a directory, "action" specifies how it is
+                 to  be  processed.   Valid  values  are "read" (the default),
+                 "recurse" (equivalent to the -r option), or "skip"  (silently
+                 skip  the path). In the default case, directories are read as
+                 if they were ordinary files. In some  operating  systems  the
+                 effect  of reading a directory like this is an immediate end-
+                 of-file.
+
+       -e pattern, --regex=pattern, --regexp=pattern
+                 Specify a pattern to be matched. This option can be used mul-
+                 tiple times in order to specify several patterns. It can also
+                 be used as a way of specifying a single pattern  that  starts
+                 with  a hyphen. When -e is used, no argument pattern is taken
+                 from the command line; all  arguments  are  treated  as  file
+                 names.  There is an overall maximum of 100 patterns. They are
+                 applied to each line in the order in which they  are  defined
+                 until one matches (or fails to match if -v is used). If -f is
+                 used with -e, the command line patterns  are  matched  first,
+                 followed  by  the  patterns from the file, independent of the
+                 order in which these options are specified. Note that  multi-
+                 ple use of -e is not the same as a single pattern with alter-
+                 natives. For example, X|Y finds the first character in a line
+                 that  is  X or Y, whereas if the two patterns are given sepa-
+                 rately, pcregrep finds X if it is present, even if it follows
+                 Y  in the line. It finds Y only if there is no X in the line.
+                 This really matters only if you are  using  -o  to  show  the
+                 part(s) of the line that matched.
+
+       --exclude=pattern
+                 When pcregrep is searching the files in a directory as a con-
+                 sequence of the -r (recursive  search)  option,  any  regular
+                 files whose names match the pattern are excluded. Subdirecto-
+                 ries are not excluded  by  this  option;  they  are  searched
+                 recursively,  subject  to the --exclude_dir and --include_dir
+                 options. The pattern is a PCRE  regular  expression,  and  is
+                 matched against the final component of the file name (not the
+                 entire path). If a  file  name  matches  both  --include  and
+                 --exclude,  it  is excluded.  There is no short form for this
+                 option.
+
+       --exclude_dir=pattern
+                 When pcregrep is searching the contents of a directory  as  a
+                 consequence  of  the -r (recursive search) option, any subdi-
+                 rectories whose names match the pattern are  excluded.  (Note
+                 that  the  --exclude  option does not affect subdirectories.)
+                 The pattern is a PCRE  regular  expression,  and  is  matched
+                 against  the  final  component  of  the  name (not the entire
+                 path). If a subdirectory name matches both --include_dir  and
+                 --exclude_dir,  it  is  excluded.  There is no short form for
+                 this option.
+
+       -F, --fixed-strings
+                 Interpret each pattern as a list of fixed strings,  separated
+                 by  newlines,  instead  of  as  a  regular expression. The -w
+                 (match as a word) and -x (match whole line)  options  can  be
+                 used with -F. They apply to each of the fixed strings. A line
+                 is selected if any of the fixed strings are found in it (sub-
+                 ject to -w or -x, if present).
+
+       -f filename, --file=filename
+                 Read  a  number  of patterns from the file, one per line, and
+                 match them against each line of input. A data line is  output
+                 if any of the patterns match it. The filename can be given as
+                 "-" to refer to the standard input. When -f is used, patterns
+                 specified  on  the command line using -e may also be present;
+                 they are tested before the file's patterns. However, no other
+                 pattern  is  taken  from  the command line; all arguments are
+                 treated as file names. There is an  overall  maximum  of  100
+                 patterns. Trailing white space is removed from each line, and
+                 blank lines are ignored. An empty file contains  no  patterns
+                 and  therefore  matches  nothing. See also the comments about
+                 multiple patterns versus a single pattern  with  alternatives
+                 in the description of -e above.
+
+       --file-offsets
+                 Instead  of  showing lines or parts of lines that match, show
+                 each match as an offset from the start  of  the  file  and  a
+                 length,  separated  by  a  comma. In this mode, no context is
+                 shown. That is, the -A, -B, and -C options  are  ignored.  If
+                 there is more than one match in a line, each of them is shown
+                 separately. This option is mutually  exclusive  with  --line-
+                 offsets and --only-matching.
+
+       -H, --with-filename
+                 Force  the  inclusion  of the filename at the start of output
+                 lines when searching a single file. By default, the  filename
+                 is  not  shown in this case. For matching lines, the filename
+                 is followed by a colon and a  space;  for  context  lines,  a
+                 hyphen separator is used. If a line number is also being out-
+                 put, it follows the file name without a space.
+
+       -h, --no-filename
+                 Suppress the output filenames when searching multiple  files.
+                 By  default,  filenames  are  shown  when  multiple files are
+                 searched. For matching lines, the filename is followed  by  a
+                 colon  and  a space; for context lines, a hyphen separator is
+                 used. If a line number is also being output, it  follows  the
+                 file name without a space.
+
+       --help    Output  a  help  message, giving brief details of the command
+                 options and file type support, and then exit.
+
+       -i, --ignore-case
+                 Ignore upper/lower case distinctions during comparisons.
+
+       --include=pattern
+                 When pcregrep is searching the files in a directory as a con-
+                 sequence of the -r (recursive search) option, only those reg-
+                 ular files whose names match the pattern are included. Subdi-
+                 rectories  are always included and searched recursively, sub-
+                 ject to the --include_dir and --exclude_dir options. The pat-
+                 tern is a PCRE regular expression, and is matched against the
+                 final component of the file name (not the entire path). If  a
+                 file  name  matches  both  --include  and  --exclude,  it  is
+                 excluded. There is no short form for this option.
+
+       --include_dir=pattern
+                 When pcregrep is searching the contents of a directory  as  a
+                 consequence  of  the -r (recursive search) option, only those
+                 subdirectories whose names match the  pattern  are  included.
+                 (Note  that  the --include option does not affect subdirecto-
+                 ries.) The pattern is  a  PCRE  regular  expression,  and  is
+                 matched  against  the  final  component  of the name (not the
+                 entire  path).  If   a   subdirectory   name   matches   both
+                 --include_dir  and --exclude_dir, it is excluded. There is no
+                 short form for this option.
+
+       -L, --files-without-match
+                 Instead of outputting lines from the files, just  output  the
+                 names  of  the files that do not contain any lines that would
+                 have been output. Each file name is output once, on  a  sepa-
+                 rate line.
+
+       -l, --files-with-matches
+                 Instead  of  outputting lines from the files, just output the
+                 names of the files containing lines that would have been out-
+                 put.  Each  file  name  is  output  once, on a separate line.
+                 Searching stops as soon as a matching  line  is  found  in  a
+                 file.
+
+       --label=name
+                 This option supplies a name to be used for the standard input
+                 when file names are being output. If not supplied, "(standard
+                 input)" is used. There is no short form for this option.
+
+       --line-offsets
+                 Instead  of  showing lines or parts of lines that match, show
+                 each match as a line number, the offset from the start of the
+                 line,  and a length. The line number is terminated by a colon
+                 (as usual; see the -n option), and the offset and length  are
+                 separated  by  a  comma.  In  this mode, no context is shown.
+                 That is, the -A, -B, and -C options are ignored. If there  is
+                 more  than  one  match in a line, each of them is shown sepa-
+                 rately. This option is mutually exclusive with --file-offsets
+                 and --only-matching.
+
+       --locale=locale-name
+                 This  option specifies a locale to be used for pattern match-
+                 ing. It overrides the value in the LC_ALL or  LC_CTYPE  envi-
+                 ronment  variables.  If  no  locale  is  specified,  the PCRE
+                 library's default (usually the "C" locale) is used. There  is
+                 no short form for this option.
+
+       -M, --multiline
+                 Allow  patterns to match more than one line. When this option
+                 is given, patterns may usefully contain literal newline char-
+                 acters  and  internal  occurrences of ^ and $ characters. The
+                 output for any one match may consist of more than  one  line.
+                 When  this option is set, the PCRE library is called in "mul-
+                 tiline" mode.  There is a limit to the number of  lines  that
+                 can  be matched, imposed by the way that pcregrep buffers the
+                 input file as it scans it. However, pcregrep ensures that  at
+                 least 8K characters or the rest of the document (whichever is
+                 the shorter) are available for forward  matching,  and  simi-
+                 larly the previous 8K characters (or all the previous charac-
+                 ters, if fewer than 8K) are guaranteed to  be  available  for
+                 lookbehind assertions.
+
+       -N newline-type, --newline=newline-type
+                 The  PCRE  library  supports  five  different conventions for
+                 indicating the ends of lines. They are  the  single-character
+                 sequences  CR  (carriage  return) and LF (linefeed), the two-
+                 character sequence CRLF, an "anycrlf" convention, which  rec-
+                 ognizes  any  of the preceding three types, and an "any" con-
+                 vention, in which any Unicode line ending sequence is assumed
+                 to  end a line. The Unicode sequences are the three just men-
+                 tioned,  plus  VT  (vertical  tab,  U+000B),  FF   (formfeed,
+                 U+000C),   NEL  (next  line,  U+0085),  LS  (line  separator,
+                 U+2028), and PS (paragraph separator, U+2029).
+
+                 When  the  PCRE  library  is  built,  a  default  line-ending
+                 sequence   is  specified.   This  is  normally  the  standard
+                 sequence for the operating system. Unless otherwise specified
+                 by  this  option,  pcregrep  uses the library's default.  The
+                 possible values for this option are CR, LF, CRLF, ANYCRLF, or
+                 ANY.  This  makes  it  possible to use pcregrep on files that
+                 have come from other environments without  having  to  modify
+                 their  line  endings.  If the data that is being scanned does
+                 not agree with the convention set by  this  option,  pcregrep
+                 may behave in strange ways.
+
+       -n, --line-number
+                 Precede each output line by its line number in the file, fol-
+                 lowed by a colon and a space for matching lines or  a  hyphen
+                 and  a space for context lines. If the filename is also being
+                 output, it precedes the line number. This option is forced if
+                 --line-offsets is used.
+
+       -o, --only-matching
+                 Show  only  the  part  of the line that matched a pattern. In
+                 this mode, no context is shown. That is, the -A, -B,  and  -C
+                 options  are  ignored.  If  there is more than one match in a
+                 line, each of them is shown separately.  If  -o  is  combined
+                 with  -v  (invert the sense of the match to find non-matching
+                 lines), no output is generated, but the return  code  is  set
+                 appropriately. This option is mutually exclusive with --file-
+                 offsets and --line-offsets.
+
+       -q, --quiet
+                 Work quietly, that is, display nothing except error messages.
+                 The  exit  status  indicates  whether or not any matches were
+                 found.
+
+       -r, --recursive
+                 If any given path is a directory, recursively scan the  files
+                 it  contains, taking note of any --include and --exclude set-
+                 tings. By default, a directory is read as a normal  file;  in
+                 some  operating  systems this gives an immediate end-of-file.
+                 This option is a shorthand  for  setting  the  -d  option  to
+                 "recurse".
+
+       -s, --no-messages
+                 Suppress  error  messages  about  non-existent  or unreadable
+                 files. Such files are quietly skipped.  However,  the  return
+                 code is still 2, even if matches were found in other files.
+
+       -u, --utf-8
+                 Operate  in UTF-8 mode. This option is available only if PCRE
+                 has been compiled with UTF-8 support. Both patterns and  sub-
+                 ject lines must be valid strings of UTF-8 characters.
+
+       -V, --version
+                 Write  the  version  numbers of pcregrep and the PCRE library
+                 that is being used to the standard error stream.
+
+       -v, --invert-match
+                 Invert the sense of the match, so that  lines  which  do  not
+                 match any of the patterns are the ones that are found.
+
+       -w, --word-regex, --word-regexp
+                 Force the patterns to match only whole words. This is equiva-
+                 lent to having \b at the start and end of the pattern.
+
+       -x, --line-regex, --line-regexp
+                 Force the patterns to be anchored (each must  start  matching
+                 at  the beginning of a line) and in addition, require them to
+                 match entire lines. This is equivalent  to  having  ^  and  $
+                 characters at the start and end of each alternative branch in
+                 every pattern.
+
+
+ENVIRONMENT VARIABLES
+
+       The environment variables LC_ALL and LC_CTYPE  are  examined,  in  that
+       order,  for  a  locale.  The first one that is set is used. This can be
+       overridden by the --locale option.  If  no  locale  is  set,  the  PCRE
+       library's default (usually the "C" locale) is used.
+
+
+NEWLINES
+
+       The  -N (--newline) option allows pcregrep to scan files with different
+       newline conventions from the default.  However,  the  setting  of  this
+       option  does not affect the way in which pcregrep writes information to
+       the standard error and output streams. It uses the  string  "\n"  in  C
+       printf()  calls  to  indicate newlines, relying on the C I/O library to
+       convert this to an appropriate sequence if the  output  is  sent  to  a
+       file.
+
+
+OPTIONS COMPATIBILITY
+
+       The majority of short and long forms of pcregrep's options are the same
+       as in the GNU grep program. Any long option of  the  form  --xxx-regexp
+       (GNU  terminology) is also available as --xxx-regex (PCRE terminology).
+       However, the --locale, -M, --multiline, -u,  and  --utf-8  options  are
+       specific to pcregrep.
+
+
+OPTIONS WITH DATA
+
+       There are four different ways in which an option with data can be spec-
+       ified.  If a short form option is used, the  data  may  follow  immedi-
+       ately, or in the next command line item. For example:
+
+         -f/some/file
+         -f /some/file
+
+       If  a long form option is used, the data may appear in the same command
+       line item, separated by an equals character, or (with one exception) it
+       may appear in the next command line item. For example:
+
+         --file=/some/file
+         --file /some/file
+
+       Note,  however, that if you want to supply a file name beginning with ~
+       as data in a shell command, and have the  shell  expand  ~  to  a  home
+       directory, you must separate the file name from the option, because the
+       shell does not treat ~ specially unless it is at the start of an  item.
+
+       The  exception  to  the  above is the --colour (or --color) option, for
+       which the data is optional. If this option does have data, it  must  be
+       given  in  the first form, using an equals character. Otherwise it will
+       be assumed that it has no data.
+
+
+MATCHING ERRORS
+
+       It is possible to supply a regular expression that takes  a  very  long
+       time  to  fail  to  match certain lines. Such patterns normally involve
+       nested indefinite repeats, for example: (a+)*\d when matched against  a
+       line  of  a's  with  no  final  digit. The PCRE matching function has a
+       resource limit that causes it to abort in these circumstances. If  this
+       happens, pcregrep outputs an error message and the line that caused the
+       problem to the standard error stream. If there are more  than  20  such
+       errors, pcregrep gives up.
+
+
+DIAGNOSTICS
+
+       Exit status is 0 if any matches were found, 1 if no matches were found,
+       and 2 for syntax errors and non-existent or inacessible files (even  if
+       matches  were  found in other files) or too many matching errors. Using
+       the -s option to suppress error messages about inaccessble  files  does
+       not affect the return code.
+
+
+SEE ALSO
+
+       pcrepattern(3), pcretest(1).
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 08 March 2008
+       Copyright (c) 1997-2008 University of Cambridge.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcrematching.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,188 @@
+.TH PCREMATCHING 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE MATCHING ALGORITHMS"
+.rs
+.sp
+This document describes the two different algorithms that are available in PCRE
+for matching a compiled regular expression against a given subject string. The
+"standard" algorithm is the one provided by the \fBpcre_exec()\fP function.
+This works in the same was as Perl's matching function, and provides a
+Perl-compatible matching operation.
+.P
+An alternative algorithm is provided by the \fBpcre_dfa_exec()\fP function;
+this operates in a different way, and is not Perl-compatible. It has advantages
+and disadvantages compared with the standard algorithm, and these are described
+below.
+.P
+When there is only one possible way in which a given subject string can match a
+pattern, the two algorithms give the same answer. A difference arises, however,
+when there are multiple possibilities. For example, if the pattern
+.sp
+  ^<.*>
+.sp
+is matched against the string
+.sp
+  <something> <something else> <something further>
+.sp
+there are three possible answers. The standard algorithm finds only one of
+them, whereas the alternative algorithm finds all three.
+.
+.SH "REGULAR EXPRESSIONS AS TREES"
+.rs
+.sp
+The set of strings that are matched by a regular expression can be represented
+as a tree structure. An unlimited repetition in the pattern makes the tree of
+infinite size, but it is still a tree. Matching the pattern to a given subject
+string (from a given starting point) can be thought of as a search of the tree.
+There are two ways to search a tree: depth-first and breadth-first, and these
+correspond to the two matching algorithms provided by PCRE.
+.
+.SH "THE STANDARD MATCHING ALGORITHM"
+.rs
+.sp
+In the terminology of Jeffrey Friedl's book "Mastering Regular
+Expressions", the standard algorithm is an "NFA algorithm". It conducts a
+depth-first search of the pattern tree. That is, it proceeds along a single
+path through the tree, checking that the subject matches what is required. When
+there is a mismatch, the algorithm tries any alternatives at the current point,
+and if they all fail, it backs up to the previous branch point in the tree, and
+tries the next alternative branch at that level. This often involves backing up
+(moving to the left) in the subject string as well. The order in which
+repetition branches are tried is controlled by the greedy or ungreedy nature of
+the quantifier.
+.P
+If a leaf node is reached, a matching string has been found, and at that point
+the algorithm stops. Thus, if there is more than one possible match, this
+algorithm returns the first one that it finds. Whether this is the shortest,
+the longest, or some intermediate length depends on the way the greedy and
+ungreedy repetition quantifiers are specified in the pattern.
+.P
+Because it ends up with a single path through the tree, it is relatively
+straightforward for this algorithm to keep track of the substrings that are
+matched by portions of the pattern in parentheses. This provides support for
+capturing parentheses and back references.
+.
+.SH "THE ALTERNATIVE MATCHING ALGORITHM"
+.rs
+.sp
+This algorithm conducts a breadth-first search of the tree. Starting from the
+first matching point in the subject, it scans the subject string from left to
+right, once, character by character, and as it does this, it remembers all the
+paths through the tree that represent valid matches. In Friedl's terminology,
+this is a kind of "DFA algorithm", though it is not implemented as a
+traditional finite state machine (it keeps multiple states active
+simultaneously).
+.P
+The scan continues until either the end of the subject is reached, or there are
+no more unterminated paths. At this point, terminated paths represent the
+different matching possibilities (if there are none, the match has failed).
+Thus, if there is more than one possible match, this algorithm finds all of
+them, and in particular, it finds the longest. In PCRE, there is an option to
+stop the algorithm after the first match (which is necessarily the shortest)
+has been found.
+.P
+Note that all the matches that are found start at the same point in the
+subject. If the pattern
+.sp
+  cat(er(pillar)?)
+.sp
+is matched against the string "the caterpillar catchment", the result will be
+the three strings "cat", "cater", and "caterpillar" that start at the fourth
+character of the subject. The algorithm does not automatically move on to find
+matches that start at later positions.
+.P
+There are a number of features of PCRE regular expressions that are not
+supported by the alternative matching algorithm. They are as follows:
+.P
+1. Because the algorithm finds all possible matches, the greedy or ungreedy
+nature of repetition quantifiers is not relevant. Greedy and ungreedy
+quantifiers are treated in exactly the same way. However, possessive
+quantifiers can make a difference when what follows could also match what is
+quantified, for example in a pattern like this:
+.sp
+  ^a++\ew!
+.sp
+This pattern matches "aaab!" but not "aaa!", which would be matched by a
+non-possessive quantifier. Similarly, if an atomic group is present, it is
+matched as if it were a standalone pattern at the current point, and the
+longest match is then "locked in" for the rest of the overall pattern.
+.P
+2. When dealing with multiple paths through the tree simultaneously, it is not
+straightforward to keep track of captured substrings for the different matching
+possibilities, and PCRE's implementation of this algorithm does not attempt to
+do this. This means that no captured substrings are available.
+.P
+3. Because no substrings are captured, back references within the pattern are
+not supported, and cause errors if encountered.
+.P
+4. For the same reason, conditional expressions that use a backreference as the
+condition or test for a specific group recursion are not supported.
+.P
+5. Because many paths through the tree may be active, the \eK escape sequence,
+which resets the start of the match when encountered (but may be on some paths
+and not on others), is not supported. It causes an error if encountered.
+.P
+6. Callouts are supported, but the value of the \fIcapture_top\fP field is
+always 1, and the value of the \fIcapture_last\fP field is always -1.
+.P
+7. The \eC escape sequence, which (in the standard algorithm) matches a single
+byte, even in UTF-8 mode, is not supported because the alternative algorithm
+moves through the subject string one character at a time, for all active paths
+through the tree.
+.P
+8. Except for (*FAIL), the backtracking control verbs such as (*PRUNE) are not
+supported. (*FAIL) is supported, and behaves like a failing negative assertion.
+.
+.SH "ADVANTAGES OF THE ALTERNATIVE ALGORITHM"
+.rs
+.sp
+Using the alternative matching algorithm provides the following advantages:
+.P
+1. All possible matches (at a single point in the subject) are automatically
+found, and in particular, the longest match is found. To find more than one
+match using the standard algorithm, you have to do kludgy things with
+callouts.
+.P
+2. There is much better support for partial matching. The restrictions on the
+content of the pattern that apply when using the standard algorithm for partial
+matching do not apply to the alternative algorithm. For non-anchored patterns,
+the starting position of a partial match is available.
+.P
+3. Because the alternative algorithm scans the subject string just once, and
+never needs to backtrack, it is possible to pass very long subject strings to
+the matching function in several pieces, checking for partial matching each
+time.
+.
+.SH "DISADVANTAGES OF THE ALTERNATIVE ALGORITHM"
+.rs
+.sp
+The alternative algorithm suffers from a number of disadvantages:
+.P
+1. It is substantially slower than the standard algorithm. This is partly
+because it has to search for all possible matches, but is also because it is
+less susceptible to optimization.
+.P
+2. Capturing parentheses and back references are not supported.
+.P
+3. Although atomic groups are supported, their use does not provide the
+performance advantage that it does for the standard algorithm.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 19 April 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcrepartial.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,219 @@
+.TH PCREPARTIAL 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PARTIAL MATCHING IN PCRE"
+.rs
+.sp
+In normal use of PCRE, if the subject string that is passed to
+\fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP matches as far as it goes, but is
+too short to match the entire pattern, PCRE_ERROR_NOMATCH is returned. There
+are circumstances where it might be helpful to distinguish this case from other
+cases in which there is no match.
+.P
+Consider, for example, an application where a human is required to type in data
+for a field with specific formatting requirements. An example might be a date
+in the form \fIddmmmyy\fP, defined by this pattern:
+.sp
+  ^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$
+.sp
+If the application sees the user's keystrokes one by one, and can check that
+what has been typed so far is potentially valid, it is able to raise an error
+as soon as a mistake is made, possibly beeping and not reflecting the
+character that has been typed. This immediate feedback is likely to be a better
+user interface than a check that is delayed until the entire string has been
+entered.
+.P
+PCRE supports the concept of partial matching by means of the PCRE_PARTIAL
+option, which can be set when calling \fBpcre_exec()\fP or
+\fBpcre_dfa_exec()\fP. When this flag is set for \fBpcre_exec()\fP, the return
+code PCRE_ERROR_NOMATCH is converted into PCRE_ERROR_PARTIAL if at any time
+during the matching process the last part of the subject string matched part of
+the pattern. Unfortunately, for non-anchored matching, it is not possible to
+obtain the position of the start of the partial match. No captured data is set
+when PCRE_ERROR_PARTIAL is returned.
+.P
+When PCRE_PARTIAL is set for \fBpcre_dfa_exec()\fP, the return code
+PCRE_ERROR_NOMATCH is converted into PCRE_ERROR_PARTIAL if the end of the
+subject is reached, there have been no complete matches, but there is still at
+least one matching possibility. The portion of the string that provided the
+partial match is set as the first matching string.
+.P
+Using PCRE_PARTIAL disables one of PCRE's optimizations. PCRE remembers the
+last literal byte in a pattern, and abandons matching immediately if such a
+byte is not present in the subject string. This optimization cannot be used
+for a subject string that might match only partially.
+.
+.
+.SH "RESTRICTED PATTERNS FOR PCRE_PARTIAL"
+.rs
+.sp
+Because of the way certain internal optimizations are implemented in the
+\fBpcre_exec()\fP function, the PCRE_PARTIAL option cannot be used with all
+patterns. These restrictions do not apply when \fBpcre_dfa_exec()\fP is used.
+For \fBpcre_exec()\fP, repeated single characters such as
+.sp
+  a{2,4}
+.sp
+and repeated single metasequences such as
+.sp
+  \ed+
+.sp
+are not permitted if the maximum number of occurrences is greater than one.
+Optional items such as \ed? (where the maximum is one) are permitted.
+Quantifiers with any values are permitted after parentheses, so the invalid
+examples above can be coded thus:
+.sp
+  (a){2,4}
+  (\ed)+
+.sp
+These constructions run more slowly, but for the kinds of application that are
+envisaged for this facility, this is not felt to be a major restriction.
+.P
+If PCRE_PARTIAL is set for a pattern that does not conform to the restrictions,
+\fBpcre_exec()\fP returns the error code PCRE_ERROR_BADPARTIAL (-13).
+You can use the PCRE_INFO_OKPARTIAL call to \fBpcre_fullinfo()\fP to find out
+if a compiled pattern can be used for partial matching.
+.
+.
+.SH "EXAMPLE OF PARTIAL MATCHING USING PCRETEST"
+.rs
+.sp
+If the escape sequence \eP is present in a \fBpcretest\fP data line, the
+PCRE_PARTIAL flag is used for the match. Here is a run of \fBpcretest\fP that
+uses the date example quoted above:
+.sp
+    re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/
+  data> 25jun04\eP
+   0: 25jun04
+   1: jun
+  data> 25dec3\eP
+  Partial match
+  data> 3ju\eP
+  Partial match
+  data> 3juj\eP
+  No match
+  data> j\eP
+  No match
+.sp
+The first data string is matched completely, so \fBpcretest\fP shows the
+matched substrings. The remaining four strings do not match the complete
+pattern, but the first two are partial matches. The same test, using
+\fBpcre_dfa_exec()\fP matching (by means of the \eD escape sequence), produces
+the following output:
+.sp
+    re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/
+  data> 25jun04\eP\eD
+   0: 25jun04
+  data> 23dec3\eP\eD
+  Partial match: 23dec3
+  data> 3ju\eP\eD
+  Partial match: 3ju
+  data> 3juj\eP\eD
+  No match
+  data> j\eP\eD
+  No match
+.sp
+Notice that in this case the portion of the string that was matched is made
+available.
+.
+.
+.SH "MULTI-SEGMENT MATCHING WITH pcre_dfa_exec()"
+.rs
+.sp
+When a partial match has been found using \fBpcre_dfa_exec()\fP, it is possible
+to continue the match by providing additional subject data and calling
+\fBpcre_dfa_exec()\fP again with the same compiled regular expression, this
+time setting the PCRE_DFA_RESTART option. You must also pass the same working
+space as before, because this is where details of the previous partial match
+are stored. Here is an example using \fBpcretest\fP, using the \eR escape
+sequence to set the PCRE_DFA_RESTART option (\eP and \eD are as above):
+.sp
+    re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/
+  data> 23ja\eP\eD
+  Partial match: 23ja
+  data> n05\eR\eD
+   0: n05
+.sp
+The first call has "23ja" as the subject, and requests partial matching; the
+second call has "n05" as the subject for the continued (restarted) match.
+Notice that when the match is complete, only the last part is shown; PCRE does
+not retain the previously partially-matched string. It is up to the calling
+program to do that if it needs to.
+.P
+You can set PCRE_PARTIAL with PCRE_DFA_RESTART to continue partial matching
+over multiple segments. This facility can be used to pass very long subject
+strings to \fBpcre_dfa_exec()\fP. However, some care is needed for certain
+types of pattern.
+.P
+1. If the pattern contains tests for the beginning or end of a line, you need
+to pass the PCRE_NOTBOL or PCRE_NOTEOL options, as appropriate, when the
+subject string for any call does not contain the beginning or end of a line.
+.P
+2. If the pattern contains backward assertions (including \eb or \eB), you need
+to arrange for some overlap in the subject strings to allow for this. For
+example, you could pass the subject in chunks that are 500 bytes long, but in
+a buffer of 700 bytes, with the starting offset set to 200 and the previous 200
+bytes at the start of the buffer.
+.P
+3. Matching a subject string that is split into multiple segments does not
+always produce exactly the same result as matching over one single long string.
+The difference arises when there are multiple matching possibilities, because a
+partial match result is given only when there are no completed matches in a
+call to \fBpcre_dfa_exec()\fP. This means that as soon as the shortest match has
+been found, continuation to a new subject segment is no longer possible.
+Consider this \fBpcretest\fP example:
+.sp
+    re> /dog(sbody)?/
+  data> do\eP\eD
+  Partial match: do
+  data> gsb\eR\eP\eD
+   0: g
+  data> dogsbody\eD
+   0: dogsbody
+   1: dog
+.sp
+The pattern matches the words "dog" or "dogsbody". When the subject is
+presented in several parts ("do" and "gsb" being the first two) the match stops
+when "dog" has been found, and it is not possible to continue. On the other
+hand, if "dogsbody" is presented as a single string, both matches are found.
+.P
+Because of this phenomenon, it does not usually make sense to end a pattern
+that is going to be matched in this way with a variable repeat.
+.P
+4. Patterns that contain alternatives at the top level which do not all
+start with the same pattern item may not work as expected. For example,
+consider this pattern:
+.sp
+  1234|3789
+.sp
+If the first part of the subject is "ABC123", a partial match of the first
+alternative is found at offset 3. There is no partial match for the second
+alternative, because such a match does not start at the same point in the
+subject string. Attempting to continue with the string "789" does not yield a
+match because only those alternatives that match at one point in the subject
+are remembered. The problem arises because the start of the second alternative
+matches within the first alternative. There is no problem with anchored
+patterns or patterns such as:
+.sp
+  1234|ABCD
+.sp
+where no string can be a partial match for both alternatives.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 04 June 2007
+Copyright (c) 1997-2007 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcrepattern.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2245 @@
+.TH PCREPATTERN 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE REGULAR EXPRESSION DETAILS"
+.rs
+.sp
+The syntax and semantics of the regular expressions that are supported by PCRE
+are described in detail below. There is a quick-reference syntax summary in the
+.\" HREF
+\fBpcresyntax\fP
+.\"
+page. PCRE tries to match Perl syntax and semantics as closely as it can. PCRE
+also supports some alternative regular expression syntax (which does not
+conflict with the Perl syntax) in order to provide some compatibility with
+regular expressions in Python, .NET, and Oniguruma.
+.P
+Perl's regular expressions are described in its own documentation, and
+regular expressions in general are covered in a number of books, some of which
+have copious examples. Jeffrey Friedl's "Mastering Regular Expressions",
+published by O'Reilly, covers regular expressions in great detail. This
+description of PCRE's regular expressions is intended as reference material.
+.P
+The original operation of PCRE was on strings of one-byte characters. However,
+there is now also support for UTF-8 character strings. To use this, you must
+build PCRE to include UTF-8 support, and then call \fBpcre_compile()\fP with
+the PCRE_UTF8 option. How this affects pattern matching is mentioned in several
+places below. There is also a summary of UTF-8 features in the
+.\" HTML <a href="pcre.html#utf8support">
+.\" </a>
+section on UTF-8 support
+.\"
+in the main
+.\" HREF
+\fBpcre\fP
+.\"
+page.
+.P
+The remainder of this document discusses the patterns that are supported by
+PCRE when its main matching function, \fBpcre_exec()\fP, is used.
+From release 6.0, PCRE offers a second matching function,
+\fBpcre_dfa_exec()\fP, which matches using a different algorithm that is not
+Perl-compatible. Some of the features discussed below are not available when
+\fBpcre_dfa_exec()\fP is used. The advantages and disadvantages of the
+alternative function, and how it differs from the normal function, are
+discussed in the
+.\" HREF
+\fBpcrematching\fP
+.\"
+page.
+.
+.
+.SH "NEWLINE CONVENTIONS"
+.rs
+.sp
+PCRE supports five different conventions for indicating line breaks in
+strings: a single CR (carriage return) character, a single LF (linefeed)
+character, the two-character sequence CRLF, any of the three preceding, or any
+Unicode newline sequence. The
+.\" HREF
+\fBpcreapi\fP
+.\"
+page has
+.\" HTML <a href="pcreapi.html#newlines">
+.\" </a>
+further discussion
+.\"
+about newlines, and shows how to set the newline convention in the
+\fIoptions\fP arguments for the compiling and matching functions.
+.P
+It is also possible to specify a newline convention by starting a pattern
+string with one of the following five sequences:
+.sp
+  (*CR)        carriage return
+  (*LF)        linefeed
+  (*CRLF)      carriage return, followed by linefeed
+  (*ANYCRLF)   any of the three above
+  (*ANY)       all Unicode newline sequences
+.sp
+These override the default and the options given to \fBpcre_compile()\fP. For
+example, on a Unix system where LF is the default newline sequence, the pattern
+.sp
+  (*CR)a.b
+.sp
+changes the convention to CR. That pattern matches "a\enb" because LF is no
+longer a newline. Note that these special settings, which are not
+Perl-compatible, are recognized only at the very start of a pattern, and that
+they must be in upper case. If more than one of them is present, the last one
+is used.
+.P
+The newline convention does not affect what the \eR escape sequence matches. By
+default, this is any Unicode newline sequence, for Perl compatibility. However,
+this can be changed; see the description of \eR in the section entitled
+.\" HTML <a href="#newlineseq">
+.\" </a>
+"Newline sequences"
+.\"
+below. A change of \eR setting can be combined with a change of newline
+convention.
+.
+.
+.SH "CHARACTERS AND METACHARACTERS"
+.rs
+.sp
+A regular expression is a pattern that is matched against a subject string from
+left to right. Most characters stand for themselves in a pattern, and match the
+corresponding characters in the subject. As a trivial example, the pattern
+.sp
+  The quick brown fox
+.sp
+matches a portion of a subject string that is identical to itself. When
+caseless matching is specified (the PCRE_CASELESS option), letters are matched
+independently of case. In UTF-8 mode, PCRE always understands the concept of
+case for characters whose values are less than 128, so caseless matching is
+always possible. For characters with higher values, the concept of case is
+supported if PCRE is compiled with Unicode property support, but not otherwise.
+If you want to use caseless matching for characters 128 and above, you must
+ensure that PCRE is compiled with Unicode property support as well as with
+UTF-8 support.
+.P
+The power of regular expressions comes from the ability to include alternatives
+and repetitions in the pattern. These are encoded in the pattern by the use of
+\fImetacharacters\fP, which do not stand for themselves but instead are
+interpreted in some special way.
+.P
+There are two different sets of metacharacters: those that are recognized
+anywhere in the pattern except within square brackets, and those that are
+recognized within square brackets. Outside square brackets, the metacharacters
+are as follows:
+.sp
+  \e      general escape character with several uses
+  ^      assert start of string (or line, in multiline mode)
+  $      assert end of string (or line, in multiline mode)
+  .      match any character except newline (by default)
+  [      start character class definition
+  |      start of alternative branch
+  (      start subpattern
+  )      end subpattern
+  ?      extends the meaning of (
+         also 0 or 1 quantifier
+         also quantifier minimizer
+  *      0 or more quantifier
+  +      1 or more quantifier
+         also "possessive quantifier"
+  {      start min/max quantifier
+.sp
+Part of a pattern that is in square brackets is called a "character class". In
+a character class the only metacharacters are:
+.sp
+  \e      general escape character
+  ^      negate the class, but only if the first character
+  -      indicates character range
+.\" JOIN
+  [      POSIX character class (only if followed by POSIX
+           syntax)
+  ]      terminates the character class
+.sp
+The following sections describe the use of each of the metacharacters.
+.
+.
+.SH BACKSLASH
+.rs
+.sp
+The backslash character has several uses. Firstly, if it is followed by a
+non-alphanumeric character, it takes away any special meaning that character
+may have. This use of backslash as an escape character applies both inside and
+outside character classes.
+.P
+For example, if you want to match a * character, you write \e* in the pattern.
+This escaping action applies whether or not the following character would
+otherwise be interpreted as a metacharacter, so it is always safe to precede a
+non-alphanumeric with backslash to specify that it stands for itself. In
+particular, if you want to match a backslash, you write \e\e.
+.P
+If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the
+pattern (other than in a character class) and characters between a # outside
+a character class and the next newline are ignored. An escaping backslash can
+be used to include a whitespace or # character as part of the pattern.
+.P
+If you want to remove the special meaning from a sequence of characters, you
+can do so by putting them between \eQ and \eE. This is different from Perl in
+that $ and @ are handled as literals in \eQ...\eE sequences in PCRE, whereas in
+Perl, $ and @ cause variable interpolation. Note the following examples:
+.sp
+  Pattern            PCRE matches   Perl matches
+.sp
+.\" JOIN
+  \eQabc$xyz\eE        abc$xyz        abc followed by the
+                                      contents of $xyz
+  \eQabc\e$xyz\eE       abc\e$xyz       abc\e$xyz
+  \eQabc\eE\e$\eQxyz\eE   abc$xyz        abc$xyz
+.sp
+The \eQ...\eE sequence is recognized both inside and outside character classes.
+.
+.
+.\" HTML <a name="digitsafterbackslash"></a>
+.SS "Non-printing characters"
+.rs
+.sp
+A second use of backslash provides a way of encoding non-printing characters
+in patterns in a visible manner. There is no restriction on the appearance of
+non-printing characters, apart from the binary zero that terminates a pattern,
+but when a pattern is being prepared by text editing, it is usually easier to
+use one of the following escape sequences than the binary character it
+represents:
+.sp
+  \ea        alarm, that is, the BEL character (hex 07)
+  \ecx       "control-x", where x is any character
+  \ee        escape (hex 1B)
+  \ef        formfeed (hex 0C)
+  \en        linefeed (hex 0A)
+  \er        carriage return (hex 0D)
+  \et        tab (hex 09)
+  \eddd      character with octal code ddd, or backreference
+  \exhh      character with hex code hh
+  \ex{hhh..} character with hex code hhh..
+.sp
+The precise effect of \ecx is as follows: if x is a lower case letter, it
+is converted to upper case. Then bit 6 of the character (hex 40) is inverted.
+Thus \ecz becomes hex 1A, but \ec{ becomes hex 3B, while \ec; becomes hex
+7B.
+.P
+After \ex, from zero to two hexadecimal digits are read (letters can be in
+upper or lower case). Any number of hexadecimal digits may appear between \ex{
+and }, but the value of the character code must be less than 256 in non-UTF-8
+mode, and less than 2**31 in UTF-8 mode. That is, the maximum value in
+hexadecimal is 7FFFFFFF. Note that this is bigger than the largest Unicode code
+point, which is 10FFFF.
+.P
+If characters other than hexadecimal digits appear between \ex{ and }, or if
+there is no terminating }, this form of escape is not recognized. Instead, the
+initial \ex will be interpreted as a basic hexadecimal escape, with no
+following digits, giving a character whose value is zero.
+.P
+Characters whose value is less than 256 can be defined by either of the two
+syntaxes for \ex. There is no difference in the way they are handled. For
+example, \exdc is exactly the same as \ex{dc}.
+.P
+After \e0 up to two further octal digits are read. If there are fewer than two
+digits, just those that are present are used. Thus the sequence \e0\ex\e07
+specifies two binary zeros followed by a BEL character (code value 7). Make
+sure you supply two digits after the initial zero if the pattern character that
+follows is itself an octal digit.
+.P
+The handling of a backslash followed by a digit other than 0 is complicated.
+Outside a character class, PCRE reads it and any following digits as a decimal
+number. If the number is less than 10, or if there have been at least that many
+previous capturing left parentheses in the expression, the entire sequence is
+taken as a \fIback reference\fP. A description of how this works is given
+.\" HTML <a href="#backreferences">
+.\" </a>
+later,
+.\"
+following the discussion of
+.\" HTML <a href="#subpattern">
+.\" </a>
+parenthesized subpatterns.
+.\"
+.P
+Inside a character class, or if the decimal number is greater than 9 and there
+have not been that many capturing subpatterns, PCRE re-reads up to three octal
+digits following the backslash, and uses them to generate a data character. Any
+subsequent digits stand for themselves. In non-UTF-8 mode, the value of a
+character specified in octal must be less than \e400. In UTF-8 mode, values up
+to \e777 are permitted. For example:
+.sp
+  \e040   is another way of writing a space
+.\" JOIN
+  \e40    is the same, provided there are fewer than 40
+            previous capturing subpatterns
+  \e7     is always a back reference
+.\" JOIN
+  \e11    might be a back reference, or another way of
+            writing a tab
+  \e011   is always a tab
+  \e0113  is a tab followed by the character "3"
+.\" JOIN
+  \e113   might be a back reference, otherwise the
+            character with octal code 113
+.\" JOIN
+  \e377   might be a back reference, otherwise
+            the byte consisting entirely of 1 bits
+.\" JOIN
+  \e81    is either a back reference, or a binary zero
+            followed by the two characters "8" and "1"
+.sp
+Note that octal values of 100 or greater must not be introduced by a leading
+zero, because no more than three octal digits are ever read.
+.P
+All the sequences that define a single character value can be used both inside
+and outside character classes. In addition, inside a character class, the
+sequence \eb is interpreted as the backspace character (hex 08), and the
+sequences \eR and \eX are interpreted as the characters "R" and "X",
+respectively. Outside a character class, these sequences have different
+meanings
+.\" HTML <a href="#uniextseq">
+.\" </a>
+(see below).
+.\"
+.
+.
+.SS "Absolute and relative back references"
+.rs
+.sp
+The sequence \eg followed by an unsigned or a negative number, optionally
+enclosed in braces, is an absolute or relative back reference. A named back
+reference can be coded as \eg{name}. Back references are discussed
+.\" HTML <a href="#backreferences">
+.\" </a>
+later,
+.\"
+following the discussion of
+.\" HTML <a href="#subpattern">
+.\" </a>
+parenthesized subpatterns.
+.\"
+.
+.
+.SS "Absolute and relative subroutine calls"
+.rs
+.sp
+For compatibility with Oniguruma, the non-Perl syntax \eg followed by a name or
+a number enclosed either in angle brackets or single quotes, is an alternative
+syntax for referencing a subpattern as a "subroutine". Details are discussed
+.\" HTML <a href="#onigurumasubroutines">
+.\" </a>
+later.
+.\"
+Note that \eg{...} (Perl syntax) and \eg<...> (Oniguruma syntax) are \fInot\fP
+synonymous. The former is a back reference; the latter is a subroutine call.
+.
+.
+.SS "Generic character types"
+.rs
+.sp
+Another use of backslash is for specifying generic character types. The
+following are always recognized:
+.sp
+  \ed     any decimal digit
+  \eD     any character that is not a decimal digit
+  \eh     any horizontal whitespace character
+  \eH     any character that is not a horizontal whitespace character
+  \es     any whitespace character
+  \eS     any character that is not a whitespace character
+  \ev     any vertical whitespace character
+  \eV     any character that is not a vertical whitespace character
+  \ew     any "word" character
+  \eW     any "non-word" character
+.sp
+Each pair of escape sequences partitions the complete set of characters into
+two disjoint sets. Any given character matches one, and only one, of each pair.
+.P
+These character type sequences can appear both inside and outside character
+classes. They each match one character of the appropriate type. If the current
+matching point is at the end of the subject string, all of them fail, since
+there is no character to match.
+.P
+For compatibility with Perl, \es does not match the VT character (code 11).
+This makes it different from the the POSIX "space" class. The \es characters
+are HT (9), LF (10), FF (12), CR (13), and space (32). If "use locale;" is
+included in a Perl script, \es may match the VT character. In PCRE, it never
+does.
+.P
+In UTF-8 mode, characters with values greater than 128 never match \ed, \es, or
+\ew, and always match \eD, \eS, and \eW. This is true even when Unicode
+character property support is available. These sequences retain their original
+meanings from before UTF-8 support was available, mainly for efficiency
+reasons.
+.P
+The sequences \eh, \eH, \ev, and \eV are Perl 5.10 features. In contrast to the
+other sequences, these do match certain high-valued codepoints in UTF-8 mode.
+The horizontal space characters are:
+.sp
+  U+0009     Horizontal tab
+  U+0020     Space
+  U+00A0     Non-break space
+  U+1680     Ogham space mark
+  U+180E     Mongolian vowel separator
+  U+2000     En quad
+  U+2001     Em quad
+  U+2002     En space
+  U+2003     Em space
+  U+2004     Three-per-em space
+  U+2005     Four-per-em space
+  U+2006     Six-per-em space
+  U+2007     Figure space
+  U+2008     Punctuation space
+  U+2009     Thin space
+  U+200A     Hair space
+  U+202F     Narrow no-break space
+  U+205F     Medium mathematical space
+  U+3000     Ideographic space
+.sp
+The vertical space characters are:
+.sp
+  U+000A     Linefeed
+  U+000B     Vertical tab
+  U+000C     Formfeed
+  U+000D     Carriage return
+  U+0085     Next line
+  U+2028     Line separator
+  U+2029     Paragraph separator
+.P
+A "word" character is an underscore or any character less than 256 that is a
+letter or digit. The definition of letters and digits is controlled by PCRE's
+low-valued character tables, and may vary if locale-specific matching is taking
+place (see
+.\" HTML <a href="pcreapi.html#localesupport">
+.\" </a>
+"Locale support"
+.\"
+in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page). For example, in a French locale such as "fr_FR" in Unix-like systems,
+or "french" in Windows, some character codes greater than 128 are used for
+accented letters, and these are matched by \ew. The use of locales with Unicode
+is discouraged.
+.
+.
+.\" HTML <a name="newlineseq"></a>
+.SS "Newline sequences"
+.rs
+.sp
+Outside a character class, by default, the escape sequence \eR matches any
+Unicode newline sequence. This is a Perl 5.10 feature. In non-UTF-8 mode \eR is
+equivalent to the following:
+.sp
+  (?>\er\en|\en|\ex0b|\ef|\er|\ex85)
+.sp
+This is an example of an "atomic group", details of which are given
+.\" HTML <a href="#atomicgroup">
+.\" </a>
+below.
+.\"
+This particular group matches either the two-character sequence CR followed by
+LF, or one of the single characters LF (linefeed, U+000A), VT (vertical tab,
+U+000B), FF (formfeed, U+000C), CR (carriage return, U+000D), or NEL (next
+line, U+0085). The two-character sequence is treated as a single unit that
+cannot be split.
+.P
+In UTF-8 mode, two additional characters whose codepoints are greater than 255
+are added: LS (line separator, U+2028) and PS (paragraph separator, U+2029).
+Unicode character property support is not needed for these characters to be
+recognized.
+.P
+It is possible to restrict \eR to match only CR, LF, or CRLF (instead of the
+complete set of Unicode line endings) by setting the option PCRE_BSR_ANYCRLF
+either at compile time or when the pattern is matched. (BSR is an abbrevation
+for "backslash R".) This can be made the default when PCRE is built; if this is
+the case, the other behaviour can be requested via the PCRE_BSR_UNICODE option.
+It is also possible to specify these settings by starting a pattern string with
+one of the following sequences:
+.sp
+  (*BSR_ANYCRLF)   CR, LF, or CRLF only
+  (*BSR_UNICODE)   any Unicode newline sequence
+.sp
+These override the default and the options given to \fBpcre_compile()\fP, but
+they can be overridden by options given to \fBpcre_exec()\fP. Note that these
+special settings, which are not Perl-compatible, are recognized only at the
+very start of a pattern, and that they must be in upper case. If more than one
+of them is present, the last one is used. They can be combined with a change of
+newline convention, for example, a pattern can start with:
+.sp
+  (*ANY)(*BSR_ANYCRLF)
+.sp
+Inside a character class, \eR matches the letter "R".
+.
+.
+.\" HTML <a name="uniextseq"></a>
+.SS Unicode character properties
+.rs
+.sp
+When PCRE is built with Unicode character property support, three additional
+escape sequences that match characters with specific properties are available.
+When not in UTF-8 mode, these sequences are of course limited to testing
+characters whose codepoints are less than 256, but they do work in this mode.
+The extra escape sequences are:
+.sp
+  \ep{\fIxx\fP}   a character with the \fIxx\fP property
+  \eP{\fIxx\fP}   a character without the \fIxx\fP property
+  \eX       an extended Unicode sequence
+.sp
+The property names represented by \fIxx\fP above are limited to the Unicode
+script names, the general category properties, and "Any", which matches any
+character (including newline). Other properties such as "InMusicalSymbols" are
+not currently supported by PCRE. Note that \eP{Any} does not match any
+characters, so always causes a match failure.
+.P
+Sets of Unicode characters are defined as belonging to certain scripts. A
+character from one of these sets can be matched using a script name. For
+example:
+.sp
+  \ep{Greek}
+  \eP{Han}
+.sp
+Those that are not part of an identified script are lumped together as
+"Common". The current list of scripts is:
+.P
+Arabic,
+Armenian,
+Balinese,
+Bengali,
+Bopomofo,
+Braille,
+Buginese,
+Buhid,
+Canadian_Aboriginal,
+Cherokee,
+Common,
+Coptic,
+Cuneiform,
+Cypriot,
+Cyrillic,
+Deseret,
+Devanagari,
+Ethiopic,
+Georgian,
+Glagolitic,
+Gothic,
+Greek,
+Gujarati,
+Gurmukhi,
+Han,
+Hangul,
+Hanunoo,
+Hebrew,
+Hiragana,
+Inherited,
+Kannada,
+Katakana,
+Kharoshthi,
+Khmer,
+Lao,
+Latin,
+Limbu,
+Linear_B,
+Malayalam,
+Mongolian,
+Myanmar,
+New_Tai_Lue,
+Nko,
+Ogham,
+Old_Italic,
+Old_Persian,
+Oriya,
+Osmanya,
+Phags_Pa,
+Phoenician,
+Runic,
+Shavian,
+Sinhala,
+Syloti_Nagri,
+Syriac,
+Tagalog,
+Tagbanwa,
+Tai_Le,
+Tamil,
+Telugu,
+Thaana,
+Thai,
+Tibetan,
+Tifinagh,
+Ugaritic,
+Yi.
+.P
+Each character has exactly one general category property, specified by a
+two-letter abbreviation. For compatibility with Perl, negation can be specified
+by including a circumflex between the opening brace and the property name. For
+example, \ep{^Lu} is the same as \eP{Lu}.
+.P
+If only one letter is specified with \ep or \eP, it includes all the general
+category properties that start with that letter. In this case, in the absence
+of negation, the curly brackets in the escape sequence are optional; these two
+examples have the same effect:
+.sp
+  \ep{L}
+  \epL
+.sp
+The following general category property codes are supported:
+.sp
+  C     Other
+  Cc    Control
+  Cf    Format
+  Cn    Unassigned
+  Co    Private use
+  Cs    Surrogate
+.sp
+  L     Letter
+  Ll    Lower case letter
+  Lm    Modifier letter
+  Lo    Other letter
+  Lt    Title case letter
+  Lu    Upper case letter
+.sp
+  M     Mark
+  Mc    Spacing mark
+  Me    Enclosing mark
+  Mn    Non-spacing mark
+.sp
+  N     Number
+  Nd    Decimal number
+  Nl    Letter number
+  No    Other number
+.sp
+  P     Punctuation
+  Pc    Connector punctuation
+  Pd    Dash punctuation
+  Pe    Close punctuation
+  Pf    Final punctuation
+  Pi    Initial punctuation
+  Po    Other punctuation
+  Ps    Open punctuation
+.sp
+  S     Symbol
+  Sc    Currency symbol
+  Sk    Modifier symbol
+  Sm    Mathematical symbol
+  So    Other symbol
+.sp
+  Z     Separator
+  Zl    Line separator
+  Zp    Paragraph separator
+  Zs    Space separator
+.sp
+The special property L& is also supported: it matches a character that has
+the Lu, Ll, or Lt property, in other words, a letter that is not classified as
+a modifier or "other".
+.P
+The Cs (Surrogate) property applies only to characters in the range U+D800 to
+U+DFFF. Such characters are not valid in UTF-8 strings (see RFC 3629) and so
+cannot be tested by PCRE, unless UTF-8 validity checking has been turned off
+(see the discussion of PCRE_NO_UTF8_CHECK in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+page).
+.P
+The long synonyms for these properties that Perl supports (such as \ep{Letter})
+are not supported by PCRE, nor is it permitted to prefix any of these
+properties with "Is".
+.P
+No character that is in the Unicode table has the Cn (unassigned) property.
+Instead, this property is assumed for any code point that is not in the
+Unicode table.
+.P
+Specifying caseless matching does not affect these escape sequences. For
+example, \ep{Lu} always matches only upper case letters.
+.P
+The \eX escape matches any number of Unicode characters that form an extended
+Unicode sequence. \eX is equivalent to
+.sp
+  (?>\ePM\epM*)
+.sp
+That is, it matches a character without the "mark" property, followed by zero
+or more characters with the "mark" property, and treats the sequence as an
+atomic group
+.\" HTML <a href="#atomicgroup">
+.\" </a>
+(see below).
+.\"
+Characters with the "mark" property are typically accents that affect the
+preceding character. None of them have codepoints less than 256, so in
+non-UTF-8 mode \eX matches any one character.
+.P
+Matching characters by Unicode property is not fast, because PCRE has to search
+a structure that contains data for over fifteen thousand characters. That is
+why the traditional escape sequences such as \ed and \ew do not use Unicode
+properties in PCRE.
+.
+.
+.\" HTML <a name="resetmatchstart"></a>
+.SS "Resetting the match start"
+.rs
+.sp
+The escape sequence \eK, which is a Perl 5.10 feature, causes any previously
+matched characters not to be included in the final matched sequence. For
+example, the pattern:
+.sp
+  foo\eKbar
+.sp
+matches "foobar", but reports that it has matched "bar". This feature is
+similar to a lookbehind assertion
+.\" HTML <a href="#lookbehind">
+.\" </a>
+(described below).
+.\"
+However, in this case, the part of the subject before the real match does not
+have to be of fixed length, as lookbehind assertions do. The use of \eK does
+not interfere with the setting of
+.\" HTML <a href="#subpattern">
+.\" </a>
+captured substrings.
+.\"
+For example, when the pattern
+.sp
+  (foo)\eKbar
+.sp
+matches "foobar", the first substring is still set to "foo".
+.
+.
+.\" HTML <a name="smallassertions"></a>
+.SS "Simple assertions"
+.rs
+.sp
+The final use of backslash is for certain simple assertions. An assertion
+specifies a condition that has to be met at a particular point in a match,
+without consuming any characters from the subject string. The use of
+subpatterns for more complicated assertions is described
+.\" HTML <a href="#bigassertions">
+.\" </a>
+below.
+.\"
+The backslashed assertions are:
+.sp
+  \eb     matches at a word boundary
+  \eB     matches when not at a word boundary
+  \eA     matches at the start of the subject
+  \eZ     matches at the end of the subject
+          also matches before a newline at the end of the subject
+  \ez     matches only at the end of the subject
+  \eG     matches at the first matching position in the subject
+.sp
+These assertions may not appear in character classes (but note that \eb has a
+different meaning, namely the backspace character, inside a character class).
+.P
+A word boundary is a position in the subject string where the current character
+and the previous character do not both match \ew or \eW (i.e. one matches
+\ew and the other matches \eW), or the start or end of the string if the
+first or last character matches \ew, respectively.
+.P
+The \eA, \eZ, and \ez assertions differ from the traditional circumflex and
+dollar (described in the next section) in that they only ever match at the very
+start and end of the subject string, whatever options are set. Thus, they are
+independent of multiline mode. These three assertions are not affected by the
+PCRE_NOTBOL or PCRE_NOTEOL options, which affect only the behaviour of the
+circumflex and dollar metacharacters. However, if the \fIstartoffset\fP
+argument of \fBpcre_exec()\fP is non-zero, indicating that matching is to start
+at a point other than the beginning of the subject, \eA can never match. The
+difference between \eZ and \ez is that \eZ matches before a newline at the end
+of the string as well as at the very end, whereas \ez matches only at the end.
+.P
+The \eG assertion is true only when the current matching position is at the
+start point of the match, as specified by the \fIstartoffset\fP argument of
+\fBpcre_exec()\fP. It differs from \eA when the value of \fIstartoffset\fP is
+non-zero. By calling \fBpcre_exec()\fP multiple times with appropriate
+arguments, you can mimic Perl's /g option, and it is in this kind of
+implementation where \eG can be useful.
+.P
+Note, however, that PCRE's interpretation of \eG, as the start of the current
+match, is subtly different from Perl's, which defines it as the end of the
+previous match. In Perl, these can be different when the previously matched
+string was empty. Because PCRE does just one match at a time, it cannot
+reproduce this behaviour.
+.P
+If all the alternatives of a pattern begin with \eG, the expression is anchored
+to the starting match position, and the "anchored" flag is set in the compiled
+regular expression.
+.
+.
+.SH "CIRCUMFLEX AND DOLLAR"
+.rs
+.sp
+Outside a character class, in the default matching mode, the circumflex
+character is an assertion that is true only if the current matching point is
+at the start of the subject string. If the \fIstartoffset\fP argument of
+\fBpcre_exec()\fP is non-zero, circumflex can never match if the PCRE_MULTILINE
+option is unset. Inside a character class, circumflex has an entirely different
+meaning
+.\" HTML <a href="#characterclass">
+.\" </a>
+(see below).
+.\"
+.P
+Circumflex need not be the first character of the pattern if a number of
+alternatives are involved, but it should be the first thing in each alternative
+in which it appears if the pattern is ever to match that branch. If all
+possible alternatives start with a circumflex, that is, if the pattern is
+constrained to match only at the start of the subject, it is said to be an
+"anchored" pattern. (There are also other constructs that can cause a pattern
+to be anchored.)
+.P
+A dollar character is an assertion that is true only if the current matching
+point is at the end of the subject string, or immediately before a newline
+at the end of the string (by default). Dollar need not be the last character of
+the pattern if a number of alternatives are involved, but it should be the last
+item in any branch in which it appears. Dollar has no special meaning in a
+character class.
+.P
+The meaning of dollar can be changed so that it matches only at the very end of
+the string, by setting the PCRE_DOLLAR_ENDONLY option at compile time. This
+does not affect the \eZ assertion.
+.P
+The meanings of the circumflex and dollar characters are changed if the
+PCRE_MULTILINE option is set. When this is the case, a circumflex matches
+immediately after internal newlines as well as at the start of the subject
+string. It does not match after a newline that ends the string. A dollar
+matches before any newlines in the string, as well as at the very end, when
+PCRE_MULTILINE is set. When newline is specified as the two-character
+sequence CRLF, isolated CR and LF characters do not indicate newlines.
+.P
+For example, the pattern /^abc$/ matches the subject string "def\enabc" (where
+\en represents a newline) in multiline mode, but not otherwise. Consequently,
+patterns that are anchored in single line mode because all branches start with
+^ are not anchored in multiline mode, and a match for circumflex is possible
+when the \fIstartoffset\fP argument of \fBpcre_exec()\fP is non-zero. The
+PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is set.
+.P
+Note that the sequences \eA, \eZ, and \ez can be used to match the start and
+end of the subject in both modes, and if all branches of a pattern start with
+\eA it is always anchored, whether or not PCRE_MULTILINE is set.
+.
+.
+.SH "FULL STOP (PERIOD, DOT)"
+.rs
+.sp
+Outside a character class, a dot in the pattern matches any one character in
+the subject string except (by default) a character that signifies the end of a
+line. In UTF-8 mode, the matched character may be more than one byte long.
+.P
+When a line ending is defined as a single character, dot never matches that
+character; when the two-character sequence CRLF is used, dot does not match CR
+if it is immediately followed by LF, but otherwise it matches all characters
+(including isolated CRs and LFs). When any Unicode line endings are being
+recognized, dot does not match CR or LF or any of the other line ending
+characters.
+.P
+The behaviour of dot with regard to newlines can be changed. If the PCRE_DOTALL
+option is set, a dot matches any one character, without exception. If the
+two-character sequence CRLF is present in the subject string, it takes two dots
+to match it.
+.P
+The handling of dot is entirely independent of the handling of circumflex and
+dollar, the only relationship being that they both involve newlines. Dot has no
+special meaning in a character class.
+.
+.
+.SH "MATCHING A SINGLE BYTE"
+.rs
+.sp
+Outside a character class, the escape sequence \eC matches any one byte, both
+in and out of UTF-8 mode. Unlike a dot, it always matches any line-ending
+characters. The feature is provided in Perl in order to match individual bytes
+in UTF-8 mode. Because it breaks up UTF-8 characters into individual bytes,
+what remains in the string may be a malformed UTF-8 string. For this reason,
+the \eC escape sequence is best avoided.
+.P
+PCRE does not allow \eC to appear in lookbehind assertions
+.\" HTML <a href="#lookbehind">
+.\" </a>
+(described below),
+.\"
+because in UTF-8 mode this would make it impossible to calculate the length of
+the lookbehind.
+.
+.
+.\" HTML <a name="characterclass"></a>
+.SH "SQUARE BRACKETS AND CHARACTER CLASSES"
+.rs
+.sp
+An opening square bracket introduces a character class, terminated by a closing
+square bracket. A closing square bracket on its own is not special. If a
+closing square bracket is required as a member of the class, it should be the
+first data character in the class (after an initial circumflex, if present) or
+escaped with a backslash.
+.P
+A character class matches a single character in the subject. In UTF-8 mode, the
+character may occupy more than one byte. A matched character must be in the set
+of characters defined by the class, unless the first character in the class
+definition is a circumflex, in which case the subject character must not be in
+the set defined by the class. If a circumflex is actually required as a member
+of the class, ensure it is not the first character, or escape it with a
+backslash.
+.P
+For example, the character class [aeiou] matches any lower case vowel, while
+[^aeiou] matches any character that is not a lower case vowel. Note that a
+circumflex is just a convenient notation for specifying the characters that
+are in the class by enumerating those that are not. A class that starts with a
+circumflex is not an assertion: it still consumes a character from the subject
+string, and therefore it fails if the current pointer is at the end of the
+string.
+.P
+In UTF-8 mode, characters with values greater than 255 can be included in a
+class as a literal string of bytes, or by using the \ex{ escaping mechanism.
+.P
+When caseless matching is set, any letters in a class represent both their
+upper case and lower case versions, so for example, a caseless [aeiou] matches
+"A" as well as "a", and a caseless [^aeiou] does not match "A", whereas a
+caseful version would. In UTF-8 mode, PCRE always understands the concept of
+case for characters whose values are less than 128, so caseless matching is
+always possible. For characters with higher values, the concept of case is
+supported if PCRE is compiled with Unicode property support, but not otherwise.
+If you want to use caseless matching for characters 128 and above, you must
+ensure that PCRE is compiled with Unicode property support as well as with
+UTF-8 support.
+.P
+Characters that might indicate line breaks are never treated in any special way
+when matching character classes, whatever line-ending sequence is in use, and
+whatever setting of the PCRE_DOTALL and PCRE_MULTILINE options is used. A class
+such as [^a] always matches one of these characters.
+.P
+The minus (hyphen) character can be used to specify a range of characters in a
+character class. For example, [d-m] matches any letter between d and m,
+inclusive. If a minus character is required in a class, it must be escaped with
+a backslash or appear in a position where it cannot be interpreted as
+indicating a range, typically as the first or last character in the class.
+.P
+It is not possible to have the literal character "]" as the end character of a
+range. A pattern such as [W-]46] is interpreted as a class of two characters
+("W" and "-") followed by a literal string "46]", so it would match "W46]" or
+"-46]". However, if the "]" is escaped with a backslash it is interpreted as
+the end of range, so [W-\e]46] is interpreted as a class containing a range
+followed by two other characters. The octal or hexadecimal representation of
+"]" can also be used to end a range.
+.P
+Ranges operate in the collating sequence of character values. They can also be
+used for characters specified numerically, for example [\e000-\e037]. In UTF-8
+mode, ranges can include characters whose values are greater than 255, for
+example [\ex{100}-\ex{2ff}].
+.P
+If a range that includes letters is used when caseless matching is set, it
+matches the letters in either case. For example, [W-c] is equivalent to
+[][\e\e^_`wxyzabc], matched caselessly, and in non-UTF-8 mode, if character
+tables for a French locale are in use, [\exc8-\excb] matches accented E
+characters in both cases. In UTF-8 mode, PCRE supports the concept of case for
+characters with values greater than 128 only when it is compiled with Unicode
+property support.
+.P
+The character types \ed, \eD, \ep, \eP, \es, \eS, \ew, and \eW may also appear
+in a character class, and add the characters that they match to the class. For
+example, [\edABCDEF] matches any hexadecimal digit. A circumflex can
+conveniently be used with the upper case character types to specify a more
+restricted set of characters than the matching lower case type. For example,
+the class [^\eW_] matches any letter or digit, but not underscore.
+.P
+The only metacharacters that are recognized in character classes are backslash,
+hyphen (only where it can be interpreted as specifying a range), circumflex
+(only at the start), opening square bracket (only when it can be interpreted as
+introducing a POSIX class name - see the next section), and the terminating
+closing square bracket. However, escaping other non-alphanumeric characters
+does no harm.
+.
+.
+.SH "POSIX CHARACTER CLASSES"
+.rs
+.sp
+Perl supports the POSIX notation for character classes. This uses names
+enclosed by [: and :] within the enclosing square brackets. PCRE also supports
+this notation. For example,
+.sp
+  [01[:alpha:]%]
+.sp
+matches "0", "1", any alphabetic character, or "%". The supported class names
+are
+.sp
+  alnum    letters and digits
+  alpha    letters
+  ascii    character codes 0 - 127
+  blank    space or tab only
+  cntrl    control characters
+  digit    decimal digits (same as \ed)
+  graph    printing characters, excluding space
+  lower    lower case letters
+  print    printing characters, including space
+  punct    printing characters, excluding letters and digits
+  space    white space (not quite the same as \es)
+  upper    upper case letters
+  word     "word" characters (same as \ew)
+  xdigit   hexadecimal digits
+.sp
+The "space" characters are HT (9), LF (10), VT (11), FF (12), CR (13), and
+space (32). Notice that this list includes the VT character (code 11). This
+makes "space" different to \es, which does not include VT (for Perl
+compatibility).
+.P
+The name "word" is a Perl extension, and "blank" is a GNU extension from Perl
+5.8. Another Perl extension is negation, which is indicated by a ^ character
+after the colon. For example,
+.sp
+  [12[:^digit:]]
+.sp
+matches "1", "2", or any non-digit. PCRE (and Perl) also recognize the POSIX
+syntax [.ch.] and [=ch=] where "ch" is a "collating element", but these are not
+supported, and an error is given if they are encountered.
+.P
+In UTF-8 mode, characters with values greater than 128 do not match any of
+the POSIX character classes.
+.
+.
+.SH "VERTICAL BAR"
+.rs
+.sp
+Vertical bar characters are used to separate alternative patterns. For example,
+the pattern
+.sp
+  gilbert|sullivan
+.sp
+matches either "gilbert" or "sullivan". Any number of alternatives may appear,
+and an empty alternative is permitted (matching the empty string). The matching
+process tries each alternative in turn, from left to right, and the first one
+that succeeds is used. If the alternatives are within a subpattern
+.\" HTML <a href="#subpattern">
+.\" </a>
+(defined below),
+.\"
+"succeeds" means matching the rest of the main pattern as well as the
+alternative in the subpattern.
+.
+.
+.SH "INTERNAL OPTION SETTING"
+.rs
+.sp
+The settings of the PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
+PCRE_EXTENDED options (which are Perl-compatible) can be changed from within
+the pattern by a sequence of Perl option letters enclosed between "(?" and ")".
+The option letters are
+.sp
+  i  for PCRE_CASELESS
+  m  for PCRE_MULTILINE
+  s  for PCRE_DOTALL
+  x  for PCRE_EXTENDED
+.sp
+For example, (?im) sets caseless, multiline matching. It is also possible to
+unset these options by preceding the letter with a hyphen, and a combined
+setting and unsetting such as (?im-sx), which sets PCRE_CASELESS and
+PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED, is also
+permitted. If a letter appears both before and after the hyphen, the option is
+unset.
+.P
+The PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and PCRE_EXTRA can be
+changed in the same way as the Perl-compatible options by using the characters
+J, U and X respectively.
+.P
+When an option change occurs at top level (that is, not inside subpattern
+parentheses), the change applies to the remainder of the pattern that follows.
+If the change is placed right at the start of a pattern, PCRE extracts it into
+the global options (and it will therefore show up in data extracted by the
+\fBpcre_fullinfo()\fP function).
+.P
+An option change within a subpattern (see below for a description of
+subpatterns) affects only that part of the current pattern that follows it, so
+.sp
+  (a(?i)b)c
+.sp
+matches abc and aBc and no other strings (assuming PCRE_CASELESS is not used).
+By this means, options can be made to have different settings in different
+parts of the pattern. Any changes made in one alternative do carry on
+into subsequent branches within the same subpattern. For example,
+.sp
+  (a(?i)b|c)
+.sp
+matches "ab", "aB", "c", and "C", even though when matching "C" the first
+branch is abandoned before the option setting. This is because the effects of
+option settings happen at compile time. There would be some very weird
+behaviour otherwise.
+.P
+\fBNote:\fP There are other PCRE-specific options that can be set by the
+application when the compile or match functions are called. In some cases the
+pattern can contain special leading sequences to override what the application
+has set or what has been defaulted. Details are given in the section entitled
+.\" HTML <a href="#newlineseq">
+.\" </a>
+"Newline sequences"
+.\"
+above.
+.
+.
+.\" HTML <a name="subpattern"></a>
+.SH SUBPATTERNS
+.rs
+.sp
+Subpatterns are delimited by parentheses (round brackets), which can be nested.
+Turning part of a pattern into a subpattern does two things:
+.sp
+1. It localizes a set of alternatives. For example, the pattern
+.sp
+  cat(aract|erpillar|)
+.sp
+matches one of the words "cat", "cataract", or "caterpillar". Without the
+parentheses, it would match "cataract", "erpillar" or an empty string.
+.sp
+2. It sets up the subpattern as a capturing subpattern. This means that, when
+the whole pattern matches, that portion of the subject string that matched the
+subpattern is passed back to the caller via the \fIovector\fP argument of
+\fBpcre_exec()\fP. Opening parentheses are counted from left to right (starting
+from 1) to obtain numbers for the capturing subpatterns.
+.P
+For example, if the string "the red king" is matched against the pattern
+.sp
+  the ((red|white) (king|queen))
+.sp
+the captured substrings are "red king", "red", and "king", and are numbered 1,
+2, and 3, respectively.
+.P
+The fact that plain parentheses fulfil two functions is not always helpful.
+There are often times when a grouping subpattern is required without a
+capturing requirement. If an opening parenthesis is followed by a question mark
+and a colon, the subpattern does not do any capturing, and is not counted when
+computing the number of any subsequent capturing subpatterns. For example, if
+the string "the white queen" is matched against the pattern
+.sp
+  the ((?:red|white) (king|queen))
+.sp
+the captured substrings are "white queen" and "queen", and are numbered 1 and
+2. The maximum number of capturing subpatterns is 65535.
+.P
+As a convenient shorthand, if any option settings are required at the start of
+a non-capturing subpattern, the option letters may appear between the "?" and
+the ":". Thus the two patterns
+.sp
+  (?i:saturday|sunday)
+  (?:(?i)saturday|sunday)
+.sp
+match exactly the same set of strings. Because alternative branches are tried
+from left to right, and options are not reset until the end of the subpattern
+is reached, an option setting in one branch does affect subsequent branches, so
+the above patterns match "SUNDAY" as well as "Saturday".
+.
+.
+.SH "DUPLICATE SUBPATTERN NUMBERS"
+.rs
+.sp
+Perl 5.10 introduced a feature whereby each alternative in a subpattern uses
+the same numbers for its capturing parentheses. Such a subpattern starts with
+(?| and is itself a non-capturing subpattern. For example, consider this
+pattern:
+.sp
+  (?|(Sat)ur|(Sun))day
+.sp
+Because the two alternatives are inside a (?| group, both sets of capturing
+parentheses are numbered one. Thus, when the pattern matches, you can look
+at captured substring number one, whichever alternative matched. This construct
+is useful when you want to capture part, but not all, of one of a number of
+alternatives. Inside a (?| group, parentheses are numbered as usual, but the
+number is reset at the start of each branch. The numbers of any capturing
+buffers that follow the subpattern start after the highest number used in any
+branch. The following example is taken from the Perl documentation.
+The numbers underneath show in which buffer the captured content will be
+stored.
+.sp
+  # before  ---------------branch-reset----------- after
+  / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
+  # 1            2         2  3        2     3     4
+.sp
+A backreference or a recursive call to a numbered subpattern always refers to
+the first one in the pattern with the given number.
+.P
+An alternative approach to using this "branch reset" feature is to use
+duplicate named subpatterns, as described in the next section.
+.
+.
+.SH "NAMED SUBPATTERNS"
+.rs
+.sp
+Identifying capturing parentheses by number is simple, but it can be very hard
+to keep track of the numbers in complicated regular expressions. Furthermore,
+if an expression is modified, the numbers may change. To help with this
+difficulty, PCRE supports the naming of subpatterns. This feature was not
+added to Perl until release 5.10. Python had the feature earlier, and PCRE
+introduced it at release 4.0, using the Python syntax. PCRE now supports both
+the Perl and the Python syntax.
+.P
+In PCRE, a subpattern can be named in one of three ways: (?<name>...) or
+(?'name'...) as in Perl, or (?P<name>...) as in Python. References to capturing
+parentheses from other parts of the pattern, such as
+.\" HTML <a href="#backreferences">
+.\" </a>
+backreferences,
+.\"
+.\" HTML <a href="#recursion">
+.\" </a>
+recursion,
+.\"
+and
+.\" HTML <a href="#conditions">
+.\" </a>
+conditions,
+.\"
+can be made by name as well as by number.
+.P
+Names consist of up to 32 alphanumeric characters and underscores. Named
+capturing parentheses are still allocated numbers as well as names, exactly as
+if the names were not present. The PCRE API provides function calls for
+extracting the name-to-number translation table from a compiled pattern. There
+is also a convenience function for extracting a captured substring by name.
+.P
+By default, a name must be unique within a pattern, but it is possible to relax
+this constraint by setting the PCRE_DUPNAMES option at compile time. This can
+be useful for patterns where only one instance of the named parentheses can
+match. Suppose you want to match the name of a weekday, either as a 3-letter
+abbreviation or as the full name, and in both cases you want to extract the
+abbreviation. This pattern (ignoring the line breaks) does the job:
+.sp
+  (?<DN>Mon|Fri|Sun)(?:day)?|
+  (?<DN>Tue)(?:sday)?|
+  (?<DN>Wed)(?:nesday)?|
+  (?<DN>Thu)(?:rsday)?|
+  (?<DN>Sat)(?:urday)?
+.sp
+There are five capturing substrings, but only one is ever set after a match.
+(An alternative way of solving this problem is to use a "branch reset"
+subpattern, as described in the previous section.)
+.P
+The convenience function for extracting the data by name returns the substring
+for the first (and in this example, the only) subpattern of that name that
+matched. This saves searching to find which numbered subpattern it was. If you
+make a reference to a non-unique named subpattern from elsewhere in the
+pattern, the one that corresponds to the lowest number is used. For further
+details of the interfaces for handling named subpatterns, see the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation.
+.
+.
+.SH REPETITION
+.rs
+.sp
+Repetition is specified by quantifiers, which can follow any of the following
+items:
+.sp
+  a literal data character
+  the dot metacharacter
+  the \eC escape sequence
+  the \eX escape sequence (in UTF-8 mode with Unicode properties)
+  the \eR escape sequence
+  an escape such as \ed that matches a single character
+  a character class
+  a back reference (see next section)
+  a parenthesized subpattern (unless it is an assertion)
+.sp
+The general repetition quantifier specifies a minimum and maximum number of
+permitted matches, by giving the two numbers in curly brackets (braces),
+separated by a comma. The numbers must be less than 65536, and the first must
+be less than or equal to the second. For example:
+.sp
+  z{2,4}
+.sp
+matches "zz", "zzz", or "zzzz". A closing brace on its own is not a special
+character. If the second number is omitted, but the comma is present, there is
+no upper limit; if the second number and the comma are both omitted, the
+quantifier specifies an exact number of required matches. Thus
+.sp
+  [aeiou]{3,}
+.sp
+matches at least 3 successive vowels, but may match many more, while
+.sp
+  \ed{8}
+.sp
+matches exactly 8 digits. An opening curly bracket that appears in a position
+where a quantifier is not allowed, or one that does not match the syntax of a
+quantifier, is taken as a literal character. For example, {,6} is not a
+quantifier, but a literal string of four characters.
+.P
+In UTF-8 mode, quantifiers apply to UTF-8 characters rather than to individual
+bytes. Thus, for example, \ex{100}{2} matches two UTF-8 characters, each of
+which is represented by a two-byte sequence. Similarly, when Unicode property
+support is available, \eX{3} matches three Unicode extended sequences, each of
+which may be several bytes long (and they may be of different lengths).
+.P
+The quantifier {0} is permitted, causing the expression to behave as if the
+previous item and the quantifier were not present. This may be useful for
+subpatterns that are referenced as
+.\" HTML <a href="#subpatternsassubroutines">
+.\" </a>
+subroutines
+.\"
+from elsewhere in the pattern. Items other than subpatterns that have a {0}
+quantifier are omitted from the compiled pattern.
+.P
+For convenience, the three most common quantifiers have single-character
+abbreviations:
+.sp
+  *    is equivalent to {0,}
+  +    is equivalent to {1,}
+  ?    is equivalent to {0,1}
+.sp
+It is possible to construct infinite loops by following a subpattern that can
+match no characters with a quantifier that has no upper limit, for example:
+.sp
+  (a?)*
+.sp
+Earlier versions of Perl and PCRE used to give an error at compile time for
+such patterns. However, because there are cases where this can be useful, such
+patterns are now accepted, but if any repetition of the subpattern does in fact
+match no characters, the loop is forcibly broken.
+.P
+By default, the quantifiers are "greedy", that is, they match as much as
+possible (up to the maximum number of permitted times), without causing the
+rest of the pattern to fail. The classic example of where this gives problems
+is in trying to match comments in C programs. These appear between /* and */
+and within the comment, individual * and / characters may appear. An attempt to
+match C comments by applying the pattern
+.sp
+  /\e*.*\e*/
+.sp
+to the string
+.sp
+  /* first comment */  not comment  /* second comment */
+.sp
+fails, because it matches the entire string owing to the greediness of the .*
+item.
+.P
+However, if a quantifier is followed by a question mark, it ceases to be
+greedy, and instead matches the minimum number of times possible, so the
+pattern
+.sp
+  /\e*.*?\e*/
+.sp
+does the right thing with the C comments. The meaning of the various
+quantifiers is not otherwise changed, just the preferred number of matches.
+Do not confuse this use of question mark with its use as a quantifier in its
+own right. Because it has two uses, it can sometimes appear doubled, as in
+.sp
+  \ed??\ed
+.sp
+which matches one digit by preference, but can match two if that is the only
+way the rest of the pattern matches.
+.P
+If the PCRE_UNGREEDY option is set (an option that is not available in Perl),
+the quantifiers are not greedy by default, but individual ones can be made
+greedy by following them with a question mark. In other words, it inverts the
+default behaviour.
+.P
+When a parenthesized subpattern is quantified with a minimum repeat count that
+is greater than 1 or with a limited maximum, more memory is required for the
+compiled pattern, in proportion to the size of the minimum or maximum.
+.P
+If a pattern starts with .* or .{0,} and the PCRE_DOTALL option (equivalent
+to Perl's /s) is set, thus allowing the dot to match newlines, the pattern is
+implicitly anchored, because whatever follows will be tried against every
+character position in the subject string, so there is no point in retrying the
+overall match at any position after the first. PCRE normally treats such a
+pattern as though it were preceded by \eA.
+.P
+In cases where it is known that the subject string contains no newlines, it is
+worth setting PCRE_DOTALL in order to obtain this optimization, or
+alternatively using ^ to indicate anchoring explicitly.
+.P
+However, there is one situation where the optimization cannot be used. When .*
+is inside capturing parentheses that are the subject of a backreference
+elsewhere in the pattern, a match at the start may fail where a later one
+succeeds. Consider, for example:
+.sp
+  (.*)abc\e1
+.sp
+If the subject is "xyz123abc123" the match point is the fourth character. For
+this reason, such a pattern is not implicitly anchored.
+.P
+When a capturing subpattern is repeated, the value captured is the substring
+that matched the final iteration. For example, after
+.sp
+  (tweedle[dume]{3}\es*)+
+.sp
+has matched "tweedledum tweedledee" the value of the captured substring is
+"tweedledee". However, if there are nested capturing subpatterns, the
+corresponding captured values may have been set in previous iterations. For
+example, after
+.sp
+  /(a|(b))+/
+.sp
+matches "aba" the value of the second captured substring is "b".
+.
+.
+.\" HTML <a name="atomicgroup"></a>
+.SH "ATOMIC GROUPING AND POSSESSIVE QUANTIFIERS"
+.rs
+.sp
+With both maximizing ("greedy") and minimizing ("ungreedy" or "lazy")
+repetition, failure of what follows normally causes the repeated item to be
+re-evaluated to see if a different number of repeats allows the rest of the
+pattern to match. Sometimes it is useful to prevent this, either to change the
+nature of the match, or to cause it fail earlier than it otherwise might, when
+the author of the pattern knows there is no point in carrying on.
+.P
+Consider, for example, the pattern \ed+foo when applied to the subject line
+.sp
+  123456bar
+.sp
+After matching all 6 digits and then failing to match "foo", the normal
+action of the matcher is to try again with only 5 digits matching the \ed+
+item, and then with 4, and so on, before ultimately failing. "Atomic grouping"
+(a term taken from Jeffrey Friedl's book) provides the means for specifying
+that once a subpattern has matched, it is not to be re-evaluated in this way.
+.P
+If we use atomic grouping for the previous example, the matcher gives up
+immediately on failing to match "foo" the first time. The notation is a kind of
+special parenthesis, starting with (?> as in this example:
+.sp
+  (?>\ed+)foo
+.sp
+This kind of parenthesis "locks up" the  part of the pattern it contains once
+it has matched, and a failure further into the pattern is prevented from
+backtracking into it. Backtracking past it to previous items, however, works as
+normal.
+.P
+An alternative description is that a subpattern of this type matches the string
+of characters that an identical standalone pattern would match, if anchored at
+the current point in the subject string.
+.P
+Atomic grouping subpatterns are not capturing subpatterns. Simple cases such as
+the above example can be thought of as a maximizing repeat that must swallow
+everything it can. So, while both \ed+ and \ed+? are prepared to adjust the
+number of digits they match in order to make the rest of the pattern match,
+(?>\ed+) can only match an entire sequence of digits.
+.P
+Atomic groups in general can of course contain arbitrarily complicated
+subpatterns, and can be nested. However, when the subpattern for an atomic
+group is just a single repeated item, as in the example above, a simpler
+notation, called a "possessive quantifier" can be used. This consists of an
+additional + character following a quantifier. Using this notation, the
+previous example can be rewritten as
+.sp
+  \ed++foo
+.sp
+Note that a possessive quantifier can be used with an entire group, for
+example:
+.sp
+  (abc|xyz){2,3}+
+.sp
+Possessive quantifiers are always greedy; the setting of the PCRE_UNGREEDY
+option is ignored. They are a convenient notation for the simpler forms of
+atomic group. However, there is no difference in the meaning of a possessive
+quantifier and the equivalent atomic group, though there may be a performance
+difference; possessive quantifiers should be slightly faster.
+.P
+The possessive quantifier syntax is an extension to the Perl 5.8 syntax.
+Jeffrey Friedl originated the idea (and the name) in the first edition of his
+book. Mike McCloskey liked it, so implemented it when he built Sun's Java
+package, and PCRE copied it from there. It ultimately found its way into Perl
+at release 5.10.
+.P
+PCRE has an optimization that automatically "possessifies" certain simple
+pattern constructs. For example, the sequence A+B is treated as A++B because
+there is no point in backtracking into a sequence of A's when B must follow.
+.P
+When a pattern contains an unlimited repeat inside a subpattern that can itself
+be repeated an unlimited number of times, the use of an atomic group is the
+only way to avoid some failing matches taking a very long time indeed. The
+pattern
+.sp
+  (\eD+|<\ed+>)*[!?]
+.sp
+matches an unlimited number of substrings that either consist of non-digits, or
+digits enclosed in <>, followed by either ! or ?. When it matches, it runs
+quickly. However, if it is applied to
+.sp
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+.sp
+it takes a long time before reporting failure. This is because the string can
+be divided between the internal \eD+ repeat and the external * repeat in a
+large number of ways, and all have to be tried. (The example uses [!?] rather
+than a single character at the end, because both PCRE and Perl have an
+optimization that allows for fast failure when a single character is used. They
+remember the last single character that is required for a match, and fail early
+if it is not present in the string.) If the pattern is changed so that it uses
+an atomic group, like this:
+.sp
+  ((?>\eD+)|<\ed+>)*[!?]
+.sp
+sequences of non-digits cannot be broken, and failure happens quickly.
+.
+.
+.\" HTML <a name="backreferences"></a>
+.SH "BACK REFERENCES"
+.rs
+.sp
+Outside a character class, a backslash followed by a digit greater than 0 (and
+possibly further digits) is a back reference to a capturing subpattern earlier
+(that is, to its left) in the pattern, provided there have been that many
+previous capturing left parentheses.
+.P
+However, if the decimal number following the backslash is less than 10, it is
+always taken as a back reference, and causes an error only if there are not
+that many capturing left parentheses in the entire pattern. In other words, the
+parentheses that are referenced need not be to the left of the reference for
+numbers less than 10. A "forward back reference" of this type can make sense
+when a repetition is involved and the subpattern to the right has participated
+in an earlier iteration.
+.P
+It is not possible to have a numerical "forward back reference" to a subpattern
+whose number is 10 or more using this syntax because a sequence such as \e50 is
+interpreted as a character defined in octal. See the subsection entitled
+"Non-printing characters"
+.\" HTML <a href="#digitsafterbackslash">
+.\" </a>
+above
+.\"
+for further details of the handling of digits following a backslash. There is
+no such problem when named parentheses are used. A back reference to any
+subpattern is possible using named parentheses (see below).
+.P
+Another way of avoiding the ambiguity inherent in the use of digits following a
+backslash is to use the \eg escape sequence, which is a feature introduced in
+Perl 5.10. This escape must be followed by an unsigned number or a negative
+number, optionally enclosed in braces. These examples are all identical:
+.sp
+  (ring), \e1
+  (ring), \eg1
+  (ring), \eg{1}
+.sp
+An unsigned number specifies an absolute reference without the ambiguity that
+is present in the older syntax. It is also useful when literal digits follow
+the reference. A negative number is a relative reference. Consider this
+example:
+.sp
+  (abc(def)ghi)\eg{-1}
+.sp
+The sequence \eg{-1} is a reference to the most recently started capturing
+subpattern before \eg, that is, is it equivalent to \e2. Similarly, \eg{-2}
+would be equivalent to \e1. The use of relative references can be helpful in
+long patterns, and also in patterns that are created by joining together
+fragments that contain references within themselves.
+.P
+A back reference matches whatever actually matched the capturing subpattern in
+the current subject string, rather than anything matching the subpattern
+itself (see
+.\" HTML <a href="#subpatternsassubroutines">
+.\" </a>
+"Subpatterns as subroutines"
+.\"
+below for a way of doing that). So the pattern
+.sp
+  (sens|respons)e and \e1ibility
+.sp
+matches "sense and sensibility" and "response and responsibility", but not
+"sense and responsibility". If caseful matching is in force at the time of the
+back reference, the case of letters is relevant. For example,
+.sp
+  ((?i)rah)\es+\e1
+.sp
+matches "rah rah" and "RAH RAH", but not "RAH rah", even though the original
+capturing subpattern is matched caselessly.
+.P
+There are several different ways of writing back references to named
+subpatterns. The .NET syntax \ek{name} and the Perl syntax \ek<name> or
+\ek'name' are supported, as is the Python syntax (?P=name). Perl 5.10's unified
+back reference syntax, in which \eg can be used for both numeric and named
+references, is also supported. We could rewrite the above example in any of
+the following ways:
+.sp
+  (?<p1>(?i)rah)\es+\ek<p1>
+  (?'p1'(?i)rah)\es+\ek{p1}
+  (?P<p1>(?i)rah)\es+(?P=p1)
+  (?<p1>(?i)rah)\es+\eg{p1}
+.sp
+A subpattern that is referenced by name may appear in the pattern before or
+after the reference.
+.P
+There may be more than one back reference to the same subpattern. If a
+subpattern has not actually been used in a particular match, any back
+references to it always fail. For example, the pattern
+.sp
+  (a|(bc))\e2
+.sp
+always fails if it starts to match "a" rather than "bc". Because there may be
+many capturing parentheses in a pattern, all digits following the backslash are
+taken as part of a potential back reference number. If the pattern continues
+with a digit character, some delimiter must be used to terminate the back
+reference. If the PCRE_EXTENDED option is set, this can be whitespace.
+Otherwise an empty comment (see
+.\" HTML <a href="#comments">
+.\" </a>
+"Comments"
+.\"
+below) can be used.
+.P
+A back reference that occurs inside the parentheses to which it refers fails
+when the subpattern is first used, so, for example, (a\e1) never matches.
+However, such references can be useful inside repeated subpatterns. For
+example, the pattern
+.sp
+  (a|b\e1)+
+.sp
+matches any number of "a"s and also "aba", "ababbaa" etc. At each iteration of
+the subpattern, the back reference matches the character string corresponding
+to the previous iteration. In order for this to work, the pattern must be such
+that the first iteration does not need to match the back reference. This can be
+done using alternation, as in the example above, or by a quantifier with a
+minimum of zero.
+.
+.
+.\" HTML <a name="bigassertions"></a>
+.SH ASSERTIONS
+.rs
+.sp
+An assertion is a test on the characters following or preceding the current
+matching point that does not actually consume any characters. The simple
+assertions coded as \eb, \eB, \eA, \eG, \eZ, \ez, ^ and $ are described
+.\" HTML <a href="#smallassertions">
+.\" </a>
+above.
+.\"
+.P
+More complicated assertions are coded as subpatterns. There are two kinds:
+those that look ahead of the current position in the subject string, and those
+that look behind it. An assertion subpattern is matched in the normal way,
+except that it does not cause the current matching position to be changed.
+.P
+Assertion subpatterns are not capturing subpatterns, and may not be repeated,
+because it makes no sense to assert the same thing several times. If any kind
+of assertion contains capturing subpatterns within it, these are counted for
+the purposes of numbering the capturing subpatterns in the whole pattern.
+However, substring capturing is carried out only for positive assertions,
+because it does not make sense for negative assertions.
+.
+.
+.SS "Lookahead assertions"
+.rs
+.sp
+Lookahead assertions start with (?= for positive assertions and (?! for
+negative assertions. For example,
+.sp
+  \ew+(?=;)
+.sp
+matches a word followed by a semicolon, but does not include the semicolon in
+the match, and
+.sp
+  foo(?!bar)
+.sp
+matches any occurrence of "foo" that is not followed by "bar". Note that the
+apparently similar pattern
+.sp
+  (?!foo)bar
+.sp
+does not find an occurrence of "bar" that is preceded by something other than
+"foo"; it finds any occurrence of "bar" whatsoever, because the assertion
+(?!foo) is always true when the next three characters are "bar". A
+lookbehind assertion is needed to achieve the other effect.
+.P
+If you want to force a matching failure at some point in a pattern, the most
+convenient way to do it is with (?!) because an empty string always matches, so
+an assertion that requires there not to be an empty string must always fail.
+.
+.
+.\" HTML <a name="lookbehind"></a>
+.SS "Lookbehind assertions"
+.rs
+.sp
+Lookbehind assertions start with (?<= for positive assertions and (?<! for
+negative assertions. For example,
+.sp
+  (?<!foo)bar
+.sp
+does find an occurrence of "bar" that is not preceded by "foo". The contents of
+a lookbehind assertion are restricted such that all the strings it matches must
+have a fixed length. However, if there are several top-level alternatives, they
+do not all have to have the same fixed length. Thus
+.sp
+  (?<=bullock|donkey)
+.sp
+is permitted, but
+.sp
+  (?<!dogs?|cats?)
+.sp
+causes an error at compile time. Branches that match different length strings
+are permitted only at the top level of a lookbehind assertion. This is an
+extension compared with Perl (at least for 5.8), which requires all branches to
+match the same length of string. An assertion such as
+.sp
+  (?<=ab(c|de))
+.sp
+is not permitted, because its single top-level branch can match two different
+lengths, but it is acceptable if rewritten to use two top-level branches:
+.sp
+  (?<=abc|abde)
+.sp
+In some cases, the Perl 5.10 escape sequence \eK
+.\" HTML <a href="#resetmatchstart">
+.\" </a>
+(see above)
+.\"
+can be used instead of a lookbehind assertion; this is not restricted to a
+fixed-length.
+.P
+The implementation of lookbehind assertions is, for each alternative, to
+temporarily move the current position back by the fixed length and then try to
+match. If there are insufficient characters before the current position, the
+assertion fails.
+.P
+PCRE does not allow the \eC escape (which matches a single byte in UTF-8 mode)
+to appear in lookbehind assertions, because it makes it impossible to calculate
+the length of the lookbehind. The \eX and \eR escapes, which can match
+different numbers of bytes, are also not permitted.
+.P
+Possessive quantifiers can be used in conjunction with lookbehind assertions to
+specify efficient matching at the end of the subject string. Consider a simple
+pattern such as
+.sp
+  abcd$
+.sp
+when applied to a long string that does not match. Because matching proceeds
+from left to right, PCRE will look for each "a" in the subject and then see if
+what follows matches the rest of the pattern. If the pattern is specified as
+.sp
+  ^.*abcd$
+.sp
+the initial .* matches the entire string at first, but when this fails (because
+there is no following "a"), it backtracks to match all but the last character,
+then all but the last two characters, and so on. Once again the search for "a"
+covers the entire string, from right to left, so we are no better off. However,
+if the pattern is written as
+.sp
+  ^.*+(?<=abcd)
+.sp
+there can be no backtracking for the .*+ item; it can match only the entire
+string. The subsequent lookbehind assertion does a single test on the last four
+characters. If it fails, the match fails immediately. For long strings, this
+approach makes a significant difference to the processing time.
+.
+.
+.SS "Using multiple assertions"
+.rs
+.sp
+Several assertions (of any sort) may occur in succession. For example,
+.sp
+  (?<=\ed{3})(?<!999)foo
+.sp
+matches "foo" preceded by three digits that are not "999". Notice that each of
+the assertions is applied independently at the same point in the subject
+string. First there is a check that the previous three characters are all
+digits, and then there is a check that the same three characters are not "999".
+This pattern does \fInot\fP match "foo" preceded by six characters, the first
+of which are digits and the last three of which are not "999". For example, it
+doesn't match "123abcfoo". A pattern to do that is
+.sp
+  (?<=\ed{3}...)(?<!999)foo
+.sp
+This time the first assertion looks at the preceding six characters, checking
+that the first three are digits, and then the second assertion checks that the
+preceding three characters are not "999".
+.P
+Assertions can be nested in any combination. For example,
+.sp
+  (?<=(?<!foo)bar)baz
+.sp
+matches an occurrence of "baz" that is preceded by "bar" which in turn is not
+preceded by "foo", while
+.sp
+  (?<=\ed{3}(?!999)...)foo
+.sp
+is another pattern that matches "foo" preceded by three digits and any three
+characters that are not "999".
+.
+.
+.\" HTML <a name="conditions"></a>
+.SH "CONDITIONAL SUBPATTERNS"
+.rs
+.sp
+It is possible to cause the matching process to obey a subpattern
+conditionally or to choose between two alternative subpatterns, depending on
+the result of an assertion, or whether a previous capturing subpattern matched
+or not. The two possible forms of conditional subpattern are
+.sp
+  (?(condition)yes-pattern)
+  (?(condition)yes-pattern|no-pattern)
+.sp
+If the condition is satisfied, the yes-pattern is used; otherwise the
+no-pattern (if present) is used. If there are more than two alternatives in the
+subpattern, a compile-time error occurs.
+.P
+There are four kinds of condition: references to subpatterns, references to
+recursion, a pseudo-condition called DEFINE, and assertions.
+.
+.SS "Checking for a used subpattern by number"
+.rs
+.sp
+If the text between the parentheses consists of a sequence of digits, the
+condition is true if the capturing subpattern of that number has previously
+matched. An alternative notation is to precede the digits with a plus or minus
+sign. In this case, the subpattern number is relative rather than absolute.
+The most recently opened parentheses can be referenced by (?(-1), the next most
+recent by (?(-2), and so on. In looping constructs it can also make sense to
+refer to subsequent groups with constructs such as (?(+2).
+.P
+Consider the following pattern, which contains non-significant white space to
+make it more readable (assume the PCRE_EXTENDED option) and to divide it into
+three parts for ease of discussion:
+.sp
+  ( \e( )?    [^()]+    (?(1) \e) )
+.sp
+The first part matches an optional opening parenthesis, and if that
+character is present, sets it as the first captured substring. The second part
+matches one or more characters that are not parentheses. The third part is a
+conditional subpattern that tests whether the first set of parentheses matched
+or not. If they did, that is, if subject started with an opening parenthesis,
+the condition is true, and so the yes-pattern is executed and a closing
+parenthesis is required. Otherwise, since no-pattern is not present, the
+subpattern matches nothing. In other words, this pattern matches a sequence of
+non-parentheses, optionally enclosed in parentheses.
+.P
+If you were embedding this pattern in a larger one, you could use a relative
+reference:
+.sp
+  ...other stuff... ( \e( )?    [^()]+    (?(-1) \e) ) ...
+.sp
+This makes the fragment independent of the parentheses in the larger pattern.
+.
+.SS "Checking for a used subpattern by name"
+.rs
+.sp
+Perl uses the syntax (?(<name>)...) or (?('name')...) to test for a used
+subpattern by name. For compatibility with earlier versions of PCRE, which had
+this facility before Perl, the syntax (?(name)...) is also recognized. However,
+there is a possible ambiguity with this syntax, because subpattern names may
+consist entirely of digits. PCRE looks first for a named subpattern; if it
+cannot find one and the name consists entirely of digits, PCRE looks for a
+subpattern of that number, which must be greater than zero. Using subpattern
+names that consist entirely of digits is not recommended.
+.P
+Rewriting the above example to use a named subpattern gives this:
+.sp
+  (?<OPEN> \e( )?    [^()]+    (?(<OPEN>) \e) )
+.sp
+.
+.SS "Checking for pattern recursion"
+.rs
+.sp
+If the condition is the string (R), and there is no subpattern with the name R,
+the condition is true if a recursive call to the whole pattern or any
+subpattern has been made. If digits or a name preceded by ampersand follow the
+letter R, for example:
+.sp
+  (?(R3)...) or (?(R&name)...)
+.sp
+the condition is true if the most recent recursion is into the subpattern whose
+number or name is given. This condition does not check the entire recursion
+stack.
+.P
+At "top level", all these recursion test conditions are false. Recursive
+patterns are described below.
+.
+.SS "Defining subpatterns for use by reference only"
+.rs
+.sp
+If the condition is the string (DEFINE), and there is no subpattern with the
+name DEFINE, the condition is always false. In this case, there may be only one
+alternative in the subpattern. It is always skipped if control reaches this
+point in the pattern; the idea of DEFINE is that it can be used to define
+"subroutines" that can be referenced from elsewhere. (The use of "subroutines"
+is described below.) For example, a pattern to match an IPv4 address could be
+written like this (ignore whitespace and line breaks):
+.sp
+  (?(DEFINE) (?<byte> 2[0-4]\ed | 25[0-5] | 1\ed\ed | [1-9]?\ed) )
+  \eb (?&byte) (\e.(?&byte)){3} \eb
+.sp
+The first part of the pattern is a DEFINE group inside which a another group
+named "byte" is defined. This matches an individual component of an IPv4
+address (a number less than 256). When matching takes place, this part of the
+pattern is skipped because DEFINE acts like a false condition.
+.P
+The rest of the pattern uses references to the named group to match the four
+dot-separated components of an IPv4 address, insisting on a word boundary at
+each end.
+.
+.SS "Assertion conditions"
+.rs
+.sp
+If the condition is not in any of the above formats, it must be an assertion.
+This may be a positive or negative lookahead or lookbehind assertion. Consider
+this pattern, again containing non-significant white space, and with the two
+alternatives on the second line:
+.sp
+  (?(?=[^a-z]*[a-z])
+  \ed{2}-[a-z]{3}-\ed{2}  |  \ed{2}-\ed{2}-\ed{2} )
+.sp
+The condition is a positive lookahead assertion that matches an optional
+sequence of non-letters followed by a letter. In other words, it tests for the
+presence of at least one letter in the subject. If a letter is found, the
+subject is matched against the first alternative; otherwise it is matched
+against the second. This pattern matches strings in one of the two forms
+dd-aaa-dd or dd-dd-dd, where aaa are letters and dd are digits.
+.
+.
+.\" HTML <a name="comments"></a>
+.SH COMMENTS
+.rs
+.sp
+The sequence (?# marks the start of a comment that continues up to the next
+closing parenthesis. Nested parentheses are not permitted. The characters
+that make up a comment play no part in the pattern matching at all.
+.P
+If the PCRE_EXTENDED option is set, an unescaped # character outside a
+character class introduces a comment that continues to immediately after the
+next newline in the pattern.
+.
+.
+.\" HTML <a name="recursion"></a>
+.SH "RECURSIVE PATTERNS"
+.rs
+.sp
+Consider the problem of matching a string in parentheses, allowing for
+unlimited nested parentheses. Without the use of recursion, the best that can
+be done is to use a pattern that matches up to some fixed depth of nesting. It
+is not possible to handle an arbitrary nesting depth.
+.P
+For some time, Perl has provided a facility that allows regular expressions to
+recurse (amongst other things). It does this by interpolating Perl code in the
+expression at run time, and the code can refer to the expression itself. A Perl
+pattern using code interpolation to solve the parentheses problem can be
+created like this:
+.sp
+  $re = qr{\e( (?: (?>[^()]+) | (?p{$re}) )* \e)}x;
+.sp
+The (?p{...}) item interpolates Perl code at run time, and in this case refers
+recursively to the pattern in which it appears.
+.P
+Obviously, PCRE cannot support the interpolation of Perl code. Instead, it
+supports special syntax for recursion of the entire pattern, and also for
+individual subpattern recursion. After its introduction in PCRE and Python,
+this kind of recursion was introduced into Perl at release 5.10.
+.P
+A special item that consists of (? followed by a number greater than zero and a
+closing parenthesis is a recursive call of the subpattern of the given number,
+provided that it occurs inside that subpattern. (If not, it is a "subroutine"
+call, which is described in the next section.) The special item (?R) or (?0) is
+a recursive call of the entire regular expression.
+.P
+In PCRE (like Python, but unlike Perl), a recursive subpattern call is always
+treated as an atomic group. That is, once it has matched some of the subject
+string, it is never re-entered, even if it contains untried alternatives and
+there is a subsequent matching failure.
+.P
+This PCRE pattern solves the nested parentheses problem (assume the
+PCRE_EXTENDED option is set so that white space is ignored):
+.sp
+  \e( ( (?>[^()]+) | (?R) )* \e)
+.sp
+First it matches an opening parenthesis. Then it matches any number of
+substrings which can either be a sequence of non-parentheses, or a recursive
+match of the pattern itself (that is, a correctly parenthesized substring).
+Finally there is a closing parenthesis.
+.P
+If this were part of a larger pattern, you would not want to recurse the entire
+pattern, so instead you could use this:
+.sp
+  ( \e( ( (?>[^()]+) | (?1) )* \e) )
+.sp
+We have put the pattern into parentheses, and caused the recursion to refer to
+them instead of the whole pattern.
+.P
+In a larger pattern, keeping track of parenthesis numbers can be tricky. This
+is made easier by the use of relative references. (A Perl 5.10 feature.)
+Instead of (?1) in the pattern above you can write (?-2) to refer to the second
+most recently opened parentheses preceding the recursion. In other words, a
+negative number counts capturing parentheses leftwards from the point at which
+it is encountered.
+.P
+It is also possible to refer to subsequently opened parentheses, by writing
+references such as (?+2). However, these cannot be recursive because the
+reference is not inside the parentheses that are referenced. They are always
+"subroutine" calls, as described in the next section.
+.P
+An alternative approach is to use named parentheses instead. The Perl syntax
+for this is (?&name); PCRE's earlier syntax (?P>name) is also supported. We
+could rewrite the above example as follows:
+.sp
+  (?<pn> \e( ( (?>[^()]+) | (?&pn) )* \e) )
+.sp
+If there is more than one subpattern with the same name, the earliest one is
+used.
+.P
+This particular example pattern that we have been looking at contains nested
+unlimited repeats, and so the use of atomic grouping for matching strings of
+non-parentheses is important when applying the pattern to strings that do not
+match. For example, when this pattern is applied to
+.sp
+  (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
+.sp
+it yields "no match" quickly. However, if atomic grouping is not used,
+the match runs for a very long time indeed because there are so many different
+ways the + and * repeats can carve up the subject, and all have to be tested
+before failure can be reported.
+.P
+At the end of a match, the values set for any capturing subpatterns are those
+from the outermost level of the recursion at which the subpattern value is set.
+If you want to obtain intermediate values, a callout function can be used (see
+below and the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation). If the pattern above is matched against
+.sp
+  (ab(cd)ef)
+.sp
+the value for the capturing parentheses is "ef", which is the last value taken
+on at the top level. If additional parentheses are added, giving
+.sp
+  \e( ( ( (?>[^()]+) | (?R) )* ) \e)
+     ^                        ^
+     ^                        ^
+.sp
+the string they capture is "ab(cd)ef", the contents of the top level
+parentheses. If there are more than 15 capturing parentheses in a pattern, PCRE
+has to obtain extra memory to store data during a recursion, which it does by
+using \fBpcre_malloc\fP, freeing it via \fBpcre_free\fP afterwards. If no
+memory can be obtained, the match fails with the PCRE_ERROR_NOMEMORY error.
+.P
+Do not confuse the (?R) item with the condition (R), which tests for recursion.
+Consider this pattern, which matches text in angle brackets, allowing for
+arbitrary nesting. Only digits are allowed in nested brackets (that is, when
+recursing), whereas any characters are permitted at the outer level.
+.sp
+  < (?: (?(R) \ed++  | [^<>]*+) | (?R)) * >
+.sp
+In this pattern, (?(R) is the start of a conditional subpattern, with two
+different alternatives for the recursive and non-recursive cases. The (?R) item
+is the actual recursive call.
+.
+.
+.\" HTML <a name="subpatternsassubroutines"></a>
+.SH "SUBPATTERNS AS SUBROUTINES"
+.rs
+.sp
+If the syntax for a recursive subpattern reference (either by number or by
+name) is used outside the parentheses to which it refers, it operates like a
+subroutine in a programming language. The "called" subpattern may be defined
+before or after the reference. A numbered reference can be absolute or
+relative, as in these examples:
+.sp
+  (...(absolute)...)...(?2)...
+  (...(relative)...)...(?-1)...
+  (...(?+1)...(relative)...
+.sp
+An earlier example pointed out that the pattern
+.sp
+  (sens|respons)e and \e1ibility
+.sp
+matches "sense and sensibility" and "response and responsibility", but not
+"sense and responsibility". If instead the pattern
+.sp
+  (sens|respons)e and (?1)ibility
+.sp
+is used, it does match "sense and responsibility" as well as the other two
+strings. Another example is given in the discussion of DEFINE above.
+.P
+Like recursive subpatterns, a "subroutine" call is always treated as an atomic
+group. That is, once it has matched some of the subject string, it is never
+re-entered, even if it contains untried alternatives and there is a subsequent
+matching failure.
+.P
+When a subpattern is used as a subroutine, processing options such as
+case-independence are fixed when the subpattern is defined. They cannot be
+changed for different calls. For example, consider this pattern:
+.sp
+  (abc)(?i:(?-1))
+.sp
+It matches "abcabc". It does not match "abcABC" because the change of
+processing option does not affect the called subpattern.
+.
+.
+.\" HTML <a name="onigurumasubroutines"></a>
+.SH "ONIGURUMA SUBROUTINE SYNTAX"
+.rs
+.sp
+For compatibility with Oniguruma, the non-Perl syntax \eg followed by a name or
+a number enclosed either in angle brackets or single quotes, is an alternative
+syntax for referencing a subpattern as a subroutine, possibly recursively. Here
+are two of the examples used above, rewritten using this syntax:
+.sp
+  (?<pn> \e( ( (?>[^()]+) | \eg<pn> )* \e) )
+  (sens|respons)e and \eg'1'ibility
+.sp
+PCRE supports an extension to Oniguruma: if a number is preceded by a
+plus or a minus sign it is taken as a relative reference. For example:
+.sp
+  (abc)(?i:\eg<-1>)
+.sp
+Note that \eg{...} (Perl syntax) and \eg<...> (Oniguruma syntax) are \fInot\fP
+synonymous. The former is a back reference; the latter is a subroutine call.
+.
+.
+.SH CALLOUTS
+.rs
+.sp
+Perl has a feature whereby using the sequence (?{...}) causes arbitrary Perl
+code to be obeyed in the middle of matching a regular expression. This makes it
+possible, amongst other things, to extract different substrings that match the
+same pair of parentheses when there is a repetition.
+.P
+PCRE provides a similar feature, but of course it cannot obey arbitrary Perl
+code. The feature is called "callout". The caller of PCRE provides an external
+function by putting its entry point in the global variable \fIpcre_callout\fP.
+By default, this variable contains NULL, which disables all calling out.
+.P
+Within a regular expression, (?C) indicates the points at which the external
+function is to be called. If you want to identify different callout points, you
+can put a number less than 256 after the letter C. The default value is zero.
+For example, this pattern has two callout points:
+.sp
+  (?C1)abc(?C2)def
+.sp
+If the PCRE_AUTO_CALLOUT flag is passed to \fBpcre_compile()\fP, callouts are
+automatically installed before each item in the pattern. They are all numbered
+255.
+.P
+During matching, when PCRE reaches a callout point (and \fIpcre_callout\fP is
+set), the external function is called. It is provided with the number of the
+callout, the position in the pattern, and, optionally, one item of data
+originally supplied by the caller of \fBpcre_exec()\fP. The callout function
+may cause matching to proceed, to backtrack, or to fail altogether. A complete
+description of the interface to the callout function is given in the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation.
+.
+.
+.SH "BACKTRACKING CONTROL"
+.rs
+.sp
+Perl 5.10 introduced a number of "Special Backtracking Control Verbs", which
+are described in the Perl documentation as "experimental and subject to change
+or removal in a future version of Perl". It goes on to say: "Their usage in
+production code should be noted to avoid problems during upgrades." The same
+remarks apply to the PCRE features described in this section.
+.P
+Since these verbs are specifically related to backtracking, most of them can be
+used only when the pattern is to be matched using \fBpcre_exec()\fP, which uses
+a backtracking algorithm. With the exception of (*FAIL), which behaves like a
+failing negative assertion, they cause an error if encountered by
+\fBpcre_dfa_exec()\fP.
+.P
+The new verbs make use of what was previously invalid syntax: an opening
+parenthesis followed by an asterisk. In Perl, they are generally of the form
+(*VERB:ARG) but PCRE does not support the use of arguments, so its general
+form is just (*VERB). Any number of these verbs may occur in a pattern. There
+are two kinds:
+.
+.SS "Verbs that act immediately"
+.rs
+.sp
+The following verbs act as soon as they are encountered:
+.sp
+   (*ACCEPT)
+.sp
+This verb causes the match to end successfully, skipping the remainder of the
+pattern. When inside a recursion, only the innermost pattern is ended
+immediately. PCRE differs from Perl in what happens if the (*ACCEPT) is inside
+capturing parentheses. In Perl, the data so far is captured: in PCRE no data is
+captured. For example:
+.sp
+  A(A|B(*ACCEPT)|C)D
+.sp
+This matches "AB", "AAD", or "ACD", but when it matches "AB", no data is
+captured.
+.sp
+  (*FAIL) or (*F)
+.sp
+This verb causes the match to fail, forcing backtracking to occur. It is
+equivalent to (?!) but easier to read. The Perl documentation notes that it is
+probably useful only when combined with (?{}) or (??{}). Those are, of course,
+Perl features that are not present in PCRE. The nearest equivalent is the
+callout feature, as for example in this pattern:
+.sp
+  a+(?C)(*FAIL)
+.sp
+A match with the string "aaaa" always fails, but the callout is taken before
+each backtrack happens (in this example, 10 times).
+.
+.SS "Verbs that act after backtracking"
+.rs
+.sp
+The following verbs do nothing when they are encountered. Matching continues
+with what follows, but if there is no subsequent match, a failure is forced.
+The verbs differ in exactly what kind of failure occurs.
+.sp
+  (*COMMIT)
+.sp
+This verb causes the whole match to fail outright if the rest of the pattern
+does not match. Even if the pattern is unanchored, no further attempts to find
+a match by advancing the start point take place. Once (*COMMIT) has been
+passed, \fBpcre_exec()\fP is committed to finding a match at the current
+starting point, or not at all. For example:
+.sp
+  a+(*COMMIT)b
+.sp
+This matches "xxaab" but not "aacaab". It can be thought of as a kind of
+dynamic anchor, or "I've started, so I must finish."
+.sp
+  (*PRUNE)
+.sp
+This verb causes the match to fail at the current position if the rest of the
+pattern does not match. If the pattern is unanchored, the normal "bumpalong"
+advance to the next starting character then happens. Backtracking can occur as
+usual to the left of (*PRUNE), or when matching to the right of (*PRUNE), but
+if there is no match to the right, backtracking cannot cross (*PRUNE).
+In simple cases, the use of (*PRUNE) is just an alternative to an atomic
+group or possessive quantifier, but there are some uses of (*PRUNE) that cannot
+be expressed in any other way.
+.sp
+  (*SKIP)
+.sp
+This verb is like (*PRUNE), except that if the pattern is unanchored, the
+"bumpalong" advance is not to the next character, but to the position in the
+subject where (*SKIP) was encountered. (*SKIP) signifies that whatever text
+was matched leading up to it cannot be part of a successful match. Consider:
+.sp
+  a+(*SKIP)b
+.sp
+If the subject is "aaaac...", after the first match attempt fails (starting at
+the first character in the string), the starting point skips on to start the
+next attempt at "c". Note that a possessive quantifer does not have the same
+effect in this example; although it would suppress backtracking during the
+first match attempt, the second attempt would start at the second character
+instead of skipping on to "c".
+.sp
+  (*THEN)
+.sp
+This verb causes a skip to the next alternation if the rest of the pattern does
+not match. That is, it cancels pending backtracking, but only within the
+current alternation. Its name comes from the observation that it can be used
+for a pattern-based if-then-else block:
+.sp
+  ( COND1 (*THEN) FOO | COND2 (*THEN) BAR | COND3 (*THEN) BAZ ) ...
+.sp
+If the COND1 pattern matches, FOO is tried (and possibly further items after
+the end of the group if FOO succeeds); on failure the matcher skips to the
+second alternative and tries COND2, without backtracking into COND1. If (*THEN)
+is used outside of any alternation, it acts exactly like (*PRUNE).
+.
+.
+.SH "SEE ALSO"
+.rs
+.sp
+\fBpcreapi\fP(3), \fBpcrecallout\fP(3), \fBpcrematching\fP(3), \fBpcre\fP(3).
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 19 April 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcreperform.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,153 @@
+.TH PCREPERFORM 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE PERFORMANCE"
+.rs
+.sp
+Two aspects of performance are discussed below: memory usage and processing
+time. The way you express your pattern as a regular expression can affect both
+of them.
+.
+.SH "MEMORY USAGE"
+.rs
+.sp
+Patterns are compiled by PCRE into a reasonably efficient byte code, so that
+most simple patterns do not use much memory. However, there is one case where
+memory usage can be unexpectedly large. When a parenthesized subpattern has a
+quantifier with a minimum greater than 1 and/or a limited maximum, the whole
+subpattern is repeated in the compiled code. For example, the pattern
+.sp
+  (abc|def){2,4}
+.sp
+is compiled as if it were
+.sp
+  (abc|def)(abc|def)((abc|def)(abc|def)?)?
+.sp
+(Technical aside: It is done this way so that backtrack points within each of
+the repetitions can be independently maintained.)
+.P
+For regular expressions whose quantifiers use only small numbers, this is not
+usually a problem. However, if the numbers are large, and particularly if such
+repetitions are nested, the memory usage can become an embarrassment. For
+example, the very simple pattern
+.sp
+  ((ab){1,1000}c){1,3}
+.sp
+uses 51K bytes when compiled. When PCRE is compiled with its default internal
+pointer size of two bytes, the size limit on a compiled pattern is 64K, and
+this is reached with the above pattern if the outer repetition is increased
+from 3 to 4. PCRE can be compiled to use larger internal pointers and thus
+handle larger compiled patterns, but it is better to try to rewrite your
+pattern to use less memory if you can.
+.P
+One way of reducing the memory usage for such patterns is to make use of PCRE's
+.\" HTML <a href="pcrepattern.html#subpatternsassubroutines">
+.\" </a>
+"subroutine"
+.\"
+facility. Re-writing the above pattern as
+.sp
+  ((ab)(?2){0,999}c)(?1){0,2}
+.sp
+reduces the memory requirements to 18K, and indeed it remains under 20K even
+with the outer repetition increased to 100. However, this pattern is not
+exactly equivalent, because the "subroutine" calls are treated as
+.\" HTML <a href="pcrepattern.html#atomicgroup">
+.\" </a>
+atomic groups
+.\"
+into which there can be no backtracking if there is a subsequent matching
+failure. Therefore, PCRE cannot do this kind of rewriting automatically.
+Furthermore, there is a noticeable loss of speed when executing the modified
+pattern. Nevertheless, if the atomic grouping is not a problem and the loss of
+speed is acceptable, this kind of rewriting will allow you to process patterns
+that PCRE cannot otherwise handle.
+.
+.SH "PROCESSING TIME"
+.rs
+.sp
+Certain items in regular expression patterns are processed more efficiently
+than others. It is more efficient to use a character class like [aeiou] than a
+set of single-character alternatives such as (a|e|i|o|u). In general, the
+simplest construction that provides the required behaviour is usually the most
+efficient. Jeffrey Friedl's book contains a lot of useful general discussion
+about optimizing regular expressions for efficient performance. This document
+contains a few observations about PCRE.
+.P
+Using Unicode character properties (the \ep, \eP, and \eX escapes) is slow,
+because PCRE has to scan a structure that contains data for over fifteen
+thousand characters whenever it needs a character's property. If you can find
+an alternative pattern that does not use character properties, it will probably
+be faster.
+.P
+When a pattern begins with .* not in parentheses, or in parentheses that are
+not the subject of a backreference, and the PCRE_DOTALL option is set, the
+pattern is implicitly anchored by PCRE, since it can match only at the start of
+a subject string. However, if PCRE_DOTALL is not set, PCRE cannot make this
+optimization, because the . metacharacter does not then match a newline, and if
+the subject string contains newlines, the pattern may match from the character
+immediately following one of them instead of from the very start. For example,
+the pattern
+.sp
+  .*second
+.sp
+matches the subject "first\enand second" (where \en stands for a newline
+character), with the match starting at the seventh character. In order to do
+this, PCRE has to retry the match starting after every newline in the subject.
+.P
+If you are using such a pattern with subject strings that do not contain
+newlines, the best performance is obtained by setting PCRE_DOTALL, or starting
+the pattern with ^.* or ^.*? to indicate explicit anchoring. That saves PCRE
+from having to scan along the subject looking for a newline to restart at.
+.P
+Beware of patterns that contain nested indefinite repeats. These can take a
+long time to run when applied to a string that does not match. Consider the
+pattern fragment
+.sp
+  ^(a+)*
+.sp
+This can match "aaaa" in 16 different ways, and this number increases very
+rapidly as the string gets longer. (The * repeat can match 0, 1, 2, 3, or 4
+times, and for each of those cases other than 0 or 4, the + repeats can match
+different numbers of times.) When the remainder of the pattern is such that the
+entire match is going to fail, PCRE has in principle to try every possible
+variation, and this can take an extremely long time, even for relatively short
+strings.
+.P
+An optimization catches some of the more simple cases such as
+.sp
+  (a+)*b
+.sp
+where a literal character follows. Before embarking on the standard matching
+procedure, PCRE checks that there is a "b" later in the subject string, and if
+there is not, it fails the match immediately. However, when there is no
+following literal this optimization cannot be used. You can see the difference
+by comparing the behaviour of
+.sp
+  (a+)*\ed
+.sp
+with the pattern above. The former gives a failure almost instantly when
+applied to a whole line of "a" characters, whereas the latter takes an
+appreciable time with strings longer than about 20 characters.
+.P
+In many cases, the solution to this kind of performance issue is to use an
+atomic group or a possessive quantifier.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 06 March 2007
+Copyright (c) 1997-2007 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcreposix.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,238 @@
+.TH PCREPOSIX 3
+.SH NAME
+PCRE - Perl-compatible regular expressions.
+.SH "SYNOPSIS OF POSIX API"
+.rs
+.sp
+.B #include <pcreposix.h>
+.PP
+.SM
+.B int regcomp(regex_t *\fIpreg\fP, const char *\fIpattern\fP,
+.ti +5n
+.B int \fIcflags\fP);
+.PP
+.B int regexec(regex_t *\fIpreg\fP, const char *\fIstring\fP,
+.ti +5n
+.B size_t \fInmatch\fP, regmatch_t \fIpmatch\fP[], int \fIeflags\fP);
+.PP
+.B size_t regerror(int \fIerrcode\fP, const regex_t *\fIpreg\fP,
+.ti +5n
+.B char *\fIerrbuf\fP, size_t \fIerrbuf_size\fP);
+.PP
+.B void regfree(regex_t *\fIpreg\fP);
+.
+.SH DESCRIPTION
+.rs
+.sp
+This set of functions provides a POSIX-style API to the PCRE regular expression
+package. See the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation for a description of PCRE's native API, which contains much
+additional functionality.
+.P
+The functions described here are just wrapper functions that ultimately call
+the PCRE native API. Their prototypes are defined in the \fBpcreposix.h\fP
+header file, and on Unix systems the library itself is called
+\fBpcreposix.a\fP, so can be accessed by adding \fB-lpcreposix\fP to the
+command for linking an application that uses them. Because the POSIX functions
+call the native ones, it is also necessary to add \fB-lpcre\fP.
+.P
+I have implemented only those option bits that can be reasonably mapped to PCRE
+native options. In addition, the option REG_EXTENDED is defined with the value
+zero. This has no effect, but since programs that are written to the POSIX
+interface often use it, this makes it easier to slot in PCRE as a replacement
+library. Other POSIX options are not even defined.
+.P
+When PCRE is called via these functions, it is only the API that is POSIX-like
+in style. The syntax and semantics of the regular expressions themselves are
+still those of Perl, subject to the setting of various PCRE options, as
+described below. "POSIX-like in style" means that the API approximates to the
+POSIX definition; it is not fully POSIX-compatible, and in multi-byte encoding
+domains it is probably even less compatible.
+.P
+The header for these functions is supplied as \fBpcreposix.h\fP to avoid any
+potential clash with other POSIX libraries. It can, of course, be renamed or
+aliased as \fBregex.h\fP, which is the "correct" name. It provides two
+structure types, \fIregex_t\fP for compiled internal forms, and
+\fIregmatch_t\fP for returning captured substrings. It also defines some
+constants whose names start with "REG_"; these are used for setting options and
+identifying error codes.
+.P
+.SH "COMPILING A PATTERN"
+.rs
+.sp
+The function \fBregcomp()\fP is called to compile a pattern into an
+internal form. The pattern is a C string terminated by a binary zero, and
+is passed in the argument \fIpattern\fP. The \fIpreg\fP argument is a pointer
+to a \fBregex_t\fP structure that is used as a base for storing information
+about the compiled regular expression.
+.P
+The argument \fIcflags\fP is either zero, or contains one or more of the bits
+defined by the following macros:
+.sp
+  REG_DOTALL
+.sp
+The PCRE_DOTALL option is set when the regular expression is passed for
+compilation to the native function. Note that REG_DOTALL is not part of the
+POSIX standard.
+.sp
+  REG_ICASE
+.sp
+The PCRE_CASELESS option is set when the regular expression is passed for
+compilation to the native function.
+.sp
+  REG_NEWLINE
+.sp
+The PCRE_MULTILINE option is set when the regular expression is passed for
+compilation to the native function. Note that this does \fInot\fP mimic the
+defined POSIX behaviour for REG_NEWLINE (see the following section).
+.sp
+  REG_NOSUB
+.sp
+The PCRE_NO_AUTO_CAPTURE option is set when the regular expression is passed
+for compilation to the native function. In addition, when a pattern that is
+compiled with this flag is passed to \fBregexec()\fP for matching, the
+\fInmatch\fP and \fIpmatch\fP arguments are ignored, and no captured strings
+are returned.
+.sp
+  REG_UTF8
+.sp
+The PCRE_UTF8 option is set when the regular expression is passed for
+compilation to the native function. This causes the pattern itself and all data
+strings used for matching it to be treated as UTF-8 strings. Note that REG_UTF8
+is not part of the POSIX standard.
+.P
+In the absence of these flags, no options are passed to the native function.
+This means the the regex is compiled with PCRE default semantics. In
+particular, the way it handles newline characters in the subject string is the
+Perl way, not the POSIX way. Note that setting PCRE_MULTILINE has only
+\fIsome\fP of the effects specified for REG_NEWLINE. It does not affect the way
+newlines are matched by . (they aren't) or by a negative class such as [^a]
+(they are).
+.P
+The yield of \fBregcomp()\fP is zero on success, and non-zero otherwise. The
+\fIpreg\fP structure is filled in on success, and one member of the structure
+is public: \fIre_nsub\fP contains the number of capturing subpatterns in
+the regular expression. Various error codes are defined in the header file.
+.
+.
+.SH "MATCHING NEWLINE CHARACTERS"
+.rs
+.sp
+This area is not simple, because POSIX and Perl take different views of things.
+It is not possible to get PCRE to obey POSIX semantics, but then PCRE was never
+intended to be a POSIX engine. The following table lists the different
+possibilities for matching newline characters in PCRE:
+.sp
+                          Default   Change with
+.sp
+  . matches newline          no     PCRE_DOTALL
+  newline matches [^a]       yes    not changeable
+  $ matches \en at end        yes    PCRE_DOLLARENDONLY
+  $ matches \en in middle     no     PCRE_MULTILINE
+  ^ matches \en in middle     no     PCRE_MULTILINE
+.sp
+This is the equivalent table for POSIX:
+.sp
+                          Default   Change with
+.sp
+  . matches newline          yes    REG_NEWLINE
+  newline matches [^a]       yes    REG_NEWLINE
+  $ matches \en at end        no     REG_NEWLINE
+  $ matches \en in middle     no     REG_NEWLINE
+  ^ matches \en in middle     no     REG_NEWLINE
+.sp
+PCRE's behaviour is the same as Perl's, except that there is no equivalent for
+PCRE_DOLLAR_ENDONLY in Perl. In both PCRE and Perl, there is no way to stop
+newline from matching [^a].
+.P
+The default POSIX newline handling can be obtained by setting PCRE_DOTALL and
+PCRE_DOLLAR_ENDONLY, but there is no way to make PCRE behave exactly as for the
+REG_NEWLINE action.
+.
+.
+.SH "MATCHING A PATTERN"
+.rs
+.sp
+The function \fBregexec()\fP is called to match a compiled pattern \fIpreg\fP
+against a given \fIstring\fP, which is by default terminated by a zero byte
+(but see REG_STARTEND below), subject to the options in \fIeflags\fP. These can
+be:
+.sp
+  REG_NOTBOL
+.sp
+The PCRE_NOTBOL option is set when calling the underlying PCRE matching
+function.
+.sp
+  REG_NOTEOL
+.sp
+The PCRE_NOTEOL option is set when calling the underlying PCRE matching
+function.
+.sp
+  REG_STARTEND
+.sp
+The string is considered to start at \fIstring\fP + \fIpmatch[0].rm_so\fP and
+to have a terminating NUL located at \fIstring\fP + \fIpmatch[0].rm_eo\fP
+(there need not actually be a NUL at that location), regardless of the value of
+\fInmatch\fP. This is a BSD extension, compatible with but not specified by
+IEEE Standard 1003.2 (POSIX.2), and should be used with caution in software
+intended to be portable to other systems. Note that a non-zero \fIrm_so\fP does
+not imply REG_NOTBOL; REG_STARTEND affects only the location of the string, not
+how it is matched.
+.P
+If the pattern was compiled with the REG_NOSUB flag, no data about any matched
+strings is returned. The \fInmatch\fP and \fIpmatch\fP arguments of
+\fBregexec()\fP are ignored.
+.P
+Otherwise,the portion of the string that was matched, and also any captured
+substrings, are returned via the \fIpmatch\fP argument, which points to an
+array of \fInmatch\fP structures of type \fIregmatch_t\fP, containing the
+members \fIrm_so\fP and \fIrm_eo\fP. These contain the offset to the first
+character of each substring and the offset to the first character after the end
+of each substring, respectively. The 0th element of the vector relates to the
+entire portion of \fIstring\fP that was matched; subsequent elements relate to
+the capturing subpatterns of the regular expression. Unused entries in the
+array have both structure members set to -1.
+.P
+A successful match yields a zero return; various error codes are defined in the
+header file, of which REG_NOMATCH is the "expected" failure code.
+.
+.
+.SH "ERROR MESSAGES"
+.rs
+.sp
+The \fBregerror()\fP function maps a non-zero errorcode from either
+\fBregcomp()\fP or \fBregexec()\fP to a printable message. If \fIpreg\fP is not
+NULL, the error should have arisen from the use of that structure. A message
+terminated by a binary zero is placed in \fIerrbuf\fP. The length of the
+message, including the zero, is limited to \fIerrbuf_size\fP. The yield of the
+function is the size of buffer needed to hold the whole message.
+.
+.
+.SH MEMORY USAGE
+.rs
+.sp
+Compiling a regular expression causes memory to be allocated and associated
+with the \fIpreg\fP structure. The function \fBregfree()\fP frees all such
+memory, after which \fIpreg\fP may no longer be used as a compiled expression.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 05 April 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcreprecompile.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,142 @@
+.TH PCREPRECOMPILE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "SAVING AND RE-USING PRECOMPILED PCRE PATTERNS"
+.rs
+.sp
+If you are running an application that uses a large number of regular
+expression patterns, it may be useful to store them in a precompiled form
+instead of having to compile them every time the application is run.
+If you are not using any private character tables (see the
+.\" HREF
+\fBpcre_maketables()\fP
+.\"
+documentation), this is relatively straightforward. If you are using private
+tables, it is a little bit more complicated.
+.P
+If you save compiled patterns to a file, you can copy them to a different host
+and run them there. This works even if the new host has the opposite endianness
+to the one on which the patterns were compiled. There may be a small
+performance penalty, but it should be insignificant. However, compiling regular
+expressions with one version of PCRE for use with a different version is not
+guaranteed to work and may cause crashes.
+.
+.
+.SH "SAVING A COMPILED PATTERN"
+.rs
+.sh
+The value returned by \fBpcre_compile()\fP points to a single block of memory
+that holds the compiled pattern and associated data. You can find the length of
+this block in bytes by calling \fBpcre_fullinfo()\fP with an argument of
+PCRE_INFO_SIZE. You can then save the data in any appropriate manner. Here is
+sample code that compiles a pattern and writes it to a file. It assumes that
+the variable \fIfd\fP refers to a file that is open for output:
+.sp
+  int erroroffset, rc, size;
+  char *error;
+  pcre *re;
+.sp
+  re = pcre_compile("my pattern", 0, &error, &erroroffset, NULL);
+  if (re == NULL) { ... handle errors ... }
+  rc = pcre_fullinfo(re, NULL, PCRE_INFO_SIZE, &size);
+  if (rc < 0) { ... handle errors ... }
+  rc = fwrite(re, 1, size, fd);
+  if (rc != size) { ... handle errors ... }
+.sp
+In this example, the bytes that comprise the compiled pattern are copied
+exactly. Note that this is binary data that may contain any of the 256 possible
+byte values. On systems that make a distinction between binary and non-binary
+data, be sure that the file is opened for binary output.
+.P
+If you want to write more than one pattern to a file, you will have to devise a
+way of separating them. For binary data, preceding each pattern with its length
+is probably the most straightforward approach. Another possibility is to write
+out the data in hexadecimal instead of binary, one pattern to a line.
+.P
+Saving compiled patterns in a file is only one possible way of storing them for
+later use. They could equally well be saved in a database, or in the memory of
+some daemon process that passes them via sockets to the processes that want
+them.
+.P
+If the pattern has been studied, it is also possible to save the study data in
+a similar way to the compiled pattern itself. When studying generates
+additional information, \fBpcre_study()\fP returns a pointer to a
+\fBpcre_extra\fP data block. Its format is defined in the
+.\" HTML <a href="pcreapi.html#extradata">
+.\" </a>
+section on matching a pattern
+.\"
+in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation. The \fIstudy_data\fP field points to the binary study data, and
+this is what you must save (not the \fBpcre_extra\fP block itself). The length
+of the study data can be obtained by calling \fBpcre_fullinfo()\fP with an
+argument of PCRE_INFO_STUDYSIZE. Remember to check that \fBpcre_study()\fP did
+return a non-NULL value before trying to save the study data.
+.
+.
+.SH "RE-USING A PRECOMPILED PATTERN"
+.rs
+.sp
+Re-using a precompiled pattern is straightforward. Having reloaded it into main
+memory, you pass its pointer to \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP in
+the usual way. This should work even on another host, and even if that host has
+the opposite endianness to the one where the pattern was compiled.
+.P
+However, if you passed a pointer to custom character tables when the pattern
+was compiled (the \fItableptr\fP argument of \fBpcre_compile()\fP), you must
+now pass a similar pointer to \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP,
+because the value saved with the compiled pattern will obviously be nonsense. A
+field in a \fBpcre_extra()\fP block is used to pass this data, as described in
+the
+.\" HTML <a href="pcreapi.html#extradata">
+.\" </a>
+section on matching a pattern
+.\"
+in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation.
+.P
+If you did not provide custom character tables when the pattern was compiled,
+the pointer in the compiled pattern is NULL, which causes \fBpcre_exec()\fP to
+use PCRE's internal tables. Thus, you do not need to take any special action at
+run time in this case.
+.P
+If you saved study data with the compiled pattern, you need to create your own
+\fBpcre_extra\fP data block and set the \fIstudy_data\fP field to point to the
+reloaded study data. You must also set the PCRE_EXTRA_STUDY_DATA bit in the
+\fIflags\fP field to indicate that study data is present. Then pass the
+\fBpcre_extra\fP block to \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP in the
+usual way.
+.
+.
+.SH "COMPATIBILITY WITH DIFFERENT PCRE RELEASES"
+.rs
+.sp
+In general, it is safest to recompile all saved patterns when you update to a
+new PCRE release, though not all updates actually require this. Recompiling is
+definitely needed for release 7.2.
+.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 13 June 2007
+Copyright (c) 1997-2007 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcresample.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,80 @@
+.TH PCRESAMPLE 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE SAMPLE PROGRAM"
+.rs
+.sp
+A simple, complete demonstration program, to get you started with using PCRE,
+is supplied in the file \fIpcredemo.c\fP in the PCRE distribution.
+.P
+The program compiles the regular expression that is its first argument, and
+matches it against the subject string in its second argument. No PCRE options
+are set, and default character tables are used. If matching succeeds, the
+program outputs the portion of the subject that matched, together with the
+contents of any captured substrings.
+.P
+If the -g option is given on the command line, the program then goes on to
+check for further matches of the same regular expression in the same subject
+string. The logic is a little bit tricky because of the possibility of matching
+an empty string. Comments in the code explain what is going on.
+.P
+If PCRE is installed in the standard include and library directories for your
+system, you should be able to compile the demonstration program using this
+command:
+.sp
+  gcc -o pcredemo pcredemo.c -lpcre
+.sp
+If PCRE is installed elsewhere, you may need to add additional options to the
+command line. For example, on a Unix-like system that has PCRE installed in
+\fI/usr/local\fP, you can compile the demonstration program using a command
+like this:
+.sp
+.\" JOINSH
+  gcc -o pcredemo -I/usr/local/include pcredemo.c \e
+      -L/usr/local/lib -lpcre
+.sp
+Once you have compiled the demonstration program, you can run simple tests like
+this:
+.sp
+  ./pcredemo 'cat|dog' 'the cat sat on the mat'
+  ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
+.sp
+Note that there is a much more comprehensive test program, called
+.\" HREF
+\fBpcretest\fP,
+.\"
+which supports many more facilities for testing regular expressions and the
+PCRE library. The \fBpcredemo\fP program is provided as a simple coding
+example.
+.P
+On some operating systems (e.g. Solaris), when PCRE is not installed in the
+standard library directory, you may get an error like this when you try to run
+\fBpcredemo\fP:
+.sp
+  ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
+.sp
+This is caused by the way shared library support works on those systems. You
+need to add
+.sp
+  -R/usr/local/lib
+.sp
+(for example) to the compile command to get round this problem.
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 23 January 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcrestack.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,160 @@
+.TH PCRESTACK 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE DISCUSSION OF STACK USAGE"
+.rs
+.sp
+When you call \fBpcre_exec()\fP, it makes use of an internal function called
+\fBmatch()\fP. This calls itself recursively at branch points in the pattern,
+in order to remember the state of the match so that it can back up and try a
+different alternative if the first one fails. As matching proceeds deeper and
+deeper into the tree of possibilities, the recursion depth increases.
+.P
+Not all calls of \fBmatch()\fP increase the recursion depth; for an item such
+as a* it may be called several times at the same level, after matching
+different numbers of a's. Furthermore, in a number of cases where the result of
+the recursive call would immediately be passed back as the result of the
+current call (a "tail recursion"), the function is just restarted instead.
+.P
+The \fBpcre_dfa_exec()\fP function operates in an entirely different way, and
+hardly uses recursion at all. The limit on its complexity is the amount of
+workspace it is given. The comments that follow do NOT apply to
+\fBpcre_dfa_exec()\fP; they are relevant only for \fBpcre_exec()\fP.
+.P
+You can set limits on the number of times that \fBmatch()\fP is called, both in
+total and recursively. If the limit is exceeded, an error occurs. For details,
+see the
+.\" HTML <a href="pcreapi.html#extradata">
+.\" </a>
+section on extra data for \fBpcre_exec()\fP
+.\"
+in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation.
+.P
+Each time that \fBmatch()\fP is actually called recursively, it uses memory
+from the process stack. For certain kinds of pattern and data, very large
+amounts of stack may be needed, despite the recognition of "tail recursion".
+You can often reduce the amount of recursion, and therefore the amount of stack
+used, by modifying the pattern that is being matched. Consider, for example,
+this pattern:
+.sp
+  ([^<]|<(?!inet))+
+.sp
+It matches from wherever it starts until it encounters "<inet" or the end of
+the data, and is the kind of pattern that might be used when processing an XML
+file. Each iteration of the outer parentheses matches either one character that
+is not "<" or a "<" that is not followed by "inet". However, each time a
+parenthesis is processed, a recursion occurs, so this formulation uses a stack
+frame for each matched character. For a long string, a lot of stack is
+required. Consider now this rewritten pattern, which matches exactly the same
+strings:
+.sp
+  ([^<]++|<(?!inet))+
+.sp
+This uses very much less stack, because runs of characters that do not contain
+"<" are "swallowed" in one item inside the parentheses. Recursion happens only
+when a "<" character that is not followed by "inet" is encountered (and we
+assume this is relatively rare). A possessive quantifier is used to stop any
+backtracking into the runs of non-"<" characters, but that is not related to
+stack usage.
+.P
+This example shows that one way of avoiding stack problems when matching long
+subject strings is to write repeated parenthesized subpatterns to match more
+than one character whenever possible.
+.
+.SS "Compiling PCRE to use heap instead of stack"
+.rs
+.sp
+In environments where stack memory is constrained, you might want to compile
+PCRE to use heap memory instead of stack for remembering back-up points. This
+makes it run a lot more slowly, however. Details of how to do this are given in
+the
+.\" HREF
+\fBpcrebuild\fP
+.\"
+documentation. When built in this way, instead of using the stack, PCRE obtains
+and frees memory by calling the functions that are pointed to by the
+\fBpcre_stack_malloc\fP and \fBpcre_stack_free\fP variables. By default, these
+point to \fBmalloc()\fP and \fBfree()\fP, but you can replace the pointers to
+cause PCRE to use your own functions. Since the block sizes are always the
+same, and are always freed in reverse order, it may be possible to implement
+customized memory handlers that are more efficient than the standard functions.
+.
+.SS "Limiting PCRE's stack usage"
+.rs
+.sp
+PCRE has an internal counter that can be used to limit the depth of recursion,
+and thus cause \fBpcre_exec()\fP to give an error code before it runs out of
+stack. By default, the limit is very large, and unlikely ever to operate. It
+can be changed when PCRE is built, and it can also be set when
+\fBpcre_exec()\fP is called. For details of these interfaces, see the
+.\" HREF
+\fBpcrebuild\fP
+.\"
+and
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation.
+.P
+As a very rough rule of thumb, you should reckon on about 500 bytes per
+recursion. Thus, if you want to limit your stack usage to 8Mb, you
+should set the limit at 16000 recursions. A 64Mb stack, on the other hand, can
+support around 128000 recursions. The \fBpcretest\fP test program has a command
+line option (\fB-S\fP) that can be used to increase the size of its stack.
+.
+.SS "Changing stack size in Unix-like systems"
+.rs
+.sp
+In Unix-like environments, there is not often a problem with the stack unless
+very long strings are involved, though the default limit on stack size varies
+from system to system. Values from 8Mb to 64Mb are common. You can find your
+default limit by running the command:
+.sp
+  ulimit -s
+.sp
+Unfortunately, the effect of running out of stack is often SIGSEGV, though
+sometimes a more explicit error message is given. You can normally increase the
+limit on stack size by code such as this:
+.sp
+  struct rlimit rlim;
+  getrlimit(RLIMIT_STACK, &rlim);
+  rlim.rlim_cur = 100*1024*1024;
+  setrlimit(RLIMIT_STACK, &rlim);
+.sp
+This reads the current limits (soft and hard) using \fBgetrlimit()\fP, then
+attempts to increase the soft limit to 100Mb using \fBsetrlimit()\fP. You must
+do this before calling \fBpcre_exec()\fP.
+.
+.SS "Changing stack size in Mac OS X"
+.rs
+.sp
+Using \fBsetrlimit()\fP, as described above, should also work on Mac OS X. It
+is also possible to set a stack size when linking a program. There is a
+discussion about stack sizes in Mac OS X at this web site:
+.\" HTML <a href="http://developer.apple.com/qa/qa2005/qa1419.html">
+.\" </a>
+http://developer.apple.com/qa/qa2005/qa1419.html.
+.\"
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 09 July 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcresyntax.3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,433 @@
+.TH PCRESYNTAX 3
+.SH NAME
+PCRE - Perl-compatible regular expressions
+.SH "PCRE REGULAR EXPRESSION SYNTAX SUMMARY"
+.rs
+.sp
+The full syntax and semantics of the regular expressions that are supported by
+PCRE are described in the
+.\" HREF
+\fBpcrepattern\fP
+.\"
+documentation. This document contains just a quick-reference summary of the
+syntax.
+.
+.
+.SH "QUOTING"
+.rs
+.sp
+  \ex         where x is non-alphanumeric is a literal x
+  \eQ...\eE    treat enclosed characters as literal
+.
+.
+.SH "CHARACTERS"
+.rs
+.sp
+  \ea         alarm, that is, the BEL character (hex 07)
+  \ecx        "control-x", where x is any character
+  \ee         escape (hex 1B)
+  \ef         formfeed (hex 0C)
+  \en         newline (hex 0A)
+  \er         carriage return (hex 0D)
+  \et         tab (hex 09)
+  \eddd       character with octal code ddd, or backreference
+  \exhh       character with hex code hh
+  \ex{hhh..}  character with hex code hhh..
+.
+.
+.SH "CHARACTER TYPES"
+.rs
+.sp
+  .          any character except newline;
+               in dotall mode, any character whatsoever
+  \eC         one byte, even in UTF-8 mode (best avoided)
+  \ed         a decimal digit
+  \eD         a character that is not a decimal digit
+  \eh         a horizontal whitespace character
+  \eH         a character that is not a horizontal whitespace character
+  \ep{\fIxx\fP}     a character with the \fIxx\fP property
+  \eP{\fIxx\fP}     a character without the \fIxx\fP property
+  \eR         a newline sequence
+  \es         a whitespace character
+  \eS         a character that is not a whitespace character
+  \ev         a vertical whitespace character
+  \eV         a character that is not a vertical whitespace character
+  \ew         a "word" character
+  \eW         a "non-word" character
+  \eX         an extended Unicode sequence
+.sp
+In PCRE, \ed, \eD, \es, \eS, \ew, and \eW recognize only ASCII characters.
+.
+.
+.SH "GENERAL CATEGORY PROPERTY CODES FOR \ep and \eP"
+.rs
+.sp
+  C          Other
+  Cc         Control
+  Cf         Format
+  Cn         Unassigned
+  Co         Private use
+  Cs         Surrogate
+.sp
+  L          Letter
+  Ll         Lower case letter
+  Lm         Modifier letter
+  Lo         Other letter
+  Lt         Title case letter
+  Lu         Upper case letter
+  L&         Ll, Lu, or Lt
+.sp
+  M          Mark
+  Mc         Spacing mark
+  Me         Enclosing mark
+  Mn         Non-spacing mark
+.sp
+  N          Number
+  Nd         Decimal number
+  Nl         Letter number
+  No         Other number
+.sp
+  P          Punctuation
+  Pc         Connector punctuation
+  Pd         Dash punctuation
+  Pe         Close punctuation
+  Pf         Final punctuation
+  Pi         Initial punctuation
+  Po         Other punctuation
+  Ps         Open punctuation
+.sp
+  S          Symbol
+  Sc         Currency symbol
+  Sk         Modifier symbol
+  Sm         Mathematical symbol
+  So         Other symbol
+.sp
+  Z          Separator
+  Zl         Line separator
+  Zp         Paragraph separator
+  Zs         Space separator
+.
+.
+.SH "SCRIPT NAMES FOR \ep AND \eP"
+.rs
+.sp
+Arabic,
+Armenian,
+Balinese,
+Bengali,
+Bopomofo,
+Braille,
+Buginese,
+Buhid,
+Canadian_Aboriginal,
+Cherokee,
+Common,
+Coptic,
+Cuneiform,
+Cypriot,
+Cyrillic,
+Deseret,
+Devanagari,
+Ethiopic,
+Georgian,
+Glagolitic,
+Gothic,
+Greek,
+Gujarati,
+Gurmukhi,
+Han,
+Hangul,
+Hanunoo,
+Hebrew,
+Hiragana,
+Inherited,
+Kannada,
+Katakana,
+Kharoshthi,
+Khmer,
+Lao,
+Latin,
+Limbu,
+Linear_B,
+Malayalam,
+Mongolian,
+Myanmar,
+New_Tai_Lue,
+Nko,
+Ogham,
+Old_Italic,
+Old_Persian,
+Oriya,
+Osmanya,
+Phags_Pa,
+Phoenician,
+Runic,
+Shavian,
+Sinhala,
+Syloti_Nagri,
+Syriac,
+Tagalog,
+Tagbanwa,
+Tai_Le,
+Tamil,
+Telugu,
+Thaana,
+Thai,
+Tibetan,
+Tifinagh,
+Ugaritic,
+Yi.
+.
+.
+.SH "CHARACTER CLASSES"
+.rs
+.sp
+  [...]       positive character class
+  [^...]      negative character class
+  [x-y]       range (can be used for hex characters)
+  [[:xxx:]]   positive POSIX named set
+  [[:^xxx:]]  negative POSIX named set
+.sp
+  alnum       alphanumeric
+  alpha       alphabetic
+  ascii       0-127
+  blank       space or tab
+  cntrl       control character
+  digit       decimal digit
+  graph       printing, excluding space
+  lower       lower case letter
+  print       printing, including space
+  punct       printing, excluding alphanumeric
+  space       whitespace
+  upper       upper case letter
+  word        same as \ew
+  xdigit      hexadecimal digit
+.sp
+In PCRE, POSIX character set names recognize only ASCII characters. You can use
+\eQ...\eE inside a character class.
+.
+.
+.SH "QUANTIFIERS"
+.rs
+.sp
+  ?           0 or 1, greedy
+  ?+          0 or 1, possessive
+  ??          0 or 1, lazy
+  *           0 or more, greedy
+  *+          0 or more, possessive
+  *?          0 or more, lazy
+  +           1 or more, greedy
+  ++          1 or more, possessive
+  +?          1 or more, lazy
+  {n}         exactly n
+  {n,m}       at least n, no more than m, greedy
+  {n,m}+      at least n, no more than m, possessive
+  {n,m}?      at least n, no more than m, lazy
+  {n,}        n or more, greedy
+  {n,}+       n or more, possessive
+  {n,}?       n or more, lazy
+.
+.
+.SH "ANCHORS AND SIMPLE ASSERTIONS"
+.rs
+.sp
+  \eb          word boundary
+  \eB          not a word boundary
+  ^           start of subject
+               also after internal newline in multiline mode
+  \eA          start of subject
+  $           end of subject
+               also before newline at end of subject
+               also before internal newline in multiline mode
+  \eZ          end of subject
+               also before newline at end of subject
+  \ez          end of subject
+  \eG          first matching position in subject
+.
+.
+.SH "MATCH POINT RESET"
+.rs
+.sp
+  \eK          reset start of match
+.
+.
+.SH "ALTERNATION"
+.rs
+.sp
+  expr|expr|expr...
+.
+.
+.SH "CAPTURING"
+.rs
+.sp
+  (...)          capturing group
+  (?<name>...)   named capturing group (Perl)
+  (?'name'...)   named capturing group (Perl)
+  (?P<name>...)  named capturing group (Python)
+  (?:...)        non-capturing group
+  (?|...)        non-capturing group; reset group numbers for
+                  capturing groups in each alternative
+.
+.
+.SH "ATOMIC GROUPS"
+.rs
+.sp
+  (?>...)        atomic, non-capturing group
+.
+.
+.
+.
+.SH "COMMENT"
+.rs
+.sp
+  (?#....)       comment (not nestable)
+.
+.
+.SH "OPTION SETTING"
+.rs
+.sp
+  (?i)           caseless
+  (?J)           allow duplicate names
+  (?m)           multiline
+  (?s)           single line (dotall)
+  (?U)           default ungreedy (lazy)
+  (?x)           extended (ignore white space)
+  (?-...)        unset option(s)
+.
+.
+.SH "LOOKAHEAD AND LOOKBEHIND ASSERTIONS"
+.rs
+.sp
+  (?=...)        positive look ahead
+  (?!...)        negative look ahead
+  (?<=...)       positive look behind
+  (?<!...)       negative look behind
+.sp
+Each top-level branch of a look behind must be of a fixed length.
+.
+.
+.SH "BACKREFERENCES"
+.rs
+.sp
+  \en             reference by number (can be ambiguous)
+  \egn            reference by number
+  \eg{n}          reference by number
+  \eg{-n}         relative reference by number
+  \ek<name>       reference by name (Perl)
+  \ek'name'       reference by name (Perl)
+  \eg{name}       reference by name (Perl)
+  \ek{name}       reference by name (.NET)
+  (?P=name)      reference by name (Python)
+.
+.
+.SH "SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)"
+.rs
+.sp
+  (?R)           recurse whole pattern
+  (?n)           call subpattern by absolute number
+  (?+n)          call subpattern by relative number
+  (?-n)          call subpattern by relative number
+  (?&name)       call subpattern by name (Perl)
+  (?P>name)      call subpattern by name (Python)
+  \eg<name>       call subpattern by name (Oniguruma)
+  \eg'name'       call subpattern by name (Oniguruma)
+  \eg<n>          call subpattern by absolute number (Oniguruma)
+  \eg'n'          call subpattern by absolute number (Oniguruma)
+  \eg<+n>         call subpattern by relative number (PCRE extension)
+  \eg'+n'         call subpattern by relative number (PCRE extension)
+  \eg<-n>         call subpattern by relative number (PCRE extension)
+  \eg'-n'         call subpattern by relative number (PCRE extension)
+.
+.
+.SH "CONDITIONAL PATTERNS"
+.rs
+.sp
+  (?(condition)yes-pattern)
+  (?(condition)yes-pattern|no-pattern)
+.sp
+  (?(n)...       absolute reference condition
+  (?(+n)...      relative reference condition
+  (?(-n)...      relative reference condition
+  (?(<name>)...  named reference condition (Perl)
+  (?('name')...  named reference condition (Perl)
+  (?(name)...    named reference condition (PCRE)
+  (?(R)...       overall recursion condition
+  (?(Rn)...      specific group recursion condition
+  (?(R&name)...  specific recursion condition
+  (?(DEFINE)...  define subpattern for reference
+  (?(assert)...  assertion condition
+.
+.
+.SH "BACKTRACKING CONTROL"
+.rs
+.sp
+The following act immediately they are reached:
+.sp
+  (*ACCEPT)      force successful match
+  (*FAIL)        force backtrack; synonym (*F)
+.sp
+The following act only when a subsequent match failure causes a backtrack to
+reach them. They all force a match failure, but they differ in what happens
+afterwards. Those that advance the start-of-match point do so only if the
+pattern is not anchored.
+.sp
+  (*COMMIT)      overall failure, no advance of starting point
+  (*PRUNE)       advance to next starting character
+  (*SKIP)        advance start to current matching position
+  (*THEN)        local failure, backtrack to next alternation
+.
+.
+.SH "NEWLINE CONVENTIONS"
+.rs
+.sp
+These are recognized only at the very start of the pattern or after a
+(*BSR_...) option.
+.sp
+  (*CR)
+  (*LF)
+  (*CRLF)
+  (*ANYCRLF)
+  (*ANY)
+.
+.
+.SH "WHAT \eR MATCHES"
+.rs
+.sp
+These are recognized only at the very start of the pattern or after a
+(*...) option that sets the newline convention.
+.sp
+  (*BSR_ANYCRLF)
+  (*BSR_UNICODE)
+.
+.
+.SH "CALLOUTS"
+.rs
+.sp
+  (?C)      callout
+  (?Cn)     callout with data n
+.
+.
+.SH "SEE ALSO"
+.rs
+.sp
+\fBpcrepattern\fP(3), \fBpcreapi\fP(3), \fBpcrecallout\fP(3),
+\fBpcrematching\fP(3), \fBpcre\fP(3).
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 09 April 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcretest.1	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,723 @@
+.TH PCRETEST 1
+.SH NAME
+pcretest - a program for testing Perl-compatible regular expressions.
+.SH SYNOPSIS
+.rs
+.sp
+.B pcretest "[options] [source] [destination]"
+.sp
+\fBpcretest\fP was written as a test program for the PCRE regular expression
+library itself, but it can also be used for experimenting with regular
+expressions. This document describes the features of the test program; for
+details of the regular expressions themselves, see the
+.\" HREF
+\fBpcrepattern\fP
+.\"
+documentation. For details of the PCRE library function calls and their
+options, see the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation.
+.
+.
+.SH OPTIONS
+.rs
+.TP 10
+\fB-b\fP
+Behave as if each regex has the \fB/B\fP (show bytecode) modifier; the internal
+form is output after compilation.
+.TP 10
+\fB-C\fP
+Output the version number of the PCRE library, and all available information
+about the optional features that are included, and then exit.
+.TP 10
+\fB-d\fP
+Behave as if each regex has the \fB/D\fP (debug) modifier; the internal
+form and information about the compiled pattern is output after compilation;
+\fB-d\fP is equivalent to \fB-b -i\fP.
+.TP 10
+\fB-dfa\fP
+Behave as if each data line contains the \eD escape sequence; this causes the
+alternative matching function, \fBpcre_dfa_exec()\fP, to be used instead of the
+standard \fBpcre_exec()\fP function (more detail is given below).
+.TP 10
+\fB-help\fP
+Output a brief summary these options and then exit.
+.TP 10
+\fB-i\fP
+Behave as if each regex has the \fB/I\fP modifier; information about the
+compiled pattern is given after compilation.
+.TP 10
+\fB-m\fP
+Output the size of each compiled pattern after it has been compiled. This is
+equivalent to adding \fB/M\fP to each regular expression. For compatibility
+with earlier versions of pcretest, \fB-s\fP is a synonym for \fB-m\fP.
+.TP 10
+\fB-o\fP \fIosize\fP
+Set the number of elements in the output vector that is used when calling
+\fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP to be \fIosize\fP. The default value
+is 45, which is enough for 14 capturing subexpressions for \fBpcre_exec()\fP or
+22 different matches for \fBpcre_dfa_exec()\fP. The vector size can be
+changed for individual matching calls by including \eO in the data line (see
+below).
+.TP 10
+\fB-p\fP
+Behave as if each regex has the \fB/P\fP modifier; the POSIX wrapper API is
+used to call PCRE. None of the other options has any effect when \fB-p\fP is
+set.
+.TP 10
+\fB-q\fP
+Do not output the version number of \fBpcretest\fP at the start of execution.
+.TP 10
+\fB-S\fP \fIsize\fP
+On Unix-like systems, set the size of the runtime stack to \fIsize\fP
+megabytes.
+.TP 10
+\fB-t\fP
+Run each compile, study, and match many times with a timer, and output
+resulting time per compile or match (in milliseconds). Do not set \fB-m\fP with
+\fB-t\fP, because you will then get the size output a zillion times, and the
+timing will be distorted. You can control the number of iterations that are
+used for timing by following \fB-t\fP with a number (as a separate item on the
+command line). For example, "-t 1000" would iterate 1000 times. The default is
+to iterate 500000 times.
+.TP 10
+\fB-tm\fP
+This is like \fB-t\fP except that it times only the matching phase, not the
+compile or study phases.
+.
+.
+.SH DESCRIPTION
+.rs
+.sp
+If \fBpcretest\fP is given two filename arguments, it reads from the first and
+writes to the second. If it is given only one filename argument, it reads from
+that file and writes to stdout. Otherwise, it reads from stdin and writes to
+stdout, and prompts for each line of input, using "re>" to prompt for regular
+expressions, and "data>" to prompt for data lines.
+.P
+When \fBpcretest\fP is built, a configuration option can specify that it should
+be linked with the \fBlibreadline\fP library. When this is done, if the input
+is from a terminal, it is read using the \fBreadline()\fP function. This
+provides line-editing and history facilities. The output from the \fB-help\fP
+option states whether or not \fBreadline()\fP will be used.
+.P
+The program handles any number of sets of input on a single input file. Each
+set starts with a regular expression, and continues with any number of data
+lines to be matched against the pattern.
+.P
+Each data line is matched separately and independently. If you want to do
+multi-line matches, you have to use the \en escape sequence (or \er or \er\en,
+etc., depending on the newline setting) in a single line of input to encode the
+newline sequences. There is no limit on the length of data lines; the input
+buffer is automatically extended if it is too small.
+.P
+An empty line signals the end of the data lines, at which point a new regular
+expression is read. The regular expressions are given enclosed in any
+non-alphanumeric delimiters other than backslash, for example:
+.sp
+  /(a|bc)x+yz/
+.sp
+White space before the initial delimiter is ignored. A regular expression may
+be continued over several input lines, in which case the newline characters are
+included within it. It is possible to include the delimiter within the pattern
+by escaping it, for example
+.sp
+  /abc\e/def/
+.sp
+If you do so, the escape and the delimiter form part of the pattern, but since
+delimiters are always non-alphanumeric, this does not affect its interpretation.
+If the terminating delimiter is immediately followed by a backslash, for
+example,
+.sp
+  /abc/\e
+.sp
+then a backslash is added to the end of the pattern. This is done to provide a
+way of testing the error condition that arises if a pattern finishes with a
+backslash, because
+.sp
+  /abc\e/
+.sp
+is interpreted as the first line of a pattern that starts with "abc/", causing
+pcretest to read the next line as a continuation of the regular expression.
+.
+.
+.SH "PATTERN MODIFIERS"
+.rs
+.sp
+A pattern may be followed by any number of modifiers, which are mostly single
+characters. Following Perl usage, these are referred to below as, for example,
+"the \fB/i\fP modifier", even though the delimiter of the pattern need not
+always be a slash, and no slash is used when writing modifiers. Whitespace may
+appear between the final pattern delimiter and the first modifier, and between
+the modifiers themselves.
+.P
+The \fB/i\fP, \fB/m\fP, \fB/s\fP, and \fB/x\fP modifiers set the PCRE_CASELESS,
+PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively, when
+\fBpcre_compile()\fP is called. These four modifier letters have the same
+effect as they do in Perl. For example:
+.sp
+  /caseless/i
+.sp
+The following table shows additional modifiers for setting PCRE options that do
+not correspond to anything in Perl:
+.sp
+  \fB/A\fP              PCRE_ANCHORED
+  \fB/C\fP              PCRE_AUTO_CALLOUT
+  \fB/E\fP              PCRE_DOLLAR_ENDONLY
+  \fB/f\fP              PCRE_FIRSTLINE
+  \fB/J\fP              PCRE_DUPNAMES
+  \fB/N\fP              PCRE_NO_AUTO_CAPTURE
+  \fB/U\fP              PCRE_UNGREEDY
+  \fB/X\fP              PCRE_EXTRA
+  \fB/<JS>\fP           PCRE_JAVASCRIPT_COMPAT
+  \fB/<cr>\fP           PCRE_NEWLINE_CR
+  \fB/<lf>\fP           PCRE_NEWLINE_LF
+  \fB/<crlf>\fP         PCRE_NEWLINE_CRLF
+  \fB/<anycrlf>\fP      PCRE_NEWLINE_ANYCRLF
+  \fB/<any>\fP          PCRE_NEWLINE_ANY
+  \fB/<bsr_anycrlf>\fP  PCRE_BSR_ANYCRLF
+  \fB/<bsr_unicode>\fP  PCRE_BSR_UNICODE
+.sp
+Those specifying line ending sequences are literal strings as shown, but the
+letters can be in either case. This example sets multiline matching with CRLF
+as the line ending sequence:
+.sp
+  /^abc/m<crlf>
+.sp
+Details of the meanings of these PCRE options are given in the
+.\" HREF
+\fBpcreapi\fP
+.\"
+documentation.
+.
+.
+.SS "Finding all matches in a string"
+.rs
+.sp
+Searching for all possible matches within each subject string can be requested
+by the \fB/g\fP or \fB/G\fP modifier. After finding a match, PCRE is called
+again to search the remainder of the subject string. The difference between
+\fB/g\fP and \fB/G\fP is that the former uses the \fIstartoffset\fP argument to
+\fBpcre_exec()\fP to start searching at a new point within the entire string
+(which is in effect what Perl does), whereas the latter passes over a shortened
+substring. This makes a difference to the matching process if the pattern
+begins with a lookbehind assertion (including \eb or \eB).
+.P
+If any call to \fBpcre_exec()\fP in a \fB/g\fP or \fB/G\fP sequence matches an
+empty string, the next call is done with the PCRE_NOTEMPTY and PCRE_ANCHORED
+flags set in order to search for another, non-empty, match at the same point.
+If this second match fails, the start offset is advanced by one, and the normal
+match is retried. This imitates the way Perl handles such cases when using the
+\fB/g\fP modifier or the \fBsplit()\fP function.
+.
+.
+.SS "Other modifiers"
+.rs
+.sp
+There are yet more modifiers for controlling the way \fBpcretest\fP
+operates.
+.P
+The \fB/+\fP modifier requests that as well as outputting the substring that
+matched the entire pattern, pcretest should in addition output the remainder of
+the subject string. This is useful for tests where the subject contains
+multiple copies of the same substring.
+.P
+The \fB/B\fP modifier is a debugging feature. It requests that \fBpcretest\fP
+output a representation of the compiled byte code after compilation. Normally
+this information contains length and offset values; however, if \fB/Z\fP is
+also present, this data is replaced by spaces. This is a special feature for
+use in the automatic test scripts; it ensures that the same output is generated
+for different internal link sizes.
+.P
+The \fB/L\fP modifier must be followed directly by the name of a locale, for
+example,
+.sp
+  /pattern/Lfr_FR
+.sp
+For this reason, it must be the last modifier. The given locale is set,
+\fBpcre_maketables()\fP is called to build a set of character tables for the
+locale, and this is then passed to \fBpcre_compile()\fP when compiling the
+regular expression. Without an \fB/L\fP modifier, NULL is passed as the tables
+pointer; that is, \fB/L\fP applies only to the expression on which it appears.
+.P
+The \fB/I\fP modifier requests that \fBpcretest\fP output information about the
+compiled pattern (whether it is anchored, has a fixed first character, and
+so on). It does this by calling \fBpcre_fullinfo()\fP after compiling a
+pattern. If the pattern is studied, the results of that are also output.
+.P
+The \fB/D\fP modifier is a PCRE debugging feature, and is equivalent to
+\fB/BI\fP, that is, both the \fB/B\fP and the \fB/I\fP modifiers.
+.P
+The \fB/F\fP modifier causes \fBpcretest\fP to flip the byte order of the
+fields in the compiled pattern that contain 2-byte and 4-byte numbers. This
+facility is for testing the feature in PCRE that allows it to execute patterns
+that were compiled on a host with a different endianness. This feature is not
+available when the POSIX interface to PCRE is being used, that is, when the
+\fB/P\fP pattern modifier is specified. See also the section about saving and
+reloading compiled patterns below.
+.P
+The \fB/S\fP modifier causes \fBpcre_study()\fP to be called after the
+expression has been compiled, and the results used when the expression is
+matched.
+.P
+The \fB/M\fP modifier causes the size of memory block used to hold the compiled
+pattern to be output.
+.P
+The \fB/P\fP modifier causes \fBpcretest\fP to call PCRE via the POSIX wrapper
+API rather than its native API. When this is done, all other modifiers except
+\fB/i\fP, \fB/m\fP, and \fB/+\fP are ignored. REG_ICASE is set if \fB/i\fP is
+present, and REG_NEWLINE is set if \fB/m\fP is present. The wrapper functions
+force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.
+.P
+The \fB/8\fP modifier causes \fBpcretest\fP to call PCRE with the PCRE_UTF8
+option set. This turns on support for UTF-8 character handling in PCRE,
+provided that it was compiled with this support enabled. This modifier also
+causes any non-printing characters in output strings to be printed using the
+\ex{hh...} notation if they are valid UTF-8 sequences.
+.P
+If the \fB/?\fP modifier is used with \fB/8\fP, it causes \fBpcretest\fP to
+call \fBpcre_compile()\fP with the PCRE_NO_UTF8_CHECK option, to suppress the
+checking of the string for UTF-8 validity.
+.
+.
+.SH "DATA LINES"
+.rs
+.sp
+Before each data line is passed to \fBpcre_exec()\fP, leading and trailing
+whitespace is removed, and it is then scanned for \e escapes. Some of these are
+pretty esoteric features, intended for checking out some of the more
+complicated features of PCRE. If you are just testing "ordinary" regular
+expressions, you probably don't need any of these. The following escapes are
+recognized:
+.sp
+  \ea         alarm (BEL, \ex07)
+  \eb         backspace (\ex08)
+  \ee         escape (\ex27)
+  \ef         formfeed (\ex0c)
+  \en         newline (\ex0a)
+.\" JOIN
+  \eqdd       set the PCRE_MATCH_LIMIT limit to dd
+               (any number of digits)
+  \er         carriage return (\ex0d)
+  \et         tab (\ex09)
+  \ev         vertical tab (\ex0b)
+  \ennn       octal character (up to 3 octal digits)
+  \exhh       hexadecimal character (up to 2 hex digits)
+.\" JOIN
+  \ex{hh...}  hexadecimal character, any number of digits
+               in UTF-8 mode
+.\" JOIN
+  \eA         pass the PCRE_ANCHORED option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \eB         pass the PCRE_NOTBOL option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \eCdd       call pcre_copy_substring() for substring dd
+               after a successful match (number less than 32)
+.\" JOIN
+  \eCname     call pcre_copy_named_substring() for substring
+               "name" after a successful match (name termin-
+               ated by next non alphanumeric character)
+.\" JOIN
+  \eC+        show the current captured substrings at callout
+               time
+  \eC-        do not supply a callout function
+.\" JOIN
+  \eC!n       return 1 instead of 0 when callout number n is
+               reached
+.\" JOIN
+  \eC!n!m     return 1 instead of 0 when callout number n is
+               reached for the nth time
+.\" JOIN
+  \eC*n       pass the number n (may be negative) as callout
+               data; this is used as the callout return value
+  \eD         use the \fBpcre_dfa_exec()\fP match function
+  \eF         only shortest match for \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \eGdd       call pcre_get_substring() for substring dd
+               after a successful match (number less than 32)
+.\" JOIN
+  \eGname     call pcre_get_named_substring() for substring
+               "name" after a successful match (name termin-
+               ated by next non-alphanumeric character)
+.\" JOIN
+  \eL         call pcre_get_substringlist() after a
+               successful match
+.\" JOIN
+  \eM         discover the minimum MATCH_LIMIT and
+               MATCH_LIMIT_RECURSION settings
+.\" JOIN
+  \eN         pass the PCRE_NOTEMPTY option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \eOdd       set the size of the output vector passed to
+               \fBpcre_exec()\fP to dd (any number of digits)
+.\" JOIN
+  \eP         pass the PCRE_PARTIAL option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \eQdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd
+               (any number of digits)
+  \eR         pass the PCRE_DFA_RESTART option to \fBpcre_dfa_exec()\fP
+  \eS         output details of memory get/free calls during matching
+.\" JOIN
+  \eZ         pass the PCRE_NOTEOL option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \e?         pass the PCRE_NO_UTF8_CHECK option to
+               \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP
+  \e>dd       start the match at offset dd (any number of digits);
+.\" JOIN
+               this sets the \fIstartoffset\fP argument for \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \e<cr>      pass the PCRE_NEWLINE_CR option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \e<lf>      pass the PCRE_NEWLINE_LF option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \e<crlf>    pass the PCRE_NEWLINE_CRLF option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \e<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.\" JOIN
+  \e<any>     pass the PCRE_NEWLINE_ANY option to \fBpcre_exec()\fP
+               or \fBpcre_dfa_exec()\fP
+.sp
+The escapes that specify line ending sequences are literal strings, exactly as
+shown. No more than one newline setting should be present in any data line.
+.P
+A backslash followed by anything else just escapes the anything else. If
+the very last character is a backslash, it is ignored. This gives a way of
+passing an empty line as data, since a real empty line terminates the data
+input.
+.P
+If \eM is present, \fBpcretest\fP calls \fBpcre_exec()\fP several times, with
+different values in the \fImatch_limit\fP and \fImatch_limit_recursion\fP
+fields of the \fBpcre_extra\fP data structure, until it finds the minimum
+numbers for each parameter that allow \fBpcre_exec()\fP to complete. The
+\fImatch_limit\fP number is a measure of the amount of backtracking that takes
+place, and checking it out can be instructive. For most simple matches, the
+number is quite small, but for patterns with very large numbers of matching
+possibilities, it can become large very quickly with increasing length of
+subject string. The \fImatch_limit_recursion\fP number is a measure of how much
+stack (or, if PCRE is compiled with NO_RECURSE, how much heap) memory is needed
+to complete the match attempt.
+.P
+When \eO is used, the value specified may be higher or lower than the size set
+by the \fB-O\fP command line option (or defaulted to 45); \eO applies only to
+the call of \fBpcre_exec()\fP for the line in which it appears.
+.P
+If the \fB/P\fP modifier was present on the pattern, causing the POSIX wrapper
+API to be used, the only option-setting sequences that have any effect are \eB
+and \eZ, causing REG_NOTBOL and REG_NOTEOL, respectively, to be passed to
+\fBregexec()\fP.
+.P
+The use of \ex{hh...} to represent UTF-8 characters is not dependent on the use
+of the \fB/8\fP modifier on the pattern. It is recognized always. There may be
+any number of hexadecimal digits inside the braces. The result is from one to
+six bytes, encoded according to the original UTF-8 rules of RFC 2279. This
+allows for values in the range 0 to 0x7FFFFFFF. Note that not all of those are
+valid Unicode code points, or indeed valid UTF-8 characters according to the
+later rules in RFC 3629.
+.
+.
+.SH "THE ALTERNATIVE MATCHING FUNCTION"
+.rs
+.sp
+By default, \fBpcretest\fP uses the standard PCRE matching function,
+\fBpcre_exec()\fP to match each data line. From release 6.0, PCRE supports an
+alternative matching function, \fBpcre_dfa_test()\fP, which operates in a
+different way, and has some restrictions. The differences between the two
+functions are described in the
+.\" HREF
+\fBpcrematching\fP
+.\"
+documentation.
+.P
+If a data line contains the \eD escape sequence, or if the command line
+contains the \fB-dfa\fP option, the alternative matching function is called.
+This function finds all possible matches at a given point. If, however, the \eF
+escape sequence is present in the data line, it stops after the first match is
+found. This is always the shortest possible match.
+.
+.
+.SH "DEFAULT OUTPUT FROM PCRETEST"
+.rs
+.sp
+This section describes the output when the normal matching function,
+\fBpcre_exec()\fP, is being used.
+.P
+When a match succeeds, pcretest outputs the list of captured substrings that
+\fBpcre_exec()\fP returns, starting with number 0 for the string that matched
+the whole pattern. Otherwise, it outputs "No match" or "Partial match"
+when \fBpcre_exec()\fP returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL,
+respectively, and otherwise the PCRE negative error number. Here is an example
+of an interactive \fBpcretest\fP run.
+.sp
+  $ pcretest
+  PCRE version 7.0 30-Nov-2006
+.sp
+    re> /^abc(\ed+)/
+  data> abc123
+   0: abc123
+   1: 123
+  data> xyz
+  No match
+.sp
+Note that unset capturing substrings that are not followed by one that is set
+are not returned by \fBpcre_exec()\fP, and are not shown by \fBpcretest\fP. In
+the following example, there are two capturing substrings, but when the first
+data line is matched, the second, unset substring is not shown. An "internal"
+unset substring is shown as "<unset>", as for the second data line.
+.sp
+    re> /(a)|(b)/
+  data> a
+   0: a
+   1: a
+  data> b
+   0: b
+   1: <unset>
+   2: b
+.sp
+If the strings contain any non-printing characters, they are output as \e0x
+escapes, or as \ex{...} escapes if the \fB/8\fP modifier was present on the
+pattern. See below for the definition of non-printing characters. If the
+pattern has the \fB/+\fP modifier, the output for substring 0 is followed by
+the the rest of the subject string, identified by "0+" like this:
+.sp
+    re> /cat/+
+  data> cataract
+   0: cat
+   0+ aract
+.sp
+If the pattern has the \fB/g\fP or \fB/G\fP modifier, the results of successive
+matching attempts are output in sequence, like this:
+.sp
+    re> /\eBi(\ew\ew)/g
+  data> Mississippi
+   0: iss
+   1: ss
+   0: iss
+   1: ss
+   0: ipp
+   1: pp
+.sp
+"No match" is output only if the first match attempt fails.
+.P
+If any of the sequences \fB\eC\fP, \fB\eG\fP, or \fB\eL\fP are present in a
+data line that is successfully matched, the substrings extracted by the
+convenience functions are output with C, G, or L after the string number
+instead of a colon. This is in addition to the normal full list. The string
+length (that is, the return from the extraction function) is given in
+parentheses after each string for \fB\eC\fP and \fB\eG\fP.
+.P
+Note that whereas patterns can be continued over several lines (a plain ">"
+prompt is used for continuations), data lines may not. However newlines can be
+included in data by means of the \en escape (or \er, \er\en, etc., depending on
+the newline sequence setting).
+.
+.
+.
+.SH "OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION"
+.rs
+.sp
+When the alternative matching function, \fBpcre_dfa_exec()\fP, is used (by
+means of the \eD escape sequence or the \fB-dfa\fP command line option), the
+output consists of a list of all the matches that start at the first point in
+the subject where there is at least one match. For example:
+.sp
+    re> /(tang|tangerine|tan)/
+  data> yellow tangerine\eD
+   0: tangerine
+   1: tang
+   2: tan
+.sp
+(Using the normal matching function on this data finds only "tang".) The
+longest matching string is always given first (and numbered zero).
+.P
+If \fB/g\fP is present on the pattern, the search for further matches resumes
+at the end of the longest match. For example:
+.sp
+    re> /(tang|tangerine|tan)/g
+  data> yellow tangerine and tangy sultana\eD
+   0: tangerine
+   1: tang
+   2: tan
+   0: tang
+   1: tan
+   0: tan
+.sp
+Since the matching function does not support substring capture, the escape
+sequences that are concerned with captured substrings are not relevant.
+.
+.
+.SH "RESTARTING AFTER A PARTIAL MATCH"
+.rs
+.sp
+When the alternative matching function has given the PCRE_ERROR_PARTIAL return,
+indicating that the subject partially matched the pattern, you can restart the
+match with additional subject data by means of the \eR escape sequence. For
+example:
+.sp
+    re> /^\ed?\ed(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\ed\ed$/
+  data> 23ja\eP\eD
+  Partial match: 23ja
+  data> n05\eR\eD
+   0: n05
+.sp
+For further information about partial matching, see the
+.\" HREF
+\fBpcrepartial\fP
+.\"
+documentation.
+.
+.
+.SH CALLOUTS
+.rs
+.sp
+If the pattern contains any callout requests, \fBpcretest\fP's callout function
+is called during matching. This works with both matching functions. By default,
+the called function displays the callout number, the start and current
+positions in the text at the callout time, and the next pattern item to be
+tested. For example, the output
+.sp
+  --->pqrabcdef
+    0    ^  ^     \ed
+.sp
+indicates that callout number 0 occurred for a match attempt starting at the
+fourth character of the subject string, when the pointer was at the seventh
+character of the data, and when the next pattern item was \ed. Just one
+circumflex is output if the start and current positions are the same.
+.P
+Callouts numbered 255 are assumed to be automatic callouts, inserted as a
+result of the \fB/C\fP pattern modifier. In this case, instead of showing the
+callout number, the offset in the pattern, preceded by a plus, is output. For
+example:
+.sp
+    re> /\ed?[A-E]\e*/C
+  data> E*
+  --->E*
+   +0 ^      \ed?
+   +3 ^      [A-E]
+   +8 ^^     \e*
+  +10 ^ ^
+   0: E*
+.sp
+The callout function in \fBpcretest\fP returns zero (carry on matching) by
+default, but you can use a \eC item in a data line (as described above) to
+change this.
+.P
+Inserting callouts can be helpful when using \fBpcretest\fP to check
+complicated regular expressions. For further information about callouts, see
+the
+.\" HREF
+\fBpcrecallout\fP
+.\"
+documentation.
+.
+.
+.
+.SH "NON-PRINTING CHARACTERS"
+.rs
+.sp
+When \fBpcretest\fP is outputting text in the compiled version of a pattern,
+bytes other than 32-126 are always treated as non-printing characters are are
+therefore shown as hex escapes.
+.P
+When \fBpcretest\fP is outputting text that is a matched part of a subject
+string, it behaves in the same way, unless a different locale has been set for
+the pattern (using the \fB/L\fP modifier). In this case, the \fBisprint()\fP
+function to distinguish printing and non-printing characters.
+.
+.
+.
+.SH "SAVING AND RELOADING COMPILED PATTERNS"
+.rs
+.sp
+The facilities described in this section are not available when the POSIX
+inteface to PCRE is being used, that is, when the \fB/P\fP pattern modifier is
+specified.
+.P
+When the POSIX interface is not in use, you can cause \fBpcretest\fP to write a
+compiled pattern to a file, by following the modifiers with > and a file name.
+For example:
+.sp
+  /pattern/im >/some/file
+.sp
+See the
+.\" HREF
+\fBpcreprecompile\fP
+.\"
+documentation for a discussion about saving and re-using compiled patterns.
+.P
+The data that is written is binary. The first eight bytes are the length of the
+compiled pattern data followed by the length of the optional study data, each
+written as four bytes in big-endian order (most significant byte first). If
+there is no study data (either the pattern was not studied, or studying did not
+return any data), the second length is zero. The lengths are followed by an
+exact copy of the compiled pattern. If there is additional study data, this
+follows immediately after the compiled pattern. After writing the file,
+\fBpcretest\fP expects to read a new pattern.
+.P
+A saved pattern can be reloaded into \fBpcretest\fP by specifing < and a file
+name instead of a pattern. The name of the file must not contain a < character,
+as otherwise \fBpcretest\fP will interpret the line as a pattern delimited by <
+characters.
+For example:
+.sp
+   re> </some/file
+  Compiled regex loaded from /some/file
+  No study data
+.sp
+When the pattern has been loaded, \fBpcretest\fP proceeds to read data lines in
+the usual way.
+.P
+You can copy a file written by \fBpcretest\fP to a different host and reload it
+there, even if the new host has opposite endianness to the one on which the
+pattern was compiled. For example, you can compile on an i86 machine and run on
+a SPARC machine.
+.P
+File names for saving and reloading can be absolute or relative, but note that
+the shell facility of expanding a file name that starts with a tilde (~) is not
+available.
+.P
+The ability to save and reload files in \fBpcretest\fP is intended for testing
+and experimentation. It is not intended for production use because only a
+single pattern can be written to a file. Furthermore, there is no facility for
+supplying custom character tables for use with a reloaded pattern. If the
+original pattern was compiled with custom tables, an attempt to match a subject
+string using a reloaded pattern is likely to cause \fBpcretest\fP to crash.
+Finally, if you attempt to load a file that is not in the correct format, the
+result is undefined.
+.
+.
+.SH "SEE ALSO"
+.rs
+.sp
+\fBpcre\fP(3), \fBpcreapi\fP(3), \fBpcrecallout\fP(3), \fBpcrematching\fP(3),
+\fBpcrepartial\fP(d), \fBpcrepattern\fP(3), \fBpcreprecompile\fP(3).
+.
+.
+.SH AUTHOR
+.rs
+.sp
+.nf
+Philip Hazel
+University Computing Service
+Cambridge CB2 3QH, England.
+.fi
+.
+.
+.SH REVISION
+.rs
+.sp
+.nf
+Last updated: 12 April 2008
+Copyright (c) 1997-2008 University of Cambridge.
+.fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/pcretest.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,654 @@
+PCRETEST(1)                                                        PCRETEST(1)
+
+
+NAME
+       pcretest - a program for testing Perl-compatible regular expressions.
+
+
+SYNOPSIS
+
+       pcretest [options] [source] [destination]
+
+       pcretest  was written as a test program for the PCRE regular expression
+       library itself, but it can also be used for experimenting with  regular
+       expressions.  This document describes the features of the test program;
+       for details of the regular expressions themselves, see the  pcrepattern
+       documentation. For details of the PCRE library function calls and their
+       options, see the pcreapi documentation.
+
+
+OPTIONS
+
+       -b        Behave as if each regex has the /B (show bytecode)  modifier;
+                 the internal form is output after compilation.
+
+       -C        Output the version number of the PCRE library, and all avail-
+                 able  information  about  the  optional  features  that   are
+                 included, and then exit.
+
+       -d        Behave  as  if  each  regex  has the /D (debug) modifier; the
+                 internal form and information about the compiled  pattern  is
+                 output after compilation; -d is equivalent to -b -i.
+
+       -dfa      Behave  as if each data line contains the \D escape sequence;
+                 this    causes    the    alternative    matching    function,
+                 pcre_dfa_exec(),   to   be   used  instead  of  the  standard
+                 pcre_exec() function (more detail is given below).
+
+       -help     Output a brief summary these options and then exit.
+
+       -i        Behave as if each regex  has  the  /I  modifier;  information
+                 about the compiled pattern is given after compilation.
+
+       -m        Output  the  size  of each compiled pattern after it has been
+                 compiled. This is equivalent to adding  /M  to  each  regular
+                 expression.   For  compatibility  with  earlier  versions  of
+                 pcretest, -s is a synonym for -m.
+
+       -o osize  Set the number of elements in the output vector that is  used
+                 when  calling pcre_exec() or pcre_dfa_exec() to be osize. The
+                 default value is 45, which is enough for 14 capturing  subex-
+                 pressions   for  pcre_exec()  or  22  different  matches  for
+                 pcre_dfa_exec(). The vector size can be changed for  individ-
+                 ual  matching  calls  by  including  \O in the data line (see
+                 below).
+
+       -p        Behave as if each regex has the /P modifier; the POSIX  wrap-
+                 per  API  is used to call PCRE. None of the other options has
+                 any effect when -p is set.
+
+       -q        Do not output the version number of pcretest at the start  of
+                 execution.
+
+       -S size   On  Unix-like  systems,  set the size of the runtime stack to
+                 size megabytes.
+
+       -t        Run each compile, study, and match many times with  a  timer,
+                 and  output resulting time per compile or match (in millisec-
+                 onds). Do not set -m with -t, because you will then  get  the
+                 size  output  a  zillion  times,  and the timing will be dis-
+                 torted. You can control the number  of  iterations  that  are
+                 used  for timing by following -t with a number (as a separate
+                 item on the command line). For example, "-t 1000" would iter-
+                 ate 1000 times. The default is to iterate 500000 times.
+
+       -tm       This is like -t except that it times only the matching phase,
+                 not the compile or study phases.
+
+
+DESCRIPTION
+
+       If pcretest is given two filename arguments, it reads  from  the  first
+       and writes to the second. If it is given only one filename argument, it
+       reads from that file and writes to stdout.  Otherwise,  it  reads  from
+       stdin  and  writes to stdout, and prompts for each line of input, using
+       "re>" to prompt for regular expressions, and "data>" to prompt for data
+       lines.
+
+       When  pcretest  is  built,  a  configuration option can specify that it
+       should be linked with the libreadline library. When this  is  done,  if
+       the input is from a terminal, it is read using the readline() function.
+       This provides line-editing and history facilities. The output from  the
+       -help option states whether or not readline() will be used.
+
+       The program handles any number of sets of input on a single input file.
+       Each set starts with a regular expression, and continues with any  num-
+       ber of data lines to be matched against the pattern.
+
+       Each  data line is matched separately and independently. If you want to
+       do multi-line matches, you have to use the \n escape sequence (or \r or
+       \r\n, etc., depending on the newline setting) in a single line of input
+       to encode the newline sequences. There is no limit  on  the  length  of
+       data  lines;  the  input  buffer is automatically extended if it is too
+       small.
+
+       An empty line signals the end of the data lines, at which point  a  new
+       regular  expression is read. The regular expressions are given enclosed
+       in any non-alphanumeric delimiters other than backslash, for example:
+
+         /(a|bc)x+yz/
+
+       White space before the initial delimiter is ignored. A regular  expres-
+       sion  may be continued over several input lines, in which case the new-
+       line characters are included within it. It is possible to  include  the
+       delimiter within the pattern by escaping it, for example
+
+         /abc\/def/
+
+       If  you  do  so, the escape and the delimiter form part of the pattern,
+       but since delimiters are always non-alphanumeric, this does not  affect
+       its  interpretation.   If the terminating delimiter is immediately fol-
+       lowed by a backslash, for example,
+
+         /abc/\
+
+       then a backslash is added to the end of the pattern. This  is  done  to
+       provide  a  way of testing the error condition that arises if a pattern
+       finishes with a backslash, because
+
+         /abc\/
+
+       is interpreted as the first line of a pattern that starts with  "abc/",
+       causing pcretest to read the next line as a continuation of the regular
+       expression.
+
+
+PATTERN MODIFIERS
+
+       A pattern may be followed by any number of modifiers, which are  mostly
+       single  characters.  Following  Perl usage, these are referred to below
+       as, for example, "the /i modifier", even though the  delimiter  of  the
+       pattern  need  not always be a slash, and no slash is used when writing
+       modifiers. Whitespace may appear between the  final  pattern  delimiter
+       and the first modifier, and between the modifiers themselves.
+
+       The /i, /m, /s, and /x modifiers set the PCRE_CASELESS, PCRE_MULTILINE,
+       PCRE_DOTALL, or PCRE_EXTENDED  options,  respectively,  when  pcre_com-
+       pile()  is  called. These four modifier letters have the same effect as
+       they do in Perl. For example:
+
+         /caseless/i
+
+       The following table shows additional modifiers for setting PCRE options
+       that do not correspond to anything in Perl:
+
+         /A              PCRE_ANCHORED
+         /C              PCRE_AUTO_CALLOUT
+         /E              PCRE_DOLLAR_ENDONLY
+         /f              PCRE_FIRSTLINE
+         /J              PCRE_DUPNAMES
+         /N              PCRE_NO_AUTO_CAPTURE
+         /U              PCRE_UNGREEDY
+         /X              PCRE_EXTRA
+         /<JS>           PCRE_JAVASCRIPT_COMPAT
+         /<cr>           PCRE_NEWLINE_CR
+         /<lf>           PCRE_NEWLINE_LF
+         /<crlf>         PCRE_NEWLINE_CRLF
+         /<anycrlf>      PCRE_NEWLINE_ANYCRLF
+         /<any>          PCRE_NEWLINE_ANY
+         /<bsr_anycrlf>  PCRE_BSR_ANYCRLF
+         /<bsr_unicode>  PCRE_BSR_UNICODE
+
+       Those  specifying  line  ending sequences are literal strings as shown,
+       but the letters can be in either  case.  This  example  sets  multiline
+       matching with CRLF as the line ending sequence:
+
+         /^abc/m<crlf>
+
+       Details  of the meanings of these PCRE options are given in the pcreapi
+       documentation.
+
+   Finding all matches in a string
+
+       Searching for all possible matches within each subject  string  can  be
+       requested  by  the  /g  or  /G modifier. After finding a match, PCRE is
+       called again to search the remainder of the subject string. The differ-
+       ence between /g and /G is that the former uses the startoffset argument
+       to pcre_exec() to start searching at a  new  point  within  the  entire
+       string  (which  is in effect what Perl does), whereas the latter passes
+       over a shortened substring. This makes a  difference  to  the  matching
+       process if the pattern begins with a lookbehind assertion (including \b
+       or \B).
+
+       If any call to pcre_exec() in a /g or  /G  sequence  matches  an  empty
+       string,  the next call is done with the PCRE_NOTEMPTY and PCRE_ANCHORED
+       flags set in order to search for another, non-empty, match at the  same
+       point.   If  this  second  match fails, the start offset is advanced by
+       one, and the normal match is retried. This imitates the way  Perl  han-
+       dles such cases when using the /g modifier or the split() function.
+
+   Other modifiers
+
+       There are yet more modifiers for controlling the way pcretest operates.
+
+       The /+ modifier requests that as well as outputting the substring  that
+       matched  the  entire  pattern,  pcretest  should in addition output the
+       remainder of the subject string. This is useful  for  tests  where  the
+       subject contains multiple copies of the same substring.
+
+       The  /B modifier is a debugging feature. It requests that pcretest out-
+       put a representation of the compiled byte code after compilation.  Nor-
+       mally  this  information contains length and offset values; however, if
+       /Z is also present, this data is replaced by spaces. This is a  special
+       feature for use in the automatic test scripts; it ensures that the same
+       output is generated for different internal link sizes.
+
+       The /L modifier must be followed directly by the name of a locale,  for
+       example,
+
+         /pattern/Lfr_FR
+
+       For this reason, it must be the last modifier. The given locale is set,
+       pcre_maketables() is called to build a set of character tables for  the
+       locale,  and  this  is then passed to pcre_compile() when compiling the
+       regular expression. Without an /L  modifier,  NULL  is  passed  as  the
+       tables  pointer; that is, /L applies only to the expression on which it
+       appears.
+
+       The /I modifier requests that pcretest  output  information  about  the
+       compiled  pattern (whether it is anchored, has a fixed first character,
+       and so on). It does this by calling pcre_fullinfo() after  compiling  a
+       pattern.  If  the pattern is studied, the results of that are also out-
+       put.
+
+       The /D modifier is a PCRE debugging feature, and is equivalent to  /BI,
+       that is, both the /B and the /I modifiers.
+
+       The /F modifier causes pcretest to flip the byte order of the fields in
+       the compiled pattern that  contain  2-byte  and  4-byte  numbers.  This
+       facility  is  for testing the feature in PCRE that allows it to execute
+       patterns that were compiled on a host with a different endianness. This
+       feature  is  not  available  when  the POSIX interface to PCRE is being
+       used, that is, when the /P pattern modifier is specified. See also  the
+       section about saving and reloading compiled patterns below.
+
+       The  /S  modifier causes pcre_study() to be called after the expression
+       has been compiled, and the results used when the expression is matched.
+
+       The  /M  modifier causes the size of memory block used to hold the com-
+       piled pattern to be output.
+
+       The /P modifier causes pcretest to call PCRE via the POSIX wrapper  API
+       rather  than  its  native  API.  When this is done, all other modifiers
+       except /i, /m, and /+ are ignored. REG_ICASE is set if /i  is  present,
+       and  REG_NEWLINE  is  set if /m is present. The wrapper functions force
+       PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is  set.
+
+       The  /8 modifier causes pcretest to call PCRE with the PCRE_UTF8 option
+       set. This turns on support for UTF-8 character handling in  PCRE,  pro-
+       vided  that  it  was  compiled with this support enabled. This modifier
+       also causes any non-printing characters in output strings to be printed
+       using the \x{hh...} notation if they are valid UTF-8 sequences.
+
+       If  the  /?  modifier  is  used  with  /8,  it  causes pcretest to call
+       pcre_compile() with the  PCRE_NO_UTF8_CHECK  option,  to  suppress  the
+       checking of the string for UTF-8 validity.
+
+
+DATA LINES
+
+       Before  each  data  line is passed to pcre_exec(), leading and trailing
+       whitespace is removed, and it is then scanned for \  escapes.  Some  of
+       these  are  pretty esoteric features, intended for checking out some of
+       the more complicated features of PCRE. If you are just  testing  "ordi-
+       nary"  regular  expressions,  you probably don't need any of these. The
+       following escapes are recognized:
+
+         \a         alarm (BEL, \x07)
+         \b         backspace (\x08)
+         \e         escape (\x27)
+         \f         formfeed (\x0c)
+         \n         newline (\x0a)
+         \qdd       set the PCRE_MATCH_LIMIT limit to dd
+                      (any number of digits)
+         \r         carriage return (\x0d)
+         \t         tab (\x09)
+         \v         vertical tab (\x0b)
+         \nnn       octal character (up to 3 octal digits)
+         \xhh       hexadecimal character (up to 2 hex digits)
+         \x{hh...}  hexadecimal character, any number of digits
+                      in UTF-8 mode
+         \A         pass the PCRE_ANCHORED option to pcre_exec()
+                      or pcre_dfa_exec()
+         \B         pass the PCRE_NOTBOL option to pcre_exec()
+                      or pcre_dfa_exec()
+         \Cdd       call pcre_copy_substring() for substring dd
+                      after a successful match (number less than 32)
+         \Cname     call pcre_copy_named_substring() for substring
+                      "name" after a successful match (name termin-
+                      ated by next non alphanumeric character)
+         \C+        show the current captured substrings at callout
+                      time
+         \C-        do not supply a callout function
+         \C!n       return 1 instead of 0 when callout number n is
+                      reached
+         \C!n!m     return 1 instead of 0 when callout number n is
+                      reached for the nth time
+         \C*n       pass the number n (may be negative) as callout
+                      data; this is used as the callout return value
+         \D         use the pcre_dfa_exec() match function
+         \F         only shortest match for pcre_dfa_exec()
+         \Gdd       call pcre_get_substring() for substring dd
+                      after a successful match (number less than 32)
+         \Gname     call pcre_get_named_substring() for substring
+                      "name" after a successful match (name termin-
+                      ated by next non-alphanumeric character)
+         \L         call pcre_get_substringlist() after a
+                      successful match
+         \M         discover the minimum MATCH_LIMIT and
+                      MATCH_LIMIT_RECURSION settings
+         \N         pass the PCRE_NOTEMPTY option to pcre_exec()
+                      or pcre_dfa_exec()
+         \Odd       set the size of the output vector passed to
+                      pcre_exec() to dd (any number of digits)
+         \P         pass the PCRE_PARTIAL option to pcre_exec()
+                      or pcre_dfa_exec()
+         \Qdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd
+                      (any number of digits)
+         \R         pass the PCRE_DFA_RESTART option to pcre_dfa_exec()
+         \S         output details of memory get/free calls during matching
+         \Z         pass the PCRE_NOTEOL option to pcre_exec()
+                      or pcre_dfa_exec()
+         \?         pass the PCRE_NO_UTF8_CHECK option to
+                      pcre_exec() or pcre_dfa_exec()
+         \>dd       start the match at offset dd (any number of digits);
+                      this sets the startoffset argument for pcre_exec()
+                      or pcre_dfa_exec()
+         \<cr>      pass the PCRE_NEWLINE_CR option to pcre_exec()
+                      or pcre_dfa_exec()
+         \<lf>      pass the PCRE_NEWLINE_LF option to pcre_exec()
+                      or pcre_dfa_exec()
+         \<crlf>    pass the PCRE_NEWLINE_CRLF option to pcre_exec()
+                      or pcre_dfa_exec()
+         \<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to pcre_exec()
+                      or pcre_dfa_exec()
+         \<any>     pass the PCRE_NEWLINE_ANY option to pcre_exec()
+                      or pcre_dfa_exec()
+
+       The escapes that specify line ending  sequences  are  literal  strings,
+       exactly as shown. No more than one newline setting should be present in
+       any data line.
+
+       A backslash followed by anything else just escapes the  anything  else.
+       If  the very last character is a backslash, it is ignored. This gives a
+       way of passing an empty line as data, since a real  empty  line  termi-
+       nates the data input.
+
+       If  \M  is present, pcretest calls pcre_exec() several times, with dif-
+       ferent values in the match_limit and  match_limit_recursion  fields  of
+       the  pcre_extra  data structure, until it finds the minimum numbers for
+       each parameter that allow pcre_exec() to complete. The match_limit num-
+       ber  is  a  measure of the amount of backtracking that takes place, and
+       checking it out can be instructive. For most simple matches, the number
+       is  quite  small,  but for patterns with very large numbers of matching
+       possibilities, it can become large very quickly with increasing  length
+       of subject string. The match_limit_recursion number is a measure of how
+       much stack (or, if PCRE is compiled with  NO_RECURSE,  how  much  heap)
+       memory is needed to complete the match attempt.
+
+       When  \O  is  used, the value specified may be higher or lower than the
+       size set by the -O command line option (or defaulted to 45); \O applies
+       only to the call of pcre_exec() for the line in which it appears.
+
+       If  the /P modifier was present on the pattern, causing the POSIX wrap-
+       per API to be used, the only option-setting  sequences  that  have  any
+       effect  are \B and \Z, causing REG_NOTBOL and REG_NOTEOL, respectively,
+       to be passed to regexec().
+
+       The use of \x{hh...} to represent UTF-8 characters is not dependent  on
+       the  use  of  the  /8 modifier on the pattern. It is recognized always.
+       There may be any number of hexadecimal digits inside  the  braces.  The
+       result  is  from  one  to  six bytes, encoded according to the original
+       UTF-8 rules of RFC 2279. This allows for  values  in  the  range  0  to
+       0x7FFFFFFF.  Note  that not all of those are valid Unicode code points,
+       or indeed valid UTF-8 characters according to the later  rules  in  RFC
+       3629.
+
+
+THE ALTERNATIVE MATCHING FUNCTION
+
+       By   default,  pcretest  uses  the  standard  PCRE  matching  function,
+       pcre_exec() to match each data line. From release 6.0, PCRE supports an
+       alternative  matching  function,  pcre_dfa_test(),  which operates in a
+       different way, and has some restrictions. The differences  between  the
+       two functions are described in the pcrematching documentation.
+
+       If  a data line contains the \D escape sequence, or if the command line
+       contains the -dfa option, the alternative matching function is  called.
+       This function finds all possible matches at a given point. If, however,
+       the \F escape sequence is present in the data line, it stops after  the
+       first match is found. This is always the shortest possible match.
+
+
+DEFAULT OUTPUT FROM PCRETEST
+
+       This  section  describes  the output when the normal matching function,
+       pcre_exec(), is being used.
+
+       When a match succeeds, pcretest outputs the list of captured substrings
+       that  pcre_exec()  returns,  starting with number 0 for the string that
+       matched the whole pattern. Otherwise, it outputs "No match" or "Partial
+       match"  when  pcre_exec() returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PAR-
+       TIAL, respectively, and otherwise the PCRE negative error number.  Here
+       is an example of an interactive pcretest run.
+
+         $ pcretest
+         PCRE version 7.0 30-Nov-2006
+
+           re> /^abc(\d+)/
+         data> abc123
+          0: abc123
+          1: 123
+         data> xyz
+         No match
+
+       Note  that unset capturing substrings that are not followed by one that
+       is set are not returned by pcre_exec(), and are not shown by  pcretest.
+       In  the following example, there are two capturing substrings, but when
+       the first data line is matched, the  second,  unset  substring  is  not
+       shown.  An "internal" unset substring is shown as "<unset>", as for the
+       second data line.
+
+           re> /(a)|(b)/
+         data> a
+          0: a
+          1: a
+         data> b
+          0: b
+          1: <unset>
+          2: b
+
+       If the strings contain any non-printing characters, they are output  as
+       \0x  escapes,  or  as \x{...} escapes if the /8 modifier was present on
+       the pattern. See below for the definition of  non-printing  characters.
+       If  the pattern has the /+ modifier, the output for substring 0 is fol-
+       lowed by the the rest of the subject string, identified  by  "0+"  like
+       this:
+
+           re> /cat/+
+         data> cataract
+          0: cat
+          0+ aract
+
+       If  the  pattern  has  the /g or /G modifier, the results of successive
+       matching attempts are output in sequence, like this:
+
+           re> /\Bi(\w\w)/g
+         data> Mississippi
+          0: iss
+          1: ss
+          0: iss
+          1: ss
+          0: ipp
+          1: pp
+
+       "No match" is output only if the first match attempt fails.
+
+       If any of the sequences \C, \G, or \L are present in a data  line  that
+       is  successfully  matched,  the substrings extracted by the convenience
+       functions are output with C, G, or L after the string number instead of
+       a colon. This is in addition to the normal full list. The string length
+       (that is, the return from the extraction function) is given  in  paren-
+       theses after each string for \C and \G.
+
+       Note that whereas patterns can be continued over several lines (a plain
+       ">" prompt is used for continuations), data lines may not. However new-
+       lines  can  be included in data by means of the \n escape (or \r, \r\n,
+       etc., depending on the newline sequence setting).
+
+
+OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION
+
+       When the alternative matching function, pcre_dfa_exec(),  is  used  (by
+       means  of  the \D escape sequence or the -dfa command line option), the
+       output consists of a list of all the matches that start  at  the  first
+       point in the subject where there is at least one match. For example:
+
+           re> /(tang|tangerine|tan)/
+         data> yellow tangerine\D
+          0: tangerine
+          1: tang
+          2: tan
+
+       (Using  the  normal  matching function on this data finds only "tang".)
+       The longest matching string is always given first (and numbered  zero).
+
+       If /g is present on the pattern, the search for further matches resumes
+       at the end of the longest match. For example:
+
+           re> /(tang|tangerine|tan)/g
+         data> yellow tangerine and tangy sultana\D
+          0: tangerine
+          1: tang
+          2: tan
+          0: tang
+          1: tan
+          0: tan
+
+       Since the matching function does not  support  substring  capture,  the
+       escape  sequences  that  are concerned with captured substrings are not
+       relevant.
+
+
+RESTARTING AFTER A PARTIAL MATCH
+
+       When the alternative matching function has given the PCRE_ERROR_PARTIAL
+       return,  indicating that the subject partially matched the pattern, you
+       can restart the match with additional subject data by means of  the  \R
+       escape sequence. For example:
+
+           re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
+         data> 23ja\P\D
+         Partial match: 23ja
+         data> n05\R\D
+          0: n05
+
+       For  further  information  about  partial matching, see the pcrepartial
+       documentation.
+
+
+CALLOUTS
+
+       If the pattern contains any callout requests, pcretest's callout  func-
+       tion  is  called  during  matching. This works with both matching func-
+       tions. By default, the called function displays the callout number, the
+       start  and  current  positions in the text at the callout time, and the
+       next pattern item to be tested. For example, the output
+
+         --->pqrabcdef
+           0    ^  ^     \d
+
+       indicates that callout number 0 occurred for a match  attempt  starting
+       at  the fourth character of the subject string, when the pointer was at
+       the seventh character of the data, and when the next pattern  item  was
+       \d.  Just  one  circumflex is output if the start and current positions
+       are the same.
+
+       Callouts numbered 255 are assumed to be automatic callouts, inserted as
+       a  result  of the /C pattern modifier. In this case, instead of showing
+       the callout number, the offset in the pattern, preceded by a  plus,  is
+       output. For example:
+
+           re> /\d?[A-E]\*/C
+         data> E*
+         --->E*
+          +0 ^      \d?
+          +3 ^      [A-E]
+          +8 ^^     \*
+         +10 ^ ^
+          0: E*
+
+       The  callout  function  in pcretest returns zero (carry on matching) by
+       default, but you can use a \C item in a data line (as described  above)
+       to change this.
+
+       Inserting  callouts can be helpful when using pcretest to check compli-
+       cated regular expressions. For further information about callouts,  see
+       the pcrecallout documentation.
+
+
+NON-PRINTING CHARACTERS
+
+       When  pcretest is outputting text in the compiled version of a pattern,
+       bytes other than 32-126 are always treated as  non-printing  characters
+       are are therefore shown as hex escapes.
+
+       When  pcretest  is  outputting text that is a matched part of a subject
+       string, it behaves in the same way, unless a different locale has  been
+       set  for  the  pattern  (using  the  /L  modifier).  In  this case, the
+       isprint() function to distinguish printing and non-printing characters.
+
+
+SAVING AND RELOADING COMPILED PATTERNS
+
+       The  facilities  described  in  this section are not available when the
+       POSIX inteface to PCRE is being used, that is, when the /P pattern mod-
+       ifier is specified.
+
+       When the POSIX interface is not in use, you can cause pcretest to write
+       a compiled pattern to a file, by following the modifiers with >  and  a
+       file name.  For example:
+
+         /pattern/im >/some/file
+
+       See  the pcreprecompile documentation for a discussion about saving and
+       re-using compiled patterns.
+
+       The data that is written is binary.  The  first  eight  bytes  are  the
+       length  of  the  compiled  pattern  data  followed by the length of the
+       optional study data, each written as four  bytes  in  big-endian  order
+       (most  significant  byte  first). If there is no study data (either the
+       pattern was not studied, or studying did not return any data), the sec-
+       ond  length  is  zero. The lengths are followed by an exact copy of the
+       compiled pattern. If there is additional study data, this follows imme-
+       diately  after  the  compiled pattern. After writing the file, pcretest
+       expects to read a new pattern.
+
+       A saved pattern can be reloaded into pcretest by specifing < and a file
+       name  instead  of  a pattern. The name of the file must not contain a <
+       character, as otherwise pcretest will interpret the line as  a  pattern
+       delimited by < characters.  For example:
+
+          re> </some/file
+         Compiled regex loaded from /some/file
+         No study data
+
+       When  the pattern has been loaded, pcretest proceeds to read data lines
+       in the usual way.
+
+       You can copy a file written by pcretest to a different host and  reload
+       it  there,  even  if the new host has opposite endianness to the one on
+       which the pattern was compiled. For example, you can compile on an  i86
+       machine and run on a SPARC machine.
+
+       File  names  for  saving and reloading can be absolute or relative, but
+       note that the shell facility of expanding a file name that starts  with
+       a tilde (~) is not available.
+
+       The  ability to save and reload files in pcretest is intended for test-
+       ing and experimentation. It is not intended for production use  because
+       only  a  single pattern can be written to a file. Furthermore, there is
+       no facility for supplying  custom  character  tables  for  use  with  a
+       reloaded  pattern.  If  the  original  pattern was compiled with custom
+       tables, an attempt to match a subject string using a  reloaded  pattern
+       is  likely to cause pcretest to crash.  Finally, if you attempt to load
+       a file that is not in the correct format, the result is undefined.
+
+
+SEE ALSO
+
+       pcre(3), pcreapi(3), pcrecallout(3),  pcrematching(3),  pcrepartial(d),
+       pcrepattern(3), pcreprecompile(3).
+
+
+AUTHOR
+
+       Philip Hazel
+       University Computing Service
+       Cambridge CB2 3QH, England.
+
+
+REVISION
+
+       Last updated: 12 April 2008
+       Copyright (c) 1997-2008 University of Cambridge.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/doc/perltest.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+The perltest program
+--------------------
+
+The perltest program tests Perl's regular expressions; it has the same
+specification as pcretest, and so can be given identical input, except that
+input patterns can be followed only by Perl's lower case modifiers and /+ (as
+used by pcretest), which is recognized and handled by the program.
+
+The data lines are processed as Perl double-quoted strings, so if they contain
+" $ or @ characters, these have to be escaped. For this reason, all such
+characters in testinput1 and testinput4 are escaped so that they can be used
+for perltest as well as for pcretest. The special upper case pattern
+modifiers such as /A that pcretest recognizes, and its special data line
+escapes, are not used in these files. The output should be identical, apart
+from the initial identifying banner.
+
+The perltest script can also test UTF-8 features. It works as is for Perl 5.8
+or higher. It recognizes the special modifier /8 that pcretest uses to invoke
+UTF-8 functionality. The testinput4 file can be fed to perltest to run
+compatible UTF-8 tests.
+
+For Perl 5.6, perltest won't work unmodified for the UTF-8 tests. You need to
+uncomment the "use utf8" lines that it contains. It is best to do this on a
+copy of the script, because for non-UTF-8 tests, these lines should remain
+commented out.
+
+The other testinput files are not suitable for feeding to perltest, since they
+make use of the special upper case modifiers and escapes that pcretest uses to
+test some features of PCRE. Some of these files also contains malformed regular
+expressions, in order to check that PCRE diagnoses them correctly.
+
+Philip Hazel
+September 2004
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/install-sh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,519 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2006-12-25.00
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# 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.
+
+nl='
+'
+IFS=" ""	$nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+	shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
+
+    -o) chowncmd="$chownprog $2"
+	shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+	shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)	shift
+	break;;
+
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dst_arg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+	echo "$0: $dst_arg: Is a directory" >&2
+	exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+	(dirname "$dst") 2>/dev/null ||
+	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	     X"$dst" : 'X\(//\)[^/]' \| \
+	     X"$dst" : 'X\(//\)$' \| \
+	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+	echo X"$dst" |
+	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)[^/].*/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\).*/{
+		   s//\1/
+		   q
+		 }
+		 s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+	# Create intermediate dirs using mode 755 as modified by the umask.
+	# This is like FreeBSD 'install' as of 1997-10-28.
+	umask=`umask`
+	case $stripcmd.$umask in
+	  # Optimize common cases.
+	  *[2367][2367]) mkdir_umask=$umask;;
+	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+	  *[0-7])
+	    mkdir_umask=`expr $umask + 22 \
+	      - $umask % 100 % 40 + $umask % 20 \
+	      - $umask % 10 % 4 + $umask % 2
+	    `;;
+	  *) mkdir_umask=$umask,go-w;;
+	esac
+
+	# With -d, create the new directory with the user-specified mode.
+	# Otherwise, rely on $mkdir_umask.
+	if test -n "$dir_arg"; then
+	  mkdir_mode=-m$mode
+	else
+	  mkdir_mode=
+	fi
+
+	posix_mkdir=false
+	case $umask in
+	  *[123567][0-7][0-7])
+	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
+	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+	    ;;
+	  *)
+	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+	    if (umask $mkdir_umask &&
+		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+	    then
+	      if test -z "$dir_arg" || {
+		   # Check for POSIX incompatibilities with -m.
+		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+		   # other-writeable bit of parent directory when it shouldn't.
+		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+		   case $ls_ld_tmpdir in
+		     d????-?r-*) different_mode=700;;
+		     d????-?--*) different_mode=755;;
+		     *) false;;
+		   esac &&
+		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+		   }
+		 }
+	      then posix_mkdir=:
+	      fi
+	      rmdir "$tmpdir/d" "$tmpdir"
+	    else
+	      # Remove any dirs left behind by ancient mkdir implementations.
+	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+	    fi
+	    trap '' 0;;
+	esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+	umask $mkdir_umask &&
+	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+	/*) prefix='/';;
+	-*) prefix='./';;
+	*)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+	test -z "$d" && continue
+
+	prefix=$prefix$d
+	if test -d "$prefix"; then
+	  prefixes=
+	else
+	  if $posix_mkdir; then
+	    (umask=$mkdir_umask &&
+	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+	    # Don't fail if two instances are running concurrently.
+	    test -d "$prefix" || exit 1
+	  else
+	    case $prefix in
+	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+	      *) qprefix=$prefix;;
+	    esac
+	    prefixes="$prefixes '$qprefix'"
+	  fi
+	fi
+	prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+	# Don't fail if two instances are running concurrently.
+	(umask $mkdir_umask &&
+	 eval "\$doit_exec \$mkdirprog $prefixes") ||
+	  test -d "$dstdir" || exit 1
+	obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # 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 $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
+
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/libpcre.pc.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,12 @@
+# Package Information for pkg-config
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libpcre
+Description: PCRE - Perl compatible regular expressions C library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lpcre
+Cflags: -I${includedir}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/libpcrecpp.pc.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,12 @@
+# Package Information for pkg-config
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libpcrecpp
+Description: PCRECPP - C++ wrapper for PCRE
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lpcre -lpcrecpp
+Cflags: -I${includedir}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/ltmain.sh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,6975 @@
+# 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, 2003, 2004, 2005, 2006,
+# 2007, 2008  Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.
+
+basename="s,^.*/,,g"
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+progname=`echo "$progpath" | $SED $basename`
+modename="$progname"
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.5.26
+TIMESTAMP=" (1.1220.2.493 2008/02/01 16:58:18)"
+
+# Be Bourne compatible (taken from Autoconf:_AS_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+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# 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 "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit $EXIT_SUCCESS
+fi
+
+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'
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  SP2NL='tr \040 \012'
+  NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  SP2NL='tr \100 \n'
+  NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+# 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.
+lt_env=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+	  save_$lt_var=\$$lt_var
+	  lt_env=\"$lt_var=\$$lt_var \$lt_env\"
+	  $lt_var=C
+	  export $lt_var
+	fi"
+done
+
+if test -n "$lt_env"; then
+  lt_env="env $lt_env"
+fi
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" 	$lt_nl"
+
+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 $EXIT_FAILURE
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+duplicate_deps=no
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+#####################################
+# Shell function definitions:
+# This seems to be the best place for them
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+	# Failing that, at least try and use $RANDOM to avoid a race
+	my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+	save_mktempdir_umask=`umask`
+	umask 0077
+	$mkdir "$my_tmpdir"
+	umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || {
+        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
+	exit $EXIT_FAILURE
+      }
+    fi
+
+    $echo "X$my_tmpdir" | $Xsed
+}
+
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
+      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+      win32_nmres=`eval $NM -f posix -A $1 | \
+	$SED -n -e '1,100{
+		/ I /{
+			s,.*,import,
+			p
+			q
+			}
+		}'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $echo $win32_libid_type
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+	case $arg in
+	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	  arg="\"$arg\""
+	  ;;
+	esac
+	CC_quoted="$CC_quoted $arg"
+      done
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+	for z in $available_tags; do
+	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+	    # Evaluate the configuration.
+	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    CC_quoted=
+	    for arg in $CC; do
+	    # Double-quote args containing other shell metacharacters.
+	    case $arg in
+	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	      arg="\"$arg\""
+	      ;;
+	    esac
+	    CC_quoted="$CC_quoted $arg"
+	  done
+	    # user sometimes does CC=<HOST>-gcc so we need to match that to 'gcc'
+	    trimedcc=`echo ${CC} | $SED -e "s/${host}-//g"`
+	    # and sometimes libtool has CC=<HOST>-gcc but user does CC=gcc
+	    extendcc=${host}-${CC}
+	    # and sometimes libtool has CC=<OLDHOST>-gcc but user has CC=<NEWHOST>-gcc  
+	    # (Gentoo-specific hack because we always export $CHOST)
+	    mungedcc=${CHOST-${host}}-${trimedcc}
+	    case "$@ " in
+	      "cc "* | " cc "* | "${host}-cc "* | " ${host}-cc "*|\
+	      "gcc "* | " gcc "* | "${host}-gcc "* | " ${host}-gcc "*)
+	      tagname=CC
+	      break ;;
+	      "$trimedcc "* | " $trimedcc "* | "`$echo $trimedcc` "* | " `$echo $trimedcc` "*|\
+	      "$extendcc "* | " $extendcc "* | "`$echo $extendcc` "* | " `$echo $extendcc` "*|\
+	      "$mungedcc "* | " $mungedcc "* | "`$echo $mungedcc` "* | " `$echo $mungedcc` "*|\
+	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
+	      # The compiler in the base compile command matches
+	      # the one in the tagged configuration.
+	      # Assume this is the tagged configuration we want.
+	      tagname=$z
+	      break
+	      ;;
+	    esac
+	  fi
+	done
+	# If $tagname still isn't set, then no tagged configuration
+	# was found and let the user know that the "--tag" command
+	# line option must be used.
+	if test -z "$tagname"; then
+	  $echo "$modename: unable to infer tagged configuration"
+	  $echo "$modename: specify a tag with \`--tag'" 1>&2
+	  exit $EXIT_FAILURE
+#        else
+#          $echo "$modename: using $tagname tagged configuration"
+	fi
+	;;
+      esac
+    fi
+}
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+
+    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
+    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
+      exit $EXIT_FAILURE
+    fi
+}
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+    my_status=""
+
+    $show "${rm}r $my_gentop"
+    $run ${rm}r "$my_gentop"
+    $show "$mkdir $my_gentop"
+    $run $mkdir "$my_gentop"
+    my_status=$?
+    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
+      exit $my_status
+    fi
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	*) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+	*" $my_xlib_u "*)
+	  extracted_serial=`expr $extracted_serial + 1`
+	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
+	*) break ;;
+	esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
+
+      $show "${rm}r $my_xdir"
+      $run ${rm}r "$my_xdir"
+      $show "$mkdir $my_xdir"
+      $run $mkdir "$my_xdir"
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
+	exit $exit_status
+      fi
+      case $host in
+      *-darwin*)
+	$show "Extracting $my_xabs"
+	# Do not bother doing anything if just a dry run
+	if test -z "$run"; then
+	  darwin_orig_dir=`pwd`
+	  cd $my_xdir || exit $?
+	  darwin_archive=$my_xabs
+	  darwin_curdir=`pwd`
+	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
+	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
+	  if test -n "$darwin_arches"; then 
+	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
+	    darwin_arch=
+	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
+	    for darwin_arch in  $darwin_arches ; do
+	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	      cd "$darwin_curdir"
+	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	    done # $darwin_arches
+      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
+	    darwin_file=
+	    darwin_files=
+	    for darwin_file in $darwin_filelist; do
+	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+	      lipo -create -output "$darwin_file" $darwin_files
+	    done # $darwin_filelist
+	    ${rm}r unfat-$$
+	    cd "$darwin_orig_dir"
+	  else
+	    cd "$darwin_orig_dir"
+ 	    func_extract_an_archive "$my_xdir" "$my_xabs"
+	  fi # $darwin_arches
+	fi # $run
+	;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+        ;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+    done
+    func_extract_archives_result="$my_oldobjs"
+}
+# End of Shell function definitions
+#####################################
+
+# Darwin sucks
+eval std_shrext=\"$shrext_cmds\"
+
+disable_libs=no
+
+# 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"
+      ;;
+    tag)
+      tagname="$arg"
+      preserve_args="${preserve_args}=$arg"
+
+      # Check whether tagname contains only valid characters
+      case $tagname in
+      *[!-_A-Za-z0-9,/]*)
+	$echo "$progname: invalid tag name: $tagname" 1>&2
+	exit $EXIT_FAILURE
+	;;
+      esac
+
+      case $tagname in
+      CC)
+	# Don't test for the "default" C tag, as we know, it's there, but
+	# not specially marked.
+	;;
+      *)
+	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
+	  taglist="$taglist $tagname"
+	  # Evaluate the configuration.
+	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
+	else
+	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
+	fi
+	;;
+      esac
+      ;;
+    *)
+      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
+
+Copyright (C) 2008  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."
+    exit $?
+    ;;
+
+  --config)
+    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
+    done
+    exit $?
+    ;;
+
+  --debug)
+    $echo "$progname: enabling shell trace mode"
+    set -x
+    preserve_args="$preserve_args $arg"
+    ;;
+
+  --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 $?
+    ;;
+
+  --finish) mode="finish" ;;
+
+  --mode) prevopt="--mode" prev=mode ;;
+  --mode=*) mode="$optarg" ;;
+
+  --preserve-dup-deps) duplicate_deps="yes" ;;
+
+  --quiet | --silent)
+    show=:
+    preserve_args="$preserve_args $arg"
+    ;;
+
+  --tag)
+    prevopt="--tag"
+    prev=tag
+    preserve_args="$preserve_args --tag"
+    ;;
+  --tag=*)
+    set tag "$optarg" ${1+"$@"}
+    shift
+    prev=tag
+    preserve_args="$preserve_args --tag"
+    ;;
+
+  -dlopen)
+    prevopt="-dlopen"
+    prev=execute_dlfiles
+    ;;
+
+  -*)
+    $echo "$modename: unrecognized option \`$arg'" 1>&2
+    $echo "$help" 1>&2
+    exit $EXIT_FAILURE
+    ;;
+
+  *)
+    nonopt="$arg"
+    break
+    ;;
+  esac
+done
+
+if test -n "$prevopt"; then
+  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+  $echo "$help" 1>&2
+  exit $EXIT_FAILURE
+fi
+
+case $disable_libs in
+no) 
+  ;;
+shared)
+  build_libtool_libs=no
+  build_old_libs=yes
+  ;;
+static)
+  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+  ;;
+esac
+
+# 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
+    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
+    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
+    case $nonopt in
+    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
+      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 $EXIT_FAILURE
+  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=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+	# do not "continue".  Instead, add this to base_compile
+	lastarg="$arg"
+	arg_mode=normal
+	;;
+
+      target )
+	libobj="$arg"
+	arg_mode=normal
+	continue
+	;;
+
+      normal )
+	# Accept any command-line options.
+	case $arg in
+	-o)
+	  if test -n "$libobj" ; then
+	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+	    exit $EXIT_FAILURE
+	  fi
+	  arg_mode=target
+	  continue
+	  ;;
+
+	-static | -prefer-pic | -prefer-non-pic)
+	  later="$later $arg"
+	  continue
+	  ;;
+
+	-no-suppress)
+	  suppress_opt=no
+	  continue
+	  ;;
+
+	-Xcompiler)
+	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
+	  continue      #  The current "srcfile" will either be retained or
+	  ;;            #  replaced later.  I would guess that would be a bug.
+
+	-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.
+	  base_compile="$base_compile $lastarg"
+	  continue
+	  ;;
+
+	* )
+	  # Accept the current argument as the source file.
+	  # The previous "srcfile" becomes the current argument.
+	  #
+	  lastarg="$srcfile"
+	  srcfile="$arg"
+	  ;;
+	esac  #  case $arg
+	;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+      case $lastarg in
+      # Double-quote args containing other shell metacharacters.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, and some SunOS ksh mistreat backslash-escaping
+      # in scan sets (worked around with variable expansion),
+      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
+      # at all, so we specify them separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	lastarg="\"$lastarg\""
+	;;
+      esac
+
+      base_compile="$base_compile $lastarg"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      $echo "$modename: you must specify an argument for -Xcompile"
+      exit $EXIT_FAILURE
+      ;;
+    target)
+      $echo "$modename: you must specify a target with \`-o'" 1>&2
+      exit $EXIT_FAILURE
+      ;;
+    *)
+      # Get the name of the library object.
+      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    xform='[cCFSifmso]'
+    case $libobj in
+    *.ada) xform=ada ;;
+    *.adb) xform=adb ;;
+    *.ads) xform=ads ;;
+    *.asm) xform=asm ;;
+    *.c++) xform=c++ ;;
+    *.cc) xform=cc ;;
+    *.ii) xform=ii ;;
+    *.class) xform=class ;;
+    *.cpp) xform=cpp ;;
+    *.cxx) xform=cxx ;;
+    *.[fF][09]?) xform=[fF][09]. ;;
+    *.for) xform=for ;;
+    *.java) xform=java ;;
+    *.obj) xform=obj ;;
+    *.sx) xform=sx ;;
+    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 $EXIT_FAILURE
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -static)
+	build_old_libs=yes
+	continue
+	;;
+
+      -prefer-pic)
+	pic_mode=yes
+	continue
+	;;
+
+      -prefer-non-pic)
+	pic_mode=no
+	continue
+	;;
+      esac
+    done
+
+    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
+    case $qlibobj in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	qlibobj="\"$qlibobj\"" ;;
+    esac
+    test "X$libobj" != "X$qlibobj" \
+	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
+	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
+    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+    if test "X$xdir" = "X$obj"; then
+      xdir=
+    else
+      xdir=$xdir/
+    fi
+    lobj=${xdir}$objdir/$objname
+
+    if test -z "$base_compile"; then
+      $echo "$modename: you must specify a compilation command" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    $run $rm $removelist
+    trap "$run $rm $removelist; exit $EXIT_FAILURE" 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 $EXIT_FAILURE" 1 2 15
+    else
+      output_obj=
+      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 "$srcfile" "$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 $EXIT_FAILURE
+      fi
+      $echo "$srcfile" > "$lockfile"
+    fi
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
+    case $qsrcfile in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+      qsrcfile="\"$qsrcfile\"" ;;
+    esac
+
+    $run $rm "$libobj" "${libobj}T"
+
+    # Create a libtool object file (analogous to a ".la" file),
+    # but don't create it if we're doing a dry run.
+    test -z "$run" && cat > ${libobj}T <<EOF
+# $libobj - a libtool object file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+EOF
+
+    # 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
+	command="$base_compile $qsrcfile $pic_flag"
+      else
+	# Don't build PIC code
+	command="$base_compile $qsrcfile"
+      fi
+
+      if test ! -d "${xdir}$objdir"; then
+	$show "$mkdir ${xdir}$objdir"
+	$run $mkdir ${xdir}$objdir
+	exit_status=$?
+	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
+	  exit $exit_status
+	fi
+      fi
+
+      if test -z "$output_obj"; then
+	# Place PIC objects in $objdir
+	command="$command -o $lobj"
+      fi
+
+      $run $rm "$lobj" "$output_obj"
+
+      $show "$command"
+      if $run eval $lt_env "$command"; then :
+      else
+	test -n "$output_obj" && $run $rm $removelist
+	exit $EXIT_FAILURE
+      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 $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+	$show "$mv $output_obj $lobj"
+	if $run $mv $output_obj $lobj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+
+      # Append the name of the PIC object to the libtool object file.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object='$objdir/$objname'
+
+EOF
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+        suppress_output=' >/dev/null 2>&1'
+      fi
+    else
+      # No PIC object so indicate it doesn't exist in the libtool
+      # object file.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object=none
+
+EOF
+    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 $qsrcfile"
+      else
+	command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+	command="$command -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      $run $rm "$obj" "$output_obj"
+      $show "$command"
+      if $run eval $lt_env "$command"; then :
+      else
+	$run $rm $removelist
+	exit $EXIT_FAILURE
+      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 $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && 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
+
+      # Append the name of the non-PIC object the libtool object file.
+      # Only append if the libtool object file exists.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object='$objname'
+
+EOF
+    else
+      # Append the name of the non-PIC object the libtool object file.
+      # Only append if the libtool object file exists.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object=none
+
+EOF
+    fi
+
+    $run $mv "${libobj}T" "${libobj}"
+
+    # Unlock the critical section if it was locked
+    if test "$need_locks" != no; then
+      $run $rm "$lockfile"
+    fi
+
+    exit $EXIT_SUCCESS
+    ;;
+
+  # 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 invocation.
+      # 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"
+    base_compile="$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=
+    non_pic_objects=
+    notinst_path= # paths that contain not-installed libtool libraries
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+    single_module="${wl}-single_module"
+
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -all-static | -static | -static-libtool-libs)
+	case $arg in
+	-all-static)
+	  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
+	  prefer_static_libs=yes
+	  ;;
+	-static)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=built
+	  ;;
+	-static-libtool-libs)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	esac
+	build_libtool_libs=no
+	build_old_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 $EXIT_FAILURE
+	  fi
+	  prev=
+	  continue
+	  ;;
+	expsyms_regex)
+	  export_symbols_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	inst_prefix)
+	  inst_prefix_dir="$arg"
+	  prev=
+	  continue
+	  ;;
+	precious_regex)
+	  precious_files_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	release)
+	  release="-$arg"
+	  prev=
+	  continue
+	  ;;
+	objectlist)
+	  if test -f "$arg"; then
+	    save_arg=$arg
+	    moreargs=
+	    for fil in `cat $save_arg`
+	    do
+#	      moreargs="$moreargs $fil"
+	      arg=$fil
+	      # A libtool-controlled object.
+
+	      # Check to see that this really is a libtool object.
+	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+		pic_object=
+		non_pic_object=
+
+		# Read the .lo file
+		# If there is no directory component, then add one.
+		case $arg in
+		*/* | *\\*) . $arg ;;
+		*) . ./$arg ;;
+		esac
+
+		if test -z "$pic_object" || \
+		   test -z "$non_pic_object" ||
+		   test "$pic_object" = none && \
+		   test "$non_pic_object" = none; then
+		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+		  exit $EXIT_FAILURE
+		fi
+
+		# Extract subdirectory from the argument.
+		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+		if test "X$xdir" = "X$arg"; then
+		  xdir=
+		else
+		  xdir="$xdir/"
+		fi
+
+		if test "$pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  pic_object="$xdir$pic_object"
+
+		  if test "$prev" = dlfiles; then
+		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		      dlfiles="$dlfiles $pic_object"
+		      prev=
+		      continue
+		    else
+		      # If libtool objects are unsupported, then we need to preload.
+		      prev=dlprefiles
+		    fi
+		  fi
+
+		  # CHECK ME:  I think I busted this.  -Ossama
+		  if test "$prev" = dlprefiles; then
+		    # Preload the old-style object.
+		    dlprefiles="$dlprefiles $pic_object"
+		    prev=
+		  fi
+
+		  # A PIC object.
+		  libobjs="$libobjs $pic_object"
+		  arg="$pic_object"
+		fi
+
+		# Non-PIC object.
+		if test "$non_pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  non_pic_object="$xdir$non_pic_object"
+
+		  # A standard non-PIC object
+		  non_pic_objects="$non_pic_objects $non_pic_object"
+		  if test -z "$pic_object" || test "$pic_object" = none ; then
+		    arg="$non_pic_object"
+		  fi
+		else
+		  # If the PIC object exists, use it instead.
+		  # $xdir was prepended to $pic_object above.
+		  non_pic_object="$pic_object"
+		  non_pic_objects="$non_pic_objects $non_pic_object"
+		fi
+	      else
+		# Only an error if not doing a dry-run.
+		if test -z "$run"; then
+		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+		  exit $EXIT_FAILURE
+		else
+		  # Dry-run case.
+
+		  # Extract subdirectory from the argument.
+		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+		  if test "X$xdir" = "X$arg"; then
+		    xdir=
+		  else
+		    xdir="$xdir/"
+		  fi
+
+		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+		  libobjs="$libobjs $pic_object"
+		  non_pic_objects="$non_pic_objects $non_pic_object"
+		fi
+	      fi
+	    done
+	  else
+	    $echo "$modename: link input file \`$save_arg' does not exist"
+	    exit $EXIT_FAILURE
+	  fi
+	  arg=$save_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 $EXIT_FAILURE
+	    ;;
+	  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
+	  ;;
+	xcclinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  compile_command="$compile_command $qarg"
+	  finalize_command="$finalize_command $qarg"
+	  continue
+	  ;;
+	shrext)
+  	  shrext_cmds="$arg"
+	  prev=
+	  continue
+	  ;;
+	darwin_framework|darwin_framework_skip)
+	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
+	  compile_command="$compile_command $arg"
+	  finalize_command="$finalize_command $arg"
+	  prev=
+	  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 $EXIT_FAILURE
+	fi
+	if test "X$arg" = "X-export-symbols"; then
+	  prev=expsyms
+	else
+	  prev=expsyms_regex
+	fi
+	continue
+	;;
+
+      -framework|-arch|-isysroot)
+	case " $CC " in
+	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
+		prev=darwin_framework_skip ;;
+	  *) compiler_flags="$compiler_flags $arg"
+	     prev=darwin_framework ;;
+	esac
+	compile_command="$compile_command $arg"
+	finalize_command="$finalize_command $arg"
+	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* | /*-*-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
+	    absdir="$dir"
+	    notinst_path="$notinst_path $dir"
+	  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*)
+	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$dir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$dir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+	continue
+	;;
+
+      -l*)
+	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
+	    # These systems don't actually have a C or math library (as such)
+	    continue
+	    ;;
+	  *-*-os2*)
+	    # These systems don't actually have a C library (as such)
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C and math libraries are in the System framework
+	    deplibs="$deplibs -framework System"
+	    continue
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  esac
+	elif test "X$arg" = "X-lc_r"; then
+	 case $host in
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	   # Do not include libc_r directly, use -pthread flag.
+	   continue
+	   ;;
+	 esac
+	fi
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      -model)
+	compile_command="$compile_command $arg"
+	compiler_flags="$compiler_flags $arg"
+	finalize_command="$finalize_command $arg"
+	prev=xcompiler
+	continue
+	;;
+
+     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	compiler_flags="$compiler_flags $arg"
+	compile_command="$compile_command $arg"
+	finalize_command="$finalize_command $arg"
+	continue
+	;;
+
+      -multi_module)
+	single_module="${wl}-multi_module"
+	continue
+	;;
+
+      -module)
+	module=yes
+	continue
+	;;
+
+      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+      # -r[0-9][0-9]* specifies the processor on the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+      # +DA*, +DD* enable 64-bit mode on the HP compiler
+      # -q* pass through compiler args for the IBM compiler
+      # -m* pass through architecture-specific compiler args for GCC
+      # -m*, -t[45]*, -txscale* pass through architecture-specific
+      # compiler args for GCC
+      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
+      # -F/path gives path to uninstalled frameworks, gcc on darwin
+      # @file GCC response files
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
+
+	# 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
+        compile_command="$compile_command $arg"
+        finalize_command="$finalize_command $arg"
+        compiler_flags="$compiler_flags $arg"
+        continue
+        ;;
+
+      -shrext)
+	prev=shrext
+	continue
+	;;
+
+      -no-fast-install)
+	fast_install=no
+	continue
+	;;
+
+      -no-install)
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
+	  # The PATH hackery in wrapper scripts is required on Windows
+	  # and Darwin 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
+	;;
+
+      -objectlist)
+	prev=objectlist
+	continue
+	;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+	prev=precious_regex
+	continue
+	;;
+
+      -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 $EXIT_FAILURE
+	  ;;
+	esac
+	case "$xrpath " in
+	*" $dir "*) ;;
+	*) xrpath="$xrpath $dir" ;;
+	esac
+	continue
+	;;
+
+      -static | -static-libtool-libs)
+	# 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
+	;;
+      -version-number)
+	prev=vinfo
+	vinfo_number=yes
+	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
+	;;
+
+      -XCClinker)
+	prev=xcclinker
+	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
+	;;
+
+      *.$objext)
+	# A standard object.
+	objs="$objs $arg"
+	;;
+
+      *.lo)
+	# A libtool-controlled object.
+
+	# Check to see that this really is a libtool object.
+	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	  pic_object=
+	  non_pic_object=
+
+	  # Read the .lo file
+	  # If there is no directory component, then add one.
+	  case $arg in
+	  */* | *\\*) . $arg ;;
+	  *) . ./$arg ;;
+	  esac
+
+	  if test -z "$pic_object" || \
+	     test -z "$non_pic_object" ||
+	     test "$pic_object" = none && \
+	     test "$non_pic_object" = none; then
+	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+	    exit $EXIT_FAILURE
+	  fi
+
+	  # Extract subdirectory from the argument.
+	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+	  if test "X$xdir" = "X$arg"; then
+	    xdir=
+ 	  else
+	    xdir="$xdir/"
+	  fi
+
+	  if test "$pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    pic_object="$xdir$pic_object"
+
+	    if test "$prev" = dlfiles; then
+	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		dlfiles="$dlfiles $pic_object"
+		prev=
+		continue
+	      else
+		# If libtool objects are unsupported, then we need to preload.
+		prev=dlprefiles
+	      fi
+	    fi
+
+	    # CHECK ME:  I think I busted this.  -Ossama
+	    if test "$prev" = dlprefiles; then
+	      # Preload the old-style object.
+	      dlprefiles="$dlprefiles $pic_object"
+	      prev=
+	    fi
+
+	    # A PIC object.
+	    libobjs="$libobjs $pic_object"
+	    arg="$pic_object"
+	  fi
+
+	  # Non-PIC object.
+	  if test "$non_pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    non_pic_object="$xdir$non_pic_object"
+
+	    # A standard non-PIC object
+	    non_pic_objects="$non_pic_objects $non_pic_object"
+	    if test -z "$pic_object" || test "$pic_object" = none ; then
+	      arg="$non_pic_object"
+	    fi
+	  else
+	    # If the PIC object exists, use it instead.
+	    # $xdir was prepended to $pic_object above.
+	    non_pic_object="$pic_object"
+	    non_pic_objects="$non_pic_objects $non_pic_object"
+	  fi
+	else
+	  # Only an error if not doing a dry-run.
+	  if test -z "$run"; then
+	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+	    exit $EXIT_FAILURE
+	  else
+	    # Dry-run case.
+
+	    # Extract subdirectory from the argument.
+	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+	    if test "X$xdir" = "X$arg"; then
+	      xdir=
+	    else
+	      xdir="$xdir/"
+	    fi
+
+	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+	    libobjs="$libobjs $pic_object"
+	    non_pic_objects="$non_pic_objects $non_pic_object"
+	  fi
+	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 $EXIT_FAILURE
+    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
+
+    oldlibs=
+    # 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
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
+	exit $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 $EXIT_FAILURE
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    case $host in
+    *cygwin* | *mingw* | *pw32*)
+      # don't eliminate duplications in $postdeps and $predeps
+      duplicate_compiler_generated_deps=yes
+      ;;
+    *)
+      duplicate_compiler_generated_deps=$duplicate_deps
+      ;;
+    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_compiler_generated_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
+    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 $EXIT_FAILURE
+	    ;;
+	  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,$pass" = "lib,link" ||
+	 test "$linkmode,$pass" = "prog,scan"; then
+	libs="$deplibs"
+	deplibs=
+      fi
+      if test "$linkmode" = prog; then
+	case $pass in
+	dlopen) libs="$dlfiles" ;;
+	dlpreopen) libs="$dlprefiles" ;;
+	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+	esac
+      fi
+      if test "$pass" = dlopen; then
+	# Collect dlpreopened libraries
+	save_deplibs="$deplibs"
+	deplibs=
+      fi
+      for deplib in $libs; do
+	lib=
+	found=no
+	case $deplib in
+	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    compiler_flags="$compiler_flags $deplib"
+	  fi
+	  continue
+	  ;;
+	-l*)
+	  if test "$linkmode" != lib && test "$linkmode" != prog; then
+	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
+	    continue
+	  fi
+	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
+	  if test "$linkmode" = lib; then
+	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+	  else
+	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+	  fi
+	  for searchdir in $searchdirs; do
+	    for search_ext in .la $std_shrext .so .a; do
+	      # Search the libtool library
+	      lib="$searchdir/lib${name}${search_ext}"
+	      if test -f "$lib"; then
+		if test "$search_ext" = ".la"; then
+		  found=yes
+		else
+		  found=no
+		fi
+		break 2
+	      fi
+	    done
+	  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
+	  else # deplib is a libtool library
+	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+	    # We need to do some special things here, and not later.
+	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      case " $predeps $postdeps " in
+	      *" $deplib "*)
+		if (${SED} -e '2q' $lib |
+                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+		  library_names=
+		  old_library=
+		  case $lib in
+		  */* | *\\*) . $lib ;;
+		  *) . ./$lib ;;
+		  esac
+		  for l in $old_library $library_names; do
+		    ll="$l"
+		  done
+		  if test "X$ll" = "X$old_library" ; then # only static version available
+		    found=no
+		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+		    test "X$ladir" = "X$lib" && ladir="."
+		    lib=$ladir/$old_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
+		fi
+	        ;;
+	      *) ;;
+	      esac
+	    fi
+	  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"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+	    ;;
+	  *)
+	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 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)
+	    valid_a_lib=no
+	    case $deplibs_check_method in
+	      match_pattern*)
+		set dummy $deplibs_check_method
+	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+		if eval $echo \"$deplib\" 2>/dev/null \
+		    | $SED 10q \
+		    | $EGREP "$match_pattern_regex" > /dev/null; then
+		  valid_a_lib=yes
+		fi
+		;;
+	      pass_all)
+		valid_a_lib=yes
+		;;
+            esac
+	    if test "$valid_a_lib" != yes; then
+	      $echo
+	      $echo "*** Warning: Trying to link with static lib archive $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"
+	      $echo "*** because the file extensions .$libext of this argument makes me believe"
+	      $echo "*** that it is just a static archive that I should not used here."
+	    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" = conv; then
+	    deplibs="$deplib $deplibs"
+	  elif test "$linkmode" = prog; then
+	    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
+	  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' or unhandled argument \`$deplib'" 1>&2
+	  exit $EXIT_FAILURE
+	fi
+
+	# Check to see that this really is a libtool archive.
+	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+	else
+	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+	  exit $EXIT_FAILURE
+	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 variables installed, or shouldnotlink
+	installed=yes
+	shouldnotlink=no
+	avoidtemprpath=
+
+
+	# Read the .la file
+	case $lib in
+	*/* | *\\*) . $lib ;;
+	*) . ./$lib ;;
+	esac
+
+	if test "$linkmode,$pass" = "lib,link" ||
+	   test "$linkmode,$pass" = "prog,scan" ||
+	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	  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 $EXIT_FAILURE
+	    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 $EXIT_FAILURE
+	  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 $EXIT_FAILURE
+	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 $EXIT_FAILURE
+	  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.  We also need to preload any
+	    # dependent libraries so libltdl's deplib preloader doesn't
+	    # bomb out in the load deplibs phase.
+	    dlprefiles="$dlprefiles $lib $dependency_libs"
+	  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
+	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	else
+	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  else
+	    dir="$ladir/$objdir"
+	    absdir="$abs_ladir/$objdir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  fi
+	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 $EXIT_FAILURE
+	  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" # used for prog,scan pass
+	  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...
+
+	if test "$linkmode,$pass" = "prog,link"; then
+	  if test -n "$library_names" &&
+	     { { test "$prefer_static_libs" = no ||
+		 test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	       test -z "$old_library"; }; then
+	    # We need to hardcode the library path
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	      # Make sure the rpath contains only unique directories.
+	      case "$temp_rpath " in
+	      *" $dir "*) ;;
+	      *" $absdir "*) ;;
+	      *) temp_rpath="$temp_rpath $absdir" ;;
+	      esac
+	    fi
+
+	    # 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
+	  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
+	fi
+
+	link_static=no # Whether the deplib will be linked statically
+	use_static_libs=$prefer_static_libs
+	if test "$use_static_libs" = built && test "$installed" = yes ; then
+	  use_static_libs=no
+	fi
+	if test -n "$library_names" &&
+	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	  if test "$installed" = no; then
+	    notinst_deplibs="$notinst_deplibs $lib"
+	    need_relink=yes
+	  fi
+	  # This is a shared library
+
+	  # Warn about portability, can't link against -module's on
+	  # some systems (darwin)
+	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
+	    $echo
+	    if test "$linkmode" = prog; then
+	      $echo "*** Warning: Linking the executable $output against the loadable module"
+	    else
+	      $echo "*** Warning: Linking the shared library $output against the loadable module"
+	    fi
+	    $echo "*** $linklib is not portable!"
+	  fi
+	  if 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
+	  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* | mingw*)
+		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='~'
+	      cmds=$extract_expsyms_cmds
+	      for cmd in $cmds; do
+		IFS="$save_ifs"
+		eval cmd=\"$cmd\"
+		$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='~'
+	      cmds=$old_archive_from_expsyms_cmds
+	      for cmd in $cmds; do
+		IFS="$save_ifs"
+		eval cmd=\"$cmd\"
+		$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"
+		case $host in
+		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+		    *-*-unixware7*) add_dir="-L$dir" ;;
+		  *-*-darwin* )
+		    # if the lib is a module then we can not link against
+		    # it, someone is ignoring the new warnings I added
+		    if /usr/bin/file -L $add 2> /dev/null |
+                      $EGREP ": [^:]* bundle" >/dev/null ; then
+		      $echo "** Warning, lib $linklib is a module, not a shared library"
+		      if test -z "$old_library" ; then
+		        $echo
+		        $echo "** And there doesn't seem to be a static archive available"
+		        $echo "** The link will probably fail, sorry"
+		      else
+		        add="$dir/$old_library"
+		      fi
+		    fi
+		esac
+	      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"
+		# Try looking first in the location we're being installed to.
+		if test -n "$inst_prefix_dir"; then
+		  case $libdir in
+		    [\\/]*)
+		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		      ;;
+		  esac
+		fi
+		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 $EXIT_FAILURE
+	    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
+	      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"
+	    elif test "$hardcode_automatic" = yes; then
+	      if test -n "$inst_prefix_dir" &&
+		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
+	        add="$inst_prefix_dir$libdir/$linklib"
+	      else
+	        add="$libdir/$linklib"
+	      fi
+	    else
+	      # We cannot seem to hardcode it, guess we'll fake it.
+	      add_dir="-L$libdir"
+	      # Try looking first in the location we're being installed to.
+	      if test -n "$inst_prefix_dir"; then
+		case $libdir in
+		  [\\/]*)
+		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		    ;;
+		esac
+	      fi
+	      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
+	  # 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 system can not link to static lib archive $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 "*** But as you try to build a module library, libtool will still create "
+	      $echo "*** a static module, that should work as long as the dlopening application"
+	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+	      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
+	    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="$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 $EXIT_FAILURE
+		  fi
+		  if test "$absdir" != "$libdir"; then
+		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
+		  fi
+		  path="$absdir"
+		fi
+		depdepl=
+		case $host in
+		*-*-darwin*)
+		  # we do not want to link against static libs,
+		  # but need to link against shared
+		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names" ; then
+		    for tmp in $deplibrary_names ; do
+		      depdepl=$tmp
+		    done
+		    if test -f "$deplibdir/$depdepl" ; then
+		      depdepl="$deplibdir/$depdepl"
+	      	    elif test -f "$path/$depdepl" ; then
+		      depdepl="$path/$depdepl"
+		    else
+		      # Can't find it, oh well...
+		      depdepl=
+		    fi
+		    # do not add paths which are already there
+		    case " $newlib_search_path " in
+		    *" $path "*) ;;
+		    *) newlib_search_path="$newlib_search_path $path";;
+		    esac
+		  fi
+		  path=""
+		  ;;
+		*)
+		  path="-L$path"
+		  ;;
+		esac
+		;;
+	      -l*)
+		case $host in
+		*-*-darwin*)
+		  # Again, we only want to link against shared libraries
+		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
+		  for tmp in $newlib_search_path ; do
+		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
+		      eval depdepl="$tmp/lib$tmp_libs.dylib"
+		      break
+		    fi
+		  done
+		  path=""
+		  ;;
+		*) continue ;;
+		esac
+		;;
+	      *) continue ;;
+	      esac
+	      case " $deplibs " in
+	      *" $path "*) ;;
+	      *) deplibs="$path $deplibs" ;;
+	      esac
+	      case " $deplibs " in
+	      *" $depdepl "*) ;;
+	      *) deplibs="$depdepl $deplibs" ;;
+	      esac
+	    done
+	  fi # link_all_deplibs != no
+	fi # linkmode = lib
+      done # for deplib in $libs
+      dependency_libs="$newdependency_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
+	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
+	    # FIXME: Pedantically, this is the right thing to do, so
+	    #        that some nasty dependency loop isn't accidentally
+	    #        broken:
+	    #new_libs="$deplib $new_libs"
+	    # Pragmatically, this seems to cause very few problems in
+	    # practice:
+	    case $deplib in
+	    -L*) new_libs="$deplib $new_libs" ;;
+	    -R*) ;;
+	    *)
+	      # And here is the reason: when a library appears more
+	      # than once as an explicit dependence of a library, or
+	      # is implicitly linked in more than once by the
+	      # compiler, it is considered special, and multiple
+	      # occurrences thereof are not removed.  Compare this
+	      # with having the same library being listed as a
+	      # dependency of multiple other libraries: in this case,
+	      # we know (pedantically, we assume) the library does not
+	      # need to be listed more than once, so we keep only the
+	      # last copy.  This is not always right, but it is rare
+	      # enough that we require users that really mean to play
+	      # such unportable linking tricks to link the library
+	      # using -Wl,-lname, so that libtool does not consider it
+	      # for duplicate removal.
+	      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
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+	case " $predeps $postdeps $compiler_lib_search_path " in
+	*" $i "*)
+	  i=""
+	  ;;
+	esac
+	if test -n "$i" ; then
+	  tmp_libs="$tmp_libs $i"
+	fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;;
+      esac
+
+      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/-version-number' 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 shared_ext=\"$shrext_cmds\"
+	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 $EXIT_FAILURE
+	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 shared_ext=\"$shrext_cmds\"
+	  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 $EXIT_FAILURE
+	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.
+	  # Some compilers have problems with a `.al' extension so
+	  # convenience libraries should have the same extension an
+	  # archive normally would.
+	  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/-version-number' 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 $EXIT_FAILURE
+	fi
+
+	# convert absolute version numbers to libtool ages
+	# this retains compatibility with .la files and attempts
+	# to make the code below a bit more comprehensible
+
+	case $vinfo_number in
+	yes)
+	  number_major="$2"
+	  number_minor="$3"
+	  number_revision="$4"
+	  #
+	  # There are really only two kinds -- those that
+	  # use the current revision as the major version
+	  # and those that subtract age and use age as
+	  # a minor version.  But, then there is irix
+	  # which has an extra 1 added just for fun
+	  #
+	  case $version_type in
+	  darwin|linux|osf|windows|none)
+	    current=`expr $number_major + $number_minor`
+	    age="$number_minor"
+	    revision="$number_revision"
+	    ;;
+	  freebsd-aout|freebsd-elf|sunos)
+	    current="$number_major"
+	    revision="$number_minor"
+	    age="0"
+	    ;;
+	  irix|nonstopux)
+	    current=`expr $number_major + $number_minor`
+	    age="$number_minor"
+	    revision="$number_minor"
+	    lt_irix_increment=no
+	    ;;
+	  esac
+	  ;;
+	no)
+	  current="$2"
+	  revision="$3"
+	  age="$4"
+	  ;;
+	esac
+
+	# Check that each of the things are valid numbers.
+	case $current in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit $EXIT_FAILURE
+	  ;;
+	esac
+
+	case $revision in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit $EXIT_FAILURE
+	  ;;
+	esac
+
+	case $age in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit $EXIT_FAILURE
+	  ;;
+	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 $EXIT_FAILURE
+	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`
+	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+	  ;;
+
+	freebsd-aout)
+	  major=".$current"
+	  versuffix=".$current.$revision";
+	  ;;
+
+	freebsd-elf)
+	  major=".$current"
+	  versuffix=".$current";
+	  ;;
+
+	irix | nonstopux)
+	  if test "X$lt_irix_increment" = "Xno"; then
+	    major=`expr $current - $age`
+	  else
+	    major=`expr $current - $age + 1`
+	  fi
+	  case $version_type in
+	    nonstopux) verstring_prefix=nonstopux ;;
+	    *)         verstring_prefix=sgi ;;
+	  esac
+	  verstring="$verstring_prefix$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="$verstring_prefix$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 $EXIT_FAILURE
+	  ;;
+	esac
+
+	# Clear the version info if we defaulted, and they specified a release.
+	if test -z "$vinfo" && test -n "$release"; then
+	  major=
+	  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, but don't remove object files since they
+	# may have been created when compiling PIC objects.
+	removelist=
+	tempremovelist=`$echo "$output_objdir/*"`
+	for p in $tempremovelist; do
+	  case $p in
+	    *.$objext)
+	       ;;
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+	       if test "X$precious_files_regex" != "X"; then
+	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+	         then
+		   continue
+		 fi
+	       fi
+	       removelist="$removelist $p"
+	       ;;
+	    *) ;;
+	  esac
+	done
+	if test -n "$removelist"; then
+	  $show "${rm}r $removelist"
+	  $run ${rm}r $removelist
+	fi
+      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* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    ;;
+ 	  *)
+	    # 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 behavior.
+	  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
+	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; 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 "$name" != "" && test "$name" != "0"; then
+		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  case " $predeps $postdeps " in
+		  *" $i "*)
+		    newdeplibs="$newdeplibs $i"
+		    i=""
+		    ;;
+		  esac
+	        fi
+		if test -n "$i" ; 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: dynamic linker does not accept needed library $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 I believe you do not have"
+		    $echo "*** because a test_compile did reveal that the linker did not use it for"
+		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
+		  fi
+		fi
+	      else
+		newdeplibs="$newdeplibs $i"
+	      fi
+	    done
+	  else
+	    # Error occurred in the first compile.  Let's try to salvage
+	    # the situation: Compile a separate 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 "$name" != "" && test "$name" != "0"; then
+		$rm conftest
+		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+		  ldd_output=`ldd conftest`
+		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		    case " $predeps $postdeps " in
+		    *" $i "*)
+		      newdeplibs="$newdeplibs $i"
+		      i=""
+		      ;;
+		    esac
+		  fi
+		  if test -n "$i" ; 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: dynamic linker does not accept needed library $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"
+		      $echo "*** because a test_compile did reveal that the linker did not use this one"
+		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+		    fi
+		  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 "$name" != "" && test  "$name" != "0"; then
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; 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
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$echo
+		$echo "*** Warning: linker path does not have real file for library $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"
+		$echo "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
+		else
+		  $echo "*** with $libname and none of the candidates passed a file format test"
+		  $echo "*** using a file magic. Last file checked: $potlib"
+		fi
+	      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
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; 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
+		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    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
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$echo
+		$echo "*** Warning: linker path does not have real file for library $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"
+		$echo "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
+		else
+		  $echo "*** with $libname and none of the candidates passed a file format test"
+		  $echo "*** using a regex pattern. Last file checked: $potlib"
+		fi
+	      fi
+	    else
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	    fi
+	  done # Gone through all deplibs.
+	  ;;
+	none | unknown | *)
+	  newdeplibs=""
+	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+	    -e 's/ -[LR][^ ]*//g'`
+	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    for i in $predeps $postdeps ; do
+	      # can't use Xsed below, because $i might contain '/'
+	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
+	    done
+	  fi
+	  if $echo "X $tmp_deplibs" | $Xsed -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
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      deplibs="$new_libs"
+
+
+      # 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"
+	    if test -n "$hardcode_libdir_flag_spec_ld"; then
+	      case $archive_cmds in
+	      *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;;
+	      *)      eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;;
+	      esac
+	    else
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+	    fi
+	  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 shared_ext=\"$shrext_cmds\"
+	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
+	if test -z "$dlname"; then
+	  dlname=$soname
+	fi
+
+	lib="$output_objdir/$realname"
+	linknames=
+	for link
+	do
+	  linknames="$linknames $link"
+	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
+	    cmds=$export_symbols_cmds
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      eval cmd=\"$cmd\"
+	      if len=`expr "X$cmd" : ".*"` &&
+	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	        $show "$cmd"
+	        $run eval "$cmd" || exit $?
+	        skipped_export=false
+	      else
+	        # The command line is too long to execute in one step.
+	        $show "using reloadable object file for export list..."
+	        skipped_export=:
+		# Break out early, otherwise skipped_export may be
+		# set to false by a later but shorter cmd.
+		break
+	      fi
+	    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
+
+	tmp_deplibs=
+	for test_deplib in $deplibs; do
+		case " $convenience " in
+		*" $test_deplib "*) ;;
+		*)
+			tmp_deplibs="$tmp_deplibs $test_deplib"
+			;;
+		esac
+	done
+	deplibs="$tmp_deplibs"
+
+	if test -n "$convenience"; then
+	  if test -n "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	  else
+	    gentop="$output_objdir/${outputname}x"
+	    generated="$generated $gentop"
+
+	    func_extract_archives $gentop $convenience
+	    libobjs="$libobjs $func_extract_archives_result"
+	  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 "$module" = yes && test -n "$module_cmds" ; then
+	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	    eval test_cmds=\"$module_expsym_cmds\"
+	    cmds=$module_expsym_cmds
+	  else
+	    eval test_cmds=\"$module_cmds\"
+	    cmds=$module_cmds
+	  fi
+	else
+	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	  eval test_cmds=\"$archive_expsym_cmds\"
+	  cmds=$archive_expsym_cmds
+	else
+	  eval test_cmds=\"$archive_cmds\"
+	  cmds=$archive_cmds
+	  fi
+	fi
+
+	if test "X$skipped_export" != "X:" &&
+	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  :
+	else
+	  # The command line is too long to link in one step, link piecewise.
+	  $echo "creating reloadable object files..."
+
+	  # Save the value of $output and $libobjs because we want to
+	  # use them later.  If we have whole_archive_flag_spec, we
+	  # want to use save_libobjs as it was before
+	  # whole_archive_flag_spec was expanded, because we can't
+	  # assume the linker understands whole_archive_flag_spec.
+	  # This may have to be revisited, in case too many
+	  # convenience libraries get linked in and end up exceeding
+	  # the spec.
+	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	  fi
+	  save_output=$output
+	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
+
+	  # Clear the reloadable object creation command queue and
+	  # initialize k to one.
+	  test_cmds=
+	  concat_cmds=
+	  objlist=
+	  delfiles=
+	  last_robj=
+	  k=1
+	  output=$output_objdir/$output_la-${k}.$objext
+	  # Loop over the list of objects to be linked.
+	  for obj in $save_libobjs
+	  do
+	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
+	    if test "X$objlist" = X ||
+	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+		 test "$len" -le "$max_cmd_len"; }; then
+	      objlist="$objlist $obj"
+	    else
+	      # The command $test_cmds is almost too long, add a
+	      # command to the queue.
+	      if test "$k" -eq 1 ; then
+		# The first file doesn't have a previous command to add.
+		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+	      else
+		# All subsequent reloadable object files will link in
+		# the last one created.
+		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
+	      fi
+	      last_robj=$output_objdir/$output_la-${k}.$objext
+	      k=`expr $k + 1`
+	      output=$output_objdir/$output_la-${k}.$objext
+	      objlist=$obj
+	      len=1
+	    fi
+	  done
+	  # Handle the remaining objects by creating one last
+	  # reloadable object file.  All subsequent reloadable object
+	  # files will link in the last one created.
+	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+
+	  if ${skipped_export-false}; then
+	    $show "generating symbol list for \`$libname.la'"
+	    export_symbols="$output_objdir/$libname.exp"
+	    $run $rm $export_symbols
+	    libobjs=$output
+	    # Append the command to create the export file.
+	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
+          fi
+
+	  # Set up a command to remove the reloadable object files
+	  # after they are used.
+	  i=0
+	  while test "$i" -lt "$k"
+	  do
+	    i=`expr $i + 1`
+	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
+	  done
+
+	  $echo "creating a temporary reloadable object file: $output"
+
+	  # Loop through the commands generated above and execute them.
+	  save_ifs="$IFS"; IFS='~'
+	  for cmd in $concat_cmds; do
+	    IFS="$save_ifs"
+	    $show "$cmd"
+	    $run eval "$cmd" || exit $?
+	  done
+	  IFS="$save_ifs"
+
+	  libobjs=$output
+	  # Restore the value of output.
+	  output=$save_output
+
+	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	  fi
+	  # Expand the library linking commands again to reset the
+	  # value of $libobjs for piecewise linking.
+
+	  # Do each of the archive commands.
+	  if test "$module" = yes && test -n "$module_cmds" ; then
+	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	      cmds=$module_expsym_cmds
+	    else
+	      cmds=$module_cmds
+	    fi
+	  else
+	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	    cmds=$archive_expsym_cmds
+	  else
+	    cmds=$archive_cmds
+	    fi
+	  fi
+
+	  # Append the command to remove the reloadable object files
+	  # to the just-reset $cmds.
+	  eval cmds=\"\$cmds~\$rm $delfiles\"
+	fi
+	save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  eval cmd=\"$cmd\"
+	  $show "$cmd"
+	  $run eval "$cmd" || {
+	    lt_exit=$?
+
+	    # Restore the uninstalled library and exit
+	    if test "$mode" = relink; then
+	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
+	    fi
+
+	    exit $lt_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 $?
+
+	  if test -n "$convenience"; then
+	    if test -z "$whole_archive_flag_spec"; then
+	      $show "${rm}r $gentop"
+	      $run ${rm}r "$gentop"
+	    fi
+	  fi
+
+	  exit $EXIT_SUCCESS
+	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)
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;;
+      esac
+
+      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 $EXIT_FAILURE
+	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 and hope we can get by with
+      # turning comma into space..
+      wl=
+
+      if test -n "$convenience"; then
+	if test -n "$whole_archive_flag_spec"; then
+	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+	  reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
+	else
+	  gentop="$output_objdir/${obj}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $convenience
+	  reload_conv_objs="$reload_objs $func_extract_archives_result"
+	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"
+      cmds=$reload_cmds
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+	IFS="$save_ifs"
+	eval cmd=\"$cmd\"
+	$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 $EXIT_SUCCESS
+      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 $EXIT_SUCCESS
+      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"
+	cmds=$reload_cmds
+	save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  eval cmd=\"$cmd\"
+	  $show "$cmd"
+	  $run eval "$cmd" || exit $?
+	done
+	IFS="$save_ifs"
+      fi
+
+      if test -n "$gentop"; then
+	$show "${rm}r $gentop"
+	$run ${rm}r $gentop
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    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
+
+      case $host in
+      *darwin*)
+        # Don't allow lazy linking, it breaks C++ global constructors
+        if test "$tagname" = CXX ; then
+        compile_command="$compile_command ${wl}-bind_at_load"
+        finalize_command="$finalize_command ${wl}-bind_at_load"
+        fi
+        ;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $compile_deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $compile_deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      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*)
+	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$libdir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$libdir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  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/$outputname.exp"
+	      $run $rm $export_symbols
+	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+              case $host in
+              *cygwin* | *mingw* )
+	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+                ;;
+              esac
+	    else
+	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+	      $run eval 'mv "$nlist"T "$nlist"'
+              case $host in
+              *cygwin* | *mingw* )
+	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+                ;;
+              esac
+	    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" |
+		if sort -k 3 </dev/null >/dev/null 2>&1; then
+		  sort -k 3
+		else
+		  sort +2
+		fi |
+		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. */
+"
+
+	    case $host in
+	    *cygwin* | *mingw* )
+	  $echo >> "$output_objdir/$dlsyms" "\
+/* DATA imports from DLLs on WIN32 can't be const, because
+   runtime relocations are performed -- see ld's documentation
+   on pseudo-relocs */
+struct {
+"
+	      ;;
+	    * )
+	  $echo >> "$output_objdir/$dlsyms" "\
+const struct {
+"
+	      ;;
+	    esac
+
+
+	  $echo >> "$output_objdir/$dlsyms" "\
+  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 -DFREEBSD_WORKAROUND";;
+	    esac;;
+	  *-*-hpux*)
+	    case "$compile_command " in
+	    *" -static "*) ;;
+	    *) pic_flag_for_symtable=" $pic_flag";;
+	    esac
+	  esac
+
+	  # Now compile the dynamic symbol file.
+	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -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.
+          case $host in
+          *cygwin* | *mingw* )
+            if test -f "$output_objdir/${outputname}.def" ; then
+              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
+              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
+            else
+              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+             fi
+            ;;
+          * )
+            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+            ;;
+          esac
+	  ;;
+	*)
+	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+	  exit $EXIT_FAILURE
+	  ;;
+	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" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
+	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
+      fi
+
+      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+	# Replace the output file specification.
+	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
+	link_command="$compile_command$compile_rpath"
+
+	# We have no uninstalled library dependencies, so finalize right now.
+	$show "$link_command"
+	$run eval "$link_command"
+	exit_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 $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 $EXIT_SUCCESS
+      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" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
+	  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" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
+      fi
+
+      # Quote $echo for shipping.
+      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
+	case $progpath in
+	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+	*) qecho="$SHELL `pwd`/$progpath --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
+	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
+	  *) exeext= ;;
+	esac
+	case $host in
+	  *cygwin* | *mingw* )
+            output_name=`basename $output`
+            output_path=`dirname $output`
+            cwrappersource="$output_path/$objdir/lt-$output_name.c"
+            cwrapper="$output_path/$output_name.exe"
+            $rm $cwrappersource $cwrapper
+            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+	    cat > $cwrappersource <<EOF
+
+/* $cwrappersource - temporary wrapper executable 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 executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+
+   Currently, it simply execs the wrapper *script* "/bin/sh $output",
+   but could eventually absorb all of the scripts functionality and
+   exec $objdir/$outputname directly.
+*/
+EOF
+	    cat >> $cwrappersource<<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+/* -DDEBUG is fairly common in CFLAGS.  */
+#undef DEBUG
+#if defined DEBUGWRAPPER
+# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
+#else
+# define DEBUG(format, ...)
+#endif
+
+const char *program_name = NULL;
+
+void * xmalloc (size_t num);
+char * xstrdup (const char *string);
+const char * base_name (const char *name);
+char * find_executable(const char *wrapper);
+int    check_executable(const char *path);
+char * strendzap(char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  DEBUG("(main) argv[0]      : %s\n",argv[0]);
+  DEBUG("(main) program_name : %s\n",program_name);
+  newargz = XMALLOC(char *, argc+2);
+EOF
+
+            cat >> $cwrappersource <<EOF
+  newargz[0] = (char *) xstrdup("$SHELL");
+EOF
+
+            cat >> $cwrappersource <<"EOF"
+  newargz[1] = find_executable(argv[0]);
+  if (newargz[1] == NULL)
+    lt_fatal("Couldn't find %s", argv[0]);
+  DEBUG("(main) found exe at : %s\n",newargz[1]);
+  /* we know the script has the same name, without the .exe */
+  /* so make sure newargz[1] doesn't end in .exe */
+  strendzap(newargz[1],".exe");
+  for (i = 1; i < argc; i++)
+    newargz[i+1] = xstrdup(argv[i]);
+  newargz[argc+1] = NULL;
+
+  for (i=0; i<argc+1; i++)
+  {
+    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
+    ;
+  }
+
+EOF
+
+            case $host_os in
+              mingw*)
+                cat >> $cwrappersource <<EOF
+  execv("$SHELL",(char const **)newargz);
+EOF
+              ;;
+              *)
+                cat >> $cwrappersource <<EOF
+  execv("$SHELL",newargz);
+EOF
+              ;;
+            esac
+
+            cat >> $cwrappersource <<"EOF"
+  return 127;
+}
+
+void *
+xmalloc (size_t num)
+{
+  void * p = (void *) malloc (num);
+  if (!p)
+    lt_fatal ("Memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
+;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable(const char * path)
+{
+  struct stat st;
+
+  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0) &&
+      (
+        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
+#if defined (S_IXOTH)
+       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
+#endif
+#if defined (S_IXGRP)
+       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
+#endif
+       ((st.st_mode & S_IXUSR) == S_IXUSR))
+      )
+    return 1;
+  else
+    return 0;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise */
+char *
+find_executable (const char* wrapper)
+{
+  int has_slash = 0;
+  const char* p;
+  const char* p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char* concat_name;
+
+  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
+  {
+    concat_name = xstrdup (wrapper);
+    if (check_executable(concat_name))
+      return concat_name;
+    XFREE(concat_name);
+  }
+  else
+  {
+#endif
+    if (IS_DIR_SEPARATOR (wrapper[0]))
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable(concat_name))
+        return concat_name;
+      XFREE(concat_name);
+    }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+    {
+      has_slash = 1;
+      break;
+    }
+  if (!has_slash)
+  {
+    /* no slashes; search PATH */
+    const char* path = getenv ("PATH");
+    if (path != NULL)
+    {
+      for (p = path; *p; p = p_next)
+      {
+        const char* q;
+        size_t p_len;
+        for (q = p; *q; q++)
+          if (IS_PATH_SEPARATOR(*q))
+            break;
+        p_len = q - p;
+        p_next = (*q == '\0' ? q : q + 1);
+        if (p_len == 0)
+        {
+          /* empty path: current directory */
+          if (getcwd (tmp, LT_PATHMAX) == NULL)
+            lt_fatal ("getcwd failed");
+          tmp_len = strlen(tmp);
+          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+          memcpy (concat_name, tmp, tmp_len);
+          concat_name[tmp_len] = '/';
+          strcpy (concat_name + tmp_len + 1, wrapper);
+        }
+        else
+        {
+          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
+          memcpy (concat_name, p, p_len);
+          concat_name[p_len] = '/';
+          strcpy (concat_name + p_len + 1, wrapper);
+        }
+        if (check_executable(concat_name))
+          return concat_name;
+        XFREE(concat_name);
+      }
+    }
+    /* not found in PATH; assume curdir */
+  }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal ("getcwd failed");
+  tmp_len = strlen(tmp);
+  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable(concat_name))
+    return concat_name;
+  XFREE(concat_name);
+  return NULL;
+}
+
+char *
+strendzap(char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert(str != NULL);
+  assert(pat != NULL);
+
+  len = strlen(str);
+  patlen = strlen(pat);
+
+  if (patlen <= len)
+  {
+    str += len - patlen;
+    if (strcmp(str, pat) == 0)
+      *str = '\0';
+  }
+  return str;
+}
+
+static void
+lt_error_core (int exit_status, const char * mode,
+          const char * message, va_list ap)
+{
+  fprintf (stderr, "%s: %s: ", program_name, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+  va_end (ap);
+}
+EOF
+          # we should really use a build-platform specific compiler
+          # here, but OTOH, the wrappers (shell script and this C one)
+          # are only useful if you want to execute the "real" binary.
+          # Since the "real" binary is built for $host, then this
+          # wrapper might as well be built for $host, too.
+          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
+          ;;
+        esac
+        $rm $output
+        trap "$rm $output; exit $EXIT_FAILURE" 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'
+
+# Be Bourne compatible (taken from Autoconf:_AS_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+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+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 $EXIT_FAILURE
+      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.
+
+      # Make sure env LD_LIBRARY_PATH does not mess us up
+      if test -n \"\${LD_LIBRARY_PATH+set}\"; then
+        export LD_LIBRARY_PATH=\$progdir:\$LD_LIBRARY_PATH
+      fi
+"
+	case $host in
+	# Backslashes separate directories on plain windows
+	*-*-mingw | *-*-os2*)
+	  $echo >> $output "\
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+	  ;;
+
+	*)
+	  $echo >> $output "\
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+	  ;;
+	esac
+	$echo >> $output "\
+      \$echo \"\$0: cannot exec \$program \$*\"
+      exit $EXIT_FAILURE
+    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 $EXIT_FAILURE
+  fi
+fi\
+"
+	chmod +x $output
+      fi
+      exit $EXIT_SUCCESS
+      ;;
+    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="$old_deplibs $non_pic_objects"
+	fi
+	addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+	gentop="$output_objdir/${outputname}x"
+	generated="$generated $gentop"
+
+	func_extract_archives $gentop $addlibs
+	oldobjs="$oldobjs $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+       cmds=$old_archive_from_new_cmds
+      else
+	# POSIX demands no paths to be encoded in archives.  We have
+	# to avoid creating archives with duplicate basenames if we
+	# might have to extract them afterwards, e.g., when creating a
+	# static archive out of a convenience library, or when linking
+	# the entirety of a libtool archive into another (currently
+	# not supported by libtool).
+	if (for obj in $oldobjs
+	    do
+	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
+	    done | sort | sort -uc >/dev/null 2>&1); then
+	  :
+	else
+	  $echo "copying selected object files to avoid basename conflicts..."
+
+	  if test -z "$gentop"; then
+	    gentop="$output_objdir/${outputname}x"
+	    generated="$generated $gentop"
+
+	    $show "${rm}r $gentop"
+	    $run ${rm}r "$gentop"
+	    $show "$mkdir $gentop"
+	    $run $mkdir "$gentop"
+	    exit_status=$?
+	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
+	      exit $exit_status
+	    fi
+	  fi
+
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  counter=1
+	  for obj in $save_oldobjs
+	  do
+	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+	    case " $oldobjs " in
+	    " ") oldobjs=$obj ;;
+	    *[\ /]"$objbase "*)
+	      while :; do
+		# Make sure we don't pick an alternate name that also
+		# overlaps.
+		newobj=lt$counter-$objbase
+		counter=`expr $counter + 1`
+		case " $oldobjs " in
+		*[\ /]"$newobj "*) ;;
+		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
+		esac
+	      done
+	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+	      $run ln "$obj" "$gentop/$newobj" ||
+	      $run cp "$obj" "$gentop/$newobj"
+	      oldobjs="$oldobjs $gentop/$newobj"
+	      ;;
+	    *) oldobjs="$oldobjs $obj" ;;
+	    esac
+	  done
+	fi
+
+	eval cmds=\"$old_archive_cmds\"
+
+	if len=`expr "X$cmds" : ".*"` &&
+	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  cmds=$old_archive_cmds
+	else
+	  # the command line is too long to link in one step, link in parts
+	  $echo "using piecewise archive linking..."
+	  save_RANLIB=$RANLIB
+	  RANLIB=:
+	  objlist=
+	  concat_cmds=
+	  save_oldobjs=$oldobjs
+
+	  # Is there a better way of finding the last object in the list?
+	  for obj in $save_oldobjs
+	  do
+	    last_oldobj=$obj
+	  done
+	  for obj in $save_oldobjs
+	  do
+	    oldobjs="$objlist $obj"
+	    objlist="$objlist $obj"
+	    eval test_cmds=\"$old_archive_cmds\"
+	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+	       test "$len" -le "$max_cmd_len"; then
+	      :
+	    else
+	      # the above command should be used before it gets too long
+	      oldobjs=$objlist
+	      if test "$obj" = "$last_oldobj" ; then
+	        RANLIB=$save_RANLIB
+	      fi
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      objlist=
+	    fi
+	  done
+	  RANLIB=$save_RANLIB
+	  oldobjs=$objlist
+	  if test "X$oldobjs" = "X" ; then
+	    eval cmds=\"\$concat_cmds\"
+	  else
+	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+	  fi
+	fi
+      fi
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+        eval cmd=\"$cmd\"
+	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 $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
+      if test "$hardcode_automatic" = yes ; then
+	relink_command=
+      fi
+
+
+      # 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 $EXIT_FAILURE
+		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 $EXIT_FAILURE
+	      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 $EXIT_FAILURE
+	      fi
+	      newdlprefiles="$newdlprefiles $libdir/$name"
+	    done
+	    dlprefiles="$newdlprefiles"
+	  else
+	    newdlfiles=
+	    for lib in $dlfiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlfiles="$newdlfiles $abs"
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlprefiles="$newdlprefiles $abs"
+	    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 | *mingw*,*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
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# 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 $EXIT_SUCCESS
+    ;;
+
+  # 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" | 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) 
+      	case " $install_prog " in
+	*[\\\ /]cp\ *) ;;
+	*) prev=$arg ;;
+	esac
+	;;
+      -g | -m | -o) prev=$arg ;;
+      -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 $EXIT_FAILURE
+    fi
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prev' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    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 $EXIT_FAILURE
+    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 $EXIT_FAILURE
+      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 $EXIT_FAILURE
+	  ;;
+	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 | grep "^# 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 $EXIT_FAILURE
+	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.
+	  # At present, this check doesn't affect windows .dll's that
+	  # are installed into $libdir/../bin (currently, that works fine)
+	  # but it's something to keep an eye on.
+	  if test "$inst_prefix_dir" = "$destdir"; then
+	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+	    exit $EXIT_FAILURE
+	  fi
+
+	  if test -n "$inst_prefix_dir"; then
+	    # Stick the inst_prefix_dir data into the link command.
+	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
+	  else
+	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
+	  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 $EXIT_FAILURE
+	  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.
+	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
+	    # so we also need to try rm && ln -s.
+	    for linkname
+	    do
+	      if test "$linkname" != "$realname"; then
+                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
+                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
+	      fi
+	    done
+	  fi
+
+	  # Do each command in the postinstall commands.
+	  lib="$destdir/$realname"
+	  cmds=$postinstall_cmds
+	  save_ifs="$IFS"; IFS='~'
+	  for cmd in $cmds; do
+	    IFS="$save_ifs"
+	    eval cmd=\"$cmd\"
+	    $show "$cmd"
+	    $run eval "$cmd" || {
+	      lt_exit=$?
+
+	      # Restore the uninstalled library and exit
+	      if test "$mode" = relink; then
+		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
+	      fi
+
+	      exit $lt_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 $EXIT_FAILURE
+	  ;;
+	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 $EXIT_SUCCESS
+	;;
+
+      *)
+	# 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
+
+	# If the file is missing, and there is a .exe on the end, strip it
+	# because it is most likely a libtool script we actually want to
+	# install
+	stripped_ext=""
+	case $file in
+	  *.exe)
+	    if test ! -f "$file"; then
+	      file=`$echo $file|${SED} 's,.exe$,,'`
+	      stripped_ext=".exe"
+	    fi
+	    ;;
+	esac
+
+	# Do a test to see if this is really a libtool program.
+	case $host in
+	*cygwin*|*mingw*)
+	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
+	    ;;
+	*)
+	    wrapper=$file
+	    ;;
+	esac
+	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
+	  notinst_deplibs=
+	  relink_command=
+
+	  # Note that it is not necessary on cygwin/mingw to append a dot to
+	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
+	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
+	  # `FILE.' does not work on cygwin managed mounts.
+	  #
+	  # If there is no directory component, then add one.
+	  case $wrapper in
+	  */* | *\\*) . ${wrapper} ;;
+	  *) . ./${wrapper} ;;
+	  esac
+
+	  # Check the variables that should have been set.
+	  if test -z "$notinst_deplibs"; then
+	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
+	    exit $EXIT_FAILURE
+	  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=
+	  # Note that it is not necessary on cygwin/mingw to append a dot to
+	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
+	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
+	  # `FILE.' does not work on cygwin managed mounts.
+	  #
+	  # If there is no directory component, then add one.
+	  case $wrapper in
+	  */* | *\\*) . ${wrapper} ;;
+	  *) . ./${wrapper} ;;
+	  esac
+
+	  outputname=
+	  if test "$fast_install" = no && test -n "$relink_command"; then
+	    if test "$finalize" = yes && test -z "$run"; then
+	      tmpdir=`func_mktempdir`
+	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
+	      outputname="$tmpdir/$file"
+	      # Replace the output file specification.
+	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
+
+	      $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$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+	  fi
+	fi
+
+	# remove .exe since cygwin /usr/bin/install will append another
+	# one anyway 
+	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 "$old_striplib"; then
+	$show "$old_striplib $oldlib"
+	$run eval "$old_striplib $oldlib" || exit $?
+      fi
+
+      # Do each command in the postinstall commands.
+      cmds=$old_postinstall_cmds
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+	IFS="$save_ifs"
+	eval cmd=\"$cmd\"
+	$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 $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    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.
+	  cmds=$finish_cmds
+	  save_ifs="$IFS"; IFS='~'
+	  for cmd in $cmds; do
+	    IFS="$save_ifs"
+	    eval cmd=\"$cmd\"
+	    $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 $EXIT_SUCCESS
+
+    $echo "X----------------------------------------------------------------------" | $Xsed
+    $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 "X----------------------------------------------------------------------" | $Xsed
+    exit $EXIT_SUCCESS
+    ;;
+
+  # 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 $EXIT_FAILURE
+    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 $EXIT_FAILURE
+      fi
+
+      dir=
+      case $file in
+      *.la)
+	# Check to see that this really is a libtool archive.
+	if (${SED} -e '2q' $file | grep "^# 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 $EXIT_FAILURE
+	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
+	  if test ! -f "$dir/$dlname"; then
+	    $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+	    exit $EXIT_FAILURE
+	  fi
+	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 | grep "^# 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 environment variables
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+	eval "if test \"\${save_$lt_var+set}\" = set; then
+		$lt_var=\$save_$lt_var; export $lt_var
+	      fi"
+      done
+
+      # 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 $EXIT_SUCCESS
+    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 $EXIT_FAILURE
+    fi
+
+    rmdirs=
+
+    origobjdir="$objdir"
+    for file in $files; do
+      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+      if test "X$dir" = "X$file"; then
+	dir=.
+	objdir="$origobjdir"
+      else
+	objdir="$dir/$origobjdir"
+      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 | grep "^# 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"
+
+	  case "$mode" in
+	  clean)
+	    case "  $library_names " in
+	    # "  " in the beginning catches empty $dlname
+	    *" $dlname "*) ;;
+	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
+	    esac
+	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+	    ;;
+	  uninstall)
+	    if test -n "$library_names"; then
+	      # Do each command in the postuninstall commands.
+	      cmds=$postuninstall_cmds
+	      save_ifs="$IFS"; IFS='~'
+	      for cmd in $cmds; do
+		IFS="$save_ifs"
+		eval cmd=\"$cmd\"
+		$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.
+	      cmds=$old_postuninstall_cmds
+	      save_ifs="$IFS"; IFS='~'
+	      for cmd in $cmds; do
+		IFS="$save_ifs"
+		eval cmd=\"$cmd\"
+		$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.
+	    ;;
+	  esac
+	fi
+	;;
+
+      *.lo)
+	# Possibly a libtool object, so verify it.
+	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+
+	  # Read the .lo file
+	  . $dir/$name
+
+	  # Add PIC object to the list of files to remove.
+	  if test -n "$pic_object" \
+	     && test "$pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$pic_object"
+	  fi
+
+	  # Add non-PIC object to the list of files to remove.
+	  if test -n "$non_pic_object" \
+	     && test "$non_pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$non_pic_object"
+	  fi
+	fi
+	;;
+
+      *)
+	if test "$mode" = clean ; then
+	  noexename=$name
+	  case $file in
+	  *.exe)
+	    file=`$echo $file|${SED} 's,.exe$,,'`
+	    noexename=`$echo $name|${SED} 's,.exe$,,'`
+	    # $file with .exe has already been added to rmfiles,
+	    # add $file without .exe
+	    rmfiles="$rmfiles $file"
+	    ;;
+	  esac
+	  # Do a test to see if this is a libtool program.
+	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	    relink_command=
+	    . $dir/$noexename
+
+	    # note $name still contains .exe if it was in $file originally
+	    # as does the version of $file that was added into $rmfiles
+	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	      rmfiles="$rmfiles $objdir/lt-$name"
+	    fi
+	    if test "X$noexename" != "X$name" ; then
+	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+	    fi
+	  fi
+	fi
+	;;
+      esac
+      $show "$rm $rmfiles"
+      $run $rm $rmfiles || exit_status=1
+    done
+    objdir="$origobjdir"
+
+    # 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 $EXIT_FAILURE
+    ;;
+  esac
+
+  if test -z "$exec_cmd"; then
+    $echo "$modename: invalid operation mode \`$mode'" 1>&2
+    $echo "$generic_help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+fi # test -z "$show_help"
+
+if test -n "$exec_cmd"; then
+  eval exec $exec_cmd
+  exit $EXIT_FAILURE
+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
+    --tag=TAG         use configuration variables from tag TAG
+    --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.
+
+Report bugs to <bug-libtool@gnu.org>."
+  exit $EXIT_SUCCESS
+  ;;
+
+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
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -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 uninstalled libtool libraries
+  -static-libtool-libs
+                    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 $EXIT_FAILURE
+  ;;
+esac
+
+$echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit $?
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+disable_libs=shared
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+disable_libs=static
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/makevp.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,66 @@
+:: AH 20-12-06 modified for new PCRE-7.0 and VP/BCC
+:: PH 19-03-07 renamed !compile.txt and !linklib.txt as makevp-compile.txt and
+::             makevp-linklib.txt
+:: PH 26-03-07 re-renamed !compile.txt and !linklib.txt as makevp-c.txt and
+::             makevp-l.txt
+:: PH 29-03-07 hopefully the final rename to makevp_c and makevp_l
+:: AH 27.08.08 updated for new PCRE-7.7
+::             required PCRE.H and CONFIG.H will be generated if not existing
+
+@echo off
+echo.
+echo Compiling PCRE with BORLAND C++ for VIRTUAL PASCAL
+echo.
+
+REM This file was contributed by Alexander Tokarev for building PCRE for use
+REM with Virtual Pascal. It has not been tested with the latest PCRE release.
+
+REM This file has been modified and extended to compile with newer PCRE releases
+REM by Stefan Weber (Angels Holocaust).
+
+REM CHANGE THIS FOR YOUR BORLAND C++ COMPILER PATH
+SET BORLAND=f:\bcc
+REM location of the TASM binaries, if compiling with the -B BCC switch
+SET TASM=f:\tasm
+
+SET PATH=%PATH%;%BORLAND%\bin;%TASM%\bin
+SET PCRE_VER=77
+SET COMPILE_DEFAULTS=-DHAVE_CONFIG_H -DPCRE_STATIC -I%BORLAND%\include
+
+del pcre%PCRE_VER%.lib >nul 2>nul
+
+:: sh configure
+
+:: check for needed header files
+if not exist pcre.h copy pcre.h.generic pcre.h
+if not exist config.h copy config.h.generic config.h
+
+bcc32 -DDFTABLES %COMPILE_DEFAULTS% -L%BORLAND%\lib dftables.c
+IF ERRORLEVEL 1 GOTO ERROR
+
+:: dftables > chartables.c
+dftables pcre_chartables.c
+
+REM compile and link the PCRE library into lib: option -B for ASM compile works too
+bcc32 -a4 -c -RT- -y- -v- -u- -R- -Q- -X -d -fp -ff -P- -O2 -Oc -Ov -3 -w-8004 -w-8064 -w-8065 -w-8012 -UDFTABLES -DVPCOMPAT %COMPILE_DEFAULTS% @makevp_c.txt
+IF ERRORLEVEL 1 GOTO ERROR
+
+tlib %BORLAND%\lib\cw32.lib *calloc *del *strncmp *memcpy *memmove *memset *memcmp *strlen
+IF ERRORLEVEL 1 GOTO ERROR
+tlib pcre%PCRE_VER%.lib @makevp_l.txt +calloc.obj +del.obj +strncmp.obj +memcpy.obj +memmove.obj +memset.obj +memcmp.obj +strlen.obj
+IF ERRORLEVEL 1 GOTO ERROR
+
+del *.obj *.tds *.bak >nul 2>nul
+
+echo ---
+echo Now the library should be complete. Please check all messages above.
+echo Don't care for warnings, it's OK.
+goto END
+
+:ERROR
+echo ---
+echo Error while compiling PCRE. Aborting...
+pause
+goto END
+
+:END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/makevp_c.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,20 @@
+pcre_chartables.c
+pcre_compile.c
+pcre_config.c
+pcre_dfa_exec.c
+pcre_exec.c
+pcre_fullinfo.c
+pcre_get.c
+pcre_globals.c
+pcre_info.c
+pcre_maketables.c
+pcre_newline.c
+pcre_ord2utf8.c
+pcre_refcount.c
+pcre_study.c
+pcre_tables.c
+pcre_try_flipped.c
+pcre_ucd.c
+pcre_valid_utf8.c
+pcre_version.c
+pcre_xclass.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/makevp_l.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,20 @@
++pcre_chartables.obj        &
++pcre_compile.obj           &
++pcre_config.obj	    &
++pcre_dfa_exec.obj          &
++pcre_exec.obj		    &
++pcre_fullinfo.obj          &
++pcre_get.obj		    &
++pcre_globals.obj           &
++pcre_info.obj		    &
++pcre_maketables.obj        &
++pcre_newline.obj           &
++pcre_ord2utf8.obj          &
++pcre_refcount.obj          &
++pcre_study.obj		    &
++pcre_tables.obj	    &
++pcre_try_flipped.obj       &
++pcre_ucd.obj               &
++pcre_valid_utf8.obj        &
++pcre_version.obj           &
++pcre_xclass.obj
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/missing	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,367 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2006-05-10.23
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+#   Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@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., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, 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=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# 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
+
+msg="missing on your system"
+
+case $1 in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -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'
+  autom4te     touch the output file, or create a stub one
+  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]
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case $1 in
+  lex|yacc)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $1 in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  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)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  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)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  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*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  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)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    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' $msg.  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 test $# -ne 1; then
+        eval LASTARG="\${$#}"
+	case $LASTARG in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if test ! -f y.tab.h; then
+	echo >y.tab.h
+    fi
+    if test ! -f y.tab.c; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  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 test $# -ne 1; then
+        eval LASTARG="\${$#}"
+	case $LASTARG in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if test ! -f lex.yy.c; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  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 "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo ".ab help2man is required to generate this page"
+	exit 1
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  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."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '
+	/^@setfilename/{
+	  s/.* \([^ ]*\) *$/\1/
+	  p
+	  q
+	}' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar)
+    shift
+
+    # 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 is $msg.
+         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 prerequisites 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
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre-config.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+exec_prefix_set=no
+
+usage="\
+Usage: pcre-config [--prefix] [--exec-prefix] [--version] [--libs] [--libs-posix] [--cflags] [--cflags-posix]"
+
+if test $# -eq 0; then
+      echo "${usage}" 1>&2
+      exit 1
+fi
+
+libR=
+case `uname -s` in
+  *SunOS*)
+  libR=" -R@libdir@"
+  ;;
+  *BSD*)
+  libR=" -Wl,-R@libdir@"
+  ;;
+esac
+
+while test $# -gt 0; do
+  case "$1" in
+  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  case $1 in
+    --prefix=*)
+      prefix=$optarg
+      if test $exec_prefix_set = no ; then
+        exec_prefix=$optarg
+      fi
+      ;;
+    --prefix)
+      echo $prefix
+      ;;
+    --exec-prefix=*)
+      exec_prefix=$optarg
+      exec_prefix_set=yes
+      ;;
+    --exec-prefix)
+      echo $exec_prefix
+      ;;
+    --version)
+      echo @PACKAGE_VERSION@
+      ;;
+    --cflags | --cflags-posix)
+      if test @includedir@ != /usr/include ; then
+        includes=-I@includedir@
+      fi
+      echo $includes
+      ;;
+    --libs-posix)
+      echo -L@libdir@$libR -lpcreposix -lpcre
+      ;;
+    --libs)
+      echo -L@libdir@$libR -lpcre
+      ;;
+    *)
+      echo "${usage}" 1>&2
+      exit 1
+      ;;
+  esac
+  shift
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre.h.generic	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,304 @@
+/*************************************************
+*       Perl-Compatible Regular Expressions      *
+*************************************************/
+
+/* This is the public header file for the PCRE library, to be #included by
+applications that call the PCRE functions.
+
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _PCRE_H
+#define _PCRE_H
+
+/* The current PCRE version information. */
+
+#define PCRE_MAJOR          7
+#define PCRE_MINOR          8
+#define PCRE_PRERELEASE     
+#define PCRE_DATE           2008-09-05
+
+/* When an application links to a PCRE DLL in Windows, the symbols that are
+imported have to be identified as such. When building PCRE, the appropriate
+export setting is defined in pcre_internal.h, which includes this file. So we
+don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC)
+#  ifndef PCRE_EXP_DECL
+#    define PCRE_EXP_DECL  extern __declspec(dllimport)
+#  endif
+#  ifdef __cplusplus
+#    ifndef PCRECPP_EXP_DECL
+#      define PCRECPP_EXP_DECL  extern __declspec(dllimport)
+#    endif
+#    ifndef PCRECPP_EXP_DEFN
+#      define PCRECPP_EXP_DEFN  __declspec(dllimport)
+#    endif
+#  endif
+#endif
+
+/* By default, we use the standard "extern" declarations. */
+
+#ifndef PCRE_EXP_DECL
+#  ifdef __cplusplus
+#    define PCRE_EXP_DECL  extern "C"
+#  else
+#    define PCRE_EXP_DECL  extern
+#  endif
+#endif
+
+#ifdef __cplusplus
+#  ifndef PCRECPP_EXP_DECL
+#    define PCRECPP_EXP_DECL  extern
+#  endif
+#  ifndef PCRECPP_EXP_DEFN
+#    define PCRECPP_EXP_DEFN
+#  endif
+#endif
+
+/* Have to include stdlib.h in order to ensure that size_t is defined;
+it is needed here for malloc. */
+
+#include <stdlib.h>
+
+/* Allow for C++ users */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Options */
+
+#define PCRE_CASELESS           0x00000001
+#define PCRE_MULTILINE          0x00000002
+#define PCRE_DOTALL             0x00000004
+#define PCRE_EXTENDED           0x00000008
+#define PCRE_ANCHORED           0x00000010
+#define PCRE_DOLLAR_ENDONLY     0x00000020
+#define PCRE_EXTRA              0x00000040
+#define PCRE_NOTBOL             0x00000080
+#define PCRE_NOTEOL             0x00000100
+#define PCRE_UNGREEDY           0x00000200
+#define PCRE_NOTEMPTY           0x00000400
+#define PCRE_UTF8               0x00000800
+#define PCRE_NO_AUTO_CAPTURE    0x00001000
+#define PCRE_NO_UTF8_CHECK      0x00002000
+#define PCRE_AUTO_CALLOUT       0x00004000
+#define PCRE_PARTIAL            0x00008000
+#define PCRE_DFA_SHORTEST       0x00010000
+#define PCRE_DFA_RESTART        0x00020000
+#define PCRE_FIRSTLINE          0x00040000
+#define PCRE_DUPNAMES           0x00080000
+#define PCRE_NEWLINE_CR         0x00100000
+#define PCRE_NEWLINE_LF         0x00200000
+#define PCRE_NEWLINE_CRLF       0x00300000
+#define PCRE_NEWLINE_ANY        0x00400000
+#define PCRE_NEWLINE_ANYCRLF    0x00500000
+#define PCRE_BSR_ANYCRLF        0x00800000
+#define PCRE_BSR_UNICODE        0x01000000
+#define PCRE_JAVASCRIPT_COMPAT  0x02000000
+
+/* Exec-time and get/set-time error codes */
+
+#define PCRE_ERROR_NOMATCH         (-1)
+#define PCRE_ERROR_NULL            (-2)
+#define PCRE_ERROR_BADOPTION       (-3)
+#define PCRE_ERROR_BADMAGIC        (-4)
+#define PCRE_ERROR_UNKNOWN_OPCODE  (-5)
+#define PCRE_ERROR_UNKNOWN_NODE    (-5)  /* For backward compatibility */
+#define PCRE_ERROR_NOMEMORY        (-6)
+#define PCRE_ERROR_NOSUBSTRING     (-7)
+#define PCRE_ERROR_MATCHLIMIT      (-8)
+#define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */
+#define PCRE_ERROR_BADUTF8        (-10)
+#define PCRE_ERROR_BADUTF8_OFFSET (-11)
+#define PCRE_ERROR_PARTIAL        (-12)
+#define PCRE_ERROR_BADPARTIAL     (-13)
+#define PCRE_ERROR_INTERNAL       (-14)
+#define PCRE_ERROR_BADCOUNT       (-15)
+#define PCRE_ERROR_DFA_UITEM      (-16)
+#define PCRE_ERROR_DFA_UCOND      (-17)
+#define PCRE_ERROR_DFA_UMLIMIT    (-18)
+#define PCRE_ERROR_DFA_WSSIZE     (-19)
+#define PCRE_ERROR_DFA_RECURSE    (-20)
+#define PCRE_ERROR_RECURSIONLIMIT (-21)
+#define PCRE_ERROR_NULLWSLIMIT    (-22)  /* No longer actually used */
+#define PCRE_ERROR_BADNEWLINE     (-23)
+
+/* Request types for pcre_fullinfo() */
+
+#define PCRE_INFO_OPTIONS            0
+#define PCRE_INFO_SIZE               1
+#define PCRE_INFO_CAPTURECOUNT       2
+#define PCRE_INFO_BACKREFMAX         3
+#define PCRE_INFO_FIRSTBYTE          4
+#define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */
+#define PCRE_INFO_FIRSTTABLE         5
+#define PCRE_INFO_LASTLITERAL        6
+#define PCRE_INFO_NAMEENTRYSIZE      7
+#define PCRE_INFO_NAMECOUNT          8
+#define PCRE_INFO_NAMETABLE          9
+#define PCRE_INFO_STUDYSIZE         10
+#define PCRE_INFO_DEFAULT_TABLES    11
+#define PCRE_INFO_OKPARTIAL         12
+#define PCRE_INFO_JCHANGED          13
+#define PCRE_INFO_HASCRORLF         14
+
+/* Request types for pcre_config(). Do not re-arrange, in order to remain
+compatible. */
+
+#define PCRE_CONFIG_UTF8                    0
+#define PCRE_CONFIG_NEWLINE                 1
+#define PCRE_CONFIG_LINK_SIZE               2
+#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3
+#define PCRE_CONFIG_MATCH_LIMIT             4
+#define PCRE_CONFIG_STACKRECURSE            5
+#define PCRE_CONFIG_UNICODE_PROPERTIES      6
+#define PCRE_CONFIG_MATCH_LIMIT_RECURSION   7
+#define PCRE_CONFIG_BSR                     8
+
+/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
+these bits, just add new ones on the end, in order to remain compatible. */
+
+#define PCRE_EXTRA_STUDY_DATA             0x0001
+#define PCRE_EXTRA_MATCH_LIMIT            0x0002
+#define PCRE_EXTRA_CALLOUT_DATA           0x0004
+#define PCRE_EXTRA_TABLES                 0x0008
+#define PCRE_EXTRA_MATCH_LIMIT_RECURSION  0x0010
+
+/* Types */
+
+struct real_pcre;                 /* declaration; the definition is private  */
+typedef struct real_pcre pcre;
+
+/* When PCRE is compiled as a C++ library, the subject pointer type can be
+replaced with a custom type. For conventional use, the public interface is a
+const char *. */
+
+#ifndef PCRE_SPTR
+#define PCRE_SPTR const char *
+#endif
+
+/* The structure for passing additional data to pcre_exec(). This is defined in
+such as way as to be extensible. Always add new fields at the end, in order to
+remain compatible. */
+
+typedef struct pcre_extra {
+  unsigned long int flags;        /* Bits for which fields are set */
+  void *study_data;               /* Opaque data from pcre_study() */
+  unsigned long int match_limit;  /* Maximum number of calls to match() */
+  void *callout_data;             /* Data passed back in callouts */
+  const unsigned char *tables;    /* Pointer to character tables */
+  unsigned long int match_limit_recursion; /* Max recursive calls to match() */
+} pcre_extra;
+
+/* The structure for passing out data via the pcre_callout_function. We use a
+structure so that new fields can be added on the end in future versions,
+without changing the API of the function, thereby allowing old clients to work
+without modification. */
+
+typedef struct pcre_callout_block {
+  int          version;           /* Identifies version of block */
+  /* ------------------------ Version 0 ------------------------------- */
+  int          callout_number;    /* Number compiled into pattern */
+  int         *offset_vector;     /* The offset vector */
+  PCRE_SPTR    subject;           /* The subject being matched */
+  int          subject_length;    /* The length of the subject */
+  int          start_match;       /* Offset to start of this match attempt */
+  int          current_position;  /* Where we currently are in the subject */
+  int          capture_top;       /* Max current capture */
+  int          capture_last;      /* Most recently closed capture */
+  void        *callout_data;      /* Data passed in with the call */
+  /* ------------------- Added for Version 1 -------------------------- */
+  int          pattern_position;  /* Offset to next item in the pattern */
+  int          next_item_length;  /* Length of next item in the pattern */
+  /* ------------------------------------------------------------------ */
+} pcre_callout_block;
+
+/* Indirection for store get and free functions. These can be set to
+alternative malloc/free functions if required. Special ones are used in the
+non-recursive case for "frames". There is also an optional callout function
+that is triggered by the (?) regex item. For Virtual Pascal, these definitions
+have to take another form. */
+
+#ifndef VPCOMPAT
+PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
+PCRE_EXP_DECL void  (*pcre_free)(void *);
+PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
+PCRE_EXP_DECL void  (*pcre_stack_free)(void *);
+PCRE_EXP_DECL int   (*pcre_callout)(pcre_callout_block *);
+#else   /* VPCOMPAT */
+PCRE_EXP_DECL void *pcre_malloc(size_t);
+PCRE_EXP_DECL void  pcre_free(void *);
+PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
+PCRE_EXP_DECL void  pcre_stack_free(void *);
+PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
+#endif  /* VPCOMPAT */
+
+/* Exported PCRE functions */
+
+PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
+                  const unsigned char *);
+PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
+                  int *, const unsigned char *);
+PCRE_EXP_DECL int  pcre_config(int, void *);
+PCRE_EXP_DECL int  pcre_copy_named_substring(const pcre *, const char *,
+                  int *, int, const char *, char *, int);
+PCRE_EXP_DECL int  pcre_copy_substring(const char *, int *, int, int, char *,
+                  int);
+PCRE_EXP_DECL int  pcre_dfa_exec(const pcre *, const pcre_extra *,
+                  const char *, int, int, int, int *, int , int *, int);
+PCRE_EXP_DECL int  pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
+                   int, int, int, int *, int);
+PCRE_EXP_DECL void pcre_free_substring(const char *);
+PCRE_EXP_DECL void pcre_free_substring_list(const char **);
+PCRE_EXP_DECL int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
+                  void *);
+PCRE_EXP_DECL int  pcre_get_named_substring(const pcre *, const char *,
+                  int *, int, const char *, const char **);
+PCRE_EXP_DECL int  pcre_get_stringnumber(const pcre *, const char *);
+PCRE_EXP_DECL int  pcre_get_stringtable_entries(const pcre *, const char *,
+                  char **, char **);
+PCRE_EXP_DECL int  pcre_get_substring(const char *, int *, int, int,
+                  const char **);
+PCRE_EXP_DECL int  pcre_get_substring_list(const char *, int *, int,
+                  const char ***);
+PCRE_EXP_DECL int  pcre_info(const pcre *, int *, int *);
+PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
+PCRE_EXP_DECL int  pcre_refcount(pcre *, int);
+PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
+PCRE_EXP_DECL const char *pcre_version(void);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif
+
+#endif /* End of pcre.h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre.h.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,304 @@
+/*************************************************
+*       Perl-Compatible Regular Expressions      *
+*************************************************/
+
+/* This is the public header file for the PCRE library, to be #included by
+applications that call the PCRE functions.
+
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+#ifndef _PCRE_H
+#define _PCRE_H
+
+/* The current PCRE version information. */
+
+#define PCRE_MAJOR          @PCRE_MAJOR@
+#define PCRE_MINOR          @PCRE_MINOR@
+#define PCRE_PRERELEASE     @PCRE_PRERELEASE@
+#define PCRE_DATE           @PCRE_DATE@
+
+/* When an application links to a PCRE DLL in Windows, the symbols that are
+imported have to be identified as such. When building PCRE, the appropriate
+export setting is defined in pcre_internal.h, which includes this file. So we
+don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC)
+#  ifndef PCRE_EXP_DECL
+#    define PCRE_EXP_DECL  extern __declspec(dllimport)
+#  endif
+#  ifdef __cplusplus
+#    ifndef PCRECPP_EXP_DECL
+#      define PCRECPP_EXP_DECL  extern __declspec(dllimport)
+#    endif
+#    ifndef PCRECPP_EXP_DEFN
+#      define PCRECPP_EXP_DEFN  __declspec(dllimport)
+#    endif
+#  endif
+#endif
+
+/* By default, we use the standard "extern" declarations. */
+
+#ifndef PCRE_EXP_DECL
+#  ifdef __cplusplus
+#    define PCRE_EXP_DECL  extern "C"
+#  else
+#    define PCRE_EXP_DECL  extern
+#  endif
+#endif
+
+#ifdef __cplusplus
+#  ifndef PCRECPP_EXP_DECL
+#    define PCRECPP_EXP_DECL  extern
+#  endif
+#  ifndef PCRECPP_EXP_DEFN
+#    define PCRECPP_EXP_DEFN
+#  endif
+#endif
+
+/* Have to include stdlib.h in order to ensure that size_t is defined;
+it is needed here for malloc. */
+
+#include <stdlib.h>
+
+/* Allow for C++ users */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Options */
+
+#define PCRE_CASELESS           0x00000001
+#define PCRE_MULTILINE          0x00000002
+#define PCRE_DOTALL             0x00000004
+#define PCRE_EXTENDED           0x00000008
+#define PCRE_ANCHORED           0x00000010
+#define PCRE_DOLLAR_ENDONLY     0x00000020
+#define PCRE_EXTRA              0x00000040
+#define PCRE_NOTBOL             0x00000080
+#define PCRE_NOTEOL             0x00000100
+#define PCRE_UNGREEDY           0x00000200
+#define PCRE_NOTEMPTY           0x00000400
+#define PCRE_UTF8               0x00000800
+#define PCRE_NO_AUTO_CAPTURE    0x00001000
+#define PCRE_NO_UTF8_CHECK      0x00002000
+#define PCRE_AUTO_CALLOUT       0x00004000
+#define PCRE_PARTIAL            0x00008000
+#define PCRE_DFA_SHORTEST       0x00010000
+#define PCRE_DFA_RESTART        0x00020000
+#define PCRE_FIRSTLINE          0x00040000
+#define PCRE_DUPNAMES           0x00080000
+#define PCRE_NEWLINE_CR         0x00100000
+#define PCRE_NEWLINE_LF         0x00200000
+#define PCRE_NEWLINE_CRLF       0x00300000
+#define PCRE_NEWLINE_ANY        0x00400000
+#define PCRE_NEWLINE_ANYCRLF    0x00500000
+#define PCRE_BSR_ANYCRLF        0x00800000
+#define PCRE_BSR_UNICODE        0x01000000
+#define PCRE_JAVASCRIPT_COMPAT  0x02000000
+
+/* Exec-time and get/set-time error codes */
+
+#define PCRE_ERROR_NOMATCH         (-1)
+#define PCRE_ERROR_NULL            (-2)
+#define PCRE_ERROR_BADOPTION       (-3)
+#define PCRE_ERROR_BADMAGIC        (-4)
+#define PCRE_ERROR_UNKNOWN_OPCODE  (-5)
+#define PCRE_ERROR_UNKNOWN_NODE    (-5)  /* For backward compatibility */
+#define PCRE_ERROR_NOMEMORY        (-6)
+#define PCRE_ERROR_NOSUBSTRING     (-7)
+#define PCRE_ERROR_MATCHLIMIT      (-8)
+#define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */
+#define PCRE_ERROR_BADUTF8        (-10)
+#define PCRE_ERROR_BADUTF8_OFFSET (-11)
+#define PCRE_ERROR_PARTIAL        (-12)
+#define PCRE_ERROR_BADPARTIAL     (-13)
+#define PCRE_ERROR_INTERNAL       (-14)
+#define PCRE_ERROR_BADCOUNT       (-15)
+#define PCRE_ERROR_DFA_UITEM      (-16)
+#define PCRE_ERROR_DFA_UCOND      (-17)
+#define PCRE_ERROR_DFA_UMLIMIT    (-18)
+#define PCRE_ERROR_DFA_WSSIZE     (-19)
+#define PCRE_ERROR_DFA_RECURSE    (-20)
+#define PCRE_ERROR_RECURSIONLIMIT (-21)
+#define PCRE_ERROR_NULLWSLIMIT    (-22)  /* No longer actually used */
+#define PCRE_ERROR_BADNEWLINE     (-23)
+
+/* Request types for pcre_fullinfo() */
+
+#define PCRE_INFO_OPTIONS            0
+#define PCRE_INFO_SIZE               1
+#define PCRE_INFO_CAPTURECOUNT       2
+#define PCRE_INFO_BACKREFMAX         3
+#define PCRE_INFO_FIRSTBYTE          4
+#define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */
+#define PCRE_INFO_FIRSTTABLE         5
+#define PCRE_INFO_LASTLITERAL        6
+#define PCRE_INFO_NAMEENTRYSIZE      7
+#define PCRE_INFO_NAMECOUNT          8
+#define PCRE_INFO_NAMETABLE          9
+#define PCRE_INFO_STUDYSIZE         10
+#define PCRE_INFO_DEFAULT_TABLES    11
+#define PCRE_INFO_OKPARTIAL         12
+#define PCRE_INFO_JCHANGED          13
+#define PCRE_INFO_HASCRORLF         14
+
+/* Request types for pcre_config(). Do not re-arrange, in order to remain
+compatible. */
+
+#define PCRE_CONFIG_UTF8                    0
+#define PCRE_CONFIG_NEWLINE                 1
+#define PCRE_CONFIG_LINK_SIZE               2
+#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3
+#define PCRE_CONFIG_MATCH_LIMIT             4
+#define PCRE_CONFIG_STACKRECURSE            5
+#define PCRE_CONFIG_UNICODE_PROPERTIES      6
+#define PCRE_CONFIG_MATCH_LIMIT_RECURSION   7
+#define PCRE_CONFIG_BSR                     8
+
+/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
+these bits, just add new ones on the end, in order to remain compatible. */
+
+#define PCRE_EXTRA_STUDY_DATA             0x0001
+#define PCRE_EXTRA_MATCH_LIMIT            0x0002
+#define PCRE_EXTRA_CALLOUT_DATA           0x0004
+#define PCRE_EXTRA_TABLES                 0x0008
+#define PCRE_EXTRA_MATCH_LIMIT_RECURSION  0x0010
+
+/* Types */
+
+struct real_pcre;                 /* declaration; the definition is private  */
+typedef struct real_pcre pcre;
+
+/* When PCRE is compiled as a C++ library, the subject pointer type can be
+replaced with a custom type. For conventional use, the public interface is a
+const char *. */
+
+#ifndef PCRE_SPTR
+#define PCRE_SPTR const char *
+#endif
+
+/* The structure for passing additional data to pcre_exec(). This is defined in
+such as way as to be extensible. Always add new fields at the end, in order to
+remain compatible. */
+
+typedef struct pcre_extra {
+  unsigned long int flags;        /* Bits for which fields are set */
+  void *study_data;               /* Opaque data from pcre_study() */
+  unsigned long int match_limit;  /* Maximum number of calls to match() */
+  void *callout_data;             /* Data passed back in callouts */
+  const unsigned char *tables;    /* Pointer to character tables */
+  unsigned long int match_limit_recursion; /* Max recursive calls to match() */
+} pcre_extra;
+
+/* The structure for passing out data via the pcre_callout_function. We use a
+structure so that new fields can be added on the end in future versions,
+without changing the API of the function, thereby allowing old clients to work
+without modification. */
+
+typedef struct pcre_callout_block {
+  int          version;           /* Identifies version of block */
+  /* ------------------------ Version 0 ------------------------------- */
+  int          callout_number;    /* Number compiled into pattern */
+  int         *offset_vector;     /* The offset vector */
+  PCRE_SPTR    subject;           /* The subject being matched */
+  int          subject_length;    /* The length of the subject */
+  int          start_match;       /* Offset to start of this match attempt */
+  int          current_position;  /* Where we currently are in the subject */
+  int          capture_top;       /* Max current capture */
+  int          capture_last;      /* Most recently closed capture */
+  void        *callout_data;      /* Data passed in with the call */
+  /* ------------------- Added for Version 1 -------------------------- */
+  int          pattern_position;  /* Offset to next item in the pattern */
+  int          next_item_length;  /* Length of next item in the pattern */
+  /* ------------------------------------------------------------------ */
+} pcre_callout_block;
+
+/* Indirection for store get and free functions. These can be set to
+alternative malloc/free functions if required. Special ones are used in the
+non-recursive case for "frames". There is also an optional callout function
+that is triggered by the (?) regex item. For Virtual Pascal, these definitions
+have to take another form. */
+
+#ifndef VPCOMPAT
+PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
+PCRE_EXP_DECL void  (*pcre_free)(void *);
+PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
+PCRE_EXP_DECL void  (*pcre_stack_free)(void *);
+PCRE_EXP_DECL int   (*pcre_callout)(pcre_callout_block *);
+#else   /* VPCOMPAT */
+PCRE_EXP_DECL void *pcre_malloc(size_t);
+PCRE_EXP_DECL void  pcre_free(void *);
+PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
+PCRE_EXP_DECL void  pcre_stack_free(void *);
+PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
+#endif  /* VPCOMPAT */
+
+/* Exported PCRE functions */
+
+PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
+                  const unsigned char *);
+PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
+                  int *, const unsigned char *);
+PCRE_EXP_DECL int  pcre_config(int, void *);
+PCRE_EXP_DECL int  pcre_copy_named_substring(const pcre *, const char *,
+                  int *, int, const char *, char *, int);
+PCRE_EXP_DECL int  pcre_copy_substring(const char *, int *, int, int, char *,
+                  int);
+PCRE_EXP_DECL int  pcre_dfa_exec(const pcre *, const pcre_extra *,
+                  const char *, int, int, int, int *, int , int *, int);
+PCRE_EXP_DECL int  pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
+                   int, int, int, int *, int);
+PCRE_EXP_DECL void pcre_free_substring(const char *);
+PCRE_EXP_DECL void pcre_free_substring_list(const char **);
+PCRE_EXP_DECL int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
+                  void *);
+PCRE_EXP_DECL int  pcre_get_named_substring(const pcre *, const char *,
+                  int *, int, const char *, const char **);
+PCRE_EXP_DECL int  pcre_get_stringnumber(const pcre *, const char *);
+PCRE_EXP_DECL int  pcre_get_stringtable_entries(const pcre *, const char *,
+                  char **, char **);
+PCRE_EXP_DECL int  pcre_get_substring(const char *, int *, int, int,
+                  const char **);
+PCRE_EXP_DECL int  pcre_get_substring_list(const char *, int *, int,
+                  const char ***);
+PCRE_EXP_DECL int  pcre_info(const pcre *, int *, int *);
+PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
+PCRE_EXP_DECL int  pcre_refcount(pcre *, int);
+PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
+PCRE_EXP_DECL const char *pcre_version(void);
+
+#ifdef __cplusplus
+}  /* extern "C" */
+#endif
+
+#endif /* End of pcre.h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_chartables.c.dist	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,198 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* This file contains character tables that are used when no external tables
+are passed to PCRE by the application that calls it. The tables are used only
+for characters whose code values are less than 256.
+
+This is a default version of the tables that assumes ASCII encoding. A program
+called dftables (which is distributed with PCRE) can be used to build
+alternative versions of this file. This is necessary if you are running in an
+EBCDIC environment, or if you want to default to a different encoding, for
+example ISO-8859-1. When dftables is run, it creates these tables in the
+current locale. If PCRE is configured with --enable-rebuild-chartables, this
+happens automatically.
+
+The following #includes are present because without the gcc 4.x may remove the
+array definition from the final binary if PCRE is built into a static library
+and dead code stripping is activated. This leads to link errors. Pulling in the
+header ensures that the array gets flagged as "someone outside this compilation
+unit might reference this" and so it will always be supplied to the linker. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+const unsigned char _pcre_default_tables[] = {
+
+/* This table is a lower casing table. */
+
+    0,  1,  2,  3,  4,  5,  6,  7,
+    8,  9, 10, 11, 12, 13, 14, 15,
+   16, 17, 18, 19, 20, 21, 22, 23,
+   24, 25, 26, 27, 28, 29, 30, 31,
+   32, 33, 34, 35, 36, 37, 38, 39,
+   40, 41, 42, 43, 44, 45, 46, 47,
+   48, 49, 50, 51, 52, 53, 54, 55,
+   56, 57, 58, 59, 60, 61, 62, 63,
+   64, 97, 98, 99,100,101,102,103,
+  104,105,106,107,108,109,110,111,
+  112,113,114,115,116,117,118,119,
+  120,121,122, 91, 92, 93, 94, 95,
+   96, 97, 98, 99,100,101,102,103,
+  104,105,106,107,108,109,110,111,
+  112,113,114,115,116,117,118,119,
+  120,121,122,123,124,125,126,127,
+  128,129,130,131,132,133,134,135,
+  136,137,138,139,140,141,142,143,
+  144,145,146,147,148,149,150,151,
+  152,153,154,155,156,157,158,159,
+  160,161,162,163,164,165,166,167,
+  168,169,170,171,172,173,174,175,
+  176,177,178,179,180,181,182,183,
+  184,185,186,187,188,189,190,191,
+  192,193,194,195,196,197,198,199,
+  200,201,202,203,204,205,206,207,
+  208,209,210,211,212,213,214,215,
+  216,217,218,219,220,221,222,223,
+  224,225,226,227,228,229,230,231,
+  232,233,234,235,236,237,238,239,
+  240,241,242,243,244,245,246,247,
+  248,249,250,251,252,253,254,255,
+
+/* This table is a case flipping table. */
+
+    0,  1,  2,  3,  4,  5,  6,  7,
+    8,  9, 10, 11, 12, 13, 14, 15,
+   16, 17, 18, 19, 20, 21, 22, 23,
+   24, 25, 26, 27, 28, 29, 30, 31,
+   32, 33, 34, 35, 36, 37, 38, 39,
+   40, 41, 42, 43, 44, 45, 46, 47,
+   48, 49, 50, 51, 52, 53, 54, 55,
+   56, 57, 58, 59, 60, 61, 62, 63,
+   64, 97, 98, 99,100,101,102,103,
+  104,105,106,107,108,109,110,111,
+  112,113,114,115,116,117,118,119,
+  120,121,122, 91, 92, 93, 94, 95,
+   96, 65, 66, 67, 68, 69, 70, 71,
+   72, 73, 74, 75, 76, 77, 78, 79,
+   80, 81, 82, 83, 84, 85, 86, 87,
+   88, 89, 90,123,124,125,126,127,
+  128,129,130,131,132,133,134,135,
+  136,137,138,139,140,141,142,143,
+  144,145,146,147,148,149,150,151,
+  152,153,154,155,156,157,158,159,
+  160,161,162,163,164,165,166,167,
+  168,169,170,171,172,173,174,175,
+  176,177,178,179,180,181,182,183,
+  184,185,186,187,188,189,190,191,
+  192,193,194,195,196,197,198,199,
+  200,201,202,203,204,205,206,207,
+  208,209,210,211,212,213,214,215,
+  216,217,218,219,220,221,222,223,
+  224,225,226,227,228,229,230,231,
+  232,233,234,235,236,237,238,239,
+  240,241,242,243,244,245,246,247,
+  248,249,250,251,252,253,254,255,
+
+/* This table contains bit maps for various character classes. Each map is 32
+bytes long and the bits run from the least significant end of each byte. The
+classes that have their own maps are: space, xdigit, digit, upper, lower, word,
+graph, print, punct, and cntrl. Other classes are built from combinations. */
+
+  0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
+  0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
+  0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,
+  0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/* This table identifies various classes of character by individual bits:
+  0x01   white space character
+  0x02   letter
+  0x04   decimal digit
+  0x08   hexadecimal digit
+  0x10   alphanumeric or '_'
+  0x80   regular expression metacharacter or binary zero
+*/
+
+  0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7 */
+  0x00,0x01,0x01,0x00,0x01,0x01,0x00,0x00, /*   8- 15 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */
+  0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /*    - '  */
+  0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /*  ( - /  */
+  0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /*  0 - 7  */
+  0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /*  8 - ?  */
+  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  @ - G  */
+  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  H - O  */
+  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  P - W  */
+  0x12,0x12,0x12,0x80,0x80,0x00,0x80,0x10, /*  X - _  */
+  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  ` - g  */
+  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  h - o  */
+  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  p - w  */
+  0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /*  x -127 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
+
+/* End of pcre_chartables.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_compile.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,6382 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_compile(), along with
+supporting internal functions that are not used by other modules. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define NLBLOCK cd             /* Block containing newline information */
+#define PSSTART start_pattern  /* Field containing processed string start */
+#define PSEND   end_pattern    /* Field containing processed string end */
+
+#include "pcre_internal.h"
+
+
+/* When DEBUG is defined, we need the pcre_printint() function, which is also
+used by pcretest. DEBUG is not defined when building a production library. */
+
+#ifdef DEBUG
+#include "pcre_printint.src"
+#endif
+
+
+/* Macro for setting individual bits in class bitmaps. */
+
+#define SETBIT(a,b) a[b/8] |= (1 << (b%8))
+
+/* Maximum length value to check against when making sure that the integer that
+holds the compiled pattern length does not overflow. We make it a bit less than
+INT_MAX to allow for adding in group terminating bytes, so that we don't have
+to check them every time. */
+
+#define OFLOW_MAX (INT_MAX - 20)
+
+
+/*************************************************
+*      Code parameters and static tables         *
+*************************************************/
+
+/* This value specifies the size of stack workspace that is used during the
+first pre-compile phase that determines how much memory is required. The regex
+is partly compiled into this space, but the compiled parts are discarded as
+soon as they can be, so that hopefully there will never be an overrun. The code
+does, however, check for an overrun. The largest amount I've seen used is 218,
+so this number is very generous.
+
+The same workspace is used during the second, actual compile phase for
+remembering forward references to groups so that they can be filled in at the
+end. Each entry in this list occupies LINK_SIZE bytes, so even when LINK_SIZE
+is 4 there is plenty of room. */
+
+#define COMPILE_WORK_SIZE (4096)
+
+
+/* Table for handling escaped characters in the range '0'-'z'. Positive returns
+are simple data values; negative values are for special things like \d and so
+on. Zero means further processing is needed (for things like \x), or the escape
+is invalid. */
+
+#ifndef EBCDIC  /* This is the "normal" table for ASCII systems */
+static const short int escapes[] = {
+     0,      0,      0,      0,      0,      0,      0,      0,   /* 0 - 7 */
+     0,      0,    ':',    ';',    '<',    '=',    '>',    '?',   /* 8 - ? */
+   '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E,      0, -ESC_G,   /* @ - G */
+-ESC_H,      0,      0, -ESC_K,      0,      0,      0,      0,   /* H - O */
+-ESC_P, -ESC_Q, -ESC_R, -ESC_S,      0,      0, -ESC_V, -ESC_W,   /* P - W */
+-ESC_X,      0, -ESC_Z,    '[',   '\\',    ']',    '^',    '_',   /* X - _ */
+   '`',      7, -ESC_b,      0, -ESC_d,  ESC_e,  ESC_f,      0,   /* ` - g */
+-ESC_h,      0,      0, -ESC_k,      0,      0,  ESC_n,      0,   /* h - o */
+-ESC_p,      0,  ESC_r, -ESC_s,  ESC_tee,    0, -ESC_v, -ESC_w,   /* p - w */
+     0,      0, -ESC_z                                            /* x - z */
+};
+
+#else           /* This is the "abnormal" table for EBCDIC systems */
+static const short int escapes[] = {
+/*  48 */     0,     0,      0,     '.',    '<',   '(',    '+',    '|',
+/*  50 */   '&',     0,      0,       0,      0,     0,      0,      0,
+/*  58 */     0,     0,    '!',     '$',    '*',   ')',    ';',    '~',
+/*  60 */   '-',   '/',      0,       0,      0,     0,      0,      0,
+/*  68 */     0,     0,    '|',     ',',    '%',   '_',    '>',    '?',
+/*  70 */     0,     0,      0,       0,      0,     0,      0,      0,
+/*  78 */     0,   '`',    ':',     '#',    '@',  '\'',    '=',    '"',
+/*  80 */     0,     7, -ESC_b,       0, -ESC_d, ESC_e,  ESC_f,      0,
+/*  88 */-ESC_h,     0,      0,     '{',      0,     0,      0,      0,
+/*  90 */     0,     0, -ESC_k,     'l',      0, ESC_n,      0, -ESC_p,
+/*  98 */     0, ESC_r,      0,     '}',      0,     0,      0,      0,
+/*  A0 */     0,   '~', -ESC_s, ESC_tee,      0,-ESC_v, -ESC_w,      0,
+/*  A8 */     0,-ESC_z,      0,       0,      0,   '[',      0,      0,
+/*  B0 */     0,     0,      0,       0,      0,     0,      0,      0,
+/*  B8 */     0,     0,      0,       0,      0,   ']',    '=',    '-',
+/*  C0 */   '{',-ESC_A, -ESC_B,  -ESC_C, -ESC_D,-ESC_E,      0, -ESC_G,
+/*  C8 */-ESC_H,     0,      0,       0,      0,     0,      0,      0,
+/*  D0 */   '}',     0, -ESC_K,       0,      0,     0,      0, -ESC_P,
+/*  D8 */-ESC_Q,-ESC_R,      0,       0,      0,     0,      0,      0,
+/*  E0 */  '\\',     0, -ESC_S,       0,      0,-ESC_V, -ESC_W, -ESC_X,
+/*  E8 */     0,-ESC_Z,      0,       0,      0,     0,      0,      0,
+/*  F0 */     0,     0,      0,       0,      0,     0,      0,      0,
+/*  F8 */     0,     0,      0,       0,      0,     0,      0,      0
+};
+#endif
+
+
+/* Table of special "verbs" like (*PRUNE). This is a short table, so it is
+searched linearly. Put all the names into a single string, in order to reduce
+the number of relocations when a shared library is dynamically linked. */
+
+typedef struct verbitem {
+  int   len;
+  int   op;
+} verbitem;
+
+static const char verbnames[] =
+  "ACCEPT\0"
+  "COMMIT\0"
+  "F\0"
+  "FAIL\0"
+  "PRUNE\0"
+  "SKIP\0"
+  "THEN";
+
+static const verbitem verbs[] = {
+  { 6, OP_ACCEPT },
+  { 6, OP_COMMIT },
+  { 1, OP_FAIL },
+  { 4, OP_FAIL },
+  { 5, OP_PRUNE },
+  { 4, OP_SKIP  },
+  { 4, OP_THEN  }
+};
+
+static const int verbcount = sizeof(verbs)/sizeof(verbitem);
+
+
+/* Tables of names of POSIX character classes and their lengths. The names are
+now all in a single string, to reduce the number of relocations when a shared
+library is dynamically loaded. The list of lengths is terminated by a zero
+length entry. The first three must be alpha, lower, upper, as this is assumed
+for handling case independence. */
+
+static const char posix_names[] =
+  "alpha\0"  "lower\0"  "upper\0"  "alnum\0"  "ascii\0"  "blank\0"
+  "cntrl\0"  "digit\0"  "graph\0"  "print\0"  "punct\0"  "space\0"
+  "word\0"   "xdigit";
+
+static const uschar posix_name_lengths[] = {
+  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };
+
+/* Table of class bit maps for each POSIX class. Each class is formed from a
+base map, with an optional addition or removal of another map. Then, for some
+classes, there is some additional tweaking: for [:blank:] the vertical space
+characters are removed, and for [:alpha:] and [:alnum:] the underscore
+character is removed. The triples in the table consist of the base map offset,
+second map offset or -1 if no second map, and a non-negative value for map
+addition or a negative value for map subtraction (if there are two maps). The
+absolute value of the third field has these meanings: 0 => no tweaking, 1 =>
+remove vertical space characters, 2 => remove underscore. */
+
+static const int posix_class_maps[] = {
+  cbit_word,  cbit_digit, -2,             /* alpha */
+  cbit_lower, -1,          0,             /* lower */
+  cbit_upper, -1,          0,             /* upper */
+  cbit_word,  -1,          2,             /* alnum - word without underscore */
+  cbit_print, cbit_cntrl,  0,             /* ascii */
+  cbit_space, -1,          1,             /* blank - a GNU extension */
+  cbit_cntrl, -1,          0,             /* cntrl */
+  cbit_digit, -1,          0,             /* digit */
+  cbit_graph, -1,          0,             /* graph */
+  cbit_print, -1,          0,             /* print */
+  cbit_punct, -1,          0,             /* punct */
+  cbit_space, -1,          0,             /* space */
+  cbit_word,  -1,          0,             /* word - a Perl extension */
+  cbit_xdigit,-1,          0              /* xdigit */
+};
+
+
+#define STRING(a)  # a
+#define XSTRING(s) STRING(s)
+
+/* The texts of compile-time error messages. These are "char *" because they
+are passed to the outside world. Do not ever re-use any error number, because
+they are documented. Always add a new error instead. Messages marked DEAD below
+are no longer used. This used to be a table of strings, but in order to reduce
+the number of relocations needed when a shared library is loaded dynamically,
+it is now one long string. We cannot use a table of offsets, because the
+lengths of inserts such as XSTRING(MAX_NAME_SIZE) are not known. Instead, we
+simply count through to the one we want - this isn't a performance issue
+because these strings are used only when there is a compilation error. */
+
+static const char error_texts[] =
+  "no error\0"
+  "\\ at end of pattern\0"
+  "\\c at end of pattern\0"
+  "unrecognized character follows \\\0"
+  "numbers out of order in {} quantifier\0"
+  /* 5 */
+  "number too big in {} quantifier\0"
+  "missing terminating ] for character class\0"
+  "invalid escape sequence in character class\0"
+  "range out of order in character class\0"
+  "nothing to repeat\0"
+  /* 10 */
+  "operand of unlimited repeat could match the empty string\0"  /** DEAD **/
+  "internal error: unexpected repeat\0"
+  "unrecognized character after (? or (?-\0"
+  "POSIX named classes are supported only within a class\0"
+  "missing )\0"
+  /* 15 */
+  "reference to non-existent subpattern\0"
+  "erroffset passed as NULL\0"
+  "unknown option bit(s) set\0"
+  "missing ) after comment\0"
+  "parentheses nested too deeply\0"  /** DEAD **/
+  /* 20 */
+  "regular expression is too large\0"
+  "failed to get memory\0"
+  "unmatched parentheses\0"
+  "internal error: code overflow\0"
+  "unrecognized character after (?<\0"
+  /* 25 */
+  "lookbehind assertion is not fixed length\0"
+  "malformed number or name after (?(\0"
+  "conditional group contains more than two branches\0"
+  "assertion expected after (?(\0"
+  "(?R or (?[+-]digits must be followed by )\0"
+  /* 30 */
+  "unknown POSIX class name\0"
+  "POSIX collating elements are not supported\0"
+  "this version of PCRE is not compiled with PCRE_UTF8 support\0"
+  "spare error\0"  /** DEAD **/
+  "character value in \\x{...} sequence is too large\0"
+  /* 35 */
+  "invalid condition (?(0)\0"
+  "\\C not allowed in lookbehind assertion\0"
+  "PCRE does not support \\L, \\l, \\N, \\U, or \\u\0"
+  "number after (?C is > 255\0"
+  "closing ) for (?C expected\0"
+  /* 40 */
+  "recursive call could loop indefinitely\0"
+  "unrecognized character after (?P\0"
+  "syntax error in subpattern name (missing terminator)\0"
+  "two named subpatterns have the same name\0"
+  "invalid UTF-8 string\0"
+  /* 45 */
+  "support for \\P, \\p, and \\X has not been compiled\0"
+  "malformed \\P or \\p sequence\0"
+  "unknown property name after \\P or \\p\0"
+  "subpattern name is too long (maximum " XSTRING(MAX_NAME_SIZE) " characters)\0"
+  "too many named subpatterns (maximum " XSTRING(MAX_NAME_COUNT) ")\0"
+  /* 50 */
+  "repeated subpattern is too long\0"    /** DEAD **/
+  "octal value is greater than \\377 (not in UTF-8 mode)\0"
+  "internal error: overran compiling workspace\0"
+  "internal error: previously-checked referenced subpattern not found\0"
+  "DEFINE group contains more than one branch\0"
+  /* 55 */
+  "repeating a DEFINE group is not allowed\0"
+  "inconsistent NEWLINE options\0"
+  "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"
+  "a numbered reference must not be zero\0"
+  "(*VERB) with an argument is not supported\0"
+  /* 60 */
+  "(*VERB) not recognized\0"
+  "number is too big\0"
+  "subpattern name expected\0"
+  "digit expected after (?+\0"
+  "] is an invalid data character in JavaScript compatibility mode";
+
+
+/* Table to identify digits and hex digits. This is used when compiling
+patterns. Note that the tables in chartables are dependent on the locale, and
+may mark arbitrary characters as digits - but the PCRE compiling code expects
+to handle only 0-9, a-z, and A-Z as digits when compiling. That is why we have
+a private table here. It costs 256 bytes, but it is a lot faster than doing
+character value tests (at least in some simple cases I timed), and in some
+applications one wants PCRE to compile efficiently as well as match
+efficiently.
+
+For convenience, we use the same bit definitions as in chartables:
+
+  0x04   decimal digit
+  0x08   hexadecimal digit
+
+Then we can use ctype_digit and ctype_xdigit in the code. */
+
+#ifndef EBCDIC  /* This is the "normal" case, for ASCII systems */
+static const unsigned char digitab[] =
+  {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   8- 15 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - '  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ( - /  */
+  0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /*  0 - 7  */
+  0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /*  8 - ?  */
+  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  @ - G  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  H - O  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  P - W  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  X - _  */
+  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  ` - g  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  h - o  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  p - w  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  x -127 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
+
+#else           /* This is the "abnormal" case, for EBCDIC systems */
+static const unsigned char digitab[] =
+  {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7  0 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   8- 15    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 10 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  32- 39 20 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  40- 47    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  48- 55 30 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  56- 63    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - 71 40 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  72- |     */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  & - 87 50 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  88- 95    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  - -103 60 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 104- ?     */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 70 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- "     */
+  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* 128- g  80 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  h -143    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144- p  90 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  q -159    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160- x  A0 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  y -175    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ^ -183 B0 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191    */
+  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  { - G  C0 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  H -207    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  } - P  D0 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  Q -223    */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  \ - X  E0 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  Y -239    */
+  0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /*  0 - 7  F0 */
+  0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00};/*  8 -255    */
+
+static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */
+  0x80,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*   0-  7 */
+  0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00, /*   8- 15 */
+  0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*  16- 23 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */
+  0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*  32- 39 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  40- 47 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  48- 55 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  56- 63 */
+  0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - 71 */
+  0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80, /*  72- |  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  & - 87 */
+  0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00, /*  88- 95 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  - -103 */
+  0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x80, /* 104- ?  */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- "  */
+  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* 128- g  */
+  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  h -143 */
+  0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* 144- p  */
+  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  q -159 */
+  0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /* 160- x  */
+  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  y -175 */
+  0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ^ -183 */
+  0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
+  0x80,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  { - G  */
+  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  H -207 */
+  0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  } - P  */
+  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  Q -223 */
+  0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /*  \ - X  */
+  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  Y -239 */
+  0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /*  0 - 7  */
+  0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00};/*  8 -255 */
+#endif
+
+
+/* Definition to allow mutual recursion */
+
+static BOOL
+  compile_regex(int, int, uschar **, const uschar **, int *, BOOL, BOOL, int,
+    int *, int *, branch_chain *, compile_data *, int *);
+
+
+
+/*************************************************
+*            Find an error text                  *
+*************************************************/
+
+/* The error texts are now all in one long string, to save on relocations. As
+some of the text is of unknown length, we can't use a table of offsets.
+Instead, just count through the strings. This is not a performance issue
+because it happens only when there has been a compilation error.
+
+Argument:   the error number
+Returns:    pointer to the error string
+*/
+
+static const char *
+find_error_text(int n)
+{
+const char *s = error_texts;
+for (; n > 0; n--) while (*s++ != 0) {};
+return s;
+}
+
+
+/*************************************************
+*            Handle escapes                      *
+*************************************************/
+
+/* This function is called when a \ has been encountered. It either returns a
+positive value for a simple escape such as \n, or a negative value which
+encodes one of the more complicated things such as \d. A backreference to group
+n is returned as -(ESC_REF + n); ESC_REF is the highest ESC_xxx macro. When
+UTF-8 is enabled, a positive value greater than 255 may be returned. On entry,
+ptr is pointing at the \. On exit, it is on the final character of the escape
+sequence.
+
+Arguments:
+  ptrptr         points to the pattern position pointer
+  errorcodeptr   points to the errorcode variable
+  bracount       number of previous extracting brackets
+  options        the options bits
+  isclass        TRUE if inside a character class
+
+Returns:         zero or positive => a data character
+                 negative => a special escape sequence
+                 on error, errorcodeptr is set
+*/
+
+static int
+check_escape(const uschar **ptrptr, int *errorcodeptr, int bracount,
+  int options, BOOL isclass)
+{
+BOOL utf8 = (options & PCRE_UTF8) != 0;
+const uschar *ptr = *ptrptr + 1;
+int c, i;
+
+GETCHARINCTEST(c, ptr);           /* Get character value, increment pointer */
+ptr--;                            /* Set pointer back to the last byte */
+
+/* If backslash is at the end of the pattern, it's an error. */
+
+if (c == 0) *errorcodeptr = ERR1;
+
+/* Non-alphanumerics are literals. For digits or letters, do an initial lookup
+in a table. A non-zero result is something that can be returned immediately.
+Otherwise further processing may be required. */
+
+#ifndef EBCDIC  /* ASCII coding */
+else if (c < '0' || c > 'z') {}                           /* Not alphanumeric */
+else if ((i = escapes[c - '0']) != 0) c = i;
+
+#else           /* EBCDIC coding */
+else if (c < 'a' || (ebcdic_chartab[c] & 0x0E) == 0) {}   /* Not alphanumeric */
+else if ((i = escapes[c - 0x48]) != 0)  c = i;
+#endif
+
+/* Escapes that need further processing, or are illegal. */
+
+else
+  {
+  const uschar *oldptr;
+  BOOL braced, negated;
+
+  switch (c)
+    {
+    /* A number of Perl escapes are not handled by PCRE. We give an explicit
+    error. */
+
+    case 'l':
+    case 'L':
+    case 'N':
+    case 'u':
+    case 'U':
+    *errorcodeptr = ERR37;
+    break;
+
+    /* \g must be followed by one of a number of specific things:
+
+    (1) A number, either plain or braced. If positive, it is an absolute
+    backreference. If negative, it is a relative backreference. This is a Perl
+    5.10 feature.
+
+    (2) Perl 5.10 also supports \g{name} as a reference to a named group. This
+    is part of Perl's movement towards a unified syntax for back references. As
+    this is synonymous with \k{name}, we fudge it up by pretending it really
+    was \k.
+
+    (3) For Oniguruma compatibility we also support \g followed by a name or a
+    number either in angle brackets or in single quotes. However, these are
+    (possibly recursive) subroutine calls, _not_ backreferences. Just return
+    the -ESC_g code (cf \k). */
+
+    case 'g':
+    if (ptr[1] == '<' || ptr[1] == '\'')
+      {
+      c = -ESC_g;
+      break;
+      }
+
+    /* Handle the Perl-compatible cases */
+
+    if (ptr[1] == '{')
+      {
+      const uschar *p;
+      for (p = ptr+2; *p != 0 && *p != '}'; p++)
+        if (*p != '-' && (digitab[*p] & ctype_digit) == 0) break;
+      if (*p != 0 && *p != '}')
+        {
+        c = -ESC_k;
+        break;
+        }
+      braced = TRUE;
+      ptr++;
+      }
+    else braced = FALSE;
+
+    if (ptr[1] == '-')
+      {
+      negated = TRUE;
+      ptr++;
+      }
+    else negated = FALSE;
+
+    c = 0;
+    while ((digitab[ptr[1]] & ctype_digit) != 0)
+      c = c * 10 + *(++ptr) - '0';
+
+    if (c < 0)   /* Integer overflow */
+      {
+      *errorcodeptr = ERR61;
+      break;
+      }
+
+    if (braced && *(++ptr) != '}')
+      {
+      *errorcodeptr = ERR57;
+      break;
+      }
+
+    if (c == 0)
+      {
+      *errorcodeptr = ERR58;
+      break;
+      }
+
+    if (negated)
+      {
+      if (c > bracount)
+        {
+        *errorcodeptr = ERR15;
+        break;
+        }
+      c = bracount - (c - 1);
+      }
+
+    c = -(ESC_REF + c);
+    break;
+
+    /* The handling of escape sequences consisting of a string of digits
+    starting with one that is not zero is not straightforward. By experiment,
+    the way Perl works seems to be as follows:
+
+    Outside a character class, the digits are read as a decimal number. If the
+    number is less than 10, or if there are that many previous extracting
+    left brackets, then it is a back reference. Otherwise, up to three octal
+    digits are read to form an escaped byte. Thus \123 is likely to be octal
+    123 (cf \0123, which is octal 012 followed by the literal 3). If the octal
+    value is greater than 377, the least significant 8 bits are taken. Inside a
+    character class, \ followed by a digit is always an octal number. */
+
+    case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+
+    if (!isclass)
+      {
+      oldptr = ptr;
+      c -= '0';
+      while ((digitab[ptr[1]] & ctype_digit) != 0)
+        c = c * 10 + *(++ptr) - '0';
+      if (c < 0)    /* Integer overflow */
+        {
+        *errorcodeptr = ERR61;
+        break;
+        }
+      if (c < 10 || c <= bracount)
+        {
+        c = -(ESC_REF + c);
+        break;
+        }
+      ptr = oldptr;      /* Put the pointer back and fall through */
+      }
+
+    /* Handle an octal number following \. If the first digit is 8 or 9, Perl
+    generates a binary zero byte and treats the digit as a following literal.
+    Thus we have to pull back the pointer by one. */
+
+    if ((c = *ptr) >= '8')
+      {
+      ptr--;
+      c = 0;
+      break;
+      }
+
+    /* \0 always starts an octal number, but we may drop through to here with a
+    larger first octal digit. The original code used just to take the least
+    significant 8 bits of octal numbers (I think this is what early Perls used
+    to do). Nowadays we allow for larger numbers in UTF-8 mode, but no more
+    than 3 octal digits. */
+
+    case '0':
+    c -= '0';
+    while(i++ < 2 && ptr[1] >= '0' && ptr[1] <= '7')
+        c = c * 8 + *(++ptr) - '0';
+    if (!utf8 && c > 255) *errorcodeptr = ERR51;
+    break;
+
+    /* \x is complicated. \x{ddd} is a character number which can be greater
+    than 0xff in utf8 mode, but only if the ddd are hex digits. If not, { is
+    treated as a data character. */
+
+    case 'x':
+    if (ptr[1] == '{')
+      {
+      const uschar *pt = ptr + 2;
+      int count = 0;
+
+      c = 0;
+      while ((digitab[*pt] & ctype_xdigit) != 0)
+        {
+        register int cc = *pt++;
+        if (c == 0 && cc == '0') continue;     /* Leading zeroes */
+        count++;
+
+#ifndef EBCDIC  /* ASCII coding */
+        if (cc >= 'a') cc -= 32;               /* Convert to upper case */
+        c = (c << 4) + cc - ((cc < 'A')? '0' : ('A' - 10));
+#else           /* EBCDIC coding */
+        if (cc >= 'a' && cc <= 'z') cc += 64;  /* Convert to upper case */
+        c = (c << 4) + cc - ((cc >= '0')? '0' : ('A' - 10));
+#endif
+        }
+
+      if (*pt == '}')
+        {
+        if (c < 0 || count > (utf8? 8 : 2)) *errorcodeptr = ERR34;
+        ptr = pt;
+        break;
+        }
+
+      /* If the sequence of hex digits does not end with '}', then we don't
+      recognize this construct; fall through to the normal \x handling. */
+      }
+
+    /* Read just a single-byte hex-defined char */
+
+    c = 0;
+    while (i++ < 2 && (digitab[ptr[1]] & ctype_xdigit) != 0)
+      {
+      int cc;                               /* Some compilers don't like ++ */
+      cc = *(++ptr);                        /* in initializers */
+#ifndef EBCDIC  /* ASCII coding */
+      if (cc >= 'a') cc -= 32;              /* Convert to upper case */
+      c = c * 16 + cc - ((cc < 'A')? '0' : ('A' - 10));
+#else           /* EBCDIC coding */
+      if (cc <= 'z') cc += 64;              /* Convert to upper case */
+      c = c * 16 + cc - ((cc >= '0')? '0' : ('A' - 10));
+#endif
+      }
+    break;
+
+    /* For \c, a following letter is upper-cased; then the 0x40 bit is flipped.
+    This coding is ASCII-specific, but then the whole concept of \cx is
+    ASCII-specific. (However, an EBCDIC equivalent has now been added.) */
+
+    case 'c':
+    c = *(++ptr);
+    if (c == 0)
+      {
+      *errorcodeptr = ERR2;
+      break;
+      }
+
+#ifndef EBCDIC  /* ASCII coding */
+    if (c >= 'a' && c <= 'z') c -= 32;
+    c ^= 0x40;
+#else           /* EBCDIC coding */
+    if (c >= 'a' && c <= 'z') c += 64;
+    c ^= 0xC0;
+#endif
+    break;
+
+    /* PCRE_EXTRA enables extensions to Perl in the matter of escapes. Any
+    other alphanumeric following \ is an error if PCRE_EXTRA was set;
+    otherwise, for Perl compatibility, it is a literal. This code looks a bit
+    odd, but there used to be some cases other than the default, and there may
+    be again in future, so I haven't "optimized" it. */
+
+    default:
+    if ((options & PCRE_EXTRA) != 0) switch(c)
+      {
+      default:
+      *errorcodeptr = ERR3;
+      break;
+      }
+    break;
+    }
+  }
+
+*ptrptr = ptr;
+return c;
+}
+
+
+
+#ifdef SUPPORT_UCP
+/*************************************************
+*               Handle \P and \p                 *
+*************************************************/
+
+/* This function is called after \P or \p has been encountered, provided that
+PCRE is compiled with support for Unicode properties. On entry, ptrptr is
+pointing at the P or p. On exit, it is pointing at the final character of the
+escape sequence.
+
+Argument:
+  ptrptr         points to the pattern position pointer
+  negptr         points to a boolean that is set TRUE for negation else FALSE
+  dptr           points to an int that is set to the detailed property value
+  errorcodeptr   points to the error code variable
+
+Returns:         type value from ucp_type_table, or -1 for an invalid type
+*/
+
+static int
+get_ucp(const uschar **ptrptr, BOOL *negptr, int *dptr, int *errorcodeptr)
+{
+int c, i, bot, top;
+const uschar *ptr = *ptrptr;
+char name[32];
+
+c = *(++ptr);
+if (c == 0) goto ERROR_RETURN;
+
+*negptr = FALSE;
+
+/* \P or \p can be followed by a name in {}, optionally preceded by ^ for
+negation. */
+
+if (c == '{')
+  {
+  if (ptr[1] == '^')
+    {
+    *negptr = TRUE;
+    ptr++;
+    }
+  for (i = 0; i < (int)sizeof(name) - 1; i++)
+    {
+    c = *(++ptr);
+    if (c == 0) goto ERROR_RETURN;
+    if (c == '}') break;
+    name[i] = c;
+    }
+  if (c !='}') goto ERROR_RETURN;
+  name[i] = 0;
+  }
+
+/* Otherwise there is just one following character */
+
+else
+  {
+  name[0] = c;
+  name[1] = 0;
+  }
+
+*ptrptr = ptr;
+
+/* Search for a recognized property name using binary chop */
+
+bot = 0;
+top = _pcre_utt_size;
+
+while (bot < top)
+  {
+  i = (bot + top) >> 1;
+  c = strcmp(name, _pcre_utt_names + _pcre_utt[i].name_offset);
+  if (c == 0)
+    {
+    *dptr = _pcre_utt[i].value;
+    return _pcre_utt[i].type;
+    }
+  if (c > 0) bot = i + 1; else top = i;
+  }
+
+*errorcodeptr = ERR47;
+*ptrptr = ptr;
+return -1;
+
+ERROR_RETURN:
+*errorcodeptr = ERR46;
+*ptrptr = ptr;
+return -1;
+}
+#endif
+
+
+
+
+/*************************************************
+*            Check for counted repeat            *
+*************************************************/
+
+/* This function is called when a '{' is encountered in a place where it might
+start a quantifier. It looks ahead to see if it really is a quantifier or not.
+It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd}
+where the ddds are digits.
+
+Arguments:
+  p         pointer to the first char after '{'
+
+Returns:    TRUE or FALSE
+*/
+
+static BOOL
+is_counted_repeat(const uschar *p)
+{
+if ((digitab[*p++] & ctype_digit) == 0) return FALSE;
+while ((digitab[*p] & ctype_digit) != 0) p++;
+if (*p == '}') return TRUE;
+
+if (*p++ != ',') return FALSE;
+if (*p == '}') return TRUE;
+
+if ((digitab[*p++] & ctype_digit) == 0) return FALSE;
+while ((digitab[*p] & ctype_digit) != 0) p++;
+
+return (*p == '}');
+}
+
+
+
+/*************************************************
+*         Read repeat counts                     *
+*************************************************/
+
+/* Read an item of the form {n,m} and return the values. This is called only
+after is_counted_repeat() has confirmed that a repeat-count quantifier exists,
+so the syntax is guaranteed to be correct, but we need to check the values.
+
+Arguments:
+  p              pointer to first char after '{'
+  minp           pointer to int for min
+  maxp           pointer to int for max
+                 returned as -1 if no max
+  errorcodeptr   points to error code variable
+
+Returns:         pointer to '}' on success;
+                 current ptr on error, with errorcodeptr set non-zero
+*/
+
+static const uschar *
+read_repeat_counts(const uschar *p, int *minp, int *maxp, int *errorcodeptr)
+{
+int min = 0;
+int max = -1;
+
+/* Read the minimum value and do a paranoid check: a negative value indicates
+an integer overflow. */
+
+while ((digitab[*p] & ctype_digit) != 0) min = min * 10 + *p++ - '0';
+if (min < 0 || min > 65535)
+  {
+  *errorcodeptr = ERR5;
+  return p;
+  }
+
+/* Read the maximum value if there is one, and again do a paranoid on its size.
+Also, max must not be less than min. */
+
+if (*p == '}') max = min; else
+  {
+  if (*(++p) != '}')
+    {
+    max = 0;
+    while((digitab[*p] & ctype_digit) != 0) max = max * 10 + *p++ - '0';
+    if (max < 0 || max > 65535)
+      {
+      *errorcodeptr = ERR5;
+      return p;
+      }
+    if (max < min)
+      {
+      *errorcodeptr = ERR4;
+      return p;
+      }
+    }
+  }
+
+/* Fill in the required variables, and pass back the pointer to the terminating
+'}'. */
+
+*minp = min;
+*maxp = max;
+return p;
+}
+
+
+
+/*************************************************
+*       Find forward referenced subpattern       *
+*************************************************/
+
+/* This function scans along a pattern's text looking for capturing
+subpatterns, and counting them. If it finds a named pattern that matches the
+name it is given, it returns its number. Alternatively, if the name is NULL, it
+returns when it reaches a given numbered subpattern. This is used for forward
+references to subpatterns. We know that if (?P< is encountered, the name will
+be terminated by '>' because that is checked in the first pass.
+
+Arguments:
+  ptr          current position in the pattern
+  cd           compile background data
+  name         name to seek, or NULL if seeking a numbered subpattern
+  lorn         name length, or subpattern number if name is NULL
+  xmode        TRUE if we are in /x mode
+
+Returns:       the number of the named subpattern, or -1 if not found
+*/
+
+static int
+find_parens(const uschar *ptr, compile_data *cd, const uschar *name, int lorn,
+  BOOL xmode)
+{
+const uschar *thisname;
+int count = cd->bracount;
+
+for (; *ptr != 0; ptr++)
+  {
+  int term;
+
+  /* Skip over backslashed characters and also entire \Q...\E */
+
+  if (*ptr == '\\')
+    {
+    if (*(++ptr) == 0) return -1;
+    if (*ptr == 'Q') for (;;)
+      {
+      while (*(++ptr) != 0 && *ptr != '\\') {};
+      if (*ptr == 0) return -1;
+      if (*(++ptr) == 'E') break;
+      }
+    continue;
+    }
+
+  /* Skip over character classes; this logic must be similar to the way they
+  are handled for real. If the first character is '^', skip it. Also, if the
+  first few characters (either before or after ^) are \Q\E or \E we skip them
+  too. This makes for compatibility with Perl. */
+
+  if (*ptr == '[')
+    {
+    BOOL negate_class = FALSE;
+    for (;;)
+      {
+      int c = *(++ptr);
+      if (c == '\\')
+        {
+        if (ptr[1] == 'E') ptr++;
+          else if (strncmp((const char *)ptr+1, "Q\\E", 3) == 0) ptr += 3;
+            else break;
+        }
+      else if (!negate_class && c == '^')
+        negate_class = TRUE;
+      else break;
+      }
+
+    /* If the next character is ']', it is a data character that must be
+    skipped, except in JavaScript compatibility mode. */
+
+    if (ptr[1] == ']' && (cd->external_options & PCRE_JAVASCRIPT_COMPAT) == 0)
+      ptr++;
+
+    while (*(++ptr) != ']')
+      {
+      if (*ptr == 0) return -1;
+      if (*ptr == '\\')
+        {
+        if (*(++ptr) == 0) return -1;
+        if (*ptr == 'Q') for (;;)
+          {
+          while (*(++ptr) != 0 && *ptr != '\\') {};
+          if (*ptr == 0) return -1;
+          if (*(++ptr) == 'E') break;
+          }
+        continue;
+        }
+      }
+    continue;
+    }
+
+  /* Skip comments in /x mode */
+
+  if (xmode && *ptr == '#')
+    {
+    while (*(++ptr) != 0 && *ptr != '\n') {};
+    if (*ptr == 0) return -1;
+    continue;
+    }
+
+  /* An opening parens must now be a real metacharacter */
+
+  if (*ptr != '(') continue;
+  if (ptr[1] != '?' && ptr[1] != '*')
+    {
+    count++;
+    if (name == NULL && count == lorn) return count;
+    continue;
+    }
+
+  ptr += 2;
+  if (*ptr == 'P') ptr++;                      /* Allow optional P */
+
+  /* We have to disambiguate (?<! and (?<= from (?<name> */
+
+  if ((*ptr != '<' || ptr[1] == '!' || ptr[1] == '=') &&
+       *ptr != '\'')
+    continue;
+
+  count++;
+
+  if (name == NULL && count == lorn) return count;
+  term = *ptr++;
+  if (term == '<') term = '>';
+  thisname = ptr;
+  while (*ptr != term) ptr++;
+  if (name != NULL && lorn == ptr - thisname &&
+      strncmp((const char *)name, (const char *)thisname, lorn) == 0)
+    return count;
+  }
+
+return -1;
+}
+
+
+
+/*************************************************
+*      Find first significant op code            *
+*************************************************/
+
+/* This is called by several functions that scan a compiled expression looking
+for a fixed first character, or an anchoring op code etc. It skips over things
+that do not influence this. For some calls, a change of option is important.
+For some calls, it makes sense to skip negative forward and all backward
+assertions, and also the \b assertion; for others it does not.
+
+Arguments:
+  code         pointer to the start of the group
+  options      pointer to external options
+  optbit       the option bit whose changing is significant, or
+                 zero if none are
+  skipassert   TRUE if certain assertions are to be skipped
+
+Returns:       pointer to the first significant opcode
+*/
+
+static const uschar*
+first_significant_code(const uschar *code, int *options, int optbit,
+  BOOL skipassert)
+{
+for (;;)
+  {
+  switch ((int)*code)
+    {
+    case OP_OPT:
+    if (optbit > 0 && ((int)code[1] & optbit) != (*options & optbit))
+      *options = (int)code[1];
+    code += 2;
+    break;
+
+    case OP_ASSERT_NOT:
+    case OP_ASSERTBACK:
+    case OP_ASSERTBACK_NOT:
+    if (!skipassert) return code;
+    do code += GET(code, 1); while (*code == OP_ALT);
+    code += _pcre_OP_lengths[*code];
+    break;
+
+    case OP_WORD_BOUNDARY:
+    case OP_NOT_WORD_BOUNDARY:
+    if (!skipassert) return code;
+    /* Fall through */
+
+    case OP_CALLOUT:
+    case OP_CREF:
+    case OP_RREF:
+    case OP_DEF:
+    code += _pcre_OP_lengths[*code];
+    break;
+
+    default:
+    return code;
+    }
+  }
+/* Control never reaches here */
+}
+
+
+
+
+/*************************************************
+*        Find the fixed length of a pattern      *
+*************************************************/
+
+/* Scan a pattern and compute the fixed length of subject that will match it,
+if the length is fixed. This is needed for dealing with backward assertions.
+In UTF8 mode, the result is in characters rather than bytes.
+
+Arguments:
+  code     points to the start of the pattern (the bracket)
+  options  the compiling options
+
+Returns:   the fixed length, or -1 if there is no fixed length,
+             or -2 if \C was encountered
+*/
+
+static int
+find_fixedlength(uschar *code, int options)
+{
+int length = -1;
+
+register int branchlength = 0;
+register uschar *cc = code + 1 + LINK_SIZE;
+
+/* Scan along the opcodes for this branch. If we get to the end of the
+branch, check the length against that of the other branches. */
+
+for (;;)
+  {
+  int d;
+  register int op = *cc;
+  switch (op)
+    {
+    case OP_CBRA:
+    case OP_BRA:
+    case OP_ONCE:
+    case OP_COND:
+    d = find_fixedlength(cc + ((op == OP_CBRA)? 2:0), options);
+    if (d < 0) return d;
+    branchlength += d;
+    do cc += GET(cc, 1); while (*cc == OP_ALT);
+    cc += 1 + LINK_SIZE;
+    break;
+
+    /* Reached end of a branch; if it's a ket it is the end of a nested
+    call. If it's ALT it is an alternation in a nested call. If it is
+    END it's the end of the outer call. All can be handled by the same code. */
+
+    case OP_ALT:
+    case OP_KET:
+    case OP_KETRMAX:
+    case OP_KETRMIN:
+    case OP_END:
+    if (length < 0) length = branchlength;
+      else if (length != branchlength) return -1;
+    if (*cc != OP_ALT) return length;
+    cc += 1 + LINK_SIZE;
+    branchlength = 0;
+    break;
+
+    /* Skip over assertive subpatterns */
+
+    case OP_ASSERT:
+    case OP_ASSERT_NOT:
+    case OP_ASSERTBACK:
+    case OP_ASSERTBACK_NOT:
+    do cc += GET(cc, 1); while (*cc == OP_ALT);
+    /* Fall through */
+
+    /* Skip over things that don't match chars */
+
+    case OP_REVERSE:
+    case OP_CREF:
+    case OP_RREF:
+    case OP_DEF:
+    case OP_OPT:
+    case OP_CALLOUT:
+    case OP_SOD:
+    case OP_SOM:
+    case OP_EOD:
+    case OP_EODN:
+    case OP_CIRC:
+    case OP_DOLL:
+    case OP_NOT_WORD_BOUNDARY:
+    case OP_WORD_BOUNDARY:
+    cc += _pcre_OP_lengths[*cc];
+    break;
+
+    /* Handle literal characters */
+
+    case OP_CHAR:
+    case OP_CHARNC:
+    case OP_NOT:
+    branchlength++;
+    cc += 2;
+#ifdef SUPPORT_UTF8
+    if ((options & PCRE_UTF8) != 0)
+      {
+      while ((*cc & 0xc0) == 0x80) cc++;
+      }
+#endif
+    break;
+
+    /* Handle exact repetitions. The count is already in characters, but we
+    need to skip over a multibyte character in UTF8 mode.  */
+
+    case OP_EXACT:
+    branchlength += GET2(cc,1);
+    cc += 4;
+#ifdef SUPPORT_UTF8
+    if ((options & PCRE_UTF8) != 0)
+      {
+      while((*cc & 0x80) == 0x80) cc++;
+      }
+#endif
+    break;
+
+    case OP_TYPEEXACT:
+    branchlength += GET2(cc,1);
+    if (cc[3] == OP_PROP || cc[3] == OP_NOTPROP) cc += 2;
+    cc += 4;
+    break;
+
+    /* Handle single-char matchers */
+
+    case OP_PROP:
+    case OP_NOTPROP:
+    cc += 2;
+    /* Fall through */
+
+    case OP_NOT_DIGIT:
+    case OP_DIGIT:
+    case OP_NOT_WHITESPACE:
+    case OP_WHITESPACE:
+    case OP_NOT_WORDCHAR:
+    case OP_WORDCHAR:
+    case OP_ANY:
+    case OP_ALLANY:
+    branchlength++;
+    cc++;
+    break;
+
+    /* The single-byte matcher isn't allowed */
+
+    case OP_ANYBYTE:
+    return -2;
+
+    /* Check a class for variable quantification */
+
+#ifdef SUPPORT_UTF8
+    case OP_XCLASS:
+    cc += GET(cc, 1) - 33;
+    /* Fall through */
+#endif
+
+    case OP_CLASS:
+    case OP_NCLASS:
+    cc += 33;
+
+    switch (*cc)
+      {
+      case OP_CRSTAR:
+      case OP_CRMINSTAR:
+      case OP_CRQUERY:
+      case OP_CRMINQUERY:
+      return -1;
+
+      case OP_CRRANGE:
+      case OP_CRMINRANGE:
+      if (GET2(cc,1) != GET2(cc,3)) return -1;
+      branchlength += GET2(cc,1);
+      cc += 5;
+      break;
+
+      default:
+      branchlength++;
+      }
+    break;
+
+    /* Anything else is variable length */
+
+    default:
+    return -1;
+    }
+  }
+/* Control never gets here */
+}
+
+
+
+
+/*************************************************
+*    Scan compiled regex for numbered bracket    *
+*************************************************/
+
+/* This little function scans through a compiled pattern until it finds a
+capturing bracket with the given number.
+
+Arguments:
+  code        points to start of expression
+  utf8        TRUE in UTF-8 mode
+  number      the required bracket number
+
+Returns:      pointer to the opcode for the bracket, or NULL if not found
+*/
+
+static const uschar *
+find_bracket(const uschar *code, BOOL utf8, int number)
+{
+for (;;)
+  {
+  register int c = *code;
+  if (c == OP_END) return NULL;
+
+  /* XCLASS is used for classes that cannot be represented just by a bit
+  map. This includes negated single high-valued characters. The length in
+  the table is zero; the actual length is stored in the compiled code. */
+
+  if (c == OP_XCLASS) code += GET(code, 1);
+
+  /* Handle capturing bracket */
+
+  else if (c == OP_CBRA)
+    {
+    int n = GET2(code, 1+LINK_SIZE);
+    if (n == number) return (uschar *)code;
+    code += _pcre_OP_lengths[c];
+    }
+
+  /* Otherwise, we can get the item's length from the table, except that for
+  repeated character types, we have to test for \p and \P, which have an extra
+  two bytes of parameters. */
+
+  else
+    {
+    switch(c)
+      {
+      case OP_TYPESTAR:
+      case OP_TYPEMINSTAR:
+      case OP_TYPEPLUS:
+      case OP_TYPEMINPLUS:
+      case OP_TYPEQUERY:
+      case OP_TYPEMINQUERY:
+      case OP_TYPEPOSSTAR:
+      case OP_TYPEPOSPLUS:
+      case OP_TYPEPOSQUERY:
+      if (code[1] == OP_PROP || code[1] == OP_NOTPROP) code += 2;
+      break;
+
+      case OP_TYPEUPTO:
+      case OP_TYPEMINUPTO:
+      case OP_TYPEEXACT:
+      case OP_TYPEPOSUPTO:
+      if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2;
+      break;
+      }
+
+    /* Add in the fixed length from the table */
+
+    code += _pcre_OP_lengths[c];
+
+  /* In UTF-8 mode, opcodes that are followed by a character may be followed by
+  a multi-byte character. The length in the table is a minimum, so we have to
+  arrange to skip the extra bytes. */
+
+#ifdef SUPPORT_UTF8
+    if (utf8) switch(c)
+      {
+      case OP_CHAR:
+      case OP_CHARNC:
+      case OP_EXACT:
+      case OP_UPTO:
+      case OP_MINUPTO:
+      case OP_POSUPTO:
+      case OP_STAR:
+      case OP_MINSTAR:
+      case OP_POSSTAR:
+      case OP_PLUS:
+      case OP_MINPLUS:
+      case OP_POSPLUS:
+      case OP_QUERY:
+      case OP_MINQUERY:
+      case OP_POSQUERY:
+      if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f];
+      break;
+      }
+#else
+    (void)(utf8);  /* Keep compiler happy by referencing function argument */
+#endif
+    }
+  }
+}
+
+
+
+/*************************************************
+*   Scan compiled regex for recursion reference  *
+*************************************************/
+
+/* This little function scans through a compiled pattern until it finds an
+instance of OP_RECURSE.
+
+Arguments:
+  code        points to start of expression
+  utf8        TRUE in UTF-8 mode
+
+Returns:      pointer to the opcode for OP_RECURSE, or NULL if not found
+*/
+
+static const uschar *
+find_recurse(const uschar *code, BOOL utf8)
+{
+for (;;)
+  {
+  register int c = *code;
+  if (c == OP_END) return NULL;
+  if (c == OP_RECURSE) return code;
+
+  /* XCLASS is used for classes that cannot be represented just by a bit
+  map. This includes negated single high-valued characters. The length in
+  the table is zero; the actual length is stored in the compiled code. */
+
+  if (c == OP_XCLASS) code += GET(code, 1);
+
+  /* Otherwise, we can get the item's length from the table, except that for
+  repeated character types, we have to test for \p and \P, which have an extra
+  two bytes of parameters. */
+
+  else
+    {
+    switch(c)
+      {
+      case OP_TYPESTAR:
+      case OP_TYPEMINSTAR:
+      case OP_TYPEPLUS:
+      case OP_TYPEMINPLUS:
+      case OP_TYPEQUERY:
+      case OP_TYPEMINQUERY:
+      case OP_TYPEPOSSTAR:
+      case OP_TYPEPOSPLUS:
+      case OP_TYPEPOSQUERY:
+      if (code[1] == OP_PROP || code[1] == OP_NOTPROP) code += 2;
+      break;
+
+      case OP_TYPEPOSUPTO:
+      case OP_TYPEUPTO:
+      case OP_TYPEMINUPTO:
+      case OP_TYPEEXACT:
+      if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2;
+      break;
+      }
+
+    /* Add in the fixed length from the table */
+
+    code += _pcre_OP_lengths[c];
+
+    /* In UTF-8 mode, opcodes that are followed by a character may be followed
+    by a multi-byte character. The length in the table is a minimum, so we have
+    to arrange to skip the extra bytes. */
+
+#ifdef SUPPORT_UTF8
+    if (utf8) switch(c)
+      {
+      case OP_CHAR:
+      case OP_CHARNC:
+      case OP_EXACT:
+      case OP_UPTO:
+      case OP_MINUPTO:
+      case OP_POSUPTO:
+      case OP_STAR:
+      case OP_MINSTAR:
+      case OP_POSSTAR:
+      case OP_PLUS:
+      case OP_MINPLUS:
+      case OP_POSPLUS:
+      case OP_QUERY:
+      case OP_MINQUERY:
+      case OP_POSQUERY:
+      if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f];
+      break;
+      }
+#else
+    (void)(utf8);  /* Keep compiler happy by referencing function argument */
+#endif
+    }
+  }
+}
+
+
+
+/*************************************************
+*    Scan compiled branch for non-emptiness      *
+*************************************************/
+
+/* This function scans through a branch of a compiled pattern to see whether it
+can match the empty string or not. It is called from could_be_empty()
+below and from compile_branch() when checking for an unlimited repeat of a
+group that can match nothing. Note that first_significant_code() skips over
+backward and negative forward assertions when its final argument is TRUE. If we
+hit an unclosed bracket, we return "empty" - this means we've struck an inner
+bracket whose current branch will already have been scanned.
+
+Arguments:
+  code        points to start of search
+  endcode     points to where to stop
+  utf8        TRUE if in UTF8 mode
+
+Returns:      TRUE if what is matched could be empty
+*/
+
+static BOOL
+could_be_empty_branch(const uschar *code, const uschar *endcode, BOOL utf8)
+{
+register int c;
+for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE);
+     code < endcode;
+     code = first_significant_code(code + _pcre_OP_lengths[c], NULL, 0, TRUE))
+  {
+  const uschar *ccode;
+
+  c = *code;
+
+  /* Skip over forward assertions; the other assertions are skipped by
+  first_significant_code() with a TRUE final argument. */
+
+  if (c == OP_ASSERT)
+    {
+    do code += GET(code, 1); while (*code == OP_ALT);
+    c = *code;
+    continue;
+    }
+
+  /* Groups with zero repeats can of course be empty; skip them. */
+
+  if (c == OP_BRAZERO || c == OP_BRAMINZERO || c == OP_SKIPZERO)
+    {
+    code += _pcre_OP_lengths[c];
+    do code += GET(code, 1); while (*code == OP_ALT);
+    c = *code;
+    continue;
+    }
+
+  /* For other groups, scan the branches. */
+
+  if (c == OP_BRA || c == OP_CBRA || c == OP_ONCE || c == OP_COND)
+    {
+    BOOL empty_branch;
+    if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */
+
+    /* Scan a closed bracket */
+
+    empty_branch = FALSE;
+    do
+      {
+      if (!empty_branch && could_be_empty_branch(code, endcode, utf8))
+        empty_branch = TRUE;
+      code += GET(code, 1);
+      }
+    while (*code == OP_ALT);
+    if (!empty_branch) return FALSE;   /* All branches are non-empty */
+    c = *code;
+    continue;
+    }
+
+  /* Handle the other opcodes */
+
+  switch (c)
+    {
+    /* Check for quantifiers after a class. XCLASS is used for classes that
+    cannot be represented just by a bit map. This includes negated single
+    high-valued characters. The length in _pcre_OP_lengths[] is zero; the
+    actual length is stored in the compiled code, so we must update "code"
+    here. */
+
+#ifdef SUPPORT_UTF8
+    case OP_XCLASS:
+    ccode = code += GET(code, 1);
+    goto CHECK_CLASS_REPEAT;
+#endif
+
+    case OP_CLASS:
+    case OP_NCLASS:
+    ccode = code + 33;
+
+#ifdef SUPPORT_UTF8
+    CHECK_CLASS_REPEAT:
+#endif
+
+    switch (*ccode)
+      {
+      case OP_CRSTAR:            /* These could be empty; continue */
+      case OP_CRMINSTAR:
+      case OP_CRQUERY:
+      case OP_CRMINQUERY:
+      break;
+
+      default:                   /* Non-repeat => class must match */
+      case OP_CRPLUS:            /* These repeats aren't empty */
+      case OP_CRMINPLUS:
+      return FALSE;
+
+      case OP_CRRANGE:
+      case OP_CRMINRANGE:
+      if (GET2(ccode, 1) > 0) return FALSE;  /* Minimum > 0 */
+      break;
+      }
+    break;
+
+    /* Opcodes that must match a character */
+
+    case OP_PROP:
+    case OP_NOTPROP:
+    case OP_EXTUNI:
+    case OP_NOT_DIGIT:
+    case OP_DIGIT:
+    case OP_NOT_WHITESPACE:
+    case OP_WHITESPACE:
+    case OP_NOT_WORDCHAR:
+    case OP_WORDCHAR:
+    case OP_ANY:
+    case OP_ALLANY:
+    case OP_ANYBYTE:
+    case OP_CHAR:
+    case OP_CHARNC:
+    case OP_NOT:
+    case OP_PLUS:
+    case OP_MINPLUS:
+    case OP_POSPLUS:
+    case OP_EXACT:
+    case OP_NOTPLUS:
+    case OP_NOTMINPLUS:
+    case OP_NOTPOSPLUS:
+    case OP_NOTEXACT:
+    case OP_TYPEPLUS:
+    case OP_TYPEMINPLUS:
+    case OP_TYPEPOSPLUS:
+    case OP_TYPEEXACT:
+    return FALSE;
+
+    /* These are going to continue, as they may be empty, but we have to
+    fudge the length for the \p and \P cases. */
+
+    case OP_TYPESTAR:
+    case OP_TYPEMINSTAR:
+    case OP_TYPEPOSSTAR:
+    case OP_TYPEQUERY:
+    case OP_TYPEMINQUERY:
+    case OP_TYPEPOSQUERY:
+    if (code[1] == OP_PROP || code[1] == OP_NOTPROP) code += 2;
+    break;
+
+    /* Same for these */
+
+    case OP_TYPEUPTO:
+    case OP_TYPEMINUPTO:
+    case OP_TYPEPOSUPTO:
+    if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2;
+    break;
+
+    /* End of branch */
+
+    case OP_KET:
+    case OP_KETRMAX:
+    case OP_KETRMIN:
+    case OP_ALT:
+    return TRUE;
+
+    /* In UTF-8 mode, STAR, MINSTAR, POSSTAR, QUERY, MINQUERY, POSQUERY, UPTO,
+    MINUPTO, and POSUPTO may be followed by a multibyte character */
+
+#ifdef SUPPORT_UTF8
+    case OP_STAR:
+    case OP_MINSTAR:
+    case OP_POSSTAR:
+    case OP_QUERY:
+    case OP_MINQUERY:
+    case OP_POSQUERY:
+    case OP_UPTO:
+    case OP_MINUPTO:
+    case OP_POSUPTO:
+    if (utf8) while ((code[2] & 0xc0) == 0x80) code++;
+    break;
+#endif
+    }
+  }
+
+return TRUE;
+}
+
+
+
+/*************************************************
+*    Scan compiled regex for non-emptiness       *
+*************************************************/
+
+/* This function is called to check for left recursive calls. We want to check
+the current branch of the current pattern to see if it could match the empty
+string. If it could, we must look outwards for branches at other levels,
+stopping when we pass beyond the bracket which is the subject of the recursion.
+
+Arguments:
+  code        points to start of the recursion
+  endcode     points to where to stop (current RECURSE item)
+  bcptr       points to the chain of current (unclosed) branch starts
+  utf8        TRUE if in UTF-8 mode
+
+Returns:      TRUE if what is matched could be empty
+*/
+
+static BOOL
+could_be_empty(const uschar *code, const uschar *endcode, branch_chain *bcptr,
+  BOOL utf8)
+{
+while (bcptr != NULL && bcptr->current >= code)
+  {
+  if (!could_be_empty_branch(bcptr->current, endcode, utf8)) return FALSE;
+  bcptr = bcptr->outer;
+  }
+return TRUE;
+}
+
+
+
+/*************************************************
+*           Check for POSIX class syntax         *
+*************************************************/
+
+/* This function is called when the sequence "[:" or "[." or "[=" is
+encountered in a character class. It checks whether this is followed by a
+sequence of characters terminated by a matching ":]" or ".]" or "=]". If we
+reach an unescaped ']' without the special preceding character, return FALSE.
+
+Originally, this function only recognized a sequence of letters between the
+terminators, but it seems that Perl recognizes any sequence of characters,
+though of course unknown POSIX names are subsequently rejected. Perl gives an
+"Unknown POSIX class" error for [:f\oo:] for example, where previously PCRE
+didn't consider this to be a POSIX class. Likewise for [:1234:].
+
+The problem in trying to be exactly like Perl is in the handling of escapes. We
+have to be sure that [abc[:x\]pqr] is *not* treated as containing a POSIX
+class, but [abc[:x\]pqr:]] is (so that an error can be generated). The code
+below handles the special case of \], but does not try to do any other escape
+processing. This makes it different from Perl for cases such as [:l\ower:]
+where Perl recognizes it as the POSIX class "lower" but PCRE does not recognize
+"l\ower". This is a lesser evil that not diagnosing bad classes when Perl does,
+I think.
+
+Arguments:
+  ptr      pointer to the initial [
+  endptr   where to return the end pointer
+
+Returns:   TRUE or FALSE
+*/
+
+static BOOL
+check_posix_syntax(const uschar *ptr, const uschar **endptr)
+{
+int terminator;          /* Don't combine these lines; the Solaris cc */
+terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */
+for (++ptr; *ptr != 0; ptr++)
+  {
+  if (*ptr == '\\' && ptr[1] == ']') ptr++; else
+    {
+    if (*ptr == ']') return FALSE;
+    if (*ptr == terminator && ptr[1] == ']')
+      {
+      *endptr = ptr;
+      return TRUE;
+      }
+    }
+  }
+return FALSE;
+}
+
+
+
+
+/*************************************************
+*          Check POSIX class name                *
+*************************************************/
+
+/* This function is called to check the name given in a POSIX-style class entry
+such as [:alnum:].
+
+Arguments:
+  ptr        points to the first letter
+  len        the length of the name
+
+Returns:     a value representing the name, or -1 if unknown
+*/
+
+static int
+check_posix_name(const uschar *ptr, int len)
+{
+const char *pn = posix_names;
+register int yield = 0;
+while (posix_name_lengths[yield] != 0)
+  {
+  if (len == posix_name_lengths[yield] &&
+    strncmp((const char *)ptr, pn, len) == 0) return yield;
+  pn += posix_name_lengths[yield] + 1;
+  yield++;
+  }
+return -1;
+}
+
+
+/*************************************************
+*    Adjust OP_RECURSE items in repeated group   *
+*************************************************/
+
+/* OP_RECURSE items contain an offset from the start of the regex to the group
+that is referenced. This means that groups can be replicated for fixed
+repetition simply by copying (because the recursion is allowed to refer to
+earlier groups that are outside the current group). However, when a group is
+optional (i.e. the minimum quantifier is zero), OP_BRAZERO or OP_SKIPZERO is
+inserted before it, after it has been compiled. This means that any OP_RECURSE
+items within it that refer to the group itself or any contained groups have to
+have their offsets adjusted. That one of the jobs of this function. Before it
+is called, the partially compiled regex must be temporarily terminated with
+OP_END.
+
+This function has been extended with the possibility of forward references for
+recursions and subroutine calls. It must also check the list of such references
+for the group we are dealing with. If it finds that one of the recursions in
+the current group is on this list, it adjusts the offset in the list, not the
+value in the reference (which is a group number).
+
+Arguments:
+  group      points to the start of the group
+  adjust     the amount by which the group is to be moved
+  utf8       TRUE in UTF-8 mode
+  cd         contains pointers to tables etc.
+  save_hwm   the hwm forward reference pointer at the start of the group
+
+Returns:     nothing
+*/
+
+static void
+adjust_recurse(uschar *group, int adjust, BOOL utf8, compile_data *cd,
+  uschar *save_hwm)
+{
+uschar *ptr = group;
+
+while ((ptr = (uschar *)find_recurse(ptr, utf8)) != NULL)
+  {
+  int offset;
+  uschar *hc;
+
+  /* See if this recursion is on the forward reference list. If so, adjust the
+  reference. */
+
+  for (hc = save_hwm; hc < cd->hwm; hc += LINK_SIZE)
+    {
+    offset = GET(hc, 0);
+    if (cd->start_code + offset == ptr + 1)
+      {
+      PUT(hc, 0, offset + adjust);
+      break;
+      }
+    }
+
+  /* Otherwise, adjust the recursion offset if it's after the start of this
+  group. */
+
+  if (hc >= cd->hwm)
+    {
+    offset = GET(ptr, 1);
+    if (cd->start_code + offset >= group) PUT(ptr, 1, offset + adjust);
+    }
+
+  ptr += 1 + LINK_SIZE;
+  }
+}
+
+
+
+/*************************************************
+*        Insert an automatic callout point       *
+*************************************************/
+
+/* This function is called when the PCRE_AUTO_CALLOUT option is set, to insert
+callout points before each pattern item.
+
+Arguments:
+  code           current code pointer
+  ptr            current pattern pointer
+  cd             pointers to tables etc
+
+Returns:         new code pointer
+*/
+
+static uschar *
+auto_callout(uschar *code, const uschar *ptr, compile_data *cd)
+{
+*code++ = OP_CALLOUT;
+*code++ = 255;
+PUT(code, 0, ptr - cd->start_pattern);  /* Pattern offset */
+PUT(code, LINK_SIZE, 0);                /* Default length */
+return code + 2*LINK_SIZE;
+}
+
+
+
+/*************************************************
+*         Complete a callout item                *
+*************************************************/
+
+/* A callout item contains the length of the next item in the pattern, which
+we can't fill in till after we have reached the relevant point. This is used
+for both automatic and manual callouts.
+
+Arguments:
+  previous_callout   points to previous callout item
+  ptr                current pattern pointer
+  cd                 pointers to tables etc
+
+Returns:             nothing
+*/
+
+static void
+complete_callout(uschar *previous_callout, const uschar *ptr, compile_data *cd)
+{
+int length = ptr - cd->start_pattern - GET(previous_callout, 2);
+PUT(previous_callout, 2 + LINK_SIZE, length);
+}
+
+
+
+#ifdef SUPPORT_UCP
+/*************************************************
+*           Get othercase range                  *
+*************************************************/
+
+/* This function is passed the start and end of a class range, in UTF-8 mode
+with UCP support. It searches up the characters, looking for internal ranges of
+characters in the "other" case. Each call returns the next one, updating the
+start address.
+
+Arguments:
+  cptr        points to starting character value; updated
+  d           end value
+  ocptr       where to put start of othercase range
+  odptr       where to put end of othercase range
+
+Yield:        TRUE when range returned; FALSE when no more
+*/
+
+static BOOL
+get_othercase_range(unsigned int *cptr, unsigned int d, unsigned int *ocptr,
+  unsigned int *odptr)
+{
+unsigned int c, othercase, next;
+
+for (c = *cptr; c <= d; c++)
+  { if ((othercase = UCD_OTHERCASE(c)) != c) break; }
+
+if (c > d) return FALSE;
+
+*ocptr = othercase;
+next = othercase + 1;
+
+for (++c; c <= d; c++)
+  {
+  if (UCD_OTHERCASE(c) != next) break;
+  next++;
+  }
+
+*odptr = next - 1;
+*cptr = c;
+
+return TRUE;
+}
+#endif  /* SUPPORT_UCP */
+
+
+
+/*************************************************
+*     Check if auto-possessifying is possible    *
+*************************************************/
+
+/* This function is called for unlimited repeats of certain items, to see
+whether the next thing could possibly match the repeated item. If not, it makes
+sense to automatically possessify the repeated item.
+
+Arguments:
+  op_code       the repeated op code
+  this          data for this item, depends on the opcode
+  utf8          TRUE in UTF-8 mode
+  utf8_char     used for utf8 character bytes, NULL if not relevant
+  ptr           next character in pattern
+  options       options bits
+  cd            contains pointers to tables etc.
+
+Returns:        TRUE if possessifying is wanted
+*/
+
+static BOOL
+check_auto_possessive(int op_code, int item, BOOL utf8, uschar *utf8_char,
+  const uschar *ptr, int options, compile_data *cd)
+{
+int next;
+
+/* Skip whitespace and comments in extended mode */
+
+if ((options & PCRE_EXTENDED) != 0)
+  {
+  for (;;)
+    {
+    while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;
+    if (*ptr == '#')
+      {
+      while (*(++ptr) != 0)
+        if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
+      }
+    else break;
+    }
+  }
+
+/* If the next item is one that we can handle, get its value. A non-negative
+value is a character, a negative value is an escape value. */
+
+if (*ptr == '\\')
+  {
+  int temperrorcode = 0;
+  next = check_escape(&ptr, &temperrorcode, cd->bracount, options, FALSE);
+  if (temperrorcode != 0) return FALSE;
+  ptr++;    /* Point after the escape sequence */
+  }
+
+else if ((cd->ctypes[*ptr] & ctype_meta) == 0)
+  {
+#ifdef SUPPORT_UTF8
+  if (utf8) { GETCHARINC(next, ptr); } else
+#endif
+  next = *ptr++;
+  }
+
+else return FALSE;
+
+/* Skip whitespace and comments in extended mode */
+
+if ((options & PCRE_EXTENDED) != 0)
+  {
+  for (;;)
+    {
+    while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;
+    if (*ptr == '#')
+      {
+      while (*(++ptr) != 0)
+        if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
+      }
+    else break;
+    }
+  }
+
+/* If the next thing is itself optional, we have to give up. */
+
+if (*ptr == '*' || *ptr == '?' || strncmp((char *)ptr, "{0,", 3) == 0)
+  return FALSE;
+
+/* Now compare the next item with the previous opcode. If the previous is a
+positive single character match, "item" either contains the character or, if
+"item" is greater than 127 in utf8 mode, the character's bytes are in
+utf8_char. */
+
+
+/* Handle cases when the next item is a character. */
+
+if (next >= 0) switch(op_code)
+  {
+  case OP_CHAR:
+#ifdef SUPPORT_UTF8
+  if (utf8 && item > 127) { GETCHAR(item, utf8_char); }
+#else
+  (void)(utf8_char);  /* Keep compiler happy by referencing function argument */
+#endif
+  return item != next;
+
+  /* For CHARNC (caseless character) we must check the other case. If we have
+  Unicode property support, we can use it to test the other case of
+  high-valued characters. */
+
+  case OP_CHARNC:
+#ifdef SUPPORT_UTF8
+  if (utf8 && item > 127) { GETCHAR(item, utf8_char); }
+#endif
+  if (item == next) return FALSE;
+#ifdef SUPPORT_UTF8
+  if (utf8)
+    {
+    unsigned int othercase;
+    if (next < 128) othercase = cd->fcc[next]; else
+#ifdef SUPPORT_UCP
+    othercase = UCD_OTHERCASE((unsigned int)next);
+#else
+    othercase = NOTACHAR;
+#endif
+    return (unsigned int)item != othercase;
+    }
+  else
+#endif  /* SUPPORT_UTF8 */
+  return (item != cd->fcc[next]);  /* Non-UTF-8 mode */
+
+  /* For OP_NOT, "item" must be a single-byte character. */
+
+  case OP_NOT:
+  if (item == next) return TRUE;
+  if ((options & PCRE_CASELESS) == 0) return FALSE;
+#ifdef SUPPORT_UTF8
+  if (utf8)
+    {
+    unsigned int othercase;
+    if (next < 128) othercase = cd->fcc[next]; else
+#ifdef SUPPORT_UCP
+    othercase = UCD_OTHERCASE(next);
+#else
+    othercase = NOTACHAR;
+#endif
+    return (unsigned int)item == othercase;
+    }
+  else
+#endif  /* SUPPORT_UTF8 */
+  return (item == cd->fcc[next]);  /* Non-UTF-8 mode */
+
+  case OP_DIGIT:
+  return next > 127 || (cd->ctypes[next] & ctype_digit) == 0;
+
+  case OP_NOT_DIGIT:
+  return next <= 127 && (cd->ctypes[next] & ctype_digit) != 0;
+
+  case OP_WHITESPACE:
+  return next > 127 || (cd->ctypes[next] & ctype_space) == 0;
+
+  case OP_NOT_WHITESPACE:
+  return next <= 127 && (cd->ctypes[next] & ctype_space) != 0;
+
+  case OP_WORDCHAR:
+  return next > 127 || (cd->ctypes[next] & ctype_word) == 0;
+
+  case OP_NOT_WORDCHAR:
+  return next <= 127 && (cd->ctypes[next] & ctype_word) != 0;
+
+  case OP_HSPACE:
+  case OP_NOT_HSPACE:
+  switch(next)
+    {
+    case 0x09:
+    case 0x20:
+    case 0xa0:
+    case 0x1680:
+    case 0x180e:
+    case 0x2000:
+    case 0x2001:
+    case 0x2002:
+    case 0x2003:
+    case 0x2004:
+    case 0x2005:
+    case 0x2006:
+    case 0x2007:
+    case 0x2008:
+    case 0x2009:
+    case 0x200A:
+    case 0x202f:
+    case 0x205f:
+    case 0x3000:
+    return op_code != OP_HSPACE;
+    default:
+    return op_code == OP_HSPACE;
+    }
+
+  case OP_VSPACE:
+  case OP_NOT_VSPACE:
+  switch(next)
+    {
+    case 0x0a:
+    case 0x0b:
+    case 0x0c:
+    case 0x0d:
+    case 0x85:
+    case 0x2028:
+    case 0x2029:
+    return op_code != OP_VSPACE;
+    default:
+    return op_code == OP_VSPACE;
+    }
+
+  default:
+  return FALSE;
+  }
+
+
+/* Handle the case when the next item is \d, \s, etc. */
+
+switch(op_code)
+  {
+  case OP_CHAR:
+  case OP_CHARNC:
+#ifdef SUPPORT_UTF8
+  if (utf8 && item > 127) { GETCHAR(item, utf8_char); }
+#endif
+  switch(-next)
+    {
+    case ESC_d:
+    return item > 127 || (cd->ctypes[item] & ctype_digit) == 0;
+
+    case ESC_D:
+    return item <= 127 && (cd->ctypes[item] & ctype_digit) != 0;
+
+    case ESC_s:
+    return item > 127 || (cd->ctypes[item] & ctype_space) == 0;
+
+    case ESC_S:
+    return item <= 127 && (cd->ctypes[item] & ctype_space) != 0;
+
+    case ESC_w:
+    return item > 127 || (cd->ctypes[item] & ctype_word) == 0;
+
+    case ESC_W:
+    return item <= 127 && (cd->ctypes[item] & ctype_word) != 0;
+
+    case ESC_h:
+    case ESC_H:
+    switch(item)
+      {
+      case 0x09:
+      case 0x20:
+      case 0xa0:
+      case 0x1680:
+      case 0x180e:
+      case 0x2000:
+      case 0x2001:
+      case 0x2002:
+      case 0x2003:
+      case 0x2004:
+      case 0x2005:
+      case 0x2006:
+      case 0x2007:
+      case 0x2008:
+      case 0x2009:
+      case 0x200A:
+      case 0x202f:
+      case 0x205f:
+      case 0x3000:
+      return -next != ESC_h;
+      default:
+      return -next == ESC_h;
+      }
+
+    case ESC_v:
+    case ESC_V:
+    switch(item)
+      {
+      case 0x0a:
+      case 0x0b:
+      case 0x0c:
+      case 0x0d:
+      case 0x85:
+      case 0x2028:
+      case 0x2029:
+      return -next != ESC_v;
+      default:
+      return -next == ESC_v;
+      }
+
+    default:
+    return FALSE;
+    }
+
+  case OP_DIGIT:
+  return next == -ESC_D || next == -ESC_s || next == -ESC_W ||
+         next == -ESC_h || next == -ESC_v;
+
+  case OP_NOT_DIGIT:
+  return next == -ESC_d;
+
+  case OP_WHITESPACE:
+  return next == -ESC_S || next == -ESC_d || next == -ESC_w;
+
+  case OP_NOT_WHITESPACE:
+  return next == -ESC_s || next == -ESC_h || next == -ESC_v;
+
+  case OP_HSPACE:
+  return next == -ESC_S || next == -ESC_H || next == -ESC_d || next == -ESC_w;
+
+  case OP_NOT_HSPACE:
+  return next == -ESC_h;
+
+  /* Can't have \S in here because VT matches \S (Perl anomaly) */
+  case OP_VSPACE:
+  return next == -ESC_V || next == -ESC_d || next == -ESC_w;
+
+  case OP_NOT_VSPACE:
+  return next == -ESC_v;
+
+  case OP_WORDCHAR:
+  return next == -ESC_W || next == -ESC_s || next == -ESC_h || next == -ESC_v;
+
+  case OP_NOT_WORDCHAR:
+  return next == -ESC_w || next == -ESC_d;
+
+  default:
+  return FALSE;
+  }
+
+/* Control does not reach here */
+}
+
+
+
+/*************************************************
+*           Compile one branch                   *
+*************************************************/
+
+/* Scan the pattern, compiling it into the a vector. If the options are
+changed during the branch, the pointer is used to change the external options
+bits. This function is used during the pre-compile phase when we are trying
+to find out the amount of memory needed, as well as during the real compile
+phase. The value of lengthptr distinguishes the two phases.
+
+Arguments:
+  optionsptr     pointer to the option bits
+  codeptr        points to the pointer to the current code point
+  ptrptr         points to the current pattern pointer
+  errorcodeptr   points to error code variable
+  firstbyteptr   set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE)
+  reqbyteptr     set to the last literal character required, else < 0
+  bcptr          points to current branch chain
+  cd             contains pointers to tables etc.
+  lengthptr      NULL during the real compile phase
+                 points to length accumulator during pre-compile phase
+
+Returns:         TRUE on success
+                 FALSE, with *errorcodeptr set non-zero on error
+*/
+
+static BOOL
+compile_branch(int *optionsptr, uschar **codeptr, const uschar **ptrptr,
+  int *errorcodeptr, int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr,
+  compile_data *cd, int *lengthptr)
+{
+int repeat_type, op_type;
+int repeat_min = 0, repeat_max = 0;      /* To please picky compilers */
+int bravalue = 0;
+int greedy_default, greedy_non_default;
+int firstbyte, reqbyte;
+int zeroreqbyte, zerofirstbyte;
+int req_caseopt, reqvary, tempreqvary;
+int options = *optionsptr;
+int after_manual_callout = 0;
+int length_prevgroup = 0;
+register int c;
+register uschar *code = *codeptr;
+uschar *last_code = code;
+uschar *orig_code = code;
+uschar *tempcode;
+BOOL inescq = FALSE;
+BOOL groupsetfirstbyte = FALSE;
+const uschar *ptr = *ptrptr;
+const uschar *tempptr;
+uschar *previous = NULL;
+uschar *previous_callout = NULL;
+uschar *save_hwm = NULL;
+uschar classbits[32];
+
+#ifdef SUPPORT_UTF8
+BOOL class_utf8;
+BOOL utf8 = (options & PCRE_UTF8) != 0;
+uschar *class_utf8data;
+uschar *class_utf8data_base;
+uschar utf8_char[6];
+#else
+BOOL utf8 = FALSE;
+uschar *utf8_char = NULL;
+#endif
+
+#ifdef DEBUG
+if (lengthptr != NULL) DPRINTF((">> start branch\n"));
+#endif
+
+/* Set up the default and non-default settings for greediness */
+
+greedy_default = ((options & PCRE_UNGREEDY) != 0);
+greedy_non_default = greedy_default ^ 1;
+
+/* Initialize no first byte, no required byte. REQ_UNSET means "no char
+matching encountered yet". It gets changed to REQ_NONE if we hit something that
+matches a non-fixed char first char; reqbyte just remains unset if we never
+find one.
+
+When we hit a repeat whose minimum is zero, we may have to adjust these values
+to take the zero repeat into account. This is implemented by setting them to
+zerofirstbyte and zeroreqbyte when such a repeat is encountered. The individual
+item types that can be repeated set these backoff variables appropriately. */
+
+firstbyte = reqbyte = zerofirstbyte = zeroreqbyte = REQ_UNSET;
+
+/* The variable req_caseopt contains either the REQ_CASELESS value or zero,
+according to the current setting of the caseless flag. REQ_CASELESS is a bit
+value > 255. It is added into the firstbyte or reqbyte variables to record the
+case status of the value. This is used only for ASCII characters. */
+
+req_caseopt = ((options & PCRE_CASELESS) != 0)? REQ_CASELESS : 0;
+
+/* Switch on next character until the end of the branch */
+
+for (;; ptr++)
+  {
+  BOOL negate_class;
+  BOOL should_flip_negation;
+  BOOL possessive_quantifier;
+  BOOL is_quantifier;
+  BOOL is_recurse;
+  BOOL reset_bracount;
+  int class_charcount;
+  int class_lastchar;
+  int newoptions;
+  int recno;
+  int refsign;
+  int skipbytes;
+  int subreqbyte;
+  int subfirstbyte;
+  int terminator;
+  int mclength;
+  uschar mcbuffer[8];
+
+  /* Get next byte in the pattern */
+
+  c = *ptr;
+
+  /* If we are in the pre-compile phase, accumulate the length used for the
+  previous cycle of this loop. */
+
+  if (lengthptr != NULL)
+    {
+#ifdef DEBUG
+    if (code > cd->hwm) cd->hwm = code;                 /* High water info */
+#endif
+    if (code > cd->start_workspace + COMPILE_WORK_SIZE) /* Check for overrun */
+      {
+      *errorcodeptr = ERR52;
+      goto FAILED;
+      }
+
+    /* There is at least one situation where code goes backwards: this is the
+    case of a zero quantifier after a class (e.g. [ab]{0}). At compile time,
+    the class is simply eliminated. However, it is created first, so we have to
+    allow memory for it. Therefore, don't ever reduce the length at this point.
+    */
+
+    if (code < last_code) code = last_code;
+
+    /* Paranoid check for integer overflow */
+
+    if (OFLOW_MAX - *lengthptr < code - last_code)
+      {
+      *errorcodeptr = ERR20;
+      goto FAILED;
+      }
+
+    *lengthptr += code - last_code;
+    DPRINTF(("length=%d added %d c=%c\n", *lengthptr, code - last_code, c));
+
+    /* If "previous" is set and it is not at the start of the work space, move
+    it back to there, in order to avoid filling up the work space. Otherwise,
+    if "previous" is NULL, reset the current code pointer to the start. */
+
+    if (previous != NULL)
+      {
+      if (previous > orig_code)
+        {
+        memmove(orig_code, previous, code - previous);
+        code -= previous - orig_code;
+        previous = orig_code;
+        }
+      }
+    else code = orig_code;
+
+    /* Remember where this code item starts so we can pick up the length
+    next time round. */
+
+    last_code = code;
+    }
+
+  /* In the real compile phase, just check the workspace used by the forward
+  reference list. */
+
+  else if (cd->hwm > cd->start_workspace + COMPILE_WORK_SIZE)
+    {
+    *errorcodeptr = ERR52;
+    goto FAILED;
+    }
+
+  /* If in \Q...\E, check for the end; if not, we have a literal */
+
+  if (inescq && c != 0)
+    {
+    if (c == '\\' && ptr[1] == 'E')
+      {
+      inescq = FALSE;
+      ptr++;
+      continue;
+      }
+    else
+      {
+      if (previous_callout != NULL)
+        {
+        if (lengthptr == NULL)  /* Don't attempt in pre-compile phase */
+          complete_callout(previous_callout, ptr, cd);
+        previous_callout = NULL;
+        }
+      if ((options & PCRE_AUTO_CALLOUT) != 0)
+        {
+        previous_callout = code;
+        code = auto_callout(code, ptr, cd);
+        }
+      goto NORMAL_CHAR;
+      }
+    }
+
+  /* Fill in length of a previous callout, except when the next thing is
+  a quantifier. */
+
+  is_quantifier = c == '*' || c == '+' || c == '?' ||
+    (c == '{' && is_counted_repeat(ptr+1));
+
+  if (!is_quantifier && previous_callout != NULL &&
+       after_manual_callout-- <= 0)
+    {
+    if (lengthptr == NULL)      /* Don't attempt in pre-compile phase */
+      complete_callout(previous_callout, ptr, cd);
+    previous_callout = NULL;
+    }
+
+  /* In extended mode, skip white space and comments */
+
+  if ((options & PCRE_EXTENDED) != 0)
+    {
+    if ((cd->ctypes[c] & ctype_space) != 0) continue;
+    if (c == '#')
+      {
+      while (*(++ptr) != 0)
+        {
+        if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }
+        }
+      if (*ptr != 0) continue;
+
+      /* Else fall through to handle end of string */
+      c = 0;
+      }
+    }
+
+  /* No auto callout for quantifiers. */
+
+  if ((options & PCRE_AUTO_CALLOUT) != 0 && !is_quantifier)
+    {
+    previous_callout = code;
+    code = auto_callout(code, ptr, cd);
+    }
+
+  switch(c)
+    {
+    /* ===================================================================*/
+    case 0:                        /* The branch terminates at string end */
+    case '|':                      /* or | or ) */
+    case ')':
+    *firstbyteptr = firstbyte;
+    *reqbyteptr = reqbyte;
+    *codeptr = code;
+    *ptrptr = ptr;
+    if (lengthptr != NULL)
+      {
+      if (OFLOW_MAX - *lengthptr < code - last_code)
+        {
+        *errorcodeptr = ERR20;
+        goto FAILED;
+        }
+      *lengthptr += code - last_code;   /* To include callout length */
+      DPRINTF((">> end branch\n"));
+      }
+    return TRUE;
+
+
+    /* ===================================================================*/
+    /* Handle single-character metacharacters. In multiline mode, ^ disables
+    the setting of any following char as a first character. */
+
+    case '^':
+    if ((options & PCRE_MULTILINE) != 0)
+      {
+      if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+      }
+    previous = NULL;
+    *code++ = OP_CIRC;
+    break;
+
+    case '$':
+    previous = NULL;
+    *code++ = OP_DOLL;
+    break;
+
+    /* There can never be a first char if '.' is first, whatever happens about
+    repeats. The value of reqbyte doesn't change either. */
+
+    case '.':
+    if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+    zerofirstbyte = firstbyte;
+    zeroreqbyte = reqbyte;
+    previous = code;
+    *code++ = ((options & PCRE_DOTALL) != 0)? OP_ALLANY: OP_ANY;
+    break;
+
+
+    /* ===================================================================*/
+    /* Character classes. If the included characters are all < 256, we build a
+    32-byte bitmap of the permitted characters, except in the special case
+    where there is only one such character. For negated classes, we build the
+    map as usual, then invert it at the end. However, we use a different opcode
+    so that data characters > 255 can be handled correctly.
+
+    If the class contains characters outside the 0-255 range, a different
+    opcode is compiled. It may optionally have a bit map for characters < 256,
+    but those above are are explicitly listed afterwards. A flag byte tells
+    whether the bitmap is present, and whether this is a negated class or not.
+
+    In JavaScript compatibility mode, an isolated ']' causes an error. In
+    default (Perl) mode, it is treated as a data character. */
+
+    case ']':
+    if ((cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
+      {
+      *errorcodeptr = ERR64;
+      goto FAILED;
+      }
+    goto NORMAL_CHAR;
+
+    case '[':
+    previous = code;
+
+    /* PCRE supports POSIX class stuff inside a class. Perl gives an error if
+    they are encountered at the top level, so we'll do that too. */
+
+    if ((ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
+        check_posix_syntax(ptr, &tempptr))
+      {
+      *errorcodeptr = (ptr[1] == ':')? ERR13 : ERR31;
+      goto FAILED;
+      }
+
+    /* If the first character is '^', set the negation flag and skip it. Also,
+    if the first few characters (either before or after ^) are \Q\E or \E we
+    skip them too. This makes for compatibility with Perl. */
+
+    negate_class = FALSE;
+    for (;;)
+      {
+      c = *(++ptr);
+      if (c == '\\')
+        {
+        if (ptr[1] == 'E') ptr++;
+          else if (strncmp((const char *)ptr+1, "Q\\E", 3) == 0) ptr += 3;
+            else break;
+        }
+      else if (!negate_class && c == '^')
+        negate_class = TRUE;
+      else break;
+      }
+
+    /* Empty classes are allowed in JavaScript compatibility mode. Otherwise,
+    an initial ']' is taken as a data character -- the code below handles
+    that. In JS mode, [] must always fail, so generate OP_FAIL, whereas
+    [^] must match any character, so generate OP_ALLANY. */
+
+    if (c ==']' && (cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
+      {
+      *code++ = negate_class? OP_ALLANY : OP_FAIL;
+      if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+      zerofirstbyte = firstbyte;
+      break;
+      }
+
+    /* If a class contains a negative special such as \S, we need to flip the
+    negation flag at the end, so that support for characters > 255 works
+    correctly (they are all included in the class). */
+
+    should_flip_negation = FALSE;
+
+    /* Keep a count of chars with values < 256 so that we can optimize the case
+    of just a single character (as long as it's < 256). However, For higher
+    valued UTF-8 characters, we don't yet do any optimization. */
+
+    class_charcount = 0;
+    class_lastchar = -1;
+
+    /* Initialize the 32-char bit map to all zeros. We build the map in a
+    temporary bit of memory, in case the class contains only 1 character (less
+    than 256), because in that case the compiled code doesn't use the bit map.
+    */
+
+    memset(classbits, 0, 32 * sizeof(uschar));
+
+#ifdef SUPPORT_UTF8
+    class_utf8 = FALSE;                       /* No chars >= 256 */
+    class_utf8data = code + LINK_SIZE + 2;    /* For UTF-8 items */
+    class_utf8data_base = class_utf8data;     /* For resetting in pass 1 */
+#endif
+
+    /* Process characters until ] is reached. By writing this as a "do" it
+    means that an initial ] is taken as a data character. At the start of the
+    loop, c contains the first byte of the character. */
+
+    if (c != 0) do
+      {
+      const uschar *oldptr;
+
+#ifdef SUPPORT_UTF8
+      if (utf8 && c > 127)
+        {                           /* Braces are required because the */
+        GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */
+        }
+
+      /* In the pre-compile phase, accumulate the length of any UTF-8 extra
+      data and reset the pointer. This is so that very large classes that
+      contain a zillion UTF-8 characters no longer overwrite the work space
+      (which is on the stack). */
+
+      if (lengthptr != NULL)
+        {
+        *lengthptr += class_utf8data - class_utf8data_base;
+        class_utf8data = class_utf8data_base;
+        }
+
+#endif
+
+      /* Inside \Q...\E everything is literal except \E */
+
+      if (inescq)
+        {
+        if (c == '\\' && ptr[1] == 'E')     /* If we are at \E */
+          {
+          inescq = FALSE;                   /* Reset literal state */
+          ptr++;                            /* Skip the 'E' */
+          continue;                         /* Carry on with next */
+          }
+        goto CHECK_RANGE;                   /* Could be range if \E follows */
+        }
+
+      /* Handle POSIX class names. Perl allows a negation extension of the
+      form [:^name:]. A square bracket that doesn't match the syntax is
+      treated as a literal. We also recognize the POSIX constructions
+      [.ch.] and [=ch=] ("collating elements") and fault them, as Perl
+      5.6 and 5.8 do. */
+
+      if (c == '[' &&
+          (ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&
+          check_posix_syntax(ptr, &tempptr))
+        {
+        BOOL local_negate = FALSE;
+        int posix_class, taboffset, tabopt;
+        register const uschar *cbits = cd->cbits;
+        uschar pbits[32];
+
+        if (ptr[1] != ':')
+          {
+          *errorcodeptr = ERR31;
+          goto FAILED;
+          }
+
+        ptr += 2;
+        if (*ptr == '^')
+          {
+          local_negate = TRUE;
+          should_flip_negation = TRUE;  /* Note negative special */
+          ptr++;
+          }
+
+        posix_class = check_posix_name(ptr, tempptr - ptr);
+        if (posix_class < 0)
+          {
+          *errorcodeptr = ERR30;
+          goto FAILED;
+          }
+
+        /* If matching is caseless, upper and lower are converted to
+        alpha. This relies on the fact that the class table starts with
+        alpha, lower, upper as the first 3 entries. */
+
+        if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
+          posix_class = 0;
+
+        /* We build the bit map for the POSIX class in a chunk of local store
+        because we may be adding and subtracting from it, and we don't want to
+        subtract bits that may be in the main map already. At the end we or the
+        result into the bit map that is being built. */
+
+        posix_class *= 3;
+
+        /* Copy in the first table (always present) */
+
+        memcpy(pbits, cbits + posix_class_maps[posix_class],
+          32 * sizeof(uschar));
+
+        /* If there is a second table, add or remove it as required. */
+
+        taboffset = posix_class_maps[posix_class + 1];
+        tabopt = posix_class_maps[posix_class + 2];
+
+        if (taboffset >= 0)
+          {
+          if (tabopt >= 0)
+            for (c = 0; c < 32; c++) pbits[c] |= cbits[c + taboffset];
+          else
+            for (c = 0; c < 32; c++) pbits[c] &= ~cbits[c + taboffset];
+          }
+
+        /* Not see if we need to remove any special characters. An option
+        value of 1 removes vertical space and 2 removes underscore. */
+
+        if (tabopt < 0) tabopt = -tabopt;
+        if (tabopt == 1) pbits[1] &= ~0x3c;
+          else if (tabopt == 2) pbits[11] &= 0x7f;
+
+        /* Add the POSIX table or its complement into the main table that is
+        being built and we are done. */
+
+        if (local_negate)
+          for (c = 0; c < 32; c++) classbits[c] |= ~pbits[c];
+        else
+          for (c = 0; c < 32; c++) classbits[c] |= pbits[c];
+
+        ptr = tempptr + 1;
+        class_charcount = 10;  /* Set > 1; assumes more than 1 per class */
+        continue;    /* End of POSIX syntax handling */
+        }
+
+      /* Backslash may introduce a single character, or it may introduce one
+      of the specials, which just set a flag. The sequence \b is a special
+      case. Inside a class (and only there) it is treated as backspace.
+      Elsewhere it marks a word boundary. Other escapes have preset maps ready
+      to 'or' into the one we are building. We assume they have more than one
+      character in them, so set class_charcount bigger than one. */
+
+      if (c == '\\')
+        {
+        c = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);
+        if (*errorcodeptr != 0) goto FAILED;
+
+        if (-c == ESC_b) c = '\b';       /* \b is backspace in a class */
+        else if (-c == ESC_X) c = 'X';   /* \X is literal X in a class */
+        else if (-c == ESC_R) c = 'R';   /* \R is literal R in a class */
+        else if (-c == ESC_Q)            /* Handle start of quoted string */
+          {
+          if (ptr[1] == '\\' && ptr[2] == 'E')
+            {
+            ptr += 2; /* avoid empty string */
+            }
+          else inescq = TRUE;
+          continue;
+          }
+        else if (-c == ESC_E) continue;  /* Ignore orphan \E */
+
+        if (c < 0)
+          {
+          register const uschar *cbits = cd->cbits;
+          class_charcount += 2;     /* Greater than 1 is what matters */
+
+          /* Save time by not doing this in the pre-compile phase. */
+
+          if (lengthptr == NULL) switch (-c)
+            {
+            case ESC_d:
+            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_digit];
+            continue;
+
+            case ESC_D:
+            should_flip_negation = TRUE;
+            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_digit];
+            continue;
+
+            case ESC_w:
+            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_word];
+            continue;
+
+            case ESC_W:
+            should_flip_negation = TRUE;
+            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_word];
+            continue;
+
+            case ESC_s:
+            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_space];
+            classbits[1] &= ~0x08;   /* Perl 5.004 onwards omits VT from \s */
+            continue;
+
+            case ESC_S:
+            should_flip_negation = TRUE;
+            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_space];
+            classbits[1] |= 0x08;    /* Perl 5.004 onwards omits VT from \s */
+            continue;
+
+            default:    /* Not recognized; fall through */
+            break;      /* Need "default" setting to stop compiler warning. */
+            }
+
+          /* In the pre-compile phase, just do the recognition. */
+
+          else if (c == -ESC_d || c == -ESC_D || c == -ESC_w ||
+                   c == -ESC_W || c == -ESC_s || c == -ESC_S) continue;
+
+          /* We need to deal with \H, \h, \V, and \v in both phases because
+          they use extra memory. */
+
+          if (-c == ESC_h)
+            {
+            SETBIT(classbits, 0x09); /* VT */
+            SETBIT(classbits, 0x20); /* SPACE */
+            SETBIT(classbits, 0xa0); /* NSBP */
+#ifdef SUPPORT_UTF8
+            if (utf8)
+              {
+              class_utf8 = TRUE;
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x1680, class_utf8data);
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x180e, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2000, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x200A, class_utf8data);
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x202f, class_utf8data);
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x205f, class_utf8data);
+              *class_utf8data++ = XCL_SINGLE;
+              class_utf8data += _pcre_ord2utf8(0x3000, class_utf8data);
+              }
+#endif
+            continue;
+            }
+
+          if (-c == ESC_H)
+            {
+            for (c = 0; c < 32; c++)
+              {
+              int x = 0xff;
+              switch (c)
+                {
+                case 0x09/8: x ^= 1 << (0x09%8); break;
+                case 0x20/8: x ^= 1 << (0x20%8); break;
+                case 0xa0/8: x ^= 1 << (0xa0%8); break;
+                default: break;
+                }
+              classbits[c] |= x;
+              }
+
+#ifdef SUPPORT_UTF8
+            if (utf8)
+              {
+              class_utf8 = TRUE;
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x0100, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x167f, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x1681, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x180d, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x180f, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x1fff, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x200B, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x202e, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2030, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x205e, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2060, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x2fff, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x3001, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x7fffffff, class_utf8data);
+              }
+#endif
+            continue;
+            }
+
+          if (-c == ESC_v)
+            {
+            SETBIT(classbits, 0x0a); /* LF */
+            SETBIT(classbits, 0x0b); /* VT */
+            SETBIT(classbits, 0x0c); /* FF */
+            SETBIT(classbits, 0x0d); /* CR */
+            SETBIT(classbits, 0x85); /* NEL */
+#ifdef SUPPORT_UTF8
+            if (utf8)
+              {
+              class_utf8 = TRUE;
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2028, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x2029, class_utf8data);
+              }
+#endif
+            continue;
+            }
+
+          if (-c == ESC_V)
+            {
+            for (c = 0; c < 32; c++)
+              {
+              int x = 0xff;
+              switch (c)
+                {
+                case 0x0a/8: x ^= 1 << (0x0a%8);
+                             x ^= 1 << (0x0b%8);
+                             x ^= 1 << (0x0c%8);
+                             x ^= 1 << (0x0d%8);
+                             break;
+                case 0x85/8: x ^= 1 << (0x85%8); break;
+                default: break;
+                }
+              classbits[c] |= x;
+              }
+
+#ifdef SUPPORT_UTF8
+            if (utf8)
+              {
+              class_utf8 = TRUE;
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x0100, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x2027, class_utf8data);
+              *class_utf8data++ = XCL_RANGE;
+              class_utf8data += _pcre_ord2utf8(0x2029, class_utf8data);
+              class_utf8data += _pcre_ord2utf8(0x7fffffff, class_utf8data);
+              }
+#endif
+            continue;
+            }
+
+          /* We need to deal with \P and \p in both phases. */
+
+#ifdef SUPPORT_UCP
+          if (-c == ESC_p || -c == ESC_P)
+            {
+            BOOL negated;
+            int pdata;
+            int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);
+            if (ptype < 0) goto FAILED;
+            class_utf8 = TRUE;
+            *class_utf8data++ = ((-c == ESC_p) != negated)?
+              XCL_PROP : XCL_NOTPROP;
+            *class_utf8data++ = ptype;
+            *class_utf8data++ = pdata;
+            class_charcount -= 2;   /* Not a < 256 character */
+            continue;
+            }
+#endif
+          /* Unrecognized escapes are faulted if PCRE is running in its
+          strict mode. By default, for compatibility with Perl, they are
+          treated as literals. */
+
+          if ((options & PCRE_EXTRA) != 0)
+            {
+            *errorcodeptr = ERR7;
+            goto FAILED;
+            }
+
+          class_charcount -= 2;  /* Undo the default count from above */
+          c = *ptr;              /* Get the final character and fall through */
+          }
+
+        /* Fall through if we have a single character (c >= 0). This may be
+        greater than 256 in UTF-8 mode. */
+
+        }   /* End of backslash handling */
+
+      /* A single character may be followed by '-' to form a range. However,
+      Perl does not permit ']' to be the end of the range. A '-' character
+      at the end is treated as a literal. Perl ignores orphaned \E sequences
+      entirely. The code for handling \Q and \E is messy. */
+
+      CHECK_RANGE:
+      while (ptr[1] == '\\' && ptr[2] == 'E')
+        {
+        inescq = FALSE;
+        ptr += 2;
+        }
+
+      oldptr = ptr;
+
+      /* Remember \r or \n */
+
+      if (c == '\r' || c == '\n') cd->external_flags |= PCRE_HASCRORLF;
+
+      /* Check for range */
+
+      if (!inescq && ptr[1] == '-')
+        {
+        int d;
+        ptr += 2;
+        while (*ptr == '\\' && ptr[1] == 'E') ptr += 2;
+
+        /* If we hit \Q (not followed by \E) at this point, go into escaped
+        mode. */
+
+        while (*ptr == '\\' && ptr[1] == 'Q')
+          {
+          ptr += 2;
+          if (*ptr == '\\' && ptr[1] == 'E') { ptr += 2; continue; }
+          inescq = TRUE;
+          break;
+          }
+
+        if (*ptr == 0 || (!inescq && *ptr == ']'))
+          {
+          ptr = oldptr;
+          goto LONE_SINGLE_CHARACTER;
+          }
+
+#ifdef SUPPORT_UTF8
+        if (utf8)
+          {                           /* Braces are required because the */
+          GETCHARLEN(d, ptr, ptr);    /* macro generates multiple statements */
+          }
+        else
+#endif
+        d = *ptr;  /* Not UTF-8 mode */
+
+        /* The second part of a range can be a single-character escape, but
+        not any of the other escapes. Perl 5.6 treats a hyphen as a literal
+        in such circumstances. */
+
+        if (!inescq && d == '\\')
+          {
+          d = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);
+          if (*errorcodeptr != 0) goto FAILED;
+
+          /* \b is backspace; \X is literal X; \R is literal R; any other
+          special means the '-' was literal */
+
+          if (d < 0)
+            {
+            if (d == -ESC_b) d = '\b';
+            else if (d == -ESC_X) d = 'X';
+            else if (d == -ESC_R) d = 'R'; else
+              {
+              ptr = oldptr;
+              goto LONE_SINGLE_CHARACTER;  /* A few lines below */
+              }
+            }
+          }
+
+        /* Check that the two values are in the correct order. Optimize
+        one-character ranges */
+
+        if (d < c)
+          {
+          *errorcodeptr = ERR8;
+          goto FAILED;
+          }
+
+        if (d == c) goto LONE_SINGLE_CHARACTER;  /* A few lines below */
+
+        /* Remember \r or \n */
+
+        if (d == '\r' || d == '\n') cd->external_flags |= PCRE_HASCRORLF;
+
+        /* In UTF-8 mode, if the upper limit is > 255, or > 127 for caseless
+        matching, we have to use an XCLASS with extra data items. Caseless
+        matching for characters > 127 is available only if UCP support is
+        available. */
+
+#ifdef SUPPORT_UTF8
+        if (utf8 && (d > 255 || ((options & PCRE_CASELESS) != 0 && d > 127)))
+          {
+          class_utf8 = TRUE;
+
+          /* With UCP support, we can find the other case equivalents of
+          the relevant characters. There may be several ranges. Optimize how
+          they fit with the basic range. */
+
+#ifdef SUPPORT_UCP
+          if ((options & PCRE_CASELESS) != 0)
+            {
+            unsigned int occ, ocd;
+            unsigned int cc = c;
+            unsigned int origd = d;
+            while (get_othercase_range(&cc, origd, &occ, &ocd))
+              {
+              if (occ >= (unsigned int)c &&
+                  ocd <= (unsigned int)d)
+                continue;                          /* Skip embedded ranges */
+
+              if (occ < (unsigned int)c  &&
+                  ocd >= (unsigned int)c - 1)      /* Extend the basic range */
+                {                                  /* if there is overlap,   */
+                c = occ;                           /* noting that if occ < c */
+                continue;                          /* we can't have ocd > d  */
+                }                                  /* because a subrange is  */
+              if (ocd > (unsigned int)d &&
+                  occ <= (unsigned int)d + 1)      /* always shorter than    */
+                {                                  /* the basic range.       */
+                d = ocd;
+                continue;
+                }
+
+              if (occ == ocd)
+                {
+                *class_utf8data++ = XCL_SINGLE;
+                }
+              else
+                {
+                *class_utf8data++ = XCL_RANGE;
+                class_utf8data += _pcre_ord2utf8(occ, class_utf8data);
+                }
+              class_utf8data += _pcre_ord2utf8(ocd, class_utf8data);
+              }
+            }
+#endif  /* SUPPORT_UCP */
+
+          /* Now record the original range, possibly modified for UCP caseless
+          overlapping ranges. */
+
+          *class_utf8data++ = XCL_RANGE;
+          class_utf8data += _pcre_ord2utf8(c, class_utf8data);
+          class_utf8data += _pcre_ord2utf8(d, class_utf8data);
+
+          /* With UCP support, we are done. Without UCP support, there is no
+          caseless matching for UTF-8 characters > 127; we can use the bit map
+          for the smaller ones. */
+
+#ifdef SUPPORT_UCP
+          continue;    /* With next character in the class */
+#else
+          if ((options & PCRE_CASELESS) == 0 || c > 127) continue;
+
+          /* Adjust upper limit and fall through to set up the map */
+
+          d = 127;
+
+#endif  /* SUPPORT_UCP */
+          }
+#endif  /* SUPPORT_UTF8 */
+
+        /* We use the bit map for all cases when not in UTF-8 mode; else
+        ranges that lie entirely within 0-127 when there is UCP support; else
+        for partial ranges without UCP support. */
+
+        class_charcount += d - c + 1;
+        class_lastchar = d;
+
+        /* We can save a bit of time by skipping this in the pre-compile. */
+
+        if (lengthptr == NULL) for (; c <= d; c++)
+          {
+          classbits[c/8] |= (1 << (c&7));
+          if ((options & PCRE_CASELESS) != 0)
+            {
+            int uc = cd->fcc[c];           /* flip case */
+            classbits[uc/8] |= (1 << (uc&7));
+            }
+          }
+
+        continue;   /* Go get the next char in the class */
+        }
+
+      /* Handle a lone single character - we can get here for a normal
+      non-escape char, or after \ that introduces a single character or for an
+      apparent range that isn't. */
+
+      LONE_SINGLE_CHARACTER:
+
+      /* Handle a character that cannot go in the bit map */
+
+#ifdef SUPPORT_UTF8
+      if (utf8 && (c > 255 || ((options & PCRE_CASELESS) != 0 && c > 127)))
+        {
+        class_utf8 = TRUE;
+        *class_utf8data++ = XCL_SINGLE;
+        class_utf8data += _pcre_ord2utf8(c, class_utf8data);
+
+#ifdef SUPPORT_UCP
+        if ((options & PCRE_CASELESS) != 0)
+          {
+          unsigned int othercase;
+          if ((othercase = UCD_OTHERCASE(c)) != c)
+            {
+            *class_utf8data++ = XCL_SINGLE;
+            class_utf8data += _pcre_ord2utf8(othercase, class_utf8data);
+            }
+          }
+#endif  /* SUPPORT_UCP */
+
+        }
+      else
+#endif  /* SUPPORT_UTF8 */
+
+      /* Handle a single-byte character */
+        {
+        classbits[c/8] |= (1 << (c&7));
+        if ((options & PCRE_CASELESS) != 0)
+          {
+          c = cd->fcc[c];   /* flip case */
+          classbits[c/8] |= (1 << (c&7));
+          }
+        class_charcount++;
+        class_lastchar = c;
+        }
+      }
+
+    /* Loop until ']' reached. This "while" is the end of the "do" above. */
+
+    while ((c = *(++ptr)) != 0 && (c != ']' || inescq));
+
+    if (c == 0)                          /* Missing terminating ']' */
+      {
+      *errorcodeptr = ERR6;
+      goto FAILED;
+      }
+
+
+/* This code has been disabled because it would mean that \s counts as
+an explicit \r or \n reference, and that's not really what is wanted. Now
+we set the flag only if there is a literal "\r" or "\n" in the class. */
+
+#if 0
+    /* Remember whether \r or \n are in this class */
+
+    if (negate_class)
+      {
+      if ((classbits[1] & 0x24) != 0x24) cd->external_flags |= PCRE_HASCRORLF;
+      }
+    else
+      {
+      if ((classbits[1] & 0x24) != 0) cd->external_flags |= PCRE_HASCRORLF;
+      }
+#endif
+
+
+    /* If class_charcount is 1, we saw precisely one character whose value is
+    less than 256. As long as there were no characters >= 128 and there was no
+    use of \p or \P, in other words, no use of any XCLASS features, we can
+    optimize.
+
+    In UTF-8 mode, we can optimize the negative case only if there were no
+    characters >= 128 because OP_NOT and the related opcodes like OP_NOTSTAR
+    operate on single-bytes only. This is an historical hangover. Maybe one day
+    we can tidy these opcodes to handle multi-byte characters.
+
+    The optimization throws away the bit map. We turn the item into a
+    1-character OP_CHAR[NC] if it's positive, or OP_NOT if it's negative. Note
+    that OP_NOT does not support multibyte characters. In the positive case, it
+    can cause firstbyte to be set. Otherwise, there can be no first char if
+    this item is first, whatever repeat count may follow. In the case of
+    reqbyte, save the previous value for reinstating. */
+
+#ifdef SUPPORT_UTF8
+    if (class_charcount == 1 && !class_utf8 &&
+      (!utf8 || !negate_class || class_lastchar < 128))
+#else
+    if (class_charcount == 1)
+#endif
+      {
+      zeroreqbyte = reqbyte;
+
+      /* The OP_NOT opcode works on one-byte characters only. */
+
+      if (negate_class)
+        {
+        if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+        zerofirstbyte = firstbyte;
+        *code++ = OP_NOT;
+        *code++ = class_lastchar;
+        break;
+        }
+
+      /* For a single, positive character, get the value into mcbuffer, and
+      then we can handle this with the normal one-character code. */
+
+#ifdef SUPPORT_UTF8
+      if (utf8 && class_lastchar > 127)
+        mclength = _pcre_ord2utf8(class_lastchar, mcbuffer);
+      else
+#endif
+        {
+        mcbuffer[0] = class_lastchar;
+        mclength = 1;
+        }
+      goto ONE_CHAR;
+      }       /* End of 1-char optimization */
+
+    /* The general case - not the one-char optimization. If this is the first
+    thing in the branch, there can be no first char setting, whatever the
+    repeat count. Any reqbyte setting must remain unchanged after any kind of
+    repeat. */
+
+    if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+    zerofirstbyte = firstbyte;
+    zeroreqbyte = reqbyte;
+
+    /* If there are characters with values > 255, we have to compile an
+    extended class, with its own opcode, unless there was a negated special
+    such as \S in the class, because in that case all characters > 255 are in
+    the class, so any that were explicitly given as well can be ignored. If
+    (when there are explicit characters > 255 that must be listed) there are no
+    characters < 256, we can omit the bitmap in the actual compiled code. */
+
+#ifdef SUPPORT_UTF8
+    if (class_utf8 && !should_flip_negation)
+      {
+      *class_utf8data++ = XCL_END;    /* Marks the end of extra data */
+      *code++ = OP_XCLASS;
+      code += LINK_SIZE;
+      *code = negate_class? XCL_NOT : 0;
+
+      /* If the map is required, move up the extra data to make room for it;
+      otherwise just move the code pointer to the end of the extra data. */
+
+      if (class_charcount > 0)
+        {
+        *code++ |= XCL_MAP;
+        memmove(code + 32, code, class_utf8data - code);
+        memcpy(code, classbits, 32);
+        code = class_utf8data + 32;
+        }
+      else code = class_utf8data;
+
+      /* Now fill in the complete length of the item */
+
+      PUT(previous, 1, code - previous);
+      break;   /* End of class handling */
+      }
+#endif
+
+    /* If there are no characters > 255, set the opcode to OP_CLASS or
+    OP_NCLASS, depending on whether the whole class was negated and whether
+    there were negative specials such as \S in the class. Then copy the 32-byte
+    map into the code vector, negating it if necessary. */
+
+    *code++ = (negate_class == should_flip_negation) ? OP_CLASS : OP_NCLASS;
+    if (negate_class)
+      {
+      if (lengthptr == NULL)    /* Save time in the pre-compile phase */
+        for (c = 0; c < 32; c++) code[c] = ~classbits[c];
+      }
+    else
+      {
+      memcpy(code, classbits, 32);
+      }
+    code += 32;
+    break;
+
+
+    /* ===================================================================*/
+    /* Various kinds of repeat; '{' is not necessarily a quantifier, but this
+    has been tested above. */
+
+    case '{':
+    if (!is_quantifier) goto NORMAL_CHAR;
+    ptr = read_repeat_counts(ptr+1, &repeat_min, &repeat_max, errorcodeptr);
+    if (*errorcodeptr != 0) goto FAILED;
+    goto REPEAT;
+
+    case '*':
+    repeat_min = 0;
+    repeat_max = -1;
+    goto REPEAT;
+
+    case '+':
+    repeat_min = 1;
+    repeat_max = -1;
+    goto REPEAT;
+
+    case '?':
+    repeat_min = 0;
+    repeat_max = 1;
+
+    REPEAT:
+    if (previous == NULL)
+      {
+      *errorcodeptr = ERR9;
+      goto FAILED;
+      }
+
+    if (repeat_min == 0)
+      {
+      firstbyte = zerofirstbyte;    /* Adjust for zero repeat */
+      reqbyte = zeroreqbyte;        /* Ditto */
+      }
+
+    /* Remember whether this is a variable length repeat */
+
+    reqvary = (repeat_min == repeat_max)? 0 : REQ_VARY;
+
+    op_type = 0;                    /* Default single-char op codes */
+    possessive_quantifier = FALSE;  /* Default not possessive quantifier */
+
+    /* Save start of previous item, in case we have to move it up to make space
+    for an inserted OP_ONCE for the additional '+' extension. */
+
+    tempcode = previous;
+
+    /* If the next character is '+', we have a possessive quantifier. This
+    implies greediness, whatever the setting of the PCRE_UNGREEDY option.
+    If the next character is '?' this is a minimizing repeat, by default,
+    but if PCRE_UNGREEDY is set, it works the other way round. We change the
+    repeat type to the non-default. */
+
+    if (ptr[1] == '+')
+      {
+      repeat_type = 0;                  /* Force greedy */
+      possessive_quantifier = TRUE;
+      ptr++;
+      }
+    else if (ptr[1] == '?')
+      {
+      repeat_type = greedy_non_default;
+      ptr++;
+      }
+    else repeat_type = greedy_default;
+
+    /* If previous was a character match, abolish the item and generate a
+    repeat item instead. If a char item has a minumum of more than one, ensure
+    that it is set in reqbyte - it might not be if a sequence such as x{3} is
+    the first thing in a branch because the x will have gone into firstbyte
+    instead.  */
+
+    if (*previous == OP_CHAR || *previous == OP_CHARNC)
+      {
+      /* Deal with UTF-8 characters that take up more than one byte. It's
+      easier to write this out separately than try to macrify it. Use c to
+      hold the length of the character in bytes, plus 0x80 to flag that it's a
+      length rather than a small character. */
+
+#ifdef SUPPORT_UTF8
+      if (utf8 && (code[-1] & 0x80) != 0)
+        {
+        uschar *lastchar = code - 1;
+        while((*lastchar & 0xc0) == 0x80) lastchar--;
+        c = code - lastchar;            /* Length of UTF-8 character */
+        memcpy(utf8_char, lastchar, c); /* Save the char */
+        c |= 0x80;                      /* Flag c as a length */
+        }
+      else
+#endif
+
+      /* Handle the case of a single byte - either with no UTF8 support, or
+      with UTF-8 disabled, or for a UTF-8 character < 128. */
+
+        {
+        c = code[-1];
+        if (repeat_min > 1) reqbyte = c | req_caseopt | cd->req_varyopt;
+        }
+
+      /* If the repetition is unlimited, it pays to see if the next thing on
+      the line is something that cannot possibly match this character. If so,
+      automatically possessifying this item gains some performance in the case
+      where the match fails. */
+
+      if (!possessive_quantifier &&
+          repeat_max < 0 &&
+          check_auto_possessive(*previous, c, utf8, utf8_char, ptr + 1,
+            options, cd))
+        {
+        repeat_type = 0;    /* Force greedy */
+        possessive_quantifier = TRUE;
+        }
+
+      goto OUTPUT_SINGLE_REPEAT;   /* Code shared with single character types */
+      }
+
+    /* If previous was a single negated character ([^a] or similar), we use
+    one of the special opcodes, replacing it. The code is shared with single-
+    character repeats by setting opt_type to add a suitable offset into
+    repeat_type. We can also test for auto-possessification. OP_NOT is
+    currently used only for single-byte chars. */
+
+    else if (*previous == OP_NOT)
+      {
+      op_type = OP_NOTSTAR - OP_STAR;  /* Use "not" opcodes */
+      c = previous[1];
+      if (!possessive_quantifier &&
+          repeat_max < 0 &&
+          check_auto_possessive(OP_NOT, c, utf8, NULL, ptr + 1, options, cd))
+        {
+        repeat_type = 0;    /* Force greedy */
+        possessive_quantifier = TRUE;
+        }
+      goto OUTPUT_SINGLE_REPEAT;
+      }
+
+    /* If previous was a character type match (\d or similar), abolish it and
+    create a suitable repeat item. The code is shared with single-character
+    repeats by setting op_type to add a suitable offset into repeat_type. Note
+    the the Unicode property types will be present only when SUPPORT_UCP is
+    defined, but we don't wrap the little bits of code here because it just
+    makes it horribly messy. */
+
+    else if (*previous < OP_EODN)
+      {
+      uschar *oldcode;
+      int prop_type, prop_value;
+      op_type = OP_TYPESTAR - OP_STAR;  /* Use type opcodes */
+      c = *previous;
+
+      if (!possessive_quantifier &&
+          repeat_max < 0 &&
+          check_auto_possessive(c, 0, utf8, NULL, ptr + 1, options, cd))
+        {
+        repeat_type = 0;    /* Force greedy */
+        possessive_quantifier = TRUE;
+        }
+
+      OUTPUT_SINGLE_REPEAT:
+      if (*previous == OP_PROP || *previous == OP_NOTPROP)
+        {
+        prop_type = previous[1];
+        prop_value = previous[2];
+        }
+      else prop_type = prop_value = -1;
+
+      oldcode = code;
+      code = previous;                  /* Usually overwrite previous item */
+
+      /* If the maximum is zero then the minimum must also be zero; Perl allows
+      this case, so we do too - by simply omitting the item altogether. */
+
+      if (repeat_max == 0) goto END_REPEAT;
+
+      /* All real repeats make it impossible to handle partial matching (maybe
+      one day we will be able to remove this restriction). */
+
+      if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL;
+
+      /* Combine the op_type with the repeat_type */
+
+      repeat_type += op_type;
+
+      /* A minimum of zero is handled either as the special case * or ?, or as
+      an UPTO, with the maximum given. */
+
+      if (repeat_min == 0)
+        {
+        if (repeat_max == -1) *code++ = OP_STAR + repeat_type;
+          else if (repeat_max == 1) *code++ = OP_QUERY + repeat_type;
+        else
+          {
+          *code++ = OP_UPTO + repeat_type;
+          PUT2INC(code, 0, repeat_max);
+          }
+        }
+
+      /* A repeat minimum of 1 is optimized into some special cases. If the
+      maximum is unlimited, we use OP_PLUS. Otherwise, the original item is
+      left in place and, if the maximum is greater than 1, we use OP_UPTO with
+      one less than the maximum. */
+
+      else if (repeat_min == 1)
+        {
+        if (repeat_max == -1)
+          *code++ = OP_PLUS + repeat_type;
+        else
+          {
+          code = oldcode;                 /* leave previous item in place */
+          if (repeat_max == 1) goto END_REPEAT;
+          *code++ = OP_UPTO + repeat_type;
+          PUT2INC(code, 0, repeat_max - 1);
+          }
+        }
+
+      /* The case {n,n} is just an EXACT, while the general case {n,m} is
+      handled as an EXACT followed by an UPTO. */
+
+      else
+        {
+        *code++ = OP_EXACT + op_type;  /* NB EXACT doesn't have repeat_type */
+        PUT2INC(code, 0, repeat_min);
+
+        /* If the maximum is unlimited, insert an OP_STAR. Before doing so,
+        we have to insert the character for the previous code. For a repeated
+        Unicode property match, there are two extra bytes that define the
+        required property. In UTF-8 mode, long characters have their length in
+        c, with the 0x80 bit as a flag. */
+
+        if (repeat_max < 0)
+          {
+#ifdef SUPPORT_UTF8
+          if (utf8 && c >= 128)
+            {
+            memcpy(code, utf8_char, c & 7);
+            code += c & 7;
+            }
+          else
+#endif
+            {
+            *code++ = c;
+            if (prop_type >= 0)
+              {
+              *code++ = prop_type;
+              *code++ = prop_value;
+              }
+            }
+          *code++ = OP_STAR + repeat_type;
+          }
+
+        /* Else insert an UPTO if the max is greater than the min, again
+        preceded by the character, for the previously inserted code. If the
+        UPTO is just for 1 instance, we can use QUERY instead. */
+
+        else if (repeat_max != repeat_min)
+          {
+#ifdef SUPPORT_UTF8
+          if (utf8 && c >= 128)
+            {
+            memcpy(code, utf8_char, c & 7);
+            code += c & 7;
+            }
+          else
+#endif
+          *code++ = c;
+          if (prop_type >= 0)
+            {
+            *code++ = prop_type;
+            *code++ = prop_value;
+            }
+          repeat_max -= repeat_min;
+
+          if (repeat_max == 1)
+            {
+            *code++ = OP_QUERY + repeat_type;
+            }
+          else
+            {
+            *code++ = OP_UPTO + repeat_type;
+            PUT2INC(code, 0, repeat_max);
+            }
+          }
+        }
+
+      /* The character or character type itself comes last in all cases. */
+
+#ifdef SUPPORT_UTF8
+      if (utf8 && c >= 128)
+        {
+        memcpy(code, utf8_char, c & 7);
+        code += c & 7;
+        }
+      else
+#endif
+      *code++ = c;
+
+      /* For a repeated Unicode property match, there are two extra bytes that
+      define the required property. */
+
+#ifdef SUPPORT_UCP
+      if (prop_type >= 0)
+        {
+        *code++ = prop_type;
+        *code++ = prop_value;
+        }
+#endif
+      }
+
+    /* If previous was a character class or a back reference, we put the repeat
+    stuff after it, but just skip the item if the repeat was {0,0}. */
+
+    else if (*previous == OP_CLASS ||
+             *previous == OP_NCLASS ||
+#ifdef SUPPORT_UTF8
+             *previous == OP_XCLASS ||
+#endif
+             *previous == OP_REF)
+      {
+      if (repeat_max == 0)
+        {
+        code = previous;
+        goto END_REPEAT;
+        }
+
+      /* All real repeats make it impossible to handle partial matching (maybe
+      one day we will be able to remove this restriction). */
+
+      if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL;
+
+      if (repeat_min == 0 && repeat_max == -1)
+        *code++ = OP_CRSTAR + repeat_type;
+      else if (repeat_min == 1 && repeat_max == -1)
+        *code++ = OP_CRPLUS + repeat_type;
+      else if (repeat_min == 0 && repeat_max == 1)
+        *code++ = OP_CRQUERY + repeat_type;
+      else
+        {
+        *code++ = OP_CRRANGE + repeat_type;
+        PUT2INC(code, 0, repeat_min);
+        if (repeat_max == -1) repeat_max = 0;  /* 2-byte encoding for max */
+        PUT2INC(code, 0, repeat_max);
+        }
+      }
+
+    /* If previous was a bracket group, we may have to replicate it in certain
+    cases. */
+
+    else if (*previous == OP_BRA  || *previous == OP_CBRA ||
+             *previous == OP_ONCE || *previous == OP_COND)
+      {
+      register int i;
+      int ketoffset = 0;
+      int len = code - previous;
+      uschar *bralink = NULL;
+
+      /* Repeating a DEFINE group is pointless */
+
+      if (*previous == OP_COND && previous[LINK_SIZE+1] == OP_DEF)
+        {
+        *errorcodeptr = ERR55;
+        goto FAILED;
+        }
+
+      /* If the maximum repeat count is unlimited, find the end of the bracket
+      by scanning through from the start, and compute the offset back to it
+      from the current code pointer. There may be an OP_OPT setting following
+      the final KET, so we can't find the end just by going back from the code
+      pointer. */
+
+      if (repeat_max == -1)
+        {
+        register uschar *ket = previous;
+        do ket += GET(ket, 1); while (*ket != OP_KET);
+        ketoffset = code - ket;
+        }
+
+      /* The case of a zero minimum is special because of the need to stick
+      OP_BRAZERO in front of it, and because the group appears once in the
+      data, whereas in other cases it appears the minimum number of times. For
+      this reason, it is simplest to treat this case separately, as otherwise
+      the code gets far too messy. There are several special subcases when the
+      minimum is zero. */
+
+      if (repeat_min == 0)
+        {
+        /* If the maximum is also zero, we used to just omit the group from the
+        output altogether, like this:
+
+        ** if (repeat_max == 0)
+        **   {
+        **   code = previous;
+        **   goto END_REPEAT;
+        **   }
+
+        However, that fails when a group is referenced as a subroutine from
+        elsewhere in the pattern, so now we stick in OP_SKIPZERO in front of it
+        so that it is skipped on execution. As we don't have a list of which
+        groups are referenced, we cannot do this selectively.
+
+        If the maximum is 1 or unlimited, we just have to stick in the BRAZERO
+        and do no more at this point. However, we do need to adjust any
+        OP_RECURSE calls inside the group that refer to the group itself or any
+        internal or forward referenced group, because the offset is from the
+        start of the whole regex. Temporarily terminate the pattern while doing
+        this. */
+
+        if (repeat_max <= 1)    /* Covers 0, 1, and unlimited */
+          {
+          *code = OP_END;
+          adjust_recurse(previous, 1, utf8, cd, save_hwm);
+          memmove(previous+1, previous, len);
+          code++;
+          if (repeat_max == 0)
+            {
+            *previous++ = OP_SKIPZERO;
+            goto END_REPEAT;
+            }
+          *previous++ = OP_BRAZERO + repeat_type;
+          }
+
+        /* If the maximum is greater than 1 and limited, we have to replicate
+        in a nested fashion, sticking OP_BRAZERO before each set of brackets.
+        The first one has to be handled carefully because it's the original
+        copy, which has to be moved up. The remainder can be handled by code
+        that is common with the non-zero minimum case below. We have to
+        adjust the value or repeat_max, since one less copy is required. Once
+        again, we may have to adjust any OP_RECURSE calls inside the group. */
+
+        else
+          {
+          int offset;
+          *code = OP_END;
+          adjust_recurse(previous, 2 + LINK_SIZE, utf8, cd, save_hwm);
+          memmove(previous + 2 + LINK_SIZE, previous, len);
+          code += 2 + LINK_SIZE;
+          *previous++ = OP_BRAZERO + repeat_type;
+          *previous++ = OP_BRA;
+
+          /* We chain together the bracket offset fields that have to be
+          filled in later when the ends of the brackets are reached. */
+
+          offset = (bralink == NULL)? 0 : previous - bralink;
+          bralink = previous;
+          PUTINC(previous, 0, offset);
+          }
+
+        repeat_max--;
+        }
+
+      /* If the minimum is greater than zero, replicate the group as many
+      times as necessary, and adjust the maximum to the number of subsequent
+      copies that we need. If we set a first char from the group, and didn't
+      set a required char, copy the latter from the former. If there are any
+      forward reference subroutine calls in the group, there will be entries on
+      the workspace list; replicate these with an appropriate increment. */
+
+      else
+        {
+        if (repeat_min > 1)
+          {
+          /* In the pre-compile phase, we don't actually do the replication. We
+          just adjust the length as if we had. Do some paranoid checks for
+          potential integer overflow. */
+
+          if (lengthptr != NULL)
+            {
+            int delta = (repeat_min - 1)*length_prevgroup;
+            if ((double)(repeat_min - 1)*(double)length_prevgroup >
+                                                            (double)INT_MAX ||
+                OFLOW_MAX - *lengthptr < delta)
+              {
+              *errorcodeptr = ERR20;
+              goto FAILED;
+              }
+            *lengthptr += delta;
+            }
+
+          /* This is compiling for real */
+
+          else
+            {
+            if (groupsetfirstbyte && reqbyte < 0) reqbyte = firstbyte;
+            for (i = 1; i < repeat_min; i++)
+              {
+              uschar *hc;
+              uschar *this_hwm = cd->hwm;
+              memcpy(code, previous, len);
+              for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)
+                {
+                PUT(cd->hwm, 0, GET(hc, 0) + len);
+                cd->hwm += LINK_SIZE;
+                }
+              save_hwm = this_hwm;
+              code += len;
+              }
+            }
+          }
+
+        if (repeat_max > 0) repeat_max -= repeat_min;
+        }
+
+      /* This code is common to both the zero and non-zero minimum cases. If
+      the maximum is limited, it replicates the group in a nested fashion,
+      remembering the bracket starts on a stack. In the case of a zero minimum,
+      the first one was set up above. In all cases the repeat_max now specifies
+      the number of additional copies needed. Again, we must remember to
+      replicate entries on the forward reference list. */
+
+      if (repeat_max >= 0)
+        {
+        /* In the pre-compile phase, we don't actually do the replication. We
+        just adjust the length as if we had. For each repetition we must add 1
+        to the length for BRAZERO and for all but the last repetition we must
+        add 2 + 2*LINKSIZE to allow for the nesting that occurs. Do some
+        paranoid checks to avoid integer overflow. */
+
+        if (lengthptr != NULL && repeat_max > 0)
+          {
+          int delta = repeat_max * (length_prevgroup + 1 + 2 + 2*LINK_SIZE) -
+                      2 - 2*LINK_SIZE;   /* Last one doesn't nest */
+          if ((double)repeat_max *
+                (double)(length_prevgroup + 1 + 2 + 2*LINK_SIZE)
+                  > (double)INT_MAX ||
+              OFLOW_MAX - *lengthptr < delta)
+            {
+            *errorcodeptr = ERR20;
+            goto FAILED;
+            }
+          *lengthptr += delta;
+          }
+
+        /* This is compiling for real */
+
+        else for (i = repeat_max - 1; i >= 0; i--)
+          {
+          uschar *hc;
+          uschar *this_hwm = cd->hwm;
+
+          *code++ = OP_BRAZERO + repeat_type;
+
+          /* All but the final copy start a new nesting, maintaining the
+          chain of brackets outstanding. */
+
+          if (i != 0)
+            {
+            int offset;
+            *code++ = OP_BRA;
+            offset = (bralink == NULL)? 0 : code - bralink;
+            bralink = code;
+            PUTINC(code, 0, offset);
+            }
+
+          memcpy(code, previous, len);
+          for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)
+            {
+            PUT(cd->hwm, 0, GET(hc, 0) + len + ((i != 0)? 2+LINK_SIZE : 1));
+            cd->hwm += LINK_SIZE;
+            }
+          save_hwm = this_hwm;
+          code += len;
+          }
+
+        /* Now chain through the pending brackets, and fill in their length
+        fields (which are holding the chain links pro tem). */
+
+        while (bralink != NULL)
+          {
+          int oldlinkoffset;
+          int offset = code - bralink + 1;
+          uschar *bra = code - offset;
+          oldlinkoffset = GET(bra, 1);
+          bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset;
+          *code++ = OP_KET;
+          PUTINC(code, 0, offset);
+          PUT(bra, 1, offset);
+          }
+        }
+
+      /* If the maximum is unlimited, set a repeater in the final copy. We
+      can't just offset backwards from the current code point, because we
+      don't know if there's been an options resetting after the ket. The
+      correct offset was computed above.
+
+      Then, when we are doing the actual compile phase, check to see whether
+      this group is a non-atomic one that could match an empty string. If so,
+      convert the initial operator to the S form (e.g. OP_BRA -> OP_SBRA) so
+      that runtime checking can be done. [This check is also applied to
+      atomic groups at runtime, but in a different way.] */
+
+      else
+        {
+        uschar *ketcode = code - ketoffset;
+        uschar *bracode = ketcode - GET(ketcode, 1);
+        *ketcode = OP_KETRMAX + repeat_type;
+        if (lengthptr == NULL && *bracode != OP_ONCE)
+          {
+          uschar *scode = bracode;
+          do
+            {
+            if (could_be_empty_branch(scode, ketcode, utf8))
+              {
+              *bracode += OP_SBRA - OP_BRA;
+              break;
+              }
+            scode += GET(scode, 1);
+            }
+          while (*scode == OP_ALT);
+          }
+        }
+      }
+
+    /* If previous is OP_FAIL, it was generated by an empty class [] in
+    JavaScript mode. The other ways in which OP_FAIL can be generated, that is
+    by (*FAIL) or (?!) set previous to NULL, which gives a "nothing to repeat"
+    error above. We can just ignore the repeat in JS case. */
+
+    else if (*previous == OP_FAIL) goto END_REPEAT;
+
+    /* Else there's some kind of shambles */
+
+    else
+      {
+      *errorcodeptr = ERR11;
+      goto FAILED;
+      }
+
+    /* If the character following a repeat is '+', or if certain optimization
+    tests above succeeded, possessive_quantifier is TRUE. For some of the
+    simpler opcodes, there is an special alternative opcode for this. For
+    anything else, we wrap the entire repeated item inside OP_ONCE brackets.
+    The '+' notation is just syntactic sugar, taken from Sun's Java package,
+    but the special opcodes can optimize it a bit. The repeated item starts at
+    tempcode, not at previous, which might be the first part of a string whose
+    (former) last char we repeated.
+
+    Possessifying an 'exact' quantifier has no effect, so we can ignore it. But
+    an 'upto' may follow. We skip over an 'exact' item, and then test the
+    length of what remains before proceeding. */
+
+    if (possessive_quantifier)
+      {
+      int len;
+      if (*tempcode == OP_EXACT || *tempcode == OP_TYPEEXACT ||
+          *tempcode == OP_NOTEXACT)
+        tempcode += _pcre_OP_lengths[*tempcode] +
+          ((*tempcode == OP_TYPEEXACT &&
+             (tempcode[3] == OP_PROP || tempcode[3] == OP_NOTPROP))? 2:0);
+      len = code - tempcode;
+      if (len > 0) switch (*tempcode)
+        {
+        case OP_STAR:  *tempcode = OP_POSSTAR; break;
+        case OP_PLUS:  *tempcode = OP_POSPLUS; break;
+        case OP_QUERY: *tempcode = OP_POSQUERY; break;
+        case OP_UPTO:  *tempcode = OP_POSUPTO; break;
+
+        case OP_TYPESTAR:  *tempcode = OP_TYPEPOSSTAR; break;
+        case OP_TYPEPLUS:  *tempcode = OP_TYPEPOSPLUS; break;
+        case OP_TYPEQUERY: *tempcode = OP_TYPEPOSQUERY; break;
+        case OP_TYPEUPTO:  *tempcode = OP_TYPEPOSUPTO; break;
+
+        case OP_NOTSTAR:  *tempcode = OP_NOTPOSSTAR; break;
+        case OP_NOTPLUS:  *tempcode = OP_NOTPOSPLUS; break;
+        case OP_NOTQUERY: *tempcode = OP_NOTPOSQUERY; break;
+        case OP_NOTUPTO:  *tempcode = OP_NOTPOSUPTO; break;
+
+        default:
+        memmove(tempcode + 1+LINK_SIZE, tempcode, len);
+        code += 1 + LINK_SIZE;
+        len += 1 + LINK_SIZE;
+        tempcode[0] = OP_ONCE;
+        *code++ = OP_KET;
+        PUTINC(code, 0, len);
+        PUT(tempcode, 1, len);
+        break;
+        }
+      }
+
+    /* In all case we no longer have a previous item. We also set the
+    "follows varying string" flag for subsequently encountered reqbytes if
+    it isn't already set and we have just passed a varying length item. */
+
+    END_REPEAT:
+    previous = NULL;
+    cd->req_varyopt |= reqvary;
+    break;
+
+
+    /* ===================================================================*/
+    /* Start of nested parenthesized sub-expression, or comment or lookahead or
+    lookbehind or option setting or condition or all the other extended
+    parenthesis forms.  */
+
+    case '(':
+    newoptions = options;
+    skipbytes = 0;
+    bravalue = OP_CBRA;
+    save_hwm = cd->hwm;
+    reset_bracount = FALSE;
+
+    /* First deal with various "verbs" that can be introduced by '*'. */
+
+    if (*(++ptr) == '*' && (cd->ctypes[ptr[1]] & ctype_letter) != 0)
+      {
+      int i, namelen;
+      const char *vn = verbnames;
+      const uschar *name = ++ptr;
+      previous = NULL;
+      while ((cd->ctypes[*++ptr] & ctype_letter) != 0) {};
+      if (*ptr == ':')
+        {
+        *errorcodeptr = ERR59;   /* Not supported */
+        goto FAILED;
+        }
+      if (*ptr != ')')
+        {
+        *errorcodeptr = ERR60;
+        goto FAILED;
+        }
+      namelen = ptr - name;
+      for (i = 0; i < verbcount; i++)
+        {
+        if (namelen == verbs[i].len &&
+            strncmp((char *)name, vn, namelen) == 0)
+          {
+          *code = verbs[i].op;
+          if (*code++ == OP_ACCEPT) cd->had_accept = TRUE;
+          break;
+          }
+        vn += verbs[i].len + 1;
+        }
+      if (i < verbcount) continue;
+      *errorcodeptr = ERR60;
+      goto FAILED;
+      }
+
+    /* Deal with the extended parentheses; all are introduced by '?', and the
+    appearance of any of them means that this is not a capturing group. */
+
+    else if (*ptr == '?')
+      {
+      int i, set, unset, namelen;
+      int *optset;
+      const uschar *name;
+      uschar *slot;
+
+      switch (*(++ptr))
+        {
+        case '#':                 /* Comment; skip to ket */
+        ptr++;
+        while (*ptr != 0 && *ptr != ')') ptr++;
+        if (*ptr == 0)
+          {
+          *errorcodeptr = ERR18;
+          goto FAILED;
+          }
+        continue;
+
+
+        /* ------------------------------------------------------------ */
+        case '|':                 /* Reset capture count for each branch */
+        reset_bracount = TRUE;
+        /* Fall through */
+
+        /* ------------------------------------------------------------ */
+        case ':':                 /* Non-capturing bracket */
+        bravalue = OP_BRA;
+        ptr++;
+        break;
+
+
+        /* ------------------------------------------------------------ */
+        case '(':
+        bravalue = OP_COND;       /* Conditional group */
+
+        /* A condition can be an assertion, a number (referring to a numbered
+        group), a name (referring to a named group), or 'R', referring to
+        recursion. R<digits> and R&name are also permitted for recursion tests.
+
+        There are several syntaxes for testing a named group: (?(name)) is used
+        by Python; Perl 5.10 onwards uses (?(<name>) or (?('name')).
+
+        There are two unfortunate ambiguities, caused by history. (a) 'R' can
+        be the recursive thing or the name 'R' (and similarly for 'R' followed
+        by digits), and (b) a number could be a name that consists of digits.
+        In both cases, we look for a name first; if not found, we try the other
+        cases. */
+
+        /* For conditions that are assertions, check the syntax, and then exit
+        the switch. This will take control down to where bracketed groups,
+        including assertions, are processed. */
+
+        if (ptr[1] == '?' && (ptr[2] == '=' || ptr[2] == '!' || ptr[2] == '<'))
+          break;
+
+        /* Most other conditions use OP_CREF (a couple change to OP_RREF
+        below), and all need to skip 3 bytes at the start of the group. */
+
+        code[1+LINK_SIZE] = OP_CREF;
+        skipbytes = 3;
+        refsign = -1;
+
+        /* Check for a test for recursion in a named group. */
+
+        if (ptr[1] == 'R' && ptr[2] == '&')
+          {
+          terminator = -1;
+          ptr += 2;
+          code[1+LINK_SIZE] = OP_RREF;    /* Change the type of test */
+          }
+
+        /* Check for a test for a named group's having been set, using the Perl
+        syntax (?(<name>) or (?('name') */
+
+        else if (ptr[1] == '<')
+          {
+          terminator = '>';
+          ptr++;
+          }
+        else if (ptr[1] == '\'')
+          {
+          terminator = '\'';
+          ptr++;
+          }
+        else
+          {
+          terminator = 0;
+          if (ptr[1] == '-' || ptr[1] == '+') refsign = *(++ptr);
+          }
+
+        /* We now expect to read a name; any thing else is an error */
+
+        if ((cd->ctypes[ptr[1]] & ctype_word) == 0)
+          {
+          ptr += 1;  /* To get the right offset */
+          *errorcodeptr = ERR28;
+          goto FAILED;
+          }
+
+        /* Read the name, but also get it as a number if it's all digits */
+
+        recno = 0;
+        name = ++ptr;
+        while ((cd->ctypes[*ptr] & ctype_word) != 0)
+          {
+          if (recno >= 0)
+            recno = ((digitab[*ptr] & ctype_digit) != 0)?
+              recno * 10 + *ptr - '0' : -1;
+          ptr++;
+          }
+        namelen = ptr - name;
+
+        if ((terminator > 0 && *ptr++ != terminator) || *ptr++ != ')')
+          {
+          ptr--;      /* Error offset */
+          *errorcodeptr = ERR26;
+          goto FAILED;
+          }
+
+        /* Do no further checking in the pre-compile phase. */
+
+        if (lengthptr != NULL) break;
+
+        /* In the real compile we do the work of looking for the actual
+        reference. If the string started with "+" or "-" we require the rest to
+        be digits, in which case recno will be set. */
+
+        if (refsign > 0)
+          {
+          if (recno <= 0)
+            {
+            *errorcodeptr = ERR58;
+            goto FAILED;
+            }
+          recno = (refsign == '-')?
+            cd->bracount - recno + 1 : recno +cd->bracount;
+          if (recno <= 0 || recno > cd->final_bracount)
+            {
+            *errorcodeptr = ERR15;
+            goto FAILED;
+            }
+          PUT2(code, 2+LINK_SIZE, recno);
+          break;
+          }
+
+        /* Otherwise (did not start with "+" or "-"), start by looking for the
+        name. */
+
+        slot = cd->name_table;
+        for (i = 0; i < cd->names_found; i++)
+          {
+          if (strncmp((char *)name, (char *)slot+2, namelen) == 0) break;
+          slot += cd->name_entry_size;
+          }
+
+        /* Found a previous named subpattern */
+
+        if (i < cd->names_found)
+          {
+          recno = GET2(slot, 0);
+          PUT2(code, 2+LINK_SIZE, recno);
+          }
+
+        /* Search the pattern for a forward reference */
+
+        else if ((i = find_parens(ptr, cd, name, namelen,
+                        (options & PCRE_EXTENDED) != 0)) > 0)
+          {
+          PUT2(code, 2+LINK_SIZE, i);
+          }
+
+        /* If terminator == 0 it means that the name followed directly after
+        the opening parenthesis [e.g. (?(abc)...] and in this case there are
+        some further alternatives to try. For the cases where terminator != 0
+        [things like (?(<name>... or (?('name')... or (?(R&name)... ] we have
+        now checked all the possibilities, so give an error. */
+
+        else if (terminator != 0)
+          {
+          *errorcodeptr = ERR15;
+          goto FAILED;
+          }
+
+        /* Check for (?(R) for recursion. Allow digits after R to specify a
+        specific group number. */
+
+        else if (*name == 'R')
+          {
+          recno = 0;
+          for (i = 1; i < namelen; i++)
+            {
+            if ((digitab[name[i]] & ctype_digit) == 0)
+              {
+              *errorcodeptr = ERR15;
+              goto FAILED;
+              }
+            recno = recno * 10 + name[i] - '0';
+            }
+          if (recno == 0) recno = RREF_ANY;
+          code[1+LINK_SIZE] = OP_RREF;      /* Change test type */
+          PUT2(code, 2+LINK_SIZE, recno);
+          }
+
+        /* Similarly, check for the (?(DEFINE) "condition", which is always
+        false. */
+
+        else if (namelen == 6 && strncmp((char *)name, "DEFINE", 6) == 0)
+          {
+          code[1+LINK_SIZE] = OP_DEF;
+          skipbytes = 1;
+          }
+
+        /* Check for the "name" actually being a subpattern number. We are
+        in the second pass here, so final_bracount is set. */
+
+        else if (recno > 0 && recno <= cd->final_bracount)
+          {
+          PUT2(code, 2+LINK_SIZE, recno);
+          }
+
+        /* Either an unidentified subpattern, or a reference to (?(0) */
+
+        else
+          {
+          *errorcodeptr = (recno == 0)? ERR35: ERR15;
+          goto FAILED;
+          }
+        break;
+
+
+        /* ------------------------------------------------------------ */
+        case '=':                 /* Positive lookahead */
+        bravalue = OP_ASSERT;
+        ptr++;
+        break;
+
+
+        /* ------------------------------------------------------------ */
+        case '!':                 /* Negative lookahead */
+        ptr++;
+        if (*ptr == ')')          /* Optimize (?!) */
+          {
+          *code++ = OP_FAIL;
+          previous = NULL;
+          continue;
+          }
+        bravalue = OP_ASSERT_NOT;
+        break;
+
+
+        /* ------------------------------------------------------------ */
+        case '<':                 /* Lookbehind or named define */
+        switch (ptr[1])
+          {
+          case '=':               /* Positive lookbehind */
+          bravalue = OP_ASSERTBACK;
+          ptr += 2;
+          break;
+
+          case '!':               /* Negative lookbehind */
+          bravalue = OP_ASSERTBACK_NOT;
+          ptr += 2;
+          break;
+
+          default:                /* Could be name define, else bad */
+          if ((cd->ctypes[ptr[1]] & ctype_word) != 0) goto DEFINE_NAME;
+          ptr++;                  /* Correct offset for error */
+          *errorcodeptr = ERR24;
+          goto FAILED;
+          }
+        break;
+
+
+        /* ------------------------------------------------------------ */
+        case '>':                 /* One-time brackets */
+        bravalue = OP_ONCE;
+        ptr++;
+        break;
+
+
+        /* ------------------------------------------------------------ */
+        case 'C':                 /* Callout - may be followed by digits; */
+        previous_callout = code;  /* Save for later completion */
+        after_manual_callout = 1; /* Skip one item before completing */
+        *code++ = OP_CALLOUT;
+          {
+          int n = 0;
+          while ((digitab[*(++ptr)] & ctype_digit) != 0)
+            n = n * 10 + *ptr - '0';
+          if (*ptr != ')')
+            {
+            *errorcodeptr = ERR39;
+            goto FAILED;
+            }
+          if (n > 255)
+            {
+            *errorcodeptr = ERR38;
+            goto FAILED;
+            }
+          *code++ = n;
+          PUT(code, 0, ptr - cd->start_pattern + 1);  /* Pattern offset */
+          PUT(code, LINK_SIZE, 0);                    /* Default length */
+          code += 2 * LINK_SIZE;
+          }
+        previous = NULL;
+        continue;
+
+
+        /* ------------------------------------------------------------ */
+        case 'P':                 /* Python-style named subpattern handling */
+        if (*(++ptr) == '=' || *ptr == '>')  /* Reference or recursion */
+          {
+          is_recurse = *ptr == '>';
+          terminator = ')';
+          goto NAMED_REF_OR_RECURSE;
+          }
+        else if (*ptr != '<')    /* Test for Python-style definition */
+          {
+          *errorcodeptr = ERR41;
+          goto FAILED;
+          }
+        /* Fall through to handle (?P< as (?< is handled */
+
+
+        /* ------------------------------------------------------------ */
+        DEFINE_NAME:    /* Come here from (?< handling */
+        case '\'':
+          {
+          terminator = (*ptr == '<')? '>' : '\'';
+          name = ++ptr;
+
+          while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++;
+          namelen = ptr - name;
+
+          /* In the pre-compile phase, just do a syntax check. */
+
+          if (lengthptr != NULL)
+            {
+            if (*ptr != terminator)
+              {
+              *errorcodeptr = ERR42;
+              goto FAILED;
+              }
+            if (cd->names_found >= MAX_NAME_COUNT)
+              {
+              *errorcodeptr = ERR49;
+              goto FAILED;
+              }
+            if (namelen + 3 > cd->name_entry_size)
+              {
+              cd->name_entry_size = namelen + 3;
+              if (namelen > MAX_NAME_SIZE)
+                {
+                *errorcodeptr = ERR48;
+                goto FAILED;
+                }
+              }
+            }
+
+          /* In the real compile, create the entry in the table */
+
+          else
+            {
+            slot = cd->name_table;
+            for (i = 0; i < cd->names_found; i++)
+              {
+              int crc = memcmp(name, slot+2, namelen);
+              if (crc == 0)
+                {
+                if (slot[2+namelen] == 0)
+                  {
+                  if ((options & PCRE_DUPNAMES) == 0)
+                    {
+                    *errorcodeptr = ERR43;
+                    goto FAILED;
+                    }
+                  }
+                else crc = -1;      /* Current name is substring */
+                }
+              if (crc < 0)
+                {
+                memmove(slot + cd->name_entry_size, slot,
+                  (cd->names_found - i) * cd->name_entry_size);
+                break;
+                }
+              slot += cd->name_entry_size;
+              }
+
+            PUT2(slot, 0, cd->bracount + 1);
+            memcpy(slot + 2, name, namelen);
+            slot[2+namelen] = 0;
+            }
+          }
+
+        /* In both cases, count the number of names we've encountered. */
+
+        ptr++;                    /* Move past > or ' */
+        cd->names_found++;
+        goto NUMBERED_GROUP;
+
+
+        /* ------------------------------------------------------------ */
+        case '&':                 /* Perl recursion/subroutine syntax */
+        terminator = ')';
+        is_recurse = TRUE;
+        /* Fall through */
+
+        /* We come here from the Python syntax above that handles both
+        references (?P=name) and recursion (?P>name), as well as falling
+        through from the Perl recursion syntax (?&name). We also come here from
+        the Perl \k<name> or \k'name' back reference syntax and the \k{name}
+        .NET syntax, and the Oniguruma \g<...> and \g'...' subroutine syntax. */
+
+        NAMED_REF_OR_RECURSE:
+        name = ++ptr;
+        while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++;
+        namelen = ptr - name;
+
+        /* In the pre-compile phase, do a syntax check and set a dummy
+        reference number. */
+
+        if (lengthptr != NULL)
+          {
+          if (namelen == 0)
+            {
+            *errorcodeptr = ERR62;
+            goto FAILED;
+            }
+          if (*ptr != terminator)
+            {
+            *errorcodeptr = ERR42;
+            goto FAILED;
+            }
+          if (namelen > MAX_NAME_SIZE)
+            {
+            *errorcodeptr = ERR48;
+            goto FAILED;
+            }
+          recno = 0;
+          }
+
+        /* In the real compile, seek the name in the table. We check the name
+        first, and then check that we have reached the end of the name in the
+        table. That way, if the name that is longer than any in the table,
+        the comparison will fail without reading beyond the table entry. */
+
+        else
+          {
+          slot = cd->name_table;
+          for (i = 0; i < cd->names_found; i++)
+            {
+            if (strncmp((char *)name, (char *)slot+2, namelen) == 0 &&
+                slot[2+namelen] == 0)
+              break;
+            slot += cd->name_entry_size;
+            }
+
+          if (i < cd->names_found)         /* Back reference */
+            {
+            recno = GET2(slot, 0);
+            }
+          else if ((recno =                /* Forward back reference */
+                    find_parens(ptr, cd, name, namelen,
+                      (options & PCRE_EXTENDED) != 0)) <= 0)
+            {
+            *errorcodeptr = ERR15;
+            goto FAILED;
+            }
+          }
+
+        /* In both phases, we can now go to the code than handles numerical
+        recursion or backreferences. */
+
+        if (is_recurse) goto HANDLE_RECURSION;
+          else goto HANDLE_REFERENCE;
+
+
+        /* ------------------------------------------------------------ */
+        case 'R':                 /* Recursion */
+        ptr++;                    /* Same as (?0)      */
+        /* Fall through */
+
+
+        /* ------------------------------------------------------------ */
+        case '-': case '+':
+        case '0': case '1': case '2': case '3': case '4':   /* Recursion or */
+        case '5': case '6': case '7': case '8': case '9':   /* subroutine */
+          {
+          const uschar *called;
+          terminator = ')';
+
+          /* Come here from the \g<...> and \g'...' code (Oniguruma
+          compatibility). However, the syntax has been checked to ensure that
+          the ... are a (signed) number, so that neither ERR63 nor ERR29 will
+          be called on this path, nor with the jump to OTHER_CHAR_AFTER_QUERY
+          ever be taken. */
+
+          HANDLE_NUMERICAL_RECURSION:
+
+          if ((refsign = *ptr) == '+')
+            {
+            ptr++;
+            if ((digitab[*ptr] & ctype_digit) == 0)
+              {
+              *errorcodeptr = ERR63;
+              goto FAILED;
+              }
+            }
+          else if (refsign == '-')
+            {
+            if ((digitab[ptr[1]] & ctype_digit) == 0)
+              goto OTHER_CHAR_AFTER_QUERY;
+            ptr++;
+            }
+
+          recno = 0;
+          while((digitab[*ptr] & ctype_digit) != 0)
+            recno = recno * 10 + *ptr++ - '0';
+
+          if (*ptr != terminator)
+            {
+            *errorcodeptr = ERR29;
+            goto FAILED;
+            }
+
+          if (refsign == '-')
+            {
+            if (recno == 0)
+              {
+              *errorcodeptr = ERR58;
+              goto FAILED;
+              }
+            recno = cd->bracount - recno + 1;
+            if (recno <= 0)
+              {
+              *errorcodeptr = ERR15;
+              goto FAILED;
+              }
+            }
+          else if (refsign == '+')
+            {
+            if (recno == 0)
+              {
+              *errorcodeptr = ERR58;
+              goto FAILED;
+              }
+            recno += cd->bracount;
+            }
+
+          /* Come here from code above that handles a named recursion */
+
+          HANDLE_RECURSION:
+
+          previous = code;
+          called = cd->start_code;
+
+          /* When we are actually compiling, find the bracket that is being
+          referenced. Temporarily end the regex in case it doesn't exist before
+          this point. If we end up with a forward reference, first check that
+          the bracket does occur later so we can give the error (and position)
+          now. Then remember this forward reference in the workspace so it can
+          be filled in at the end. */
+
+          if (lengthptr == NULL)
+            {
+            *code = OP_END;
+            if (recno != 0) called = find_bracket(cd->start_code, utf8, recno);
+
+            /* Forward reference */
+
+            if (called == NULL)
+              {
+              if (find_parens(ptr, cd, NULL, recno,
+                    (options & PCRE_EXTENDED) != 0) < 0)
+                {
+                *errorcodeptr = ERR15;
+                goto FAILED;
+                }
+              called = cd->start_code + recno;
+              PUTINC(cd->hwm, 0, code + 2 + LINK_SIZE - cd->start_code);
+              }
+
+            /* If not a forward reference, and the subpattern is still open,
+            this is a recursive call. We check to see if this is a left
+            recursion that could loop for ever, and diagnose that case. */
+
+            else if (GET(called, 1) == 0 &&
+                     could_be_empty(called, code, bcptr, utf8))
+              {
+              *errorcodeptr = ERR40;
+              goto FAILED;
+              }
+            }
+
+          /* Insert the recursion/subroutine item, automatically wrapped inside
+          "once" brackets. Set up a "previous group" length so that a
+          subsequent quantifier will work. */
+
+          *code = OP_ONCE;
+          PUT(code, 1, 2 + 2*LINK_SIZE);
+          code += 1 + LINK_SIZE;
+
+          *code = OP_RECURSE;
+          PUT(code, 1, called - cd->start_code);
+          code += 1 + LINK_SIZE;
+
+          *code = OP_KET;
+          PUT(code, 1, 2 + 2*LINK_SIZE);
+          code += 1 + LINK_SIZE;
+
+          length_prevgroup = 3 + 3*LINK_SIZE;
+          }
+
+        /* Can't determine a first byte now */
+
+        if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+        continue;
+
+
+        /* ------------------------------------------------------------ */
+        default:              /* Other characters: check option setting */
+        OTHER_CHAR_AFTER_QUERY:
+        set = unset = 0;
+        optset = &set;
+
+        while (*ptr != ')' && *ptr != ':')
+          {
+          switch (*ptr++)
+            {
+            case '-': optset = &unset; break;
+
+            case 'J':    /* Record that it changed in the external options */
+            *optset |= PCRE_DUPNAMES;
+            cd->external_flags |= PCRE_JCHANGED;
+            break;
+
+            case 'i': *optset |= PCRE_CASELESS; break;
+            case 'm': *optset |= PCRE_MULTILINE; break;
+            case 's': *optset |= PCRE_DOTALL; break;
+            case 'x': *optset |= PCRE_EXTENDED; break;
+            case 'U': *optset |= PCRE_UNGREEDY; break;
+            case 'X': *optset |= PCRE_EXTRA; break;
+
+            default:  *errorcodeptr = ERR12;
+                      ptr--;    /* Correct the offset */
+                      goto FAILED;
+            }
+          }
+
+        /* Set up the changed option bits, but don't change anything yet. */
+
+        newoptions = (options | set) & (~unset);
+
+        /* If the options ended with ')' this is not the start of a nested
+        group with option changes, so the options change at this level. If this
+        item is right at the start of the pattern, the options can be
+        abstracted and made external in the pre-compile phase, and ignored in
+        the compile phase. This can be helpful when matching -- for instance in
+        caseless checking of required bytes.
+
+        If the code pointer is not (cd->start_code + 1 + LINK_SIZE), we are
+        definitely *not* at the start of the pattern because something has been
+        compiled. In the pre-compile phase, however, the code pointer can have
+        that value after the start, because it gets reset as code is discarded
+        during the pre-compile. However, this can happen only at top level - if
+        we are within parentheses, the starting BRA will still be present. At
+        any parenthesis level, the length value can be used to test if anything
+        has been compiled at that level. Thus, a test for both these conditions
+        is necessary to ensure we correctly detect the start of the pattern in
+        both phases.
+
+        If we are not at the pattern start, compile code to change the ims
+        options if this setting actually changes any of them, and reset the
+        greedy defaults and the case value for firstbyte and reqbyte. */
+
+        if (*ptr == ')')
+          {
+          if (code == cd->start_code + 1 + LINK_SIZE &&
+               (lengthptr == NULL || *lengthptr == 2 + 2*LINK_SIZE))
+            {
+            cd->external_options = newoptions;
+            }
+         else
+            {
+            if ((options & PCRE_IMS) != (newoptions & PCRE_IMS))
+              {
+              *code++ = OP_OPT;
+              *code++ = newoptions & PCRE_IMS;
+              }
+            greedy_default = ((newoptions & PCRE_UNGREEDY) != 0);
+            greedy_non_default = greedy_default ^ 1;
+            req_caseopt = ((newoptions & PCRE_CASELESS) != 0)? REQ_CASELESS : 0;
+            }
+
+          /* Change options at this level, and pass them back for use
+          in subsequent branches. When not at the start of the pattern, this
+          information is also necessary so that a resetting item can be
+          compiled at the end of a group (if we are in a group). */
+
+          *optionsptr = options = newoptions;
+          previous = NULL;       /* This item can't be repeated */
+          continue;              /* It is complete */
+          }
+
+        /* If the options ended with ':' we are heading into a nested group
+        with possible change of options. Such groups are non-capturing and are
+        not assertions of any kind. All we need to do is skip over the ':';
+        the newoptions value is handled below. */
+
+        bravalue = OP_BRA;
+        ptr++;
+        }     /* End of switch for character following (? */
+      }       /* End of (? handling */
+
+    /* Opening parenthesis not followed by '?'. If PCRE_NO_AUTO_CAPTURE is set,
+    all unadorned brackets become non-capturing and behave like (?:...)
+    brackets. */
+
+    else if ((options & PCRE_NO_AUTO_CAPTURE) != 0)
+      {
+      bravalue = OP_BRA;
+      }
+
+    /* Else we have a capturing group. */
+
+    else
+      {
+      NUMBERED_GROUP:
+      cd->bracount += 1;
+      PUT2(code, 1+LINK_SIZE, cd->bracount);
+      skipbytes = 2;
+      }
+
+    /* Process nested bracketed regex. Assertions may not be repeated, but
+    other kinds can be. All their opcodes are >= OP_ONCE. We copy code into a
+    non-register variable in order to be able to pass its address because some
+    compilers complain otherwise. Pass in a new setting for the ims options if
+    they have changed. */
+
+    previous = (bravalue >= OP_ONCE)? code : NULL;
+    *code = bravalue;
+    tempcode = code;
+    tempreqvary = cd->req_varyopt;     /* Save value before bracket */
+    length_prevgroup = 0;              /* Initialize for pre-compile phase */
+
+    if (!compile_regex(
+         newoptions,                   /* The complete new option state */
+         options & PCRE_IMS,           /* The previous ims option state */
+         &tempcode,                    /* Where to put code (updated) */
+         &ptr,                         /* Input pointer (updated) */
+         errorcodeptr,                 /* Where to put an error message */
+         (bravalue == OP_ASSERTBACK ||
+          bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
+         reset_bracount,               /* True if (?| group */
+         skipbytes,                    /* Skip over bracket number */
+         &subfirstbyte,                /* For possible first char */
+         &subreqbyte,                  /* For possible last char */
+         bcptr,                        /* Current branch chain */
+         cd,                           /* Tables block */
+         (lengthptr == NULL)? NULL :   /* Actual compile phase */
+           &length_prevgroup           /* Pre-compile phase */
+         ))
+      goto FAILED;
+
+    /* At the end of compiling, code is still pointing to the start of the
+    group, while tempcode has been updated to point past the end of the group
+    and any option resetting that may follow it. The pattern pointer (ptr)
+    is on the bracket. */
+
+    /* If this is a conditional bracket, check that there are no more than
+    two branches in the group, or just one if it's a DEFINE group. We do this
+    in the real compile phase, not in the pre-pass, where the whole group may
+    not be available. */
+
+    if (bravalue == OP_COND && lengthptr == NULL)
+      {
+      uschar *tc = code;
+      int condcount = 0;
+
+      do {
+         condcount++;
+         tc += GET(tc,1);
+         }
+      while (*tc != OP_KET);
+
+      /* A DEFINE group is never obeyed inline (the "condition" is always
+      false). It must have only one branch. */
+
+      if (code[LINK_SIZE+1] == OP_DEF)
+        {
+        if (condcount > 1)
+          {
+          *errorcodeptr = ERR54;
+          goto FAILED;
+          }
+        bravalue = OP_DEF;   /* Just a flag to suppress char handling below */
+        }
+
+      /* A "normal" conditional group. If there is just one branch, we must not
+      make use of its firstbyte or reqbyte, because this is equivalent to an
+      empty second branch. */
+
+      else
+        {
+        if (condcount > 2)
+          {
+          *errorcodeptr = ERR27;
+          goto FAILED;
+          }
+        if (condcount == 1) subfirstbyte = subreqbyte = REQ_NONE;
+        }
+      }
+
+    /* Error if hit end of pattern */
+
+    if (*ptr != ')')
+      {
+      *errorcodeptr = ERR14;
+      goto FAILED;
+      }
+
+    /* In the pre-compile phase, update the length by the length of the group,
+    less the brackets at either end. Then reduce the compiled code to just a
+    set of non-capturing brackets so that it doesn't use much memory if it is
+    duplicated by a quantifier.*/
+
+    if (lengthptr != NULL)
+      {
+      if (OFLOW_MAX - *lengthptr < length_prevgroup - 2 - 2*LINK_SIZE)
+        {
+        *errorcodeptr = ERR20;
+        goto FAILED;
+        }
+      *lengthptr += length_prevgroup - 2 - 2*LINK_SIZE;
+      *code++ = OP_BRA;
+      PUTINC(code, 0, 1 + LINK_SIZE);
+      *code++ = OP_KET;
+      PUTINC(code, 0, 1 + LINK_SIZE);
+      break;    /* No need to waste time with special character handling */
+      }
+
+    /* Otherwise update the main code pointer to the end of the group. */
+
+    code = tempcode;
+
+    /* For a DEFINE group, required and first character settings are not
+    relevant. */
+
+    if (bravalue == OP_DEF) break;
+
+    /* Handle updating of the required and first characters for other types of
+    group. Update for normal brackets of all kinds, and conditions with two
+    branches (see code above). If the bracket is followed by a quantifier with
+    zero repeat, we have to back off. Hence the definition of zeroreqbyte and
+    zerofirstbyte outside the main loop so that they can be accessed for the
+    back off. */
+
+    zeroreqbyte = reqbyte;
+    zerofirstbyte = firstbyte;
+    groupsetfirstbyte = FALSE;
+
+    if (bravalue >= OP_ONCE)
+      {
+      /* If we have not yet set a firstbyte in this branch, take it from the
+      subpattern, remembering that it was set here so that a repeat of more
+      than one can replicate it as reqbyte if necessary. If the subpattern has
+      no firstbyte, set "none" for the whole branch. In both cases, a zero
+      repeat forces firstbyte to "none". */
+
+      if (firstbyte == REQ_UNSET)
+        {
+        if (subfirstbyte >= 0)
+          {
+          firstbyte = subfirstbyte;
+          groupsetfirstbyte = TRUE;
+          }
+        else firstbyte = REQ_NONE;
+        zerofirstbyte = REQ_NONE;
+        }
+
+      /* If firstbyte was previously set, convert the subpattern's firstbyte
+      into reqbyte if there wasn't one, using the vary flag that was in
+      existence beforehand. */
+
+      else if (subfirstbyte >= 0 && subreqbyte < 0)
+        subreqbyte = subfirstbyte | tempreqvary;
+
+      /* If the subpattern set a required byte (or set a first byte that isn't
+      really the first byte - see above), set it. */
+
+      if (subreqbyte >= 0) reqbyte = subreqbyte;
+      }
+
+    /* For a forward assertion, we take the reqbyte, if set. This can be
+    helpful if the pattern that follows the assertion doesn't set a different
+    char. For example, it's useful for /(?=abcde).+/. We can't set firstbyte
+    for an assertion, however because it leads to incorrect effect for patterns
+    such as /(?=a)a.+/ when the "real" "a" would then become a reqbyte instead
+    of a firstbyte. This is overcome by a scan at the end if there's no
+    firstbyte, looking for an asserted first char. */
+
+    else if (bravalue == OP_ASSERT && subreqbyte >= 0) reqbyte = subreqbyte;
+    break;     /* End of processing '(' */
+
+
+    /* ===================================================================*/
+    /* Handle metasequences introduced by \. For ones like \d, the ESC_ values
+    are arranged to be the negation of the corresponding OP_values. For the
+    back references, the values are ESC_REF plus the reference number. Only
+    back references and those types that consume a character may be repeated.
+    We can test for values between ESC_b and ESC_Z for the latter; this may
+    have to change if any new ones are ever created. */
+
+    case '\\':
+    tempptr = ptr;
+    c = check_escape(&ptr, errorcodeptr, cd->bracount, options, FALSE);
+    if (*errorcodeptr != 0) goto FAILED;
+
+    if (c < 0)
+      {
+      if (-c == ESC_Q)            /* Handle start of quoted string */
+        {
+        if (ptr[1] == '\\' && ptr[2] == 'E') ptr += 2; /* avoid empty string */
+          else inescq = TRUE;
+        continue;
+        }
+
+      if (-c == ESC_E) continue;  /* Perl ignores an orphan \E */
+
+      /* For metasequences that actually match a character, we disable the
+      setting of a first character if it hasn't already been set. */
+
+      if (firstbyte == REQ_UNSET && -c > ESC_b && -c < ESC_Z)
+        firstbyte = REQ_NONE;
+
+      /* Set values to reset to if this is followed by a zero repeat. */
+
+      zerofirstbyte = firstbyte;
+      zeroreqbyte = reqbyte;
+
+      /* \g<name> or \g'name' is a subroutine call by name and \g<n> or \g'n'
+      is a subroutine call by number (Oniguruma syntax). In fact, the value
+      -ESC_g is returned only for these cases. So we don't need to check for <
+      or ' if the value is -ESC_g. For the Perl syntax \g{n} the value is
+      -ESC_REF+n, and for the Perl syntax \g{name} the result is -ESC_k (as
+      that is a synonym for a named back reference). */
+
+      if (-c == ESC_g)
+        {
+        const uschar *p;
+        save_hwm = cd->hwm;   /* Normally this is set when '(' is read */
+        terminator = (*(++ptr) == '<')? '>' : '\'';
+
+        /* These two statements stop the compiler for warning about possibly
+        unset variables caused by the jump to HANDLE_NUMERICAL_RECURSION. In
+        fact, because we actually check for a number below, the paths that
+        would actually be in error are never taken. */
+
+        skipbytes = 0;
+        reset_bracount = FALSE;
+
+        /* Test for a name */
+
+        if (ptr[1] != '+' && ptr[1] != '-')
+          {
+          BOOL isnumber = TRUE;
+          for (p = ptr + 1; *p != 0 && *p != terminator; p++)
+            {
+            if ((cd->ctypes[*p] & ctype_digit) == 0) isnumber = FALSE;
+            if ((cd->ctypes[*p] & ctype_word) == 0) break;
+            }
+          if (*p != terminator)
+            {
+            *errorcodeptr = ERR57;
+            break;
+            }
+          if (isnumber)
+            {
+            ptr++;
+            goto HANDLE_NUMERICAL_RECURSION;
+            }
+          is_recurse = TRUE;
+          goto NAMED_REF_OR_RECURSE;
+          }
+
+        /* Test a signed number in angle brackets or quotes. */
+
+        p = ptr + 2;
+        while ((digitab[*p] & ctype_digit) != 0) p++;
+        if (*p != terminator)
+          {
+          *errorcodeptr = ERR57;
+          break;
+          }
+        ptr++;
+        goto HANDLE_NUMERICAL_RECURSION;
+        }
+
+      /* \k<name> or \k'name' is a back reference by name (Perl syntax).
+      We also support \k{name} (.NET syntax) */
+
+      if (-c == ESC_k && (ptr[1] == '<' || ptr[1] == '\'' || ptr[1] == '{'))
+        {
+        is_recurse = FALSE;
+        terminator = (*(++ptr) == '<')? '>' : (*ptr == '\'')? '\'' : '}';
+        goto NAMED_REF_OR_RECURSE;
+        }
+
+      /* Back references are handled specially; must disable firstbyte if
+      not set to cope with cases like (?=(\w+))\1: which would otherwise set
+      ':' later. */
+
+      if (-c >= ESC_REF)
+        {
+        recno = -c - ESC_REF;
+
+        HANDLE_REFERENCE:    /* Come here from named backref handling */
+        if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
+        previous = code;
+        *code++ = OP_REF;
+        PUT2INC(code, 0, recno);
+        cd->backref_map |= (recno < 32)? (1 << recno) : 1;
+        if (recno > cd->top_backref) cd->top_backref = recno;
+        }
+
+      /* So are Unicode property matches, if supported. */
+
+#ifdef SUPPORT_UCP
+      else if (-c == ESC_P || -c == ESC_p)
+        {
+        BOOL negated;
+        int pdata;
+        int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);
+        if (ptype < 0) goto FAILED;
+        previous = code;
+        *code++ = ((-c == ESC_p) != negated)? OP_PROP : OP_NOTPROP;
+        *code++ = ptype;
+        *code++ = pdata;
+        }
+#else
+
+      /* If Unicode properties are not supported, \X, \P, and \p are not
+      allowed. */
+
+      else if (-c == ESC_X || -c == ESC_P || -c == ESC_p)
+        {
+        *errorcodeptr = ERR45;
+        goto FAILED;
+        }
+#endif
+
+      /* For the rest (including \X when Unicode properties are supported), we
+      can obtain the OP value by negating the escape value. */
+
+      else
+        {
+        previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;
+        *code++ = -c;
+        }
+      continue;
+      }
+
+    /* We have a data character whose value is in c. In UTF-8 mode it may have
+    a value > 127. We set its representation in the length/buffer, and then
+    handle it as a data character. */
+
+#ifdef SUPPORT_UTF8
+    if (utf8 && c > 127)
+      mclength = _pcre_ord2utf8(c, mcbuffer);
+    else
+#endif
+
+     {
+     mcbuffer[0] = c;
+     mclength = 1;
+     }
+    goto ONE_CHAR;
+
+
+    /* ===================================================================*/
+    /* Handle a literal character. It is guaranteed not to be whitespace or #
+    when the extended flag is set. If we are in UTF-8 mode, it may be a
+    multi-byte literal character. */
+
+    default:
+    NORMAL_CHAR:
+    mclength = 1;
+    mcbuffer[0] = c;
+
+#ifdef SUPPORT_UTF8
+    if (utf8 && c >= 0xc0)
+      {
+      while ((ptr[1] & 0xc0) == 0x80)
+        mcbuffer[mclength++] = *(++ptr);
+      }
+#endif
+
+    /* At this point we have the character's bytes in mcbuffer, and the length
+    in mclength. When not in UTF-8 mode, the length is always 1. */
+
+    ONE_CHAR:
+    previous = code;
+    *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARNC : OP_CHAR;
+    for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];
+
+    /* Remember if \r or \n were seen */
+
+    if (mcbuffer[0] == '\r' || mcbuffer[0] == '\n')
+      cd->external_flags |= PCRE_HASCRORLF;
+
+    /* Set the first and required bytes appropriately. If no previous first
+    byte, set it from this character, but revert to none on a zero repeat.
+    Otherwise, leave the firstbyte value alone, and don't change it on a zero
+    repeat. */
+
+    if (firstbyte == REQ_UNSET)
+      {
+      zerofirstbyte = REQ_NONE;
+      zeroreqbyte = reqbyte;
+
+      /* If the character is more than one byte long, we can set firstbyte
+      only if it is not to be matched caselessly. */
+
+      if (mclength == 1 || req_caseopt == 0)
+        {
+        firstbyte = mcbuffer[0] | req_caseopt;
+        if (mclength != 1) reqbyte = code[-1] | cd->req_varyopt;
+        }
+      else firstbyte = reqbyte = REQ_NONE;
+      }
+
+    /* firstbyte was previously set; we can set reqbyte only the length is
+    1 or the matching is caseful. */
+
+    else
+      {
+      zerofirstbyte = firstbyte;
+      zeroreqbyte = reqbyte;
+      if (mclength == 1 || req_caseopt == 0)
+        reqbyte = code[-1] | req_caseopt | cd->req_varyopt;
+      }
+
+    break;            /* End of literal character handling */
+    }
+  }                   /* end of big loop */
+
+
+/* Control never reaches here by falling through, only by a goto for all the
+error states. Pass back the position in the pattern so that it can be displayed
+to the user for diagnosing the error. */
+
+FAILED:
+*ptrptr = ptr;
+return FALSE;
+}
+
+
+
+
+/*************************************************
+*     Compile sequence of alternatives           *
+*************************************************/
+
+/* On entry, ptr is pointing past the bracket character, but on return it
+points to the closing bracket, or vertical bar, or end of string. The code
+variable is pointing at the byte into which the BRA operator has been stored.
+If the ims options are changed at the start (for a (?ims: group) or during any
+branch, we need to insert an OP_OPT item at the start of every following branch
+to ensure they get set correctly at run time, and also pass the new options
+into every subsequent branch compile.
+
+This function is used during the pre-compile phase when we are trying to find
+out the amount of memory needed, as well as during the real compile phase. The
+value of lengthptr distinguishes the two phases.
+
+Arguments:
+  options        option bits, including any changes for this subpattern
+  oldims         previous settings of ims option bits
+  codeptr        -> the address of the current code pointer
+  ptrptr         -> the address of the current pattern pointer
+  errorcodeptr   -> pointer to error code variable
+  lookbehind     TRUE if this is a lookbehind assertion
+  reset_bracount TRUE to reset the count for each branch
+  skipbytes      skip this many bytes at start (for brackets and OP_COND)
+  firstbyteptr   place to put the first required character, or a negative number
+  reqbyteptr     place to put the last required character, or a negative number
+  bcptr          pointer to the chain of currently open branches
+  cd             points to the data block with tables pointers etc.
+  lengthptr      NULL during the real compile phase
+                 points to length accumulator during pre-compile phase
+
+Returns:         TRUE on success
+*/
+
+static BOOL
+compile_regex(int options, int oldims, uschar **codeptr, const uschar **ptrptr,
+  int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes,
+  int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd,
+  int *lengthptr)
+{
+const uschar *ptr = *ptrptr;
+uschar *code = *codeptr;
+uschar *last_branch = code;
+uschar *start_bracket = code;
+uschar *reverse_count = NULL;
+int firstbyte, reqbyte;
+int branchfirstbyte, branchreqbyte;
+int length;
+int orig_bracount;
+int max_bracount;
+branch_chain bc;
+
+bc.outer = bcptr;
+bc.current = code;
+
+firstbyte = reqbyte = REQ_UNSET;
+
+/* Accumulate the length for use in the pre-compile phase. Start with the
+length of the BRA and KET and any extra bytes that are required at the
+beginning. We accumulate in a local variable to save frequent testing of
+lenthptr for NULL. We cannot do this by looking at the value of code at the
+start and end of each alternative, because compiled items are discarded during
+the pre-compile phase so that the work space is not exceeded. */
+
+length = 2 + 2*LINK_SIZE + skipbytes;
+
+/* WARNING: If the above line is changed for any reason, you must also change
+the code that abstracts option settings at the start of the pattern and makes
+them global. It tests the value of length for (2 + 2*LINK_SIZE) in the
+pre-compile phase to find out whether anything has yet been compiled or not. */
+
+/* Offset is set zero to mark that this bracket is still open */
+
+PUT(code, 1, 0);
+code += 1 + LINK_SIZE + skipbytes;
+
+/* Loop for each alternative branch */
+
+orig_bracount = max_bracount = cd->bracount;
+for (;;)
+  {
+  /* For a (?| group, reset the capturing bracket count so that each branch
+  uses the same numbers. */
+
+  if (reset_bracount) cd->bracount = orig_bracount;
+
+  /* Handle a change of ims options at the start of the branch */
+
+  if ((options & PCRE_IMS) != oldims)
+    {
+    *code++ = OP_OPT;
+    *code++ = options & PCRE_IMS;
+    length += 2;
+    }
+
+  /* Set up dummy OP_REVERSE if lookbehind assertion */
+
+  if (lookbehind)
+    {
+    *code++ = OP_REVERSE;
+    reverse_count = code;
+    PUTINC(code, 0, 0);
+    length += 1 + LINK_SIZE;
+    }
+
+  /* Now compile the branch; in the pre-compile phase its length gets added
+  into the length. */
+
+  if (!compile_branch(&options, &code, &ptr, errorcodeptr, &branchfirstbyte,
+        &branchreqbyte, &bc, cd, (lengthptr == NULL)? NULL : &length))
+    {
+    *ptrptr = ptr;
+    return FALSE;
+    }
+
+  /* Keep the highest bracket count in case (?| was used and some branch
+  has fewer than the rest. */
+
+  if (cd->bracount > max_bracount) max_bracount = cd->bracount;
+
+  /* In the real compile phase, there is some post-processing to be done. */
+
+  if (lengthptr == NULL)
+    {
+    /* If this is the first branch, the firstbyte and reqbyte values for the
+    branch become the values for the regex. */
+
+    if (*last_branch != OP_ALT)
+      {
+      firstbyte = branchfirstbyte;
+      reqbyte = branchreqbyte;
+      }
+
+    /* If this is not the first branch, the first char and reqbyte have to
+    match the values from all the previous branches, except that if the
+    previous value for reqbyte didn't have REQ_VARY set, it can still match,
+    and we set REQ_VARY for the regex. */
+
+    else
+      {
+      /* If we previously had a firstbyte, but it doesn't match the new branch,
+      we have to abandon the firstbyte for the regex, but if there was
+      previously no reqbyte, it takes on the value of the old firstbyte. */
+
+      if (firstbyte >= 0 && firstbyte != branchfirstbyte)
+        {
+        if (reqbyte < 0) reqbyte = firstbyte;
+        firstbyte = REQ_NONE;
+        }
+
+      /* If we (now or from before) have no firstbyte, a firstbyte from the
+      branch becomes a reqbyte if there isn't a branch reqbyte. */
+
+      if (firstbyte < 0 && branchfirstbyte >= 0 && branchreqbyte < 0)
+          branchreqbyte = branchfirstbyte;
+
+      /* Now ensure that the reqbytes match */
+
+      if ((reqbyte & ~REQ_VARY) != (branchreqbyte & ~REQ_VARY))
+        reqbyte = REQ_NONE;
+      else reqbyte |= branchreqbyte;   /* To "or" REQ_VARY */
+      }
+
+    /* If lookbehind, check that this branch matches a fixed-length string, and
+    put the length into the OP_REVERSE item. Temporarily mark the end of the
+    branch with OP_END. */
+
+    if (lookbehind)
+      {
+      int fixed_length;
+      *code = OP_END;
+      fixed_length = find_fixedlength(last_branch, options);
+      DPRINTF(("fixed length = %d\n", fixed_length));
+      if (fixed_length < 0)
+        {
+        *errorcodeptr = (fixed_length == -2)? ERR36 : ERR25;
+        *ptrptr = ptr;
+        return FALSE;
+        }
+      PUT(reverse_count, 0, fixed_length);
+      }
+    }
+
+  /* Reached end of expression, either ')' or end of pattern. In the real
+  compile phase, go back through the alternative branches and reverse the chain
+  of offsets, with the field in the BRA item now becoming an offset to the
+  first alternative. If there are no alternatives, it points to the end of the
+  group. The length in the terminating ket is always the length of the whole
+  bracketed item. If any of the ims options were changed inside the group,
+  compile a resetting op-code following, except at the very end of the pattern.
+  Return leaving the pointer at the terminating char. */
+
+  if (*ptr != '|')
+    {
+    if (lengthptr == NULL)
+      {
+      int branch_length = code - last_branch;
+      do
+        {
+        int prev_length = GET(last_branch, 1);
+        PUT(last_branch, 1, branch_length);
+        branch_length = prev_length;
+        last_branch -= branch_length;
+        }
+      while (branch_length > 0);
+      }
+
+    /* Fill in the ket */
+
+    *code = OP_KET;
+    PUT(code, 1, code - start_bracket);
+    code += 1 + LINK_SIZE;
+
+    /* Resetting option if needed */
+
+    if ((options & PCRE_IMS) != oldims && *ptr == ')')
+      {
+      *code++ = OP_OPT;
+      *code++ = oldims;
+      length += 2;
+      }
+
+    /* Retain the highest bracket number, in case resetting was used. */
+
+    cd->bracount = max_bracount;
+
+    /* Set values to pass back */
+
+    *codeptr = code;
+    *ptrptr = ptr;
+    *firstbyteptr = firstbyte;
+    *reqbyteptr = reqbyte;
+    if (lengthptr != NULL)
+      {
+      if (OFLOW_MAX - *lengthptr < length)
+        {
+        *errorcodeptr = ERR20;
+        return FALSE;
+        }
+      *lengthptr += length;
+      }
+    return TRUE;
+    }
+
+  /* Another branch follows. In the pre-compile phase, we can move the code
+  pointer back to where it was for the start of the first branch. (That is,
+  pretend that each branch is the only one.)
+
+  In the real compile phase, insert an ALT node. Its length field points back
+  to the previous branch while the bracket remains open. At the end the chain
+  is reversed. It's done like this so that the start of the bracket has a
+  zero offset until it is closed, making it possible to detect recursion. */
+
+  if (lengthptr != NULL)
+    {
+    code = *codeptr + 1 + LINK_SIZE + skipbytes;
+    length += 1 + LINK_SIZE;
+    }
+  else
+    {
+    *code = OP_ALT;
+    PUT(code, 1, code - last_branch);
+    bc.current = last_branch = code;
+    code += 1 + LINK_SIZE;
+    }
+
+  ptr++;
+  }
+/* Control never reaches here */
+}
+
+
+
+
+/*************************************************
+*          Check for anchored expression         *
+*************************************************/
+
+/* Try to find out if this is an anchored regular expression. Consider each
+alternative branch. If they all start with OP_SOD or OP_CIRC, or with a bracket
+all of whose alternatives start with OP_SOD or OP_CIRC (recurse ad lib), then
+it's anchored. However, if this is a multiline pattern, then only OP_SOD
+counts, since OP_CIRC can match in the middle.
+
+We can also consider a regex to be anchored if OP_SOM starts all its branches.
+This is the code for \G, which means "match at start of match position, taking
+into account the match offset".
+
+A branch is also implicitly anchored if it starts with .* and DOTALL is set,
+because that will try the rest of the pattern at all possible matching points,
+so there is no point trying again.... er ....
+
+.... except when the .* appears inside capturing parentheses, and there is a
+subsequent back reference to those parentheses. We haven't enough information
+to catch that case precisely.
+
+At first, the best we could do was to detect when .* was in capturing brackets
+and the highest back reference was greater than or equal to that level.
+However, by keeping a bitmap of the first 31 back references, we can catch some
+of the more common cases more precisely.
+
+Arguments:
+  code           points to start of expression (the bracket)
+  options        points to the options setting
+  bracket_map    a bitmap of which brackets we are inside while testing; this
+                  handles up to substring 31; after that we just have to take
+                  the less precise approach
+  backref_map    the back reference bitmap
+
+Returns:     TRUE or FALSE
+*/
+
+static BOOL
+is_anchored(register const uschar *code, int *options, unsigned int bracket_map,
+  unsigned int backref_map)
+{
+do {
+   const uschar *scode = first_significant_code(code + _pcre_OP_lengths[*code],
+     options, PCRE_MULTILINE, FALSE);
+   register int op = *scode;
+
+   /* Non-capturing brackets */
+
+   if (op == OP_BRA)
+     {
+     if (!is_anchored(scode, options, bracket_map, backref_map)) return FALSE;
+     }
+
+   /* Capturing brackets */
+
+   else if (op == OP_CBRA)
+     {
+     int n = GET2(scode, 1+LINK_SIZE);
+     int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
+     if (!is_anchored(scode, options, new_map, backref_map)) return FALSE;
+     }
+
+   /* Other brackets */
+
+   else if (op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
+     {
+     if (!is_anchored(scode, options, bracket_map, backref_map)) return FALSE;
+     }
+
+   /* .* is not anchored unless DOTALL is set (which generates OP_ALLANY) and
+   it isn't in brackets that are or may be referenced. */
+
+   else if ((op == OP_TYPESTAR || op == OP_TYPEMINSTAR ||
+             op == OP_TYPEPOSSTAR))
+     {
+     if (scode[1] != OP_ALLANY || (bracket_map & backref_map) != 0)
+       return FALSE;
+     }
+
+   /* Check for explicit anchoring */
+
+   else if (op != OP_SOD && op != OP_SOM &&
+           ((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))
+     return FALSE;
+   code += GET(code, 1);
+   }
+while (*code == OP_ALT);   /* Loop for each alternative */
+return TRUE;
+}
+
+
+
+/*************************************************
+*         Check for starting with ^ or .*        *
+*************************************************/
+
+/* This is called to find out if every branch starts with ^ or .* so that
+"first char" processing can be done to speed things up in multiline
+matching and for non-DOTALL patterns that start with .* (which must start at
+the beginning or after \n). As in the case of is_anchored() (see above), we
+have to take account of back references to capturing brackets that contain .*
+because in that case we can't make the assumption.
+
+Arguments:
+  code           points to start of expression (the bracket)
+  bracket_map    a bitmap of which brackets we are inside while testing; this
+                  handles up to substring 31; after that we just have to take
+                  the less precise approach
+  backref_map    the back reference bitmap
+
+Returns:         TRUE or FALSE
+*/
+
+static BOOL
+is_startline(const uschar *code, unsigned int bracket_map,
+  unsigned int backref_map)
+{
+do {
+   const uschar *scode = first_significant_code(code + _pcre_OP_lengths[*code],
+     NULL, 0, FALSE);
+   register int op = *scode;
+
+   /* Non-capturing brackets */
+
+   if (op == OP_BRA)
+     {
+     if (!is_startline(scode, bracket_map, backref_map)) return FALSE;
+     }
+
+   /* Capturing brackets */
+
+   else if (op == OP_CBRA)
+     {
+     int n = GET2(scode, 1+LINK_SIZE);
+     int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
+     if (!is_startline(scode, new_map, backref_map)) return FALSE;
+     }
+
+   /* Other brackets */
+
+   else if (op == OP_ASSERT || op == OP_ONCE || op == OP_COND)
+     { if (!is_startline(scode, bracket_map, backref_map)) return FALSE; }
+
+   /* .* means "start at start or after \n" if it isn't in brackets that
+   may be referenced. */
+
+   else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR || op == OP_TYPEPOSSTAR)
+     {
+     if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0) return FALSE;
+     }
+
+   /* Check for explicit circumflex */
+
+   else if (op != OP_CIRC) return FALSE;
+
+   /* Move on to the next alternative */
+
+   code += GET(code, 1);
+   }
+while (*code == OP_ALT);  /* Loop for each alternative */
+return TRUE;
+}
+
+
+
+/*************************************************
+*       Check for asserted fixed first char      *
+*************************************************/
+
+/* During compilation, the "first char" settings from forward assertions are
+discarded, because they can cause conflicts with actual literals that follow.
+However, if we end up without a first char setting for an unanchored pattern,
+it is worth scanning the regex to see if there is an initial asserted first
+char. If all branches start with the same asserted char, or with a bracket all
+of whose alternatives start with the same asserted char (recurse ad lib), then
+we return that char, otherwise -1.
+
+Arguments:
+  code       points to start of expression (the bracket)
+  options    pointer to the options (used to check casing changes)
+  inassert   TRUE if in an assertion
+
+Returns:     -1 or the fixed first char
+*/
+
+static int
+find_firstassertedchar(const uschar *code, int *options, BOOL inassert)
+{
+register int c = -1;
+do {
+   int d;
+   const uschar *scode =
+     first_significant_code(code + 1+LINK_SIZE, options, PCRE_CASELESS, TRUE);
+   register int op = *scode;
+
+   switch(op)
+     {
+     default:
+     return -1;
+
+     case OP_BRA:
+     case OP_CBRA:
+     case OP_ASSERT:
+     case OP_ONCE:
+     case OP_COND:
+     if ((d = find_firstassertedchar(scode, options, op == OP_ASSERT)) < 0)
+       return -1;
+     if (c < 0) c = d; else if (c != d) return -1;
+     break;
+
+     case OP_EXACT:       /* Fall through */
+     scode += 2;
+
+     case OP_CHAR:
+     case OP_CHARNC:
+     case OP_PLUS:
+     case OP_MINPLUS:
+     case OP_POSPLUS:
+     if (!inassert) return -1;
+     if (c < 0)
+       {
+       c = scode[1];
+       if ((*options & PCRE_CASELESS) != 0) c |= REQ_CASELESS;
+       }
+     else if (c != scode[1]) return -1;
+     break;
+     }
+
+   code += GET(code, 1);
+   }
+while (*code == OP_ALT);
+return c;
+}
+
+
+
+/*************************************************
+*        Compile a Regular Expression            *
+*************************************************/
+
+/* This function takes a string and returns a pointer to a block of store
+holding a compiled version of the expression. The original API for this
+function had no error code return variable; it is retained for backwards
+compatibility. The new function is given a new name.
+
+Arguments:
+  pattern       the regular expression
+  options       various option bits
+  errorcodeptr  pointer to error code variable (pcre_compile2() only)
+                  can be NULL if you don't want a code value
+  errorptr      pointer to pointer to error text
+  erroroffset   ptr offset in pattern where error was detected
+  tables        pointer to character tables or NULL
+
+Returns:        pointer to compiled data block, or NULL on error,
+                with errorptr and erroroffset set
+*/
+
+PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
+pcre_compile(const char *pattern, int options, const char **errorptr,
+  int *erroroffset, const unsigned char *tables)
+{
+return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
+}
+
+
+PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
+pcre_compile2(const char *pattern, int options, int *errorcodeptr,
+  const char **errorptr, int *erroroffset, const unsigned char *tables)
+{
+real_pcre *re;
+int length = 1;  /* For final END opcode */
+int firstbyte, reqbyte, newline;
+int errorcode = 0;
+int skipatstart = 0;
+#ifdef SUPPORT_UTF8
+BOOL utf8;
+#endif
+size_t size;
+uschar *code;
+const uschar *codestart;
+const uschar *ptr;
+compile_data compile_block;
+compile_data *cd = &compile_block;
+
+/* This space is used for "compiling" into during the first phase, when we are
+computing the amount of memory that is needed. Compiled items are thrown away
+as soon as possible, so that a fairly large buffer should be sufficient for
+this purpose. The same space is used in the second phase for remembering where
+to fill in forward references to subpatterns. */
+
+uschar cworkspace[COMPILE_WORK_SIZE];
+
+/* Set this early so that early errors get offset 0. */
+
+ptr = (const uschar *)pattern;
+
+/* We can't pass back an error message if errorptr is NULL; I guess the best we
+can do is just return NULL, but we can set a code value if there is a code
+pointer. */
+
+if (errorptr == NULL)
+  {
+  if (errorcodeptr != NULL) *errorcodeptr = 99;
+  return NULL;
+  }
+
+*errorptr = NULL;
+if (errorcodeptr != NULL) *errorcodeptr = ERR0;
+
+/* However, we can give a message for this error */
+
+if (erroroffset == NULL)
+  {
+  errorcode = ERR16;
+  goto PCRE_EARLY_ERROR_RETURN2;
+  }
+
+*erroroffset = 0;
+
+/* Can't support UTF8 unless PCRE has been compiled to include the code. */
+
+#ifdef SUPPORT_UTF8
+utf8 = (options & PCRE_UTF8) != 0;
+if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&
+     (*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0)
+  {
+  errorcode = ERR44;
+  goto PCRE_EARLY_ERROR_RETURN2;
+  }
+#else
+if ((options & PCRE_UTF8) != 0)
+  {
+  errorcode = ERR32;
+  goto PCRE_EARLY_ERROR_RETURN;
+  }
+#endif
+
+if ((options & ~PUBLIC_OPTIONS) != 0)
+  {
+  errorcode = ERR17;
+  goto PCRE_EARLY_ERROR_RETURN;
+  }
+
+/* Set up pointers to the individual character tables */
+
+if (tables == NULL) tables = _pcre_default_tables;
+cd->lcc = tables + lcc_offset;
+cd->fcc = tables + fcc_offset;
+cd->cbits = tables + cbits_offset;
+cd->ctypes = tables + ctypes_offset;
+
+/* Check for global one-time settings at the start of the pattern, and remember
+the offset for later. */
+
+while (ptr[skipatstart] == '(' && ptr[skipatstart+1] == '*')
+  {
+  int newnl = 0;
+  int newbsr = 0;
+
+  if (strncmp((char *)(ptr+skipatstart+2), "CR)", 3) == 0)
+    { skipatstart += 5; newnl = PCRE_NEWLINE_CR; }
+  else if (strncmp((char *)(ptr+skipatstart+2), "LF)", 3)  == 0)
+    { skipatstart += 5; newnl = PCRE_NEWLINE_LF; }
+  else if (strncmp((char *)(ptr+skipatstart+2), "CRLF)", 5)  == 0)
+    { skipatstart += 7; newnl = PCRE_NEWLINE_CR + PCRE_NEWLINE_LF; }
+  else if (strncmp((char *)(ptr+skipatstart+2), "ANY)", 4) == 0)
+    { skipatstart += 6; newnl = PCRE_NEWLINE_ANY; }
+  else if (strncmp((char *)(ptr+skipatstart+2), "ANYCRLF)", 8)  == 0)
+    { skipatstart += 10; newnl = PCRE_NEWLINE_ANYCRLF; }
+
+  else if (strncmp((char *)(ptr+skipatstart+2), "BSR_ANYCRLF)", 12) == 0)
+    { skipatstart += 14; newbsr = PCRE_BSR_ANYCRLF; }
+  else if (strncmp((char *)(ptr+skipatstart+2), "BSR_UNICODE)", 12) == 0)
+    { skipatstart += 14; newbsr = PCRE_BSR_UNICODE; }
+
+  if (newnl != 0)
+    options = (options & ~PCRE_NEWLINE_BITS) | newnl;
+  else if (newbsr != 0)
+    options = (options & ~(PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) | newbsr;
+  else break;
+  }
+
+/* Check validity of \R options. */
+
+switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
+  {
+  case 0:
+  case PCRE_BSR_ANYCRLF:
+  case PCRE_BSR_UNICODE:
+  break;
+  default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;
+  }
+
+/* Handle different types of newline. The three bits give seven cases. The
+current code allows for fixed one- or two-byte sequences, plus "any" and
+"anycrlf". */
+
+switch (options & PCRE_NEWLINE_BITS)
+  {
+  case 0: newline = NEWLINE; break;   /* Build-time default */
+  case PCRE_NEWLINE_CR: newline = '\r'; break;
+  case PCRE_NEWLINE_LF: newline = '\n'; break;
+  case PCRE_NEWLINE_CR+
+       PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
+  case PCRE_NEWLINE_ANY: newline = -1; break;
+  case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
+  default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;
+  }
+
+if (newline == -2)
+  {
+  cd->nltype = NLTYPE_ANYCRLF;
+  }
+else if (newline < 0)
+  {
+  cd->nltype = NLTYPE_ANY;
+  }
+else
+  {
+  cd->nltype = NLTYPE_FIXED;
+  if (newline > 255)
+    {
+    cd->nllen = 2;
+    cd->nl[0] = (newline >> 8) & 255;
+    cd->nl[1] = newline & 255;
+    }
+  else
+    {
+    cd->nllen = 1;
+    cd->nl[0] = newline;
+    }
+  }
+
+/* Maximum back reference and backref bitmap. The bitmap records up to 31 back
+references to help in deciding whether (.*) can be treated as anchored or not.
+*/
+
+cd->top_backref = 0;
+cd->backref_map = 0;
+
+/* Reflect pattern for debugging output */
+
+DPRINTF(("------------------------------------------------------------------\n"));
+DPRINTF(("%s\n", pattern));
+
+/* Pretend to compile the pattern while actually just accumulating the length
+of memory required. This behaviour is triggered by passing a non-NULL final
+argument to compile_regex(). We pass a block of workspace (cworkspace) for it
+to compile parts of the pattern into; the compiled code is discarded when it is
+no longer needed, so hopefully this workspace will never overflow, though there
+is a test for its doing so. */
+
+cd->bracount = cd->final_bracount = 0;
+cd->names_found = 0;
+cd->name_entry_size = 0;
+cd->name_table = NULL;
+cd->start_workspace = cworkspace;
+cd->start_code = cworkspace;
+cd->hwm = cworkspace;
+cd->start_pattern = (const uschar *)pattern;
+cd->end_pattern = (const uschar *)(pattern + strlen(pattern));
+cd->req_varyopt = 0;
+cd->external_options = options;
+cd->external_flags = 0;
+
+/* Now do the pre-compile. On error, errorcode will be set non-zero, so we
+don't need to look at the result of the function here. The initial options have
+been put into the cd block so that they can be changed if an option setting is
+found within the regex right at the beginning. Bringing initial option settings
+outside can help speed up starting point checks. */
+
+ptr += skipatstart;
+code = cworkspace;
+*code = OP_BRA;
+(void)compile_regex(cd->external_options, cd->external_options & PCRE_IMS,
+  &code, &ptr, &errorcode, FALSE, FALSE, 0, &firstbyte, &reqbyte, NULL, cd,
+  &length);
+if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;
+
+DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,
+  cd->hwm - cworkspace));
+
+if (length > MAX_PATTERN_SIZE)
+  {
+  errorcode = ERR20;
+  goto PCRE_EARLY_ERROR_RETURN;
+  }
+
+/* Compute the size of data block needed and get it, either from malloc or
+externally provided function. Integer overflow should no longer be possible
+because nowadays we limit the maximum value of cd->names_found and
+cd->name_entry_size. */
+
+size = length + sizeof(real_pcre) + cd->names_found * (cd->name_entry_size + 3);
+re = (real_pcre *)(pcre_malloc)(size);
+
+if (re == NULL)
+  {
+  errorcode = ERR21;
+  goto PCRE_EARLY_ERROR_RETURN;
+  }
+
+/* Put in the magic number, and save the sizes, initial options, internal
+flags, and character table pointer. NULL is used for the default character
+tables. The nullpad field is at the end; it's there to help in the case when a
+regex compiled on a system with 4-byte pointers is run on another with 8-byte
+pointers. */
+
+re->magic_number = MAGIC_NUMBER;
+re->size = size;
+re->options = cd->external_options;
+re->flags = cd->external_flags;
+re->dummy1 = 0;
+re->first_byte = 0;
+re->req_byte = 0;
+re->name_table_offset = sizeof(real_pcre);
+re->name_entry_size = cd->name_entry_size;
+re->name_count = cd->names_found;
+re->ref_count = 0;
+re->tables = (tables == _pcre_default_tables)? NULL : tables;
+re->nullpad = NULL;
+
+/* The starting points of the name/number translation table and of the code are
+passed around in the compile data block. The start/end pattern and initial
+options are already set from the pre-compile phase, as is the name_entry_size
+field. Reset the bracket count and the names_found field. Also reset the hwm
+field; this time it's used for remembering forward references to subpatterns.
+*/
+
+cd->final_bracount = cd->bracount;  /* Save for checking forward references */
+cd->bracount = 0;
+cd->names_found = 0;
+cd->name_table = (uschar *)re + re->name_table_offset;
+codestart = cd->name_table + re->name_entry_size * re->name_count;
+cd->start_code = codestart;
+cd->hwm = cworkspace;
+cd->req_varyopt = 0;
+cd->had_accept = FALSE;
+
+/* Set up a starting, non-extracting bracket, then compile the expression. On
+error, errorcode will be set non-zero, so we don't need to look at the result
+of the function here. */
+
+ptr = (const uschar *)pattern + skipatstart;
+code = (uschar *)codestart;
+*code = OP_BRA;
+(void)compile_regex(re->options, re->options & PCRE_IMS, &code, &ptr,
+  &errorcode, FALSE, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, NULL);
+re->top_bracket = cd->bracount;
+re->top_backref = cd->top_backref;
+re->flags = cd->external_flags;
+
+if (cd->had_accept) reqbyte = -1;   /* Must disable after (*ACCEPT) */
+
+/* If not reached end of pattern on success, there's an excess bracket. */
+
+if (errorcode == 0 && *ptr != 0) errorcode = ERR22;
+
+/* Fill in the terminating state and check for disastrous overflow, but
+if debugging, leave the test till after things are printed out. */
+
+*code++ = OP_END;
+
+#ifndef DEBUG
+if (code - codestart > length) errorcode = ERR23;
+#endif
+
+/* Fill in any forward references that are required. */
+
+while (errorcode == 0 && cd->hwm > cworkspace)
+  {
+  int offset, recno;
+  const uschar *groupptr;
+  cd->hwm -= LINK_SIZE;
+  offset = GET(cd->hwm, 0);
+  recno = GET(codestart, offset);
+  groupptr = find_bracket(codestart, (re->options & PCRE_UTF8) != 0, recno);
+  if (groupptr == NULL) errorcode = ERR53;
+    else PUT(((uschar *)codestart), offset, groupptr - codestart);
+  }
+
+/* Give an error if there's back reference to a non-existent capturing
+subpattern. */
+
+if (errorcode == 0 && re->top_backref > re->top_bracket) errorcode = ERR15;
+
+/* Failed to compile, or error while post-processing */
+
+if (errorcode != 0)
+  {
+  (pcre_free)(re);
+  PCRE_EARLY_ERROR_RETURN:
+  *erroroffset = ptr - (const uschar *)pattern;
+  PCRE_EARLY_ERROR_RETURN2:
+  *errorptr = find_error_text(errorcode);
+  if (errorcodeptr != NULL) *errorcodeptr = errorcode;
+  return NULL;
+  }
+
+/* If the anchored option was not passed, set the flag if we can determine that
+the pattern is anchored by virtue of ^ characters or \A or anything else (such
+as starting with .* when DOTALL is set).
+
+Otherwise, if we know what the first byte has to be, save it, because that
+speeds up unanchored matches no end. If not, see if we can set the
+PCRE_STARTLINE flag. This is helpful for multiline matches when all branches
+start with ^. and also when all branches start with .* for non-DOTALL matches.
+*/
+
+if ((re->options & PCRE_ANCHORED) == 0)
+  {
+  int temp_options = re->options;   /* May get changed during these scans */
+  if (is_anchored(codestart, &temp_options, 0, cd->backref_map))
+    re->options |= PCRE_ANCHORED;
+  else
+    {
+    if (firstbyte < 0)
+      firstbyte = find_firstassertedchar(codestart, &temp_options, FALSE);
+    if (firstbyte >= 0)   /* Remove caseless flag for non-caseable chars */
+      {
+      int ch = firstbyte & 255;
+      re->first_byte = ((firstbyte & REQ_CASELESS) != 0 &&
+         cd->fcc[ch] == ch)? ch : firstbyte;
+      re->flags |= PCRE_FIRSTSET;
+      }
+    else if (is_startline(codestart, 0, cd->backref_map))
+      re->flags |= PCRE_STARTLINE;
+    }
+  }
+
+/* For an anchored pattern, we use the "required byte" only if it follows a
+variable length item in the regex. Remove the caseless flag for non-caseable
+bytes. */
+
+if (reqbyte >= 0 &&
+     ((re->options & PCRE_ANCHORED) == 0 || (reqbyte & REQ_VARY) != 0))
+  {
+  int ch = reqbyte & 255;
+  re->req_byte = ((reqbyte & REQ_CASELESS) != 0 &&
+    cd->fcc[ch] == ch)? (reqbyte & ~REQ_CASELESS) : reqbyte;
+  re->flags |= PCRE_REQCHSET;
+  }
+
+/* Print out the compiled data if debugging is enabled. This is never the
+case when building a production library. */
+
+#ifdef DEBUG
+
+printf("Length = %d top_bracket = %d top_backref = %d\n",
+  length, re->top_bracket, re->top_backref);
+
+printf("Options=%08x\n", re->options);
+
+if ((re->flags & PCRE_FIRSTSET) != 0)
+  {
+  int ch = re->first_byte & 255;
+  const char *caseless = ((re->first_byte & REQ_CASELESS) == 0)?
+    "" : " (caseless)";
+  if (isprint(ch)) printf("First char = %c%s\n", ch, caseless);
+    else printf("First char = \\x%02x%s\n", ch, caseless);
+  }
+
+if ((re->flags & PCRE_REQCHSET) != 0)
+  {
+  int ch = re->req_byte & 255;
+  const char *caseless = ((re->req_byte & REQ_CASELESS) == 0)?
+    "" : " (caseless)";
+  if (isprint(ch)) printf("Req char = %c%s\n", ch, caseless);
+    else printf("Req char = \\x%02x%s\n", ch, caseless);
+  }
+
+pcre_printint(re, stdout, TRUE);
+
+/* This check is done here in the debugging case so that the code that
+was compiled can be seen. */
+
+if (code - codestart > length)
+  {
+  (pcre_free)(re);
+  *errorptr = find_error_text(ERR23);
+  *erroroffset = ptr - (uschar *)pattern;
+  if (errorcodeptr != NULL) *errorcodeptr = ERR23;
+  return NULL;
+  }
+#endif   /* DEBUG */
+
+return (pcre *)re;
+}
+
+/* End of pcre_compile.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_config.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,128 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_config(). */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+* Return info about what features are configured *
+*************************************************/
+
+/* This function has an extensible interface so that additional items can be
+added compatibly.
+
+Arguments:
+  what             what information is required
+  where            where to put the information
+
+Returns:           0 if data returned, negative on error
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_config(int what, void *where)
+{
+switch (what)
+  {
+  case PCRE_CONFIG_UTF8:
+#ifdef SUPPORT_UTF8
+  *((int *)where) = 1;
+#else
+  *((int *)where) = 0;
+#endif
+  break;
+
+  case PCRE_CONFIG_UNICODE_PROPERTIES:
+#ifdef SUPPORT_UCP
+  *((int *)where) = 1;
+#else
+  *((int *)where) = 0;
+#endif
+  break;
+
+  case PCRE_CONFIG_NEWLINE:
+  *((int *)where) = NEWLINE;
+  break;
+
+  case PCRE_CONFIG_BSR:
+#ifdef BSR_ANYCRLF
+  *((int *)where) = 1;
+#else
+  *((int *)where) = 0;
+#endif
+  break;
+
+  case PCRE_CONFIG_LINK_SIZE:
+  *((int *)where) = LINK_SIZE;
+  break;
+
+  case PCRE_CONFIG_POSIX_MALLOC_THRESHOLD:
+  *((int *)where) = POSIX_MALLOC_THRESHOLD;
+  break;
+
+  case PCRE_CONFIG_MATCH_LIMIT:
+  *((unsigned int *)where) = MATCH_LIMIT;
+  break;
+
+  case PCRE_CONFIG_MATCH_LIMIT_RECURSION:
+  *((unsigned int *)where) = MATCH_LIMIT_RECURSION;
+  break;
+
+  case PCRE_CONFIG_STACKRECURSE:
+#ifdef NO_RECURSE
+  *((int *)where) = 0;
+#else
+  *((int *)where) = 1;
+#endif
+  break;
+
+  default: return PCRE_ERROR_BADOPTION;
+  }
+
+return 0;
+}
+
+/* End of pcre_config.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_dfa_exec.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2920 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_dfa_exec(), which is an
+alternative matching function that uses a sort of DFA algorithm (not a true
+FSM). This is NOT Perl- compatible, but it has advantages in certain
+applications. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define NLBLOCK md             /* Block containing newline information */
+#define PSSTART start_subject  /* Field containing processed string start */
+#define PSEND   end_subject    /* Field containing processed string end */
+
+#include "pcre_internal.h"
+
+
+/* For use to indent debugging output */
+
+#define SP "                   "
+
+
+
+/*************************************************
+*      Code parameters and static tables         *
+*************************************************/
+
+/* These are offsets that are used to turn the OP_TYPESTAR and friends opcodes
+into others, under special conditions. A gap of 20 between the blocks should be
+enough. The resulting opcodes don't have to be less than 256 because they are
+never stored, so we push them well clear of the normal opcodes. */
+
+#define OP_PROP_EXTRA       300
+#define OP_EXTUNI_EXTRA     320
+#define OP_ANYNL_EXTRA      340
+#define OP_HSPACE_EXTRA     360
+#define OP_VSPACE_EXTRA     380
+
+
+/* This table identifies those opcodes that are followed immediately by a
+character that is to be tested in some way. This makes is possible to
+centralize the loading of these characters. In the case of Type * etc, the
+"character" is the opcode for \D, \d, \S, \s, \W, or \w, which will always be a
+small value. ***NOTE*** If the start of this table is modified, the two tables
+that follow must also be modified. */
+
+static const uschar coptable[] = {
+  0,                             /* End                                    */
+  0, 0, 0, 0, 0,                 /* \A, \G, \K, \B, \b                     */
+  0, 0, 0, 0, 0, 0,              /* \D, \d, \S, \s, \W, \w                 */
+  0, 0, 0,                       /* Any, AllAny, Anybyte                   */
+  0, 0, 0,                       /* NOTPROP, PROP, EXTUNI                  */
+  0, 0, 0, 0, 0,                 /* \R, \H, \h, \V, \v                     */
+  0, 0, 0, 0, 0,                 /* \Z, \z, Opt, ^, $                      */
+  1,                             /* Char                                   */
+  1,                             /* Charnc                                 */
+  1,                             /* not                                    */
+  /* Positive single-char repeats                                          */
+  1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */
+  3, 3, 3,                       /* upto, minupto, exact                   */
+  1, 1, 1, 3,                    /* *+, ++, ?+, upto+                      */
+  /* Negative single-char repeats - only for chars < 256                   */
+  1, 1, 1, 1, 1, 1,              /* NOT *, *?, +, +?, ?, ??                */
+  3, 3, 3,                       /* NOT upto, minupto, exact               */
+  1, 1, 1, 3,                    /* NOT *+, ++, ?+, updo+                  */
+  /* Positive type repeats                                                 */
+  1, 1, 1, 1, 1, 1,              /* Type *, *?, +, +?, ?, ??               */
+  3, 3, 3,                       /* Type upto, minupto, exact              */
+  1, 1, 1, 3,                    /* Type *+, ++, ?+, upto+                 */
+  /* Character class & ref repeats                                         */
+  0, 0, 0, 0, 0, 0,              /* *, *?, +, +?, ?, ??                    */
+  0, 0,                          /* CRRANGE, CRMINRANGE                    */
+  0,                             /* CLASS                                  */
+  0,                             /* NCLASS                                 */
+  0,                             /* XCLASS - variable length               */
+  0,                             /* REF                                    */
+  0,                             /* RECURSE                                */
+  0,                             /* CALLOUT                                */
+  0,                             /* Alt                                    */
+  0,                             /* Ket                                    */
+  0,                             /* KetRmax                                */
+  0,                             /* KetRmin                                */
+  0,                             /* Assert                                 */
+  0,                             /* Assert not                             */
+  0,                             /* Assert behind                          */
+  0,                             /* Assert behind not                      */
+  0,                             /* Reverse                                */
+  0, 0, 0, 0,                    /* ONCE, BRA, CBRA, COND                  */
+  0, 0, 0,                       /* SBRA, SCBRA, SCOND                     */
+  0,                             /* CREF                                   */
+  0,                             /* RREF                                   */
+  0,                             /* DEF                                    */
+  0, 0,                          /* BRAZERO, BRAMINZERO                    */
+  0, 0, 0, 0,                    /* PRUNE, SKIP, THEN, COMMIT              */
+  0, 0, 0                        /* FAIL, ACCEPT, SKIPZERO                 */
+};
+
+/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,
+and \w */
+
+static const uschar toptable1[] = {
+  0, 0, 0, 0, 0, 0,
+  ctype_digit, ctype_digit,
+  ctype_space, ctype_space,
+  ctype_word,  ctype_word,
+  0, 0                            /* OP_ANY, OP_ALLANY */
+};
+
+static const uschar toptable2[] = {
+  0, 0, 0, 0, 0, 0,
+  ctype_digit, 0,
+  ctype_space, 0,
+  ctype_word,  0,
+  1, 1                            /* OP_ANY, OP_ALLANY */
+};
+
+
+/* Structure for holding data about a particular state, which is in effect the
+current data for an active path through the match tree. It must consist
+entirely of ints because the working vector we are passed, and which we put
+these structures in, is a vector of ints. */
+
+typedef struct stateblock {
+  int offset;                     /* Offset to opcode */
+  int count;                      /* Count for repeats */
+  int ims;                        /* ims flag bits */
+  int data;                       /* Some use extra data */
+} stateblock;
+
+#define INTS_PER_STATEBLOCK  (sizeof(stateblock)/sizeof(int))
+
+
+#ifdef DEBUG
+/*************************************************
+*             Print character string             *
+*************************************************/
+
+/* Character string printing function for debugging.
+
+Arguments:
+  p            points to string
+  length       number of bytes
+  f            where to print
+
+Returns:       nothing
+*/
+
+static void
+pchars(unsigned char *p, int length, FILE *f)
+{
+int c;
+while (length-- > 0)
+  {
+  if (isprint(c = *(p++)))
+    fprintf(f, "%c", c);
+  else
+    fprintf(f, "\\x%02x", c);
+  }
+}
+#endif
+
+
+
+/*************************************************
+*    Execute a Regular Expression - DFA engine   *
+*************************************************/
+
+/* This internal function applies a compiled pattern to a subject string,
+starting at a given point, using a DFA engine. This function is called from the
+external one, possibly multiple times if the pattern is not anchored. The
+function calls itself recursively for some kinds of subpattern.
+
+Arguments:
+  md                the match_data block with fixed information
+  this_start_code   the opening bracket of this subexpression's code
+  current_subject   where we currently are in the subject string
+  start_offset      start offset in the subject string
+  offsets           vector to contain the matching string offsets
+  offsetcount       size of same
+  workspace         vector of workspace
+  wscount           size of same
+  ims               the current ims flags
+  rlevel            function call recursion level
+  recursing         regex recursive call level
+
+Returns:            > 0 => number of match offset pairs placed in offsets
+                    = 0 => offsets overflowed; longest matches are present
+                     -1 => failed to match
+                   < -1 => some kind of unexpected problem
+
+The following macros are used for adding states to the two state vectors (one
+for the current character, one for the following character). */
+
+#define ADD_ACTIVE(x,y) \
+  if (active_count++ < wscount) \
+    { \
+    next_active_state->offset = (x); \
+    next_active_state->count  = (y); \
+    next_active_state->ims    = ims; \
+    next_active_state++; \
+    DPRINTF(("%.*sADD_ACTIVE(%d,%d)\n", rlevel*2-2, SP, (x), (y))); \
+    } \
+  else return PCRE_ERROR_DFA_WSSIZE
+
+#define ADD_ACTIVE_DATA(x,y,z) \
+  if (active_count++ < wscount) \
+    { \
+    next_active_state->offset = (x); \
+    next_active_state->count  = (y); \
+    next_active_state->ims    = ims; \
+    next_active_state->data   = (z); \
+    next_active_state++; \
+    DPRINTF(("%.*sADD_ACTIVE_DATA(%d,%d,%d)\n", rlevel*2-2, SP, (x), (y), (z))); \
+    } \
+  else return PCRE_ERROR_DFA_WSSIZE
+
+#define ADD_NEW(x,y) \
+  if (new_count++ < wscount) \
+    { \
+    next_new_state->offset = (x); \
+    next_new_state->count  = (y); \
+    next_new_state->ims    = ims; \
+    next_new_state++; \
+    DPRINTF(("%.*sADD_NEW(%d,%d)\n", rlevel*2-2, SP, (x), (y))); \
+    } \
+  else return PCRE_ERROR_DFA_WSSIZE
+
+#define ADD_NEW_DATA(x,y,z) \
+  if (new_count++ < wscount) \
+    { \
+    next_new_state->offset = (x); \
+    next_new_state->count  = (y); \
+    next_new_state->ims    = ims; \
+    next_new_state->data   = (z); \
+    next_new_state++; \
+    DPRINTF(("%.*sADD_NEW_DATA(%d,%d,%d)\n", rlevel*2-2, SP, (x), (y), (z))); \
+    } \
+  else return PCRE_ERROR_DFA_WSSIZE
+
+/* And now, here is the code */
+
+static int
+internal_dfa_exec(
+  dfa_match_data *md,
+  const uschar *this_start_code,
+  const uschar *current_subject,
+  int start_offset,
+  int *offsets,
+  int offsetcount,
+  int *workspace,
+  int wscount,
+  int ims,
+  int  rlevel,
+  int  recursing)
+{
+stateblock *active_states, *new_states, *temp_states;
+stateblock *next_active_state, *next_new_state;
+
+const uschar *ctypes, *lcc, *fcc;
+const uschar *ptr;
+const uschar *end_code, *first_op;
+
+int active_count, new_count, match_count;
+
+/* Some fields in the md block are frequently referenced, so we load them into
+independent variables in the hope that this will perform better. */
+
+const uschar *start_subject = md->start_subject;
+const uschar *end_subject = md->end_subject;
+const uschar *start_code = md->start_code;
+
+#ifdef SUPPORT_UTF8
+BOOL utf8 = (md->poptions & PCRE_UTF8) != 0;
+#else
+BOOL utf8 = FALSE;
+#endif
+
+rlevel++;
+offsetcount &= (-2);
+
+wscount -= 2;
+wscount = (wscount - (wscount % (INTS_PER_STATEBLOCK * 2))) /
+          (2 * INTS_PER_STATEBLOCK);
+
+DPRINTF(("\n%.*s---------------------\n"
+  "%.*sCall to internal_dfa_exec f=%d r=%d\n",
+  rlevel*2-2, SP, rlevel*2-2, SP, rlevel, recursing));
+
+ctypes = md->tables + ctypes_offset;
+lcc = md->tables + lcc_offset;
+fcc = md->tables + fcc_offset;
+
+match_count = PCRE_ERROR_NOMATCH;   /* A negative number */
+
+active_states = (stateblock *)(workspace + 2);
+next_new_state = new_states = active_states + wscount;
+new_count = 0;
+
+first_op = this_start_code + 1 + LINK_SIZE +
+  ((*this_start_code == OP_CBRA || *this_start_code == OP_SCBRA)? 2:0);
+
+/* The first thing in any (sub) pattern is a bracket of some sort. Push all
+the alternative states onto the list, and find out where the end is. This
+makes is possible to use this function recursively, when we want to stop at a
+matching internal ket rather than at the end.
+
+If the first opcode in the first alternative is OP_REVERSE, we are dealing with
+a backward assertion. In that case, we have to find out the maximum amount to
+move back, and set up each alternative appropriately. */
+
+if (*first_op == OP_REVERSE)
+  {
+  int max_back = 0;
+  int gone_back;
+
+  end_code = this_start_code;
+  do
+    {
+    int back = GET(end_code, 2+LINK_SIZE);
+    if (back > max_back) max_back = back;
+    end_code += GET(end_code, 1);
+    }
+  while (*end_code == OP_ALT);
+
+  /* If we can't go back the amount required for the longest lookbehind
+  pattern, go back as far as we can; some alternatives may still be viable. */
+
+#ifdef SUPPORT_UTF8
+  /* In character mode we have to step back character by character */
+
+  if (utf8)
+    {
+    for (gone_back = 0; gone_back < max_back; gone_back++)
+      {
+      if (current_subject <= start_subject) break;
+      current_subject--;
+      while (current_subject > start_subject &&
+             (*current_subject & 0xc0) == 0x80)
+        current_subject--;
+      }
+    }
+  else
+#endif
+
+  /* In byte-mode we can do this quickly. */
+
+    {
+    gone_back = (current_subject - max_back < start_subject)?
+      current_subject - start_subject : max_back;
+    current_subject -= gone_back;
+    }
+
+  /* Now we can process the individual branches. */
+
+  end_code = this_start_code;
+  do
+    {
+    int back = GET(end_code, 2+LINK_SIZE);
+    if (back <= gone_back)
+      {
+      int bstate = end_code - start_code + 2 + 2*LINK_SIZE;
+      ADD_NEW_DATA(-bstate, 0, gone_back - back);
+      }
+    end_code += GET(end_code, 1);
+    }
+  while (*end_code == OP_ALT);
+ }
+
+/* This is the code for a "normal" subpattern (not a backward assertion). The
+start of a whole pattern is always one of these. If we are at the top level,
+we may be asked to restart matching from the same point that we reached for a
+previous partial match. We still have to scan through the top-level branches to
+find the end state. */
+
+else
+  {
+  end_code = this_start_code;
+
+  /* Restarting */
+
+  if (rlevel == 1 && (md->moptions & PCRE_DFA_RESTART) != 0)
+    {
+    do { end_code += GET(end_code, 1); } while (*end_code == OP_ALT);
+    new_count = workspace[1];
+    if (!workspace[0])
+      memcpy(new_states, active_states, new_count * sizeof(stateblock));
+    }
+
+  /* Not restarting */
+
+  else
+    {
+    int length = 1 + LINK_SIZE +
+      ((*this_start_code == OP_CBRA || *this_start_code == OP_SCBRA)? 2:0);
+    do
+      {
+      ADD_NEW(end_code - start_code + length, 0);
+      end_code += GET(end_code, 1);
+      length = 1 + LINK_SIZE;
+      }
+    while (*end_code == OP_ALT);
+    }
+  }
+
+workspace[0] = 0;    /* Bit indicating which vector is current */
+
+DPRINTF(("%.*sEnd state = %d\n", rlevel*2-2, SP, end_code - start_code));
+
+/* Loop for scanning the subject */
+
+ptr = current_subject;
+for (;;)
+  {
+  int i, j;
+  int clen, dlen;
+  unsigned int c, d;
+
+  /* Make the new state list into the active state list and empty the
+  new state list. */
+
+  temp_states = active_states;
+  active_states = new_states;
+  new_states = temp_states;
+  active_count = new_count;
+  new_count = 0;
+
+  workspace[0] ^= 1;              /* Remember for the restarting feature */
+  workspace[1] = active_count;
+
+#ifdef DEBUG
+  printf("%.*sNext character: rest of subject = \"", rlevel*2-2, SP);
+  pchars((uschar *)ptr, strlen((char *)ptr), stdout);
+  printf("\"\n");
+
+  printf("%.*sActive states: ", rlevel*2-2, SP);
+  for (i = 0; i < active_count; i++)
+    printf("%d/%d ", active_states[i].offset, active_states[i].count);
+  printf("\n");
+#endif
+
+  /* Set the pointers for adding new states */
+
+  next_active_state = active_states + active_count;
+  next_new_state = new_states;
+
+  /* Load the current character from the subject outside the loop, as many
+  different states may want to look at it, and we assume that at least one
+  will. */
+
+  if (ptr < end_subject)
+    {
+    clen = 1;        /* Number of bytes in the character */
+#ifdef SUPPORT_UTF8
+    if (utf8) { GETCHARLEN(c, ptr, clen); } else
+#endif  /* SUPPORT_UTF8 */
+    c = *ptr;
+    }
+  else
+    {
+    clen = 0;        /* This indicates the end of the subject */
+    c = NOTACHAR;    /* This value should never actually be used */
+    }
+
+  /* Scan up the active states and act on each one. The result of an action
+  may be to add more states to the currently active list (e.g. on hitting a
+  parenthesis) or it may be to put states on the new list, for considering
+  when we move the character pointer on. */
+
+  for (i = 0; i < active_count; i++)
+    {
+    stateblock *current_state = active_states + i;
+    const uschar *code;
+    int state_offset = current_state->offset;
+    int count, codevalue;
+
+#ifdef DEBUG
+    printf ("%.*sProcessing state %d c=", rlevel*2-2, SP, state_offset);
+    if (clen == 0) printf("EOL\n");
+      else if (c > 32 && c < 127) printf("'%c'\n", c);
+        else printf("0x%02x\n", c);
+#endif
+
+    /* This variable is referred to implicity in the ADD_xxx macros. */
+
+    ims = current_state->ims;
+
+    /* A negative offset is a special case meaning "hold off going to this
+    (negated) state until the number of characters in the data field have
+    been skipped". */
+
+    if (state_offset < 0)
+      {
+      if (current_state->data > 0)
+        {
+        DPRINTF(("%.*sSkipping this character\n", rlevel*2-2, SP));
+        ADD_NEW_DATA(state_offset, current_state->count,
+          current_state->data - 1);
+        continue;
+        }
+      else
+        {
+        current_state->offset = state_offset = -state_offset;
+        }
+      }
+
+    /* Check for a duplicate state with the same count, and skip if found. */
+
+    for (j = 0; j < i; j++)
+      {
+      if (active_states[j].offset == state_offset &&
+          active_states[j].count == current_state->count)
+        {
+        DPRINTF(("%.*sDuplicate state: skipped\n", rlevel*2-2, SP));
+        goto NEXT_ACTIVE_STATE;
+        }
+      }
+
+    /* The state offset is the offset to the opcode */
+
+    code = start_code + state_offset;
+    codevalue = *code;
+
+    /* If this opcode is followed by an inline character, load it. It is
+    tempting to test for the presence of a subject character here, but that
+    is wrong, because sometimes zero repetitions of the subject are
+    permitted.
+
+    We also use this mechanism for opcodes such as OP_TYPEPLUS that take an
+    argument that is not a data character - but is always one byte long. We
+    have to take special action to deal with  \P, \p, \H, \h, \V, \v and \X in
+    this case. To keep the other cases fast, convert these ones to new opcodes.
+    */
+
+    if (coptable[codevalue] > 0)
+      {
+      dlen = 1;
+#ifdef SUPPORT_UTF8
+      if (utf8) { GETCHARLEN(d, (code + coptable[codevalue]), dlen); } else
+#endif  /* SUPPORT_UTF8 */
+      d = code[coptable[codevalue]];
+      if (codevalue >= OP_TYPESTAR)
+        {
+        switch(d)
+          {
+          case OP_ANYBYTE: return PCRE_ERROR_DFA_UITEM;
+          case OP_NOTPROP:
+          case OP_PROP: codevalue += OP_PROP_EXTRA; break;
+          case OP_ANYNL: codevalue += OP_ANYNL_EXTRA; break;
+          case OP_EXTUNI: codevalue += OP_EXTUNI_EXTRA; break;
+          case OP_NOT_HSPACE:
+          case OP_HSPACE: codevalue += OP_HSPACE_EXTRA; break;
+          case OP_NOT_VSPACE:
+          case OP_VSPACE: codevalue += OP_VSPACE_EXTRA; break;
+          default: break;
+          }
+        }
+      }
+    else
+      {
+      dlen = 0;         /* Not strictly necessary, but compilers moan */
+      d = NOTACHAR;     /* if these variables are not set. */
+      }
+
+
+    /* Now process the individual opcodes */
+
+    switch (codevalue)
+      {
+
+/* ========================================================================== */
+      /* Reached a closing bracket. If not at the end of the pattern, carry
+      on with the next opcode. Otherwise, unless we have an empty string and
+      PCRE_NOTEMPTY is set, save the match data, shifting up all previous
+      matches so we always have the longest first. */
+
+      case OP_KET:
+      case OP_KETRMIN:
+      case OP_KETRMAX:
+      if (code != end_code)
+        {
+        ADD_ACTIVE(state_offset + 1 + LINK_SIZE, 0);
+        if (codevalue != OP_KET)
+          {
+          ADD_ACTIVE(state_offset - GET(code, 1), 0);
+          }
+        }
+      else if (ptr > current_subject || (md->moptions & PCRE_NOTEMPTY) == 0)
+        {
+        if (match_count < 0) match_count = (offsetcount >= 2)? 1 : 0;
+          else if (match_count > 0 && ++match_count * 2 >= offsetcount)
+            match_count = 0;
+        count = ((match_count == 0)? offsetcount : match_count * 2) - 2;
+        if (count > 0) memmove(offsets + 2, offsets, count * sizeof(int));
+        if (offsetcount >= 2)
+          {
+          offsets[0] = current_subject - start_subject;
+          offsets[1] = ptr - start_subject;
+          DPRINTF(("%.*sSet matched string = \"%.*s\"\n", rlevel*2-2, SP,
+            offsets[1] - offsets[0], current_subject));
+          }
+        if ((md->moptions & PCRE_DFA_SHORTEST) != 0)
+          {
+          DPRINTF(("%.*sEnd of internal_dfa_exec %d: returning %d\n"
+            "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel,
+            match_count, rlevel*2-2, SP));
+          return match_count;
+          }
+        }
+      break;
+
+/* ========================================================================== */
+      /* These opcodes add to the current list of states without looking
+      at the current character. */
+
+      /*-----------------------------------------------------------------*/
+      case OP_ALT:
+      do { code += GET(code, 1); } while (*code == OP_ALT);
+      ADD_ACTIVE(code - start_code, 0);
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_BRA:
+      case OP_SBRA:
+      do
+        {
+        ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);
+        code += GET(code, 1);
+        }
+      while (*code == OP_ALT);
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_CBRA:
+      case OP_SCBRA:
+      ADD_ACTIVE(code - start_code + 3 + LINK_SIZE,  0);
+      code += GET(code, 1);
+      while (*code == OP_ALT)
+        {
+        ADD_ACTIVE(code - start_code + 1 + LINK_SIZE,  0);
+        code += GET(code, 1);
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_BRAZERO:
+      case OP_BRAMINZERO:
+      ADD_ACTIVE(state_offset + 1, 0);
+      code += 1 + GET(code, 2);
+      while (*code == OP_ALT) code += GET(code, 1);
+      ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_SKIPZERO:
+      code += 1 + GET(code, 2);
+      while (*code == OP_ALT) code += GET(code, 1);
+      ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_CIRC:
+      if ((ptr == start_subject && (md->moptions & PCRE_NOTBOL) == 0) ||
+          ((ims & PCRE_MULTILINE) != 0 &&
+            ptr != end_subject &&
+            WAS_NEWLINE(ptr)))
+        { ADD_ACTIVE(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_EOD:
+      if (ptr >= end_subject) { ADD_ACTIVE(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_OPT:
+      ims = code[1];
+      ADD_ACTIVE(state_offset + 2, 0);
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_SOD:
+      if (ptr == start_subject) { ADD_ACTIVE(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_SOM:
+      if (ptr == start_subject + start_offset) { ADD_ACTIVE(state_offset + 1, 0); }
+      break;
+
+
+/* ========================================================================== */
+      /* These opcodes inspect the next subject character, and sometimes
+      the previous one as well, but do not have an argument. The variable
+      clen contains the length of the current character and is zero if we are
+      at the end of the subject. */
+
+      /*-----------------------------------------------------------------*/
+      case OP_ANY:
+      if (clen > 0 && !IS_NEWLINE(ptr))
+        { ADD_NEW(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_ALLANY:
+      if (clen > 0)
+        { ADD_NEW(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_EODN:
+      if (clen == 0 || (IS_NEWLINE(ptr) && ptr == end_subject - md->nllen))
+        { ADD_ACTIVE(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_DOLL:
+      if ((md->moptions & PCRE_NOTEOL) == 0)
+        {
+        if (clen == 0 ||
+            (IS_NEWLINE(ptr) &&
+               ((ims & PCRE_MULTILINE) != 0 || ptr == end_subject - md->nllen)
+            ))
+          { ADD_ACTIVE(state_offset + 1, 0); }
+        }
+      else if ((ims & PCRE_MULTILINE) != 0 && IS_NEWLINE(ptr))
+        { ADD_ACTIVE(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+
+      case OP_DIGIT:
+      case OP_WHITESPACE:
+      case OP_WORDCHAR:
+      if (clen > 0 && c < 256 &&
+            ((ctypes[c] & toptable1[codevalue]) ^ toptable2[codevalue]) != 0)
+        { ADD_NEW(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_NOT_DIGIT:
+      case OP_NOT_WHITESPACE:
+      case OP_NOT_WORDCHAR:
+      if (clen > 0 && (c >= 256 ||
+            ((ctypes[c] & toptable1[codevalue]) ^ toptable2[codevalue]) != 0))
+        { ADD_NEW(state_offset + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_WORD_BOUNDARY:
+      case OP_NOT_WORD_BOUNDARY:
+        {
+        int left_word, right_word;
+
+        if (ptr > start_subject)
+          {
+          const uschar *temp = ptr - 1;
+#ifdef SUPPORT_UTF8
+          if (utf8) BACKCHAR(temp);
+#endif
+          GETCHARTEST(d, temp);
+          left_word = d < 256 && (ctypes[d] & ctype_word) != 0;
+          }
+        else left_word = 0;
+
+        if (clen > 0) right_word = c < 256 && (ctypes[c] & ctype_word) != 0;
+          else right_word = 0;
+
+        if ((left_word == right_word) == (codevalue == OP_NOT_WORD_BOUNDARY))
+          { ADD_ACTIVE(state_offset + 1, 0); }
+        }
+      break;
+
+
+      /*-----------------------------------------------------------------*/
+      /* Check the next character by Unicode property. We will get here only
+      if the support is in the binary; otherwise a compile-time error occurs.
+      */
+
+#ifdef SUPPORT_UCP
+      case OP_PROP:
+      case OP_NOTPROP:
+      if (clen > 0)
+        {
+        BOOL OK;
+        const ucd_record * prop = GET_UCD(c);
+        switch(code[1])
+          {
+          case PT_ANY:
+          OK = TRUE;
+          break;
+
+          case PT_LAMP:
+          OK = prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || prop->chartype == ucp_Lt;
+          break;
+
+          case PT_GC:
+          OK = _pcre_ucp_gentype[prop->chartype] == code[2];
+          break;
+
+          case PT_PC:
+          OK = prop->chartype == code[2];
+          break;
+
+          case PT_SC:
+          OK = prop->script == code[2];
+          break;
+
+          /* Should never occur, but keep compilers from grumbling. */
+
+          default:
+          OK = codevalue != OP_PROP;
+          break;
+          }
+
+        if (OK == (codevalue == OP_PROP)) { ADD_NEW(state_offset + 3, 0); }
+        }
+      break;
+#endif
+
+
+
+/* ========================================================================== */
+      /* These opcodes likewise inspect the subject character, but have an
+      argument that is not a data character. It is one of these opcodes:
+      OP_ANY, OP_ALLANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE,
+      OP_WORDCHAR, OP_NOT_WORDCHAR. The value is loaded into d. */
+
+      case OP_TYPEPLUS:
+      case OP_TYPEMINPLUS:
+      case OP_TYPEPOSPLUS:
+      count = current_state->count;  /* Already matched */
+      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
+      if (clen > 0)
+        {
+        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
+            (c < 256 &&
+              (d != OP_ANY || !IS_NEWLINE(ptr)) &&
+              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
+          {
+          if (count > 0 && codevalue == OP_TYPEPOSPLUS)
+            {
+            active_count--;            /* Remove non-match possibility */
+            next_active_state--;
+            }
+          count++;
+          ADD_NEW(state_offset, count);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_TYPEQUERY:
+      case OP_TYPEMINQUERY:
+      case OP_TYPEPOSQUERY:
+      ADD_ACTIVE(state_offset + 2, 0);
+      if (clen > 0)
+        {
+        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
+            (c < 256 &&
+              (d != OP_ANY || !IS_NEWLINE(ptr)) &&
+              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
+          {
+          if (codevalue == OP_TYPEPOSQUERY)
+            {
+            active_count--;            /* Remove non-match possibility */
+            next_active_state--;
+            }
+          ADD_NEW(state_offset + 2, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_TYPESTAR:
+      case OP_TYPEMINSTAR:
+      case OP_TYPEPOSSTAR:
+      ADD_ACTIVE(state_offset + 2, 0);
+      if (clen > 0)
+        {
+        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
+            (c < 256 &&
+              (d != OP_ANY || !IS_NEWLINE(ptr)) &&
+              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
+          {
+          if (codevalue == OP_TYPEPOSSTAR)
+            {
+            active_count--;            /* Remove non-match possibility */
+            next_active_state--;
+            }
+          ADD_NEW(state_offset, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_TYPEEXACT:
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0)
+        {
+        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
+            (c < 256 &&
+              (d != OP_ANY || !IS_NEWLINE(ptr)) &&
+              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
+          {
+          if (++count >= GET2(code, 1))
+            { ADD_NEW(state_offset + 4, 0); }
+          else
+            { ADD_NEW(state_offset, count); }
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_TYPEUPTO:
+      case OP_TYPEMINUPTO:
+      case OP_TYPEPOSUPTO:
+      ADD_ACTIVE(state_offset + 4, 0);
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0)
+        {
+        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
+            (c < 256 &&
+              (d != OP_ANY || !IS_NEWLINE(ptr)) &&
+              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
+          {
+          if (codevalue == OP_TYPEPOSUPTO)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          if (++count >= GET2(code, 1))
+            { ADD_NEW(state_offset + 4, 0); }
+          else
+            { ADD_NEW(state_offset, count); }
+          }
+        }
+      break;
+
+/* ========================================================================== */
+      /* These are virtual opcodes that are used when something like
+      OP_TYPEPLUS has OP_PROP, OP_NOTPROP, OP_ANYNL, or OP_EXTUNI as its
+      argument. It keeps the code above fast for the other cases. The argument
+      is in the d variable. */
+
+#ifdef SUPPORT_UCP
+      case OP_PROP_EXTRA + OP_TYPEPLUS:
+      case OP_PROP_EXTRA + OP_TYPEMINPLUS:
+      case OP_PROP_EXTRA + OP_TYPEPOSPLUS:
+      count = current_state->count;           /* Already matched */
+      if (count > 0) { ADD_ACTIVE(state_offset + 4, 0); }
+      if (clen > 0)
+        {
+        BOOL OK;
+        const ucd_record * prop = GET_UCD(c);
+        switch(code[2])
+          {
+          case PT_ANY:
+          OK = TRUE;
+          break;
+
+          case PT_LAMP:
+          OK = prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || prop->chartype == ucp_Lt;
+          break;
+
+          case PT_GC:
+          OK = _pcre_ucp_gentype[prop->chartype] == code[3];
+          break;
+
+          case PT_PC:
+          OK = prop->chartype == code[3];
+          break;
+
+          case PT_SC:
+          OK = prop->script == code[3];
+          break;
+
+          /* Should never occur, but keep compilers from grumbling. */
+
+          default:
+          OK = codevalue != OP_PROP;
+          break;
+          }
+
+        if (OK == (d == OP_PROP))
+          {
+          if (count > 0 && codevalue == OP_PROP_EXTRA + OP_TYPEPOSPLUS)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          count++;
+          ADD_NEW(state_offset, count);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_EXTUNI_EXTRA + OP_TYPEPLUS:
+      case OP_EXTUNI_EXTRA + OP_TYPEMINPLUS:
+      case OP_EXTUNI_EXTRA + OP_TYPEPOSPLUS:
+      count = current_state->count;  /* Already matched */
+      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
+      if (clen > 0 && UCD_CATEGORY(c) != ucp_M)
+        {
+        const uschar *nptr = ptr + clen;
+        int ncount = 0;
+        if (count > 0 && codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSPLUS)
+          {
+          active_count--;           /* Remove non-match possibility */
+          next_active_state--;
+          }
+        while (nptr < end_subject)
+          {
+          int nd;
+          int ndlen = 1;
+          GETCHARLEN(nd, nptr, ndlen);
+          if (UCD_CATEGORY(nd) != ucp_M) break;
+          ncount++;
+          nptr += ndlen;
+          }
+        count++;
+        ADD_NEW_DATA(-state_offset, count, ncount);
+        }
+      break;
+#endif
+
+      /*-----------------------------------------------------------------*/
+      case OP_ANYNL_EXTRA + OP_TYPEPLUS:
+      case OP_ANYNL_EXTRA + OP_TYPEMINPLUS:
+      case OP_ANYNL_EXTRA + OP_TYPEPOSPLUS:
+      count = current_state->count;  /* Already matched */
+      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
+      if (clen > 0)
+        {
+        int ncount = 0;
+        switch (c)
+          {
+          case 0x000b:
+          case 0x000c:
+          case 0x0085:
+          case 0x2028:
+          case 0x2029:
+          if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
+          goto ANYNL01;
+
+          case 0x000d:
+          if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
+          /* Fall through */
+
+          ANYNL01:
+          case 0x000a:
+          if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          count++;
+          ADD_NEW_DATA(-state_offset, count, ncount);
+          break;
+
+          default:
+          break;
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_VSPACE_EXTRA + OP_TYPEPLUS:
+      case OP_VSPACE_EXTRA + OP_TYPEMINPLUS:
+      case OP_VSPACE_EXTRA + OP_TYPEPOSPLUS:
+      count = current_state->count;  /* Already matched */
+      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
+      if (clen > 0)
+        {
+        BOOL OK;
+        switch (c)
+          {
+          case 0x000a:
+          case 0x000b:
+          case 0x000c:
+          case 0x000d:
+          case 0x0085:
+          case 0x2028:
+          case 0x2029:
+          OK = TRUE;
+          break;
+
+          default:
+          OK = FALSE;
+          break;
+          }
+
+        if (OK == (d == OP_VSPACE))
+          {
+          if (count > 0 && codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSPLUS)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          count++;
+          ADD_NEW_DATA(-state_offset, count, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_HSPACE_EXTRA + OP_TYPEPLUS:
+      case OP_HSPACE_EXTRA + OP_TYPEMINPLUS:
+      case OP_HSPACE_EXTRA + OP_TYPEPOSPLUS:
+      count = current_state->count;  /* Already matched */
+      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }
+      if (clen > 0)
+        {
+        BOOL OK;
+        switch (c)
+          {
+          case 0x09:      /* HT */
+          case 0x20:      /* SPACE */
+          case 0xa0:      /* NBSP */
+          case 0x1680:    /* OGHAM SPACE MARK */
+          case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+          case 0x2000:    /* EN QUAD */
+          case 0x2001:    /* EM QUAD */
+          case 0x2002:    /* EN SPACE */
+          case 0x2003:    /* EM SPACE */
+          case 0x2004:    /* THREE-PER-EM SPACE */
+          case 0x2005:    /* FOUR-PER-EM SPACE */
+          case 0x2006:    /* SIX-PER-EM SPACE */
+          case 0x2007:    /* FIGURE SPACE */
+          case 0x2008:    /* PUNCTUATION SPACE */
+          case 0x2009:    /* THIN SPACE */
+          case 0x200A:    /* HAIR SPACE */
+          case 0x202f:    /* NARROW NO-BREAK SPACE */
+          case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+          case 0x3000:    /* IDEOGRAPHIC SPACE */
+          OK = TRUE;
+          break;
+
+          default:
+          OK = FALSE;
+          break;
+          }
+
+        if (OK == (d == OP_HSPACE))
+          {
+          if (count > 0 && codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSPLUS)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          count++;
+          ADD_NEW_DATA(-state_offset, count, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+#ifdef SUPPORT_UCP
+      case OP_PROP_EXTRA + OP_TYPEQUERY:
+      case OP_PROP_EXTRA + OP_TYPEMINQUERY:
+      case OP_PROP_EXTRA + OP_TYPEPOSQUERY:
+      count = 4;
+      goto QS1;
+
+      case OP_PROP_EXTRA + OP_TYPESTAR:
+      case OP_PROP_EXTRA + OP_TYPEMINSTAR:
+      case OP_PROP_EXTRA + OP_TYPEPOSSTAR:
+      count = 0;
+
+      QS1:
+
+      ADD_ACTIVE(state_offset + 4, 0);
+      if (clen > 0)
+        {
+        BOOL OK;
+        const ucd_record * prop = GET_UCD(c);
+        switch(code[2])
+          {
+          case PT_ANY:
+          OK = TRUE;
+          break;
+
+          case PT_LAMP:
+          OK = prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || prop->chartype == ucp_Lt;
+          break;
+
+          case PT_GC:
+          OK = _pcre_ucp_gentype[prop->chartype] == code[3];
+          break;
+
+          case PT_PC:
+          OK = prop->chartype == code[3];
+          break;
+
+          case PT_SC:
+          OK = prop->script == code[3];
+          break;
+
+          /* Should never occur, but keep compilers from grumbling. */
+
+          default:
+          OK = codevalue != OP_PROP;
+          break;
+          }
+
+        if (OK == (d == OP_PROP))
+          {
+          if (codevalue == OP_PROP_EXTRA + OP_TYPEPOSSTAR ||
+              codevalue == OP_PROP_EXTRA + OP_TYPEPOSQUERY)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          ADD_NEW(state_offset + count, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_EXTUNI_EXTRA + OP_TYPEQUERY:
+      case OP_EXTUNI_EXTRA + OP_TYPEMINQUERY:
+      case OP_EXTUNI_EXTRA + OP_TYPEPOSQUERY:
+      count = 2;
+      goto QS2;
+
+      case OP_EXTUNI_EXTRA + OP_TYPESTAR:
+      case OP_EXTUNI_EXTRA + OP_TYPEMINSTAR:
+      case OP_EXTUNI_EXTRA + OP_TYPEPOSSTAR:
+      count = 0;
+
+      QS2:
+
+      ADD_ACTIVE(state_offset + 2, 0);
+      if (clen > 0 && UCD_CATEGORY(c) != ucp_M)
+        {
+        const uschar *nptr = ptr + clen;
+        int ncount = 0;
+        if (codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSSTAR ||
+            codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSQUERY)
+          {
+          active_count--;           /* Remove non-match possibility */
+          next_active_state--;
+          }
+        while (nptr < end_subject)
+          {
+          int nd;
+          int ndlen = 1;
+          GETCHARLEN(nd, nptr, ndlen);
+          if (UCD_CATEGORY(nd) != ucp_M) break;
+          ncount++;
+          nptr += ndlen;
+          }
+        ADD_NEW_DATA(-(state_offset + count), 0, ncount);
+        }
+      break;
+#endif
+
+      /*-----------------------------------------------------------------*/
+      case OP_ANYNL_EXTRA + OP_TYPEQUERY:
+      case OP_ANYNL_EXTRA + OP_TYPEMINQUERY:
+      case OP_ANYNL_EXTRA + OP_TYPEPOSQUERY:
+      count = 2;
+      goto QS3;
+
+      case OP_ANYNL_EXTRA + OP_TYPESTAR:
+      case OP_ANYNL_EXTRA + OP_TYPEMINSTAR:
+      case OP_ANYNL_EXTRA + OP_TYPEPOSSTAR:
+      count = 0;
+
+      QS3:
+      ADD_ACTIVE(state_offset + 2, 0);
+      if (clen > 0)
+        {
+        int ncount = 0;
+        switch (c)
+          {
+          case 0x000b:
+          case 0x000c:
+          case 0x0085:
+          case 0x2028:
+          case 0x2029:
+          if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
+          goto ANYNL02;
+
+          case 0x000d:
+          if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
+          /* Fall through */
+
+          ANYNL02:
+          case 0x000a:
+          if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR ||
+              codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          ADD_NEW_DATA(-(state_offset + count), 0, ncount);
+          break;
+
+          default:
+          break;
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_VSPACE_EXTRA + OP_TYPEQUERY:
+      case OP_VSPACE_EXTRA + OP_TYPEMINQUERY:
+      case OP_VSPACE_EXTRA + OP_TYPEPOSQUERY:
+      count = 2;
+      goto QS4;
+
+      case OP_VSPACE_EXTRA + OP_TYPESTAR:
+      case OP_VSPACE_EXTRA + OP_TYPEMINSTAR:
+      case OP_VSPACE_EXTRA + OP_TYPEPOSSTAR:
+      count = 0;
+
+      QS4:
+      ADD_ACTIVE(state_offset + 2, 0);
+      if (clen > 0)
+        {
+        BOOL OK;
+        switch (c)
+          {
+          case 0x000a:
+          case 0x000b:
+          case 0x000c:
+          case 0x000d:
+          case 0x0085:
+          case 0x2028:
+          case 0x2029:
+          OK = TRUE;
+          break;
+
+          default:
+          OK = FALSE;
+          break;
+          }
+        if (OK == (d == OP_VSPACE))
+          {
+          if (codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSSTAR ||
+              codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSQUERY)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          ADD_NEW_DATA(-(state_offset + count), 0, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_HSPACE_EXTRA + OP_TYPEQUERY:
+      case OP_HSPACE_EXTRA + OP_TYPEMINQUERY:
+      case OP_HSPACE_EXTRA + OP_TYPEPOSQUERY:
+      count = 2;
+      goto QS5;
+
+      case OP_HSPACE_EXTRA + OP_TYPESTAR:
+      case OP_HSPACE_EXTRA + OP_TYPEMINSTAR:
+      case OP_HSPACE_EXTRA + OP_TYPEPOSSTAR:
+      count = 0;
+
+      QS5:
+      ADD_ACTIVE(state_offset + 2, 0);
+      if (clen > 0)
+        {
+        BOOL OK;
+        switch (c)
+          {
+          case 0x09:      /* HT */
+          case 0x20:      /* SPACE */
+          case 0xa0:      /* NBSP */
+          case 0x1680:    /* OGHAM SPACE MARK */
+          case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+          case 0x2000:    /* EN QUAD */
+          case 0x2001:    /* EM QUAD */
+          case 0x2002:    /* EN SPACE */
+          case 0x2003:    /* EM SPACE */
+          case 0x2004:    /* THREE-PER-EM SPACE */
+          case 0x2005:    /* FOUR-PER-EM SPACE */
+          case 0x2006:    /* SIX-PER-EM SPACE */
+          case 0x2007:    /* FIGURE SPACE */
+          case 0x2008:    /* PUNCTUATION SPACE */
+          case 0x2009:    /* THIN SPACE */
+          case 0x200A:    /* HAIR SPACE */
+          case 0x202f:    /* NARROW NO-BREAK SPACE */
+          case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+          case 0x3000:    /* IDEOGRAPHIC SPACE */
+          OK = TRUE;
+          break;
+
+          default:
+          OK = FALSE;
+          break;
+          }
+
+        if (OK == (d == OP_HSPACE))
+          {
+          if (codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSSTAR ||
+              codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSQUERY)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          ADD_NEW_DATA(-(state_offset + count), 0, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+#ifdef SUPPORT_UCP
+      case OP_PROP_EXTRA + OP_TYPEEXACT:
+      case OP_PROP_EXTRA + OP_TYPEUPTO:
+      case OP_PROP_EXTRA + OP_TYPEMINUPTO:
+      case OP_PROP_EXTRA + OP_TYPEPOSUPTO:
+      if (codevalue != OP_PROP_EXTRA + OP_TYPEEXACT)
+        { ADD_ACTIVE(state_offset + 6, 0); }
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0)
+        {
+        BOOL OK;
+        const ucd_record * prop = GET_UCD(c);
+        switch(code[4])
+          {
+          case PT_ANY:
+          OK = TRUE;
+          break;
+
+          case PT_LAMP:
+          OK = prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || prop->chartype == ucp_Lt;
+          break;
+
+          case PT_GC:
+          OK = _pcre_ucp_gentype[prop->chartype] == code[5];
+          break;
+
+          case PT_PC:
+          OK = prop->chartype == code[5];
+          break;
+
+          case PT_SC:
+          OK = prop->script == code[5];
+          break;
+
+          /* Should never occur, but keep compilers from grumbling. */
+
+          default:
+          OK = codevalue != OP_PROP;
+          break;
+          }
+
+        if (OK == (d == OP_PROP))
+          {
+          if (codevalue == OP_PROP_EXTRA + OP_TYPEPOSUPTO)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          if (++count >= GET2(code, 1))
+            { ADD_NEW(state_offset + 6, 0); }
+          else
+            { ADD_NEW(state_offset, count); }
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_EXTUNI_EXTRA + OP_TYPEEXACT:
+      case OP_EXTUNI_EXTRA + OP_TYPEUPTO:
+      case OP_EXTUNI_EXTRA + OP_TYPEMINUPTO:
+      case OP_EXTUNI_EXTRA + OP_TYPEPOSUPTO:
+      if (codevalue != OP_EXTUNI_EXTRA + OP_TYPEEXACT)
+        { ADD_ACTIVE(state_offset + 4, 0); }
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0 && UCD_CATEGORY(c) != ucp_M)
+        {
+        const uschar *nptr = ptr + clen;
+        int ncount = 0;
+        if (codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSUPTO)
+          {
+          active_count--;           /* Remove non-match possibility */
+          next_active_state--;
+          }
+        while (nptr < end_subject)
+          {
+          int nd;
+          int ndlen = 1;
+          GETCHARLEN(nd, nptr, ndlen);
+          if (UCD_CATEGORY(nd) != ucp_M) break;
+          ncount++;
+          nptr += ndlen;
+          }
+        if (++count >= GET2(code, 1))
+          { ADD_NEW_DATA(-(state_offset + 4), 0, ncount); }
+        else
+          { ADD_NEW_DATA(-state_offset, count, ncount); }
+        }
+      break;
+#endif
+
+      /*-----------------------------------------------------------------*/
+      case OP_ANYNL_EXTRA + OP_TYPEEXACT:
+      case OP_ANYNL_EXTRA + OP_TYPEUPTO:
+      case OP_ANYNL_EXTRA + OP_TYPEMINUPTO:
+      case OP_ANYNL_EXTRA + OP_TYPEPOSUPTO:
+      if (codevalue != OP_ANYNL_EXTRA + OP_TYPEEXACT)
+        { ADD_ACTIVE(state_offset + 4, 0); }
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0)
+        {
+        int ncount = 0;
+        switch (c)
+          {
+          case 0x000b:
+          case 0x000c:
+          case 0x0085:
+          case 0x2028:
+          case 0x2029:
+          if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
+          goto ANYNL03;
+
+          case 0x000d:
+          if (ptr + 1 < end_subject && ptr[1] == 0x0a) ncount = 1;
+          /* Fall through */
+
+          ANYNL03:
+          case 0x000a:
+          if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          if (++count >= GET2(code, 1))
+            { ADD_NEW_DATA(-(state_offset + 4), 0, ncount); }
+          else
+            { ADD_NEW_DATA(-state_offset, count, ncount); }
+          break;
+
+          default:
+          break;
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_VSPACE_EXTRA + OP_TYPEEXACT:
+      case OP_VSPACE_EXTRA + OP_TYPEUPTO:
+      case OP_VSPACE_EXTRA + OP_TYPEMINUPTO:
+      case OP_VSPACE_EXTRA + OP_TYPEPOSUPTO:
+      if (codevalue != OP_VSPACE_EXTRA + OP_TYPEEXACT)
+        { ADD_ACTIVE(state_offset + 4, 0); }
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0)
+        {
+        BOOL OK;
+        switch (c)
+          {
+          case 0x000a:
+          case 0x000b:
+          case 0x000c:
+          case 0x000d:
+          case 0x0085:
+          case 0x2028:
+          case 0x2029:
+          OK = TRUE;
+          break;
+
+          default:
+          OK = FALSE;
+          }
+
+        if (OK == (d == OP_VSPACE))
+          {
+          if (codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSUPTO)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          if (++count >= GET2(code, 1))
+            { ADD_NEW_DATA(-(state_offset + 4), 0, 0); }
+          else
+            { ADD_NEW_DATA(-state_offset, count, 0); }
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_HSPACE_EXTRA + OP_TYPEEXACT:
+      case OP_HSPACE_EXTRA + OP_TYPEUPTO:
+      case OP_HSPACE_EXTRA + OP_TYPEMINUPTO:
+      case OP_HSPACE_EXTRA + OP_TYPEPOSUPTO:
+      if (codevalue != OP_HSPACE_EXTRA + OP_TYPEEXACT)
+        { ADD_ACTIVE(state_offset + 4, 0); }
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0)
+        {
+        BOOL OK;
+        switch (c)
+          {
+          case 0x09:      /* HT */
+          case 0x20:      /* SPACE */
+          case 0xa0:      /* NBSP */
+          case 0x1680:    /* OGHAM SPACE MARK */
+          case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+          case 0x2000:    /* EN QUAD */
+          case 0x2001:    /* EM QUAD */
+          case 0x2002:    /* EN SPACE */
+          case 0x2003:    /* EM SPACE */
+          case 0x2004:    /* THREE-PER-EM SPACE */
+          case 0x2005:    /* FOUR-PER-EM SPACE */
+          case 0x2006:    /* SIX-PER-EM SPACE */
+          case 0x2007:    /* FIGURE SPACE */
+          case 0x2008:    /* PUNCTUATION SPACE */
+          case 0x2009:    /* THIN SPACE */
+          case 0x200A:    /* HAIR SPACE */
+          case 0x202f:    /* NARROW NO-BREAK SPACE */
+          case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+          case 0x3000:    /* IDEOGRAPHIC SPACE */
+          OK = TRUE;
+          break;
+
+          default:
+          OK = FALSE;
+          break;
+          }
+
+        if (OK == (d == OP_HSPACE))
+          {
+          if (codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSUPTO)
+            {
+            active_count--;           /* Remove non-match possibility */
+            next_active_state--;
+            }
+          if (++count >= GET2(code, 1))
+            { ADD_NEW_DATA(-(state_offset + 4), 0, 0); }
+          else
+            { ADD_NEW_DATA(-state_offset, count, 0); }
+          }
+        }
+      break;
+
+/* ========================================================================== */
+      /* These opcodes are followed by a character that is usually compared
+      to the current subject character; it is loaded into d. We still get
+      here even if there is no subject character, because in some cases zero
+      repetitions are permitted. */
+
+      /*-----------------------------------------------------------------*/
+      case OP_CHAR:
+      if (clen > 0 && c == d) { ADD_NEW(state_offset + dlen + 1, 0); }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_CHARNC:
+      if (clen == 0) break;
+
+#ifdef SUPPORT_UTF8
+      if (utf8)
+        {
+        if (c == d) { ADD_NEW(state_offset + dlen + 1, 0); } else
+          {
+          unsigned int othercase;
+          if (c < 128) othercase = fcc[c]; else
+
+          /* If we have Unicode property support, we can use it to test the
+          other case of the character. */
+
+#ifdef SUPPORT_UCP
+          othercase = UCD_OTHERCASE(c);
+#else
+          othercase = NOTACHAR;
+#endif
+
+          if (d == othercase) { ADD_NEW(state_offset + dlen + 1, 0); }
+          }
+        }
+      else
+#endif  /* SUPPORT_UTF8 */
+
+      /* Non-UTF-8 mode */
+        {
+        if (lcc[c] == lcc[d]) { ADD_NEW(state_offset + 2, 0); }
+        }
+      break;
+
+
+#ifdef SUPPORT_UCP
+      /*-----------------------------------------------------------------*/
+      /* This is a tricky one because it can match more than one character.
+      Find out how many characters to skip, and then set up a negative state
+      to wait for them to pass before continuing. */
+
+      case OP_EXTUNI:
+      if (clen > 0 && UCD_CATEGORY(c) != ucp_M)
+        {
+        const uschar *nptr = ptr + clen;
+        int ncount = 0;
+        while (nptr < end_subject)
+          {
+          int nclen = 1;
+          GETCHARLEN(c, nptr, nclen);
+          if (UCD_CATEGORY(c) != ucp_M) break;
+          ncount++;
+          nptr += nclen;
+          }
+        ADD_NEW_DATA(-(state_offset + 1), 0, ncount);
+        }
+      break;
+#endif
+
+      /*-----------------------------------------------------------------*/
+      /* This is a tricky like EXTUNI because it too can match more than one
+      character (when CR is followed by LF). In this case, set up a negative
+      state to wait for one character to pass before continuing. */
+
+      case OP_ANYNL:
+      if (clen > 0) switch(c)
+        {
+        case 0x000b:
+        case 0x000c:
+        case 0x0085:
+        case 0x2028:
+        case 0x2029:
+        if ((md->moptions & PCRE_BSR_ANYCRLF) != 0) break;
+
+        case 0x000a:
+        ADD_NEW(state_offset + 1, 0);
+        break;
+
+        case 0x000d:
+        if (ptr + 1 < end_subject && ptr[1] == 0x0a)
+          {
+          ADD_NEW_DATA(-(state_offset + 1), 0, 1);
+          }
+        else
+          {
+          ADD_NEW(state_offset + 1, 0);
+          }
+        break;
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_NOT_VSPACE:
+      if (clen > 0) switch(c)
+        {
+        case 0x000a:
+        case 0x000b:
+        case 0x000c:
+        case 0x000d:
+        case 0x0085:
+        case 0x2028:
+        case 0x2029:
+        break;
+
+        default:
+        ADD_NEW(state_offset + 1, 0);
+        break;
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_VSPACE:
+      if (clen > 0) switch(c)
+        {
+        case 0x000a:
+        case 0x000b:
+        case 0x000c:
+        case 0x000d:
+        case 0x0085:
+        case 0x2028:
+        case 0x2029:
+        ADD_NEW(state_offset + 1, 0);
+        break;
+
+        default: break;
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_NOT_HSPACE:
+      if (clen > 0) switch(c)
+        {
+        case 0x09:      /* HT */
+        case 0x20:      /* SPACE */
+        case 0xa0:      /* NBSP */
+        case 0x1680:    /* OGHAM SPACE MARK */
+        case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+        case 0x2000:    /* EN QUAD */
+        case 0x2001:    /* EM QUAD */
+        case 0x2002:    /* EN SPACE */
+        case 0x2003:    /* EM SPACE */
+        case 0x2004:    /* THREE-PER-EM SPACE */
+        case 0x2005:    /* FOUR-PER-EM SPACE */
+        case 0x2006:    /* SIX-PER-EM SPACE */
+        case 0x2007:    /* FIGURE SPACE */
+        case 0x2008:    /* PUNCTUATION SPACE */
+        case 0x2009:    /* THIN SPACE */
+        case 0x200A:    /* HAIR SPACE */
+        case 0x202f:    /* NARROW NO-BREAK SPACE */
+        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+        case 0x3000:    /* IDEOGRAPHIC SPACE */
+        break;
+
+        default:
+        ADD_NEW(state_offset + 1, 0);
+        break;
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_HSPACE:
+      if (clen > 0) switch(c)
+        {
+        case 0x09:      /* HT */
+        case 0x20:      /* SPACE */
+        case 0xa0:      /* NBSP */
+        case 0x1680:    /* OGHAM SPACE MARK */
+        case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+        case 0x2000:    /* EN QUAD */
+        case 0x2001:    /* EM QUAD */
+        case 0x2002:    /* EN SPACE */
+        case 0x2003:    /* EM SPACE */
+        case 0x2004:    /* THREE-PER-EM SPACE */
+        case 0x2005:    /* FOUR-PER-EM SPACE */
+        case 0x2006:    /* SIX-PER-EM SPACE */
+        case 0x2007:    /* FIGURE SPACE */
+        case 0x2008:    /* PUNCTUATION SPACE */
+        case 0x2009:    /* THIN SPACE */
+        case 0x200A:    /* HAIR SPACE */
+        case 0x202f:    /* NARROW NO-BREAK SPACE */
+        case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+        case 0x3000:    /* IDEOGRAPHIC SPACE */
+        ADD_NEW(state_offset + 1, 0);
+        break;
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      /* Match a negated single character. This is only used for one-byte
+      characters, that is, we know that d < 256. The character we are
+      checking (c) can be multibyte. */
+
+      case OP_NOT:
+      if (clen > 0)
+        {
+        unsigned int otherd = ((ims & PCRE_CASELESS) != 0)? fcc[d] : d;
+        if (c != d && c != otherd) { ADD_NEW(state_offset + dlen + 1, 0); }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_PLUS:
+      case OP_MINPLUS:
+      case OP_POSPLUS:
+      case OP_NOTPLUS:
+      case OP_NOTMINPLUS:
+      case OP_NOTPOSPLUS:
+      count = current_state->count;  /* Already matched */
+      if (count > 0) { ADD_ACTIVE(state_offset + dlen + 1, 0); }
+      if (clen > 0)
+        {
+        unsigned int otherd = NOTACHAR;
+        if ((ims & PCRE_CASELESS) != 0)
+          {
+#ifdef SUPPORT_UTF8
+          if (utf8 && d >= 128)
+            {
+#ifdef SUPPORT_UCP
+            otherd = UCD_OTHERCASE(d);
+#endif  /* SUPPORT_UCP */
+            }
+          else
+#endif  /* SUPPORT_UTF8 */
+          otherd = fcc[d];
+          }
+        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))
+          {
+          if (count > 0 &&
+              (codevalue == OP_POSPLUS || codevalue == OP_NOTPOSPLUS))
+            {
+            active_count--;             /* Remove non-match possibility */
+            next_active_state--;
+            }
+          count++;
+          ADD_NEW(state_offset, count);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_QUERY:
+      case OP_MINQUERY:
+      case OP_POSQUERY:
+      case OP_NOTQUERY:
+      case OP_NOTMINQUERY:
+      case OP_NOTPOSQUERY:
+      ADD_ACTIVE(state_offset + dlen + 1, 0);
+      if (clen > 0)
+        {
+        unsigned int otherd = NOTACHAR;
+        if ((ims & PCRE_CASELESS) != 0)
+          {
+#ifdef SUPPORT_UTF8
+          if (utf8 && d >= 128)
+            {
+#ifdef SUPPORT_UCP
+            otherd = UCD_OTHERCASE(d);
+#endif  /* SUPPORT_UCP */
+            }
+          else
+#endif  /* SUPPORT_UTF8 */
+          otherd = fcc[d];
+          }
+        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))
+          {
+          if (codevalue == OP_POSQUERY || codevalue == OP_NOTPOSQUERY)
+            {
+            active_count--;            /* Remove non-match possibility */
+            next_active_state--;
+            }
+          ADD_NEW(state_offset + dlen + 1, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_STAR:
+      case OP_MINSTAR:
+      case OP_POSSTAR:
+      case OP_NOTSTAR:
+      case OP_NOTMINSTAR:
+      case OP_NOTPOSSTAR:
+      ADD_ACTIVE(state_offset + dlen + 1, 0);
+      if (clen > 0)
+        {
+        unsigned int otherd = NOTACHAR;
+        if ((ims & PCRE_CASELESS) != 0)
+          {
+#ifdef SUPPORT_UTF8
+          if (utf8 && d >= 128)
+            {
+#ifdef SUPPORT_UCP
+            otherd = UCD_OTHERCASE(d);
+#endif  /* SUPPORT_UCP */
+            }
+          else
+#endif  /* SUPPORT_UTF8 */
+          otherd = fcc[d];
+          }
+        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))
+          {
+          if (codevalue == OP_POSSTAR || codevalue == OP_NOTPOSSTAR)
+            {
+            active_count--;            /* Remove non-match possibility */
+            next_active_state--;
+            }
+          ADD_NEW(state_offset, 0);
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_EXACT:
+      case OP_NOTEXACT:
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0)
+        {
+        unsigned int otherd = NOTACHAR;
+        if ((ims & PCRE_CASELESS) != 0)
+          {
+#ifdef SUPPORT_UTF8
+          if (utf8 && d >= 128)
+            {
+#ifdef SUPPORT_UCP
+            otherd = UCD_OTHERCASE(d);
+#endif  /* SUPPORT_UCP */
+            }
+          else
+#endif  /* SUPPORT_UTF8 */
+          otherd = fcc[d];
+          }
+        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))
+          {
+          if (++count >= GET2(code, 1))
+            { ADD_NEW(state_offset + dlen + 3, 0); }
+          else
+            { ADD_NEW(state_offset, count); }
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_UPTO:
+      case OP_MINUPTO:
+      case OP_POSUPTO:
+      case OP_NOTUPTO:
+      case OP_NOTMINUPTO:
+      case OP_NOTPOSUPTO:
+      ADD_ACTIVE(state_offset + dlen + 3, 0);
+      count = current_state->count;  /* Number already matched */
+      if (clen > 0)
+        {
+        unsigned int otherd = NOTACHAR;
+        if ((ims & PCRE_CASELESS) != 0)
+          {
+#ifdef SUPPORT_UTF8
+          if (utf8 && d >= 128)
+            {
+#ifdef SUPPORT_UCP
+            otherd = UCD_OTHERCASE(d);
+#endif  /* SUPPORT_UCP */
+            }
+          else
+#endif  /* SUPPORT_UTF8 */
+          otherd = fcc[d];
+          }
+        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))
+          {
+          if (codevalue == OP_POSUPTO || codevalue == OP_NOTPOSUPTO)
+            {
+            active_count--;             /* Remove non-match possibility */
+            next_active_state--;
+            }
+          if (++count >= GET2(code, 1))
+            { ADD_NEW(state_offset + dlen + 3, 0); }
+          else
+            { ADD_NEW(state_offset, count); }
+          }
+        }
+      break;
+
+
+/* ========================================================================== */
+      /* These are the class-handling opcodes */
+
+      case OP_CLASS:
+      case OP_NCLASS:
+      case OP_XCLASS:
+        {
+        BOOL isinclass = FALSE;
+        int next_state_offset;
+        const uschar *ecode;
+
+        /* For a simple class, there is always just a 32-byte table, and we
+        can set isinclass from it. */
+
+        if (codevalue != OP_XCLASS)
+          {
+          ecode = code + 33;
+          if (clen > 0)
+            {
+            isinclass = (c > 255)? (codevalue == OP_NCLASS) :
+              ((code[1 + c/8] & (1 << (c&7))) != 0);
+            }
+          }
+
+        /* An extended class may have a table or a list of single characters,
+        ranges, or both, and it may be positive or negative. There's a
+        function that sorts all this out. */
+
+        else
+         {
+         ecode = code + GET(code, 1);
+         if (clen > 0) isinclass = _pcre_xclass(c, code + 1 + LINK_SIZE);
+         }
+
+        /* At this point, isinclass is set for all kinds of class, and ecode
+        points to the byte after the end of the class. If there is a
+        quantifier, this is where it will be. */
+
+        next_state_offset = ecode - start_code;
+
+        switch (*ecode)
+          {
+          case OP_CRSTAR:
+          case OP_CRMINSTAR:
+          ADD_ACTIVE(next_state_offset + 1, 0);
+          if (isinclass) { ADD_NEW(state_offset, 0); }
+          break;
+
+          case OP_CRPLUS:
+          case OP_CRMINPLUS:
+          count = current_state->count;  /* Already matched */
+          if (count > 0) { ADD_ACTIVE(next_state_offset + 1, 0); }
+          if (isinclass) { count++; ADD_NEW(state_offset, count); }
+          break;
+
+          case OP_CRQUERY:
+          case OP_CRMINQUERY:
+          ADD_ACTIVE(next_state_offset + 1, 0);
+          if (isinclass) { ADD_NEW(next_state_offset + 1, 0); }
+          break;
+
+          case OP_CRRANGE:
+          case OP_CRMINRANGE:
+          count = current_state->count;  /* Already matched */
+          if (count >= GET2(ecode, 1))
+            { ADD_ACTIVE(next_state_offset + 5, 0); }
+          if (isinclass)
+            {
+            int max = GET2(ecode, 3);
+            if (++count >= max && max != 0)   /* Max 0 => no limit */
+              { ADD_NEW(next_state_offset + 5, 0); }
+            else
+              { ADD_NEW(state_offset, count); }
+            }
+          break;
+
+          default:
+          if (isinclass) { ADD_NEW(next_state_offset, 0); }
+          break;
+          }
+        }
+      break;
+
+/* ========================================================================== */
+      /* These are the opcodes for fancy brackets of various kinds. We have
+      to use recursion in order to handle them. The "always failing" assersion
+      (?!) is optimised when compiling to OP_FAIL, so we have to support that,
+      though the other "backtracking verbs" are not supported. */
+
+      case OP_FAIL:
+      break;
+
+      case OP_ASSERT:
+      case OP_ASSERT_NOT:
+      case OP_ASSERTBACK:
+      case OP_ASSERTBACK_NOT:
+        {
+        int rc;
+        int local_offsets[2];
+        int local_workspace[1000];
+        const uschar *endasscode = code + GET(code, 1);
+
+        while (*endasscode == OP_ALT) endasscode += GET(endasscode, 1);
+
+        rc = internal_dfa_exec(
+          md,                                   /* static match data */
+          code,                                 /* this subexpression's code */
+          ptr,                                  /* where we currently are */
+          ptr - start_subject,                  /* start offset */
+          local_offsets,                        /* offset vector */
+          sizeof(local_offsets)/sizeof(int),    /* size of same */
+          local_workspace,                      /* workspace vector */
+          sizeof(local_workspace)/sizeof(int),  /* size of same */
+          ims,                                  /* the current ims flags */
+          rlevel,                               /* function recursion level */
+          recursing);                           /* pass on regex recursion */
+
+        if ((rc >= 0) == (codevalue == OP_ASSERT || codevalue == OP_ASSERTBACK))
+            { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_COND:
+      case OP_SCOND:
+        {
+        int local_offsets[1000];
+        int local_workspace[1000];
+        int condcode = code[LINK_SIZE+1];
+
+        /* Back reference conditions are not supported */
+
+        if (condcode == OP_CREF) return PCRE_ERROR_DFA_UCOND;
+
+        /* The DEFINE condition is always false */
+
+        if (condcode == OP_DEF)
+          {
+          ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0);
+          }
+
+        /* The only supported version of OP_RREF is for the value RREF_ANY,
+        which means "test if in any recursion". We can't test for specifically
+        recursed groups. */
+
+        else if (condcode == OP_RREF)
+          {
+          int value = GET2(code, LINK_SIZE+2);
+          if (value != RREF_ANY) return PCRE_ERROR_DFA_UCOND;
+          if (recursing > 0) { ADD_ACTIVE(state_offset + LINK_SIZE + 4, 0); }
+            else { ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0); }
+          }
+
+        /* Otherwise, the condition is an assertion */
+
+        else
+          {
+          int rc;
+          const uschar *asscode = code + LINK_SIZE + 1;
+          const uschar *endasscode = asscode + GET(asscode, 1);
+
+          while (*endasscode == OP_ALT) endasscode += GET(endasscode, 1);
+
+          rc = internal_dfa_exec(
+            md,                                   /* fixed match data */
+            asscode,                              /* this subexpression's code */
+            ptr,                                  /* where we currently are */
+            ptr - start_subject,                  /* start offset */
+            local_offsets,                        /* offset vector */
+            sizeof(local_offsets)/sizeof(int),    /* size of same */
+            local_workspace,                      /* workspace vector */
+            sizeof(local_workspace)/sizeof(int),  /* size of same */
+            ims,                                  /* the current ims flags */
+            rlevel,                               /* function recursion level */
+            recursing);                           /* pass on regex recursion */
+
+          if ((rc >= 0) ==
+                (condcode == OP_ASSERT || condcode == OP_ASSERTBACK))
+            { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }
+          else
+            { ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0); }
+          }
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_RECURSE:
+        {
+        int local_offsets[1000];
+        int local_workspace[1000];
+        int rc;
+
+        DPRINTF(("%.*sStarting regex recursion %d\n", rlevel*2-2, SP,
+          recursing + 1));
+
+        rc = internal_dfa_exec(
+          md,                                   /* fixed match data */
+          start_code + GET(code, 1),            /* this subexpression's code */
+          ptr,                                  /* where we currently are */
+          ptr - start_subject,                  /* start offset */
+          local_offsets,                        /* offset vector */
+          sizeof(local_offsets)/sizeof(int),    /* size of same */
+          local_workspace,                      /* workspace vector */
+          sizeof(local_workspace)/sizeof(int),  /* size of same */
+          ims,                                  /* the current ims flags */
+          rlevel,                               /* function recursion level */
+          recursing + 1);                       /* regex recurse level */
+
+        DPRINTF(("%.*sReturn from regex recursion %d: rc=%d\n", rlevel*2-2, SP,
+          recursing + 1, rc));
+
+        /* Ran out of internal offsets */
+
+        if (rc == 0) return PCRE_ERROR_DFA_RECURSE;
+
+        /* For each successful matched substring, set up the next state with a
+        count of characters to skip before trying it. Note that the count is in
+        characters, not bytes. */
+
+        if (rc > 0)
+          {
+          for (rc = rc*2 - 2; rc >= 0; rc -= 2)
+            {
+            const uschar *p = start_subject + local_offsets[rc];
+            const uschar *pp = start_subject + local_offsets[rc+1];
+            int charcount = local_offsets[rc+1] - local_offsets[rc];
+            while (p < pp) if ((*p++ & 0xc0) == 0x80) charcount--;
+            if (charcount > 0)
+              {
+              ADD_NEW_DATA(-(state_offset + LINK_SIZE + 1), 0, (charcount - 1));
+              }
+            else
+              {
+              ADD_ACTIVE(state_offset + LINK_SIZE + 1, 0);
+              }
+            }
+          }
+        else if (rc != PCRE_ERROR_NOMATCH) return rc;
+        }
+      break;
+
+      /*-----------------------------------------------------------------*/
+      case OP_ONCE:
+        {
+        int local_offsets[2];
+        int local_workspace[1000];
+
+        int rc = internal_dfa_exec(
+          md,                                   /* fixed match data */
+          code,                                 /* this subexpression's code */
+          ptr,                                  /* where we currently are */
+          ptr - start_subject,                  /* start offset */
+          local_offsets,                        /* offset vector */
+          sizeof(local_offsets)/sizeof(int),    /* size of same */
+          local_workspace,                      /* workspace vector */
+          sizeof(local_workspace)/sizeof(int),  /* size of same */
+          ims,                                  /* the current ims flags */
+          rlevel,                               /* function recursion level */
+          recursing);                           /* pass on regex recursion */
+
+        if (rc >= 0)
+          {
+          const uschar *end_subpattern = code;
+          int charcount = local_offsets[1] - local_offsets[0];
+          int next_state_offset, repeat_state_offset;
+
+          do { end_subpattern += GET(end_subpattern, 1); }
+            while (*end_subpattern == OP_ALT);
+          next_state_offset = end_subpattern - start_code + LINK_SIZE + 1;
+
+          /* If the end of this subpattern is KETRMAX or KETRMIN, we must
+          arrange for the repeat state also to be added to the relevant list.
+          Calculate the offset, or set -1 for no repeat. */
+
+          repeat_state_offset = (*end_subpattern == OP_KETRMAX ||
+                                 *end_subpattern == OP_KETRMIN)?
+            end_subpattern - start_code - GET(end_subpattern, 1) : -1;
+
+          /* If we have matched an empty string, add the next state at the
+          current character pointer. This is important so that the duplicate
+          checking kicks in, which is what breaks infinite loops that match an
+          empty string. */
+
+          if (charcount == 0)
+            {
+            ADD_ACTIVE(next_state_offset, 0);
+            }
+
+          /* Optimization: if there are no more active states, and there
+          are no new states yet set up, then skip over the subject string
+          right here, to save looping. Otherwise, set up the new state to swing
+          into action when the end of the substring is reached. */
+
+          else if (i + 1 >= active_count && new_count == 0)
+            {
+            ptr += charcount;
+            clen = 0;
+            ADD_NEW(next_state_offset, 0);
+
+            /* If we are adding a repeat state at the new character position,
+            we must fudge things so that it is the only current state.
+            Otherwise, it might be a duplicate of one we processed before, and
+            that would cause it to be skipped. */
+
+            if (repeat_state_offset >= 0)
+              {
+              next_active_state = active_states;
+              active_count = 0;
+              i = -1;
+              ADD_ACTIVE(repeat_state_offset, 0);
+              }
+            }
+          else
+            {
+            const uschar *p = start_subject + local_offsets[0];
+            const uschar *pp = start_subject + local_offsets[1];
+            while (p < pp) if ((*p++ & 0xc0) == 0x80) charcount--;
+            ADD_NEW_DATA(-next_state_offset, 0, (charcount - 1));
+            if (repeat_state_offset >= 0)
+              { ADD_NEW_DATA(-repeat_state_offset, 0, (charcount - 1)); }
+            }
+
+          }
+        else if (rc != PCRE_ERROR_NOMATCH) return rc;
+        }
+      break;
+
+
+/* ========================================================================== */
+      /* Handle callouts */
+
+      case OP_CALLOUT:
+      if (pcre_callout != NULL)
+        {
+        int rrc;
+        pcre_callout_block cb;
+        cb.version          = 1;   /* Version 1 of the callout block */
+        cb.callout_number   = code[1];
+        cb.offset_vector    = offsets;
+        cb.subject          = (PCRE_SPTR)start_subject;
+        cb.subject_length   = end_subject - start_subject;
+        cb.start_match      = current_subject - start_subject;
+        cb.current_position = ptr - start_subject;
+        cb.pattern_position = GET(code, 2);
+        cb.next_item_length = GET(code, 2 + LINK_SIZE);
+        cb.capture_top      = 1;
+        cb.capture_last     = -1;
+        cb.callout_data     = md->callout_data;
+        if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */
+        if (rrc == 0) { ADD_ACTIVE(state_offset + 2 + 2*LINK_SIZE, 0); }
+        }
+      break;
+
+
+/* ========================================================================== */
+      default:        /* Unsupported opcode */
+      return PCRE_ERROR_DFA_UITEM;
+      }
+
+    NEXT_ACTIVE_STATE: continue;
+
+    }      /* End of loop scanning active states */
+
+  /* We have finished the processing at the current subject character. If no
+  new states have been set for the next character, we have found all the
+  matches that we are going to find. If we are at the top level and partial
+  matching has been requested, check for appropriate conditions. */
+
+  if (new_count <= 0)
+    {
+    if (match_count < 0 &&                     /* No matches found */
+        rlevel == 1 &&                         /* Top level match function */
+        (md->moptions & PCRE_PARTIAL) != 0 &&  /* Want partial matching */
+        ptr >= end_subject &&                  /* Reached end of subject */
+        ptr > current_subject)                 /* Matched non-empty string */
+      {
+      if (offsetcount >= 2)
+        {
+        offsets[0] = current_subject - start_subject;
+        offsets[1] = end_subject - start_subject;
+        }
+      match_count = PCRE_ERROR_PARTIAL;
+      }
+
+    DPRINTF(("%.*sEnd of internal_dfa_exec %d: returning %d\n"
+      "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel, match_count,
+      rlevel*2-2, SP));
+    break;        /* In effect, "return", but see the comment below */
+    }
+
+  /* One or more states are active for the next character. */
+
+  ptr += clen;    /* Advance to next subject character */
+  }               /* Loop to move along the subject string */
+
+/* Control gets here from "break" a few lines above. We do it this way because
+if we use "return" above, we have compiler trouble. Some compilers warn if
+there's nothing here because they think the function doesn't return a value. On
+the other hand, if we put a dummy statement here, some more clever compilers
+complain that it can't be reached. Sigh. */
+
+return match_count;
+}
+
+
+
+
+/*************************************************
+*    Execute a Regular Expression - DFA engine   *
+*************************************************/
+
+/* This external function applies a compiled re to a subject string using a DFA
+engine. This function calls the internal function multiple times if the pattern
+is not anchored.
+
+Arguments:
+  argument_re     points to the compiled expression
+  extra_data      points to extra data or is NULL
+  subject         points to the subject string
+  length          length of subject string (may contain binary zeros)
+  start_offset    where to start in the subject string
+  options         option bits
+  offsets         vector of match offsets
+  offsetcount     size of same
+  workspace       workspace vector
+  wscount         size of same
+
+Returns:          > 0 => number of match offset pairs placed in offsets
+                  = 0 => offsets overflowed; longest matches are present
+                   -1 => failed to match
+                 < -1 => some kind of unexpected problem
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,
+  const char *subject, int length, int start_offset, int options, int *offsets,
+  int offsetcount, int *workspace, int wscount)
+{
+real_pcre *re = (real_pcre *)argument_re;
+dfa_match_data match_block;
+dfa_match_data *md = &match_block;
+BOOL utf8, anchored, startline, firstline;
+const uschar *current_subject, *end_subject, *lcc;
+
+pcre_study_data internal_study;
+const pcre_study_data *study = NULL;
+real_pcre internal_re;
+
+const uschar *req_byte_ptr;
+const uschar *start_bits = NULL;
+BOOL first_byte_caseless = FALSE;
+BOOL req_byte_caseless = FALSE;
+int first_byte = -1;
+int req_byte = -1;
+int req_byte2 = -1;
+int newline;
+
+/* Plausibility checks */
+
+if ((options & ~PUBLIC_DFA_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
+if (re == NULL || subject == NULL || workspace == NULL ||
+   (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;
+if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
+if (wscount < 20) return PCRE_ERROR_DFA_WSSIZE;
+
+/* We need to find the pointer to any study data before we test for byte
+flipping, so we scan the extra_data block first. This may set two fields in the
+match block, so we must initialize them beforehand. However, the other fields
+in the match block must not be set until after the byte flipping. */
+
+md->tables = re->tables;
+md->callout_data = NULL;
+
+if (extra_data != NULL)
+  {
+  unsigned int flags = extra_data->flags;
+  if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)
+    study = (const pcre_study_data *)extra_data->study_data;
+  if ((flags & PCRE_EXTRA_MATCH_LIMIT) != 0) return PCRE_ERROR_DFA_UMLIMIT;
+  if ((flags & PCRE_EXTRA_MATCH_LIMIT_RECURSION) != 0)
+    return PCRE_ERROR_DFA_UMLIMIT;
+  if ((flags & PCRE_EXTRA_CALLOUT_DATA) != 0)
+    md->callout_data = extra_data->callout_data;
+  if ((flags & PCRE_EXTRA_TABLES) != 0)
+    md->tables = extra_data->tables;
+  }
+
+/* Check that the first field in the block is the magic number. If it is not,
+test for a regex that was compiled on a host of opposite endianness. If this is
+the case, flipped values are put in internal_re and internal_study if there was
+study data too. */
+
+if (re->magic_number != MAGIC_NUMBER)
+  {
+  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);
+  if (re == NULL) return PCRE_ERROR_BADMAGIC;
+  if (study != NULL) study = &internal_study;
+  }
+
+/* Set some local values */
+
+current_subject = (const unsigned char *)subject + start_offset;
+end_subject = (const unsigned char *)subject + length;
+req_byte_ptr = current_subject - 1;
+
+#ifdef SUPPORT_UTF8
+utf8 = (re->options & PCRE_UTF8) != 0;
+#else
+utf8 = FALSE;
+#endif
+
+anchored = (options & (PCRE_ANCHORED|PCRE_DFA_RESTART)) != 0 ||
+  (re->options & PCRE_ANCHORED) != 0;
+
+/* The remaining fixed data for passing around. */
+
+md->start_code = (const uschar *)argument_re +
+    re->name_table_offset + re->name_count * re->name_entry_size;
+md->start_subject = (const unsigned char *)subject;
+md->end_subject = end_subject;
+md->moptions = options;
+md->poptions = re->options;
+
+/* If the BSR option is not set at match time, copy what was set
+at compile time. */
+
+if ((md->moptions & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) == 0)
+  {
+  if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
+    md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE);
+#ifdef BSR_ANYCRLF
+  else md->moptions |= PCRE_BSR_ANYCRLF;
+#endif
+  }
+
+/* Handle different types of newline. The three bits give eight cases. If
+nothing is set at run time, whatever was used at compile time applies. */
+
+switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) &
+         PCRE_NEWLINE_BITS)
+  {
+  case 0: newline = NEWLINE; break;   /* Compile-time default */
+  case PCRE_NEWLINE_CR: newline = '\r'; break;
+  case PCRE_NEWLINE_LF: newline = '\n'; break;
+  case PCRE_NEWLINE_CR+
+       PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
+  case PCRE_NEWLINE_ANY: newline = -1; break;
+  case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
+  default: return PCRE_ERROR_BADNEWLINE;
+  }
+
+if (newline == -2)
+  {
+  md->nltype = NLTYPE_ANYCRLF;
+  }
+else if (newline < 0)
+  {
+  md->nltype = NLTYPE_ANY;
+  }
+else
+  {
+  md->nltype = NLTYPE_FIXED;
+  if (newline > 255)
+    {
+    md->nllen = 2;
+    md->nl[0] = (newline >> 8) & 255;
+    md->nl[1] = newline & 255;
+    }
+  else
+    {
+    md->nllen = 1;
+    md->nl[0] = newline;
+    }
+  }
+
+/* Check a UTF-8 string if required. Unfortunately there's no way of passing
+back the character offset. */
+
+#ifdef SUPPORT_UTF8
+if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)
+  {
+  if (_pcre_valid_utf8((uschar *)subject, length) >= 0)
+    return PCRE_ERROR_BADUTF8;
+  if (start_offset > 0 && start_offset < length)
+    {
+    int tb = ((uschar *)subject)[start_offset];
+    if (tb > 127)
+      {
+      tb &= 0xc0;
+      if (tb != 0 && tb != 0xc0) return PCRE_ERROR_BADUTF8_OFFSET;
+      }
+    }
+  }
+#endif
+
+/* If the exec call supplied NULL for tables, use the inbuilt ones. This
+is a feature that makes it possible to save compiled regex and re-use them
+in other programs later. */
+
+if (md->tables == NULL) md->tables = _pcre_default_tables;
+
+/* The lower casing table and the "must be at the start of a line" flag are
+used in a loop when finding where to start. */
+
+lcc = md->tables + lcc_offset;
+startline = (re->flags & PCRE_STARTLINE) != 0;
+firstline = (re->options & PCRE_FIRSTLINE) != 0;
+
+/* Set up the first character to match, if available. The first_byte value is
+never set for an anchored regular expression, but the anchoring may be forced
+at run time, so we have to test for anchoring. The first char may be unset for
+an unanchored pattern, of course. If there's no first char and the pattern was
+studied, there may be a bitmap of possible first characters. */
+
+if (!anchored)
+  {
+  if ((re->flags & PCRE_FIRSTSET) != 0)
+    {
+    first_byte = re->first_byte & 255;
+    if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
+      first_byte = lcc[first_byte];
+    }
+  else
+    {
+    if (startline && study != NULL &&
+         (study->options & PCRE_STUDY_MAPPED) != 0)
+      start_bits = study->start_bits;
+    }
+  }
+
+/* For anchored or unanchored matches, there may be a "last known required
+character" set. */
+
+if ((re->flags & PCRE_REQCHSET) != 0)
+  {
+  req_byte = re->req_byte & 255;
+  req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
+  req_byte2 = (md->tables + fcc_offset)[req_byte];  /* case flipped */
+  }
+
+/* Call the main matching function, looping for a non-anchored regex after a
+failed match. Unless restarting, optimize by moving to the first match
+character if possible, when not anchored. Then unless wanting a partial match,
+check for a required later character. */
+
+for (;;)
+  {
+  int rc;
+
+  if ((options & PCRE_DFA_RESTART) == 0)
+    {
+    const uschar *save_end_subject = end_subject;
+
+    /* Advance to a unique first char if possible. If firstline is TRUE, the
+    start of the match is constrained to the first line of a multiline string.
+    Implement this by temporarily adjusting end_subject so that we stop
+    scanning at a newline. If the match fails at the newline, later code breaks
+    this loop. */
+
+    if (firstline)
+      {
+      USPTR t = current_subject;
+#ifdef SUPPORT_UTF8
+      if (utf8)
+        {
+        while (t < md->end_subject && !IS_NEWLINE(t))
+          {
+          t++;
+          while (t < end_subject && (*t & 0xc0) == 0x80) t++;
+          }
+        }
+      else
+#endif
+      while (t < md->end_subject && !IS_NEWLINE(t)) t++;
+      end_subject = t;
+      }
+
+    if (first_byte >= 0)
+      {
+      if (first_byte_caseless)
+        while (current_subject < end_subject &&
+               lcc[*current_subject] != first_byte)
+          current_subject++;
+      else
+        while (current_subject < end_subject && *current_subject != first_byte)
+          current_subject++;
+      }
+
+    /* Or to just after a linebreak for a multiline match if possible */
+
+    else if (startline)
+      {
+      if (current_subject > md->start_subject + start_offset)
+        {
+#ifdef SUPPORT_UTF8
+        if (utf8)
+          {
+          while (current_subject < end_subject && !WAS_NEWLINE(current_subject))
+            {
+            current_subject++;
+            while(current_subject < end_subject &&
+                  (*current_subject & 0xc0) == 0x80)
+              current_subject++;
+            }
+          }
+        else
+#endif
+        while (current_subject < end_subject && !WAS_NEWLINE(current_subject))
+          current_subject++;
+
+        /* If we have just passed a CR and the newline option is ANY or
+        ANYCRLF, and we are now at a LF, advance the match position by one more
+        character. */
+
+        if (current_subject[-1] == '\r' &&
+             (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
+             current_subject < end_subject &&
+             *current_subject == '\n')
+          current_subject++;
+        }
+      }
+
+    /* Or to a non-unique first char after study */
+
+    else if (start_bits != NULL)
+      {
+      while (current_subject < end_subject)
+        {
+        register unsigned int c = *current_subject;
+        if ((start_bits[c/8] & (1 << (c&7))) == 0) current_subject++;
+          else break;
+        }
+      }
+
+    /* Restore fudged end_subject */
+
+    end_subject = save_end_subject;
+    }
+
+  /* If req_byte is set, we know that that character must appear in the subject
+  for the match to succeed. If the first character is set, req_byte must be
+  later in the subject; otherwise the test starts at the match point. This
+  optimization can save a huge amount of work in patterns with nested unlimited
+  repeats that aren't going to match. Writing separate code for cased/caseless
+  versions makes it go faster, as does using an autoincrement and backing off
+  on a match.
+
+  HOWEVER: when the subject string is very, very long, searching to its end can
+  take a long time, and give bad performance on quite ordinary patterns. This
+  showed up when somebody was matching /^C/ on a 32-megabyte string... so we
+  don't do this when the string is sufficiently long.
+
+  ALSO: this processing is disabled when partial matching is requested.
+  */
+
+  if (req_byte >= 0 &&
+      end_subject - current_subject < REQ_BYTE_MAX &&
+      (options & PCRE_PARTIAL) == 0)
+    {
+    register const uschar *p = current_subject + ((first_byte >= 0)? 1 : 0);
+
+    /* We don't need to repeat the search if we haven't yet reached the
+    place we found it at last time. */
+
+    if (p > req_byte_ptr)
+      {
+      if (req_byte_caseless)
+        {
+        while (p < end_subject)
+          {
+          register int pp = *p++;
+          if (pp == req_byte || pp == req_byte2) { p--; break; }
+          }
+        }
+      else
+        {
+        while (p < end_subject)
+          {
+          if (*p++ == req_byte) { p--; break; }
+          }
+        }
+
+      /* If we can't find the required character, break the matching loop,
+      which will cause a return or PCRE_ERROR_NOMATCH. */
+
+      if (p >= end_subject) break;
+
+      /* If we have found the required character, save the point where we
+      found it, so that we don't search again next time round the loop if
+      the start hasn't passed this character yet. */
+
+      req_byte_ptr = p;
+      }
+    }
+
+  /* OK, now we can do the business */
+
+  rc = internal_dfa_exec(
+    md,                                /* fixed match data */
+    md->start_code,                    /* this subexpression's code */
+    current_subject,                   /* where we currently are */
+    start_offset,                      /* start offset in subject */
+    offsets,                           /* offset vector */
+    offsetcount,                       /* size of same */
+    workspace,                         /* workspace vector */
+    wscount,                           /* size of same */
+    re->options & (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL), /* ims flags */
+    0,                                 /* function recurse level */
+    0);                                /* regex recurse level */
+
+  /* Anything other than "no match" means we are done, always; otherwise, carry
+  on only if not anchored. */
+
+  if (rc != PCRE_ERROR_NOMATCH || anchored) return rc;
+
+  /* Advance to the next subject character unless we are at the end of a line
+  and firstline is set. */
+
+  if (firstline && IS_NEWLINE(current_subject)) break;
+  current_subject++;
+  if (utf8)
+    {
+    while (current_subject < end_subject && (*current_subject & 0xc0) == 0x80)
+      current_subject++;
+    }
+  if (current_subject > end_subject) break;
+
+  /* If we have just passed a CR and we are now at a LF, and the pattern does
+  not contain any explicit matches for \r or \n, and the newline option is CRLF
+  or ANY or ANYCRLF, advance the match position by one more character. */
+
+  if (current_subject[-1] == '\r' &&
+      current_subject < end_subject &&
+      *current_subject == '\n' &&
+      (re->flags & PCRE_HASCRORLF) == 0 &&
+        (md->nltype == NLTYPE_ANY ||
+         md->nltype == NLTYPE_ANYCRLF ||
+         md->nllen == 2))
+    current_subject++;
+
+  }   /* "Bumpalong" loop */
+
+return PCRE_ERROR_NOMATCH;
+}
+
+/* End of pcre_dfa_exec.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_exec.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4999 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains pcre_exec(), the externally visible function that does
+pattern matching using an NFA algorithm, trying to mimic Perl as closely as
+possible. There are also some static supporting functions. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define NLBLOCK md             /* Block containing newline information */
+#define PSSTART start_subject  /* Field containing processed string start */
+#define PSEND   end_subject    /* Field containing processed string end */
+
+#include "pcre_internal.h"
+
+/* Undefine some potentially clashing cpp symbols */
+
+#undef min
+#undef max
+
+/* Flag bits for the match() function */
+
+#define match_condassert     0x01  /* Called to check a condition assertion */
+#define match_cbegroup       0x02  /* Could-be-empty unlimited repeat group */
+
+/* Non-error returns from the match() function. Error returns are externally
+defined PCRE_ERROR_xxx codes, which are all negative. */
+
+#define MATCH_MATCH        1
+#define MATCH_NOMATCH      0
+
+/* Special internal returns from the match() function. Make them sufficiently
+negative to avoid the external error codes. */
+
+#define MATCH_COMMIT       (-999)
+#define MATCH_PRUNE        (-998)
+#define MATCH_SKIP         (-997)
+#define MATCH_THEN         (-996)
+
+/* Maximum number of ints of offset to save on the stack for recursive calls.
+If the offset vector is bigger, malloc is used. This should be a multiple of 3,
+because the offset vector is always a multiple of 3 long. */
+
+#define REC_STACK_SAVE_MAX 30
+
+/* Min and max values for the common repeats; for the maxima, 0 => infinity */
+
+static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
+static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
+
+
+
+#ifdef DEBUG
+/*************************************************
+*        Debugging function to print chars       *
+*************************************************/
+
+/* Print a sequence of chars in printable format, stopping at the end of the
+subject if the requested.
+
+Arguments:
+  p           points to characters
+  length      number to print
+  is_subject  TRUE if printing from within md->start_subject
+  md          pointer to matching data block, if is_subject is TRUE
+
+Returns:     nothing
+*/
+
+static void
+pchars(const uschar *p, int length, BOOL is_subject, match_data *md)
+{
+unsigned int c;
+if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
+while (length-- > 0)
+  if (isprint(c = *(p++))) printf("%c", c); else printf("\\x%02x", c);
+}
+#endif
+
+
+
+/*************************************************
+*          Match a back-reference                *
+*************************************************/
+
+/* If a back reference hasn't been set, the length that is passed is greater
+than the number of characters left in the string, so the match fails.
+
+Arguments:
+  offset      index into the offset vector
+  eptr        points into the subject
+  length      length to be matched
+  md          points to match data block
+  ims         the ims flags
+
+Returns:      TRUE if matched
+*/
+
+static BOOL
+match_ref(int offset, register USPTR eptr, int length, match_data *md,
+  unsigned long int ims)
+{
+USPTR p = md->start_subject + md->offset_vector[offset];
+
+#ifdef DEBUG
+if (eptr >= md->end_subject)
+  printf("matching subject <null>");
+else
+  {
+  printf("matching subject ");
+  pchars(eptr, length, TRUE, md);
+  }
+printf(" against backref ");
+pchars(p, length, FALSE, md);
+printf("\n");
+#endif
+
+/* Always fail if not enough characters left */
+
+if (length > md->end_subject - eptr) return FALSE;
+
+/* Separate the caseless case for speed. In UTF-8 mode we can only do this
+properly if Unicode properties are supported. Otherwise, we can check only
+ASCII characters. */
+
+if ((ims & PCRE_CASELESS) != 0)
+  {
+#ifdef SUPPORT_UTF8
+#ifdef SUPPORT_UCP
+  if (md->utf8)
+    {
+    USPTR endptr = eptr + length;
+    while (eptr < endptr)
+      {
+      int c, d;
+      GETCHARINC(c, eptr);
+      GETCHARINC(d, p);
+      if (c != d && c != UCD_OTHERCASE(d)) return FALSE;
+      }
+    }
+  else
+#endif
+#endif
+
+  /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
+  is no UCP support. */
+
+  while (length-- > 0)
+    { if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; }
+  }
+
+/* In the caseful case, we can just compare the bytes, whether or not we
+are in UTF-8 mode. */
+
+else
+  { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }
+
+return TRUE;
+}
+
+
+
+/***************************************************************************
+****************************************************************************
+                   RECURSION IN THE match() FUNCTION
+
+The match() function is highly recursive, though not every recursive call
+increases the recursive depth. Nevertheless, some regular expressions can cause
+it to recurse to a great depth. I was writing for Unix, so I just let it call
+itself recursively. This uses the stack for saving everything that has to be
+saved for a recursive call. On Unix, the stack can be large, and this works
+fine.
+
+It turns out that on some non-Unix-like systems there are problems with
+programs that use a lot of stack. (This despite the fact that every last chip
+has oodles of memory these days, and techniques for extending the stack have
+been known for decades.) So....
+
+There is a fudge, triggered by defining NO_RECURSE, which avoids recursive
+calls by keeping local variables that need to be preserved in blocks of memory
+obtained from malloc() instead instead of on the stack. Macros are used to
+achieve this so that the actual code doesn't look very different to what it
+always used to.
+
+The original heap-recursive code used longjmp(). However, it seems that this
+can be very slow on some operating systems. Following a suggestion from Stan
+Switzer, the use of longjmp() has been abolished, at the cost of having to
+provide a unique number for each call to RMATCH. There is no way of generating
+a sequence of numbers at compile time in C. I have given them names, to make
+them stand out more clearly.
+
+Crude tests on x86 Linux show a small speedup of around 5-8%. However, on
+FreeBSD, avoiding longjmp() more than halves the time taken to run the standard
+tests. Furthermore, not using longjmp() means that local dynamic variables
+don't have indeterminate values; this has meant that the frame size can be
+reduced because the result can be "passed back" by straight setting of the
+variable instead of being passed in the frame.
+****************************************************************************
+***************************************************************************/
+
+/* Numbers for RMATCH calls. When this list is changed, the code at HEAP_RETURN
+below must be updated in sync.  */
+
+enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM6,  RM7,  RM8,  RM9,  RM10,
+       RM11,  RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,
+       RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
+       RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
+       RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
+       RM51,  RM52, RM53, RM54 };
+
+/* These versions of the macros use the stack, as normal. There are debugging
+versions and production versions. Note that the "rw" argument of RMATCH isn't
+actuall used in this definition. */
+
+#ifndef NO_RECURSE
+#define REGISTER register
+
+#ifdef DEBUG
+#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
+  { \
+  printf("match() called in line %d\n", __LINE__); \
+  rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1); \
+  printf("to line %d\n", __LINE__); \
+  }
+#define RRETURN(ra) \
+  { \
+  printf("match() returned %d from line %d ", ra, __LINE__); \
+  return ra; \
+  }
+#else
+#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
+  rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1)
+#define RRETURN(ra) return ra
+#endif
+
+#else
+
+
+/* These versions of the macros manage a private stack on the heap. Note that
+the "rd" argument of RMATCH isn't actually used in this definition. It's the md
+argument of match(), which never changes. */
+
+#define REGISTER
+
+#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\
+  {\
+  heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\
+  frame->Xwhere = rw; \
+  newframe->Xeptr = ra;\
+  newframe->Xecode = rb;\
+  newframe->Xmstart = mstart;\
+  newframe->Xoffset_top = rc;\
+  newframe->Xims = re;\
+  newframe->Xeptrb = rf;\
+  newframe->Xflags = rg;\
+  newframe->Xrdepth = frame->Xrdepth + 1;\
+  newframe->Xprevframe = frame;\
+  frame = newframe;\
+  DPRINTF(("restarting from line %d\n", __LINE__));\
+  goto HEAP_RECURSE;\
+  L_##rw:\
+  DPRINTF(("jumped back to line %d\n", __LINE__));\
+  }
+
+#define RRETURN(ra)\
+  {\
+  heapframe *newframe = frame;\
+  frame = newframe->Xprevframe;\
+  (pcre_stack_free)(newframe);\
+  if (frame != NULL)\
+    {\
+    rrc = ra;\
+    goto HEAP_RETURN;\
+    }\
+  return ra;\
+  }
+
+
+/* Structure for remembering the local variables in a private frame */
+
+typedef struct heapframe {
+  struct heapframe *Xprevframe;
+
+  /* Function arguments that may change */
+
+  const uschar *Xeptr;
+  const uschar *Xecode;
+  const uschar *Xmstart;
+  int Xoffset_top;
+  long int Xims;
+  eptrblock *Xeptrb;
+  int Xflags;
+  unsigned int Xrdepth;
+
+  /* Function local variables */
+
+  const uschar *Xcallpat;
+  const uschar *Xcharptr;
+  const uschar *Xdata;
+  const uschar *Xnext;
+  const uschar *Xpp;
+  const uschar *Xprev;
+  const uschar *Xsaved_eptr;
+
+  recursion_info Xnew_recursive;
+
+  BOOL Xcur_is_word;
+  BOOL Xcondition;
+  BOOL Xprev_is_word;
+
+  unsigned long int Xoriginal_ims;
+
+#ifdef SUPPORT_UCP
+  int Xprop_type;
+  int Xprop_value;
+  int Xprop_fail_result;
+  int Xprop_category;
+  int Xprop_chartype;
+  int Xprop_script;
+  int Xoclength;
+  uschar Xocchars[8];
+#endif
+
+  int Xctype;
+  unsigned int Xfc;
+  int Xfi;
+  int Xlength;
+  int Xmax;
+  int Xmin;
+  int Xnumber;
+  int Xoffset;
+  int Xop;
+  int Xsave_capture_last;
+  int Xsave_offset1, Xsave_offset2, Xsave_offset3;
+  int Xstacksave[REC_STACK_SAVE_MAX];
+
+  eptrblock Xnewptrb;
+
+  /* Where to jump back to */
+
+  int Xwhere;
+
+} heapframe;
+
+#endif
+
+
+/***************************************************************************
+***************************************************************************/
+
+
+
+/*************************************************
+*         Match from current position            *
+*************************************************/
+
+/* This function is called recursively in many circumstances. Whenever it
+returns a negative (error) response, the outer incarnation must also return the
+same response.
+
+Performance note: It might be tempting to extract commonly used fields from the
+md structure (e.g. utf8, end_subject) into individual variables to improve
+performance. Tests using gcc on a SPARC disproved this; in the first case, it
+made performance worse.
+
+Arguments:
+   eptr        pointer to current character in subject
+   ecode       pointer to current position in compiled code
+   mstart      pointer to the current match start position (can be modified
+                 by encountering \K)
+   offset_top  current top pointer
+   md          pointer to "static" info for the match
+   ims         current /i, /m, and /s options
+   eptrb       pointer to chain of blocks containing eptr at start of
+                 brackets - for testing for empty matches
+   flags       can contain
+                 match_condassert - this is an assertion condition
+                 match_cbegroup - this is the start of an unlimited repeat
+                   group that can match an empty string
+   rdepth      the recursion depth
+
+Returns:       MATCH_MATCH if matched            )  these values are >= 0
+               MATCH_NOMATCH if failed to match  )
+               a negative PCRE_ERROR_xxx value if aborted by an error condition
+                 (e.g. stopped by repeated call or recursion limit)
+*/
+
+static int
+match(REGISTER USPTR eptr, REGISTER const uschar *ecode, const uschar *mstart,
+  int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,
+  int flags, unsigned int rdepth)
+{
+/* These variables do not need to be preserved over recursion in this function,
+so they can be ordinary variables in all cases. Mark some of them with
+"register" because they are used a lot in loops. */
+
+register int  rrc;         /* Returns from recursive calls */
+register int  i;           /* Used for loops not involving calls to RMATCH() */
+register unsigned int c;   /* Character values not kept over RMATCH() calls */
+register BOOL utf8;        /* Local copy of UTF-8 flag for speed */
+
+BOOL minimize, possessive; /* Quantifier options */
+
+/* When recursion is not being used, all "local" variables that have to be
+preserved over calls to RMATCH() are part of a "frame" which is obtained from
+heap storage. Set up the top-level frame here; others are obtained from the
+heap whenever RMATCH() does a "recursion". See the macro definitions above. */
+
+#ifdef NO_RECURSE
+heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe));
+frame->Xprevframe = NULL;            /* Marks the top level */
+
+/* Copy in the original argument variables */
+
+frame->Xeptr = eptr;
+frame->Xecode = ecode;
+frame->Xmstart = mstart;
+frame->Xoffset_top = offset_top;
+frame->Xims = ims;
+frame->Xeptrb = eptrb;
+frame->Xflags = flags;
+frame->Xrdepth = rdepth;
+
+/* This is where control jumps back to to effect "recursion" */
+
+HEAP_RECURSE:
+
+/* Macros make the argument variables come from the current frame */
+
+#define eptr               frame->Xeptr
+#define ecode              frame->Xecode
+#define mstart             frame->Xmstart
+#define offset_top         frame->Xoffset_top
+#define ims                frame->Xims
+#define eptrb              frame->Xeptrb
+#define flags              frame->Xflags
+#define rdepth             frame->Xrdepth
+
+/* Ditto for the local variables */
+
+#ifdef SUPPORT_UTF8
+#define charptr            frame->Xcharptr
+#endif
+#define callpat            frame->Xcallpat
+#define data               frame->Xdata
+#define next               frame->Xnext
+#define pp                 frame->Xpp
+#define prev               frame->Xprev
+#define saved_eptr         frame->Xsaved_eptr
+
+#define new_recursive      frame->Xnew_recursive
+
+#define cur_is_word        frame->Xcur_is_word
+#define condition          frame->Xcondition
+#define prev_is_word       frame->Xprev_is_word
+
+#define original_ims       frame->Xoriginal_ims
+
+#ifdef SUPPORT_UCP
+#define prop_type          frame->Xprop_type
+#define prop_value         frame->Xprop_value
+#define prop_fail_result   frame->Xprop_fail_result
+#define prop_category      frame->Xprop_category
+#define prop_chartype      frame->Xprop_chartype
+#define prop_script        frame->Xprop_script
+#define oclength           frame->Xoclength
+#define occhars            frame->Xocchars
+#endif
+
+#define ctype              frame->Xctype
+#define fc                 frame->Xfc
+#define fi                 frame->Xfi
+#define length             frame->Xlength
+#define max                frame->Xmax
+#define min                frame->Xmin
+#define number             frame->Xnumber
+#define offset             frame->Xoffset
+#define op                 frame->Xop
+#define save_capture_last  frame->Xsave_capture_last
+#define save_offset1       frame->Xsave_offset1
+#define save_offset2       frame->Xsave_offset2
+#define save_offset3       frame->Xsave_offset3
+#define stacksave          frame->Xstacksave
+
+#define newptrb            frame->Xnewptrb
+
+/* When recursion is being used, local variables are allocated on the stack and
+get preserved during recursion in the normal way. In this environment, fi and
+i, and fc and c, can be the same variables. */
+
+#else         /* NO_RECURSE not defined */
+#define fi i
+#define fc c
+
+
+#ifdef SUPPORT_UTF8                /* Many of these variables are used only  */
+const uschar *charptr;             /* in small blocks of the code. My normal */
+#endif                             /* style of coding would have declared    */
+const uschar *callpat;             /* them within each of those blocks.      */
+const uschar *data;                /* However, in order to accommodate the   */
+const uschar *next;                /* version of this code that uses an      */
+USPTR         pp;                  /* external "stack" implemented on the    */
+const uschar *prev;                /* heap, it is easier to declare them all */
+USPTR         saved_eptr;          /* here, so the declarations can be cut   */
+                                   /* out in a block. The only declarations  */
+recursion_info new_recursive;      /* within blocks below are for variables  */
+                                   /* that do not have to be preserved over  */
+BOOL cur_is_word;                  /* a recursive call to RMATCH().          */
+BOOL condition;
+BOOL prev_is_word;
+
+unsigned long int original_ims;
+
+#ifdef SUPPORT_UCP
+int prop_type;
+int prop_value;
+int prop_fail_result;
+int prop_category;
+int prop_chartype;
+int prop_script;
+int oclength;
+uschar occhars[8];
+#endif
+
+int ctype;
+int length;
+int max;
+int min;
+int number;
+int offset;
+int op;
+int save_capture_last;
+int save_offset1, save_offset2, save_offset3;
+int stacksave[REC_STACK_SAVE_MAX];
+
+eptrblock newptrb;
+#endif     /* NO_RECURSE */
+
+/* These statements are here to stop the compiler complaining about unitialized
+variables. */
+
+#ifdef SUPPORT_UCP
+prop_value = 0;
+prop_fail_result = 0;
+#endif
+
+
+/* This label is used for tail recursion, which is used in a few cases even
+when NO_RECURSE is not defined, in order to reduce the amount of stack that is
+used. Thanks to Ian Taylor for noticing this possibility and sending the
+original patch. */
+
+TAIL_RECURSE:
+
+/* OK, now we can get on with the real code of the function. Recursive calls
+are specified by the macro RMATCH and RRETURN is used to return. When
+NO_RECURSE is *not* defined, these just turn into a recursive call to match()
+and a "return", respectively (possibly with some debugging if DEBUG is
+defined). However, RMATCH isn't like a function call because it's quite a
+complicated macro. It has to be used in one particular way. This shouldn't,
+however, impact performance when true recursion is being used. */
+
+#ifdef SUPPORT_UTF8
+utf8 = md->utf8;       /* Local copy of the flag */
+#else
+utf8 = FALSE;
+#endif
+
+/* First check that we haven't called match() too many times, or that we
+haven't exceeded the recursive call limit. */
+
+if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT);
+if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT);
+
+original_ims = ims;    /* Save for resetting on ')' */
+
+/* At the start of a group with an unlimited repeat that may match an empty
+string, the match_cbegroup flag is set. When this is the case, add the current
+subject pointer to the chain of such remembered pointers, to be checked when we
+hit the closing ket, in order to break infinite loops that match no characters.
+When match() is called in other circumstances, don't add to the chain. The
+match_cbegroup flag must NOT be used with tail recursion, because the memory
+block that is used is on the stack, so a new one may be required for each
+match(). */
+
+if ((flags & match_cbegroup) != 0)
+  {
+  newptrb.epb_saved_eptr = eptr;
+  newptrb.epb_prev = eptrb;
+  eptrb = &newptrb;
+  }
+
+/* Now start processing the opcodes. */
+
+for (;;)
+  {
+  minimize = possessive = FALSE;
+  op = *ecode;
+
+  /* For partial matching, remember if we ever hit the end of the subject after
+  matching at least one subject character. */
+
+  if (md->partial &&
+      eptr >= md->end_subject &&
+      eptr > mstart)
+    md->hitend = TRUE;
+
+  switch(op)
+    {
+    case OP_FAIL:
+    RRETURN(MATCH_NOMATCH);
+
+    case OP_PRUNE:
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
+      ims, eptrb, flags, RM51);
+    if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+    RRETURN(MATCH_PRUNE);
+
+    case OP_COMMIT:
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
+      ims, eptrb, flags, RM52);
+    if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+    RRETURN(MATCH_COMMIT);
+
+    case OP_SKIP:
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
+      ims, eptrb, flags, RM53);
+    if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+    md->start_match_ptr = eptr;   /* Pass back current position */
+    RRETURN(MATCH_SKIP);
+
+    case OP_THEN:
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
+      ims, eptrb, flags, RM54);
+    if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+    RRETURN(MATCH_THEN);
+
+    /* Handle a capturing bracket. If there is space in the offset vector, save
+    the current subject position in the working slot at the top of the vector.
+    We mustn't change the current values of the data slot, because they may be
+    set from a previous iteration of this group, and be referred to by a
+    reference inside the group.
+
+    If the bracket fails to match, we need to restore this value and also the
+    values of the final offsets, in case they were set by a previous iteration
+    of the same bracket.
+
+    If there isn't enough space in the offset vector, treat this as if it were
+    a non-capturing bracket. Don't worry about setting the flag for the error
+    case here; that is handled in the code for KET. */
+
+    case OP_CBRA:
+    case OP_SCBRA:
+    number = GET2(ecode, 1+LINK_SIZE);
+    offset = number << 1;
+
+#ifdef DEBUG
+    printf("start bracket %d\n", number);
+    printf("subject=");
+    pchars(eptr, 16, TRUE, md);
+    printf("\n");
+#endif
+
+    if (offset < md->offset_max)
+      {
+      save_offset1 = md->offset_vector[offset];
+      save_offset2 = md->offset_vector[offset+1];
+      save_offset3 = md->offset_vector[md->offset_end - number];
+      save_capture_last = md->capture_last;
+
+      DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
+      md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
+
+      flags = (op == OP_SCBRA)? match_cbegroup : 0;
+      do
+        {
+        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
+          ims, eptrb, flags, RM1);
+        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
+        md->capture_last = save_capture_last;
+        ecode += GET(ecode, 1);
+        }
+      while (*ecode == OP_ALT);
+
+      DPRINTF(("bracket %d failed\n", number));
+
+      md->offset_vector[offset] = save_offset1;
+      md->offset_vector[offset+1] = save_offset2;
+      md->offset_vector[md->offset_end - number] = save_offset3;
+
+      RRETURN(MATCH_NOMATCH);
+      }
+
+    /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
+    as a non-capturing bracket. */
+
+    /* VVVVVVVVVVVVVVVVVVVVVVVVV */
+    /* VVVVVVVVVVVVVVVVVVVVVVVVV */
+
+    DPRINTF(("insufficient capture room: treat as non-capturing\n"));
+
+    /* VVVVVVVVVVVVVVVVVVVVVVVVV */
+    /* VVVVVVVVVVVVVVVVVVVVVVVVV */
+
+    /* Non-capturing bracket. Loop for all the alternatives. When we get to the
+    final alternative within the brackets, we would return the result of a
+    recursive call to match() whatever happened. We can reduce stack usage by
+    turning this into a tail recursion, except in the case when match_cbegroup
+    is set.*/
+
+    case OP_BRA:
+    case OP_SBRA:
+    DPRINTF(("start non-capturing bracket\n"));
+    flags = (op >= OP_SBRA)? match_cbegroup : 0;
+    for (;;)
+      {
+      if (ecode[GET(ecode, 1)] != OP_ALT)   /* Final alternative */
+        {
+        if (flags == 0)    /* Not a possibly empty group */
+          {
+          ecode += _pcre_OP_lengths[*ecode];
+          DPRINTF(("bracket 0 tail recursion\n"));
+          goto TAIL_RECURSE;
+          }
+
+        /* Possibly empty group; can't use tail recursion. */
+
+        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
+          eptrb, flags, RM48);
+        RRETURN(rrc);
+        }
+
+      /* For non-final alternatives, continue the loop for a NOMATCH result;
+      otherwise return. */
+
+      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
+        eptrb, flags, RM2);
+      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
+      ecode += GET(ecode, 1);
+      }
+    /* Control never reaches here. */
+
+    /* Conditional group: compilation checked that there are no more than
+    two branches. If the condition is false, skipping the first branch takes us
+    past the end if there is only one branch, but that's OK because that is
+    exactly what going to the ket would do. As there is only one branch to be
+    obeyed, we can use tail recursion to avoid using another stack frame. */
+
+    case OP_COND:
+    case OP_SCOND:
+    if (ecode[LINK_SIZE+1] == OP_RREF)         /* Recursion test */
+      {
+      offset = GET2(ecode, LINK_SIZE + 2);     /* Recursion group number*/
+      condition = md->recursive != NULL &&
+        (offset == RREF_ANY || offset == md->recursive->group_num);
+      ecode += condition? 3 : GET(ecode, 1);
+      }
+
+    else if (ecode[LINK_SIZE+1] == OP_CREF)    /* Group used test */
+      {
+      offset = GET2(ecode, LINK_SIZE+2) << 1;  /* Doubled ref number */
+      condition = offset < offset_top && md->offset_vector[offset] >= 0;
+      ecode += condition? 3 : GET(ecode, 1);
+      }
+
+    else if (ecode[LINK_SIZE+1] == OP_DEF)     /* DEFINE - always false */
+      {
+      condition = FALSE;
+      ecode += GET(ecode, 1);
+      }
+
+    /* The condition is an assertion. Call match() to evaluate it - setting
+    the final argument match_condassert causes it to stop at the end of an
+    assertion. */
+
+    else
+      {
+      RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
+          match_condassert, RM3);
+      if (rrc == MATCH_MATCH)
+        {
+        condition = TRUE;
+        ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
+        while (*ecode == OP_ALT) ecode += GET(ecode, 1);
+        }
+      else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
+        {
+        RRETURN(rrc);         /* Need braces because of following else */
+        }
+      else
+        {
+        condition = FALSE;
+        ecode += GET(ecode, 1);
+        }
+      }
+
+    /* We are now at the branch that is to be obeyed. As there is only one,
+    we can use tail recursion to avoid using another stack frame, except when
+    match_cbegroup is required for an unlimited repeat of a possibly empty
+    group. If the second alternative doesn't exist, we can just plough on. */
+
+    if (condition || *ecode == OP_ALT)
+      {
+      ecode += 1 + LINK_SIZE;
+      if (op == OP_SCOND)        /* Possibly empty group */
+        {
+        RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49);
+        RRETURN(rrc);
+        }
+      else                       /* Group must match something */
+        {
+        flags = 0;
+        goto TAIL_RECURSE;
+        }
+      }
+    else                         /* Condition false & no 2nd alternative */
+      {
+      ecode += 1 + LINK_SIZE;
+      }
+    break;
+
+
+    /* End of the pattern, either real or forced. If we are in a top-level
+    recursion, we should restore the offsets appropriately and continue from
+    after the call. */
+
+    case OP_ACCEPT:
+    case OP_END:
+    if (md->recursive != NULL && md->recursive->group_num == 0)
+      {
+      recursion_info *rec = md->recursive;
+      DPRINTF(("End of pattern in a (?0) recursion\n"));
+      md->recursive = rec->prevrec;
+      memmove(md->offset_vector, rec->offset_save,
+        rec->saved_max * sizeof(int));
+      mstart = rec->save_start;
+      ims = original_ims;
+      ecode = rec->after_call;
+      break;
+      }
+
+    /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty
+    string - backtracking will then try other alternatives, if any. */
+
+    if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH);
+    md->end_match_ptr = eptr;           /* Record where we ended */
+    md->end_offset_top = offset_top;    /* and how many extracts were taken */
+    md->start_match_ptr = mstart;       /* and the start (\K can modify) */
+    RRETURN(MATCH_MATCH);
+
+    /* Change option settings */
+
+    case OP_OPT:
+    ims = ecode[1];
+    ecode += 2;
+    DPRINTF(("ims set to %02lx\n", ims));
+    break;
+
+    /* Assertion brackets. Check the alternative branches in turn - the
+    matching won't pass the KET for an assertion. If any one branch matches,
+    the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
+    start of each branch to move the current point backwards, so the code at
+    this level is identical to the lookahead case. */
+
+    case OP_ASSERT:
+    case OP_ASSERTBACK:
+    do
+      {
+      RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
+        RM4);
+      if (rrc == MATCH_MATCH) break;
+      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
+      ecode += GET(ecode, 1);
+      }
+    while (*ecode == OP_ALT);
+    if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);
+
+    /* If checking an assertion for a condition, return MATCH_MATCH. */
+
+    if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);
+
+    /* Continue from after the assertion, updating the offsets high water
+    mark, since extracts may have been taken during the assertion. */
+
+    do ecode += GET(ecode,1); while (*ecode == OP_ALT);
+    ecode += 1 + LINK_SIZE;
+    offset_top = md->end_offset_top;
+    continue;
+
+    /* Negative assertion: all branches must fail to match */
+
+    case OP_ASSERT_NOT:
+    case OP_ASSERTBACK_NOT:
+    do
+      {
+      RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
+        RM5);
+      if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);
+      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
+      ecode += GET(ecode,1);
+      }
+    while (*ecode == OP_ALT);
+
+    if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);
+
+    ecode += 1 + LINK_SIZE;
+    continue;
+
+    /* Move the subject pointer back. This occurs only at the start of
+    each branch of a lookbehind assertion. If we are too close to the start to
+    move back, this match function fails. When working with UTF-8 we move
+    back a number of characters, not bytes. */
+
+    case OP_REVERSE:
+#ifdef SUPPORT_UTF8
+    if (utf8)
+      {
+      i = GET(ecode, 1);
+      while (i-- > 0)
+        {
+        eptr--;
+        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
+        BACKCHAR(eptr);
+        }
+      }
+    else
+#endif
+
+    /* No UTF-8 support, or not in UTF-8 mode: count is byte count */
+
+      {
+      eptr -= GET(ecode, 1);
+      if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
+      }
+
+    /* Skip to next op code */
+
+    ecode += 1 + LINK_SIZE;
+    break;
+
+    /* The callout item calls an external function, if one is provided, passing
+    details of the match so far. This is mainly for debugging, though the
+    function is able to force a failure. */
+
+    case OP_CALLOUT:
+    if (pcre_callout != NULL)
+      {
+      pcre_callout_block cb;
+      cb.version          = 1;   /* Version 1 of the callout block */
+      cb.callout_number   = ecode[1];
+      cb.offset_vector    = md->offset_vector;
+      cb.subject          = (PCRE_SPTR)md->start_subject;
+      cb.subject_length   = md->end_subject - md->start_subject;
+      cb.start_match      = mstart - md->start_subject;
+      cb.current_position = eptr - md->start_subject;
+      cb.pattern_position = GET(ecode, 2);
+      cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
+      cb.capture_top      = offset_top/2;
+      cb.capture_last     = md->capture_last;
+      cb.callout_data     = md->callout_data;
+      if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);
+      if (rrc < 0) RRETURN(rrc);
+      }
+    ecode += 2 + 2*LINK_SIZE;
+    break;
+
+    /* Recursion either matches the current regex, or some subexpression. The
+    offset data is the offset to the starting bracket from the start of the
+    whole pattern. (This is so that it works from duplicated subpatterns.)
+
+    If there are any capturing brackets started but not finished, we have to
+    save their starting points and reinstate them after the recursion. However,
+    we don't know how many such there are (offset_top records the completed
+    total) so we just have to save all the potential data. There may be up to
+    65535 such values, which is too large to put on the stack, but using malloc
+    for small numbers seems expensive. As a compromise, the stack is used when
+    there are no more than REC_STACK_SAVE_MAX values to store; otherwise malloc
+    is used. A problem is what to do if the malloc fails ... there is no way of
+    returning to the top level with an error. Save the top REC_STACK_SAVE_MAX
+    values on the stack, and accept that the rest may be wrong.
+
+    There are also other values that have to be saved. We use a chained
+    sequence of blocks that actually live on the stack. Thanks to Robin Houston
+    for the original version of this logic. */
+
+    case OP_RECURSE:
+      {
+      callpat = md->start_code + GET(ecode, 1);
+      new_recursive.group_num = (callpat == md->start_code)? 0 :
+        GET2(callpat, 1 + LINK_SIZE);
+
+      /* Add to "recursing stack" */
+
+      new_recursive.prevrec = md->recursive;
+      md->recursive = &new_recursive;
+
+      /* Find where to continue from afterwards */
+
+      ecode += 1 + LINK_SIZE;
+      new_recursive.after_call = ecode;
+
+      /* Now save the offset data. */
+
+      new_recursive.saved_max = md->offset_end;
+      if (new_recursive.saved_max <= REC_STACK_SAVE_MAX)
+        new_recursive.offset_save = stacksave;
+      else
+        {
+        new_recursive.offset_save =
+          (int *)(pcre_malloc)(new_recursive.saved_max * sizeof(int));
+        if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
+        }
+
+      memcpy(new_recursive.offset_save, md->offset_vector,
+            new_recursive.saved_max * sizeof(int));
+      new_recursive.save_start = mstart;
+      mstart = eptr;
+
+      /* OK, now we can do the recursion. For each top-level alternative we
+      restore the offset and recursion data. */
+
+      DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
+      flags = (*callpat >= OP_SBRA)? match_cbegroup : 0;
+      do
+        {
+        RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,
+          md, ims, eptrb, flags, RM6);
+        if (rrc == MATCH_MATCH)
+          {
+          DPRINTF(("Recursion matched\n"));
+          md->recursive = new_recursive.prevrec;
+          if (new_recursive.offset_save != stacksave)
+            (pcre_free)(new_recursive.offset_save);
+          RRETURN(MATCH_MATCH);
+          }
+        else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
+          {
+          DPRINTF(("Recursion gave error %d\n", rrc));
+          RRETURN(rrc);
+          }
+
+        md->recursive = &new_recursive;
+        memcpy(md->offset_vector, new_recursive.offset_save,
+            new_recursive.saved_max * sizeof(int));
+        callpat += GET(callpat, 1);
+        }
+      while (*callpat == OP_ALT);
+
+      DPRINTF(("Recursion didn't match\n"));
+      md->recursive = new_recursive.prevrec;
+      if (new_recursive.offset_save != stacksave)
+        (pcre_free)(new_recursive.offset_save);
+      RRETURN(MATCH_NOMATCH);
+      }
+    /* Control never reaches here */
+
+    /* "Once" brackets are like assertion brackets except that after a match,
+    the point in the subject string is not moved back. Thus there can never be
+    a move back into the brackets. Friedl calls these "atomic" subpatterns.
+    Check the alternative branches in turn - the matching won't pass the KET
+    for this kind of subpattern. If any one branch matches, we carry on as at
+    the end of a normal bracket, leaving the subject pointer. */
+
+    case OP_ONCE:
+    prev = ecode;
+    saved_eptr = eptr;
+
+    do
+      {
+      RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);
+      if (rrc == MATCH_MATCH) break;
+      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
+      ecode += GET(ecode,1);
+      }
+    while (*ecode == OP_ALT);
+
+    /* If hit the end of the group (which could be repeated), fail */
+
+    if (*ecode != OP_ONCE && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH);
+
+    /* Continue as from after the assertion, updating the offsets high water
+    mark, since extracts may have been taken. */
+
+    do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
+
+    offset_top = md->end_offset_top;
+    eptr = md->end_match_ptr;
+
+    /* For a non-repeating ket, just continue at this level. This also
+    happens for a repeating ket if no characters were matched in the group.
+    This is the forcible breaking of infinite loops as implemented in Perl
+    5.005. If there is an options reset, it will get obeyed in the normal
+    course of events. */
+
+    if (*ecode == OP_KET || eptr == saved_eptr)
+      {
+      ecode += 1+LINK_SIZE;
+      break;
+      }
+
+    /* The repeating kets try the rest of the pattern or restart from the
+    preceding bracket, in the appropriate order. The second "call" of match()
+    uses tail recursion, to avoid using another stack frame. We need to reset
+    any options that changed within the bracket before re-running it, so
+    check the next opcode. */
+
+    if (ecode[1+LINK_SIZE] == OP_OPT)
+      {
+      ims = (ims & ~PCRE_IMS) | ecode[4];
+      DPRINTF(("ims set to %02lx at group repeat\n", ims));
+      }
+
+    if (*ecode == OP_KETRMIN)
+      {
+      RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8);
+      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+      ecode = prev;
+      flags = 0;
+      goto TAIL_RECURSE;
+      }
+    else  /* OP_KETRMAX */
+      {
+      RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9);
+      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+      ecode += 1 + LINK_SIZE;
+      flags = 0;
+      goto TAIL_RECURSE;
+      }
+    /* Control never gets here */
+
+    /* An alternation is the end of a branch; scan along to find the end of the
+    bracketed group and go to there. */
+
+    case OP_ALT:
+    do ecode += GET(ecode,1); while (*ecode == OP_ALT);
+    break;
+
+    /* BRAZERO, BRAMINZERO and SKIPZERO occur just before a bracket group,
+    indicating that it may occur zero times. It may repeat infinitely, or not
+    at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets
+    with fixed upper repeat limits are compiled as a number of copies, with the
+    optional ones preceded by BRAZERO or BRAMINZERO. */
+
+    case OP_BRAZERO:
+      {
+      next = ecode+1;
+      RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10);
+      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+      do next += GET(next,1); while (*next == OP_ALT);
+      ecode = next + 1 + LINK_SIZE;
+      }
+    break;
+
+    case OP_BRAMINZERO:
+      {
+      next = ecode+1;
+      do next += GET(next, 1); while (*next == OP_ALT);
+      RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RM11);
+      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+      ecode++;
+      }
+    break;
+
+    case OP_SKIPZERO:
+      {
+      next = ecode+1;
+      do next += GET(next,1); while (*next == OP_ALT);
+      ecode = next + 1 + LINK_SIZE;
+      }
+    break;
+
+    /* End of a group, repeated or non-repeating. */
+
+    case OP_KET:
+    case OP_KETRMIN:
+    case OP_KETRMAX:
+    prev = ecode - GET(ecode, 1);
+
+    /* If this was a group that remembered the subject start, in order to break
+    infinite repeats of empty string matches, retrieve the subject start from
+    the chain. Otherwise, set it NULL. */
+
+    if (*prev >= OP_SBRA)
+      {
+      saved_eptr = eptrb->epb_saved_eptr;   /* Value at start of group */
+      eptrb = eptrb->epb_prev;              /* Backup to previous group */
+      }
+    else saved_eptr = NULL;
+
+    /* If we are at the end of an assertion group, stop matching and return
+    MATCH_MATCH, but record the current high water mark for use by positive
+    assertions. Do this also for the "once" (atomic) groups. */
+
+    if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
+        *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
+        *prev == OP_ONCE)
+      {
+      md->end_match_ptr = eptr;      /* For ONCE */
+      md->end_offset_top = offset_top;
+      RRETURN(MATCH_MATCH);
+      }
+
+    /* For capturing groups we have to check the group number back at the start
+    and if necessary complete handling an extraction by setting the offsets and
+    bumping the high water mark. Note that whole-pattern recursion is coded as
+    a recurse into group 0, so it won't be picked up here. Instead, we catch it
+    when the OP_END is reached. Other recursion is handled here. */
+
+    if (*prev == OP_CBRA || *prev == OP_SCBRA)
+      {
+      number = GET2(prev, 1+LINK_SIZE);
+      offset = number << 1;
+
+#ifdef DEBUG
+      printf("end bracket %d", number);
+      printf("\n");
+#endif
+
+      md->capture_last = number;
+      if (offset >= md->offset_max) md->offset_overflow = TRUE; else
+        {
+        md->offset_vector[offset] =
+          md->offset_vector[md->offset_end - number];
+        md->offset_vector[offset+1] = eptr - md->start_subject;
+        if (offset_top <= offset) offset_top = offset + 2;
+        }
+
+      /* Handle a recursively called group. Restore the offsets
+      appropriately and continue from after the call. */
+
+      if (md->recursive != NULL && md->recursive->group_num == number)
+        {
+        recursion_info *rec = md->recursive;
+        DPRINTF(("Recursion (%d) succeeded - continuing\n", number));
+        md->recursive = rec->prevrec;
+        mstart = rec->save_start;
+        memcpy(md->offset_vector, rec->offset_save,
+          rec->saved_max * sizeof(int));
+        ecode = rec->after_call;
+        ims = original_ims;
+        break;
+        }
+      }
+
+    /* For both capturing and non-capturing groups, reset the value of the ims
+    flags, in case they got changed during the group. */
+
+    ims = original_ims;
+    DPRINTF(("ims reset to %02lx\n", ims));
+
+    /* For a non-repeating ket, just continue at this level. This also
+    happens for a repeating ket if no characters were matched in the group.
+    This is the forcible breaking of infinite loops as implemented in Perl
+    5.005. If there is an options reset, it will get obeyed in the normal
+    course of events. */
+
+    if (*ecode == OP_KET || eptr == saved_eptr)
+      {
+      ecode += 1 + LINK_SIZE;
+      break;
+      }
+
+    /* The repeating kets try the rest of the pattern or restart from the
+    preceding bracket, in the appropriate order. In the second case, we can use
+    tail recursion to avoid using another stack frame, unless we have an
+    unlimited repeat of a group that can match an empty string. */
+
+    flags = (*prev >= OP_SBRA)? match_cbegroup : 0;
+
+    if (*ecode == OP_KETRMIN)
+      {
+      RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12);
+      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+      if (flags != 0)    /* Could match an empty string */
+        {
+        RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50);
+        RRETURN(rrc);
+        }
+      ecode = prev;
+      goto TAIL_RECURSE;
+      }
+    else  /* OP_KETRMAX */
+      {
+      RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13);
+      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+      ecode += 1 + LINK_SIZE;
+      flags = 0;
+      goto TAIL_RECURSE;
+      }
+    /* Control never gets here */
+
+    /* Start of subject unless notbol, or after internal newline if multiline */
+
+    case OP_CIRC:
+    if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
+    if ((ims & PCRE_MULTILINE) != 0)
+      {
+      if (eptr != md->start_subject &&
+          (eptr == md->end_subject || !WAS_NEWLINE(eptr)))
+        RRETURN(MATCH_NOMATCH);
+      ecode++;
+      break;
+      }
+    /* ... else fall through */
+
+    /* Start of subject assertion */
+
+    case OP_SOD:
+    if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    /* Start of match assertion */
+
+    case OP_SOM:
+    if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    /* Reset the start of match point */
+
+    case OP_SET_SOM:
+    mstart = eptr;
+    ecode++;
+    break;
+
+    /* Assert before internal newline if multiline, or before a terminating
+    newline unless endonly is set, else end of subject unless noteol is set. */
+
+    case OP_DOLL:
+    if ((ims & PCRE_MULTILINE) != 0)
+      {
+      if (eptr < md->end_subject)
+        { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }
+      else
+        { if (md->noteol) RRETURN(MATCH_NOMATCH); }
+      ecode++;
+      break;
+      }
+    else
+      {
+      if (md->noteol) RRETURN(MATCH_NOMATCH);
+      if (!md->endonly)
+        {
+        if (eptr != md->end_subject &&
+            (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
+          RRETURN(MATCH_NOMATCH);
+        ecode++;
+        break;
+        }
+      }
+    /* ... else fall through for endonly */
+
+    /* End of subject assertion (\z) */
+
+    case OP_EOD:
+    if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    /* End of subject or ending \n assertion (\Z) */
+
+    case OP_EODN:
+    if (eptr != md->end_subject &&
+        (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
+      RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    /* Word boundary assertions */
+
+    case OP_NOT_WORD_BOUNDARY:
+    case OP_WORD_BOUNDARY:
+      {
+
+      /* Find out if the previous and current characters are "word" characters.
+      It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to
+      be "non-word" characters. */
+
+#ifdef SUPPORT_UTF8
+      if (utf8)
+        {
+        if (eptr == md->start_subject) prev_is_word = FALSE; else
+          {
+          const uschar *lastptr = eptr - 1;
+          while((*lastptr & 0xc0) == 0x80) lastptr--;
+          GETCHAR(c, lastptr);
+          prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
+          }
+        if (eptr >= md->end_subject) cur_is_word = FALSE; else
+          {
+          GETCHAR(c, eptr);
+          cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
+          }
+        }
+      else
+#endif
+
+      /* More streamlined when not in UTF-8 mode */
+
+        {
+        prev_is_word = (eptr != md->start_subject) &&
+          ((md->ctypes[eptr[-1]] & ctype_word) != 0);
+        cur_is_word = (eptr < md->end_subject) &&
+          ((md->ctypes[*eptr] & ctype_word) != 0);
+        }
+
+      /* Now see if the situation is what we want */
+
+      if ((*ecode++ == OP_WORD_BOUNDARY)?
+           cur_is_word == prev_is_word : cur_is_word != prev_is_word)
+        RRETURN(MATCH_NOMATCH);
+      }
+    break;
+
+    /* Match a single character type; inline for speed */
+
+    case OP_ANY:
+    if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
+    /* Fall through */
+
+    case OP_ALLANY:
+    if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+    ecode++;
+    break;
+
+    /* Match a single byte, even in UTF-8 mode. This opcode really does match
+    any byte, even newline, independent of the setting of PCRE_DOTALL. */
+
+    case OP_ANYBYTE:
+    if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    case OP_NOT_DIGIT:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    if (
+#ifdef SUPPORT_UTF8
+       c < 256 &&
+#endif
+       (md->ctypes[c] & ctype_digit) != 0
+       )
+      RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    case OP_DIGIT:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    if (
+#ifdef SUPPORT_UTF8
+       c >= 256 ||
+#endif
+       (md->ctypes[c] & ctype_digit) == 0
+       )
+      RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    case OP_NOT_WHITESPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    if (
+#ifdef SUPPORT_UTF8
+       c < 256 &&
+#endif
+       (md->ctypes[c] & ctype_space) != 0
+       )
+      RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    case OP_WHITESPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    if (
+#ifdef SUPPORT_UTF8
+       c >= 256 ||
+#endif
+       (md->ctypes[c] & ctype_space) == 0
+       )
+      RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    case OP_NOT_WORDCHAR:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    if (
+#ifdef SUPPORT_UTF8
+       c < 256 &&
+#endif
+       (md->ctypes[c] & ctype_word) != 0
+       )
+      RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    case OP_WORDCHAR:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    if (
+#ifdef SUPPORT_UTF8
+       c >= 256 ||
+#endif
+       (md->ctypes[c] & ctype_word) == 0
+       )
+      RRETURN(MATCH_NOMATCH);
+    ecode++;
+    break;
+
+    case OP_ANYNL:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: RRETURN(MATCH_NOMATCH);
+      case 0x000d:
+      if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+      break;
+
+      case 0x000a:
+      break;
+
+      case 0x000b:
+      case 0x000c:
+      case 0x0085:
+      case 0x2028:
+      case 0x2029:
+      if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+      break;
+      }
+    ecode++;
+    break;
+
+    case OP_NOT_HSPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: break;
+      case 0x09:      /* HT */
+      case 0x20:      /* SPACE */
+      case 0xa0:      /* NBSP */
+      case 0x1680:    /* OGHAM SPACE MARK */
+      case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+      case 0x2000:    /* EN QUAD */
+      case 0x2001:    /* EM QUAD */
+      case 0x2002:    /* EN SPACE */
+      case 0x2003:    /* EM SPACE */
+      case 0x2004:    /* THREE-PER-EM SPACE */
+      case 0x2005:    /* FOUR-PER-EM SPACE */
+      case 0x2006:    /* SIX-PER-EM SPACE */
+      case 0x2007:    /* FIGURE SPACE */
+      case 0x2008:    /* PUNCTUATION SPACE */
+      case 0x2009:    /* THIN SPACE */
+      case 0x200A:    /* HAIR SPACE */
+      case 0x202f:    /* NARROW NO-BREAK SPACE */
+      case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+      case 0x3000:    /* IDEOGRAPHIC SPACE */
+      RRETURN(MATCH_NOMATCH);
+      }
+    ecode++;
+    break;
+
+    case OP_HSPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: RRETURN(MATCH_NOMATCH);
+      case 0x09:      /* HT */
+      case 0x20:      /* SPACE */
+      case 0xa0:      /* NBSP */
+      case 0x1680:    /* OGHAM SPACE MARK */
+      case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+      case 0x2000:    /* EN QUAD */
+      case 0x2001:    /* EM QUAD */
+      case 0x2002:    /* EN SPACE */
+      case 0x2003:    /* EM SPACE */
+      case 0x2004:    /* THREE-PER-EM SPACE */
+      case 0x2005:    /* FOUR-PER-EM SPACE */
+      case 0x2006:    /* SIX-PER-EM SPACE */
+      case 0x2007:    /* FIGURE SPACE */
+      case 0x2008:    /* PUNCTUATION SPACE */
+      case 0x2009:    /* THIN SPACE */
+      case 0x200A:    /* HAIR SPACE */
+      case 0x202f:    /* NARROW NO-BREAK SPACE */
+      case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+      case 0x3000:    /* IDEOGRAPHIC SPACE */
+      break;
+      }
+    ecode++;
+    break;
+
+    case OP_NOT_VSPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: break;
+      case 0x0a:      /* LF */
+      case 0x0b:      /* VT */
+      case 0x0c:      /* FF */
+      case 0x0d:      /* CR */
+      case 0x85:      /* NEL */
+      case 0x2028:    /* LINE SEPARATOR */
+      case 0x2029:    /* PARAGRAPH SEPARATOR */
+      RRETURN(MATCH_NOMATCH);
+      }
+    ecode++;
+    break;
+
+    case OP_VSPACE:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+    switch(c)
+      {
+      default: RRETURN(MATCH_NOMATCH);
+      case 0x0a:      /* LF */
+      case 0x0b:      /* VT */
+      case 0x0c:      /* FF */
+      case 0x0d:      /* CR */
+      case 0x85:      /* NEL */
+      case 0x2028:    /* LINE SEPARATOR */
+      case 0x2029:    /* PARAGRAPH SEPARATOR */
+      break;
+      }
+    ecode++;
+    break;
+
+#ifdef SUPPORT_UCP
+    /* Check the next character by Unicode property. We will get here only
+    if the support is in the binary; otherwise a compile-time error occurs. */
+
+    case OP_PROP:
+    case OP_NOTPROP:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+      {
+      const ucd_record * prop = GET_UCD(c);
+
+      switch(ecode[1])
+        {
+        case PT_ANY:
+        if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);
+        break;
+
+        case PT_LAMP:
+        if ((prop->chartype == ucp_Lu ||
+             prop->chartype == ucp_Ll ||
+             prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
+          RRETURN(MATCH_NOMATCH);
+         break;
+
+        case PT_GC:
+        if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))
+          RRETURN(MATCH_NOMATCH);
+        break;
+
+        case PT_PC:
+        if ((ecode[2] != prop->chartype) == (op == OP_PROP))
+          RRETURN(MATCH_NOMATCH);
+        break;
+
+        case PT_SC:
+        if ((ecode[2] != prop->script) == (op == OP_PROP))
+          RRETURN(MATCH_NOMATCH);
+        break;
+
+        default:
+        RRETURN(PCRE_ERROR_INTERNAL);
+        }
+
+      ecode += 3;
+      }
+    break;
+
+    /* Match an extended Unicode sequence. We will get here only if the support
+    is in the binary; otherwise a compile-time error occurs. */
+
+    case OP_EXTUNI:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    GETCHARINCTEST(c, eptr);
+      {
+      int category = UCD_CATEGORY(c);
+      if (category == ucp_M) RRETURN(MATCH_NOMATCH);
+      while (eptr < md->end_subject)
+        {
+        int len = 1;
+        if (!utf8) c = *eptr; else
+          {
+          GETCHARLEN(c, eptr, len);
+          }
+        category = UCD_CATEGORY(c);
+        if (category != ucp_M) break;
+        eptr += len;
+        }
+      }
+    ecode++;
+    break;
+#endif
+
+
+    /* Match a back reference, possibly repeatedly. Look past the end of the
+    item to see if there is repeat information following. The code is similar
+    to that for character classes, but repeated for efficiency. Then obey
+    similar code to character type repeats - written out again for speed.
+    However, if the referenced string is the empty string, always treat
+    it as matched, any number of times (otherwise there could be infinite
+    loops). */
+
+    case OP_REF:
+      {
+      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */
+      ecode += 3;
+
+      /* If the reference is unset, there are two possibilities:
+
+      (a) In the default, Perl-compatible state, set the length to be longer
+      than the amount of subject left; this ensures that every attempt at a
+      match fails. We can't just fail here, because of the possibility of
+      quantifiers with zero minima.
+
+      (b) If the JavaScript compatibility flag is set, set the length to zero
+      so that the back reference matches an empty string.
+
+      Otherwise, set the length to the length of what was matched by the
+      referenced subpattern. */
+
+      if (offset >= offset_top || md->offset_vector[offset] < 0)
+        length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1;
+      else
+        length = md->offset_vector[offset+1] - md->offset_vector[offset];
+
+      /* Set up for repetition, or handle the non-repeated case */
+
+      switch (*ecode)
+        {
+        case OP_CRSTAR:
+        case OP_CRMINSTAR:
+        case OP_CRPLUS:
+        case OP_CRMINPLUS:
+        case OP_CRQUERY:
+        case OP_CRMINQUERY:
+        c = *ecode++ - OP_CRSTAR;
+        minimize = (c & 1) != 0;
+        min = rep_min[c];                 /* Pick up values from tables; */
+        max = rep_max[c];                 /* zero for max => infinity */
+        if (max == 0) max = INT_MAX;
+        break;
+
+        case OP_CRRANGE:
+        case OP_CRMINRANGE:
+        minimize = (*ecode == OP_CRMINRANGE);
+        min = GET2(ecode, 1);
+        max = GET2(ecode, 3);
+        if (max == 0) max = INT_MAX;
+        ecode += 5;
+        break;
+
+        default:               /* No repeat follows */
+        if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);
+        eptr += length;
+        continue;              /* With the main loop */
+        }
+
+      /* If the length of the reference is zero, just continue with the
+      main loop. */
+
+      if (length == 0) continue;
+
+      /* First, ensure the minimum number of matches are present. We get back
+      the length of the reference string explicitly rather than passing the
+      address of eptr, so that eptr can be a register variable. */
+
+      for (i = 1; i <= min; i++)
+        {
+        if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);
+        eptr += length;
+        }
+
+      /* If min = max, continue at the same level without recursion.
+      They are not both allowed to be zero. */
+
+      if (min == max) continue;
+
+      /* If minimizing, keep trying and advancing the pointer */
+
+      if (minimize)
+        {
+        for (fi = min;; fi++)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (fi >= max || !match_ref(offset, eptr, length, md, ims))
+            RRETURN(MATCH_NOMATCH);
+          eptr += length;
+          }
+        /* Control never gets here */
+        }
+
+      /* If maximizing, find the longest string and work backwards */
+
+      else
+        {
+        pp = eptr;
+        for (i = min; i < max; i++)
+          {
+          if (!match_ref(offset, eptr, length, md, ims)) break;
+          eptr += length;
+          }
+        while (eptr >= pp)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          eptr -= length;
+          }
+        RRETURN(MATCH_NOMATCH);
+        }
+      }
+    /* Control never gets here */
+
+
+
+    /* Match a bit-mapped character class, possibly repeatedly. This op code is
+    used when all the characters in the class have values in the range 0-255,
+    and either the matching is caseful, or the characters are in the range
+    0-127 when UTF-8 processing is enabled. The only difference between
+    OP_CLASS and OP_NCLASS occurs when a data character outside the range is
+    encountered.
+
+    First, look past the end of the item to see if there is repeat information
+    following. Then obey similar code to character type repeats - written out
+    again for speed. */
+
+    case OP_NCLASS:
+    case OP_CLASS:
+      {
+      data = ecode + 1;                /* Save for matching */
+      ecode += 33;                     /* Advance past the item */
+
+      switch (*ecode)
+        {
+        case OP_CRSTAR:
+        case OP_CRMINSTAR:
+        case OP_CRPLUS:
+        case OP_CRMINPLUS:
+        case OP_CRQUERY:
+        case OP_CRMINQUERY:
+        c = *ecode++ - OP_CRSTAR;
+        minimize = (c & 1) != 0;
+        min = rep_min[c];                 /* Pick up values from tables; */
+        max = rep_max[c];                 /* zero for max => infinity */
+        if (max == 0) max = INT_MAX;
+        break;
+
+        case OP_CRRANGE:
+        case OP_CRMINRANGE:
+        minimize = (*ecode == OP_CRMINRANGE);
+        min = GET2(ecode, 1);
+        max = GET2(ecode, 3);
+        if (max == 0) max = INT_MAX;
+        ecode += 5;
+        break;
+
+        default:               /* No repeat follows */
+        min = max = 1;
+        break;
+        }
+
+      /* First, ensure the minimum number of matches are present. */
+
+#ifdef SUPPORT_UTF8
+      /* UTF-8 mode */
+      if (utf8)
+        {
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          if (c > 255)
+            {
+            if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
+            }
+          else
+            {
+            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
+            }
+          }
+        }
+      else
+#endif
+      /* Not UTF-8 mode */
+        {
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          c = *eptr++;
+          if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
+          }
+        }
+
+      /* If max == min we can continue with the main loop without the
+      need to recurse. */
+
+      if (min == max) continue;
+
+      /* If minimizing, keep testing the rest of the expression and advancing
+      the pointer while it matches the class. */
+
+      if (minimize)
+        {
+#ifdef SUPPORT_UTF8
+        /* UTF-8 mode */
+        if (utf8)
+          {
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINC(c, eptr);
+            if (c > 255)
+              {
+              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
+              }
+            else
+              {
+              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
+              }
+            }
+          }
+        else
+#endif
+        /* Not UTF-8 mode */
+          {
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            c = *eptr++;
+            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
+            }
+          }
+        /* Control never gets here */
+        }
+
+      /* If maximizing, find the longest possible run, then work backwards. */
+
+      else
+        {
+        pp = eptr;
+
+#ifdef SUPPORT_UTF8
+        /* UTF-8 mode */
+        if (utf8)
+          {
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (c > 255)
+              {
+              if (op == OP_CLASS) break;
+              }
+            else
+              {
+              if ((data[c/8] & (1 << (c&7))) == 0) break;
+              }
+            eptr += len;
+            }
+          for (;;)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (eptr-- == pp) break;        /* Stop if tried at original pos */
+            BACKCHAR(eptr);
+            }
+          }
+        else
+#endif
+          /* Not UTF-8 mode */
+          {
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if ((data[c/8] & (1 << (c&7))) == 0) break;
+            eptr++;
+            }
+          while (eptr >= pp)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            eptr--;
+            }
+          }
+
+        RRETURN(MATCH_NOMATCH);
+        }
+      }
+    /* Control never gets here */
+
+
+    /* Match an extended character class. This opcode is encountered only
+    in UTF-8 mode, because that's the only time it is compiled. */
+
+#ifdef SUPPORT_UTF8
+    case OP_XCLASS:
+      {
+      data = ecode + 1 + LINK_SIZE;                /* Save for matching */
+      ecode += GET(ecode, 1);                      /* Advance past the item */
+
+      switch (*ecode)
+        {
+        case OP_CRSTAR:
+        case OP_CRMINSTAR:
+        case OP_CRPLUS:
+        case OP_CRMINPLUS:
+        case OP_CRQUERY:
+        case OP_CRMINQUERY:
+        c = *ecode++ - OP_CRSTAR;
+        minimize = (c & 1) != 0;
+        min = rep_min[c];                 /* Pick up values from tables; */
+        max = rep_max[c];                 /* zero for max => infinity */
+        if (max == 0) max = INT_MAX;
+        break;
+
+        case OP_CRRANGE:
+        case OP_CRMINRANGE:
+        minimize = (*ecode == OP_CRMINRANGE);
+        min = GET2(ecode, 1);
+        max = GET2(ecode, 3);
+        if (max == 0) max = INT_MAX;
+        ecode += 5;
+        break;
+
+        default:               /* No repeat follows */
+        min = max = 1;
+        break;
+        }
+
+      /* First, ensure the minimum number of matches are present. */
+
+      for (i = 1; i <= min; i++)
+        {
+        if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+        GETCHARINC(c, eptr);
+        if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
+        }
+
+      /* If max == min we can continue with the main loop without the
+      need to recurse. */
+
+      if (min == max) continue;
+
+      /* If minimizing, keep testing the rest of the expression and advancing
+      the pointer while it matches the class. */
+
+      if (minimize)
+        {
+        for (fi = min;; fi++)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
+          }
+        /* Control never gets here */
+        }
+
+      /* If maximizing, find the longest possible run, then work backwards. */
+
+      else
+        {
+        pp = eptr;
+        for (i = min; i < max; i++)
+          {
+          int len = 1;
+          if (eptr >= md->end_subject) break;
+          GETCHARLEN(c, eptr, len);
+          if (!_pcre_xclass(c, data)) break;
+          eptr += len;
+          }
+        for(;;)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (eptr-- == pp) break;        /* Stop if tried at original pos */
+          if (utf8) BACKCHAR(eptr);
+          }
+        RRETURN(MATCH_NOMATCH);
+        }
+
+      /* Control never gets here */
+      }
+#endif    /* End of XCLASS */
+
+    /* Match a single character, casefully */
+
+    case OP_CHAR:
+#ifdef SUPPORT_UTF8
+    if (utf8)
+      {
+      length = 1;
+      ecode++;
+      GETCHARLEN(fc, ecode, length);
+      if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
+      while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
+      }
+    else
+#endif
+
+    /* Non-UTF-8 mode */
+      {
+      if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);
+      if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
+      ecode += 2;
+      }
+    break;
+
+    /* Match a single character, caselessly */
+
+    case OP_CHARNC:
+#ifdef SUPPORT_UTF8
+    if (utf8)
+      {
+      length = 1;
+      ecode++;
+      GETCHARLEN(fc, ecode, length);
+
+      if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
+
+      /* If the pattern character's value is < 128, we have only one byte, and
+      can use the fast lookup table. */
+
+      if (fc < 128)
+        {
+        if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+        }
+
+      /* Otherwise we must pick up the subject character */
+
+      else
+        {
+        unsigned int dc;
+        GETCHARINC(dc, eptr);
+        ecode += length;
+
+        /* If we have Unicode property support, we can use it to test the other
+        case of the character, if there is one. */
+
+        if (fc != dc)
+          {
+#ifdef SUPPORT_UCP
+          if (dc != UCD_OTHERCASE(fc))
+#endif
+            RRETURN(MATCH_NOMATCH);
+          }
+        }
+      }
+    else
+#endif   /* SUPPORT_UTF8 */
+
+    /* Non-UTF-8 mode */
+      {
+      if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);
+      if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+      ecode += 2;
+      }
+    break;
+
+    /* Match a single character repeatedly. */
+
+    case OP_EXACT:
+    min = max = GET2(ecode, 1);
+    ecode += 3;
+    goto REPEATCHAR;
+
+    case OP_POSUPTO:
+    possessive = TRUE;
+    /* Fall through */
+
+    case OP_UPTO:
+    case OP_MINUPTO:
+    min = 0;
+    max = GET2(ecode, 1);
+    minimize = *ecode == OP_MINUPTO;
+    ecode += 3;
+    goto REPEATCHAR;
+
+    case OP_POSSTAR:
+    possessive = TRUE;
+    min = 0;
+    max = INT_MAX;
+    ecode++;
+    goto REPEATCHAR;
+
+    case OP_POSPLUS:
+    possessive = TRUE;
+    min = 1;
+    max = INT_MAX;
+    ecode++;
+    goto REPEATCHAR;
+
+    case OP_POSQUERY:
+    possessive = TRUE;
+    min = 0;
+    max = 1;
+    ecode++;
+    goto REPEATCHAR;
+
+    case OP_STAR:
+    case OP_MINSTAR:
+    case OP_PLUS:
+    case OP_MINPLUS:
+    case OP_QUERY:
+    case OP_MINQUERY:
+    c = *ecode++ - OP_STAR;
+    minimize = (c & 1) != 0;
+    min = rep_min[c];                 /* Pick up values from tables; */
+    max = rep_max[c];                 /* zero for max => infinity */
+    if (max == 0) max = INT_MAX;
+
+    /* Common code for all repeated single-character matches. We can give
+    up quickly if there are fewer than the minimum number of characters left in
+    the subject. */
+
+    REPEATCHAR:
+#ifdef SUPPORT_UTF8
+    if (utf8)
+      {
+      length = 1;
+      charptr = ecode;
+      GETCHARLEN(fc, ecode, length);
+      if (min * length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
+      ecode += length;
+
+      /* Handle multibyte character matching specially here. There is
+      support for caseless matching if UCP support is present. */
+
+      if (length > 1)
+        {
+#ifdef SUPPORT_UCP
+        unsigned int othercase;
+        if ((ims & PCRE_CASELESS) != 0 &&
+            (othercase = UCD_OTHERCASE(fc)) != fc)
+          oclength = _pcre_ord2utf8(othercase, occhars);
+        else oclength = 0;
+#endif  /* SUPPORT_UCP */
+
+        for (i = 1; i <= min; i++)
+          {
+          if (memcmp(eptr, charptr, length) == 0) eptr += length;
+#ifdef SUPPORT_UCP
+          /* Need braces because of following else */
+          else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }
+          else
+            {
+            if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);
+            eptr += oclength;
+            }
+#else   /* without SUPPORT_UCP */
+          else { RRETURN(MATCH_NOMATCH); }
+#endif  /* SUPPORT_UCP */
+          }
+
+        if (min == max) continue;
+
+        if (minimize)
+          {
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            if (memcmp(eptr, charptr, length) == 0) eptr += length;
+#ifdef SUPPORT_UCP
+            /* Need braces because of following else */
+            else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }
+            else
+              {
+              if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);
+              eptr += oclength;
+              }
+#else   /* without SUPPORT_UCP */
+            else { RRETURN (MATCH_NOMATCH); }
+#endif  /* SUPPORT_UCP */
+            }
+          /* Control never gets here */
+          }
+
+        else  /* Maximize */
+          {
+          pp = eptr;
+          for (i = min; i < max; i++)
+            {
+            if (eptr > md->end_subject - length) break;
+            if (memcmp(eptr, charptr, length) == 0) eptr += length;
+#ifdef SUPPORT_UCP
+            else if (oclength == 0) break;
+            else
+              {
+              if (memcmp(eptr, occhars, oclength) != 0) break;
+              eptr += oclength;
+              }
+#else   /* without SUPPORT_UCP */
+            else break;
+#endif  /* SUPPORT_UCP */
+            }
+
+          if (possessive) continue;
+          for(;;)
+           {
+           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23);
+           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+           if (eptr == pp) RRETURN(MATCH_NOMATCH);
+#ifdef SUPPORT_UCP
+           eptr--;
+           BACKCHAR(eptr);
+#else   /* without SUPPORT_UCP */
+           eptr -= length;
+#endif  /* SUPPORT_UCP */
+           }
+          }
+        /* Control never gets here */
+        }
+
+      /* If the length of a UTF-8 character is 1, we fall through here, and
+      obey the code as for non-UTF-8 characters below, though in this case the
+      value of fc will always be < 128. */
+      }
+    else
+#endif  /* SUPPORT_UTF8 */
+
+    /* When not in UTF-8 mode, load a single-byte character. */
+      {
+      if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
+      fc = *ecode++;
+      }
+
+    /* The value of fc at this point is always less than 256, though we may or
+    may not be in UTF-8 mode. The code is duplicated for the caseless and
+    caseful cases, for speed, since matching characters is likely to be quite
+    common. First, ensure the minimum number of matches are present. If min =
+    max, continue at the same level without recursing. Otherwise, if
+    minimizing, keep trying the rest of the expression and advancing one
+    matching character if failing, up to the maximum. Alternatively, if
+    maximizing, find the maximum number of characters and work backwards. */
+
+    DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
+      max, eptr));
+
+    if ((ims & PCRE_CASELESS) != 0)
+      {
+      fc = md->lcc[fc];
+      for (i = 1; i <= min; i++)
+        if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+      if (min == max) continue;
+      if (minimize)
+        {
+        for (fi = min;; fi++)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (fi >= max || eptr >= md->end_subject ||
+              fc != md->lcc[*eptr++])
+            RRETURN(MATCH_NOMATCH);
+          }
+        /* Control never gets here */
+        }
+      else  /* Maximize */
+        {
+        pp = eptr;
+        for (i = min; i < max; i++)
+          {
+          if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break;
+          eptr++;
+          }
+        if (possessive) continue;
+        while (eptr >= pp)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25);
+          eptr--;
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          }
+        RRETURN(MATCH_NOMATCH);
+        }
+      /* Control never gets here */
+      }
+
+    /* Caseful comparisons (includes all multi-byte characters) */
+
+    else
+      {
+      for (i = 1; i <= min; i++) if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
+      if (min == max) continue;
+      if (minimize)
+        {
+        for (fi = min;; fi++)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (fi >= max || eptr >= md->end_subject || fc != *eptr++)
+            RRETURN(MATCH_NOMATCH);
+          }
+        /* Control never gets here */
+        }
+      else  /* Maximize */
+        {
+        pp = eptr;
+        for (i = min; i < max; i++)
+          {
+          if (eptr >= md->end_subject || fc != *eptr) break;
+          eptr++;
+          }
+        if (possessive) continue;
+        while (eptr >= pp)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27);
+          eptr--;
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          }
+        RRETURN(MATCH_NOMATCH);
+        }
+      }
+    /* Control never gets here */
+
+    /* Match a negated single one-byte character. The character we are
+    checking can be multibyte. */
+
+    case OP_NOT:
+    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+    ecode++;
+    GETCHARINCTEST(c, eptr);
+    if ((ims & PCRE_CASELESS) != 0)
+      {
+#ifdef SUPPORT_UTF8
+      if (c < 256)
+#endif
+      c = md->lcc[c];
+      if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH);
+      }
+    else
+      {
+      if (*ecode++ == c) RRETURN(MATCH_NOMATCH);
+      }
+    break;
+
+    /* Match a negated single one-byte character repeatedly. This is almost a
+    repeat of the code for a repeated single character, but I haven't found a
+    nice way of commoning these up that doesn't require a test of the
+    positive/negative option for each character match. Maybe that wouldn't add
+    very much to the time taken, but character matching *is* what this is all
+    about... */
+
+    case OP_NOTEXACT:
+    min = max = GET2(ecode, 1);
+    ecode += 3;
+    goto REPEATNOTCHAR;
+
+    case OP_NOTUPTO:
+    case OP_NOTMINUPTO:
+    min = 0;
+    max = GET2(ecode, 1);
+    minimize = *ecode == OP_NOTMINUPTO;
+    ecode += 3;
+    goto REPEATNOTCHAR;
+
+    case OP_NOTPOSSTAR:
+    possessive = TRUE;
+    min = 0;
+    max = INT_MAX;
+    ecode++;
+    goto REPEATNOTCHAR;
+
+    case OP_NOTPOSPLUS:
+    possessive = TRUE;
+    min = 1;
+    max = INT_MAX;
+    ecode++;
+    goto REPEATNOTCHAR;
+
+    case OP_NOTPOSQUERY:
+    possessive = TRUE;
+    min = 0;
+    max = 1;
+    ecode++;
+    goto REPEATNOTCHAR;
+
+    case OP_NOTPOSUPTO:
+    possessive = TRUE;
+    min = 0;
+    max = GET2(ecode, 1);
+    ecode += 3;
+    goto REPEATNOTCHAR;
+
+    case OP_NOTSTAR:
+    case OP_NOTMINSTAR:
+    case OP_NOTPLUS:
+    case OP_NOTMINPLUS:
+    case OP_NOTQUERY:
+    case OP_NOTMINQUERY:
+    c = *ecode++ - OP_NOTSTAR;
+    minimize = (c & 1) != 0;
+    min = rep_min[c];                 /* Pick up values from tables; */
+    max = rep_max[c];                 /* zero for max => infinity */
+    if (max == 0) max = INT_MAX;
+
+    /* Common code for all repeated single-byte matches. We can give up quickly
+    if there are fewer than the minimum number of bytes left in the
+    subject. */
+
+    REPEATNOTCHAR:
+    if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
+    fc = *ecode++;
+
+    /* The code is duplicated for the caseless and caseful cases, for speed,
+    since matching characters is likely to be quite common. First, ensure the
+    minimum number of matches are present. If min = max, continue at the same
+    level without recursing. Otherwise, if minimizing, keep trying the rest of
+    the expression and advancing one matching character if failing, up to the
+    maximum. Alternatively, if maximizing, find the maximum number of
+    characters and work backwards. */
+
+    DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,
+      max, eptr));
+
+    if ((ims & PCRE_CASELESS) != 0)
+      {
+      fc = md->lcc[fc];
+
+#ifdef SUPPORT_UTF8
+      /* UTF-8 mode */
+      if (utf8)
+        {
+        register unsigned int d;
+        for (i = 1; i <= min; i++)
+          {
+          GETCHARINC(d, eptr);
+          if (d < 256) d = md->lcc[d];
+          if (fc == d) RRETURN(MATCH_NOMATCH);
+          }
+        }
+      else
+#endif
+
+      /* Not UTF-8 mode */
+        {
+        for (i = 1; i <= min; i++)
+          if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+        }
+
+      if (min == max) continue;
+
+      if (minimize)
+        {
+#ifdef SUPPORT_UTF8
+        /* UTF-8 mode */
+        if (utf8)
+          {
+          register unsigned int d;
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINC(d, eptr);
+            if (d < 256) d = md->lcc[d];
+            if (fc == d) RRETURN(MATCH_NOMATCH);
+
+            }
+          }
+        else
+#endif
+        /* Not UTF-8 mode */
+          {
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++])
+              RRETURN(MATCH_NOMATCH);
+            }
+          }
+        /* Control never gets here */
+        }
+
+      /* Maximize case */
+
+      else
+        {
+        pp = eptr;
+
+#ifdef SUPPORT_UTF8
+        /* UTF-8 mode */
+        if (utf8)
+          {
+          register unsigned int d;
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(d, eptr, len);
+            if (d < 256) d = md->lcc[d];
+            if (fc == d) break;
+            eptr += len;
+            }
+        if (possessive) continue;
+        for(;;)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (eptr-- == pp) break;        /* Stop if tried at original pos */
+            BACKCHAR(eptr);
+            }
+          }
+        else
+#endif
+        /* Not UTF-8 mode */
+          {
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break;
+            eptr++;
+            }
+          if (possessive) continue;
+          while (eptr >= pp)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            eptr--;
+            }
+          }
+
+        RRETURN(MATCH_NOMATCH);
+        }
+      /* Control never gets here */
+      }
+
+    /* Caseful comparisons */
+
+    else
+      {
+#ifdef SUPPORT_UTF8
+      /* UTF-8 mode */
+      if (utf8)
+        {
+        register unsigned int d;
+        for (i = 1; i <= min; i++)
+          {
+          GETCHARINC(d, eptr);
+          if (fc == d) RRETURN(MATCH_NOMATCH);
+          }
+        }
+      else
+#endif
+      /* Not UTF-8 mode */
+        {
+        for (i = 1; i <= min; i++)
+          if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
+        }
+
+      if (min == max) continue;
+
+      if (minimize)
+        {
+#ifdef SUPPORT_UTF8
+        /* UTF-8 mode */
+        if (utf8)
+          {
+          register unsigned int d;
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINC(d, eptr);
+            if (fc == d) RRETURN(MATCH_NOMATCH);
+            }
+          }
+        else
+#endif
+        /* Not UTF-8 mode */
+          {
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject || fc == *eptr++)
+              RRETURN(MATCH_NOMATCH);
+            }
+          }
+        /* Control never gets here */
+        }
+
+      /* Maximize case */
+
+      else
+        {
+        pp = eptr;
+
+#ifdef SUPPORT_UTF8
+        /* UTF-8 mode */
+        if (utf8)
+          {
+          register unsigned int d;
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(d, eptr, len);
+            if (fc == d) break;
+            eptr += len;
+            }
+          if (possessive) continue;
+          for(;;)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (eptr-- == pp) break;        /* Stop if tried at original pos */
+            BACKCHAR(eptr);
+            }
+          }
+        else
+#endif
+        /* Not UTF-8 mode */
+          {
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || fc == *eptr) break;
+            eptr++;
+            }
+          if (possessive) continue;
+          while (eptr >= pp)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            eptr--;
+            }
+          }
+
+        RRETURN(MATCH_NOMATCH);
+        }
+      }
+    /* Control never gets here */
+
+    /* Match a single character type repeatedly; several different opcodes
+    share code. This is very similar to the code for single characters, but we
+    repeat it in the interests of efficiency. */
+
+    case OP_TYPEEXACT:
+    min = max = GET2(ecode, 1);
+    minimize = TRUE;
+    ecode += 3;
+    goto REPEATTYPE;
+
+    case OP_TYPEUPTO:
+    case OP_TYPEMINUPTO:
+    min = 0;
+    max = GET2(ecode, 1);
+    minimize = *ecode == OP_TYPEMINUPTO;
+    ecode += 3;
+    goto REPEATTYPE;
+
+    case OP_TYPEPOSSTAR:
+    possessive = TRUE;
+    min = 0;
+    max = INT_MAX;
+    ecode++;
+    goto REPEATTYPE;
+
+    case OP_TYPEPOSPLUS:
+    possessive = TRUE;
+    min = 1;
+    max = INT_MAX;
+    ecode++;
+    goto REPEATTYPE;
+
+    case OP_TYPEPOSQUERY:
+    possessive = TRUE;
+    min = 0;
+    max = 1;
+    ecode++;
+    goto REPEATTYPE;
+
+    case OP_TYPEPOSUPTO:
+    possessive = TRUE;
+    min = 0;
+    max = GET2(ecode, 1);
+    ecode += 3;
+    goto REPEATTYPE;
+
+    case OP_TYPESTAR:
+    case OP_TYPEMINSTAR:
+    case OP_TYPEPLUS:
+    case OP_TYPEMINPLUS:
+    case OP_TYPEQUERY:
+    case OP_TYPEMINQUERY:
+    c = *ecode++ - OP_TYPESTAR;
+    minimize = (c & 1) != 0;
+    min = rep_min[c];                 /* Pick up values from tables; */
+    max = rep_max[c];                 /* zero for max => infinity */
+    if (max == 0) max = INT_MAX;
+
+    /* Common code for all repeated single character type matches. Note that
+    in UTF-8 mode, '.' matches a character of any length, but for the other
+    character types, the valid characters are all one-byte long. */
+
+    REPEATTYPE:
+    ctype = *ecode++;      /* Code for the character type */
+
+#ifdef SUPPORT_UCP
+    if (ctype == OP_PROP || ctype == OP_NOTPROP)
+      {
+      prop_fail_result = ctype == OP_NOTPROP;
+      prop_type = *ecode++;
+      prop_value = *ecode++;
+      }
+    else prop_type = -1;
+#endif
+
+    /* First, ensure the minimum number of matches are present. Use inline
+    code for maximizing the speed, and do the type test once at the start
+    (i.e. keep it out of the loop). Also we can test that there are at least
+    the minimum number of bytes before we start. This isn't as effective in
+    UTF-8 mode, but it does no harm. Separate the UTF-8 code completely as that
+    is tidier. Also separate the UCP code, which can be the same for both UTF-8
+    and single-bytes. */
+
+    if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
+    if (min > 0)
+      {
+#ifdef SUPPORT_UCP
+      if (prop_type >= 0)
+        {
+        switch(prop_type)
+          {
+          case PT_ANY:
+          if (prop_fail_result) RRETURN(MATCH_NOMATCH);
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINCTEST(c, eptr);
+            }
+          break;
+
+          case PT_LAMP:
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINCTEST(c, eptr);
+            prop_chartype = UCD_CHARTYPE(c);
+            if ((prop_chartype == ucp_Lu ||
+                 prop_chartype == ucp_Ll ||
+                 prop_chartype == ucp_Lt) == prop_fail_result)
+              RRETURN(MATCH_NOMATCH);
+            }
+          break;
+
+          case PT_GC:
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == prop_value) == prop_fail_result)
+              RRETURN(MATCH_NOMATCH);
+            }
+          break;
+
+          case PT_PC:
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINCTEST(c, eptr);
+            prop_chartype = UCD_CHARTYPE(c);
+            if ((prop_chartype == prop_value) == prop_fail_result)
+              RRETURN(MATCH_NOMATCH);
+            }
+          break;
+
+          case PT_SC:
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINCTEST(c, eptr);
+            prop_script = UCD_SCRIPT(c);
+            if ((prop_script == prop_value) == prop_fail_result)
+              RRETURN(MATCH_NOMATCH);
+            }
+          break;
+
+          default:
+          RRETURN(PCRE_ERROR_INTERNAL);
+          }
+        }
+
+      /* Match extended Unicode sequences. We will get here only if the
+      support is in the binary; otherwise a compile-time error occurs. */
+
+      else if (ctype == OP_EXTUNI)
+        {
+        for (i = 1; i <= min; i++)
+          {
+          GETCHARINCTEST(c, eptr);
+          prop_category = UCD_CATEGORY(c);
+          if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);
+          while (eptr < md->end_subject)
+            {
+            int len = 1;
+            if (!utf8) c = *eptr; else
+              {
+              GETCHARLEN(c, eptr, len);
+              }
+            prop_category = UCD_CATEGORY(c);
+            if (prop_category != ucp_M) break;
+            eptr += len;
+            }
+          }
+        }
+
+      else
+#endif     /* SUPPORT_UCP */
+
+/* Handle all other cases when the coding is UTF-8 */
+
+#ifdef SUPPORT_UTF8
+      if (utf8) switch(ctype)
+        {
+        case OP_ANY:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject || IS_NEWLINE(eptr))
+            RRETURN(MATCH_NOMATCH);
+          eptr++;
+          while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+          }
+        break;
+
+        case OP_ALLANY:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          eptr++;
+          while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+          }
+        break;
+
+        case OP_ANYBYTE:
+        eptr += min;
+        break;
+
+        case OP_ANYNL:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x000d:
+            if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+            break;
+
+            case 0x000a:
+            break;
+
+            case 0x000b:
+            case 0x000c:
+            case 0x0085:
+            case 0x2028:
+            case 0x2029:
+            if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+            break;
+            }
+          }
+        break;
+
+        case OP_NOT_HSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: break;
+            case 0x09:      /* HT */
+            case 0x20:      /* SPACE */
+            case 0xa0:      /* NBSP */
+            case 0x1680:    /* OGHAM SPACE MARK */
+            case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+            case 0x2000:    /* EN QUAD */
+            case 0x2001:    /* EM QUAD */
+            case 0x2002:    /* EN SPACE */
+            case 0x2003:    /* EM SPACE */
+            case 0x2004:    /* THREE-PER-EM SPACE */
+            case 0x2005:    /* FOUR-PER-EM SPACE */
+            case 0x2006:    /* SIX-PER-EM SPACE */
+            case 0x2007:    /* FIGURE SPACE */
+            case 0x2008:    /* PUNCTUATION SPACE */
+            case 0x2009:    /* THIN SPACE */
+            case 0x200A:    /* HAIR SPACE */
+            case 0x202f:    /* NARROW NO-BREAK SPACE */
+            case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+            case 0x3000:    /* IDEOGRAPHIC SPACE */
+            RRETURN(MATCH_NOMATCH);
+            }
+          }
+        break;
+
+        case OP_HSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x09:      /* HT */
+            case 0x20:      /* SPACE */
+            case 0xa0:      /* NBSP */
+            case 0x1680:    /* OGHAM SPACE MARK */
+            case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+            case 0x2000:    /* EN QUAD */
+            case 0x2001:    /* EM QUAD */
+            case 0x2002:    /* EN SPACE */
+            case 0x2003:    /* EM SPACE */
+            case 0x2004:    /* THREE-PER-EM SPACE */
+            case 0x2005:    /* FOUR-PER-EM SPACE */
+            case 0x2006:    /* SIX-PER-EM SPACE */
+            case 0x2007:    /* FIGURE SPACE */
+            case 0x2008:    /* PUNCTUATION SPACE */
+            case 0x2009:    /* THIN SPACE */
+            case 0x200A:    /* HAIR SPACE */
+            case 0x202f:    /* NARROW NO-BREAK SPACE */
+            case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+            case 0x3000:    /* IDEOGRAPHIC SPACE */
+            break;
+            }
+          }
+        break;
+
+        case OP_NOT_VSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: break;
+            case 0x0a:      /* LF */
+            case 0x0b:      /* VT */
+            case 0x0c:      /* FF */
+            case 0x0d:      /* CR */
+            case 0x85:      /* NEL */
+            case 0x2028:    /* LINE SEPARATOR */
+            case 0x2029:    /* PARAGRAPH SEPARATOR */
+            RRETURN(MATCH_NOMATCH);
+            }
+          }
+        break;
+
+        case OP_VSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          switch(c)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x0a:      /* LF */
+            case 0x0b:      /* VT */
+            case 0x0c:      /* FF */
+            case 0x0d:      /* CR */
+            case 0x85:      /* NEL */
+            case 0x2028:    /* LINE SEPARATOR */
+            case 0x2029:    /* PARAGRAPH SEPARATOR */
+            break;
+            }
+          }
+        break;
+
+        case OP_NOT_DIGIT:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINC(c, eptr);
+          if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
+            RRETURN(MATCH_NOMATCH);
+          }
+        break;
+
+        case OP_DIGIT:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject ||
+             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)
+            RRETURN(MATCH_NOMATCH);
+          /* No need to skip more bytes - we know it's a 1-byte character */
+          }
+        break;
+
+        case OP_NOT_WHITESPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject ||
+             (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0))
+            RRETURN(MATCH_NOMATCH);
+          while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
+          }
+        break;
+
+        case OP_WHITESPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject ||
+             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)
+            RRETURN(MATCH_NOMATCH);
+          /* No need to skip more bytes - we know it's a 1-byte character */
+          }
+        break;
+
+        case OP_NOT_WORDCHAR:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject ||
+             (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0))
+            RRETURN(MATCH_NOMATCH);
+          while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
+          }
+        break;
+
+        case OP_WORDCHAR:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject ||
+             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)
+            RRETURN(MATCH_NOMATCH);
+          /* No need to skip more bytes - we know it's a 1-byte character */
+          }
+        break;
+
+        default:
+        RRETURN(PCRE_ERROR_INTERNAL);
+        }  /* End switch(ctype) */
+
+      else
+#endif     /* SUPPORT_UTF8 */
+
+      /* Code for the non-UTF-8 case for minimum matching of operators other
+      than OP_PROP and OP_NOTPROP. We can assume that there are the minimum
+      number of bytes present, as this was tested above. */
+
+      switch(ctype)
+        {
+        case OP_ANY:
+        for (i = 1; i <= min; i++)
+          {
+          if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
+          eptr++;
+          }
+        break;
+
+        case OP_ALLANY:
+        eptr += min;
+        break;
+
+        case OP_ANYBYTE:
+        eptr += min;
+        break;
+
+        /* Because of the CRLF case, we can't assume the minimum number of
+        bytes are present in this case. */
+
+        case OP_ANYNL:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x000d:
+            if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+            break;
+            case 0x000a:
+            break;
+
+            case 0x000b:
+            case 0x000c:
+            case 0x0085:
+            if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+            break;
+            }
+          }
+        break;
+
+        case OP_NOT_HSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: break;
+            case 0x09:      /* HT */
+            case 0x20:      /* SPACE */
+            case 0xa0:      /* NBSP */
+            RRETURN(MATCH_NOMATCH);
+            }
+          }
+        break;
+
+        case OP_HSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x09:      /* HT */
+            case 0x20:      /* SPACE */
+            case 0xa0:      /* NBSP */
+            break;
+            }
+          }
+        break;
+
+        case OP_NOT_VSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: break;
+            case 0x0a:      /* LF */
+            case 0x0b:      /* VT */
+            case 0x0c:      /* FF */
+            case 0x0d:      /* CR */
+            case 0x85:      /* NEL */
+            RRETURN(MATCH_NOMATCH);
+            }
+          }
+        break;
+
+        case OP_VSPACE:
+        for (i = 1; i <= min; i++)
+          {
+          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          switch(*eptr++)
+            {
+            default: RRETURN(MATCH_NOMATCH);
+            case 0x0a:      /* LF */
+            case 0x0b:      /* VT */
+            case 0x0c:      /* FF */
+            case 0x0d:      /* CR */
+            case 0x85:      /* NEL */
+            break;
+            }
+          }
+        break;
+
+        case OP_NOT_DIGIT:
+        for (i = 1; i <= min; i++)
+          if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
+        break;
+
+        case OP_DIGIT:
+        for (i = 1; i <= min; i++)
+          if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
+        break;
+
+        case OP_NOT_WHITESPACE:
+        for (i = 1; i <= min; i++)
+          if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
+        break;
+
+        case OP_WHITESPACE:
+        for (i = 1; i <= min; i++)
+          if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
+        break;
+
+        case OP_NOT_WORDCHAR:
+        for (i = 1; i <= min; i++)
+          if ((md->ctypes[*eptr++] & ctype_word) != 0)
+            RRETURN(MATCH_NOMATCH);
+        break;
+
+        case OP_WORDCHAR:
+        for (i = 1; i <= min; i++)
+          if ((md->ctypes[*eptr++] & ctype_word) == 0)
+            RRETURN(MATCH_NOMATCH);
+        break;
+
+        default:
+        RRETURN(PCRE_ERROR_INTERNAL);
+        }
+      }
+
+    /* If min = max, continue at the same level without recursing */
+
+    if (min == max) continue;
+
+    /* If minimizing, we have to test the rest of the pattern before each
+    subsequent match. Again, separate the UTF-8 case for speed, and also
+    separate the UCP cases. */
+
+    if (minimize)
+      {
+#ifdef SUPPORT_UCP
+      if (prop_type >= 0)
+        {
+        switch(prop_type)
+          {
+          case PT_ANY:
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINC(c, eptr);
+            if (prop_fail_result) RRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          case PT_LAMP:
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINC(c, eptr);
+            prop_chartype = UCD_CHARTYPE(c);
+            if ((prop_chartype == ucp_Lu ||
+                 prop_chartype == ucp_Ll ||
+                 prop_chartype == ucp_Lt) == prop_fail_result)
+              RRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          case PT_GC:
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINC(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == prop_value) == prop_fail_result)
+              RRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          case PT_PC:
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINC(c, eptr);
+            prop_chartype = UCD_CHARTYPE(c);
+            if ((prop_chartype == prop_value) == prop_fail_result)
+              RRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          case PT_SC:
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+            GETCHARINC(c, eptr);
+            prop_script = UCD_SCRIPT(c);
+            if ((prop_script == prop_value) == prop_fail_result)
+              RRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          default:
+          RRETURN(PCRE_ERROR_INTERNAL);
+          }
+        }
+
+      /* Match extended Unicode sequences. We will get here only if the
+      support is in the binary; otherwise a compile-time error occurs. */
+
+      else if (ctype == OP_EXTUNI)
+        {
+        for (fi = min;; fi++)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);
+          GETCHARINCTEST(c, eptr);
+          prop_category = UCD_CATEGORY(c);
+          if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);
+          while (eptr < md->end_subject)
+            {
+            int len = 1;
+            if (!utf8) c = *eptr; else
+              {
+              GETCHARLEN(c, eptr, len);
+              }
+            prop_category = UCD_CATEGORY(c);
+            if (prop_category != ucp_M) break;
+            eptr += len;
+            }
+          }
+        }
+
+      else
+#endif     /* SUPPORT_UCP */
+
+#ifdef SUPPORT_UTF8
+      /* UTF-8 mode */
+      if (utf8)
+        {
+        for (fi = min;; fi++)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (fi >= max || eptr >= md->end_subject ||
+               (ctype == OP_ANY && IS_NEWLINE(eptr)))
+            RRETURN(MATCH_NOMATCH);
+
+          GETCHARINC(c, eptr);
+          switch(ctype)
+            {
+            case OP_ANY:        /* This is the non-NL case */
+            case OP_ALLANY:
+            case OP_ANYBYTE:
+            break;
+
+            case OP_ANYNL:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x000d:
+              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+              break;
+              case 0x000a:
+              break;
+
+              case 0x000b:
+              case 0x000c:
+              case 0x0085:
+              case 0x2028:
+              case 0x2029:
+              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+              break;
+              }
+            break;
+
+            case OP_NOT_HSPACE:
+            switch(c)
+              {
+              default: break;
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              case 0x1680:    /* OGHAM SPACE MARK */
+              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+              case 0x2000:    /* EN QUAD */
+              case 0x2001:    /* EM QUAD */
+              case 0x2002:    /* EN SPACE */
+              case 0x2003:    /* EM SPACE */
+              case 0x2004:    /* THREE-PER-EM SPACE */
+              case 0x2005:    /* FOUR-PER-EM SPACE */
+              case 0x2006:    /* SIX-PER-EM SPACE */
+              case 0x2007:    /* FIGURE SPACE */
+              case 0x2008:    /* PUNCTUATION SPACE */
+              case 0x2009:    /* THIN SPACE */
+              case 0x200A:    /* HAIR SPACE */
+              case 0x202f:    /* NARROW NO-BREAK SPACE */
+              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+              case 0x3000:    /* IDEOGRAPHIC SPACE */
+              RRETURN(MATCH_NOMATCH);
+              }
+            break;
+
+            case OP_HSPACE:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              case 0x1680:    /* OGHAM SPACE MARK */
+              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+              case 0x2000:    /* EN QUAD */
+              case 0x2001:    /* EM QUAD */
+              case 0x2002:    /* EN SPACE */
+              case 0x2003:    /* EM SPACE */
+              case 0x2004:    /* THREE-PER-EM SPACE */
+              case 0x2005:    /* FOUR-PER-EM SPACE */
+              case 0x2006:    /* SIX-PER-EM SPACE */
+              case 0x2007:    /* FIGURE SPACE */
+              case 0x2008:    /* PUNCTUATION SPACE */
+              case 0x2009:    /* THIN SPACE */
+              case 0x200A:    /* HAIR SPACE */
+              case 0x202f:    /* NARROW NO-BREAK SPACE */
+              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+              case 0x3000:    /* IDEOGRAPHIC SPACE */
+              break;
+              }
+            break;
+
+            case OP_NOT_VSPACE:
+            switch(c)
+              {
+              default: break;
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              case 0x2028:    /* LINE SEPARATOR */
+              case 0x2029:    /* PARAGRAPH SEPARATOR */
+              RRETURN(MATCH_NOMATCH);
+              }
+            break;
+
+            case OP_VSPACE:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              case 0x2028:    /* LINE SEPARATOR */
+              case 0x2029:    /* PARAGRAPH SEPARATOR */
+              break;
+              }
+            break;
+
+            case OP_NOT_DIGIT:
+            if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
+              RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_DIGIT:
+            if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)
+              RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_NOT_WHITESPACE:
+            if (c < 256 && (md->ctypes[c] & ctype_space) != 0)
+              RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_WHITESPACE:
+            if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
+              RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_NOT_WORDCHAR:
+            if (c < 256 && (md->ctypes[c] & ctype_word) != 0)
+              RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_WORDCHAR:
+            if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)
+              RRETURN(MATCH_NOMATCH);
+            break;
+
+            default:
+            RRETURN(PCRE_ERROR_INTERNAL);
+            }
+          }
+        }
+      else
+#endif
+      /* Not UTF-8 mode */
+        {
+        for (fi = min;; fi++)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (fi >= max || eptr >= md->end_subject ||
+               (ctype == OP_ANY && IS_NEWLINE(eptr)))
+            RRETURN(MATCH_NOMATCH);
+
+          c = *eptr++;
+          switch(ctype)
+            {
+            case OP_ANY:     /* This is the non-NL case */
+            case OP_ALLANY:
+            case OP_ANYBYTE:
+            break;
+
+            case OP_ANYNL:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x000d:
+              if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+              break;
+
+              case 0x000a:
+              break;
+
+              case 0x000b:
+              case 0x000c:
+              case 0x0085:
+              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+              break;
+              }
+            break;
+
+            case OP_NOT_HSPACE:
+            switch(c)
+              {
+              default: break;
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              RRETURN(MATCH_NOMATCH);
+              }
+            break;
+
+            case OP_HSPACE:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              break;
+              }
+            break;
+
+            case OP_NOT_VSPACE:
+            switch(c)
+              {
+              default: break;
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              RRETURN(MATCH_NOMATCH);
+              }
+            break;
+
+            case OP_VSPACE:
+            switch(c)
+              {
+              default: RRETURN(MATCH_NOMATCH);
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              break;
+              }
+            break;
+
+            case OP_NOT_DIGIT:
+            if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_DIGIT:
+            if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_NOT_WHITESPACE:
+            if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_WHITESPACE:
+            if  ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_NOT_WORDCHAR:
+            if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);
+            break;
+
+            case OP_WORDCHAR:
+            if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);
+            break;
+
+            default:
+            RRETURN(PCRE_ERROR_INTERNAL);
+            }
+          }
+        }
+      /* Control never gets here */
+      }
+
+    /* If maximizing, it is worth using inline code for speed, doing the type
+    test once at the start (i.e. keep it out of the loop). Again, keep the
+    UTF-8 and UCP stuff separate. */
+
+    else
+      {
+      pp = eptr;  /* Remember where we started */
+
+#ifdef SUPPORT_UCP
+      if (prop_type >= 0)
+        {
+        switch(prop_type)
+          {
+          case PT_ANY:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (prop_fail_result) break;
+            eptr+= len;
+            }
+          break;
+
+          case PT_LAMP:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            prop_chartype = UCD_CHARTYPE(c);
+            if ((prop_chartype == ucp_Lu ||
+                 prop_chartype == ucp_Ll ||
+                 prop_chartype == ucp_Lt) == prop_fail_result)
+              break;
+            eptr+= len;
+            }
+          break;
+
+          case PT_GC:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == prop_value) == prop_fail_result)
+              break;
+            eptr+= len;
+            }
+          break;
+
+          case PT_PC:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            prop_chartype = UCD_CHARTYPE(c);
+            if ((prop_chartype == prop_value) == prop_fail_result)
+              break;
+            eptr+= len;
+            }
+          break;
+
+          case PT_SC:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            prop_script = UCD_SCRIPT(c);
+            if ((prop_script == prop_value) == prop_fail_result)
+              break;
+            eptr+= len;
+            }
+          break;
+          }
+
+        /* eptr is now past the end of the maximum run */
+
+        if (possessive) continue;
+        for(;;)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (eptr-- == pp) break;        /* Stop if tried at original pos */
+          if (utf8) BACKCHAR(eptr);
+          }
+        }
+
+      /* Match extended Unicode sequences. We will get here only if the
+      support is in the binary; otherwise a compile-time error occurs. */
+
+      else if (ctype == OP_EXTUNI)
+        {
+        for (i = min; i < max; i++)
+          {
+          if (eptr >= md->end_subject) break;
+          GETCHARINCTEST(c, eptr);
+          prop_category = UCD_CATEGORY(c);
+          if (prop_category == ucp_M) break;
+          while (eptr < md->end_subject)
+            {
+            int len = 1;
+            if (!utf8) c = *eptr; else
+              {
+              GETCHARLEN(c, eptr, len);
+              }
+            prop_category = UCD_CATEGORY(c);
+            if (prop_category != ucp_M) break;
+            eptr += len;
+            }
+          }
+
+        /* eptr is now past the end of the maximum run */
+
+        if (possessive) continue;
+        for(;;)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (eptr-- == pp) break;        /* Stop if tried at original pos */
+          for (;;)                        /* Move back over one extended */
+            {
+            int len = 1;
+            if (!utf8) c = *eptr; else
+              {
+              BACKCHAR(eptr);
+              GETCHARLEN(c, eptr, len);
+              }
+            prop_category = UCD_CATEGORY(c);
+            if (prop_category != ucp_M) break;
+            eptr--;
+            }
+          }
+        }
+
+      else
+#endif   /* SUPPORT_UCP */
+
+#ifdef SUPPORT_UTF8
+      /* UTF-8 mode */
+
+      if (utf8)
+        {
+        switch(ctype)
+          {
+          case OP_ANY:
+          if (max < INT_MAX)
+            {
+            for (i = min; i < max; i++)
+              {
+              if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
+              eptr++;
+              while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+              }
+            }
+
+          /* Handle unlimited UTF-8 repeat */
+
+          else
+            {
+            for (i = min; i < max; i++)
+              {
+              if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
+              eptr++;
+              while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+              }
+            }
+          break;
+
+          case OP_ALLANY:
+          if (max < INT_MAX)
+            {
+            for (i = min; i < max; i++)
+              {
+              if (eptr >= md->end_subject) break;
+              eptr++;
+              while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
+              }
+            }
+          else eptr = md->end_subject;   /* Unlimited UTF-8 repeat */
+          break;
+
+          /* The byte case is the same as non-UTF8 */
+
+          case OP_ANYBYTE:
+          c = max - min;
+          if (c > (unsigned int)(md->end_subject - eptr))
+            c = md->end_subject - eptr;
+          eptr += c;
+          break;
+
+          case OP_ANYNL:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (c == 0x000d)
+              {
+              if (++eptr >= md->end_subject) break;
+              if (*eptr == 0x000a) eptr++;
+              }
+            else
+              {
+              if (c != 0x000a &&
+                  (md->bsr_anycrlf ||
+                   (c != 0x000b && c != 0x000c &&
+                    c != 0x0085 && c != 0x2028 && c != 0x2029)))
+                break;
+              eptr += len;
+              }
+            }
+          break;
+
+          case OP_NOT_HSPACE:
+          case OP_HSPACE:
+          for (i = min; i < max; i++)
+            {
+            BOOL gotspace;
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            switch(c)
+              {
+              default: gotspace = FALSE; break;
+              case 0x09:      /* HT */
+              case 0x20:      /* SPACE */
+              case 0xa0:      /* NBSP */
+              case 0x1680:    /* OGHAM SPACE MARK */
+              case 0x180e:    /* MONGOLIAN VOWEL SEPARATOR */
+              case 0x2000:    /* EN QUAD */
+              case 0x2001:    /* EM QUAD */
+              case 0x2002:    /* EN SPACE */
+              case 0x2003:    /* EM SPACE */
+              case 0x2004:    /* THREE-PER-EM SPACE */
+              case 0x2005:    /* FOUR-PER-EM SPACE */
+              case 0x2006:    /* SIX-PER-EM SPACE */
+              case 0x2007:    /* FIGURE SPACE */
+              case 0x2008:    /* PUNCTUATION SPACE */
+              case 0x2009:    /* THIN SPACE */
+              case 0x200A:    /* HAIR SPACE */
+              case 0x202f:    /* NARROW NO-BREAK SPACE */
+              case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
+              case 0x3000:    /* IDEOGRAPHIC SPACE */
+              gotspace = TRUE;
+              break;
+              }
+            if (gotspace == (ctype == OP_NOT_HSPACE)) break;
+            eptr += len;
+            }
+          break;
+
+          case OP_NOT_VSPACE:
+          case OP_VSPACE:
+          for (i = min; i < max; i++)
+            {
+            BOOL gotspace;
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            switch(c)
+              {
+              default: gotspace = FALSE; break;
+              case 0x0a:      /* LF */
+              case 0x0b:      /* VT */
+              case 0x0c:      /* FF */
+              case 0x0d:      /* CR */
+              case 0x85:      /* NEL */
+              case 0x2028:    /* LINE SEPARATOR */
+              case 0x2029:    /* PARAGRAPH SEPARATOR */
+              gotspace = TRUE;
+              break;
+              }
+            if (gotspace == (ctype == OP_NOT_VSPACE)) break;
+            eptr += len;
+            }
+          break;
+
+          case OP_NOT_DIGIT:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break;
+            eptr+= len;
+            }
+          break;
+
+          case OP_DIGIT:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break;
+            eptr+= len;
+            }
+          break;
+
+          case OP_NOT_WHITESPACE:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break;
+            eptr+= len;
+            }
+          break;
+
+          case OP_WHITESPACE:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break;
+            eptr+= len;
+            }
+          break;
+
+          case OP_NOT_WORDCHAR:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break;
+            eptr+= len;
+            }
+          break;
+
+          case OP_WORDCHAR:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject) break;
+            GETCHARLEN(c, eptr, len);
+            if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break;
+            eptr+= len;
+            }
+          break;
+
+          default:
+          RRETURN(PCRE_ERROR_INTERNAL);
+          }
+
+        /* eptr is now past the end of the maximum run */
+
+        if (possessive) continue;
+        for(;;)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM46);
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          if (eptr-- == pp) break;        /* Stop if tried at original pos */
+          BACKCHAR(eptr);
+          }
+        }
+      else
+#endif  /* SUPPORT_UTF8 */
+
+      /* Not UTF-8 mode */
+        {
+        switch(ctype)
+          {
+          case OP_ANY:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break;
+            eptr++;
+            }
+          break;
+
+          case OP_ALLANY:
+          case OP_ANYBYTE:
+          c = max - min;
+          if (c > (unsigned int)(md->end_subject - eptr))
+            c = md->end_subject - eptr;
+          eptr += c;
+          break;
+
+          case OP_ANYNL:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c == 0x000d)
+              {
+              if (++eptr >= md->end_subject) break;
+              if (*eptr == 0x000a) eptr++;
+              }
+            else
+              {
+              if (c != 0x000a &&
+                  (md->bsr_anycrlf ||
+                    (c != 0x000b && c != 0x000c && c != 0x0085)))
+                break;
+              eptr++;
+              }
+            }
+          break;
+
+          case OP_NOT_HSPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c == 0x09 || c == 0x20 || c == 0xa0) break;
+            eptr++;
+            }
+          break;
+
+          case OP_HSPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c != 0x09 && c != 0x20 && c != 0xa0) break;
+            eptr++;
+            }
+          break;
+
+          case OP_NOT_VSPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)
+              break;
+            eptr++;
+            }
+          break;
+
+          case OP_VSPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject) break;
+            c = *eptr;
+            if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85)
+              break;
+            eptr++;
+            }
+          break;
+
+          case OP_NOT_DIGIT:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)
+              break;
+            eptr++;
+            }
+          break;
+
+          case OP_DIGIT:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)
+              break;
+            eptr++;
+            }
+          break;
+
+          case OP_NOT_WHITESPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)
+              break;
+            eptr++;
+            }
+          break;
+
+          case OP_WHITESPACE:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)
+              break;
+            eptr++;
+            }
+          break;
+
+          case OP_NOT_WORDCHAR:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)
+              break;
+            eptr++;
+            }
+          break;
+
+          case OP_WORDCHAR:
+          for (i = min; i < max; i++)
+            {
+            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)
+              break;
+            eptr++;
+            }
+          break;
+
+          default:
+          RRETURN(PCRE_ERROR_INTERNAL);
+          }
+
+        /* eptr is now past the end of the maximum run */
+
+        if (possessive) continue;
+        while (eptr >= pp)
+          {
+          RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM47);
+          eptr--;
+          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+          }
+        }
+
+      /* Get here if we can't make it match with any permitted repetitions */
+
+      RRETURN(MATCH_NOMATCH);
+      }
+    /* Control never gets here */
+
+    /* There's been some horrible disaster. Arrival here can only mean there is
+    something seriously wrong in the code above or the OP_xxx definitions. */
+
+    default:
+    DPRINTF(("Unknown opcode %d\n", *ecode));
+    RRETURN(PCRE_ERROR_UNKNOWN_OPCODE);
+    }
+
+  /* Do not stick any code in here without much thought; it is assumed
+  that "continue" in the code above comes out to here to repeat the main
+  loop. */
+
+  }             /* End of main loop */
+/* Control never reaches here */
+
+
+/* When compiling to use the heap rather than the stack for recursive calls to
+match(), the RRETURN() macro jumps here. The number that is saved in
+frame->Xwhere indicates which label we actually want to return to. */
+
+#ifdef NO_RECURSE
+#define LBL(val) case val: goto L_RM##val;
+HEAP_RETURN:
+switch (frame->Xwhere)
+  {
+  LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8)
+  LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17)
+  LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33)
+  LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)
+  LBL(53) LBL(54)
+#ifdef SUPPORT_UTF8
+  LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30)
+  LBL(32) LBL(34) LBL(42) LBL(46)
+#ifdef SUPPORT_UCP
+  LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
+#endif  /* SUPPORT_UCP */
+#endif  /* SUPPORT_UTF8 */
+  default:
+  DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));
+  return PCRE_ERROR_INTERNAL;
+  }
+#undef LBL
+#endif  /* NO_RECURSE */
+}
+
+
+/***************************************************************************
+****************************************************************************
+                   RECURSION IN THE match() FUNCTION
+
+Undefine all the macros that were defined above to handle this. */
+
+#ifdef NO_RECURSE
+#undef eptr
+#undef ecode
+#undef mstart
+#undef offset_top
+#undef ims
+#undef eptrb
+#undef flags
+
+#undef callpat
+#undef charptr
+#undef data
+#undef next
+#undef pp
+#undef prev
+#undef saved_eptr
+
+#undef new_recursive
+
+#undef cur_is_word
+#undef condition
+#undef prev_is_word
+
+#undef original_ims
+
+#undef ctype
+#undef length
+#undef max
+#undef min
+#undef number
+#undef offset
+#undef op
+#undef save_capture_last
+#undef save_offset1
+#undef save_offset2
+#undef save_offset3
+#undef stacksave
+
+#undef newptrb
+
+#endif
+
+/* These two are defined as macros in both cases */
+
+#undef fc
+#undef fi
+
+/***************************************************************************
+***************************************************************************/
+
+
+
+/*************************************************
+*         Execute a Regular Expression           *
+*************************************************/
+
+/* This function applies a compiled re to a subject string and picks out
+portions of the string if it matches. Two elements in the vector are set for
+each substring: the offsets to the start and end of the substring.
+
+Arguments:
+  argument_re     points to the compiled expression
+  extra_data      points to extra data or is NULL
+  subject         points to the subject string
+  length          length of subject string (may contain binary zeros)
+  start_offset    where to start in the subject string
+  options         option bits
+  offsets         points to a vector of ints to be filled in with offsets
+  offsetcount     the number of elements in the vector
+
+Returns:          > 0 => success; value is the number of elements filled in
+                  = 0 => success, but offsets is not big enough
+                   -1 => failed to match
+                 < -1 => some kind of unexpected problem
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
+  PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
+  int offsetcount)
+{
+int rc, resetcount, ocount;
+int first_byte = -1;
+int req_byte = -1;
+int req_byte2 = -1;
+int newline;
+unsigned long int ims;
+BOOL using_temporary_offsets = FALSE;
+BOOL anchored;
+BOOL startline;
+BOOL firstline;
+BOOL first_byte_caseless = FALSE;
+BOOL req_byte_caseless = FALSE;
+BOOL utf8;
+match_data match_block;
+match_data *md = &match_block;
+const uschar *tables;
+const uschar *start_bits = NULL;
+USPTR start_match = (USPTR)subject + start_offset;
+USPTR end_subject;
+USPTR req_byte_ptr = start_match - 1;
+
+pcre_study_data internal_study;
+const pcre_study_data *study;
+
+real_pcre internal_re;
+const real_pcre *external_re = (const real_pcre *)argument_re;
+const real_pcre *re = external_re;
+
+/* Plausibility checks */
+
+if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
+if (re == NULL || subject == NULL ||
+   (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;
+if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
+
+/* Fish out the optional data from the extra_data structure, first setting
+the default values. */
+
+study = NULL;
+md->match_limit = MATCH_LIMIT;
+md->match_limit_recursion = MATCH_LIMIT_RECURSION;
+md->callout_data = NULL;
+
+/* The table pointer is always in native byte order. */
+
+tables = external_re->tables;
+
+if (extra_data != NULL)
+  {
+  register unsigned int flags = extra_data->flags;
+  if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)
+    study = (const pcre_study_data *)extra_data->study_data;
+  if ((flags & PCRE_EXTRA_MATCH_LIMIT) != 0)
+    md->match_limit = extra_data->match_limit;
+  if ((flags & PCRE_EXTRA_MATCH_LIMIT_RECURSION) != 0)
+    md->match_limit_recursion = extra_data->match_limit_recursion;
+  if ((flags & PCRE_EXTRA_CALLOUT_DATA) != 0)
+    md->callout_data = extra_data->callout_data;
+  if ((flags & PCRE_EXTRA_TABLES) != 0) tables = extra_data->tables;
+  }
+
+/* If the exec call supplied NULL for tables, use the inbuilt ones. This
+is a feature that makes it possible to save compiled regex and re-use them
+in other programs later. */
+
+if (tables == NULL) tables = _pcre_default_tables;
+
+/* Check that the first field in the block is the magic number. If it is not,
+test for a regex that was compiled on a host of opposite endianness. If this is
+the case, flipped values are put in internal_re and internal_study if there was
+study data too. */
+
+if (re->magic_number != MAGIC_NUMBER)
+  {
+  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);
+  if (re == NULL) return PCRE_ERROR_BADMAGIC;
+  if (study != NULL) study = &internal_study;
+  }
+
+/* Set up other data */
+
+anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
+startline = (re->flags & PCRE_STARTLINE) != 0;
+firstline = (re->options & PCRE_FIRSTLINE) != 0;
+
+/* The code starts after the real_pcre block and the capture name table. */
+
+md->start_code = (const uschar *)external_re + re->name_table_offset +
+  re->name_count * re->name_entry_size;
+
+md->start_subject = (USPTR)subject;
+md->start_offset = start_offset;
+md->end_subject = md->start_subject + length;
+end_subject = md->end_subject;
+
+md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
+utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0;
+md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
+
+md->notbol = (options & PCRE_NOTBOL) != 0;
+md->noteol = (options & PCRE_NOTEOL) != 0;
+md->notempty = (options & PCRE_NOTEMPTY) != 0;
+md->partial = (options & PCRE_PARTIAL) != 0;
+md->hitend = FALSE;
+
+md->recursive = NULL;                   /* No recursion at top level */
+
+md->lcc = tables + lcc_offset;
+md->ctypes = tables + ctypes_offset;
+
+/* Handle different \R options. */
+
+switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
+  {
+  case 0:
+  if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
+    md->bsr_anycrlf = (re->options & PCRE_BSR_ANYCRLF) != 0;
+  else
+#ifdef BSR_ANYCRLF
+  md->bsr_anycrlf = TRUE;
+#else
+  md->bsr_anycrlf = FALSE;
+#endif
+  break;
+
+  case PCRE_BSR_ANYCRLF:
+  md->bsr_anycrlf = TRUE;
+  break;
+
+  case PCRE_BSR_UNICODE:
+  md->bsr_anycrlf = FALSE;
+  break;
+
+  default: return PCRE_ERROR_BADNEWLINE;
+  }
+
+/* Handle different types of newline. The three bits give eight cases. If
+nothing is set at run time, whatever was used at compile time applies. */
+
+switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options :
+        (pcre_uint32)options) & PCRE_NEWLINE_BITS)
+  {
+  case 0: newline = NEWLINE; break;   /* Compile-time default */
+  case PCRE_NEWLINE_CR: newline = '\r'; break;
+  case PCRE_NEWLINE_LF: newline = '\n'; break;
+  case PCRE_NEWLINE_CR+
+       PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
+  case PCRE_NEWLINE_ANY: newline = -1; break;
+  case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
+  default: return PCRE_ERROR_BADNEWLINE;
+  }
+
+if (newline == -2)
+  {
+  md->nltype = NLTYPE_ANYCRLF;
+  }
+else if (newline < 0)
+  {
+  md->nltype = NLTYPE_ANY;
+  }
+else
+  {
+  md->nltype = NLTYPE_FIXED;
+  if (newline > 255)
+    {
+    md->nllen = 2;
+    md->nl[0] = (newline >> 8) & 255;
+    md->nl[1] = newline & 255;
+    }
+  else
+    {
+    md->nllen = 1;
+    md->nl[0] = newline;
+    }
+  }
+
+/* Partial matching is supported only for a restricted set of regexes at the
+moment. */
+
+if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0)
+  return PCRE_ERROR_BADPARTIAL;
+
+/* Check a UTF-8 string if required. Unfortunately there's no way of passing
+back the character offset. */
+
+#ifdef SUPPORT_UTF8
+if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)
+  {
+  if (_pcre_valid_utf8((uschar *)subject, length) >= 0)
+    return PCRE_ERROR_BADUTF8;
+  if (start_offset > 0 && start_offset < length)
+    {
+    int tb = ((uschar *)subject)[start_offset];
+    if (tb > 127)
+      {
+      tb &= 0xc0;
+      if (tb != 0 && tb != 0xc0) return PCRE_ERROR_BADUTF8_OFFSET;
+      }
+    }
+  }
+#endif
+
+/* The ims options can vary during the matching as a result of the presence
+of (?ims) items in the pattern. They are kept in a local variable so that
+restoring at the exit of a group is easy. */
+
+ims = re->options & (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL);
+
+/* If the expression has got more back references than the offsets supplied can
+hold, we get a temporary chunk of working store to use during the matching.
+Otherwise, we can use the vector supplied, rounding down its size to a multiple
+of 3. */
+
+ocount = offsetcount - (offsetcount % 3);
+
+if (re->top_backref > 0 && re->top_backref >= ocount/3)
+  {
+  ocount = re->top_backref * 3 + 3;
+  md->offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int));
+  if (md->offset_vector == NULL) return PCRE_ERROR_NOMEMORY;
+  using_temporary_offsets = TRUE;
+  DPRINTF(("Got memory to hold back references\n"));
+  }
+else md->offset_vector = offsets;
+
+md->offset_end = ocount;
+md->offset_max = (2*ocount)/3;
+md->offset_overflow = FALSE;
+md->capture_last = -1;
+
+/* Compute the minimum number of offsets that we need to reset each time. Doing
+this makes a huge difference to execution time when there aren't many brackets
+in the pattern. */
+
+resetcount = 2 + re->top_bracket * 2;
+if (resetcount > offsetcount) resetcount = ocount;
+
+/* Reset the working variable associated with each extraction. These should
+never be used unless previously set, but they get saved and restored, and so we
+initialize them to avoid reading uninitialized locations. */
+
+if (md->offset_vector != NULL)
+  {
+  register int *iptr = md->offset_vector + ocount;
+  register int *iend = iptr - resetcount/2 + 1;
+  while (--iptr >= iend) *iptr = -1;
+  }
+
+/* Set up the first character to match, if available. The first_byte value is
+never set for an anchored regular expression, but the anchoring may be forced
+at run time, so we have to test for anchoring. The first char may be unset for
+an unanchored pattern, of course. If there's no first char and the pattern was
+studied, there may be a bitmap of possible first characters. */
+
+if (!anchored)
+  {
+  if ((re->flags & PCRE_FIRSTSET) != 0)
+    {
+    first_byte = re->first_byte & 255;
+    if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)
+      first_byte = md->lcc[first_byte];
+    }
+  else
+    if (!startline && study != NULL &&
+      (study->options & PCRE_STUDY_MAPPED) != 0)
+        start_bits = study->start_bits;
+  }
+
+/* For anchored or unanchored matches, there may be a "last known required
+character" set. */
+
+if ((re->flags & PCRE_REQCHSET) != 0)
+  {
+  req_byte = re->req_byte & 255;
+  req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;
+  req_byte2 = (tables + fcc_offset)[req_byte];  /* case flipped */
+  }
+
+
+/* ==========================================================================*/
+
+/* Loop for handling unanchored repeated matching attempts; for anchored regexs
+the loop runs just once. */
+
+for(;;)
+  {
+  USPTR save_end_subject = end_subject;
+  USPTR new_start_match;
+
+  /* Reset the maximum number of extractions we might see. */
+
+  if (md->offset_vector != NULL)
+    {
+    register int *iptr = md->offset_vector;
+    register int *iend = iptr + resetcount;
+    while (iptr < iend) *iptr++ = -1;
+    }
+
+  /* Advance to a unique first char if possible. If firstline is TRUE, the
+  start of the match is constrained to the first line of a multiline string.
+  That is, the match must be before or at the first newline. Implement this by
+  temporarily adjusting end_subject so that we stop scanning at a newline. If
+  the match fails at the newline, later code breaks this loop. */
+
+  if (firstline)
+    {
+    USPTR t = start_match;
+#ifdef SUPPORT_UTF8
+    if (utf8)
+      {
+      while (t < md->end_subject && !IS_NEWLINE(t))
+        {
+        t++;
+        while (t < end_subject && (*t & 0xc0) == 0x80) t++;
+        }
+      }
+    else
+#endif
+    while (t < md->end_subject && !IS_NEWLINE(t)) t++;
+    end_subject = t;
+    }
+
+  /* Now advance to a unique first byte if there is one. */
+
+  if (first_byte >= 0)
+    {
+    if (first_byte_caseless)
+      while (start_match < end_subject && md->lcc[*start_match] != first_byte)
+        start_match++;
+    else
+      while (start_match < end_subject && *start_match != first_byte)
+        start_match++;
+    }
+
+  /* Or to just after a linebreak for a multiline match */
+
+  else if (startline)
+    {
+    if (start_match > md->start_subject + start_offset)
+      {
+#ifdef SUPPORT_UTF8
+      if (utf8)
+        {
+        while (start_match < end_subject && !WAS_NEWLINE(start_match))
+          {
+          start_match++;
+          while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
+            start_match++;
+          }
+        }
+      else
+#endif
+      while (start_match < end_subject && !WAS_NEWLINE(start_match))
+        start_match++;
+
+      /* If we have just passed a CR and the newline option is ANY or ANYCRLF,
+      and we are now at a LF, advance the match position by one more character.
+      */
+
+      if (start_match[-1] == '\r' &&
+           (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
+           start_match < end_subject &&
+           *start_match == '\n')
+        start_match++;
+      }
+    }
+
+  /* Or to a non-unique first byte after study */
+
+  else if (start_bits != NULL)
+    {
+    while (start_match < end_subject)
+      {
+      register unsigned int c = *start_match;
+      if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++;
+        else break;
+      }
+    }
+
+  /* Restore fudged end_subject */
+
+  end_subject = save_end_subject;
+
+#ifdef DEBUG  /* Sigh. Some compilers never learn. */
+  printf(">>>> Match against: ");
+  pchars(start_match, end_subject - start_match, TRUE, md);
+  printf("\n");
+#endif
+
+  /* If req_byte is set, we know that that character must appear in the subject
+  for the match to succeed. If the first character is set, req_byte must be
+  later in the subject; otherwise the test starts at the match point. This
+  optimization can save a huge amount of backtracking in patterns with nested
+  unlimited repeats that aren't going to match. Writing separate code for
+  cased/caseless versions makes it go faster, as does using an autoincrement
+  and backing off on a match.
+
+  HOWEVER: when the subject string is very, very long, searching to its end can
+  take a long time, and give bad performance on quite ordinary patterns. This
+  showed up when somebody was matching something like /^\d+C/ on a 32-megabyte
+  string... so we don't do this when the string is sufficiently long.
+
+  ALSO: this processing is disabled when partial matching is requested.
+  */
+
+  if (req_byte >= 0 &&
+      end_subject - start_match < REQ_BYTE_MAX &&
+      !md->partial)
+    {
+    register USPTR p = start_match + ((first_byte >= 0)? 1 : 0);
+
+    /* We don't need to repeat the search if we haven't yet reached the
+    place we found it at last time. */
+
+    if (p > req_byte_ptr)
+      {
+      if (req_byte_caseless)
+        {
+        while (p < end_subject)
+          {
+          register int pp = *p++;
+          if (pp == req_byte || pp == req_byte2) { p--; break; }
+          }
+        }
+      else
+        {
+        while (p < end_subject)
+          {
+          if (*p++ == req_byte) { p--; break; }
+          }
+        }
+
+      /* If we can't find the required character, break the matching loop,
+      forcing a match failure. */
+
+      if (p >= end_subject)
+        {
+        rc = MATCH_NOMATCH;
+        break;
+        }
+
+      /* If we have found the required character, save the point where we
+      found it, so that we don't search again next time round the loop if
+      the start hasn't passed this character yet. */
+
+      req_byte_ptr = p;
+      }
+    }
+
+  /* OK, we can now run the match. */
+
+  md->start_match_ptr = start_match;
+  md->match_call_count = 0;
+  rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);
+
+  switch(rc)
+    {
+    /* NOMATCH and PRUNE advance by one character. THEN at this level acts
+    exactly like PRUNE. */
+
+    case MATCH_NOMATCH:
+    case MATCH_PRUNE:
+    case MATCH_THEN:
+    new_start_match = start_match + 1;
+#ifdef SUPPORT_UTF8
+    if (utf8)
+      while(new_start_match < end_subject && (*new_start_match & 0xc0) == 0x80)
+        new_start_match++;
+#endif
+    break;
+
+    /* SKIP passes back the next starting point explicitly. */
+
+    case MATCH_SKIP:
+    new_start_match = md->start_match_ptr;
+    break;
+
+    /* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */
+
+    case MATCH_COMMIT:
+    rc = MATCH_NOMATCH;
+    goto ENDLOOP;
+
+    /* Any other return is some kind of error. */
+
+    default:
+    goto ENDLOOP;
+    }
+
+  /* Control reaches here for the various types of "no match at this point"
+  result. Reset the code to MATCH_NOMATCH for subsequent checking. */
+
+  rc = MATCH_NOMATCH;
+
+  /* If PCRE_FIRSTLINE is set, the match must happen before or at the first
+  newline in the subject (though it may continue over the newline). Therefore,
+  if we have just failed to match, starting at a newline, do not continue. */
+
+  if (firstline && IS_NEWLINE(start_match)) break;
+
+  /* Advance to new matching position */
+
+  start_match = new_start_match;
+
+  /* Break the loop if the pattern is anchored or if we have passed the end of
+  the subject. */
+
+  if (anchored || start_match > end_subject) break;
+
+  /* If we have just passed a CR and we are now at a LF, and the pattern does
+  not contain any explicit matches for \r or \n, and the newline option is CRLF
+  or ANY or ANYCRLF, advance the match position by one more character. */
+
+  if (start_match[-1] == '\r' &&
+      start_match < end_subject &&
+      *start_match == '\n' &&
+      (re->flags & PCRE_HASCRORLF) == 0 &&
+        (md->nltype == NLTYPE_ANY ||
+         md->nltype == NLTYPE_ANYCRLF ||
+         md->nllen == 2))
+    start_match++;
+
+  }   /* End of for(;;) "bumpalong" loop */
+
+/* ==========================================================================*/
+
+/* We reach here when rc is not MATCH_NOMATCH, or if one of the stopping
+conditions is true:
+
+(1) The pattern is anchored or the match was failed by (*COMMIT);
+
+(2) We are past the end of the subject;
+
+(3) PCRE_FIRSTLINE is set and we have failed to match at a newline, because
+    this option requests that a match occur at or before the first newline in
+    the subject.
+
+When we have a match and the offset vector is big enough to deal with any
+backreferences, captured substring offsets will already be set up. In the case
+where we had to get some local store to hold offsets for backreference
+processing, copy those that we can. In this case there need not be overflow if
+certain parts of the pattern were not used, even though there are more
+capturing parentheses than vector slots. */
+
+ENDLOOP:
+
+if (rc == MATCH_MATCH)
+  {
+  if (using_temporary_offsets)
+    {
+    if (offsetcount >= 4)
+      {
+      memcpy(offsets + 2, md->offset_vector + 2,
+        (offsetcount - 2) * sizeof(int));
+      DPRINTF(("Copied offsets from temporary memory\n"));
+      }
+    if (md->end_offset_top > offsetcount) md->offset_overflow = TRUE;
+    DPRINTF(("Freeing temporary memory\n"));
+    (pcre_free)(md->offset_vector);
+    }
+
+  /* Set the return code to the number of captured strings, or 0 if there are
+  too many to fit into the vector. */
+
+  rc = md->offset_overflow? 0 : md->end_offset_top/2;
+
+  /* If there is space, set up the whole thing as substring 0. The value of
+  md->start_match_ptr might be modified if \K was encountered on the success
+  matching path. */
+
+  if (offsetcount < 2) rc = 0; else
+    {
+    offsets[0] = md->start_match_ptr - md->start_subject;
+    offsets[1] = md->end_match_ptr - md->start_subject;
+    }
+
+  DPRINTF((">>>> returning %d\n", rc));
+  return rc;
+  }
+
+/* Control gets here if there has been an error, or if the overall match
+attempt has failed at all permitted starting positions. */
+
+if (using_temporary_offsets)
+  {
+  DPRINTF(("Freeing temporary memory\n"));
+  (pcre_free)(md->offset_vector);
+  }
+
+if (rc != MATCH_NOMATCH)
+  {
+  DPRINTF((">>>> error: returning %d\n", rc));
+  return rc;
+  }
+else if (md->partial && md->hitend)
+  {
+  DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n"));
+  return PCRE_ERROR_PARTIAL;
+  }
+else
+  {
+  DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));
+  return PCRE_ERROR_NOMATCH;
+  }
+}
+
+/* End of pcre_exec.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_fullinfo.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,165 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_fullinfo(), which returns
+information about a compiled pattern. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+*        Return info about compiled pattern      *
+*************************************************/
+
+/* This is a newer "info" function which has an extensible interface so
+that additional items can be added compatibly.
+
+Arguments:
+  argument_re      points to compiled code
+  extra_data       points extra data, or NULL
+  what             what information is required
+  where            where to put the information
+
+Returns:           0 if data returned, negative on error
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,
+  void *where)
+{
+real_pcre internal_re;
+pcre_study_data internal_study;
+const real_pcre *re = (const real_pcre *)argument_re;
+const pcre_study_data *study = NULL;
+
+if (re == NULL || where == NULL) return PCRE_ERROR_NULL;
+
+if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
+  study = (const pcre_study_data *)extra_data->study_data;
+
+if (re->magic_number != MAGIC_NUMBER)
+  {
+  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);
+  if (re == NULL) return PCRE_ERROR_BADMAGIC;
+  if (study != NULL) study = &internal_study;
+  }
+
+switch (what)
+  {
+  case PCRE_INFO_OPTIONS:
+  *((unsigned long int *)where) = re->options & PUBLIC_OPTIONS;
+  break;
+
+  case PCRE_INFO_SIZE:
+  *((size_t *)where) = re->size;
+  break;
+
+  case PCRE_INFO_STUDYSIZE:
+  *((size_t *)where) = (study == NULL)? 0 : study->size;
+  break;
+
+  case PCRE_INFO_CAPTURECOUNT:
+  *((int *)where) = re->top_bracket;
+  break;
+
+  case PCRE_INFO_BACKREFMAX:
+  *((int *)where) = re->top_backref;
+  break;
+
+  case PCRE_INFO_FIRSTBYTE:
+  *((int *)where) =
+    ((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :
+    ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
+  break;
+
+  /* Make sure we pass back the pointer to the bit vector in the external
+  block, not the internal copy (with flipped integer fields). */
+
+  case PCRE_INFO_FIRSTTABLE:
+  *((const uschar **)where) =
+    (study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0)?
+      ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;
+  break;
+
+  case PCRE_INFO_LASTLITERAL:
+  *((int *)where) =
+    ((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1;
+  break;
+
+  case PCRE_INFO_NAMEENTRYSIZE:
+  *((int *)where) = re->name_entry_size;
+  break;
+
+  case PCRE_INFO_NAMECOUNT:
+  *((int *)where) = re->name_count;
+  break;
+
+  case PCRE_INFO_NAMETABLE:
+  *((const uschar **)where) = (const uschar *)re + re->name_table_offset;
+  break;
+
+  case PCRE_INFO_DEFAULT_TABLES:
+  *((const uschar **)where) = (const uschar *)(_pcre_default_tables);
+  break;
+
+  case PCRE_INFO_OKPARTIAL:
+  *((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
+  break;
+
+  case PCRE_INFO_JCHANGED:
+  *((int *)where) = (re->flags & PCRE_JCHANGED) != 0;
+  break;
+
+  case PCRE_INFO_HASCRORLF:
+  *((int *)where) = (re->flags & PCRE_HASCRORLF) != 0;
+  break;
+
+  default: return PCRE_ERROR_BADOPTION;
+  }
+
+return 0;
+}
+
+/* End of pcre_fullinfo.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_get.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,465 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains some convenience functions for extracting substrings
+from the subject string after a regex match has succeeded. The original idea
+for these functions came from Scott Wimer. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+*           Find number for named string         *
+*************************************************/
+
+/* This function is used by the get_first_set() function below, as well
+as being generally available. It assumes that names are unique.
+
+Arguments:
+  code        the compiled regex
+  stringname  the name whose number is required
+
+Returns:      the number of the named parentheses, or a negative number
+                (PCRE_ERROR_NOSUBSTRING) if not found
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_get_stringnumber(const pcre *code, const char *stringname)
+{
+int rc;
+int entrysize;
+int top, bot;
+uschar *nametable;
+
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
+  return rc;
+if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
+
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
+  return rc;
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
+  return rc;
+
+bot = 0;
+while (top > bot)
+  {
+  int mid = (top + bot) / 2;
+  uschar *entry = nametable + entrysize*mid;
+  int c = strcmp(stringname, (char *)(entry + 2));
+  if (c == 0) return (entry[0] << 8) + entry[1];
+  if (c > 0) bot = mid + 1; else top = mid;
+  }
+
+return PCRE_ERROR_NOSUBSTRING;
+}
+
+
+
+/*************************************************
+*     Find (multiple) entries for named string   *
+*************************************************/
+
+/* This is used by the get_first_set() function below, as well as being
+generally available. It is used when duplicated names are permitted.
+
+Arguments:
+  code        the compiled regex
+  stringname  the name whose entries required
+  firstptr    where to put the pointer to the first entry
+  lastptr     where to put the pointer to the last entry
+
+Returns:      the length of each entry, or a negative number
+                (PCRE_ERROR_NOSUBSTRING) if not found
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_get_stringtable_entries(const pcre *code, const char *stringname,
+  char **firstptr, char **lastptr)
+{
+int rc;
+int entrysize;
+int top, bot;
+uschar *nametable, *lastentry;
+
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
+  return rc;
+if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
+
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
+  return rc;
+if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
+  return rc;
+
+lastentry = nametable + entrysize * (top - 1);
+bot = 0;
+while (top > bot)
+  {
+  int mid = (top + bot) / 2;
+  uschar *entry = nametable + entrysize*mid;
+  int c = strcmp(stringname, (char *)(entry + 2));
+  if (c == 0)
+    {
+    uschar *first = entry;
+    uschar *last = entry;
+    while (first > nametable)
+      {
+      if (strcmp(stringname, (char *)(first - entrysize + 2)) != 0) break;
+      first -= entrysize;
+      }
+    while (last < lastentry)
+      {
+      if (strcmp(stringname, (char *)(last + entrysize + 2)) != 0) break;
+      last += entrysize;
+      }
+    *firstptr = (char *)first;
+    *lastptr = (char *)last;
+    return entrysize;
+    }
+  if (c > 0) bot = mid + 1; else top = mid;
+  }
+
+return PCRE_ERROR_NOSUBSTRING;
+}
+
+
+
+/*************************************************
+*    Find first set of multiple named strings    *
+*************************************************/
+
+/* This function allows for duplicate names in the table of named substrings.
+It returns the number of the first one that was set in a pattern match.
+
+Arguments:
+  code         the compiled regex
+  stringname   the name of the capturing substring
+  ovector      the vector of matched substrings
+
+Returns:       the number of the first that is set,
+               or the number of the last one if none are set,
+               or a negative number on error
+*/
+
+static int
+get_first_set(const pcre *code, const char *stringname, int *ovector)
+{
+const real_pcre *re = (const real_pcre *)code;
+int entrysize;
+char *first, *last;
+uschar *entry;
+if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
+  return pcre_get_stringnumber(code, stringname);
+entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last);
+if (entrysize <= 0) return entrysize;
+for (entry = (uschar *)first; entry <= (uschar *)last; entry += entrysize)
+  {
+  int n = (entry[0] << 8) + entry[1];
+  if (ovector[n*2] >= 0) return n;
+  }
+return (first[0] << 8) + first[1];
+}
+
+
+
+
+/*************************************************
+*      Copy captured string to given buffer      *
+*************************************************/
+
+/* This function copies a single captured substring into a given buffer.
+Note that we use memcpy() rather than strncpy() in case there are binary zeros
+in the string.
+
+Arguments:
+  subject        the subject string that was matched
+  ovector        pointer to the offsets table
+  stringcount    the number of substrings that were captured
+                   (i.e. the yield of the pcre_exec call, unless
+                   that was zero, in which case it should be 1/3
+                   of the offset table size)
+  stringnumber   the number of the required substring
+  buffer         where to put the substring
+  size           the size of the buffer
+
+Returns:         if successful:
+                   the length of the copied string, not including the zero
+                   that is put on the end; can be zero
+                 if not successful:
+                   PCRE_ERROR_NOMEMORY (-6) buffer too small
+                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_copy_substring(const char *subject, int *ovector, int stringcount,
+  int stringnumber, char *buffer, int size)
+{
+int yield;
+if (stringnumber < 0 || stringnumber >= stringcount)
+  return PCRE_ERROR_NOSUBSTRING;
+stringnumber *= 2;
+yield = ovector[stringnumber+1] - ovector[stringnumber];
+if (size < yield + 1) return PCRE_ERROR_NOMEMORY;
+memcpy(buffer, subject + ovector[stringnumber], yield);
+buffer[yield] = 0;
+return yield;
+}
+
+
+
+/*************************************************
+*   Copy named captured string to given buffer   *
+*************************************************/
+
+/* This function copies a single captured substring into a given buffer,
+identifying it by name. If the regex permits duplicate names, the first
+substring that is set is chosen.
+
+Arguments:
+  code           the compiled regex
+  subject        the subject string that was matched
+  ovector        pointer to the offsets table
+  stringcount    the number of substrings that were captured
+                   (i.e. the yield of the pcre_exec call, unless
+                   that was zero, in which case it should be 1/3
+                   of the offset table size)
+  stringname     the name of the required substring
+  buffer         where to put the substring
+  size           the size of the buffer
+
+Returns:         if successful:
+                   the length of the copied string, not including the zero
+                   that is put on the end; can be zero
+                 if not successful:
+                   PCRE_ERROR_NOMEMORY (-6) buffer too small
+                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_copy_named_substring(const pcre *code, const char *subject, int *ovector,
+  int stringcount, const char *stringname, char *buffer, int size)
+{
+int n = get_first_set(code, stringname, ovector);
+if (n <= 0) return n;
+return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);
+}
+
+
+
+/*************************************************
+*      Copy all captured strings to new store    *
+*************************************************/
+
+/* This function gets one chunk of store and builds a list of pointers and all
+of the captured substrings in it. A NULL pointer is put on the end of the list.
+
+Arguments:
+  subject        the subject string that was matched
+  ovector        pointer to the offsets table
+  stringcount    the number of substrings that were captured
+                   (i.e. the yield of the pcre_exec call, unless
+                   that was zero, in which case it should be 1/3
+                   of the offset table size)
+  listptr        set to point to the list of pointers
+
+Returns:         if successful: 0
+                 if not successful:
+                   PCRE_ERROR_NOMEMORY (-6) failed to get store
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
+  const char ***listptr)
+{
+int i;
+int size = sizeof(char *);
+int double_count = stringcount * 2;
+char **stringlist;
+char *p;
+
+for (i = 0; i < double_count; i += 2)
+  size += sizeof(char *) + ovector[i+1] - ovector[i] + 1;
+
+stringlist = (char **)(pcre_malloc)(size);
+if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;
+
+*listptr = (const char **)stringlist;
+p = (char *)(stringlist + stringcount + 1);
+
+for (i = 0; i < double_count; i += 2)
+  {
+  int len = ovector[i+1] - ovector[i];
+  memcpy(p, subject + ovector[i], len);
+  *stringlist++ = p;
+  p += len;
+  *p++ = 0;
+  }
+
+*stringlist = NULL;
+return 0;
+}
+
+
+
+/*************************************************
+*   Free store obtained by get_substring_list    *
+*************************************************/
+
+/* This function exists for the benefit of people calling PCRE from non-C
+programs that can call its functions, but not free() or (pcre_free)() directly.
+
+Argument:   the result of a previous pcre_get_substring_list()
+Returns:    nothing
+*/
+
+PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
+pcre_free_substring_list(const char **pointer)
+{
+(pcre_free)((void *)pointer);
+}
+
+
+
+/*************************************************
+*      Copy captured string to new store         *
+*************************************************/
+
+/* This function copies a single captured substring into a piece of new
+store
+
+Arguments:
+  subject        the subject string that was matched
+  ovector        pointer to the offsets table
+  stringcount    the number of substrings that were captured
+                   (i.e. the yield of the pcre_exec call, unless
+                   that was zero, in which case it should be 1/3
+                   of the offset table size)
+  stringnumber   the number of the required substring
+  stringptr      where to put a pointer to the substring
+
+Returns:         if successful:
+                   the length of the string, not including the zero that
+                   is put on the end; can be zero
+                 if not successful:
+                   PCRE_ERROR_NOMEMORY (-6) failed to get store
+                   PCRE_ERROR_NOSUBSTRING (-7) substring not present
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_get_substring(const char *subject, int *ovector, int stringcount,
+  int stringnumber, const char **stringptr)
+{
+int yield;
+char *substring;
+if (stringnumber < 0 || stringnumber >= stringcount)
+  return PCRE_ERROR_NOSUBSTRING;
+stringnumber *= 2;
+yield = ovector[stringnumber+1] - ovector[stringnumber];
+substring = (char *)(pcre_malloc)(yield + 1);
+if (substring == NULL) return PCRE_ERROR_NOMEMORY;
+memcpy(substring, subject + ovector[stringnumber], yield);
+substring[yield] = 0;
+*stringptr = substring;
+return yield;
+}
+
+
+
+/*************************************************
+*   Copy named captured string to new store      *
+*************************************************/
+
+/* This function copies a single captured substring, identified by name, into
+new store. If the regex permits duplicate names, the first substring that is
+set is chosen.
+
+Arguments:
+  code           the compiled regex
+  subject        the subject string that was matched
+  ovector        pointer to the offsets table
+  stringcount    the number of substrings that were captured
+                   (i.e. the yield of the pcre_exec call, unless
+                   that was zero, in which case it should be 1/3
+                   of the offset table size)
+  stringname     the name of the required substring
+  stringptr      where to put the pointer
+
+Returns:         if successful:
+                   the length of the copied string, not including the zero
+                   that is put on the end; can be zero
+                 if not successful:
+                   PCRE_ERROR_NOMEMORY (-6) couldn't get memory
+                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_get_named_substring(const pcre *code, const char *subject, int *ovector,
+  int stringcount, const char *stringname, const char **stringptr)
+{
+int n = get_first_set(code, stringname, ovector);
+if (n <= 0) return n;
+return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
+}
+
+
+
+
+/*************************************************
+*       Free store obtained by get_substring     *
+*************************************************/
+
+/* This function exists for the benefit of people calling PCRE from non-C
+programs that can call its functions, but not free() or (pcre_free)() directly.
+
+Argument:   the result of a previous pcre_get_substring()
+Returns:    nothing
+*/
+
+PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
+pcre_free_substring(const char *pointer)
+{
+(pcre_free)((void *)pointer);
+}
+
+/* End of pcre_get.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_globals.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,63 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains global variables that are exported by the PCRE library.
+PCRE is thread-clean and doesn't use any global variables in the normal sense.
+However, it calls memory allocation and freeing functions via the four
+indirections below, and it can optionally do callouts, using the fifth
+indirection. These values can be changed by the caller, but are shared between
+all threads. However, when compiling for Virtual Pascal, things are done
+differently, and global variables are not used (see pcre.in). */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+#ifndef VPCOMPAT
+PCRE_EXP_DATA_DEFN void *(*pcre_malloc)(size_t) = malloc;
+PCRE_EXP_DATA_DEFN void  (*pcre_free)(void *) = free;
+PCRE_EXP_DATA_DEFN void *(*pcre_stack_malloc)(size_t) = malloc;
+PCRE_EXP_DATA_DEFN void  (*pcre_stack_free)(void *) = free;
+PCRE_EXP_DATA_DEFN int   (*pcre_callout)(pcre_callout_block *) = NULL;
+#endif
+
+/* End of pcre_globals.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_info.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,93 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_info(), which gives some
+information about a compiled pattern. However, use of this function is now
+deprecated, as it has been superseded by pcre_fullinfo(). */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+* (Obsolete) Return info about compiled pattern  *
+*************************************************/
+
+/* This is the original "info" function. It picks potentially useful data out
+of the private structure, but its interface was too rigid. It remains for
+backwards compatibility. The public options are passed back in an int - though
+the re->options field has been expanded to a long int, all the public options
+at the low end of it, and so even on 16-bit systems this will still be OK.
+Therefore, I haven't changed the API for pcre_info().
+
+Arguments:
+  argument_re   points to compiled code
+  optptr        where to pass back the options
+  first_byte    where to pass back the first character,
+                or -1 if multiline and all branches start ^,
+                or -2 otherwise
+
+Returns:        number of capturing subpatterns
+                or negative values on error
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_info(const pcre *argument_re, int *optptr, int *first_byte)
+{
+real_pcre internal_re;
+const real_pcre *re = (const real_pcre *)argument_re;
+if (re == NULL) return PCRE_ERROR_NULL;
+if (re->magic_number != MAGIC_NUMBER)
+  {
+  re = _pcre_try_flipped(re, &internal_re, NULL, NULL);
+  if (re == NULL) return PCRE_ERROR_BADMAGIC;
+  }
+if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_OPTIONS);
+if (first_byte != NULL)
+  *first_byte = ((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :
+     ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
+return re->top_bracket;
+}
+
+/* End of pcre_info.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_internal.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1176 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+/* This header contains definitions that are shared between the different
+modules, but which are not relevant to the exported API. This includes some
+functions whose names all begin with "_pcre_". */
+
+#ifndef PCRE_INTERNAL_H
+#define PCRE_INTERNAL_H
+
+/* Define DEBUG to get debugging output on stdout. */
+
+#if 0
+#define DEBUG
+#endif
+
+/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
+inline, and there are *still* stupid compilers about that don't like indented
+pre-processor statements, or at least there were when I first wrote this. After
+all, it had only been about 10 years then...
+
+It turns out that the Mac Debugging.h header also defines the macro DPRINTF, so
+be absolutely sure we get our version. */
+
+#undef DPRINTF
+#ifdef DEBUG
+#define DPRINTF(p) printf p
+#else
+#define DPRINTF(p) /* Nothing */
+#endif
+
+
+/* Standard C headers plus the external interface definition. The only time
+setjmp and stdarg are used is when NO_RECURSE is set. */
+
+#include <ctype.h>
+#include <limits.h>
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* When compiling a DLL for Windows, the exported symbols have to be declared
+using some MS magic. I found some useful information on this web page:
+http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
+information there, using __declspec(dllexport) without "extern" we have a
+definition; with "extern" we have a declaration. The settings here override the
+setting in pcre.h (which is included below); it defines only PCRE_EXP_DECL,
+which is all that is needed for applications (they just import the symbols). We
+use:
+
+  PCRE_EXP_DECL       for declarations
+  PCRE_EXP_DEFN       for definitions of exported functions
+  PCRE_EXP_DATA_DEFN  for definitions of exported variables
+
+The reason for the two DEFN macros is that in non-Windows environments, one
+does not want to have "extern" before variable definitions because it leads to
+compiler warnings. So we distinguish between functions and variables. In
+Windows, the two should always be the same.
+
+The reason for wrapping this in #ifndef PCRE_EXP_DECL is so that pcretest,
+which is an application, but needs to import this file in order to "peek" at
+internals, can #include pcre.h first to get an application's-eye view.
+
+In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
+special-purpose environments) might want to stick other stuff in front of
+exported symbols. That's why, in the non-Windows case, we set PCRE_EXP_DEFN and
+PCRE_EXP_DATA_DEFN only if they are not already set. */
+
+#ifndef PCRE_EXP_DECL
+#  ifdef _WIN32
+#    ifndef PCRE_STATIC
+#      define PCRE_EXP_DECL       extern __declspec(dllexport)
+#      define PCRE_EXP_DEFN       __declspec(dllexport)
+#      define PCRE_EXP_DATA_DEFN  __declspec(dllexport)
+#    else
+#      define PCRE_EXP_DECL       extern
+#      define PCRE_EXP_DEFN
+#      define PCRE_EXP_DATA_DEFN
+#    endif
+#  else
+#    ifdef __cplusplus
+#      define PCRE_EXP_DECL       extern "C"
+#    else
+#      define PCRE_EXP_DECL       extern
+#    endif
+#    ifndef PCRE_EXP_DEFN
+#      define PCRE_EXP_DEFN       PCRE_EXP_DECL
+#    endif
+#    ifndef PCRE_EXP_DATA_DEFN
+#      define PCRE_EXP_DATA_DEFN
+#    endif
+#  endif
+#endif
+
+/* When compiling with the MSVC compiler, it is sometimes necessary to include
+a "calling convention" before exported function names. (This is secondhand
+information; I know nothing about MSVC myself). For example, something like
+
+  void __cdecl function(....)
+
+might be needed. In order so make this easy, all the exported functions have
+PCRE_CALL_CONVENTION just before their names. It is rarely needed; if not
+set, we ensure here that it has no effect. */
+
+#ifndef PCRE_CALL_CONVENTION
+#define PCRE_CALL_CONVENTION
+#endif
+
+/* We need to have types that specify unsigned 16-bit and 32-bit integers. We
+cannot determine these outside the compilation (e.g. by running a program as
+part of "configure") because PCRE is often cross-compiled for use on other
+systems. Instead we make use of the maximum sizes that are available at
+preprocessor time in standard C environments. */
+
+#if USHRT_MAX == 65535
+  typedef unsigned short pcre_uint16;
+  typedef short pcre_int16;
+#elif UINT_MAX == 65535
+  typedef unsigned int pcre_uint16;
+  typedef int pcre_int16;
+#else
+  #error Cannot determine a type for 16-bit unsigned integers
+#endif
+
+#if UINT_MAX == 4294967295
+  typedef unsigned int pcre_uint32;
+  typedef int pcre_int32;
+#elif ULONG_MAX == 4294967295
+  typedef unsigned long int pcre_uint32;
+  typedef long int pcre_int32;
+#else
+  #error Cannot determine a type for 32-bit unsigned integers
+#endif
+
+/* All character handling must be done as unsigned characters. Otherwise there
+are problems with top-bit-set characters and functions such as isspace().
+However, we leave the interface to the outside world as char *, because that
+should make things easier for callers. We define a short type for unsigned char
+to save lots of typing. I tried "uchar", but it causes problems on Digital
+Unix, where it is defined in sys/types, so use "uschar" instead. */
+
+typedef unsigned char uschar;
+
+/* This is an unsigned int value that no character can ever have. UTF-8
+characters only go up to 0x7fffffff (though Unicode doesn't go beyond
+0x0010ffff). */
+
+#define NOTACHAR 0xffffffff
+
+/* PCRE is able to support several different kinds of newline (CR, LF, CRLF,
+"any" and "anycrlf" at present). The following macros are used to package up
+testing for newlines. NLBLOCK, PSSTART, and PSEND are defined in the various
+modules to indicate in which datablock the parameters exist, and what the
+start/end of string field names are. */
+
+#define NLTYPE_FIXED    0     /* Newline is a fixed length string */
+#define NLTYPE_ANY      1     /* Newline is any Unicode line ending */
+#define NLTYPE_ANYCRLF  2     /* Newline is CR, LF, or CRLF */
+
+/* This macro checks for a newline at the given position */
+
+#define IS_NEWLINE(p) \
+  ((NLBLOCK->nltype != NLTYPE_FIXED)? \
+    ((p) < NLBLOCK->PSEND && \
+     _pcre_is_newline((p), NLBLOCK->nltype, NLBLOCK->PSEND, &(NLBLOCK->nllen),\
+       utf8)) \
+    : \
+    ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \
+     (p)[0] == NLBLOCK->nl[0] && \
+     (NLBLOCK->nllen == 1 || (p)[1] == NLBLOCK->nl[1]) \
+    ) \
+  )
+
+/* This macro checks for a newline immediately preceding the given position */
+
+#define WAS_NEWLINE(p) \
+  ((NLBLOCK->nltype != NLTYPE_FIXED)? \
+    ((p) > NLBLOCK->PSSTART && \
+     _pcre_was_newline((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \
+       &(NLBLOCK->nllen), utf8)) \
+    : \
+    ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \
+     (p)[-NLBLOCK->nllen] == NLBLOCK->nl[0] && \
+     (NLBLOCK->nllen == 1 || (p)[-NLBLOCK->nllen+1] == NLBLOCK->nl[1]) \
+    ) \
+  )
+
+/* When PCRE is compiled as a C++ library, the subject pointer can be replaced
+with a custom type. This makes it possible, for example, to allow pcre_exec()
+to process subject strings that are discontinuous by using a smart pointer
+class. It must always be possible to inspect all of the subject string in
+pcre_exec() because of the way it backtracks. Two macros are required in the
+normal case, for sign-unspecified and unsigned char pointers. The former is
+used for the external interface and appears in pcre.h, which is why its name
+must begin with PCRE_. */
+
+#ifdef CUSTOM_SUBJECT_PTR
+#define PCRE_SPTR CUSTOM_SUBJECT_PTR
+#define USPTR CUSTOM_SUBJECT_PTR
+#else
+#define PCRE_SPTR const char *
+#define USPTR const unsigned char *
+#endif
+
+
+
+/* Include the public PCRE header and the definitions of UCP character property
+values. */
+
+#include "pcre.h"
+#include "ucp.h"
+
+/* When compiling for use with the Virtual Pascal compiler, these functions
+need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
+option on the command line. */
+
+#ifdef VPCOMPAT
+#define strlen(s)        _strlen(s)
+#define strncmp(s1,s2,m) _strncmp(s1,s2,m)
+#define memcmp(s,c,n)    _memcmp(s,c,n)
+#define memcpy(d,s,n)    _memcpy(d,s,n)
+#define memmove(d,s,n)   _memmove(d,s,n)
+#define memset(s,c,n)    _memset(s,c,n)
+#else  /* VPCOMPAT */
+
+/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
+define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
+is set. Otherwise, include an emulating function for those systems that have
+neither (there some non-Unix environments where this is the case). */
+
+#ifndef HAVE_MEMMOVE
+#undef  memmove        /* some systems may have a macro */
+#ifdef HAVE_BCOPY
+#define memmove(a, b, c) bcopy(b, a, c)
+#else  /* HAVE_BCOPY */
+static void *
+pcre_memmove(void *d, const void *s, size_t n)
+{
+size_t i;
+unsigned char *dest = (unsigned char *)d;
+const unsigned char *src = (const unsigned char *)s;
+if (dest > src)
+  {
+  dest += n;
+  src += n;
+  for (i = 0; i < n; ++i) *(--dest) = *(--src);
+  return (void *)dest;
+  }
+else
+  {
+  for (i = 0; i < n; ++i) *dest++ = *src++;
+  return (void *)(dest - n);
+  }
+}
+#define memmove(a, b, c) pcre_memmove(a, b, c)
+#endif   /* not HAVE_BCOPY */
+#endif   /* not HAVE_MEMMOVE */
+#endif   /* not VPCOMPAT */
+
+
+/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored
+in big-endian order) by default. These are used, for example, to link from the
+start of a subpattern to its alternatives and its end. The use of 2 bytes per
+offset limits the size of the compiled regex to around 64K, which is big enough
+for almost everybody. However, I received a request for an even bigger limit.
+For this reason, and also to make the code easier to maintain, the storing and
+loading of offsets from the byte string is now handled by the macros that are
+defined here.
+
+The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
+the config.h file, but can be overridden by using -D on the command line. This
+is automated on Unix systems via the "configure" command. */
+
+#if LINK_SIZE == 2
+
+#define PUT(a,n,d)   \
+  (a[n] = (d) >> 8), \
+  (a[(n)+1] = (d) & 255)
+
+#define GET(a,n) \
+  (((a)[n] << 8) | (a)[(n)+1])
+
+#define MAX_PATTERN_SIZE (1 << 16)
+
+
+#elif LINK_SIZE == 3
+
+#define PUT(a,n,d)       \
+  (a[n] = (d) >> 16),    \
+  (a[(n)+1] = (d) >> 8), \
+  (a[(n)+2] = (d) & 255)
+
+#define GET(a,n) \
+  (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
+
+#define MAX_PATTERN_SIZE (1 << 24)
+
+
+#elif LINK_SIZE == 4
+
+#define PUT(a,n,d)        \
+  (a[n] = (d) >> 24),     \
+  (a[(n)+1] = (d) >> 16), \
+  (a[(n)+2] = (d) >> 8),  \
+  (a[(n)+3] = (d) & 255)
+
+#define GET(a,n) \
+  (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
+
+#define MAX_PATTERN_SIZE (1 << 30)   /* Keep it positive */
+
+
+#else
+#error LINK_SIZE must be either 2, 3, or 4
+#endif
+
+
+/* Convenience macro defined in terms of the others */
+
+#define PUTINC(a,n,d)   PUT(a,n,d), a += LINK_SIZE
+
+
+/* PCRE uses some other 2-byte quantities that do not change when the size of
+offsets changes. There are used for repeat counts and for other things such as
+capturing parenthesis numbers in back references. */
+
+#define PUT2(a,n,d)   \
+  a[n] = (d) >> 8; \
+  a[(n)+1] = (d) & 255
+
+#define GET2(a,n) \
+  (((a)[n] << 8) | (a)[(n)+1])
+
+#define PUT2INC(a,n,d)  PUT2(a,n,d), a += 2
+
+
+/* When UTF-8 encoding is being used, a character is no longer just a single
+byte. The macros for character handling generate simple sequences when used in
+byte-mode, and more complicated ones for UTF-8 characters. BACKCHAR should
+never be called in byte mode. To make sure it can never even appear when UTF-8
+support is omitted, we don't even define it. */
+
+#ifndef SUPPORT_UTF8
+#define GETCHAR(c, eptr) c = *eptr;
+#define GETCHARTEST(c, eptr) c = *eptr;
+#define GETCHARINC(c, eptr) c = *eptr++;
+#define GETCHARINCTEST(c, eptr) c = *eptr++;
+#define GETCHARLEN(c, eptr, len) c = *eptr;
+/* #define BACKCHAR(eptr) */
+
+#else   /* SUPPORT_UTF8 */
+
+/* Get the next UTF-8 character, not advancing the pointer. This is called when
+we know we are in UTF-8 mode. */
+
+#define GETCHAR(c, eptr) \
+  c = *eptr; \
+  if (c >= 0xc0) \
+    { \
+    int gcii; \
+    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \
+    int gcss = 6*gcaa; \
+    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
+    for (gcii = 1; gcii <= gcaa; gcii++) \
+      { \
+      gcss -= 6; \
+      c |= (eptr[gcii] & 0x3f) << gcss; \
+      } \
+    }
+
+/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the
+pointer. */
+
+#define GETCHARTEST(c, eptr) \
+  c = *eptr; \
+  if (utf8 && c >= 0xc0) \
+    { \
+    int gcii; \
+    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \
+    int gcss = 6*gcaa; \
+    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
+    for (gcii = 1; gcii <= gcaa; gcii++) \
+      { \
+      gcss -= 6; \
+      c |= (eptr[gcii] & 0x3f) << gcss; \
+      } \
+    }
+
+/* Get the next UTF-8 character, advancing the pointer. This is called when we
+know we are in UTF-8 mode. */
+
+#define GETCHARINC(c, eptr) \
+  c = *eptr++; \
+  if (c >= 0xc0) \
+    { \
+    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \
+    int gcss = 6*gcaa; \
+    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
+    while (gcaa-- > 0) \
+      { \
+      gcss -= 6; \
+      c |= (*eptr++ & 0x3f) << gcss; \
+      } \
+    }
+
+/* Get the next character, testing for UTF-8 mode, and advancing the pointer */
+
+#define GETCHARINCTEST(c, eptr) \
+  c = *eptr++; \
+  if (utf8 && c >= 0xc0) \
+    { \
+    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \
+    int gcss = 6*gcaa; \
+    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
+    while (gcaa-- > 0) \
+      { \
+      gcss -= 6; \
+      c |= (*eptr++ & 0x3f) << gcss; \
+      } \
+    }
+
+/* Get the next UTF-8 character, not advancing the pointer, incrementing length
+if there are extra bytes. This is called when we know we are in UTF-8 mode. */
+
+#define GETCHARLEN(c, eptr, len) \
+  c = *eptr; \
+  if (c >= 0xc0) \
+    { \
+    int gcii; \
+    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \
+    int gcss = 6*gcaa; \
+    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
+    for (gcii = 1; gcii <= gcaa; gcii++) \
+      { \
+      gcss -= 6; \
+      c |= (eptr[gcii] & 0x3f) << gcss; \
+      } \
+    len += gcaa; \
+    }
+
+/* If the pointer is not at the start of a character, move it back until
+it is. This is called only in UTF-8 mode - we don't put a test within the macro
+because almost all calls are already within a block of UTF-8 only code. */
+
+#define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--
+
+#endif
+
+
+/* In case there is no definition of offsetof() provided - though any proper
+Standard C system should have one. */
+
+#ifndef offsetof
+#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
+#endif
+
+
+/* These are the public options that can change during matching. */
+
+#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
+
+/* Private flags containing information about the compiled regex. They used to
+live at the top end of the options word, but that got almost full, so now they
+are in a 16-bit flags word. */
+
+#define PCRE_NOPARTIAL     0x0001  /* can't use partial with this regex */
+#define PCRE_FIRSTSET      0x0002  /* first_byte is set */
+#define PCRE_REQCHSET      0x0004  /* req_byte is set */
+#define PCRE_STARTLINE     0x0008  /* start after \n for multiline */
+#define PCRE_JCHANGED      0x0010  /* j option used in regex */
+#define PCRE_HASCRORLF     0x0020  /* explicit \r or \n in pattern */
+
+/* Options for the "extra" block produced by pcre_study(). */
+
+#define PCRE_STUDY_MAPPED   0x01     /* a map of starting chars exists */
+
+/* Masks for identifying the public options that are permitted at compile
+time, run time, or study time, respectively. */
+
+#define PCRE_NEWLINE_BITS (PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_ANY| \
+                           PCRE_NEWLINE_ANYCRLF)
+
+#define PUBLIC_OPTIONS \
+  (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
+   PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
+   PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \
+   PCRE_DUPNAMES|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
+   PCRE_JAVASCRIPT_COMPAT)
+
+#define PUBLIC_EXEC_OPTIONS \
+  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
+   PCRE_PARTIAL|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)
+
+#define PUBLIC_DFA_EXEC_OPTIONS \
+  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
+   PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART|PCRE_NEWLINE_BITS| \
+   PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)
+
+#define PUBLIC_STUDY_OPTIONS 0   /* None defined */
+
+/* Magic number to provide a small check against being handed junk. Also used
+to detect whether a pattern was compiled on a host of different endianness. */
+
+#define MAGIC_NUMBER  0x50435245UL   /* 'PCRE' */
+
+/* Negative values for the firstchar and reqchar variables */
+
+#define REQ_UNSET (-2)
+#define REQ_NONE  (-1)
+
+/* The maximum remaining length of subject we are prepared to search for a
+req_byte match. */
+
+#define REQ_BYTE_MAX 1000
+
+/* Flags added to firstbyte or reqbyte; a "non-literal" item is either a
+variable-length repeat, or a anything other than literal characters. */
+
+#define REQ_CASELESS 0x0100    /* indicates caselessness */
+#define REQ_VARY     0x0200    /* reqbyte followed non-literal item */
+
+/* Miscellaneous definitions. The #ifndef is to pacify compiler warnings in
+environments where these macros are defined elsewhere. */
+
+#ifndef FALSE
+typedef int BOOL;
+
+#define FALSE   0
+#define TRUE    1
+#endif
+
+/* Escape items that are just an encoding of a particular data value. */
+
+#ifndef ESC_e
+#define ESC_e 27
+#endif
+
+#ifndef ESC_f
+#define ESC_f '\f'
+#endif
+
+#ifndef ESC_n
+#define ESC_n '\n'
+#endif
+
+#ifndef ESC_r
+#define ESC_r '\r'
+#endif
+
+/* We can't officially use ESC_t because it is a POSIX reserved identifier
+(presumably because of all the others like size_t). */
+
+#ifndef ESC_tee
+#define ESC_tee '\t'
+#endif
+
+/* Codes for different types of Unicode property */
+
+#define PT_ANY        0    /* Any property - matches all chars */
+#define PT_LAMP       1    /* L& - the union of Lu, Ll, Lt */
+#define PT_GC         2    /* General characteristic (e.g. L) */
+#define PT_PC         3    /* Particular characteristic (e.g. Lu) */
+#define PT_SC         4    /* Script (e.g. Han) */
+
+/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
+contain UTF-8 characters with values greater than 255. */
+
+#define XCL_NOT    0x01    /* Flag: this is a negative class */
+#define XCL_MAP    0x02    /* Flag: a 32-byte map is present */
+
+#define XCL_END       0    /* Marks end of individual items */
+#define XCL_SINGLE    1    /* Single item (one multibyte char) follows */
+#define XCL_RANGE     2    /* A range (two multibyte chars) follows */
+#define XCL_PROP      3    /* Unicode property (2-byte property code follows) */
+#define XCL_NOTPROP   4    /* Unicode inverted property (ditto) */
+
+/* These are escaped items that aren't just an encoding of a particular data
+value such as \n. They must have non-zero values, as check_escape() returns
+their negation. Also, they must appear in the same order as in the opcode
+definitions below, up to ESC_z. There's a dummy for OP_ANY because it
+corresponds to "." rather than an escape sequence, and another for OP_ALLANY
+(which is used for [^] in JavaScript compatibility mode).
+
+The final escape must be ESC_REF as subsequent values are used for
+backreferences (\1, \2, \3, etc). There are two tests in the code for an escape
+greater than ESC_b and less than ESC_Z to detect the types that may be
+repeated. These are the types that consume characters. If any new escapes are
+put in between that don't consume a character, that code will have to change.
+*/
+
+enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
+       ESC_W, ESC_w, ESC_dum1, ESC_dum2, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
+       ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_g, ESC_k,
+       ESC_REF };
+
+
+/* Opcode table: Starting from 1 (i.e. after OP_END), the values up to
+OP_EOD must correspond in order to the list of escapes immediately above.
+
+*** NOTE NOTE NOTE *** Whenever this list is updated, the two macro definitions
+that follow must also be updated to match. There is also a table called
+"coptable" in pcre_dfa_exec.c that must be updated. */
+
+enum {
+  OP_END,            /* 0 End of pattern */
+
+  /* Values corresponding to backslashed metacharacters */
+
+  OP_SOD,            /* 1 Start of data: \A */
+  OP_SOM,            /* 2 Start of match (subject + offset): \G */
+  OP_SET_SOM,        /* 3 Set start of match (\K) */
+  OP_NOT_WORD_BOUNDARY,  /*  4 \B */
+  OP_WORD_BOUNDARY,      /*  5 \b */
+  OP_NOT_DIGIT,          /*  6 \D */
+  OP_DIGIT,              /*  7 \d */
+  OP_NOT_WHITESPACE,     /*  8 \S */
+  OP_WHITESPACE,         /*  9 \s */
+  OP_NOT_WORDCHAR,       /* 10 \W */
+  OP_WORDCHAR,           /* 11 \w */
+  OP_ANY,            /* 12 Match any character (subject to DOTALL) */
+  OP_ALLANY,         /* 13 Match any character (not subject to DOTALL) */
+  OP_ANYBYTE,        /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */
+  OP_NOTPROP,        /* 15 \P (not Unicode property) */
+  OP_PROP,           /* 16 \p (Unicode property) */
+  OP_ANYNL,          /* 17 \R (any newline sequence) */
+  OP_NOT_HSPACE,     /* 18 \H (not horizontal whitespace) */
+  OP_HSPACE,         /* 19 \h (horizontal whitespace) */
+  OP_NOT_VSPACE,     /* 20 \V (not vertical whitespace) */
+  OP_VSPACE,         /* 21 \v (vertical whitespace) */
+  OP_EXTUNI,         /* 22 \X (extended Unicode sequence */
+  OP_EODN,           /* 23 End of data or \n at end of data: \Z. */
+  OP_EOD,            /* 24 End of data: \z */
+
+  OP_OPT,            /* 25 Set runtime options */
+  OP_CIRC,           /* 26 Start of line - varies with multiline switch */
+  OP_DOLL,           /* 27 End of line - varies with multiline switch */
+  OP_CHAR,           /* 28 Match one character, casefully */
+  OP_CHARNC,         /* 29 Match one character, caselessly */
+  OP_NOT,            /* 30 Match one character, not the following one */
+
+  OP_STAR,           /* 31 The maximizing and minimizing versions of */
+  OP_MINSTAR,        /* 32 these six opcodes must come in pairs, with */
+  OP_PLUS,           /* 33 the minimizing one second. */
+  OP_MINPLUS,        /* 34 This first set applies to single characters.*/
+  OP_QUERY,          /* 35 */
+  OP_MINQUERY,       /* 36 */
+
+  OP_UPTO,           /* 37 From 0 to n matches */
+  OP_MINUPTO,        /* 38 */
+  OP_EXACT,          /* 39 Exactly n matches */
+
+  OP_POSSTAR,        /* 40 Possessified star */
+  OP_POSPLUS,        /* 41 Possessified plus */
+  OP_POSQUERY,       /* 42 Posesssified query */
+  OP_POSUPTO,        /* 43 Possessified upto */
+
+  OP_NOTSTAR,        /* 44 The maximizing and minimizing versions of */
+  OP_NOTMINSTAR,     /* 45 these six opcodes must come in pairs, with */
+  OP_NOTPLUS,        /* 46 the minimizing one second. They must be in */
+  OP_NOTMINPLUS,     /* 47 exactly the same order as those above. */
+  OP_NOTQUERY,       /* 48 This set applies to "not" single characters. */
+  OP_NOTMINQUERY,    /* 49 */
+
+  OP_NOTUPTO,        /* 50 From 0 to n matches */
+  OP_NOTMINUPTO,     /* 51 */
+  OP_NOTEXACT,       /* 52 Exactly n matches */
+
+  OP_NOTPOSSTAR,     /* 53 Possessified versions */
+  OP_NOTPOSPLUS,     /* 54 */
+  OP_NOTPOSQUERY,    /* 55 */
+  OP_NOTPOSUPTO,     /* 56 */
+
+  OP_TYPESTAR,       /* 57 The maximizing and minimizing versions of */
+  OP_TYPEMINSTAR,    /* 58 these six opcodes must come in pairs, with */
+  OP_TYPEPLUS,       /* 59 the minimizing one second. These codes must */
+  OP_TYPEMINPLUS,    /* 60 be in exactly the same order as those above. */
+  OP_TYPEQUERY,      /* 61 This set applies to character types such as \d */
+  OP_TYPEMINQUERY,   /* 62 */
+
+  OP_TYPEUPTO,       /* 63 From 0 to n matches */
+  OP_TYPEMINUPTO,    /* 64 */
+  OP_TYPEEXACT,      /* 65 Exactly n matches */
+
+  OP_TYPEPOSSTAR,    /* 66 Possessified versions */
+  OP_TYPEPOSPLUS,    /* 67 */
+  OP_TYPEPOSQUERY,   /* 68 */
+  OP_TYPEPOSUPTO,    /* 69 */
+
+  OP_CRSTAR,         /* 70 The maximizing and minimizing versions of */
+  OP_CRMINSTAR,      /* 71 all these opcodes must come in pairs, with */
+  OP_CRPLUS,         /* 72 the minimizing one second. These codes must */
+  OP_CRMINPLUS,      /* 73 be in exactly the same order as those above. */
+  OP_CRQUERY,        /* 74 These are for character classes and back refs */
+  OP_CRMINQUERY,     /* 75 */
+  OP_CRRANGE,        /* 76 These are different to the three sets above. */
+  OP_CRMINRANGE,     /* 77 */
+
+  OP_CLASS,          /* 78 Match a character class, chars < 256 only */
+  OP_NCLASS,         /* 79 Same, but the bitmap was created from a negative
+                           class - the difference is relevant only when a UTF-8
+                           character > 255 is encountered. */
+
+  OP_XCLASS,         /* 80 Extended class for handling UTF-8 chars within the
+                           class. This does both positive and negative. */
+
+  OP_REF,            /* 81 Match a back reference */
+  OP_RECURSE,        /* 82 Match a numbered subpattern (possibly recursive) */
+  OP_CALLOUT,        /* 83 Call out to external function if provided */
+
+  OP_ALT,            /* 84 Start of alternation */
+  OP_KET,            /* 85 End of group that doesn't have an unbounded repeat */
+  OP_KETRMAX,        /* 86 These two must remain together and in this */
+  OP_KETRMIN,        /* 87 order. They are for groups the repeat for ever. */
+
+  /* The assertions must come before BRA, CBRA, ONCE, and COND.*/
+
+  OP_ASSERT,         /* 88 Positive lookahead */
+  OP_ASSERT_NOT,     /* 89 Negative lookahead */
+  OP_ASSERTBACK,     /* 90 Positive lookbehind */
+  OP_ASSERTBACK_NOT, /* 91 Negative lookbehind */
+  OP_REVERSE,        /* 92 Move pointer back - used in lookbehind assertions */
+
+  /* ONCE, BRA, CBRA, and COND must come after the assertions, with ONCE first,
+  as there's a test for >= ONCE for a subpattern that isn't an assertion. */
+
+  OP_ONCE,           /* 93 Atomic group */
+  OP_BRA,            /* 94 Start of non-capturing bracket */
+  OP_CBRA,           /* 95 Start of capturing bracket */
+  OP_COND,           /* 96 Conditional group */
+
+  /* These three must follow the previous three, in the same order. There's a
+  check for >= SBRA to distinguish the two sets. */
+
+  OP_SBRA,           /* 97 Start of non-capturing bracket, check empty  */
+  OP_SCBRA,          /* 98 Start of capturing bracket, check empty */
+  OP_SCOND,          /* 99 Conditional group, check empty */
+
+  OP_CREF,           /* 100 Used to hold a capture number as condition */
+  OP_RREF,           /* 101 Used to hold a recursion number as condition */
+  OP_DEF,            /* 102 The DEFINE condition */
+
+  OP_BRAZERO,        /* 103 These two must remain together and in this */
+  OP_BRAMINZERO,     /* 104 order. */
+
+  /* These are backtracking control verbs */
+
+  OP_PRUNE,          /* 105 */
+  OP_SKIP,           /* 106 */
+  OP_THEN,           /* 107 */
+  OP_COMMIT,         /* 108 */
+
+  /* These are forced failure and success verbs */
+
+  OP_FAIL,           /* 109 */
+  OP_ACCEPT,         /* 110 */
+
+  /* This is used to skip a subpattern with a {0} quantifier */
+
+  OP_SKIPZERO        /* 111 */
+};
+
+
+/* This macro defines textual names for all the opcodes. These are used only
+for debugging. The macro is referenced only in pcre_printint.c. */
+
+#define OP_NAME_LIST \
+  "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d",         \
+  "\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte",         \
+  "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v",           \
+  "extuni",  "\\Z", "\\z",                                        \
+  "Opt", "^", "$", "char", "charnc", "not",                       \
+  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
+  "*+","++", "?+", "{",                                           \
+  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
+  "*+","++", "?+", "{",                                           \
+  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
+  "*+","++", "?+", "{",                                           \
+  "*", "*?", "+", "+?", "?", "??", "{", "{",                      \
+  "class", "nclass", "xclass", "Ref", "Recurse", "Callout",       \
+  "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",     \
+  "AssertB", "AssertB not", "Reverse",                            \
+  "Once", "Bra", "CBra", "Cond", "SBra", "SCBra", "SCond",        \
+  "Cond ref", "Cond rec", "Cond def", "Brazero", "Braminzero",    \
+  "*PRUNE", "*SKIP", "*THEN", "*COMMIT", "*FAIL", "*ACCEPT",      \
+  "Skip zero"
+
+
+/* This macro defines the length of fixed length operations in the compiled
+regex. The lengths are used when searching for specific things, and also in the
+debugging printing of a compiled regex. We use a macro so that it can be
+defined close to the definitions of the opcodes themselves.
+
+As things have been extended, some of these are no longer fixed lenths, but are
+minima instead. For example, the length of a single-character repeat may vary
+in UTF-8 mode. The code that uses this table must know about such things. */
+
+#define OP_LENGTHS \
+  1,                             /* End                                    */ \
+  1, 1, 1, 1, 1,                 /* \A, \G, \K, \B, \b                     */ \
+  1, 1, 1, 1, 1, 1,              /* \D, \d, \S, \s, \W, \w                 */ \
+  1, 1, 1,                       /* Any, AllAny, Anybyte                   */ \
+  3, 3, 1,                       /* NOTPROP, PROP, EXTUNI                  */ \
+  1, 1, 1, 1, 1,                 /* \R, \H, \h, \V, \v                     */ \
+  1, 1, 2, 1, 1,                 /* \Z, \z, Opt, ^, $                      */ \
+  2,                             /* Char  - the minimum length             */ \
+  2,                             /* Charnc  - the minimum length           */ \
+  2,                             /* not                                    */ \
+  /* Positive single-char repeats                            ** These are  */ \
+  2, 2, 2, 2, 2, 2,              /* *, *?, +, +?, ?, ??      ** minima in  */ \
+  4, 4, 4,                       /* upto, minupto, exact     ** UTF-8 mode */ \
+  2, 2, 2, 4,                    /* *+, ++, ?+, upto+                      */ \
+  /* Negative single-char repeats - only for chars < 256                   */ \
+  2, 2, 2, 2, 2, 2,              /* NOT *, *?, +, +?, ?, ??                */ \
+  4, 4, 4,                       /* NOT upto, minupto, exact               */ \
+  2, 2, 2, 4,                    /* Possessive *, +, ?, upto               */ \
+  /* Positive type repeats                                                 */ \
+  2, 2, 2, 2, 2, 2,              /* Type *, *?, +, +?, ?, ??               */ \
+  4, 4, 4,                       /* Type upto, minupto, exact              */ \
+  2, 2, 2, 4,                    /* Possessive *+, ++, ?+, upto+           */ \
+  /* Character class & ref repeats                                         */ \
+  1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */ \
+  5, 5,                          /* CRRANGE, CRMINRANGE                    */ \
+ 33,                             /* CLASS                                  */ \
+ 33,                             /* NCLASS                                 */ \
+  0,                             /* XCLASS - variable length               */ \
+  3,                             /* REF                                    */ \
+  1+LINK_SIZE,                   /* RECURSE                                */ \
+  2+2*LINK_SIZE,                 /* CALLOUT                                */ \
+  1+LINK_SIZE,                   /* Alt                                    */ \
+  1+LINK_SIZE,                   /* Ket                                    */ \
+  1+LINK_SIZE,                   /* KetRmax                                */ \
+  1+LINK_SIZE,                   /* KetRmin                                */ \
+  1+LINK_SIZE,                   /* Assert                                 */ \
+  1+LINK_SIZE,                   /* Assert not                             */ \
+  1+LINK_SIZE,                   /* Assert behind                          */ \
+  1+LINK_SIZE,                   /* Assert behind not                      */ \
+  1+LINK_SIZE,                   /* Reverse                                */ \
+  1+LINK_SIZE,                   /* ONCE                                   */ \
+  1+LINK_SIZE,                   /* BRA                                    */ \
+  3+LINK_SIZE,                   /* CBRA                                   */ \
+  1+LINK_SIZE,                   /* COND                                   */ \
+  1+LINK_SIZE,                   /* SBRA                                   */ \
+  3+LINK_SIZE,                   /* SCBRA                                  */ \
+  1+LINK_SIZE,                   /* SCOND                                  */ \
+  3,                             /* CREF                                   */ \
+  3,                             /* RREF                                   */ \
+  1,                             /* DEF                                    */ \
+  1, 1,                          /* BRAZERO, BRAMINZERO                    */ \
+  1, 1, 1, 1,                    /* PRUNE, SKIP, THEN, COMMIT,             */ \
+  1, 1, 1                        /* FAIL, ACCEPT, SKIPZERO                 */
+
+
+/* A magic value for OP_RREF to indicate the "any recursion" condition. */
+
+#define RREF_ANY  0xffff
+
+/* Error code numbers. They are given names so that they can more easily be
+tracked. */
+
+enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,
+       ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19,
+       ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29,
+       ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
+       ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
+       ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
+       ERR60, ERR61, ERR62, ERR63, ERR64 };
+
+/* The real format of the start of the pcre block; the index of names and the
+code vector run on as long as necessary after the end. We store an explicit
+offset to the name table so that if a regex is compiled on one host, saved, and
+then run on another where the size of pointers is different, all might still
+be well. For the case of compiled-on-4 and run-on-8, we include an extra
+pointer that is always NULL. For future-proofing, a few dummy fields were
+originally included - even though you can never get this planning right - but
+there is only one left now.
+
+NOTE NOTE NOTE:
+Because people can now save and re-use compiled patterns, any additions to this
+structure should be made at the end, and something earlier (e.g. a new
+flag in the options or one of the dummy fields) should indicate that the new
+fields are present. Currently PCRE always sets the dummy fields to zero.
+NOTE NOTE NOTE:
+*/
+
+typedef struct real_pcre {
+  pcre_uint32 magic_number;
+  pcre_uint32 size;               /* Total that was malloced */
+  pcre_uint32 options;            /* Public options */
+  pcre_uint16 flags;              /* Private flags */
+  pcre_uint16 dummy1;             /* For future use */
+  pcre_uint16 top_bracket;
+  pcre_uint16 top_backref;
+  pcre_uint16 first_byte;
+  pcre_uint16 req_byte;
+  pcre_uint16 name_table_offset;  /* Offset to name table that follows */
+  pcre_uint16 name_entry_size;    /* Size of any name items */
+  pcre_uint16 name_count;         /* Number of name items */
+  pcre_uint16 ref_count;          /* Reference count */
+
+  const unsigned char *tables;    /* Pointer to tables or NULL for std */
+  const unsigned char *nullpad;   /* NULL padding */
+} real_pcre;
+
+/* The format of the block used to store data from pcre_study(). The same
+remark (see NOTE above) about extending this structure applies. */
+
+typedef struct pcre_study_data {
+  pcre_uint32 size;               /* Total that was malloced */
+  pcre_uint32 options;
+  uschar start_bits[32];
+} pcre_study_data;
+
+/* Structure for passing "static" information around between the functions
+doing the compiling, so that they are thread-safe. */
+
+typedef struct compile_data {
+  const uschar *lcc;            /* Points to lower casing table */
+  const uschar *fcc;            /* Points to case-flipping table */
+  const uschar *cbits;          /* Points to character type table */
+  const uschar *ctypes;         /* Points to table of type maps */
+  const uschar *start_workspace;/* The start of working space */
+  const uschar *start_code;     /* The start of the compiled code */
+  const uschar *start_pattern;  /* The start of the pattern */
+  const uschar *end_pattern;    /* The end of the pattern */
+  uschar *hwm;                  /* High watermark of workspace */
+  uschar *name_table;           /* The name/number table */
+  int  names_found;             /* Number of entries so far */
+  int  name_entry_size;         /* Size of each entry */
+  int  bracount;                /* Count of capturing parens as we compile */
+  int  final_bracount;          /* Saved value after first pass */
+  int  top_backref;             /* Maximum back reference */
+  unsigned int backref_map;     /* Bitmap of low back refs */
+  int  external_options;        /* External (initial) options */
+  int  external_flags;          /* External flag bits to be set */
+  int  req_varyopt;             /* "After variable item" flag for reqbyte */
+  BOOL had_accept;              /* (*ACCEPT) encountered */
+  int  nltype;                  /* Newline type */
+  int  nllen;                   /* Newline string length */
+  uschar nl[4];                 /* Newline string when fixed length */
+} compile_data;
+
+/* Structure for maintaining a chain of pointers to the currently incomplete
+branches, for testing for left recursion. */
+
+typedef struct branch_chain {
+  struct branch_chain *outer;
+  uschar *current;
+} branch_chain;
+
+/* Structure for items in a linked list that represents an explicit recursive
+call within the pattern. */
+
+typedef struct recursion_info {
+  struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
+  int group_num;                /* Number of group that was called */
+  const uschar *after_call;     /* "Return value": points after the call in the expr */
+  USPTR save_start;             /* Old value of mstart */
+  int *offset_save;             /* Pointer to start of saved offsets */
+  int saved_max;                /* Number of saved offsets */
+} recursion_info;
+
+/* Structure for building a chain of data for holding the values of the subject
+pointer at the start of each subpattern, so as to detect when an empty string
+has been matched by a subpattern - to break infinite loops. */
+
+typedef struct eptrblock {
+  struct eptrblock *epb_prev;
+  USPTR epb_saved_eptr;
+} eptrblock;
+
+
+/* Structure for passing "static" information around between the functions
+doing traditional NFA matching, so that they are thread-safe. */
+
+typedef struct match_data {
+  unsigned long int match_call_count;      /* As it says */
+  unsigned long int match_limit;           /* As it says */
+  unsigned long int match_limit_recursion; /* As it says */
+  int   *offset_vector;         /* Offset vector */
+  int    offset_end;            /* One past the end */
+  int    offset_max;            /* The maximum usable for return data */
+  int    nltype;                /* Newline type */
+  int    nllen;                 /* Newline string length */
+  uschar nl[4];                 /* Newline string when fixed */
+  const uschar *lcc;            /* Points to lower casing table */
+  const uschar *ctypes;         /* Points to table of type maps */
+  BOOL   offset_overflow;       /* Set if too many extractions */
+  BOOL   notbol;                /* NOTBOL flag */
+  BOOL   noteol;                /* NOTEOL flag */
+  BOOL   utf8;                  /* UTF8 flag */
+  BOOL   jscript_compat;        /* JAVASCRIPT_COMPAT flag */
+  BOOL   endonly;               /* Dollar not before final \n */
+  BOOL   notempty;              /* Empty string match not wanted */
+  BOOL   partial;               /* PARTIAL flag */
+  BOOL   hitend;                /* Hit the end of the subject at some point */
+  BOOL   bsr_anycrlf;           /* \R is just any CRLF, not full Unicode */
+  const uschar *start_code;     /* For use when recursing */
+  USPTR  start_subject;         /* Start of the subject string */
+  USPTR  end_subject;           /* End of the subject string */
+  USPTR  start_match_ptr;       /* Start of matched string */
+  USPTR  end_match_ptr;         /* Subject position at end match */
+  int    end_offset_top;        /* Highwater mark at end of match */
+  int    capture_last;          /* Most recent capture number */
+  int    start_offset;          /* The start offset value */
+  eptrblock *eptrchain;         /* Chain of eptrblocks for tail recursions */
+  int    eptrn;                 /* Next free eptrblock */
+  recursion_info *recursive;    /* Linked list of recursion data */
+  void  *callout_data;          /* To pass back to callouts */
+} match_data;
+
+/* A similar structure is used for the same purpose by the DFA matching
+functions. */
+
+typedef struct dfa_match_data {
+  const uschar *start_code;     /* Start of the compiled pattern */
+  const uschar *start_subject;  /* Start of the subject string */
+  const uschar *end_subject;    /* End of subject string */
+  const uschar *tables;         /* Character tables */
+  int   moptions;               /* Match options */
+  int   poptions;               /* Pattern options */
+  int    nltype;                /* Newline type */
+  int    nllen;                 /* Newline string length */
+  uschar nl[4];                 /* Newline string when fixed */
+  void  *callout_data;          /* To pass back to callouts */
+} dfa_match_data;
+
+/* Bit definitions for entries in the pcre_ctypes table. */
+
+#define ctype_space   0x01
+#define ctype_letter  0x02
+#define ctype_digit   0x04
+#define ctype_xdigit  0x08
+#define ctype_word    0x10   /* alphanumeric or '_' */
+#define ctype_meta    0x80   /* regexp meta char or zero (end pattern) */
+
+/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
+of bits for a class map. Some classes are built by combining these tables. */
+
+#define cbit_space     0      /* [:space:] or \s */
+#define cbit_xdigit   32      /* [:xdigit:] */
+#define cbit_digit    64      /* [:digit:] or \d */
+#define cbit_upper    96      /* [:upper:] */
+#define cbit_lower   128      /* [:lower:] */
+#define cbit_word    160      /* [:word:] or \w */
+#define cbit_graph   192      /* [:graph:] */
+#define cbit_print   224      /* [:print:] */
+#define cbit_punct   256      /* [:punct:] */
+#define cbit_cntrl   288      /* [:cntrl:] */
+#define cbit_length  320      /* Length of the cbits table */
+
+/* Offsets of the various tables from the base tables pointer, and
+total length. */
+
+#define lcc_offset      0
+#define fcc_offset    256
+#define cbits_offset  512
+#define ctypes_offset (cbits_offset + cbit_length)
+#define tables_length (ctypes_offset + 256)
+
+/* Layout of the UCP type table that translates property names into types and
+codes. Each entry used to point directly to a name, but to reduce the number of
+relocations in shared libraries, it now has an offset into a single string
+instead. */
+
+typedef struct {
+  pcre_uint16 name_offset;
+  pcre_uint16 type;
+  pcre_uint16 value;
+} ucp_type_table;
+
+
+/* Internal shared data tables. These are tables that are used by more than one
+of the exported public functions. They have to be "external" in the C sense,
+but are not part of the PCRE public API. The data for these tables is in the
+pcre_tables.c module. */
+
+extern const int    _pcre_utf8_table1[];
+extern const int    _pcre_utf8_table2[];
+extern const int    _pcre_utf8_table3[];
+extern const uschar _pcre_utf8_table4[];
+
+extern const int    _pcre_utf8_table1_size;
+
+extern const char   _pcre_utt_names[];
+extern const ucp_type_table _pcre_utt[];
+extern const int _pcre_utt_size;
+
+extern const uschar _pcre_default_tables[];
+
+extern const uschar _pcre_OP_lengths[];
+
+
+/* Internal shared functions. These are functions that are used by more than
+one of the exported public functions. They have to be "external" in the C
+sense, but are not part of the PCRE public API. */
+
+extern BOOL         _pcre_is_newline(const uschar *, int, const uschar *,
+                      int *, BOOL);
+extern int          _pcre_ord2utf8(int, uschar *);
+extern real_pcre   *_pcre_try_flipped(const real_pcre *, real_pcre *,
+                      const pcre_study_data *, pcre_study_data *);
+extern int          _pcre_valid_utf8(const uschar *, int);
+extern BOOL         _pcre_was_newline(const uschar *, int, const uschar *,
+                      int *, BOOL);
+extern BOOL         _pcre_xclass(int, const uschar *);
+
+
+/* Unicode character database (UCD) */
+
+typedef struct {
+  uschar script;
+  uschar chartype;
+  pcre_int32 other_case;
+} ucd_record;
+
+extern const ucd_record  _pcre_ucd_records[];
+extern const uschar      _pcre_ucd_stage1[];
+extern const pcre_uint16 _pcre_ucd_stage2[];
+extern const int         _pcre_ucp_gentype[];
+
+
+/* UCD access macros */
+
+#define UCD_BLOCK_SIZE 128
+#define GET_UCD(ch) (_pcre_ucd_records + \
+        _pcre_ucd_stage2[_pcre_ucd_stage1[(ch) / UCD_BLOCK_SIZE] * \
+        UCD_BLOCK_SIZE + ch % UCD_BLOCK_SIZE])
+
+#define UCD_CHARTYPE(ch)  GET_UCD(ch)->chartype
+#define UCD_SCRIPT(ch)    GET_UCD(ch)->script
+#define UCD_CATEGORY(ch)  _pcre_ucp_gentype[UCD_CHARTYPE(ch)]
+#define UCD_OTHERCASE(ch) (ch + GET_UCD(ch)->other_case)
+
+#endif
+
+/* End of pcre_internal.h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_maketables.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,143 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_maketables(), which builds
+character tables for PCRE in the current locale. The file is compiled on its
+own as part of the PCRE library. However, it is also included in the
+compilation of dftables.c, in which case the macro DFTABLES is defined. */
+
+
+#ifndef DFTABLES
+#  ifdef HAVE_CONFIG_H
+#  include "config.h"
+#  endif
+#  include "pcre_internal.h"
+#endif
+
+
+/*************************************************
+*           Create PCRE character tables         *
+*************************************************/
+
+/* This function builds a set of character tables for use by PCRE and returns
+a pointer to them. They are build using the ctype functions, and consequently
+their contents will depend upon the current locale setting. When compiled as
+part of the library, the store is obtained via pcre_malloc(), but when compiled
+inside dftables, use malloc().
+
+Arguments:   none
+Returns:     pointer to the contiguous block of data
+*/
+
+const unsigned char *
+pcre_maketables(void)
+{
+unsigned char *yield, *p;
+int i;
+
+#ifndef DFTABLES
+yield = (unsigned char*)(pcre_malloc)(tables_length);
+#else
+yield = (unsigned char*)malloc(tables_length);
+#endif
+
+if (yield == NULL) return NULL;
+p = yield;
+
+/* First comes the lower casing table */
+
+for (i = 0; i < 256; i++) *p++ = tolower(i);
+
+/* Next the case-flipping table */
+
+for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
+
+/* Then the character class tables. Don't try to be clever and save effort on
+exclusive ones - in some locales things may be different. Note that the table
+for "space" includes everything "isspace" gives, including VT in the default
+locale. This makes it work for the POSIX class [:space:]. Note also that it is
+possible for a character to be alnum or alpha without being lower or upper,
+such as "male and female ordinals" (\xAA and \xBA) in the fr_FR locale (at
+least under Debian Linux's locales as of 12/2005). So we must test for alnum
+specially. */
+
+memset(p, 0, cbit_length);
+for (i = 0; i < 256; i++)
+  {
+  if (isdigit(i)) p[cbit_digit  + i/8] |= 1 << (i&7);
+  if (isupper(i)) p[cbit_upper  + i/8] |= 1 << (i&7);
+  if (islower(i)) p[cbit_lower  + i/8] |= 1 << (i&7);
+  if (isalnum(i)) p[cbit_word   + i/8] |= 1 << (i&7);
+  if (i == '_')   p[cbit_word   + i/8] |= 1 << (i&7);
+  if (isspace(i)) p[cbit_space  + i/8] |= 1 << (i&7);
+  if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
+  if (isgraph(i)) p[cbit_graph  + i/8] |= 1 << (i&7);
+  if (isprint(i)) p[cbit_print  + i/8] |= 1 << (i&7);
+  if (ispunct(i)) p[cbit_punct  + i/8] |= 1 << (i&7);
+  if (iscntrl(i)) p[cbit_cntrl  + i/8] |= 1 << (i&7);
+  }
+p += cbit_length;
+
+/* Finally, the character type table. In this, we exclude VT from the white
+space chars, because Perl doesn't recognize it as such for \s and for comments
+within regexes. */
+
+for (i = 0; i < 256; i++)
+  {
+  int x = 0;
+  if (i != 0x0b && isspace(i)) x += ctype_space;
+  if (isalpha(i)) x += ctype_letter;
+  if (isdigit(i)) x += ctype_digit;
+  if (isxdigit(i)) x += ctype_xdigit;
+  if (isalnum(i) || i == '_') x += ctype_word;
+
+  /* Note: strchr includes the terminating zero in the characters it considers.
+  In this instance, that is ok because we want binary zero to be flagged as a
+  meta-character, which in this sense is any character that terminates a run
+  of data characters. */
+
+  if (strchr("\\*+?{^.$|()[", i) != 0) x += ctype_meta;
+  *p++ = x;
+  }
+
+return yield;
+}
+
+/* End of pcre_maketables.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_newline.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,164 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains internal functions for testing newlines when more than
+one kind of newline is to be recognized. When a newline is found, its length is
+returned. In principle, we could implement several newline "types", each
+referring to a different set of newline characters. At present, PCRE supports
+only NLTYPE_FIXED, which gets handled without these functions, NLTYPE_ANYCRLF,
+and NLTYPE_ANY. The full list of Unicode newline characters is taken from
+http://unicode.org/unicode/reports/tr18/. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+
+/*************************************************
+*      Check for newline at given position       *
+*************************************************/
+
+/* It is guaranteed that the initial value of ptr is less than the end of the
+string that is being processed.
+
+Arguments:
+  ptr          pointer to possible newline
+  type         the newline type
+  endptr       pointer to the end of the string
+  lenptr       where to return the length
+  utf8         TRUE if in utf8 mode
+
+Returns:       TRUE or FALSE
+*/
+
+BOOL
+_pcre_is_newline(const uschar *ptr, int type, const uschar *endptr,
+  int *lenptr, BOOL utf8)
+{
+int c;
+if (utf8) { GETCHAR(c, ptr); } else c = *ptr;
+
+if (type == NLTYPE_ANYCRLF) switch(c)
+  {
+  case 0x000a: *lenptr = 1; return TRUE;             /* LF */
+  case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1;
+               return TRUE;                          /* CR */
+  default: return FALSE;
+  }
+
+/* NLTYPE_ANY */
+
+else switch(c)
+  {
+  case 0x000a:                                       /* LF */
+  case 0x000b:                                       /* VT */
+  case 0x000c: *lenptr = 1; return TRUE;             /* FF */
+  case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1;
+               return TRUE;                          /* CR */
+  case 0x0085: *lenptr = utf8? 2 : 1; return TRUE;   /* NEL */
+  case 0x2028:                                       /* LS */
+  case 0x2029: *lenptr = 3; return TRUE;             /* PS */
+  default: return FALSE;
+  }
+}
+
+
+
+/*************************************************
+*     Check for newline at previous position     *
+*************************************************/
+
+/* It is guaranteed that the initial value of ptr is greater than the start of
+the string that is being processed.
+
+Arguments:
+  ptr          pointer to possible newline
+  type         the newline type
+  startptr     pointer to the start of the string
+  lenptr       where to return the length
+  utf8         TRUE if in utf8 mode
+
+Returns:       TRUE or FALSE
+*/
+
+BOOL
+_pcre_was_newline(const uschar *ptr, int type, const uschar *startptr,
+  int *lenptr, BOOL utf8)
+{
+int c;
+ptr--;
+#ifdef SUPPORT_UTF8
+if (utf8)
+  {
+  BACKCHAR(ptr);
+  GETCHAR(c, ptr);
+  }
+else c = *ptr;
+#else   /* no UTF-8 support */
+c = *ptr;
+#endif  /* SUPPORT_UTF8 */
+
+if (type == NLTYPE_ANYCRLF) switch(c)
+  {
+  case 0x000a: *lenptr = (ptr > startptr && ptr[-1] == 0x0d)? 2 : 1;
+               return TRUE;                         /* LF */
+  case 0x000d: *lenptr = 1; return TRUE;            /* CR */
+  default: return FALSE;
+  }
+
+else switch(c)
+  {
+  case 0x000a: *lenptr = (ptr > startptr && ptr[-1] == 0x0d)? 2 : 1;
+               return TRUE;                         /* LF */
+  case 0x000b:                                      /* VT */
+  case 0x000c:                                      /* FF */
+  case 0x000d: *lenptr = 1; return TRUE;            /* CR */
+  case 0x0085: *lenptr = utf8? 2 : 1; return TRUE;  /* NEL */
+  case 0x2028:                                      /* LS */
+  case 0x2029: *lenptr = 3; return TRUE;            /* PS */
+  default: return FALSE;
+  }
+}
+
+/* End of pcre_newline.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_ord2utf8.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,87 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This file contains a private PCRE function that converts an ordinal
+character value into a UTF8 string. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+*       Convert character value to UTF-8         *
+*************************************************/
+
+/* This function takes an integer value in the range 0 - 0x7fffffff
+and encodes it as a UTF-8 character in 0 to 6 bytes.
+
+Arguments:
+  cvalue     the character value
+  buffer     pointer to buffer for result - at least 6 bytes long
+
+Returns:     number of characters placed in the buffer
+*/
+
+int
+_pcre_ord2utf8(int cvalue, uschar *buffer)
+{
+#ifdef SUPPORT_UTF8
+register int i, j;
+for (i = 0; i < _pcre_utf8_table1_size; i++)
+  if (cvalue <= _pcre_utf8_table1[i]) break;
+buffer += i;
+for (j = i; j > 0; j--)
+ {
+ *buffer-- = 0x80 | (cvalue & 0x3f);
+ cvalue >>= 6;
+ }
+*buffer = _pcre_utf8_table2[i] | cvalue;
+return i + 1;
+#else
+(void)(cvalue);  /* Keep compiler happy; this function won't ever be */
+(void)(buffer);  /* called when SUPPORT_UTF8 is not defined. */
+return 0;
+#endif
+}
+
+/* End of pcre_ord2utf8.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_printint.src	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,512 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains a PCRE private debugging function for printing out the
+internal form of a compiled regular expression, along with some supporting
+local functions. This source file is used in two places:
+
+(1) It is #included by pcre_compile.c when it is compiled in debugging mode
+(DEBUG defined in pcre_internal.h). It is not included in production compiles.
+
+(2) It is always #included by pcretest.c, which can be asked to print out a
+compiled regex for debugging purposes. */
+
+
+/* Macro that decides whether a character should be output as a literal or in
+hexadecimal. We don't use isprint() because that can vary from system to system
+(even without the use of locales) and we want the output always to be the same,
+for testing purposes. This macro is used in pcretest as well as in this file. */
+
+#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
+
+/* The table of operator names. */
+
+static const char *OP_names[] = { OP_NAME_LIST };
+
+
+
+/*************************************************
+*       Print single- or multi-byte character    *
+*************************************************/
+
+static int
+print_char(FILE *f, uschar *ptr, BOOL utf8)
+{
+int c = *ptr;
+
+#ifndef SUPPORT_UTF8
+utf8 = utf8;  /* Avoid compiler warning */
+if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
+return 0;
+
+#else
+if (!utf8 || (c & 0xc0) != 0xc0)
+  {
+  if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
+  return 0;
+  }
+else
+  {
+  int i;
+  int a = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */
+  int s = 6*a;
+  c = (c & _pcre_utf8_table3[a]) << s;
+  for (i = 1; i <= a; i++)
+    {
+    /* This is a check for malformed UTF-8; it should only occur if the sanity
+    check has been turned off. Rather than swallow random bytes, just stop if
+    we hit a bad one. Print it with \X instead of \x as an indication. */
+
+    if ((ptr[i] & 0xc0) != 0x80)
+      {
+      fprintf(f, "\\X{%x}", c);
+      return i - 1;
+      }
+
+    /* The byte is OK */
+
+    s -= 6;
+    c |= (ptr[i] & 0x3f) << s;
+    }
+  if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);
+  return a;
+  }
+#endif
+}
+
+
+
+/*************************************************
+*          Find Unicode property name            *
+*************************************************/
+
+static const char *
+get_ucpname(int ptype, int pvalue)
+{
+#ifdef SUPPORT_UCP
+int i;
+for (i = _pcre_utt_size - 1; i >= 0; i--)
+  {
+  if (ptype == _pcre_utt[i].type && pvalue == _pcre_utt[i].value) break;
+  }
+return (i >= 0)? _pcre_utt_names + _pcre_utt[i].name_offset : "??";
+#else
+/* It gets harder and harder to shut off unwanted compiler warnings. */
+ptype = ptype * pvalue;
+return (ptype == pvalue)? "??" : "??";
+#endif
+}
+
+
+
+/*************************************************
+*         Print compiled regex                   *
+*************************************************/
+
+/* Make this function work for a regex with integers either byte order.
+However, we assume that what we are passed is a compiled regex. The
+print_lengths flag controls whether offsets and lengths of items are printed.
+They can be turned off from pcretest so that automatic tests on bytecode can be
+written that do not depend on the value of LINK_SIZE. */
+
+static void
+pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
+{
+real_pcre *re = (real_pcre *)external_re;
+uschar *codestart, *code;
+BOOL utf8;
+
+unsigned int options = re->options;
+int offset = re->name_table_offset;
+int count = re->name_count;
+int size = re->name_entry_size;
+
+if (re->magic_number != MAGIC_NUMBER)
+  {
+  offset = ((offset << 8) & 0xff00) | ((offset >> 8) & 0xff);
+  count = ((count << 8) & 0xff00) | ((count >> 8) & 0xff);
+  size = ((size << 8) & 0xff00) | ((size >> 8) & 0xff);
+  options = ((options << 24) & 0xff000000) |
+            ((options <<  8) & 0x00ff0000) |
+            ((options >>  8) & 0x0000ff00) |
+            ((options >> 24) & 0x000000ff);
+  }
+
+code = codestart = (uschar *)re + offset + count * size;
+utf8 = (options & PCRE_UTF8) != 0;
+
+for(;;)
+  {
+  uschar *ccode;
+  int c;
+  int extra = 0;
+
+  if (print_lengths)
+    fprintf(f, "%3d ", (int)(code - codestart));
+  else
+    fprintf(f, "    ");
+
+  switch(*code)
+    {
+    case OP_END:
+    fprintf(f, "    %s\n", OP_names[*code]);
+    fprintf(f, "------------------------------------------------------------------\n");
+    return;
+
+    case OP_OPT:
+    fprintf(f, " %.2x %s", code[1], OP_names[*code]);
+    break;
+
+    case OP_CHAR:
+    fprintf(f, "    ");
+    do
+      {
+      code++;
+      code += 1 + print_char(f, code, utf8);
+      }
+    while (*code == OP_CHAR);
+    fprintf(f, "\n");
+    continue;
+
+    case OP_CHARNC:
+    fprintf(f, " NC ");
+    do
+      {
+      code++;
+      code += 1 + print_char(f, code, utf8);
+      }
+    while (*code == OP_CHARNC);
+    fprintf(f, "\n");
+    continue;
+
+    case OP_CBRA:
+    case OP_SCBRA:
+    if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+      else fprintf(f, "    ");
+    fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));
+    break;
+
+    case OP_BRA:
+    case OP_SBRA:
+    case OP_KETRMAX:
+    case OP_KETRMIN:
+    case OP_ALT:
+    case OP_KET:
+    case OP_ASSERT:
+    case OP_ASSERT_NOT:
+    case OP_ASSERTBACK:
+    case OP_ASSERTBACK_NOT:
+    case OP_ONCE:
+    case OP_COND:
+    case OP_SCOND:
+    case OP_REVERSE:
+    if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+      else fprintf(f, "    ");
+    fprintf(f, "%s", OP_names[*code]);
+    break;
+
+    case OP_CREF:
+    fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
+    break;
+
+    case OP_RREF:
+    c = GET2(code, 1);
+    if (c == RREF_ANY)
+      fprintf(f, "    Cond recurse any");
+    else
+      fprintf(f, "    Cond recurse %d", c);
+    break;
+
+    case OP_DEF:
+    fprintf(f, "    Cond def");
+    break;
+
+    case OP_STAR:
+    case OP_MINSTAR:
+    case OP_POSSTAR:
+    case OP_PLUS:
+    case OP_MINPLUS:
+    case OP_POSPLUS:
+    case OP_QUERY:
+    case OP_MINQUERY:
+    case OP_POSQUERY:
+    case OP_TYPESTAR:
+    case OP_TYPEMINSTAR:
+    case OP_TYPEPOSSTAR:
+    case OP_TYPEPLUS:
+    case OP_TYPEMINPLUS:
+    case OP_TYPEPOSPLUS:
+    case OP_TYPEQUERY:
+    case OP_TYPEMINQUERY:
+    case OP_TYPEPOSQUERY:
+    fprintf(f, "    ");
+    if (*code >= OP_TYPESTAR)
+      {
+      fprintf(f, "%s", OP_names[code[1]]);
+      if (code[1] == OP_PROP || code[1] == OP_NOTPROP)
+        {
+        fprintf(f, " %s ", get_ucpname(code[2], code[3]));
+        extra = 2;
+        }
+      }
+    else extra = print_char(f, code+1, utf8);
+    fprintf(f, "%s", OP_names[*code]);
+    break;
+
+    case OP_EXACT:
+    case OP_UPTO:
+    case OP_MINUPTO:
+    case OP_POSUPTO:
+    fprintf(f, "    ");
+    extra = print_char(f, code+3, utf8);
+    fprintf(f, "{");
+    if (*code != OP_EXACT) fprintf(f, "0,");
+    fprintf(f, "%d}", GET2(code,1));
+    if (*code == OP_MINUPTO) fprintf(f, "?");
+      else if (*code == OP_POSUPTO) fprintf(f, "+");
+    break;
+
+    case OP_TYPEEXACT:
+    case OP_TYPEUPTO:
+    case OP_TYPEMINUPTO:
+    case OP_TYPEPOSUPTO:
+    fprintf(f, "    %s", OP_names[code[3]]);
+    if (code[3] == OP_PROP || code[3] == OP_NOTPROP)
+      {
+      fprintf(f, " %s ", get_ucpname(code[4], code[5]));
+      extra = 2;
+      }
+    fprintf(f, "{");
+    if (*code != OP_TYPEEXACT) fprintf(f, "0,");
+    fprintf(f, "%d}", GET2(code,1));
+    if (*code == OP_TYPEMINUPTO) fprintf(f, "?");
+      else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");
+    break;
+
+    case OP_NOT:
+    c = code[1];
+    if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);
+      else fprintf(f, "    [^\\x%02x]", c);
+    break;
+
+    case OP_NOTSTAR:
+    case OP_NOTMINSTAR:
+    case OP_NOTPOSSTAR:
+    case OP_NOTPLUS:
+    case OP_NOTMINPLUS:
+    case OP_NOTPOSPLUS:
+    case OP_NOTQUERY:
+    case OP_NOTMINQUERY:
+    case OP_NOTPOSQUERY:
+    c = code[1];
+    if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);
+      else fprintf(f, "    [^\\x%02x]", c);
+    fprintf(f, "%s", OP_names[*code]);
+    break;
+
+    case OP_NOTEXACT:
+    case OP_NOTUPTO:
+    case OP_NOTMINUPTO:
+    case OP_NOTPOSUPTO:
+    c = code[3];
+    if (PRINTABLE(c)) fprintf(f, "    [^%c]{", c);
+      else fprintf(f, "    [^\\x%02x]{", c);
+    if (*code != OP_NOTEXACT) fprintf(f, "0,");
+    fprintf(f, "%d}", GET2(code,1));
+    if (*code == OP_NOTMINUPTO) fprintf(f, "?");
+      else if (*code == OP_NOTPOSUPTO) fprintf(f, "+");
+    break;
+
+    case OP_RECURSE:
+    if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
+      else fprintf(f, "    ");
+    fprintf(f, "%s", OP_names[*code]);
+    break;
+
+    case OP_REF:
+    fprintf(f, "    \\%d", GET2(code,1));
+    ccode = code + _pcre_OP_lengths[*code];
+    goto CLASS_REF_REPEAT;
+
+    case OP_CALLOUT:
+    fprintf(f, "    %s %d %d %d", OP_names[*code], code[1], GET(code,2),
+      GET(code, 2 + LINK_SIZE));
+    break;
+
+    case OP_PROP:
+    case OP_NOTPROP:
+    fprintf(f, "    %s %s", OP_names[*code], get_ucpname(code[1], code[2]));
+    break;
+
+    /* OP_XCLASS can only occur in UTF-8 mode. However, there's no harm in
+    having this code always here, and it makes it less messy without all those
+    #ifdefs. */
+
+    case OP_CLASS:
+    case OP_NCLASS:
+    case OP_XCLASS:
+      {
+      int i, min, max;
+      BOOL printmap;
+
+      fprintf(f, "    [");
+
+      if (*code == OP_XCLASS)
+        {
+        extra = GET(code, 1);
+        ccode = code + LINK_SIZE + 1;
+        printmap = (*ccode & XCL_MAP) != 0;
+        if ((*ccode++ & XCL_NOT) != 0) fprintf(f, "^");
+        }
+      else
+        {
+        printmap = TRUE;
+        ccode = code + 1;
+        }
+
+      /* Print a bit map */
+
+      if (printmap)
+        {
+        for (i = 0; i < 256; i++)
+          {
+          if ((ccode[i/8] & (1 << (i&7))) != 0)
+            {
+            int j;
+            for (j = i+1; j < 256; j++)
+              if ((ccode[j/8] & (1 << (j&7))) == 0) break;
+            if (i == '-' || i == ']') fprintf(f, "\\");
+            if (PRINTABLE(i)) fprintf(f, "%c", i);
+              else fprintf(f, "\\x%02x", i);
+            if (--j > i)
+              {
+              if (j != i + 1) fprintf(f, "-");
+              if (j == '-' || j == ']') fprintf(f, "\\");
+              if (PRINTABLE(j)) fprintf(f, "%c", j);
+                else fprintf(f, "\\x%02x", j);
+              }
+            i = j;
+            }
+          }
+        ccode += 32;
+        }
+
+      /* For an XCLASS there is always some additional data */
+
+      if (*code == OP_XCLASS)
+        {
+        int ch;
+        while ((ch = *ccode++) != XCL_END)
+          {
+          if (ch == XCL_PROP)
+            {
+            int ptype = *ccode++;
+            int pvalue = *ccode++;
+            fprintf(f, "\\p{%s}", get_ucpname(ptype, pvalue));
+            }
+          else if (ch == XCL_NOTPROP)
+            {
+            int ptype = *ccode++;
+            int pvalue = *ccode++;
+            fprintf(f, "\\P{%s}", get_ucpname(ptype, pvalue));
+            }
+          else
+            {
+            ccode += 1 + print_char(f, ccode, TRUE);
+            if (ch == XCL_RANGE)
+              {
+              fprintf(f, "-");
+              ccode += 1 + print_char(f, ccode, TRUE);
+              }
+            }
+          }
+        }
+
+      /* Indicate a non-UTF8 class which was created by negation */
+
+      fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");
+
+      /* Handle repeats after a class or a back reference */
+
+      CLASS_REF_REPEAT:
+      switch(*ccode)
+        {
+        case OP_CRSTAR:
+        case OP_CRMINSTAR:
+        case OP_CRPLUS:
+        case OP_CRMINPLUS:
+        case OP_CRQUERY:
+        case OP_CRMINQUERY:
+        fprintf(f, "%s", OP_names[*ccode]);
+        extra += _pcre_OP_lengths[*ccode];
+        break;
+
+        case OP_CRRANGE:
+        case OP_CRMINRANGE:
+        min = GET2(ccode,1);
+        max = GET2(ccode,3);
+        if (max == 0) fprintf(f, "{%d,}", min);
+        else fprintf(f, "{%d,%d}", min, max);
+        if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
+        extra += _pcre_OP_lengths[*ccode];
+        break;
+
+        /* Do nothing if it's not a repeat; this code stops picky compilers
+        warning about the lack of a default code path. */
+
+        default:
+        break;
+        }
+      }
+    break;
+
+    /* Anything else is just an item with no data*/
+
+    default:
+    fprintf(f, "    %s", OP_names[*code]);
+    break;
+    }
+
+  code += _pcre_OP_lengths[*code] + extra;
+  fprintf(f, "\n");
+  }
+}
+
+/* End of pcre_printint.src */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_refcount.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,82 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_refcount(), which is an
+auxiliary function that can be used to maintain a reference count in a compiled
+pattern data block. This might be helpful in applications where the block is
+shared by different users. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+*           Maintain reference count             *
+*************************************************/
+
+/* The reference count is a 16-bit field, initialized to zero. It is not
+possible to transfer a non-zero count from one host to a different host that
+has a different byte order - though I can't see why anyone in their right mind
+would ever want to do that!
+
+Arguments:
+  argument_re   points to compiled code
+  adjust        value to add to the count
+
+Returns:        the (possibly updated) count value (a non-negative number), or
+                a negative error number
+*/
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre_refcount(pcre *argument_re, int adjust)
+{
+real_pcre *re = (real_pcre *)argument_re;
+if (re == NULL) return PCRE_ERROR_NULL;
+re->ref_count = (-adjust > re->ref_count)? 0 :
+                (adjust + re->ref_count > 65535)? 65535 :
+                re->ref_count + adjust;
+return re->ref_count;
+}
+
+/* End of pcre_refcount.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_scanner.cc	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,199 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <vector>
+#include <assert.h>
+
+#include "pcrecpp_internal.h"
+#include "pcre_scanner.h"
+
+using std::vector;
+
+namespace pcrecpp {
+
+Scanner::Scanner()
+  : data_(),
+    input_(data_),
+    skip_(NULL),
+    should_skip_(false),
+    skip_repeat_(false),
+    save_comments_(false),
+    comments_(NULL),
+    comments_offset_(0) {
+}
+
+Scanner::Scanner(const string& in)
+  : data_(in),
+    input_(data_),
+    skip_(NULL),
+    should_skip_(false),
+    skip_repeat_(false),
+    save_comments_(false),
+    comments_(NULL),
+    comments_offset_(0) {
+}
+
+Scanner::~Scanner() {
+  delete skip_;
+  delete comments_;
+}
+
+void Scanner::SetSkipExpression(const char* re) {
+  delete skip_;
+  if (re != NULL) {
+    skip_ = new RE(re);
+    should_skip_ = true;
+    skip_repeat_ = true;
+    ConsumeSkip();
+  } else {
+    skip_ = NULL;
+    should_skip_ = false;
+    skip_repeat_ = false;
+  }
+}
+
+void Scanner::Skip(const char* re) {
+  delete skip_;
+  if (re != NULL) {
+    skip_ = new RE(re);
+    should_skip_ = true;
+    skip_repeat_ = false;
+    ConsumeSkip();
+  } else {
+    skip_ = NULL;
+    should_skip_ = false;
+    skip_repeat_ = false;
+  }
+}
+
+void Scanner::DisableSkip() {
+  assert(skip_ != NULL);
+  should_skip_ = false;
+}
+
+void Scanner::EnableSkip() {
+  assert(skip_ != NULL);
+  should_skip_ = true;
+  ConsumeSkip();
+}
+
+int Scanner::LineNumber() const {
+  // TODO: Make it more efficient by keeping track of the last point
+  // where we computed line numbers and counting newlines since then.
+  // We could use std:count, but not all systems have it. :-(
+  int count = 1;
+  for (const char* p = data_.data(); p < input_.data(); ++p)
+    if (*p == '\n')
+      ++count;
+  return count;
+}
+
+int Scanner::Offset() const {
+  return input_.data() - data_.c_str();
+}
+
+bool Scanner::LookingAt(const RE& re) const {
+  int consumed;
+  return re.DoMatch(input_, RE::ANCHOR_START, &consumed, 0, 0);
+}
+
+
+bool Scanner::Consume(const RE& re,
+                      const Arg& arg0,
+                      const Arg& arg1,
+                      const Arg& arg2) {
+  const bool result = re.Consume(&input_, arg0, arg1, arg2);
+  if (result && should_skip_) ConsumeSkip();
+  return result;
+}
+
+// helper function to consume *skip_ and honour save_comments_
+void Scanner::ConsumeSkip() {
+  const char* start_data = input_.data();
+  while (skip_->Consume(&input_)) {
+    if (!skip_repeat_) {
+      // Only one skip allowed.
+      break;
+    }
+  }
+  if (save_comments_) {
+    if (comments_ == NULL) {
+      comments_ = new vector<StringPiece>;
+    }
+    // already pointing one past end, so no need to +1
+    int length = input_.data() - start_data;
+    if (length > 0) {
+      comments_->push_back(StringPiece(start_data, length));
+    }
+  }
+}
+
+
+void Scanner::GetComments(int start, int end, vector<StringPiece> *ranges) {
+  // short circuit out if we've not yet initialized comments_
+  // (e.g., when save_comments is false)
+  if (!comments_) {
+    return;
+  }
+  // TODO: if we guarantee that comments_ will contain StringPieces
+  // that are ordered by their start, then we can do a binary search
+  // for the first StringPiece at or past start and then scan for the
+  // ones contained in the range, quit early (use equal_range or
+  // lower_bound)
+  for (vector<StringPiece>::const_iterator it = comments_->begin();
+       it != comments_->end(); ++it) {
+    if ((it->data() >= data_.c_str() + start &&
+         it->data() + it->size() <= data_.c_str() + end)) {
+      ranges->push_back(*it);
+    }
+  }
+}
+
+
+void Scanner::GetNextComments(vector<StringPiece> *ranges) {
+  // short circuit out if we've not yet initialized comments_
+  // (e.g., when save_comments is false)
+  if (!comments_) {
+    return;
+  }
+  for (vector<StringPiece>::const_iterator it =
+         comments_->begin() + comments_offset_;
+       it != comments_->end(); ++it) {
+    ranges->push_back(*it);
+    ++comments_offset_;
+  }
+}
+
+}   // namespace pcrecpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_scanner.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,172 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// Regular-expression based scanner for parsing an input stream.
+//
+// Example 1: parse a sequence of "var = number" entries from input:
+//
+//      Scanner scanner(input);
+//      string var;
+//      int number;
+//      scanner.SetSkipExpression("\\s+"); // Skip any white space we encounter
+//      while (scanner.Consume("(\\w+) = (\\d+)", &var, &number)) {
+//        ...;
+//      }
+
+#ifndef _PCRE_SCANNER_H
+#define _PCRE_SCANNER_H
+
+#include <assert.h>
+#include <string>
+#include <vector>
+
+#include <pcrecpp.h>
+#include <pcre_stringpiece.h>
+
+namespace pcrecpp {
+
+class PCRECPP_EXP_DEFN Scanner {
+ public:
+  Scanner();
+  explicit Scanner(const std::string& input);
+  ~Scanner();
+
+  // Return current line number.  The returned line-number is
+  // one-based.  I.e. it returns 1 + the number of consumed newlines.
+  //
+  // Note: this method may be slow.  It may take time proportional to
+  // the size of the input.
+  int LineNumber() const;
+
+  // Return the byte-offset that the scanner is looking in the
+  // input data;
+  int Offset() const;
+
+  // Return true iff the start of the remaining input matches "re"
+  bool LookingAt(const RE& re) const;
+
+  // Return true iff all of the following are true
+  //    a. the start of the remaining input matches "re",
+  //    b. if any arguments are supplied, matched sub-patterns can be
+  //       parsed and stored into the arguments.
+  // If it returns true, it skips over the matched input and any
+  // following input that matches the "skip" regular expression.
+  bool Consume(const RE& re,
+               const Arg& arg0 = RE::no_arg,
+               const Arg& arg1 = RE::no_arg,
+               const Arg& arg2 = RE::no_arg
+               // TODO: Allow more arguments?
+               );
+
+  // Set the "skip" regular expression.  If after consuming some data,
+  // a prefix of the input matches this RE, it is automatically
+  // skipped.  For example, a programming language scanner would use
+  // a skip RE that matches white space and comments.
+  //
+  //    scanner.SetSkipExpression("\\s+|//.*|/[*](.|\n)*?[*]/");
+  //
+  // Skipping repeats as long as it succeeds.  We used to let people do
+  // this by writing "(...)*" in the regular expression, but that added
+  // up to lots of recursive calls within the pcre library, so now we
+  // control repetition explicitly via the function call API.
+  //
+  // You can pass NULL for "re" if you do not want any data to be skipped.
+  void Skip(const char* re);   // DEPRECATED; does *not* repeat
+  void SetSkipExpression(const char* re);
+
+  // Temporarily pause "skip"ing. This
+  //   Skip("Foo"); code ; DisableSkip(); code; EnableSkip()
+  // is similar to
+  //   Skip("Foo"); code ; Skip(NULL); code ; Skip("Foo");
+  // but avoids creating/deleting new RE objects.
+  void DisableSkip();
+
+  // Reenable previously paused skipping.  Any prefix of the input
+  // that matches the skip pattern is immediately dropped.
+  void EnableSkip();
+
+  /***** Special wrappers around SetSkip() for some common idioms *****/
+
+  // Arranges to skip whitespace, C comments, C++ comments.
+  // The overall RE is a disjunction of the following REs:
+  //    \\s                     whitespace
+  //    //.*\n                  C++ comment
+  //    /[*](.|\n)*?[*]/        C comment (x*? means minimal repetitions of x)
+  // We get repetition via the semantics of SetSkipExpression, not by using *
+  void SkipCXXComments() {
+    SetSkipExpression("\\s|//.*\n|/[*](?:\n|.)*?[*]/");
+  }
+
+  void set_save_comments(bool comments) {
+    save_comments_ = comments;
+  }
+
+  bool save_comments() {
+    return save_comments_;
+  }
+
+  // Append to vector ranges the comments found in the
+  // byte range [start,end] (inclusive) of the input data.
+  // Only comments that were extracted entirely within that
+  // range are returned: no range splitting of atomically-extracted
+  // comments is performed.
+  void GetComments(int start, int end, std::vector<StringPiece> *ranges);
+
+  // Append to vector ranges the comments added
+  // since the last time this was called. This
+  // functionality is provided for efficiency when
+  // interleaving scanning with parsing.
+  void GetNextComments(std::vector<StringPiece> *ranges);
+
+ private:
+  std::string   data_;          // All the input data
+  StringPiece   input_;         // Unprocessed input
+  RE*           skip_;          // If non-NULL, RE for skipping input
+  bool          should_skip_;   // If true, use skip_
+  bool          skip_repeat_;   // If true, repeat skip_ as long as it works
+  bool          save_comments_; // If true, aggregate the skip expression
+
+  // the skipped comments
+  // TODO: later consider requiring that the StringPieces be added
+  // in order by their start position
+  std::vector<StringPiece> *comments_;
+
+  // the offset into comments_ that has been returned by GetNextComments
+  int           comments_offset_;
+
+  // helper function to consume *skip_ and honour
+  // save_comments_
+  void ConsumeSkip();
+};
+
+}   // namespace pcrecpp
+
+#endif /* _PCRE_SCANNER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_scanner_unittest.cc	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,158 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Greg J. Badros
+//
+// Unittest for scanner, especially GetNextComments and GetComments()
+// functionality.
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string>
+#include <vector>
+
+#include "pcrecpp.h"
+#include "pcre_stringpiece.h"
+#include "pcre_scanner.h"
+
+#define FLAGS_unittest_stack_size   49152
+
+// Dies with a fatal error if the two values are not equal.
+#define CHECK_EQ(a, b)  do {                                    \
+  if ( (a) != (b) ) {                                           \
+    fprintf(stderr, "%s:%d: Check failed because %s != %s\n",   \
+            __FILE__, __LINE__, #a, #b);                        \
+    exit(1);                                                    \
+  }                                                             \
+} while (0)
+
+using std::vector;
+using pcrecpp::StringPiece;
+using pcrecpp::Scanner;
+
+static void TestScanner() {
+  const char input[] = "\n"
+                       "alpha = 1; // this sets alpha\n"
+                       "bravo = 2; // bravo is set here\n"
+                       "gamma = 33; /* and here is gamma */\n";
+
+  const char *re = "(\\w+) = (\\d+);";
+
+  Scanner s(input);
+  string var;
+  int number;
+  s.SkipCXXComments();
+  s.set_save_comments(true);
+  vector<StringPiece> comments;
+
+  s.Consume(re, &var, &number);
+  CHECK_EQ(var, "alpha");
+  CHECK_EQ(number, 1);
+  CHECK_EQ(s.LineNumber(), 3);
+  s.GetNextComments(&comments);
+  CHECK_EQ(comments.size(), 1);
+  CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
+  comments.resize(0);
+
+  s.Consume(re, &var, &number);
+  CHECK_EQ(var, "bravo");
+  CHECK_EQ(number, 2);
+  s.GetNextComments(&comments);
+  CHECK_EQ(comments.size(), 1);
+  CHECK_EQ(comments[0].as_string(), " // bravo is set here\n");
+  comments.resize(0);
+
+  s.Consume(re, &var, &number);
+  CHECK_EQ(var, "gamma");
+  CHECK_EQ(number, 33);
+  s.GetNextComments(&comments);
+  CHECK_EQ(comments.size(), 1);
+  CHECK_EQ(comments[0].as_string(), " /* and here is gamma */\n");
+  comments.resize(0);
+
+  s.GetComments(0, sizeof(input), &comments);
+  CHECK_EQ(comments.size(), 3);
+  CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
+  CHECK_EQ(comments[1].as_string(), " // bravo is set here\n");
+  CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");
+  comments.resize(0);
+
+  s.GetComments(0, strchr(input, '/') - input, &comments);
+  CHECK_EQ(comments.size(), 0);
+  comments.resize(0);
+
+  s.GetComments(strchr(input, '/') - input - 1, sizeof(input),
+                &comments);
+  CHECK_EQ(comments.size(), 3);
+  CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
+  CHECK_EQ(comments[1].as_string(), " // bravo is set here\n");
+  CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");
+  comments.resize(0);
+
+  s.GetComments(strchr(input, '/') - input - 1,
+                strchr(input + 1, '\n') - input + 1, &comments);
+  CHECK_EQ(comments.size(), 1);
+  CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
+  comments.resize(0);
+}
+
+static void TestBigComment() {
+  string input;
+  for (int i = 0; i < 1024; ++i) {
+    char buf[1024];  // definitely big enough
+    sprintf(buf, "    # Comment %d\n", i);
+    input += buf;
+  }
+  input += "name = value;\n";
+
+  Scanner s(input.c_str());
+  s.SetSkipExpression("\\s+|#.*\n");
+
+  string name;
+  string value;
+  s.Consume("(\\w+) = (\\w+);", &name, &value);
+  CHECK_EQ(name, "name");
+  CHECK_EQ(value, "value");
+}
+
+// TODO: also test scanner and big-comment in a thread with a
+//       small stack size
+
+int main(int argc, char** argv) {
+  TestScanner();
+  TestBigComment();
+
+  // Done
+  printf("OK\n");
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_stringpiece.cc	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,43 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wilsonh@google.com (Wilson Hsieh)
+//
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <iostream>
+#include "pcrecpp_internal.h"
+#include "pcre_stringpiece.h"
+
+std::ostream& operator<<(std::ostream& o, const pcrecpp::StringPiece& piece) {
+  return (o << piece.as_string());
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_stringpiece.h.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,177 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// A string like object that points into another piece of memory.
+// Useful for providing an interface that allows clients to easily
+// pass in either a "const char*" or a "string".
+//
+// Arghh!  I wish C++ literals were automatically of type "string".
+
+#ifndef _PCRE_STRINGPIECE_H
+#define _PCRE_STRINGPIECE_H
+
+#include <string.h>
+#include <string>
+#include <iosfwd>    // for ostream forward-declaration
+
+#if @pcre_have_type_traits@
+#define HAVE_TYPE_TRAITS
+#include <type_traits.h>
+#elif @pcre_have_bits_type_traits@
+#define HAVE_TYPE_TRAITS
+#include <bits/type_traits.h>
+#endif
+
+#include <pcre.h>
+
+using std::string;
+
+namespace pcrecpp {
+
+class PCRECPP_EXP_DEFN StringPiece {
+ private:
+  const char*   ptr_;
+  int           length_;
+
+ public:
+  // We provide non-explicit singleton constructors so users can pass
+  // in a "const char*" or a "string" wherever a "StringPiece" is
+  // expected.
+  StringPiece()
+    : ptr_(NULL), length_(0) { }
+  StringPiece(const char* str)
+    : ptr_(str), length_(static_cast<int>(strlen(ptr_))) { }
+  StringPiece(const unsigned char* str)
+    : ptr_(reinterpret_cast<const char*>(str)),
+      length_(static_cast<int>(strlen(ptr_))) { }
+  StringPiece(const string& str)
+    : ptr_(str.data()), length_(static_cast<int>(str.size())) { }
+  StringPiece(const char* offset, int len)
+    : ptr_(offset), length_(len) { }
+
+  // data() may return a pointer to a buffer with embedded NULs, and the
+  // returned buffer may or may not be null terminated.  Therefore it is
+  // typically a mistake to pass data() to a routine that expects a NUL
+  // terminated string.  Use "as_string().c_str()" if you really need to do
+  // this.  Or better yet, change your routine so it does not rely on NUL
+  // termination.
+  const char* data() const { return ptr_; }
+  int size() const { return length_; }
+  bool empty() const { return length_ == 0; }
+
+  void clear() { ptr_ = NULL; length_ = 0; }
+  void set(const char* buffer, int len) { ptr_ = buffer; length_ = len; }
+  void set(const char* str) {
+    ptr_ = str;
+    length_ = static_cast<int>(strlen(str));
+  }
+  void set(const void* buffer, int len) {
+    ptr_ = reinterpret_cast<const char*>(buffer);
+    length_ = len;
+  }
+
+  char operator[](int i) const { return ptr_[i]; }
+
+  void remove_prefix(int n) {
+    ptr_ += n;
+    length_ -= n;
+  }
+
+  void remove_suffix(int n) {
+    length_ -= n;
+  }
+
+  bool operator==(const StringPiece& x) const {
+    return ((length_ == x.length_) &&
+            (memcmp(ptr_, x.ptr_, length_) == 0));
+  }
+  bool operator!=(const StringPiece& x) const {
+    return !(*this == x);
+  }
+
+#define STRINGPIECE_BINARY_PREDICATE(cmp,auxcmp)                             \
+  bool operator cmp (const StringPiece& x) const {                           \
+    int r = memcmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_); \
+    return ((r auxcmp 0) || ((r == 0) && (length_ cmp x.length_)));          \
+  }
+  STRINGPIECE_BINARY_PREDICATE(<,  <);
+  STRINGPIECE_BINARY_PREDICATE(<=, <);
+  STRINGPIECE_BINARY_PREDICATE(>=, >);
+  STRINGPIECE_BINARY_PREDICATE(>,  >);
+#undef STRINGPIECE_BINARY_PREDICATE
+
+  int compare(const StringPiece& x) const {
+    int r = memcmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_);
+    if (r == 0) {
+      if (length_ < x.length_) r = -1;
+      else if (length_ > x.length_) r = +1;
+    }
+    return r;
+  }
+
+  string as_string() const {
+    return string(data(), size());
+  }
+
+  void CopyToString(string* target) const {
+    target->assign(ptr_, length_);
+  }
+
+  // Does "this" start with "x"
+  bool starts_with(const StringPiece& x) const {
+    return ((length_ >= x.length_) && (memcmp(ptr_, x.ptr_, x.length_) == 0));
+  }
+};
+
+}   // namespace pcrecpp
+
+// ------------------------------------------------------------------
+// Functions used to create STL containers that use StringPiece
+//  Remember that a StringPiece's lifetime had better be less than
+//  that of the underlying string or char*.  If it is not, then you
+//  cannot safely store a StringPiece into an STL container
+// ------------------------------------------------------------------
+
+#ifdef HAVE_TYPE_TRAITS
+// This makes vector<StringPiece> really fast for some STL implementations
+template<> struct __type_traits<pcrecpp::StringPiece> {
+  typedef __true_type    has_trivial_default_constructor;
+  typedef __true_type    has_trivial_copy_constructor;
+  typedef __true_type    has_trivial_assignment_operator;
+  typedef __true_type    has_trivial_destructor;
+  typedef __true_type    is_POD_type;
+};
+#endif
+
+// allow StringPiece to be logged
+std::ostream& operator<<(std::ostream& o, const pcrecpp::StringPiece& piece);
+
+#endif /* _PCRE_STRINGPIECE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_stringpiece_unittest.cc	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,151 @@
+// Copyright 2003 and onwards Google Inc.
+// Author: Sanjay Ghemawat
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <map>
+#include <algorithm>    // for make_pair
+
+#include "pcrecpp.h"
+#include "pcre_stringpiece.h"
+
+// CHECK dies with a fatal error if condition is not true.  It is *not*
+// controlled by NDEBUG, so the check will be executed regardless of
+// compilation mode.  Therefore, it is safe to do things like:
+//    CHECK(fp->Write(x) == 4)
+#define CHECK(condition) do {                           \
+  if (!(condition)) {                                   \
+    fprintf(stderr, "%s:%d: Check failed: %s\n",        \
+            __FILE__, __LINE__, #condition);            \
+    exit(1);                                            \
+  }                                                     \
+} while (0)
+
+using std::map;
+using std::make_pair;
+using pcrecpp::StringPiece;
+
+static void CheckSTLComparator() {
+  string s1("foo");
+  string s2("bar");
+  string s3("baz");
+
+  StringPiece p1(s1);
+  StringPiece p2(s2);
+  StringPiece p3(s3);
+
+  typedef map<StringPiece, int> TestMap;
+  TestMap map;
+
+  map.insert(make_pair(p1, 0));
+  map.insert(make_pair(p2, 1));
+  map.insert(make_pair(p3, 2));
+  CHECK(map.size() == 3);
+
+  TestMap::const_iterator iter = map.begin();
+  CHECK(iter->second == 1);
+  ++iter;
+  CHECK(iter->second == 2);
+  ++iter;
+  CHECK(iter->second == 0);
+  ++iter;
+  CHECK(iter == map.end());
+
+  TestMap::iterator new_iter = map.find("zot");
+  CHECK(new_iter == map.end());
+
+  new_iter = map.find("bar");
+  CHECK(new_iter != map.end());
+
+  map.erase(new_iter);
+  CHECK(map.size() == 2);
+
+  iter = map.begin();
+  CHECK(iter->second == 2);
+  ++iter;
+  CHECK(iter->second == 0);
+  ++iter;
+  CHECK(iter == map.end());
+}
+
+static void CheckComparisonOperators() {
+#define CMP_Y(op, x, y)                                         \
+  CHECK( (StringPiece((x)) op StringPiece((y))));               \
+  CHECK( (StringPiece((x)).compare(StringPiece((y))) op 0))
+
+#define CMP_N(op, x, y)                                         \
+  CHECK(!(StringPiece((x)) op StringPiece((y))));               \
+  CHECK(!(StringPiece((x)).compare(StringPiece((y))) op 0))
+
+  CMP_Y(==, "",   "");
+  CMP_Y(==, "a",  "a");
+  CMP_Y(==, "aa", "aa");
+  CMP_N(==, "a",  "");
+  CMP_N(==, "",   "a");
+  CMP_N(==, "a",  "b");
+  CMP_N(==, "a",  "aa");
+  CMP_N(==, "aa", "a");
+
+  CMP_N(!=, "",   "");
+  CMP_N(!=, "a",  "a");
+  CMP_N(!=, "aa", "aa");
+  CMP_Y(!=, "a",  "");
+  CMP_Y(!=, "",   "a");
+  CMP_Y(!=, "a",  "b");
+  CMP_Y(!=, "a",  "aa");
+  CMP_Y(!=, "aa", "a");
+
+  CMP_Y(<, "a",  "b");
+  CMP_Y(<, "a",  "aa");
+  CMP_Y(<, "aa", "b");
+  CMP_Y(<, "aa", "bb");
+  CMP_N(<, "a",  "a");
+  CMP_N(<, "b",  "a");
+  CMP_N(<, "aa", "a");
+  CMP_N(<, "b",  "aa");
+  CMP_N(<, "bb", "aa");
+
+  CMP_Y(<=, "a",  "a");
+  CMP_Y(<=, "a",  "b");
+  CMP_Y(<=, "a",  "aa");
+  CMP_Y(<=, "aa", "b");
+  CMP_Y(<=, "aa", "bb");
+  CMP_N(<=, "b",  "a");
+  CMP_N(<=, "aa", "a");
+  CMP_N(<=, "b",  "aa");
+  CMP_N(<=, "bb", "aa");
+
+  CMP_N(>=, "a",  "b");
+  CMP_N(>=, "a",  "aa");
+  CMP_N(>=, "aa", "b");
+  CMP_N(>=, "aa", "bb");
+  CMP_Y(>=, "a",  "a");
+  CMP_Y(>=, "b",  "a");
+  CMP_Y(>=, "aa", "a");
+  CMP_Y(>=, "b",  "aa");
+  CMP_Y(>=, "bb", "aa");
+
+  CMP_N(>, "a",  "a");
+  CMP_N(>, "a",  "b");
+  CMP_N(>, "a",  "aa");
+  CMP_N(>, "aa", "b");
+  CMP_N(>, "aa", "bb");
+  CMP_Y(>, "b",  "a");
+  CMP_Y(>, "aa", "a");
+  CMP_Y(>, "b",  "aa");
+  CMP_Y(>, "bb", "aa");
+
+#undef CMP_Y
+#undef CMP_N
+}
+
+int main(int argc, char** argv) {
+  CheckComparisonOperators();
+  CheckSTLComparator();
+
+  printf("OK\n");
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_study.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,588 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_study(), along with local
+supporting functions. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/* Returns from set_start_bits() */
+
+enum { SSB_FAIL, SSB_DONE, SSB_CONTINUE };
+
+
+/*************************************************
+*      Set a bit and maybe its alternate case    *
+*************************************************/
+
+/* Given a character, set its bit in the table, and also the bit for the other
+version of a letter if we are caseless.
+
+Arguments:
+  start_bits    points to the bit map
+  c             is the character
+  caseless      the caseless flag
+  cd            the block with char table pointers
+
+Returns:        nothing
+*/
+
+static void
+set_bit(uschar *start_bits, unsigned int c, BOOL caseless, compile_data *cd)
+{
+start_bits[c/8] |= (1 << (c&7));
+if (caseless && (cd->ctypes[c] & ctype_letter) != 0)
+  start_bits[cd->fcc[c]/8] |= (1 << (cd->fcc[c]&7));
+}
+
+
+
+/*************************************************
+*          Create bitmap of starting bytes       *
+*************************************************/
+
+/* This function scans a compiled unanchored expression recursively and
+attempts to build a bitmap of the set of possible starting bytes. As time goes
+by, we may be able to get more clever at doing this. The SSB_CONTINUE return is
+useful for parenthesized groups in patterns such as (a*)b where the group
+provides some optional starting bytes but scanning must continue at the outer
+level to find at least one mandatory byte. At the outermost level, this
+function fails unless the result is SSB_DONE.
+
+Arguments:
+  code         points to an expression
+  start_bits   points to a 32-byte table, initialized to 0
+  caseless     the current state of the caseless flag
+  utf8         TRUE if in UTF-8 mode
+  cd           the block with char table pointers
+
+Returns:       SSB_FAIL     => Failed to find any starting bytes
+               SSB_DONE     => Found mandatory starting bytes
+               SSB_CONTINUE => Found optional starting bytes
+*/
+
+static int
+set_start_bits(const uschar *code, uschar *start_bits, BOOL caseless,
+  BOOL utf8, compile_data *cd)
+{
+register int c;
+int yield = SSB_DONE;
+
+#if 0
+/* ========================================================================= */
+/* The following comment and code was inserted in January 1999. In May 2006,
+when it was observed to cause compiler warnings about unused values, I took it
+out again. If anybody is still using OS/2, they will have to put it back
+manually. */
+
+/* This next statement and the later reference to dummy are here in order to
+trick the optimizer of the IBM C compiler for OS/2 into generating correct
+code. Apparently IBM isn't going to fix the problem, and we would rather not
+disable optimization (in this module it actually makes a big difference, and
+the pcre module can use all the optimization it can get). */
+
+volatile int dummy;
+/* ========================================================================= */
+#endif
+
+do
+  {
+  const uschar *tcode = code + (((int)*code == OP_CBRA)? 3:1) + LINK_SIZE;
+  BOOL try_next = TRUE;
+
+  while (try_next)    /* Loop for items in this branch */
+    {
+    int rc;
+    switch(*tcode)
+      {
+      /* Fail if we reach something we don't understand */
+
+      default:
+      return SSB_FAIL;
+
+      /* If we hit a bracket or a positive lookahead assertion, recurse to set
+      bits from within the subpattern. If it can't find anything, we have to
+      give up. If it finds some mandatory character(s), we are done for this
+      branch. Otherwise, carry on scanning after the subpattern. */
+
+      case OP_BRA:
+      case OP_SBRA:
+      case OP_CBRA:
+      case OP_SCBRA:
+      case OP_ONCE:
+      case OP_ASSERT:
+      rc = set_start_bits(tcode, start_bits, caseless, utf8, cd);
+      if (rc == SSB_FAIL) return SSB_FAIL;
+      if (rc == SSB_DONE) try_next = FALSE; else
+        {
+        do tcode += GET(tcode, 1); while (*tcode == OP_ALT);
+        tcode += 1 + LINK_SIZE;
+        }
+      break;
+
+      /* If we hit ALT or KET, it means we haven't found anything mandatory in
+      this branch, though we might have found something optional. For ALT, we
+      continue with the next alternative, but we have to arrange that the final
+      result from subpattern is SSB_CONTINUE rather than SSB_DONE. For KET,
+      return SSB_CONTINUE: if this is the top level, that indicates failure,
+      but after a nested subpattern, it causes scanning to continue. */
+
+      case OP_ALT:
+      yield = SSB_CONTINUE;
+      try_next = FALSE;
+      break;
+
+      case OP_KET:
+      case OP_KETRMAX:
+      case OP_KETRMIN:
+      return SSB_CONTINUE;
+
+      /* Skip over callout */
+
+      case OP_CALLOUT:
+      tcode += 2 + 2*LINK_SIZE;
+      break;
+
+      /* Skip over lookbehind and negative lookahead assertions */
+
+      case OP_ASSERT_NOT:
+      case OP_ASSERTBACK:
+      case OP_ASSERTBACK_NOT:
+      do tcode += GET(tcode, 1); while (*tcode == OP_ALT);
+      tcode += 1 + LINK_SIZE;
+      break;
+
+      /* Skip over an option setting, changing the caseless flag */
+
+      case OP_OPT:
+      caseless = (tcode[1] & PCRE_CASELESS) != 0;
+      tcode += 2;
+      break;
+
+      /* BRAZERO does the bracket, but carries on. */
+
+      case OP_BRAZERO:
+      case OP_BRAMINZERO:
+      if (set_start_bits(++tcode, start_bits, caseless, utf8, cd) == SSB_FAIL)
+        return SSB_FAIL;
+/* =========================================================================
+      See the comment at the head of this function concerning the next line,
+      which was an old fudge for the benefit of OS/2.
+      dummy = 1;
+  ========================================================================= */
+      do tcode += GET(tcode,1); while (*tcode == OP_ALT);
+      tcode += 1 + LINK_SIZE;
+      break;
+
+      /* SKIPZERO skips the bracket. */
+
+      case OP_SKIPZERO:
+      tcode++;
+      do tcode += GET(tcode,1); while (*tcode == OP_ALT);
+      tcode += 1 + LINK_SIZE;
+      break;
+
+      /* Single-char * or ? sets the bit and tries the next item */
+
+      case OP_STAR:
+      case OP_MINSTAR:
+      case OP_POSSTAR:
+      case OP_QUERY:
+      case OP_MINQUERY:
+      case OP_POSQUERY:
+      set_bit(start_bits, tcode[1], caseless, cd);
+      tcode += 2;
+#ifdef SUPPORT_UTF8
+      if (utf8 && tcode[-1] >= 0xc0)
+        tcode += _pcre_utf8_table4[tcode[-1] & 0x3f];
+#endif
+      break;
+
+      /* Single-char upto sets the bit and tries the next */
+
+      case OP_UPTO:
+      case OP_MINUPTO:
+      case OP_POSUPTO:
+      set_bit(start_bits, tcode[3], caseless, cd);
+      tcode += 4;
+#ifdef SUPPORT_UTF8
+      if (utf8 && tcode[-1] >= 0xc0)
+        tcode += _pcre_utf8_table4[tcode[-1] & 0x3f];
+#endif
+      break;
+
+      /* At least one single char sets the bit and stops */
+
+      case OP_EXACT:       /* Fall through */
+      tcode += 2;
+
+      case OP_CHAR:
+      case OP_CHARNC:
+      case OP_PLUS:
+      case OP_MINPLUS:
+      case OP_POSPLUS:
+      set_bit(start_bits, tcode[1], caseless, cd);
+      try_next = FALSE;
+      break;
+
+      /* Single character type sets the bits and stops */
+
+      case OP_NOT_DIGIT:
+      for (c = 0; c < 32; c++)
+        start_bits[c] |= ~cd->cbits[c+cbit_digit];
+      try_next = FALSE;
+      break;
+
+      case OP_DIGIT:
+      for (c = 0; c < 32; c++)
+        start_bits[c] |= cd->cbits[c+cbit_digit];
+      try_next = FALSE;
+      break;
+
+      /* The cbit_space table has vertical tab as whitespace; we have to
+      discard it. */
+
+      case OP_NOT_WHITESPACE:
+      for (c = 0; c < 32; c++)
+        {
+        int d = cd->cbits[c+cbit_space];
+        if (c == 1) d &= ~0x08;
+        start_bits[c] |= ~d;
+        }
+      try_next = FALSE;
+      break;
+
+      /* The cbit_space table has vertical tab as whitespace; we have to
+      discard it. */
+
+      case OP_WHITESPACE:
+      for (c = 0; c < 32; c++)
+        {
+        int d = cd->cbits[c+cbit_space];
+        if (c == 1) d &= ~0x08;
+        start_bits[c] |= d;
+        }
+      try_next = FALSE;
+      break;
+
+      case OP_NOT_WORDCHAR:
+      for (c = 0; c < 32; c++)
+        start_bits[c] |= ~cd->cbits[c+cbit_word];
+      try_next = FALSE;
+      break;
+
+      case OP_WORDCHAR:
+      for (c = 0; c < 32; c++)
+        start_bits[c] |= cd->cbits[c+cbit_word];
+      try_next = FALSE;
+      break;
+
+      /* One or more character type fudges the pointer and restarts, knowing
+      it will hit a single character type and stop there. */
+
+      case OP_TYPEPLUS:
+      case OP_TYPEMINPLUS:
+      tcode++;
+      break;
+
+      case OP_TYPEEXACT:
+      tcode += 3;
+      break;
+
+      /* Zero or more repeats of character types set the bits and then
+      try again. */
+
+      case OP_TYPEUPTO:
+      case OP_TYPEMINUPTO:
+      case OP_TYPEPOSUPTO:
+      tcode += 2;               /* Fall through */
+
+      case OP_TYPESTAR:
+      case OP_TYPEMINSTAR:
+      case OP_TYPEPOSSTAR:
+      case OP_TYPEQUERY:
+      case OP_TYPEMINQUERY:
+      case OP_TYPEPOSQUERY:
+      switch(tcode[1])
+        {
+        case OP_ANY:
+        case OP_ALLANY:
+        return SSB_FAIL;
+
+        case OP_NOT_DIGIT:
+        for (c = 0; c < 32; c++)
+          start_bits[c] |= ~cd->cbits[c+cbit_digit];
+        break;
+
+        case OP_DIGIT:
+        for (c = 0; c < 32; c++)
+          start_bits[c] |= cd->cbits[c+cbit_digit];
+        break;
+
+        /* The cbit_space table has vertical tab as whitespace; we have to
+        discard it. */
+
+        case OP_NOT_WHITESPACE:
+        for (c = 0; c < 32; c++)
+          {
+          int d = cd->cbits[c+cbit_space];
+          if (c == 1) d &= ~0x08;
+          start_bits[c] |= ~d;
+          }
+        break;
+
+        /* The cbit_space table has vertical tab as whitespace; we have to
+        discard it. */
+
+        case OP_WHITESPACE:
+        for (c = 0; c < 32; c++)
+          {
+          int d = cd->cbits[c+cbit_space];
+          if (c == 1) d &= ~0x08;
+          start_bits[c] |= d;
+          }
+        break;
+
+        case OP_NOT_WORDCHAR:
+        for (c = 0; c < 32; c++)
+          start_bits[c] |= ~cd->cbits[c+cbit_word];
+        break;
+
+        case OP_WORDCHAR:
+        for (c = 0; c < 32; c++)
+          start_bits[c] |= cd->cbits[c+cbit_word];
+        break;
+        }
+
+      tcode += 2;
+      break;
+
+      /* Character class where all the information is in a bit map: set the
+      bits and either carry on or not, according to the repeat count. If it was
+      a negative class, and we are operating with UTF-8 characters, any byte
+      with a value >= 0xc4 is a potentially valid starter because it starts a
+      character with a value > 255. */
+
+      case OP_NCLASS:
+#ifdef SUPPORT_UTF8
+      if (utf8)
+        {
+        start_bits[24] |= 0xf0;              /* Bits for 0xc4 - 0xc8 */
+        memset(start_bits+25, 0xff, 7);      /* Bits for 0xc9 - 0xff */
+        }
+#endif
+      /* Fall through */
+
+      case OP_CLASS:
+        {
+        tcode++;
+
+        /* In UTF-8 mode, the bits in a bit map correspond to character
+        values, not to byte values. However, the bit map we are constructing is
+        for byte values. So we have to do a conversion for characters whose
+        value is > 127. In fact, there are only two possible starting bytes for
+        characters in the range 128 - 255. */
+
+#ifdef SUPPORT_UTF8
+        if (utf8)
+          {
+          for (c = 0; c < 16; c++) start_bits[c] |= tcode[c];
+          for (c = 128; c < 256; c++)
+            {
+            if ((tcode[c/8] && (1 << (c&7))) != 0)
+              {
+              int d = (c >> 6) | 0xc0;            /* Set bit for this starter */
+              start_bits[d/8] |= (1 << (d&7));    /* and then skip on to the */
+              c = (c & 0xc0) + 0x40 - 1;          /* next relevant character. */
+              }
+            }
+          }
+
+        /* In non-UTF-8 mode, the two bit maps are completely compatible. */
+
+        else
+#endif
+          {
+          for (c = 0; c < 32; c++) start_bits[c] |= tcode[c];
+          }
+
+        /* Advance past the bit map, and act on what follows */
+
+        tcode += 32;
+        switch (*tcode)
+          {
+          case OP_CRSTAR:
+          case OP_CRMINSTAR:
+          case OP_CRQUERY:
+          case OP_CRMINQUERY:
+          tcode++;
+          break;
+
+          case OP_CRRANGE:
+          case OP_CRMINRANGE:
+          if (((tcode[1] << 8) + tcode[2]) == 0) tcode += 5;
+            else try_next = FALSE;
+          break;
+
+          default:
+          try_next = FALSE;
+          break;
+          }
+        }
+      break; /* End of bitmap class handling */
+
+      }      /* End of switch */
+    }        /* End of try_next loop */
+
+  code += GET(code, 1);   /* Advance to next branch */
+  }
+while (*code == OP_ALT);
+return yield;
+}
+
+
+
+/*************************************************
+*          Study a compiled expression           *
+*************************************************/
+
+/* This function is handed a compiled expression that it must study to produce
+information that will speed up the matching. It returns a pcre_extra block
+which then gets handed back to pcre_exec().
+
+Arguments:
+  re        points to the compiled expression
+  options   contains option bits
+  errorptr  points to where to place error messages;
+            set NULL unless error
+
+Returns:    pointer to a pcre_extra block, with study_data filled in and the
+              appropriate flag set;
+            NULL on error or if no optimization possible
+*/
+
+PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION
+pcre_study(const pcre *external_re, int options, const char **errorptr)
+{
+uschar start_bits[32];
+pcre_extra *extra;
+pcre_study_data *study;
+const uschar *tables;
+uschar *code;
+compile_data compile_block;
+const real_pcre *re = (const real_pcre *)external_re;
+
+*errorptr = NULL;
+
+if (re == NULL || re->magic_number != MAGIC_NUMBER)
+  {
+  *errorptr = "argument is not a compiled regular expression";
+  return NULL;
+  }
+
+if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)
+  {
+  *errorptr = "unknown or incorrect option bit(s) set";
+  return NULL;
+  }
+
+code = (uschar *)re + re->name_table_offset +
+  (re->name_count * re->name_entry_size);
+
+/* For an anchored pattern, or an unanchored pattern that has a first char, or
+a multiline pattern that matches only at "line starts", no further processing
+at present. */
+
+if ((re->options & PCRE_ANCHORED) != 0 ||
+    (re->flags & (PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)
+  return NULL;
+
+/* Set the character tables in the block that is passed around */
+
+tables = re->tables;
+if (tables == NULL)
+  (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
+  (void *)(&tables));
+
+compile_block.lcc = tables + lcc_offset;
+compile_block.fcc = tables + fcc_offset;
+compile_block.cbits = tables + cbits_offset;
+compile_block.ctypes = tables + ctypes_offset;
+
+/* See if we can find a fixed set of initial characters for the pattern. */
+
+memset(start_bits, 0, 32 * sizeof(uschar));
+if (set_start_bits(code, start_bits, (re->options & PCRE_CASELESS) != 0,
+  (re->options & PCRE_UTF8) != 0, &compile_block) != SSB_DONE) return NULL;
+
+/* Get a pcre_extra block and a pcre_study_data block. The study data is put in
+the latter, which is pointed to by the former, which may also get additional
+data set later by the calling program. At the moment, the size of
+pcre_study_data is fixed. We nevertheless save it in a field for returning via
+the pcre_fullinfo() function so that if it becomes variable in the future, we
+don't have to change that code. */
+
+extra = (pcre_extra *)(pcre_malloc)
+  (sizeof(pcre_extra) + sizeof(pcre_study_data));
+
+if (extra == NULL)
+  {
+  *errorptr = "failed to get memory";
+  return NULL;
+  }
+
+study = (pcre_study_data *)((char *)extra + sizeof(pcre_extra));
+extra->flags = PCRE_EXTRA_STUDY_DATA;
+extra->study_data = study;
+
+study->size = sizeof(pcre_study_data);
+study->options = PCRE_STUDY_MAPPED;
+memcpy(study->start_bits, start_bits, sizeof(start_bits));
+
+return extra;
+}
+
+/* End of pcre_study.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_tables.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,356 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains some fixed tables that are used by more than one of the
+PCRE code modules. The tables are also #included by the pcretest program, which
+uses macros to change their names from _pcre_xxx to xxxx, thereby avoiding name
+clashes with the library. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that
+the definition is next to the definition of the opcodes in pcre_internal.h. */
+
+const uschar _pcre_OP_lengths[] = { OP_LENGTHS };
+
+
+
+/*************************************************
+*           Tables for UTF-8 support             *
+*************************************************/
+
+/* These are the breakpoints for different numbers of bytes in a UTF-8
+character. */
+
+#ifdef SUPPORT_UTF8
+
+const int _pcre_utf8_table1[] =
+  { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
+
+const int _pcre_utf8_table1_size = sizeof(_pcre_utf8_table1)/sizeof(int);
+
+/* These are the indicator bits and the mask for the data bits to set in the
+first byte of a character, indexed by the number of additional bytes. */
+
+const int _pcre_utf8_table2[] = { 0,    0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
+const int _pcre_utf8_table3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
+
+/* Table of the number of extra bytes, indexed by the first byte masked with
+0x3f. The highest number for a valid UTF-8 first byte is in fact 0x3d. */
+
+const uschar _pcre_utf8_table4[] = {
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+  3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
+
+/* Table to translate from particular type value to the general value. */
+
+const int _pcre_ucp_gentype[] = {
+  ucp_C, ucp_C, ucp_C, ucp_C, ucp_C,  /* Cc, Cf, Cn, Co, Cs */
+  ucp_L, ucp_L, ucp_L, ucp_L, ucp_L,  /* Ll, Lu, Lm, Lo, Lt */
+  ucp_M, ucp_M, ucp_M,                /* Mc, Me, Mn */
+  ucp_N, ucp_N, ucp_N,                /* Nd, Nl, No */
+  ucp_P, ucp_P, ucp_P, ucp_P, ucp_P,  /* Pc, Pd, Pe, Pf, Pi */
+  ucp_P, ucp_P,                       /* Ps, Po */
+  ucp_S, ucp_S, ucp_S, ucp_S,         /* Sc, Sk, Sm, So */
+  ucp_Z, ucp_Z, ucp_Z                 /* Zl, Zp, Zs */
+};
+
+/* The pcre_utt[] table below translates Unicode property names into type and
+code values. It is searched by binary chop, so must be in collating sequence of
+name. Originally, the table contained pointers to the name strings in the first
+field of each entry. However, that leads to a large number of relocations when
+a shared library is dynamically loaded. A significant reduction is made by
+putting all the names into a single, large string and then using offsets in the
+table itself. Maintenance is more error-prone, but frequent changes to this
+data are unlikely.
+
+July 2008: There is now a script called maint/GenerateUtt.py which can be used
+to generate this data instead of maintaining it entirely by hand. */
+
+const char _pcre_utt_names[] =
+  "Any\0"
+  "Arabic\0"
+  "Armenian\0"
+  "Balinese\0"
+  "Bengali\0"
+  "Bopomofo\0"
+  "Braille\0"
+  "Buginese\0"
+  "Buhid\0"
+  "C\0"
+  "Canadian_Aboriginal\0"
+  "Carian\0"
+  "Cc\0"
+  "Cf\0"
+  "Cham\0"
+  "Cherokee\0"
+  "Cn\0"
+  "Co\0"
+  "Common\0"
+  "Coptic\0"
+  "Cs\0"
+  "Cuneiform\0"
+  "Cypriot\0"
+  "Cyrillic\0"
+  "Deseret\0"
+  "Devanagari\0"
+  "Ethiopic\0"
+  "Georgian\0"
+  "Glagolitic\0"
+  "Gothic\0"
+  "Greek\0"
+  "Gujarati\0"
+  "Gurmukhi\0"
+  "Han\0"
+  "Hangul\0"
+  "Hanunoo\0"
+  "Hebrew\0"
+  "Hiragana\0"
+  "Inherited\0"
+  "Kannada\0"
+  "Katakana\0"
+  "Kayah_Li\0"
+  "Kharoshthi\0"
+  "Khmer\0"
+  "L\0"
+  "L&\0"
+  "Lao\0"
+  "Latin\0"
+  "Lepcha\0"
+  "Limbu\0"
+  "Linear_B\0"
+  "Ll\0"
+  "Lm\0"
+  "Lo\0"
+  "Lt\0"
+  "Lu\0"
+  "Lycian\0"
+  "Lydian\0"
+  "M\0"
+  "Malayalam\0"
+  "Mc\0"
+  "Me\0"
+  "Mn\0"
+  "Mongolian\0"
+  "Myanmar\0"
+  "N\0"
+  "Nd\0"
+  "New_Tai_Lue\0"
+  "Nko\0"
+  "Nl\0"
+  "No\0"
+  "Ogham\0"
+  "Ol_Chiki\0"
+  "Old_Italic\0"
+  "Old_Persian\0"
+  "Oriya\0"
+  "Osmanya\0"
+  "P\0"
+  "Pc\0"
+  "Pd\0"
+  "Pe\0"
+  "Pf\0"
+  "Phags_Pa\0"
+  "Phoenician\0"
+  "Pi\0"
+  "Po\0"
+  "Ps\0"
+  "Rejang\0"
+  "Runic\0"
+  "S\0"
+  "Saurashtra\0"
+  "Sc\0"
+  "Shavian\0"
+  "Sinhala\0"
+  "Sk\0"
+  "Sm\0"
+  "So\0"
+  "Sundanese\0"
+  "Syloti_Nagri\0"
+  "Syriac\0"
+  "Tagalog\0"
+  "Tagbanwa\0"
+  "Tai_Le\0"
+  "Tamil\0"
+  "Telugu\0"
+  "Thaana\0"
+  "Thai\0"
+  "Tibetan\0"
+  "Tifinagh\0"
+  "Ugaritic\0"
+  "Vai\0"
+  "Yi\0"
+  "Z\0"
+  "Zl\0"
+  "Zp\0"
+  "Zs\0";
+
+const ucp_type_table _pcre_utt[] = {
+  {   0, PT_ANY, 0 },
+  {   4, PT_SC, ucp_Arabic },
+  {  11, PT_SC, ucp_Armenian },
+  {  20, PT_SC, ucp_Balinese },
+  {  29, PT_SC, ucp_Bengali },
+  {  37, PT_SC, ucp_Bopomofo },
+  {  46, PT_SC, ucp_Braille },
+  {  54, PT_SC, ucp_Buginese },
+  {  63, PT_SC, ucp_Buhid },
+  {  69, PT_GC, ucp_C },
+  {  71, PT_SC, ucp_Canadian_Aboriginal },
+  {  91, PT_SC, ucp_Carian },
+  {  98, PT_PC, ucp_Cc },
+  { 101, PT_PC, ucp_Cf },
+  { 104, PT_SC, ucp_Cham },
+  { 109, PT_SC, ucp_Cherokee },
+  { 118, PT_PC, ucp_Cn },
+  { 121, PT_PC, ucp_Co },
+  { 124, PT_SC, ucp_Common },
+  { 131, PT_SC, ucp_Coptic },
+  { 138, PT_PC, ucp_Cs },
+  { 141, PT_SC, ucp_Cuneiform },
+  { 151, PT_SC, ucp_Cypriot },
+  { 159, PT_SC, ucp_Cyrillic },
+  { 168, PT_SC, ucp_Deseret },
+  { 176, PT_SC, ucp_Devanagari },
+  { 187, PT_SC, ucp_Ethiopic },
+  { 196, PT_SC, ucp_Georgian },
+  { 205, PT_SC, ucp_Glagolitic },
+  { 216, PT_SC, ucp_Gothic },
+  { 223, PT_SC, ucp_Greek },
+  { 229, PT_SC, ucp_Gujarati },
+  { 238, PT_SC, ucp_Gurmukhi },
+  { 247, PT_SC, ucp_Han },
+  { 251, PT_SC, ucp_Hangul },
+  { 258, PT_SC, ucp_Hanunoo },
+  { 266, PT_SC, ucp_Hebrew },
+  { 273, PT_SC, ucp_Hiragana },
+  { 282, PT_SC, ucp_Inherited },
+  { 292, PT_SC, ucp_Kannada },
+  { 300, PT_SC, ucp_Katakana },
+  { 309, PT_SC, ucp_Kayah_Li },
+  { 318, PT_SC, ucp_Kharoshthi },
+  { 329, PT_SC, ucp_Khmer },
+  { 335, PT_GC, ucp_L },
+  { 337, PT_LAMP, 0 },
+  { 340, PT_SC, ucp_Lao },
+  { 344, PT_SC, ucp_Latin },
+  { 350, PT_SC, ucp_Lepcha },
+  { 357, PT_SC, ucp_Limbu },
+  { 363, PT_SC, ucp_Linear_B },
+  { 372, PT_PC, ucp_Ll },
+  { 375, PT_PC, ucp_Lm },
+  { 378, PT_PC, ucp_Lo },
+  { 381, PT_PC, ucp_Lt },
+  { 384, PT_PC, ucp_Lu },
+  { 387, PT_SC, ucp_Lycian },
+  { 394, PT_SC, ucp_Lydian },
+  { 401, PT_GC, ucp_M },
+  { 403, PT_SC, ucp_Malayalam },
+  { 413, PT_PC, ucp_Mc },
+  { 416, PT_PC, ucp_Me },
+  { 419, PT_PC, ucp_Mn },
+  { 422, PT_SC, ucp_Mongolian },
+  { 432, PT_SC, ucp_Myanmar },
+  { 440, PT_GC, ucp_N },
+  { 442, PT_PC, ucp_Nd },
+  { 445, PT_SC, ucp_New_Tai_Lue },
+  { 457, PT_SC, ucp_Nko },
+  { 461, PT_PC, ucp_Nl },
+  { 464, PT_PC, ucp_No },
+  { 467, PT_SC, ucp_Ogham },
+  { 473, PT_SC, ucp_Ol_Chiki },
+  { 482, PT_SC, ucp_Old_Italic },
+  { 493, PT_SC, ucp_Old_Persian },
+  { 505, PT_SC, ucp_Oriya },
+  { 511, PT_SC, ucp_Osmanya },
+  { 519, PT_GC, ucp_P },
+  { 521, PT_PC, ucp_Pc },
+  { 524, PT_PC, ucp_Pd },
+  { 527, PT_PC, ucp_Pe },
+  { 530, PT_PC, ucp_Pf },
+  { 533, PT_SC, ucp_Phags_Pa },
+  { 542, PT_SC, ucp_Phoenician },
+  { 553, PT_PC, ucp_Pi },
+  { 556, PT_PC, ucp_Po },
+  { 559, PT_PC, ucp_Ps },
+  { 562, PT_SC, ucp_Rejang },
+  { 569, PT_SC, ucp_Runic },
+  { 575, PT_GC, ucp_S },
+  { 577, PT_SC, ucp_Saurashtra },
+  { 588, PT_PC, ucp_Sc },
+  { 591, PT_SC, ucp_Shavian },
+  { 599, PT_SC, ucp_Sinhala },
+  { 607, PT_PC, ucp_Sk },
+  { 610, PT_PC, ucp_Sm },
+  { 613, PT_PC, ucp_So },
+  { 616, PT_SC, ucp_Sundanese },
+  { 626, PT_SC, ucp_Syloti_Nagri },
+  { 639, PT_SC, ucp_Syriac },
+  { 646, PT_SC, ucp_Tagalog },
+  { 654, PT_SC, ucp_Tagbanwa },
+  { 663, PT_SC, ucp_Tai_Le },
+  { 670, PT_SC, ucp_Tamil },
+  { 676, PT_SC, ucp_Telugu },
+  { 683, PT_SC, ucp_Thaana },
+  { 690, PT_SC, ucp_Thai },
+  { 695, PT_SC, ucp_Tibetan },
+  { 703, PT_SC, ucp_Tifinagh },
+  { 712, PT_SC, ucp_Ugaritic },
+  { 721, PT_SC, ucp_Vai },
+  { 725, PT_SC, ucp_Yi },
+  { 728, PT_GC, ucp_Z },
+  { 730, PT_PC, ucp_Zl },
+  { 733, PT_PC, ucp_Zp },
+  { 736, PT_PC, ucp_Zs }
+};
+
+const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);
+
+#endif  /* SUPPORT_UTF8 */
+
+/* End of pcre_tables.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_try_flipped.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,137 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains an internal function that tests a compiled pattern to
+see if it was compiled with the opposite endianness. If so, it uses an
+auxiliary local function to flip the appropriate bytes. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+*         Flip bytes in an integer               *
+*************************************************/
+
+/* This function is called when the magic number in a regex doesn't match, in
+order to flip its bytes to see if we are dealing with a pattern that was
+compiled on a host of different endianness. If so, this function is used to
+flip other byte values.
+
+Arguments:
+  value        the number to flip
+  n            the number of bytes to flip (assumed to be 2 or 4)
+
+Returns:       the flipped value
+*/
+
+static unsigned long int
+byteflip(unsigned long int value, int n)
+{
+if (n == 2) return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);
+return ((value & 0x000000ff) << 24) |
+       ((value & 0x0000ff00) <<  8) |
+       ((value & 0x00ff0000) >>  8) |
+       ((value & 0xff000000) >> 24);
+}
+
+
+
+/*************************************************
+*       Test for a byte-flipped compiled regex   *
+*************************************************/
+
+/* This function is called from pcre_exec(), pcre_dfa_exec(), and also from
+pcre_fullinfo(). Its job is to test whether the regex is byte-flipped - that
+is, it was compiled on a system of opposite endianness. The function is called
+only when the native MAGIC_NUMBER test fails. If the regex is indeed flipped,
+we flip all the relevant values into a different data block, and return it.
+
+Arguments:
+  re               points to the regex
+  study            points to study data, or NULL
+  internal_re      points to a new regex block
+  internal_study   points to a new study block
+
+Returns:           the new block if is is indeed a byte-flipped regex
+                   NULL if it is not
+*/
+
+real_pcre *
+_pcre_try_flipped(const real_pcre *re, real_pcre *internal_re,
+  const pcre_study_data *study, pcre_study_data *internal_study)
+{
+if (byteflip(re->magic_number, sizeof(re->magic_number)) != MAGIC_NUMBER)
+  return NULL;
+
+*internal_re = *re;           /* To copy other fields */
+internal_re->size = byteflip(re->size, sizeof(re->size));
+internal_re->options = byteflip(re->options, sizeof(re->options));
+internal_re->flags = (pcre_uint16)byteflip(re->flags, sizeof(re->flags));
+internal_re->top_bracket =
+  (pcre_uint16)byteflip(re->top_bracket, sizeof(re->top_bracket));
+internal_re->top_backref =
+  (pcre_uint16)byteflip(re->top_backref, sizeof(re->top_backref));
+internal_re->first_byte =
+  (pcre_uint16)byteflip(re->first_byte, sizeof(re->first_byte));
+internal_re->req_byte =
+  (pcre_uint16)byteflip(re->req_byte, sizeof(re->req_byte));
+internal_re->name_table_offset =
+  (pcre_uint16)byteflip(re->name_table_offset, sizeof(re->name_table_offset));
+internal_re->name_entry_size =
+  (pcre_uint16)byteflip(re->name_entry_size, sizeof(re->name_entry_size));
+internal_re->name_count =
+  (pcre_uint16)byteflip(re->name_count, sizeof(re->name_count));
+
+if (study != NULL)
+  {
+  *internal_study = *study;   /* To copy other fields */
+  internal_study->size = byteflip(study->size, sizeof(study->size));
+  internal_study->options = byteflip(study->options, sizeof(study->options));
+  }
+
+return internal_re;
+}
+
+/* End of pcre_tryflipped.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_ucd.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2610 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "pcre_internal.h"
+
+/* Unicode character database. */
+/* This file was autogenerated by the MultiStage2.py script. */
+/* Total size: 52808 bytes, block size: 128. */
+/* When recompiling tables with a new Unicode version,
+please check types in the structure definition from pcre_internal.h:
+typedef struct {
+uschar property_0;
+uschar property_1;
+pcre_int32 property_2;
+} ucd_record; */
+
+
+const ucd_record _pcre_ucd_records[] = { /* 3656 bytes, record size 8 */
+  {     9,      0,      0, }, /*   0 */
+  {     9,     29,      0, }, /*   1 */
+  {     9,     21,      0, }, /*   2 */
+  {     9,     23,      0, }, /*   3 */
+  {     9,     22,      0, }, /*   4 */
+  {     9,     18,      0, }, /*   5 */
+  {     9,     25,      0, }, /*   6 */
+  {     9,     17,      0, }, /*   7 */
+  {     9,     13,      0, }, /*   8 */
+  {    33,      9,     32, }, /*   9 */
+  {     9,     24,      0, }, /*  10 */
+  {     9,     16,      0, }, /*  11 */
+  {    33,      5,    -32, }, /*  12 */
+  {     9,     26,      0, }, /*  13 */
+  {    33,      5,      0, }, /*  14 */
+  {     9,     20,      0, }, /*  15 */
+  {     9,      1,      0, }, /*  16 */
+  {     9,     15,      0, }, /*  17 */
+  {     9,      5,    743, }, /*  18 */
+  {     9,     19,      0, }, /*  19 */
+  {    33,      5,    121, }, /*  20 */
+  {    33,      9,      1, }, /*  21 */
+  {    33,      5,     -1, }, /*  22 */
+  {    33,      9,   -199, }, /*  23 */
+  {    33,      5,   -232, }, /*  24 */
+  {    33,      9,   -121, }, /*  25 */
+  {    33,      5,   -300, }, /*  26 */
+  {    33,      5,    195, }, /*  27 */
+  {    33,      9,    210, }, /*  28 */
+  {    33,      9,    206, }, /*  29 */
+  {    33,      9,    205, }, /*  30 */
+  {    33,      9,     79, }, /*  31 */
+  {    33,      9,    202, }, /*  32 */
+  {    33,      9,    203, }, /*  33 */
+  {    33,      9,    207, }, /*  34 */
+  {    33,      5,     97, }, /*  35 */
+  {    33,      9,    211, }, /*  36 */
+  {    33,      9,    209, }, /*  37 */
+  {    33,      5,    163, }, /*  38 */
+  {    33,      9,    213, }, /*  39 */
+  {    33,      5,    130, }, /*  40 */
+  {    33,      9,    214, }, /*  41 */
+  {    33,      9,    218, }, /*  42 */
+  {    33,      9,    217, }, /*  43 */
+  {    33,      9,    219, }, /*  44 */
+  {    33,      7,      0, }, /*  45 */
+  {    33,      5,     56, }, /*  46 */
+  {    33,      9,      2, }, /*  47 */
+  {    33,      8,     -1, }, /*  48 */
+  {    33,      5,     -2, }, /*  49 */
+  {    33,      5,    -79, }, /*  50 */
+  {    33,      9,    -97, }, /*  51 */
+  {    33,      9,    -56, }, /*  52 */
+  {    33,      9,   -130, }, /*  53 */
+  {    33,      9,  10795, }, /*  54 */
+  {    33,      9,   -163, }, /*  55 */
+  {    33,      9,  10792, }, /*  56 */
+  {    33,      9,   -195, }, /*  57 */
+  {    33,      9,     69, }, /*  58 */
+  {    33,      9,     71, }, /*  59 */
+  {    33,      5,  10783, }, /*  60 */
+  {    33,      5,  10780, }, /*  61 */
+  {    33,      5,   -210, }, /*  62 */
+  {    33,      5,   -206, }, /*  63 */
+  {    33,      5,   -205, }, /*  64 */
+  {    33,      5,   -202, }, /*  65 */
+  {    33,      5,   -203, }, /*  66 */
+  {    33,      5,   -207, }, /*  67 */
+  {    33,      5,   -209, }, /*  68 */
+  {    33,      5,   -211, }, /*  69 */
+  {    33,      5,  10743, }, /*  70 */
+  {    33,      5,  10749, }, /*  71 */
+  {    33,      5,   -213, }, /*  72 */
+  {    33,      5,   -214, }, /*  73 */
+  {    33,      5,  10727, }, /*  74 */
+  {    33,      5,   -218, }, /*  75 */
+  {    33,      5,    -69, }, /*  76 */
+  {    33,      5,   -217, }, /*  77 */
+  {    33,      5,    -71, }, /*  78 */
+  {    33,      5,   -219, }, /*  79 */
+  {    33,      6,      0, }, /*  80 */
+  {     9,      6,      0, }, /*  81 */
+  {    27,     12,      0, }, /*  82 */
+  {    27,     12,     84, }, /*  83 */
+  {    19,      9,      1, }, /*  84 */
+  {    19,      5,     -1, }, /*  85 */
+  {    19,     24,      0, }, /*  86 */
+  {     9,      2,      0, }, /*  87 */
+  {    19,      6,      0, }, /*  88 */
+  {    19,      5,    130, }, /*  89 */
+  {    19,      9,     38, }, /*  90 */
+  {    19,      9,     37, }, /*  91 */
+  {    19,      9,     64, }, /*  92 */
+  {    19,      9,     63, }, /*  93 */
+  {    19,      5,      0, }, /*  94 */
+  {    19,      9,     32, }, /*  95 */
+  {    19,      5,    -38, }, /*  96 */
+  {    19,      5,    -37, }, /*  97 */
+  {    19,      5,    -32, }, /*  98 */
+  {    19,      5,    -31, }, /*  99 */
+  {    19,      5,    -64, }, /* 100 */
+  {    19,      5,    -63, }, /* 101 */
+  {    19,      9,      8, }, /* 102 */
+  {    19,      5,    -62, }, /* 103 */
+  {    19,      5,    -57, }, /* 104 */
+  {    19,      9,      0, }, /* 105 */
+  {    19,      5,    -47, }, /* 106 */
+  {    19,      5,    -54, }, /* 107 */
+  {    19,      5,     -8, }, /* 108 */
+  {    10,      9,      1, }, /* 109 */
+  {    10,      5,     -1, }, /* 110 */
+  {    19,      5,    -86, }, /* 111 */
+  {    19,      5,    -80, }, /* 112 */
+  {    19,      5,      7, }, /* 113 */
+  {    19,      9,    -60, }, /* 114 */
+  {    19,      5,    -96, }, /* 115 */
+  {    19,     25,      0, }, /* 116 */
+  {    19,      9,     -7, }, /* 117 */
+  {    19,      9,   -130, }, /* 118 */
+  {    12,      9,     80, }, /* 119 */
+  {    12,      9,     32, }, /* 120 */
+  {    12,      5,    -32, }, /* 121 */
+  {    12,      5,    -80, }, /* 122 */
+  {    12,      9,      1, }, /* 123 */
+  {    12,      5,     -1, }, /* 124 */
+  {    12,     26,      0, }, /* 125 */
+  {    12,     12,      0, }, /* 126 */
+  {    12,     11,      0, }, /* 127 */
+  {    12,      9,     15, }, /* 128 */
+  {    12,      5,    -15, }, /* 129 */
+  {     1,      9,     48, }, /* 130 */
+  {     1,      6,      0, }, /* 131 */
+  {     1,     21,      0, }, /* 132 */
+  {     1,      5,    -48, }, /* 133 */
+  {     1,      5,      0, }, /* 134 */
+  {     1,     17,      0, }, /* 135 */
+  {    25,     12,      0, }, /* 136 */
+  {    25,     17,      0, }, /* 137 */
+  {    25,     21,      0, }, /* 138 */
+  {    25,      7,      0, }, /* 139 */
+  {     0,     25,      0, }, /* 140 */
+  {     0,     21,      0, }, /* 141 */
+  {     0,     23,      0, }, /* 142 */
+  {     0,     26,      0, }, /* 143 */
+  {     0,     12,      0, }, /* 144 */
+  {     0,      7,      0, }, /* 145 */
+  {     0,     11,      0, }, /* 146 */
+  {     0,      6,      0, }, /* 147 */
+  {     0,     13,      0, }, /* 148 */
+  {    49,     21,      0, }, /* 149 */
+  {    49,      1,      0, }, /* 150 */
+  {    49,      7,      0, }, /* 151 */
+  {    49,     12,      0, }, /* 152 */
+  {    55,      7,      0, }, /* 153 */
+  {    55,     12,      0, }, /* 154 */
+  {    63,     13,      0, }, /* 155 */
+  {    63,      7,      0, }, /* 156 */
+  {    63,     12,      0, }, /* 157 */
+  {    63,      6,      0, }, /* 158 */
+  {    63,     26,      0, }, /* 159 */
+  {    63,     21,      0, }, /* 160 */
+  {    14,     12,      0, }, /* 161 */
+  {    14,     10,      0, }, /* 162 */
+  {    14,      7,      0, }, /* 163 */
+  {    14,     13,      0, }, /* 164 */
+  {    14,      6,      0, }, /* 165 */
+  {     2,     12,      0, }, /* 166 */
+  {     2,     10,      0, }, /* 167 */
+  {     2,      7,      0, }, /* 168 */
+  {     2,     13,      0, }, /* 169 */
+  {     2,     23,      0, }, /* 170 */
+  {     2,     15,      0, }, /* 171 */
+  {     2,     26,      0, }, /* 172 */
+  {    21,     12,      0, }, /* 173 */
+  {    21,     10,      0, }, /* 174 */
+  {    21,      7,      0, }, /* 175 */
+  {    21,     13,      0, }, /* 176 */
+  {    20,     12,      0, }, /* 177 */
+  {    20,     10,      0, }, /* 178 */
+  {    20,      7,      0, }, /* 179 */
+  {    20,     13,      0, }, /* 180 */
+  {    20,     23,      0, }, /* 181 */
+  {    43,     12,      0, }, /* 182 */
+  {    43,     10,      0, }, /* 183 */
+  {    43,      7,      0, }, /* 184 */
+  {    43,     13,      0, }, /* 185 */
+  {    43,     26,      0, }, /* 186 */
+  {    53,     12,      0, }, /* 187 */
+  {    53,      7,      0, }, /* 188 */
+  {    53,     10,      0, }, /* 189 */
+  {    53,     13,      0, }, /* 190 */
+  {    53,     15,      0, }, /* 191 */
+  {    53,     26,      0, }, /* 192 */
+  {    53,     23,      0, }, /* 193 */
+  {    54,     10,      0, }, /* 194 */
+  {    54,      7,      0, }, /* 195 */
+  {    54,     12,      0, }, /* 196 */
+  {    54,     13,      0, }, /* 197 */
+  {    54,     15,      0, }, /* 198 */
+  {    54,     26,      0, }, /* 199 */
+  {    28,     10,      0, }, /* 200 */
+  {    28,      7,      0, }, /* 201 */
+  {    28,     12,      0, }, /* 202 */
+  {    28,     13,      0, }, /* 203 */
+  {    36,     10,      0, }, /* 204 */
+  {    36,      7,      0, }, /* 205 */
+  {    36,     12,      0, }, /* 206 */
+  {    36,     13,      0, }, /* 207 */
+  {    36,     15,      0, }, /* 208 */
+  {    36,     26,      0, }, /* 209 */
+  {    47,     10,      0, }, /* 210 */
+  {    47,      7,      0, }, /* 211 */
+  {    47,     12,      0, }, /* 212 */
+  {    47,     21,      0, }, /* 213 */
+  {    56,      7,      0, }, /* 214 */
+  {    56,     12,      0, }, /* 215 */
+  {    56,      6,      0, }, /* 216 */
+  {    56,     21,      0, }, /* 217 */
+  {    56,     13,      0, }, /* 218 */
+  {    32,      7,      0, }, /* 219 */
+  {    32,     12,      0, }, /* 220 */
+  {    32,      6,      0, }, /* 221 */
+  {    32,     13,      0, }, /* 222 */
+  {    57,      7,      0, }, /* 223 */
+  {    57,     26,      0, }, /* 224 */
+  {    57,     21,      0, }, /* 225 */
+  {    57,     12,      0, }, /* 226 */
+  {    57,     13,      0, }, /* 227 */
+  {    57,     15,      0, }, /* 228 */
+  {    57,     22,      0, }, /* 229 */
+  {    57,     18,      0, }, /* 230 */
+  {    57,     10,      0, }, /* 231 */
+  {    38,      7,      0, }, /* 232 */
+  {    38,     10,      0, }, /* 233 */
+  {    38,     12,      0, }, /* 234 */
+  {    38,     13,      0, }, /* 235 */
+  {    38,     21,      0, }, /* 236 */
+  {    38,     26,      0, }, /* 237 */
+  {    16,      9,   7264, }, /* 238 */
+  {    16,      7,      0, }, /* 239 */
+  {    16,      6,      0, }, /* 240 */
+  {    23,      7,      0, }, /* 241 */
+  {    15,      7,      0, }, /* 242 */
+  {    15,     12,      0, }, /* 243 */
+  {    15,     26,      0, }, /* 244 */
+  {    15,     21,      0, }, /* 245 */
+  {    15,     15,      0, }, /* 246 */
+  {     8,      7,      0, }, /* 247 */
+  {     7,      7,      0, }, /* 248 */
+  {     7,     21,      0, }, /* 249 */
+  {    40,     29,      0, }, /* 250 */
+  {    40,      7,      0, }, /* 251 */
+  {    40,     22,      0, }, /* 252 */
+  {    40,     18,      0, }, /* 253 */
+  {    45,      7,      0, }, /* 254 */
+  {    45,     14,      0, }, /* 255 */
+  {    50,      7,      0, }, /* 256 */
+  {    50,     12,      0, }, /* 257 */
+  {    24,      7,      0, }, /* 258 */
+  {    24,     12,      0, }, /* 259 */
+  {     6,      7,      0, }, /* 260 */
+  {     6,     12,      0, }, /* 261 */
+  {    51,      7,      0, }, /* 262 */
+  {    51,     12,      0, }, /* 263 */
+  {    31,      7,      0, }, /* 264 */
+  {    31,      1,      0, }, /* 265 */
+  {    31,     10,      0, }, /* 266 */
+  {    31,     12,      0, }, /* 267 */
+  {    31,     21,      0, }, /* 268 */
+  {    31,      6,      0, }, /* 269 */
+  {    31,     23,      0, }, /* 270 */
+  {    31,     13,      0, }, /* 271 */
+  {    31,     15,      0, }, /* 272 */
+  {    37,     21,      0, }, /* 273 */
+  {    37,     17,      0, }, /* 274 */
+  {    37,     12,      0, }, /* 275 */
+  {    37,     29,      0, }, /* 276 */
+  {    37,     13,      0, }, /* 277 */
+  {    37,      7,      0, }, /* 278 */
+  {    37,      6,      0, }, /* 279 */
+  {    34,      7,      0, }, /* 280 */
+  {    34,     12,      0, }, /* 281 */
+  {    34,     10,      0, }, /* 282 */
+  {    34,     26,      0, }, /* 283 */
+  {    34,     21,      0, }, /* 284 */
+  {    34,     13,      0, }, /* 285 */
+  {    52,      7,      0, }, /* 286 */
+  {    39,      7,      0, }, /* 287 */
+  {    39,     10,      0, }, /* 288 */
+  {    39,     13,      0, }, /* 289 */
+  {    39,     21,      0, }, /* 290 */
+  {    31,     26,      0, }, /* 291 */
+  {     5,      7,      0, }, /* 292 */
+  {     5,     12,      0, }, /* 293 */
+  {     5,     10,      0, }, /* 294 */
+  {     5,     21,      0, }, /* 295 */
+  {    61,     12,      0, }, /* 296 */
+  {    61,     10,      0, }, /* 297 */
+  {    61,      7,      0, }, /* 298 */
+  {    61,     13,      0, }, /* 299 */
+  {    61,     21,      0, }, /* 300 */
+  {    61,     26,      0, }, /* 301 */
+  {    75,     12,      0, }, /* 302 */
+  {    75,     10,      0, }, /* 303 */
+  {    75,      7,      0, }, /* 304 */
+  {    75,     13,      0, }, /* 305 */
+  {    69,      7,      0, }, /* 306 */
+  {    69,     10,      0, }, /* 307 */
+  {    69,     12,      0, }, /* 308 */
+  {    69,     21,      0, }, /* 309 */
+  {    69,     13,      0, }, /* 310 */
+  {    72,     13,      0, }, /* 311 */
+  {    72,      7,      0, }, /* 312 */
+  {    72,      6,      0, }, /* 313 */
+  {    72,     21,      0, }, /* 314 */
+  {    12,      5,      0, }, /* 315 */
+  {    12,      6,      0, }, /* 316 */
+  {    33,      5,  35332, }, /* 317 */
+  {    33,      5,   3814, }, /* 318 */
+  {    33,      5,    -59, }, /* 319 */
+  {    33,      9,  -7615, }, /* 320 */
+  {    19,      5,      8, }, /* 321 */
+  {    19,      9,     -8, }, /* 322 */
+  {    19,      5,     74, }, /* 323 */
+  {    19,      5,     86, }, /* 324 */
+  {    19,      5,    100, }, /* 325 */
+  {    19,      5,    128, }, /* 326 */
+  {    19,      5,    112, }, /* 327 */
+  {    19,      5,    126, }, /* 328 */
+  {    19,      8,     -8, }, /* 329 */
+  {    19,      5,      9, }, /* 330 */
+  {    19,      9,    -74, }, /* 331 */
+  {    19,      8,     -9, }, /* 332 */
+  {    19,      5,  -7205, }, /* 333 */
+  {    19,      9,    -86, }, /* 334 */
+  {    19,      9,   -100, }, /* 335 */
+  {    19,      9,   -112, }, /* 336 */
+  {    19,      9,   -128, }, /* 337 */
+  {    19,      9,   -126, }, /* 338 */
+  {    27,      1,      0, }, /* 339 */
+  {     9,     27,      0, }, /* 340 */
+  {     9,     28,      0, }, /* 341 */
+  {    27,     11,      0, }, /* 342 */
+  {     9,      9,      0, }, /* 343 */
+  {     9,      5,      0, }, /* 344 */
+  {    19,      9,  -7517, }, /* 345 */
+  {    33,      9,  -8383, }, /* 346 */
+  {    33,      9,  -8262, }, /* 347 */
+  {    33,      9,     28, }, /* 348 */
+  {     9,      7,      0, }, /* 349 */
+  {    33,      5,    -28, }, /* 350 */
+  {    33,     14,     16, }, /* 351 */
+  {    33,     14,    -16, }, /* 352 */
+  {    33,     14,      0, }, /* 353 */
+  {     9,     26,     26, }, /* 354 */
+  {     9,     26,    -26, }, /* 355 */
+  {     4,     26,      0, }, /* 356 */
+  {    17,      9,     48, }, /* 357 */
+  {    17,      5,    -48, }, /* 358 */
+  {    33,      9, -10743, }, /* 359 */
+  {    33,      9,  -3814, }, /* 360 */
+  {    33,      9, -10727, }, /* 361 */
+  {    33,      5, -10795, }, /* 362 */
+  {    33,      5, -10792, }, /* 363 */
+  {    33,      9, -10780, }, /* 364 */
+  {    33,      9, -10749, }, /* 365 */
+  {    33,      9, -10783, }, /* 366 */
+  {    10,      5,      0, }, /* 367 */
+  {    10,     26,      0, }, /* 368 */
+  {    10,     21,      0, }, /* 369 */
+  {    10,     15,      0, }, /* 370 */
+  {    16,      5,  -7264, }, /* 371 */
+  {    58,      7,      0, }, /* 372 */
+  {    58,      6,      0, }, /* 373 */
+  {    22,     26,      0, }, /* 374 */
+  {    22,      6,      0, }, /* 375 */
+  {    22,     14,      0, }, /* 376 */
+  {    26,      7,      0, }, /* 377 */
+  {    26,      6,      0, }, /* 378 */
+  {    29,      7,      0, }, /* 379 */
+  {    29,      6,      0, }, /* 380 */
+  {     3,      7,      0, }, /* 381 */
+  {    23,     26,      0, }, /* 382 */
+  {    29,     26,      0, }, /* 383 */
+  {    22,      7,      0, }, /* 384 */
+  {    60,      7,      0, }, /* 385 */
+  {    60,      6,      0, }, /* 386 */
+  {    60,     26,      0, }, /* 387 */
+  {    76,      7,      0, }, /* 388 */
+  {    76,      6,      0, }, /* 389 */
+  {    76,     21,      0, }, /* 390 */
+  {    76,     13,      0, }, /* 391 */
+  {    12,      7,      0, }, /* 392 */
+  {    12,     21,      0, }, /* 393 */
+  {    33,      9, -35332, }, /* 394 */
+  {    48,      7,      0, }, /* 395 */
+  {    48,     12,      0, }, /* 396 */
+  {    48,     10,      0, }, /* 397 */
+  {    48,     26,      0, }, /* 398 */
+  {    64,      7,      0, }, /* 399 */
+  {    64,     21,      0, }, /* 400 */
+  {    74,     10,      0, }, /* 401 */
+  {    74,      7,      0, }, /* 402 */
+  {    74,     12,      0, }, /* 403 */
+  {    74,     21,      0, }, /* 404 */
+  {    74,     13,      0, }, /* 405 */
+  {    68,     13,      0, }, /* 406 */
+  {    68,      7,      0, }, /* 407 */
+  {    68,     12,      0, }, /* 408 */
+  {    68,     21,      0, }, /* 409 */
+  {    73,      7,      0, }, /* 410 */
+  {    73,     12,      0, }, /* 411 */
+  {    73,     10,      0, }, /* 412 */
+  {    73,     21,      0, }, /* 413 */
+  {    67,      7,      0, }, /* 414 */
+  {    67,     12,      0, }, /* 415 */
+  {    67,     10,      0, }, /* 416 */
+  {    67,     13,      0, }, /* 417 */
+  {    67,     21,      0, }, /* 418 */
+  {     9,      4,      0, }, /* 419 */
+  {     9,      3,      0, }, /* 420 */
+  {    25,     25,      0, }, /* 421 */
+  {    35,      7,      0, }, /* 422 */
+  {    19,     14,      0, }, /* 423 */
+  {    19,     15,      0, }, /* 424 */
+  {    19,     26,      0, }, /* 425 */
+  {    70,      7,      0, }, /* 426 */
+  {    66,      7,      0, }, /* 427 */
+  {    41,      7,      0, }, /* 428 */
+  {    41,     15,      0, }, /* 429 */
+  {    18,      7,      0, }, /* 430 */
+  {    18,     14,      0, }, /* 431 */
+  {    59,      7,      0, }, /* 432 */
+  {    59,     21,      0, }, /* 433 */
+  {    42,      7,      0, }, /* 434 */
+  {    42,     21,      0, }, /* 435 */
+  {    42,     14,      0, }, /* 436 */
+  {    13,      9,     40, }, /* 437 */
+  {    13,      5,    -40, }, /* 438 */
+  {    46,      7,      0, }, /* 439 */
+  {    44,      7,      0, }, /* 440 */
+  {    44,     13,      0, }, /* 441 */
+  {    11,      7,      0, }, /* 442 */
+  {    65,      7,      0, }, /* 443 */
+  {    65,     15,      0, }, /* 444 */
+  {    65,     21,      0, }, /* 445 */
+  {    71,      7,      0, }, /* 446 */
+  {    71,     21,      0, }, /* 447 */
+  {    30,      7,      0, }, /* 448 */
+  {    30,     12,      0, }, /* 449 */
+  {    30,     15,      0, }, /* 450 */
+  {    30,     21,      0, }, /* 451 */
+  {    62,      7,      0, }, /* 452 */
+  {    62,     14,      0, }, /* 453 */
+  {    62,     21,      0, }, /* 454 */
+  {     9,     10,      0, }, /* 455 */
+  {    19,     12,      0, }, /* 456 */
+};
+
+const uschar _pcre_ucd_stage1[] = { /* 8704 bytes */
+  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, /* U+0000 */
+ 16, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, /* U+0800 */
+ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 40, 40, 41, 42, 43, 44, /* U+1000 */
+ 45, 46, 47, 48, 49, 16, 50, 51, 52, 16, 53, 54, 55, 56, 57, 58, /* U+1800 */
+ 59, 60, 61, 62, 63, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, /* U+2000 */
+ 74, 74, 63, 75, 63, 63, 76, 16, 77, 78, 79, 80, 81, 82, 83, 84, /* U+2800 */
+ 85, 86, 87, 88, 89, 90, 91, 68, 92, 92, 92, 92, 92, 92, 92, 92, /* U+3000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+3800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+4000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 93, 92, 92, 92, 92, /* U+4800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+5000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+5800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+6000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+6800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+7000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+7800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+8000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+8800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+9000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 94, /* U+9800 */
+ 95, 96, 96, 96, 96, 96, 96, 96, 96, 97, 98, 98, 99,100,101,102, /* U+A000 */
+103,104,105, 16,106, 16, 16, 16,107,107,107,107,107,107,107,107, /* U+A800 */
+107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, /* U+B000 */
+107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, /* U+B800 */
+107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, /* U+C000 */
+107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107, /* U+C800 */
+107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,108, /* U+D000 */
+109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109, /* U+D800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+E000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+E800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F000 */
+110,110, 92, 92,111,112,113,114,115,115,116,117,118,119,120,121, /* U+F800 */
+122,123,124,125, 16,126,127,128,129,130, 16, 16, 16, 16, 16, 16, /* U+10000 */
+131, 16,132, 16,133, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+10800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+11000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+11800 */
+134,134,134,134,134,134,135, 16,136, 16, 16, 16, 16, 16, 16, 16, /* U+12000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+12800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+13000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+13800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+14000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+14800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+15000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+15800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+16000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+16800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+17000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+17800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+18000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+18800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+19000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+19800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1C800 */
+ 68,137,138,139,140, 16,141, 16,142,143,144,145,146,147,148,149, /* U+1D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1E800 */
+150,151, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1F000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+1F800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+20000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+20800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+21000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+21800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+22000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+22800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+23000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+23800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+24000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+24800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+25000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+25800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+26000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+26800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+27000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+27800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+28000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+28800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+29000 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, /* U+29800 */
+ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,152, 16, 16, /* U+2A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2C800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2E800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2F000 */
+ 92, 92, 92, 92,153, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+2F800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+30000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+30800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+31000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+31800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+32000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+32800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+33000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+33800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+34000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+34800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+35000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+35800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+36000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+36800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+37000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+37800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+38000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+38800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+39000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+39800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3C800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3E800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3F000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+3F800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+40000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+40800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+41000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+41800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+42000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+42800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+43000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+43800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+44000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+44800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+45000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+45800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+46000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+46800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+47000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+47800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+48000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+48800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+49000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+49800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4C800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4E800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4F000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+4F800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+50000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+50800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+51000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+51800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+52000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+52800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+53000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+53800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+54000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+54800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+55000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+55800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+56000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+56800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+57000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+57800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+58000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+58800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+59000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+59800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5C800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5E800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5F000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+5F800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+60000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+60800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+61000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+61800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+62000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+62800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+63000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+63800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+64000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+64800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+65000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+65800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+66000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+66800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+67000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+67800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+68000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+68800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+69000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+69800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6C800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6E800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6F000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+6F800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+70000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+70800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+71000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+71800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+72000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+72800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+73000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+73800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+74000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+74800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+75000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+75800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+76000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+76800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+77000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+77800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+78000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+78800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+79000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+79800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7C800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7E800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7F000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+7F800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+80000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+80800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+81000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+81800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+82000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+82800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+83000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+83800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+84000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+84800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+85000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+85800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+86000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+86800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+87000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+87800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+88000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+88800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+89000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+89800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8C800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8E800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8F000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+8F800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+90000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+90800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+91000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+91800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+92000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+92800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+93000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+93800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+94000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+94800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+95000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+95800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+96000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+96800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+97000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+97800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+98000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+98800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+99000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+99800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9A000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9A800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9B000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9B800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9C000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9C800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9D000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9D800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9E000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9E800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9F000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+9F800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A0000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A0800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A1000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A1800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A2000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A2800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A3000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A3800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A4000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A4800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A5000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A5800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A6000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A6800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A7000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A7800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A8000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A8800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A9000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+A9800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AA000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AA800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AB000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AB800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AC000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AC800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AD000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AD800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AE000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AE800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AF000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+AF800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B0000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B0800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B1000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B1800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B2000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B2800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B3000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B3800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B4000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B4800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B5000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B5800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B6000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B6800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B7000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B7800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B8000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B8800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B9000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+B9800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BA000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BA800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BB000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BB800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BC000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BC800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BD000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BD800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BE000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BE800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BF000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+BF800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C0000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C0800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C1000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C1800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C2000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C2800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C3000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C3800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C4000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C4800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C5000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C5800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C6000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C6800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C7000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C7800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C8000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C8800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C9000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+C9800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CA000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CA800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CB000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CB800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CC000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CC800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CD000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CD800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CE000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CE800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CF000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+CF800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D0000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D0800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D1000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D1800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D2000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D2800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D3000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D3800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D4000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D4800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D5000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D5800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D6000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D6800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D7000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D7800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D8000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D8800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D9000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+D9800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DA000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DA800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DB000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DB800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DC000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DC800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DD000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DD800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DE000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DE800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DF000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+DF800 */
+154, 16,155,156, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E0000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E0800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E1000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E1800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E2000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E2800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E3000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E3800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E4000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E4800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E5000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E5800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E6000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E6800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E7000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E7800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E8000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E8800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E9000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+E9800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EA000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EA800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EB000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EB800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EC000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EC800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+ED000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+ED800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EE000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EE800 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EF000 */
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* U+EF800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F0000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F0800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F1000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F1800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F2000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F2800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F3000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F3800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F4000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F4800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F5000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F5800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F6000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F6800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F7000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F7800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F8000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F8800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F9000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+F9800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FA000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FA800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FB000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FB800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FC000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FC800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FD000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FD800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FE000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FE800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+FF000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,157, /* U+FF800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+100000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+100800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+101000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+101800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+102000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+102800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+103000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+103800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+104000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+104800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+105000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+105800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+106000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+106800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+107000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+107800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+108000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+108800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+109000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+109800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10A000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10A800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10B000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10B800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10C000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10C800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10D000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10D800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10E000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10E800 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, /* U+10F000 */
+110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,157, /* U+10F800 */
+};
+
+const pcre_uint16 _pcre_ucd_stage2[] = { /* 40448 bytes, block = 128 */
+/* block 0 */
+  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+  1,  2,  2,  2,  3,  2,  2,  2,  4,  5,  2,  6,  2,  7,  2,  2,
+  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  2,  2,  6,  6,  6,  2,
+  2,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
+  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  4,  2,  5, 10, 11,
+ 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  4,  6,  5,  6,  0,
+
+/* block 1 */
+  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+  1,  2,  3,  3,  3,  3, 13, 13, 10, 13, 14, 15,  6, 16, 13, 10,
+ 13,  6, 17, 17, 10, 18, 13,  2, 10, 17, 14, 19, 17, 17, 17,  2,
+  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
+  9,  9,  9,  9,  9,  9,  9,  6,  9,  9,  9,  9,  9,  9,  9, 14,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12,  6, 12, 12, 12, 12, 12, 12, 12, 20,
+
+/* block 2 */
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 23, 24, 21, 22, 21, 22, 21, 22, 14, 21, 22, 21, 22, 21, 22, 21,
+ 22, 21, 22, 21, 22, 21, 22, 21, 22, 14, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 25, 21, 22, 21, 22, 21, 22, 26,
+
+/* block 3 */
+ 27, 28, 21, 22, 21, 22, 29, 21, 22, 30, 30, 21, 22, 14, 31, 32,
+ 33, 21, 22, 30, 34, 35, 36, 37, 21, 22, 38, 14, 36, 39, 40, 41,
+ 21, 22, 21, 22, 21, 22, 42, 21, 22, 42, 14, 14, 21, 22, 42, 21,
+ 22, 43, 43, 21, 22, 21, 22, 44, 21, 22, 14, 45, 21, 22, 14, 46,
+ 45, 45, 45, 45, 47, 48, 49, 47, 48, 49, 47, 48, 49, 21, 22, 21,
+ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 50, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 14, 47, 48, 49, 21, 22, 51, 52, 21, 22, 21, 22, 21, 22, 21, 22,
+
+/* block 4 */
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 53, 14, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 14, 14, 14, 14, 14, 14, 54, 21, 22, 55, 56, 14,
+ 14, 21, 22, 57, 58, 59, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 60, 61, 14, 62, 63, 14, 64, 64, 14, 65, 14, 66, 14, 14, 14, 14,
+ 64, 14, 14, 67, 14, 14, 14, 14, 68, 69, 14, 70, 14, 14, 14, 69,
+ 14, 71, 72, 14, 14, 73, 14, 14, 14, 14, 14, 14, 14, 74, 14, 14,
+
+/* block 5 */
+ 75, 14, 14, 75, 14, 14, 14, 14, 75, 76, 77, 77, 78, 14, 14, 14,
+ 14, 14, 79, 14, 45, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 81, 81, 81, 81, 81,
+ 81, 81, 10, 10, 10, 10, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
+ 81, 81, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 80, 80, 80, 80, 80, 10, 10, 10, 10, 10, 10, 10, 81, 10, 81, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+
+/* block 6 */
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 83, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 84, 85, 84, 85, 81, 86, 84, 85, 87, 87, 88, 89, 89, 89,  2, 87,
+
+/* block 7 */
+ 87, 87, 87, 87, 86, 10, 90,  2, 91, 91, 91, 87, 92, 87, 93, 93,
+ 94, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+ 95, 95, 87, 95, 95, 95, 95, 95, 95, 95, 95, 95, 96, 97, 97, 97,
+ 94, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
+ 98, 98, 99, 98, 98, 98, 98, 98, 98, 98, 98, 98,100,101,101,102,
+103,104,105,105,105,106,107,108, 84, 85, 84, 85, 84, 85, 84, 85,
+ 84, 85,109,110,109,110,109,110,109,110,109,110,109,110,109,110,
+111,112,113, 94,114,115,116, 84, 85,117, 84, 85, 94,118,118,118,
+
+/* block 8 */
+119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,
+120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
+120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
+121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
+121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,121,
+122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,122,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+
+/* block 9 */
+123,124,125,126,126,126,126,126,127,127,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+128,123,124,123,124,123,124,123,124,123,124,123,124,123,124,129,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+
+/* block 10 */
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,
+130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,
+130,130,130,130,130,130,130, 87, 87,131,132,132,132,132,132,132,
+ 87,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
+133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
+
+/* block 11 */
+133,133,133,133,133,133,133,134, 87,  2,135, 87, 87, 87, 87, 87,
+ 87,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
+136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,
+136,136,136,136,136,136,136,136,136,136,136,136,136,136,137,136,
+138,136,136,138,136,136,138,136, 87, 87, 87, 87, 87, 87, 87, 87,
+139,139,139,139,139,139,139,139,139,139,139,139,139,139,139,139,
+139,139,139,139,139,139,139,139,139,139,139, 87, 87, 87, 87, 87,
+139,139,139,138,138, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 12 */
+ 16, 16, 16, 16, 87, 87,140,140,140,141,141,142,  2,141,143,143,
+144,144,144,144,144,144,144,144,144,144,144,  2, 87, 87,141,  2,
+ 87,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+ 81,145,145,145,145,145,145,145,145,145,145, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82,144,144,144,144,144,144,144,144,144, 87,
+  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,141,141,141,141,145,145,
+ 82,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+
+/* block 13 */
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,141,145,144,144,144,144,144,144,144, 16,146,144,
+144,144,144,144,144,147,147,144,144,143,144,144,144,144,145,145,
+148,148,148,148,148,148,148,148,148,148,145,145,145,143,143,145,
+
+/* block 14 */
+149,149,149,149,149,149,149,149,149,149,149,149,149,149, 87,150,
+151,152,151,151,151,151,151,151,151,151,151,151,151,151,151,151,
+151,151,151,151,151,151,151,151,151,151,151,151,151,151,151,151,
+152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
+152,152,152,152,152,152,152,152,152,152,152, 87, 87,151,151,151,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+
+/* block 15 */
+153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
+153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
+153,153,153,153,153,153,154,154,154,154,154,154,154,154,154,154,
+154,153, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+155,155,155,155,155,155,155,155,155,155,156,156,156,156,156,156,
+156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
+156,156,156,156,156,156,156,156,156,156,156,157,157,157,157,157,
+157,157,157,157,158,158,159,160,160,160,158, 87, 87, 87, 87, 87,
+
+/* block 16 */
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 17 */
+ 87,161,161,162,163,163,163,163,163,163,163,163,163,163,163,163,
+163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,
+163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,
+163,163,163,163,163,163,163,163,163,163, 87, 87,161,163,162,162,
+162,161,161,161,161,161,161,161,161,162,162,162,162,161, 87, 87,
+163, 82, 82,161,161, 87, 87, 87,163,163,163,163,163,163,163,163,
+163,163,161,161,  2,  2,164,164,164,164,164,164,164,164,164,164,
+  2,165,163, 87, 87, 87, 87, 87, 87, 87, 87,163,163,163,163,163,
+
+/* block 18 */
+ 87,166,167,167, 87,168,168,168,168,168,168,168,168, 87, 87,168,
+168, 87, 87,168,168,168,168,168,168,168,168,168,168,168,168,168,
+168,168,168,168,168,168,168,168,168, 87,168,168,168,168,168,168,
+168, 87,168, 87, 87, 87,168,168,168,168, 87, 87,166,168,167,167,
+167,166,166,166,166, 87, 87,167,167, 87, 87,167,167,166,168, 87,
+ 87, 87, 87, 87, 87, 87, 87,167, 87, 87, 87, 87,168,168, 87,168,
+168,168,166,166, 87, 87,169,169,169,169,169,169,169,169,169,169,
+168,168,170,170,171,171,171,171,171,171,172, 87, 87, 87, 87, 87,
+
+/* block 19 */
+ 87,173,173,174, 87,175,175,175,175,175,175, 87, 87, 87, 87,175,
+175, 87, 87,175,175,175,175,175,175,175,175,175,175,175,175,175,
+175,175,175,175,175,175,175,175,175, 87,175,175,175,175,175,175,
+175, 87,175,175, 87,175,175, 87,175,175, 87, 87,173, 87,174,174,
+174,173,173, 87, 87, 87, 87,173,173, 87, 87,173,173,173, 87, 87,
+ 87,173, 87, 87, 87, 87, 87, 87, 87,175,175,175,175, 87,175, 87,
+ 87, 87, 87, 87, 87, 87,176,176,176,176,176,176,176,176,176,176,
+173,173,175,175,175,173, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 20 */
+ 87,177,177,178, 87,179,179,179,179,179,179,179,179,179, 87,179,
+179,179, 87,179,179,179,179,179,179,179,179,179,179,179,179,179,
+179,179,179,179,179,179,179,179,179, 87,179,179,179,179,179,179,
+179, 87,179,179, 87,179,179,179,179,179, 87, 87,177,179,178,178,
+178,177,177,177,177,177, 87,177,177,178, 87,178,178,177, 87, 87,
+179, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+179,179,177,177, 87, 87,180,180,180,180,180,180,180,180,180,180,
+ 87,181, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 21 */
+ 87,182,183,183, 87,184,184,184,184,184,184,184,184, 87, 87,184,
+184, 87, 87,184,184,184,184,184,184,184,184,184,184,184,184,184,
+184,184,184,184,184,184,184,184,184, 87,184,184,184,184,184,184,
+184, 87,184,184, 87,184,184,184,184,184, 87, 87,182,184,183,182,
+183,182,182,182,182, 87, 87,183,183, 87, 87,183,183,182, 87, 87,
+ 87, 87, 87, 87, 87, 87,182,183, 87, 87, 87, 87,184,184, 87,184,
+184,184,182,182, 87, 87,185,185,185,185,185,185,185,185,185,185,
+186,184, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 22 */
+ 87, 87,187,188, 87,188,188,188,188,188,188, 87, 87, 87,188,188,
+188, 87,188,188,188,188, 87, 87, 87,188,188, 87,188, 87,188,188,
+ 87, 87, 87,188,188, 87, 87, 87,188,188,188, 87, 87, 87,188,188,
+188,188,188,188,188,188,188,188,188,188, 87, 87, 87, 87,189,189,
+187,189,189, 87, 87, 87,189,189,189, 87,189,189,189,187, 87, 87,
+188, 87, 87, 87, 87, 87, 87,189, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87,190,190,190,190,190,190,190,190,190,190,
+191,191,191,192,192,192,192,192,192,193,192, 87, 87, 87, 87, 87,
+
+/* block 23 */
+ 87,194,194,194, 87,195,195,195,195,195,195,195,195, 87,195,195,
+195, 87,195,195,195,195,195,195,195,195,195,195,195,195,195,195,
+195,195,195,195,195,195,195,195,195, 87,195,195,195,195,195,195,
+195,195,195,195, 87,195,195,195,195,195, 87, 87, 87,195,196,196,
+196,194,194,194,194, 87,196,196,196, 87,196,196,196,196, 87, 87,
+ 87, 87, 87, 87, 87,196,196, 87,195,195, 87, 87, 87, 87, 87, 87,
+195,195,196,196, 87, 87,197,197,197,197,197,197,197,197,197,197,
+ 87, 87, 87, 87, 87, 87, 87, 87,198,198,198,198,198,198,198,199,
+
+/* block 24 */
+ 87, 87,200,200, 87,201,201,201,201,201,201,201,201, 87,201,201,
+201, 87,201,201,201,201,201,201,201,201,201,201,201,201,201,201,
+201,201,201,201,201,201,201,201,201, 87,201,201,201,201,201,201,
+201,201,201,201, 87,201,201,201,201,201, 87, 87,202,201,200,202,
+200,200,200,200,200, 87,202,200,200, 87,200,200,202,202, 87, 87,
+ 87, 87, 87, 87, 87,200,200, 87, 87, 87, 87, 87, 87, 87,201, 87,
+201,201,202,202, 87, 87,203,203,203,203,203,203,203,203,203,203,
+ 87, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 25 */
+ 87, 87,204,204, 87,205,205,205,205,205,205,205,205, 87,205,205,
+205, 87,205,205,205,205,205,205,205,205,205,205,205,205,205,205,
+205,205,205,205,205,205,205,205,205, 87,205,205,205,205,205,205,
+205,205,205,205,205,205,205,205,205,205, 87, 87, 87,205,204,204,
+204,206,206,206,206, 87,204,204,204, 87,204,204,204,206, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87,204, 87, 87, 87, 87, 87, 87, 87, 87,
+205,205,206,206, 87, 87,207,207,207,207,207,207,207,207,207,207,
+208,208,208,208,208,208, 87, 87, 87,209,205,205,205,205,205,205,
+
+/* block 26 */
+ 87, 87,210,210, 87,211,211,211,211,211,211,211,211,211,211,211,
+211,211,211,211,211,211,211, 87, 87, 87,211,211,211,211,211,211,
+211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,
+211,211, 87,211,211,211,211,211,211,211,211,211, 87,211, 87, 87,
+211,211,211,211,211,211,211, 87, 87, 87,212, 87, 87, 87, 87,210,
+210,210,212,212,212, 87,212, 87,210,210,210,210,210,210,210,210,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87,210,210,213, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 27 */
+ 87,214,214,214,214,214,214,214,214,214,214,214,214,214,214,214,
+214,214,214,214,214,214,214,214,214,214,214,214,214,214,214,214,
+214,214,214,214,214,214,214,214,214,214,214,214,214,214,214,214,
+214,215,214,214,215,215,215,215,215,215,215, 87, 87, 87, 87,  3,
+214,214,214,214,214,214,216,215,215,215,215,215,215,215,215,217,
+218,218,218,218,218,218,218,218,218,218,217,217, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 28 */
+ 87,219,219, 87,219, 87, 87,219,219, 87,219, 87, 87,219, 87, 87,
+ 87, 87, 87, 87,219,219,219,219, 87,219,219,219,219,219,219,219,
+ 87,219,219,219, 87,219, 87,219, 87, 87,219,219, 87,219,219,219,
+219,220,219,219,220,220,220,220,220,220, 87,220,220,219, 87, 87,
+219,219,219,219,219, 87,221, 87,220,220,220,220,220,220, 87, 87,
+222,222,222,222,222,222,222,222,222,222, 87, 87,219,219, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 29 */
+223,224,224,224,225,225,225,225,225,225,225,225,225,225,225,225,
+225,225,225,224,224,224,224,224,226,226,224,224,224,224,224,224,
+227,227,227,227,227,227,227,227,227,227,228,228,228,228,228,228,
+228,228,228,228,224,226,224,226,224,226,229,230,229,230,231,231,
+223,223,223,223,223,223,223,223, 87,223,223,223,223,223,223,223,
+223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,
+223,223,223,223,223,223,223,223,223,223,223,223,223, 87, 87, 87,
+ 87,226,226,226,226,226,226,226,226,226,226,226,226,226,226,231,
+
+/* block 30 */
+226,226,226,226,226,225,226,226,223,223,223,223, 87, 87, 87, 87,
+226,226,226,226,226,226,226,226, 87,226,226,226,226,226,226,226,
+226,226,226,226,226,226,226,226,226,226,226,226,226,226,226,226,
+226,226,226,226,226,226,226,226,226,226,226,226,226, 87,224,224,
+224,224,224,224,224,224,226,224,224,224,224,224,224, 87,224,224,
+225,225,225,225,225, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 31 */
+232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
+232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,
+232,232,232,232,232,232,232,232,232,232,232,233,233,234,234,234,
+234,233,234,234,234,234,234,234,233,234,234,233,233,234,234,232,
+235,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,
+232,232,232,232,232,232,233,233,234,234,232,232,232,232,234,234,
+234,232,233,233,233,232,232,233,233,233,233,233,233,233,232,232,
+232,234,234,234,234,232,232,232,232,232,232,232,232,232,232,232,
+
+/* block 32 */
+232,232,234,233,233,234,234,233,233,233,233,233,233,234,232,233,
+235,235,235,235,235,235,235,235,235,235, 87, 87, 87, 87,237,237,
+238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,
+238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,
+238,238,238,238,238,238, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,
+239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,
+239,239,239,239,239,239,239,239,239,239,239,  2,240, 87, 87, 87,
+
+/* block 33 */
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241, 87, 87, 87, 87, 87,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+
+/* block 34 */
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241, 87, 87, 87, 87, 87,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241, 87, 87, 87, 87, 87, 87,
+
+/* block 35 */
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242, 87,242,242,242,242, 87, 87,
+242,242,242,242,242,242,242, 87,242, 87,242,242,242,242, 87, 87,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+
+/* block 36 */
+242,242,242,242,242,242,242,242,242, 87,242,242,242,242, 87, 87,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242, 87,242,242,242,242, 87, 87,242,242,242,242,242,242,242, 87,
+242, 87,242,242,242,242, 87, 87,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242, 87,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+
+/* block 37 */
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242, 87,242,242,242,242, 87, 87,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242,242,242,242,242, 87, 87, 87, 87,243,
+244,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,
+246,246,246,246,246,246,246,246,246,246,246,246,246, 87, 87, 87,
+
+/* block 38 */
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+244,244,244,244,244,244,244,244,244,244, 87, 87, 87, 87, 87, 87,
+247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,
+247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,
+247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,
+247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,
+247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,
+247,247,247,247,247, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 39 */
+ 87,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+
+/* block 40 */
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+
+/* block 41 */
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,
+248,248,248,248,248,248,248,248,248,248,248,248,248,249,249,248,
+248,248,248,248,248,248,248, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 42 */
+250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,
+251,251,251,251,251,251,251,251,251,251,251,252,253, 87, 87, 87,
+254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,
+254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,
+254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,
+254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,
+254,254,254,254,254,254,254,254,254,254,254,  2,  2,  2,255,255,
+255, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 43 */
+256,256,256,256,256,256,256,256,256,256,256,256,256, 87,256,256,
+256,256,257,257,257, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+258,258,258,258,258,258,258,258,258,258,258,258,258,258,258,258,
+258,258,259,259,259,  2,  2, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+260,260,260,260,260,260,260,260,260,260,260,260,260,260,260,260,
+260,260,261,261, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+262,262,262,262,262,262,262,262,262,262,262,262,262, 87,262,262,
+262, 87,263,263, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 44 */
+264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,
+264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,
+264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,
+264,264,264,264,265,265,266,267,267,267,267,267,267,267,266,266,
+266,266,266,266,266,266,267,266,266,267,267,267,267,267,267,267,
+267,267,267,267,268,268,268,269,268,268,268,270,264,267, 87, 87,
+271,271,271,271,271,271,271,271,271,271, 87, 87, 87, 87, 87, 87,
+272,272,272,272,272,272,272,272,272,272, 87, 87, 87, 87, 87, 87,
+
+/* block 45 */
+273,273,  2,  2,273,  2,274,273,273,273,273,275,275,275,276, 87,
+277,277,277,277,277,277,277,277,277,277, 87, 87, 87, 87, 87, 87,
+278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,
+278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,
+278,278,278,279,278,278,278,278,278,278,278,278,278,278,278,278,
+278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,
+278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,
+278,278,278,278,278,278,278,278, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 46 */
+278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,
+278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,
+278,278,278,278,278,278,278,278,278,275,278, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 47 */
+280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,
+280,280,280,280,280,280,280,280,280,280,280,280,280, 87, 87, 87,
+281,281,281,282,282,282,282,281,281,282,282,282, 87, 87, 87, 87,
+282,282,281,282,282,282,282,282,282,281,281,281, 87, 87, 87, 87,
+283, 87, 87, 87,284,284,285,285,285,285,285,285,285,285,285,285,
+286,286,286,286,286,286,286,286,286,286,286,286,286,286,286,286,
+286,286,286,286,286,286,286,286,286,286,286,286,286,286, 87, 87,
+286,286,286,286,286, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 48 */
+287,287,287,287,287,287,287,287,287,287,287,287,287,287,287,287,
+287,287,287,287,287,287,287,287,287,287,287,287,287,287,287,287,
+287,287,287,287,287,287,287,287,287,287, 87, 87, 87, 87, 87, 87,
+288,288,288,288,288,288,288,288,288,288,288,288,288,288,288,288,
+288,287,287,287,287,287,287,287,288,288, 87, 87, 87, 87, 87, 87,
+289,289,289,289,289,289,289,289,289,289, 87, 87, 87, 87,290,290,
+291,291,291,291,291,291,291,291,291,291,291,291,291,291,291,291,
+291,291,291,291,291,291,291,291,291,291,291,291,291,291,291,291,
+
+/* block 49 */
+292,292,292,292,292,292,292,292,292,292,292,292,292,292,292,292,
+292,292,292,292,292,292,292,293,293,294,294,294, 87, 87,295,295,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 50 */
+296,296,296,296,297,298,298,298,298,298,298,298,298,298,298,298,
+298,298,298,298,298,298,298,298,298,298,298,298,298,298,298,298,
+298,298,298,298,298,298,298,298,298,298,298,298,298,298,298,298,
+298,298,298,298,296,297,296,296,296,296,296,297,296,297,297,297,
+297,297,296,297,297,298,298,298,298,298,298,298, 87, 87, 87, 87,
+299,299,299,299,299,299,299,299,299,299,300,300,300,300,300,300,
+300,301,301,301,301,301,301,301,301,301,301,296,296,296,296,296,
+296,296,296,296,301,301,301,301,301,301,301,301,301, 87, 87, 87,
+
+/* block 51 */
+302,302,303,304,304,304,304,304,304,304,304,304,304,304,304,304,
+304,304,304,304,304,304,304,304,304,304,304,304,304,304,304,304,
+304,303,302,302,302,302,303,303,302,302,303, 87, 87, 87,304,304,
+305,305,305,305,305,305,305,305,305,305, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 52 */
+306,306,306,306,306,306,306,306,306,306,306,306,306,306,306,306,
+306,306,306,306,306,306,306,306,306,306,306,306,306,306,306,306,
+306,306,306,306,307,307,307,307,307,307,307,307,308,308,308,308,
+308,308,308,308,307,307,308,308, 87, 87, 87,309,309,309,309,309,
+310,310,310,310,310,310,310,310,310,310, 87, 87, 87,306,306,306,
+311,311,311,311,311,311,311,311,311,311,312,312,312,312,312,312,
+312,312,312,312,312,312,312,312,312,312,312,312,312,312,312,312,
+312,312,312,312,312,312,312,312,313,313,313,313,313,313,314,314,
+
+/* block 53 */
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 94, 94, 94, 94, 94,315, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 88, 88, 88,
+ 88, 88, 14, 14, 14, 14, 94, 94, 94, 94, 94, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,316,317, 14, 14, 14,318, 14, 14,
+
+/* block 54 */
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 88,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 82, 82,
+
+/* block 55 */
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+
+/* block 56 */
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 14, 14, 14, 14, 14,319, 14, 14,320, 14,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+
+/* block 57 */
+321,321,321,321,321,321,321,321,322,322,322,322,322,322,322,322,
+321,321,321,321,321,321, 87, 87,322,322,322,322,322,322, 87, 87,
+321,321,321,321,321,321,321,321,322,322,322,322,322,322,322,322,
+321,321,321,321,321,321,321,321,322,322,322,322,322,322,322,322,
+321,321,321,321,321,321, 87, 87,322,322,322,322,322,322, 87, 87,
+ 94,321, 94,321, 94,321, 94,321, 87,322, 87,322, 87,322, 87,322,
+321,321,321,321,321,321,321,321,322,322,322,322,322,322,322,322,
+323,323,324,324,324,324,325,325,326,326,327,327,328,328, 87, 87,
+
+/* block 58 */
+321,321,321,321,321,321,321,321,329,329,329,329,329,329,329,329,
+321,321,321,321,321,321,321,321,329,329,329,329,329,329,329,329,
+321,321,321,321,321,321,321,321,329,329,329,329,329,329,329,329,
+321,321, 94,330, 94, 87, 94, 94,322,322,331,331,332, 86,333, 86,
+ 86, 86, 94,330, 94, 87, 94, 94,334,334,334,334,332, 86, 86, 86,
+321,321, 94, 94, 87, 87, 94, 94,322,322,335,335, 87, 86, 86, 86,
+321,321, 94, 94, 94,113, 94, 94,322,322,336,336,117, 86, 86, 86,
+ 87, 87, 94,330, 94, 87, 94, 94,337,337,338,338,332, 86, 86, 87,
+
+/* block 59 */
+  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1, 16,339,339, 16, 16,
+  7,  7,  7,  7,  7,  7,  2,  2, 15, 19,  4, 15, 15, 19,  4, 15,
+  2,  2,  2,  2,  2,  2,  2,  2,340,341, 16, 16, 16, 16, 16,  1,
+  2,  2,  2,  2,  2,  2,  2,  2,  2, 15, 19,  2,  2,  2,  2, 11,
+ 11,  2,  2,  2,  6,  4,  5,  2,  2,  2,  2,  2,  2,  2,  2,  2,
+  2,  2,  6,  2, 11,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  1,
+ 16, 16, 16, 16, 16, 87, 87, 87, 87, 87, 16, 16, 16, 16, 16, 16,
+ 17, 14, 87, 87, 17, 17, 17, 17, 17, 17,  6,  6,  6,  4,  5, 14,
+
+/* block 60 */
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,  6,  6,  6,  4,  5, 87,
+ 80, 80, 80, 80, 80, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
+  3,  3,  3,  3,  3,  3, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,342,342,342,
+342, 82,342,342,342, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 61 */
+ 13, 13,343, 13, 13, 13, 13,343, 13, 13,344,343,343,343,344,344,
+343,343,343,344, 13,343, 13, 13, 13,343,343,343,343,343, 13, 13,
+ 13, 13, 13, 13,343, 13,345, 13,343, 13,346,347,343,343, 13,344,
+343,343,348,343,344,349,349,349,349,344, 13, 13,344,344,343,343,
+  6,  6,  6,  6,  6,343,344,344,344,344, 13,  6, 13, 13,350, 13,
+ 87, 87, 87, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+351,351,351,351,351,351,351,351,351,351,351,351,351,351,351,351,
+352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,
+
+/* block 62 */
+353,353,353, 21, 22,353,353,353,353, 87, 87, 87, 87, 87, 87, 87,
+  6,  6,  6,  6,  6, 13, 13, 13, 13, 13,  6,  6, 13, 13, 13, 13,
+  6, 13, 13,  6, 13, 13,  6, 13, 13, 13, 13, 13, 13, 13,  6, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  6,  6,
+ 13, 13,  6, 13,  6, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+
+/* block 63 */
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+
+/* block 64 */
+ 13, 13, 13, 13, 13, 13, 13, 13,  6,  6,  6,  6, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+  6,  6, 13, 13, 13, 13, 13, 13, 13,  4,  5, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  6, 13, 13, 13,
+
+/* block 65 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  6,  6,  6,  6,
+  6,  6, 13, 13, 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 66 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+
+/* block 67 */
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13,354,354,354,354,354,354,354,354,354,354,
+354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,
+355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,
+355,355,355,355,355,355,355,355,355,355, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+
+/* block 68 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+
+/* block 69 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13,  6, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13,  6, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13,  6,  6,  6,  6,  6,  6,  6,  6,
+
+/* block 70 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  6,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+
+/* block 71 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87, 87,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87, 87, 87,
+ 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 72 */
+ 87, 13, 13, 13, 13, 87, 13, 13, 13, 13, 87, 87, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 87, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87, 13, 87, 13,
+ 13, 13, 13, 87, 87, 87, 13, 87, 13, 13, 13, 13, 13, 13, 13, 87,
+ 87, 13, 13, 13, 13, 13, 13, 13,  4,  5,  4,  5,  4,  5,  4,  5,
+  4,  5,  4,  5,  4,  5, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+
+/* block 73 */
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 13, 87, 87, 87, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 87, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87,
+  6,  6,  6,  6,  6,  4,  5,  6,  6,  6,  6, 87,  6, 87, 87, 87,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  4,  5,  4,  5,  4,  5,  4,  5,  4,  5,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+
+/* block 74 */
+356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,
+356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,
+356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,
+356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,
+356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,
+356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,
+356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,
+356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,
+
+/* block 75 */
+  6,  6,  6,  4,  5,  4,  5,  4,  5,  4,  5,  4,  5,  4,  5,  4,
+  5,  4,  5,  4,  5,  4,  5,  4,  5,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  4,  5,  4,  5,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  4,  5,  6,  6,
+
+/* block 76 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+  6,  6,  6,  6,  6, 13, 13,  6,  6,  6,  6,  6,  6, 87, 87, 87,
+ 13, 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 77 */
+357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,
+357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,
+357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, 87,
+358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,
+358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,
+358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, 87,
+ 21, 22,359,360,361,362,363, 21, 22, 21, 22, 21, 22,364,365,366,
+ 87, 14, 21, 22, 14, 21, 22, 14, 14, 14, 14, 14, 14, 80, 87, 87,
+
+/* block 78 */
+109,110,109,110,109,110,109,110,109,110,109,110,109,110,109,110,
+109,110,109,110,109,110,109,110,109,110,109,110,109,110,109,110,
+109,110,109,110,109,110,109,110,109,110,109,110,109,110,109,110,
+109,110,109,110,109,110,109,110,109,110,109,110,109,110,109,110,
+109,110,109,110,109,110,109,110,109,110,109,110,109,110,109,110,
+109,110,109,110,109,110,109,110,109,110,109,110,109,110,109,110,
+109,110,109,110,367,368,368,368,368,368,368, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87,369,369,369,369,370,369,369,
+
+/* block 79 */
+371,371,371,371,371,371,371,371,371,371,371,371,371,371,371,371,
+371,371,371,371,371,371,371,371,371,371,371,371,371,371,371,371,
+371,371,371,371,371,371, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,
+372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,
+372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,
+372,372,372,372,372,372, 87, 87, 87, 87, 87, 87, 87, 87, 87,373,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 80 */
+242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,242,
+242,242,242,242,242,242,242, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+242,242,242,242,242,242,242, 87,242,242,242,242,242,242,242, 87,
+242,242,242,242,242,242,242, 87,242,242,242,242,242,242,242, 87,
+242,242,242,242,242,242,242, 87,242,242,242,242,242,242,242, 87,
+242,242,242,242,242,242,242, 87,242,242,242,242,242,242,242, 87,
+126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,
+126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,
+
+/* block 81 */
+  2,  2, 15, 19, 15, 19,  2,  2,  2, 15, 19,  2, 15, 19,  2,  2,
+  2,  2,  2,  2,  2,  2,  2,  7,  2,  2,  7,  2, 15, 19,  2,  2,
+ 15, 19,  4,  5,  4,  5,  4,  5,  4,  5,  2,  2,  2,  2,  2, 81,
+  2, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 82 */
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374, 87,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 83 */
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+
+/* block 84 */
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,374,
+374,374,374,374,374,374, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87, 87, 87, 87,
+
+/* block 85 */
+  1,  2,  2,  2, 13,375,349,376,  4,  5,  4,  5,  4,  5,  4,  5,
+  4,  5, 13, 13,  4,  5,  4,  5,  4,  5,  4,  5,  7,  4,  5,  5,
+ 13,376,376,376,376,376,376,376,376,376, 82, 82, 82, 82, 82, 82,
+  7, 81, 81, 81, 81, 81, 13, 13,376,376,376,375,349,  2, 13, 13,
+ 87,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,
+377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,
+377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,
+377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,
+
+/* block 86 */
+377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,
+377,377,377,377,377,377,377, 87, 87, 82, 82, 10, 10,378,378,377,
+  7,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,
+379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,
+379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,
+379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,
+379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,
+379,379,379,379,379,379,379,379,379,379,379,  2, 81,380,380,379,
+
+/* block 87 */
+ 87, 87, 87, 87, 87,381,381,381,381,381,381,381,381,381,381,381,
+381,381,381,381,381,381,381,381,381,381,381,381,381,381,381,381,
+381,381,381,381,381,381,381,381,381,381,381,381,381,381, 87, 87,
+ 87,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+
+/* block 88 */
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241, 87,
+ 13, 13, 17, 17, 17, 17, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+381,381,381,381,381,381,381,381,381,381,381,381,381,381,381,381,
+381,381,381,381,381,381,381,381, 87, 87, 87, 87, 87, 87, 87, 87,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,
+
+/* block 89 */
+382,382,382,382,382,382,382,382,382,382,382,382,382,382,382,382,
+382,382,382,382,382,382,382,382,382,382,382,382,382,382,382, 87,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 13, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+382,382,382,382,382,382,382,382,382,382,382,382,382,382,382,382,
+382,382,382,382,382,382,382,382,382,382,382,382,382,382,382, 13,
+
+/* block 90 */
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,
+383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,
+383,383,383,383,383,383,383,383,383,383,383,383,383,383,383, 87,
+
+/* block 91 */
+383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,
+383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,
+383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,
+383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,
+383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,
+383,383,383,383,383,383,383,383, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+
+/* block 92 */
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+
+/* block 93 */
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+
+/* block 94 */
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 95 */
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,386,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+
+/* block 96 */
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,385,
+
+/* block 97 */
+385,385,385,385,385,385,385,385,385,385,385,385,385, 87, 87, 87,
+387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,
+387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,
+387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,
+387,387,387,387,387,387,387, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 98 */
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+
+/* block 99 */
+388,388,388,388,388,388,388,388,388,388,388,388,389,390,390,390,
+388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,388,
+391,391,391,391,391,391,391,391,391,391,388,388, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+ 87, 87,123,124,123,124,123,124,123,124,123,124,123,124,392,126,
+127,127,127,393, 87, 87, 87, 87, 87, 87, 87, 87,126,126,393,316,
+
+/* block 100 */
+123,124,123,124,123,124,123,124,123,124,123,124,123,124,123,124,
+123,124,123,124,123,124,123,124, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 101 */
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 81, 81, 81, 81, 81, 81, 81, 81, 81,
+ 10, 10, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 14, 14, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22,
+ 80, 14, 14, 14, 14, 14, 14, 14, 14, 21, 22, 21, 22,394, 21, 22,
+
+/* block 102 */
+ 21, 22, 21, 22, 21, 22, 21, 22, 81, 10, 10, 21, 22, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 45, 45, 45, 45, 45,
+
+/* block 103 */
+395,395,396,395,395,395,396,395,395,395,395,396,395,395,395,395,
+395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,
+395,395,395,397,397,396,396,397,398,398,398,398, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+399,399,399,399,399,399,399,399,399,399,399,399,399,399,399,399,
+399,399,399,399,399,399,399,399,399,399,399,399,399,399,399,399,
+399,399,399,399,399,399,399,399,399,399,399,399,399,399,399,399,
+399,399,399,399,400,400,400,400, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 104 */
+401,401,402,402,402,402,402,402,402,402,402,402,402,402,402,402,
+402,402,402,402,402,402,402,402,402,402,402,402,402,402,402,402,
+402,402,402,402,402,402,402,402,402,402,402,402,402,402,402,402,
+402,402,402,402,401,401,401,401,401,401,401,401,401,401,401,401,
+401,401,401,401,403, 87, 87, 87, 87, 87, 87, 87, 87, 87,404,404,
+405,405,405,405,405,405,405,405,405,405, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 105 */
+406,406,406,406,406,406,406,406,406,406,407,407,407,407,407,407,
+407,407,407,407,407,407,407,407,407,407,407,407,407,407,407,407,
+407,407,407,407,407,407,408,408,408,408,408,408,408,408,409,409,
+410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,
+410,410,410,410,410,410,410,411,411,411,411,411,411,411,411,411,
+411,411,412,412, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,413,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 106 */
+414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,
+414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,
+414,414,414,414,414,414,414,414,414,415,415,415,415,415,415,416,
+416,415,415,416,416,415,415, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+414,414,414,415,414,414,414,414,414,414,414,414,415,416, 87, 87,
+417,417,417,417,417,417,417,417,417,417, 87, 87,418,418,418,418,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 107 */
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+
+/* block 108 */
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 109 */
+419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,
+419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,
+419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,
+419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,
+419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,
+419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,
+419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,
+419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,
+
+/* block 110 */
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+
+/* block 111 */
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384, 87, 87,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384, 87, 87, 87, 87, 87,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+
+/* block 112 */
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 113 */
+ 14, 14, 14, 14, 14, 14, 14, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87,134,134,134,134,134, 87, 87, 87, 87, 87,139,136,139,
+139,139,139,139,139,139,139,139,139,421,139,139,139,139,139,139,
+139,139,139,139,139,139,139, 87,139,139,139,139,139, 87,139, 87,
+139,139, 87,139,139, 87,139,139,139,139,139,139,139,139,139,139,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+
+/* block 114 */
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+
+/* block 115 */
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+
+/* block 116 */
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,  4,  5,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+
+/* block 117 */
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+ 87, 87,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+145,145,145,145,145,145,145,145,145,145,145,145,142, 13, 87, 87,
+
+/* block 118 */
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+  2,  2,  2,  2,  2,  2,  2,  4,  5,  2, 87, 87, 87, 87, 87, 87,
+ 82, 82, 82, 82, 82, 82, 82, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+  2,  7,  7, 11, 11,  4,  5,  4,  5,  4,  5,  4,  5,  4,  5,  4,
+  5,  4,  5,  4,  5,  2,  2,  4,  5,  2,  2,  2,  2, 11, 11, 11,
+  2,  2,  2, 87,  2,  2,  2,  2,  7,  4,  5,  4,  5,  4,  5,  2,
+  2,  2,  6,  7,  6,  6,  6, 87,  2,  3,  2,  2, 87, 87, 87, 87,
+145,145,145,145,145, 87,145,145,145,145,145,145,145,145,145,145,
+
+/* block 119 */
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
+145,145,145,145,145,145,145,145,145,145,145,145,145, 87, 87, 16,
+
+/* block 120 */
+ 87,  2,  2,  2,  3,  2,  2,  2,  4,  5,  2,  6,  2,  7,  2,  2,
+  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  2,  2,  6,  6,  6,  2,
+  2,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
+  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  4,  2,  5, 10, 11,
+ 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  4,  6,  5,  6,  4,
+  5,  2,  4,  5,  2,  2,379,379,379,379,379,379,379,379,379,379,
+ 81,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,
+
+/* block 121 */
+379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,379,
+379,379,379,379,379,379,379,379,379,379,379,379,379,379, 81, 81,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
+241,241,241,241,241,241,241,241,241,241,241,241,241,241,241, 87,
+ 87, 87,241,241,241,241,241,241, 87, 87,241,241,241,241,241,241,
+ 87, 87,241,241,241,241,241,241, 87, 87,241,241,241, 87, 87, 87,
+  3,  3,  6, 10, 13,  3,  3, 87, 13,  6,  6,  6,  6, 13, 13, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 16, 16, 16, 13, 13, 87, 87,
+
+/* block 122 */
+422,422,422,422,422,422,422,422,422,422,422,422, 87,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422, 87,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422, 87,422,422, 87,422,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422, 87, 87,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 123 */
+422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,422,
+422,422,422,422,422,422,422,422,422,422,422, 87, 87, 87, 87, 87,
+
+/* block 124 */
+  2,  2, 13, 87, 87, 87, 87, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 87, 87, 87, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+423,423,423,423,423,423,423,423,423,423,423,423,423,423,423,423,
+423,423,423,423,423,423,423,423,423,423,423,423,423,423,423,423,
+423,423,423,423,423,423,423,423,423,423,423,423,423,423,423,423,
+423,423,423,423,423,424,424,424,424,425,425,425,425,425,425,425,
+
+/* block 125 */
+425,425,425,425,425,425,425,425,425,425,424, 87, 87, 87, 87, 87,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 82, 87, 87,
+
+/* block 126 */
+426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,
+426,426,426,426,426,426,426,426,426,426,426,426,426, 87, 87, 87,
+427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,
+427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,
+427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,427,
+427, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 127 */
+428,428,428,428,428,428,428,428,428,428,428,428,428,428,428,428,
+428,428,428,428,428,428,428,428,428,428,428,428,428,428,428, 87,
+429,429,429,429, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+430,430,430,430,430,430,430,430,430,430,430,430,430,430,430,430,
+430,431,430,430,430,430,430,430,430,430,431, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 128 */
+432,432,432,432,432,432,432,432,432,432,432,432,432,432,432,432,
+432,432,432,432,432,432,432,432,432,432,432,432,432,432, 87,433,
+434,434,434,434,434,434,434,434,434,434,434,434,434,434,434,434,
+434,434,434,434,434,434,434,434,434,434,434,434,434,434,434,434,
+434,434,434,434, 87, 87, 87, 87,434,434,434,434,434,434,434,434,
+435,436,436,436,436,436, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 129 */
+437,437,437,437,437,437,437,437,437,437,437,437,437,437,437,437,
+437,437,437,437,437,437,437,437,437,437,437,437,437,437,437,437,
+437,437,437,437,437,437,437,437,438,438,438,438,438,438,438,438,
+438,438,438,438,438,438,438,438,438,438,438,438,438,438,438,438,
+438,438,438,438,438,438,438,438,438,438,438,438,438,438,438,438,
+439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,
+439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,
+439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,439,
+
+/* block 130 */
+440,440,440,440,440,440,440,440,440,440,440,440,440,440,440,440,
+440,440,440,440,440,440,440,440,440,440,440,440,440,440, 87, 87,
+441,441,441,441,441,441,441,441,441,441, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 131 */
+442,442,442,442,442,442, 87, 87,442, 87,442,442,442,442,442,442,
+442,442,442,442,442,442,442,442,442,442,442,442,442,442,442,442,
+442,442,442,442,442,442,442,442,442,442,442,442,442,442,442,442,
+442,442,442,442,442,442, 87,442,442, 87, 87, 87,442, 87, 87,442,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 132 */
+443,443,443,443,443,443,443,443,443,443,443,443,443,443,443,443,
+443,443,443,443,443,443,444,444,444,444, 87, 87, 87, 87, 87,445,
+446,446,446,446,446,446,446,446,446,446,446,446,446,446,446,446,
+446,446,446,446,446,446,446,446,446,446, 87, 87, 87, 87, 87,447,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 133 */
+448,449,449,449, 87,449,449, 87, 87, 87, 87, 87,449,449,449,449,
+448,448,448,448, 87,448,448,448, 87,448,448,448,448,448,448,448,
+448,448,448,448,448,448,448,448,448,448,448,448,448,448,448,448,
+448,448,448,448, 87, 87, 87, 87,449,449,449, 87, 87, 87, 87,449,
+450,450,450,450,450,450,450,450, 87, 87, 87, 87, 87, 87, 87, 87,
+451,451,451,451,451,451,451,451,451, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 134 */
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+
+/* block 135 */
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,452,
+452,452,452,452,452,452,452,452,452,452,452,452,452,452,452, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 136 */
+453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,
+453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,
+453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,
+453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,
+453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,
+453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,
+453,453,453, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+454,454,454,454, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 137 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 138 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 87, 87, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13,455,455, 82, 82, 82, 13, 13, 13,455,455,455,
+455,455,455, 16, 16, 16, 16, 16, 16, 16, 16, 82, 82, 82, 82, 82,
+
+/* block 139 */
+ 82, 82, 82, 13, 13, 82, 82, 82, 82, 82, 82, 82, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 82, 82, 82, 82, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 140 */
+425,425,425,425,425,425,425,425,425,425,425,425,425,425,425,425,
+425,425,425,425,425,425,425,425,425,425,425,425,425,425,425,425,
+425,425,425,425,425,425,425,425,425,425,425,425,425,425,425,425,
+425,425,425,425,425,425,425,425,425,425,425,425,425,425,425,425,
+425,425,456,456,456,425, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 141 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 142 */
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,344,344,
+344,344,344,344,344, 87,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+
+/* block 143 */
+343,343,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,343, 87,343,343,
+ 87, 87,343, 87, 87,343,343, 87, 87,343,343,343,343, 87,343,343,
+343,343,343,343,343,343,344,344,344,344, 87,344, 87,344,344,344,
+344,344,344,344, 87,344,344,344,344,344,344,344,344,344,344,344,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+
+/* block 144 */
+344,344,344,344,343,343, 87,343,343,343,343, 87, 87,343,343,343,
+343,343,343,343,343, 87,343,343,343,343,343,343,343, 87,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,343,343, 87,343,343,343,343, 87,
+343,343,343,343,343, 87,343, 87, 87, 87,343,343,343,343,343,343,
+343, 87,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+
+/* block 145 */
+343,343,343,343,343,343,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+
+/* block 146 */
+344,344,344,344,344,344,344,344,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+
+/* block 147 */
+343,343,343,343,343,343,343,343,343,343,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344, 87, 87,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,  6,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,  6,344,344,344,344,
+344,344,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,  6,344,344,344,344,
+
+/* block 148 */
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,  6,344,344,344,344,344,344,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,  6,344,344,344,344,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,  6,
+344,344,344,344,344,344,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,  6,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+
+/* block 149 */
+344,344,344,344,344,344,344,344,344,  6,344,344,344,344,344,344,
+343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,
+343,343,343,343,343,343,343,343,343,  6,344,344,344,344,344,344,
+344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,
+344,344,344,  6,344,344,344,344,344,344,343,344, 87, 87,  8,  8,
+  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
+  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
+  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
+
+/* block 150 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 87, 87, 87, 87,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+
+/* block 151 */
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 152 */
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 153 */
+384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,
+384,384,384,384,384,384,384,384,384,384,384,384,384,384, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 154 */
+ 87, 16, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+
+/* block 155 */
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+
+/* block 156 */
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+
+/* block 157 */
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,420,
+420,420,420,420,420,420,420,420,420,420,420,420,420,420, 87, 87,
+
+};
+
+#if UCD_BLOCK_SIZE != 128
+#error Please correct UCD_BLOCK_SIZE in pcre_internal.h
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_valid_utf8.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,165 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains an internal function for validating UTF-8 character
+strings. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+*         Validate a UTF-8 string                *
+*************************************************/
+
+/* This function is called (optionally) at the start of compile or match, to
+validate that a supposed UTF-8 string is actually valid. The early check means
+that subsequent code can assume it is dealing with a valid string. The check
+can be turned off for maximum performance, but the consequences of supplying
+an invalid string are then undefined.
+
+Originally, this function checked according to RFC 2279, allowing for values in
+the range 0 to 0x7fffffff, up to 6 bytes long, but ensuring that they were in
+the canonical format. Once somebody had pointed out RFC 3629 to me (it
+obsoletes 2279), additional restrictions were applied. The values are now
+limited to be between 0 and 0x0010ffff, no more than 4 bytes long, and the
+subrange 0xd000 to 0xdfff is excluded.
+
+Arguments:
+  string       points to the string
+  length       length of string, or -1 if the string is zero-terminated
+
+Returns:       < 0    if the string is a valid UTF-8 string
+               >= 0   otherwise; the value is the offset of the bad byte
+*/
+
+int
+_pcre_valid_utf8(const uschar *string, int length)
+{
+#ifdef SUPPORT_UTF8
+register const uschar *p;
+
+if (length < 0)
+  {
+  for (p = string; *p != 0; p++);
+  length = p - string;
+  }
+
+for (p = string; length-- > 0; p++)
+  {
+  register int ab;
+  register int c = *p;
+  if (c < 128) continue;
+  if (c < 0xc0) return p - string;
+  ab = _pcre_utf8_table4[c & 0x3f];     /* Number of additional bytes */
+  if (length < ab || ab > 3) return p - string;
+  length -= ab;
+
+  /* Check top bits in the second byte */
+  if ((*(++p) & 0xc0) != 0x80) return p - string;
+
+  /* Check for overlong sequences for each different length, and for the
+  excluded range 0xd000 to 0xdfff.  */
+
+  switch (ab)
+    {
+    /* Check for xx00 000x (overlong sequence) */
+
+    case 1:
+    if ((c & 0x3e) == 0) return p - string;
+    continue;   /* We know there aren't any more bytes to check */
+
+    /* Check for 1110 0000, xx0x xxxx (overlong sequence) or
+                 1110 1101, 1010 xxxx (0xd000 - 0xdfff) */
+
+    case 2:
+    if ((c == 0xe0 && (*p & 0x20) == 0) ||
+        (c == 0xed && *p >= 0xa0))
+      return p - string;
+    break;
+
+    /* Check for 1111 0000, xx00 xxxx (overlong sequence) or
+       greater than 0x0010ffff (f4 8f bf bf) */
+
+    case 3:
+    if ((c == 0xf0 && (*p & 0x30) == 0) ||
+        (c > 0xf4 ) ||
+        (c == 0xf4 && *p > 0x8f))
+      return p - string;
+    break;
+
+#if 0
+    /* These cases can no longer occur, as we restrict to a maximum of four
+    bytes nowadays. Leave the code here in case we ever want to add an option
+    for longer sequences. */
+
+    /* Check for 1111 1000, xx00 0xxx */
+    case 4:
+    if (c == 0xf8 && (*p & 0x38) == 0) return p - string;
+    break;
+
+    /* Check for leading 0xfe or 0xff, and then for 1111 1100, xx00 00xx */
+    case 5:
+    if (c == 0xfe || c == 0xff ||
+       (c == 0xfc && (*p & 0x3c) == 0)) return p - string;
+    break;
+#endif
+
+    }
+
+  /* Check for valid bytes after the 2nd, if any; all must start 10 */
+  while (--ab > 0)
+    {
+    if ((*(++p) & 0xc0) != 0x80) return p - string;
+    }
+  }
+#else
+(void)(string);  /* Keep picky compilers happy */
+(void)(length);
+#endif
+
+return -1;
+}
+
+/* End of pcre_valid_utf8.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_version.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,90 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains the external function pcre_version(), which returns a
+string that identifies the PCRE version that is in use. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+*          Return version string                 *
+*************************************************/
+
+/* These macros are the standard way of turning unquoted text into C strings.
+They allow macros like PCRE_MAJOR to be defined without quotes, which is
+convenient for user programs that want to test its value. */
+
+#define STRING(a)  # a
+#define XSTRING(s) STRING(s)
+
+/* A problem turned up with PCRE_PRERELEASE, which is defined empty for
+production releases. Originally, it was used naively in this code:
+
+  return XSTRING(PCRE_MAJOR)
+         "." XSTRING(PCRE_MINOR)
+             XSTRING(PCRE_PRERELEASE)
+         " " XSTRING(PCRE_DATE);
+
+However, when PCRE_PRERELEASE is empty, this leads to an attempted expansion of
+STRING(). The C standard states: "If (before argument substitution) any
+argument consists of no preprocessing tokens, the behavior is undefined." It
+turns out the gcc treats this case as a single empty string - which is what we
+really want - but Visual C grumbles about the lack of an argument for the
+macro. Unfortunately, both are within their rights. To cope with both ways of
+handling this, I had resort to some messy hackery that does a test at run time.
+I could find no way of detecting that a macro is defined as an empty string at
+pre-processor time. This hack uses a standard trick for avoiding calling
+the STRING macro with an empty argument when doing the test. */
+
+PCRE_EXP_DEFN const char * PCRE_CALL_CONVENTION
+pcre_version(void)
+{
+return (XSTRING(Z PCRE_PRERELEASE)[1] == 0)?
+  XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) :
+  XSTRING(PCRE_MAJOR.PCRE_MINOR) XSTRING(PCRE_PRERELEASE PCRE_DATE);
+}
+
+/* End of pcre_version.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcre_xclass.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,147 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module contains an internal function that is used to match an extended
+class (one that contains characters whose values are > 255). It is used by both
+pcre_exec() and pcre_def_exec(). */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+
+/*************************************************
+*       Match character against an XCLASS        *
+*************************************************/
+
+/* This function is called to match a character against an extended class that
+might contain values > 255.
+
+Arguments:
+  c           the character
+  data        points to the flag byte of the XCLASS data
+
+Returns:      TRUE if character matches, else FALSE
+*/
+
+BOOL
+_pcre_xclass(int c, const uschar *data)
+{
+int t;
+BOOL negated = (*data & XCL_NOT) != 0;
+
+/* Character values < 256 are matched against a bitmap, if one is present. If
+not, we still carry on, because there may be ranges that start below 256 in the
+additional data. */
+
+if (c < 256)
+  {
+  if ((*data & XCL_MAP) != 0 && (data[1 + c/8] & (1 << (c&7))) != 0)
+    return !negated;   /* char found */
+  }
+
+/* First skip the bit map if present. Then match against the list of Unicode
+properties or large chars or ranges that end with a large char. We won't ever
+encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */
+
+if ((*data++ & XCL_MAP) != 0) data += 32;
+
+while ((t = *data++) != XCL_END)
+  {
+  int x, y;
+  if (t == XCL_SINGLE)
+    {
+    GETCHARINC(x, data);
+    if (c == x) return !negated;
+    }
+  else if (t == XCL_RANGE)
+    {
+    GETCHARINC(x, data);
+    GETCHARINC(y, data);
+    if (c >= x && c <= y) return !negated;
+    }
+
+#ifdef SUPPORT_UCP
+  else  /* XCL_PROP & XCL_NOTPROP */
+    {
+    const ucd_record * prop = GET_UCD(c);
+
+    switch(*data)
+      {
+      case PT_ANY:
+      if (t == XCL_PROP) return !negated;
+      break;
+
+      case PT_LAMP:
+      if ((prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || prop->chartype == ucp_Lt) ==
+          (t == XCL_PROP)) return !negated;
+      break;
+
+      case PT_GC:
+      if ((data[1] == _pcre_ucp_gentype[prop->chartype]) == (t == XCL_PROP)) return !negated;
+      break;
+
+      case PT_PC:
+      if ((data[1] == prop->chartype) == (t == XCL_PROP)) return !negated;
+      break;
+
+      case PT_SC:
+      if ((data[1] == prop->script) == (t == XCL_PROP)) return !negated;
+      break;
+
+      /* This should never occur, but compilers may mutter if there is no
+      default. */
+
+      default:
+      return FALSE;
+      }
+
+    data += 2;
+    }
+#endif  /* SUPPORT_UCP */
+  }
+
+return negated;   /* char did not match */
+}
+
+/* End of pcre_xclass.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcrecpp.cc	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,893 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <limits.h>      /* for SHRT_MIN, USHRT_MAX, etc */
+#include <assert.h>
+#include <errno.h>
+#include <string>
+#include <algorithm>
+
+#include "pcrecpp_internal.h"
+#include "pcre.h"
+#include "pcrecpp.h"
+#include "pcre_stringpiece.h"
+
+
+namespace pcrecpp {
+
+// Maximum number of args we can set
+static const int kMaxArgs = 16;
+static const int kVecSize = (1 + kMaxArgs) * 3;  // results + PCRE workspace
+
+// Special object that stands-in for no argument
+Arg RE::no_arg((void*)NULL);
+
+// This is for ABI compatibility with old versions of pcre (pre-7.6),
+// which defined a global no_arg variable instead of putting it in the
+// RE class.  This works on GCC >= 3, at least.  It definitely works
+// for ELF, but may not for other object formats (Mach-O, for
+// instance, does not support aliases.)  We could probably have a more
+// inclusive test if we ever needed it.  (Note that not only the
+// __attribute__ syntax, but also __USER_LABEL_PREFIX__, are
+// gnu-specific.)
+#if defined(__GNUC__) && __GNUC__ >= 3 && defined(__ELF__)
+# define ULP_AS_STRING(x)            ULP_AS_STRING_INTERNAL(x)
+# define ULP_AS_STRING_INTERNAL(x)   #x
+# define USER_LABEL_PREFIX_STR       ULP_AS_STRING(__USER_LABEL_PREFIX__)
+extern Arg no_arg
+  __attribute__((alias(USER_LABEL_PREFIX_STR "_ZN7pcrecpp2RE6no_argE")));
+#endif
+
+// If a regular expression has no error, its error_ field points here
+static const string empty_string;
+
+// If the user doesn't ask for any options, we just use this one
+static RE_Options default_options;
+
+void RE::Init(const string& pat, const RE_Options* options) {
+  pattern_ = pat;
+  if (options == NULL) {
+    options_ = default_options;
+  } else {
+    options_ = *options;
+  }
+  error_ = &empty_string;
+  re_full_ = NULL;
+  re_partial_ = NULL;
+
+  re_partial_ = Compile(UNANCHORED);
+  if (re_partial_ != NULL) {
+    re_full_ = Compile(ANCHOR_BOTH);
+  }
+}
+
+void RE::Cleanup() {
+  if (re_full_ != NULL)         (*pcre_free)(re_full_);
+  if (re_partial_ != NULL)      (*pcre_free)(re_partial_);
+  if (error_ != &empty_string)  delete error_;
+}
+
+
+RE::~RE() {
+  Cleanup();
+}
+
+
+pcre* RE::Compile(Anchor anchor) {
+  // First, convert RE_Options into pcre options
+  int pcre_options = 0;
+  pcre_options = options_.all_options();
+
+  // Special treatment for anchoring.  This is needed because at
+  // runtime pcre only provides an option for anchoring at the
+  // beginning of a string (unless you use offset).
+  //
+  // There are three types of anchoring we want:
+  //    UNANCHORED      Compile the original pattern, and use
+  //                    a pcre unanchored match.
+  //    ANCHOR_START    Compile the original pattern, and use
+  //                    a pcre anchored match.
+  //    ANCHOR_BOTH     Tack a "\z" to the end of the original pattern
+  //                    and use a pcre anchored match.
+
+  const char* compile_error;
+  int eoffset;
+  pcre* re;
+  if (anchor != ANCHOR_BOTH) {
+    re = pcre_compile(pattern_.c_str(), pcre_options,
+                      &compile_error, &eoffset, NULL);
+  } else {
+    // Tack a '\z' at the end of RE.  Parenthesize it first so that
+    // the '\z' applies to all top-level alternatives in the regexp.
+    string wrapped = "(?:";  // A non-counting grouping operator
+    wrapped += pattern_;
+    wrapped += ")\\z";
+    re = pcre_compile(wrapped.c_str(), pcre_options,
+                      &compile_error, &eoffset, NULL);
+  }
+  if (re == NULL) {
+    if (error_ == &empty_string) error_ = new string(compile_error);
+  }
+  return re;
+}
+
+/***** Matching interfaces *****/
+
+bool RE::FullMatch(const StringPiece& text,
+                   const Arg& ptr1,
+                   const Arg& ptr2,
+                   const Arg& ptr3,
+                   const Arg& ptr4,
+                   const Arg& ptr5,
+                   const Arg& ptr6,
+                   const Arg& ptr7,
+                   const Arg& ptr8,
+                   const Arg& ptr9,
+                   const Arg& ptr10,
+                   const Arg& ptr11,
+                   const Arg& ptr12,
+                   const Arg& ptr13,
+                   const Arg& ptr14,
+                   const Arg& ptr15,
+                   const Arg& ptr16) const {
+  const Arg* args[kMaxArgs];
+  int n = 0;
+  if (&ptr1  == &no_arg) goto done; args[n++] = &ptr1;
+  if (&ptr2  == &no_arg) goto done; args[n++] = &ptr2;
+  if (&ptr3  == &no_arg) goto done; args[n++] = &ptr3;
+  if (&ptr4  == &no_arg) goto done; args[n++] = &ptr4;
+  if (&ptr5  == &no_arg) goto done; args[n++] = &ptr5;
+  if (&ptr6  == &no_arg) goto done; args[n++] = &ptr6;
+  if (&ptr7  == &no_arg) goto done; args[n++] = &ptr7;
+  if (&ptr8  == &no_arg) goto done; args[n++] = &ptr8;
+  if (&ptr9  == &no_arg) goto done; args[n++] = &ptr9;
+  if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10;
+  if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11;
+  if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12;
+  if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13;
+  if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14;
+  if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15;
+  if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16;
+ done:
+
+  int consumed;
+  int vec[kVecSize];
+  return DoMatchImpl(text, ANCHOR_BOTH, &consumed, args, n, vec, kVecSize);
+}
+
+bool RE::PartialMatch(const StringPiece& text,
+                      const Arg& ptr1,
+                      const Arg& ptr2,
+                      const Arg& ptr3,
+                      const Arg& ptr4,
+                      const Arg& ptr5,
+                      const Arg& ptr6,
+                      const Arg& ptr7,
+                      const Arg& ptr8,
+                      const Arg& ptr9,
+                      const Arg& ptr10,
+                      const Arg& ptr11,
+                      const Arg& ptr12,
+                      const Arg& ptr13,
+                      const Arg& ptr14,
+                      const Arg& ptr15,
+                      const Arg& ptr16) const {
+  const Arg* args[kMaxArgs];
+  int n = 0;
+  if (&ptr1  == &no_arg) goto done; args[n++] = &ptr1;
+  if (&ptr2  == &no_arg) goto done; args[n++] = &ptr2;
+  if (&ptr3  == &no_arg) goto done; args[n++] = &ptr3;
+  if (&ptr4  == &no_arg) goto done; args[n++] = &ptr4;
+  if (&ptr5  == &no_arg) goto done; args[n++] = &ptr5;
+  if (&ptr6  == &no_arg) goto done; args[n++] = &ptr6;
+  if (&ptr7  == &no_arg) goto done; args[n++] = &ptr7;
+  if (&ptr8  == &no_arg) goto done; args[n++] = &ptr8;
+  if (&ptr9  == &no_arg) goto done; args[n++] = &ptr9;
+  if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10;
+  if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11;
+  if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12;
+  if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13;
+  if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14;
+  if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15;
+  if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16;
+ done:
+
+  int consumed;
+  int vec[kVecSize];
+  return DoMatchImpl(text, UNANCHORED, &consumed, args, n, vec, kVecSize);
+}
+
+bool RE::Consume(StringPiece* input,
+                 const Arg& ptr1,
+                 const Arg& ptr2,
+                 const Arg& ptr3,
+                 const Arg& ptr4,
+                 const Arg& ptr5,
+                 const Arg& ptr6,
+                 const Arg& ptr7,
+                 const Arg& ptr8,
+                 const Arg& ptr9,
+                 const Arg& ptr10,
+                 const Arg& ptr11,
+                 const Arg& ptr12,
+                 const Arg& ptr13,
+                 const Arg& ptr14,
+                 const Arg& ptr15,
+                 const Arg& ptr16) const {
+  const Arg* args[kMaxArgs];
+  int n = 0;
+  if (&ptr1  == &no_arg) goto done; args[n++] = &ptr1;
+  if (&ptr2  == &no_arg) goto done; args[n++] = &ptr2;
+  if (&ptr3  == &no_arg) goto done; args[n++] = &ptr3;
+  if (&ptr4  == &no_arg) goto done; args[n++] = &ptr4;
+  if (&ptr5  == &no_arg) goto done; args[n++] = &ptr5;
+  if (&ptr6  == &no_arg) goto done; args[n++] = &ptr6;
+  if (&ptr7  == &no_arg) goto done; args[n++] = &ptr7;
+  if (&ptr8  == &no_arg) goto done; args[n++] = &ptr8;
+  if (&ptr9  == &no_arg) goto done; args[n++] = &ptr9;
+  if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10;
+  if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11;
+  if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12;
+  if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13;
+  if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14;
+  if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15;
+  if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16;
+ done:
+
+  int consumed;
+  int vec[kVecSize];
+  if (DoMatchImpl(*input, ANCHOR_START, &consumed,
+                  args, n, vec, kVecSize)) {
+    input->remove_prefix(consumed);
+    return true;
+  } else {
+    return false;
+  }
+}
+
+bool RE::FindAndConsume(StringPiece* input,
+                        const Arg& ptr1,
+                        const Arg& ptr2,
+                        const Arg& ptr3,
+                        const Arg& ptr4,
+                        const Arg& ptr5,
+                        const Arg& ptr6,
+                        const Arg& ptr7,
+                        const Arg& ptr8,
+                        const Arg& ptr9,
+                        const Arg& ptr10,
+                        const Arg& ptr11,
+                        const Arg& ptr12,
+                        const Arg& ptr13,
+                        const Arg& ptr14,
+                        const Arg& ptr15,
+                        const Arg& ptr16) const {
+  const Arg* args[kMaxArgs];
+  int n = 0;
+  if (&ptr1  == &no_arg) goto done; args[n++] = &ptr1;
+  if (&ptr2  == &no_arg) goto done; args[n++] = &ptr2;
+  if (&ptr3  == &no_arg) goto done; args[n++] = &ptr3;
+  if (&ptr4  == &no_arg) goto done; args[n++] = &ptr4;
+  if (&ptr5  == &no_arg) goto done; args[n++] = &ptr5;
+  if (&ptr6  == &no_arg) goto done; args[n++] = &ptr6;
+  if (&ptr7  == &no_arg) goto done; args[n++] = &ptr7;
+  if (&ptr8  == &no_arg) goto done; args[n++] = &ptr8;
+  if (&ptr9  == &no_arg) goto done; args[n++] = &ptr9;
+  if (&ptr10 == &no_arg) goto done; args[n++] = &ptr10;
+  if (&ptr11 == &no_arg) goto done; args[n++] = &ptr11;
+  if (&ptr12 == &no_arg) goto done; args[n++] = &ptr12;
+  if (&ptr13 == &no_arg) goto done; args[n++] = &ptr13;
+  if (&ptr14 == &no_arg) goto done; args[n++] = &ptr14;
+  if (&ptr15 == &no_arg) goto done; args[n++] = &ptr15;
+  if (&ptr16 == &no_arg) goto done; args[n++] = &ptr16;
+ done:
+
+  int consumed;
+  int vec[kVecSize];
+  if (DoMatchImpl(*input, UNANCHORED, &consumed,
+                  args, n, vec, kVecSize)) {
+    input->remove_prefix(consumed);
+    return true;
+  } else {
+    return false;
+  }
+}
+
+bool RE::Replace(const StringPiece& rewrite,
+                 string *str) const {
+  int vec[kVecSize];
+  int matches = TryMatch(*str, 0, UNANCHORED, vec, kVecSize);
+  if (matches == 0)
+    return false;
+
+  string s;
+  if (!Rewrite(&s, rewrite, *str, vec, matches))
+    return false;
+
+  assert(vec[0] >= 0);
+  assert(vec[1] >= 0);
+  str->replace(vec[0], vec[1] - vec[0], s);
+  return true;
+}
+
+// Returns PCRE_NEWLINE_CRLF, PCRE_NEWLINE_CR, or PCRE_NEWLINE_LF.
+// Note that PCRE_NEWLINE_CRLF is defined to be P_N_CR | P_N_LF.
+// Modified by PH to add PCRE_NEWLINE_ANY and PCRE_NEWLINE_ANYCRLF.
+
+static int NewlineMode(int pcre_options) {
+  // TODO: if we can make it threadsafe, cache this var
+  int newline_mode = 0;
+  /* if (newline_mode) return newline_mode; */  // do this once it's cached
+  if (pcre_options & (PCRE_NEWLINE_CRLF|PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|
+                      PCRE_NEWLINE_ANY|PCRE_NEWLINE_ANYCRLF)) {
+    newline_mode = (pcre_options &
+                    (PCRE_NEWLINE_CRLF|PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|
+                     PCRE_NEWLINE_ANY|PCRE_NEWLINE_ANYCRLF));
+  } else {
+    int newline;
+    pcre_config(PCRE_CONFIG_NEWLINE, &newline);
+    if (newline == 10)
+      newline_mode = PCRE_NEWLINE_LF;
+    else if (newline == 13)
+      newline_mode = PCRE_NEWLINE_CR;
+    else if (newline == 3338)
+      newline_mode = PCRE_NEWLINE_CRLF;
+    else if (newline == -1)
+      newline_mode = PCRE_NEWLINE_ANY;
+    else if (newline == -2)
+      newline_mode = PCRE_NEWLINE_ANYCRLF;
+    else
+      assert(NULL == "Unexpected return value from pcre_config(NEWLINE)");
+  }
+  return newline_mode;
+}
+
+int RE::GlobalReplace(const StringPiece& rewrite,
+                      string *str) const {
+  int count = 0;
+  int vec[kVecSize];
+  string out;
+  int start = 0;
+  int lastend = -1;
+
+  while (start <= static_cast<int>(str->length())) {
+    int matches = TryMatch(*str, start, UNANCHORED, vec, kVecSize);
+    if (matches <= 0)
+      break;
+    int matchstart = vec[0], matchend = vec[1];
+    assert(matchstart >= start);
+    assert(matchend >= matchstart);
+    if (matchstart == matchend && matchstart == lastend) {
+      // advance one character if we matched an empty string at the same
+      // place as the last match occurred
+      matchend = start + 1;
+      // If the current char is CR and we're in CRLF mode, skip LF too.
+      // Note it's better to call pcre_fullinfo() than to examine
+      // all_options(), since options_ could have changed bewteen
+      // compile-time and now, but this is simpler and safe enough.
+      // Modified by PH to add ANY and ANYCRLF.
+      if (start+1 < static_cast<int>(str->length()) &&
+          (*str)[start] == '\r' && (*str)[start+1] == '\n' &&
+          (NewlineMode(options_.all_options()) == PCRE_NEWLINE_CRLF ||
+           NewlineMode(options_.all_options()) == PCRE_NEWLINE_ANY ||
+           NewlineMode(options_.all_options()) == PCRE_NEWLINE_ANYCRLF)
+          ) {
+        matchend++;
+      }
+      // We also need to advance more than one char if we're in utf8 mode.
+#ifdef SUPPORT_UTF8
+      if (options_.utf8()) {
+        while (matchend < static_cast<int>(str->length()) &&
+               ((*str)[matchend] & 0xc0) == 0x80)
+          matchend++;
+      }
+#endif
+      if (matchend <= static_cast<int>(str->length()))
+        out.append(*str, start, matchend - start);
+      start = matchend;
+    } else {
+      out.append(*str, start, matchstart - start);
+      Rewrite(&out, rewrite, *str, vec, matches);
+      start = matchend;
+      lastend = matchend;
+      count++;
+    }
+  }
+
+  if (count == 0)
+    return 0;
+
+  if (start < static_cast<int>(str->length()))
+    out.append(*str, start, str->length() - start);
+  swap(out, *str);
+  return count;
+}
+
+bool RE::Extract(const StringPiece& rewrite,
+                 const StringPiece& text,
+                 string *out) const {
+  int vec[kVecSize];
+  int matches = TryMatch(text, 0, UNANCHORED, vec, kVecSize);
+  if (matches == 0)
+    return false;
+  out->erase();
+  return Rewrite(out, rewrite, text, vec, matches);
+}
+
+/*static*/ string RE::QuoteMeta(const StringPiece& unquoted) {
+  string result;
+
+  // Escape any ascii character not in [A-Za-z_0-9].
+  //
+  // Note that it's legal to escape a character even if it has no
+  // special meaning in a regular expression -- so this function does
+  // that.  (This also makes it identical to the perl function of the
+  // same name; see `perldoc -f quotemeta`.)  The one exception is
+  // escaping NUL: rather than doing backslash + NUL, like perl does,
+  // we do '\0', because pcre itself doesn't take embedded NUL chars.
+  for (int ii = 0; ii < unquoted.size(); ++ii) {
+    // Note that using 'isalnum' here raises the benchmark time from
+    // 32ns to 58ns:
+    if (unquoted[ii] == '\0') {
+      result += "\\0";
+    } else if ((unquoted[ii] < 'a' || unquoted[ii] > 'z') &&
+               (unquoted[ii] < 'A' || unquoted[ii] > 'Z') &&
+               (unquoted[ii] < '0' || unquoted[ii] > '9') &&
+               unquoted[ii] != '_' &&
+               // If this is the part of a UTF8 or Latin1 character, we need
+               // to copy this byte without escaping.  Experimentally this is
+               // what works correctly with the regexp library.
+               !(unquoted[ii] & 128)) {
+      result += '\\';
+      result += unquoted[ii];
+    } else {
+      result += unquoted[ii];
+    }
+  }
+
+  return result;
+}
+
+/***** Actual matching and rewriting code *****/
+
+int RE::TryMatch(const StringPiece& text,
+                 int startpos,
+                 Anchor anchor,
+                 int *vec,
+                 int vecsize) const {
+  pcre* re = (anchor == ANCHOR_BOTH) ? re_full_ : re_partial_;
+  if (re == NULL) {
+    //fprintf(stderr, "Matching against invalid re: %s\n", error_->c_str());
+    return 0;
+  }
+
+  pcre_extra extra = { 0, 0, 0, 0, 0, 0 };
+  if (options_.match_limit() > 0) {
+    extra.flags |= PCRE_EXTRA_MATCH_LIMIT;
+    extra.match_limit = options_.match_limit();
+  }
+  if (options_.match_limit_recursion() > 0) {
+    extra.flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
+    extra.match_limit_recursion = options_.match_limit_recursion();
+  }
+  int rc = pcre_exec(re,              // The regular expression object
+                     &extra,
+                     (text.data() == NULL) ? "" : text.data(),
+                     text.size(),
+                     startpos,
+                     (anchor == UNANCHORED) ? 0 : PCRE_ANCHORED,
+                     vec,
+                     vecsize);
+
+  // Handle errors
+  if (rc == PCRE_ERROR_NOMATCH) {
+    return 0;
+  } else if (rc < 0) {
+    //fprintf(stderr, "Unexpected return code: %d when matching '%s'\n",
+    //        re, pattern_.c_str());
+    return 0;
+  } else if (rc == 0) {
+    // pcre_exec() returns 0 as a special case when the number of
+    // capturing subpatterns exceeds the size of the vector.
+    // When this happens, there is a match and the output vector
+    // is filled, but we miss out on the positions of the extra subpatterns.
+    rc = vecsize / 2;
+  }
+
+  return rc;
+}
+
+bool RE::DoMatchImpl(const StringPiece& text,
+                     Anchor anchor,
+                     int* consumed,
+                     const Arg* const* args,
+                     int n,
+                     int* vec,
+                     int vecsize) const {
+  assert((1 + n) * 3 <= vecsize);  // results + PCRE workspace
+  int matches = TryMatch(text, 0, anchor, vec, vecsize);
+  assert(matches >= 0);  // TryMatch never returns negatives
+  if (matches == 0)
+    return false;
+
+  *consumed = vec[1];
+
+  if (n == 0 || args == NULL) {
+    // We are not interested in results
+    return true;
+  }
+
+  if (NumberOfCapturingGroups() < n) {
+    // RE has fewer capturing groups than number of arg pointers passed in
+    return false;
+  }
+
+  // If we got here, we must have matched the whole pattern.
+  // We do not need (can not do) any more checks on the value of 'matches' here
+  // -- see the comment for TryMatch.
+  for (int i = 0; i < n; i++) {
+    const int start = vec[2*(i+1)];
+    const int limit = vec[2*(i+1)+1];
+    if (!args[i]->Parse(text.data() + start, limit-start)) {
+      // TODO: Should we indicate what the error was?
+      return false;
+    }
+  }
+
+  return true;
+}
+
+bool RE::DoMatch(const StringPiece& text,
+                 Anchor anchor,
+                 int* consumed,
+                 const Arg* const args[],
+                 int n) const {
+  assert(n >= 0);
+  size_t const vecsize = (1 + n) * 3;  // results + PCRE workspace
+                                       // (as for kVecSize)
+  int space[21];   // use stack allocation for small vecsize (common case)
+  int* vec = vecsize <= 21 ? space : new int[vecsize];
+  bool retval = DoMatchImpl(text, anchor, consumed, args, n, vec, vecsize);
+  if (vec != space) delete [] vec;
+  return retval;
+}
+
+bool RE::Rewrite(string *out, const StringPiece &rewrite,
+                 const StringPiece &text, int *vec, int veclen) const {
+  for (const char *s = rewrite.data(), *end = s + rewrite.size();
+       s < end; s++) {
+    int c = *s;
+    if (c == '\\') {
+      c = *++s;
+      if (isdigit(c)) {
+        int n = (c - '0');
+        if (n >= veclen) {
+          //fprintf(stderr, requested group %d in regexp %.*s\n",
+          //        n, rewrite.size(), rewrite.data());
+          return false;
+        }
+        int start = vec[2 * n];
+        if (start >= 0)
+          out->append(text.data() + start, vec[2 * n + 1] - start);
+      } else if (c == '\\') {
+        *out += '\\';
+      } else {
+        //fprintf(stderr, "invalid rewrite pattern: %.*s\n",
+        //        rewrite.size(), rewrite.data());
+        return false;
+      }
+    } else {
+      *out += c;
+    }
+  }
+  return true;
+}
+
+// Return the number of capturing subpatterns, or -1 if the
+// regexp wasn't valid on construction.
+int RE::NumberOfCapturingGroups() const {
+  if (re_partial_ == NULL) return -1;
+
+  int result;
+  int pcre_retval = pcre_fullinfo(re_partial_,  // The regular expression object
+                                  NULL,         // We did not study the pattern
+                                  PCRE_INFO_CAPTURECOUNT,
+                                  &result);
+  assert(pcre_retval == 0);
+  return result;
+}
+
+/***** Parsers for various types *****/
+
+bool Arg::parse_null(const char* str, int n, void* dest) {
+  // We fail if somebody asked us to store into a non-NULL void* pointer
+  return (dest == NULL);
+}
+
+bool Arg::parse_string(const char* str, int n, void* dest) {
+  if (dest == NULL) return true;
+  reinterpret_cast<string*>(dest)->assign(str, n);
+  return true;
+}
+
+bool Arg::parse_stringpiece(const char* str, int n, void* dest) {
+  if (dest == NULL) return true;
+  reinterpret_cast<StringPiece*>(dest)->set(str, n);
+  return true;
+}
+
+bool Arg::parse_char(const char* str, int n, void* dest) {
+  if (n != 1) return false;
+  if (dest == NULL) return true;
+  *(reinterpret_cast<char*>(dest)) = str[0];
+  return true;
+}
+
+bool Arg::parse_uchar(const char* str, int n, void* dest) {
+  if (n != 1) return false;
+  if (dest == NULL) return true;
+  *(reinterpret_cast<unsigned char*>(dest)) = str[0];
+  return true;
+}
+
+// Largest number spec that we are willing to parse
+static const int kMaxNumberLength = 32;
+
+// REQUIRES "buf" must have length at least kMaxNumberLength+1
+// REQUIRES "n > 0"
+// Copies "str" into "buf" and null-terminates if necessary.
+// Returns one of:
+//      a. "str" if no termination is needed
+//      b. "buf" if the string was copied and null-terminated
+//      c. "" if the input was invalid and has no hope of being parsed
+static const char* TerminateNumber(char* buf, const char* str, int n) {
+  if ((n > 0) && isspace(*str)) {
+    // We are less forgiving than the strtoxxx() routines and do not
+    // allow leading spaces.
+    return "";
+  }
+
+  // See if the character right after the input text may potentially
+  // look like a digit.
+  if (isdigit(str[n]) ||
+      ((str[n] >= 'a') && (str[n] <= 'f')) ||
+      ((str[n] >= 'A') && (str[n] <= 'F'))) {
+    if (n > kMaxNumberLength) return ""; // Input too big to be a valid number
+    memcpy(buf, str, n);
+    buf[n] = '\0';
+    return buf;
+  } else {
+    // We can parse right out of the supplied string, so return it.
+    return str;
+  }
+}
+
+bool Arg::parse_long_radix(const char* str,
+                           int n,
+                           void* dest,
+                           int radix) {
+  if (n == 0) return false;
+  char buf[kMaxNumberLength+1];
+  str = TerminateNumber(buf, str, n);
+  char* end;
+  errno = 0;
+  long r = strtol(str, &end, radix);
+  if (end != str + n) return false;   // Leftover junk
+  if (errno) return false;
+  if (dest == NULL) return true;
+  *(reinterpret_cast<long*>(dest)) = r;
+  return true;
+}
+
+bool Arg::parse_ulong_radix(const char* str,
+                            int n,
+                            void* dest,
+                            int radix) {
+  if (n == 0) return false;
+  char buf[kMaxNumberLength+1];
+  str = TerminateNumber(buf, str, n);
+  if (str[0] == '-') return false;    // strtoul() on a negative number?!
+  char* end;
+  errno = 0;
+  unsigned long r = strtoul(str, &end, radix);
+  if (end != str + n) return false;   // Leftover junk
+  if (errno) return false;
+  if (dest == NULL) return true;
+  *(reinterpret_cast<unsigned long*>(dest)) = r;
+  return true;
+}
+
+bool Arg::parse_short_radix(const char* str,
+                            int n,
+                            void* dest,
+                            int radix) {
+  long r;
+  if (!parse_long_radix(str, n, &r, radix)) return false; // Could not parse
+  if (r < SHRT_MIN || r > SHRT_MAX) return false;       // Out of range
+  if (dest == NULL) return true;
+  *(reinterpret_cast<short*>(dest)) = static_cast<short>(r);
+  return true;
+}
+
+bool Arg::parse_ushort_radix(const char* str,
+                             int n,
+                             void* dest,
+                             int radix) {
+  unsigned long r;
+  if (!parse_ulong_radix(str, n, &r, radix)) return false; // Could not parse
+  if (r > USHRT_MAX) return false;                      // Out of range
+  if (dest == NULL) return true;
+  *(reinterpret_cast<unsigned short*>(dest)) = static_cast<unsigned short>(r);
+  return true;
+}
+
+bool Arg::parse_int_radix(const char* str,
+                          int n,
+                          void* dest,
+                          int radix) {
+  long r;
+  if (!parse_long_radix(str, n, &r, radix)) return false; // Could not parse
+  if (r < INT_MIN || r > INT_MAX) return false;         // Out of range
+  if (dest == NULL) return true;
+  *(reinterpret_cast<int*>(dest)) = r;
+  return true;
+}
+
+bool Arg::parse_uint_radix(const char* str,
+                           int n,
+                           void* dest,
+                           int radix) {
+  unsigned long r;
+  if (!parse_ulong_radix(str, n, &r, radix)) return false; // Could not parse
+  if (r > UINT_MAX) return false;                       // Out of range
+  if (dest == NULL) return true;
+  *(reinterpret_cast<unsigned int*>(dest)) = r;
+  return true;
+}
+
+bool Arg::parse_longlong_radix(const char* str,
+                               int n,
+                               void* dest,
+                               int radix) {
+#ifndef HAVE_LONG_LONG
+  return false;
+#else
+  if (n == 0) return false;
+  char buf[kMaxNumberLength+1];
+  str = TerminateNumber(buf, str, n);
+  char* end;
+  errno = 0;
+#if defined HAVE_STRTOQ
+  long long r = strtoq(str, &end, radix);
+#elif defined HAVE_STRTOLL
+  long long r = strtoll(str, &end, radix);
+#elif defined HAVE__STRTOI64
+  long long r = _strtoi64(str, &end, radix);
+#else
+#error parse_longlong_radix: cannot convert input to a long-long
+#endif
+  if (end != str + n) return false;   // Leftover junk
+  if (errno) return false;
+  if (dest == NULL) return true;
+  *(reinterpret_cast<long long*>(dest)) = r;
+  return true;
+#endif   /* HAVE_LONG_LONG */
+}
+
+bool Arg::parse_ulonglong_radix(const char* str,
+                                int n,
+                                void* dest,
+                                int radix) {
+#ifndef HAVE_UNSIGNED_LONG_LONG
+  return false;
+#else
+  if (n == 0) return false;
+  char buf[kMaxNumberLength+1];
+  str = TerminateNumber(buf, str, n);
+  if (str[0] == '-') return false;    // strtoull() on a negative number?!
+  char* end;
+  errno = 0;
+#if defined HAVE_STRTOQ
+  unsigned long long r = strtouq(str, &end, radix);
+#elif defined HAVE_STRTOLL
+  unsigned long long r = strtoull(str, &end, radix);
+#elif defined HAVE__STRTOI64
+  unsigned long long r = _strtoui64(str, &end, radix);
+#else
+#error parse_ulonglong_radix: cannot convert input to a long-long
+#endif
+  if (end != str + n) return false;   // Leftover junk
+  if (errno) return false;
+  if (dest == NULL) return true;
+  *(reinterpret_cast<unsigned long long*>(dest)) = r;
+  return true;
+#endif   /* HAVE_UNSIGNED_LONG_LONG */
+}
+
+bool Arg::parse_double(const char* str, int n, void* dest) {
+  if (n == 0) return false;
+  static const int kMaxLength = 200;
+  char buf[kMaxLength];
+  if (n >= kMaxLength) return false;
+  memcpy(buf, str, n);
+  buf[n] = '\0';
+  errno = 0;
+  char* end;
+  double r = strtod(buf, &end);
+  if (end != buf + n) return false;   // Leftover junk
+  if (errno) return false;
+  if (dest == NULL) return true;
+  *(reinterpret_cast<double*>(dest)) = r;
+  return true;
+}
+
+bool Arg::parse_float(const char* str, int n, void* dest) {
+  double r;
+  if (!parse_double(str, n, &r)) return false;
+  if (dest == NULL) return true;
+  *(reinterpret_cast<float*>(dest)) = static_cast<float>(r);
+  return true;
+}
+
+
+#define DEFINE_INTEGER_PARSERS(name)                                    \
+  bool Arg::parse_##name(const char* str, int n, void* dest) {          \
+    return parse_##name##_radix(str, n, dest, 10);                      \
+  }                                                                     \
+  bool Arg::parse_##name##_hex(const char* str, int n, void* dest) {    \
+    return parse_##name##_radix(str, n, dest, 16);                      \
+  }                                                                     \
+  bool Arg::parse_##name##_octal(const char* str, int n, void* dest) {  \
+    return parse_##name##_radix(str, n, dest, 8);                       \
+  }                                                                     \
+  bool Arg::parse_##name##_cradix(const char* str, int n, void* dest) { \
+    return parse_##name##_radix(str, n, dest, 0);                       \
+  }
+
+DEFINE_INTEGER_PARSERS(short)      /*                                   */
+DEFINE_INTEGER_PARSERS(ushort)     /*                                   */
+DEFINE_INTEGER_PARSERS(int)        /* Don't use semicolons after these  */
+DEFINE_INTEGER_PARSERS(uint)       /* statements because they can cause */
+DEFINE_INTEGER_PARSERS(long)       /* compiler warnings if the checking */
+DEFINE_INTEGER_PARSERS(ulong)      /* level is turned up high enough.   */
+DEFINE_INTEGER_PARSERS(longlong)   /*                                   */
+DEFINE_INTEGER_PARSERS(ulonglong)  /*                                   */
+
+#undef DEFINE_INTEGER_PARSERS
+
+}   // namespace pcrecpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcrecpp.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,703 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+// Support for PCRE_XXX modifiers added by Giuseppe Maxia, July 2005
+
+#ifndef _PCRECPP_H
+#define _PCRECPP_H
+
+// C++ interface to the pcre regular-expression library.  RE supports
+// Perl-style regular expressions (with extensions like \d, \w, \s,
+// ...).
+//
+// -----------------------------------------------------------------------
+// REGEXP SYNTAX:
+//
+// This module is part of the pcre library and hence supports its syntax
+// for regular expressions.
+//
+// The syntax is pretty similar to Perl's.  For those not familiar
+// with Perl's regular expressions, here are some examples of the most
+// commonly used extensions:
+//
+//   "hello (\\w+) world"  -- \w matches a "word" character
+//   "version (\\d+)"      -- \d matches a digit
+//   "hello\\s+world"      -- \s matches any whitespace character
+//   "\\b(\\w+)\\b"        -- \b matches empty string at a word boundary
+//   "(?i)hello"           -- (?i) turns on case-insensitive matching
+//   "/\\*(.*?)\\*/"       -- .*? matches . minimum no. of times possible
+//
+// -----------------------------------------------------------------------
+// MATCHING INTERFACE:
+//
+// The "FullMatch" operation checks that supplied text matches a
+// supplied pattern exactly.
+//
+// Example: successful match
+//    pcrecpp::RE re("h.*o");
+//    re.FullMatch("hello");
+//
+// Example: unsuccessful match (requires full match):
+//    pcrecpp::RE re("e");
+//    !re.FullMatch("hello");
+//
+// Example: creating a temporary RE object:
+//    pcrecpp::RE("h.*o").FullMatch("hello");
+//
+// You can pass in a "const char*" or a "string" for "text".  The
+// examples below tend to use a const char*.
+//
+// You can, as in the different examples above, store the RE object
+// explicitly in a variable or use a temporary RE object.  The
+// examples below use one mode or the other arbitrarily.  Either
+// could correctly be used for any of these examples.
+//
+// -----------------------------------------------------------------------
+// MATCHING WITH SUB-STRING EXTRACTION:
+//
+// You can supply extra pointer arguments to extract matched subpieces.
+//
+// Example: extracts "ruby" into "s" and 1234 into "i"
+//    int i;
+//    string s;
+//    pcrecpp::RE re("(\\w+):(\\d+)");
+//    re.FullMatch("ruby:1234", &s, &i);
+//
+// Example: does not try to extract any extra sub-patterns
+//    re.FullMatch("ruby:1234", &s);
+//
+// Example: does not try to extract into NULL
+//    re.FullMatch("ruby:1234", NULL, &i);
+//
+// Example: integer overflow causes failure
+//    !re.FullMatch("ruby:1234567891234", NULL, &i);
+//
+// Example: fails because there aren't enough sub-patterns:
+//    !pcrecpp::RE("\\w+:\\d+").FullMatch("ruby:1234", &s);
+//
+// Example: fails because string cannot be stored in integer
+//    !pcrecpp::RE("(.*)").FullMatch("ruby", &i);
+//
+// The provided pointer arguments can be pointers to any scalar numeric
+// type, or one of
+//    string        (matched piece is copied to string)
+//    StringPiece   (StringPiece is mutated to point to matched piece)
+//    T             (where "bool T::ParseFrom(const char*, int)" exists)
+//    NULL          (the corresponding matched sub-pattern is not copied)
+//
+// CAVEAT: An optional sub-pattern that does not exist in the matched
+// string is assigned the empty string.  Therefore, the following will
+// return false (because the empty string is not a valid number):
+//    int number;
+//    pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
+//
+// -----------------------------------------------------------------------
+// DO_MATCH
+//
+// The matching interface supports at most 16 arguments per call.
+// If you need more, consider using the more general interface
+// pcrecpp::RE::DoMatch().  See pcrecpp.h for the signature for DoMatch.
+//
+// -----------------------------------------------------------------------
+// PARTIAL MATCHES
+//
+// You can use the "PartialMatch" operation when you want the pattern
+// to match any substring of the text.
+//
+// Example: simple search for a string:
+//    pcrecpp::RE("ell").PartialMatch("hello");
+//
+// Example: find first number in a string:
+//    int number;
+//    pcrecpp::RE re("(\\d+)");
+//    re.PartialMatch("x*100 + 20", &number);
+//    assert(number == 100);
+//
+// -----------------------------------------------------------------------
+// UTF-8 AND THE MATCHING INTERFACE:
+//
+// By default, pattern and text are plain text, one byte per character.
+// The UTF8 flag, passed to the constructor, causes both pattern
+// and string to be treated as UTF-8 text, still a byte stream but
+// potentially multiple bytes per character. In practice, the text
+// is likelier to be UTF-8 than the pattern, but the match returned
+// may depend on the UTF8 flag, so always use it when matching
+// UTF8 text.  E.g., "." will match one byte normally but with UTF8
+// set may match up to three bytes of a multi-byte character.
+//
+// Example:
+//    pcrecpp::RE_Options options;
+//    options.set_utf8();
+//    pcrecpp::RE re(utf8_pattern, options);
+//    re.FullMatch(utf8_string);
+//
+// Example: using the convenience function UTF8():
+//    pcrecpp::RE re(utf8_pattern, pcrecpp::UTF8());
+//    re.FullMatch(utf8_string);
+//
+// NOTE: The UTF8 option is ignored if pcre was not configured with the
+//       --enable-utf8 flag.
+//
+// -----------------------------------------------------------------------
+// PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
+//
+// PCRE defines some modifiers to change the behavior of the regular
+// expression engine.
+// The C++ wrapper defines an auxiliary class, RE_Options, as a vehicle
+// to pass such modifiers to a RE class.
+//
+// Currently, the following modifiers are supported
+//
+//    modifier              description               Perl corresponding
+//
+//    PCRE_CASELESS         case insensitive match    /i
+//    PCRE_MULTILINE        multiple lines match      /m
+//    PCRE_DOTALL           dot matches newlines      /s
+//    PCRE_DOLLAR_ENDONLY   $ matches only at end     N/A
+//    PCRE_EXTRA            strict escape parsing     N/A
+//    PCRE_EXTENDED         ignore whitespaces        /x
+//    PCRE_UTF8             handles UTF8 chars        built-in
+//    PCRE_UNGREEDY         reverses * and *?         N/A
+//    PCRE_NO_AUTO_CAPTURE  disables matching parens  N/A (*)
+//
+// (For a full account on how each modifier works, please check the
+// PCRE API reference manual).
+//
+// (*) Both Perl and PCRE allow non matching parentheses by means of the
+// "?:" modifier within the pattern itself. e.g. (?:ab|cd) does not
+// capture, while (ab|cd) does.
+//
+// For each modifier, there are two member functions whose name is made
+// out of the modifier in lowercase, without the "PCRE_" prefix. For
+// instance, PCRE_CASELESS is handled by
+//    bool caseless(),
+// which returns true if the modifier is set, and
+//    RE_Options & set_caseless(bool),
+// which sets or unsets the modifier.
+//
+// Moreover, PCRE_EXTRA_MATCH_LIMIT can be accessed through the
+// set_match_limit() and match_limit() member functions.
+// Setting match_limit to a non-zero value will limit the executation of
+// pcre to keep it from doing bad things like blowing the stack or taking
+// an eternity to return a result.  A value of 5000 is good enough to stop
+// stack blowup in a 2MB thread stack.  Setting match_limit to zero will
+// disable match limiting.  Alternately, you can set match_limit_recursion()
+// which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much pcre
+// recurses.  match_limit() caps the number of matches pcre does;
+// match_limit_recrusion() caps the depth of recursion.
+//
+// Normally, to pass one or more modifiers to a RE class, you declare
+// a RE_Options object, set the appropriate options, and pass this
+// object to a RE constructor. Example:
+//
+//    RE_options opt;
+//    opt.set_caseless(true);
+//
+//    if (RE("HELLO", opt).PartialMatch("hello world")) ...
+//
+// RE_options has two constructors. The default constructor takes no
+// arguments and creates a set of flags that are off by default.
+//
+// The optional parameter 'option_flags' is to facilitate transfer
+// of legacy code from C programs.  This lets you do
+//    RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
+//
+// But new code is better off doing
+//    RE(pattern,
+//      RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str);
+// (See below)
+//
+// If you are going to pass one of the most used modifiers, there are some
+// convenience functions that return a RE_Options class with the
+// appropriate modifier already set:
+// CASELESS(), UTF8(), MULTILINE(), DOTALL(), EXTENDED()
+//
+// If you need to set several options at once, and you don't want to go
+// through the pains of declaring a RE_Options object and setting several
+// options, there is a parallel method that give you such ability on the
+// fly. You can concatenate several set_xxxxx member functions, since each
+// of them returns a reference to its class object.  e.g.: to pass
+// PCRE_CASELESS, PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one
+// statement, you may write
+//
+//    RE(" ^ xyz \\s+ .* blah$", RE_Options()
+//                            .set_caseless(true)
+//                            .set_extended(true)
+//                            .set_multiline(true)).PartialMatch(sometext);
+//
+// -----------------------------------------------------------------------
+// SCANNING TEXT INCREMENTALLY
+//
+// The "Consume" operation may be useful if you want to repeatedly
+// match regular expressions at the front of a string and skip over
+// them as they match.  This requires use of the "StringPiece" type,
+// which represents a sub-range of a real string.  Like RE, StringPiece
+// is defined in the pcrecpp namespace.
+//
+// Example: read lines of the form "var = value" from a string.
+//    string contents = ...;                 // Fill string somehow
+//    pcrecpp::StringPiece input(contents);  // Wrap in a StringPiece
+//
+//    string var;
+//    int value;
+//    pcrecpp::RE re("(\\w+) = (\\d+)\n");
+//    while (re.Consume(&input, &var, &value)) {
+//      ...;
+//    }
+//
+// Each successful call to "Consume" will set "var/value", and also
+// advance "input" so it points past the matched text.
+//
+// The "FindAndConsume" operation is similar to "Consume" but does not
+// anchor your match at the beginning of the string.  For example, you
+// could extract all words from a string by repeatedly calling
+//     pcrecpp::RE("(\\w+)").FindAndConsume(&input, &word)
+//
+// -----------------------------------------------------------------------
+// PARSING HEX/OCTAL/C-RADIX NUMBERS
+//
+// By default, if you pass a pointer to a numeric value, the
+// corresponding text is interpreted as a base-10 number.  You can
+// instead wrap the pointer with a call to one of the operators Hex(),
+// Octal(), or CRadix() to interpret the text in another base.  The
+// CRadix operator interprets C-style "0" (base-8) and "0x" (base-16)
+// prefixes, but defaults to base-10.
+//
+// Example:
+//   int a, b, c, d;
+//   pcrecpp::RE re("(.*) (.*) (.*) (.*)");
+//   re.FullMatch("100 40 0100 0x40",
+//                pcrecpp::Octal(&a), pcrecpp::Hex(&b),
+//                pcrecpp::CRadix(&c), pcrecpp::CRadix(&d));
+// will leave 64 in a, b, c, and d.
+//
+// -----------------------------------------------------------------------
+// REPLACING PARTS OF STRINGS
+//
+// You can replace the first match of "pattern" in "str" with
+// "rewrite".  Within "rewrite", backslash-escaped digits (\1 to \9)
+// can be used to insert text matching corresponding parenthesized
+// group from the pattern.  \0 in "rewrite" refers to the entire
+// matching text.  E.g.,
+//
+//   string s = "yabba dabba doo";
+//   pcrecpp::RE("b+").Replace("d", &s);
+//
+// will leave "s" containing "yada dabba doo".  The result is true if
+// the pattern matches and a replacement occurs, or false otherwise.
+//
+// GlobalReplace() is like Replace(), except that it replaces all
+// occurrences of the pattern in the string with the rewrite.
+// Replacements are not subject to re-matching.  E.g.,
+//
+//   string s = "yabba dabba doo";
+//   pcrecpp::RE("b+").GlobalReplace("d", &s);
+//
+// will leave "s" containing "yada dada doo".  It returns the number
+// of replacements made.
+//
+// Extract() is like Replace(), except that if the pattern matches,
+// "rewrite" is copied into "out" (an additional argument) with
+// substitutions.  The non-matching portions of "text" are ignored.
+// Returns true iff a match occurred and the extraction happened
+// successfully.  If no match occurs, the string is left unaffected.
+
+
+#include <string>
+#include <pcre.h>
+#include <pcrecpparg.h>   // defines the Arg class
+// This isn't technically needed here, but we include it
+// anyway so folks who include pcrecpp.h don't have to.
+#include <pcre_stringpiece.h>
+
+namespace pcrecpp {
+
+#define PCRE_SET_OR_CLEAR(b, o) \
+    if (b) all_options_ |= (o); else all_options_ &= ~(o); \
+    return *this
+
+#define PCRE_IS_SET(o)  \
+        (all_options_ & o) == o
+
+/***** Compiling regular expressions: the RE class *****/
+
+// RE_Options allow you to set options to be passed along to pcre,
+// along with other options we put on top of pcre.
+// Only 9 modifiers, plus match_limit and match_limit_recursion,
+// are supported now.
+class PCRECPP_EXP_DEFN RE_Options {
+ public:
+  // constructor
+  RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {}
+
+  // alternative constructor.
+  // To facilitate transfer of legacy code from C programs
+  //
+  // This lets you do
+  //    RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
+  // But new code is better off doing
+  //    RE(pattern,
+  //      RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str);
+  RE_Options(int option_flags) : match_limit_(0), match_limit_recursion_(0),
+                                 all_options_(option_flags) {}
+  // we're fine with the default destructor, copy constructor, etc.
+
+  // accessors and mutators
+  int match_limit() const { return match_limit_; };
+  RE_Options &set_match_limit(int limit) {
+    match_limit_ = limit;
+    return *this;
+  }
+
+  int match_limit_recursion() const { return match_limit_recursion_; };
+  RE_Options &set_match_limit_recursion(int limit) {
+    match_limit_recursion_ = limit;
+    return *this;
+  }
+
+  bool caseless() const {
+    return PCRE_IS_SET(PCRE_CASELESS);
+  }
+  RE_Options &set_caseless(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_CASELESS);
+  }
+
+  bool multiline() const {
+    return PCRE_IS_SET(PCRE_MULTILINE);
+  }
+  RE_Options &set_multiline(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_MULTILINE);
+  }
+
+  bool dotall() const {
+    return PCRE_IS_SET(PCRE_DOTALL);
+  }
+  RE_Options &set_dotall(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_DOTALL);
+  }
+
+  bool extended() const {
+    return PCRE_IS_SET(PCRE_EXTENDED);
+  }
+  RE_Options &set_extended(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_EXTENDED);
+  }
+
+  bool dollar_endonly() const {
+    return PCRE_IS_SET(PCRE_DOLLAR_ENDONLY);
+  }
+  RE_Options &set_dollar_endonly(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_DOLLAR_ENDONLY);
+  }
+
+  bool extra() const {
+    return PCRE_IS_SET(PCRE_EXTRA);
+  }
+  RE_Options &set_extra(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_EXTRA);
+  }
+
+  bool ungreedy() const {
+    return PCRE_IS_SET(PCRE_UNGREEDY);
+  }
+  RE_Options &set_ungreedy(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_UNGREEDY);
+  }
+
+  bool utf8() const {
+    return PCRE_IS_SET(PCRE_UTF8);
+  }
+  RE_Options &set_utf8(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_UTF8);
+  }
+
+  bool no_auto_capture() const {
+    return PCRE_IS_SET(PCRE_NO_AUTO_CAPTURE);
+  }
+  RE_Options &set_no_auto_capture(bool x) {
+    PCRE_SET_OR_CLEAR(x, PCRE_NO_AUTO_CAPTURE);
+  }
+
+  RE_Options &set_all_options(int opt) {
+    all_options_ = opt;
+    return *this;
+  }
+  int all_options() const {
+    return all_options_ ;
+  }
+
+  // TODO: add other pcre flags
+
+ private:
+  int match_limit_;
+  int match_limit_recursion_;
+  int all_options_;
+};
+
+// These functions return some common RE_Options
+static inline RE_Options UTF8() {
+  return RE_Options().set_utf8(true);
+}
+
+static inline RE_Options CASELESS() {
+  return RE_Options().set_caseless(true);
+}
+static inline RE_Options MULTILINE() {
+  return RE_Options().set_multiline(true);
+}
+
+static inline RE_Options DOTALL() {
+  return RE_Options().set_dotall(true);
+}
+
+static inline RE_Options EXTENDED() {
+  return RE_Options().set_extended(true);
+}
+
+// Interface for regular expression matching.  Also corresponds to a
+// pre-compiled regular expression.  An "RE" object is safe for
+// concurrent use by multiple threads.
+class PCRECPP_EXP_DEFN RE {
+ public:
+  // We provide implicit conversions from strings so that users can
+  // pass in a string or a "const char*" wherever an "RE" is expected.
+  RE(const string& pat) { Init(pat, NULL); }
+  RE(const string& pat, const RE_Options& option) { Init(pat, &option); }
+  RE(const char* pat) { Init(pat, NULL); }
+  RE(const char* pat, const RE_Options& option) { Init(pat, &option); }
+  RE(const unsigned char* pat) {
+    Init(reinterpret_cast<const char*>(pat), NULL);
+  }
+  RE(const unsigned char* pat, const RE_Options& option) {
+    Init(reinterpret_cast<const char*>(pat), &option);
+  }
+
+  // Copy constructor & assignment - note that these are expensive
+  // because they recompile the expression.
+  RE(const RE& re) { Init(re.pattern_, &re.options_); }
+  const RE& operator=(const RE& re) {
+    if (this != &re) {
+      Cleanup();
+
+      // This is the code that originally came from Google
+      // Init(re.pattern_.c_str(), &re.options_);
+
+      // This is the replacement from Ari Pollak
+      Init(re.pattern_, &re.options_);
+    }
+    return *this;
+  }
+
+
+  ~RE();
+
+  // The string specification for this RE.  E.g.
+  //   RE re("ab*c?d+");
+  //   re.pattern();    // "ab*c?d+"
+  const string& pattern() const { return pattern_; }
+
+  // If RE could not be created properly, returns an error string.
+  // Else returns the empty string.
+  const string& error() const { return *error_; }
+
+  /***** The useful part: the matching interface *****/
+
+  // This is provided so one can do pattern.ReplaceAll() just as
+  // easily as ReplaceAll(pattern-text, ....)
+
+  bool FullMatch(const StringPiece& text,
+                 const Arg& ptr1 = no_arg,
+                 const Arg& ptr2 = no_arg,
+                 const Arg& ptr3 = no_arg,
+                 const Arg& ptr4 = no_arg,
+                 const Arg& ptr5 = no_arg,
+                 const Arg& ptr6 = no_arg,
+                 const Arg& ptr7 = no_arg,
+                 const Arg& ptr8 = no_arg,
+                 const Arg& ptr9 = no_arg,
+                 const Arg& ptr10 = no_arg,
+                 const Arg& ptr11 = no_arg,
+                 const Arg& ptr12 = no_arg,
+                 const Arg& ptr13 = no_arg,
+                 const Arg& ptr14 = no_arg,
+                 const Arg& ptr15 = no_arg,
+                 const Arg& ptr16 = no_arg) const;
+
+  bool PartialMatch(const StringPiece& text,
+                    const Arg& ptr1 = no_arg,
+                    const Arg& ptr2 = no_arg,
+                    const Arg& ptr3 = no_arg,
+                    const Arg& ptr4 = no_arg,
+                    const Arg& ptr5 = no_arg,
+                    const Arg& ptr6 = no_arg,
+                    const Arg& ptr7 = no_arg,
+                    const Arg& ptr8 = no_arg,
+                    const Arg& ptr9 = no_arg,
+                    const Arg& ptr10 = no_arg,
+                    const Arg& ptr11 = no_arg,
+                    const Arg& ptr12 = no_arg,
+                    const Arg& ptr13 = no_arg,
+                    const Arg& ptr14 = no_arg,
+                    const Arg& ptr15 = no_arg,
+                    const Arg& ptr16 = no_arg) const;
+
+  bool Consume(StringPiece* input,
+               const Arg& ptr1 = no_arg,
+               const Arg& ptr2 = no_arg,
+               const Arg& ptr3 = no_arg,
+               const Arg& ptr4 = no_arg,
+               const Arg& ptr5 = no_arg,
+               const Arg& ptr6 = no_arg,
+               const Arg& ptr7 = no_arg,
+               const Arg& ptr8 = no_arg,
+               const Arg& ptr9 = no_arg,
+               const Arg& ptr10 = no_arg,
+               const Arg& ptr11 = no_arg,
+               const Arg& ptr12 = no_arg,
+               const Arg& ptr13 = no_arg,
+               const Arg& ptr14 = no_arg,
+               const Arg& ptr15 = no_arg,
+               const Arg& ptr16 = no_arg) const;
+
+  bool FindAndConsume(StringPiece* input,
+                      const Arg& ptr1 = no_arg,
+                      const Arg& ptr2 = no_arg,
+                      const Arg& ptr3 = no_arg,
+                      const Arg& ptr4 = no_arg,
+                      const Arg& ptr5 = no_arg,
+                      const Arg& ptr6 = no_arg,
+                      const Arg& ptr7 = no_arg,
+                      const Arg& ptr8 = no_arg,
+                      const Arg& ptr9 = no_arg,
+                      const Arg& ptr10 = no_arg,
+                      const Arg& ptr11 = no_arg,
+                      const Arg& ptr12 = no_arg,
+                      const Arg& ptr13 = no_arg,
+                      const Arg& ptr14 = no_arg,
+                      const Arg& ptr15 = no_arg,
+                      const Arg& ptr16 = no_arg) const;
+
+  bool Replace(const StringPiece& rewrite,
+               string *str) const;
+
+  int GlobalReplace(const StringPiece& rewrite,
+                    string *str) const;
+
+  bool Extract(const StringPiece &rewrite,
+               const StringPiece &text,
+               string *out) const;
+
+  // Escapes all potentially meaningful regexp characters in
+  // 'unquoted'.  The returned string, used as a regular expression,
+  // will exactly match the original string.  For example,
+  //           1.5-2.0?
+  // may become:
+  //           1\.5\-2\.0\?
+  // Note QuoteMeta behaves the same as perl's QuoteMeta function,
+  // *except* that it escapes the NUL character (\0) as backslash + 0,
+  // rather than backslash + NUL.
+  static string QuoteMeta(const StringPiece& unquoted);
+
+
+  /***** Generic matching interface *****/
+
+  // Type of match (TODO: Should be restructured as part of RE_Options)
+  enum Anchor {
+    UNANCHORED,         // No anchoring
+    ANCHOR_START,       // Anchor at start only
+    ANCHOR_BOTH         // Anchor at start and end
+  };
+
+  // General matching routine.  Stores the length of the match in
+  // "*consumed" if successful.
+  bool DoMatch(const StringPiece& text,
+               Anchor anchor,
+               int* consumed,
+               const Arg* const* args, int n) const;
+
+  // Return the number of capturing subpatterns, or -1 if the
+  // regexp wasn't valid on construction.
+  int NumberOfCapturingGroups() const;
+
+  // The default value for an argument, to indicate no arg was passed in
+  static Arg no_arg;
+
+ private:
+
+  void Init(const string& pattern, const RE_Options* options);
+  void Cleanup();
+
+  // Match against "text", filling in "vec" (up to "vecsize" * 2/3) with
+  // pairs of integers for the beginning and end positions of matched
+  // text.  The first pair corresponds to the entire matched text;
+  // subsequent pairs correspond, in order, to parentheses-captured
+  // matches.  Returns the number of pairs (one more than the number of
+  // the last subpattern with a match) if matching was successful
+  // and zero if the match failed.
+  // I.e. for RE("(foo)|(bar)|(baz)") it will return 2, 3, and 4 when matching
+  // against "foo", "bar", and "baz" respectively.
+  // When matching RE("(foo)|hello") against "hello", it will return 1.
+  // But the values for all subpattern are filled in into "vec".
+  int TryMatch(const StringPiece& text,
+               int startpos,
+               Anchor anchor,
+               int *vec,
+               int vecsize) const;
+
+  // Append the "rewrite" string, with backslash subsitutions from "text"
+  // and "vec", to string "out".
+  bool Rewrite(string *out,
+               const StringPiece& rewrite,
+               const StringPiece& text,
+               int *vec,
+               int veclen) const;
+
+  // internal implementation for DoMatch
+  bool DoMatchImpl(const StringPiece& text,
+                   Anchor anchor,
+                   int* consumed,
+                   const Arg* const args[],
+                   int n,
+                   int* vec,
+                   int vecsize) const;
+
+  // Compile the regexp for the specified anchoring mode
+  pcre* Compile(Anchor anchor);
+
+  string        pattern_;
+  RE_Options    options_;
+  pcre*         re_full_;       // For full matches
+  pcre*         re_partial_;    // For partial matches
+  const string* error_;         // Error indicator (or points to empty string)
+};
+
+}   // namespace pcrecpp
+
+#endif /* _PCRECPP_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcrecpp_internal.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,71 @@
+/*************************************************
+*       Perl-Compatible Regular Expressions      *
+*************************************************/
+
+/*
+Copyright (c) 2005, Google Inc.
+All rights reserved.
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+#ifndef PCRECPP_INTERNAL_H
+#define PCRECPP_INTERNAL_H
+
+/* When compiling a DLL for Windows, the exported symbols have to be declared
+using some MS magic. I found some useful information on this web page:
+http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
+information there, using __declspec(dllexport) without "extern" we have a
+definition; with "extern" we have a declaration. The settings here override the
+setting in pcre.h. We use:
+
+  PCRECPP_EXP_DECL       for declarations
+  PCRECPP_EXP_DEFN       for definitions of exported functions
+
+*/
+
+#ifndef PCRECPP_EXP_DECL
+#  ifdef _WIN32
+#    ifndef PCRE_STATIC
+#      define PCRECPP_EXP_DECL       extern __declspec(dllexport)
+#      define PCRECPP_EXP_DEFN       __declspec(dllexport)
+#    else
+#      define PCRECPP_EXP_DECL       extern
+#      define PCRECPP_EXP_DEFN
+#    endif
+#  else
+#    define PCRECPP_EXP_DECL         extern
+#    define PCRECPP_EXP_DEFN
+#  endif
+#endif
+
+#endif  /* PCRECPP_INTERNAL_H */
+
+/* End of pcrecpp_internal.h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcrecpp_unittest.cc	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1276 @@
+// -*- coding: utf-8 -*-
+//
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// TODO: Test extractions for PartialMatch/Consume
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <cassert>
+#include <vector>
+#include "pcrecpp.h"
+
+using pcrecpp::StringPiece;
+using pcrecpp::RE;
+using pcrecpp::RE_Options;
+using pcrecpp::Hex;
+using pcrecpp::Octal;
+using pcrecpp::CRadix;
+
+static bool VERBOSE_TEST  = false;
+
+// CHECK dies with a fatal error if condition is not true.  It is *not*
+// controlled by NDEBUG, so the check will be executed regardless of
+// compilation mode.  Therefore, it is safe to do things like:
+//    CHECK_EQ(fp->Write(x), 4)
+#define CHECK(condition) do {                           \
+  if (!(condition)) {                                   \
+    fprintf(stderr, "%s:%d: Check failed: %s\n",        \
+            __FILE__, __LINE__, #condition);            \
+    exit(1);                                            \
+  }                                                     \
+} while (0)
+
+#define CHECK_EQ(a, b)   CHECK(a == b)
+
+static void Timing1(int num_iters) {
+  // Same pattern lots of times
+  RE pattern("ruby:\\d+");
+  StringPiece p("ruby:1234");
+  for (int j = num_iters; j > 0; j--) {
+    CHECK(pattern.FullMatch(p));
+  }
+}
+
+static void Timing2(int num_iters) {
+  // Same pattern lots of times
+  RE pattern("ruby:(\\d+)");
+  int i;
+  for (int j = num_iters; j > 0; j--) {
+    CHECK(pattern.FullMatch("ruby:1234", &i));
+    CHECK_EQ(i, 1234);
+  }
+}
+
+static void Timing3(int num_iters) {
+  string text_string;
+  for (int j = num_iters; j > 0; j--) {
+    text_string += "this is another line\n";
+  }
+
+  RE line_matcher(".*\n");
+  string line;
+  StringPiece text(text_string);
+  int counter = 0;
+  while (line_matcher.Consume(&text)) {
+    counter++;
+  }
+  printf("Matched %d lines\n", counter);
+}
+
+#if 0  // uncomment this if you have a way of defining VirtualProcessSize()
+
+static void LeakTest() {
+  // Check for memory leaks
+  unsigned long long initial_size = 0;
+  for (int i = 0; i < 100000; i++) {
+    if (i == 50000) {
+      initial_size = VirtualProcessSize();
+      printf("Size after 50000: %llu\n", initial_size);
+    }
+    char buf[100];  // definitely big enough
+    sprintf(buf, "pat%09d", i);
+    RE newre(buf);
+  }
+  uint64 final_size = VirtualProcessSize();
+  printf("Size after 100000: %llu\n", final_size);
+  const double growth = double(final_size - initial_size) / final_size;
+  printf("Growth: %0.2f%%", growth * 100);
+  CHECK(growth < 0.02);       // Allow < 2% growth
+}
+
+#endif
+
+static void RadixTests() {
+  printf("Testing hex\n");
+
+#define CHECK_HEX(type, value) \
+  do { \
+    type v; \
+    CHECK(RE("([0-9a-fA-F]+)[uUlL]*").FullMatch(#value, Hex(&v))); \
+    CHECK_EQ(v, 0x ## value); \
+    CHECK(RE("([0-9a-fA-FxX]+)[uUlL]*").FullMatch("0x" #value, CRadix(&v))); \
+    CHECK_EQ(v, 0x ## value); \
+  } while(0)
+
+  CHECK_HEX(short,              2bad);
+  CHECK_HEX(unsigned short,     2badU);
+  CHECK_HEX(int,                dead);
+  CHECK_HEX(unsigned int,       deadU);
+  CHECK_HEX(long,               7eadbeefL);
+  CHECK_HEX(unsigned long,      deadbeefUL);
+#ifdef HAVE_LONG_LONG
+  CHECK_HEX(long long,          12345678deadbeefLL);
+#endif
+#ifdef HAVE_UNSIGNED_LONG_LONG
+  CHECK_HEX(unsigned long long, cafebabedeadbeefULL);
+#endif
+
+#undef CHECK_HEX
+
+  printf("Testing octal\n");
+
+#define CHECK_OCTAL(type, value) \
+  do { \
+    type v; \
+    CHECK(RE("([0-7]+)[uUlL]*").FullMatch(#value, Octal(&v))); \
+    CHECK_EQ(v, 0 ## value); \
+    CHECK(RE("([0-9a-fA-FxX]+)[uUlL]*").FullMatch("0" #value, CRadix(&v))); \
+    CHECK_EQ(v, 0 ## value); \
+  } while(0)
+
+  CHECK_OCTAL(short,              77777);
+  CHECK_OCTAL(unsigned short,     177777U);
+  CHECK_OCTAL(int,                17777777777);
+  CHECK_OCTAL(unsigned int,       37777777777U);
+  CHECK_OCTAL(long,               17777777777L);
+  CHECK_OCTAL(unsigned long,      37777777777UL);
+#ifdef HAVE_LONG_LONG
+  CHECK_OCTAL(long long,          777777777777777777777LL);
+#endif
+#ifdef HAVE_UNSIGNED_LONG_LONG
+  CHECK_OCTAL(unsigned long long, 1777777777777777777777ULL);
+#endif
+
+#undef CHECK_OCTAL
+
+  printf("Testing decimal\n");
+
+#define CHECK_DECIMAL(type, value) \
+  do { \
+    type v; \
+    CHECK(RE("(-?[0-9]+)[uUlL]*").FullMatch(#value, &v)); \
+    CHECK_EQ(v, value); \
+    CHECK(RE("(-?[0-9a-fA-FxX]+)[uUlL]*").FullMatch(#value, CRadix(&v))); \
+    CHECK_EQ(v, value); \
+  } while(0)
+
+  CHECK_DECIMAL(short,              -1);
+  CHECK_DECIMAL(unsigned short,     9999);
+  CHECK_DECIMAL(int,                -1000);
+  CHECK_DECIMAL(unsigned int,       12345U);
+  CHECK_DECIMAL(long,               -10000000L);
+  CHECK_DECIMAL(unsigned long,      3083324652U);
+#ifdef HAVE_LONG_LONG
+  CHECK_DECIMAL(long long,          -100000000000000LL);
+#endif
+#ifdef HAVE_UNSIGNED_LONG_LONG
+  CHECK_DECIMAL(unsigned long long, 1234567890987654321ULL);
+#endif
+
+#undef CHECK_DECIMAL
+
+}
+
+static void TestReplace() {
+  printf("Testing Replace\n");
+
+  struct ReplaceTest {
+    const char *regexp;
+    const char *rewrite;
+    const char *original;
+    const char *single;
+    const char *global;
+    int global_count;         // the expected return value from ReplaceAll
+  };
+  static const ReplaceTest tests[] = {
+    { "(qu|[b-df-hj-np-tv-z]*)([a-z]+)",
+      "\\2\\1ay",
+      "the quick brown fox jumps over the lazy dogs.",
+      "ethay quick brown fox jumps over the lazy dogs.",
+      "ethay ickquay ownbray oxfay umpsjay overay ethay azylay ogsday.",
+      9 },
+    { "\\w+",
+      "\\0-NOSPAM",
+      "paul.haahr@google.com",
+      "paul-NOSPAM.haahr@google.com",
+      "paul-NOSPAM.haahr-NOSPAM@google-NOSPAM.com-NOSPAM",
+      4 },
+    { "^",
+      "(START)",
+      "foo",
+      "(START)foo",
+      "(START)foo",
+      1 },
+    { "^",
+      "(START)",
+      "",
+      "(START)",
+      "(START)",
+      1 },
+    { "$",
+      "(END)",
+      "",
+      "(END)",
+      "(END)",
+      1 },
+    { "b",
+      "bb",
+      "ababababab",
+      "abbabababab",
+      "abbabbabbabbabb",
+       5 },
+    { "b",
+      "bb",
+      "bbbbbb",
+      "bbbbbbb",
+      "bbbbbbbbbbbb",
+      6 },
+    { "b+",
+      "bb",
+      "bbbbbb",
+      "bb",
+      "bb",
+      1 },
+    { "b*",
+      "bb",
+      "bbbbbb",
+      "bb",
+      "bb",
+      1 },
+    { "b*",
+      "bb",
+      "aaaaa",
+      "bbaaaaa",
+      "bbabbabbabbabbabb",
+      6 },
+    { "b*",
+      "bb",
+      "aa\naa\n",
+      "bbaa\naa\n",
+      "bbabbabb\nbbabbabb\nbb",
+      7 },
+    { "b*",
+      "bb",
+      "aa\raa\r",
+      "bbaa\raa\r",
+      "bbabbabb\rbbabbabb\rbb",
+      7 },
+    { "b*",
+      "bb",
+      "aa\r\naa\r\n",
+      "bbaa\r\naa\r\n",
+      "bbabbabb\r\nbbabbabb\r\nbb",
+      7 },
+#ifdef SUPPORT_UTF8
+    { "b*",
+      "bb",
+      "\xE3\x83\x9B\xE3\x83\xBC\xE3\x83\xA0\xE3\x81\xB8",   // utf8
+      "bb\xE3\x83\x9B\xE3\x83\xBC\xE3\x83\xA0\xE3\x81\xB8",
+      "bb\xE3\x83\x9B""bb""\xE3\x83\xBC""bb""\xE3\x83\xA0""bb""\xE3\x81\xB8""bb",
+      5 },
+    { "b*",
+      "bb",
+      "\xE3\x83\x9B\r\n\xE3\x83\xBC\r\xE3\x83\xA0\n\xE3\x81\xB8\r\n",   // utf8
+      "bb\xE3\x83\x9B\r\n\xE3\x83\xBC\r\xE3\x83\xA0\n\xE3\x81\xB8\r\n",
+      ("bb\xE3\x83\x9B""bb\r\nbb""\xE3\x83\xBC""bb\rbb""\xE3\x83\xA0"
+       "bb\nbb""\xE3\x81\xB8""bb\r\nbb"),
+      9 },
+#endif
+    { "", NULL, NULL, NULL, NULL, 0 }
+  };
+
+#ifdef SUPPORT_UTF8
+  const bool support_utf8 = true;
+#else
+  const bool support_utf8 = false;
+#endif
+
+  for (const ReplaceTest *t = tests; t->original != NULL; ++t) {
+    RE re(t->regexp, RE_Options(PCRE_NEWLINE_CRLF).set_utf8(support_utf8));
+    assert(re.error().empty());
+    string one(t->original);
+    CHECK(re.Replace(t->rewrite, &one));
+    CHECK_EQ(one, t->single);
+    string all(t->original);
+    const int replace_count = re.GlobalReplace(t->rewrite, &all);
+    CHECK_EQ(all, t->global);
+    CHECK_EQ(replace_count, t->global_count);
+  }
+
+  // One final test: test \r\n replacement when we're not in CRLF mode
+  {
+    RE re("b*", RE_Options(PCRE_NEWLINE_CR).set_utf8(support_utf8));
+    assert(re.error().empty());
+    string all("aa\r\naa\r\n");
+    CHECK_EQ(re.GlobalReplace("bb", &all), 9);
+    CHECK_EQ(all, string("bbabbabb\rbb\nbbabbabb\rbb\nbb"));
+  }
+  {
+    RE re("b*", RE_Options(PCRE_NEWLINE_LF).set_utf8(support_utf8));
+    assert(re.error().empty());
+    string all("aa\r\naa\r\n");
+    CHECK_EQ(re.GlobalReplace("bb", &all), 9);
+    CHECK_EQ(all, string("bbabbabb\rbb\nbbabbabb\rbb\nbb"));
+  }
+  // TODO: test what happens when no PCRE_NEWLINE_* flag is set.
+  //       Alas, the answer depends on how pcre was compiled.
+}
+
+static void TestExtract() {
+  printf("Testing Extract\n");
+
+  string s;
+
+  CHECK(RE("(.*)@([^.]*)").Extract("\\2!\\1", "boris@kremvax.ru", &s));
+  CHECK_EQ(s, "kremvax!boris");
+
+  // check the RE interface as well
+  CHECK(RE(".*").Extract("'\\0'", "foo", &s));
+  CHECK_EQ(s, "'foo'");
+  CHECK(!RE("bar").Extract("'\\0'", "baz", &s));
+  CHECK_EQ(s, "'foo'");
+}
+
+static void TestConsume() {
+  printf("Testing Consume\n");
+
+  string word;
+
+  string s("   aaa b!@#$@#$cccc");
+  StringPiece input(s);
+
+  RE r("\\s*(\\w+)");    // matches a word, possibly proceeded by whitespace
+  CHECK(r.Consume(&input, &word));
+  CHECK_EQ(word, "aaa");
+  CHECK(r.Consume(&input, &word));
+  CHECK_EQ(word, "b");
+  CHECK(! r.Consume(&input, &word));
+}
+
+static void TestFindAndConsume() {
+  printf("Testing FindAndConsume\n");
+
+  string word;
+
+  string s("   aaa b!@#$@#$cccc");
+  StringPiece input(s);
+
+  RE r("(\\w+)");      // matches a word
+  CHECK(r.FindAndConsume(&input, &word));
+  CHECK_EQ(word, "aaa");
+  CHECK(r.FindAndConsume(&input, &word));
+  CHECK_EQ(word, "b");
+  CHECK(r.FindAndConsume(&input, &word));
+  CHECK_EQ(word, "cccc");
+  CHECK(! r.FindAndConsume(&input, &word));
+}
+
+static void TestMatchNumberPeculiarity() {
+  printf("Testing match-number peculiaraity\n");
+
+  string word1;
+  string word2;
+  string word3;
+
+  RE r("(foo)|(bar)|(baz)");
+  CHECK(r.PartialMatch("foo", &word1, &word2, &word3));
+  CHECK_EQ(word1, "foo");
+  CHECK_EQ(word2, "");
+  CHECK_EQ(word3, "");
+  CHECK(r.PartialMatch("bar", &word1, &word2, &word3));
+  CHECK_EQ(word1, "");
+  CHECK_EQ(word2, "bar");
+  CHECK_EQ(word3, "");
+  CHECK(r.PartialMatch("baz", &word1, &word2, &word3));
+  CHECK_EQ(word1, "");
+  CHECK_EQ(word2, "");
+  CHECK_EQ(word3, "baz");
+  CHECK(!r.PartialMatch("f", &word1, &word2, &word3));
+
+  string a;
+  CHECK(RE("(foo)|hello").FullMatch("hello", &a));
+  CHECK_EQ(a, "");
+}
+
+static void TestRecursion() {
+  printf("Testing recursion\n");
+
+  // Get one string that passes (sometimes), one that never does.
+  string text_good("abcdefghijk");
+  string text_bad("acdefghijkl");
+
+  // According to pcretest, matching text_good against (\w+)*b
+  // requires match_limit of at least 8192, and match_recursion_limit
+  // of at least 37.
+
+  RE_Options options_ml;
+  options_ml.set_match_limit(8192);
+  RE re("(\\w+)*b", options_ml);
+  CHECK(re.PartialMatch(text_good) == true);
+  CHECK(re.PartialMatch(text_bad) == false);
+  CHECK(re.FullMatch(text_good) == false);
+  CHECK(re.FullMatch(text_bad) == false);
+
+  options_ml.set_match_limit(1024);
+  RE re2("(\\w+)*b", options_ml);
+  CHECK(re2.PartialMatch(text_good) == false);   // because of match_limit
+  CHECK(re2.PartialMatch(text_bad) == false);
+  CHECK(re2.FullMatch(text_good) == false);
+  CHECK(re2.FullMatch(text_bad) == false);
+
+  RE_Options options_mlr;
+  options_mlr.set_match_limit_recursion(50);
+  RE re3("(\\w+)*b", options_mlr);
+  CHECK(re3.PartialMatch(text_good) == true);
+  CHECK(re3.PartialMatch(text_bad) == false);
+  CHECK(re3.FullMatch(text_good) == false);
+  CHECK(re3.FullMatch(text_bad) == false);
+
+  options_mlr.set_match_limit_recursion(10);
+  RE re4("(\\w+)*b", options_mlr);
+  CHECK(re4.PartialMatch(text_good) == false);
+  CHECK(re4.PartialMatch(text_bad) == false);
+  CHECK(re4.FullMatch(text_good) == false);
+  CHECK(re4.FullMatch(text_bad) == false);
+}
+
+// A meta-quoted string, interpreted as a pattern, should always match
+// the original unquoted string.
+static void TestQuoteMeta(string unquoted, RE_Options options = RE_Options()) {
+  string quoted = RE::QuoteMeta(unquoted);
+  RE re(quoted, options);
+  CHECK(re.FullMatch(unquoted));
+}
+
+// A string containing meaningful regexp characters, which is then meta-
+// quoted, should not generally match a string the unquoted string does.
+static void NegativeTestQuoteMeta(string unquoted, string should_not_match,
+                                  RE_Options options = RE_Options()) {
+  string quoted = RE::QuoteMeta(unquoted);
+  RE re(quoted, options);
+  CHECK(!re.FullMatch(should_not_match));
+}
+
+// Tests that quoted meta characters match their original strings,
+// and that a few things that shouldn't match indeed do not.
+static void TestQuotaMetaSimple() {
+  TestQuoteMeta("foo");
+  TestQuoteMeta("foo.bar");
+  TestQuoteMeta("foo\\.bar");
+  TestQuoteMeta("[1-9]");
+  TestQuoteMeta("1.5-2.0?");
+  TestQuoteMeta("\\d");
+  TestQuoteMeta("Who doesn't like ice cream?");
+  TestQuoteMeta("((a|b)c?d*e+[f-h]i)");
+  TestQuoteMeta("((?!)xxx).*yyy");
+  TestQuoteMeta("([");
+  TestQuoteMeta(string("foo\0bar", 7));
+}
+
+static void TestQuoteMetaSimpleNegative() {
+  NegativeTestQuoteMeta("foo", "bar");
+  NegativeTestQuoteMeta("...", "bar");
+  NegativeTestQuoteMeta("\\.", ".");
+  NegativeTestQuoteMeta("\\.", "..");
+  NegativeTestQuoteMeta("(a)", "a");
+  NegativeTestQuoteMeta("(a|b)", "a");
+  NegativeTestQuoteMeta("(a|b)", "(a)");
+  NegativeTestQuoteMeta("(a|b)", "a|b");
+  NegativeTestQuoteMeta("[0-9]", "0");
+  NegativeTestQuoteMeta("[0-9]", "0-9");
+  NegativeTestQuoteMeta("[0-9]", "[9]");
+  NegativeTestQuoteMeta("((?!)xxx)", "xxx");
+}
+
+static void TestQuoteMetaLatin1() {
+  TestQuoteMeta("3\xb2 = 9");
+}
+
+static void TestQuoteMetaUtf8() {
+#ifdef SUPPORT_UTF8
+  TestQuoteMeta("Pl\xc3\xa1\x63ido Domingo", pcrecpp::UTF8());
+  TestQuoteMeta("xyz", pcrecpp::UTF8());            // No fancy utf8
+  TestQuoteMeta("\xc2\xb0", pcrecpp::UTF8());       // 2-byte utf8 (degree symbol)
+  TestQuoteMeta("27\xc2\xb0 degrees", pcrecpp::UTF8());  // As a middle character
+  TestQuoteMeta("\xe2\x80\xb3", pcrecpp::UTF8());   // 3-byte utf8 (double prime)
+  TestQuoteMeta("\xf0\x9d\x85\x9f", pcrecpp::UTF8()); // 4-byte utf8 (music note)
+  TestQuoteMeta("27\xc2\xb0"); // Interpreted as Latin-1, but should still work
+  NegativeTestQuoteMeta("27\xc2\xb0",               // 2-byte utf (degree symbol)
+                        "27\\\xc2\\\xb0",
+                        pcrecpp::UTF8());
+#endif
+}
+
+static void TestQuoteMetaAll() {
+  printf("Testing QuoteMeta\n");
+  TestQuotaMetaSimple();
+  TestQuoteMetaSimpleNegative();
+  TestQuoteMetaLatin1();
+  TestQuoteMetaUtf8();
+}
+
+//
+// Options tests contributed by
+// Giuseppe Maxia, CTO, Stardata s.r.l.
+// July 2005
+//
+static void GetOneOptionResult(
+                const char *option_name,
+                const char *regex,
+                const char *str,
+                RE_Options options,
+                bool full,
+                string expected) {
+
+  printf("Testing Option <%s>\n", option_name);
+  if(VERBOSE_TEST)
+    printf("/%s/ finds \"%s\" within \"%s\" \n",
+                    regex,
+                    expected.c_str(),
+                    str);
+  string captured("");
+  if (full)
+    RE(regex,options).FullMatch(str, &captured);
+  else
+    RE(regex,options).PartialMatch(str, &captured);
+  CHECK_EQ(captured, expected);
+}
+
+static void TestOneOption(
+                const char *option_name,
+                const char *regex,
+                const char *str,
+                RE_Options options,
+                bool full,
+                bool assertive = true) {
+
+  printf("Testing Option <%s>\n", option_name);
+  if (VERBOSE_TEST)
+    printf("'%s' %s /%s/ \n",
+                  str,
+                  (assertive? "matches" : "doesn't match"),
+                  regex);
+  if (assertive) {
+    if (full)
+      CHECK(RE(regex,options).FullMatch(str));
+    else
+      CHECK(RE(regex,options).PartialMatch(str));
+  } else {
+    if (full)
+      CHECK(!RE(regex,options).FullMatch(str));
+    else
+      CHECK(!RE(regex,options).PartialMatch(str));
+  }
+}
+
+static void Test_CASELESS() {
+  RE_Options options;
+  RE_Options options2;
+
+  options.set_caseless(true);
+  TestOneOption("CASELESS (class)",  "HELLO",    "hello", options, false);
+  TestOneOption("CASELESS (class2)", "HELLO",    "hello", options2.set_caseless(true), false);
+  TestOneOption("CASELESS (class)",  "^[A-Z]+$", "Hello", options, false);
+
+  TestOneOption("CASELESS (function)", "HELLO",    "hello", pcrecpp::CASELESS(), false);
+  TestOneOption("CASELESS (function)", "^[A-Z]+$", "Hello", pcrecpp::CASELESS(), false);
+  options.set_caseless(false);
+  TestOneOption("no CASELESS", "HELLO",    "hello", options, false, false);
+}
+
+static void Test_MULTILINE() {
+  RE_Options options;
+  RE_Options options2;
+  const char *str = "HELLO\n" "cruel\n" "world\n";
+
+  options.set_multiline(true);
+  TestOneOption("MULTILINE (class)",    "^cruel$", str, options, false);
+  TestOneOption("MULTILINE (class2)",   "^cruel$", str, options2.set_multiline(true), false);
+  TestOneOption("MULTILINE (function)", "^cruel$", str, pcrecpp::MULTILINE(), false);
+  options.set_multiline(false);
+  TestOneOption("no MULTILINE", "^cruel$", str, options, false, false);
+}
+
+static void Test_DOTALL() {
+  RE_Options options;
+  RE_Options options2;
+  const char *str = "HELLO\n" "cruel\n" "world";
+
+  options.set_dotall(true);
+  TestOneOption("DOTALL (class)",    "HELLO.*world", str, options, true);
+  TestOneOption("DOTALL (class2)",   "HELLO.*world", str, options2.set_dotall(true), true);
+  TestOneOption("DOTALL (function)",    "HELLO.*world", str, pcrecpp::DOTALL(), true);
+  options.set_dotall(false);
+  TestOneOption("no DOTALL", "HELLO.*world", str, options, true, false);
+}
+
+static void Test_DOLLAR_ENDONLY() {
+  RE_Options options;
+  RE_Options options2;
+  const char *str = "HELLO world\n";
+
+  TestOneOption("no DOLLAR_ENDONLY", "world$", str, options, false);
+  options.set_dollar_endonly(true);
+  TestOneOption("DOLLAR_ENDONLY 1",    "world$", str, options, false, false);
+  TestOneOption("DOLLAR_ENDONLY 2",    "world$", str, options2.set_dollar_endonly(true), false, false);
+}
+
+static void Test_EXTRA() {
+  RE_Options options;
+  const char *str = "HELLO";
+
+  options.set_extra(true);
+  TestOneOption("EXTRA 1", "\\HELL\\O", str, options, true, false );
+  TestOneOption("EXTRA 2", "\\HELL\\O", str, RE_Options().set_extra(true), true, false );
+  options.set_extra(false);
+  TestOneOption("no EXTRA", "\\HELL\\O", str, options, true );
+}
+
+static void Test_EXTENDED() {
+  RE_Options options;
+  RE_Options options2;
+  const char *str = "HELLO world";
+
+  options.set_extended(true);
+  TestOneOption("EXTENDED (class)",    "HELLO world", str, options, false, false);
+  TestOneOption("EXTENDED (class2)",   "HELLO world", str, options2.set_extended(true), false, false);
+  TestOneOption("EXTENDED (class)",
+                    "^ HE L{2} O "
+                    "\\s+        "
+                    "\\w+ $      ",
+                    str,
+                    options,
+                    false);
+
+  TestOneOption("EXTENDED (function)",    "HELLO world", str, pcrecpp::EXTENDED(), false, false);
+  TestOneOption("EXTENDED (function)",
+                    "^ HE L{2} O "
+                    "\\s+        "
+                    "\\w+ $      ",
+                    str,
+                    pcrecpp::EXTENDED(),
+                    false);
+
+  options.set_extended(false);
+  TestOneOption("no EXTENDED", "HELLO world", str, options, false);
+}
+
+static void Test_NO_AUTO_CAPTURE() {
+  RE_Options options;
+  const char *str = "HELLO world";
+  string captured;
+
+  printf("Testing Option <no NO_AUTO_CAPTURE>\n");
+  if (VERBOSE_TEST)
+    printf("parentheses capture text\n");
+  RE re("(world|universe)$", options);
+  CHECK(re.Extract("\\1", str , &captured));
+  CHECK_EQ(captured, "world");
+  options.set_no_auto_capture(true);
+  printf("testing Option <NO_AUTO_CAPTURE>\n");
+  if (VERBOSE_TEST)
+    printf("parentheses do not capture text\n");
+  re.Extract("\\1",str, &captured );
+  CHECK_EQ(captured, "world");
+}
+
+static void Test_UNGREEDY() {
+  RE_Options options;
+  const char *str = "HELLO, 'this' is the 'world'";
+
+  options.set_ungreedy(true);
+  GetOneOptionResult("UNGREEDY 1", "('.*')", str, options, false, "'this'" );
+  GetOneOptionResult("UNGREEDY 2", "('.*')", str, RE_Options().set_ungreedy(true), false, "'this'" );
+  GetOneOptionResult("UNGREEDY", "('.*?')", str, options, false, "'this' is the 'world'" );
+
+  options.set_ungreedy(false);
+  GetOneOptionResult("no UNGREEDY", "('.*')", str, options, false, "'this' is the 'world'" );
+  GetOneOptionResult("no UNGREEDY", "('.*?')", str, options, false, "'this'" );
+}
+
+static void Test_all_options() {
+  const char *str = "HELLO\n" "cruel\n" "world";
+  RE_Options options;
+  options.set_all_options(PCRE_CASELESS | PCRE_DOTALL);
+
+  TestOneOption("all_options (CASELESS|DOTALL)", "^hello.*WORLD", str , options, false);
+  options.set_all_options(0);
+  TestOneOption("all_options (0)", "^hello.*WORLD", str , options, false, false);
+  options.set_all_options(PCRE_MULTILINE | PCRE_EXTENDED);
+
+  TestOneOption("all_options (MULTILINE|EXTENDED)", " ^ c r u e l $ ", str, options, false);
+  TestOneOption("all_options (MULTILINE|EXTENDED) with constructor",
+                  " ^ c r u e l $ ",
+                  str,
+                  RE_Options(PCRE_MULTILINE | PCRE_EXTENDED),
+                  false);
+
+  TestOneOption("all_options (MULTILINE|EXTENDED) with concatenation",
+                  " ^ c r u e l $ ",
+                  str,
+                  RE_Options()
+                       .set_multiline(true)
+                       .set_extended(true),
+                  false);
+
+  options.set_all_options(0);
+  TestOneOption("all_options (0)", "^ c r u e l $", str, options, false, false);
+
+}
+
+static void TestOptions() {
+  printf("Testing Options\n");
+  Test_CASELESS();
+  Test_MULTILINE();
+  Test_DOTALL();
+  Test_DOLLAR_ENDONLY();
+  Test_EXTENDED();
+  Test_NO_AUTO_CAPTURE();
+  Test_UNGREEDY();
+  Test_EXTRA();
+  Test_all_options();
+}
+
+static void TestConstructors() {
+  printf("Testing constructors\n");
+
+  RE_Options options;
+  options.set_dotall(true);
+  const char *str = "HELLO\n" "cruel\n" "world";
+
+  RE orig("HELLO.*world", options);
+  CHECK(orig.FullMatch(str));
+
+  RE copy1(orig);
+  CHECK(copy1.FullMatch(str));
+
+  RE copy2("not a match");
+  CHECK(!copy2.FullMatch(str));
+  copy2 = copy1;
+  CHECK(copy2.FullMatch(str));
+  copy2 = orig;
+  CHECK(copy2.FullMatch(str));
+
+  // Make sure when we assign to ourselves, nothing bad happens
+  orig = orig;
+  copy1 = copy1;
+  copy2 = copy2;
+  CHECK(orig.FullMatch(str));
+  CHECK(copy1.FullMatch(str));
+  CHECK(copy2.FullMatch(str));
+}
+
+int main(int argc, char** argv) {
+  // Treat any flag as --help
+  if (argc > 1 && argv[1][0] == '-') {
+    printf("Usage: %s [timing1|timing2|timing3 num-iters]\n"
+           "       If 'timingX ###' is specified, run the given timing test\n"
+           "       with the given number of iterations, rather than running\n"
+           "       the default corectness test.\n", argv[0]);
+    return 0;
+  }
+
+  if (argc > 1) {
+    if ( argc == 2 || atoi(argv[2]) == 0) {
+      printf("timing mode needs a num-iters argument\n");
+      return 1;
+    }
+    if (!strcmp(argv[1], "timing1"))
+      Timing1(atoi(argv[2]));
+    else if (!strcmp(argv[1], "timing2"))
+      Timing2(atoi(argv[2]));
+    else if (!strcmp(argv[1], "timing3"))
+      Timing3(atoi(argv[2]));
+    else
+      printf("Unknown argument '%s'\n", argv[1]);
+    return 0;
+  }
+
+  printf("Testing FullMatch\n");
+
+  int i;
+  string s;
+
+  /***** FullMatch with no args *****/
+
+  CHECK(RE("h.*o").FullMatch("hello"));
+  CHECK(!RE("h.*o").FullMatch("othello"));     // Must be anchored at front
+  CHECK(!RE("h.*o").FullMatch("hello!"));      // Must be anchored at end
+  CHECK(RE("a*").FullMatch("aaaa"));           // Fullmatch with normal op
+  CHECK(RE("a*?").FullMatch("aaaa"));          // Fullmatch with nongreedy op
+  CHECK(RE("a*?\\z").FullMatch("aaaa"));       // Two unusual ops
+
+  /***** FullMatch with args *****/
+
+  // Zero-arg
+  CHECK(RE("\\d+").FullMatch("1001"));
+
+  // Single-arg
+  CHECK(RE("(\\d+)").FullMatch("1001",   &i));
+  CHECK_EQ(i, 1001);
+  CHECK(RE("(-?\\d+)").FullMatch("-123", &i));
+  CHECK_EQ(i, -123);
+  CHECK(!RE("()\\d+").FullMatch("10", &i));
+  CHECK(!RE("(\\d+)").FullMatch("1234567890123456789012345678901234567890",
+                                &i));
+
+  // Digits surrounding integer-arg
+  CHECK(RE("1(\\d*)4").FullMatch("1234", &i));
+  CHECK_EQ(i, 23);
+  CHECK(RE("(\\d)\\d+").FullMatch("1234", &i));
+  CHECK_EQ(i, 1);
+  CHECK(RE("(-\\d)\\d+").FullMatch("-1234", &i));
+  CHECK_EQ(i, -1);
+  CHECK(RE("(\\d)").PartialMatch("1234", &i));
+  CHECK_EQ(i, 1);
+  CHECK(RE("(-\\d)").PartialMatch("-1234", &i));
+  CHECK_EQ(i, -1);
+
+  // String-arg
+  CHECK(RE("h(.*)o").FullMatch("hello", &s));
+  CHECK_EQ(s, string("ell"));
+
+  // StringPiece-arg
+  StringPiece sp;
+  CHECK(RE("(\\w+):(\\d+)").FullMatch("ruby:1234", &sp, &i));
+  CHECK_EQ(sp.size(), 4);
+  CHECK(memcmp(sp.data(), "ruby", 4) == 0);
+  CHECK_EQ(i, 1234);
+
+  // Multi-arg
+  CHECK(RE("(\\w+):(\\d+)").FullMatch("ruby:1234", &s, &i));
+  CHECK_EQ(s, string("ruby"));
+  CHECK_EQ(i, 1234);
+
+  // Ignore non-void* NULL arg
+  CHECK(RE("he(.*)lo").FullMatch("hello", (char*)NULL));
+  CHECK(RE("h(.*)o").FullMatch("hello", (string*)NULL));
+  CHECK(RE("h(.*)o").FullMatch("hello", (StringPiece*)NULL));
+  CHECK(RE("(.*)").FullMatch("1234", (int*)NULL));
+#ifdef HAVE_LONG_LONG
+  CHECK(RE("(.*)").FullMatch("1234567890123456", (long long*)NULL));
+#endif
+  CHECK(RE("(.*)").FullMatch("123.4567890123456", (double*)NULL));
+  CHECK(RE("(.*)").FullMatch("123.4567890123456", (float*)NULL));
+
+  // Fail on non-void* NULL arg if the match doesn't parse for the given type.
+  CHECK(!RE("h(.*)lo").FullMatch("hello", &s, (char*)NULL));
+  CHECK(!RE("(.*)").FullMatch("hello", (int*)NULL));
+  CHECK(!RE("(.*)").FullMatch("1234567890123456", (int*)NULL));
+  CHECK(!RE("(.*)").FullMatch("hello", (double*)NULL));
+  CHECK(!RE("(.*)").FullMatch("hello", (float*)NULL));
+
+  // Ignored arg
+  CHECK(RE("(\\w+)(:)(\\d+)").FullMatch("ruby:1234", &s, (void*)NULL, &i));
+  CHECK_EQ(s, string("ruby"));
+  CHECK_EQ(i, 1234);
+
+  // Type tests
+  {
+    char c;
+    CHECK(RE("(H)ello").FullMatch("Hello", &c));
+    CHECK_EQ(c, 'H');
+  }
+  {
+    unsigned char c;
+    CHECK(RE("(H)ello").FullMatch("Hello", &c));
+    CHECK_EQ(c, static_cast<unsigned char>('H'));
+  }
+  {
+    short v;
+    CHECK(RE("(-?\\d+)").FullMatch("100",     &v));    CHECK_EQ(v, 100);
+    CHECK(RE("(-?\\d+)").FullMatch("-100",    &v));    CHECK_EQ(v, -100);
+    CHECK(RE("(-?\\d+)").FullMatch("32767",   &v));    CHECK_EQ(v, 32767);
+    CHECK(RE("(-?\\d+)").FullMatch("-32768",  &v));    CHECK_EQ(v, -32768);
+    CHECK(!RE("(-?\\d+)").FullMatch("-32769", &v));
+    CHECK(!RE("(-?\\d+)").FullMatch("32768",  &v));
+  }
+  {
+    unsigned short v;
+    CHECK(RE("(\\d+)").FullMatch("100",     &v));    CHECK_EQ(v, 100);
+    CHECK(RE("(\\d+)").FullMatch("32767",   &v));    CHECK_EQ(v, 32767);
+    CHECK(RE("(\\d+)").FullMatch("65535",   &v));    CHECK_EQ(v, 65535);
+    CHECK(!RE("(\\d+)").FullMatch("65536",  &v));
+  }
+  {
+    int v;
+    static const int max_value = 0x7fffffff;
+    static const int min_value = -max_value - 1;
+    CHECK(RE("(-?\\d+)").FullMatch("100",         &v)); CHECK_EQ(v, 100);
+    CHECK(RE("(-?\\d+)").FullMatch("-100",        &v)); CHECK_EQ(v, -100);
+    CHECK(RE("(-?\\d+)").FullMatch("2147483647",  &v)); CHECK_EQ(v, max_value);
+    CHECK(RE("(-?\\d+)").FullMatch("-2147483648", &v)); CHECK_EQ(v, min_value);
+    CHECK(!RE("(-?\\d+)").FullMatch("-2147483649", &v));
+    CHECK(!RE("(-?\\d+)").FullMatch("2147483648",  &v));
+  }
+  {
+    unsigned int v;
+    static const unsigned int max_value = 0xfffffffful;
+    CHECK(RE("(\\d+)").FullMatch("100",         &v)); CHECK_EQ(v, 100);
+    CHECK(RE("(\\d+)").FullMatch("4294967295",  &v)); CHECK_EQ(v, max_value);
+    CHECK(!RE("(\\d+)").FullMatch("4294967296", &v));
+  }
+#ifdef HAVE_LONG_LONG
+# if defined(__MINGW__) || defined(__MINGW32__)
+#   define LLD "%I64d"
+#   define LLU "%I64u"
+# else
+#   define LLD "%lld"
+#   define LLU "%llu"
+# endif
+  {
+    long long v;
+    static const long long max_value = 0x7fffffffffffffffLL;
+    static const long long min_value = -max_value - 1;
+    char buf[32];  // definitely big enough for a long long
+
+    CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
+    CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100);
+
+    sprintf(buf, LLD, max_value);
+    CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
+
+    sprintf(buf, LLD, min_value);
+    CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value);
+
+    sprintf(buf, LLD, max_value);
+    assert(buf[strlen(buf)-1] != '9');
+    buf[strlen(buf)-1]++;
+    CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
+
+    sprintf(buf, LLD, min_value);
+    assert(buf[strlen(buf)-1] != '9');
+    buf[strlen(buf)-1]++;
+    CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
+  }
+#endif
+#if defined HAVE_UNSIGNED_LONG_LONG && defined HAVE_LONG_LONG
+  {
+    unsigned long long v;
+    long long v2;
+    static const unsigned long long max_value = 0xffffffffffffffffULL;
+    char buf[32];  // definitely big enough for a unsigned long long
+
+    CHECK(RE("(-?\\d+)").FullMatch("100",&v)); CHECK_EQ(v, 100);
+    CHECK(RE("(-?\\d+)").FullMatch("-100",&v2)); CHECK_EQ(v2, -100);
+
+    sprintf(buf, LLU, max_value);
+    CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
+
+    assert(buf[strlen(buf)-1] != '9');
+    buf[strlen(buf)-1]++;
+    CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
+  }
+#endif
+  {
+    float v;
+    CHECK(RE("(.*)").FullMatch("100", &v));
+    CHECK(RE("(.*)").FullMatch("-100.", &v));
+    CHECK(RE("(.*)").FullMatch("1e23", &v));
+  }
+  {
+    double v;
+    CHECK(RE("(.*)").FullMatch("100", &v));
+    CHECK(RE("(.*)").FullMatch("-100.", &v));
+    CHECK(RE("(.*)").FullMatch("1e23", &v));
+  }
+
+  // Check that matching is fully anchored
+  CHECK(!RE("(\\d+)").FullMatch("x1001",  &i));
+  CHECK(!RE("(\\d+)").FullMatch("1001x",  &i));
+  CHECK(RE("x(\\d+)").FullMatch("x1001", &i)); CHECK_EQ(i, 1001);
+  CHECK(RE("(\\d+)x").FullMatch("1001x", &i)); CHECK_EQ(i, 1001);
+
+  // Braces
+  CHECK(RE("[0-9a-f+.-]{5,}").FullMatch("0abcd"));
+  CHECK(RE("[0-9a-f+.-]{5,}").FullMatch("0abcde"));
+  CHECK(!RE("[0-9a-f+.-]{5,}").FullMatch("0abc"));
+
+  // Complicated RE
+  CHECK(RE("foo|bar|[A-Z]").FullMatch("foo"));
+  CHECK(RE("foo|bar|[A-Z]").FullMatch("bar"));
+  CHECK(RE("foo|bar|[A-Z]").FullMatch("X"));
+  CHECK(!RE("foo|bar|[A-Z]").FullMatch("XY"));
+
+  // Check full-match handling (needs '$' tacked on internally)
+  CHECK(RE("fo|foo").FullMatch("fo"));
+  CHECK(RE("fo|foo").FullMatch("foo"));
+  CHECK(RE("fo|foo$").FullMatch("fo"));
+  CHECK(RE("fo|foo$").FullMatch("foo"));
+  CHECK(RE("foo$").FullMatch("foo"));
+  CHECK(!RE("foo\\$").FullMatch("foo$bar"));
+  CHECK(!RE("fo|bar").FullMatch("fox"));
+
+  // Uncomment the following if we change the handling of '$' to
+  // prevent it from matching a trailing newline
+  if (false) {
+    // Check that we don't get bitten by pcre's special handling of a
+    // '\n' at the end of the string matching '$'
+    CHECK(!RE("foo$").PartialMatch("foo\n"));
+  }
+
+  // Number of args
+  int a[16];
+  CHECK(RE("").FullMatch(""));
+
+  memset(a, 0, sizeof(0));
+  CHECK(RE("(\\d){1}").FullMatch("1",
+                                 &a[0]));
+  CHECK_EQ(a[0], 1);
+
+  memset(a, 0, sizeof(0));
+  CHECK(RE("(\\d)(\\d)").FullMatch("12",
+                                   &a[0],  &a[1]));
+  CHECK_EQ(a[0], 1);
+  CHECK_EQ(a[1], 2);
+
+  memset(a, 0, sizeof(0));
+  CHECK(RE("(\\d)(\\d)(\\d)").FullMatch("123",
+                                        &a[0],  &a[1],  &a[2]));
+  CHECK_EQ(a[0], 1);
+  CHECK_EQ(a[1], 2);
+  CHECK_EQ(a[2], 3);
+
+  memset(a, 0, sizeof(0));
+  CHECK(RE("(\\d)(\\d)(\\d)(\\d)").FullMatch("1234",
+                                             &a[0],  &a[1],  &a[2],  &a[3]));
+  CHECK_EQ(a[0], 1);
+  CHECK_EQ(a[1], 2);
+  CHECK_EQ(a[2], 3);
+  CHECK_EQ(a[3], 4);
+
+  memset(a, 0, sizeof(0));
+  CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("12345",
+                                                  &a[0],  &a[1],  &a[2],
+                                                  &a[3],  &a[4]));
+  CHECK_EQ(a[0], 1);
+  CHECK_EQ(a[1], 2);
+  CHECK_EQ(a[2], 3);
+  CHECK_EQ(a[3], 4);
+  CHECK_EQ(a[4], 5);
+
+  memset(a, 0, sizeof(0));
+  CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("123456",
+                                                       &a[0],  &a[1],  &a[2],
+                                                       &a[3],  &a[4],  &a[5]));
+  CHECK_EQ(a[0], 1);
+  CHECK_EQ(a[1], 2);
+  CHECK_EQ(a[2], 3);
+  CHECK_EQ(a[3], 4);
+  CHECK_EQ(a[4], 5);
+  CHECK_EQ(a[5], 6);
+
+  memset(a, 0, sizeof(0));
+  CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("1234567",
+                                                            &a[0],  &a[1],  &a[2],  &a[3],
+                                                            &a[4],  &a[5],  &a[6]));
+  CHECK_EQ(a[0], 1);
+  CHECK_EQ(a[1], 2);
+  CHECK_EQ(a[2], 3);
+  CHECK_EQ(a[3], 4);
+  CHECK_EQ(a[4], 5);
+  CHECK_EQ(a[5], 6);
+  CHECK_EQ(a[6], 7);
+
+  memset(a, 0, sizeof(0));
+  CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)"
+           "(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch(
+               "1234567890123456",
+               &a[0],  &a[1],  &a[2],  &a[3],
+               &a[4],  &a[5],  &a[6],  &a[7],
+               &a[8],  &a[9],  &a[10], &a[11],
+               &a[12], &a[13], &a[14], &a[15]));
+  CHECK_EQ(a[0], 1);
+  CHECK_EQ(a[1], 2);
+  CHECK_EQ(a[2], 3);
+  CHECK_EQ(a[3], 4);
+  CHECK_EQ(a[4], 5);
+  CHECK_EQ(a[5], 6);
+  CHECK_EQ(a[6], 7);
+  CHECK_EQ(a[7], 8);
+  CHECK_EQ(a[8], 9);
+  CHECK_EQ(a[9], 0);
+  CHECK_EQ(a[10], 1);
+  CHECK_EQ(a[11], 2);
+  CHECK_EQ(a[12], 3);
+  CHECK_EQ(a[13], 4);
+  CHECK_EQ(a[14], 5);
+  CHECK_EQ(a[15], 6);
+
+  /***** PartialMatch *****/
+
+  printf("Testing PartialMatch\n");
+
+  CHECK(RE("h.*o").PartialMatch("hello"));
+  CHECK(RE("h.*o").PartialMatch("othello"));
+  CHECK(RE("h.*o").PartialMatch("hello!"));
+  CHECK(RE("((((((((((((((((((((x))))))))))))))))))))").PartialMatch("x"));
+
+  /***** other tests *****/
+
+  RadixTests();
+  TestReplace();
+  TestExtract();
+  TestConsume();
+  TestFindAndConsume();
+  TestQuoteMetaAll();
+  TestMatchNumberPeculiarity();
+
+  // Check the pattern() accessor
+  {
+    const string kPattern = "http://([^/]+)/.*";
+    const RE re(kPattern);
+    CHECK_EQ(kPattern, re.pattern());
+  }
+
+  // Check RE error field.
+  {
+    RE re("foo");
+    CHECK(re.error().empty());  // Must have no error
+  }
+
+#ifdef SUPPORT_UTF8
+  // Check UTF-8 handling
+  {
+    printf("Testing UTF-8 handling\n");
+
+    // Three Japanese characters (nihongo)
+    const unsigned char utf8_string[] = {
+         0xe6, 0x97, 0xa5, // 65e5
+         0xe6, 0x9c, 0xac, // 627c
+         0xe8, 0xaa, 0x9e, // 8a9e
+         0
+    };
+    const unsigned char utf8_pattern[] = {
+         '.',
+         0xe6, 0x9c, 0xac, // 627c
+         '.',
+         0
+    };
+
+    // Both should match in either mode, bytes or UTF-8
+    RE re_test1(".........");
+    CHECK(re_test1.FullMatch(utf8_string));
+    RE re_test2("...", pcrecpp::UTF8());
+    CHECK(re_test2.FullMatch(utf8_string));
+
+    // Check that '.' matches one byte or UTF-8 character
+    // according to the mode.
+    string ss;
+    RE re_test3("(.)");
+    CHECK(re_test3.PartialMatch(utf8_string, &ss));
+    CHECK_EQ(ss, string("\xe6"));
+    RE re_test4("(.)", pcrecpp::UTF8());
+    CHECK(re_test4.PartialMatch(utf8_string, &ss));
+    CHECK_EQ(ss, string("\xe6\x97\xa5"));
+
+    // Check that string matches itself in either mode
+    RE re_test5(utf8_string);
+    CHECK(re_test5.FullMatch(utf8_string));
+    RE re_test6(utf8_string, pcrecpp::UTF8());
+    CHECK(re_test6.FullMatch(utf8_string));
+
+    // Check that pattern matches string only in UTF8 mode
+    RE re_test7(utf8_pattern);
+    CHECK(!re_test7.FullMatch(utf8_string));
+    RE re_test8(utf8_pattern, pcrecpp::UTF8());
+    CHECK(re_test8.FullMatch(utf8_string));
+  }
+
+  // Check that ungreedy, UTF8 regular expressions don't match when they
+  // oughtn't -- see bug 82246.
+  {
+    // This code always worked.
+    const char* pattern = "\\w+X";
+    const string target = "a aX";
+    RE match_sentence(pattern);
+    RE match_sentence_re(pattern, pcrecpp::UTF8());
+
+    CHECK(!match_sentence.FullMatch(target));
+    CHECK(!match_sentence_re.FullMatch(target));
+  }
+
+  {
+    const char* pattern = "(?U)\\w+X";
+    const string target = "a aX";
+    RE match_sentence(pattern);
+    RE match_sentence_re(pattern, pcrecpp::UTF8());
+
+    CHECK(!match_sentence.FullMatch(target));
+    CHECK(!match_sentence_re.FullMatch(target));
+  }
+#endif  /* def SUPPORT_UTF8 */
+
+  printf("Testing error reporting\n");
+
+  { RE re("a\\1"); CHECK(!re.error().empty()); }
+  {
+    RE re("a[x");
+    CHECK(!re.error().empty());
+  }
+  {
+    RE re("a[z-a]");
+    CHECK(!re.error().empty());
+  }
+  {
+    RE re("a[[:foobar:]]");
+    CHECK(!re.error().empty());
+  }
+  {
+    RE re("a(b");
+    CHECK(!re.error().empty());
+  }
+  {
+    RE re("a\\");
+    CHECK(!re.error().empty());
+  }
+
+  // Test that recursion is stopped
+  TestRecursion();
+
+  // Test Options
+  if (getenv("VERBOSE_TEST") != NULL)
+    VERBOSE_TEST  = true;
+  TestOptions();
+
+  // Test the constructors
+  TestConstructors();
+
+  // Done
+  printf("OK\n");
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcrecpparg.h.in	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,174 @@
+// Copyright (c) 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+
+#ifndef _PCRECPPARG_H
+#define _PCRECPPARG_H
+
+#include <stdlib.h>    // for NULL
+#include <string>
+
+#include <pcre.h>
+
+namespace pcrecpp {
+
+class StringPiece;
+
+// Hex/Octal/Binary?
+
+// Special class for parsing into objects that define a ParseFrom() method
+template <class T>
+class _RE_MatchObject {
+ public:
+  static inline bool Parse(const char* str, int n, void* dest) {
+    if (dest == NULL) return true;
+    T* object = reinterpret_cast<T*>(dest);
+    return object->ParseFrom(str, n);
+  }
+};
+
+class PCRECPP_EXP_DEFN Arg {
+ public:
+  // Empty constructor so we can declare arrays of Arg
+  Arg();
+
+  // Constructor specially designed for NULL arguments
+  Arg(void*);
+
+  typedef bool (*Parser)(const char* str, int n, void* dest);
+
+// Type-specific parsers
+#define PCRE_MAKE_PARSER(type,name)                             \
+  Arg(type* p) : arg_(p), parser_(name) { }                     \
+  Arg(type* p, Parser parser) : arg_(p), parser_(parser) { }
+
+
+  PCRE_MAKE_PARSER(char,               parse_char);
+  PCRE_MAKE_PARSER(unsigned char,      parse_uchar);
+  PCRE_MAKE_PARSER(short,              parse_short);
+  PCRE_MAKE_PARSER(unsigned short,     parse_ushort);
+  PCRE_MAKE_PARSER(int,                parse_int);
+  PCRE_MAKE_PARSER(unsigned int,       parse_uint);
+  PCRE_MAKE_PARSER(long,               parse_long);
+  PCRE_MAKE_PARSER(unsigned long,      parse_ulong);
+#if @pcre_have_long_long@
+  PCRE_MAKE_PARSER(long long,          parse_longlong);
+#endif
+#if @pcre_have_ulong_long@
+  PCRE_MAKE_PARSER(unsigned long long, parse_ulonglong);
+#endif
+  PCRE_MAKE_PARSER(float,              parse_float);
+  PCRE_MAKE_PARSER(double,             parse_double);
+  PCRE_MAKE_PARSER(std::string,        parse_string);
+  PCRE_MAKE_PARSER(StringPiece,        parse_stringpiece);
+
+#undef PCRE_MAKE_PARSER
+
+  // Generic constructor
+  template <class T> Arg(T*, Parser parser);
+  // Generic constructor template
+  template <class T> Arg(T* p)
+    : arg_(p), parser_(_RE_MatchObject<T>::Parse) {
+  }
+
+  // Parse the data
+  bool Parse(const char* str, int n) const;
+
+ private:
+  void*         arg_;
+  Parser        parser_;
+
+  static bool parse_null          (const char* str, int n, void* dest);
+  static bool parse_char          (const char* str, int n, void* dest);
+  static bool parse_uchar         (const char* str, int n, void* dest);
+  static bool parse_float         (const char* str, int n, void* dest);
+  static bool parse_double        (const char* str, int n, void* dest);
+  static bool parse_string        (const char* str, int n, void* dest);
+  static bool parse_stringpiece   (const char* str, int n, void* dest);
+
+#define PCRE_DECLARE_INTEGER_PARSER(name)                                   \
+ private:                                                                   \
+  static bool parse_ ## name(const char* str, int n, void* dest);           \
+  static bool parse_ ## name ## _radix(                                     \
+    const char* str, int n, void* dest, int radix);                         \
+ public:                                                                    \
+  static bool parse_ ## name ## _hex(const char* str, int n, void* dest);   \
+  static bool parse_ ## name ## _octal(const char* str, int n, void* dest); \
+  static bool parse_ ## name ## _cradix(const char* str, int n, void* dest)
+
+  PCRE_DECLARE_INTEGER_PARSER(short);
+  PCRE_DECLARE_INTEGER_PARSER(ushort);
+  PCRE_DECLARE_INTEGER_PARSER(int);
+  PCRE_DECLARE_INTEGER_PARSER(uint);
+  PCRE_DECLARE_INTEGER_PARSER(long);
+  PCRE_DECLARE_INTEGER_PARSER(ulong);
+  PCRE_DECLARE_INTEGER_PARSER(longlong);
+  PCRE_DECLARE_INTEGER_PARSER(ulonglong);
+
+#undef PCRE_DECLARE_INTEGER_PARSER
+};
+
+inline Arg::Arg() : arg_(NULL), parser_(parse_null) { }
+inline Arg::Arg(void* p) : arg_(p), parser_(parse_null) { }
+
+inline bool Arg::Parse(const char* str, int n) const {
+  return (*parser_)(str, n, arg_);
+}
+
+// This part of the parser, appropriate only for ints, deals with bases
+#define MAKE_INTEGER_PARSER(type, name) \
+  inline Arg Hex(type* ptr) { \
+    return Arg(ptr, Arg::parse_ ## name ## _hex); } \
+  inline Arg Octal(type* ptr) { \
+    return Arg(ptr, Arg::parse_ ## name ## _octal); } \
+  inline Arg CRadix(type* ptr) { \
+    return Arg(ptr, Arg::parse_ ## name ## _cradix); }
+
+MAKE_INTEGER_PARSER(short,              short)     /*                        */
+MAKE_INTEGER_PARSER(unsigned short,     ushort)    /*                        */
+MAKE_INTEGER_PARSER(int,                int)       /* Don't use semicolons   */
+MAKE_INTEGER_PARSER(unsigned int,       uint)      /* after these statement  */
+MAKE_INTEGER_PARSER(long,               long)      /* because they can cause */
+MAKE_INTEGER_PARSER(unsigned long,      ulong)     /* compiler warnings if   */
+#if @pcre_have_long_long@                          /* the checking level is  */
+MAKE_INTEGER_PARSER(long long,          longlong)  /* turned up high enough. */
+#endif                                             /*                        */
+#if @pcre_have_ulong_long@                         /*                        */
+MAKE_INTEGER_PARSER(unsigned long long, ulonglong) /*                        */
+#endif
+
+#undef PCRE_IS_SET
+#undef PCRE_SET_OR_CLEAR
+#undef MAKE_INTEGER_PARSER
+
+}   // namespace pcrecpp
+
+
+#endif /* _PCRECPPARG_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcredemo.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,334 @@
+/*************************************************
+*           PCRE DEMONSTRATION PROGRAM           *
+*************************************************/
+
+/* This is a demonstration program to illustrate the most straightforward ways
+of calling the PCRE regular expression library from a C program. See the
+pcresample documentation for a short discussion ("man pcresample" if you have
+the PCRE man pages installed).
+
+In Unix-like environments, compile this program thuswise:
+
+  gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib \
+    -R/usr/local/lib -lpcre
+
+Replace "/usr/local/include" and "/usr/local/lib" with wherever the include and
+library files for PCRE are installed on your system. You don't need -I and -L
+if PCRE is installed in the standard system libraries. Only some operating
+systems (e.g. Solaris) use the -R option.
+
+Building under Windows:
+
+If you want to statically link this program against a non-dll .a file, you must
+define PCRE_STATIC before including pcre.h, otherwise the pcre_malloc() and
+pcre_free() exported functions will be declared __declspec(dllimport), with
+unwanted results. So in this environment, uncomment the following line. */
+
+/* #define PCRE_STATIC */
+
+#include <stdio.h>
+#include <string.h>
+#include <pcre.h>
+
+#define OVECCOUNT 30    /* should be a multiple of 3 */
+
+
+int main(int argc, char **argv)
+{
+pcre *re;
+const char *error;
+char *pattern;
+char *subject;
+unsigned char *name_table;
+int erroffset;
+int find_all;
+int namecount;
+int name_entry_size;
+int ovector[OVECCOUNT];
+int subject_length;
+int rc, i;
+
+
+/**************************************************************************
+* First, sort out the command line. There is only one possible option at  *
+* the moment, "-g" to request repeated matching to find all occurrences,  *
+* like Perl's /g option. We set the variable find_all to a non-zero value *
+* if the -g option is present. Apart from that, there must be exactly two *
+* arguments.                                                              *
+**************************************************************************/
+
+find_all = 0;
+for (i = 1; i < argc; i++)
+  {
+  if (strcmp(argv[i], "-g") == 0) find_all = 1;
+    else break;
+  }
+
+/* After the options, we require exactly two arguments, which are the pattern,
+and the subject string. */
+
+if (argc - i != 2)
+  {
+  printf("Two arguments required: a regex and a subject string\n");
+  return 1;
+  }
+
+pattern = argv[i];
+subject = argv[i+1];
+subject_length = (int)strlen(subject);
+
+
+/*************************************************************************
+* Now we are going to compile the regular expression pattern, and handle *
+* and errors that are detected.                                          *
+*************************************************************************/
+
+re = pcre_compile(
+  pattern,              /* the pattern */
+  0,                    /* default options */
+  &error,               /* for error message */
+  &erroffset,           /* for error offset */
+  NULL);                /* use default character tables */
+
+/* Compilation failed: print the error message and exit */
+
+if (re == NULL)
+  {
+  printf("PCRE compilation failed at offset %d: %s\n", erroffset, error);
+  return 1;
+  }
+
+
+/*************************************************************************
+* If the compilation succeeded, we call PCRE again, in order to do a     *
+* pattern match against the subject string. This does just ONE match. If *
+* further matching is needed, it will be done below.                     *
+*************************************************************************/
+
+rc = pcre_exec(
+  re,                   /* the compiled pattern */
+  NULL,                 /* no extra data - we didn't study the pattern */
+  subject,              /* the subject string */
+  subject_length,       /* the length of the subject */
+  0,                    /* start at offset 0 in the subject */
+  0,                    /* default options */
+  ovector,              /* output vector for substring information */
+  OVECCOUNT);           /* number of elements in the output vector */
+
+/* Matching failed: handle error cases */
+
+if (rc < 0)
+  {
+  switch(rc)
+    {
+    case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
+    /*
+    Handle other special cases if you like
+    */
+    default: printf("Matching error %d\n", rc); break;
+    }
+  pcre_free(re);     /* Release memory used for the compiled pattern */
+  return 1;
+  }
+
+/* Match succeded */
+
+printf("\nMatch succeeded at offset %d\n", ovector[0]);
+
+
+/*************************************************************************
+* We have found the first match within the subject string. If the output *
+* vector wasn't big enough, say so. Then output any substrings that were *
+* captured.                                                              *
+*************************************************************************/
+
+/* The output vector wasn't big enough */
+
+if (rc == 0)
+  {
+  rc = OVECCOUNT/3;
+  printf("ovector only has room for %d captured substrings\n", rc - 1);
+  }
+
+/* Show substrings stored in the output vector by number. Obviously, in a real
+application you might want to do things other than print them. */
+
+for (i = 0; i < rc; i++)
+  {
+  char *substring_start = subject + ovector[2*i];
+  int substring_length = ovector[2*i+1] - ovector[2*i];
+  printf("%2d: %.*s\n", i, substring_length, substring_start);
+  }
+
+
+/**************************************************************************
+* That concludes the basic part of this demonstration program. We have    *
+* compiled a pattern, and performed a single match. The code that follows *
+* shows first how to access named substrings, and then how to code for    *
+* repeated matches on the same subject.                                   *
+**************************************************************************/
+
+/* See if there are any named substrings, and if so, show them by name. First
+we have to extract the count of named parentheses from the pattern. */
+
+(void)pcre_fullinfo(
+  re,                   /* the compiled pattern */
+  NULL,                 /* no extra data - we didn't study the pattern */
+  PCRE_INFO_NAMECOUNT,  /* number of named substrings */
+  &namecount);          /* where to put the answer */
+
+if (namecount <= 0) printf("No named substrings\n"); else
+  {
+  unsigned char *tabptr;
+  printf("Named substrings\n");
+
+  /* Before we can access the substrings, we must extract the table for
+  translating names to numbers, and the size of each entry in the table. */
+
+  (void)pcre_fullinfo(
+    re,                       /* the compiled pattern */
+    NULL,                     /* no extra data - we didn't study the pattern */
+    PCRE_INFO_NAMETABLE,      /* address of the table */
+    &name_table);             /* where to put the answer */
+
+  (void)pcre_fullinfo(
+    re,                       /* the compiled pattern */
+    NULL,                     /* no extra data - we didn't study the pattern */
+    PCRE_INFO_NAMEENTRYSIZE,  /* size of each entry in the table */
+    &name_entry_size);        /* where to put the answer */
+
+  /* Now we can scan the table and, for each entry, print the number, the name,
+  and the substring itself. */
+
+  tabptr = name_table;
+  for (i = 0; i < namecount; i++)
+    {
+    int n = (tabptr[0] << 8) | tabptr[1];
+    printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
+      ovector[2*n+1] - ovector[2*n], subject + ovector[2*n]);
+    tabptr += name_entry_size;
+    }
+  }
+
+
+/*************************************************************************
+* If the "-g" option was given on the command line, we want to continue  *
+* to search for additional matches in the subject string, in a similar   *
+* way to the /g option in Perl. This turns out to be trickier than you   *
+* might think because of the possibility of matching an empty string.    *
+* What happens is as follows:                                            *
+*                                                                        *
+* If the previous match was NOT for an empty string, we can just start   *
+* the next match at the end of the previous one.                         *
+*                                                                        *
+* If the previous match WAS for an empty string, we can't do that, as it *
+* would lead to an infinite loop. Instead, a special call of pcre_exec() *
+* is made with the PCRE_NOTEMPTY and PCRE_ANCHORED flags set. The first  *
+* of these tells PCRE that an empty string is not a valid match; other   *
+* possibilities must be tried. The second flag restricts PCRE to one     *
+* match attempt at the initial string position. If this match succeeds,  *
+* an alternative to the empty string match has been found, and we can    *
+* proceed round the loop.                                                *
+*************************************************************************/
+
+if (!find_all)
+  {
+  pcre_free(re);   /* Release the memory used for the compiled pattern */
+  return 0;        /* Finish unless -g was given */
+  }
+
+/* Loop for second and subsequent matches */
+
+for (;;)
+  {
+  int options = 0;                 /* Normally no options */
+  int start_offset = ovector[1];   /* Start at end of previous match */
+
+  /* If the previous match was for an empty string, we are finished if we are
+  at the end of the subject. Otherwise, arrange to run another match at the
+  same point to see if a non-empty match can be found. */
+
+  if (ovector[0] == ovector[1])
+    {
+    if (ovector[0] == subject_length) break;
+    options = PCRE_NOTEMPTY | PCRE_ANCHORED;
+    }
+
+  /* Run the next matching operation */
+
+  rc = pcre_exec(
+    re,                   /* the compiled pattern */
+    NULL,                 /* no extra data - we didn't study the pattern */
+    subject,              /* the subject string */
+    subject_length,       /* the length of the subject */
+    start_offset,         /* starting offset in the subject */
+    options,              /* options */
+    ovector,              /* output vector for substring information */
+    OVECCOUNT);           /* number of elements in the output vector */
+
+  /* This time, a result of NOMATCH isn't an error. If the value in "options"
+  is zero, it just means we have found all possible matches, so the loop ends.
+  Otherwise, it means we have failed to find a non-empty-string match at a
+  point where there was a previous empty-string match. In this case, we do what
+  Perl does: advance the matching position by one, and continue. We do this by
+  setting the "end of previous match" offset, because that is picked up at the
+  top of the loop as the point at which to start again. */
+
+  if (rc == PCRE_ERROR_NOMATCH)
+    {
+    if (options == 0) break;
+    ovector[1] = start_offset + 1;
+    continue;    /* Go round the loop again */
+    }
+
+  /* Other matching errors are not recoverable. */
+
+  if (rc < 0)
+    {
+    printf("Matching error %d\n", rc);
+    pcre_free(re);    /* Release memory used for the compiled pattern */
+    return 1;
+    }
+
+  /* Match succeded */
+
+  printf("\nMatch succeeded again at offset %d\n", ovector[0]);
+
+  /* The match succeeded, but the output vector wasn't big enough. */
+
+  if (rc == 0)
+    {
+    rc = OVECCOUNT/3;
+    printf("ovector only has room for %d captured substrings\n", rc - 1);
+    }
+
+  /* As before, show substrings stored in the output vector by number, and then
+  also any named substrings. */
+
+  for (i = 0; i < rc; i++)
+    {
+    char *substring_start = subject + ovector[2*i];
+    int substring_length = ovector[2*i+1] - ovector[2*i];
+    printf("%2d: %.*s\n", i, substring_length, substring_start);
+    }
+
+  if (namecount <= 0) printf("No named substrings\n"); else
+    {
+    unsigned char *tabptr = name_table;
+    printf("Named substrings\n");
+    for (i = 0; i < namecount; i++)
+      {
+      int n = (tabptr[0] << 8) | tabptr[1];
+      printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
+        ovector[2*n+1] - ovector[2*n], subject + ovector[2*n]);
+      tabptr += name_entry_size;
+      }
+    }
+  }      /* End of loop to find second and subsequent matches */
+
+printf("\n");
+pcre_free(re);       /* Release memory used for the compiled pattern */
+return 0;
+}
+
+/* End of pcredemo.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcregexp.pas	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,820 @@
+{
+  pcRegExp - Perl compatible regular expressions for Virtual Pascal
+  (c) 2001 Peter S. Voronov aka Chem O'Dun <petervrn@yahoo.com>
+
+  Based on PCRE library interface unit for Virtual Pascal.
+  (c) 2001 Alexander Tokarev <dwalin@dwalin.ru>
+
+  The current PCRE version is: 3.7
+
+  This software must be distributed as Freeware.
+
+  The PCRE library is written by: Philip Hazel <ph10@cam.ac.uk>
+  Copyright (c) 1997-2004 University of Cambridge
+
+  AngelsHolocaust 4-11-04 updated to use version v5.0
+  (INFO: this is regex-directed, NFA)
+  AH:  9-11-04 - pcre_free: removed var, pcre already gives the ptr, now
+			    everything works as it should (no more crashes)
+		 -> removed CheckRegExp because pcre handles errors perfectly
+      10-11-04 - added pcError (errorhandling), pcInit
+      13-11-04 - removed the ErrorPos = 0 check -> always print erroroffset
+      17-10-05 - support for \1-\9 backreferences in TpcRegExp.GetReplStr
+      17-02-06 - added RunTimeOptions: caller can set options while searching
+      19-02-06 - added SearchOfs(): let PCRE use the complete string and offset
+		 into the string itself
+      20-12-06 - support for version 7.0
+      27.08.08 - support for v7.7
+}
+
+{$H+} {$DEFINE PCRE_3_7} {$DEFINE PCRE_5_0} {$DEFINE PCRE_7_0} {$DEFINE PCRE_7_7}
+
+Unit pcregexp;
+
+Interface
+
+uses objects;
+
+Type
+ PpcRegExp = ^TpcRegExp;
+// TpcRegExp = object
+ TpcRegExp = object(TObject)
+  MatchesCount: integer;
+  RegExpC, RegExpExt : Pointer;
+  Matches:Pointer;
+  RegExp: shortstring;
+  SourceLen: integer;
+  PartialMatch : boolean;
+  Error : boolean;
+  ErrorMsg : Pchar;
+  ErrorPos : integer;
+  RunTimeOptions: Integer; // options which can be set by the caller
+  constructor Init(const ARegExp : shortstring; AOptions : integer; ALocale : Pointer);
+  function Search(AStr: Pchar; ALen : longint) : boolean; virtual;
+  function SearchNext( AStr: Pchar; ALen : longint) : boolean; virtual;
+  function SearchOfs ( AStr: Pchar; ALen, AOfs : longint) : boolean; virtual;
+  function MatchSub(ANom: integer; var Pos, Len : longint) : boolean; virtual;
+  function MatchFull(var Pos, Len : longint) : boolean; virtual;
+  function GetSubStr(ANom: integer; AStr: Pchar) : string; virtual;
+  function GetFullStr(AStr: Pchar) : string; virtual;
+  function GetReplStr(AStr: Pchar; const ARepl: string) : string; virtual;
+  function GetPreSubStr(AStr: Pchar) : string; virtual;
+  function GetPostSubStr(AStr: Pchar) : string; virtual;
+  function ErrorStr : string; virtual;
+  destructor Done; virtual;
+ end;
+
+ function pcGrepMatch(WildCard, aStr: string; AOptions:integer; ALocale : Pointer): Boolean;
+ function pcGrepSub(WildCard, aStr, aRepl: string; AOptions:integer; ALocale : Pointer): string;
+
+ function pcFastGrepMatch(WildCard, aStr: string): Boolean;
+ function pcFastGrepSub(WildCard, aStr, aRepl: string): string;
+
+{$IFDEF PCRE_5_0}
+ function pcGetVersion : pchar;
+{$ENDIF}
+
+ function pcError (var pRegExp : Pointer) : Boolean;
+ function pcInit  (const Pattern: Shortstring; CaseSens: Boolean) : Pointer;
+
+Const { Options }
+ PCRE_CASELESS         = $0001;
+ PCRE_MULTILINE        = $0002;
+ PCRE_DOTALL           = $0004;
+ PCRE_EXTENDED         = $0008;
+ PCRE_ANCHORED         = $0010;
+ PCRE_DOLLAR_ENDONLY   = $0020;
+ PCRE_EXTRA            = $0040;
+ PCRE_NOTBOL           = $0080;
+ PCRE_NOTEOL           = $0100;
+ PCRE_UNGREEDY         = $0200;
+ PCRE_NOTEMPTY         = $0400;
+{$IFDEF PCRE_5_0}
+ PCRE_UTF8             = $0800;
+ PCRE_NO_AUTO_CAPTURE  = $1000;
+ PCRE_NO_UTF8_CHECK    = $2000;
+ PCRE_AUTO_CALLOUT     = $4000;
+ PCRE_PARTIAL          = $8000;
+{$ENDIF}
+{$IFDEF PCRE_7_0}
+ PCRE_DFA_SHORTEST     = $00010000;
+ PCRE_DFA_RESTART      = $00020000;
+ PCRE_FIRSTLINE        = $00040000;
+ PCRE_DUPNAMES         = $00080000;
+ PCRE_NEWLINE_CR       = $00100000;
+ PCRE_NEWLINE_LF       = $00200000;
+ PCRE_NEWLINE_CRLF     = $00300000;
+ PCRE_NEWLINE_ANY      = $00400000;
+ PCRE_NEWLINE_ANYCRLF  = $00500000;
+
+ PCRE_NEWLINE_BITS     = PCRE_NEWLINE_CR or PCRE_NEWLINE_LF or PCRE_NEWLINE_ANY;
+
+{$ENDIF}
+{$IFDEF PCRE_7_7}
+ PCRE_BSR_ANYCRLF      = $00800000;
+ PCRE_BSR_UNICODE      = $01000000;
+ PCRE_JAVASCRIPT_COMPAT= $02000000;
+{$ENDIF}
+
+ PCRE_COMPILE_ALLOWED_OPTIONS = PCRE_ANCHORED + PCRE_AUTO_CALLOUT + PCRE_CASELESS  +
+				PCRE_DOLLAR_ENDONLY + PCRE_DOTALL + PCRE_EXTENDED  +
+				PCRE_EXTRA + PCRE_MULTILINE + PCRE_NO_AUTO_CAPTURE +
+				PCRE_UNGREEDY + PCRE_UTF8 + PCRE_NO_UTF8_CHECK
+				{$IFDEF PCRE_7_0}
+				+ PCRE_DUPNAMES + PCRE_FIRSTLINE + PCRE_NEWLINE_BITS
+				{$ENDIF}
+				{$IFDEF PCRE_7_7}
+				+ PCRE_BSR_ANYCRLF + PCRE_BSR_UNICODE + PCRE_JAVASCRIPT_COMPAT
+				{$ENDIF}
+				;
+
+ PCRE_EXEC_ALLOWED_OPTIONS = PCRE_ANCHORED + PCRE_NOTBOL + PCRE_NOTEOL +
+			     PCRE_NOTEMPTY + PCRE_NO_UTF8_CHECK + PCRE_PARTIAL
+			     {$IFDEF PCRE_7_0}
+			     + PCRE_NEWLINE_BITS
+			     {$ENDIF}
+			     {$IFDEF PCRE_7_7}
+			     + PCRE_BSR_ANYCRLF + PCRE_BSR_UNICODE
+			     {$ENDIF}
+			     ;
+
+{$IFDEF PCRE_7_0}
+ PCRE_DFA_EXEC_ALLOWED_OPTIONS = PCRE_ANCHORED + PCRE_NOTBOL + PCRE_NOTEOL +
+				 PCRE_NOTEMPTY + PCRE_NO_UTF8_CHECK + PCRE_PARTIAL +
+				 PCRE_DFA_SHORTEST + PCRE_DFA_RESTART +
+				 PCRE_NEWLINE_BITS
+				 {$IFDEF PCRE_7_7}
+				 + PCRE_BSR_ANYCRLF + PCRE_BSR_UNICODE
+				 {$ENDIF}
+				 ;
+{$ENDIF}
+
+{ Exec-time and get/set-time error codes }
+ PCRE_ERROR_NOMATCH        =  -1;
+ PCRE_ERROR_NULL	   =  -2;
+ PCRE_ERROR_BADOPTION      =  -3;
+ PCRE_ERROR_BADMAGIC       =  -4;
+ PCRE_ERROR_UNKNOWN_MODE   =  -5;
+ PCRE_ERROR_NOMEMORY       =  -6;
+ PCRE_ERROR_NOSUBSTRING    =  -7;
+{$IFDEF PCRE_5_0}
+ PCRE_ERROR_MATCHLIMIT     =  -8;
+ PCRE_ERROR_CALLOUT        =  -9;  { Never used by PCRE itself }
+ PCRE_ERROR_BADUTF8        = -10;
+ PCRE_ERROR_BADUTF8_OFFSET = -11;
+ PCRE_ERROR_PARTIAL        = -12;
+ PCRE_ERROR_BADPARTIAL     = -13;
+ PCRE_ERROR_INTERNAL       = -14;
+ PCRE_ERROR_BADCOUNT       = -15;
+{$ENDIF}
+{$IFDEF PCRE_7_0}
+ PCRE_ERROR_DFA_UITEM      = -16;
+ PCRE_ERROR_DFA_UCOND      = -17;
+ PCRE_ERROR_DFA_UMLIMIT    = -18;
+ PCRE_ERROR_DFA_WSSIZE     = -19;
+ PCRE_ERROR_DFA_RECURSE    = -20;
+ PCRE_ERROR_RECURSIONLIMIT = -21;
+ PCRE_ERROR_NULLWSLIMIT    = -22;
+ PCRE_ERROR_BADNEWLINE     = -23;
+{$ENDIF}
+
+{ Request types for pcre_fullinfo() }
+
+ PCRE_INFO_OPTIONS         =  0;
+ PCRE_INFO_SIZE 	   =  1;
+ PCRE_INFO_CAPTURECOUNT    =  2;
+ PCRE_INFO_BACKREFMAX      =  3;
+ PCRE_INFO_FIRSTBYTE       =  4;
+ PCRE_INFO_FIRSTCHAR       =  4; { For backwards compatibility }
+ PCRE_INFO_FIRSTTABLE      =  5;
+{$IFDEF PCRE_5_0}
+ PCRE_INFO_LASTLITERAL     =  6;
+ PCRE_INFO_NAMEENTRYSIZE   =  7;
+ PCRE_INFO_NAMECOUNT       =  8;
+ PCRE_INFO_NAMETABLE       =  9;
+ PCRE_INFO_STUDYSIZE       = 10;
+ PCRE_INFO_DEFAULT_TABLES  = 11;
+{$ENDIF PCRE_5_0}
+{$IFDEF PCRE_7_7}
+ PCRE_INFO_OKPARTIAL       = 12;
+ PCRE_INFO_JCHANGED        = 13;
+ PCRE_INFO_HASCRORLF       = 14;
+{$ENDIF}
+
+{ Request types for pcre_config() }
+{$IFDEF PCRE_5_0}
+ PCRE_CONFIG_UTF8       	    = 0;
+ PCRE_CONFIG_NEWLINE    	    = 1;
+ PCRE_CONFIG_LINK_SIZE  	    = 2;
+ PCRE_CONFIG_POSIX_MALLOC_THRESHOLD = 3;
+ PCRE_CONFIG_MATCH_LIMIT	    = 4;
+ PCRE_CONFIG_STACKRECURSE           = 5;
+ PCRE_CONFIG_UNICODE_PROPERTIES     = 6;
+{$ENDIF PCRE_5_0}
+{$IFDEF PCRE_7_0}
+ PCRE_CONFIG_MATCH_LIMIT_RECURSION  = 7;
+{$ENDIF}
+{$IFDEF PCRE_7_7}
+ PCRE_CONFIG_BSR		    = 8;
+{$ENDIF}
+
+{ Bit flags for the pcre_extra structure }
+{$IFDEF PCRE_5_0}
+ PCRE_EXTRA_STUDY_DATA  	  = $0001;
+ PCRE_EXTRA_MATCH_LIMIT 	  = $0002;
+ PCRE_EXTRA_CALLOUT_DATA	  = $0004;
+ PCRE_EXTRA_TABLES      	  = $0008;
+{$ENDIF PCRE_5_0}
+{$IFDEF PCRE_7_0}
+ PCRE_EXTRA_MATCH_LIMIT_RECURSION = $0010;
+{$ENDIF}
+
+Const
+// DefaultOptions : integer = 0;
+ DefaultLocaleTable : pointer = nil;
+
+{$IFDEF PCRE_5_0}
+{ The structure for passing additional data to pcre_exec(). This is defined in
+such as way as to be extensible. Always add new fields at the end, in order to
+remain compatible. }
+
+type ppcre_extra = ^tpcre_extra;
+     tpcre_extra = record
+       flags : longint; 	       { Bits for which fields are set }
+       study_data : pointer;           { Opaque data from pcre_study() }
+       match_limit : longint;          { Maximum number of calls to match() }
+       callout_data : pointer;         { Data passed back in callouts }
+       tables : pointer;	       { Pointer to character tables }
+       match_limit_recursion: longint; { Max recursive calls to match() }
+     end;
+
+type ppcre_callout_block = ^pcre_callout_block;
+     pcre_callout_block = record
+       version,
+  (* ------------------------ Version 0 ------------------------------- *)
+       callout_number : integer;
+       offset_vector : pointer;
+       subject : pchar;
+       subject_length, start_match, current_position, capture_top,
+       capture_last : integer;
+       callout_data : pointer;
+  (* ------------------- Added for Version 1 -------------------------- *)
+       pattern_position, next_item_length : integer;
+     end;
+{$ENDIF PCRE_5_0}
+
+{$OrgName+}
+{$IFDEF VIRTUALPASCAL} {&Cdecl+} {$ENDIF VIRTUALPASCAL}
+
+ { local replacement of external pcre memory management functions }
+ function pcre_malloc( size : integer ) : pointer;
+ procedure pcre_free( {var} p : pointer );
+{$IFDEF PCRE_5_0}
+ const pcre_stack_malloc: function ( size : integer ): pointer = pcre_malloc;
+       pcre_stack_free: procedure ( {var} p : pointer ) = pcre_free;
+ function pcre_callout(var p : ppcre_callout_block) : integer;
+{$ENDIF PCRE_5_0}
+{$IFDEF VIRTUALPASCAL} {&Cdecl-} {$ENDIF VIRTUALPASCAL}
+
+Implementation
+
+Uses strings, collect, messages, dnapp, commands, advance0, stringsx
+    {$IFDEF VIRTUALPASCAL} ,vpsyslow {$ENDIF VIRTUALPASCAL};
+
+Const
+ MAGIC_NUMBER = $50435245; { 'PCRE' }
+ MAX_MATCHES = 90; { changed in 3.5 version; should be divisible by 3, was 64}
+
+Type
+ PMatchArray = ^TMatchArray;
+ TMatchArray = array[0..( MAX_MATCHES * 3 )] of integer;
+
+ PRegExpCollection = ^TRegExpCollection;
+ TRegExpCollection =  object(TSortedCollection)
+   MaxRegExp : integer;
+   SearchRegExp : shortstring;
+   CompareModeInsert : boolean;
+   constructor Init(AMaxRegExp:integer);
+   procedure FreeItem(P: Pointer); virtual;
+   function  Compare(P1, P2: Pointer): Integer; virtual;
+   function  Find(ARegExp:shortstring;var P: PpcRegExp):boolean; virtual;
+   function CheckNew(ARegExp:shortstring):PpcRegExp;virtual;
+ end;
+
+Var
+ PRegExpCache : PRegExpCollection;
+
+
+{$IFDEF VIRTUALPASCAL} {&Cdecl+} {$ENDIF VIRTUALPASCAL}
+
+ { imported original pcre functions }
+
+ function pcre_compile( const pattern : PChar; options : integer;
+			var errorptr : PChar; var erroroffset : integer;
+			const tables : PChar ) : pointer {pcre}; external;
+{$IFDEF PCRE_7_0}
+ function pcre_compile2( const pattern : PChar; options : integer;
+			 var errorcodeptr : Integer;
+			 var errorptr : PChar; var erroroffset : integer;
+			 const tables : PChar ) : pointer {pcre}; external;
+{$ENDIF}
+{$IFDEF PCRE_5_0}
+ function pcre_config( what : integer; where : pointer) : integer; external;
+ function pcre_copy_named_substring( const code : pointer {pcre};
+				     const subject : pchar;
+				     var ovector : integer;
+				     stringcount : integer;
+				     const stringname : pchar;
+				     var buffer : pchar;
+				     size : integer) : integer; external;
+ function pcre_copy_substring( const subject : pchar; var ovector : integer;
+			       stringcount, stringnumber : integer;
+			       var buffer : pchar; size : integer )
+			       : integer; external;
+ function pcre_exec( const argument_re : pointer {pcre};
+		     const extra_data : pointer {pcre_extra};
+{$ELSE}
+ function pcre_exec( const external_re : pointer;
+		     const external_extra : pointer;
+{$ENDIF}
+		     const subject : PChar;
+		     length, start_offset, options : integer;
+		     offsets : pointer;
+		     offsetcount : integer ) : integer; external;
+{$IFDEF PCRE_7_0}
+ function pcre_dfa_exec( const argument_re : pointer {pcre};
+			 const extra_data : pointer {pcre_extra};
+			 const subject : pchar;
+			 length, start_offset, options : integer;
+			 offsets : pointer;
+			 offsetcount : integer;
+			 workspace : pointer;
+			 wscount : integer ) : integer; external;
+{$ENDIF}
+{$IFDEF PCRE_5_0}
+ procedure pcre_free_substring( const p : pchar ); external;
+ procedure pcre_free_substring_list( var p : pchar ); external;
+ function pcre_fullinfo( const argument_re : pointer {pcre};
+			 const extra_data : pointer {pcre_extra};
+			 what : integer;
+			 where : pointer ) : integer; external;
+ function pcre_get_named_substring( const code : pointer {pcre};
+				    const subject : pchar;
+				    var ovector : integer;
+				    stringcount : integer;
+				    const stringname : pchar;
+				    var stringptr : pchar ) : integer; external;
+ function pcre_get_stringnumber( const code : pointer {pcre};
+				 const stringname : pchar ) : integer; external;
+ function pcre_get_stringtable_entries( const code : pointer {pcre};
+					const stringname : pchar;
+					var firstptr,
+					    lastptr : pchar ) : integer; external;
+ function pcre_get_substring( const subject : pchar; var ovector : integer;
+			      stringcount, stringnumber : integer;
+			      var stringptr : pchar ) : integer; external;
+ function pcre_get_substring_list( const subject : pchar; var ovector : integer;
+				   stringcount : integer;
+				   listptr : pointer {const char ***listptr}) : integer; external;
+ function pcre_info( const argument_re : pointer {pcre};
+		     var optptr : integer;
+		     var first_byte : integer ) : integer; external;
+ function pcre_maketables : pchar; external;
+{$ENDIF}
+{$IFDEF PCRE_7_0}
+ function pcre_refcount( const argument_re : pointer {pcre};
+			 adjust : integer ) : pchar; external;
+{$ENDIF}
+ function pcre_study( const external_re : pointer {pcre};
+		      options : integer;
+		      var errorptr : PChar ) : pointer {pcre_extra}; external;
+{$IFDEF PCRE_5_0}
+ function pcre_version : pchar; external;
+{$ENDIF}
+
+ function pcre_malloc( size : integer ) : pointer;
+ begin
+  GetMem( result, size );
+ end;
+
+ procedure pcre_free( {var} p : pointer );
+ begin
+  if (p <> nil) then
+    FreeMem( p, 0 );
+  {@p := nil;}
+ end;
+
+{$IFDEF PCRE_5_0}
+(* Called from PCRE as a result of the (?C) item. We print out where we are in
+the match. Yield zero unless more callouts than the fail count, or the callout
+data is not zero. *)
+
+ function pcre_callout;
+ begin
+ end;
+{$ENDIF}
+
+{$IFDEF VIRTUALPASCAL} {&Cdecl-} {$ENDIF VIRTUALPASCAL}
+
+// Always include the newest version of the library
+{$IFDEF PCRE_7_7}
+  {$L pcre77.lib}
+{$ELSE}
+  {$IFDEF PCRE_7_0}
+    {$L pcre70.lib}
+  {$ELSE}
+    {$IFDEF PCRE_5_0}
+      {$L pcre50.lib}
+    {$ELSE}
+      {$IFDEF PCRE_3_7}
+	{$L pcre37.lib}
+      {$ENDIF PCRE_3_7}
+    {$ENDIF PCRE_5_0}
+  {$ENDIF PCRE_7_0}
+{$ENDIF PCRE_7_7}
+
+{TpcRegExp}
+
+ constructor TpcRegExp.Init(const ARegExp:shortstring; AOptions:integer; ALocale : Pointer);
+ var
+  pRegExp : PChar;
+ begin
+  RegExp:=ARegExp;
+  RegExpC:=nil;
+  RegExpExt:=nil;
+  Matches:=nil;
+  MatchesCount:=0;
+  Error:=true;
+  ErrorMsg:=nil;
+  ErrorPos:=0;
+  RunTimeOptions := 0;
+  if length(RegExp) < 255 then
+   begin
+    RegExp[length(RegExp)+1]:=#0;
+    pRegExp:=@RegExp[1];
+   end
+  else
+   begin
+    GetMem(pRegExp,length(RegExp)+1);
+    pRegExp:=strpcopy(pRegExp,RegExp);
+   end;
+  RegExpC := pcre_compile( pRegExp,
+			   AOptions and PCRE_COMPILE_ALLOWED_OPTIONS,
+			   ErrorMsg, ErrorPos, ALocale);
+  if length(RegExp) = 255 then
+   StrDispose(pRegExp);
+  if RegExpC = nil then
+   exit;
+  ErrorMsg:=nil;
+  RegExpExt := pcre_study( RegExpC, 0, ErrorMsg );
+  if (RegExpExt = nil) and (ErrorMsg <> nil) then
+   begin
+    pcre_free(RegExpC);
+    exit;
+   end;
+  GetMem(Matches,SizeOf(TMatchArray));
+  Error:=false;
+ end;
+
+ destructor TpcRegExp.Done;
+ begin
+  if RegExpC <> nil then
+    pcre_free(RegExpC);
+  if RegExpExt <> nil then
+    pcre_free(RegExpExt);
+  if Matches <> nil then
+    FreeMem(Matches,SizeOf(TMatchArray));
+ end;
+
+ function TpcRegExp.SearchNext( AStr: Pchar; ALen : longint ) : boolean;
+ var Options: Integer;
+ begin // must handle PCRE_ERROR_PARTIAL here
+  Options := (RunTimeOptions or startup.MiscMultiData.cfgRegEx.DefaultOptions) and
+	     PCRE_EXEC_ALLOWED_OPTIONS;
+  if MatchesCount > 0 then
+    MatchesCount:=pcre_exec( RegExpC, RegExpExt, AStr, ALen, PMatchArray(Matches)^[1],
+			     Options, Matches, MAX_MATCHES ) else
+    MatchesCount:=pcre_exec( RegExpC, RegExpExt, AStr, ALen, 0,
+			     Options, Matches, MAX_MATCHES );
+{  if MatchesCount = 0 then
+    MatchesCount := MatchesCount div 3;}
+  PartialMatch := MatchesCount = PCRE_ERROR_PARTIAL;
+  SearchNext := MatchesCount > 0;
+ end;
+
+ function TpcRegExp.Search( AStr: Pchar; ALen : longint):boolean;
+ begin
+  MatchesCount:=0;
+  Search:=SearchNext(AStr,ALen);
+  SourceLen:=ALen;
+ end;
+
+ function TpcRegExp.SearchOfs( AStr: Pchar; ALen, AOfs: longint ) : boolean;
+ var Options: Integer;
+ begin
+  MatchesCount:=0;
+  Options := (RunTimeOptions or startup.MiscMultiData.cfgRegEx.DefaultOptions) and
+	     PCRE_EXEC_ALLOWED_OPTIONS;
+  MatchesCount:=pcre_exec( RegExpC, RegExpExt, AStr, ALen, AOfs,
+			   Options, Matches, MAX_MATCHES );
+  PartialMatch := MatchesCount = PCRE_ERROR_PARTIAL;
+  SearchOfs := MatchesCount > 0;
+  SourceLen := ALen-AOfs;
+ end;
+
+ function TpcRegExp.MatchSub(ANom:integer; var Pos,Len:longint):boolean;
+ begin
+  if (MatchesCount > 0) and (ANom <= (MatchesCount-1)) then
+   begin
+    ANom:=ANom*2;
+    Pos:=PMatchArray(Matches)^[ANom];
+    Len:=PMatchArray(Matches)^[ANom+1]-Pos;
+    MatchSub:=true;
+   end
+  else
+   MatchSub:=false;
+ end;
+
+ function TpcRegExp.MatchFull(var Pos,Len:longint):boolean;
+ begin
+  MatchFull:=MatchSub(0,Pos,Len);
+ end;
+
+ function TpcRegExp.GetSubStr(ANom: integer; AStr: Pchar):string;
+ var
+  s: ansistring;
+  pos,len: longint;
+ begin
+  s:='';
+  if MatchSub(ANom, pos, len) then
+   begin
+    setlength(s, len);
+    Move(AStr[pos], s[1], len);
+   end;
+  GetSubStr:=s;
+ end;
+
+ function TpcRegExp.GetPreSubStr(AStr: Pchar):string;
+ var
+  s: ansistring;
+  l: longint;
+ begin
+  s:='';
+  if (MatchesCount > 0) then
+   begin
+    l:=PMatchArray(Matches)^[0]-1;
+    if l > 0 then
+     begin
+      setlength(s,l);
+      Move(AStr[1],s[1],l);
+     end;
+   end;
+  GetPreSubStr:=s;
+ end;
+
+ function TpcRegExp.GetPostSubStr(AStr: Pchar):string;
+ var
+  s: ansistring;
+  l: longint;
+  ANom: integer;
+ begin
+  s:='';
+  if (MatchesCount > 0) then
+   begin
+    ANom:=(MatchesCount-1){*2} shl 1;
+    l:=SourceLen-PMatchArray(Matches)^[ANom+1]+1;
+    if l > 0 then
+     begin
+      setlength(s,l);
+      Move(AStr[PMatchArray(Matches)^[ANom+1]],s[1],l);
+     end;
+   end;
+  GetPostSubStr:=s;
+ end;
+
+
+ function TpcRegExp.GetFullStr(AStr: Pchar):string;
+ var
+  s: ansistring;
+  l: longint;
+ begin
+  GetFullStr:=GetSubStr(0,AStr);
+ end;
+
+ function TpcRegExp.GetReplStr(AStr: Pchar; const ARepl: string):string;
+ var
+  s: ansistring;
+  l,i,lasti: longint;
+ begin
+  l:=length(ARepl);
+  i:=1;
+  lasti:=1;
+  s:='';
+  while i <= l do
+   begin
+    case ARepl[i] of
+     '\' :
+      begin
+       if i < l then
+	begin
+	 s:=s+copy(ARepl,lasti,i-lasti){+ARepl[i+1]};
+	 {AH 17-10-05 support for POSIX \1-\9 backreferences}
+	 case ARepl[i+1] of
+	  '0' : s:=s+GetFullStr(AStr);
+	  '1'..'9' : s:=s+GetSubStr(ord(ARepl[i+1])-ord('0'),AStr);
+	  else s:=s+ARepl[i+1]; // copy the escaped character
+	 end;
+	end;
+       inc(i);
+       lasti:=i+1;
+      end;
+     '$' :
+      begin
+       if i < l then
+	begin
+	 s:=s+copy(ARepl,lasti,i-lasti);
+	 case ARepl[i+1] of
+	  '&' : s:=s+GetFullStr(AStr);
+	  '1'..'9' : s:=s+GetSubStr(ord(ARepl[i+1])-ord('0'),AStr);
+	  '`' : s:=s+GetPreSubStr(AStr);
+	  #39 : s:=s+GetPostSubStr(AStr);
+	 end;
+	end;
+       inc(i);
+       lasti:=i+1;
+      end;
+    end;
+    inc(i);
+   end;
+  if lasti <= {AH 25-10-2004 added =, else l==1 won't work} l then
+    s:=s+copy(ARepl,lasti,l-lasti+1);
+  GetReplStr:=s;
+ end;
+
+ function TpcRegExp.ErrorStr:string;
+  begin
+   ErrorStr:=StrPas(ErrorMsg);
+  end;
+
+{TRegExpCollection}
+
+constructor TRegExpCollection.Init(AMaxRegExp: integer);
+begin
+ Inherited Init(1,1);
+ MaxRegExp:=AMaxRegExp;
+ CompareModeInsert:=true;
+end;
+
+procedure TRegExpCollection.FreeItem(P: Pointer);
+begin
+ if P <> nil then
+  begin
+   Dispose(PpcRegExp(P),Done);
+  end;
+end;
+
+function  TRegExpCollection.Compare(P1, P2: Pointer): Integer;
+//var
+// l,l1,l2,i : byte;
+//// wPos: pchar;
+begin
+ if CompareModeInsert then
+  begin
+//   l1:=length(PpcRegExp(P1)^.RegExp);
+//   l2:=length(PpcRegExp(P2)^.RegExp);
+//   if l1 > l2 then l:=l2 else
+//      	     l:=l1;
+//   for i:=1 to l do
+//     if PpcRegExp(P1).RegExp[i] <> PpcRegExp(P2).RegExp[i] then break;
+//   if i <=l then
+//     Compare:=ord(PpcRegExp(P1).RegExp[i])-ord(PpcRegExp(P2).RegExp[i]) else
+//     Compare:=l1-l2;
+    Compare := stringsx.PasStrCmp(PpcRegExp(P1).RegExp, PpcRegExp(P2).RegExp, False);
+  end
+ else
+  begin
+//   l1:=length(PpcRegExp(P1)^.RegExp);
+//   l2:=length(SearchRegExp);
+//   if l1 > l2 then l:=l2 else
+//      	     l:=l1;
+//   for i:=1 to l do
+//     if PpcRegExp(P1).RegExp[i] <> SearchRegExp[i] then
+//     begin
+//       Compare:=ord(PpcRegExp(P1).RegExp[i])-ord(SearchRegExp[i]);
+//       break;
+//     end;
+//   if i > l then Compare:=l1-l2;
+    Compare := stringsx.PasStrCmp(PpcRegExp(P1).RegExp, SearchRegExp, False);
+  end;
+end;
+
+function  TRegExpCollection.Find(ARegExp:shortstring;var P: PpcRegExp):boolean;
+var I : integer;
+begin
+ CompareModeInsert:=false;
+ SearchRegExp:=ARegExp;
+ if Search(nil,I) then
+  begin
+   P:=PpcRegExp(At(I));
+   Find:=true;
+  end
+ else
+  begin
+   P:=nil;
+   Find:=false;
+  end;
+ CompareModeInsert:=true;
+end;
+
+function TRegExpCollection.CheckNew(ARegExp:shortstring):PpcRegExp;
+var
+ P : PpcRegExp;
+begin
+ if not Find(ARegExp,P) then
+  begin
+   if Count = MaxRegExp then
+    AtFree(0);
+   P:=New(ppcRegExp,Init(ARegExp,PCRE_CASELESS,nil));
+   Insert(P);
+  end;
+ CheckNew:=P;
+end;
+
+function pcGrepMatch(WildCard, aStr: string; AOptions:integer; ALocale : Pointer): Boolean;
+var
+ PpcRE:PpcRegExp;
+begin
+ PpcRE:=New(ppcRegExp,Init(WildCard,AOptions,Alocale));
+ pcGrepMatch:=PpcRE^.Search(pchar(AStr),Length(AStr));
+ Dispose(PpcRE,Done);
+end;
+
+function pcGrepSub(WildCard, aStr, aRepl: string; AOptions:integer; ALocale : Pointer): string;
+var
+ PpcRE:PpcRegExp;
+begin
+ PpcRE:=New(ppcRegExp,Init(WildCard,AOptions,Alocale));
+ if PpcRE^.Search(pchar(AStr),Length(AStr)) then
+  pcGrepSub:=PpcRE^.GetReplStr(pchar(AStr),ARepl)
+ else
+  pcGrepSub:='';
+ Dispose(PpcRE,Done);
+end;
+
+function pcFastGrepMatch(WildCard, aStr: string): Boolean;
+var
+ PpcRE:PpcRegExp;
+begin
+ PpcRE:=PRegExpCache^.CheckNew(WildCard);
+ pcFastGrepMatch:=PpcRE^.Search(pchar(AStr),Length(AStr));
+end;
+
+function pcFastGrepSub(WildCard, aStr, aRepl: string): string;
+var
+ PpcRE:PpcRegExp;
+begin
+ PpcRE:=PRegExpCache^.CheckNew(WildCard);
+ if PpcRE^.Search(pchar(AStr),Length(AStr)) then
+  pcFastGrepSub:=PpcRE^.GetReplStr(pchar(AStr),ARepl)
+ else
+  pcFastGrepSub:='';
+end;
+
+{$IFDEF PCRE_5_0}
+function pcGetVersion : pchar; assembler; {$FRAME-}{$USES none}
+asm
+  call pcre_version
+end;
+{$ENDIF PCRE_5_0}
+
+function pcError;
+var P: ppcRegExp absolute pRegExp;
+begin
+  Result := (P = nil) or P^.Error;
+  If Result and (P <> nil) then
+  begin
+{     if P^.ErrorPos = 0 then
+      MessageBox(GetString(erRegExpCompile)+'"'+P^.ErrorStr+'"', nil,mfConfirmation+mfOkButton)
+    else}
+      MessageBox(GetString(erRegExpCompile)+'"'+P^.ErrorStr+'"'+GetString(erRegExpCompPos),
+		 @P^.ErrorPos,mfConfirmation+mfOkButton);
+    Dispose(P, Done);
+    P:=nil;
+  end;
+end;
+
+function pcInit;
+var Options : Integer;
+begin
+  If CaseSens then Options := 0 else Options := PCRE_CASELESS;
+  Result := New( PpcRegExp, Init( Pattern,
+				  {DefaultOptions}
+				  startup.MiscMultiData.cfgRegEx.DefaultOptions or Options,
+				  DefaultLocaleTable) );
+end;
+
+Initialization
+ PRegExpCache:=New(PRegExpCollection,Init(64));
+Finalization
+ Dispose(PRegExpCache,Done);
+End.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcregrep.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2379 @@
+/*************************************************
+*               pcregrep program                 *
+*************************************************/
+
+/* This is a grep program that uses the PCRE regular expression library to do
+its pattern matching. On a Unix or Win32 system it can recurse into
+directories.
+
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <ctype.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef SUPPORT_LIBZ
+#include <zlib.h>
+#endif
+
+#ifdef SUPPORT_LIBBZ2
+#include <bzlib.h>
+#endif
+
+#include "pcre.h"
+
+#define FALSE 0
+#define TRUE 1
+
+typedef int BOOL;
+
+#define MAX_PATTERN_COUNT 100
+
+#if BUFSIZ > 8192
+#define MBUFTHIRD BUFSIZ
+#else
+#define MBUFTHIRD 8192
+#endif
+
+/* Values for the "filenames" variable, which specifies options for file name
+output. The order is important; it is assumed that a file name is wanted for
+all values greater than FN_DEFAULT. */
+
+enum { FN_NONE, FN_DEFAULT, FN_ONLY, FN_NOMATCH_ONLY, FN_FORCE };
+
+/* File reading styles */
+
+enum { FR_PLAIN, FR_LIBZ, FR_LIBBZ2 };
+
+/* Actions for the -d and -D options */
+
+enum { dee_READ, dee_SKIP, dee_RECURSE };
+enum { DEE_READ, DEE_SKIP };
+
+/* Actions for special processing options (flag bits) */
+
+#define PO_WORD_MATCH     0x0001
+#define PO_LINE_MATCH     0x0002
+#define PO_FIXED_STRINGS  0x0004
+
+/* Line ending types */
+
+enum { EL_LF, EL_CR, EL_CRLF, EL_ANY, EL_ANYCRLF };
+
+
+
+/*************************************************
+*               Global variables                 *
+*************************************************/
+
+/* Jeffrey Friedl has some debugging requirements that are not part of the
+regular code. */
+
+#ifdef JFRIEDL_DEBUG
+static int S_arg = -1;
+static unsigned int jfriedl_XR = 0; /* repeat regex attempt this many times */
+static unsigned int jfriedl_XT = 0; /* replicate text this many times */
+static const char *jfriedl_prefix = "";
+static const char *jfriedl_postfix = "";
+#endif
+
+static int  endlinetype;
+
+static char *colour_string = (char *)"1;31";
+static char *colour_option = NULL;
+static char *dee_option = NULL;
+static char *DEE_option = NULL;
+static char *newline = NULL;
+static char *pattern_filename = NULL;
+static char *stdin_name = (char *)"(standard input)";
+static char *locale = NULL;
+
+static const unsigned char *pcretables = NULL;
+
+static int  pattern_count = 0;
+static pcre **pattern_list = NULL;
+static pcre_extra **hints_list = NULL;
+
+static char *include_pattern = NULL;
+static char *exclude_pattern = NULL;
+static char *include_dir_pattern = NULL;
+static char *exclude_dir_pattern = NULL;
+
+static pcre *include_compiled = NULL;
+static pcre *exclude_compiled = NULL;
+static pcre *include_dir_compiled = NULL;
+static pcre *exclude_dir_compiled = NULL;
+
+static int after_context = 0;
+static int before_context = 0;
+static int both_context = 0;
+static int dee_action = dee_READ;
+static int DEE_action = DEE_READ;
+static int error_count = 0;
+static int filenames = FN_DEFAULT;
+static int process_options = 0;
+
+static BOOL count_only = FALSE;
+static BOOL do_colour = FALSE;
+static BOOL file_offsets = FALSE;
+static BOOL hyphenpending = FALSE;
+static BOOL invert = FALSE;
+static BOOL line_offsets = FALSE;
+static BOOL multiline = FALSE;
+static BOOL number = FALSE;
+static BOOL only_matching = FALSE;
+static BOOL quiet = FALSE;
+static BOOL silent = FALSE;
+static BOOL utf8 = FALSE;
+
+/* Structure for options and list of them */
+
+enum { OP_NODATA, OP_STRING, OP_OP_STRING, OP_NUMBER, OP_OP_NUMBER,
+       OP_PATLIST };
+
+typedef struct option_item {
+  int type;
+  int one_char;
+  void *dataptr;
+  const char *long_name;
+  const char *help_text;
+} option_item;
+
+/* Options without a single-letter equivalent get a negative value. This can be
+used to identify them. */
+
+#define N_COLOUR       (-1)
+#define N_EXCLUDE      (-2)
+#define N_EXCLUDE_DIR  (-3)
+#define N_HELP         (-4)
+#define N_INCLUDE      (-5)
+#define N_INCLUDE_DIR  (-6)
+#define N_LABEL        (-7)
+#define N_LOCALE       (-8)
+#define N_NULL         (-9)
+#define N_LOFFSETS     (-10)
+#define N_FOFFSETS     (-11)
+
+static option_item optionlist[] = {
+  { OP_NODATA,    N_NULL,   NULL,              "",              "  terminate options" },
+  { OP_NODATA,    N_HELP,   NULL,              "help",          "display this help and exit" },
+  { OP_NUMBER,    'A',      &after_context,    "after-context=number", "set number of following context lines" },
+  { OP_NUMBER,    'B',      &before_context,   "before-context=number", "set number of prior context lines" },
+  { OP_OP_STRING, N_COLOUR, &colour_option,    "color=option",  "matched text color option" },
+  { OP_NUMBER,    'C',      &both_context,     "context=number", "set number of context lines, before & after" },
+  { OP_NODATA,    'c',      NULL,              "count",         "print only a count of matching lines per FILE" },
+  { OP_OP_STRING, N_COLOUR, &colour_option,    "colour=option", "matched text colour option" },
+  { OP_STRING,    'D',      &DEE_option,       "devices=action","how to handle devices, FIFOs, and sockets" },
+  { OP_STRING,    'd',      &dee_option,       "directories=action", "how to handle directories" },
+  { OP_PATLIST,   'e',      NULL,              "regex(p)",      "specify pattern (may be used more than once)" },
+  { OP_NODATA,    'F',      NULL,              "fixed_strings", "patterns are sets of newline-separated strings" },
+  { OP_STRING,    'f',      &pattern_filename, "file=path",     "read patterns from file" },
+  { OP_NODATA,    N_FOFFSETS, NULL,            "file-offsets",  "output file offsets, not text" },
+  { OP_NODATA,    'H',      NULL,              "with-filename", "force the prefixing filename on output" },
+  { OP_NODATA,    'h',      NULL,              "no-filename",   "suppress the prefixing filename on output" },
+  { OP_NODATA,    'i',      NULL,              "ignore-case",   "ignore case distinctions" },
+  { OP_NODATA,    'l',      NULL,              "files-with-matches", "print only FILE names containing matches" },
+  { OP_NODATA,    'L',      NULL,              "files-without-match","print only FILE names not containing matches" },
+  { OP_STRING,    N_LABEL,  &stdin_name,       "label=name",    "set name for standard input" },
+  { OP_NODATA,    N_LOFFSETS, NULL,            "line-offsets",  "output line numbers and offsets, not text" },
+  { OP_STRING,    N_LOCALE, &locale,           "locale=locale", "use the named locale" },
+  { OP_NODATA,    'M',      NULL,              "multiline",     "run in multiline mode" },
+  { OP_STRING,    'N',      &newline,          "newline=type",  "set newline type (CR, LF, CRLF, ANYCRLF or ANY)" },
+  { OP_NODATA,    'n',      NULL,              "line-number",   "print line number with output lines" },
+  { OP_NODATA,    'o',      NULL,              "only-matching", "show only the part of the line that matched" },
+  { OP_NODATA,    'q',      NULL,              "quiet",         "suppress output, just set return code" },
+  { OP_NODATA,    'r',      NULL,              "recursive",     "recursively scan sub-directories" },
+  { OP_STRING,    N_EXCLUDE,&exclude_pattern,  "exclude=pattern","exclude matching files when recursing" },
+  { OP_STRING,    N_INCLUDE,&include_pattern,  "include=pattern","include matching files when recursing" },
+  { OP_STRING,    N_EXCLUDE_DIR,&exclude_dir_pattern, "exclude_dir=pattern","exclude matching directories when recursing" },
+  { OP_STRING,    N_INCLUDE_DIR,&include_dir_pattern, "include_dir=pattern","include matching directories when recursing" },
+#ifdef JFRIEDL_DEBUG
+  { OP_OP_NUMBER, 'S',      &S_arg,            "jeffS",         "replace matched (sub)string with X" },
+#endif
+  { OP_NODATA,    's',      NULL,              "no-messages",   "suppress error messages" },
+  { OP_NODATA,    'u',      NULL,              "utf-8",         "use UTF-8 mode" },
+  { OP_NODATA,    'V',      NULL,              "version",       "print version information and exit" },
+  { OP_NODATA,    'v',      NULL,              "invert-match",  "select non-matching lines" },
+  { OP_NODATA,    'w',      NULL,              "word-regex(p)", "force patterns to match only as words"  },
+  { OP_NODATA,    'x',      NULL,              "line-regex(p)", "force patterns to match only whole lines" },
+  { OP_NODATA,    0,        NULL,               NULL,            NULL }
+};
+
+/* Tables for prefixing and suffixing patterns, according to the -w, -x, and -F
+options. These set the 1, 2, and 4 bits in process_options, respectively. Note
+that the combination of -w and -x has the same effect as -x on its own, so we
+can treat them as the same. */
+
+static const char *prefix[] = {
+  "", "\\b", "^(?:", "^(?:", "\\Q", "\\b\\Q", "^(?:\\Q", "^(?:\\Q" };
+
+static const char *suffix[] = {
+  "", "\\b", ")$",   ")$",   "\\E", "\\E\\b", "\\E)$",   "\\E)$" };
+
+/* UTF-8 tables - used only when the newline setting is "any". */
+
+const int utf8_table3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
+
+const char utf8_table4[] = {
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+  3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
+
+
+
+/*************************************************
+*            OS-specific functions               *
+*************************************************/
+
+/* These functions are defined so that they can be made system specific,
+although at present the only ones are for Unix, Win32, and for "no support". */
+
+
+/************* Directory scanning in Unix ***********/
+
+#if defined HAVE_SYS_STAT_H && defined HAVE_DIRENT_H && defined HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+
+typedef DIR directory_type;
+
+static int
+isdirectory(char *filename)
+{
+struct stat statbuf;
+if (stat(filename, &statbuf) < 0)
+  return 0;        /* In the expectation that opening as a file will fail */
+return ((statbuf.st_mode & S_IFMT) == S_IFDIR)? '/' : 0;
+}
+
+static directory_type *
+opendirectory(char *filename)
+{
+return opendir(filename);
+}
+
+static char *
+readdirectory(directory_type *dir)
+{
+for (;;)
+  {
+  struct dirent *dent = readdir(dir);
+  if (dent == NULL) return NULL;
+  if (strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0)
+    return dent->d_name;
+  }
+/* Control never reaches here */
+}
+
+static void
+closedirectory(directory_type *dir)
+{
+closedir(dir);
+}
+
+
+/************* Test for regular file in Unix **********/
+
+static int
+isregfile(char *filename)
+{
+struct stat statbuf;
+if (stat(filename, &statbuf) < 0)
+  return 1;        /* In the expectation that opening as a file will fail */
+return (statbuf.st_mode & S_IFMT) == S_IFREG;
+}
+
+
+/************* Test stdout for being a terminal in Unix **********/
+
+static BOOL
+is_stdout_tty(void)
+{
+return isatty(fileno(stdout));
+}
+
+
+/************* Directory scanning in Win32 ***********/
+
+/* I (Philip Hazel) have no means of testing this code. It was contributed by
+Lionel Fourquaux. David Burgess added a patch to define INVALID_FILE_ATTRIBUTES
+when it did not exist. David Byron added a patch that moved the #include of
+<windows.h> to before the INVALID_FILE_ATTRIBUTES definition rather than after.
+*/
+
+#elif HAVE_WINDOWS_H
+
+#ifndef STRICT
+# define STRICT
+#endif
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+
+#include <windows.h>
+
+#ifndef INVALID_FILE_ATTRIBUTES
+#define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF
+#endif
+
+typedef struct directory_type
+{
+HANDLE handle;
+BOOL first;
+WIN32_FIND_DATA data;
+} directory_type;
+
+int
+isdirectory(char *filename)
+{
+DWORD attr = GetFileAttributes(filename);
+if (attr == INVALID_FILE_ATTRIBUTES)
+  return 0;
+return ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) ? '/' : 0;
+}
+
+directory_type *
+opendirectory(char *filename)
+{
+size_t len;
+char *pattern;
+directory_type *dir;
+DWORD err;
+len = strlen(filename);
+pattern = (char *) malloc(len + 3);
+dir = (directory_type *) malloc(sizeof(*dir));
+if ((pattern == NULL) || (dir == NULL))
+  {
+  fprintf(stderr, "pcregrep: malloc failed\n");
+  exit(2);
+  }
+memcpy(pattern, filename, len);
+memcpy(&(pattern[len]), "\\*", 3);
+dir->handle = FindFirstFile(pattern, &(dir->data));
+if (dir->handle != INVALID_HANDLE_VALUE)
+  {
+  free(pattern);
+  dir->first = TRUE;
+  return dir;
+  }
+err = GetLastError();
+free(pattern);
+free(dir);
+errno = (err == ERROR_ACCESS_DENIED) ? EACCES : ENOENT;
+return NULL;
+}
+
+char *
+readdirectory(directory_type *dir)
+{
+for (;;)
+  {
+  if (!dir->first)
+    {
+    if (!FindNextFile(dir->handle, &(dir->data)))
+      return NULL;
+    }
+  else
+    {
+    dir->first = FALSE;
+    }
+  if (strcmp(dir->data.cFileName, ".") != 0 && strcmp(dir->data.cFileName, "..") != 0)
+    return dir->data.cFileName;
+  }
+#ifndef _MSC_VER
+return NULL;   /* Keep compiler happy; never executed */
+#endif
+}
+
+void
+closedirectory(directory_type *dir)
+{
+FindClose(dir->handle);
+free(dir);
+}
+
+
+/************* Test for regular file in Win32 **********/
+
+/* I don't know how to do this, or if it can be done; assume all paths are
+regular if they are not directories. */
+
+int isregfile(char *filename)
+{
+return !isdirectory(filename);
+}
+
+
+/************* Test stdout for being a terminal in Win32 **********/
+
+/* I don't know how to do this; assume never */
+
+static BOOL
+is_stdout_tty(void)
+{
+return FALSE;
+}
+
+
+/************* Directory scanning when we can't do it ***********/
+
+/* The type is void, and apart from isdirectory(), the functions do nothing. */
+
+#else
+
+typedef void directory_type;
+
+int isdirectory(char *filename) { return 0; }
+directory_type * opendirectory(char *filename) { return (directory_type*)0;}
+char *readdirectory(directory_type *dir) { return (char*)0;}
+void closedirectory(directory_type *dir) {}
+
+
+/************* Test for regular when we can't do it **********/
+
+/* Assume all files are regular. */
+
+int isregfile(char *filename) { return 1; }
+
+
+/************* Test stdout for being a terminal when we can't do it **********/
+
+static BOOL
+is_stdout_tty(void)
+{
+return FALSE;
+}
+
+
+#endif
+
+
+
+#ifndef HAVE_STRERROR
+/*************************************************
+*     Provide strerror() for non-ANSI libraries  *
+*************************************************/
+
+/* Some old-fashioned systems still around (e.g. SunOS4) don't have strerror()
+in their libraries, but can provide the same facility by this simple
+alternative function. */
+
+extern int   sys_nerr;
+extern char *sys_errlist[];
+
+char *
+strerror(int n)
+{
+if (n < 0 || n >= sys_nerr) return "unknown error number";
+return sys_errlist[n];
+}
+#endif /* HAVE_STRERROR */
+
+
+
+/*************************************************
+*             Find end of line                   *
+*************************************************/
+
+/* The length of the endline sequence that is found is set via lenptr. This may
+be zero at the very end of the file if there is no line-ending sequence there.
+
+Arguments:
+  p         current position in line
+  endptr    end of available data
+  lenptr    where to put the length of the eol sequence
+
+Returns:    pointer to the last byte of the line
+*/
+
+static char *
+end_of_line(char *p, char *endptr, int *lenptr)
+{
+switch(endlinetype)
+  {
+  default:      /* Just in case */
+  case EL_LF:
+  while (p < endptr && *p != '\n') p++;
+  if (p < endptr)
+    {
+    *lenptr = 1;
+    return p + 1;
+    }
+  *lenptr = 0;
+  return endptr;
+
+  case EL_CR:
+  while (p < endptr && *p != '\r') p++;
+  if (p < endptr)
+    {
+    *lenptr = 1;
+    return p + 1;
+    }
+  *lenptr = 0;
+  return endptr;
+
+  case EL_CRLF:
+  for (;;)
+    {
+    while (p < endptr && *p != '\r') p++;
+    if (++p >= endptr)
+      {
+      *lenptr = 0;
+      return endptr;
+      }
+    if (*p == '\n')
+      {
+      *lenptr = 2;
+      return p + 1;
+      }
+    }
+  break;
+
+  case EL_ANYCRLF:
+  while (p < endptr)
+    {
+    int extra = 0;
+    register int c = *((unsigned char *)p);
+
+    if (utf8 && c >= 0xc0)
+      {
+      int gcii, gcss;
+      extra = utf8_table4[c & 0x3f];  /* Number of additional bytes */
+      gcss = 6*extra;
+      c = (c & utf8_table3[extra]) << gcss;
+      for (gcii = 1; gcii <= extra; gcii++)
+        {
+        gcss -= 6;
+        c |= (p[gcii] & 0x3f) << gcss;
+        }
+      }
+
+    p += 1 + extra;
+
+    switch (c)
+      {
+      case 0x0a:    /* LF */
+      *lenptr = 1;
+      return p;
+
+      case 0x0d:    /* CR */
+      if (p < endptr && *p == 0x0a)
+        {
+        *lenptr = 2;
+        p++;
+        }
+      else *lenptr = 1;
+      return p;
+
+      default:
+      break;
+      }
+    }   /* End of loop for ANYCRLF case */
+
+  *lenptr = 0;  /* Must have hit the end */
+  return endptr;
+
+  case EL_ANY:
+  while (p < endptr)
+    {
+    int extra = 0;
+    register int c = *((unsigned char *)p);
+
+    if (utf8 && c >= 0xc0)
+      {
+      int gcii, gcss;
+      extra = utf8_table4[c & 0x3f];  /* Number of additional bytes */
+      gcss = 6*extra;
+      c = (c & utf8_table3[extra]) << gcss;
+      for (gcii = 1; gcii <= extra; gcii++)
+        {
+        gcss -= 6;
+        c |= (p[gcii] & 0x3f) << gcss;
+        }
+      }
+
+    p += 1 + extra;
+
+    switch (c)
+      {
+      case 0x0a:    /* LF */
+      case 0x0b:    /* VT */
+      case 0x0c:    /* FF */
+      *lenptr = 1;
+      return p;
+
+      case 0x0d:    /* CR */
+      if (p < endptr && *p == 0x0a)
+        {
+        *lenptr = 2;
+        p++;
+        }
+      else *lenptr = 1;
+      return p;
+
+      case 0x85:    /* NEL */
+      *lenptr = utf8? 2 : 1;
+      return p;
+
+      case 0x2028:  /* LS */
+      case 0x2029:  /* PS */
+      *lenptr = 3;
+      return p;
+
+      default:
+      break;
+      }
+    }   /* End of loop for ANY case */
+
+  *lenptr = 0;  /* Must have hit the end */
+  return endptr;
+  }     /* End of overall switch */
+}
+
+
+
+/*************************************************
+*         Find start of previous line            *
+*************************************************/
+
+/* This is called when looking back for before lines to print.
+
+Arguments:
+  p         start of the subsequent line
+  startptr  start of available data
+
+Returns:    pointer to the start of the previous line
+*/
+
+static char *
+previous_line(char *p, char *startptr)
+{
+switch(endlinetype)
+  {
+  default:      /* Just in case */
+  case EL_LF:
+  p--;
+  while (p > startptr && p[-1] != '\n') p--;
+  return p;
+
+  case EL_CR:
+  p--;
+  while (p > startptr && p[-1] != '\n') p--;
+  return p;
+
+  case EL_CRLF:
+  for (;;)
+    {
+    p -= 2;
+    while (p > startptr && p[-1] != '\n') p--;
+    if (p <= startptr + 1 || p[-2] == '\r') return p;
+    }
+  return p;   /* But control should never get here */
+
+  case EL_ANY:
+  case EL_ANYCRLF:
+  if (*(--p) == '\n' && p > startptr && p[-1] == '\r') p--;
+  if (utf8) while ((*p & 0xc0) == 0x80) p--;
+
+  while (p > startptr)
+    {
+    register int c;
+    char *pp = p - 1;
+
+    if (utf8)
+      {
+      int extra = 0;
+      while ((*pp & 0xc0) == 0x80) pp--;
+      c = *((unsigned char *)pp);
+      if (c >= 0xc0)
+        {
+        int gcii, gcss;
+        extra = utf8_table4[c & 0x3f];  /* Number of additional bytes */
+        gcss = 6*extra;
+        c = (c & utf8_table3[extra]) << gcss;
+        for (gcii = 1; gcii <= extra; gcii++)
+          {
+          gcss -= 6;
+          c |= (pp[gcii] & 0x3f) << gcss;
+          }
+        }
+      }
+    else c = *((unsigned char *)pp);
+
+    if (endlinetype == EL_ANYCRLF) switch (c)
+      {
+      case 0x0a:    /* LF */
+      case 0x0d:    /* CR */
+      return p;
+
+      default:
+      break;
+      }
+
+    else switch (c)
+      {
+      case 0x0a:    /* LF */
+      case 0x0b:    /* VT */
+      case 0x0c:    /* FF */
+      case 0x0d:    /* CR */
+      case 0x85:    /* NEL */
+      case 0x2028:  /* LS */
+      case 0x2029:  /* PS */
+      return p;
+
+      default:
+      break;
+      }
+
+    p = pp;  /* Back one character */
+    }        /* End of loop for ANY case */
+
+  return startptr;  /* Hit start of data */
+  }     /* End of overall switch */
+}
+
+
+
+
+
+/*************************************************
+*       Print the previous "after" lines         *
+*************************************************/
+
+/* This is called if we are about to lose said lines because of buffer filling,
+and at the end of the file. The data in the line is written using fwrite() so
+that a binary zero does not terminate it.
+
+Arguments:
+  lastmatchnumber   the number of the last matching line, plus one
+  lastmatchrestart  where we restarted after the last match
+  endptr            end of available data
+  printname         filename for printing
+
+Returns:            nothing
+*/
+
+static void do_after_lines(int lastmatchnumber, char *lastmatchrestart,
+  char *endptr, char *printname)
+{
+if (after_context > 0 && lastmatchnumber > 0)
+  {
+  int count = 0;
+  while (lastmatchrestart < endptr && count++ < after_context)
+    {
+    int ellength;
+    char *pp = lastmatchrestart;
+    if (printname != NULL) fprintf(stdout, "%s-", printname);
+    if (number) fprintf(stdout, "%d-", lastmatchnumber++);
+    pp = end_of_line(pp, endptr, &ellength);
+    fwrite(lastmatchrestart, 1, pp - lastmatchrestart, stdout);
+    lastmatchrestart = pp;
+    }
+  hyphenpending = TRUE;
+  }
+}
+
+
+
+/*************************************************
+*            Grep an individual file             *
+*************************************************/
+
+/* This is called from grep_or_recurse() below. It uses a buffer that is three
+times the value of MBUFTHIRD. The matching point is never allowed to stray into
+the top third of the buffer, thus keeping more of the file available for
+context printing or for multiline scanning. For large files, the pointer will
+be in the middle third most of the time, so the bottom third is available for
+"before" context printing.
+
+Arguments:
+  handle       the fopened FILE stream for a normal file
+               the gzFile pointer when reading is via libz
+               the BZFILE pointer when reading is via libbz2
+  frtype       FR_PLAIN, FR_LIBZ, or FR_LIBBZ2
+  printname    the file name if it is to be printed for each match
+               or NULL if the file name is not to be printed
+               it cannot be NULL if filenames[_nomatch]_only is set
+
+Returns:       0 if there was at least one match
+               1 otherwise (no matches)
+               2 if there is a read error on a .bz2 file
+*/
+
+static int
+pcregrep(void *handle, int frtype, char *printname)
+{
+int rc = 1;
+int linenumber = 1;
+int lastmatchnumber = 0;
+int count = 0;
+int filepos = 0;
+int offsets[99];
+char *lastmatchrestart = NULL;
+char buffer[3*MBUFTHIRD];
+char *ptr = buffer;
+char *endptr;
+size_t bufflength;
+BOOL endhyphenpending = FALSE;
+FILE *in = NULL;                    /* Ensure initialized */
+
+#ifdef SUPPORT_LIBZ
+gzFile ingz = NULL;
+#endif
+
+#ifdef SUPPORT_LIBBZ2
+BZFILE *inbz2 = NULL;
+#endif
+
+
+/* Do the first read into the start of the buffer and set up the pointer to end
+of what we have. In the case of libz, a non-zipped .gz file will be read as a
+plain file. However, if a .bz2 file isn't actually bzipped, the first read will
+fail. */
+
+#ifdef SUPPORT_LIBZ
+if (frtype == FR_LIBZ)
+  {
+  ingz = (gzFile)handle;
+  bufflength = gzread (ingz, buffer, 3*MBUFTHIRD);
+  }
+else
+#endif
+
+#ifdef SUPPORT_LIBBZ2
+if (frtype == FR_LIBBZ2)
+  {
+  inbz2 = (BZFILE *)handle;
+  bufflength = BZ2_bzread(inbz2, buffer, 3*MBUFTHIRD);
+  if ((int)bufflength < 0) return 2;   /* Gotcha: bufflength is size_t; */
+  }                                    /* without the cast it is unsigned. */
+else
+#endif
+
+  {
+  in = (FILE *)handle;
+  bufflength = fread(buffer, 1, 3*MBUFTHIRD, in);
+  }
+
+endptr = buffer + bufflength;
+
+/* Loop while the current pointer is not at the end of the file. For large
+files, endptr will be at the end of the buffer when we are in the middle of the
+file, but ptr will never get there, because as soon as it gets over 2/3 of the
+way, the buffer is shifted left and re-filled. */
+
+while (ptr < endptr)
+  {
+  int i, endlinelength;
+  int mrc = 0;
+  BOOL match = FALSE;
+  char *matchptr = ptr;
+  char *t = ptr;
+  size_t length, linelength;
+
+  /* At this point, ptr is at the start of a line. We need to find the length
+  of the subject string to pass to pcre_exec(). In multiline mode, it is the
+  length remainder of the data in the buffer. Otherwise, it is the length of
+  the next line. After matching, we always advance by the length of the next
+  line. In multiline mode the PCRE_FIRSTLINE option is used for compiling, so
+  that any match is constrained to be in the first line. */
+
+  t = end_of_line(t, endptr, &endlinelength);
+  linelength = t - ptr - endlinelength;
+  length = multiline? (size_t)(endptr - ptr) : linelength;
+
+  /* Extra processing for Jeffrey Friedl's debugging. */
+
+#ifdef JFRIEDL_DEBUG
+  if (jfriedl_XT || jfriedl_XR)
+  {
+      #include <sys/time.h>
+      #include <time.h>
+      struct timeval start_time, end_time;
+      struct timezone dummy;
+
+      if (jfriedl_XT)
+      {
+          unsigned long newlen = length * jfriedl_XT + strlen(jfriedl_prefix) + strlen(jfriedl_postfix);
+          const char *orig = ptr;
+          ptr = malloc(newlen + 1);
+          if (!ptr) {
+                  printf("out of memory");
+                  exit(2);
+          }
+          endptr = ptr;
+          strcpy(endptr, jfriedl_prefix); endptr += strlen(jfriedl_prefix);
+          for (i = 0; i < jfriedl_XT; i++) {
+                  strncpy(endptr, orig,  length);
+                  endptr += length;
+          }
+          strcpy(endptr, jfriedl_postfix); endptr += strlen(jfriedl_postfix);
+          length = newlen;
+      }
+
+      if (gettimeofday(&start_time, &dummy) != 0)
+              perror("bad gettimeofday");
+
+
+      for (i = 0; i < jfriedl_XR; i++)
+          match = (pcre_exec(pattern_list[0], hints_list[0], ptr, length, 0, 0, offsets, 99) >= 0);
+
+      if (gettimeofday(&end_time, &dummy) != 0)
+              perror("bad gettimeofday");
+
+      double delta = ((end_time.tv_sec + (end_time.tv_usec / 1000000.0))
+                      -
+                      (start_time.tv_sec + (start_time.tv_usec / 1000000.0)));
+
+      printf("%s TIMER[%.4f]\n", match ? "MATCH" : "FAIL", delta);
+      return 0;
+  }
+#endif
+
+  /* We come back here after a match when the -o option (only_matching) is set,
+  in order to find any further matches in the same line. */
+
+  ONLY_MATCHING_RESTART:
+
+  /* Run through all the patterns until one matches. Note that we don't include
+  the final newline in the subject string. */
+
+  for (i = 0; i < pattern_count; i++)
+    {
+    mrc = pcre_exec(pattern_list[i], hints_list[i], matchptr, length, 0, 0,
+      offsets, 99);
+    if (mrc >= 0) { match = TRUE; break; }
+    if (mrc != PCRE_ERROR_NOMATCH)
+      {
+      fprintf(stderr, "pcregrep: pcre_exec() error %d while matching ", mrc);
+      if (pattern_count > 1) fprintf(stderr, "pattern number %d to ", i+1);
+      fprintf(stderr, "this line:\n");
+      fwrite(matchptr, 1, linelength, stderr);  /* In case binary zero included */
+      fprintf(stderr, "\n");
+      if (error_count == 0 &&
+          (mrc == PCRE_ERROR_MATCHLIMIT || mrc == PCRE_ERROR_RECURSIONLIMIT))
+        {
+        fprintf(stderr, "pcregrep: error %d means that a resource limit "
+          "was exceeded\n", mrc);
+        fprintf(stderr, "pcregrep: check your regex for nested unlimited loops\n");
+        }
+      if (error_count++ > 20)
+        {
+        fprintf(stderr, "pcregrep: too many errors - abandoned\n");
+        exit(2);
+        }
+      match = invert;    /* No more matching; don't show the line again */
+      break;
+      }
+    }
+
+  /* If it's a match or a not-match (as required), do what's wanted. */
+
+  if (match != invert)
+    {
+    BOOL hyphenprinted = FALSE;
+
+    /* We've failed if we want a file that doesn't have any matches. */
+
+    if (filenames == FN_NOMATCH_ONLY) return 1;
+
+    /* Just count if just counting is wanted. */
+
+    if (count_only) count++;
+
+    /* If all we want is a file name, there is no need to scan any more lines
+    in the file. */
+
+    else if (filenames == FN_ONLY)
+      {
+      fprintf(stdout, "%s\n", printname);
+      return 0;
+      }
+
+    /* Likewise, if all we want is a yes/no answer. */
+
+    else if (quiet) return 0;
+
+    /* The --only-matching option prints just the substring that matched, and
+    the --file-offsets and --line-offsets options output offsets for the
+    matching substring (they both force --only-matching). None of these options
+    prints any context. Afterwards, adjust the start and length, and then jump
+    back to look for further matches in the same line. If we are in invert
+    mode, however, nothing is printed - this could be still useful because the
+    return code is set. */
+
+    else if (only_matching)
+      {
+      if (!invert)
+        {
+        if (printname != NULL) fprintf(stdout, "%s:", printname);
+        if (number) fprintf(stdout, "%d:", linenumber);
+        if (line_offsets)
+          fprintf(stdout, "%d,%d", (int)(matchptr + offsets[0] - ptr),
+            offsets[1] - offsets[0]);
+        else if (file_offsets)
+          fprintf(stdout, "%d,%d", (int)(filepos + matchptr + offsets[0] - ptr),
+            offsets[1] - offsets[0]);
+        else
+          fwrite(matchptr + offsets[0], 1, offsets[1] - offsets[0], stdout);
+        fprintf(stdout, "\n");
+        matchptr += offsets[1];
+        length -= offsets[1];
+        match = FALSE;
+        goto ONLY_MATCHING_RESTART;
+        }
+      }
+
+    /* This is the default case when none of the above options is set. We print
+    the matching lines(s), possibly preceded and/or followed by other lines of
+    context. */
+
+    else
+      {
+      /* See if there is a requirement to print some "after" lines from a
+      previous match. We never print any overlaps. */
+
+      if (after_context > 0 && lastmatchnumber > 0)
+        {
+        int ellength;
+        int linecount = 0;
+        char *p = lastmatchrestart;
+
+        while (p < ptr && linecount < after_context)
+          {
+          p = end_of_line(p, ptr, &ellength);
+          linecount++;
+          }
+
+        /* It is important to advance lastmatchrestart during this printing so
+        that it interacts correctly with any "before" printing below. Print
+        each line's data using fwrite() in case there are binary zeroes. */
+
+        while (lastmatchrestart < p)
+          {
+          char *pp = lastmatchrestart;
+          if (printname != NULL) fprintf(stdout, "%s-", printname);
+          if (number) fprintf(stdout, "%d-", lastmatchnumber++);
+          pp = end_of_line(pp, endptr, &ellength);
+          fwrite(lastmatchrestart, 1, pp - lastmatchrestart, stdout);
+          lastmatchrestart = pp;
+          }
+        if (lastmatchrestart != ptr) hyphenpending = TRUE;
+        }
+
+      /* If there were non-contiguous lines printed above, insert hyphens. */
+
+      if (hyphenpending)
+        {
+        fprintf(stdout, "--\n");
+        hyphenpending = FALSE;
+        hyphenprinted = TRUE;
+        }
+
+      /* See if there is a requirement to print some "before" lines for this
+      match. Again, don't print overlaps. */
+
+      if (before_context > 0)
+        {
+        int linecount = 0;
+        char *p = ptr;
+
+        while (p > buffer && (lastmatchnumber == 0 || p > lastmatchrestart) &&
+               linecount < before_context)
+          {
+          linecount++;
+          p = previous_line(p, buffer);
+          }
+
+        if (lastmatchnumber > 0 && p > lastmatchrestart && !hyphenprinted)
+          fprintf(stdout, "--\n");
+
+        while (p < ptr)
+          {
+          int ellength;
+          char *pp = p;
+          if (printname != NULL) fprintf(stdout, "%s-", printname);
+          if (number) fprintf(stdout, "%d-", linenumber - linecount--);
+          pp = end_of_line(pp, endptr, &ellength);
+          fwrite(p, 1, pp - p, stdout);
+          p = pp;
+          }
+        }
+
+      /* Now print the matching line(s); ensure we set hyphenpending at the end
+      of the file if any context lines are being output. */
+
+      if (after_context > 0 || before_context > 0)
+        endhyphenpending = TRUE;
+
+      if (printname != NULL) fprintf(stdout, "%s:", printname);
+      if (number) fprintf(stdout, "%d:", linenumber);
+
+      /* In multiline mode, we want to print to the end of the line in which
+      the end of the matched string is found, so we adjust linelength and the
+      line number appropriately, but only when there actually was a match
+      (invert not set). Because the PCRE_FIRSTLINE option is set, the start of
+      the match will always be before the first newline sequence. */
+
+      if (multiline)
+        {
+        int ellength;
+        char *endmatch = ptr;
+        if (!invert)
+          {
+          endmatch += offsets[1];
+          t = ptr;
+          while (t < endmatch)
+            {
+            t = end_of_line(t, endptr, &ellength);
+            if (t <= endmatch) linenumber++; else break;
+            }
+          }
+        endmatch = end_of_line(endmatch, endptr, &ellength);
+        linelength = endmatch - ptr - ellength;
+        }
+
+      /*** NOTE: Use only fwrite() to output the data line, so that binary
+      zeroes are treated as just another data character. */
+
+      /* This extra option, for Jeffrey Friedl's debugging requirements,
+      replaces the matched string, or a specific captured string if it exists,
+      with X. When this happens, colouring is ignored. */
+
+#ifdef JFRIEDL_DEBUG
+      if (S_arg >= 0 && S_arg < mrc)
+        {
+        int first = S_arg * 2;
+        int last  = first + 1;
+        fwrite(ptr, 1, offsets[first], stdout);
+        fprintf(stdout, "X");
+        fwrite(ptr + offsets[last], 1, linelength - offsets[last], stdout);
+        }
+      else
+#endif
+
+      /* We have to split the line(s) up if colouring. */
+
+      if (do_colour)
+        {
+        fwrite(ptr, 1, offsets[0], stdout);
+        fprintf(stdout, "%c[%sm", 0x1b, colour_string);
+        fwrite(ptr + offsets[0], 1, offsets[1] - offsets[0], stdout);
+        fprintf(stdout, "%c[00m", 0x1b);
+        fwrite(ptr + offsets[1], 1, (linelength + endlinelength) - offsets[1],
+          stdout);
+        }
+      else fwrite(ptr, 1, linelength + endlinelength, stdout);
+      }
+
+    /* End of doing what has to be done for a match */
+
+    rc = 0;    /* Had some success */
+
+    /* Remember where the last match happened for after_context. We remember
+    where we are about to restart, and that line's number. */
+
+    lastmatchrestart = ptr + linelength + endlinelength;
+    lastmatchnumber = linenumber + 1;
+    }
+
+  /* For a match in multiline inverted mode (which of course did not cause
+  anything to be printed), we have to move on to the end of the match before
+  proceeding. */
+
+  if (multiline && invert && match)
+    {
+    int ellength;
+    char *endmatch = ptr + offsets[1];
+    t = ptr;
+    while (t < endmatch)
+      {
+      t = end_of_line(t, endptr, &ellength);
+      if (t <= endmatch) linenumber++; else break;
+      }
+    endmatch = end_of_line(endmatch, endptr, &ellength);
+    linelength = endmatch - ptr - ellength;
+    }
+
+  /* Advance to after the newline and increment the line number. The file
+  offset to the current line is maintained in filepos. */
+
+  ptr += linelength + endlinelength;
+  filepos += linelength + endlinelength;
+  linenumber++;
+
+  /* If we haven't yet reached the end of the file (the buffer is full), and
+  the current point is in the top 1/3 of the buffer, slide the buffer down by
+  1/3 and refill it. Before we do this, if some unprinted "after" lines are
+  about to be lost, print them. */
+
+  if (bufflength >= sizeof(buffer) && ptr > buffer + 2*MBUFTHIRD)
+    {
+    if (after_context > 0 &&
+        lastmatchnumber > 0 &&
+        lastmatchrestart < buffer + MBUFTHIRD)
+      {
+      do_after_lines(lastmatchnumber, lastmatchrestart, endptr, printname);
+      lastmatchnumber = 0;
+      }
+
+    /* Now do the shuffle */
+
+    memmove(buffer, buffer + MBUFTHIRD, 2*MBUFTHIRD);
+    ptr -= MBUFTHIRD;
+
+#ifdef SUPPORT_LIBZ
+    if (frtype == FR_LIBZ)
+      bufflength = 2*MBUFTHIRD +
+        gzread (ingz, buffer + 2*MBUFTHIRD, MBUFTHIRD);
+    else
+#endif
+
+#ifdef SUPPORT_LIBBZ2
+    if (frtype == FR_LIBBZ2)
+      bufflength = 2*MBUFTHIRD +
+        BZ2_bzread(inbz2, buffer + 2*MBUFTHIRD, MBUFTHIRD);
+    else
+#endif
+
+    bufflength = 2*MBUFTHIRD + fread(buffer + 2*MBUFTHIRD, 1, MBUFTHIRD, in);
+
+    endptr = buffer + bufflength;
+
+    /* Adjust any last match point */
+
+    if (lastmatchnumber > 0) lastmatchrestart -= MBUFTHIRD;
+    }
+  }     /* Loop through the whole file */
+
+/* End of file; print final "after" lines if wanted; do_after_lines sets
+hyphenpending if it prints something. */
+
+if (!only_matching && !count_only)
+  {
+  do_after_lines(lastmatchnumber, lastmatchrestart, endptr, printname);
+  hyphenpending |= endhyphenpending;
+  }
+
+/* Print the file name if we are looking for those without matches and there
+were none. If we found a match, we won't have got this far. */
+
+if (filenames == FN_NOMATCH_ONLY)
+  {
+  fprintf(stdout, "%s\n", printname);
+  return 0;
+  }
+
+/* Print the match count if wanted */
+
+if (count_only)
+  {
+  if (printname != NULL) fprintf(stdout, "%s:", printname);
+  fprintf(stdout, "%d\n", count);
+  }
+
+return rc;
+}
+
+
+
+/*************************************************
+*     Grep a file or recurse into a directory    *
+*************************************************/
+
+/* Given a path name, if it's a directory, scan all the files if we are
+recursing; if it's a file, grep it.
+
+Arguments:
+  pathname          the path to investigate
+  dir_recurse       TRUE if recursing is wanted (-r or -drecurse)
+  only_one_at_top   TRUE if the path is the only one at toplevel
+
+Returns:   0 if there was at least one match
+           1 if there were no matches
+           2 there was some kind of error
+
+However, file opening failures are suppressed if "silent" is set.
+*/
+
+static int
+grep_or_recurse(char *pathname, BOOL dir_recurse, BOOL only_one_at_top)
+{
+int rc = 1;
+int sep;
+int frtype;
+int pathlen;
+void *handle;
+FILE *in = NULL;           /* Ensure initialized */
+
+#ifdef SUPPORT_LIBZ
+gzFile ingz = NULL;
+#endif
+
+#ifdef SUPPORT_LIBBZ2
+BZFILE *inbz2 = NULL;
+#endif
+
+/* If the file name is "-" we scan stdin */
+
+if (strcmp(pathname, "-") == 0)
+  {
+  return pcregrep(stdin, FR_PLAIN,
+    (filenames > FN_DEFAULT || (filenames == FN_DEFAULT && !only_one_at_top))?
+      stdin_name : NULL);
+  }
+
+/* If the file is a directory, skip if skipping or if we are recursing, scan
+each file and directory within it, subject to any include or exclude patterns
+that were set. The scanning code is localized so it can be made
+system-specific. */
+
+if ((sep = isdirectory(pathname)) != 0)
+  {
+  if (dee_action == dee_SKIP) return 1;
+  if (dee_action == dee_RECURSE)
+    {
+    char buffer[1024];
+    char *nextfile;
+    directory_type *dir = opendirectory(pathname);
+
+    if (dir == NULL)
+      {
+      if (!silent)
+        fprintf(stderr, "pcregrep: Failed to open directory %s: %s\n", pathname,
+          strerror(errno));
+      return 2;
+      }
+
+    while ((nextfile = readdirectory(dir)) != NULL)
+      {
+      int frc, nflen;
+      sprintf(buffer, "%.512s%c%.128s", pathname, sep, nextfile);
+      nflen = strlen(nextfile);
+
+      if (isdirectory(buffer))
+        {
+        if (exclude_dir_compiled != NULL &&
+            pcre_exec(exclude_dir_compiled, NULL, nextfile, nflen, 0, 0, NULL, 0) >= 0)
+          continue;
+
+        if (include_dir_compiled != NULL &&
+            pcre_exec(include_dir_compiled, NULL, nextfile, nflen, 0, 0, NULL, 0) < 0)
+          continue;
+        }
+      else
+        {
+        if (exclude_compiled != NULL &&
+            pcre_exec(exclude_compiled, NULL, nextfile, nflen, 0, 0, NULL, 0) >= 0)
+          continue;
+
+        if (include_compiled != NULL &&
+            pcre_exec(include_compiled, NULL, nextfile, nflen, 0, 0, NULL, 0) < 0)
+          continue;
+        }
+
+      frc = grep_or_recurse(buffer, dir_recurse, FALSE);
+      if (frc > 1) rc = frc;
+       else if (frc == 0 && rc == 1) rc = 0;
+      }
+
+    closedirectory(dir);
+    return rc;
+    }
+  }
+
+/* If the file is not a directory and not a regular file, skip it if that's
+been requested. */
+
+else if (!isregfile(pathname) && DEE_action == DEE_SKIP) return 1;
+
+/* Control reaches here if we have a regular file, or if we have a directory
+and recursion or skipping was not requested, or if we have anything else and
+skipping was not requested. The scan proceeds. If this is the first and only
+argument at top level, we don't show the file name, unless we are only showing
+the file name, or the filename was forced (-H). */
+
+pathlen = strlen(pathname);
+
+/* Open using zlib if it is supported and the file name ends with .gz. */
+
+#ifdef SUPPORT_LIBZ
+if (pathlen > 3 && strcmp(pathname + pathlen - 3, ".gz") == 0)
+  {
+  ingz = gzopen(pathname, "rb");
+  if (ingz == NULL)
+    {
+    if (!silent)
+      fprintf(stderr, "pcregrep: Failed to open %s: %s\n", pathname,
+        strerror(errno));
+    return 2;
+    }
+  handle = (void *)ingz;
+  frtype = FR_LIBZ;
+  }
+else
+#endif
+
+/* Otherwise open with bz2lib if it is supported and the name ends with .bz2. */
+
+#ifdef SUPPORT_LIBBZ2
+if (pathlen > 4 && strcmp(pathname + pathlen - 4, ".bz2") == 0)
+  {
+  inbz2 = BZ2_bzopen(pathname, "rb");
+  handle = (void *)inbz2;
+  frtype = FR_LIBBZ2;
+  }
+else
+#endif
+
+/* Otherwise use plain fopen(). The label is so that we can come back here if
+an attempt to read a .bz2 file indicates that it really is a plain file. */
+
+#ifdef SUPPORT_LIBBZ2
+PLAIN_FILE:
+#endif
+  {
+  in = fopen(pathname, "r");
+  handle = (void *)in;
+  frtype = FR_PLAIN;
+  }
+
+/* All the opening methods return errno when they fail. */
+
+if (handle == NULL)
+  {
+  if (!silent)
+    fprintf(stderr, "pcregrep: Failed to open %s: %s\n", pathname,
+      strerror(errno));
+  return 2;
+  }
+
+/* Now grep the file */
+
+rc = pcregrep(handle, frtype, (filenames > FN_DEFAULT ||
+  (filenames == FN_DEFAULT && !only_one_at_top))? pathname : NULL);
+
+/* Close in an appropriate manner. */
+
+#ifdef SUPPORT_LIBZ
+if (frtype == FR_LIBZ)
+  gzclose(ingz);
+else
+#endif
+
+/* If it is a .bz2 file and the result is 2, it means that the first attempt to
+read failed. If the error indicates that the file isn't in fact bzipped, try
+again as a normal file. */
+
+#ifdef SUPPORT_LIBBZ2
+if (frtype == FR_LIBBZ2)
+  {
+  if (rc == 2)
+    {
+    int errnum;
+    const char *err = BZ2_bzerror(inbz2, &errnum);
+    if (errnum == BZ_DATA_ERROR_MAGIC)
+      {
+      BZ2_bzclose(inbz2);
+      goto PLAIN_FILE;
+      }
+    else if (!silent)
+      fprintf(stderr, "pcregrep: Failed to read %s using bzlib: %s\n",
+        pathname, err);
+    }
+  BZ2_bzclose(inbz2);
+  }
+else
+#endif
+
+/* Normal file close */
+
+fclose(in);
+
+/* Pass back the yield from pcregrep(). */
+
+return rc;
+}
+
+
+
+
+/*************************************************
+*                Usage function                  *
+*************************************************/
+
+static int
+usage(int rc)
+{
+option_item *op;
+fprintf(stderr, "Usage: pcregrep [-");
+for (op = optionlist; op->one_char != 0; op++)
+  {
+  if (op->one_char > 0) fprintf(stderr, "%c", op->one_char);
+  }
+fprintf(stderr, "] [long options] [pattern] [files]\n");
+fprintf(stderr, "Type `pcregrep --help' for more information and the long "
+  "options.\n");
+return rc;
+}
+
+
+
+
+/*************************************************
+*                Help function                   *
+*************************************************/
+
+static void
+help(void)
+{
+option_item *op;
+
+printf("Usage: pcregrep [OPTION]... [PATTERN] [FILE1 FILE2 ...]\n");
+printf("Search for PATTERN in each FILE or standard input.\n");
+printf("PATTERN must be present if neither -e nor -f is used.\n");
+printf("\"-\" can be used as a file name to mean STDIN.\n");
+
+#ifdef SUPPORT_LIBZ
+printf("Files whose names end in .gz are read using zlib.\n");
+#endif
+
+#ifdef SUPPORT_LIBBZ2
+printf("Files whose names end in .bz2 are read using bzlib2.\n");
+#endif
+
+#if defined SUPPORT_LIBZ || defined SUPPORT_LIBBZ2
+printf("Other files and the standard input are read as plain files.\n\n");
+#else
+printf("All files are read as plain files, without any interpretation.\n\n");
+#endif
+
+printf("Example: pcregrep -i 'hello.*world' menu.h main.c\n\n");
+printf("Options:\n");
+
+for (op = optionlist; op->one_char != 0; op++)
+  {
+  int n;
+  char s[4];
+  if (op->one_char > 0) sprintf(s, "-%c,", op->one_char); else strcpy(s, "   ");
+  n = 30 - printf("  %s --%s", s, op->long_name);
+  if (n < 1) n = 1;
+  printf("%.*s%s\n", n, "                    ", op->help_text);
+  }
+
+printf("\nWhen reading patterns from a file instead of using a command line option,\n");
+printf("trailing white space is removed and blank lines are ignored.\n");
+printf("There is a maximum of %d patterns.\n", MAX_PATTERN_COUNT);
+
+printf("\nWith no FILEs, read standard input. If fewer than two FILEs given, assume -h.\n");
+printf("Exit status is 0 if any matches, 1 if no matches, and 2 if trouble.\n");
+}
+
+
+
+
+/*************************************************
+*    Handle a single-letter, no data option      *
+*************************************************/
+
+static int
+handle_option(int letter, int options)
+{
+switch(letter)
+  {
+  case N_FOFFSETS: file_offsets = TRUE; break;
+  case N_HELP: help(); exit(0);
+  case N_LOFFSETS: line_offsets = number = TRUE; break;
+  case 'c': count_only = TRUE; break;
+  case 'F': process_options |= PO_FIXED_STRINGS; break;
+  case 'H': filenames = FN_FORCE; break;
+  case 'h': filenames = FN_NONE; break;
+  case 'i': options |= PCRE_CASELESS; break;
+  case 'l': filenames = FN_ONLY; break;
+  case 'L': filenames = FN_NOMATCH_ONLY; break;
+  case 'M': multiline = TRUE; options |= PCRE_MULTILINE|PCRE_FIRSTLINE; break;
+  case 'n': number = TRUE; break;
+  case 'o': only_matching = TRUE; break;
+  case 'q': quiet = TRUE; break;
+  case 'r': dee_action = dee_RECURSE; break;
+  case 's': silent = TRUE; break;
+  case 'u': options |= PCRE_UTF8; utf8 = TRUE; break;
+  case 'v': invert = TRUE; break;
+  case 'w': process_options |= PO_WORD_MATCH; break;
+  case 'x': process_options |= PO_LINE_MATCH; break;
+
+  case 'V':
+  fprintf(stderr, "pcregrep version %s\n", pcre_version());
+  exit(0);
+  break;
+
+  default:
+  fprintf(stderr, "pcregrep: Unknown option -%c\n", letter);
+  exit(usage(2));
+  }
+
+return options;
+}
+
+
+
+
+/*************************************************
+*          Construct printed ordinal             *
+*************************************************/
+
+/* This turns a number into "1st", "3rd", etc. */
+
+static char *
+ordin(int n)
+{
+static char buffer[8];
+char *p = buffer;
+sprintf(p, "%d", n);
+while (*p != 0) p++;
+switch (n%10)
+  {
+  case 1: strcpy(p, "st"); break;
+  case 2: strcpy(p, "nd"); break;
+  case 3: strcpy(p, "rd"); break;
+  default: strcpy(p, "th"); break;
+  }
+return buffer;
+}
+
+
+
+/*************************************************
+*          Compile a single pattern              *
+*************************************************/
+
+/* When the -F option has been used, this is called for each substring.
+Otherwise it's called for each supplied pattern.
+
+Arguments:
+  pattern        the pattern string
+  options        the PCRE options
+  filename       the file name, or NULL for a command-line pattern
+  count          0 if this is the only command line pattern, or
+                 number of the command line pattern, or
+                 linenumber for a pattern from a file
+
+Returns:         TRUE on success, FALSE after an error
+*/
+
+static BOOL
+compile_single_pattern(char *pattern, int options, char *filename, int count)
+{
+char buffer[MBUFTHIRD + 16];
+const char *error;
+int errptr;
+
+if (pattern_count >= MAX_PATTERN_COUNT)
+  {
+  fprintf(stderr, "pcregrep: Too many %spatterns (max %d)\n",
+    (filename == NULL)? "command-line " : "", MAX_PATTERN_COUNT);
+  return FALSE;
+  }
+
+sprintf(buffer, "%s%.*s%s", prefix[process_options], MBUFTHIRD, pattern,
+  suffix[process_options]);
+pattern_list[pattern_count] =
+  pcre_compile(buffer, options, &error, &errptr, pcretables);
+if (pattern_list[pattern_count] != NULL)
+  {
+  pattern_count++;
+  return TRUE;
+  }
+
+/* Handle compile errors */
+
+errptr -= (int)strlen(prefix[process_options]);
+if (errptr > (int)strlen(pattern)) errptr = (int)strlen(pattern);
+
+if (filename == NULL)
+  {
+  if (count == 0)
+    fprintf(stderr, "pcregrep: Error in command-line regex "
+      "at offset %d: %s\n", errptr, error);
+  else
+    fprintf(stderr, "pcregrep: Error in %s command-line regex "
+      "at offset %d: %s\n", ordin(count), errptr, error);
+  }
+else
+  {
+  fprintf(stderr, "pcregrep: Error in regex in line %d of %s "
+    "at offset %d: %s\n", count, filename, errptr, error);
+  }
+
+return FALSE;
+}
+
+
+
+/*************************************************
+*           Compile one supplied pattern         *
+*************************************************/
+
+/* When the -F option has been used, each string may be a list of strings,
+separated by line breaks. They will be matched literally.
+
+Arguments:
+  pattern        the pattern string
+  options        the PCRE options
+  filename       the file name, or NULL for a command-line pattern
+  count          0 if this is the only command line pattern, or
+                 number of the command line pattern, or
+                 linenumber for a pattern from a file
+
+Returns:         TRUE on success, FALSE after an error
+*/
+
+static BOOL
+compile_pattern(char *pattern, int options, char *filename, int count)
+{
+if ((process_options & PO_FIXED_STRINGS) != 0)
+  {
+  char *eop = pattern + strlen(pattern);
+  char buffer[MBUFTHIRD];
+  for(;;)
+    {
+    int ellength;
+    char *p = end_of_line(pattern, eop, &ellength);
+    if (ellength == 0)
+      return compile_single_pattern(pattern, options, filename, count);
+    sprintf(buffer, "%.*s", (int)(p - pattern - ellength), pattern);
+    pattern = p;
+    if (!compile_single_pattern(buffer, options, filename, count))
+      return FALSE;
+    }
+  }
+else return compile_single_pattern(pattern, options, filename, count);
+}
+
+
+
+/*************************************************
+*                Main program                    *
+*************************************************/
+
+/* Returns 0 if something matched, 1 if nothing matched, 2 after an error. */
+
+int
+main(int argc, char **argv)
+{
+int i, j;
+int rc = 1;
+int pcre_options = 0;
+int cmd_pattern_count = 0;
+int hint_count = 0;
+int errptr;
+BOOL only_one_at_top;
+char *patterns[MAX_PATTERN_COUNT];
+const char *locale_from = "--locale";
+const char *error;
+
+/* Set the default line ending value from the default in the PCRE library;
+"lf", "cr", "crlf", and "any" are supported. Anything else is treated as "lf".
+*/
+
+(void)pcre_config(PCRE_CONFIG_NEWLINE, &i);
+switch(i)
+  {
+  default:                 newline = (char *)"lf"; break;
+  case '\r':               newline = (char *)"cr"; break;
+  case ('\r' << 8) | '\n': newline = (char *)"crlf"; break;
+  case -1:                 newline = (char *)"any"; break;
+  case -2:                 newline = (char *)"anycrlf"; break;
+  }
+
+/* Process the options */
+
+for (i = 1; i < argc; i++)
+  {
+  option_item *op = NULL;
+  char *option_data = (char *)"";    /* default to keep compiler happy */
+  BOOL longop;
+  BOOL longopwasequals = FALSE;
+
+  if (argv[i][0] != '-') break;
+
+  /* If we hit an argument that is just "-", it may be a reference to STDIN,
+  but only if we have previously had -e or -f to define the patterns. */
+
+  if (argv[i][1] == 0)
+    {
+    if (pattern_filename != NULL || pattern_count > 0) break;
+      else exit(usage(2));
+    }
+
+  /* Handle a long name option, or -- to terminate the options */
+
+  if (argv[i][1] == '-')
+    {
+    char *arg = argv[i] + 2;
+    char *argequals = strchr(arg, '=');
+
+    if (*arg == 0)    /* -- terminates options */
+      {
+      i++;
+      break;                /* out of the options-handling loop */
+      }
+
+    longop = TRUE;
+
+    /* Some long options have data that follows after =, for example file=name.
+    Some options have variations in the long name spelling: specifically, we
+    allow "regexp" because GNU grep allows it, though I personally go along
+    with Jeffrey Friedl and Larry Wall in preferring "regex" without the "p".
+    These options are entered in the table as "regex(p)". No option is in both
+    these categories, fortunately. */
+
+    for (op = optionlist; op->one_char != 0; op++)
+      {
+      char *opbra = strchr(op->long_name, '(');
+      char *equals = strchr(op->long_name, '=');
+      if (opbra == NULL)     /* Not a (p) case */
+        {
+        if (equals == NULL)  /* Not thing=data case */
+          {
+          if (strcmp(arg, op->long_name) == 0) break;
+          }
+        else                 /* Special case xxx=data */
+          {
+          int oplen = equals - op->long_name;
+          int arglen = (argequals == NULL)? (int)strlen(arg) : argequals - arg;
+          if (oplen == arglen && strncmp(arg, op->long_name, oplen) == 0)
+            {
+            option_data = arg + arglen;
+            if (*option_data == '=')
+              {
+              option_data++;
+              longopwasequals = TRUE;
+              }
+            break;
+            }
+          }
+        }
+      else                   /* Special case xxxx(p) */
+        {
+        char buff1[24];
+        char buff2[24];
+        int baselen = opbra - op->long_name;
+        sprintf(buff1, "%.*s", baselen, op->long_name);
+        sprintf(buff2, "%s%.*s", buff1,
+          (int)strlen(op->long_name) - baselen - 2, opbra + 1);
+        if (strcmp(arg, buff1) == 0 || strcmp(arg, buff2) == 0)
+          break;
+        }
+      }
+
+    if (op->one_char == 0)
+      {
+      fprintf(stderr, "pcregrep: Unknown option %s\n", argv[i]);
+      exit(usage(2));
+      }
+    }
+
+
+  /* Jeffrey Friedl's debugging harness uses these additional options which
+  are not in the right form for putting in the option table because they use
+  only one hyphen, yet are more than one character long. By putting them
+  separately here, they will not get displayed as part of the help() output,
+  but I don't think Jeffrey will care about that. */
+
+#ifdef JFRIEDL_DEBUG
+  else if (strcmp(argv[i], "-pre") == 0) {
+          jfriedl_prefix = argv[++i];
+          continue;
+  } else if (strcmp(argv[i], "-post") == 0) {
+          jfriedl_postfix = argv[++i];
+          continue;
+  } else if (strcmp(argv[i], "-XT") == 0) {
+          sscanf(argv[++i], "%d", &jfriedl_XT);
+          continue;
+  } else if (strcmp(argv[i], "-XR") == 0) {
+          sscanf(argv[++i], "%d", &jfriedl_XR);
+          continue;
+  }
+#endif
+
+
+  /* One-char options; many that have no data may be in a single argument; we
+  continue till we hit the last one or one that needs data. */
+
+  else
+    {
+    char *s = argv[i] + 1;
+    longop = FALSE;
+    while (*s != 0)
+      {
+      for (op = optionlist; op->one_char != 0; op++)
+        { if (*s == op->one_char) break; }
+      if (op->one_char == 0)
+        {
+        fprintf(stderr, "pcregrep: Unknown option letter '%c' in \"%s\"\n",
+          *s, argv[i]);
+        exit(usage(2));
+        }
+      if (op->type != OP_NODATA || s[1] == 0)
+        {
+        option_data = s+1;
+        break;
+        }
+      pcre_options = handle_option(*s++, pcre_options);
+      }
+    }
+
+  /* At this point we should have op pointing to a matched option. If the type
+  is NO_DATA, it means that there is no data, and the option might set
+  something in the PCRE options. */
+
+  if (op->type == OP_NODATA)
+    {
+    pcre_options = handle_option(op->one_char, pcre_options);
+    continue;
+    }
+
+  /* If the option type is OP_OP_STRING or OP_OP_NUMBER, it's an option that
+  either has a value or defaults to something. It cannot have data in a
+  separate item. At the moment, the only such options are "colo(u)r" and
+  Jeffrey Friedl's special -S debugging option. */
+
+  if (*option_data == 0 &&
+      (op->type == OP_OP_STRING || op->type == OP_OP_NUMBER))
+    {
+    switch (op->one_char)
+      {
+      case N_COLOUR:
+      colour_option = (char *)"auto";
+      break;
+#ifdef JFRIEDL_DEBUG
+      case 'S':
+      S_arg = 0;
+      break;
+#endif
+      }
+    continue;
+    }
+
+  /* Otherwise, find the data string for the option. */
+
+  if (*option_data == 0)
+    {
+    if (i >= argc - 1 || longopwasequals)
+      {
+      fprintf(stderr, "pcregrep: Data missing after %s\n", argv[i]);
+      exit(usage(2));
+      }
+    option_data = argv[++i];
+    }
+
+  /* If the option type is OP_PATLIST, it's the -e option, which can be called
+  multiple times to create a list of patterns. */
+
+  if (op->type == OP_PATLIST)
+    {
+    if (cmd_pattern_count >= MAX_PATTERN_COUNT)
+      {
+      fprintf(stderr, "pcregrep: Too many command-line patterns (max %d)\n",
+        MAX_PATTERN_COUNT);
+      return 2;
+      }
+    patterns[cmd_pattern_count++] = option_data;
+    }
+
+  /* Otherwise, deal with single string or numeric data values. */
+
+  else if (op->type != OP_NUMBER && op->type != OP_OP_NUMBER)
+    {
+    *((char **)op->dataptr) = option_data;
+    }
+  else
+    {
+    char *endptr;
+    int n = strtoul(option_data, &endptr, 10);
+    if (*endptr != 0)
+      {
+      if (longop)
+        {
+        char *equals = strchr(op->long_name, '=');
+        int nlen = (equals == NULL)? (int)strlen(op->long_name) :
+          equals - op->long_name;
+        fprintf(stderr, "pcregrep: Malformed number \"%s\" after --%.*s\n",
+          option_data, nlen, op->long_name);
+        }
+      else
+        fprintf(stderr, "pcregrep: Malformed number \"%s\" after -%c\n",
+          option_data, op->one_char);
+      exit(usage(2));
+      }
+    *((int *)op->dataptr) = n;
+    }
+  }
+
+/* Options have been decoded. If -C was used, its value is used as a default
+for -A and -B. */
+
+if (both_context > 0)
+  {
+  if (after_context == 0) after_context = both_context;
+  if (before_context == 0) before_context = both_context;
+  }
+
+/* Only one of --only-matching, --file-offsets, or --line-offsets is permitted.
+However, the latter two set the only_matching flag. */
+
+if ((only_matching && (file_offsets || line_offsets)) ||
+    (file_offsets && line_offsets))
+  {
+  fprintf(stderr, "pcregrep: Cannot mix --only-matching, --file-offsets "
+    "and/or --line-offsets\n");
+  exit(usage(2));
+  }
+
+if (file_offsets || line_offsets) only_matching = TRUE;
+
+/* If a locale has not been provided as an option, see if the LC_CTYPE or
+LC_ALL environment variable is set, and if so, use it. */
+
+if (locale == NULL)
+  {
+  locale = getenv("LC_ALL");
+  locale_from = "LCC_ALL";
+  }
+
+if (locale == NULL)
+  {
+  locale = getenv("LC_CTYPE");
+  locale_from = "LC_CTYPE";
+  }
+
+/* If a locale has been provided, set it, and generate the tables the PCRE
+needs. Otherwise, pcretables==NULL, which causes the use of default tables. */
+
+if (locale != NULL)
+  {
+  if (setlocale(LC_CTYPE, locale) == NULL)
+    {
+    fprintf(stderr, "pcregrep: Failed to set locale %s (obtained from %s)\n",
+      locale, locale_from);
+    return 2;
+    }
+  pcretables = pcre_maketables();
+  }
+
+/* Sort out colouring */
+
+if (colour_option != NULL && strcmp(colour_option, "never") != 0)
+  {
+  if (strcmp(colour_option, "always") == 0) do_colour = TRUE;
+  else if (strcmp(colour_option, "auto") == 0) do_colour = is_stdout_tty();
+  else
+    {
+    fprintf(stderr, "pcregrep: Unknown colour setting \"%s\"\n",
+      colour_option);
+    return 2;
+    }
+  if (do_colour)
+    {
+    char *cs = getenv("PCREGREP_COLOUR");
+    if (cs == NULL) cs = getenv("PCREGREP_COLOR");
+    if (cs != NULL) colour_string = cs;
+    }
+  }
+
+/* Interpret the newline type; the default settings are Unix-like. */
+
+if (strcmp(newline, "cr") == 0 || strcmp(newline, "CR") == 0)
+  {
+  pcre_options |= PCRE_NEWLINE_CR;
+  endlinetype = EL_CR;
+  }
+else if (strcmp(newline, "lf") == 0 || strcmp(newline, "LF") == 0)
+  {
+  pcre_options |= PCRE_NEWLINE_LF;
+  endlinetype = EL_LF;
+  }
+else if (strcmp(newline, "crlf") == 0 || strcmp(newline, "CRLF") == 0)
+  {
+  pcre_options |= PCRE_NEWLINE_CRLF;
+  endlinetype = EL_CRLF;
+  }
+else if (strcmp(newline, "any") == 0 || strcmp(newline, "ANY") == 0)
+  {
+  pcre_options |= PCRE_NEWLINE_ANY;
+  endlinetype = EL_ANY;
+  }
+else if (strcmp(newline, "anycrlf") == 0 || strcmp(newline, "ANYCRLF") == 0)
+  {
+  pcre_options |= PCRE_NEWLINE_ANYCRLF;
+  endlinetype = EL_ANYCRLF;
+  }
+else
+  {
+  fprintf(stderr, "pcregrep: Invalid newline specifier \"%s\"\n", newline);
+  return 2;
+  }
+
+/* Interpret the text values for -d and -D */
+
+if (dee_option != NULL)
+  {
+  if (strcmp(dee_option, "read") == 0) dee_action = dee_READ;
+  else if (strcmp(dee_option, "recurse") == 0) dee_action = dee_RECURSE;
+  else if (strcmp(dee_option, "skip") == 0) dee_action = dee_SKIP;
+  else
+    {
+    fprintf(stderr, "pcregrep: Invalid value \"%s\" for -d\n", dee_option);
+    return 2;
+    }
+  }
+
+if (DEE_option != NULL)
+  {
+  if (strcmp(DEE_option, "read") == 0) DEE_action = DEE_READ;
+  else if (strcmp(DEE_option, "skip") == 0) DEE_action = DEE_SKIP;
+  else
+    {
+    fprintf(stderr, "pcregrep: Invalid value \"%s\" for -D\n", DEE_option);
+    return 2;
+    }
+  }
+
+/* Check the values for Jeffrey Friedl's debugging options. */
+
+#ifdef JFRIEDL_DEBUG
+if (S_arg > 9)
+  {
+  fprintf(stderr, "pcregrep: bad value for -S option\n");
+  return 2;
+  }
+if (jfriedl_XT != 0 || jfriedl_XR != 0)
+  {
+  if (jfriedl_XT == 0) jfriedl_XT = 1;
+  if (jfriedl_XR == 0) jfriedl_XR = 1;
+  }
+#endif
+
+/* Get memory to store the pattern and hints lists. */
+
+pattern_list = (pcre **)malloc(MAX_PATTERN_COUNT * sizeof(pcre *));
+hints_list = (pcre_extra **)malloc(MAX_PATTERN_COUNT * sizeof(pcre_extra *));
+
+if (pattern_list == NULL || hints_list == NULL)
+  {
+  fprintf(stderr, "pcregrep: malloc failed\n");
+  goto EXIT2;
+  }
+
+/* If no patterns were provided by -e, and there is no file provided by -f,
+the first argument is the one and only pattern, and it must exist. */
+
+if (cmd_pattern_count == 0 && pattern_filename == NULL)
+  {
+  if (i >= argc) return usage(2);
+  patterns[cmd_pattern_count++] = argv[i++];
+  }
+
+/* Compile the patterns that were provided on the command line, either by
+multiple uses of -e or as a single unkeyed pattern. */
+
+for (j = 0; j < cmd_pattern_count; j++)
+  {
+  if (!compile_pattern(patterns[j], pcre_options, NULL,
+       (j == 0 && cmd_pattern_count == 1)? 0 : j + 1))
+    goto EXIT2;
+  }
+
+/* Compile the regular expressions that are provided in a file. */
+
+if (pattern_filename != NULL)
+  {
+  int linenumber = 0;
+  FILE *f;
+  char *filename;
+  char buffer[MBUFTHIRD];
+
+  if (strcmp(pattern_filename, "-") == 0)
+    {
+    f = stdin;
+    filename = stdin_name;
+    }
+  else
+    {
+    f = fopen(pattern_filename, "r");
+    if (f == NULL)
+      {
+      fprintf(stderr, "pcregrep: Failed to open %s: %s\n", pattern_filename,
+        strerror(errno));
+      goto EXIT2;
+      }
+    filename = pattern_filename;
+    }
+
+  while (fgets(buffer, MBUFTHIRD, f) != NULL)
+    {
+    char *s = buffer + (int)strlen(buffer);
+    while (s > buffer && isspace((unsigned char)(s[-1]))) s--;
+    *s = 0;
+    linenumber++;
+    if (buffer[0] == 0) continue;   /* Skip blank lines */
+    if (!compile_pattern(buffer, pcre_options, filename, linenumber))
+      goto EXIT2;
+    }
+
+  if (f != stdin) fclose(f);
+  }
+
+/* Study the regular expressions, as we will be running them many times */
+
+for (j = 0; j < pattern_count; j++)
+  {
+  hints_list[j] = pcre_study(pattern_list[j], 0, &error);
+  if (error != NULL)
+    {
+    char s[16];
+    if (pattern_count == 1) s[0] = 0; else sprintf(s, " number %d", j);
+    fprintf(stderr, "pcregrep: Error while studying regex%s: %s\n", s, error);
+    goto EXIT2;
+    }
+  hint_count++;
+  }
+
+/* If there are include or exclude patterns, compile them. */
+
+if (exclude_pattern != NULL)
+  {
+  exclude_compiled = pcre_compile(exclude_pattern, 0, &error, &errptr,
+    pcretables);
+  if (exclude_compiled == NULL)
+    {
+    fprintf(stderr, "pcregrep: Error in 'exclude' regex at offset %d: %s\n",
+      errptr, error);
+    goto EXIT2;
+    }
+  }
+
+if (include_pattern != NULL)
+  {
+  include_compiled = pcre_compile(include_pattern, 0, &error, &errptr,
+    pcretables);
+  if (include_compiled == NULL)
+    {
+    fprintf(stderr, "pcregrep: Error in 'include' regex at offset %d: %s\n",
+      errptr, error);
+    goto EXIT2;
+    }
+  }
+
+if (exclude_dir_pattern != NULL)
+  {
+  exclude_dir_compiled = pcre_compile(exclude_dir_pattern, 0, &error, &errptr,
+    pcretables);
+  if (exclude_dir_compiled == NULL)
+    {
+    fprintf(stderr, "pcregrep: Error in 'exclude_dir' regex at offset %d: %s\n",
+      errptr, error);
+    goto EXIT2;
+    }
+  }
+
+if (include_dir_pattern != NULL)
+  {
+  include_dir_compiled = pcre_compile(include_dir_pattern, 0, &error, &errptr,
+    pcretables);
+  if (include_dir_compiled == NULL)
+    {
+    fprintf(stderr, "pcregrep: Error in 'include_dir' regex at offset %d: %s\n",
+      errptr, error);
+    goto EXIT2;
+    }
+  }
+
+/* If there are no further arguments, do the business on stdin and exit. */
+
+if (i >= argc)
+  {
+  rc = pcregrep(stdin, FR_PLAIN, (filenames > FN_DEFAULT)? stdin_name : NULL);
+  goto EXIT;
+  }
+
+/* Otherwise, work through the remaining arguments as files or directories.
+Pass in the fact that there is only one argument at top level - this suppresses
+the file name if the argument is not a directory and filenames are not
+otherwise forced. */
+
+only_one_at_top = i == argc - 1;   /* Catch initial value of i */
+
+for (; i < argc; i++)
+  {
+  int frc = grep_or_recurse(argv[i], dee_action == dee_RECURSE,
+    only_one_at_top);
+  if (frc > 1) rc = frc;
+    else if (frc == 0 && rc == 1) rc = 0;
+  }
+
+EXIT:
+if (pattern_list != NULL)
+  {
+  for (i = 0; i < pattern_count; i++) free(pattern_list[i]);
+  free(pattern_list);
+  }
+if (hints_list != NULL)
+  {
+  for (i = 0; i < hint_count; i++) free(hints_list[i]);
+  free(hints_list);
+  }
+return rc;
+
+EXIT2:
+rc = 2;
+goto EXIT;
+}
+
+/* End of pcregrep */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcreposix.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,356 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* PCRE is a library of functions to support regular expressions whose syntax
+and semantics are as close as possible to those of the Perl 5 language.
+
+                       Written by Philip Hazel
+           Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+/* This module is a wrapper that provides a POSIX API to the underlying PCRE
+functions. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
+/* Ensure that the PCREPOSIX_EXP_xxx macros are set appropriately for
+compiling these functions. This must come before including pcreposix.h, where
+they are set for an application (using these functions) if they have not
+previously been set. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC)
+#  define PCREPOSIX_EXP_DECL extern __declspec(dllexport)
+#  define PCREPOSIX_EXP_DEFN __declspec(dllexport)
+#endif
+
+#include "pcre.h"
+#include "pcre_internal.h"
+#include "pcreposix.h"
+
+
+/* Table to translate PCRE compile time error codes into POSIX error codes. */
+
+static const int eint[] = {
+  0,           /* no error */
+  REG_EESCAPE, /* \ at end of pattern */
+  REG_EESCAPE, /* \c at end of pattern */
+  REG_EESCAPE, /* unrecognized character follows \ */
+  REG_BADBR,   /* numbers out of order in {} quantifier */
+  REG_BADBR,   /* number too big in {} quantifier */
+  REG_EBRACK,  /* missing terminating ] for character class */
+  REG_ECTYPE,  /* invalid escape sequence in character class */
+  REG_ERANGE,  /* range out of order in character class */
+  REG_BADRPT,  /* nothing to repeat */
+  REG_BADRPT,  /* operand of unlimited repeat could match the empty string */
+  REG_ASSERT,  /* internal error: unexpected repeat */
+  REG_BADPAT,  /* unrecognized character after (? */
+  REG_BADPAT,  /* POSIX named classes are supported only within a class */
+  REG_EPAREN,  /* missing ) */
+  REG_ESUBREG, /* reference to non-existent subpattern */
+  REG_INVARG,  /* erroffset passed as NULL */
+  REG_INVARG,  /* unknown option bit(s) set */
+  REG_EPAREN,  /* missing ) after comment */
+  REG_ESIZE,   /* parentheses nested too deeply */
+  REG_ESIZE,   /* regular expression too large */
+  REG_ESPACE,  /* failed to get memory */
+  REG_EPAREN,  /* unmatched brackets */
+  REG_ASSERT,  /* internal error: code overflow */
+  REG_BADPAT,  /* unrecognized character after (?< */
+  REG_BADPAT,  /* lookbehind assertion is not fixed length */
+  REG_BADPAT,  /* malformed number or name after (?( */
+  REG_BADPAT,  /* conditional group contains more than two branches */
+  REG_BADPAT,  /* assertion expected after (?( */
+  REG_BADPAT,  /* (?R or (?[+-]digits must be followed by ) */
+  REG_ECTYPE,  /* unknown POSIX class name */
+  REG_BADPAT,  /* POSIX collating elements are not supported */
+  REG_INVARG,  /* this version of PCRE is not compiled with PCRE_UTF8 support */
+  REG_BADPAT,  /* spare error */
+  REG_BADPAT,  /* character value in \x{...} sequence is too large */
+  REG_BADPAT,  /* invalid condition (?(0) */
+  REG_BADPAT,  /* \C not allowed in lookbehind assertion */
+  REG_EESCAPE, /* PCRE does not support \L, \l, \N, \U, or \u */
+  REG_BADPAT,  /* number after (?C is > 255 */
+  REG_BADPAT,  /* closing ) for (?C expected */
+  REG_BADPAT,  /* recursive call could loop indefinitely */
+  REG_BADPAT,  /* unrecognized character after (?P */
+  REG_BADPAT,  /* syntax error in subpattern name (missing terminator) */
+  REG_BADPAT,  /* two named subpatterns have the same name */
+  REG_BADPAT,  /* invalid UTF-8 string */
+  REG_BADPAT,  /* support for \P, \p, and \X has not been compiled */
+  REG_BADPAT,  /* malformed \P or \p sequence */
+  REG_BADPAT,  /* unknown property name after \P or \p */
+  REG_BADPAT,  /* subpattern name is too long (maximum 32 characters) */
+  REG_BADPAT,  /* too many named subpatterns (maximum 10,000) */
+  REG_BADPAT,  /* repeated subpattern is too long */
+  REG_BADPAT,  /* octal value is greater than \377 (not in UTF-8 mode) */
+  REG_BADPAT,  /* internal error: overran compiling workspace */
+  REG_BADPAT,  /* internal error: previously-checked referenced subpattern not found */
+  REG_BADPAT,  /* DEFINE group contains more than one branch */
+  REG_BADPAT,  /* repeating a DEFINE group is not allowed */
+  REG_INVARG,  /* inconsistent NEWLINE options */
+  REG_BADPAT,  /* \g is not followed followed by an (optionally braced) non-zero number */
+  REG_BADPAT,  /* (?+ or (?- must be followed by a non-zero number */
+  REG_BADPAT,  /* number is too big */
+  REG_BADPAT,  /* subpattern name expected */
+  REG_BADPAT,  /* digit expected after (?+ */
+  REG_BADPAT   /* ] is an invalid data character in JavaScript compatibility mode */
+};
+
+/* Table of texts corresponding to POSIX error codes */
+
+static const char *const pstring[] = {
+  "",                                /* Dummy for value 0 */
+  "internal error",                  /* REG_ASSERT */
+  "invalid repeat counts in {}",     /* BADBR      */
+  "pattern error",                   /* BADPAT     */
+  "? * + invalid",                   /* BADRPT     */
+  "unbalanced {}",                   /* EBRACE     */
+  "unbalanced []",                   /* EBRACK     */
+  "collation error - not relevant",  /* ECOLLATE   */
+  "bad class",                       /* ECTYPE     */
+  "bad escape sequence",             /* EESCAPE    */
+  "empty expression",                /* EMPTY      */
+  "unbalanced ()",                   /* EPAREN     */
+  "bad range inside []",             /* ERANGE     */
+  "expression too big",              /* ESIZE      */
+  "failed to get memory",            /* ESPACE     */
+  "bad back reference",              /* ESUBREG    */
+  "bad argument",                    /* INVARG     */
+  "match failed"                     /* NOMATCH    */
+};
+
+
+
+
+/*************************************************
+*          Translate error code to string        *
+*************************************************/
+
+PCREPOSIX_EXP_DEFN size_t PCRE_CALL_CONVENTION
+regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
+{
+const char *message, *addmessage;
+size_t length, addlength;
+
+message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
+  "unknown error code" : pstring[errcode];
+length = strlen(message) + 1;
+
+addmessage = " at offset ";
+addlength = (preg != NULL && (int)preg->re_erroffset != -1)?
+  strlen(addmessage) + 6 : 0;
+
+if (errbuf_size > 0)
+  {
+  if (addlength > 0 && errbuf_size >= length + addlength)
+    sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
+  else
+    {
+    strncpy(errbuf, message, errbuf_size - 1);
+    errbuf[errbuf_size-1] = 0;
+    }
+  }
+
+return length + addlength;
+}
+
+
+
+
+/*************************************************
+*           Free store held by a regex           *
+*************************************************/
+
+PCREPOSIX_EXP_DEFN void PCRE_CALL_CONVENTION
+regfree(regex_t *preg)
+{
+(pcre_free)(preg->re_pcre);
+}
+
+
+
+
+/*************************************************
+*            Compile a regular expression        *
+*************************************************/
+
+/*
+Arguments:
+  preg        points to a structure for recording the compiled expression
+  pattern     the pattern to compile
+  cflags      compilation flags
+
+Returns:      0 on success
+              various non-zero codes on failure
+*/
+
+PCREPOSIX_EXP_DEFN int PCRE_CALL_CONVENTION
+regcomp(regex_t *preg, const char *pattern, int cflags)
+{
+const char *errorptr;
+int erroffset;
+int errorcode;
+int options = 0;
+
+if ((cflags & REG_ICASE) != 0)   options |= PCRE_CASELESS;
+if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
+if ((cflags & REG_DOTALL) != 0)  options |= PCRE_DOTALL;
+if ((cflags & REG_NOSUB) != 0)   options |= PCRE_NO_AUTO_CAPTURE;
+if ((cflags & REG_UTF8) != 0)    options |= PCRE_UTF8;
+
+preg->re_pcre = pcre_compile2(pattern, options, &errorcode, &errorptr,
+  &erroffset, NULL);
+preg->re_erroffset = erroffset;
+
+if (preg->re_pcre == NULL) return eint[errorcode];
+
+preg->re_nsub = pcre_info((const pcre *)preg->re_pcre, NULL, NULL);
+return 0;
+}
+
+
+
+
+/*************************************************
+*              Match a regular expression        *
+*************************************************/
+
+/* Unfortunately, PCRE requires 3 ints of working space for each captured
+substring, so we have to get and release working store instead of just using
+the POSIX structures as was done in earlier releases when PCRE needed only 2
+ints. However, if the number of possible capturing brackets is small, use a
+block of store on the stack, to reduce the use of malloc/free. The threshold is
+in a macro that can be changed at configure time.
+
+If REG_NOSUB was specified at compile time, the PCRE_NO_AUTO_CAPTURE flag will
+be set. When this is the case, the nmatch and pmatch arguments are ignored, and
+the only result is yes/no/error. */
+
+PCREPOSIX_EXP_DEFN int PCRE_CALL_CONVENTION
+regexec(const regex_t *preg, const char *string, size_t nmatch,
+  regmatch_t pmatch[], int eflags)
+{
+int rc, so, eo;
+int options = 0;
+int *ovector = NULL;
+int small_ovector[POSIX_MALLOC_THRESHOLD * 3];
+BOOL allocated_ovector = FALSE;
+BOOL nosub =
+  (((const pcre *)preg->re_pcre)->options & PCRE_NO_AUTO_CAPTURE) != 0;
+
+if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
+if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
+
+((regex_t *)preg)->re_erroffset = (size_t)(-1);  /* Only has meaning after compile */
+
+/* When no string data is being returned, ensure that nmatch is zero.
+Otherwise, ensure the vector for holding the return data is large enough. */
+
+if (nosub) nmatch = 0;
+
+else if (nmatch > 0)
+  {
+  if (nmatch <= POSIX_MALLOC_THRESHOLD)
+    {
+    ovector = &(small_ovector[0]);
+    }
+  else
+    {
+    if (nmatch > INT_MAX/(sizeof(int) * 3)) return REG_ESPACE;
+    ovector = (int *)malloc(sizeof(int) * nmatch * 3);
+    if (ovector == NULL) return REG_ESPACE;
+    allocated_ovector = TRUE;
+    }
+  }
+
+/* REG_STARTEND is a BSD extension, to allow for non-NUL-terminated strings.
+The man page from OS X says "REG_STARTEND affects only the location of the
+string, not how it is matched". That is why the "so" value is used to bump the
+start location rather than being passed as a PCRE "starting offset". */
+
+if ((eflags & REG_STARTEND) != 0)
+  {
+  so = pmatch[0].rm_so;
+  eo = pmatch[0].rm_eo;
+  }
+else
+  {
+  so = 0;
+  eo = strlen(string);
+  }
+
+rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string + so, (eo - so),
+  0, options, ovector, nmatch * 3);
+
+if (rc == 0) rc = nmatch;    /* All captured slots were filled in */
+
+if (rc >= 0)
+  {
+  size_t i;
+  if (!nosub)
+    {
+    for (i = 0; i < (size_t)rc; i++)
+      {
+      pmatch[i].rm_so = ovector[i*2];
+      pmatch[i].rm_eo = ovector[i*2+1];
+      }
+    if (allocated_ovector) free(ovector);
+    for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
+    }
+  return 0;
+  }
+
+else
+  {
+  if (allocated_ovector) free(ovector);
+  switch(rc)
+    {
+    case PCRE_ERROR_NOMATCH: return REG_NOMATCH;
+    case PCRE_ERROR_NULL: return REG_INVARG;
+    case PCRE_ERROR_BADOPTION: return REG_INVARG;
+    case PCRE_ERROR_BADMAGIC: return REG_INVARG;
+    case PCRE_ERROR_UNKNOWN_NODE: return REG_ASSERT;
+    case PCRE_ERROR_NOMEMORY: return REG_ESPACE;
+    case PCRE_ERROR_MATCHLIMIT: return REG_ESPACE;
+    case PCRE_ERROR_BADUTF8: return REG_INVARG;
+    case PCRE_ERROR_BADUTF8_OFFSET: return REG_INVARG;
+    default: return REG_ASSERT;
+    }
+  }
+}
+
+/* End of pcreposix.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcreposix.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,143 @@
+/*************************************************
+*       Perl-Compatible Regular Expressions      *
+*************************************************/
+
+#ifndef _PCREPOSIX_H
+#define _PCREPOSIX_H
+
+/* This is the header for the POSIX wrapper interface to the PCRE Perl-
+Compatible Regular Expression library. It defines the things POSIX says should
+be there. I hope.
+
+            Copyright (c) 1997-2008 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+/* Have to include stdlib.h in order to ensure that size_t is defined. */
+
+#include <stdlib.h>
+
+/* Allow for C++ users */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Options, mostly defined by POSIX, but with a couple of extras. */
+
+#define REG_ICASE     0x0001
+#define REG_NEWLINE   0x0002
+#define REG_NOTBOL    0x0004
+#define REG_NOTEOL    0x0008
+#define REG_DOTALL    0x0010   /* NOT defined by POSIX. */
+#define REG_NOSUB     0x0020
+#define REG_UTF8      0x0040   /* NOT defined by POSIX. */
+#define REG_STARTEND  0x0080   /* BSD feature: pass subject string by so,eo */
+
+/* This is not used by PCRE, but by defining it we make it easier
+to slot PCRE into existing programs that make POSIX calls. */
+
+#define REG_EXTENDED  0
+
+/* Error values. Not all these are relevant or used by the wrapper. */
+
+enum {
+  REG_ASSERT = 1,  /* internal error ? */
+  REG_BADBR,       /* invalid repeat counts in {} */
+  REG_BADPAT,      /* pattern error */
+  REG_BADRPT,      /* ? * + invalid */
+  REG_EBRACE,      /* unbalanced {} */
+  REG_EBRACK,      /* unbalanced [] */
+  REG_ECOLLATE,    /* collation error - not relevant */
+  REG_ECTYPE,      /* bad class */
+  REG_EESCAPE,     /* bad escape sequence */
+  REG_EMPTY,       /* empty expression */
+  REG_EPAREN,      /* unbalanced () */
+  REG_ERANGE,      /* bad range inside [] */
+  REG_ESIZE,       /* expression too big */
+  REG_ESPACE,      /* failed to get memory */
+  REG_ESUBREG,     /* bad back reference */
+  REG_INVARG,      /* bad argument */
+  REG_NOMATCH      /* match failed */
+};
+
+
+/* The structure representing a compiled regular expression. */
+
+typedef struct {
+  void *re_pcre;
+  size_t re_nsub;
+  size_t re_erroffset;
+} regex_t;
+
+/* The structure in which a captured offset is returned. */
+
+typedef int regoff_t;
+
+typedef struct {
+  regoff_t rm_so;
+  regoff_t rm_eo;
+} regmatch_t;
+
+/* When an application links to a PCRE DLL in Windows, the symbols that are
+imported have to be identified as such. When building PCRE, the appropriate
+export settings are needed, and are set in pcreposix.c before including this
+file. */
+
+#if defined(_WIN32) && !defined(PCRE_STATIC) && !defined(PCREPOSIX_EXP_DECL)
+#  define PCREPOSIX_EXP_DECL  extern __declspec(dllimport)
+#  define PCREPOSIX_EXP_DEFN  __declspec(dllimport)
+#endif
+
+/* By default, we use the standard "extern" declarations. */
+
+#ifndef PCREPOSIX_EXP_DECL
+#  ifdef __cplusplus
+#    define PCREPOSIX_EXP_DECL  extern "C"
+#    define PCREPOSIX_EXP_DEFN  extern "C"
+#  else
+#    define PCREPOSIX_EXP_DECL  extern
+#    define PCREPOSIX_EXP_DEFN  extern
+#  endif
+#endif
+
+/* The functions */
+
+PCREPOSIX_EXP_DECL int regcomp(regex_t *, const char *, int);
+PCREPOSIX_EXP_DECL int regexec(const regex_t *, const char *, size_t,
+                     regmatch_t *, int);
+PCREPOSIX_EXP_DECL size_t regerror(int, const regex_t *, char *, size_t);
+PCREPOSIX_EXP_DECL void regfree(regex_t *);
+
+#ifdef __cplusplus
+}   /* extern "C" */
+#endif
+
+#endif /* End of pcreposix.h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/pcretest.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2476 @@
+/*************************************************
+*             PCRE testing program               *
+*************************************************/
+
+/* This program was hacked up as a tester for PCRE. I really should have
+written it more tidily in the first place. Will I ever learn? It has grown and
+been extended and consequently is now rather, er, *very* untidy in places.
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * 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.
+
+    * Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+*/
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <locale.h>
+#include <errno.h>
+
+#ifdef SUPPORT_LIBREADLINE
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <readline/readline.h>
+#include <readline/history.h>
+#endif
+
+
+/* A number of things vary for Windows builds. Originally, pcretest opened its
+input and output without "b"; then I was told that "b" was needed in some
+environments, so it was added for release 5.0 to both the input and output. (It
+makes no difference on Unix-like systems.) Later I was told that it is wrong
+for the input on Windows. I've now abstracted the modes into two macros that
+are set here, to make it easier to fiddle with them, and removed "b" from the
+input mode under Windows. */
+
+#if defined(_WIN32) || defined(WIN32)
+#include <io.h>                /* For _setmode() */
+#include <fcntl.h>             /* For _O_BINARY */
+#define INPUT_MODE   "r"
+#define OUTPUT_MODE  "wb"
+
+#define isatty _isatty         /* This is what Windows calls them, I'm told */
+#define fileno _fileno
+
+#else
+#include <sys/time.h>          /* These two includes are needed */
+#include <sys/resource.h>      /* for setrlimit(). */
+#define INPUT_MODE   "rb"
+#define OUTPUT_MODE  "wb"
+#endif
+
+
+/* We have to include pcre_internal.h because we need the internal info for
+displaying the results of pcre_study() and we also need to know about the
+internal macros, structures, and other internal data values; pcretest has
+"inside information" compared to a program that strictly follows the PCRE API.
+
+Although pcre_internal.h does itself include pcre.h, we explicitly include it
+here before pcre_internal.h so that the PCRE_EXP_xxx macros get set
+appropriately for an application, not for building PCRE. */
+
+#include "pcre.h"
+#include "pcre_internal.h"
+
+/* We need access to some of the data tables that PCRE uses. So as not to have
+to keep two copies, we include the source file here, changing the names of the
+external symbols to prevent clashes. */
+
+#define _pcre_ucp_gentype      ucp_gentype
+#define _pcre_utf8_table1      utf8_table1
+#define _pcre_utf8_table1_size utf8_table1_size
+#define _pcre_utf8_table2      utf8_table2
+#define _pcre_utf8_table3      utf8_table3
+#define _pcre_utf8_table4      utf8_table4
+#define _pcre_utt              utt
+#define _pcre_utt_size         utt_size
+#define _pcre_utt_names        utt_names
+#define _pcre_OP_lengths       OP_lengths
+
+#include "pcre_tables.c"
+
+/* We also need the pcre_printint() function for printing out compiled
+patterns. This function is in a separate file so that it can be included in
+pcre_compile.c when that module is compiled with debugging enabled.
+
+The definition of the macro PRINTABLE, which determines whether to print an
+output character as-is or as a hex value when showing compiled patterns, is
+contained in this file. We uses it here also, in cases when the locale has not
+been explicitly changed, so as to get consistent output from systems that
+differ in their output from isprint() even in the "C" locale. */
+
+#include "pcre_printint.src"
+
+#define PRINTHEX(c) (locale_set? isprint(c) : PRINTABLE(c))
+
+
+/* It is possible to compile this test program without including support for
+testing the POSIX interface, though this is not available via the standard
+Makefile. */
+
+#if !defined NOPOSIX
+#include "pcreposix.h"
+#endif
+
+/* It is also possible, for the benefit of the version currently imported into
+Exim, to build pcretest without support for UTF8 (define NOUTF8), without the
+interface to the DFA matcher (NODFA), and without the doublecheck of the old
+"info" function (define NOINFOCHECK). In fact, we automatically cut out the
+UTF8 support if PCRE is built without it. */
+
+#ifndef SUPPORT_UTF8
+#ifndef NOUTF8
+#define NOUTF8
+#endif
+#endif
+
+
+/* Other parameters */
+
+#ifndef CLOCKS_PER_SEC
+#ifdef CLK_TCK
+#define CLOCKS_PER_SEC CLK_TCK
+#else
+#define CLOCKS_PER_SEC 100
+#endif
+#endif
+
+/* This is the default loop count for timing. */
+
+#define LOOPREPEAT 500000
+
+/* Static variables */
+
+static FILE *outfile;
+static int log_store = 0;
+static int callout_count;
+static int callout_extra;
+static int callout_fail_count;
+static int callout_fail_id;
+static int debug_lengths;
+static int first_callout;
+static int locale_set = 0;
+static int show_malloc;
+static int use_utf8;
+static size_t gotten_store;
+
+/* The buffers grow automatically if very long input lines are encountered. */
+
+static int buffer_size = 50000;
+static uschar *buffer = NULL;
+static uschar *dbuffer = NULL;
+static uschar *pbuffer = NULL;
+
+
+
+/*************************************************
+*        Read or extend an input line            *
+*************************************************/
+
+/* Input lines are read into buffer, but both patterns and data lines can be
+continued over multiple input lines. In addition, if the buffer fills up, we
+want to automatically expand it so as to be able to handle extremely large
+lines that are needed for certain stress tests. When the input buffer is
+expanded, the other two buffers must also be expanded likewise, and the
+contents of pbuffer, which are a copy of the input for callouts, must be
+preserved (for when expansion happens for a data line). This is not the most
+optimal way of handling this, but hey, this is just a test program!
+
+Arguments:
+  f            the file to read
+  start        where in buffer to start (this *must* be within buffer)
+  prompt       for stdin or readline()
+
+Returns:       pointer to the start of new data
+               could be a copy of start, or could be moved
+               NULL if no data read and EOF reached
+*/
+
+static uschar *
+extend_inputline(FILE *f, uschar *start, const char *prompt)
+{
+uschar *here = start;
+
+for (;;)
+  {
+  int rlen = buffer_size - (here - buffer);
+
+  if (rlen > 1000)
+    {
+    int dlen;
+
+    /* If libreadline support is required, use readline() to read a line if the
+    input is a terminal. Note that readline() removes the trailing newline, so
+    we must put it back again, to be compatible with fgets(). */
+
+#ifdef SUPPORT_LIBREADLINE
+    if (isatty(fileno(f)))
+      {
+      size_t len;
+      char *s = readline(prompt);
+      if (s == NULL) return (here == start)? NULL : start;
+      len = strlen(s);
+      if (len > 0) add_history(s);
+      if (len > rlen - 1) len = rlen - 1;
+      memcpy(here, s, len);
+      here[len] = '\n';
+      here[len+1] = 0;
+      free(s);
+      }
+    else
+#endif
+
+    /* Read the next line by normal means, prompting if the file is stdin. */
+
+      {
+      if (f == stdin) printf(prompt);
+      if (fgets((char *)here, rlen,  f) == NULL)
+        return (here == start)? NULL : start;
+      }
+
+    dlen = (int)strlen((char *)here);
+    if (dlen > 0 && here[dlen - 1] == '\n') return start;
+    here += dlen;
+    }
+
+  else
+    {
+    int new_buffer_size = 2*buffer_size;
+    uschar *new_buffer = (unsigned char *)malloc(new_buffer_size);
+    uschar *new_dbuffer = (unsigned char *)malloc(new_buffer_size);
+    uschar *new_pbuffer = (unsigned char *)malloc(new_buffer_size);
+
+    if (new_buffer == NULL || new_dbuffer == NULL || new_pbuffer == NULL)
+      {
+      fprintf(stderr, "pcretest: malloc(%d) failed\n", new_buffer_size);
+      exit(1);
+      }
+
+    memcpy(new_buffer, buffer, buffer_size);
+    memcpy(new_pbuffer, pbuffer, buffer_size);
+
+    buffer_size = new_buffer_size;
+
+    start = new_buffer + (start - buffer);
+    here = new_buffer + (here - buffer);
+
+    free(buffer);
+    free(dbuffer);
+    free(pbuffer);
+
+    buffer = new_buffer;
+    dbuffer = new_dbuffer;
+    pbuffer = new_pbuffer;
+    }
+  }
+
+return NULL;  /* Control never gets here */
+}
+
+
+
+
+
+
+
+/*************************************************
+*          Read number from string               *
+*************************************************/
+
+/* We don't use strtoul() because SunOS4 doesn't have it. Rather than mess
+around with conditional compilation, just do the job by hand. It is only used
+for unpicking arguments, so just keep it simple.
+
+Arguments:
+  str           string to be converted
+  endptr        where to put the end pointer
+
+Returns:        the unsigned long
+*/
+
+static int
+get_value(unsigned char *str, unsigned char **endptr)
+{
+int result = 0;
+while(*str != 0 && isspace(*str)) str++;
+while (isdigit(*str)) result = result * 10 + (int)(*str++ - '0');
+*endptr = str;
+return(result);
+}
+
+
+
+
+/*************************************************
+*            Convert UTF-8 string to value       *
+*************************************************/
+
+/* This function takes one or more bytes that represents a UTF-8 character,
+and returns the value of the character.
+
+Argument:
+  utf8bytes   a pointer to the byte vector
+  vptr        a pointer to an int to receive the value
+
+Returns:      >  0 => the number of bytes consumed
+              -6 to 0 => malformed UTF-8 character at offset = (-return)
+*/
+
+#if !defined NOUTF8
+
+static int
+utf82ord(unsigned char *utf8bytes, int *vptr)
+{
+int c = *utf8bytes++;
+int d = c;
+int i, j, s;
+
+for (i = -1; i < 6; i++)               /* i is number of additional bytes */
+  {
+  if ((d & 0x80) == 0) break;
+  d <<= 1;
+  }
+
+if (i == -1) { *vptr = c; return 1; }  /* ascii character */
+if (i == 0 || i == 6) return 0;        /* invalid UTF-8 */
+
+/* i now has a value in the range 1-5 */
+
+s = 6*i;
+d = (c & utf8_table3[i]) << s;
+
+for (j = 0; j < i; j++)
+  {
+  c = *utf8bytes++;
+  if ((c & 0xc0) != 0x80) return -(j+1);
+  s -= 6;
+  d |= (c & 0x3f) << s;
+  }
+
+/* Check that encoding was the correct unique one */
+
+for (j = 0; j < utf8_table1_size; j++)
+  if (d <= utf8_table1[j]) break;
+if (j != i) return -(i+1);
+
+/* Valid value */
+
+*vptr = d;
+return i+1;
+}
+
+#endif
+
+
+
+/*************************************************
+*       Convert character value to UTF-8         *
+*************************************************/
+
+/* This function takes an integer value in the range 0 - 0x7fffffff
+and encodes it as a UTF-8 character in 0 to 6 bytes.
+
+Arguments:
+  cvalue     the character value
+  utf8bytes  pointer to buffer for result - at least 6 bytes long
+
+Returns:     number of characters placed in the buffer
+*/
+
+#if !defined NOUTF8
+
+static int
+ord2utf8(int cvalue, uschar *utf8bytes)
+{
+register int i, j;
+for (i = 0; i < utf8_table1_size; i++)
+  if (cvalue <= utf8_table1[i]) break;
+utf8bytes += i;
+for (j = i; j > 0; j--)
+ {
+ *utf8bytes-- = 0x80 | (cvalue & 0x3f);
+ cvalue >>= 6;
+ }
+*utf8bytes = utf8_table2[i] | cvalue;
+return i + 1;
+}
+
+#endif
+
+
+
+/*************************************************
+*             Print character string             *
+*************************************************/
+
+/* Character string printing function. Must handle UTF-8 strings in utf8
+mode. Yields number of characters printed. If handed a NULL file, just counts
+chars without printing. */
+
+static int pchars(unsigned char *p, int length, FILE *f)
+{
+int c = 0;
+int yield = 0;
+
+while (length-- > 0)
+  {
+#if !defined NOUTF8
+  if (use_utf8)
+    {
+    int rc = utf82ord(p, &c);
+
+    if (rc > 0 && rc <= length + 1)   /* Mustn't run over the end */
+      {
+      length -= rc - 1;
+      p += rc;
+      if (PRINTHEX(c))
+        {
+        if (f != NULL) fprintf(f, "%c", c);
+        yield++;
+        }
+      else
+        {
+        int n = 4;
+        if (f != NULL) fprintf(f, "\\x{%02x}", c);
+        yield += (n <= 0x000000ff)? 2 :
+                 (n <= 0x00000fff)? 3 :
+                 (n <= 0x0000ffff)? 4 :
+                 (n <= 0x000fffff)? 5 : 6;
+        }
+      continue;
+      }
+    }
+#endif
+
+   /* Not UTF-8, or malformed UTF-8  */
+
+  c = *p++;
+  if (PRINTHEX(c))
+    {
+    if (f != NULL) fprintf(f, "%c", c);
+    yield++;
+    }
+  else
+    {
+    if (f != NULL) fprintf(f, "\\x%02x", c);
+    yield += 4;
+    }
+  }
+
+return yield;
+}
+
+
+
+/*************************************************
+*              Callout function                  *
+*************************************************/
+
+/* Called from PCRE as a result of the (?C) item. We print out where we are in
+the match. Yield zero unless more callouts than the fail count, or the callout
+data is not zero. */
+
+static int callout(pcre_callout_block *cb)
+{
+FILE *f = (first_callout | callout_extra)? outfile : NULL;
+int i, pre_start, post_start, subject_length;
+
+if (callout_extra)
+  {
+  fprintf(f, "Callout %d: last capture = %d\n",
+    cb->callout_number, cb->capture_last);
+
+  for (i = 0; i < cb->capture_top * 2; i += 2)
+    {
+    if (cb->offset_vector[i] < 0)
+      fprintf(f, "%2d: <unset>\n", i/2);
+    else
+      {
+      fprintf(f, "%2d: ", i/2);
+      (void)pchars((unsigned char *)cb->subject + cb->offset_vector[i],
+        cb->offset_vector[i+1] - cb->offset_vector[i], f);
+      fprintf(f, "\n");
+      }
+    }
+  }
+
+/* Re-print the subject in canonical form, the first time or if giving full
+datails. On subsequent calls in the same match, we use pchars just to find the
+printed lengths of the substrings. */
+
+if (f != NULL) fprintf(f, "--->");
+
+pre_start = pchars((unsigned char *)cb->subject, cb->start_match, f);
+post_start = pchars((unsigned char *)(cb->subject + cb->start_match),
+  cb->current_position - cb->start_match, f);
+
+subject_length = pchars((unsigned char *)cb->subject, cb->subject_length, NULL);
+
+(void)pchars((unsigned char *)(cb->subject + cb->current_position),
+  cb->subject_length - cb->current_position, f);
+
+if (f != NULL) fprintf(f, "\n");
+
+/* Always print appropriate indicators, with callout number if not already
+shown. For automatic callouts, show the pattern offset. */
+
+if (cb->callout_number == 255)
+  {
+  fprintf(outfile, "%+3d ", cb->pattern_position);
+  if (cb->pattern_position > 99) fprintf(outfile, "\n    ");
+  }
+else
+  {
+  if (callout_extra) fprintf(outfile, "    ");
+    else fprintf(outfile, "%3d ", cb->callout_number);
+  }
+
+for (i = 0; i < pre_start; i++) fprintf(outfile, " ");
+fprintf(outfile, "^");
+
+if (post_start > 0)
+  {
+  for (i = 0; i < post_start - 1; i++) fprintf(outfile, " ");
+  fprintf(outfile, "^");
+  }
+
+for (i = 0; i < subject_length - pre_start - post_start + 4; i++)
+  fprintf(outfile, " ");
+
+fprintf(outfile, "%.*s", (cb->next_item_length == 0)? 1 : cb->next_item_length,
+  pbuffer + cb->pattern_position);
+
+fprintf(outfile, "\n");
+first_callout = 0;
+
+if (cb->callout_data != NULL)
+  {
+  int callout_data = *((int *)(cb->callout_data));
+  if (callout_data != 0)
+    {
+    fprintf(outfile, "Callout data = %d\n", callout_data);
+    return callout_data;
+    }
+  }
+
+return (cb->callout_number != callout_fail_id)? 0 :
+       (++callout_count >= callout_fail_count)? 1 : 0;
+}
+
+
+/*************************************************
+*            Local malloc functions              *
+*************************************************/
+
+/* Alternative malloc function, to test functionality and show the size of the
+compiled re. */
+
+static void *new_malloc(size_t size)
+{
+void *block = malloc(size);
+gotten_store = size;
+if (show_malloc)
+  fprintf(outfile, "malloc       %3d %p\n", (int)size, block);
+return block;
+}
+
+static void new_free(void *block)
+{
+if (show_malloc)
+  fprintf(outfile, "free             %p\n", block);
+free(block);
+}
+
+
+/* For recursion malloc/free, to test stacking calls */
+
+static void *stack_malloc(size_t size)
+{
+void *block = malloc(size);
+if (show_malloc)
+  fprintf(outfile, "stack_malloc %3d %p\n", (int)size, block);
+return block;
+}
+
+static void stack_free(void *block)
+{
+if (show_malloc)
+  fprintf(outfile, "stack_free       %p\n", block);
+free(block);
+}
+
+
+/*************************************************
+*          Call pcre_fullinfo()                  *
+*************************************************/
+
+/* Get one piece of information from the pcre_fullinfo() function */
+
+static void new_info(pcre *re, pcre_extra *study, int option, void *ptr)
+{
+int rc;
+if ((rc = pcre_fullinfo(re, study, option, ptr)) < 0)
+  fprintf(outfile, "Error %d from pcre_fullinfo(%d)\n", rc, option);
+}
+
+
+
+/*************************************************
+*         Byte flipping function                 *
+*************************************************/
+
+static unsigned long int
+byteflip(unsigned long int value, int n)
+{
+if (n == 2) return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);
+return ((value & 0x000000ff) << 24) |
+       ((value & 0x0000ff00) <<  8) |
+       ((value & 0x00ff0000) >>  8) |
+       ((value & 0xff000000) >> 24);
+}
+
+
+
+
+/*************************************************
+*        Check match or recursion limit          *
+*************************************************/
+
+static int
+check_match_limit(pcre *re, pcre_extra *extra, uschar *bptr, int len,
+  int start_offset, int options, int *use_offsets, int use_size_offsets,
+  int flag, unsigned long int *limit, int errnumber, const char *msg)
+{
+int count;
+int min = 0;
+int mid = 64;
+int max = -1;
+
+extra->flags |= flag;
+
+for (;;)
+  {
+  *limit = mid;
+
+  count = pcre_exec(re, extra, (char *)bptr, len, start_offset, options,
+    use_offsets, use_size_offsets);
+
+  if (count == errnumber)
+    {
+    /* fprintf(outfile, "Testing %s limit = %d\n", msg, mid); */
+    min = mid;
+    mid = (mid == max - 1)? max : (max > 0)? (min + max)/2 : mid*2;
+    }
+
+  else if (count >= 0 || count == PCRE_ERROR_NOMATCH ||
+                         count == PCRE_ERROR_PARTIAL)
+    {
+    if (mid == min + 1)
+      {
+      fprintf(outfile, "Minimum %s limit = %d\n", msg, mid);
+      break;
+      }
+    /* fprintf(outfile, "Testing %s limit = %d\n", msg, mid); */
+    max = mid;
+    mid = (min + mid)/2;
+    }
+  else break;    /* Some other error */
+  }
+
+extra->flags &= ~flag;
+return count;
+}
+
+
+
+/*************************************************
+*         Case-independent strncmp() function    *
+*************************************************/
+
+/*
+Arguments:
+  s         first string
+  t         second string
+  n         number of characters to compare
+
+Returns:    < 0, = 0, or > 0, according to the comparison
+*/
+
+static int
+strncmpic(uschar *s, uschar *t, int n)
+{
+while (n--)
+  {
+  int c = tolower(*s++) - tolower(*t++);
+  if (c) return c;
+  }
+return 0;
+}
+
+
+
+/*************************************************
+*         Check newline indicator                *
+*************************************************/
+
+/* This is used both at compile and run-time to check for <xxx> escapes, where
+xxx is LF, CR, CRLF, ANYCRLF, or ANY. Print a message and return 0 if there is
+no match.
+
+Arguments:
+  p           points after the leading '<'
+  f           file for error message
+
+Returns:      appropriate PCRE_NEWLINE_xxx flags, or 0
+*/
+
+static int
+check_newline(uschar *p, FILE *f)
+{
+if (strncmpic(p, (uschar *)"cr>", 3) == 0) return PCRE_NEWLINE_CR;
+if (strncmpic(p, (uschar *)"lf>", 3) == 0) return PCRE_NEWLINE_LF;
+if (strncmpic(p, (uschar *)"crlf>", 5) == 0) return PCRE_NEWLINE_CRLF;
+if (strncmpic(p, (uschar *)"anycrlf>", 8) == 0) return PCRE_NEWLINE_ANYCRLF;
+if (strncmpic(p, (uschar *)"any>", 4) == 0) return PCRE_NEWLINE_ANY;
+if (strncmpic(p, (uschar *)"bsr_anycrlf>", 12) == 0) return PCRE_BSR_ANYCRLF;
+if (strncmpic(p, (uschar *)"bsr_unicode>", 12) == 0) return PCRE_BSR_UNICODE;
+fprintf(f, "Unknown newline type at: <%s\n", p);
+return 0;
+}
+
+
+
+/*************************************************
+*             Usage function                     *
+*************************************************/
+
+static void
+usage(void)
+{
+printf("Usage:     pcretest [options] [<input file> [<output file>]]\n\n");
+printf("Input and output default to stdin and stdout.\n");
+#ifdef SUPPORT_LIBREADLINE
+printf("If input is a terminal, readline() is used to read from it.\n");
+#else
+printf("This version of pcretest is not linked with readline().\n");
+#endif
+printf("\nOptions:\n");
+printf("  -b       show compiled code (bytecode)\n");
+printf("  -C       show PCRE compile-time options and exit\n");
+printf("  -d       debug: show compiled code and information (-b and -i)\n");
+#if !defined NODFA
+printf("  -dfa     force DFA matching for all subjects\n");
+#endif
+printf("  -help    show usage information\n");
+printf("  -i       show information about compiled patterns\n"
+       "  -m       output memory used information\n"
+       "  -o <n>   set size of offsets vector to <n>\n");
+#if !defined NOPOSIX
+printf("  -p       use POSIX interface\n");
+#endif
+printf("  -q       quiet: do not output PCRE version number at start\n");
+printf("  -S <n>   set stack size to <n> megabytes\n");
+printf("  -s       output store (memory) used information\n"
+       "  -t       time compilation and execution\n");
+printf("  -t <n>   time compilation and execution, repeating <n> times\n");
+printf("  -tm      time execution (matching) only\n");
+printf("  -tm <n>  time execution (matching) only, repeating <n> times\n");
+}
+
+
+
+/*************************************************
+*                Main Program                    *
+*************************************************/
+
+/* Read lines from named file or stdin and write to named file or stdout; lines
+consist of a regular expression, in delimiters and optionally followed by
+options, followed by a set of test data, terminated by an empty line. */
+
+int main(int argc, char **argv)
+{
+FILE *infile = stdin;
+int options = 0;
+int study_options = 0;
+int op = 1;
+int timeit = 0;
+int timeitm = 0;
+int showinfo = 0;
+int showstore = 0;
+int quiet = 0;
+int size_offsets = 45;
+int size_offsets_max;
+int *offsets = NULL;
+#if !defined NOPOSIX
+int posix = 0;
+#endif
+int debug = 0;
+int done = 0;
+int all_use_dfa = 0;
+int yield = 0;
+int stack_size;
+
+/* These vectors store, end-to-end, a list of captured substring names. Assume
+that 1024 is plenty long enough for the few names we'll be testing. */
+
+uschar copynames[1024];
+uschar getnames[1024];
+
+uschar *copynamesptr;
+uschar *getnamesptr;
+
+/* Get buffers from malloc() so that Electric Fence will check their misuse
+when I am debugging. They grow automatically when very long lines are read. */
+
+buffer = (unsigned char *)malloc(buffer_size);
+dbuffer = (unsigned char *)malloc(buffer_size);
+pbuffer = (unsigned char *)malloc(buffer_size);
+
+/* The outfile variable is static so that new_malloc can use it. */
+
+outfile = stdout;
+
+/* The following  _setmode() stuff is some Windows magic that tells its runtime
+library to translate CRLF into a single LF character. At least, that's what
+I've been told: never having used Windows I take this all on trust. Originally
+it set 0x8000, but then I was advised that _O_BINARY was better. */
+
+#if defined(_WIN32) || defined(WIN32)
+_setmode( _fileno( stdout ), _O_BINARY );
+#endif
+
+/* Scan options */
+
+while (argc > 1 && argv[op][0] == '-')
+  {
+  unsigned char *endptr;
+
+  if (strcmp(argv[op], "-s") == 0 || strcmp(argv[op], "-m") == 0)
+    showstore = 1;
+  else if (strcmp(argv[op], "-q") == 0) quiet = 1;
+  else if (strcmp(argv[op], "-b") == 0) debug = 1;
+  else if (strcmp(argv[op], "-i") == 0) showinfo = 1;
+  else if (strcmp(argv[op], "-d") == 0) showinfo = debug = 1;
+#if !defined NODFA
+  else if (strcmp(argv[op], "-dfa") == 0) all_use_dfa = 1;
+#endif
+  else if (strcmp(argv[op], "-o") == 0 && argc > 2 &&
+      ((size_offsets = get_value((unsigned char *)argv[op+1], &endptr)),
+        *endptr == 0))
+    {
+    op++;
+    argc--;
+    }
+  else if (strcmp(argv[op], "-t") == 0 || strcmp(argv[op], "-tm") == 0)
+    {
+    int both = argv[op][2] == 0;
+    int temp;
+    if (argc > 2 && (temp = get_value((unsigned char *)argv[op+1], &endptr),
+                     *endptr == 0))
+      {
+      timeitm = temp;
+      op++;
+      argc--;
+      }
+    else timeitm = LOOPREPEAT;
+    if (both) timeit = timeitm;
+    }
+  else if (strcmp(argv[op], "-S") == 0 && argc > 2 &&
+      ((stack_size = get_value((unsigned char *)argv[op+1], &endptr)),
+        *endptr == 0))
+    {
+#if defined(_WIN32) || defined(WIN32)
+    printf("PCRE: -S not supported on this OS\n");
+    exit(1);
+#else
+    int rc;
+    struct rlimit rlim;
+    getrlimit(RLIMIT_STACK, &rlim);
+    rlim.rlim_cur = stack_size * 1024 * 1024;
+    rc = setrlimit(RLIMIT_STACK, &rlim);
+    if (rc != 0)
+      {
+    printf("PCRE: setrlimit() failed with error %d\n", rc);
+    exit(1);
+      }
+    op++;
+    argc--;
+#endif
+    }
+#if !defined NOPOSIX
+  else if (strcmp(argv[op], "-p") == 0) posix = 1;
+#endif
+  else if (strcmp(argv[op], "-C") == 0)
+    {
+    int rc;
+    printf("PCRE version %s\n", pcre_version());
+    printf("Compiled with\n");
+    (void)pcre_config(PCRE_CONFIG_UTF8, &rc);
+    printf("  %sUTF-8 support\n", rc? "" : "No ");
+    (void)pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &rc);
+    printf("  %sUnicode properties support\n", rc? "" : "No ");
+    (void)pcre_config(PCRE_CONFIG_NEWLINE, &rc);
+    printf("  Newline sequence is %s\n", (rc == '\r')? "CR" :
+      (rc == '\n')? "LF" : (rc == ('\r'<<8 | '\n'))? "CRLF" :
+      (rc == -2)? "ANYCRLF" :
+      (rc == -1)? "ANY" : "???");
+    (void)pcre_config(PCRE_CONFIG_BSR, &rc);
+    printf("  \\R matches %s\n", rc? "CR, LF, or CRLF only" :
+                                     "all Unicode newlines");
+    (void)pcre_config(PCRE_CONFIG_LINK_SIZE, &rc);
+    printf("  Internal link size = %d\n", rc);
+    (void)pcre_config(PCRE_CONFIG_POSIX_MALLOC_THRESHOLD, &rc);
+    printf("  POSIX malloc threshold = %d\n", rc);
+    (void)pcre_config(PCRE_CONFIG_MATCH_LIMIT, &rc);
+    printf("  Default match limit = %d\n", rc);
+    (void)pcre_config(PCRE_CONFIG_MATCH_LIMIT_RECURSION, &rc);
+    printf("  Default recursion depth limit = %d\n", rc);
+    (void)pcre_config(PCRE_CONFIG_STACKRECURSE, &rc);
+    printf("  Match recursion uses %s\n", rc? "stack" : "heap");
+    goto EXIT;
+    }
+  else if (strcmp(argv[op], "-help") == 0 ||
+           strcmp(argv[op], "--help") == 0)
+    {
+    usage();
+    goto EXIT;
+    }
+  else
+    {
+    printf("** Unknown or malformed option %s\n", argv[op]);
+    usage();
+    yield = 1;
+    goto EXIT;
+    }
+  op++;
+  argc--;
+  }
+
+/* Get the store for the offsets vector, and remember what it was */
+
+size_offsets_max = size_offsets;
+offsets = (int *)malloc(size_offsets_max * sizeof(int));
+if (offsets == NULL)
+  {
+  printf("** Failed to get %d bytes of memory for offsets vector\n",
+    (int)(size_offsets_max * sizeof(int)));
+  yield = 1;
+  goto EXIT;
+  }
+
+/* Sort out the input and output files */
+
+if (argc > 1)
+  {
+  infile = fopen(argv[op], INPUT_MODE);
+  if (infile == NULL)
+    {
+    printf("** Failed to open %s\n", argv[op]);
+    yield = 1;
+    goto EXIT;
+    }
+  }
+
+if (argc > 2)
+  {
+  outfile = fopen(argv[op+1], OUTPUT_MODE);
+  if (outfile == NULL)
+    {
+    printf("** Failed to open %s\n", argv[op+1]);
+    yield = 1;
+    goto EXIT;
+    }
+  }
+
+/* Set alternative malloc function */
+
+pcre_malloc = new_malloc;
+pcre_free = new_free;
+pcre_stack_malloc = stack_malloc;
+pcre_stack_free = stack_free;
+
+/* Heading line unless quiet, then prompt for first regex if stdin */
+
+if (!quiet) fprintf(outfile, "PCRE version %s\n\n", pcre_version());
+
+/* Main loop */
+
+while (!done)
+  {
+  pcre *re = NULL;
+  pcre_extra *extra = NULL;
+
+#if !defined NOPOSIX  /* There are still compilers that require no indent */
+  regex_t preg;
+  int do_posix = 0;
+#endif
+
+  const char *error;
+  unsigned char *p, *pp, *ppp;
+  unsigned char *to_file = NULL;
+  const unsigned char *tables = NULL;
+  unsigned long int true_size, true_study_size = 0;
+  size_t size, regex_gotten_store;
+  int do_study = 0;
+  int do_debug = debug;
+  int do_G = 0;
+  int do_g = 0;
+  int do_showinfo = showinfo;
+  int do_showrest = 0;
+  int do_flip = 0;
+  int erroroffset, len, delimiter, poffset;
+
+  use_utf8 = 0;
+  debug_lengths = 1;
+
+  if (extend_inputline(infile, buffer, "  re> ") == NULL) break;
+  if (infile != stdin) fprintf(outfile, "%s", (char *)buffer);
+  fflush(outfile);
+
+  p = buffer;
+  while (isspace(*p)) p++;
+  if (*p == 0) continue;
+
+  /* See if the pattern is to be loaded pre-compiled from a file. */
+
+  if (*p == '<' && strchr((char *)(p+1), '<') == NULL)
+    {
+    unsigned long int magic, get_options;
+    uschar sbuf[8];
+    FILE *f;
+
+    p++;
+    pp = p + (int)strlen((char *)p);
+    while (isspace(pp[-1])) pp--;
+    *pp = 0;
+
+    f = fopen((char *)p, "rb");
+    if (f == NULL)
+      {
+      fprintf(outfile, "Failed to open %s: %s\n", p, strerror(errno));
+      continue;
+      }
+
+    if (fread(sbuf, 1, 8, f) != 8) goto FAIL_READ;
+
+    true_size =
+      (sbuf[0] << 24) | (sbuf[1] << 16) | (sbuf[2] << 8) | sbuf[3];
+    true_study_size =
+      (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];
+
+    re = (real_pcre *)new_malloc(true_size);
+    regex_gotten_store = gotten_store;
+
+    if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;
+
+    magic = ((real_pcre *)re)->magic_number;
+    if (magic != MAGIC_NUMBER)
+      {
+      if (byteflip(magic, sizeof(magic)) == MAGIC_NUMBER)
+        {
+        do_flip = 1;
+        }
+      else
+        {
+        fprintf(outfile, "Data in %s is not a compiled PCRE regex\n", p);
+        fclose(f);
+        continue;
+        }
+      }
+
+    fprintf(outfile, "Compiled regex%s loaded from %s\n",
+      do_flip? " (byte-inverted)" : "", p);
+
+    /* Need to know if UTF-8 for printing data strings */
+
+    new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options);
+    use_utf8 = (get_options & PCRE_UTF8) != 0;
+
+    /* Now see if there is any following study data */
+
+    if (true_study_size != 0)
+      {
+      pcre_study_data *psd;
+
+      extra = (pcre_extra *)new_malloc(sizeof(pcre_extra) + true_study_size);
+      extra->flags = PCRE_EXTRA_STUDY_DATA;
+
+      psd = (pcre_study_data *)(((char *)extra) + sizeof(pcre_extra));
+      extra->study_data = psd;
+
+      if (fread(psd, 1, true_study_size, f) != true_study_size)
+        {
+        FAIL_READ:
+        fprintf(outfile, "Failed to read data from %s\n", p);
+        if (extra != NULL) new_free(extra);
+        if (re != NULL) new_free(re);
+        fclose(f);
+        continue;
+        }
+      fprintf(outfile, "Study data loaded from %s\n", p);
+      do_study = 1;     /* To get the data output if requested */
+      }
+    else fprintf(outfile, "No study data\n");
+
+    fclose(f);
+    goto SHOW_INFO;
+    }
+
+  /* In-line pattern (the usual case). Get the delimiter and seek the end of
+  the pattern; if is isn't complete, read more. */
+
+  delimiter = *p++;
+
+  if (isalnum(delimiter) || delimiter == '\\')
+    {
+    fprintf(outfile, "** Delimiter must not be alphanumeric or \\\n");
+    goto SKIP_DATA;
+    }
+
+  pp = p;
+  poffset = p - buffer;
+
+  for(;;)
+    {
+    while (*pp != 0)
+      {
+      if (*pp == '\\' && pp[1] != 0) pp++;
+        else if (*pp == delimiter) break;
+      pp++;
+      }
+    if (*pp != 0) break;
+    if ((pp = extend_inputline(infile, pp, "    > ")) == NULL)
+      {
+      fprintf(outfile, "** Unexpected EOF\n");
+      done = 1;
+      goto CONTINUE;
+      }
+    if (infile != stdin) fprintf(outfile, "%s", (char *)pp);
+    }
+
+  /* The buffer may have moved while being extended; reset the start of data
+  pointer to the correct relative point in the buffer. */
+
+  p = buffer + poffset;
+
+  /* If the first character after the delimiter is backslash, make
+  the pattern end with backslash. This is purely to provide a way
+  of testing for the error message when a pattern ends with backslash. */
+
+  if (pp[1] == '\\') *pp++ = '\\';
+
+  /* Terminate the pattern at the delimiter, and save a copy of the pattern
+  for callouts. */
+
+  *pp++ = 0;
+  strcpy((char *)pbuffer, (char *)p);
+
+  /* Look for options after final delimiter */
+
+  options = 0;
+  study_options = 0;
+  log_store = showstore;  /* default from command line */
+
+  while (*pp != 0)
+    {
+    switch (*pp++)
+      {
+      case 'f': options |= PCRE_FIRSTLINE; break;
+      case 'g': do_g = 1; break;
+      case 'i': options |= PCRE_CASELESS; break;
+      case 'm': options |= PCRE_MULTILINE; break;
+      case 's': options |= PCRE_DOTALL; break;
+      case 'x': options |= PCRE_EXTENDED; break;
+
+      case '+': do_showrest = 1; break;
+      case 'A': options |= PCRE_ANCHORED; break;
+      case 'B': do_debug = 1; break;
+      case 'C': options |= PCRE_AUTO_CALLOUT; break;
+      case 'D': do_debug = do_showinfo = 1; break;
+      case 'E': options |= PCRE_DOLLAR_ENDONLY; break;
+      case 'F': do_flip = 1; break;
+      case 'G': do_G = 1; break;
+      case 'I': do_showinfo = 1; break;
+      case 'J': options |= PCRE_DUPNAMES; break;
+      case 'M': log_store = 1; break;
+      case 'N': options |= PCRE_NO_AUTO_CAPTURE; break;
+
+#if !defined NOPOSIX
+      case 'P': do_posix = 1; break;
+#endif
+
+      case 'S': do_study = 1; break;
+      case 'U': options |= PCRE_UNGREEDY; break;
+      case 'X': options |= PCRE_EXTRA; break;
+      case 'Z': debug_lengths = 0; break;
+      case '8': options |= PCRE_UTF8; use_utf8 = 1; break;
+      case '?': options |= PCRE_NO_UTF8_CHECK; break;
+
+      case 'L':
+      ppp = pp;
+      /* The '\r' test here is so that it works on Windows. */
+      /* The '0' test is just in case this is an unterminated line. */
+      while (*ppp != 0 && *ppp != '\n' && *ppp != '\r' && *ppp != ' ') ppp++;
+      *ppp = 0;
+      if (setlocale(LC_CTYPE, (const char *)pp) == NULL)
+        {
+        fprintf(outfile, "** Failed to set locale \"%s\"\n", pp);
+        goto SKIP_DATA;
+        }
+      locale_set = 1;
+      tables = pcre_maketables();
+      pp = ppp;
+      break;
+
+      case '>':
+      to_file = pp;
+      while (*pp != 0) pp++;
+      while (isspace(pp[-1])) pp--;
+      *pp = 0;
+      break;
+
+      case '<':
+        {
+        if (strncmp((char *)pp, "JS>", 3) == 0)
+          {
+          options |= PCRE_JAVASCRIPT_COMPAT;
+          pp += 3;
+          }
+        else
+          {
+          int x = check_newline(pp, outfile);
+          if (x == 0) goto SKIP_DATA;
+          options |= x;
+          while (*pp++ != '>');
+          }
+        }
+      break;
+
+      case '\r':                      /* So that it works in Windows */
+      case '\n':
+      case ' ':
+      break;
+
+      default:
+      fprintf(outfile, "** Unknown option '%c'\n", pp[-1]);
+      goto SKIP_DATA;
+      }
+    }
+
+  /* Handle compiling via the POSIX interface, which doesn't support the
+  timing, showing, or debugging options, nor the ability to pass over
+  local character tables. */
+
+#if !defined NOPOSIX
+  if (posix || do_posix)
+    {
+    int rc;
+    int cflags = 0;
+
+    if ((options & PCRE_CASELESS) != 0) cflags |= REG_ICASE;
+    if ((options & PCRE_MULTILINE) != 0) cflags |= REG_NEWLINE;
+    if ((options & PCRE_DOTALL) != 0) cflags |= REG_DOTALL;
+    if ((options & PCRE_NO_AUTO_CAPTURE) != 0) cflags |= REG_NOSUB;
+    if ((options & PCRE_UTF8) != 0) cflags |= REG_UTF8;
+
+    rc = regcomp(&preg, (char *)p, cflags);
+
+    /* Compilation failed; go back for another re, skipping to blank line
+    if non-interactive. */
+
+    if (rc != 0)
+      {
+      (void)regerror(rc, &preg, (char *)buffer, buffer_size);
+      fprintf(outfile, "Failed: POSIX code %d: %s\n", rc, buffer);
+      goto SKIP_DATA;
+      }
+    }
+
+  /* Handle compiling via the native interface */
+
+  else
+#endif  /* !defined NOPOSIX */
+
+    {
+    if (timeit > 0)
+      {
+      register int i;
+      clock_t time_taken;
+      clock_t start_time = clock();
+      for (i = 0; i < timeit; i++)
+        {
+        re = pcre_compile((char *)p, options, &error, &erroroffset, tables);
+        if (re != NULL) free(re);
+        }
+      time_taken = clock() - start_time;
+      fprintf(outfile, "Compile time %.4f milliseconds\n",
+        (((double)time_taken * 1000.0) / (double)timeit) /
+          (double)CLOCKS_PER_SEC);
+      }
+
+    re = pcre_compile((char *)p, options, &error, &erroroffset, tables);
+
+    /* Compilation failed; go back for another re, skipping to blank line
+    if non-interactive. */
+
+    if (re == NULL)
+      {
+      fprintf(outfile, "Failed: %s at offset %d\n", error, erroroffset);
+      SKIP_DATA:
+      if (infile != stdin)
+        {
+        for (;;)
+          {
+          if (extend_inputline(infile, buffer, NULL) == NULL)
+            {
+            done = 1;
+            goto CONTINUE;
+            }
+          len = (int)strlen((char *)buffer);
+          while (len > 0 && isspace(buffer[len-1])) len--;
+          if (len == 0) break;
+          }
+        fprintf(outfile, "\n");
+        }
+      goto CONTINUE;
+      }
+
+    /* Compilation succeeded; print data if required. There are now two
+    info-returning functions. The old one has a limited interface and
+    returns only limited data. Check that it agrees with the newer one. */
+
+    if (log_store)
+      fprintf(outfile, "Memory allocation (code space): %d\n",
+        (int)(gotten_store -
+              sizeof(real_pcre) -
+              ((real_pcre *)re)->name_count * ((real_pcre *)re)->name_entry_size));
+
+    /* Extract the size for possible writing before possibly flipping it,
+    and remember the store that was got. */
+
+    true_size = ((real_pcre *)re)->size;
+    regex_gotten_store = gotten_store;
+
+    /* If /S was present, study the regexp to generate additional info to
+    help with the matching. */
+
+    if (do_study)
+      {
+      if (timeit > 0)
+        {
+        register int i;
+        clock_t time_taken;
+        clock_t start_time = clock();
+        for (i = 0; i < timeit; i++)
+          extra = pcre_study(re, study_options, &error);
+        time_taken = clock() - start_time;
+        if (extra != NULL) free(extra);
+        fprintf(outfile, "  Study time %.4f milliseconds\n",
+          (((double)time_taken * 1000.0) / (double)timeit) /
+            (double)CLOCKS_PER_SEC);
+        }
+      extra = pcre_study(re, study_options, &error);
+      if (error != NULL)
+        fprintf(outfile, "Failed to study: %s\n", error);
+      else if (extra != NULL)
+        true_study_size = ((pcre_study_data *)(extra->study_data))->size;
+      }
+
+    /* If the 'F' option was present, we flip the bytes of all the integer
+    fields in the regex data block and the study block. This is to make it
+    possible to test PCRE's handling of byte-flipped patterns, e.g. those
+    compiled on a different architecture. */
+
+    if (do_flip)
+      {
+      real_pcre *rre = (real_pcre *)re;
+      rre->magic_number =
+        byteflip(rre->magic_number, sizeof(rre->magic_number));
+      rre->size = byteflip(rre->size, sizeof(rre->size));
+      rre->options = byteflip(rre->options, sizeof(rre->options));
+      rre->flags = (pcre_uint16)byteflip(rre->flags, sizeof(rre->flags));
+      rre->top_bracket =
+        (pcre_uint16)byteflip(rre->top_bracket, sizeof(rre->top_bracket));
+      rre->top_backref =
+        (pcre_uint16)byteflip(rre->top_backref, sizeof(rre->top_backref));
+      rre->first_byte =
+        (pcre_uint16)byteflip(rre->first_byte, sizeof(rre->first_byte));
+      rre->req_byte =
+        (pcre_uint16)byteflip(rre->req_byte, sizeof(rre->req_byte));
+      rre->name_table_offset = (pcre_uint16)byteflip(rre->name_table_offset,
+        sizeof(rre->name_table_offset));
+      rre->name_entry_size = (pcre_uint16)byteflip(rre->name_entry_size,
+        sizeof(rre->name_entry_size));
+      rre->name_count = (pcre_uint16)byteflip(rre->name_count,
+        sizeof(rre->name_count));
+
+      if (extra != NULL)
+        {
+        pcre_study_data *rsd = (pcre_study_data *)(extra->study_data);
+        rsd->size = byteflip(rsd->size, sizeof(rsd->size));
+        rsd->options = byteflip(rsd->options, sizeof(rsd->options));
+        }
+      }
+
+    /* Extract information from the compiled data if required */
+
+    SHOW_INFO:
+
+    if (do_debug)
+      {
+      fprintf(outfile, "------------------------------------------------------------------\n");
+      pcre_printint(re, outfile, debug_lengths);
+      }
+
+    if (do_showinfo)
+      {
+      unsigned long int get_options, all_options;
+#if !defined NOINFOCHECK
+      int old_first_char, old_options, old_count;
+#endif
+      int count, backrefmax, first_char, need_char, okpartial, jchanged,
+        hascrorlf;
+      int nameentrysize, namecount;
+      const uschar *nametable;
+
+      new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options);
+      new_info(re, NULL, PCRE_INFO_SIZE, &size);
+      new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count);
+      new_info(re, NULL, PCRE_INFO_BACKREFMAX, &backrefmax);
+      new_info(re, NULL, PCRE_INFO_FIRSTBYTE, &first_char);
+      new_info(re, NULL, PCRE_INFO_LASTLITERAL, &need_char);
+      new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &nameentrysize);
+      new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount);
+      new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable);
+      new_info(re, NULL, PCRE_INFO_OKPARTIAL, &okpartial);
+      new_info(re, NULL, PCRE_INFO_JCHANGED, &jchanged);
+      new_info(re, NULL, PCRE_INFO_HASCRORLF, &hascrorlf);
+
+#if !defined NOINFOCHECK
+      old_count = pcre_info(re, &old_options, &old_first_char);
+      if (count < 0) fprintf(outfile,
+        "Error %d from pcre_info()\n", count);
+      else
+        {
+        if (old_count != count) fprintf(outfile,
+          "Count disagreement: pcre_fullinfo=%d pcre_info=%d\n", count,
+            old_count);
+
+        if (old_first_char != first_char) fprintf(outfile,
+          "First char disagreement: pcre_fullinfo=%d pcre_info=%d\n",
+            first_char, old_first_char);
+
+        if (old_options != (int)get_options) fprintf(outfile,
+          "Options disagreement: pcre_fullinfo=%ld pcre_info=%d\n",
+            get_options, old_options);
+        }
+#endif
+
+      if (size != regex_gotten_store) fprintf(outfile,
+        "Size disagreement: pcre_fullinfo=%d call to malloc for %d\n",
+        (int)size, (int)regex_gotten_store);
+
+      fprintf(outfile, "Capturing subpattern count = %d\n", count);
+      if (backrefmax > 0)
+        fprintf(outfile, "Max back reference = %d\n", backrefmax);
+
+      if (namecount > 0)
+        {
+        fprintf(outfile, "Named capturing subpatterns:\n");
+        while (namecount-- > 0)
+          {
+          fprintf(outfile, "  %s %*s%3d\n", nametable + 2,
+            nameentrysize - 3 - (int)strlen((char *)nametable + 2), "",
+            GET2(nametable, 0));
+          nametable += nameentrysize;
+          }
+        }
+
+      if (!okpartial) fprintf(outfile, "Partial matching not supported\n");
+      if (hascrorlf) fprintf(outfile, "Contains explicit CR or LF match\n");
+
+      all_options = ((real_pcre *)re)->options;
+      if (do_flip) all_options = byteflip(all_options, sizeof(all_options));
+
+      if (get_options == 0) fprintf(outfile, "No options\n");
+        else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+          ((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",
+          ((get_options & PCRE_CASELESS) != 0)? " caseless" : "",
+          ((get_options & PCRE_EXTENDED) != 0)? " extended" : "",
+          ((get_options & PCRE_MULTILINE) != 0)? " multiline" : "",
+          ((get_options & PCRE_FIRSTLINE) != 0)? " firstline" : "",
+          ((get_options & PCRE_DOTALL) != 0)? " dotall" : "",
+          ((get_options & PCRE_BSR_ANYCRLF) != 0)? " bsr_anycrlf" : "",
+          ((get_options & PCRE_BSR_UNICODE) != 0)? " bsr_unicode" : "",
+          ((get_options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "",
+          ((get_options & PCRE_EXTRA) != 0)? " extra" : "",
+          ((get_options & PCRE_UNGREEDY) != 0)? " ungreedy" : "",
+          ((get_options & PCRE_NO_AUTO_CAPTURE) != 0)? " no_auto_capture" : "",
+          ((get_options & PCRE_UTF8) != 0)? " utf8" : "",
+          ((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf8_check" : "",
+          ((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : "");
+
+      if (jchanged) fprintf(outfile, "Duplicate name status changes\n");
+
+      switch (get_options & PCRE_NEWLINE_BITS)
+        {
+        case PCRE_NEWLINE_CR:
+        fprintf(outfile, "Forced newline sequence: CR\n");
+        break;
+
+        case PCRE_NEWLINE_LF:
+        fprintf(outfile, "Forced newline sequence: LF\n");
+        break;
+
+        case PCRE_NEWLINE_CRLF:
+        fprintf(outfile, "Forced newline sequence: CRLF\n");
+        break;
+
+        case PCRE_NEWLINE_ANYCRLF:
+        fprintf(outfile, "Forced newline sequence: ANYCRLF\n");
+        break;
+
+        case PCRE_NEWLINE_ANY:
+        fprintf(outfile, "Forced newline sequence: ANY\n");
+        break;
+
+        default:
+        break;
+        }
+
+      if (first_char == -1)
+        {
+        fprintf(outfile, "First char at start or follows newline\n");
+        }
+      else if (first_char < 0)
+        {
+        fprintf(outfile, "No first char\n");
+        }
+      else
+        {
+        int ch = first_char & 255;
+        const char *caseless = ((first_char & REQ_CASELESS) == 0)?
+          "" : " (caseless)";
+        if (PRINTHEX(ch))
+          fprintf(outfile, "First char = \'%c\'%s\n", ch, caseless);
+        else
+          fprintf(outfile, "First char = %d%s\n", ch, caseless);
+        }
+
+      if (need_char < 0)
+        {
+        fprintf(outfile, "No need char\n");
+        }
+      else
+        {
+        int ch = need_char & 255;
+        const char *caseless = ((need_char & REQ_CASELESS) == 0)?
+          "" : " (caseless)";
+        if (PRINTHEX(ch))
+          fprintf(outfile, "Need char = \'%c\'%s\n", ch, caseless);
+        else
+          fprintf(outfile, "Need char = %d%s\n", ch, caseless);
+        }
+
+      /* Don't output study size; at present it is in any case a fixed
+      value, but it varies, depending on the computer architecture, and
+      so messes up the test suite. (And with the /F option, it might be
+      flipped.) */
+
+      if (do_study)
+        {
+        if (extra == NULL)
+          fprintf(outfile, "Study returned NULL\n");
+        else
+          {
+          uschar *start_bits = NULL;
+          new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits);
+
+          if (start_bits == NULL)
+            fprintf(outfile, "No starting byte set\n");
+          else
+            {
+            int i;
+            int c = 24;
+            fprintf(outfile, "Starting byte set: ");
+            for (i = 0; i < 256; i++)
+              {
+              if ((start_bits[i/8] & (1<<(i&7))) != 0)
+                {
+                if (c > 75)
+                  {
+                  fprintf(outfile, "\n  ");
+                  c = 2;
+                  }
+                if (PRINTHEX(i) && i != ' ')
+                  {
+                  fprintf(outfile, "%c ", i);
+                  c += 2;
+                  }
+                else
+                  {
+                  fprintf(outfile, "\\x%02x ", i);
+                  c += 5;
+                  }
+                }
+              }
+            fprintf(outfile, "\n");
+            }
+          }
+        }
+      }
+
+    /* If the '>' option was present, we write out the regex to a file, and
+    that is all. The first 8 bytes of the file are the regex length and then
+    the study length, in big-endian order. */
+
+    if (to_file != NULL)
+      {
+      FILE *f = fopen((char *)to_file, "wb");
+      if (f == NULL)
+        {
+        fprintf(outfile, "Unable to open %s: %s\n", to_file, strerror(errno));
+        }
+      else
+        {
+        uschar sbuf[8];
+        sbuf[0] = (uschar)((true_size >> 24) & 255);
+        sbuf[1] = (uschar)((true_size >> 16) & 255);
+        sbuf[2] = (uschar)((true_size >>  8) & 255);
+        sbuf[3] = (uschar)((true_size) & 255);
+
+        sbuf[4] = (uschar)((true_study_size >> 24) & 255);
+        sbuf[5] = (uschar)((true_study_size >> 16) & 255);
+        sbuf[6] = (uschar)((true_study_size >>  8) & 255);
+        sbuf[7] = (uschar)((true_study_size) & 255);
+
+        if (fwrite(sbuf, 1, 8, f) < 8 ||
+            fwrite(re, 1, true_size, f) < true_size)
+          {
+          fprintf(outfile, "Write error on %s: %s\n", to_file, strerror(errno));
+          }
+        else
+          {
+          fprintf(outfile, "Compiled regex written to %s\n", to_file);
+          if (extra != NULL)
+            {
+            if (fwrite(extra->study_data, 1, true_study_size, f) <
+                true_study_size)
+              {
+              fprintf(outfile, "Write error on %s: %s\n", to_file,
+                strerror(errno));
+              }
+            else fprintf(outfile, "Study data written to %s\n", to_file);
+
+            }
+          }
+        fclose(f);
+        }
+
+      new_free(re);
+      if (extra != NULL) new_free(extra);
+      if (tables != NULL) new_free((void *)tables);
+      continue;  /* With next regex */
+      }
+    }        /* End of non-POSIX compile */
+
+  /* Read data lines and test them */
+
+  for (;;)
+    {
+    uschar *q;
+    uschar *bptr;
+    int *use_offsets = offsets;
+    int use_size_offsets = size_offsets;
+    int callout_data = 0;
+    int callout_data_set = 0;
+    int count, c;
+    int copystrings = 0;
+    int find_match_limit = 0;
+    int getstrings = 0;
+    int getlist = 0;
+    int gmatched = 0;
+    int start_offset = 0;
+    int g_notempty = 0;
+    int use_dfa = 0;
+
+    options = 0;
+
+    *copynames = 0;
+    *getnames = 0;
+
+    copynamesptr = copynames;
+    getnamesptr = getnames;
+
+    pcre_callout = callout;
+    first_callout = 1;
+    callout_extra = 0;
+    callout_count = 0;
+    callout_fail_count = 999999;
+    callout_fail_id = -1;
+    show_malloc = 0;
+
+    if (extra != NULL) extra->flags &=
+      ~(PCRE_EXTRA_MATCH_LIMIT|PCRE_EXTRA_MATCH_LIMIT_RECURSION);
+
+    len = 0;
+    for (;;)
+      {
+      if (extend_inputline(infile, buffer + len, "data> ") == NULL)
+        {
+        if (len > 0) break;
+        done = 1;
+        goto CONTINUE;
+        }
+      if (infile != stdin) fprintf(outfile, "%s", (char *)buffer);
+      len = (int)strlen((char *)buffer);
+      if (buffer[len-1] == '\n') break;
+      }
+
+    while (len > 0 && isspace(buffer[len-1])) len--;
+    buffer[len] = 0;
+    if (len == 0) break;
+
+    p = buffer;
+    while (isspace(*p)) p++;
+
+    bptr = q = dbuffer;
+    while ((c = *p++) != 0)
+      {
+      int i = 0;
+      int n = 0;
+
+      if (c == '\\') switch ((c = *p++))
+        {
+        case 'a': c =    7; break;
+        case 'b': c = '\b'; break;
+        case 'e': c =   27; break;
+        case 'f': c = '\f'; break;
+        case 'n': c = '\n'; break;
+        case 'r': c = '\r'; break;
+        case 't': c = '\t'; break;
+        case 'v': c = '\v'; break;
+
+        case '0': case '1': case '2': case '3':
+        case '4': case '5': case '6': case '7':
+        c -= '0';
+        while (i++ < 2 && isdigit(*p) && *p != '8' && *p != '9')
+          c = c * 8 + *p++ - '0';
+
+#if !defined NOUTF8
+        if (use_utf8 && c > 255)
+          {
+          unsigned char buff8[8];
+          int ii, utn;
+          utn = ord2utf8(c, buff8);
+          for (ii = 0; ii < utn - 1; ii++) *q++ = buff8[ii];
+          c = buff8[ii];   /* Last byte */
+          }
+#endif
+        break;
+
+        case 'x':
+
+        /* Handle \x{..} specially - new Perl thing for utf8 */
+
+#if !defined NOUTF8
+        if (*p == '{')
+          {
+          unsigned char *pt = p;
+          c = 0;
+          while (isxdigit(*(++pt)))
+            c = c * 16 + tolower(*pt) - ((isdigit(*pt))? '0' : 'W');
+          if (*pt == '}')
+            {
+            unsigned char buff8[8];
+            int ii, utn;
+            if (use_utf8)
+              {
+              utn = ord2utf8(c, buff8);
+              for (ii = 0; ii < utn - 1; ii++) *q++ = buff8[ii];
+              c = buff8[ii];   /* Last byte */
+              }
+            else
+             {
+             if (c > 255)
+               fprintf(outfile, "** Character \\x{%x} is greater than 255 and "
+                 "UTF-8 mode is not enabled.\n"
+                 "** Truncation will probably give the wrong result.\n", c);
+             }
+            p = pt + 1;
+            break;
+            }
+          /* Not correct form; fall through */
+          }
+#endif
+
+        /* Ordinary \x */
+
+        c = 0;
+        while (i++ < 2 && isxdigit(*p))
+          {
+          c = c * 16 + tolower(*p) - ((isdigit(*p))? '0' : 'W');
+          p++;
+          }
+        break;
+
+        case 0:   /* \ followed by EOF allows for an empty line */
+        p--;
+        continue;
+
+        case '>':
+        while(isdigit(*p)) start_offset = start_offset * 10 + *p++ - '0';
+        continue;
+
+        case 'A':  /* Option setting */
+        options |= PCRE_ANCHORED;
+        continue;
+
+        case 'B':
+        options |= PCRE_NOTBOL;
+        continue;
+
+        case 'C':
+        if (isdigit(*p))    /* Set copy string */
+          {
+          while(isdigit(*p)) n = n * 10 + *p++ - '0';
+          copystrings |= 1 << n;
+          }
+        else if (isalnum(*p))
+          {
+          uschar *npp = copynamesptr;
+          while (isalnum(*p)) *npp++ = *p++;
+          *npp++ = 0;
+          *npp = 0;
+          n = pcre_get_stringnumber(re, (char *)copynamesptr);
+          if (n < 0)
+            fprintf(outfile, "no parentheses with name \"%s\"\n", copynamesptr);
+          copynamesptr = npp;
+          }
+        else if (*p == '+')
+          {
+          callout_extra = 1;
+          p++;
+          }
+        else if (*p == '-')
+          {
+          pcre_callout = NULL;
+          p++;
+          }
+        else if (*p == '!')
+          {
+          callout_fail_id = 0;
+          p++;
+          while(isdigit(*p))
+            callout_fail_id = callout_fail_id * 10 + *p++ - '0';
+          callout_fail_count = 0;
+          if (*p == '!')
+            {
+            p++;
+            while(isdigit(*p))
+              callout_fail_count = callout_fail_count * 10 + *p++ - '0';
+            }
+          }
+        else if (*p == '*')
+          {
+          int sign = 1;
+          callout_data = 0;
+          if (*(++p) == '-') { sign = -1; p++; }
+          while(isdigit(*p))
+            callout_data = callout_data * 10 + *p++ - '0';
+          callout_data *= sign;
+          callout_data_set = 1;
+          }
+        continue;
+
+#if !defined NODFA
+        case 'D':
+#if !defined NOPOSIX
+        if (posix || do_posix)
+          printf("** Can't use dfa matching in POSIX mode: \\D ignored\n");
+        else
+#endif
+          use_dfa = 1;
+        continue;
+
+        case 'F':
+        options |= PCRE_DFA_SHORTEST;
+        continue;
+#endif
+
+        case 'G':
+        if (isdigit(*p))
+          {
+          while(isdigit(*p)) n = n * 10 + *p++ - '0';
+          getstrings |= 1 << n;
+          }
+        else if (isalnum(*p))
+          {
+          uschar *npp = getnamesptr;
+          while (isalnum(*p)) *npp++ = *p++;
+          *npp++ = 0;
+          *npp = 0;
+          n = pcre_get_stringnumber(re, (char *)getnamesptr);
+          if (n < 0)
+            fprintf(outfile, "no parentheses with name \"%s\"\n", getnamesptr);
+          getnamesptr = npp;
+          }
+        continue;
+
+        case 'L':
+        getlist = 1;
+        continue;
+
+        case 'M':
+        find_match_limit = 1;
+        continue;
+
+        case 'N':
+        options |= PCRE_NOTEMPTY;
+        continue;
+
+        case 'O':
+        while(isdigit(*p)) n = n * 10 + *p++ - '0';
+        if (n > size_offsets_max)
+          {
+          size_offsets_max = n;
+          free(offsets);
+          use_offsets = offsets = (int *)malloc(size_offsets_max * sizeof(int));
+          if (offsets == NULL)
+            {
+            printf("** Failed to get %d bytes of memory for offsets vector\n",
+              (int)(size_offsets_max * sizeof(int)));
+            yield = 1;
+            goto EXIT;
+            }
+          }
+        use_size_offsets = n;
+        if (n == 0) use_offsets = NULL;   /* Ensures it can't write to it */
+        continue;
+
+        case 'P':
+        options |= PCRE_PARTIAL;
+        continue;
+
+        case 'Q':
+        while(isdigit(*p)) n = n * 10 + *p++ - '0';
+        if (extra == NULL)
+          {
+          extra = (pcre_extra *)malloc(sizeof(pcre_extra));
+          extra->flags = 0;
+          }
+        extra->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
+        extra->match_limit_recursion = n;
+        continue;
+
+        case 'q':
+        while(isdigit(*p)) n = n * 10 + *p++ - '0';
+        if (extra == NULL)
+          {
+          extra = (pcre_extra *)malloc(sizeof(pcre_extra));
+          extra->flags = 0;
+          }
+        extra->flags |= PCRE_EXTRA_MATCH_LIMIT;
+        extra->match_limit = n;
+        continue;
+
+#if !defined NODFA
+        case 'R':
+        options |= PCRE_DFA_RESTART;
+        continue;
+#endif
+
+        case 'S':
+        show_malloc = 1;
+        continue;
+
+        case 'Z':
+        options |= PCRE_NOTEOL;
+        continue;
+
+        case '?':
+        options |= PCRE_NO_UTF8_CHECK;
+        continue;
+
+        case '<':
+          {
+          int x = check_newline(p, outfile);
+          if (x == 0) goto NEXT_DATA;
+          options |= x;
+          while (*p++ != '>');
+          }
+        continue;
+        }
+      *q++ = c;
+      }
+    *q = 0;
+    len = q - dbuffer;
+
+    /* Move the data to the end of the buffer so that a read over the end of
+    the buffer will be seen by valgrind, even if it doesn't cause a crash. If
+    we are using the POSIX interface, we must include the terminating zero. */
+
+#if !defined NOPOSIX
+    if (posix || do_posix)
+      {
+      memmove(bptr + buffer_size - len - 1, bptr, len + 1);
+      bptr += buffer_size - len - 1;
+      }
+    else
+#endif
+      {
+      memmove(bptr + buffer_size - len, bptr, len);
+      bptr += buffer_size - len;
+      }
+
+    if ((all_use_dfa || use_dfa) && find_match_limit)
+      {
+      printf("**Match limit not relevant for DFA matching: ignored\n");
+      find_match_limit = 0;
+      }
+
+    /* Handle matching via the POSIX interface, which does not
+    support timing or playing with the match limit or callout data. */
+
+#if !defined NOPOSIX
+    if (posix || do_posix)
+      {
+      int rc;
+      int eflags = 0;
+      regmatch_t *pmatch = NULL;
+      if (use_size_offsets > 0)
+        pmatch = (regmatch_t *)malloc(sizeof(regmatch_t) * use_size_offsets);
+      if ((options & PCRE_NOTBOL) != 0) eflags |= REG_NOTBOL;
+      if ((options & PCRE_NOTEOL) != 0) eflags |= REG_NOTEOL;
+
+      rc = regexec(&preg, (const char *)bptr, use_size_offsets, pmatch, eflags);
+
+      if (rc != 0)
+        {
+        (void)regerror(rc, &preg, (char *)buffer, buffer_size);
+        fprintf(outfile, "No match: POSIX code %d: %s\n", rc, buffer);
+        }
+      else if ((((const pcre *)preg.re_pcre)->options & PCRE_NO_AUTO_CAPTURE)
+              != 0)
+        {
+        fprintf(outfile, "Matched with REG_NOSUB\n");
+        }
+      else
+        {
+        size_t i;
+        for (i = 0; i < (size_t)use_size_offsets; i++)
+          {
+          if (pmatch[i].rm_so >= 0)
+            {
+            fprintf(outfile, "%2d: ", (int)i);
+            (void)pchars(dbuffer + pmatch[i].rm_so,
+              pmatch[i].rm_eo - pmatch[i].rm_so, outfile);
+            fprintf(outfile, "\n");
+            if (i == 0 && do_showrest)
+              {
+              fprintf(outfile, " 0+ ");
+              (void)pchars(dbuffer + pmatch[i].rm_eo, len - pmatch[i].rm_eo,
+                outfile);
+              fprintf(outfile, "\n");
+              }
+            }
+          }
+        }
+      free(pmatch);
+      }
+
+    /* Handle matching via the native interface - repeats for /g and /G */
+
+    else
+#endif  /* !defined NOPOSIX */
+
+    for (;; gmatched++)    /* Loop for /g or /G */
+      {
+      if (timeitm > 0)
+        {
+        register int i;
+        clock_t time_taken;
+        clock_t start_time = clock();
+
+#if !defined NODFA
+        if (all_use_dfa || use_dfa)
+          {
+          int workspace[1000];
+          for (i = 0; i < timeitm; i++)
+            count = pcre_dfa_exec(re, NULL, (char *)bptr, len, start_offset,
+              options | g_notempty, use_offsets, use_size_offsets, workspace,
+              sizeof(workspace)/sizeof(int));
+          }
+        else
+#endif
+
+        for (i = 0; i < timeitm; i++)
+          count = pcre_exec(re, extra, (char *)bptr, len,
+            start_offset, options | g_notempty, use_offsets, use_size_offsets);
+
+        time_taken = clock() - start_time;
+        fprintf(outfile, "Execute time %.4f milliseconds\n",
+          (((double)time_taken * 1000.0) / (double)timeitm) /
+            (double)CLOCKS_PER_SEC);
+        }
+
+      /* If find_match_limit is set, we want to do repeated matches with
+      varying limits in order to find the minimum value for the match limit and
+      for the recursion limit. */
+
+      if (find_match_limit)
+        {
+        if (extra == NULL)
+          {
+          extra = (pcre_extra *)malloc(sizeof(pcre_extra));
+          extra->flags = 0;
+          }
+
+        (void)check_match_limit(re, extra, bptr, len, start_offset,
+          options|g_notempty, use_offsets, use_size_offsets,
+          PCRE_EXTRA_MATCH_LIMIT, &(extra->match_limit),
+          PCRE_ERROR_MATCHLIMIT, "match()");
+
+        count = check_match_limit(re, extra, bptr, len, start_offset,
+          options|g_notempty, use_offsets, use_size_offsets,
+          PCRE_EXTRA_MATCH_LIMIT_RECURSION, &(extra->match_limit_recursion),
+          PCRE_ERROR_RECURSIONLIMIT, "match() recursion");
+        }
+
+      /* If callout_data is set, use the interface with additional data */
+
+      else if (callout_data_set)
+        {
+        if (extra == NULL)
+          {
+          extra = (pcre_extra *)malloc(sizeof(pcre_extra));
+          extra->flags = 0;
+          }
+        extra->flags |= PCRE_EXTRA_CALLOUT_DATA;
+        extra->callout_data = &callout_data;
+        count = pcre_exec(re, extra, (char *)bptr, len, start_offset,
+          options | g_notempty, use_offsets, use_size_offsets);
+        extra->flags &= ~PCRE_EXTRA_CALLOUT_DATA;
+        }
+
+      /* The normal case is just to do the match once, with the default
+      value of match_limit. */
+
+#if !defined NODFA
+      else if (all_use_dfa || use_dfa)
+        {
+        int workspace[1000];
+        count = pcre_dfa_exec(re, NULL, (char *)bptr, len, start_offset,
+          options | g_notempty, use_offsets, use_size_offsets, workspace,
+          sizeof(workspace)/sizeof(int));
+        if (count == 0)
+          {
+          fprintf(outfile, "Matched, but too many subsidiary matches\n");
+          count = use_size_offsets/2;
+          }
+        }
+#endif
+
+      else
+        {
+        count = pcre_exec(re, extra, (char *)bptr, len,
+          start_offset, options | g_notempty, use_offsets, use_size_offsets);
+        if (count == 0)
+          {
+          fprintf(outfile, "Matched, but too many substrings\n");
+          count = use_size_offsets/3;
+          }
+        }
+
+      /* Matched */
+
+      if (count >= 0)
+        {
+        int i, maxcount;
+
+#if !defined NODFA
+        if (all_use_dfa || use_dfa) maxcount = use_size_offsets/2; else
+#endif
+          maxcount = use_size_offsets/3;
+
+        /* This is a check against a lunatic return value. */
+
+        if (count > maxcount)
+          {
+          fprintf(outfile,
+            "** PCRE error: returned count %d is too big for offset size %d\n",
+            count, use_size_offsets);
+          count = use_size_offsets/3;
+          if (do_g || do_G)
+            {
+            fprintf(outfile, "** /%c loop abandoned\n", do_g? 'g' : 'G');
+            do_g = do_G = FALSE;        /* Break g/G loop */
+            }
+          }
+
+        for (i = 0; i < count * 2; i += 2)
+          {
+          if (use_offsets[i] < 0)
+            fprintf(outfile, "%2d: <unset>\n", i/2);
+          else
+            {
+            fprintf(outfile, "%2d: ", i/2);
+            (void)pchars(bptr + use_offsets[i],
+              use_offsets[i+1] - use_offsets[i], outfile);
+            fprintf(outfile, "\n");
+            if (i == 0)
+              {
+              if (do_showrest)
+                {
+                fprintf(outfile, " 0+ ");
+                (void)pchars(bptr + use_offsets[i+1], len - use_offsets[i+1],
+                  outfile);
+                fprintf(outfile, "\n");
+                }
+              }
+            }
+          }
+
+        for (i = 0; i < 32; i++)
+          {
+          if ((copystrings & (1 << i)) != 0)
+            {
+            char copybuffer[256];
+            int rc = pcre_copy_substring((char *)bptr, use_offsets, count,
+              i, copybuffer, sizeof(copybuffer));
+            if (rc < 0)
+              fprintf(outfile, "copy substring %d failed %d\n", i, rc);
+            else
+              fprintf(outfile, "%2dC %s (%d)\n", i, copybuffer, rc);
+            }
+          }
+
+        for (copynamesptr = copynames;
+             *copynamesptr != 0;
+             copynamesptr += (int)strlen((char*)copynamesptr) + 1)
+          {
+          char copybuffer[256];
+          int rc = pcre_copy_named_substring(re, (char *)bptr, use_offsets,
+            count, (char *)copynamesptr, copybuffer, sizeof(copybuffer));
+          if (rc < 0)
+            fprintf(outfile, "copy substring %s failed %d\n", copynamesptr, rc);
+          else
+            fprintf(outfile, "  C %s (%d) %s\n", copybuffer, rc, copynamesptr);
+          }
+
+        for (i = 0; i < 32; i++)
+          {
+          if ((getstrings & (1 << i)) != 0)
+            {
+            const char *substring;
+            int rc = pcre_get_substring((char *)bptr, use_offsets, count,
+              i, &substring);
+            if (rc < 0)
+              fprintf(outfile, "get substring %d failed %d\n", i, rc);
+            else
+              {
+              fprintf(outfile, "%2dG %s (%d)\n", i, substring, rc);
+              pcre_free_substring(substring);
+              }
+            }
+          }
+
+        for (getnamesptr = getnames;
+             *getnamesptr != 0;
+             getnamesptr += (int)strlen((char*)getnamesptr) + 1)
+          {
+          const char *substring;
+          int rc = pcre_get_named_substring(re, (char *)bptr, use_offsets,
+            count, (char *)getnamesptr, &substring);
+          if (rc < 0)
+            fprintf(outfile, "copy substring %s failed %d\n", getnamesptr, rc);
+          else
+            {
+            fprintf(outfile, "  G %s (%d) %s\n", substring, rc, getnamesptr);
+            pcre_free_substring(substring);
+            }
+          }
+
+        if (getlist)
+          {
+          const char **stringlist;
+          int rc = pcre_get_substring_list((char *)bptr, use_offsets, count,
+            &stringlist);
+          if (rc < 0)
+            fprintf(outfile, "get substring list failed %d\n", rc);
+          else
+            {
+            for (i = 0; i < count; i++)
+              fprintf(outfile, "%2dL %s\n", i, stringlist[i]);
+            if (stringlist[i] != NULL)
+              fprintf(outfile, "string list not terminated by NULL\n");
+            /* free((void *)stringlist); */
+            pcre_free_substring_list(stringlist);
+            }
+          }
+        }
+
+      /* There was a partial match */
+
+      else if (count == PCRE_ERROR_PARTIAL)
+        {
+        fprintf(outfile, "Partial match");
+#if !defined NODFA
+        if ((all_use_dfa || use_dfa) && use_size_offsets > 2)
+          fprintf(outfile, ": %.*s", use_offsets[1] - use_offsets[0],
+            bptr + use_offsets[0]);
+#endif
+        fprintf(outfile, "\n");
+        break;  /* Out of the /g loop */
+        }
+
+      /* Failed to match. If this is a /g or /G loop and we previously set
+      g_notempty after a null match, this is not necessarily the end. We want
+      to advance the start offset, and continue. We won't be at the end of the
+      string - that was checked before setting g_notempty.
+
+      Complication arises in the case when the newline option is "any" or
+      "anycrlf". If the previous match was at the end of a line terminated by
+      CRLF, an advance of one character just passes the \r, whereas we should
+      prefer the longer newline sequence, as does the code in pcre_exec().
+      Fudge the offset value to achieve this.
+
+      Otherwise, in the case of UTF-8 matching, the advance must be one
+      character, not one byte. */
+
+      else
+        {
+        if (g_notempty != 0)
+          {
+          int onechar = 1;
+          unsigned int obits = ((real_pcre *)re)->options;
+          use_offsets[0] = start_offset;
+          if ((obits & PCRE_NEWLINE_BITS) == 0)
+            {
+            int d;
+            (void)pcre_config(PCRE_CONFIG_NEWLINE, &d);
+            obits = (d == '\r')? PCRE_NEWLINE_CR :
+                    (d == '\n')? PCRE_NEWLINE_LF :
+                    (d == ('\r'<<8 | '\n'))? PCRE_NEWLINE_CRLF :
+                    (d == -2)? PCRE_NEWLINE_ANYCRLF :
+                    (d == -1)? PCRE_NEWLINE_ANY : 0;
+            }
+          if (((obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANY ||
+               (obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF)
+              &&
+              start_offset < len - 1 &&
+              bptr[start_offset] == '\r' &&
+              bptr[start_offset+1] == '\n')
+            onechar++;
+          else if (use_utf8)
+            {
+            while (start_offset + onechar < len)
+              {
+              int tb = bptr[start_offset+onechar];
+              if (tb <= 127) break;
+              tb &= 0xc0;
+              if (tb != 0 && tb != 0xc0) onechar++;
+              }
+            }
+          use_offsets[1] = start_offset + onechar;
+          }
+        else
+          {
+          if (count == PCRE_ERROR_NOMATCH)
+            {
+            if (gmatched == 0) fprintf(outfile, "No match\n");
+            }
+          else fprintf(outfile, "Error %d\n", count);
+          break;  /* Out of the /g loop */
+          }
+        }
+
+      /* If not /g or /G we are done */
+
+      if (!do_g && !do_G) break;
+
+      /* If we have matched an empty string, first check to see if we are at
+      the end of the subject. If so, the /g loop is over. Otherwise, mimic
+      what Perl's /g options does. This turns out to be rather cunning. First
+      we set PCRE_NOTEMPTY and PCRE_ANCHORED and try the match again at the
+      same point. If this fails (picked up above) we advance to the next
+      character. */
+
+      g_notempty = 0;
+
+      if (use_offsets[0] == use_offsets[1])
+        {
+        if (use_offsets[0] == len) break;
+        g_notempty = PCRE_NOTEMPTY | PCRE_ANCHORED;
+        }
+
+      /* For /g, update the start offset, leaving the rest alone */
+
+      if (do_g) start_offset = use_offsets[1];
+
+      /* For /G, update the pointer and length */
+
+      else
+        {
+        bptr += use_offsets[1];
+        len -= use_offsets[1];
+        }
+      }  /* End of loop for /g and /G */
+
+    NEXT_DATA: continue;
+    }    /* End of loop for data lines */
+
+  CONTINUE:
+
+#if !defined NOPOSIX
+  if (posix || do_posix) regfree(&preg);
+#endif
+
+  if (re != NULL) new_free(re);
+  if (extra != NULL) new_free(extra);
+  if (tables != NULL)
+    {
+    new_free((void *)tables);
+    setlocale(LC_CTYPE, "C");
+    locale_set = 0;
+    }
+  }
+
+if (infile == stdin) fprintf(outfile, "\n");
+
+EXIT:
+
+if (infile != NULL && infile != stdin) fclose(infile);
+if (outfile != NULL && outfile != stdout) fclose(outfile);
+
+free(buffer);
+free(dbuffer);
+free(pbuffer);
+free(offsets);
+
+return yield;
+}
+
+/* End of pcretest.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/perltest.pl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,191 @@
+#! /usr/bin/env perl
+
+# Program for testing regular expressions with perl to check that PCRE handles
+# them the same. This is the version that supports /8 for UTF-8 testing. As it
+# stands, it requires at least Perl 5.8 for UTF-8 support. However, it needs to
+# have "use utf8" at the start for running the UTF-8 tests, but *not* for the
+# other tests. The only way I've found for doing this is to cat this line in
+# explicitly in the RunPerlTest script.
+
+# use locale;  # With this included, \x0b matches \s!
+
+# Function for turning a string into a string of printing chars. There are
+# currently problems with UTF-8 strings; this fudges round them.
+
+sub pchars {
+my($t) = "";
+
+if ($utf8)
+  {
+  @p = unpack('U*', $_[0]);
+  foreach $c (@p)
+    {
+    if ($c >= 32 && $c < 127) { $t .= chr $c; }
+      else { $t .= sprintf("\\x{%02x}", $c); }
+    }
+  }
+
+else
+  {
+  foreach $c (split(//, $_[0]))
+    {
+    if (ord $c >= 32 && ord $c < 127) { $t .= $c; }
+      else { $t .= sprintf("\\x%02x", ord $c); }
+    }
+  }
+
+$t;
+}
+
+
+# Read lines from named file or stdin and write to named file or stdout; lines
+# consist of a regular expression, in delimiters and optionally followed by
+# options, followed by a set of test data, terminated by an empty line.
+
+# Sort out the input and output files
+
+if (@ARGV > 0)
+  {
+  open(INFILE, "<$ARGV[0]") || die "Failed to open $ARGV[0]\n";
+  $infile = "INFILE";
+  }
+else { $infile = "STDIN"; }
+
+if (@ARGV > 1)
+  {
+  open(OUTFILE, ">$ARGV[1]") || die "Failed to open $ARGV[1]\n";
+  $outfile = "OUTFILE";
+  }
+else { $outfile = "STDOUT"; }
+
+printf($outfile "Perl $] Regular Expressions\n\n");
+
+# Main loop
+
+NEXT_RE:
+for (;;)
+  {
+  printf "  re> " if $infile eq "STDIN";
+  last if ! ($_ = <$infile>);
+  printf $outfile "$_" if $infile ne "STDIN";
+  next if ($_ eq "");
+
+  $pattern = $_;
+
+  while ($pattern !~ /^\s*(.).*\1/s)
+    {
+    printf "    > " if $infile eq "STDIN";
+    last if ! ($_ = <$infile>);
+    printf $outfile "$_" if $infile ne "STDIN";
+    $pattern .= $_;
+    }
+
+   chomp($pattern);
+   $pattern =~ s/\s+$//;
+
+  # The private /+ modifier means "print $' afterwards".
+
+  $showrest = ($pattern =~ s/\+(?=[a-z]*$)//);
+
+  # Remove /8 from a UTF-8 pattern.
+
+  $utf8 = $pattern =~ s/8(?=[a-z]*$)//;
+
+  # Check that the pattern is valid
+
+  eval "\$_ =~ ${pattern}";
+  if ($@)
+    {
+    printf $outfile "Error: $@";
+    next NEXT_RE;
+    }
+
+  # If the /g modifier is present, we want to put a loop round the matching;
+  # otherwise just a single "if".
+
+  $cmd = ($pattern =~ /g[a-z]*$/)? "while" : "if";
+
+  # If the pattern is actually the null string, Perl uses the most recently
+  # executed (and successfully compiled) regex is used instead. This is a
+  # nasty trap for the unwary! The PCRE test suite does contain null strings
+  # in places - if they are allowed through here all sorts of weird and
+  # unexpected effects happen. To avoid this, we replace such patterns with
+  # a non-null pattern that has the same effect.
+
+  $pattern = "/(?#)/$2" if ($pattern =~ /^(.)\1(.*)$/);
+
+  # Read data lines and test them
+
+  for (;;)
+    {
+    printf "data> " if $infile eq "STDIN";
+    last NEXT_RE if ! ($_ = <$infile>);
+    chomp;
+    printf $outfile "$_\n" if $infile ne "STDIN";
+
+    s/\s+$//;
+    s/^\s+//;
+
+    last if ($_ eq "");
+    $x = eval "\"$_\"";   # To get escapes processed
+
+    # Empty array for holding results, then do the matching.
+
+    @subs = ();
+
+    $pushes = "push \@subs,\$&;" .
+         "push \@subs,\$1;" .
+         "push \@subs,\$2;" .
+         "push \@subs,\$3;" .
+         "push \@subs,\$4;" .
+         "push \@subs,\$5;" .
+         "push \@subs,\$6;" .
+         "push \@subs,\$7;" .
+         "push \@subs,\$8;" .
+         "push \@subs,\$9;" .
+         "push \@subs,\$10;" .
+         "push \@subs,\$11;" .
+         "push \@subs,\$12;" .
+         "push \@subs,\$13;" .
+         "push \@subs,\$14;" .
+         "push \@subs,\$15;" .
+         "push \@subs,\$16;" .
+         "push \@subs,\$'; }";
+
+    eval "${cmd} (\$x =~ ${pattern}) {" . $pushes;
+
+    if ($@)
+      {
+      printf $outfile "Error: $@\n";
+      next NEXT_RE;
+      }
+    elsif (scalar(@subs) == 0)
+      {
+      printf $outfile "No match\n";
+      }
+    else
+      {
+      while (scalar(@subs) != 0)
+        {
+        printf $outfile (" 0: %s\n", &pchars($subs[0]));
+        printf $outfile (" 0+ %s\n", &pchars($subs[17])) if $showrest;
+        $last_printed = 0;
+        for ($i = 1; $i <= 16; $i++)
+          {
+          if (defined $subs[$i])
+            {
+            while ($last_printed++ < $i-1)
+              { printf $outfile ("%2d: <unset>\n", $last_printed); }
+            printf $outfile ("%2d: %s\n", $i, &pchars($subs[$i]));
+            $last_printed = $i;
+            }
+          }
+        splice(@subs, 0, 18);
+        }
+      }
+    }
+  }
+
+# printf $outfile "\n";
+
+# End
Binary file libraries/spcre/libpcre/pcre/testdata/grepinput has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/grepinput8	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,11 @@
+X one
+X twoX threeX four
X five
+X six
+X seven…X eight
X nine
X ten
+
+Before 111
+Before 222
Before 333…Match
+After 111
+After 222
After 333
+And so on and so on
+And so on and so on
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/grepinputv	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+The quick brown
+fox jumps
+over the lazy dog.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/grepinputx	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,42 @@
+This is a second file of input for the pcregrep tests.
+
+Here is the pattern again.
+
+Pattern
+That time it was on a line by itself.
+
+To pat or not to pat, that is the question.
+
+complete pair
+of lines
+
+That was a complete pair
+of lines all by themselves.
+
+complete pair
+of lines
+
+And there they were again, to check line numbers.
+
+one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
+eleven
+twelve
+thirteen
+fourteen
+fifteen
+sixteen
+seventeen
+eighteen
+nineteen
+twenty
+
+This is the last line of this file.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/greplist	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,7 @@
+This is a file of patterns for testing the -f option. Don't include any blank
+lines because they will match everything! This is no longer true, so have one.
+
+pattern
+line by itself
+
+End of the list of patterns.
Binary file libraries/spcre/libpcre/pcre/testdata/grepoutput has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/grepoutput8	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,10 @@
+---------------------------- Test U1 ------------------------------
+1:X one
+2:X two3:X three4:X four
5:X five
+6:X six
+7:X seven…8:X eight
9:X nine
10:X ten
+---------------------------- Test U2 ------------------------------
+12-Before 111
+13-Before 222
14-Before 333…15:Match
+16-After 111
+17-After 222
18-After 333
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/grepoutputN	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+---------------------------- Test N1 ------------------------------
+1:abc
2:def
---------------------------- Test N2 ------------------------------
+1:abc
def
+2:ghi
+jkl---------------------------- Test N3 ------------------------------
+2:def
3:
+ghi
+jkl---------------------------- Test N4 ------------------------------
+2:ghi
+jkl---------------------------- Test N5 ------------------------------
+1:abc
2:def
+3:ghi
+4:jkl---------------------------- Test N6 ------------------------------
+1:abc
2:def
+3:ghi
+4:jkl
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput1	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4042 @@
+/the quick brown fox/
+    the quick brown fox
+    The quick brown FOX
+    What do you know about the quick brown fox?
+    What do you know about THE QUICK BROWN FOX?
+
+/The quick brown fox/i
+    the quick brown fox
+    The quick brown FOX
+    What do you know about the quick brown fox?
+    What do you know about THE QUICK BROWN FOX?
+
+/abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
+    abcd\t\n\r\f\a\e9;\$\\?caxyz
+
+/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
+    abxyzpqrrrabbxyyyypqAzz
+    abxyzpqrrrabbxyyyypqAzz
+    aabxyzpqrrrabbxyyyypqAzz
+    aaabxyzpqrrrabbxyyyypqAzz
+    aaaabxyzpqrrrabbxyyyypqAzz
+    abcxyzpqrrrabbxyyyypqAzz
+    aabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypAzz
+    aaabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqqAzz
+    aaaabcxyzpqrrrabbxyyyypqAzz
+    abxyzzpqrrrabbxyyyypqAzz
+    aabxyzzzpqrrrabbxyyyypqAzz
+    aaabxyzzzzpqrrrabbxyyyypqAzz
+    aaaabxyzzzzpqrrrabbxyyyypqAzz
+    abcxyzzpqrrrabbxyyyypqAzz
+    aabcxyzzzpqrrrabbxyyyypqAzz
+    aaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypABzz
+    aaabcxyzpqrrrabbxyyyypABBzz
+    >>>aaabxyzpqrrrabbxyyyypqAzz
+    >aaaabxyzpqrrrabbxyyyypqAzz
+    >>>>abcxyzpqrrrabbxyyyypqAzz
+    *** Failers
+    abxyzpqrrabbxyyyypqAzz
+    abxyzpqrrrrabbxyyyypqAzz
+    abxyzpqrrrabxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyypqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
+
+/^(abc){1,2}zz/
+    abczz
+    abcabczz
+    *** Failers
+    zz
+    abcabcabczz
+    >>abczz
+
+/^(b+?|a){1,2}?c/
+    bc
+    bbc
+    bbbc
+    bac
+    bbac
+    aac
+    abbbbbbbbbbbc
+    bbbbbbbbbbbac
+    *** Failers
+    aaac
+    abbbbbbbbbbbac
+
+/^(b+|a){1,2}c/
+    bc
+    bbc
+    bbbc
+    bac
+    bbac
+    aac
+    abbbbbbbbbbbc
+    bbbbbbbbbbbac
+    *** Failers
+    aaac
+    abbbbbbbbbbbac
+
+/^(b+|a){1,2}?bc/
+    bbc
+
+/^(b*|ba){1,2}?bc/
+    babc
+    bbabc
+    bababc
+    *** Failers
+    bababbc
+    babababc
+
+/^(ba|b*){1,2}?bc/
+    babc
+    bbabc
+    bababc
+    *** Failers
+    bababbc
+    babababc
+
+/^\ca\cA\c[\c{\c:/
+    \x01\x01\e;z
+
+/^[ab\]cde]/
+    athing
+    bthing
+    ]thing
+    cthing
+    dthing
+    ething
+    *** Failers
+    fthing
+    [thing
+    \\thing
+
+/^[]cde]/
+    ]thing
+    cthing
+    dthing
+    ething
+    *** Failers
+    athing
+    fthing
+
+/^[^ab\]cde]/
+    fthing
+    [thing
+    \\thing
+    *** Failers
+    athing
+    bthing
+    ]thing
+    cthing
+    dthing
+    ething
+
+/^[^]cde]/
+    athing
+    fthing
+    *** Failers
+    ]thing
+    cthing
+    dthing
+    ething
+
+/^\/
+    
+
+/^ÿ/
+    ÿ
+
+/^[0-9]+$/
+    0
+    1
+    2
+    3
+    4
+    5
+    6
+    7
+    8
+    9
+    10
+    100
+    *** Failers
+    abc
+
+/^.*nter/
+    enter
+    inter
+    uponter
+
+/^xxx[0-9]+$/
+    xxx0
+    xxx1234
+    *** Failers
+    xxx
+
+/^.+[0-9][0-9][0-9]$/
+    x123
+    xx123
+    123456
+    *** Failers
+    123
+    x1234
+
+/^.+?[0-9][0-9][0-9]$/
+    x123
+    xx123
+    123456
+    *** Failers
+    123
+    x1234
+
+/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
+    abc!pqr=apquxz.ixr.zzz.ac.uk
+    *** Failers
+    !pqr=apquxz.ixr.zzz.ac.uk
+    abc!=apquxz.ixr.zzz.ac.uk
+    abc!pqr=apquxz:ixr.zzz.ac.uk
+    abc!pqr=apquxz.ixr.zzz.ac.ukk
+
+/:/
+    Well, we need a colon: somewhere
+    *** Fail if we don't
+
+/([\da-f:]+)$/i
+    0abc
+    abc
+    fed
+    E
+    ::
+    5f03:12C0::932e
+    fed def
+    Any old stuff
+    *** Failers
+    0zzz
+    gzzz
+    fed\x20
+    Any old rubbish
+
+/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
+    .1.2.3
+    A.12.123.0
+    *** Failers
+    .1.2.3333
+    1.2.3
+    1234.2.3
+
+/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
+    1 IN SOA non-sp1 non-sp2(
+    1    IN    SOA    non-sp1    non-sp2   (
+    *** Failers
+    1IN SOA non-sp1 non-sp2(
+
+/^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
+    a.
+    Z.
+    2.
+    ab-c.pq-r.
+    sxk.zzz.ac.uk.
+    x-.y-.
+    *** Failers
+    -abc.peq.
+
+/^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
+    *.a
+    *.b0-a
+    *.c3-b.c
+    *.c-a.b-c
+    *** Failers
+    *.0
+    *.a-
+    *.a-b.c-
+    *.c-a.0-c
+
+/^(?=ab(de))(abd)(e)/
+    abde
+
+/^(?!(ab)de|x)(abd)(f)/
+    abdf
+
+/^(?=(ab(cd)))(ab)/
+    abcd
+
+/^[\da-f](\.[\da-f])*$/i
+    a.b.c.d
+    A.B.C.D
+    a.b.c.1.2.3.C
+
+/^\".*\"\s*(;.*)?$/
+    \"1234\"
+    \"abcd\" ;
+    \"\" ; rhubarb
+    *** Failers
+    \"1234\" : things
+
+/^$/
+    \
+    *** Failers
+
+/   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/x
+    ab c
+    *** Failers
+    abc
+    ab cde
+
+/(?x)   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/
+    ab c
+    *** Failers
+    abc
+    ab cde
+
+/^   a\ b[c ]d       $/x
+    a bcd
+    a b d
+    *** Failers
+    abcd
+    ab d
+
+/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
+    abcdefhijklm
+
+/^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
+    abcdefhijklm
+
+/^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
+    a+ Z0+\x08\n\x1d\x12
+
+/^[.^$|()*+?{,}]+/
+    .^\$(*+)|{?,?}
+
+/^a*\w/
+    z
+    az
+    aaaz
+    a
+    aa
+    aaaa
+    a+
+    aa+
+
+/^a*?\w/
+    z
+    az
+    aaaz
+    a
+    aa
+    aaaa
+    a+
+    aa+
+
+/^a+\w/
+    az
+    aaaz
+    aa
+    aaaa
+    aa+
+
+/^a+?\w/
+    az
+    aaaz
+    aa
+    aaaa
+    aa+
+
+/^\d{8}\w{2,}/
+    1234567890
+    12345678ab
+    12345678__
+    *** Failers
+    1234567
+
+/^[aeiou\d]{4,5}$/
+    uoie
+    1234
+    12345
+    aaaaa
+    *** Failers
+    123456
+
+/^[aeiou\d]{4,5}?/
+    uoie
+    1234
+    12345
+    aaaaa
+    123456
+
+/\A(abc|def)=(\1){2,3}\Z/
+    abc=abcabc
+    def=defdefdef
+    *** Failers
+    abc=defdef
+
+/^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
+    abcdefghijkcda2
+    abcdefghijkkkkcda2
+
+/(cat(a(ract|tonic)|erpillar)) \1()2(3)/
+    cataract cataract23
+    catatonic catatonic23
+    caterpillar caterpillar23
+
+
+/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
+    From abcd  Mon Sep 01 12:33:02 1997
+
+/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
+    From abcd  Mon Sep 01 12:33:02 1997
+    From abcd  Mon Sep  1 12:33:02 1997
+    *** Failers
+    From abcd  Sep 01 12:33:02 1997
+
+/^12.34/s
+    12\n34
+    12\r34
+
+/\w+(?=\t)/
+    the quick brown\t fox
+
+/foo(?!bar)(.*)/
+    foobar is foolish see?
+
+/(?:(?!foo)...|^.{0,2})bar(.*)/
+    foobar crowbar etc
+    barrel
+    2barrel
+    A barrel
+
+/^(\D*)(?=\d)(?!123)/
+    abc456
+    *** Failers
+    abc123
+
+/^1234(?# test newlines
+  inside)/
+    1234
+
+/^1234 #comment in extended re
+  /x
+    1234
+
+/#rhubarb
+  abcd/x
+    abcd
+
+/^abcd#rhubarb/x
+    abcd
+
+/^(a)\1{2,3}(.)/
+    aaab
+    aaaab
+    aaaaab
+    aaaaaab
+
+/(?!^)abc/
+    the abc
+    *** Failers
+    abc
+
+/(?=^)abc/
+    abc
+    *** Failers
+    the abc
+
+/^[ab]{1,3}(ab*|b)/
+    aabbbbb
+
+/^[ab]{1,3}?(ab*|b)/
+    aabbbbb
+
+/^[ab]{1,3}?(ab*?|b)/
+    aabbbbb
+
+/^[ab]{1,3}(ab*?|b)/
+    aabbbbb
+
+/  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                          # optional leading comment
+(?:    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+# address
+|                     #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)             # one word, optionally followed by....
+(?:
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
+\(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)       |  # comments, or...
+
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+# quoted strings
+)*
+<  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                     # leading <
+(?:  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  ,  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+)* # further okay, if led by comma
+:                                # closing colon
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  )? #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+#       address spec
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  > #                  trailing >
+# name and address
+)  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                       # optional trailing comment
+/x
+    Alan Other <user\@dom.ain>
+    <user\@dom.ain>
+    user\@dom.ain
+    \"A. Other\" <user.1234\@dom.ain> (a comment)
+    A. Other <user.1234\@dom.ain> (a comment)
+    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
+    A missing angle <user\@some.where
+    *** Failers
+    The quick brown fox
+
+/[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional leading comment
+(?:
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# additional words
+)*
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+# address
+|                             #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+# leading word
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *               # "normal" atoms and or spaces
+(?:
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+|
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+) # "special" comment or quoted string
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *            #  more "normal"
+)*
+<
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# <
+(?:
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+(?: ,
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+)*  # additional domains
+:
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)?     #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# additional words
+)*
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+#       address spec
+>                    #                 >
+# name and address
+)
+/x
+    Alan Other <user\@dom.ain>
+    <user\@dom.ain>
+    user\@dom.ain
+    \"A. Other\" <user.1234\@dom.ain> (a comment)
+    A. Other <user.1234\@dom.ain> (a comment)
+    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
+    A missing angle <user\@some.where
+    *** Failers
+    The quick brown fox
+
+/abc\0def\00pqr\000xyz\0000AB/
+    abc\0def\00pqr\000xyz\0000AB
+    abc456 abc\0def\00pqr\000xyz\0000ABCDE
+
+/abc\x0def\x00pqr\x000xyz\x0000AB/
+    abc\x0def\x00pqr\x000xyz\x0000AB
+    abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
+
+/^[\000-\037]/
+    \0A
+    \01B
+    \037C
+
+/\0*/
+    \0\0\0\0
+
+/A\x0{2,3}Z/
+    The A\x0\x0Z
+    An A\0\x0\0Z
+    *** Failers
+    A\0Z
+    A\0\x0\0\x0Z
+
+/^(cow|)\1(bell)/
+    cowcowbell
+    bell
+    *** Failers
+    cowbell
+
+/^\s/
+    \040abc
+    \x0cabc
+    \nabc
+    \rabc
+    \tabc
+    *** Failers
+    abc
+
+/^a	b
+      c/x
+    abc
+
+/^(a|)\1*b/
+    ab
+    aaaab
+    b
+    *** Failers
+    acb
+
+/^(a|)\1+b/
+    aab
+    aaaab
+    b
+    *** Failers
+    ab
+
+/^(a|)\1?b/
+    ab
+    aab
+    b
+    *** Failers
+    acb
+
+/^(a|)\1{2}b/
+    aaab
+    b
+    *** Failers
+    ab
+    aab
+    aaaab
+
+/^(a|)\1{2,3}b/
+    aaab
+    aaaab
+    b
+    *** Failers
+    ab
+    aab
+    aaaaab
+
+/ab{1,3}bc/
+    abbbbc
+    abbbc
+    abbc
+    *** Failers
+    abc
+    abbbbbc
+
+/([^.]*)\.([^:]*):[T ]+(.*)/
+    track1.title:TBlah blah blah
+
+/([^.]*)\.([^:]*):[T ]+(.*)/i
+    track1.title:TBlah blah blah
+
+/([^.]*)\.([^:]*):[t ]+(.*)/i
+    track1.title:TBlah blah blah
+
+/^[W-c]+$/
+    WXY_^abc
+    *** Failers
+    wxy
+
+/^[W-c]+$/i
+    WXY_^abc
+    wxy_^ABC
+
+/^[\x3f-\x5F]+$/i
+    WXY_^abc
+    wxy_^ABC
+
+/^abc$/m
+    abc
+    qqq\nabc
+    abc\nzzz
+    qqq\nabc\nzzz
+
+/^abc$/
+    abc
+    *** Failers
+    qqq\nabc
+    abc\nzzz
+    qqq\nabc\nzzz
+
+/\Aabc\Z/m
+    abc
+    abc\n 
+    *** Failers
+    qqq\nabc
+    abc\nzzz
+    qqq\nabc\nzzz
+    
+/\A(.)*\Z/s
+    abc\ndef
+
+/\A(.)*\Z/m
+    *** Failers
+    abc\ndef
+
+/(?:b)|(?::+)/
+    b::c
+    c::b
+
+/[-az]+/
+    az-
+    *** Failers
+    b
+
+/[az-]+/
+    za-
+    *** Failers
+    b
+
+/[a\-z]+/
+    a-z
+    *** Failers
+    b
+
+/[a-z]+/
+    abcdxyz
+
+/[\d-]+/
+    12-34
+    *** Failers
+    aaa
+
+/[\d-z]+/
+    12-34z
+    *** Failers
+    aaa
+
+/\x5c/
+    \\
+
+/\x20Z/
+    the Zoo
+    *** Failers
+    Zulu
+
+/(abc)\1/i
+    abcabc
+    ABCabc
+    abcABC
+
+/ab{3cd/
+    ab{3cd
+
+/ab{3,cd/
+    ab{3,cd
+
+/ab{3,4a}cd/
+    ab{3,4a}cd
+
+/{4,5a}bc/
+    {4,5a}bc
+
+/abc$/
+    abc
+    abc\n
+    *** Failers
+    abc\ndef
+
+/(abc)\123/
+    abc\x53
+
+/(abc)\223/
+    abc\x93
+
+/(abc)\323/
+    abc\xd3
+
+/(abc)\100/
+    abc\x40
+    abc\100
+
+/(abc)\1000/
+    abc\x400
+    abc\x40\x30
+    abc\1000
+    abc\100\x30
+    abc\100\060
+    abc\100\60
+
+/abc\81/
+    abc\081
+    abc\0\x38\x31
+
+/abc\91/
+    abc\091
+    abc\0\x39\x31
+
+/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
+    abcdefghijkllS
+
+/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
+    abcdefghijk\12S
+
+/ab\idef/
+    abidef
+
+/a{0}bc/
+    bc
+
+/(a|(bc)){0,0}?xyz/
+    xyz
+
+/abc[\10]de/
+    abc\010de
+
+/abc[\1]de/
+    abc\1de
+
+/(abc)[\1]de/
+    abc\1de
+
+/(?s)a.b/
+    a\nb
+
+/^([^a])([^\b])([^c]*)([^d]{3,4})/
+    baNOTccccd
+    baNOTcccd
+    baNOTccd
+    bacccd
+    *** Failers
+    anything
+    b\bc   
+    baccd
+
+/[^a]/
+    Abc
+  
+/[^a]/i
+    Abc 
+
+/[^a]+/
+    AAAaAbc
+  
+/[^a]+/i
+    AAAaAbc 
+
+/[^a]+/
+    bbb\nccc
+   
+/[^k]$/
+    abc
+    *** Failers
+    abk   
+   
+/[^k]{2,3}$/
+    abc
+    kbc
+    kabc 
+    *** Failers
+    abk
+    akb
+    akk 
+
+/^\d{8,}\@.+[^k]$/
+    12345678\@a.b.c.d
+    123456789\@x.y.z
+    *** Failers
+    12345678\@x.y.uk
+    1234567\@a.b.c.d       
+
+/(a)\1{8,}/
+    aaaaaaaaa
+    aaaaaaaaaa
+    *** Failers
+    aaaaaaa   
+
+/[^a]/
+    aaaabcd
+    aaAabcd 
+
+/[^a]/i
+    aaaabcd
+    aaAabcd 
+
+/[^az]/
+    aaaabcd
+    aaAabcd 
+
+/[^az]/i
+    aaaabcd
+    aaAabcd 
+
+/\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377/
+ \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377
+
+/P[^*]TAIRE[^*]{1,6}?LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+
+/P[^*]TAIRE[^*]{1,}?LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+
+/(\.\d\d[1-9]?)\d+/
+    1.230003938
+    1.875000282   
+    1.235  
+                  
+/(\.\d\d((?=0)|\d(?=\d)))/
+    1.230003938      
+    1.875000282
+    *** Failers 
+    1.235 
+    
+/a(?)b/
+    ab 
+ 
+/\b(foo)\s+(\w+)/i
+    Food is on the foo table
+    
+/foo(.*)bar/
+    The food is under the bar in the barn.
+    
+/foo(.*?)bar/  
+    The food is under the bar in the barn.
+
+/(.*)(\d*)/
+    I have 2 numbers: 53147
+    
+/(.*)(\d+)/
+    I have 2 numbers: 53147
+ 
+/(.*?)(\d*)/
+    I have 2 numbers: 53147
+
+/(.*?)(\d+)/
+    I have 2 numbers: 53147
+
+/(.*)(\d+)$/
+    I have 2 numbers: 53147
+
+/(.*?)(\d+)$/
+    I have 2 numbers: 53147
+
+/(.*)\b(\d+)$/
+    I have 2 numbers: 53147
+
+/(.*\D)(\d+)$/
+    I have 2 numbers: 53147
+
+/^\D*(?!123)/
+    ABC123
+     
+/^(\D*)(?=\d)(?!123)/
+    ABC445
+    *** Failers
+    ABC123
+    
+/^[W-]46]/
+    W46]789 
+    -46]789
+    *** Failers
+    Wall
+    Zebra
+    42
+    [abcd] 
+    ]abcd[
+       
+/^[W-\]46]/
+    W46]789 
+    Wall
+    Zebra
+    Xylophone  
+    42
+    [abcd] 
+    ]abcd[
+    \\backslash 
+    *** Failers
+    -46]789
+    well
+    
+/\d\d\/\d\d\/\d\d\d\d/
+    01/01/2000
+
+/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
+  word cat dog elephant mussel cow horse canary baboon snake shark otherword
+  word cat dog elephant mussel cow horse canary baboon snake shark
+
+/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
+  word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+
+/^(a){0,0}/
+    bcd
+    abc
+    aab     
+
+/^(a){0,1}/
+    bcd
+    abc
+    aab  
+
+/^(a){0,2}/
+    bcd
+    abc
+    aab  
+
+/^(a){0,3}/
+    bcd
+    abc
+    aab
+    aaa   
+
+/^(a){0,}/
+    bcd
+    abc
+    aab
+    aaa
+    aaaaaaaa    
+
+/^(a){1,1}/
+    bcd
+    abc
+    aab  
+
+/^(a){1,2}/
+    bcd
+    abc
+    aab  
+
+/^(a){1,3}/
+    bcd
+    abc
+    aab
+    aaa   
+
+/^(a){1,}/
+    bcd
+    abc
+    aab
+    aaa
+    aaaaaaaa    
+
+/.*\.gif/
+    borfle\nbib.gif\nno
+
+/.{0,}\.gif/
+    borfle\nbib.gif\nno
+
+/.*\.gif/m
+    borfle\nbib.gif\nno
+
+/.*\.gif/s
+    borfle\nbib.gif\nno
+
+/.*\.gif/ms
+    borfle\nbib.gif\nno
+    
+/.*$/
+    borfle\nbib.gif\nno
+
+/.*$/m
+    borfle\nbib.gif\nno
+
+/.*$/s
+    borfle\nbib.gif\nno
+
+/.*$/ms
+    borfle\nbib.gif\nno
+    
+/.*$/
+    borfle\nbib.gif\nno\n
+
+/.*$/m
+    borfle\nbib.gif\nno\n
+
+/.*$/s
+    borfle\nbib.gif\nno\n
+
+/.*$/ms
+    borfle\nbib.gif\nno\n
+    
+/(.*X|^B)/
+    abcde\n1234Xyz
+    BarFoo 
+    *** Failers
+    abcde\nBar  
+
+/(.*X|^B)/m
+    abcde\n1234Xyz
+    BarFoo 
+    abcde\nBar  
+
+/(.*X|^B)/s
+    abcde\n1234Xyz
+    BarFoo 
+    *** Failers
+    abcde\nBar  
+
+/(.*X|^B)/ms
+    abcde\n1234Xyz
+    BarFoo 
+    abcde\nBar  
+
+/(?s)(.*X|^B)/
+    abcde\n1234Xyz
+    BarFoo 
+    *** Failers 
+    abcde\nBar  
+
+/(?s:.*X|^B)/
+    abcde\n1234Xyz
+    BarFoo 
+    *** Failers 
+    abcde\nBar  
+
+/^.*B/
+    **** Failers
+    abc\nB
+     
+/(?s)^.*B/
+    abc\nB
+
+/(?m)^.*B/
+    abc\nB
+     
+/(?ms)^.*B/
+    abc\nB
+
+/(?ms)^B/
+    abc\nB
+
+/(?s)B$/
+    B\n
+
+/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
+    123456654321
+  
+/^\d\d\d\d\d\d\d\d\d\d\d\d/
+    123456654321 
+
+/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
+    123456654321
+  
+/^[abc]{12}/
+    abcabcabcabc
+    
+/^[a-c]{12}/
+    abcabcabcabc
+    
+/^(a|b|c){12}/
+    abcabcabcabc 
+
+/^[abcdefghijklmnopqrstuvwxy0123456789]/
+    n
+    *** Failers 
+    z 
+
+/abcde{0,0}/
+    abcd
+    *** Failers
+    abce  
+
+/ab[cd]{0,0}e/
+    abe
+    *** Failers
+    abcde 
+    
+/ab(c){0,0}d/
+    abd
+    *** Failers
+    abcd   
+
+/a(b*)/
+    a
+    ab
+    abbbb
+    *** Failers
+    bbbbb    
+    
+/ab\d{0}e/
+    abe
+    *** Failers
+    ab1e   
+    
+/"([^\\"]+|\\.)*"/
+    the \"quick\" brown fox
+    \"the \\\"quick\\\" brown fox\" 
+
+/.*?/g+
+    abc
+  
+/\b/g+
+    abc 
+
+/\b/+g
+    abc 
+
+//g
+    abc
+
+/<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/is
+  <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
+
+/a[^a]b/
+    acb
+    a\nb
+    
+/a.b/
+    acb
+    *** Failers 
+    a\nb   
+    
+/a[^a]b/s
+    acb
+    a\nb  
+    
+/a.b/s
+    acb
+    a\nb  
+
+/^(b+?|a){1,2}?c/
+    bac
+    bbac
+    bbbac
+    bbbbac
+    bbbbbac 
+
+/^(b+|a){1,2}?c/
+    bac
+    bbac
+    bbbac
+    bbbbac
+    bbbbbac 
+    
+/(?!\A)x/m
+    x\nb\n
+    a\bx\n  
+    
+/\x0{ab}/
+    \0{ab} 
+
+/(A|B)*?CD/
+    CD 
+    
+/(A|B)*CD/
+    CD 
+
+/(AB)*?\1/
+    ABABAB
+
+/(AB)*\1/
+    ABABAB
+    
+/(?<!bar)foo/
+    foo
+    catfood
+    arfootle
+    rfoosh
+    *** Failers
+    barfoo
+    towbarfoo
+
+/\w{3}(?<!bar)foo/
+    catfood
+    *** Failers
+    foo
+    barfoo
+    towbarfoo
+
+/(?<=(foo)a)bar/
+    fooabar
+    *** Failers
+    bar
+    foobbar
+      
+/\Aabc\z/m
+    abc
+    *** Failers
+    abc\n   
+    qqq\nabc
+    abc\nzzz
+    qqq\nabc\nzzz
+
+"(?>.*/)foo"
+    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
+
+"(?>.*/)foo"
+    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+
+/(?>(\.\d\d[1-9]?))\d+/
+    1.230003938
+    1.875000282
+    *** Failers 
+    1.235 
+
+/^((?>\w+)|(?>\s+))*$/
+    now is the time for all good men to come to the aid of the party
+    *** Failers
+    this is not a line with only words and spaces!
+    
+/(\d+)(\w)/
+    12345a
+    12345+ 
+
+/((?>\d+))(\w)/
+    12345a
+    *** Failers
+    12345+ 
+
+/(?>a+)b/
+    aaab
+
+/((?>a+)b)/
+    aaab
+
+/(?>(a+))b/
+    aaab
+
+/(?>b)+/
+    aaabbbccc
+
+/(?>a+|b+|c+)*c/
+    aaabbbbccccd
+
+/((?>[^()]+)|\([^()]*\))+/
+    ((abc(ade)ufh()()x
+    
+/\(((?>[^()]+)|\([^()]+\))+\)/ 
+    (abc)
+    (abc(def)xyz)
+    *** Failers
+    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa   
+
+/a(?-i)b/i
+    ab
+    Ab
+    *** Failers 
+    aB
+    AB
+        
+/(a (?x)b c)d e/
+    a bcd e
+    *** Failers
+    a b cd e
+    abcd e   
+    a bcde 
+ 
+/(a b(?x)c d (?-x)e f)/
+    a bcde f
+    *** Failers
+    abcdef  
+
+/(a(?i)b)c/
+    abc
+    aBc
+    *** Failers
+    abC
+    aBC  
+    Abc
+    ABc
+    ABC
+    AbC
+    
+/a(?i:b)c/
+    abc
+    aBc
+    *** Failers 
+    ABC
+    abC
+    aBC
+    
+/a(?i:b)*c/
+    aBc
+    aBBc
+    *** Failers 
+    aBC
+    aBBC
+    
+/a(?=b(?i)c)\w\wd/
+    abcd
+    abCd
+    *** Failers
+    aBCd
+    abcD     
+    
+/(?s-i:more.*than).*million/i
+    more than million
+    more than MILLION
+    more \n than Million 
+    *** Failers
+    MORE THAN MILLION    
+    more \n than \n million 
+
+/(?:(?s-i)more.*than).*million/i
+    more than million
+    more than MILLION
+    more \n than Million 
+    *** Failers
+    MORE THAN MILLION    
+    more \n than \n million 
+    
+/(?>a(?i)b+)+c/ 
+    abc
+    aBbc
+    aBBc 
+    *** Failers
+    Abc
+    abAb    
+    abbC 
+    
+/(?=a(?i)b)\w\wc/
+    abc
+    aBc
+    *** Failers
+    Ab 
+    abC
+    aBC     
+    
+/(?<=a(?i)b)(\w\w)c/
+    abxxc
+    aBxxc
+    *** Failers
+    Abxxc
+    ABxxc
+    abxxC      
+
+/(?:(a)|b)(?(1)A|B)/
+    aA
+    bB
+    *** Failers
+    aB
+    bA    
+
+/^(a)?(?(1)a|b)+$/
+    aa
+    b
+    bb  
+    *** Failers
+    ab   
+
+/^(?(?=abc)\w{3}:|\d\d)$/
+    abc:
+    12
+    *** Failers
+    123
+    xyz    
+
+/^(?(?!abc)\d\d|\w{3}:)$/
+    abc:
+    12
+    *** Failers
+    123
+    xyz    
+    
+/(?(?<=foo)bar|cat)/
+    foobar
+    cat
+    fcat
+    focat   
+    *** Failers
+    foocat  
+
+/(?(?<!foo)cat|bar)/
+    foobar
+    cat
+    fcat
+    focat   
+    *** Failers
+    foocat  
+
+/( \( )? [^()]+ (?(1) \) |) /x
+    abcd
+    (abcd)
+    the quick (abcd) fox
+    (abcd   
+
+/( \( )? [^()]+ (?(1) \) ) /x
+    abcd
+    (abcd)
+    the quick (abcd) fox
+    (abcd   
+
+/^(?(2)a|(1)(2))+$/
+    12
+    12a
+    12aa
+    *** Failers
+    1234    
+
+/((?i)blah)\s+\1/
+    blah blah
+    BLAH BLAH
+    Blah Blah
+    blaH blaH
+    *** Failers
+    blah BLAH
+    Blah blah      
+    blaH blah 
+
+/((?i)blah)\s+(?i:\1)/
+    blah blah
+    BLAH BLAH
+    Blah Blah
+    blaH blaH
+    blah BLAH
+    Blah blah      
+    blaH blah 
+
+/(?>a*)*/
+    a
+    aa
+    aaaa
+    
+/(abc|)+/
+    abc
+    abcabc
+    abcabcabc
+    xyz      
+
+/([a]*)*/
+    a
+    aaaaa 
+ 
+/([ab]*)*/
+    a
+    b
+    ababab
+    aaaabcde
+    bbbb    
+ 
+/([^a]*)*/
+    b
+    bbbb
+    aaa   
+ 
+/([^ab]*)*/
+    cccc
+    abab  
+ 
+/([a]*?)*/
+    a
+    aaaa 
+ 
+/([ab]*?)*/
+    a
+    b
+    abab
+    baba   
+ 
+/([^a]*?)*/
+    b
+    bbbb
+    aaa   
+ 
+/([^ab]*?)*/
+    c
+    cccc
+    baba   
+ 
+/(?>a*)*/
+    a
+    aaabcde 
+ 
+/((?>a*))*/
+    aaaaa
+    aabbaa 
+ 
+/((?>a*?))*/
+    aaaaa
+    aabbaa 
+
+/(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /x
+    12-sep-98
+    12-09-98
+    *** Failers
+    sep-12-98
+        
+/(?<=(foo))bar\1/
+    foobarfoo
+    foobarfootling 
+    *** Failers
+    foobar
+    barfoo   
+
+/(?i:saturday|sunday)/
+    saturday
+    sunday
+    Saturday
+    Sunday
+    SATURDAY
+    SUNDAY
+    SunDay
+    
+/(a(?i)bc|BB)x/
+    abcx
+    aBCx
+    bbx
+    BBx
+    *** Failers
+    abcX
+    aBCX
+    bbX
+    BBX               
+
+/^([ab](?i)[cd]|[ef])/
+    ac
+    aC
+    bD
+    elephant
+    Europe 
+    frog
+    France
+    *** Failers
+    Africa     
+
+/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
+    ab
+    aBd
+    xy
+    xY
+    zebra
+    Zambesi
+    *** Failers
+    aCD  
+    XY  
+
+/(?<=foo\n)^bar/m
+    foo\nbar
+    *** Failers
+    bar
+    baz\nbar   
+
+/(?<=(?<!foo)bar)baz/
+    barbaz
+    barbarbaz 
+    koobarbaz 
+    *** Failers
+    baz
+    foobarbaz 
+
+/The case of aaaaaa is missed out below because I think Perl 5.005_02 gets/
+/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/
+/where it does set $1 to aa when matching aaaaaa./
+
+/^(a\1?){4}$/
+    a
+    aa
+    aaa
+    aaaa
+    aaaaa
+    aaaaaaa
+    aaaaaaaa
+    aaaaaaaaa
+    aaaaaaaaaa
+    aaaaaaaaaaa
+    aaaaaaaaaaaa
+    aaaaaaaaaaaaa
+    aaaaaaaaaaaaaa
+    aaaaaaaaaaaaaaa
+    aaaaaaaaaaaaaaaa               
+
+/^(a\1?)(a\1?)(a\2?)(a\3?)$/
+    a
+    aa
+    aaa
+    aaaa
+    aaaaa
+    aaaaaa
+    aaaaaaa
+    aaaaaaaa
+    aaaaaaaaa
+    aaaaaaaaaa
+    aaaaaaaaaaa
+    aaaaaaaaaaaa
+    aaaaaaaaaaaaa
+    aaaaaaaaaaaaaa
+    aaaaaaaaaaaaaaa
+    aaaaaaaaaaaaaaaa               
+
+/The following tests are taken from the Perl 5.005 test suite; some of them/
+/are compatible with 5.004, but I'd rather not have to sort them out./
+
+/abc/
+    abc
+    xabcy
+    ababc
+    *** Failers
+    xbc
+    axc
+    abx
+
+/ab*c/
+    abc
+
+/ab*bc/
+    abc
+    abbc
+    abbbbc
+
+/.{1}/
+    abbbbc
+
+/.{3,4}/
+    abbbbc
+
+/ab{0,}bc/
+    abbbbc
+
+/ab+bc/
+    abbc
+    *** Failers
+    abc
+    abq
+
+/ab{1,}bc/
+
+/ab+bc/
+    abbbbc
+
+/ab{1,}bc/
+    abbbbc
+
+/ab{1,3}bc/
+    abbbbc
+
+/ab{3,4}bc/
+    abbbbc
+
+/ab{4,5}bc/
+    *** Failers
+    abq
+    abbbbc
+
+/ab?bc/
+    abbc
+    abc
+
+/ab{0,1}bc/
+    abc
+
+/ab?bc/
+
+/ab?c/
+    abc
+
+/ab{0,1}c/
+    abc
+
+/^abc$/
+    abc
+    *** Failers
+    abbbbc
+    abcc
+
+/^abc/
+    abcc
+
+/^abc$/
+
+/abc$/
+    aabc
+    *** Failers
+    aabc
+    aabcd
+
+/^/
+    abc
+
+/$/
+    abc
+
+/a.c/
+    abc
+    axc
+
+/a.*c/
+    axyzc
+
+/a[bc]d/
+    abd
+    *** Failers
+    axyzd
+    abc
+
+/a[b-d]e/
+    ace
+
+/a[b-d]/
+    aac
+
+/a[-b]/
+    a-
+
+/a[b-]/
+    a-
+
+/a]/
+    a]
+
+/a[]]b/
+    a]b
+
+/a[^bc]d/
+    aed
+    *** Failers
+    abd
+    abd
+
+/a[^-b]c/
+    adc
+
+/a[^]b]c/
+    adc
+    *** Failers
+    a-c
+    a]c
+
+/\ba\b/
+    a-
+    -a
+    -a-
+
+/\by\b/
+    *** Failers
+    xy
+    yz
+    xyz
+
+/\Ba\B/
+    *** Failers
+    a-
+    -a
+    -a-
+
+/\By\b/
+    xy
+
+/\by\B/
+    yz
+
+/\By\B/
+    xyz
+
+/\w/
+    a
+
+/\W/
+    -
+    *** Failers
+    -
+    a
+
+/a\sb/
+    a b
+
+/a\Sb/
+    a-b
+    *** Failers
+    a-b
+    a b
+
+/\d/
+    1
+
+/\D/
+    -
+    *** Failers
+    -
+    1
+
+/[\w]/
+    a
+
+/[\W]/
+    -
+    *** Failers
+    -
+    a
+
+/a[\s]b/
+    a b
+
+/a[\S]b/
+    a-b
+    *** Failers
+    a-b
+    a b
+
+/[\d]/
+    1
+
+/[\D]/
+    -
+    *** Failers
+    -
+    1
+
+/ab|cd/
+    abc
+    abcd
+
+/()ef/
+    def
+
+/$b/
+
+/a\(b/
+    a(b
+
+/a\(*b/
+    ab
+    a((b
+
+/a\\b/
+    a\b
+
+/((a))/
+    abc
+
+/(a)b(c)/
+    abc
+
+/a+b+c/
+    aabbabc
+
+/a{1,}b{1,}c/
+    aabbabc
+
+/a.+?c/
+    abcabc
+
+/(a+|b)*/
+    ab
+
+/(a+|b){0,}/
+    ab
+
+/(a+|b)+/
+    ab
+
+/(a+|b){1,}/
+    ab
+
+/(a+|b)?/
+    ab
+
+/(a+|b){0,1}/
+    ab
+
+/[^ab]*/
+    cde
+
+/abc/
+    *** Failers
+    b
+    
+
+/a*/
+    
+
+/([abc])*d/
+    abbbcd
+
+/([abc])*bcd/
+    abcd
+
+/a|b|c|d|e/
+    e
+
+/(a|b|c|d|e)f/
+    ef
+
+/abcd*efg/
+    abcdefg
+
+/ab*/
+    xabyabbbz
+    xayabbbz
+
+/(ab|cd)e/
+    abcde
+
+/[abhgefdc]ij/
+    hij
+
+/^(ab|cd)e/
+
+/(abc|)ef/
+    abcdef
+
+/(a|b)c*d/
+    abcd
+
+/(ab|ab*)bc/
+    abc
+
+/a([bc]*)c*/
+    abc
+
+/a([bc]*)(c*d)/
+    abcd
+
+/a([bc]+)(c*d)/
+    abcd
+
+/a([bc]*)(c+d)/
+    abcd
+
+/a[bcd]*dcdcde/
+    adcdcde
+
+/a[bcd]+dcdcde/
+    *** Failers
+    abcde
+    adcdcde
+
+/(ab|a)b*c/
+    abc
+
+/((a)(b)c)(d)/
+    abcd
+
+/[a-zA-Z_][a-zA-Z0-9_]*/
+    alpha
+
+/^a(bc+|b[eh])g|.h$/
+    abh
+
+/(bc+d$|ef*g.|h?i(j|k))/
+    effgz
+    ij
+    reffgz
+    *** Failers
+    effg
+    bcdd
+
+/((((((((((a))))))))))/
+    a
+
+/((((((((((a))))))))))\10/
+    aa
+
+/(((((((((a)))))))))/
+    a
+
+/multiple words of text/
+    *** Failers
+    aa
+    uh-uh
+
+/multiple words/
+    multiple words, yeah
+
+/(.*)c(.*)/
+    abcde
+
+/\((.*), (.*)\)/
+    (a, b)
+
+/[k]/
+
+/abcd/
+    abcd
+
+/a(bc)d/
+    abcd
+
+/a[-]?c/
+    ac
+
+/(abc)\1/
+    abcabc
+
+/([a-c]*)\1/
+    abcabc
+
+/(a)|\1/
+    a
+    *** Failers
+    ab
+    x
+
+/(([a-c])b*?\2)*/
+    ababbbcbc
+
+/(([a-c])b*?\2){3}/
+    ababbbcbc
+
+/((\3|b)\2(a)x)+/
+    aaaxabaxbaaxbbax
+
+/((\3|b)\2(a)){2,}/
+    bbaababbabaaaaabbaaaabba
+
+/abc/i
+    ABC
+    XABCY
+    ABABC
+    *** Failers
+    aaxabxbaxbbx
+    XBC
+    AXC
+    ABX
+
+/ab*c/i
+    ABC
+
+/ab*bc/i
+    ABC
+    ABBC
+
+/ab*?bc/i
+    ABBBBC
+
+/ab{0,}?bc/i
+    ABBBBC
+
+/ab+?bc/i
+    ABBC
+
+/ab+bc/i
+    *** Failers
+    ABC
+    ABQ
+
+/ab{1,}bc/i
+
+/ab+bc/i
+    ABBBBC
+
+/ab{1,}?bc/i
+    ABBBBC
+
+/ab{1,3}?bc/i
+    ABBBBC
+
+/ab{3,4}?bc/i
+    ABBBBC
+
+/ab{4,5}?bc/i
+    *** Failers
+    ABQ
+    ABBBBC
+
+/ab??bc/i
+    ABBC
+    ABC
+
+/ab{0,1}?bc/i
+    ABC
+
+/ab??bc/i
+
+/ab??c/i
+    ABC
+
+/ab{0,1}?c/i
+    ABC
+
+/^abc$/i
+    ABC
+    *** Failers
+    ABBBBC
+    ABCC
+
+/^abc/i
+    ABCC
+
+/^abc$/i
+
+/abc$/i
+    AABC
+
+/^/i
+    ABC
+
+/$/i
+    ABC
+
+/a.c/i
+    ABC
+    AXC
+
+/a.*?c/i
+    AXYZC
+
+/a.*c/i
+    *** Failers
+    AABC
+    AXYZD
+
+/a[bc]d/i
+    ABD
+
+/a[b-d]e/i
+    ACE
+    *** Failers
+    ABC
+    ABD
+
+/a[b-d]/i
+    AAC
+
+/a[-b]/i
+    A-
+
+/a[b-]/i
+    A-
+
+/a]/i
+    A]
+
+/a[]]b/i
+    A]B
+
+/a[^bc]d/i
+    AED
+
+/a[^-b]c/i
+    ADC
+    *** Failers
+    ABD
+    A-C
+
+/a[^]b]c/i
+    ADC
+
+/ab|cd/i
+    ABC
+    ABCD
+
+/()ef/i
+    DEF
+
+/$b/i
+    *** Failers
+    A]C
+    B
+
+/a\(b/i
+    A(B
+
+/a\(*b/i
+    AB
+    A((B
+
+/a\\b/i
+    A\B
+
+/((a))/i
+    ABC
+
+/(a)b(c)/i
+    ABC
+
+/a+b+c/i
+    AABBABC
+
+/a{1,}b{1,}c/i
+    AABBABC
+
+/a.+?c/i
+    ABCABC
+
+/a.*?c/i
+    ABCABC
+
+/a.{0,5}?c/i
+    ABCABC
+
+/(a+|b)*/i
+    AB
+
+/(a+|b){0,}/i
+    AB
+
+/(a+|b)+/i
+    AB
+
+/(a+|b){1,}/i
+    AB
+
+/(a+|b)?/i
+    AB
+
+/(a+|b){0,1}/i
+    AB
+
+/(a+|b){0,1}?/i
+    AB
+
+/[^ab]*/i
+    CDE
+
+/abc/i
+
+/a*/i
+    
+
+/([abc])*d/i
+    ABBBCD
+
+/([abc])*bcd/i
+    ABCD
+
+/a|b|c|d|e/i
+    E
+
+/(a|b|c|d|e)f/i
+    EF
+
+/abcd*efg/i
+    ABCDEFG
+
+/ab*/i
+    XABYABBBZ
+    XAYABBBZ
+
+/(ab|cd)e/i
+    ABCDE
+
+/[abhgefdc]ij/i
+    HIJ
+
+/^(ab|cd)e/i
+    ABCDE
+
+/(abc|)ef/i
+    ABCDEF
+
+/(a|b)c*d/i
+    ABCD
+
+/(ab|ab*)bc/i
+    ABC
+
+/a([bc]*)c*/i
+    ABC
+
+/a([bc]*)(c*d)/i
+    ABCD
+
+/a([bc]+)(c*d)/i
+    ABCD
+
+/a([bc]*)(c+d)/i
+    ABCD
+
+/a[bcd]*dcdcde/i
+    ADCDCDE
+
+/a[bcd]+dcdcde/i
+
+/(ab|a)b*c/i
+    ABC
+
+/((a)(b)c)(d)/i
+    ABCD
+
+/[a-zA-Z_][a-zA-Z0-9_]*/i
+    ALPHA
+
+/^a(bc+|b[eh])g|.h$/i
+    ABH
+
+/(bc+d$|ef*g.|h?i(j|k))/i
+    EFFGZ
+    IJ
+    REFFGZ
+    *** Failers
+    ADCDCDE
+    EFFG
+    BCDD
+
+/((((((((((a))))))))))/i
+    A
+
+/((((((((((a))))))))))\10/i
+    AA
+
+/(((((((((a)))))))))/i
+    A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
+    A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
+    C
+
+/multiple words of text/i
+    *** Failers
+    AA
+    UH-UH
+
+/multiple words/i
+    MULTIPLE WORDS, YEAH
+
+/(.*)c(.*)/i
+    ABCDE
+
+/\((.*), (.*)\)/i
+    (A, B)
+
+/[k]/i
+
+/abcd/i
+    ABCD
+
+/a(bc)d/i
+    ABCD
+
+/a[-]?c/i
+    AC
+
+/(abc)\1/i
+    ABCABC
+
+/([a-c]*)\1/i
+    ABCABC
+
+/a(?!b)./
+    abad
+
+/a(?=d)./
+    abad
+
+/a(?=c|d)./
+    abad
+
+/a(?:b|c|d)(.)/
+    ace
+
+/a(?:b|c|d)*(.)/
+    ace
+
+/a(?:b|c|d)+?(.)/
+    ace
+    acdbcdbe
+
+/a(?:b|c|d)+(.)/
+    acdbcdbe
+
+/a(?:b|c|d){2}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){4,5}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){4,5}?(.)/
+    acdbcdbe
+
+/((foo)|(bar))*/
+    foobar
+
+/a(?:b|c|d){6,7}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){6,7}?(.)/
+    acdbcdbe
+
+/a(?:b|c|d){5,6}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){5,6}?(.)/
+    acdbcdbe
+
+/a(?:b|c|d){5,7}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){5,7}?(.)/
+    acdbcdbe
+
+/a(?:b|(c|e){1,2}?|d)+?(.)/
+    ace
+
+/^(.+)?B/
+    AB
+
+/^([^a-z])|(\^)$/
+    .
+
+/^[<>]&/
+    <&OUT
+
+/^(a\1?){4}$/
+    aaaaaaaaaa
+    *** Failers
+    AB
+    aaaaaaaaa
+    aaaaaaaaaaa
+
+/^(a(?(1)\1)){4}$/
+    aaaaaaaaaa
+    *** Failers
+    aaaaaaaaa
+    aaaaaaaaaaa
+
+/(?:(f)(o)(o)|(b)(a)(r))*/
+    foobar
+
+/(?<=a)b/
+    ab
+    *** Failers
+    cb
+    b
+
+/(?<!c)b/
+    ab
+    b
+    b
+
+/(?:..)*a/
+    aba
+
+/(?:..)*?a/
+    aba
+
+/^(?:b|a(?=(.)))*\1/
+    abc
+
+/^(){3,5}/
+    abc
+
+/^(a+)*ax/
+    aax
+
+/^((a|b)+)*ax/
+    aax
+
+/^((a|bc)+)*ax/
+    aax
+
+/(a|x)*ab/
+    cab
+
+/(a)*ab/
+    cab
+
+/(?:(?i)a)b/
+    ab
+
+/((?i)a)b/
+    ab
+
+/(?:(?i)a)b/
+    Ab
+
+/((?i)a)b/
+    Ab
+
+/(?:(?i)a)b/
+    *** Failers
+    cb
+    aB
+
+/((?i)a)b/
+
+/(?i:a)b/
+    ab
+
+/((?i:a))b/
+    ab
+
+/(?i:a)b/
+    Ab
+
+/((?i:a))b/
+    Ab
+
+/(?i:a)b/
+    *** Failers
+    aB
+    aB
+
+/((?i:a))b/
+
+/(?:(?-i)a)b/i
+    ab
+
+/((?-i)a)b/i
+    ab
+
+/(?:(?-i)a)b/i
+    aB
+
+/((?-i)a)b/i
+    aB
+
+/(?:(?-i)a)b/i
+    *** Failers
+    aB
+    Ab
+
+/((?-i)a)b/i
+
+/(?:(?-i)a)b/i
+    aB
+
+/((?-i)a)b/i
+    aB
+
+/(?:(?-i)a)b/i
+    *** Failers
+    Ab
+    AB
+
+/((?-i)a)b/i
+
+/(?-i:a)b/i
+    ab
+
+/((?-i:a))b/i
+    ab
+
+/(?-i:a)b/i
+    aB
+
+/((?-i:a))b/i
+    aB
+
+/(?-i:a)b/i
+    *** Failers
+    AB
+    Ab
+
+/((?-i:a))b/i
+
+/(?-i:a)b/i
+    aB
+
+/((?-i:a))b/i
+    aB
+
+/(?-i:a)b/i
+    *** Failers
+    Ab
+    AB
+
+/((?-i:a))b/i
+
+/((?-i:a.))b/i
+    *** Failers
+    AB
+    a\nB
+
+/((?s-i:a.))b/i
+    a\nB
+
+/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
+    cabbbb
+
+/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
+    caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+/(ab)\d\1/i
+    Ab4ab
+    ab4Ab
+
+/foo\w*\d{4}baz/
+    foobar1234baz
+
+/x(~~)*(?:(?:F)?)?/
+    x~~
+
+/^a(?#xxx){3}c/
+    aaac
+
+/^a (?#xxx) (?#yyy) {3}c/x
+    aaac
+
+/(?<![cd])b/
+    *** Failers
+    B\nB
+    dbcb
+
+/(?<![cd])[ab]/
+    dbaacb
+
+/(?<!(c|d))b/
+
+/(?<!(c|d))[ab]/
+    dbaacb
+
+/(?<!cd)[ab]/
+    cdaccb
+
+/^(?:a?b?)*$/
+    \
+    a
+    ab
+    aaa   
+    *** Failers
+    dbcb
+    a--
+    aa-- 
+
+/((?s)^a(.))((?m)^b$)/
+    a\nb\nc\n
+
+/((?m)^b$)/
+    a\nb\nc\n
+
+/(?m)^b/
+    a\nb\n
+
+/(?m)^(b)/
+    a\nb\n
+
+/((?m)^b)/
+    a\nb\n
+
+/\n((?m)^b)/
+    a\nb\n
+
+/((?s).)c(?!.)/
+    a\nb\nc\n
+    a\nb\nc\n
+
+/((?s)b.)c(?!.)/
+    a\nb\nc\n
+    a\nb\nc\n
+
+/^b/
+
+/()^b/
+    *** Failers
+    a\nb\nc\n
+    a\nb\nc\n
+
+/((?m)^b)/
+    a\nb\nc\n
+
+/(x)?(?(1)a|b)/
+    *** Failers
+    a
+    a
+
+/(x)?(?(1)b|a)/
+    a
+
+/()?(?(1)b|a)/
+    a
+
+/()(?(1)b|a)/
+
+/()?(?(1)a|b)/
+    a
+
+/^(\()?blah(?(1)(\)))$/
+    (blah)
+    blah
+    *** Failers
+    a
+    blah)
+    (blah
+
+/^(\(+)?blah(?(1)(\)))$/
+    (blah)
+    blah
+    *** Failers
+    blah)
+    (blah
+
+/(?(?!a)a|b)/
+
+/(?(?!a)b|a)/
+    a
+
+/(?(?=a)b|a)/
+    *** Failers
+    a
+    a
+
+/(?(?=a)a|b)/
+    a
+
+/(?=(a+?))(\1ab)/
+    aaab
+
+/^(?=(a+?))\1ab/
+
+/(\w+:)+/
+    one:
+
+/$(?<=^(a))/
+    a
+
+/(?=(a+?))(\1ab)/
+    aaab
+
+/^(?=(a+?))\1ab/
+    *** Failers
+    aaab
+    aaab
+
+/([\w:]+::)?(\w+)$/
+    abcd
+    xy:z:::abcd
+
+/^[^bcd]*(c+)/
+    aexycd
+
+/(a*)b+/
+    caab
+
+/([\w:]+::)?(\w+)$/
+    abcd
+    xy:z:::abcd
+    *** Failers
+    abcd:
+    abcd:
+
+/^[^bcd]*(c+)/
+    aexycd
+
+/(>a+)ab/
+
+/(?>a+)b/
+    aaab
+
+/([[:]+)/
+    a:[b]:
+
+/([[=]+)/
+    a=[b]=
+
+/([[.]+)/
+    a.[b].
+
+/((?>a+)b)/
+    aaab
+
+/(?>(a+))b/
+    aaab
+
+/((?>[^()]+)|\([^()]*\))+/
+    ((abc(ade)ufh()()x
+
+/a\Z/
+    *** Failers
+    aaab
+    a\nb\n
+
+/b\Z/
+    a\nb\n
+
+/b\z/
+
+/b\Z/
+    a\nb
+
+/b\z/
+    a\nb
+    *** Failers
+    
+/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
+    a
+    abc
+    a-b
+    0-9 
+    a.b
+    5.6.7  
+    the.quick.brown.fox
+    a100.b200.300c  
+    12-ab.1245 
+    *** Failers
+    \
+    .a
+    -a
+    a-
+    a.  
+    a_b 
+    a.-
+    a..  
+    ab..bc 
+    the.quick.brown.fox-
+    the.quick.brown.fox.
+    the.quick.brown.fox_
+    the.quick.brown.fox+       
+
+/(?>.*)(?<=(abcd|wxyz))/
+    alphabetabcd
+    endingwxyz
+    *** Failers
+    a rather long string that doesn't end with one of them
+
+/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
+    word cat dog elephant mussel cow horse canary baboon snake shark otherword
+    word cat dog elephant mussel cow horse canary baboon snake shark
+  
+/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
+    word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+
+/(?<=\d{3}(?!999))foo/
+    999foo
+    123999foo 
+    *** Failers
+    123abcfoo
+    
+/(?<=(?!...999)\d{3})foo/
+    999foo
+    123999foo 
+    *** Failers
+    123abcfoo
+
+/(?<=\d{3}(?!999)...)foo/
+    123abcfoo
+    123456foo 
+    *** Failers
+    123999foo  
+    
+/(?<=\d{3}...)(?<!999)foo/
+    123abcfoo   
+    123456foo 
+    *** Failers
+    123999foo  
+
+/<a[\s]+href[\s]*=[\s]*          # find <a href=
+ ([\"\'])?                       # find single or double quote
+ (?(1) (.*?)\1 | ([^\s]+))       # if quote found, match up to next matching
+                                 # quote, otherwise match up to next space
+/isx
+    <a href=abcd xyz
+    <a href=\"abcd xyz pqr\" cats
+    <a href=\'abcd xyz pqr\' cats
+
+/<a\s+href\s*=\s*                # find <a href=
+ (["'])?                         # find single or double quote
+ (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
+                                 # quote, otherwise match up to next space
+/isx
+    <a href=abcd xyz
+    <a href=\"abcd xyz pqr\" cats
+    <a href       =       \'abcd xyz pqr\' cats
+
+/<a\s+href(?>\s*)=(?>\s*)        # find <a href=
+ (["'])?                         # find single or double quote
+ (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
+                                 # quote, otherwise match up to next space
+/isx
+    <a href=abcd xyz
+    <a href=\"abcd xyz pqr\" cats
+    <a href       =       \'abcd xyz pqr\' cats
+
+/((Z)+|A)*/
+    ZABCDEFG
+
+/(Z()|A)*/
+    ZABCDEFG
+
+/(Z(())|A)*/
+    ZABCDEFG
+
+/((?>Z)+|A)*/
+    ZABCDEFG
+
+/((?>)+|A)*/
+    ZABCDEFG
+
+/a*/g
+    abbab
+
+/^[a-\d]/
+    abcde
+    -things
+    0digit
+    *** Failers
+    bcdef    
+
+/^[\d-a]/
+    abcde
+    -things
+    0digit
+    *** Failers
+    bcdef    
+    
+/[[:space:]]+/
+    > \x09\x0a\x0c\x0d\x0b<
+     
+/[[:blank:]]+/
+    > \x09\x0a\x0c\x0d\x0b<
+     
+/[\s]+/
+    > \x09\x0a\x0c\x0d\x0b<
+     
+/\s+/
+    > \x09\x0a\x0c\x0d\x0b<
+     
+/ab/x
+    ab
+
+/(?!\A)x/m
+  a\nxb\n
+
+/(?!^)x/m
+  a\nxb\n
+
+/abc\Qabc\Eabc/
+    abcabcabc
+    
+/abc\Q(*+|\Eabc/
+    abc(*+|abc 
+
+/   abc\Q abc\Eabc/x
+    abc abcabc
+    *** Failers
+    abcabcabc  
+    
+/abc#comment
+    \Q#not comment
+    literal\E/x
+    abc#not comment\n    literal     
+
+/abc#comment
+    \Q#not comment
+    literal/x
+    abc#not comment\n    literal     
+
+/abc#comment
+    \Q#not comment
+    literal\E #more comment
+    /x
+    abc#not comment\n    literal     
+
+/abc#comment
+    \Q#not comment
+    literal\E #more comment/x
+    abc#not comment\n    literal     
+
+/\Qabc\$xyz\E/
+    abc\\\$xyz
+
+/\Qabc\E\$\Qxyz\E/
+    abc\$xyz
+
+/\Gabc/
+    abc
+    *** Failers
+    xyzabc  
+
+/\Gabc./g
+    abc1abc2xyzabc3
+
+/abc./g
+    abc1abc2xyzabc3 
+
+/a(?x: b c )d/
+    XabcdY
+    *** Failers 
+    Xa b c d Y 
+
+/((?x)x y z | a b c)/
+    XabcY
+    AxyzB 
+
+/(?i)AB(?-i)C/
+    XabCY
+    *** Failers
+    XabcY  
+
+/((?i)AB(?-i)C|D)E/
+    abCE
+    DE
+    *** Failers
+    abcE
+    abCe  
+    dE
+    De    
+
+/(.*)\d+\1/
+    abc123abc
+    abc123bc 
+
+/(.*)\d+\1/s
+    abc123abc
+    abc123bc 
+    
+/((.*))\d+\1/
+    abc123abc
+    abc123bc  
+
+/-- This tests for an IPv6 address in the form where it can have up to --/
+/-- eight components, one and only one of which is empty. This must be --/
+/-- an internal component. --/
+
+/^(?!:)                       # colon disallowed at start
+  (?:                         # start of item
+    (?: [0-9a-f]{1,4} |       # 1-4 hex digits or
+    (?(1)0 | () ) )           # if null previously matched, fail; else null
+    :                         # followed by colon
+  ){1,7}                      # end item; 1-7 of them required               
+  [0-9a-f]{1,4} $             # final hex number at end of string
+  (?(1)|.)                    # check that there was an empty component
+  /xi
+    a123::a123
+    a123:b342::abcd
+    a123:b342::324e:abcd
+    a123:ddde:b342::324e:abcd
+    a123:ddde:b342::324e:dcba:abcd
+    a123:ddde:9999:b342::324e:dcba:abcd
+    *** Failers
+    1:2:3:4:5:6:7:8
+    a123:bce:ddde:9999:b342::324e:dcba:abcd
+    a123::9999:b342::324e:dcba:abcd
+    abcde:2:3:4:5:6:7:8
+    ::1
+    abcd:fee0:123::   
+    :1
+    1:  
+
+/[z\Qa-d]\E]/
+    z
+    a
+    -
+    d
+    ] 
+    *** Failers
+    b     
+
+/[\z\C]/
+    z
+    C 
+    
+/\M/
+    M 
+    
+/(a+)*b/
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
+    
+/(?i)reg(?:ul(?:[aä]|ae)r|ex)/
+    REGular
+    regulaer
+    Regex  
+    regulär 
+
+/Åæåä[à-ÿÀ-ß]+/
+    Åæåäà
+    Åæåäÿ
+    ÅæåäÀ
+    Åæåäß
+
+/(?<=Z)X./
+  \x84XAZXB
+
+/ab cd (?x) de fg/
+    ab cd defg
+
+/ab cd(?x) de fg/
+    ab cddefg
+    ** Failers 
+    abcddefg
+
+/(?<![^f]oo)(bar)/
+    foobarX 
+    ** Failers 
+    boobarX
+
+/(?<![^f])X/
+    offX
+    ** Failers
+    onyX  
+
+/(?<=[^f])X/
+    onyX
+    ** Failers
+    offX 
+
+/^/mg
+    a\nb\nc\n
+    \ 
+    
+/(?<=C\n)^/mg
+    A\nC\nC\n 
+
+/(?:(?(1)a|b)(X))+/
+    bXaX
+
+/(?:(?(1)\1a|b)(X|Y))+/
+    bXXaYYaY
+    bXYaXXaX  
+
+/()()()()()()()()()(?:(?(10)\10a|b)(X|Y))+/
+    bXXaYYaY
+
+/[[,abc,]+]/
+    abc]
+    a,b]
+    [a,b,c]  
+
+/(?-x: )/x
+    A\x20B
+    
+"(?x)(?-x: \s*#\s*)"
+    A # B
+    ** Failers
+    #  
+
+"(?x-is)(?:(?-ixs) \s*#\s*) include"
+    A #include
+    ** Failers
+    A#include  
+    A #Include
+
+/a*b*\w/
+    aaabbbb
+    aaaa
+    a
+
+/a*b?\w/
+    aaabbbb
+    aaaa
+    a
+
+/a*b{0,4}\w/
+    aaabbbb
+    aaaa
+    a
+
+/a*b{0,}\w/
+    aaabbbb
+    aaaa
+    a
+    
+/a*\d*\w/
+    0a
+    a 
+    
+/a*b *\w/x
+    a 
+
+/a*b#comment
+  *\w/x
+    a 
+
+/a* b *\w/x
+    a 
+
+/^\w+=.*(\\\n.*)*/
+    abc=xyz\\\npqr
+
+/(?=(\w+))\1:/
+    abcd:
+
+/^(?=(\w+))\1:/
+    abcd:
+
+/^\Eabc/
+    abc
+    
+/^[\Eabc]/
+    a
+    ** Failers 
+    E 
+    
+/^[a-\Ec]/
+    b
+    ** Failers
+    -
+    E    
+
+/^[a\E\E-\Ec]/
+    b
+    ** Failers
+    -
+    E    
+
+/^[\E\Qa\E-\Qz\E]+/
+    b
+    ** Failers
+    -  
+    
+/^[a\Q]bc\E]/
+    a
+    ]
+    c
+    
+/^[a-\Q\E]/
+    a
+    -     
+
+/^(a()*)*/
+    aaaa
+
+/^(?:a(?:(?:))*)*/
+    aaaa
+
+/^(a()+)+/
+    aaaa
+
+/^(?:a(?:(?:))+)+/
+    aaaa
+
+/(a){0,3}(?(1)b|(c|))*D/
+    abbD
+    ccccD
+    D  
+
+/(a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/(?>a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/(?:a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/\Z/g
+  abc\n
+  
+/^(?s)(?>.*)(?<!\n)/
+  abc
+  abc\n  
+
+/^(?![^\n]*\n\z)/
+  abc
+  abc\n 
+  
+/\z(?<!\n)/
+  abc
+  abc\n  
+
+/(.*(.)?)*/
+    abcd
+
+/( (A | (?(1)0|) )*   )/x
+    abcd
+
+/( ( (?(1)0|) )*   )/x
+    abcd
+
+/(  (?(1)0|)*   )/x
+    abcd
+
+/[[:abcd:xyz]]/
+    a]
+    :] 
+    
+/[abc[:x\]pqr]/
+    a
+    [
+    :
+    ]
+    p    
+
+/.*[op][xyz]/
+    fooabcfoo
+
+/ End of testinput1 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput10	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,124 @@
+/-- These are a few representative patterns whose lengths and offsets are to be 
+shown when the link size is 2. This is just a doublecheck test to ensure the 
+sizes don't go horribly wrong when something is changed. The pattern contents 
+are all themselves checked in other tests. --/
+
+/((?i)b)/BM
+
+/(?s)(.*X|^B)/BM
+
+/(?s:.*X|^B)/BM
+
+/^[[:alnum:]]/BM
+
+/#/IxMD
+
+/a#/IxMD
+
+/x?+/BM
+
+/x++/BM
+
+/x{1,3}+/BM 
+
+/(x)*+/BM
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/BM
+
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|BM
+
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|BM
+
+/(a(?1)b)/BM
+
+/(a(?1)+b)/BM
+
+/a(?P<name1>b|c)d(?P<longername2>e)/BM
+
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/BM
+
+/(?P<a>a)...(?P=a)bbb(?P>a)d/BM
+
+/abc(?C255)de(?C)f/BM
+
+/abcde/CBM
+
+/\x{100}/8BM
+
+/\x{1000}/8BM
+
+/\x{10000}/8BM
+
+/\x{100000}/8BM
+
+/\x{1000000}/8BM
+
+/\x{4000000}/8BM
+
+/\x{7fffFFFF}/8BM
+
+/[\x{ff}]/8BM
+
+/[\x{100}]/8BM
+
+/\x80/8BM
+
+/\xff/8BM
+
+/\x{0041}\x{2262}\x{0391}\x{002e}/D8M
+    
+/\x{D55c}\x{ad6d}\x{C5B4}/D8M 
+
+/\x{65e5}\x{672c}\x{8a9e}/D8M
+
+/[\x{100}]/8BM
+
+/[Z\x{100}]/8BM
+
+/^[\x{100}\E-\Q\E\x{150}]/B8M
+
+/^[\QÄ€\E-\QÅ\E]/B8M
+
+/^[\QÄ€\E-\QÅ\E/B8M
+
+/[\p{L}]/BM
+
+/[\p{^L}]/BM
+
+/[\P{L}]/BM
+
+/[\P{^L}]/BM
+
+/[abc\p{L}\x{0660}]/8BM
+
+/[\p{Nd}]/8BM
+
+/[\p{Nd}+-]+/8BM
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iBM
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8BM
+
+/[\x{105}-\x{109}]/8iBM
+
+/( ( (?(1)0|) )*   )/xBM
+
+/(  (?(1)0|)*   )/xBM
+
+/[a]/BM
+
+/[a]/8BM
+
+/[\xaa]/BM
+
+/[\xaa]/8BM
+
+/[^a]/BM
+
+/[^a]/8BM
+
+/[^\xaa]/BM
+
+/[^\xaa]/8BM
+
+/ End of testinput10 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput2	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2729 @@
+/(a)b|/I
+
+/abc/I
+    abc
+    defabc
+    \Aabc
+    *** Failers
+    \Adefabc
+    ABC
+
+/^abc/I
+    abc
+    \Aabc
+    *** Failers
+    defabc
+    \Adefabc
+
+/a+bc/I
+
+/a*bc/I
+
+/a{3}bc/I
+
+/(abc|a+z)/I
+
+/^abc$/I
+    abc
+    *** Failers
+    def\nabc
+
+/ab\idef/X
+
+/(?X)ab\idef/X
+
+/x{5,4}/
+
+/z{65536}/
+
+/[abcd/
+
+/(?X)[\B]/
+
+/[z-a]/
+
+/^*/
+
+/(abc/
+
+/(?# abc/
+
+/(?z)abc/
+
+/.*b/I
+
+/.*?b/I
+
+/cat|dog|elephant/I
+    this sentence eventually mentions a cat
+    this sentences rambles on and on for a while and then reaches elephant
+
+/cat|dog|elephant/IS
+    this sentence eventually mentions a cat
+    this sentences rambles on and on for a while and then reaches elephant
+
+/cat|dog|elephant/IiS
+    this sentence eventually mentions a CAT cat
+    this sentences rambles on and on for a while to elephant ElePhant
+
+/a|[bcd]/IS
+
+/(a|[^\dZ])/IS
+
+/(a|b)*[\s]/IS
+
+/(ab\2)/
+
+/{4,5}abc/
+
+/(a)(b)(c)\2/I
+    abcb
+    \O0abcb
+    \O3abcb
+    \O6abcb
+    \O9abcb
+    \O12abcb
+
+/(a)bc|(a)(b)\2/I
+    abc
+    \O0abc
+    \O3abc
+    \O6abc
+    aba
+    \O0aba
+    \O3aba
+    \O6aba
+    \O9aba
+    \O12aba
+
+/abc$/IE
+    abc
+    *** Failers
+    abc\n
+    abc\ndef
+
+/(a)(b)(c)(d)(e)\6/
+
+/the quick brown fox/I
+    the quick brown fox
+    this is a line with the quick brown fox
+
+/the quick brown fox/IA
+    the quick brown fox
+    *** Failers
+    this is a line with the quick brown fox
+
+/ab(?z)cd/
+
+/^abc|def/I
+    abcdef
+    abcdef\B
+
+/.*((abc)$|(def))/I
+    defabc
+    \Zdefabc
+
+/abc/IP
+    abc
+    *** Failers
+
+/^abc|def/IP
+    abcdef
+    abcdef\B
+
+/.*((abc)$|(def))/IP
+    defabc
+    \Zdefabc
+
+/the quick brown fox/IP
+    the quick brown fox
+    *** Failers
+    The Quick Brown Fox
+
+/the quick brown fox/IPi
+    the quick brown fox
+    The Quick Brown Fox
+
+/abc.def/IP
+    *** Failers
+    abc\ndef
+
+/abc$/IP
+    abc
+    abc\n
+
+/(abc)\2/IP
+
+/(abc\1)/IP
+    abc
+
+/)/
+
+/a[]b/
+
+/[^aeiou ]{3,}/I
+    co-processors, and for
+
+/<.*>/I
+    abc<def>ghi<klm>nop
+
+/<.*?>/I
+    abc<def>ghi<klm>nop
+
+/<.*>/IU
+    abc<def>ghi<klm>nop
+
+/(?U)<.*>/I
+    abc<def>ghi<klm>nop
+
+/<.*?>/IU
+    abc<def>ghi<klm>nop
+
+/={3,}/IU
+    abc========def
+
+/(?U)={3,}?/I
+    abc========def
+
+/(?<!bar|cattle)foo/I
+    foo
+    catfoo
+    *** Failers
+    the barfoo
+    and cattlefoo
+
+/(?<=a+)b/
+
+/(?<=aaa|b{0,3})b/
+
+/(?<!(foo)a\1)bar/
+
+/(?i)abc/I
+
+/(a|(?m)a)/I
+
+/(?i)^1234/I
+
+/(^b|(?i)^d)/I
+
+/(?s).*/I
+
+/[abcd]/IS
+
+/(?i)[abcd]/IS
+
+/(?m)[xy]|(b|c)/IS
+
+/(^a|^b)/Im
+
+/(?i)(^a|^b)/Im
+
+/(a)(?(1)a|b|c)/
+
+/(?(?=a)a|b|c)/
+
+/(?(1a)/
+
+/(?(1a))/
+
+/(?(?i))/
+
+/(?(abc))/
+
+/(?(?<ab))/
+
+/((?s)blah)\s+\1/I
+
+/((?i)blah)\s+\1/I
+
+/((?i)b)/IDZS
+
+/(a*b|(?i:c*(?-i)d))/IS
+
+/a$/I
+    a
+    a\n
+    *** Failers
+    \Za
+    \Za\n
+
+/a$/Im
+    a
+    a\n
+    \Za\n
+    *** Failers
+    \Za
+
+/\Aabc/Im
+
+/^abc/Im
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/I
+  aaaaabbbbbcccccdef
+
+/(?<=foo)[ab]/IS
+
+/(?<!foo)(alpha|omega)/IS
+
+/(?!alphabet)[ab]/IS
+
+/(?<=foo\n)^bar/Im
+    foo\nbarbar
+    ***Failers
+    rhubarb
+    barbell
+    abc\nbarton
+
+/^(?<=foo\n)bar/Im
+    foo\nbarbar
+    ***Failers
+    rhubarb
+    barbell
+    abc\nbarton
+
+/(?>^abc)/Im
+    abc
+    def\nabc
+    *** Failers
+    defabc
+
+/(?<=ab(c+)d)ef/
+
+/(?<=ab(?<=c+)d)ef/
+
+/(?<=ab(c|de)f)g/
+
+/The next three are in testinput2 because they have variable length branches/
+
+/(?<=bullock|donkey)-cart/I
+    the bullock-cart
+    a donkey-cart race
+    *** Failers
+    cart
+    horse-and-cart
+
+/(?<=ab(?i)x|y|z)/I
+
+/(?>.*)(?<=(abcd)|(xyz))/I
+    alphabetabcd
+    endingxyz
+
+/(?<=ab(?i)x(?-i)y|(?i)z|b)ZZ/I
+    abxyZZ
+    abXyZZ
+    ZZZ
+    zZZ
+    bZZ
+    BZZ
+    *** Failers
+    ZZ
+    abXYZZ
+    zzz
+    bzz
+
+/(?<!(foo)a)bar/I
+    bar
+    foobbar
+    *** Failers
+    fooabar
+
+/This one is here because Perl 5.005_02 doesn't fail it/I
+
+/^(a)?(?(1)a|b)+$/I
+    *** Failers
+    a
+
+/This one is here because I think Perl 5.005_02 gets the setting of $1 wrong/I
+
+/^(a\1?){4}$/I
+    aaaaaa
+
+/These are syntax tests from Perl 5.005/I
+
+/a[b-a]/
+
+/a[]b/
+
+/a[/
+
+/*a/
+
+/(*)b/
+
+/abc)/
+
+/(abc/
+
+/a**/
+
+/)(/
+
+/\1/
+
+/\2/
+
+/(a)|\2/
+
+/a[b-a]/Ii
+
+/a[]b/Ii
+
+/a[/Ii
+
+/*a/Ii
+
+/(*)b/Ii
+
+/abc)/Ii
+
+/(abc/Ii
+
+/a**/Ii
+
+/)(/Ii
+
+/:(?:/
+
+/(?<%)b/
+
+/a(?{)b/
+
+/a(?{{})b/
+
+/a(?{}})b/
+
+/a(?{"{"})b/
+
+/a(?{"{"}})b/
+
+/(?(1?)a|b)/
+
+/[a[:xyz:/
+
+/(?<=x+)y/
+
+/a{37,17}/
+
+/abc/\
+
+/abc/\P
+
+/abc/\i
+
+/(a)bc(d)/I
+    abcd
+    abcd\C2
+    abcd\C5
+
+/(.{20})/I
+    abcdefghijklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz\C1
+    abcdefghijklmnopqrstuvwxyz\G1
+
+/(.{15})/I
+    abcdefghijklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz\C1\G1
+
+/(.{16})/I
+    abcdefghijklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz\C1\G1\L
+
+/^(a|(bc))de(f)/I
+    adef\G1\G2\G3\G4\L
+    bcdef\G1\G2\G3\G4\L
+    adefghijk\C0
+
+/^abc\00def/I
+    abc\00def\L\C0
+
+/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
+)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
+)?)?)?)?)?)?)?)?)?otherword/I
+
+/.*X/IDZ
+
+/.*X/IDZs
+
+/(.*X|^B)/IDZ
+
+/(.*X|^B)/IDZs
+
+/(?s)(.*X|^B)/IDZ
+
+/(?s:.*X|^B)/IDZ
+
+/\Biss\B/I+
+    Mississippi
+
+/\Biss\B/I+P
+    Mississippi
+
+/iss/IG+
+    Mississippi
+
+/\Biss\B/IG+
+    Mississippi
+
+/\Biss\B/Ig+
+    Mississippi
+    *** Failers
+    Mississippi\A
+
+/(?<=[Ms])iss/Ig+
+    Mississippi
+
+/(?<=[Ms])iss/IG+
+    Mississippi
+
+/^iss/Ig+
+    ississippi
+
+/.*iss/Ig+
+    abciss\nxyzisspqr
+
+/.i./I+g
+    Mississippi
+    Mississippi\A
+    Missouri river
+    Missouri river\A
+
+/^.is/I+g
+    Mississippi
+
+/^ab\n/Ig+
+    ab\nab\ncd
+
+/^ab\n/Img+
+    ab\nab\ncd
+
+/abc/I
+
+/abc|bac/I
+
+/(abc|bac)/I
+
+/(abc|(c|dc))/I
+
+/(abc|(d|de)c)/I
+
+/a*/I
+
+/a+/I
+
+/(baa|a+)/I
+
+/a{0,3}/I
+
+/baa{3,}/I
+
+/"([^\\"]+|\\.)*"/I
+
+/(abc|ab[cd])/I
+
+/(a|.)/I
+
+/a|ba|\w/I
+
+/abc(?=pqr)/I
+
+/...(?<=abc)/I
+
+/abc(?!pqr)/I
+
+/ab./I
+
+/ab[xyz]/I
+
+/abc*/I
+
+/ab.c*/I
+
+/a.c*/I
+
+/.c*/I
+
+/ac*/I
+
+/(a.c*|b.c*)/I
+
+/a.c*|aba/I
+
+/.+a/I
+
+/(?=abcda)a.*/I
+
+/(?=a)a.*/I
+
+/a(b)*/I
+
+/a\d*/I
+
+/ab\d*/I
+
+/a(\d)*/I
+
+/abcde{0,0}/I
+
+/ab\d+/I
+
+/a(?(1)b)(.)/I
+
+/a(?(1)bag|big)(.)/I
+
+/a(?(1)bag|big)*(.)/I
+
+/a(?(1)bag|big)+(.)/I
+
+/a(?(1)b..|b..)(.)/I
+
+/ab\d{0}e/I
+
+/a?b?/I
+    a
+    b
+    ab
+    \
+    *** Failers
+    \N
+
+/|-/I
+    abcd
+    -abc
+    \Nab-c
+    *** Failers
+    \Nabc
+
+/a*(b+)(z)(z)/IP
+    aaaabbbbzzzz
+    aaaabbbbzzzz\O0
+    aaaabbbbzzzz\O1
+    aaaabbbbzzzz\O2
+    aaaabbbbzzzz\O3
+    aaaabbbbzzzz\O4
+    aaaabbbbzzzz\O5
+
+/^.?abcd/IS
+
+/\(             # ( at start
+  (?:           # Non-capturing bracket
+  (?>[^()]+)    # Either a sequence of non-brackets (no backtracking)
+  |             # Or
+  (?R)          # Recurse - i.e. nested bracketed string
+  )*            # Zero or more contents
+  \)            # Closing )
+  /Ix
+    (abcd)
+    (abcd)xyz
+    xyz(abcd)
+    (ab(xy)cd)pqr
+    (ab(xycd)pqr
+    () abc ()
+    12(abcde(fsh)xyz(foo(bar))lmno)89
+    *** Failers
+    abcd
+    abcd)
+    (abcd
+
+/\(  ( (?>[^()]+) | (?R) )* \) /Ixg
+    (ab(xy)cd)pqr
+    1(abcd)(x(y)z)pqr
+
+/\(  (?: (?>[^()]+) | (?R) ) \) /Ix
+    (abcd)
+    (ab(xy)cd)
+    (a(b(c)d)e)
+    ((ab))
+    *** Failers
+    ()
+
+/\(  (?: (?>[^()]+) | (?R) )? \) /Ix
+    ()
+    12(abcde(fsh)xyz(foo(bar))lmno)89
+
+/\(  ( (?>[^()]+) | (?R) )* \) /Ix
+    (ab(xy)cd)
+
+/\( ( ( (?>[^()]+) | (?R) )* ) \) /Ix
+    (ab(xy)cd)
+
+/\( (123)? ( ( (?>[^()]+) | (?R) )* ) \) /Ix
+    (ab(xy)cd)
+    (123ab(xy)cd)
+
+/\( ( (123)? ( (?>[^()]+) | (?R) )* ) \) /Ix
+    (ab(xy)cd)
+    (123ab(xy)cd)
+
+/\( (((((((((( ( (?>[^()]+) | (?R) )* )))))))))) \) /Ix
+    (ab(xy)cd)
+
+/\( ( ( (?>[^()<>]+) | ((?>[^()]+)) | (?R) )* ) \) /Ix
+    (abcd(xyz<p>qrs)123)
+
+/\( ( ( (?>[^()]+) | ((?R)) )* ) \) /Ix
+    (ab(cd)ef)
+    (ab(cd(ef)gh)ij)
+
+/^[[:alnum:]]/DZ
+
+/^[[:^alnum:]]/DZ
+
+/^[[:alpha:]]/DZ
+
+/^[[:^alpha:]]/DZ
+
+/[_[:alpha:]]/IS
+
+/^[[:ascii:]]/DZ
+
+/^[[:^ascii:]]/DZ
+
+/^[[:blank:]]/DZ
+
+/^[[:^blank:]]/DZ
+
+/[\n\x0b\x0c\x0d[:blank:]]/IS
+
+/^[[:cntrl:]]/DZ
+
+/^[[:digit:]]/DZ
+
+/^[[:graph:]]/DZ
+
+/^[[:lower:]]/DZ
+
+/^[[:print:]]/DZ
+
+/^[[:punct:]]/DZ
+
+/^[[:space:]]/DZ
+
+/^[[:upper:]]/DZ
+
+/^[[:xdigit:]]/DZ
+
+/^[[:word:]]/DZ
+
+/^[[:^cntrl:]]/DZ
+
+/^[12[:^digit:]]/DZ
+
+/^[[:^blank:]]/DZ
+
+/[01[:alpha:]%]/DZ
+
+/[[.ch.]]/I
+
+/[[=ch=]]/I
+
+/[[:rhubarb:]]/I
+
+/[[:upper:]]/Ii
+    A
+    a
+
+/[[:lower:]]/Ii
+    A
+    a
+
+/((?-i)[[:lower:]])[[:lower:]]/Ii
+    ab
+    aB
+    *** Failers
+    Ab
+    AB
+
+/[\200-\110]/I
+
+/^(?(0)f|b)oo/I
+
+/This one's here because of the large output vector needed/I
+
+/(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\w+)\s+(\270)/I
+    \O900 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 ABC ABC
+
+/This one's here because Perl does this differently and PCRE can't at present/I
+
+/(main(O)?)+/I
+    mainmain
+    mainOmain
+
+/These are all cases where Perl does it differently (nested captures)/I
+
+/^(a(b)?)+$/I
+    aba
+
+/^(aa(bb)?)+$/I
+    aabbaa
+
+/^(aa|aa(bb))+$/I
+    aabbaa
+
+/^(aa(bb)??)+$/I
+    aabbaa
+
+/^(?:aa(bb)?)+$/I
+    aabbaa
+
+/^(aa(b(b))?)+$/I
+    aabbaa
+
+/^(?:aa(b(b))?)+$/I
+    aabbaa
+
+/^(?:aa(b(?:b))?)+$/I
+    aabbaa
+
+/^(?:aa(bb(?:b))?)+$/I
+    aabbbaa
+
+/^(?:aa(b(?:bb))?)+$/I
+    aabbbaa
+
+/^(?:aa(?:b(b))?)+$/I
+    aabbaa
+
+/^(?:aa(?:b(bb))?)+$/I
+    aabbbaa
+
+/^(aa(b(bb))?)+$/I
+    aabbbaa
+
+/^(aa(bb(bb))?)+$/I
+    aabbbbaa
+
+/--------------------------------------------------------------------/I
+
+/#/IxDZ
+
+/a#/IxDZ
+
+/[\s]/DZ
+
+/[\S]/DZ
+
+/a(?i)b/DZ
+    ab
+    aB
+    *** Failers
+    AB
+
+/(a(?i)b)/DZ
+    ab
+    aB
+    *** Failers
+    AB
+
+/   (?i)abc/IxDZ
+
+/#this is a comment
+  (?i)abc/IxDZ
+
+/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/DZ
+
+/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/DZ
+
+/\Q\E/DZ
+    \
+
+/\Q\Ex/DZ
+
+/ \Q\E/DZ
+
+/a\Q\E/DZ
+  abc
+  bca
+  bac
+
+/a\Q\Eb/DZ
+  abc
+
+/\Q\Eabc/DZ
+
+/x*+\w/DZ
+    *** Failers
+    xxxxx
+
+/x?+/DZ
+
+/x++/DZ
+
+/x{1,3}+/DZ
+
+/(x)*+/DZ
+
+/^(\w++|\s++)*$/I
+    now is the time for all good men to come to the aid of the party
+    *** Failers
+    this is not a line with only words and spaces!
+
+/(\d++)(\w)/I
+    12345a
+    *** Failers
+    12345+
+
+/a++b/I
+    aaab
+
+/(a++b)/I
+    aaab
+
+/(a++)b/I
+    aaab
+
+/([^()]++|\([^()]*\))+/I
+    ((abc(ade)ufh()()x
+
+/\(([^()]++|\([^()]+\))+\)/I
+    (abc)
+    (abc(def)xyz)
+    *** Failers
+    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/(abc){1,3}+/DZ
+
+/a+?+/I
+
+/a{2,3}?+b/I
+
+/(?U)a+?+/I
+
+/a{2,3}?+b/IU
+
+/x(?U)a++b/DZ
+    xaaaab
+
+/(?U)xa++b/DZ
+    xaaaab
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/DZ
+
+/^x(?U)a+b/DZ
+
+/^x(?U)(a+)b/DZ
+
+/[.x.]/I
+
+/[=x=]/I
+
+/[:x:]/I
+
+/\l/I
+
+/\L/I
+
+/\N{name}/I
+
+/\u/I
+
+/\U/I
+
+/[/I
+
+/[a-/I
+
+/[[:space:]/I
+
+/[\s]/IDZ
+
+/[[:space:]]/IDZ
+
+/[[:space:]abcde]/IDZ
+
+/< (?: (?(R) \d++  | [^<>]*+) | (?R)) * >/Ix
+    <>
+    <abcd>
+    <abc <123> hij>
+    <abc <def> hij>
+    <abc<>def>
+    <abc<>
+    *** Failers
+    <abc
+
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDZ
+
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDZ
+
+/(.*)\d+\1/I
+
+/(.*)\d+/I
+
+/(.*)\d+\1/Is
+
+/(.*)\d+/Is
+
+/(.*(xyz))\d+\2/I
+
+/((.*))\d+\1/I
+    abc123bc
+
+/a[b]/I
+
+/(?=a).*/I
+
+/(?=abc).xyz/IiI
+
+/(?=abc)(?i).xyz/I
+
+/(?=a)(?=b)/I
+
+/(?=.)a/I
+
+/((?=abcda)a)/I
+
+/((?=abcda)ab)/I
+
+/()a/I
+
+/(?(1)ab|ac)(.)/I
+
+/(?(1)abz|acz)(.)/I
+
+/(?(1)abz)(.)/I
+
+/(?(1)abz)(1)23/I
+
+/(a)+/I
+
+/(a){2,3}/I
+
+/(a)*/I
+
+/[a]/I
+
+/[ab]/I
+
+/[ab]/IS
+
+/[^a]/I
+
+/\d456/I
+
+/\d456/IS
+
+/a^b/I
+
+/^a/Im
+  abcde
+  xy\nabc
+  *** Failers
+  xyabc
+
+/c|abc/I
+
+/(?i)[ab]/IS
+
+/[ab](?i)cd/IS
+
+/abc(?C)def/I
+    abcdef
+    1234abcdef
+    *** Failers
+    abcxyz
+    abcxyzf
+
+/abc(?C)de(?C1)f/I
+    123abcdef
+
+/(?C1)\dabc(?C2)def/I
+    1234abcdef
+    *** Failers
+    abcdef
+
+/(?C255)ab/I
+
+/(?C256)ab/I
+
+/(?Cab)xx/I
+
+/(?C12vr)x/I
+
+/abc(?C)def/I
+    *** Failers
+    \x83\x0\x61bcdef
+
+/(abc)(?C)de(?C1)f/I
+    123abcdef
+    123abcdef\C+
+    123abcdef\C-
+    *** Failers
+    123abcdef\C!1
+
+/(?C0)(abc(?C1))*/I
+    abcabcabc
+    abcabc\C!1!3
+    *** Failers
+    abcabcabc\C!1!3
+
+/(\d{3}(?C))*/I
+    123\C+
+    123456\C+
+    123456789\C+
+
+/((xyz)(?C)p|(?C1)xyzabc)/I
+    xyzabc\C+
+
+/(X)((xyz)(?C)p|(?C1)xyzabc)/I
+    Xxyzabc\C+
+
+/(?=(abc))(?C)abcdef/I
+    abcdef\C+
+
+/(?!(abc)(?C1)d)(?C2)abcxyz/I
+    abcxyz\C+
+
+/(?<=(abc)(?C))xyz/I
+   abcxyz\C+
+
+/a(b+)(c*)(?C1)/I
+    abbbbbccc\C*1
+
+/a(b+?)(c*?)(?C1)/I
+    abbbbbccc\C*1
+
+/(?C)abc/I
+
+/(?C)^abc/I
+
+/(?C)a|b/IS
+
+/(?R)/I
+
+/(a|(?R))/I
+
+/(ab|(bc|(de|(?R))))/I
+
+/x(ab|(bc|(de|(?R))))/I
+    xab
+    xbc
+    xde
+    xxab
+    xxxab
+    *** Failers
+    xyab
+
+/(ab|(bc|(de|(?1))))/I
+
+/x(ab|(bc|(de|(?1)x)x)x)/I
+
+/^([^()]|\((?1)*\))*$/I
+    abc
+    a(b)c
+    a(b(c))d
+    *** Failers)
+    a(b(c)d
+
+/^>abc>([^()]|\((?1)*\))*<xyz<$/I
+   >abc>123<xyz<
+   >abc>1(2)3<xyz<
+   >abc>(1(2)3)<xyz<
+
+/(a(?1)b)/DZ
+
+/(a(?1)+b)/DZ
+
+/^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/Ii
+    1221
+    Satan, oscillate my metallic sonatas!
+    A man, a plan, a canal: Panama!
+    Able was I ere I saw Elba.
+    *** Failers
+    The quick brown fox
+
+/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/I
+    12
+    (((2+2)*-3)-7)
+    -12
+    *** Failers
+    ((2+2)*-3)-7)
+
+/^(x(y|(?1){2})z)/I
+    xyz
+    xxyzxyzz
+    *** Failers
+    xxyzz
+    xxyzxyzxyzz
+
+/((< (?: (?(R) \d++  | [^<>]*+) | (?2)) * >))/Ix
+    <>
+    <abcd>
+    <abc <123> hij>
+    <abc <def> hij>
+    <abc<>def>
+    <abc<>
+    *** Failers
+    <abc
+
+/(?1)/I
+
+/((?2)(abc)/I
+
+/^(abc)def(?1)/I
+    abcdefabc
+
+/^(a|b|c)=(?1)+/I
+    a=a
+    a=b
+    a=bc
+
+/^(a|b|c)=((?1))+/I
+    a=a
+    a=b
+    a=bc
+
+/a(?P<name1>b|c)d(?P<longername2>e)/DZ
+    abde
+    acde
+
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/DZ
+
+/(?P<a>a)...(?P=a)bbb(?P>a)d/DZ
+
+/^\W*(?:(?P<one>(?P<two>.)\W*(?P>one)\W*(?P=two)|)|(?P<three>(?P<four>.)\W*(?P>three)\W*(?P=four)|\W*.\W*))\W*$/Ii
+    1221
+    Satan, oscillate my metallic sonatas!
+    A man, a plan, a canal: Panama!
+    Able was I ere I saw Elba.
+    *** Failers
+    The quick brown fox
+
+/((?(R)a|b))\1(?1)?/I
+  bb
+  bbaa
+
+/(.*)a/Is
+
+/(.*)a\1/Is
+
+/(.*)a(b)\2/Is
+
+/((.*)a|(.*)b)z/Is
+
+/((.*)a|(.*)b)z\1/Is
+
+/((.*)a|(.*)b)z\2/Is
+
+/((.*)a|(.*)b)z\3/Is
+
+/((.*)a|^(.*)b)z\3/Is
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a/Is
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\31/Is
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\32/Is
+
+/(a)(bc)/INDZ
+  abc
+
+/(?P<one>a)(bc)/INDZ
+  abc
+
+/(a)(?P<named>bc)/INDZ
+
+/(a+)*zz/I
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzbbbbbb\M
+  aaaaaaaaaaaaaz\M
+
+/(aaa(?C1)bbb|ab)/I
+   aaabbb
+   aaabbb\C*0
+   aaabbb\C*1
+   aaabbb\C*-1
+
+/ab(?P<one>cd)ef(?P<two>gh)/I
+    abcdefgh
+    abcdefgh\C1\Gtwo
+    abcdefgh\Cone\Ctwo
+    abcdefgh\Cthree
+
+/(?P<Tes>)(?P<Test>)/DZ
+
+/(?P<Test>)(?P<Tes>)/DZ
+
+/(?P<Z>zz)(?P<A>aa)/I
+    zzaa\CZ
+    zzaa\CA
+
+/(?P<x>eks)(?P<x>eccs)/I
+
+/(?P<abc>abc(?P<def>def)(?P<abc>xyz))/I
+
+"\[((?P<elem>\d+)(,(?P>elem))*)\]"I
+    [10,20,30,5,5,4,4,2,43,23,4234]
+    *** Failers
+    []
+
+"\[((?P<elem>\d+)(,(?P>elem))*)?\]"I
+    [10,20,30,5,5,4,4,2,43,23,4234]
+    []
+
+/(a(b(?2)c))?/DZ
+
+/(a(b(?2)c))*/DZ
+
+/(a(b(?2)c)){0,2}/DZ
+
+/[ab]{1}+/DZ
+
+/((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/Ii
+     Baby Bjorn Active Carrier - With free SHIPPING!!
+
+/((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/IiS
+     Baby Bjorn Active Carrier - With free SHIPPING!!
+
+/a*.*b/ISDZ
+
+/(a|b)*.?c/ISDZ
+
+/abc(?C255)de(?C)f/DZ
+
+/abcde/ICDZ
+  abcde
+  abcdfe
+
+/a*b/ICDZ
+  ab
+  aaaab
+  aaaacb
+
+/a+b/ICDZ
+  ab
+  aaaab
+  aaaacb
+
+/(abc|def)x/ICDZ
+  abcx
+  defx
+  abcdefzx
+
+/(ab|cd){3,4}/IC
+  ababab
+  abcdabcd
+  abcdcdcdcdcd
+
+/([ab]{,4}c|xy)/ICDZ
+    Note: that { does NOT introduce a quantifier
+
+/([ab]{1,4}c|xy){4,5}?123/ICDZ
+    aacaacaacaacaac123
+
+/\b.*/I
+  ab cd\>1
+
+/\b.*/Is
+  ab cd\>1
+
+/(?!.bcd).*/I
+  Xbcd12345
+
+/abcde/I
+    ab\P
+    abc\P
+    abcd\P
+    abcde\P
+    the quick brown abc\P
+    ** Failers\P
+    the quick brown abxyz fox\P
+
+"^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/(20)?\d\d$"I
+    13/05/04\P
+    13/5/2004\P
+    02/05/09\P
+    1\P
+    1/2\P
+    1/2/0\P
+    1/2/04\P
+    0\P
+    02/\P
+    02/0\P
+    02/1\P
+    ** Failers\P
+    \P
+    123\P
+    33/4/04\P
+    3/13/04\P
+    0/1/2003\P
+    0/\P
+    02/0/\P
+    02/13\P
+
+/0{0,2}ABC/I
+
+/\d{3,}ABC/I
+
+/\d*ABC/I
+
+/[abc]+DE/I
+
+/[abc]?123/I
+    123\P
+    a\P
+    b\P
+    c\P
+    c12\P
+    c123\P
+
+/^(?:\d){3,5}X/I
+    1\P
+    123\P
+    123X
+    1234\P
+    1234X
+    12345\P
+    12345X
+    *** Failers
+    1X
+    123456\P
+
+/abc/I>testsavedregex
+<testsavedregex
+    abc
+    ** Failers
+    bca
+
+/abc/IF>testsavedregex
+<testsavedregex
+    abc
+    ** Failers
+    bca
+
+/(a|b)/IS>testsavedregex
+<testsavedregex
+    abc
+    ** Failers
+    def
+
+/(a|b)/ISF>testsavedregex
+<testsavedregex
+    abc
+    ** Failers
+    def
+
+~<(\w+)/?>(.)*</(\1)>~smgI
+    <!DOCTYPE seite SYSTEM "http://www.lco.lineas.de/xmlCms.dtd">\n<seite>\n<dokumenteninformation>\n<seitentitel>Partner der LCO</seitentitel>\n<sprache>de</sprache>\n<seitenbeschreibung>Partner der LINEAS Consulting\nGmbH</seitenbeschreibung>\n<schluesselworte>LINEAS Consulting GmbH Hamburg\nPartnerfirmen</schluesselworte>\n<revisit>30 days</revisit>\n<robots>index,follow</robots>\n<menueinformation>\n<aktiv>ja</aktiv>\n<menueposition>3</menueposition>\n<menuetext>Partner</menuetext>\n</menueinformation>\n<lastedited>\n<autor>LCO</autor>\n<firma>LINEAS Consulting</firma>\n<datum>15.10.2003</datum>\n</lastedited>\n</dokumenteninformation>\n<inhalt>\n\n<absatzueberschrift>Die Partnerfirmen der LINEAS Consulting\nGmbH</absatzueberschrift>\n\n<absatz><link ziel="http://www.ca.com/" zielfenster="_blank">\n<bild name="logo_ca.gif" rahmen="no"/></link> <link\nziel="http://www.ey.com/" zielfenster="_blank"><bild\nname="logo_euy.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><link ziel="http://www.cisco.de/" zielfenster="_blank">\n<bild name="logo_cisco.gif" rahmen="ja"/></link></absatz>\n\n<absatz><link ziel="http://www.atelion.de/"\nzielfenster="_blank"><bild\nname="logo_atelion.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><link ziel="http://www.line-information.de/"\nzielfenster="_blank">\n<bild name="logo_line_information.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><bild name="logo_aw.gif" rahmen="no"/></absatz>\n\n<absatz><link ziel="http://www.incognis.de/"\nzielfenster="_blank"><bild\nname="logo_incognis.gif" rahmen="no"/></link></absatz>\n\n<absatz><link ziel="http://www.addcraft.com/"\nzielfenster="_blank"><bild\nname="logo_addcraft.gif" rahmen="no"/></link></absatz>\n\n<absatz><link ziel="http://www.comendo.com/"\nzielfenster="_blank"><bild\nname="logo_comendo.gif" rahmen="no"/></link></absatz>\n\n</inhalt>\n</seite>
+
+/^a/IF
+
+/line\nbreak/I
+    this is a line\nbreak
+    line one\nthis is a line\nbreak in the second line
+
+/line\nbreak/If
+    this is a line\nbreak
+    ** Failers
+    line one\nthis is a line\nbreak in the second line
+
+/line\nbreak/Imf
+    this is a line\nbreak
+    ** Failers
+    line one\nthis is a line\nbreak in the second line
+
+/ab.cd/IP
+    ab-cd
+    ab=cd
+    ** Failers
+    ab\ncd
+
+/ab.cd/IPs
+    ab-cd
+    ab=cd
+    ab\ncd
+
+/(?i)(?-i)AbCd/I
+    AbCd
+    ** Failers
+    abcd
+
+/a{11111111111111111111}/I
+
+/(){64294967295}/I
+
+/(){2,4294967295}/I
+
+"(?i:a)(?i:b)(?i:c)(?i:d)(?i:e)(?i:f)(?i:g)(?i:h)(?i:i)(?i:j)(k)(?i:l)A\1B"I
+    abcdefghijklAkB
+
+"(?P<n0>a)(?P<n1>b)(?P<n2>c)(?P<n3>d)(?P<n4>e)(?P<n5>f)(?P<n6>g)(?P<n7>h)(?P<n8>i)(?P<n9>j)(?P<n10>k)(?P<n11>l)A\11B"I
+    abcdefghijklAkB
+
+"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)A\11B"I
+    abcdefghijklAkB
+
+"(?P<name0>a)(?P<name1>a)(?P<name2>a)(?P<name3>a)(?P<name4>a)(?P<name5>a)(?P<name6>a)(?P<name7>a)(?P<name8>a)(?P<name9>a)(?P<name10>a)(?P<name11>a)(?P<name12>a)(?P<name13>a)(?P<name14>a)(?P<name15>a)(?P<name16>a)(?P<name17>a)(?P<name18>a)(?P<name19>a)(?P<name20>a)(?P<name21>a)(?P<name22>a)(?P<name23>a)(?P<name24>a)(?P<name25>a)(?P<name26>a)(?P<name27>a)(?P<name28>a)(?P<name29>a)(?P<name30>a)(?P<name31>a)(?P<name32>a)(?P<name33>a)(?P<name34>a)(?P<name35>a)(?P<name36>a)(?P<name37>a)(?P<name38>a)(?P<name39>a)(?P<name40>a)(?P<name41>a)(?P<name42>a)(?P<name43>a)(?P<name44>a)(?P<name45>a)(?P<name46>a)(?P<name47>a)(?P<name48>a)(?P<name49>a)(?P<name50>a)(?P<name51>a)(?P<name52>a)(?P<name53>a)(?P<name54>a)(?P<name55>a)(?P<name56>a)(?P<name57>a)(?P<name58>a)(?P<name59>a)(?P<name60>a)(?P<name61>a)(?P<name62>a)(?P<name63>a)(?P<name64>a)(?P<name65>a)(?P<name66>a)(?P<name67>a)(?P<name68>a)(?P<name69>a)(?P<name70>a)(?P<name71>a)(?P<name72>a)(?P<name73>a)(?P<name74>a)(?P<name75>a)(?P<name76>a)(?P<name77>a)(?P<name78>a)(?P<name79>a)(?P<name80>a)(?P<name81>a)(?P<name82>a)(?P<name83>a)(?P<name84>a)(?P<name85>a)(?P<name86>a)(?P<name87>a)(?P<name88>a)(?P<name89>a)(?P<name90>a)(?P<name91>a)(?P<name92>a)(?P<name93>a)(?P<name94>a)(?P<name95>a)(?P<name96>a)(?P<name97>a)(?P<name98>a)(?P<name99>a)(?P<name100>a)"I
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+"(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)"I
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[^()]*(?:\((?R)\)[^()]*)*/I
+    (this(and)that
+    (this(and)that)
+    (this(and)that)stuff
+
+/[^()]*(?:\((?>(?R))\)[^()]*)*/I
+    (this(and)that
+    (this(and)that)
+
+/[^()]*(?:\((?R)\))*[^()]*/I
+    (this(and)that
+    (this(and)that)
+
+/(?:\((?R)\))*[^()]*/I
+    (this(and)that
+    (this(and)that)
+    ((this))
+
+/(?:\((?R)\))|[^()]*/I
+    (this(and)that
+    (this(and)that)
+    (this)
+    ((this))
+
+/a(b)c/IPN
+    abc
+
+/a(?P<name>b)c/IPN
+    abc
+
+/\x{100}/I
+
+/\x{0000ff}/I
+
+/^((?P<A>a1)|(?P<A>a2)b)/I
+
+/^((?P<A>a1)|(?P<A>a2)b)/IJ
+    a1b\CA
+    a2b\CA
+    ** Failers
+    a1b\CZ\CA
+
+/^(?P<A>a)(?P<A>b)/IJ
+    ab\CA
+
+/^(?P<A>a)(?P<A>b)|cd/IJ
+    ab\CA
+    cd\CA
+
+/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/IJ
+    cdefgh\CA
+
+/^((?P<A>a1)|(?P<A>a2)b)/IJ
+    a1b\GA
+    a2b\GA
+    ** Failers
+    a1b\GZ\GA
+
+/^(?P<A>a)(?P<A>b)/IJ
+    ab\GA
+
+/^(?P<A>a)(?P<A>b)|cd/IJ
+    ab\GA
+    cd\GA
+
+/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/IJ
+    cdefgh\GA
+
+/(?J)^((?P<A>a1)|(?P<A>a2)b)/I
+    a1b\CA
+    a2b\CA
+
+/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<A>d)/I
+
+/ In this next test, J is not set at the outer level; consequently it isn't
+set in the pattern's options; consequently pcre_get_named_substring() produces
+a random value. /Ix
+
+/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<C>d)/I
+    a bc d\CA\CB\CC
+
+/^(?P<A>a)?(?(A)a|b)/I
+    aabc
+    bc
+    ** Failers
+    abc
+
+/(?:(?(ZZ)a|b)(?P<ZZ>X))+/I
+    bXaX
+
+/(?:(?(2y)a|b)(X))+/I
+
+/(?:(?(ZA)a|b)(?P<ZZ>X))+/I
+
+/(?:(?(ZZ)a|b)(?(ZZ)a|b)(?P<ZZ>X))+/I
+    bbXaaX
+
+/(?:(?(ZZ)a|\(b\))\\(?P<ZZ>X))+/I
+    (b)\\Xa\\X
+
+/(?P<ABC/I
+
+/(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
+    bXXaYYaY
+    bXYaXXaX
+
+/()()()()()()()()()(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
+    bXXaYYaY
+
+/\777/I
+
+/\s*,\s*/IS
+    \x0b,\x0b
+    \x0c,\x0d
+
+/^abc/Im
+    xyz\nabc
+    xyz\nabc\<lf>
+    xyz\r\nabc\<lf>
+    xyz\rabc\<cr>
+    xyz\r\nabc\<crlf>
+    ** Failers
+    xyz\nabc\<cr>
+    xyz\r\nabc\<cr>
+    xyz\nabc\<crlf>
+    xyz\rabc\<crlf>
+    xyz\rabc\<lf>
+
+/abc$/Im<lf>
+    xyzabc
+    xyzabc\n
+    xyzabc\npqr
+    xyzabc\r\<cr>
+    xyzabc\rpqr\<cr>
+    xyzabc\r\n\<crlf>
+    xyzabc\r\npqr\<crlf>
+    ** Failers
+    xyzabc\r
+    xyzabc\rpqr
+    xyzabc\r\n
+    xyzabc\r\npqr
+
+/^abc/Im<cr>
+    xyz\rabcdef
+    xyz\nabcdef\<lf>
+    ** Failers
+    xyz\nabcdef
+
+/^abc/Im<lf>
+    xyz\nabcdef
+    xyz\rabcdef\<cr>
+    ** Failers
+    xyz\rabcdef
+
+/^abc/Im<crlf>
+    xyz\r\nabcdef
+    xyz\rabcdef\<cr>
+    ** Failers
+    xyz\rabcdef
+
+/^abc/Im<bad>
+
+/abc/I
+    xyz\rabc\<bad>
+    abc
+
+/.*/I<lf>
+    abc\ndef
+    abc\rdef
+    abc\r\ndef
+    \<cr>abc\ndef
+    \<cr>abc\rdef
+    \<cr>abc\r\ndef
+    \<crlf>abc\ndef
+    \<crlf>abc\rdef
+    \<crlf>abc\r\ndef
+
+/\w+(.)(.)?def/Is
+    abc\ndef
+    abc\rdef
+    abc\r\ndef
+
++((?:\s|//.*\\n|/[*](?:\\n|.)*?[*]/)*)+I
+   /* this is a C style comment */\M
+
+/(?P<B>25[0-5]|2[0-4]\d|[01]?\d?\d)(?:\.(?P>B)){3}/I
+
+/()()()()()()()()()()()()()()()()()()()()
+ ()()()()()()()()()()()()()()()()()()()()
+ ()()()()()()()()()()()()()()()()()()()()
+ ()()()()()()()()()()()()()()()()()()()()
+ ()()()()()()()()()()()()()()()()()()()()
+ (.(.))/Ix
+    XY\O400
+
+/(a*b|(?i:c*(?-i)d))/IS
+
+/()[ab]xyz/IS
+
+/(|)[ab]xyz/IS
+
+/(|c)[ab]xyz/IS
+
+/(|c?)[ab]xyz/IS
+
+/(d?|c?)[ab]xyz/IS
+
+/(d?|c)[ab]xyz/IS
+
+/^a*b\d/DZ
+
+/^a*+b\d/DZ
+
+/^a*?b\d/DZ
+
+/^a+A\d/DZ
+    aaaA5
+    ** Failers
+    aaaa5
+
+/^a*A\d/IiDZ
+    aaaA5
+    aaaa5
+
+/(a*|b*)[cd]/IS
+
+/(a+|b*)[cd]/IS
+
+/(a*|b+)[cd]/IS
+
+/(a+|b+)[cd]/IS
+
+/((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
+ ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
+ (((
+ a
+ ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
+ ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
+ )))
+/Ix
+  large nest
+
+/a*\d/BZ
+
+/a*\D/BZ
+
+/0*\d/BZ
+
+/0*\D/BZ
+
+/a*\s/BZ
+
+/a*\S/BZ
+
+/ *\s/BZ
+
+/ *\S/BZ
+
+/a*\w/BZ
+
+/a*\W/BZ
+
+/=*\w/BZ
+
+/=*\W/BZ
+
+/\d*a/BZ
+
+/\d*2/BZ
+
+/\d*\d/BZ
+
+/\d*\D/BZ
+
+/\d*\s/BZ
+
+/\d*\S/BZ
+
+/\d*\w/BZ
+
+/\d*\W/BZ
+
+/\D*a/BZ
+
+/\D*2/BZ
+
+/\D*\d/BZ
+
+/\D*\D/BZ
+
+/\D*\s/BZ
+
+/\D*\S/BZ
+
+/\D*\w/BZ
+
+/\D*\W/BZ
+
+/\s*a/BZ
+
+/\s*2/BZ
+
+/\s*\d/BZ
+
+/\s*\D/BZ
+
+/\s*\s/BZ
+
+/\s*\S/BZ
+
+/\s*\w/BZ
+
+/\s*\W/BZ
+
+/\S*a/BZ
+
+/\S*2/BZ
+
+/\S*\d/BZ
+
+/\S*\D/BZ
+
+/\S*\s/BZ
+
+/\S*\S/BZ
+
+/\S*\w/BZ
+
+/\S*\W/BZ
+
+/\w*a/BZ
+
+/\w*2/BZ
+
+/\w*\d/BZ
+
+/\w*\D/BZ
+
+/\w*\s/BZ
+
+/\w*\S/BZ
+
+/\w*\w/BZ
+
+/\w*\W/BZ
+
+/\W*a/BZ
+
+/\W*2/BZ
+
+/\W*\d/BZ
+
+/\W*\D/BZ
+
+/\W*\s/BZ
+
+/\W*\S/BZ
+
+/\W*\w/BZ
+
+/\W*\W/BZ
+
+/[^a]+a/BZ
+
+/[^a]+a/BZi
+
+/[^a]+A/BZi
+
+/[^a]+b/BZ
+
+/[^a]+\d/BZ
+
+/a*[^a]/BZ
+
+/(?P<abc>x)(?P<xyz>y)/I
+    xy\Cabc\Cxyz
+
+/(?<abc>x)(?'xyz'y)/I
+    xy\Cabc\Cxyz
+
+/(?<abc'x)(?'xyz'y)/I
+
+/(?<abc>x)(?'xyz>y)/I
+
+/(?P'abc'x)(?P<xyz>y)/I
+
+/^(?:(?(ZZ)a|b)(?<ZZ>X))+/
+    bXaX
+    bXbX
+    ** Failers
+    aXaX
+    aXbX
+
+/^(?P>abc)(?<abcd>xxx)/
+
+/^(?P>abc)(?<abc>x|y)/
+    xx
+    xy
+    yy
+    yx
+
+/^(?P>abc)(?P<abc>x|y)/
+    xx
+    xy
+    yy
+    yx
+
+/^((?(abc)a|b)(?<abc>x|y))+/
+    bxay
+    bxby
+    ** Failers
+    axby
+
+/^(((?P=abc)|X)(?<abc>x|y))+/
+    XxXxxx
+    XxXyyx
+    XxXyxx
+    ** Failers
+    x
+
+/^(?1)(abc)/
+    abcabc
+
+/^(?:(?:\1|X)(a|b))+/
+    Xaaa
+    Xaba
+
+/^[\E\Qa\E-\Qz\E]+/BZ
+
+/^[a\Q]bc\E]/BZ
+
+/^[a-\Q\E]/BZ
+
+/^(?P>abc)[()](?<abc>)/BZ
+
+/^((?(abc)y)[()](?P<abc>x))+/BZ
+    (xy)x
+
+/^(?P>abc)\Q()\E(?<abc>)/BZ
+
+/^(?P>abc)[a\Q(]\E(](?<abc>)/BZ
+
+/^(?P>abc) # this is (a comment)
+  (?<abc>)/BZx
+
+/^\W*(?:(?<one>(?<two>.)\W*(?&one)\W*\k<two>|)|(?<three>(?<four>.)\W*(?&three)\W*\k'four'|\W*.\W*))\W*$/Ii
+    1221
+    Satan, oscillate my metallic sonatas!
+    A man, a plan, a canal: Panama!
+    Able was I ere I saw Elba.
+    *** Failers
+    The quick brown fox
+
+/(?=(\w+))\1:/I
+    abcd:
+
+/(?=(?'abc'\w+))\k<abc>:/I
+    abcd:
+
+/(?'abc'\w+):\k<abc>{2}/
+    a:aaxyz
+    ab:ababxyz
+    ** Failers
+    a:axyz
+    ab:abxyz
+
+/(?'abc'a|b)(?<abc>d|e)\k<abc>{2}/J
+    adaa
+    ** Failers
+    addd
+    adbb
+
+/(?'abc'a|b)(?<abc>d|e)(?&abc){2}/J
+    bdaa
+    bdab
+    ** Failers
+    bddd
+
+/^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
+    abd
+    ce
+
+/(?(<bc))/
+
+/(?(''))/
+
+/(?('R')stuff)/
+
+/((abc (?(R) (?(R1)1) (?(R2)2) X  |  (?1)  (?2)   (?R) ))) /x
+    abcabc1Xabc2XabcXabcabc
+
+/(?<A> (?'B' abc (?(R) (?(R&A)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
+    abcabc1Xabc2XabcXabcabc
+
+/(?<A> (?'B' abc (?(R) (?(R&1)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
+
+/(?<1> (?'B' abc (?(R) (?(R&1)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
+    abcabc1Xabc2XabcXabcabc
+
+/^(?(DEFINE) (?<A> a) (?<B> b) )  (?&A) (?&B) /x
+    abcd
+
+/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
+  (?(DEFINE)
+  (?<NAME_PAT>[a-z]+)
+  (?<ADDRESS_PAT>\d+)
+  )/x
+    metcalfe 33
+
+/^(?(DEFINE) abc | xyz ) /x
+
+/(?(DEFINE) abc) xyz/xI
+
+/(?(DEFINE) abc){3} xyz/x
+
+/(a|)*\d/
+  \O0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  \O0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/^a.b/<lf>
+    a\rb
+    a\nb\<cr>
+    a\x85b\<anycrlf> 
+    ** Failers
+    a\nb
+    a\nb\<any>
+    a\rb\<cr>
+    a\rb\<any>
+    a\x85b\<any> 
+    a\rb\<anycrlf>
+
+/^abc./mgx<any>
+    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x85abc7 JUNK
+
+/abc.$/mgx<any>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc7 abc9
+
+/a/<cr><any>
+
+/a/<any><crlf>
+
+/^a\Rb/<bsr_unicode>
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0cb
+    a\x85b
+    ** Failers
+    a\n\rb
+
+/^a\R*b/<bsr_unicode>
+    ab
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0cb
+    a\x85b
+    a\n\rb
+    a\n\r\x85\x0cb
+
+/^a\R+b/<bsr_unicode>
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0cb
+    a\x85b
+    a\n\rb
+    a\n\r\x85\x0cb
+    ** Failers
+    ab
+
+/^a\R{1,3}b/<bsr_unicode>
+    a\nb
+    a\n\rb
+    a\n\r\x85b
+    a\r\n\r\nb
+    a\r\n\r\n\r\nb
+    a\n\r\n\rb
+    a\n\n\r\nb
+    ** Failers
+    a\n\n\n\rb
+    a\r
+
+/^a[\R]b/<bsr_unicode>
+    aRb
+    ** Failers
+    a\nb
+
+/(?&abc)X(?<abc>P)/I
+    abcPXP123
+
+/(?1)X(?<abc>P)/I
+    abcPXP123
+
+/(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
+    1.2.3.4
+    131.111.10.206
+    10.0.0.0
+    ** Failers
+    10.6
+    455.3.4.5
+
+/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
+    1.2.3.4
+    131.111.10.206
+    10.0.0.0
+    ** Failers
+    10.6
+    455.3.4.5
+
+/(?:a(?&abc)b)*(?<abc>x)/
+    123axbaxbaxbx456
+    123axbaxbaxb456
+
+/(?:a(?&abc)b){1,5}(?<abc>x)/
+    123axbaxbaxbx456
+
+/(?:a(?&abc)b){2,5}(?<abc>x)/
+    123axbaxbaxbx456
+
+/(?:a(?&abc)b){2,}(?<abc>x)/
+    123axbaxbaxbx456
+
+/(abc)(?i:(?1))/
+   defabcabcxyz
+   DEFabcABCXYZ
+
+/(abc)(?:(?i)(?1))/
+   defabcabcxyz
+   DEFabcABCXYZ
+
+/^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-02}Z/
+    ababababbbabZXXXX
+
+/^(a)\g-2/
+
+/^(a)\g/
+
+/^(a)\g{0}/
+
+/^(a)\g{3/
+
+/^(a)\g{4a}/
+
+/^a.b/<lf>
+    a\rb
+    *** Failers
+    a\nb
+
+/.+foo/
+    afoo
+    ** Failers
+    \r\nfoo
+    \nfoo
+
+/.+foo/<crlf>
+    afoo
+    \nfoo
+    ** Failers
+    \r\nfoo
+
+/.+foo/<any>
+    afoo
+    ** Failers
+    \nfoo
+    \r\nfoo
+
+/.+foo/s
+    afoo
+    \r\nfoo
+    \nfoo
+    
+/^$/mg<any>
+    abc\r\rxyz
+    abc\n\rxyz  
+    ** Failers 
+    abc\r\nxyz
+
+/(?m)^$/<any>g+
+    abc\r\n\r\n
+
+/(?m)^$|^\r\n/<any>g+ 
+    abc\r\n\r\n
+    
+/(?m)$/<any>g+ 
+    abc\r\n\r\n
+
+/abc.$/mgx<anycrlf>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc9
+
+/^X/m
+    XABC
+    ** Failers 
+    XABC\B
+
+/(ab|c)(?-1)/BZ
+    abc
+
+/xy(?+1)(abc)/BZ
+    xyabcabc
+    ** Failers
+    xyabc  
+    
+/x(?-0)y/
+
+/x(?-1)y/
+
+/x(?+0)y/ 
+
+/x(?+1)y/
+
+/^(abc)?(?(-1)X|Y)/BZ
+    abcX
+    Y
+    ** Failers
+    abcY   
+    
+/^((?(+1)X|Y)(abc))+/BZ 
+    YabcXabc
+    YabcXabcXabc
+    ** Failers
+    XabcXabc  
+
+/(?(-1)a)/BZ
+
+/((?(-1)a))/BZ
+
+/((?(-2)a))/BZ
+
+/^(?(+1)X|Y)(.)/BZ
+    Y!
+
+/(foo)\Kbar/
+    foobar
+   
+/(foo)(\Kbar|baz)/
+    foobar
+    foobaz 
+
+/(foo\Kbar)baz/
+    foobarbaz
+
+/(?<A>tom|bon)-\k{A}/
+    tom-tom
+    bon-bon 
+    ** Failers
+    tom-bon  
+
+/(?<A>tom|bon)-\g{A}/
+    tom-tom
+    bon-bon 
+    
+/\g{A/ 
+
+/(?|(abc)|(xyz))/BZ
+   >abc<
+   >xyz< 
+
+/(x)(?|(abc)|(xyz))(x)/BZ
+    xabcx
+    xxyzx 
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/BZ
+    xabcpqrx
+    xxyzx 
+
+/(?|(abc)|(xyz))\1/
+    abcabc
+    xyzxyz 
+    ** Failers
+    abcxyz
+    xyzabc   
+    
+/(?|(abc)|(xyz))(?1)/
+    abcabc
+    xyzabc 
+    ** Failers 
+    xyzxyz 
+ 
+/\H\h\V\v/
+    X X\x0a
+    X\x09X\x0b
+    ** Failers
+    \xa0 X\x0a   
+    
+/\H*\h+\V?\v{3,4}/ 
+    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\xa0\x0a\x0b\x0c
+    ** Failers 
+    \x09\x20\xa0\x0a\x0b
+     
+/\H{3,4}/
+    XY  ABCDE
+    XY  PQR ST 
+    
+/.\h{3,4}./
+    XY  AB    PQRS
+
+/\h*X\h?\H+Y\H?Z/
+    >XNNNYZ
+    >  X NYQZ
+    ** Failers
+    >XYZ   
+    >  X NY Z
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+    >XY\x0aZ\x0aA\x0bNN\x0c
+    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
+/[\h]/BZ
+    >\x09<
+
+/[\h]+/BZ
+    >\x09\x20\xa0<
+
+/[\v]/BZ
+
+/[\H]/BZ
+
+/[^\h]/BZ
+
+/[\V]/BZ
+
+/[\x0a\V]/BZ
+
+/\H++X/BZ
+    ** Failers
+    XXXX
+    
+/\H+\hY/BZ
+    XXXX Y 
+
+/\H+ Y/BZ
+
+/\h+A/BZ
+
+/\v*B/BZ
+
+/\V+\x0a/BZ
+
+/A+\h/BZ
+
+/ *\H/BZ
+
+/A*\v/BZ
+
+/\x0b*\V/BZ
+
+/\d+\h/BZ
+
+/\d*\v/BZ
+
+/S+\h\S+\v/BZ
+
+/\w{3,}\h\w+\v/BZ
+
+/\h+\d\h+\w\h+\S\h+\H/BZ
+
+/\v+\d\v+\w\v+\S\v+\V/BZ
+
+/\H+\h\H+\d/BZ
+
+/\V+\v\V+\w/BZ
+
+/\( (?: [^()]* | (?R) )* \)/x
+(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(00)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)
+
+/[\E]AAA/
+
+/[\Q\E]AAA/
+
+/[^\E]AAA/
+
+/[^\Q\E]AAA/
+
+/[\E^]AAA/
+
+/[\Q\E^]AAA/
+
+/A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/BZ
+
+/^a+(*FAIL)/
+    aaaaaa
+    
+/a+b?c+(*FAIL)/
+    aaabccc
+
+/a+b?(*PRUNE)c+(*FAIL)/
+    aaabccc
+
+/a+b?(*COMMIT)c+(*FAIL)/
+    aaabccc
+    
+/a+b?(*SKIP)c+(*FAIL)/
+    aaabcccaaabccc
+
+/^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
+    aaaxxxxxx
+    aaa++++++ 
+    bbbxxxxx
+    bbb+++++ 
+    cccxxxx
+    ccc++++ 
+    dddddddd   
+
+/^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
+    aaaxxxxxx
+    aaa++++++ 
+    bbbxxxxx
+    bbb+++++ 
+    cccxxxx
+    ccc++++ 
+    dddddddd   
+
+/a+b?(*THEN)c+(*FAIL)/
+    aaabccc
+
+/(A (A|B(*ACCEPT)|C) D)(E)/x
+    ABX
+    AADE
+    ACDE
+    ** Failers
+    AD 
+        
+/^a+(*FAIL)/C
+    aaaaaa
+    
+/a+b?c+(*FAIL)/C
+    aaabccc
+
+/a+b?(*PRUNE)c+(*FAIL)/C
+    aaabccc
+
+/a+b?(*COMMIT)c+(*FAIL)/C
+    aaabccc
+    
+/a+b?(*SKIP)c+(*FAIL)/C
+    aaabcccaaabccc
+
+/a+b?(*THEN)c+(*FAIL)/C
+    aaabccc
+    
+/a(*PRUNE:XXX)b/
+
+/a(*MARK)b/ 
+
+/(?i:A{1,}\6666666666)/
+
+/\g6666666666/
+
+/[\g6666666666]/
+
+/(?1)\c[/
+
+/.+A/<crlf>
+    \r\nA
+    
+/\nA/<crlf>
+    \r\nA 
+
+/[\r\n]A/<crlf>
+    \r\nA 
+
+/(\r|\n)A/<crlf>
+    \r\nA 
+
+/a(*CR)b/
+
+/(*CR)a.b/
+    a\nb
+    ** Failers
+    a\rb  
+
+/(*CR)a.b/<lf>
+    a\nb
+    ** Failers
+    a\rb  
+
+/(*LF)a.b/<CRLF>
+    a\rb
+    ** Failers
+    a\nb  
+
+/(*CRLF)a.b/
+    a\rb
+    a\nb  
+    ** Failers
+    a\r\nb  
+
+/(*ANYCRLF)a.b/<CR>
+    ** Failers
+    a\rb
+    a\nb  
+    a\r\nb  
+
+/(*ANY)a.b/<cr>
+    ** Failers
+    a\rb
+    a\nb  
+    a\r\nb  
+    a\x85b 
+
+/a\Rb/I<bsr_anycrlf>
+    a\rb
+    a\nb
+    a\r\nb
+    ** Failers
+    a\x85b
+    a\x0bb     
+
+/a\Rb/I<bsr_unicode>
+    a\rb
+    a\nb
+    a\r\nb
+    a\x85b
+    a\x0bb     
+    ** Failers 
+    a\x85b\<bsr_anycrlf>
+    a\x0bb\<bsr_anycrlf>
+    
+/a\R?b/I<bsr_anycrlf>
+    a\rb
+    a\nb
+    a\r\nb
+    ** Failers
+    a\x85b
+    a\x0bb     
+
+/a\R?b/I<bsr_unicode>
+    a\rb
+    a\nb
+    a\r\nb
+    a\x85b
+    a\x0bb     
+    ** Failers 
+    a\x85b\<bsr_anycrlf>
+    a\x0bb\<bsr_anycrlf>
+    
+/a\R{2,4}b/I<bsr_anycrlf>
+    a\r\n\nb
+    a\n\r\rb
+    a\r\n\r\n\r\n\r\nb
+    ** Failers
+    a\x85\85b
+    a\x0b\0bb     
+
+/a\R{2,4}b/I<bsr_unicode>
+    a\r\rb
+    a\n\n\nb
+    a\r\n\n\r\rb
+    a\x85\85b
+    a\x0b\0bb     
+    ** Failers 
+    a\r\r\r\r\rb 
+    a\x85\85b\<bsr_anycrlf>
+    a\x0b\0bb\<bsr_anycrlf>
+ 
+/(*BSR_ANYCRLF)a\Rb/I
+    a\nb
+    a\rb 
+
+/(*BSR_UNICODE)a\Rb/I
+    a\x85b
+
+/(*BSR_ANYCRLF)(*CRLF)a\Rb/I
+    a\nb
+    a\rb 
+
+/(*CRLF)(*BSR_UNICODE)a\Rb/I
+    a\x85b
+
+/(*CRLF)(*BSR_ANYCRLF)(*CR)ab/I
+
+/(?<a>)(?&)/
+
+/(?<abc>)(?&a)/
+
+/(?<a>)(?&aaaaaaaaaaaaaaaaaaaaaaa)/
+
+/(?+-a)/
+
+/(?-+a)/
+
+/(?(-1))/
+
+/(?(+10))/
+
+/(?(10))/
+
+/(?(+2))()()/
+
+/(?(2))()()/
+
+/\k''/
+
+/\k<>/
+
+/\k{}/
+
+/(?P=)/
+
+/(?P>)/
+
+/(?!\w)(?R)/
+
+/(?=\w)(?R)/
+
+/(?<!\w)(?R)/
+
+/(?<=\w)(?R)/
+
+/[[:foo:]]/
+
+/[[:1234:]]/
+
+/[[:f\oo:]]/
+
+/[[: :]]/
+
+/[[:...:]]/
+
+/[[:l\ower:]]/
+
+/[[:abc\:]]/
+
+/[abc[:x\]pqr:]]/
+
+/[[:a\dz:]]/
+
+/^(?<name>a|b\g<name>c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/^(?<name>a|b\g'name'c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/^(a|b\g<1>c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/^(a|b\g'1'c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/^(a|b\g'-1'c)/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/(^(a|b\g<-1>c))/
+    aaaa
+    bacxxx
+    bbaccxxx 
+    bbbacccxx
+
+/(^(a|b\g<-1'c))/
+
+/(^(a|b\g{-1}))/
+    bacxxx
+
+/(?-i:\g<name>)(?i:(?<name>a))/
+    XaaX
+    XAAX 
+
+/(?i:\g<name>)(?-i:(?<name>a))/
+    XaaX
+    ** Failers 
+    XAAX 
+
+/(?-i:\g<+1>)(?i:(a))/
+    XaaX
+    XAAX 
+
+/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/
+
+/(?<n>a|b|c)\g<n>*/
+   abc
+   accccbbb 
+
+/^(?+1)(?<a>x|y){0}z/
+    xzxx
+    yzyy 
+    ** Failers
+    xxz  
+
+/(\3)(\1)(a)/
+    cat
+
+/(\3)(\1)(a)/<JS>
+    cat
+    
+/TA]/
+    The ACTA] comes 
+
+/TA]/<JS>
+    The ACTA] comes 
+
+/(?2)[]a()b](abc)/
+    abcbabc
+
+/(?2)[^]a()b](abc)/
+    abcbabc
+
+/(?1)[]a()b](abc)/
+    abcbabc
+    ** Failers 
+    abcXabc
+
+/(?1)[^]a()b](abc)/
+    abcXabc
+    ** Failers 
+    abcbabc
+
+/(?2)[]a()b](abc)(xyz)/
+    xyzbabcxyz
+
+/(?&N)[]a(?<N>)](?<M>abc)/
+   abc<abc
+
+/(?&N)[]a(?<N>)](abc)/
+   abc<abc
+
+/a[]b/
+
+/a[^]b/
+
+/a[]b/<JS>
+    ** Failers
+    ab
+
+/a[]+b/<JS>
+    ** Failers
+    ab 
+
+/a[]*+b/<JS>
+    ** Failers
+    ab 
+
+/a[^]b/<JS>
+    aXb
+    a\nb 
+    ** Failers
+    ab  
+    
+/a[^]+b/<JS> 
+    aXb
+    a\nX\nXb 
+    ** Failers
+    ab  
+
+/a(?!)+b/
+
+/a(*FAIL)+b/
+
+/(abc|pqr|123){0}[xyz]/SI
+
+/ End of testinput2 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,91 @@
+/^[\w]+/
+    *** Failers
+    École
+
+/^[\w]+/Lfr_FR
+    École
+
+/^[\w]+/
+    *** Failers
+    École
+
+/^[\W]+/
+    École
+
+/^[\W]+/Lfr_FR
+    *** Failers
+    École
+
+/[\b]/
+    \b
+    *** Failers
+    a
+
+/[\b]/Lfr_FR
+    \b
+    *** Failers
+    a
+
+/^\w+/
+    *** Failers
+    École
+
+/^\w+/Lfr_FR
+    École
+
+/(.+)\b(.+)/
+    École
+
+/(.+)\b(.+)/Lfr_FR
+    *** Failers
+    École
+
+/École/i
+    École
+    *** Failers
+    école
+
+/École/iLfr_FR
+    École
+    école
+
+/\w/IS
+
+/\w/ISLfr_FR
+
+/^[\xc8-\xc9]/iLfr_FR
+    École
+    école
+
+/^[\xc8-\xc9]/Lfr_FR
+    École
+    *** Failers 
+    école
+
+/\W+/Lfr_FR
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/[\W]+/Lfr_FR
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/[^[:alpha:]]+/Lfr_FR
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/\w+/Lfr_FR
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/[\w]+/Lfr_FR
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/[[:alpha:]]+/Lfr_FR
+    >>>\xaa<<<
+    >>>\xba<<< 
+    
+/[[:alpha:]][[:lower:]][[:upper:]]/DZLfr_FR 
+
+/ End of testinput3 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput4	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,626 @@
+/-- Do not use the \x{} construct except with patterns that have the --/
+/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
+/-- that option is set. However, the latest Perls recognize them always. --/
+
+/a.b/8
+    acb
+    a\x7fb
+    a\x{100}b 
+    *** Failers
+    a\nb  
+
+/a(.{3})b/8
+    a\x{4000}xyb 
+    a\x{4000}\x7fyb 
+    a\x{4000}\x{100}yb 
+    *** Failers
+    a\x{4000}b 
+    ac\ncb 
+
+/a(.*?)(.)/
+    a\xc0\x88b
+
+/a(.*?)(.)/8
+    a\x{100}b
+
+/a(.*)(.)/
+    a\xc0\x88b
+
+/a(.*)(.)/8
+    a\x{100}b
+
+/a(.)(.)/
+    a\xc0\x92bcd
+
+/a(.)(.)/8
+    a\x{240}bcd
+
+/a(.?)(.)/
+    a\xc0\x92bcd
+
+/a(.?)(.)/8
+    a\x{240}bcd
+
+/a(.??)(.)/
+    a\xc0\x92bcd
+
+/a(.??)(.)/8
+    a\x{240}bcd
+
+/a(.{3})b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    *** Failers
+    a\x{1234}b 
+    ac\ncb 
+
+/a(.{3,})b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    axxxxbcdefghijb 
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+    *** Failers
+    a\x{1234}b 
+
+/a(.{3,}?)b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    axxxxbcdefghijb 
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+    *** Failers
+    a\x{1234}b 
+
+/a(.{3,5})b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    axxxxbcdefghijb 
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+    axbxxbcdefghijb 
+    axxxxxbcdefghijb 
+    *** Failers
+    a\x{1234}b 
+    axxxxxxbcdefghijb 
+
+/a(.{3,5}?)b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    axxxxbcdefghijb 
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+    axbxxbcdefghijb 
+    axxxxxbcdefghijb 
+    *** Failers
+    a\x{1234}b 
+    axxxxxxbcdefghijb 
+
+/^[a\x{c0}]/8
+    *** Failers
+    \x{100}
+
+/(?<=aXb)cd/8
+    aXbcd
+
+/(?<=a\x{100}b)cd/8
+    a\x{100}bcd
+
+/(?<=a\x{100000}b)cd/8
+    a\x{100000}bcd
+    
+/(?:\x{100}){3}b/8
+    \x{100}\x{100}\x{100}b
+    *** Failers 
+    \x{100}\x{100}b
+
+/\x{ab}/8
+    \x{ab} 
+    \xc2\xab
+    *** Failers 
+    \x00{ab}
+
+/(?<=(.))X/8
+    WXYZ
+    \x{256}XYZ 
+    *** Failers
+    XYZ 
+
+/X(\C{3})/8
+    X\x{1234}
+
+/X(\C{4})/8
+    X\x{1234}YZ
+    
+/X\C*/8
+    XYZabcdce
+    
+/X\C*?/8
+    XYZabcde
+    
+/X\C{3,5}/8
+    Xabcdefg   
+    X\x{1234} 
+    X\x{1234}YZ
+    X\x{1234}\x{512}  
+    X\x{1234}\x{512}YZ
+
+/X\C{3,5}?/8
+    Xabcdefg   
+    X\x{1234} 
+    X\x{1234}YZ
+    X\x{1234}\x{512}  
+
+/[^a]+/8g
+    bcd
+    \x{100}aY\x{256}Z 
+    
+/^[^a]{2}/8
+    \x{100}bc
+ 
+/^[^a]{2,}/8
+    \x{100}bcAa
+
+/^[^a]{2,}?/8
+    \x{100}bca
+
+/[^a]+/8ig
+    bcd
+    \x{100}aY\x{256}Z 
+    
+/^[^a]{2}/8i
+    \x{100}bc
+ 
+/^[^a]{2,}/8i
+    \x{100}bcAa
+
+/^[^a]{2,}?/8i
+    \x{100}bca
+
+/\x{100}{0,0}/8
+    abcd
+ 
+/\x{100}?/8
+    abcd
+    \x{100}\x{100} 
+
+/\x{100}{0,3}/8 
+    \x{100}\x{100} 
+    \x{100}\x{100}\x{100}\x{100} 
+    
+/\x{100}*/8
+    abce
+    \x{100}\x{100}\x{100}\x{100} 
+
+/\x{100}{1,1}/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+
+/\x{100}{1,3}/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+
+/\x{100}+/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+
+/\x{100}{3}/8
+    abcd\x{100}\x{100}\x{100}XX
+
+/\x{100}{3,5}/8
+    abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+
+/\x{100}{3,}/8
+    abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+
+/(?<=a\x{100}{2}b)X/8+
+    Xyyya\x{100}\x{100}bXzzz
+
+/\D*/8
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\D*/8
+  \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+
+/\D/8
+    1X2
+    1\x{100}2 
+  
+/>\S/8
+    > >X Y
+    > >\x{100} Y
+  
+/\d/8
+    \x{100}3
+    
+/\s/8
+    \x{100} X
+    
+/\D+/8
+    12abcd34
+    *** Failers
+    1234  
+
+/\D{2,3}/8
+    12abcd34
+    12ab34
+    *** Failers  
+    1234
+    12a34  
+
+/\D{2,3}?/8
+    12abcd34
+    12ab34
+    *** Failers  
+    1234
+    12a34  
+
+/\d+/8
+    12abcd34
+    *** Failers
+
+/\d{2,3}/8
+    12abcd34
+    1234abcd
+    *** Failers  
+    1.4 
+
+/\d{2,3}?/8
+    12abcd34
+    1234abcd
+    *** Failers  
+    1.4 
+
+/\S+/8
+    12abcd34
+    *** Failers
+    \    \ 
+
+/\S{2,3}/8
+    12abcd34
+    1234abcd
+    *** Failers
+    \     \  
+
+/\S{2,3}?/8
+    12abcd34
+    1234abcd
+    *** Failers
+    \     \  
+
+/>\s+</8+
+    12>      <34
+    *** Failers
+
+/>\s{2,3}</8+
+    ab>  <cd
+    ab>   <ce
+    *** Failers
+    ab>    <cd 
+
+/>\s{2,3}?</8+
+    ab>  <cd
+    ab>   <ce
+    *** Failers
+    ab>    <cd 
+
+/\w+/8
+    12      34
+    *** Failers
+    +++=*! 
+
+/\w{2,3}/8
+    ab  cd
+    abcd ce
+    *** Failers
+    a.b.c
+
+/\w{2,3}?/8
+    ab  cd
+    abcd ce
+    *** Failers
+    a.b.c
+
+/\W+/8
+    12====34
+    *** Failers
+    abcd 
+
+/\W{2,3}/8
+    ab====cd
+    ab==cd
+    *** Failers
+    a.b.c
+
+/\W{2,3}?/8
+    ab====cd
+    ab==cd
+    *** Failers
+    a.b.c
+
+/[\x{100}]/8
+    \x{100}
+    Z\x{100}
+    \x{100}Z
+    *** Failers 
+
+/[Z\x{100}]/8
+    Z\x{100}
+    \x{100}
+    \x{100}Z
+    *** Failers 
+
+/[\x{100}\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   *** Failers  
+
+/[\x{100}-\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{111}cd 
+   *** Failers  
+
+/[z-\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{111}cd 
+   abzcd
+   ab|cd  
+   *** Failers  
+
+/[Q\x{100}\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   Q? 
+   *** Failers  
+
+/[Q\x{100}-\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{111}cd 
+   Q? 
+   *** Failers  
+
+/[Qz-\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{111}cd 
+   abzcd
+   ab|cd  
+   Q? 
+   *** Failers  
+
+/[\x{100}\x{200}]{1,3}/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{200}\x{100}\x{200}\x{100}cd
+   *** Failers  
+
+/[\x{100}\x{200}]{1,3}?/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{200}\x{100}\x{200}\x{100}cd
+   *** Failers  
+
+/[Q\x{100}\x{200}]{1,3}/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{200}\x{100}\x{200}\x{100}cd
+   *** Failers  
+
+/[Q\x{100}\x{200}]{1,3}?/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{200}\x{100}\x{200}\x{100}cd
+   *** Failers  
+
+/(?<=[\x{100}\x{200}])X/8
+    abc\x{200}X
+    abc\x{100}X 
+    *** Failers
+    X  
+
+/(?<=[Q\x{100}\x{200}])X/8
+    abc\x{200}X
+    abc\x{100}X 
+    abQX 
+    *** Failers
+    X  
+
+/(?<=[\x{100}\x{200}]{3})X/8
+    abc\x{100}\x{200}\x{100}X
+    *** Failers
+    abc\x{200}X
+    X  
+
+/[^\x{100}\x{200}]X/8
+    AX
+    \x{150}X
+    \x{500}X 
+    *** Failers
+    \x{100}X
+    \x{200}X   
+
+/[^Q\x{100}\x{200}]X/8
+    AX
+    \x{150}X
+    \x{500}X 
+    *** Failers
+    \x{100}X
+    \x{200}X   
+    QX 
+
+/[^\x{100}-\x{200}]X/8
+    AX
+    \x{500}X 
+    *** Failers
+    \x{100}X
+    \x{150}X
+    \x{200}X   
+
+/a\Cb/
+    aXb
+    a\nb
+  
+/a\Cb/8
+    aXb
+    a\nb
+    *** Failers 
+    a\x{100}b 
+
+/[z-\x{100}]/8i
+    z
+    Z 
+    \x{100}
+    *** Failers
+    \x{102}
+    y    
+
+/[\xFF]/
+    >\xff<
+
+/[\xff]/8
+    >\x{ff}<
+
+/[^\xFF]/
+    XYZ
+
+/[^\xff]/8
+    XYZ
+    \x{123} 
+
+/^[ac]*b/8
+  xb
+
+/^[ac\x{100}]*b/8
+  xb
+
+/^[^x]*b/8i
+  xb
+
+/^[^x]*b/8
+  xb
+  
+/^\d*b/8
+  xb 
+
+/(|a)/g8
+    catac
+    a\x{256}a 
+
+/^\x{85}$/8i
+    \x{85}
+
+/^ሴ/8
+    ሴ 
+
+/^\ሴ/8
+    ሴ 
+
+"(?s)(.{1,5})"8
+    abcdefg
+    ab
+
+/a*\x{100}*\w/8
+    a 
+
+/\S\S/8g
+    A\x{a3}BC
+    
+/\S{2}/8g
+    A\x{a3}BC
+    
+/\W\W/8g
+    +\x{a3}== 
+
+/\W{2}/8g
+    +\x{a3}== 
+
+/\S/8g
+    \x{442}\x{435}\x{441}\x{442}
+
+/[\S]/8g
+    \x{442}\x{435}\x{441}\x{442}
+
+/\D/8g
+    \x{442}\x{435}\x{441}\x{442}
+
+/[\D]/8g
+    \x{442}\x{435}\x{441}\x{442}
+
+/\W/8g
+    \x{2442}\x{2435}\x{2441}\x{2442}
+
+/[\W]/8g
+    \x{2442}\x{2435}\x{2441}\x{2442}
+    
+/[\S\s]*/8
+    abc\n\r\x{442}\x{435}\x{441}\x{442}xyz 
+
+/[\x{41f}\S]/8g
+    \x{442}\x{435}\x{441}\x{442}
+
+/.[^\S]./8g
+    abc def\x{442}\x{443}xyz\npqr
+
+/.[^\S\n]./8g
+    abc def\x{442}\x{443}xyz\npqr
+
+/[[:^alnum:]]/8g  
+    +\x{2442}
+    
+/[[:^alpha:]]/8g 
+    +\x{2442}
+    
+/[[:^ascii:]]/8g 
+    A\x{442}
+    
+/[[:^blank:]]/8g 
+    A\x{442}
+    
+/[[:^cntrl:]]/8g 
+    A\x{442}
+    
+/[[:^digit:]]/8g 
+    A\x{442}
+    
+/[[:^graph:]]/8g 
+    \x19\x{e01ff}
+    
+/[[:^lower:]]/8g 
+    A\x{422}
+    
+/[[:^print:]]/8g 
+    \x{19}\x{e01ff}
+    
+/[[:^punct:]]/8g 
+    A\x{442}
+    
+/[[:^space:]]/8g 
+    A\x{442}
+    
+/[[:^upper:]]/8g 
+    a\x{442}
+    
+/[[:^word:]]/8g  
+    +\x{2442}
+    
+/[[:^xdigit:]]/8g
+    M\x{442}
+
+/[^ABCDEFGHIJKLMNOPQRSTUVWXYZÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞĀĂĄĆĈĊČĎÄĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿÅŃŅŇŊŌŎÅÅ’Å”Å–Å˜ÅšÅœÅžÅ Å¢Å¤Å¦Å¨ÅªÅ¬Å®Å°Å²Å´Å¶Å¸Å¹Å»Å½ÆÆ‚Æ„Æ†Æ‡Æ‰ÆŠÆ‹ÆŽÆÆÆ‘Æ“Æ”Æ–Æ—Æ˜ÆœÆÆŸÆ Æ¢Æ¤Æ¦Æ§Æ©Æ¬Æ®Æ¯Æ±Æ²Æ³ÆµÆ·Æ¸Æ¼Ç„LJNJÇÇǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶǷǸǺǼǾȀȂȄȆȈȊȌȎÈȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺȻȽȾÉΆΈΉΊΌΎÎΑΒΓΔΕΖΗΘΙΚΛΜÎΞΟΠΡΣΤΥΦΧΨΩΪΫϒϓϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹϺϽϾϿЀÐЂЃЄЅІЇЈЉЊЋЌÐÐŽÐÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎÒҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀÓÓƒÓ…Ó‡Ó‰Ó‹ÓÓӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸԀԂԄԆԈԊԌԎԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀÕÕ‚ÕƒÕ„Õ…Õ†Õ‡ÕˆÕ‰ÕŠÕ‹ÕŒÕÕŽÕÕՑՒՓՔՕՖႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀáƒáƒ‚ჃჄჅḀḂḄḆḈḊḌḎá¸á¸’ḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎá¹á¹’ṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎáºáº’ẔẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎá»á»’ỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸἈἉἊἋἌá¼á¼Žá¼á¼˜á¼™á¼šá¼›á¼œá¼á¼¨á¼©á¼ªá¼«á¼¬á¼­á¼®á¼¯á¼¸á¼¹á¼ºá¼»á¼¼á¼½á¼¾á¼¿á½ˆá½‰á½Šá½‹á½Œá½á½™á½›á½á½Ÿá½¨á½©á½ªá½«á½¬á½­á½®á½¯á¾¸á¾¹á¾ºá¾»á¿ˆá¿‰á¿Šá¿‹á¿˜á¿™á¿šá¿›á¿¨á¿©á¿ªá¿«á¿¬á¿¸á¿¹á¿ºá¿»abcdefghijklmnopqrstuvwxyzªµºßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿÄăąćĉċÄÄđēĕėęěÄğġģĥħĩīĭįıijĵķĸĺļľŀłńņňʼnŋÅÅőœŕŗřśÅÅŸÅ¡Å£Å¥Å§Å©Å«Å­Å¯Å±Å³ÅµÅ·ÅºÅ¼Å¾Å¿Æ€ÆƒÆ…ÆˆÆŒÆÆ’ƕƙƚƛƞơƣƥƨƪƫƭưƴƶƹƺƽƾƿdžljnjǎÇǒǔǖǘǚǜÇǟǡǣǥǧǩǫǭǯǰdzǵǹǻǽǿÈȃȅȇȉȋÈÈȑȓȕȗșțÈȟȡȣȥȧȩȫȭȯȱȳȴȵȶȷȸȹȼȿɀÉɑɒɓɔɕɖɗɘəɚɛɜÉɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀÊʂʃʄʅʆʇʈʉʊʋʌÊÊŽÊÊʑʒʓʔʕʖʗʘʙʚʛʜÊʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯÎάέήίΰαβγδεζηθικλμνξοπÏςστυφχψωϊϋόÏÏŽÏϑϕϖϗϙϛÏϟϡϣϥϧϩϫϭϯϰϱϲϳϵϸϻϼабвгдежзийклмнопрÑтуфхцчшщъыьÑÑŽÑÑёђѓєѕіїјљњћќÑўџѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿÒÒ‹ÒÒÒ‘Ò“Ò•Ò—Ò™Ò›ÒҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӆӈӊӌӎӑӓӕӗәӛÓÓŸÓ¡Ó£Ó¥Ó§Ó©Ó«Ó­Ó¯Ó±Ó³ÓµÓ·Ó¹ÔÔƒÔ…Ô‡Ô‰Ô‹ÔÔÕ¡Õ¢Õ£Õ¤Õ¥Õ¦Õ§Õ¨Õ©ÕªÕ«Õ¬Õ­Õ®Õ¯Õ°Õ±Õ²Õ³Õ´ÕµÕ¶Õ·Õ¸Õ¹ÕºÕ»Õ¼Õ½Õ¾Õ¿Ö€Öւփքօֆևᴀá´á´‚ᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌá´á´Žá´á´á´‘ᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜá´á´žá´Ÿá´ á´¡á´¢á´£á´¤á´¥á´¦á´§á´¨á´©á´ªá´«áµ¢áµ£áµ¤áµ¥áµ¦áµ§áµ¨áµ©áµªáµ«áµ¬áµ­áµ®áµ¯áµ°áµ±áµ²áµ³áµ´áµµáµ¶áµ·áµ¹áµºáµ»áµ¼áµ½áµ¾áµ¿á¶€á¶á¶‚ᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌá¶á¶Žá¶á¶á¶‘ᶒᶓᶔᶕᶖᶗᶘᶙᶚá¸á¸ƒá¸…ḇḉḋá¸á¸á¸‘ḓḕḗḙḛá¸á¸Ÿá¸¡á¸£á¸¥á¸§á¸©á¸«á¸­á¸¯á¸±á¸³á¸µá¸·á¸¹á¸»á¸½á¸¿á¹á¹ƒá¹…ṇṉṋá¹á¹á¹‘ṓṕṗṙṛá¹á¹Ÿá¹¡á¹£á¹¥á¹§á¹©á¹«á¹­á¹¯á¹±á¹³á¹µá¹·á¹¹á¹»á¹½á¹¿áºáºƒáº…ẇẉẋáºáºáº‘ẓẕẖẗẘẙẚẛạảấầẩẫậắằẳẵặẹẻẽếá»á»ƒá»…ệỉịá»á»á»‘ồổỗộớá»á»Ÿá»¡á»£á»¥á»§á»©á»«á»­á»¯á»±á»³á»µá»·á»¹á¼€á¼á¼‚ἃἄἅἆἇá¼á¼‘ἒἓἔἕἠἡἢἣἤἥἦἧἰἱἲἳἴἵἶἷὀá½á½‚ὃὄὅá½á½‘ὒὓὔὕὖὗὠὡὢὣὤὥὦὧὰάὲέὴήὶίὸόὺύὼώᾀá¾á¾‚ᾃᾄᾅᾆᾇá¾á¾‘ᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷιῂῃῄῆῇá¿á¿‘ῒΐῖῗῠῡῢΰῤῥῦῧῲῳῴῶῷâ²â²ƒâ²…ⲇⲉⲋâ²â²â²‘ⲓⲕⲗⲙⲛâ²â²Ÿâ²¡â²£â²¥â²§â²©â²«â²­â²¯â²±â²³â²µâ²·â²¹â²»â²½â²¿â³â³ƒâ³…ⳇⳉⳋâ³â³â³‘ⳓⳕⳗⳙⳛâ³â³Ÿâ³¡â³£â³¤â´€â´â´‚ⴃⴄⴅⴆⴇⴈⴉⴊⴋⴌâ´â´Žâ´â´â´‘ⴒⴓⴔⴕⴖⴗⴘⴙⴚⴛⴜâ´â´žâ´Ÿâ´ â´¡â´¢â´£â´¤â´¥ï¬€ï¬ï¬‚ffifflſtstﬓﬔﬕﬖﬗ\d-_^]/8
+
+/^[^d]*?$/
+    abc
+
+/^[^d]*?$/8
+    abc
+
+/^[^d]*?$/i
+    abc
+
+/^[^d]*?$/8i
+    abc
+
+/(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]/8
+
+/ End of testinput4 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput5	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,483 @@
+/\x{100}/8DZ
+
+/\x{1000}/8DZ
+
+/\x{10000}/8DZ
+
+/\x{100000}/8DZ
+
+/\x{1000000}/8DZ
+
+/\x{4000000}/8DZ
+
+/\x{7fffFFFF}/8DZ
+
+/[\x{ff}]/8DZ
+
+/[\x{100}]/8DZ
+
+/\x{ffffffff}/8
+
+/\x{100000000}/8
+
+/^\x{100}a\x{1234}/8
+    \x{100}a\x{1234}bcd
+
+/\x80/8DZ
+
+/\xff/8DZ
+
+/\x{0041}\x{2262}\x{0391}\x{002e}/DZ8
+    \x{0041}\x{2262}\x{0391}\x{002e}
+    
+/\x{D55c}\x{ad6d}\x{C5B4}/DZ8 
+    \x{D55c}\x{ad6d}\x{C5B4} 
+
+/\x{65e5}\x{672c}\x{8a9e}/DZ8
+    \x{65e5}\x{672c}\x{8a9e}
+
+/\x{80}/DZ8
+
+/\x{084}/DZ8
+
+/\x{104}/DZ8
+
+/\x{861}/DZ8
+
+/\x{212ab}/DZ8
+
+/.{3,5}X/DZ8
+    \x{212ab}\x{212ab}\x{212ab}\x{861}X
+
+
+/.{3,5}?/DZ8
+    \x{212ab}\x{212ab}\x{212ab}\x{861}
+
+/-- These tests are here rather than in testinput4 because Perl 5.6 has some
+problems with UTF-8 support, in the area of \x{..} where the value is < 255. 
+It grumbles about invalid UTF-8 strings. --/
+
+/^[a\x{c0}]b/8
+    \x{c0}b
+    
+/^([a\x{c0}]*?)aa/8
+    a\x{c0}aaaa/ 
+
+/^([a\x{c0}]*?)aa/8
+    a\x{c0}aaaa/ 
+    a\x{c0}a\x{c0}aaa/ 
+
+/^([a\x{c0}]*)aa/8
+    a\x{c0}aaaa/ 
+    a\x{c0}a\x{c0}aaa/ 
+
+/^([a\x{c0}]*)a\x{c0}/8
+    a\x{c0}aaaa/ 
+    a\x{c0}a\x{c0}aaa/ 
+    
+/-- --/ 
+    
+/(?<=\C)X/8
+    Should produce an error diagnostic
+    
+/-- This one is here not because it's different to Perl, but because the way
+the captured single-byte is displayed. (In Perl it becomes a character, and you
+can't tell the difference.) --/
+    
+/X(\C)(.*)/8
+    X\x{1234}
+    X\nabc 
+    
+/^[ab]/8DZ
+    bar
+    *** Failers
+    c
+    \x{ff}
+    \x{100}  
+
+/^[^ab]/8DZ
+    c
+    \x{ff}
+    \x{100}  
+    *** Failers 
+    aaa
+  
+/[^ab\xC0-\xF0]/8SDZ
+    \x{f1}
+    \x{bf}
+    \x{100}
+    \x{1000}   
+    *** Failers
+    \x{c0} 
+    \x{f0} 
+
+/Ä€{3,4}/8SDZ
+  \x{100}\x{100}\x{100}\x{100\x{100}
+
+/(\x{100}+|x)/8SDZ
+
+/(\x{100}*a|x)/8SDZ
+
+/(\x{100}{0,2}a|x)/8SDZ
+
+/(\x{100}{1,2}a|x)/8SDZ
+
+/\x{100}*(\d+|"(?1)")/8
+    1234
+    "1234" 
+    \x{100}1234
+    "\x{100}1234"  
+    \x{100}\x{100}12ab 
+    \x{100}\x{100}"12" 
+    *** Failers 
+    \x{100}\x{100}abcd
+
+/\x{100}/8DZ
+
+/\x{100}*/8DZ
+
+/a\x{100}*/8DZ
+
+/ab\x{100}*/8DZ
+
+/a\x{100}\x{101}*/8DZ
+
+/a\x{100}\x{101}+/8DZ
+
+/\x{100}*A/8DZ
+    A
+
+/\x{100}*\d(?R)/8DZ
+
+/[^\x{c4}]/DZ
+
+/[^\x{c4}]/8DZ
+
+/[\x{100}]/8DZ
+    \x{100}
+    Z\x{100}
+    \x{100}Z
+    *** Failers 
+
+/[Z\x{100}]/8DZ
+    Z\x{100}
+    \x{100}
+    \x{100}Z
+    *** Failers 
+
+/[\x{200}-\x{100}]/8
+
+/[Ä€-Ä„]/8
+    \x{100}
+    \x{104}
+    *** Failers
+    \x{105}
+    \x{ff}    
+
+/[z-\x{100}]/8DZ
+
+/[z\Qa-d]Ä€\E]/8DZ
+    \x{100}
+    Ā 
+
+/[\xFF]/DZ
+    >\xff<
+
+/[\xff]/DZ8
+    >\x{ff}<
+
+/[^\xFF]/DZ
+
+/[^\xff]/8DZ
+
+/[Ä-Ü]/8
+    Ö # Matches without Study
+    \x{d6}
+    
+/[Ä-Ü]/8S
+    Ö <-- Same with Study
+    \x{d6}
+    
+/[\x{c4}-\x{dc}]/8 
+    Ö # Matches without Study
+    \x{d6} 
+
+/[\x{c4}-\x{dc}]/8S
+    Ö <-- Same with Study
+    \x{d6} 
+
+/[Ã]/8
+
+/Ã/8
+
+/ÃÃÃxxx/8
+
+/ÃÃÃxxx/8?DZ
+
+/abc/8
+    Ã]
+    Ã
+    ÃÃÃ
+    ÃÃÃ\?
+
+/anything/8
+    \xc0\x80
+    \xc1\x8f 
+    \xe0\x9f\x80
+    \xf0\x8f\x80\x80 
+    \xf8\x87\x80\x80\x80  
+    \xfc\x83\x80\x80\x80\x80
+    \xfe\x80\x80\x80\x80\x80  
+    \xff\x80\x80\x80\x80\x80  
+    \xc3\x8f
+    \xe0\xaf\x80
+    \xe1\x80\x80
+    \xf0\x9f\x80\x80 
+    \xf1\x8f\x80\x80 
+    \xf8\x88\x80\x80\x80  
+    \xf9\x87\x80\x80\x80  
+    \xfc\x84\x80\x80\x80\x80
+    \xfd\x83\x80\x80\x80\x80
+    \?\xf8\x88\x80\x80\x80  
+    \?\xf9\x87\x80\x80\x80  
+    \?\xfc\x84\x80\x80\x80\x80
+    \?\xfd\x83\x80\x80\x80\x80
+
+/\x{100}abc(xyz(?1))/8DZ
+
+/[^\x{100}]abc(xyz(?1))/8DZ
+
+/[ab\x{100}]abc(xyz(?1))/8DZ
+
+/(\x{100}(b(?2)c))?/DZ8
+
+/(\x{100}(b(?2)c)){0,2}/DZ8
+
+/(\x{100}(b(?1)c))?/DZ8
+
+/(\x{100}(b(?1)c)){0,2}/DZ8
+
+/\W/8
+    A.B
+    A\x{100}B 
+  
+/\w/8
+    \x{100}X   
+
+/a\x{1234}b/P8
+    a\x{1234}b
+
+/^\ሴ/8DZ
+
+/\777/I
+
+/\777/8I
+  \x{1ff}
+  \777 
+  
+/\x{100}*\d/8DZ
+
+/\x{100}*\s/8DZ
+
+/\x{100}*\w/8DZ
+
+/\x{100}*\D/8DZ
+
+/\x{100}*\S/8DZ
+
+/\x{100}*\W/8DZ
+
+/\x{100}+\x{200}/8DZ
+
+/\x{100}+X/8DZ
+
+/X+\x{200}/8DZ
+
+/()()()()()()()()()()
+ ()()()()()()()()()()
+ ()()()()()()()()()()
+ ()()()()()()()()()()
+ A (x) (?41) B/8x
+    AxxB     
+
+/^[\x{100}\E-\Q\E\x{150}]/BZ8
+
+/^[\QÄ€\E-\QÅ\E]/BZ8
+
+/^[\QÄ€\E-\QÅ\E/BZ8
+
+/^abc./mgx8<any>
+    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x{0085}abc7 \x{2028}abc8 \x{2029}abc9 JUNK
+
+/abc.$/mgx8<any>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x{0085} abc7\x{2028} abc8\x{2029} abc9
+
+/^a\Rb/8<bsr_unicode>
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0cb
+    a\x{85}b   
+    a\x{2028}b 
+    a\x{2029}b 
+    ** Failers
+    a\n\rb    
+
+/^a\R*b/8<bsr_unicode>
+    ab
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0c\x{2028}\x{2029}b
+    a\x{85}b   
+    a\n\rb    
+    a\n\r\x{85}\x0cb 
+
+/^a\R+b/8<bsr_unicode>
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0c\x{2028}\x{2029}b
+    a\x{85}b   
+    a\n\rb    
+    a\n\r\x{85}\x0cb 
+    ** Failers
+    ab  
+
+/^a\R{1,3}b/8<bsr_unicode>
+    a\nb
+    a\n\rb
+    a\n\r\x{85}b
+    a\r\n\r\nb 
+    a\r\n\r\n\r\nb 
+    a\n\r\n\rb
+    a\n\n\r\nb 
+    ** Failers
+    a\n\n\n\rb
+    a\r
+
+/\H\h\V\v/8
+    X X\x0a
+    X\x09X\x0b
+    ** Failers
+    \x{a0} X\x0a   
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\x{a0}\x0a\x0b\x0c
+    ** Failers 
+    \x09\x20\x{a0}\x0a\x0b
+     
+/\H\h\V\v/8
+    \x{3001}\x{3000}\x{2030}\x{2028}
+    X\x{180e}X\x{85}
+    ** Failers
+    \x{2009} X\x0a   
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+    \x09\x20\x{202f}\x0a\x0b\x0c
+    ** Failers 
+    \x09\x{200a}\x{a0}\x{2028}\x0b
+     
+/[\h]/8BZ
+    >\x{1680}
+
+/[\h]{3,}/8BZ
+    >\x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}<
+
+/[\v]/8BZ
+
+/[\H]/8BZ
+
+/[\V]/8BZ
+
+/.*$/8<any>
+    \x{1ec5} 
+    
+/-- This tests the stricter UTF-8 check according to RFC 3629. --/ 
+    
+/X/8
+    \x{0}\x{d7ff}\x{e000}\x{10ffff}
+    \x{d800}
+    \x{d800}\?
+    \x{da00}
+    \x{da00}\?
+    \x{dfff}
+    \x{dfff}\?
+    \x{110000}    
+    \x{110000}\?    
+    \x{2000000} 
+    \x{2000000}\? 
+    \x{7fffffff} 
+    \x{7fffffff}\? 
+
+/a\Rb/I8<bsr_anycrlf>
+    a\rb
+    a\nb
+    a\r\nb
+    ** Failers
+    a\x{85}b
+    a\x0bb     
+
+/a\Rb/I8<bsr_unicode>
+    a\rb
+    a\nb
+    a\r\nb
+    a\x{85}b
+    a\x0bb     
+    ** Failers 
+    a\x{85}b\<bsr_anycrlf>
+    a\x0bb\<bsr_anycrlf>
+    
+/a\R?b/I8<bsr_anycrlf>
+    a\rb
+    a\nb
+    a\r\nb
+    ** Failers
+    a\x{85}b
+    a\x0bb     
+
+/a\R?b/I8<bsr_unicode>
+    a\rb
+    a\nb
+    a\r\nb
+    a\x{85}b
+    a\x0bb     
+    ** Failers 
+    a\x{85}b\<bsr_anycrlf>
+    a\x0bb\<bsr_anycrlf>
+ 
+/.*a.*=.b.*/8<ANY>
+    QQQ\x{2029}ABCaXYZ=!bPQR
+    ** Failers
+    a\x{2029}b
+    \x61\xe2\x80\xa9\x62 
+
+/[[:a\x{100}b:]]/8
+
+/a[^]b/<JS>8
+    a\x{1234}b
+    a\nb 
+    ** Failers
+    ab  
+    
+/a[^]+b/<JS>8
+    aXb
+    a\nX\nX\x{1234}b 
+    ** Failers
+    ab  
+
+/(\x{de})\1/
+    \x{de}\x{de}
+    \x{123} 
+
+/X/8f<any> 
+    A\x{1ec5}ABCXYZ
+
+/ End of testinput5 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput6	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,946 @@
+/^\pC\pL\pM\pN\pP\pS\pZ</8
+    \x7f\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
+    \np\x{300}9!\$ < 
+    ** Failers 
+    ap\x{300}9!\$ < 
+  
+/^\PC/8
+    X
+    ** Failers 
+    \x7f
+  
+/^\PL/8
+    9
+    ** Failers 
+    \x{c0}
+  
+/^\PM/8
+    X
+    ** Failers 
+    \x{30f}
+  
+/^\PN/8
+    X
+    ** Failers 
+    \x{660}
+  
+/^\PP/8
+    X
+    ** Failers 
+    \x{66c}
+  
+/^\PS/8
+    X
+    ** Failers 
+    \x{f01}
+  
+/^\PZ/8
+    X
+    ** Failers 
+    \x{1680}
+    
+/^\p{Cc}/8
+    \x{017}
+    \x{09f} 
+    ** Failers
+    \x{0600} 
+  
+/^\p{Cf}/8
+    \x{601}
+    ** Failers
+    \x{09f} 
+  
+/^\p{Cn}/8
+    \x{e0000}
+    ** Failers
+    \x{09f} 
+  
+/^\p{Co}/8
+    \x{f8ff}
+    ** Failers
+    \x{09f} 
+  
+/^\p{Cs}/8
+    \?\x{dfff}
+    ** Failers
+    \x{09f} 
+  
+/^\p{Ll}/8
+    a
+    ** Failers 
+    Z
+    \x{e000}  
+  
+/^\p{Lm}/8
+    \x{2b0}
+    ** Failers
+    a 
+  
+/^\p{Lo}/8
+    \x{1bb}
+    \x{3400}
+    \x{3401}
+    \x{4d00}
+    \x{4db4}
+    \x{4db5}     
+    ** Failers
+    a 
+    \x{2b0}
+    \x{4db6} 
+  
+/^\p{Lt}/8
+    \x{1c5}
+    ** Failers
+    a 
+    \x{2b0}
+  
+/^\p{Lu}/8
+    A
+    ** Failers
+    \x{2b0}
+  
+/^\p{Mc}/8
+    \x{903}
+    ** Failers
+    X
+    \x{300}
+       
+/^\p{Me}/8
+    \x{488}
+    ** Failers
+    X
+    \x{903}
+    \x{300}
+  
+/^\p{Mn}/8
+    \x{300}
+    ** Failers
+    X
+    \x{903}
+  
+/^\p{Nd}+/8
+    0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}\x{667}\x{668}\x{669}\x{66a}
+    \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}\x{6f7}\x{6f8}\x{6f9}\x{6fa}
+    \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}\x{96d}\x{96e}\x{96f}\x{970}
+    ** Failers
+    X
+  
+/^\p{Nl}/8
+    \x{16ee}
+    ** Failers
+    X
+    \x{966}
+  
+/^\p{No}/8
+    \x{b2}
+    \x{b3}
+    ** Failers
+    X
+    \x{16ee}
+  
+/^\p{Pc}/8
+    \x5f
+    \x{203f}
+    ** Failers
+    X
+    -
+    \x{58a}
+  
+/^\p{Pd}/8
+    -
+    \x{58a}
+    ** Failers
+    X
+    \x{203f}
+  
+/^\p{Pe}/8
+    )
+    ]
+    }
+    \x{f3b}
+    ** Failers
+    X
+    \x{203f}
+    (
+    [
+    {
+    \x{f3c}
+  
+/^\p{Pf}/8
+    \x{bb}
+    \x{2019}
+    ** Failers
+    X
+    \x{203f}
+  
+/^\p{Pi}/8
+    \x{ab}
+    \x{2018}
+    ** Failers
+    X
+    \x{203f}
+  
+/^\p{Po}/8
+    !
+    \x{37e}
+    ** Failers
+    X
+    \x{203f}
+  
+/^\p{Ps}/8
+    (
+    [
+    {
+    \x{f3c}
+    ** Failers
+    X
+    )
+    ]
+    }
+    \x{f3b}
+  
+/^\p{Sc}+/8
+    $\x{a2}\x{a3}\x{a4}\x{a5}\x{a6}
+    \x{9f2}
+    ** Failers
+    X
+    \x{2c2}
+  
+/^\p{Sk}/8
+    \x{2c2}
+    ** Failers
+    X
+    \x{9f2}
+  
+/^\p{Sm}+/8
+    +<|~\x{ac}\x{2044}
+    ** Failers
+    X
+    \x{9f2}
+  
+/^\p{So}/8
+    \x{a6}
+    \x{482} 
+    ** Failers
+    X
+    \x{9f2}
+  
+/^\p{Zl}/8
+    \x{2028}
+    ** Failers
+    X
+    \x{2029}
+  
+/^\p{Zp}/8
+    \x{2029}
+    ** Failers
+    X
+    \x{2028}
+  
+/^\p{Zs}/8
+    \ \
+    \x{a0}
+    \x{1680}
+    \x{180e}
+    \x{2000}
+    \x{2001}     
+    ** Failers
+    \x{2028}
+    \x{200d} 
+  
+/\p{Nd}+(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}+?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2,}(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2,}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2}(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2,3}(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2,3}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}??(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*+(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*+(...)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*+(....)/8
+      ** Failers
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Lu}/8i
+    A
+    a\x{10a0}B 
+    ** Failers 
+    a
+    \x{1d00}  
+
+/\p{^Lu}/8i
+    1234
+    ** Failers
+    ABC 
+
+/\P{Lu}/8i
+    1234
+    ** Failers
+    ABC 
+
+/(?<=A\p{Nd})XYZ/8
+    A2XYZ
+    123A5XYZPQR
+    ABA\x{660}XYZpqr
+    ** Failers
+    AXYZ
+    XYZ     
+    
+/(?<!\pL)XYZ/8
+    1XYZ
+    AB=XYZ.. 
+    XYZ 
+    ** Failers
+    WXYZ 
+
+/[\p{L}]/DZ
+
+/[\p{^L}]/DZ
+
+/[\P{L}]/DZ
+
+/[\P{^L}]/DZ
+
+/[abc\p{L}\x{0660}]/8DZ
+
+/[\p{Nd}]/8DZ
+    1234
+
+/[\p{Nd}+-]+/8DZ
+    1234
+    12-34
+    12+\x{661}-34  
+    ** Failers
+    abcd  
+
+/[\P{Nd}]+/8
+    abcd
+    ** Failers
+    1234
+
+/\D+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+     
+/\P{Nd}+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\D]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\P{Nd}]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\D\P{Nd}]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\pL/8
+    a
+    A 
+
+/\pL/8i
+    a
+    A 
+    
+/\p{Lu}/8 
+    A
+    aZ
+    ** Failers
+    abc   
+
+/\p{Lu}/8i
+    A
+    aZ
+    ** Failers
+    abc   
+
+/\p{Ll}/8 
+    a
+    Az
+    ** Failers
+    ABC   
+
+/\p{Ll}/8i 
+    a
+    Az
+    ** Failers
+    ABC   
+
+/^\x{c0}$/8i
+    \x{c0}
+    \x{e0} 
+
+/^\x{e0}$/8i
+    \x{c0}
+    \x{e0} 
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8
+    A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    ** Failers
+    a\x{391}\x{10427}\x{ff3a}\x{1fb0}   
+    A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+    A\x{391}\x{1044F}\x{ff3a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8i
+    A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    a\x{391}\x{10427}\x{ff3a}\x{1fb0}   
+    A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+    A\x{391}\x{1044F}\x{ff3a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iDZ
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8DZ
+
+/AB\x{1fb0}/8DZ
+
+/AB\x{1fb0}/8DZi
+
+/\x{391}+/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
+
+/\x{391}{3,5}(.)/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+
+/\x{391}{3,5}?(.)/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+
+/[\x{391}\x{ff3a}]/8i
+    \x{391}
+    \x{ff3a}
+    \x{3b1}
+    \x{ff5a}   
+    
+/[\x{c0}\x{391}]/8i
+    \x{c0}
+    \x{e0} 
+
+/[\x{105}-\x{109}]/8iDZ
+    \x{104}
+    \x{105}
+    \x{109}  
+    ** Failers
+    \x{100}
+    \x{10a} 
+    
+/[z-\x{100}]/8iDZ 
+    Z
+    z
+    \x{39c}
+    \x{178}
+    |
+    \x{80}
+    \x{ff}
+    \x{100}
+    \x{101} 
+    ** Failers
+    \x{102}
+    Y
+    y           
+
+/[z-\x{100}]/8DZi
+
+/^\X/8
+    A
+    A\x{300}BC 
+    A\x{300}\x{301}\x{302}BC 
+    *** Failers
+    \x{300}  
+
+/^[\X]/8
+    X123
+    *** Failers
+    AXYZ
+
+/^(\X*)C/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+
+/^(\X*?)C/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+
+/^(\X*)(.)/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+
+/^(\X*?)(.)/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+
+/^\X(.)/8
+    *** Failers
+    A\x{300}\x{301}\x{302}
+
+/^\X{2,3}(.)/8
+    A\x{300}\x{301}B\x{300}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}DA\x{300}X
+    
+/^\X{2,3}?(.)/8
+    A\x{300}\x{301}B\x{300}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}DA\x{300}X
+    
+/^\p{Han}+/8
+    \x{2e81}\x{3007}\x{2f804}\x{31a0}
+    ** Failers
+    \x{2e7f}  
+
+/^\P{Katakana}+/8
+    \x{3105}
+    ** Failers
+    \x{30ff}  
+
+/^[\p{Arabic}]/8
+    \x{06e9}
+    \x{060b}
+    ** Failers
+    X\x{06e9}   
+
+/^[\P{Yi}]/8
+    \x{2f800}
+    ** Failers
+    \x{a014}
+    \x{a4c6}   
+    
+/^\p{Any}X/8
+    AXYZ
+    \x{1234}XYZ 
+    ** Failers
+    X  
+    
+/^\P{Any}X/8
+    ** Failers
+    AX
+    
+/^\p{Any}?X/8
+    XYZ
+    AXYZ
+    \x{1234}XYZ 
+    ** Failers
+    ABXYZ   
+
+/^\P{Any}?X/8
+    XYZ
+    ** Failers
+    AXYZ
+    \x{1234}XYZ 
+    ABXYZ   
+
+/^\p{Any}+X/8
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    ** Failers
+    XYZ
+
+/^\P{Any}+X/8
+    ** Failers
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    XYZ
+
+/^\p{Any}*X/8
+    XYZ
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    ** Failers
+
+/^\P{Any}*X/8
+    XYZ
+    ** Failers
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+
+/^[\p{Any}]X/8
+    AXYZ
+    \x{1234}XYZ 
+    ** Failers
+    X  
+    
+/^[\P{Any}]X/8
+    ** Failers
+    AX
+    
+/^[\p{Any}]?X/8
+    XYZ
+    AXYZ
+    \x{1234}XYZ 
+    ** Failers
+    ABXYZ   
+
+/^[\P{Any}]?X/8
+    XYZ
+    ** Failers
+    AXYZ
+    \x{1234}XYZ 
+    ABXYZ   
+
+/^[\p{Any}]+X/8
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    ** Failers
+    XYZ
+
+/^[\P{Any}]+X/8
+    ** Failers
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    XYZ
+
+/^[\p{Any}]*X/8
+    XYZ
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    ** Failers
+
+/^[\P{Any}]*X/8
+    XYZ
+    ** Failers
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+
+/^\p{Any}{3,5}?/8
+    abcdefgh
+    \x{1234}\n\r\x{3456}xyz 
+
+/^\p{Any}{3,5}/8
+    abcdefgh
+    \x{1234}\n\r\x{3456}xyz 
+
+/^\P{Any}{3,5}?/8
+    ** Failers
+    abcdefgh
+    \x{1234}\n\r\x{3456}xyz 
+
+/^\p{L&}X/8
+     AXY
+     aXY
+     \x{1c5}XY
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^[\p{L&}]X/8
+     AXY
+     aXY
+     \x{1c5}XY
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^\p{L&}+X/8
+     AXY
+     aXY
+     AbcdeXyz 
+     \x{1c5}AbXY
+     abcDEXypqreXlmn 
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^[\p{L&}]+X/8
+     AXY
+     aXY
+     AbcdeXyz 
+     \x{1c5}AbXY
+     abcDEXypqreXlmn 
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^\p{L&}+?X/8
+     AXY
+     aXY
+     AbcdeXyz 
+     \x{1c5}AbXY
+     abcDEXypqreXlmn 
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^[\p{L&}]+?X/8
+     AXY
+     aXY
+     AbcdeXyz 
+     \x{1c5}AbXY
+     abcDEXypqreXlmn 
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^\P{L&}X/8
+     !XY
+     \x{1bb}XY
+     \x{2b0}XY
+     ** Failers
+     \x{1c5}XY
+     AXY      
+
+/^[\P{L&}]X/8
+     !XY
+     \x{1bb}XY
+     \x{2b0}XY
+     ** Failers
+     \x{1c5}XY
+     AXY      
+
+/^(\p{Z}[^\p{C}\p{Z}]+)*$/
+    \xa0!
+
+/^[\pL](abc)(?1)/
+    AabcabcYZ    
+
+/([\pL]=(abc))*X/
+    L=abcX
+
+/The next two should be Perl-compatible, but it fails to match \x{e0}. PCRE
+will match it only with UCP support, because without that it has no notion
+of case for anything other than the ASCII letters. / 
+
+/((?i)[\x{c0}])/8
+    \x{c0}
+    \x{e0} 
+
+/(?i:[\x{c0}])/8
+    \x{c0}
+    \x{e0} 
+    
+/^\p{Balinese}\p{Cuneiform}\p{Nko}\p{Phags_Pa}\p{Phoenician}/8
+    \x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
+
+/The next two are special cases where the lengths of the different cases of the 
+same character differ. The first went wrong with heap frame storage; the 2nd
+was broken in all cases./
+
+/^\x{023a}+?(\x{0130}+)/8i
+  \x{023a}\x{2c65}\x{0130}
+  
+/^\x{023a}+([^X])/8i
+  \x{023a}\x{2c65}X
+
+/Check property support in non-UTF-8 mode/
+ 
+/\p{L}{4}/
+    123abcdefg
+    123abc\xc4\xc5zz
+
+/\X{1,3}\d/
+  \x8aBCD
+  
+/\X?\d/
+  \x8aBCD 
+
+/\P{L}?\d/
+  \x8aBCD 
+
+/[\PPP\x8a]{1,}\x80/
+    A\x80
+
+/(?:[\PPa*]*){8,}/
+
+/[\P{Any}]/BZ
+
+/[\P{Any}\E]/BZ
+
+/(\P{Yi}+\277)/
+
+/(\P{Yi}+\277)?/
+
+/(?<=\P{Yi}{3}A)X/
+
+/\p{Yi}+(\P{Yi}+)(?1)/
+
+/(\P{Yi}{2}\277)?/
+
+/[\P{Yi}A]/
+
+/[\P{Yi}\P{Yi}\P{Yi}A]/
+
+/[^\P{Yi}A]/
+
+/[^\P{Yi}\P{Yi}\P{Yi}A]/
+
+/(\P{Yi}*\277)*/
+
+/(\P{Yi}*?\277)*/
+
+/(\p{Yi}*+\277)*/
+
+/(\P{Yi}?\277)*/
+
+/(\P{Yi}??\277)*/
+
+/(\p{Yi}?+\277)*/
+
+/(\P{Yi}{0,3}\277)*/
+
+/(\P{Yi}{0,3}?\277)*/
+
+/(\p{Yi}{0,3}+\277)*/
+
+/^[\p{Arabic}]/8
+    \x{60e} 
+    \x{656} 
+    \x{657} 
+    \x{658} 
+    \x{659} 
+    \x{65a} 
+    \x{65b} 
+    \x{65c} 
+    \x{65d} 
+    \x{65e} 
+    \x{66a} 
+    \x{6e9} 
+    \x{6ef}
+    \x{6fa}  
+    ** Failers
+    \x{600}
+    \x{650}
+    \x{651}  
+    \x{652}  
+    \x{653}  
+    \x{654} 
+    \x{655} 
+    \x{65f}  
+    
+/^\p{Cyrillic}/8
+    \x{1d2b} 
+    
+/^\p{Common}/8
+    \x{589}
+    \x{60c}
+    \x{61f}  
+    \x{964}
+    \x{965}  
+    \x{970}  
+
+/^\p{Inherited}/8
+    \x{64b}
+    \x{654}
+    \x{655}
+    \x{200c} 
+    ** Failers
+    \x{64a}
+    \x{656}     
+
+/^\p{Shavian}/8
+    \x{10450}
+    \x{1047f}
+    
+/^\p{Deseret}/8
+    \x{10400}
+    \x{1044f}
+    
+/^\p{Osmanya}/8
+    \x{10480}
+    \x{1049d}
+    \x{104a0}
+    \x{104a9}
+    ** Failers
+    \x{1049e}
+    \x{1049f}
+    \x{104aa}           
+
+/\p{Zl}{2,3}+/8BZ
+    \xe2\x80\xa8\xe2\x80\xa8
+    \x{2028}\x{2028}\x{2028}
+    
+/\p{Zl}/8BZ
+
+/\p{Lu}{3}+/8BZ
+
+/\pL{2}+/8BZ
+
+/\p{Cc}{2}+/8BZ
+
+/\x{c0}+\x{116}+/8i
+    \x{c0}\x{e0}\x{116}\x{117}
+
+/[\x{c0}\x{116}]+/8i
+    \x{c0}\x{e0}\x{116}\x{117}
+
+/\p{Carian}\p{Cham}\p{Kayah_Li}\p{Lepcha}\p{Lycian}\p{Lydian}\p{Ol_Chiki}\p{Rejang}\p{Saurashtra}\p{Sundanese}\p{Vai}/8
+    \x{102A4}\x{AA52}\x{A91D}\x{1C46}\x{10283}\x{1092E}\x{1C6B}\x{A93B}\x{A8BF}\x{1BA0}\x{A50A}====
+
+/\x{a77d}\x{1d79}/8i
+    \x{a77d}\x{1d79}
+    \x{1d79}\x{a77d} 
+
+/\x{a77d}\x{1d79}/8
+    \x{a77d}\x{1d79}
+    ** Failers 
+    \x{1d79}\x{a77d} 
+
+/(A)\1/8i
+    AA
+    Aa
+    aa
+    aA
+
+/(\x{de})\1/8i
+    \x{de}\x{de}
+    \x{de}\x{fe}
+    \x{fe}\x{fe}
+    \x{fe}\x{de}
+
+/(\x{10a})\1/8i
+    \x{10a}\x{10a}
+    \x{10a}\x{10b}
+    \x{10b}\x{10b}
+    \x{10b}\x{10a}
+
+/ End of testinput6 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput7	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,4395 @@
+/abc/
+    abc
+    
+/ab*c/
+    abc
+    abbbbc
+    ac
+    
+/ab+c/
+    abc
+    abbbbbbc
+    *** Failers 
+    ac
+    ab
+    
+/a*/
+    a
+    aaaaaaaaaaaaaaaaa
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\F 
+    
+/(a|abcd|african)/
+    a
+    abcd
+    african
+    
+/^abc/
+    abcdef
+    *** Failers
+    xyzabc
+    xyz\nabc    
+    
+/^abc/m
+    abcdef
+    xyz\nabc    
+    *** Failers
+    xyzabc
+    
+/\Aabc/
+    abcdef
+    *** Failers
+    xyzabc
+    xyz\nabc    
+    
+/\Aabc/m
+    abcdef
+    *** Failers
+    xyzabc
+    xyz\nabc    
+    
+/\Gabc/
+    abcdef
+    xyzabc\>3
+    *** Failers
+    xyzabc    
+    xyzabc\>2 
+    
+/x\dy\Dz/
+    x9yzz
+    x0y+z
+    *** Failers
+    xyz
+    xxy0z     
+    
+/x\sy\Sz/
+    x yzz
+    x y+z
+    *** Failers
+    xyz
+    xxyyz
+    
+/x\wy\Wz/
+    xxy+z
+    *** Failers
+    xxy0z
+    x+y+z         
+    
+/x.y/
+    x+y
+    x-y
+    *** Failers
+    x\ny
+    
+/x.y/s
+    x+y
+    x-y
+    x\ny
+
+/(a.b(?s)c.d|x.y)p.q/
+    a+bc+dp+q
+    a+bc\ndp+q
+    x\nyp+q 
+    *** Failers 
+    a\nbc\ndp+q
+    a+bc\ndp\nq
+    x\nyp\nq 
+
+/a\d\z/
+    ba0
+    *** Failers
+    ba0\n
+    ba0\ncd   
+
+/a\d\z/m
+    ba0
+    *** Failers
+    ba0\n
+    ba0\ncd   
+
+/a\d\Z/
+    ba0
+    ba0\n
+    *** Failers
+    ba0\ncd   
+
+/a\d\Z/m
+    ba0
+    ba0\n
+    *** Failers
+    ba0\ncd   
+
+/a\d$/
+    ba0
+    ba0\n
+    *** Failers
+    ba0\ncd   
+
+/a\d$/m
+    ba0
+    ba0\n
+    ba0\ncd   
+    *** Failers
+
+/abc/i
+    abc
+    aBc
+    ABC
+    
+/[^a]/
+    abcd
+    
+/ab?\w/
+    abz
+    abbz
+    azz  
+
+/x{0,3}yz/
+    ayzq
+    axyzq
+    axxyz
+    axxxyzq
+    axxxxyzq
+    *** Failers
+    ax
+    axx     
+      
+/x{3}yz/
+    axxxyzq
+    axxxxyzq
+    *** Failers
+    ax
+    axx     
+    ayzq
+    axyzq
+    axxyz
+      
+/x{2,3}yz/
+    axxyz
+    axxxyzq
+    axxxxyzq
+    *** Failers
+    ax
+    axx     
+    ayzq
+    axyzq
+      
+/[^a]+/
+    bac
+    bcdefax
+    *** Failers
+    aaaaa   
+
+/[^a]*/
+    bac
+    bcdefax
+    *** Failers
+    aaaaa   
+    
+/[^a]{3,5}/
+    xyz
+    awxyza
+    abcdefa
+    abcdefghijk
+    *** Failers
+    axya
+    axa
+    aaaaa         
+
+/\d*/
+    1234b567
+    xyz
+    
+/\D*/
+    a1234b567
+    xyz
+     
+/\d+/
+    ab1234c56
+    *** Failers
+    xyz
+    
+/\D+/
+    ab123c56
+    *** Failers
+    789
+    
+/\d?A/
+    045ABC
+    ABC
+    *** Failers
+    XYZ
+    
+/\D?A/
+    ABC
+    BAC
+    9ABC             
+    *** Failers
+
+/a+/
+    aaaa
+
+/^.*xyz/
+    xyz
+    ggggggggxyz
+    
+/^.+xyz/
+    abcdxyz
+    axyz
+    *** Failers
+    xyz
+    
+/^.?xyz/
+    xyz
+    cxyz       
+
+/^\d{2,3}X/
+    12X
+    123X
+    *** Failers
+    X
+    1X
+    1234X     
+
+/^[abcd]\d/
+    a45
+    b93
+    c99z
+    d04
+    *** Failers
+    e45
+    abcd      
+    abcd1234
+    1234  
+
+/^[abcd]*\d/
+    a45
+    b93
+    c99z
+    d04
+    abcd1234
+    1234  
+    *** Failers
+    e45
+    abcd      
+
+/^[abcd]+\d/
+    a45
+    b93
+    c99z
+    d04
+    abcd1234
+    *** Failers
+    1234  
+    e45
+    abcd      
+
+/^a+X/
+    aX
+    aaX 
+
+/^[abcd]?\d/
+    a45
+    b93
+    c99z
+    d04
+    1234  
+    *** Failers
+    abcd1234
+    e45
+
+/^[abcd]{2,3}\d/
+    ab45
+    bcd93
+    *** Failers
+    1234 
+    a36 
+    abcd1234
+    ee45
+
+/^(abc)*\d/
+    abc45
+    abcabcabc45
+    42xyz 
+    *** Failers
+
+/^(abc)+\d/
+    abc45
+    abcabcabc45
+    *** Failers
+    42xyz 
+
+/^(abc)?\d/
+    abc45
+    42xyz 
+    *** Failers
+    abcabcabc45
+
+/^(abc){2,3}\d/
+    abcabc45
+    abcabcabc45
+    *** Failers
+    abcabcabcabc45
+    abc45
+    42xyz 
+
+/1(abc|xyz)2(?1)3/
+    1abc2abc3456
+    1abc2xyz3456 
+
+/^(a*\w|ab)=(a*\w|ab)/
+    ab=ab
+
+/^(a*\w|ab)=(?1)/
+    ab=ab
+
+/^([^()]|\((?1)*\))*$/
+    abc
+    a(b)c
+    a(b(c))d  
+    *** Failers)
+    a(b(c)d  
+
+/^>abc>([^()]|\((?1)*\))*<xyz<$/
+    >abc>123<xyz<
+    >abc>1(2)3<xyz<
+    >abc>(1(2)3)<xyz<
+
+/^(?>a*)\d/
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9876
+    *** Failers 
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/< (?: (?(R) \d++  | [^<>]*+) | (?R)) * >/x
+    <>
+    <abcd>
+    <abc <123> hij>
+    <abc <def> hij>
+    <abc<>def> 
+    <abc<>      
+    *** Failers
+    <abc
+
+/^(?(?=abc)\w{3}:|\d\d)$/        
+    abc:                          
+    12                             
+    *** Failers                     
+    123                       
+    xyz                        
+                                
+/^(?(?!abc)\d\d|\w{3}:)$/      
+    abc:                        
+    12         
+    *** Failers
+    123
+    xyz    
+
+/^(?=abc)\w{5}:$/        
+    abcde:                          
+    *** Failers                     
+    abc.. 
+    123                       
+    vwxyz                        
+                                
+/^(?!abc)\d\d$/      
+    12         
+    *** Failers
+    abcde:
+    abc..  
+    123
+    vwxyz    
+
+/(?<=abc|xy)123/
+    abc12345
+    wxy123z
+    *** Failers
+    123abc
+
+/(?<!abc|xy)123/
+    123abc
+    mno123456 
+    *** Failers
+    abc12345
+    wxy123z
+
+/abc(?C1)xyz/
+    abcxyz
+    123abcxyz999 
+
+/(ab|cd){3,4}/C
+  ababab
+  abcdabcd
+  abcdcdcdcdcd  
+
+/^abc/
+    abcdef
+    *** Failers
+    abcdef\B  
+
+/^(a*|xyz)/
+    bcd
+    aaabcd
+    xyz
+    xyz\N  
+    *** Failers
+    bcd\N   
+    
+/xyz$/
+    xyz
+    xyz\n
+    *** Failers
+    xyz\Z
+    xyz\n\Z    
+    
+/xyz$/m
+    xyz
+    xyz\n 
+    abcxyz\npqr 
+    abcxyz\npqr\Z 
+    xyz\n\Z    
+    *** Failers
+    xyz\Z
+
+/\Gabc/
+    abcdef
+    defabcxyz\>3 
+    *** Failers 
+    defabcxyz
+
+/^abcdef/
+    ab\P
+    abcde\P
+    abcdef\P
+    *** Failers
+    abx\P    
+
+/^a{2,4}\d+z/
+    a\P
+    aa\P
+    aa2\P 
+    aaa\P
+    aaa23\P 
+    aaaa12345\P
+    aa0z\P
+    aaaa4444444444444z\P 
+    *** Failers
+    az\P 
+    aaaaa\P 
+    a56\P 
+
+/^abcdef/
+   abc\P
+   def\R 
+   
+/(?<=foo)bar/
+   xyzfo\P 
+   foob\P\>2 
+   foobar...\R\P\>4 
+   xyzfo\P
+   foobar\>2  
+   *** Failers
+   xyzfo\P
+   obar\R   
+
+/(ab*(cd|ef))+X/
+    adfadadaklhlkalkajhlkjahdfasdfasdfladsfjkj\P\Z
+    lkjhlkjhlkjhlkjhabbbbbbcdaefabbbbbbbefa\P\B\Z
+    cdabbbbbbbb\P\R\B\Z
+    efabbbbbbbbbbbbbbbb\P\R\B\Z
+    bbbbbbbbbbbbcdXyasdfadf\P\R\B\Z    
+
+/(a|b)/SF>testsavedregex
+<testsavedregex
+    abc
+    ** Failers
+    def  
+    
+/the quick brown fox/
+    the quick brown fox
+    The quick brown FOX
+    What do you know about the quick brown fox?
+    What do you know about THE QUICK BROWN FOX?
+
+/The quick brown fox/i
+    the quick brown fox
+    The quick brown FOX
+    What do you know about the quick brown fox?
+    What do you know about THE QUICK BROWN FOX?
+
+/abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
+    abcd\t\n\r\f\a\e9;\$\\?caxyz
+
+/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
+    abxyzpqrrrabbxyyyypqAzz
+    abxyzpqrrrabbxyyyypqAzz
+    aabxyzpqrrrabbxyyyypqAzz
+    aaabxyzpqrrrabbxyyyypqAzz
+    aaaabxyzpqrrrabbxyyyypqAzz
+    abcxyzpqrrrabbxyyyypqAzz
+    aabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypAzz
+    aaabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqqAzz
+    aaaabcxyzpqrrrabbxyyyypqAzz
+    abxyzzpqrrrabbxyyyypqAzz
+    aabxyzzzpqrrrabbxyyyypqAzz
+    aaabxyzzzzpqrrrabbxyyyypqAzz
+    aaaabxyzzzzpqrrrabbxyyyypqAzz
+    abcxyzzpqrrrabbxyyyypqAzz
+    aabcxyzzzpqrrrabbxyyyypqAzz
+    aaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypABzz
+    aaabcxyzpqrrrabbxyyyypABBzz
+    >>>aaabxyzpqrrrabbxyyyypqAzz
+    >aaaabxyzpqrrrabbxyyyypqAzz
+    >>>>abcxyzpqrrrabbxyyyypqAzz
+    *** Failers
+    abxyzpqrrabbxyyyypqAzz
+    abxyzpqrrrrabbxyyyypqAzz
+    abxyzpqrrrabxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyypqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
+
+/^(abc){1,2}zz/
+    abczz
+    abcabczz
+    *** Failers
+    zz
+    abcabcabczz
+    >>abczz
+
+/^(b+?|a){1,2}?c/
+    bc
+    bbc
+    bbbc
+    bac
+    bbac
+    aac
+    abbbbbbbbbbbc
+    bbbbbbbbbbbac
+    *** Failers
+    aaac
+    abbbbbbbbbbbac
+
+/^(b+|a){1,2}c/
+    bc
+    bbc
+    bbbc
+    bac
+    bbac
+    aac
+    abbbbbbbbbbbc
+    bbbbbbbbbbbac
+    *** Failers
+    aaac
+    abbbbbbbbbbbac
+
+/^(b+|a){1,2}?bc/
+    bbc
+
+/^(b*|ba){1,2}?bc/
+    babc
+    bbabc
+    bababc
+    *** Failers
+    bababbc
+    babababc
+
+/^(ba|b*){1,2}?bc/
+    babc
+    bbabc
+    bababc
+    *** Failers
+    bababbc
+    babababc
+
+/^\ca\cA\c[\c{\c:/
+    \x01\x01\e;z
+
+/^[ab\]cde]/
+    athing
+    bthing
+    ]thing
+    cthing
+    dthing
+    ething
+    *** Failers
+    fthing
+    [thing
+    \\thing
+
+/^[]cde]/
+    ]thing
+    cthing
+    dthing
+    ething
+    *** Failers
+    athing
+    fthing
+
+/^[^ab\]cde]/
+    fthing
+    [thing
+    \\thing
+    *** Failers
+    athing
+    bthing
+    ]thing
+    cthing
+    dthing
+    ething
+
+/^[^]cde]/
+    athing
+    fthing
+    *** Failers
+    ]thing
+    cthing
+    dthing
+    ething
+
+/^\/
+    
+
+/^ÿ/
+    ÿ
+
+/^[0-9]+$/
+    0
+    1
+    2
+    3
+    4
+    5
+    6
+    7
+    8
+    9
+    10
+    100
+    *** Failers
+    abc
+
+/^.*nter/
+    enter
+    inter
+    uponter
+
+/^xxx[0-9]+$/
+    xxx0
+    xxx1234
+    *** Failers
+    xxx
+
+/^.+[0-9][0-9][0-9]$/
+    x123
+    xx123
+    123456
+    *** Failers
+    123
+    x1234
+
+/^.+?[0-9][0-9][0-9]$/
+    x123
+    xx123
+    123456
+    *** Failers
+    123
+    x1234
+
+/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
+    abc!pqr=apquxz.ixr.zzz.ac.uk
+    *** Failers
+    !pqr=apquxz.ixr.zzz.ac.uk
+    abc!=apquxz.ixr.zzz.ac.uk
+    abc!pqr=apquxz:ixr.zzz.ac.uk
+    abc!pqr=apquxz.ixr.zzz.ac.ukk
+
+/:/
+    Well, we need a colon: somewhere
+    *** Fail if we don't
+
+/([\da-f:]+)$/i
+    0abc
+    abc
+    fed
+    E
+    ::
+    5f03:12C0::932e
+    fed def
+    Any old stuff
+    *** Failers
+    0zzz
+    gzzz
+    fed\x20
+    Any old rubbish
+
+/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
+    .1.2.3
+    A.12.123.0
+    *** Failers
+    .1.2.3333
+    1.2.3
+    1234.2.3
+
+/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
+    1 IN SOA non-sp1 non-sp2(
+    1    IN    SOA    non-sp1    non-sp2   (
+    *** Failers
+    1IN SOA non-sp1 non-sp2(
+
+/^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
+    a.
+    Z.
+    2.
+    ab-c.pq-r.
+    sxk.zzz.ac.uk.
+    x-.y-.
+    *** Failers
+    -abc.peq.
+
+/^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
+    *.a
+    *.b0-a
+    *.c3-b.c
+    *.c-a.b-c
+    *** Failers
+    *.0
+    *.a-
+    *.a-b.c-
+    *.c-a.0-c
+
+/^(?=ab(de))(abd)(e)/
+    abde
+
+/^(?!(ab)de|x)(abd)(f)/
+    abdf
+
+/^(?=(ab(cd)))(ab)/
+    abcd
+
+/^[\da-f](\.[\da-f])*$/i
+    a.b.c.d
+    A.B.C.D
+    a.b.c.1.2.3.C
+
+/^\".*\"\s*(;.*)?$/
+    \"1234\"
+    \"abcd\" ;
+    \"\" ; rhubarb
+    *** Failers
+    \"1234\" : things
+
+/^$/
+    \
+    *** Failers
+
+/   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/x
+    ab c
+    *** Failers
+    abc
+    ab cde
+
+/(?x)   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/
+    ab c
+    *** Failers
+    abc
+    ab cde
+
+/^   a\ b[c ]d       $/x
+    a bcd
+    a b d
+    *** Failers
+    abcd
+    ab d
+
+/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
+    abcdefhijklm
+
+/^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
+    abcdefhijklm
+
+/^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
+    a+ Z0+\x08\n\x1d\x12
+
+/^[.^$|()*+?{,}]+/
+    .^\$(*+)|{?,?}
+
+/^a*\w/
+    z
+    az
+    aaaz
+    a
+    aa
+    aaaa
+    a+
+    aa+
+
+/^a*?\w/
+    z
+    az
+    aaaz
+    a
+    aa
+    aaaa
+    a+
+    aa+
+
+/^a+\w/
+    az
+    aaaz
+    aa
+    aaaa
+    aa+
+
+/^a+?\w/
+    az
+    aaaz
+    aa
+    aaaa
+    aa+
+
+/^\d{8}\w{2,}/
+    1234567890
+    12345678ab
+    12345678__
+    *** Failers
+    1234567
+
+/^[aeiou\d]{4,5}$/
+    uoie
+    1234
+    12345
+    aaaaa
+    *** Failers
+    123456
+
+/^[aeiou\d]{4,5}?/
+    uoie
+    1234
+    12345
+    aaaaa
+    123456
+
+/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
+    From abcd  Mon Sep 01 12:33:02 1997
+
+/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
+    From abcd  Mon Sep 01 12:33:02 1997
+    From abcd  Mon Sep  1 12:33:02 1997
+    *** Failers
+    From abcd  Sep 01 12:33:02 1997
+
+/^12.34/s
+    12\n34
+    12\r34
+
+/\w+(?=\t)/
+    the quick brown\t fox
+
+/foo(?!bar)(.*)/
+    foobar is foolish see?
+
+/(?:(?!foo)...|^.{0,2})bar(.*)/
+    foobar crowbar etc
+    barrel
+    2barrel
+    A barrel
+
+/^(\D*)(?=\d)(?!123)/
+    abc456
+    *** Failers
+    abc123
+
+/^1234(?# test newlines
+  inside)/
+    1234
+
+/^1234 #comment in extended re
+  /x
+    1234
+
+/#rhubarb
+  abcd/x
+    abcd
+
+/^abcd#rhubarb/x
+    abcd
+
+/(?!^)abc/
+    the abc
+    *** Failers
+    abc
+
+/(?=^)abc/
+    abc
+    *** Failers
+    the abc
+
+/^[ab]{1,3}(ab*|b)/
+    aabbbbb
+
+/^[ab]{1,3}?(ab*|b)/
+    aabbbbb
+
+/^[ab]{1,3}?(ab*?|b)/
+    aabbbbb
+
+/^[ab]{1,3}(ab*?|b)/
+    aabbbbb
+
+/  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                          # optional leading comment
+(?:    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+# address
+|                     #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)             # one word, optionally followed by....
+(?:
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
+\(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)       |  # comments, or...
+
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+# quoted strings
+)*
+<  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                     # leading <
+(?:  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  ,  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+)* # further okay, if led by comma
+:                                # closing colon
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  )? #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+#       address spec
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  > #                  trailing >
+# name and address
+)  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                       # optional trailing comment
+/x
+    Alan Other <user\@dom.ain>
+    <user\@dom.ain>
+    user\@dom.ain
+    \"A. Other\" <user.1234\@dom.ain> (a comment)
+    A. Other <user.1234\@dom.ain> (a comment)
+    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
+    A missing angle <user\@some.where
+    *** Failers
+    The quick brown fox
+
+/[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional leading comment
+(?:
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# additional words
+)*
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+# address
+|                             #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+# leading word
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *               # "normal" atoms and or spaces
+(?:
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+|
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+) # "special" comment or quoted string
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *            #  more "normal"
+)*
+<
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# <
+(?:
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+(?: ,
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+)*  # additional domains
+:
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)?     #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# additional words
+)*
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+#       address spec
+>                    #                 >
+# name and address
+)
+/x
+    Alan Other <user\@dom.ain>
+    <user\@dom.ain>
+    user\@dom.ain
+    \"A. Other\" <user.1234\@dom.ain> (a comment)
+    A. Other <user.1234\@dom.ain> (a comment)
+    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
+    A missing angle <user\@some.where
+    *** Failers
+    The quick brown fox
+
+/abc\0def\00pqr\000xyz\0000AB/
+    abc\0def\00pqr\000xyz\0000AB
+    abc456 abc\0def\00pqr\000xyz\0000ABCDE
+
+/abc\x0def\x00pqr\x000xyz\x0000AB/
+    abc\x0def\x00pqr\x000xyz\x0000AB
+    abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
+
+/^[\000-\037]/
+    \0A
+    \01B
+    \037C
+
+/\0*/
+    \0\0\0\0
+
+/A\x0{2,3}Z/
+    The A\x0\x0Z
+    An A\0\x0\0Z
+    *** Failers
+    A\0Z
+    A\0\x0\0\x0Z
+
+/^\s/
+    \040abc
+    \x0cabc
+    \nabc
+    \rabc
+    \tabc
+    *** Failers
+    abc
+
+/^a	b
+      c/x
+    abc
+
+/ab{1,3}bc/
+    abbbbc
+    abbbc
+    abbc
+    *** Failers
+    abc
+    abbbbbc
+
+/([^.]*)\.([^:]*):[T ]+(.*)/
+    track1.title:TBlah blah blah
+
+/([^.]*)\.([^:]*):[T ]+(.*)/i
+    track1.title:TBlah blah blah
+
+/([^.]*)\.([^:]*):[t ]+(.*)/i
+    track1.title:TBlah blah blah
+
+/^[W-c]+$/
+    WXY_^abc
+    *** Failers
+    wxy
+
+/^[W-c]+$/i
+    WXY_^abc
+    wxy_^ABC
+
+/^[\x3f-\x5F]+$/i
+    WXY_^abc
+    wxy_^ABC
+
+/^abc$/m
+    abc
+    qqq\nabc
+    abc\nzzz
+    qqq\nabc\nzzz
+
+/^abc$/
+    abc
+    *** Failers
+    qqq\nabc
+    abc\nzzz
+    qqq\nabc\nzzz
+
+/\Aabc\Z/m
+    abc
+    abc\n 
+    *** Failers
+    qqq\nabc
+    abc\nzzz
+    qqq\nabc\nzzz
+    
+/\A(.)*\Z/s
+    abc\ndef
+
+/\A(.)*\Z/m
+    *** Failers
+    abc\ndef
+
+/(?:b)|(?::+)/
+    b::c
+    c::b
+
+/[-az]+/
+    az-
+    *** Failers
+    b
+
+/[az-]+/
+    za-
+    *** Failers
+    b
+
+/[a\-z]+/
+    a-z
+    *** Failers
+    b
+
+/[a-z]+/
+    abcdxyz
+
+/[\d-]+/
+    12-34
+    *** Failers
+    aaa
+
+/[\d-z]+/
+    12-34z
+    *** Failers
+    aaa
+
+/\x5c/
+    \\
+
+/\x20Z/
+    the Zoo
+    *** Failers
+    Zulu
+
+/ab{3cd/
+    ab{3cd
+
+/ab{3,cd/
+    ab{3,cd
+
+/ab{3,4a}cd/
+    ab{3,4a}cd
+
+/{4,5a}bc/
+    {4,5a}bc
+
+/^a.b/<lf>
+    a\rb
+    *** Failers
+    a\nb
+
+/abc$/
+    abc
+    abc\n
+    *** Failers
+    abc\ndef
+
+/(abc)\123/
+    abc\x53
+
+/(abc)\223/
+    abc\x93
+
+/(abc)\323/
+    abc\xd3
+
+/(abc)\100/
+    abc\x40
+    abc\100
+
+/(abc)\1000/
+    abc\x400
+    abc\x40\x30
+    abc\1000
+    abc\100\x30
+    abc\100\060
+    abc\100\60
+
+/abc\81/
+    abc\081
+    abc\0\x38\x31
+
+/abc\91/
+    abc\091
+    abc\0\x39\x31
+
+/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
+    abcdefghijk\12S
+
+/ab\idef/
+    abidef
+
+/a{0}bc/
+    bc
+
+/(a|(bc)){0,0}?xyz/
+    xyz
+
+/abc[\10]de/
+    abc\010de
+
+/abc[\1]de/
+    abc\1de
+
+/(abc)[\1]de/
+    abc\1de
+
+/(?s)a.b/
+    a\nb
+
+/^([^a])([^\b])([^c]*)([^d]{3,4})/
+    baNOTccccd
+    baNOTcccd
+    baNOTccd
+    bacccd
+    *** Failers
+    anything
+    b\bc   
+    baccd
+
+/[^a]/
+    Abc
+  
+/[^a]/i
+    Abc 
+
+/[^a]+/
+    AAAaAbc
+  
+/[^a]+/i
+    AAAaAbc 
+
+/[^a]+/
+    bbb\nccc
+   
+/[^k]$/
+    abc
+    *** Failers
+    abk   
+   
+/[^k]{2,3}$/
+    abc
+    kbc
+    kabc 
+    *** Failers
+    abk
+    akb
+    akk 
+
+/^\d{8,}\@.+[^k]$/
+    12345678\@a.b.c.d
+    123456789\@x.y.z
+    *** Failers
+    12345678\@x.y.uk
+    1234567\@a.b.c.d       
+
+/[^a]/
+    aaaabcd
+    aaAabcd 
+
+/[^a]/i
+    aaaabcd
+    aaAabcd 
+
+/[^az]/
+    aaaabcd
+    aaAabcd 
+
+/[^az]/i
+    aaaabcd
+    aaAabcd 
+
+/\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377/
+ \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377
+
+/P[^*]TAIRE[^*]{1,6}?LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+
+/P[^*]TAIRE[^*]{1,}?LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+
+/(\.\d\d[1-9]?)\d+/
+    1.230003938
+    1.875000282   
+    1.235  
+                  
+/(\.\d\d((?=0)|\d(?=\d)))/
+    1.230003938      
+    1.875000282
+    *** Failers 
+    1.235 
+    
+/a(?)b/
+    ab 
+ 
+/\b(foo)\s+(\w+)/i
+    Food is on the foo table
+    
+/foo(.*)bar/
+    The food is under the bar in the barn.
+    
+/foo(.*?)bar/  
+    The food is under the bar in the barn.
+
+/(.*)(\d*)/
+    I have 2 numbers: 53147
+    
+/(.*)(\d+)/
+    I have 2 numbers: 53147
+ 
+/(.*?)(\d*)/
+    I have 2 numbers: 53147
+
+/(.*?)(\d+)/
+    I have 2 numbers: 53147
+
+/(.*)(\d+)$/
+    I have 2 numbers: 53147
+
+/(.*?)(\d+)$/
+    I have 2 numbers: 53147
+
+/(.*)\b(\d+)$/
+    I have 2 numbers: 53147
+
+/(.*\D)(\d+)$/
+    I have 2 numbers: 53147
+
+/^\D*(?!123)/
+    ABC123
+     
+/^(\D*)(?=\d)(?!123)/
+    ABC445
+    *** Failers
+    ABC123
+    
+/^[W-]46]/
+    W46]789 
+    -46]789
+    *** Failers
+    Wall
+    Zebra
+    42
+    [abcd] 
+    ]abcd[
+       
+/^[W-\]46]/
+    W46]789 
+    Wall
+    Zebra
+    Xylophone  
+    42
+    [abcd] 
+    ]abcd[
+    \\backslash 
+    *** Failers
+    -46]789
+    well
+    
+/\d\d\/\d\d\/\d\d\d\d/
+    01/01/2000
+
+/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
+  word cat dog elephant mussel cow horse canary baboon snake shark otherword
+  word cat dog elephant mussel cow horse canary baboon snake shark
+
+/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
+  word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+
+/^(a){0,0}/
+    bcd
+    abc
+    aab     
+
+/^(a){0,1}/
+    bcd
+    abc
+    aab  
+
+/^(a){0,2}/
+    bcd
+    abc
+    aab  
+
+/^(a){0,3}/
+    bcd
+    abc
+    aab
+    aaa   
+
+/^(a){0,}/
+    bcd
+    abc
+    aab
+    aaa
+    aaaaaaaa    
+
+/^(a){1,1}/
+    bcd
+    abc
+    aab  
+
+/^(a){1,2}/
+    bcd
+    abc
+    aab  
+
+/^(a){1,3}/
+    bcd
+    abc
+    aab
+    aaa   
+
+/^(a){1,}/
+    bcd
+    abc
+    aab
+    aaa
+    aaaaaaaa    
+
+/.*\.gif/
+    borfle\nbib.gif\nno
+
+/.{0,}\.gif/
+    borfle\nbib.gif\nno
+
+/.*\.gif/m
+    borfle\nbib.gif\nno
+
+/.*\.gif/s
+    borfle\nbib.gif\nno
+
+/.*\.gif/ms
+    borfle\nbib.gif\nno
+    
+/.*$/
+    borfle\nbib.gif\nno
+
+/.*$/m
+    borfle\nbib.gif\nno
+
+/.*$/s
+    borfle\nbib.gif\nno
+
+/.*$/ms
+    borfle\nbib.gif\nno
+    
+/.*$/
+    borfle\nbib.gif\nno\n
+
+/.*$/m
+    borfle\nbib.gif\nno\n
+
+/.*$/s
+    borfle\nbib.gif\nno\n
+
+/.*$/ms
+    borfle\nbib.gif\nno\n
+    
+/(.*X|^B)/
+    abcde\n1234Xyz
+    BarFoo 
+    *** Failers
+    abcde\nBar  
+
+/(.*X|^B)/m
+    abcde\n1234Xyz
+    BarFoo 
+    abcde\nBar  
+
+/(.*X|^B)/s
+    abcde\n1234Xyz
+    BarFoo 
+    *** Failers
+    abcde\nBar  
+
+/(.*X|^B)/ms
+    abcde\n1234Xyz
+    BarFoo 
+    abcde\nBar  
+
+/(?s)(.*X|^B)/
+    abcde\n1234Xyz
+    BarFoo 
+    *** Failers 
+    abcde\nBar  
+
+/(?s:.*X|^B)/
+    abcde\n1234Xyz
+    BarFoo 
+    *** Failers 
+    abcde\nBar  
+
+/^.*B/
+    **** Failers
+    abc\nB
+     
+/(?s)^.*B/
+    abc\nB
+
+/(?m)^.*B/
+    abc\nB
+     
+/(?ms)^.*B/
+    abc\nB
+
+/(?ms)^B/
+    abc\nB
+
+/(?s)B$/
+    B\n
+
+/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
+    123456654321
+  
+/^\d\d\d\d\d\d\d\d\d\d\d\d/
+    123456654321 
+
+/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
+    123456654321
+  
+/^[abc]{12}/
+    abcabcabcabc
+    
+/^[a-c]{12}/
+    abcabcabcabc
+    
+/^(a|b|c){12}/
+    abcabcabcabc 
+
+/^[abcdefghijklmnopqrstuvwxy0123456789]/
+    n
+    *** Failers 
+    z 
+
+/abcde{0,0}/
+    abcd
+    *** Failers
+    abce  
+
+/ab[cd]{0,0}e/
+    abe
+    *** Failers
+    abcde 
+    
+/ab(c){0,0}d/
+    abd
+    *** Failers
+    abcd   
+
+/a(b*)/
+    a
+    ab
+    abbbb
+    *** Failers
+    bbbbb    
+    
+/ab\d{0}e/
+    abe
+    *** Failers
+    ab1e   
+    
+/"([^\\"]+|\\.)*"/
+    the \"quick\" brown fox
+    \"the \\\"quick\\\" brown fox\" 
+
+/.*?/g+
+    abc
+  
+/\b/g+
+    abc 
+
+/\b/+g
+    abc 
+
+//g
+    abc
+
+/<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/is
+  <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
+
+/a[^a]b/
+    acb
+    a\nb
+    
+/a.b/
+    acb
+    *** Failers 
+    a\nb   
+    
+/a[^a]b/s
+    acb
+    a\nb  
+    
+/a.b/s
+    acb
+    a\nb  
+
+/^(b+?|a){1,2}?c/
+    bac
+    bbac
+    bbbac
+    bbbbac
+    bbbbbac 
+
+/^(b+|a){1,2}?c/
+    bac
+    bbac
+    bbbac
+    bbbbac
+    bbbbbac 
+    
+/(?!\A)x/m
+    x\nb\n
+    a\bx\n  
+    
+/\x0{ab}/
+    \0{ab} 
+
+/(A|B)*?CD/
+    CD 
+    
+/(A|B)*CD/
+    CD 
+
+/(?<!bar)foo/
+    foo
+    catfood
+    arfootle
+    rfoosh
+    *** Failers
+    barfoo
+    towbarfoo
+
+/\w{3}(?<!bar)foo/
+    catfood
+    *** Failers
+    foo
+    barfoo
+    towbarfoo
+
+/(?<=(foo)a)bar/
+    fooabar
+    *** Failers
+    bar
+    foobbar
+      
+/\Aabc\z/m
+    abc
+    *** Failers
+    abc\n   
+    qqq\nabc
+    abc\nzzz
+    qqq\nabc\nzzz
+
+"(?>.*/)foo"
+    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
+
+"(?>.*/)foo"
+    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+
+/(?>(\.\d\d[1-9]?))\d+/
+    1.230003938
+    1.875000282
+    *** Failers 
+    1.235 
+
+/^((?>\w+)|(?>\s+))*$/
+    now is the time for all good men to come to the aid of the party
+    *** Failers
+    this is not a line with only words and spaces!
+    
+/(\d+)(\w)/
+    12345a
+    12345+ 
+
+/((?>\d+))(\w)/
+    12345a
+    *** Failers
+    12345+ 
+
+/(?>a+)b/
+    aaab
+
+/((?>a+)b)/
+    aaab
+
+/(?>(a+))b/
+    aaab
+
+/(?>b)+/
+    aaabbbccc
+
+/(?>a+|b+|c+)*c/
+    aaabbbbccccd
+    
+/(a+|b+|c+)*c/
+    aaabbbbccccd
+
+/((?>[^()]+)|\([^()]*\))+/
+    ((abc(ade)ufh()()x
+    
+/\(((?>[^()]+)|\([^()]+\))+\)/ 
+    (abc)
+    (abc(def)xyz)
+    *** Failers
+    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa   
+
+/a(?-i)b/i
+    ab
+    Ab
+    *** Failers 
+    aB
+    AB
+        
+/(a (?x)b c)d e/
+    a bcd e
+    *** Failers
+    a b cd e
+    abcd e   
+    a bcde 
+ 
+/(a b(?x)c d (?-x)e f)/
+    a bcde f
+    *** Failers
+    abcdef  
+
+/(a(?i)b)c/
+    abc
+    aBc
+    *** Failers
+    abC
+    aBC  
+    Abc
+    ABc
+    ABC
+    AbC
+    
+/a(?i:b)c/
+    abc
+    aBc
+    *** Failers 
+    ABC
+    abC
+    aBC
+    
+/a(?i:b)*c/
+    aBc
+    aBBc
+    *** Failers 
+    aBC
+    aBBC
+    
+/a(?=b(?i)c)\w\wd/
+    abcd
+    abCd
+    *** Failers
+    aBCd
+    abcD     
+    
+/(?s-i:more.*than).*million/i
+    more than million
+    more than MILLION
+    more \n than Million 
+    *** Failers
+    MORE THAN MILLION    
+    more \n than \n million 
+
+/(?:(?s-i)more.*than).*million/i
+    more than million
+    more than MILLION
+    more \n than Million 
+    *** Failers
+    MORE THAN MILLION    
+    more \n than \n million 
+    
+/(?>a(?i)b+)+c/ 
+    abc
+    aBbc
+    aBBc 
+    *** Failers
+    Abc
+    abAb    
+    abbC 
+    
+/(?=a(?i)b)\w\wc/
+    abc
+    aBc
+    *** Failers
+    Ab 
+    abC
+    aBC     
+    
+/(?<=a(?i)b)(\w\w)c/
+    abxxc
+    aBxxc
+    *** Failers
+    Abxxc
+    ABxxc
+    abxxC      
+
+/^(?(?=abc)\w{3}:|\d\d)$/
+    abc:
+    12
+    *** Failers
+    123
+    xyz    
+
+/^(?(?!abc)\d\d|\w{3}:)$/
+    abc:
+    12
+    *** Failers
+    123
+    xyz    
+    
+/(?(?<=foo)bar|cat)/
+    foobar
+    cat
+    fcat
+    focat   
+    *** Failers
+    foocat  
+
+/(?(?<!foo)cat|bar)/
+    foobar
+    cat
+    fcat
+    focat   
+    *** Failers
+    foocat  
+
+/(?>a*)*/
+    a
+    aa
+    aaaa
+    
+/(abc|)+/
+    abc
+    abcabc
+    abcabcabc
+    xyz      
+
+/([a]*)*/
+    a
+    aaaaa 
+ 
+/([ab]*)*/
+    a
+    b
+    ababab
+    aaaabcde
+    bbbb    
+ 
+/([^a]*)*/
+    b
+    bbbb
+    aaa   
+ 
+/([^ab]*)*/
+    cccc
+    abab  
+ 
+/([a]*?)*/
+    a
+    aaaa 
+ 
+/([ab]*?)*/
+    a
+    b
+    abab
+    baba   
+ 
+/([^a]*?)*/
+    b
+    bbbb
+    aaa   
+ 
+/([^ab]*?)*/
+    c
+    cccc
+    baba   
+ 
+/(?>a*)*/
+    a
+    aaabcde 
+ 
+/((?>a*))*/
+    aaaaa
+    aabbaa 
+ 
+/((?>a*?))*/
+    aaaaa
+    aabbaa 
+
+/(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /x
+    12-sep-98
+    12-09-98
+    *** Failers
+    sep-12-98
+        
+/(?i:saturday|sunday)/
+    saturday
+    sunday
+    Saturday
+    Sunday
+    SATURDAY
+    SUNDAY
+    SunDay
+    
+/(a(?i)bc|BB)x/
+    abcx
+    aBCx
+    bbx
+    BBx
+    *** Failers
+    abcX
+    aBCX
+    bbX
+    BBX               
+
+/^([ab](?i)[cd]|[ef])/
+    ac
+    aC
+    bD
+    elephant
+    Europe 
+    frog
+    France
+    *** Failers
+    Africa     
+
+/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
+    ab
+    aBd
+    xy
+    xY
+    zebra
+    Zambesi
+    *** Failers
+    aCD  
+    XY  
+
+/(?<=foo\n)^bar/m
+    foo\nbar
+    *** Failers
+    bar
+    baz\nbar   
+
+/(?<=(?<!foo)bar)baz/
+    barbaz
+    barbarbaz 
+    koobarbaz 
+    *** Failers
+    baz
+    foobarbaz 
+
+/The following tests are taken from the Perl 5.005 test suite; some of them/
+/are compatible with 5.004, but I'd rather not have to sort them out./
+
+/abc/
+    abc
+    xabcy
+    ababc
+    *** Failers
+    xbc
+    axc
+    abx
+
+/ab*c/
+    abc
+
+/ab*bc/
+    abc
+    abbc
+    abbbbc
+
+/.{1}/
+    abbbbc
+
+/.{3,4}/
+    abbbbc
+
+/ab{0,}bc/
+    abbbbc
+
+/ab+bc/
+    abbc
+    *** Failers
+    abc
+    abq
+
+/ab{1,}bc/
+
+/ab+bc/
+    abbbbc
+
+/ab{1,}bc/
+    abbbbc
+
+/ab{1,3}bc/
+    abbbbc
+
+/ab{3,4}bc/
+    abbbbc
+
+/ab{4,5}bc/
+    *** Failers
+    abq
+    abbbbc
+
+/ab?bc/
+    abbc
+    abc
+
+/ab{0,1}bc/
+    abc
+
+/ab?bc/
+
+/ab?c/
+    abc
+
+/ab{0,1}c/
+    abc
+
+/^abc$/
+    abc
+    *** Failers
+    abbbbc
+    abcc
+
+/^abc/
+    abcc
+
+/^abc$/
+
+/abc$/
+    aabc
+    *** Failers
+    aabc
+    aabcd
+
+/^/
+    abc
+
+/$/
+    abc
+
+/a.c/
+    abc
+    axc
+
+/a.*c/
+    axyzc
+
+/a[bc]d/
+    abd
+    *** Failers
+    axyzd
+    abc
+
+/a[b-d]e/
+    ace
+
+/a[b-d]/
+    aac
+
+/a[-b]/
+    a-
+
+/a[b-]/
+    a-
+
+/a]/
+    a]
+
+/a[]]b/
+    a]b
+
+/a[^bc]d/
+    aed
+    *** Failers
+    abd
+    abd
+
+/a[^-b]c/
+    adc
+
+/a[^]b]c/
+    adc
+    *** Failers
+    a-c
+    a]c
+
+/\ba\b/
+    a-
+    -a
+    -a-
+
+/\by\b/
+    *** Failers
+    xy
+    yz
+    xyz
+
+/\Ba\B/
+    *** Failers
+    a-
+    -a
+    -a-
+
+/\By\b/
+    xy
+
+/\by\B/
+    yz
+
+/\By\B/
+    xyz
+
+/\w/
+    a
+
+/\W/
+    -
+    *** Failers
+    -
+    a
+
+/a\sb/
+    a b
+
+/a\Sb/
+    a-b
+    *** Failers
+    a-b
+    a b
+
+/\d/
+    1
+
+/\D/
+    -
+    *** Failers
+    -
+    1
+
+/[\w]/
+    a
+
+/[\W]/
+    -
+    *** Failers
+    -
+    a
+
+/a[\s]b/
+    a b
+
+/a[\S]b/
+    a-b
+    *** Failers
+    a-b
+    a b
+
+/[\d]/
+    1
+
+/[\D]/
+    -
+    *** Failers
+    -
+    1
+
+/ab|cd/
+    abc
+    abcd
+
+/()ef/
+    def
+
+/$b/
+
+/a\(b/
+    a(b
+
+/a\(*b/
+    ab
+    a((b
+
+/a\\b/
+    a\b
+
+/((a))/
+    abc
+
+/(a)b(c)/
+    abc
+
+/a+b+c/
+    aabbabc
+
+/a{1,}b{1,}c/
+    aabbabc
+
+/a.+?c/
+    abcabc
+
+/(a+|b)*/
+    ab
+
+/(a+|b){0,}/
+    ab
+
+/(a+|b)+/
+    ab
+
+/(a+|b){1,}/
+    ab
+
+/(a+|b)?/
+    ab
+
+/(a+|b){0,1}/
+    ab
+
+/[^ab]*/
+    cde
+
+/abc/
+    *** Failers
+    b
+    
+
+/a*/
+    
+
+/([abc])*d/
+    abbbcd
+
+/([abc])*bcd/
+    abcd
+
+/a|b|c|d|e/
+    e
+
+/(a|b|c|d|e)f/
+    ef
+
+/abcd*efg/
+    abcdefg
+
+/ab*/
+    xabyabbbz
+    xayabbbz
+
+/(ab|cd)e/
+    abcde
+
+/[abhgefdc]ij/
+    hij
+
+/^(ab|cd)e/
+
+/(abc|)ef/
+    abcdef
+
+/(a|b)c*d/
+    abcd
+
+/(ab|ab*)bc/
+    abc
+
+/a([bc]*)c*/
+    abc
+
+/a([bc]*)(c*d)/
+    abcd
+
+/a([bc]+)(c*d)/
+    abcd
+
+/a([bc]*)(c+d)/
+    abcd
+
+/a[bcd]*dcdcde/
+    adcdcde
+
+/a[bcd]+dcdcde/
+    *** Failers
+    abcde
+    adcdcde
+
+/(ab|a)b*c/
+    abc
+
+/((a)(b)c)(d)/
+    abcd
+
+/[a-zA-Z_][a-zA-Z0-9_]*/
+    alpha
+
+/^a(bc+|b[eh])g|.h$/
+    abh
+
+/(bc+d$|ef*g.|h?i(j|k))/
+    effgz
+    ij
+    reffgz
+    *** Failers
+    effg
+    bcdd
+
+/((((((((((a))))))))))/
+    a
+
+/(((((((((a)))))))))/
+    a
+
+/multiple words of text/
+    *** Failers
+    aa
+    uh-uh
+
+/multiple words/
+    multiple words, yeah
+
+/(.*)c(.*)/
+    abcde
+
+/\((.*), (.*)\)/
+    (a, b)
+
+/[k]/
+
+/abcd/
+    abcd
+
+/a(bc)d/
+    abcd
+
+/a[-]?c/
+    ac
+
+/abc/i
+    ABC
+    XABCY
+    ABABC
+    *** Failers
+    aaxabxbaxbbx
+    XBC
+    AXC
+    ABX
+
+/ab*c/i
+    ABC
+
+/ab*bc/i
+    ABC
+    ABBC
+
+/ab*?bc/i
+    ABBBBC
+
+/ab{0,}?bc/i
+    ABBBBC
+
+/ab+?bc/i
+    ABBC
+
+/ab+bc/i
+    *** Failers
+    ABC
+    ABQ
+
+/ab{1,}bc/i
+
+/ab+bc/i
+    ABBBBC
+
+/ab{1,}?bc/i
+    ABBBBC
+
+/ab{1,3}?bc/i
+    ABBBBC
+
+/ab{3,4}?bc/i
+    ABBBBC
+
+/ab{4,5}?bc/i
+    *** Failers
+    ABQ
+    ABBBBC
+
+/ab??bc/i
+    ABBC
+    ABC
+
+/ab{0,1}?bc/i
+    ABC
+
+/ab??bc/i
+
+/ab??c/i
+    ABC
+
+/ab{0,1}?c/i
+    ABC
+
+/^abc$/i
+    ABC
+    *** Failers
+    ABBBBC
+    ABCC
+
+/^abc/i
+    ABCC
+
+/^abc$/i
+
+/abc$/i
+    AABC
+
+/^/i
+    ABC
+
+/$/i
+    ABC
+
+/a.c/i
+    ABC
+    AXC
+
+/a.*?c/i
+    AXYZC
+
+/a.*c/i
+    *** Failers
+    AABC
+    AXYZD
+
+/a[bc]d/i
+    ABD
+
+/a[b-d]e/i
+    ACE
+    *** Failers
+    ABC
+    ABD
+
+/a[b-d]/i
+    AAC
+
+/a[-b]/i
+    A-
+
+/a[b-]/i
+    A-
+
+/a]/i
+    A]
+
+/a[]]b/i
+    A]B
+
+/a[^bc]d/i
+    AED
+
+/a[^-b]c/i
+    ADC
+    *** Failers
+    ABD
+    A-C
+
+/a[^]b]c/i
+    ADC
+
+/ab|cd/i
+    ABC
+    ABCD
+
+/()ef/i
+    DEF
+
+/$b/i
+    *** Failers
+    A]C
+    B
+
+/a\(b/i
+    A(B
+
+/a\(*b/i
+    AB
+    A((B
+
+/a\\b/i
+    A\B
+
+/((a))/i
+    ABC
+
+/(a)b(c)/i
+    ABC
+
+/a+b+c/i
+    AABBABC
+
+/a{1,}b{1,}c/i
+    AABBABC
+
+/a.+?c/i
+    ABCABC
+
+/a.*?c/i
+    ABCABC
+
+/a.{0,5}?c/i
+    ABCABC
+
+/(a+|b)*/i
+    AB
+
+/(a+|b){0,}/i
+    AB
+
+/(a+|b)+/i
+    AB
+
+/(a+|b){1,}/i
+    AB
+
+/(a+|b)?/i
+    AB
+
+/(a+|b){0,1}/i
+    AB
+
+/(a+|b){0,1}?/i
+    AB
+
+/[^ab]*/i
+    CDE
+
+/abc/i
+
+/a*/i
+    
+
+/([abc])*d/i
+    ABBBCD
+
+/([abc])*bcd/i
+    ABCD
+
+/a|b|c|d|e/i
+    E
+
+/(a|b|c|d|e)f/i
+    EF
+
+/abcd*efg/i
+    ABCDEFG
+
+/ab*/i
+    XABYABBBZ
+    XAYABBBZ
+
+/(ab|cd)e/i
+    ABCDE
+
+/[abhgefdc]ij/i
+    HIJ
+
+/^(ab|cd)e/i
+    ABCDE
+
+/(abc|)ef/i
+    ABCDEF
+
+/(a|b)c*d/i
+    ABCD
+
+/(ab|ab*)bc/i
+    ABC
+
+/a([bc]*)c*/i
+    ABC
+
+/a([bc]*)(c*d)/i
+    ABCD
+
+/a([bc]+)(c*d)/i
+    ABCD
+
+/a([bc]*)(c+d)/i
+    ABCD
+
+/a[bcd]*dcdcde/i
+    ADCDCDE
+
+/a[bcd]+dcdcde/i
+
+/(ab|a)b*c/i
+    ABC
+
+/((a)(b)c)(d)/i
+    ABCD
+
+/[a-zA-Z_][a-zA-Z0-9_]*/i
+    ALPHA
+
+/^a(bc+|b[eh])g|.h$/i
+    ABH
+
+/(bc+d$|ef*g.|h?i(j|k))/i
+    EFFGZ
+    IJ
+    REFFGZ
+    *** Failers
+    ADCDCDE
+    EFFG
+    BCDD
+
+/((((((((((a))))))))))/i
+    A
+
+/(((((((((a)))))))))/i
+    A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
+    A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
+    C
+
+/multiple words of text/i
+    *** Failers
+    AA
+    UH-UH
+
+/multiple words/i
+    MULTIPLE WORDS, YEAH
+
+/(.*)c(.*)/i
+    ABCDE
+
+/\((.*), (.*)\)/i
+    (A, B)
+
+/[k]/i
+
+/abcd/i
+    ABCD
+
+/a(bc)d/i
+    ABCD
+
+/a[-]?c/i
+    AC
+
+/a(?!b)./
+    abad
+
+/a(?=d)./
+    abad
+
+/a(?=c|d)./
+    abad
+
+/a(?:b|c|d)(.)/
+    ace
+
+/a(?:b|c|d)*(.)/
+    ace
+
+/a(?:b|c|d)+?(.)/
+    ace
+    acdbcdbe
+
+/a(?:b|c|d)+(.)/
+    acdbcdbe
+
+/a(?:b|c|d){2}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){4,5}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){4,5}?(.)/
+    acdbcdbe
+
+/((foo)|(bar))*/
+    foobar
+
+/a(?:b|c|d){6,7}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){6,7}?(.)/
+    acdbcdbe
+
+/a(?:b|c|d){5,6}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){5,6}?(.)/
+    acdbcdbe
+
+/a(?:b|c|d){5,7}(.)/
+    acdbcdbe
+
+/a(?:b|c|d){5,7}?(.)/
+    acdbcdbe
+
+/a(?:b|(c|e){1,2}?|d)+?(.)/
+    ace
+
+/^(.+)?B/
+    AB
+
+/^([^a-z])|(\^)$/
+    .
+
+/^[<>]&/
+    <&OUT
+
+/(?:(f)(o)(o)|(b)(a)(r))*/
+    foobar
+
+/(?<=a)b/
+    ab
+    *** Failers
+    cb
+    b
+
+/(?<!c)b/
+    ab
+    b
+    b
+
+/(?:..)*a/
+    aba
+
+/(?:..)*?a/
+    aba
+
+/^(){3,5}/
+    abc
+
+/^(a+)*ax/
+    aax
+
+/^((a|b)+)*ax/
+    aax
+
+/^((a|bc)+)*ax/
+    aax
+
+/(a|x)*ab/
+    cab
+
+/(a)*ab/
+    cab
+
+/(?:(?i)a)b/
+    ab
+
+/((?i)a)b/
+    ab
+
+/(?:(?i)a)b/
+    Ab
+
+/((?i)a)b/
+    Ab
+
+/(?:(?i)a)b/
+    *** Failers
+    cb
+    aB
+
+/((?i)a)b/
+
+/(?i:a)b/
+    ab
+
+/((?i:a))b/
+    ab
+
+/(?i:a)b/
+    Ab
+
+/((?i:a))b/
+    Ab
+
+/(?i:a)b/
+    *** Failers
+    aB
+    aB
+
+/((?i:a))b/
+
+/(?:(?-i)a)b/i
+    ab
+
+/((?-i)a)b/i
+    ab
+
+/(?:(?-i)a)b/i
+    aB
+
+/((?-i)a)b/i
+    aB
+
+/(?:(?-i)a)b/i
+    *** Failers
+    aB
+    Ab
+
+/((?-i)a)b/i
+
+/(?:(?-i)a)b/i
+    aB
+
+/((?-i)a)b/i
+    aB
+
+/(?:(?-i)a)b/i
+    *** Failers
+    Ab
+    AB
+
+/((?-i)a)b/i
+
+/(?-i:a)b/i
+    ab
+
+/((?-i:a))b/i
+    ab
+
+/(?-i:a)b/i
+    aB
+
+/((?-i:a))b/i
+    aB
+
+/(?-i:a)b/i
+    *** Failers
+    AB
+    Ab
+
+/((?-i:a))b/i
+
+/(?-i:a)b/i
+    aB
+
+/((?-i:a))b/i
+    aB
+
+/(?-i:a)b/i
+    *** Failers
+    Ab
+    AB
+
+/((?-i:a))b/i
+
+/((?-i:a.))b/i
+    *** Failers
+    AB
+    a\nB
+
+/((?s-i:a.))b/i
+    a\nB
+
+/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
+    cabbbb
+
+/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
+    caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+/foo\w*\d{4}baz/
+    foobar1234baz
+
+/x(~~)*(?:(?:F)?)?/
+    x~~
+
+/^a(?#xxx){3}c/
+    aaac
+
+/^a (?#xxx) (?#yyy) {3}c/x
+    aaac
+
+/(?<![cd])b/
+    *** Failers
+    B\nB
+    dbcb
+
+/(?<![cd])[ab]/
+    dbaacb
+
+/(?<!(c|d))b/
+
+/(?<!(c|d))[ab]/
+    dbaacb
+
+/(?<!cd)[ab]/
+    cdaccb
+
+/^(?:a?b?)*$/
+    *** Failers
+    dbcb
+    a--
+
+/((?s)^a(.))((?m)^b$)/
+    a\nb\nc\n
+
+/((?m)^b$)/
+    a\nb\nc\n
+
+/(?m)^b/
+    a\nb\n
+
+/(?m)^(b)/
+    a\nb\n
+
+/((?m)^b)/
+    a\nb\n
+
+/\n((?m)^b)/
+    a\nb\n
+
+/((?s).)c(?!.)/
+    a\nb\nc\n
+    a\nb\nc\n
+
+/((?s)b.)c(?!.)/
+    a\nb\nc\n
+    a\nb\nc\n
+
+/^b/
+
+/()^b/
+    *** Failers
+    a\nb\nc\n
+    a\nb\nc\n
+
+/((?m)^b)/
+    a\nb\nc\n
+
+/(?(?!a)a|b)/
+
+/(?(?!a)b|a)/
+    a
+
+/(?(?=a)b|a)/
+    *** Failers
+    a
+    a
+
+/(?(?=a)a|b)/
+    a
+
+/(\w+:)+/
+    one:
+
+/$(?<=^(a))/
+    a
+
+/([\w:]+::)?(\w+)$/
+    abcd
+    xy:z:::abcd
+
+/^[^bcd]*(c+)/
+    aexycd
+
+/(a*)b+/
+    caab
+
+/([\w:]+::)?(\w+)$/
+    abcd
+    xy:z:::abcd
+    *** Failers
+    abcd:
+    abcd:
+
+/^[^bcd]*(c+)/
+    aexycd
+
+/(>a+)ab/
+
+/(?>a+)b/
+    aaab
+
+/([[:]+)/
+    a:[b]:
+
+/([[=]+)/
+    a=[b]=
+
+/([[.]+)/
+    a.[b].
+
+/((?>a+)b)/
+    aaab
+
+/(?>(a+))b/
+    aaab
+
+/((?>[^()]+)|\([^()]*\))+/
+    ((abc(ade)ufh()()x
+
+/a\Z/
+    *** Failers
+    aaab
+    a\nb\n
+
+/b\Z/
+    a\nb\n
+
+/b\z/
+
+/b\Z/
+    a\nb
+
+/b\z/
+    a\nb
+    *** Failers
+    
+/(?>.*)(?<=(abcd|wxyz))/
+    alphabetabcd
+    endingwxyz
+    *** Failers
+    a rather long string that doesn't end with one of them
+
+/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
+    word cat dog elephant mussel cow horse canary baboon snake shark otherword
+    word cat dog elephant mussel cow horse canary baboon snake shark
+  
+/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
+    word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+
+/(?<=\d{3}(?!999))foo/
+    999foo
+    123999foo 
+    *** Failers
+    123abcfoo
+    
+/(?<=(?!...999)\d{3})foo/
+    999foo
+    123999foo 
+    *** Failers
+    123abcfoo
+
+/(?<=\d{3}(?!999)...)foo/
+    123abcfoo
+    123456foo 
+    *** Failers
+    123999foo  
+    
+/(?<=\d{3}...)(?<!999)foo/
+    123abcfoo   
+    123456foo 
+    *** Failers
+    123999foo  
+
+/((Z)+|A)*/
+    ZABCDEFG
+
+/(Z()|A)*/
+    ZABCDEFG
+
+/(Z(())|A)*/
+    ZABCDEFG
+
+/((?>Z)+|A)*/
+    ZABCDEFG
+
+/((?>)+|A)*/
+    ZABCDEFG
+
+/a*/g
+    abbab
+
+/^[a-\d]/
+    abcde
+    -things
+    0digit
+    *** Failers
+    bcdef    
+
+/^[\d-a]/
+    abcde
+    -things
+    0digit
+    *** Failers
+    bcdef    
+    
+/[[:space:]]+/
+    > \x09\x0a\x0c\x0d\x0b<
+     
+/[[:blank:]]+/
+    > \x09\x0a\x0c\x0d\x0b<
+     
+/[\s]+/
+    > \x09\x0a\x0c\x0d\x0b<
+     
+/\s+/
+    > \x09\x0a\x0c\x0d\x0b<
+     
+/ab/x
+    ab
+
+/(?!\A)x/m
+  a\nxb\n
+
+/(?!^)x/m
+  a\nxb\n
+
+/abc\Qabc\Eabc/
+    abcabcabc
+    
+/abc\Q(*+|\Eabc/
+    abc(*+|abc 
+
+/   abc\Q abc\Eabc/x
+    abc abcabc
+    *** Failers
+    abcabcabc  
+    
+/abc#comment
+    \Q#not comment
+    literal\E/x
+    abc#not comment\n    literal     
+
+/abc#comment
+    \Q#not comment
+    literal/x
+    abc#not comment\n    literal     
+
+/abc#comment
+    \Q#not comment
+    literal\E #more comment
+    /x
+    abc#not comment\n    literal     
+
+/abc#comment
+    \Q#not comment
+    literal\E #more comment/x
+    abc#not comment\n    literal     
+
+/\Qabc\$xyz\E/
+    abc\\\$xyz
+
+/\Qabc\E\$\Qxyz\E/
+    abc\$xyz
+
+/\Gabc/
+    abc
+    *** Failers
+    xyzabc  
+
+/\Gabc./g
+    abc1abc2xyzabc3
+
+/abc./g
+    abc1abc2xyzabc3 
+
+/a(?x: b c )d/
+    XabcdY
+    *** Failers 
+    Xa b c d Y 
+
+/((?x)x y z | a b c)/
+    XabcY
+    AxyzB 
+
+/(?i)AB(?-i)C/
+    XabCY
+    *** Failers
+    XabcY  
+
+/((?i)AB(?-i)C|D)E/
+    abCE
+    DE
+    *** Failers
+    abcE
+    abCe  
+    dE
+    De    
+
+/[z\Qa-d]\E]/
+    z
+    a
+    -
+    d
+    ] 
+    *** Failers
+    b     
+
+/[\z\C]/
+    z
+    C 
+    
+/\M/
+    M 
+    
+/(a+)*b/
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
+    
+/(?i)reg(?:ul(?:[aä]|ae)r|ex)/
+    REGular
+    regulaer
+    Regex  
+    regulär 
+
+/Åæåä[à-ÿÀ-ß]+/
+    Åæåäà
+    Åæåäÿ
+    ÅæåäÀ
+    Åæåäß
+
+/(?<=Z)X./
+    \x84XAZXB
+
+/^(?(2)a|(1)(2))+$/
+    123a
+
+/(?<=a|bbbb)c/
+    ac
+    bbbbc
+
+/abc/>testsavedregex
+<testsavedregex
+    abc
+    *** Failers
+    bca
+    
+/abc/F>testsavedregex
+<testsavedregex
+    abc
+    *** Failers
+    bca
+
+/(a|b)/S>testsavedregex
+<testsavedregex
+    abc
+    *** Failers
+    def  
+    
+/(a|b)/SF>testsavedregex
+<testsavedregex
+    abc
+    *** Failers
+    def  
+    
+/line\nbreak/
+    this is a line\nbreak
+    line one\nthis is a line\nbreak in the second line 
+
+/line\nbreak/f
+    this is a line\nbreak
+    ** Failers 
+    line one\nthis is a line\nbreak in the second line 
+
+/line\nbreak/mf
+    this is a line\nbreak
+    ** Failers 
+    line one\nthis is a line\nbreak in the second line 
+
+/1234/
+    123\P
+    a4\P\R
+
+/1234/
+    123\P
+    4\P\R
+
+/^/mg
+    a\nb\nc\n
+    \ 
+    
+/(?<=C\n)^/mg
+    A\nC\nC\n 
+
+/(?s)A?B/
+    AB
+    aB  
+
+/(?s)A*B/
+    AB
+    aB  
+
+/(?m)A?B/
+    AB
+    aB  
+
+/(?m)A*B/
+    AB
+    aB  
+
+/Content-Type\x3A[^\r\n]{6,}/
+    Content-Type:xxxxxyyy 
+
+/Content-Type\x3A[^\r\n]{6,}z/
+    Content-Type:xxxxxyyyz
+
+/Content-Type\x3A[^a]{6,}/
+    Content-Type:xxxyyy 
+
+/Content-Type\x3A[^a]{6,}z/
+    Content-Type:xxxyyyz
+
+/^abc/m
+    xyz\nabc
+    xyz\nabc\<lf>
+    xyz\r\nabc\<lf>
+    xyz\rabc\<cr>
+    xyz\r\nabc\<crlf>
+    ** Failers 
+    xyz\nabc\<cr>
+    xyz\r\nabc\<cr>
+    xyz\nabc\<crlf>
+    xyz\rabc\<crlf>
+    xyz\rabc\<lf>
+    
+/abc$/m<lf>
+    xyzabc
+    xyzabc\n 
+    xyzabc\npqr 
+    xyzabc\r\<cr> 
+    xyzabc\rpqr\<cr> 
+    xyzabc\r\n\<crlf> 
+    xyzabc\r\npqr\<crlf> 
+    ** Failers
+    xyzabc\r 
+    xyzabc\rpqr 
+    xyzabc\r\n 
+    xyzabc\r\npqr 
+    
+/^abc/m<cr>
+    xyz\rabcdef
+    xyz\nabcdef\<lf>
+    ** Failers  
+    xyz\nabcdef
+       
+/^abc/m<lf>
+    xyz\nabcdef
+    xyz\rabcdef\<cr>
+    ** Failers  
+    xyz\rabcdef
+       
+/^abc/m<crlf>
+    xyz\r\nabcdef
+    xyz\rabcdef\<cr>
+    ** Failers  
+    xyz\rabcdef
+    
+/.*/<lf>
+    abc\ndef
+    abc\rdef
+    abc\r\ndef
+    \<cr>abc\ndef
+    \<cr>abc\rdef
+    \<cr>abc\r\ndef
+    \<crlf>abc\ndef
+    \<crlf>abc\rdef
+    \<crlf>abc\r\ndef
+
+/\w+(.)(.)?def/s
+    abc\ndef
+    abc\rdef
+    abc\r\ndef
+
+/^\w+=.*(\\\n.*)*/
+    abc=xyz\\\npqr
+
+/^(a()*)*/
+    aaaa
+
+/^(?:a(?:(?:))*)*/
+    aaaa
+
+/^(a()+)+/
+    aaaa
+
+/^(?:a(?:(?:))+)+/
+    aaaa
+
+/(a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/(?>a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/(?:a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/^a.b/<lf>
+    a\rb
+    a\nb\<cr> 
+    ** Failers
+    a\nb
+    a\nb\<any>
+    a\rb\<cr>   
+    a\rb\<any>   
+
+/^abc./mgx<any>
+    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x85abc7 JUNK
+
+/abc.$/mgx<any>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc9
+
+/^a\Rb/<bsr_unicode>
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0cb
+    a\x85b   
+    ** Failers
+    a\n\rb    
+
+/^a\R*b/<bsr_unicode>
+    ab
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0cb
+    a\x85b   
+    a\n\rb    
+    a\n\r\x85\x0cb 
+
+/^a\R+b/<bsr_unicode>
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0cb
+    a\x85b   
+    a\n\rb    
+    a\n\r\x85\x0cb 
+    ** Failers
+    ab  
+    
+/^a\R{1,3}b/<bsr_unicode>
+    a\nb
+    a\n\rb
+    a\n\r\x85b
+    a\r\n\r\nb 
+    a\r\n\r\n\r\nb 
+    a\n\r\n\rb
+    a\n\n\r\nb 
+    ** Failers
+    a\n\n\n\rb
+    a\r
+
+/^a[\R]b/<bsr_unicode>
+    aRb
+    ** Failers
+    a\nb  
+
+/.+foo/
+    afoo
+    ** Failers 
+    \r\nfoo 
+    \nfoo 
+
+/.+foo/<crlf>
+    afoo
+    \nfoo 
+    ** Failers 
+    \r\nfoo 
+
+/.+foo/<any>
+    afoo
+    ** Failers 
+    \nfoo 
+    \r\nfoo 
+
+/.+foo/s
+    afoo
+    \r\nfoo 
+    \nfoo 
+
+/^$/mg<any>
+    abc\r\rxyz
+    abc\n\rxyz  
+    ** Failers 
+    abc\r\nxyz
+
+/^X/m
+    XABC
+    ** Failers 
+    XABC\B
+
+/(?m)^$/<any>g+
+    abc\r\n\r\n
+
+/(?m)^$|^\r\n/<any>g+ 
+    abc\r\n\r\n
+    
+/(?m)$/<any>g+ 
+    abc\r\n\r\n
+
+/(?|(abc)|(xyz))/
+   >abc<
+   >xyz< 
+
+/(x)(?|(abc)|(xyz))(x)/
+    xabcx
+    xxyzx 
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/
+    xabcpqrx
+    xxyzx 
+
+/(?|(abc)|(xyz))(?1)/
+    abcabc
+    xyzabc 
+    ** Failers 
+    xyzxyz 
+ 
+/\H\h\V\v/
+    X X\x0a
+    X\x09X\x0b
+    ** Failers
+    \xa0 X\x0a   
+    
+/\H*\h+\V?\v{3,4}/ 
+    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\xa0\x0a\x0b\x0c
+    ** Failers 
+    \x09\x20\xa0\x0a\x0b
+     
+/\H{3,4}/
+    XY  ABCDE
+    XY  PQR ST 
+    
+/.\h{3,4}./
+    XY  AB    PQRS
+
+/\h*X\h?\H+Y\H?Z/
+    >XNNNYZ
+    >  X NYQZ
+    ** Failers
+    >XYZ   
+    >  X NY Z
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+    >XY\x0aZ\x0aA\x0bNN\x0c
+    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
+/.+A/<crlf>
+    \r\nA
+    
+/\nA/<crlf>
+    \r\nA 
+
+/[\r\n]A/<crlf>
+    \r\nA 
+
+/(\r|\n)A/<crlf>
+    \r\nA 
+
+/a\Rb/I<bsr_anycrlf>
+    a\rb
+    a\nb
+    a\r\nb
+    ** Failers
+    a\x85b
+    a\x0bb     
+
+/a\Rb/I<bsr_unicode>
+    a\rb
+    a\nb
+    a\r\nb
+    a\x85b
+    a\x0bb     
+    ** Failers 
+    a\x85b\<bsr_anycrlf>
+    a\x0bb\<bsr_anycrlf>
+    
+/a\R?b/I<bsr_anycrlf>
+    a\rb
+    a\nb
+    a\r\nb
+    ** Failers
+    a\x85b
+    a\x0bb     
+
+/a\R?b/I<bsr_unicode>
+    a\rb
+    a\nb
+    a\r\nb
+    a\x85b
+    a\x0bb     
+    ** Failers 
+    a\x85b\<bsr_anycrlf>
+    a\x0bb\<bsr_anycrlf>
+    
+/a\R{2,4}b/I<bsr_anycrlf>
+    a\r\n\nb
+    a\n\r\rb
+    a\r\n\r\n\r\n\r\nb
+    ** Failers
+    a\x85\85b
+    a\x0b\0bb     
+
+/a\R{2,4}b/I<bsr_unicode>
+    a\r\rb
+    a\n\n\nb
+    a\r\n\n\r\rb
+    a\x85\85b
+    a\x0b\0bb     
+    ** Failers 
+    a\r\r\r\r\rb 
+    a\x85\85b\<bsr_anycrlf>
+    a\x0b\0bb\<bsr_anycrlf>
+    
+/a(?!)|\wbc/
+    abc 
+
+/a[]b/<JS>
+    ** Failers
+    ab
+
+/a[]+b/<JS>
+    ** Failers
+    ab 
+
+/a[]*+b/<JS>
+    ** Failers
+    ab 
+
+/a[^]b/<JS>
+    aXb
+    a\nb 
+    ** Failers
+    ab  
+    
+/a[^]+b/<JS> 
+    aXb
+    a\nX\nXb 
+    ** Failers
+    ab  
+
+/ End of testinput7 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput8	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,670 @@
+/-- Do not use the \x{} construct except with patterns that have the --/
+/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
+/-- that option is set. However, the latest Perls recognize them always. --/
+
+/\x{100}ab/8
+  \x{100}ab
+  
+/a\x{100}*b/8
+    ab
+    a\x{100}b  
+    a\x{100}\x{100}b  
+    
+/a\x{100}+b/8
+    a\x{100}b  
+    a\x{100}\x{100}b  
+    *** Failers 
+    ab
+     
+/\bX/8
+    Xoanon
+    +Xoanon
+    \x{300}Xoanon 
+    *** Failers 
+    YXoanon  
+    
+/\BX/8
+    YXoanon
+    *** Failers
+    Xoanon
+    +Xoanon    
+    \x{300}Xoanon 
+
+/X\b/8
+    X+oanon
+    ZX\x{300}oanon 
+    FAX 
+    *** Failers 
+    Xoanon  
+    
+/X\B/8
+    Xoanon  
+    *** Failers
+    X+oanon
+    ZX\x{300}oanon 
+    FAX 
+    
+/[^a]/8
+    abcd
+    a\x{100}   
+
+/^[abc\x{123}\x{400}-\x{402}]{2,3}\d/8
+    ab99
+    \x{123}\x{123}45
+    \x{400}\x{401}\x{402}6  
+    *** Failers
+    d99
+    \x{123}\x{122}4   
+    \x{400}\x{403}6  
+    \x{400}\x{401}\x{402}\x{402}6  
+
+/abc/8
+    Ã]
+    Ã
+    ÃÃÃ
+    ÃÃÃ\?
+
+/a.b/8
+    acb
+    a\x7fb
+    a\x{100}b 
+    *** Failers
+    a\nb  
+
+/a(.{3})b/8
+    a\x{4000}xyb 
+    a\x{4000}\x7fyb 
+    a\x{4000}\x{100}yb 
+    *** Failers
+    a\x{4000}b 
+    ac\ncb 
+
+/a(.*?)(.)/
+    a\xc0\x88b
+
+/a(.*?)(.)/8
+    a\x{100}b
+
+/a(.*)(.)/
+    a\xc0\x88b
+
+/a(.*)(.)/8
+    a\x{100}b
+
+/a(.)(.)/
+    a\xc0\x92bcd
+
+/a(.)(.)/8
+    a\x{240}bcd
+
+/a(.?)(.)/
+    a\xc0\x92bcd
+
+/a(.?)(.)/8
+    a\x{240}bcd
+
+/a(.??)(.)/
+    a\xc0\x92bcd
+
+/a(.??)(.)/8
+    a\x{240}bcd
+
+/a(.{3})b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    *** Failers
+    a\x{1234}b 
+    ac\ncb 
+
+/a(.{3,})b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    axxxxbcdefghijb 
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+    *** Failers
+    a\x{1234}b 
+
+/a(.{3,}?)b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    axxxxbcdefghijb 
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+    *** Failers
+    a\x{1234}b 
+
+/a(.{3,5})b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    axxxxbcdefghijb 
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+    axbxxbcdefghijb 
+    axxxxxbcdefghijb 
+    *** Failers
+    a\x{1234}b 
+    axxxxxxbcdefghijb 
+
+/a(.{3,5}?)b/8
+    a\x{1234}xyb 
+    a\x{1234}\x{4321}yb 
+    a\x{1234}\x{4321}\x{3412}b 
+    axxxxbcdefghijb 
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+    axbxxbcdefghijb 
+    axxxxxbcdefghijb 
+    *** Failers
+    a\x{1234}b 
+    axxxxxxbcdefghijb 
+
+/^[a\x{c0}]/8
+    *** Failers
+    \x{100}
+
+/(?<=aXb)cd/8
+    aXbcd
+
+/(?<=a\x{100}b)cd/8
+    a\x{100}bcd
+
+/(?<=a\x{100000}b)cd/8
+    a\x{100000}bcd
+    
+/(?:\x{100}){3}b/8
+    \x{100}\x{100}\x{100}b
+    *** Failers 
+    \x{100}\x{100}b
+
+/\x{ab}/8
+    \x{ab} 
+    \xc2\xab
+    *** Failers 
+    \x00{ab}
+
+/(?<=(.))X/8
+    WXYZ
+    \x{256}XYZ 
+    *** Failers
+    XYZ 
+
+/[^a]+/8g
+    bcd
+    \x{100}aY\x{256}Z 
+    
+/^[^a]{2}/8
+    \x{100}bc
+ 
+/^[^a]{2,}/8
+    \x{100}bcAa
+
+/^[^a]{2,}?/8
+    \x{100}bca
+
+/[^a]+/8ig
+    bcd
+    \x{100}aY\x{256}Z 
+    
+/^[^a]{2}/8i
+    \x{100}bc
+ 
+/^[^a]{2,}/8i
+    \x{100}bcAa
+
+/^[^a]{2,}?/8i
+    \x{100}bca
+
+/\x{100}{0,0}/8
+    abcd
+ 
+/\x{100}?/8
+    abcd
+    \x{100}\x{100} 
+
+/\x{100}{0,3}/8 
+    \x{100}\x{100} 
+    \x{100}\x{100}\x{100}\x{100} 
+    
+/\x{100}*/8
+    abce
+    \x{100}\x{100}\x{100}\x{100} 
+
+/\x{100}{1,1}/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+
+/\x{100}{1,3}/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+
+/\x{100}+/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+
+/\x{100}{3}/8
+    abcd\x{100}\x{100}\x{100}XX
+
+/\x{100}{3,5}/8
+    abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+
+/\x{100}{3,}/8
+    abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+
+/(?<=a\x{100}{2}b)X/8
+    Xyyya\x{100}\x{100}bXzzz
+
+/\D*/8
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\D*/8
+  \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+
+/\D/8
+    1X2
+    1\x{100}2 
+  
+/>\S/8
+    > >X Y
+    > >\x{100} Y
+  
+/\d/8
+    \x{100}3
+    
+/\s/8
+    \x{100} X
+    
+/\D+/8
+    12abcd34
+    *** Failers
+    1234  
+
+/\D{2,3}/8
+    12abcd34
+    12ab34
+    *** Failers  
+    1234
+    12a34  
+
+/\D{2,3}?/8
+    12abcd34
+    12ab34
+    *** Failers  
+    1234
+    12a34  
+
+/\d+/8
+    12abcd34
+    *** Failers
+
+/\d{2,3}/8
+    12abcd34
+    1234abcd
+    *** Failers  
+    1.4 
+
+/\d{2,3}?/8
+    12abcd34
+    1234abcd
+    *** Failers  
+    1.4 
+
+/\S+/8
+    12abcd34
+    *** Failers
+    \    \ 
+
+/\S{2,3}/8
+    12abcd34
+    1234abcd
+    *** Failers
+    \     \  
+
+/\S{2,3}?/8
+    12abcd34
+    1234abcd
+    *** Failers
+    \     \  
+
+/>\s+</8
+    12>      <34
+    *** Failers
+
+/>\s{2,3}</8
+    ab>  <cd
+    ab>   <ce
+    *** Failers
+    ab>    <cd 
+
+/>\s{2,3}?</8
+    ab>  <cd
+    ab>   <ce
+    *** Failers
+    ab>    <cd 
+
+/\w+/8
+    12      34
+    *** Failers
+    +++=*! 
+
+/\w{2,3}/8
+    ab  cd
+    abcd ce
+    *** Failers
+    a.b.c
+
+/\w{2,3}?/8
+    ab  cd
+    abcd ce
+    *** Failers
+    a.b.c
+
+/\W+/8
+    12====34
+    *** Failers
+    abcd 
+
+/\W{2,3}/8
+    ab====cd
+    ab==cd
+    *** Failers
+    a.b.c
+
+/\W{2,3}?/8
+    ab====cd
+    ab==cd
+    *** Failers
+    a.b.c
+
+/[\x{100}]/8
+    \x{100}
+    Z\x{100}
+    \x{100}Z
+    *** Failers 
+
+/[Z\x{100}]/8
+    Z\x{100}
+    \x{100}
+    \x{100}Z
+    *** Failers 
+
+/[\x{100}\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   *** Failers  
+
+/[\x{100}-\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{111}cd 
+   *** Failers  
+
+/[z-\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{111}cd 
+   abzcd
+   ab|cd  
+   *** Failers  
+
+/[Q\x{100}\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   Q? 
+   *** Failers  
+
+/[Q\x{100}-\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{111}cd 
+   Q? 
+   *** Failers  
+
+/[Qz-\x{200}]/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{111}cd 
+   abzcd
+   ab|cd  
+   Q? 
+   *** Failers  
+
+/[\x{100}\x{200}]{1,3}/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{200}\x{100}\x{200}\x{100}cd
+   *** Failers  
+
+/[\x{100}\x{200}]{1,3}?/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{200}\x{100}\x{200}\x{100}cd
+   *** Failers  
+
+/[Q\x{100}\x{200}]{1,3}/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{200}\x{100}\x{200}\x{100}cd
+   *** Failers  
+
+/[Q\x{100}\x{200}]{1,3}?/8
+   ab\x{100}cd
+   ab\x{200}cd
+   ab\x{200}\x{100}\x{200}\x{100}cd
+   *** Failers  
+
+/(?<=[\x{100}\x{200}])X/8
+    abc\x{200}X
+    abc\x{100}X 
+    *** Failers
+    X  
+
+/(?<=[Q\x{100}\x{200}])X/8
+    abc\x{200}X
+    abc\x{100}X 
+    abQX 
+    *** Failers
+    X  
+
+/(?<=[\x{100}\x{200}]{3})X/8
+    abc\x{100}\x{200}\x{100}X
+    *** Failers
+    abc\x{200}X
+    X  
+
+/[^\x{100}\x{200}]X/8
+    AX
+    \x{150}X
+    \x{500}X 
+    *** Failers
+    \x{100}X
+    \x{200}X   
+
+/[^Q\x{100}\x{200}]X/8
+    AX
+    \x{150}X
+    \x{500}X 
+    *** Failers
+    \x{100}X
+    \x{200}X   
+    QX 
+
+/[^\x{100}-\x{200}]X/8
+    AX
+    \x{500}X 
+    *** Failers
+    \x{100}X
+    \x{150}X
+    \x{200}X   
+
+/[z-\x{100}]/8i
+    z
+    Z 
+    \x{100}
+    *** Failers
+    \x{102}
+    y    
+
+/[\xFF]/
+    >\xff<
+
+/[\xff]/8
+    >\x{ff}<
+
+/[^\xFF]/
+    XYZ
+
+/[^\xff]/8
+    XYZ
+    \x{123} 
+
+/^[ac]*b/8
+  xb
+
+/^[ac\x{100}]*b/8
+  xb
+
+/^[^x]*b/8i
+  xb
+
+/^[^x]*b/8
+  xb
+  
+/^\d*b/8
+  xb 
+
+/(|a)/g8
+    catac
+    a\x{256}a 
+
+/^\x{85}$/8i
+    \x{85}
+
+/^abc./mgx8<any>
+    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x{0085}abc7 \x{2028}abc8 \x{2029}abc9 JUNK
+
+/abc.$/mgx8<any>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x{0085} abc7\x{2028} abc8\x{2029} abc9
+
+/^a\Rb/8<bsr_unicode>
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0cb
+    a\x{85}b   
+    a\x{2028}b 
+    a\x{2029}b 
+    ** Failers
+    a\n\rb    
+
+/^a\R*b/8<bsr_unicode>
+    ab
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0c\x{2028}\x{2029}b
+    a\x{85}b   
+    a\n\rb    
+    a\n\r\x{85}\x0cb 
+
+/^a\R+b/8<bsr_unicode>
+    a\nb
+    a\rb
+    a\r\nb
+    a\x0bb
+    a\x0c\x{2028}\x{2029}b
+    a\x{85}b   
+    a\n\rb    
+    a\n\r\x{85}\x0cb 
+    ** Failers
+    ab  
+
+/^a\R{1,3}b/8<bsr_unicode>
+    a\nb
+    a\n\rb
+    a\n\r\x{85}b
+    a\r\n\r\nb 
+    a\r\n\r\n\r\nb 
+    a\n\r\n\rb
+    a\n\n\r\nb 
+    ** Failers
+    a\n\n\n\rb
+    a\r
+
+/\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+
+/\V?\v{3,4}/8 
+    \x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+
+/\h+\V?\v{3,4}/8
+    >\x09\x20\x{a0}X\x0a\x0a\x0a<
+
+/\V?\v{3,4}/8
+    >\x09\x20\x{a0}X\x0a\x0a\x0a<
+
+/\H\h\V\v/8
+    X X\x0a
+    X\x09X\x0b
+    ** Failers
+    \x{a0} X\x0a   
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+    \x09\x20\x{a0}\x0a\x0b\x0c
+    ** Failers 
+    \x09\x20\x{a0}\x0a\x0b
+     
+/\H\h\V\v/8
+    \x{3001}\x{3000}\x{2030}\x{2028}
+    X\x{180e}X\x{85}
+    ** Failers
+    \x{2009} X\x0a   
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+    \x09\x20\x{202f}\x0a\x0b\x0c
+    ** Failers 
+    \x09\x{200a}\x{a0}\x{2028}\x0b
+     
+/a\Rb/I8<bsr_anycrlf>
+    a\rb
+    a\nb
+    a\r\nb
+    ** Failers
+    a\x{85}b
+    a\x0bb     
+
+/a\Rb/I8<bsr_unicode>
+    a\rb
+    a\nb
+    a\r\nb
+    a\x{85}b
+    a\x0bb     
+    ** Failers 
+    a\x{85}b\<bsr_anycrlf>
+    a\x0bb\<bsr_anycrlf>
+    
+/a\R?b/I8<bsr_anycrlf>
+    a\rb
+    a\nb
+    a\r\nb
+    ** Failers
+    a\x{85}b
+    a\x0bb     
+
+/a\R?b/I8<bsr_unicode>
+    a\rb
+    a\nb
+    a\r\nb
+    a\x{85}b
+    a\x0bb     
+    ** Failers 
+    a\x{85}b\<bsr_anycrlf>
+    a\x0bb\<bsr_anycrlf>
+ 
+/X/8f<any> 
+    A\x{1ec5}ABCXYZ
+
+/ End of testinput 8 / 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testinput9	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,846 @@
+/\pL\P{Nd}/8
+    AB
+    *** Failers
+    A0
+    00   
+
+/\X./8
+    AB
+    A\x{300}BC 
+    A\x{300}\x{301}\x{302}BC 
+    *** Failers
+    \x{300}  
+
+/\X\X/8
+    ABC
+    A\x{300}B\x{300}\x{301}C 
+    A\x{300}\x{301}\x{302}BC 
+    *** Failers
+    \x{300}  
+
+/^\pL+/8
+    abcd
+    a 
+    *** Failers 
+
+/^\PL+/8
+    1234
+    = 
+    *** Failers 
+    abcd 
+
+/^\X+/8
+    abcdA\x{300}\x{301}\x{302}
+    A\x{300}\x{301}\x{302}
+    A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}
+    a 
+    *** Failers 
+    \x{300}\x{301}\x{302}
+
+/\X?abc/8
+    abc
+    A\x{300}abc
+    A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abcxyz
+    \x{300}abc  
+    *** Failers
+
+/^\X?abc/8
+    abc
+    A\x{300}abc
+    *** Failers
+    A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abcxyz
+    \x{300}abc  
+
+/\X*abc/8
+    abc
+    A\x{300}abc
+    A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abcxyz
+    \x{300}abc  
+    *** Failers
+
+/^\X*abc/8
+    abc
+    A\x{300}abc
+    A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abcxyz
+    *** Failers
+    \x{300}abc  
+
+/^\pL?=./8
+    A=b
+    =c 
+    *** Failers
+    1=2 
+    AAAA=b  
+
+/^\pL*=./8
+    AAAA=b
+    =c 
+    *** Failers
+    1=2  
+
+/^\X{2,3}X/8
+    A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}X
+    A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}X 
+    *** Failers
+    X
+    A\x{300}\x{301}\x{302}X
+    A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}X
+
+/^\pC\pL\pM\pN\pP\pS\pZ</8
+    \x7f\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
+    \np\x{300}9!\$ < 
+    ** Failers 
+    ap\x{300}9!\$ < 
+  
+/^\PC/8
+    X
+    ** Failers 
+    \x7f
+  
+/^\PL/8
+    9
+    ** Failers 
+    \x{c0}
+  
+/^\PM/8
+    X
+    ** Failers 
+    \x{30f}
+  
+/^\PN/8
+    X
+    ** Failers 
+    \x{660}
+  
+/^\PP/8
+    X
+    ** Failers 
+    \x{66c}
+  
+/^\PS/8
+    X
+    ** Failers 
+    \x{f01}
+  
+/^\PZ/8
+    X
+    ** Failers 
+    \x{1680}
+    
+/^\p{Cc}/8
+    \x{017}
+    \x{09f} 
+    ** Failers
+    \x{0600} 
+  
+/^\p{Cf}/8
+    \x{601}
+    ** Failers
+    \x{09f} 
+  
+/^\p{Cn}/8
+    ** Failers
+    \x{09f} 
+  
+/^\p{Co}/8
+    \x{f8ff}
+    ** Failers
+    \x{09f} 
+  
+/^\p{Cs}/8
+    \?\x{dfff}
+    ** Failers
+    \x{09f} 
+  
+/^\p{Ll}/8
+    a
+    ** Failers 
+    Z
+    \x{e000}  
+  
+/^\p{Lm}/8
+    \x{2b0}
+    ** Failers
+    a 
+  
+/^\p{Lo}/8
+    \x{1bb}
+    ** Failers
+    a 
+    \x{2b0}
+  
+/^\p{Lt}/8
+    \x{1c5}
+    ** Failers
+    a 
+    \x{2b0}
+  
+/^\p{Lu}/8
+    A
+    ** Failers
+    \x{2b0}
+  
+/^\p{Mc}/8
+    \x{903}
+    ** Failers
+    X
+    \x{300}
+       
+/^\p{Me}/8
+    \x{488}
+    ** Failers
+    X
+    \x{903}
+    \x{300}
+  
+/^\p{Mn}/8
+    \x{300}
+    ** Failers
+    X
+    \x{903}
+  
+/^\p{Nd}+/8
+    0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}\x{667}\x{668}\x{669}\x{66a}
+    \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}\x{6f7}\x{6f8}\x{6f9}\x{6fa}
+    \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}\x{96d}\x{96e}\x{96f}\x{970}
+    ** Failers
+    X
+  
+/^\p{Nl}/8
+    \x{16ee}
+    ** Failers
+    X
+    \x{966}
+  
+/^\p{No}/8
+    \x{b2}
+    \x{b3}
+    ** Failers
+    X
+    \x{16ee}
+  
+/^\p{Pc}/8
+    \x5f
+    \x{203f}
+    ** Failers
+    X
+    -
+    \x{58a}
+  
+/^\p{Pd}/8
+    -
+    \x{58a}
+    ** Failers
+    X
+    \x{203f}
+  
+/^\p{Pe}/8
+    )
+    ]
+    }
+    \x{f3b}
+    ** Failers
+    X
+    \x{203f}
+    (
+    [
+    {
+    \x{f3c}
+  
+/^\p{Pf}/8
+    \x{bb}
+    \x{2019}
+    ** Failers
+    X
+    \x{203f}
+  
+/^\p{Pi}/8
+    \x{ab}
+    \x{2018}
+    ** Failers
+    X
+    \x{203f}
+  
+/^\p{Po}/8
+    !
+    \x{37e}
+    ** Failers
+    X
+    \x{203f}
+  
+/^\p{Ps}/8
+    (
+    [
+    {
+    \x{f3c}
+    ** Failers
+    X
+    )
+    ]
+    }
+    \x{f3b}
+  
+/^\p{Sc}+/8
+    $\x{a2}\x{a3}\x{a4}\x{a5}\x{a6}
+    \x{9f2}
+    ** Failers
+    X
+    \x{2c2}
+  
+/^\p{Sk}/8
+    \x{2c2}
+    ** Failers
+    X
+    \x{9f2}
+  
+/^\p{Sm}+/8
+    +<|~\x{ac}\x{2044}
+    ** Failers
+    X
+    \x{9f2}
+  
+/^\p{So}/8
+    \x{a6}
+    \x{482} 
+    ** Failers
+    X
+    \x{9f2}
+  
+/^\p{Zl}/8
+    \x{2028}
+    ** Failers
+    X
+    \x{2029}
+  
+/^\p{Zp}/8
+    \x{2029}
+    ** Failers
+    X
+    \x{2028}
+  
+/^\p{Zs}/8
+    \ \
+    \x{a0}
+    \x{1680}
+    \x{180e}
+    \x{2000}
+    \x{2001}     
+    ** Failers
+    \x{2028}
+    \x{200d} 
+  
+/\p{Nd}+(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}+?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2,}(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2,}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2}(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2,3}(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}{2,3}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}??(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*+(..)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*+(...)/8
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*+(....)/8
+      ** Failers
+      \x{660}\x{661}\x{662}ABC
+  
+/\p{Lu}/8i
+    A
+    a\x{10a0}B 
+    ** Failers 
+    a
+    \x{1d00}  
+
+/\p{^Lu}/8i
+    1234
+    ** Failers
+    ABC 
+
+/\P{Lu}/8i
+    1234
+    ** Failers
+    ABC 
+
+/(?<=A\p{Nd})XYZ/8
+    A2XYZ
+    123A5XYZPQR
+    ABA\x{660}XYZpqr
+    ** Failers
+    AXYZ
+    XYZ     
+    
+/(?<!\pL)XYZ/8
+    1XYZ
+    AB=XYZ.. 
+    XYZ 
+    ** Failers
+    WXYZ 
+
+/[\p{Nd}]/8
+    1234
+
+/[\p{Nd}+-]+/8
+    1234
+    12-34
+    12+\x{661}-34  
+    ** Failers
+    abcd  
+
+/[\P{Nd}]+/8
+    abcd
+    ** Failers
+    1234
+
+/\D+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+     
+/\P{Nd}+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\D]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\P{Nd}]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\D\P{Nd}]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\pL/8
+    a
+    A 
+
+/\pL/8i
+    a
+    A 
+    
+/\p{Lu}/8 
+    A
+    aZ
+    ** Failers
+    abc   
+
+/\p{Lu}/8i
+    A
+    aZ
+    ** Failers
+    abc   
+
+/\p{Ll}/8 
+    a
+    Az
+    ** Failers
+    ABC   
+
+/\p{Ll}/8i 
+    a
+    Az
+    ** Failers
+    ABC   
+
+/^\x{c0}$/8i
+    \x{c0}
+    \x{e0} 
+
+/^\x{e0}$/8i
+    \x{c0}
+    \x{e0} 
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8
+    A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    ** Failers
+    a\x{391}\x{10427}\x{ff3a}\x{1fb0}   
+    A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+    A\x{391}\x{1044F}\x{ff3a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8i
+    A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    a\x{391}\x{10427}\x{ff3a}\x{1fb0}   
+    A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+    A\x{391}\x{1044F}\x{ff3a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+
+/\x{391}+/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
+
+/\x{391}{3,5}(.)/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+
+/\x{391}{3,5}?(.)/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+
+/[\x{391}\x{ff3a}]/8i
+    \x{391}
+    \x{ff3a}
+    \x{3b1}
+    \x{ff5a}   
+    
+/[\x{c0}\x{391}]/8i
+    \x{c0}
+    \x{e0} 
+
+/[\x{105}-\x{109}]/8i
+    \x{104}
+    \x{105}
+    \x{109}  
+    ** Failers
+    \x{100}
+    \x{10a} 
+    
+/[z-\x{100}]/8i 
+    Z
+    z
+    \x{39c}
+    \x{178}
+    |
+    \x{80}
+    \x{ff}
+    \x{100}
+    \x{101} 
+    ** Failers
+    \x{102}
+    Y
+    y           
+
+/[z-\x{100}]/8i
+
+/^\X/8
+    A
+    A\x{300}BC 
+    A\x{300}\x{301}\x{302}BC 
+    *** Failers
+    \x{300}  
+
+/^[\X]/8
+    X123
+    *** Failers
+    AXYZ
+
+/^(\X*)C/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+
+/^(\X*?)C/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+
+/^(\X*)(.)/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+
+/^(\X*?)(.)/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+
+/^\X(.)/8
+    *** Failers
+    A\x{300}\x{301}\x{302}
+
+/^\X{2,3}(.)/8
+    A\x{300}\x{301}B\x{300}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}DA\x{300}X
+    
+/^\X{2,3}?(.)/8
+    A\x{300}\x{301}B\x{300}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}DA\x{300}X
+
+/^\pN{2,3}X/
+    12X
+    123X
+    *** Failers
+    X
+    1X
+    1234X     
+
+/\x{100}/i8
+    \x{100}   
+    \x{101} 
+    
+/^\p{Han}+/8
+    \x{2e81}\x{3007}\x{2f804}\x{31a0}
+    ** Failers
+    \x{2e7f}  
+
+/^\P{Katakana}+/8
+    \x{3105}
+    ** Failers
+    \x{30ff}  
+
+/^[\p{Arabic}]/8
+    \x{06e9}
+    \x{060b}
+    ** Failers
+    X\x{06e9}   
+
+/^[\P{Yi}]/8
+    \x{2f800}
+    ** Failers
+    \x{a014}
+    \x{a4c6}   
+
+/^\p{Any}X/8
+    AXYZ
+    \x{1234}XYZ 
+    ** Failers
+    X  
+    
+/^\P{Any}X/8
+    ** Failers
+    AX
+    
+/^\p{Any}?X/8
+    XYZ
+    AXYZ
+    \x{1234}XYZ 
+    ** Failers
+    ABXYZ   
+
+/^\P{Any}?X/8
+    XYZ
+    ** Failers
+    AXYZ
+    \x{1234}XYZ 
+    ABXYZ   
+
+/^\p{Any}+X/8
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    ** Failers
+    XYZ
+
+/^\P{Any}+X/8
+    ** Failers
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    XYZ
+
+/^\p{Any}*X/8
+    XYZ
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    ** Failers
+
+/^\P{Any}*X/8
+    XYZ
+    ** Failers
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+
+/^[\p{Any}]X/8
+    AXYZ
+    \x{1234}XYZ 
+    ** Failers
+    X  
+    
+/^[\P{Any}]X/8
+    ** Failers
+    AX
+    
+/^[\p{Any}]?X/8
+    XYZ
+    AXYZ
+    \x{1234}XYZ 
+    ** Failers
+    ABXYZ   
+
+/^[\P{Any}]?X/8
+    XYZ
+    ** Failers
+    AXYZ
+    \x{1234}XYZ 
+    ABXYZ   
+
+/^[\p{Any}]+X/8
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    ** Failers
+    XYZ
+
+/^[\P{Any}]+X/8
+    ** Failers
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    XYZ
+
+/^[\p{Any}]*X/8
+    XYZ
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+    ** Failers
+
+/^[\P{Any}]*X/8
+    XYZ
+    ** Failers
+    AXYZ
+    \x{1234}XYZ
+    A\x{1234}XYZ
+
+/^\p{Any}{3,5}?/8
+    abcdefgh
+    \x{1234}\n\r\x{3456}xyz 
+
+/^\p{Any}{3,5}/8
+    abcdefgh
+    \x{1234}\n\r\x{3456}xyz 
+
+/^\P{Any}{3,5}?/8
+    ** Failers
+    abcdefgh
+    \x{1234}\n\r\x{3456}xyz 
+
+/^\p{L&}X/8
+     AXY
+     aXY
+     \x{1c5}XY
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^[\p{L&}]X/8
+     AXY
+     aXY
+     \x{1c5}XY
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^\p{L&}+X/8
+     AXY
+     aXY
+     AbcdeXyz 
+     \x{1c5}AbXY
+     abcDEXypqreXlmn 
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^[\p{L&}]+X/8
+     AXY
+     aXY
+     AbcdeXyz 
+     \x{1c5}AbXY
+     abcDEXypqreXlmn 
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^\p{L&}+?X/8
+     AXY
+     aXY
+     AbcdeXyz 
+     \x{1c5}AbXY
+     abcDEXypqreXlmn 
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^[\p{L&}]+?X/8
+     AXY
+     aXY
+     AbcdeXyz 
+     \x{1c5}AbXY
+     abcDEXypqreXlmn 
+     ** Failers
+     \x{1bb}XY
+     \x{2b0}XY
+     !XY      
+
+/^\P{L&}X/8
+     !XY
+     \x{1bb}XY
+     \x{2b0}XY
+     ** Failers
+     \x{1c5}XY
+     AXY      
+
+/^[\P{L&}]X/8
+     !XY
+     \x{1bb}XY
+     \x{2b0}XY
+     ** Failers
+     \x{1c5}XY
+     AXY      
+
+/^\x{023a}+?(\x{0130}+)/8i
+  \x{023a}\x{2c65}\x{0130}
+  
+/^\x{023a}+([^X])/8i
+  \x{023a}\x{2c65}X
+ 
+/\x{c0}+\x{116}+/8i
+    \x{c0}\x{e0}\x{116}\x{117}
+
+/[\x{c0}\x{116}]+/8i
+    \x{c0}\x{e0}\x{116}\x{117}
+
+/Check property support in non-UTF-8 mode/
+ 
+/\p{L}{4}/
+    123abcdefg
+    123abc\xc4\xc5zz
+
+/\p{Carian}\p{Cham}\p{Kayah_Li}\p{Lepcha}\p{Lycian}\p{Lydian}\p{Ol_Chiki}\p{Rejang}\p{Saurashtra}\p{Sundanese}\p{Vai}/8
+    \x{102A4}\x{AA52}\x{A91D}\x{1C46}\x{10283}\x{1092E}\x{1C6B}\x{A93B}\x{A8BF}\x{1BA0}\x{A50A}====
+
+/\x{a77d}\x{1d79}/8i
+    \x{a77d}\x{1d79}
+    \x{1d79}\x{a77d} 
+
+/\x{a77d}\x{1d79}/8
+    \x{a77d}\x{1d79}
+    ** Failers 
+    \x{1d79}\x{a77d} 
+
+/ End / 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput1	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,6612 @@
+/the quick brown fox/
+    the quick brown fox
+ 0: the quick brown fox
+    The quick brown FOX
+No match
+    What do you know about the quick brown fox?
+ 0: the quick brown fox
+    What do you know about THE QUICK BROWN FOX?
+No match
+
+/The quick brown fox/i
+    the quick brown fox
+ 0: the quick brown fox
+    The quick brown FOX
+ 0: The quick brown FOX
+    What do you know about the quick brown fox?
+ 0: the quick brown fox
+    What do you know about THE QUICK BROWN FOX?
+ 0: THE QUICK BROWN FOX
+
+/abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
+    abcd\t\n\r\f\a\e9;\$\\?caxyz
+ 0: abcd\x09\x0a\x0d\x0c\x07\x1b9;$\?caxyz
+
+/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
+    abxyzpqrrrabbxyyyypqAzz
+ 0: abxyzpqrrrabbxyyyypqAzz
+    abxyzpqrrrabbxyyyypqAzz
+ 0: abxyzpqrrrabbxyyyypqAzz
+    aabxyzpqrrrabbxyyyypqAzz
+ 0: aabxyzpqrrrabbxyyyypqAzz
+    aaabxyzpqrrrabbxyyyypqAzz
+ 0: aaabxyzpqrrrabbxyyyypqAzz
+    aaaabxyzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzpqrrrabbxyyyypqAzz
+    abcxyzpqrrrabbxyyyypqAzz
+ 0: abcxyzpqrrrabbxyyyypqAzz
+    aabcxyzpqrrrabbxyyyypqAzz
+ 0: aabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypAzz
+ 0: aaabcxyzpqrrrabbxyyyypAzz
+    aaabcxyzpqrrrabbxyyyypqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqqqAzz
+    aaaabcxyzpqrrrabbxyyyypqAzz
+ 0: aaaabcxyzpqrrrabbxyyyypqAzz
+    abxyzzpqrrrabbxyyyypqAzz
+ 0: abxyzzpqrrrabbxyyyypqAzz
+    aabxyzzzpqrrrabbxyyyypqAzz
+ 0: aabxyzzzpqrrrabbxyyyypqAzz
+    aaabxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaabxyzzzzpqrrrabbxyyyypqAzz
+    aaaabxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzzzzpqrrrabbxyyyypqAzz
+    abcxyzzpqrrrabbxyyyypqAzz
+ 0: abcxyzzpqrrrabbxyyyypqAzz
+    aabcxyzzzpqrrrabbxyyyypqAzz
+ 0: aabcxyzzzpqrrrabbxyyyypqAzz
+    aaabcxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypABzz
+ 0: aaabcxyzpqrrrabbxyyyypABzz
+    aaabcxyzpqrrrabbxyyyypABBzz
+ 0: aaabcxyzpqrrrabbxyyyypABBzz
+    >>>aaabxyzpqrrrabbxyyyypqAzz
+ 0: aaabxyzpqrrrabbxyyyypqAzz
+    >aaaabxyzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzpqrrrabbxyyyypqAzz
+    >>>>abcxyzpqrrrabbxyyyypqAzz
+ 0: abcxyzpqrrrabbxyyyypqAzz
+    *** Failers
+No match
+    abxyzpqrrabbxyyyypqAzz
+No match
+    abxyzpqrrrrabbxyyyypqAzz
+No match
+    abxyzpqrrrabxyyyypqAzz
+No match
+    aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
+No match
+    aaaabcxyzzzzpqrrrabbbxyyypqAzz
+No match
+    aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
+No match
+
+/^(abc){1,2}zz/
+    abczz
+ 0: abczz
+ 1: abc
+    abcabczz
+ 0: abcabczz
+ 1: abc
+    *** Failers
+No match
+    zz
+No match
+    abcabcabczz
+No match
+    >>abczz
+No match
+
+/^(b+?|a){1,2}?c/
+    bc
+ 0: bc
+ 1: b
+    bbc
+ 0: bbc
+ 1: b
+    bbbc
+ 0: bbbc
+ 1: bb
+    bac
+ 0: bac
+ 1: a
+    bbac
+ 0: bbac
+ 1: a
+    aac
+ 0: aac
+ 1: a
+    abbbbbbbbbbbc
+ 0: abbbbbbbbbbbc
+ 1: bbbbbbbbbbb
+    bbbbbbbbbbbac
+ 0: bbbbbbbbbbbac
+ 1: a
+    *** Failers
+No match
+    aaac
+No match
+    abbbbbbbbbbbac
+No match
+
+/^(b+|a){1,2}c/
+    bc
+ 0: bc
+ 1: b
+    bbc
+ 0: bbc
+ 1: bb
+    bbbc
+ 0: bbbc
+ 1: bbb
+    bac
+ 0: bac
+ 1: a
+    bbac
+ 0: bbac
+ 1: a
+    aac
+ 0: aac
+ 1: a
+    abbbbbbbbbbbc
+ 0: abbbbbbbbbbbc
+ 1: bbbbbbbbbbb
+    bbbbbbbbbbbac
+ 0: bbbbbbbbbbbac
+ 1: a
+    *** Failers
+No match
+    aaac
+No match
+    abbbbbbbbbbbac
+No match
+
+/^(b+|a){1,2}?bc/
+    bbc
+ 0: bbc
+ 1: b
+
+/^(b*|ba){1,2}?bc/
+    babc
+ 0: babc
+ 1: ba
+    bbabc
+ 0: bbabc
+ 1: ba
+    bababc
+ 0: bababc
+ 1: ba
+    *** Failers
+No match
+    bababbc
+No match
+    babababc
+No match
+
+/^(ba|b*){1,2}?bc/
+    babc
+ 0: babc
+ 1: ba
+    bbabc
+ 0: bbabc
+ 1: ba
+    bababc
+ 0: bababc
+ 1: ba
+    *** Failers
+No match
+    bababbc
+No match
+    babababc
+No match
+
+/^\ca\cA\c[\c{\c:/
+    \x01\x01\e;z
+ 0: \x01\x01\x1b;z
+
+/^[ab\]cde]/
+    athing
+ 0: a
+    bthing
+ 0: b
+    ]thing
+ 0: ]
+    cthing
+ 0: c
+    dthing
+ 0: d
+    ething
+ 0: e
+    *** Failers
+No match
+    fthing
+No match
+    [thing
+No match
+    \\thing
+No match
+
+/^[]cde]/
+    ]thing
+ 0: ]
+    cthing
+ 0: c
+    dthing
+ 0: d
+    ething
+ 0: e
+    *** Failers
+No match
+    athing
+No match
+    fthing
+No match
+
+/^[^ab\]cde]/
+    fthing
+ 0: f
+    [thing
+ 0: [
+    \\thing
+ 0: \
+    *** Failers
+ 0: *
+    athing
+No match
+    bthing
+No match
+    ]thing
+No match
+    cthing
+No match
+    dthing
+No match
+    ething
+No match
+
+/^[^]cde]/
+    athing
+ 0: a
+    fthing
+ 0: f
+    *** Failers
+ 0: *
+    ]thing
+No match
+    cthing
+No match
+    dthing
+No match
+    ething
+No match
+
+/^\/
+    
+ 0: \x81
+
+/^ÿ/
+    ÿ
+ 0: \xff
+
+/^[0-9]+$/
+    0
+ 0: 0
+    1
+ 0: 1
+    2
+ 0: 2
+    3
+ 0: 3
+    4
+ 0: 4
+    5
+ 0: 5
+    6
+ 0: 6
+    7
+ 0: 7
+    8
+ 0: 8
+    9
+ 0: 9
+    10
+ 0: 10
+    100
+ 0: 100
+    *** Failers
+No match
+    abc
+No match
+
+/^.*nter/
+    enter
+ 0: enter
+    inter
+ 0: inter
+    uponter
+ 0: uponter
+
+/^xxx[0-9]+$/
+    xxx0
+ 0: xxx0
+    xxx1234
+ 0: xxx1234
+    *** Failers
+No match
+    xxx
+No match
+
+/^.+[0-9][0-9][0-9]$/
+    x123
+ 0: x123
+    xx123
+ 0: xx123
+    123456
+ 0: 123456
+    *** Failers
+No match
+    123
+No match
+    x1234
+ 0: x1234
+
+/^.+?[0-9][0-9][0-9]$/
+    x123
+ 0: x123
+    xx123
+ 0: xx123
+    123456
+ 0: 123456
+    *** Failers
+No match
+    123
+No match
+    x1234
+ 0: x1234
+
+/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
+    abc!pqr=apquxz.ixr.zzz.ac.uk
+ 0: abc!pqr=apquxz.ixr.zzz.ac.uk
+ 1: abc
+ 2: pqr
+    *** Failers
+No match
+    !pqr=apquxz.ixr.zzz.ac.uk
+No match
+    abc!=apquxz.ixr.zzz.ac.uk
+No match
+    abc!pqr=apquxz:ixr.zzz.ac.uk
+No match
+    abc!pqr=apquxz.ixr.zzz.ac.ukk
+No match
+
+/:/
+    Well, we need a colon: somewhere
+ 0: :
+    *** Fail if we don't
+No match
+
+/([\da-f:]+)$/i
+    0abc
+ 0: 0abc
+ 1: 0abc
+    abc
+ 0: abc
+ 1: abc
+    fed
+ 0: fed
+ 1: fed
+    E
+ 0: E
+ 1: E
+    ::
+ 0: ::
+ 1: ::
+    5f03:12C0::932e
+ 0: 5f03:12C0::932e
+ 1: 5f03:12C0::932e
+    fed def
+ 0: def
+ 1: def
+    Any old stuff
+ 0: ff
+ 1: ff
+    *** Failers
+No match
+    0zzz
+No match
+    gzzz
+No match
+    fed\x20
+No match
+    Any old rubbish
+No match
+
+/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
+    .1.2.3
+ 0: .1.2.3
+ 1: 1
+ 2: 2
+ 3: 3
+    A.12.123.0
+ 0: A.12.123.0
+ 1: 12
+ 2: 123
+ 3: 0
+    *** Failers
+No match
+    .1.2.3333
+No match
+    1.2.3
+No match
+    1234.2.3
+No match
+
+/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
+    1 IN SOA non-sp1 non-sp2(
+ 0: 1 IN SOA non-sp1 non-sp2(
+ 1: 1
+ 2: non-sp1
+ 3: non-sp2
+    1    IN    SOA    non-sp1    non-sp2   (
+ 0: 1    IN    SOA    non-sp1    non-sp2   (
+ 1: 1
+ 2: non-sp1
+ 3: non-sp2
+    *** Failers
+No match
+    1IN SOA non-sp1 non-sp2(
+No match
+
+/^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
+    a.
+ 0: a.
+    Z.
+ 0: Z.
+    2.
+ 0: 2.
+    ab-c.pq-r.
+ 0: ab-c.pq-r.
+ 1: .pq-r
+    sxk.zzz.ac.uk.
+ 0: sxk.zzz.ac.uk.
+ 1: .uk
+    x-.y-.
+ 0: x-.y-.
+ 1: .y-
+    *** Failers
+No match
+    -abc.peq.
+No match
+
+/^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
+    *.a
+ 0: *.a
+    *.b0-a
+ 0: *.b0-a
+ 1: 0-a
+    *.c3-b.c
+ 0: *.c3-b.c
+ 1: 3-b
+ 2: .c
+    *.c-a.b-c
+ 0: *.c-a.b-c
+ 1: -a
+ 2: .b-c
+ 3: -c
+    *** Failers
+No match
+    *.0
+No match
+    *.a-
+No match
+    *.a-b.c-
+No match
+    *.c-a.0-c
+No match
+
+/^(?=ab(de))(abd)(e)/
+    abde
+ 0: abde
+ 1: de
+ 2: abd
+ 3: e
+
+/^(?!(ab)de|x)(abd)(f)/
+    abdf
+ 0: abdf
+ 1: <unset>
+ 2: abd
+ 3: f
+
+/^(?=(ab(cd)))(ab)/
+    abcd
+ 0: ab
+ 1: abcd
+ 2: cd
+ 3: ab
+
+/^[\da-f](\.[\da-f])*$/i
+    a.b.c.d
+ 0: a.b.c.d
+ 1: .d
+    A.B.C.D
+ 0: A.B.C.D
+ 1: .D
+    a.b.c.1.2.3.C
+ 0: a.b.c.1.2.3.C
+ 1: .C
+
+/^\".*\"\s*(;.*)?$/
+    \"1234\"
+ 0: "1234"
+    \"abcd\" ;
+ 0: "abcd" ;
+ 1: ;
+    \"\" ; rhubarb
+ 0: "" ; rhubarb
+ 1: ; rhubarb
+    *** Failers
+No match
+    \"1234\" : things
+No match
+
+/^$/
+    \
+ 0: 
+    *** Failers
+No match
+
+/   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/x
+    ab c
+ 0: ab c
+    *** Failers
+No match
+    abc
+No match
+    ab cde
+No match
+
+/(?x)   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/
+    ab c
+ 0: ab c
+    *** Failers
+No match
+    abc
+No match
+    ab cde
+No match
+
+/^   a\ b[c ]d       $/x
+    a bcd
+ 0: a bcd
+    a b d
+ 0: a b d
+    *** Failers
+No match
+    abcd
+No match
+    ab d
+No match
+
+/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
+    abcdefhijklm
+ 0: abcdefhijklm
+ 1: abc
+ 2: bc
+ 3: c
+ 4: def
+ 5: ef
+ 6: f
+ 7: hij
+ 8: ij
+ 9: j
+10: klm
+11: lm
+12: m
+
+/^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
+    abcdefhijklm
+ 0: abcdefhijklm
+ 1: bc
+ 2: c
+ 3: ef
+ 4: f
+ 5: ij
+ 6: j
+ 7: lm
+ 8: m
+
+/^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
+    a+ Z0+\x08\n\x1d\x12
+ 0: a+ Z0+\x08\x0a\x1d\x12
+
+/^[.^$|()*+?{,}]+/
+    .^\$(*+)|{?,?}
+ 0: .^$(*+)|{?,?}
+
+/^a*\w/
+    z
+ 0: z
+    az
+ 0: az
+    aaaz
+ 0: aaaz
+    a
+ 0: a
+    aa
+ 0: aa
+    aaaa
+ 0: aaaa
+    a+
+ 0: a
+    aa+
+ 0: aa
+
+/^a*?\w/
+    z
+ 0: z
+    az
+ 0: a
+    aaaz
+ 0: a
+    a
+ 0: a
+    aa
+ 0: a
+    aaaa
+ 0: a
+    a+
+ 0: a
+    aa+
+ 0: a
+
+/^a+\w/
+    az
+ 0: az
+    aaaz
+ 0: aaaz
+    aa
+ 0: aa
+    aaaa
+ 0: aaaa
+    aa+
+ 0: aa
+
+/^a+?\w/
+    az
+ 0: az
+    aaaz
+ 0: aa
+    aa
+ 0: aa
+    aaaa
+ 0: aa
+    aa+
+ 0: aa
+
+/^\d{8}\w{2,}/
+    1234567890
+ 0: 1234567890
+    12345678ab
+ 0: 12345678ab
+    12345678__
+ 0: 12345678__
+    *** Failers
+No match
+    1234567
+No match
+
+/^[aeiou\d]{4,5}$/
+    uoie
+ 0: uoie
+    1234
+ 0: 1234
+    12345
+ 0: 12345
+    aaaaa
+ 0: aaaaa
+    *** Failers
+No match
+    123456
+No match
+
+/^[aeiou\d]{4,5}?/
+    uoie
+ 0: uoie
+    1234
+ 0: 1234
+    12345
+ 0: 1234
+    aaaaa
+ 0: aaaa
+    123456
+ 0: 1234
+
+/\A(abc|def)=(\1){2,3}\Z/
+    abc=abcabc
+ 0: abc=abcabc
+ 1: abc
+ 2: abc
+    def=defdefdef
+ 0: def=defdefdef
+ 1: def
+ 2: def
+    *** Failers
+No match
+    abc=defdef
+No match
+
+/^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
+    abcdefghijkcda2
+ 0: abcdefghijkcda2
+ 1: a
+ 2: b
+ 3: c
+ 4: d
+ 5: e
+ 6: f
+ 7: g
+ 8: h
+ 9: i
+10: j
+11: k
+12: cd
+    abcdefghijkkkkcda2
+ 0: abcdefghijkkkkcda2
+ 1: a
+ 2: b
+ 3: c
+ 4: d
+ 5: e
+ 6: f
+ 7: g
+ 8: h
+ 9: i
+10: j
+11: k
+12: cd
+
+/(cat(a(ract|tonic)|erpillar)) \1()2(3)/
+    cataract cataract23
+ 0: cataract cataract23
+ 1: cataract
+ 2: aract
+ 3: ract
+ 4: 
+ 5: 3
+    catatonic catatonic23
+ 0: catatonic catatonic23
+ 1: catatonic
+ 2: atonic
+ 3: tonic
+ 4: 
+ 5: 3
+    caterpillar caterpillar23
+ 0: caterpillar caterpillar23
+ 1: caterpillar
+ 2: erpillar
+ 3: <unset>
+ 4: 
+ 5: 3
+
+
+/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
+    From abcd  Mon Sep 01 12:33:02 1997
+ 0: From abcd  Mon Sep 01 12:33
+ 1: abcd
+
+/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
+    From abcd  Mon Sep 01 12:33:02 1997
+ 0: From abcd  Mon Sep 01 12:33
+ 1: Sep 
+    From abcd  Mon Sep  1 12:33:02 1997
+ 0: From abcd  Mon Sep  1 12:33
+ 1: Sep  
+    *** Failers
+No match
+    From abcd  Sep 01 12:33:02 1997
+No match
+
+/^12.34/s
+    12\n34
+ 0: 12\x0a34
+    12\r34
+ 0: 12\x0d34
+
+/\w+(?=\t)/
+    the quick brown\t fox
+ 0: brown
+
+/foo(?!bar)(.*)/
+    foobar is foolish see?
+ 0: foolish see?
+ 1: lish see?
+
+/(?:(?!foo)...|^.{0,2})bar(.*)/
+    foobar crowbar etc
+ 0: rowbar etc
+ 1:  etc
+    barrel
+ 0: barrel
+ 1: rel
+    2barrel
+ 0: 2barrel
+ 1: rel
+    A barrel
+ 0: A barrel
+ 1: rel
+
+/^(\D*)(?=\d)(?!123)/
+    abc456
+ 0: abc
+ 1: abc
+    *** Failers
+No match
+    abc123
+No match
+
+/^1234(?# test newlines
+  inside)/
+    1234
+ 0: 1234
+
+/^1234 #comment in extended re
+  /x
+    1234
+ 0: 1234
+
+/#rhubarb
+  abcd/x
+    abcd
+ 0: abcd
+
+/^abcd#rhubarb/x
+    abcd
+ 0: abcd
+
+/^(a)\1{2,3}(.)/
+    aaab
+ 0: aaab
+ 1: a
+ 2: b
+    aaaab
+ 0: aaaab
+ 1: a
+ 2: b
+    aaaaab
+ 0: aaaaa
+ 1: a
+ 2: a
+    aaaaaab
+ 0: aaaaa
+ 1: a
+ 2: a
+
+/(?!^)abc/
+    the abc
+ 0: abc
+    *** Failers
+No match
+    abc
+No match
+
+/(?=^)abc/
+    abc
+ 0: abc
+    *** Failers
+No match
+    the abc
+No match
+
+/^[ab]{1,3}(ab*|b)/
+    aabbbbb
+ 0: aabb
+ 1: b
+
+/^[ab]{1,3}?(ab*|b)/
+    aabbbbb
+ 0: aabbbbb
+ 1: abbbbb
+
+/^[ab]{1,3}?(ab*?|b)/
+    aabbbbb
+ 0: aa
+ 1: a
+
+/^[ab]{1,3}(ab*?|b)/
+    aabbbbb
+ 0: aabb
+ 1: b
+
+/  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                          # optional leading comment
+(?:    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+# address
+|                     #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)             # one word, optionally followed by....
+(?:
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
+\(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)       |  # comments, or...
+
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+# quoted strings
+)*
+<  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                     # leading <
+(?:  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  ,  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+)* # further okay, if led by comma
+:                                # closing colon
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  )? #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+#       address spec
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  > #                  trailing >
+# name and address
+)  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                       # optional trailing comment
+/x
+    Alan Other <user\@dom.ain>
+ 0: Alan Other <user@dom.ain>
+    <user\@dom.ain>
+ 0: user@dom.ain
+    user\@dom.ain
+ 0: user@dom.ain
+    \"A. Other\" <user.1234\@dom.ain> (a comment)
+ 0: "A. Other" <user.1234@dom.ain> (a comment)
+    A. Other <user.1234\@dom.ain> (a comment)
+ 0:  Other <user.1234@dom.ain> (a comment)
+    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
+ 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
+    A missing angle <user\@some.where
+ 0: user@some.where
+    *** Failers
+No match
+    The quick brown fox
+No match
+
+/[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional leading comment
+(?:
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# additional words
+)*
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+# address
+|                             #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+# leading word
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *               # "normal" atoms and or spaces
+(?:
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+|
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+) # "special" comment or quoted string
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *            #  more "normal"
+)*
+<
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# <
+(?:
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+(?: ,
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+)*  # additional domains
+:
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)?     #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# additional words
+)*
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+#       address spec
+>                    #                 >
+# name and address
+)
+/x
+    Alan Other <user\@dom.ain>
+ 0: Alan Other <user@dom.ain>
+    <user\@dom.ain>
+ 0: user@dom.ain
+    user\@dom.ain
+ 0: user@dom.ain
+    \"A. Other\" <user.1234\@dom.ain> (a comment)
+ 0: "A. Other" <user.1234@dom.ain>
+    A. Other <user.1234\@dom.ain> (a comment)
+ 0:  Other <user.1234@dom.ain>
+    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
+ 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
+    A missing angle <user\@some.where
+ 0: user@some.where
+    *** Failers
+No match
+    The quick brown fox
+No match
+
+/abc\0def\00pqr\000xyz\0000AB/
+    abc\0def\00pqr\000xyz\0000AB
+ 0: abc\x00def\x00pqr\x00xyz\x000AB
+    abc456 abc\0def\00pqr\000xyz\0000ABCDE
+ 0: abc\x00def\x00pqr\x00xyz\x000AB
+
+/abc\x0def\x00pqr\x000xyz\x0000AB/
+    abc\x0def\x00pqr\x000xyz\x0000AB
+ 0: abc\x0def\x00pqr\x000xyz\x0000AB
+    abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
+ 0: abc\x0def\x00pqr\x000xyz\x0000AB
+
+/^[\000-\037]/
+    \0A
+ 0: \x00
+    \01B
+ 0: \x01
+    \037C
+ 0: \x1f
+
+/\0*/
+    \0\0\0\0
+ 0: \x00\x00\x00\x00
+
+/A\x0{2,3}Z/
+    The A\x0\x0Z
+ 0: A\x00\x00Z
+    An A\0\x0\0Z
+ 0: A\x00\x00\x00Z
+    *** Failers
+No match
+    A\0Z
+No match
+    A\0\x0\0\x0Z
+No match
+
+/^(cow|)\1(bell)/
+    cowcowbell
+ 0: cowcowbell
+ 1: cow
+ 2: bell
+    bell
+ 0: bell
+ 1: 
+ 2: bell
+    *** Failers
+No match
+    cowbell
+No match
+
+/^\s/
+    \040abc
+ 0:  
+    \x0cabc
+ 0: \x0c
+    \nabc
+ 0: \x0a
+    \rabc
+ 0: \x0d
+    \tabc
+ 0: \x09
+    *** Failers
+No match
+    abc
+No match
+
+/^a	b
+      c/x
+    abc
+ 0: abc
+
+/^(a|)\1*b/
+    ab
+ 0: ab
+ 1: a
+    aaaab
+ 0: aaaab
+ 1: a
+    b
+ 0: b
+ 1: 
+    *** Failers
+No match
+    acb
+No match
+
+/^(a|)\1+b/
+    aab
+ 0: aab
+ 1: a
+    aaaab
+ 0: aaaab
+ 1: a
+    b
+ 0: b
+ 1: 
+    *** Failers
+No match
+    ab
+No match
+
+/^(a|)\1?b/
+    ab
+ 0: ab
+ 1: a
+    aab
+ 0: aab
+ 1: a
+    b
+ 0: b
+ 1: 
+    *** Failers
+No match
+    acb
+No match
+
+/^(a|)\1{2}b/
+    aaab
+ 0: aaab
+ 1: a
+    b
+ 0: b
+ 1: 
+    *** Failers
+No match
+    ab
+No match
+    aab
+No match
+    aaaab
+No match
+
+/^(a|)\1{2,3}b/
+    aaab
+ 0: aaab
+ 1: a
+    aaaab
+ 0: aaaab
+ 1: a
+    b
+ 0: b
+ 1: 
+    *** Failers
+No match
+    ab
+No match
+    aab
+No match
+    aaaaab
+No match
+
+/ab{1,3}bc/
+    abbbbc
+ 0: abbbbc
+    abbbc
+ 0: abbbc
+    abbc
+ 0: abbc
+    *** Failers
+No match
+    abc
+No match
+    abbbbbc
+No match
+
+/([^.]*)\.([^:]*):[T ]+(.*)/
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1
+ 2: title
+ 3: Blah blah blah
+
+/([^.]*)\.([^:]*):[T ]+(.*)/i
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1
+ 2: title
+ 3: Blah blah blah
+
+/([^.]*)\.([^:]*):[t ]+(.*)/i
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1
+ 2: title
+ 3: Blah blah blah
+
+/^[W-c]+$/
+    WXY_^abc
+ 0: WXY_^abc
+    *** Failers
+No match
+    wxy
+No match
+
+/^[W-c]+$/i
+    WXY_^abc
+ 0: WXY_^abc
+    wxy_^ABC
+ 0: wxy_^ABC
+
+/^[\x3f-\x5F]+$/i
+    WXY_^abc
+ 0: WXY_^abc
+    wxy_^ABC
+ 0: wxy_^ABC
+
+/^abc$/m
+    abc
+ 0: abc
+    qqq\nabc
+ 0: abc
+    abc\nzzz
+ 0: abc
+    qqq\nabc\nzzz
+ 0: abc
+
+/^abc$/
+    abc
+ 0: abc
+    *** Failers
+No match
+    qqq\nabc
+No match
+    abc\nzzz
+No match
+    qqq\nabc\nzzz
+No match
+
+/\Aabc\Z/m
+    abc
+ 0: abc
+    abc\n 
+ 0: abc
+    *** Failers
+No match
+    qqq\nabc
+No match
+    abc\nzzz
+No match
+    qqq\nabc\nzzz
+No match
+    
+/\A(.)*\Z/s
+    abc\ndef
+ 0: abc\x0adef
+ 1: f
+
+/\A(.)*\Z/m
+    *** Failers
+ 0: *** Failers
+ 1: s
+    abc\ndef
+No match
+
+/(?:b)|(?::+)/
+    b::c
+ 0: b
+    c::b
+ 0: ::
+
+/[-az]+/
+    az-
+ 0: az-
+    *** Failers
+ 0: a
+    b
+No match
+
+/[az-]+/
+    za-
+ 0: za-
+    *** Failers
+ 0: a
+    b
+No match
+
+/[a\-z]+/
+    a-z
+ 0: a-z
+    *** Failers
+ 0: a
+    b
+No match
+
+/[a-z]+/
+    abcdxyz
+ 0: abcdxyz
+
+/[\d-]+/
+    12-34
+ 0: 12-34
+    *** Failers
+No match
+    aaa
+No match
+
+/[\d-z]+/
+    12-34z
+ 0: 12-34z
+    *** Failers
+No match
+    aaa
+No match
+
+/\x5c/
+    \\
+ 0: \
+
+/\x20Z/
+    the Zoo
+ 0:  Z
+    *** Failers
+No match
+    Zulu
+No match
+
+/(abc)\1/i
+    abcabc
+ 0: abcabc
+ 1: abc
+    ABCabc
+ 0: ABCabc
+ 1: ABC
+    abcABC
+ 0: abcABC
+ 1: abc
+
+/ab{3cd/
+    ab{3cd
+ 0: ab{3cd
+
+/ab{3,cd/
+    ab{3,cd
+ 0: ab{3,cd
+
+/ab{3,4a}cd/
+    ab{3,4a}cd
+ 0: ab{3,4a}cd
+
+/{4,5a}bc/
+    {4,5a}bc
+ 0: {4,5a}bc
+
+/abc$/
+    abc
+ 0: abc
+    abc\n
+ 0: abc
+    *** Failers
+No match
+    abc\ndef
+No match
+
+/(abc)\123/
+    abc\x53
+ 0: abcS
+ 1: abc
+
+/(abc)\223/
+    abc\x93
+ 0: abc\x93
+ 1: abc
+
+/(abc)\323/
+    abc\xd3
+ 0: abc\xd3
+ 1: abc
+
+/(abc)\100/
+    abc\x40
+ 0: abc@
+ 1: abc
+    abc\100
+ 0: abc@
+ 1: abc
+
+/(abc)\1000/
+    abc\x400
+ 0: abc@0
+ 1: abc
+    abc\x40\x30
+ 0: abc@0
+ 1: abc
+    abc\1000
+ 0: abc@0
+ 1: abc
+    abc\100\x30
+ 0: abc@0
+ 1: abc
+    abc\100\060
+ 0: abc@0
+ 1: abc
+    abc\100\60
+ 0: abc@0
+ 1: abc
+
+/abc\81/
+    abc\081
+ 0: abc\x0081
+    abc\0\x38\x31
+ 0: abc\x0081
+
+/abc\91/
+    abc\091
+ 0: abc\x0091
+    abc\0\x39\x31
+ 0: abc\x0091
+
+/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
+    abcdefghijkllS
+ 0: abcdefghijkllS
+ 1: a
+ 2: b
+ 3: c
+ 4: d
+ 5: e
+ 6: f
+ 7: g
+ 8: h
+ 9: i
+10: j
+11: k
+12: l
+
+/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
+    abcdefghijk\12S
+ 0: abcdefghijk\x0aS
+ 1: a
+ 2: b
+ 3: c
+ 4: d
+ 5: e
+ 6: f
+ 7: g
+ 8: h
+ 9: i
+10: j
+11: k
+
+/ab\idef/
+    abidef
+ 0: abidef
+
+/a{0}bc/
+    bc
+ 0: bc
+
+/(a|(bc)){0,0}?xyz/
+    xyz
+ 0: xyz
+
+/abc[\10]de/
+    abc\010de
+ 0: abc\x08de
+
+/abc[\1]de/
+    abc\1de
+ 0: abc\x01de
+
+/(abc)[\1]de/
+    abc\1de
+ 0: abc\x01de
+ 1: abc
+
+/(?s)a.b/
+    a\nb
+ 0: a\x0ab
+
+/^([^a])([^\b])([^c]*)([^d]{3,4})/
+    baNOTccccd
+ 0: baNOTcccc
+ 1: b
+ 2: a
+ 3: NOT
+ 4: cccc
+    baNOTcccd
+ 0: baNOTccc
+ 1: b
+ 2: a
+ 3: NOT
+ 4: ccc
+    baNOTccd
+ 0: baNOTcc
+ 1: b
+ 2: a
+ 3: NO
+ 4: Tcc
+    bacccd
+ 0: baccc
+ 1: b
+ 2: a
+ 3: 
+ 4: ccc
+    *** Failers
+ 0: *** Failers
+ 1: *
+ 2: *
+ 3: * Fail
+ 4: ers
+    anything
+No match
+    b\bc   
+No match
+    baccd
+No match
+
+/[^a]/
+    Abc
+ 0: A
+  
+/[^a]/i
+    Abc 
+ 0: b
+
+/[^a]+/
+    AAAaAbc
+ 0: AAA
+  
+/[^a]+/i
+    AAAaAbc 
+ 0: bc
+
+/[^a]+/
+    bbb\nccc
+ 0: bbb\x0accc
+   
+/[^k]$/
+    abc
+ 0: c
+    *** Failers
+ 0: s
+    abk   
+No match
+   
+/[^k]{2,3}$/
+    abc
+ 0: abc
+    kbc
+ 0: bc
+    kabc 
+ 0: abc
+    *** Failers
+ 0: ers
+    abk
+No match
+    akb
+No match
+    akk 
+No match
+
+/^\d{8,}\@.+[^k]$/
+    12345678\@a.b.c.d
+ 0: 12345678@a.b.c.d
+    123456789\@x.y.z
+ 0: 123456789@x.y.z
+    *** Failers
+No match
+    12345678\@x.y.uk
+No match
+    1234567\@a.b.c.d       
+No match
+
+/(a)\1{8,}/
+    aaaaaaaaa
+ 0: aaaaaaaaa
+ 1: a
+    aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: a
+    *** Failers
+No match
+    aaaaaaa   
+No match
+
+/[^a]/
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: A
+
+/[^a]/i
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: b
+
+/[^az]/
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: A
+
+/[^az]/i
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: b
+
+/\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377/
+ \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377
+ 0: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff
+
+/P[^*]TAIRE[^*]{1,6}?LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+ 0: PSTAIREISLL
+
+/P[^*]TAIRE[^*]{1,}?LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+ 0: PSTAIREISLL
+
+/(\.\d\d[1-9]?)\d+/
+    1.230003938
+ 0: .230003938
+ 1: .23
+    1.875000282   
+ 0: .875000282
+ 1: .875
+    1.235  
+ 0: .235
+ 1: .23
+                  
+/(\.\d\d((?=0)|\d(?=\d)))/
+    1.230003938      
+ 0: .23
+ 1: .23
+ 2: 
+    1.875000282
+ 0: .875
+ 1: .875
+ 2: 5
+    *** Failers 
+No match
+    1.235 
+No match
+    
+/a(?)b/
+    ab 
+ 0: ab
+ 
+/\b(foo)\s+(\w+)/i
+    Food is on the foo table
+ 0: foo table
+ 1: foo
+ 2: table
+    
+/foo(.*)bar/
+    The food is under the bar in the barn.
+ 0: food is under the bar in the bar
+ 1: d is under the bar in the 
+    
+/foo(.*?)bar/  
+    The food is under the bar in the barn.
+ 0: food is under the bar
+ 1: d is under the 
+
+/(.*)(\d*)/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 53147
+ 2: 
+    
+/(.*)(\d+)/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 5314
+ 2: 7
+ 
+/(.*?)(\d*)/
+    I have 2 numbers: 53147
+ 0: 
+ 1: 
+ 2: 
+
+/(.*?)(\d+)/
+    I have 2 numbers: 53147
+ 0: I have 2
+ 1: I have 
+ 2: 2
+
+/(.*)(\d+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 5314
+ 2: 7
+
+/(.*?)(\d+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 
+ 2: 53147
+
+/(.*)\b(\d+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 
+ 2: 53147
+
+/(.*\D)(\d+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 
+ 2: 53147
+
+/^\D*(?!123)/
+    ABC123
+ 0: AB
+     
+/^(\D*)(?=\d)(?!123)/
+    ABC445
+ 0: ABC
+ 1: ABC
+    *** Failers
+No match
+    ABC123
+No match
+    
+/^[W-]46]/
+    W46]789 
+ 0: W46]
+    -46]789
+ 0: -46]
+    *** Failers
+No match
+    Wall
+No match
+    Zebra
+No match
+    42
+No match
+    [abcd] 
+No match
+    ]abcd[
+No match
+       
+/^[W-\]46]/
+    W46]789 
+ 0: W
+    Wall
+ 0: W
+    Zebra
+ 0: Z
+    Xylophone  
+ 0: X
+    42
+ 0: 4
+    [abcd] 
+ 0: [
+    ]abcd[
+ 0: ]
+    \\backslash 
+ 0: \
+    *** Failers
+No match
+    -46]789
+No match
+    well
+No match
+    
+/\d\d\/\d\d\/\d\d\d\d/
+    01/01/2000
+ 0: 01/01/2000
+
+/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
+  word cat dog elephant mussel cow horse canary baboon snake shark otherword
+ 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
+  word cat dog elephant mussel cow horse canary baboon snake shark
+No match
+
+/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
+  word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+No match
+
+/^(a){0,0}/
+    bcd
+ 0: 
+    abc
+ 0: 
+    aab     
+ 0: 
+
+/^(a){0,1}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: a
+    aab  
+ 0: a
+ 1: a
+
+/^(a){0,2}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: a
+    aab  
+ 0: aa
+ 1: a
+
+/^(a){0,3}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: a
+    aab
+ 0: aa
+ 1: a
+    aaa   
+ 0: aaa
+ 1: a
+
+/^(a){0,}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: a
+    aab
+ 0: aa
+ 1: a
+    aaa
+ 0: aaa
+ 1: a
+    aaaaaaaa    
+ 0: aaaaaaaa
+ 1: a
+
+/^(a){1,1}/
+    bcd
+No match
+    abc
+ 0: a
+ 1: a
+    aab  
+ 0: a
+ 1: a
+
+/^(a){1,2}/
+    bcd
+No match
+    abc
+ 0: a
+ 1: a
+    aab  
+ 0: aa
+ 1: a
+
+/^(a){1,3}/
+    bcd
+No match
+    abc
+ 0: a
+ 1: a
+    aab
+ 0: aa
+ 1: a
+    aaa   
+ 0: aaa
+ 1: a
+
+/^(a){1,}/
+    bcd
+No match
+    abc
+ 0: a
+ 1: a
+    aab
+ 0: aa
+ 1: a
+    aaa
+ 0: aaa
+ 1: a
+    aaaaaaaa    
+ 0: aaaaaaaa
+ 1: a
+
+/.*\.gif/
+    borfle\nbib.gif\nno
+ 0: bib.gif
+
+/.{0,}\.gif/
+    borfle\nbib.gif\nno
+ 0: bib.gif
+
+/.*\.gif/m
+    borfle\nbib.gif\nno
+ 0: bib.gif
+
+/.*\.gif/s
+    borfle\nbib.gif\nno
+ 0: borfle\x0abib.gif
+
+/.*\.gif/ms
+    borfle\nbib.gif\nno
+ 0: borfle\x0abib.gif
+    
+/.*$/
+    borfle\nbib.gif\nno
+ 0: no
+
+/.*$/m
+    borfle\nbib.gif\nno
+ 0: borfle
+
+/.*$/s
+    borfle\nbib.gif\nno
+ 0: borfle\x0abib.gif\x0ano
+
+/.*$/ms
+    borfle\nbib.gif\nno
+ 0: borfle\x0abib.gif\x0ano
+    
+/.*$/
+    borfle\nbib.gif\nno\n
+ 0: no
+
+/.*$/m
+    borfle\nbib.gif\nno\n
+ 0: borfle
+
+/.*$/s
+    borfle\nbib.gif\nno\n
+ 0: borfle\x0abib.gif\x0ano\x0a
+
+/.*$/ms
+    borfle\nbib.gif\nno\n
+ 0: borfle\x0abib.gif\x0ano\x0a
+    
+/(.*X|^B)/
+    abcde\n1234Xyz
+ 0: 1234X
+ 1: 1234X
+    BarFoo 
+ 0: B
+ 1: B
+    *** Failers
+No match
+    abcde\nBar  
+No match
+
+/(.*X|^B)/m
+    abcde\n1234Xyz
+ 0: 1234X
+ 1: 1234X
+    BarFoo 
+ 0: B
+ 1: B
+    abcde\nBar  
+ 0: B
+ 1: B
+
+/(.*X|^B)/s
+    abcde\n1234Xyz
+ 0: abcde\x0a1234X
+ 1: abcde\x0a1234X
+    BarFoo 
+ 0: B
+ 1: B
+    *** Failers
+No match
+    abcde\nBar  
+No match
+
+/(.*X|^B)/ms
+    abcde\n1234Xyz
+ 0: abcde\x0a1234X
+ 1: abcde\x0a1234X
+    BarFoo 
+ 0: B
+ 1: B
+    abcde\nBar  
+ 0: B
+ 1: B
+
+/(?s)(.*X|^B)/
+    abcde\n1234Xyz
+ 0: abcde\x0a1234X
+ 1: abcde\x0a1234X
+    BarFoo 
+ 0: B
+ 1: B
+    *** Failers 
+No match
+    abcde\nBar  
+No match
+
+/(?s:.*X|^B)/
+    abcde\n1234Xyz
+ 0: abcde\x0a1234X
+    BarFoo 
+ 0: B
+    *** Failers 
+No match
+    abcde\nBar  
+No match
+
+/^.*B/
+    **** Failers
+No match
+    abc\nB
+No match
+     
+/(?s)^.*B/
+    abc\nB
+ 0: abc\x0aB
+
+/(?m)^.*B/
+    abc\nB
+ 0: B
+     
+/(?ms)^.*B/
+    abc\nB
+ 0: abc\x0aB
+
+/(?ms)^B/
+    abc\nB
+ 0: B
+
+/(?s)B$/
+    B\n
+ 0: B
+
+/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
+    123456654321
+ 0: 123456654321
+  
+/^\d\d\d\d\d\d\d\d\d\d\d\d/
+    123456654321 
+ 0: 123456654321
+
+/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
+    123456654321
+ 0: 123456654321
+  
+/^[abc]{12}/
+    abcabcabcabc
+ 0: abcabcabcabc
+    
+/^[a-c]{12}/
+    abcabcabcabc
+ 0: abcabcabcabc
+    
+/^(a|b|c){12}/
+    abcabcabcabc 
+ 0: abcabcabcabc
+ 1: c
+
+/^[abcdefghijklmnopqrstuvwxy0123456789]/
+    n
+ 0: n
+    *** Failers 
+No match
+    z 
+No match
+
+/abcde{0,0}/
+    abcd
+ 0: abcd
+    *** Failers
+No match
+    abce  
+No match
+
+/ab[cd]{0,0}e/
+    abe
+ 0: abe
+    *** Failers
+No match
+    abcde 
+No match
+    
+/ab(c){0,0}d/
+    abd
+ 0: abd
+    *** Failers
+No match
+    abcd   
+No match
+
+/a(b*)/
+    a
+ 0: a
+ 1: 
+    ab
+ 0: ab
+ 1: b
+    abbbb
+ 0: abbbb
+ 1: bbbb
+    *** Failers
+ 0: a
+ 1: 
+    bbbbb    
+No match
+    
+/ab\d{0}e/
+    abe
+ 0: abe
+    *** Failers
+No match
+    ab1e   
+No match
+    
+/"([^\\"]+|\\.)*"/
+    the \"quick\" brown fox
+ 0: "quick"
+ 1: quick
+    \"the \\\"quick\\\" brown fox\" 
+ 0: "the \"quick\" brown fox"
+ 1:  brown fox
+
+/.*?/g+
+    abc
+ 0: 
+ 0+ abc
+ 0: a
+ 0+ bc
+ 0: 
+ 0+ bc
+ 0: b
+ 0+ c
+ 0: 
+ 0+ c
+ 0: c
+ 0+ 
+ 0: 
+ 0+ 
+  
+/\b/g+
+    abc 
+ 0: 
+ 0+ abc
+ 0: 
+ 0+ 
+
+/\b/+g
+    abc 
+ 0: 
+ 0+ abc
+ 0: 
+ 0+ 
+
+//g
+    abc
+ 0: 
+ 0: 
+ 0: 
+ 0: 
+
+/<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/is
+  <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
+ 0: <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
+ 1:  BGCOLOR='#DBE9E9'
+ 2:  align=left valign=top
+ 3: 43.
+ 4: <a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)
+ 5: 
+ 6: 
+ 7: <unset>
+ 8:  align=left valign=top
+ 9: Lega lstaff.com
+10:  align=left valign=top
+11: CA - Statewide
+
+/a[^a]b/
+    acb
+ 0: acb
+    a\nb
+ 0: a\x0ab
+    
+/a.b/
+    acb
+ 0: acb
+    *** Failers 
+No match
+    a\nb   
+No match
+    
+/a[^a]b/s
+    acb
+ 0: acb
+    a\nb  
+ 0: a\x0ab
+    
+/a.b/s
+    acb
+ 0: acb
+    a\nb  
+ 0: a\x0ab
+
+/^(b+?|a){1,2}?c/
+    bac
+ 0: bac
+ 1: a
+    bbac
+ 0: bbac
+ 1: a
+    bbbac
+ 0: bbbac
+ 1: a
+    bbbbac
+ 0: bbbbac
+ 1: a
+    bbbbbac 
+ 0: bbbbbac
+ 1: a
+
+/^(b+|a){1,2}?c/
+    bac
+ 0: bac
+ 1: a
+    bbac
+ 0: bbac
+ 1: a
+    bbbac
+ 0: bbbac
+ 1: a
+    bbbbac
+ 0: bbbbac
+ 1: a
+    bbbbbac 
+ 0: bbbbbac
+ 1: a
+    
+/(?!\A)x/m
+    x\nb\n
+No match
+    a\bx\n  
+ 0: x
+    
+/\x0{ab}/
+    \0{ab} 
+ 0: \x00{ab}
+
+/(A|B)*?CD/
+    CD 
+ 0: CD
+    
+/(A|B)*CD/
+    CD 
+ 0: CD
+
+/(AB)*?\1/
+    ABABAB
+ 0: ABAB
+ 1: AB
+
+/(AB)*\1/
+    ABABAB
+ 0: ABABAB
+ 1: AB
+    
+/(?<!bar)foo/
+    foo
+ 0: foo
+    catfood
+ 0: foo
+    arfootle
+ 0: foo
+    rfoosh
+ 0: foo
+    *** Failers
+No match
+    barfoo
+No match
+    towbarfoo
+No match
+
+/\w{3}(?<!bar)foo/
+    catfood
+ 0: catfoo
+    *** Failers
+No match
+    foo
+No match
+    barfoo
+No match
+    towbarfoo
+No match
+
+/(?<=(foo)a)bar/
+    fooabar
+ 0: bar
+ 1: foo
+    *** Failers
+No match
+    bar
+No match
+    foobbar
+No match
+      
+/\Aabc\z/m
+    abc
+ 0: abc
+    *** Failers
+No match
+    abc\n   
+No match
+    qqq\nabc
+No match
+    abc\nzzz
+No match
+    qqq\nabc\nzzz
+No match
+
+"(?>.*/)foo"
+    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
+No match
+
+"(?>.*/)foo"
+    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+ 0: /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+
+/(?>(\.\d\d[1-9]?))\d+/
+    1.230003938
+ 0: .230003938
+ 1: .23
+    1.875000282
+ 0: .875000282
+ 1: .875
+    *** Failers 
+No match
+    1.235 
+No match
+
+/^((?>\w+)|(?>\s+))*$/
+    now is the time for all good men to come to the aid of the party
+ 0: now is the time for all good men to come to the aid of the party
+ 1: party
+    *** Failers
+No match
+    this is not a line with only words and spaces!
+No match
+    
+/(\d+)(\w)/
+    12345a
+ 0: 12345a
+ 1: 12345
+ 2: a
+    12345+ 
+ 0: 12345
+ 1: 1234
+ 2: 5
+
+/((?>\d+))(\w)/
+    12345a
+ 0: 12345a
+ 1: 12345
+ 2: a
+    *** Failers
+No match
+    12345+ 
+No match
+
+/(?>a+)b/
+    aaab
+ 0: aaab
+
+/((?>a+)b)/
+    aaab
+ 0: aaab
+ 1: aaab
+
+/(?>(a+))b/
+    aaab
+ 0: aaab
+ 1: aaa
+
+/(?>b)+/
+    aaabbbccc
+ 0: bbb
+
+/(?>a+|b+|c+)*c/
+    aaabbbbccccd
+ 0: aaabbbbc
+
+/((?>[^()]+)|\([^()]*\))+/
+    ((abc(ade)ufh()()x
+ 0: abc(ade)ufh()()x
+ 1: x
+    
+/\(((?>[^()]+)|\([^()]+\))+\)/ 
+    (abc)
+ 0: (abc)
+ 1: abc
+    (abc(def)xyz)
+ 0: (abc(def)xyz)
+ 1: xyz
+    *** Failers
+No match
+    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa   
+No match
+
+/a(?-i)b/i
+    ab
+ 0: ab
+    Ab
+ 0: Ab
+    *** Failers 
+No match
+    aB
+No match
+    AB
+No match
+        
+/(a (?x)b c)d e/
+    a bcd e
+ 0: a bcd e
+ 1: a bc
+    *** Failers
+No match
+    a b cd e
+No match
+    abcd e   
+No match
+    a bcde 
+No match
+ 
+/(a b(?x)c d (?-x)e f)/
+    a bcde f
+ 0: a bcde f
+ 1: a bcde f
+    *** Failers
+No match
+    abcdef  
+No match
+
+/(a(?i)b)c/
+    abc
+ 0: abc
+ 1: ab
+    aBc
+ 0: aBc
+ 1: aB
+    *** Failers
+No match
+    abC
+No match
+    aBC  
+No match
+    Abc
+No match
+    ABc
+No match
+    ABC
+No match
+    AbC
+No match
+    
+/a(?i:b)c/
+    abc
+ 0: abc
+    aBc
+ 0: aBc
+    *** Failers 
+No match
+    ABC
+No match
+    abC
+No match
+    aBC
+No match
+    
+/a(?i:b)*c/
+    aBc
+ 0: aBc
+    aBBc
+ 0: aBBc
+    *** Failers 
+No match
+    aBC
+No match
+    aBBC
+No match
+    
+/a(?=b(?i)c)\w\wd/
+    abcd
+ 0: abcd
+    abCd
+ 0: abCd
+    *** Failers
+No match
+    aBCd
+No match
+    abcD     
+No match
+    
+/(?s-i:more.*than).*million/i
+    more than million
+ 0: more than million
+    more than MILLION
+ 0: more than MILLION
+    more \n than Million 
+ 0: more \x0a than Million
+    *** Failers
+No match
+    MORE THAN MILLION    
+No match
+    more \n than \n million 
+No match
+
+/(?:(?s-i)more.*than).*million/i
+    more than million
+ 0: more than million
+    more than MILLION
+ 0: more than MILLION
+    more \n than Million 
+ 0: more \x0a than Million
+    *** Failers
+No match
+    MORE THAN MILLION    
+No match
+    more \n than \n million 
+No match
+    
+/(?>a(?i)b+)+c/ 
+    abc
+ 0: abc
+    aBbc
+ 0: aBbc
+    aBBc 
+ 0: aBBc
+    *** Failers
+No match
+    Abc
+No match
+    abAb    
+No match
+    abbC 
+No match
+    
+/(?=a(?i)b)\w\wc/
+    abc
+ 0: abc
+    aBc
+ 0: aBc
+    *** Failers
+No match
+    Ab 
+No match
+    abC
+No match
+    aBC     
+No match
+    
+/(?<=a(?i)b)(\w\w)c/
+    abxxc
+ 0: xxc
+ 1: xx
+    aBxxc
+ 0: xxc
+ 1: xx
+    *** Failers
+No match
+    Abxxc
+No match
+    ABxxc
+No match
+    abxxC      
+No match
+
+/(?:(a)|b)(?(1)A|B)/
+    aA
+ 0: aA
+ 1: a
+    bB
+ 0: bB
+    *** Failers
+No match
+    aB
+No match
+    bA    
+No match
+
+/^(a)?(?(1)a|b)+$/
+    aa
+ 0: aa
+ 1: a
+    b
+ 0: b
+    bb  
+ 0: bb
+    *** Failers
+No match
+    ab   
+No match
+
+/^(?(?=abc)\w{3}:|\d\d)$/
+    abc:
+ 0: abc:
+    12
+ 0: 12
+    *** Failers
+No match
+    123
+No match
+    xyz    
+No match
+
+/^(?(?!abc)\d\d|\w{3}:)$/
+    abc:
+ 0: abc:
+    12
+ 0: 12
+    *** Failers
+No match
+    123
+No match
+    xyz    
+No match
+    
+/(?(?<=foo)bar|cat)/
+    foobar
+ 0: bar
+    cat
+ 0: cat
+    fcat
+ 0: cat
+    focat   
+ 0: cat
+    *** Failers
+No match
+    foocat  
+No match
+
+/(?(?<!foo)cat|bar)/
+    foobar
+ 0: bar
+    cat
+ 0: cat
+    fcat
+ 0: cat
+    focat   
+ 0: cat
+    *** Failers
+No match
+    foocat  
+No match
+
+/( \( )? [^()]+ (?(1) \) |) /x
+    abcd
+ 0: abcd
+    (abcd)
+ 0: (abcd)
+ 1: (
+    the quick (abcd) fox
+ 0: the quick 
+    (abcd   
+ 0: abcd
+
+/( \( )? [^()]+ (?(1) \) ) /x
+    abcd
+ 0: abcd
+    (abcd)
+ 0: (abcd)
+ 1: (
+    the quick (abcd) fox
+ 0: the quick 
+    (abcd   
+ 0: abcd
+
+/^(?(2)a|(1)(2))+$/
+    12
+ 0: 12
+ 1: 1
+ 2: 2
+    12a
+ 0: 12a
+ 1: 1
+ 2: 2
+    12aa
+ 0: 12aa
+ 1: 1
+ 2: 2
+    *** Failers
+No match
+    1234    
+No match
+
+/((?i)blah)\s+\1/
+    blah blah
+ 0: blah blah
+ 1: blah
+    BLAH BLAH
+ 0: BLAH BLAH
+ 1: BLAH
+    Blah Blah
+ 0: Blah Blah
+ 1: Blah
+    blaH blaH
+ 0: blaH blaH
+ 1: blaH
+    *** Failers
+No match
+    blah BLAH
+No match
+    Blah blah      
+No match
+    blaH blah 
+No match
+
+/((?i)blah)\s+(?i:\1)/
+    blah blah
+ 0: blah blah
+ 1: blah
+    BLAH BLAH
+ 0: BLAH BLAH
+ 1: BLAH
+    Blah Blah
+ 0: Blah Blah
+ 1: Blah
+    blaH blaH
+ 0: blaH blaH
+ 1: blaH
+    blah BLAH
+ 0: blah BLAH
+ 1: blah
+    Blah blah      
+ 0: Blah blah
+ 1: Blah
+    blaH blah 
+ 0: blaH blah
+ 1: blaH
+
+/(?>a*)*/
+    a
+ 0: a
+    aa
+ 0: aa
+    aaaa
+ 0: aaaa
+    
+/(abc|)+/
+    abc
+ 0: abc
+ 1: 
+    abcabc
+ 0: abcabc
+ 1: 
+    abcabcabc
+ 0: abcabcabc
+ 1: 
+    xyz      
+ 0: 
+ 1: 
+
+/([a]*)*/
+    a
+ 0: a
+ 1: 
+    aaaaa 
+ 0: aaaaa
+ 1: 
+ 
+/([ab]*)*/
+    a
+ 0: a
+ 1: 
+    b
+ 0: b
+ 1: 
+    ababab
+ 0: ababab
+ 1: 
+    aaaabcde
+ 0: aaaab
+ 1: 
+    bbbb    
+ 0: bbbb
+ 1: 
+ 
+/([^a]*)*/
+    b
+ 0: b
+ 1: 
+    bbbb
+ 0: bbbb
+ 1: 
+    aaa   
+ 0: 
+ 1: 
+ 
+/([^ab]*)*/
+    cccc
+ 0: cccc
+ 1: 
+    abab  
+ 0: 
+ 1: 
+ 
+/([a]*?)*/
+    a
+ 0: 
+ 1: 
+    aaaa 
+ 0: 
+ 1: 
+ 
+/([ab]*?)*/
+    a
+ 0: 
+ 1: 
+    b
+ 0: 
+ 1: 
+    abab
+ 0: 
+ 1: 
+    baba   
+ 0: 
+ 1: 
+ 
+/([^a]*?)*/
+    b
+ 0: 
+ 1: 
+    bbbb
+ 0: 
+ 1: 
+    aaa   
+ 0: 
+ 1: 
+ 
+/([^ab]*?)*/
+    c
+ 0: 
+ 1: 
+    cccc
+ 0: 
+ 1: 
+    baba   
+ 0: 
+ 1: 
+ 
+/(?>a*)*/
+    a
+ 0: a
+    aaabcde 
+ 0: aaa
+ 
+/((?>a*))*/
+    aaaaa
+ 0: aaaaa
+ 1: 
+    aabbaa 
+ 0: aa
+ 1: 
+ 
+/((?>a*?))*/
+    aaaaa
+ 0: 
+ 1: 
+    aabbaa 
+ 0: 
+ 1: 
+
+/(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /x
+    12-sep-98
+ 0: 12-sep-98
+    12-09-98
+ 0: 12-09-98
+    *** Failers
+No match
+    sep-12-98
+No match
+        
+/(?<=(foo))bar\1/
+    foobarfoo
+ 0: barfoo
+ 1: foo
+    foobarfootling 
+ 0: barfoo
+ 1: foo
+    *** Failers
+No match
+    foobar
+No match
+    barfoo   
+No match
+
+/(?i:saturday|sunday)/
+    saturday
+ 0: saturday
+    sunday
+ 0: sunday
+    Saturday
+ 0: Saturday
+    Sunday
+ 0: Sunday
+    SATURDAY
+ 0: SATURDAY
+    SUNDAY
+ 0: SUNDAY
+    SunDay
+ 0: SunDay
+    
+/(a(?i)bc|BB)x/
+    abcx
+ 0: abcx
+ 1: abc
+    aBCx
+ 0: aBCx
+ 1: aBC
+    bbx
+ 0: bbx
+ 1: bb
+    BBx
+ 0: BBx
+ 1: BB
+    *** Failers
+No match
+    abcX
+No match
+    aBCX
+No match
+    bbX
+No match
+    BBX               
+No match
+
+/^([ab](?i)[cd]|[ef])/
+    ac
+ 0: ac
+ 1: ac
+    aC
+ 0: aC
+ 1: aC
+    bD
+ 0: bD
+ 1: bD
+    elephant
+ 0: e
+ 1: e
+    Europe 
+ 0: E
+ 1: E
+    frog
+ 0: f
+ 1: f
+    France
+ 0: F
+ 1: F
+    *** Failers
+No match
+    Africa     
+No match
+
+/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
+    ab
+ 0: ab
+ 1: ab
+    aBd
+ 0: aBd
+ 1: aBd
+    xy
+ 0: xy
+ 1: xy
+    xY
+ 0: xY
+ 1: xY
+    zebra
+ 0: z
+ 1: z
+    Zambesi
+ 0: Z
+ 1: Z
+    *** Failers
+No match
+    aCD  
+No match
+    XY  
+No match
+
+/(?<=foo\n)^bar/m
+    foo\nbar
+ 0: bar
+    *** Failers
+No match
+    bar
+No match
+    baz\nbar   
+No match
+
+/(?<=(?<!foo)bar)baz/
+    barbaz
+ 0: baz
+    barbarbaz 
+ 0: baz
+    koobarbaz 
+ 0: baz
+    *** Failers
+No match
+    baz
+No match
+    foobarbaz 
+No match
+
+/The case of aaaaaa is missed out below because I think Perl 5.005_02 gets/
+/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/
+No match
+/where it does set $1 to aa when matching aaaaaa./
+No match
+
+/^(a\1?){4}$/
+    a
+No match
+    aa
+No match
+    aaa
+No match
+    aaaa
+ 0: aaaa
+ 1: a
+    aaaaa
+ 0: aaaaa
+ 1: a
+    aaaaaaa
+ 0: aaaaaaa
+ 1: a
+    aaaaaaaa
+No match
+    aaaaaaaaa
+No match
+    aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: aaaa
+    aaaaaaaaaaa
+No match
+    aaaaaaaaaaaa
+No match
+    aaaaaaaaaaaaa
+No match
+    aaaaaaaaaaaaaa
+No match
+    aaaaaaaaaaaaaaa
+No match
+    aaaaaaaaaaaaaaaa               
+No match
+
+/^(a\1?)(a\1?)(a\2?)(a\3?)$/
+    a
+No match
+    aa
+No match
+    aaa
+No match
+    aaaa
+ 0: aaaa
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+    aaaaa
+ 0: aaaaa
+ 1: a
+ 2: aa
+ 3: a
+ 4: a
+    aaaaaa
+ 0: aaaaaa
+ 1: a
+ 2: aa
+ 3: a
+ 4: aa
+    aaaaaaa
+ 0: aaaaaaa
+ 1: a
+ 2: aa
+ 3: aaa
+ 4: a
+    aaaaaaaa
+No match
+    aaaaaaaaa
+No match
+    aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: a
+ 2: aa
+ 3: aaa
+ 4: aaaa
+    aaaaaaaaaaa
+No match
+    aaaaaaaaaaaa
+No match
+    aaaaaaaaaaaaa
+No match
+    aaaaaaaaaaaaaa
+No match
+    aaaaaaaaaaaaaaa
+No match
+    aaaaaaaaaaaaaaaa               
+No match
+
+/The following tests are taken from the Perl 5.005 test suite; some of them/
+/are compatible with 5.004, but I'd rather not have to sort them out./
+No match
+
+/abc/
+    abc
+ 0: abc
+    xabcy
+ 0: abc
+    ababc
+ 0: abc
+    *** Failers
+No match
+    xbc
+No match
+    axc
+No match
+    abx
+No match
+
+/ab*c/
+    abc
+ 0: abc
+
+/ab*bc/
+    abc
+ 0: abc
+    abbc
+ 0: abbc
+    abbbbc
+ 0: abbbbc
+
+/.{1}/
+    abbbbc
+ 0: a
+
+/.{3,4}/
+    abbbbc
+ 0: abbb
+
+/ab{0,}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab+bc/
+    abbc
+ 0: abbc
+    *** Failers
+No match
+    abc
+No match
+    abq
+No match
+
+/ab{1,}bc/
+
+/ab+bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{1,}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{1,3}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{3,4}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{4,5}bc/
+    *** Failers
+No match
+    abq
+No match
+    abbbbc
+No match
+
+/ab?bc/
+    abbc
+ 0: abbc
+    abc
+ 0: abc
+
+/ab{0,1}bc/
+    abc
+ 0: abc
+
+/ab?bc/
+
+/ab?c/
+    abc
+ 0: abc
+
+/ab{0,1}c/
+    abc
+ 0: abc
+
+/^abc$/
+    abc
+ 0: abc
+    *** Failers
+No match
+    abbbbc
+No match
+    abcc
+No match
+
+/^abc/
+    abcc
+ 0: abc
+
+/^abc$/
+
+/abc$/
+    aabc
+ 0: abc
+    *** Failers
+No match
+    aabc
+ 0: abc
+    aabcd
+No match
+
+/^/
+    abc
+ 0: 
+
+/$/
+    abc
+ 0: 
+
+/a.c/
+    abc
+ 0: abc
+    axc
+ 0: axc
+
+/a.*c/
+    axyzc
+ 0: axyzc
+
+/a[bc]d/
+    abd
+ 0: abd
+    *** Failers
+No match
+    axyzd
+No match
+    abc
+No match
+
+/a[b-d]e/
+    ace
+ 0: ace
+
+/a[b-d]/
+    aac
+ 0: ac
+
+/a[-b]/
+    a-
+ 0: a-
+
+/a[b-]/
+    a-
+ 0: a-
+
+/a]/
+    a]
+ 0: a]
+
+/a[]]b/
+    a]b
+ 0: a]b
+
+/a[^bc]d/
+    aed
+ 0: aed
+    *** Failers
+No match
+    abd
+No match
+    abd
+No match
+
+/a[^-b]c/
+    adc
+ 0: adc
+
+/a[^]b]c/
+    adc
+ 0: adc
+    *** Failers
+No match
+    a-c
+ 0: a-c
+    a]c
+No match
+
+/\ba\b/
+    a-
+ 0: a
+    -a
+ 0: a
+    -a-
+ 0: a
+
+/\by\b/
+    *** Failers
+No match
+    xy
+No match
+    yz
+No match
+    xyz
+No match
+
+/\Ba\B/
+    *** Failers
+ 0: a
+    a-
+No match
+    -a
+No match
+    -a-
+No match
+
+/\By\b/
+    xy
+ 0: y
+
+/\by\B/
+    yz
+ 0: y
+
+/\By\B/
+    xyz
+ 0: y
+
+/\w/
+    a
+ 0: a
+
+/\W/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    a
+No match
+
+/a\sb/
+    a b
+ 0: a b
+
+/a\Sb/
+    a-b
+ 0: a-b
+    *** Failers
+No match
+    a-b
+ 0: a-b
+    a b
+No match
+
+/\d/
+    1
+ 0: 1
+
+/\D/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    1
+No match
+
+/[\w]/
+    a
+ 0: a
+
+/[\W]/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    a
+No match
+
+/a[\s]b/
+    a b
+ 0: a b
+
+/a[\S]b/
+    a-b
+ 0: a-b
+    *** Failers
+No match
+    a-b
+ 0: a-b
+    a b
+No match
+
+/[\d]/
+    1
+ 0: 1
+
+/[\D]/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    1
+No match
+
+/ab|cd/
+    abc
+ 0: ab
+    abcd
+ 0: ab
+
+/()ef/
+    def
+ 0: ef
+ 1: 
+
+/$b/
+
+/a\(b/
+    a(b
+ 0: a(b
+
+/a\(*b/
+    ab
+ 0: ab
+    a((b
+ 0: a((b
+
+/a\\b/
+    a\b
+No match
+
+/((a))/
+    abc
+ 0: a
+ 1: a
+ 2: a
+
+/(a)b(c)/
+    abc
+ 0: abc
+ 1: a
+ 2: c
+
+/a+b+c/
+    aabbabc
+ 0: abc
+
+/a{1,}b{1,}c/
+    aabbabc
+ 0: abc
+
+/a.+?c/
+    abcabc
+ 0: abc
+
+/(a+|b)*/
+    ab
+ 0: ab
+ 1: b
+
+/(a+|b){0,}/
+    ab
+ 0: ab
+ 1: b
+
+/(a+|b)+/
+    ab
+ 0: ab
+ 1: b
+
+/(a+|b){1,}/
+    ab
+ 0: ab
+ 1: b
+
+/(a+|b)?/
+    ab
+ 0: a
+ 1: a
+
+/(a+|b){0,1}/
+    ab
+ 0: a
+ 1: a
+
+/[^ab]*/
+    cde
+ 0: cde
+
+/abc/
+    *** Failers
+No match
+    b
+No match
+    
+
+/a*/
+    
+
+/([abc])*d/
+    abbbcd
+ 0: abbbcd
+ 1: c
+
+/([abc])*bcd/
+    abcd
+ 0: abcd
+ 1: a
+
+/a|b|c|d|e/
+    e
+ 0: e
+
+/(a|b|c|d|e)f/
+    ef
+ 0: ef
+ 1: e
+
+/abcd*efg/
+    abcdefg
+ 0: abcdefg
+
+/ab*/
+    xabyabbbz
+ 0: ab
+    xayabbbz
+ 0: a
+
+/(ab|cd)e/
+    abcde
+ 0: cde
+ 1: cd
+
+/[abhgefdc]ij/
+    hij
+ 0: hij
+
+/^(ab|cd)e/
+
+/(abc|)ef/
+    abcdef
+ 0: ef
+ 1: 
+
+/(a|b)c*d/
+    abcd
+ 0: bcd
+ 1: b
+
+/(ab|ab*)bc/
+    abc
+ 0: abc
+ 1: a
+
+/a([bc]*)c*/
+    abc
+ 0: abc
+ 1: bc
+
+/a([bc]*)(c*d)/
+    abcd
+ 0: abcd
+ 1: bc
+ 2: d
+
+/a([bc]+)(c*d)/
+    abcd
+ 0: abcd
+ 1: bc
+ 2: d
+
+/a([bc]*)(c+d)/
+    abcd
+ 0: abcd
+ 1: b
+ 2: cd
+
+/a[bcd]*dcdcde/
+    adcdcde
+ 0: adcdcde
+
+/a[bcd]+dcdcde/
+    *** Failers
+No match
+    abcde
+No match
+    adcdcde
+No match
+
+/(ab|a)b*c/
+    abc
+ 0: abc
+ 1: ab
+
+/((a)(b)c)(d)/
+    abcd
+ 0: abcd
+ 1: abc
+ 2: a
+ 3: b
+ 4: d
+
+/[a-zA-Z_][a-zA-Z0-9_]*/
+    alpha
+ 0: alpha
+
+/^a(bc+|b[eh])g|.h$/
+    abh
+ 0: bh
+
+/(bc+d$|ef*g.|h?i(j|k))/
+    effgz
+ 0: effgz
+ 1: effgz
+    ij
+ 0: ij
+ 1: ij
+ 2: j
+    reffgz
+ 0: effgz
+ 1: effgz
+    *** Failers
+No match
+    effg
+No match
+    bcdd
+No match
+
+/((((((((((a))))))))))/
+    a
+ 0: a
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+
+/((((((((((a))))))))))\10/
+    aa
+ 0: aa
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+
+/(((((((((a)))))))))/
+    a
+ 0: a
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+
+/multiple words of text/
+    *** Failers
+No match
+    aa
+No match
+    uh-uh
+No match
+
+/multiple words/
+    multiple words, yeah
+ 0: multiple words
+
+/(.*)c(.*)/
+    abcde
+ 0: abcde
+ 1: ab
+ 2: de
+
+/\((.*), (.*)\)/
+    (a, b)
+ 0: (a, b)
+ 1: a
+ 2: b
+
+/[k]/
+
+/abcd/
+    abcd
+ 0: abcd
+
+/a(bc)d/
+    abcd
+ 0: abcd
+ 1: bc
+
+/a[-]?c/
+    ac
+ 0: ac
+
+/(abc)\1/
+    abcabc
+ 0: abcabc
+ 1: abc
+
+/([a-c]*)\1/
+    abcabc
+ 0: abcabc
+ 1: abc
+
+/(a)|\1/
+    a
+ 0: a
+ 1: a
+    *** Failers
+ 0: a
+ 1: a
+    ab
+ 0: a
+ 1: a
+    x
+No match
+
+/(([a-c])b*?\2)*/
+    ababbbcbc
+ 0: ababb
+ 1: bb
+ 2: b
+
+/(([a-c])b*?\2){3}/
+    ababbbcbc
+ 0: ababbbcbc
+ 1: cbc
+ 2: c
+
+/((\3|b)\2(a)x)+/
+    aaaxabaxbaaxbbax
+ 0: bbax
+ 1: bbax
+ 2: b
+ 3: a
+
+/((\3|b)\2(a)){2,}/
+    bbaababbabaaaaabbaaaabba
+ 0: bbaaaabba
+ 1: bba
+ 2: b
+ 3: a
+
+/abc/i
+    ABC
+ 0: ABC
+    XABCY
+ 0: ABC
+    ABABC
+ 0: ABC
+    *** Failers
+No match
+    aaxabxbaxbbx
+No match
+    XBC
+No match
+    AXC
+No match
+    ABX
+No match
+
+/ab*c/i
+    ABC
+ 0: ABC
+
+/ab*bc/i
+    ABC
+ 0: ABC
+    ABBC
+ 0: ABBC
+
+/ab*?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{0,}?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab+?bc/i
+    ABBC
+ 0: ABBC
+
+/ab+bc/i
+    *** Failers
+No match
+    ABC
+No match
+    ABQ
+No match
+
+/ab{1,}bc/i
+
+/ab+bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{1,}?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{1,3}?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{3,4}?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{4,5}?bc/i
+    *** Failers
+No match
+    ABQ
+No match
+    ABBBBC
+No match
+
+/ab??bc/i
+    ABBC
+ 0: ABBC
+    ABC
+ 0: ABC
+
+/ab{0,1}?bc/i
+    ABC
+ 0: ABC
+
+/ab??bc/i
+
+/ab??c/i
+    ABC
+ 0: ABC
+
+/ab{0,1}?c/i
+    ABC
+ 0: ABC
+
+/^abc$/i
+    ABC
+ 0: ABC
+    *** Failers
+No match
+    ABBBBC
+No match
+    ABCC
+No match
+
+/^abc/i
+    ABCC
+ 0: ABC
+
+/^abc$/i
+
+/abc$/i
+    AABC
+ 0: ABC
+
+/^/i
+    ABC
+ 0: 
+
+/$/i
+    ABC
+ 0: 
+
+/a.c/i
+    ABC
+ 0: ABC
+    AXC
+ 0: AXC
+
+/a.*?c/i
+    AXYZC
+ 0: AXYZC
+
+/a.*c/i
+    *** Failers
+No match
+    AABC
+ 0: AABC
+    AXYZD
+No match
+
+/a[bc]d/i
+    ABD
+ 0: ABD
+
+/a[b-d]e/i
+    ACE
+ 0: ACE
+    *** Failers
+No match
+    ABC
+No match
+    ABD
+No match
+
+/a[b-d]/i
+    AAC
+ 0: AC
+
+/a[-b]/i
+    A-
+ 0: A-
+
+/a[b-]/i
+    A-
+ 0: A-
+
+/a]/i
+    A]
+ 0: A]
+
+/a[]]b/i
+    A]B
+ 0: A]B
+
+/a[^bc]d/i
+    AED
+ 0: AED
+
+/a[^-b]c/i
+    ADC
+ 0: ADC
+    *** Failers
+No match
+    ABD
+No match
+    A-C
+No match
+
+/a[^]b]c/i
+    ADC
+ 0: ADC
+
+/ab|cd/i
+    ABC
+ 0: AB
+    ABCD
+ 0: AB
+
+/()ef/i
+    DEF
+ 0: EF
+ 1: 
+
+/$b/i
+    *** Failers
+No match
+    A]C
+No match
+    B
+No match
+
+/a\(b/i
+    A(B
+ 0: A(B
+
+/a\(*b/i
+    AB
+ 0: AB
+    A((B
+ 0: A((B
+
+/a\\b/i
+    A\B
+No match
+
+/((a))/i
+    ABC
+ 0: A
+ 1: A
+ 2: A
+
+/(a)b(c)/i
+    ABC
+ 0: ABC
+ 1: A
+ 2: C
+
+/a+b+c/i
+    AABBABC
+ 0: ABC
+
+/a{1,}b{1,}c/i
+    AABBABC
+ 0: ABC
+
+/a.+?c/i
+    ABCABC
+ 0: ABC
+
+/a.*?c/i
+    ABCABC
+ 0: ABC
+
+/a.{0,5}?c/i
+    ABCABC
+ 0: ABC
+
+/(a+|b)*/i
+    AB
+ 0: AB
+ 1: B
+
+/(a+|b){0,}/i
+    AB
+ 0: AB
+ 1: B
+
+/(a+|b)+/i
+    AB
+ 0: AB
+ 1: B
+
+/(a+|b){1,}/i
+    AB
+ 0: AB
+ 1: B
+
+/(a+|b)?/i
+    AB
+ 0: A
+ 1: A
+
+/(a+|b){0,1}/i
+    AB
+ 0: A
+ 1: A
+
+/(a+|b){0,1}?/i
+    AB
+ 0: 
+
+/[^ab]*/i
+    CDE
+ 0: CDE
+
+/abc/i
+
+/a*/i
+    
+
+/([abc])*d/i
+    ABBBCD
+ 0: ABBBCD
+ 1: C
+
+/([abc])*bcd/i
+    ABCD
+ 0: ABCD
+ 1: A
+
+/a|b|c|d|e/i
+    E
+ 0: E
+
+/(a|b|c|d|e)f/i
+    EF
+ 0: EF
+ 1: E
+
+/abcd*efg/i
+    ABCDEFG
+ 0: ABCDEFG
+
+/ab*/i
+    XABYABBBZ
+ 0: AB
+    XAYABBBZ
+ 0: A
+
+/(ab|cd)e/i
+    ABCDE
+ 0: CDE
+ 1: CD
+
+/[abhgefdc]ij/i
+    HIJ
+ 0: HIJ
+
+/^(ab|cd)e/i
+    ABCDE
+No match
+
+/(abc|)ef/i
+    ABCDEF
+ 0: EF
+ 1: 
+
+/(a|b)c*d/i
+    ABCD
+ 0: BCD
+ 1: B
+
+/(ab|ab*)bc/i
+    ABC
+ 0: ABC
+ 1: A
+
+/a([bc]*)c*/i
+    ABC
+ 0: ABC
+ 1: BC
+
+/a([bc]*)(c*d)/i
+    ABCD
+ 0: ABCD
+ 1: BC
+ 2: D
+
+/a([bc]+)(c*d)/i
+    ABCD
+ 0: ABCD
+ 1: BC
+ 2: D
+
+/a([bc]*)(c+d)/i
+    ABCD
+ 0: ABCD
+ 1: B
+ 2: CD
+
+/a[bcd]*dcdcde/i
+    ADCDCDE
+ 0: ADCDCDE
+
+/a[bcd]+dcdcde/i
+
+/(ab|a)b*c/i
+    ABC
+ 0: ABC
+ 1: AB
+
+/((a)(b)c)(d)/i
+    ABCD
+ 0: ABCD
+ 1: ABC
+ 2: A
+ 3: B
+ 4: D
+
+/[a-zA-Z_][a-zA-Z0-9_]*/i
+    ALPHA
+ 0: ALPHA
+
+/^a(bc+|b[eh])g|.h$/i
+    ABH
+ 0: BH
+
+/(bc+d$|ef*g.|h?i(j|k))/i
+    EFFGZ
+ 0: EFFGZ
+ 1: EFFGZ
+    IJ
+ 0: IJ
+ 1: IJ
+ 2: J
+    REFFGZ
+ 0: EFFGZ
+ 1: EFFGZ
+    *** Failers
+No match
+    ADCDCDE
+No match
+    EFFG
+No match
+    BCDD
+No match
+
+/((((((((((a))))))))))/i
+    A
+ 0: A
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+10: A
+
+/((((((((((a))))))))))\10/i
+    AA
+ 0: AA
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+10: A
+
+/(((((((((a)))))))))/i
+    A
+ 0: A
+ 1: A
+ 2: A
+ 3: A
+ 4: A
+ 5: A
+ 6: A
+ 7: A
+ 8: A
+ 9: A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
+    A
+ 0: A
+ 1: A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
+    C
+ 0: C
+ 1: C
+
+/multiple words of text/i
+    *** Failers
+No match
+    AA
+No match
+    UH-UH
+No match
+
+/multiple words/i
+    MULTIPLE WORDS, YEAH
+ 0: MULTIPLE WORDS
+
+/(.*)c(.*)/i
+    ABCDE
+ 0: ABCDE
+ 1: AB
+ 2: DE
+
+/\((.*), (.*)\)/i
+    (A, B)
+ 0: (A, B)
+ 1: A
+ 2: B
+
+/[k]/i
+
+/abcd/i
+    ABCD
+ 0: ABCD
+
+/a(bc)d/i
+    ABCD
+ 0: ABCD
+ 1: BC
+
+/a[-]?c/i
+    AC
+ 0: AC
+
+/(abc)\1/i
+    ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/([a-c]*)\1/i
+    ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/a(?!b)./
+    abad
+ 0: ad
+
+/a(?=d)./
+    abad
+ 0: ad
+
+/a(?=c|d)./
+    abad
+ 0: ad
+
+/a(?:b|c|d)(.)/
+    ace
+ 0: ace
+ 1: e
+
+/a(?:b|c|d)*(.)/
+    ace
+ 0: ace
+ 1: e
+
+/a(?:b|c|d)+?(.)/
+    ace
+ 0: ace
+ 1: e
+    acdbcdbe
+ 0: acd
+ 1: d
+
+/a(?:b|c|d)+(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){2}(.)/
+    acdbcdbe
+ 0: acdb
+ 1: b
+
+/a(?:b|c|d){4,5}(.)/
+    acdbcdbe
+ 0: acdbcdb
+ 1: b
+
+/a(?:b|c|d){4,5}?(.)/
+    acdbcdbe
+ 0: acdbcd
+ 1: d
+
+/((foo)|(bar))*/
+    foobar
+ 0: foobar
+ 1: bar
+ 2: foo
+ 3: bar
+
+/a(?:b|c|d){6,7}(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){6,7}?(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){5,6}(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){5,6}?(.)/
+    acdbcdbe
+ 0: acdbcdb
+ 1: b
+
+/a(?:b|c|d){5,7}(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: e
+
+/a(?:b|c|d){5,7}?(.)/
+    acdbcdbe
+ 0: acdbcdb
+ 1: b
+
+/a(?:b|(c|e){1,2}?|d)+?(.)/
+    ace
+ 0: ace
+ 1: c
+ 2: e
+
+/^(.+)?B/
+    AB
+ 0: AB
+ 1: A
+
+/^([^a-z])|(\^)$/
+    .
+ 0: .
+ 1: .
+
+/^[<>]&/
+    <&OUT
+ 0: <&
+
+/^(a\1?){4}$/
+    aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: aaaa
+    *** Failers
+No match
+    AB
+No match
+    aaaaaaaaa
+No match
+    aaaaaaaaaaa
+No match
+
+/^(a(?(1)\1)){4}$/
+    aaaaaaaaaa
+ 0: aaaaaaaaaa
+ 1: aaaa
+    *** Failers
+No match
+    aaaaaaaaa
+No match
+    aaaaaaaaaaa
+No match
+
+/(?:(f)(o)(o)|(b)(a)(r))*/
+    foobar
+ 0: foobar
+ 1: f
+ 2: o
+ 3: o
+ 4: b
+ 5: a
+ 6: r
+
+/(?<=a)b/
+    ab
+ 0: b
+    *** Failers
+No match
+    cb
+No match
+    b
+No match
+
+/(?<!c)b/
+    ab
+ 0: b
+    b
+ 0: b
+    b
+ 0: b
+
+/(?:..)*a/
+    aba
+ 0: aba
+
+/(?:..)*?a/
+    aba
+ 0: a
+
+/^(?:b|a(?=(.)))*\1/
+    abc
+ 0: ab
+ 1: b
+
+/^(){3,5}/
+    abc
+ 0: 
+ 1: 
+
+/^(a+)*ax/
+    aax
+ 0: aax
+ 1: a
+
+/^((a|b)+)*ax/
+    aax
+ 0: aax
+ 1: a
+ 2: a
+
+/^((a|bc)+)*ax/
+    aax
+ 0: aax
+ 1: a
+ 2: a
+
+/(a|x)*ab/
+    cab
+ 0: ab
+
+/(a)*ab/
+    cab
+ 0: ab
+
+/(?:(?i)a)b/
+    ab
+ 0: ab
+
+/((?i)a)b/
+    ab
+ 0: ab
+ 1: a
+
+/(?:(?i)a)b/
+    Ab
+ 0: Ab
+
+/((?i)a)b/
+    Ab
+ 0: Ab
+ 1: A
+
+/(?:(?i)a)b/
+    *** Failers
+No match
+    cb
+No match
+    aB
+No match
+
+/((?i)a)b/
+
+/(?i:a)b/
+    ab
+ 0: ab
+
+/((?i:a))b/
+    ab
+ 0: ab
+ 1: a
+
+/(?i:a)b/
+    Ab
+ 0: Ab
+
+/((?i:a))b/
+    Ab
+ 0: Ab
+ 1: A
+
+/(?i:a)b/
+    *** Failers
+No match
+    aB
+No match
+    aB
+No match
+
+/((?i:a))b/
+
+/(?:(?-i)a)b/i
+    ab
+ 0: ab
+
+/((?-i)a)b/i
+    ab
+ 0: ab
+ 1: a
+
+/(?:(?-i)a)b/i
+    aB
+ 0: aB
+
+/((?-i)a)b/i
+    aB
+ 0: aB
+ 1: a
+
+/(?:(?-i)a)b/i
+    *** Failers
+No match
+    aB
+ 0: aB
+    Ab
+No match
+
+/((?-i)a)b/i
+
+/(?:(?-i)a)b/i
+    aB
+ 0: aB
+
+/((?-i)a)b/i
+    aB
+ 0: aB
+ 1: a
+
+/(?:(?-i)a)b/i
+    *** Failers
+No match
+    Ab
+No match
+    AB
+No match
+
+/((?-i)a)b/i
+
+/(?-i:a)b/i
+    ab
+ 0: ab
+
+/((?-i:a))b/i
+    ab
+ 0: ab
+ 1: a
+
+/(?-i:a)b/i
+    aB
+ 0: aB
+
+/((?-i:a))b/i
+    aB
+ 0: aB
+ 1: a
+
+/(?-i:a)b/i
+    *** Failers
+No match
+    AB
+No match
+    Ab
+No match
+
+/((?-i:a))b/i
+
+/(?-i:a)b/i
+    aB
+ 0: aB
+
+/((?-i:a))b/i
+    aB
+ 0: aB
+ 1: a
+
+/(?-i:a)b/i
+    *** Failers
+No match
+    Ab
+No match
+    AB
+No match
+
+/((?-i:a))b/i
+
+/((?-i:a.))b/i
+    *** Failers
+No match
+    AB
+No match
+    a\nB
+No match
+
+/((?s-i:a.))b/i
+    a\nB
+ 0: a\x0aB
+ 1: a\x0a
+
+/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
+    cabbbb
+ 0: cabbbb
+
+/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
+    caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ 0: caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+/(ab)\d\1/i
+    Ab4ab
+ 0: Ab4ab
+ 1: Ab
+    ab4Ab
+ 0: ab4Ab
+ 1: ab
+
+/foo\w*\d{4}baz/
+    foobar1234baz
+ 0: foobar1234baz
+
+/x(~~)*(?:(?:F)?)?/
+    x~~
+ 0: x~~
+ 1: ~~
+
+/^a(?#xxx){3}c/
+    aaac
+ 0: aaac
+
+/^a (?#xxx) (?#yyy) {3}c/x
+    aaac
+ 0: aaac
+
+/(?<![cd])b/
+    *** Failers
+No match
+    B\nB
+No match
+    dbcb
+No match
+
+/(?<![cd])[ab]/
+    dbaacb
+ 0: a
+
+/(?<!(c|d))b/
+
+/(?<!(c|d))[ab]/
+    dbaacb
+ 0: a
+
+/(?<!cd)[ab]/
+    cdaccb
+ 0: b
+
+/^(?:a?b?)*$/
+    \
+ 0: 
+    a
+ 0: a
+    ab
+ 0: ab
+    aaa   
+ 0: aaa
+    *** Failers
+No match
+    dbcb
+No match
+    a--
+No match
+    aa-- 
+No match
+
+/((?s)^a(.))((?m)^b$)/
+    a\nb\nc\n
+ 0: a\x0ab
+ 1: a\x0a
+ 2: \x0a
+ 3: b
+
+/((?m)^b$)/
+    a\nb\nc\n
+ 0: b
+ 1: b
+
+/(?m)^b/
+    a\nb\n
+ 0: b
+
+/(?m)^(b)/
+    a\nb\n
+ 0: b
+ 1: b
+
+/((?m)^b)/
+    a\nb\n
+ 0: b
+ 1: b
+
+/\n((?m)^b)/
+    a\nb\n
+ 0: \x0ab
+ 1: b
+
+/((?s).)c(?!.)/
+    a\nb\nc\n
+ 0: \x0ac
+ 1: \x0a
+    a\nb\nc\n
+ 0: \x0ac
+ 1: \x0a
+
+/((?s)b.)c(?!.)/
+    a\nb\nc\n
+ 0: b\x0ac
+ 1: b\x0a
+    a\nb\nc\n
+ 0: b\x0ac
+ 1: b\x0a
+
+/^b/
+
+/()^b/
+    *** Failers
+No match
+    a\nb\nc\n
+No match
+    a\nb\nc\n
+No match
+
+/((?m)^b)/
+    a\nb\nc\n
+ 0: b
+ 1: b
+
+/(x)?(?(1)a|b)/
+    *** Failers
+No match
+    a
+No match
+    a
+No match
+
+/(x)?(?(1)b|a)/
+    a
+ 0: a
+
+/()?(?(1)b|a)/
+    a
+ 0: a
+
+/()(?(1)b|a)/
+
+/()?(?(1)a|b)/
+    a
+ 0: a
+ 1: 
+
+/^(\()?blah(?(1)(\)))$/
+    (blah)
+ 0: (blah)
+ 1: (
+ 2: )
+    blah
+ 0: blah
+    *** Failers
+No match
+    a
+No match
+    blah)
+No match
+    (blah
+No match
+
+/^(\(+)?blah(?(1)(\)))$/
+    (blah)
+ 0: (blah)
+ 1: (
+ 2: )
+    blah
+ 0: blah
+    *** Failers
+No match
+    blah)
+No match
+    (blah
+No match
+
+/(?(?!a)a|b)/
+
+/(?(?!a)b|a)/
+    a
+ 0: a
+
+/(?(?=a)b|a)/
+    *** Failers
+No match
+    a
+No match
+    a
+No match
+
+/(?(?=a)a|b)/
+    a
+ 0: a
+
+/(?=(a+?))(\1ab)/
+    aaab
+ 0: aab
+ 1: a
+ 2: aab
+
+/^(?=(a+?))\1ab/
+
+/(\w+:)+/
+    one:
+ 0: one:
+ 1: one:
+
+/$(?<=^(a))/
+    a
+ 0: 
+ 1: a
+
+/(?=(a+?))(\1ab)/
+    aaab
+ 0: aab
+ 1: a
+ 2: aab
+
+/^(?=(a+?))\1ab/
+    *** Failers
+No match
+    aaab
+No match
+    aaab
+No match
+
+/([\w:]+::)?(\w+)$/
+    abcd
+ 0: abcd
+ 1: <unset>
+ 2: abcd
+    xy:z:::abcd
+ 0: xy:z:::abcd
+ 1: xy:z:::
+ 2: abcd
+
+/^[^bcd]*(c+)/
+    aexycd
+ 0: aexyc
+ 1: c
+
+/(a*)b+/
+    caab
+ 0: aab
+ 1: aa
+
+/([\w:]+::)?(\w+)$/
+    abcd
+ 0: abcd
+ 1: <unset>
+ 2: abcd
+    xy:z:::abcd
+ 0: xy:z:::abcd
+ 1: xy:z:::
+ 2: abcd
+    *** Failers
+ 0: Failers
+ 1: <unset>
+ 2: Failers
+    abcd:
+No match
+    abcd:
+No match
+
+/^[^bcd]*(c+)/
+    aexycd
+ 0: aexyc
+ 1: c
+
+/(>a+)ab/
+
+/(?>a+)b/
+    aaab
+ 0: aaab
+
+/([[:]+)/
+    a:[b]:
+ 0: :[
+ 1: :[
+
+/([[=]+)/
+    a=[b]=
+ 0: =[
+ 1: =[
+
+/([[.]+)/
+    a.[b].
+ 0: .[
+ 1: .[
+
+/((?>a+)b)/
+    aaab
+ 0: aaab
+ 1: aaab
+
+/(?>(a+))b/
+    aaab
+ 0: aaab
+ 1: aaa
+
+/((?>[^()]+)|\([^()]*\))+/
+    ((abc(ade)ufh()()x
+ 0: abc(ade)ufh()()x
+ 1: x
+
+/a\Z/
+    *** Failers
+No match
+    aaab
+No match
+    a\nb\n
+No match
+
+/b\Z/
+    a\nb\n
+ 0: b
+
+/b\z/
+
+/b\Z/
+    a\nb
+ 0: b
+
+/b\z/
+    a\nb
+ 0: b
+    *** Failers
+No match
+    
+/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
+    a
+ 0: a
+ 1: 
+    abc
+ 0: abc
+ 1: 
+    a-b
+ 0: a-b
+ 1: 
+    0-9 
+ 0: 0-9
+ 1: 
+    a.b
+ 0: a.b
+ 1: 
+    5.6.7  
+ 0: 5.6.7
+ 1: 
+    the.quick.brown.fox
+ 0: the.quick.brown.fox
+ 1: 
+    a100.b200.300c  
+ 0: a100.b200.300c
+ 1: 
+    12-ab.1245 
+ 0: 12-ab.1245
+ 1: 
+    *** Failers
+No match
+    \
+No match
+    .a
+No match
+    -a
+No match
+    a-
+No match
+    a.  
+No match
+    a_b 
+No match
+    a.-
+No match
+    a..  
+No match
+    ab..bc 
+No match
+    the.quick.brown.fox-
+No match
+    the.quick.brown.fox.
+No match
+    the.quick.brown.fox_
+No match
+    the.quick.brown.fox+       
+No match
+
+/(?>.*)(?<=(abcd|wxyz))/
+    alphabetabcd
+ 0: alphabetabcd
+ 1: abcd
+    endingwxyz
+ 0: endingwxyz
+ 1: wxyz
+    *** Failers
+No match
+    a rather long string that doesn't end with one of them
+No match
+
+/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
+    word cat dog elephant mussel cow horse canary baboon snake shark otherword
+ 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
+    word cat dog elephant mussel cow horse canary baboon snake shark
+No match
+  
+/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
+    word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+No match
+
+/(?<=\d{3}(?!999))foo/
+    999foo
+ 0: foo
+    123999foo 
+ 0: foo
+    *** Failers
+No match
+    123abcfoo
+No match
+    
+/(?<=(?!...999)\d{3})foo/
+    999foo
+ 0: foo
+    123999foo 
+ 0: foo
+    *** Failers
+No match
+    123abcfoo
+No match
+
+/(?<=\d{3}(?!999)...)foo/
+    123abcfoo
+ 0: foo
+    123456foo 
+ 0: foo
+    *** Failers
+No match
+    123999foo  
+No match
+    
+/(?<=\d{3}...)(?<!999)foo/
+    123abcfoo   
+ 0: foo
+    123456foo 
+ 0: foo
+    *** Failers
+No match
+    123999foo  
+No match
+
+/<a[\s]+href[\s]*=[\s]*          # find <a href=
+ ([\"\'])?                       # find single or double quote
+ (?(1) (.*?)\1 | ([^\s]+))       # if quote found, match up to next matching
+                                 # quote, otherwise match up to next space
+/isx
+    <a href=abcd xyz
+ 0: <a href=abcd
+ 1: <unset>
+ 2: <unset>
+ 3: abcd
+    <a href=\"abcd xyz pqr\" cats
+ 0: <a href="abcd xyz pqr"
+ 1: "
+ 2: abcd xyz pqr
+    <a href=\'abcd xyz pqr\' cats
+ 0: <a href='abcd xyz pqr'
+ 1: '
+ 2: abcd xyz pqr
+
+/<a\s+href\s*=\s*                # find <a href=
+ (["'])?                         # find single or double quote
+ (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
+                                 # quote, otherwise match up to next space
+/isx
+    <a href=abcd xyz
+ 0: <a href=abcd
+ 1: <unset>
+ 2: <unset>
+ 3: abcd
+    <a href=\"abcd xyz pqr\" cats
+ 0: <a href="abcd xyz pqr"
+ 1: "
+ 2: abcd xyz pqr
+    <a href       =       \'abcd xyz pqr\' cats
+ 0: <a href       =       'abcd xyz pqr'
+ 1: '
+ 2: abcd xyz pqr
+
+/<a\s+href(?>\s*)=(?>\s*)        # find <a href=
+ (["'])?                         # find single or double quote
+ (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
+                                 # quote, otherwise match up to next space
+/isx
+    <a href=abcd xyz
+ 0: <a href=abcd
+ 1: <unset>
+ 2: <unset>
+ 3: abcd
+    <a href=\"abcd xyz pqr\" cats
+ 0: <a href="abcd xyz pqr"
+ 1: "
+ 2: abcd xyz pqr
+    <a href       =       \'abcd xyz pqr\' cats
+ 0: <a href       =       'abcd xyz pqr'
+ 1: '
+ 2: abcd xyz pqr
+
+/((Z)+|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: A
+ 2: Z
+
+/(Z()|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: A
+ 2: 
+
+/(Z(())|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: A
+ 2: 
+ 3: 
+
+/((?>Z)+|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: A
+
+/((?>)+|A)*/
+    ZABCDEFG
+ 0: 
+ 1: 
+
+/a*/g
+    abbab
+ 0: a
+ 0: 
+ 0: 
+ 0: a
+ 0: 
+ 0: 
+
+/^[a-\d]/
+    abcde
+ 0: a
+    -things
+ 0: -
+    0digit
+ 0: 0
+    *** Failers
+No match
+    bcdef    
+No match
+
+/^[\d-a]/
+    abcde
+ 0: a
+    -things
+ 0: -
+    0digit
+ 0: 0
+    *** Failers
+No match
+    bcdef    
+No match
+    
+/[[:space:]]+/
+    > \x09\x0a\x0c\x0d\x0b<
+ 0:  \x09\x0a\x0c\x0d\x0b
+     
+/[[:blank:]]+/
+    > \x09\x0a\x0c\x0d\x0b<
+ 0:  \x09
+     
+/[\s]+/
+    > \x09\x0a\x0c\x0d\x0b<
+ 0:  \x09\x0a\x0c\x0d
+     
+/\s+/
+    > \x09\x0a\x0c\x0d\x0b<
+ 0:  \x09\x0a\x0c\x0d
+     
+/ab/x
+    ab
+No match
+
+/(?!\A)x/m
+  a\nxb\n
+ 0: x
+
+/(?!^)x/m
+  a\nxb\n
+No match
+
+/abc\Qabc\Eabc/
+    abcabcabc
+ 0: abcabcabc
+    
+/abc\Q(*+|\Eabc/
+    abc(*+|abc 
+ 0: abc(*+|abc
+
+/   abc\Q abc\Eabc/x
+    abc abcabc
+ 0: abc abcabc
+    *** Failers
+No match
+    abcabcabc  
+No match
+    
+/abc#comment
+    \Q#not comment
+    literal\E/x
+    abc#not comment\n    literal     
+ 0: abc#not comment\x0a    literal
+
+/abc#comment
+    \Q#not comment
+    literal/x
+    abc#not comment\n    literal     
+ 0: abc#not comment\x0a    literal
+
+/abc#comment
+    \Q#not comment
+    literal\E #more comment
+    /x
+    abc#not comment\n    literal     
+ 0: abc#not comment\x0a    literal
+
+/abc#comment
+    \Q#not comment
+    literal\E #more comment/x
+    abc#not comment\n    literal     
+ 0: abc#not comment\x0a    literal
+
+/\Qabc\$xyz\E/
+    abc\\\$xyz
+ 0: abc\$xyz
+
+/\Qabc\E\$\Qxyz\E/
+    abc\$xyz
+ 0: abc$xyz
+
+/\Gabc/
+    abc
+ 0: abc
+    *** Failers
+No match
+    xyzabc  
+No match
+
+/\Gabc./g
+    abc1abc2xyzabc3
+ 0: abc1
+ 0: abc2
+
+/abc./g
+    abc1abc2xyzabc3 
+ 0: abc1
+ 0: abc2
+ 0: abc3
+
+/a(?x: b c )d/
+    XabcdY
+ 0: abcd
+    *** Failers 
+No match
+    Xa b c d Y 
+No match
+
+/((?x)x y z | a b c)/
+    XabcY
+ 0: abc
+ 1: abc
+    AxyzB 
+ 0: xyz
+ 1: xyz
+
+/(?i)AB(?-i)C/
+    XabCY
+ 0: abC
+    *** Failers
+No match
+    XabcY  
+No match
+
+/((?i)AB(?-i)C|D)E/
+    abCE
+ 0: abCE
+ 1: abC
+    DE
+ 0: DE
+ 1: D
+    *** Failers
+No match
+    abcE
+No match
+    abCe  
+No match
+    dE
+No match
+    De    
+No match
+
+/(.*)\d+\1/
+    abc123abc
+ 0: abc123abc
+ 1: abc
+    abc123bc 
+ 0: bc123bc
+ 1: bc
+
+/(.*)\d+\1/s
+    abc123abc
+ 0: abc123abc
+ 1: abc
+    abc123bc 
+ 0: bc123bc
+ 1: bc
+    
+/((.*))\d+\1/
+    abc123abc
+ 0: abc123abc
+ 1: abc
+ 2: abc
+    abc123bc  
+ 0: bc123bc
+ 1: bc
+ 2: bc
+
+/-- This tests for an IPv6 address in the form where it can have up to --/
+/-- eight components, one and only one of which is empty. This must be --/
+No match
+/-- an internal component. --/
+No match
+
+/^(?!:)                       # colon disallowed at start
+  (?:                         # start of item
+    (?: [0-9a-f]{1,4} |       # 1-4 hex digits or
+    (?(1)0 | () ) )           # if null previously matched, fail; else null
+    :                         # followed by colon
+  ){1,7}                      # end item; 1-7 of them required               
+  [0-9a-f]{1,4} $             # final hex number at end of string
+  (?(1)|.)                    # check that there was an empty component
+  /xi
+    a123::a123
+ 0: a123::a123
+ 1: 
+    a123:b342::abcd
+ 0: a123:b342::abcd
+ 1: 
+    a123:b342::324e:abcd
+ 0: a123:b342::324e:abcd
+ 1: 
+    a123:ddde:b342::324e:abcd
+ 0: a123:ddde:b342::324e:abcd
+ 1: 
+    a123:ddde:b342::324e:dcba:abcd
+ 0: a123:ddde:b342::324e:dcba:abcd
+ 1: 
+    a123:ddde:9999:b342::324e:dcba:abcd
+ 0: a123:ddde:9999:b342::324e:dcba:abcd
+ 1: 
+    *** Failers
+No match
+    1:2:3:4:5:6:7:8
+No match
+    a123:bce:ddde:9999:b342::324e:dcba:abcd
+No match
+    a123::9999:b342::324e:dcba:abcd
+No match
+    abcde:2:3:4:5:6:7:8
+No match
+    ::1
+No match
+    abcd:fee0:123::   
+No match
+    :1
+No match
+    1:  
+No match
+
+/[z\Qa-d]\E]/
+    z
+ 0: z
+    a
+ 0: a
+    -
+ 0: -
+    d
+ 0: d
+    ] 
+ 0: ]
+    *** Failers
+ 0: a
+    b     
+No match
+
+/[\z\C]/
+    z
+ 0: z
+    C 
+ 0: C
+    
+/\M/
+    M 
+ 0: M
+    
+/(a+)*b/
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
+No match
+    
+/(?i)reg(?:ul(?:[aä]|ae)r|ex)/
+    REGular
+ 0: REGular
+    regulaer
+ 0: regulaer
+    Regex  
+ 0: Regex
+    regulär 
+ 0: regul\xe4r
+
+/Åæåä[à-ÿÀ-ß]+/
+    Åæåäà
+ 0: \xc5\xe6\xe5\xe4\xe0
+    Åæåäÿ
+ 0: \xc5\xe6\xe5\xe4\xff
+    ÅæåäÀ
+ 0: \xc5\xe6\xe5\xe4\xc0
+    Åæåäß
+ 0: \xc5\xe6\xe5\xe4\xdf
+
+/(?<=Z)X./
+  \x84XAZXB
+ 0: XB
+
+/ab cd (?x) de fg/
+    ab cd defg
+ 0: ab cd defg
+
+/ab cd(?x) de fg/
+    ab cddefg
+ 0: ab cddefg
+    ** Failers 
+No match
+    abcddefg
+No match
+
+/(?<![^f]oo)(bar)/
+    foobarX 
+ 0: bar
+ 1: bar
+    ** Failers 
+No match
+    boobarX
+No match
+
+/(?<![^f])X/
+    offX
+ 0: X
+    ** Failers
+No match
+    onyX  
+No match
+
+/(?<=[^f])X/
+    onyX
+ 0: X
+    ** Failers
+No match
+    offX 
+No match
+
+/^/mg
+    a\nb\nc\n
+ 0: 
+ 0: 
+ 0: 
+    \ 
+ 0: 
+    
+/(?<=C\n)^/mg
+    A\nC\nC\n 
+ 0: 
+
+/(?:(?(1)a|b)(X))+/
+    bXaX
+ 0: bXaX
+ 1: X
+
+/(?:(?(1)\1a|b)(X|Y))+/
+    bXXaYYaY
+ 0: bXXaYYaY
+ 1: Y
+    bXYaXXaX  
+ 0: bX
+ 1: X
+
+/()()()()()()()()()(?:(?(10)\10a|b)(X|Y))+/
+    bXXaYYaY
+ 0: bX
+ 1: 
+ 2: 
+ 3: 
+ 4: 
+ 5: 
+ 6: 
+ 7: 
+ 8: 
+ 9: 
+10: X
+
+/[[,abc,]+]/
+    abc]
+ 0: abc]
+    a,b]
+ 0: a,b]
+    [a,b,c]  
+ 0: [a,b,c]
+
+/(?-x: )/x
+    A\x20B
+ 0:  
+    
+"(?x)(?-x: \s*#\s*)"
+    A # B
+ 0:  # 
+    ** Failers
+No match
+    #  
+No match
+
+"(?x-is)(?:(?-ixs) \s*#\s*) include"
+    A #include
+ 0:  #include
+    ** Failers
+No match
+    A#include  
+No match
+    A #Include
+No match
+
+/a*b*\w/
+    aaabbbb
+ 0: aaabbbb
+    aaaa
+ 0: aaaa
+    a
+ 0: a
+
+/a*b?\w/
+    aaabbbb
+ 0: aaabb
+    aaaa
+ 0: aaaa
+    a
+ 0: a
+
+/a*b{0,4}\w/
+    aaabbbb
+ 0: aaabbbb
+    aaaa
+ 0: aaaa
+    a
+ 0: a
+
+/a*b{0,}\w/
+    aaabbbb
+ 0: aaabbbb
+    aaaa
+ 0: aaaa
+    a
+ 0: a
+    
+/a*\d*\w/
+    0a
+ 0: 0a
+    a 
+ 0: a
+    
+/a*b *\w/x
+    a 
+ 0: a
+
+/a*b#comment
+  *\w/x
+    a 
+ 0: a
+
+/a* b *\w/x
+    a 
+ 0: a
+
+/^\w+=.*(\\\n.*)*/
+    abc=xyz\\\npqr
+ 0: abc=xyz\
+
+/(?=(\w+))\1:/
+    abcd:
+ 0: abcd:
+ 1: abcd
+
+/^(?=(\w+))\1:/
+    abcd:
+ 0: abcd:
+ 1: abcd
+
+/^\Eabc/
+    abc
+ 0: abc
+    
+/^[\Eabc]/
+    a
+ 0: a
+    ** Failers 
+No match
+    E 
+No match
+    
+/^[a-\Ec]/
+    b
+ 0: b
+    ** Failers
+No match
+    -
+No match
+    E    
+No match
+
+/^[a\E\E-\Ec]/
+    b
+ 0: b
+    ** Failers
+No match
+    -
+No match
+    E    
+No match
+
+/^[\E\Qa\E-\Qz\E]+/
+    b
+ 0: b
+    ** Failers
+No match
+    -  
+No match
+    
+/^[a\Q]bc\E]/
+    a
+ 0: a
+    ]
+ 0: ]
+    c
+ 0: c
+    
+/^[a-\Q\E]/
+    a
+ 0: a
+    -     
+ 0: -
+
+/^(a()*)*/
+    aaaa
+ 0: aaaa
+ 1: a
+ 2: 
+
+/^(?:a(?:(?:))*)*/
+    aaaa
+ 0: aaaa
+
+/^(a()+)+/
+    aaaa
+ 0: aaaa
+ 1: a
+ 2: 
+
+/^(?:a(?:(?:))+)+/
+    aaaa
+ 0: aaaa
+
+/(a){0,3}(?(1)b|(c|))*D/
+    abbD
+ 0: abbD
+ 1: a
+    ccccD
+ 0: ccccD
+ 1: <unset>
+ 2: 
+    D  
+ 0: D
+ 1: <unset>
+ 2: 
+
+/(a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+ 1: 
+
+/(?>a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/(?:a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/\Z/g
+  abc\n
+ 0: 
+ 0: 
+  
+/^(?s)(?>.*)(?<!\n)/
+  abc
+ 0: abc
+  abc\n  
+No match
+
+/^(?![^\n]*\n\z)/
+  abc
+ 0: 
+  abc\n 
+No match
+  
+/\z(?<!\n)/
+  abc
+ 0: 
+  abc\n  
+No match
+
+/(.*(.)?)*/
+    abcd
+ 0: abcd
+ 1: 
+
+/( (A | (?(1)0|) )*   )/x
+    abcd
+ 0: 
+ 1: 
+ 2: 
+
+/( ( (?(1)0|) )*   )/x
+    abcd
+ 0: 
+ 1: 
+ 2: 
+
+/(  (?(1)0|)*   )/x
+    abcd
+ 0: 
+ 1: 
+
+/[[:abcd:xyz]]/
+    a]
+ 0: a]
+    :] 
+ 0: :]
+    
+/[abc[:x\]pqr]/
+    a
+ 0: a
+    [
+ 0: [
+    :
+ 0: :
+    ]
+ 0: ]
+    p    
+ 0: p
+
+/.*[op][xyz]/
+    fooabcfoo
+No match
+
+/ End of testinput1 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput10	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,669 @@
+/-- These are a few representative patterns whose lengths and offsets are to be 
+shown when the link size is 2. This is just a doublecheck test to ensure the 
+sizes don't go horribly wrong when something is changed. The pattern contents 
+are all themselves checked in other tests. --/
+
+/((?i)b)/BM
+Memory allocation (code space): 21
+------------------------------------------------------------------
+  0  17 Bra
+  3   9 CBra 1
+  8  01 Opt
+ 10  NC b
+ 12   9 Ket
+ 15  00 Opt
+ 17  17 Ket
+ 20     End
+------------------------------------------------------------------
+
+/(?s)(.*X|^B)/BM
+Memory allocation (code space): 25
+------------------------------------------------------------------
+  0  21 Bra
+  3   9 CBra 1
+  8     AllAny*
+ 10     X
+ 12   6 Alt
+ 15     ^
+ 16     B
+ 18  15 Ket
+ 21  21 Ket
+ 24     End
+------------------------------------------------------------------
+
+/(?s:.*X|^B)/BM
+Memory allocation (code space): 29
+------------------------------------------------------------------
+  0  25 Bra
+  3   9 Bra
+  6  04 Opt
+  8     AllAny*
+ 10     X
+ 12   8 Alt
+ 15  04 Opt
+ 17     ^
+ 18     B
+ 20  17 Ket
+ 23  00 Opt
+ 25  25 Ket
+ 28     End
+------------------------------------------------------------------
+
+/^[[:alnum:]]/BM
+Memory allocation (code space): 41
+------------------------------------------------------------------
+  0  37 Bra
+  3     ^
+  4     [0-9A-Za-z]
+ 37  37 Ket
+ 40     End
+------------------------------------------------------------------
+
+/#/IxMD
+Memory allocation (code space): 7
+------------------------------------------------------------------
+  0   3 Bra
+  3   3 Ket
+  6     End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: extended
+No first char
+No need char
+
+/a#/IxMD
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     a
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: extended
+First char = 'a'
+No need char
+
+/x?+/BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     x?+
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+
+/x++/BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     x++
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+
+/x{1,3}+/BM 
+Memory allocation (code space): 19
+------------------------------------------------------------------
+  0  15 Bra
+  3   9 Once
+  6     x
+  8     x{0,2}
+ 12   9 Ket
+ 15  15 Ket
+ 18     End
+------------------------------------------------------------------
+
+/(x)*+/BM
+Memory allocation (code space): 24
+------------------------------------------------------------------
+  0  20 Bra
+  3  14 Once
+  6     Brazero
+  7   7 CBra 1
+ 12     x
+ 14   7 KetRmax
+ 17  14 Ket
+ 20  20 Ket
+ 23     End
+------------------------------------------------------------------
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/BM
+Memory allocation (code space): 120
+------------------------------------------------------------------
+  0 116 Bra
+  3     ^
+  4 109 CBra 1
+  9   7 CBra 2
+ 14     a+
+ 16   7 Ket
+ 19  39 CBra 3
+ 24     [ab]+?
+ 58  39 Ket
+ 61  39 CBra 4
+ 66     [bc]+
+100  39 Ket
+103   7 CBra 5
+108     \w*
+110   7 Ket
+113 109 Ket
+116 116 Ket
+119     End
+------------------------------------------------------------------
+
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|BM
+Memory allocation (code space): 826
+------------------------------------------------------------------
+  0 822 Bra
+  3     8J$WE<.rX+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+821     \b
+822 822 Ket
+825     End
+------------------------------------------------------------------
+
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|BM
+Memory allocation (code space): 816
+------------------------------------------------------------------
+  0 812 Bra
+  3     $<.X+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+811     \b
+812 812 Ket
+815     End
+------------------------------------------------------------------
+
+/(a(?1)b)/BM
+Memory allocation (code space): 28
+------------------------------------------------------------------
+  0  24 Bra
+  3  18 CBra 1
+  8     a
+ 10   6 Once
+ 13   3 Recurse
+ 16   6 Ket
+ 19     b
+ 21  18 Ket
+ 24  24 Ket
+ 27     End
+------------------------------------------------------------------
+
+/(a(?1)+b)/BM
+Memory allocation (code space): 28
+------------------------------------------------------------------
+  0  24 Bra
+  3  18 CBra 1
+  8     a
+ 10   6 Once
+ 13   3 Recurse
+ 16   6 KetRmax
+ 19     b
+ 21  18 Ket
+ 24  24 Ket
+ 27     End
+------------------------------------------------------------------
+
+/a(?P<name1>b|c)d(?P<longername2>e)/BM
+Memory allocation (code space): 42
+------------------------------------------------------------------
+  0  32 Bra
+  3     a
+  5   7 CBra 1
+ 10     b
+ 12   5 Alt
+ 15     c
+ 17  12 Ket
+ 20     d
+ 22   7 CBra 2
+ 27     e
+ 29   7 Ket
+ 32  32 Ket
+ 35     End
+------------------------------------------------------------------
+
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/BM
+Memory allocation (code space): 54
+------------------------------------------------------------------
+  0  41 Bra
+  3  25 Bra
+  6     a
+  8  17 CBra 1
+ 13     c
+ 15   7 CBra 2
+ 20     d
+ 22   7 Ket
+ 25  17 Ket
+ 28  25 Ket
+ 31   7 CBra 3
+ 36     a
+ 38   7 Ket
+ 41  41 Ket
+ 44     End
+------------------------------------------------------------------
+
+/(?P<a>a)...(?P=a)bbb(?P>a)d/BM
+Memory allocation (code space): 43
+------------------------------------------------------------------
+  0  36 Bra
+  3   7 CBra 1
+  8     a
+ 10   7 Ket
+ 13     Any
+ 14     Any
+ 15     Any
+ 16     \1
+ 19     bbb
+ 25   6 Once
+ 28   3 Recurse
+ 31   6 Ket
+ 34     d
+ 36  36 Ket
+ 39     End
+------------------------------------------------------------------
+
+/abc(?C255)de(?C)f/BM
+Memory allocation (code space): 31
+------------------------------------------------------------------
+  0  27 Bra
+  3     abc
+  9     Callout 255 10 1
+ 15     de
+ 19     Callout 0 16 1
+ 25     f
+ 27  27 Ket
+ 30     End
+------------------------------------------------------------------
+
+/abcde/CBM
+Memory allocation (code space): 53
+------------------------------------------------------------------
+  0  49 Bra
+  3     Callout 255 0 1
+  9     a
+ 11     Callout 255 1 1
+ 17     b
+ 19     Callout 255 2 1
+ 25     c
+ 27     Callout 255 3 1
+ 33     d
+ 35     Callout 255 4 1
+ 41     e
+ 43     Callout 255 5 0
+ 49  49 Ket
+ 52     End
+------------------------------------------------------------------
+
+/\x{100}/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+  0   6 Bra
+  3     \x{100}
+  6   6 Ket
+  9     End
+------------------------------------------------------------------
+
+/\x{1000}/8BM
+Memory allocation (code space): 11
+------------------------------------------------------------------
+  0   7 Bra
+  3     \x{1000}
+  7   7 Ket
+ 10     End
+------------------------------------------------------------------
+
+/\x{10000}/8BM
+Memory allocation (code space): 12
+------------------------------------------------------------------
+  0   8 Bra
+  3     \x{10000}
+  8   8 Ket
+ 11     End
+------------------------------------------------------------------
+
+/\x{100000}/8BM
+Memory allocation (code space): 12
+------------------------------------------------------------------
+  0   8 Bra
+  3     \x{100000}
+  8   8 Ket
+ 11     End
+------------------------------------------------------------------
+
+/\x{1000000}/8BM
+Memory allocation (code space): 13
+------------------------------------------------------------------
+  0   9 Bra
+  3     \x{1000000}
+  9   9 Ket
+ 12     End
+------------------------------------------------------------------
+
+/\x{4000000}/8BM
+Memory allocation (code space): 14
+------------------------------------------------------------------
+  0  10 Bra
+  3     \x{4000000}
+ 10  10 Ket
+ 13     End
+------------------------------------------------------------------
+
+/\x{7fffFFFF}/8BM
+Memory allocation (code space): 14
+------------------------------------------------------------------
+  0  10 Bra
+  3     \x{7fffffff}
+ 10  10 Ket
+ 13     End
+------------------------------------------------------------------
+
+/[\x{ff}]/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+  0   6 Bra
+  3     \x{ff}
+  6   6 Ket
+  9     End
+------------------------------------------------------------------
+
+/[\x{100}]/8BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+  0  11 Bra
+  3     [\x{100}]
+ 11  11 Ket
+ 14     End
+------------------------------------------------------------------
+
+/\x80/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+  0   6 Bra
+  3     \x{80}
+  6   6 Ket
+  9     End
+------------------------------------------------------------------
+
+/\xff/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+  0   6 Bra
+  3     \x{ff}
+  6   6 Ket
+  9     End
+------------------------------------------------------------------
+
+/\x{0041}\x{2262}\x{0391}\x{002e}/D8M
+Memory allocation (code space): 18
+------------------------------------------------------------------
+  0  14 Bra
+  3     A\x{2262}\x{391}.
+ 14  14 Ket
+ 17     End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'A'
+Need char = '.'
+    
+/\x{D55c}\x{ad6d}\x{C5B4}/D8M 
+Memory allocation (code space): 19
+------------------------------------------------------------------
+  0  15 Bra
+  3     \x{d55c}\x{ad6d}\x{c5b4}
+ 15  15 Ket
+ 18     End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 237
+Need char = 180
+
+/\x{65e5}\x{672c}\x{8a9e}/D8M
+Memory allocation (code space): 19
+------------------------------------------------------------------
+  0  15 Bra
+  3     \x{65e5}\x{672c}\x{8a9e}
+ 15  15 Ket
+ 18     End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 230
+Need char = 158
+
+/[\x{100}]/8BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+  0  11 Bra
+  3     [\x{100}]
+ 11  11 Ket
+ 14     End
+------------------------------------------------------------------
+
+/[Z\x{100}]/8BM
+Memory allocation (code space): 47
+------------------------------------------------------------------
+  0  43 Bra
+  3     [Z\x{100}]
+ 43  43 Ket
+ 46     End
+------------------------------------------------------------------
+
+/^[\x{100}\E-\Q\E\x{150}]/B8M
+Memory allocation (code space): 18
+------------------------------------------------------------------
+  0  14 Bra
+  3     ^
+  4     [\x{100}-\x{150}]
+ 14  14 Ket
+ 17     End
+------------------------------------------------------------------
+
+/^[\QÄ€\E-\QÅ\E]/B8M
+Memory allocation (code space): 18
+------------------------------------------------------------------
+  0  14 Bra
+  3     ^
+  4     [\x{100}-\x{150}]
+ 14  14 Ket
+ 17     End
+------------------------------------------------------------------
+
+/^[\QÄ€\E-\QÅ\E/B8M
+Failed: missing terminating ] for character class at offset 15
+
+/[\p{L}]/BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+  0  11 Bra
+  3     [\p{L}]
+ 11  11 Ket
+ 14     End
+------------------------------------------------------------------
+
+/[\p{^L}]/BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+  0  11 Bra
+  3     [\P{L}]
+ 11  11 Ket
+ 14     End
+------------------------------------------------------------------
+
+/[\P{L}]/BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+  0  11 Bra
+  3     [\P{L}]
+ 11  11 Ket
+ 14     End
+------------------------------------------------------------------
+
+/[\P{^L}]/BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+  0  11 Bra
+  3     [\p{L}]
+ 11  11 Ket
+ 14     End
+------------------------------------------------------------------
+
+/[abc\p{L}\x{0660}]/8BM
+Memory allocation (code space): 50
+------------------------------------------------------------------
+  0  46 Bra
+  3     [a-c\p{L}\x{660}]
+ 46  46 Ket
+ 49     End
+------------------------------------------------------------------
+
+/[\p{Nd}]/8BM
+Memory allocation (code space): 15
+------------------------------------------------------------------
+  0  11 Bra
+  3     [\p{Nd}]
+ 11  11 Ket
+ 14     End
+------------------------------------------------------------------
+
+/[\p{Nd}+-]+/8BM
+Memory allocation (code space): 48
+------------------------------------------------------------------
+  0  44 Bra
+  3     [+\-\p{Nd}]+
+ 44  44 Ket
+ 47     End
+------------------------------------------------------------------
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iBM
+Memory allocation (code space): 25
+------------------------------------------------------------------
+  0  21 Bra
+  3  NC A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ 21  21 Ket
+ 24     End
+------------------------------------------------------------------
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8BM
+Memory allocation (code space): 25
+------------------------------------------------------------------
+  0  21 Bra
+  3     A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ 21  21 Ket
+ 24     End
+------------------------------------------------------------------
+
+/[\x{105}-\x{109}]/8iBM
+Memory allocation (code space): 17
+------------------------------------------------------------------
+  0  13 Bra
+  3     [\x{104}-\x{109}]
+ 13  13 Ket
+ 16     End
+------------------------------------------------------------------
+
+/( ( (?(1)0|) )*   )/xBM
+Memory allocation (code space): 38
+------------------------------------------------------------------
+  0  34 Bra
+  3  28 CBra 1
+  8     Brazero
+  9  19 SCBra 2
+ 14   8 Cond
+ 17   1 Cond ref
+ 20     0
+ 22   3 Alt
+ 25  11 Ket
+ 28  19 KetRmax
+ 31  28 Ket
+ 34  34 Ket
+ 37     End
+------------------------------------------------------------------
+
+/(  (?(1)0|)*   )/xBM
+Memory allocation (code space): 30
+------------------------------------------------------------------
+  0  26 Bra
+  3  20 CBra 1
+  8     Brazero
+  9   8 SCond
+ 12   1 Cond ref
+ 15     0
+ 17   3 Alt
+ 20  11 KetRmax
+ 23  20 Ket
+ 26  26 Ket
+ 29     End
+------------------------------------------------------------------
+
+/[a]/BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     a
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+
+/[a]/8BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     a
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+
+/[\xaa]/BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     \xaa
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+
+/[\xaa]/8BM
+Memory allocation (code space): 10
+------------------------------------------------------------------
+  0   6 Bra
+  3     \x{aa}
+  6   6 Ket
+  9     End
+------------------------------------------------------------------
+
+/[^a]/BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     [^a]
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+
+/[^a]/8BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     [^a]
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+
+/[^\xaa]/BM
+Memory allocation (code space): 9
+------------------------------------------------------------------
+  0   5 Bra
+  3     [^\xaa]
+  5   5 Ket
+  8     End
+------------------------------------------------------------------
+
+/[^\xaa]/8BM
+Memory allocation (code space): 40
+------------------------------------------------------------------
+  0  36 Bra
+  3     [\x00-\xa9\xab-\xff] (neg)
+ 36  36 Ket
+ 39     End
+------------------------------------------------------------------
+
+/ End of testinput10 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput2	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,9641 @@
+/(a)b|/I
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+
+/abc/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+    abc
+ 0: abc
+    defabc
+ 0: abc
+    \Aabc
+ 0: abc
+    *** Failers
+No match
+    \Adefabc
+No match
+    ABC
+No match
+
+/^abc/I
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+    abc
+ 0: abc
+    \Aabc
+ 0: abc
+    *** Failers
+No match
+    defabc
+No match
+    \Adefabc
+No match
+
+/a+bc/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'c'
+
+/a*bc/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+Need char = 'c'
+
+/a{3}bc/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'c'
+
+/(abc|a+z)/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+First char = 'a'
+No need char
+
+/^abc$/I
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+    abc
+ 0: abc
+    *** Failers
+No match
+    def\nabc
+No match
+
+/ab\idef/X
+Failed: unrecognized character follows \ at offset 3
+
+/(?X)ab\idef/X
+Failed: unrecognized character follows \ at offset 7
+
+/x{5,4}/
+Failed: numbers out of order in {} quantifier at offset 5
+
+/z{65536}/
+Failed: number too big in {} quantifier at offset 7
+
+/[abcd/
+Failed: missing terminating ] for character class at offset 5
+
+/(?X)[\B]/
+Failed: invalid escape sequence in character class at offset 6
+
+/[z-a]/
+Failed: range out of order in character class at offset 3
+
+/^*/
+Failed: nothing to repeat at offset 1
+
+/(abc/
+Failed: missing ) at offset 4
+
+/(?# abc/
+Failed: missing ) after comment at offset 7
+
+/(?z)abc/
+Failed: unrecognized character after (? or (?- at offset 2
+
+/.*b/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char at start or follows newline
+Need char = 'b'
+
+/.*?b/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char at start or follows newline
+Need char = 'b'
+
+/cat|dog|elephant/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+    this sentence eventually mentions a cat
+ 0: cat
+    this sentences rambles on and on for a while and then reaches elephant
+ 0: elephant
+
+/cat|dog|elephant/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: c d e 
+    this sentence eventually mentions a cat
+ 0: cat
+    this sentences rambles on and on for a while and then reaches elephant
+ 0: elephant
+
+/cat|dog|elephant/IiS
+Capturing subpattern count = 0
+Options: caseless
+No first char
+No need char
+Starting byte set: C D E c d e 
+    this sentence eventually mentions a CAT cat
+ 0: CAT
+    this sentences rambles on and on for a while to elephant ElePhant
+ 0: elephant
+
+/a|[bcd]/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: a b c d 
+
+/(a|[^\dZ])/IS
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+Starting byte set: \x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0a 
+  \x0b \x0c \x0d \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 
+  \x1a \x1b \x1c \x1d \x1e \x1f \x20 ! " # $ % & ' ( ) * + , - . / : ; < = > 
+  ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y [ \ ] ^ _ ` a b c d 
+  e f g h i j k l m n o p q r s t u v w x y z { | } ~ \x7f \x80 \x81 \x82 \x83 
+  \x84 \x85 \x86 \x87 \x88 \x89 \x8a \x8b \x8c \x8d \x8e \x8f \x90 \x91 \x92 
+  \x93 \x94 \x95 \x96 \x97 \x98 \x99 \x9a \x9b \x9c \x9d \x9e \x9f \xa0 \xa1 
+  \xa2 \xa3 \xa4 \xa5 \xa6 \xa7 \xa8 \xa9 \xaa \xab \xac \xad \xae \xaf \xb0 
+  \xb1 \xb2 \xb3 \xb4 \xb5 \xb6 \xb7 \xb8 \xb9 \xba \xbb \xbc \xbd \xbe \xbf 
+  \xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce 
+  \xcf \xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd 
+  \xde \xdf \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec 
+  \xed \xee \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf7 \xf8 \xf9 \xfa \xfb 
+  \xfc \xfd \xfe \xff 
+
+/(a|b)*[\s]/IS
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+Starting byte set: \x09 \x0a \x0c \x0d \x20 a b 
+
+/(ab\2)/
+Failed: reference to non-existent subpattern at offset 6
+
+/{4,5}abc/
+Failed: nothing to repeat at offset 4
+
+/(a)(b)(c)\2/I
+Capturing subpattern count = 3
+Max back reference = 2
+No options
+First char = 'a'
+Need char = 'c'
+    abcb
+ 0: abcb
+ 1: a
+ 2: b
+ 3: c
+    \O0abcb
+Matched, but too many substrings
+    \O3abcb
+Matched, but too many substrings
+ 0: abcb
+    \O6abcb
+Matched, but too many substrings
+ 0: abcb
+ 1: a
+    \O9abcb
+Matched, but too many substrings
+ 0: abcb
+ 1: a
+ 2: b
+    \O12abcb
+ 0: abcb
+ 1: a
+ 2: b
+ 3: c
+
+/(a)bc|(a)(b)\2/I
+Capturing subpattern count = 3
+Max back reference = 2
+No options
+First char = 'a'
+No need char
+    abc
+ 0: abc
+ 1: a
+    \O0abc
+Matched, but too many substrings
+    \O3abc
+Matched, but too many substrings
+ 0: abc
+    \O6abc
+ 0: abc
+ 1: a
+    aba
+ 0: aba
+ 1: <unset>
+ 2: a
+ 3: b
+    \O0aba
+Matched, but too many substrings
+    \O3aba
+Matched, but too many substrings
+ 0: aba
+    \O6aba
+Matched, but too many substrings
+ 0: aba
+ 1: <unset>
+    \O9aba
+Matched, but too many substrings
+ 0: aba
+ 1: <unset>
+ 2: a
+    \O12aba
+ 0: aba
+ 1: <unset>
+ 2: a
+ 3: b
+
+/abc$/IE
+Capturing subpattern count = 0
+Options: dollar_endonly
+First char = 'a'
+Need char = 'c'
+    abc
+ 0: abc
+    *** Failers
+No match
+    abc\n
+No match
+    abc\ndef
+No match
+
+/(a)(b)(c)(d)(e)\6/
+Failed: reference to non-existent subpattern at offset 17
+
+/the quick brown fox/I
+Capturing subpattern count = 0
+No options
+First char = 't'
+Need char = 'x'
+    the quick brown fox
+ 0: the quick brown fox
+    this is a line with the quick brown fox
+ 0: the quick brown fox
+
+/the quick brown fox/IA
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+    the quick brown fox
+ 0: the quick brown fox
+    *** Failers
+No match
+    this is a line with the quick brown fox
+No match
+
+/ab(?z)cd/
+Failed: unrecognized character after (? or (?- at offset 4
+
+/^abc|def/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+    abcdef
+ 0: abc
+    abcdef\B
+ 0: def
+
+/.*((abc)$|(def))/I
+Capturing subpattern count = 3
+Partial matching not supported
+No options
+First char at start or follows newline
+No need char
+    defabc
+ 0: defabc
+ 1: abc
+ 2: abc
+    \Zdefabc
+ 0: def
+ 1: def
+ 2: <unset>
+ 3: def
+
+/abc/IP
+    abc
+ 0: abc
+    *** Failers
+No match: POSIX code 17: match failed
+
+/^abc|def/IP
+    abcdef
+ 0: abc
+    abcdef\B
+ 0: def
+
+/.*((abc)$|(def))/IP
+    defabc
+ 0: defabc
+ 1: abc
+ 2: abc
+    \Zdefabc
+ 0: def
+ 1: def
+ 3: def
+
+/the quick brown fox/IP
+    the quick brown fox
+ 0: the quick brown fox
+    *** Failers
+No match: POSIX code 17: match failed
+    The Quick Brown Fox
+No match: POSIX code 17: match failed
+
+/the quick brown fox/IPi
+    the quick brown fox
+ 0: the quick brown fox
+    The Quick Brown Fox
+ 0: The Quick Brown Fox
+
+/abc.def/IP
+    *** Failers
+No match: POSIX code 17: match failed
+    abc\ndef
+No match: POSIX code 17: match failed
+
+/abc$/IP
+    abc
+ 0: abc
+    abc\n
+ 0: abc
+
+/(abc)\2/IP
+Failed: POSIX code 15: bad back reference at offset 7     
+
+/(abc\1)/IP
+    abc
+No match: POSIX code 17: match failed
+
+/)/
+Failed: unmatched parentheses at offset 0
+
+/a[]b/
+Failed: missing terminating ] for character class at offset 4
+
+/[^aeiou ]{3,}/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+    co-processors, and for
+ 0: -pr
+
+/<.*>/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = '<'
+Need char = '>'
+    abc<def>ghi<klm>nop
+ 0: <def>ghi<klm>
+
+/<.*?>/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = '<'
+Need char = '>'
+    abc<def>ghi<klm>nop
+ 0: <def>
+
+/<.*>/IU
+Capturing subpattern count = 0
+Partial matching not supported
+Options: ungreedy
+First char = '<'
+Need char = '>'
+    abc<def>ghi<klm>nop
+ 0: <def>
+
+/(?U)<.*>/I
+Capturing subpattern count = 0
+Partial matching not supported
+Options: ungreedy
+First char = '<'
+Need char = '>'
+    abc<def>ghi<klm>nop
+ 0: <def>
+
+/<.*?>/IU
+Capturing subpattern count = 0
+Partial matching not supported
+Options: ungreedy
+First char = '<'
+Need char = '>'
+    abc<def>ghi<klm>nop
+ 0: <def>ghi<klm>
+
+/={3,}/IU
+Capturing subpattern count = 0
+Partial matching not supported
+Options: ungreedy
+First char = '='
+Need char = '='
+    abc========def
+ 0: ===
+
+/(?U)={3,}?/I
+Capturing subpattern count = 0
+Partial matching not supported
+Options: ungreedy
+First char = '='
+Need char = '='
+    abc========def
+ 0: ========
+
+/(?<!bar|cattle)foo/I
+Capturing subpattern count = 0
+No options
+First char = 'f'
+Need char = 'o'
+    foo
+ 0: foo
+    catfoo
+ 0: foo
+    *** Failers
+No match
+    the barfoo
+No match
+    and cattlefoo
+No match
+
+/(?<=a+)b/
+Failed: lookbehind assertion is not fixed length at offset 6
+
+/(?<=aaa|b{0,3})b/
+Failed: lookbehind assertion is not fixed length at offset 14
+
+/(?<!(foo)a\1)bar/
+Failed: lookbehind assertion is not fixed length at offset 12
+
+/(?i)abc/I
+Capturing subpattern count = 0
+Options: caseless
+First char = 'a' (caseless)
+Need char = 'c' (caseless)
+
+/(a|(?m)a)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/(?i)^1234/I
+Capturing subpattern count = 0
+Options: anchored caseless
+No first char
+No need char
+
+/(^b|(?i)^d)/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+
+/(?s).*/I
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored dotall
+No first char
+No need char
+
+/[abcd]/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: a b c d 
+
+/(?i)[abcd]/IS
+Capturing subpattern count = 0
+Options: caseless
+No first char
+No need char
+Starting byte set: A B C D a b c d 
+
+/(?m)[xy]|(b|c)/IS
+Capturing subpattern count = 1
+Options: multiline
+No first char
+No need char
+Starting byte set: b c x y 
+
+/(^a|^b)/Im
+Capturing subpattern count = 1
+Options: multiline
+First char at start or follows newline
+No need char
+
+/(?i)(^a|^b)/Im
+Capturing subpattern count = 1
+Options: caseless multiline
+First char at start or follows newline
+No need char
+
+/(a)(?(1)a|b|c)/
+Failed: conditional group contains more than two branches at offset 13
+
+/(?(?=a)a|b|c)/
+Failed: conditional group contains more than two branches at offset 12
+
+/(?(1a)/
+Failed: missing ) at offset 6
+
+/(?(1a))/
+Failed: reference to non-existent subpattern at offset 6
+
+/(?(?i))/
+Failed: assertion expected after (?( at offset 3
+
+/(?(abc))/
+Failed: reference to non-existent subpattern at offset 7
+
+/(?(?<ab))/
+Failed: syntax error in subpattern name (missing terminator) at offset 7
+
+/((?s)blah)\s+\1/I
+Capturing subpattern count = 1
+Max back reference = 1
+Partial matching not supported
+No options
+First char = 'b'
+Need char = 'h'
+
+/((?i)blah)\s+\1/I
+Capturing subpattern count = 1
+Max back reference = 1
+Partial matching not supported
+No options
+First char = 'b' (caseless)
+Need char = 'h' (caseless)
+
+/((?i)b)/IDZS
+------------------------------------------------------------------
+        Bra
+        CBra 1
+     01 Opt
+     NC b
+        Ket
+     00 Opt
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+First char = 'b' (caseless)
+No need char
+Study returned NULL
+
+/(a*b|(?i:c*(?-i)d))/IS
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+Starting byte set: C a b c d 
+
+/a$/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+    a
+ 0: a
+    a\n
+ 0: a
+    *** Failers
+No match
+    \Za
+No match
+    \Za\n
+No match
+
+/a$/Im
+Capturing subpattern count = 0
+Options: multiline
+First char = 'a'
+No need char
+    a
+ 0: a
+    a\n
+ 0: a
+    \Za\n
+ 0: a
+    *** Failers
+No match
+    \Za
+No match
+
+/\Aabc/Im
+Capturing subpattern count = 0
+Options: anchored multiline
+No first char
+No need char
+
+/^abc/Im
+Capturing subpattern count = 0
+Options: multiline
+First char at start or follows newline
+Need char = 'c'
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/I
+Capturing subpattern count = 5
+Partial matching not supported
+Options: anchored
+No first char
+No need char
+  aaaaabbbbbcccccdef
+ 0: aaaaabbbbbcccccdef
+ 1: aaaaabbbbbcccccdef
+ 2: aaaaa
+ 3: b
+ 4: bbbbccccc
+ 5: def
+
+/(?<=foo)[ab]/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: a b 
+
+/(?<!foo)(alpha|omega)/IS
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'a'
+Starting byte set: a o 
+
+/(?!alphabet)[ab]/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: a b 
+
+/(?<=foo\n)^bar/Im
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+Options: multiline
+No first char
+Need char = 'r'
+    foo\nbarbar
+ 0: bar
+    ***Failers
+No match
+    rhubarb
+No match
+    barbell
+No match
+    abc\nbarton
+No match
+
+/^(?<=foo\n)bar/Im
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+Options: multiline
+First char at start or follows newline
+Need char = 'r'
+    foo\nbarbar
+ 0: bar
+    ***Failers
+No match
+    rhubarb
+No match
+    barbell
+No match
+    abc\nbarton
+No match
+
+/(?>^abc)/Im
+Capturing subpattern count = 0
+Options: multiline
+First char at start or follows newline
+Need char = 'c'
+    abc
+ 0: abc
+    def\nabc
+ 0: abc
+    *** Failers
+No match
+    defabc
+No match
+
+/(?<=ab(c+)d)ef/
+Failed: lookbehind assertion is not fixed length at offset 11
+
+/(?<=ab(?<=c+)d)ef/
+Failed: lookbehind assertion is not fixed length at offset 12
+
+/(?<=ab(c|de)f)g/
+Failed: lookbehind assertion is not fixed length at offset 13
+
+/The next three are in testinput2 because they have variable length branches/
+
+/(?<=bullock|donkey)-cart/I
+Capturing subpattern count = 0
+No options
+First char = '-'
+Need char = 't'
+    the bullock-cart
+ 0: -cart
+    a donkey-cart race
+ 0: -cart
+    *** Failers
+No match
+    cart
+No match
+    horse-and-cart
+No match
+
+/(?<=ab(?i)x|y|z)/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/(?>.*)(?<=(abcd)|(xyz))/I
+Capturing subpattern count = 2
+Partial matching not supported
+No options
+First char at start or follows newline
+No need char
+    alphabetabcd
+ 0: alphabetabcd
+ 1: abcd
+    endingxyz
+ 0: endingxyz
+ 1: <unset>
+ 2: xyz
+
+/(?<=ab(?i)x(?-i)y|(?i)z|b)ZZ/I
+Capturing subpattern count = 0
+No options
+First char = 'Z'
+Need char = 'Z'
+    abxyZZ
+ 0: ZZ
+    abXyZZ
+ 0: ZZ
+    ZZZ
+ 0: ZZ
+    zZZ
+ 0: ZZ
+    bZZ
+ 0: ZZ
+    BZZ
+ 0: ZZ
+    *** Failers
+No match
+    ZZ
+No match
+    abXYZZ
+No match
+    zzz
+No match
+    bzz
+No match
+
+/(?<!(foo)a)bar/I
+Capturing subpattern count = 1
+No options
+First char = 'b'
+Need char = 'r'
+    bar
+ 0: bar
+    foobbar
+ 0: bar
+    *** Failers
+No match
+    fooabar
+No match
+
+/This one is here because Perl 5.005_02 doesn't fail it/I
+Capturing subpattern count = 0
+No options
+First char = 'T'
+Need char = 't'
+
+/^(a)?(?(1)a|b)+$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    *** Failers
+No match
+    a
+No match
+
+/This one is here because I think Perl 5.005_02 gets the setting of $1 wrong/I
+Capturing subpattern count = 0
+No options
+First char = 'T'
+Need char = 'g'
+
+/^(a\1?){4}$/I
+Capturing subpattern count = 1
+Max back reference = 1
+Options: anchored
+No first char
+No need char
+    aaaaaa
+ 0: aaaaaa
+ 1: aa
+
+/These are syntax tests from Perl 5.005/I
+Capturing subpattern count = 0
+No options
+First char = 'T'
+Need char = '5'
+
+/a[b-a]/
+Failed: range out of order in character class at offset 4
+
+/a[]b/
+Failed: missing terminating ] for character class at offset 4
+
+/a[/
+Failed: missing terminating ] for character class at offset 2
+
+/*a/
+Failed: nothing to repeat at offset 0
+
+/(*)b/
+Failed: nothing to repeat at offset 1
+
+/abc)/
+Failed: unmatched parentheses at offset 3
+
+/(abc/
+Failed: missing ) at offset 4
+
+/a**/
+Failed: nothing to repeat at offset 2
+
+/)(/
+Failed: unmatched parentheses at offset 0
+
+/\1/
+Failed: reference to non-existent subpattern at offset 2
+
+/\2/
+Failed: reference to non-existent subpattern at offset 2
+
+/(a)|\2/
+Failed: reference to non-existent subpattern at offset 6
+
+/a[b-a]/Ii
+Failed: range out of order in character class at offset 4
+
+/a[]b/Ii
+Failed: missing terminating ] for character class at offset 4
+
+/a[/Ii
+Failed: missing terminating ] for character class at offset 2
+
+/*a/Ii
+Failed: nothing to repeat at offset 0
+
+/(*)b/Ii
+Failed: nothing to repeat at offset 1
+
+/abc)/Ii
+Failed: unmatched parentheses at offset 3
+
+/(abc/Ii
+Failed: missing ) at offset 4
+
+/a**/Ii
+Failed: nothing to repeat at offset 2
+
+/)(/Ii
+Failed: unmatched parentheses at offset 0
+
+/:(?:/
+Failed: missing ) at offset 4
+
+/(?<%)b/
+Failed: unrecognized character after (?< at offset 3
+
+/a(?{)b/
+Failed: unrecognized character after (? or (?- at offset 3
+
+/a(?{{})b/
+Failed: unrecognized character after (? or (?- at offset 3
+
+/a(?{}})b/
+Failed: unrecognized character after (? or (?- at offset 3
+
+/a(?{"{"})b/
+Failed: unrecognized character after (? or (?- at offset 3
+
+/a(?{"{"}})b/
+Failed: unrecognized character after (? or (?- at offset 3
+
+/(?(1?)a|b)/
+Failed: malformed number or name after (?( at offset 4
+
+/[a[:xyz:/
+Failed: missing terminating ] for character class at offset 8
+
+/(?<=x+)y/
+Failed: lookbehind assertion is not fixed length at offset 6
+
+/a{37,17}/
+Failed: numbers out of order in {} quantifier at offset 7
+
+/abc/\
+Failed: \ at end of pattern at offset 4
+
+/abc/\P
+Failed: POSIX code 9: bad escape sequence at offset 4     
+
+/abc/\i
+Failed: \ at end of pattern at offset 4
+
+/(a)bc(d)/I
+Capturing subpattern count = 2
+No options
+First char = 'a'
+Need char = 'd'
+    abcd
+ 0: abcd
+ 1: a
+ 2: d
+    abcd\C2
+ 0: abcd
+ 1: a
+ 2: d
+ 2C d (1)
+    abcd\C5
+ 0: abcd
+ 1: a
+ 2: d
+copy substring 5 failed -7
+
+/(.{20})/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+    abcdefghijklmnopqrstuvwxyz
+ 0: abcdefghijklmnopqrst
+ 1: abcdefghijklmnopqrst
+    abcdefghijklmnopqrstuvwxyz\C1
+ 0: abcdefghijklmnopqrst
+ 1: abcdefghijklmnopqrst
+ 1C abcdefghijklmnopqrst (20)
+    abcdefghijklmnopqrstuvwxyz\G1
+ 0: abcdefghijklmnopqrst
+ 1: abcdefghijklmnopqrst
+ 1G abcdefghijklmnopqrst (20)
+
+/(.{15})/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+    abcdefghijklmnopqrstuvwxyz
+ 0: abcdefghijklmno
+ 1: abcdefghijklmno
+    abcdefghijklmnopqrstuvwxyz\C1\G1
+ 0: abcdefghijklmno
+ 1: abcdefghijklmno
+ 1C abcdefghijklmno (15)
+ 1G abcdefghijklmno (15)
+
+/(.{16})/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+    abcdefghijklmnopqrstuvwxyz
+ 0: abcdefghijklmnop
+ 1: abcdefghijklmnop
+    abcdefghijklmnopqrstuvwxyz\C1\G1\L
+ 0: abcdefghijklmnop
+ 1: abcdefghijklmnop
+ 1C abcdefghijklmnop (16)
+ 1G abcdefghijklmnop (16)
+ 0L abcdefghijklmnop
+ 1L abcdefghijklmnop
+
+/^(a|(bc))de(f)/I
+Capturing subpattern count = 3
+Options: anchored
+No first char
+No need char
+    adef\G1\G2\G3\G4\L
+ 0: adef
+ 1: a
+ 2: <unset>
+ 3: f
+ 1G a (1)
+ 2G  (0)
+ 3G f (1)
+get substring 4 failed -7
+ 0L adef
+ 1L a
+ 2L 
+ 3L f
+    bcdef\G1\G2\G3\G4\L
+ 0: bcdef
+ 1: bc
+ 2: bc
+ 3: f
+ 1G bc (2)
+ 2G bc (2)
+ 3G f (1)
+get substring 4 failed -7
+ 0L bcdef
+ 1L bc
+ 2L bc
+ 3L f
+    adefghijk\C0
+ 0: adef
+ 1: a
+ 2: <unset>
+ 3: f
+ 0C adef (4)
+
+/^abc\00def/I
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+    abc\00def\L\C0
+ 0: abc\x00def
+ 0C abc (7)
+ 0L abc
+
+/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
+)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
+)?)?)?)?)?)?)?)?)?otherword/I
+Capturing subpattern count = 8
+Partial matching not supported
+Contains explicit CR or LF match
+No options
+First char = 'w'
+Need char = 'd'
+
+/.*X/IDZ
+------------------------------------------------------------------
+        Bra
+        Any*
+        X
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char at start or follows newline
+Need char = 'X'
+
+/.*X/IDZs
+------------------------------------------------------------------
+        Bra
+        AllAny*
+        X
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored dotall
+No first char
+Need char = 'X'
+
+/(.*X|^B)/IDZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        Any*
+        X
+        Alt
+        ^
+        B
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+First char at start or follows newline
+No need char
+
+/(.*X|^B)/IDZs
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        AllAny*
+        X
+        Alt
+        ^
+        B
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+Options: anchored dotall
+No first char
+No need char
+
+/(?s)(.*X|^B)/IDZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        AllAny*
+        X
+        Alt
+        ^
+        B
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+Options: anchored dotall
+No first char
+No need char
+
+/(?s:.*X|^B)/IDZ
+------------------------------------------------------------------
+        Bra
+        Bra
+     04 Opt
+        AllAny*
+        X
+        Alt
+     04 Opt
+        ^
+        B
+        Ket
+     00 Opt
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored
+No first char
+No need char
+
+/\Biss\B/I+
+Capturing subpattern count = 0
+No options
+First char = 'i'
+Need char = 's'
+    Mississippi
+ 0: iss
+ 0+ issippi
+
+/\Biss\B/I+P
+    Mississippi
+ 0: iss
+ 0+ issippi
+
+/iss/IG+
+Capturing subpattern count = 0
+No options
+First char = 'i'
+Need char = 's'
+    Mississippi
+ 0: iss
+ 0+ issippi
+ 0: iss
+ 0+ ippi
+
+/\Biss\B/IG+
+Capturing subpattern count = 0
+No options
+First char = 'i'
+Need char = 's'
+    Mississippi
+ 0: iss
+ 0+ issippi
+
+/\Biss\B/Ig+
+Capturing subpattern count = 0
+No options
+First char = 'i'
+Need char = 's'
+    Mississippi
+ 0: iss
+ 0+ issippi
+ 0: iss
+ 0+ ippi
+    *** Failers
+No match
+    Mississippi\A
+No match
+
+/(?<=[Ms])iss/Ig+
+Capturing subpattern count = 0
+No options
+First char = 'i'
+Need char = 's'
+    Mississippi
+ 0: iss
+ 0+ issippi
+ 0: iss
+ 0+ ippi
+
+/(?<=[Ms])iss/IG+
+Capturing subpattern count = 0
+No options
+First char = 'i'
+Need char = 's'
+    Mississippi
+ 0: iss
+ 0+ issippi
+
+/^iss/Ig+
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+    ississippi
+ 0: iss
+ 0+ issippi
+
+/.*iss/Ig+
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char at start or follows newline
+Need char = 's'
+    abciss\nxyzisspqr
+ 0: abciss
+ 0+ \x0axyzisspqr
+ 0: xyziss
+ 0+ pqr
+
+/.i./I+g
+Capturing subpattern count = 0
+No options
+No first char
+Need char = 'i'
+    Mississippi
+ 0: Mis
+ 0+ sissippi
+ 0: sis
+ 0+ sippi
+ 0: sip
+ 0+ pi
+    Mississippi\A
+ 0: Mis
+ 0+ sissippi
+ 0: sis
+ 0+ sippi
+ 0: sip
+ 0+ pi
+    Missouri river
+ 0: Mis
+ 0+ souri river
+ 0: ri 
+ 0+ river
+ 0: riv
+ 0+ er
+    Missouri river\A
+ 0: Mis
+ 0+ souri river
+
+/^.is/I+g
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+    Mississippi
+ 0: Mis
+ 0+ sissippi
+
+/^ab\n/Ig+
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+Options: anchored
+No first char
+No need char
+    ab\nab\ncd
+ 0: ab\x0a
+ 0+ ab\x0acd
+
+/^ab\n/Img+
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+Options: multiline
+First char at start or follows newline
+Need char = 10
+    ab\nab\ncd
+ 0: ab\x0a
+ 0+ ab\x0acd
+ 0: ab\x0a
+ 0+ cd
+
+/abc/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+
+/abc|bac/I
+Capturing subpattern count = 0
+No options
+No first char
+Need char = 'c'
+
+/(abc|bac)/I
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'c'
+
+/(abc|(c|dc))/I
+Capturing subpattern count = 2
+No options
+No first char
+Need char = 'c'
+
+/(abc|(d|de)c)/I
+Capturing subpattern count = 2
+No options
+No first char
+Need char = 'c'
+
+/a*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+
+/a+/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+No need char
+
+/(baa|a+)/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+Need char = 'a'
+
+/a{0,3}/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+
+/baa{3,}/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'b'
+Need char = 'a'
+
+/"([^\\"]+|\\.)*"/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+First char = '"'
+Need char = '"'
+
+/(abc|ab[cd])/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/(a|.)/I
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+
+/a|ba|\w/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/abc(?=pqr)/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'r'
+
+/...(?<=abc)/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/abc(?!pqr)/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+
+/ab./I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+
+/ab[xyz]/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+
+/abc*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+
+/ab.c*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+
+/a.c*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+No need char
+
+/.c*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+
+/ac*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+No need char
+
+/(a.c*|b.c*)/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+
+/a.c*|aba/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+No need char
+
+/.+a/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+Need char = 'a'
+
+/(?=abcda)a.*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'a'
+
+/(?=a)a.*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+No need char
+
+/a(b)*/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/a\d*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+No need char
+
+/ab\d*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+
+/a(\d)*/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/abcde{0,0}/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'd'
+
+/ab\d+/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+
+/a(?(1)b)(.)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/a(?(1)bag|big)(.)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'g'
+
+/a(?(1)bag|big)*(.)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/a(?(1)bag|big)+(.)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'g'
+
+/a(?(1)b..|b..)(.)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+
+/ab\d{0}e/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'e'
+
+/a?b?/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+    a
+ 0: a
+    b
+ 0: b
+    ab
+ 0: ab
+    \
+ 0: 
+    *** Failers
+ 0: 
+    \N
+No match
+
+/|-/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+    abcd
+ 0: 
+    -abc
+ 0: 
+    \Nab-c
+ 0: -
+    *** Failers
+ 0: 
+    \Nabc
+No match
+
+/a*(b+)(z)(z)/IP
+    aaaabbbbzzzz
+ 0: aaaabbbbzz
+ 1: bbbb
+ 2: z
+ 3: z
+    aaaabbbbzzzz\O0
+    aaaabbbbzzzz\O1
+ 0: aaaabbbbzz
+    aaaabbbbzzzz\O2
+ 0: aaaabbbbzz
+ 1: bbbb
+    aaaabbbbzzzz\O3
+ 0: aaaabbbbzz
+ 1: bbbb
+ 2: z
+    aaaabbbbzzzz\O4
+ 0: aaaabbbbzz
+ 1: bbbb
+ 2: z
+ 3: z
+    aaaabbbbzzzz\O5
+ 0: aaaabbbbzz
+ 1: bbbb
+ 2: z
+ 3: z
+
+/^.?abcd/IS
+Capturing subpattern count = 0
+Options: anchored
+No first char
+Need char = 'd'
+Study returned NULL
+
+/\(             # ( at start
+  (?:           # Non-capturing bracket
+  (?>[^()]+)    # Either a sequence of non-brackets (no backtracking)
+  |             # Or
+  (?R)          # Recurse - i.e. nested bracketed string
+  )*            # Zero or more contents
+  \)            # Closing )
+  /Ix
+Capturing subpattern count = 0
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (abcd)
+ 0: (abcd)
+    (abcd)xyz
+ 0: (abcd)
+    xyz(abcd)
+ 0: (abcd)
+    (ab(xy)cd)pqr
+ 0: (ab(xy)cd)
+    (ab(xycd)pqr
+ 0: (xycd)
+    () abc ()
+ 0: ()
+    12(abcde(fsh)xyz(foo(bar))lmno)89
+ 0: (abcde(fsh)xyz(foo(bar))lmno)
+    *** Failers
+No match
+    abcd
+No match
+    abcd)
+No match
+    (abcd
+No match
+
+/\(  ( (?>[^()]+) | (?R) )* \) /Ixg
+Capturing subpattern count = 1
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (ab(xy)cd)pqr
+ 0: (ab(xy)cd)
+ 1: cd
+    1(abcd)(x(y)z)pqr
+ 0: (abcd)
+ 1: abcd
+ 0: (x(y)z)
+ 1: z
+
+/\(  (?: (?>[^()]+) | (?R) ) \) /Ix
+Capturing subpattern count = 0
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (abcd)
+ 0: (abcd)
+    (ab(xy)cd)
+ 0: (xy)
+    (a(b(c)d)e)
+ 0: (c)
+    ((ab))
+ 0: ((ab))
+    *** Failers
+No match
+    ()
+No match
+
+/\(  (?: (?>[^()]+) | (?R) )? \) /Ix
+Capturing subpattern count = 0
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    ()
+ 0: ()
+    12(abcde(fsh)xyz(foo(bar))lmno)89
+ 0: (fsh)
+
+/\(  ( (?>[^()]+) | (?R) )* \) /Ix
+Capturing subpattern count = 1
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (ab(xy)cd)
+ 0: (ab(xy)cd)
+ 1: cd
+
+/\( ( ( (?>[^()]+) | (?R) )* ) \) /Ix
+Capturing subpattern count = 2
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (ab(xy)cd)
+ 0: (ab(xy)cd)
+ 1: ab(xy)cd
+ 2: cd
+
+/\( (123)? ( ( (?>[^()]+) | (?R) )* ) \) /Ix
+Capturing subpattern count = 3
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (ab(xy)cd)
+ 0: (ab(xy)cd)
+ 1: <unset>
+ 2: ab(xy)cd
+ 3: cd
+    (123ab(xy)cd)
+ 0: (123ab(xy)cd)
+ 1: 123
+ 2: ab(xy)cd
+ 3: cd
+
+/\( ( (123)? ( (?>[^()]+) | (?R) )* ) \) /Ix
+Capturing subpattern count = 3
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (ab(xy)cd)
+ 0: (ab(xy)cd)
+ 1: ab(xy)cd
+ 2: <unset>
+ 3: cd
+    (123ab(xy)cd)
+ 0: (123ab(xy)cd)
+ 1: 123ab(xy)cd
+ 2: 123
+ 3: cd
+
+/\( (((((((((( ( (?>[^()]+) | (?R) )* )))))))))) \) /Ix
+Capturing subpattern count = 11
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (ab(xy)cd)
+ 0: (ab(xy)cd)
+ 1: ab(xy)cd
+ 2: ab(xy)cd
+ 3: ab(xy)cd
+ 4: ab(xy)cd
+ 5: ab(xy)cd
+ 6: ab(xy)cd
+ 7: ab(xy)cd
+ 8: ab(xy)cd
+ 9: ab(xy)cd
+10: ab(xy)cd
+11: cd
+
+/\( ( ( (?>[^()<>]+) | ((?>[^()]+)) | (?R) )* ) \) /Ix
+Capturing subpattern count = 3
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (abcd(xyz<p>qrs)123)
+ 0: (abcd(xyz<p>qrs)123)
+ 1: abcd(xyz<p>qrs)123
+ 2: 123
+ 3: <unset>
+
+/\( ( ( (?>[^()]+) | ((?R)) )* ) \) /Ix
+Capturing subpattern count = 3
+Partial matching not supported
+Options: extended
+First char = '('
+Need char = ')'
+    (ab(cd)ef)
+ 0: (ab(cd)ef)
+ 1: ab(cd)ef
+ 2: ef
+ 3: (cd)
+    (ab(cd(ef)gh)ij)
+ 0: (ab(cd(ef)gh)ij)
+ 1: ab(cd(ef)gh)ij
+ 2: ij
+ 3: (cd(ef)gh)
+
+/^[[:alnum:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [0-9A-Za-z]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:^alnum:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x00-/:-@[-`{-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:alpha:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [A-Za-z]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:^alpha:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x00-@[-`{-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/[_[:alpha:]]/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 
+  _ a b c d e f g h i j k l m n o p q r s t u v w x y z 
+
+/^[[:ascii:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x00-\x7f]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:^ascii:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x80-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:blank:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x09 ]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:^blank:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x00-\x08\x0a-\x1f!-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/[\n\x0b\x0c\x0d[:blank:]]/IS
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+No options
+No first char
+No need char
+Starting byte set: \x09 \x0a \x0b \x0c \x0d \x20 
+
+/^[[:cntrl:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x00-\x1f\x7f]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:digit:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [0-9]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:graph:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [!-~]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:lower:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [a-z]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:print:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [ -~]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:punct:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [!-/:-@[-`{-~]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:space:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x09-\x0d ]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:upper:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [A-Z]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:xdigit:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [0-9A-Fa-f]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:word:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [0-9A-Z_a-z]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:^cntrl:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [ -~\x80-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[12[:^digit:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x00-/12:-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/^[[:^blank:]]/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x00-\x08\x0a-\x1f!-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/[01[:alpha:]%]/DZ
+------------------------------------------------------------------
+        Bra
+        [%01A-Za-z]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[[.ch.]]/I
+Failed: POSIX collating elements are not supported at offset 1
+
+/[[=ch=]]/I
+Failed: POSIX collating elements are not supported at offset 1
+
+/[[:rhubarb:]]/I
+Failed: unknown POSIX class name at offset 3
+
+/[[:upper:]]/Ii
+Capturing subpattern count = 0
+Options: caseless
+No first char
+No need char
+    A
+ 0: A
+    a
+ 0: a
+
+/[[:lower:]]/Ii
+Capturing subpattern count = 0
+Options: caseless
+No first char
+No need char
+    A
+ 0: A
+    a
+ 0: a
+
+/((?-i)[[:lower:]])[[:lower:]]/Ii
+Capturing subpattern count = 1
+Options: caseless
+No first char
+No need char
+    ab
+ 0: ab
+ 1: a
+    aB
+ 0: aB
+ 1: a
+    *** Failers
+ 0: ai
+ 1: a
+    Ab
+No match
+    AB
+No match
+
+/[\200-\110]/I
+Failed: range out of order in character class at offset 9
+
+/^(?(0)f|b)oo/I
+Failed: invalid condition (?(0) at offset 6
+
+/This one's here because of the large output vector needed/I
+Capturing subpattern count = 0
+No options
+First char = 'T'
+Need char = 'd'
+
+/(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\w+)\s+(\270)/I
+Capturing subpattern count = 271
+Max back reference = 270
+Partial matching not supported
+No options
+No first char
+No need char
+    \O900 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 ABC ABC
+ 0: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 ABC ABC
+ 1: 1 
+ 2: 2 
+ 3: 3 
+ 4: 4 
+ 5: 5 
+ 6: 6 
+ 7: 7 
+ 8: 8 
+ 9: 9 
+10: 10 
+11: 11 
+12: 12 
+13: 13 
+14: 14 
+15: 15 
+16: 16 
+17: 17 
+18: 18 
+19: 19 
+20: 20 
+21: 21 
+22: 22 
+23: 23 
+24: 24 
+25: 25 
+26: 26 
+27: 27 
+28: 28 
+29: 29 
+30: 30 
+31: 31 
+32: 32 
+33: 33 
+34: 34 
+35: 35 
+36: 36 
+37: 37 
+38: 38 
+39: 39 
+40: 40 
+41: 41 
+42: 42 
+43: 43 
+44: 44 
+45: 45 
+46: 46 
+47: 47 
+48: 48 
+49: 49 
+50: 50 
+51: 51 
+52: 52 
+53: 53 
+54: 54 
+55: 55 
+56: 56 
+57: 57 
+58: 58 
+59: 59 
+60: 60 
+61: 61 
+62: 62 
+63: 63 
+64: 64 
+65: 65 
+66: 66 
+67: 67 
+68: 68 
+69: 69 
+70: 70 
+71: 71 
+72: 72 
+73: 73 
+74: 74 
+75: 75 
+76: 76 
+77: 77 
+78: 78 
+79: 79 
+80: 80 
+81: 81 
+82: 82 
+83: 83 
+84: 84 
+85: 85 
+86: 86 
+87: 87 
+88: 88 
+89: 89 
+90: 90 
+91: 91 
+92: 92 
+93: 93 
+94: 94 
+95: 95 
+96: 96 
+97: 97 
+98: 98 
+99: 99 
+100: 100 
+101: 101 
+102: 102 
+103: 103 
+104: 104 
+105: 105 
+106: 106 
+107: 107 
+108: 108 
+109: 109 
+110: 110 
+111: 111 
+112: 112 
+113: 113 
+114: 114 
+115: 115 
+116: 116 
+117: 117 
+118: 118 
+119: 119 
+120: 120 
+121: 121 
+122: 122 
+123: 123 
+124: 124 
+125: 125 
+126: 126 
+127: 127 
+128: 128 
+129: 129 
+130: 130 
+131: 131 
+132: 132 
+133: 133 
+134: 134 
+135: 135 
+136: 136 
+137: 137 
+138: 138 
+139: 139 
+140: 140 
+141: 141 
+142: 142 
+143: 143 
+144: 144 
+145: 145 
+146: 146 
+147: 147 
+148: 148 
+149: 149 
+150: 150 
+151: 151 
+152: 152 
+153: 153 
+154: 154 
+155: 155 
+156: 156 
+157: 157 
+158: 158 
+159: 159 
+160: 160 
+161: 161 
+162: 162 
+163: 163 
+164: 164 
+165: 165 
+166: 166 
+167: 167 
+168: 168 
+169: 169 
+170: 170 
+171: 171 
+172: 172 
+173: 173 
+174: 174 
+175: 175 
+176: 176 
+177: 177 
+178: 178 
+179: 179 
+180: 180 
+181: 181 
+182: 182 
+183: 183 
+184: 184 
+185: 185 
+186: 186 
+187: 187 
+188: 188 
+189: 189 
+190: 190 
+191: 191 
+192: 192 
+193: 193 
+194: 194 
+195: 195 
+196: 196 
+197: 197 
+198: 198 
+199: 199 
+200: 200 
+201: 201 
+202: 202 
+203: 203 
+204: 204 
+205: 205 
+206: 206 
+207: 207 
+208: 208 
+209: 209 
+210: 210 
+211: 211 
+212: 212 
+213: 213 
+214: 214 
+215: 215 
+216: 216 
+217: 217 
+218: 218 
+219: 219 
+220: 220 
+221: 221 
+222: 222 
+223: 223 
+224: 224 
+225: 225 
+226: 226 
+227: 227 
+228: 228 
+229: 229 
+230: 230 
+231: 231 
+232: 232 
+233: 233 
+234: 234 
+235: 235 
+236: 236 
+237: 237 
+238: 238 
+239: 239 
+240: 240 
+241: 241 
+242: 242 
+243: 243 
+244: 244 
+245: 245 
+246: 246 
+247: 247 
+248: 248 
+249: 249 
+250: 250 
+251: 251 
+252: 252 
+253: 253 
+254: 254 
+255: 255 
+256: 256 
+257: 257 
+258: 258 
+259: 259 
+260: 260 
+261: 261 
+262: 262 
+263: 263 
+264: 264 
+265: 265 
+266: 266 
+267: 267 
+268: 268 
+269: 269 
+270: ABC
+271: ABC
+
+/This one's here because Perl does this differently and PCRE can't at present/I
+Capturing subpattern count = 0
+No options
+First char = 'T'
+Need char = 't'
+
+/(main(O)?)+/I
+Capturing subpattern count = 2
+No options
+First char = 'm'
+Need char = 'n'
+    mainmain
+ 0: mainmain
+ 1: main
+    mainOmain
+ 0: mainOmain
+ 1: main
+ 2: O
+
+/These are all cases where Perl does it differently (nested captures)/I
+Capturing subpattern count = 1
+No options
+First char = 'T'
+Need char = 's'
+
+/^(a(b)?)+$/I
+Capturing subpattern count = 2
+Options: anchored
+No first char
+No need char
+    aba
+ 0: aba
+ 1: a
+ 2: b
+
+/^(aa(bb)?)+$/I
+Capturing subpattern count = 2
+Options: anchored
+No first char
+No need char
+    aabbaa
+ 0: aabbaa
+ 1: aa
+ 2: bb
+
+/^(aa|aa(bb))+$/I
+Capturing subpattern count = 2
+Options: anchored
+No first char
+No need char
+    aabbaa
+ 0: aabbaa
+ 1: aa
+ 2: bb
+
+/^(aa(bb)??)+$/I
+Capturing subpattern count = 2
+Options: anchored
+No first char
+No need char
+    aabbaa
+ 0: aabbaa
+ 1: aa
+ 2: bb
+
+/^(?:aa(bb)?)+$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    aabbaa
+ 0: aabbaa
+ 1: bb
+
+/^(aa(b(b))?)+$/I
+Capturing subpattern count = 3
+Options: anchored
+No first char
+No need char
+    aabbaa
+ 0: aabbaa
+ 1: aa
+ 2: bb
+ 3: b
+
+/^(?:aa(b(b))?)+$/I
+Capturing subpattern count = 2
+Options: anchored
+No first char
+No need char
+    aabbaa
+ 0: aabbaa
+ 1: bb
+ 2: b
+
+/^(?:aa(b(?:b))?)+$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    aabbaa
+ 0: aabbaa
+ 1: bb
+
+/^(?:aa(bb(?:b))?)+$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    aabbbaa
+ 0: aabbbaa
+ 1: bbb
+
+/^(?:aa(b(?:bb))?)+$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    aabbbaa
+ 0: aabbbaa
+ 1: bbb
+
+/^(?:aa(?:b(b))?)+$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    aabbaa
+ 0: aabbaa
+ 1: b
+
+/^(?:aa(?:b(bb))?)+$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    aabbbaa
+ 0: aabbbaa
+ 1: bb
+
+/^(aa(b(bb))?)+$/I
+Capturing subpattern count = 3
+Options: anchored
+No first char
+No need char
+    aabbbaa
+ 0: aabbbaa
+ 1: aa
+ 2: bbb
+ 3: bb
+
+/^(aa(bb(bb))?)+$/I
+Capturing subpattern count = 3
+Options: anchored
+No first char
+No need char
+    aabbbbaa
+ 0: aabbbbaa
+ 1: aa
+ 2: bbbb
+ 3: bb
+
+/--------------------------------------------------------------------/I
+Capturing subpattern count = 0
+No options
+First char = '-'
+Need char = '-'
+
+/#/IxDZ
+------------------------------------------------------------------
+        Bra
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: extended
+No first char
+No need char
+
+/a#/IxDZ
+------------------------------------------------------------------
+        Bra
+        a
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: extended
+First char = 'a'
+No need char
+
+/[\s]/DZ
+------------------------------------------------------------------
+        Bra
+        [\x09\x0a\x0c\x0d ]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[\S]/DZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\x08\x0b\x0e-\x1f!-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/a(?i)b/DZ
+------------------------------------------------------------------
+        Bra
+        a
+     01 Opt
+     NC b
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b' (caseless)
+    ab
+ 0: ab
+    aB
+ 0: aB
+    *** Failers
+No match
+    AB
+No match
+
+/(a(?i)b)/DZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        a
+     01 Opt
+     NC b
+        Ket
+     00 Opt
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b' (caseless)
+    ab
+ 0: ab
+ 1: ab
+    aB
+ 0: aB
+ 1: aB
+    *** Failers
+No match
+    AB
+No match
+
+/   (?i)abc/IxDZ
+------------------------------------------------------------------
+        Bra
+     NC abc
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless extended
+First char = 'a' (caseless)
+Need char = 'c' (caseless)
+
+/#this is a comment
+  (?i)abc/IxDZ
+------------------------------------------------------------------
+        Bra
+     NC abc
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless extended
+First char = 'a' (caseless)
+Need char = 'c' (caseless)
+
+/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/DZ
+------------------------------------------------------------------
+        Bra
+        123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = '1'
+Need char = '0'
+
+/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/DZ
+------------------------------------------------------------------
+        Bra
+        123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = '1'
+Need char = '0'
+
+/\Q\E/DZ
+------------------------------------------------------------------
+        Bra
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+    \
+ 0: 
+
+/\Q\Ex/DZ
+------------------------------------------------------------------
+        Bra
+        x
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'x'
+No need char
+
+/ \Q\E/DZ
+------------------------------------------------------------------
+        Bra
+         
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = ' '
+No need char
+
+/a\Q\E/DZ
+------------------------------------------------------------------
+        Bra
+        a
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+  abc
+ 0: a
+  bca
+ 0: a
+  bac
+ 0: a
+
+/a\Q\Eb/DZ
+------------------------------------------------------------------
+        Bra
+        ab
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+  abc
+ 0: ab
+
+/\Q\Eabc/DZ
+------------------------------------------------------------------
+        Bra
+        abc
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+
+/x*+\w/DZ
+------------------------------------------------------------------
+        Bra
+        x*+
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+    *** Failers
+ 0: F
+    xxxxx
+No match
+
+/x?+/DZ
+------------------------------------------------------------------
+        Bra
+        x?+
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/x++/DZ
+------------------------------------------------------------------
+        Bra
+        x++
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'x'
+No need char
+
+/x{1,3}+/DZ
+------------------------------------------------------------------
+        Bra
+        Once
+        x
+        x{0,2}
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'x'
+No need char
+
+/(x)*+/DZ
+------------------------------------------------------------------
+        Bra
+        Once
+        Brazero
+        CBra 1
+        x
+        KetRmax
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+
+/^(\w++|\s++)*$/I
+Capturing subpattern count = 1
+Partial matching not supported
+Options: anchored
+No first char
+No need char
+    now is the time for all good men to come to the aid of the party
+ 0: now is the time for all good men to come to the aid of the party
+ 1: party
+    *** Failers
+No match
+    this is not a line with only words and spaces!
+No match
+
+/(\d++)(\w)/I
+Capturing subpattern count = 2
+Partial matching not supported
+No options
+No first char
+No need char
+    12345a
+ 0: 12345a
+ 1: 12345
+ 2: a
+    *** Failers
+No match
+    12345+
+No match
+
+/a++b/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+    aaab
+ 0: aaab
+
+/(a++b)/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+    aaab
+ 0: aaab
+ 1: aaab
+
+/(a++)b/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+    aaab
+ 0: aaab
+ 1: aaa
+
+/([^()]++|\([^()]*\))+/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+    ((abc(ade)ufh()()x
+ 0: abc(ade)ufh()()x
+ 1: x
+
+/\(([^()]++|\([^()]+\))+\)/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+First char = '('
+Need char = ')'
+    (abc)
+ 0: (abc)
+ 1: abc
+    (abc(def)xyz)
+ 0: (abc(def)xyz)
+ 1: xyz
+    *** Failers
+No match
+    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+
+/(abc){1,3}+/DZ
+------------------------------------------------------------------
+        Bra
+        Once
+        CBra 1
+        abc
+        Ket
+        Brazero
+        Bra
+        CBra 1
+        abc
+        Ket
+        Brazero
+        CBra 1
+        abc
+        Ket
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'c'
+
+/a+?+/I
+Failed: nothing to repeat at offset 3
+
+/a{2,3}?+b/I
+Failed: nothing to repeat at offset 7
+
+/(?U)a+?+/I
+Failed: nothing to repeat at offset 7
+
+/a{2,3}?+b/IU
+Failed: nothing to repeat at offset 7
+
+/x(?U)a++b/DZ
+------------------------------------------------------------------
+        Bra
+        x
+        a++
+        b
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'x'
+Need char = 'b'
+    xaaaab
+ 0: xaaaab
+
+/(?U)xa++b/DZ
+------------------------------------------------------------------
+        Bra
+        x
+        a++
+        b
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: ungreedy
+First char = 'x'
+Need char = 'b'
+    xaaaab
+ 0: xaaaab
+
+/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        CBra 1
+        CBra 2
+        a+
+        Ket
+        CBra 3
+        [ab]+?
+        Ket
+        CBra 4
+        [bc]+
+        Ket
+        CBra 5
+        \w*
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 5
+Partial matching not supported
+Options: anchored
+No first char
+No need char
+
+/^x(?U)a+b/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        x
+        a++
+        b
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored
+No first char
+Need char = 'b'
+
+/^x(?U)(a+)b/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        x
+        CBra 1
+        a+?
+        Ket
+        b
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+Options: anchored
+No first char
+Need char = 'b'
+
+/[.x.]/I
+Failed: POSIX collating elements are not supported at offset 0
+
+/[=x=]/I
+Failed: POSIX collating elements are not supported at offset 0
+
+/[:x:]/I
+Failed: POSIX named classes are supported only within a class at offset 0
+
+/\l/I
+Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+
+/\L/I
+Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+
+/\N{name}/I
+Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+
+/\u/I
+Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+
+/\U/I
+Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+
+/[/I
+Failed: missing terminating ] for character class at offset 1
+
+/[a-/I
+Failed: missing terminating ] for character class at offset 3
+
+/[[:space:]/I
+Failed: missing terminating ] for character class at offset 10
+
+/[\s]/IDZ
+------------------------------------------------------------------
+        Bra
+        [\x09\x0a\x0c\x0d ]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[[:space:]]/IDZ
+------------------------------------------------------------------
+        Bra
+        [\x09-\x0d ]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[[:space:]abcde]/IDZ
+------------------------------------------------------------------
+        Bra
+        [\x09-\x0d a-e]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/< (?: (?(R) \d++  | [^<>]*+) | (?R)) * >/Ix
+Capturing subpattern count = 0
+Partial matching not supported
+Options: extended
+First char = '<'
+Need char = '>'
+    <>
+ 0: <>
+    <abcd>
+ 0: <abcd>
+    <abc <123> hij>
+ 0: <abc <123> hij>
+    <abc <def> hij>
+ 0: <def>
+    <abc<>def>
+ 0: <abc<>def>
+    <abc<>
+ 0: <>
+    *** Failers
+No match
+    <abc
+No match
+
+|8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDZ
+------------------------------------------------------------------
+        Bra
+        8J$WE<.rX+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+        \b
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = '8'
+Need char = 'X'
+
+|\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b|IDZ
+------------------------------------------------------------------
+        Bra
+        $<.X+ix[d1b!H#?vV0vrK:ZH1=2M>iV;?aPhFB<*vW@QW@sO9}cfZA-i'w%hKd6gt1UJP,15_#QY$M^Mss_U/]&LK9[5vQub^w[KDD<EjmhUZ?.akp2dF>qmj;2}YWFdYx.Ap]hjCPTP(n28k+3;o&WXqs/gOXdr$:r'do0;b4c(f_Gr="\4)[01T7ajQJvL$W~mL_sS/4h:x*[ZN=KLs&L5zX//>it,o:aU(;Z>pW&T7oP'2K^E:x9'c[%z-,64JQ5AeH_G#KijUKghQw^\vea3a?kka_G$8#`*kynsxzBLru']k_[7FrVx}^=$blx>s-N%j;D*aZDnsw:YKZ%Q.Kne9#hP?+b3(SOvL,^;&u5@?5C5Bhb=m-vEh_L15Jl]U)0RP6{q%L^_z5E'Dw6X
+        \b
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = '$'
+Need char = 'X'
+
+/(.*)\d+\1/I
+Capturing subpattern count = 1
+Max back reference = 1
+Partial matching not supported
+No options
+No first char
+No need char
+
+/(.*)\d+/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+First char at start or follows newline
+No need char
+
+/(.*)\d+\1/Is
+Capturing subpattern count = 1
+Max back reference = 1
+Partial matching not supported
+Options: dotall
+No first char
+No need char
+
+/(.*)\d+/Is
+Capturing subpattern count = 1
+Partial matching not supported
+Options: anchored dotall
+No first char
+No need char
+
+/(.*(xyz))\d+\2/I
+Capturing subpattern count = 2
+Max back reference = 2
+Partial matching not supported
+No options
+First char at start or follows newline
+Need char = 'z'
+
+/((.*))\d+\1/I
+Capturing subpattern count = 2
+Max back reference = 1
+Partial matching not supported
+No options
+No first char
+No need char
+    abc123bc
+ 0: bc123bc
+ 1: bc
+ 2: bc
+
+/a[b]/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+
+/(?=a).*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+First char = 'a'
+No need char
+
+/(?=abc).xyz/IiI
+Capturing subpattern count = 0
+Options: caseless
+First char = 'a' (caseless)
+Need char = 'z' (caseless)
+
+/(?=abc)(?i).xyz/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'z' (caseless)
+
+/(?=a)(?=b)/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+
+/(?=.)a/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+
+/((?=abcda)a)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'a'
+
+/((?=abcda)ab)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+
+/()a/I
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'a'
+
+/(?(1)ab|ac)(.)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/(?(1)abz|acz)(.)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'z'
+
+/(?(1)abz)(.)/I
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+
+/(?(1)abz)(1)23/I
+Capturing subpattern count = 1
+No options
+No first char
+Need char = '3'
+
+/(a)+/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+No need char
+
+/(a){2,3}/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'a'
+
+/(a)*/I
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+
+/[a]/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+No need char
+
+/[ab]/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[ab]/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: a b 
+
+/[^a]/I
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/\d456/I
+Capturing subpattern count = 0
+No options
+No first char
+Need char = '6'
+
+/\d456/IS
+Capturing subpattern count = 0
+No options
+No first char
+Need char = '6'
+Starting byte set: 0 1 2 3 4 5 6 7 8 9 
+
+/a^b/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+
+/^a/Im
+Capturing subpattern count = 0
+Options: multiline
+First char at start or follows newline
+Need char = 'a'
+  abcde
+ 0: a
+  xy\nabc
+ 0: a
+  *** Failers
+No match
+  xyabc
+No match
+
+/c|abc/I
+Capturing subpattern count = 0
+No options
+No first char
+Need char = 'c'
+
+/(?i)[ab]/IS
+Capturing subpattern count = 0
+Options: caseless
+No first char
+No need char
+Starting byte set: A B a b 
+
+/[ab](?i)cd/IS
+Capturing subpattern count = 0
+No options
+No first char
+Need char = 'd' (caseless)
+Starting byte set: a b 
+
+/abc(?C)def/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'f'
+    abcdef
+--->abcdef
+  0 ^  ^       d
+ 0: abcdef
+    1234abcdef
+--->1234abcdef
+  0     ^  ^       d
+ 0: abcdef
+    *** Failers
+No match
+    abcxyz
+No match
+    abcxyzf
+--->abcxyzf
+  0 ^  ^        d
+No match
+
+/abc(?C)de(?C1)f/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'f'
+    123abcdef
+--->123abcdef
+  0    ^  ^       d
+  1    ^    ^     f
+ 0: abcdef
+
+/(?C1)\dabc(?C2)def/I
+Capturing subpattern count = 0
+No options
+No first char
+Need char = 'f'
+    1234abcdef
+--->1234abcdef
+  1 ^              \d
+  1  ^             \d
+  1   ^            \d
+  1    ^           \d
+  2    ^   ^       d
+ 0: 4abcdef
+    *** Failers
+No match
+    abcdef
+--->abcdef
+  1 ^          \d
+  1  ^         \d
+  1   ^        \d
+  1    ^       \d
+  1     ^      \d
+  1      ^     \d
+No match
+
+/(?C255)ab/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'b'
+
+/(?C256)ab/I
+Failed: number after (?C is > 255 at offset 6
+
+/(?Cab)xx/I
+Failed: closing ) for (?C expected at offset 3
+
+/(?C12vr)x/I
+Failed: closing ) for (?C expected at offset 5
+
+/abc(?C)def/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'f'
+    *** Failers
+No match
+    \x83\x0\x61bcdef
+--->\x83\x00abcdef
+  0         ^  ^       d
+ 0: abcdef
+
+/(abc)(?C)de(?C1)f/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'f'
+    123abcdef
+--->123abcdef
+  0    ^  ^       d
+  1    ^    ^     f
+ 0: abcdef
+ 1: abc
+    123abcdef\C+
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: abc
+--->123abcdef
+       ^  ^       d
+Callout 1: last capture = 1
+ 0: <unset>
+ 1: abc
+--->123abcdef
+       ^    ^     f
+ 0: abcdef
+ 1: abc
+    123abcdef\C-
+ 0: abcdef
+ 1: abc
+    *** Failers
+No match
+    123abcdef\C!1
+--->123abcdef
+  0    ^  ^       d
+  1    ^    ^     f
+No match
+
+/(?C0)(abc(?C1))*/I
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+    abcabcabc
+--->abcabcabc
+  0 ^             (abc(?C1))*
+  1 ^  ^          )
+  1 ^     ^       )
+  1 ^        ^    )
+ 0: abcabcabc
+ 1: abc
+    abcabc\C!1!3
+--->abcabc
+  0 ^          (abc(?C1))*
+  1 ^  ^       )
+  1 ^     ^    )
+ 0: abcabc
+ 1: abc
+    *** Failers
+--->*** Failers
+  0 ^               (abc(?C1))*
+ 0: 
+    abcabcabc\C!1!3
+--->abcabcabc
+  0 ^             (abc(?C1))*
+  1 ^  ^          )
+  1 ^     ^       )
+  1 ^        ^    )
+ 0: abcabc
+ 1: abc
+
+/(\d{3}(?C))*/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+    123\C+
+Callout 0: last capture = -1
+ 0: <unset>
+--->123
+    ^  ^    )
+ 0: 123
+ 1: 123
+    123456\C+
+Callout 0: last capture = -1
+ 0: <unset>
+--->123456
+    ^  ^       )
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: 123
+--->123456
+    ^     ^    )
+ 0: 123456
+ 1: 456
+    123456789\C+
+Callout 0: last capture = -1
+ 0: <unset>
+--->123456789
+    ^  ^          )
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: 123
+--->123456789
+    ^     ^       )
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: 456
+--->123456789
+    ^        ^    )
+ 0: 123456789
+ 1: 789
+
+/((xyz)(?C)p|(?C1)xyzabc)/I
+Capturing subpattern count = 2
+No options
+First char = 'x'
+No need char
+    xyzabc\C+
+Callout 0: last capture = 2
+ 0: <unset>
+ 1: <unset>
+ 2: xyz
+--->xyzabc
+    ^  ^       p
+Callout 1: last capture = -1
+ 0: <unset>
+--->xyzabc
+    ^          x
+ 0: xyzabc
+ 1: xyzabc
+
+/(X)((xyz)(?C)p|(?C1)xyzabc)/I
+Capturing subpattern count = 3
+No options
+First char = 'X'
+Need char = 'x'
+    Xxyzabc\C+
+Callout 0: last capture = 3
+ 0: <unset>
+ 1: X
+ 2: <unset>
+ 3: xyz
+--->Xxyzabc
+    ^   ^       p
+Callout 1: last capture = 1
+ 0: <unset>
+ 1: X
+--->Xxyzabc
+    ^^          x
+ 0: Xxyzabc
+ 1: X
+ 2: xyzabc
+
+/(?=(abc))(?C)abcdef/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'f'
+    abcdef\C+
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: abc
+--->abcdef
+    ^          a
+ 0: abcdef
+ 1: abc
+
+/(?!(abc)(?C1)d)(?C2)abcxyz/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'z'
+    abcxyz\C+
+Callout 1: last capture = 1
+ 0: <unset>
+ 1: abc
+--->abcxyz
+    ^  ^       d
+Callout 2: last capture = -1
+ 0: <unset>
+--->abcxyz
+    ^          a
+ 0: abcxyz
+
+/(?<=(abc)(?C))xyz/I
+Capturing subpattern count = 1
+No options
+First char = 'x'
+Need char = 'z'
+   abcxyz\C+
+Callout 0: last capture = 1
+ 0: <unset>
+ 1: abc
+--->abcxyz
+       ^       )
+ 0: xyz
+ 1: abc
+
+/a(b+)(c*)(?C1)/I
+Capturing subpattern count = 2
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+    abbbbbccc\C*1
+--->abbbbbccc
+  1 ^        ^    
+Callout data = 1
+  1 ^       ^     
+Callout data = 1
+  1 ^      ^      
+Callout data = 1
+  1 ^     ^       
+Callout data = 1
+  1 ^    ^        
+Callout data = 1
+  1 ^   ^         
+Callout data = 1
+  1 ^  ^          
+Callout data = 1
+  1 ^ ^           
+Callout data = 1
+No match
+
+/a(b+?)(c*?)(?C1)/I
+Capturing subpattern count = 2
+Partial matching not supported
+No options
+First char = 'a'
+Need char = 'b'
+    abbbbbccc\C*1
+--->abbbbbccc
+  1 ^ ^           
+Callout data = 1
+  1 ^  ^          
+Callout data = 1
+  1 ^   ^         
+Callout data = 1
+  1 ^    ^        
+Callout data = 1
+  1 ^     ^       
+Callout data = 1
+  1 ^      ^      
+Callout data = 1
+  1 ^       ^     
+Callout data = 1
+  1 ^        ^    
+Callout data = 1
+No match
+
+/(?C)abc/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+
+/(?C)^abc/I
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/(?C)a|b/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: a b 
+
+/(?R)/I
+Failed: recursive call could loop indefinitely at offset 3
+
+/(a|(?R))/I
+Failed: recursive call could loop indefinitely at offset 6
+
+/(ab|(bc|(de|(?R))))/I
+Failed: recursive call could loop indefinitely at offset 15
+
+/x(ab|(bc|(de|(?R))))/I
+Capturing subpattern count = 3
+No options
+First char = 'x'
+No need char
+    xab
+ 0: xab
+ 1: ab
+    xbc
+ 0: xbc
+ 1: bc
+ 2: bc
+    xde
+ 0: xde
+ 1: de
+ 2: de
+ 3: de
+    xxab
+ 0: xxab
+ 1: xab
+ 2: xab
+ 3: xab
+    xxxab
+ 0: xxxab
+ 1: xxab
+ 2: xxab
+ 3: xxab
+    *** Failers
+No match
+    xyab
+No match
+
+/(ab|(bc|(de|(?1))))/I
+Failed: recursive call could loop indefinitely at offset 15
+
+/x(ab|(bc|(de|(?1)x)x)x)/I
+Failed: recursive call could loop indefinitely at offset 16
+
+/^([^()]|\((?1)*\))*$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    abc
+ 0: abc
+ 1: c
+    a(b)c
+ 0: a(b)c
+ 1: c
+    a(b(c))d
+ 0: a(b(c))d
+ 1: d
+    *** Failers)
+No match
+    a(b(c)d
+No match
+
+/^>abc>([^()]|\((?1)*\))*<xyz<$/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+Need char = '<'
+   >abc>123<xyz<
+ 0: >abc>123<xyz<
+ 1: 3
+   >abc>1(2)3<xyz<
+ 0: >abc>1(2)3<xyz<
+ 1: 3
+   >abc>(1(2)3)<xyz<
+ 0: >abc>(1(2)3)<xyz<
+ 1: (1(2)3)
+
+/(a(?1)b)/DZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        a
+        Once
+        Recurse
+        Ket
+        b
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+
+/(a(?1)+b)/DZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        a
+        Once
+        Recurse
+        KetRmax
+        b
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+
+/^\W*(?:((.)\W*(?1)\W*\2|)|((.)\W*(?3)\W*\4|\W*.\W*))\W*$/Ii
+Capturing subpattern count = 4
+Max back reference = 4
+Partial matching not supported
+Options: anchored caseless
+No first char
+No need char
+    1221
+ 0: 1221
+ 1: 1221
+ 2: 1
+    Satan, oscillate my metallic sonatas!
+ 0: Satan, oscillate my metallic sonatas!
+ 1: <unset>
+ 2: <unset>
+ 3: Satan, oscillate my metallic sonatas
+ 4: S
+    A man, a plan, a canal: Panama!
+ 0: A man, a plan, a canal: Panama!
+ 1: <unset>
+ 2: <unset>
+ 3: A man, a plan, a canal: Panama
+ 4: A
+    Able was I ere I saw Elba.
+ 0: Able was I ere I saw Elba.
+ 1: <unset>
+ 2: <unset>
+ 3: Able was I ere I saw Elba
+ 4: A
+    *** Failers
+No match
+    The quick brown fox
+No match
+
+/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/I
+Capturing subpattern count = 2
+Partial matching not supported
+Options: anchored
+No first char
+No need char
+    12
+ 0: 12
+ 1: 12
+    (((2+2)*-3)-7)
+ 0: (((2+2)*-3)-7)
+ 1: (((2+2)*-3)-7)
+ 2: -
+    -12
+ 0: -12
+ 1: -12
+    *** Failers
+No match
+    ((2+2)*-3)-7)
+No match
+
+/^(x(y|(?1){2})z)/I
+Capturing subpattern count = 2
+Options: anchored
+No first char
+No need char
+    xyz
+ 0: xyz
+ 1: xyz
+ 2: y
+    xxyzxyzz
+ 0: xxyzxyzz
+ 1: xxyzxyzz
+ 2: xyzxyz
+    *** Failers
+No match
+    xxyzz
+No match
+    xxyzxyzxyzz
+No match
+
+/((< (?: (?(R) \d++  | [^<>]*+) | (?2)) * >))/Ix
+Capturing subpattern count = 2
+Partial matching not supported
+Options: extended
+First char = '<'
+Need char = '>'
+    <>
+ 0: <>
+ 1: <>
+ 2: <>
+    <abcd>
+ 0: <abcd>
+ 1: <abcd>
+ 2: <abcd>
+    <abc <123> hij>
+ 0: <abc <123> hij>
+ 1: <abc <123> hij>
+ 2: <abc <123> hij>
+    <abc <def> hij>
+ 0: <def>
+ 1: <def>
+ 2: <def>
+    <abc<>def>
+ 0: <abc<>def>
+ 1: <abc<>def>
+ 2: <abc<>def>
+    <abc<>
+ 0: <>
+ 1: <>
+ 2: <>
+    *** Failers
+No match
+    <abc
+No match
+
+/(?1)/I
+Failed: reference to non-existent subpattern at offset 3
+
+/((?2)(abc)/I
+Failed: missing ) at offset 10
+
+/^(abc)def(?1)/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    abcdefabc
+ 0: abcdefabc
+ 1: abc
+
+/^(a|b|c)=(?1)+/I
+Capturing subpattern count = 1
+Options: anchored
+No first char
+No need char
+    a=a
+ 0: a=a
+ 1: a
+    a=b
+ 0: a=b
+ 1: a
+    a=bc
+ 0: a=bc
+ 1: a
+
+/^(a|b|c)=((?1))+/I
+Capturing subpattern count = 2
+Options: anchored
+No first char
+No need char
+    a=a
+ 0: a=a
+ 1: a
+ 2: a
+    a=b
+ 0: a=b
+ 1: a
+ 2: b
+    a=bc
+ 0: a=bc
+ 1: a
+ 2: c
+
+/a(?P<name1>b|c)d(?P<longername2>e)/DZ
+------------------------------------------------------------------
+        Bra
+        a
+        CBra 1
+        b
+        Alt
+        c
+        Ket
+        d
+        CBra 2
+        e
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  longername2   2
+  name1         1
+No options
+First char = 'a'
+Need char = 'e'
+    abde
+ 0: abde
+ 1: b
+ 2: e
+    acde
+ 0: acde
+ 1: c
+ 2: e
+
+/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/DZ
+------------------------------------------------------------------
+        Bra
+        Bra
+        a
+        CBra 1
+        c
+        CBra 2
+        d
+        Ket
+        Ket
+        Ket
+        CBra 3
+        a
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 3
+Named capturing subpatterns:
+  a   3
+  c   1
+  d   2
+No options
+First char = 'a'
+Need char = 'a'
+
+/(?P<a>a)...(?P=a)bbb(?P>a)d/DZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        a
+        Ket
+        Any
+        Any
+        Any
+        \1
+        bbb
+        Once
+        Recurse
+        Ket
+        d
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Max back reference = 1
+Named capturing subpatterns:
+  a   1
+No options
+First char = 'a'
+Need char = 'd'
+
+/^\W*(?:(?P<one>(?P<two>.)\W*(?P>one)\W*(?P=two)|)|(?P<three>(?P<four>.)\W*(?P>three)\W*(?P=four)|\W*.\W*))\W*$/Ii
+Capturing subpattern count = 4
+Max back reference = 4
+Named capturing subpatterns:
+  four    4
+  one     1
+  three   3
+  two     2
+Partial matching not supported
+Options: anchored caseless
+No first char
+No need char
+    1221
+ 0: 1221
+ 1: 1221
+ 2: 1
+    Satan, oscillate my metallic sonatas!
+ 0: Satan, oscillate my metallic sonatas!
+ 1: <unset>
+ 2: <unset>
+ 3: Satan, oscillate my metallic sonatas
+ 4: S
+    A man, a plan, a canal: Panama!
+ 0: A man, a plan, a canal: Panama!
+ 1: <unset>
+ 2: <unset>
+ 3: A man, a plan, a canal: Panama
+ 4: A
+    Able was I ere I saw Elba.
+ 0: Able was I ere I saw Elba.
+ 1: <unset>
+ 2: <unset>
+ 3: Able was I ere I saw Elba
+ 4: A
+    *** Failers
+No match
+    The quick brown fox
+No match
+
+/((?(R)a|b))\1(?1)?/I
+Capturing subpattern count = 1
+Max back reference = 1
+No options
+No first char
+No need char
+  bb
+ 0: bb
+ 1: b
+  bbaa
+ 0: bba
+ 1: b
+
+/(.*)a/Is
+Capturing subpattern count = 1
+Partial matching not supported
+Options: anchored dotall
+No first char
+Need char = 'a'
+
+/(.*)a\1/Is
+Capturing subpattern count = 1
+Max back reference = 1
+Partial matching not supported
+Options: dotall
+No first char
+Need char = 'a'
+
+/(.*)a(b)\2/Is
+Capturing subpattern count = 2
+Max back reference = 2
+Partial matching not supported
+Options: anchored dotall
+No first char
+Need char = 'b'
+
+/((.*)a|(.*)b)z/Is
+Capturing subpattern count = 3
+Partial matching not supported
+Options: anchored dotall
+No first char
+Need char = 'z'
+
+/((.*)a|(.*)b)z\1/Is
+Capturing subpattern count = 3
+Max back reference = 1
+Partial matching not supported
+Options: dotall
+No first char
+Need char = 'z'
+
+/((.*)a|(.*)b)z\2/Is
+Capturing subpattern count = 3
+Max back reference = 2
+Partial matching not supported
+Options: dotall
+No first char
+Need char = 'z'
+
+/((.*)a|(.*)b)z\3/Is
+Capturing subpattern count = 3
+Max back reference = 3
+Partial matching not supported
+Options: dotall
+No first char
+Need char = 'z'
+
+/((.*)a|^(.*)b)z\3/Is
+Capturing subpattern count = 3
+Max back reference = 3
+Partial matching not supported
+Options: anchored dotall
+No first char
+Need char = 'z'
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a/Is
+Capturing subpattern count = 31
+Partial matching not supported
+Options: anchored dotall
+No first char
+No need char
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\31/Is
+Capturing subpattern count = 31
+Max back reference = 31
+Partial matching not supported
+Options: dotall
+No first char
+No need char
+
+/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\32/Is
+Capturing subpattern count = 32
+Max back reference = 32
+Partial matching not supported
+Options: dotall
+No first char
+No need char
+
+/(a)(bc)/INDZ
+------------------------------------------------------------------
+        Bra
+        Bra
+        a
+        Ket
+        Bra
+        bc
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: no_auto_capture
+First char = 'a'
+Need char = 'c'
+  abc
+ 0: abc
+
+/(?P<one>a)(bc)/INDZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        a
+        Ket
+        Bra
+        bc
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  one   1
+Options: no_auto_capture
+First char = 'a'
+Need char = 'c'
+  abc
+ 0: abc
+ 1: a
+
+/(a)(?P<named>bc)/INDZ
+------------------------------------------------------------------
+        Bra
+        Bra
+        a
+        Ket
+        CBra 1
+        bc
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  named   1
+Options: no_auto_capture
+First char = 'a'
+Need char = 'c'
+
+/(a+)*zz/I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+Need char = 'z'
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzbbbbbb\M
+Minimum match() limit = 8
+Minimum match() recursion limit = 6
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazz
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  aaaaaaaaaaaaaz\M
+Minimum match() limit = 32768
+Minimum match() recursion limit = 42
+No match
+
+/(aaa(?C1)bbb|ab)/I
+Capturing subpattern count = 1
+No options
+First char = 'a'
+Need char = 'b'
+   aaabbb
+--->aaabbb
+  1 ^  ^       b
+ 0: aaabbb
+ 1: aaabbb
+   aaabbb\C*0
+--->aaabbb
+  1 ^  ^       b
+ 0: aaabbb
+ 1: aaabbb
+   aaabbb\C*1
+--->aaabbb
+  1 ^  ^       b
+Callout data = 1
+ 0: ab
+ 1: ab
+   aaabbb\C*-1
+--->aaabbb
+  1 ^  ^       b
+Callout data = -1
+No match
+
+/ab(?P<one>cd)ef(?P<two>gh)/I
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  one   1
+  two   2
+No options
+First char = 'a'
+Need char = 'h'
+    abcdefgh
+ 0: abcdefgh
+ 1: cd
+ 2: gh
+    abcdefgh\C1\Gtwo
+ 0: abcdefgh
+ 1: cd
+ 2: gh
+ 1C cd (2)
+  G gh (2) two
+    abcdefgh\Cone\Ctwo
+ 0: abcdefgh
+ 1: cd
+ 2: gh
+  C cd (2) one
+  C gh (2) two
+    abcdefgh\Cthree
+no parentheses with name "three"
+ 0: abcdefgh
+ 1: cd
+ 2: gh
+copy substring three failed -7
+
+/(?P<Tes>)(?P<Test>)/DZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        Ket
+        CBra 2
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  Tes    1
+  Test   2
+No options
+No first char
+No need char
+
+/(?P<Test>)(?P<Tes>)/DZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        Ket
+        CBra 2
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  Tes    2
+  Test   1
+No options
+No first char
+No need char
+
+/(?P<Z>zz)(?P<A>aa)/I
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  A   2
+  Z   1
+No options
+First char = 'z'
+Need char = 'a'
+    zzaa\CZ
+ 0: zzaa
+ 1: zz
+ 2: aa
+  C zz (2) Z
+    zzaa\CA
+ 0: zzaa
+ 1: zz
+ 2: aa
+  C aa (2) A
+
+/(?P<x>eks)(?P<x>eccs)/I
+Failed: two named subpatterns have the same name at offset 15
+
+/(?P<abc>abc(?P<def>def)(?P<abc>xyz))/I
+Failed: two named subpatterns have the same name at offset 30
+
+"\[((?P<elem>\d+)(,(?P>elem))*)\]"I
+Capturing subpattern count = 3
+Named capturing subpatterns:
+  elem   2
+Partial matching not supported
+No options
+First char = '['
+Need char = ']'
+    [10,20,30,5,5,4,4,2,43,23,4234]
+ 0: [10,20,30,5,5,4,4,2,43,23,4234]
+ 1: 10,20,30,5,5,4,4,2,43,23,4234
+ 2: 10
+ 3: ,4234
+    *** Failers
+No match
+    []
+No match
+
+"\[((?P<elem>\d+)(,(?P>elem))*)?\]"I
+Capturing subpattern count = 3
+Named capturing subpatterns:
+  elem   2
+Partial matching not supported
+No options
+First char = '['
+Need char = ']'
+    [10,20,30,5,5,4,4,2,43,23,4234]
+ 0: [10,20,30,5,5,4,4,2,43,23,4234]
+ 1: 10,20,30,5,5,4,4,2,43,23,4234
+ 2: 10
+ 3: ,4234
+    []
+ 0: []
+
+/(a(b(?2)c))?/DZ
+------------------------------------------------------------------
+        Bra
+        Brazero
+        CBra 1
+        a
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+No options
+No first char
+No need char
+
+/(a(b(?2)c))*/DZ
+------------------------------------------------------------------
+        Bra
+        Brazero
+        CBra 1
+        a
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        KetRmax
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+No options
+No first char
+No need char
+
+/(a(b(?2)c)){0,2}/DZ
+------------------------------------------------------------------
+        Bra
+        Brazero
+        Bra
+        CBra 1
+        a
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Brazero
+        CBra 1
+        a
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+No options
+No first char
+No need char
+
+/[ab]{1}+/DZ
+------------------------------------------------------------------
+        Bra
+        Once
+        [ab]{1,1}
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/Ii
+Capturing subpattern count = 3
+Partial matching not supported
+Options: caseless
+No first char
+Need char = 'g' (caseless)
+     Baby Bjorn Active Carrier - With free SHIPPING!!
+ 0: Baby Bjorn Active Carrier - With free SHIPPING!!
+ 1: Baby Bjorn Active Carrier - With free SHIPPING!!
+
+/((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/IiS
+Capturing subpattern count = 3
+Partial matching not supported
+Options: caseless
+No first char
+Need char = 'g' (caseless)
+Study returned NULL
+     Baby Bjorn Active Carrier - With free SHIPPING!!
+ 0: Baby Bjorn Active Carrier - With free SHIPPING!!
+ 1: Baby Bjorn Active Carrier - With free SHIPPING!!
+
+/a*.*b/ISDZ
+------------------------------------------------------------------
+        Bra
+        a*
+        Any*
+        b
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+Need char = 'b'
+Study returned NULL
+
+/(a|b)*.?c/ISDZ
+------------------------------------------------------------------
+        Bra
+        Brazero
+        CBra 1
+        a
+        Alt
+        b
+        KetRmax
+        Any?
+        c
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'c'
+Study returned NULL
+
+/abc(?C255)de(?C)f/DZ
+------------------------------------------------------------------
+        Bra
+        abc
+        Callout 255 10 1
+        de
+        Callout 0 16 1
+        f
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'f'
+
+/abcde/ICDZ
+------------------------------------------------------------------
+        Bra
+        Callout 255 0 1
+        a
+        Callout 255 1 1
+        b
+        Callout 255 2 1
+        c
+        Callout 255 3 1
+        d
+        Callout 255 4 1
+        e
+        Callout 255 5 0
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options:
+First char = 'a'
+Need char = 'e'
+  abcde
+--->abcde
+ +0 ^         a
+ +1 ^^        b
+ +2 ^ ^       c
+ +3 ^  ^      d
+ +4 ^   ^     e
+ +5 ^    ^    
+ 0: abcde
+  abcdfe
+--->abcdfe
+ +0 ^          a
+ +1 ^^         b
+ +2 ^ ^        c
+ +3 ^  ^       d
+ +4 ^   ^      e
+No match
+
+/a*b/ICDZ
+------------------------------------------------------------------
+        Bra
+        Callout 255 0 2
+        a*+
+        Callout 255 2 1
+        b
+        Callout 255 3 0
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options:
+No first char
+Need char = 'b'
+  ab
+--->ab
+ +0 ^      a*
+ +2 ^^     b
+ +3 ^ ^    
+ 0: ab
+  aaaab
+--->aaaab
+ +0 ^         a*
+ +2 ^   ^     b
+ +3 ^    ^    
+ 0: aaaab
+  aaaacb
+--->aaaacb
+ +0 ^          a*
+ +2 ^   ^      b
+ +0  ^         a*
+ +2  ^  ^      b
+ +0   ^        a*
+ +2   ^ ^      b
+ +0    ^       a*
+ +2    ^^      b
+ +0     ^      a*
+ +2     ^      b
+ +0      ^     a*
+ +2      ^     b
+ +3      ^^    
+ 0: b
+
+/a+b/ICDZ
+------------------------------------------------------------------
+        Bra
+        Callout 255 0 2
+        a++
+        Callout 255 2 1
+        b
+        Callout 255 3 0
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options:
+First char = 'a'
+Need char = 'b'
+  ab
+--->ab
+ +0 ^      a+
+ +2 ^^     b
+ +3 ^ ^    
+ 0: ab
+  aaaab
+--->aaaab
+ +0 ^         a+
+ +2 ^   ^     b
+ +3 ^    ^    
+ 0: aaaab
+  aaaacb
+--->aaaacb
+ +0 ^          a+
+ +2 ^   ^      b
+ +0  ^         a+
+ +2  ^  ^      b
+ +0   ^        a+
+ +2   ^ ^      b
+ +0    ^       a+
+ +2    ^^      b
+No match
+
+/(abc|def)x/ICDZ
+------------------------------------------------------------------
+        Bra
+        Callout 255 0 9
+        CBra 1
+        Callout 255 1 1
+        a
+        Callout 255 2 1
+        b
+        Callout 255 3 1
+        c
+        Callout 255 4 0
+        Alt
+        Callout 255 5 1
+        d
+        Callout 255 6 1
+        e
+        Callout 255 7 1
+        f
+        Callout 255 8 0
+        Ket
+        Callout 255 9 1
+        x
+        Callout 255 10 0
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options:
+No first char
+Need char = 'x'
+  abcx
+--->abcx
+ +0 ^        (abc|def)
+ +1 ^        a
+ +2 ^^       b
+ +3 ^ ^      c
+ +4 ^  ^     |
+ +9 ^  ^     x
++10 ^   ^    
+ 0: abcx
+ 1: abc
+  defx
+--->defx
+ +0 ^        (abc|def)
+ +1 ^        a
+ +5 ^        d
+ +6 ^^       e
+ +7 ^ ^      f
+ +8 ^  ^     )
+ +9 ^  ^     x
++10 ^   ^    
+ 0: defx
+ 1: def
+  abcdefzx
+--->abcdefzx
+ +0 ^            (abc|def)
+ +1 ^            a
+ +2 ^^           b
+ +3 ^ ^          c
+ +4 ^  ^         |
+ +9 ^  ^         x
+ +5 ^            d
+ +0  ^           (abc|def)
+ +1  ^           a
+ +5  ^           d
+ +0   ^          (abc|def)
+ +1   ^          a
+ +5   ^          d
+ +0    ^         (abc|def)
+ +1    ^         a
+ +5    ^         d
+ +6    ^^        e
+ +7    ^ ^       f
+ +8    ^  ^      )
+ +9    ^  ^      x
+ +0     ^        (abc|def)
+ +1     ^        a
+ +5     ^        d
+ +0      ^       (abc|def)
+ +1      ^       a
+ +5      ^       d
+ +0       ^      (abc|def)
+ +1       ^      a
+ +5       ^      d
+ +0        ^     (abc|def)
+ +1        ^     a
+ +5        ^     d
+No match
+
+/(ab|cd){3,4}/IC
+Capturing subpattern count = 1
+Options:
+No first char
+No need char
+  ababab
+--->ababab
+ +0 ^          (ab|cd){3,4}
+ +1 ^          a
+ +2 ^^         b
+ +3 ^ ^        |
+ +1 ^ ^        a
+ +2 ^  ^       b
+ +3 ^   ^      |
+ +1 ^   ^      a
+ +2 ^    ^     b
+ +3 ^     ^    |
+ +1 ^     ^    a
+ +4 ^     ^    c
++12 ^     ^    
+ 0: ababab
+ 1: ab
+  abcdabcd
+--->abcdabcd
+ +0 ^            (ab|cd){3,4}
+ +1 ^            a
+ +2 ^^           b
+ +3 ^ ^          |
+ +1 ^ ^          a
+ +4 ^ ^          c
+ +5 ^  ^         d
+ +6 ^   ^        )
+ +1 ^   ^        a
+ +2 ^    ^       b
+ +3 ^     ^      |
+ +1 ^     ^      a
+ +4 ^     ^      c
+ +5 ^      ^     d
+ +6 ^       ^    )
++12 ^       ^    
+ 0: abcdabcd
+ 1: cd
+  abcdcdcdcdcd
+--->abcdcdcdcdcd
+ +0 ^                (ab|cd){3,4}
+ +1 ^                a
+ +2 ^^               b
+ +3 ^ ^              |
+ +1 ^ ^              a
+ +4 ^ ^              c
+ +5 ^  ^             d
+ +6 ^   ^            )
+ +1 ^   ^            a
+ +4 ^   ^            c
+ +5 ^    ^           d
+ +6 ^     ^          )
+ +1 ^     ^          a
+ +4 ^     ^          c
+ +5 ^      ^         d
+ +6 ^       ^        )
++12 ^       ^        
+ 0: abcdcdcd
+ 1: cd
+
+/([ab]{,4}c|xy)/ICDZ
+------------------------------------------------------------------
+        Bra
+        Callout 255 0 14
+        CBra 1
+        Callout 255 1 4
+        [ab]
+        Callout 255 5 1
+        {
+        Callout 255 6 1
+        ,
+        Callout 255 7 1
+        4
+        Callout 255 8 1
+        }
+        Callout 255 9 1
+        c
+        Callout 255 10 0
+        Alt
+        Callout 255 11 1
+        x
+        Callout 255 12 1
+        y
+        Callout 255 13 0
+        Ket
+        Callout 255 14 0
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options:
+No first char
+No need char
+    Note: that { does NOT introduce a quantifier
+--->Note: that { does NOT introduce a quantifier
+ +0 ^                                                ([ab]{,4}c|xy)
+ +1 ^                                                [ab]
++11 ^                                                x
+ +0  ^                                               ([ab]{,4}c|xy)
+ +1  ^                                               [ab]
++11  ^                                               x
+ +0   ^                                              ([ab]{,4}c|xy)
+ +1   ^                                              [ab]
++11   ^                                              x
+ +0    ^                                             ([ab]{,4}c|xy)
+ +1    ^                                             [ab]
++11    ^                                             x
+ +0     ^                                            ([ab]{,4}c|xy)
+ +1     ^                                            [ab]
++11     ^                                            x
+ +0      ^                                           ([ab]{,4}c|xy)
+ +1      ^                                           [ab]
++11      ^                                           x
+ +0       ^                                          ([ab]{,4}c|xy)
+ +1       ^                                          [ab]
++11       ^                                          x
+ +0        ^                                         ([ab]{,4}c|xy)
+ +1        ^                                         [ab]
++11        ^                                         x
+ +0         ^                                        ([ab]{,4}c|xy)
+ +1         ^                                        [ab]
+ +5         ^^                                       {
++11         ^                                        x
+ +0          ^                                       ([ab]{,4}c|xy)
+ +1          ^                                       [ab]
++11          ^                                       x
+ +0           ^                                      ([ab]{,4}c|xy)
+ +1           ^                                      [ab]
++11           ^                                      x
+ +0            ^                                     ([ab]{,4}c|xy)
+ +1            ^                                     [ab]
++11            ^                                     x
+ +0             ^                                    ([ab]{,4}c|xy)
+ +1             ^                                    [ab]
++11             ^                                    x
+ +0              ^                                   ([ab]{,4}c|xy)
+ +1              ^                                   [ab]
++11              ^                                   x
+ +0               ^                                  ([ab]{,4}c|xy)
+ +1               ^                                  [ab]
++11               ^                                  x
+ +0                ^                                 ([ab]{,4}c|xy)
+ +1                ^                                 [ab]
++11                ^                                 x
+ +0                 ^                                ([ab]{,4}c|xy)
+ +1                 ^                                [ab]
++11                 ^                                x
+ +0                  ^                               ([ab]{,4}c|xy)
+ +1                  ^                               [ab]
++11                  ^                               x
+ +0                   ^                              ([ab]{,4}c|xy)
+ +1                   ^                              [ab]
++11                   ^                              x
+ +0                    ^                             ([ab]{,4}c|xy)
+ +1                    ^                             [ab]
++11                    ^                             x
+ +0                     ^                            ([ab]{,4}c|xy)
+ +1                     ^                            [ab]
++11                     ^                            x
+ +0                      ^                           ([ab]{,4}c|xy)
+ +1                      ^                           [ab]
++11                      ^                           x
+ +0                       ^                          ([ab]{,4}c|xy)
+ +1                       ^                          [ab]
++11                       ^                          x
+ +0                        ^                         ([ab]{,4}c|xy)
+ +1                        ^                         [ab]
++11                        ^                         x
+ +0                         ^                        ([ab]{,4}c|xy)
+ +1                         ^                        [ab]
++11                         ^                        x
+ +0                          ^                       ([ab]{,4}c|xy)
+ +1                          ^                       [ab]
++11                          ^                       x
+ +0                           ^                      ([ab]{,4}c|xy)
+ +1                           ^                      [ab]
++11                           ^                      x
+ +0                            ^                     ([ab]{,4}c|xy)
+ +1                            ^                     [ab]
++11                            ^                     x
+ +0                             ^                    ([ab]{,4}c|xy)
+ +1                             ^                    [ab]
++11                             ^                    x
+ +0                              ^                   ([ab]{,4}c|xy)
+ +1                              ^                   [ab]
++11                              ^                   x
+ +0                               ^                  ([ab]{,4}c|xy)
+ +1                               ^                  [ab]
++11                               ^                  x
+ +0                                ^                 ([ab]{,4}c|xy)
+ +1                                ^                 [ab]
++11                                ^                 x
+ +0                                 ^                ([ab]{,4}c|xy)
+ +1                                 ^                [ab]
+ +5                                 ^^               {
++11                                 ^                x
+ +0                                  ^               ([ab]{,4}c|xy)
+ +1                                  ^               [ab]
++11                                  ^               x
+ +0                                   ^              ([ab]{,4}c|xy)
+ +1                                   ^              [ab]
++11                                   ^              x
+ +0                                    ^             ([ab]{,4}c|xy)
+ +1                                    ^             [ab]
++11                                    ^             x
+ +0                                     ^            ([ab]{,4}c|xy)
+ +1                                     ^            [ab]
+ +5                                     ^^           {
++11                                     ^            x
+ +0                                      ^           ([ab]{,4}c|xy)
+ +1                                      ^           [ab]
++11                                      ^           x
+ +0                                       ^          ([ab]{,4}c|xy)
+ +1                                       ^          [ab]
++11                                       ^          x
+ +0                                        ^         ([ab]{,4}c|xy)
+ +1                                        ^         [ab]
++11                                        ^         x
+ +0                                         ^        ([ab]{,4}c|xy)
+ +1                                         ^        [ab]
++11                                         ^        x
+ +0                                          ^       ([ab]{,4}c|xy)
+ +1                                          ^       [ab]
++11                                          ^       x
+ +0                                           ^      ([ab]{,4}c|xy)
+ +1                                           ^      [ab]
++11                                           ^      x
+ +0                                            ^     ([ab]{,4}c|xy)
+ +1                                            ^     [ab]
++11                                            ^     x
+ +0                                             ^    ([ab]{,4}c|xy)
+ +1                                             ^    [ab]
++11                                             ^    x
+No match
+
+/([ab]{1,4}c|xy){4,5}?123/ICDZ
+------------------------------------------------------------------
+        Bra
+        Callout 255 0 21
+        CBra 1
+        Callout 255 1 9
+        [ab]{1,4}
+        Callout 255 10 1
+        c
+        Callout 255 11 0
+        Alt
+        Callout 255 12 1
+        x
+        Callout 255 13 1
+        y
+        Callout 255 14 0
+        Ket
+        CBra 1
+        Callout 255 1 9
+        [ab]{1,4}
+        Callout 255 10 1
+        c
+        Callout 255 11 0
+        Alt
+        Callout 255 12 1
+        x
+        Callout 255 13 1
+        y
+        Callout 255 14 0
+        Ket
+        CBra 1
+        Callout 255 1 9
+        [ab]{1,4}
+        Callout 255 10 1
+        c
+        Callout 255 11 0
+        Alt
+        Callout 255 12 1
+        x
+        Callout 255 13 1
+        y
+        Callout 255 14 0
+        Ket
+        CBra 1
+        Callout 255 1 9
+        [ab]{1,4}
+        Callout 255 10 1
+        c
+        Callout 255 11 0
+        Alt
+        Callout 255 12 1
+        x
+        Callout 255 13 1
+        y
+        Callout 255 14 0
+        Ket
+        Braminzero
+        CBra 1
+        Callout 255 1 9
+        [ab]{1,4}
+        Callout 255 10 1
+        c
+        Callout 255 11 0
+        Alt
+        Callout 255 12 1
+        x
+        Callout 255 13 1
+        y
+        Callout 255 14 0
+        Ket
+        Callout 255 21 1
+        1
+        Callout 255 22 1
+        2
+        Callout 255 23 1
+        3
+        Callout 255 24 0
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+Options:
+No first char
+Need char = '3'
+    aacaacaacaacaac123
+--->aacaacaacaacaac123
+ +0 ^                      ([ab]{1,4}c|xy){4,5}?
+ +1 ^                      [ab]{1,4}
++10 ^ ^                    c
++11 ^  ^                   |
+ +1 ^  ^                   [ab]{1,4}
++10 ^    ^                 c
++11 ^     ^                |
+ +1 ^     ^                [ab]{1,4}
++10 ^       ^              c
++11 ^        ^             |
+ +1 ^        ^             [ab]{1,4}
++10 ^          ^           c
++11 ^           ^          |
++21 ^           ^          1
+ +1 ^           ^          [ab]{1,4}
++10 ^             ^        c
++11 ^              ^       |
++21 ^              ^       1
++22 ^               ^      2
++23 ^                ^     3
++24 ^                 ^    
+ 0: aacaacaacaacaac123
+ 1: aac
+
+/\b.*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+  ab cd\>1
+ 0:  cd
+
+/\b.*/Is
+Capturing subpattern count = 0
+Partial matching not supported
+Options: dotall
+No first char
+No need char
+  ab cd\>1
+ 0:  cd
+
+/(?!.bcd).*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+  Xbcd12345
+ 0: bcd12345
+
+/abcde/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'e'
+    ab\P
+Partial match
+    abc\P
+Partial match
+    abcd\P
+Partial match
+    abcde\P
+ 0: abcde
+    the quick brown abc\P
+Partial match
+    ** Failers\P
+No match
+    the quick brown abxyz fox\P
+No match
+
+"^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/(20)?\d\d$"I
+Capturing subpattern count = 3
+Options: anchored
+No first char
+Need char = '/'
+    13/05/04\P
+ 0: 13/05/04
+ 1: 13
+ 2: 05
+    13/5/2004\P
+ 0: 13/5/2004
+ 1: 13
+ 2: 5
+ 3: 20
+    02/05/09\P
+ 0: 02/05/09
+ 1: 02
+ 2: 05
+    1\P
+Partial match
+    1/2\P
+Partial match
+    1/2/0\P
+Partial match
+    1/2/04\P
+ 0: 1/2/04
+ 1: 1
+ 2: 2
+    0\P
+Partial match
+    02/\P
+Partial match
+    02/0\P
+Partial match
+    02/1\P
+Partial match
+    ** Failers\P
+No match
+    \P
+No match
+    123\P
+No match
+    33/4/04\P
+No match
+    3/13/04\P
+No match
+    0/1/2003\P
+No match
+    0/\P
+No match
+    02/0/\P
+No match
+    02/13\P
+No match
+
+/0{0,2}ABC/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+Need char = 'C'
+
+/\d{3,}ABC/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+Need char = 'C'
+
+/\d*ABC/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+Need char = 'C'
+
+/[abc]+DE/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+Need char = 'E'
+
+/[abc]?123/I
+Capturing subpattern count = 0
+No options
+No first char
+Need char = '3'
+    123\P
+ 0: 123
+    a\P
+Partial match
+    b\P
+Partial match
+    c\P
+Partial match
+    c12\P
+Partial match
+    c123\P
+ 0: c123
+
+/^(?:\d){3,5}X/I
+Capturing subpattern count = 0
+Options: anchored
+No first char
+Need char = 'X'
+    1\P
+Partial match
+    123\P
+Partial match
+    123X
+ 0: 123X
+    1234\P
+Partial match
+    1234X
+ 0: 1234X
+    12345\P
+Partial match
+    12345X
+ 0: 12345X
+    *** Failers
+No match
+    1X
+No match
+    123456\P
+No match
+
+/abc/I>testsavedregex
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+Compiled regex written to testsavedregex
+<testsavedregex
+Compiled regex loaded from testsavedregex
+No study data
+    abc
+ 0: abc
+    ** Failers
+No match
+    bca
+No match
+
+/abc/IF>testsavedregex
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+Compiled regex written to testsavedregex
+<testsavedregex
+Compiled regex (byte-inverted) loaded from testsavedregex
+No study data
+    abc
+ 0: abc
+    ** Failers
+No match
+    bca
+No match
+
+/(a|b)/IS>testsavedregex
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+Starting byte set: a b 
+Compiled regex written to testsavedregex
+Study data written to testsavedregex
+<testsavedregex
+Compiled regex loaded from testsavedregex
+Study data loaded from testsavedregex
+    abc
+ 0: a
+ 1: a
+    ** Failers
+ 0: a
+ 1: a
+    def
+No match
+
+/(a|b)/ISF>testsavedregex
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+Starting byte set: a b 
+Compiled regex written to testsavedregex
+Study data written to testsavedregex
+<testsavedregex
+Compiled regex (byte-inverted) loaded from testsavedregex
+Study data loaded from testsavedregex
+    abc
+ 0: a
+ 1: a
+    ** Failers
+ 0: a
+ 1: a
+    def
+No match
+
+~<(\w+)/?>(.)*</(\1)>~smgI
+Capturing subpattern count = 3
+Max back reference = 1
+Partial matching not supported
+Options: multiline dotall
+First char = '<'
+Need char = '>'
+    <!DOCTYPE seite SYSTEM "http://www.lco.lineas.de/xmlCms.dtd">\n<seite>\n<dokumenteninformation>\n<seitentitel>Partner der LCO</seitentitel>\n<sprache>de</sprache>\n<seitenbeschreibung>Partner der LINEAS Consulting\nGmbH</seitenbeschreibung>\n<schluesselworte>LINEAS Consulting GmbH Hamburg\nPartnerfirmen</schluesselworte>\n<revisit>30 days</revisit>\n<robots>index,follow</robots>\n<menueinformation>\n<aktiv>ja</aktiv>\n<menueposition>3</menueposition>\n<menuetext>Partner</menuetext>\n</menueinformation>\n<lastedited>\n<autor>LCO</autor>\n<firma>LINEAS Consulting</firma>\n<datum>15.10.2003</datum>\n</lastedited>\n</dokumenteninformation>\n<inhalt>\n\n<absatzueberschrift>Die Partnerfirmen der LINEAS Consulting\nGmbH</absatzueberschrift>\n\n<absatz><link ziel="http://www.ca.com/" zielfenster="_blank">\n<bild name="logo_ca.gif" rahmen="no"/></link> <link\nziel="http://www.ey.com/" zielfenster="_blank"><bild\nname="logo_euy.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><link ziel="http://www.cisco.de/" zielfenster="_blank">\n<bild name="logo_cisco.gif" rahmen="ja"/></link></absatz>\n\n<absatz><link ziel="http://www.atelion.de/"\nzielfenster="_blank"><bild\nname="logo_atelion.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><link ziel="http://www.line-information.de/"\nzielfenster="_blank">\n<bild name="logo_line_information.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><bild name="logo_aw.gif" rahmen="no"/></absatz>\n\n<absatz><link ziel="http://www.incognis.de/"\nzielfenster="_blank"><bild\nname="logo_incognis.gif" rahmen="no"/></link></absatz>\n\n<absatz><link ziel="http://www.addcraft.com/"\nzielfenster="_blank"><bild\nname="logo_addcraft.gif" rahmen="no"/></link></absatz>\n\n<absatz><link ziel="http://www.comendo.com/"\nzielfenster="_blank"><bild\nname="logo_comendo.gif" rahmen="no"/></link></absatz>\n\n</inhalt>\n</seite>
+ 0: <seite>\x0a<dokumenteninformation>\x0a<seitentitel>Partner der LCO</seitentitel>\x0a<sprache>de</sprache>\x0a<seitenbeschreibung>Partner der LINEAS Consulting\x0aGmbH</seitenbeschreibung>\x0a<schluesselworte>LINEAS Consulting GmbH Hamburg\x0aPartnerfirmen</schluesselworte>\x0a<revisit>30 days</revisit>\x0a<robots>index,follow</robots>\x0a<menueinformation>\x0a<aktiv>ja</aktiv>\x0a<menueposition>3</menueposition>\x0a<menuetext>Partner</menuetext>\x0a</menueinformation>\x0a<lastedited>\x0a<autor>LCO</autor>\x0a<firma>LINEAS Consulting</firma>\x0a<datum>15.10.2003</datum>\x0a</lastedited>\x0a</dokumenteninformation>\x0a<inhalt>\x0a\x0a<absatzueberschrift>Die Partnerfirmen der LINEAS Consulting\x0aGmbH</absatzueberschrift>\x0a\x0a<absatz><link ziel="http://www.ca.com/" zielfenster="_blank">\x0a<bild name="logo_ca.gif" rahmen="no"/></link> <link\x0aziel="http://www.ey.com/" zielfenster="_blank"><bild\x0aname="logo_euy.gif" rahmen="no"/></link>\x0a</absatz>\x0a\x0a<absatz><link ziel="http://www.cisco.de/" zielfenster="_blank">\x0a<bild name="logo_cisco.gif" rahmen="ja"/></link></absatz>\x0a\x0a<absatz><link ziel="http://www.atelion.de/"\x0azielfenster="_blank"><bild\x0aname="logo_atelion.gif" rahmen="no"/></link>\x0a</absatz>\x0a\x0a<absatz><link ziel="http://www.line-information.de/"\x0azielfenster="_blank">\x0a<bild name="logo_line_information.gif" rahmen="no"/></link>\x0a</absatz>\x0a\x0a<absatz><bild name="logo_aw.gif" rahmen="no"/></absatz>\x0a\x0a<absatz><link ziel="http://www.incognis.de/"\x0azielfenster="_blank"><bild\x0aname="logo_incognis.gif" rahmen="no"/></link></absatz>\x0a\x0a<absatz><link ziel="http://www.addcraft.com/"\x0azielfenster="_blank"><bild\x0aname="logo_addcraft.gif" rahmen="no"/></link></absatz>\x0a\x0a<absatz><link ziel="http://www.comendo.com/"\x0azielfenster="_blank"><bild\x0aname="logo_comendo.gif" rahmen="no"/></link></absatz>\x0a\x0a</inhalt>\x0a</seite>
+ 1: seite
+ 2: \x0a
+ 3: seite
+
+/^a/IF
+Capturing subpattern count = 0
+Options: anchored
+No first char
+No need char
+
+/line\nbreak/I
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+No options
+First char = 'l'
+Need char = 'k'
+    this is a line\nbreak
+ 0: line\x0abreak
+    line one\nthis is a line\nbreak in the second line
+ 0: line\x0abreak
+
+/line\nbreak/If
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+Options: firstline
+First char = 'l'
+Need char = 'k'
+    this is a line\nbreak
+ 0: line\x0abreak
+    ** Failers
+No match
+    line one\nthis is a line\nbreak in the second line
+No match
+
+/line\nbreak/Imf
+Capturing subpattern count = 0
+Contains explicit CR or LF match
+Options: multiline firstline
+First char = 'l'
+Need char = 'k'
+    this is a line\nbreak
+ 0: line\x0abreak
+    ** Failers
+No match
+    line one\nthis is a line\nbreak in the second line
+No match
+
+/ab.cd/IP
+    ab-cd
+ 0: ab-cd
+    ab=cd
+ 0: ab=cd
+    ** Failers
+No match: POSIX code 17: match failed
+    ab\ncd
+No match: POSIX code 17: match failed
+
+/ab.cd/IPs
+    ab-cd
+ 0: ab-cd
+    ab=cd
+ 0: ab=cd
+    ab\ncd
+ 0: ab\x0acd
+
+/(?i)(?-i)AbCd/I
+Capturing subpattern count = 0
+No options
+First char = 'A'
+Need char = 'd'
+    AbCd
+ 0: AbCd
+    ** Failers
+No match
+    abcd
+No match
+
+/a{11111111111111111111}/I
+Failed: number too big in {} quantifier at offset 22
+
+/(){64294967295}/I
+Failed: number too big in {} quantifier at offset 14
+
+/(){2,4294967295}/I
+Failed: number too big in {} quantifier at offset 15
+
+"(?i:a)(?i:b)(?i:c)(?i:d)(?i:e)(?i:f)(?i:g)(?i:h)(?i:i)(?i:j)(k)(?i:l)A\1B"I
+Capturing subpattern count = 1
+Max back reference = 1
+No options
+First char = 'a' (caseless)
+Need char = 'B'
+    abcdefghijklAkB
+ 0: abcdefghijklAkB
+ 1: k
+
+"(?P<n0>a)(?P<n1>b)(?P<n2>c)(?P<n3>d)(?P<n4>e)(?P<n5>f)(?P<n6>g)(?P<n7>h)(?P<n8>i)(?P<n9>j)(?P<n10>k)(?P<n11>l)A\11B"I
+Capturing subpattern count = 12
+Max back reference = 11
+Named capturing subpatterns:
+  n0    1
+  n1    2
+  n10  11
+  n11  12
+  n2    3
+  n3    4
+  n4    5
+  n5    6
+  n6    7
+  n7    8
+  n8    9
+  n9   10
+No options
+First char = 'a'
+Need char = 'B'
+    abcdefghijklAkB
+ 0: abcdefghijklAkB
+ 1: a
+ 2: b
+ 3: c
+ 4: d
+ 5: e
+ 6: f
+ 7: g
+ 8: h
+ 9: i
+10: j
+11: k
+12: l
+
+"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)A\11B"I
+Capturing subpattern count = 12
+Max back reference = 11
+No options
+First char = 'a'
+Need char = 'B'
+    abcdefghijklAkB
+ 0: abcdefghijklAkB
+ 1: a
+ 2: b
+ 3: c
+ 4: d
+ 5: e
+ 6: f
+ 7: g
+ 8: h
+ 9: i
+10: j
+11: k
+12: l
+
+"(?P<name0>a)(?P<name1>a)(?P<name2>a)(?P<name3>a)(?P<name4>a)(?P<name5>a)(?P<name6>a)(?P<name7>a)(?P<name8>a)(?P<name9>a)(?P<name10>a)(?P<name11>a)(?P<name12>a)(?P<name13>a)(?P<name14>a)(?P<name15>a)(?P<name16>a)(?P<name17>a)(?P<name18>a)(?P<name19>a)(?P<name20>a)(?P<name21>a)(?P<name22>a)(?P<name23>a)(?P<name24>a)(?P<name25>a)(?P<name26>a)(?P<name27>a)(?P<name28>a)(?P<name29>a)(?P<name30>a)(?P<name31>a)(?P<name32>a)(?P<name33>a)(?P<name34>a)(?P<name35>a)(?P<name36>a)(?P<name37>a)(?P<name38>a)(?P<name39>a)(?P<name40>a)(?P<name41>a)(?P<name42>a)(?P<name43>a)(?P<name44>a)(?P<name45>a)(?P<name46>a)(?P<name47>a)(?P<name48>a)(?P<name49>a)(?P<name50>a)(?P<name51>a)(?P<name52>a)(?P<name53>a)(?P<name54>a)(?P<name55>a)(?P<name56>a)(?P<name57>a)(?P<name58>a)(?P<name59>a)(?P<name60>a)(?P<name61>a)(?P<name62>a)(?P<name63>a)(?P<name64>a)(?P<name65>a)(?P<name66>a)(?P<name67>a)(?P<name68>a)(?P<name69>a)(?P<name70>a)(?P<name71>a)(?P<name72>a)(?P<name73>a)(?P<name74>a)(?P<name75>a)(?P<name76>a)(?P<name77>a)(?P<name78>a)(?P<name79>a)(?P<name80>a)(?P<name81>a)(?P<name82>a)(?P<name83>a)(?P<name84>a)(?P<name85>a)(?P<name86>a)(?P<name87>a)(?P<name88>a)(?P<name89>a)(?P<name90>a)(?P<name91>a)(?P<name92>a)(?P<name93>a)(?P<name94>a)(?P<name95>a)(?P<name96>a)(?P<name97>a)(?P<name98>a)(?P<name99>a)(?P<name100>a)"I
+Capturing subpattern count = 101
+Named capturing subpatterns:
+  name0     1
+  name1     2
+  name10   11
+  name100 101
+  name11   12
+  name12   13
+  name13   14
+  name14   15
+  name15   16
+  name16   17
+  name17   18
+  name18   19
+  name19   20
+  name2     3
+  name20   21
+  name21   22
+  name22   23
+  name23   24
+  name24   25
+  name25   26
+  name26   27
+  name27   28
+  name28   29
+  name29   30
+  name3     4
+  name30   31
+  name31   32
+  name32   33
+  name33   34
+  name34   35
+  name35   36
+  name36   37
+  name37   38
+  name38   39
+  name39   40
+  name4     5
+  name40   41
+  name41   42
+  name42   43
+  name43   44
+  name44   45
+  name45   46
+  name46   47
+  name47   48
+  name48   49
+  name49   50
+  name5     6
+  name50   51
+  name51   52
+  name52   53
+  name53   54
+  name54   55
+  name55   56
+  name56   57
+  name57   58
+  name58   59
+  name59   60
+  name6     7
+  name60   61
+  name61   62
+  name62   63
+  name63   64
+  name64   65
+  name65   66
+  name66   67
+  name67   68
+  name68   69
+  name69   70
+  name7     8
+  name70   71
+  name71   72
+  name72   73
+  name73   74
+  name74   75
+  name75   76
+  name76   77
+  name77   78
+  name78   79
+  name79   80
+  name8     9
+  name80   81
+  name81   82
+  name82   83
+  name83   84
+  name84   85
+  name85   86
+  name86   87
+  name87   88
+  name88   89
+  name89   90
+  name9    10
+  name90   91
+  name91   92
+  name92   93
+  name93   94
+  name94   95
+  name95   96
+  name96   97
+  name97   98
+  name98   99
+  name99  100
+No options
+First char = 'a'
+Need char = 'a'
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Matched, but too many substrings
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+11: a
+12: a
+13: a
+14: a
+
+"(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)"I
+Capturing subpattern count = 101
+No options
+First char = 'a'
+Need char = 'a'
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Matched, but too many substrings
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+11: a
+12: a
+13: a
+14: a
+
+/[^()]*(?:\((?R)\)[^()]*)*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+    (this(and)that
+ 0: 
+    (this(and)that)
+ 0: (this(and)that)
+    (this(and)that)stuff
+ 0: (this(and)that)stuff
+
+/[^()]*(?:\((?>(?R))\)[^()]*)*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+    (this(and)that
+ 0: 
+    (this(and)that)
+ 0: (this(and)that)
+
+/[^()]*(?:\((?R)\))*[^()]*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+    (this(and)that
+ 0: 
+    (this(and)that)
+ 0: (this(and)that)
+
+/(?:\((?R)\))*[^()]*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+    (this(and)that
+ 0: 
+    (this(and)that)
+ 0: 
+    ((this))
+ 0: ((this))
+
+/(?:\((?R)\))|[^()]*/I
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+No need char
+    (this(and)that
+ 0: 
+    (this(and)that)
+ 0: 
+    (this)
+ 0: (this)
+    ((this))
+ 0: ((this))
+
+/a(b)c/IPN
+    abc
+Matched with REG_NOSUB
+
+/a(?P<name>b)c/IPN
+    abc
+Matched with REG_NOSUB
+
+/\x{100}/I
+Failed: character value in \x{...} sequence is too large at offset 6
+
+/\x{0000ff}/I
+Capturing subpattern count = 0
+No options
+First char = 255
+No need char
+
+/^((?P<A>a1)|(?P<A>a2)b)/I
+Failed: two named subpatterns have the same name at offset 17
+
+/^((?P<A>a1)|(?P<A>a2)b)/IJ
+Capturing subpattern count = 3
+Named capturing subpatterns:
+  A   2
+  A   3
+Options: anchored dupnames
+No first char
+No need char
+    a1b\CA
+ 0: a1
+ 1: a1
+ 2: a1
+  C a1 (2) A
+    a2b\CA
+ 0: a2b
+ 1: a2b
+ 2: <unset>
+ 3: a2
+  C a2 (2) A
+    ** Failers
+No match
+    a1b\CZ\CA
+no parentheses with name "Z"
+ 0: a1
+ 1: a1
+ 2: a1
+copy substring Z failed -7
+  C a1 (2) A
+
+/^(?P<A>a)(?P<A>b)/IJ
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  A   1
+  A   2
+Options: anchored dupnames
+No first char
+No need char
+    ab\CA
+ 0: ab
+ 1: a
+ 2: b
+  C a (1) A
+
+/^(?P<A>a)(?P<A>b)|cd/IJ
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  A   1
+  A   2
+Options: dupnames
+No first char
+No need char
+    ab\CA
+ 0: ab
+ 1: a
+ 2: b
+  C a (1) A
+    cd\CA
+ 0: cd
+copy substring A failed -7
+
+/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/IJ
+Capturing subpattern count = 4
+Named capturing subpatterns:
+  A   1
+  A   2
+  A   3
+  A   4
+Options: dupnames
+No first char
+No need char
+    cdefgh\CA
+ 0: cdefgh
+ 1: <unset>
+ 2: <unset>
+ 3: ef
+ 4: gh
+  C ef (2) A
+
+/^((?P<A>a1)|(?P<A>a2)b)/IJ
+Capturing subpattern count = 3
+Named capturing subpatterns:
+  A   2
+  A   3
+Options: anchored dupnames
+No first char
+No need char
+    a1b\GA
+ 0: a1
+ 1: a1
+ 2: a1
+  G a1 (2) A
+    a2b\GA
+ 0: a2b
+ 1: a2b
+ 2: <unset>
+ 3: a2
+  G a2 (2) A
+    ** Failers
+No match
+    a1b\GZ\GA
+no parentheses with name "Z"
+ 0: a1
+ 1: a1
+ 2: a1
+copy substring Z failed -7
+  G a1 (2) A
+
+/^(?P<A>a)(?P<A>b)/IJ
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  A   1
+  A   2
+Options: anchored dupnames
+No first char
+No need char
+    ab\GA
+ 0: ab
+ 1: a
+ 2: b
+  G a (1) A
+
+/^(?P<A>a)(?P<A>b)|cd/IJ
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  A   1
+  A   2
+Options: dupnames
+No first char
+No need char
+    ab\GA
+ 0: ab
+ 1: a
+ 2: b
+  G a (1) A
+    cd\GA
+ 0: cd
+copy substring A failed -7
+
+/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/IJ
+Capturing subpattern count = 4
+Named capturing subpatterns:
+  A   1
+  A   2
+  A   3
+  A   4
+Options: dupnames
+No first char
+No need char
+    cdefgh\GA
+ 0: cdefgh
+ 1: <unset>
+ 2: <unset>
+ 3: ef
+ 4: gh
+  G ef (2) A
+
+/(?J)^((?P<A>a1)|(?P<A>a2)b)/I
+Capturing subpattern count = 3
+Named capturing subpatterns:
+  A   2
+  A   3
+Options: anchored dupnames
+Duplicate name status changes
+No first char
+No need char
+    a1b\CA
+ 0: a1
+ 1: a1
+ 2: a1
+  C a1 (2) A
+    a2b\CA
+ 0: a2b
+ 1: a2b
+ 2: <unset>
+ 3: a2
+  C a2 (2) A
+
+/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<A>d)/I
+Failed: two named subpatterns have the same name at offset 37
+
+/ In this next test, J is not set at the outer level; consequently it isn't
+set in the pattern's options; consequently pcre_get_named_substring() produces
+a random value. /Ix
+Capturing subpattern count = 1
+Options: extended
+First char = 'I'
+Need char = 'e'
+
+/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<C>d)/I
+Capturing subpattern count = 4
+Named capturing subpatterns:
+  A   1
+  B   2
+  B   3
+  C   4
+Options: anchored
+Duplicate name status changes
+No first char
+No need char
+    a bc d\CA\CB\CC
+ 0: a bc d
+ 1: a
+ 2: b
+ 3: c
+ 4: d
+  C a (1) A
+  C b (1) B
+  C d (1) C
+
+/^(?P<A>a)?(?(A)a|b)/I
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  A   1
+Options: anchored
+No first char
+No need char
+    aabc
+ 0: aa
+ 1: a
+    bc
+ 0: b
+    ** Failers
+No match
+    abc
+No match
+
+/(?:(?(ZZ)a|b)(?P<ZZ>X))+/I
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  ZZ   1
+No options
+No first char
+Need char = 'X'
+    bXaX
+ 0: bXaX
+ 1: X
+
+/(?:(?(2y)a|b)(X))+/I
+Failed: reference to non-existent subpattern at offset 9
+
+/(?:(?(ZA)a|b)(?P<ZZ>X))+/I
+Failed: reference to non-existent subpattern at offset 9
+
+/(?:(?(ZZ)a|b)(?(ZZ)a|b)(?P<ZZ>X))+/I
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  ZZ   1
+No options
+No first char
+Need char = 'X'
+    bbXaaX
+ 0: bbXaaX
+ 1: X
+
+/(?:(?(ZZ)a|\(b\))\\(?P<ZZ>X))+/I
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  ZZ   1
+No options
+No first char
+Need char = 'X'
+    (b)\\Xa\\X
+ 0: (b)\Xa\X
+ 1: X
+
+/(?P<ABC/I
+Failed: syntax error in subpattern name (missing terminator) at offset 7
+
+/(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
+Capturing subpattern count = 1
+Max back reference = 1
+Named capturing subpatterns:
+  A   1
+No options
+No first char
+No need char
+    bXXaYYaY
+ 0: bXXaYYaY
+ 1: Y
+    bXYaXXaX
+ 0: bX
+ 1: X
+
+/()()()()()()()()()(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
+Capturing subpattern count = 10
+Max back reference = 10
+Named capturing subpatterns:
+  A  10
+No options
+No first char
+No need char
+    bXXaYYaY
+ 0: bXXaYYaY
+ 1: 
+ 2: 
+ 3: 
+ 4: 
+ 5: 
+ 6: 
+ 7: 
+ 8: 
+ 9: 
+10: Y
+
+/\777/I
+Failed: octal value is greater than \377 (not in UTF-8 mode) at offset 3
+
+/\s*,\s*/IS
+Capturing subpattern count = 0
+Partial matching not supported
+No options
+No first char
+Need char = ','
+Starting byte set: \x09 \x0a \x0c \x0d \x20 , 
+    \x0b,\x0b
+ 0: ,
+    \x0c,\x0d
+ 0: \x0c,\x0d
+
+/^abc/Im
+Capturing subpattern count = 0
+Options: multiline
+First char at start or follows newline
+Need char = 'c'
+    xyz\nabc
+ 0: abc
+    xyz\nabc\<lf>
+ 0: abc
+    xyz\r\nabc\<lf>
+ 0: abc
+    xyz\rabc\<cr>
+ 0: abc
+    xyz\r\nabc\<crlf>
+ 0: abc
+    ** Failers
+No match
+    xyz\nabc\<cr>
+No match
+    xyz\r\nabc\<cr>
+No match
+    xyz\nabc\<crlf>
+No match
+    xyz\rabc\<crlf>
+No match
+    xyz\rabc\<lf>
+No match
+
+/abc$/Im<lf>
+Capturing subpattern count = 0
+Options: multiline
+Forced newline sequence: LF
+First char = 'a'
+Need char = 'c'
+    xyzabc
+ 0: abc
+    xyzabc\n
+ 0: abc
+    xyzabc\npqr
+ 0: abc
+    xyzabc\r\<cr>
+ 0: abc
+    xyzabc\rpqr\<cr>
+ 0: abc
+    xyzabc\r\n\<crlf>
+ 0: abc
+    xyzabc\r\npqr\<crlf>
+ 0: abc
+    ** Failers
+No match
+    xyzabc\r
+No match
+    xyzabc\rpqr
+No match
+    xyzabc\r\n
+No match
+    xyzabc\r\npqr
+No match
+
+/^abc/Im<cr>
+Capturing subpattern count = 0
+Options: multiline
+Forced newline sequence: CR
+First char at start or follows newline
+Need char = 'c'
+    xyz\rabcdef
+ 0: abc
+    xyz\nabcdef\<lf>
+ 0: abc
+    ** Failers
+No match
+    xyz\nabcdef
+No match
+
+/^abc/Im<lf>
+Capturing subpattern count = 0
+Options: multiline
+Forced newline sequence: LF
+First char at start or follows newline
+Need char = 'c'
+    xyz\nabcdef
+ 0: abc
+    xyz\rabcdef\<cr>
+ 0: abc
+    ** Failers
+No match
+    xyz\rabcdef
+No match
+
+/^abc/Im<crlf>
+Capturing subpattern count = 0
+Options: multiline
+Forced newline sequence: CRLF
+First char at start or follows newline
+Need char = 'c'
+    xyz\r\nabcdef
+ 0: abc
+    xyz\rabcdef\<cr>
+ 0: abc
+    ** Failers
+No match
+    xyz\rabcdef
+No match
+
+/^abc/Im<bad>
+Unknown newline type at: <bad>
+
+
+/abc/I
+Capturing subpattern count = 0
+No options
+First char = 'a'
+Need char = 'c'
+    xyz\rabc\<bad>
+Unknown newline type at: <bad>
+    abc
+ 0: abc
+
+/.*/I<lf>
+Capturing subpattern count = 0
+Partial matching not supported
+Options:
+Forced newline sequence: LF
+First char at start or follows newline
+No need char
+    abc\ndef
+ 0: abc
+    abc\rdef
+ 0: abc\x0ddef
+    abc\r\ndef
+ 0: abc\x0d
+    \<cr>abc\ndef
+ 0: abc\x0adef
+    \<cr>abc\rdef
+ 0: abc
+    \<cr>abc\r\ndef
+ 0: abc
+    \<crlf>abc\ndef
+ 0: abc\x0adef
+    \<crlf>abc\rdef
+ 0: abc\x0ddef
+    \<crlf>abc\r\ndef
+ 0: abc
+
+/\w+(.)(.)?def/Is
+Capturing subpattern count = 2
+Partial matching not supported
+Options: dotall
+No first char
+Need char = 'f'
+    abc\ndef
+ 0: abc\x0adef
+ 1: \x0a
+    abc\rdef
+ 0: abc\x0ddef
+ 1: \x0d
+    abc\r\ndef
+ 0: abc\x0d\x0adef
+ 1: \x0d
+ 2: \x0a
+
++((?:\s|//.*\\n|/[*](?:\\n|.)*?[*]/)*)+I
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+   /* this is a C style comment */\M
+Minimum match() limit = 120
+Minimum match() recursion limit = 6
+ 0: /* this is a C style comment */
+ 1: /* this is a C style comment */
+
+/(?P<B>25[0-5]|2[0-4]\d|[01]?\d?\d)(?:\.(?P>B)){3}/I
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  B   1
+No options
+No first char
+Need char = '.'
+
+/()()()()()()()()()()()()()()()()()()()()
+ ()()()()()()()()()()()()()()()()()()()()
+ ()()()()()()()()()()()()()()()()()()()()
+ ()()()()()()()()()()()()()()()()()()()()
+ ()()()()()()()()()()()()()()()()()()()()
+ (.(.))/Ix
+Capturing subpattern count = 102
+Options: extended
+No first char
+No need char
+    XY\O400
+ 0: XY
+ 1: 
+ 2: 
+ 3: 
+ 4: 
+ 5: 
+ 6: 
+ 7: 
+ 8: 
+ 9: 
+10: 
+11: 
+12: 
+13: 
+14: 
+15: 
+16: 
+17: 
+18: 
+19: 
+20: 
+21: 
+22: 
+23: 
+24: 
+25: 
+26: 
+27: 
+28: 
+29: 
+30: 
+31: 
+32: 
+33: 
+34: 
+35: 
+36: 
+37: 
+38: 
+39: 
+40: 
+41: 
+42: 
+43: 
+44: 
+45: 
+46: 
+47: 
+48: 
+49: 
+50: 
+51: 
+52: 
+53: 
+54: 
+55: 
+56: 
+57: 
+58: 
+59: 
+60: 
+61: 
+62: 
+63: 
+64: 
+65: 
+66: 
+67: 
+68: 
+69: 
+70: 
+71: 
+72: 
+73: 
+74: 
+75: 
+76: 
+77: 
+78: 
+79: 
+80: 
+81: 
+82: 
+83: 
+84: 
+85: 
+86: 
+87: 
+88: 
+89: 
+90: 
+91: 
+92: 
+93: 
+94: 
+95: 
+96: 
+97: 
+98: 
+99: 
+100: 
+101: XY
+102: Y
+
+/(a*b|(?i:c*(?-i)d))/IS
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+Starting byte set: C a b c d 
+
+/()[ab]xyz/IS
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'z'
+Starting byte set: a b 
+
+/(|)[ab]xyz/IS
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'z'
+Starting byte set: a b 
+
+/(|c)[ab]xyz/IS
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'z'
+Starting byte set: a b c 
+
+/(|c?)[ab]xyz/IS
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'z'
+Starting byte set: a b c 
+
+/(d?|c?)[ab]xyz/IS
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'z'
+Starting byte set: a b c d 
+
+/(d?|c)[ab]xyz/IS
+Capturing subpattern count = 1
+No options
+No first char
+Need char = 'z'
+Starting byte set: a b c d 
+
+/^a*b\d/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        a*+
+        b
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored
+No first char
+Need char = 'b'
+
+/^a*+b\d/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        a*+
+        b
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored
+No first char
+Need char = 'b'
+
+/^a*?b\d/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        a*+
+        b
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored
+No first char
+Need char = 'b'
+
+/^a+A\d/DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        a++
+        A
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored
+No first char
+Need char = 'A'
+    aaaA5
+ 0: aaaA5
+    ** Failers
+No match
+    aaaa5
+No match
+
+/^a*A\d/IiDZ
+------------------------------------------------------------------
+        Bra
+        ^
+        a*
+     NC A
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: anchored caseless
+No first char
+Need char = 'A' (caseless)
+    aaaA5
+ 0: aaaA5
+    aaaa5
+ 0: aaaa5
+
+/(a*|b*)[cd]/IS
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+Starting byte set: a b c d 
+
+/(a+|b*)[cd]/IS
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+Starting byte set: a b c d 
+
+/(a*|b+)[cd]/IS
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+Starting byte set: a b c d 
+
+/(a+|b+)[cd]/IS
+Capturing subpattern count = 1
+Partial matching not supported
+No options
+No first char
+No need char
+Starting byte set: a b 
+
+/((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
+ ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
+ (((
+ a
+ ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
+ ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
+ )))
+/Ix
+Capturing subpattern count = 203
+Options: extended
+First char = 'a'
+No need char
+  large nest
+Matched, but too many substrings
+ 0: a
+ 1: a
+ 2: a
+ 3: a
+ 4: a
+ 5: a
+ 6: a
+ 7: a
+ 8: a
+ 9: a
+10: a
+11: a
+12: a
+13: a
+14: a
+
+/a*\d/BZ
+------------------------------------------------------------------
+        Bra
+        a*+
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/a*\D/BZ
+------------------------------------------------------------------
+        Bra
+        a*
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+
+/0*\d/BZ
+------------------------------------------------------------------
+        Bra
+        0*
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/0*\D/BZ
+------------------------------------------------------------------
+        Bra
+        0*+
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+
+/a*\s/BZ
+------------------------------------------------------------------
+        Bra
+        a*+
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+
+/a*\S/BZ
+------------------------------------------------------------------
+        Bra
+        a*
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+
+/ *\s/BZ
+------------------------------------------------------------------
+        Bra
+         *
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+
+/ *\S/BZ
+------------------------------------------------------------------
+        Bra
+         *+
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+
+/a*\w/BZ
+------------------------------------------------------------------
+        Bra
+        a*
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/a*\W/BZ
+------------------------------------------------------------------
+        Bra
+        a*+
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+
+/=*\w/BZ
+------------------------------------------------------------------
+        Bra
+        =*+
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/=*\W/BZ
+------------------------------------------------------------------
+        Bra
+        =*
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*a/BZ
+------------------------------------------------------------------
+        Bra
+        \d*+
+        a
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*2/BZ
+------------------------------------------------------------------
+        Bra
+        \d*
+        2
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\d/BZ
+------------------------------------------------------------------
+        Bra
+        \d*
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\D/BZ
+------------------------------------------------------------------
+        Bra
+        \d*+
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\s/BZ
+------------------------------------------------------------------
+        Bra
+        \d*+
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\S/BZ
+------------------------------------------------------------------
+        Bra
+        \d*
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\w/BZ
+------------------------------------------------------------------
+        Bra
+        \d*
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\W/BZ
+------------------------------------------------------------------
+        Bra
+        \d*+
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+
+/\D*a/BZ
+------------------------------------------------------------------
+        Bra
+        \D*
+        a
+        Ket
+        End
+------------------------------------------------------------------
+
+/\D*2/BZ
+------------------------------------------------------------------
+        Bra
+        \D*+
+        2
+        Ket
+        End
+------------------------------------------------------------------
+
+/\D*\d/BZ
+------------------------------------------------------------------
+        Bra
+        \D*+
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\D*\D/BZ
+------------------------------------------------------------------
+        Bra
+        \D*
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+
+/\D*\s/BZ
+------------------------------------------------------------------
+        Bra
+        \D*
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+
+/\D*\S/BZ
+------------------------------------------------------------------
+        Bra
+        \D*
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+
+/\D*\w/BZ
+------------------------------------------------------------------
+        Bra
+        \D*
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/\D*\W/BZ
+------------------------------------------------------------------
+        Bra
+        \D*
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*a/BZ
+------------------------------------------------------------------
+        Bra
+        \s*+
+        a
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*2/BZ
+------------------------------------------------------------------
+        Bra
+        \s*+
+        2
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*\d/BZ
+------------------------------------------------------------------
+        Bra
+        \s*+
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*\D/BZ
+------------------------------------------------------------------
+        Bra
+        \s*
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*\s/BZ
+------------------------------------------------------------------
+        Bra
+        \s*
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*\S/BZ
+------------------------------------------------------------------
+        Bra
+        \s*+
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*\w/BZ
+------------------------------------------------------------------
+        Bra
+        \s*+
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*\W/BZ
+------------------------------------------------------------------
+        Bra
+        \s*
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+
+/\S*a/BZ
+------------------------------------------------------------------
+        Bra
+        \S*
+        a
+        Ket
+        End
+------------------------------------------------------------------
+
+/\S*2/BZ
+------------------------------------------------------------------
+        Bra
+        \S*
+        2
+        Ket
+        End
+------------------------------------------------------------------
+
+/\S*\d/BZ
+------------------------------------------------------------------
+        Bra
+        \S*
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\S*\D/BZ
+------------------------------------------------------------------
+        Bra
+        \S*
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+
+/\S*\s/BZ
+------------------------------------------------------------------
+        Bra
+        \S*+
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+
+/\S*\S/BZ
+------------------------------------------------------------------
+        Bra
+        \S*
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+
+/\S*\w/BZ
+------------------------------------------------------------------
+        Bra
+        \S*
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/\S*\W/BZ
+------------------------------------------------------------------
+        Bra
+        \S*
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w*a/BZ
+------------------------------------------------------------------
+        Bra
+        \w*
+        a
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w*2/BZ
+------------------------------------------------------------------
+        Bra
+        \w*
+        2
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w*\d/BZ
+------------------------------------------------------------------
+        Bra
+        \w*
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w*\D/BZ
+------------------------------------------------------------------
+        Bra
+        \w*
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w*\s/BZ
+------------------------------------------------------------------
+        Bra
+        \w*+
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w*\S/BZ
+------------------------------------------------------------------
+        Bra
+        \w*
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w*\w/BZ
+------------------------------------------------------------------
+        Bra
+        \w*
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w*\W/BZ
+------------------------------------------------------------------
+        Bra
+        \w*+
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+
+/\W*a/BZ
+------------------------------------------------------------------
+        Bra
+        \W*+
+        a
+        Ket
+        End
+------------------------------------------------------------------
+
+/\W*2/BZ
+------------------------------------------------------------------
+        Bra
+        \W*+
+        2
+        Ket
+        End
+------------------------------------------------------------------
+
+/\W*\d/BZ
+------------------------------------------------------------------
+        Bra
+        \W*+
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\W*\D/BZ
+------------------------------------------------------------------
+        Bra
+        \W*
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+
+/\W*\s/BZ
+------------------------------------------------------------------
+        Bra
+        \W*
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+
+/\W*\S/BZ
+------------------------------------------------------------------
+        Bra
+        \W*
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+
+/\W*\w/BZ
+------------------------------------------------------------------
+        Bra
+        \W*+
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/\W*\W/BZ
+------------------------------------------------------------------
+        Bra
+        \W*
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^a]+a/BZ
+------------------------------------------------------------------
+        Bra
+        [^a]++
+        a
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^a]+a/BZi
+------------------------------------------------------------------
+        Bra
+        [^A]++
+     NC a
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^a]+A/BZi
+------------------------------------------------------------------
+        Bra
+        [^A]++
+     NC A
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^a]+b/BZ
+------------------------------------------------------------------
+        Bra
+        [^a]+
+        b
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^a]+\d/BZ
+------------------------------------------------------------------
+        Bra
+        [^a]+
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/a*[^a]/BZ
+------------------------------------------------------------------
+        Bra
+        a*
+        [^a]
+        Ket
+        End
+------------------------------------------------------------------
+
+/(?P<abc>x)(?P<xyz>y)/I
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  abc   1
+  xyz   2
+No options
+First char = 'x'
+Need char = 'y'
+    xy\Cabc\Cxyz
+ 0: xy
+ 1: x
+ 2: y
+  C x (1) abc
+  C y (1) xyz
+
+/(?<abc>x)(?'xyz'y)/I
+Capturing subpattern count = 2
+Named capturing subpatterns:
+  abc   1
+  xyz   2
+No options
+First char = 'x'
+Need char = 'y'
+    xy\Cabc\Cxyz
+ 0: xy
+ 1: x
+ 2: y
+  C x (1) abc
+  C y (1) xyz
+
+/(?<abc'x)(?'xyz'y)/I
+Failed: syntax error in subpattern name (missing terminator) at offset 6
+
+/(?<abc>x)(?'xyz>y)/I
+Failed: syntax error in subpattern name (missing terminator) at offset 15
+
+/(?P'abc'x)(?P<xyz>y)/I
+Failed: unrecognized character after (?P at offset 3
+
+/^(?:(?(ZZ)a|b)(?<ZZ>X))+/
+    bXaX
+ 0: bXaX
+ 1: X
+    bXbX
+ 0: bX
+ 1: X
+    ** Failers
+No match
+    aXaX
+No match
+    aXbX
+No match
+
+/^(?P>abc)(?<abcd>xxx)/
+Failed: reference to non-existent subpattern at offset 8
+
+/^(?P>abc)(?<abc>x|y)/
+    xx
+ 0: xx
+ 1: x
+    xy
+ 0: xy
+ 1: y
+    yy
+ 0: yy
+ 1: y
+    yx
+ 0: yx
+ 1: x
+
+/^(?P>abc)(?P<abc>x|y)/
+    xx
+ 0: xx
+ 1: x
+    xy
+ 0: xy
+ 1: y
+    yy
+ 0: yy
+ 1: y
+    yx
+ 0: yx
+ 1: x
+
+/^((?(abc)a|b)(?<abc>x|y))+/
+    bxay
+ 0: bxay
+ 1: ay
+ 2: y
+    bxby
+ 0: bx
+ 1: bx
+ 2: x
+    ** Failers
+No match
+    axby
+No match
+
+/^(((?P=abc)|X)(?<abc>x|y))+/
+    XxXxxx
+ 0: XxXxxx
+ 1: xx
+ 2: x
+ 3: x
+    XxXyyx
+ 0: XxXyyx
+ 1: yx
+ 2: y
+ 3: x
+    XxXyxx
+ 0: XxXy
+ 1: Xy
+ 2: X
+ 3: y
+    ** Failers
+No match
+    x
+No match
+
+/^(?1)(abc)/
+    abcabc
+ 0: abcabc
+ 1: abc
+
+/^(?:(?:\1|X)(a|b))+/
+    Xaaa
+ 0: Xaaa
+ 1: a
+    Xaba
+ 0: Xa
+ 1: a
+
+/^[\E\Qa\E-\Qz\E]+/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [a-z]+
+        Ket
+        End
+------------------------------------------------------------------
+
+/^[a\Q]bc\E]/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\]a-c]
+        Ket
+        End
+------------------------------------------------------------------
+
+/^[a-\Q\E]/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\-a]
+        Ket
+        End
+------------------------------------------------------------------
+
+/^(?P>abc)[()](?<abc>)/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        Once
+        Recurse
+        Ket
+        [()]
+        CBra 1
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/^((?(abc)y)[()](?P<abc>x))+/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        CBra 1
+        Cond
+      2 Cond ref
+        y
+        Ket
+        [()]
+        CBra 2
+        x
+        Ket
+        KetRmax
+        Ket
+        End
+------------------------------------------------------------------
+    (xy)x
+ 0: (xy)x
+ 1: y)x
+ 2: x
+
+/^(?P>abc)\Q()\E(?<abc>)/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        Once
+        Recurse
+        Ket
+        ()
+        CBra 1
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/^(?P>abc)[a\Q(]\E(](?<abc>)/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        Once
+        Recurse
+        Ket
+        [(\]a]
+        CBra 1
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/^(?P>abc) # this is (a comment)
+  (?<abc>)/BZx
+------------------------------------------------------------------
+        Bra
+        ^
+        Once
+        Recurse
+        Ket
+        CBra 1
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/^\W*(?:(?<one>(?<two>.)\W*(?&one)\W*\k<two>|)|(?<three>(?<four>.)\W*(?&three)\W*\k'four'|\W*.\W*))\W*$/Ii
+Capturing subpattern count = 4
+Max back reference = 4
+Named capturing subpatterns:
+  four    4
+  one     1
+  three   3
+  two     2
+Partial matching not supported
+Options: anchored caseless
+No first char
+No need char
+    1221
+ 0: 1221
+ 1: 1221
+ 2: 1
+    Satan, oscillate my metallic sonatas!
+ 0: Satan, oscillate my metallic sonatas!
+ 1: <unset>
+ 2: <unset>
+ 3: Satan, oscillate my metallic sonatas
+ 4: S
+    A man, a plan, a canal: Panama!
+ 0: A man, a plan, a canal: Panama!
+ 1: <unset>
+ 2: <unset>
+ 3: A man, a plan, a canal: Panama
+ 4: A
+    Able was I ere I saw Elba.
+ 0: Able was I ere I saw Elba.
+ 1: <unset>
+ 2: <unset>
+ 3: Able was I ere I saw Elba
+ 4: A
+    *** Failers
+No match
+    The quick brown fox
+No match
+
+/(?=(\w+))\1:/I
+Capturing subpattern count = 1
+Max back reference = 1
+Partial matching not supported
+No options
+No first char
+Need char = ':'
+    abcd:
+ 0: abcd:
+ 1: abcd
+
+/(?=(?'abc'\w+))\k<abc>:/I
+Capturing subpattern count = 1
+Max back reference = 1
+Named capturing subpatterns:
+  abc   1
+Partial matching not supported
+No options
+No first char
+Need char = ':'
+    abcd:
+ 0: abcd:
+ 1: abcd
+
+/(?'abc'\w+):\k<abc>{2}/
+    a:aaxyz
+ 0: a:aa
+ 1: a
+    ab:ababxyz
+ 0: ab:abab
+ 1: ab
+    ** Failers
+No match
+    a:axyz
+No match
+    ab:abxyz
+No match
+
+/(?'abc'a|b)(?<abc>d|e)\k<abc>{2}/J
+    adaa
+ 0: adaa
+ 1: a
+ 2: d
+    ** Failers
+No match
+    addd
+No match
+    adbb
+No match
+
+/(?'abc'a|b)(?<abc>d|e)(?&abc){2}/J
+    bdaa
+ 0: bdaa
+ 1: b
+ 2: d
+    bdab
+ 0: bdab
+ 1: b
+ 2: d
+    ** Failers
+No match
+    bddd
+No match
+
+/^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
+    abd
+ 0: abd
+ 1: a
+    ce
+ 0: ce
+
+/(?(<bc))/
+Failed: malformed number or name after (?( at offset 6
+
+/(?(''))/
+Failed: assertion expected after (?( at offset 4
+
+/(?('R')stuff)/
+Failed: reference to non-existent subpattern at offset 7
+
+/((abc (?(R) (?(R1)1) (?(R2)2) X  |  (?1)  (?2)   (?R) ))) /x
+    abcabc1Xabc2XabcXabcabc
+ 0: abcabc1Xabc2XabcX
+ 1: abcabc1Xabc2XabcX
+ 2: abcabc1Xabc2XabcX
+
+/(?<A> (?'B' abc (?(R) (?(R&A)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
+    abcabc1Xabc2XabcXabcabc
+ 0: abcabc1Xabc2XabcX
+ 1: abcabc1Xabc2XabcX
+ 2: abcabc1Xabc2XabcX
+
+/(?<A> (?'B' abc (?(R) (?(R&1)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
+Failed: reference to non-existent subpattern at offset 29
+
+/(?<1> (?'B' abc (?(R) (?(R&1)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
+    abcabc1Xabc2XabcXabcabc
+ 0: abcabc1Xabc2XabcX
+ 1: abcabc1Xabc2XabcX
+ 2: abcabc1Xabc2XabcX
+
+/^(?(DEFINE) (?<A> a) (?<B> b) )  (?&A) (?&B) /x
+    abcd
+ 0: ab
+ 1: <unset>
+ 2: <unset>
+
+/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
+  (?(DEFINE)
+  (?<NAME_PAT>[a-z]+)
+  (?<ADDRESS_PAT>\d+)
+  )/x
+    metcalfe 33
+ 0: metcalfe 33
+ 1: metcalfe
+ 2: 33
+ 3: <unset>
+ 4: <unset>
+
+/^(?(DEFINE) abc | xyz ) /x
+Failed: DEFINE group contains more than one branch at offset 22
+
+/(?(DEFINE) abc) xyz/xI
+Capturing subpattern count = 0
+Options: extended
+First char = 'x'
+Need char = 'z'
+
+/(?(DEFINE) abc){3} xyz/x
+Failed: repeating a DEFINE group is not allowed at offset 17
+
+/(a|)*\d/
+  \O0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+  \O0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+Matched, but too many substrings
+
+/^a.b/<lf>
+    a\rb
+ 0: a\x0db
+    a\nb\<cr>
+ 0: a\x0ab
+    a\x85b\<anycrlf> 
+ 0: a\x85b
+    ** Failers
+No match
+    a\nb
+No match
+    a\nb\<any>
+No match
+    a\rb\<cr>
+No match
+    a\rb\<any>
+No match
+    a\x85b\<any> 
+No match
+    a\rb\<anycrlf>
+No match
+
+/^abc./mgx<any>
+    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x85abc7 JUNK
+ 0: abc1
+ 0: abc2
+ 0: abc3
+ 0: abc4
+ 0: abc5
+ 0: abc6
+ 0: abc7
+
+/abc.$/mgx<any>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc7 abc9
+ 0: abc1
+ 0: abc2
+ 0: abc3
+ 0: abc4
+ 0: abc5
+ 0: abc6
+ 0: abc9
+
+/a/<cr><any>
+
+/a/<any><crlf>
+Failed: inconsistent NEWLINE options at offset 0
+
+/^a\Rb/<bsr_unicode>
+    a\nb
+ 0: a\x0ab
+    a\rb
+ 0: a\x0db
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x0bb
+ 0: a\x0bb
+    a\x0cb
+ 0: a\x0cb
+    a\x85b
+ 0: a\x85b
+    ** Failers
+No match
+    a\n\rb
+No match
+
+/^a\R*b/<bsr_unicode>
+    ab
+ 0: ab
+    a\nb
+ 0: a\x0ab
+    a\rb
+ 0: a\x0db
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x0bb
+ 0: a\x0bb
+    a\x0cb
+ 0: a\x0cb
+    a\x85b
+ 0: a\x85b
+    a\n\rb
+ 0: a\x0a\x0db
+    a\n\r\x85\x0cb
+ 0: a\x0a\x0d\x85\x0cb
+
+/^a\R+b/<bsr_unicode>
+    a\nb
+ 0: a\x0ab
+    a\rb
+ 0: a\x0db
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x0bb
+ 0: a\x0bb
+    a\x0cb
+ 0: a\x0cb
+    a\x85b
+ 0: a\x85b
+    a\n\rb
+ 0: a\x0a\x0db
+    a\n\r\x85\x0cb
+ 0: a\x0a\x0d\x85\x0cb
+    ** Failers
+No match
+    ab
+No match
+
+/^a\R{1,3}b/<bsr_unicode>
+    a\nb
+ 0: a\x0ab
+    a\n\rb
+ 0: a\x0a\x0db
+    a\n\r\x85b
+ 0: a\x0a\x0d\x85b
+    a\r\n\r\nb
+ 0: a\x0d\x0a\x0d\x0ab
+    a\r\n\r\n\r\nb
+ 0: a\x0d\x0a\x0d\x0a\x0d\x0ab
+    a\n\r\n\rb
+ 0: a\x0a\x0d\x0a\x0db
+    a\n\n\r\nb
+ 0: a\x0a\x0a\x0d\x0ab
+    ** Failers
+No match
+    a\n\n\n\rb
+No match
+    a\r
+No match
+
+/^a[\R]b/<bsr_unicode>
+    aRb
+ 0: aRb
+    ** Failers
+No match
+    a\nb
+No match
+
+/(?&abc)X(?<abc>P)/I
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  abc   1
+No options
+No first char
+Need char = 'P'
+    abcPXP123
+ 0: PXP
+ 1: P
+
+/(?1)X(?<abc>P)/I
+Capturing subpattern count = 1
+Named capturing subpatterns:
+  abc   1
+No options
+No first char
+Need char = 'P'
+    abcPXP123
+ 0: PXP
+ 1: P
+
+/(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
+    1.2.3.4
+ 0: 1.2.3.4
+ 1: <unset>
+ 2: .4
+    131.111.10.206
+ 0: 131.111.10.206
+ 1: <unset>
+ 2: .206
+    10.0.0.0
+ 0: 10.0.0.0
+ 1: <unset>
+ 2: .0
+    ** Failers
+No match
+    10.6
+No match
+    455.3.4.5
+No match
+
+/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
+    1.2.3.4
+ 0: 1.2.3.4
+ 1: .4
+ 2: <unset>
+    131.111.10.206
+ 0: 131.111.10.206
+ 1: .206
+ 2: <unset>
+    10.0.0.0
+ 0: 10.0.0.0
+ 1: .0
+ 2: <unset>
+    ** Failers
+No match
+    10.6
+No match
+    455.3.4.5
+No match
+
+/(?:a(?&abc)b)*(?<abc>x)/
+    123axbaxbaxbx456
+ 0: axbaxbaxbx
+ 1: x
+    123axbaxbaxb456
+ 0: x
+ 1: x
+
+/(?:a(?&abc)b){1,5}(?<abc>x)/
+    123axbaxbaxbx456
+ 0: axbaxbaxbx
+ 1: x
+
+/(?:a(?&abc)b){2,5}(?<abc>x)/
+    123axbaxbaxbx456
+ 0: axbaxbaxbx
+ 1: x
+
+/(?:a(?&abc)b){2,}(?<abc>x)/
+    123axbaxbaxbx456
+ 0: axbaxbaxbx
+ 1: x
+
+/(abc)(?i:(?1))/
+   defabcabcxyz
+ 0: abcabc
+ 1: abc
+   DEFabcABCXYZ
+No match
+
+/(abc)(?:(?i)(?1))/
+   defabcabcxyz
+ 0: abcabc
+ 1: abc
+   DEFabcABCXYZ
+No match
+
+/^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-02}Z/
+    ababababbbabZXXXX
+ 0: ababababbbabZ
+ 1: ab
+ 2: b
+
+/^(a)\g-2/
+Failed: reference to non-existent subpattern at offset 7
+
+/^(a)\g/
+Failed: a numbered reference must not be zero at offset 5
+
+/^(a)\g{0}/
+Failed: a numbered reference must not be zero at offset 8
+
+/^(a)\g{3/
+Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 8
+
+/^(a)\g{4a}/
+Failed: reference to non-existent subpattern at offset 9
+
+/^a.b/<lf>
+    a\rb
+ 0: a\x0db
+    *** Failers
+No match
+    a\nb
+No match
+
+/.+foo/
+    afoo
+ 0: afoo
+    ** Failers
+No match
+    \r\nfoo
+No match
+    \nfoo
+No match
+
+/.+foo/<crlf>
+    afoo
+ 0: afoo
+    \nfoo
+ 0: \x0afoo
+    ** Failers
+No match
+    \r\nfoo
+No match
+
+/.+foo/<any>
+    afoo
+ 0: afoo
+    ** Failers
+No match
+    \nfoo
+No match
+    \r\nfoo
+No match
+
+/.+foo/s
+    afoo
+ 0: afoo
+    \r\nfoo
+ 0: \x0d\x0afoo
+    \nfoo
+ 0: \x0afoo
+    
+/^$/mg<any>
+    abc\r\rxyz
+ 0: 
+    abc\n\rxyz  
+ 0: 
+    ** Failers 
+No match
+    abc\r\nxyz
+No match
+
+/(?m)^$/<any>g+
+    abc\r\n\r\n
+ 0: 
+ 0+ \x0d\x0a
+
+/(?m)^$|^\r\n/<any>g+ 
+    abc\r\n\r\n
+ 0: 
+ 0+ \x0d\x0a
+ 0: \x0d\x0a
+ 0+ 
+    
+/(?m)$/<any>g+ 
+    abc\r\n\r\n
+ 0: 
+ 0+ \x0d\x0a\x0d\x0a
+ 0: 
+ 0+ \x0d\x0a
+ 0: 
+ 0+ 
+
+/abc.$/mgx<anycrlf>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc9
+ 0: abc1
+ 0: abc4
+ 0: abc5
+ 0: abc9
+
+/^X/m
+    XABC
+ 0: X
+    ** Failers 
+No match
+    XABC\B
+No match
+
+/(ab|c)(?-1)/BZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        ab
+        Alt
+        c
+        Ket
+        Once
+        Recurse
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    abc
+ 0: abc
+ 1: ab
+
+/xy(?+1)(abc)/BZ
+------------------------------------------------------------------
+        Bra
+        xy
+        Once
+        Recurse
+        Ket
+        CBra 1
+        abc
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    xyabcabc
+ 0: xyabcabc
+ 1: abc
+    ** Failers
+No match
+    xyabc  
+No match
+    
+/x(?-0)y/
+Failed: a numbered reference must not be zero at offset 5
+
+/x(?-1)y/
+Failed: reference to non-existent subpattern at offset 5
+
+/x(?+0)y/ 
+Failed: a numbered reference must not be zero at offset 5
+
+/x(?+1)y/
+Failed: reference to non-existent subpattern at offset 5
+
+/^(abc)?(?(-1)X|Y)/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        Brazero
+        CBra 1
+        abc
+        Ket
+        Cond
+      1 Cond ref
+        X
+        Alt
+        Y
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    abcX
+ 0: abcX
+ 1: abc
+    Y
+ 0: Y
+    ** Failers
+No match
+    abcY   
+No match
+    
+/^((?(+1)X|Y)(abc))+/BZ 
+------------------------------------------------------------------
+        Bra
+        ^
+        CBra 1
+        Cond
+      2 Cond ref
+        X
+        Alt
+        Y
+        Ket
+        CBra 2
+        abc
+        Ket
+        KetRmax
+        Ket
+        End
+------------------------------------------------------------------
+    YabcXabc
+ 0: YabcXabc
+ 1: Xabc
+ 2: abc
+    YabcXabcXabc
+ 0: YabcXabcXabc
+ 1: Xabc
+ 2: abc
+    ** Failers
+No match
+    XabcXabc  
+No match
+
+/(?(-1)a)/BZ
+Failed: reference to non-existent subpattern at offset 6
+
+/((?(-1)a))/BZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        Cond
+      1 Cond ref
+        a
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/((?(-2)a))/BZ
+Failed: reference to non-existent subpattern at offset 7
+
+/^(?(+1)X|Y)(.)/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        Cond
+      1 Cond ref
+        X
+        Alt
+        Y
+        Ket
+        CBra 1
+        Any
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    Y!
+ 0: Y!
+ 1: !
+
+/(foo)\Kbar/
+    foobar
+ 0: bar
+ 1: foo
+   
+/(foo)(\Kbar|baz)/
+    foobar
+ 0: bar
+ 1: foo
+ 2: bar
+    foobaz 
+ 0: foobaz
+ 1: foo
+ 2: baz
+
+/(foo\Kbar)baz/
+    foobarbaz
+ 0: barbaz
+ 1: foobar
+
+/(?<A>tom|bon)-\k{A}/
+    tom-tom
+ 0: tom-tom
+ 1: tom
+    bon-bon 
+ 0: bon-bon
+ 1: bon
+    ** Failers
+No match
+    tom-bon  
+No match
+
+/(?<A>tom|bon)-\g{A}/
+    tom-tom
+ 0: tom-tom
+ 1: tom
+    bon-bon 
+ 0: bon-bon
+ 1: bon
+    
+/\g{A/ 
+Failed: syntax error in subpattern name (missing terminator) at offset 4
+
+/(?|(abc)|(xyz))/BZ
+------------------------------------------------------------------
+        Bra
+        Bra
+        CBra 1
+        abc
+        Ket
+        Alt
+        CBra 1
+        xyz
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+   >abc<
+ 0: abc
+ 1: abc
+   >xyz< 
+ 0: xyz
+ 1: xyz
+
+/(x)(?|(abc)|(xyz))(x)/BZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        x
+        Ket
+        Bra
+        CBra 2
+        abc
+        Ket
+        Alt
+        CBra 2
+        xyz
+        Ket
+        Ket
+        CBra 3
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    xabcx
+ 0: xabcx
+ 1: x
+ 2: abc
+ 3: x
+    xxyzx 
+ 0: xxyzx
+ 1: x
+ 2: xyz
+ 3: x
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/BZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        x
+        Ket
+        Bra
+        CBra 2
+        abc
+        Ket
+        CBra 3
+        pqr
+        Ket
+        Alt
+        CBra 2
+        xyz
+        Ket
+        Ket
+        CBra 4
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+    xabcpqrx
+ 0: xabcpqrx
+ 1: x
+ 2: abc
+ 3: pqr
+ 4: x
+    xxyzx 
+ 0: xxyzx
+ 1: x
+ 2: xyz
+ 3: <unset>
+ 4: x
+
+/(?|(abc)|(xyz))\1/
+    abcabc
+ 0: abcabc
+ 1: abc
+    xyzxyz 
+ 0: xyzxyz
+ 1: xyz
+    ** Failers
+No match
+    abcxyz
+No match
+    xyzabc   
+No match
+    
+/(?|(abc)|(xyz))(?1)/
+    abcabc
+ 0: abcabc
+ 1: abc
+    xyzabc 
+ 0: xyzabc
+ 1: xyz
+    ** Failers 
+No match
+    xyzxyz 
+No match
+ 
+/\H\h\V\v/
+    X X\x0a
+ 0: X X\x0a
+    X\x09X\x0b
+ 0: X\x09X\x0b
+    ** Failers
+No match
+    \xa0 X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/ 
+    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0X\x0a\x0b\x0c\x0d
+    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0\x0a\x0b\x0c\x0d
+    \x09\x20\xa0\x0a\x0b\x0c
+ 0: \x09 \xa0\x0a\x0b\x0c
+    ** Failers 
+No match
+    \x09\x20\xa0\x0a\x0b
+No match
+     
+/\H{3,4}/
+    XY  ABCDE
+ 0: ABCD
+    XY  PQR ST 
+ 0: PQR
+    
+/.\h{3,4}./
+    XY  AB    PQRS
+ 0: B    P
+
+/\h*X\h?\H+Y\H?Z/
+    >XNNNYZ
+ 0: XNNNYZ
+    >  X NYQZ
+ 0:   X NYQZ
+    ** Failers
+No match
+    >XYZ   
+No match
+    >  X NY Z
+No match
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+    >XY\x0aZ\x0aA\x0bNN\x0c
+ 0: XY\x0aZ\x0aA\x0bNN\x0c
+    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+ 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
+/[\h]/BZ
+------------------------------------------------------------------
+        Bra
+        [\x09 \xa0]
+        Ket
+        End
+------------------------------------------------------------------
+    >\x09<
+ 0: \x09
+
+/[\h]+/BZ
+------------------------------------------------------------------
+        Bra
+        [\x09 \xa0]+
+        Ket
+        End
+------------------------------------------------------------------
+    >\x09\x20\xa0<
+ 0: \x09 \xa0
+
+/[\v]/BZ
+------------------------------------------------------------------
+        Bra
+        [\x0a-\x0d\x85]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\H]/BZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^\h]/BZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\V]/BZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\x09\x0e-\x84\x86-\xff]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\x0a\V]/BZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\x0a\x0e-\x84\x86-\xff]
+        Ket
+        End
+------------------------------------------------------------------
+
+/\H++X/BZ
+------------------------------------------------------------------
+        Bra
+        \H++
+        X
+        Ket
+        End
+------------------------------------------------------------------
+    ** Failers
+No match
+    XXXX
+No match
+    
+/\H+\hY/BZ
+------------------------------------------------------------------
+        Bra
+        \H++
+        \h
+        Y
+        Ket
+        End
+------------------------------------------------------------------
+    XXXX Y 
+ 0: XXXX Y
+
+/\H+ Y/BZ
+------------------------------------------------------------------
+        Bra
+        \H++
+         Y
+        Ket
+        End
+------------------------------------------------------------------
+
+/\h+A/BZ
+------------------------------------------------------------------
+        Bra
+        \h++
+        A
+        Ket
+        End
+------------------------------------------------------------------
+
+/\v*B/BZ
+------------------------------------------------------------------
+        Bra
+        \v*+
+        B
+        Ket
+        End
+------------------------------------------------------------------
+
+/\V+\x0a/BZ
+------------------------------------------------------------------
+        Bra
+        \V++
+        \x0a
+        Ket
+        End
+------------------------------------------------------------------
+
+/A+\h/BZ
+------------------------------------------------------------------
+        Bra
+        A++
+        \h
+        Ket
+        End
+------------------------------------------------------------------
+
+/ *\H/BZ
+------------------------------------------------------------------
+        Bra
+         *+
+        \H
+        Ket
+        End
+------------------------------------------------------------------
+
+/A*\v/BZ
+------------------------------------------------------------------
+        Bra
+        A*+
+        \v
+        Ket
+        End
+------------------------------------------------------------------
+
+/\x0b*\V/BZ
+------------------------------------------------------------------
+        Bra
+        \x0b*+
+        \V
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d+\h/BZ
+------------------------------------------------------------------
+        Bra
+        \d++
+        \h
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\v/BZ
+------------------------------------------------------------------
+        Bra
+        \d*+
+        \v
+        Ket
+        End
+------------------------------------------------------------------
+
+/S+\h\S+\v/BZ
+------------------------------------------------------------------
+        Bra
+        S++
+        \h
+        \S++
+        \v
+        Ket
+        End
+------------------------------------------------------------------
+
+/\w{3,}\h\w+\v/BZ
+------------------------------------------------------------------
+        Bra
+        \w{3}
+        \w*+
+        \h
+        \w++
+        \v
+        Ket
+        End
+------------------------------------------------------------------
+
+/\h+\d\h+\w\h+\S\h+\H/BZ
+------------------------------------------------------------------
+        Bra
+        \h++
+        \d
+        \h++
+        \w
+        \h++
+        \S
+        \h++
+        \H
+        Ket
+        End
+------------------------------------------------------------------
+
+/\v+\d\v+\w\v+\S\v+\V/BZ
+------------------------------------------------------------------
+        Bra
+        \v++
+        \d
+        \v++
+        \w
+        \v+
+        \S
+        \v++
+        \V
+        Ket
+        End
+------------------------------------------------------------------
+
+/\H+\h\H+\d/BZ
+------------------------------------------------------------------
+        Bra
+        \H++
+        \h
+        \H+
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\V+\v\V+\w/BZ
+------------------------------------------------------------------
+        Bra
+        \V++
+        \v
+        \V+
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+
+/\( (?: [^()]* | (?R) )* \)/x
+(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(00)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)
+ 0: (0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(00)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)
+
+/[\E]AAA/
+Failed: missing terminating ] for character class at offset 7
+
+/[\Q\E]AAA/
+Failed: missing terminating ] for character class at offset 9
+
+/[^\E]AAA/
+Failed: missing terminating ] for character class at offset 8
+
+/[^\Q\E]AAA/
+Failed: missing terminating ] for character class at offset 10
+
+/[\E^]AAA/
+Failed: missing terminating ] for character class at offset 8
+
+/[\Q\E^]AAA/
+Failed: missing terminating ] for character class at offset 10
+
+/A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/BZ
+------------------------------------------------------------------
+        Bra
+        A
+        *PRUNE
+        B
+        *SKIP
+        C
+        *THEN
+        D
+        *COMMIT
+        E
+        *FAIL
+        F
+        *FAIL
+        G
+        *FAIL
+        H
+        *ACCEPT
+        I
+        Ket
+        End
+------------------------------------------------------------------
+
+/^a+(*FAIL)/
+    aaaaaa
+No match
+    
+/a+b?c+(*FAIL)/
+    aaabccc
+No match
+
+/a+b?(*PRUNE)c+(*FAIL)/
+    aaabccc
+No match
+
+/a+b?(*COMMIT)c+(*FAIL)/
+    aaabccc
+No match
+    
+/a+b?(*SKIP)c+(*FAIL)/
+    aaabcccaaabccc
+No match
+
+/^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
+    aaaxxxxxx
+ 0: aaaxxxxxx
+    aaa++++++ 
+ 0: aaa
+    bbbxxxxx
+ 0: bbbxxxxx
+    bbb+++++ 
+ 0: bbb
+    cccxxxx
+ 0: cccxxxx
+    ccc++++ 
+ 0: ccc
+    dddddddd   
+ 0: ddd
+
+/^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
+    aaaxxxxxx
+ 0: aaaxxxxxx
+ 1: aaaxxxxxx
+    aaa++++++ 
+ 0: aaa
+ 1: aaa
+    bbbxxxxx
+ 0: bbbxxxxx
+ 1: bbbxxxxx
+    bbb+++++ 
+ 0: bbb
+ 1: bbb
+    cccxxxx
+ 0: cccxxxx
+ 1: cccxxxx
+    ccc++++ 
+ 0: ccc
+ 1: ccc
+    dddddddd   
+ 0: ddd
+ 1: ddd
+
+/a+b?(*THEN)c+(*FAIL)/
+    aaabccc
+No match
+
+/(A (A|B(*ACCEPT)|C) D)(E)/x
+    ABX
+ 0: AB
+    AADE
+ 0: AADE
+ 1: AAD
+ 2: A
+ 3: E
+    ACDE
+ 0: ACDE
+ 1: ACD
+ 2: C
+ 3: E
+    ** Failers
+No match
+    AD 
+No match
+        
+/^a+(*FAIL)/C
+    aaaaaa
+--->aaaaaa
+ +0 ^          ^
+ +1 ^          a+
+ +3 ^     ^    (*FAIL)
+ +3 ^    ^     (*FAIL)
+ +3 ^   ^      (*FAIL)
+ +3 ^  ^       (*FAIL)
+ +3 ^ ^        (*FAIL)
+ +3 ^^         (*FAIL)
+No match
+    
+/a+b?c+(*FAIL)/C
+    aaabccc
+--->aaabccc
+ +0 ^           a+
+ +2 ^  ^        b?
+ +4 ^   ^       c+
+ +6 ^      ^    (*FAIL)
+ +6 ^     ^     (*FAIL)
+ +6 ^    ^      (*FAIL)
+ +4 ^  ^        c+
+ +2 ^ ^         b?
+ +4 ^ ^         c+
+ +2 ^^          b?
+ +4 ^^          c+
+ +0  ^          a+
+ +2  ^ ^        b?
+ +4  ^  ^       c+
+ +6  ^     ^    (*FAIL)
+ +6  ^    ^     (*FAIL)
+ +6  ^   ^      (*FAIL)
+ +4  ^ ^        c+
+ +2  ^^         b?
+ +4  ^^         c+
+ +0   ^         a+
+ +2   ^^        b?
+ +4   ^ ^       c+
+ +6   ^    ^    (*FAIL)
+ +6   ^   ^     (*FAIL)
+ +6   ^  ^      (*FAIL)
+ +4   ^^        c+
+No match
+
+/a+b?(*PRUNE)c+(*FAIL)/C
+    aaabccc
+--->aaabccc
+ +0 ^           a+
+ +2 ^  ^        b?
+ +4 ^   ^       (*PRUNE)
++12 ^   ^       c+
++14 ^      ^    (*FAIL)
++14 ^     ^     (*FAIL)
++14 ^    ^      (*FAIL)
+ +0  ^          a+
+ +2  ^ ^        b?
+ +4  ^  ^       (*PRUNE)
++12  ^  ^       c+
++14  ^     ^    (*FAIL)
++14  ^    ^     (*FAIL)
++14  ^   ^      (*FAIL)
+ +0   ^         a+
+ +2   ^^        b?
+ +4   ^ ^       (*PRUNE)
++12   ^ ^       c+
++14   ^    ^    (*FAIL)
++14   ^   ^     (*FAIL)
++14   ^  ^      (*FAIL)
+No match
+
+/a+b?(*COMMIT)c+(*FAIL)/C
+    aaabccc
+--->aaabccc
+ +0 ^           a+
+ +2 ^  ^        b?
+ +4 ^   ^       (*COMMIT)
++13 ^   ^       c+
++15 ^      ^    (*FAIL)
++15 ^     ^     (*FAIL)
++15 ^    ^      (*FAIL)
+No match
+    
+/a+b?(*SKIP)c+(*FAIL)/C
+    aaabcccaaabccc
+--->aaabcccaaabccc
+ +0 ^                  a+
+ +2 ^  ^               b?
+ +4 ^   ^              (*SKIP)
++11 ^   ^              c+
++13 ^      ^           (*FAIL)
++13 ^     ^            (*FAIL)
++13 ^    ^             (*FAIL)
+ +0        ^           a+
+ +2        ^  ^        b?
+ +4        ^   ^       (*SKIP)
++11        ^   ^       c+
++13        ^      ^    (*FAIL)
++13        ^     ^     (*FAIL)
++13        ^    ^      (*FAIL)
+No match
+
+/a+b?(*THEN)c+(*FAIL)/C
+    aaabccc
+--->aaabccc
+ +0 ^           a+
+ +2 ^  ^        b?
+ +4 ^   ^       (*THEN)
++11 ^   ^       c+
++13 ^      ^    (*FAIL)
++13 ^     ^     (*FAIL)
++13 ^    ^      (*FAIL)
+ +0  ^          a+
+ +2  ^ ^        b?
+ +4  ^  ^       (*THEN)
++11  ^  ^       c+
++13  ^     ^    (*FAIL)
++13  ^    ^     (*FAIL)
++13  ^   ^      (*FAIL)
+ +0   ^         a+
+ +2   ^^        b?
+ +4   ^ ^       (*THEN)
++11   ^ ^       c+
++13   ^    ^    (*FAIL)
++13   ^   ^     (*FAIL)
++13   ^  ^      (*FAIL)
+No match
+    
+/a(*PRUNE:XXX)b/
+Failed: (*VERB) with an argument is not supported at offset 8
+
+/a(*MARK)b/ 
+Failed: (*VERB) not recognized at offset 7
+
+/(?i:A{1,}\6666666666)/
+Failed: number is too big at offset 19
+
+/\g6666666666/
+Failed: number is too big at offset 11
+
+/[\g6666666666]/
+Failed: number is too big at offset 12
+
+/(?1)\c[/
+Failed: reference to non-existent subpattern at offset 3
+
+/.+A/<crlf>
+    \r\nA
+No match
+    
+/\nA/<crlf>
+    \r\nA 
+ 0: \x0aA
+
+/[\r\n]A/<crlf>
+    \r\nA 
+ 0: \x0aA
+
+/(\r|\n)A/<crlf>
+    \r\nA 
+ 0: \x0aA
+ 1: \x0a
+
+/a(*CR)b/
+Failed: (*VERB) not recognized at offset 5
+
+/(*CR)a.b/
+    a\nb
+ 0: a\x0ab
+    ** Failers
+No match
+    a\rb  
+No match
+
+/(*CR)a.b/<lf>
+    a\nb
+ 0: a\x0ab
+    ** Failers
+No match
+    a\rb  
+No match
+
+/(*LF)a.b/<CRLF>
+    a\rb
+ 0: a\x0db
+    ** Failers
+No match
+    a\nb  
+No match
+
+/(*CRLF)a.b/
+    a\rb
+ 0: a\x0db
+    a\nb  
+ 0: a\x0ab
+    ** Failers
+No match
+    a\r\nb  
+No match
+
+/(*ANYCRLF)a.b/<CR>
+    ** Failers
+No match
+    a\rb
+No match
+    a\nb  
+No match
+    a\r\nb  
+No match
+
+/(*ANY)a.b/<cr>
+    ** Failers
+No match
+    a\rb
+No match
+    a\nb  
+No match
+    a\r\nb  
+No match
+    a\x85b 
+No match
+
+/a\Rb/I<bsr_anycrlf>
+Capturing subpattern count = 0
+Options: bsr_anycrlf
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x0db
+    a\nb
+ 0: a\x0ab
+    a\r\nb
+ 0: a\x0d\x0ab
+    ** Failers
+No match
+    a\x85b
+No match
+    a\x0bb     
+No match
+
+/a\Rb/I<bsr_unicode>
+Capturing subpattern count = 0
+Options: bsr_unicode
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x0db
+    a\nb
+ 0: a\x0ab
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x85b
+ 0: a\x85b
+    a\x0bb     
+ 0: a\x0bb
+    ** Failers 
+No match
+    a\x85b\<bsr_anycrlf>
+No match
+    a\x0bb\<bsr_anycrlf>
+No match
+    
+/a\R?b/I<bsr_anycrlf>
+Capturing subpattern count = 0
+Options: bsr_anycrlf
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x0db
+    a\nb
+ 0: a\x0ab
+    a\r\nb
+ 0: a\x0d\x0ab
+    ** Failers
+No match
+    a\x85b
+No match
+    a\x0bb     
+No match
+
+/a\R?b/I<bsr_unicode>
+Capturing subpattern count = 0
+Options: bsr_unicode
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x0db
+    a\nb
+ 0: a\x0ab
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x85b
+ 0: a\x85b
+    a\x0bb     
+ 0: a\x0bb
+    ** Failers 
+No match
+    a\x85b\<bsr_anycrlf>
+No match
+    a\x0bb\<bsr_anycrlf>
+No match
+    
+/a\R{2,4}b/I<bsr_anycrlf>
+Capturing subpattern count = 0
+Partial matching not supported
+Options: bsr_anycrlf
+First char = 'a'
+Need char = 'b'
+    a\r\n\nb
+ 0: a\x0d\x0a\x0ab
+    a\n\r\rb
+ 0: a\x0a\x0d\x0db
+    a\r\n\r\n\r\n\r\nb
+ 0: a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0ab
+    ** Failers
+No match
+    a\x85\85b
+No match
+    a\x0b\0bb     
+No match
+
+/a\R{2,4}b/I<bsr_unicode>
+Capturing subpattern count = 0
+Partial matching not supported
+Options: bsr_unicode
+First char = 'a'
+Need char = 'b'
+    a\r\rb
+ 0: a\x0d\x0db
+    a\n\n\nb
+ 0: a\x0a\x0a\x0ab
+    a\r\n\n\r\rb
+ 0: a\x0d\x0a\x0a\x0d\x0db
+    a\x85\85b
+No match
+    a\x0b\0bb     
+No match
+    ** Failers 
+No match
+    a\r\r\r\r\rb 
+No match
+    a\x85\85b\<bsr_anycrlf>
+No match
+    a\x0b\0bb\<bsr_anycrlf>
+No match
+ 
+/(*BSR_ANYCRLF)a\Rb/I
+Capturing subpattern count = 0
+Options: bsr_anycrlf
+First char = 'a'
+Need char = 'b'
+    a\nb
+ 0: a\x0ab
+    a\rb 
+ 0: a\x0db
+
+/(*BSR_UNICODE)a\Rb/I
+Capturing subpattern count = 0
+Options: bsr_unicode
+First char = 'a'
+Need char = 'b'
+    a\x85b
+ 0: a\x85b
+
+/(*BSR_ANYCRLF)(*CRLF)a\Rb/I
+Capturing subpattern count = 0
+Options: bsr_anycrlf
+Forced newline sequence: CRLF
+First char = 'a'
+Need char = 'b'
+    a\nb
+ 0: a\x0ab
+    a\rb 
+ 0: a\x0db
+
+/(*CRLF)(*BSR_UNICODE)a\Rb/I
+Capturing subpattern count = 0
+Options: bsr_unicode
+Forced newline sequence: CRLF
+First char = 'a'
+Need char = 'b'
+    a\x85b
+ 0: a\x85b
+
+/(*CRLF)(*BSR_ANYCRLF)(*CR)ab/I
+Capturing subpattern count = 0
+Options: bsr_anycrlf
+Forced newline sequence: CR
+First char = 'a'
+Need char = 'b'
+
+/(?<a>)(?&)/
+Failed: subpattern name expected at offset 9
+
+/(?<abc>)(?&a)/
+Failed: reference to non-existent subpattern at offset 12
+
+/(?<a>)(?&aaaaaaaaaaaaaaaaaaaaaaa)/
+Failed: reference to non-existent subpattern at offset 32
+
+/(?+-a)/
+Failed: digit expected after (?+ at offset 3
+
+/(?-+a)/
+Failed: unrecognized character after (? or (?- at offset 3
+
+/(?(-1))/
+Failed: reference to non-existent subpattern at offset 6
+
+/(?(+10))/
+Failed: reference to non-existent subpattern at offset 7
+
+/(?(10))/
+Failed: reference to non-existent subpattern at offset 6
+
+/(?(+2))()()/
+
+/(?(2))()()/
+
+/\k''/
+Failed: subpattern name expected at offset 3
+
+/\k<>/
+Failed: subpattern name expected at offset 3
+
+/\k{}/
+Failed: subpattern name expected at offset 3
+
+/(?P=)/
+Failed: subpattern name expected at offset 4
+
+/(?P>)/
+Failed: subpattern name expected at offset 4
+
+/(?!\w)(?R)/
+Failed: recursive call could loop indefinitely at offset 9
+
+/(?=\w)(?R)/
+Failed: recursive call could loop indefinitely at offset 9
+
+/(?<!\w)(?R)/
+Failed: recursive call could loop indefinitely at offset 10
+
+/(?<=\w)(?R)/
+Failed: recursive call could loop indefinitely at offset 10
+
+/[[:foo:]]/
+Failed: unknown POSIX class name at offset 3
+
+/[[:1234:]]/
+Failed: unknown POSIX class name at offset 3
+
+/[[:f\oo:]]/
+Failed: unknown POSIX class name at offset 3
+
+/[[: :]]/
+Failed: unknown POSIX class name at offset 3
+
+/[[:...:]]/
+Failed: unknown POSIX class name at offset 3
+
+/[[:l\ower:]]/
+Failed: unknown POSIX class name at offset 3
+
+/[[:abc\:]]/
+Failed: unknown POSIX class name at offset 3
+
+/[abc[:x\]pqr:]]/
+Failed: unknown POSIX class name at offset 6
+
+/[[:a\dz:]]/
+Failed: unknown POSIX class name at offset 3
+
+/^(?<name>a|b\g<name>c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/^(?<name>a|b\g'name'c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/^(a|b\g<1>c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/^(a|b\g'1'c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/^(a|b\g'-1'c)/
+    aaaa
+ 0: a
+ 1: a
+    bacxxx
+ 0: bac
+ 1: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+
+/(^(a|b\g<-1>c))/
+    aaaa
+ 0: a
+ 1: a
+ 2: a
+    bacxxx
+ 0: bac
+ 1: bac
+ 2: bac
+    bbaccxxx 
+ 0: bbacc
+ 1: bbacc
+ 2: bbacc
+    bbbacccxx
+ 0: bbbaccc
+ 1: bbbaccc
+ 2: bbbaccc
+
+/(^(a|b\g<-1'c))/
+Failed: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number at offset 15
+
+/(^(a|b\g{-1}))/
+    bacxxx
+No match
+
+/(?-i:\g<name>)(?i:(?<name>a))/
+    XaaX
+ 0: aa
+ 1: a
+    XAAX 
+ 0: AA
+ 1: A
+
+/(?i:\g<name>)(?-i:(?<name>a))/
+    XaaX
+ 0: aa
+ 1: a
+    ** Failers 
+No match
+    XAAX 
+No match
+
+/(?-i:\g<+1>)(?i:(a))/
+    XaaX
+ 0: aa
+ 1: a
+    XAAX 
+ 0: AA
+ 1: A
+
+/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/
+
+/(?<n>a|b|c)\g<n>*/
+   abc
+ 0: abc
+ 1: a
+   accccbbb 
+ 0: accccbbb
+ 1: a
+
+/^(?+1)(?<a>x|y){0}z/
+    xzxx
+ 0: xz
+ 1: <unset>
+    yzyy 
+ 0: yz
+ 1: <unset>
+    ** Failers
+No match
+    xxz  
+No match
+
+/(\3)(\1)(a)/
+    cat
+No match
+
+/(\3)(\1)(a)/<JS>
+    cat
+ 0: a
+ 1: 
+ 2: 
+ 3: a
+    
+/TA]/
+    The ACTA] comes 
+ 0: TA]
+
+/TA]/<JS>
+Failed: ] is an invalid data character in JavaScript compatibility mode at offset 2
+
+/(?2)[]a()b](abc)/
+Failed: reference to non-existent subpattern at offset 3
+
+/(?2)[^]a()b](abc)/
+Failed: reference to non-existent subpattern at offset 3
+
+/(?1)[]a()b](abc)/
+    abcbabc
+ 0: abcbabc
+ 1: abc
+    ** Failers 
+No match
+    abcXabc
+No match
+
+/(?1)[^]a()b](abc)/
+    abcXabc
+ 0: abcXabc
+ 1: abc
+    ** Failers 
+No match
+    abcbabc
+No match
+
+/(?2)[]a()b](abc)(xyz)/
+    xyzbabcxyz
+ 0: xyzbabcxyz
+ 1: abc
+ 2: xyz
+
+/(?&N)[]a(?<N>)](?<M>abc)/
+Failed: reference to non-existent subpattern at offset 4
+
+/(?&N)[]a(?<N>)](abc)/
+Failed: reference to non-existent subpattern at offset 4
+
+/a[]b/
+Failed: missing terminating ] for character class at offset 4
+
+/a[^]b/
+Failed: missing terminating ] for character class at offset 5
+
+/a[]b/<JS>
+    ** Failers
+No match
+    ab
+No match
+
+/a[]+b/<JS>
+    ** Failers
+No match
+    ab 
+No match
+
+/a[]*+b/<JS>
+    ** Failers
+No match
+    ab 
+No match
+
+/a[^]b/<JS>
+    aXb
+ 0: aXb
+    a\nb 
+ 0: a\x0ab
+    ** Failers
+No match
+    ab  
+No match
+    
+/a[^]+b/<JS> 
+    aXb
+ 0: aXb
+    a\nX\nXb 
+ 0: a\x0aX\x0aXb
+    ** Failers
+No match
+    ab  
+No match
+
+/a(?!)+b/
+Failed: nothing to repeat at offset 5
+
+/a(*FAIL)+b/
+Failed: nothing to repeat at offset 8
+
+/(abc|pqr|123){0}[xyz]/SI
+Capturing subpattern count = 1
+No options
+No first char
+No need char
+Starting byte set: x y z 
+
+/ End of testinput2 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,163 @@
+/^[\w]+/
+    *** Failers
+No match
+    École
+No match
+
+/^[\w]+/Lfr_FR
+    École
+ 0: École
+
+/^[\w]+/
+    *** Failers
+No match
+    École
+No match
+
+/^[\W]+/
+    École
+ 0: \xc9
+
+/^[\W]+/Lfr_FR
+    *** Failers
+ 0: *** 
+    École
+No match
+
+/[\b]/
+    \b
+ 0: \x08
+    *** Failers
+No match
+    a
+No match
+
+/[\b]/Lfr_FR
+    \b
+ 0: \x08
+    *** Failers
+No match
+    a
+No match
+
+/^\w+/
+    *** Failers
+No match
+    École
+No match
+
+/^\w+/Lfr_FR
+    École
+ 0: École
+
+/(.+)\b(.+)/
+    École
+ 0: \xc9cole
+ 1: \xc9
+ 2: cole
+
+/(.+)\b(.+)/Lfr_FR
+    *** Failers
+ 0: *** Failers
+ 1: *** 
+ 2: Failers
+    École
+No match
+
+/École/i
+    École
+ 0: \xc9cole
+    *** Failers
+No match
+    école
+No match
+
+/École/iLfr_FR
+    École
+ 0: École
+    école
+ 0: école
+
+/\w/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P 
+  Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z 
+
+/\w/ISLfr_FR
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P 
+  Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z 
+  ª µ º À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß à á â 
+  ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý þ ÿ 
+
+/^[\xc8-\xc9]/iLfr_FR
+    École
+ 0: É
+    école
+ 0: é
+
+/^[\xc8-\xc9]/Lfr_FR
+    École
+ 0: É
+    *** Failers 
+No match
+    école
+No match
+
+/\W+/Lfr_FR
+    >>>\xaa<<<
+ 0: >>>
+    >>>\xba<<< 
+ 0: >>>
+
+/[\W]+/Lfr_FR
+    >>>\xaa<<<
+ 0: >>>
+    >>>\xba<<< 
+ 0: >>>
+
+/[^[:alpha:]]+/Lfr_FR
+    >>>\xaa<<<
+ 0: >>>
+    >>>\xba<<< 
+ 0: >>>
+
+/\w+/Lfr_FR
+    >>>\xaa<<<
+ 0: ª
+    >>>\xba<<< 
+ 0: º
+
+/[\w]+/Lfr_FR
+    >>>\xaa<<<
+ 0: ª
+    >>>\xba<<< 
+ 0: º
+
+/[[:alpha:]]+/Lfr_FR
+    >>>\xaa<<<
+ 0: ª
+    >>>\xba<<< 
+ 0: º
+    
+/[[:alpha:]][[:lower:]][[:upper:]]/DZLfr_FR 
+------------------------------------------------------------------
+        Bra
+        [A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\xff]
+        [a-z\xb5\xdf-\xf6\xf8-\xff]
+        [A-Z\xc0-\xd6\xd8-\xde]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/ End of testinput3 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput4	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1092 @@
+/-- Do not use the \x{} construct except with patterns that have the --/
+/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
+No match
+/-- that option is set. However, the latest Perls recognize them always. --/
+No match
+
+/a.b/8
+    acb
+ 0: acb
+    a\x7fb
+ 0: a\x{7f}b
+    a\x{100}b 
+ 0: a\x{100}b
+    *** Failers
+No match
+    a\nb  
+No match
+
+/a(.{3})b/8
+    a\x{4000}xyb 
+ 0: a\x{4000}xyb
+ 1: \x{4000}xy
+    a\x{4000}\x7fyb 
+ 0: a\x{4000}\x{7f}yb
+ 1: \x{4000}\x{7f}y
+    a\x{4000}\x{100}yb 
+ 0: a\x{4000}\x{100}yb
+ 1: \x{4000}\x{100}y
+    *** Failers
+No match
+    a\x{4000}b 
+No match
+    ac\ncb 
+No match
+
+/a(.*?)(.)/
+    a\xc0\x88b
+ 0: a\xc0
+ 1: 
+ 2: \xc0
+
+/a(.*?)(.)/8
+    a\x{100}b
+ 0: a\x{100}
+ 1: 
+ 2: \x{100}
+
+/a(.*)(.)/
+    a\xc0\x88b
+ 0: a\xc0\x88b
+ 1: \xc0\x88
+ 2: b
+
+/a(.*)(.)/8
+    a\x{100}b
+ 0: a\x{100}b
+ 1: \x{100}
+ 2: b
+
+/a(.)(.)/
+    a\xc0\x92bcd
+ 0: a\xc0\x92
+ 1: \xc0
+ 2: \x92
+
+/a(.)(.)/8
+    a\x{240}bcd
+ 0: a\x{240}b
+ 1: \x{240}
+ 2: b
+
+/a(.?)(.)/
+    a\xc0\x92bcd
+ 0: a\xc0\x92
+ 1: \xc0
+ 2: \x92
+
+/a(.?)(.)/8
+    a\x{240}bcd
+ 0: a\x{240}b
+ 1: \x{240}
+ 2: b
+
+/a(.??)(.)/
+    a\xc0\x92bcd
+ 0: a\xc0
+ 1: 
+ 2: \xc0
+
+/a(.??)(.)/8
+    a\x{240}bcd
+ 0: a\x{240}
+ 1: 
+ 2: \x{240}
+
+/a(.{3})b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+    ac\ncb 
+No match
+
+/a(.{3,})b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+    axxxxbcdefghijb 
+ 0: axxxxbcdefghijb
+ 1: xxxxbcdefghij
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 1: \x{1234}\x{4321}\x{3412}\x{3421}
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+
+/a(.{3,}?)b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+    axxxxbcdefghijb 
+ 0: axxxxb
+ 1: xxxx
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 1: \x{1234}\x{4321}\x{3412}\x{3421}
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+
+/a(.{3,5})b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+    axxxxbcdefghijb 
+ 0: axxxxb
+ 1: xxxx
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 1: \x{1234}\x{4321}\x{3412}\x{3421}
+    axbxxbcdefghijb 
+ 0: axbxxb
+ 1: xbxx
+    axxxxxbcdefghijb 
+ 0: axxxxxb
+ 1: xxxxx
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+    axxxxxxbcdefghijb 
+No match
+
+/a(.{3,5}?)b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+ 1: \x{1234}xy
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+ 1: \x{1234}\x{4321}y
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+ 1: \x{1234}\x{4321}\x{3412}
+    axxxxbcdefghijb 
+ 0: axxxxb
+ 1: xxxx
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+ 1: \x{1234}\x{4321}\x{3412}\x{3421}
+    axbxxbcdefghijb 
+ 0: axbxxb
+ 1: xbxx
+    axxxxxbcdefghijb 
+ 0: axxxxxb
+ 1: xxxxx
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+    axxxxxxbcdefghijb 
+No match
+
+/^[a\x{c0}]/8
+    *** Failers
+No match
+    \x{100}
+No match
+
+/(?<=aXb)cd/8
+    aXbcd
+ 0: cd
+
+/(?<=a\x{100}b)cd/8
+    a\x{100}bcd
+ 0: cd
+
+/(?<=a\x{100000}b)cd/8
+    a\x{100000}bcd
+ 0: cd
+    
+/(?:\x{100}){3}b/8
+    \x{100}\x{100}\x{100}b
+ 0: \x{100}\x{100}\x{100}b
+    *** Failers 
+No match
+    \x{100}\x{100}b
+No match
+
+/\x{ab}/8
+    \x{ab} 
+ 0: \x{ab}
+    \xc2\xab
+ 0: \x{ab}
+    *** Failers 
+No match
+    \x00{ab}
+No match
+
+/(?<=(.))X/8
+    WXYZ
+ 0: X
+ 1: W
+    \x{256}XYZ 
+ 0: X
+ 1: \x{256}
+    *** Failers
+No match
+    XYZ 
+No match
+
+/X(\C{3})/8
+    X\x{1234}
+ 0: X\x{1234}
+ 1: \x{1234}
+
+/X(\C{4})/8
+    X\x{1234}YZ
+ 0: X\x{1234}Y
+ 1: \x{1234}Y
+    
+/X\C*/8
+    XYZabcdce
+ 0: XYZabcdce
+    
+/X\C*?/8
+    XYZabcde
+ 0: X
+    
+/X\C{3,5}/8
+    Xabcdefg   
+ 0: Xabcde
+    X\x{1234} 
+ 0: X\x{1234}
+    X\x{1234}YZ
+ 0: X\x{1234}YZ
+    X\x{1234}\x{512}  
+ 0: X\x{1234}\x{512}
+    X\x{1234}\x{512}YZ
+ 0: X\x{1234}\x{512}
+
+/X\C{3,5}?/8
+    Xabcdefg   
+ 0: Xabc
+    X\x{1234} 
+ 0: X\x{1234}
+    X\x{1234}YZ
+ 0: X\x{1234}
+    X\x{1234}\x{512}  
+ 0: X\x{1234}
+
+/[^a]+/8g
+    bcd
+ 0: bcd
+    \x{100}aY\x{256}Z 
+ 0: \x{100}
+ 0: Y\x{256}Z
+    
+/^[^a]{2}/8
+    \x{100}bc
+ 0: \x{100}b
+ 
+/^[^a]{2,}/8
+    \x{100}bcAa
+ 0: \x{100}bcA
+
+/^[^a]{2,}?/8
+    \x{100}bca
+ 0: \x{100}b
+
+/[^a]+/8ig
+    bcd
+ 0: bcd
+    \x{100}aY\x{256}Z 
+ 0: \x{100}
+ 0: Y\x{256}Z
+    
+/^[^a]{2}/8i
+    \x{100}bc
+ 0: \x{100}b
+ 
+/^[^a]{2,}/8i
+    \x{100}bcAa
+ 0: \x{100}bc
+
+/^[^a]{2,}?/8i
+    \x{100}bca
+ 0: \x{100}b
+
+/\x{100}{0,0}/8
+    abcd
+ 0: 
+ 
+/\x{100}?/8
+    abcd
+ 0: 
+    \x{100}\x{100} 
+ 0: \x{100}
+
+/\x{100}{0,3}/8 
+    \x{100}\x{100} 
+ 0: \x{100}\x{100}
+    \x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}\x{100}\x{100}
+    
+/\x{100}*/8
+    abce
+ 0: 
+    \x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{1,1}/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}
+
+/\x{100}{1,3}/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}\x{100}\x{100}
+
+/\x{100}+/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{3}/8
+    abcd\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}
+
+/\x{100}{3,5}/8
+    abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}
+
+/\x{100}{3,}/8
+    abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+
+/(?<=a\x{100}{2}b)X/8+
+    Xyyya\x{100}\x{100}bXzzz
+ 0: X
+ 0+ zzz
+
+/\D*/8
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\D*/8
+  \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+
+/\D/8
+    1X2
+ 0: X
+    1\x{100}2 
+ 0: \x{100}
+  
+/>\S/8
+    > >X Y
+ 0: >X
+    > >\x{100} Y
+ 0: >\x{100}
+  
+/\d/8
+    \x{100}3
+ 0: 3
+    
+/\s/8
+    \x{100} X
+ 0:  
+    
+/\D+/8
+    12abcd34
+ 0: abcd
+    *** Failers
+ 0: *** Failers
+    1234  
+No match
+
+/\D{2,3}/8
+    12abcd34
+ 0: abc
+    12ab34
+ 0: ab
+    *** Failers  
+ 0: ***
+    1234
+No match
+    12a34  
+No match
+
+/\D{2,3}?/8
+    12abcd34
+ 0: ab
+    12ab34
+ 0: ab
+    *** Failers  
+ 0: **
+    1234
+No match
+    12a34  
+No match
+
+/\d+/8
+    12abcd34
+ 0: 12
+    *** Failers
+No match
+
+/\d{2,3}/8
+    12abcd34
+ 0: 12
+    1234abcd
+ 0: 123
+    *** Failers  
+No match
+    1.4 
+No match
+
+/\d{2,3}?/8
+    12abcd34
+ 0: 12
+    1234abcd
+ 0: 12
+    *** Failers  
+No match
+    1.4 
+No match
+
+/\S+/8
+    12abcd34
+ 0: 12abcd34
+    *** Failers
+ 0: ***
+    \    \ 
+No match
+
+/\S{2,3}/8
+    12abcd34
+ 0: 12a
+    1234abcd
+ 0: 123
+    *** Failers
+ 0: ***
+    \     \  
+No match
+
+/\S{2,3}?/8
+    12abcd34
+ 0: 12
+    1234abcd
+ 0: 12
+    *** Failers
+ 0: **
+    \     \  
+No match
+
+/>\s+</8+
+    12>      <34
+ 0: >      <
+ 0+ 34
+    *** Failers
+No match
+
+/>\s{2,3}</8+
+    ab>  <cd
+ 0: >  <
+ 0+ cd
+    ab>   <ce
+ 0: >   <
+ 0+ ce
+    *** Failers
+No match
+    ab>    <cd 
+No match
+
+/>\s{2,3}?</8+
+    ab>  <cd
+ 0: >  <
+ 0+ cd
+    ab>   <ce
+ 0: >   <
+ 0+ ce
+    *** Failers
+No match
+    ab>    <cd 
+No match
+
+/\w+/8
+    12      34
+ 0: 12
+    *** Failers
+ 0: Failers
+    +++=*! 
+No match
+
+/\w{2,3}/8
+    ab  cd
+ 0: ab
+    abcd ce
+ 0: abc
+    *** Failers
+ 0: Fai
+    a.b.c
+No match
+
+/\w{2,3}?/8
+    ab  cd
+ 0: ab
+    abcd ce
+ 0: ab
+    *** Failers
+ 0: Fa
+    a.b.c
+No match
+
+/\W+/8
+    12====34
+ 0: ====
+    *** Failers
+ 0: *** 
+    abcd 
+No match
+
+/\W{2,3}/8
+    ab====cd
+ 0: ===
+    ab==cd
+ 0: ==
+    *** Failers
+ 0: ***
+    a.b.c
+No match
+
+/\W{2,3}?/8
+    ab====cd
+ 0: ==
+    ab==cd
+ 0: ==
+    *** Failers
+ 0: **
+    a.b.c
+No match
+
+/[\x{100}]/8
+    \x{100}
+ 0: \x{100}
+    Z\x{100}
+ 0: \x{100}
+    \x{100}Z
+ 0: \x{100}
+    *** Failers 
+No match
+
+/[Z\x{100}]/8
+    Z\x{100}
+ 0: Z
+    \x{100}
+ 0: \x{100}
+    \x{100}Z
+ 0: \x{100}
+    *** Failers 
+No match
+
+/[\x{100}\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   *** Failers  
+No match
+
+/[\x{100}-\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{111}cd 
+ 0: \x{111}
+   *** Failers  
+No match
+
+/[z-\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{111}cd 
+ 0: \x{111}
+   abzcd
+ 0: z
+   ab|cd  
+ 0: |
+   *** Failers  
+No match
+
+/[Q\x{100}\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   Q? 
+ 0: Q
+   *** Failers  
+No match
+
+/[Q\x{100}-\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{111}cd 
+ 0: \x{111}
+   Q? 
+ 0: Q
+   *** Failers  
+No match
+
+/[Qz-\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{111}cd 
+ 0: \x{111}
+   abzcd
+ 0: z
+   ab|cd  
+ 0: |
+   Q? 
+ 0: Q
+   *** Failers  
+No match
+
+/[\x{100}\x{200}]{1,3}/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}\x{100}\x{200}
+   *** Failers  
+No match
+
+/[\x{100}\x{200}]{1,3}?/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}
+   *** Failers  
+No match
+
+/[Q\x{100}\x{200}]{1,3}/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}\x{100}\x{200}
+   *** Failers  
+No match
+
+/[Q\x{100}\x{200}]{1,3}?/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}
+   *** Failers  
+No match
+
+/(?<=[\x{100}\x{200}])X/8
+    abc\x{200}X
+ 0: X
+    abc\x{100}X 
+ 0: X
+    *** Failers
+No match
+    X  
+No match
+
+/(?<=[Q\x{100}\x{200}])X/8
+    abc\x{200}X
+ 0: X
+    abc\x{100}X 
+ 0: X
+    abQX 
+ 0: X
+    *** Failers
+No match
+    X  
+No match
+
+/(?<=[\x{100}\x{200}]{3})X/8
+    abc\x{100}\x{200}\x{100}X
+ 0: X
+    *** Failers
+No match
+    abc\x{200}X
+No match
+    X  
+No match
+
+/[^\x{100}\x{200}]X/8
+    AX
+ 0: AX
+    \x{150}X
+ 0: \x{150}X
+    \x{500}X 
+ 0: \x{500}X
+    *** Failers
+No match
+    \x{100}X
+No match
+    \x{200}X   
+No match
+
+/[^Q\x{100}\x{200}]X/8
+    AX
+ 0: AX
+    \x{150}X
+ 0: \x{150}X
+    \x{500}X 
+ 0: \x{500}X
+    *** Failers
+No match
+    \x{100}X
+No match
+    \x{200}X   
+No match
+    QX 
+No match
+
+/[^\x{100}-\x{200}]X/8
+    AX
+ 0: AX
+    \x{500}X 
+ 0: \x{500}X
+    *** Failers
+No match
+    \x{100}X
+No match
+    \x{150}X
+No match
+    \x{200}X   
+No match
+
+/a\Cb/
+    aXb
+ 0: aXb
+    a\nb
+ 0: a\x0ab
+  
+/a\Cb/8
+    aXb
+ 0: aXb
+    a\nb
+ 0: a\x{0a}b
+    *** Failers 
+No match
+    a\x{100}b 
+No match
+
+/[z-\x{100}]/8i
+    z
+ 0: z
+    Z 
+ 0: Z
+    \x{100}
+ 0: \x{100}
+    *** Failers
+No match
+    \x{102}
+No match
+    y    
+No match
+
+/[\xFF]/
+    >\xff<
+ 0: \xff
+
+/[\xff]/8
+    >\x{ff}<
+ 0: \x{ff}
+
+/[^\xFF]/
+    XYZ
+ 0: X
+
+/[^\xff]/8
+    XYZ
+ 0: X
+    \x{123} 
+ 0: \x{123}
+
+/^[ac]*b/8
+  xb
+No match
+
+/^[ac\x{100}]*b/8
+  xb
+No match
+
+/^[^x]*b/8i
+  xb
+No match
+
+/^[^x]*b/8
+  xb
+No match
+  
+/^\d*b/8
+  xb 
+No match
+
+/(|a)/g8
+    catac
+ 0: 
+ 1: 
+ 0: 
+ 1: 
+ 0: a
+ 1: a
+ 0: 
+ 1: 
+ 0: 
+ 1: 
+ 0: a
+ 1: a
+ 0: 
+ 1: 
+ 0: 
+ 1: 
+    a\x{256}a 
+ 0: 
+ 1: 
+ 0: a
+ 1: a
+ 0: 
+ 1: 
+ 0: 
+ 1: 
+ 0: a
+ 1: a
+ 0: 
+ 1: 
+
+/^\x{85}$/8i
+    \x{85}
+ 0: \x{85}
+
+/^ሴ/8
+    ሴ 
+ 0: \x{1234}
+
+/^\ሴ/8
+    ሴ 
+ 0: \x{1234}
+
+"(?s)(.{1,5})"8
+    abcdefg
+ 0: abcde
+ 1: abcde
+    ab
+ 0: ab
+ 1: ab
+
+/a*\x{100}*\w/8
+    a 
+ 0: a
+
+/\S\S/8g
+    A\x{a3}BC
+ 0: A\x{a3}
+ 0: BC
+    
+/\S{2}/8g
+    A\x{a3}BC
+ 0: A\x{a3}
+ 0: BC
+    
+/\W\W/8g
+    +\x{a3}== 
+ 0: +\x{a3}
+ 0: ==
+
+/\W{2}/8g
+    +\x{a3}== 
+ 0: +\x{a3}
+ 0: ==
+
+/\S/8g
+    \x{442}\x{435}\x{441}\x{442}
+ 0: \x{442}
+ 0: \x{435}
+ 0: \x{441}
+ 0: \x{442}
+
+/[\S]/8g
+    \x{442}\x{435}\x{441}\x{442}
+ 0: \x{442}
+ 0: \x{435}
+ 0: \x{441}
+ 0: \x{442}
+
+/\D/8g
+    \x{442}\x{435}\x{441}\x{442}
+ 0: \x{442}
+ 0: \x{435}
+ 0: \x{441}
+ 0: \x{442}
+
+/[\D]/8g
+    \x{442}\x{435}\x{441}\x{442}
+ 0: \x{442}
+ 0: \x{435}
+ 0: \x{441}
+ 0: \x{442}
+
+/\W/8g
+    \x{2442}\x{2435}\x{2441}\x{2442}
+ 0: \x{2442}
+ 0: \x{2435}
+ 0: \x{2441}
+ 0: \x{2442}
+
+/[\W]/8g
+    \x{2442}\x{2435}\x{2441}\x{2442}
+ 0: \x{2442}
+ 0: \x{2435}
+ 0: \x{2441}
+ 0: \x{2442}
+    
+/[\S\s]*/8
+    abc\n\r\x{442}\x{435}\x{441}\x{442}xyz 
+ 0: abc\x{0a}\x{0d}\x{442}\x{435}\x{441}\x{442}xyz
+
+/[\x{41f}\S]/8g
+    \x{442}\x{435}\x{441}\x{442}
+ 0: \x{442}
+ 0: \x{435}
+ 0: \x{441}
+ 0: \x{442}
+
+/.[^\S]./8g
+    abc def\x{442}\x{443}xyz\npqr
+ 0: c d
+ 0: z\x{0a}p
+
+/.[^\S\n]./8g
+    abc def\x{442}\x{443}xyz\npqr
+ 0: c d
+
+/[[:^alnum:]]/8g  
+    +\x{2442}
+ 0: +
+ 0: \x{2442}
+    
+/[[:^alpha:]]/8g 
+    +\x{2442}
+ 0: +
+ 0: \x{2442}
+    
+/[[:^ascii:]]/8g 
+    A\x{442}
+ 0: \x{442}
+    
+/[[:^blank:]]/8g 
+    A\x{442}
+ 0: A
+ 0: \x{442}
+    
+/[[:^cntrl:]]/8g 
+    A\x{442}
+ 0: A
+ 0: \x{442}
+    
+/[[:^digit:]]/8g 
+    A\x{442}
+ 0: A
+ 0: \x{442}
+    
+/[[:^graph:]]/8g 
+    \x19\x{e01ff}
+ 0: \x{19}
+ 0: \x{e01ff}
+    
+/[[:^lower:]]/8g 
+    A\x{422}
+ 0: A
+ 0: \x{422}
+    
+/[[:^print:]]/8g 
+    \x{19}\x{e01ff}
+ 0: \x{19}
+ 0: \x{e01ff}
+    
+/[[:^punct:]]/8g 
+    A\x{442}
+ 0: A
+ 0: \x{442}
+    
+/[[:^space:]]/8g 
+    A\x{442}
+ 0: A
+ 0: \x{442}
+    
+/[[:^upper:]]/8g 
+    a\x{442}
+ 0: a
+ 0: \x{442}
+    
+/[[:^word:]]/8g  
+    +\x{2442}
+ 0: +
+ 0: \x{2442}
+    
+/[[:^xdigit:]]/8g
+    M\x{442}
+ 0: M
+ 0: \x{442}
+
+/[^ABCDEFGHIJKLMNOPQRSTUVWXYZÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞĀĂĄĆĈĊČĎÄĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿÅŃŅŇŊŌŎÅÅ’Å”Å–Å˜ÅšÅœÅžÅ Å¢Å¤Å¦Å¨ÅªÅ¬Å®Å°Å²Å´Å¶Å¸Å¹Å»Å½ÆÆ‚Æ„Æ†Æ‡Æ‰ÆŠÆ‹ÆŽÆÆÆ‘Æ“Æ”Æ–Æ—Æ˜ÆœÆÆŸÆ Æ¢Æ¤Æ¦Æ§Æ©Æ¬Æ®Æ¯Æ±Æ²Æ³ÆµÆ·Æ¸Æ¼Ç„LJNJÇÇǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶǷǸǺǼǾȀȂȄȆȈȊȌȎÈȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺȻȽȾÉΆΈΉΊΌΎÎΑΒΓΔΕΖΗΘΙΚΛΜÎΞΟΠΡΣΤΥΦΧΨΩΪΫϒϓϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹϺϽϾϿЀÐЂЃЄЅІЇЈЉЊЋЌÐÐŽÐÐБВГДЕЖЗИЙКЛМÐОПРСТУФХЦЧШЩЪЫЬЭЮЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎÒҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀÓÓƒÓ…Ó‡Ó‰Ó‹ÓÓӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸԀԂԄԆԈԊԌԎԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀÕÕ‚ÕƒÕ„Õ…Õ†Õ‡ÕˆÕ‰ÕŠÕ‹ÕŒÕÕŽÕÕՑՒՓՔՕՖႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀáƒáƒ‚ჃჄჅḀḂḄḆḈḊḌḎá¸á¸’ḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎá¹á¹’ṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎáºáº’ẔẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎá»á»’ỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸἈἉἊἋἌá¼á¼Žá¼á¼˜á¼™á¼šá¼›á¼œá¼á¼¨á¼©á¼ªá¼«á¼¬á¼­á¼®á¼¯á¼¸á¼¹á¼ºá¼»á¼¼á¼½á¼¾á¼¿á½ˆá½‰á½Šá½‹á½Œá½á½™á½›á½á½Ÿá½¨á½©á½ªá½«á½¬á½­á½®á½¯á¾¸á¾¹á¾ºá¾»á¿ˆá¿‰á¿Šá¿‹á¿˜á¿™á¿šá¿›á¿¨á¿©á¿ªá¿«á¿¬á¿¸á¿¹á¿ºá¿»abcdefghijklmnopqrstuvwxyzªµºßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿÄăąćĉċÄÄđēĕėęěÄğġģĥħĩīĭįıijĵķĸĺļľŀłńņňʼnŋÅÅőœŕŗřśÅÅŸÅ¡Å£Å¥Å§Å©Å«Å­Å¯Å±Å³ÅµÅ·ÅºÅ¼Å¾Å¿Æ€ÆƒÆ…ÆˆÆŒÆÆ’ƕƙƚƛƞơƣƥƨƪƫƭưƴƶƹƺƽƾƿdžljnjǎÇǒǔǖǘǚǜÇǟǡǣǥǧǩǫǭǯǰdzǵǹǻǽǿÈȃȅȇȉȋÈÈȑȓȕȗșțÈȟȡȣȥȧȩȫȭȯȱȳȴȵȶȷȸȹȼȿɀÉɑɒɓɔɕɖɗɘəɚɛɜÉɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀÊʂʃʄʅʆʇʈʉʊʋʌÊÊŽÊÊʑʒʓʔʕʖʗʘʙʚʛʜÊʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯÎάέήίΰαβγδεζηθικλμνξοπÏςστυφχψωϊϋόÏÏŽÏϑϕϖϗϙϛÏϟϡϣϥϧϩϫϭϯϰϱϲϳϵϸϻϼабвгдежзийклмнопрÑтуфхцчшщъыьÑÑŽÑÑёђѓєѕіїјљњћќÑўџѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿÒÒ‹ÒÒÒ‘Ò“Ò•Ò—Ò™Ò›ÒҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӆӈӊӌӎӑӓӕӗәӛÓÓŸÓ¡Ó£Ó¥Ó§Ó©Ó«Ó­Ó¯Ó±Ó³ÓµÓ·Ó¹ÔÔƒÔ…Ô‡Ô‰Ô‹ÔÔÕ¡Õ¢Õ£Õ¤Õ¥Õ¦Õ§Õ¨Õ©ÕªÕ«Õ¬Õ­Õ®Õ¯Õ°Õ±Õ²Õ³Õ´ÕµÕ¶Õ·Õ¸Õ¹ÕºÕ»Õ¼Õ½Õ¾Õ¿Ö€Öւփքօֆևᴀá´á´‚ᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌá´á´Žá´á´á´‘ᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜá´á´žá´Ÿá´ á´¡á´¢á´£á´¤á´¥á´¦á´§á´¨á´©á´ªá´«áµ¢áµ£áµ¤áµ¥áµ¦áµ§áµ¨áµ©áµªáµ«áµ¬áµ­áµ®áµ¯áµ°áµ±áµ²áµ³áµ´áµµáµ¶áµ·áµ¹áµºáµ»áµ¼áµ½áµ¾áµ¿á¶€á¶á¶‚ᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌá¶á¶Žá¶á¶á¶‘ᶒᶓᶔᶕᶖᶗᶘᶙᶚá¸á¸ƒá¸…ḇḉḋá¸á¸á¸‘ḓḕḗḙḛá¸á¸Ÿá¸¡á¸£á¸¥á¸§á¸©á¸«á¸­á¸¯á¸±á¸³á¸µá¸·á¸¹á¸»á¸½á¸¿á¹á¹ƒá¹…ṇṉṋá¹á¹á¹‘ṓṕṗṙṛá¹á¹Ÿá¹¡á¹£á¹¥á¹§á¹©á¹«á¹­á¹¯á¹±á¹³á¹µá¹·á¹¹á¹»á¹½á¹¿áºáºƒáº…ẇẉẋáºáºáº‘ẓẕẖẗẘẙẚẛạảấầẩẫậắằẳẵặẹẻẽếá»á»ƒá»…ệỉịá»á»á»‘ồổỗộớá»á»Ÿá»¡á»£á»¥á»§á»©á»«á»­á»¯á»±á»³á»µá»·á»¹á¼€á¼á¼‚ἃἄἅἆἇá¼á¼‘ἒἓἔἕἠἡἢἣἤἥἦἧἰἱἲἳἴἵἶἷὀá½á½‚ὃὄὅá½á½‘ὒὓὔὕὖὗὠὡὢὣὤὥὦὧὰάὲέὴήὶίὸόὺύὼώᾀá¾á¾‚ᾃᾄᾅᾆᾇá¾á¾‘ᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷιῂῃῄῆῇá¿á¿‘ῒΐῖῗῠῡῢΰῤῥῦῧῲῳῴῶῷâ²â²ƒâ²…ⲇⲉⲋâ²â²â²‘ⲓⲕⲗⲙⲛâ²â²Ÿâ²¡â²£â²¥â²§â²©â²«â²­â²¯â²±â²³â²µâ²·â²¹â²»â²½â²¿â³â³ƒâ³…ⳇⳉⳋâ³â³â³‘ⳓⳕⳗⳙⳛâ³â³Ÿâ³¡â³£â³¤â´€â´â´‚ⴃⴄⴅⴆⴇⴈⴉⴊⴋⴌâ´â´Žâ´â´â´‘ⴒⴓⴔⴕⴖⴗⴘⴙⴚⴛⴜâ´â´žâ´Ÿâ´ â´¡â´¢â´£â´¤â´¥ï¬€ï¬ï¬‚ffifflſtstﬓﬔﬕﬖﬗ\d-_^]/8
+
+/^[^d]*?$/
+    abc
+ 0: abc
+
+/^[^d]*?$/8
+    abc
+ 0: abc
+
+/^[^d]*?$/i
+    abc
+ 0: abc
+
+/^[^d]*?$/8i
+    abc
+ 0: abc
+
+/(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]/8
+
+/ End of testinput4 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput5	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1644 @@
+/\x{100}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 196
+Need char = 128
+
+/\x{1000}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{1000}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 225
+Need char = 128
+
+/\x{10000}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{10000}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 240
+Need char = 128
+
+/\x{100000}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100000}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 244
+Need char = 128
+
+/\x{1000000}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{1000000}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 249
+Need char = 128
+
+/\x{4000000}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{4000000}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 252
+Need char = 128
+
+/\x{7fffFFFF}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{7fffffff}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 253
+Need char = 191
+
+/[\x{ff}]/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{ff}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 195
+Need char = 191
+
+/[\x{100}]/8DZ
+------------------------------------------------------------------
+        Bra
+        [\x{100}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/\x{ffffffff}/8
+Failed: character value in \x{...} sequence is too large at offset 11
+
+/\x{100000000}/8
+Failed: character value in \x{...} sequence is too large at offset 12
+
+/^\x{100}a\x{1234}/8
+    \x{100}a\x{1234}bcd
+ 0: \x{100}a\x{1234}
+
+/\x80/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{80}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 194
+Need char = 128
+
+/\xff/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{ff}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 195
+Need char = 191
+
+/\x{0041}\x{2262}\x{0391}\x{002e}/DZ8
+------------------------------------------------------------------
+        Bra
+        A\x{2262}\x{391}.
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'A'
+Need char = '.'
+    \x{0041}\x{2262}\x{0391}\x{002e}
+ 0: A\x{2262}\x{391}.
+    
+/\x{D55c}\x{ad6d}\x{C5B4}/DZ8 
+------------------------------------------------------------------
+        Bra
+        \x{d55c}\x{ad6d}\x{c5b4}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 237
+Need char = 180
+    \x{D55c}\x{ad6d}\x{C5B4} 
+ 0: \x{d55c}\x{ad6d}\x{c5b4}
+
+/\x{65e5}\x{672c}\x{8a9e}/DZ8
+------------------------------------------------------------------
+        Bra
+        \x{65e5}\x{672c}\x{8a9e}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 230
+Need char = 158
+    \x{65e5}\x{672c}\x{8a9e}
+ 0: \x{65e5}\x{672c}\x{8a9e}
+
+/\x{80}/DZ8
+------------------------------------------------------------------
+        Bra
+        \x{80}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 194
+Need char = 128
+
+/\x{084}/DZ8
+------------------------------------------------------------------
+        Bra
+        \x{84}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 194
+Need char = 132
+
+/\x{104}/DZ8
+------------------------------------------------------------------
+        Bra
+        \x{104}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 196
+Need char = 132
+
+/\x{861}/DZ8
+------------------------------------------------------------------
+        Bra
+        \x{861}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 224
+Need char = 161
+
+/\x{212ab}/DZ8
+------------------------------------------------------------------
+        Bra
+        \x{212ab}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 240
+Need char = 171
+
+/.{3,5}X/DZ8
+------------------------------------------------------------------
+        Bra
+        Any{3}
+        Any{0,2}
+        X
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+Need char = 'X'
+    \x{212ab}\x{212ab}\x{212ab}\x{861}X
+ 0: \x{212ab}\x{212ab}\x{212ab}\x{861}X
+
+
+/.{3,5}?/DZ8
+------------------------------------------------------------------
+        Bra
+        Any{3}
+        Any{0,2}?
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+    \x{212ab}\x{212ab}\x{212ab}\x{861}
+ 0: \x{212ab}\x{212ab}\x{212ab}
+
+/-- These tests are here rather than in testinput4 because Perl 5.6 has some
+problems with UTF-8 support, in the area of \x{..} where the value is < 255. 
+It grumbles about invalid UTF-8 strings. --/
+
+/^[a\x{c0}]b/8
+    \x{c0}b
+ 0: \x{c0}b
+    
+/^([a\x{c0}]*?)aa/8
+    a\x{c0}aaaa/ 
+ 0: a\x{c0}aa
+ 1: a\x{c0}
+
+/^([a\x{c0}]*?)aa/8
+    a\x{c0}aaaa/ 
+ 0: a\x{c0}aa
+ 1: a\x{c0}
+    a\x{c0}a\x{c0}aaa/ 
+ 0: a\x{c0}a\x{c0}aa
+ 1: a\x{c0}a\x{c0}
+
+/^([a\x{c0}]*)aa/8
+    a\x{c0}aaaa/ 
+ 0: a\x{c0}aaaa
+ 1: a\x{c0}aa
+    a\x{c0}a\x{c0}aaa/ 
+ 0: a\x{c0}a\x{c0}aaa
+ 1: a\x{c0}a\x{c0}a
+
+/^([a\x{c0}]*)a\x{c0}/8
+    a\x{c0}aaaa/ 
+ 0: a\x{c0}
+ 1: 
+    a\x{c0}a\x{c0}aaa/ 
+ 0: a\x{c0}a\x{c0}
+ 1: a\x{c0}
+    
+/-- --/ 
+    
+/(?<=\C)X/8
+Failed: \C not allowed in lookbehind assertion at offset 6
+
+/-- This one is here not because it's different to Perl, but because the way
+the captured single-byte is displayed. (In Perl it becomes a character, and you
+can't tell the difference.) --/
+    
+/X(\C)(.*)/8
+    X\x{1234}
+ 0: X\x{1234}
+ 1: \xe1
+ 2: \x88\xb4
+    X\nabc 
+ 0: X\x{0a}abc
+ 1: \x{0a}
+ 2: abc
+    
+/^[ab]/8DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [ab]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored utf8
+No first char
+No need char
+    bar
+ 0: b
+    *** Failers
+No match
+    c
+No match
+    \x{ff}
+No match
+    \x{100}  
+No match
+
+/^[^ab]/8DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x00-`c-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored utf8
+No first char
+No need char
+    c
+ 0: c
+    \x{ff}
+ 0: \x{ff}
+    \x{100}  
+ 0: \x{100}
+    *** Failers 
+ 0: *
+    aaa
+No match
+  
+/[^ab\xC0-\xF0]/8SDZ
+------------------------------------------------------------------
+        Bra
+        [\x00-`c-\xbf\xf1-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+Starting byte set: \x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0a 
+  \x0b \x0c \x0d \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 
+  \x1a \x1b \x1c \x1d \x1e \x1f \x20 ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 
+  5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y 
+  Z [ \ ] ^ _ ` c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ \x7f 
+  \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 
+  \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf 
+  \xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee 
+  \xef \xf0 \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf7 \xf8 \xf9 \xfa \xfb \xfc \xfd 
+  \xfe \xff 
+    \x{f1}
+ 0: \x{f1}
+    \x{bf}
+ 0: \x{bf}
+    \x{100}
+ 0: \x{100}
+    \x{1000}   
+ 0: \x{1000}
+    *** Failers
+ 0: *
+    \x{c0} 
+No match
+    \x{f0} 
+No match
+
+/Ä€{3,4}/8SDZ
+------------------------------------------------------------------
+        Bra
+        \x{100}{3}
+        \x{100}?
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+First char = 196
+Need char = 128
+Study returned NULL
+  \x{100}\x{100}\x{100}\x{100\x{100}
+ 0: \x{100}\x{100}\x{100}
+
+/(\x{100}+|x)/8SDZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        \x{100}+
+        Alt
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+Starting byte set: x \xc4 
+
+/(\x{100}*a|x)/8SDZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        \x{100}*+
+        a
+        Alt
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+Starting byte set: a x \xc4 
+
+/(\x{100}{0,2}a|x)/8SDZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        \x{100}{0,2}
+        a
+        Alt
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+Starting byte set: a x \xc4 
+
+/(\x{100}{1,2}a|x)/8SDZ
+------------------------------------------------------------------
+        Bra
+        CBra 1
+        \x{100}
+        \x{100}{0,1}
+        a
+        Alt
+        x
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+Starting byte set: x \xc4 
+
+/\x{100}*(\d+|"(?1)")/8
+    1234
+ 0: 1234
+ 1: 1234
+    "1234" 
+ 0: "1234"
+ 1: "1234"
+    \x{100}1234
+ 0: \x{100}1234
+ 1: 1234
+    "\x{100}1234"  
+ 0: \x{100}1234
+ 1: 1234
+    \x{100}\x{100}12ab 
+ 0: \x{100}\x{100}12
+ 1: 12
+    \x{100}\x{100}"12" 
+ 0: \x{100}\x{100}"12"
+ 1: "12"
+    *** Failers 
+No match
+    \x{100}\x{100}abcd
+No match
+
+/\x{100}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 196
+Need char = 128
+
+/\x{100}*/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+
+/a\x{100}*/8DZ
+------------------------------------------------------------------
+        Bra
+        a
+        \x{100}*
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+First char = 'a'
+No need char
+
+/ab\x{100}*/8DZ
+------------------------------------------------------------------
+        Bra
+        ab
+        \x{100}*
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+First char = 'a'
+Need char = 'b'
+
+/a\x{100}\x{101}*/8DZ
+------------------------------------------------------------------
+        Bra
+        a\x{100}
+        \x{101}*
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+First char = 'a'
+Need char = 128
+
+/a\x{100}\x{101}+/8DZ
+------------------------------------------------------------------
+        Bra
+        a\x{100}
+        \x{101}+
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+First char = 'a'
+Need char = 129
+
+/\x{100}*A/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*+
+        A
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+Need char = 'A'
+    A
+ 0: A
+
+/\x{100}*\d(?R)/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*+
+        \d
+        Once
+        Recurse
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+
+/[^\x{c4}]/DZ
+------------------------------------------------------------------
+        Bra
+        [^\xc4]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[^\x{c4}]/8DZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\xc3\xc5-\xff] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/[\x{100}]/8DZ
+------------------------------------------------------------------
+        Bra
+        [\x{100}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+    \x{100}
+ 0: \x{100}
+    Z\x{100}
+ 0: \x{100}
+    \x{100}Z
+ 0: \x{100}
+    *** Failers 
+No match
+
+/[Z\x{100}]/8DZ
+------------------------------------------------------------------
+        Bra
+        [Z\x{100}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+    Z\x{100}
+ 0: Z
+    \x{100}
+ 0: \x{100}
+    \x{100}Z
+ 0: \x{100}
+    *** Failers 
+No match
+
+/[\x{200}-\x{100}]/8
+Failed: range out of order in character class at offset 15
+
+/[Ä€-Ä„]/8
+    \x{100}
+ 0: \x{100}
+    \x{104}
+ 0: \x{104}
+    *** Failers
+No match
+    \x{105}
+No match
+    \x{ff}    
+No match
+
+/[z-\x{100}]/8DZ
+------------------------------------------------------------------
+        Bra
+        [z-\x{100}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/[z\Qa-d]Ä€\E]/8DZ
+------------------------------------------------------------------
+        Bra
+        [\-\]adz\x{100}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+    \x{100}
+ 0: \x{100}
+    Ā 
+ 0: \x{100}
+
+/[\xFF]/DZ
+------------------------------------------------------------------
+        Bra
+        \xff
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+First char = 255
+No need char
+    >\xff<
+ 0: \xff
+
+/[\xff]/DZ8
+------------------------------------------------------------------
+        Bra
+        \x{ff}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 195
+Need char = 191
+    >\x{ff}<
+ 0: \x{ff}
+
+/[^\xFF]/DZ
+------------------------------------------------------------------
+        Bra
+        [^\xff]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[^\xff]/8DZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\xfe] (neg)
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/[Ä-Ü]/8
+    Ö # Matches without Study
+ 0: \x{d6}
+    \x{d6}
+ 0: \x{d6}
+    
+/[Ä-Ü]/8S
+    Ö <-- Same with Study
+ 0: \x{d6}
+    \x{d6}
+ 0: \x{d6}
+    
+/[\x{c4}-\x{dc}]/8 
+    Ö # Matches without Study
+ 0: \x{d6}
+    \x{d6} 
+ 0: \x{d6}
+
+/[\x{c4}-\x{dc}]/8S
+    Ö <-- Same with Study
+ 0: \x{d6}
+    \x{d6} 
+ 0: \x{d6}
+
+/[Ã]/8
+Failed: invalid UTF-8 string at offset 2
+
+/Ã/8
+Failed: invalid UTF-8 string at offset 0
+
+/ÃÃÃxxx/8
+Failed: invalid UTF-8 string at offset 1
+
+/ÃÃÃxxx/8?DZ
+------------------------------------------------------------------
+        Bra
+        \X{c0}\X{c0}\X{c0}xxx
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8 no_utf8_check
+First char = 195
+Need char = 'x'
+
+/abc/8
+    Ã]
+Error -10
+    Ã
+Error -10
+    ÃÃÃ
+Error -10
+    ÃÃÃ\?
+No match
+
+/anything/8
+    \xc0\x80
+Error -10
+    \xc1\x8f 
+Error -10
+    \xe0\x9f\x80
+Error -10
+    \xf0\x8f\x80\x80 
+Error -10
+    \xf8\x87\x80\x80\x80  
+Error -10
+    \xfc\x83\x80\x80\x80\x80
+Error -10
+    \xfe\x80\x80\x80\x80\x80  
+Error -10
+    \xff\x80\x80\x80\x80\x80  
+Error -10
+    \xc3\x8f
+No match
+    \xe0\xaf\x80
+No match
+    \xe1\x80\x80
+No match
+    \xf0\x9f\x80\x80 
+No match
+    \xf1\x8f\x80\x80 
+No match
+    \xf8\x88\x80\x80\x80  
+Error -10
+    \xf9\x87\x80\x80\x80  
+Error -10
+    \xfc\x84\x80\x80\x80\x80
+Error -10
+    \xfd\x83\x80\x80\x80\x80
+Error -10
+    \?\xf8\x88\x80\x80\x80  
+No match
+    \?\xf9\x87\x80\x80\x80  
+No match
+    \?\xfc\x84\x80\x80\x80\x80
+No match
+    \?\xfd\x83\x80\x80\x80\x80
+No match
+
+/\x{100}abc(xyz(?1))/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}abc
+        CBra 1
+        xyz
+        Once
+        Recurse
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options: utf8
+First char = 196
+Need char = 'z'
+
+/[^\x{100}]abc(xyz(?1))/8DZ
+------------------------------------------------------------------
+        Bra
+        [^\x{100}]
+        abc
+        CBra 1
+        xyz
+        Once
+        Recurse
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options: utf8
+No first char
+Need char = 'z'
+
+/[ab\x{100}]abc(xyz(?1))/8DZ
+------------------------------------------------------------------
+        Bra
+        [ab\x{100}]
+        abc
+        CBra 1
+        xyz
+        Once
+        Recurse
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 1
+Options: utf8
+No first char
+Need char = 'z'
+
+/(\x{100}(b(?2)c))?/DZ8
+------------------------------------------------------------------
+        Bra
+        Brazero
+        CBra 1
+        \x{100}
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Options: utf8
+No first char
+No need char
+
+/(\x{100}(b(?2)c)){0,2}/DZ8
+------------------------------------------------------------------
+        Bra
+        Brazero
+        Bra
+        CBra 1
+        \x{100}
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Brazero
+        CBra 1
+        \x{100}
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Options: utf8
+No first char
+No need char
+
+/(\x{100}(b(?1)c))?/DZ8
+------------------------------------------------------------------
+        Bra
+        Brazero
+        CBra 1
+        \x{100}
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Options: utf8
+No first char
+No need char
+
+/(\x{100}(b(?1)c)){0,2}/DZ8
+------------------------------------------------------------------
+        Bra
+        Brazero
+        Bra
+        CBra 1
+        \x{100}
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Brazero
+        CBra 1
+        \x{100}
+        CBra 2
+        b
+        Once
+        Recurse
+        Ket
+        c
+        Ket
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 2
+Options: utf8
+No first char
+No need char
+
+/\W/8
+    A.B
+ 0: .
+    A\x{100}B 
+ 0: \x{100}
+  
+/\w/8
+    \x{100}X   
+ 0: X
+
+/a\x{1234}b/P8
+    a\x{1234}b
+ 0: a\x{1234}b
+
+/^\ሴ/8DZ
+------------------------------------------------------------------
+        Bra
+        ^
+        \x{1234}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: anchored utf8
+No first char
+No need char
+
+/\777/I
+Failed: octal value is greater than \377 (not in UTF-8 mode) at offset 3
+
+/\777/8I
+Capturing subpattern count = 0
+Options: utf8
+First char = 199
+Need char = 191
+  \x{1ff}
+ 0: \x{1ff}
+  \777 
+ 0: \x{1ff}
+  
+/\x{100}*\d/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*+
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+
+/\x{100}*\s/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*+
+        \s
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+
+/\x{100}*\w/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*+
+        \w
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+
+/\x{100}*\D/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*
+        \D
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+
+/\x{100}*\S/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*
+        \S
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+
+/\x{100}*\W/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}*
+        \W
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+
+/\x{100}+\x{200}/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}++
+        \x{200}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+First char = 196
+Need char = 128
+
+/\x{100}+X/8DZ
+------------------------------------------------------------------
+        Bra
+        \x{100}++
+        X
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+First char = 196
+Need char = 'X'
+
+/X+\x{200}/8DZ
+------------------------------------------------------------------
+        Bra
+        X++
+        \x{200}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+First char = 'X'
+Need char = 128
+
+/()()()()()()()()()()
+ ()()()()()()()()()()
+ ()()()()()()()()()()
+ ()()()()()()()()()()
+ A (x) (?41) B/8x
+    AxxB     
+Matched, but too many substrings
+ 0: AxxB
+ 1: 
+ 2: 
+ 3: 
+ 4: 
+ 5: 
+ 6: 
+ 7: 
+ 8: 
+ 9: 
+10: 
+11: 
+12: 
+13: 
+14: 
+
+/^[\x{100}\E-\Q\E\x{150}]/BZ8
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x{100}-\x{150}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/^[\QÄ€\E-\QÅ\E]/BZ8
+------------------------------------------------------------------
+        Bra
+        ^
+        [\x{100}-\x{150}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/^[\QÄ€\E-\QÅ\E/BZ8
+Failed: missing terminating ] for character class at offset 15
+
+/^abc./mgx8<any>
+    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x{0085}abc7 \x{2028}abc8 \x{2029}abc9 JUNK
+ 0: abc1
+ 0: abc2
+ 0: abc3
+ 0: abc4
+ 0: abc5
+ 0: abc6
+ 0: abc7
+ 0: abc8
+ 0: abc9
+
+/abc.$/mgx8<any>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x{0085} abc7\x{2028} abc8\x{2029} abc9
+ 0: abc1
+ 0: abc2
+ 0: abc3
+ 0: abc4
+ 0: abc5
+ 0: abc6
+ 0: abc7
+ 0: abc8
+ 0: abc9
+
+/^a\Rb/8<bsr_unicode>
+    a\nb
+ 0: a\x{0a}b
+    a\rb
+ 0: a\x{0d}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x0bb
+ 0: a\x{0b}b
+    a\x0cb
+ 0: a\x{0c}b
+    a\x{85}b   
+ 0: a\x{85}b
+    a\x{2028}b 
+ 0: a\x{2028}b
+    a\x{2029}b 
+ 0: a\x{2029}b
+    ** Failers
+No match
+    a\n\rb    
+No match
+
+/^a\R*b/8<bsr_unicode>
+    ab
+ 0: ab
+    a\nb
+ 0: a\x{0a}b
+    a\rb
+ 0: a\x{0d}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x0bb
+ 0: a\x{0b}b
+    a\x0c\x{2028}\x{2029}b
+ 0: a\x{0c}\x{2028}\x{2029}b
+    a\x{85}b   
+ 0: a\x{85}b
+    a\n\rb    
+ 0: a\x{0a}\x{0d}b
+    a\n\r\x{85}\x0cb 
+ 0: a\x{0a}\x{0d}\x{85}\x{0c}b
+
+/^a\R+b/8<bsr_unicode>
+    a\nb
+ 0: a\x{0a}b
+    a\rb
+ 0: a\x{0d}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x0bb
+ 0: a\x{0b}b
+    a\x0c\x{2028}\x{2029}b
+ 0: a\x{0c}\x{2028}\x{2029}b
+    a\x{85}b   
+ 0: a\x{85}b
+    a\n\rb    
+ 0: a\x{0a}\x{0d}b
+    a\n\r\x{85}\x0cb 
+ 0: a\x{0a}\x{0d}\x{85}\x{0c}b
+    ** Failers
+No match
+    ab  
+No match
+
+/^a\R{1,3}b/8<bsr_unicode>
+    a\nb
+ 0: a\x{0a}b
+    a\n\rb
+ 0: a\x{0a}\x{0d}b
+    a\n\r\x{85}b
+ 0: a\x{0a}\x{0d}\x{85}b
+    a\r\n\r\nb 
+ 0: a\x{0d}\x{0a}\x{0d}\x{0a}b
+    a\r\n\r\n\r\nb 
+ 0: a\x{0d}\x{0a}\x{0d}\x{0a}\x{0d}\x{0a}b
+    a\n\r\n\rb
+ 0: a\x{0a}\x{0d}\x{0a}\x{0d}b
+    a\n\n\r\nb 
+ 0: a\x{0a}\x{0a}\x{0d}\x{0a}b
+    ** Failers
+No match
+    a\n\n\n\rb
+No match
+    a\r
+No match
+
+/\H\h\V\v/8
+    X X\x0a
+ 0: X X\x{0a}
+    X\x09X\x0b
+ 0: X\x{09}X\x{0b}
+    ** Failers
+No match
+    \x{a0} X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}\x{0d}
+    \x09\x20\x{a0}\x0a\x0b\x0c
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+    ** Failers 
+No match
+    \x09\x20\x{a0}\x0a\x0b
+No match
+     
+/\H\h\V\v/8
+    \x{3001}\x{3000}\x{2030}\x{2028}
+ 0: \x{3001}\x{3000}\x{2030}\x{2028}
+    X\x{180e}X\x{85}
+ 0: X\x{180e}X\x{85}
+    ** Failers
+No match
+    \x{2009} X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+ 0: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}\x{0d}
+    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+ 0: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}\x{2028}
+    \x09\x20\x{202f}\x0a\x0b\x0c
+ 0: \x{09} \x{202f}\x{0a}\x{0b}\x{0c}
+    ** Failers 
+No match
+    \x09\x{200a}\x{a0}\x{2028}\x0b
+No match
+     
+/[\h]/8BZ
+------------------------------------------------------------------
+        Bra
+        [\x09 \xa0\x{1680}\x{180e}\x{2000}-\x{200a}\x{202f}\x{205f}\x{3000}]
+        Ket
+        End
+------------------------------------------------------------------
+    >\x{1680}
+ 0: \x{1680}
+
+/[\h]{3,}/8BZ
+------------------------------------------------------------------
+        Bra
+        [\x09 \xa0\x{1680}\x{180e}\x{2000}-\x{200a}\x{202f}\x{205f}\x{3000}]{3,}
+        Ket
+        End
+------------------------------------------------------------------
+    >\x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}<
+ 0: \x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}
+
+/[\v]/8BZ
+------------------------------------------------------------------
+        Bra
+        [\x0a-\x0d\x85\x{2028}-\x{2029}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\H]/8BZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\x08\x0a-\x1f!-\x9f\xa1-\xff\x{100}-\x{167f}\x{1681}-\x{180d}\x{180f}-\x{1fff}\x{200b}-\x{202e}\x{2030}-\x{205e}\x{2060}-\x{2fff}\x{3001}-\x{7fffffff}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\V]/8BZ
+------------------------------------------------------------------
+        Bra
+        [\x00-\x09\x0e-\x84\x86-\xff\x{100}-\x{2027}\x{2029}-\x{7fffffff}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/.*$/8<any>
+    \x{1ec5} 
+ 0: \x{1ec5}
+    
+/-- This tests the stricter UTF-8 check according to RFC 3629. --/ 
+    
+/X/8
+    \x{0}\x{d7ff}\x{e000}\x{10ffff}
+No match
+    \x{d800}
+Error -10
+    \x{d800}\?
+No match
+    \x{da00}
+Error -10
+    \x{da00}\?
+No match
+    \x{dfff}
+Error -10
+    \x{dfff}\?
+No match
+    \x{110000}    
+Error -10
+    \x{110000}\?    
+No match
+    \x{2000000} 
+Error -10
+    \x{2000000}\? 
+No match
+    \x{7fffffff} 
+Error -10
+    \x{7fffffff}\? 
+No match
+
+/a\Rb/I8<bsr_anycrlf>
+Capturing subpattern count = 0
+Options: bsr_anycrlf utf8
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x{0d}b
+    a\nb
+ 0: a\x{0a}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    ** Failers
+No match
+    a\x{85}b
+No match
+    a\x0bb     
+No match
+
+/a\Rb/I8<bsr_unicode>
+Capturing subpattern count = 0
+Options: bsr_unicode utf8
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x{0d}b
+    a\nb
+ 0: a\x{0a}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x{85}b
+ 0: a\x{85}b
+    a\x0bb     
+ 0: a\x{0b}b
+    ** Failers 
+No match
+    a\x{85}b\<bsr_anycrlf>
+No match
+    a\x0bb\<bsr_anycrlf>
+No match
+    
+/a\R?b/I8<bsr_anycrlf>
+Capturing subpattern count = 0
+Options: bsr_anycrlf utf8
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x{0d}b
+    a\nb
+ 0: a\x{0a}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    ** Failers
+No match
+    a\x{85}b
+No match
+    a\x0bb     
+No match
+
+/a\R?b/I8<bsr_unicode>
+Capturing subpattern count = 0
+Options: bsr_unicode utf8
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x{0d}b
+    a\nb
+ 0: a\x{0a}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x{85}b
+ 0: a\x{85}b
+    a\x0bb     
+ 0: a\x{0b}b
+    ** Failers 
+No match
+    a\x{85}b\<bsr_anycrlf>
+No match
+    a\x0bb\<bsr_anycrlf>
+No match
+ 
+/.*a.*=.b.*/8<ANY>
+    QQQ\x{2029}ABCaXYZ=!bPQR
+ 0: ABCaXYZ=!bPQR
+    ** Failers
+No match
+    a\x{2029}b
+No match
+    \x61\xe2\x80\xa9\x62 
+No match
+
+/[[:a\x{100}b:]]/8
+Failed: unknown POSIX class name at offset 3
+
+/a[^]b/<JS>8
+    a\x{1234}b
+ 0: a\x{1234}b
+    a\nb 
+ 0: a\x{0a}b
+    ** Failers
+No match
+    ab  
+No match
+    
+/a[^]+b/<JS>8
+    aXb
+ 0: aXb
+    a\nX\nX\x{1234}b 
+ 0: a\x{0a}X\x{0a}X\x{1234}b
+    ** Failers
+No match
+    ab  
+No match
+
+/(\x{de})\1/
+    \x{de}\x{de}
+ 0: \xde\xde
+ 1: \xde
+    \x{123} 
+** Character \x{123} is greater than 255 and UTF-8 mode is not enabled.
+** Truncation will probably give the wrong result.
+No match
+
+/X/8f<any> 
+    A\x{1ec5}ABCXYZ
+ 0: X
+
+/ End of testinput5 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput6	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1750 @@
+/^\pC\pL\pM\pN\pP\pS\pZ</8
+    \x7f\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
+ 0: \x{7f}\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
+    \np\x{300}9!\$ < 
+ 0: \x{0a}p\x{300}9!$ <
+    ** Failers 
+No match
+    ap\x{300}9!\$ < 
+No match
+  
+/^\PC/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x7f
+No match
+  
+/^\PL/8
+    9
+ 0: 9
+    ** Failers 
+ 0: *
+    \x{c0}
+No match
+  
+/^\PM/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x{30f}
+No match
+  
+/^\PN/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x{660}
+No match
+  
+/^\PP/8
+    X
+ 0: X
+    ** Failers 
+No match
+    \x{66c}
+No match
+  
+/^\PS/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x{f01}
+No match
+  
+/^\PZ/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x{1680}
+No match
+    
+/^\p{Cc}/8
+    \x{017}
+ 0: \x{17}
+    \x{09f} 
+ 0: \x{9f}
+    ** Failers
+No match
+    \x{0600} 
+No match
+  
+/^\p{Cf}/8
+    \x{601}
+ 0: \x{601}
+    ** Failers
+No match
+    \x{09f} 
+No match
+  
+/^\p{Cn}/8
+    \x{e0000}
+ 0: \x{e0000}
+    ** Failers
+No match
+    \x{09f} 
+No match
+  
+/^\p{Co}/8
+    \x{f8ff}
+ 0: \x{f8ff}
+    ** Failers
+No match
+    \x{09f} 
+No match
+  
+/^\p{Cs}/8
+    \?\x{dfff}
+ 0: \x{dfff}
+    ** Failers
+No match
+    \x{09f} 
+No match
+  
+/^\p{Ll}/8
+    a
+ 0: a
+    ** Failers 
+No match
+    Z
+No match
+    \x{e000}  
+No match
+  
+/^\p{Lm}/8
+    \x{2b0}
+ 0: \x{2b0}
+    ** Failers
+No match
+    a 
+No match
+  
+/^\p{Lo}/8
+    \x{1bb}
+ 0: \x{1bb}
+    \x{3400}
+ 0: \x{3400}
+    \x{3401}
+ 0: \x{3401}
+    \x{4d00}
+ 0: \x{4d00}
+    \x{4db4}
+ 0: \x{4db4}
+    \x{4db5}     
+ 0: \x{4db5}
+    ** Failers
+No match
+    a 
+No match
+    \x{2b0}
+No match
+    \x{4db6} 
+No match
+  
+/^\p{Lt}/8
+    \x{1c5}
+ 0: \x{1c5}
+    ** Failers
+No match
+    a 
+No match
+    \x{2b0}
+No match
+  
+/^\p{Lu}/8
+    A
+ 0: A
+    ** Failers
+No match
+    \x{2b0}
+No match
+  
+/^\p{Mc}/8
+    \x{903}
+ 0: \x{903}
+    ** Failers
+No match
+    X
+No match
+    \x{300}
+No match
+       
+/^\p{Me}/8
+    \x{488}
+ 0: \x{488}
+    ** Failers
+No match
+    X
+No match
+    \x{903}
+No match
+    \x{300}
+No match
+  
+/^\p{Mn}/8
+    \x{300}
+ 0: \x{300}
+    ** Failers
+No match
+    X
+No match
+    \x{903}
+No match
+  
+/^\p{Nd}+/8
+    0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}\x{667}\x{668}\x{669}\x{66a}
+ 0: 0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}\x{667}\x{668}\x{669}
+    \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}\x{6f7}\x{6f8}\x{6f9}\x{6fa}
+ 0: \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}\x{6f7}\x{6f8}\x{6f9}
+    \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}\x{96d}\x{96e}\x{96f}\x{970}
+ 0: \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}\x{96d}\x{96e}\x{96f}
+    ** Failers
+No match
+    X
+No match
+  
+/^\p{Nl}/8
+    \x{16ee}
+ 0: \x{16ee}
+    ** Failers
+No match
+    X
+No match
+    \x{966}
+No match
+  
+/^\p{No}/8
+    \x{b2}
+ 0: \x{b2}
+    \x{b3}
+ 0: \x{b3}
+    ** Failers
+No match
+    X
+No match
+    \x{16ee}
+No match
+  
+/^\p{Pc}/8
+    \x5f
+ 0: _
+    \x{203f}
+ 0: \x{203f}
+    ** Failers
+No match
+    X
+No match
+    -
+No match
+    \x{58a}
+No match
+  
+/^\p{Pd}/8
+    -
+ 0: -
+    \x{58a}
+ 0: \x{58a}
+    ** Failers
+No match
+    X
+No match
+    \x{203f}
+No match
+  
+/^\p{Pe}/8
+    )
+ 0: )
+    ]
+ 0: ]
+    }
+ 0: }
+    \x{f3b}
+ 0: \x{f3b}
+    ** Failers
+No match
+    X
+No match
+    \x{203f}
+No match
+    (
+No match
+    [
+No match
+    {
+No match
+    \x{f3c}
+No match
+  
+/^\p{Pf}/8
+    \x{bb}
+ 0: \x{bb}
+    \x{2019}
+ 0: \x{2019}
+    ** Failers
+No match
+    X
+No match
+    \x{203f}
+No match
+  
+/^\p{Pi}/8
+    \x{ab}
+ 0: \x{ab}
+    \x{2018}
+ 0: \x{2018}
+    ** Failers
+No match
+    X
+No match
+    \x{203f}
+No match
+  
+/^\p{Po}/8
+    !
+ 0: !
+    \x{37e}
+ 0: \x{37e}
+    ** Failers
+ 0: *
+    X
+No match
+    \x{203f}
+No match
+  
+/^\p{Ps}/8
+    (
+ 0: (
+    [
+ 0: [
+    {
+ 0: {
+    \x{f3c}
+ 0: \x{f3c}
+    ** Failers
+No match
+    X
+No match
+    )
+No match
+    ]
+No match
+    }
+No match
+    \x{f3b}
+No match
+  
+/^\p{Sc}+/8
+    $\x{a2}\x{a3}\x{a4}\x{a5}\x{a6}
+ 0: $\x{a2}\x{a3}\x{a4}\x{a5}
+    \x{9f2}
+ 0: \x{9f2}
+    ** Failers
+No match
+    X
+No match
+    \x{2c2}
+No match
+  
+/^\p{Sk}/8
+    \x{2c2}
+ 0: \x{2c2}
+    ** Failers
+No match
+    X
+No match
+    \x{9f2}
+No match
+  
+/^\p{Sm}+/8
+    +<|~\x{ac}\x{2044}
+ 0: +<|~\x{ac}\x{2044}
+    ** Failers
+No match
+    X
+No match
+    \x{9f2}
+No match
+  
+/^\p{So}/8
+    \x{a6}
+ 0: \x{a6}
+    \x{482} 
+ 0: \x{482}
+    ** Failers
+No match
+    X
+No match
+    \x{9f2}
+No match
+  
+/^\p{Zl}/8
+    \x{2028}
+ 0: \x{2028}
+    ** Failers
+No match
+    X
+No match
+    \x{2029}
+No match
+  
+/^\p{Zp}/8
+    \x{2029}
+ 0: \x{2029}
+    ** Failers
+No match
+    X
+No match
+    \x{2028}
+No match
+  
+/^\p{Zs}/8
+    \ \
+ 0:  
+    \x{a0}
+ 0: \x{a0}
+    \x{1680}
+ 0: \x{1680}
+    \x{180e}
+ 0: \x{180e}
+    \x{2000}
+ 0: \x{2000}
+    \x{2001}     
+ 0: \x{2001}
+    ** Failers
+No match
+    \x{2028}
+No match
+    \x{200d} 
+No match
+  
+/\p{Nd}+(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: AB
+  
+/\p{Nd}+?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}
+ 1: \x{661}\x{662}
+  
+/\p{Nd}{2,}(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: AB
+  
+/\p{Nd}{2,}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}A
+ 1: \x{662}A
+  
+/\p{Nd}*(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: AB
+  
+/\p{Nd}*?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}
+ 1: \x{660}\x{661}
+  
+/\p{Nd}{2}(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}A
+ 1: \x{662}A
+  
+/\p{Nd}{2,3}(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: AB
+  
+/\p{Nd}{2,3}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}A
+ 1: \x{662}A
+  
+/\p{Nd}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}
+ 1: \x{661}\x{662}
+  
+/\p{Nd}??(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}
+ 1: \x{660}\x{661}
+  
+/\p{Nd}*+(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: AB
+  
+/\p{Nd}*+(...)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}ABC
+ 1: ABC
+  
+/\p{Nd}*+(....)/8
+      ** Failers
+ 0: ** F
+ 1: ** F
+      \x{660}\x{661}\x{662}ABC
+No match
+  
+/\p{Lu}/8i
+    A
+ 0: A
+    a\x{10a0}B 
+ 0: \x{10a0}
+    ** Failers 
+ 0: F
+    a
+No match
+    \x{1d00}  
+No match
+
+/\p{^Lu}/8i
+    1234
+ 0: 1
+    ** Failers
+ 0: *
+    ABC 
+No match
+
+/\P{Lu}/8i
+    1234
+ 0: 1
+    ** Failers
+ 0: *
+    ABC 
+No match
+
+/(?<=A\p{Nd})XYZ/8
+    A2XYZ
+ 0: XYZ
+    123A5XYZPQR
+ 0: XYZ
+    ABA\x{660}XYZpqr
+ 0: XYZ
+    ** Failers
+No match
+    AXYZ
+No match
+    XYZ     
+No match
+    
+/(?<!\pL)XYZ/8
+    1XYZ
+ 0: XYZ
+    AB=XYZ.. 
+ 0: XYZ
+    XYZ 
+ 0: XYZ
+    ** Failers
+No match
+    WXYZ 
+No match
+
+/[\p{L}]/DZ
+------------------------------------------------------------------
+        Bra
+        [\p{L}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[\p{^L}]/DZ
+------------------------------------------------------------------
+        Bra
+        [\P{L}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[\P{L}]/DZ
+------------------------------------------------------------------
+        Bra
+        [\P{L}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[\P{^L}]/DZ
+------------------------------------------------------------------
+        Bra
+        [\p{L}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/[abc\p{L}\x{0660}]/8DZ
+------------------------------------------------------------------
+        Bra
+        [a-c\p{L}\x{660}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+
+/[\p{Nd}]/8DZ
+------------------------------------------------------------------
+        Bra
+        [\p{Nd}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+    1234
+ 0: 1
+
+/[\p{Nd}+-]+/8DZ
+------------------------------------------------------------------
+        Bra
+        [+\-\p{Nd}]+
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Partial matching not supported
+Options: utf8
+No first char
+No need char
+    1234
+ 0: 1234
+    12-34
+ 0: 12-34
+    12+\x{661}-34  
+ 0: 12+\x{661}-34
+    ** Failers
+No match
+    abcd  
+No match
+
+/[\P{Nd}]+/8
+    abcd
+ 0: abcd
+    ** Failers
+ 0: ** Failers
+    1234
+No match
+
+/\D+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+     
+/\P{Nd}+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\D]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\P{Nd}]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\D\P{Nd}]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\pL/8
+    a
+ 0: a
+    A 
+ 0: A
+
+/\pL/8i
+    a
+ 0: a
+    A 
+ 0: A
+    
+/\p{Lu}/8 
+    A
+ 0: A
+    aZ
+ 0: Z
+    ** Failers
+ 0: F
+    abc   
+No match
+
+/\p{Lu}/8i
+    A
+ 0: A
+    aZ
+ 0: Z
+    ** Failers
+ 0: F
+    abc   
+No match
+
+/\p{Ll}/8 
+    a
+ 0: a
+    Az
+ 0: z
+    ** Failers
+ 0: a
+    ABC   
+No match
+
+/\p{Ll}/8i 
+    a
+ 0: a
+    Az
+ 0: z
+    ** Failers
+ 0: a
+    ABC   
+No match
+
+/^\x{c0}$/8i
+    \x{c0}
+ 0: \x{c0}
+    \x{e0} 
+ 0: \x{e0}
+
+/^\x{e0}$/8i
+    \x{c0}
+ 0: \x{c0}
+    \x{e0} 
+ 0: \x{e0}
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8
+    A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ 0: A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    ** Failers
+No match
+    a\x{391}\x{10427}\x{ff3a}\x{1fb0}   
+No match
+    A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+No match
+    A\x{391}\x{1044F}\x{ff3a}\x{1fb0}
+No match
+    A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+No match
+    A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+No match
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8i
+    A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ 0: A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    a\x{391}\x{10427}\x{ff3a}\x{1fb0}   
+ 0: a\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+ 0: A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+    A\x{391}\x{1044F}\x{ff3a}\x{1fb0}
+ 0: A\x{391}\x{1044f}\x{ff3a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+ 0: A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+ 0: A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8iDZ
+------------------------------------------------------------------
+        Bra
+     NC A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless utf8
+First char = 'A' (caseless)
+No need char
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8DZ
+------------------------------------------------------------------
+        Bra
+        A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'A'
+Need char = 176
+
+/AB\x{1fb0}/8DZ
+------------------------------------------------------------------
+        Bra
+        AB\x{1fb0}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: utf8
+First char = 'A'
+Need char = 176
+
+/AB\x{1fb0}/8DZi
+------------------------------------------------------------------
+        Bra
+     NC AB\x{1fb0}
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless utf8
+First char = 'A' (caseless)
+Need char = 'B' (caseless)
+
+/\x{391}+/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
+ 0: \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
+
+/\x{391}{3,5}(.)/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+ 0: \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+ 1: X
+
+/\x{391}{3,5}?(.)/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+ 0: \x{391}\x{3b1}\x{3b1}\x{3b1}
+ 1: \x{3b1}
+
+/[\x{391}\x{ff3a}]/8i
+    \x{391}
+ 0: \x{391}
+    \x{ff3a}
+ 0: \x{ff3a}
+    \x{3b1}
+ 0: \x{3b1}
+    \x{ff5a}   
+ 0: \x{ff5a}
+    
+/[\x{c0}\x{391}]/8i
+    \x{c0}
+ 0: \x{c0}
+    \x{e0} 
+ 0: \x{e0}
+
+/[\x{105}-\x{109}]/8iDZ
+------------------------------------------------------------------
+        Bra
+        [\x{104}-\x{109}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless utf8
+No first char
+No need char
+    \x{104}
+ 0: \x{104}
+    \x{105}
+ 0: \x{105}
+    \x{109}  
+ 0: \x{109}
+    ** Failers
+No match
+    \x{100}
+No match
+    \x{10a} 
+No match
+    
+/[z-\x{100}]/8iDZ 
+------------------------------------------------------------------
+        Bra
+        [Z\x{39c}\x{178}z-\x{101}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless utf8
+No first char
+No need char
+    Z
+ 0: Z
+    z
+ 0: z
+    \x{39c}
+ 0: \x{39c}
+    \x{178}
+ 0: \x{178}
+    |
+ 0: |
+    \x{80}
+ 0: \x{80}
+    \x{ff}
+ 0: \x{ff}
+    \x{100}
+ 0: \x{100}
+    \x{101} 
+ 0: \x{101}
+    ** Failers
+No match
+    \x{102}
+No match
+    Y
+No match
+    y           
+No match
+
+/[z-\x{100}]/8DZi
+------------------------------------------------------------------
+        Bra
+        [Z\x{39c}\x{178}z-\x{101}]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+Options: caseless utf8
+No first char
+No need char
+
+/^\X/8
+    A
+ 0: A
+    A\x{300}BC 
+ 0: A\x{300}
+    A\x{300}\x{301}\x{302}BC 
+ 0: A\x{300}\x{301}\x{302}
+    *** Failers
+ 0: *
+    \x{300}  
+No match
+
+/^[\X]/8
+    X123
+ 0: X
+    *** Failers
+No match
+    AXYZ
+No match
+
+/^(\X*)C/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+ 0: A\x{300}\x{301}\x{302}BC
+ 1: A\x{300}\x{301}\x{302}B
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+ 0: A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C
+ 1: A\x{300}\x{301}\x{302}BCA\x{300}\x{301}
+
+/^(\X*?)C/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+ 0: A\x{300}\x{301}\x{302}BC
+ 1: A\x{300}\x{301}\x{302}B
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+ 0: A\x{300}\x{301}\x{302}BC
+ 1: A\x{300}\x{301}\x{302}B
+
+/^(\X*)(.)/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+ 0: A\x{300}\x{301}\x{302}BCA
+ 1: A\x{300}\x{301}\x{302}BC
+ 2: A
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+ 0: A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C
+ 1: A\x{300}\x{301}\x{302}BCA\x{300}\x{301}
+ 2: C
+
+/^(\X*?)(.)/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+ 0: A
+ 1: 
+ 2: A
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+ 0: A
+ 1: 
+ 2: A
+
+/^\X(.)/8
+    *** Failers
+ 0: **
+ 1: *
+    A\x{300}\x{301}\x{302}
+No match
+
+/^\X{2,3}(.)/8
+    A\x{300}\x{301}B\x{300}X
+ 0: A\x{300}\x{301}B\x{300}X
+ 1: X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}
+ 0: A\x{300}\x{301}B\x{300}C
+ 1: C
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+ 0: A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+ 1: X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}DA\x{300}X
+ 0: A\x{300}\x{301}B\x{300}C\x{300}\x{301}D
+ 1: D
+    
+/^\X{2,3}?(.)/8
+    A\x{300}\x{301}B\x{300}X
+ 0: A\x{300}\x{301}B\x{300}X
+ 1: X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}
+ 0: A\x{300}\x{301}B\x{300}C
+ 1: C
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+ 0: A\x{300}\x{301}B\x{300}C
+ 1: C
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}DA\x{300}X
+ 0: A\x{300}\x{301}B\x{300}C
+ 1: C
+    
+/^\p{Han}+/8
+    \x{2e81}\x{3007}\x{2f804}\x{31a0}
+ 0: \x{2e81}\x{3007}\x{2f804}
+    ** Failers
+No match
+    \x{2e7f}  
+No match
+
+/^\P{Katakana}+/8
+    \x{3105}
+ 0: \x{3105}
+    ** Failers
+ 0: ** Failers
+    \x{30ff}  
+No match
+
+/^[\p{Arabic}]/8
+    \x{06e9}
+ 0: \x{6e9}
+    \x{060b}
+ 0: \x{60b}
+    ** Failers
+No match
+    X\x{06e9}   
+No match
+
+/^[\P{Yi}]/8
+    \x{2f800}
+ 0: \x{2f800}
+    ** Failers
+ 0: *
+    \x{a014}
+No match
+    \x{a4c6}   
+No match
+    
+/^\p{Any}X/8
+    AXYZ
+ 0: AX
+    \x{1234}XYZ 
+ 0: \x{1234}X
+    ** Failers
+No match
+    X  
+No match
+    
+/^\P{Any}X/8
+    ** Failers
+No match
+    AX
+No match
+    
+/^\p{Any}?X/8
+    XYZ
+ 0: X
+    AXYZ
+ 0: AX
+    \x{1234}XYZ 
+ 0: \x{1234}X
+    ** Failers
+No match
+    ABXYZ   
+No match
+
+/^\P{Any}?X/8
+    XYZ
+ 0: X
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ 
+No match
+    ABXYZ   
+No match
+
+/^\p{Any}+X/8
+    AXYZ
+ 0: AX
+    \x{1234}XYZ
+ 0: \x{1234}X
+    A\x{1234}XYZ
+ 0: A\x{1234}X
+    ** Failers
+No match
+    XYZ
+No match
+
+/^\P{Any}+X/8
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ
+No match
+    A\x{1234}XYZ
+No match
+    XYZ
+No match
+
+/^\p{Any}*X/8
+    XYZ
+ 0: X
+    AXYZ
+ 0: AX
+    \x{1234}XYZ
+ 0: \x{1234}X
+    A\x{1234}XYZ
+ 0: A\x{1234}X
+    ** Failers
+No match
+
+/^\P{Any}*X/8
+    XYZ
+ 0: X
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ
+No match
+    A\x{1234}XYZ
+No match
+
+/^[\p{Any}]X/8
+    AXYZ
+ 0: AX
+    \x{1234}XYZ 
+ 0: \x{1234}X
+    ** Failers
+No match
+    X  
+No match
+    
+/^[\P{Any}]X/8
+    ** Failers
+No match
+    AX
+No match
+    
+/^[\p{Any}]?X/8
+    XYZ
+ 0: X
+    AXYZ
+ 0: AX
+    \x{1234}XYZ 
+ 0: \x{1234}X
+    ** Failers
+No match
+    ABXYZ   
+No match
+
+/^[\P{Any}]?X/8
+    XYZ
+ 0: X
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ 
+No match
+    ABXYZ   
+No match
+
+/^[\p{Any}]+X/8
+    AXYZ
+ 0: AX
+    \x{1234}XYZ
+ 0: \x{1234}X
+    A\x{1234}XYZ
+ 0: A\x{1234}X
+    ** Failers
+No match
+    XYZ
+No match
+
+/^[\P{Any}]+X/8
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ
+No match
+    A\x{1234}XYZ
+No match
+    XYZ
+No match
+
+/^[\p{Any}]*X/8
+    XYZ
+ 0: X
+    AXYZ
+ 0: AX
+    \x{1234}XYZ
+ 0: \x{1234}X
+    A\x{1234}XYZ
+ 0: A\x{1234}X
+    ** Failers
+No match
+
+/^[\P{Any}]*X/8
+    XYZ
+ 0: X
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ
+No match
+    A\x{1234}XYZ
+No match
+
+/^\p{Any}{3,5}?/8
+    abcdefgh
+ 0: abc
+    \x{1234}\n\r\x{3456}xyz 
+ 0: \x{1234}\x{0a}\x{0d}
+
+/^\p{Any}{3,5}/8
+    abcdefgh
+ 0: abcde
+    \x{1234}\n\r\x{3456}xyz 
+ 0: \x{1234}\x{0a}\x{0d}\x{3456}x
+
+/^\P{Any}{3,5}?/8
+    ** Failers
+No match
+    abcdefgh
+No match
+    \x{1234}\n\r\x{3456}xyz 
+No match
+
+/^\p{L&}X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     \x{1c5}XY
+ 0: \x{1c5}X
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^[\p{L&}]X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     \x{1c5}XY
+ 0: \x{1c5}X
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^\p{L&}+X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     AbcdeXyz 
+ 0: AbcdeX
+     \x{1c5}AbXY
+ 0: \x{1c5}AbX
+     abcDEXypqreXlmn 
+ 0: abcDEXypqreX
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^[\p{L&}]+X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     AbcdeXyz 
+ 0: AbcdeX
+     \x{1c5}AbXY
+ 0: \x{1c5}AbX
+     abcDEXypqreXlmn 
+ 0: abcDEXypqreX
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^\p{L&}+?X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     AbcdeXyz 
+ 0: AbcdeX
+     \x{1c5}AbXY
+ 0: \x{1c5}AbX
+     abcDEXypqreXlmn 
+ 0: abcDEX
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^[\p{L&}]+?X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     AbcdeXyz 
+ 0: AbcdeX
+     \x{1c5}AbXY
+ 0: \x{1c5}AbX
+     abcDEXypqreXlmn 
+ 0: abcDEX
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^\P{L&}X/8
+     !XY
+ 0: !X
+     \x{1bb}XY
+ 0: \x{1bb}X
+     \x{2b0}XY
+ 0: \x{2b0}X
+     ** Failers
+No match
+     \x{1c5}XY
+No match
+     AXY      
+No match
+
+/^[\P{L&}]X/8
+     !XY
+ 0: !X
+     \x{1bb}XY
+ 0: \x{1bb}X
+     \x{2b0}XY
+ 0: \x{2b0}X
+     ** Failers
+No match
+     \x{1c5}XY
+No match
+     AXY      
+No match
+
+/^(\p{Z}[^\p{C}\p{Z}]+)*$/
+    \xa0!
+ 0: \xa0!
+ 1: \xa0!
+
+/^[\pL](abc)(?1)/
+    AabcabcYZ    
+ 0: Aabcabc
+ 1: abc
+
+/([\pL]=(abc))*X/
+    L=abcX
+ 0: L=abcX
+ 1: L=abc
+ 2: abc
+
+/The next two should be Perl-compatible, but it fails to match \x{e0}. PCRE
+will match it only with UCP support, because without that it has no notion
+of case for anything other than the ASCII letters. / 
+
+/((?i)[\x{c0}])/8
+    \x{c0}
+ 0: \x{c0}
+ 1: \x{c0}
+    \x{e0} 
+ 0: \x{e0}
+ 1: \x{e0}
+
+/(?i:[\x{c0}])/8
+    \x{c0}
+ 0: \x{c0}
+    \x{e0} 
+ 0: \x{e0}
+    
+/^\p{Balinese}\p{Cuneiform}\p{Nko}\p{Phags_Pa}\p{Phoenician}/8
+    \x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
+ 0: \x{1b00}\x{12000}\x{7c0}\x{a840}\x{10900}
+
+/The next two are special cases where the lengths of the different cases of the 
+same character differ. The first went wrong with heap frame storage; the 2nd
+was broken in all cases./
+
+/^\x{023a}+?(\x{0130}+)/8i
+  \x{023a}\x{2c65}\x{0130}
+ 0: \x{23a}\x{2c65}\x{130}
+ 1: \x{130}
+  
+/^\x{023a}+([^X])/8i
+  \x{023a}\x{2c65}X
+ 0: \x{23a}\x{2c65}
+ 1: \x{2c65}
+
+/Check property support in non-UTF-8 mode/
+ 
+/\p{L}{4}/
+    123abcdefg
+ 0: abcd
+    123abc\xc4\xc5zz
+ 0: abc\xc4
+
+/\X{1,3}\d/
+  \x8aBCD
+No match
+  
+/\X?\d/
+  \x8aBCD 
+No match
+
+/\P{L}?\d/
+  \x8aBCD 
+No match
+
+/[\PPP\x8a]{1,}\x80/
+    A\x80
+ 0: A\x80
+
+/(?:[\PPa*]*){8,}/
+
+/[\P{Any}]/BZ
+------------------------------------------------------------------
+        Bra
+        [\P{Any}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\P{Any}\E]/BZ
+------------------------------------------------------------------
+        Bra
+        [\P{Any}]
+        Ket
+        End
+------------------------------------------------------------------
+
+/(\P{Yi}+\277)/
+
+/(\P{Yi}+\277)?/
+
+/(?<=\P{Yi}{3}A)X/
+
+/\p{Yi}+(\P{Yi}+)(?1)/
+
+/(\P{Yi}{2}\277)?/
+
+/[\P{Yi}A]/
+
+/[\P{Yi}\P{Yi}\P{Yi}A]/
+
+/[^\P{Yi}A]/
+
+/[^\P{Yi}\P{Yi}\P{Yi}A]/
+
+/(\P{Yi}*\277)*/
+
+/(\P{Yi}*?\277)*/
+
+/(\p{Yi}*+\277)*/
+
+/(\P{Yi}?\277)*/
+
+/(\P{Yi}??\277)*/
+
+/(\p{Yi}?+\277)*/
+
+/(\P{Yi}{0,3}\277)*/
+
+/(\P{Yi}{0,3}?\277)*/
+
+/(\p{Yi}{0,3}+\277)*/
+
+/^[\p{Arabic}]/8
+    \x{60e} 
+ 0: \x{60e}
+    \x{656} 
+ 0: \x{656}
+    \x{657} 
+ 0: \x{657}
+    \x{658} 
+ 0: \x{658}
+    \x{659} 
+ 0: \x{659}
+    \x{65a} 
+ 0: \x{65a}
+    \x{65b} 
+ 0: \x{65b}
+    \x{65c} 
+ 0: \x{65c}
+    \x{65d} 
+ 0: \x{65d}
+    \x{65e} 
+ 0: \x{65e}
+    \x{66a} 
+ 0: \x{66a}
+    \x{6e9} 
+ 0: \x{6e9}
+    \x{6ef}
+ 0: \x{6ef}
+    \x{6fa}  
+ 0: \x{6fa}
+    ** Failers
+No match
+    \x{600}
+No match
+    \x{650}
+No match
+    \x{651}  
+No match
+    \x{652}  
+No match
+    \x{653}  
+No match
+    \x{654} 
+No match
+    \x{655} 
+No match
+    \x{65f}  
+No match
+    
+/^\p{Cyrillic}/8
+    \x{1d2b} 
+ 0: \x{1d2b}
+    
+/^\p{Common}/8
+    \x{589}
+ 0: \x{589}
+    \x{60c}
+ 0: \x{60c}
+    \x{61f}  
+ 0: \x{61f}
+    \x{964}
+ 0: \x{964}
+    \x{965}  
+ 0: \x{965}
+    \x{970}  
+ 0: \x{970}
+
+/^\p{Inherited}/8
+    \x{64b}
+ 0: \x{64b}
+    \x{654}
+ 0: \x{654}
+    \x{655}
+ 0: \x{655}
+    \x{200c} 
+ 0: \x{200c}
+    ** Failers
+No match
+    \x{64a}
+No match
+    \x{656}     
+No match
+
+/^\p{Shavian}/8
+    \x{10450}
+ 0: \x{10450}
+    \x{1047f}
+ 0: \x{1047f}
+    
+/^\p{Deseret}/8
+    \x{10400}
+ 0: \x{10400}
+    \x{1044f}
+ 0: \x{1044f}
+    
+/^\p{Osmanya}/8
+    \x{10480}
+ 0: \x{10480}
+    \x{1049d}
+ 0: \x{1049d}
+    \x{104a0}
+ 0: \x{104a0}
+    \x{104a9}
+ 0: \x{104a9}
+    ** Failers
+No match
+    \x{1049e}
+No match
+    \x{1049f}
+No match
+    \x{104aa}           
+No match
+
+/\p{Zl}{2,3}+/8BZ
+------------------------------------------------------------------
+        Bra
+        prop Zl {2}
+        prop Zl ?+
+        Ket
+        End
+------------------------------------------------------------------
+    \xe2\x80\xa8\xe2\x80\xa8
+ 0: \x{2028}\x{2028}
+    \x{2028}\x{2028}\x{2028}
+ 0: \x{2028}\x{2028}\x{2028}
+    
+/\p{Zl}/8BZ
+------------------------------------------------------------------
+        Bra
+        prop Zl
+        Ket
+        End
+------------------------------------------------------------------
+
+/\p{Lu}{3}+/8BZ
+------------------------------------------------------------------
+        Bra
+        prop Lu {3}
+        Ket
+        End
+------------------------------------------------------------------
+
+/\pL{2}+/8BZ
+------------------------------------------------------------------
+        Bra
+        prop L {2}
+        Ket
+        End
+------------------------------------------------------------------
+
+/\p{Cc}{2}+/8BZ
+------------------------------------------------------------------
+        Bra
+        prop Cc {2}
+        Ket
+        End
+------------------------------------------------------------------
+
+/\x{c0}+\x{116}+/8i
+    \x{c0}\x{e0}\x{116}\x{117}
+ 0: \x{c0}\x{e0}\x{116}\x{117}
+
+/[\x{c0}\x{116}]+/8i
+    \x{c0}\x{e0}\x{116}\x{117}
+ 0: \x{c0}\x{e0}\x{116}\x{117}
+
+/\p{Carian}\p{Cham}\p{Kayah_Li}\p{Lepcha}\p{Lycian}\p{Lydian}\p{Ol_Chiki}\p{Rejang}\p{Saurashtra}\p{Sundanese}\p{Vai}/8
+    \x{102A4}\x{AA52}\x{A91D}\x{1C46}\x{10283}\x{1092E}\x{1C6B}\x{A93B}\x{A8BF}\x{1BA0}\x{A50A}====
+ 0: \x{102a4}\x{aa52}\x{a91d}\x{1c46}\x{10283}\x{1092e}\x{1c6b}\x{a93b}\x{a8bf}\x{1ba0}\x{a50a}
+
+/\x{a77d}\x{1d79}/8i
+    \x{a77d}\x{1d79}
+ 0: \x{a77d}\x{1d79}
+    \x{1d79}\x{a77d} 
+ 0: \x{1d79}\x{a77d}
+
+/\x{a77d}\x{1d79}/8
+    \x{a77d}\x{1d79}
+ 0: \x{a77d}\x{1d79}
+    ** Failers 
+No match
+    \x{1d79}\x{a77d} 
+No match
+
+/(A)\1/8i
+    AA
+ 0: AA
+ 1: A
+    Aa
+ 0: Aa
+ 1: A
+    aa
+ 0: aa
+ 1: a
+    aA
+ 0: aA
+ 1: a
+
+/(\x{de})\1/8i
+    \x{de}\x{de}
+ 0: \x{de}\x{de}
+ 1: \x{de}
+    \x{de}\x{fe}
+ 0: \x{de}\x{fe}
+ 1: \x{de}
+    \x{fe}\x{fe}
+ 0: \x{fe}\x{fe}
+ 1: \x{fe}
+    \x{fe}\x{de}
+ 0: \x{fe}\x{de}
+ 1: \x{fe}
+
+/(\x{10a})\1/8i
+    \x{10a}\x{10a}
+ 0: \x{10a}\x{10a}
+ 1: \x{10a}
+    \x{10a}\x{10b}
+ 0: \x{10a}\x{10b}
+ 1: \x{10a}
+    \x{10b}\x{10b}
+ 0: \x{10b}\x{10b}
+ 1: \x{10b}
+    \x{10b}\x{10a}
+ 0: \x{10b}\x{10a}
+ 1: \x{10b}
+
+/ End of testinput6 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput7	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,7257 @@
+/abc/
+    abc
+ 0: abc
+    
+/ab*c/
+    abc
+ 0: abc
+    abbbbc
+ 0: abbbbc
+    ac
+ 0: ac
+    
+/ab+c/
+    abc
+ 0: abc
+    abbbbbbc
+ 0: abbbbbbc
+    *** Failers 
+No match
+    ac
+No match
+    ab
+No match
+    
+/a*/
+    a
+ 0: a
+ 1: 
+    aaaaaaaaaaaaaaaaa
+ 0: aaaaaaaaaaaaaaaaa
+ 1: aaaaaaaaaaaaaaaa
+ 2: aaaaaaaaaaaaaaa
+ 3: aaaaaaaaaaaaaa
+ 4: aaaaaaaaaaaaa
+ 5: aaaaaaaaaaaa
+ 6: aaaaaaaaaaa
+ 7: aaaaaaaaaa
+ 8: aaaaaaaaa
+ 9: aaaaaaaa
+10: aaaaaaa
+11: aaaaaa
+12: aaaaa
+13: aaaa
+14: aaa
+15: aa
+16: a
+17: 
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
+Matched, but too many subsidiary matches
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 3: aaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 4: aaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5: aaaaaaaaaaaaaaaaaaaaaaaaa
+ 6: aaaaaaaaaaaaaaaaaaaaaaaa
+ 7: aaaaaaaaaaaaaaaaaaaaaaa
+ 8: aaaaaaaaaaaaaaaaaaaaaa
+ 9: aaaaaaaaaaaaaaaaaaaaa
+10: aaaaaaaaaaaaaaaaaaaa
+11: aaaaaaaaaaaaaaaaaaa
+12: aaaaaaaaaaaaaaaaaa
+13: aaaaaaaaaaaaaaaaa
+14: aaaaaaaaaaaaaaaa
+15: aaaaaaaaaaaaaaa
+16: aaaaaaaaaaaaaa
+17: aaaaaaaaaaaaa
+18: aaaaaaaaaaaa
+19: aaaaaaaaaaa
+20: aaaaaaaaaa
+21: aaaaaaaaa
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\F 
+ 0: 
+    
+/(a|abcd|african)/
+    a
+ 0: a
+    abcd
+ 0: abcd
+ 1: a
+    african
+ 0: african
+ 1: a
+    
+/^abc/
+    abcdef
+ 0: abc
+    *** Failers
+No match
+    xyzabc
+No match
+    xyz\nabc    
+No match
+    
+/^abc/m
+    abcdef
+ 0: abc
+    xyz\nabc    
+ 0: abc
+    *** Failers
+No match
+    xyzabc
+No match
+    
+/\Aabc/
+    abcdef
+ 0: abc
+    *** Failers
+No match
+    xyzabc
+No match
+    xyz\nabc    
+No match
+    
+/\Aabc/m
+    abcdef
+ 0: abc
+    *** Failers
+No match
+    xyzabc
+No match
+    xyz\nabc    
+No match
+    
+/\Gabc/
+    abcdef
+ 0: abc
+    xyzabc\>3
+ 0: abc
+    *** Failers
+No match
+    xyzabc    
+No match
+    xyzabc\>2 
+No match
+    
+/x\dy\Dz/
+    x9yzz
+ 0: x9yzz
+    x0y+z
+ 0: x0y+z
+    *** Failers
+No match
+    xyz
+No match
+    xxy0z     
+No match
+    
+/x\sy\Sz/
+    x yzz
+ 0: x yzz
+    x y+z
+ 0: x y+z
+    *** Failers
+No match
+    xyz
+No match
+    xxyyz
+No match
+    
+/x\wy\Wz/
+    xxy+z
+ 0: xxy+z
+    *** Failers
+No match
+    xxy0z
+No match
+    x+y+z         
+No match
+    
+/x.y/
+    x+y
+ 0: x+y
+    x-y
+ 0: x-y
+    *** Failers
+No match
+    x\ny
+No match
+    
+/x.y/s
+    x+y
+ 0: x+y
+    x-y
+ 0: x-y
+    x\ny
+ 0: x\x0ay
+
+/(a.b(?s)c.d|x.y)p.q/
+    a+bc+dp+q
+ 0: a+bc+dp+q
+    a+bc\ndp+q
+ 0: a+bc\x0adp+q
+    x\nyp+q 
+ 0: x\x0ayp+q
+    *** Failers 
+No match
+    a\nbc\ndp+q
+No match
+    a+bc\ndp\nq
+No match
+    x\nyp\nq 
+No match
+
+/a\d\z/
+    ba0
+ 0: a0
+    *** Failers
+No match
+    ba0\n
+No match
+    ba0\ncd   
+No match
+
+/a\d\z/m
+    ba0
+ 0: a0
+    *** Failers
+No match
+    ba0\n
+No match
+    ba0\ncd   
+No match
+
+/a\d\Z/
+    ba0
+ 0: a0
+    ba0\n
+ 0: a0
+    *** Failers
+No match
+    ba0\ncd   
+No match
+
+/a\d\Z/m
+    ba0
+ 0: a0
+    ba0\n
+ 0: a0
+    *** Failers
+No match
+    ba0\ncd   
+No match
+
+/a\d$/
+    ba0
+ 0: a0
+    ba0\n
+ 0: a0
+    *** Failers
+No match
+    ba0\ncd   
+No match
+
+/a\d$/m
+    ba0
+ 0: a0
+    ba0\n
+ 0: a0
+    ba0\ncd   
+ 0: a0
+    *** Failers
+No match
+
+/abc/i
+    abc
+ 0: abc
+    aBc
+ 0: aBc
+    ABC
+ 0: ABC
+    
+/[^a]/
+    abcd
+ 0: b
+    
+/ab?\w/
+    abz
+ 0: abz
+ 1: ab
+    abbz
+ 0: abb
+ 1: ab
+    azz  
+ 0: az
+
+/x{0,3}yz/
+    ayzq
+ 0: yz
+    axyzq
+ 0: xyz
+    axxyz
+ 0: xxyz
+    axxxyzq
+ 0: xxxyz
+    axxxxyzq
+ 0: xxxyz
+    *** Failers
+No match
+    ax
+No match
+    axx     
+No match
+      
+/x{3}yz/
+    axxxyzq
+ 0: xxxyz
+    axxxxyzq
+ 0: xxxyz
+    *** Failers
+No match
+    ax
+No match
+    axx     
+No match
+    ayzq
+No match
+    axyzq
+No match
+    axxyz
+No match
+      
+/x{2,3}yz/
+    axxyz
+ 0: xxyz
+    axxxyzq
+ 0: xxxyz
+    axxxxyzq
+ 0: xxxyz
+    *** Failers
+No match
+    ax
+No match
+    axx     
+No match
+    ayzq
+No match
+    axyzq
+No match
+      
+/[^a]+/
+    bac
+ 0: b
+    bcdefax
+ 0: bcdef
+ 1: bcde
+ 2: bcd
+ 3: bc
+ 4: b
+    *** Failers
+ 0: *** F
+ 1: *** 
+ 2: ***
+ 3: **
+ 4: *
+    aaaaa   
+No match
+
+/[^a]*/
+    bac
+ 0: b
+ 1: 
+    bcdefax
+ 0: bcdef
+ 1: bcde
+ 2: bcd
+ 3: bc
+ 4: b
+ 5: 
+    *** Failers
+ 0: *** F
+ 1: *** 
+ 2: ***
+ 3: **
+ 4: *
+ 5: 
+    aaaaa   
+ 0: 
+    
+/[^a]{3,5}/
+    xyz
+ 0: xyz
+    awxyza
+ 0: wxyz
+ 1: wxy
+    abcdefa
+ 0: bcdef
+ 1: bcde
+ 2: bcd
+    abcdefghijk
+ 0: bcdef
+ 1: bcde
+ 2: bcd
+    *** Failers
+ 0: *** F
+ 1: *** 
+ 2: ***
+    axya
+No match
+    axa
+No match
+    aaaaa         
+No match
+
+/\d*/
+    1234b567
+ 0: 1234
+ 1: 123
+ 2: 12
+ 3: 1
+ 4: 
+    xyz
+ 0: 
+    
+/\D*/
+    a1234b567
+ 0: a
+ 1: 
+    xyz
+ 0: xyz
+ 1: xy
+ 2: x
+ 3: 
+     
+/\d+/
+    ab1234c56
+ 0: 1234
+ 1: 123
+ 2: 12
+ 3: 1
+    *** Failers
+No match
+    xyz
+No match
+    
+/\D+/
+    ab123c56
+ 0: ab
+ 1: a
+    *** Failers
+ 0: *** Failers
+ 1: *** Failer
+ 2: *** Faile
+ 3: *** Fail
+ 4: *** Fai
+ 5: *** Fa
+ 6: *** F
+ 7: *** 
+ 8: ***
+ 9: **
+10: *
+    789
+No match
+    
+/\d?A/
+    045ABC
+ 0: 5A
+    ABC
+ 0: A
+    *** Failers
+No match
+    XYZ
+No match
+    
+/\D?A/
+    ABC
+ 0: A
+    BAC
+ 0: BA
+    9ABC             
+ 0: A
+    *** Failers
+No match
+
+/a+/
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+ 3: a
+
+/^.*xyz/
+    xyz
+ 0: xyz
+    ggggggggxyz
+ 0: ggggggggxyz
+    
+/^.+xyz/
+    abcdxyz
+ 0: abcdxyz
+    axyz
+ 0: axyz
+    *** Failers
+No match
+    xyz
+No match
+    
+/^.?xyz/
+    xyz
+ 0: xyz
+    cxyz       
+ 0: cxyz
+
+/^\d{2,3}X/
+    12X
+ 0: 12X
+    123X
+ 0: 123X
+    *** Failers
+No match
+    X
+No match
+    1X
+No match
+    1234X     
+No match
+
+/^[abcd]\d/
+    a45
+ 0: a4
+    b93
+ 0: b9
+    c99z
+ 0: c9
+    d04
+ 0: d0
+    *** Failers
+No match
+    e45
+No match
+    abcd      
+No match
+    abcd1234
+No match
+    1234  
+No match
+
+/^[abcd]*\d/
+    a45
+ 0: a4
+    b93
+ 0: b9
+    c99z
+ 0: c9
+    d04
+ 0: d0
+    abcd1234
+ 0: abcd1
+    1234  
+ 0: 1
+    *** Failers
+No match
+    e45
+No match
+    abcd      
+No match
+
+/^[abcd]+\d/
+    a45
+ 0: a4
+    b93
+ 0: b9
+    c99z
+ 0: c9
+    d04
+ 0: d0
+    abcd1234
+ 0: abcd1
+    *** Failers
+No match
+    1234  
+No match
+    e45
+No match
+    abcd      
+No match
+
+/^a+X/
+    aX
+ 0: aX
+    aaX 
+ 0: aaX
+
+/^[abcd]?\d/
+    a45
+ 0: a4
+    b93
+ 0: b9
+    c99z
+ 0: c9
+    d04
+ 0: d0
+    1234  
+ 0: 1
+    *** Failers
+No match
+    abcd1234
+No match
+    e45
+No match
+
+/^[abcd]{2,3}\d/
+    ab45
+ 0: ab4
+    bcd93
+ 0: bcd9
+    *** Failers
+No match
+    1234 
+No match
+    a36 
+No match
+    abcd1234
+No match
+    ee45
+No match
+
+/^(abc)*\d/
+    abc45
+ 0: abc4
+    abcabcabc45
+ 0: abcabcabc4
+    42xyz 
+ 0: 4
+    *** Failers
+No match
+
+/^(abc)+\d/
+    abc45
+ 0: abc4
+    abcabcabc45
+ 0: abcabcabc4
+    *** Failers
+No match
+    42xyz 
+No match
+
+/^(abc)?\d/
+    abc45
+ 0: abc4
+    42xyz 
+ 0: 4
+    *** Failers
+No match
+    abcabcabc45
+No match
+
+/^(abc){2,3}\d/
+    abcabc45
+ 0: abcabc4
+    abcabcabc45
+ 0: abcabcabc4
+    *** Failers
+No match
+    abcabcabcabc45
+No match
+    abc45
+No match
+    42xyz 
+No match
+
+/1(abc|xyz)2(?1)3/
+    1abc2abc3456
+ 0: 1abc2abc3
+    1abc2xyz3456 
+ 0: 1abc2xyz3
+
+/^(a*\w|ab)=(a*\w|ab)/
+    ab=ab
+ 0: ab=ab
+ 1: ab=a
+
+/^(a*\w|ab)=(?1)/
+    ab=ab
+ 0: ab=ab
+
+/^([^()]|\((?1)*\))*$/
+    abc
+ 0: abc
+    a(b)c
+ 0: a(b)c
+    a(b(c))d  
+ 0: a(b(c))d
+    *** Failers)
+No match
+    a(b(c)d  
+No match
+
+/^>abc>([^()]|\((?1)*\))*<xyz<$/
+    >abc>123<xyz<
+ 0: >abc>123<xyz<
+    >abc>1(2)3<xyz<
+ 0: >abc>1(2)3<xyz<
+    >abc>(1(2)3)<xyz<
+ 0: >abc>(1(2)3)<xyz<
+
+/^(?>a*)\d/
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9876
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9
+    *** Failers 
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+
+/< (?: (?(R) \d++  | [^<>]*+) | (?R)) * >/x
+    <>
+ 0: <>
+    <abcd>
+ 0: <abcd>
+    <abc <123> hij>
+ 0: <abc <123> hij>
+    <abc <def> hij>
+ 0: <def>
+    <abc<>def> 
+ 0: <abc<>def>
+    <abc<>      
+ 0: <>
+    *** Failers
+No match
+    <abc
+No match
+
+/^(?(?=abc)\w{3}:|\d\d)$/        
+    abc:                          
+ 0: abc:
+    12                             
+ 0: 12
+    *** Failers                     
+No match
+    123                       
+No match
+    xyz                        
+No match
+                                
+/^(?(?!abc)\d\d|\w{3}:)$/      
+    abc:                        
+ 0: abc:
+    12         
+ 0: 12
+    *** Failers
+No match
+    123
+No match
+    xyz    
+No match
+
+/^(?=abc)\w{5}:$/        
+    abcde:                          
+ 0: abcde:
+    *** Failers                     
+No match
+    abc.. 
+No match
+    123                       
+No match
+    vwxyz                        
+No match
+                                
+/^(?!abc)\d\d$/      
+    12         
+ 0: 12
+    *** Failers
+No match
+    abcde:
+No match
+    abc..  
+No match
+    123
+No match
+    vwxyz    
+No match
+
+/(?<=abc|xy)123/
+    abc12345
+ 0: 123
+    wxy123z
+ 0: 123
+    *** Failers
+No match
+    123abc
+No match
+
+/(?<!abc|xy)123/
+    123abc
+ 0: 123
+    mno123456 
+ 0: 123
+    *** Failers
+No match
+    abc12345
+No match
+    wxy123z
+No match
+
+/abc(?C1)xyz/
+    abcxyz
+--->abcxyz
+  1 ^  ^       x
+ 0: abcxyz
+    123abcxyz999 
+--->123abcxyz999
+  1    ^  ^          x
+ 0: abcxyz
+
+/(ab|cd){3,4}/C
+  ababab
+--->ababab
+ +0 ^          (ab|cd){3,4}
+ +1 ^          a
+ +4 ^          c
+ +2 ^^         b
+ +3 ^ ^        |
+ +1 ^ ^        a
+ +4 ^ ^        c
+ +2 ^  ^       b
+ +3 ^   ^      |
+ +1 ^   ^      a
+ +4 ^   ^      c
+ +2 ^    ^     b
+ +3 ^     ^    |
++12 ^     ^    
+ +1 ^     ^    a
+ +4 ^     ^    c
+ 0: ababab
+  abcdabcd
+--->abcdabcd
+ +0 ^            (ab|cd){3,4}
+ +1 ^            a
+ +4 ^            c
+ +2 ^^           b
+ +3 ^ ^          |
+ +1 ^ ^          a
+ +4 ^ ^          c
+ +5 ^  ^         d
+ +6 ^   ^        )
+ +1 ^   ^        a
+ +4 ^   ^        c
+ +2 ^    ^       b
+ +3 ^     ^      |
++12 ^     ^      
+ +1 ^     ^      a
+ +4 ^     ^      c
+ +5 ^      ^     d
+ +6 ^       ^    )
++12 ^       ^    
+ 0: abcdabcd
+ 1: abcdab
+  abcdcdcdcdcd  
+--->abcdcdcdcdcd
+ +0 ^                (ab|cd){3,4}
+ +1 ^                a
+ +4 ^                c
+ +2 ^^               b
+ +3 ^ ^              |
+ +1 ^ ^              a
+ +4 ^ ^              c
+ +5 ^  ^             d
+ +6 ^   ^            )
+ +1 ^   ^            a
+ +4 ^   ^            c
+ +5 ^    ^           d
+ +6 ^     ^          )
++12 ^     ^          
+ +1 ^     ^          a
+ +4 ^     ^          c
+ +5 ^      ^         d
+ +6 ^       ^        )
++12 ^       ^        
+ 0: abcdcdcd
+ 1: abcdcd
+
+/^abc/
+    abcdef
+ 0: abc
+    *** Failers
+No match
+    abcdef\B  
+No match
+
+/^(a*|xyz)/
+    bcd
+ 0: 
+    aaabcd
+ 0: aaa
+ 1: aa
+ 2: a
+ 3: 
+    xyz
+ 0: xyz
+ 1: 
+    xyz\N  
+ 0: xyz
+    *** Failers
+ 0: 
+    bcd\N   
+No match
+    
+/xyz$/
+    xyz
+ 0: xyz
+    xyz\n
+ 0: xyz
+    *** Failers
+No match
+    xyz\Z
+No match
+    xyz\n\Z    
+No match
+    
+/xyz$/m
+    xyz
+ 0: xyz
+    xyz\n 
+ 0: xyz
+    abcxyz\npqr 
+ 0: xyz
+    abcxyz\npqr\Z 
+ 0: xyz
+    xyz\n\Z    
+ 0: xyz
+    *** Failers
+No match
+    xyz\Z
+No match
+
+/\Gabc/
+    abcdef
+ 0: abc
+    defabcxyz\>3 
+ 0: abc
+    *** Failers 
+No match
+    defabcxyz
+No match
+
+/^abcdef/
+    ab\P
+Partial match: ab
+    abcde\P
+Partial match: abcde
+    abcdef\P
+ 0: abcdef
+    *** Failers
+No match
+    abx\P    
+No match
+
+/^a{2,4}\d+z/
+    a\P
+Partial match: a
+    aa\P
+Partial match: aa
+    aa2\P 
+Partial match: aa2
+    aaa\P
+Partial match: aaa
+    aaa23\P 
+Partial match: aaa23
+    aaaa12345\P
+Partial match: aaaa12345
+    aa0z\P
+ 0: aa0z
+    aaaa4444444444444z\P 
+ 0: aaaa4444444444444z
+    *** Failers
+No match
+    az\P 
+No match
+    aaaaa\P 
+No match
+    a56\P 
+No match
+
+/^abcdef/
+   abc\P
+Partial match: abc
+   def\R 
+ 0: def
+   
+/(?<=foo)bar/
+   xyzfo\P 
+No match
+   foob\P\>2 
+Partial match: b
+   foobar...\R\P\>4 
+ 0: ar
+   xyzfo\P
+No match
+   foobar\>2  
+ 0: bar
+   *** Failers
+No match
+   xyzfo\P
+No match
+   obar\R   
+No match
+
+/(ab*(cd|ef))+X/
+    adfadadaklhlkalkajhlkjahdfasdfasdfladsfjkj\P\Z
+No match
+    lkjhlkjhlkjhlkjhabbbbbbcdaefabbbbbbbefa\P\B\Z
+Partial match: abbbbbbcdaefabbbbbbbefa
+    cdabbbbbbbb\P\R\B\Z
+Partial match: cdabbbbbbbb
+    efabbbbbbbbbbbbbbbb\P\R\B\Z
+Partial match: efabbbbbbbbbbbbbbbb
+    bbbbbbbbbbbbcdXyasdfadf\P\R\B\Z    
+ 0: bbbbbbbbbbbbcdX
+
+/(a|b)/SF>testsavedregex
+Compiled regex written to testsavedregex
+Study data written to testsavedregex
+<testsavedregex
+Compiled regex (byte-inverted) loaded from testsavedregex
+Study data loaded from testsavedregex
+    abc
+ 0: a
+    ** Failers
+ 0: a
+    def  
+No match
+    
+/the quick brown fox/
+    the quick brown fox
+ 0: the quick brown fox
+    The quick brown FOX
+No match
+    What do you know about the quick brown fox?
+ 0: the quick brown fox
+    What do you know about THE QUICK BROWN FOX?
+No match
+
+/The quick brown fox/i
+    the quick brown fox
+ 0: the quick brown fox
+    The quick brown FOX
+ 0: The quick brown FOX
+    What do you know about the quick brown fox?
+ 0: the quick brown fox
+    What do you know about THE QUICK BROWN FOX?
+ 0: THE QUICK BROWN FOX
+
+/abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
+    abcd\t\n\r\f\a\e9;\$\\?caxyz
+ 0: abcd\x09\x0a\x0d\x0c\x07\x1b9;$\?caxyz
+
+/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
+    abxyzpqrrrabbxyyyypqAzz
+ 0: abxyzpqrrrabbxyyyypqAzz
+    abxyzpqrrrabbxyyyypqAzz
+ 0: abxyzpqrrrabbxyyyypqAzz
+    aabxyzpqrrrabbxyyyypqAzz
+ 0: aabxyzpqrrrabbxyyyypqAzz
+    aaabxyzpqrrrabbxyyyypqAzz
+ 0: aaabxyzpqrrrabbxyyyypqAzz
+    aaaabxyzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzpqrrrabbxyyyypqAzz
+    abcxyzpqrrrabbxyyyypqAzz
+ 0: abcxyzpqrrrabbxyyyypqAzz
+    aabcxyzpqrrrabbxyyyypqAzz
+ 0: aabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypAzz
+ 0: aaabcxyzpqrrrabbxyyyypAzz
+    aaabcxyzpqrrrabbxyyyypqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqqAzz
+    aaabcxyzpqrrrabbxyyyypqqqqqqAzz
+ 0: aaabcxyzpqrrrabbxyyyypqqqqqqAzz
+    aaaabcxyzpqrrrabbxyyyypqAzz
+ 0: aaaabcxyzpqrrrabbxyyyypqAzz
+    abxyzzpqrrrabbxyyyypqAzz
+ 0: abxyzzpqrrrabbxyyyypqAzz
+    aabxyzzzpqrrrabbxyyyypqAzz
+ 0: aabxyzzzpqrrrabbxyyyypqAzz
+    aaabxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaabxyzzzzpqrrrabbxyyyypqAzz
+    aaaabxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzzzzpqrrrabbxyyyypqAzz
+    abcxyzzpqrrrabbxyyyypqAzz
+ 0: abcxyzzpqrrrabbxyyyypqAzz
+    aabcxyzzzpqrrrabbxyyyypqAzz
+ 0: aabcxyzzzpqrrrabbxyyyypqAzz
+    aaabcxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbxyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbbxyyyypqAzz
+    aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
+ 0: aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
+    aaabcxyzpqrrrabbxyyyypABzz
+ 0: aaabcxyzpqrrrabbxyyyypABzz
+    aaabcxyzpqrrrabbxyyyypABBzz
+ 0: aaabcxyzpqrrrabbxyyyypABBzz
+    >>>aaabxyzpqrrrabbxyyyypqAzz
+ 0: aaabxyzpqrrrabbxyyyypqAzz
+    >aaaabxyzpqrrrabbxyyyypqAzz
+ 0: aaaabxyzpqrrrabbxyyyypqAzz
+    >>>>abcxyzpqrrrabbxyyyypqAzz
+ 0: abcxyzpqrrrabbxyyyypqAzz
+    *** Failers
+No match
+    abxyzpqrrabbxyyyypqAzz
+No match
+    abxyzpqrrrrabbxyyyypqAzz
+No match
+    abxyzpqrrrabxyyyypqAzz
+No match
+    aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
+No match
+    aaaabcxyzzzzpqrrrabbbxyyypqAzz
+No match
+    aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
+No match
+
+/^(abc){1,2}zz/
+    abczz
+ 0: abczz
+    abcabczz
+ 0: abcabczz
+    *** Failers
+No match
+    zz
+No match
+    abcabcabczz
+No match
+    >>abczz
+No match
+
+/^(b+?|a){1,2}?c/
+    bc
+ 0: bc
+    bbc
+ 0: bbc
+    bbbc
+ 0: bbbc
+    bac
+ 0: bac
+    bbac
+ 0: bbac
+    aac
+ 0: aac
+    abbbbbbbbbbbc
+ 0: abbbbbbbbbbbc
+    bbbbbbbbbbbac
+ 0: bbbbbbbbbbbac
+    *** Failers
+No match
+    aaac
+No match
+    abbbbbbbbbbbac
+No match
+
+/^(b+|a){1,2}c/
+    bc
+ 0: bc
+    bbc
+ 0: bbc
+    bbbc
+ 0: bbbc
+    bac
+ 0: bac
+    bbac
+ 0: bbac
+    aac
+ 0: aac
+    abbbbbbbbbbbc
+ 0: abbbbbbbbbbbc
+    bbbbbbbbbbbac
+ 0: bbbbbbbbbbbac
+    *** Failers
+No match
+    aaac
+No match
+    abbbbbbbbbbbac
+No match
+
+/^(b+|a){1,2}?bc/
+    bbc
+ 0: bbc
+
+/^(b*|ba){1,2}?bc/
+    babc
+ 0: babc
+    bbabc
+ 0: bbabc
+    bababc
+ 0: bababc
+    *** Failers
+No match
+    bababbc
+No match
+    babababc
+No match
+
+/^(ba|b*){1,2}?bc/
+    babc
+ 0: babc
+    bbabc
+ 0: bbabc
+    bababc
+ 0: bababc
+    *** Failers
+No match
+    bababbc
+No match
+    babababc
+No match
+
+/^\ca\cA\c[\c{\c:/
+    \x01\x01\e;z
+ 0: \x01\x01\x1b;z
+
+/^[ab\]cde]/
+    athing
+ 0: a
+    bthing
+ 0: b
+    ]thing
+ 0: ]
+    cthing
+ 0: c
+    dthing
+ 0: d
+    ething
+ 0: e
+    *** Failers
+No match
+    fthing
+No match
+    [thing
+No match
+    \\thing
+No match
+
+/^[]cde]/
+    ]thing
+ 0: ]
+    cthing
+ 0: c
+    dthing
+ 0: d
+    ething
+ 0: e
+    *** Failers
+No match
+    athing
+No match
+    fthing
+No match
+
+/^[^ab\]cde]/
+    fthing
+ 0: f
+    [thing
+ 0: [
+    \\thing
+ 0: \
+    *** Failers
+ 0: *
+    athing
+No match
+    bthing
+No match
+    ]thing
+No match
+    cthing
+No match
+    dthing
+No match
+    ething
+No match
+
+/^[^]cde]/
+    athing
+ 0: a
+    fthing
+ 0: f
+    *** Failers
+ 0: *
+    ]thing
+No match
+    cthing
+No match
+    dthing
+No match
+    ething
+No match
+
+/^\/
+    
+ 0: \x81
+
+/^ÿ/
+    ÿ
+ 0: \xff
+
+/^[0-9]+$/
+    0
+ 0: 0
+    1
+ 0: 1
+    2
+ 0: 2
+    3
+ 0: 3
+    4
+ 0: 4
+    5
+ 0: 5
+    6
+ 0: 6
+    7
+ 0: 7
+    8
+ 0: 8
+    9
+ 0: 9
+    10
+ 0: 10
+    100
+ 0: 100
+    *** Failers
+No match
+    abc
+No match
+
+/^.*nter/
+    enter
+ 0: enter
+    inter
+ 0: inter
+    uponter
+ 0: uponter
+
+/^xxx[0-9]+$/
+    xxx0
+ 0: xxx0
+    xxx1234
+ 0: xxx1234
+    *** Failers
+No match
+    xxx
+No match
+
+/^.+[0-9][0-9][0-9]$/
+    x123
+ 0: x123
+    xx123
+ 0: xx123
+    123456
+ 0: 123456
+    *** Failers
+No match
+    123
+No match
+    x1234
+ 0: x1234
+
+/^.+?[0-9][0-9][0-9]$/
+    x123
+ 0: x123
+    xx123
+ 0: xx123
+    123456
+ 0: 123456
+    *** Failers
+No match
+    123
+No match
+    x1234
+ 0: x1234
+
+/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
+    abc!pqr=apquxz.ixr.zzz.ac.uk
+ 0: abc!pqr=apquxz.ixr.zzz.ac.uk
+    *** Failers
+No match
+    !pqr=apquxz.ixr.zzz.ac.uk
+No match
+    abc!=apquxz.ixr.zzz.ac.uk
+No match
+    abc!pqr=apquxz:ixr.zzz.ac.uk
+No match
+    abc!pqr=apquxz.ixr.zzz.ac.ukk
+No match
+
+/:/
+    Well, we need a colon: somewhere
+ 0: :
+    *** Fail if we don't
+No match
+
+/([\da-f:]+)$/i
+    0abc
+ 0: 0abc
+    abc
+ 0: abc
+    fed
+ 0: fed
+    E
+ 0: E
+    ::
+ 0: ::
+    5f03:12C0::932e
+ 0: 5f03:12C0::932e
+    fed def
+ 0: def
+    Any old stuff
+ 0: ff
+    *** Failers
+No match
+    0zzz
+No match
+    gzzz
+No match
+    fed\x20
+No match
+    Any old rubbish
+No match
+
+/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
+    .1.2.3
+ 0: .1.2.3
+    A.12.123.0
+ 0: A.12.123.0
+    *** Failers
+No match
+    .1.2.3333
+No match
+    1.2.3
+No match
+    1234.2.3
+No match
+
+/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
+    1 IN SOA non-sp1 non-sp2(
+ 0: 1 IN SOA non-sp1 non-sp2(
+    1    IN    SOA    non-sp1    non-sp2   (
+ 0: 1    IN    SOA    non-sp1    non-sp2   (
+    *** Failers
+No match
+    1IN SOA non-sp1 non-sp2(
+No match
+
+/^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
+    a.
+ 0: a.
+    Z.
+ 0: Z.
+    2.
+ 0: 2.
+    ab-c.pq-r.
+ 0: ab-c.pq-r.
+    sxk.zzz.ac.uk.
+ 0: sxk.zzz.ac.uk.
+    x-.y-.
+ 0: x-.y-.
+    *** Failers
+No match
+    -abc.peq.
+No match
+
+/^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
+    *.a
+ 0: *.a
+    *.b0-a
+ 0: *.b0-a
+    *.c3-b.c
+ 0: *.c3-b.c
+    *.c-a.b-c
+ 0: *.c-a.b-c
+    *** Failers
+No match
+    *.0
+No match
+    *.a-
+No match
+    *.a-b.c-
+No match
+    *.c-a.0-c
+No match
+
+/^(?=ab(de))(abd)(e)/
+    abde
+ 0: abde
+
+/^(?!(ab)de|x)(abd)(f)/
+    abdf
+ 0: abdf
+
+/^(?=(ab(cd)))(ab)/
+    abcd
+ 0: ab
+
+/^[\da-f](\.[\da-f])*$/i
+    a.b.c.d
+ 0: a.b.c.d
+    A.B.C.D
+ 0: A.B.C.D
+    a.b.c.1.2.3.C
+ 0: a.b.c.1.2.3.C
+
+/^\".*\"\s*(;.*)?$/
+    \"1234\"
+ 0: "1234"
+    \"abcd\" ;
+ 0: "abcd" ;
+    \"\" ; rhubarb
+ 0: "" ; rhubarb
+    *** Failers
+No match
+    \"1234\" : things
+No match
+
+/^$/
+    \
+ 0: 
+    *** Failers
+No match
+
+/   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/x
+    ab c
+ 0: ab c
+    *** Failers
+No match
+    abc
+No match
+    ab cde
+No match
+
+/(?x)   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/
+    ab c
+ 0: ab c
+    *** Failers
+No match
+    abc
+No match
+    ab cde
+No match
+
+/^   a\ b[c ]d       $/x
+    a bcd
+ 0: a bcd
+    a b d
+ 0: a b d
+    *** Failers
+No match
+    abcd
+No match
+    ab d
+No match
+
+/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
+    abcdefhijklm
+ 0: abcdefhijklm
+
+/^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
+    abcdefhijklm
+ 0: abcdefhijklm
+
+/^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
+    a+ Z0+\x08\n\x1d\x12
+ 0: a+ Z0+\x08\x0a\x1d\x12
+
+/^[.^$|()*+?{,}]+/
+    .^\$(*+)|{?,?}
+ 0: .^$(*+)|{?,?}
+ 1: .^$(*+)|{?,?
+ 2: .^$(*+)|{?,
+ 3: .^$(*+)|{?
+ 4: .^$(*+)|{
+ 5: .^$(*+)|
+ 6: .^$(*+)
+ 7: .^$(*+
+ 8: .^$(*
+ 9: .^$(
+10: .^$
+11: .^
+12: .
+
+/^a*\w/
+    z
+ 0: z
+    az
+ 0: az
+ 1: a
+    aaaz
+ 0: aaaz
+ 1: aaa
+ 2: aa
+ 3: a
+    a
+ 0: a
+    aa
+ 0: aa
+ 1: a
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+ 3: a
+    a+
+ 0: a
+    aa+
+ 0: aa
+ 1: a
+
+/^a*?\w/
+    z
+ 0: z
+    az
+ 0: az
+ 1: a
+    aaaz
+ 0: aaaz
+ 1: aaa
+ 2: aa
+ 3: a
+    a
+ 0: a
+    aa
+ 0: aa
+ 1: a
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+ 3: a
+    a+
+ 0: a
+    aa+
+ 0: aa
+ 1: a
+
+/^a+\w/
+    az
+ 0: az
+    aaaz
+ 0: aaaz
+ 1: aaa
+ 2: aa
+    aa
+ 0: aa
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+    aa+
+ 0: aa
+
+/^a+?\w/
+    az
+ 0: az
+    aaaz
+ 0: aaaz
+ 1: aaa
+ 2: aa
+    aa
+ 0: aa
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+    aa+
+ 0: aa
+
+/^\d{8}\w{2,}/
+    1234567890
+ 0: 1234567890
+    12345678ab
+ 0: 12345678ab
+    12345678__
+ 0: 12345678__
+    *** Failers
+No match
+    1234567
+No match
+
+/^[aeiou\d]{4,5}$/
+    uoie
+ 0: uoie
+    1234
+ 0: 1234
+    12345
+ 0: 12345
+    aaaaa
+ 0: aaaaa
+    *** Failers
+No match
+    123456
+No match
+
+/^[aeiou\d]{4,5}?/
+    uoie
+ 0: uoie
+    1234
+ 0: 1234
+    12345
+ 0: 12345
+ 1: 1234
+    aaaaa
+ 0: aaaaa
+ 1: aaaa
+    123456
+ 0: 12345
+ 1: 1234
+
+/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
+    From abcd  Mon Sep 01 12:33:02 1997
+ 0: From abcd  Mon Sep 01 12:33
+
+/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
+    From abcd  Mon Sep 01 12:33:02 1997
+ 0: From abcd  Mon Sep 01 12:33
+    From abcd  Mon Sep  1 12:33:02 1997
+ 0: From abcd  Mon Sep  1 12:33
+    *** Failers
+No match
+    From abcd  Sep 01 12:33:02 1997
+No match
+
+/^12.34/s
+    12\n34
+ 0: 12\x0a34
+    12\r34
+ 0: 12\x0d34
+
+/\w+(?=\t)/
+    the quick brown\t fox
+ 0: brown
+
+/foo(?!bar)(.*)/
+    foobar is foolish see?
+ 0: foolish see?
+ 1: foolish see
+ 2: foolish se
+ 3: foolish s
+ 4: foolish 
+ 5: foolish
+ 6: foolis
+ 7: fooli
+ 8: fool
+ 9: foo
+
+/(?:(?!foo)...|^.{0,2})bar(.*)/
+    foobar crowbar etc
+ 0: rowbar etc
+ 1: rowbar et
+ 2: rowbar e
+ 3: rowbar 
+ 4: rowbar
+    barrel
+ 0: barrel
+ 1: barre
+ 2: barr
+ 3: bar
+    2barrel
+ 0: 2barrel
+ 1: 2barre
+ 2: 2barr
+ 3: 2bar
+    A barrel
+ 0: A barrel
+ 1: A barre
+ 2: A barr
+ 3: A bar
+
+/^(\D*)(?=\d)(?!123)/
+    abc456
+ 0: abc
+    *** Failers
+No match
+    abc123
+No match
+
+/^1234(?# test newlines
+  inside)/
+    1234
+ 0: 1234
+
+/^1234 #comment in extended re
+  /x
+    1234
+ 0: 1234
+
+/#rhubarb
+  abcd/x
+    abcd
+ 0: abcd
+
+/^abcd#rhubarb/x
+    abcd
+ 0: abcd
+
+/(?!^)abc/
+    the abc
+ 0: abc
+    *** Failers
+No match
+    abc
+No match
+
+/(?=^)abc/
+    abc
+ 0: abc
+    *** Failers
+No match
+    the abc
+No match
+
+/^[ab]{1,3}(ab*|b)/
+    aabbbbb
+ 0: aabbbbb
+ 1: aabbbb
+ 2: aabbb
+ 3: aabb
+ 4: aab
+ 5: aa
+
+/^[ab]{1,3}?(ab*|b)/
+    aabbbbb
+ 0: aabbbbb
+ 1: aabbbb
+ 2: aabbb
+ 3: aabb
+ 4: aab
+ 5: aa
+
+/^[ab]{1,3}?(ab*?|b)/
+    aabbbbb
+ 0: aabbbbb
+ 1: aabbbb
+ 2: aabbb
+ 3: aabb
+ 4: aab
+ 5: aa
+
+/^[ab]{1,3}(ab*?|b)/
+    aabbbbb
+ 0: aabbbbb
+ 1: aabbbb
+ 2: aabbb
+ 3: aabb
+ 4: aab
+ 5: aa
+
+/  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                          # optional leading comment
+(?:    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+# address
+|                     #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)             # one word, optionally followed by....
+(?:
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
+\(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)       |  # comments, or...
+
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+# quoted strings
+)*
+<  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                     # leading <
+(?:  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  ,  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+)* # further okay, if led by comma
+:                                # closing colon
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  )? #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)                    # initial word
+(?:  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+" (?:                      # opening quote...
+[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
+|                     #    or
+\\ [^\x80-\xff]           #   Escaped something (something != CR)
+)* "  # closing quote
+)  )* # further okay, if led by a period
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  @  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*    (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                           # initial subdomain
+(?:                                  #
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  \.                        # if led by a period...
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*   (?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|   \[                         # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
+\]                        #           ]
+)                     #   ...further okay
+)*
+#       address spec
+(?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*  > #                  trailing >
+# name and address
+)  (?: [\040\t] |  \(
+(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
+\)  )*                       # optional trailing comment
+/x
+    Alan Other <user\@dom.ain>
+ 0: Alan Other <user@dom.ain>
+    <user\@dom.ain>
+ 0: user@dom.ain
+ 1: user@dom
+    user\@dom.ain
+ 0: user@dom.ain
+ 1: user@dom
+    \"A. Other\" <user.1234\@dom.ain> (a comment)
+ 0: "A. Other" <user.1234@dom.ain> (a comment)
+ 1: "A. Other" <user.1234@dom.ain> 
+ 2: "A. Other" <user.1234@dom.ain>
+    A. Other <user.1234\@dom.ain> (a comment)
+ 0:  Other <user.1234@dom.ain> (a comment)
+ 1:  Other <user.1234@dom.ain> 
+ 2:  Other <user.1234@dom.ain>
+    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
+ 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
+ 1: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re
+    A missing angle <user\@some.where
+ 0: user@some.where
+ 1: user@some
+    *** Failers
+No match
+    The quick brown fox
+No match
+
+/[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional leading comment
+(?:
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# additional words
+)*
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+# address
+|                             #  or
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+# leading word
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *               # "normal" atoms and or spaces
+(?:
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+|
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+) # "special" comment or quoted string
+[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *            #  more "normal"
+)*
+<
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# <
+(?:
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+(?: ,
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+)*  # additional domains
+:
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)?     #       optional route
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+# Atom
+|                       #  or
+"                                     # "
+[^\\\x80-\xff\n\015"] *                            #   normal
+(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
+"                                     #        "
+# Quoted string
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# additional words
+)*
+@
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+(?:
+\.
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+(?:
+[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
+|
+\[                            # [
+(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
+\]                           #           ]
+)
+[\040\t]*                    # Nab whitespace.
+(?:
+\(                              #  (
+[^\\\x80-\xff\n\015()] *                             #     normal*
+(?:                                 #       (
+(?:  \\ [^\x80-\xff]  |
+\(                            #  (
+[^\\\x80-\xff\n\015()] *                            #     normal*
+(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
+\)                           #                       )
+)    #         special
+[^\\\x80-\xff\n\015()] *                         #         normal*
+)*                                  #            )*
+\)                             #                )
+[\040\t]* )*    # If comment found, allow more spaces.
+# optional trailing comments
+)*
+#       address spec
+>                    #                 >
+# name and address
+)
+/x
+    Alan Other <user\@dom.ain>
+ 0: Alan Other <user@dom.ain>
+    <user\@dom.ain>
+ 0: user@dom.ain
+ 1: user@dom
+    user\@dom.ain
+ 0: user@dom.ain
+ 1: user@dom
+    \"A. Other\" <user.1234\@dom.ain> (a comment)
+ 0: "A. Other" <user.1234@dom.ain>
+    A. Other <user.1234\@dom.ain> (a comment)
+ 0:  Other <user.1234@dom.ain>
+    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
+ 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
+ 1: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re
+    A missing angle <user\@some.where
+ 0: user@some.where
+ 1: user@some
+    *** Failers
+No match
+    The quick brown fox
+No match
+
+/abc\0def\00pqr\000xyz\0000AB/
+    abc\0def\00pqr\000xyz\0000AB
+ 0: abc\x00def\x00pqr\x00xyz\x000AB
+    abc456 abc\0def\00pqr\000xyz\0000ABCDE
+ 0: abc\x00def\x00pqr\x00xyz\x000AB
+
+/abc\x0def\x00pqr\x000xyz\x0000AB/
+    abc\x0def\x00pqr\x000xyz\x0000AB
+ 0: abc\x0def\x00pqr\x000xyz\x0000AB
+    abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
+ 0: abc\x0def\x00pqr\x000xyz\x0000AB
+
+/^[\000-\037]/
+    \0A
+ 0: \x00
+    \01B
+ 0: \x01
+    \037C
+ 0: \x1f
+
+/\0*/
+    \0\0\0\0
+ 0: \x00\x00\x00\x00
+ 1: \x00\x00\x00
+ 2: \x00\x00
+ 3: \x00
+ 4: 
+
+/A\x0{2,3}Z/
+    The A\x0\x0Z
+ 0: A\x00\x00Z
+    An A\0\x0\0Z
+ 0: A\x00\x00\x00Z
+    *** Failers
+No match
+    A\0Z
+No match
+    A\0\x0\0\x0Z
+No match
+
+/^\s/
+    \040abc
+ 0:  
+    \x0cabc
+ 0: \x0c
+    \nabc
+ 0: \x0a
+    \rabc
+ 0: \x0d
+    \tabc
+ 0: \x09
+    *** Failers
+No match
+    abc
+No match
+
+/^a	b
+      c/x
+    abc
+ 0: abc
+
+/ab{1,3}bc/
+    abbbbc
+ 0: abbbbc
+    abbbc
+ 0: abbbc
+    abbc
+ 0: abbc
+    *** Failers
+No match
+    abc
+No match
+    abbbbbc
+No match
+
+/([^.]*)\.([^:]*):[T ]+(.*)/
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1.title:TBlah blah bla
+ 2: track1.title:TBlah blah bl
+ 3: track1.title:TBlah blah b
+ 4: track1.title:TBlah blah 
+ 5: track1.title:TBlah blah
+ 6: track1.title:TBlah bla
+ 7: track1.title:TBlah bl
+ 8: track1.title:TBlah b
+ 9: track1.title:TBlah 
+10: track1.title:TBlah
+11: track1.title:TBla
+12: track1.title:TBl
+13: track1.title:TB
+14: track1.title:T
+
+/([^.]*)\.([^:]*):[T ]+(.*)/i
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1.title:TBlah blah bla
+ 2: track1.title:TBlah blah bl
+ 3: track1.title:TBlah blah b
+ 4: track1.title:TBlah blah 
+ 5: track1.title:TBlah blah
+ 6: track1.title:TBlah bla
+ 7: track1.title:TBlah bl
+ 8: track1.title:TBlah b
+ 9: track1.title:TBlah 
+10: track1.title:TBlah
+11: track1.title:TBla
+12: track1.title:TBl
+13: track1.title:TB
+14: track1.title:T
+
+/([^.]*)\.([^:]*):[t ]+(.*)/i
+    track1.title:TBlah blah blah
+ 0: track1.title:TBlah blah blah
+ 1: track1.title:TBlah blah bla
+ 2: track1.title:TBlah blah bl
+ 3: track1.title:TBlah blah b
+ 4: track1.title:TBlah blah 
+ 5: track1.title:TBlah blah
+ 6: track1.title:TBlah bla
+ 7: track1.title:TBlah bl
+ 8: track1.title:TBlah b
+ 9: track1.title:TBlah 
+10: track1.title:TBlah
+11: track1.title:TBla
+12: track1.title:TBl
+13: track1.title:TB
+14: track1.title:T
+
+/^[W-c]+$/
+    WXY_^abc
+ 0: WXY_^abc
+    *** Failers
+No match
+    wxy
+No match
+
+/^[W-c]+$/i
+    WXY_^abc
+ 0: WXY_^abc
+    wxy_^ABC
+ 0: wxy_^ABC
+
+/^[\x3f-\x5F]+$/i
+    WXY_^abc
+ 0: WXY_^abc
+    wxy_^ABC
+ 0: wxy_^ABC
+
+/^abc$/m
+    abc
+ 0: abc
+    qqq\nabc
+ 0: abc
+    abc\nzzz
+ 0: abc
+    qqq\nabc\nzzz
+ 0: abc
+
+/^abc$/
+    abc
+ 0: abc
+    *** Failers
+No match
+    qqq\nabc
+No match
+    abc\nzzz
+No match
+    qqq\nabc\nzzz
+No match
+
+/\Aabc\Z/m
+    abc
+ 0: abc
+    abc\n 
+ 0: abc
+    *** Failers
+No match
+    qqq\nabc
+No match
+    abc\nzzz
+No match
+    qqq\nabc\nzzz
+No match
+    
+/\A(.)*\Z/s
+    abc\ndef
+ 0: abc\x0adef
+
+/\A(.)*\Z/m
+    *** Failers
+ 0: *** Failers
+    abc\ndef
+No match
+
+/(?:b)|(?::+)/
+    b::c
+ 0: b
+    c::b
+ 0: ::
+ 1: :
+
+/[-az]+/
+    az-
+ 0: az-
+ 1: az
+ 2: a
+    *** Failers
+ 0: a
+    b
+No match
+
+/[az-]+/
+    za-
+ 0: za-
+ 1: za
+ 2: z
+    *** Failers
+ 0: a
+    b
+No match
+
+/[a\-z]+/
+    a-z
+ 0: a-z
+ 1: a-
+ 2: a
+    *** Failers
+ 0: a
+    b
+No match
+
+/[a-z]+/
+    abcdxyz
+ 0: abcdxyz
+ 1: abcdxy
+ 2: abcdx
+ 3: abcd
+ 4: abc
+ 5: ab
+ 6: a
+
+/[\d-]+/
+    12-34
+ 0: 12-34
+ 1: 12-3
+ 2: 12-
+ 3: 12
+ 4: 1
+    *** Failers
+No match
+    aaa
+No match
+
+/[\d-z]+/
+    12-34z
+ 0: 12-34z
+ 1: 12-34
+ 2: 12-3
+ 3: 12-
+ 4: 12
+ 5: 1
+    *** Failers
+No match
+    aaa
+No match
+
+/\x5c/
+    \\
+ 0: \
+
+/\x20Z/
+    the Zoo
+ 0:  Z
+    *** Failers
+No match
+    Zulu
+No match
+
+/ab{3cd/
+    ab{3cd
+ 0: ab{3cd
+
+/ab{3,cd/
+    ab{3,cd
+ 0: ab{3,cd
+
+/ab{3,4a}cd/
+    ab{3,4a}cd
+ 0: ab{3,4a}cd
+
+/{4,5a}bc/
+    {4,5a}bc
+ 0: {4,5a}bc
+
+/^a.b/<lf>
+    a\rb
+ 0: a\x0db
+    *** Failers
+No match
+    a\nb
+No match
+
+/abc$/
+    abc
+ 0: abc
+    abc\n
+ 0: abc
+    *** Failers
+No match
+    abc\ndef
+No match
+
+/(abc)\123/
+    abc\x53
+ 0: abcS
+
+/(abc)\223/
+    abc\x93
+ 0: abc\x93
+
+/(abc)\323/
+    abc\xd3
+ 0: abc\xd3
+
+/(abc)\100/
+    abc\x40
+ 0: abc@
+    abc\100
+ 0: abc@
+
+/(abc)\1000/
+    abc\x400
+ 0: abc@0
+    abc\x40\x30
+ 0: abc@0
+    abc\1000
+ 0: abc@0
+    abc\100\x30
+ 0: abc@0
+    abc\100\060
+ 0: abc@0
+    abc\100\60
+ 0: abc@0
+
+/abc\81/
+    abc\081
+ 0: abc\x0081
+    abc\0\x38\x31
+ 0: abc\x0081
+
+/abc\91/
+    abc\091
+ 0: abc\x0091
+    abc\0\x39\x31
+ 0: abc\x0091
+
+/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
+    abcdefghijk\12S
+ 0: abcdefghijk\x0aS
+
+/ab\idef/
+    abidef
+ 0: abidef
+
+/a{0}bc/
+    bc
+ 0: bc
+
+/(a|(bc)){0,0}?xyz/
+    xyz
+ 0: xyz
+
+/abc[\10]de/
+    abc\010de
+ 0: abc\x08de
+
+/abc[\1]de/
+    abc\1de
+ 0: abc\x01de
+
+/(abc)[\1]de/
+    abc\1de
+ 0: abc\x01de
+
+/(?s)a.b/
+    a\nb
+ 0: a\x0ab
+
+/^([^a])([^\b])([^c]*)([^d]{3,4})/
+    baNOTccccd
+ 0: baNOTcccc
+ 1: baNOTccc
+ 2: baNOTcc
+ 3: baNOTc
+ 4: baNOT
+    baNOTcccd
+ 0: baNOTccc
+ 1: baNOTcc
+ 2: baNOTc
+ 3: baNOT
+    baNOTccd
+ 0: baNOTcc
+ 1: baNOTc
+ 2: baNOT
+    bacccd
+ 0: baccc
+    *** Failers
+ 0: *** Failers
+ 1: *** Failer
+ 2: *** Faile
+ 3: *** Fail
+ 4: *** Fai
+ 5: *** Fa
+ 6: *** F
+    anything
+No match
+    b\bc   
+No match
+    baccd
+No match
+
+/[^a]/
+    Abc
+ 0: A
+  
+/[^a]/i
+    Abc 
+ 0: b
+
+/[^a]+/
+    AAAaAbc
+ 0: AAA
+ 1: AA
+ 2: A
+  
+/[^a]+/i
+    AAAaAbc 
+ 0: bc
+ 1: b
+
+/[^a]+/
+    bbb\nccc
+ 0: bbb\x0accc
+ 1: bbb\x0acc
+ 2: bbb\x0ac
+ 3: bbb\x0a
+ 4: bbb
+ 5: bb
+ 6: b
+   
+/[^k]$/
+    abc
+ 0: c
+    *** Failers
+ 0: s
+    abk   
+No match
+   
+/[^k]{2,3}$/
+    abc
+ 0: abc
+    kbc
+ 0: bc
+    kabc 
+ 0: abc
+    *** Failers
+ 0: ers
+    abk
+No match
+    akb
+No match
+    akk 
+No match
+
+/^\d{8,}\@.+[^k]$/
+    12345678\@a.b.c.d
+ 0: 12345678@a.b.c.d
+    123456789\@x.y.z
+ 0: 123456789@x.y.z
+    *** Failers
+No match
+    12345678\@x.y.uk
+No match
+    1234567\@a.b.c.d       
+No match
+
+/[^a]/
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: A
+
+/[^a]/i
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: b
+
+/[^az]/
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: A
+
+/[^az]/i
+    aaaabcd
+ 0: b
+    aaAabcd 
+ 0: b
+
+/\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377/
+ \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377
+ 0: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff
+
+/P[^*]TAIRE[^*]{1,6}?LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+ 0: PSTAIREISLL
+
+/P[^*]TAIRE[^*]{1,}?LL/
+    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
+ 0: PSTAIREISLL
+
+/(\.\d\d[1-9]?)\d+/
+    1.230003938
+ 0: .230003938
+ 1: .23000393
+ 2: .2300039
+ 3: .230003
+ 4: .23000
+ 5: .2300
+ 6: .230
+    1.875000282   
+ 0: .875000282
+ 1: .87500028
+ 2: .8750002
+ 3: .875000
+ 4: .87500
+ 5: .8750
+ 6: .875
+    1.235  
+ 0: .235
+                  
+/(\.\d\d((?=0)|\d(?=\d)))/
+    1.230003938      
+ 0: .230
+ 1: .23
+    1.875000282
+ 0: .875
+    *** Failers 
+No match
+    1.235 
+No match
+    
+/a(?)b/
+    ab 
+ 0: ab
+ 
+/\b(foo)\s+(\w+)/i
+    Food is on the foo table
+ 0: foo table
+ 1: foo tabl
+ 2: foo tab
+ 3: foo ta
+ 4: foo t
+    
+/foo(.*)bar/
+    The food is under the bar in the barn.
+ 0: food is under the bar in the bar
+ 1: food is under the bar
+    
+/foo(.*?)bar/  
+    The food is under the bar in the barn.
+ 0: food is under the bar in the bar
+ 1: food is under the bar
+
+/(.*)(\d*)/
+    I have 2 numbers: 53147
+Matched, but too many subsidiary matches
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 5314
+ 2: I have 2 numbers: 531
+ 3: I have 2 numbers: 53
+ 4: I have 2 numbers: 5
+ 5: I have 2 numbers: 
+ 6: I have 2 numbers:
+ 7: I have 2 numbers
+ 8: I have 2 number
+ 9: I have 2 numbe
+10: I have 2 numb
+11: I have 2 num
+12: I have 2 nu
+13: I have 2 n
+14: I have 2 
+15: I have 2
+16: I have 
+17: I have
+18: I hav
+19: I ha
+20: I h
+21: I 
+    
+/(.*)(\d+)/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 5314
+ 2: I have 2 numbers: 531
+ 3: I have 2 numbers: 53
+ 4: I have 2 numbers: 5
+ 5: I have 2
+ 
+/(.*?)(\d*)/
+    I have 2 numbers: 53147
+Matched, but too many subsidiary matches
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 5314
+ 2: I have 2 numbers: 531
+ 3: I have 2 numbers: 53
+ 4: I have 2 numbers: 5
+ 5: I have 2 numbers: 
+ 6: I have 2 numbers:
+ 7: I have 2 numbers
+ 8: I have 2 number
+ 9: I have 2 numbe
+10: I have 2 numb
+11: I have 2 num
+12: I have 2 nu
+13: I have 2 n
+14: I have 2 
+15: I have 2
+16: I have 
+17: I have
+18: I hav
+19: I ha
+20: I h
+21: I 
+
+/(.*?)(\d+)/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+ 1: I have 2 numbers: 5314
+ 2: I have 2 numbers: 531
+ 3: I have 2 numbers: 53
+ 4: I have 2 numbers: 5
+ 5: I have 2
+
+/(.*)(\d+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+
+/(.*?)(\d+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+
+/(.*)\b(\d+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+
+/(.*\D)(\d+)$/
+    I have 2 numbers: 53147
+ 0: I have 2 numbers: 53147
+
+/^\D*(?!123)/
+    ABC123
+ 0: AB
+ 1: A
+ 2: 
+     
+/^(\D*)(?=\d)(?!123)/
+    ABC445
+ 0: ABC
+    *** Failers
+No match
+    ABC123
+No match
+    
+/^[W-]46]/
+    W46]789 
+ 0: W46]
+    -46]789
+ 0: -46]
+    *** Failers
+No match
+    Wall
+No match
+    Zebra
+No match
+    42
+No match
+    [abcd] 
+No match
+    ]abcd[
+No match
+       
+/^[W-\]46]/
+    W46]789 
+ 0: W
+    Wall
+ 0: W
+    Zebra
+ 0: Z
+    Xylophone  
+ 0: X
+    42
+ 0: 4
+    [abcd] 
+ 0: [
+    ]abcd[
+ 0: ]
+    \\backslash 
+ 0: \
+    *** Failers
+No match
+    -46]789
+No match
+    well
+No match
+    
+/\d\d\/\d\d\/\d\d\d\d/
+    01/01/2000
+ 0: 01/01/2000
+
+/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
+  word cat dog elephant mussel cow horse canary baboon snake shark otherword
+ 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
+  word cat dog elephant mussel cow horse canary baboon snake shark
+No match
+
+/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
+  word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+No match
+
+/^(a){0,0}/
+    bcd
+ 0: 
+    abc
+ 0: 
+    aab     
+ 0: 
+
+/^(a){0,1}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: 
+    aab  
+ 0: a
+ 1: 
+
+/^(a){0,2}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: 
+    aab  
+ 0: aa
+ 1: a
+ 2: 
+
+/^(a){0,3}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: 
+    aab
+ 0: aa
+ 1: a
+ 2: 
+    aaa   
+ 0: aaa
+ 1: aa
+ 2: a
+ 3: 
+
+/^(a){0,}/
+    bcd
+ 0: 
+    abc
+ 0: a
+ 1: 
+    aab
+ 0: aa
+ 1: a
+ 2: 
+    aaa
+ 0: aaa
+ 1: aa
+ 2: a
+ 3: 
+    aaaaaaaa    
+ 0: aaaaaaaa
+ 1: aaaaaaa
+ 2: aaaaaa
+ 3: aaaaa
+ 4: aaaa
+ 5: aaa
+ 6: aa
+ 7: a
+ 8: 
+
+/^(a){1,1}/
+    bcd
+No match
+    abc
+ 0: a
+    aab  
+ 0: a
+
+/^(a){1,2}/
+    bcd
+No match
+    abc
+ 0: a
+    aab  
+ 0: aa
+ 1: a
+
+/^(a){1,3}/
+    bcd
+No match
+    abc
+ 0: a
+    aab
+ 0: aa
+ 1: a
+    aaa   
+ 0: aaa
+ 1: aa
+ 2: a
+
+/^(a){1,}/
+    bcd
+No match
+    abc
+ 0: a
+    aab
+ 0: aa
+ 1: a
+    aaa
+ 0: aaa
+ 1: aa
+ 2: a
+    aaaaaaaa    
+ 0: aaaaaaaa
+ 1: aaaaaaa
+ 2: aaaaaa
+ 3: aaaaa
+ 4: aaaa
+ 5: aaa
+ 6: aa
+ 7: a
+
+/.*\.gif/
+    borfle\nbib.gif\nno
+ 0: bib.gif
+
+/.{0,}\.gif/
+    borfle\nbib.gif\nno
+ 0: bib.gif
+
+/.*\.gif/m
+    borfle\nbib.gif\nno
+ 0: bib.gif
+
+/.*\.gif/s
+    borfle\nbib.gif\nno
+ 0: borfle\x0abib.gif
+
+/.*\.gif/ms
+    borfle\nbib.gif\nno
+ 0: borfle\x0abib.gif
+    
+/.*$/
+    borfle\nbib.gif\nno
+ 0: no
+
+/.*$/m
+    borfle\nbib.gif\nno
+ 0: borfle
+
+/.*$/s
+    borfle\nbib.gif\nno
+ 0: borfle\x0abib.gif\x0ano
+
+/.*$/ms
+    borfle\nbib.gif\nno
+ 0: borfle\x0abib.gif\x0ano
+ 1: borfle\x0abib.gif
+ 2: borfle
+    
+/.*$/
+    borfle\nbib.gif\nno\n
+ 0: no
+
+/.*$/m
+    borfle\nbib.gif\nno\n
+ 0: borfle
+
+/.*$/s
+    borfle\nbib.gif\nno\n
+ 0: borfle\x0abib.gif\x0ano\x0a
+ 1: borfle\x0abib.gif\x0ano
+
+/.*$/ms
+    borfle\nbib.gif\nno\n
+ 0: borfle\x0abib.gif\x0ano\x0a
+ 1: borfle\x0abib.gif\x0ano
+ 2: borfle\x0abib.gif
+ 3: borfle
+    
+/(.*X|^B)/
+    abcde\n1234Xyz
+ 0: 1234X
+    BarFoo 
+ 0: B
+    *** Failers
+No match
+    abcde\nBar  
+No match
+
+/(.*X|^B)/m
+    abcde\n1234Xyz
+ 0: 1234X
+    BarFoo 
+ 0: B
+    abcde\nBar  
+ 0: B
+
+/(.*X|^B)/s
+    abcde\n1234Xyz
+ 0: abcde\x0a1234X
+    BarFoo 
+ 0: B
+    *** Failers
+No match
+    abcde\nBar  
+No match
+
+/(.*X|^B)/ms
+    abcde\n1234Xyz
+ 0: abcde\x0a1234X
+    BarFoo 
+ 0: B
+    abcde\nBar  
+ 0: B
+
+/(?s)(.*X|^B)/
+    abcde\n1234Xyz
+ 0: abcde\x0a1234X
+    BarFoo 
+ 0: B
+    *** Failers 
+No match
+    abcde\nBar  
+No match
+
+/(?s:.*X|^B)/
+    abcde\n1234Xyz
+ 0: abcde\x0a1234X
+    BarFoo 
+ 0: B
+    *** Failers 
+No match
+    abcde\nBar  
+No match
+
+/^.*B/
+    **** Failers
+No match
+    abc\nB
+No match
+     
+/(?s)^.*B/
+    abc\nB
+ 0: abc\x0aB
+
+/(?m)^.*B/
+    abc\nB
+ 0: B
+     
+/(?ms)^.*B/
+    abc\nB
+ 0: abc\x0aB
+
+/(?ms)^B/
+    abc\nB
+ 0: B
+
+/(?s)B$/
+    B\n
+ 0: B
+
+/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
+    123456654321
+ 0: 123456654321
+  
+/^\d\d\d\d\d\d\d\d\d\d\d\d/
+    123456654321 
+ 0: 123456654321
+
+/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
+    123456654321
+ 0: 123456654321
+  
+/^[abc]{12}/
+    abcabcabcabc
+ 0: abcabcabcabc
+    
+/^[a-c]{12}/
+    abcabcabcabc
+ 0: abcabcabcabc
+    
+/^(a|b|c){12}/
+    abcabcabcabc 
+ 0: abcabcabcabc
+
+/^[abcdefghijklmnopqrstuvwxy0123456789]/
+    n
+ 0: n
+    *** Failers 
+No match
+    z 
+No match
+
+/abcde{0,0}/
+    abcd
+ 0: abcd
+    *** Failers
+No match
+    abce  
+No match
+
+/ab[cd]{0,0}e/
+    abe
+ 0: abe
+    *** Failers
+No match
+    abcde 
+No match
+    
+/ab(c){0,0}d/
+    abd
+ 0: abd
+    *** Failers
+No match
+    abcd   
+No match
+
+/a(b*)/
+    a
+ 0: a
+    ab
+ 0: ab
+ 1: a
+    abbbb
+ 0: abbbb
+ 1: abbb
+ 2: abb
+ 3: ab
+ 4: a
+    *** Failers
+ 0: a
+    bbbbb    
+No match
+    
+/ab\d{0}e/
+    abe
+ 0: abe
+    *** Failers
+No match
+    ab1e   
+No match
+    
+/"([^\\"]+|\\.)*"/
+    the \"quick\" brown fox
+ 0: "quick"
+    \"the \\\"quick\\\" brown fox\" 
+ 0: "the \"quick\" brown fox"
+
+/.*?/g+
+    abc
+ 0: abc
+ 0+ 
+ 1: ab
+ 2: a
+ 3: 
+ 0: 
+ 0+ 
+  
+/\b/g+
+    abc 
+ 0: 
+ 0+ abc
+ 0: 
+ 0+ 
+
+/\b/+g
+    abc 
+ 0: 
+ 0+ abc
+ 0: 
+ 0+ 
+
+//g
+    abc
+ 0: 
+ 0: 
+ 0: 
+ 0: 
+
+/<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/is
+  <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
+ 0: <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
+
+/a[^a]b/
+    acb
+ 0: acb
+    a\nb
+ 0: a\x0ab
+    
+/a.b/
+    acb
+ 0: acb
+    *** Failers 
+No match
+    a\nb   
+No match
+    
+/a[^a]b/s
+    acb
+ 0: acb
+    a\nb  
+ 0: a\x0ab
+    
+/a.b/s
+    acb
+ 0: acb
+    a\nb  
+ 0: a\x0ab
+
+/^(b+?|a){1,2}?c/
+    bac
+ 0: bac
+    bbac
+ 0: bbac
+    bbbac
+ 0: bbbac
+    bbbbac
+ 0: bbbbac
+    bbbbbac 
+ 0: bbbbbac
+
+/^(b+|a){1,2}?c/
+    bac
+ 0: bac
+    bbac
+ 0: bbac
+    bbbac
+ 0: bbbac
+    bbbbac
+ 0: bbbbac
+    bbbbbac 
+ 0: bbbbbac
+    
+/(?!\A)x/m
+    x\nb\n
+No match
+    a\bx\n  
+ 0: x
+    
+/\x0{ab}/
+    \0{ab} 
+ 0: \x00{ab}
+
+/(A|B)*?CD/
+    CD 
+ 0: CD
+    
+/(A|B)*CD/
+    CD 
+ 0: CD
+
+/(?<!bar)foo/
+    foo
+ 0: foo
+    catfood
+ 0: foo
+    arfootle
+ 0: foo
+    rfoosh
+ 0: foo
+    *** Failers
+No match
+    barfoo
+No match
+    towbarfoo
+No match
+
+/\w{3}(?<!bar)foo/
+    catfood
+ 0: catfoo
+    *** Failers
+No match
+    foo
+No match
+    barfoo
+No match
+    towbarfoo
+No match
+
+/(?<=(foo)a)bar/
+    fooabar
+ 0: bar
+    *** Failers
+No match
+    bar
+No match
+    foobbar
+No match
+      
+/\Aabc\z/m
+    abc
+ 0: abc
+    *** Failers
+No match
+    abc\n   
+No match
+    qqq\nabc
+No match
+    abc\nzzz
+No match
+    qqq\nabc\nzzz
+No match
+
+"(?>.*/)foo"
+    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
+No match
+
+"(?>.*/)foo"
+    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+ 0: /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
+
+/(?>(\.\d\d[1-9]?))\d+/
+    1.230003938
+ 0: .230003938
+ 1: .23000393
+ 2: .2300039
+ 3: .230003
+ 4: .23000
+ 5: .2300
+ 6: .230
+    1.875000282
+ 0: .875000282
+ 1: .87500028
+ 2: .8750002
+ 3: .875000
+ 4: .87500
+ 5: .8750
+    *** Failers 
+No match
+    1.235 
+No match
+
+/^((?>\w+)|(?>\s+))*$/
+    now is the time for all good men to come to the aid of the party
+ 0: now is the time for all good men to come to the aid of the party
+    *** Failers
+No match
+    this is not a line with only words and spaces!
+No match
+    
+/(\d+)(\w)/
+    12345a
+ 0: 12345a
+ 1: 12345
+ 2: 1234
+ 3: 123
+ 4: 12
+    12345+ 
+ 0: 12345
+ 1: 1234
+ 2: 123
+ 3: 12
+
+/((?>\d+))(\w)/
+    12345a
+ 0: 12345a
+    *** Failers
+No match
+    12345+ 
+No match
+
+/(?>a+)b/
+    aaab
+ 0: aaab
+
+/((?>a+)b)/
+    aaab
+ 0: aaab
+
+/(?>(a+))b/
+    aaab
+ 0: aaab
+
+/(?>b)+/
+    aaabbbccc
+ 0: bbb
+ 1: bb
+ 2: b
+
+/(?>a+|b+|c+)*c/
+    aaabbbbccccd
+ 0: aaabbbbcccc
+ 1: aaabbbbc
+    
+/(a+|b+|c+)*c/
+    aaabbbbccccd
+ 0: aaabbbbcccc
+ 1: aaabbbbccc
+ 2: aaabbbbcc
+ 3: aaabbbbc
+
+/((?>[^()]+)|\([^()]*\))+/
+    ((abc(ade)ufh()()x
+ 0: abc(ade)ufh()()x
+ 1: abc(ade)ufh()()
+ 2: abc(ade)ufh()
+ 3: abc(ade)ufh
+ 4: abc(ade)
+ 5: abc
+    
+/\(((?>[^()]+)|\([^()]+\))+\)/ 
+    (abc)
+ 0: (abc)
+    (abc(def)xyz)
+ 0: (abc(def)xyz)
+    *** Failers
+No match
+    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa   
+No match
+
+/a(?-i)b/i
+    ab
+ 0: ab
+    Ab
+ 0: Ab
+    *** Failers 
+No match
+    aB
+No match
+    AB
+No match
+        
+/(a (?x)b c)d e/
+    a bcd e
+ 0: a bcd e
+    *** Failers
+No match
+    a b cd e
+No match
+    abcd e   
+No match
+    a bcde 
+No match
+ 
+/(a b(?x)c d (?-x)e f)/
+    a bcde f
+ 0: a bcde f
+    *** Failers
+No match
+    abcdef  
+No match
+
+/(a(?i)b)c/
+    abc
+ 0: abc
+    aBc
+ 0: aBc
+    *** Failers
+No match
+    abC
+No match
+    aBC  
+No match
+    Abc
+No match
+    ABc
+No match
+    ABC
+No match
+    AbC
+No match
+    
+/a(?i:b)c/
+    abc
+ 0: abc
+    aBc
+ 0: aBc
+    *** Failers 
+No match
+    ABC
+No match
+    abC
+No match
+    aBC
+No match
+    
+/a(?i:b)*c/
+    aBc
+ 0: aBc
+    aBBc
+ 0: aBBc
+    *** Failers 
+No match
+    aBC
+No match
+    aBBC
+No match
+    
+/a(?=b(?i)c)\w\wd/
+    abcd
+ 0: abcd
+    abCd
+ 0: abCd
+    *** Failers
+No match
+    aBCd
+No match
+    abcD     
+No match
+    
+/(?s-i:more.*than).*million/i
+    more than million
+ 0: more than million
+    more than MILLION
+ 0: more than MILLION
+    more \n than Million 
+ 0: more \x0a than Million
+    *** Failers
+No match
+    MORE THAN MILLION    
+No match
+    more \n than \n million 
+No match
+
+/(?:(?s-i)more.*than).*million/i
+    more than million
+ 0: more than million
+    more than MILLION
+ 0: more than MILLION
+    more \n than Million 
+ 0: more \x0a than Million
+    *** Failers
+No match
+    MORE THAN MILLION    
+No match
+    more \n than \n million 
+No match
+    
+/(?>a(?i)b+)+c/ 
+    abc
+ 0: abc
+    aBbc
+ 0: aBbc
+    aBBc 
+ 0: aBBc
+    *** Failers
+No match
+    Abc
+No match
+    abAb    
+No match
+    abbC 
+No match
+    
+/(?=a(?i)b)\w\wc/
+    abc
+ 0: abc
+    aBc
+ 0: aBc
+    *** Failers
+No match
+    Ab 
+No match
+    abC
+No match
+    aBC     
+No match
+    
+/(?<=a(?i)b)(\w\w)c/
+    abxxc
+ 0: xxc
+    aBxxc
+ 0: xxc
+    *** Failers
+No match
+    Abxxc
+No match
+    ABxxc
+No match
+    abxxC      
+No match
+
+/^(?(?=abc)\w{3}:|\d\d)$/
+    abc:
+ 0: abc:
+    12
+ 0: 12
+    *** Failers
+No match
+    123
+No match
+    xyz    
+No match
+
+/^(?(?!abc)\d\d|\w{3}:)$/
+    abc:
+ 0: abc:
+    12
+ 0: 12
+    *** Failers
+No match
+    123
+No match
+    xyz    
+No match
+    
+/(?(?<=foo)bar|cat)/
+    foobar
+ 0: bar
+    cat
+ 0: cat
+    fcat
+ 0: cat
+    focat   
+ 0: cat
+    *** Failers
+No match
+    foocat  
+No match
+
+/(?(?<!foo)cat|bar)/
+    foobar
+ 0: bar
+    cat
+ 0: cat
+    fcat
+ 0: cat
+    focat   
+ 0: cat
+    *** Failers
+No match
+    foocat  
+No match
+
+/(?>a*)*/
+    a
+ 0: a
+ 1: 
+    aa
+ 0: aa
+ 1: 
+    aaaa
+ 0: aaaa
+ 1: 
+    
+/(abc|)+/
+    abc
+ 0: abc
+ 1: 
+    abcabc
+ 0: abcabc
+ 1: abc
+ 2: 
+    abcabcabc
+ 0: abcabcabc
+ 1: abcabc
+ 2: abc
+ 3: 
+    xyz      
+ 0: 
+
+/([a]*)*/
+    a
+ 0: a
+ 1: 
+    aaaaa 
+ 0: aaaaa
+ 1: aaaa
+ 2: aaa
+ 3: aa
+ 4: a
+ 5: 
+ 
+/([ab]*)*/
+    a
+ 0: a
+ 1: 
+    b
+ 0: b
+ 1: 
+    ababab
+ 0: ababab
+ 1: ababa
+ 2: abab
+ 3: aba
+ 4: ab
+ 5: a
+ 6: 
+    aaaabcde
+ 0: aaaab
+ 1: aaaa
+ 2: aaa
+ 3: aa
+ 4: a
+ 5: 
+    bbbb    
+ 0: bbbb
+ 1: bbb
+ 2: bb
+ 3: b
+ 4: 
+ 
+/([^a]*)*/
+    b
+ 0: b
+ 1: 
+    bbbb
+ 0: bbbb
+ 1: bbb
+ 2: bb
+ 3: b
+ 4: 
+    aaa   
+ 0: 
+ 
+/([^ab]*)*/
+    cccc
+ 0: cccc
+ 1: ccc
+ 2: cc
+ 3: c
+ 4: 
+    abab  
+ 0: 
+ 
+/([a]*?)*/
+    a
+ 0: a
+ 1: 
+    aaaa 
+ 0: aaaa
+ 1: aaa
+ 2: aa
+ 3: a
+ 4: 
+ 
+/([ab]*?)*/
+    a
+ 0: a
+ 1: 
+    b
+ 0: b
+ 1: 
+    abab
+ 0: abab
+ 1: aba
+ 2: ab
+ 3: a
+ 4: 
+    baba   
+ 0: baba
+ 1: bab
+ 2: ba
+ 3: b
+ 4: 
+ 
+/([^a]*?)*/
+    b
+ 0: b
+ 1: 
+    bbbb
+ 0: bbbb
+ 1: bbb
+ 2: bb
+ 3: b
+ 4: 
+    aaa   
+ 0: 
+ 
+/([^ab]*?)*/
+    c
+ 0: c
+ 1: 
+    cccc
+ 0: cccc
+ 1: ccc
+ 2: cc
+ 3: c
+ 4: 
+    baba   
+ 0: 
+ 
+/(?>a*)*/
+    a
+ 0: a
+ 1: 
+    aaabcde 
+ 0: aaa
+ 1: 
+ 
+/((?>a*))*/
+    aaaaa
+ 0: aaaaa
+ 1: 
+    aabbaa 
+ 0: aa
+ 1: 
+ 
+/((?>a*?))*/
+    aaaaa
+ 0: aaaaa
+ 1: 
+    aabbaa 
+ 0: aa
+ 1: 
+
+/(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /x
+    12-sep-98
+ 0: 12-sep-98
+    12-09-98
+ 0: 12-09-98
+    *** Failers
+No match
+    sep-12-98
+No match
+        
+/(?i:saturday|sunday)/
+    saturday
+ 0: saturday
+    sunday
+ 0: sunday
+    Saturday
+ 0: Saturday
+    Sunday
+ 0: Sunday
+    SATURDAY
+ 0: SATURDAY
+    SUNDAY
+ 0: SUNDAY
+    SunDay
+ 0: SunDay
+    
+/(a(?i)bc|BB)x/
+    abcx
+ 0: abcx
+    aBCx
+ 0: aBCx
+    bbx
+ 0: bbx
+    BBx
+ 0: BBx
+    *** Failers
+No match
+    abcX
+No match
+    aBCX
+No match
+    bbX
+No match
+    BBX               
+No match
+
+/^([ab](?i)[cd]|[ef])/
+    ac
+ 0: ac
+    aC
+ 0: aC
+    bD
+ 0: bD
+    elephant
+ 0: e
+    Europe 
+ 0: E
+    frog
+ 0: f
+    France
+ 0: F
+    *** Failers
+No match
+    Africa     
+No match
+
+/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
+    ab
+ 0: ab
+    aBd
+ 0: aBd
+    xy
+ 0: xy
+    xY
+ 0: xY
+    zebra
+ 0: z
+    Zambesi
+ 0: Z
+    *** Failers
+No match
+    aCD  
+No match
+    XY  
+No match
+
+/(?<=foo\n)^bar/m
+    foo\nbar
+ 0: bar
+    *** Failers
+No match
+    bar
+No match
+    baz\nbar   
+No match
+
+/(?<=(?<!foo)bar)baz/
+    barbaz
+ 0: baz
+    barbarbaz 
+ 0: baz
+    koobarbaz 
+ 0: baz
+    *** Failers
+No match
+    baz
+No match
+    foobarbaz 
+No match
+
+/The following tests are taken from the Perl 5.005 test suite; some of them/
+/are compatible with 5.004, but I'd rather not have to sort them out./
+No match
+
+/abc/
+    abc
+ 0: abc
+    xabcy
+ 0: abc
+    ababc
+ 0: abc
+    *** Failers
+No match
+    xbc
+No match
+    axc
+No match
+    abx
+No match
+
+/ab*c/
+    abc
+ 0: abc
+
+/ab*bc/
+    abc
+ 0: abc
+    abbc
+ 0: abbc
+    abbbbc
+ 0: abbbbc
+
+/.{1}/
+    abbbbc
+ 0: a
+
+/.{3,4}/
+    abbbbc
+ 0: abbb
+ 1: abb
+
+/ab{0,}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab+bc/
+    abbc
+ 0: abbc
+    *** Failers
+No match
+    abc
+No match
+    abq
+No match
+
+/ab{1,}bc/
+
+/ab+bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{1,}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{1,3}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{3,4}bc/
+    abbbbc
+ 0: abbbbc
+
+/ab{4,5}bc/
+    *** Failers
+No match
+    abq
+No match
+    abbbbc
+No match
+
+/ab?bc/
+    abbc
+ 0: abbc
+    abc
+ 0: abc
+
+/ab{0,1}bc/
+    abc
+ 0: abc
+
+/ab?bc/
+
+/ab?c/
+    abc
+ 0: abc
+
+/ab{0,1}c/
+    abc
+ 0: abc
+
+/^abc$/
+    abc
+ 0: abc
+    *** Failers
+No match
+    abbbbc
+No match
+    abcc
+No match
+
+/^abc/
+    abcc
+ 0: abc
+
+/^abc$/
+
+/abc$/
+    aabc
+ 0: abc
+    *** Failers
+No match
+    aabc
+ 0: abc
+    aabcd
+No match
+
+/^/
+    abc
+ 0: 
+
+/$/
+    abc
+ 0: 
+
+/a.c/
+    abc
+ 0: abc
+    axc
+ 0: axc
+
+/a.*c/
+    axyzc
+ 0: axyzc
+
+/a[bc]d/
+    abd
+ 0: abd
+    *** Failers
+No match
+    axyzd
+No match
+    abc
+No match
+
+/a[b-d]e/
+    ace
+ 0: ace
+
+/a[b-d]/
+    aac
+ 0: ac
+
+/a[-b]/
+    a-
+ 0: a-
+
+/a[b-]/
+    a-
+ 0: a-
+
+/a]/
+    a]
+ 0: a]
+
+/a[]]b/
+    a]b
+ 0: a]b
+
+/a[^bc]d/
+    aed
+ 0: aed
+    *** Failers
+No match
+    abd
+No match
+    abd
+No match
+
+/a[^-b]c/
+    adc
+ 0: adc
+
+/a[^]b]c/
+    adc
+ 0: adc
+    *** Failers
+No match
+    a-c
+ 0: a-c
+    a]c
+No match
+
+/\ba\b/
+    a-
+ 0: a
+    -a
+ 0: a
+    -a-
+ 0: a
+
+/\by\b/
+    *** Failers
+No match
+    xy
+No match
+    yz
+No match
+    xyz
+No match
+
+/\Ba\B/
+    *** Failers
+ 0: a
+    a-
+No match
+    -a
+No match
+    -a-
+No match
+
+/\By\b/
+    xy
+ 0: y
+
+/\by\B/
+    yz
+ 0: y
+
+/\By\B/
+    xyz
+ 0: y
+
+/\w/
+    a
+ 0: a
+
+/\W/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    a
+No match
+
+/a\sb/
+    a b
+ 0: a b
+
+/a\Sb/
+    a-b
+ 0: a-b
+    *** Failers
+No match
+    a-b
+ 0: a-b
+    a b
+No match
+
+/\d/
+    1
+ 0: 1
+
+/\D/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    1
+No match
+
+/[\w]/
+    a
+ 0: a
+
+/[\W]/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    a
+No match
+
+/a[\s]b/
+    a b
+ 0: a b
+
+/a[\S]b/
+    a-b
+ 0: a-b
+    *** Failers
+No match
+    a-b
+ 0: a-b
+    a b
+No match
+
+/[\d]/
+    1
+ 0: 1
+
+/[\D]/
+    -
+ 0: -
+    *** Failers
+ 0: *
+    -
+ 0: -
+    1
+No match
+
+/ab|cd/
+    abc
+ 0: ab
+    abcd
+ 0: ab
+
+/()ef/
+    def
+ 0: ef
+
+/$b/
+
+/a\(b/
+    a(b
+ 0: a(b
+
+/a\(*b/
+    ab
+ 0: ab
+    a((b
+ 0: a((b
+
+/a\\b/
+    a\b
+No match
+
+/((a))/
+    abc
+ 0: a
+
+/(a)b(c)/
+    abc
+ 0: abc
+
+/a+b+c/
+    aabbabc
+ 0: abc
+
+/a{1,}b{1,}c/
+    aabbabc
+ 0: abc
+
+/a.+?c/
+    abcabc
+ 0: abcabc
+ 1: abc
+
+/(a+|b)*/
+    ab
+ 0: ab
+ 1: a
+ 2: 
+
+/(a+|b){0,}/
+    ab
+ 0: ab
+ 1: a
+ 2: 
+
+/(a+|b)+/
+    ab
+ 0: ab
+ 1: a
+
+/(a+|b){1,}/
+    ab
+ 0: ab
+ 1: a
+
+/(a+|b)?/
+    ab
+ 0: a
+ 1: 
+
+/(a+|b){0,1}/
+    ab
+ 0: a
+ 1: 
+
+/[^ab]*/
+    cde
+ 0: cde
+ 1: cd
+ 2: c
+ 3: 
+
+/abc/
+    *** Failers
+No match
+    b
+No match
+    
+
+/a*/
+    
+
+/([abc])*d/
+    abbbcd
+ 0: abbbcd
+
+/([abc])*bcd/
+    abcd
+ 0: abcd
+
+/a|b|c|d|e/
+    e
+ 0: e
+
+/(a|b|c|d|e)f/
+    ef
+ 0: ef
+
+/abcd*efg/
+    abcdefg
+ 0: abcdefg
+
+/ab*/
+    xabyabbbz
+ 0: ab
+ 1: a
+    xayabbbz
+ 0: a
+
+/(ab|cd)e/
+    abcde
+ 0: cde
+
+/[abhgefdc]ij/
+    hij
+ 0: hij
+
+/^(ab|cd)e/
+
+/(abc|)ef/
+    abcdef
+ 0: ef
+
+/(a|b)c*d/
+    abcd
+ 0: bcd
+
+/(ab|ab*)bc/
+    abc
+ 0: abc
+
+/a([bc]*)c*/
+    abc
+ 0: abc
+ 1: ab
+ 2: a
+
+/a([bc]*)(c*d)/
+    abcd
+ 0: abcd
+
+/a([bc]+)(c*d)/
+    abcd
+ 0: abcd
+
+/a([bc]*)(c+d)/
+    abcd
+ 0: abcd
+
+/a[bcd]*dcdcde/
+    adcdcde
+ 0: adcdcde
+
+/a[bcd]+dcdcde/
+    *** Failers
+No match
+    abcde
+No match
+    adcdcde
+No match
+
+/(ab|a)b*c/
+    abc
+ 0: abc
+
+/((a)(b)c)(d)/
+    abcd
+ 0: abcd
+
+/[a-zA-Z_][a-zA-Z0-9_]*/
+    alpha
+ 0: alpha
+ 1: alph
+ 2: alp
+ 3: al
+ 4: a
+
+/^a(bc+|b[eh])g|.h$/
+    abh
+ 0: bh
+
+/(bc+d$|ef*g.|h?i(j|k))/
+    effgz
+ 0: effgz
+    ij
+ 0: ij
+    reffgz
+ 0: effgz
+    *** Failers
+No match
+    effg
+No match
+    bcdd
+No match
+
+/((((((((((a))))))))))/
+    a
+ 0: a
+
+/(((((((((a)))))))))/
+    a
+ 0: a
+
+/multiple words of text/
+    *** Failers
+No match
+    aa
+No match
+    uh-uh
+No match
+
+/multiple words/
+    multiple words, yeah
+ 0: multiple words
+
+/(.*)c(.*)/
+    abcde
+ 0: abcde
+ 1: abcd
+ 2: abc
+
+/\((.*), (.*)\)/
+    (a, b)
+ 0: (a, b)
+
+/[k]/
+
+/abcd/
+    abcd
+ 0: abcd
+
+/a(bc)d/
+    abcd
+ 0: abcd
+
+/a[-]?c/
+    ac
+ 0: ac
+
+/abc/i
+    ABC
+ 0: ABC
+    XABCY
+ 0: ABC
+    ABABC
+ 0: ABC
+    *** Failers
+No match
+    aaxabxbaxbbx
+No match
+    XBC
+No match
+    AXC
+No match
+    ABX
+No match
+
+/ab*c/i
+    ABC
+ 0: ABC
+
+/ab*bc/i
+    ABC
+ 0: ABC
+    ABBC
+ 0: ABBC
+
+/ab*?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{0,}?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab+?bc/i
+    ABBC
+ 0: ABBC
+
+/ab+bc/i
+    *** Failers
+No match
+    ABC
+No match
+    ABQ
+No match
+
+/ab{1,}bc/i
+
+/ab+bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{1,}?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{1,3}?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{3,4}?bc/i
+    ABBBBC
+ 0: ABBBBC
+
+/ab{4,5}?bc/i
+    *** Failers
+No match
+    ABQ
+No match
+    ABBBBC
+No match
+
+/ab??bc/i
+    ABBC
+ 0: ABBC
+    ABC
+ 0: ABC
+
+/ab{0,1}?bc/i
+    ABC
+ 0: ABC
+
+/ab??bc/i
+
+/ab??c/i
+    ABC
+ 0: ABC
+
+/ab{0,1}?c/i
+    ABC
+ 0: ABC
+
+/^abc$/i
+    ABC
+ 0: ABC
+    *** Failers
+No match
+    ABBBBC
+No match
+    ABCC
+No match
+
+/^abc/i
+    ABCC
+ 0: ABC
+
+/^abc$/i
+
+/abc$/i
+    AABC
+ 0: ABC
+
+/^/i
+    ABC
+ 0: 
+
+/$/i
+    ABC
+ 0: 
+
+/a.c/i
+    ABC
+ 0: ABC
+    AXC
+ 0: AXC
+
+/a.*?c/i
+    AXYZC
+ 0: AXYZC
+
+/a.*c/i
+    *** Failers
+No match
+    AABC
+ 0: AABC
+    AXYZD
+No match
+
+/a[bc]d/i
+    ABD
+ 0: ABD
+
+/a[b-d]e/i
+    ACE
+ 0: ACE
+    *** Failers
+No match
+    ABC
+No match
+    ABD
+No match
+
+/a[b-d]/i
+    AAC
+ 0: AC
+
+/a[-b]/i
+    A-
+ 0: A-
+
+/a[b-]/i
+    A-
+ 0: A-
+
+/a]/i
+    A]
+ 0: A]
+
+/a[]]b/i
+    A]B
+ 0: A]B
+
+/a[^bc]d/i
+    AED
+ 0: AED
+
+/a[^-b]c/i
+    ADC
+ 0: ADC
+    *** Failers
+No match
+    ABD
+No match
+    A-C
+No match
+
+/a[^]b]c/i
+    ADC
+ 0: ADC
+
+/ab|cd/i
+    ABC
+ 0: AB
+    ABCD
+ 0: AB
+
+/()ef/i
+    DEF
+ 0: EF
+
+/$b/i
+    *** Failers
+No match
+    A]C
+No match
+    B
+No match
+
+/a\(b/i
+    A(B
+ 0: A(B
+
+/a\(*b/i
+    AB
+ 0: AB
+    A((B
+ 0: A((B
+
+/a\\b/i
+    A\B
+No match
+
+/((a))/i
+    ABC
+ 0: A
+
+/(a)b(c)/i
+    ABC
+ 0: ABC
+
+/a+b+c/i
+    AABBABC
+ 0: ABC
+
+/a{1,}b{1,}c/i
+    AABBABC
+ 0: ABC
+
+/a.+?c/i
+    ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/a.*?c/i
+    ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/a.{0,5}?c/i
+    ABCABC
+ 0: ABCABC
+ 1: ABC
+
+/(a+|b)*/i
+    AB
+ 0: AB
+ 1: A
+ 2: 
+
+/(a+|b){0,}/i
+    AB
+ 0: AB
+ 1: A
+ 2: 
+
+/(a+|b)+/i
+    AB
+ 0: AB
+ 1: A
+
+/(a+|b){1,}/i
+    AB
+ 0: AB
+ 1: A
+
+/(a+|b)?/i
+    AB
+ 0: A
+ 1: 
+
+/(a+|b){0,1}/i
+    AB
+ 0: A
+ 1: 
+
+/(a+|b){0,1}?/i
+    AB
+ 0: A
+ 1: 
+
+/[^ab]*/i
+    CDE
+ 0: CDE
+ 1: CD
+ 2: C
+ 3: 
+
+/abc/i
+
+/a*/i
+    
+
+/([abc])*d/i
+    ABBBCD
+ 0: ABBBCD
+
+/([abc])*bcd/i
+    ABCD
+ 0: ABCD
+
+/a|b|c|d|e/i
+    E
+ 0: E
+
+/(a|b|c|d|e)f/i
+    EF
+ 0: EF
+
+/abcd*efg/i
+    ABCDEFG
+ 0: ABCDEFG
+
+/ab*/i
+    XABYABBBZ
+ 0: AB
+ 1: A
+    XAYABBBZ
+ 0: A
+
+/(ab|cd)e/i
+    ABCDE
+ 0: CDE
+
+/[abhgefdc]ij/i
+    HIJ
+ 0: HIJ
+
+/^(ab|cd)e/i
+    ABCDE
+No match
+
+/(abc|)ef/i
+    ABCDEF
+ 0: EF
+
+/(a|b)c*d/i
+    ABCD
+ 0: BCD
+
+/(ab|ab*)bc/i
+    ABC
+ 0: ABC
+
+/a([bc]*)c*/i
+    ABC
+ 0: ABC
+ 1: AB
+ 2: A
+
+/a([bc]*)(c*d)/i
+    ABCD
+ 0: ABCD
+
+/a([bc]+)(c*d)/i
+    ABCD
+ 0: ABCD
+
+/a([bc]*)(c+d)/i
+    ABCD
+ 0: ABCD
+
+/a[bcd]*dcdcde/i
+    ADCDCDE
+ 0: ADCDCDE
+
+/a[bcd]+dcdcde/i
+
+/(ab|a)b*c/i
+    ABC
+ 0: ABC
+
+/((a)(b)c)(d)/i
+    ABCD
+ 0: ABCD
+
+/[a-zA-Z_][a-zA-Z0-9_]*/i
+    ALPHA
+ 0: ALPHA
+ 1: ALPH
+ 2: ALP
+ 3: AL
+ 4: A
+
+/^a(bc+|b[eh])g|.h$/i
+    ABH
+ 0: BH
+
+/(bc+d$|ef*g.|h?i(j|k))/i
+    EFFGZ
+ 0: EFFGZ
+    IJ
+ 0: IJ
+    REFFGZ
+ 0: EFFGZ
+    *** Failers
+No match
+    ADCDCDE
+No match
+    EFFG
+No match
+    BCDD
+No match
+
+/((((((((((a))))))))))/i
+    A
+ 0: A
+
+/(((((((((a)))))))))/i
+    A
+ 0: A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
+    A
+ 0: A
+
+/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
+    C
+ 0: C
+
+/multiple words of text/i
+    *** Failers
+No match
+    AA
+No match
+    UH-UH
+No match
+
+/multiple words/i
+    MULTIPLE WORDS, YEAH
+ 0: MULTIPLE WORDS
+
+/(.*)c(.*)/i
+    ABCDE
+ 0: ABCDE
+ 1: ABCD
+ 2: ABC
+
+/\((.*), (.*)\)/i
+    (A, B)
+ 0: (A, B)
+
+/[k]/i
+
+/abcd/i
+    ABCD
+ 0: ABCD
+
+/a(bc)d/i
+    ABCD
+ 0: ABCD
+
+/a[-]?c/i
+    AC
+ 0: AC
+
+/a(?!b)./
+    abad
+ 0: ad
+
+/a(?=d)./
+    abad
+ 0: ad
+
+/a(?=c|d)./
+    abad
+ 0: ad
+
+/a(?:b|c|d)(.)/
+    ace
+ 0: ace
+
+/a(?:b|c|d)*(.)/
+    ace
+ 0: ace
+ 1: ac
+
+/a(?:b|c|d)+?(.)/
+    ace
+ 0: ace
+    acdbcdbe
+ 0: acdbcdbe
+ 1: acdbcdb
+ 2: acdbcd
+ 3: acdbc
+ 4: acdb
+ 5: acd
+
+/a(?:b|c|d)+(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: acdbcdb
+ 2: acdbcd
+ 3: acdbc
+ 4: acdb
+ 5: acd
+
+/a(?:b|c|d){2}(.)/
+    acdbcdbe
+ 0: acdb
+
+/a(?:b|c|d){4,5}(.)/
+    acdbcdbe
+ 0: acdbcdb
+ 1: acdbcd
+
+/a(?:b|c|d){4,5}?(.)/
+    acdbcdbe
+ 0: acdbcdb
+ 1: acdbcd
+
+/((foo)|(bar))*/
+    foobar
+ 0: foobar
+ 1: foo
+ 2: 
+
+/a(?:b|c|d){6,7}(.)/
+    acdbcdbe
+ 0: acdbcdbe
+
+/a(?:b|c|d){6,7}?(.)/
+    acdbcdbe
+ 0: acdbcdbe
+
+/a(?:b|c|d){5,6}(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: acdbcdb
+
+/a(?:b|c|d){5,6}?(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: acdbcdb
+
+/a(?:b|c|d){5,7}(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: acdbcdb
+
+/a(?:b|c|d){5,7}?(.)/
+    acdbcdbe
+ 0: acdbcdbe
+ 1: acdbcdb
+
+/a(?:b|(c|e){1,2}?|d)+?(.)/
+    ace
+ 0: ace
+
+/^(.+)?B/
+    AB
+ 0: AB
+
+/^([^a-z])|(\^)$/
+    .
+ 0: .
+
+/^[<>]&/
+    <&OUT
+ 0: <&
+
+/(?:(f)(o)(o)|(b)(a)(r))*/
+    foobar
+ 0: foobar
+ 1: foo
+ 2: 
+
+/(?<=a)b/
+    ab
+ 0: b
+    *** Failers
+No match
+    cb
+No match
+    b
+No match
+
+/(?<!c)b/
+    ab
+ 0: b
+    b
+ 0: b
+    b
+ 0: b
+
+/(?:..)*a/
+    aba
+ 0: aba
+ 1: a
+
+/(?:..)*?a/
+    aba
+ 0: aba
+ 1: a
+
+/^(){3,5}/
+    abc
+ 0: 
+
+/^(a+)*ax/
+    aax
+ 0: aax
+
+/^((a|b)+)*ax/
+    aax
+ 0: aax
+
+/^((a|bc)+)*ax/
+    aax
+ 0: aax
+
+/(a|x)*ab/
+    cab
+ 0: ab
+
+/(a)*ab/
+    cab
+ 0: ab
+
+/(?:(?i)a)b/
+    ab
+ 0: ab
+
+/((?i)a)b/
+    ab
+ 0: ab
+
+/(?:(?i)a)b/
+    Ab
+ 0: Ab
+
+/((?i)a)b/
+    Ab
+ 0: Ab
+
+/(?:(?i)a)b/
+    *** Failers
+No match
+    cb
+No match
+    aB
+No match
+
+/((?i)a)b/
+
+/(?i:a)b/
+    ab
+ 0: ab
+
+/((?i:a))b/
+    ab
+ 0: ab
+
+/(?i:a)b/
+    Ab
+ 0: Ab
+
+/((?i:a))b/
+    Ab
+ 0: Ab
+
+/(?i:a)b/
+    *** Failers
+No match
+    aB
+No match
+    aB
+No match
+
+/((?i:a))b/
+
+/(?:(?-i)a)b/i
+    ab
+ 0: ab
+
+/((?-i)a)b/i
+    ab
+ 0: ab
+
+/(?:(?-i)a)b/i
+    aB
+ 0: aB
+
+/((?-i)a)b/i
+    aB
+ 0: aB
+
+/(?:(?-i)a)b/i
+    *** Failers
+No match
+    aB
+ 0: aB
+    Ab
+No match
+
+/((?-i)a)b/i
+
+/(?:(?-i)a)b/i
+    aB
+ 0: aB
+
+/((?-i)a)b/i
+    aB
+ 0: aB
+
+/(?:(?-i)a)b/i
+    *** Failers
+No match
+    Ab
+No match
+    AB
+No match
+
+/((?-i)a)b/i
+
+/(?-i:a)b/i
+    ab
+ 0: ab
+
+/((?-i:a))b/i
+    ab
+ 0: ab
+
+/(?-i:a)b/i
+    aB
+ 0: aB
+
+/((?-i:a))b/i
+    aB
+ 0: aB
+
+/(?-i:a)b/i
+    *** Failers
+No match
+    AB
+No match
+    Ab
+No match
+
+/((?-i:a))b/i
+
+/(?-i:a)b/i
+    aB
+ 0: aB
+
+/((?-i:a))b/i
+    aB
+ 0: aB
+
+/(?-i:a)b/i
+    *** Failers
+No match
+    Ab
+No match
+    AB
+No match
+
+/((?-i:a))b/i
+
+/((?-i:a.))b/i
+    *** Failers
+No match
+    AB
+No match
+    a\nB
+No match
+
+/((?s-i:a.))b/i
+    a\nB
+ 0: a\x0aB
+
+/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
+    cabbbb
+ 0: cabbbb
+
+/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
+    caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ 0: caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+/foo\w*\d{4}baz/
+    foobar1234baz
+ 0: foobar1234baz
+
+/x(~~)*(?:(?:F)?)?/
+    x~~
+ 0: x~~
+ 1: x
+
+/^a(?#xxx){3}c/
+    aaac
+ 0: aaac
+
+/^a (?#xxx) (?#yyy) {3}c/x
+    aaac
+ 0: aaac
+
+/(?<![cd])b/
+    *** Failers
+No match
+    B\nB
+No match
+    dbcb
+No match
+
+/(?<![cd])[ab]/
+    dbaacb
+ 0: a
+
+/(?<!(c|d))b/
+
+/(?<!(c|d))[ab]/
+    dbaacb
+ 0: a
+
+/(?<!cd)[ab]/
+    cdaccb
+ 0: b
+
+/^(?:a?b?)*$/
+    *** Failers
+No match
+    dbcb
+No match
+    a--
+No match
+
+/((?s)^a(.))((?m)^b$)/
+    a\nb\nc\n
+ 0: a\x0ab
+
+/((?m)^b$)/
+    a\nb\nc\n
+ 0: b
+
+/(?m)^b/
+    a\nb\n
+ 0: b
+
+/(?m)^(b)/
+    a\nb\n
+ 0: b
+
+/((?m)^b)/
+    a\nb\n
+ 0: b
+
+/\n((?m)^b)/
+    a\nb\n
+ 0: \x0ab
+
+/((?s).)c(?!.)/
+    a\nb\nc\n
+ 0: \x0ac
+    a\nb\nc\n
+ 0: \x0ac
+
+/((?s)b.)c(?!.)/
+    a\nb\nc\n
+ 0: b\x0ac
+    a\nb\nc\n
+ 0: b\x0ac
+
+/^b/
+
+/()^b/
+    *** Failers
+No match
+    a\nb\nc\n
+No match
+    a\nb\nc\n
+No match
+
+/((?m)^b)/
+    a\nb\nc\n
+ 0: b
+
+/(?(?!a)a|b)/
+
+/(?(?!a)b|a)/
+    a
+ 0: a
+
+/(?(?=a)b|a)/
+    *** Failers
+No match
+    a
+No match
+    a
+No match
+
+/(?(?=a)a|b)/
+    a
+ 0: a
+
+/(\w+:)+/
+    one:
+ 0: one:
+
+/$(?<=^(a))/
+    a
+ 0: 
+
+/([\w:]+::)?(\w+)$/
+    abcd
+ 0: abcd
+    xy:z:::abcd
+ 0: xy:z:::abcd
+
+/^[^bcd]*(c+)/
+    aexycd
+ 0: aexyc
+
+/(a*)b+/
+    caab
+ 0: aab
+
+/([\w:]+::)?(\w+)$/
+    abcd
+ 0: abcd
+    xy:z:::abcd
+ 0: xy:z:::abcd
+    *** Failers
+ 0: Failers
+    abcd:
+No match
+    abcd:
+No match
+
+/^[^bcd]*(c+)/
+    aexycd
+ 0: aexyc
+
+/(>a+)ab/
+
+/(?>a+)b/
+    aaab
+ 0: aaab
+
+/([[:]+)/
+    a:[b]:
+ 0: :[
+ 1: :
+
+/([[=]+)/
+    a=[b]=
+ 0: =[
+ 1: =
+
+/([[.]+)/
+    a.[b].
+ 0: .[
+ 1: .
+
+/((?>a+)b)/
+    aaab
+ 0: aaab
+
+/(?>(a+))b/
+    aaab
+ 0: aaab
+
+/((?>[^()]+)|\([^()]*\))+/
+    ((abc(ade)ufh()()x
+ 0: abc(ade)ufh()()x
+ 1: abc(ade)ufh()()
+ 2: abc(ade)ufh()
+ 3: abc(ade)ufh
+ 4: abc(ade)
+ 5: abc
+
+/a\Z/
+    *** Failers
+No match
+    aaab
+No match
+    a\nb\n
+No match
+
+/b\Z/
+    a\nb\n
+ 0: b
+
+/b\z/
+
+/b\Z/
+    a\nb
+ 0: b
+
+/b\z/
+    a\nb
+ 0: b
+    *** Failers
+No match
+    
+/(?>.*)(?<=(abcd|wxyz))/
+    alphabetabcd
+ 0: alphabetabcd
+    endingwxyz
+ 0: endingwxyz
+    *** Failers
+No match
+    a rather long string that doesn't end with one of them
+No match
+
+/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
+    word cat dog elephant mussel cow horse canary baboon snake shark otherword
+ 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
+    word cat dog elephant mussel cow horse canary baboon snake shark
+No match
+  
+/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
+    word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
+No match
+
+/(?<=\d{3}(?!999))foo/
+    999foo
+ 0: foo
+    123999foo 
+ 0: foo
+    *** Failers
+No match
+    123abcfoo
+No match
+    
+/(?<=(?!...999)\d{3})foo/
+    999foo
+ 0: foo
+    123999foo 
+ 0: foo
+    *** Failers
+No match
+    123abcfoo
+No match
+
+/(?<=\d{3}(?!999)...)foo/
+    123abcfoo
+ 0: foo
+    123456foo 
+ 0: foo
+    *** Failers
+No match
+    123999foo  
+No match
+    
+/(?<=\d{3}...)(?<!999)foo/
+    123abcfoo   
+ 0: foo
+    123456foo 
+ 0: foo
+    *** Failers
+No match
+    123999foo  
+No match
+
+/((Z)+|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: Z
+ 2: 
+
+/(Z()|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: Z
+ 2: 
+
+/(Z(())|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: Z
+ 2: 
+
+/((?>Z)+|A)*/
+    ZABCDEFG
+ 0: ZA
+ 1: Z
+ 2: 
+
+/((?>)+|A)*/
+    ZABCDEFG
+ 0: 
+
+/a*/g
+    abbab
+ 0: a
+ 1: 
+ 0: 
+ 0: 
+ 0: a
+ 1: 
+ 0: 
+ 0: 
+
+/^[a-\d]/
+    abcde
+ 0: a
+    -things
+ 0: -
+    0digit
+ 0: 0
+    *** Failers
+No match
+    bcdef    
+No match
+
+/^[\d-a]/
+    abcde
+ 0: a
+    -things
+ 0: -
+    0digit
+ 0: 0
+    *** Failers
+No match
+    bcdef    
+No match
+    
+/[[:space:]]+/
+    > \x09\x0a\x0c\x0d\x0b<
+ 0:  \x09\x0a\x0c\x0d\x0b
+ 1:  \x09\x0a\x0c\x0d
+ 2:  \x09\x0a\x0c
+ 3:  \x09\x0a
+ 4:  \x09
+ 5:  
+     
+/[[:blank:]]+/
+    > \x09\x0a\x0c\x0d\x0b<
+ 0:  \x09
+ 1:  
+     
+/[\s]+/
+    > \x09\x0a\x0c\x0d\x0b<
+ 0:  \x09\x0a\x0c\x0d
+ 1:  \x09\x0a\x0c
+ 2:  \x09\x0a
+ 3:  \x09
+ 4:  
+     
+/\s+/
+    > \x09\x0a\x0c\x0d\x0b<
+ 0:  \x09\x0a\x0c\x0d
+ 1:  \x09\x0a\x0c
+ 2:  \x09\x0a
+ 3:  \x09
+ 4:  
+     
+/ab/x
+    ab
+No match
+
+/(?!\A)x/m
+  a\nxb\n
+ 0: x
+
+/(?!^)x/m
+  a\nxb\n
+No match
+
+/abc\Qabc\Eabc/
+    abcabcabc
+ 0: abcabcabc
+    
+/abc\Q(*+|\Eabc/
+    abc(*+|abc 
+ 0: abc(*+|abc
+
+/   abc\Q abc\Eabc/x
+    abc abcabc
+ 0: abc abcabc
+    *** Failers
+No match
+    abcabcabc  
+No match
+    
+/abc#comment
+    \Q#not comment
+    literal\E/x
+    abc#not comment\n    literal     
+ 0: abc#not comment\x0a    literal
+
+/abc#comment
+    \Q#not comment
+    literal/x
+    abc#not comment\n    literal     
+ 0: abc#not comment\x0a    literal
+
+/abc#comment
+    \Q#not comment
+    literal\E #more comment
+    /x
+    abc#not comment\n    literal     
+ 0: abc#not comment\x0a    literal
+
+/abc#comment
+    \Q#not comment
+    literal\E #more comment/x
+    abc#not comment\n    literal     
+ 0: abc#not comment\x0a    literal
+
+/\Qabc\$xyz\E/
+    abc\\\$xyz
+ 0: abc\$xyz
+
+/\Qabc\E\$\Qxyz\E/
+    abc\$xyz
+ 0: abc$xyz
+
+/\Gabc/
+    abc
+ 0: abc
+    *** Failers
+No match
+    xyzabc  
+No match
+
+/\Gabc./g
+    abc1abc2xyzabc3
+ 0: abc1
+ 0: abc2
+
+/abc./g
+    abc1abc2xyzabc3 
+ 0: abc1
+ 0: abc2
+ 0: abc3
+
+/a(?x: b c )d/
+    XabcdY
+ 0: abcd
+    *** Failers 
+No match
+    Xa b c d Y 
+No match
+
+/((?x)x y z | a b c)/
+    XabcY
+ 0: abc
+    AxyzB 
+ 0: xyz
+
+/(?i)AB(?-i)C/
+    XabCY
+ 0: abC
+    *** Failers
+No match
+    XabcY  
+No match
+
+/((?i)AB(?-i)C|D)E/
+    abCE
+ 0: abCE
+    DE
+ 0: DE
+    *** Failers
+No match
+    abcE
+No match
+    abCe  
+No match
+    dE
+No match
+    De    
+No match
+
+/[z\Qa-d]\E]/
+    z
+ 0: z
+    a
+ 0: a
+    -
+ 0: -
+    d
+ 0: d
+    ] 
+ 0: ]
+    *** Failers
+ 0: a
+    b     
+No match
+
+/[\z\C]/
+    z
+ 0: z
+    C 
+ 0: C
+    
+/\M/
+    M 
+ 0: M
+    
+/(a+)*b/
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
+No match
+    
+/(?i)reg(?:ul(?:[aä]|ae)r|ex)/
+    REGular
+ 0: REGular
+    regulaer
+ 0: regulaer
+    Regex  
+ 0: Regex
+    regulär 
+ 0: regul\xe4r
+
+/Åæåä[à-ÿÀ-ß]+/
+    Åæåäà
+ 0: \xc5\xe6\xe5\xe4\xe0
+    Åæåäÿ
+ 0: \xc5\xe6\xe5\xe4\xff
+    ÅæåäÀ
+ 0: \xc5\xe6\xe5\xe4\xc0
+    Åæåäß
+ 0: \xc5\xe6\xe5\xe4\xdf
+
+/(?<=Z)X./
+    \x84XAZXB
+ 0: XB
+
+/^(?(2)a|(1)(2))+$/
+    123a
+Error -17
+
+/(?<=a|bbbb)c/
+    ac
+ 0: c
+    bbbbc
+ 0: c
+
+/abc/>testsavedregex
+Compiled regex written to testsavedregex
+<testsavedregex
+Compiled regex loaded from testsavedregex
+No study data
+    abc
+ 0: abc
+    *** Failers
+No match
+    bca
+No match
+    
+/abc/F>testsavedregex
+Compiled regex written to testsavedregex
+<testsavedregex
+Compiled regex (byte-inverted) loaded from testsavedregex
+No study data
+    abc
+ 0: abc
+    *** Failers
+No match
+    bca
+No match
+
+/(a|b)/S>testsavedregex
+Compiled regex written to testsavedregex
+Study data written to testsavedregex
+<testsavedregex
+Compiled regex loaded from testsavedregex
+Study data loaded from testsavedregex
+    abc
+ 0: a
+    *** Failers
+ 0: a
+    def  
+No match
+    
+/(a|b)/SF>testsavedregex
+Compiled regex written to testsavedregex
+Study data written to testsavedregex
+<testsavedregex
+Compiled regex (byte-inverted) loaded from testsavedregex
+Study data loaded from testsavedregex
+    abc
+ 0: a
+    *** Failers
+ 0: a
+    def  
+No match
+    
+/line\nbreak/
+    this is a line\nbreak
+ 0: line\x0abreak
+    line one\nthis is a line\nbreak in the second line 
+ 0: line\x0abreak
+
+/line\nbreak/f
+    this is a line\nbreak
+ 0: line\x0abreak
+    ** Failers 
+No match
+    line one\nthis is a line\nbreak in the second line 
+No match
+
+/line\nbreak/mf
+    this is a line\nbreak
+ 0: line\x0abreak
+    ** Failers 
+No match
+    line one\nthis is a line\nbreak in the second line 
+No match
+
+/1234/
+    123\P
+Partial match: 123
+    a4\P\R
+No match
+
+/1234/
+    123\P
+Partial match: 123
+    4\P\R
+ 0: 4
+
+/^/mg
+    a\nb\nc\n
+ 0: 
+ 0: 
+ 0: 
+    \ 
+ 0: 
+    
+/(?<=C\n)^/mg
+    A\nC\nC\n 
+ 0: 
+
+/(?s)A?B/
+    AB
+ 0: AB
+    aB  
+ 0: B
+
+/(?s)A*B/
+    AB
+ 0: AB
+    aB  
+ 0: B
+
+/(?m)A?B/
+    AB
+ 0: AB
+    aB  
+ 0: B
+
+/(?m)A*B/
+    AB
+ 0: AB
+    aB  
+ 0: B
+
+/Content-Type\x3A[^\r\n]{6,}/
+    Content-Type:xxxxxyyy 
+ 0: Content-Type:xxxxxyyy
+ 1: Content-Type:xxxxxyy
+ 2: Content-Type:xxxxxy
+
+/Content-Type\x3A[^\r\n]{6,}z/
+    Content-Type:xxxxxyyyz
+ 0: Content-Type:xxxxxyyyz
+
+/Content-Type\x3A[^a]{6,}/
+    Content-Type:xxxyyy 
+ 0: Content-Type:xxxyyy
+
+/Content-Type\x3A[^a]{6,}z/
+    Content-Type:xxxyyyz
+ 0: Content-Type:xxxyyyz
+
+/^abc/m
+    xyz\nabc
+ 0: abc
+    xyz\nabc\<lf>
+ 0: abc
+    xyz\r\nabc\<lf>
+ 0: abc
+    xyz\rabc\<cr>
+ 0: abc
+    xyz\r\nabc\<crlf>
+ 0: abc
+    ** Failers 
+No match
+    xyz\nabc\<cr>
+No match
+    xyz\r\nabc\<cr>
+No match
+    xyz\nabc\<crlf>
+No match
+    xyz\rabc\<crlf>
+No match
+    xyz\rabc\<lf>
+No match
+    
+/abc$/m<lf>
+    xyzabc
+ 0: abc
+    xyzabc\n 
+ 0: abc
+    xyzabc\npqr 
+ 0: abc
+    xyzabc\r\<cr> 
+ 0: abc
+    xyzabc\rpqr\<cr> 
+ 0: abc
+    xyzabc\r\n\<crlf> 
+ 0: abc
+    xyzabc\r\npqr\<crlf> 
+ 0: abc
+    ** Failers
+No match
+    xyzabc\r 
+No match
+    xyzabc\rpqr 
+No match
+    xyzabc\r\n 
+No match
+    xyzabc\r\npqr 
+No match
+    
+/^abc/m<cr>
+    xyz\rabcdef
+ 0: abc
+    xyz\nabcdef\<lf>
+ 0: abc
+    ** Failers  
+No match
+    xyz\nabcdef
+No match
+       
+/^abc/m<lf>
+    xyz\nabcdef
+ 0: abc
+    xyz\rabcdef\<cr>
+ 0: abc
+    ** Failers  
+No match
+    xyz\rabcdef
+No match
+       
+/^abc/m<crlf>
+    xyz\r\nabcdef
+ 0: abc
+    xyz\rabcdef\<cr>
+ 0: abc
+    ** Failers  
+No match
+    xyz\rabcdef
+No match
+    
+/.*/<lf>
+    abc\ndef
+ 0: abc
+ 1: ab
+ 2: a
+ 3: 
+    abc\rdef
+ 0: abc\x0ddef
+ 1: abc\x0dde
+ 2: abc\x0dd
+ 3: abc\x0d
+ 4: abc
+ 5: ab
+ 6: a
+ 7: 
+    abc\r\ndef
+ 0: abc\x0d
+ 1: abc
+ 2: ab
+ 3: a
+ 4: 
+    \<cr>abc\ndef
+ 0: abc\x0adef
+ 1: abc\x0ade
+ 2: abc\x0ad
+ 3: abc\x0a
+ 4: abc
+ 5: ab
+ 6: a
+ 7: 
+    \<cr>abc\rdef
+ 0: abc
+ 1: ab
+ 2: a
+ 3: 
+    \<cr>abc\r\ndef
+ 0: abc
+ 1: ab
+ 2: a
+ 3: 
+    \<crlf>abc\ndef
+ 0: abc\x0adef
+ 1: abc\x0ade
+ 2: abc\x0ad
+ 3: abc\x0a
+ 4: abc
+ 5: ab
+ 6: a
+ 7: 
+    \<crlf>abc\rdef
+ 0: abc\x0ddef
+ 1: abc\x0dde
+ 2: abc\x0dd
+ 3: abc\x0d
+ 4: abc
+ 5: ab
+ 6: a
+ 7: 
+    \<crlf>abc\r\ndef
+ 0: abc
+ 1: ab
+ 2: a
+ 3: 
+
+/\w+(.)(.)?def/s
+    abc\ndef
+ 0: abc\x0adef
+    abc\rdef
+ 0: abc\x0ddef
+    abc\r\ndef
+ 0: abc\x0d\x0adef
+
+/^\w+=.*(\\\n.*)*/
+    abc=xyz\\\npqr
+ 0: abc=xyz\\x0apqr
+ 1: abc=xyz\\x0apq
+ 2: abc=xyz\\x0ap
+ 3: abc=xyz\\x0a
+ 4: abc=xyz\
+ 5: abc=xyz
+ 6: abc=xy
+ 7: abc=x
+ 8: abc=
+
+/^(a()*)*/
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+ 3: a
+ 4: 
+
+/^(?:a(?:(?:))*)*/
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+ 3: a
+ 4: 
+
+/^(a()+)+/
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+ 3: a
+
+/^(?:a(?:(?:))+)+/
+    aaaa
+ 0: aaaa
+ 1: aaa
+ 2: aa
+ 3: a
+
+/(a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/(?>a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/(?:a|)*\d/
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+No match
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
+
+/^a.b/<lf>
+    a\rb
+ 0: a\x0db
+    a\nb\<cr> 
+ 0: a\x0ab
+    ** Failers
+No match
+    a\nb
+No match
+    a\nb\<any>
+No match
+    a\rb\<cr>   
+No match
+    a\rb\<any>   
+No match
+
+/^abc./mgx<any>
+    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x85abc7 JUNK
+ 0: abc1
+ 0: abc2
+ 0: abc3
+ 0: abc4
+ 0: abc5
+ 0: abc6
+ 0: abc7
+
+/abc.$/mgx<any>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc9
+ 0: abc1
+ 0: abc2
+ 0: abc3
+ 0: abc4
+ 0: abc5
+ 0: abc6
+ 0: abc9
+
+/^a\Rb/<bsr_unicode>
+    a\nb
+ 0: a\x0ab
+    a\rb
+ 0: a\x0db
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x0bb
+ 0: a\x0bb
+    a\x0cb
+ 0: a\x0cb
+    a\x85b   
+ 0: a\x85b
+    ** Failers
+No match
+    a\n\rb    
+No match
+
+/^a\R*b/<bsr_unicode>
+    ab
+ 0: ab
+    a\nb
+ 0: a\x0ab
+    a\rb
+ 0: a\x0db
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x0bb
+ 0: a\x0bb
+    a\x0cb
+ 0: a\x0cb
+    a\x85b   
+ 0: a\x85b
+    a\n\rb    
+ 0: a\x0a\x0db
+    a\n\r\x85\x0cb 
+ 0: a\x0a\x0d\x85\x0cb
+
+/^a\R+b/<bsr_unicode>
+    a\nb
+ 0: a\x0ab
+    a\rb
+ 0: a\x0db
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x0bb
+ 0: a\x0bb
+    a\x0cb
+ 0: a\x0cb
+    a\x85b   
+ 0: a\x85b
+    a\n\rb    
+ 0: a\x0a\x0db
+    a\n\r\x85\x0cb 
+ 0: a\x0a\x0d\x85\x0cb
+    ** Failers
+No match
+    ab  
+No match
+    
+/^a\R{1,3}b/<bsr_unicode>
+    a\nb
+ 0: a\x0ab
+    a\n\rb
+ 0: a\x0a\x0db
+    a\n\r\x85b
+ 0: a\x0a\x0d\x85b
+    a\r\n\r\nb 
+ 0: a\x0d\x0a\x0d\x0ab
+    a\r\n\r\n\r\nb 
+ 0: a\x0d\x0a\x0d\x0a\x0d\x0ab
+    a\n\r\n\rb
+ 0: a\x0a\x0d\x0a\x0db
+    a\n\n\r\nb 
+ 0: a\x0a\x0a\x0d\x0ab
+    ** Failers
+No match
+    a\n\n\n\rb
+No match
+    a\r
+No match
+
+/^a[\R]b/<bsr_unicode>
+    aRb
+ 0: aRb
+    ** Failers
+No match
+    a\nb  
+No match
+
+/.+foo/
+    afoo
+ 0: afoo
+    ** Failers 
+No match
+    \r\nfoo 
+No match
+    \nfoo 
+No match
+
+/.+foo/<crlf>
+    afoo
+ 0: afoo
+    \nfoo 
+ 0: \x0afoo
+    ** Failers 
+No match
+    \r\nfoo 
+No match
+
+/.+foo/<any>
+    afoo
+ 0: afoo
+    ** Failers 
+No match
+    \nfoo 
+No match
+    \r\nfoo 
+No match
+
+/.+foo/s
+    afoo
+ 0: afoo
+    \r\nfoo 
+ 0: \x0d\x0afoo
+    \nfoo 
+ 0: \x0afoo
+
+/^$/mg<any>
+    abc\r\rxyz
+ 0: 
+    abc\n\rxyz  
+ 0: 
+    ** Failers 
+No match
+    abc\r\nxyz
+No match
+
+/^X/m
+    XABC
+ 0: X
+    ** Failers 
+No match
+    XABC\B
+No match
+
+/(?m)^$/<any>g+
+    abc\r\n\r\n
+ 0: 
+ 0+ \x0d\x0a
+
+/(?m)^$|^\r\n/<any>g+ 
+    abc\r\n\r\n
+ 0: \x0d\x0a
+ 0+ 
+ 1: 
+    
+/(?m)$/<any>g+ 
+    abc\r\n\r\n
+ 0: 
+ 0+ \x0d\x0a\x0d\x0a
+ 0: 
+ 0+ \x0d\x0a
+ 0: 
+ 0+ 
+
+/(?|(abc)|(xyz))/
+   >abc<
+ 0: abc
+   >xyz< 
+ 0: xyz
+
+/(x)(?|(abc)|(xyz))(x)/
+    xabcx
+ 0: xabcx
+    xxyzx 
+ 0: xxyzx
+
+/(x)(?|(abc)(pqr)|(xyz))(x)/
+    xabcpqrx
+ 0: xabcpqrx
+    xxyzx 
+ 0: xxyzx
+
+/(?|(abc)|(xyz))(?1)/
+    abcabc
+ 0: abcabc
+    xyzabc 
+ 0: xyzabc
+    ** Failers 
+No match
+    xyzxyz 
+No match
+ 
+/\H\h\V\v/
+    X X\x0a
+ 0: X X\x0a
+    X\x09X\x0b
+ 0: X\x09X\x0b
+    ** Failers
+No match
+    \xa0 X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/ 
+    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0X\x0a\x0b\x0c\x0d
+ 1: \x09 \xa0X\x0a\x0b\x0c
+    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
+ 0: \x09 \xa0\x0a\x0b\x0c\x0d
+ 1: \x09 \xa0\x0a\x0b\x0c
+    \x09\x20\xa0\x0a\x0b\x0c
+ 0: \x09 \xa0\x0a\x0b\x0c
+    ** Failers 
+No match
+    \x09\x20\xa0\x0a\x0b
+No match
+     
+/\H{3,4}/
+    XY  ABCDE
+ 0: ABCD
+ 1: ABC
+    XY  PQR ST 
+ 0: PQR
+    
+/.\h{3,4}./
+    XY  AB    PQRS
+ 0: B    P
+ 1: B    
+
+/\h*X\h?\H+Y\H?Z/
+    >XNNNYZ
+ 0: XNNNYZ
+    >  X NYQZ
+ 0:   X NYQZ
+    ** Failers
+No match
+    >XYZ   
+No match
+    >  X NY Z
+No match
+
+/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
+    >XY\x0aZ\x0aA\x0bNN\x0c
+ 0: XY\x0aZ\x0aA\x0bNN\x0c
+    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+ 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
+
+/.+A/<crlf>
+    \r\nA
+No match
+    
+/\nA/<crlf>
+    \r\nA 
+ 0: \x0aA
+
+/[\r\n]A/<crlf>
+    \r\nA 
+ 0: \x0aA
+
+/(\r|\n)A/<crlf>
+    \r\nA 
+ 0: \x0aA
+
+/a\Rb/I<bsr_anycrlf>
+Capturing subpattern count = 0
+Options: bsr_anycrlf
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x0db
+    a\nb
+ 0: a\x0ab
+    a\r\nb
+ 0: a\x0d\x0ab
+    ** Failers
+No match
+    a\x85b
+No match
+    a\x0bb     
+No match
+
+/a\Rb/I<bsr_unicode>
+Capturing subpattern count = 0
+Options: bsr_unicode
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x0db
+    a\nb
+ 0: a\x0ab
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x85b
+ 0: a\x85b
+    a\x0bb     
+ 0: a\x0bb
+    ** Failers 
+No match
+    a\x85b\<bsr_anycrlf>
+No match
+    a\x0bb\<bsr_anycrlf>
+No match
+    
+/a\R?b/I<bsr_anycrlf>
+Capturing subpattern count = 0
+Options: bsr_anycrlf
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x0db
+    a\nb
+ 0: a\x0ab
+    a\r\nb
+ 0: a\x0d\x0ab
+    ** Failers
+No match
+    a\x85b
+No match
+    a\x0bb     
+No match
+
+/a\R?b/I<bsr_unicode>
+Capturing subpattern count = 0
+Options: bsr_unicode
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x0db
+    a\nb
+ 0: a\x0ab
+    a\r\nb
+ 0: a\x0d\x0ab
+    a\x85b
+ 0: a\x85b
+    a\x0bb     
+ 0: a\x0bb
+    ** Failers 
+No match
+    a\x85b\<bsr_anycrlf>
+No match
+    a\x0bb\<bsr_anycrlf>
+No match
+    
+/a\R{2,4}b/I<bsr_anycrlf>
+Capturing subpattern count = 0
+Partial matching not supported
+Options: bsr_anycrlf
+First char = 'a'
+Need char = 'b'
+    a\r\n\nb
+ 0: a\x0d\x0a\x0ab
+    a\n\r\rb
+ 0: a\x0a\x0d\x0db
+    a\r\n\r\n\r\n\r\nb
+ 0: a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0ab
+    ** Failers
+No match
+    a\x85\85b
+No match
+    a\x0b\0bb     
+No match
+
+/a\R{2,4}b/I<bsr_unicode>
+Capturing subpattern count = 0
+Partial matching not supported
+Options: bsr_unicode
+First char = 'a'
+Need char = 'b'
+    a\r\rb
+ 0: a\x0d\x0db
+    a\n\n\nb
+ 0: a\x0a\x0a\x0ab
+    a\r\n\n\r\rb
+ 0: a\x0d\x0a\x0a\x0d\x0db
+    a\x85\85b
+No match
+    a\x0b\0bb     
+No match
+    ** Failers 
+No match
+    a\r\r\r\r\rb 
+No match
+    a\x85\85b\<bsr_anycrlf>
+No match
+    a\x0b\0bb\<bsr_anycrlf>
+No match
+    
+/a(?!)|\wbc/
+    abc 
+ 0: abc
+
+/a[]b/<JS>
+    ** Failers
+No match
+    ab
+No match
+
+/a[]+b/<JS>
+    ** Failers
+No match
+    ab 
+No match
+
+/a[]*+b/<JS>
+    ** Failers
+No match
+    ab 
+No match
+
+/a[^]b/<JS>
+    aXb
+ 0: aXb
+    a\nb 
+ 0: a\x0ab
+    ** Failers
+No match
+    ab  
+No match
+    
+/a[^]+b/<JS> 
+    aXb
+ 0: aXb
+    a\nX\nXb 
+ 0: a\x0aX\x0aXb
+    ** Failers
+No match
+    ab  
+No match
+
+/ End of testinput7 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput8	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1291 @@
+/-- Do not use the \x{} construct except with patterns that have the --/
+/-- /8 option set, because PCRE doesn't recognize them as UTF-8 unless --/
+No match
+/-- that option is set. However, the latest Perls recognize them always. --/
+No match
+
+/\x{100}ab/8
+  \x{100}ab
+ 0: \x{100}ab
+  
+/a\x{100}*b/8
+    ab
+ 0: ab
+    a\x{100}b  
+ 0: a\x{100}b
+    a\x{100}\x{100}b  
+ 0: a\x{100}\x{100}b
+    
+/a\x{100}+b/8
+    a\x{100}b  
+ 0: a\x{100}b
+    a\x{100}\x{100}b  
+ 0: a\x{100}\x{100}b
+    *** Failers 
+No match
+    ab
+No match
+     
+/\bX/8
+    Xoanon
+ 0: X
+    +Xoanon
+ 0: X
+    \x{300}Xoanon 
+ 0: X
+    *** Failers 
+No match
+    YXoanon  
+No match
+    
+/\BX/8
+    YXoanon
+ 0: X
+    *** Failers
+No match
+    Xoanon
+No match
+    +Xoanon    
+No match
+    \x{300}Xoanon 
+No match
+
+/X\b/8
+    X+oanon
+ 0: X
+    ZX\x{300}oanon 
+ 0: X
+    FAX 
+ 0: X
+    *** Failers 
+No match
+    Xoanon  
+No match
+    
+/X\B/8
+    Xoanon  
+ 0: X
+    *** Failers
+No match
+    X+oanon
+No match
+    ZX\x{300}oanon 
+No match
+    FAX 
+No match
+    
+/[^a]/8
+    abcd
+ 0: b
+    a\x{100}   
+ 0: \x{100}
+
+/^[abc\x{123}\x{400}-\x{402}]{2,3}\d/8
+    ab99
+ 0: ab9
+    \x{123}\x{123}45
+ 0: \x{123}\x{123}4
+    \x{400}\x{401}\x{402}6  
+ 0: \x{400}\x{401}\x{402}6
+    *** Failers
+No match
+    d99
+No match
+    \x{123}\x{122}4   
+No match
+    \x{400}\x{403}6  
+No match
+    \x{400}\x{401}\x{402}\x{402}6  
+No match
+
+/abc/8
+    Ã]
+Error -10
+    Ã
+Error -10
+    ÃÃÃ
+Error -10
+    ÃÃÃ\?
+No match
+
+/a.b/8
+    acb
+ 0: acb
+    a\x7fb
+ 0: a\x{7f}b
+    a\x{100}b 
+ 0: a\x{100}b
+    *** Failers
+No match
+    a\nb  
+No match
+
+/a(.{3})b/8
+    a\x{4000}xyb 
+ 0: a\x{4000}xyb
+    a\x{4000}\x7fyb 
+ 0: a\x{4000}\x{7f}yb
+    a\x{4000}\x{100}yb 
+ 0: a\x{4000}\x{100}yb
+    *** Failers
+No match
+    a\x{4000}b 
+No match
+    ac\ncb 
+No match
+
+/a(.*?)(.)/
+    a\xc0\x88b
+ 0: a\xc0\x88b
+ 1: a\xc0\x88
+ 2: a\xc0
+
+/a(.*?)(.)/8
+    a\x{100}b
+ 0: a\x{100}b
+ 1: a\x{100}
+
+/a(.*)(.)/
+    a\xc0\x88b
+ 0: a\xc0\x88b
+ 1: a\xc0\x88
+ 2: a\xc0
+
+/a(.*)(.)/8
+    a\x{100}b
+ 0: a\x{100}b
+ 1: a\x{100}
+
+/a(.)(.)/
+    a\xc0\x92bcd
+ 0: a\xc0\x92
+
+/a(.)(.)/8
+    a\x{240}bcd
+ 0: a\x{240}b
+
+/a(.?)(.)/
+    a\xc0\x92bcd
+ 0: a\xc0\x92
+ 1: a\xc0
+
+/a(.?)(.)/8
+    a\x{240}bcd
+ 0: a\x{240}b
+ 1: a\x{240}
+
+/a(.??)(.)/
+    a\xc0\x92bcd
+ 0: a\xc0\x92
+ 1: a\xc0
+
+/a(.??)(.)/8
+    a\x{240}bcd
+ 0: a\x{240}b
+ 1: a\x{240}
+
+/a(.{3})b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+    ac\ncb 
+No match
+
+/a(.{3,})b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+    axxxxbcdefghijb 
+ 0: axxxxbcdefghijb
+ 1: axxxxb
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+
+/a(.{3,}?)b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+    axxxxbcdefghijb 
+ 0: axxxxbcdefghijb
+ 1: axxxxb
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+
+/a(.{3,5})b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+    axxxxbcdefghijb 
+ 0: axxxxb
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+    axbxxbcdefghijb 
+ 0: axbxxb
+    axxxxxbcdefghijb 
+ 0: axxxxxb
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+    axxxxxxbcdefghijb 
+No match
+
+/a(.{3,5}?)b/8
+    a\x{1234}xyb 
+ 0: a\x{1234}xyb
+    a\x{1234}\x{4321}yb 
+ 0: a\x{1234}\x{4321}yb
+    a\x{1234}\x{4321}\x{3412}b 
+ 0: a\x{1234}\x{4321}\x{3412}b
+    axxxxbcdefghijb 
+ 0: axxxxb
+    a\x{1234}\x{4321}\x{3412}\x{3421}b 
+ 0: a\x{1234}\x{4321}\x{3412}\x{3421}b
+    axbxxbcdefghijb 
+ 0: axbxxb
+    axxxxxbcdefghijb 
+ 0: axxxxxb
+    *** Failers
+No match
+    a\x{1234}b 
+No match
+    axxxxxxbcdefghijb 
+No match
+
+/^[a\x{c0}]/8
+    *** Failers
+No match
+    \x{100}
+No match
+
+/(?<=aXb)cd/8
+    aXbcd
+ 0: cd
+
+/(?<=a\x{100}b)cd/8
+    a\x{100}bcd
+ 0: cd
+
+/(?<=a\x{100000}b)cd/8
+    a\x{100000}bcd
+ 0: cd
+    
+/(?:\x{100}){3}b/8
+    \x{100}\x{100}\x{100}b
+ 0: \x{100}\x{100}\x{100}b
+    *** Failers 
+No match
+    \x{100}\x{100}b
+No match
+
+/\x{ab}/8
+    \x{ab} 
+ 0: \x{ab}
+    \xc2\xab
+ 0: \x{ab}
+    *** Failers 
+No match
+    \x00{ab}
+No match
+
+/(?<=(.))X/8
+    WXYZ
+ 0: X
+    \x{256}XYZ 
+ 0: X
+    *** Failers
+No match
+    XYZ 
+No match
+
+/[^a]+/8g
+    bcd
+ 0: bcd
+ 1: bc
+ 2: b
+    \x{100}aY\x{256}Z 
+ 0: \x{100}
+ 0: Y\x{256}Z
+ 1: Y\x{256}
+ 2: Y
+    
+/^[^a]{2}/8
+    \x{100}bc
+ 0: \x{100}b
+ 
+/^[^a]{2,}/8
+    \x{100}bcAa
+ 0: \x{100}bcA
+ 1: \x{100}bc
+ 2: \x{100}b
+
+/^[^a]{2,}?/8
+    \x{100}bca
+ 0: \x{100}bc
+ 1: \x{100}b
+
+/[^a]+/8ig
+    bcd
+ 0: bcd
+ 1: bc
+ 2: b
+    \x{100}aY\x{256}Z 
+ 0: \x{100}
+ 0: Y\x{256}Z
+ 1: Y\x{256}
+ 2: Y
+    
+/^[^a]{2}/8i
+    \x{100}bc
+ 0: \x{100}b
+ 
+/^[^a]{2,}/8i
+    \x{100}bcAa
+ 0: \x{100}bc
+ 1: \x{100}b
+
+/^[^a]{2,}?/8i
+    \x{100}bca
+ 0: \x{100}bc
+ 1: \x{100}b
+
+/\x{100}{0,0}/8
+    abcd
+ 0: 
+ 
+/\x{100}?/8
+    abcd
+ 0: 
+    \x{100}\x{100} 
+ 0: \x{100}
+ 1: 
+
+/\x{100}{0,3}/8 
+    \x{100}\x{100} 
+ 0: \x{100}\x{100}
+ 1: \x{100}
+ 2: 
+    \x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}\x{100}\x{100}
+ 1: \x{100}\x{100}
+ 2: \x{100}
+ 3: 
+    
+/\x{100}*/8
+    abce
+ 0: 
+    \x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}\x{100}\x{100}\x{100}
+ 1: \x{100}\x{100}\x{100}
+ 2: \x{100}\x{100}
+ 3: \x{100}
+ 4: 
+
+/\x{100}{1,1}/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}
+
+/\x{100}{1,3}/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}\x{100}\x{100}
+ 1: \x{100}\x{100}
+ 2: \x{100}
+
+/\x{100}+/8
+    abcd\x{100}\x{100}\x{100}\x{100} 
+ 0: \x{100}\x{100}\x{100}\x{100}
+ 1: \x{100}\x{100}\x{100}
+ 2: \x{100}\x{100}
+ 3: \x{100}
+
+/\x{100}{3}/8
+    abcd\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}
+
+/\x{100}{3,5}/8
+    abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}
+ 1: \x{100}\x{100}\x{100}\x{100}
+ 2: \x{100}\x{100}\x{100}
+
+/\x{100}{3,}/8
+    abcd\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}XX
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 1: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 2: \x{100}\x{100}\x{100}\x{100}\x{100}
+ 3: \x{100}\x{100}\x{100}\x{100}
+ 4: \x{100}\x{100}\x{100}
+
+/(?<=a\x{100}{2}b)X/8
+    Xyyya\x{100}\x{100}bXzzz
+ 0: X
+
+/\D*/8
+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Matched, but too many subsidiary matches
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 3: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 4: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 6: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 7: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 8: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 9: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+10: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+11: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+12: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+13: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+14: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+15: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+16: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+17: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+18: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+19: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+20: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+21: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\D*/8
+  \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+Matched, but too many subsidiary matches
+ 0: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 1: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 2: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 3: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 4: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 5: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 6: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 7: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 8: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+ 9: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+10: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+11: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+12: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+13: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+14: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+15: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+16: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+17: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+18: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+19: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+20: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+21: \x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}\x{100}
+
+/\D/8
+    1X2
+ 0: X
+    1\x{100}2 
+ 0: \x{100}
+  
+/>\S/8
+    > >X Y
+ 0: >X
+    > >\x{100} Y
+ 0: >\x{100}
+  
+/\d/8
+    \x{100}3
+ 0: 3
+    
+/\s/8
+    \x{100} X
+ 0:  
+    
+/\D+/8
+    12abcd34
+ 0: abcd
+ 1: abc
+ 2: ab
+ 3: a
+    *** Failers
+ 0: *** Failers
+ 1: *** Failer
+ 2: *** Faile
+ 3: *** Fail
+ 4: *** Fai
+ 5: *** Fa
+ 6: *** F
+ 7: *** 
+ 8: ***
+ 9: **
+10: *
+    1234  
+No match
+
+/\D{2,3}/8
+    12abcd34
+ 0: abc
+ 1: ab
+    12ab34
+ 0: ab
+    *** Failers  
+ 0: ***
+ 1: **
+    1234
+No match
+    12a34  
+No match
+
+/\D{2,3}?/8
+    12abcd34
+ 0: abc
+ 1: ab
+    12ab34
+ 0: ab
+    *** Failers  
+ 0: ***
+ 1: **
+    1234
+No match
+    12a34  
+No match
+
+/\d+/8
+    12abcd34
+ 0: 12
+ 1: 1
+    *** Failers
+No match
+
+/\d{2,3}/8
+    12abcd34
+ 0: 12
+    1234abcd
+ 0: 123
+ 1: 12
+    *** Failers  
+No match
+    1.4 
+No match
+
+/\d{2,3}?/8
+    12abcd34
+ 0: 12
+    1234abcd
+ 0: 123
+ 1: 12
+    *** Failers  
+No match
+    1.4 
+No match
+
+/\S+/8
+    12abcd34
+ 0: 12abcd34
+ 1: 12abcd3
+ 2: 12abcd
+ 3: 12abc
+ 4: 12ab
+ 5: 12a
+ 6: 12
+ 7: 1
+    *** Failers
+ 0: ***
+ 1: **
+ 2: *
+    \    \ 
+No match
+
+/\S{2,3}/8
+    12abcd34
+ 0: 12a
+ 1: 12
+    1234abcd
+ 0: 123
+ 1: 12
+    *** Failers
+ 0: ***
+ 1: **
+    \     \  
+No match
+
+/\S{2,3}?/8
+    12abcd34
+ 0: 12a
+ 1: 12
+    1234abcd
+ 0: 123
+ 1: 12
+    *** Failers
+ 0: ***
+ 1: **
+    \     \  
+No match
+
+/>\s+</8
+    12>      <34
+ 0: >      <
+    *** Failers
+No match
+
+/>\s{2,3}</8
+    ab>  <cd
+ 0: >  <
+    ab>   <ce
+ 0: >   <
+    *** Failers
+No match
+    ab>    <cd 
+No match
+
+/>\s{2,3}?</8
+    ab>  <cd
+ 0: >  <
+    ab>   <ce
+ 0: >   <
+    *** Failers
+No match
+    ab>    <cd 
+No match
+
+/\w+/8
+    12      34
+ 0: 12
+ 1: 1
+    *** Failers
+ 0: Failers
+ 1: Failer
+ 2: Faile
+ 3: Fail
+ 4: Fai
+ 5: Fa
+ 6: F
+    +++=*! 
+No match
+
+/\w{2,3}/8
+    ab  cd
+ 0: ab
+    abcd ce
+ 0: abc
+ 1: ab
+    *** Failers
+ 0: Fai
+ 1: Fa
+    a.b.c
+No match
+
+/\w{2,3}?/8
+    ab  cd
+ 0: ab
+    abcd ce
+ 0: abc
+ 1: ab
+    *** Failers
+ 0: Fai
+ 1: Fa
+    a.b.c
+No match
+
+/\W+/8
+    12====34
+ 0: ====
+ 1: ===
+ 2: ==
+ 3: =
+    *** Failers
+ 0: *** 
+ 1: ***
+ 2: **
+ 3: *
+    abcd 
+No match
+
+/\W{2,3}/8
+    ab====cd
+ 0: ===
+ 1: ==
+    ab==cd
+ 0: ==
+    *** Failers
+ 0: ***
+ 1: **
+    a.b.c
+No match
+
+/\W{2,3}?/8
+    ab====cd
+ 0: ===
+ 1: ==
+    ab==cd
+ 0: ==
+    *** Failers
+ 0: ***
+ 1: **
+    a.b.c
+No match
+
+/[\x{100}]/8
+    \x{100}
+ 0: \x{100}
+    Z\x{100}
+ 0: \x{100}
+    \x{100}Z
+ 0: \x{100}
+    *** Failers 
+No match
+
+/[Z\x{100}]/8
+    Z\x{100}
+ 0: Z
+    \x{100}
+ 0: \x{100}
+    \x{100}Z
+ 0: \x{100}
+    *** Failers 
+No match
+
+/[\x{100}\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   *** Failers  
+No match
+
+/[\x{100}-\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{111}cd 
+ 0: \x{111}
+   *** Failers  
+No match
+
+/[z-\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{111}cd 
+ 0: \x{111}
+   abzcd
+ 0: z
+   ab|cd  
+ 0: |
+   *** Failers  
+No match
+
+/[Q\x{100}\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   Q? 
+ 0: Q
+   *** Failers  
+No match
+
+/[Q\x{100}-\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{111}cd 
+ 0: \x{111}
+   Q? 
+ 0: Q
+   *** Failers  
+No match
+
+/[Qz-\x{200}]/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{111}cd 
+ 0: \x{111}
+   abzcd
+ 0: z
+   ab|cd  
+ 0: |
+   Q? 
+ 0: Q
+   *** Failers  
+No match
+
+/[\x{100}\x{200}]{1,3}/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}\x{100}\x{200}
+ 1: \x{200}\x{100}
+ 2: \x{200}
+   *** Failers  
+No match
+
+/[\x{100}\x{200}]{1,3}?/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}\x{100}\x{200}
+ 1: \x{200}\x{100}
+ 2: \x{200}
+   *** Failers  
+No match
+
+/[Q\x{100}\x{200}]{1,3}/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}\x{100}\x{200}
+ 1: \x{200}\x{100}
+ 2: \x{200}
+   *** Failers  
+No match
+
+/[Q\x{100}\x{200}]{1,3}?/8
+   ab\x{100}cd
+ 0: \x{100}
+   ab\x{200}cd
+ 0: \x{200}
+   ab\x{200}\x{100}\x{200}\x{100}cd
+ 0: \x{200}\x{100}\x{200}
+ 1: \x{200}\x{100}
+ 2: \x{200}
+   *** Failers  
+No match
+
+/(?<=[\x{100}\x{200}])X/8
+    abc\x{200}X
+ 0: X
+    abc\x{100}X 
+ 0: X
+    *** Failers
+No match
+    X  
+No match
+
+/(?<=[Q\x{100}\x{200}])X/8
+    abc\x{200}X
+ 0: X
+    abc\x{100}X 
+ 0: X
+    abQX 
+ 0: X
+    *** Failers
+No match
+    X  
+No match
+
+/(?<=[\x{100}\x{200}]{3})X/8
+    abc\x{100}\x{200}\x{100}X
+ 0: X
+    *** Failers
+No match
+    abc\x{200}X
+No match
+    X  
+No match
+
+/[^\x{100}\x{200}]X/8
+    AX
+ 0: AX
+    \x{150}X
+ 0: \x{150}X
+    \x{500}X 
+ 0: \x{500}X
+    *** Failers
+No match
+    \x{100}X
+No match
+    \x{200}X   
+No match
+
+/[^Q\x{100}\x{200}]X/8
+    AX
+ 0: AX
+    \x{150}X
+ 0: \x{150}X
+    \x{500}X 
+ 0: \x{500}X
+    *** Failers
+No match
+    \x{100}X
+No match
+    \x{200}X   
+No match
+    QX 
+No match
+
+/[^\x{100}-\x{200}]X/8
+    AX
+ 0: AX
+    \x{500}X 
+ 0: \x{500}X
+    *** Failers
+No match
+    \x{100}X
+No match
+    \x{150}X
+No match
+    \x{200}X   
+No match
+
+/[z-\x{100}]/8i
+    z
+ 0: z
+    Z 
+ 0: Z
+    \x{100}
+ 0: \x{100}
+    *** Failers
+No match
+    \x{102}
+No match
+    y    
+No match
+
+/[\xFF]/
+    >\xff<
+ 0: \xff
+
+/[\xff]/8
+    >\x{ff}<
+ 0: \x{ff}
+
+/[^\xFF]/
+    XYZ
+ 0: X
+
+/[^\xff]/8
+    XYZ
+ 0: X
+    \x{123} 
+ 0: \x{123}
+
+/^[ac]*b/8
+  xb
+No match
+
+/^[ac\x{100}]*b/8
+  xb
+No match
+
+/^[^x]*b/8i
+  xb
+No match
+
+/^[^x]*b/8
+  xb
+No match
+  
+/^\d*b/8
+  xb 
+No match
+
+/(|a)/g8
+    catac
+ 0: 
+ 0: a
+ 1: 
+ 0: 
+ 0: a
+ 1: 
+ 0: 
+ 0: 
+    a\x{256}a 
+ 0: a
+ 1: 
+ 0: 
+ 0: a
+ 1: 
+ 0: 
+
+/^\x{85}$/8i
+    \x{85}
+ 0: \x{85}
+
+/^abc./mgx8<any>
+    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x{0085}abc7 \x{2028}abc8 \x{2029}abc9 JUNK
+ 0: abc1
+ 0: abc2
+ 0: abc3
+ 0: abc4
+ 0: abc5
+ 0: abc6
+ 0: abc7
+ 0: abc8
+ 0: abc9
+
+/abc.$/mgx8<any>
+    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x{0085} abc7\x{2028} abc8\x{2029} abc9
+ 0: abc1
+ 0: abc2
+ 0: abc3
+ 0: abc4
+ 0: abc5
+ 0: abc6
+ 0: abc7
+ 0: abc8
+ 0: abc9
+
+/^a\Rb/8<bsr_unicode>
+    a\nb
+ 0: a\x{0a}b
+    a\rb
+ 0: a\x{0d}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x0bb
+ 0: a\x{0b}b
+    a\x0cb
+ 0: a\x{0c}b
+    a\x{85}b   
+ 0: a\x{85}b
+    a\x{2028}b 
+ 0: a\x{2028}b
+    a\x{2029}b 
+ 0: a\x{2029}b
+    ** Failers
+No match
+    a\n\rb    
+No match
+
+/^a\R*b/8<bsr_unicode>
+    ab
+ 0: ab
+    a\nb
+ 0: a\x{0a}b
+    a\rb
+ 0: a\x{0d}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x0bb
+ 0: a\x{0b}b
+    a\x0c\x{2028}\x{2029}b
+ 0: a\x{0c}\x{2028}\x{2029}b
+    a\x{85}b   
+ 0: a\x{85}b
+    a\n\rb    
+ 0: a\x{0a}\x{0d}b
+    a\n\r\x{85}\x0cb 
+ 0: a\x{0a}\x{0d}\x{85}\x{0c}b
+
+/^a\R+b/8<bsr_unicode>
+    a\nb
+ 0: a\x{0a}b
+    a\rb
+ 0: a\x{0d}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x0bb
+ 0: a\x{0b}b
+    a\x0c\x{2028}\x{2029}b
+ 0: a\x{0c}\x{2028}\x{2029}b
+    a\x{85}b   
+ 0: a\x{85}b
+    a\n\rb    
+ 0: a\x{0a}\x{0d}b
+    a\n\r\x{85}\x0cb 
+ 0: a\x{0a}\x{0d}\x{85}\x{0c}b
+    ** Failers
+No match
+    ab  
+No match
+
+/^a\R{1,3}b/8<bsr_unicode>
+    a\nb
+ 0: a\x{0a}b
+    a\n\rb
+ 0: a\x{0a}\x{0d}b
+    a\n\r\x{85}b
+ 0: a\x{0a}\x{0d}\x{85}b
+    a\r\n\r\nb 
+ 0: a\x{0d}\x{0a}\x{0d}\x{0a}b
+    a\r\n\r\n\r\nb 
+ 0: a\x{0d}\x{0a}\x{0d}\x{0a}\x{0d}\x{0a}b
+    a\n\r\n\rb
+ 0: a\x{0a}\x{0d}\x{0a}\x{0d}b
+    a\n\n\r\nb 
+ 0: a\x{0a}\x{0a}\x{0d}\x{0a}b
+    ** Failers
+No match
+    a\n\n\n\rb
+No match
+    a\r
+No match
+
+/\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}
+
+/\V?\v{3,4}/8 
+    \x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: X\x{0a}\x{0b}\x{0c}
+
+/\h+\V?\v{3,4}/8
+    >\x09\x20\x{a0}X\x0a\x0a\x0a<
+ 0: \x{09} \x{a0}X\x{0a}\x{0a}\x{0a}
+
+/\V?\v{3,4}/8
+    >\x09\x20\x{a0}X\x0a\x0a\x0a<
+ 0: X\x{0a}\x{0a}\x{0a}
+
+/\H\h\V\v/8
+    X X\x0a
+ 0: X X\x{0a}
+    X\x09X\x0b
+ 0: X\x{09}X\x{0b}
+    ** Failers
+No match
+    \x{a0} X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}X\x{0a}\x{0b}\x{0c}
+    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}\x{0d}
+ 1: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+    \x09\x20\x{a0}\x0a\x0b\x0c
+ 0: \x{09} \x{a0}\x{0a}\x{0b}\x{0c}
+    ** Failers 
+No match
+    \x09\x20\x{a0}\x0a\x0b
+No match
+     
+/\H\h\V\v/8
+    \x{3001}\x{3000}\x{2030}\x{2028}
+ 0: \x{3001}\x{3000}\x{2030}\x{2028}
+    X\x{180e}X\x{85}
+ 0: X\x{180e}X\x{85}
+    ** Failers
+No match
+    \x{2009} X\x0a   
+No match
+    
+/\H*\h+\V?\v{3,4}/8 
+    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
+ 0: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}\x{0d}
+ 1: \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x{0c}
+    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
+ 0: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}\x{2028}
+ 1: \x{09}\x{205f}\x{a0}\x{0a}\x{2029}\x{0c}
+    \x09\x20\x{202f}\x0a\x0b\x0c
+ 0: \x{09} \x{202f}\x{0a}\x{0b}\x{0c}
+    ** Failers 
+No match
+    \x09\x{200a}\x{a0}\x{2028}\x0b
+No match
+     
+/a\Rb/I8<bsr_anycrlf>
+Capturing subpattern count = 0
+Options: bsr_anycrlf utf8
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x{0d}b
+    a\nb
+ 0: a\x{0a}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    ** Failers
+No match
+    a\x{85}b
+No match
+    a\x0bb     
+No match
+
+/a\Rb/I8<bsr_unicode>
+Capturing subpattern count = 0
+Options: bsr_unicode utf8
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x{0d}b
+    a\nb
+ 0: a\x{0a}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x{85}b
+ 0: a\x{85}b
+    a\x0bb     
+ 0: a\x{0b}b
+    ** Failers 
+No match
+    a\x{85}b\<bsr_anycrlf>
+No match
+    a\x0bb\<bsr_anycrlf>
+No match
+    
+/a\R?b/I8<bsr_anycrlf>
+Capturing subpattern count = 0
+Options: bsr_anycrlf utf8
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x{0d}b
+    a\nb
+ 0: a\x{0a}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    ** Failers
+No match
+    a\x{85}b
+No match
+    a\x0bb     
+No match
+
+/a\R?b/I8<bsr_unicode>
+Capturing subpattern count = 0
+Options: bsr_unicode utf8
+First char = 'a'
+Need char = 'b'
+    a\rb
+ 0: a\x{0d}b
+    a\nb
+ 0: a\x{0a}b
+    a\r\nb
+ 0: a\x{0d}\x{0a}b
+    a\x{85}b
+ 0: a\x{85}b
+    a\x0bb     
+ 0: a\x{0b}b
+    ** Failers 
+No match
+    a\x{85}b\<bsr_anycrlf>
+No match
+    a\x0bb\<bsr_anycrlf>
+No match
+ 
+/X/8f<any> 
+    A\x{1ec5}ABCXYZ
+ 0: X
+
+/ End of testinput 8 / 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/testoutput9	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1673 @@
+/\pL\P{Nd}/8
+    AB
+ 0: AB
+    *** Failers
+ 0: Fa
+    A0
+No match
+    00   
+No match
+
+/\X./8
+    AB
+ 0: AB
+    A\x{300}BC 
+ 0: A\x{300}B
+    A\x{300}\x{301}\x{302}BC 
+ 0: A\x{300}\x{301}\x{302}B
+    *** Failers
+ 0: **
+    \x{300}  
+No match
+
+/\X\X/8
+    ABC
+ 0: AB
+    A\x{300}B\x{300}\x{301}C 
+ 0: A\x{300}B\x{300}\x{301}
+    A\x{300}\x{301}\x{302}BC 
+ 0: A\x{300}\x{301}\x{302}B
+    *** Failers
+ 0: **
+    \x{300}  
+No match
+
+/^\pL+/8
+    abcd
+ 0: abcd
+ 1: abc
+ 2: ab
+ 3: a
+    a 
+ 0: a
+    *** Failers 
+No match
+
+/^\PL+/8
+    1234
+ 0: 1234
+ 1: 123
+ 2: 12
+ 3: 1
+    = 
+ 0: =
+    *** Failers 
+ 0: *** 
+ 1: ***
+ 2: **
+ 3: *
+    abcd 
+No match
+
+/^\X+/8
+    abcdA\x{300}\x{301}\x{302}
+ 0: abcdA\x{300}\x{301}\x{302}
+ 1: abcd
+ 2: abc
+ 3: ab
+ 4: a
+    A\x{300}\x{301}\x{302}
+ 0: A\x{300}\x{301}\x{302}
+    A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}
+ 0: A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}
+ 1: A\x{300}\x{301}\x{302}
+    a 
+ 0: a
+    *** Failers 
+ 0: *** Failers
+ 1: *** Failer
+ 2: *** Faile
+ 3: *** Fail
+ 4: *** Fai
+ 5: *** Fa
+ 6: *** F
+ 7: *** 
+ 8: ***
+ 9: **
+10: *
+    \x{300}\x{301}\x{302}
+No match
+
+/\X?abc/8
+    abc
+ 0: abc
+    A\x{300}abc
+ 0: A\x{300}abc
+    A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abcxyz
+ 0: A\x{300}abc
+    \x{300}abc  
+ 0: abc
+    *** Failers
+No match
+
+/^\X?abc/8
+    abc
+ 0: abc
+    A\x{300}abc
+ 0: A\x{300}abc
+    *** Failers
+No match
+    A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abcxyz
+No match
+    \x{300}abc  
+No match
+
+/\X*abc/8
+    abc
+ 0: abc
+    A\x{300}abc
+ 0: A\x{300}abc
+    A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abcxyz
+ 0: A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abc
+    \x{300}abc  
+ 0: abc
+    *** Failers
+No match
+
+/^\X*abc/8
+    abc
+ 0: abc
+    A\x{300}abc
+ 0: A\x{300}abc
+    A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abcxyz
+ 0: A\x{300}\x{301}\x{302}A\x{300}A\x{300}A\x{300}abc
+    *** Failers
+No match
+    \x{300}abc  
+No match
+
+/^\pL?=./8
+    A=b
+ 0: A=b
+    =c 
+ 0: =c
+    *** Failers
+No match
+    1=2 
+No match
+    AAAA=b  
+No match
+
+/^\pL*=./8
+    AAAA=b
+ 0: AAAA=b
+    =c 
+ 0: =c
+    *** Failers
+No match
+    1=2  
+No match
+
+/^\X{2,3}X/8
+    A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}X
+ 0: A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}X
+    A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}X 
+ 0: A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}X
+    *** Failers
+No match
+    X
+No match
+    A\x{300}\x{301}\x{302}X
+No match
+    A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}A\x{300}\x{301}\x{302}X
+No match
+
+/^\pC\pL\pM\pN\pP\pS\pZ</8
+    \x7f\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
+ 0: \x{7f}\x{c0}\x{30f}\x{660}\x{66c}\x{f01}\x{1680}<
+    \np\x{300}9!\$ < 
+ 0: \x{0a}p\x{300}9!$ <
+    ** Failers 
+No match
+    ap\x{300}9!\$ < 
+No match
+  
+/^\PC/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x7f
+No match
+  
+/^\PL/8
+    9
+ 0: 9
+    ** Failers 
+ 0: *
+    \x{c0}
+No match
+  
+/^\PM/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x{30f}
+No match
+  
+/^\PN/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x{660}
+No match
+  
+/^\PP/8
+    X
+ 0: X
+    ** Failers 
+No match
+    \x{66c}
+No match
+  
+/^\PS/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x{f01}
+No match
+  
+/^\PZ/8
+    X
+ 0: X
+    ** Failers 
+ 0: *
+    \x{1680}
+No match
+    
+/^\p{Cc}/8
+    \x{017}
+ 0: \x{17}
+    \x{09f} 
+ 0: \x{9f}
+    ** Failers
+No match
+    \x{0600} 
+No match
+  
+/^\p{Cf}/8
+    \x{601}
+ 0: \x{601}
+    ** Failers
+No match
+    \x{09f} 
+No match
+  
+/^\p{Cn}/8
+    ** Failers
+No match
+    \x{09f} 
+No match
+  
+/^\p{Co}/8
+    \x{f8ff}
+ 0: \x{f8ff}
+    ** Failers
+No match
+    \x{09f} 
+No match
+  
+/^\p{Cs}/8
+    \?\x{dfff}
+ 0: \x{dfff}
+    ** Failers
+No match
+    \x{09f} 
+No match
+  
+/^\p{Ll}/8
+    a
+ 0: a
+    ** Failers 
+No match
+    Z
+No match
+    \x{e000}  
+No match
+  
+/^\p{Lm}/8
+    \x{2b0}
+ 0: \x{2b0}
+    ** Failers
+No match
+    a 
+No match
+  
+/^\p{Lo}/8
+    \x{1bb}
+ 0: \x{1bb}
+    ** Failers
+No match
+    a 
+No match
+    \x{2b0}
+No match
+  
+/^\p{Lt}/8
+    \x{1c5}
+ 0: \x{1c5}
+    ** Failers
+No match
+    a 
+No match
+    \x{2b0}
+No match
+  
+/^\p{Lu}/8
+    A
+ 0: A
+    ** Failers
+No match
+    \x{2b0}
+No match
+  
+/^\p{Mc}/8
+    \x{903}
+ 0: \x{903}
+    ** Failers
+No match
+    X
+No match
+    \x{300}
+No match
+       
+/^\p{Me}/8
+    \x{488}
+ 0: \x{488}
+    ** Failers
+No match
+    X
+No match
+    \x{903}
+No match
+    \x{300}
+No match
+  
+/^\p{Mn}/8
+    \x{300}
+ 0: \x{300}
+    ** Failers
+No match
+    X
+No match
+    \x{903}
+No match
+  
+/^\p{Nd}+/8
+    0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}\x{667}\x{668}\x{669}\x{66a}
+ 0: 0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}\x{667}\x{668}\x{669}
+ 1: 0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}\x{667}\x{668}
+ 2: 0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}\x{667}
+ 3: 0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}\x{666}
+ 4: 0123456789\x{660}\x{661}\x{662}\x{663}\x{664}\x{665}
+ 5: 0123456789\x{660}\x{661}\x{662}\x{663}\x{664}
+ 6: 0123456789\x{660}\x{661}\x{662}\x{663}
+ 7: 0123456789\x{660}\x{661}\x{662}
+ 8: 0123456789\x{660}\x{661}
+ 9: 0123456789\x{660}
+10: 0123456789
+11: 012345678
+12: 01234567
+13: 0123456
+14: 012345
+15: 01234
+16: 0123
+17: 012
+18: 01
+19: 0
+    \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}\x{6f7}\x{6f8}\x{6f9}\x{6fa}
+ 0: \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}\x{6f7}\x{6f8}\x{6f9}
+ 1: \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}\x{6f7}\x{6f8}
+ 2: \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}\x{6f7}
+ 3: \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}\x{6f6}
+ 4: \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}\x{6f5}
+ 5: \x{6f0}\x{6f1}\x{6f2}\x{6f3}\x{6f4}
+ 6: \x{6f0}\x{6f1}\x{6f2}\x{6f3}
+ 7: \x{6f0}\x{6f1}\x{6f2}
+ 8: \x{6f0}\x{6f1}
+ 9: \x{6f0}
+    \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}\x{96d}\x{96e}\x{96f}\x{970}
+ 0: \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}\x{96d}\x{96e}\x{96f}
+ 1: \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}\x{96d}\x{96e}
+ 2: \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}\x{96d}
+ 3: \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}\x{96c}
+ 4: \x{966}\x{967}\x{968}\x{969}\x{96a}\x{96b}
+ 5: \x{966}\x{967}\x{968}\x{969}\x{96a}
+ 6: \x{966}\x{967}\x{968}\x{969}
+ 7: \x{966}\x{967}\x{968}
+ 8: \x{966}\x{967}
+ 9: \x{966}
+    ** Failers
+No match
+    X
+No match
+  
+/^\p{Nl}/8
+    \x{16ee}
+ 0: \x{16ee}
+    ** Failers
+No match
+    X
+No match
+    \x{966}
+No match
+  
+/^\p{No}/8
+    \x{b2}
+ 0: \x{b2}
+    \x{b3}
+ 0: \x{b3}
+    ** Failers
+No match
+    X
+No match
+    \x{16ee}
+No match
+  
+/^\p{Pc}/8
+    \x5f
+ 0: _
+    \x{203f}
+ 0: \x{203f}
+    ** Failers
+No match
+    X
+No match
+    -
+No match
+    \x{58a}
+No match
+  
+/^\p{Pd}/8
+    -
+ 0: -
+    \x{58a}
+ 0: \x{58a}
+    ** Failers
+No match
+    X
+No match
+    \x{203f}
+No match
+  
+/^\p{Pe}/8
+    )
+ 0: )
+    ]
+ 0: ]
+    }
+ 0: }
+    \x{f3b}
+ 0: \x{f3b}
+    ** Failers
+No match
+    X
+No match
+    \x{203f}
+No match
+    (
+No match
+    [
+No match
+    {
+No match
+    \x{f3c}
+No match
+  
+/^\p{Pf}/8
+    \x{bb}
+ 0: \x{bb}
+    \x{2019}
+ 0: \x{2019}
+    ** Failers
+No match
+    X
+No match
+    \x{203f}
+No match
+  
+/^\p{Pi}/8
+    \x{ab}
+ 0: \x{ab}
+    \x{2018}
+ 0: \x{2018}
+    ** Failers
+No match
+    X
+No match
+    \x{203f}
+No match
+  
+/^\p{Po}/8
+    !
+ 0: !
+    \x{37e}
+ 0: \x{37e}
+    ** Failers
+ 0: *
+    X
+No match
+    \x{203f}
+No match
+  
+/^\p{Ps}/8
+    (
+ 0: (
+    [
+ 0: [
+    {
+ 0: {
+    \x{f3c}
+ 0: \x{f3c}
+    ** Failers
+No match
+    X
+No match
+    )
+No match
+    ]
+No match
+    }
+No match
+    \x{f3b}
+No match
+  
+/^\p{Sc}+/8
+    $\x{a2}\x{a3}\x{a4}\x{a5}\x{a6}
+ 0: $\x{a2}\x{a3}\x{a4}\x{a5}
+ 1: $\x{a2}\x{a3}\x{a4}
+ 2: $\x{a2}\x{a3}
+ 3: $\x{a2}
+ 4: $
+    \x{9f2}
+ 0: \x{9f2}
+    ** Failers
+No match
+    X
+No match
+    \x{2c2}
+No match
+  
+/^\p{Sk}/8
+    \x{2c2}
+ 0: \x{2c2}
+    ** Failers
+No match
+    X
+No match
+    \x{9f2}
+No match
+  
+/^\p{Sm}+/8
+    +<|~\x{ac}\x{2044}
+ 0: +<|~\x{ac}\x{2044}
+ 1: +<|~\x{ac}
+ 2: +<|~
+ 3: +<|
+ 4: +<
+ 5: +
+    ** Failers
+No match
+    X
+No match
+    \x{9f2}
+No match
+  
+/^\p{So}/8
+    \x{a6}
+ 0: \x{a6}
+    \x{482} 
+ 0: \x{482}
+    ** Failers
+No match
+    X
+No match
+    \x{9f2}
+No match
+  
+/^\p{Zl}/8
+    \x{2028}
+ 0: \x{2028}
+    ** Failers
+No match
+    X
+No match
+    \x{2029}
+No match
+  
+/^\p{Zp}/8
+    \x{2029}
+ 0: \x{2029}
+    ** Failers
+No match
+    X
+No match
+    \x{2028}
+No match
+  
+/^\p{Zs}/8
+    \ \
+ 0:  
+    \x{a0}
+ 0: \x{a0}
+    \x{1680}
+ 0: \x{1680}
+    \x{180e}
+ 0: \x{180e}
+    \x{2000}
+ 0: \x{2000}
+    \x{2001}     
+ 0: \x{2001}
+    ** Failers
+No match
+    \x{2028}
+No match
+    \x{200d} 
+No match
+  
+/\p{Nd}+(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: \x{660}\x{661}\x{662}A
+ 2: \x{660}\x{661}\x{662}
+  
+/\p{Nd}+?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: \x{660}\x{661}\x{662}A
+ 2: \x{660}\x{661}\x{662}
+  
+/\p{Nd}{2,}(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: \x{660}\x{661}\x{662}A
+  
+/\p{Nd}{2,}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: \x{660}\x{661}\x{662}A
+  
+/\p{Nd}*(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: \x{660}\x{661}\x{662}A
+ 2: \x{660}\x{661}\x{662}
+ 3: \x{660}\x{661}
+  
+/\p{Nd}*?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: \x{660}\x{661}\x{662}A
+ 2: \x{660}\x{661}\x{662}
+ 3: \x{660}\x{661}
+  
+/\p{Nd}{2}(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}A
+  
+/\p{Nd}{2,3}(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: \x{660}\x{661}\x{662}A
+  
+/\p{Nd}{2,3}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+ 1: \x{660}\x{661}\x{662}A
+  
+/\p{Nd}?(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}
+ 1: \x{660}\x{661}
+  
+/\p{Nd}??(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}
+ 1: \x{660}\x{661}
+  
+/\p{Nd}*+(..)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}AB
+  
+/\p{Nd}*+(...)/8
+      \x{660}\x{661}\x{662}ABC
+ 0: \x{660}\x{661}\x{662}ABC
+  
+/\p{Nd}*+(....)/8
+      ** Failers
+ 0: ** F
+      \x{660}\x{661}\x{662}ABC
+No match
+  
+/\p{Lu}/8i
+    A
+ 0: A
+    a\x{10a0}B 
+ 0: \x{10a0}
+    ** Failers 
+ 0: F
+    a
+No match
+    \x{1d00}  
+No match
+
+/\p{^Lu}/8i
+    1234
+ 0: 1
+    ** Failers
+ 0: *
+    ABC 
+No match
+
+/\P{Lu}/8i
+    1234
+ 0: 1
+    ** Failers
+ 0: *
+    ABC 
+No match
+
+/(?<=A\p{Nd})XYZ/8
+    A2XYZ
+ 0: XYZ
+    123A5XYZPQR
+ 0: XYZ
+    ABA\x{660}XYZpqr
+ 0: XYZ
+    ** Failers
+No match
+    AXYZ
+No match
+    XYZ     
+No match
+    
+/(?<!\pL)XYZ/8
+    1XYZ
+ 0: XYZ
+    AB=XYZ.. 
+ 0: XYZ
+    XYZ 
+ 0: XYZ
+    ** Failers
+No match
+    WXYZ 
+No match
+
+/[\p{Nd}]/8
+    1234
+ 0: 1
+
+/[\p{Nd}+-]+/8
+    1234
+ 0: 1234
+ 1: 123
+ 2: 12
+ 3: 1
+    12-34
+ 0: 12-34
+ 1: 12-3
+ 2: 12-
+ 3: 12
+ 4: 1
+    12+\x{661}-34  
+ 0: 12+\x{661}-34
+ 1: 12+\x{661}-3
+ 2: 12+\x{661}-
+ 3: 12+\x{661}
+ 4: 12+
+ 5: 12
+ 6: 1
+    ** Failers
+No match
+    abcd  
+No match
+
+/[\P{Nd}]+/8
+    abcd
+ 0: abcd
+ 1: abc
+ 2: ab
+ 3: a
+    ** Failers
+ 0: ** Failers
+ 1: ** Failer
+ 2: ** Faile
+ 3: ** Fail
+ 4: ** Fai
+ 5: ** Fa
+ 6: ** F
+ 7: ** 
+ 8: **
+ 9: *
+    1234
+No match
+
+/\D+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Matched, but too many subsidiary matches
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 3: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 4: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 6: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 7: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 8: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 9: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+10: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+11: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+12: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+13: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+14: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+15: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+16: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+17: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+18: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+19: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+20: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+21: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+     
+/\P{Nd}+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Matched, but too many subsidiary matches
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 3: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 4: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 6: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 7: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 8: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 9: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+10: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+11: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+12: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+13: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+14: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+15: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+16: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+17: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+18: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+19: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+20: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+21: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\D]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Matched, but too many subsidiary matches
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 3: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 4: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 6: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 7: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 8: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 9: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+10: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+11: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+12: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+13: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+14: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+15: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+16: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+17: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+18: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+19: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+20: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+21: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\P{Nd}]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Matched, but too many subsidiary matches
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 3: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 4: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 6: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 7: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 8: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 9: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+10: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+11: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+12: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+13: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+14: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+15: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+16: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+17: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+18: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+19: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+20: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+21: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/[\D\P{Nd}]+/8
+    11111111111111111111111111111111111111111111111111111111111111111111111
+No match
+    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Matched, but too many subsidiary matches
+ 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 3: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 4: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 5: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 6: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 7: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 8: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 9: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+10: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+11: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+12: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+13: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+14: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+15: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+16: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+17: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+18: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+19: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+20: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+21: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+/\pL/8
+    a
+ 0: a
+    A 
+ 0: A
+
+/\pL/8i
+    a
+ 0: a
+    A 
+ 0: A
+    
+/\p{Lu}/8 
+    A
+ 0: A
+    aZ
+ 0: Z
+    ** Failers
+ 0: F
+    abc   
+No match
+
+/\p{Lu}/8i
+    A
+ 0: A
+    aZ
+ 0: Z
+    ** Failers
+ 0: F
+    abc   
+No match
+
+/\p{Ll}/8 
+    a
+ 0: a
+    Az
+ 0: z
+    ** Failers
+ 0: a
+    ABC   
+No match
+
+/\p{Ll}/8i 
+    a
+ 0: a
+    Az
+ 0: z
+    ** Failers
+ 0: a
+    ABC   
+No match
+
+/^\x{c0}$/8i
+    \x{c0}
+ 0: \x{c0}
+    \x{e0} 
+ 0: \x{e0}
+
+/^\x{e0}$/8i
+    \x{c0}
+ 0: \x{c0}
+    \x{e0} 
+ 0: \x{e0}
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8
+    A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ 0: A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    ** Failers
+No match
+    a\x{391}\x{10427}\x{ff3a}\x{1fb0}   
+No match
+    A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+No match
+    A\x{391}\x{1044F}\x{ff3a}\x{1fb0}
+No match
+    A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+No match
+    A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+No match
+
+/A\x{391}\x{10427}\x{ff3a}\x{1fb0}/8i
+    A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+ 0: A\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    a\x{391}\x{10427}\x{ff3a}\x{1fb0}   
+ 0: a\x{391}\x{10427}\x{ff3a}\x{1fb0}
+    A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+ 0: A\x{3b1}\x{10427}\x{ff3a}\x{1fb0}
+    A\x{391}\x{1044F}\x{ff3a}\x{1fb0}
+ 0: A\x{391}\x{1044f}\x{ff3a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+ 0: A\x{391}\x{10427}\x{ff5a}\x{1fb0}
+    A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+ 0: A\x{391}\x{10427}\x{ff3a}\x{1fb8}
+
+/\x{391}+/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
+ 0: \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
+ 1: \x{391}\x{3b1}\x{3b1}\x{3b1}
+ 2: \x{391}\x{3b1}\x{3b1}
+ 3: \x{391}\x{3b1}
+ 4: \x{391}
+
+/\x{391}{3,5}(.)/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+ 0: \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+ 1: \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
+ 2: \x{391}\x{3b1}\x{3b1}\x{3b1}
+
+/\x{391}{3,5}?(.)/8i
+    \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+ 0: \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}X
+ 1: \x{391}\x{3b1}\x{3b1}\x{3b1}\x{391}
+ 2: \x{391}\x{3b1}\x{3b1}\x{3b1}
+
+/[\x{391}\x{ff3a}]/8i
+    \x{391}
+ 0: \x{391}
+    \x{ff3a}
+ 0: \x{ff3a}
+    \x{3b1}
+ 0: \x{3b1}
+    \x{ff5a}   
+ 0: \x{ff5a}
+    
+/[\x{c0}\x{391}]/8i
+    \x{c0}
+ 0: \x{c0}
+    \x{e0} 
+ 0: \x{e0}
+
+/[\x{105}-\x{109}]/8i
+    \x{104}
+ 0: \x{104}
+    \x{105}
+ 0: \x{105}
+    \x{109}  
+ 0: \x{109}
+    ** Failers
+No match
+    \x{100}
+No match
+    \x{10a} 
+No match
+    
+/[z-\x{100}]/8i 
+    Z
+ 0: Z
+    z
+ 0: z
+    \x{39c}
+ 0: \x{39c}
+    \x{178}
+ 0: \x{178}
+    |
+ 0: |
+    \x{80}
+ 0: \x{80}
+    \x{ff}
+ 0: \x{ff}
+    \x{100}
+ 0: \x{100}
+    \x{101} 
+ 0: \x{101}
+    ** Failers
+No match
+    \x{102}
+No match
+    Y
+No match
+    y           
+No match
+
+/[z-\x{100}]/8i
+
+/^\X/8
+    A
+ 0: A
+    A\x{300}BC 
+ 0: A\x{300}
+    A\x{300}\x{301}\x{302}BC 
+ 0: A\x{300}\x{301}\x{302}
+    *** Failers
+ 0: *
+    \x{300}  
+No match
+
+/^[\X]/8
+    X123
+ 0: X
+    *** Failers
+No match
+    AXYZ
+No match
+
+/^(\X*)C/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+ 0: A\x{300}\x{301}\x{302}BC
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+ 0: A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C
+ 1: A\x{300}\x{301}\x{302}BC
+
+/^(\X*?)C/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+ 0: A\x{300}\x{301}\x{302}BC
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+ 0: A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C
+ 1: A\x{300}\x{301}\x{302}BC
+
+/^(\X*)(.)/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+ 0: A\x{300}\x{301}\x{302}BCA
+ 1: A\x{300}\x{301}\x{302}BC
+ 2: A\x{300}\x{301}\x{302}B
+ 3: A
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+ 0: A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C
+ 1: A\x{300}\x{301}\x{302}BCA
+ 2: A\x{300}\x{301}\x{302}BC
+ 3: A\x{300}\x{301}\x{302}B
+ 4: A
+
+/^(\X*?)(.)/8
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301} 
+ 0: A\x{300}\x{301}\x{302}BCA
+ 1: A\x{300}\x{301}\x{302}BC
+ 2: A\x{300}\x{301}\x{302}B
+ 3: A
+    A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C 
+ 0: A\x{300}\x{301}\x{302}BCA\x{300}\x{301}C
+ 1: A\x{300}\x{301}\x{302}BCA
+ 2: A\x{300}\x{301}\x{302}BC
+ 3: A\x{300}\x{301}\x{302}B
+ 4: A
+
+/^\X(.)/8
+    *** Failers
+ 0: **
+    A\x{300}\x{301}\x{302}
+No match
+
+/^\X{2,3}(.)/8
+    A\x{300}\x{301}B\x{300}X
+ 0: A\x{300}\x{301}B\x{300}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}
+ 0: A\x{300}\x{301}B\x{300}C
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+ 0: A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+ 1: A\x{300}\x{301}B\x{300}C
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}DA\x{300}X
+ 0: A\x{300}\x{301}B\x{300}C\x{300}\x{301}D
+ 1: A\x{300}\x{301}B\x{300}C
+    
+/^\X{2,3}?(.)/8
+    A\x{300}\x{301}B\x{300}X
+ 0: A\x{300}\x{301}B\x{300}X
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}
+ 0: A\x{300}\x{301}B\x{300}C
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+ 0: A\x{300}\x{301}B\x{300}C\x{300}\x{301}X
+ 1: A\x{300}\x{301}B\x{300}C
+    A\x{300}\x{301}B\x{300}C\x{300}\x{301}DA\x{300}X
+ 0: A\x{300}\x{301}B\x{300}C\x{300}\x{301}D
+ 1: A\x{300}\x{301}B\x{300}C
+
+/^\pN{2,3}X/
+    12X
+ 0: 12X
+    123X
+ 0: 123X
+    *** Failers
+No match
+    X
+No match
+    1X
+No match
+    1234X     
+No match
+
+/\x{100}/i8
+    \x{100}   
+ 0: \x{100}
+    \x{101} 
+ 0: \x{101}
+    
+/^\p{Han}+/8
+    \x{2e81}\x{3007}\x{2f804}\x{31a0}
+ 0: \x{2e81}\x{3007}\x{2f804}
+ 1: \x{2e81}\x{3007}
+ 2: \x{2e81}
+    ** Failers
+No match
+    \x{2e7f}  
+No match
+
+/^\P{Katakana}+/8
+    \x{3105}
+ 0: \x{3105}
+    ** Failers
+ 0: ** Failers
+ 1: ** Failer
+ 2: ** Faile
+ 3: ** Fail
+ 4: ** Fai
+ 5: ** Fa
+ 6: ** F
+ 7: ** 
+ 8: **
+ 9: *
+    \x{30ff}  
+No match
+
+/^[\p{Arabic}]/8
+    \x{06e9}
+ 0: \x{6e9}
+    \x{060b}
+ 0: \x{60b}
+    ** Failers
+No match
+    X\x{06e9}   
+No match
+
+/^[\P{Yi}]/8
+    \x{2f800}
+ 0: \x{2f800}
+    ** Failers
+ 0: *
+    \x{a014}
+No match
+    \x{a4c6}   
+No match
+
+/^\p{Any}X/8
+    AXYZ
+ 0: AX
+    \x{1234}XYZ 
+ 0: \x{1234}X
+    ** Failers
+No match
+    X  
+No match
+    
+/^\P{Any}X/8
+    ** Failers
+No match
+    AX
+No match
+    
+/^\p{Any}?X/8
+    XYZ
+ 0: X
+    AXYZ
+ 0: AX
+    \x{1234}XYZ 
+ 0: \x{1234}X
+    ** Failers
+No match
+    ABXYZ   
+No match
+
+/^\P{Any}?X/8
+    XYZ
+ 0: X
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ 
+No match
+    ABXYZ   
+No match
+
+/^\p{Any}+X/8
+    AXYZ
+ 0: AX
+    \x{1234}XYZ
+ 0: \x{1234}X
+    A\x{1234}XYZ
+ 0: A\x{1234}X
+    ** Failers
+No match
+    XYZ
+No match
+
+/^\P{Any}+X/8
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ
+No match
+    A\x{1234}XYZ
+No match
+    XYZ
+No match
+
+/^\p{Any}*X/8
+    XYZ
+ 0: X
+    AXYZ
+ 0: AX
+    \x{1234}XYZ
+ 0: \x{1234}X
+    A\x{1234}XYZ
+ 0: A\x{1234}X
+    ** Failers
+No match
+
+/^\P{Any}*X/8
+    XYZ
+ 0: X
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ
+No match
+    A\x{1234}XYZ
+No match
+
+/^[\p{Any}]X/8
+    AXYZ
+ 0: AX
+    \x{1234}XYZ 
+ 0: \x{1234}X
+    ** Failers
+No match
+    X  
+No match
+    
+/^[\P{Any}]X/8
+    ** Failers
+No match
+    AX
+No match
+    
+/^[\p{Any}]?X/8
+    XYZ
+ 0: X
+    AXYZ
+ 0: AX
+    \x{1234}XYZ 
+ 0: \x{1234}X
+    ** Failers
+No match
+    ABXYZ   
+No match
+
+/^[\P{Any}]?X/8
+    XYZ
+ 0: X
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ 
+No match
+    ABXYZ   
+No match
+
+/^[\p{Any}]+X/8
+    AXYZ
+ 0: AX
+    \x{1234}XYZ
+ 0: \x{1234}X
+    A\x{1234}XYZ
+ 0: A\x{1234}X
+    ** Failers
+No match
+    XYZ
+No match
+
+/^[\P{Any}]+X/8
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ
+No match
+    A\x{1234}XYZ
+No match
+    XYZ
+No match
+
+/^[\p{Any}]*X/8
+    XYZ
+ 0: X
+    AXYZ
+ 0: AX
+    \x{1234}XYZ
+ 0: \x{1234}X
+    A\x{1234}XYZ
+ 0: A\x{1234}X
+    ** Failers
+No match
+
+/^[\P{Any}]*X/8
+    XYZ
+ 0: X
+    ** Failers
+No match
+    AXYZ
+No match
+    \x{1234}XYZ
+No match
+    A\x{1234}XYZ
+No match
+
+/^\p{Any}{3,5}?/8
+    abcdefgh
+ 0: abcde
+ 1: abcd
+ 2: abc
+    \x{1234}\n\r\x{3456}xyz 
+ 0: \x{1234}\x{0a}\x{0d}\x{3456}x
+ 1: \x{1234}\x{0a}\x{0d}\x{3456}
+ 2: \x{1234}\x{0a}\x{0d}
+
+/^\p{Any}{3,5}/8
+    abcdefgh
+ 0: abcde
+ 1: abcd
+ 2: abc
+    \x{1234}\n\r\x{3456}xyz 
+ 0: \x{1234}\x{0a}\x{0d}\x{3456}x
+ 1: \x{1234}\x{0a}\x{0d}\x{3456}
+ 2: \x{1234}\x{0a}\x{0d}
+
+/^\P{Any}{3,5}?/8
+    ** Failers
+No match
+    abcdefgh
+No match
+    \x{1234}\n\r\x{3456}xyz 
+No match
+
+/^\p{L&}X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     \x{1c5}XY
+ 0: \x{1c5}X
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^[\p{L&}]X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     \x{1c5}XY
+ 0: \x{1c5}X
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^\p{L&}+X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     AbcdeXyz 
+ 0: AbcdeX
+     \x{1c5}AbXY
+ 0: \x{1c5}AbX
+     abcDEXypqreXlmn 
+ 0: abcDEXypqreX
+ 1: abcDEX
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^[\p{L&}]+X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     AbcdeXyz 
+ 0: AbcdeX
+     \x{1c5}AbXY
+ 0: \x{1c5}AbX
+     abcDEXypqreXlmn 
+ 0: abcDEXypqreX
+ 1: abcDEX
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^\p{L&}+?X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     AbcdeXyz 
+ 0: AbcdeX
+     \x{1c5}AbXY
+ 0: \x{1c5}AbX
+     abcDEXypqreXlmn 
+ 0: abcDEXypqreX
+ 1: abcDEX
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^[\p{L&}]+?X/8
+     AXY
+ 0: AX
+     aXY
+ 0: aX
+     AbcdeXyz 
+ 0: AbcdeX
+     \x{1c5}AbXY
+ 0: \x{1c5}AbX
+     abcDEXypqreXlmn 
+ 0: abcDEXypqreX
+ 1: abcDEX
+     ** Failers
+No match
+     \x{1bb}XY
+No match
+     \x{2b0}XY
+No match
+     !XY      
+No match
+
+/^\P{L&}X/8
+     !XY
+ 0: !X
+     \x{1bb}XY
+ 0: \x{1bb}X
+     \x{2b0}XY
+ 0: \x{2b0}X
+     ** Failers
+No match
+     \x{1c5}XY
+No match
+     AXY      
+No match
+
+/^[\P{L&}]X/8
+     !XY
+ 0: !X
+     \x{1bb}XY
+ 0: \x{1bb}X
+     \x{2b0}XY
+ 0: \x{2b0}X
+     ** Failers
+No match
+     \x{1c5}XY
+No match
+     AXY      
+No match
+
+/^\x{023a}+?(\x{0130}+)/8i
+  \x{023a}\x{2c65}\x{0130}
+ 0: \x{23a}\x{2c65}\x{130}
+  
+/^\x{023a}+([^X])/8i
+  \x{023a}\x{2c65}X
+ 0: \x{23a}\x{2c65}
+ 
+/\x{c0}+\x{116}+/8i
+    \x{c0}\x{e0}\x{116}\x{117}
+ 0: \x{c0}\x{e0}\x{116}\x{117}
+ 1: \x{c0}\x{e0}\x{116}
+
+/[\x{c0}\x{116}]+/8i
+    \x{c0}\x{e0}\x{116}\x{117}
+ 0: \x{c0}\x{e0}\x{116}\x{117}
+ 1: \x{c0}\x{e0}\x{116}
+ 2: \x{c0}\x{e0}
+ 3: \x{c0}
+
+/Check property support in non-UTF-8 mode/
+ 
+/\p{L}{4}/
+    123abcdefg
+ 0: abcd
+    123abc\xc4\xc5zz
+ 0: abc\xc4
+
+/\p{Carian}\p{Cham}\p{Kayah_Li}\p{Lepcha}\p{Lycian}\p{Lydian}\p{Ol_Chiki}\p{Rejang}\p{Saurashtra}\p{Sundanese}\p{Vai}/8
+    \x{102A4}\x{AA52}\x{A91D}\x{1C46}\x{10283}\x{1092E}\x{1C6B}\x{A93B}\x{A8BF}\x{1BA0}\x{A50A}====
+ 0: \x{102a4}\x{aa52}\x{a91d}\x{1c46}\x{10283}\x{1092e}\x{1c6b}\x{a93b}\x{a8bf}\x{1ba0}\x{a50a}
+
+/\x{a77d}\x{1d79}/8i
+    \x{a77d}\x{1d79}
+ 0: \x{a77d}\x{1d79}
+    \x{1d79}\x{a77d} 
+ 0: \x{1d79}\x{a77d}
+
+/\x{a77d}\x{1d79}/8
+    \x{a77d}\x{1d79}
+ 0: \x{a77d}\x{1d79}
+    ** Failers 
+No match
+    \x{1d79}\x{a77d} 
+No match
+
+/ End / 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/wintestinput3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,91 @@
+/^[\w]+/
+    *** Failers
+    École
+
+/^[\w]+/Lfrench
+    École
+
+/^[\w]+/
+    *** Failers
+    École
+
+/^[\W]+/
+    École
+
+/^[\W]+/Lfrench
+    *** Failers
+    École
+
+/[\b]/
+    \b
+    *** Failers
+    a
+
+/[\b]/Lfrench
+    \b
+    *** Failers
+    a
+
+/^\w+/
+    *** Failers
+    École
+
+/^\w+/Lfrench
+    École
+
+/(.+)\b(.+)/
+    École
+
+/(.+)\b(.+)/Lfrench
+    *** Failers
+    École
+
+/École/i
+    École
+    *** Failers
+    école
+
+/École/iLfrench
+    École
+    école
+
+/\w/IS
+
+/\w/ISLfrench
+
+/^[\xc8-\xc9]/iLfrench
+    École
+    école
+
+/^[\xc8-\xc9]/Lfrench
+    École
+    *** Failers 
+    école
+
+/\W+/Lfrench
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/[\W]+/Lfrench
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/[^[:alpha:]]+/Lfrench
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/\w+/Lfrench
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/[\w]+/Lfrench
+    >>>\xaa<<<
+    >>>\xba<<< 
+
+/[[:alpha:]]+/Lfrench
+    >>>\xaa<<<
+    >>>\xba<<< 
+    
+/[[:alpha:]][[:lower:]][[:upper:]]/DZLfrench 
+
+/ End of testinput3 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/testdata/wintestoutput3	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,164 @@
+/^[\w]+/
+    *** Failers
+No match
+    École
+No match
+
+/^[\w]+/Lfrench
+    École
+ 0: École
+
+/^[\w]+/
+    *** Failers
+No match
+    École
+No match
+
+/^[\W]+/
+    École
+ 0: \xc9
+
+/^[\W]+/Lfrench
+    *** Failers
+ 0: *** 
+    École
+No match
+
+/[\b]/
+    \b
+ 0: \x08
+    *** Failers
+No match
+    a
+No match
+
+/[\b]/Lfrench
+    \b
+ 0: \x08
+    *** Failers
+No match
+    a
+No match
+
+/^\w+/
+    *** Failers
+No match
+    École
+No match
+
+/^\w+/Lfrench
+    École
+ 0: École
+
+/(.+)\b(.+)/
+    École
+ 0: \xc9cole
+ 1: \xc9
+ 2: cole
+
+/(.+)\b(.+)/Lfrench
+    *** Failers
+ 0: *** Failers
+ 1: *** 
+ 2: Failers
+    École
+No match
+
+/École/i
+    École
+ 0: \xc9cole
+    *** Failers
+No match
+    école
+No match
+
+/École/iLfrench
+    École
+ 0: École
+    école
+ 0: école
+
+/\w/IS
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P 
+  Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z 
+
+/\w/ISLfrench
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Starting byte set: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P 
+  Q R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u v w x y z 
+  ƒ Š Œ Ž š œ ž Ÿ ª ² ³ µ ¹ º À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö 
+  Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý 
+  þ ÿ 
+
+/^[\xc8-\xc9]/iLfrench
+    École
+ 0: É
+    école
+ 0: é
+
+/^[\xc8-\xc9]/Lfrench
+    École
+ 0: É
+    *** Failers 
+No match
+    école
+No match
+
+/\W+/Lfrench
+    >>>\xaa<<<
+ 0: >>>
+    >>>\xba<<< 
+ 0: >>>
+
+/[\W]+/Lfrench
+    >>>\xaa<<<
+ 0: >>>
+    >>>\xba<<< 
+ 0: >>>
+
+/[^[:alpha:]]+/Lfrench
+    >>>\xaa<<<
+ 0: >>>
+    >>>\xba<<< 
+ 0: >>>
+
+/\w+/Lfrench
+    >>>\xaa<<<
+ 0: ª
+    >>>\xba<<< 
+ 0: º
+
+/[\w]+/Lfrench
+    >>>\xaa<<<
+ 0: ª
+    >>>\xba<<< 
+ 0: º
+
+/[[:alpha:]]+/Lfrench
+    >>>\xaa<<<
+ 0: ª
+    >>>\xba<<< 
+ 0: º
+    
+/[[:alpha:]][[:lower:]][[:upper:]]/DZLfrench 
+------------------------------------------------------------------
+        Bra
+        [A-Za-z\x83\x8a\x8c\x8e\x9a\x9c\x9e\x9f\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\xff]
+        [a-z\x83\x9a\x9c\x9e\xaa\xb5\xba\xdf-\xf6\xf8-\xff]
+        [A-Z\x8a\x8c\x8e\x9f\xc0-\xd6\xd8-\xde]
+        Ket
+        End
+------------------------------------------------------------------
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+
+/ End of testinput3 /
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/pcre/ucp.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,146 @@
+/*************************************************
+*          Unicode Property Table handler        *
+*************************************************/
+
+#ifndef _UCP_H
+#define _UCP_H
+
+/* This file contains definitions of the property values that are returned by
+the function _pcre_ucp_findprop(). New values that are added for new releases
+of Unicode should always be at the end of each enum, for backwards
+compatibility. */
+
+/* These are the general character categories. */
+
+enum {
+  ucp_C,     /* Other */
+  ucp_L,     /* Letter */
+  ucp_M,     /* Mark */
+  ucp_N,     /* Number */
+  ucp_P,     /* Punctuation */
+  ucp_S,     /* Symbol */
+  ucp_Z      /* Separator */
+};
+
+/* These are the particular character types. */
+
+enum {
+  ucp_Cc,    /* Control */
+  ucp_Cf,    /* Format */
+  ucp_Cn,    /* Unassigned */
+  ucp_Co,    /* Private use */
+  ucp_Cs,    /* Surrogate */
+  ucp_Ll,    /* Lower case letter */
+  ucp_Lm,    /* Modifier letter */
+  ucp_Lo,    /* Other letter */
+  ucp_Lt,    /* Title case letter */
+  ucp_Lu,    /* Upper case letter */
+  ucp_Mc,    /* Spacing mark */
+  ucp_Me,    /* Enclosing mark */
+  ucp_Mn,    /* Non-spacing mark */
+  ucp_Nd,    /* Decimal number */
+  ucp_Nl,    /* Letter number */
+  ucp_No,    /* Other number */
+  ucp_Pc,    /* Connector punctuation */
+  ucp_Pd,    /* Dash punctuation */
+  ucp_Pe,    /* Close punctuation */
+  ucp_Pf,    /* Final punctuation */
+  ucp_Pi,    /* Initial punctuation */
+  ucp_Po,    /* Other punctuation */
+  ucp_Ps,    /* Open punctuation */
+  ucp_Sc,    /* Currency symbol */
+  ucp_Sk,    /* Modifier symbol */
+  ucp_Sm,    /* Mathematical symbol */
+  ucp_So,    /* Other symbol */
+  ucp_Zl,    /* Line separator */
+  ucp_Zp,    /* Paragraph separator */
+  ucp_Zs     /* Space separator */
+};
+
+/* These are the script identifications. */
+
+enum {
+  ucp_Arabic,
+  ucp_Armenian,
+  ucp_Bengali,
+  ucp_Bopomofo,
+  ucp_Braille,
+  ucp_Buginese,
+  ucp_Buhid,
+  ucp_Canadian_Aboriginal,
+  ucp_Cherokee,
+  ucp_Common,
+  ucp_Coptic,
+  ucp_Cypriot,
+  ucp_Cyrillic,
+  ucp_Deseret,
+  ucp_Devanagari,
+  ucp_Ethiopic,
+  ucp_Georgian,
+  ucp_Glagolitic,
+  ucp_Gothic,
+  ucp_Greek,
+  ucp_Gujarati,
+  ucp_Gurmukhi,
+  ucp_Han,
+  ucp_Hangul,
+  ucp_Hanunoo,
+  ucp_Hebrew,
+  ucp_Hiragana,
+  ucp_Inherited,
+  ucp_Kannada,
+  ucp_Katakana,
+  ucp_Kharoshthi,
+  ucp_Khmer,
+  ucp_Lao,
+  ucp_Latin,
+  ucp_Limbu,
+  ucp_Linear_B,
+  ucp_Malayalam,
+  ucp_Mongolian,
+  ucp_Myanmar,
+  ucp_New_Tai_Lue,
+  ucp_Ogham,
+  ucp_Old_Italic,
+  ucp_Old_Persian,
+  ucp_Oriya,
+  ucp_Osmanya,
+  ucp_Runic,
+  ucp_Shavian,
+  ucp_Sinhala,
+  ucp_Syloti_Nagri,
+  ucp_Syriac,
+  ucp_Tagalog,
+  ucp_Tagbanwa,
+  ucp_Tai_Le,
+  ucp_Tamil,
+  ucp_Telugu,
+  ucp_Thaana,
+  ucp_Thai,
+  ucp_Tibetan,
+  ucp_Tifinagh,
+  ucp_Ugaritic,
+  ucp_Yi,
+  /* New for Unicode 5.0: */
+  ucp_Balinese,
+  ucp_Cuneiform,
+  ucp_Nko,
+  ucp_Phags_Pa,
+  ucp_Phoenician,
+  /* New for Unicode 5.1: */
+  ucp_Carian,
+  ucp_Cham,
+  ucp_Kayah_Li,
+  ucp_Lepcha,
+  ucp_Lycian,
+  ucp_Lydian,
+  ucp_Ol_Chiki,
+  ucp_Rejang,
+  ucp_Saurashtra,
+  ucp_Sundanese,
+  ucp_Vai
+};
+
+#endif
+
+/* End of ucp.h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/src/pcre_chartables.c	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,198 @@
+/*************************************************
+*      Perl-Compatible Regular Expressions       *
+*************************************************/
+
+/* This file contains character tables that are used when no external tables
+are passed to PCRE by the application that calls it. The tables are used only
+for characters whose code values are less than 256.
+
+This is a default version of the tables that assumes ASCII encoding. A program
+called dftables (which is distributed with PCRE) can be used to build
+alternative versions of this file. This is necessary if you are running in an
+EBCDIC environment, or if you want to default to a different encoding, for
+example ISO-8859-1. When dftables is run, it creates these tables in the
+current locale. If PCRE is configured with --enable-rebuild-chartables, this
+happens automatically.
+
+The following #includes are present because without the gcc 4.x may remove the
+array definition from the final binary if PCRE is built into a static library
+and dead code stripping is activated. This leads to link errors. Pulling in the
+header ensures that the array gets flagged as "someone outside this compilation
+unit might reference this" and so it will always be supplied to the linker. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+const unsigned char _pcre_default_tables[] = {
+
+/* This table is a lower casing table. */
+
+    0,  1,  2,  3,  4,  5,  6,  7,
+    8,  9, 10, 11, 12, 13, 14, 15,
+   16, 17, 18, 19, 20, 21, 22, 23,
+   24, 25, 26, 27, 28, 29, 30, 31,
+   32, 33, 34, 35, 36, 37, 38, 39,
+   40, 41, 42, 43, 44, 45, 46, 47,
+   48, 49, 50, 51, 52, 53, 54, 55,
+   56, 57, 58, 59, 60, 61, 62, 63,
+   64, 97, 98, 99,100,101,102,103,
+  104,105,106,107,108,109,110,111,
+  112,113,114,115,116,117,118,119,
+  120,121,122, 91, 92, 93, 94, 95,
+   96, 97, 98, 99,100,101,102,103,
+  104,105,106,107,108,109,110,111,
+  112,113,114,115,116,117,118,119,
+  120,121,122,123,124,125,126,127,
+  128,129,130,131,132,133,134,135,
+  136,137,138,139,140,141,142,143,
+  144,145,146,147,148,149,150,151,
+  152,153,154,155,156,157,158,159,
+  160,161,162,163,164,165,166,167,
+  168,169,170,171,172,173,174,175,
+  176,177,178,179,180,181,182,183,
+  184,185,186,187,188,189,190,191,
+  192,193,194,195,196,197,198,199,
+  200,201,202,203,204,205,206,207,
+  208,209,210,211,212,213,214,215,
+  216,217,218,219,220,221,222,223,
+  224,225,226,227,228,229,230,231,
+  232,233,234,235,236,237,238,239,
+  240,241,242,243,244,245,246,247,
+  248,249,250,251,252,253,254,255,
+
+/* This table is a case flipping table. */
+
+    0,  1,  2,  3,  4,  5,  6,  7,
+    8,  9, 10, 11, 12, 13, 14, 15,
+   16, 17, 18, 19, 20, 21, 22, 23,
+   24, 25, 26, 27, 28, 29, 30, 31,
+   32, 33, 34, 35, 36, 37, 38, 39,
+   40, 41, 42, 43, 44, 45, 46, 47,
+   48, 49, 50, 51, 52, 53, 54, 55,
+   56, 57, 58, 59, 60, 61, 62, 63,
+   64, 97, 98, 99,100,101,102,103,
+  104,105,106,107,108,109,110,111,
+  112,113,114,115,116,117,118,119,
+  120,121,122, 91, 92, 93, 94, 95,
+   96, 65, 66, 67, 68, 69, 70, 71,
+   72, 73, 74, 75, 76, 77, 78, 79,
+   80, 81, 82, 83, 84, 85, 86, 87,
+   88, 89, 90,123,124,125,126,127,
+  128,129,130,131,132,133,134,135,
+  136,137,138,139,140,141,142,143,
+  144,145,146,147,148,149,150,151,
+  152,153,154,155,156,157,158,159,
+  160,161,162,163,164,165,166,167,
+  168,169,170,171,172,173,174,175,
+  176,177,178,179,180,181,182,183,
+  184,185,186,187,188,189,190,191,
+  192,193,194,195,196,197,198,199,
+  200,201,202,203,204,205,206,207,
+  208,209,210,211,212,213,214,215,
+  216,217,218,219,220,221,222,223,
+  224,225,226,227,228,229,230,231,
+  232,233,234,235,236,237,238,239,
+  240,241,242,243,244,245,246,247,
+  248,249,250,251,252,253,254,255,
+
+/* This table contains bit maps for various character classes. Each map is 32
+bytes long and the bits run from the least significant end of each byte. The
+classes that have their own maps are: space, xdigit, digit, upper, lower, word,
+graph, print, punct, and cntrl. Other classes are built from combinations. */
+
+  0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
+  0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
+  0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,
+  0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/* This table identifies various classes of character by individual bits:
+  0x01   white space character
+  0x02   letter
+  0x04   decimal digit
+  0x08   hexadecimal digit
+  0x10   alphanumeric or '_'
+  0x80   regular expression metacharacter or binary zero
+*/
+
+  0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7 */
+  0x00,0x01,0x01,0x00,0x01,0x01,0x00,0x00, /*   8- 15 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */
+  0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /*    - '  */
+  0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /*  ( - /  */
+  0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /*  0 - 7  */
+  0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /*  8 - ?  */
+  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  @ - G  */
+  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  H - O  */
+  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  P - W  */
+  0x12,0x12,0x12,0x80,0x80,0x00,0x80,0x10, /*  X - _  */
+  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  ` - g  */
+  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  h - o  */
+  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  p - w  */
+  0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /*  x -127 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
+
+/* End of pcre_chartables.c */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/libpcre/src/pcredllmain.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,66 @@
+// pcredllmain.cpp
+//
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+//  Include Files  
+#include <e32std.h>		 // GLDEF_C
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pcre_internal.h"
+
+//  Exported Functions
+
+PCRE_EXP_DEFN void* PCRE_CALL_CONVENTION pcre_malloc(size_t nBytes)
+	{
+	return User::Alloc(nBytes);
+	}
+
+PCRE_EXP_DEFN void PCRE_CALL_CONVENTION pcre_free(void* p)
+	{
+	User::Free(p);
+	}
+
+PCRE_EXP_DEFN void* PCRE_CALL_CONVENTION pcre_stack_malloc(size_t nBytes)
+	{
+	return User::Alloc(nBytes);
+	}
+
+PCRE_EXP_DEFN void PCRE_CALL_CONVENTION pcre_stack_free(void* p)
+	{
+	User::Free(p);
+	}
+
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION pcre_callout(pcre_callout_block *)
+	{
+	return 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/src/cregex.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1522 @@
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+
+// Heavily refactored for Symbian OS by Accenture.
+
+#define PCRE_EXP_DECL IMPORT_C // We need to define this because the config.h that defines it when building libpcre isn't exported.
+
+#include <fshell/descriptorutils.h>
+#include "pcre.h"
+#include "cregex.h"
+#include "tregexarg.h"
+
+/**
+ * Maximum number of optional arguments supported by the matching interface.
+ * If more arguments are required then use the more generic DoMatchL() function.
+ */
+static const TInt KMaxArgs = 4;
+
+/**
+ * Multiplier used to calculate size of vector that stores results from PCRE.
+ * @see KVecSize
+ */
+static const TInt KPcreWorkspaceMultiplier = 3;
+
+/**
+* "The first two-thirds of the vector is used to pass back captured subpatterns,
+* each subpattern using a pair of integers. The remaining third of the vector
+* is used as workspace by pcre_exec() while matching capturing subpatterns,
+* and is not available for passing back information. The number passed in 
+* vecsize should always be a multiple of three. If it is not, it is rounded
+* down."
+*/ 
+static const TInt KVecSize = (1 + KMaxArgs) * KPcreWorkspaceMultiplier;
+
+/**
+ * Number of characters in a triplet escape sequence.
+ */
+static const TInt KEscapeTripletLength = 3;
+
+/**
+ * Number of characters to reserve for escape sequences
+ * Reserves enough room for several.
+ */
+static const TInt KReserveForEscapeChars = KEscapeTripletLength * 4;
+
+
+// Public Functions //
+
+/**
+ * 2-Phase constructor for CRegEx objects.
+ * @param aPattern regular expression pattern
+ * @return a pre-compiled regular expression object ready to perform matching.
+ */
+EXPORT_C CRegEx* CRegEx::NewL(const TDesC8& aPattern)
+	{
+	CRegEx* self = NewLC(aPattern);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+ * 2-Phase constructor for CRegEx objects.
+ * @param aPattern regular expression pattern.
+ * @param aOptions options to use when compiling regular expression.
+ * @return a pre-compiled regular expression object ready to perform matching.
+ */
+EXPORT_C CRegEx* CRegEx::NewL(const TDesC8& aPattern,
+	const TRegExOptions& aOptions)
+	{
+	CRegEx* self = NewLC(aPattern, aOptions);
+	CleanupStack::Pop(self);
+	return self;	
+	}
+
+/**
+ * 2-Phase constructor for CRegEx objects. Object is left on the cleanup stack.
+ * @param aPattern regular expression pattern.
+ * @return a pre-compiled regular expression object ready to perform matching.
+ */
+EXPORT_C CRegEx* CRegEx::NewLC(const TDesC8& aPattern)
+	{
+	CRegEx* self = new(ELeave) CRegEx();
+	CleanupStack::PushL(self);
+	self->ConstructL(aPattern);
+	return self;
+	}
+
+/**
+ * 2-Phase constructor for CRegEx objects. Object is left on the cleanup stack.
+ * @param aPattern regular expression pattern.
+ * @param aOptions options to use when compiling regular expression.
+ * @return a pre-compiled regular expression object ready to perform matching.
+ */
+EXPORT_C CRegEx* CRegEx::NewLC(const TDesC8& aPattern,
+	const TRegExOptions& aOptions)
+	{
+	CRegEx* self = new(ELeave) CRegEx(aOptions);
+	CleanupStack::PushL(self);
+	self->ConstructL(aPattern);
+	return self;	
+	}
+
+EXPORT_C CRegEx* CRegEx::NewL(const TDesC16& aPattern, const TRegExOptions& aOptions)
+	{
+	CRegEx* self = new(ELeave) CRegEx(aOptions);
+	CleanupStack::PushL(self);
+	self->ConstructL(aPattern);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+/**
+ * Standard destructor to free resources.
+ */
+EXPORT_C CRegEx::~CRegEx()
+	{
+	delete iNoArg;
+	delete iPattern;
+	Cleanup();
+	}
+
+// Public matching interface //
+
+/**
+ * Checks if the regular expression (RE) matches the supplied text entirely.
+ * @param aText the text to match against the regular expression.
+ * @return ETrue if the RE matches the supplied text entirely, EFalse otherwise.
+ * @see PartialMatchL()
+ */
+EXPORT_C TBool CRegEx::FullMatchL(const TDesC8& aText) const
+	{
+	return FullMatchL(aText, *iNoArg, *iNoArg, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Checks if the regular expression (RE) matches the supplied text entirely.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @return ETrue if the RE matches the supplied text entirely, EFalse otherwise.
+ * @see PartialMatchL()
+ */
+EXPORT_C TBool CRegEx::FullMatchL(const TDesC8& aText,
+		  const TRegExArg& aArg1) const
+	{
+	return FullMatchL(aText, aArg1, *iNoArg, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Checks if the regular expression (RE) matches the supplied text entirely.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @return ETrue if the RE matches the supplied text entirely, EFalse otherwise.
+ * @see PartialMatchL()
+ */
+EXPORT_C TBool CRegEx::FullMatchL(const TDesC8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2) const
+	{
+	return FullMatchL(aText, aArg1, aArg2, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Checks if the regular expression (RE) matches the supplied text entirely.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @return ETrue if the RE matches the supplied text entirely, EFalse otherwise.
+ * @see PartialMatchL()
+ */
+EXPORT_C TBool CRegEx::FullMatchL(const TDesC8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3) const
+	{
+	return FullMatchL(aText, aArg1, aArg2, aArg3, *iNoArg);
+	}
+
+/**
+ * Checks if the regular expression (RE) matches the supplied text entirely.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @param aArg4 contains the fourth extracted subpattern.
+ * @return ETrue if the RE matches the supplied text entirely, EFalse otherwise.
+ * @see PartialMatchL()
+ */
+EXPORT_C TBool CRegEx::FullMatchL(const TDesC8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3,
+		  const TRegExArg& aArg4) const
+	{
+	RPointerArray<const TRegExArg> args;
+	CleanupClosePushL(args);
+	args.ReserveL(KMaxArgs);
+	
+	if (&aArg1 != iNoArg)
+		{
+		args.AppendL(&aArg1);
+		}
+	if (&aArg2 != iNoArg)
+		{
+		args.AppendL(&aArg2);		
+		}
+	if (&aArg3 != iNoArg)
+		{
+		args.AppendL(&aArg3);		
+		}
+	if (&aArg4 != iNoArg)
+		{
+		args.AppendL(&aArg4);		
+		}
+	
+	TInt consumed = 0;
+	TInt vector[KVecSize];
+	
+	TBool r =  DoMatchImpl(aText, EAnchorBoth, consumed, args, vector, KVecSize);
+	CleanupStack::PopAndDestroy(&args);
+	return r;
+	}
+
+/**
+ * Checks if the regular expression (RE) matches any substring of the text.
+ * @param aText the text to match against the regular expression.
+ * @return ETrue if the RE  matches any substring of the supplied text,
+ * EFalse otherwise.
+ * @see FullMatchL()
+ */
+EXPORT_C TBool CRegEx::PartialMatchL(const TDesC8& aText) const
+	{
+	return PartialMatchL(aText, *iNoArg, *iNoArg, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Checks if the regular expression (RE) matches any substring of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @return ETrue if the RE  matches any substring of the supplied text,
+ * EFalse otherwise.
+ * @see FullMatchL()
+ */
+EXPORT_C TBool CRegEx::PartialMatchL(const TDesC8& aText,
+		  const TRegExArg& aArg1) const
+	{
+	return PartialMatchL(aText, aArg1, *iNoArg, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Checks if the regular expression (RE) matches any substring of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @return ETrue if the RE  matches any substring of the supplied text,
+ * EFalse otherwise.
+ * @see FullMatchL()
+ */
+EXPORT_C TBool CRegEx::PartialMatchL(const TDesC8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2) const
+	{
+	return PartialMatchL(aText, aArg1, aArg2, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Checks if the regular expression (RE) matches any substring of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @return ETrue if the RE  matches any substring of the supplied text,
+ * EFalse otherwise.
+ * @see FullMatchL()
+ */
+EXPORT_C TBool CRegEx::PartialMatchL(const TDesC8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3) const
+	{
+	return PartialMatchL(aText, aArg1, aArg2, aArg3, *iNoArg);
+	}
+
+/**
+ * Checks if the regular expression (RE) matches any substring of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @param aArg4 contains the fourth extracted subpattern. 
+ * @return ETrue if the RE  matches any substring of the supplied text,
+ * EFalse otherwise.
+ * @see FullMatchL()
+ */
+EXPORT_C TBool CRegEx::PartialMatchL(const TDesC8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3,
+		  const TRegExArg& aArg4) const
+	{
+	RPointerArray<const TRegExArg> args;
+	CleanupClosePushL(args);
+	args.ReserveL(KMaxArgs);
+
+	if (&aArg1 != iNoArg)
+		{
+		args.AppendL(&aArg1);
+		}
+	if (&aArg2 != iNoArg)
+		{
+		args.AppendL(&aArg2);		
+		}
+	if (&aArg3 != iNoArg)
+		{
+		args.AppendL(&aArg3);		
+		}
+	if (&aArg4 != iNoArg)
+		{
+		args.AppendL(&aArg4);		
+		}
+	
+	TInt consumed = 0;
+	TInt vector[KVecSize];
+	
+	TBool r =  DoMatchImpl(aText, EUnanchored, consumed, args, vector,
+					KVecSize);
+	CleanupStack::PopAndDestroy(&args);
+	return r;
+	}
+
+
+/**
+ * General function to perform a regular expression (RE) match on a substring
+ * of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aAnchor the type of match to perform
+ * @return ETrue if the RE  matches a substring of the supplied text,
+ * EFalse otherwise.
+ */
+EXPORT_C TBool CRegEx::DoMatchL(const TDesC8& aText,
+		  TAnchor aAnchor,
+		  TInt&	aConsumed) const
+	{
+	return DoMatchL(aText, aAnchor, aConsumed, *iNoArg, *iNoArg, *iNoArg,
+				*iNoArg);
+	}
+
+/**
+ * General function to perform a regular expression (RE) match on a substring
+ * of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aAnchor the type of match to perform
+ * @param aArg1 contains the first extracted subpattern.
+ * @return ETrue if the RE  matches a substring of the supplied text,
+ * EFalse otherwise.
+ */
+EXPORT_C TBool CRegEx::DoMatchL(const TDesC8& aText,
+		  TAnchor aAnchor,
+		  TInt&	aConsumed,
+		  const TRegExArg& aArg1) const
+	{
+	return DoMatchL(aText, aAnchor, aConsumed, aArg1, *iNoArg, *iNoArg,
+				*iNoArg);
+	}
+
+/**
+ * General function to perform a regular expression (RE) match on a substring
+ * of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aAnchor the type of match to perform
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @return ETrue if the RE  matches a substring of the supplied text,
+ * EFalse otherwise.
+ */
+EXPORT_C TBool CRegEx::DoMatchL(const TDesC8& aText,
+		  TAnchor aAnchor,
+		  TInt&	aConsumed,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2) const
+	{
+	return DoMatchL(aText, aAnchor, aConsumed, aArg1, aArg2, *iNoArg, *iNoArg);
+	}
+
+/**
+ * General function to perform a regular expression (RE) match on a substring
+ * of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aAnchor the type of match to perform
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @return ETrue if the RE  matches a substring of the supplied text,
+ * EFalse otherwise.
+ */
+EXPORT_C TBool CRegEx::DoMatchL(const TDesC8& aText,
+		  TAnchor aAnchor,
+		  TInt&	aConsumed,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3) const
+	{
+	return DoMatchL(aText, aAnchor, aConsumed, aArg1, aArg2, aArg3, *iNoArg);
+	}
+
+/**
+ * General function to perform a regular expression (RE) match on a substring
+ * of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aAnchor the type of match to perform
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @param aArg4 contains the fourth extracted subpattern. 
+ * @return ETrue if the RE  matches a substring of the supplied text,
+ * EFalse otherwise.
+ */
+EXPORT_C TBool CRegEx::DoMatchL(const TDesC8& aText,
+		  TAnchor aAnchor,
+		  TInt&	aConsumed,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3,
+		  const TRegExArg& aArg4) const
+	{
+	RPointerArray<const TRegExArg> args;
+	CleanupClosePushL(args);
+	args.ReserveL(KMaxArgs);
+	
+	if (&aArg1 != iNoArg)
+		{
+		args.AppendL(&aArg1);
+		}
+	if (&aArg2 != iNoArg)
+		{
+		args.AppendL(&aArg2);		
+		}
+	if (&aArg3 != iNoArg)
+		{
+		args.AppendL(&aArg3);		
+		}
+	if (&aArg4 != iNoArg)
+		{
+		args.AppendL(&aArg4);		
+		}	
+
+	TInt r = DoMatchL(aText, aAnchor, aConsumed, args);
+	CleanupStack::PopAndDestroy(&args);
+	return r;
+	}
+
+/**
+ * General function to perform a regular expression (RE) match on a substring
+ * of the text.
+ * @param aText the text to match against the regular expression.
+ * @param aAnchor the type of match to perform
+ * @param array of arguments that will contain the extracted subpatterns.
+ * @return ETrue if the RE  matches a substring of the supplied text,
+ * EFalse otherwise.
+ */
+EXPORT_C TBool CRegEx::DoMatchL(const TDesC8& aText,
+		  TAnchor aAnchor,
+		  TInt&	aConsumed,			
+		  const RPointerArray<const TRegExArg>& aArgs) const
+	{
+	const TInt vectorSize = (1 + aArgs.Count()) * KPcreWorkspaceMultiplier;
+	TInt* vector = new( ELeave ) TInt[ vectorSize ];
+	CleanupArrayDeletePushL( vector );	
+	
+	TBool r =  DoMatchImpl(aText, aAnchor, aConsumed, aArgs, vector,
+					vectorSize);
+	CleanupStack::PopAndDestroy(vector);
+	return r;	
+	}
+
+/**
+ * Allows text to be scanned incrementally. Call this function repeatidly to
+ * match regular expressions at the front of a string and skip over them as
+ * they match. 
+ * @param aText the text to match against the regular expression.
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see FindAndConsumeL()
+ */
+EXPORT_C TBool CRegEx::ConsumeL(TDes8& aText) const
+	{
+	return ConsumeL(aText, *iNoArg, *iNoArg, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match regular expressions at the front of a string and skip over them as
+ * they match. 
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see FindAndConsumeL()
+ */
+EXPORT_C TBool CRegEx::ConsumeL(TDes8& aText,
+		  const TRegExArg& aArg1) const
+	{
+	return ConsumeL(aText, aArg1, *iNoArg, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match regular expressions at the front of a string and skip over them as
+ * they match. 
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see FindAndConsumeL()
+ */
+EXPORT_C TBool CRegEx::ConsumeL(TDes8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2) const
+	{
+	return ConsumeL(aText, aArg1, aArg2, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match regular expressions at the front of a string and skip over them as
+ * they match. 
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see FindAndConsumeL()
+ */
+EXPORT_C TBool CRegEx::ConsumeL(TDes8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3) const
+	{
+	return ConsumeL(aText, aArg1, aArg2, aArg3, *iNoArg);
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match regular expressions at the front of a string and skip over them as
+ * they match. 
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @param aArg4 contains the fourth extracted subpattern. 
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see FindAndConsumeL()
+ */
+EXPORT_C TBool CRegEx::ConsumeL(TDes8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3,
+		  const TRegExArg& aArg4) const
+	{
+	RPointerArray<const TRegExArg> args;
+	CleanupClosePushL(args);
+	args.ReserveL(KMaxArgs);
+
+	if (&aArg1 != iNoArg)
+		{
+		args.AppendL(&aArg1);
+		}
+	if (&aArg2 != iNoArg)
+		{
+		args.AppendL(&aArg2);		
+		}
+	if (&aArg3 != iNoArg)
+		{
+		args.AppendL(&aArg3);		
+		}
+	if (&aArg4 != iNoArg)
+		{
+		args.AppendL(&aArg4);		
+		}
+	
+	TInt consumed = 0;
+	TInt vector[KVecSize];
+	
+	TBool r =  DoMatchImpl(aText, EAnchorStart, consumed, args, vector,
+					KVecSize);
+	if (r)
+		{
+		// Remove prefix
+		aText.Delete(0, consumed);		
+		}
+	CleanupStack::PopAndDestroy(&args);
+	return r;	
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match  regular expression in a string and extract them as they match.
+ * Unlike ConsumeL, your match is not anchored to the start of the string.
+ * @param aText the text to match against the regular expression.
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see ConsumeL()
+ */
+EXPORT_C TBool CRegEx::FindAndConsumeL(TDes8& aText) const
+	{
+	return FindAndConsumeL(aText, *iNoArg, *iNoArg, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match  regular expression in a string and extract them as they match.
+ * Unlike ConsumeL, your match is not anchored to the start of the string.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see ConsumeL()
+ */
+EXPORT_C TBool CRegEx::FindAndConsumeL(TDes8& aText,
+		  const TRegExArg& aArg1) const
+	{
+	return FindAndConsumeL(aText, aArg1, *iNoArg, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match  regular expression in a string and extract them as they match.
+ * Unlike ConsumeL, your match is not anchored to the start of the string.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see ConsumeL()
+ */
+EXPORT_C TBool CRegEx::FindAndConsumeL(TDes8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2) const
+	{
+	return FindAndConsumeL(aText, aArg1, aArg2, *iNoArg, *iNoArg);
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match  regular expression in a string and extract them as they match.
+ * Unlike ConsumeL, your match is not anchored to the start of the string.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see ConsumeL()
+ */
+EXPORT_C TBool CRegEx::FindAndConsumeL(TDes8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3) const
+	{
+	return FindAndConsumeL(aText, aArg1, aArg2, aArg3, *iNoArg);
+	}
+
+/**
+ * Allows text to be scanned incrementally. Repeatidly call this function to
+ * match  regular expression in a string and extract them as they match.
+ * Unlike ConsumeL, your match is not anchored to the start of the string.
+ * @param aText the text to match against the regular expression.
+ * @param aArg1 contains the first extracted subpattern.
+ * @param aArg2 contains the second extracted subpattern.
+ * @param aArg3 contains the third extracted subpattern.
+ * @param aArg4 contains the fourth extracted subpattern. 
+ * @return ETrue if the RE matched and a substring was consumed,
+ * EFalse otherwise.
+ * @see ConsumeL()
+ */
+EXPORT_C TBool CRegEx::FindAndConsumeL(TDes8& aText,
+		  const TRegExArg& aArg1,
+		  const TRegExArg& aArg2,
+		  const TRegExArg& aArg3,
+		  const TRegExArg& aArg4) const
+	{
+	RPointerArray<const TRegExArg> args;
+	CleanupClosePushL(args);
+	args.ReserveL(KMaxArgs);
+
+	if (&aArg1 != iNoArg)
+		{
+		args.AppendL(&aArg1);
+		}
+	if (&aArg2 != iNoArg)
+		{
+		args.AppendL(&aArg2);		
+		}
+	if (&aArg3 != iNoArg)
+		{
+		args.AppendL(&aArg3);		
+		}
+	if (&aArg4 != iNoArg)
+		{
+		args.AppendL(&aArg4);		
+		}	
+	
+	TInt consumed = 0;
+	TInt vector[KVecSize];
+	
+	TBool r = DoMatchImpl(aText, EUnanchored, consumed, args, vector, KVecSize);
+	CleanupStack::PopAndDestroy(&args);
+	
+	if (r)
+		{
+		// Remove prefix
+		aText.Delete(0, consumed);
+		}
+	
+	return r;
+	}
+
+
+/**
+ * The first match of the regular expression in aString is
+ * replaced by aRewrite.
+ * 
+ * Within aRewrite, backslash-escaped digits (\1 to \9) can be
+ * used to insert text matching a corresponding parenthesized group from
+ * the pattern. \0 in aRewrite refers to the entire matching text.
+ * @param aRewrite the text to replace the matching substring with.
+ * @param aText the text to match against the regular expression.
+ * @return ETrue if match occurred and replace was succsessful,
+ * EFalse otherwise.
+ * @see GlobalReplaceL()
+ */
+EXPORT_C TBool CRegEx::ReplaceL(const TDesC8& aRewrite, TDes8& aString) const
+	{
+	TInt r = EFalse;
+	TInt vector[KVecSize];
+	
+	TInt matches = TryMatch(aString, 0, EUnanchored, vector, KVecSize);
+	if (matches == 0)
+		{
+		return r;
+		}		
+	
+	HBufC8* s = HBufC8::NewLC(aString.MaxLength());
+	TPtr8 pS = s->Des();
+	if (!Rewrite(pS, aRewrite, aString, vector, KVecSize, matches))
+		{
+		CleanupStack::PopAndDestroy(s);
+		return r;
+		}		
+	
+	__ASSERT_DEBUG(vector[0] >= 0, Panic(EInvalidMatchResults));
+	__ASSERT_DEBUG(vector[1] >= 0, Panic(EInvalidMatchResults));
+	
+	TInt replacementLength = vector[1] - vector[0];
+	
+	if((aString.Length() + s->Length() - replacementLength) <= aString.MaxLength())
+		{
+		aString.Replace(vector[0], replacementLength, *s);
+		}
+	else
+		{
+		CleanupStack::PopAndDestroy(s);
+		iErrorCode = KErrRegExOutputTooBig;
+		return r;
+		}
+	
+	CleanupStack::PopAndDestroy(s);
+	r = ETrue;
+	return r;
+	}
+
+/**
+ * All matches of the regular expression in aString are
+ * replaced by aRewrite.
+ * 
+ * Within the rewrite string, backslash-escaped digits (\1 to \9) can be
+ * used to insert text matching a corresponding parenthesized group from
+ * the pattern. \0 in "aRewrite" refers to the entire matching text.
+ * @param aRewrite the text to replace the matching substring with.
+ * @param aText the text to match against the regular expression.
+ * @return ETrue if matches occurred and replace was succsessful,
+ * EFalse otherwise.
+ * @see ReplaceL()
+ */
+EXPORT_C TInt CRegEx::GlobalReplaceL(const TDesC8& aRewrite,
+	TDes8& aString) const	
+	{
+	TInt count = 0;
+	TInt vector[KVecSize];
+	
+	HBufC8* out = HBufC8::NewLC(aString.MaxLength());
+	TPtr8 pOut = out->Des();
+	
+	TInt start = 0;
+	TInt lastend = -1;
+	
+	while (start <= aString.Length())
+		{
+		TInt matches = TryMatch(aString, start, EUnanchored, vector, KVecSize);
+		if (matches <= 0)
+			{
+			break;
+			}			
+		TInt matchstart = vector[0];
+		TInt matchend = vector[1];
+		
+		__ASSERT_DEBUG(matchstart >= start, EInvalidMatchResults);
+		__ASSERT_DEBUG(matchend >= matchstart, EInvalidMatchResults);
+		if (matchstart == matchend && matchstart == lastend)
+			{
+			// advance one character if we matched an empty string at the same
+			// place as the last match occurred
+			matchend = start + 1;
+			// If the current char is CR and we're in CRLF mode, skip LF too.
+			// Note it's better to call pcre_fullinfo() than to examine
+			// all_options(), since options_ could have changed bewteen
+			// compile-time and now, but this is simpler and safe enough.
+			// Modified by PH to add ANY and ANYCRLF.
+			if ((start + 1 < aString.Length()) &&
+					aString[start] == '\r' && aString[start+1] == '\n' &&
+					(NewlineMode(iOptions.AllOptions()) == PCRE_NEWLINE_CRLF ||
+					NewlineMode(iOptions.AllOptions()) == PCRE_NEWLINE_ANY ||
+					NewlineMode(iOptions.AllOptions()) == PCRE_NEWLINE_ANYCRLF))
+				{
+				matchend++;
+				}
+			// We also need to advance more than one char if we're in utf8 mode.
+			#ifdef SUPPORT_UTF8
+			if (iOptions.Utf8())
+				{
+				while ((matchend < aString.Length())
+					&& (aString[matchend] & 0xc0) == 0x80)
+					{
+					matchend++;
+					}					
+				}
+			#endif
+			if (matchend <= aString.Length())
+				{
+				if(pOut.Length() + (matchend - start) <= pOut.MaxLength())
+					{
+					pOut.Append(aString.Mid(start, matchend - start));
+					}
+				else
+					{
+					iErrorCode = KErrRegExOutputTooBig;
+					return KErrRegExOutputTooBig;
+					}
+				}				
+			start = matchend;
+			}
+		else
+			{
+			if(pOut.Length() + (matchstart - start) <= pOut.MaxLength())
+				{
+				pOut.Append(aString.Mid(start, matchstart - start));
+				}
+			else
+				{
+				iErrorCode = KErrRegExOutputTooBig;
+				return KErrRegExOutputTooBig;
+				}
+			Rewrite(pOut, aRewrite, aString, vector, KVecSize, matches);
+			start = matchend;
+			lastend = matchend;
+			count++;
+			}
+		}
+	
+	if (count == 0)
+		{
+		return count;
+		}	
+
+	if (start < aString.Length())
+		{
+		if((aString.Length() - start) + pOut.Length() <= pOut.MaxLength())
+			{
+			pOut.Append(aString.Mid(start, aString.Length() - start));
+			}
+		else
+			{
+			iErrorCode = KErrRegExOutputTooBig;
+			return KErrRegExOutputTooBig;
+			}
+		}
+	
+	aString.Swap(pOut);
+	
+	CleanupStack::PopAndDestroy(out);
+	
+	return count;
+	}
+
+/**
+ * The first match of the regular expression in the supplied string is
+ * replaced by another supplied string and copied into aOut with substitutions.
+ * The non-matching portions of aString are ignored.
+ * 
+ * Within the rewrite string, backslash-escaped digits (\1 to \9) can be
+ * used to insert text matching a corresponding parenthesized group from
+ * the pattern. \0 in "aRewrite" refers to the entire matching text.
+ * @param aRewrite the text to replace the matching substring with.
+ * @param aText the text to match against the regular expression.
+ * @return ETrue if match occurred and extraction was succsessful,
+ * EFalse otherwise.
+ * @see ReplaceL()
+ */
+EXPORT_C TBool CRegEx::ExtractL(const TDesC8& aRewrite,
+					const TDesC8& aText, TDes8& aOut) const
+	{
+	TInt vector[KVecSize];
+	
+	TInt matches = TryMatch(aText, 0, EUnanchored, vector, KVecSize);
+	if (matches == 0)
+		{
+		iErrorCode = KErrRegExZeroMatches;
+		return EFalse;
+		}	
+	aOut.Zero();
+	
+	TBool r = Rewrite(aOut, aRewrite, aText, vector, KVecSize, matches);
+	return r;
+	}
+
+/**
+ * Returns EPcreNewlineAnyCrLf, EPcreNewlineAny, EPcreNewlineCrLf,
+ * EPcreNewlineLf or EPcreNewlineCr
+ * Note that EPcreNewlineCrLf is defined to be EPcreNewlineCr | EPcreNewlineLf.
+ * @param aOptions
+ * @return
+ */
+
+EXPORT_C TInt CRegEx::NewlineMode(TInt aOptions)
+	{
+	// TODO: if we can make it threadsafe, cache this var
+	TInt newlineMode = 0;
+	/* if (newlineMode) return newlineMode; */  // do this once it's cached
+	
+	if (aOptions & (EPcreNewlineCrLf|EPcreNewlineCr|EPcreNewlineLf|
+			EPcreNewlineAny|EPcreNewlineAnyCrLf))
+		{
+		newlineMode = (aOptions &
+				(EPcreNewlineCrLf|EPcreNewlineCr|EPcreNewlineLf|
+						EPcreNewlineAny|EPcreNewlineAnyCrLf));
+		}
+	else
+		{
+		TInt newline;
+		pcre_config(PCRE_CONFIG_NEWLINE, &newline);
+
+		switch(newline)
+			{
+			case KNewLineAnyCrLf:
+				{
+				newlineMode = EPcreNewlineAnyCrLf;
+				break;
+				}			
+			case KNewLineAny:
+				{
+				newlineMode = EPcreNewlineAny;
+				break;
+				}	
+			case KNewLineLf:
+				{
+				newlineMode = EPcreNewlineLf;
+				break;
+				}			
+			case KNewLineCr:
+				{
+				newlineMode = EPcreNewlineCr;
+				break;
+				}
+			case KNewLineCrLf:
+				{
+				newlineMode = EPcreNewlineCrLf;
+				break;
+				}
+			default:
+				{
+				__ASSERT_DEBUG(EFalse, EUnexpectedRetValFromPcre);				
+				}				
+			}		
+		}
+	return newlineMode;
+	}
+
+/** 
+ * Escapes all potentially meaningful regular expression (RE) characters in
+ * aUnquoted.  The returned string, used as a regular expression,
+ * will exactly match the original string.  For example,
+ *           1.5-2.0?
+ * may become:
+ *           1\.5\-2\.0\?
+ * Note QuoteMeta behaves the same as perl's QuoteMeta function,
+ * *except* that it escapes the NUL character (\0) as backslash + 0,
+ * rather than backslash + NUL.
+ * @param aUnquoted unescaped string.
+ * @return string with all meaningful RE characters escaped.
+ */
+EXPORT_C HBufC8* CRegEx::QuoteMetaL(const TDesC8& aUnquoted)
+	{
+	HBufC8* result = HBufC8::NewLC(aUnquoted.Length() + KReserveForEscapeChars);
+	TPtr8 pResult = result->Des();
+
+	_LIT8(KEscapeNull, "\\0");
+	_LIT8(KEscapeOther, "\\%c");
+	
+	// Escape any ascii character not in [A-Za-z_0-9].
+	//
+	// Note that it's legal to escape a character even if it has no
+	// special meaning in a regular expression -- so this function does
+	// that.  (This also makes it identical to the perl function of the
+	// same name; see `perldoc -f quotemeta`.)  The one exception is
+	// escaping NUL: rather than doing backslash + NUL, like perl does,
+	// we do '\0', because pcre itself doesn't take embedded NUL chars.
+	for (TInt ii = 0; ii < aUnquoted.Length(); ++ii)
+	  {
+	  
+	  // Always make sure we have enough room to escape at least one character
+	  if(pResult.MaxLength() <= pResult.Length() + KEscapeTripletLength)
+		  {
+		  result = result->ReAllocL(pResult.Length() + KReserveForEscapeChars);
+		  CleanupStack::Pop();
+		  CleanupStack::PushL(result);
+		  pResult.Set(result->Des());
+		  }
+	  
+	  if (aUnquoted[ii] == TChar('\0'))
+		  {
+		  pResult.Append(KEscapeNull());
+		  }
+	  else if ((aUnquoted[ii] < TChar('a') || aUnquoted[ii] > TChar('z')) &&
+			   (aUnquoted[ii] < TChar('A') || aUnquoted[ii] > TChar('Z')) &&
+			   (aUnquoted[ii] < TChar('0') || aUnquoted[ii] > TChar('9')) &&
+			   aUnquoted[ii] != TChar('_') &&
+			   // If this is the part of a UTF8 or Latin1 character, we need
+			   // to copy this byte without escaping.  Experimentally this is
+			   // what works correctly with the regexp library.
+			   !(aUnquoted[ii] & TChar(0x80)))
+		  {
+		  pResult.AppendFormat(KEscapeOther, aUnquoted[ii]);
+		  }
+	  else
+		  {
+		  pResult.Append(aUnquoted[ii]);
+		  }
+	}
+	CleanupStack::Pop(result);
+	return result;
+}
+
+/**
+ * Returns the number of capturing subpatterns, or -1 if the
+ * regular expressions wasn't valid on construction.
+ * @return the number of capturing subpatterns or or -1 if the regular
+ * expressions wasn't valid on construction.
+ */
+EXPORT_C TInt CRegEx::NumberOfCapturingGroups() const
+	{
+	if (iRePartial == NULL) return KErrNotFound;
+	
+	TInt result;
+	TInt pcreRetVal = pcre_fullinfo(iRePartial, // The regular expression object
+								iExtraPartial,  // Study data
+                                PCRE_INFO_CAPTURECOUNT,
+                                &result);
+	__ASSERT_DEBUG(pcreRetVal == 0, Panic(EUnexpectedRetValFromPcre));
+	return result;
+	}
+
+/**
+ * Analyzes a regular expression (RE) pattern further. This is especially useful
+ * if an RE is going to be used several times to reduce the time taken for
+ * matching.
+ *  
+ * "At present, studying a pattern is useful only for non-anchored patterns that
+ * do not have a single fixed starting character." 
+ */
+EXPORT_C void CRegEx::Study()
+	{
+	// "At present, studying a pattern is useful only for non-anchored
+	// patterns that do not have a single fixed starting character."
+	if(iRePartial)
+		{
+		const char* compileError; // ignored
+		iExtraPartial = pcre_study(
+				iRePartial,     /* result of pcre_compile() */
+				0,              /* no options exist */
+				&compileError);	/* set to NULL or points to a message */		
+		}
+	}
+
+
+// Private Functions //
+
+/**
+ * Standard constructor
+ */
+CRegEx::CRegEx()
+	{
+	}
+
+
+/**
+ * Standard constructor
+ * @param aOptions options used when compiling regular expression.
+ */
+CRegEx::CRegEx(const TRegExOptions& aOptions)
+	: iOptions(aOptions)
+	{
+	}
+
+/**
+ * Second phase constructor.
+ */
+void CRegEx::ConstructL(const TDesC8& aPattern)
+	{
+	iPattern = HBufC8::NewL(aPattern.Length() + 1); // Leave room for \0
+	TPtr8 pPattern = iPattern->Des();
+	pPattern.Copy(aPattern);
+	pPattern.ZeroTerminate();
+	CommonConstructL();
+	}
+
+void CRegEx::CommonConstructL()
+	{
+	// The default value for an argument, to indicate no arg was passed in
+	iNoArg = new(ELeave) TRegExArg((TAny*)NULL);
+	
+	// Compile patterns used for partial and full matches.	
+	iReFull = NULL;
+	iRePartial = NULL;
+	
+	iRePartial = CompileL(EUnanchored);
+	if(iRePartial)
+		{
+		iReFull = CompileL(EAnchorBoth);
+		}	
+	User::LeaveIfError(iErrorCode);	
+	}	
+
+void CRegEx::ConstructL(const TDesC16& aPattern)
+	{
+	LtkUtils::RLtkBuf8 narrowBuf;
+	narrowBuf.CreateLC(aPattern.Length() + 1);
+	if (iOptions.Utf8())
+		{
+		narrowBuf.CopyAsUtf8L(aPattern);
+		}
+	else
+		{
+		narrowBuf.Copy(aPattern);
+		}
+	narrowBuf.AppendL(0);
+	iPattern = narrowBuf.ToHBuf();
+	CleanupStack::Pop(&narrowBuf);
+
+	CommonConstructL();
+	}
+
+/**
+ * Compile the regular expression (RE) pattern.
+ * @param aAnchor anchoring to use for the RE pattern.
+ * @return pointer to PCRE object with compiled RE data. 
+ */
+pcre* CRegEx::CompileL(TAnchor aAnchor)
+	{
+	// First, convert TRegExOptions into pcre options
+	TInt pcreOptions = iOptions.AllOptions();
+	
+	// Special treatment for anchoring.  This is needed because at
+	// runtime pcre only provides an option for anchoring at the
+	// beginning of a string (unless you use offset).
+	//
+	// There are three types of anchoring we want:
+	//    EUnanchored      Compile the original pattern, and use
+	//                    a pcre unanchored match.
+	//    EAnchorStart    Compile the original pattern, and use
+	//                    a pcre anchored match.
+	//    EAnchorBoth     Tack a "\z" to the end of the original pattern
+	//                    and use a pcre anchored match.
+	
+	pcre* re;
+	TInt errCode = 0;
+	TInt errOffset = 0;
+	
+	const char* compileError; // ignored
+
+	if (aAnchor != EAnchorBoth)
+		{
+		re = pcre_compile2((const char *)iPattern->Ptr(), pcreOptions,
+				&errCode,&compileError, &errOffset, NULL);
+		}
+	else
+		{
+		// Tack a '\z' at the end of RE.  Parenthesize it first so that
+		// the '\z' applies to all top-level alternatives in the regexp.
+		_LIT8(KWrapped, "(?:%S)\\z\x0");
+		HBufC8* wrapped = HBufC8::NewLC(KWrapped().Length()
+				+ iPattern->Length());
+		TPtr8 pWrapped = wrapped->Des();
+		pWrapped.Format(KWrapped(), iPattern);
+		re = pcre_compile2((const char *)pWrapped.Ptr(), pcreOptions,
+				&errCode, &compileError, &errOffset, NULL);
+		CleanupStack::PopAndDestroy(wrapped);
+		}
+	
+	if (!re && (iErrorCode == KErrNone))
+		{
+		iErrorCode = KErrRegExCompileBase - errCode;
+		iErrorOffset = errOffset;
+		}
+	return re;
+	}
+
+/**
+ * Cleanup the compiled regular expression and study data.
+ * Separated out from destructor in case support for recompiling
+ * is introduced.
+ */
+void CRegEx::Cleanup()
+	{
+	if (iReFull)
+		{
+		(*pcre_free)(iReFull);
+		}
+	
+	if (iRePartial)
+		{
+		(*pcre_free)(iRePartial);
+		}
+	if(iExtraPartial)
+		{
+		(*pcre_free)(iExtraPartial);
+		}
+	}
+
+// Internal matching and rewrite implementations //
+
+/**
+ * Match against aText, filling in aVector (up to aVector.Count() * 2/3) with
+ * pairs of integers for the beginning and end positions of matched
+ * text.  The first pair corresponds to the entire matched text;
+ * subsequent pairs correspond, in order, to parentheses-captured
+ * matches.  Returns the number of pairs (one more than the number of
+ * the last subpattern with a match) if matching was successful
+ * and zero if the match failed.
+ * I.e. for RE("(foo)|(bar)|(baz)") it will return 2, 3, and 4 when matching
+ * against "foo", "bar", and "baz" respectively.
+ * When matching RE("(foo)|hello") against "hello", it will return 1.
+ * But the values for all subpattern are filled in into "aVector".
+ * @param aText the text to match against the regular expression.
+ * @param aStartPos position in aText to start matching from
+ * @param aAnchor  the type of match to perform.
+ * @param aVector vector that stores pairs of integers for the start and end
+ * positions of matched substrings.
+ * @param aVectorSize length of aVector
+ * @return the number of matched subpatterns.
+ */
+TInt CRegEx::TryMatch(const TDesC8& aText,
+                 TInt aStartPos,
+                 TAnchor aAnchor,
+   			   	TInt* aVector,
+   			    TInt aVectorSize) const
+    {
+	pcre* re = (aAnchor == EAnchorBoth) ? iReFull : iRePartial;
+	if (!re)
+		{
+		// Matching against invalid re
+		return 0;
+		}
+	
+	pcre_extra extra = { 0, 0, 0, 0, 0, 0 };
+	
+	if(iExtraPartial)
+		{
+		extra = *iExtraPartial;
+		}
+
+	if (iOptions.MatchLimit() > 0)
+		{
+		extra.flags |= PCRE_EXTRA_MATCH_LIMIT;
+		extra.match_limit = iOptions.MatchLimit();
+		}
+	
+	if (iOptions.MatchLimitRecursion() > 0)
+		{
+		extra.flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
+		extra.match_limit_recursion = iOptions.MatchLimitRecursion();
+		}
+	
+	TInt rc = pcre_exec(re,              // The regular expression object
+						&extra,
+						(const char *)aText.Ptr(),
+						aText.Length(),
+						aStartPos,
+						(aAnchor == EUnanchored) ? 0 : PCRE_ANCHORED,
+						aVector,
+						aVectorSize);
+	
+	// Handle errors
+	if (rc == PCRE_ERROR_NOMATCH)
+		{
+		return 0;
+		}
+	else if (rc < 0)
+		{
+		// Unexpected return code
+		return 0;
+		}
+	else if (rc == 0)
+		{
+		// pcre_exec() returns 0 as a special case when the number of
+		// capturing subpatterns exceeds the size of the vector.
+		// When this happens, there is a match and the output vector
+		// is filled, but we miss out on the positions of the extra subpatterns.
+		rc = aVectorSize / 2;
+		}
+	return rc;
+    }
+
+/**
+ * Internal implementation of rewrite functionality used by the replace &
+ * extract functions.
+ * Appends the aRewrite string, with backslash subsitutions from aText
+ * and aVector, to string aOut.
+ * @param aOut output descriptor
+ * @param aRewrite descriptor backslash subsitutions to append to aOut.
+ * @param aText descriptor containing substitutions.
+ * @param aVector vector that stores pairs of integers for the start and end
+ * positions of matched substrings.
+ * @param aVectorSize length of aVector.
+ * @param aMatches number of matches.
+ * @return ETrue if the operation was successfull, EFalse otherwise.
+ * @see ReplaceL()
+ * @see GlobalReplaceL()
+ * @see ExtractL()
+ */
+TBool CRegEx::Rewrite(TDes8& aOut, const TDesC8& aRewrite,
+                 const TDesC8& aText, TInt* aVector,
+                 TInt aVectorSize, TInt aMatches) const
+    {
+	for(TInt i = 0; i < aRewrite.Length(); i++)
+		{
+		TChar c = aRewrite[i];
+		
+		if (c == '\\')
+			{
+			c = aRewrite[++i];
+			if (c.IsDigit())
+				{
+				TUint n = c - TChar('0');
+				if (n >= aMatches)
+					{
+					iErrorCode = KErrRegExBadBackslashSubsitution;
+					return EFalse;
+					}
+				__ASSERT_DEBUG(aVectorSize >= 2 * n + 1, Panic(EVectorTooSmall));
+				TInt start = aVector[2 * n];				
+				if (start >= 0)
+					{
+					TInt requiredLength = aVector[2 * n + 1] - start;
+					if((aOut.Length() + requiredLength) <= aOut.MaxLength())
+						{
+						aOut.Append(aText.Mid(start, requiredLength));
+						}
+					else
+						{
+						iErrorCode = KErrRegExOutputTooBig;
+						return EFalse;
+						}						
+					}				
+				}
+				else if (c == '\\')
+					{
+					if((aOut.Length() + 1) <= aOut.MaxLength())
+						{
+						aOut.Append(c);
+						}
+					else
+						{
+						iErrorCode = KErrRegExOutputTooBig;
+						return EFalse;
+						}
+					}
+				else
+					{
+					// Invalid rewrite pattern
+					iErrorCode = KErrRegExInvalidRewritePattern;
+					return EFalse;
+					}
+			} 
+		else
+			{
+			if((aOut.Length() + 1) <= aOut.MaxLength())
+				{
+				aOut.Append(c);
+				}
+			else
+				{
+				iErrorCode = KErrRegExOutputTooBig;
+				return EFalse;
+				}
+			}
+		}
+	return ETrue;
+	}
+
+/**
+ * Internal implementation of the match functionality.
+ * @param aText the text to match against the regular expression.
+ * @param aAnchor the type of match to perform.
+ * @param aConsumed the length of the matched substring.
+ * @param aArgs array of arguments that will contain the extracted subpatterns.
+ * @param aVector output vector that stores pairs of integers for the start and
+ * end positions of matched substrings.
+ * @param aVectorSize length of aVector
+ * @return
+ */
+TBool CRegEx::DoMatchImpl(const TDesC8& aText,
+                    TAnchor aAnchor,
+                    TInt& aConsumed,
+                    const RPointerArray<const TRegExArg>& aArgs,
+      			   	TInt* aVector,
+      			    TInt aVectorSize) const
+    {
+    // results + PCRE workspace
+	__ASSERT_DEBUG((1 + aArgs.Count()) * KPcreWorkspaceMultiplier <= aVectorSize,Panic(EVectorTooSmall) );
+	TInt matches = TryMatch(aText, 0, aAnchor, aVector, aVectorSize);
+	// TryMatch never returns negatives
+	__ASSERT_DEBUG(matches >= 0, Panic(EInvalidMatchResults));  
+	
+	if (matches == 0)
+		{
+		iErrorCode = KErrRegExZeroMatches;
+		return EFalse;
+		}	
+	
+	aConsumed = aVector[1];
+	
+	if (aArgs.Count() == 0)
+		{
+		// We are not interested in results
+		return ETrue;
+		}
+	
+	if (NumberOfCapturingGroups() < aArgs.Count())
+		{
+		// RE has fewer capturing groups than number of arg pointers passed in
+		iErrorCode = KErrRegExFewerCaptureGroupsThanArgs;
+		return EFalse;
+		}
+
+	// If we got here, we must have matched the whole pattern.
+	// We do not need (can not do) any more checks on the value of 'matches'
+	// here -- see the comment for TryMatch.
+	for (TInt i = 0; i < aArgs.Count(); i++)
+		{
+		const TInt start = aVector[2*(i+1)];
+		const TInt limit = aVector[2*(i+1)+1];
+		
+		TBool r;
+		if(start == -1 || limit == -1)
+			{
+			r = aArgs[i]->Parse(KNullDesC8());
+			}
+		else
+			{
+			r = aArgs[i]->Parse(aText.Mid(start, limit - start));
+			}
+		if(!r)
+			{
+			iErrorCode = KErrRegExFailedToParseArg;
+			return EFalse;			
+			}
+		}
+
+	return ETrue;
+	}
+
+/**
+ * Panic the current thread.
+ * @param aPanic panic code.
+ */
+void CRegEx::Panic(TRegExPanic aPanic)
+	{
+	User::Panic(KRegExPanic(), aPanic);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/src/tregexarg.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,275 @@
+// tregexarg.cpp
+//
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// Heavily refactored for Symbian OS by Accenture.
+
+/***** Parsers for various types *****/
+#include "tregexarg.h"
+
+EXPORT_C TBool TRegExArg::ParseNull(const TDesC8& /*aString*/,
+	TAny* aDestination)
+	{
+	// We fail if somebody asked us to store into a non-NULL TAny* pointer
+	return (aDestination == NULL);
+	}
+
+EXPORT_C TBool TRegExArg::ParseTDes8(const TDesC8& aString, TAny* aDestination)
+	{
+	if (aDestination == NULL) return ETrue;
+	TDes8* dest = reinterpret_cast<TDes8*>(aDestination);
+	if(dest->MaxLength() < aString.Length())
+		{
+		return EFalse;
+		}
+	else
+		{
+		dest->Copy(aString);
+		return ETrue;
+		}
+	}
+
+EXPORT_C TBool TRegExArg::ParseTPtrC8(const TDesC8& aString, TAny* aDestination)
+	{
+	if (aDestination == NULL) return ETrue;
+	TPtrC8* dest = reinterpret_cast<TPtrC8*>(aDestination);
+	
+	dest->Set(aString);
+	return ETrue;
+	}
+
+EXPORT_C TBool TRegExArg::ParseTChar(const TDesC8& aString, TAny* aDestination)
+	{
+	if (aString.Length() != 1) return EFalse;
+	if (aDestination == NULL) return ETrue;
+	*(reinterpret_cast<TChar*>(aDestination)) = aString[0];
+	return ETrue;
+	}
+
+EXPORT_C TBool TRegExArg::ParseTInt8(const TDesC8& aString, TAny* aDestination)
+	{
+	if (aString.Length() == 0) return EFalse;
+	
+	TInt8 val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val);
+	if(err) return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TInt8*>(aDestination)) = val;
+	return ETrue;
+	}
+
+EXPORT_C TBool TRegExArg::ParseTInt16(const TDesC8& aString, TAny* aDestination)
+	{
+	if (aString.Length() == 0) return EFalse;
+	
+	TInt16 val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val);
+	if(err) return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TInt16*>(aDestination)) = val;
+	return ETrue;
+	}
+
+EXPORT_C TBool TRegExArg::ParseTInt32(const TDesC8& aString, TAny* aDestination)
+	{
+	if (aString.Length() == 0) return EFalse;
+
+	TInt32 val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val);
+	if(err) return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TInt32*>(aDestination)) = val;
+	return ETrue;
+	}
+
+EXPORT_C TBool TRegExArg::ParseTInt(const TDesC8& aString, TAny* aDestination)
+	{
+	if (aString.Length() == 0) return EFalse;
+
+	TInt val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val);
+	if(err) return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TInt*>(aDestination)) = val;
+	return ETrue;
+	}
+
+TBool TRegExArg::ParseTInt64Radix(const TDesC8& aString, TAny* aDestination,
+		TRadix aRadix)
+	{
+	if (aString.Length() == 0)
+		return EFalse;
+
+	TInt64 val = 0;
+	TLex8 lex(aString);
+	// Note TInt64 is treated as unsigned by TLex
+	TInt err = lex.Val(val, aRadix);
+	
+	// If val is returned as negative then it means we have overflowed.
+	if (err || val < 0)	
+		return EFalse;
+	
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TInt64*> (aDestination)) = val;
+	return ETrue;
+	}
+
+TBool TRegExArg::ParseTUint8Radix(const TDesC8& aString, TAny* aDestination,
+		TRadix aRadix)
+	{
+	if (aString.Length() == 0)
+		return EFalse;
+
+	TUint8 val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val, aRadix);
+	if (err)
+		return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TUint8*> (aDestination)) = val;
+	return ETrue;
+	}
+
+TBool TRegExArg::ParseTUint16Radix(const TDesC8& aString, TAny* aDestination,
+		TRadix aRadix)
+	{
+	if (aString.Length() == 0)
+		return EFalse;
+
+	TUint16 val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val, aRadix);
+	if (err)
+		return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TUint16*> (aDestination)) = val;
+	return ETrue;
+	}
+
+TBool TRegExArg::ParseTUint32Radix(const TDesC8& aString, TAny* aDestination,
+		TRadix aRadix)
+	{
+	if (aString.Length() == 0)
+		return EFalse;
+
+	TUint32 val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val, aRadix);
+	if (err)
+		return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TUint32*> (aDestination)) = val;
+	return ETrue;
+	}
+
+TBool TRegExArg::ParseTUintRadix(const TDesC8& aString, TAny* aDestination,
+		TRadix aRadix)
+	{
+	if (aString.Length() == 0)
+		return EFalse;
+
+	TUint val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val, aRadix);
+	if (err)
+		return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TUint*> (aDestination)) = val;
+	return ETrue;
+	}
+EXPORT_C TBool TRegExArg::ParseTReal32(const TDesC8& aString,
+	TAny* aDestination)
+	{
+	if (aString.Length() == 0) return EFalse;
+
+	TReal32 val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val); 
+	if(err) return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TReal32*>(aDestination)) = val;
+	return ETrue;
+	}
+
+EXPORT_C TBool TRegExArg::ParseTReal64(const TDesC8& aString,
+	TAny* aDestination)
+	{
+	if (aString.Length() == 0) return EFalse;
+
+	TReal64 val = 0;
+	TLex8 lex(aString);
+	TInt err = lex.Val(val); 
+	if(err) return EFalse;
+	if (aDestination == NULL) return ETrue;
+	
+	*(reinterpret_cast<TReal64*>(aDestination)) = val;
+	return ETrue;
+	}
+
+#define DEFINE_INTEGER_PARSERS(name)										\
+	EXPORT_C TBool TRegExArg::Parse##name(const TDesC8& aString,			\
+		TAny* aDestination)													\
+		{																	\
+		return Parse##name##Radix(aString, aDestination, EDecimal);			\
+		}																	\
+	EXPORT_C TBool TRegExArg::Parse##name##Hex(const TDesC8& aString,		\
+		TAny* aDestination)													\
+		{																	\
+		return Parse##name##Radix(aString, aDestination, EHex);				\
+		}																	\
+	EXPORT_C TBool TRegExArg::Parse##name##Octal(const TDesC8& aString,		\
+		TAny* aDestination)													\
+		{																	\
+		return Parse##name##Radix(aString, aDestination, EOctal);			\
+		}																				
+
+	DEFINE_INTEGER_PARSERS(TInt64)
+	DEFINE_INTEGER_PARSERS(TUint8)
+	DEFINE_INTEGER_PARSERS(TUint16)
+	DEFINE_INTEGER_PARSERS(TUint32)
+	DEFINE_INTEGER_PARSERS(TUint)
+
+#undef DEFINE_INTEGER_PARSERS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/src/tregexoptions.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+// tregexoptions.cpp
+//
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "tregexoptions.h"
+
+EXPORT_C TRegExOptions::TRegExOptions()
+	: iMatchLimit(0), iMatchLimitRecursion(0), iAllOptions(0)
+	{}
+EXPORT_C TRegExOptions::TRegExOptions(TUint aOptionFlags)
+	: iMatchLimit(0), iMatchLimitRecursion(0), iAllOptions(aOptionFlags)
+	{}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/test/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// bld.inf
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTMMPFILES
+spcreconsole.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/test/group/spcreconsole.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,48 @@
+// spcreconsole.mmp
+//
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Accenture 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+TARGET		  spcreconsole.exe
+TARGETTYPE	  exe
+UID			 0 0xE38DDCE0
+
+MACRO SUPPORT_UTF8
+
+USERINCLUDE	 ..\inc
+SYSTEMINCLUDE   \epoc32\include \epoc32\include\libc
+
+SOURCEPATH	  ..\src
+SOURCE		  spcreconsole.cpp
+
+LIBRARY		 euser.lib bafl.lib spcre.lib
+
+#ifdef ENABLE_ABIV2_MODE
+  DEBUGGABLE_UDEBONLY
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/spcre/test/src/spcreconsole.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2101 @@
+// spcreconsole.cpp
+//
+// Copyright (c) 2005 - 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * 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.
+//     * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: Sanjay Ghemawat
+//
+// Heavily refactored for Symbian OS by Accenture.
+
+
+#include <e32base.h>
+#include <e32std.h>
+#include <e32math.h>
+#include <e32cons.h>			// Console
+#include <bacline.h>
+#include <cregex.h>
+#include <tregexarg.h>
+#include <tregexoptions.h>
+
+//  Constants
+_LIT(KTextConsoleTitle, "Console");
+_LIT(KTextFailed, " failed, leave code = %d\n");
+_LIT(KTextPressAnyKey, "[press any key]\n");
+//  Global Variables
+LOCAL_D CConsoleBase* console; // write all messages to this
+TBool verboseMode = EFalse;
+
+//  Local Functions
+
+// CHECK dies with a fatal error if condition is not true.  It is *not*
+// controlled by NDEBUG, so the check will be executed regardless of
+// compilation mode.  Therefore, it is safe to do things like:
+//    CHECK_EQ(fp->Write(x), 4)
+#define CHECK(condition)								\
+	{													\
+	if (!(condition))									\
+		{                                   			\
+		_LIT(KCondition, #condition);					\
+		console->Printf(_L("%d: Check failed: %S\n"),	\
+						__LINE__, &KCondition());		\
+		User::Leave(KErrGeneral);						\
+		}												\
+	}
+
+#define CHECK_EQ(a, b)   CHECK(a == b)
+
+static void Timing1L(TInt aNumIters)
+	{
+	console->Printf(_L("Test Timing 1, %d iterations.\n"), aNumIters);
+	
+	// Same pattern lots of times
+	_LIT8(KPattern, "ruby:\\d+");
+	_LIT8(KString,"ruby:1234");
+	CRegEx* pattern = CRegEx::NewLC(KPattern());
+
+	for (TInt j = aNumIters; j > 0; j--)
+		{
+		CHECK(pattern->FullMatchL(KString()));
+		}
+	CleanupStack::PopAndDestroy(pattern);
+	}
+
+static void Timing2L(TInt aNumIters)
+	{
+	console->Printf(_L("Test Timing 2, %d iterations.\n"), aNumIters);
+	// Same pattern lots of times
+	_LIT8(KPattern, "ruby:(\\d+)");
+	_LIT8(KString,"ruby:1234");
+	CRegEx* pattern = CRegEx::NewLC(KPattern());
+
+	TInt i;
+	for (TInt j = aNumIters; j > 0; j--)
+		{
+		CHECK(pattern->FullMatchL(KString(), &i));
+		CHECK_EQ(i, 1234);
+		}
+	CleanupStack::PopAndDestroy(pattern);
+	}
+
+static void Timing3L(TInt aNumIters)
+	{
+	console->Printf(_L("Test Timing 3, %d iterations.\n"), aNumIters);
+	_LIT8(KLine, "this is another line\n");
+	HBufC8* text = HBufC8::NewLC(KLine().Length() * aNumIters);
+	TPtr8 pText = text->Des();
+
+	for (int j = aNumIters; j > 0; j--)
+		{
+		pText.Append(KLine());
+		}
+
+	CRegEx* lineMatcher = CRegEx::NewLC(_L8(".*\n"));
+
+	TInt counter = 0;
+	while (lineMatcher->ConsumeL(pText))
+		{
+		counter++;
+		}
+	CleanupStack::PopAndDestroy(2, text);
+	CHECK_EQ(counter, aNumIters);
+	console->Printf(_L("Matched %d lines\n"), counter);
+	}
+
+
+static void RadixTestsL()
+	{
+	console->Write(_L("Testing hex\n"));
+
+	#define CHECK_HEX(type, value) 										\
+		{																\
+		type v;															\
+		CRegEx* re = CRegEx::NewLC(_L8("([0-9a-fA-F]+)[uUlL]*"));		\
+		CHECK(re->FullMatchL(_L8(#value), Hex(&v)));					\
+		CHECK_EQ(v, 0x ## value);										\
+		CleanupStack::PopAndDestroy(re);								\
+		re = NULL;														\
+		}
+
+	CHECK_HEX(TInt64,     2baddeadbeefLL);
+	CHECK_HEX(TUint8,     abU);
+	CHECK_HEX(TUint16,    2badU);
+	CHECK_HEX(TUint32,    deadbeefUL);
+	CHECK_HEX(TUint,      cafebabeU);
+	#undef CHECK_HEX
+
+	console->Write(_L("Testing octal\n"));
+
+	#define CHECK_OCTAL(type, value) 									\
+		{																\
+		type v;															\
+		CRegEx* re = CRegEx::NewLC(_L8("([0-7]+)[uUlL]*"));				\
+		CHECK(re->FullMatchL(_L8(#value), Octal(&v)));					\
+		CHECK_EQ(v, 0 ## value);										\
+		CleanupStack::PopAndDestroy(re);								\
+		re = NULL;														\
+		}
+
+	CHECK_OCTAL(TInt64,		777777777777LL);
+	CHECK_OCTAL(TUint8,		177U);
+	CHECK_OCTAL(TUint16,	177777U);
+	CHECK_OCTAL(TUint32,	3777777777UL);
+	CHECK_OCTAL(TUint,		3777777777U);
+	#undef CHECK_OCTAL
+
+	console->Write(_L("Testing decimal\n"));
+	
+	#define CHECK_DECIMAL(type, value) 									\
+		{																\
+		type v;															\
+		CRegEx* re = CRegEx::NewLC(_L8("(-?[0-9]+)[uUlL]*"));			\
+		CHECK(re->FullMatchL(_L8(#value), &v));							\
+		CHECK_EQ(v, value);												\
+		CleanupStack::PopAndDestroy(re);								\
+		re = NULL;														\
+		}	
+	
+	CHECK_DECIMAL(TInt8,	-1);
+	CHECK_DECIMAL(TUint8,	1U);
+	CHECK_DECIMAL(TInt16,	-9999);
+	CHECK_DECIMAL(TUint16,	9999U);
+	CHECK_DECIMAL(TInt32,	-123456L);
+	CHECK_DECIMAL(TUint32,	123456U);
+	CHECK_DECIMAL(TInt64,	1234567890123456789LL);
+	CHECK_DECIMAL(TInt,		-1234567890);
+	CHECK_DECIMAL(TUint,	1234567890U);
+	#undef CHECK_DECIMAL
+}
+
+static void TestReplaceL()
+	{
+	console->Write(_L("Testing ReplaceL\n"));
+
+	struct ReplaceTest
+		{
+		TBuf8<32>	iRegExp;
+		TBuf8<32>	iRewrite;
+		TBuf8<64>	iOriginal;
+		TBuf8<64>	iSingle;
+		TBuf8<64>	iGlobal;
+		TInt		iGlobalCount; // the expected return value from ReplaceAll
+		};
+	
+	static const ReplaceTest tests[] =
+	{
+		// Test 1
+		{
+		_L8("(qu|[b-df-hj-np-tv-z]*)([a-z]+)"),
+		_L8("\\2\\1ay"),
+		_L8("the quick brown fox jumps over the lazy dogs."),
+		_L8("ethay quick brown fox jumps over the lazy dogs."),
+		_L8("ethay ickquay ownbray oxfay umpsjay overay ethay azylay ogsday."),
+		9
+		},
+		// Test 2
+		{
+		_L8("\\w+"),
+		_L8("\\0-NOSPAM"),
+		_L8("paul.haahr@google.com"),
+		_L8("paul-NOSPAM.haahr@google.com"),
+		_L8("paul-NOSPAM.haahr-NOSPAM@google-NOSPAM.com-NOSPAM"),
+		4
+		},
+		// Test 3
+		{_L8("^"),
+		_L8("(START)"),
+		_L8("foo"),
+		_L8("(START)foo"),
+		_L8("(START)foo"),
+		1
+		},
+		// Test 4
+		{
+		_L8("^"),
+		_L8("(START)"),
+		_L8(""),
+		_L8("(START)"),
+		_L8("(START)"),
+		1
+		},
+		// Test 5
+		{
+		_L8("$"),
+		_L8("(END)"),
+		_L8(""),
+		_L8("(END)"),
+		_L8("(END)"),
+		1
+		},
+		// Test 6
+		{
+		_L8("b"),
+		_L8("bb"),
+		_L8("ababababab"),
+		_L8("abbabababab"),
+		_L8("abbabbabbabbabb"),
+		5
+		},
+		// Test 7
+		{
+		_L8("b"),
+		_L8("bb"),
+		_L8("bbbbbb"),
+		_L8("bbbbbbb"),
+		_L8("bbbbbbbbbbbb"),
+		6
+		},
+		// Test 8
+		{_L8("b+"),
+		_L8("bb"),
+		_L8("bbbbbb"),
+		_L8("bb"),
+		_L8("bb"),
+		1
+		},
+		// Test 9
+		{
+		_L8("b*"),
+		_L8("bb"),
+		_L8("bbbbbb"),
+		_L8("bb"),
+		_L8("bb"),
+		1
+		},
+		// Test 10
+		{
+		_L8("b*"),
+		_L8("bb"),
+		_L8("aaaaa"),
+		_L8("bbaaaaa"),
+		_L8("bbabbabbabbabbabb"),
+		6
+		},
+		// Test 11
+		{
+		_L8("b*"),
+		_L8("bb"),
+		_L8("aa\naa\n"),
+		_L8("bbaa\naa\n"),
+		_L8("bbabbabb\nbbabbabb\nbb"),
+		7
+		},
+		// Test 12
+		{
+		_L8("b*"),
+		_L8("bb"),
+		_L8("aa\raa\r"),
+		_L8("bbaa\raa\r"),
+		_L8("bbabbabb\rbbabbabb\rbb"),
+		7
+		},
+		// Test 13
+		{
+		_L8("b*"),
+		_L8("bb"),
+		_L8("aa\r\naa\r\n"),
+		_L8("bbaa\r\naa\r\n"),
+		_L8("bbabbabb\r\nbbabbabb\r\nbb"),
+		7
+		},
+#ifdef SUPPORT_UTF8
+		// Test 14
+		{	
+		_L8("b*"),
+		_L8("bb"),
+		_L8("\xE3\x83\x9B\xE3\x83\xBC\xE3\x83\xA0\xE3\x81\xB8"),   // utf8
+		_L8("bb\xE3\x83\x9B\xE3\x83\xBC\xE3\x83\xA0\xE3\x81\xB8"),
+		_L8("bb\xE3\x83\x9B""bb""\xE3\x83\xBC""bb""\xE3\x83\xA0""bb""\xE3\x81\xB8""bb"),
+		5
+		},
+		// Test 15
+		{
+		_L8("b*"),
+		_L8("bb"),
+		_L8("\xE3\x83\x9B\r\n\xE3\x83\xBC\r\xE3\x83\xA0\n\xE3\x81\xB8\r\n"),   // utf8
+		_L8("bb\xE3\x83\x9B\r\n\xE3\x83\xBC\r\xE3\x83\xA0\n\xE3\x81\xB8\r\n"),
+		_L8("bb\xE3\x83\x9B""bb\r\nbb""\xE3\x83\xBC""bb\rbb""\xE3\x83\xA0""bb\nbb""\xE3\x81\xB8""bb\r\nbb"),
+		9
+		},
+#endif
+		{
+		KNullDesC8(),
+		KNullDesC8(),
+		KNullDesC8(),
+		KNullDesC8(),
+		KNullDesC8(),
+		-1
+		}
+	};
+
+#ifdef SUPPORT_UTF8
+	const TBool supportUtf8 = ETrue;
+#else
+	const TBool supportUtf8 = EFalse;
+#endif
+  
+	CRegEx* re = NULL;
+	TRegExOptions options = TRegExOptions(EPcreNewlineCrLf);
+	options.SetUtf8(supportUtf8);	
+	TInt i =0;
+	for (const ReplaceTest* t = tests; t->iGlobalCount > -1; ++t)
+		{		
+		console->Printf(_L("Replace Test %d\n"), ++i);
+		re = CRegEx::NewLC(t->iRegExp, options);
+		CHECK_EQ(re->Error(), KErrNone);
+		TBuf8<64> one(t->iOriginal);
+		CHECK(re->ReplaceL(t->iRewrite, one));
+		CHECK_EQ(one, t->iSingle);
+		TBuf8<64> all(t->iOriginal);
+		const TInt replaceCount = re->GlobalReplaceL(t->iRewrite, all);
+		CHECK_EQ(all, t->iGlobal);
+		CHECK_EQ(replaceCount, t->iGlobalCount);		
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+
+	// One final test: test \r\n replacement when we're not in CRLF mode
+	{
+	TRegExOptions options2 = TRegExOptions(EPcreNewlineCr);
+	options2.SetUtf8(supportUtf8);
+	re = CRegEx::NewLC(_L8("b*"), options2);
+	CHECK_EQ(re->Error(), KErrNone);
+	TBuf8<32> all(_L8("aa\r\naa\r\n"));
+	CHECK_EQ(re->GlobalReplaceL(_L8("bb"), all), 9);
+	CHECK_EQ(all, _L8("bbabbabb\rbb\nbbabbabb\rbb\nbb"));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	}
+	{
+	TRegExOptions options3 = TRegExOptions(EPcreNewlineLf);
+	options3.SetUtf8(supportUtf8);
+	re = CRegEx::NewLC(_L8("b*"), options3);
+	CHECK_EQ(re->Error(), KErrNone);
+	TBuf8<32> all(_L8("aa\r\naa\r\n"));
+	CHECK_EQ(re->GlobalReplaceL(_L8("bb"), all), 9);
+	CHECK_EQ(all, _L8("bbabbabb\rbb\nbbabbabb\rbb\nbb"));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	}
+
+	// TODO: test what happens when no PCRE_NEWLINE_* flag is set.
+	//       Alas, the answer depends on how pcre was compiled.
+}
+
+static void TestExtractL()
+	{
+	console->Write(_L("Testing ExtractL\n"));
+
+	TBuf8<32> s;	
+	CRegEx* re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(.*)@([^.]*)"));
+	CHECK(re->ExtractL(_L8("\\2!\\1"), _L8("boris@kremvax.ru"), s));
+	CHECK_EQ(s, _L8("kremvax!boris"));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	// check the RE interface as well
+	re = CRegEx::NewLC(_L8(".*"));
+	CHECK(re->ExtractL(_L8("'\\0'"), _L8("foo"), s));
+	CHECK_EQ(s, _L8("'foo'"));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("bar"));
+	CHECK(!re->ExtractL(_L8("'\\0'"), _L8("baz"), s));
+	CHECK_EQ(s, _L8("'foo'"));
+	CleanupStack::PopAndDestroy(re);
+	}
+
+static void TestConsumeL()
+	{
+	console->Write(_L("Testing ConsumeL\n"));
+
+	TBuf8<3> word;
+	TBuf8<24> input(_L8("   aaa b!@#$@#$cccc"));
+
+	// matches a word, possibly proceeded by whitespace
+	CRegEx* re = CRegEx::NewLC(_L8("\\s*(\\w+)"));
+	CHECK(re->ConsumeL(input, &word));
+	CHECK_EQ(word, _L8("aaa"));
+	CHECK(re->ConsumeL(input, &word));
+	CHECK_EQ(word, _L8("b"));
+	CHECK(!re->ConsumeL(input, &word));
+	CleanupStack::PopAndDestroy(re);
+	}
+
+static void TestFindAndConsumeL()
+	{
+	console->Write(_L("Testing FindAndConsumeL\n"));
+
+	TBuf8<4> word;
+	TBuf8<24> input(_L8("   aaa b!@#$@#$cccc"));
+
+	CRegEx* re = CRegEx::NewLC(_L8("(\\w+)")); // matches a word
+	CHECK(re->FindAndConsumeL(input, &word));
+	CHECK_EQ(word, _L8("aaa"));
+	CHECK(re->FindAndConsumeL(input, &word));
+	CHECK_EQ(word, _L8("b"));
+	CHECK(re->FindAndConsumeL(input, &word));
+	CHECK_EQ(word, _L8("cccc"));
+	CHECK(!re->FindAndConsumeL(input, &word));
+	CleanupStack::PopAndDestroy(re);
+	}
+
+static void TestMatchNumberPeculiarityL()
+	{
+	console->Write(_L("Testing match-number peculiarity\n"));
+
+	TBuf8<3> word1;
+	TBuf8<3> word2;
+	TBuf8<3> word3;
+
+	CRegEx* re = CRegEx::NewLC(_L8("(foo)|(bar)|(baz)"));
+	CHECK(re->PartialMatchL(_L8("foo"), &word1, &word2, &word3));
+	CHECK_EQ(word1, _L8("foo"));
+	CHECK_EQ(word2, KNullDesC8());
+	CHECK_EQ(word3, KNullDesC8());
+	CHECK(re->PartialMatchL(_L8("bar"), &word1, &word2, &word3));
+	CHECK_EQ(word1, KNullDesC8());
+	CHECK_EQ(word2, _L8("bar"));
+	CHECK_EQ(word3, KNullDesC8());
+	CHECK(re->PartialMatchL(_L8("baz"), &word1, &word2, &word3));
+	CHECK_EQ(word1, KNullDesC8());
+	CHECK_EQ(word2, KNullDesC8());
+	CHECK_EQ(word3, _L8("baz"));
+	CHECK(!re->PartialMatchL(_L8("f"), &word1, &word2, &word3));
+
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	TBuf8<12> a;
+	re = CRegEx::NewLC(_L8("(foo)|hello"));
+	CHECK(re->FullMatchL(_L8("hello"), &a));
+	CHECK_EQ(a, KNullDesC8());
+	CleanupStack::PopAndDestroy(re);
+	}
+
+static void TestRecursionL()
+	{
+	console->Write(_L("Testing recursion\n"));
+	
+	// Get one string that passes (sometimes), one that never does.
+	TBuf8<12> good(_L8("abcdefghijk"));
+	TBuf8<12> bad(_L8("acdefghijkl"));
+
+	// According to pcretest, matching text_good against (\w+)*b
+	// requires match_limit of at least 8192, and match_recursion_limit
+	// of at least 37.
+
+	TRegExOptions optionsMatchLimit;
+	optionsMatchLimit.SetMatchLimit(8192);
+	
+	CRegEx* re = CRegEx::NewLC(_L8("(\\w+)*b"), optionsMatchLimit);
+	CHECK(re->PartialMatchL(good));
+	CHECK(re->PartialMatchL(bad) == EFalse);
+	CHECK(re->FullMatchL(good) == EFalse);
+	CHECK(re->FullMatchL(bad) == EFalse);	
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	optionsMatchLimit.SetMatchLimit(1024);
+	CRegEx* re2 = CRegEx::NewLC(_L8("(\\w+)*b"), optionsMatchLimit);
+	CHECK(re2->PartialMatchL(good) == EFalse);   // because of match_limit
+	CHECK(re2->PartialMatchL(bad) == EFalse);
+	CHECK(re2->FullMatchL(good) == EFalse);
+	CHECK(re2->FullMatchL(bad) == EFalse);
+	CleanupStack::PopAndDestroy(re2);
+	re2 = NULL;
+	
+	TRegExOptions optionsMathLimitRecursion;
+	optionsMathLimitRecursion.SetMatchLimitRecursion(50);
+	CRegEx* re3 = CRegEx::NewLC(_L8("(\\w+)*b"), optionsMathLimitRecursion);
+	CHECK(re3->PartialMatchL(good));
+	CHECK(re3->PartialMatchL(bad) == EFalse);
+	CHECK(re3->FullMatchL(good) == EFalse);
+	CHECK(re3->FullMatchL(bad) == EFalse);
+	CleanupStack::PopAndDestroy(re3);
+	re3 = NULL;
+	
+	optionsMathLimitRecursion.SetMatchLimitRecursion(10);
+	CRegEx* re4 = CRegEx::NewLC(_L8("(\\w+)*b"), optionsMathLimitRecursion);
+	CHECK(re4->PartialMatchL(good) == EFalse);
+	CHECK(re4->PartialMatchL(bad) == EFalse);
+	CHECK(re4->FullMatchL(good) == EFalse);
+	CHECK(re4->FullMatchL(bad) == EFalse);
+	CleanupStack::PopAndDestroy(re4);
+	re4 = NULL;	
+	}
+
+// A meta-quoted string, interpreted as a pattern, should always match
+// the original unquoted string.
+static void TestQuoteMetaL(const TDesC8& aUnquoted, TRegExOptions aOptions =
+		TRegExOptions())
+	{
+	HBufC8* quoted = CRegEx::QuoteMetaL(aUnquoted);
+	CleanupStack::PushL(quoted);
+
+	CRegEx* re = CRegEx::NewLC(*quoted, aOptions);
+	CHECK(re->FullMatchL(aUnquoted));
+	CleanupStack::PopAndDestroy(2, quoted); // re
+	}
+
+// A string containing meaningful regexp characters, which is then meta-
+// quoted, should not generally match a string the unquoted string does.
+static void NegativeTestQuoteMetaL(const TDesC8& aUnquoted,
+		const TDesC8& aNotMatch, TRegExOptions aOptions = TRegExOptions())
+	{
+	HBufC8* quoted = CRegEx::QuoteMetaL(aUnquoted);
+	CleanupStack::PushL(quoted);
+
+	CRegEx* re = CRegEx::NewLC(*quoted, aOptions);
+	CHECK(!re->FullMatchL(aNotMatch));
+	CleanupStack::PopAndDestroy(2, quoted); // re
+	}
+
+// Tests that quoted meta characters match their original strings,
+// and that a few things that shouldn't match indeed do not.
+static void TestQuotaMetaSimpleL()
+	{
+	TestQuoteMetaL(_L8("foo"));
+	TestQuoteMetaL(_L8("foo.bar"));
+	TestQuoteMetaL(_L8("foo\\.bar"));
+	TestQuoteMetaL(_L8("[1-9]"));
+	TestQuoteMetaL(_L8("1.5-2.0?"));
+	TestQuoteMetaL(_L8("\\d"));
+	TestQuoteMetaL(_L8("Who doesn't like ice cream?"));
+	TestQuoteMetaL(_L8("((a|b)c?d*e+[f-h]i)"));
+	TestQuoteMetaL(_L8("((?!)xxx).*yyy"));
+	TestQuoteMetaL(_L8("(["));
+	TestQuoteMetaL(_L8("foo\0bar"));
+	}
+
+static void TestQuoteMetaSimpleNegativeL()
+	{
+	NegativeTestQuoteMetaL(_L8("foo"), _L8("bar"));
+	NegativeTestQuoteMetaL(_L8("..."), _L8("bar"));
+	NegativeTestQuoteMetaL(_L8("\\."), _L8("."));
+	NegativeTestQuoteMetaL(_L8("\\."), _L8(".."));
+	NegativeTestQuoteMetaL(_L8("(a)"), _L8("a"));
+	NegativeTestQuoteMetaL(_L8("(a|b)"), _L8("a"));
+	NegativeTestQuoteMetaL(_L8("(a|b)"), _L8("(a)"));
+	NegativeTestQuoteMetaL(_L8("(a|b)"), _L8("a|b"));
+	NegativeTestQuoteMetaL(_L8("[0-9]"), _L8("0"));
+	NegativeTestQuoteMetaL(_L8("[0-9]"), _L8("0-9"));
+	NegativeTestQuoteMetaL(_L8("[0-9]"), _L8("[9]"));
+	NegativeTestQuoteMetaL(_L8("((?!)xxx)"), _L8("xxx"));
+	}
+
+static void TestQuoteMetaLatin1L()
+	{
+	TestQuoteMetaL(_L8("3\xb2 = 9"));
+	}
+
+
+static void TestQuoteMetaUtf8L()
+	{
+#ifdef SUPPORT_UTF8
+	TRegExOptions options;
+	options.SetUtf8(ETrue);
+	TestQuoteMetaL(_L8("Pl\xc3\xa1\x63ido Domingo"), options);
+	TestQuoteMetaL(_L8("xyz"), options);            // No fancy utf8
+	TestQuoteMetaL(_L8("\xc2\xb0"), options);       // 2-byte utf8 (degree symbol)
+	TestQuoteMetaL(_L8("27\xc2\xb0 degrees"), options);  // As a middle character
+	TestQuoteMetaL(_L8("\xe2\x80\xb3"), options);   // 3-byte utf8 (double prime)
+	TestQuoteMetaL(_L8("\xf0\x9d\x85\x9f"), options); // 4-byte utf8 (music note)
+	TestQuoteMetaL(_L8("27\xc2\xb0")); // Interpreted as Latin-1, but should still work
+	NegativeTestQuoteMetaL(_L8("27\xc2\xb0"),               // 2-byte utf (degree symbol)
+			_L8("27\\\xc2\\\xb0"),
+			options);
+#endif
+	}
+
+
+static void TestQuoteMetaAllL()
+	{
+	console->Write(_L("Testing QuoteMeta\n"));
+
+	TestQuotaMetaSimpleL();
+	TestQuoteMetaSimpleNegativeL();
+	TestQuoteMetaLatin1L();
+	TestQuoteMetaUtf8L();
+	}
+
+//
+// Options tests contributed by
+// Giuseppe Maxia, CTO, Stardata s.r.l.
+// July 2005
+//
+static void GetOneOptionResultL(
+                const TDesC& aOptionName,
+                const TDesC8& aRegEx,
+                const TDesC8& aString,
+                TRegExOptions& aOptions,
+                TBool aFull,
+                const TDesC8& aExpected)
+	{
+	console->Printf(_L("Testing Option <%S>\n"), &aOptionName);
+	
+	if(verboseMode)
+		{
+		TBuf<32> str;
+		str.Copy(aString);
+		TBuf<32> rx;
+		rx.Copy(aRegEx);
+		TBuf<32> expected;
+		expected.Copy(aExpected);
+
+		console->Printf(_L("/%S/ finds \"%S\" within \"%S\" \n"), &rx, &expected, &str);
+		}
+	
+  TBuf8<32> captured;
+  CRegEx* re = CRegEx::NewLC(aRegEx, aOptions);
+  
+  if (aFull)
+	  {
+	  CHECK(re->FullMatchL(aString, &captured));
+	  }    
+  else
+	  {
+	  CHECK(re->PartialMatchL(aString, &captured));
+	  }   
+  CHECK_EQ(captured, aExpected);
+  
+  CleanupStack::PopAndDestroy(re);
+}
+
+static void TestOneOptionL(
+                const TDesC& aOptionName,
+                const TDesC8& aRegEx,
+                const TDesC8& aString,
+                const TRegExOptions& aOptions,
+                TBool aFull,
+                TBool aAssertive = ETrue)
+	{
+	
+	console->Printf(_L("Testing Option <%S>\n"), &aOptionName);
+	if(verboseMode)
+		{
+		_LIT(KMatches, "matches");
+		_LIT(KNoMatch, "doesn't match");
+		TBuf<32> str;
+		str.Copy(aString);
+		TBuf<64> rx;
+		rx.Copy(aRegEx);
+		
+		console->Printf(_L("'%S' %S /%S/ \n"),
+	                  &str,
+	                  (aAssertive? &KMatches() : &KNoMatch()),
+	                  &rx);	
+		}
+
+	CRegEx* re = NULL;
+	TRAPD(err, re = CRegEx::NewLC(aRegEx, aOptions); CleanupStack::Pop());
+	
+	if(err)
+		{
+		CHECK_EQ(aAssertive, EFalse);
+		return;
+		}
+	
+	CleanupStack::PushL(re);
+	
+	if (aAssertive)
+		{
+		if (aFull)
+			{
+			CHECK(re->FullMatchL(aString));
+			}     
+		else
+			{
+			CHECK(re->PartialMatchL(aString));
+			}
+		}
+	else
+		{
+		if (aFull)
+			{
+			CHECK(!re->FullMatchL(aString));
+			}		  
+		else
+			{
+			CHECK(!re->PartialMatchL(aString));
+			}
+		}
+	CleanupStack::PopAndDestroy(re);	
+	}
+
+static void TestCaseLessL()
+	{
+	TRegExOptions options;
+	TRegExOptions options2;
+	TRegExOptions caseless;
+	caseless.SetCaseless(ETrue);
+
+	options.SetCaseless(ETrue);
+	TestOneOptionL(_L("CASELESS (class)"), _L8("HELLO"), _L8("hello"), options, EFalse);
+	TestOneOptionL(_L("CASELESS (class2)"), _L8("HELLO"), _L8("hello"), options2.SetCaseless(ETrue), EFalse);
+	TestOneOptionL(_L("CASELESS (class)"), _L8("^[A-Z]+$"), _L8("Hello"), options, EFalse);
+
+	TestOneOptionL(_L("CASELESS (function)"), _L8("HELLO"), _L8("hello"), caseless, EFalse);
+	TestOneOptionL(_L("CASELESS (function)"), _L8("^[A-Z]+$"), _L8("Hello"), caseless, EFalse);
+	options.SetCaseless(EFalse);
+	TestOneOptionL(_L("no CASELESS"), _L8("HELLO"), _L8("hello"), options, EFalse, EFalse);
+	}
+
+static void TestMultilineL()
+	{
+	TRegExOptions options;
+	TRegExOptions options2;
+	TRegExOptions multiline;
+	multiline.SetMultiline(ETrue);
+
+	TBuf8<32> str(_L8("HELLO\n" "cruel\n" "world\n"));
+
+	options.SetMultiline(ETrue);
+	TestOneOptionL(_L("MULTILINE (class)"), _L8("^cruel$"), str, options, EFalse);
+	TestOneOptionL(_L("MULTILINE (class2)"), _L8("^cruel$"), str, options2.SetMultiline(ETrue), EFalse);
+	TestOneOptionL(_L("MULTILINE (function)"), _L8("^cruel$"), str, multiline, EFalse);
+	options.SetMultiline(EFalse);
+	TestOneOptionL(_L("no MULTILINE"), _L8("^cruel$"), str, options, EFalse, EFalse);
+	}
+
+static void TestDotAllL()
+	{
+	TRegExOptions options;
+	TRegExOptions options2;
+	TRegExOptions dotAll;
+	dotAll.SetDotAll(ETrue);
+
+	TBuf8<32> str(_L8("HELLO\n" "cruel\n" "world"));
+
+	options.SetDotAll(ETrue);
+	TestOneOptionL(_L("DOTALL (class)"), _L8("HELLO.*world"),str, options, ETrue);
+	TestOneOptionL(_L("DOTALL (class2)"), _L8("HELLO.*world"),str, options2.SetDotAll(ETrue), ETrue);
+	TestOneOptionL(_L("DOTALL (function)"), _L8("HELLO.*world"),str, dotAll, ETrue);
+	options.SetDotAll(EFalse);
+	TestOneOptionL(_L("no DOTALL"), _L8("HELLO.*world"),str, options, ETrue, EFalse);
+	}
+
+static void TestDollarEndOnlyL()
+	{
+	TRegExOptions options;
+	TRegExOptions options2;
+	TRegExOptions dollarEndOnly;
+	dollarEndOnly.SetDollarEndOnly(ETrue);
+
+	TBuf8<32> str(_L8("HELLO world\n"));
+
+	TestOneOptionL(_L("no DOLLAR_ENDONLY"), _L8("world$"), str, options, EFalse);
+	options.SetDollarEndOnly(ETrue);
+	TestOneOptionL(_L("DOLLAR_ENDONLY 1"), _L8("world$"), str, options, EFalse, EFalse);
+	TestOneOptionL(_L("DOLLAR_ENDONLY 2"), _L8("world$"), str, options2.SetDollarEndOnly(ETrue), EFalse, EFalse);
+	}
+
+
+static void TestExtraL()
+	{	
+	TRegExOptions options;
+
+	TBuf8<32> str(_L8("HELLO"));
+	options.SetExtra(ETrue);
+	TestOneOptionL(_L("EXTRA 1"), _L8("\\HELL\\O"), str, options, ETrue, EFalse );
+	TestOneOptionL(_L("EXTRA 2"), _L8("\\HELL\\O"), str, TRegExOptions().SetExtra(ETrue), ETrue, EFalse );
+	options.SetExtra(EFalse);
+	TestOneOptionL(_L("no EXTRA"), _L8("\\HELL\\O"), str, options, ETrue );
+	}
+
+static void TestExtendedL()
+	{
+	TRegExOptions options;
+	TRegExOptions options2;
+	TRegExOptions extended;
+	extended.SetExtended(ETrue);
+
+	TBuf8<32> str(_L8("HELLO world"));
+
+	options.SetExtended(ETrue);
+	TestOneOptionL(_L("EXTENDED (class)"), _L8("HELLO world"), str, options, EFalse, EFalse);
+	TestOneOptionL(_L("EXTENDED (class2)"), _L8("HELLO world"), str, options2.SetExtended(ETrue), EFalse, EFalse);
+	TestOneOptionL(_L("EXTENDED (class)"), _L8("^ HE L{2} O \\s+        \\w+ $      "), str, options, EFalse);
+
+	TestOneOptionL(_L("EXTENDED (function)"), _L8("HELLO world"), str, extended, EFalse, EFalse);
+	TestOneOptionL(_L("EXTENDED (function)"), _L8("^ HE L{2} O \\s+        \\w+ $      "), str, extended, EFalse);
+
+	options.SetExtended(EFalse);
+	TestOneOptionL(_L("no EXTENDED"), _L8("HELLO world"), str, options, EFalse);
+	}
+
+static void TestNoAutoCaptureL()
+	{
+	TRegExOptions options;
+	TBuf8<32> str(_L8("HELLO world"));
+	TBuf8<5> captured;
+	console->Write(_L("Testing Option <no NO_AUTO_CAPTURE>\n"));
+	if (verboseMode)
+		{
+		console->Write(_L("parentheses capture text\n"));
+		}
+
+	CRegEx* re = CRegEx::NewLC(_L8("(world|universe)$"), options);
+	CHECK(re->ExtractL(_L8("\\1"), str , captured));
+	CHECK_EQ(captured, _L8("world"));
+	options.SetNoAutoCapture(ETrue);
+	console->Write(_L("testing Option <NO_AUTO_CAPTURE>\n"));
+
+	if (verboseMode)
+		{
+		console->Write(_L("parentheses do not capture text\n"));
+		}
+
+	re->ExtractL(_L8("\\1"),str, captured);
+	CHECK_EQ(captured, _L8("world"));
+	
+	CleanupStack::PopAndDestroy(re);
+	}
+
+static void TestUngreedyL()
+	{
+	TRegExOptions options;
+	TRegExOptions ungreedy;
+	ungreedy.SetUngreedy(ETrue);
+
+	TBuf8<32> str(_L8("HELLO, 'this' is the 'world'"));
+
+	options.SetUngreedy(ETrue);
+	GetOneOptionResultL(_L("UNGREEDY 1"), _L8("('.*')"), str, options, EFalse, _L8("'this'") );
+	GetOneOptionResultL(_L("UNGREEDY 2"), _L8("('.*')"), str, ungreedy, EFalse, _L8("'this'") );
+	GetOneOptionResultL(_L("UNGREEDY"), _L8("('.*?')"), str, options, EFalse, _L8("'this' is the 'world'") );
+
+	options.SetUngreedy(EFalse);
+	GetOneOptionResultL(_L("no UNGREEDY"), _L8("('.*')"), str, options, EFalse, _L8("'this' is the 'world'") );
+	GetOneOptionResultL(_L("no UNGREEDY"), _L8("('.*?')"), str, options, EFalse, _L8("'this'") );
+	}
+
+static void TestAllOptionsL()
+	{
+	TBuf8<32> str(_L8("HELLO\n" "cruel\n" "world"));
+	TRegExOptions options;
+	options.SetAllOptions(EPcreCaseless | EPcreDotAll);
+
+	TestOneOptionL(_L("all_options (CASELESS|DOTALL)"), _L8("^hello.*WORLD"), str , options, EFalse);
+	options.SetAllOptions(0);
+	TestOneOptionL(_L("all_options (0)"), _L8("^hello.*WORLD"), str , options, EFalse, EFalse);
+	options.SetAllOptions(EPcreMultiline | EPcreExtended);
+
+	TestOneOptionL(_L("all_options (MULTILINE|EXTENDED)"), _L8(" ^ c r u e l $ "), str, options, EFalse);
+	TestOneOptionL(_L("all_options (MULTILINE|EXTENDED) with constructor"),
+	_L8(" ^ c r u e l $ "),
+	str,
+	TRegExOptions(EPcreMultiline | EPcreExtended),
+	EFalse);
+
+	TRegExOptions multilineExtended = TRegExOptions().SetMultiline(ETrue);
+	multilineExtended.SetExtended(ETrue);
+
+	TestOneOptionL(_L("all_options (MULTILINE|EXTENDED) with concatenation"),
+	_L8(" ^ c r u e l $ "),
+	str,
+	multilineExtended, EFalse);
+
+	options.SetAllOptions(0);
+	TestOneOptionL(_L("all_options (0)"), _L8("^ c r u e l $"), str, options, EFalse, EFalse);
+	}
+
+static void TestOptionsL()
+	{
+	console->Write(_L("Testing Options\n"));
+	TestCaseLessL();
+	TestMultilineL();
+	TestDotAllL();
+	TestDollarEndOnlyL();
+	TestExtendedL();
+	TestNoAutoCaptureL();
+	TestUngreedyL();
+	TestExtraL();
+	TestAllOptionsL();
+	}
+
+
+LOCAL_C void MainL()
+	{
+	
+	_LIT(KTimingArg1, "timing1");
+	_LIT(KTimingArg2, "timing2");
+	_LIT(KTimingArg3, "timing3");
+	
+	CCommandLineArguments* args = CCommandLineArguments::NewLC();
+
+	// Treat any flag as --help
+	if(args->Count() > 1 && args->Arg(1)[0] == '-')
+		{
+		console->Printf(_L("Usage: %S [%S|%S|%S num-iters]\n"), &(args->Arg(0)), &KTimingArg1(), &KTimingArg2(), &KTimingArg3());
+		console->Write(_L("If 'timingX ###' is specified, run the given timing test\n"));
+		console->Write(_L("with the given number of iterations, rather than running\n"));
+		console->Write(_L("the default corectness test.\n"));
+		CleanupStack::PopAndDestroy(args);
+		return;		
+		}
+	if(args->Count() > 1)
+		{
+		if(args->Count() == 2)
+			{
+			console->Write(_L("timing mode needs a num-iters argument\n"));
+			CleanupStack::PopAndDestroy(args);
+			return;			
+			}
+		
+		TLex lex(args->Arg(2));
+		TInt iters;
+		TInt err = lex.Val(iters);
+		
+		if(err || iters == 0)
+			{
+			CleanupStack::PopAndDestroy(args);
+			return;	
+			}
+		
+		if(args->Arg(1) == KTimingArg1)
+			{
+			Timing1L(iters);
+			}
+		else if(args->Arg(1) == KTimingArg2)
+			{
+			Timing2L(iters);
+			}
+		else if(args->Arg(1) == KTimingArg3)
+			{
+			Timing3L(iters);
+			}		
+		else
+			{
+			console->Printf(_L("Unknown argument '%S'\n"), &(args->Arg(1)));
+			}
+		CleanupStack::PopAndDestroy(args);
+		return;			
+		}
+	CleanupStack::PopAndDestroy(args);
+	
+	console->Write(_L("Testing FullMatch\n"));
+
+	CRegEx* re = NULL;
+	TInt i;
+	TBuf8<10> s;
+	
+	/***** FullMatch with no args *****/
+	re = CRegEx::NewLC(_L8("h.*o"));
+	CHECK(re->FullMatchL(_L8("hello")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("h.*o")); // Must be anchored at front
+	CHECK(!re->FullMatchL(_L8("othello")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("h.*o")); // Must be anchored at end
+	CHECK(!re->FullMatchL(_L8("hello!")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("a*")); // Fullmatch with normal op
+	CHECK(re->FullMatchL(_L8("aaaa")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("a*?")); // Fullmatch with nongreedy op
+	CHECK(re->FullMatchL(_L8("aaaa")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("a*?\\z")); // Two unusual ops
+	CHECK(re->FullMatchL(_L8("aaaa")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	/***** FullMatch with args *****/
+
+	// Zero-arg
+	re = CRegEx::NewLC(_L8("\\d+"));
+	CHECK(re->FullMatchL(_L8("1001")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+
+	// Single-arg
+	re = CRegEx::NewLC(_L8("(\\d+)"));
+	CHECK(re->FullMatchL(_L8("1001"), &i));
+	CHECK_EQ(i, 1001);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(-?\\d+)"));
+	CHECK(re->FullMatchL(_L8("-123"), &i));
+	CHECK_EQ(i, -123);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("()\\d+"));
+	CHECK(!re->FullMatchL(_L8("10"), &i));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(\\d+)"));
+	CHECK(!re->FullMatchL(_L8("1234567890123456789012345678901234567890"), &i));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+
+	// Digits surrounding integer-arg
+	re = CRegEx::NewLC(_L8("1(\\d*)4"));
+	CHECK(re->FullMatchL(_L8("1234"), &i));
+	CHECK_EQ(i, 23);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(\\d)\\d+"));
+	CHECK(re->FullMatchL(_L8("1234"), &i));
+	CHECK_EQ(i, 1);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(-\\d)\\d+"));
+	CHECK(re->FullMatchL(_L8("-1234"), &i));
+	CHECK_EQ(i, -1);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(\\d)"));
+	CHECK(re->PartialMatchL(_L8("1234"), &i));
+	CHECK_EQ(i, 1);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("(-\\d)"));
+	CHECK(re->PartialMatchL(_L8("-1234"), &i));
+	CHECK_EQ(i, -1);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	// String-arg
+	re = CRegEx::NewLC(_L8("h(.*)o"));
+	CHECK(re->PartialMatchL(_L8("hello"), &s));
+	CHECK_EQ(s, _L8("ell"));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+
+	// Multi-arg
+	re = CRegEx::NewLC(_L8("(\\w+):(\\d+)"));
+	CHECK(re->PartialMatchL(_L8("ruby:1234"), &s, &i));
+	CHECK_EQ(s.Length(), 4);
+	CHECK_EQ(s, _L8("ruby"));
+	CHECK_EQ(i, 1234);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+
+	// Ignore non-void* NULL arg
+	re = CRegEx::NewLC(_L8("he(.*)lo"));
+	CHECK(re->FullMatchL(_L8("hello"), (TDes8*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("123"), (TInt8*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;			
+
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("12345"), (TInt16*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;			
+
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("1234567890"), (TInt32*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;			
+
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("1234567890123456"), (TInt64*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("1234567890"), (TInt*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("123"), (TUint8*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("12345"), (TUint16*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("1234567890"), (TUint32*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("1234567890"), (TUint*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("123.4567890123456"), (TReal32*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("123.4567890123456"), (TReal64*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(re->FullMatchL(_L8("123.4567890123456"), (TReal*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	// Fail on non-void* NULL arg if the match doesn't parse for the given type.
+	re = CRegEx::NewLC(_L8("h(.*)lo"));
+	CHECK(!re->FullMatchL(_L8("hello"), &s, (TDes8*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TInt8*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TInt16*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TInt32*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TInt64*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TInt*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TUint8*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TUint16*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TUint32*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TUint*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TReal32*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TReal64*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("hello"), (TReal*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("1234"), (TInt8*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("123456"), (TInt16*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("12345678901"), (TInt32*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("12345678901"), (TInt*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("1234"), (TUint8*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("123456"), (TUint16*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("12345678901"), (TUint32*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(.*)"));
+	CHECK(!re->FullMatchL(_L8("12345678901"), (TUint*)NULL));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+
+	// Ignored arg
+	re = CRegEx::NewLC(_L8("(\\w+)(:)(\\d+)"));
+	CHECK(re->FullMatchL(_L8("ruby:1234"), &s, (TAny*)NULL, &i));
+	CleanupStack::PopAndDestroy(re);
+	CHECK_EQ(s, _L8("ruby"));
+	CHECK_EQ(i, 1234);
+	re = NULL;		
+
+// Type tests
+		{
+		TChar c;
+		re = CRegEx::NewLC(_L8("(H)ello"));
+		CHECK(re->FullMatchL(_L8("Hello"), &c));
+		CHECK_EQ(c, 'H');
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+		{
+		TInt8 v;
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("-100"), &v));
+		CHECK_EQ(v, -100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("127"), &v));
+		CHECK_EQ(v, KMaxTInt8);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("-128"), &v));
+		CHECK_EQ(v, KMinTInt8);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("128"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-129"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+		{
+		TUint8 v;
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("128"), &v));
+		CHECK_EQ(v, KMaxTInt8 + 1);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("255"), &v));
+		CHECK_EQ(v, KMaxTUint8);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(!re->FullMatchL(_L8("256"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-100"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+		{
+		TInt16 v;
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("-100"), &v));
+		CHECK_EQ(v, -100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("32767"), &v));
+		CHECK_EQ(v, KMaxTInt16);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("-32768"), &v));
+		CHECK_EQ(v, KMinTInt16);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("32768"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-32769"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+		{
+		TUint16 v;
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("32767"), &v));
+		CHECK_EQ(v, KMaxTInt16);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("65535"), &v));
+		CHECK_EQ(v, KMaxTUint16);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(!re->FullMatchL(_L8("655356"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-100"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;		
+		}		
+		{
+		TInt32 v;
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("-100"), &v));
+		CHECK_EQ(v, -100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("2147483647"), &v));
+		CHECK_EQ(v, KMaxTInt32);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("-2147483648"), &v));
+		CHECK_EQ(v, KMinTInt32);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("2147483648"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-2147483649"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}	
+		{
+		TUint32 v;
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("2147483647"), &v));
+		CHECK_EQ(v, KMaxTInt32);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("4294967295"), &v));
+		CHECK_EQ(v, KMaxTUint32);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(!re->FullMatchL(_L8("4294967296"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-100"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;		
+		}
+		{
+		TInt64 v;
+		// Note  TLex treats TInt64 as unsigned
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("9223372036854775807"), &v));
+		CHECK_EQ(v, KMaxTInt64);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-100"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-9223372036854775808"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("9223372036854775808"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-9223372036854775809"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+		{
+		TInt v;
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("-100"), &v));
+		CHECK_EQ(v, -100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("2147483647"), &v));
+		CHECK_EQ(v, KMaxTInt);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(re->FullMatchL(_L8("-2147483648"), &v));
+		CHECK_EQ(v, KMinTInt);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("2147483648"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(-?\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-2147483649"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}	
+		{
+		TUint v;
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);		
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("2147483647"), &v));
+		CHECK_EQ(v, KMaxTInt);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(re->FullMatchL(_L8("4294967295"), &v));
+		CHECK_EQ(v, KMaxTUint);		
+		CleanupStack::PopAndDestroy(re);
+
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(!re->FullMatchL(_L8("4294967296"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		
+		re = CRegEx::NewLC(_L8("(\\d+)"));
+		CHECK(!re->FullMatchL(_L8("-100"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;		
+		}		
+		{
+		TReal32 v;
+		re = CRegEx::NewLC(_L8("(.*)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(.*)"));
+		CHECK(re->FullMatchL(_L8("-100"), &v));
+		CHECK_EQ(v, -100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(.*)"));
+		CHECK(re->FullMatchL(_L8("3.4028234663852885981170418348452e+38"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(.*)"));
+		CHECK(re->FullMatchL(_L8("-1.17549435E-38f"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+		{
+		TReal64 v;
+		re = CRegEx::NewLC(_L8("(.*)"));
+		CHECK(re->FullMatchL(_L8("100"), &v));
+		CHECK_EQ(v, 100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(.*)"));
+		CHECK(re->FullMatchL(_L8("-100"), &v));
+		CHECK_EQ(v, -100);
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(.*)"));
+		CHECK(re->FullMatchL(_L8("1.7976931348623157E+308"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+
+		re = CRegEx::NewLC(_L8("(.*)"));
+		CHECK(re->FullMatchL(_L8("-2.2250738585072015E-308"), &v));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+		
+	// Check that matching is fully anchored
+	re = CRegEx::NewLC(_L8("(\\d+)"));
+	CHECK(!re->FullMatchL(_L8("x1001"), &i));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;	
+	
+	re = CRegEx::NewLC(_L8("(\\d+)"));
+	CHECK(!re->FullMatchL(_L8("1001x"), &i));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;		
+	
+	re = CRegEx::NewLC(_L8("x(\\d+)"));
+	CHECK(re->FullMatchL(_L8("x1001"), &i));
+	CleanupStack::PopAndDestroy(re);
+	CHECK_EQ(i, 1001);
+	re = NULL;		
+	
+	re = CRegEx::NewLC(_L8("(\\d+)x"));
+	CHECK(re->FullMatchL(_L8("1001x"), &i));
+	CleanupStack::PopAndDestroy(re);
+	CHECK_EQ(i, 1001);
+	re = NULL;
+	
+	// Braces
+	re = CRegEx::NewLC(_L8("[0-9a-f+.-]{5,}"));
+	CHECK(re->FullMatchL(_L8("0abcd")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("[0-9a-f+.-]{5,}"));
+	CHECK(re->FullMatchL(_L8("0abcde")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("[0-9a-f+.-]{5,}"));
+	CHECK(!re->FullMatchL(_L8("0abc")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	// Complicated RE
+	re = CRegEx::NewLC(_L8("foo|bar|[A-Z]"));
+	CHECK(re->FullMatchL(_L8("foo")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("foo|bar|[A-Z]"));
+	CHECK(re->FullMatchL(_L8("bar")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("foo|bar|[A-Z]"));
+	CHECK(re->FullMatchL(_L8("X")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	re = CRegEx::NewLC(_L8("foo|bar|[A-Z]"));
+	CHECK(!re->FullMatchL(_L8("XY")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	
+	// Check full-match handling (needs '$' tacked on internally)
+	re = CRegEx::NewLC(_L8("fo|foo"));
+	CHECK(re->FullMatchL(_L8("fo")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("fo|foo"));
+	CHECK(re->FullMatchL(_L8("foo")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("fo|foo$"));
+	CHECK(re->FullMatchL(_L8("fo")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("fo|foo$"));
+	CHECK(re->FullMatchL(_L8("foo")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("foo$"));
+	CHECK(re->FullMatchL(_L8("foo")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("foo\\$"));
+	CHECK(!re->FullMatchL(_L8("foo$bar")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("fo|bar"));
+	CHECK(!re->FullMatchL(_L8("fox")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	// Uncomment the following if we change the handling of '$' to
+	// prevent it from matching a trailing newline
+	if (false)
+		{
+		// Check that we don't get bitten by pcre's special handling of a
+		// '\n' at the end of the string matching '$'
+		re = CRegEx::NewLC(_L8("foo$"));
+		CHECK(!re->PartialMatchL(_L8("foo\n")));
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+
+	// Number of args
+	TInt a[16];
+
+	re = CRegEx::NewLC(_L8(""));
+	CHECK(re->FullMatchL(_L8("")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	memset(a, 0, sizeof(0));
+	re = CRegEx::NewLC(_L8("(\\d){1}"));
+	CHECK(re->FullMatchL(_L8("1"), &a[0]));
+	CHECK_EQ(a[0], 1);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	memset(a, 0, sizeof(0));
+	re = CRegEx::NewLC(_L8("(\\d)(\\d)"));
+	CHECK(re->FullMatchL(_L8("12"), &a[0], &a[1]));
+	CHECK_EQ(a[0], 1);
+	CHECK_EQ(a[1], 2);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	memset(a, 0, sizeof(0));
+	re = CRegEx::NewLC(_L8("(\\d)(\\d)(\\d)"));
+	CHECK(re->FullMatchL(_L8("123"), &a[0], &a[1], &a[2]));
+	CHECK_EQ(a[0], 1);
+	CHECK_EQ(a[1], 2);
+	CHECK_EQ(a[2], 3);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	memset(a, 0, sizeof(0));
+	re = CRegEx::NewLC(_L8("(\\d)(\\d)(\\d)(\\d)"));
+	CHECK(re->FullMatchL(_L8("1234"), &a[0], &a[1], &a[2], &a[3]));
+	CHECK_EQ(a[0], 1);
+	CHECK_EQ(a[1], 2);
+	CHECK_EQ(a[2], 3);
+	CHECK_EQ(a[3], 4);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	// Currently maximum args == 4
+	/*
+	memset(a, 0, sizeof(0));
+	re = CRegEx::NewLC(_L8("(\\d)(\\d)(\\d)(\\d)(\\d)"));
+	CHECK(re->FullMatchL(_L8("12345"), &a[0], &a[1], &a[2], &a[3], &a[4]));
+	CHECK_EQ(a[0], 1);
+	CHECK_EQ(a[1], 2);
+	CHECK_EQ(a[2], 3);
+	CHECK_EQ(a[3], 4);
+	CHECK_EQ(a[4], 5);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	memset(a, 0, sizeof(0));
+	re = CRegEx::NewLC(_L8("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)"));
+	CHECK(re->FullMatchL(_L8("123456"), &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]));
+	CHECK_EQ(a[0], 1);
+	CHECK_EQ(a[1], 2);
+	CHECK_EQ(a[2], 3);
+	CHECK_EQ(a[3], 4);
+	CHECK_EQ(a[4], 5);
+	CHECK_EQ(a[5], 6);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	memset(a, 0, sizeof(0));
+	re = CRegEx::NewLC(_L8("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)"));
+	CHECK(re->FullMatchL(_L8("1234567"), &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6]));
+	CHECK_EQ(a[0], 1);
+	CHECK_EQ(a[1], 2);
+	CHECK_EQ(a[2], 3);
+	CHECK_EQ(a[3], 4);
+	CHECK_EQ(a[4], 5);
+	CHECK_EQ(a[5], 6);
+	CHECK_EQ(a[6], 7);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	memset(a, 0, sizeof(0));
+	re
+			= CRegEx::NewLC(
+					_L8("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)"));
+	CHECK(re->FullMatchL(_L8("1234567890123456"), &a[0], &a[1], &a[2], &a[3],
+					&a[4], &a[5], &a[6], &a[7],
+					&a[8], &a[9], &a[10], &a[11],
+					&a[12],&a[13], &a[14], &a[15]));
+	CHECK_EQ(a[0], 1);
+	CHECK_EQ(a[1], 2);
+	CHECK_EQ(a[2], 3);
+	CHECK_EQ(a[3], 4);
+	CHECK_EQ(a[4], 5);
+	CHECK_EQ(a[5], 6);
+	CHECK_EQ(a[6], 7);
+	CHECK_EQ(a[7], 8);
+	CHECK_EQ(a[8], 9);
+	CHECK_EQ(a[9], 0);
+	CHECK_EQ(a[10], 1);
+	CHECK_EQ(a[11], 2);
+	CHECK_EQ(a[12], 3);
+	CHECK_EQ(a[13], 4);
+	CHECK_EQ(a[14], 5);
+	CHECK_EQ(a[15], 6);
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+	 */
+	
+	/***** PartialMatch *****/
+	console->Write(_L("Testing PartialMatch\n"));
+
+	re = CRegEx::NewLC(_L8("h.*o"));
+	CHECK(re->PartialMatchL(_L8("hello")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("h.*o"));
+	CHECK(re->PartialMatchL(_L8("othello")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("h.*o"));
+	CHECK(re->PartialMatchL(_L8("hello!")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	re = CRegEx::NewLC(_L8("((((((((((((((((((((x))))))))))))))))))))"));
+	CHECK(re->PartialMatchL(_L8("x")));
+	CleanupStack::PopAndDestroy(re);
+	re = NULL;
+
+	/***** other tests *****/
+
+	RadixTestsL();
+	TestReplaceL();
+	TestExtractL();
+	TestConsumeL();
+	TestFindAndConsumeL();
+	TestQuoteMetaAllL();
+	TestMatchNumberPeculiarityL();
+	
+	// Check the pattern() accessor
+		{
+		_LIT8(KPattern, "http://([^/]+)/.*");
+		re = CRegEx::NewLC(KPattern());
+		CHECK_EQ(KPattern(), re->Pattern());
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}	
+		// Check RE error field.
+		{
+		re = CRegEx::NewLC(_L8("foo"));
+		CHECK_EQ(re->Error(), KErrNone);  // Must have no error
+		CleanupStack::PopAndDestroy(re);
+		re = NULL;
+		}
+		
+#ifdef SUPPORT_UTF8
+	  // Check UTF-8 handling
+		{
+		console->Write(_L("Testing UTF-8 handling\n"));
+
+		// Three Japanese characters (nihongo)
+		TBuf8<9> utf8String(_L8("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"));
+		TBuf8<5> utf8Pattern(_L8(".\xE6\x9C\xAC."));
+		TRegExOptions utf8Options;
+		utf8Options.SetUtf8(ETrue);	
+	
+		// Both should match in either mode, bytes or UTF-8
+		CRegEx* re_test1 = CRegEx::NewLC(_L8("........."));
+		CHECK(re_test1->FullMatchL(utf8String));
+		CleanupStack::PopAndDestroy(re_test1);
+		re_test1 = NULL;
+		
+		CRegEx* re_test2 = CRegEx::NewLC(_L8("..."), utf8Options);
+		CHECK(re_test2->FullMatchL(utf8String));
+		CleanupStack::PopAndDestroy(re_test2);
+		re_test2 = NULL;		
+
+		// Check that '.' matches one byte or UTF-8 character
+		// according to the mode.
+		TBuf8<3> ss;
+		
+		CRegEx* re_test3 = CRegEx::NewLC(_L8("(.)"));
+		CHECK(re_test3->PartialMatchL(utf8String, &ss));
+		CHECK_EQ(ss, _L8("\xE6"));
+		CleanupStack::PopAndDestroy(re_test3);
+		re_test3 = NULL;	
+		
+		CRegEx* re_test4 = CRegEx::NewLC(_L8("(.)"), utf8Options);
+		CHECK(re_test4->PartialMatchL(utf8String, &ss));
+		CHECK_EQ(ss, _L8("\xE6\x97\xA5"));
+		CleanupStack::PopAndDestroy(re_test4);
+		re_test4 = NULL;	
+		
+		// Check that string matches itself in either mode
+		CRegEx* re_test5 = CRegEx::NewLC(utf8String);
+		CHECK(re_test5->FullMatchL(utf8String));
+		CleanupStack::PopAndDestroy(re_test5);
+		re_test5 = NULL;	
+		
+		CRegEx* re_test6 = CRegEx::NewLC(utf8String, utf8Options);
+		CHECK(re_test6->FullMatchL(utf8String));
+		CleanupStack::PopAndDestroy(re_test6);
+		re_test6 = NULL;			
+		
+		// Check that pattern matches string only in UTF8 mode
+		CRegEx* re_test7 = CRegEx::NewLC(utf8Pattern);
+		CHECK(!re_test7->FullMatchL(utf8String));
+		CleanupStack::PopAndDestroy(re_test7);
+		re_test7 = NULL;
+		
+		CRegEx* re_test8 = CRegEx::NewLC(utf8Pattern, utf8Options);
+		CHECK(re_test8->FullMatchL(utf8String));
+		CleanupStack::PopAndDestroy(re_test8);
+		re_test8 = NULL;
+		}
+
+	// Check that ungreedy, UTF8 regular expressions don't match when they
+	// oughtn't -- see bug 82246.
+		{
+		// This code always worked.
+		_LIT8(KPattern, "\\w+X");
+		_LIT8(KTarget, "a aX");
+
+		TRegExOptions utf8Options;
+		utf8Options.SetUtf8(ETrue);	
+		
+		CRegEx* matchSentence = CRegEx::NewLC(KPattern());
+		CHECK(!matchSentence->FullMatchL(KTarget()));
+		CleanupStack::PopAndDestroy(matchSentence);
+		matchSentence = NULL;
+		
+		CRegEx* matchSentenceRe = CRegEx::NewLC(KPattern(), utf8Options);
+		CHECK(!matchSentenceRe->FullMatchL(KTarget()));
+		CleanupStack::PopAndDestroy(matchSentenceRe);
+		matchSentenceRe = NULL;
+		}
+		{
+		_LIT8(KPattern, "(?U)\\w+X");
+		_LIT8(KTarget, "a aX");
+
+		TRegExOptions utf8Options;
+		utf8Options.SetUtf8(ETrue);	
+		
+		CRegEx* matchSentence = CRegEx::NewLC(KPattern());
+		CHECK(!matchSentence->FullMatchL(KTarget()));
+		CleanupStack::PopAndDestroy(matchSentence);
+		matchSentence = NULL;
+		
+		CRegEx* matchSentenceRe = CRegEx::NewLC(KPattern(), utf8Options);
+		CHECK(!matchSentenceRe->FullMatchL(KTarget()));
+		CleanupStack::PopAndDestroy(matchSentenceRe);
+		matchSentenceRe = NULL;
+		}
+		
+#endif  /* def SUPPORT_UTF8 */	
+
+  console->Write(_L("Testing error reporting\n"));
+	  {
+	  TRAPD(err, re = CRegEx::NewLC(_L8("a\\1")); CleanupStack::PopAndDestroy());
+	  CHECK(err != KErrNone);
+	  re = NULL;
+	  }
+	  {
+	  TRAPD(err, re = CRegEx::NewLC(_L8("a[x")); CleanupStack::PopAndDestroy());
+	  CHECK(err != KErrNone);
+	  re = NULL;
+	  }
+	  {
+	  TRAPD(err, re = CRegEx::NewLC(_L8("a[z-a]")); CleanupStack::PopAndDestroy());
+	  CHECK(err != KErrNone);
+	  re = NULL;
+	  }
+	  {
+	  TRAPD(err, re = CRegEx::NewLC(_L8("a[[:foobar:]]")); CleanupStack::PopAndDestroy());
+	  CHECK(err != KErrNone);
+	  re = NULL;
+	  }
+	  {
+	  TRAPD(err, re = CRegEx::NewLC(_L8("a(b")); CleanupStack::PopAndDestroy());
+	  CHECK(err != KErrNone);
+	  re = NULL;
+	  }
+	  {
+	  TRAPD(err, re = CRegEx::NewLC(_L8("a\\")); CleanupStack::PopAndDestroy());
+	  CHECK(err != KErrNone);
+	  re = NULL;
+	  }
+	  
+	  // Test that recursion is stopped
+	  TestRecursionL();
+	  
+	  // Test Options
+	  TestOptionsL();
+
+	  // Done
+	  console->Write(_L("OK\n"));
+	}
+LOCAL_C void DoStartL()
+	{
+	// Create active scheduler (to run active objects)
+	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+
+	MainL();
+
+	// Delete active scheduler
+	CleanupStack::PopAndDestroy(scheduler);
+	}
+
+//  Global Functions
+
+GLDEF_C TInt E32Main()
+	{
+	// Create cleanup stack
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	// Create output console
+	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(
+							KConsFullScreen, KConsFullScreen)));
+	if (createError)
+		return createError;
+	// Run application code inside TRAP harness, wait keypress when terminated
+	TRAPD(mainError, DoStartL());
+	if (mainError)
+		console->Printf(KTextFailed, mainError);
+	console->Printf(KTextPressAnyKey);
+	console->Getch();
+
+	delete console;
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/common/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+.\consoleextensions.h \epoc32\include\fshell\consoleextensions.h
+.\consoleextensions.inl \epoc32\include\fshell\consoleextensions.inl
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/common/consoleextensions.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,125 @@
+// consoleextensions.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __CONSOLEEXTENSIONS_H__
+#define __CONSOLEEXTENSIONS_H__
+
+#include <e32base.h>
+
+class ConsoleMode
+	{
+public:
+	enum TMode
+		{
+		EBinary,
+		EText,
+		};
+	static const TUint KSetConsoleModeExtension = 0x10285e15;
+public:
+	/**
+	A console implementation that does not support different mode or a CBase derived class
+	that does not derive from CConsoleBase will return KErrExtensionNotSupported if passed
+	into this function.
+	*/
+	static inline TInt Set(CBase* aConsole, TMode aMode);
+	};
+
+class UnderlyingConsole
+	{
+public:
+	static const TUint KSetUnderlyingConsoleExtension = 0x10287199;
+public:
+	/**
+	Set the underlying console of another console. The underlying console may be used during construction
+	of the actual console to display information or error messages, such as the IP address to connect to
+	in the case of a TCP console implementation.
+	
+	Note, for consoles loaded within the IO server, the underlying console is write only. Attempting to
+	read from it will cause a panic.
+	*/
+	static inline TInt Set(CBase* aConsole, CConsoleBase* aUnderlyingConsole);
+	};
+
+class ConsoleAttributes
+	{
+public:
+	// Note these are also defined in win32cons.h
+	enum TAttribute
+		{
+		ENone			= 0x0001,
+		EBold			= 0x0002,
+		EUnderscore		= 0x0004,
+		EBlink			= 0x0008,
+		EInverse		= 0x0010,
+		EConceal		= 0x0020
+		};
+	enum TColor
+		{
+		EBlack,
+		ERed,
+		EGreen,
+		EYellow,
+		EBlue,
+		EMagenta,
+		ECyan,
+		EWhite,
+		EReset,
+		EUnchanged
+		};
+	class TAttributes
+		{
+	public:
+		inline TAttributes(TUint aAttributes, TColor aForegroundColor = EUnchanged, TColor aBackgroundColor = EUnchanged);
+	public:
+		TUint iAttributes;
+		TColor iForegroundColor;
+		TColor iBackgroundColor;
+		};
+	static const TUint KSetConsoleAttributesExtension = 0x10286B6E;
+public:
+	/**
+	A console implementation that does not support different mode or a CBase derived class
+	that does not derive from CConsoleBase will return KErrExtensionNotSupported if passed
+	into this function.
+	*/
+	static inline TInt Set(CBase* aConsole, const TAttributes& aAttributes);
+	};
+	
+class LazyConsole
+	{
+public:
+	static const TUint KLazyConsoleExtension = 0x1028719e;
+public:
+	/**
+	Returns true if the console is lazy.
+	*/
+	static inline TBool IsLazy(CBase* aConsole);
+	/**
+	Returns true if he console is lazy, AND it's been constructed.
+	*/
+	static inline TBool IsConstructed(CBase* aConsole);
+	};
+
+class ConsoleStdErr
+	{
+public:
+	static const TInt KWriteStdErrConsoleExtension = 0x10286aaa;
+public:
+	/**
+	Write to StdErr of the underlying console if the console supports this.
+	*/
+	static inline TInt Write(CBase* aConsole, const TDesC& aDes);
+	};
+	
+#include <fshell/consoleextensions.inl>
+	
+#endif //__CONSOLEEXTENSIONS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/common/consoleextensions.inl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,63 @@
+// consoleextensions.inl
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// Dummy class used to allow calls into protected Extension_ in a CBase derived class.
+class CBaseExtensionDummy : public CBase
+	{
+public:
+	using CBase::Extension_;
+	};
+
+TInt ConsoleMode::Set(CBase* aConsole, ConsoleMode::TMode aMode)
+	{
+	TAny* ignore;
+	return ((CBaseExtensionDummy*)aConsole)->Extension_(KSetConsoleModeExtension, ignore, reinterpret_cast<TAny*>(aMode));
+	}
+
+TInt UnderlyingConsole::Set(CBase* aConsole, CConsoleBase* aUnderlyingConsole)
+	{
+	TAny* ignore;
+	return ((CBaseExtensionDummy*)aConsole)->Extension_(KSetUnderlyingConsoleExtension, ignore, aUnderlyingConsole);
+	}
+
+ConsoleAttributes::TAttributes::TAttributes(TUint aAttributes, TColor aForegroundColor, TColor aBackgroundColor)
+	: iAttributes(aAttributes), iForegroundColor(aForegroundColor), iBackgroundColor(aBackgroundColor)
+	{
+	}
+
+TInt ConsoleAttributes::Set(CBase* aConsole, const TAttributes& aAttributes)
+	{
+	TAny* ignore;
+	return ((CBaseExtensionDummy*)aConsole)->Extension_(KSetConsoleAttributesExtension, ignore, (TAny*)&aAttributes);
+	}
+
+TBool LazyConsole::IsLazy(CBase* aConsole)
+	{
+	TBool constructed = EFalse;
+	TAny* ignore;
+	TInt err = ((CBaseExtensionDummy*)aConsole)->Extension_(KLazyConsoleExtension, ignore, (TAny*)&constructed);
+	return (err==KErrNone);
+	}
+
+TBool LazyConsole::IsConstructed(CBase* aConsole)
+	{
+	TBool constructed = EFalse;
+	TAny* ignore;
+	TInt err = ((CBaseExtensionDummy*)aConsole)->Extension_(KLazyConsoleExtension, ignore, (TAny*)&constructed);
+	return (err==KErrNone) && (constructed);
+	}
+
+TInt ConsoleStdErr::Write(CBase* aConsole, const TDesC& aDes)
+	{
+	TAny* ignore;
+	return ((CBaseExtensionDummy*)aConsole)->Extension_(KWriteStdErrConsoleExtension, ignore, const_cast<TAny*>((const TAny*)&aDes));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/BMARM/consoleproxyU.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,69 @@
+EXPORTS
+	__20CConsoleProxySessionPFv_P12CConsoleBase @ 1 NONAME R3UNUSED ; CConsoleProxySession::CConsoleProxySession(CConsoleBase *(*)(void))
+	ClearScreen__13RConsoleProxy @ 2 NONAME R3UNUSED ; RConsoleProxy::ClearScreen(void)
+	ClearScreen__13RConsoleProxyR14TRequestStatus @ 3 NONAME R3UNUSED ; RConsoleProxy::ClearScreen(TRequestStatus &)
+	ClearToEndOfLine__13CConsoleProxy @ 4 NONAME R3UNUSED ; CConsoleProxy::ClearToEndOfLine(void)
+	ClearToEndOfLine__13RConsoleProxy @ 5 NONAME R3UNUSED ; RConsoleProxy::ClearToEndOfLine(void)
+	ClearToEndOfLine__13RConsoleProxyR14TRequestStatus @ 6 NONAME R3UNUSED ; RConsoleProxy::ClearToEndOfLine(TRequestStatus &)
+	Connect__13RConsoleProxyG8RServer2 @ 7 NONAME R3UNUSED ; RConsoleProxy::Connect(RServer2)
+	Connect__13RConsoleProxyPFPv_P19CConsoleProxyServerPvRC7TDesC16iiiR8RServer2R7RThread @ 8 NONAME ; RConsoleProxy::Connect(CConsoleProxyServer *(*)(void *), void *, TDesC16 const &, int, int, int, RServer2 &, RThread &)
+	Connect__13RConsoleProxyPFv_P12CConsoleBaseRC7TDesC16iiiR8RServer2R7RThread @ 9 NONAME ; RConsoleProxy::Connect(CConsoleBase *(*)(void), TDesC16 const &, int, int, int, RServer2 &, RThread &)
+	Connect__13RConsoleProxyRC7TDesC16T1 @ 10 NONAME R3UNUSED ; RConsoleProxy::Connect(TDesC16 const &, TDesC16 const &)
+	ConsoleCreatedL__20CConsoleProxySessionP15MProxiedConsole @ 11 NONAME R3UNUSED ; CConsoleProxySession::ConsoleCreatedL(MProxiedConsole *)
+	ConstructL__13CConsoleProxyRC13RConsoleProxy @ 12 NONAME R3UNUSED ; CConsoleProxy::ConstructL(RConsoleProxy const &)
+	ConstructL__19CConsoleProxyServerRC7TDesC16 @ 13 NONAME R3UNUSED ; CConsoleProxyServer::ConstructL(TDesC16 const &)
+	CreateL__20CConsoleProxySession @ 14 NONAME R3UNUSED ; CConsoleProxySession::CreateL(void)
+	Create__13CConsoleProxyRC7TDesC16G5TSize @ 15 NONAME ; CConsoleProxy::Create(TDesC16 const &, TSize)
+	Create__13RConsoleProxyRC7TDesC16G5TSize @ 16 NONAME ; RConsoleProxy::Create(TDesC16 const &, TSize)
+	Create__13RConsoleProxyRC7TDesC16G5TSizeR14TRequestStatus @ 17 NONAME ; RConsoleProxy::Create(TDesC16 const &, TSize, TRequestStatus &)
+	CursorPos__C13CConsoleProxy @ 18 NONAME R3UNUSED ; CConsoleProxy::CursorPos(void) const
+	CursorPos__C13RConsoleProxyR6TPoint @ 19 NONAME R3UNUSED ; RConsoleProxy::CursorPos(TPoint &) const
+	CursorPos__C13RConsoleProxyRt5TPckg1Z6TPointR14TRequestStatus @ 20 NONAME R3UNUSED ; RConsoleProxy::CursorPos(TPckg<TPoint> &, TRequestStatus &) const
+	DefaultL__15MProxiedConsoleP12CConsoleBase @ 21 NONAME R3UNUSED ; MProxiedConsole::DefaultL(CConsoleBase *)
+	DoCreateL__20CConsoleProxySessionRC7TDesC16RC5TSize @ 22 NONAME R3UNUSED ; CConsoleProxySession::DoCreateL(TDesC16 const &, TSize const &)
+	Extension___13CConsoleProxyUiRPvPv @ 23 NONAME ; CConsoleProxy::Extension_(unsigned int, void *&, void *)
+	GetKeyCode__C13RConsoleProxyR8TKeyCode @ 24 NONAME R3UNUSED ; RConsoleProxy::GetKeyCode(TKeyCode &) const
+	GetKeyModifiers__C13RConsoleProxyRUi @ 25 NONAME R3UNUSED ; RConsoleProxy::GetKeyModifiers(unsigned int &) const
+	GetScreenSize__C13RConsoleProxyR5TSize @ 26 NONAME R3UNUSED ; RConsoleProxy::GetScreenSize(TSize &) const
+	GetScreenSize__C13RConsoleProxyRt5TPckg1Z5TSizeR14TRequestStatus @ 27 NONAME R3UNUSED ; RConsoleProxy::GetScreenSize(TPckg<TSize> &, TRequestStatus &) const
+	InstantiateConsoleL__20CConsoleProxySession @ 28 NONAME R3UNUSED ; CConsoleProxySession::InstantiateConsoleL(void)
+	KeyCode__C13CConsoleProxy @ 29 NONAME R3UNUSED ; CConsoleProxy::KeyCode(void) const
+	KeyModifiers__C13CConsoleProxy @ 30 NONAME R3UNUSED ; CConsoleProxy::KeyModifiers(void) const
+	NewL__13CConsoleProxyRC13RConsoleProxy @ 31 NONAME R3UNUSED ; CConsoleProxy::NewL(RConsoleProxy const &)
+	NewL__19CConsoleProxyServerRC7TDesC16iPFv_P12CConsoleBase @ 32 NONAME R3UNUSED ; CConsoleProxyServer::NewL(TDesC16 const &, int, CConsoleBase *(*)(void))
+	NewSessionL__C19CConsoleProxyServerRC8TVersionRC9RMessage2 @ 33 NONAME R3UNUSED ; CConsoleProxyServer::NewSessionL(TVersion const &, RMessage2 const &) const
+	ReadCancel__13CConsoleProxy @ 34 NONAME R3UNUSED ; CConsoleProxy::ReadCancel(void)
+	ReadCancel__13RConsoleProxy @ 35 NONAME R3UNUSED ; RConsoleProxy::ReadCancel(void)
+	ReadComplete__20CConsoleProxySessioni @ 36 NONAME R3UNUSED ; CConsoleProxySession::ReadComplete(int)
+	Read__13CConsoleProxyR14TRequestStatus @ 37 NONAME R3UNUSED ; CConsoleProxy::Read(TRequestStatus &)
+	Read__13RConsoleProxyR14TRequestStatus @ 38 NONAME R3UNUSED ; RConsoleProxy::Read(TRequestStatus &)
+	Read__13RConsoleProxyRt5TPckg1Z8TKeyCodeRt5TPckg1ZUiR14TRequestStatus @ 39 NONAME ; RConsoleProxy::Read(TPckg<TKeyCode> &, TPckg<unsigned int> &, TRequestStatus &)
+	ScreenSize__C13CConsoleProxy @ 40 NONAME R3UNUSED ; CConsoleProxy::ScreenSize(void) const
+	Server__13RConsoleProxyR8RServer2 @ 41 NONAME R3UNUSED ; RConsoleProxy::Server(RServer2 &)
+	ServiceL__20CConsoleProxySessionRC9RMessage2 @ 42 NONAME R3UNUSED ; CConsoleProxySession::ServiceL(RMessage2 const &)
+	SetCursorHeight__13CConsoleProxyi @ 43 NONAME R3UNUSED ; CConsoleProxy::SetCursorHeight(int)
+	SetCursorHeight__13RConsoleProxyi @ 44 NONAME R3UNUSED ; RConsoleProxy::SetCursorHeight(int)
+	SetCursorHeight__13RConsoleProxyiR14TRequestStatus @ 45 NONAME R3UNUSED ; RConsoleProxy::SetCursorHeight(int, TRequestStatus &)
+	SetCursorPosAbs__13CConsoleProxyRC6TPoint @ 46 NONAME R3UNUSED ; CConsoleProxy::SetCursorPosAbs(TPoint const &)
+	SetCursorPosAbs__13RConsoleProxyRC6TPoint @ 47 NONAME R3UNUSED ; RConsoleProxy::SetCursorPosAbs(TPoint const &)
+	SetCursorPosAbs__13RConsoleProxyRC6TPointR14TRequestStatus @ 48 NONAME R3UNUSED ; RConsoleProxy::SetCursorPosAbs(TPoint const &, TRequestStatus &)
+	SetCursorPosRel__13CConsoleProxyRC6TPoint @ 49 NONAME R3UNUSED ; CConsoleProxy::SetCursorPosRel(TPoint const &)
+	SetCursorPosRel__13RConsoleProxyRC6TPoint @ 50 NONAME R3UNUSED ; RConsoleProxy::SetCursorPosRel(TPoint const &)
+	SetCursorPosRel__13RConsoleProxyRC6TPointR14TRequestStatus @ 51 NONAME R3UNUSED ; RConsoleProxy::SetCursorPosRel(TPoint const &, TRequestStatus &)
+	SetTitle__13CConsoleProxyRC7TDesC16 @ 52 NONAME R3UNUSED ; CConsoleProxy::SetTitle(TDesC16 const &)
+	SetTitle__13RConsoleProxyRC7TDesC16 @ 53 NONAME R3UNUSED ; RConsoleProxy::SetTitle(TDesC16 const &)
+	SetTitle__13RConsoleProxyRC7TDesC16R14TRequestStatus @ 54 NONAME R3UNUSED ; RConsoleProxy::SetTitle(TDesC16 const &, TRequestStatus &)
+	ShutdownTimerExpired__19CConsoleProxyServer @ 55 NONAME R3UNUSED ; CConsoleProxyServer::ShutdownTimerExpired(void)
+	Write__13CConsoleProxyRC7TDesC16 @ 56 NONAME R3UNUSED ; CConsoleProxy::Write(TDesC16 const &)
+	Write__13RConsoleProxyRC7TDesC16 @ 57 NONAME R3UNUSED ; RConsoleProxy::Write(TDesC16 const &)
+	Write__13RConsoleProxyRC7TDesC16R14TRequestStatus @ 58 NONAME R3UNUSED ; RConsoleProxy::Write(TDesC16 const &, TRequestStatus &)
+	"_._13CConsoleProxy" @ 59 NONAME R3UNUSED ; CConsoleProxy::~CConsoleProxy(void)
+	"_._19CConsoleProxyServer" @ 60 NONAME R3UNUSED ; CConsoleProxyServer::~CConsoleProxyServer(void)
+	"_._20CConsoleProxySession" @ 61 NONAME R3UNUSED ; CConsoleProxySession::~CConsoleProxySession(void)
+	__13CConsoleProxy @ 62 NONAME R3UNUSED ; CConsoleProxy::CConsoleProxy(void)
+	__19CConsoleProxyServerPFv_P12CConsoleBasei @ 63 NONAME R3UNUSED ; CConsoleProxyServer::CConsoleProxyServer(CConsoleBase *(*)(void), int)
+	__20CConsoleProxySessionP15MProxiedConsole @ 64 NONAME R3UNUSED ; CConsoleProxySession::CConsoleProxySession(MProxiedConsole *)
+	ClearScreen__13CConsoleProxy @ 65 NONAME R3UNUSED ; CConsoleProxy::ClearScreen(void)
+	IsConstructed__13RConsoleProxyRi @ 66 NONAME R3UNUSED ; RConsoleProxy::IsConstructed(int &)
+	SetAttributes__13RConsoleProxyUiQ217ConsoleAttributes6TColorT2R14TRequestStatus @ 67 NONAME ; RConsoleProxy::SetAttributes(unsigned int, ConsoleAttributes::TColor, ConsoleAttributes::TColor, TRequestStatus &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/bwins/consoleproxyu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,69 @@
+EXPORTS
+	??0CConsoleProxyServer@@IAE@P6APAVCConsoleBase@@XZH@Z @ 1 NONAME ; CConsoleProxyServer::CConsoleProxyServer(class CConsoleBase * (*)(void), int)
+	??0CConsoleProxySession@@QAE@P6APAVCConsoleBase@@XZ@Z @ 2 NONAME ; CConsoleProxySession::CConsoleProxySession(class CConsoleBase * (*)(void))
+	??0CConsoleProxySession@@QAE@PAVMProxiedConsole@@@Z @ 3 NONAME ; CConsoleProxySession::CConsoleProxySession(class MProxiedConsole *)
+	??1CConsoleProxyServer@@UAE@XZ @ 4 NONAME ; CConsoleProxyServer::~CConsoleProxyServer(void)
+	??1CConsoleProxySession@@UAE@XZ @ 5 NONAME ; CConsoleProxySession::~CConsoleProxySession(void)
+	?ClearScreen@RConsoleProxy@@QAEHXZ @ 6 NONAME ; int RConsoleProxy::ClearScreen(void)
+	?ClearScreen@RConsoleProxy@@QAEXAAVTRequestStatus@@@Z @ 7 NONAME ; void RConsoleProxy::ClearScreen(class TRequestStatus &)
+	?ClearToEndOfLine@RConsoleProxy@@QAEHXZ @ 8 NONAME ; int RConsoleProxy::ClearToEndOfLine(void)
+	?ClearToEndOfLine@RConsoleProxy@@QAEXAAVTRequestStatus@@@Z @ 9 NONAME ; void RConsoleProxy::ClearToEndOfLine(class TRequestStatus &)
+	?Connect@RConsoleProxy@@QAEHABVTDesC16@@0@Z @ 10 NONAME ; int RConsoleProxy::Connect(class TDesC16 const &, class TDesC16 const &)
+	?Connect@RConsoleProxy@@QAEHP6APAVCConsoleBase@@XZABVTDesC16@@HHHAAVRServer2@@AAVRThread@@@Z @ 11 NONAME ; int RConsoleProxy::Connect(class CConsoleBase * (*)(void), class TDesC16 const &, int, int, int, class RServer2 &, class RThread &)
+	?Connect@RConsoleProxy@@QAEHP6APAVCConsoleProxyServer@@PAX@Z0ABVTDesC16@@HHHAAVRServer2@@AAVRThread@@@Z @ 12 NONAME ; int RConsoleProxy::Connect(class CConsoleProxyServer * (*)(void *), void *, class TDesC16 const &, int, int, int, class RServer2 &, class RThread &)
+	?Connect@RConsoleProxy@@QAEHVRServer2@@@Z @ 13 NONAME ; int RConsoleProxy::Connect(class RServer2)
+	?ConstructL@CConsoleProxyServer@@IAEXABVTDesC16@@@Z @ 14 NONAME ; void CConsoleProxyServer::ConstructL(class TDesC16 const &)
+	?Create@RConsoleProxy@@QAEHABVTDesC16@@VTSize@@@Z @ 15 NONAME ; int RConsoleProxy::Create(class TDesC16 const &, class TSize)
+	?Create@RConsoleProxy@@QAEXABVTDesC16@@VTSize@@AAVTRequestStatus@@@Z @ 16 NONAME ; void RConsoleProxy::Create(class TDesC16 const &, class TSize, class TRequestStatus &)
+	?InstantiateConsoleL@CConsoleProxySession@@MAEPAVMProxiedConsole@@XZ @ 17 NONAME ; class MProxiedConsole * CConsoleProxySession::InstantiateConsoleL(void)
+	?CursorPos@RConsoleProxy@@QBEHAAVTPoint@@@Z @ 18 NONAME ; int RConsoleProxy::CursorPos(class TPoint &) const
+	?CursorPos@RConsoleProxy@@QBEXAAV?$TPckg@VTPoint@@@@AAVTRequestStatus@@@Z @ 19 NONAME ; void RConsoleProxy::CursorPos(class TPckg<class TPoint> &, class TRequestStatus &) const
+	?GetKeyCode@RConsoleProxy@@QBEHAAW4TKeyCode@@@Z @ 20 NONAME ; int RConsoleProxy::GetKeyCode(enum TKeyCode &) const
+	?GetKeyModifiers@RConsoleProxy@@QBEHAAI@Z @ 21 NONAME ; int RConsoleProxy::GetKeyModifiers(unsigned int &) const
+	?GetScreenSize@RConsoleProxy@@QBEHAAVTSize@@@Z @ 22 NONAME ; int RConsoleProxy::GetScreenSize(class TSize &) const
+	?GetScreenSize@RConsoleProxy@@QBEXAAV?$TPckg@VTSize@@@@AAVTRequestStatus@@@Z @ 23 NONAME ; void RConsoleProxy::GetScreenSize(class TPckg<class TSize> &, class TRequestStatus &) const
+	?NewL@CConsoleProxyServer@@SAPAV1@ABVTDesC16@@HP6APAVCConsoleBase@@XZ@Z @ 24 NONAME ; class CConsoleProxyServer * CConsoleProxyServer::NewL(class TDesC16 const &, int, class CConsoleBase * (*)(void))
+	?NewSessionL@CConsoleProxyServer@@MBEPAVCSession2@@ABVTVersion@@ABVRMessage2@@@Z @ 25 NONAME ; class CSession2 * CConsoleProxyServer::NewSessionL(class TVersion const &, class RMessage2 const &) const
+	?Read@RConsoleProxy@@QAEXAAVTRequestStatus@@@Z @ 26 NONAME ; void RConsoleProxy::Read(class TRequestStatus &)
+	?ReadCancel@RConsoleProxy@@QAEXXZ @ 27 NONAME ; void RConsoleProxy::ReadCancel(void)
+	?ReadComplete@CConsoleProxySession@@QAEXH@Z @ 28 NONAME ; void CConsoleProxySession::ReadComplete(int)
+	?Server@RConsoleProxy@@QAEHAAVRServer2@@@Z @ 29 NONAME ; int RConsoleProxy::Server(class RServer2 &)
+	?ServiceL@CConsoleProxySession@@UAEXABVRMessage2@@@Z @ 30 NONAME ; void CConsoleProxySession::ServiceL(class RMessage2 const &)
+	?SetCursorHeight@RConsoleProxy@@QAEHH@Z @ 31 NONAME ; int RConsoleProxy::SetCursorHeight(int)
+	?SetCursorHeight@RConsoleProxy@@QAEXHAAVTRequestStatus@@@Z @ 32 NONAME ; void RConsoleProxy::SetCursorHeight(int, class TRequestStatus &)
+	?SetCursorPosAbs@RConsoleProxy@@QAEHABVTPoint@@@Z @ 33 NONAME ; int RConsoleProxy::SetCursorPosAbs(class TPoint const &)
+	?SetCursorPosAbs@RConsoleProxy@@QAEXABVTPoint@@AAVTRequestStatus@@@Z @ 34 NONAME ; void RConsoleProxy::SetCursorPosAbs(class TPoint const &, class TRequestStatus &)
+	?SetCursorPosRel@RConsoleProxy@@QAEHABVTPoint@@@Z @ 35 NONAME ; int RConsoleProxy::SetCursorPosRel(class TPoint const &)
+	?SetCursorPosRel@RConsoleProxy@@QAEXABVTPoint@@AAVTRequestStatus@@@Z @ 36 NONAME ; void RConsoleProxy::SetCursorPosRel(class TPoint const &, class TRequestStatus &)
+	?SetTitle@RConsoleProxy@@QAEHABVTDesC16@@@Z @ 37 NONAME ; int RConsoleProxy::SetTitle(class TDesC16 const &)
+	?SetTitle@RConsoleProxy@@QAEXABVTDesC16@@AAVTRequestStatus@@@Z @ 38 NONAME ; void RConsoleProxy::SetTitle(class TDesC16 const &, class TRequestStatus &)
+	?ShutdownTimerExpired@CConsoleProxyServer@@MAEXXZ @ 39 NONAME ; void CConsoleProxyServer::ShutdownTimerExpired(void)
+	?Write@RConsoleProxy@@QAEHABVTDesC16@@@Z @ 40 NONAME ; int RConsoleProxy::Write(class TDesC16 const &)
+	?Write@RConsoleProxy@@QAEXABVTDesC16@@AAVTRequestStatus@@@Z @ 41 NONAME ; void RConsoleProxy::Write(class TDesC16 const &, class TRequestStatus &)
+	?CreateL@CConsoleProxySession@@UAEXXZ @ 42 NONAME ; void CConsoleProxySession::CreateL(void)
+	??0CConsoleProxy@@IAE@XZ @ 43 NONAME ; CConsoleProxy::CConsoleProxy(void)
+	??1CConsoleProxy@@UAE@XZ @ 44 NONAME ; CConsoleProxy::~CConsoleProxy(void)
+	?ClearScreen@CConsoleProxy@@UAEXXZ @ 45 NONAME ; void CConsoleProxy::ClearScreen(void)
+	?ClearToEndOfLine@CConsoleProxy@@UAEXXZ @ 46 NONAME ; void CConsoleProxy::ClearToEndOfLine(void)
+	?ConstructL@CConsoleProxy@@IAEXABVRConsoleProxy@@@Z @ 47 NONAME ; void CConsoleProxy::ConstructL(class RConsoleProxy const &)
+	?Create@CConsoleProxy@@UAEHABVTDesC16@@VTSize@@@Z @ 48 NONAME ; int CConsoleProxy::Create(class TDesC16 const &, class TSize)
+	?CursorPos@CConsoleProxy@@UBE?AVTPoint@@XZ @ 49 NONAME ; class TPoint CConsoleProxy::CursorPos(void) const
+	?Extension_@CConsoleProxy@@MAEHIAAPAXPAX@Z @ 50 NONAME ; int CConsoleProxy::Extension_(unsigned int, void * &, void *)
+	?KeyCode@CConsoleProxy@@UBE?AW4TKeyCode@@XZ @ 51 NONAME ; enum TKeyCode CConsoleProxy::KeyCode(void) const
+	?KeyModifiers@CConsoleProxy@@UBEIXZ @ 52 NONAME ; unsigned int CConsoleProxy::KeyModifiers(void) const
+	?NewL@CConsoleProxy@@SAPAV1@ABVRConsoleProxy@@@Z @ 53 NONAME ; class CConsoleProxy * CConsoleProxy::NewL(class RConsoleProxy const &)
+	?Read@CConsoleProxy@@UAEXAAVTRequestStatus@@@Z @ 54 NONAME ; void CConsoleProxy::Read(class TRequestStatus &)
+	?ReadCancel@CConsoleProxy@@UAEXXZ @ 55 NONAME ; void CConsoleProxy::ReadCancel(void)
+	?ScreenSize@CConsoleProxy@@UBE?AVTSize@@XZ @ 56 NONAME ; class TSize CConsoleProxy::ScreenSize(void) const
+	?SetCursorHeight@CConsoleProxy@@UAEXH@Z @ 57 NONAME ; void CConsoleProxy::SetCursorHeight(int)
+	?SetCursorPosAbs@CConsoleProxy@@UAEXABVTPoint@@@Z @ 58 NONAME ; void CConsoleProxy::SetCursorPosAbs(class TPoint const &)
+	?SetCursorPosRel@CConsoleProxy@@UAEXABVTPoint@@@Z @ 59 NONAME ; void CConsoleProxy::SetCursorPosRel(class TPoint const &)
+	?SetTitle@CConsoleProxy@@UAEXABVTDesC16@@@Z @ 60 NONAME ; void CConsoleProxy::SetTitle(class TDesC16 const &)
+	?Write@CConsoleProxy@@UAEXABVTDesC16@@@Z @ 61 NONAME ; void CConsoleProxy::Write(class TDesC16 const &)
+	?Read@RConsoleProxy@@QAEXAAV?$TPckg@W4TKeyCode@@@@AAV?$TPckg@I@@AAVTRequestStatus@@@Z @ 62 NONAME ; void RConsoleProxy::Read(class TPckg<enum TKeyCode> &, class TPckg<unsigned int> &, class TRequestStatus &)
+	?DoCreateL@CConsoleProxySession@@IAEXABVTDesC16@@ABVTSize@@@Z @ 63 NONAME ; void CConsoleProxySession::DoCreateL(class TDesC16 const &, class TSize const &)
+	?ConsoleCreatedL@CConsoleProxySession@@MAEXPAVMProxiedConsole@@@Z @ 64 NONAME ; void CConsoleProxySession::ConsoleCreatedL(class MProxiedConsole *)
+	?DefaultL@MProxiedConsole@@SAPAV1@PAVCConsoleBase@@@Z @ 65 NONAME ; class MProxiedConsole * MProxiedConsole::DefaultL(class CConsoleBase *)
+	?SetAttributes@RConsoleProxy@@QAEXIW4TColor@ConsoleAttributes@@0AAVTRequestStatus@@@Z @ 66 NONAME ; void RConsoleProxy::SetAttributes(unsigned int, enum ConsoleAttributes::TColor, enum ConsoleAttributes::TColor, class TRequestStatus &)
+	?IsConstructed@RConsoleProxy@@QAEHAAH@Z @ 67 NONAME ; int RConsoleProxy::IsConstructed(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/eabi/consoleproxyu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,85 @@
+EXPORTS
+	_ZN13RConsoleProxy10ReadCancelEv @ 1 NONAME
+	_ZN13RConsoleProxy11ClearScreenER14TRequestStatus @ 2 NONAME
+	_ZN13RConsoleProxy11ClearScreenEv @ 3 NONAME
+	_ZN13RConsoleProxy15SetCursorHeightEi @ 4 NONAME
+	_ZN13RConsoleProxy15SetCursorHeightEiR14TRequestStatus @ 5 NONAME
+	_ZN13RConsoleProxy15SetCursorPosAbsERK6TPoint @ 6 NONAME
+	_ZN13RConsoleProxy15SetCursorPosAbsERK6TPointR14TRequestStatus @ 7 NONAME
+	_ZN13RConsoleProxy15SetCursorPosRelERK6TPoint @ 8 NONAME
+	_ZN13RConsoleProxy15SetCursorPosRelERK6TPointR14TRequestStatus @ 9 NONAME
+	_ZN13RConsoleProxy16ClearToEndOfLineER14TRequestStatus @ 10 NONAME
+	_ZN13RConsoleProxy16ClearToEndOfLineEv @ 11 NONAME
+	_ZN13RConsoleProxy4ReadER14TRequestStatus @ 12 NONAME
+	_ZN13RConsoleProxy5WriteERK7TDesC16 @ 13 NONAME
+	_ZN13RConsoleProxy5WriteERK7TDesC16R14TRequestStatus @ 14 NONAME
+	_ZN13RConsoleProxy6CreateERK7TDesC165TSize @ 15 NONAME
+	_ZN13RConsoleProxy6CreateERK7TDesC165TSizeR14TRequestStatus @ 16 NONAME
+	_ZN13RConsoleProxy6ServerER8RServer2 @ 17 NONAME
+	_ZN13RConsoleProxy7ConnectE8RServer2 @ 18 NONAME
+	_ZN13RConsoleProxy7ConnectEPFP12CConsoleBasevERK7TDesC16iiiR8RServer2R7RThread @ 19 NONAME
+	_ZN13RConsoleProxy7ConnectEPFP19CConsoleProxyServerPvES2_RK7TDesC16iiiR8RServer2R7RThread @ 20 NONAME
+	_ZN13RConsoleProxy7ConnectERK7TDesC16S2_ @ 21 NONAME
+	_ZN13RConsoleProxy8SetTitleERK7TDesC16 @ 22 NONAME
+	_ZN13RConsoleProxy8SetTitleERK7TDesC16R14TRequestStatus @ 23 NONAME
+	_ZN19CConsoleProxyServer10ConstructLERK7TDesC16 @ 24 NONAME
+	_ZN19CConsoleProxyServer20ShutdownTimerExpiredEv @ 25 NONAME
+	_ZN19CConsoleProxyServer4NewLERK7TDesC16iPFP12CConsoleBasevE @ 26 NONAME
+	_ZN19CConsoleProxyServerC1EPFP12CConsoleBasevEi @ 27 NONAME
+	_ZN19CConsoleProxyServerC2EPFP12CConsoleBasevEi @ 28 NONAME
+	_ZN19CConsoleProxyServerD0Ev @ 29 NONAME
+	_ZN19CConsoleProxyServerD1Ev @ 30 NONAME
+	_ZN19CConsoleProxyServerD2Ev @ 31 NONAME
+	_ZN20CConsoleProxySession12ReadCompleteEi @ 32 NONAME
+	_ZN20CConsoleProxySession19InstantiateConsoleLEv @ 33 NONAME
+	_ZN20CConsoleProxySession8ServiceLERK9RMessage2 @ 34 NONAME
+	_ZN20CConsoleProxySessionC1EP15MProxiedConsole @ 35 NONAME
+	_ZN20CConsoleProxySessionC1EPFP12CConsoleBasevE @ 36 NONAME
+	_ZN20CConsoleProxySessionC2EP15MProxiedConsole @ 37 NONAME
+	_ZN20CConsoleProxySessionC2EPFP12CConsoleBasevE @ 38 NONAME
+	_ZN20CConsoleProxySessionD0Ev @ 39 NONAME
+	_ZN20CConsoleProxySessionD1Ev @ 40 NONAME
+	_ZN20CConsoleProxySessionD2Ev @ 41 NONAME
+	_ZNK13RConsoleProxy10GetKeyCodeER8TKeyCode @ 42 NONAME
+	_ZNK13RConsoleProxy13GetScreenSizeER5TPckgI5TSizeER14TRequestStatus @ 43 NONAME
+	_ZNK13RConsoleProxy13GetScreenSizeER5TSize @ 44 NONAME
+	_ZNK13RConsoleProxy15GetKeyModifiersERj @ 45 NONAME
+	_ZNK13RConsoleProxy9CursorPosER5TPckgI6TPointER14TRequestStatus @ 46 NONAME
+	_ZNK13RConsoleProxy9CursorPosER6TPoint @ 47 NONAME
+	_ZNK19CConsoleProxyServer11NewSessionLERK8TVersionRK9RMessage2 @ 48 NONAME
+	_ZTI19CConsoleProxyServer @ 49 NONAME ; #<TI>#
+	_ZTI20CConsoleProxySession @ 50 NONAME ; #<TI>#
+	_ZTV19CConsoleProxyServer @ 51 NONAME ; #<VT>#
+	_ZTV20CConsoleProxySession @ 52 NONAME ; #<VT>#
+	_ZN20CConsoleProxySession7CreateLEv @ 53 NONAME
+	_ZN13CConsoleProxy10ConstructLERK13RConsoleProxy @ 54 NONAME
+	_ZN13CConsoleProxy10Extension_EjRPvS0_ @ 55 NONAME
+	_ZN13CConsoleProxy10ReadCancelEv @ 56 NONAME
+	_ZN13CConsoleProxy11ClearScreenEv @ 57 NONAME
+	_ZN13CConsoleProxy15SetCursorHeightEi @ 58 NONAME
+	_ZN13CConsoleProxy15SetCursorPosAbsERK6TPoint @ 59 NONAME
+	_ZN13CConsoleProxy15SetCursorPosRelERK6TPoint @ 60 NONAME
+	_ZN13CConsoleProxy16ClearToEndOfLineEv @ 61 NONAME
+	_ZN13CConsoleProxy4NewLERK13RConsoleProxy @ 62 NONAME
+	_ZN13CConsoleProxy4ReadER14TRequestStatus @ 63 NONAME
+	_ZN13CConsoleProxy5WriteERK7TDesC16 @ 64 NONAME
+	_ZN13CConsoleProxy6CreateERK7TDesC165TSize @ 65 NONAME
+	_ZN13CConsoleProxy8SetTitleERK7TDesC16 @ 66 NONAME
+	_ZN13CConsoleProxyC1Ev @ 67 NONAME
+	_ZN13CConsoleProxyC2Ev @ 68 NONAME
+	_ZN13CConsoleProxyD0Ev @ 69 NONAME
+	_ZN13CConsoleProxyD1Ev @ 70 NONAME
+	_ZN13CConsoleProxyD2Ev @ 71 NONAME
+	_ZNK13CConsoleProxy10ScreenSizeEv @ 72 NONAME
+	_ZNK13CConsoleProxy12KeyModifiersEv @ 73 NONAME
+	_ZNK13CConsoleProxy7KeyCodeEv @ 74 NONAME
+	_ZNK13CConsoleProxy9CursorPosEv @ 75 NONAME
+	_ZTI13CConsoleProxy @ 76 NONAME ; #<TI>#
+	_ZTV13CConsoleProxy @ 77 NONAME ; #<VT>#
+	_ZN13RConsoleProxy4ReadER5TPckgI8TKeyCodeERS0_IjER14TRequestStatus @ 78 NONAME
+	_ZN20CConsoleProxySession9DoCreateLERK7TDesC16RK5TSize @ 79 NONAME
+	_ZN20CConsoleProxySession15ConsoleCreatedLEP15MProxiedConsole @ 80 NONAME
+	_ZN15MProxiedConsole8DefaultLEP12CConsoleBase @ 81 NONAME
+	_ZN13RConsoleProxy13SetAttributesEjN17ConsoleAttributes6TColorES1_R14TRequestStatus @ 82 NONAME
+	_ZN13RConsoleProxy13IsConstructedERi @ 83 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+// bld.inf
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+..\inc\consoleproxy.h	\epoc32\include\fshell\consoleproxy.h
+FSHELL_ROM_INCLUDE(consoleproxy.iby)
+
+PRJ_MMPFILES
+.\consoleproxy.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/group/consoleproxy.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// consoleproxy.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __CONSOLEPROXY_IBY__
+#define __CONSOLEPROXY_IBY__
+
+#include <fsh_config.iby>
+FSHELL_EXECUTABLE_FILE(consoleproxy.dll)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/group/consoleproxy.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// consoleproxy.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target          consoleproxy.dll
+targettype      dll
+capability      FSHELL_CAP_MMP_MAX
+UID		FSHELL_UID_CONSOLEPROXY
+
+systeminclude   ..\inc
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath      ..\src
+
+source          client.cpp
+source          server.cpp
+
+library         euser.lib
+
+deffile         consoleproxy.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/inc/consoleproxy.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,284 @@
+// consoleproxy.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __CONSOLEPROXY_H__
+#define __CONSOLEPROXY_H__
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <fshell/consoleextensions.h>
+
+class CConsoleProxyServer;
+class TServerParams;
+
+typedef CConsoleBase* (*TConsoleCreateFunction)();
+typedef CConsoleProxyServer* (*TServerNewL)(TAny*);
+
+enum TConsoleProxyPanic
+	{
+	EConsoleAlreadyCreated = 0,
+	ENoConsoleInstatiated = 1,
+	};
+	
+void Panic(TConsoleProxyPanic aReason);
+
+class RConsoleProxy : public RSessionBase
+	{
+public:
+	enum TOpCode
+		{
+		EGetServer,
+		ECreate,
+		ERead,
+		EReadKey,
+		EReadCancel,
+		EWrite,
+		EGetCursorPos,
+		ESetCursorPosAbs,
+		ESetCursorPosRel,
+		ESetCursorHeight,
+		ESetTitle,
+		EClearScreen,
+		EClearToEndOfLine,
+		EGetScreenSize,
+		EGetKeyCode,
+		EGetKeyModifiers,
+		ESetAttributes,
+		EIsConstructed,
+		
+		EOpCodeCustomBase = 1000,
+		};
+public:
+	/**
+	Create a new sub-thread to host a console and connect to it.
+
+	@param aConsoleCreate Function pointer to create the console in the new thread
+	@param aServer On return, the handle of the server running in the sub thread. Ownership is NOT returned
+			to the caller.
+	@param aServerThread On return, the handle to the thread that the server is running in. Ownership is
+			returned to the caller.
+	*/
+	IMPORT_C TInt Connect(TConsoleCreateFunction aConsoleCreate, const TDesC& aThreadNameBase,
+							TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize,
+							RServer2& aServer, RThread& aServerThread);
+	
+	/**
+	Create a new sub-thread to host a console and connect to it, using a custom CConsoleProxyServer derived
+	server.
+	
+	@param aServerConstructor NewL of the server class
+	@param aServerParams Parameters to pass into the server NewL.
+	@param aServer On return, the handle of the server running in the sub thread. Ownership is NOT returned
+			to the caller.
+	@param aServerThread On return, the handle to the thread that the server is running in. Ownership is
+			returned to the caller.
+	*/
+	IMPORT_C TInt Connect(TServerNewL aServerConstructor, TAny* aServerParams, const TDesC& aThreadNameBase,
+							TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize,
+							RServer2& aServer, RThread& aServerThread);
+	
+	/**
+	Connects to a console hosted with the given server.
+	*/
+	IMPORT_C TInt Connect(RServer2 aServer);
+	/**
+	Connect to a console created within another process. 
+	*/
+	IMPORT_C TInt Connect(const TDesC& aServerName, const TDesC& aServerArgs = KNullDesC);
+	
+	IMPORT_C TInt Server(RServer2& aServer);
+	
+	IMPORT_C TInt Create(const TDesC& aConsoleTitle, TSize aSize);
+	IMPORT_C void Read(TRequestStatus& aStatus);
+	IMPORT_C void Read(TPckg<TKeyCode>& aKeyCode, TPckg<TUint>& aKeyModifiers, TRequestStatus& aStatus);
+	IMPORT_C void ReadCancel();
+	IMPORT_C TInt Write(const TDesC& aDescriptor);
+	IMPORT_C TInt CursorPos(TPoint& aPos) const;
+	IMPORT_C TInt SetCursorPosAbs(const TPoint& aPoint);
+	IMPORT_C TInt SetCursorPosRel(const TPoint& aPoint);
+	IMPORT_C TInt SetCursorHeight(TInt aPercentage);
+	IMPORT_C TInt SetTitle(const TDesC& aTitle);
+	IMPORT_C TInt ClearScreen();
+	IMPORT_C TInt ClearToEndOfLine();
+	IMPORT_C TInt GetScreenSize(TSize& aSize) const;
+	IMPORT_C TInt GetKeyCode(TKeyCode& aCode) const;
+	IMPORT_C TInt GetKeyModifiers(TUint& aModifiers) const;
+	
+	IMPORT_C void Create(const TDesC& aConsoleTitle, TSize aSize, TRequestStatus& aStatus);
+	IMPORT_C void Write(const TDesC& aDescriptor, TRequestStatus& aStatus);
+	IMPORT_C void CursorPos(TPckg<TPoint>& aPoint, TRequestStatus& aStatus) const;
+	IMPORT_C void SetCursorPosAbs(const TPoint& aPoint, TRequestStatus& aStatus);
+	IMPORT_C void SetCursorPosRel(const TPoint& aPoint, TRequestStatus& aStatus);
+	IMPORT_C void SetCursorHeight(TInt aPercentage, TRequestStatus& aStatus);
+	IMPORT_C void SetTitle(const TDesC& aTitle, TRequestStatus& aStatus);
+	IMPORT_C void ClearScreen(TRequestStatus& aStatus);
+	IMPORT_C void ClearToEndOfLine(TRequestStatus& aStatus);
+	IMPORT_C void GetScreenSize(TPckg<TSize>& aSize, TRequestStatus& aStatus) const;
+	IMPORT_C void SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, TRequestStatus& aStatus);
+	IMPORT_C TInt IsConstructed(TBool& aLazy);
+private:
+	TInt DoConnect(TServerParams* aParams, const TDesC& aThreadNameBase,
+			TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize,
+			RServer2& aServer, RThread& aServerThread);
+	};
+	
+class CConsoleProxy : public CConsoleBase
+	{
+public:
+	/**
+	Create a CConsoleBase wrapper around an RConsoleProxy.
+	
+	@param aProxySession A connected session. The handle will be duplicated by this class,
+			so ownership is  not transferred.
+	*/
+	IMPORT_C static CConsoleProxy* NewL(const RConsoleProxy& aProxySession);
+	IMPORT_C ~CConsoleProxy();
+public: // from CConsoleBase
+	IMPORT_C virtual TInt Create(const TDesC &aTitle,TSize aSize);
+	IMPORT_C virtual void Read(TRequestStatus &aStatus);
+	IMPORT_C virtual void ReadCancel();
+	IMPORT_C virtual void Write(const TDesC &aDes);
+	IMPORT_C virtual TPoint CursorPos() const;
+	IMPORT_C virtual void SetCursorPosAbs(const TPoint &aPoint);
+	IMPORT_C virtual void SetCursorPosRel(const TPoint &aPoint);
+	IMPORT_C virtual void SetCursorHeight(TInt aPercentage);
+	IMPORT_C virtual void SetTitle(const TDesC &aTitle);
+	IMPORT_C virtual void ClearScreen();
+	IMPORT_C virtual void ClearToEndOfLine();
+	IMPORT_C virtual TSize ScreenSize() const;
+	IMPORT_C virtual TKeyCode KeyCode() const;
+	IMPORT_C virtual TUint KeyModifiers() const;
+protected:
+	IMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+	IMPORT_C CConsoleProxy();
+	IMPORT_C void ConstructL(const RConsoleProxy& aProxySession);
+protected:
+	RConsoleProxy iConsole;
+	TKeyCode iKeyCode;
+	TUint iKeyModifiers;
+	TPckg<TKeyCode> iKeyCodePckg;
+	TPckg<TUint> iKeyModifiersPckg;
+	};
+	
+class CConsoleProxySession;
+
+class MProxiedConsole
+	{
+public:
+	IMPORT_C static MProxiedConsole* DefaultL(CConsoleBase* aConsole);
+public:
+	virtual void Open() = 0;
+	virtual void Close() = 0;
+	virtual CConsoleBase* Console() = 0;
+	virtual void Read(CConsoleProxySession& aSession) = 0;
+	virtual void ReadCancel() = 0;
+	};
+	
+class TConsoleProxyServerNewLParams
+	{
+public:
+	TConsoleProxyServerNewLParams(const TDesC& aName, TInt aAoPriority, TConsoleCreateFunction aConsoleCreate = NULL)
+		: iName(aName), iAoPriority(aAoPriority), iConsoleCreate(aConsoleCreate) {}
+public:
+	const TDesC& iName;
+	TInt iAoPriority;
+	TConsoleCreateFunction iConsoleCreate;
+	};
+	
+class CShutdownTimer;
+
+class CConsoleProxyServer : public CServer2
+	{
+public:
+	static CConsoleProxyServer* NewL(TAny* aParams); // aParams is TConsoleProxyServerNewLParams*
+	IMPORT_C static CConsoleProxyServer* NewL(const TDesC& aName, TInt aAoPriority, TConsoleCreateFunction aConsoleCreate = NULL);
+	
+	IMPORT_C virtual ~CConsoleProxyServer();
+
+	void AddSession();
+	void DropSession();
+protected:
+	IMPORT_C CConsoleProxyServer(TConsoleCreateFunction aConsoleCreate, TInt aAoPriority);
+	IMPORT_C void ConstructL(const TDesC& aName);
+	
+	/**
+	Called after a timeout when
+	- no session connects to the server after startup
+	- the last session disconnects
+	and stops the active scheduler. Can be over-ridden to change the behaviour in these cases.
+	*/
+	IMPORT_C virtual void ShutdownTimerExpired();
+	
+	// from CServer2:
+	IMPORT_C virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+protected:
+	TConsoleCreateFunction iConsoleCreate;
+private:
+	TInt iSessionCount;
+	CShutdownTimer* iShutdownTimer;
+	friend class CShutdownTimer;
+	};
+	
+class CConsoleProxySession	: public CSession2
+	{
+public:
+	IMPORT_C CConsoleProxySession(TConsoleCreateFunction aConsoleCreate);
+	IMPORT_C CConsoleProxySession(MProxiedConsole* aConsole);
+	IMPORT_C virtual ~CConsoleProxySession();
+	
+	CConsoleProxyServer* Server() { return (CConsoleProxyServer*)CSession2::Server();}
+		
+	
+	// from CSession2:
+	IMPORT_C virtual void ServiceL(const RMessage2& aMessage);
+	IMPORT_C virtual void CreateL();
+	
+	// callback from from MProxiedConsole:
+	IMPORT_C void ReadComplete(TInt aStatus);
+protected:
+	/**
+	Creates the console using the given title and size. The console must not already have
+	been created.
+	*/
+	IMPORT_C void DoCreateL(const TDesC& aTitle, const TSize& aSize);
+	/**
+	Instantiate the CConsoleBase class, but don't call Create() on it; return it wrapped up
+	inside a MProxiedConsole derived class.
+	*/
+	IMPORT_C virtual MProxiedConsole* InstantiateConsoleL();
+	/**
+	Called just after a console has been successfully Create()'d, to perform any extra
+	configuration necessary. Default implementation does nothing.
+	
+	Note, iConsole will not have been set yet. If this leaves, it causes construction
+	of the console to fail.
+	*/
+	IMPORT_C virtual void ConsoleCreatedL(MProxiedConsole* aConsole);
+private:
+	void CreateL(const RMessage2& aMessage);
+protected:
+	TConsoleCreateFunction iConsoleCreate;
+	MProxiedConsole* iConsole;
+	RMessagePtr2 iReadMessage;
+	enum 
+		{
+		EReadBasic,
+		EReadKeys,
+		} iReadType;
+	TKeyCode iKeyCode;
+	TUint iKeyModifiers;
+	};
+
+
+
+
+#endif //__CONSOLEPROXY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/src/client.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,418 @@
+// client.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <consoleproxy.h>
+#include "server.h"
+
+//______________________________________________________________________________
+//						RConsoleProxy
+static TInt StartServer(const TDesC& aServerName, const TDesC& aServerArgs)
+	{
+	TPtrC processName(aServerName);
+	if (processName.Length() && processName[0] == '!')
+		{
+		processName.Set(processName.Mid(1));
+		}
+	RProcess server;
+	TInt r = server.Create(processName, aServerArgs);
+	if (r!=KErrNone) return r;
+	TRequestStatus stat;
+	server.Rendezvous(stat);
+	if (stat != KRequestPending)
+		{
+		server.Kill(0);
+		}
+	else
+		{
+		server.Resume();
+		}
+	User::WaitForRequest(stat);		// wait for start or death
+	r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
+	server.Close();
+	return r;
+	}
+	
+EXPORT_C TInt RConsoleProxy::Connect(const TDesC& aServerName, const TDesC& aServerArgs)
+	{
+	TInt retry = 2;
+	for (;;)
+		{
+		TInt r = CreateSession(aServerName, TVersion(0,0,0));
+		if ((r != KErrNotFound) && (r != KErrServerTerminated))
+			{
+			return r;
+			}
+		if (--retry == 0)
+			{
+			return r;
+			}
+		r = StartServer(aServerName, aServerArgs);
+		if ((r != KErrNone) && (r != KErrAlreadyExists))
+			{
+			return r;
+			}
+		}
+	}
+
+EXPORT_C TInt RConsoleProxy::Connect(RServer2 aServer)
+	{
+	return CreateSession(aServer, TVersion(0,0,0));
+	}
+	
+EXPORT_C TInt RConsoleProxy::Connect(TConsoleCreateFunction aConsoleCreate, const TDesC& aThreadNameBase, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, RServer2& aServer, RThread& aServerThread)
+	{
+	TConsoleProxyServerNewLParams newLParams(KNullDesC, CActive::EPriorityStandard, aConsoleCreate);
+	TServerParams params;
+	params.iServerNewL = &CConsoleProxyServer::NewL;
+	params.iServerParams = &newLParams;
+	return DoConnect(&params, aThreadNameBase, aStackSize, aHeapMinSize, aHeapMaxSize, aServer, aServerThread);
+	}
+	
+EXPORT_C TInt RConsoleProxy::Connect(TServerNewL aServerConstructor, TAny* aServerParams, const TDesC& aThreadNameBase, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, RServer2& aServer, RThread& aServerThread)
+	{
+	TServerParams params;
+	params.iServerNewL = aServerConstructor;
+	params.iServerParams = aServerParams;
+	return DoConnect(&params, aThreadNameBase, aStackSize, aHeapMinSize, aHeapMaxSize, aServer, aServerThread);
+	}
+	
+TInt RConsoleProxy::DoConnect(TServerParams* aParams, const TDesC& aThreadNameBase, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, RServer2& aServer, RThread& aServerThread)
+	{
+	TName threadName;
+	RThread server;
+	TInt threadId = 0;
+	_LIT(KThreadIdFmt, "%08x");
+	TInt err;
+	do
+		{
+		threadName = aThreadNameBase.Left(threadName.MaxLength()-8);
+		threadName.AppendFormat(KThreadIdFmt, threadId);
+		err = server.Create(threadName, &ServerThreadFunction, aStackSize, aHeapMinSize, aHeapMaxSize, aParams);
+		++threadId;
+		} while (err==KErrAlreadyExists);
+	if (err!=KErrNone) return err;
+	
+	TRequestStatus rendezvous;
+	server.Rendezvous(rendezvous);
+	if (rendezvous == KRequestPending)
+		{
+		server.Resume();
+		}
+	User::WaitForRequest(rendezvous);
+	err = rendezvous.Int();
+	if (server.ExitType() != EExitPending && err >= 0) err = KErrDied;
+	if (err==KErrNone)
+		{
+		err = Connect(aParams->iServer);
+		}
+	aServer = aParams->iServer;
+	aServerThread = server;
+	return err;
+	}
+
+
+EXPORT_C TInt RConsoleProxy::Server(RServer2& aServer)
+	{
+	TInt r = SendReceive(EGetServer);
+	return aServer.SetReturnedHandle(r);
+	}
+
+EXPORT_C void RConsoleProxy::Create(const TDesC& aConsoleTitle, TSize aSize, TRequestStatus& aStatus)
+	{
+	SendReceive(ECreate, TIpcArgs(&aConsoleTitle, aSize.iWidth, aSize.iHeight), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::Read(TRequestStatus& aStatus)
+	{
+	SendReceive(ERead, aStatus);
+	}
+	
+EXPORT_C void RConsoleProxy::Read(TPckg<TKeyCode>& aKeyCode, TPckg<TUint>& aKeyModifiers, TRequestStatus& aStatus)
+	{
+	SendReceive(EReadKey, TIpcArgs(&aKeyCode, &aKeyModifiers), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::ReadCancel()
+	{
+	Send(EReadCancel);
+	}
+
+EXPORT_C void RConsoleProxy::Write(const TDesC& aDescriptor, TRequestStatus& aStatus)
+	{
+	SendReceive(EWrite, TIpcArgs(&aDescriptor), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::CursorPos(TPckg<TPoint>& aPos, TRequestStatus& aStatus) const
+	{
+	SendReceive(EGetCursorPos, TIpcArgs(&aPos), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::SetCursorPosAbs(const TPoint& aPoint, TRequestStatus& aStatus)
+	{
+	SendReceive(ESetCursorPosAbs, TIpcArgs(aPoint.iX, aPoint.iY), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::SetCursorPosRel(const TPoint& aPoint, TRequestStatus& aStatus)
+	{
+	SendReceive(ESetCursorPosRel, TIpcArgs(aPoint.iX, aPoint.iY), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::SetCursorHeight(TInt aPercentage, TRequestStatus& aStatus)
+	{
+	SendReceive(ESetCursorHeight, TIpcArgs(aPercentage), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::SetTitle(const TDesC& aTitle, TRequestStatus& aStatus)
+	{
+	SendReceive(ESetTitle, TIpcArgs(&aTitle), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::ClearScreen(TRequestStatus& aStatus)
+	{
+	SendReceive(EClearScreen, aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::ClearToEndOfLine(TRequestStatus& aStatus)
+	{
+	SendReceive(EClearToEndOfLine, aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::GetScreenSize(TPckg<TSize>& aSize, TRequestStatus& aStatus) const
+	{
+	SendReceive(EGetScreenSize, TIpcArgs(&aSize), aStatus);
+	}
+
+EXPORT_C void RConsoleProxy::SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, TRequestStatus& aStatus)
+	{
+	SendReceive(ESetAttributes, TIpcArgs(aAttributes, aForegroundColor, aBackgroundColor), aStatus);
+	}
+	
+EXPORT_C TInt RConsoleProxy::IsConstructed(TBool& aLazy)
+	{
+	TPckg<TBool> constructed(aLazy);
+	return SendReceive(EIsConstructed, TIpcArgs(&constructed));
+	}
+
+EXPORT_C TInt RConsoleProxy::GetKeyCode(TKeyCode& aCode) const
+	{
+	TPckg<TKeyCode> kc(aCode);
+	return SendReceive(EGetKeyCode, TIpcArgs(&(kc)));
+	}
+
+EXPORT_C TInt RConsoleProxy::GetKeyModifiers(TUint& aModifiers) const
+	{
+	TPckg<TUint> mod(aModifiers);
+	return SendReceive(EGetKeyCode, TIpcArgs(&mod));
+	}
+
+EXPORT_C TInt RConsoleProxy::Create(const TDesC& aConsoleTitle, TSize aSize)
+	{
+	TRequestStatus stat;
+	Create(aConsoleTitle, aSize, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::Write(const TDesC& aDescriptor)
+	{
+	TRequestStatus stat;
+	Write(aDescriptor, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::CursorPos(TPoint& aPos) const
+	{
+	TRequestStatus stat;
+	TPckg<TPoint> pos(aPos);
+	CursorPos(pos, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	TRequestStatus stat;
+	SetCursorPosAbs(aPoint, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::SetCursorPosRel(const TPoint& aPoint)
+	{
+	TRequestStatus stat;
+	SetCursorPosRel(aPoint, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::SetCursorHeight(TInt aPercentage)
+	{
+	TRequestStatus stat;
+	SetCursorHeight(aPercentage, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::SetTitle(const TDesC& aTitle)
+	{
+	TRequestStatus stat;
+	SetTitle(aTitle, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::ClearScreen()
+	{
+	TRequestStatus stat;
+	ClearScreen(stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::ClearToEndOfLine()
+	{
+	TRequestStatus stat;
+	ClearToEndOfLine(stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+EXPORT_C TInt RConsoleProxy::GetScreenSize(TSize& aSize) const
+	{
+	TRequestStatus stat;
+	TPckg<TSize> size(aSize);
+	GetScreenSize(size, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+//______________________________________________________________________________
+//						CConsoleProxy
+EXPORT_C CConsoleProxy* CConsoleProxy::NewL(const RConsoleProxy& aProxySession)
+	{
+	CConsoleProxy* self = new(ELeave)CConsoleProxy();
+	CleanupStack::PushL(self);
+	self->ConstructL(aProxySession);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CConsoleProxy::CConsoleProxy()
+	: iKeyCodePckg(iKeyCode), iKeyModifiersPckg(iKeyModifiers)
+	{
+	}
+
+EXPORT_C TInt CConsoleProxy::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	if (aExtensionId == ConsoleAttributes::KSetConsoleAttributesExtension)
+		{
+		TRequestStatus status;
+		ConsoleAttributes::TAttributes* attributes = (ConsoleAttributes::TAttributes*)a1;
+		iConsole.SetAttributes(attributes->iAttributes, attributes->iForegroundColor, attributes->iBackgroundColor, status);
+		User::WaitForRequest(status);
+		return status.Int();
+		}
+	if (aExtensionId == LazyConsole::KLazyConsoleExtension)
+		{
+		TBool* constructed = (TBool*)a1;
+		return iConsole.IsConstructed(*constructed);
+		}
+	return CConsoleBase::Extension_(aExtensionId, a0, a1);
+	}
+	
+EXPORT_C void CConsoleProxy::ConstructL(const RConsoleProxy& aProxySession)
+	{
+	RConsoleProxy cons = aProxySession;
+	User::LeaveIfError(cons.Duplicate(RThread(), EOwnerThread));
+	iConsole = cons;
+	}
+
+EXPORT_C CConsoleProxy::~CConsoleProxy()
+	{
+	iConsole.Close();
+	}
+
+EXPORT_C TInt CConsoleProxy::Create(const TDesC &aTitle, TSize aSize)
+	{
+	return iConsole.Create(aTitle, aSize);
+	}
+
+EXPORT_C void CConsoleProxy::Read(TRequestStatus &aStatus)
+	{
+	iConsole.Read(iKeyCodePckg, iKeyModifiersPckg, aStatus);
+	}
+
+EXPORT_C void CConsoleProxy::ReadCancel()
+	{
+	iConsole.ReadCancel();
+	}
+
+EXPORT_C void CConsoleProxy::Write(const TDesC &aDes)
+	{
+	iConsole.Write(aDes);
+	}
+
+EXPORT_C TPoint CConsoleProxy::CursorPos() const
+	{
+	TPoint pos;
+	iConsole.CursorPos(pos);
+	return pos;
+	}
+
+
+EXPORT_C void CConsoleProxy::SetCursorPosAbs(const TPoint &aPoint)
+	{
+	iConsole.SetCursorPosAbs(aPoint);
+	}
+
+EXPORT_C void CConsoleProxy::SetCursorPosRel(const TPoint &aPoint)
+	{
+	iConsole.SetCursorPosRel(aPoint);
+	}
+
+EXPORT_C void CConsoleProxy::SetCursorHeight(TInt aPercentage)
+	{
+	iConsole.SetCursorHeight(aPercentage);
+	}
+
+EXPORT_C void CConsoleProxy::SetTitle(const TDesC &aTitle)
+	{
+	iConsole.SetTitle(aTitle);
+	}
+
+EXPORT_C void CConsoleProxy::ClearScreen()
+	{
+	iConsole.ClearScreen();
+	}
+
+EXPORT_C void CConsoleProxy::ClearToEndOfLine()
+	{
+	iConsole.ClearToEndOfLine();
+	}
+
+EXPORT_C TSize CConsoleProxy::ScreenSize() const
+	{
+	TSize size;
+	iConsole.GetScreenSize(size);
+	return size;
+	}
+
+EXPORT_C TKeyCode CConsoleProxy::KeyCode() const
+	{
+	return iKeyCode;
+	}
+
+EXPORT_C TUint CConsoleProxy::KeyModifiers() const
+	{
+	return iKeyModifiers;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/src/server.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,456 @@
+// server.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <consoleproxy.h>
+#include "server.h"
+
+_LIT(KPronxyConsolePanic, "proxyconsole");
+	
+void Panic(TConsoleProxyPanic aReason)
+	{
+	User::Panic(KPronxyConsolePanic, aReason);
+	}
+
+
+void ServerThreadL(TServerParams* aParams)
+	{
+	CActiveScheduler* as = new(ELeave)CActiveScheduler;
+	CleanupStack::PushL(as);
+	CActiveScheduler::Install(as);
+	
+	CConsoleProxyServer* server = (aParams->iServerNewL)(aParams->iServerParams);
+	CleanupStack::PushL(server);
+	
+	aParams->iServer = server->Server();
+	RThread::Rendezvous(KErrNone);
+	
+	CActiveScheduler::Start();
+	
+	CleanupStack::PopAndDestroy(2, as);
+	}
+		
+
+TInt ServerThreadFunction(TAny* aArgs)
+	{
+	__UHEAP_MARK;
+	User::SetCritical(User::ENotCritical);
+	
+	TServerParams* params = (TServerParams*)aArgs;
+	
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	if (!cleanup)
+		{
+		return KErrNoMemory;
+		}
+		
+	TRAPD(err, ServerThreadL(params));
+		
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return err;
+	}
+		
+//______________________________________________________________________________
+//						CConsoleProxyServer
+CConsoleProxyServer* CConsoleProxyServer::NewL(TAny* aParams)
+	{
+	TConsoleProxyServerNewLParams* params = (TConsoleProxyServerNewLParams*)aParams;
+	return NewL(params->iName, params->iAoPriority, params->iConsoleCreate);
+	}
+	
+EXPORT_C CConsoleProxyServer* CConsoleProxyServer::NewL(const TDesC& aName, TInt aAoPriority, TConsoleCreateFunction aConsoleCreate)
+	{
+	CConsoleProxyServer* self = new(ELeave)CConsoleProxyServer(aConsoleCreate, aAoPriority);
+	CleanupStack::PushL(self);
+	self->ConstructL(aName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+EXPORT_C void CConsoleProxyServer::ConstructL(const TDesC& aName)
+	{
+	StartL(aName);
+	iShutdownTimer = CShutdownTimer::NewL(*this);
+	iShutdownTimer->Start();
+	}
+
+EXPORT_C CConsoleProxyServer::CConsoleProxyServer(TConsoleCreateFunction aConsoleCreate, TInt aAoPriority)
+	: CServer2(aAoPriority, CServer2::ESharableSessions)
+	, iConsoleCreate(aConsoleCreate)
+	{
+	}
+
+EXPORT_C CConsoleProxyServer::~CConsoleProxyServer()
+	{
+	delete iShutdownTimer;
+	iShutdownTimer = NULL; // Can be referenced by session destructors which run after this, as part of ~CServer2, which will call ~CConsoleProxySession which can call DropSession...
+	}
+	
+EXPORT_C void CConsoleProxyServer::ShutdownTimerExpired()
+	{
+	CActiveScheduler::Stop();
+	}
+
+EXPORT_C CSession2* CConsoleProxyServer::NewSessionL(const TVersion&,const RMessage2&) const
+	{
+	return new(ELeave)CConsoleProxySession(iConsoleCreate);
+	}
+
+void CConsoleProxyServer::AddSession()
+	{
+	iShutdownTimer->Cancel();
+	++iSessionCount;
+	}
+
+void CConsoleProxyServer::DropSession()
+	{
+	--iSessionCount;
+	if ((iSessionCount==0) && iShutdownTimer && (!iShutdownTimer->IsActive()))
+		{
+		iShutdownTimer->Start();
+		}
+	}
+
+//______________________________________________________________________________
+//						CConsoleProxySession
+EXPORT_C CConsoleProxySession::CConsoleProxySession(TConsoleCreateFunction aConsoleCreate)
+	: iConsoleCreate(aConsoleCreate)
+	{
+	}
+	
+EXPORT_C CConsoleProxySession::CConsoleProxySession(MProxiedConsole* aConsole)
+	: iConsole(aConsole)
+	{
+	iConsole->Open();
+	}
+
+EXPORT_C CConsoleProxySession::~CConsoleProxySession()
+	{
+	Server()->DropSession();
+	if (!iReadMessage.IsNull())
+		{
+		iReadMessage.Complete(KErrDisconnected);
+		if (iConsole) iConsole->ReadCancel();
+		}
+	if (iConsole) iConsole->Close();
+	}
+
+EXPORT_C void CConsoleProxySession::CreateL()
+	{
+	Server()->AddSession();
+	}
+
+EXPORT_C void CConsoleProxySession::ServiceL(const RMessage2& aMessage)
+	{
+	if (!iConsole && (aMessage.Function() != RConsoleProxy::ECreate))
+		{
+		User::Leave(KErrNotReady);
+		}
+	RBuf buf;
+	CleanupClosePushL(buf);
+	TBool complete = ETrue;
+	switch (aMessage.Function())
+		{
+	case RConsoleProxy::ECreate:
+		CreateL(aMessage);
+		break;
+	case RConsoleProxy::ERead:
+		if (!iReadMessage.IsNull()) User::Leave(KErrAlreadyExists);
+		iReadType = EReadBasic;
+		iReadMessage = aMessage;
+		iConsole->Read(*this);
+		complete = EFalse;
+		break;
+	case RConsoleProxy::EReadKey:
+		if (!iReadMessage.IsNull()) User::Leave(KErrAlreadyExists);
+		iReadType = EReadKeys;
+		iReadMessage = aMessage;
+		iConsole->Read(*this);
+		complete = EFalse;
+		break;
+	case RConsoleProxy::EReadCancel:
+		if (!iReadMessage.IsNull())
+			{
+			iReadMessage.Complete(KErrCancel);
+			iConsole->ReadCancel();
+			}
+		break;
+	case RConsoleProxy::EWrite:
+		buf.CreateL(aMessage.GetDesLengthL(0));
+		aMessage.ReadL(0, buf);
+		iConsole->Console()->Write(buf);
+		break;
+	case RConsoleProxy::EGetCursorPos:
+		{
+		TPckgBuf<TPoint> pos;
+		pos() = iConsole->Console()->CursorPos();
+		aMessage.WriteL(0, pos);
+		break;
+		}
+	case RConsoleProxy::ESetCursorPosAbs:
+		{
+		TPoint pos(aMessage.Int0(), aMessage.Int1());
+		iConsole->Console()->SetCursorPosAbs(pos);
+		break;
+		}
+	case RConsoleProxy::ESetCursorPosRel:
+		{
+		TPoint pos(aMessage.Int0(), aMessage.Int1());
+		iConsole->Console()->SetCursorPosRel(pos);
+		break;
+		}
+	case RConsoleProxy::ESetCursorHeight:
+		iConsole->Console()->SetCursorHeight(aMessage.Int0());
+		break;
+	case RConsoleProxy::ESetTitle:
+		buf.CreateL(aMessage.GetDesLengthL(0));
+		aMessage.ReadL(0, buf);
+		iConsole->Console()->SetTitle(buf);
+		break;
+	case RConsoleProxy::EClearScreen:
+		iConsole->Console()->ClearScreen();
+		break;
+	case RConsoleProxy::EClearToEndOfLine:
+		iConsole->Console()->ClearToEndOfLine();
+		break;
+	case RConsoleProxy::EGetScreenSize:
+		{
+		TPckgBuf<TSize> size;
+		if (aMessage.GetDesLengthL(0)!=size.Length()) User::Leave(KErrArgument);
+		size() = iConsole->Console()->ScreenSize();
+		aMessage.WriteL(0, size);
+		break;
+		}
+	case RConsoleProxy::EGetKeyCode:
+		{
+		TPckg<TKeyCode> kc(iKeyCode);
+		if (aMessage.GetDesLengthL(0)!=kc.Length()) User::Leave(KErrArgument);
+		aMessage.WriteL(0, kc);
+		break;
+		}
+	case RConsoleProxy::EGetKeyModifiers:
+		{
+		TPckg<TUint> mod(iKeyModifiers);
+		if (aMessage.GetDesLengthL(0)!=mod.Length()) User::Leave(KErrArgument);
+		aMessage.WriteL(0, mod);
+		break;
+		}
+	case RConsoleProxy::ESetAttributes:
+		{
+		if (!iConsole) User::Leave(KErrNotReady);
+		ConsoleAttributes::TAttributes attributes((TUint)aMessage.Int0(), (ConsoleAttributes::TColor)aMessage.Int1(), (ConsoleAttributes::TColor)aMessage.Int2());
+		TInt err = ConsoleAttributes::Set(iConsole->Console(), attributes);
+		aMessage.Complete(err);
+		complete = EFalse;
+		break;
+		}
+	case RConsoleProxy::EIsConstructed:
+		{
+		if (aMessage.GetDesLengthL(0)!=sizeof(TBool)) User::Leave(KErrArgument);
+		if (!iConsole) User::Leave(KErrNotReady);
+		if (!LazyConsole::IsLazy(iConsole->Console())) User::Leave(KErrExtensionNotSupported);
+		TPckgBuf<TBool> constructed = LazyConsole::IsConstructed(iConsole->Console());
+		aMessage.WriteL(0, constructed);
+		complete = ETrue;
+		break;
+		}
+	default:
+		aMessage.Complete(KErrNotSupported);
+		}
+	CleanupStack::PopAndDestroy(&buf);
+	if (complete)
+		{
+		aMessage.Complete(KErrNone);
+		}
+	}
+	
+EXPORT_C void CConsoleProxySession::ReadComplete(TInt aStatus)
+	{
+	iKeyCode = iConsole->Console()->KeyCode();
+	iKeyModifiers = iConsole->Console()->KeyModifiers();
+	if (!iReadMessage.IsNull())
+		{
+		TInt err = aStatus;
+		if (iReadType == EReadKeys)
+			{
+			if (err == KErrNone)
+				{
+				err = iReadMessage.Write(0, TPckg<TKeyCode>(iKeyCode));
+				}
+			if (err == KErrNone)
+				{
+				err = iReadMessage.Write(1, TPckg<TUint>(iKeyModifiers));
+				}	
+			}
+		
+		iReadMessage.Complete(err);
+		}
+	}
+	
+EXPORT_C void CConsoleProxySession::DoCreateL(const TDesC& aTitle, const TSize& aSize)
+	{
+	__ASSERT_ALWAYS(!iConsole, Panic(EConsoleAlreadyCreated));
+	MProxiedConsole* cons = InstantiateConsoleL();
+	__ASSERT_ALWAYS(cons, Panic(ENoConsoleInstatiated));
+	CleanupClosePushL(*cons);
+	TName procName = RProcess().Name(); // econseik sets the process name to the console title...
+	TInt err = cons->Console()->Create(aTitle, aSize);
+	User::RenameProcess(procName.Left(procName.Locate('['))); // ...so restore it just in case
+	User::LeaveIfError(err);
+	
+	ConsoleCreatedL(cons);
+	
+	iConsole = cons;
+	CleanupStack::Pop(cons);
+	}
+	
+EXPORT_C void CConsoleProxySession::ConsoleCreatedL(MProxiedConsole*)
+	{
+	}
+
+void CConsoleProxySession::CreateL(const RMessage2& aMessage)
+	{
+	if (iConsole) User::Leave(KErrAlreadyExists);
+	RBuf title;
+	title.CreateL(aMessage.GetDesLengthL(0));
+	CleanupClosePushL(title);
+	aMessage.ReadL(0, title);
+	
+	TSize size(aMessage.Int1(), aMessage.Int2());
+	
+	DoCreateL(title, size);
+	
+	CleanupStack::PopAndDestroy(&title);
+	}
+
+EXPORT_C MProxiedConsole* CConsoleProxySession::InstantiateConsoleL()
+	{
+	return CConsoleWrapper::NewL(iConsoleCreate);
+	}
+
+
+//______________________________________________________________________________
+//						MProxiedConsole
+EXPORT_C MProxiedConsole* MProxiedConsole::DefaultL(CConsoleBase* aConsole)
+	{
+	return CConsoleWrapper::NewL(aConsole);
+	}
+//______________________________________________________________________________
+//						CConsoleWrapper
+CConsoleWrapper* CConsoleWrapper::NewL(TConsoleCreateFunction aConsoleCreate)
+	{
+	CConsoleWrapper* self = new(ELeave)CConsoleWrapper;
+	CleanupStack::PushL(self);
+	self->ConstructL(aConsoleCreate);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CConsoleWrapper* CConsoleWrapper::NewL(CConsoleBase* aConsole)
+	{
+	CConsoleWrapper* self = new(ELeave)CConsoleWrapper;
+	self->iConsole = aConsole;
+	return self;	
+	}
+	
+CConsoleWrapper::~CConsoleWrapper()
+	{
+	Cancel();
+	delete iConsole;
+	}
+
+void CConsoleWrapper::Open()
+	{
+	++iRefCount;
+	}
+
+void CConsoleWrapper::Close()
+	{
+	--iRefCount;
+	if (!iRefCount)
+		{
+		delete this;
+		}
+	}
+
+CConsoleBase* CConsoleWrapper::Console()
+	{
+	return iConsole;
+	}
+
+void CConsoleWrapper::Read(CConsoleProxySession& aSession)
+	{
+	if (!IsActive())
+		{
+		iReader = &aSession;
+		iConsole->Read(iStatus);
+		SetActive();
+		}
+	}
+
+void CConsoleWrapper::ReadCancel()
+	{
+	Cancel();
+	iReader = NULL;
+	}
+
+void CConsoleWrapper::RunL()
+	{
+	iReader->ReadComplete(iStatus.Int());
+	}
+
+void CConsoleWrapper::DoCancel()
+	{
+	iConsole->ReadCancel();
+	}
+
+void CConsoleWrapper::ConstructL(TConsoleCreateFunction aConsoleCreate)
+	{
+	iConsole = aConsoleCreate();
+	User::LeaveIfNull(iConsole);
+	}
+
+CConsoleWrapper::CConsoleWrapper()
+	: CActive(CActive::EPriorityStandard)
+	, iRefCount(1)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+
+//______________________________________________________________________________
+//						CShutdownTimer
+CShutdownTimer* CShutdownTimer::NewL(CConsoleProxyServer& aServer)
+	{
+	CShutdownTimer* self = new(ELeave)CShutdownTimer(aServer);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CShutdownTimer::CShutdownTimer(CConsoleProxyServer& aServer)
+	: CTimer(CActive::EPriorityLow), iServer(aServer)
+	{
+	CActiveScheduler::Add(this);
+	}
+	
+void CShutdownTimer::Start()
+	{
+	After(KServerShutdownTimer);
+	}
+
+void CShutdownTimer::RunL()
+	{
+	iServer.ShutdownTimerExpired();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/consoleproxy/src/server.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,68 @@
+// server.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SERVER_H__
+#define __SERVER_H__
+
+static const TInt KServerShutdownTimer = 500000;
+
+TInt ServerThreadFunction(TAny* aArgs);
+
+class TServerParams
+	{
+public:
+	TServerNewL iServerNewL;
+	TAny* iServerParams;
+	RServer2 iServer;
+	};
+	
+NONSHARABLE_CLASS(CConsoleWrapper)	: public CActive
+									, public MProxiedConsole
+	{
+public:
+	static CConsoleWrapper* NewL(TConsoleCreateFunction aConsoleCreate);
+	static CConsoleWrapper* NewL(CConsoleBase* aConsole);
+	~CConsoleWrapper();
+private:
+	// from MProxiedConsole:
+	virtual void Open();
+	virtual void Close();
+	virtual CConsoleBase* Console();
+	virtual void Read(CConsoleProxySession& aSession);
+	virtual void ReadCancel();
+	// from CActive:
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	void ConstructL(TConsoleCreateFunction aConsoleCreate);
+	CConsoleWrapper();
+private:
+	TInt iRefCount;
+	CConsoleBase* iConsole;
+	CConsoleProxySession* iReader;
+	};
+	
+NONSHARABLE_CLASS(CShutdownTimer) : public CTimer
+	{
+public:
+	static CShutdownTimer* NewL(CConsoleProxyServer& aServer);
+	void Start();
+private:
+	CShutdownTimer(CConsoleProxyServer& aServer);
+	virtual void RunL();
+private:
+	CConsoleProxyServer& iServer;
+	};
+
+
+
+#endif //__SERVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/defcons/bmarm/defconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME R3UNUSED ; (null)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/defcons/bwins/defconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/defcons/eabi/defconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/defcons/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(defcons.iby)
+
+PRJ_MMPFILES
+..\src\defcons
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/defcons/group/defcons.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// defcons.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __DEFCONS_IBY__
+#define __DEFCONS_IBY__
+
+#include <fsh_config.iby>
+FSHELL_EXECUTABLE_FILE(defcons.dll)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/defcons/src/defcons.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,275 @@
+// defcons.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32std.h>
+#include <e32cons.h>
+#include <e32keys.h>
+#include <e32uid.h>
+#ifdef __WINS__
+#include <e32wins.h>
+#endif
+#include <fshell/descriptorutils.h>
+
+
+//
+// Constants.
+//
+
+const LtkUtils::SLitC KConsoleImplementations[] =
+	{
+	DESC("guicons"),
+	DESC("econseik"),
+	DESC("econs"),
+	DESC("nullcons")
+	};
+const TInt KNumConsoleImplementations = sizeof(KConsoleImplementations) / sizeof(LtkUtils::SLitC);
+
+
+/**
+
+  The default console implementation, used by iosrv. This console implentation has
+  two reasons to exist:
+
+  1) To hunt for a suitable real console implementation to be used by default. On
+     GUI configurations this will either be guicons.dll or econseik.dll. On text
+	 configurations this will be econs.dll.
+
+  2) To delay the creation of the real console implementation until it is known
+     to be needed. This is useful because CCommandBase creates a default console
+	 even if --console has been specified on the command line. The default console
+	 may be used by the specified console during its construction to interact with
+	 the user (e.g. vt100tcpcons uses it to tell the user which TCP port and IP
+	 address it is listening on). However, if it weren't to be used, the user
+	 would see the default console briefly appear and then disappear when the
+	 actual console is created. Delaying the creation of the console underlying
+	 the default console avoids this.
+
+*/
+NONSHARABLE_CLASS(CDefaultConsole) : public CConsoleBase
+	{
+public:
+	enum TPanicReason
+		{
+		EDoubleRead = 0,
+		EUnableToCreateConsole = 1
+		};
+public:
+	CDefaultConsole();
+	virtual ~CDefaultConsole();
+	virtual TInt Create(const TDesC &aTitle, TSize aSize);
+	virtual void Read(TRequestStatus& aStatus);
+	virtual void ReadCancel();
+	virtual void Write(const TDesC &aDes);
+	virtual TPoint CursorPos() const;
+	virtual void SetCursorPosAbs(const TPoint &aPoint);
+	virtual void SetCursorPosRel(const TPoint &aPoint);
+	virtual void SetCursorHeight(TInt aPercentage);
+	virtual void SetTitle(const TDesC &aTitle);
+	virtual void ClearScreen();
+	virtual void ClearToEndOfLine();
+	virtual TSize ScreenSize() const;
+	virtual TKeyCode KeyCode() const;
+	virtual TUint KeyModifiers() const;
+	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+private:
+	void CreateIfRequired();
+	void CreateIfRequired() const;
+	TInt TryCreateConsole(const TDesC& aImplementation);
+	void Panic(TPanicReason aReason);
+private:
+	HBufC* iTitle;
+	TSize iSize;
+	RLibrary iConsoleLibrary;
+	CConsoleBase* iUnderlyingConsole;
+	};
+
+CDefaultConsole::CDefaultConsole()
+	{
+	}
+
+CDefaultConsole::~CDefaultConsole()
+	{
+	delete iTitle;
+	delete iUnderlyingConsole;
+	iConsoleLibrary.Close();
+	}
+
+TInt CDefaultConsole::Create(const TDesC& aTitle, TSize aSize)
+	{
+	iTitle = aTitle.Alloc();
+	if (iTitle)
+		{
+		iSize = aSize;
+		return KErrNone;
+		}
+	return KErrNoMemory;
+	}
+
+void CDefaultConsole::Read(TRequestStatus& aStatus)
+	{
+	CreateIfRequired();
+	iUnderlyingConsole->Read(aStatus);
+	}
+
+void CDefaultConsole::ReadCancel()
+	{
+	if (iUnderlyingConsole)
+		{
+		iUnderlyingConsole->ReadCancel();
+		}
+	}
+
+void CDefaultConsole::Write(const TDesC& aDes)
+	{
+	CreateIfRequired();
+	iUnderlyingConsole->Write(aDes);
+	}
+
+TPoint CDefaultConsole::CursorPos() const
+	{
+	CreateIfRequired();
+	return iUnderlyingConsole->CursorPos();
+	}
+
+void CDefaultConsole::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	CreateIfRequired();
+	iUnderlyingConsole->SetCursorPosAbs(aPoint);
+	}
+
+void CDefaultConsole::SetCursorPosRel(const TPoint& aPoint)
+	{
+	CreateIfRequired();
+	iUnderlyingConsole->SetCursorPosRel(aPoint);
+	}
+
+void CDefaultConsole::SetCursorHeight(TInt aPercentage)
+	{
+	CreateIfRequired();
+	iUnderlyingConsole->SetCursorHeight(aPercentage);
+	}
+
+void CDefaultConsole::SetTitle(const TDesC& aTitle)
+	{
+	CreateIfRequired();
+	iUnderlyingConsole->SetTitle(aTitle);
+	}
+
+void CDefaultConsole::ClearScreen()
+	{
+	CreateIfRequired();
+	iUnderlyingConsole->ClearScreen();
+	}
+
+void CDefaultConsole::ClearToEndOfLine()
+	{
+	CreateIfRequired();
+	iUnderlyingConsole->ClearToEndOfLine();
+	}
+
+TSize CDefaultConsole::ScreenSize() const
+	{
+	CreateIfRequired();
+	return iUnderlyingConsole->ScreenSize();
+	}
+
+TKeyCode CDefaultConsole::KeyCode() const
+	{
+	CreateIfRequired();
+	return iUnderlyingConsole->KeyCode();
+	}
+
+TUint CDefaultConsole::KeyModifiers() const
+	{
+	CreateIfRequired();
+	return iUnderlyingConsole->KeyModifiers();
+	}
+
+TInt CDefaultConsole::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	CreateIfRequired();
+	return ((CDefaultConsole*)iUnderlyingConsole)->Extension_(aExtensionId, a0, a1); // Evil cast to work around the fact that Extension_ is protected in CConsoleBase.
+	}
+
+void CDefaultConsole::CreateIfRequired()
+	{
+	if (iUnderlyingConsole == NULL)
+		{
+		TInt err = KErrGeneral;
+#ifdef __WINS__
+		if (EmulatorNoGui())
+			{
+			err = TryCreateConsole(_L("nullcons"));
+			}
+		else if (EmulatorTextShell())
+			{
+			err = TryCreateConsole(_L("econs"));
+			}
+		else
+			{
+#endif
+		for (TInt i = 0; i < KNumConsoleImplementations; ++i)
+			{
+			err = TryCreateConsole(KConsoleImplementations[i]);
+			if (err == KErrNone)
+				{
+				break;
+				}
+			}
+
+#ifdef __WINS__
+			}
+#endif
+
+		__ASSERT_ALWAYS(err == KErrNone, Panic(EUnableToCreateConsole));
+		}
+	}
+
+void CDefaultConsole::CreateIfRequired() const
+	{
+	const_cast<CDefaultConsole*>(this)->CreateIfRequired();
+	}
+
+TInt CDefaultConsole::TryCreateConsole(const TDesC& aImplementation)
+	{
+	TInt err = iConsoleLibrary.Load(aImplementation);
+	if ((err == KErrNone) && (iConsoleLibrary.Type()[1] == KSharedLibraryUid) && (iConsoleLibrary.Type()[2] == KConsoleDllUid))
+		{
+		TLibraryFunction entry = iConsoleLibrary.Lookup(1);
+		CConsoleBase* console = (CConsoleBase*)entry();
+		if (console)
+			{
+			err = console->Create(*iTitle, iSize);
+			}
+		if (err == KErrNone)
+			{
+			iUnderlyingConsole = console;
+			}
+		else
+			{
+			delete console;
+			iConsoleLibrary.Close();
+			}
+		}
+	return err;
+	}
+
+void CDefaultConsole::Panic(TPanicReason aReason)
+	{
+	_LIT(KCategory, "defcons");
+	User::Panic(KCategory, aReason);
+	}
+
+extern "C" EXPORT_C TAny *NewConsole()
+	{
+	return(new CDefaultConsole);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/defcons/src/defcons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// defcons.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			defcons.dll
+TARGETTYPE		dll
+UID             0x1000008d 0x100039e7
+
+CAPABILITY		FSHELL_CAP_MMP_NORMAL
+
+#include <fshell/fsh_system_include.mmh>
+
+SOURCEPATH		.
+SOURCE			defcons.cpp
+
+LIBRARY			euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/docs/consoles.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,293 @@
+# consoles.pod
+#
+# Copyright (c) 2008-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 Console Implementations
+
+=head2 Overview
+
+Since its inception, Symbian OS has supported a simple console API; C<CConsoleBase>. The tool-kit provides various implementations of this interface, each suited to different circumstances. This document is intended to provide an overview of the console implementations that are available, and their main pros and cons.
+
+=head2 Consoles Provided By Symbian OS
+
+=head3 econs.dll
+
+The console implementation for the text window server. Provided by Symbian OS.
+
+Pros:
+
+=over 5
+
+=item *
+
+Has few dependencies.
+
+=item *
+
+Supported on the WINSCW emulator.
+
+=item *
+
+Supports multiple concurrent C<CConsoleBase> clients. Each get a separate window. Different windows can be brought into the foreground by dragging using a pointer.
+
+=item *
+
+Light-weight - boots quickly and is reasonably fast in use.
+
+=item *
+
+Can be run remotely via a serial connection using a VT100 screen driver implementation.
+
+=item *
+
+Reasonably bug free.
+
+=back
+
+Cons:
+
+=over 5
+
+=item *
+
+Does not support scrolling. Once text has disappeared from the top of the console it can not be retrieved.
+
+=item *
+
+Requires hardware with a full keyboard.
+
+=item *
+
+Does not support color or attributes.
+
+=back
+
+Typically, this console is used for minimal base-port ROMs and the early stages of product bring up. However, because it boots quickly under the emulator, it is also the console of choice for emulator based debugging of console applications.
+
+=head3 econseik.dll
+
+A console implementation for the graphical window server.
+
+Pros:
+
+=over 5
+
+=item *
+
+None.
+
+=back
+
+Cons:
+
+=over 5
+
+=item *
+
+Buggy. Slow to redraw.
+
+=item *
+
+Tends to select a font that is small and hard to read.
+
+=item *
+
+Does not play nicely with UI frameworks because its window obscures the entire screen. On some UI platforms this makes it impossible to navigate away from.
+
+=item *
+
+Does not support scrolling. Once text has disappeared from the top of the console it cannot be retrieved.
+
+=item *
+
+Requires hardware with a full keyboard.
+
+=item *
+
+Does not support color or attributes.
+
+=back
+
+This console doesn't have much to recommend it. The fshell makes it obsolete with Guicons.
+
+=head2 Consoles Provided By FShell
+
+=head3 Guicons
+
+A console implementation for the graphical window server. Currently only supported on S60, but has minimal UI framework dependencies making it easy to port.
+
+Pros:
+
+=over 5
+
+=item *
+
+Does not require a full keyboard - can use whatever text entry capabilities the handset its running on supports.
+
+=item *
+
+Provides its own fixed width fonts that are easy to read.
+
+=item *
+
+Supports multiple console clients via tabbed windows.
+
+=item *
+
+Supports scrolling.
+
+=item *
+
+Supports color and attributes.
+
+=back
+
+Cons:
+
+=over 5
+
+=item *
+
+Can only be used locally, and so hardware with limited text input capabilities can be painful to use.
+
+=back
+
+This is the console of choice for running on a handset with a full graphical ROM, if remote connectivity is not available.
+
+=head3 L<vt100cons.dll|vt100cons>
+
+A console implementation that will communicate with a VT100 compatible terminal (or terminal emulator such as HyperTerminal) via a serial connection. There are variants that work over TCP connnections (F<vt100tcpcons.dll>), Bluetooth (F<vt100btcons.dll>) and USB (F<vt100usbcons.dll>).
+
+Pros:
+
+=over 5
+
+=item *
+
+Overcomes limitations of the host hardware by using the keyboard and screen of a remote machine.
+
+=item *
+
+Supports file transfers between the host hardware and the remote machine via L<fshell's|fshell> L<ymodem|ymodem> and L<xmodem|xmodem> commands.
+
+=item *
+
+Supports color and attributes.
+
+=item *
+
+The TCP variant supports both passive (i.e. incoming) and active (i.e. outgoing) connections. This, (perhaps used in conjunction with SSH tunnels) can provide an extremely flexible means of establishing a link.
+
+=back
+
+Cons:
+
+=over 5
+
+=item *
+
+Can only host a single console client per serial channel. However, since L<fshell|fshell> allows multiple commands to share a single console, this doesn't tend to be a major limitation.
+
+=back
+
+This is the remote console of choice when running on target (i.e. non-emulated) hardware.
+
+=head3 L<rcons.dll|rcons>
+
+A console implementation that connects via TCP to a Win32 executable (called L<rcons.exe|rcons.exe>) that hosts console windows remotely.
+
+Pros:
+
+=over 5
+
+=item *
+
+Supports multiple concurrent C<CConsoleBase> clients. Each get a separate native Windows window.
+
+=item *
+
+Supports scrolling.
+
+=back
+
+Cons:
+
+=over 5
+
+=item *
+
+Only supports active (i.e. outgoing) TCP connections to the host PC. This can cause problems if the host PC is protected by a firewall.
+
+=item *
+
+Does not support color or attributes.
+
+=item *
+
+Does not support file transfers.
+
+=back
+
+This console has been largely superceded by L<vt100cons|vt100cons> (or one of its variants) for target use. However, it is still useful on the emulator because a) it is easy to get up an running, and b) new windows automatically appear (rather than needing to explicitly connect a terminal emulator).
+
+=head3 win32cons.dll
+
+A specialized console for running the WINSCW emulator directly in a DOS box. A batch file F<\epoc32\tools\fshell.bat> is provided for convenience.
+
+Pros:
+
+=over 5
+
+=item *
+
+Interfaces with the Windows command prompt (F<cmd.exe>).
+
+=back
+
+Cons:
+
+=over 5
+
+=item *
+
+Only supported on the emulator.
+
+=back
+
+The console of choice for running L<fshell|fshell> commands as part of a build process because errors and warnings are reported directly to whatever is controlling the build (normally F<make>).
+
+=head3 nullcons.dll
+
+A console that provides no input and throws away all output. The console of choice for running L<fshell|fshell> commands headlessly.
+
+=head3 iocons.dll
+
+A console implementation that exposes L<fshell's|fshell> console sharing functionality via the C<CConsoleBase> API. Used internally to support legacy Symbian console applications.
+
+=head3 defcons.dll
+
+A dummy console implementation that L<fshell|fshell> (or, more specifically F<iosrv>) uses internally to find a suitable default console implementation. You should never explicitly instanciate this console yourself.
+
+=head1 See Also
+
+L<fshell|fshell>
+
+L<rcons|rcons>
+
+L<vt100cons|vt100cons>
+
+=head1 Copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/BWINS/guiconsU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,59 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+	??0CGuiConsole@@QAE@AAVCConsoleControl@@@Z @ 2 NONAME ; CGuiConsole::CGuiConsole(class CConsoleControl &)
+	??1CConsoleControl@@UAE@XZ @ 3 NONAME ; CConsoleControl::~CConsoleControl(void)
+	??1CConsoleFont@@UAE@XZ @ 4 NONAME ; CConsoleFont::~CConsoleFont(void)
+	?ClearScreen@CConsoleControl@@QAEXXZ @ 5 NONAME ; void CConsoleControl::ClearScreen(void)
+	?ClearScreen@CGuiConsole@@UAEXXZ @ 6 NONAME ; void CGuiConsole::ClearScreen(void)
+	?ClearToEndOfLine@CConsoleControl@@QAEXXZ @ 7 NONAME ; void CConsoleControl::ClearToEndOfLine(void)
+	?ClearToEndOfLine@CGuiConsole@@UAEXXZ @ 8 NONAME ; void CGuiConsole::ClearToEndOfLine(void)
+	?Create@CGuiConsole@@UAEHABVTDesC16@@VTSize@@@Z @ 9 NONAME ; int CGuiConsole::Create(class TDesC16 const &, class TSize)
+	?CursorPos@CConsoleControl@@QBE?AVTPoint@@XZ @ 10 NONAME ; class TPoint CConsoleControl::CursorPos(void) const
+	?CursorPos@CGuiConsole@@UBE?AVTPoint@@XZ @ 11 NONAME ; class TPoint CGuiConsole::CursorPos(void) const
+	?Draw@CConsoleControl@@UBEXABVTRect@@@Z @ 12 NONAME ; void CConsoleControl::Draw(class TRect const &) const
+	?DrawChar@CConsoleFont@@QAEXVTChar@@AAVCBitmapContext@@VTPoint@@VTRgb@@@Z @ 13 NONAME ; void CConsoleFont::DrawChar(class TChar, class CBitmapContext &, class TPoint, class TRgb)
+	?GlyphSize@CConsoleFont@@QBE?AVTSize@@XZ @ 14 NONAME ; class TSize CConsoleFont::GlyphSize(void) const
+	?KeyCode@CConsoleControl@@QBE?AW4TKeyCode@@XZ @ 15 NONAME ; enum TKeyCode CConsoleControl::KeyCode(void) const
+	?KeyCode@CGuiConsole@@UBE?AW4TKeyCode@@XZ @ 16 NONAME ; enum TKeyCode CGuiConsole::KeyCode(void) const
+	?KeyModifiers@CConsoleControl@@QBEIXZ @ 17 NONAME ; unsigned int CConsoleControl::KeyModifiers(void) const
+	?KeyModifiers@CGuiConsole@@UBEIXZ @ 18 NONAME ; unsigned int CGuiConsole::KeyModifiers(void) const
+	?NewL@CConsoleControl@@SAPAV1@HABVTDesC16@@PAVMConsoleUi@@@Z @ 19 NONAME ; class CConsoleControl * CConsoleControl::NewL(int, class TDesC16 const &, class MConsoleUi *)
+	?NewL@CConsoleFont@@SAPAV1@ABVTDesC16@@@Z @ 20 NONAME ; class CConsoleFont * CConsoleFont::NewL(class TDesC16 const &)
+	?OfferKeyEventL@CConsoleControl@@UAE?AW4TKeyResponse@@ABUTKeyEvent@@W4TEventCode@@@Z @ 21 NONAME ; enum TKeyResponse CConsoleControl::OfferKeyEventL(struct TKeyEvent const &, enum TEventCode)
+	?Read@CConsoleControl@@QAEXAAVMGuiConsoleReader@@@Z @ 22 NONAME ; void CConsoleControl::Read(class MGuiConsoleReader &)
+	?Read@CGuiConsole@@UAEXAAVTRequestStatus@@@Z @ 23 NONAME ; void CGuiConsole::Read(class TRequestStatus &)
+	?ReadCancel@CConsoleControl@@QAEXXZ @ 24 NONAME ; void CConsoleControl::ReadCancel(void)
+	?ReadCancel@CGuiConsole@@UAEXXZ @ 25 NONAME ; void CGuiConsole::ReadCancel(void)
+	?ScreenSize@CConsoleControl@@QBE?AVTSize@@XZ @ 26 NONAME ; class TSize CConsoleControl::ScreenSize(void) const
+	?ScreenSize@CGuiConsole@@UBE?AVTSize@@XZ @ 27 NONAME ; class TSize CGuiConsole::ScreenSize(void) const
+	?ViewScrollDown@CConsoleControl@@QAEXXZ @ 28 NONAME ; void CConsoleControl::ViewScrollDown(void)
+	?SetCursorHeight@CConsoleControl@@QAEXH@Z @ 29 NONAME ; void CConsoleControl::SetCursorHeight(int)
+	?SetCursorHeight@CGuiConsole@@UAEXH@Z @ 30 NONAME ; void CGuiConsole::SetCursorHeight(int)
+	?SetCursorPosAbs@CConsoleControl@@QAEXABVTPoint@@@Z @ 31 NONAME ; void CConsoleControl::SetCursorPosAbs(class TPoint const &)
+	?SetCursorPosAbs@CGuiConsole@@UAEXABVTPoint@@@Z @ 32 NONAME ; void CGuiConsole::SetCursorPosAbs(class TPoint const &)
+	?SetCursorPosRel@CConsoleControl@@QAEXABVTPoint@@@Z @ 33 NONAME ; void CConsoleControl::SetCursorPosRel(class TPoint const &)
+	?SetCursorPosRel@CGuiConsole@@UAEXABVTPoint@@@Z @ 34 NONAME ; void CGuiConsole::SetCursorPosRel(class TPoint const &)
+	?SetTitle@CConsoleControl@@QAEXABVTDesC16@@@Z @ 35 NONAME ; void CConsoleControl::SetTitle(class TDesC16 const &)
+	?SetTitle@CGuiConsole@@UAEXABVTDesC16@@@Z @ 36 NONAME ; void CGuiConsole::SetTitle(class TDesC16 const &)
+	?SizeChanged@CConsoleControl@@UAEXXZ @ 37 NONAME ; void CConsoleControl::SizeChanged(void)
+	?Write@CConsoleControl@@QAEXABVTDesC16@@@Z @ 38 NONAME ; void CConsoleControl::Write(class TDesC16 const &)
+	?Write@CGuiConsole@@UAEXABVTDesC16@@@Z @ 39 NONAME ; void CGuiConsole::Write(class TDesC16 const &)
+	?StartGuiConsServerL@@YAPAVCServer2@@ABVTDesC16@@AAVMConsoleUi@@@Z @ 40 NONAME ; class CServer2 * StartGuiConsServerL(class TDesC16 const &, class MConsoleUi &)
+	?InjectKeysL@CConsoleControl@@QAEXABVTDesC16@@@Z @ 41 NONAME ; void CConsoleControl::InjectKeysL(class TDesC16 const &)
+	?InputCapabilities@CConsoleControl@@UBE?AVTCoeInputCapabilities@@XZ @ 42 NONAME ; class TCoeInputCapabilities CConsoleControl::InputCapabilities(void) const
+	?FocusChanged@CConsoleControl@@UAEXW4TDrawNow@@@Z @ 43 NONAME ; void CConsoleControl::FocusChanged(enum TDrawNow)
+	?ViewScrollUp@CConsoleControl@@QAEXXZ @ 44 NONAME ; void CConsoleControl::ViewScrollUp(void)
+	?ViewEnd@CConsoleControl@@QAEXXZ @ 45 NONAME ; void CConsoleControl::ViewEnd(void)
+	?ViewHome@CConsoleControl@@QAEXXZ @ 46 NONAME ; void CConsoleControl::ViewHome(void)
+	?ViewPageDown@CConsoleControl@@QAEXXZ @ 47 NONAME ; void CConsoleControl::ViewPageDown(void)
+	?ViewPageUp@CConsoleControl@@QAEXXZ @ 48 NONAME ; void CConsoleControl::ViewPageUp(void)
+	?HandlePointerEventL@CConsoleControl@@UAEXABUTPointerEvent@@@Z @ 49 NONAME ; void CConsoleControl::HandlePointerEventL(struct TPointerEvent const &)
+	?NewL@CConsoleControl@@SAPAV1@HPAVMConsoleUi@@@Z @ 50 NONAME ; class CConsoleControl * CConsoleControl::NewL(int, class MConsoleUi *)
+	?NewL@CConsoleFont@@SAPAV1@ABVTDesC8@@@Z @ 51 NONAME ; class CConsoleFont * CConsoleFont::NewL(class TDesC8 const &)
+	?Closed@CConsoleControl@@QAEXXZ @ 52 NONAME ; void CConsoleControl::Closed(void)
+	?Control@CGuiConsole@@QAEAAVCConsoleControl@@XZ @ 53 NONAME ; class CConsoleControl & CGuiConsole::Control(void)
+	?FivewayNavIsDisplaying@CConsoleControl@@QBEHXZ @ 54 NONAME ; int CConsoleControl::FivewayNavIsDisplaying(void) const
+	?SetDisplayFivewayNav@CConsoleControl@@QAEXH@Z @ 55 NONAME ; void CConsoleControl::SetDisplayFivewayNav(int)
+	?Extension_@CGuiConsole@@UAEHIAAPAXPAX@Z @ 56 NONAME ; int CGuiConsole::Extension_(unsigned int, void * &, void *)
+	?SetAttributes@CConsoleControl@@QAEHIW4TColor@ConsoleAttributes@@0@Z @ 57 NONAME ; int CConsoleControl::SetAttributes(unsigned int, enum ConsoleAttributes::TColor, enum ConsoleAttributes::TColor)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/EABI/guiconsU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,71 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+	_ZTI11CGuiConsole @ 2 NONAME ; #<TI>#
+	_ZTI12CConsoleFont @ 3 NONAME ; #<TI>#
+	_ZTI15CConsoleControl @ 4 NONAME ; #<TI>#
+	_ZTV11CGuiConsole @ 5 NONAME ; #<VT>#
+	_ZTV12CConsoleFont @ 6 NONAME ; #<VT>#
+	_ZTV15CConsoleControl @ 7 NONAME ; #<VT>#
+	_ZN11CGuiConsole10ReadCancelEv @ 8 NONAME
+	_ZN11CGuiConsole11ClearScreenEv @ 9 NONAME
+	_ZN11CGuiConsole15SetCursorHeightEi @ 10 NONAME
+	_ZN11CGuiConsole15SetCursorPosAbsERK6TPoint @ 11 NONAME
+	_ZN11CGuiConsole15SetCursorPosRelERK6TPoint @ 12 NONAME
+	_ZN11CGuiConsole16ClearToEndOfLineEv @ 13 NONAME
+	_ZN11CGuiConsole4ReadER14TRequestStatus @ 14 NONAME
+	_ZN11CGuiConsole5WriteERK7TDesC16 @ 15 NONAME
+	_ZN11CGuiConsole6CreateERK7TDesC165TSize @ 16 NONAME
+	_ZN11CGuiConsole8SetTitleERK7TDesC16 @ 17 NONAME
+	_ZN11CGuiConsoleC1ER15CConsoleControl @ 18 NONAME
+	_ZN11CGuiConsoleC2ER15CConsoleControl @ 19 NONAME
+	_ZN12CConsoleFont4NewLERK7TDesC16 @ 20 NONAME
+	_ZN12CConsoleFontD0Ev @ 21 NONAME
+	_ZN12CConsoleFontD1Ev @ 22 NONAME
+	_ZN12CConsoleFontD2Ev @ 23 NONAME
+	_ZN15CConsoleControl10ReadCancelEv @ 24 NONAME
+	_ZN15CConsoleControl14ViewScrollDownEv @ 25 NONAME
+	_ZN15CConsoleControl11ClearScreenEv @ 26 NONAME
+	_ZN15CConsoleControl11SizeChangedEv @ 27 NONAME
+	_ZN15CConsoleControl14OfferKeyEventLERK9TKeyEvent10TEventCode @ 28 NONAME
+	_ZN15CConsoleControl15SetCursorHeightEi @ 29 NONAME
+	_ZN15CConsoleControl15SetCursorPosAbsERK6TPoint @ 30 NONAME
+	_ZN15CConsoleControl15SetCursorPosRelERK6TPoint @ 31 NONAME
+	_ZN15CConsoleControl16ClearToEndOfLineEv @ 32 NONAME
+	_ZN15CConsoleControl4NewLEiRK7TDesC16P10MConsoleUi @ 33 NONAME
+	_ZN15CConsoleControl4ReadER17MGuiConsoleReader @ 34 NONAME
+	_ZN15CConsoleControl5WriteERK7TDesC16 @ 35 NONAME
+	_ZN15CConsoleControl8SetTitleERK7TDesC16 @ 36 NONAME
+	_ZN15CConsoleControlD0Ev @ 37 NONAME
+	_ZN15CConsoleControlD1Ev @ 38 NONAME
+	_ZN15CConsoleControlD2Ev @ 39 NONAME
+	_ZNK11CGuiConsole10ScreenSizeEv @ 40 NONAME
+	_ZNK11CGuiConsole12KeyModifiersEv @ 41 NONAME
+	_ZNK11CGuiConsole7KeyCodeEv @ 42 NONAME
+	_ZNK11CGuiConsole9CursorPosEv @ 43 NONAME
+	_ZN12CConsoleFont8DrawCharE5TCharR14CBitmapContext6TPoint4TRgb @ 44 NONAME
+	_ZNK12CConsoleFont9GlyphSizeEv @ 45 NONAME
+	_ZNK15CConsoleControl10ScreenSizeEv @ 46 NONAME
+	_ZNK15CConsoleControl12KeyModifiersEv @ 47 NONAME
+	_ZNK15CConsoleControl4DrawERK5TRect @ 48 NONAME
+	_ZNK15CConsoleControl7KeyCodeEv @ 49 NONAME
+	_ZNK15CConsoleControl9CursorPosEv @ 50 NONAME
+	_Z19StartGuiConsServerLRK7TDesC16R10MConsoleUi @ 51 NONAME
+	_ZN15CConsoleControl10ViewPageUpEv @ 52 NONAME
+	_ZN15CConsoleControl11InjectKeysLERK7TDesC16 @ 53 NONAME
+	_ZN15CConsoleControl12FocusChangedE8TDrawNow @ 54 NONAME
+	_ZN15CConsoleControl12ViewPageDownEv @ 55 NONAME
+	_ZN15CConsoleControl12ViewScrollUpEv @ 56 NONAME
+	_ZN15CConsoleControl19HandlePointerEventLERK13TPointerEvent @ 57 NONAME
+	_ZN15CConsoleControl7ViewEndEv @ 58 NONAME
+	_ZN15CConsoleControl8ViewHomeEv @ 59 NONAME
+	_ZNK15CConsoleControl17InputCapabilitiesEv @ 60 NONAME
+	_ZN12CConsoleFont4NewLERK6TDesC8 @ 61 NONAME
+	_ZN15CConsoleControl4NewLEiP10MConsoleUi @ 62 NONAME
+	_ZN15CConsoleControl6ClosedEv @ 63 NONAME
+	_ZThn8_N11CGuiConsole10ReadCancelEv @ 64 NONAME ; #<thunk>#
+	_ZN11CGuiConsole7ControlEv @ 65 NONAME
+	_ZN15CConsoleControl20SetDisplayFivewayNavEi @ 66 NONAME
+	_ZNK15CConsoleControl22FivewayNavIsDisplayingEv @ 67 NONAME
+	_ZN11CGuiConsole10Extension_EjRPvS0_ @ 68 NONAME
+	_ZN15CConsoleControl13SetAttributesEjN17ConsoleAttributes6TColorES1_ @ 69 NONAME
+
Binary file plugins/consoles/guicons/data/font_6x10.PNG has changed
Binary file plugins/consoles/guicons/data/font_7x13.PNG has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/doc/guicons_todo.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,65 @@
+# guicons_todo.pod
+#
+# Copyright (c) 2009-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 guicons todo list
+
+=over 5
+
+=item *
+
+Write some user documentation. This should include details on how fonts work and how to create your own.
+
+=item *
+
+Configuration. This includes:
+
+=over
+
+=item *
+
+Configuring the console using the console title, for example:
+
+	fshell --console guicons --console-title "font=c:\myfont.gif;exe=custom_guicons_app.exe;servername=myguicons;title=fshell console"
+
+or similar.
+
+=item *
+
+Save configuration options in guicons application (currently, there is only the line/interactive mode setting, there will be more...)
+
+=back
+
+=item *
+
+Allow changing of the font after a console is created (by selecting a new image file using a dialog)
+
+=item *
+
+In the line editor, when the text is injected into the console, dont' remove it but instead justr highlight it. Then, you can easily inject it again, or start typing to replace it.
+
+=item *
+
+Copy, paste support
+
+=item *
+
+Option to hide the line editor on devices that have a full keyboard.
+
+=back
+
+=head1 Copyright
+
+Copyright (c) 2009-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/group/bin2lit.pl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+#!perl
+# bin2lit.pl
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+my $litName = shift(@ARGV);
+die "Error: No name specified\n" unless $litName;
+
+binmode(STDIN);
+undef $/;
+my $content = <>;
+close (STDIN);
+
+print <<__EOS__;
+// This file has been automatically generated by $0
+// Do not edit it directly!
+
+_LIT8($litName, 
+__EOS__
+print "\t\"";
+for (my $i=0; $i<length($content); ++$i) {
+	print "\"\n\t\"" if ($i && ($i%20) == 0);
+	my $c = ord(substr($content, $i, 1));
+	printf "\\x%02x", $c;
+}
+print "\");\n\n"
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// bld.inf
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(guicons.iby)
+
+#ifdef FSHELL_WSERV_SUPPORT
+
+..\data\font_6x10.PNG	Z:\resource\font_6x10.PNG
+..\data\font_7x13.PNG	Z:\resource\font_7x13.PNG
+..\inc\guicons.h	\epoc32\include\fshell\guicons.h
+
+PRJ_MMPFILES
+gnumakefile guicons_makefont.mk
+guicons.mmp
+
+#ifdef FSHELL_PLATFORM_S60
+#include "..\s60\group\bld.inf"
+#endif
+
+#endif // FSHELL_WSERV_SUPPORT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/group/fontchars.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,12 @@
+ !"#$%&'
+()*+,-./
+01234567
+89:;<=>?
+@ABCDEFG
+HIJKLMNO
+PQRSTUVW
+XYZ[\]^_
+`abcdefg
+hijklmno
+pqrstuvw
+xyz{|}~¦
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/group/guicons.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// guicons.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __GUICONS_IBY__
+#define __GUICONS_IBY__
+
+#ifdef FSHELL_WSERV_SUPPORT
+
+FSHELL_EXECUTABLE_FILE(guicons.dll)
+
+// don't include the font file in the SIS build, as they seem to cause problems for software install
+// on S60. (Corrupted error message).
+#if !defined(FSHELL_MAKESIS)
+// font_6x10.PNG is not included as this is the default, built into the binary
+FSHELL_DATA_FILE(ZRESOURCE\font_7x13.PNG, \resource\font_7x13.PNG)
+#endif
+
+#ifdef FSHELL_PLATFORM_S60
+#include <s60_guicons.iby>
+#endif
+
+#endif // FSHELL_WSERV_SUPPORT
+
+#endif //__GUICONS_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/group/guicons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// guicons.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET		guicons.dll
+TARGETTYPE	dll
+UID		0x1000008d 0x100039e7
+
+CAPABILITY	FSHELL_CAP_MMP_NORMAL
+
+SOURCEPATH	..\src
+SOURCE		GuiCons.cpp
+SOURCE		clientserver.cpp
+
+USERINCLUDE	..\inc
+USERINCLUDE	\epoc32\build\fshell/guicons\generated
+
+#include <fshell/fsh_system_include.mmh>
+
+LIBRARY		euser.lib
+LIBRARY		cone.lib
+LIBRARY		efsrv.lib 
+LIBRARY		imageconversion.lib fbscli.lib ws32.lib bitgdi.lib gdi.lib
+LIBRARY		ecom.lib
+LIBRARY		consoleproxy.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/group/guicons_makefont.mk	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+# guicons_makefont.mk
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+GENERATED_SOURCE_DIR = $(EPOCROOT)epoc32\build\fshell/guicons\generated
+GENERATED_SOURCE = $(GENERATED_SOURCE_DIR)\defaultfontdata.inl
+
+MAKMAKE : $(GENERATED_SOURCE)
+
+$(GENERATED_SOURCE) : ..\data\font_6x10.PNG
+	perl -S emkdir.pl $(GENERATED_SOURCE_DIR)
+	echo perl .\bin2lit.pl KDefaultFontImageData ^< ..\data\font_6x10.PNG ^> $(GENERATED_SOURCE)
+	perl .\bin2lit.pl KDefaultFontImageData < ..\data\font_6x10.PNG > $(GENERATED_SOURCE)
+
+CLEAN :
+	perl -S ermdir.pl $(GENERATED_SOURCE_DIR)
+
+BLD FREEZE RESOURCE LIB CLEANLIB RESOURCE SAVESPACE RELEASABLES FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/inc/guicons.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,362 @@
+// guicons.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __GUICONS_H__
+#define __GUICONS_H__
+
+#include <coecntrl.h>
+#include <e32cons.h>
+#include <fshell/consoleproxy.h>
+#include <fshell/consoleextensions.h>
+
+static const TInt KFontBitmapWidthChars = 8;
+static const TInt KFontBitmapHeightChars = 12;
+static const TInt KFontBitmapFirstCharCode = ' ';
+static const TInt KNumGlyphs = KFontBitmapWidthChars * KFontBitmapHeightChars;
+static const TInt KFontBitmapLastCharCode = KFontBitmapFirstCharCode + KNumGlyphs - 1;
+static const TInt KDefaultCursorHeightPercentage = 20;
+static const TInt KTabSize = 4;
+static const TInt KNumColors = 16;
+
+class CConsoleControl;
+class CConsoleLine;
+class CConsoleFont;
+class MGuiConsoleReader;
+class MConsoleUi;
+class TBufferPosition;
+class TConsCursorPosition;
+class TViewPosition;
+class CImageDecoder;
+class RImageDecodeThreadParams;
+
+IMPORT_C CServer2* StartGuiConsServerL(const TDesC& aServerName, MConsoleUi& aConsoleUi);
+
+class MConsoleUi
+	{
+public:
+	virtual void HandleNewConsoleL(CConsoleControl* aConsole) = 0;
+	virtual void HandleConsoleClosed(CConsoleControl* aConsole) = 0;
+	virtual void ConsoleTitleChangedL(const CConsoleControl*, const TDesC&){};
+	virtual TInt GetConsoleBufferSize() = 0;
+	virtual const TDesC& GetConsoleFont() = 0;
+	};
+
+/**
+Position relative to the text buffer. The cursor window and view window will be somewhere within this.
+*/
+class TBufferPosition
+	{
+public:
+	TBufferPosition(const CConsoleControl& aConsole, TPoint aPosition);
+	TBufferPosition(const CConsoleControl& aConsole, TInt aX, TInt aY);
+	TBufferPosition(const TConsCursorPosition& aCursorPosition);
+	TBufferPosition(const TViewPosition& aViewPosition);
+public:
+	const CConsoleControl& iConsole;
+	TPoint iPoint;
+	};
+
+/**
+Position relative to the cursor window - i.e. the area that the cursor can move around in
+*/
+class TConsCursorPosition
+	{
+public:
+	TConsCursorPosition(const CConsoleControl& aConsole, TPoint aPosition);
+	TConsCursorPosition(const CConsoleControl& aConsole, TInt aX, TInt aY);
+	TConsCursorPosition(const TBufferPosition& aBufferPosition);
+	TConsCursorPosition(const TViewPosition& aViewPosition);
+public:
+	const CConsoleControl& iConsole;
+	TPoint iPoint;
+	};
+
+/**
+Position relative to the view window - i.e. the area of the console seen on the screen
+*/
+class TViewPosition
+	{
+public:
+	TViewPosition(const CConsoleControl& aConsole, TPoint aPosition);
+	TViewPosition(const CConsoleControl& aConsole, TInt aX, TInt aY);
+	TViewPosition(const TConsCursorPosition& aCursorPosition);
+	TViewPosition(const TBufferPosition& aBufferPosition);
+public:
+	const CConsoleControl& iConsole;
+	TPoint iPoint;
+	};
+
+/**
+Position in pixels relative to CConsoleControl's rectangle.
+*/
+class TScreenPosition
+	{
+public:
+	TScreenPosition(const CConsoleControl& aConsole, TPoint aPosition);
+	TScreenPosition(const CConsoleControl& aConsole, TInt aX, TInt aY);
+	TScreenPosition(const TViewPosition& aViewPosition);
+public:
+	const CConsoleControl& iConsole;
+	TPoint iPoint;
+	};
+
+class TConsoleCursor
+	{
+public:
+	TConsoleCursor(CConsoleControl& aOwner);
+	void SetFont(const CConsoleFont& aFont);
+	TConsCursorPosition Position() const;
+	void SetPosAbs(TConsCursorPosition aPos);
+	void SetPosRel(TConsCursorPosition aPos);
+	void SetHeight(TInt aPercentage);
+	
+	void Hide();
+
+	void operator++(int);
+	void operator--(int);
+	void operator+=(TUint aHowMuch);
+	void operator-=(TUint aHowMuch);
+	void Down();
+	void Up();
+	
+	void Update();
+private:
+	void BoundsCheck();
+private:
+	CConsoleControl& iOwner;
+	TSize iGlyphSize;
+	TPoint iPosition;
+	TTextCursor iTextCursor;
+	TInt iTextCursorOffset;
+	};
+
+class MGuiConsoleReader
+	{
+public:
+	virtual void ReadComplete(TInt aStatus) = 0;
+	};
+	
+class CGuiConsole	: public CConsoleBase
+					, public MGuiConsoleReader
+					, public MProxiedConsole
+	{
+public:
+	IMPORT_C CGuiConsole(CConsoleControl& aControl);
+	
+	IMPORT_C CConsoleControl& Control();
+	
+	// from CConsoleBase
+	IMPORT_C virtual TInt Create(const TDesC &aTitle,TSize aSize);
+	IMPORT_C virtual void Read(TRequestStatus& aStatus);
+	IMPORT_C virtual void ReadCancel();
+	IMPORT_C virtual void Write(const TDesC &aDes);
+	IMPORT_C virtual TPoint CursorPos() const;
+	IMPORT_C virtual void SetCursorPosAbs(const TPoint &aPoint);
+	IMPORT_C virtual void SetCursorPosRel(const TPoint &aPoint);
+	IMPORT_C virtual void SetCursorHeight(TInt aPercentage);
+	IMPORT_C virtual void SetTitle(const TDesC &aTitle);
+	IMPORT_C virtual void ClearScreen();
+	IMPORT_C virtual void ClearToEndOfLine();
+	IMPORT_C virtual TSize ScreenSize() const;
+	IMPORT_C virtual TKeyCode KeyCode() const;
+	IMPORT_C virtual TUint KeyModifiers() const;
+	IMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+	
+	// from MGuiConsoleReader
+	virtual void ReadComplete(TInt aStatus);
+	// from MProxiedConsole:
+	virtual void Open();
+	virtual void Close();
+	virtual CConsoleBase* Console();
+	virtual void Read(CConsoleProxySession& aSession);
+private:
+	~CGuiConsole();
+private:
+	CConsoleControl& iControl;
+	TInt iRefCount;
+	TRequestStatus* iReadStatus;
+	CConsoleProxySession* iReader;
+	};
+
+class CConsoleControl : public CCoeControl
+	{
+public:
+	IMPORT_C static CConsoleControl* NewL(TInt aBufferSize, MConsoleUi* aUi = NULL);
+	IMPORT_C static CConsoleControl* NewL(TInt aBufferSize, const TDesC& aFontFile, MConsoleUi* aUi = NULL);
+	IMPORT_C virtual ~CConsoleControl();
+	IMPORT_C void Closed();
+	
+	IMPORT_C void InjectKeysL(const TDesC& aKeys);
+	IMPORT_C TBool FivewayNavIsDisplaying() const;
+	IMPORT_C void SetDisplayFivewayNav(TBool aShow);
+	
+	// from CCoeControl:
+	IMPORT_C virtual void Draw(const TRect& aRect) const;
+	IMPORT_C virtual void SizeChanged();
+	IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+	IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const;
+	IMPORT_C virtual void FocusChanged(TDrawNow aDrawNow);
+	IMPORT_C virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
+	
+	// CConsoleBase API
+	IMPORT_C void Read(MGuiConsoleReader &aStatus);
+	IMPORT_C void ReadCancel();
+	IMPORT_C void Write(const TDesC &aDes);
+	IMPORT_C TPoint CursorPos() const;
+	IMPORT_C void SetCursorPosAbs(const TPoint &aPoint);
+	IMPORT_C void SetCursorPosRel(const TPoint &aPoint);
+	IMPORT_C void SetCursorHeight(TInt aPercentage);
+	IMPORT_C void SetTitle(const TDesC &aTitle);
+	IMPORT_C void ClearScreen();
+	IMPORT_C void ClearToEndOfLine();
+	IMPORT_C TSize ScreenSize() const;
+	IMPORT_C TKeyCode KeyCode() const;
+	IMPORT_C TUint KeyModifiers() const;
+	
+	IMPORT_C void ViewScrollUp();
+	IMPORT_C void ViewScrollDown();
+	IMPORT_C void ViewPageUp();
+	IMPORT_C void ViewPageDown();
+	IMPORT_C void ViewHome();
+	IMPORT_C void ViewEnd();
+	IMPORT_C TInt SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor);
+	
+	// calls from CConsoleCursor:
+	void CursorWindowScrollDown();
+	
+	TPoint ViewPosition() const;
+	TPoint CursorWindowPosition() const;
+	TSize GlyphSize() const;
+	void ActivateL();
+	void StartBlinking();
+	
+private:
+	CConsoleControl(MConsoleUi* aUi, TInt aBufferSize);
+	void ConstructL(CConsoleFont* aFont);
+	void SizeChangedL();
+	
+	void DrawLine(TViewPosition aLine, CBitmapContext& aDrawTo) const;
+	TRect LineRect(TViewPosition aLine) const;
+	
+	TBool IsSpecialChar(TChar aChar) const;
+	void HandleSpecialChar(TChar aChar);
+	
+	void SendKey();
+	
+	CConsoleLine* GetLine(TBufferPosition aLine) const;
+	void ViewMoved();
+	void Invalidate5Way();
+	enum TButton { EUp, EDown, ELeft, ERight, ECenter, ENumButtons };
+	void SimulateKeyL(TButton aButton);
+	void WriteL(const TDesC &aDes);
+
+	static TInt BlinkCallback(TAny* aPtr);
+	
+private:
+	MConsoleUi* iUi;
+	CConsoleFont* iFont;
+	RPointerArray<CConsoleLine> iBuffer;
+	CPeriodic* iBlinkTimer;
+	TSize iSizeChars;
+	TConsoleCursor iCursor;
+	TPoint iCursorWindow;
+	TPoint iViewWindow;
+
+	MGuiConsoleReader* iReader;
+	RArray<TKeyEvent> iKeyQueue;
+	TKeyEvent iCurrentKey; 
+	
+	TPoint iDragStart;
+	TBool iIgnoringDrags;
+
+	TRect iButtonRects[ENumButtons];
+	TBool iDrawNavigator;
+	ConsoleAttributes::TAttributes iCurrentAttributes;
+	
+	TInt iBufferSize;
+	TBool iBlinkOn;
+	};
+	
+class CConsoleFont : public CBase
+	{
+public:
+	IMPORT_C static CConsoleFont* NewL(const TDesC& aFontFile);
+	IMPORT_C static CConsoleFont* NewL(const TDesC8& aEncodedFontImage);
+	IMPORT_C ~CConsoleFont();
+	IMPORT_C TSize GlyphSize() const;
+	IMPORT_C void DrawChar(TChar aChar, CBitmapContext& aDrawTo, TPoint aPosPixels, TRgb aColor);
+	void PrepareForegroundColorL(TRgb aColor);
+private:
+	CConsoleFont();
+	void ConstructL(const TDesC& aFontFile);
+	void ConstructL(const TDesC8& aEncodedFontImage);
+	void ConstructL(RImageDecodeThreadParams& aThreadParams);
+	CFbsBitmap* ForegroundBitmap(TRgb aColor);
+private:
+	TFixedArray<CFbsBitmap*, KNumGlyphs> iChars;
+	TFixedArray<CFbsBitmap*, KNumColors> iColors;
+	TRect iGlyphRect;
+	};
+
+class RAttributeMap
+	{
+public:
+	RAttributeMap();
+	void Close();
+	void Reset();
+	void AddL(TInt aPosition, TInt aLineWidth, const ConsoleAttributes::TAttributes& aAttributes);
+	void RemoveFrom(TInt aPosition);
+	TInt NumberOfBlocks() const;
+	void GetBlock(TInt aIndex, TInt aLineWidth, TInt& aStartPosition, TInt& aEndPosition, ConsoleAttributes::TAttributes& aAttributes) const;
+private:
+	class TAttributes
+		{
+	public:
+		TAttributes(TInt aPosition, const ConsoleAttributes::TAttributes& aAttributes);
+		TBool operator==(const TAttributes& aAttributes) const;
+	public:
+		TInt iPosition;
+		ConsoleAttributes::TAttributes iAttributes;
+		};
+private:
+	RArray<TAttributes> iAttributes;
+	};
+	
+NONSHARABLE_CLASS(CConsoleLine) : public CBase
+	{
+public:
+	static CConsoleLine* NewL(CConsoleControl& aControl, const CConsoleFont& aFont, TInt aWidth);
+	~CConsoleLine();
+	
+	void SetWidthL(TInt aNewWidth);
+	
+	void SetL(TInt aIndex, TUint8 aChar, const ConsoleAttributes::TAttributes& aAttributes);
+	void Clear();
+	void ClearFrom(TBufferPosition aPosition);
+	
+	void Draw(CBitmapContext& aDrawTo, TViewPosition aViewPosition) const;
+	TBool NeedToBlink(TBool aBlinkOn);
+private:
+	CConsoleLine(CConsoleControl& aControl, const CConsoleFont& aFont);
+	void ConstructL(TInt aWidth);
+	TUint16 At(TInt aPos) const;
+private:
+	CConsoleControl& iControl;
+	const CConsoleFont& iFont;
+	RBuf8 iText;
+	RAttributeMap iAttributeMap;
+	TInt iWidth;
+	TBool iBlinkOn;
+	};
+
+
+#endif //__GUICONS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/GuiCons.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,222 @@
+// GuiCons.rss
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+NAME GUNS
+
+#include <eikon.rh>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <appinfo.rh>
+#include <CommonDialogs.rh>
+#include "GuiCons.hrh"
+
+RESOURCE RSS_SIGNATURE
+	{
+	}
+
+RESOURCE TBUF r_default_document_name
+	{
+	buf="GUNS";
+	}
+
+RESOURCE EIK_APP_INFO
+	{
+	menubar = r_guicons_menubar;
+	cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+	}
+	
+RESOURCE CBA r_guicons_interactive_cba
+	{
+	buttons =
+	        {
+	        CBA_BUTTON {id=EAknSoftkeyOptions; txt = "Options";},
+	        CBA_BUTTON {id=EGuiConsFocusEdwin; txt = "Line mode"; }
+	        };
+	}
+
+RESOURCE CBA r_guicons_line_cba
+	{
+	buttons =
+	        {
+	        CBA_BUTTON {id=EAknSoftkeyOptions; txt = "Options";},
+	        CBA_BUTTON {id=EGuiConsFocusConsole; txt = "Interactive"; }
+	        };
+	}
+
+RESOURCE CBA r_guicons_closed_cba
+	{
+	buttons =
+	        {
+	        CBA_BUTTON {id=EAknSoftkeyOptions; txt = "Options";},
+	        CBA_BUTTON {id=EGuiConsCloseConsole; txt = "Close"; }
+	        };
+	}
+
+RESOURCE MENU_BAR r_guicons_menubar
+	{
+	titles =
+		{
+		MENU_TITLE { menu_pane = r_guicons_menu; }
+		};
+	}
+
+RESOURCE MENU_PANE r_guicons_menu
+	{
+	items =
+		{
+		MENU_ITEM
+			{
+			command = EGuiConsCtrlC;
+			txt = "Ctrl-C";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsNavigationSubMenu;
+			cascade = r_guicons_navigation_submenu;
+			txt = "Navigation";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsNewConsole;
+			txt = "New gui console";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsCommandsSubMenu;
+			cascade = r_guicons_commands_submenu;
+			txt = "Commands";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsSwitchTab;
+			cascade = r_guicons_tabs_submenu;
+			txt = "Go to tab";
+			},
+ 		MENU_ITEM
+			{
+			command = EGuiConsSettingsSubMenu;
+			cascade = r_guicons_settings_submenu;
+			txt = "Settings";
+			},
+ 		MENU_ITEM
+			{
+			command = EGuiConsFocusConsole;
+			txt = "Interactive mode";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsFocusEdwin;
+			txt = "Line mode";
+			},
+		MENU_ITEM
+			{
+			command = EAknSoftkeyExit;
+			txt = "Exit";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsCloseConsole;
+			txt = "Close console";
+			}
+		};
+	}
+
+RESOURCE LOCALISABLE_APP_INFO r_guicons_localisable_app_info
+	{
+	short_caption = "guicons";
+	caption_and_icon = 
+	CAPTION_AND_ICON_INFO
+		{
+		caption = "guicons";
+		number_of_icons = 1;
+		icon_file = "\\Resource\\Apps\\guicons.mif";
+		};
+	}
+
+RESOURCE EDWIN r_guicons_lineeditor_edwin
+	{
+	flags = EEikEdwinNoWrap | EEikEdwinLineCursor | EEikEdwinNoLineOrParaBreaks;
+	width = 100;
+	default_case = EAknEditorLowerCase;
+	max_view_height_in_lines = 1;	
+	}
+
+RESOURCE MENU_PANE r_guicons_tabs_submenu
+	{
+	items=
+		{
+		};
+	}
+
+RESOURCE MENU_PANE r_guicons_navigation_submenu
+	{
+	items=
+		{
+		MENU_ITEM
+			{
+			command = EGuiConsPageUp;
+			txt = "Page up";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsPageDown;
+			txt = "Page Down";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsHome;
+			txt = "Home";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsEnd;
+			txt = "End";
+			}
+		};
+	}
+
+RESOURCE MENU_PANE r_guicons_settings_submenu
+	{
+	items=
+		{
+		MENU_ITEM
+			{
+			command = EGuiConsLongPressSwitchesTabs;
+			txt = "Long press switches tabs";
+			flags = EEikMenuItemCheckBox;
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsShow5Way;
+			txt = "Show 5-way nav";
+			flags = EEikMenuItemCheckBox;
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsChooseFont;
+			txt = "Choose font";
+			},
+		MENU_ITEM
+			{
+			command = EGuiConsResetFont;
+			txt = "Use default font";
+			}
+		};
+	}
+
+RESOURCE MENU_PANE r_guicons_commands_submenu
+	{
+	items=
+		{
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/GuiCons_reg.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// GuiCons_reg.rss
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <appinfo.rh>
+#include <GuiCons.rsg>
+#include <fshell/common.mmh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 FSHELL_UID_S60_GUICONS
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file="GuiCons";
+	localisable_resource_file =  "\\resource\\apps\\guicons";
+	localisable_resource_id = R_GUICONS_LOCALISABLE_APP_INFO;
+
+	embeddability=KAppNotEmbeddable;
+	newfile=KAppDoesNotSupportNewFile;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/New_BT_console.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1 @@
+fshell --console vt100btcons
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/New_TCP_console.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1 @@
+fshell --console vt100tcpcons --console-title port=8080
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/New_busdevcomm_console.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1 @@
+fshell --console vt100busdevcons --console-title pdd=euart1,ldd=ecomm,rate=115200,port=0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/New_serial_console.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1 @@
+fshell --console vt100cons --console-title pdd=euart1,ldd=ecomm,csy=ecuart,rate=115200,port=comm::0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/guicons.idf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+# guicons.idf
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Description:
+# INI definition file for guicons.ini
+
+font			filename
+font.name		Font bitmap
+font.description	The font to use for consoles. The font should be a bitmap containing a 8x12 grid of fixed width characters with ASCII codes 32 through 127
+
+shownav			boolean
+shownav.name		Show 5-way nav
+shownav.description	Show five way navigation control, to allow direction keys to be inputted on a device with just a touch screen
+shownav.default		true
+
+longpress		boolean
+longpress.name		Long press switches tabs
+longpress.description	Allows a long press of a direction key to switch betweeb tabs
+longpress.default	no
+
+buffersize		integer
+buffersize.name		Buffer size
+buffersize.description	Number of lines in the console buffer history
+buffersize.default	200
Binary file plugins/consoles/guicons/s60/data/guicons.mif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/guicons.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   version="1.0"
+   width="44"
+   height="44"
+   id="svg13744"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   sodipodi:docname="guicons.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape">
+  <metadata
+     id="metadata2447">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     inkscape:window-height="952"
+     inkscape:window-width="1280"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     guidetolerance="10.0"
+     gridtolerance="10.0"
+     objecttolerance="10.0"
+     borderopacity="1.0"
+     bordercolor="#666666"
+     pagecolor="#ffffff"
+     id="base"
+     showgrid="false"
+     inkscape:zoom="13.12069"
+     inkscape:cx="42.000001"
+     inkscape:cy="25.651257"
+     inkscape:window-x="0"
+     inkscape:window-y="45"
+     inkscape:current-layer="svg13744" />
+  <defs
+     id="defs13746">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 16 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="32 : 16 : 1"
+       inkscape:persp3d-origin="16 : 10.666667 : 1"
+       id="perspective2449" />
+  </defs>
+  <g
+     transform="matrix(1.3743906,0,0,1.4637276,-1.4480592e-2,-0.981291)"
+     id="g2654">
+    <rect
+       width="28.651619"
+       height="17.958471"
+       ry="2.5706975"
+       x="0.96957904"
+       y="8.4601355"
+       transform="matrix(0.9857576,-0.1681724,0,1,0,0)"
+       id="rect2656"
+       style="fill:#00668c;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00480461;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:21.79999924;stroke-dasharray:none;stroke-opacity:1" />
+    <rect
+       width="28.651619"
+       height="17.958471"
+       ry="2.5706975"
+       x="2.9018717"
+       y="10.544497"
+       transform="matrix(0.9857576,-0.1681724,0,1,0,0)"
+       id="rect2658"
+       style="fill:#00b8fc;fill-opacity:0.83574877;fill-rule:evenodd;stroke:#000000;stroke-width:1.00480461;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:21.79999924;stroke-dasharray:none;stroke-opacity:1" />
+    <path
+       d="M 5.8228178,13.248344 L 5.8228178,13.248344 L 10.963385,15.410032 L 6.0510609,19.151846 L 6.1400143,20.571272 L 12.258239,15.914674 L 12.169286,14.442488 L 5.825408,11.883728 L 5.8228178,13.248344 z"
+       id="path2660"
+       style="fill:#e0ea00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.50394464;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <rect
+       width="7.894608"
+       height="1.0460696"
+       ry="0"
+       x="12.788285"
+       y="20.731438"
+       transform="matrix(0.9857576,-0.1681724,0,1,0,0)"
+       id="rect2662"
+       style="fill:#e0ea00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.37287086;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/guicons.tiny.svg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" height="44" version="1.0" width="44">
+<defs/>
+<g transform="matrix(1.3743906,0,0,1.4637276,-1.4480592e-2,-0.981291)">
+<rect height="17.958471" ry="2.5706975" style="fill:#00668c;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00480461;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:21.79999924;stroke-dasharray:none;stroke-opacity:1" transform="matrix(0.9857576,-0.1681724,0,1,0,0)" width="28.651619" x="0.96957904" y="8.4601355"/>
+<rect height="17.958471" ry="2.5706975" style="fill:#00b8fc;fill-opacity:0.83574877;fill-rule:evenodd;stroke:#000000;stroke-width:1.00480461;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:21.79999924;stroke-dasharray:none;stroke-opacity:1" transform="matrix(0.9857576,-0.1681724,0,1,0,0)" width="28.651619" x="2.9018717" y="10.544497"/>
+<path d="M 5.8228178,13.248344 L 5.8228178,13.248344 L 10.963385,15.410032 L 6.0510609,19.151846 L 6.1400143,20.571272 L 12.258239,15.914674 L 12.169286,14.442488 L 5.825408,11.883728 L 5.8228178,13.248344 z" style="fill:#e0ea00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.50394464;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/>
+<rect height="1.0460696" ry="0" style="fill:#e0ea00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.37287086;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" transform="matrix(0.9857576,-0.1681724,0,1,0,0)" width="7.894608" x="12.788285" y="20.731438"/>
+</g>
+</svg>
Binary file plugins/consoles/guicons/s60/data/guiconsbg.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/data/mif.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,12 @@
+@REM mif.bat
+@REM 
+@REM Copyright (c) 2010 Accenture. All rights reserved.
+@REM This component and the accompanying materials are made available
+@REM under the terms of the "Eclipse Public License v1.0"
+@REM which accompanies this distribution, and is available
+@REM at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@REM 
+@REM Initial Contributors:
+@REM Accenture - Initial contribution
+@REM
+mifconv guicons.mif /X /c32 guicons.tiny.svg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+// bld.inf
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(s60_guicons.iby)
+..\data\guicons.mif	z:\resource\apps\guicons.mif
+..\data\guiconsbg.png	z:\resource\guiconsbg.png
+
+..\data\guicons.idf	z:\resource\guicons.idf
+
+..\data\New_BT_console.txt z:\system\console\commands\100-New_BT_console.txt
+..\data\New_TCP_console.txt z:\system\console\commands\101-New_TCP_console.txt
+..\data\New_serial_console.txt z:\system\console\commands\102-New_serial_console.txt
+..\data\New_busdevcomm_console.txt z:\system\console\commands\103-New_busdevcomm_console.txt
+
+PRJ_MMPFILES
+s60_guicons.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/group/s60_guicons.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// s60_guicons.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __S60_GUICONS_IBY__
+#define __S60_GUICONS_IBY__
+
+FSHELL_EXECUTABLE_FILE(guicons.exe)
+FSHELL_DATA_FILE(ZPRIVATE\10003a3f\Apps\guicons_reg.rsc, private\10003a3f\import\Apps\guicons_reg.rsc)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\guicons.rsc, Resource\Apps\guicons.rsc)
+FSHELL_DATA_FILE(ZRESOURCE\Apps\guicons.mif, Resource\Apps\guicons.mif)
+FSHELL_DATA_FILE(ZRESOURCE\guicons.idf, resource\guicons.idf)
+
+#if !defined(FSHELL_MAKESIS) && defined (FSHELL_GUICONS_GRATUITOUS)
+FSHELL_DATA_FILE(ZRESOURCE\guiconsbg.png, \resource\guiconsbg.png)
+#endif
+
+FSHELL_DATA_FILE(ZSYSTEM\console\commands\100-New_BT_console.txt, system\console\commands\100-New_BT_console.txt)
+FSHELL_DATA_FILE(ZSYSTEM\console\commands\101-New_TCP_console.txt, system\console\commands\101-New_TCP_console.txt)
+FSHELL_DATA_FILE(ZSYSTEM\console\commands\102-New_serial_console.txt, system\console\commands\102-New_serial_console.txt)
+FSHELL_DATA_FILE(ZSYSTEM\console\commands\103-New_busdevcomm_console.txt, system\console\commands\103-New_busdevcomm_console.txt)
+
+#endif //__S60_GUICONS_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/group/s60_guicons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+// s60_guicons.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET		GuiCons.exe
+TARGETTYPE	exe
+UID		0x100039CE FSHELL_UID_S60_GUICONS
+
+SECUREID	FSHELL_UID_S60_GUICONS
+CAPABILITY	FSHELL_CAP_MMP_NORMAL
+
+SOURCEPATH	..\src
+SOURCE		GuiCons.cpp
+SOURCE		GuiConsApplication.cpp
+SOURCE		GuiConsAppView.cpp
+SOURCE		GuiConsAppUi.cpp
+SOURCE		GuiConsDocument.cpp
+
+SOURCEPATH	..\data
+
+START RESOURCE	GuiCons.rss
+HEADER
+TARGETPATH	resource\apps
+END
+
+START RESOURCE	GuiCons_reg.rss
+TARGETPATH	\private\10003a3f\apps
+END
+
+USERINCLUDE	..\inc
+
+#include <fshell/fsh_system_include.mmh>
+
+LIBRARY		euser.lib
+LIBRARY		apparc.lib
+LIBRARY		cone.lib
+LIBRARY		eikcore.lib
+LIBRARY		avkon.lib
+LIBRARY		commonengine.lib
+LIBRARY		efsrv.lib 
+LIBRARY		estor.lib
+LIBRARY		eikcoctl.lib
+LIBRARY		egul.lib
+LIBRARY		guicons.lib
+LIBRARY		ws32.lib
+LIBRARY		imageconversion.lib
+LIBRARY		fbscli.lib
+LIBRARY		qr3.lib
+LIBRARY		hal.lib
+LIBRARY		ltkutils.lib
+LIBRARY		iocli.lib
+LIBRARY		CommonDialogs.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/inc/GuiCons.hrh	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// GuiCons.hrh
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __GUICONS_HRH__
+#define __GUICONS_HRH__
+
+// GuiCons commands
+enum TGuiConsCommands
+	{
+	EGuiConsCommandFirst = 0x6001, // start value must not be 0
+	EGuiConsFocusConsole = EGuiConsCommandFirst,
+	EGuiConsFocusEdwin,
+	EGuiConsCloseConsole,
+	EGuiConsNewConsole,
+	EGuiConsSwitchTab,
+	EGuiConsCtrlC,
+	EGuiConsNavigationSubMenu,
+	EGuiConsSettingsSubMenu,
+	EGuiConsCommandsSubMenu,
+	EGuiConsCommandLast,
+
+	// Commands below here are in submenus
+	EGuiConsPageUp,
+	EGuiConsPageDown,
+	EGuiConsHome,
+	EGuiConsEnd,
+	EGuiConsLongPressSwitchesTabs,
+	EGuiConsShow5Way,
+	EGuiConsChooseFont,
+	EGuiConsResetFont,
+
+	ECommandStart = 0x6500,
+	ETabStart = 0x7000
+	};
+
+#endif // __GUICONS_HRH__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/inc/GuiConsAppUi.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,131 @@
+// GuiConsAppUi.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __GUICONSAPPUI_H__
+#define __GUICONSAPPUI_H__
+
+#include <aknappui.h>
+#include <aknnavide.h>
+#include <eikedwin.h>
+#include <akntabobserver.h>
+
+#include <fshell/guicons.h>
+#include <fshell/settings.h>
+#include <fshell/qr3dll.h>
+
+class CGuiConsAppView;
+class CAknTabGroup;
+class CConsoleState;
+class CCommandText;
+
+class CGuiConsAppUi : public CAknAppUi
+					, public MConsoleUi
+					, public MAknTabObserver
+					, public MCaptureInterface
+	{
+public:
+	void ConstructL();
+	CGuiConsAppUi();
+	virtual ~CGuiConsAppUi();
+	
+	void SetNaviPaneTextL(const TDesC& aText);
+	// from CCoeAppUi:
+	virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
+	// from MConsoleUi
+	virtual void HandleNewConsoleL(CConsoleControl* aConsole);
+	virtual void HandleConsoleClosed(CConsoleControl* aConsole);
+	virtual void ConsoleTitleChangedL(const CConsoleControl*, const TDesC&);
+	virtual TInt GetConsoleBufferSize();
+	virtual const TDesC& GetConsoleFont();
+private:
+	enum TState
+		{
+		ENoConsole,
+		EConsoleActive,
+		EEdwinActive,
+		EConsoleClosed,
+		};
+private:
+	void HandleCommandL(TInt aCommand);
+	void HandleStatusPaneSizeChange();
+	void SetMenuItemDimmed(TInt aCommandId, CEikMenuPane* aMenuPane);
+	void DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane);
+	TBool CommandValidInCurrentState(TInt aCommandId);
+	
+	void SetStateL(TState aNewState);
+	void SetSoftkeysL();
+	
+	void NewFshellProcessL(const TDesC& aArgs);
+	CConsoleState* StateForConsole(const CConsoleControl* aControl);
+	void SetStateToPreferredL();
+	void DeleteCurrentConsoleL();
+	void SwitchTabL(TInt aTabIdx);
+	void SetCapturingLongPressesL(TBool aEnable);
+	void InputTextL(const TDesC& aText);
+	void LoadCommandsL();
+	
+	void DisplayMessageL(TRefByValue<const TDesC> aFmt, ...);
+
+private: // From MAknTabObserver
+	void TabChangedL(TInt aIndex);
+private: // From MCaptureInterface
+	void CapturedKeyPressedL(TInt aIdentifier);
+
+private:
+	TState iState;
+	TBool iEdwinWasLastRunningState;
+	CGuiConsAppView* iAppView;
+	CAknNavigationDecorator* iNaviDecorator;
+	CAknNavigationControlContainer* iNaviPane;
+	CAknTabGroup* iTabGroup;
+	RPointerArray<CConsoleState> iTabs;
+	TBool iShouldDisplayOnscreenNav;
+	
+	CServer2* iConsoleServer;
+
+	CConsoleControl* iConsole; // The currently displayed console. Not owned
+	CConsoleState* iTempState; // Used in case we get a call to SetTitle before HandleNewConsole
+	RPointerArray<CCommandText> iCommands;
+	
+	LtkUtils::CIniFile* iIniFile;
+	};
+	
+class CBlankControl : public CCoeControl
+	{
+public:
+	virtual void Draw(const TRect& aRect) const;
+	};
+
+class CConsoleState : public CBase
+	{
+public:
+	CConsoleState(CConsoleControl* aControl);
+	~CConsoleState();
+
+	CConsoleControl* iControl;
+	TBool iConsoleClosed;
+	TBuf<32> iTitle;
+	};
+
+class CCommandText : public CBase
+	{
+public:
+	CCommandText(TInt aOrder);
+	~CCommandText();
+	static TInt Order(const CCommandText& aLeft, const CCommandText& aRight);
+public:
+	TInt iOrder;
+	TBuf<16> iName;
+	HBufC* iValue;
+	};
+	
+#endif // __GUICONSAPPUI_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/inc/GuiConsAppView.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,88 @@
+// GuiConsAppView.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __GUICONSAPPVIEW_H__
+#define __GUICONSAPPVIEW_H__
+
+#include <coecntrl.h>
+class CEikEdwin;
+class CEikLabel;
+class CImageDecoder;
+class CImageDecodeAo;
+
+enum TGuiConsViewPanic
+	{
+	EGuiConsControlAlreadyExists = 0,
+	EGuiConsBadControlIndex,
+	};
+
+class CGuiConsAppView : public CCoeControl
+	{
+public:
+	static CGuiConsAppView* NewL(const TRect& aRect);
+	static CGuiConsAppView* NewLC(const TRect& aRect);
+	virtual ~CGuiConsAppView();
+	
+	void SetLargeControlL(CCoeControl* aControl);
+	void ClearLargeControl();
+	void ShowLabelL(const TDesC& aText);
+	void ShowEditor();
+	void FocusEditor(TBool aFocus);
+	void AddEditorToStackL(CCoeAppUi* aAppUi);
+	void RemoveEditorFromStack(CCoeAppUi* aAppUi);
+	HBufC* GetEditorTextL();
+	void SetEditorTextL(const TDesC* aText);
+	
+	void Draw(const TRect& aRect) const;
+	virtual void SizeChanged();
+	TInt CountComponentControls() const;
+	CCoeControl* ComponentControl(TInt aIndex) const;
+
+	void Layout();
+
+	void BgImageReady();
+private:
+	void ConstructL(const TRect& aRect);
+	CGuiConsAppView();
+	
+private:
+	CCoeControl* iLargeControl;
+	CEikEdwin* iEditor;
+	CEikLabel* iLabel;
+	CImageDecodeAo* iBgImage;
+	};
+	
+class CImageDecodeAo : public CActive
+	{
+public:
+	static CImageDecodeAo* NewL(CGuiConsAppView& aOwner, const TDesC& aFileName);
+	~CImageDecodeAo();
+	CFbsBitmap* Bitmap();
+	void Bitblt(CWindowGc& aGc, TPoint aPosition);
+	
+private:
+	CImageDecodeAo(CGuiConsAppView& aOwner);
+	void ConstructL(const TDesC& aFileName);
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	CGuiConsAppView& iOwner;
+	RFs iFs;
+	CImageDecoder* iDecoder;
+	TBool iBitmapReady;
+	CFbsBitmap* iBitmap;
+	CFbsBitmap* iMask;	
+	};
+	
+
+
+#endif // __GUICONSAPPVIEW_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/inc/GuiConsApplication.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// GuiConsApplication.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __GUICONSAPPLICATION_H__
+#define __GUICONSAPPLICATION_H__
+
+#include <aknapp.h>
+
+class CGuiConsApplication : public CAknApplication
+	{
+public:
+	TUid AppDllUid() const;
+protected:
+	CApaDocument* CreateDocumentL();
+	};
+
+#endif // __GUICONSAPPLICATION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/inc/GuiConsDocument.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+// GuiConsDocument.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __GUICONSDOCUMENT_H__
+#define __GUICONSDOCUMENT_H__
+
+#include <akndoc.h>
+
+class CGuiConsAppUi;
+class CEikApplication;
+
+class CGuiConsDocument : public CAknDocument
+	{
+public:
+	static CGuiConsDocument* NewL( CEikApplication& aApp );
+	static CGuiConsDocument* NewLC( CEikApplication& aApp );
+	virtual ~CGuiConsDocument();
+public:
+	CEikAppUi* CreateAppUiL();
+private:
+	void ConstructL();
+	CGuiConsDocument( CEikApplication& aApp );
+	};
+
+#endif // __GUICONSDOCUMENT_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/src/GuiCons.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+// GuiCons.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <eikstart.h>
+#include "GuiConsApplication.h"
+
+
+LOCAL_C CApaApplication* NewApplication()
+	{
+	return new CGuiConsApplication;
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	return EikStart::RunApplication( NewApplication );
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/src/GuiConsAppUi.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,841 @@
+// GuiConsAppUi.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <avkon.hrh>
+#include <aknnotewrappers.h>
+#include <stringloader.h>
+#include <GuiCons.rsg>
+#include <f32file.h>
+#include <s32file.h>
+#include <aknnavi.h>
+#include <aknnavilabel.h>
+#include <akntabgrp.h>
+#include <akntitle.h>
+#include <hal.h>
+#include <caknmemoryselectiondialog.h>
+#include <caknfileselectiondialog.h>
+#include <fshell/ltkutils.h>
+
+#include "GuiConsAppUi.h"
+#include "GuiConsAppView.h"
+#include "GuiCons.hrh"
+
+#define EXPAND(L, X) L(X)
+#define PANIC() User::Panic(EXPAND(_L, __FILE__), __LINE__)
+#define GUICONS_ASSERT(x) __ASSERT_ALWAYS(x, PANIC())
+
+_LIT(KServerName, "guicons");
+_LIT(KNoConsole, "no console connected");
+_LIT(KConsoleClosed, "console closed");
+_LIT(KNewProcName, "fshell.exe");
+_LIT(KNewProcArgs, "--console guicons");
+
+_LIT(KIniFile, "\\system\\console\\guicons.ini");
+_LIT(KIdfFile, "\\resource\\guicons.idf");
+_LIT(KIniLongPress, "longpress");
+_LIT(KIniShowNav, "shownav");
+_LIT(KIniBufferSize, "buffersize");
+_LIT(KIniFont, "font");
+
+_LIT(KInvalidFontMsgFmt, "The file '%S' is not a valid font (error %d).\r\n\r\nA font file is a bitmap containing an 8x12 grid "
+			L"of characters with ASCII codes 32 to 127. The width of the bitmap must be a multiple of 8, and the "
+			L"height must be a multiple of 12.");
+_LIT(KFontPreview, "New font:\r\nThe quick brown fox jumps over the lazy dog.");
+
+void CGuiConsAppUi::ConstructL()
+	{
+	BaseConstructL(CAknAppUi::EAknEnableSkin);
+	iTempState = new(ELeave) CConsoleState(NULL);
+	iAppView = CGuiConsAppView::NewL( ClientRect() );
+	
+	iIniFile = LtkUtils::CIniFile::NewL(KIniFile, KIdfFile);
+	
+	iAppView->Layout();
+	iAppView->ActivateL();
+
+	CEikStatusPane* sp = StatusPane();
+	iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
+	//iNaviDecorator = iNaviPane->CreateNavigationLabelL(_L("guicons"));
+	iNaviDecorator = iNaviPane->CreateTabGroupL(this);
+	iTabGroup = static_cast<CAknTabGroup*>(iNaviDecorator->DecoratedControl());
+	iTabGroup->SetTabFixedWidthL(KTabWidthWithFourTabs);
+	iNaviPane->PushL(*iNaviDecorator);
+
+	SetStateL(ENoConsole);
+	ConsoleTitleChangedL(NULL, KNullDesC);
+
+	SetCapturingLongPressesL(iIniFile->GetBool(KIniLongPress));
+	
+	LtkUtils::CSetting* showNavSetting = iIniFile->GetSetting(KIniShowNav);
+	if (!showNavSetting->IsSet())
+		{
+		TBool hasTouchScreen = EFalse;
+		TInt err = HAL::Get(HAL::EPen, hasTouchScreen);
+		if (!err && hasTouchScreen)
+			{
+			iShouldDisplayOnscreenNav = ETrue;
+			}
+		}
+	else
+		{
+		iShouldDisplayOnscreenNav = showNavSetting->AsBool();
+		}
+	
+	iConsoleServer = StartGuiConsServerL(KServerName, *this);	
+
+	TRAP_IGNORE(LoadCommandsL());
+	}
+
+CGuiConsAppUi::CGuiConsAppUi()
+	{
+	}
+	
+void CGuiConsAppUi::SetNaviPaneTextL(const TDesC& aText)
+	{
+	if (iNaviDecorator->ControlType() == CAknNavigationDecorator::ENaviLabel)
+		{
+		CAknNaviLabel* naviLabel = (CAknNaviLabel*)iNaviDecorator->DecoratedControl();
+		naviLabel->SetTextL(aText);
+		iNaviPane->DrawNow();
+		naviLabel->DrawNow();
+		}
+	}
+	
+TKeyResponse CGuiConsAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if (aType == EEventKey)
+		{
+		switch (iState)
+			{
+		case EEdwinActive:
+			GUICONS_ASSERT(iConsole);
+			// fallthrough
+		case EConsoleClosed:
+			switch (aKeyEvent.iCode)
+				{
+			case EKeyEnter:
+			case EKeyDevice3:
+				if (iState == EEdwinActive) 
+					{
+					HBufC* text = iAppView->GetEditorTextL();
+					if (text)
+						{
+							{
+							CleanupStack::PushL(text);
+							iConsole->InjectKeysL(*text);
+							CleanupStack::PopAndDestroy();
+							}
+						iConsole->InjectKeysL(_L("\r"));
+						iAppView->SetEditorTextL(NULL);
+						//iAppView->Editor()->DrawNow();
+						}
+					SetStateL(iState);
+					return EKeyWasConsumed;
+					}
+			case EKeyUpArrow:
+				iConsole->ViewScrollUp();
+				return EKeyWasConsumed;
+			case EKeyDownArrow:
+				iConsole->ViewScrollDown();
+				return EKeyWasConsumed;
+			case EKeyPageDown:
+				iConsole->ViewPageDown();
+				return EKeyWasConsumed;
+			case EKeyPageUp:
+				iConsole->ViewPageUp();
+				return EKeyWasConsumed;
+			case EKeyHome:
+				iConsole->ViewHome();
+				return EKeyWasConsumed;
+			case EKeyEnd:
+				iConsole->ViewEnd();
+				return EKeyWasConsumed;
+			default:
+				break;
+				}
+		case EConsoleActive:
+		case ENoConsole:
+		default:
+			return EKeyWasNotConsumed;
+			}
+		}
+	return EKeyWasNotConsumed;
+	}
+	
+	
+void CGuiConsAppUi::SetSoftkeysL()
+	{
+	CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
+	
+	TInt softkeysResourceId;
+	switch (iState)
+		{
+	case EConsoleActive:
+		softkeysResourceId = R_GUICONS_INTERACTIVE_CBA;
+		break;
+	case EEdwinActive:
+		softkeysResourceId = R_GUICONS_LINE_CBA;
+		break;
+	case EConsoleClosed:
+		softkeysResourceId = R_GUICONS_CLOSED_CBA;
+		break;
+	case ENoConsole:
+	default:
+		softkeysResourceId = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+		break;
+		}
+	cba->SetCommandSetL(softkeysResourceId);
+	cba->DrawNow();
+	}
+	
+void CGuiConsAppUi::SetStateL(TState aNewState)
+	{
+	switch (aNewState)
+		{
+	case ENoConsole:
+		GUICONS_ASSERT(!iConsole);
+		CCoeEnv::Static()->RootWin().CancelTextCursor();
+		iAppView->ShowLabelL(KNoConsole);
+		break;
+		
+	case EConsoleActive:
+		GUICONS_ASSERT(iConsole);
+		iAppView->FocusEditor(EFalse);
+		iAppView->RemoveEditorFromStack(this);
+
+		RemoveFromStack(iConsole);
+		AddToStackL(iConsole);
+		iConsole->SetFocusing(ETrue);
+		iConsole->SetFocus(ETrue);
+		iAppView->ShowEditor();
+		iEdwinWasLastRunningState = EFalse;
+		break;
+		
+	case EEdwinActive:
+		GUICONS_ASSERT(iConsole);
+		iConsole->SetFocus(EFalse);
+		iConsole->SetFocusing(EFalse);
+		RemoveFromStack(iConsole);
+		iAppView->ShowEditor();
+		iAppView->FocusEditor(ETrue);
+		
+		iAppView->RemoveEditorFromStack(this);
+		iAppView->AddEditorToStackL(this);
+
+		iAppView->ShowEditor();
+		iEdwinWasLastRunningState = ETrue;
+		break;
+		
+	case EConsoleClosed:
+		GUICONS_ASSERT(iConsole);
+		iAppView->FocusEditor(EFalse);
+		iAppView->RemoveEditorFromStack(this);
+		RemoveFromStack(iConsole);
+		iAppView->ShowLabelL(KConsoleClosed);
+		CCoeEnv::Static()->RootWin().CancelTextCursor();
+		break;
+		}
+	iState = aNewState;
+	SetSoftkeysL();
+	}
+	
+void CGuiConsAppUi::HandleNewConsoleL(CConsoleControl* aConsole)
+	{
+	CConsoleState* newState = new(ELeave) CConsoleState(aConsole);
+	iTabs.AppendL(newState);
+	if (aConsole == iTempState->iControl)
+		{
+		newState->iTitle.Copy(iTempState->iTitle);
+		iTempState->iControl = NULL;
+		}
+	TBuf<2> text;
+	text.Num(iTabs.Count());
+	iTabGroup->AddTabL(reinterpret_cast<TInt>(newState), text);
+	SwitchTabL(iTabs.Count()-1);
+	SetStateToPreferredL();
+	aConsole->ActivateL();
+	}
+	
+void CGuiConsAppUi::HandleConsoleClosed(CConsoleControl* aConsole)
+	{
+	CConsoleState* state = StateForConsole(aConsole);
+	if (state)
+		{
+		state->iConsoleClosed = ETrue;
+		}
+
+	if (aConsole && (aConsole == iConsole))
+		{
+		TRAP_IGNORE(SetStateL(EConsoleClosed));
+		}
+	}
+	
+void CGuiConsAppUi::ConsoleTitleChangedL(const CConsoleControl* aConsole, const TDesC& aTitle)
+	{
+	//SetNaviPaneTextL(aTitle);
+
+	// Put it in the title so the navi bar is free for tabs
+	if (aConsole == iConsole)
+		{
+		// If aConsole isn't current, we don't want to update anything
+		CEikStatusPane* sp = StatusPane();
+		CAknTitlePane* titlePane = NULL;
+		if (sp) titlePane = (CAknTitlePane*)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
+		if (titlePane)
+			{
+			if (aTitle.Length())
+				{
+				titlePane->SetTextL(aTitle);
+				}
+			else
+				{
+				titlePane->SetTextL(_L("GuiCons"));
+				}
+			}
+		}
+
+	// And update the state
+	CConsoleState* state = StateForConsole(aConsole);
+	if (state)
+		{
+		state->iTitle = aTitle.Left(state->iTitle.MaxLength());
+		}
+	else
+		{
+		iTempState->iControl = const_cast<CConsoleControl*>(aConsole);
+		iTempState->iTitle = aTitle.Left(iTempState->iTitle.MaxLength());
+		}
+	}
+	
+TInt CGuiConsAppUi::GetConsoleBufferSize()
+	{
+	return iIniFile->GetInt(KIniBufferSize);
+	}
+	
+const TDesC& CGuiConsAppUi::GetConsoleFont()
+	{
+	return iIniFile->GetString(KIniFont);
+	}
+
+CGuiConsAppUi::~CGuiConsAppUi()
+	{
+	CKeyCapturer::DeleteCapturer();
+
+	iAppView->RemoveEditorFromStack(this);
+	delete iConsoleServer;
+	iTabs.ResetAndDestroy();
+	delete iNaviDecorator;
+	delete iAppView;
+	delete iTempState;
+	iCommands.ResetAndDestroy();
+	delete iIniFile;
+	}
+
+void CGuiConsAppUi::HandleCommandL(TInt aCommand)
+	{
+	if (!CommandValidInCurrentState(aCommand))
+		{
+		_LIT(KNotAvailableNow, "Not available now");
+		iEikonEnv->InfoMsg(KNotAvailableNow);
+		return;
+		}
+	
+	switch(aCommand)
+		{
+	case EEikCmdExit:
+	case EAknSoftkeyExit:
+		Exit();
+		break;
+
+	case EGuiConsFocusConsole:
+		SetStateL(EConsoleActive);
+		break;
+	case EGuiConsFocusEdwin:
+		SetStateL(EEdwinActive);
+		break;
+	case EGuiConsPageUp:
+		iConsole->ViewPageUp();
+		break;
+	case EGuiConsPageDown:
+		iConsole->ViewPageDown();
+		break;
+	case EGuiConsHome:
+		iConsole->ViewHome();
+		break;
+	case EGuiConsEnd:
+		iConsole->ViewEnd();
+		break;
+	case EGuiConsCloseConsole:
+		DeleteCurrentConsoleL();
+		break;
+	case EGuiConsNewConsole:
+		NewFshellProcessL(KNullDesC);
+		break;
+	case EGuiConsCtrlC:
+		{
+		TKeyEvent key;
+		key.iCode = CTRL('c');
+		key.iScanCode = 0;
+		key.iRepeats = 0;
+		key.iModifiers = EModifierLeftCtrl | EModifierCtrl;
+		iConsole->OfferKeyEventL(key, EEventKey);
+		break;
+		}
+	case EGuiConsShow5Way:
+		{
+		iShouldDisplayOnscreenNav = !iShouldDisplayOnscreenNav;
+		if (iConsole) iConsole->SetDisplayFivewayNav(iShouldDisplayOnscreenNav);
+		TRAP_IGNORE(iIniFile->SetL(KIniShowNav, iShouldDisplayOnscreenNav); iIniFile->WriteL());
+		break;
+		}
+	case EGuiConsLongPressSwitchesTabs:
+		{
+		TBool capturing = CKeyCapturer::GetCapturerL()->IsCaptured(EKeyLeftArrow);
+		SetCapturingLongPressesL(!capturing);
+		TRAP_IGNORE(iIniFile->SetL(KIniLongPress, !capturing); iIniFile->WriteL());
+		break;
+		}
+	case EGuiConsChooseFont:
+		{
+		// Note, we have to use the memory and file selection dialogs seperately
+		// so that we can choose things from C: outside of C:\Data
+		
+		// choose drive
+		// TODO see if we can do something better here, so we can also choose files from Z: and
+		// other drives
+		CAknMemorySelectionDialog::TMemory memory = CAknMemorySelectionDialog::EPhoneMemory;
+		if (!CAknMemorySelectionDialog::RunDlgLD(memory))
+			{
+			break;
+			}
+		TChar drive = (memory == CAknMemorySelectionDialog::EPhoneMemory) ? 'C' : 'E';
+		
+		TFileName* fn = new(ELeave)TFileName;
+		CleanupStack::PushL(fn);
+		fn->Append(drive);
+		fn->Append(_L(":\\"));
+		CAknFileSelectionDialog* fileSel = CAknFileSelectionDialog::NewL(ECFDDialogTypeSelect);
+		CleanupStack::PushL(fileSel);
+		fileSel->SetDefaultFolderL(_L("\\"));
+		if (fileSel->ExecuteL(*fn))
+			{
+			
+			// verify that the file chosen is a valid font
+			CConsoleFont* font = NULL;
+			TRAPD(err, font = CConsoleFont::NewL(*fn));
+			if (err!=KErrNone)
+				{
+				DisplayMessageL(KInvalidFontMsgFmt, fn, err);
+				}
+			else
+				{
+				TRAP_IGNORE(iIniFile->SetL(KIniFont, *fn); iIniFile->WriteL());
+				DisplayMessageL(KFontPreview);
+				}
+			delete font;
+			}
+		CleanupStack::PopAndDestroy(2, fn); // fn, fileSel
+		break;
+		}
+	
+	case EGuiConsResetFont:
+		iIniFile->RemoveValueL(KIniFont);
+		iIniFile->WriteL();
+		break;
+		
+	default:		
+		break;
+		}
+
+	if (aCommand >= ETabStart)
+		{
+		TInt tabIdx = aCommand - ETabStart;
+		SwitchTabL(tabIdx);
+		}
+	else if (aCommand >= ECommandStart)
+		{
+		TInt cmdIdx = aCommand - ECommandStart;
+		InputTextL(*iCommands[cmdIdx]->iValue);
+		}
+	}
+	
+void CGuiConsAppUi::NewFshellProcessL(const TDesC& aArgs)
+	{
+	RBuf args;
+	args.Create(aArgs.Length()+1+KNewProcArgs().Length());
+	CleanupClosePushL(args);
+	args.Append(KNewProcArgs);
+	args.Append(' ');
+	args.Append(aArgs);
+	
+	RProcess proc;
+	User::LeaveIfError(proc.Create(KNewProcName, args));
+	proc.Resume();
+	proc.Close();
+	CleanupStack::PopAndDestroy(&args);
+	}
+
+void CGuiConsAppUi::HandleStatusPaneSizeChange()
+	{
+	iAppView->SetRect( ClientRect() );
+	}
+	
+void CGuiConsAppUi::SetMenuItemDimmed(TInt aCommandId, CEikMenuPane* aMenuPane)
+	{
+	aMenuPane->SetItemDimmed(aCommandId, !CommandValidInCurrentState(aCommandId));
+	}
+	
+void CGuiConsAppUi::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane)
+	{
+	if (aMenuId == R_GUICONS_MENU)
+		{
+		SetMenuItemDimmed(EAknSoftkeyExit, aMenuPane);
+		for (TInt i = EGuiConsCommandFirst; i<EGuiConsCommandLast; ++i)
+			{
+			SetMenuItemDimmed(i, aMenuPane);
+			}
+		}
+	else if (aMenuId == R_GUICONS_TABS_SUBMENU)
+		{
+		for (TInt i = 0; i < iTabs.Count(); i++)
+			{
+			CConsoleState* state = iTabs[i];
+			CEikMenuPaneItem::SData menu;
+			menu.iCommandId = ETabStart + i;
+			menu.iCascadeId = 0;
+			menu.iFlags = 0;
+			menu.iText = state->iTitle;
+			aMenuPane->AddMenuItemL(menu);
+			}
+		}
+	else if (aMenuId == R_GUICONS_SETTINGS_SUBMENU)
+		{
+		TBool capturing = CKeyCapturer::GetCapturerL()->IsCaptured(EKeyLeftArrow);
+		aMenuPane->SetItemButtonState(EGuiConsLongPressSwitchesTabs, capturing ? EEikMenuItemSymbolOn : 0);
+		aMenuPane->SetItemButtonState(EGuiConsShow5Way, iShouldDisplayOnscreenNav ? EEikMenuItemSymbolOn : 0);
+		SetMenuItemDimmed(EGuiConsResetFont, aMenuPane);
+		}
+	else if (aMenuId == R_GUICONS_COMMANDS_SUBMENU)
+		{
+		for (TInt i = 0; i < iCommands.Count(); i++)
+			{
+			CCommandText* command = iCommands[i];
+			CEikMenuPaneItem::SData menu;
+			menu.iCommandId = ECommandStart + i;
+			menu.iCascadeId = 0;
+			menu.iFlags = 0;
+			menu.iText = command->iName;
+			aMenuPane->AddMenuItemL(menu);
+			}
+		}
+	}
+	
+TBool CGuiConsAppUi::CommandValidInCurrentState(TInt aCommandId)
+	{
+	switch (aCommandId)
+		{
+	case EEikCmdExit:
+	case EAknSoftkeyExit:
+		return (iState == ENoConsole || iState == EConsoleClosed);
+	case EGuiConsFocusConsole:
+		return (iState == EEdwinActive);
+	case EGuiConsFocusEdwin:
+		return (iState == EConsoleActive);
+	case EGuiConsPageUp:
+	case EGuiConsPageDown:
+	case EGuiConsHome:
+	case EGuiConsEnd:
+		return (iState == EEdwinActive) || (iState == EConsoleActive) || (iState == EConsoleClosed);
+	case EGuiConsCloseConsole:
+		return (iState == EConsoleClosed);
+	case EGuiConsNewConsole:
+		return ETrue; //(iState == ENoConsole);
+	case EGuiConsSwitchTab:
+		return iTabs.Count() > 1;
+	case EGuiConsCtrlC:
+		return (iState == EEdwinActive) || (iState == EConsoleActive);
+	case EGuiConsNavigationSubMenu:
+		return CommandValidInCurrentState(EGuiConsHome) || CommandValidInCurrentState(EGuiConsEnd) || CommandValidInCurrentState(EGuiConsPageUp) || CommandValidInCurrentState(EGuiConsPageDown);
+	case EGuiConsCommandsSubMenu:
+		return (iState == EEdwinActive) || (iState == EConsoleActive);
+	case EGuiConsResetFont:
+		return iIniFile->GetSetting(KIniFont)->IsSet();
+	default:
+		return ETrue;
+		}
+	}
+
+
+void CBlankControl::Draw(const TRect& aRect) const
+	{
+	CWindowGc& gc = SystemGc();
+	gc.SetPenStyle(CGraphicsContext::ENullPen);
+	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
+	gc.SetBrushColor(TRgb(0x80, 0x80, 0x80));
+	gc.DrawRect(aRect);
+	}
+
+void CGuiConsAppUi::TabChangedL(TInt aIndex)
+	{
+	//__DEBUGGER();
+	CConsoleState* newTabState = (CConsoleState*)(TAny*)iTabGroup->TabIdFromIndex(aIndex);
+	CConsoleControl* newTab = newTabState->iControl;
+	CConsoleControl* oldTab = iConsole;
+	iConsole = newTab;
+
+	// Update what's on screen, and what has keyboard focus
+	if (oldTab)
+		{
+		// Could be null, maybe
+		RemoveFromStack(oldTab);
+		oldTab->MakeVisible(EFalse);
+		}
+	if (newTab)
+		{
+		// Could be null if we haven't implemented this tab yet
+		//AppUi()->AddToStackL(*this, newTab, ECoeStackPriorityDefault-1); // One less than the tab bar to ensure we don't unintentionally consume left and right arrows
+		AddToStackL(newTab);
+		newTab->MakeVisible(ETrue);
+		newTab->SetDisplayFivewayNav(iShouldDisplayOnscreenNav); // Make sure this is sync'd
+		}
+	iAppView->ClearLargeControl();
+	iAppView->SetLargeControlL(iConsole);
+	if (newTabState->iConsoleClosed)
+		{
+		SetStateL(EConsoleClosed);
+		}
+	else
+		{
+		SetStateToPreferredL();
+		}
+	ConsoleTitleChangedL(iConsole, newTabState->iTitle);
+	}
+
+CConsoleState* CGuiConsAppUi::StateForConsole(const CConsoleControl* aControl)
+	{
+	for (TInt i = 0; i < iTabs.Count(); i++)
+		{
+		if (iTabs[i]->iControl == aControl) return iTabs[i];
+		}
+	return NULL;
+	}
+
+void CGuiConsAppUi::SetStateToPreferredL()
+	{
+	if (iEdwinWasLastRunningState)
+		{
+		SetStateL(EEdwinActive);
+		}
+	else
+		{
+		SetStateL(EConsoleActive);
+		}
+	}
+
+void CGuiConsAppUi::DeleteCurrentConsoleL()
+	{
+	TInt found = KErrNotFound;
+	for (TInt i = 0; i < iTabs.Count(); i++)
+		{
+		if (iTabs[i]->iControl == iConsole)
+			{
+			found = i;
+			break;
+			}
+		}
+	GUICONS_ASSERT(found >= 0);
+
+	CConsoleState* state = iTabs[found];
+	iTabs.Remove(found);
+	CleanupStack::PushL(state); // Keep the state around until we've finished switching, just in case
+	iTabGroup->DeleteTabL((TInt)state);
+	if (found >= iTabs.Count()) found = iTabs.Count()-1;
+	if (found >= 0)
+		{
+		SwitchTabL(found);
+		}
+	else
+		{
+		iConsole = NULL;
+		iAppView->ClearLargeControl();
+		SetStateL(ENoConsole);
+		ConsoleTitleChangedL(NULL, KNullDesC);
+		}
+	CleanupStack::PopAndDestroy(state);
+	}
+
+void CGuiConsAppUi::CapturedKeyPressedL(TInt aIdentifier)
+	{
+	TKeyEvent key;
+	key.iCode = aIdentifier;
+	key.iRepeats = 0;
+	key.iModifiers = 0;
+	switch (aIdentifier)
+		{
+		case EKeyLeftArrow:
+			key.iScanCode = EStdKeyLeftArrow;
+			iTabGroup->OfferKeyEventL(key, EEventKey);
+			break;
+		case EKeyRightArrow:
+			key.iScanCode = EStdKeyRightArrow;
+			iTabGroup->OfferKeyEventL(key, EEventKey);
+			break;
+		default:
+			break;
+		}
+	}
+
+void CGuiConsAppUi::SwitchTabL(TInt aTabIdx)
+	{
+	iTabGroup->SetActiveTabByIndex(aTabIdx);
+	TabChangedL(aTabIdx);
+	}
+
+void CGuiConsAppUi::SetCapturingLongPressesL(TBool aEnable)
+	{
+	CKeyCapturer::GetCapturerL()->RemoveCapture(this, EKeyLeftArrow);
+	CKeyCapturer::GetCapturerL()->RemoveCapture(this, EKeyRightArrow);
+	if (aEnable)
+		{
+		CKeyCapturer::GetCapturerL()->AddLongCaptureL(this, EKeyLeftArrow, EKeyLeftArrow, EStdKeyLeftArrow);
+		CKeyCapturer::GetCapturerL()->AddLongCaptureL(this, EKeyRightArrow, EKeyRightArrow, EStdKeyRightArrow);
+		}
+	}
+
+void CGuiConsAppUi::InputTextL(const TDesC& aText)
+	{
+	if (iState == EEdwinActive)
+		{
+		iAppView->SetEditorTextL(&aText);
+		}
+	else
+		{
+		iConsole->InjectKeysL(aText);
+		}
+	}
+
+void CGuiConsAppUi::LoadCommandsL()
+	{
+	_LIT(KCommandsDir, "\\system\\console\\commands\\");
+	_LIT(KCommandNameMatch, "*.txt");
+	TFindFile findfile(iEikonEnv->FsSession());
+	CDir* list = NULL;
+	TInt found = findfile.FindWildByDir(KCommandsDir, KCommandNameMatch, list);
+	TFileName filename;
+	while (found == KErrNone)
+		{
+		filename = TParsePtrC(findfile.File()).DriveAndPath();
+		TInt dirLen = filename.Length();
+		CleanupStack::PushL(list);
+		for (TInt i = 0; i < list->Count(); i++)
+			{
+			const TEntry& entry = (*list)[i];
+			const TDesC& name = entry.iName;
+			filename.SetLength(dirLen);
+			filename.Append(name);
+			TLex lex(name);
+			TInt order = 0;
+			lex.Val(order);
+			if (lex.Peek() == '-') lex.Inc();
+			CCommandText* cmd = new(ELeave) CCommandText(order);
+			CleanupStack::PushL(cmd);
+			cmd->iName = TParsePtrC(lex.Remainder()).Name().Left(cmd->iName.MaxLength());
+			LtkUtils::ReplaceText(cmd->iName, _L("_"), _L(" "));
+			cmd->iValue = HBufC::NewMaxL(entry.iSize);
+			TPtr8 narrow((TUint8*)cmd->iValue->Ptr(), 0, entry.iSize*2);
+			User::LeaveIfError(iEikonEnv->FsSession().ReadFileSection(filename, 0, narrow, entry.iSize));
+			narrow.Expand();
+			iCommands.InsertInOrderAllowRepeatsL(cmd, TLinearOrder<CCommandText>(&CCommandText::Order));
+			CleanupStack::Pop(cmd);
+			}
+		CleanupStack::PopAndDestroy(list);
+		found = findfile.FindWild(list);
+		}
+	}
+	
+_LIT(KShellEchoArgsStart, "--exec \"echo --wrap ^\"");
+_LIT(KShellEchoArgsEnd, "^\"\"");
+_LIT(KEsc, "^^");
+
+TBool NeedsEscape(TChar aChar)
+	{
+	return (aChar == '"');
+	}
+
+void CGuiConsAppUi::DisplayMessageL(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+
+	IoUtils::CTextBuffer* msgBuf = IoUtils::CTextBuffer::NewLC(0x20);
+	msgBuf->AppendFormatListL(aFmt, list);	
+	
+	IoUtils::CTextBuffer* buf = IoUtils::CTextBuffer::NewLC(0x20);
+	
+	buf->AppendL(KShellEchoArgsStart);
+	const TDesC& msg(msgBuf->Descriptor());
+	
+	for (TInt i=0; i<msg.Length(); ++i)
+		{
+		if (msg[i] == '\n')
+			{
+			buf->AppendL(KEsc);
+			buf->AppendL('n');
+			}
+		else if (msg[i] == '\r')
+			{
+			buf->AppendL(KEsc);
+			buf->AppendL('r');
+			}
+		else if (NeedsEscape(msg[i]))
+			{
+			buf->AppendL(KEsc);
+			buf->AppendL(msg[i]);
+			}
+		else
+			{
+			buf->AppendL(msg[i]);
+			}
+		}
+	buf->AppendL(KShellEchoArgsEnd);
+	
+	NewFshellProcessL(buf->Descriptor());
+	CleanupStack::PopAndDestroy(2, msgBuf);
+	}
+
+// CConsoleState
+
+CConsoleState::CConsoleState(CConsoleControl* aControl)
+: iControl(aControl), iConsoleClosed(EFalse)
+	{
+	}
+
+CConsoleState::~CConsoleState()
+	{
+	delete iControl;
+	}
+
+// CCommandText
+
+CCommandText::CCommandText(TInt aOrder)
+	: iOrder(aOrder)
+	{}
+
+TInt CCommandText::Order(const CCommandText& aLeft, const CCommandText& aRight)
+	{
+	return aLeft.iOrder - aRight.iOrder;
+	}
+
+CCommandText::~CCommandText()
+	{
+	delete iValue;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/src/GuiConsAppView.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,311 @@
+// GuiConsAppView.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <coemain.h>
+#include <eikedwin.h>
+#include <eiklabel.h>
+#include <eikenv.h>
+#include <barsread.h>
+#include <coeaui.h>
+#include <ImageConversion.h>
+#include "GuiConsAppView.h"
+#include "guicons.rsg"
+
+
+class CEdwinThatDoesntConsumeEnter : public CEikEdwin
+	{
+	TKeyResponse OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType);
+	};
+
+TKeyResponse CEdwinThatDoesntConsumeEnter::OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType)
+	{
+	if (aEvent.iCode == EKeyEnter)
+		{
+		return EKeyWasNotConsumed;
+		}
+	return CEikEdwin::OfferKeyEventL(aEvent, aType);
+	}
+
+_LIT(KGuiConsViewPanic, "GuiConsView");
+
+void Panic(TGuiConsViewPanic aReason)
+	{
+	User::Panic(KGuiConsViewPanic, aReason);
+	}
+
+CGuiConsAppView* CGuiConsAppView::NewL(const TRect& aRect)
+	{
+	CGuiConsAppView* self = CGuiConsAppView::NewLC(aRect);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CGuiConsAppView* CGuiConsAppView::NewLC(const TRect& aRect)
+	{
+	CGuiConsAppView* self = new(ELeave)CGuiConsAppView;
+	CleanupStack::PushL(self);
+	self->ConstructL(aRect);
+	return self;
+	}
+	
+_LIT(KBgImage, "\\resource\\guiconsbg.png");
+
+void CGuiConsAppView::ConstructL(const TRect& aRect)
+	{
+	CreateWindowL();
+
+	iEditor = new(ELeave) CEdwinThatDoesntConsumeEnter;
+
+	iEditor->ConstructL(
+		CEikEdwin::EAvkonEditor | CEikEdwin::ENoWrap | CEikEdwin::ELineCursor | CEikEdwin::ENoLineOrParaBreaks,
+		20, // width in chars
+		0,
+		1); // number of lines
+/*    TResourceReader reader;
+    CCoeEnv::Static()->CreateResourceReaderLC(reader, R_GUICONS_LINEEDITOR_EDWIN);
+
+	iEditor->ConstructFromResourceL(reader);
+	CleanupStack::PopAndDestroy();*/
+
+	iEditor->SetBorder(TGulBorder::ESingleDotted);
+	iEditor->SetContainerWindowL(*this);
+	
+	iLabel = new(ELeave)CEikLabel();
+	iLabel->SetContainerWindowL(*this);
+	iLabel->SetFont(CEikonEnv::Static()->DenseFont());
+	iLabel->SetAlignment(EHCenterVCenter);
+	iLabel->OverrideColorL(EColorLabelText, 0x808080);
+	
+	TRAP_IGNORE(iBgImage = CImageDecodeAo::NewL(*this, KBgImage));
+
+	SetRect(aRect);
+	}
+	
+void CGuiConsAppView::SetLargeControlL(CCoeControl* aControl)
+	{
+	__ASSERT_ALWAYS(!iLargeControl, Panic(EGuiConsControlAlreadyExists));
+	if (!aControl->DrawableWindow())
+		{
+		aControl->SetContainerWindowL(*this);
+		}
+	iLargeControl = aControl;
+	Layout();
+	//DrawNow();
+	DrawDeferred();
+	}
+
+void CGuiConsAppView::ClearLargeControl()
+	{
+	iLargeControl = NULL;
+	//DrawNow();
+	DrawDeferred();
+	}
+	
+void CGuiConsAppView::ShowLabelL(const TDesC& aText)
+	{
+	iLabel->SetTextL(aText);
+	iLabel->MakeVisible(ETrue);
+	iEditor->MakeVisible(EFalse);
+	DrawNow();
+	}
+	
+void CGuiConsAppView::ShowEditor()
+	{
+	iLabel->MakeVisible(EFalse);
+	iEditor->MakeVisible(ETrue);
+	DrawNow();
+	}
+	
+void CGuiConsAppView::FocusEditor(TBool aFocus)
+	{
+	iEditor->SetDimmed(!aFocus);
+	iEditor->SetFocusing(aFocus);
+	iEditor->SetFocus(aFocus);
+	iEditor->SetReadOnly(!aFocus);
+	}
+	
+void CGuiConsAppView::AddEditorToStackL(CCoeAppUi* aAppUi)
+	{
+	aAppUi->AddToStackL(iEditor);
+	}
+	
+void CGuiConsAppView::RemoveEditorFromStack(CCoeAppUi* aAppUi)
+	{
+	aAppUi->RemoveFromStack(iEditor);
+	}
+	
+HBufC* CGuiConsAppView::GetEditorTextL()
+	{
+	return iEditor->GetTextInHBufL();
+	}
+	
+void CGuiConsAppView::SetEditorTextL(const TDesC* aText)
+	{
+	iEditor->SetTextL(aText);
+	}
+
+CGuiConsAppView::CGuiConsAppView()
+	{
+	}
+
+CGuiConsAppView::~CGuiConsAppView()
+	{
+	delete iEditor;
+	delete iLabel;
+	delete iBgImage;
+	}
+
+void CGuiConsAppView::Draw(const TRect& aRect) const
+	{
+	CWindowGc& gc = SystemGc();
+	gc.Clear( aRect );
+
+	// JB - This doesn't seem to work reliably and it messes up scrolling.
+/*	TGulBorder border = iEditor->Border();
+	TRect editorRect = iEditor->Rect();
+	border.Draw(gc, border.OuterRect(editorRect));
+ */   
+    if ((!iLargeControl) && (iBgImage) && (iBgImage->Bitmap()))
+    	{
+    	CFbsBitmap* bg = iBgImage->Bitmap();
+    	TSize bgSize = bg->SizeInPixels();
+    	TPoint myCentre = Rect().iTl + TPoint(Size().iWidth / 2, Size().iHeight/2);
+    	TPoint imgTl = myCentre - TPoint(bgSize.iWidth / 2, bgSize.iHeight / 2);
+    	iBgImage->Bitblt(gc, imgTl);
+    	}
+	}
+	
+void CGuiConsAppView::BgImageReady()
+	{
+	if (!iLargeControl) DrawNow();
+	}
+
+void CGuiConsAppView::SizeChanged()
+	{  
+	Layout();
+	DrawNow();
+	}
+	
+TInt CGuiConsAppView::CountComponentControls() const
+	{
+	TInt count = 2;
+	if (iLargeControl) count++;
+	return count;
+	}
+	
+CCoeControl* CGuiConsAppView::ComponentControl(TInt aIndex) const
+	{
+	switch (aIndex)
+		{
+	case 0:
+		return iLabel;
+	case 1:
+		return iEditor;
+	case 2:
+		if (iLargeControl)
+			{
+			return iLargeControl;
+			}
+		// fallthrough
+	default:
+		Panic(EGuiConsBadControlIndex);
+		return NULL; // keep compiler quiet
+		}
+	}
+	
+void CGuiConsAppView::Layout()
+	{
+	TRect myRect = Rect();
+	TSize largeSize(myRect.Size());	
+
+
+	TSize editorSize(myRect.Width(), iEditor->MinimumSize().iHeight);
+	TRect editorRect(myRect.iBr - editorSize.AsPoint(), editorSize);
+	iEditor->SetRect(editorRect);
+	iLabel->SetRect(editorRect);
+	
+	
+	largeSize.iHeight -= editorSize.iHeight;		
+	
+	if (iLargeControl)
+		{
+		TRect largeRect(myRect.iTl, largeSize);
+		iLargeControl->SetRect(largeRect);
+		}
+	}
+
+//______________________________________________________________________________
+//						CImageDecodeAo
+CImageDecodeAo* CImageDecodeAo::NewL(CGuiConsAppView& aOwner, const TDesC& aFileName)
+	{
+	CImageDecodeAo* self = new(ELeave)CImageDecodeAo(aOwner);
+	CleanupStack::PushL(self);
+	self->ConstructL(aFileName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+CImageDecodeAo::~CImageDecodeAo()
+	{
+	Cancel();
+	delete iDecoder;
+	delete iBitmap;
+	delete iMask;
+	iFs.Close();
+	}
+	
+CFbsBitmap* CImageDecodeAo::Bitmap()
+	{
+	return iBitmapReady ? iBitmap : NULL;
+	}
+	
+void CImageDecodeAo::Bitblt(CWindowGc& aGc, TPoint aPosition)
+	{
+	if (!Bitmap()) return;
+   	aGc.BitBltMasked(aPosition, iBitmap, iBitmap->SizeInPixels(), iMask, EFalse);
+	}
+
+CImageDecodeAo::CImageDecodeAo(CGuiConsAppView& aOwner)
+	: CActive(CActive::EPriorityLow), iOwner(aOwner) 
+	{
+	CActiveScheduler::Add(this);
+	}
+	
+void CImageDecodeAo::ConstructL(const TDesC& aFileName)
+	{
+	User::LeaveIfError(iFs.Connect());
+	User::LeaveIfError(iFs.ShareAuto());
+	TFindFile ff(iFs);
+	User::LeaveIfError(ff.FindByDir(aFileName, KNullDesC));
+	
+	iDecoder = CImageDecoder::FileNewL(iFs, ff.File());
+	iBitmap = new(ELeave)CFbsBitmap;
+	iMask = new(ELeave)CFbsBitmap;
+	User::LeaveIfError(iBitmap->Create(iDecoder->FrameInfo().iOverallSizeInPixels, iDecoder->FrameInfo().iFrameDisplayMode));
+	User::LeaveIfError(iMask->Create(iDecoder->FrameInfo().iOverallSizeInPixels, EGray2));
+	iDecoder->Convert(&iStatus, *iBitmap, *iMask);
+	SetActive();
+	}
+
+void CImageDecodeAo::RunL()
+	{
+	if (iStatus.Int()==0)
+		{
+		iBitmapReady = ETrue;
+		iOwner.BgImageReady();
+		}
+	}
+	
+void CImageDecodeAo::DoCancel()
+	{
+	iDecoder->Cancel();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/src/GuiConsApplication.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,28 @@
+// GuiConsApplication.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "GuiConsDocument.h"
+#include "GuiConsApplication.h"
+#include <fshell/common.mmh>
+
+const TUid KUidGuiConsApp = { FSHELL_UID_S60_GUICONS };
+
+
+CApaDocument* CGuiConsApplication::CreateDocumentL()
+	{
+	return (static_cast<CApaDocument*> ( CGuiConsDocument::NewL( *this ) ) );
+	}
+
+TUid CGuiConsApplication::AppDllUid() const
+	{
+	return KUidGuiConsApp;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/s60/src/GuiConsDocument.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,47 @@
+// GuiConsDocument.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "GuiConsAppUi.h"
+#include "GuiConsDocument.h"
+
+CGuiConsDocument* CGuiConsDocument::NewL(CEikApplication& aApp)
+	{
+	CGuiConsDocument* self = NewLC(aApp);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CGuiConsDocument* CGuiConsDocument::NewLC(CEikApplication& aApp)
+	{
+	CGuiConsDocument* self = new(ELeave)CGuiConsDocument(aApp);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+void CGuiConsDocument::ConstructL()
+	{
+	}
+
+CGuiConsDocument::CGuiConsDocument(CEikApplication& aApp)
+	: CAknDocument(aApp)
+	{
+	}
+
+CGuiConsDocument::~CGuiConsDocument()
+	{
+	}
+
+CEikAppUi* CGuiConsDocument::CreateAppUiL()
+	{
+	return static_cast<CEikAppUi*>(new(ELeave)CGuiConsAppUi);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/src/clientserver.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,121 @@
+// clientserver.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "clientserver.h"
+
+
+_LIT(KDefaultServerName, "guicons");
+
+//______________________________________________________________________________
+// This function prodes the regular console DLL interface; it MUST be the first
+// export.
+EXPORT_C TAny* NewConsole()
+	{
+	return new CGuiConsClient;
+	}
+
+//______________________________________________________________________________
+//						CGuiConsClient
+CGuiConsClient::CGuiConsClient()
+	{
+	}
+	
+TInt CGuiConsClient::Create(const TDesC &aTitle, TSize aSize)
+	{
+	//TODO parse title for server name, font, etc
+	TInt r = iConsole.Connect(KDefaultServerName);
+	if (r==KErrNone)
+		{
+		r = CConsoleProxy::Create(aTitle, aSize);
+		}
+	return r;		
+	}
+
+
+EXPORT_C CServer2* StartGuiConsServerL(const TDesC& aServerName, MConsoleUi& aConsoleUi)
+	{
+	CConsoleProxyServer* server = CGuiConsServer::NewL(aServerName, aConsoleUi);
+	return server;
+	}
+
+//______________________________________________________________________________
+//						CGuiConsServer
+CGuiConsServer* CGuiConsServer::NewL(const TDesC& aServerName, MConsoleUi& aConsoleUi)
+	{
+	CGuiConsServer* self = new(ELeave)CGuiConsServer(aConsoleUi);
+	CleanupStack::PushL(self);
+	self->ConstructL(aServerName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CGuiConsServer::~CGuiConsServer()
+	{
+	}
+	
+void CGuiConsServer::ShutdownTimerExpired()
+	{
+	// we don't want to do anything here, we want the UI app to remain after all consoles have closed.
+	}
+
+CGuiConsServer::CGuiConsServer(MConsoleUi& aConsoleUi)
+	// set the AO priority higher than CCoeRedrawer so that multiple writes from the client only cause
+	// a single redraw of the console, improving performance.
+	: CConsoleProxyServer(NULL, EActivePriorityRedrawEvents+1)
+	, iUi(aConsoleUi)
+	{
+	}
+
+CSession2* CGuiConsServer::NewSessionL(const TVersion&, const RMessage2&) const
+	{
+	return new(ELeave)CGuiConsSession(iUi);
+	}
+
+
+	
+
+//______________________________________________________________________________
+//						CGuiConsSession
+CGuiConsSession::CGuiConsSession(MConsoleUi& aConsoleUi)
+	: CConsoleProxySession((TConsoleCreateFunction)NULL), iUi(aConsoleUi)
+	{
+	}
+
+CGuiConsSession::~CGuiConsSession()
+	{
+	}
+
+MProxiedConsole* CGuiConsSession::InstantiateConsoleL()
+	{
+	CCoeEnv::Static()->RootWin().SetOrdinalPosition(0);
+
+	const TDesC& fontFile(iUi.GetConsoleFont());
+	CConsoleControl* control;
+	if (fontFile.Length())
+		{
+		control = CConsoleControl::NewL(iUi.GetConsoleBufferSize(), fontFile, &iUi);
+		}
+	else
+		{
+		control = CConsoleControl::NewL(iUi.GetConsoleBufferSize(), &iUi);
+		}
+	CleanupStack::PushL(control);
+	MProxiedConsole* result = new(ELeave)CGuiConsole(*control);
+	CleanupStack::Pop(control);
+	return result;
+	}
+	
+void CGuiConsSession::ConsoleCreatedL(MProxiedConsole* aConsole)
+	{
+	iUi.HandleNewConsoleL(&((CGuiConsole*)aConsole)->Control());
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/src/clientserver.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,59 @@
+// clientserver.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#ifndef __CLIENTSERVER_H__
+#define __CLIENTSERVER_H__
+
+#include <e32cons.h>
+#include <fshell/consoleproxy.h>
+#include "guicons.h"
+
+NONSHARABLE_CLASS(CGuiConsClient) : public CConsoleProxy
+	{
+public:
+	CGuiConsClient();
+	
+	virtual TInt Create(const TDesC &aTitle,TSize aSize);
+	};
+	
+NONSHARABLE_CLASS(CGuiConsServer) : public CConsoleProxyServer
+	{
+public:
+	static CGuiConsServer* NewL(const TDesC& aServerName, MConsoleUi& aConsoleUi);
+	
+	virtual void ShutdownTimerExpired();	
+	virtual ~CGuiConsServer();
+private:
+	CGuiConsServer(MConsoleUi& aConsoleUi);
+	// from CConsoleProxyServer:
+	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+private:
+	MConsoleUi& iUi;
+	};
+	
+NONSHARABLE_CLASS(CGuiConsSession)	: public CConsoleProxySession
+	{
+public:
+	CGuiConsSession(MConsoleUi& aConsoleUi);
+	virtual ~CGuiConsSession();
+	
+private: // from CGuiConsSession
+	virtual MProxiedConsole* InstantiateConsoleL();
+	virtual void ConsoleCreatedL(MProxiedConsole* aConsole);
+private:
+	MConsoleUi& iUi;
+	};
+
+
+#endif //__CLIENTSERVER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/guicons/src/guicons.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1858 @@
+// guicons.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include "guicons.h"
+#include <ImageConversion.h>
+#include <e32Math.h>
+
+#include "defaultfontdata.inl"
+
+const TInt KAttributeMapGranularity = 3;
+
+const ConsoleAttributes::TColor KDefaultForegroundColor = ConsoleAttributes::EBlack;
+const ConsoleAttributes::TColor KDefaultBackgroundColor = ConsoleAttributes::EWhite;
+
+
+ConsoleAttributes::TAttributes DefaultAttributes()
+	{
+	return ConsoleAttributes::TAttributes(ConsoleAttributes::ENone, KDefaultForegroundColor, KDefaultBackgroundColor);
+	}
+
+TRgb MapColor(TUint aAttributes, ConsoleAttributes::TColor aColor)
+	{
+	TRgb rgb;
+
+	switch (aColor)
+		{
+		case ConsoleAttributes::EBlack:
+			if (aAttributes & ConsoleAttributes::EBold)
+				{
+				rgb = KRgbGray;
+				}
+			else
+				{
+				rgb = KRgbBlack;
+				}
+			break;
+		case ConsoleAttributes::ERed:
+			if (aAttributes & ConsoleAttributes::EBold)
+				{
+				rgb = KRgbRed;
+				}
+			else
+				{
+				rgb = KRgbDarkRed;
+				}
+			break;
+		case ConsoleAttributes::EGreen:
+			if (aAttributes & ConsoleAttributes::EBold)
+				{
+				rgb = KRgbGreen;
+				}
+			else
+				{
+				rgb = KRgbDarkGreen;
+				}
+			break;
+		case ConsoleAttributes::EYellow:
+			if (aAttributes & ConsoleAttributes::EBold)
+				{
+				rgb = KRgbYellow;
+				}
+			else
+				{
+				rgb = KRgbDarkYellow;
+				}
+			break;
+		case ConsoleAttributes::EBlue:
+			if (aAttributes & ConsoleAttributes::EBold)
+				{
+				rgb = KRgbBlue;
+				}
+			else
+				{
+				rgb = KRgbDarkBlue;
+				}
+			break;
+		case ConsoleAttributes::EMagenta:
+			if (aAttributes & ConsoleAttributes::EBold)
+				{
+				rgb = KRgbMagenta;
+				}
+			else
+				{
+				rgb = KRgbDarkMagenta;
+				}
+			break;
+		case ConsoleAttributes::ECyan:
+			if (aAttributes & ConsoleAttributes::EBold)
+				{
+				rgb = KRgbCyan;
+				}
+			else
+				{
+				rgb = KRgbDarkCyan;
+				}
+			break;
+		case ConsoleAttributes::EWhite:
+			if (aAttributes & ConsoleAttributes::EBold)
+				{
+				rgb = KRgbWhite;
+				}
+			else
+				{
+				rgb = KRgbWhite;//KRgbGray;
+				}
+			break;
+		case ConsoleAttributes::EReset:
+		case ConsoleAttributes::EUnchanged:
+		default:
+			ASSERT(EFalse);
+		}
+
+	if (aAttributes & ConsoleAttributes::EInverse)
+		{
+		rgb = ~rgb;
+		}
+
+	return rgb;
+	}
+
+void SignalSemaphore(TAny* aSemaphore)
+	{
+	((RSemaphore*)aSemaphore)->Signal();
+	}
+
+void CleanupSignalSemaphorePushL(RSemaphore& aSemaphore)
+	{
+	CleanupStack::PushL(TCleanupItem(SignalSemaphore, &aSemaphore));
+	}
+	
+void WaitForRequest(TAny* aStatus)
+	{
+	User::WaitForRequest(*(TRequestStatus*)aStatus);
+	}
+	
+void CleanupWaitForRequestPushL(TRequestStatus& aStatus)
+	{
+	CleanupStack::PushL(TCleanupItem(WaitForRequest, &aStatus));
+	}
+	
+//______________________________________________________________________________
+//						CConsoleControl
+EXPORT_C CConsoleControl* CConsoleControl::NewL(TInt aBufferSize, MConsoleUi* aUi)
+	{
+	CConsoleControl* self = new(ELeave)CConsoleControl(aUi, aBufferSize);
+	CleanupStack::PushL(self);
+	self->ConstructL(CConsoleFont::NewL(KDefaultFontImageData));
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CConsoleControl* CConsoleControl::NewL(TInt aBufferSize, const TDesC& aFontFile, MConsoleUi* aUi)
+	{
+	CConsoleControl* self = new(ELeave)CConsoleControl(aUi, aBufferSize);
+	CleanupStack::PushL(self);
+	self->ConstructL(CConsoleFont::NewL(aFontFile));
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+EXPORT_C CConsoleControl::~CConsoleControl()
+	{
+	delete iBlinkTimer;
+	delete iFont;
+	iCursor.Hide();
+	iBuffer.ResetAndDestroy();
+	iKeyQueue.Close();
+	}
+	
+EXPORT_C void CConsoleControl::Closed()
+	{
+	if (iUi)
+		{
+		iUi->HandleConsoleClosed(this);
+		}
+	}
+
+EXPORT_C void CConsoleControl::Draw(const TRect& aRect) const
+	{
+	CWindowGc& gc = SystemGc();
+	gc.SetBrushStyle(CGraphicsContext::ENullBrush);
+	gc.SetPenStyle(CGraphicsContext::ENullPen);
+	// Need to do a clear here, to ensure we actually draw to all the pixels in aRect that we've been asked to draw. If we don't do that, wserv generally gets upset.
+//	gc.SetBrushColor(KDefaultBackgroundColor);
+//	gc.Clear(aRect);
+	
+	for (TInt y=0; y<iSizeChars.iHeight; ++y)
+		{
+		TViewPosition line(*this, 0, y);
+		if (aRect.Intersects(LineRect(line)))
+			{
+			DrawLine(line, gc);
+			}
+		}
+
+	if (iDrawNavigator)
+		{
+		// And draw the 5-way UI
+#ifdef FSHELL_WSERV2_SUPPORT
+		// XOR draw mode doesn't seem to be supported in recent wserv, so use a colour with alpha channel instead
+		const TRgb col(15, 15, 15, 128);
+		gc.SetDrawMode(CGraphicsContext::EDrawModePEN);
+#else
+		const TRgb col(15,15,15);
+		gc.SetDrawMode(CGraphicsContext::EDrawModeXOR);
+#endif
+		gc.SetBrushColor(col);
+		gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
+		gc.SetPenColor(col);
+		for (TInt i = 0; i < ENumButtons; i++)
+			{
+			if (aRect.Intersects(iButtonRects[i]))
+				{
+				if (i == ECenter)
+					{
+					gc.DrawEllipse(iButtonRects[i]);
+					}
+				else
+					{
+					gc.DrawRect(iButtonRects[i]);
+					}
+				}
+			}
+		}
+	}
+	
+EXPORT_C TCoeInputCapabilities CConsoleControl::InputCapabilities() const
+	{
+	return TCoeInputCapabilities(
+				TCoeInputCapabilities::ENonPredictive 
+			|	TCoeInputCapabilities::EAllText
+			|	TCoeInputCapabilities::ENavigation
+			);
+	}
+	
+EXPORT_C void CConsoleControl::FocusChanged(TDrawNow)
+	{
+	iCursor.Update();
+	if (IsFocused())
+		{
+		StartBlinking();
+		}
+	else
+		{
+		iBlinkTimer->Cancel();
+		}
+	}
+	
+EXPORT_C void CConsoleControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
+	{
+	if (aPointerEvent.iType == TPointerEvent::EButton1Down)
+		{
+		for (TInt i = 0; i < ENumButtons; i++)
+			{
+			if (iButtonRects[i].Contains(aPointerEvent.iPosition))
+				{
+				SimulateKeyL((TButton)i);
+				iIgnoringDrags = ETrue;
+				return;
+				}
+			}
+		iIgnoringDrags = EFalse;
+		}
+
+	if (iIgnoringDrags) return;
+	if (aPointerEvent.iType == TPointerEvent::EButton1Down)
+		{
+		iDragStart = aPointerEvent.iPosition;
+		}
+	if (aPointerEvent.iType == TPointerEvent::EDrag)
+		{
+		TPoint delta = iDragStart - aPointerEvent.iPosition;
+		TInt lines = delta.iY / iFont->GlyphSize().iHeight;
+		if (lines)
+			{
+			iViewWindow.iY += lines;
+			ViewMoved();
+			
+			iDragStart.iY -= (lines * iFont->GlyphSize().iHeight);
+			}
+		}
+	}
+	
+EXPORT_C TKeyResponse CConsoleControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
+	{
+	if ((!IsFocused()) || IsNonFocusing()) return EKeyWasNotConsumed;
+	
+	if (aType == EEventKey)
+		{
+		iKeyQueue.AppendL(aKeyEvent);
+		SendKey();
+		
+#ifdef LOCAL_ECHO
+		TUint code = aKeyEvent.iCode;
+		if (code == '\r') code = '\n';
+		
+		TBuf<0x20> ip;
+		ip.AppendFormat(_L("key %d"), code);
+		User::InfoPrint(ip);
+
+		TBuf<1> buf;
+		buf.Append(TChar(code));
+		Write(buf);
+#endif
+		return EKeyWasConsumed;
+		}
+	return EKeyWasNotConsumed;	
+	}
+	
+EXPORT_C void CConsoleControl::InjectKeysL(const TDesC& aKeys)
+	{
+	for (TInt i=0; i<aKeys.Length(); ++i)
+		{
+		TKeyEvent key;
+		key.iCode = aKeys[i];
+		key.iModifiers = 0;
+		iKeyQueue.AppendL(key);		
+		}
+	SendKey();
+	}
+	
+void CConsoleControl::DrawLine(TViewPosition aLine, CBitmapContext& aDrawTo) const
+	{
+	CConsoleLine* line = GetLine(aLine);
+	if (line)
+		{
+		line->Draw(aDrawTo, aLine);
+		}
+	}
+
+TRect CConsoleControl::LineRect(TViewPosition aLine) const
+	{
+	return TRect(TScreenPosition(aLine).iPoint, TSize(iFont->GlyphSize().iWidth * iSizeChars.iWidth, iFont->GlyphSize().iHeight));
+	}
+
+
+EXPORT_C void CConsoleControl::SizeChanged()
+	{
+	TSize sizePixels = Size();
+	TSize newSizeChars(sizePixels.iWidth / iFont->GlyphSize().iWidth, sizePixels.iHeight / iFont->GlyphSize().iHeight);
+	if (newSizeChars != iSizeChars)
+		{
+		iSizeChars = newSizeChars;
+		TRAP_IGNORE(SizeChangedL());
+		}
+	}
+
+CConsoleControl::CConsoleControl(MConsoleUi* aUi, TInt aBufferSize)
+	: iUi(aUi), iCursor(*this), iCurrentAttributes(ConsoleAttributes::ENone, KDefaultForegroundColor, KDefaultBackgroundColor), iBufferSize(aBufferSize)
+	{
+	}
+
+void CConsoleControl::ConstructL(CConsoleFont* aFont)
+	{
+	iBlinkTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+	iFont = aFont;
+	iCursor.SetFont(*iFont);
+	SetCursorHeight(KDefaultCursorHeightPercentage);
+	}
+
+void CConsoleControl::SizeChangedL()
+	{
+	TInt bufferSize = Max(iBufferSize, iSizeChars.iHeight);
+	for (TInt i=0; i<Min(iBuffer.Count(), bufferSize); ++i)
+		{
+		iBuffer[i]->SetWidthL(iSizeChars.iWidth);
+		}
+	while (iBuffer.Count() < bufferSize)
+		{
+		CConsoleLine* line = CConsoleLine::NewL(*this, *iFont, iSizeChars.iWidth);
+		CleanupStack::PushL(line);
+		iBuffer.AppendL(line);
+		CleanupStack::Pop();
+		}
+	while (iBuffer.Count() > bufferSize)
+		{
+		delete iBuffer[iBuffer.Count()-1];
+		iBuffer.Remove(iBuffer.Count()-1);
+		}
+	iCursor.Update();
+
+	if (FivewayNavIsDisplaying()) SetDisplayFivewayNav(ETrue); // re-layout the onscreen nav if applicable
+	}
+	
+CConsoleLine* CConsoleControl::GetLine(TBufferPosition aLine) const
+	{
+	return iBuffer[aLine.iPoint.iY];
+	}
+	
+TPoint CConsoleControl::ViewPosition() const
+	{
+	return iViewWindow;
+	}
+	
+TPoint CConsoleControl::CursorWindowPosition() const
+	{
+	return iCursorWindow;
+	}
+
+TSize CConsoleControl::GlyphSize() const
+	{
+	return iFont->GlyphSize();
+	}
+	
+TBool CConsoleControl::IsSpecialChar(TChar aChar) const
+	{
+	switch(aChar)
+		{
+		case 0x00:	// Null.
+		case 0x07:	// Bell.
+		case 0x08:	// Backspace.
+		case 0x7f:	// Delete.
+		case 0x09:	// Tab.
+		case 0x0a:	// Line feed.
+		case 0x0b:	// Vertical tab.
+		case 0x0c:	// Form feed.
+		case 0x0d:	// Carriage return.
+			return ETrue;
+		default:
+			return EFalse;
+		}
+	}
+	
+void CConsoleControl::HandleSpecialChar(TChar aChar)
+	{
+	switch(aChar)
+		{
+		case 0x00:	// Null.
+			break;
+		case 0x07:	// Bell.
+			break;
+		case 0x08:	// Backspace.
+		case 0x7f:	// Delete.
+			iCursor--;
+			break;
+		case 0x09:	// horizontal tab
+			iCursor += KTabSize - (iCursor.Position().iPoint.iX % KTabSize);
+			break;
+		case 0x0a:	// line feed
+			iCursor -= iCursor.Position().iPoint.iX;
+			iCursor.Down();
+			break;
+		case 0x0b:	// Vertical tab.
+			break;
+		case 0x0c:  // Form feed
+			ClearScreen();
+			break;
+		case 0x0d:	// carriage return
+			iCursor -= iCursor.Position().iPoint.iX;
+			break;
+		default:
+			User::Invariant();
+		}
+	}
+	
+void CConsoleControl::SendKey()
+	{
+	if (iReader && iKeyQueue.Count())
+		{
+		iCurrentKey = iKeyQueue[0];
+		iKeyQueue.Remove(0);
+		iReader->ReadComplete(KErrNone);
+		iReader = NULL;
+		}
+	}
+	
+EXPORT_C void CConsoleControl::Read(MGuiConsoleReader& aReader)
+	{
+	if (iReader)
+		{
+		aReader.ReadComplete(KErrInUse);
+		}
+	else
+		{
+		iReader = &aReader;
+		SendKey();
+		}
+	}
+	
+EXPORT_C void CConsoleControl::ReadCancel()
+	{
+	iReader = NULL;
+	}
+	
+EXPORT_C void CConsoleControl::Write(const TDesC &aDes)
+	{
+	TRAP_IGNORE(WriteL(aDes));
+	}
+
+void CConsoleControl::WriteL(const TDesC &aDes)
+	{
+	TRect invalidRect;
+	for (TInt i=0; i<aDes.Length(); ++i)
+		{
+		if (IsSpecialChar(aDes[i]))
+			{
+			if (!invalidRect.IsEmpty())
+				{
+				// Draw to the invalid rectangle before handling this special character because it may cause the
+				// window to scroll, thereby invalidating the coordinates of invalidRect.
+				DrawNow(invalidRect);
+				invalidRect = TRect();
+				}
+			HandleSpecialChar(aDes[i]);
+			}
+		else
+			{
+			CConsoleLine* line = GetLine(iCursor.Position());
+			line->SetL(iCursor.Position().iPoint.iX, aDes[i], iCurrentAttributes);
+			TRect lineRect(LineRect(iCursor.Position()));
+			Window().Invalidate(lineRect);
+			if (invalidRect.IsEmpty())
+				{
+				invalidRect = lineRect;
+				}
+			else
+				{
+				invalidRect.BoundingRect(lineRect);
+				}
+			iCursor++;
+			}
+		}
+
+	if (!invalidRect.IsEmpty())
+		{
+		DrawNow(invalidRect);
+		}
+	
+	iCursor.Update();
+	}
+
+void CConsoleControl::StartBlinking()
+	{
+	if (!iBlinkTimer->IsActive())
+		{
+		iBlinkTimer->Start(500000, 500000, TCallBack(BlinkCallback, this));
+		}
+	}
+
+TInt CConsoleControl::BlinkCallback(TAny* aPtr)
+	{
+	CConsoleControl* self = static_cast<CConsoleControl*>(aPtr);
+
+	TBool neededToBlink(EFalse);
+	for (TInt y = 0; y < self->iSizeChars.iHeight; ++y)
+		{
+		TViewPosition line(*self, 0, y);
+		if (self->GetLine(line)->NeedToBlink(self->iBlinkOn))
+			{
+			neededToBlink = ETrue;
+			self->Window().Invalidate(self->LineRect(line));
+			}
+		}
+	if (neededToBlink)
+		{
+		self->iBlinkOn = !self->iBlinkOn;
+		}
+	else
+		{
+		self->iBlinkTimer->Cancel();
+		}
+
+	return KErrNone;
+	}
+	
+EXPORT_C void CConsoleControl::ViewScrollUp()
+	{
+	iViewWindow.iY--;
+	ViewMoved();
+	}
+	
+EXPORT_C void CConsoleControl::ViewScrollDown()
+	{
+	iViewWindow.iY++;
+	ViewMoved();
+	}
+	
+EXPORT_C void CConsoleControl::ViewPageUp()
+	{
+	iViewWindow.iY -= iSizeChars.iHeight-1;
+	ViewMoved();
+	}
+	
+EXPORT_C void CConsoleControl::ViewPageDown()
+	{
+	iViewWindow.iY += iSizeChars.iHeight-1;
+	ViewMoved();
+	}
+	
+EXPORT_C void CConsoleControl::ViewHome()
+	{
+	iViewWindow.iY = 0;
+	ViewMoved();
+	}
+	
+EXPORT_C void CConsoleControl::ViewEnd()
+	{
+	iViewWindow = iCursorWindow;
+	ViewMoved();
+	}
+
+void CConsoleControl::Invalidate5Way()
+	{
+	if (iDrawNavigator)
+		{
+		for (TInt i = 0; i < ENumButtons; i++)
+			{
+			Window().Invalidate(iButtonRects[i]);
+			}
+		}
+	}
+
+EXPORT_C TInt CConsoleControl::SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor)
+	{
+	ConsoleAttributes::TAttributes currentAttributes = iCurrentAttributes;
+
+	if (aAttributes == ConsoleAttributes::ENone)
+		{
+		currentAttributes = DefaultAttributes();
+		}
+	else
+		{
+		currentAttributes.iAttributes = aAttributes;
+		}
+
+	switch (aForegroundColor)
+		{
+		case ConsoleAttributes::EReset:
+			currentAttributes.iForegroundColor = KDefaultForegroundColor;
+			break;
+		case ConsoleAttributes::EUnchanged:
+			// Do nothing.
+			break;
+		default:
+			currentAttributes.iForegroundColor = aForegroundColor;
+			break;
+		}
+
+	switch (aBackgroundColor)
+		{
+		case ConsoleAttributes::EReset:
+			currentAttributes.iBackgroundColor = KDefaultBackgroundColor;
+			break;
+		case ConsoleAttributes::EUnchanged:
+			// Do nothing.
+			break;
+		default:
+			currentAttributes.iBackgroundColor = aBackgroundColor;
+			break;
+		}
+
+	TRAPD(err, iFont->PrepareForegroundColorL(MapColor(currentAttributes.iAttributes, currentAttributes.iForegroundColor)));
+	if (err == KErrNone)
+		{
+		iCurrentAttributes = currentAttributes;
+		}
+
+	return err;
+	}
+	
+void CConsoleControl::ViewMoved()
+	{
+	if (iViewWindow.iY < 0) iViewWindow.iY = 0;
+	if (iViewWindow.iY + iSizeChars.iHeight > iBuffer.Count()) iViewWindow.iY = iBuffer.Count() - iSizeChars.iHeight;
+	Window().Invalidate();
+	}
+
+void CConsoleControl::CursorWindowScrollDown()
+	{
+	TBool viewWindowMatchesCursorWindow = (iViewWindow.iY == iCursorWindow.iY);
+	iCursorWindow.iY++;
+	if (iCursorWindow.iY + iSizeChars.iHeight > iBuffer.Count())
+		{
+		iCursorWindow.iY--;
+		CConsoleLine* topLine = iBuffer[0];
+		iBuffer.Remove(0);
+		topLine->Clear();
+		iBuffer.Append(topLine);
+		
+		// JB - Disabled the code below because it forces a full redraw of the window which seems
+		// unnecessary, particularly now that this function trys to efficiently scroll using
+		// RDrawableWindow::Scroll. Note though that I can't claim to fully understand this code,
+		// so this may be a dumb thing to do. Original comment follows...
+		// move this up so that the text in the view window moves up with the scrolling text.
+		// ViewScrollUp();
+		}
+	
+	if (viewWindowMatchesCursorWindow) // keep them in sync if they were when we started
+		{
+		iViewWindow.iY = iCursorWindow.iY;
+		}
+
+#ifndef FSHELL_WSERV2_SUPPORT
+	// On wserv1 we can't use Scroll if we're showing the 5-way nav - it looks bad
+	if (iDrawNavigator)
+		{
+		DrawDeferred();
+		}
+	else
+#endif
+		{
+		// on wserv2, or wserv1 when the 5-way nav isn't displayed, we can use RWindow::Scroll for better performance (although, performance only seems to be a problem on wserv1 with a wide screen. On wserv2 probably just a DrawDeferred() would be sufficient)
+		Invalidate5Way();
+		Window().Scroll(Rect(), TPoint(0, -(iFont->GlyphSize().iHeight)));
+		Invalidate5Way();
+		TRect invalidRect(LineRect(TViewPosition(*this, 0, iSizeChars.iHeight - 1)));
+		Window().Invalidate(invalidRect);
+		}
+	}
+	
+EXPORT_C TPoint CConsoleControl::CursorPos() const
+	{
+	return iCursor.Position().iPoint;
+	}
+	
+EXPORT_C void CConsoleControl::SetCursorPosAbs(const TPoint &aPoint)
+	{
+	iCursor.SetPosAbs(TConsCursorPosition(*this, aPoint));
+	iCursor.Update();
+	}
+	
+EXPORT_C void CConsoleControl::SetCursorPosRel(const TPoint &aPoint)
+	{
+	iCursor.SetPosRel(TConsCursorPosition(*this, aPoint));
+	iCursor.Update();
+	}
+	
+EXPORT_C void CConsoleControl::SetCursorHeight(TInt aPercentage)
+	{
+	iCursor.SetHeight(aPercentage);
+	iCursor.Update();
+	}
+	
+EXPORT_C void CConsoleControl::SetTitle(const TDesC &aTitle)
+	{
+	if (iUi)
+		{
+		TRAP_IGNORE(iUi->ConsoleTitleChangedL(this, aTitle));
+		}
+	}
+	
+EXPORT_C void CConsoleControl::ClearScreen()
+	{
+	Window().Invalidate();
+	for (TInt y=0; y<iBuffer.Count(); ++y)
+		{
+		iBuffer[y]->Clear();
+		}
+	iCursorWindow.iY = 0;
+	iViewWindow.iY = 0;
+	iCursor.SetPosAbs(TConsCursorPosition(*this, 0,0));
+	iCurrentAttributes = DefaultAttributes();
+	}
+	
+EXPORT_C void CConsoleControl::ClearToEndOfLine()
+	{
+	GetLine(iCursor.Position())->ClearFrom(iCursor.Position());
+	Window().Invalidate(LineRect(iCursor.Position()));
+	}
+	
+EXPORT_C TSize CConsoleControl::ScreenSize() const
+	{
+	return iSizeChars;
+	}
+	
+EXPORT_C TKeyCode CConsoleControl::KeyCode() const
+	{
+	return (TKeyCode)iCurrentKey.iCode;
+	}
+	
+EXPORT_C TUint CConsoleControl::KeyModifiers() const
+	{
+	return iCurrentKey.iModifiers;
+	}
+
+void CConsoleControl::SimulateKeyL(TButton aButton)
+	{
+	TKeyEvent key;
+	key.iRepeats = 0;
+	key.iModifiers = 0;
+	switch (aButton)
+		{
+		case EUp:
+			key.iCode = EKeyUpArrow;
+			key.iScanCode = EStdKeyUpArrow;
+			break;
+		case EDown:
+			key.iCode = EKeyDownArrow;
+			key.iScanCode = EStdKeyDownArrow;
+			break;
+		case ELeft:
+			key.iCode = EKeyLeftArrow;
+			key.iScanCode = EStdKeyLeftArrow;
+			break;
+		case ERight:
+			key.iCode = EKeyRightArrow;
+			key.iScanCode = EStdKeyRightArrow;
+			break;
+		case ECenter:
+			key.iCode = EKeyEnter;
+			key.iScanCode = EStdKeyEnter;
+			break;
+		default:
+			return;
+		}
+	iCoeEnv->SimulateKeyEventL(key, EEventKey);
+	}
+
+EXPORT_C TBool CConsoleControl::FivewayNavIsDisplaying() const
+	{
+	return iButtonRects[ECenter].Width();
+	}
+
+EXPORT_C void CConsoleControl::SetDisplayFivewayNav(TBool aShow)
+	{
+	if (aShow)
+		{
+		TRect rect(Rect());
+		TInt shortLen = Min(rect.Width(), rect.Height()); // Look nicer in landscape
+		TSize buttonSize(shortLen / 4, shortLen / 4);
+		TRect center(TPoint(rect.Width()/2 - buttonSize.iWidth/2, rect.Height() - 2*buttonSize.iHeight), buttonSize);
+		iButtonRects[ECenter] = center;
+		iButtonRects[ECenter].Shrink(5, 5);
+		iButtonRects[ELeft] = center; iButtonRects[ELeft].Move(-buttonSize.iWidth, 0);
+		iButtonRects[ERight] = center; iButtonRects[ERight].Move(buttonSize.iWidth, 0);
+		iButtonRects[EUp] = center; iButtonRects[EUp].Move(0, -buttonSize.iHeight);
+		iButtonRects[EDown] = center; iButtonRects[EDown].Move(0, buttonSize.iHeight);
+		iDrawNavigator = ETrue;
+		}
+	else
+		{
+		Mem::FillZ(iButtonRects, sizeof(iButtonRects));
+		}
+	DrawDeferred();
+	}
+
+void CConsoleControl::ActivateL()
+	{
+	Window().SetBackgroundColor(KRgbWhite);
+	CCoeControl::ActivateL();
+	}
+
+//______________________________________________________________________________
+//						Image loader thread
+// We use ICl to decode the font image. Despite ICL having the ability to create
+// a thread of it own to do the decoding, when we decode from a descriptor
+// (instead of a file), it still requires a AO RunL's in out thread to operate.
+// So, we have to create a new thread manually so that we can always load images
+// synchronously.
+
+class RImageDecodeThreadParams
+	{
+public:
+	RImageDecodeThreadParams(const TDesC& aFileName)
+		: iMode(EDecodeFile), iFileName(aFileName), iData(KNullDesC8), iBitmapHandle(KNullHandle) {}
+	RImageDecodeThreadParams(const TDesC8& aImageData)
+		: iMode(EDecodeData), iFileName(KNullDesC), iData(aImageData), iBitmapHandle(KNullHandle) {}
+	TInt Open()
+		{
+		TInt err = iBitmapReadySemaphore.CreateLocal(0);
+		if (err==KErrNone) err = iThreadExitSemaphore.CreateLocal(0);
+		if (err!=KErrNone) Close();
+		return err;
+		}
+	void Close()
+		{
+		iBitmapReadySemaphore.Close();
+		iThreadExitSemaphore.Close();
+		}
+public:
+	enum
+		{
+		EDecodeFile,
+		EDecodeData,
+		} iMode;
+	const TPtrC iFileName;
+	const TPtrC8 iData;
+	TFrameInfo iFrameInfo;
+	TInt iBitmapHandle;
+	RSemaphore iBitmapReadySemaphore;
+	RSemaphore iThreadExitSemaphore;
+	TInt iThreadError;
+	};
+	
+class CImageDecodeWaiter : public CActive
+	{
+public:
+	CImageDecodeWaiter(TInt aPriority)
+		: CActive(aPriority)
+		{
+		CActiveScheduler::Add(this);
+		}
+	void Start(CImageDecoder* aDecoder, CFbsBitmap* aBitmap)
+		{
+		TRequestStatus* stat = &iStatus;
+		aDecoder->Convert(stat, *aBitmap);
+		SetActive();
+		CActiveScheduler::Start();
+		}
+	virtual void RunL()
+		{
+		iCompletionErr = iStatus.Int();
+		CActiveScheduler::Stop();
+		}
+	virtual void DoCancel() {}
+public:
+	TInt iCompletionErr;
+	};
+
+void ImageDecodeThreadL(RImageDecodeThreadParams& aParams)
+	{
+	User::LeaveIfError(RFbsSession::Connect());
+	
+	CActiveScheduler* as = new(ELeave)CActiveScheduler;
+	CActiveScheduler::Install(as);
+	CleanupStack::PushL(as);
+	
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+	User::LeaveIfError(fs.ShareAuto());
+
+	CImageDecoder* dec = NULL;
+	switch (aParams.iMode)
+		{
+	case RImageDecodeThreadParams::EDecodeFile:
+		dec = CImageDecoder::FileNewL(fs, aParams.iFileName);
+		break;
+	case RImageDecodeThreadParams::EDecodeData:
+		dec = CImageDecoder::DataNewL(fs, aParams.iData);
+		break;
+		}
+	CleanupStack::PushL(dec);
+	
+	aParams.iFrameInfo = dec->FrameInfo();
+	CFbsBitmap* bmp = new(ELeave)CFbsBitmap;
+	CleanupStack::PushL(bmp);
+	User::LeaveIfError(bmp->Create(aParams.iFrameInfo.iOverallSizeInPixels, aParams.iFrameInfo.iFrameDisplayMode));
+	
+	
+	CImageDecodeWaiter* waiter = new(ELeave)CImageDecodeWaiter(CActive::EPriorityStandard);
+	CleanupStack::PushL(waiter);
+	
+	waiter->Start(dec, bmp);
+	User::LeaveIfError(waiter->iCompletionErr);
+	
+	aParams.iBitmapHandle = bmp->Handle();
+	aParams.iThreadError = KErrNone;
+	aParams.iBitmapReadySemaphore.Signal();
+	aParams.iThreadExitSemaphore.Wait();
+	
+	CleanupStack::PopAndDestroy(5, as); // as, fs, dec, bmp, waiter
+	}
+
+TInt ImageDecodeThead(TAny* aParams)
+	{
+	User::SetCritical(User::EProcessCritical);
+	__UHEAP_MARK;
+	RImageDecodeThreadParams* params = (RImageDecodeThreadParams*)aParams;
+
+	CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack
+	if (!cleanup) return KErrNoMemory;
+	TRAPD(err, ImageDecodeThreadL(*params));
+	params->iThreadError = err;
+	if (err!=KErrNone)
+		{
+		params->iBitmapReadySemaphore.Signal();
+		}
+
+	delete cleanup;
+	REComSession::FinalClose();
+	RFbsSession::Disconnect();
+	__UHEAP_MARKEND;
+	User::SetCritical(User::ENotCritical);
+	return err;	
+	}
+
+//______________________________________________________________________________
+//						CConsoleFont
+EXPORT_C CConsoleFont* CConsoleFont::NewL(const TDesC& aFontFile)
+	{
+	CConsoleFont* self = new(ELeave)CConsoleFont;
+	CleanupStack::PushL(self);
+	self->ConstructL(aFontFile);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+EXPORT_C CConsoleFont* CConsoleFont::NewL(const TDesC8& aEncodedFontImage)
+	{
+	CConsoleFont* self = new(ELeave)CConsoleFont;
+	CleanupStack::PushL(self);
+	self->ConstructL(aEncodedFontImage);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+EXPORT_C CConsoleFont::~CConsoleFont()
+	{
+	for (TInt i = 0; i < KNumGlyphs; ++i)
+		{
+		delete iChars[i];
+		}
+	for (TInt i = 0; i < KNumColors; ++i)
+		{
+		delete iColors[i];
+		}
+	}
+
+EXPORT_C TSize CConsoleFont::GlyphSize() const
+	{
+	return iGlyphRect.Size();
+	}
+
+
+EXPORT_C void CConsoleFont::DrawChar(TChar aChar, CBitmapContext& aDrawTo, TPoint aPosPixels, TRgb aColor)
+	{
+	// Note, this method assumes that the glyph's background has already been set to the appropriate color.
+
+	if ((aChar < KFontBitmapFirstCharCode) || (aChar > KFontBitmapLastCharCode))
+		{
+		aChar = KFontBitmapLastCharCode;
+		}
+	
+	aDrawTo.BitBltMasked(aPosPixels, ForegroundBitmap(aColor), iGlyphRect, iChars[(TInt)aChar - KFontBitmapFirstCharCode], ETrue);
+	}
+
+CConsoleFont::CConsoleFont()
+	{
+	}
+
+void CConsoleFont::ConstructL(const TDesC& aFontFile)
+	{
+	RImageDecodeThreadParams decodeParams(aFontFile);
+	ConstructL(decodeParams);
+	}
+
+void CConsoleFont::ConstructL(const TDesC8& aEncodedFontImage)
+	{
+	RImageDecodeThreadParams decodeParams(aEncodedFontImage);
+	ConstructL(decodeParams);
+	}
+
+_LIT(KImageDecodeThreadNameFmt, "ImageDecodeThread%08x");
+
+void CConsoleFont::ConstructL(RImageDecodeThreadParams& aDecodeParams)
+	{
+	User::LeaveIfError(aDecodeParams.Open());
+	CleanupClosePushL(aDecodeParams);
+	RThread decodeThread;
+	CleanupClosePushL(decodeThread);
+	// kick off the sub thread doing the decoding
+	TInt err;
+	TInt seq = 0;
+	do
+		{
+		TBuf<0x20> threadName;
+		threadName.AppendFormat(KImageDecodeThreadNameFmt, seq);
+		err = decodeThread.Create(threadName, ImageDecodeThead, KDefaultStackSize, 0x1000, 0x200000, &aDecodeParams);
+		seq++;
+		} while (err==KErrAlreadyExists);
+	User::LeaveIfError(err);
+	decodeThread.Resume();
+
+	TRequestStatus threadExit;
+	decodeThread.Logon(threadExit);
+
+	CleanupWaitForRequestPushL(threadExit); // things will probably go wrong if we leave on this line
+	CleanupSignalSemaphorePushL(aDecodeParams.iThreadExitSemaphore);
+	
+	/*
+	Now, on the cleanup stack we have:
+	1. iThreadExitSemaphore.Signal()
+	2. WaitForRequest(threadExit)
+	3. decodeThread
+	4. aDecodeParams
+	
+	So, if we leave now:
+	1. We will signal the sub thread to exit
+	2. We will then wait for the sub thread to exit
+	3. close the sub thread handle
+	4. close aDecodeParams, which will destroy the semaphores
+	
+	Note, it's important that we wait for the thread to exit before the cleanup stack
+	if fully unwound, as if we destroy the semaphores before the sub thread has exitted,
+	then it will panic with KERN-EXEC 0.
+	*/
+	
+	// wait for it to decode the bitmap (or die)
+	aDecodeParams.iBitmapReadySemaphore.Wait();
+	User::LeaveIfError(aDecodeParams.iThreadError); // we will leave here if there was an error in the subthread
+	
+	// process decoded image
+	TSize bmpSize = aDecodeParams.iFrameInfo.iOverallSizeInPixels;
+	if (bmpSize.iWidth % KFontBitmapWidthChars) User::Leave(KErrCorrupt);// better error code / panic?
+	if (bmpSize.iHeight % KFontBitmapHeightChars) User::Leave(KErrCorrupt);// better error code / panic?
+	iGlyphRect = TRect(TPoint(0, 0), TSize(bmpSize.iWidth / KFontBitmapWidthChars, bmpSize.iHeight / KFontBitmapHeightChars));
+	
+	CFbsBitmap* allChars = new(ELeave)CFbsBitmap();
+	CleanupStack::PushL(allChars);
+	User::LeaveIfError(allChars->Duplicate(aDecodeParams.iBitmapHandle));
+
+	for (TInt i = 0; i < KNumGlyphs; ++i)
+		{
+		iChars[i] = new(ELeave)CFbsBitmap;
+		User::LeaveIfError(iChars[i]->Create(iGlyphRect.Size(), EGray2));
+
+		CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(iChars[i]);
+		CleanupStack::PushL(bitmapDevice);
+	
+		CBitmapContext* bitmapContext;
+		User::LeaveIfError(bitmapDevice->CreateBitmapContext(bitmapContext));
+		CleanupStack::PushL(bitmapContext);
+
+		TPoint charPos(i % KFontBitmapWidthChars, i / KFontBitmapWidthChars);
+		TPoint pixelPos(charPos.iX * iGlyphRect.Size().iWidth, charPos.iY * iGlyphRect.Size().iHeight);
+		TRect charRect(pixelPos, iGlyphRect.Size());
+		bitmapContext->BitBlt(TPoint(0, 0), allChars, charRect);	
+
+		CleanupStack::PopAndDestroy(2, bitmapDevice);
+		}
+
+	// this will clean everything up - see above comment.
+	CleanupStack::PopAndDestroy(5, &aDecodeParams); // decodeThread, aDecodeParams
+
+	PrepareForegroundColorL(KDefaultForegroundColor);
+	}
+
+void CConsoleFont::PrepareForegroundColorL(TRgb aColor)
+	{
+	CFbsBitmap* bitmap = ForegroundBitmap(aColor);
+	if (bitmap == NULL)
+		{
+		bitmap = new(ELeave)CFbsBitmap;
+		CleanupStack::PushL(bitmap);
+		User::LeaveIfError(bitmap->Create(iGlyphRect.Size(), EColor16));
+		CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
+		CleanupStack::PushL(bitmapDevice);
+		CBitmapContext* bitmapContext;
+		User::LeaveIfError(bitmapDevice->CreateBitmapContext(bitmapContext));
+		CleanupStack::PushL(bitmapContext);
+		bitmapContext->SetBrushColor(aColor);
+		bitmapContext->SetPenStyle(CGraphicsContext::ENullPen);
+		bitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
+		bitmapContext->DrawRect(iGlyphRect);
+		CleanupStack::PopAndDestroy(2, bitmapDevice);
+		CleanupStack::Pop(bitmap);
+		iColors[aColor.Color16()] = bitmap;
+		}
+	}
+
+CFbsBitmap* CConsoleFont::ForegroundBitmap(TRgb aColor)
+	{
+	return iColors[aColor.Color16()];
+	}
+
+//______________________________________________________________________________
+//						CConsoleLine
+CConsoleLine* CConsoleLine::NewL(CConsoleControl& aControl, const CConsoleFont& aFont, TInt aWidth)
+	{
+	CConsoleLine* self = new(ELeave)CConsoleLine(aControl, aFont);
+	CleanupStack::PushL(self);
+	self->ConstructL(aWidth);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CConsoleLine::~CConsoleLine()
+	{
+	iText.Close();
+	iAttributeMap.Close();
+	}
+
+void CConsoleLine::SetWidthL(TInt aNewWidth)
+	{
+	if (aNewWidth != iWidth)
+		{
+		RBuf8 newText;
+		newText.CreateL(aNewWidth);
+		newText.Copy(iText.Left(aNewWidth));
+		newText.Swap(iText);
+		newText.Close();
+		iWidth = aNewWidth;
+		iAttributeMap.RemoveFrom(aNewWidth);
+		}
+	}
+
+void CConsoleLine::SetL(TInt aIndex, TUint8 aChar, const ConsoleAttributes::TAttributes& aAttributes)
+	{
+	__ASSERT_ALWAYS((aIndex < iWidth)&&(aIndex>=0), User::Invariant());
+	iAttributeMap.AddL(aIndex, iWidth, aAttributes);
+	if (aIndex > iText.Length())
+		{
+		TInt oldLen = iText.Length();
+		iText.SetLength(aIndex);
+		iText.MidTPtr(oldLen).Fill(' ');
+		iText.Append(aChar);
+		}
+	else if (aIndex == iText.Length())
+		{
+		iText.Append(aChar);
+		}
+	else
+		{
+		iText[aIndex] = aChar;
+		}
+	}
+	
+void CConsoleLine::Clear()
+	{
+	iAttributeMap.Reset();
+	iText.Zero();
+	}
+	
+void CConsoleLine::ClearFrom(TBufferPosition aPos)
+	{
+	TInt pos = Min(aPos.iPoint.iX, iText.Length());
+	iText.SetLength(pos);
+	iAttributeMap.RemoveFrom(pos);
+	}
+
+void CConsoleLine::Draw(CBitmapContext& aDrawTo, TViewPosition aViewPosition) const
+	{
+	const TSize glyphSize(iFont.GlyphSize());
+
+	TScreenPosition screenPos(aViewPosition);
+	TRect rectToClear(screenPos.iPoint, TScreenPosition(aViewPosition.iConsole, 0, (aViewPosition.iPoint.iY + 1) * glyphSize.iHeight).iPoint);
+
+	const TInt numAttributeBlocks = iAttributeMap.NumberOfBlocks();
+	for (TInt i = 0; i < numAttributeBlocks; ++i)
+		{
+		TInt startXPos = 0;
+		TInt endXPos = 0;
+		ConsoleAttributes::TAttributes attributes(ConsoleAttributes::ENone);
+		iAttributeMap.GetBlock(i, iWidth, startXPos, endXPos, attributes);
+
+		// Draw the background in the appropriate color in one hit.
+		rectToClear.iTl.iX = screenPos.iPoint.iX + (startXPos * glyphSize.iWidth);
+		rectToClear.iBr.iX = screenPos.iPoint.iX + (endXPos * glyphSize.iWidth);
+		TRgb backgroundColor = MapColor(attributes.iAttributes, attributes.iBackgroundColor);
+		aDrawTo.SetBrushColor(backgroundColor);
+		aDrawTo.Clear(rectToClear);
+
+		// Check if we're blinking.
+		TRgb foregroundColor = MapColor(attributes.iAttributes, attributes.iForegroundColor);
+		if ((attributes.iAttributes & ConsoleAttributes::EBlink) && iBlinkOn)
+			{
+			foregroundColor = backgroundColor;
+			}
+
+		// Draw any non-white-space characters in the appropriate foreground color.
+		for (TInt i = startXPos; i < endXPos; ++i)
+			{
+			TUint16 c = At(i);
+			if (c != ' ')
+				{
+				const_cast<CConsoleFont&>(iFont).DrawChar(c, aDrawTo, TPoint(screenPos.iPoint.iX + (i * glyphSize.iWidth), screenPos.iPoint.iY), foregroundColor);
+				}
+			if (attributes.iAttributes & ConsoleAttributes::EUnderscore)
+				{
+				const_cast<CConsoleFont&>(iFont).DrawChar('_', aDrawTo, TPoint(screenPos.iPoint.iX + (i * glyphSize.iWidth), screenPos.iPoint.iY), foregroundColor);
+				}
+			}
+
+		if (attributes.iAttributes & ConsoleAttributes::EBlink)
+			{
+			iControl.StartBlinking();
+			}
+		}
+	}
+
+TBool CConsoleLine::NeedToBlink(TBool aBlinkOn)
+	{
+	TBool needToBlink(EFalse);
+	const TInt numAttributeBlocks = iAttributeMap.NumberOfBlocks();
+	for (TInt i = 0; i < numAttributeBlocks; ++i)
+		{
+		TInt startXPos = 0;
+		TInt endXPos = 0;
+		ConsoleAttributes::TAttributes attributes(ConsoleAttributes::ENone);
+		iAttributeMap.GetBlock(i, iWidth, startXPos, endXPos, attributes);
+		if (attributes.iAttributes & ConsoleAttributes::EBlink)
+			{
+			needToBlink = ETrue;
+			iBlinkOn = aBlinkOn;
+			break;
+			}
+		}
+	return needToBlink;
+	}
+	
+TUint16 CConsoleLine::At(TInt aPos) const
+	{
+	__ASSERT_ALWAYS((aPos < iWidth)&&(aPos>=0), User::Invariant());
+	if (aPos < iText.Length())
+		{
+		return iText[aPos];
+		}
+	else
+		{
+		return ' ';
+		}
+	}
+	
+CConsoleLine::CConsoleLine(CConsoleControl& aControl, const CConsoleFont& aFont)
+	: iControl(aControl), iFont(aFont)
+	{
+	}
+	
+void CConsoleLine::ConstructL(TInt aWidth)
+	{
+	iText.CreateL(aWidth);
+	iWidth = aWidth;
+	}
+
+//______________________________________________________________________________
+//						TConsoleCursor
+TConsoleCursor::TConsoleCursor(CConsoleControl& aOwner)
+	: iOwner(aOwner)
+	{
+	iTextCursor.iType = TTextCursor::ETypeRectangle;
+	iTextCursor.iAscent = 0;
+	iTextCursor.iColor = KRgbWhite;
+	}
+
+void TConsoleCursor::SetFont(const CConsoleFont& aFont)
+	{
+	iGlyphSize = aFont.GlyphSize();
+	iTextCursor.iWidth = iGlyphSize.iWidth;
+	}
+
+TConsCursorPosition TConsoleCursor::Position() const
+	{
+	return TConsCursorPosition(iOwner, iPosition);
+	}
+
+void TConsoleCursor::SetPosAbs(TConsCursorPosition aPos)
+	{
+	iPosition = aPos.iPoint;
+	BoundsCheck();
+	}
+
+void TConsoleCursor::SetPosRel(TConsCursorPosition aPos)
+	{
+	iPosition += aPos.iPoint;
+	BoundsCheck();
+	}
+
+void TConsoleCursor::SetHeight(TInt aPercentage)
+	{
+	aPercentage = Max(0, Min(100, aPercentage));
+	TReal height = ((TReal)iGlyphSize.iHeight * (TReal)aPercentage) / 100.0;
+	TReal roundedHeight;
+	Math::Round(roundedHeight, height, 0);
+	iTextCursor.iHeight = (TInt)roundedHeight;
+	// make sure the cursor is always visible if the percentage is non-zero.
+	if ((iTextCursor.iHeight==0) && (aPercentage!=0)) iTextCursor.iHeight = 1;
+	iTextCursor.iAscent = 0;
+	iTextCursorOffset = iGlyphSize.iHeight - iTextCursor.iHeight;
+	}
+
+void TConsoleCursor::Update()
+	{
+	if (iOwner.IsFocused() && !iOwner.IsNonFocusing())
+		{
+		TViewPosition viewPos = Position();
+		TPoint cursorPosPixels;
+		cursorPosPixels.iX = viewPos.iPoint.iX * iGlyphSize.iWidth;
+		cursorPosPixels.iY = ((viewPos.iPoint.iY) * iGlyphSize.iHeight) + iTextCursorOffset;
+		/*if (iOwner.Rect().Contains(cursorPosPixels))
+			{*/
+			if (iOwner.DrawableWindow())
+				{
+				CCoeEnv::Static()->RootWin().SetTextCursor(*iOwner.DrawableWindow(), cursorPosPixels, iTextCursor);
+				}
+		/*	}
+		else
+			{
+			Hide();
+			}*/
+		}
+	}
+	
+void TConsoleCursor::Hide()
+	{
+	CCoeEnv::Static()->RootWin().CancelTextCursor();
+	}
+
+void TConsoleCursor::BoundsCheck()
+	{
+	iPosition.iX = Max(0, iPosition.iX);
+	iPosition.iY = Max(0, iPosition.iY);
+	iPosition.iX = Min(iOwner.ScreenSize().iWidth-1, iPosition.iX);
+	iPosition.iY = Min(iOwner.ScreenSize().iHeight-1, iPosition.iY);
+	}
+
+void TConsoleCursor::operator++(int)
+	{
+	(*this)+=1;
+	}
+	
+void TConsoleCursor::operator--(int)
+	{
+	(*this)-=1;
+	}
+	
+void TConsoleCursor::operator+=(TUint aHowMuch)
+	{
+	TSize consSize(iOwner.ScreenSize());
+	while (aHowMuch)
+		{
+		TInt len = Min(consSize.iWidth - iPosition.iX, aHowMuch);
+		iPosition.iX += len;
+		aHowMuch -= len;
+
+		if (iPosition.iX == consSize.iWidth)
+			{
+			Down();
+			iPosition.iX = 0;
+			}
+		}
+	}
+	
+void TConsoleCursor::operator-=(TUint aHowMuch)
+	{
+	TSize consSize(iOwner.ScreenSize());
+	while (aHowMuch)
+		{
+		if (iPosition.iX == 0)
+			{
+			Up();
+			iPosition.iX = consSize.iWidth;
+			}
+
+		TInt len = Min(iPosition.iX, aHowMuch);
+		iPosition.iX -= len;
+		aHowMuch -= len;
+		}
+	
+	}
+	
+void TConsoleCursor::Down()
+	{
+	iPosition.iY++;
+	if (iPosition.iY >= iOwner.ScreenSize().iHeight)
+		{
+		iPosition.iY--;
+		iOwner.CursorWindowScrollDown();
+		}
+	}
+
+void TConsoleCursor::Up()
+	{
+	iPosition.iY--;
+	BoundsCheck();
+	}
+
+//______________________________________________________________________________
+//						CGuiConsole
+EXPORT_C CGuiConsole::CGuiConsole(CConsoleControl& aControl)
+	: iControl(aControl), iRefCount(1)
+	{
+	}
+	
+EXPORT_C CConsoleControl& CGuiConsole::Control()
+	{
+	return iControl;
+	}
+
+EXPORT_C TInt CGuiConsole::Create(const TDesC &aTitle, TSize)
+	{
+	iControl.SetTitle(aTitle);
+	return KErrNone;
+	}
+
+EXPORT_C void CGuiConsole::Read(TRequestStatus &aStatus)
+	{
+	if (iReadStatus || iReader)
+		{
+		TRequestStatus* stat = &aStatus;
+		User::RequestComplete(stat, KErrInUse);
+		}
+	else
+		{
+		iReadStatus = &aStatus;
+		iControl.Read(*this);
+		}
+	}
+
+EXPORT_C void CGuiConsole::ReadCancel()
+	{
+	if (iReadStatus)
+		{
+		User::RequestComplete(iReadStatus, KErrCancel);
+		iControl.ReadCancel();
+		}
+	else if (iReader)
+		{
+		iReader->ReadComplete(KErrCancel);
+		iReader = NULL;
+		iControl.ReadCancel();
+		}
+	}
+
+EXPORT_C void CGuiConsole::Write(const TDesC &aDes)
+	{
+	iControl.Write(aDes);
+	}
+
+EXPORT_C TPoint CGuiConsole::CursorPos() const
+	{
+	return iControl.CursorPos();
+	}
+
+EXPORT_C void CGuiConsole::SetCursorPosAbs(const TPoint &aPoint)
+	{
+	iControl.SetCursorPosAbs(aPoint);
+	}
+
+EXPORT_C void CGuiConsole::SetCursorPosRel(const TPoint &aPoint)
+	{
+	iControl.SetCursorPosRel(aPoint);
+	}
+
+EXPORT_C void CGuiConsole::SetCursorHeight(TInt aPercentage)
+	{
+	iControl.SetCursorHeight(aPercentage);
+	}
+
+EXPORT_C void CGuiConsole::SetTitle(const TDesC &aTitle)
+	{
+	iControl.SetTitle(aTitle);
+	}
+
+EXPORT_C void CGuiConsole::ClearScreen()
+	{
+	iControl.ClearScreen();
+	}
+
+EXPORT_C void CGuiConsole::ClearToEndOfLine()
+	{
+	iControl.ClearToEndOfLine();
+	}
+
+EXPORT_C TSize CGuiConsole::ScreenSize() const
+	{
+	return iControl.ScreenSize();
+	}
+
+
+EXPORT_C TKeyCode CGuiConsole::KeyCode() const
+	{
+	return iControl.KeyCode();
+	}
+
+
+EXPORT_C TUint CGuiConsole::KeyModifiers() const
+	{
+	return iControl.KeyModifiers();
+	}
+
+EXPORT_C TInt CGuiConsole::Extension_(TUint aExtensionId, TAny*&, TAny* a1)
+	{
+	if (aExtensionId == ConsoleAttributes::KSetConsoleAttributesExtension)
+		{
+		ConsoleAttributes::TAttributes* attributes = (ConsoleAttributes::TAttributes*)a1;
+		return iControl.SetAttributes(attributes->iAttributes, attributes->iForegroundColor, attributes->iBackgroundColor);
+		}
+	return KErrNotSupported;
+	}
+
+void CGuiConsole::ReadComplete(TInt aStatus)
+	{
+	if (iReadStatus)
+		{
+		User::RequestComplete(iReadStatus, aStatus);
+		}
+	if (iReader)
+		{
+		CConsoleProxySession* reader = iReader;
+		iReader = NULL;
+		reader->ReadComplete(aStatus);
+		}
+	}
+	
+void CGuiConsole::Open()
+	{
+	++iRefCount;
+	}
+
+void CGuiConsole::Close()
+	{
+	--iRefCount;
+	if (iRefCount==0)
+		{
+		delete this;
+		}
+	}
+
+CConsoleBase* CGuiConsole::Console()
+	{
+	return this;
+	}
+
+void CGuiConsole::Read(CConsoleProxySession& aSession)
+	{
+	if (iReader || iReadStatus)
+		{
+		aSession.ReadComplete(KErrInUse);
+		}
+	else
+		{
+		iReader = &aSession;
+		iControl.Read(*this);
+		}
+	}
+
+CGuiConsole::~CGuiConsole()
+	{
+	iControl.Closed();
+	}
+
+//______________________________________________________________________________
+//						TBufferPosition
+TBufferPosition::TBufferPosition(const CConsoleControl& aConsole, TPoint aPosition)
+	: iConsole(aConsole), iPoint(aPosition)
+	{
+	}
+
+TBufferPosition::TBufferPosition(const CConsoleControl& aConsole, TInt aX, TInt aY)
+	: iConsole(aConsole), iPoint(aX, aY)
+	{
+	}
+
+TBufferPosition::TBufferPosition(const TConsCursorPosition& aCursorPosition)
+	: iConsole(aCursorPosition.iConsole)
+	, iPoint(aCursorPosition.iPoint + aCursorPosition.iConsole.CursorWindowPosition())
+	{
+	}
+
+TBufferPosition::TBufferPosition(const TViewPosition& aViewPosition)
+	: iConsole(aViewPosition.iConsole)
+	, iPoint(aViewPosition.iPoint + aViewPosition.iConsole.ViewPosition())
+	{
+	}
+
+	
+
+//______________________________________________________________________________
+//						TConsCursorPosition
+TConsCursorPosition::TConsCursorPosition(const CConsoleControl& aConsole, TPoint aPosition)
+	: iConsole(aConsole), iPoint(aPosition)
+	{
+	}
+
+TConsCursorPosition::TConsCursorPosition(const CConsoleControl& aConsole, TInt aX, TInt aY)
+	: iConsole(aConsole), iPoint(aX, aY)
+	{
+	}
+
+TConsCursorPosition::TConsCursorPosition(const TBufferPosition& aBufferPosition)
+	: iConsole(aBufferPosition.iConsole)
+	, iPoint(aBufferPosition.iPoint - aBufferPosition.iConsole.CursorWindowPosition())
+	{
+	}
+
+TConsCursorPosition::TConsCursorPosition(const TViewPosition& aViewPosition)
+	: iConsole(aViewPosition.iConsole)
+	, iPoint(aViewPosition.iPoint + aViewPosition.iConsole.ViewPosition() - aViewPosition.iConsole.CursorWindowPosition())
+	{
+	}
+
+	
+
+//______________________________________________________________________________
+//						TViewPosition
+TViewPosition::TViewPosition(const CConsoleControl& aConsole, TPoint aPosition)
+	: iConsole(aConsole), iPoint(aPosition)
+	{
+	}
+
+TViewPosition::TViewPosition(const CConsoleControl& aConsole, TInt aX, TInt aY)
+	: iConsole(aConsole), iPoint(aX, aY)
+	{
+	}
+
+TViewPosition::TViewPosition(const TConsCursorPosition& aCursorPosition)
+	: iConsole(aCursorPosition.iConsole)
+	, iPoint(aCursorPosition.iPoint + aCursorPosition.iConsole.CursorWindowPosition() - aCursorPosition.iConsole.ViewPosition())
+	{
+	}
+
+TViewPosition::TViewPosition(const TBufferPosition& aBufferPosition)
+	: iConsole(aBufferPosition.iConsole)
+	, iPoint(aBufferPosition.iPoint - aBufferPosition.iConsole.ViewPosition())
+	{
+	}
+
+//______________________________________________________________________________
+//						TScreenPosition
+TScreenPosition::TScreenPosition(const CConsoleControl& aConsole, TPoint aPosition)
+	: iConsole(aConsole), iPoint(aPosition)
+	{
+	}
+
+TScreenPosition::TScreenPosition(const CConsoleControl& aConsole, TInt aX, TInt aY)
+	: iConsole(aConsole), iPoint(aX, aY)
+	{
+	}
+
+TScreenPosition::TScreenPosition(const TViewPosition& aViewPosition)
+	: iConsole(aViewPosition.iConsole)
+	, iPoint(aViewPosition.iPoint.iX * aViewPosition.iConsole.GlyphSize().iWidth, aViewPosition.iPoint.iY * aViewPosition.iConsole.GlyphSize().iHeight)
+	{
+	}
+
+//______________________________________________________________________________
+//						RAttributeMap
+
+RAttributeMap::RAttributeMap()
+	: iAttributes(KAttributeMapGranularity, _FOFF(TAttributes, iPosition))
+	{
+	}
+
+void RAttributeMap::Close()
+	{
+	iAttributes.Close();
+	}
+
+void RAttributeMap::Reset()
+	{
+	iAttributes.Reset();
+	}
+
+void RAttributeMap::AddL(TInt aPosition, TInt aLineWidth, const ConsoleAttributes::TAttributes& aAttributes)
+	{
+	// Take a copy of the attributes array to make cleanup easier.
+	RArray<TAttributes> attributes;
+	CleanupClosePushL(attributes);
+	const TInt numAttributes = iAttributes.Count();
+	for (TInt i = 0; i < numAttributes; ++i)
+		{
+		attributes.AppendL(iAttributes[i]);
+		}
+
+	if (attributes.Count() == 0)
+		{
+		// This is the first set of attributes to be added. Add a default set before them.
+		attributes.AppendL(TAttributes(0, DefaultAttributes()));
+		}
+
+	TAttributes attr(aPosition, aAttributes);
+	TInt pos;
+	TInt err = attributes.FindInSignedKeyOrder(attr, pos);
+	if (err == KErrNone)
+		{
+		// Attribute already exists at this position - replace.
+		attributes[pos] = attr;
+		}
+	else
+		{
+		// No attribute found at aPosition.
+		// pos is set to the index _after_ aPosition. This must be at least 1 because the first slot in the array is always taken with defaults or something else.
+		// Set pos to the index _before_ aPosition.
+		--pos;
+
+		// Check earlier attributes to see if they match.
+		if (!(attributes[pos] == attr))
+			{
+			// No match - insert new attributes.
+			attributes.InsertInSignedKeyOrderL(attr);
+
+			// Get the position of the newly inserted attributes.
+			attributes.FindInSignedKeyOrder(attr, pos);
+			}
+		}
+
+	const TAttributes& newAttributes = attributes[pos];
+	if ((pos == (attributes.Count() - 1)) && (newAttributes.iPosition < (aLineWidth - 1)) && !(newAttributes == TAttributes(0, DefaultAttributes())))
+		{
+		// New attributes are the last in the list, and not at the end of the line and not defaults.
+		// Add another set of defaults after them.
+		attributes.AppendL(TAttributes(newAttributes.iPosition + 1, DefaultAttributes()));
+		}
+
+	iAttributes.Close();
+	iAttributes = attributes;
+	CleanupStack::Pop(&attributes);
+	}
+
+void RAttributeMap::RemoveFrom(TInt aPosition)
+	{
+	for (TInt i = (iAttributes.Count() - 1); i >= 0; --i)
+		{
+		if (iAttributes[i].iPosition >= aPosition)
+			{
+			iAttributes.Remove(i);
+			}
+		}
+	}
+
+TInt RAttributeMap::NumberOfBlocks() const
+	{
+	if (iAttributes.Count() == 0)
+		{
+		return 1; // If no attributes have been added, give the entire line an implict default set of attributes.
+		}
+	return iAttributes.Count();
+	}
+
+void RAttributeMap::GetBlock(TInt aIndex, TInt aLineWidth, TInt& aStartPosition, TInt& aEndPosition, ConsoleAttributes::TAttributes& aAttributes) const
+	{
+	if (iAttributes.Count() == 0)
+		{
+		ASSERT(aIndex == 0);
+		aStartPosition = 0;
+		aEndPosition = aLineWidth;
+		aAttributes = DefaultAttributes();
+		}
+	else
+		{
+		const TAttributes& attributes = iAttributes[aIndex];
+		aAttributes = attributes.iAttributes;
+		aStartPosition = attributes.iPosition;
+
+		if ((iAttributes.Count() == 1) || (aIndex == (iAttributes.Count() - 1)))
+			{
+			aEndPosition = aLineWidth;
+			}
+		else
+			{
+			aEndPosition = iAttributes[aIndex + 1].iPosition;
+			}
+		}
+	}
+
+RAttributeMap::TAttributes::TAttributes(TInt aPosition, const ConsoleAttributes::TAttributes& aAttributes)
+	: iPosition(aPosition), iAttributes(aAttributes)
+	{
+	}
+
+TBool RAttributeMap::TAttributes::operator==(const TAttributes& aAttributes) const
+	{
+	// Note, intentionally ignoring iPosition so ensure that existing attribute block are extended where possible.
+	return ((iAttributes.iAttributes == aAttributes.iAttributes.iAttributes) && 
+			(iAttributes.iForegroundColor == aAttributes.iAttributes.iForegroundColor) &&
+			(iAttributes.iBackgroundColor == aAttributes.iAttributes.iBackgroundColor));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/bmarm/econs.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+EXPORTS
+	NewConsole @ 1 NONAME ; (null)
+	Write__8RConsoleRC7TDesC16 @ 2 NONAME ; RConsole::Write(TDesC16 const &)
+	ClearToEndOfLine__8RConsole @ 3 NONAME ; RConsole::ClearToEndOfLine(void)
+	Code__C11TConsoleKey @ 4 NONAME ; TConsoleKey::Code(void) const
+	Control__8RConsoleRC7TDesC16 @ 5 NONAME ; RConsole::Control(TDesC16 const &)
+	Create__8RConsole @ 6 NONAME ; RConsole::Create(void)
+	CursorPos__C8RConsoleR6TPoint @ 7 NONAME ; RConsole::CursorPos(TPoint &) const
+	Destroy__8RConsole @ 8 NONAME ; RConsole::Destroy(void)
+	GetPaletteEntry__8RConsoleUiRUcN22 @ 9 NONAME ; RConsole::GetPaletteEntry(unsigned int, unsigned char &, unsigned char &, unsigned char &)
+	Init__8RConsoleRC7TDesC16RC5TSize @ 10 NONAME ; RConsole::Init(TDesC16 const &, TSize const &)
+	Modifiers__C11TConsoleKey @ 11 NONAME ; TConsoleKey::Modifiers(void) const
+	MousePos__C11TConsoleKey @ 12 NONAME ; TConsoleKey::MousePos(void) const
+	Panic__F13TConsolePanic @ 13 NONAME ; Panic(TConsolePanic)
+	ReadCancel__8RConsole @ 14 NONAME ; RConsole::ReadCancel(void)
+	Read__8RConsoleR11TConsoleKey @ 15 NONAME ; RConsole::Read(TConsoleKey &)
+	Read__8RConsoleR11TConsoleKeyR14TRequestStatus @ 16 NONAME ; RConsole::Read(TConsoleKey &, TRequestStatus &)
+	ScreenSize__C8RConsoleR5TSize @ 17 NONAME ; RConsole::ScreenSize(TSize &) const
+	SetCursorHeight__8RConsolei @ 18 NONAME ; RConsole::SetCursorHeight(int)
+	SetCursorPosAbs__8RConsoleRC6TPoint @ 19 NONAME ; RConsole::SetCursorPosAbs(TPoint const &)
+	SetCursorPosRel__8RConsoleRC6TPoint @ 20 NONAME ; RConsole::SetCursorPosRel(TPoint const &)
+	SetMode__8RConsole10TVideoMode @ 21 NONAME ; RConsole::SetMode(TVideoMode)
+	SetPaletteEntry__8RConsoleUiUcUcUc @ 22 NONAME ; RConsole::SetPaletteEntry(unsigned int, unsigned char, unsigned char, unsigned char)
+	SetSize__8RConsoleRC5TSize @ 23 NONAME ; RConsole::SetSize(TSize const &)
+	SetTextAttribute__8RConsole14TTextAttribute @ 24 NONAME ; RConsole::SetTextAttribute(TTextAttribute)
+	SetTextColors__8RConsoleUiUi @ 25 NONAME ; RConsole::SetTextColors(unsigned int, unsigned int)
+	SetTitle__8RConsoleRC7TDesC16 @ 26 NONAME ; RConsole::SetTitle(TDesC16 const &)
+	SetUIColors__8RConsoleUiUiUi @ 27 NONAME ; RConsole::SetUIColors(unsigned int, unsigned int, unsigned int)
+	SetWindowPosAbs__8RConsoleRC6TPoint @ 28 NONAME ; RConsole::SetWindowPosAbs(TPoint const &)
+	Size__C8RConsoleR5TSize @ 29 NONAME ; RConsole::Size(TSize &) const
+	Type__C11TConsoleKey @ 30 NONAME ; TConsoleKey::Type(void) const
+	Version__8RConsole @ 31 NONAME ; RConsole::Version(void)
+	ClearScreen__8RConsole @ 32 NONAME ; RConsole::ClearScreen(void)
+	PointerNumber__C11TConsoleKey @ 33 NONAME ; TConsoleKey::PointerNumber(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/bwins/econs.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+	?ClearScreen@RConsole@@QAEHXZ @ 2 NONAME ; public: int __thiscall RConsole::ClearScreen(void)
+	?ClearToEndOfLine@RConsole@@QAEHXZ @ 3 NONAME ; public: int __thiscall RConsole::ClearToEndOfLine(void)
+	?Code@TConsoleKey@@QBE?AW4TKeyCode@@XZ @ 4 NONAME ; public: enum TKeyCode  __thiscall TConsoleKey::Code(void)const 
+	?Control@RConsole@@QAEHABVTDesC16@@@Z @ 5 NONAME ; public: int __thiscall RConsole::Control(class TDesC16 const &)
+	?Create@RConsole@@QAEHXZ @ 6 NONAME ; public: int __thiscall RConsole::Create(void)
+	?CursorPos@RConsole@@QBEHAAVTPoint@@@Z @ 7 NONAME ; public: int __thiscall RConsole::CursorPos(class TPoint &)const 
+	?Destroy@RConsole@@QAEHXZ @ 8 NONAME ; public: int __thiscall RConsole::Destroy(void)
+	?GetPaletteEntry@RConsole@@QAEXIAAE00@Z @ 9 NONAME ; public: void __thiscall RConsole::GetPaletteEntry(unsigned int,unsigned char &,unsigned char &,unsigned char &)
+	?Init@RConsole@@QAEHABVTDesC16@@ABVTSize@@@Z @ 10 NONAME ; public: int __thiscall RConsole::Init(class TDesC16 const &,class TSize const &)
+	?Modifiers@TConsoleKey@@QBEHXZ @ 11 NONAME ; public: int __thiscall TConsoleKey::Modifiers(void)const 
+	?MousePos@TConsoleKey@@QBE?AVTPoint@@XZ @ 12 NONAME ; public: class TPoint  __thiscall TConsoleKey::MousePos(void)const 
+	?Panic@@YAXW4TConsolePanic@@@Z @ 13 NONAME ; void __cdecl Panic(enum TConsolePanic)
+	?Read@RConsole@@QAEHAAVTConsoleKey@@@Z @ 14 NONAME ; public: int __thiscall RConsole::Read(class TConsoleKey &)
+	?Read@RConsole@@QAEXAAVTConsoleKey@@AAVTRequestStatus@@@Z @ 15 NONAME ; public: void __thiscall RConsole::Read(class TConsoleKey &,class TRequestStatus &)
+	?ReadCancel@RConsole@@QAEHXZ @ 16 NONAME ; public: int __thiscall RConsole::ReadCancel(void)
+	?ScreenSize@RConsole@@QBEHAAVTSize@@@Z @ 17 NONAME ; public: int __thiscall RConsole::ScreenSize(class TSize &)const 
+	?SetCursorHeight@RConsole@@QAEHH@Z @ 18 NONAME ; public: int __thiscall RConsole::SetCursorHeight(int)
+	?SetCursorPosAbs@RConsole@@QAEHABVTPoint@@@Z @ 19 NONAME ; public: int __thiscall RConsole::SetCursorPosAbs(class TPoint const &)
+	?SetCursorPosRel@RConsole@@QAEHABVTPoint@@@Z @ 20 NONAME ; public: int __thiscall RConsole::SetCursorPosRel(class TPoint const &)
+	?SetMode@RConsole@@QAEHW4TVideoMode@@@Z @ 21 NONAME ; public: int __thiscall RConsole::SetMode(enum TVideoMode)
+	?SetPaletteEntry@RConsole@@QAEXIEEE@Z @ 22 NONAME ; public: void __thiscall RConsole::SetPaletteEntry(unsigned int,unsigned char,unsigned char,unsigned char)
+	?SetSize@RConsole@@QAEHABVTSize@@@Z @ 23 NONAME ; public: int __thiscall RConsole::SetSize(class TSize const &)
+	?SetTextAttribute@RConsole@@QAEXW4TTextAttribute@@@Z @ 24 NONAME ; public: void __thiscall RConsole::SetTextAttribute(enum TTextAttribute)
+	?SetTextColors@RConsole@@QAEXII@Z @ 25 NONAME ; public: void __thiscall RConsole::SetTextColors(unsigned int,unsigned int)
+	?SetTitle@RConsole@@QAEHABVTDesC16@@@Z @ 26 NONAME ; public: int __thiscall RConsole::SetTitle(class TDesC16 const &)
+	?SetUIColors@RConsole@@QAEXIII@Z @ 27 NONAME ; public: void __thiscall RConsole::SetUIColors(unsigned int,unsigned int,unsigned int)
+	?SetWindowPosAbs@RConsole@@QAEHABVTPoint@@@Z @ 28 NONAME ; public: int __thiscall RConsole::SetWindowPosAbs(class TPoint const &)
+	?Size@RConsole@@QBEHAAVTSize@@@Z @ 29 NONAME ; public: int __thiscall RConsole::Size(class TSize &)const 
+	?Type@TConsoleKey@@QBEHXZ @ 30 NONAME ; public: int __thiscall TConsoleKey::Type(void)const 
+	?Version@RConsole@@QAE?AVTVersion@@XZ @ 31 NONAME ; public: class TVersion  __thiscall RConsole::Version(void)
+	?Write@RConsole@@QAEHABVTDesC16@@@Z @ 32 NONAME ; public: int __thiscall RConsole::Write(class TDesC16 const &)
+	?PointerNumber@TConsoleKey@@QBEEXZ @ 33 NONAME ; public: unsigned char __thiscall TConsoleKey::PointerNumber(void)const 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/eabi/econs.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+EXPORTS
+	NewConsole @ 1 NONAME ; NewConsole
+	_Z5Panic13TConsolePanic @ 2 NONAME ; Panic(TConsolePanic)
+	_ZN8RConsole10ReadCancelEv @ 3 NONAME ; RConsole::ReadCancel()
+	_ZN8RConsole11ClearScreenEv @ 4 NONAME ; RConsole::ClearScreen()
+	_ZN8RConsole11SetUIColorsEjjj @ 5 NONAME ; RConsole::SetUIColors(unsigned int, unsigned int, unsigned int)
+	_ZN8RConsole13SetTextColorsEjj @ 6 NONAME ; RConsole::SetTextColors(unsigned int, unsigned int)
+	_ZN8RConsole15GetPaletteEntryEjRhS0_S0_ @ 7 NONAME ; RConsole::GetPaletteEntry(unsigned int, unsigned char&, unsigned char&, unsigned char&)
+	_ZN8RConsole15SetCursorHeightEi @ 8 NONAME ; RConsole::SetCursorHeight(int)
+	_ZN8RConsole15SetCursorPosAbsERK6TPoint @ 9 NONAME ; RConsole::SetCursorPosAbs(TPoint const&)
+	_ZN8RConsole15SetCursorPosRelERK6TPoint @ 10 NONAME ; RConsole::SetCursorPosRel(TPoint const&)
+	_ZN8RConsole15SetPaletteEntryEjhhh @ 11 NONAME ; RConsole::SetPaletteEntry(unsigned int, unsigned char, unsigned char, unsigned char)
+	_ZN8RConsole15SetWindowPosAbsERK6TPoint @ 12 NONAME ; RConsole::SetWindowPosAbs(TPoint const&)
+	_ZN8RConsole16ClearToEndOfLineEv @ 13 NONAME ; RConsole::ClearToEndOfLine()
+	_ZN8RConsole16SetTextAttributeE14TTextAttribute @ 14 NONAME ; RConsole::SetTextAttribute(TTextAttribute)
+	_ZN8RConsole4InitERK7TDesC16RK5TSize @ 15 NONAME ; RConsole::Init(TDesC16 const&, TSize const&)
+	_ZN8RConsole4ReadER11TConsoleKey @ 16 NONAME ; RConsole::Read(TConsoleKey&)
+	_ZN8RConsole4ReadER11TConsoleKeyR14TRequestStatus @ 17 NONAME ; RConsole::Read(TConsoleKey&, TRequestStatus&)
+	_ZN8RConsole5WriteERK7TDesC16 @ 18 NONAME ; RConsole::Write(TDesC16 const&)
+	_ZN8RConsole6CreateEv @ 19 NONAME ; RConsole::Create()
+	_ZN8RConsole7ControlERK7TDesC16 @ 20 NONAME ; RConsole::Control(TDesC16 const&)
+	_ZN8RConsole7DestroyEv @ 21 NONAME ; RConsole::Destroy()
+	_ZN8RConsole7SetModeE10TVideoMode @ 22 NONAME ; RConsole::SetMode(TVideoMode)
+	_ZN8RConsole7SetSizeERK5TSize @ 23 NONAME ; RConsole::SetSize(TSize const&)
+	_ZN8RConsole7VersionEv @ 24 NONAME ; RConsole::Version()
+	_ZN8RConsole8SetTitleERK7TDesC16 @ 25 NONAME ; RConsole::SetTitle(TDesC16 const&)
+	_ZNK11TConsoleKey4CodeEv @ 26 NONAME ; TConsoleKey::Code() const
+	_ZNK11TConsoleKey4TypeEv @ 27 NONAME ; TConsoleKey::Type() const
+	_ZNK11TConsoleKey8MousePosEv @ 28 NONAME ; TConsoleKey::MousePos() const
+	_ZNK11TConsoleKey9ModifiersEv @ 29 NONAME ; TConsoleKey::Modifiers() const
+	_ZNK8RConsole10ScreenSizeER5TSize @ 30 NONAME ; RConsole::ScreenSize(TSize&) const
+	_ZNK8RConsole4SizeER5TSize @ 31 NONAME ; RConsole::Size(TSize&) const
+	_ZNK8RConsole9CursorPosER6TPoint @ 32 NONAME ; RConsole::CursorPos(TPoint&) const
+	_ZNK11TConsoleKey13PointerNumberEv @ 33 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_MMPFILES
+.\iocons.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/group/iocons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// iocons.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			iocons.dll
+targettype		DLL
+uid				0x1000008d 0x100039e7
+capability		FSHELL_CAP_MMP_MAX
+
+sourcepath		..\src
+#include <fshell/fsh_system_include.mmh>
+
+source			ioconsole.cpp
+source 			co_cli.cpp co_utl.cpp
+
+library			euser.lib
+library			iocli.lib
+
+nostrictdef
+deffile			econs.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/src/co_cli.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,318 @@
+// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32\ewsrv\co_cli.cpp
+// 
+//
+
+#include "ws_std.h"
+
+TInt RConsole::Connect()
+	{
+	return CreateSession(KE32WindowServer,Version(),KMessageSlots);
+	}
+
+EXPORT_C TInt RConsole::Create()
+//
+// Connect with the window server if connection not already made,
+// then create a default console window without displaying it
+//
+	{
+
+	if (Handle()==KNullHandle)
+		{
+		TInt r = Connect();
+		if (r!=KErrNone)
+			return r;
+		}
+	return SendReceive(CWsSession::EConsoleCreate, TIpcArgs());
+	}
+
+EXPORT_C TInt RConsole::Init(const TDesC &aName,const TSize &aSize)
+//
+// Connect with the window server if connection not already made,
+// then open/display a console window on with the specified title.
+//
+	{
+
+	if (Handle()==KNullHandle)
+		{
+		TInt r = Connect();
+		if (r!=KErrNone)
+			return r;
+		}
+	TPckgC<TSize> size(aSize);
+	return SendReceive(CWsSession::EConsoleSet, TIpcArgs(&aName, &size));
+	}
+
+EXPORT_C TInt RConsole::SetTitle(const TDesC &aName)
+//
+// Change the title of the window
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleSetTitle, TIpcArgs(&aName));
+	}
+
+EXPORT_C TInt RConsole::SetSize(const TSize &aSize)
+//
+// Change the underlying size of the window
+//
+	{
+
+	TPckgC<TSize> size(aSize);
+	return SendReceive(CWsSession::EConsoleSetSize, TIpcArgs(&size));
+	}
+
+EXPORT_C TInt RConsole::Size(TSize &aSize) const
+//
+// Read the current window size
+//
+	{
+
+	TPckg<TSize> size(aSize);
+	return SendReceive(CWsSession::EConsoleSize, TIpcArgs( (TDes8*)&size ));
+	}
+
+EXPORT_C TInt RConsole::ScreenSize(TSize &aSize) const
+//
+// Read the screen size in characters
+//
+	{
+	
+	TPckg<TSize> size(aSize);
+	return SendReceive(CWsSession::EConsoleScreenSize, TIpcArgs( (TDes8*)&size ));
+	}
+
+EXPORT_C TVersion RConsole::Version()
+//
+// Return the client side version number.
+//
+	{
+
+	return TVersion(KW32MajorVersionNumber,KW32MinorVersionNumber,KE32BuildVersionNumber);
+	}
+
+EXPORT_C TInt RConsole::Write(const TDesC &aDes)
+//
+// Write to the console.
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleWrite, TIpcArgs(&aDes));
+	}
+
+EXPORT_C TInt RConsole::ClearScreen()
+//
+// Clear window
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleClearScreen, TIpcArgs());
+	}
+
+EXPORT_C TInt RConsole::ClearToEndOfLine()
+//
+// Clear window from current cursor position to the end of the line
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleClearToEndOfLine, TIpcArgs());
+	}
+
+EXPORT_C TInt RConsole::Destroy()
+//
+// Remove and close down the window
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleDestroy, TIpcArgs());
+	}
+
+EXPORT_C TInt RConsole::SetWindowPosAbs(const TPoint &aPosition)
+//
+// Position the window
+//
+	{
+	
+	TPckgC<TPoint> point(aPosition);
+	return SendReceive(CWsSession::EConsoleSetWindowPosAbs, TIpcArgs(&point));
+	}
+
+EXPORT_C TInt RConsole::SetCursorHeight(TInt aPercentage)
+//
+// Set the percentage height of the cursor
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleSetCursorHeight, TIpcArgs(aPercentage));
+	}
+		
+EXPORT_C TInt RConsole::SetCursorPosAbs(const TPoint &aPosition)
+//
+// Position the cursor in the window buffer
+//
+	{
+
+	TPckgC<TPoint> point(aPosition);
+	return SendReceive(CWsSession::EConsoleSetCursorPosAbs, TIpcArgs(&point));
+	}
+
+EXPORT_C TInt RConsole::SetCursorPosRel(const TPoint &aVector)
+//
+// Position the cursor in the window buffer
+//
+	{
+
+	TPckg<TPoint> point(aVector);
+	return SendReceive(CWsSession::EConsoleSetCursorPosRel, TIpcArgs(&point));
+	}
+
+EXPORT_C TInt RConsole::CursorPos(TPoint &aPosition) const
+//
+// Read current cursor position relative to the window
+//
+	{
+
+	TPckg<TPoint> point(aPosition);
+	return SendReceive(CWsSession::EConsoleCursorPos, TIpcArgs( (TDes8*)&point ));
+	}
+
+EXPORT_C TInt RConsole::Control(const TDesC &aDes)
+//
+// Control window properties
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleControl, TIpcArgs(&aDes));
+	}
+
+EXPORT_C TInt RConsole::Read(TConsoleKey &aKeystroke)
+//
+// Synchronous get keystroke from window
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleRead, TIpcArgs( (TDes8*)&aKeystroke ));
+	}
+
+EXPORT_C void RConsole::Read(TConsoleKey &aKeystroke,TRequestStatus &aStatus)
+//
+// Asynchronous get keystroke from window
+//
+	{
+
+	SendReceive(CWsSession::EConsoleRead, TIpcArgs( (TDes8*)&aKeystroke ), aStatus);
+	}
+
+EXPORT_C TInt RConsole::ReadCancel()
+//
+// Cancel asynchronous read request
+//
+	{
+
+	return SendReceive(CWsSession::EConsoleReadCancel, TIpcArgs());
+	}
+
+EXPORT_C TInt RConsole::SetMode(TVideoMode aMode)
+//
+//
+//
+	{
+	
+	if (Handle()==KNullHandle)
+		{
+		TInt r = Connect();
+		if (r!=KErrNone)
+			return r;
+		}
+	return SendReceive(CWsSession::EConsoleSetMode, TIpcArgs(aMode));
+	}
+
+EXPORT_C void RConsole::SetPaletteEntry(TUint aIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue)
+//
+//
+//
+	{
+	
+	if (Handle()==KNullHandle)
+		{
+		TInt r = Connect();
+		if (r!=KErrNone)
+			return;
+		}
+	SendReceive(CWsSession::EConsoleSetPaletteEntry, TIpcArgs(aIndex,aRed,aGreen,aBlue));
+	}
+
+EXPORT_C void RConsole::GetPaletteEntry(TUint aIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue)
+//
+//
+//
+	{
+	
+	if (Handle()==KNullHandle)
+		{
+		TInt r = Connect();
+		if (r!=KErrNone)
+			return;
+		}
+	TPckg<TUint8> r(aRed);
+	TPckg<TUint8> g(aGreen);
+	TPckg<TUint8> b(aBlue);
+	SendReceive(CWsSession::EConsoleGetPaletteEntry, TIpcArgs(aIndex, &r, &g, &b));
+	}
+
+EXPORT_C void RConsole::SetTextColors(TUint aFgColor,TUint aBgColor)
+//
+//
+//
+	{
+	
+	if (Handle()==KNullHandle)
+		{
+		TInt r = Connect();
+		if (r!=KErrNone)
+			return;
+		}
+	SendReceive(CWsSession::EConsoleSetTextColors, TIpcArgs(aFgColor, aBgColor));
+	}
+
+EXPORT_C void RConsole::SetUIColors(TUint aWindowBgColor,TUint aBorderColor,TUint aScreenColor)
+//
+//
+//
+	{
+	
+	if (Handle()==KNullHandle)
+		{
+		TInt r = Connect();
+		if (r!=KErrNone)
+			return;
+		}
+	SendReceive(CWsSession::EConsoleSetUIColors, TIpcArgs(aWindowBgColor, aBorderColor, aScreenColor));
+	}
+
+EXPORT_C void RConsole::SetTextAttribute(TTextAttribute aAttr)
+//
+//
+//
+	{
+
+	if (Handle()==KNullHandle)
+		{
+		TInt r = Connect();
+		if (r!=KErrNone)
+			return;
+		}
+	SendReceive(CWsSession::EConsoleSetTextAttribute, TIpcArgs(aAttr));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/src/co_utl.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,72 @@
+// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32\ewsrv\co_utl.cpp
+// 
+//
+
+#include "ws_std.h"
+
+EXPORT_C void Panic(TConsolePanic aPanic)
+//
+// Panic the client side console code
+//
+	{
+
+	User::Panic(_L("Console-TWIN"),aPanic);
+	}
+
+EXPORT_C TKeyCode TConsoleKey::Code() const
+//
+// Return the keycode
+//
+	{
+
+	return((*((TConsoleKey *)this))().iCode);
+	}
+
+EXPORT_C TInt TConsoleKey::Modifiers() const
+//
+// Return the key modifiers
+//
+	{
+
+	return((*((TConsoleKey *)this))().iModifiers);
+	}
+
+EXPORT_C TUint8 TConsoleKey::PointerNumber() const
+//
+// Return the pointer number
+//
+	{
+	return((*((TConsoleKey *)this))().iPointerNumber);
+	}
+
+EXPORT_C TInt TConsoleKey::Type() const
+//
+// Return the key type
+//
+	{
+
+	return((*((TConsoleKey *)this))().iType);
+	}
+
+EXPORT_C TPoint TConsoleKey::MousePos() const
+//
+// Return the mouse position
+//
+	{
+
+	return((*((TConsoleKey *)this))().iMousePos);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/src/e32twin.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,134 @@
+// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// e32\include\e32twin.h
+// 
+// WARNING: This file contains some APIs which are internal and are subject
+//          to change without notice. Such APIs should therefore not be used
+//          outside the Kernel and Hardware Services package.
+//
+
+#ifndef __E32TWIN_H__
+#define __E32TWIN_H__
+#include <e32cons.h>
+//
+
+/** @internalComponent */
+_LIT(KE32WindowServer,"!E32WindowServer");
+
+/** @internalTechnology */
+enum TEventType
+    {
+    EKeyPress,
+    EMouseClick
+    };
+
+/**
+@publishedPartner
+@released
+*/
+enum TVideoMode
+	{
+	EMono=1,
+	EGray4=2,
+	EGray16=4,
+	EColor256=8,
+	EColor4K=12,
+	EColor64K=16,
+	EColor16M=24
+
+	};
+
+/** @internalTechnology */
+struct SConsoleKey
+	{
+ 	TKeyCode iCode;
+	TUint iModifiers;
+    TPoint iMousePos;
+    TInt iType;
+    TUint8 iPointerNumber;
+	};
+
+/** @internalTechnology */
+class TConsoleKey : public TPckgBuf<SConsoleKey>
+	{
+public:
+	IMPORT_C TKeyCode Code() const;
+	IMPORT_C TInt Modifiers() const;
+    IMPORT_C TInt Type() const;
+    IMPORT_C TPoint MousePos() const;
+    IMPORT_C TUint8 PointerNumber() const;
+	};
+
+/** @internalTechnology */
+class RConsole : public RSessionBase
+	{
+public:
+	IMPORT_C TVersion Version();
+	TInt Connect();
+	IMPORT_C TInt Create();
+	IMPORT_C TInt Init(const TDesC &aName,const TSize &aSize);
+	IMPORT_C TInt Write(const TDesC &aDes);
+	IMPORT_C TInt ClearScreen();
+	IMPORT_C TInt ClearToEndOfLine();
+	IMPORT_C TInt Destroy();
+	IMPORT_C TInt SetTitle(const TDesC &aName);
+	IMPORT_C TInt SetSize(const TSize &aSize);
+	IMPORT_C TInt SetWindowPosAbs(const TPoint &aPosition);
+	IMPORT_C TInt SetCursorHeight(TInt aPercentage);
+	IMPORT_C TInt SetCursorPosAbs(const TPoint &aPosition);
+	IMPORT_C TInt SetCursorPosRel(const TPoint &aVector);
+	IMPORT_C TInt Size(TSize &aSize) const;
+	IMPORT_C TInt ScreenSize(TSize &aSize) const;
+	IMPORT_C TInt CursorPos(TPoint &aPosition) const;
+	IMPORT_C TInt Control(const TDesC &aDes);
+	IMPORT_C TInt Read(TConsoleKey &aKeystroke);
+	IMPORT_C void Read(TConsoleKey &aKeystroke,TRequestStatus &aStatus);
+	IMPORT_C TInt ReadCancel();
+	IMPORT_C TInt SetMode(TVideoMode aMode);
+	IMPORT_C void SetPaletteEntry(TUint anIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue);
+	IMPORT_C void GetPaletteEntry(TUint anIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue);
+	IMPORT_C void SetTextColors(TUint anFgColor,TUint aBgColor);
+	IMPORT_C void SetUIColors(TUint aWindowBgColor,TUint aBorderColor,TUint aScreenColor);
+	IMPORT_C void SetTextAttribute(TTextAttribute anAttribute);
+	};
+
+/** @internalComponent */
+NONSHARABLE_CLASS(CConsoleTextWin) : public CConsoleBase
+	{
+public:
+	static CConsoleTextWin *NewL(const TDesC &aTitle,TSize aSize);
+	CConsoleTextWin();
+	virtual ~CConsoleTextWin();
+	virtual TInt Create(const TDesC &aTitle,TSize aSize);
+	virtual void Read(TRequestStatus &aStatus);
+	virtual void ReadCancel();
+	virtual void Write(const TDesC &aDes);
+	virtual TPoint CursorPos() const;
+	virtual void SetCursorPosAbs(const TPoint &aPoint);
+	virtual void SetCursorPosRel(const TPoint &aPoint);
+	virtual void SetCursorHeight(TInt aPercentage);
+	virtual void SetTitle(const TDesC &aTitle);
+	virtual void ClearScreen();
+	virtual void ClearToEndOfLine();
+	virtual TSize ScreenSize() const;
+	virtual TKeyCode KeyCode() const;
+	virtual TUint KeyModifiers() const;
+	virtual void SetTextAttribute(TTextAttribute anAttribute);
+	RConsole &Console();
+private:
+	TConsoleKey iKey;
+	RConsole iConsole;
+	};
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/src/ioconsole.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// ioconsole.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <e32cons.h>
+#include <fshell/ioutils.h>
+
+EXPORT_C TAny* NewConsole()
+	{
+	return IoUtils::NewConsole();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/iocons/src/ws_std.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,109 @@
+// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Cut down version of M:\sf\os\kernelhwsrv\kernel\eka\include\ws_std.h for iocons.
+// 
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef __WS_STD_H__
+#define __WS_STD_H__
+
+#include <e32base.h>
+#include <e32cons.h>
+#include <e32twin.h>
+#include <e32ver.h>
+#include <e32svr.h>
+//
+//
+const TInt KW32MajorVersionNumber=1;
+const TInt KW32MinorVersionNumber=0;
+const TInt KMessageSlots=3;
+//
+enum TConsolePanic
+	{
+	EConsServerFailed,
+	EConsNotSupportedYet
+	};
+//
+enum TWsPanic
+	{
+	EPrematureOperation,
+	ETooManyWindowsOpen,
+	EWindowTooWide,
+	EWindowTooThin,
+	EWindowTooHigh,
+	EWindowTooShort,
+	EWindowOutOfMemory,
+	EDoubleReadRequest,
+	};
+//
+enum TWsFault
+	{
+	ECreateScheduler,
+	ECreateServer,
+	EStartServer,
+	ECreateEvent,
+	ECreateShell,
+	ESchedulerError,
+	EWindowsInitialisation,
+	ENoKeyboardTranslator,
+	ECreateNotifierSemaphore,
+	ECreateNotifierThread,
+	ELocaleDll,
+	EChangeLocale,
+	};
+//
+class CWsSession : public CSession2
+	{
+public:
+	enum
+		{
+		EConsoleCreate,
+		EConsoleSet,
+		EConsoleClearScreen,
+		EConsoleClearToEndOfLine,
+		EConsoleSetWindowPosAbs,
+		EConsoleSetCursorHeight,
+		EConsoleSetCursorPosAbs,
+		EConsoleSetCursorPosRel,
+		EConsoleCursorPos,
+		EConsoleControl,
+		EConsoleWrite,
+		EConsoleRead,
+		EConsoleReadCancel,
+		EConsoleDestroy,
+		EConsoleSetTitle,
+		EConsoleSetSize,
+		EConsoleSize,
+		EConsoleScreenSize,
+		EConsoleSetMode,
+		EConsoleSetPaletteEntry,
+		EConsoleGetPaletteEntry,
+		EConsoleSetTextColors,
+		EConsoleSetUIColors,
+		EConsoleSetTextAttribute
+		};
+	};
+//
+GLREF_C TInt WindowServerThread(TAny *anArg);
+GLREF_C void Panic(TWsPanic aPanic);
+GLREF_C void Fault(TWsFault aFault);
+//
+IMPORT_C void Panic(TConsolePanic aPanic);
+
+#endif	// __WS_STD_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/nullcons/BMARM/nullconsU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME R3UNUSED ; (null)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/nullcons/bwins/nullconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/nullcons/eabi/nullconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/nullcons/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(nullcons.iby)
+
+PRJ_MMPFILES
+..\src\nullcons
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/nullcons/group/nullcons.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// nullcons.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __NULLCONS_IBY__
+#define __NULLCONS_IBY__
+
+#include <fsh_config.iby>
+FSHELL_EXECUTABLE_FILE(nullcons.dll)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/nullcons/src/nullcons.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,112 @@
+// nullcons.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32std.h>
+#include <e32cons.h>
+#include <e32keys.h>
+
+NONSHARABLE_CLASS(CNullConsole) : public CConsoleBase
+	{
+public:
+	CNullConsole();
+	virtual ~CNullConsole();
+	virtual TInt Create(const TDesC &aTitle,TSize aSize);
+	virtual void Read(TRequestStatus &aStatus);
+	virtual void ReadCancel();
+	virtual void Write(const TDesC &aDes);
+	virtual TPoint CursorPos() const;
+	virtual void SetCursorPosAbs(const TPoint &aPoint);
+	virtual void SetCursorPosRel(const TPoint &aPoint);
+	virtual void SetCursorHeight(TInt aPercentage);
+	virtual void SetTitle(const TDesC &aTitle);
+	virtual void ClearScreen();
+	virtual void ClearToEndOfLine();
+	virtual TSize ScreenSize() const;
+	virtual TKeyCode KeyCode() const;
+	virtual TUint KeyModifiers() const;
+	};
+
+CNullConsole::CNullConsole()
+	{
+	}
+
+CNullConsole::~CNullConsole()
+	{
+	}
+
+TInt CNullConsole::Create(const TDesC& /*aTitle*/, TSize /*aSize*/)
+	{
+	return(KErrNone);
+	}
+
+void CNullConsole::Read(TRequestStatus &aStatus)
+	{
+	TRequestStatus *pS=(&aStatus);
+	User::RequestComplete(pS, KErrNotSupported);
+	}
+
+void CNullConsole::ReadCancel()
+	{
+	}
+
+void CNullConsole::Write(const TDesC& /*aDes*/)
+	{
+	}
+
+TPoint CNullConsole::CursorPos() const
+	{
+	return TPoint(0,0);
+	}
+
+void CNullConsole::SetCursorPosAbs(const TPoint& /*aPoint*/)
+	{
+	}
+
+void CNullConsole::SetCursorPosRel(const TPoint& /*aPoint*/)
+	{
+	}
+
+void CNullConsole::SetCursorHeight(TInt /*aPercentage*/)
+	{
+	}
+
+void CNullConsole::SetTitle(const TDesC& /*aTitle*/)
+	{
+	}
+
+void CNullConsole::ClearScreen()
+	{
+	}
+
+void CNullConsole::ClearToEndOfLine()
+	{
+	}
+
+TSize CNullConsole::ScreenSize() const
+	{
+	return TSize(10,10);
+	}
+
+TKeyCode CNullConsole::KeyCode() const
+	{
+	return EKeyNull;
+	}
+
+TUint CNullConsole::KeyModifiers() const
+	{
+	return 0;
+	}
+
+extern "C" EXPORT_C TAny *NewConsole()
+	{
+	return(new CNullConsole);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/nullcons/src/nullcons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// nullcons.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+TARGET			nullcons.dll
+TARGETTYPE		dll
+UID             0x1000008d 0x100039e7
+
+CAPABILITY		FSHELL_CAP_MMP_NORMAL
+
+#include <fshell/fsh_system_include.mmh>
+
+SOURCEPATH		.
+SOURCE			nullcons.cpp
+
+LIBRARY			euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/bmarm/remote_consoleu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME R3UNUSED ; (null)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/bwins/remote_consoleu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/data/rcons.idf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,53 @@
+# rcons.idf
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Description:
+# INI description file for rcons.ini
+
+connection_type			enum
+connection_type.name		Connection type
+connection_type.description	Connection type ('implicit' or 'explicit')
+# values for this correspond to anum TRemoteConsoleConfig::TConnectionType
+connection_type.values		implicit,explicit
+connection_type.default		implicit
+
+remote_ip			string
+remote_ip.name			Remote IP address
+remote_ip.description		IP address of host running the rcons server
+remote_ip.default		wsockhost.mrouter
+
+remote_port			integer
+remote_port.name		Remote port number
+remote_port.description		Port number that the rcons server is listening on
+remote_port.default		3000
+
+protocol			integer
+protocol.name			Protocol identifier
+protocol.description		Identifier of the socket transport protocol to use
+# protocol 6 is TCP (KProtocolInetTcp)
+protocol.default		6
+
+iap_id				integer
+iap_id.name			IAP identifier
+iap_id.description		Identifier of the IAP to use for connection to the rcons server
+iap_id.default			0
+
+network_id			integer
+network_id.name			Network ID
+network_id.description		ID of the network to use to connet to the rcon server
+network_id.default		0
+
+debug				boolean
+debug.name			DebugW
+debug.description		Enable or disable debug
+debug.default			0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/data/rcons.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+#!iniedit -i \resource\rcons.idf
+# rcons.ini
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+remote_ip		192.168.0.2
+remote_port		8086
+fallback_console	ECONS_FB.DLL
+iap_id			3
+network_id		1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/data/rcons.ini.emulator	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+#!iniedit -i \resource\rcons.idf
+# rcons.ini.emulator
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+protocol		9000
+remote_ip		localhost
+remote_port		8086
+debug			0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/eabi/remote_consoleU.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/group/rcons.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+// rcons.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __RCONS_IBY__
+#define __RCONS_IBY__
+
+#include <fsh_config.iby>
+FSHELL_EXECUTABLE_FILE(rcons.dll)
+FSHELL_DATA_FILE(ZRESOURCE\rcons.idf, \resource\rcons.idf)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/group/remote_console.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// remote_console.mmp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			rcons.dll
+targettype		dll
+uid             0x1000008d 0x100039e7
+capability      FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			remote_console.cpp
+source			remote_console_config.cpp
+
+library			ltkutils.lib
+library			EUSER.LIB
+library			EFSRV.LIB
+library			ESOCK.LIB
+library			INSOCK.LIB
+library			COMMDB.LIB
+
+deffile			remote_console.def
+
+macro           USE_RCONNECTION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/inc/remote_console.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,73 @@
+// remote_console.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __REMOTE_CONSOLE_H__
+#define __REMOTE_CONSOLE_H__
+
+#include <e32cons.h>
+#include <es_sock.h>
+#include "remote_console_config.h"
+
+
+#ifdef EKA2
+NONSHARABLE_CLASS(CRemoteConsole)
+#else
+class CRemoteConsole
+#endif
+	 : public CConsoleBase
+	{
+public:
+	CRemoteConsole();
+public: // From CConsoleBase.
+	virtual ~CRemoteConsole();
+	virtual TInt Create(const TDesC& aTitle, TSize aSize);
+	virtual void Read(TRequestStatus& aStatus);
+	virtual void ReadCancel();
+	virtual void Write(const TDesC& aDes);
+	virtual TPoint CursorPos() const;
+	virtual void SetCursorPosAbs(const TPoint& aPoint);
+	virtual void SetCursorPosRel(const TPoint& aPoint);
+	virtual void SetCursorHeight(TInt aPercentage);
+	virtual void SetTitle(const TDesC& aTitle);
+	virtual void ClearScreen();
+	virtual void ClearToEndOfLine();
+	virtual TSize ScreenSize() const;
+	virtual TKeyCode KeyCode() const;
+	virtual TUint KeyModifiers() const;
+	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+private:
+	TInt Connect(const TDesC& aTitle, TSize aSize);
+	void CleanupConnection();
+	void WriteCommand(const TDesC8& aDes) const;
+	void ReadCommandResponse(TDes8& aDes) const;
+private:
+	class TKeyEvent
+		{
+	public:
+		TUint16 iChar;
+		TUint32 iModifiers;
+		};
+private:
+	TRemoteConsoleConfig iConfig;
+	RSocketServ iSocketSession;
+#ifdef USE_RCONNECTION
+	RConnection iConnection;
+#endif
+	mutable RSocket iCommandSocket;
+	RSocket iKeyEventSocket;
+	TKeyEvent iKeyEvent;
+	TPckg<TKeyEvent> iKeyEventPckg;
+	CConsoleBase* iUnderlyingConsole;
+	};
+
+
+#endif // __REMOTE_CONSOLE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/inc/remote_console_config.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,58 @@
+// remote_console_config.h
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include <e32std.h>
+#include <in_sock.h>
+#ifdef USE_RCONNECTION
+#include <es_enum.h>
+#endif
+
+
+class TRemoteConsoleConfig
+	{
+public:
+	enum TConnectionType
+		{
+		EImplicit,
+		EExplicit
+		};
+public:
+	TRemoteConsoleConfig();
+	TInt Init();
+	void PersistL() const;
+	TConnectionType ConnectionType() const;
+	const TDesC& ConnectionTypeString() const;
+	TUint RemotePort() const;
+	const TDesC& RemoteHostName() const;
+	TUint Protocol() const;
+	TUint IapId() const;
+	TUint NetworkId() const;
+	TBool Debug() const;
+	void SetConnectionType(const TDesC& aConnectionType);
+	void SetConnectionType(TConnectionType aType);
+	void SetRemotePort(TUint aPort);
+	TInt SetRemoteHostName(const TDesC& aName);
+	void SetProtocol(TUint aProtocol);
+	void SetIapId(TUint aIapId);
+	void SetNetworkId(TUint aNetworkId);
+	void SetDebug(TBool aDebug);
+private:
+	TConnectionType iConnectionType;
+	TUint iRemotePort;
+	TName iRemoteHostName;
+	TUint iProtocol;
+	TUint iIapId;
+	TUint iNetworkId;
+	TBool iDebug;
+	};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/src/remote_console.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,482 @@
+// remote_console.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32uid.h>
+#include <in_sock.h>
+#ifdef USE_RCONNECTION
+#include <es_enum.h>
+#include <commdbconnpref.h>
+#endif
+#include <fshell/consoleextensions.h>
+#include "remote_console.h"
+
+const TInt KMajorVersion = 1;
+const TInt KMinorVersion = 0;
+
+#define DEBUG_LOG(x) if (iUnderlyingConsole && iConfig.Debug()) iUnderlyingConsole->Write(_L(x))
+#define DEBUG_LOG_1(x, a) if (iUnderlyingConsole && iConfig.Debug()) iUnderlyingConsole->Printf(_L(x), a)
+#define DEBUG_LOG_2(x, a, b) if (iUnderlyingConsole && iConfig.Debug()) iUnderlyingConsole->Printf(_L(x), a, b)
+#define DEBUG_LOG_3(x, a, b, c) if (iUnderlyingConsole && iConfig.Debug()) iUnderlyingConsole->Printf(_L(x), a, b, c)
+#define CLEANUP_AND_RETURN_IF_ERROR(x) { TInt __err = x; if (__err < 0) { CleanupConnection(); return __err; } }
+
+enum TPacketType
+	{
+	ECommandCreateConsoleWindow,
+	ECommandAttachKeyEventSocket,
+	ECommandWrite,
+	ECommandGetCursorPos,
+	ECommandSetAbsCursorPos,
+	ECommandSetRelCursorPos,
+	ECommandSetCursorHeight,
+	ECommandGetScreenSize,
+	ECommandSetTitle,
+	ECommandClearScreen,
+	ECommandClearToEndOfLine
+	};
+
+
+class THeaderBase
+	{
+public:
+	THeaderBase(TPacketType aCommand, TInt aPacketSize);
+private:
+	const TInt iPacketType;
+	const TInt iPacketSize;
+	};
+
+THeaderBase::THeaderBase(TPacketType aCommand, TInt aPacketSize)
+	: iPacketType(aCommand), iPacketSize(aPacketSize - sizeof(THeaderBase))
+	{
+	}
+
+class TCreateConsoleWindowHeader : public THeaderBase
+	{
+public:
+	TCreateConsoleWindowHeader(const TDesC& aTitle, TSize aSize);
+private:
+	const TInt iMajorVersion;
+	const TInt iMinorVersion;
+	TInt iWidth;
+	TInt iHeight;
+	TInt iTitleLength;
+	};
+
+TCreateConsoleWindowHeader::TCreateConsoleWindowHeader(const TDesC& aTitle, TSize aSize)
+	: THeaderBase(ECommandCreateConsoleWindow, sizeof(TCreateConsoleWindowHeader) + aTitle.Size()), iMajorVersion(KMajorVersion), iMinorVersion(KMinorVersion), iWidth(aSize.iWidth), iHeight(aSize.iHeight), iTitleLength(aTitle.Length())
+	{
+	}
+
+class TAttachKeyEventSocketHeader : public THeaderBase
+	{
+public:
+	TAttachKeyEventSocketHeader(TInt aWindowId);
+private:
+	TInt iWindowId;
+	};
+
+TAttachKeyEventSocketHeader::TAttachKeyEventSocketHeader(TInt aWindowId)
+	: THeaderBase(ECommandAttachKeyEventSocket, sizeof(TAttachKeyEventSocketHeader)), iWindowId(aWindowId)
+	{
+	}
+
+class TWriteHeader : public THeaderBase
+	{
+public:
+	TWriteHeader(const TDesC& aDes);
+private:
+	TInt iDesLength;
+	};
+
+TWriteHeader::TWriteHeader(const TDesC& aDes)
+	: THeaderBase(ECommandWrite, sizeof(TWriteHeader) + aDes.Size()), iDesLength(aDes.Length())
+	{
+	}
+
+class TWriteOneHeader : public THeaderBase
+	{
+public:
+	TWriteOneHeader(const TDesC& aDes);
+private:
+	TInt iDesLength;
+	TUint16 iChar;
+	};
+
+TWriteOneHeader::TWriteOneHeader(const TDesC& aDes)
+	: THeaderBase(ECommandWrite, sizeof(TWriteOneHeader)), iDesLength(1), iChar(aDes[0])
+	{
+	}
+
+
+class TSetCursorPosHeader : public THeaderBase
+	{
+public:
+	TSetCursorPosHeader(TPacketType aCommand, const TPoint& aPos);
+private:
+	TInt iX;
+	TInt iY;
+	};
+
+TSetCursorPosHeader::TSetCursorPosHeader(TPacketType aCommand, const TPoint& aPos)
+	: THeaderBase(aCommand, sizeof(TSetCursorPosHeader)), iX(aPos.iX), iY(aPos.iY)
+	{
+	ASSERT((aCommand == ECommandSetAbsCursorPos) || (aCommand == ECommandSetRelCursorPos));
+	}
+
+class TSetCursorHeightHeader : public THeaderBase
+	{
+public:
+	TSetCursorHeightHeader(TInt aHeight);
+private:
+	TInt iHeight;
+	};
+
+TSetCursorHeightHeader::TSetCursorHeightHeader(TInt aHeight)
+	: THeaderBase(ECommandSetCursorHeight, sizeof(TSetCursorHeightHeader)), iHeight(aHeight)
+	{
+	}
+
+class TSetTitleHeader : public THeaderBase
+	{
+public:
+	TSetTitleHeader(const TDesC& aTitle);
+	};
+
+TSetTitleHeader::TSetTitleHeader(const TDesC& aTitle)
+	: THeaderBase(ECommandSetTitle, sizeof(TSetTitleHeader) + aTitle.Size())
+	{
+	}
+
+
+CRemoteConsole::CRemoteConsole()
+	: iKeyEventPckg(iKeyEvent)
+	{
+	}
+
+CRemoteConsole::~CRemoteConsole()
+	{
+	CleanupConnection();
+	delete iUnderlyingConsole;
+	}
+
+TInt CRemoteConsole::Create(const TDesC& aTitle, TSize aSize)
+	{
+	TInt ret = iConfig.Init();
+	if (ret == KErrNone)
+		{
+		ret = Connect(aTitle, aSize);
+		}
+	if (ret && iUnderlyingConsole)
+		{
+		iUnderlyingConsole->Printf(_L("Remote connection failed: %d\r\n"), ret);
+#ifdef __WINS__
+		// Give the user the chance to read the error message.
+		User::After(10000000);
+#endif
+		}
+	return ret;
+	}
+
+TInt CRemoteConsole::Connect(const TDesC& aTitle, TSize aSize)
+	{
+	// Connect to Socket Server.
+	DEBUG_LOG("Connecting to ESock\r\n");
+	TInt err = iSocketSession.Connect();
+	CLEANUP_AND_RETURN_IF_ERROR(err);
+
+#ifdef USE_RCONNECTION
+	switch (iConfig.ConnectionType())
+		{
+		default:
+		case TRemoteConsoleConfig::EImplicit:
+			{
+			DEBUG_LOG("Opening command socket\r\n");
+			CLEANUP_AND_RETURN_IF_ERROR(iCommandSocket.Open(iSocketSession, KAfInet, KSockStream, iConfig.Protocol()));
+			DEBUG_LOG("Opening event\r\n");
+			CLEANUP_AND_RETURN_IF_ERROR(iKeyEventSocket.Open(iSocketSession, KAfInet, KSockStream, iConfig.Protocol()));
+			break;
+			}
+		case TRemoteConsoleConfig::EExplicit:
+			{
+			DEBUG_LOG("Opening connection\r\n");
+			CLEANUP_AND_RETURN_IF_ERROR(iConnection.Open(iSocketSession));
+			TUint numConnections;
+			DEBUG_LOG("Enumerating existing connections\r\n");
+			err = iConnection.EnumerateConnections(numConnections);
+			CLEANUP_AND_RETURN_IF_ERROR(err);
+			DEBUG_LOG_2("Looking for IapId: %d NetId: %d\r\n", iConfig.IapId(), iConfig.NetworkId());
+
+			TBool connectionAttached(EFalse);
+			for (TInt i = 1; i <= (TInt)numConnections; ++i)
+				{
+				DEBUG_LOG_1("Getting info for connection %d\r\n", i);
+				TConnectionInfoBuf connectionInfoBuf;
+				CLEANUP_AND_RETURN_IF_ERROR(iConnection.GetConnectionInfo(i, connectionInfoBuf));
+				const TConnectionInfo& info = connectionInfoBuf();
+				DEBUG_LOG_2("Found IapId: %d NetId: %d\r\n", info.iIapId, info.iNetId);
+				if ((info.iIapId == iConfig.IapId()) && (info.iNetId == iConfig.NetworkId()))
+					{
+					DEBUG_LOG("Matching IAP and Network IDs found, attaching...\r\n");
+					CLEANUP_AND_RETURN_IF_ERROR(iConnection.Attach(connectionInfoBuf, RConnection::EAttachTypeNormal));
+					DEBUG_LOG("Opening command socket on connection\r\n");
+					CLEANUP_AND_RETURN_IF_ERROR(iCommandSocket.Open(iSocketSession, KAfInet, KSockStream, iConfig.Protocol(), iConnection));
+					DEBUG_LOG("Opening event socket on connection\r\n");
+					CLEANUP_AND_RETURN_IF_ERROR(iKeyEventSocket.Open(iSocketSession, KAfInet, KSockStream, iConfig.Protocol(), iConnection));
+					connectionAttached = ETrue;
+					}
+				}
+			if (!connectionAttached)
+				{
+				CLEANUP_AND_RETURN_IF_ERROR(KErrCouldNotConnect);
+				}
+			break;
+			}
+		}
+#else	// USE_RCONNECTION
+	DEBUG_LOG("Opening command socket\r\n");
+	CLEANUP_AND_RETURN_IF_ERROR(iCommandSocket.Open(iSocketSession, KAfInet, KSockStream, iConfig.Protocol()));
+	DEBUG_LOG("Opening event\r\n");
+	CLEANUP_AND_RETURN_IF_ERROR(iKeyEventSocket.Open(iSocketSession, KAfInet, KSockStream, iConfig.Protocol()));
+#endif
+
+	iCommandSocket.SetOpt(KSoTcpNoDelay, KSolInetTcp, ETrue);	// Ignore error (may not be supported).
+	iKeyEventSocket.SetOpt(KSoTcpNoDelay, KSolInetTcp, ETrue);	// Ignore error (may not be supported).
+
+	// Resolve IP address (if need be).
+	const TDesC& remoteHostName = iConfig.RemoteHostName();
+	TInetAddr remoteAddress(iConfig.RemotePort());
+	err = remoteAddress.Input(remoteHostName);
+	if (err)
+		{
+		RHostResolver resolver;
+#ifdef USE_RCONNECTION
+		if (iConnection.SubSessionHandle())
+			{
+			CLEANUP_AND_RETURN_IF_ERROR(resolver.Open(iSocketSession, KAfInet, iConfig.Protocol(), iConnection));
+			}
+		else
+			{
+			CLEANUP_AND_RETURN_IF_ERROR(resolver.Open(iSocketSession, KAfInet, iConfig.Protocol()));
+			}
+#else
+		CLEANUP_AND_RETURN_IF_ERROR(resolver.Open(iSocketSession, KAfInet, iConfig.Protocol()));
+#endif
+		TNameEntry nameEntry;
+		err = resolver.GetByName(remoteHostName, nameEntry);
+		if (err)
+			{
+			resolver.Close();
+			CLEANUP_AND_RETURN_IF_ERROR(err);
+			}
+		remoteAddress.SetAddress(TInetAddr::Cast(nameEntry().iAddr).Address());
+		resolver.Close();
+		}
+
+	// Connect command socket.
+	DEBUG_LOG_2("Connecting command socket to %S : %d\r\n", &remoteHostName, iConfig.RemotePort());
+	TRequestStatus status;
+	iCommandSocket.Connect(remoteAddress, status);
+	User::WaitForRequest(status);
+	CLEANUP_AND_RETURN_IF_ERROR(status.Int());
+
+	// Request a new console window in the remote host.
+	DEBUG_LOG("Requesting new console window\r\n");
+	TCreateConsoleWindowHeader createConsoleWindowHeader(aTitle, aSize);
+	TPckgC<TCreateConsoleWindowHeader> createConsoleWindowHeaderPckg(createConsoleWindowHeader);
+	iCommandSocket.Write(createConsoleWindowHeaderPckg, status);
+	User::WaitForRequest(status);
+	CLEANUP_AND_RETURN_IF_ERROR(status.Int());
+	DEBUG_LOG("Sending title\r\n");
+	TPtrC8 narrowTitlePtr((TUint8*)aTitle.Ptr(), aTitle.Size());
+	iCommandSocket.Write(narrowTitlePtr, status);
+	User::WaitForRequest(status);
+	CLEANUP_AND_RETURN_IF_ERROR(status.Int());
+
+	// Read response (window identifier if successful).
+	DEBUG_LOG("Reading window identifier\r\n");
+	TInt response;
+	TPckg<TInt> responsePckg(response);
+	iCommandSocket.Read(responsePckg, status);
+	User::WaitForRequest(status);
+	CLEANUP_AND_RETURN_IF_ERROR(status.Int());
+	CLEANUP_AND_RETURN_IF_ERROR(response);
+
+	// Connect key event socket.
+	DEBUG_LOG_2("Connecting event socket to %S : %d\r\n", &remoteHostName, iConfig.RemotePort());
+	iKeyEventSocket.Connect(remoteAddress, status);
+	User::WaitForRequest(status);
+	CLEANUP_AND_RETURN_IF_ERROR(status.Int());
+
+	// Attach key event socket to the new console window.
+	DEBUG_LOG("Attaching event socket to console window\r\n");
+	TAttachKeyEventSocketHeader attachKeyEventSocketHeader(response);
+	TPckgC<TAttachKeyEventSocketHeader> attachKeyEventSocketHeaderPckg(attachKeyEventSocketHeader);
+	iKeyEventSocket.Write(attachKeyEventSocketHeaderPckg, status);
+	User::WaitForRequest(status);
+	CLEANUP_AND_RETURN_IF_ERROR(status.Int());
+
+	return KErrNone;
+	}
+
+void CRemoteConsole::Read(TRequestStatus& aStatus)
+	{
+	iKeyEventSocket.Read(iKeyEventPckg, aStatus);
+	}
+
+void CRemoteConsole::ReadCancel()
+	{
+	iKeyEventSocket.CancelRead();
+	}
+
+void CRemoteConsole::Write(const TDesC& aDes)
+	{
+	if (aDes.Length() == 1)
+		{
+		// Only do a single ESock write for the case where there's only 1 character.
+		TWriteOneHeader writeHeader(aDes);
+		TPckgC<TWriteOneHeader> writeHeaderPckg(writeHeader);
+		WriteCommand(writeHeaderPckg);
+		}
+	else
+		{
+		TWriteHeader writeHeader(aDes);
+		TPckgC<TWriteHeader> writeHeaderPckg(writeHeader);
+		WriteCommand(writeHeaderPckg);
+		TPtrC8 narrowPtr((TUint8*)aDes.Ptr(), aDes.Size());
+		WriteCommand(narrowPtr);
+		}
+	}
+
+TPoint CRemoteConsole::CursorPos() const
+	{
+	THeaderBase header(ECommandGetCursorPos, sizeof(THeaderBase));
+	TPckgC<THeaderBase> headerPckg(header);
+	WriteCommand(headerPckg);
+	TPoint response;
+	TPckg<TPoint> responsePckg(response);
+	ReadCommandResponse(responsePckg);
+	return response;
+	}
+
+void CRemoteConsole::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	TSetCursorPosHeader header(ECommandSetAbsCursorPos, aPoint);
+	TPckgC<TSetCursorPosHeader> headerPckg(header);
+	WriteCommand(headerPckg);
+	}
+
+void CRemoteConsole::SetCursorPosRel(const TPoint& aPoint)
+	{
+	TSetCursorPosHeader header(ECommandSetRelCursorPos, aPoint);
+	TPckgC<TSetCursorPosHeader> headerPckg(header);
+	WriteCommand(headerPckg);
+	}
+
+void CRemoteConsole::SetCursorHeight(TInt aPercentage)
+	{
+	TSetCursorHeightHeader header(aPercentage);
+	TPckgC<TSetCursorHeightHeader> headerPckg(header);
+	WriteCommand(headerPckg);
+	}
+
+void CRemoteConsole::SetTitle(const TDesC& aTitle)
+	{
+	TSetTitleHeader header(aTitle);
+	TPckgC<TSetTitleHeader> headerPckg(header);
+	WriteCommand(headerPckg);
+	TPtrC8 narrowTitlePtr((TUint8*)aTitle.Ptr(), aTitle.Size());
+	WriteCommand(narrowTitlePtr);
+	}
+
+void CRemoteConsole::ClearScreen()
+	{
+	THeaderBase header(ECommandClearScreen, sizeof(THeaderBase));
+	TPckgC<THeaderBase> headerPckg(header);
+	WriteCommand(headerPckg);
+	}
+
+void CRemoteConsole::ClearToEndOfLine()
+	{
+	THeaderBase header(ECommandClearToEndOfLine, sizeof(THeaderBase));
+	TPckgC<THeaderBase> headerPckg(header);
+	WriteCommand(headerPckg);
+	}
+
+TSize CRemoteConsole::ScreenSize() const
+	{
+	THeaderBase header(ECommandGetScreenSize, sizeof(THeaderBase));
+	TPckgC<THeaderBase> headerPckg(header);
+	WriteCommand(headerPckg);
+	TSize response;
+	TPckg<TSize> responsePckg(response);
+	ReadCommandResponse(responsePckg);
+	return response;
+	}
+
+TKeyCode CRemoteConsole::KeyCode() const
+	{
+	return (TKeyCode)(iKeyEvent.iChar);
+	}
+
+TUint CRemoteConsole::KeyModifiers() const
+	{
+	return iKeyEvent.iModifiers;
+	}
+
+TInt CRemoteConsole::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	if (aExtensionId == UnderlyingConsole::KSetUnderlyingConsoleExtension)
+		{
+		iUnderlyingConsole = (CConsoleBase*)a1;
+		return KErrNone;
+		}
+	else
+		{
+		return CConsoleBase::Extension_(aExtensionId, a0, a1);
+		}
+	}
+
+void CRemoteConsole::CleanupConnection()
+	{
+	iKeyEventSocket.Close();
+	iCommandSocket.Close();
+#ifdef USE_RCONNECTION
+	iConnection.Close();
+#endif
+	iSocketSession.Close();
+	}
+
+void CRemoteConsole::WriteCommand(const TDesC8& aDes) const
+	{
+	TRequestStatus status;
+	iCommandSocket.Write(aDes, status);
+	User::WaitForRequest(status);
+	}
+
+void CRemoteConsole::ReadCommandResponse(TDes8& aDes) const
+	{
+	TRequestStatus status;
+	iCommandSocket.Read(aDes, status);
+	User::WaitForRequest(status);
+	}
+
+
+EXPORT_C TAny* NewConsole()
+	{
+	return new CRemoteConsole;
+	}
+
+#ifndef EKA2
+GLDEF_C TInt E32Dll(TDllReason)
+	{
+	return(KErrNone);
+	}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/client/src/remote_console_config.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,202 @@
+// remote_console_config.cpp
+// 
+// Copyright (c) 2005 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <f32file.h>
+#include <in_sock.h>
+#include <fshell/settings.h>
+#include "remote_console_config.h"
+
+#define CLEANUP_IF_ERROR(x) ret = x; if (ret < 0) goto cleanup
+
+
+// Default values (used if the config file can't be read).
+_LIT(KDefaultRemoteIpAddress, "wsockhost.mrouter");
+const TUint KDefaultRemotePort = 8086;
+const TUint KDefaultIapId = 0;
+const TUint KDefaultNetworkId = 0;
+
+// Config file details.
+_LIT(KConfigFileName, "\\system\\console\\rcons.ini");
+_LIT(KConfigDesciptionFile, "\\resource\\rcons.idf");
+
+// Configuration attributes.
+_LIT(KAttConnectionType, "connection_type");
+_LIT(KAttRemoteIpAddress, "remote_ip");
+_LIT(KAttRemotePort, "remote_port");
+_LIT(KAttProtocol, "protocol");
+_LIT(KAttIapId, "iap_id");
+_LIT(KAttNetId, "network_id");
+_LIT(KAttDebug, "debug");
+_LIT(KConTypeImplicit, "implicit");
+_LIT(KConTypeExplicit, "explicit");
+
+
+TRemoteConsoleConfig::TRemoteConsoleConfig()
+	: iConnectionType(EImplicit), iRemotePort(KDefaultRemotePort), iRemoteHostName(KDefaultRemoteIpAddress), iProtocol(KProtocolInetTcp), iIapId(KDefaultIapId), iNetworkId(KDefaultNetworkId), iDebug(EFalse)
+	{
+	}
+
+TInt TRemoteConsoleConfig::Init()
+	{
+	LtkUtils::CIniFile* settings = NULL;
+	TRAPD(err, settings = LtkUtils::CIniFile::NewL(KConfigFileName, KConfigDesciptionFile));
+	
+	if (err)
+		{
+		return err;
+		}
+		
+	SetConnectionType((TConnectionType)settings->GetInt(KAttConnectionType));
+	SetRemoteHostName(settings->GetString(KAttRemoteIpAddress));
+	SetRemotePort(settings->GetInt(KAttRemotePort));
+	iProtocol = settings->GetInt(KAttProtocol);
+	iIapId = settings->GetInt(KAttIapId);
+	iNetworkId = settings->GetInt(KAttNetId);
+	iDebug = settings->GetBool(KAttDebug);
+	
+	delete settings;
+	return KErrNone;
+	}
+
+void TRemoteConsoleConfig::PersistL() const
+	{
+	LtkUtils::CIniFile* settings = LtkUtils::CIniFile::NewL(KConfigFileName, KConfigDesciptionFile);
+	CleanupStack::PushL(settings);
+	
+	settings->SetL(KAttConnectionType, iConnectionType);
+	settings->SetL(KAttRemoteIpAddress, iRemoteHostName);
+	settings->SetL(KAttRemotePort, iRemotePort);
+	settings->SetL(KAttProtocol, iProtocol);
+	settings->SetL(KAttIapId, iIapId);
+	settings->SetL(KAttNetId, iNetworkId);
+	settings->SetL(KAttDebug, iDebug);
+	
+	settings->WriteL();
+	CleanupStack::PopAndDestroy(settings);
+	
+	}
+
+TRemoteConsoleConfig::TConnectionType TRemoteConsoleConfig::ConnectionType() const
+	{
+	return iConnectionType;
+	}
+
+const TDesC& TRemoteConsoleConfig::ConnectionTypeString() const
+	{
+	switch (iConnectionType)
+		{
+		case EImplicit:
+			{
+			return KConTypeImplicit;
+			}
+		case EExplicit:
+			{
+			return KConTypeExplicit;
+			}
+		default:
+			{
+			_LIT(KUnknownConnectionType, "unknown");
+			return KUnknownConnectionType;
+			}
+		}
+	}
+
+TUint TRemoteConsoleConfig::RemotePort() const
+	{
+	return iRemotePort;
+	}
+
+const TDesC& TRemoteConsoleConfig::RemoteHostName() const
+	{
+	return iRemoteHostName;
+	}
+
+TUint TRemoteConsoleConfig::Protocol() const
+	{
+	return iProtocol;
+	}
+
+TUint TRemoteConsoleConfig::IapId() const
+	{
+	return iIapId;
+	}
+	
+TUint TRemoteConsoleConfig::NetworkId() const
+	{
+	return iNetworkId;
+	}
+
+TBool TRemoteConsoleConfig::Debug() const
+	{
+	return iDebug;
+	}
+
+void TRemoteConsoleConfig::SetConnectionType(const TDesC& aConnectionType)
+	{
+	if (aConnectionType == KConTypeImplicit)
+		{
+		iConnectionType = EImplicit;
+		}
+	else if (aConnectionType == KConTypeExplicit)
+		{
+		iConnectionType = EExplicit;
+		}
+	else
+		{
+		iConnectionType = EImplicit;
+		}
+	}
+
+void TRemoteConsoleConfig::SetConnectionType(TConnectionType aType)
+	{
+	iConnectionType = aType;
+	}
+
+TInt TRemoteConsoleConfig::SetRemoteHostName(const TDesC& aName)
+	{
+	TInt err = KErrNone;
+	if (aName.Length() > iRemoteHostName.MaxLength())
+		{
+		err = KErrTooBig;
+		iRemoteHostName = aName.Left(iRemoteHostName.MaxLength());
+		}
+	else
+		{
+		iRemoteHostName = aName;
+		}
+	return err;
+	}
+
+void TRemoteConsoleConfig::SetRemotePort(TUint aPort)
+	{
+	iRemotePort = aPort;
+	}
+
+void TRemoteConsoleConfig::SetProtocol(TUint aProtocol)
+	{
+	iProtocol = aProtocol;
+	}
+
+void TRemoteConsoleConfig::SetIapId(TUint aIapId)
+	{
+	iIapId = aIapId;
+	}
+
+void TRemoteConsoleConfig::SetNetworkId(TUint aNetworkId)
+	{
+	iNetworkId = aNetworkId;
+	}
+
+void TRemoteConsoleConfig::SetDebug(TBool aDebug)
+	{
+	iDebug = aDebug;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/documentation/rcons.dll.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+# rcons.dll.pod
+#
+# Copyright (c) 2007-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 C<rcons.dll> - The Symbian OS Client Implementation
+
+=head2 Introduction
+
+To do.
+
+=head2 Installation
+
+To do.
+
+=head1 Copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/documentation/rcons.exe.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,35 @@
+# rcons.exe.pod
+#
+# Copyright (c) 2007-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 C<rcons.exe> - The Win32 Server Implementation
+
+=head2 Introduction
+
+C<rcons.exe> is the server side implementation of C<rcons>. It is a Win32 executable.
+
+=head2 Installation
+
+A build of F<fshell> puts F<rcons.exe> into F<\epoc32\tools>. No further installation is necessary.
+
+=head2 Configuration
+
+The most significant aspect of the server's configuration is the TCP port number that it listens on for in-coming connections from console clients. This must match the client side configuration. It can be changed on the server side using the menu C<File | Preferences | Listen on port:>. By default it is set to 8086.
+
+Something else to bear in mind is that if you have a firewall running on the network interface between your PC and your Symbian OS device, that will need to allow incomming connections on the relevant TCP port through. Note though that mRouter (Symbian's PC connectivity transport) will happily forward connections to TCP servers running on the same PC as itself, so if you're using mRouter as your transport firewalls shouldn't be a problem.
+
+=head1 Copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/documentation/rcons.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,43 @@
+# rcons.pod
+#
+# Copyright (c) 2007-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 F<rcons> - A Remote Console for Symbian OS
+
+=head2 Introduction
+
+F<rcons> has a client / server implementation. The client side (L<rcons.dll|rcons.dll>) runs on Symbian OS and the server side (L<rcons.exe|rcons.exe>) runs on a Win32 PC. The two sides communicate with one another via a pair of TCP/IP connections. The net result is that when something on the Symbian OS side creates a console, instead of a console window appearing on the Symbian OS hosted screen, a console window appears on the PC. This is a conventional Windows window that can be typed into using the PC's keyboard, resized using the PC's mouse, etc.
+
+In order for the client and server sides to communicate with one another, some kind of TCP transport needs to be in place. However, in most cases you shouldn't need to worry about the details of configuring a suitable transport as that should have already been done in your fshell distribution (assuming you're using supported hardware).
+
+The remainder of this documentation describes how to manually install and configure F<rcons>.
+
+=head2 Installation
+
+The PC side (L<rcons.exe|rcons.exe>) should already be installed in your development environment (assuming you did a full build of F<fshell>). Running it is simply as case of launching F<\epoc32\tools\rcons.exe>. This should create a new window that states the TCP port that the program is listening for connections on. Provided this matches the client side configuration, not further configuration of the server is necessary. For details of how to use the server side, see L<rcons.exe|rcons.exe>.
+
+There are more choices to be made regarding the installation of the Symbian OS side. See L<rcons.dll|rcons.dll> for more details, however by default C<fshell> installs and configures L<rcons.dll|rcons.dll> appropriately for most peoples needs. It is recommended that you try the default C<fshell> installation first, and only worry about different configurations if you need more flexibility.
+
+=head2 See Also
+
+L<rcons.exe|rcons.exe>
+
+L<rcons.dll|rcons.dll>
+
+L<fshell|fshell>
+
+=head1 Copyright
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,24 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE2(..\client\group\rcons.iby, rcons.iby)
+..\server\win32\rcons.exe       	\epoc32\tools\rcons.exe
+..\client\data\rcons.ini.emulator	\epoc32\winscw\c\system\console\rcons.ini
+..\client\data\rcons.idf		Z:\resource\rcons.idf
+
+PRJ_MMPFILES
+..\client\group\remote_console.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Base.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// Base.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// Description:
+// implementation of the CBase class.
+
+#include "Misc.h"
+#include "stdafx.h"
+#include "Base.h"
+
+LPCTSTR KUnamed = TEXT("Unamed");
+
+CBase::~CBase()
+	{
+	}
+
+void CBase::SetName(LPCTSTR aName)
+	{
+	iName = aName;
+	}
+
+CBase::CBase()
+	: iName(KUnamed)
+	{
+	}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Base.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// Base.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// Description:
+// Base.h: interface for the CBase class.
+
+#if !defined(AFX_BASE_H__531B81D8_F017_4998_92BA_35CB284A9B50__INCLUDED_)
+#define AFX_BASE_H__531B81D8_F017_4998_92BA_35CB284A9B50__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "StdAfx.h"
+
+class CBase  
+	{
+public:
+	virtual ~CBase();
+	void SetName(LPCTSTR aName);
+protected:
+	CBase();
+private:
+	LPCTSTR iName;
+	};
+
+#endif // !defined(AFX_BASE_H__531B81D8_F017_4998_92BA_35CB284A9B50__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/ClientSocket.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,156 @@
+// ClientSocket.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+#include "ClientSocket.h"
+#include "DynamicBuffer.h"
+
+const int KInitialBufferLength = 1;
+const int KNotifyReadComplete = 9000;
+
+
+CClientSocket* CClientSocket::New(CWindow& aWindow, SOCKET aSocket)
+	{
+	std::auto_ptr<CClientSocket> self(new(EThrow) CClientSocket(aWindow, aSocket));
+	self->Construct();
+	return self.release();
+	}
+
+CClientSocket::CClientSocket(CWindow& aWindow, SOCKET aSocket)
+	: CSocket(aWindow, aSocket), iReadHandler(NULL), iReadBuf(NULL), iReadLength(0)
+	{
+	}
+
+void CClientSocket::Read(char* aBuf, int aLength, MSocketReadHandler& aHandler)
+	{
+	ASSERT(iReadHandler == NULL);
+	iReadBuf = aBuf;
+	iReadLength = aLength;
+	iReadHandler = &aHandler;
+	HandleRead(FALSE);
+	}
+
+void CClientSocket::Write(char* aBuf, int aLength)
+	{
+	iWriteBuf->Add(aBuf, aLength);
+	HandleWrite();
+	}
+
+CClientSocket::~CClientSocket()
+	{
+	delete iWriteBuf;
+	}
+
+void CClientSocket::Construct()
+	{
+	CSocket::Construct();
+
+	if (WSAAsyncSelect(iSocket, iWindow.Handle(), KSocketMessage, FD_READ | FD_WRITE | FD_CLOSE) == SOCKET_ERROR)
+		{
+		throw KExceptionSocketSelectFailed;
+		}
+
+	iWriteBuf = CDynamicWriteBuffer::New(KInitialBufferLength);
+	}
+
+void CClientSocket::HandleRead(bool aNotifySynchronously)
+	{
+	if (iReadLength > 0)
+		{
+		int ret = recv(iSocket, iReadBuf, iReadLength, 0);
+		if (ret == SOCKET_ERROR)
+			{
+			if (WSAGetLastError() != WSAEWOULDBLOCK)
+				{
+				HandleClosure();
+				}
+			}
+		else if (ret == 0)
+			{
+			HandleClosure();
+			}
+		else
+			{
+			iReadLength -= ret;
+			ASSERT(iReadLength >= 0);
+			if (iReadLength == 0)
+				{
+				if (aNotifySynchronously)
+					{
+					NotifyReadComplete();
+					}
+				else
+					{
+					PostMessage(iWindow.Handle(), KSocketMessage, iSocket, KNotifyReadComplete);
+					}
+				}
+			else
+				{
+				iReadBuf += ret;
+				}
+			}
+		}
+	}
+
+void CClientSocket::HandleWrite()
+	{
+	if (iWriteBuf->Length() > 0)
+		{
+		int ret = send(iSocket, iWriteBuf->Buffer(), iWriteBuf->Length(), 0);
+		if (ret == SOCKET_ERROR)
+			{
+			if (WSAGetLastError() != WSAEWOULDBLOCK)
+				{
+				HandleClosure();
+				}
+			}
+		else if (ret == 0)
+			{
+			HandleClosure();
+			}
+		else
+			{
+			iWriteBuf->Remove(ret);
+			}
+		}
+	}
+
+void CClientSocket::NotifyReadComplete()
+	{
+	ASSERT(iReadHandler);
+	MSocketReadHandler* readHandler = iReadHandler;
+	iReadBuf = NULL;
+	iReadLength = 0;
+	iReadHandler = NULL;
+	readHandler->SocketReadComplete();
+	}
+
+LRESULT CClientSocket::HandleSocketMessage(LPARAM aLParam)
+	{
+	switch (WSAGETSELECTEVENT(aLParam))
+		{
+		case FD_READ:
+			HandleRead(TRUE);
+			break;
+		case FD_WRITE:
+			HandleWrite();
+			break;
+		case KNotifyReadComplete:
+			NotifyReadComplete();
+			break;
+		default:
+			ASSERT(FALSE);
+		}
+	return 0;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/ClientSocket.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,54 @@
+// ClientSocket.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_CLIENTSOCKET_H__BF5D862F_0F6A_4476_88DD_81F067F299E5__INCLUDED_)
+#define AFX_CLIENTSOCKET_H__BF5D862F_0F6A_4476_88DD_81F067F299E5__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "Socket.h"
+
+class CDynamicWriteBuffer;
+
+
+class MSocketReadHandler
+	{
+public:
+	virtual void SocketReadComplete() = 0;
+	};
+
+
+class CClientSocket : public CSocket
+	{
+public:
+	static CClientSocket* New(CWindow& aWindow, SOCKET aSocket);
+	virtual ~CClientSocket();
+	void Read(char* aBuf, int aLength, MSocketReadHandler& aHandler);
+	void Write(char* aBuf, int aLength);
+private:
+	CClientSocket(CWindow& aWindow, SOCKET aSocket);
+	void Construct();
+	void HandleRead(bool aNotifySynchronously);
+	void HandleWrite();
+	void NotifyReadComplete();
+protected: // From CSocket.
+	virtual LRESULT HandleSocketMessage(LPARAM aLParam);
+private:
+	MSocketReadHandler* iReadHandler;
+	char* iReadBuf;
+	int iReadLength;
+	CDynamicWriteBuffer* iWriteBuf;
+	};
+
+#endif // !defined(AFX_CLIENTSOCKET_H__BF5D862F_0F6A_4476_88DD_81F067F299E5__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/ConsoleWindow.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,363 @@
+// ConsoleWindow.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "Misc.h"
+#include <windowsx.h>
+#include "stdafx.h"
+#include "ConsoleWindow.h"
+#include "TextBuffer.h"
+#include "TextView.h"
+#include "resource.h"
+
+const int KMaxFormatBuf = 256;
+
+
+CConsoleWindow* CConsoleWindow::New(HINSTANCE aAppHandle, LPCTSTR aWindowClass, LPCTSTR aTitle, int aPosX, int aPosY, int aWidth, int aHeight, int aNumOverflowLines, MWindowObserver* aWindowObserver, MConsoleCharHandler* aCharHandler, bool aNoSelection)
+	{
+	std::auto_ptr<CConsoleWindow> self(new(EThrow) CConsoleWindow(aNoSelection));
+	self->Construct(aAppHandle, aWindowClass, aTitle, aPosX, aPosY, aWidth, aHeight, aNumOverflowLines, aWindowObserver, aCharHandler);
+	return self.release();
+	}
+
+CConsoleWindow::~CConsoleWindow()
+	{
+	delete iView;
+	delete iBuffer;
+	}
+
+void CConsoleWindow::Write(LPCTSTR aString)
+	{
+	Write(aString, wcslen(aString));
+	}
+
+void CConsoleWindow::Write(LPCTSTR aString, int aLength)
+	{
+	iView->BeginUpdate();
+	iBuffer->Write(aString, aLength);
+	iView->EndUpdate();
+	}
+
+void CConsoleWindow::WriteFormat(LPCTSTR aFormat, ...)
+	{
+	va_list args;
+	va_start(args, aFormat);
+	TCHAR buf[KMaxFormatBuf];
+	int length = _vsnwprintf(buf, KMaxFormatBuf, aFormat, args);
+	Write(buf, length);
+	}
+
+void CConsoleWindow::GetCursorPos(int& aX, int& aY)
+	{
+	iBuffer->GetCursorPos(aX, aY);
+	}
+
+void CConsoleWindow::SetAbsCursorPos(int aX, int aY)
+	{
+	iView->BeginUpdate();
+	iBuffer->SetAbsCursorPos(aX, aY);
+	iView->EndUpdate();
+	}
+
+void CConsoleWindow::SetRelCursorPos(int aX, int aY)
+	{
+	iView->BeginUpdate();
+	iBuffer->SetRelCursorPos(aX, aY);
+	iView->EndUpdate();
+	}
+
+void CConsoleWindow::SetCursorHeight(int aHeight)
+	{
+	(aHeight > 0) ? iView->EnableCursor() : iView->DisableCursor();
+	}
+
+void CConsoleWindow::GetConsoleSize(int& aWidth, int& aHeight)
+	{
+	iBuffer->GetSize(aWidth, aHeight);
+	}
+
+void CConsoleWindow::ClearScreen()
+	{
+	iView->BeginUpdate();
+	iBuffer->Clear();
+	iView->EndUpdate();
+	}
+
+void CConsoleWindow::ClearToEndOfLine()
+	{
+	iView->BeginUpdate();
+	iBuffer->ClearToEndOfLine();
+	iView->EndUpdate();
+	}
+
+void CConsoleWindow::CaptureToFile(LPCTSTR aFileName)
+	{
+	iBuffer->CaptureToFile(aFileName);
+	}
+
+void CConsoleWindow::StopCaptureToFile()
+	{
+	iBuffer->StopCaptureToFile();
+	}
+
+bool CConsoleWindow::IsCapturingToFile() const
+	{
+	return iBuffer->IsCapturingToFile();
+	}
+
+void CConsoleWindow::PasteFromClipboard()
+	{
+	if (iCharHandler && OpenClipboard(Handle())) 
+		{
+		HGLOBAL hglb = GetClipboardData(CF_TEXT);
+		if (hglb)
+			{
+			char* narrowBuf = (char*)GlobalLock(hglb);
+			if (narrowBuf)
+				{
+				LPTSTR wideBuf;
+				int length = strlen(narrowBuf);
+				ConvertNarrowToWideAlloc(narrowBuf, length, wideBuf);
+				if (wideBuf)
+					{
+					iCharHandler->HandleConsoleString(wideBuf, length);
+					delete wideBuf;
+					}
+				GlobalUnlock(hglb);
+				}
+			}
+		CloseClipboard(); 
+		}
+	}
+
+void CConsoleWindow::CopyToClipboard() const
+	{
+    if (OpenClipboard(Handle())) 
+		{
+	    EmptyClipboard();
+		LPTSTR wideSelection = iView->Selection();
+		if (wideSelection)
+			{
+			int length = wcslen(wideSelection);
+			HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (length + 1) * sizeof(TCHAR));
+			if (hglbCopy)
+				{
+				char* narrowBuf = (char*)GlobalLock(hglbCopy);
+				ConvertWideToNarrow(wideSelection, length, narrowBuf);
+				GlobalUnlock(hglbCopy);
+				SetClipboardData(CF_TEXT, hglbCopy);
+				iView->ClearSelection();
+				}
+			delete wideSelection;
+			}
+		CloseClipboard();
+		}
+	}
+
+void CConsoleWindow::SetDimmed(bool aDimmed)
+	{
+	iView->SetDimmed(aDimmed);
+	}
+
+CConsoleWindow::CConsoleWindow(bool aNoSelection) : iCharHandler(NULL), iBuffer(NULL), iView(NULL), iNoSelection(aNoSelection)
+	{
+	}
+
+void CConsoleWindow::Construct(HINSTANCE aAppHandle, LPCTSTR aWindowClass, LPCTSTR aTitle, int aPosX, int aPosY, int aCharWidth, int aCharHeight, int aNumOverflowLines, MWindowObserver* aWindowObserver, MConsoleCharHandler* aCharHandler)
+	{
+	iCharHandler = aCharHandler;
+
+	int numHorizChars = (aCharWidth == -1) ? 80 : aCharWidth;
+	int numVertChars = (aCharHeight == -1) ? 40 : aCharHeight;
+
+	iBuffer = CTextBuffer::New(numHorizChars, numVertChars, aNumOverflowLines);
+	iView = CTextView::New(*this, *iBuffer, aCharWidth, aCharHeight);
+	if (!iCharHandler)
+		{
+		iView->DisableCursor();
+		}
+
+	int pixelWidth;
+	int pixelHeight;
+	iView->GetSize(pixelWidth, pixelHeight);
+
+	CWindow::Construct(aAppHandle, aWindowClass, aTitle, aPosX, aPosY, pixelWidth, pixelHeight, aWindowObserver);
+	}
+
+void CConsoleWindow::Draw() const
+	{
+	iView->Draw();
+	}
+
+LRESULT CConsoleWindow::HandleChar(TCHAR aChar, UINT aModifiers)
+	{
+	if (iCharHandler)
+		{
+		iView->ScrollToEndIfNeeded();
+		iCharHandler->HandleConsoleChar(aChar, aModifiers);
+		}
+	return 0;
+	}
+
+LRESULT CConsoleWindow::HandleFocusChange(bool aFocused)
+	{
+	aFocused ? iView->HandleFocusGained() : iView->HandleFocusLost();
+	return 0;
+	}
+
+void CConsoleWindow::HandleScrollEvent(UINT aMessage, WPARAM aWParam)
+	{
+	int scrollDir = (aMessage == WM_HSCROLL) ? SB_HORZ : SB_VERT;
+	SCROLLINFO scrollInfo;
+	scrollInfo.cbSize = sizeof(scrollInfo);
+	scrollInfo.fMask = SIF_ALL;
+	GetScrollInfo(Handle(), scrollDir, &scrollInfo);
+	int pos = scrollInfo.nPos;
+	switch (LOWORD(aWParam))
+		{
+		case SB_LINEUP:		// Also SB_LINELEFT.
+			scrollInfo.nPos -= (aMessage == WM_HSCROLL) ? iView->CharWidth() : iView->CharHeight();
+			break;
+		case SB_LINEDOWN:	// Also SB_LINERIGHT.
+			scrollInfo.nPos += (aMessage == WM_HSCROLL) ? iView->CharWidth() : iView->CharHeight();
+			break;
+		case SB_PAGEUP:		// Also SB_PAGELEFT.
+			scrollInfo.nPos -= scrollInfo.nPage;
+			break;
+		case SB_PAGEDOWN:	// Also SB_PAGERIGHT.
+			scrollInfo.nPos += scrollInfo.nPage;
+			break;
+		case SB_THUMBTRACK: 
+			scrollInfo.nPos = scrollInfo.nTrackPos;
+			break;
+		default:
+			break;
+		}
+	scrollInfo.fMask = SIF_POS;
+	SetScrollInfo (Handle(), scrollDir, &scrollInfo, TRUE);
+	GetScrollInfo (Handle(), scrollDir, &scrollInfo);
+	if (scrollInfo.nPos != pos)
+		{
+		if (aMessage == WM_HSCROLL)
+			{
+			iView->SetHorzScrollPosition(scrollInfo.nPos);
+			}
+		else
+			{
+			iView->SetVertScrollPosition(scrollInfo.nPos);
+			}
+		}
+	}
+
+void CConsoleWindow::HandleSizeChanged(int aWidth, int aHeight)
+	{
+	iView->SetSize(aWidth, aHeight);
+	}
+
+void CConsoleWindow::HandleMouseEvent(UINT aMessage, WPARAM aWParam, LPARAM aLParam)
+	{
+	if (!iNoSelection)
+		{
+		switch(aMessage)
+			{
+			case WM_LBUTTONDOWN:
+				{
+				SetCapture(Handle());
+				iView->StartSelection(GET_X_LPARAM(aLParam), GET_Y_LPARAM(aLParam));
+				break;
+				}
+			case WM_LBUTTONDBLCLK:
+				{
+				iView->SelectWord(GET_X_LPARAM(aLParam), GET_Y_LPARAM(aLParam));
+				break;
+				}
+			case WM_MOUSEMOVE:
+				{
+				RECT clientRect;
+				GetClientRect(Handle(), &clientRect);
+				POINT mousePos = { GET_X_LPARAM(aLParam), GET_Y_LPARAM(aLParam) };
+				if ((mousePos.x > clientRect.right) || (mousePos.x < clientRect.left))
+					{
+					SCROLLINFO scrollInfo;
+					scrollInfo.cbSize = sizeof(scrollInfo);
+					scrollInfo.fMask = SIF_POS;
+					GetScrollInfo(Handle(), SB_HORZ, &scrollInfo);
+					if (mousePos.x > clientRect.right)
+						{
+						scrollInfo.nPos += iView->CharWidth();
+						}
+					else
+						{
+						scrollInfo.nPos -= iView->CharWidth();
+						}
+					SetScrollInfo (Handle(), SB_HORZ, &scrollInfo, TRUE);
+					GetScrollInfo (Handle(), SB_HORZ, &scrollInfo);
+					iView->SetHorzScrollPosition(scrollInfo.nPos);
+					}
+				if ((mousePos.y < clientRect.top) || (mousePos.y > clientRect.bottom))
+					{
+					SCROLLINFO scrollInfo;
+					scrollInfo.cbSize = sizeof(scrollInfo);
+					scrollInfo.fMask = SIF_POS;
+					GetScrollInfo(Handle(), SB_VERT, &scrollInfo);
+					if (mousePos.y < clientRect.top)
+						{
+						scrollInfo.nPos -= iView->CharHeight();
+						}
+					else
+						{
+						scrollInfo.nPos += iView->CharHeight();
+						}
+					SetScrollInfo (Handle(), SB_VERT, &scrollInfo, TRUE);
+					GetScrollInfo (Handle(), SB_VERT, &scrollInfo);
+					iView->SetVertScrollPosition(scrollInfo.nPos);
+					}
+
+				iView->AdjustSelection(GET_X_LPARAM(aLParam), GET_Y_LPARAM(aLParam));
+				break;
+				}
+			case WM_LBUTTONUP:
+				{
+				ReleaseCapture();
+				iView->EndSelection(GET_X_LPARAM(aLParam), GET_Y_LPARAM(aLParam));
+				break;
+				}
+			default:
+				{
+				break;
+				}
+			}
+		}
+	}
+
+void CConsoleWindow::HandleMenuPopUp(HMENU aMenu)
+	{
+	int numMenuItems = GetMenuItemCount(aMenu);
+	for (int i = 0; i < numMenuItems; ++i)
+		{
+		switch (GetMenuItemID(aMenu, i))
+			{
+			case ID_EDIT_COPY:
+				{
+				EnableMenuItem(aMenu, ID_EDIT_COPY, iView->SelectionAvailable() ? MF_BYCOMMAND | MF_ENABLED : MF_BYCOMMAND | MF_GRAYED);
+				break;
+				}
+			case ID_EDIT_PASTE:
+				{
+				EnableMenuItem(aMenu, ID_EDIT_PASTE, iCharHandler && IsClipboardFormatAvailable(CF_TEXT) ? MF_BYCOMMAND | MF_ENABLED : MF_BYCOMMAND | MF_GRAYED);
+				break;
+				}
+			default:
+				{
+				break;
+				}
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/ConsoleWindow.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,73 @@
+// ConsoleWindow.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_CONSOLEWINDOW_H__F891F8FC_FA99_41C1_93FB_6C1BB31F655D__INCLUDED_)
+#define AFX_CONSOLEWINDOW_H__F891F8FC_FA99_41C1_93FB_6C1BB31F655D__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "Window.h"
+
+class CTextBuffer;
+class CTextView;
+
+
+class MConsoleCharHandler
+	{
+public:
+	virtual void HandleConsoleChar(TCHAR aChar, UINT aModifiers) = 0;
+	virtual void HandleConsoleString(LPCTSTR aString, int aLength) = 0;
+	};
+
+
+class CConsoleWindow : public CWindow
+	{
+public:
+	static CConsoleWindow* New(HINSTANCE aAppHandle, LPCTSTR aWindowClass, LPCTSTR aTitle, int aPosX, int aPosY, int aCharWidth, int aCharHeight, int aNumOverflowLines, MWindowObserver* aWindowObserver, MConsoleCharHandler* aCharHandler, bool aNoSelection);
+	virtual ~CConsoleWindow();
+	void Write(LPCTSTR aString);
+	void Write(LPCTSTR aString, int aLength);
+	void WriteFormat(LPCTSTR aFormat, ...);
+	void GetCursorPos(int& aX, int& aY);
+	void SetAbsCursorPos(int aX, int aY);
+	void SetRelCursorPos(int aX, int aY);
+	void SetCursorHeight(int aHeight);
+	void GetConsoleSize(int& aWidth, int& aHeight);
+	void ClearScreen();
+	void ClearToEndOfLine();
+	void CaptureToFile(LPCTSTR aFileName);
+	void StopCaptureToFile();
+	bool IsCapturingToFile() const;
+	void PasteFromClipboard();
+	void CopyToClipboard() const;
+	void SetDimmed(bool aDimmed);
+private:
+	CConsoleWindow(bool aNoSelection);
+	void Construct(HINSTANCE aAppHandle, LPCTSTR aWindowClass, LPCTSTR aTitle, int aPosX, int aPosY, int aWidth, int aHeight, int aNumOverflowLines, MWindowObserver* aWindowObserver, MConsoleCharHandler* aCharHandler);
+private: // From CWindow.
+	virtual void Draw() const;
+	virtual LRESULT HandleChar(TCHAR aChar, UINT aModifiers);
+	virtual LRESULT HandleFocusChange(bool aFocused);
+	virtual void HandleScrollEvent(UINT aMessage, WPARAM aWParam);
+	virtual void HandleSizeChanged(int aWidth, int aHeight);
+	virtual void HandleMouseEvent(UINT aMessage, WPARAM aWParam, LPARAM aLParam);
+	virtual void HandleMenuPopUp(HMENU aMenu);
+private:
+	MConsoleCharHandler* iCharHandler;
+	CTextBuffer* iBuffer;
+	CTextView* iView;
+	bool iNoSelection;
+	};
+
+#endif // !defined(AFX_CONSOLEWINDOW_H__F891F8FC_FA99_41C1_93FB_6C1BB31F655D__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/DynamicBuffer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,123 @@
+// DynamicBuffer.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+#include "console_host.h"
+#include "DynamicBuffer.h"
+
+
+CDynamicReadBuffer* CDynamicReadBuffer::New(int aInitialLength)
+	{
+	std::auto_ptr<CDynamicReadBuffer> self(new(EThrow) CDynamicReadBuffer());
+	self->Construct(aInitialLength);
+	return self.release();
+	}
+
+CDynamicReadBuffer::~CDynamicReadBuffer()
+	{
+	delete iBuf;
+	}
+
+const char* CDynamicReadBuffer::Buffer() const
+	{
+	return iBuf;
+	}
+
+char* CDynamicReadBuffer::Buffer(int aLength)
+	{
+	if (aLength > iMaxBufLength)
+		{
+		GrowBuf(aLength);
+		}
+	return iBuf;
+	}
+
+CDynamicReadBuffer::CDynamicReadBuffer() : iBuf(NULL), iMaxBufLength(0)
+	{
+	}
+
+void CDynamicReadBuffer::Construct(int aInitialLength)
+	{
+	GrowBuf(aInitialLength);
+	}
+
+void CDynamicReadBuffer::GrowBuf(int aNewLength)
+	{
+	ASSERT(aNewLength > iMaxBufLength);
+	char* newBuf = new(EThrow) char[aNewLength];
+	delete iBuf;
+	iBuf = newBuf;
+	iMaxBufLength = aNewLength;
+	}
+
+
+CDynamicWriteBuffer* CDynamicWriteBuffer::New(int aInitialLength)
+	{
+	std::auto_ptr<CDynamicWriteBuffer> self(new(EThrow) CDynamicWriteBuffer());
+	self->Construct(aInitialLength);
+	return self.release();
+	}
+
+CDynamicWriteBuffer::~CDynamicWriteBuffer()
+	{
+	delete iBuf;
+	}
+
+void CDynamicWriteBuffer::Add(char* aBuf, int aLength)
+	{
+	if (aLength > (iMaxBufLength - iCurrentBufLength))
+		{
+		GrowBuf(iCurrentBufLength + aLength);
+		}
+	memcpy(iBuf + iCurrentBufLength, aBuf, aLength);
+	iCurrentBufLength += aLength;
+	}
+
+void CDynamicWriteBuffer::Remove(int aLength)
+	{
+	ASSERT(aLength <= iCurrentBufLength);
+	memmove(iBuf, iBuf + aLength, iCurrentBufLength - aLength);
+	iCurrentBufLength -= aLength;
+	}
+
+const char* CDynamicWriteBuffer::Buffer() const
+	{
+	return iBuf;
+	}
+
+int CDynamicWriteBuffer::Length() const
+	{
+	return iCurrentBufLength;
+	}
+
+CDynamicWriteBuffer::CDynamicWriteBuffer() : iBuf(NULL), iMaxBufLength(0), iCurrentBufLength(0)
+	{
+	}
+
+void CDynamicWriteBuffer::Construct(int aInitialLength)
+	{
+	GrowBuf(aInitialLength);
+	}
+
+void CDynamicWriteBuffer::GrowBuf(int aNewLength)
+	{
+	ASSERT(aNewLength > iMaxBufLength);
+	char* newBuf = new(EThrow) char[aNewLength];
+	if (iBuf)
+		{
+		memcpy(newBuf, iBuf, iCurrentBufLength);
+		delete iBuf;
+		}
+	iBuf = newBuf;
+	iMaxBufLength = aNewLength;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/DynamicBuffer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,57 @@
+// DynamicBuffer.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_DYNAMICBUFFER_H__FC5FE4BC_8299_4843_BC15_E5B01611B9E2__INCLUDED_)
+#define AFX_DYNAMICBUFFER_H__FC5FE4BC_8299_4843_BC15_E5B01611B9E2__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+class CDynamicReadBuffer  
+	{
+public:
+	static CDynamicReadBuffer* New(int aInitialLength);
+	virtual ~CDynamicReadBuffer();
+	const char* Buffer() const;
+	char* Buffer(int aLength);
+private:
+	CDynamicReadBuffer();
+	void Construct(int aInitialLength);
+	void GrowBuf(int aNewLength);
+private:
+	char* iBuf;
+	int iMaxBufLength;
+	};
+
+
+class CDynamicWriteBuffer  
+	{
+public:
+	static CDynamicWriteBuffer* New(int aInitialLength);
+	virtual ~CDynamicWriteBuffer();
+	void Add(char* aBuf, int aLength);
+	void Remove(int aLength);
+	const char* Buffer() const;
+	int Length() const;
+private:
+	CDynamicWriteBuffer();
+	void Construct(int aInitialLength);
+	void GrowBuf(int aNewLength);
+private:
+	char* iBuf;
+	int iMaxBufLength;
+	int iCurrentBufLength;
+	};
+
+#endif // !defined(AFX_DYNAMICBUFFER_H__FC5FE4BC_8299_4843_BC15_E5B01611B9E2__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Misc.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,100 @@
+// Misc.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "Misc.h"
+
+void* operator new(size_t n, TThrow)
+	{
+	void* cell = ::operator new(n);
+	if (!cell)
+		{
+		throw KExceptionNoMemory;
+		}
+	return cell;
+	}
+
+void operator delete(void* const p, TThrow)
+	{
+	::operator delete(p);
+	}
+
+void* operator new[](size_t n, TThrow)
+	{
+	void* cell = ::operator new[](n);
+	if (!cell)
+		{
+		throw KExceptionNoMemory;
+		}
+	return cell;
+	}
+
+void operator delete[](void* const p, TThrow)
+	{
+	::operator delete[](p);
+	}
+
+void Panic()
+	{
+	_asm int 3;
+	}
+
+void DebugLog(LPCTSTR aFormat, ...)
+	{
+	const int KMaxFormatBuf = 256;
+	va_list args;
+	va_start(args, aFormat);
+	TCHAR buf[KMaxFormatBuf];
+	int length = _vsnwprintf(buf, KMaxFormatBuf, aFormat, args);
+	OutputDebugString(buf);
+	OutputDebugString(TEXT("\r\n"));
+	}
+
+bool FileExists(LPCTSTR aFileName)
+	{
+	int att = GetFileAttributes(aFileName);
+	return (att > 0);
+	}
+
+void ConvertNarrowToWide(const char* aNarrow, int aLength, WCHAR* aWide)
+	{
+	for (int i = 0; i < aLength; ++i)
+		{
+		aWide[i] = (unsigned short)aNarrow[i];
+		}
+	aWide[aLength] = TCHAR('\0');
+	}
+
+void ConvertNarrowToWideAlloc(const char* aNarrow, int aLength, WCHAR*& aWide)
+	{
+	aWide = new WCHAR[aLength + 1];
+	if (aWide)
+		{
+		ConvertNarrowToWide(aNarrow, aLength, aWide);
+		}
+	}
+
+void ConvertWideToNarrow(const WCHAR* aWide, int aLength, char* aNarrow)
+	{
+	for (int i = 0; i < aLength; ++i)
+		{
+		aNarrow[i] = (char)aWide[i];
+		}
+	aNarrow[aLength] = '\0';
+	}
+
+void ConvertWideToNarrowAlloc(const WCHAR* aWide, int aLength, char*& aNarrow)
+	{
+	aNarrow = new char[aLength + 1];
+	if (aNarrow)
+		{
+		ConvertWideToNarrow(aWide, aLength, aNarrow);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Misc.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,65 @@
+// Misc.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef __MISC_H__
+#define __MISC_H__
+
+#define UNICODE
+
+#include <memory>
+#include "stdafx.h"
+
+enum TException
+	{
+	KExceptionNoMemory,
+	KExceptionWindowClassRegistrationFailed,
+	KExceptionWindowConstructFailed,
+	KExceptionConsoleWindowConstructFailed,
+	KExceptionWinSockStartupFailed,
+	KExceptionWinSockVersionInvalid,
+	KExceptionSocketConstructFailed,
+	KExceptionSocketBindFailed,
+	KExceptionSocketSelectFailed,
+	KExceptionSocketListenFailed,
+	KExceptionSocketAcceptFailed,
+	KExceptionSocketReadFailed,
+	KExceptionInvalidClientVersion,
+	KExceptionFailedToFindPrefsFileName,
+	KExceptionFailedToReadPrefsFile,
+	KExceptionFailedToWritePrefsFile,
+	KExceptionFailedToCreateCaptureFile,
+	KExceptionFailedToWriteToCaptureFile,
+	KExceptionFailedToDeleteExistingCaptureFile,
+	KExceptionUnknown
+	};
+
+enum TThrow { EThrow = 0 };
+void* operator new(size_t n, TThrow);
+void operator delete(void* const p, TThrow);
+
+void* operator new[](size_t, TThrow);
+void operator delete[](void* const p, TThrow);
+
+#ifdef _DEBUG
+#define ASSERT(x) if (!(x)) Panic()
+#else
+#define ASSERT(x)
+#endif
+
+void Panic();
+void DebugLog(LPCTSTR aFormat, ...);
+bool FileExists(LPCTSTR aFileName);
+void ConvertNarrowToWide(const char* aNarrow, int aLength, WCHAR* aWide);
+void ConvertNarrowToWideAlloc(const char* aNarrow, int aLength, WCHAR*& aWide);
+void ConvertWideToNarrow(const WCHAR* aWide, int aLength, char* aNarrow);
+void ConvertWideToNarrowAlloc(const WCHAR* aWide, int aLength, char*& aNarrow);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Preferences.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,191 @@
+// Preferences.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include <fcntl.h>
+#include <io.h>
+#include <sys/stat.h>
+#include "stdafx.h"
+#include "shlwapi.h"
+#include "Preferences.h"
+
+const int KMaxFileNameLength = MAX_PATH;
+LPCTSTR KPrefsFileName = TEXT("\\console_host.ini");
+static bool sPrefsModified = FALSE;
+
+
+TPreferences::TPreferences()
+	: iServerPort(8086), iDefaultWindowWidth(80), iDefaultWindowHeight(40), iDefaultWindowPosX(0), iDefaultWindowPosY(0), iSystemPositionedWindows(TRUE), iNumOverflowLines(100)
+	{
+	wcscpy(iDefaultCaptureFilePath, TEXT("c:\\"));
+	}
+
+void PrefsFileName(LPTSTR aName)
+	{
+	if (GetModuleFileName(NULL, aName, KMaxFileNameLength) == 0)
+		{
+		throw KExceptionFailedToFindPrefsFileName;
+		}
+	if (PathRemoveFileSpec(aName) == 0)
+		{
+		throw KExceptionFailedToFindPrefsFileName;
+		}
+	if (wcscat(aName, KPrefsFileName) == 0)
+		{
+		throw KExceptionFailedToFindPrefsFileName;
+		}
+	}
+
+void TPreferences::Read()
+	{
+	TCHAR fileName[MAX_PATH];
+	PrefsFileName(fileName);
+	int file = _wopen(fileName, _O_RDWR | _O_BINARY);
+	if (file != -1)
+		{
+		int err = 0;
+		struct _stat fileStat;
+		if (_fstat(file, &fileStat) == 0)
+			{
+			if (_read(file, this, fileStat.st_size) < fileStat.st_size)
+				{
+				err = 1;
+				}
+			}
+		_close(file);
+		if (err)
+			{
+			throw KExceptionFailedToReadPrefsFile;
+			}
+		}
+	}
+
+void TPreferences::Write() const
+	{
+	if (sPrefsModified)
+		{
+		int err = 0;
+		TCHAR fileName[MAX_PATH];
+		PrefsFileName(fileName);
+		int file = _wopen(fileName, _O_CREAT | _O_WRONLY | _O_BINARY, _S_IWRITE);
+		if (file != -1)
+			{
+			int err = 0;
+			if (_write(file, this, sizeof(TPreferences)) < sizeof(TPreferences))
+				{
+				err = 1;
+				}
+			_close(file);
+			}
+		else
+			{
+			err = 1;
+			}
+		if (err)
+			{
+			_wremove(fileName);
+			throw KExceptionFailedToWritePrefsFile;
+			}
+		else
+			{
+			sPrefsModified = FALSE;
+			}
+		}
+	}
+
+unsigned short TPreferences::ServerPort() const
+	{
+	return iServerPort;
+	}
+
+unsigned int TPreferences::DefaultWindowWidth() const
+	{
+	return iDefaultWindowWidth;
+	}
+
+unsigned int TPreferences::DefaultWindowHeight() const
+	{
+	return iDefaultWindowHeight;
+	}
+
+unsigned int TPreferences::DefaultWindowPosX() const
+	{
+	return iDefaultWindowPosX;
+	}
+
+unsigned int TPreferences::DefaultWindowPosY() const
+	{
+	return iDefaultWindowPosY;
+	}
+
+int TPreferences::SystemPositionedWindows() const
+	{
+	return iSystemPositionedWindows;
+	}
+
+unsigned int TPreferences::NumOverflowLines() const
+	{
+	return iNumOverflowLines;
+	}
+
+LPCTSTR TPreferences::DefaultCaptureFilePath() const
+	{
+	return iDefaultCaptureFilePath;
+	}
+
+void TPreferences::SetServerPort(unsigned short aPort)
+	{
+	iServerPort = aPort;
+	sPrefsModified = TRUE;
+	}
+
+void TPreferences::SetDefaultWindowWidth(unsigned int aWidth)
+	{
+	iDefaultWindowWidth = aWidth;
+	sPrefsModified = TRUE;
+	}
+
+void TPreferences::SetDefaultWindowHeight(unsigned int aHeight)
+	{
+	iDefaultWindowHeight = aHeight;
+	sPrefsModified = TRUE;
+	}
+
+void TPreferences::SetDefaultWindowPosX(unsigned int aPosX)
+	{
+	iDefaultWindowPosX = aPosX;
+	sPrefsModified = TRUE;
+	}
+
+void TPreferences::SetDefaultWindowPosY(unsigned int aPosY)
+	{
+	iDefaultWindowPosY = aPosY;
+	sPrefsModified = TRUE;
+	}
+
+void TPreferences::SetSystemPositionedWindows(int aSystemPositionedWindows)
+	{
+	iSystemPositionedWindows = aSystemPositionedWindows;
+	sPrefsModified = TRUE;
+	}
+
+void TPreferences::SetNumOverflowLines(unsigned int aNumOverflowLines)
+	{
+	iNumOverflowLines = aNumOverflowLines;
+	sPrefsModified = TRUE;
+	}
+
+void TPreferences::SetDefaultCaptureFilePath(LPCTSTR aPath)
+	{
+	wcscpy(iDefaultCaptureFilePath, aPath);
+	sPrefsModified = TRUE;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Preferences.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,53 @@
+// Preferences.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+
+#ifndef __PREFERENCES_H__
+#define __PREFERENCES_H__
+
+
+class TPreferences
+	{
+public:
+	TPreferences();
+	void Read();
+	void Write() const;
+	unsigned short ServerPort() const;
+	unsigned int DefaultWindowWidth() const;
+	unsigned int DefaultWindowHeight() const;
+	unsigned int DefaultWindowPosX() const;
+	unsigned int DefaultWindowPosY() const;
+	int SystemPositionedWindows() const;
+	unsigned int NumOverflowLines() const;
+	LPCTSTR DefaultCaptureFilePath() const;
+	void SetServerPort(unsigned short aPort);
+	void SetDefaultWindowWidth(unsigned int aWidth);
+	void SetDefaultWindowHeight(unsigned int aHeight);
+	void SetDefaultWindowPosX(unsigned int aPosX);
+	void SetDefaultWindowPosY(unsigned int aPosY);
+	void SetSystemPositionedWindows(int aSystemPositionedWindows);
+	void SetNumOverflowLines(unsigned int aNumOverflowLines);
+	void SetDefaultCaptureFilePath(LPCTSTR aPath);
+private:
+	unsigned short iServerPort;
+	unsigned int iDefaultWindowWidth;
+	unsigned int iDefaultWindowHeight;
+	unsigned int iDefaultWindowPosX;
+	unsigned int iDefaultWindowPosY;
+	int iSystemPositionedWindows;
+	unsigned int iNumOverflowLines;
+	TCHAR iDefaultCaptureFilePath[MAX_PATH];
+	};
+
+#endif // __PREFERENCES_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/RemoteConsole.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,416 @@
+// RemoteConsole.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+#include <commdlg.h>
+#include "console_host.h"
+#include "RemoteConsole.h"
+#include "ConsoleWindow.h"
+
+LPCTSTR KWindowClassName = TEXT("RemoteConsoleWindowClass");
+LPCTSTR KRemoteConsoleName = TEXT("Remote Console");
+LPCTSTR KRemoteConsoleCommandReaderName = TEXT("Remote Console Command Reader");
+
+bool CRemoteConsole::sWindowClassRegistered = FALSE;
+int CRemoteConsole::sNextId = 1;
+CRemoteConsole* CRemoteConsole::sFirst = NULL;
+CRemoteConsole* CRemoteConsole::sLast = NULL;
+
+
+CRemoteConsole* CRemoteConsole::Instance(int aId)
+	{
+	CRemoteConsole* console = sFirst;
+	bool found(0);
+	while (console && !found)
+		{
+		if (console->iId == aId)
+			{
+			found = 1;
+			}
+		else
+			{
+			console = console->iNext;
+			}
+		}
+		
+
+	if (found)
+		{
+		return console;
+		}
+	return NULL;
+	}
+
+CRemoteConsole* CRemoteConsole::New(HINSTANCE aAppHandle, CSocketCommandReader& aCommandReader, LPCTSTR aTitle, int aWidth, int aHeight, TPreferences& aPreferences)
+	{
+	std::auto_ptr<CRemoteConsole> self(new(EThrow) CRemoteConsole(aCommandReader, aPreferences));
+	self->Construct(aAppHandle, aTitle, aWidth, aHeight);
+	return self.release();
+	}
+
+CRemoteConsole::~CRemoteConsole()
+	{
+	iConsole->StopCaptureToFile();
+	delete iCommandReader;
+	delete iKeyEventSocket;
+	delete iConsole;
+	if (sLast == this)
+		{
+		ASSERT(iNext == NULL);
+		sLast = iPrevious;
+		}
+	if (sFirst == this)
+		{
+		sFirst = iNext;
+		}
+	if (iPrevious)
+		{
+		iPrevious->iNext = iNext;
+		}
+	if (iNext)
+		{
+		iNext->iPrevious = iPrevious;
+		}
+	}
+
+int CRemoteConsole::Id() const
+	{
+	return iId;
+	}
+
+void CRemoteConsole::AttachKeyEventSocket(CClientSocket& aSocket)
+	{
+	ASSERT(iKeyEventSocket == NULL);
+	iKeyEventSocket = &aSocket;
+	iKeyEventSocket->SetClosureObserver(this);
+	}
+
+CRemoteConsole::CRemoteConsole(CSocketCommandReader& aCommandReader, TPreferences& aPreferences)
+	: iId(sNextId++), iCommandReader(&aCommandReader), iKeyEventSocket(NULL), iNext(NULL), iPrevious(NULL), iClosing(FALSE), iPreferences(aPreferences)
+	{
+	if (sFirst == NULL)
+		{
+		ASSERT(sLast == NULL);
+		sFirst = this;
+		sLast = this;
+		}
+	else
+		{
+		sLast->iNext = this;
+		iPrevious = sLast;
+		sLast = this;
+		}
+	}
+
+void CRemoteConsole::Construct(HINSTANCE aAppHandle, LPCTSTR aTitle, int aWidth, int aHeight)
+	{
+	if (!sWindowClassRegistered)
+		{
+		WNDCLASSEX wcex;
+		wcex.cbSize = sizeof(WNDCLASSEX); 
+		wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
+		wcex.lpfnWndProc	= (WNDPROC)CWindow::HandleMessage;
+		wcex.cbClsExtra		= 0;
+		wcex.cbWndExtra		= 0;
+		wcex.hInstance		= aAppHandle;
+		wcex.hIcon			= LoadIcon(aAppHandle, (LPCTSTR)IDI_CONSOLE_HOST);
+		wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
+		wcex.hbrBackground	= NULL;
+		wcex.lpszMenuName	= (LPCTSTR)ID_REMOTE_CONSOLE_MENU;
+		wcex.lpszClassName	= KWindowClassName;
+		wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
+		if (RegisterClassEx(&wcex) == 0)
+			{
+			throw KExceptionWindowClassRegistrationFailed;
+			}
+		sWindowClassRegistered = TRUE;
+		}
+
+	int posX = CW_USEDEFAULT;
+	int posY = CW_USEDEFAULT;
+	if (!iPreferences.SystemPositionedWindows())
+		{
+		posX = iPreferences.DefaultWindowPosX();
+		posY = iPreferences.DefaultWindowPosY();
+		}
+	iConsole = CConsoleWindow::New(aAppHandle, KWindowClassName, aTitle, posX, posY, (aWidth == -1) ? iPreferences.DefaultWindowWidth() : aWidth, (aHeight == -1) ? iPreferences.DefaultWindowHeight() : aHeight, iPreferences.NumOverflowLines(), this, this, FALSE);
+	iConsole->SetName(KRemoteConsoleName);
+	iCommandReader->ChangeHandler(*this);
+	iCommandReader->SetName(KRemoteConsoleCommandReaderName);
+	iCommandReader->ReadCommand();
+	}
+
+void CRemoteConsole::HandleSocketClosure(CSocket& aSocket)
+	{
+	if (!iClosing)
+		{
+		iConsole->SetTitle(TEXT("Remote console closed - press any key to close window"));
+		iConsole->SetDimmed(TRUE);
+		iClosing = TRUE;
+		}
+	}
+
+void CRemoteConsole::HandleWindowClosure(CWindow&)
+	{
+	delete this;
+	}
+
+LRESULT CRemoteConsole::HandleWindowCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam)
+	{
+	switch (LOWORD(aWParam))
+		{
+		case ID_RC_CAPTURE:
+			{
+			UINT checkMenuItem = MF_BYCOMMAND | MF_UNCHECKED;
+			if (iConsole->IsCapturingToFile())
+				{
+				iConsole->StopCaptureToFile();
+				}
+			else
+				{
+				TCHAR captureFileName[MAX_PATH];
+				if (GetCaptureFileName(captureFileName))
+					{
+					iConsole->CaptureToFile(captureFileName);
+					checkMenuItem = MF_BYCOMMAND | MF_CHECKED;
+					}
+				}
+			CheckMenuItem(GetMenu(iConsole->Handle()), ID_RC_CAPTURE, checkMenuItem);
+			break;
+			}
+		case ID_RC_CLOSE:
+			{
+			DestroyWindow(iConsole->Handle());
+			break;
+			}
+		case ID_EDIT_COPY:
+			{
+			iConsole->CopyToClipboard();
+			break;
+			}
+		case ID_EDIT_PASTE:
+			{
+			iConsole->PasteFromClipboard();
+			break;
+			}
+		default:
+			{
+			return DefWindowProc(iConsole->Handle(), aMessage, aWParam, aLParam);
+			}
+		}
+	return 0;
+	}
+
+class TKeyEvent
+	{
+public:
+	TCHAR iChar;
+	UINT iModifiers;
+	};
+
+void CRemoteConsole::HandleConsoleChar(TCHAR aChar, UINT aModifiers)
+	{
+	if (iClosing)
+		{
+		DestroyWindow(iConsole->Handle());
+		}
+	else if (iKeyEventSocket)
+		{
+		TKeyEvent keyEvent;
+		keyEvent.iChar = aChar;
+		keyEvent.iModifiers = aModifiers;
+		iKeyEventSocket->Write((char*)&keyEvent, sizeof(TKeyEvent));
+		}
+	}
+
+void CRemoteConsole::HandleConsoleString(LPCTSTR aString, int aLength)
+	{
+	if (iClosing)
+		{
+		DestroyWindow(iConsole->Handle());
+		}
+	else if (iKeyEventSocket)
+		{
+		for (int i = 0; i < aLength; ++i)
+			{
+			HandleConsoleChar(*(aString + i), 0);
+			}
+		}
+	}
+
+void CRemoteConsole::HandleSocketCommand(TPacketHeader::TPacketType aCommand, const char* aPacket, int aPacketLength, CSocketCommandReader& aReader)
+	{
+	ASSERT(&aReader == iCommandReader);
+	switch (aCommand)
+		{
+		case TPacketHeader::ECommandWrite:
+			{
+			const int* toWriteLength = new((char*)aPacket) int;
+			LPTSTR toWrite = (TCHAR*)(aPacket + sizeof(int));
+			iConsole->Write(toWrite, *toWriteLength);
+			break;
+			}
+		case TPacketHeader::ECommandGetCursorPos:
+			{
+			class TPos
+				{
+			public:
+				int iX;
+				int iY;
+				};
+			TPos pos;
+			iConsole->GetCursorPos(pos.iX, pos.iY);
+			iCommandReader->SendResponse((char*)&pos, sizeof(TPos));
+			break;
+			}
+		case TPacketHeader::ECommandSetAbsCursorPos:
+			{
+			const int* x = new((char*)aPacket) int;
+			const int* y = new(((char*)aPacket) + sizeof(int)) int;
+			iConsole->SetAbsCursorPos(*x, *y);
+			break;
+			}
+		case TPacketHeader::ECommandSetRelCursorPos:
+			{
+			const int* x = new((char*)aPacket) int;
+			const int* y = new(((char*)aPacket) + sizeof(int)) int;
+			iConsole->SetRelCursorPos(*x, *y);
+			break;
+			}
+		case TPacketHeader::ECommandSetCursorHeight:
+			{
+			const int* height = new((char*)aPacket) int;
+			iConsole->SetCursorHeight(*height);
+			break;
+			}
+		case TPacketHeader::ECommandGetScreenSize:
+			{
+			class TSize
+				{
+			public:
+				int iWidth;
+				int iHeight;
+				};
+			TSize size;
+			iConsole->GetConsoleSize(size.iWidth, size.iHeight);
+			iCommandReader->SendResponse((char*)&size, sizeof(TSize));
+			break;
+			}
+		case TPacketHeader::ECommandSetTitle:
+			{
+			iConsole->SetTitle((TCHAR*)aPacket);
+			break;
+			}
+		case TPacketHeader::ECommandClearScreen:
+			{
+			iConsole->ClearScreen();
+			break;
+			}
+		case TPacketHeader::ECommandClearToEndOfLine:
+			{
+			iConsole->ClearToEndOfLine();
+			break;
+			}
+		default:
+			{
+			// Unknown command - do nothing.
+			}
+		}
+	iCommandReader->ReadCommand();
+	}
+
+void CRemoteConsole::HandleSocketClosure(CSocketCommandReader& aReader)
+	{
+	HandleSocketClosure(aReader.Socket());
+	}
+
+bool CRemoteConsole::GetCaptureFileName(LPTSTR aFileName) const
+	{
+	GetDefaultCaptureFileName(aFileName);
+	OPENFILENAME ofn;
+	ZeroMemory(&ofn, sizeof(ofn));
+	ofn.lStructSize = sizeof(ofn);
+	ofn.hwndOwner = iConsole->Handle();
+	ofn.lpstrFile = aFileName;
+	ofn.nMaxFile = MAX_PATH;
+	ofn.lpstrFilter = TEXT("All\0*.*\0Text\0*.TXT\0");
+	ofn.nFilterIndex = 1;
+	ofn.lpstrFileTitle = NULL;
+	ofn.nMaxFileTitle = 0;
+	ofn.lpstrInitialDir = NULL;
+	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
+	ofn.lpstrTitle = TEXT("Capture to");
+	bool ok = !(GetSaveFileName(&ofn) == 0);
+	if (ok)
+		{
+		if (FileExists(aFileName))
+			{
+			LPCTSTR constErrorText = TEXT(" already exists. Overwrite it?");
+			std::auto_ptr<TCHAR> errorText(new(EThrow) TCHAR[wcslen(aFileName) + wcslen(constErrorText) + 1]);
+			wcscpy(errorText.get(), aFileName);
+			wcscat(errorText.get(), constErrorText);
+			if (MessageBox(iConsole->Handle(), errorText.get(), TEXT("Warning"), MB_OKCANCEL | MB_ICONWARNING) == IDOK)
+				{
+				if (DeleteFile(aFileName) <= 0)
+					{
+					throw KExceptionFailedToDeleteExistingCaptureFile;
+					}
+				}
+			else
+				{
+				ok = FALSE;
+				}
+			}
+		}
+	if (ok)
+		{
+		SetDefaultCaptureFilePath(aFileName);
+		}
+	return ok;
+	}
+
+void CRemoteConsole::GetDefaultCaptureFileName(LPTSTR aFileName) const
+	{
+	TCHAR formatString[MAX_PATH];
+	wcscpy(formatString, iPreferences.DefaultCaptureFilePath());
+	TCHAR windowTitle[MAX_PATH];
+	iConsole->GetTitle(windowTitle, MAX_PATH);
+	if (wcslen(formatString) + wcslen(windowTitle) + 10 > MAX_PATH) // + 10 for the '_%03d.txt\0'.
+		{
+		wcscpy(formatString, TEXT("c:\\"));
+		}
+	wcscat(formatString, windowTitle);
+	wcscat(formatString, TEXT("_%03d.txt"));
+	int i = 1;
+	bool uniqueNameFound(FALSE);
+	do
+		{
+		_snwprintf(aFileName, MAX_PATH, formatString, i++);
+		if (!FileExists(aFileName))
+			{
+			uniqueNameFound = TRUE;
+			}
+		}
+		while (!uniqueNameFound);
+	}
+
+void CRemoteConsole::SetDefaultCaptureFilePath(LPCTSTR aFileName) const
+	{
+	int pathLength;
+	for (pathLength = wcslen(aFileName) - 1; (pathLength > 0) && (aFileName[pathLength - 1] != TCHAR('\\')); --pathLength);
+	TCHAR path[MAX_PATH];
+	wcsncpy(path, aFileName, pathLength);
+	*(path + pathLength) = CHAR('\0');
+	iPreferences.SetDefaultCaptureFilePath(path);
+	iPreferences.Write();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/RemoteConsole.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,68 @@
+// RemoteConsole.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_REMOTECONSOLE_H__EE1B18FE_34CC_42EE_8102_A6C62658E7EA__INCLUDED_)
+#define AFX_REMOTECONSOLE_H__EE1B18FE_34CC_42EE_8102_A6C62658E7EA__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "Base.h"
+#include "ClientSocket.h"
+#include "SocketCommandHandler.h"
+#include "Server.h"
+#include "ConsoleWindow.h"
+
+
+class CRemoteConsole : public CBase, public MSocketClosureObserver, public MWindowObserver, public MConsoleCharHandler, public MSocketCommandHandler
+	{
+public:
+	static CRemoteConsole* Instance(int aId);
+	static CRemoteConsole* New(HINSTANCE aAppHandle, CSocketCommandReader& aCommandReader, LPCTSTR aTitle, int aWidth, int aHeight, TPreferences& aPreferences);
+	virtual ~CRemoteConsole();
+	int Id() const;
+	void AttachKeyEventSocket(CClientSocket& aSocket);
+private:
+	CRemoteConsole(CSocketCommandReader& aCommandReader, TPreferences& aPreferences);
+	void Construct(HINSTANCE aAppHandle, LPCTSTR aTitle, int aWidth, int aHeight);
+private: // From MSocketClosureObserver.
+	virtual void HandleSocketClosure(CSocket& aSocket);
+private: // From MWindowObserver.
+	virtual void HandleWindowClosure(CWindow& aWindow);
+	virtual LRESULT HandleWindowCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam);
+private: // From MConsoleCharHandler.
+	virtual void HandleConsoleChar(TCHAR aChar, UINT aModifiers);
+	virtual void HandleConsoleString(LPCTSTR aString, int aLength);
+private: // From MSocketCommandHandler.
+	virtual void HandleSocketCommand(TPacketHeader::TPacketType aCommand, const char* aPacket, int aPacketLength, CSocketCommandReader& aReader);
+	virtual void HandleSocketClosure(CSocketCommandReader& aReader);
+private:
+	bool GetCaptureFileName(LPTSTR aFileName) const;
+	void GetDefaultCaptureFileName(LPTSTR aFileName) const;
+	void SetDefaultCaptureFilePath(LPCTSTR aFileName) const;
+private:
+	static bool sWindowClassRegistered;
+	static int sNextId;
+	static CRemoteConsole* sFirst;
+	static CRemoteConsole* sLast;
+	int iId;
+	CRemoteConsole* iNext;
+	CRemoteConsole* iPrevious;
+	CSocketCommandReader* iCommandReader;
+	CClientSocket* iKeyEventSocket;
+	CConsoleWindow* iConsole;
+	bool iClosing;
+	TPreferences& iPreferences;
+	};
+
+#endif // !defined(AFX_REMOTECONSOLE_H__EE1B18FE_34CC_42EE_8102_A6C62658E7EA__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Server.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,335 @@
+// Server.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+#include "console_host.h"
+#include "Server.h"
+#include "ConsoleWindow.h"
+#include "RemoteConsole.h"
+
+const int KMajorVersion = 1;
+const int KServerInitParam = ID_RC_CLOSE - 1;
+static CServer* sServer = NULL;
+LPCTSTR KServerWindowClassName = TEXT("ServerWindowClass");
+LPCTSTR KServerConsoleName = TEXT("Server Console");
+LPCTSTR KServerSocketName = TEXT("Server Socket");
+
+
+class TCreateConsoleWindowPacket
+	{
+public:
+	void Validate() const;
+public:
+	int iMajorVersion;
+	int iMinorVersion;
+	int iWidth;
+	int iHeight;
+	int iTitleLength;
+	};
+
+void TCreateConsoleWindowPacket::Validate() const
+	{
+	if (iMajorVersion > KMajorVersion)
+		{
+		throw KExceptionInvalidClientVersion;
+		}
+	}
+
+
+CServer* CServer::New(HINSTANCE aAppHandle)
+	{
+	std::auto_ptr<CServer> self(new(EThrow) CServer(aAppHandle));
+	self->Construct();
+	return self.release();
+	}
+
+CServer::~CServer()
+	{
+	delete iSocket;
+	delete iConsole;
+	}
+
+void CServer::HandleException(TException aException)
+	{
+	switch (aException)
+		{
+		case KExceptionNoMemory:
+			iConsole->Write(TEXT("Out of memory\r\n"));
+			break;
+		case KExceptionWindowConstructFailed:
+			iConsole->Write(TEXT("Failed to construct new window\r\n"));
+			break;
+		case KExceptionConsoleWindowConstructFailed:
+			iConsole->Write(TEXT("Failed to construct new console window\r\n"));
+			break;
+		case KExceptionSocketConstructFailed:
+			iConsole->Write(TEXT("Failed to construct new socket\r\n"));
+			break;
+		case KExceptionSocketBindFailed:
+			iConsole->Write(TEXT("Failed to bind server socket. Is something else already listening on that port?\r\n"));
+			break;
+		case KExceptionSocketListenFailed:
+			iConsole->Write(TEXT("Failed to listen on server socket\r\n"));
+			break;
+		case KExceptionSocketSelectFailed:
+			iConsole->Write(TEXT("Failed to asynchronously wait on socket\r\n"));
+			break;
+		case KExceptionSocketAcceptFailed:
+			iConsole->Write(TEXT("Failed to accept to client connection\r\n"));
+			break;
+		case KExceptionSocketReadFailed:
+			iConsole->Write(TEXT("Failed to read from socket\r\n"));
+			break;
+		case KExceptionInvalidClientVersion:
+			iConsole->Write(TEXT("Invalid client version\r\n"));
+			break;
+		case KExceptionFailedToWritePrefsFile:
+			iConsole->Write(TEXT("Failed to write preferences file\r\n"));
+			break;
+		default:
+			iConsole->Write(TEXT("Unknown error\r\n"));
+			break;
+		}
+	}
+
+TPreferences& CServer::Preferences()
+	{
+	return iPreferences;
+	}
+
+const TPreferences& CServer::Preferences() const
+	{
+	return iPreferences;
+	}
+
+CServer::CServer(HINSTANCE aAppHandle) : iAppHandle(aAppHandle), iSocket(NULL), iConsole(NULL), iPort(0)
+	{
+	sServer = this;
+	}
+
+void CServer::Construct()
+	{
+	WNDCLASSEX wcex;
+	wcex.cbSize = sizeof(WNDCLASSEX); 
+	wcex.style			= CS_HREDRAW | CS_VREDRAW;
+	wcex.lpfnWndProc	= (WNDPROC)CWindow::HandleMessage;
+	wcex.cbClsExtra		= 0;
+	wcex.cbWndExtra		= 0;
+	wcex.hInstance		= iAppHandle;
+	wcex.hIcon			= LoadIcon(iAppHandle, (LPCTSTR)IDI_CONSOLE_HOST);
+	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
+	wcex.hbrBackground	= NULL;
+	wcex.lpszMenuName	= (LPCTSTR)ID_SERVER_MENU;
+	wcex.lpszClassName	= KServerWindowClassName;
+	wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
+	if (RegisterClassEx(&wcex) == 0)
+		{
+		throw KExceptionWindowClassRegistrationFailed;
+		}
+	
+	iConsole = CConsoleWindow::New(iAppHandle, KServerWindowClassName, TEXT("Remote Console Server"), CW_USEDEFAULT, CW_USEDEFAULT, 40, 20, 20, this, NULL, TRUE);
+	iConsole->SetName(KServerConsoleName);
+
+	try
+		{
+		iPreferences.Read();
+		}
+	catch (...)
+		{
+		iConsole->Write(TEXT("Unable to read preferences"));
+		}
+
+	iSocket = CServerSocket::New(*iConsole);
+	iSocket->SetName(KServerSocketName);
+	PostMessage(iConsole->Handle(), WM_COMMAND, KServerInitParam, 0);
+	}
+
+void CServer::Listen()
+	{
+	if (iPort != iPreferences.ServerPort())
+		{
+		delete iSocket;
+		iSocket = CServerSocket::New(*iConsole);
+		iSocket->SetName(KServerSocketName);
+		iSocket->Listen(iPreferences.ServerPort(), 5, *this);
+		iConsole->WriteFormat(TEXT("Listening on port %d\r\n"), iPreferences.ServerPort());
+		iPort = iPreferences.ServerPort();
+		}
+	}
+
+void CServer::HandleNewClient(CClientSocket& aClientSocket)
+	{
+	CSocketCommandReader* commandReader = CSocketCommandReader::New(aClientSocket, *this);
+	commandReader->ReadCommand();
+	}
+
+void CServer::HandleSocketClosure(CSocket& aSocket)
+	{
+	ASSERT(&aSocket == iSocket);
+	PostQuitMessage(0);
+	}
+
+void CServer::HandleSocketCommand(TPacketHeader::TPacketType aCommand, const char* aPacket, int aPacketLength, CSocketCommandReader& aReader)
+	{
+	switch (aCommand)
+		{
+		case TPacketHeader::ECommandCreateConsoleWindow:
+			{
+			iConsole->Write(TEXT("Creating new console window...\r\n"));
+			const TCreateConsoleWindowPacket* createConsoleWindowPacket = new((char*)aPacket) TCreateConsoleWindowPacket;
+			LPTSTR title = (TCHAR*)((char*)aPacket + sizeof(TCreateConsoleWindowPacket));
+			try
+				{
+				createConsoleWindowPacket->Validate();
+				CRemoteConsole* remoteConsole = CRemoteConsole::New(iAppHandle, aReader, title, createConsoleWindowPacket->iWidth, createConsoleWindowPacket->iHeight, iPreferences);
+				int consoleId = remoteConsole->Id();
+				iConsole->WriteFormat(TEXT("Created window \"%s\" (%d)...\r\n"), title, consoleId);
+				aReader.SendResponse((char*)&consoleId, sizeof(int));
+				}
+			catch (TException aException)
+				{
+				int err = -2; // KErrGeneral.
+				if (aException == KExceptionInvalidClientVersion)
+					{
+					err = -21; // KErrAccessDenied.
+					}
+				aReader.SendResponse((char*)&err, sizeof(int));
+				delete &aReader;
+				throw aException;
+				}
+			catch (...)
+				{
+				delete &aReader;
+				throw KExceptionUnknown;
+				}
+			break;
+			}
+		case TPacketHeader::ECommandAttachKeyEventSocket:
+			{
+			iConsole->Write(TEXT("Attaching key event socket...\r\n"));
+			int* consoleId = new((char*)aPacket) int;
+			CRemoteConsole* remoteConsole = CRemoteConsole::Instance(*consoleId);
+			if (remoteConsole)
+				{
+				remoteConsole->AttachKeyEventSocket(aReader.ReleaseSocket());
+				iConsole->WriteFormat(TEXT("Attached key event socket to window %d...\r\n"), *consoleId);
+				}
+			delete &aReader;
+			break;
+			}
+		default:
+			{
+			iConsole->WriteFormat(TEXT("Invalid server socket command: %d\r\n"), aCommand);
+			delete &aReader;
+			break;
+			}
+		}
+	}
+
+void CServer::HandleSocketClosure(CSocketCommandReader& aReader)
+	{
+	delete &aReader;
+	}
+
+void CServer::HandleWindowClosure(CWindow& aWindow)
+	{
+	ASSERT(&aWindow == iConsole);
+	PostQuitMessage(0);
+	}
+
+LRESULT CALLBACK PrefsCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+	{
+	switch (message)
+		{
+		case WM_INITDIALOG:
+			TCHAR string[128];
+			swprintf(string, TEXT("%u"), sServer->Preferences().ServerPort());
+			SetDlgItemText(hDlg, ID_EDIT_PORT, string);
+			swprintf(string, TEXT("%u"), sServer->Preferences().DefaultWindowWidth());
+			SetDlgItemText(hDlg, ID_EDIT_WIN_WIDTH, string);
+			swprintf(string, TEXT("%u"), sServer->Preferences().DefaultWindowHeight());
+			SetDlgItemText(hDlg, ID_EDIT_WIN_HEIGHT, string);
+			swprintf(string, TEXT("%u"), sServer->Preferences().DefaultWindowPosX());
+			SetDlgItemText(hDlg, ID_EDIT_WIN_POS_X, string);
+			swprintf(string, TEXT("%u"), sServer->Preferences().DefaultWindowPosY());
+			SetDlgItemText(hDlg, ID_EDIT_WIN_POS_Y, string);
+			EnableWindow(GetDlgItem(hDlg, ID_EDIT_WIN_POS_X), !sServer->Preferences().SystemPositionedWindows());
+			EnableWindow(GetDlgItem(hDlg, ID_EDIT_WIN_POS_Y), !sServer->Preferences().SystemPositionedWindows());
+			CheckDlgButton(hDlg, ID_CHECK_WIN_POS, sServer->Preferences().SystemPositionedWindows());
+			swprintf(string, TEXT("%u"), sServer->Preferences().NumOverflowLines());
+			SetDlgItemText(hDlg, ID_OVERFLOW_LINES, string);
+			return TRUE;
+		case WM_COMMAND:
+			switch (LOWORD(wParam))
+				{
+				case IDOK:
+					{
+					TCHAR string[128];
+					GetDlgItemText(hDlg, ID_EDIT_PORT, string, 128);
+					unsigned int val;
+					swscanf(string, TEXT("%u"), &val);
+					sServer->Preferences().SetServerPort((unsigned short)val);
+					GetDlgItemText(hDlg, ID_EDIT_WIN_WIDTH, string, 128);
+					swscanf(string, TEXT("%u"), &val);
+					sServer->Preferences().SetDefaultWindowWidth(val);
+					GetDlgItemText(hDlg, ID_EDIT_WIN_HEIGHT, string, 128);
+					swscanf(string, TEXT("%u"), &val);
+					sServer->Preferences().SetDefaultWindowHeight(val);
+					GetDlgItemText(hDlg, ID_EDIT_WIN_POS_X, string, 128);
+					swscanf(string, TEXT("%u"), &val);
+					sServer->Preferences().SetDefaultWindowPosX(val);
+					GetDlgItemText(hDlg, ID_EDIT_WIN_POS_Y, string, 128);
+					swscanf(string, TEXT("%u"), &val);
+					sServer->Preferences().SetDefaultWindowPosY(val);
+					GetDlgItemText(hDlg, ID_OVERFLOW_LINES, string, 128);
+					swscanf(string, TEXT("%u"), &val);
+					sServer->Preferences().SetNumOverflowLines(val);
+					sServer->Preferences().SetSystemPositionedWindows((IsDlgButtonChecked(hDlg, ID_CHECK_WIN_POS) == BST_CHECKED) ? TRUE : FALSE);
+					sServer->Preferences().Write();
+					sServer->Listen();
+					}	// Deliberate fall through.
+				case IDCANCEL:
+					{
+					EndDialog(hDlg, LOWORD(wParam));
+					return TRUE;
+					}
+				case ID_CHECK_WIN_POS:
+					{
+					int isChecked = IsDlgButtonChecked(hDlg, ID_CHECK_WIN_POS);
+					EnableWindow(GetDlgItem(hDlg, ID_EDIT_WIN_POS_X), !isChecked);
+					EnableWindow(GetDlgItem(hDlg, ID_EDIT_WIN_POS_Y), !isChecked);
+					break;
+					}
+				}
+			break;
+		}
+    return FALSE;
+	}
+
+LRESULT CServer::HandleWindowCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam)
+	{
+	int wmId = LOWORD(aWParam); 
+	int wmEvent = HIWORD(aWParam); 
+	switch (wmId)
+		{
+		case KServerInitParam:
+			Listen();
+			break;
+		case ID_PREFS:
+			DialogBox(iAppHandle, (LPCTSTR)IDD_PREFS_DIALOG, iConsole->Handle(), (DLGPROC)PrefsCallback);
+			break;
+		default:
+			return DefWindowProc(iConsole->Handle(), aMessage, aWParam, aLParam);
+		}
+	return 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Server.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,60 @@
+// Server.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_SERVER_H__ECF36F93_36B9_491D_A482_5A1FCBE29932__INCLUDED_)
+#define AFX_SERVER_H__ECF36F93_36B9_491D_A482_5A1FCBE29932__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "Base.h"
+#include "ServerSocket.h"
+#include "SocketCommandHandler.h"
+#include "Preferences.h"
+#include "ConsoleWindow.h"
+
+
+class CConsoleWindow;
+
+
+class CServer : public CBase, public MSocketClientAcceptor, public MSocketClosureObserver, public MSocketCommandHandler, public MWindowObserver
+	{
+public:
+	static CServer* New(HINSTANCE aAppHandle);
+	virtual ~CServer();
+	void HandleException(TException aException);
+	TPreferences& Preferences();
+	const TPreferences& Preferences() const;
+	void Listen();
+private:
+	CServer(HINSTANCE aAppHandle);
+	void Construct();
+private: // From MClientAcceptor.
+	virtual void HandleNewClient(CClientSocket& aClientSocket);
+private: // From MSocketClosureObserver.
+	virtual void HandleSocketClosure(CSocket& aSocket);
+private: // From MSocketCommandHandler.
+	virtual void HandleSocketCommand(TPacketHeader::TPacketType aCommand, const char* aPacket, int aPacketLength, CSocketCommandReader& aReader);
+	virtual void HandleSocketClosure(CSocketCommandReader& aReader);
+private: // From MWindowObserver.
+	virtual void HandleWindowClosure(CWindow& aWindow);
+	virtual LRESULT HandleWindowCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam);
+private:
+	HINSTANCE iAppHandle;
+	CServerSocket* iSocket;
+	CConsoleWindow* iConsole;
+	TPreferences iPreferences;
+	unsigned short iPort;
+	};
+
+#endif // !defined(AFX_SERVER_H__ECF36F93_36B9_491D_A482_5A1FCBE29932__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/ServerSocket.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,86 @@
+// ServerSocket.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+#include "console_host.h"
+#include "ServerSocket.h"
+#include "ClientSocket.h"
+
+
+CServerSocket* CServerSocket::New(CWindow& aWindow)
+	{
+	std::auto_ptr<CServerSocket> self(new(EThrow) CServerSocket(aWindow));
+	self->Construct();
+	return self.release();
+	}
+
+CServerSocket::CServerSocket(CWindow& aWindow)
+	: CSocket(aWindow), iClientAcceptor(NULL)
+	{
+	}
+
+void CServerSocket::Listen(unsigned short aPort, unsigned int aBacklogSize, MSocketClientAcceptor& aClientAcceptor)
+	{
+	SOCKADDR_IN sockAddr;
+	memset(&sockAddr, 0, sizeof(sockAddr));
+	sockAddr.sin_family = AF_INET;
+	sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
+	sockAddr.sin_port = htons((u_short)aPort);
+
+	if (bind(iSocket, (SOCKADDR*)&sockAddr, sizeof(sockAddr)) == SOCKET_ERROR)
+		{
+		throw KExceptionSocketBindFailed;
+		}
+
+	if (listen(iSocket, aBacklogSize) == SOCKET_ERROR)
+		{
+		throw KExceptionSocketListenFailed;
+		}
+
+	iClientAcceptor = &aClientAcceptor;
+	}
+
+CServerSocket::~CServerSocket()
+	{
+	}
+
+void CServerSocket::Construct()
+	{
+	CSocket::Construct();
+
+	if (WSAAsyncSelect(iSocket, iWindow.Handle(), KSocketMessage, FD_ACCEPT | FD_CLOSE) == SOCKET_ERROR)
+		{
+		throw KExceptionSocketSelectFailed;
+		}
+	}
+
+void CServerSocket::HandleAccept()
+	{
+	ASSERT(iClientAcceptor);
+	SOCKET newSocket = WSAAccept(iSocket, NULL, NULL, NULL, 0);
+	if (newSocket == INVALID_SOCKET)
+		{
+		int err = WSAGetLastError();
+		throw KExceptionSocketAcceptFailed;
+		}
+	std::auto_ptr<CClientSocket> clientSocket(CClientSocket::New(iWindow, newSocket));
+	iClientAcceptor->HandleNewClient(*clientSocket.get());
+	clientSocket.release();
+	}
+
+LRESULT CServerSocket::HandleSocketMessage(LPARAM /*aLParam*/)
+	{
+	HandleAccept();
+	return 0;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/ServerSocket.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,49 @@
+// ServerSocket.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_SERVERSOCKET_H__1B6002D0_3BFE_4640_A9E6_566461E06718__INCLUDED_)
+#define AFX_SERVERSOCKET_H__1B6002D0_3BFE_4640_A9E6_566461E06718__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "Socket.h"
+
+
+class CClientSocket;
+
+
+class MSocketClientAcceptor
+	{
+public:
+	virtual void HandleNewClient(CClientSocket& aClientSocket) = 0;
+	};
+
+
+class CServerSocket : public CSocket
+	{
+public:
+	static CServerSocket* New(CWindow& aWindow);
+	virtual ~CServerSocket();
+	void Listen(unsigned short aPort, unsigned int aBacklogSize, MSocketClientAcceptor& aClientAcceptor);
+private:
+	CServerSocket(CWindow& aWindow);
+	void Construct();
+	void HandleAccept();
+private: // From CSocket.
+	virtual LRESULT HandleSocketMessage(LPARAM aLParam);
+private:
+	MSocketClientAcceptor* iClientAcceptor;
+	};
+
+#endif // !defined(AFX_SERVERSOCKET_H__1B6002D0_3BFE_4640_A9E6_566461E06718__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Socket.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,84 @@
+// Socket.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+#include "console_host.h"
+#include "Socket.h"
+#include "DynamicBuffer.h"
+
+
+CSocket::CSocket(CWindow& aWindow)
+	: iWindow(aWindow), iSocket(INVALID_SOCKET), iClosureObserver(NULL)
+	{
+	}
+
+CSocket::CSocket(CWindow& aWindow, SOCKET aSocket)
+	: iWindow(aWindow), iSocket(aSocket), iClosureObserver(NULL)
+	{
+	}
+
+CSocket::~CSocket()
+	{
+	if (iSocket != INVALID_SOCKET)
+		{
+		closesocket(iSocket);
+		}
+
+	iWindow.RemoveMessageHandler(*this);
+	}
+
+void CSocket::SetClosureObserver(MSocketClosureObserver* aClosureObserver)
+	{
+	iClosureObserver = aClosureObserver;
+	}
+
+void CSocket::Construct()
+	{
+	if (iSocket == INVALID_SOCKET)
+		{
+		if ((iSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET)
+			{
+			throw KExceptionSocketConstructFailed;
+			}
+		BOOL b = 1;
+		setsockopt(iSocket, IPPROTO_TCP, TCP_NODELAY, (char*)&b, sizeof(BOOL));
+		}
+
+	iWindow.AddMessageHandler(*this);
+	}
+
+void CSocket::HandleClosure()
+	{
+	if (iClosureObserver)
+		{
+		iClosureObserver->HandleSocketClosure(*this);
+		}
+	}
+
+LRESULT CSocket::HandleWindowMessage(UINT aMessage, WPARAM aWParam, LPARAM aLParam)
+	{
+	if ((aMessage == KSocketMessage) && (aWParam == iSocket))
+		{
+		if (WSAGETSELECTEVENT(aLParam) == FD_CLOSE)
+			{
+			HandleClosure();
+			}
+		else
+			{
+			HandleSocketMessage(aLParam);
+			}
+		return 0;
+		}
+	return 1;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Socket.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,57 @@
+// Socket.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_SOCKET_H__EE7BB9E5_00B0_4007_A36C_A2251979F83F__INCLUDED_)
+#define AFX_SOCKET_H__EE7BB9E5_00B0_4007_A36C_A2251979F83F__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "Base.h"
+#include <winsock2.h>
+#include "Window.h"
+
+
+class CSocket;
+
+
+class MSocketClosureObserver
+	{
+public:
+	virtual void HandleSocketClosure(CSocket& aSocket) = 0;
+	};
+
+
+class CSocket : public CBase, public MWindowMessageHandler
+	{
+public:
+	virtual ~CSocket();
+	void SetClosureObserver(MSocketClosureObserver* aClosureObserver);
+protected:
+	CSocket(CWindow& aWindow);
+	CSocket(CWindow& aWindow, SOCKET aSocket);
+	void Construct();
+	void HandleClosure();
+private: // From MWindowMessageHandler.
+	virtual LRESULT HandleWindowMessage(UINT aMessage, WPARAM aWParam, LPARAM aLParam);
+protected: // New.
+	virtual LRESULT HandleSocketMessage(LPARAM aLParam) = 0;
+protected:
+	CWindow& iWindow;
+	SOCKET iSocket;
+private:
+	MSocketClosureObserver* iClosureObserver;
+	};
+
+
+#endif // !defined(AFX_SOCKET_H__EE7BB9E5_00B0_4007_A36C_A2251979F83F__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/SocketCommandHandler.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,133 @@
+// SocketCommandHandler.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+#include "console_host.h"
+#include "SocketCommandHandler.h"
+#include "DynamicBuffer.h"
+
+const int KInitialBufferLength = 1;
+
+
+CSocketCommandReader* CSocketCommandReader::New(CClientSocket& aSocket, MSocketCommandHandler& aHandler)
+	{
+	std::auto_ptr<CSocketCommandReader> self(new(EThrow) CSocketCommandReader(aSocket, aHandler));
+	self->Construct();
+	return self.release();
+	}
+
+CSocketCommandReader::~CSocketCommandReader()
+	{
+	delete iSocket;
+	delete iReadBuf;
+	}
+
+void CSocketCommandReader::ChangeHandler(MSocketCommandHandler& aHandler)
+	{
+	iHandler = &aHandler;
+	}
+
+void CSocketCommandReader::ReadCommand()
+	{
+	ASSERT(iState == EIdle);
+	iState = EReadingHeader;
+	QueueRead();
+	}
+
+void CSocketCommandReader::SendResponse(char* aMessage, int aLength)
+	{
+	iSocket->Write(aMessage, aLength);
+	}
+
+CClientSocket& CSocketCommandReader::ReleaseSocket()
+	{
+	CClientSocket* socket = iSocket;
+	iSocket = NULL;
+	return *socket;
+	}
+
+CClientSocket& CSocketCommandReader::Socket() const
+	{
+	ASSERT(iSocket);
+	return *iSocket;
+	}
+
+CSocketCommandReader::CSocketCommandReader(CClientSocket& aSocket, MSocketCommandHandler& aHandler)
+	: iSocket(&aSocket), iHandler(&aHandler), iState(EIdle)
+	{
+	}
+
+void CSocketCommandReader::Construct()
+	{
+	iReadBuf = CDynamicReadBuffer::New(KInitialBufferLength);
+	iSocket->SetClosureObserver(this);
+	}
+
+void CSocketCommandReader::QueueRead()
+	{
+	switch (iState)
+		{
+		case EReadingHeader:
+			{
+			iSocket->Read((char*)&iPacketHeader, sizeof(TPacketHeader), *this);
+			break;
+			}
+		case EReadingBody:
+			{
+			iSocket->Read(iReadBuf->Buffer(iPacketHeader.iSize + 2), iPacketHeader.iSize, *this); // + 2 for string terminator.
+			break;
+			}
+		default:
+			{
+			ASSERT(FALSE);
+			}
+		}
+	}
+
+void CSocketCommandReader::SocketReadComplete()
+	{
+	switch (iState)
+		{
+		case EReadingHeader:
+			{
+			if (iPacketHeader.iSize > 0)
+				{
+				iState = EReadingBody;
+				QueueRead();
+				}
+			else
+				{
+				// Empty body.
+				iState = EIdle;
+				iHandler->HandleSocketCommand(iPacketHeader.iType, NULL, 0, *this);
+				}
+			break;
+			}
+		case EReadingBody:
+			{
+			iState = EIdle;
+			*(TCHAR*)((char*)iReadBuf->Buffer() + iPacketHeader.iSize) = 0; // Add terminator.
+			iHandler->HandleSocketCommand(iPacketHeader.iType, iReadBuf->Buffer(), iPacketHeader.iSize, *this);
+			break;
+			}
+		default:
+			{
+			ASSERT(FALSE);
+			}
+		}
+	}
+
+void CSocketCommandReader::HandleSocketClosure(CSocket& /*aSocket*/)
+	{
+	iHandler->HandleSocketClosure(*this);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/SocketCommandHandler.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,94 @@
+// SocketCommandHandler.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_SOCKETCOMMANDHANDLER_H__C4FCCE6D_0FA7_4D9F_AA7D_449E22C3ED74__INCLUDED_)
+#define AFX_SOCKETCOMMANDHANDLER_H__C4FCCE6D_0FA7_4D9F_AA7D_449E22C3ED74__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+#include "Base.h"
+#include "ClientSocket.h"
+
+
+class CDynamicReadBuffer;
+class CSocketCommandReader;
+
+
+class TPacketHeader
+	{
+public:
+	enum TPacketType
+		{
+		ECommandCreateConsoleWindow,
+		ECommandAttachKeyEventSocket,
+		ECommandWrite,
+		ECommandGetCursorPos,
+		ECommandSetAbsCursorPos,
+		ECommandSetRelCursorPos,
+		ECommandSetCursorHeight,
+		ECommandGetScreenSize,
+		ECommandSetTitle,
+		ECommandClearScreen,
+		ECommandClearToEndOfLine
+		};
+public:
+	TPacketType iType;
+	int iSize;
+	};
+
+
+class MSocketCommandHandler
+	{
+public:
+	virtual void HandleSocketCommand(TPacketHeader::TPacketType aCommand, const char* aPacket, int aPacketLength, CSocketCommandReader& aReader) = 0;
+	virtual void HandleSocketClosure(CSocketCommandReader& aReader) = 0;
+	};
+
+
+class CSocketCommandReader : public CBase, public MSocketReadHandler, public MSocketClosureObserver
+	{
+public:
+	static CSocketCommandReader* New(CClientSocket& aSocket, MSocketCommandHandler& aHandler);
+	virtual ~CSocketCommandReader();
+	void ChangeHandler(MSocketCommandHandler& aHandler);
+	void ReadCommand();
+	void SendResponse(char* aMessage, int aLength);
+	CClientSocket& ReleaseSocket();
+	CClientSocket& Socket() const;
+private:
+	CSocketCommandReader(CClientSocket& aSocket, MSocketCommandHandler& aHandler);
+	void Construct();
+	void QueueRead();
+private: // From MSocketReadHandler.
+	virtual void SocketReadComplete();
+private: // From MSocketClosureObserver.
+	virtual void HandleSocketClosure(CSocket& aSocket);
+private:
+	enum TState
+		{
+		EIdle,
+		EReadingHeader,
+		EReadingBody
+		};
+private:
+	CClientSocket* iSocket;
+	MSocketCommandHandler* iHandler;
+	TState iState;
+	TPacketHeader iPacketHeader;
+	CDynamicReadBuffer* iReadBuf;
+	};
+
+
+#endif // !defined(AFX_SOCKETCOMMANDHANDLER_H__C4FCCE6D_0FA7_4D9F_AA7D_449E22C3ED74__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/StdAfx.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+// StdAfx.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/StdAfx.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,39 @@
+// StdAfx.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
+
+
+// Windows Header Files:
+#include <windows.h>
+
+// C RunTime Header Files
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+
+// Local Header Files
+
+// TODO: reference additional headers your program requires here
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/TextBuffer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,467 @@
+// TextBuffer.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "Misc.h"
+#include <fcntl.h>
+#include <io.h>
+#include <sys/stat.h>
+#include "TextBuffer.h"
+
+const int KTabSize = 4;
+
+
+CTextBuffer* CTextBuffer::New(int aWidth, int aHeight, int aMaxNumOverflowLines)
+	{
+	std::auto_ptr<CTextBuffer> self(new(EThrow) CTextBuffer(aWidth, aHeight, aMaxNumOverflowLines));
+	self->Construct();
+	return self.release();
+	}
+
+CTextBuffer::~CTextBuffer()
+	{
+	delete iBuffer;
+	}
+
+void CTextBuffer::SetObserver(MTextBufferObserver* aObserver)
+	{
+	iObserver = aObserver;
+	}
+
+int StringLength(LPCTSTR aStart, LPCTSTR aEnd)
+	{
+	return (aEnd - aStart) + 1;
+	}
+
+void CTextBuffer::Write(LPCTSTR aString, int aLength)
+	{
+	LPCTSTR startBlock = aString;
+	LPCTSTR ptr = aString;
+	LPCTSTR end = aString + aLength - 1;
+	int numCharsToLineEnd = NumCharsToLineEnd();
+	while (ptr <= end)
+		{
+		if (!IsOrdinaryChar(*ptr))
+			{
+			// Not an ordinary character, so write the block we've gathered so far.
+			if (StringLength(startBlock, ptr - 1) > 0)
+				{
+				WriteBlock(startBlock, StringLength(startBlock, ptr - 1));
+				}
+			// Write the special character.
+			WriteSpecialChar(*ptr);
+			// Setup variables for the next block.
+			startBlock = ptr + 1;
+			numCharsToLineEnd = NumCharsToLineEnd();
+			}
+		else if (StringLength(startBlock, ptr) == numCharsToLineEnd)
+			{
+			// Reached line end, so write the block we've gathered so far.
+			ASSERT(numCharsToLineEnd > 0);
+			WriteBlock(startBlock, numCharsToLineEnd);
+			// Setup variables for the next block.
+			startBlock = ptr + 1;
+			numCharsToLineEnd = NumCharsToLineEnd();
+			}
+		else if (ptr == end)
+			{
+			// Reached end of buffer.
+			if (StringLength(startBlock, ptr) > 0)
+				{
+				WriteBlock(startBlock, StringLength(startBlock, ptr));
+				}
+			}
+		++ptr;
+		}
+	}
+
+void CTextBuffer::GetCursorPos(int& aX, int& aY) const
+	{
+	aX = iCursorPosX;
+	aY = iCursorPosY;
+	}
+
+void CTextBuffer::SetAbsCursorPos(int aX, int aY)
+	{
+	MoveCursor(aX, aY);
+	}
+
+void CTextBuffer::SetRelCursorPos(int aX, int aY)
+	{
+	MoveCursor(iCursorPosX + aX, iCursorPosY + aY);
+	}
+
+void CTextBuffer::GetSize(int& aWidth, int& aHeight) const
+	{
+	aWidth = iWidth;
+	aHeight = iHeight;
+	}
+
+int CTextBuffer::NumOverflowLines() const
+	{
+	return iNumOverflowLines;
+	}
+
+void CTextBuffer::Clear()
+	{
+	ClearBuffer();
+	MoveCursor(0, 0);
+	}
+
+void CTextBuffer::ClearToEndOfLine()
+	{
+	const PTCHAR start = CursorPtr();
+	PTCHAR ptr = start;
+	const PTCHAR end = LineEndPtr();
+
+	while (ptr <= end)
+		{
+		*ptr++ = TCHAR(' ');
+		}
+
+	if (iObserver)
+		{
+		iObserver->HandleTextBufferChange(iCursorPosX, iCursorPosY, start, StringLength(start, end));
+		}
+	}
+
+CTextBuffer::CTextBuffer(int aWidth, int aHeight, int aMaxNumOverflowLines)
+	: iObserver(NULL), iBuffer(NULL), iWidth(aWidth), iHeight(aHeight), iMaxNumOverflowLines(aMaxNumOverflowLines), iNumOverflowLines(0), iCursorPosX(0), iCursorPosY(0), iCaptureFile(0)
+	{
+	}
+
+void CTextBuffer::Construct()
+	{
+	iBuffer = new(EThrow) TCHAR[iWidth * (iHeight + iMaxNumOverflowLines)];
+	ClearBuffer();
+	}
+
+void CTextBuffer::MoveCursor(int aNewX, int aNewY)
+	{
+	ASSERT((aNewX >= 0) && (aNewY >= 0));
+	if ((aNewX >= 0) && (aNewY >= 0))
+		{
+		if (aNewX < iWidth)
+			{
+			iCursorPosX = aNewX;
+			}
+		if (aNewY < iHeight)
+			{
+			iCursorPosY = aNewY;
+			}
+		if (iObserver)
+			{
+			iObserver->HandleTextBufferCursorChange();
+			}
+		}
+	}
+
+PTCHAR CTextBuffer::CursorPtr() const
+	{
+	return iBuffer + (((iMaxNumOverflowLines + iCursorPosY) * iWidth) + iCursorPosX);
+	}
+
+PTCHAR CTextBuffer::LineEndPtr() const
+	{
+	return iBuffer + (((iMaxNumOverflowLines + iCursorPosY) * iWidth) + (iWidth - 1));
+	}
+
+PTCHAR CTextBuffer::BufEndPtr() const
+	{
+	return iBuffer + (iWidth * (iHeight + iMaxNumOverflowLines));
+	}
+
+void CTextBuffer::WriteSpecialChar(TCHAR aChar)
+	{
+	switch(aChar)
+		{
+		case 0x00:	// Null.
+			break;
+		case 0x07:	// Bell.
+			break;
+		case 0x08:	// Backspace.
+		case 0x7f:	// Delete.
+			BackSpace();
+			break;
+		case 0x09:
+			HorizontalTab();
+			break;
+		case 0x0a:
+			LineFeed();
+			break;
+		case 0x0b:	// Vertical tab.
+			break;
+		case 0x0c:
+			FormFeed();
+			break;
+		case 0x0d:
+			CarriageReturn();
+			break;
+		default:
+			ASSERT(FALSE);
+		}
+	}
+
+void CTextBuffer::WriteBlock(LPCTSTR aString, int aLength)
+	{
+	PTCHAR cursorPtr = CursorPtr();
+	PTCHAR ptr = cursorPtr;
+	for (int i = 0; i < aLength; ++i)
+		{
+		*ptr++ = aString[i];
+		}
+	if (iObserver)
+		{
+		iObserver->HandleTextBufferChange(iCursorPosX, iCursorPosY, cursorPtr, aLength);
+		}
+	if ((iCursorPosX + aLength) == iWidth)
+		{
+		MoveCursor(iWidth - 1, iCursorPosY);
+		CursorRight();
+		}
+	else
+		{
+		MoveCursor(iCursorPosX + aLength, iCursorPosY);
+		}
+	}
+
+bool CTextBuffer::IsOrdinaryChar(TCHAR aChar) const
+	{
+	switch(aChar)
+		{
+		case 0x00:	// Null.
+		case 0x07:	// Bell.
+		case 0x08:	// Backspace.
+		case 0x7f:	// Delete.
+		case 0x09:	// Tab.
+		case 0x0a:	// Line feed.
+		case 0x0b:	// Vertical tab.
+		case 0x0c:	// Form feed.
+		case 0x0d:	// Carriage return.
+			return FALSE;
+		default:
+			return TRUE;
+		}
+	}
+
+int CTextBuffer::NumCharsToLineEnd() const
+	{
+	return iWidth - iCursorPosX;
+	}
+
+void CTextBuffer::ClearBuffer()
+	{
+	PTCHAR bufPtr = iBuffer;
+	PTCHAR end = BufEndPtr();
+	while (bufPtr < end )
+		{
+		*bufPtr++ = TCHAR(' ');
+		}
+	iNumOverflowLines = 0;
+	if (iObserver)
+		{
+		iObserver->HandleTextBufferCleared();
+		}
+	}
+
+LPCTSTR CTextBuffer::GetLine(int aPos) const
+	{
+	ASSERT(aPos >= -iNumOverflowLines);
+	ASSERT(aPos < iHeight);
+	return iBuffer + ((iMaxNumOverflowLines + aPos) * iWidth);
+	}
+
+void CTextBuffer::CaptureToFile(LPCTSTR aFileName)
+	{
+	ASSERT(iCaptureFile == 0);
+	iCaptureFile = _wopen(aFileName, _O_CREAT | _O_WRONLY | _O_BINARY, _S_IWRITE);
+	if (iCaptureFile == -1)
+		{
+		iCaptureFile = 0;
+		throw KExceptionFailedToCreateCaptureFile;
+		}
+	WriteOverflowLinesToCaptureFile();
+	}
+
+void CTextBuffer::StopCaptureToFile()
+	{
+	if (iCaptureFile)
+		{
+		WriteBufferToCaptureFile();
+		_close(iCaptureFile);
+		iCaptureFile = 0;
+		}
+	}
+
+bool CTextBuffer::IsCapturingToFile() const
+	{
+	return !(iCaptureFile == 0);
+	}
+
+void CTextBuffer::CursorLeft()
+	{
+	if (iCursorPosX > 0)
+		{
+		// Not yet reached beginning of line.
+		MoveCursor(iCursorPosX - 1, iCursorPosY);
+		}
+	else if (iCursorPosY > 0)
+		{
+		// Reached beginning of line, so jump to end of line above.
+		MoveCursor(iWidth - 1, iCursorPosY - 1);
+		}
+	else
+		{
+		// Reached the top left corner of the console - do nothing.
+		}
+	}
+
+void CTextBuffer::CursorRight()
+	{
+	if (iCursorPosX < (iWidth - 1))
+		{
+		// Not yet reached the end of the line.
+		MoveCursor(iCursorPosX + 1, iCursorPosY);
+		}
+	else if (iCursorPosY < (iHeight - 1))
+		{
+		// Reached the end of the line and there's space below - jump to the beginning of the line below.
+		MoveCursor(0, iCursorPosY + 1);
+		}
+	else
+		{
+		// Reached the end of the line and there's no space below - scroll up a line and jump to the beginning of the newly exposed line.
+		ScrollUp();
+		MoveCursor(0, iCursorPosY);
+		}
+	}
+
+void CTextBuffer::FormFeed()
+	{
+	Clear();
+	}
+
+void CTextBuffer::LineFeed()
+	{
+	if (iCursorPosY < (iHeight - 1))
+		{
+		MoveCursor(0, iCursorPosY + 1);
+		}
+	else
+		{
+		ScrollUp();
+		MoveCursor(0, iCursorPosY);
+		}
+	}
+
+void CTextBuffer::CarriageReturn()
+	{
+	MoveCursor(0, iCursorPosY);
+	}
+
+void CTextBuffer::BackSpace()
+	{
+	if (!((iCursorPosX == 0) && (iCursorPosY == 0)))
+		{
+		CursorLeft();
+		WriteBlock(TEXT(" "), 1);
+		CursorLeft();
+		}
+	}
+
+void CTextBuffer::HorizontalTab()
+	{
+	MoveCursor(iCursorPosX - (iCursorPosX % KTabSize) + KTabSize, iCursorPosY);
+	if (iCursorPosX > (iWidth - 1))
+		{
+		CarriageReturn();
+		LineFeed();
+		}
+	}
+
+void CTextBuffer::ScrollUp()
+	{
+	WriteLineToCaptureFile(GetLine(0));
+	PTCHAR dst = iBuffer;
+	PTCHAR end = BufEndPtr();
+	PTCHAR src = dst + iWidth;
+	while (src < end)
+		{
+		*dst++ = *src++;
+		}
+	while (dst < end)
+		{
+		*dst++ = TCHAR(' ');
+		}
+	if (iNumOverflowLines < iMaxNumOverflowLines)
+		{
+		++iNumOverflowLines;
+		}
+	if (iObserver)
+		{
+		iObserver->HandleTextBufferScroll();
+		}
+	}
+
+void CTextBuffer::WriteLineToCaptureFile(LPCTSTR aLinePtr)
+	{
+	if (iCaptureFile)
+		{
+		LPCTSTR lineEnd = aLinePtr + iWidth - 1;
+		while ((*lineEnd == TCHAR(' ')) && (lineEnd > aLinePtr))
+			{
+			--lineEnd;
+			}
+		if (lineEnd == aLinePtr)
+			{
+			if (_write(iCaptureFile, "\r\n", 2) != 2)
+				{
+				_close(iCaptureFile);
+				iCaptureFile = 0;
+				throw KExceptionFailedToWriteToCaptureFile;
+				}
+			}
+		else
+			{
+			const int lineLength = (lineEnd - aLinePtr) + 3;
+			std::auto_ptr<char> narrowBuf(new(EThrow) char[lineLength]);
+			char* narrowBufPtr = narrowBuf.get();
+			while (aLinePtr <= lineEnd)
+				{
+				*narrowBufPtr++ = (char)*aLinePtr++;
+				}
+			*narrowBufPtr++ = '\r';
+			*narrowBufPtr = '\n';
+			if (_write(iCaptureFile, narrowBuf.get(), lineLength) != lineLength)
+				{
+				_close(iCaptureFile);
+				iCaptureFile = 0;
+				throw KExceptionFailedToWriteToCaptureFile;
+				}
+			
+			}
+		}
+	}
+
+void CTextBuffer::WriteOverflowLinesToCaptureFile()
+	{
+	for (int i = -iNumOverflowLines; i < 0; ++i)
+		{
+		WriteLineToCaptureFile(GetLine(i));
+		}
+	}
+
+void CTextBuffer::WriteBufferToCaptureFile()
+	{
+	for (int i = 0; i < iHeight; ++i)
+		{
+		WriteLineToCaptureFile(GetLine(i));
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/TextBuffer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,86 @@
+// TextBuffer.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __TEXTBUFFER_H__
+#define __TEXTBUFFER_H__
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "base.h"
+
+
+class MTextBufferObserver
+	{
+public:
+	virtual void HandleTextBufferChange(int aPosX, int aPosY, PTCHAR aPtr, int aLength) = 0;
+	virtual void HandleTextBufferScroll() = 0;
+	virtual void HandleTextBufferCursorChange() = 0;
+	virtual void HandleTextBufferCleared() = 0;
+	};
+
+
+class CTextBuffer : public CBase
+	{
+public:
+	static CTextBuffer* New(int aWidth, int aHeight, int aMaxNumOverflowLines);
+	virtual ~CTextBuffer();
+	void SetObserver(MTextBufferObserver* aObserver);
+	void Write(LPCTSTR aString, int aLength);
+	void GetCursorPos(int& aX, int& aY) const;
+	void SetAbsCursorPos(int aX, int aY);
+	void SetRelCursorPos(int aX, int aY);
+	void GetSize(int& aWidth, int& aHeight) const;
+	int NumOverflowLines() const;
+	void Clear();
+	void ClearToEndOfLine();
+	LPCTSTR GetLine(int aPos) const;
+	void CaptureToFile(LPCTSTR aFileName);
+	void StopCaptureToFile();
+	bool IsCapturingToFile() const;
+private:
+	CTextBuffer(int aWidth, int aHeight, int aMaxNumOverflowLines);
+	void Construct();
+	void MoveCursor(int aNewX, int aNewY);
+	PTCHAR CursorPtr() const;
+	PTCHAR LineEndPtr() const;
+	PTCHAR BufEndPtr() const;
+	void WriteSpecialChar(TCHAR aChar);
+	void WriteBlock(LPCTSTR aString, int aLength);
+	bool IsOrdinaryChar(TCHAR aChar) const;
+	int NumCharsToLineEnd() const;
+	void ClearBuffer();
+	void CursorLeft();
+	void CursorRight();
+	void FormFeed();
+	void LineFeed();
+	void CarriageReturn();
+	void BackSpace();
+	void HorizontalTab();
+	void ScrollUp();
+	void WriteLineToCaptureFile(LPCTSTR aLinePtr);
+	void WriteOverflowLinesToCaptureFile();
+	void WriteBufferToCaptureFile();
+private:
+	MTextBufferObserver* iObserver;
+	PTCHAR iBuffer;
+	const int iWidth;
+	const int iHeight;
+	const int iMaxNumOverflowLines;
+	int iNumOverflowLines;
+	int iCursorPosX;
+	int iCursorPosY;
+	int iCaptureFile;
+	};
+
+#endif // __TEXTBUFFER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/TextView.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,811 @@
+// TextView.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include "Misc.h"
+#include "TextView.h"
+#include "Window.h"
+
+
+const int KCursorHeight = 2;
+
+
+CTextView* CTextView::New(CWindow& aWindow, CTextBuffer& aTextBuffer, int aWidthInChars, int aHeightInChars)
+	{
+	std::auto_ptr<CTextView> self(new(EThrow) CTextView(aWindow, aTextBuffer));
+	self->Construct(aWidthInChars, aHeightInChars);
+	return self.release();
+	}
+
+CTextView::~CTextView()
+	{
+	}
+
+CTextView::CTextView(CWindow& aWindow, CTextBuffer& aTextBuffer)
+	: iWindow(aWindow), iTextBuffer(aTextBuffer), iViewWidth(0), iViewHeight(0), iNumOverflowLines(aTextBuffer.NumOverflowLines()), iCursorEnabled(TRUE), iUpdating(FALSE), iCursorHidden(FALSE), iFocused(FALSE), iSelectionX1(-1), iSelectionY1(-1), iSelectionX2(-1), iSelectionY2(-1), iSelecting(FALSE), iDimmed(FALSE)
+	{
+	}
+
+void CTextView::Construct(int aWidthInChars, int aHeightInChars)
+	{
+	iFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
+	LOGFONT logFont;
+	if (GetObject(iFont, sizeof(LOGFONT), &logFont) == 0)
+		{
+		throw KExceptionConsoleWindowConstructFailed;
+		}
+
+	// ToDo - Figure out why logFont appears to be out by 1.
+	iCharWidth = 8;//logFont.lfWidth;
+	iCharHeight = 13;//logFont.lfHeight;
+	iViewWidth = aWidthInChars * iCharWidth;
+	iViewHeight = aHeightInChars * iCharHeight;
+
+	ResetBufferPos();
+	ConfigureScrollBars(TRUE);
+	iTextBuffer.SetObserver(this);
+	}
+
+void CTextView::EnableCursor()
+	{
+	if (!iCursorEnabled)
+		{
+		iCursorEnabled = TRUE;
+		SetCursorVisibility();
+		}
+	}
+
+void CTextView::DisableCursor()
+	{
+	if (iCursorEnabled)
+		{
+		iCursorEnabled = FALSE;
+		SetCursorVisibility();
+		}
+	}
+
+void CTextView::BeginUpdate()
+	{
+	ASSERT(!iUpdating);
+	iUpdating = TRUE;
+	SetCursorVisibility();
+	}
+
+void CTextView::EndUpdate()
+	{
+	ASSERT(iUpdating);
+	iUpdating = FALSE;
+	SetCursorVisibility();
+	}
+
+void CTextView::Draw() const
+	{
+	PAINTSTRUCT ps;
+	HDC hdc = BeginPaint(iWindow.Handle(), &ps);
+	HRGN undrawnRegion = CreateRectRgn(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
+	--ps.rcPaint.right;
+	--ps.rcPaint.bottom;
+	SetMapMode(hdc, MM_TEXT);
+	HFONT oldFont = (HFONT)SelectObject(hdc, iFont);
+	int bufferWidth;
+	int bufferHeight;
+	iTextBuffer.GetSize(bufferWidth, bufferHeight);
+	int firstLineToDraw;
+	int lastLineToDraw;
+	GetVisibleLines(ps.rcPaint, firstLineToDraw, lastLineToDraw);
+	RECT selectionRect;
+	GetSelectionRect(selectionRect);
+
+	for (int i = firstLineToDraw; i <= lastLineToDraw; ++i)
+		{
+		RECT lineRect;
+		GetViewRect(0, i, bufferWidth, lineRect);
+		RECT selectionIntersection;
+		IntersectRect(&selectionIntersection, &selectionRect, &lineRect);
+		if (IsRectEmpty(&selectionIntersection))
+			{
+			COLORREF origTextColor;
+			if (iDimmed)
+				{
+				origTextColor = SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
+				}
+			TextOut(hdc, lineRect.left, lineRect.top, iTextBuffer.GetLine(i), bufferWidth);
+			if (iDimmed)
+				{
+				SetTextColor(hdc, origTextColor);
+				}
+			}
+		else
+			{
+			LPCTSTR lineText = iTextBuffer.GetLine(i);
+			RECT drawRect;
+			drawRect.left = lineRect.left;
+			drawRect.top = lineRect.top;
+			drawRect.right = selectionIntersection.left;
+			drawRect.bottom = selectionIntersection.bottom;
+			COLORREF origTextColor;
+			if (iDimmed)
+				{
+				origTextColor = SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
+				}
+			ExtTextOut(hdc, lineRect.left, lineRect.top, ETO_CLIPPED, &drawRect, lineText, bufferWidth, NULL);
+			if (iDimmed)
+				{
+				SetTextColor(hdc, origTextColor);
+				}
+			drawRect.left = drawRect.right;
+			drawRect.right = selectionIntersection.right;
+			origTextColor = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+			COLORREF origBackgroundColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
+			ExtTextOut(hdc, lineRect.left, lineRect.top, ETO_CLIPPED, &drawRect, lineText, bufferWidth, NULL);
+			drawRect.left = drawRect.right;
+			drawRect.right = lineRect.right;
+			SetTextColor(hdc, origTextColor);
+			SetBkColor(hdc, origBackgroundColor);
+			if (iDimmed)
+				{
+				origTextColor = SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
+				}
+			ExtTextOut(hdc, lineRect.left, lineRect.top, ETO_CLIPPED, &drawRect, lineText, bufferWidth, NULL);
+			if (iDimmed)
+				{
+				SetTextColor(hdc, origTextColor);
+				}
+			}
+		HRGN lineRegion = CreateRectRgn(lineRect.left, lineRect.top, lineRect.right, lineRect.bottom);
+		CombineRgn(undrawnRegion, undrawnRegion, lineRegion, RGN_DIFF);
+		DeleteObject(lineRegion);
+		}
+
+	HBRUSH brush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
+	FillRgn(hdc, undrawnRegion, brush);
+	DeleteObject(brush);
+	DeleteObject(undrawnRegion);
+	SelectObject(hdc, oldFont);
+	EndPaint(iWindow.Handle(), &ps);
+	}
+
+void CTextView::HandleFocusGained()
+	{
+	iFocused = TRUE;
+	CreateCaret(iWindow.Handle(), (HBITMAP) NULL, iCharWidth, 2);
+	iCursorHidden = TRUE;
+	SetCursorPos();
+	SetCursorVisibility();
+	}
+
+void CTextView::HandleFocusLost()
+	{
+	iFocused = FALSE;
+	DestroyCaret();
+	}
+
+void CTextView::SetSize(int aWidth, int aHeight)
+	{
+	iViewWidth = aWidth;
+	iViewHeight = aHeight;
+	ResetBufferPos();
+	SetCursorPos();
+	ConfigureScrollBars(TRUE);
+	ReDraw();
+	}
+
+void CTextView::GetSize(int& aWidth, int& aHeight) const
+	{
+	aWidth = iViewWidth;
+	aHeight = iViewHeight;
+	}
+
+void CTextView::SetHorzScrollPosition(int aPosX)
+	{
+	int newBufferPosX;
+	int newBufferPosY;
+	MapScrollPosToBufPix(aPosX, 0, newBufferPosX, newBufferPosY);
+	int dX = newBufferPosX - iBufferPosX;
+	SetBufferPos(newBufferPosX, iBufferPosY);
+	SetCursorPos();
+	ScrollWindowEx(iWindow.Handle(), dX, 0, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+	UpdateWindow(iWindow.Handle());
+	}
+
+void CTextView::SetVertScrollPosition(int aPosY)
+	{
+	int newBufferPosX;
+	int newBufferPosY;
+	MapScrollPosToBufPix(0, aPosY, newBufferPosX, newBufferPosY);
+	int dY = newBufferPosY - iBufferPosY;
+	SetBufferPos(iBufferPosX, newBufferPosY);
+	SetCursorPos();
+	ScrollWindowEx(iWindow.Handle(), 0, dY, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+	UpdateWindow(iWindow.Handle());
+	}
+
+void CTextView::StartSelection(int aPosX, int aPosY)
+	{
+	ASSERT(!iSelecting);
+	iSelecting = TRUE;
+	RECT invalidRect;
+	GetSelectionRect(invalidRect);
+	if (!IsRectEmpty(&invalidRect))
+		{
+		InvalidateRect(iWindow.Handle(), &invalidRect, FALSE);
+		}
+	MapViewPixToBufPix(aPosX, aPosY, aPosX, aPosY);
+	MapBufPixToBufChar(aPosX, aPosY, iSelectionX1, iSelectionY1);
+	iSelectionX2 = iSelectionX1;
+	iSelectionY2 = iSelectionY1;
+	GetSelectionRect(invalidRect);
+	InvalidateRect(iWindow.Handle(), &invalidRect, FALSE);
+	UpdateWindow(iWindow.Handle());
+	}
+
+void CTextView::AdjustSelection(int aPosX, int aPosY)
+	{
+	if (iSelecting)
+		{
+		RECT previousSelectionRect;
+		GetSelectionRect(previousSelectionRect);
+		MapViewPixToBufPix(aPosX, aPosY, aPosX, aPosY);
+		MapBufPixToBufChar(aPosX, aPosY, iSelectionX2, iSelectionY2);
+		int bufferWidth;
+		int bufferHeight;
+		iTextBuffer.GetSize(bufferWidth, bufferHeight);
+		if (iSelectionX2 < 0)
+			{
+			iSelectionX2 = 0;
+			}
+		if (iSelectionX2 >= bufferWidth)
+			{
+			iSelectionX2 = bufferWidth - 1;
+			}
+		if (iSelectionY2 < -iNumOverflowLines)
+			{
+			iSelectionY2 = -iNumOverflowLines;
+			}
+		if (iSelectionY2 >= bufferHeight)
+			{
+			iSelectionY2 = bufferHeight - 1;
+			}
+		RECT newSelectionRect;
+		GetSelectionRect(newSelectionRect);
+
+		HRGN previousSelectionRegion = CreateRectRgn(previousSelectionRect.left, previousSelectionRect.top, previousSelectionRect.right, previousSelectionRect.bottom);
+		HRGN region = CreateRectRgn(newSelectionRect.left, newSelectionRect.top, newSelectionRect.right, newSelectionRect.bottom);
+		CombineRgn(region, region, previousSelectionRegion, RGN_XOR);
+		DeleteObject(previousSelectionRegion);
+
+		RECT regionBox;
+		if (GetRgnBox(region, &regionBox) != NULLREGION)
+			{
+			InvalidateRgn(iWindow.Handle(), region, FALSE);
+			UpdateWindow(iWindow.Handle());
+			}
+		DeleteObject(region);
+		}
+	}
+
+void CTextView::EndSelection(int aPosX, int aPosY)
+	{
+	if (iSelecting)
+		{
+		AdjustSelection(aPosX, aPosY);
+		}
+	iSelecting = FALSE;
+	}
+
+void CTextView::SelectWord(int aPosX, int aPosY)
+	{
+	iSelecting = FALSE;
+	RECT invalidRect;
+	GetSelectionRect(invalidRect);
+	if (!IsRectEmpty(&invalidRect))
+		{
+		InvalidateRect(iWindow.Handle(), &invalidRect, FALSE);
+		}
+
+	MapViewPixToBufPix(aPosX, aPosY, aPosX, aPosY);
+	MapBufPixToBufChar(aPosX, aPosY, iSelectionX1, iSelectionY1);
+	iSelectionX2 = iSelectionX1;
+	iSelectionY2 = iSelectionY1;
+	LPCTSTR linePtr = iTextBuffer.GetLine(iSelectionY1);
+
+	if (*(linePtr + iSelectionX1) != TCHAR(' '))
+		{
+		// Find the beginning of the word.
+		while ((*(linePtr + iSelectionX1) != TCHAR(' ')) && (iSelectionX1 > 0))
+			{
+			--iSelectionX1;
+			}
+		if (*(linePtr + iSelectionX1) == TCHAR(' '))
+			{
+			++iSelectionX1;
+			}
+		int bufferWidth;
+		int bufferHeight;
+		iTextBuffer.GetSize(bufferWidth, bufferHeight);
+
+		// Find the end of the word.
+		while ((*(linePtr + iSelectionX2) != TCHAR(' ')) && (iSelectionX2 < bufferWidth))
+			{
+			++iSelectionX2;
+			}
+		if (*(linePtr + iSelectionX2) == TCHAR(' '))
+			{
+			--iSelectionX2;
+			}
+		}
+
+	GetSelectionRect(invalidRect);
+	InvalidateRect(iWindow.Handle(), &invalidRect, FALSE);
+	}
+
+int CTextView::CharHeight() const
+	{
+	return iCharHeight;
+	}
+
+int CTextView::CharWidth() const
+	{
+	return iCharWidth;
+	}
+
+bool CTextView::SelectionAvailable() const
+	{
+	if (iSelectionX1 == -1)
+		{
+		ASSERT(iSelectionY1 == -1);
+		ASSERT(iSelectionX2 == -1);
+		ASSERT(iSelectionY2 == -1);
+		return FALSE;
+		}
+	return TRUE;
+	}
+
+LPTSTR CTextView::Selection() const
+	{
+	ASSERT(iSelectionX1 != -1);
+	ASSERT(iSelectionY1 != -1);
+	ASSERT(iSelectionX2 != -1);
+	ASSERT(iSelectionY2 != -1);
+	int tlX = min(iSelectionX1, iSelectionX2);
+	int tlY = min(iSelectionY1, iSelectionY2);
+	int brX = max(iSelectionX1, iSelectionX2);
+	int brY = max(iSelectionY1, iSelectionY2);
+	TCHAR* buf = new TCHAR[((brX - tlX + 3) * (brY - tlY + 1)) + 1];
+	if (buf)
+		{
+		TCHAR* bufPtr = buf;
+		for (int y = tlY; y <= brY; ++y)
+			{
+			LPCTSTR lineText = iTextBuffer.GetLine(y);
+			int x;
+			for (x = tlX; x <= brX; ++x)
+				{
+				*bufPtr++ = lineText[x];
+				}
+			while ((*(bufPtr - 1) == TCHAR(' ')) && (x > tlX))
+				{	// Remove trailing spaces from line.
+				--bufPtr;
+				--x;
+				}
+			if (y < brY)
+				{
+				*bufPtr++ = TCHAR('\r');
+				*bufPtr++ = TCHAR('\n');
+				}
+			}
+		*bufPtr = TCHAR('\0');
+		}
+	return buf;
+	}
+
+void CTextView::ClearSelection()
+	{
+	RECT invalidRect;
+	GetSelectionRect(invalidRect);
+	iSelectionX1 = iSelectionY1 = iSelectionX2 = iSelectionY2 = -1;
+	if (!IsRectEmpty(&invalidRect))
+		{
+		InvalidateRect(iWindow.Handle(), &invalidRect, FALSE);
+		UpdateWindow(iWindow.Handle());
+		}
+	}
+
+void CTextView::SetDimmed(bool aDimmed)
+	{
+	if (!aDimmed != !iDimmed)
+		{
+		iDimmed = aDimmed;
+		if (iDimmed)
+			{
+			DisableCursor();
+			}
+		else
+			{
+			EnableCursor();
+			}
+		iWindow.Redraw();
+		}
+	}
+
+void CTextView::HandleTextBufferChange(int aPosX, int aPosY, PTCHAR aPtr, int aLength)
+	{
+	RECT viewRect;
+	GetViewRect(aPosX, aPosY, aLength, viewRect);
+	RECT clientRect = {0, 0, iViewWidth, iViewHeight};
+	RECT intersection;
+	IntersectRect(&intersection, &clientRect, &viewRect);
+	if (!IsRectEmpty(&intersection))
+		{
+		InvalidateRect(iWindow.Handle(), &intersection, FALSE);
+		UpdateWindow(iWindow.Handle());
+		}
+	}
+
+void CTextView::HandleTextBufferScroll()
+	{
+	bool doScroll(FALSE);
+	ASSERT((iNumOverflowLines == iTextBuffer.NumOverflowLines()) || (iNumOverflowLines + 1 == iTextBuffer.NumOverflowLines()));
+	bool newOverflowLine(iNumOverflowLines != iTextBuffer.NumOverflowLines());
+	int moveBufferBy(0);
+
+	if (BottomLineVisible())
+		{
+		if (newOverflowLine)
+			{
+			moveBufferBy = -iCharHeight;
+			}
+		doScroll = TRUE;
+		}
+	else if (TopLineVisible() && !newOverflowLine)
+		{
+		doScroll = TRUE;
+		}
+	else if (!newOverflowLine)
+		{
+		moveBufferBy = iCharHeight;
+		}
+
+	if (newOverflowLine)
+		{
+		++iNumOverflowLines;
+		}
+
+	ScrollSelection();
+
+	if (moveBufferBy)
+		{
+		MoveBuffer(moveBufferBy);
+		}
+
+	if (doScroll)
+		{
+		ScrollWindowEx(iWindow.Handle(), 0, -iCharHeight, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+		UpdateWindow(iWindow.Handle());
+		}
+
+	SetCursorPos();
+	ConfigureScrollBars(FALSE);
+	}
+
+void CTextView::HandleTextBufferCursorChange()
+	{
+	SetCursorPos();
+	}
+
+void CTextView::HandleTextBufferCleared()
+	{
+	iNumOverflowLines = 0;
+	ResetBufferPos();
+	ConfigureScrollBars(TRUE);
+	ReDraw();
+	}
+
+void CTextView::SetCursorVisibility()
+	{
+	if (iCursorEnabled && !iUpdating && CursorInView())
+		{
+		if (iCursorHidden)
+			{
+			ShowCaret(iWindow.Handle());
+			iCursorHidden = FALSE;
+			}
+		}
+	else if (!iCursorHidden)
+		{
+		HideCaret(iWindow.Handle());
+		iCursorHidden = TRUE;
+		}
+	}
+
+bool CTextView::CursorInView() const
+	{
+	int cursorX;
+	int cursorY;
+	GetCursorPixelPos(cursorX, cursorY);
+	RECT cursorRect = {cursorX, cursorY, cursorX + iCharWidth, cursorY + KCursorHeight};
+	return RectVisible(cursorRect);
+	}
+
+void CTextView::GetCursorPixelPos(int& aX, int& aY) const
+	{
+	iTextBuffer.GetCursorPos(aX, aY);
+	MapBufCharToBufPix(aX, aY, aX, aY);
+	aY += (iCharHeight - KCursorHeight);
+	MapBufPixToViewPix(aX, aY, aX, aY);
+	}
+
+void CTextView::SetCursorPos()
+	{
+	if (iFocused)
+		{
+		int cursorX;
+		int cursorY;
+		GetCursorPixelPos(cursorX, cursorY);
+		SetCaretPos(cursorX, cursorY);
+		}
+	}
+
+void CTextView::ResetBufferPos()
+	{
+	SetBufferPos(0, MinBufferPosY());
+	}
+
+void CTextView::SetBufferPos(int aPosX, int aPosY)
+	{
+	iBufferPosX = aPosX;
+	iBufferPosY = aPosY;
+	SetCursorVisibility();
+	}
+
+void CTextView::MoveBuffer(int aDiffY)
+	{
+	iBufferPosY += aDiffY;
+	ASSERT(iBufferPosY <= MaxBufferPosY());
+	int min = MinBufferPosY();
+	if (iBufferPosY < min)
+		{
+		iBufferPosY = min;
+		}
+	}
+
+void CTextView::ConfigureScrollBars(bool aReset)
+	{
+	int bufferWidth;
+	int bufferHeight;
+	iTextBuffer.GetSize(bufferWidth, bufferHeight);
+	bufferHeight += iNumOverflowLines;
+
+	int vertMax = (bufferHeight * iCharHeight) - 1;
+	int horzMax = (bufferWidth * iCharWidth) - 1;
+
+	SCROLLINFO scrollInfo;
+	scrollInfo.cbSize = sizeof(scrollInfo);
+	scrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+	scrollInfo.nMin = 0;
+	scrollInfo.nMax = vertMax;
+	scrollInfo.nPage = iViewHeight;
+	if (aReset)
+		{
+		scrollInfo.nPos = vertMax;
+		}
+	else
+		{
+		scrollInfo.nPos = -iBufferPosY;
+		}
+	SetScrollInfo(iWindow.Handle(), SB_VERT, &scrollInfo, TRUE);
+
+	scrollInfo.fMask = aReset ? SIF_RANGE | SIF_PAGE | SIF_POS : SIF_RANGE | SIF_PAGE;
+	scrollInfo.nMax = horzMax;
+	scrollInfo.nPage = iViewWidth;
+	if (aReset)
+		{
+		scrollInfo.nPos = 0;
+		}
+	SetScrollInfo(iWindow.Handle(), SB_HORZ, &scrollInfo, TRUE);
+	}
+
+void CTextView::ReDraw() const
+	{
+	InvalidateRect(iWindow.Handle(), NULL, FALSE);
+	}
+
+void CTextView::GetViewRect(int aCharPosX, int aCharPosY, int aNumChars, RECT& aRect) const
+	{
+	int x;
+	int y;
+	MapBufCharToBufPix(aCharPosX, aCharPosY, x, y);
+	MapBufPixToViewPix(x, y, x, y);
+	aRect.left = x;
+	aRect.top = y;
+	aRect.right = aRect.left + (aNumChars * iCharWidth);
+	aRect.bottom = aRect.top + iCharHeight;
+	}
+
+void CTextView::GetViewRect(int aCharPosX1, int aCharPosY1, int aCharPosX2, int aCharPosY2, RECT& aRect) const
+	{
+	int tlX = min(aCharPosX1, aCharPosX2);
+	int tlY = min(aCharPosY1, aCharPosY2);
+	int brX = max(aCharPosX1, aCharPosX2);
+	int brY = max(aCharPosY1, aCharPosY2);
+	MapBufCharToBufPix(tlX, tlY, tlX, tlY);
+	MapBufPixToViewPix(tlX, tlY, tlX, tlY);
+	MapBufCharToBufPix(brX, brY, brX, brY);
+	MapBufPixToViewPix(brX, brY, brX, brY);
+	brX += iCharWidth;
+	brY += iCharHeight;
+	aRect.left = tlX;
+	aRect.top = tlY;
+	aRect.right = brX;
+	aRect.bottom = brY;
+	}
+
+bool CTextView::RectVisible(const RECT& aRect) const
+	{
+	RECT clientRect = {0, 0, iViewWidth, iViewHeight};
+	RECT intersection;
+	IntersectRect(&intersection, &clientRect, &aRect);
+	return !IsRectEmpty(&intersection);
+	}
+
+bool CTextView::LineVisible(int aLinePos) const
+	{
+	int bufWidth;
+	int bufHeight;
+	iTextBuffer.GetSize(bufWidth, bufHeight);
+	RECT rect;
+	GetViewRect(0, aLinePos, bufWidth, rect);
+	return RectVisible(rect);
+	}
+
+bool CTextView::TopLineVisible() const
+	{
+	return LineVisible(-iNumOverflowLines);
+	}
+
+bool CTextView::BottomLineVisible() const
+	{
+	int bufWidth;
+	int bufHeight;
+	iTextBuffer.GetSize(bufWidth, bufHeight);
+	return LineVisible(bufHeight - 1);
+	}
+
+int CTextView::TotalBufferHeight() const
+	{
+	int bufferWidth;
+	int bufferHeight;
+	iTextBuffer.GetSize(bufferWidth, bufferHeight);
+	return (bufferHeight + iNumOverflowLines) * iCharHeight;
+	}
+
+int CTextView::MinBufferPosY() const
+	{
+	return iViewHeight - TotalBufferHeight();
+	}
+
+int CTextView::MaxBufferPosY() const
+	{
+	int minBufferPosY = MinBufferPosY();
+	if (minBufferPosY <= 0)
+		{
+		return 0;
+		}
+	return minBufferPosY;
+	}
+
+void CTextView::GetVisibleLines(const RECT& aRect, int& aFrom, int& aTo) const
+	{
+	int x;
+	int y;
+	MapViewPixToBufPix(aRect.left, aRect.top, x, y);
+	MapBufPixToBufChar(x, y, x, aFrom);
+	MapViewPixToBufPix(aRect.right, aRect.bottom, x, y);
+	MapBufPixToBufChar(x, y, x, aTo);
+	int bufWidth;
+	int bufHeight;
+	iTextBuffer.GetSize(bufWidth, bufHeight);
+	if (aFrom < -iNumOverflowLines)
+		{
+		aFrom = -iNumOverflowLines;
+		}
+	if (aFrom >= bufHeight)
+		{
+		aFrom = bufHeight - 1;
+		}
+	if (aTo >= bufHeight)
+		{
+		aTo = bufHeight - 1;
+		}
+	}
+
+void CTextView::MapBufCharToBufPix(int aBufCharPosX, int aBufCharPosY, int& aBufPixPosX, int& aBufPixPosY) const
+	{
+	aBufPixPosX = aBufCharPosX * iCharWidth;
+	aBufPixPosY = (iNumOverflowLines + aBufCharPosY) * iCharHeight;
+	}
+
+void CTextView::MapBufPixToViewPix(int aBufPixPosX, int aBufPixPosY, int& aViewPixPosX, int& aViewPixPosY) const
+	{
+	aViewPixPosX = aBufPixPosX + iBufferPosX;
+	aViewPixPosY = aBufPixPosY + iBufferPosY;
+	}
+
+void CTextView::MapBufPixToBufChar(int aBufPixPosX, int aBufPixPosY, int& aBufCharPosX, int& aBufCharPosY) const
+	{
+	aBufCharPosX = aBufPixPosX / iCharWidth;
+	aBufCharPosY = (aBufPixPosY / iCharHeight) - iNumOverflowLines;
+	}
+
+void CTextView::MapViewPixToBufPix(int aViewPixPosX, int aViewPixPosY, int& aBufPixPosX, int& aBufPixPosY) const
+	{
+	aBufPixPosX = aViewPixPosX - iBufferPosX;
+	aBufPixPosY = aViewPixPosY - iBufferPosY;
+	}
+
+void CTextView::MapScrollPosToBufPix(int aScrollPosX, int aScrollPosY, int& aBufPixPosX, int& aBufPixPosY) const
+	{
+	aBufPixPosX = -aScrollPosX;
+	aBufPixPosY = -aScrollPosY;
+	}
+
+void CTextView::GetSelectionRect(RECT& aRect) const
+	{
+	if (iSelectionX1 == -1)
+		{
+		ASSERT(iSelectionY1 == -1);
+		ASSERT(iSelectionX2 == -1);
+		ASSERT(iSelectionY2 == -1);
+		aRect.bottom = aRect.left = aRect.right = aRect.top = 0;
+		}
+	else
+		{
+		GetViewRect(iSelectionX1, iSelectionY1, iSelectionX2, iSelectionY2, aRect);
+		}
+	}
+
+void CTextView::ScrollSelection()
+	{
+	if (iSelectionX1 == -1)
+		{
+		ASSERT(iSelectionY1 == -1);
+		ASSERT(iSelectionX2 == -1);
+		ASSERT(iSelectionY2 == -1);
+		}
+	else
+		{
+		if ((iSelectionY1 == -iNumOverflowLines) && (iSelectionY2 == -iNumOverflowLines))
+			{
+			iSelectionX1 = iSelectionY1 = iSelectionX2 = iSelectionY2 = -1;
+			}
+		else
+			{
+			--iSelectionY1;
+			--iSelectionY2;
+			if (iSelectionY1 < -iNumOverflowLines)
+				{
+				iSelectionY1 = -iNumOverflowLines;
+				}
+			if (iSelectionY2 < -iNumOverflowLines)
+				{
+				iSelectionY2 = -iNumOverflowLines;
+				}
+			}
+		}
+	}
+
+void CTextView::ScrollToEndIfNeeded()
+	{
+	if (!BottomLineVisible())
+		{
+		SetVertScrollPosition(TotalBufferHeight()-iViewHeight);
+		ConfigureScrollBars(FALSE);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/TextView.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,147 @@
+// TextView.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __TEXTVIEW_H__
+#define __TEXTVIEW_H__
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "base.h"
+#include "TextBuffer.h"
+
+class CWindow;
+
+
+class CTextView : public CBase, public MTextBufferObserver
+	{
+public:
+	static CTextView* New(CWindow& aWindow, CTextBuffer& aTextBuffer, int aWidthInChars, int aHeightInChars);
+	virtual ~CTextView();
+	void EnableCursor();
+	void DisableCursor();
+	void BeginUpdate();
+	void EndUpdate();
+	void Draw() const;
+	void HandleFocusGained();
+	void HandleFocusLost();
+	void SetSize(int aWidth, int aHeight);
+	void GetSize(int& aWidth, int& aHeight) const;
+	void SetHorzScrollPosition(int aPosX);
+	void SetVertScrollPosition(int aPosY);
+	void StartSelection(int aPosX, int aPosY);
+	void AdjustSelection(int aPosX, int aPosY);
+	void EndSelection(int aPosX, int aPosY);
+	void SelectWord(int aPosX, int aPosY);
+	int CharHeight() const;
+	int CharWidth() const;
+	bool SelectionAvailable() const;
+	LPTSTR Selection() const;
+	void ClearSelection();
+	void SetDimmed(bool aDimmed);
+	void ScrollToEndIfNeeded();
+private:
+	CTextView(CWindow& aWindow, CTextBuffer& aTextBuffer);
+	void Construct(int aWidthInChars, int aHeightInChars);
+private: // From MTextBufferObserver.
+	virtual void HandleTextBufferChange(int aPosX, int aPosY, PTCHAR aPtr, int aLength);
+	virtual void HandleTextBufferScroll();
+	virtual void HandleTextBufferCursorChange();
+	virtual void HandleTextBufferCleared();
+private:
+	void SetCursorVisibility();
+	bool CursorInView() const;
+	void GetCursorPixelPos(int& aX, int& aY) const;
+	void SetCursorPos();
+	void ResetBufferPos();
+	void SetBufferPos(int aPosX, int aPosY);
+	void MoveBuffer(int aDiffY);
+	void ConfigureScrollBars(bool aReset);
+	void ReDraw() const;
+	void GetViewRect(int aCharPosX, int aCharPosY, int aNumChars, RECT& aRect) const;
+	void GetViewRect(int aCharPosX1, int aCharPosY1, int aCharPosX2, int aCharPosY2, RECT& aRect) const;
+	bool RectVisible(const RECT& aRect) const;
+	bool LineVisible(int aLinePos) const;
+	bool TopLineVisible() const;
+	bool BottomLineVisible() const;
+	int TotalBufferHeight() const;
+	int MinBufferPosY() const;
+	int MaxBufferPosY() const;
+	void GetVisibleLines(const RECT& aRect, int& aFrom, int& aTo) const;
+	void MapBufCharToBufPix(int aBufCharPosX, int aBufCharPosY, int& aBufPixPosX, int& aBufPixPosY) const;
+	void MapBufPixToViewPix(int aBufPixPosX, int aBufPixPosY, int& aViewPixPosX, int& aViewPixPosY) const;
+	void MapBufPixToBufChar(int aBufPixPosX, int aBufPixPosY, int& aBufCharPosX, int& aBufCharPosY) const;
+	void MapViewPixToBufPix(int aViewPixPosX, int aViewPixPosY, int& aBufPixPosX, int& aBufPixPosY) const;
+	void MapScrollPosToBufPix(int aScrollPosX, int aScrollPosY, int& aBufPixPosX, int& aBufPixPosY) const;
+	void GetSelectionRect(RECT& aRect) const;
+	void ScrollSelection();
+private:
+	CWindow& iWindow;
+	CTextBuffer& iTextBuffer;
+	HFONT iFont;
+	int iCharWidth;			///< Character width in pixels.
+	int iCharHeight;		///< Character height in pixels.
+	int iViewWidth;
+	int iViewHeight;
+	int iBufferPosX;
+	int iBufferPosY;
+	int iNumOverflowLines;
+	bool iCursorEnabled;
+	bool iUpdating;
+	bool iCursorHidden;
+	bool iFocused;
+	int iSelectionX1;		///< In buffer character coordinates.
+	int iSelectionY1;		///<        "             "
+	int iSelectionX2;		///<        "             "
+	int iSelectionY2;		///<        "             "
+	bool iSelecting;
+	bool iDimmed;
+	};
+
+
+
+/*
+        /-- (iBufferPosX, iBufferPosY) in pixels relative to view.
+       /
+      |----------------------------------------------------------------|
+      |                                                                |
+      |                                                                |
+      |                                                                |
+      |                                                                |
+      |                                                                |
+      |                                                                |
+      |        /-- (0, 0) in Windows pixel coordinates.                |
+      |       /                                                        |
+      |   i  |-------------------------------------------------|       |
+      |   V  |                                               |-|       |
+      |   i  |                                               | |       |
+      |   e  |                                               | |       |
+      |   w  |                                               | |       |
+      |   H  |                                               | |       |
+      |   e  |                                               | |       |
+      |   i  |                                               | |       |
+      |   g  |                                               | |       |
+      |   h  |-|---------------------------------------------|-|       |
+      |   t  |-------------------------------------------------|       |
+      |                                                                |
+      |      <----------- iViewWidth (in pixels) ----------->          |
+      |                                                                |
+      |                                                                |
+      |                                                                |
+      |                                                                |
+      |                                                                |
+      |                                                                |
+      |----------------------------------------------------------------|
+*/
+
+#endif // __TEXTVIEW_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Window.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,546 @@
+// Window.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Misc.h"
+#include "stdafx.h"
+#include "console_host.h"
+#include "Window.h"
+
+#ifdef _DEBUG
+#undef THIS_FILE
+static char THIS_FILE[]=__FILE__;
+#endif
+
+const DWORD KWindowStyle = (WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL);// & ~WS_THICKFRAME;
+CWindow* CWindow::sFirst = NULL;
+CWindow* CWindow::sLast = NULL;
+MWindowMessageHandler* CWindow::sFirstMessageHandler = NULL;
+MWindowMessageHandler* CWindow::sLastMessageHandler = NULL;
+
+
+// From e32keys.h
+enum TKeyCode
+	{
+	EKeyNull=0x0000,
+	EKeyBell=0x0007,
+	EKeyBackspace=0x0008,
+	EKeyTab=0x0009,
+	EKeyLineFeed=0x000a,
+	EKeyVerticalTab=0x000b,
+	EKeyFormFeed=0x000c,
+	EKeyEnter=0x000d,
+	EKeyEscape=0x001b,
+	EKeySpace=0x0020,
+	EKeyDelete=0x007f,
+	EKeyPrintScreen=0xf800,
+	EKeyPause,
+	EKeyHome,
+	EKeyEnd,
+	EKeyPageUp,
+	EKeyPageDown,
+	EKeyInsert,
+	EKeyLeftArrow,
+	EKeyRightArrow,
+	EKeyUpArrow,
+	EKeyDownArrow,
+	EKeyLeftShift,
+	EKeyRightShift,
+	EKeyLeftAlt,
+	EKeyRightAlt,
+	EKeyLeftCtrl,
+	EKeyRightCtrl,
+	EKeyLeftFunc,
+	EKeyRightFunc,
+	EKeyCapsLock,
+	EKeyNumLock,
+	EKeyScrollLock,
+	EKeyF1,
+	EKeyF2,
+	EKeyF3,
+	EKeyF4,
+	EKeyF5,
+	EKeyF6,
+	EKeyF7,
+	EKeyF8,
+	EKeyF9,
+	EKeyF10,
+	EKeyF11,
+	EKeyF12,
+	EKeyF13,
+	EKeyF14,
+	EKeyF15,
+	EKeyF16,
+	EKeyF17,
+	EKeyF18,
+	EKeyF19,
+	EKeyF20,
+	EKeyF21,
+	EKeyF22,
+	EKeyF23,
+	EKeyF24,
+    EKeyOff,
+    EKeyIncContrast,
+    EKeyDecContrast,
+    EKeyBacklightOn,
+    EKeyBacklightOff,
+    EKeyBacklightToggle,
+    EKeySliderDown,
+    EKeySliderUp,
+    EKeyMenu,
+    EKeyDictaphonePlay,
+    EKeyDictaphoneStop,
+    EKeyDictaphoneRecord,
+    EKeyHelp,
+    EKeyDial,
+	EKeyScreenDimension0,
+	EKeyScreenDimension1,
+	EKeyScreenDimension2,
+	EKeyScreenDimension3,
+	EKeyIncVolume,
+	EKeyDecVolume,
+	EKeyDevice0,
+	EKeyDevice1,
+	EKeyDevice2,
+	EKeyDevice3,
+	EKeyDevice4,
+	EKeyDevice5,
+	EKeyDevice6,
+	EKeyDevice7,
+	EKeyDevice8,
+	EKeyDevice9,
+	EKeyDeviceA,
+	EKeyDeviceB,
+	EKeyDeviceC,
+	EKeyDeviceD,
+	EKeyDeviceE,
+	EKeyDeviceF,
+	EKeyApplication0,
+	EKeyApplication1,
+	EKeyApplication2,
+	EKeyApplication3,
+	EKeyApplication4,
+	EKeyApplication5,
+	EKeyApplication6,
+	EKeyApplication7,
+	EKeyApplication8,
+	EKeyApplication9,
+	EKeyApplicationA,
+	EKeyApplicationB,
+	EKeyApplicationC,
+	EKeyApplicationD,
+	EKeyApplicationE,
+	EKeyApplicationF,
+	EKeyYes,
+	EKeyNo,
+	EKeyIncBrightness,
+	EKeyDecBrightness
+	};
+
+enum TEventModifier
+	{
+	EModifierAutorepeatable=0x00000001, /**< Key event can auto-repeat.*/
+	EModifierKeypad=0x00000002,         /**< The key that generated the event was on the numeric keypad, on the emulator.*/
+	EModifierLeftAlt=0x00000004,        /**< Left Alt key.*/
+	EModifierRightAlt=0x00000008,       /**< Right Alt key.*/
+	EModifierAlt=0x00000010,            /**< Single Alt key.*/
+	EModifierLeftCtrl=0x00000020,       /**< Left Control (Ctrl) key.*/
+	EModifierRightCtrl=0x00000040,      /**< Right Control (Ctrl) key.*/
+	EModifierCtrl=0x00000080,           /**< Single Control (Ctrl) key.*/
+	EModifierLeftShift=0x00000100,      /**< Left Shift key.*/
+	EModifierRightShift=0x00000200,     /**< Right Shift key.*/
+	EModifierShift=0x00000400,          /**< Single Shift key.*/
+	EModifierLeftFunc=0x00000800,       /**< Left Fn key.*/
+	EModifierRightFunc=0x00001000,      /**< Right Fn key.*/
+	EModifierFunc=0x00002000,           /**< Single Fn key.*/
+	EModifierCapsLock=0x00004000,       /**< Caps lock key.*/
+	EModifierNumLock=0x00008000,        /**< Num lock key.*/
+	EModifierScrollLock=0x00010000,     /**< Scroll lock key.*/
+	EModifierKeyUp=0x00020000,          /**< Key up event.*/
+	EModifierSpecial=0x00040000,        /**< The keycode is a non-standard keyboard character that has been generated in a special keyboard mode, for example accented vowels.*/
+	EModifierDoubleClick=0x00080000,    /**< Double click.*/
+	EModifierPureKeycode=0x00100000,    /**< The key code in the key event is not changed. E.g.an alphabetic key is not changed by the Caps Lock or Shift key being pressed.*/
+	EModifierKeyboardExtend=0x00200000,	/**< The "Keyboard extend" generated modifier. */
+	EModifierCancelRotation=0x00000000, /**< No Keyboard rotation is in effect. */
+	EModifierRotateBy90=0x00400000,		/**< Keyboard rotation through 90 degrees clockwise is in effect. */
+	EModifierRotateBy180=0x00800000,	/**< Keyboard rotation through 180 degrees clockwise is in effect. */
+	EModifierRotateBy270=0x01000000,	/**< Keyboard rotation through 270 degrees clockwise is in effect. */
+	EModifierPointer3DButton1=0x02000000,/**< 3D pointer device specific modifier (button 1). */
+	EModifierPointer3DButton2=0x04000000,/**< 3D pointer device specific modifier (button 2). */
+	EModifierPointer3DButton3=0x08000000,/**< 3D pointer device specific modifier (button 3). */
+	EAllModifiers=0x0fffffff            /**< A combination of all event modifiers.*/
+	};
+
+
+MWindowMessageHandler::MWindowMessageHandler() : iNext(NULL), iPrevious(NULL)
+	{
+	}
+
+CWindow::~CWindow()
+	{
+	if (sLast == this)
+		{
+		ASSERT(iNext == NULL);
+		sLast = iPrevious;
+		}
+	if (sFirst == this)
+		{
+		sFirst = iNext;
+		}
+	if (iPrevious)
+		{
+		iPrevious->iNext = iNext;
+		}
+	if (iNext)
+		{
+		iNext->iPrevious = iPrevious;
+		}
+	}
+
+void CWindow::AddMessageHandler(MWindowMessageHandler& aHandler)
+	{
+	if (sFirstMessageHandler == NULL)
+		{
+		ASSERT(sLastMessageHandler == NULL);
+		sFirstMessageHandler = &aHandler;
+		sLastMessageHandler = &aHandler;
+		}
+	else
+		{
+		sLastMessageHandler->iNext = &aHandler;
+		aHandler.iPrevious = sLastMessageHandler;
+		sLastMessageHandler = &aHandler;
+		}
+	}
+
+void CWindow::RemoveMessageHandler(MWindowMessageHandler& aHandler)
+	{
+	if (sLastMessageHandler == &aHandler)
+		{
+		ASSERT(aHandler.iNext == NULL);
+		sLastMessageHandler = aHandler.iPrevious;
+		}
+	if (sFirstMessageHandler == &aHandler)
+		{
+		sFirstMessageHandler = aHandler.iNext;
+		}
+	if (aHandler.iPrevious)
+		{
+		aHandler.iPrevious->iNext = aHandler.iNext;
+		}
+	if (aHandler.iNext)
+		{
+		aHandler.iNext->iPrevious = aHandler.iPrevious;
+		}
+	}
+
+HWND CWindow::Handle() const
+	{
+	return iHandle;
+	}
+
+void CWindow::SetTitle(LPCTSTR aTitle)
+	{
+	SetWindowText(iHandle, aTitle);
+	}
+
+void CWindow::GetTitle(LPTSTR aTitle, int aMaxLength) const
+	{
+	GetWindowText(iHandle, aTitle, aMaxLength);
+	}
+
+CWindow::CWindow() : iNext(NULL), iPrevious(NULL), iObserver(NULL)
+	{
+	if (sFirst == NULL)
+		{
+		ASSERT(sLast == NULL);
+		sFirst = this;
+		sLast = this;
+		}
+	else
+		{
+		sLast->iNext = this;
+		iPrevious = sLast;
+		sLast = this;
+		}
+	}
+
+void CWindow::Construct(HINSTANCE aAppHandle, LPCTSTR aWindowClass, LPCTSTR aTitle, int aPoxX, int aPosY, int aWidth, int aHeight, MWindowObserver* aObserver)
+	{
+	iAppHandle = aAppHandle;
+	iObserver = aObserver;
+
+	RECT windowRect = {0, 0, aWidth, aHeight};
+	AdjustWindowRect(&windowRect, KWindowStyle, TRUE);
+	windowRect.right += GetSystemMetrics(SM_CYVSCROLL);
+	iHandle = CreateWindow(aWindowClass, aTitle, KWindowStyle, aPoxX, aPosY, windowRect.right-windowRect.left, windowRect.bottom-windowRect.top, NULL, NULL, aAppHandle, NULL);
+	if (iHandle == 0)
+		{
+		throw KExceptionWindowConstructFailed;
+		}
+	ShowWindow(iHandle, SW_SHOWNORMAL);
+	if (UpdateWindow(iHandle) == 0)
+		{
+		throw KExceptionWindowConstructFailed;
+		}
+	}
+
+void CWindow::Redraw()
+	{
+	InvalidateRect(iHandle, NULL, TRUE);
+	}
+
+void CWindow::Draw() const
+	{
+	}
+
+LRESULT CWindow::HandleChar(TCHAR, UINT)
+	{
+	return 0;
+	}
+
+LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+	{
+	switch (message)
+		{
+		case WM_INITDIALOG:
+				return TRUE;
+		case WM_COMMAND:
+			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
+				{
+				EndDialog(hDlg, LOWORD(wParam));
+				return TRUE;
+				}
+			break;
+		}
+    return FALSE;
+	}
+
+LRESULT CWindow::HandleCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam)
+	{
+	int wmId = LOWORD(aWParam); 
+	int wmEvent = HIWORD(aWParam); 
+	switch (wmId)
+		{
+		case ID_ABOUT:
+			DialogBox(iAppHandle, (LPCTSTR)IDD_ABOUTBOX, iHandle, (DLGPROC)About);
+			break;
+		case IDM_EXIT:
+			DestroyWindow(iHandle);
+			break;
+		default:
+			if (iObserver)
+				{
+				return iObserver->HandleWindowCommand(aMessage, aWParam, aLParam);
+				}
+			return DefWindowProc(iHandle, aMessage, aWParam, aLParam);
+		}
+	return 0;
+	}
+
+LRESULT CWindow::HandleFocusChange(bool aFocused)
+	{
+	return 0;
+	}
+
+void CWindow::HandleScrollEvent(UINT aMessage, WPARAM aWParam)
+	{
+	}
+
+void CWindow::HandleSizeChanged(int aWidth, int aHeight)
+	{
+	}
+
+void CWindow::HandleMouseEvent(UINT aMessage, WPARAM aWParam, LPARAM aLParam)
+	{
+	}
+
+void CWindow::HandleMenuPopUp(HMENU aMenu)
+	{
+	}
+
+LRESULT CALLBACK CWindow::HandleMessage(HWND aHandle, UINT aMessage, WPARAM aWParam, LPARAM aLParam)
+	{
+	CWindow* window = Instance(aHandle);
+
+	if (window)
+		{
+		MWindowMessageHandler* messageHandler = sFirstMessageHandler;
+		while (messageHandler)
+			{
+			if (messageHandler->HandleWindowMessage(aMessage, aWParam, aLParam) == 0)
+				{
+				return 0;
+				}
+			messageHandler = messageHandler->iNext;
+			}
+		}
+
+	switch (aMessage) 
+		{
+		case WM_SETFOCUS:
+			if (window)
+				{
+				window->HandleFocusChange(TRUE);
+				}
+			break;
+		case WM_KILLFOCUS:
+			if (window)
+				{
+				window->HandleFocusChange(FALSE);
+				}
+			break;
+		case WM_COMMAND:
+			if (window)
+				{
+				return window->HandleCommand(aMessage, aWParam, aLParam);
+				}
+			break;
+		case WM_KEYDOWN:
+		case WM_SYSKEYDOWN:
+			if (window)
+				{
+				UINT modifiers = EModifierAutorepeatable;
+				if (aMessage == WM_SYSKEYDOWN)
+					{
+					modifiers |= (EModifierLeftAlt | EModifierAlt | EModifierLeftFunc | EModifierFunc);
+					}
+				switch (aWParam) 
+					{ 
+					case VK_LEFT:		return window->HandleChar(EKeyLeftArrow, modifiers);
+					case VK_UP:			return window->HandleChar(EKeyUpArrow, modifiers);
+					case VK_RIGHT:		return window->HandleChar(EKeyRightArrow, modifiers);
+					case VK_DOWN:		return window->HandleChar(EKeyDownArrow, modifiers);
+					case VK_HOME:		return window->HandleChar(EKeyHome, modifiers);
+					case VK_END:		return window->HandleChar(EKeyEnd, modifiers);
+					case VK_PRIOR:		return window->HandleChar(EKeyPageUp, modifiers);
+					case VK_NEXT:		return window->HandleChar(EKeyPageDown, modifiers);
+					case VK_PAUSE:		return window->HandleChar(EKeyPause, modifiers);
+					case VK_PRINT:		return window->HandleChar(EKeyPrintScreen, modifiers);
+					case VK_INSERT:		return window->HandleChar(EKeyInsert, modifiers);
+					case VK_DELETE:		return window->HandleChar(EKeyDelete, modifiers);
+					case VK_CAPITAL:	return window->HandleChar(EKeyCapsLock, modifiers);
+					case VK_NUMLOCK:	return window->HandleChar(EKeyNumLock, modifiers);
+					case VK_SCROLL:		return window->HandleChar(EKeyScrollLock, modifiers);
+					case VK_F1:			return window->HandleChar(EKeyF1, modifiers);
+					case VK_F2:			return window->HandleChar(EKeyF2, modifiers);
+					case VK_F3:			return window->HandleChar(EKeyF3, modifiers);
+					case VK_F4:			return window->HandleChar(EKeyF4, modifiers);
+					case VK_F5:			return window->HandleChar(EKeyF5, modifiers);
+					case VK_F6:			return window->HandleChar(EKeyF6, modifiers);
+					case VK_F7:			return window->HandleChar(EKeyF7, modifiers);
+					case VK_F8:			return window->HandleChar(EKeyF8, modifiers);
+					case VK_F9:			return window->HandleChar(EKeyF9, modifiers);
+					case VK_F10:		return window->HandleChar(EKeyF10, modifiers);
+					case VK_F11:		return window->HandleChar(EKeyF11, modifiers);
+					case VK_F12:		return window->HandleChar(EKeyF12, modifiers);
+					case VK_F13:		return window->HandleChar(EKeyF13, modifiers);
+					case VK_F14:		return window->HandleChar(EKeyF14, modifiers);
+					case VK_F15:		return window->HandleChar(EKeyF15, modifiers);
+					case VK_F16:		return window->HandleChar(EKeyF16, modifiers);
+					case VK_F17:		return window->HandleChar(EKeyF17, modifiers);
+					case VK_F18:		return window->HandleChar(EKeyF18, modifiers);
+					case VK_F19:		return window->HandleChar(EKeyF19, modifiers);
+					case VK_F20:		return window->HandleChar(EKeyF20, modifiers);
+					case VK_F21:		return window->HandleChar(EKeyF21, modifiers);
+					case VK_F22:		return window->HandleChar(EKeyF22, modifiers);
+					case VK_F23:		return window->HandleChar(EKeyF23, modifiers);
+					case VK_F24:		return window->HandleChar(EKeyF24, modifiers);
+					default:			return 0;
+					}
+				}
+			break;
+		case WM_CHAR:
+		case WM_SYSCHAR:
+			if (window)
+				{
+				UINT modifiers = EModifierAutorepeatable;
+				if (aMessage == WM_SYSCHAR)
+					{
+					modifiers |= (EModifierLeftAlt | EModifierAlt | EModifierLeftFunc | EModifierFunc);
+					}
+				return window->HandleChar(TCHAR(aWParam), modifiers);
+				}
+			break;
+		case WM_SIZE:
+			if (window)
+				{
+				window->HandleSizeChanged(LOWORD(aLParam), HIWORD(aLParam));
+				}
+			break;
+		case WM_HSCROLL:
+		case WM_VSCROLL:
+			if (window)
+				{
+				window->HandleScrollEvent(aMessage, aWParam);
+				}
+			break;
+		case 0x020A: // WM_MOUSEWHEEL
+			if (window)
+				{
+				window->HandleScrollEvent(WM_VSCROLL, (short)HIWORD(aWParam) > 0 ? SB_LINEUP : SB_LINEDOWN);
+				}
+			break;
+		case WM_PAINT:
+			if (window)
+				{
+				window->Draw();
+				}
+			break;
+		case WM_LBUTTONDOWN:
+		case WM_LBUTTONDBLCLK:
+		case WM_MOUSEMOVE:
+		case WM_LBUTTONUP:
+			if (window)
+				{
+				window->HandleMouseEvent(aMessage, aWParam, aLParam);
+				}
+			break;
+		case WM_INITMENUPOPUP:
+			if (window)
+				{
+				window->HandleMenuPopUp((HMENU)aWParam);
+				}
+			break;
+		case WM_DESTROY:
+			if (window && window->iObserver)
+				{
+				window->iObserver->HandleWindowClosure(*window);
+				}
+			break;
+		default:
+			return DefWindowProc(aHandle, aMessage, aWParam, aLParam);
+		}
+	return 0;
+	}
+
+CWindow* CWindow::Instance(HWND aHandle)
+	{
+	CWindow* window = sFirst;
+	bool found(0);
+	while (window && !found)
+		{
+		if (window->iHandle == aHandle)
+			{
+			found = 1;
+			}
+		else
+			{
+			window = window->iNext;
+			}
+		}
+
+	if (found)
+		{
+		return window;
+		}
+	return NULL;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/Window.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,86 @@
+// Window.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_WINDOW_H__079A244F_DED8_49A3_AB8E_EEE262119929__INCLUDED_)
+#define AFX_WINDOW_H__079A244F_DED8_49A3_AB8E_EEE262119929__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+#include "Base.h"
+
+const unsigned int KSocketMessage = WM_USER;
+
+
+class CWindow;
+
+
+class MWindowMessageHandler
+	{
+public:
+	MWindowMessageHandler();
+	virtual LRESULT HandleWindowMessage(UINT aMessage, WPARAM aWParam, LPARAM aLParam) = 0;
+private:
+	friend class CWindow;
+	MWindowMessageHandler* iNext;
+	MWindowMessageHandler* iPrevious;
+	};
+
+
+class MWindowObserver
+	{
+public:
+	virtual void HandleWindowClosure(CWindow& aWindow) = 0;
+	virtual LRESULT HandleWindowCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam) = 0;
+	};
+
+
+class CWindow : public CBase
+	{
+public:
+	virtual ~CWindow();
+	void AddMessageHandler(MWindowMessageHandler& aHandler);
+	void RemoveMessageHandler(MWindowMessageHandler& aHandler);
+	HWND Handle() const;
+	void SetTitle(LPCTSTR aTitle);
+	void GetTitle(LPTSTR aTitle, int aMaxLength) const;
+	void Redraw();
+protected:
+	CWindow();
+	void Construct(HINSTANCE aAppHandle, LPCTSTR aWindowClass, LPCTSTR aTitle, int aPoxX, int aPosY, int aWidth, int aHeight, MWindowObserver* aObserver);
+private:
+	virtual void Draw() const;
+	virtual LRESULT HandleChar(TCHAR aChar, UINT aModifiers);
+	virtual LRESULT HandleCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam);
+	virtual LRESULT HandleFocusChange(bool aFocused);
+	virtual void HandleScrollEvent(UINT aMessage, WPARAM aWParam);
+	virtual void HandleSizeChanged(int aWidth, int aHeight);
+	virtual void HandleMouseEvent(UINT aMessage, WPARAM aWParam, LPARAM aLParam);
+	virtual void HandleMenuPopUp(HMENU aMenu);
+public:
+	static LRESULT CALLBACK HandleMessage(HWND aHandle, UINT aMessage, WPARAM aWParam, LPARAM aLParam);
+	static CWindow* Instance(HWND aHandle);
+private:
+	static CWindow* sFirst;
+	static CWindow* sLast;
+	static MWindowMessageHandler* sFirstMessageHandler;
+	static MWindowMessageHandler* sLastMessageHandler;
+	CWindow* iNext;
+	CWindow* iPrevious;
+	HINSTANCE iAppHandle;
+	HWND iHandle;
+	MWindowObserver* iObserver;
+	};
+
+#endif // !defined(AFX_WINDOW_H__079A244F_DED8_49A3_AB8E_EEE262119929__INCLUDED_)
Binary file plugins/consoles/rcons/server/win32/console_host.aps has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/console_host.clw	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,86 @@
+; CLW file contains information for the MFC ClassWizard
+
+[General Info]
+Version=1
+LastClass=
+LastTemplate=CDialog
+NewFileInclude1=#include "stdafx.h"
+NewFileInclude2=#include "console_host.h"
+LastPage=0
+
+ClassCount=0
+
+ResourceCount=5
+Resource1=ID_SERVER_MENU (English (U.S.))
+Resource2=ID_REMOTE_CONSOLE_MENU
+Resource3=IDC_CONSOLE_HOST (English (U.S.))
+Resource4=IDD_ABOUTBOX (English (U.S.))
+Resource5=IDD_PREFS_DIALOG
+
+[ACL:IDC_CONSOLE_HOST (English (U.S.))]
+Type=1
+Class=?
+Command1=IDM_ABOUT
+Command2=IDM_ABOUT
+CommandCount=2
+
+[DLG:IDD_ABOUTBOX (English (U.S.))]
+Type=1
+Class=?
+ControlCount=4
+Control1=IDC_MYICON,static,1342177283
+Control2=IDC_STATIC,static,1342308480
+Control3=IDC_STATIC,static,1342308352
+Control4=IDOK,button,1342373889
+
+[MNU:IDC_CONSOLE_HOST (English (U.S.))]
+Type=1
+Class=?
+Command1=IDM_EXIT
+Command2=IDM_ABOUT
+CommandCount=2
+
+[MNU:ID_SERVER_MENU (English (U.S.))]
+Type=1
+Class=?
+Command1=ID_PREFS
+Command2=ID_EXIT
+Command3=ID_ABOUT
+CommandCount=3
+
+[DLG:IDD_PREFS_DIALOG]
+Type=1
+Class=?
+ControlCount=21
+Control1=ID_EDIT_PORT,edit,1350639744
+Control2=ID_OVERFLOW_LINES,edit,1350639744
+Control3=ID_EDIT_WIN_WIDTH,edit,1350639744
+Control4=ID_EDIT_WIN_HEIGHT,edit,1350639744
+Control5=ID_CHECK_WIN_POS,button,1342242819
+Control6=ID_EDIT_WIN_POS_X,edit,1350639744
+Control7=ID_EDIT_WIN_POS_Y,edit,1350639744
+Control8=IDOK,button,1342242817
+Control9=IDCANCEL,button,1342242816
+Control10=IDC_STATIC,button,1342177287
+Control11=IDC_STATIC,static,1342308864
+Control12=IDC_STATIC,button,1342177287
+Control13=IDC_STATIC,button,1342177287
+Control14=IDC_STATIC,static,1342308352
+Control15=IDC_STATIC,static,1342308352
+Control16=IDC_STATIC,button,1342177287
+Control17=IDC_STATIC,static,1342308352
+Control18=IDC_STATIC,static,1342308352
+Control19=IDC_STATIC,static,1342308352
+Control20=IDC_STATIC,static,1342308865
+Control21=IDC_STATIC,static,1342308864
+
+[MNU:ID_REMOTE_CONSOLE_MENU]
+Type=1
+Class=?
+Command1=ID_RC_CAPTURE
+Command2=ID_RC_CLOSE
+Command3=ID_EDIT_COPY
+Command4=ID_EDIT_PASTE
+Command5=ID_ABOUT
+CommandCount=5
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/console_host.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,101 @@
+// console_host.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "stdafx.h"
+#include "resource.h"
+#include "Misc.h"
+#include "Window.h"
+#include "ConsoleWindow.h"
+#include <winsock2.h>
+#include "Server.h"
+
+void InitWinSock()
+	{
+	WORD version = MAKEWORD (2, 2);
+	WSADATA wsaData;
+
+	if (WSAStartup(version, &wsaData) == SOCKET_ERROR)
+		{
+		throw KExceptionWinSockStartupFailed;
+		}
+
+	if (version != wsaData.wVersion)
+		{
+		throw KExceptionWinSockVersionInvalid;
+		}
+	}
+
+int APIENTRY WinMain(HINSTANCE hInstance,
+                     HINSTANCE hPrevInstance,
+                     LPSTR     lpCmdLine,
+                     int       nCmdShow)
+	{
+	MSG msg;
+	HACCEL hAccelTable;
+	CServer* server;
+	try
+		{
+		hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_CONSOLE_HOST);
+		InitWinSock();
+		server = CServer::New(hInstance);
+		}
+	catch (TException aException)
+		{
+		LPCTSTR errorTitle = TEXT("Remote Console Server Initialization Error");
+		LPCTSTR errorText = NULL;
+		switch (aException)
+			{
+			case KExceptionNoMemory:
+				errorText = TEXT("Not enough memory to initialize server.");
+				break;
+			case KExceptionWindowConstructFailed:
+				errorText = TEXT("Failed to construct server window.");
+				break;
+			case KExceptionWinSockStartupFailed:
+				errorText = TEXT("Failed to initialize WINSOCK.");
+				break;
+			case KExceptionWinSockVersionInvalid:
+				errorText = TEXT("Invalid WINSOCK version.");
+				break;
+			case KExceptionSocketConstructFailed:
+				errorText = TEXT("Failed to construct server socket.");
+				break;
+			default:
+				errorText = TEXT("Unknown error.");
+				break;
+			}
+		MessageBox(NULL, errorText, errorTitle, MB_OK);
+		WSACleanup();
+		return 0;
+		}
+
+	while (GetMessage(&msg, NULL, 0, 0)) 
+		{
+		try
+			{
+			if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
+				{
+				TranslateMessage(&msg);
+				DispatchMessage(&msg);
+				}
+			}
+		catch (TException aException)
+			{
+			server->HandleException(aException);
+			}
+		}
+
+	delete server;
+	WSACleanup();
+
+	return msg.wParam;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/console_host.dsp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,256 @@
+# Microsoft Developer Studio Project File - Name="console_host" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=console_host - 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 "console_host.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 "console_host.mak" CFG="console_host - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "console_host - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "console_host - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "console_host - 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 "\epoc32\build\rcons\server\win32\Release"
+# PROP Intermediate_Dir "\epoc32\build\rcons\server\win32\Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /W3 /GX /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR /FD /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib shlwapi.lib /nologo /subsystem:windows /machine:I386 /out:"\epoc32\tools\rcons.exe"
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF  "$(CFG)" == "console_host - 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 "\epoc32\build\rcons\server\win32\Debug"
+# PROP Intermediate_Dir "\epoc32\build\rcons\server\win32\Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib shlwapi.lib /nologo /subsystem:windows /debug /machine:I386 /out:"\epoc32\build\rcons\server\win32\Debug\rcons.exe" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF 
+
+# Begin Target
+
+# Name "console_host - Win32 Release"
+# Name "console_host - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Base.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ClientSocket.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\console_host.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\console_host.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\ConsoleWindow.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\DynamicBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Misc.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Preferences.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\RemoteConsole.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Server.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ServerSocket.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Socket.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SocketCommandHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\TextBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\TextView.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Window.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Base.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ClientSocket.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\console_host.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ConsoleWindow.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\DynamicBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Misc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Preferences.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\RemoteConsole.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Server.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ServerSocket.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Socket.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SocketCommandHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\TextBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\TextView.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Window.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\console_host.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\small.ico
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\ReadMe.txt
+# End Source File
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/console_host.dsw	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "console_host"=.\console_host.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/console_host.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+// console_host.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#if !defined(AFX_CONSOLE_HOST_H__433CF317_13F9_41E8_98C4_71C6611DC8D9__INCLUDED_)
+#define AFX_CONSOLE_HOST_H__433CF317_13F9_41E8_98C4_71C6611DC8D9__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "resource.h"
+
+
+#endif // !defined(AFX_CONSOLE_HOST_H__433CF317_13F9_41E8_98C4_71C6611DC8D9__INCLUDED_)
Binary file plugins/consoles/rcons/server/win32/console_host.ico has changed
Binary file plugins/consoles/rcons/server/win32/console_host.ncb has changed
Binary file plugins/consoles/rcons/server/win32/console_host.opt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/console_host.plg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,109 @@
+<html>
+<body>
+<pre>
+<h1>Build Log</h1>
+<h3>
+--------------------Configuration: console_host - Win32 Release--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating command line "rc.exe /l 0x809 /fo"\epoc32\build\rcons\server\win32\Release/console_host.res" /d "NDEBUG" "E:\hg\fshell/consoles\rcons\server\win32\console_host.rc"" 
+Creating temporary file "C:\DOCUME~1\thosutcl\LOCALS~1\Temp\RSP3B8.tmp" with contents
+[
+/nologo /ML /W3 /GX /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR"\epoc32\build\rcons\server\win32\Release/" /Fo"\epoc32\build\rcons\server\win32\Release/" /Fd"\epoc32\build\rcons\server\win32\Release/" /FD /c 
+"E:\hg\fshell/consoles\rcons\server\win32\Base.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\ClientSocket.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\console_host.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\ConsoleWindow.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\DynamicBuffer.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\Misc.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\Preferences.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\RemoteConsole.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\Server.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\ServerSocket.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\Socket.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\SocketCommandHandler.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\TextBuffer.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\TextView.cpp"
+"E:\hg\fshell/consoles\rcons\server\win32\Window.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\thosutcl\LOCALS~1\Temp\RSP3B8.tmp" 
+Creating temporary file "C:\DOCUME~1\thosutcl\LOCALS~1\Temp\RSP3B9.tmp" with contents
+[
+/nologo /ML /W3 /GX /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR"\epoc32\build\rcons\server\win32\Release/" /Fp"\epoc32\build\rcons\server\win32\Release/console_host.pch" /Yc"stdafx.h" /Fo"\epoc32\build\rcons\server\win32\Release/" /Fd"\epoc32\build\rcons\server\win32\Release/" /FD /c 
+"E:\hg\fshell/consoles\rcons\server\win32\StdAfx.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\thosutcl\LOCALS~1\Temp\RSP3B9.tmp" 
+Creating temporary file "C:\DOCUME~1\thosutcl\LOCALS~1\Temp\RSP3BA.tmp" with contents
+[
+kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib shlwapi.lib /nologo /subsystem:windows /incremental:no /pdb:"\epoc32\build\rcons\server\win32\Release/rcons.pdb" /machine:I386 /out:"\epoc32\tools\rcons.exe" 
+\epoc32\build\rcons\server\win32\Release\Base.obj
+\epoc32\build\rcons\server\win32\Release\ClientSocket.obj
+\epoc32\build\rcons\server\win32\Release\console_host.obj
+\epoc32\build\rcons\server\win32\Release\ConsoleWindow.obj
+\epoc32\build\rcons\server\win32\Release\DynamicBuffer.obj
+\epoc32\build\rcons\server\win32\Release\Misc.obj
+\epoc32\build\rcons\server\win32\Release\Preferences.obj
+\epoc32\build\rcons\server\win32\Release\RemoteConsole.obj
+\epoc32\build\rcons\server\win32\Release\Server.obj
+\epoc32\build\rcons\server\win32\Release\ServerSocket.obj
+\epoc32\build\rcons\server\win32\Release\Socket.obj
+\epoc32\build\rcons\server\win32\Release\SocketCommandHandler.obj
+\epoc32\build\rcons\server\win32\Release\StdAfx.obj
+\epoc32\build\rcons\server\win32\Release\TextBuffer.obj
+\epoc32\build\rcons\server\win32\Release\TextView.obj
+\epoc32\build\rcons\server\win32\Release\Window.obj
+\epoc32\build\rcons\server\win32\Release\console_host.res
+]
+Creating command line "link.exe @C:\DOCUME~1\thosutcl\LOCALS~1\Temp\RSP3BA.tmp"
+<h3>Output Window</h3>
+Compiling resources...
+Compiling...
+StdAfx.cpp
+Compiling...
+Base.cpp
+ClientSocket.cpp
+console_host.cpp
+ConsoleWindow.cpp
+DynamicBuffer.cpp
+Misc.cpp
+Preferences.cpp
+RemoteConsole.cpp
+Server.cpp
+ServerSocket.cpp
+Socket.cpp
+SocketCommandHandler.cpp
+TextBuffer.cpp
+TextView.cpp
+Window.cpp
+Generating Code...
+Linking...
+Creating temporary file "C:\DOCUME~1\thosutcl\LOCALS~1\Temp\RSP3BC.tmp" with contents
+[
+/nologo /o"\epoc32\build\rcons\server\win32\Release/console_host.bsc" 
+\epoc32\build\rcons\server\win32\Release\StdAfx.sbr
+\epoc32\build\rcons\server\win32\Release\Base.sbr
+\epoc32\build\rcons\server\win32\Release\ClientSocket.sbr
+\epoc32\build\rcons\server\win32\Release\console_host.sbr
+\epoc32\build\rcons\server\win32\Release\ConsoleWindow.sbr
+\epoc32\build\rcons\server\win32\Release\DynamicBuffer.sbr
+\epoc32\build\rcons\server\win32\Release\Misc.sbr
+\epoc32\build\rcons\server\win32\Release\Preferences.sbr
+\epoc32\build\rcons\server\win32\Release\RemoteConsole.sbr
+\epoc32\build\rcons\server\win32\Release\Server.sbr
+\epoc32\build\rcons\server\win32\Release\ServerSocket.sbr
+\epoc32\build\rcons\server\win32\Release\Socket.sbr
+\epoc32\build\rcons\server\win32\Release\SocketCommandHandler.sbr
+\epoc32\build\rcons\server\win32\Release\TextBuffer.sbr
+\epoc32\build\rcons\server\win32\Release\TextView.sbr
+\epoc32\build\rcons\server\win32\Release\Window.sbr]
+Creating command line "bscmake.exe @C:\DOCUME~1\thosutcl\LOCALS~1\Temp\RSP3BC.tmp"
+Creating browse info file...
+<h3>Output Window</h3>
+
+
+
+<h3>Results</h3>
+rcons.exe - 0 error(s), 0 warning(s)
+</pre>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/console_host.rc	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,248 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_CONSOLE_HOST        ICON    DISCARDABLE     "console_host.ICO"
+IDI_SMALL               ICON    DISCARDABLE     "SMALL.ICO"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+ID_SERVER_MENU MENU DISCARDABLE 
+BEGIN
+    POPUP "&File"
+    BEGIN
+        MENUITEM "&Preferences",                ID_PREFS
+        MENUITEM SEPARATOR
+        MENUITEM "E&xit",                       ID_EXIT
+    END
+    POPUP "&Help"
+    BEGIN
+        MENUITEM "&About",                      ID_ABOUT
+    END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDC_CONSOLE_HOST ACCELERATORS MOVEABLE PURE 
+BEGIN
+    "/",            IDM_ABOUT,              ASCII,  ALT, NOINVERT
+    "?",            IDM_ABOUT,              ASCII,  ALT, NOINVERT
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOG DISCARDABLE  22, 17, 231, 55
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "About"
+FONT 10, "Arial"
+BEGIN
+    ICON            IDI_CONSOLE_HOST,IDC_MYICON,14,9,20,20
+    LTEXT           "Remote Console Server Version 1.2",IDC_STATIC,49,10,119,8,
+                    SS_NOPREFIX
+    LTEXT           "Copyright (c) Accenture 2005 - 2010",IDC_STATIC,49,
+                    20,146,8
+    DEFPUSHBUTTON   "OK",IDOK,195,40,30,11,WS_GROUP
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+    "#include ""windows.h""\r\n"
+    "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+    "#include ""resource.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_APP_TITLE           "console_host"
+    IDS_HELLO               "Hello World!"
+    IDC_CONSOLE_HOST        "CONSOLE_HOST"
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+ID_REMOTE_CONSOLE_MENU MENU DISCARDABLE 
+BEGIN
+    POPUP "&File"
+    BEGIN
+        MENUITEM "C&apture to file",            ID_RC_CAPTURE
+        MENUITEM "&Close",                      ID_RC_CLOSE
+    END
+    POPUP "&Edit"
+    BEGIN
+        MENUITEM "Copy",                        ID_EDIT_COPY
+        MENUITEM "Paste",                       ID_EDIT_PASTE
+    END
+    POPUP "&Help"
+    BEGIN
+        MENUITEM "&About",                      ID_ABOUT
+    END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_PREFS_DIALOG DIALOG DISCARDABLE  0, 0, 237, 210
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Preferences"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        ID_EDIT_PORT,65,20,100,12,ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        ID_OVERFLOW_LINES,110,75,55,12,ES_AUTOHSCROLL | 
+                    ES_NUMBER
+    EDITTEXT        ID_EDIT_WIN_WIDTH,55,110,35,12,ES_AUTOHSCROLL | 
+                    ES_NUMBER
+    EDITTEXT        ID_EDIT_WIN_HEIGHT,55,125,35,12,ES_AUTOHSCROLL | 
+                    ES_NUMBER
+    CONTROL         "Let Windows decide",ID_CHECK_WIN_POS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,115,110,81,10
+    EDITTEXT        ID_EDIT_WIN_POS_X,130,130,35,12,ES_AUTOHSCROLL | 
+                    ES_NUMBER
+    EDITTEXT        ID_EDIT_WIN_POS_Y,130,145,35,12,ES_AUTOHSCROLL | 
+                    ES_NUMBER
+    DEFPUSHBUTTON   "OK",IDOK,150,185,35,14
+    PUSHBUTTON      "Cancel",IDCANCEL,190,185,35,14
+    GROUPBOX        "Server settings",IDC_STATIC,10,5,215,40
+    LTEXT           "Listen on port:",IDC_STATIC,15,20,49,10,SS_CENTERIMAGE
+    GROUPBOX        "Console settings",IDC_STATIC,10,55,215,120
+    GROUPBOX        "Default size",IDC_STATIC,20,95,78,65
+    LTEXT           "Width:",IDC_STATIC,25,110,25,10
+    LTEXT           "Height:",IDC_STATIC,25,125,25,10
+    GROUPBOX        "Default window position",IDC_STATIC,110,95,105,70
+    LTEXT           "X:",IDC_STATIC,115,130,10,10
+    LTEXT           "Y:",IDC_STATIC,115,145,10,10
+    LTEXT           "Default number of buffered overflow lines:",IDC_STATIC,
+                    25,70,80,20
+    CTEXT           "(In characters)",IDC_STATIC,25,140,65,15,SS_CENTERIMAGE
+    LTEXT           "(In pixels)",IDC_STATIC,175,135,35,15,SS_CENTERIMAGE
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "resource.h\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_PREFS_DIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 230
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 203
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+#endif    // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
Binary file plugins/consoles/rcons/server/win32/rcons.exe has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/rcons/server/win32/resource.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+// resource.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#define IDC_MYICON                      2
+#define IDD_CONSOLE_HOST_DIALOG         102
+#define IDD_ABOUTBOX                    103
+#define IDS_APP_TITLE                   103
+#define IDM_ABOUT                       104
+#define IDM_EXIT                        105
+#define ID_EXIT                         105
+#define IDS_HELLO                       106
+#define IDI_CONSOLE_HOST                107
+#define IDI_SMALL                       108
+#define IDC_CONSOLE_HOST                109
+#define ID_SERVER_MENU                  109
+#define IDR_MAINFRAME                   128
+#define IDD_PREFS_DIALOG                129
+#define ID_REMOTE_CONSOLE_MENU          130
+#define ID_EDIT_PORT                    1003
+#define ID_CHECK_FOCUS_NEW_WINDOWS      1004
+#define ID_EDIT_WIN_WIDTH               1005
+#define ID_EDIT_WIN_HEIGHT              1006
+#define ID_EDIT_WIN_POS_X               1007
+#define ID_EDIT_WIN_POS_Y               1008
+#define ID_CHECK_WIN_POS                1009
+#define ID_OVERFLOW_LINES               1010
+#define ID_RC_CLOSE                     32771
+#define ID_ABOUT                        32772
+#define ID_PREFS                        32775
+#define ID_RC_CAPTURE                   32776
+#define ID_EDIT_COPY                    32779
+#define ID_EDIT_PASTE                   32780
+#define IDC_STATIC                      -1
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        132
+#define _APS_NEXT_COMMAND_VALUE         32781
+#define _APS_NEXT_CONTROL_VALUE         1016
+#define _APS_NEXT_SYMED_VALUE           110
+#endif
+#endif
Binary file plugins/consoles/rcons/server/win32/small.ico has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/BMARM/vt100U.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,37 @@
+EXPORTS
+	__9TKeyPress8TKeyCodeUi @ 1 NONAME R3UNUSED ; TKeyPress::TKeyPress(TKeyCode, unsigned int)
+	ClearScreen__15CVtcConsoleBase @ 2 NONAME R3UNUSED ; CVtcConsoleBase::ClearScreen(void)
+	ClearToEndOfLine__15CVtcConsoleBase @ 3 NONAME R3UNUSED ; CVtcConsoleBase::ClearToEndOfLine(void)
+	ConstructL__15CVtcConsoleBaseRC7TDesC16 @ 4 NONAME R3UNUSED ; CVtcConsoleBase::ConstructL(TDesC16 const &)
+	Create__15CVtcConsoleBaseRC7TDesC16G5TSize @ 5 NONAME ; CVtcConsoleBase::Create(TDesC16 const &, TSize)
+	CursorPos__C15CVtcConsoleBase @ 6 NONAME R3UNUSED ; CVtcConsoleBase::CursorPos(void) const
+	Extension___15CVtcConsoleBaseUiRPvPv @ 7 NONAME ; CVtcConsoleBase::Extension_(unsigned int, void *&, void *)
+	GetKeyPress__25CVtConsoleInputControllerR9TKeyPressR14TRequestStatus @ 8 NONAME R3UNUSED ; CVtConsoleInputController::GetKeyPress(TKeyPress &, TRequestStatus &)
+	KeyCode__C15CVtcConsoleBase @ 9 NONAME R3UNUSED ; CVtcConsoleBase::KeyCode(void) const
+	KeyModifiers__C15CVtcConsoleBase @ 10 NONAME R3UNUSED ; CVtcConsoleBase::KeyModifiers(void) const
+	Message__15CVtcConsoleBaseQ215CVtcConsoleBase10TVerbosityGt11TRefByValue1ZC7TDesC16e @ 11 NONAME ; CVtcConsoleBase::Message(CVtcConsoleBase::TVerbosity, TRefByValue<TDesC16 const>,...)
+	NewLC__25CVtConsoleInputControllerR13MConsoleInputRQ28LtkUtils8CIniFile @ 12 NONAME R3UNUSED ; CVtConsoleInputController::NewLC(MConsoleInput &, LtkUtils::CIniFile &)
+	NewL__25CVtConsoleInputControllerR13MConsoleInputRQ28LtkUtils8CIniFile @ 13 NONAME R3UNUSED ; CVtConsoleInputController::NewL(MConsoleInput &, LtkUtils::CIniFile &)
+	NewL__26CVtConsoleOutputControllerR14MConsoleOutputRQ28LtkUtils8CIniFileRC5TSize @ 14 NONAME R3UNUSED ; CVtConsoleOutputController::NewL(MConsoleOutput &, LtkUtils::CIniFile &, TSize const &)
+	New__25CVtConsoleInputControllerR13MConsoleInputRQ28LtkUtils8CIniFile @ 15 NONAME R3UNUSED ; CVtConsoleInputController::New(MConsoleInput &, LtkUtils::CIniFile &)
+	New__26CVtConsoleOutputControllerR14MConsoleOutputRQ28LtkUtils8CIniFileRC5TSize @ 16 NONAME R3UNUSED ; CVtConsoleOutputController::New(MConsoleOutput &, LtkUtils::CIniFile &, TSize const &)
+	ResetAttributes__26CVtConsoleOutputController @ 17 NONAME R3UNUSED ; CVtConsoleOutputController::ResetAttributes(void)
+	SetAttributes__26CVtConsoleOutputControllerUiQ217ConsoleAttributes6TColorT2 @ 18 NONAME ; CVtConsoleOutputController::SetAttributes(unsigned int, ConsoleAttributes::TColor, ConsoleAttributes::TColor)
+	ReadCancel__15CVtcConsoleBase @ 19 NONAME R3UNUSED ; CVtcConsoleBase::ReadCancel(void)
+	Read__15CVtcConsoleBaseR14TRequestStatus @ 20 NONAME R3UNUSED ; CVtcConsoleBase::Read(TRequestStatus &)
+	ScreenSize__C15CVtcConsoleBase @ 21 NONAME R3UNUSED ; CVtcConsoleBase::ScreenSize(void) const
+	SetCursorHeight__15CVtcConsoleBasei @ 22 NONAME R3UNUSED ; CVtcConsoleBase::SetCursorHeight(int)
+	SetCursorPosAbs__15CVtcConsoleBaseRC6TPoint @ 23 NONAME R3UNUSED ; CVtcConsoleBase::SetCursorPosAbs(TPoint const &)
+	SetCursorPosRel__15CVtcConsoleBaseRC6TPoint @ 24 NONAME R3UNUSED ; CVtcConsoleBase::SetCursorPosRel(TPoint const &)
+	SetMode__25CVtConsoleInputControllerQ211ConsoleMode5TMode @ 25 NONAME R3UNUSED ; CVtConsoleInputController::SetMode(ConsoleMode::TMode)
+	SetTitle__15CVtcConsoleBaseRC7TDesC16 @ 26 NONAME R3UNUSED ; CVtcConsoleBase::SetTitle(TDesC16 const &)
+	Write__15CVtcConsoleBaseRC7TDesC16 @ 27 NONAME R3UNUSED ; CVtcConsoleBase::Write(TDesC16 const &)
+	"_._15CVtcConsoleBase" @ 28 NONAME R3UNUSED ; CVtcConsoleBase::~CVtcConsoleBase(void)
+	"_._26CVtConsoleOutputController" @ 29 NONAME R3UNUSED ; CVtConsoleOutputController::~CVtConsoleOutputController(void)
+	__15CVtcConsoleBase @ 30 NONAME R3UNUSED ; CVtcConsoleBase::CVtcConsoleBase(void)
+	__9TKeyPress @ 31 NONAME R3UNUSED ; TKeyPress::TKeyPress(void)
+	CancelGetKeyPress__25CVtConsoleInputController @ 32 NONAME R3UNUSED ; CVtConsoleInputController::CancelGetKeyPress(void)
+	Debug__15CVtcConsoleBase @ 33 NONAME R3UNUSED ; CVtcConsoleBase::Debug(void)
+	SetDebug__15CVtcConsoleBasei @ 34 NONAME R3UNUSED ; CVtcConsoleBase::SetDebug(int)
+	ReadKeywordValuePair__15CVtcConsoleBaseR6TLex16R7TPtrC16T2 @ 35 NONAME R3UNUSED ; CVtcConsoleBase::ReadKeywordValuePair(TLex16 &, TPtrC16 &, TPtrC16 &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/BMARM/vt100consU.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME R3UNUSED ; (null)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/bwins/vt100btconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/bwins/vt100consu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/bwins/vt100serialu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	??0CVtcSerialConsole@@QAE@XZ @ 1 NONAME ; CVtcSerialConsole::CVtcSerialConsole(void)
+	??1CVtcSerialConsole@@UAE@XZ @ 2 NONAME ; CVtcSerialConsole::~CVtcSerialConsole(void)
+	?CancelInput@CVtcSerialConsole@@EAEXAAVTRequestStatus@@@Z @ 3 NONAME ; void CVtcSerialConsole::CancelInput(class TRequestStatus &)
+	?ConstructL@CVtcSerialConsole@@MAEXABVTDesC16@@@Z @ 4  NONAME ; void CVtcSerialConsole::ConstructL(class TDesC16 const &)
+	?Input@CVtcSerialConsole@@EAEXAAVTDes8@@AAVTRequestStatus@@@Z @ 5 NONAME ; void CVtcSerialConsole::Input(class TDes8 &, class TRequestStatus &)
+	?Output@CVtcSerialConsole@@EAEHABVTDesC8@@@Z @ 6 NONAME ; int CVtcSerialConsole::Output(class TDesC8 const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/bwins/vt100u.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,40 @@
+EXPORTS
+	??0CVtcConsoleBase@@IAE@XZ @ 1 NONAME ; CVtcConsoleBase::CVtcConsoleBase(void)
+	??0TKeyPress@@QAE@W4TKeyCode@@I@Z @ 2 NONAME ; TKeyPress::TKeyPress(enum TKeyCode, unsigned int)
+	??0TKeyPress@@QAE@XZ @ 3 NONAME ; TKeyPress::TKeyPress(void)
+	??1CVtConsoleOutputController@@UAE@XZ @ 4 NONAME ; CVtConsoleOutputController::~CVtConsoleOutputController(void)
+	??1CVtcConsoleBase@@UAE@XZ @ 5 NONAME ; CVtcConsoleBase::~CVtcConsoleBase(void)
+	?CancelGetKeyPress@CVtConsoleInputController@@QAEXXZ @ 6 NONAME ; void CVtConsoleInputController::CancelGetKeyPress(void)
+	?ClearScreen@CVtcConsoleBase@@UAEXXZ @ 7 NONAME ; void CVtcConsoleBase::ClearScreen(void)
+	?ClearToEndOfLine@CVtcConsoleBase@@UAEXXZ @ 8 NONAME ; void CVtcConsoleBase::ClearToEndOfLine(void)
+	?ConstructL@CVtcConsoleBase@@MAEXABVTDesC16@@@Z @ 9 NONAME ; void CVtcConsoleBase::ConstructL(class TDesC16 const &)
+	?Create@CVtcConsoleBase@@UAEHABVTDesC16@@VTSize@@@Z @ 10 NONAME ; int CVtcConsoleBase::Create(class TDesC16 const &, class TSize)
+	?CursorPos@CVtcConsoleBase@@UBE?AVTPoint@@XZ @ 11 NONAME ; class TPoint CVtcConsoleBase::CursorPos(void) const
+	?Extension_@CVtcConsoleBase@@UAEHIAAPAXPAX@Z @ 12 NONAME ; int CVtcConsoleBase::Extension_(unsigned int, void * &, void *)
+	?GetKeyPress@CVtConsoleInputController@@QAEXAAVTKeyPress@@AAVTRequestStatus@@@Z @ 13 NONAME ; void CVtConsoleInputController::GetKeyPress(class TKeyPress &, class TRequestStatus &)
+	?KeyCode@CVtcConsoleBase@@UBE?AW4TKeyCode@@XZ @ 14 NONAME ; enum TKeyCode CVtcConsoleBase::KeyCode(void) const
+	?KeyModifiers@CVtcConsoleBase@@UBEIXZ @ 15 NONAME ; unsigned int CVtcConsoleBase::KeyModifiers(void) const
+	?New@CVtConsoleInputController@@SAPAV1@AAVMConsoleInput@@AAVCIniFile@LtkUtils@@@Z @ 16 NONAME ; class CVtConsoleInputController * CVtConsoleInputController::New(class MConsoleInput &, class LtkUtils::CIniFile &)
+	?New@CVtConsoleOutputController@@SAPAV1@AAVMConsoleOutput@@AAVCIniFile@LtkUtils@@ABVTSize@@@Z @ 17 NONAME ; class CVtConsoleOutputController * CVtConsoleOutputController::New(class MConsoleOutput &, class LtkUtils::CIniFile &, class TSize const &)
+	?NewL@CVtConsoleInputController@@SAPAV1@AAVMConsoleInput@@AAVCIniFile@LtkUtils@@@Z @ 18 NONAME ; class CVtConsoleInputController * CVtConsoleInputController::NewL(class MConsoleInput &, class LtkUtils::CIniFile &)
+	?NewL@CVtConsoleOutputController@@SAPAV1@AAVMConsoleOutput@@AAVCIniFile@LtkUtils@@ABVTSize@@@Z @ 19 NONAME ; class CVtConsoleOutputController * CVtConsoleOutputController::NewL(class MConsoleOutput &, class LtkUtils::CIniFile &, class TSize const &)
+	?NewLC@CVtConsoleInputController@@SAPAV1@AAVMConsoleInput@@AAVCIniFile@LtkUtils@@@Z @ 20 NONAME ; class CVtConsoleInputController * CVtConsoleInputController::NewLC(class MConsoleInput &, class LtkUtils::CIniFile &)
+	?Read@CVtcConsoleBase@@UAEXAAVTRequestStatus@@@Z @ 21 NONAME ; void CVtcConsoleBase::Read(class TRequestStatus &)
+	?ReadCancel@CVtcConsoleBase@@UAEXXZ @ 22 NONAME ; void CVtcConsoleBase::ReadCancel(void)
+	?ScreenSize@CVtcConsoleBase@@UBE?AVTSize@@XZ @ 23 NONAME ; class TSize CVtcConsoleBase::ScreenSize(void) const
+	?SetCursorHeight@CVtcConsoleBase@@UAEXH@Z @ 24 NONAME ; void CVtcConsoleBase::SetCursorHeight(int)
+	?SetCursorPosAbs@CVtcConsoleBase@@UAEXABVTPoint@@@Z @ 25 NONAME ; void CVtcConsoleBase::SetCursorPosAbs(class TPoint const &)
+	?SetCursorPosRel@CVtcConsoleBase@@UAEXABVTPoint@@@Z @ 26 NONAME ; void CVtcConsoleBase::SetCursorPosRel(class TPoint const &)
+	?SetMode@CVtConsoleInputController@@QAEXW4TMode@ConsoleMode@@@Z @ 27 NONAME ; void CVtConsoleInputController::SetMode(enum ConsoleMode::TMode)
+	?SetTitle@CVtcConsoleBase@@UAEXABVTDesC16@@@Z @ 28 NONAME ; void CVtcConsoleBase::SetTitle(class TDesC16 const &)
+	?Write@CVtcConsoleBase@@UAEXABVTDesC16@@@Z @ 29 NONAME ; void CVtcConsoleBase::Write(class TDesC16 const &)
+	?NewL@CVtConsoleInputController@@SAPAV1@AAVMConsoleInputObserver@@@Z @ 30 NONAME ABSENT ; class CVtConsoleInputController * CVtConsoleInputController::NewL(class MConsoleInputObserver &)
+	?NewLC@CVtConsoleInputController@@SAPAV1@AAVMConsoleInputObserver@@@Z @ 31 NONAME ABSENT ; class CVtConsoleInputController * CVtConsoleInputController::NewLC(class MConsoleInputObserver &)
+	?QueueBufL@CVtConsoleInputController@@QAEXABVTDesC8@@@Z @ 32 NONAME ABSENT ; void CVtConsoleInputController::QueueBufL(class TDesC8 const &)
+	?Debug@CVtcConsoleBase@@IAEHXZ @ 33 NONAME ; int CVtcConsoleBase::Debug(void)
+	?Message@CVtcConsoleBase@@IAAXW4TVerbosity@1@V?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 34 NONAME ; void CVtcConsoleBase::Message(enum CVtcConsoleBase::TVerbosity, class TRefByValue<class TDesC16 const >, ...)
+	?SetDebug@CVtcConsoleBase@@IAEXH@Z @ 35 NONAME ; void CVtcConsoleBase::SetDebug(int)
+	?SetAttributes@CVtConsoleOutputController@@QAEHIW4TColor@ConsoleAttributes@@0@Z @ 36 NONAME ; int CVtConsoleOutputController::SetAttributes(unsigned int, enum ConsoleAttributes::TColor, enum ConsoleAttributes::TColor)
+	?ResetAttributes@CVtConsoleOutputController@@QAEHXZ @ 37 NONAME ; int CVtConsoleOutputController::ResetAttributes(void)
+	?ReadKeywordValuePair@CVtcConsoleBase@@KAHAAVTLex16@@AAVTPtrC16@@1@Z @ 38 NONAME ; int CVtcConsoleBase::ReadKeywordValuePair(class TLex16 &, class TPtrC16 &, class TPtrC16 &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/bwins/vt100usbconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/doc/vt100cons.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,273 @@
+# vt100cons.pod
+#
+# Copyright (c) 2008-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 vt100cons
+
+=head2 Introduction
+
+A Symbian console implementation (sub-class of C<CConsoleBase>) for communicating with a VT100 terminal (or, more likely, a terminal emulator such as the Windows HyperTerminal program) over a C32 hosted serial connection. This console makes it possible to run console based tools on any handset that can be connected to via a serial connection.
+
+Note, the console provides no mechanism for remote clients to automatically connect and launch console tools. The launching of the required console tool must be initiated on the handset, causing F<vt100cons.dll> to be loaded. It will then attempt to establish a serial connection to the terminal that is expected to be listening on the other end of the connection.
+
+There are six variants:
+
+=over 5
+
+=item 1 F<vt100cons.dll>
+
+Uses a regular C<RComm> based serial connection. The most basic implementation, for communicating over plain old serial ports.
+
+=item 1 F<vt100btcons.dll>
+
+Accepts an incoming bluetooth serial port connection.
+
+=item 1 F<vt100tcpcons.dll>
+
+Uses a TCP/IP connection. Can either actively connect to a remote host, or passively listen for connections.
+
+=item 1 F<vt100usbcons.dll>
+
+Like vt100cons.dll but with some extra USB-specific setup.
+
+=item 1 F<vt100debugport.dll>
+
+This is a textshell-only variant of vt100cons.dll that does not require C32 support.
+
+=item 1 F<vt100busdevcons.dll>
+
+Like vt100cons.dll but uses C<RBusDevComm> directly rather than going through C32. Like vt100debugport.dll it doesn't rely on C32, but it has better console emulation support.
+
+=back
+
+=head2 Serial Variant
+
+=head3 Configuration
+
+The console implementation expects to be provided with a set of configuration data in the title parameter of the C<CConsoleBase> constructor. This string may consist of the following keyword / value pairs:
+
+=over 5
+
+=item * C<pdd=name>
+
+If present, the named physical device driver will be loaded. May be omitted, in which case ecdrv (on the emulator) or euart1 (on target) is assumed.
+
+=item * C<ldd=name>
+
+If present, the named logical device driver will be loaded. May be omitted, in which case ecomm is assumed.
+
+=item * C<csy=name>
+
+If present, the named C32 CSY module will be loaded. May be omitted, in which case ecuart is assumed.
+
+=item * C<port=name>
+
+Specifies the serial port name to be opened. Must be specified. If no other configuration items are specified the C<port=> prefix may be omitted.
+
+=item * C<rate=value>
+
+If present, set the baud rate of the serial port. Allowed values are: 115200, 57600, 19200, 9600. If specified, the port is configured with the following settings: rate as specified; data bits 8; stop bits 1; parity none; handshake 0, terminator count 0. For virtual serial ports (eg USB ACMs or Bluetooth serial ports) it is generally not necessary to configure hardware attributes so the rate parameter should not be specified.
+
+=back
+
+Each keyword and value must be separated by an equals ('=') character. There may be whitespace either side of this. Each keword / value pair must be separated by a comma (',') character. Again, there may be whitespace either side of this. The name values may not contain either equals or comma characters as no form of escaping is currently supported.
+
+=head3 Example Configuration Strings
+
+=over 5
+
+=item * Simple use of a C<LOOPBACK.CSY> channel.
+
+ 'loopback::0'
+
+With this example, it is assumed that C<LOOPBACK.CSY> is already loaded. This may, for example be done by whatever is using the other end of the looped back channel.
+
+=item * Use of a C<EUCART.CSY> on the emulator.
+
+ 'pdd=ecdrv, ldd=ecomm, csy=ecuart, port=comm::0'
+
+This will cause both physical and logical device drivers suitable for supporting the C<ECUART.CSY> to be loaded, in addition to the CSY itself. Note, if any of these are already loaded, the KErrAlreadyExists error will be ignored.
+
+=item * Use of a hardware serial port.
+
+ 'pdd=euart1, ldd=ecomm, csy=ecuart, port=comm::0, rate=115200'
+
+=back
+
+=head3 Getting the Configuration String into the Console Implementation
+
+If the console object is being created by the traditional method of calling the function C<Console::NewL>, the configuration string can be specified as the first parameter. For example:
+
+  CConsoleBase* cons = Console::NewL(_L("loopback::0"), TSize(KConsFullScreen, KConsFullScreen));
+
+Note, C<Console::NewL> will attempt to create a C<CConsoleBase> implementation by dynamically loading first F<econs.dll> and (if that fails) F<econseik.dll>. One way to force F<vt100cons.dll> to be used in preference is to put this file in the handset ROM, but name it F<econs.dll>. However, with F<fshell> installations it is more normal for another console implementation named F<iocons.dll> to replace F<econs.dll>. This is a layering console - it doesn't provide a real implementation, but instead allows an underlying console implementation to be used (and shared with other processes). The name of the underlying console implementation is defined in F<\system\console\iosrv.ini>. Change the C<console> keyword value in this file to F<vt100cons.dll> to change the default console implementation used by all console based tools.
+
+Alternatively, if L<fshell|fshell> (or any of F<fshell>'s external C<CCommandBase> derived L<commands|commands>) are being used, both console implementation and title string (the configuration string for F<vt100cons>) can be specified using the command line options C<--console> and C<--console-title>. For example:
+
+  fshell --console vt100cons --console-title 'pdd=euart1, ldd=ecomm, csy=ecuart, port=comm::0, rate=115200'
+
+=head2 USB Variant
+
+Vt100usbcons behaves the same as the serial variant, with the exception that it waits for USB to enumerate into a personality that supports ACM if not already present. In other words it waits for the USB cable to be inserted before trying to open the port. If necessary it also waits for the user to select a config that includes some USB serial ports. It expects the C<--console-title> argument to be of the format C<ACM::x> where x is the port number. This number is platform-specific but is usually 0 or 1. Generally this will be taken care of already in the platform-specific build of the toolkit and you can just launch the "fshell (USB)" icon.
+
+=head2 Bluetooth Variant
+
+Advertises a Bluetooth Serial Port called "Bluetooth Serial Console" and waits for a connection. There are no C<--console-title> configuration options for vt100btcons.
+
+=head3 Configuration
+
+Bluetooth should be enabled on the phone, and it should be paired with the computer. This can be performed using the bluetooth UIs on the phone and PC.
+
+Configuring the PC to correctly connect to the right Bluetooth port can be quite tricky on Windows if the phone already has a Bluetooth serial port configured, for example to provide wireless modem support or mRouter. This is because the Windows UI is not designed to allow configuration of multiple Bluetooth Serial ports. On Windows XP with the default bluetooth stack, the following sequence usually works:
+
+=over 5
+
+=item 1
+
+Ensure that the device and PC are paired, and the device is in discoverable mode.
+
+=item 1
+
+Start the vt100btcons listening, by launching the F<fshell (BT)> icon or by running C<fshell --console vt100btcons>.
+
+=item 1
+
+Launch the Bluetooth Setup Wizard on the PC.
+
+=item 1
+
+Select "I know the service I want to use" in the setup wizard, then choose "Bluetooth Serial Port" from the service list.
+
+=item 1
+
+Choose the relevant bluetooth device. (You may have to change the filter to say "Show phones and modems").
+
+=item 1
+
+If the computer says it has found a port named "<phonename> Bluetooth Serial Console" then it has found the right port first time round and you can skip to step 11. If it says anything else such as "<phonename> Serial port" you need to continue to the next step.
+
+=item 1
+
+Select "Start the connection" and click "Finish". (Don't select "Create a shortcut and restart wizard").
+
+=item 1
+
+Open a terminal program (eg TeraTerm, HyperTerm) and connect to the port you've just created and started. This is not the fshell Bluetooth serial port, but having it connected while re-running the search generally means the PC finds the correct port next time round. You can check that it doesn't give you the fshell prompt "c:\>" but instead probably responds C<OK> if you type C<AT>.
+
+=item 1
+
+Leaving the TeraTerm (or whatever) window connected, go back into the Bluetooth Setup Wizard and rerun "I know the service I want to use", and re-select your device.
+
+=item 1
+
+All being well you will get a dialog appear saying "Connection shortcut for service 'Bluetooth Serial Console' and device '<phonename>' already exists. Do you want to create another shortcut?". Click "Yes".
+
+=item 1
+
+The PC should now report it has completed setup for "<phonename> Bluetooth Serial Console". This is the shortcut you actually want. At this point you can close the TeraTerm connection you had to the other BT serial port. Do that, then click finish in the setup wizard, and it will re-initialise the connection this time to the right serial console port. Connect in teraterm and you should see the fshell "c:\>" prompt appear (you may have to press return first).
+
+=back
+
+=head3 Using the console
+
+Start the vt100btcons listening if it isn't already, by launching the F<fshell (BT)> icon or by running C<fshell --console vt100btcons>. A console will open on the device saying C<Waiting for Bluetooth connection>.
+
+On the PC run the "<phonename> Bluetooth Serial Console" shortcut in the "My Bluetooth Places" that you created during setup. If you're running a different flavour of OS or Bluetooth stack, do whatever is appropriate to start the Bluetooth connection. When the connection is established, the device UI should say C<BT device 'x' connected>. If you only have one bluetooth serial port set up on the PC you can sometimes skip this step completely and it will happen automatically when you open the COM port.
+
+Connect to the appropriate COM port in your preferred terminal emulator. You should see the fshell C<< c:\> >> prompt appear. If you don't, press the return key to initialise the console.
+
+Depending on the Bluetooth stack and how you set up the connection, and the OS version running on the device, the PC may still connect to the wrong port (such as mRouter) instead of the console when the serial connection is established. If this happens, you'll see garbage appearing in your terminal emulator, or you'll get a prompt which only responds to C<AT>. Generally if you disconnect and then re-establish the bluetooth serial connection, it should connect the console on the 2nd attempt. If not you may have to delete the bluetooth config on the PC and try the instructions above in the "Configuration" section.
+
+=head2 TCP/IP Variant
+
+=head3 Configuration
+
+The TCP/IP variant (F<vt100tcpcons.dll>) either listens on a particular TCP port for an incoming connection, or actively connects to a specified remote host. Typically the remote end of the connection is a terminal emulator such as HyperTerminal using TCP/IP as its transport. F<vt100tcpcons.dll> is configured via the C<--console-title> string in a similar way to the serial variant. The follow keyword / value pairs are supported:
+
+=over 5
+
+=item * C<host=string>
+
+Specifies the TCP host to connect to. Can be either a name or an IP address. If not specified, no active connection is attempted, instead the console will passively listen for in-coming connections on the specified port (see below).
+
+=item * C<port=number>
+
+Specifies the TCP port number to listen upon. Mandatory.
+
+=item * C<iap=number>
+
+Specifies the identifier of the Internet Access Provider to be used to establish a network connection. Use the fshell L<iap|fshell::commands::iap> command to get a list of available IAPs.
+
+=item * C<network=number>
+
+Specifies the identifier of the network to be used to establish a network connection. This doesn't appear to be required.
+
+=item * C<protocol=number>
+
+Specifies the ESock protocol to be used. By default selects the Symbian TCP/IP implementation. However, when running on the emulator setting this to 9000 will cause L<winsockprt|winsockprt> to be selected instead.
+
+=item * C<debug=number>
+
+If C<number> is non-zero, debug information relating to the establishment of the TCP connection will be displayed via the underlying console (usually guicons, or if not available C<User::InfoPrint>).
+
+=item * C<implicit=number>
+
+If C<number> is non-zero, no attempt to use the C<RConnection> API will be made and instead all sockets will be associated with the implicit connection. This option is present primarily to support the emulator when using L<winsockprt|winsockprt>, which don't support connections properly. Note, if you're not using winsockprt and are using vt100tcpcons in server (i.e. listening) mode, you will need to ensure that a connection is active if you use implicit mode. This is because passively listening on a socket is not enough to bring up the implicit connection. This does not apply to winsockprt, because that is always effectively connected.
+
+=back
+
+For example:
+
+  fshell --console vt100tcpcons --console-title 'port=8080, iap=6'
+
+=head2 Debugport variant
+
+This console is intended for use only when comm port support is not present in the ROM but the debug port is functional. Generally this only happens early on during a baseport. It uses the text windowserver for input and RDebug::Print for output, the upshot being you get a (mostly) VT100-compatible fshell prompt over the device's debug port without needing C32 comms support (although a working debug port with serial keyboard driver obviously is). There are some limitations on use of this console due to the fact that the text windowserver swallows many control sequences:
+
+=over 5
+
+=item *
+
+Binary mode is not available. This means that xmodem/ymodem cannot be used.
+
+=item *
+
+Console size detection is not supported, and must be disabled in vt100.ini and iosrv.ini (eg by including vt100.ini.noautodetect and iosrv.ini.noautodetect). The console will always be assumed to be 80x24.
+
+=item *
+
+Commands such as fed that rely heavily on control keys may not work properly (or at all).
+
+=item *
+
+Navigation keys such as pageup/down, home/end, function keys, fwd delete and escape will not work. (Escape sort of works, taking effect only on the next keypress).
+
+=back
+
+There are no C<--console-title> options for vt100debugport.dll. Usage:
+
+    fshell --console vt100debugport.dll
+
+=head2 RBusDevComm variant
+
+This console is intended for early on in board bring-up when C32 is not available, but there is a working uart driver. Compare to vt100debugport.dll, which is only worth using when there isn't even a uart driver available but the debug port and serial keyboard driver are available. Unlike vt100debugport.dll, this console does not have any serial emulation restrictions so the full range of services such as binary mode and control keys are available. The C<--console-title> argument is used to specify the port number and other options in a similar way to vt100cons:
+
+    fshell --console vt100busdevcons.dll --console-title port=2
+
+If an option isn't specified, the following are assumed: pdd=euart, ldd=ecomm, rate=115200.
+
+=head1 Copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/eabi/vt100btconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/eabi/vt100consu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2 @@
+EXPORTS
+	NewConsole @ 1 NONAME ; NewConsole
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/eabi/vt100serialu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+EXPORTS
+	_ZN17CVtcSerialConsole10ConstructLERK7TDesC16 @ 1 NONAME
+	_ZN17CVtcSerialConsole11CancelInputER14TRequestStatus @ 2 NONAME
+	_ZN17CVtcSerialConsole5InputER5TDes8R14TRequestStatus @ 3 NONAME
+	_ZN17CVtcSerialConsole6OutputERK6TDesC8 @ 4 NONAME
+	_ZN17CVtcSerialConsoleC1Ev @ 5 NONAME
+	_ZN17CVtcSerialConsoleC2Ev @ 6 NONAME
+	_ZN17CVtcSerialConsoleD0Ev @ 7 NONAME
+	_ZN17CVtcSerialConsoleD1Ev @ 8 NONAME
+	_ZN17CVtcSerialConsoleD2Ev @ 9 NONAME
+	_ZTI17CVtcSerialConsole @ 10 NONAME ; #<TI>#
+	_ZTV17CVtcSerialConsole @ 11 NONAME ; #<VT>#
+	_ZThn4_N17CVtcSerialConsole6OutputERK6TDesC8 @ 12 NONAME ; #<thunk>#
+	_ZThn8_N17CVtcSerialConsole11CancelInputER14TRequestStatus @ 13 NONAME ; #<thunk>#
+	_ZThn8_N17CVtcSerialConsole5InputER5TDes8R14TRequestStatus @ 14 NONAME ; #<thunk>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/eabi/vt100u.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,48 @@
+EXPORTS
+	_ZN15CVtcConsoleBase10ConstructLERK7TDesC16 @ 1 NONAME
+	_ZN15CVtcConsoleBase10Extension_EjRPvS0_ @ 2 NONAME
+	_ZN15CVtcConsoleBase10ReadCancelEv @ 3 NONAME
+	_ZN15CVtcConsoleBase11ClearScreenEv @ 4 NONAME
+	_ZN15CVtcConsoleBase15SetCursorHeightEi @ 5 NONAME
+	_ZN15CVtcConsoleBase15SetCursorPosAbsERK6TPoint @ 6 NONAME
+	_ZN15CVtcConsoleBase15SetCursorPosRelERK6TPoint @ 7 NONAME
+	_ZN15CVtcConsoleBase16ClearToEndOfLineEv @ 8 NONAME
+	_ZN15CVtcConsoleBase4ReadER14TRequestStatus @ 9 NONAME
+	_ZN15CVtcConsoleBase5WriteERK7TDesC16 @ 10 NONAME
+	_ZN15CVtcConsoleBase6CreateERK7TDesC165TSize @ 11 NONAME
+	_ZN15CVtcConsoleBase8SetTitleERK7TDesC16 @ 12 NONAME
+	_ZN15CVtcConsoleBaseC2Ev @ 13 NONAME
+	_ZN15CVtcConsoleBaseD0Ev @ 14 NONAME
+	_ZN15CVtcConsoleBaseD1Ev @ 15 NONAME
+	_ZN15CVtcConsoleBaseD2Ev @ 16 NONAME
+	_ZN25CVtConsoleInputController11GetKeyPressER9TKeyPressR14TRequestStatus @ 17 NONAME
+	_ZN25CVtConsoleInputController17CancelGetKeyPressEv @ 18 NONAME
+	_ZN25CVtConsoleInputController3NewER13MConsoleInputRN8LtkUtils8CIniFileE @ 19 NONAME
+	_ZN25CVtConsoleInputController4NewLER13MConsoleInputRN8LtkUtils8CIniFileE @ 20 NONAME
+	_ZN25CVtConsoleInputController5NewLCER13MConsoleInputRN8LtkUtils8CIniFileE @ 21 NONAME
+	_ZN25CVtConsoleInputController7SetModeEN11ConsoleMode5TModeE @ 22 NONAME
+	_ZN26CVtConsoleOutputController3NewER14MConsoleOutputRN8LtkUtils8CIniFileERK5TSize @ 23 NONAME
+	_ZN26CVtConsoleOutputController4NewLER14MConsoleOutputRN8LtkUtils8CIniFileERK5TSize @ 24 NONAME
+	_ZN26CVtConsoleOutputControllerD0Ev @ 25 NONAME
+	_ZN26CVtConsoleOutputControllerD1Ev @ 26 NONAME
+	_ZN26CVtConsoleOutputControllerD2Ev @ 27 NONAME
+	_ZN9TKeyPressC1E8TKeyCodej @ 28 NONAME
+	_ZN9TKeyPressC1Ev @ 29 NONAME
+	_ZN9TKeyPressC2E8TKeyCodej @ 30 NONAME
+	_ZN9TKeyPressC2Ev @ 31 NONAME
+	_ZNK15CVtcConsoleBase10ScreenSizeEv @ 32 NONAME
+	_ZNK15CVtcConsoleBase12KeyModifiersEv @ 33 NONAME
+	_ZNK15CVtcConsoleBase7KeyCodeEv @ 34 NONAME
+	_ZNK15CVtcConsoleBase9CursorPosEv @ 35 NONAME
+	_ZTI15CVtcConsoleBase @ 36 NONAME ; #<TI>#
+	_ZTV15CVtcConsoleBase @ 37 NONAME ; #<VT>#
+	_ZN25CVtConsoleInputController4NewLER21MConsoleInputObserver @ 38 NONAME ABSENT
+	_ZN25CVtConsoleInputController5NewLCER21MConsoleInputObserver @ 39 NONAME ABSENT
+	_ZN25CVtConsoleInputController9QueueBufLERK6TDesC8 @ 40 NONAME ABSENT
+	_ZN15CVtcConsoleBase5DebugEv @ 41 NONAME
+	_ZN15CVtcConsoleBase7MessageENS_10TVerbosityE11TRefByValueIK7TDesC16Ez @ 42 NONAME
+	_ZN15CVtcConsoleBase8SetDebugEi @ 43 NONAME
+	_ZN26CVtConsoleOutputController13SetAttributesEjN17ConsoleAttributes6TColorES1_ @ 44 NONAME
+	_ZN26CVtConsoleOutputController15ResetAttributesEv @ 45 NONAME
+	_ZN15CVtcConsoleBase20ReadKeywordValuePairER6TLex16R7TPtrC16S3_ @ 46 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/eabi/vt100usbconsu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,41 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+FSHELL_ROM_INCLUDE(vt100.iby)
+FSHELL_ROM_INCLUDE(vt100cons.iby)
+..\inc\vtc_base.h	\epoc32\include\fshell\vtc_base.h
+..\inc\vtc_controller.h	\epoc32\include\fshell\vtc_controller.h
+..\src\vt100\vt100.ini	\epoc32\winscw\c\system\console\vt100.ini
+..\src\vt100\vt100.idf		Z:\resource\vt100.idf
+..\src\vt100\vt100.ini.noautodetect	Z:\system\console\vt100.ini.noautodetect
+
+PRJ_MMPFILES
+.\vt100.mmp
+.\vt100busdevcons.mmp
+
+#ifdef FSHELL_COMMS_SUPPORT
+.\vt100serial.mmp
+.\vt100cons.mmp
+.\vt100btcons.mmp
+.\vt100tcpcons.mmp
+.\vt100usbcons.mmp
+#endif
+
+#ifndef FSHELL_WSERV_SUPPORT
+// If we're text windowserver only
+.\vt100debugport.mmp
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+// vt100.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef VT100_IBY
+#define VT100_IBY
+
+#include <fsh_config.iby>
+FSHELL_EXECUTABLE_FILE(vt100.dll)
+FSHELL_DATA_FILE(ZRESOURCE\vt100.idf, resource\vt100.idf)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// vt100.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			vt100.dll
+targettype		DLL
+uid             0x1000008d FSHELL_UID_VT100
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src\vt100
+userinclude		.
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			vtc_base.cpp
+source			vtc_controller.cpp
+source			vtc_cursor_tracker.cpp
+
+library			euser.lib
+library			ltkutils.lib
+
+deffile			vt100.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100btcons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// vt100btcons.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			vt100btcons.dll
+targettype		DLL
+uid             0x1000008d 0x100039e7
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src\bluetooth
+userinclude		.
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			vtc_bt.cpp
+
+library			euser.lib
+library			btincomingserial.lib bluetooth.lib
+library			vt100.lib
+
+deffile			vt100btcons.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100busdevcons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// vt100busdevcons.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			vt100busdevcons.dll
+targettype		DLL
+uid				0x1000008d 0x100039e7 // Note this MUST be set to 0x100039e7
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			vtc_busdevcons.cpp
+
+library			euser.lib
+library			econs.lib
+library			vt100.lib
+
+deffile			vt100cons.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100cons.iby	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,41 @@
+// vt100cons.iby
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef VT100CONS_IBY
+#define VT100CONS_IBY
+
+#include <fsh_config.iby>
+#include <vt100.iby>
+#include <btincomingserial.iby>
+
+FSHELL_EXECUTABLE_FILE(vt100busdevcons.dll)
+
+#ifdef FSHELL_COMMS_SUPPORT
+FSHELL_EXECUTABLE_FILE(vt100serial.dll)
+FSHELL_EXECUTABLE_FILE(vt100cons.dll)
+FSHELL_EXECUTABLE_FILE(vt100btcons.dll)
+FSHELL_EXECUTABLE_FILE(vt100tcpcons.dll)
+FSHELL_EXECUTABLE_FILE(vt100usbcons.dll)
+#endif
+
+#ifndef FSHELL_WSERV_SUPPORT
+FSHELL_EXECUTABLE_FILE(vt100debugport.dll)
+#endif
+
+// Note, not #including loopback.iby because its doesn't use the
+// tool-kit's .iby file macros, and so breaks SIS file generation
+// via .iby files.
+//#ifndef __LOOPBACK_IBY__
+//#define __LOOPBACK_IBY__
+//FSHELL_EXECUTABLE_FILE(LOOPBACK.CSY)
+//#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100cons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// vt100cons.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			vt100cons.dll
+targettype		DLL
+uid                     0x1000008d 0x100039e7
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src\serial
+userinclude		.
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			vtc_main.cpp
+
+library			euser.lib
+library			vt100serial.lib
+library			vt100.lib
+
+deffile			vt100cons.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100debugport.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// vt100debugport.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			vt100debugport.dll
+targettype		DLL
+uid				0x1000008d 0x100039e7 // Note this MUST be set to 0x100039e7
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			vtc_debugport.cpp
+
+library			euser.lib
+library			econs.lib
+library			vt100.lib
+
+deffile			vt100cons.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100serial.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+// vt100serial.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			vt100serial.dll
+targettype		DLL
+uid				0x1000008d FSHELL_UID_VTCSERIAL
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src\serial
+userinclude		.
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			vtc_serial.cpp
+
+library			euser.lib
+library			c32.lib
+library			vt100.lib
+
+deffile			vt100serial.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100tcpcons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,33 @@
+// vt100tcpcons.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			vt100tcpcons.dll
+targettype		DLL
+uid			0x1000008d 0x100039e7
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src\tcp
+userinclude		.
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			vtc_tcp.cpp
+
+library			euser.lib
+library			esock.lib
+library			vt100.lib
+library			insock.lib
+library			commdb.lib
+
+deffile			vt100cons.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/group/vt100usbcons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// vt100usbcons.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			vt100usbcons.dll
+targettype		DLL
+uid                     0x1000008d 0x100039e7
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src\usb
+userinclude		.
+userinclude		..\inc
+#include <fshell/fsh_system_include.mmh>
+
+source			vtc_usb.cpp
+
+library			euser.lib
+library			usbman.lib
+library			vt100.lib
+library			vt100serial.lib
+
+deffile			vt100usbcons.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/inc/vtc_base.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,71 @@
+// vtc_base.h
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __VT100CONS_BASE_H__
+#define __VT100CONS_BASE_H__
+
+#include <e32std.h>
+#include <e32cons.h>
+#include <fshell/settings.h>
+#include <fshell/vtc_controller.h>
+
+class CVtcConsoleBase : public CConsoleBase, public MConsoleOutput, public MConsoleInput
+	{
+public:
+	IMPORT_C virtual ~CVtcConsoleBase();
+	IMPORT_C virtual TInt Create(const TDesC& aTitle, TSize aSize);
+	IMPORT_C virtual void Read(TRequestStatus& aStatus);
+	IMPORT_C virtual void ReadCancel();
+	IMPORT_C virtual void Write(const TDesC& aDes);
+	IMPORT_C virtual TPoint CursorPos() const;
+	IMPORT_C virtual void SetCursorPosAbs(const TPoint& aPoint);
+	IMPORT_C virtual void SetCursorPosRel(const TPoint& aPoint);
+	IMPORT_C virtual void SetCursorHeight(TInt aPercentage);
+	IMPORT_C virtual void SetTitle(const TDesC& aTitle);
+	IMPORT_C virtual void ClearScreen();
+	IMPORT_C virtual void ClearToEndOfLine();
+	IMPORT_C virtual TSize ScreenSize() const;
+	IMPORT_C virtual TKeyCode KeyCode() const;
+	IMPORT_C virtual TUint KeyModifiers() const;
+	IMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+protected:
+	enum TVerbosity
+		{
+		EInformation,
+		EError,
+		EDebug,
+		};
+protected:
+	IMPORT_C void Message(TVerbosity aVerbosity, TRefByValue<const TDesC> aFmt, ...);
+	IMPORT_C TBool Debug();
+	IMPORT_C void SetDebug(TBool aDebug);
+protected:
+	IMPORT_C CVtcConsoleBase();
+	IMPORT_C virtual void ConstructL(const TDesC& aTitle);
+	IMPORT_C static TInt ReadKeywordValuePair(TLex& aLex, TPtrC& aKeyword, TPtrC& aValue);
+
+private:
+	void DetectScreenSizeL(TSize& aSize);
+	TInt DoDetectScreenSize(TSize& aSize);
+	TInt ReadCursorPos(TPoint& aResult);
+private:
+	TKeyPress iKeyPress;
+	CVtConsoleOutputController* iOutputController;
+	CVtConsoleInputController* iInputController;
+	LtkUtils::CIniFile* iIniFile;
+	TInt iDebug;
+protected:
+	CConsoleBase* iUnderlyingConsole;
+	};
+
+
+#endif // __VT100CONS_BASE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/inc/vtc_controller.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,133 @@
+// vtc_controller.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __VTC_CONTROLLER_H__
+#define __VTC_CONTROLLER_H__
+
+#include <e32keys.h>
+#include <fshell/settings.h>
+#include <fshell/consoleextensions.h>
+#include <fshell/abstract_console_writer.h>
+#include <fshell/common.mmh>
+#include <fshell/descriptorutils.h>
+
+class TCursorTracker;
+class TEscapeMapping;
+
+class MConsoleOutput
+	{
+public:
+	virtual TInt Output(const TDesC8& aDes) = 0;
+	};
+
+NONSHARABLE_CLASS(CVtConsoleOutputController) : public CBase, public MAbstractConsoleWriter
+	{
+public:
+	IMPORT_C static CVtConsoleOutputController* NewL(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile, const TSize& aScreenSize);
+	IMPORT_C static CVtConsoleOutputController* New(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile, const TSize& aScreenSize);
+	IMPORT_C ~CVtConsoleOutputController();
+	IMPORT_C TInt ResetAttributes();
+	IMPORT_C TInt SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor = ConsoleAttributes::EUnchanged, ConsoleAttributes::TColor aBackgroundColor = ConsoleAttributes::EUnchanged);
+	void SetMode(ConsoleMode::TMode aMode);
+
+public: // From MAbstractConsoleWriter.
+	virtual TInt GetCursorPos(TPoint& aPos) const;
+	virtual TInt SetCursorPosAbs(const TPoint& aPos);
+	virtual TInt SetCursorPosRel(const TPoint& aPos);
+	virtual TInt SetCursorHeight(TInt aPercentage);
+	virtual TInt SetTitle(const TDesC& aTitle);
+	virtual TInt ClearScreen();
+	virtual TInt ClearToEndOfLine();
+	virtual TInt GetScreenSize(TSize& aSize) const;
+	virtual TInt Write(const TDesC& aDes);
+	virtual TInt Write(const TDesC8& aDes);
+private:
+	CVtConsoleOutputController(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile);
+	TInt Construct(const TSize& aScreenSize);
+private:
+	MConsoleOutput& iOutput;
+	LtkUtils::CIniFile& iIniFile;
+	TCursorTracker* iCursorTracker;
+	LtkUtils::RLtkBuf8 iOutputBuf;
+	ConsoleMode::TMode iMode;
+	};
+	
+class TKeyPress
+	{
+public:
+	IMPORT_C TKeyPress();
+	IMPORT_C TKeyPress(TKeyCode aCode, TUint aModifiers);
+public:
+	TKeyCode iCode;
+	TUint iModifiers;
+	};
+
+class MConsoleInput
+	{
+public:
+	virtual void Input(TDes8& aDes, TRequestStatus& aStatus) = 0;
+	virtual void CancelInput(TRequestStatus& aStatus) = 0;
+	};
+
+NONSHARABLE_CLASS(CVtConsoleInputController) : public CActive
+	{
+public:
+	IMPORT_C static CVtConsoleInputController* New(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile);
+	IMPORT_C static CVtConsoleInputController* NewL(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile);
+	IMPORT_C static CVtConsoleInputController* NewLC(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile);
+	IMPORT_C void GetKeyPress(TKeyPress& aKeyPress, TRequestStatus& aStatus);
+	IMPORT_C void CancelGetKeyPress();
+	IMPORT_C void SetMode(ConsoleMode::TMode aMode);
+public:
+	virtual ~CVtConsoleInputController();
+private:
+	void ConstructL();
+	CVtConsoleInputController(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile);
+	void DoEscapeKeyL(TUint8 aChar, const TEscapeMapping* iMappings, TInt aMappingCount);
+	void DoExtendedEscapeKey();
+	static TInt EscapeTimeoutS(TAny* aSelf);
+	TInt EscapeTimeout();
+	void ReadKeyPress();
+	void CompleteKeyPressRequest(TInt aError);
+	void CompleteKeyPressRequest(TKeyCode aKeyCode);
+	void CompleteKeyPressRequest(TKeyCode aKeyCode1, TKeyCode aKeyCode2);
+	void Reset();
+	void ReadInput();
+private: // From CActive.
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	enum TState
+		{
+		ENormal,
+		EWaitingForEscapeChar2,
+		EWaitingForEscapeChar3,
+		EWaitingForEscapeChar3Func,
+		EWaitingForExtendedFunc, // Chars 4 and later
+		};
+private:
+	MConsoleInput& iConsoleInput;
+	LtkUtils::CIniFile& iIniFile;
+	TState iState;
+	CPeriodic* iEscapeTimer;
+	ConsoleMode::TMode iMode;
+	TBuf8<1024> iBuf;
+	TInt iBufPos;
+	TKeyPress* iClientKeyPress;
+	TRequestStatus* iClientRequestStatus;
+	TBool iKeyCodePending;
+	TKeyCode iPendingKeyCode;
+	TInt iInputError;
+	TBuf8<4> iExtendedEscapeBuf;
+	};
+	
+#endif //__VTC_CONTROLLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/inc/vtc_serial.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,56 @@
+// vtc_serial.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __VTC_SERIAL_H__
+#define __VTC_SERIAL_H__
+
+#include <e32std.h>
+#include <e32cons.h>
+#include <c32comm.h>
+#include <e32math.h>
+#include <fshell/consoleextensions.h>
+#include <fshell/vtc_base.h>
+#include <fshell/vtc_controller.h>
+
+class TPortConfig
+	{
+public:
+	TPortConfig() : iRate(EBpsAutobaud) {}
+
+	TPtrC iPdd;
+	TPtrC iLdd;
+	TPtrC iCsy;
+	TPtrC iPort;
+	TBps iRate;
+	};
+	
+
+class CVtcSerialConsole : public CVtcConsoleBase
+	{
+public:
+	IMPORT_C CVtcSerialConsole();
+	IMPORT_C virtual ~CVtcSerialConsole();
+protected: // From CVtcSerialConsole.
+	IMPORT_C virtual void ConstructL(const TDesC& aTitle);
+private: // From MConsoleOutput.
+	IMPORT_C virtual TInt Output(const TDesC8& aDes);
+private: // From MConsoleInput.
+	IMPORT_C virtual void Input(TDes8& aDes, TRequestStatus& aStatus);
+	IMPORT_C virtual void CancelInput(TRequestStatus& aStatus);
+private:
+	TInt ReadConfig(const TDesC& aConfigDes, TPortConfig& aConfig);
+private:
+	RCommServ iCommServ;
+	RComm iCommPort;
+	};
+
+#endif //__VTC_SERIAL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/bluetooth/vtc_bt.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,113 @@
+// vtc_bt.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32std.h>
+#include <fshell/consoleextensions.h>
+#include "vtc_bt.h"
+
+
+EXPORT_C TAny* NewConsole()
+	{
+	return new CBtConsole;
+	}
+	
+//______________________________________________________________________________
+//						CBtConsole
+CBtConsole::CBtConsole()
+	{
+	}
+
+CBtConsole::~CBtConsole()
+	{
+	iBtConnection.Close();
+	}
+
+_LIT(KWaitingForBt, "Waiting for Bluetooth connection");
+_LIT(KConnectionErrorFmt, "Bluetooth connection error - %d");
+_LIT(KConnectedNameAddrFmt, "BT device '%S' (%02x:%02x:%02x:%02x:%02x:%02x) connected");
+_LIT(KConnectedAddrFmt, "BT device %02x:%02x:%02x:%02x:%02x:%02x connected");
+
+void CBtConsole::ConstructL(const TDesC& aTitle)
+	{
+	// Run the preamble script, if we have one. Because iosrv is multithreaded this shouldn't cause a deadlock so long as we use a different console (in this case, nullcons)
+	_LIT(KPreamble, "--console nullcons vt100btcons_preamble");
+	RProcess preamble;
+	TRequestStatus stat;
+	TInt err = preamble.Create(_L("fshell.exe"), KPreamble);
+	if (err == KErrNone)
+		{
+		preamble.Logon(stat);
+		if (stat == KRequestPending)
+			{
+			preamble.Resume();
+			User::WaitForRequest(stat);
+			}
+		err = stat.Int();
+		preamble.Close();
+		}
+
+	if (err == KErrNone)
+		{
+		Message(EInformation, _L("Preamble script ran ok"));
+		}
+	else if (err != KErrNotFound)
+		{
+		Message(EInformation, _L("Preamble script failed with %d"), err);
+		}
+
+
+	User::LeaveIfError(iBtConnection.Connect());
+	iBtConnection.WaitForConnection(stat);
+	Message(EInformation, KWaitingForBt);
+	User::WaitForRequest(stat);
+	if (stat.Int() != KErrNone)
+		{
+		Message(EError, KConnectionErrorFmt, stat.Int());
+		User::Leave(stat.Int());
+		}
+		
+	TBTDevAddr addr;
+	User::LeaveIfError(iBtConnection.GetConnectedDeviceAddr(addr));
+	TName name;
+	
+	TInt nerr = iBtConnection.GetConnectedDeviceName(name);
+	if (nerr == KErrOverflow) nerr = KErrNone;
+	
+	if (nerr == KErrNone)
+		{
+		Message(EInformation, KConnectedNameAddrFmt, &name, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+		}
+	else
+		{
+		Message(EInformation, KConnectedAddrFmt, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+		}
+	
+	CVtcConsoleBase::ConstructL(aTitle);
+	}
+	
+TInt CBtConsole::Output(const TDesC8& aDes)
+	{
+	TRequestStatus stat;
+	iBtConnection.Write(aDes, stat);
+	User::WaitForRequest(stat);
+	return stat.Int();
+	}
+
+void CBtConsole::Input(TDes8& aDes, TRequestStatus& aStatus)
+	{
+	iBtConnection.Read(aDes, aStatus);
+	}
+
+void CBtConsole::CancelInput(TRequestStatus&)
+	{
+	iBtConnection.CancelRead();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/bluetooth/vtc_bt.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// vtc_bt.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __VTC_BT_H__
+#define __VTC_BT_H__
+
+#include <e32cons.h>
+#include <fshell/btserialclient.h>
+#include <fshell/vtc_base.h>
+#include <fshell/vtc_controller.h>
+
+NONSHARABLE_CLASS(CBtConsole) : public CVtcConsoleBase
+	{
+public:
+	CBtConsole();
+	virtual ~CBtConsole();
+private: // From CVtcSerialConsole.
+	virtual void ConstructL(const TDesC& aTitle);
+private: // From MConsoleOutput.
+	virtual TInt Output(const TDesC8& aDes);
+private: // From MConsoleInput.
+	virtual void Input(TDes8& aDes, TRequestStatus& aStatus);
+	virtual void CancelInput(TRequestStatus& aStatus);
+private:
+	RBtSerialSession iBtConnection;
+	};
+
+
+#endif //__VTC_BT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/serial/vtc_main.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+// vtc_main.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "vtc_serial.h"
+
+
+EXPORT_C TAny* NewConsole()
+	{
+	return new CVtcSerialConsole;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/serial/vtc_serial.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,210 @@
+// vtc_serial.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+#include "vtc_serial.h"
+
+const TInt KMaxWriteLength = 2 * 1024; // Some serial drivers fail with KErrNoMemory if writes are too big, so they have to be broken up.
+
+#define LEAVE_IF_ERROR_ALLOW_ALREADY_EXISTS(_x) { TInt _err = _x; if ((_err < 0) && (_err != KErrAlreadyExists)) { User::Leave(_err); } }
+
+EXPORT_C CVtcSerialConsole::CVtcSerialConsole()
+	{
+	}
+
+EXPORT_C CVtcSerialConsole::~CVtcSerialConsole()
+	{
+	iCommPort.Close();
+	iCommServ.Close();
+	}
+
+TInt CVtcSerialConsole::ReadConfig(const TDesC& aConfigDes, TPortConfig& aConfig)
+	{
+	_LIT(KKeywordPdd, "pdd");
+	_LIT(KKeywordLdd, "ldd");
+	_LIT(KKeywordCsy, "csy");
+	_LIT(KKeywordPort, "port");
+	_LIT(KKeywordRate, "rate");
+
+	TBool keywordFound(EFalse);
+	TLex lex(aConfigDes);
+	while (!lex.Eos())
+		{
+		TPtrC keyword;
+		TPtrC value;
+		TInt err = ReadKeywordValuePair(lex, keyword, value);
+		if (err != KErrNone)
+			{
+			break;
+			}
+
+		if (keyword == KKeywordPdd)
+			{
+			aConfig.iPdd.Set(value);
+			keywordFound = ETrue;
+			}
+		else if (keyword == KKeywordLdd)
+			{
+			aConfig.iLdd.Set(value);
+			keywordFound = ETrue;
+			}
+		else if (keyword == KKeywordCsy)
+			{
+			aConfig.iCsy.Set(value);
+			keywordFound = ETrue;
+			}
+		else if (keyword == KKeywordPort)
+			{
+			aConfig.iPort.Set(value);
+			keywordFound = ETrue;
+			}
+		else if (keyword == KKeywordRate)
+			{
+			TLex lex(value);
+			TUint rate;
+			if (lex.Val(rate) == KErrNone)
+				{
+				switch (rate)
+					{
+				case 115200:
+					aConfig.iRate = EBps115200; break;
+				case 9600:
+					aConfig.iRate = EBps9600; break;
+				case 19200:
+					aConfig.iRate = EBps19200; break;
+				case 57600:
+					aConfig.iRate = EBps57600; break;
+				default:
+					break;
+					}
+				}
+			keywordFound = ETrue;
+			}
+		}
+
+	if (!keywordFound)
+		{
+		// Treat unrecognised string as a port name (to preserve backwards compatibility with earlier releases).
+		aConfig.iPort.Set(aConfigDes);
+		}
+
+	return KErrNone;
+	}
+
+EXPORT_C void CVtcSerialConsole::ConstructL(const TDesC& aTitle)
+	{
+	TPortConfig portConfig;
+	User::LeaveIfError(ReadConfig(aTitle, portConfig));
+	if (portConfig.iPort.Length() == 0)
+		{
+		User::Leave(KErrArgument);
+		}
+	if (portConfig.iPdd.Length())
+		{
+		LEAVE_IF_ERROR_ALLOW_ALREADY_EXISTS(User::LoadPhysicalDevice(portConfig.iPdd));
+		}
+	else
+		{
+		// If not specified, assume they probably intended the standard ones (but don't error if they fail, since the user might actually know what they're doing
+#ifdef __WINS__
+		User::LoadPhysicalDevice(_L("ecdrv"));
+#else
+		User::LoadPhysicalDevice(_L("euart1"));
+#endif
+		}
+
+	if (portConfig.iLdd.Length())
+		{
+		LEAVE_IF_ERROR_ALLOW_ALREADY_EXISTS(User::LoadLogicalDevice(portConfig.iLdd));
+		}
+	else
+		{
+		User::LoadLogicalDevice(_L("ecomm"));
+		}
+
+	User::LeaveIfError(iCommServ.Connect());
+	if (portConfig.iCsy.Length())
+		{
+		LEAVE_IF_ERROR_ALLOW_ALREADY_EXISTS(iCommServ.LoadCommModule(portConfig.iCsy));
+		}
+	else
+		{
+		iCommServ.LoadCommModule(_L("ecuart"));
+		}
+	User::LeaveIfError(iCommPort.Open(iCommServ, portConfig.iPort, ECommExclusive));
+
+#ifdef __WINS__
+	// For BC reasons, we always set rate on WINS
+	if (portConfig.iRate == EBpsAutobaud) portConfig.iRate = EBps115200;
+#endif
+
+	if (portConfig.iRate != EBpsAutobaud)
+		{
+		TCommConfig cfg;
+		cfg().iRate = portConfig.iRate;
+		cfg().iDataBits = EData8;
+		cfg().iStopBits = EStop1;
+		cfg().iParity = EParityNone;
+		cfg().iHandshake = 0;
+		cfg().iParityError = KConfigParityErrorFail;
+		cfg().iFifo = EFifoEnable;
+		cfg().iSpecialRate = 0;
+		cfg().iTerminatorCount = 0;
+		cfg().iSIREnable = ESIRDisable;
+		User::LeaveIfError(iCommPort.SetConfig(cfg));
+		}
+	
+	User::LeaveIfError(iCommPort.ResetBuffers());
+	CVtcConsoleBase::ConstructL(aTitle);
+	}
+	
+EXPORT_C TInt CVtcSerialConsole::Output(const TDesC8& aDes)
+	{
+	TRequestStatus status;
+	TInt offset = 0;
+	TInt err = KErrNone;
+	while ((offset < aDes.Length()) && (err == KErrNone))
+		{
+		const TInt bytesToWrite = Min(aDes.Length() - offset, KMaxWriteLength);
+		do
+			{
+			iCommPort.Write(status, aDes.Mid(offset, bytesToWrite));
+			User::WaitForRequest(status);
+			err = status.Int();
+			if (err == KErrNone)
+				{
+				offset += bytesToWrite;
+				}
+			else if (err == KErrNoMemory)	// Necessary because of nasty behaviour in loopback.csy where it returns KErrNoMemory when its buffer is full, rather than simply delaying completion of the request until there is enough space.
+				{
+				User::After(200000);
+				}
+			}
+#ifdef FSHELL_PLATFORM_OPP // Temporary OPP specific change - the drivers for the mid-sized prototype currently complete requests with KErrAbort just before power management sends the device to sleep.
+		while ((err == KErrNoMemory) || (err == KErrAbort));
+#else
+		while (err == KErrNoMemory);
+#endif
+		}
+
+	return err;
+	}
+
+EXPORT_C void CVtcSerialConsole::Input(TDes8& aDes, TRequestStatus& aStatus)
+	{
+	iCommPort.ReadOneOrMore(aStatus, aDes);
+	}
+
+EXPORT_C void CVtcSerialConsole::CancelInput(TRequestStatus&)
+	{
+	iCommPort.ReadCancel();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/tcp/vtc_tcp.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,440 @@
+// vtc_tcp.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32std.h>
+#include <e32cons.h>
+#include <c32comm.h>
+#include <e32math.h>
+#include <es_sock.h>
+#include <in_sock.h>
+#include <commdbconnpref.h>
+#include <fshell/consoleextensions.h>
+#include <fshell/vtc_base.h>
+#include <fshell/vtc_controller.h>
+
+const TInt KUninitialized = -1;
+
+class TPortConfig
+	{
+public:
+	TPortConfig();
+public:
+	TName iHost;
+	TInt iPort;
+	TInt iIapId;
+	TInt iNetworkId;
+	TInt iProtocolId;
+	TInt iImplicit;
+	};
+
+TPortConfig::TPortConfig()
+	: iPort(8080), iIapId(KUninitialized), iNetworkId(KUninitialized), iProtocolId(KProtocolInetTcp), iImplicit(0)
+	{
+	}
+	
+NONSHARABLE_CLASS(CVtcTcpConsole) : public CVtcConsoleBase
+	{
+public:
+	CVtcTcpConsole();
+	~CVtcTcpConsole();
+private: // From CVtcSerialConsole.
+	virtual void ConstructL(const TDesC& aTitle);
+private: // From MConsoleOutput.
+	virtual TInt Output(const TDesC8& aDes);
+private: // From MConsoleInput.
+	virtual void Input(TDes8& aDes, TRequestStatus& aStatus);
+	virtual void CancelInput(TRequestStatus& aStatus);
+private:
+	TInt ConfigurePort(const TDesC& aConfig);
+	TInt ReadConfig(const TDesC& aConfigDes, TPortConfig& aConfig);
+	TInt Accept(const TPortConfig& aConfig);
+	TInt Connect(const TPortConfig& aConfig);
+	
+	TInt Query(TRequestStatus& stat, TRefByValue<const TDesC> aFmt, ...);
+	void CancelQuery();
+	void CleanupQuery();
+
+private:
+	RSocketServ iSocketServ;
+	RConnection iConnection;
+	RSocket iListeningSocket;
+	RSocket iClientSocket;
+	TSockXfrLength iSockXfrLength;
+	RNotifier iNotifier;
+	TInt iQueryResult;
+	};
+
+
+CVtcTcpConsole::CVtcTcpConsole()
+	{
+	}
+
+CVtcTcpConsole::~CVtcTcpConsole()
+	{
+	iNotifier.Close();
+	
+	iListeningSocket.Close();
+	iClientSocket.Close();
+	iConnection.Close();
+	iSocketServ.Close();
+	}
+
+class TOverflowTruncate : public TDes16Overflow
+	{
+public:
+	virtual void Overflow(TDes16&) {}
+	};
+	
+TInt CVtcTcpConsole::Query(TRequestStatus& stat, TRefByValue<const TDesC> aFmt, ...)
+	{
+	TOverflowTruncate overflow;
+	VA_LIST list;
+	VA_START(list, aFmt);
+	TBuf<0x100> buf;
+	buf.AppendFormatList(aFmt, list, &overflow);
+
+	if (iUnderlyingConsole)
+		{
+		Message(EInformation, buf);
+		// when using a console, the accept can be cancelled by hitting ctrl-c
+		return KErrNotSupported;
+		}
+	else
+		{
+		TInt err = KErrNone;
+		if (iNotifier.Handle() == KNullHandle)
+			{
+			err = iNotifier.Connect();
+			}
+		if (err == KErrNone)
+			{
+			iNotifier.Notify(_L("vt100tcpcons"), buf, _L("OK"), _L("Cancel"), iQueryResult, stat);
+			}
+		return err;
+		}
+	}
+	
+void CVtcTcpConsole::CancelQuery()
+	{
+	if (iNotifier.Handle())
+		{
+		iNotifier.NotifyCancel(); // Annoyingly this doesn't appear to be implemented, so we can't auto-dismiss the dialog.
+		iNotifier.Close();
+		}
+	}
+	
+void CVtcTcpConsole::ConstructL(const TDesC& aTitle)
+	{
+	User::LeaveIfError(ConfigurePort(aTitle));
+	CVtcConsoleBase::ConstructL(aTitle);
+	}
+
+TInt CVtcTcpConsole::ReadConfig(const TDesC& aConfigDes, TPortConfig& aConfig)
+	{
+	_LIT(KKeywordHost, "host");
+	_LIT(KKeywordPort, "port");
+	_LIT(KKeywordIapId, "iap");
+	_LIT(KKeywordNetworkId, "network");
+	_LIT(KKeywordProtocolId, "protocol");
+	_LIT(KKeywordDebug, "debug");
+	_LIT(KKeywordImplicit, "implicit");
+
+	TInt err = KErrNone;
+	TLex lex(aConfigDes);
+	while (!lex.Eos())
+		{
+		TPtrC keyword;
+		TPtrC valueDes;
+		err = ReadKeywordValuePair(lex, keyword, valueDes);
+		if (err != KErrNone)
+			{
+			break;
+			}
+
+		if (keyword == KKeywordHost)
+			{
+			aConfig.iHost = valueDes;
+			}
+		else
+			{
+			TInt valueInt;
+			TLex lex(valueDes);
+			err = lex.Val(valueInt);
+
+			if (keyword == KKeywordPort)
+				{
+				aConfig.iPort = valueInt;
+				}
+			else if (keyword == KKeywordIapId)
+				{
+				aConfig.iIapId = valueInt;
+				}
+			else if (keyword == KKeywordNetworkId)
+				{
+				aConfig.iNetworkId = valueInt;
+				}
+			else if (keyword == KKeywordProtocolId)
+				{
+				aConfig.iProtocolId = valueInt;
+				}
+			else if (keyword == KKeywordDebug)
+				{
+				SetDebug(valueInt);
+				}
+			else if (keyword == KKeywordImplicit)
+				{
+				aConfig.iImplicit = valueInt;
+				}
+			}
+		}
+
+	return err;
+	}
+
+TInt CVtcTcpConsole::ConfigurePort(const TDesC& aConfig)
+	{
+	TPortConfig portConfig;
+	TInt err = ReadConfig(aConfig, portConfig);
+	if (err == KErrNone)
+		{
+		err = iSocketServ.Connect();
+		}
+	if ((err == KErrNone) && !portConfig.iImplicit)
+		{
+		err = iConnection.Open(iSocketServ);
+		if (err == KErrNone)
+			{
+			Message(EDebug, _L("Starting connection..."));
+			TCommDbConnPref prefs;
+			if (portConfig.iIapId == KUninitialized)
+				{
+				prefs.SetDialogPreference(ECommDbDialogPrefPrompt);
+				}
+			else
+				{
+				prefs.SetIapId(portConfig.iIapId);
+				prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+				}
+			err = iConnection.Start(prefs);
+			if (err)
+				{
+				Message(EError, _L("Connection failed (%d)"), err);
+				}
+			}
+		}
+	if (err == KErrNone)
+		{
+		if (portConfig.iHost.Length() > 0)
+			{
+			err = Connect(portConfig);
+			}
+		else
+			{
+			err = Accept(portConfig);
+			}			
+		}
+
+	if (err == KErrNone)
+		{
+		iClientSocket.SetOpt(KSoTcpNoDelay, KSolInetTcp, ETrue);	// Ignore error (may not be supported).
+		Message(EDebug, _L("Connected."));
+		}
+
+	if (err != KErrNone)
+		{
+		iClientSocket.Close();
+		iListeningSocket.Close();
+		iConnection.Close();
+		iSocketServ.Close();
+		}
+
+	return err;
+	}
+	
+TInt CVtcTcpConsole::Connect(const TPortConfig& aConfig)
+	{
+	Message(EDebug, _L("Connecting to %S:%u"), &aConfig.iHost, aConfig.iPort);
+	TInetAddr addr(aConfig.iPort);
+	TInt err = addr.Input(aConfig.iHost);
+	if (err)
+		{
+		RHostResolver resolver;
+		if (aConfig.iImplicit)
+			{
+			err = (resolver.Open(iSocketServ, KAfInet, aConfig.iProtocolId));
+			}
+		else
+			{
+			err = (resolver.Open(iSocketServ, KAfInet, aConfig.iProtocolId, iConnection));
+			}
+		if (err == KErrNone)
+			{
+			TNameEntry nameEntry;
+			err = resolver.GetByName(aConfig.iHost, nameEntry);
+			if (err == KErrNone)
+				{
+				addr.SetAddress(TInetAddr::Cast(nameEntry().iAddr).Address());
+				}
+			resolver.Close();
+			}
+		}
+	if (err == KErrNone)
+		{
+		if (aConfig.iImplicit)
+			{
+			err = iClientSocket.Open(iSocketServ, KAfInet, KSockStream, aConfig.iProtocolId);
+			}
+		else
+			{
+			err = iClientSocket.Open(iSocketServ, KAfInet, KSockStream, aConfig.iProtocolId, iConnection);
+			}
+		}
+	if (err == KErrNone)
+		{
+		TRequestStatus status;
+		iClientSocket.Connect(addr, status);
+		User::WaitForRequest(status);
+		err = status.Int();
+		}
+	if (err != KErrNone)
+		{
+		Message(EError, _L("Connection to %S:%u failed (%d)"), &aConfig.iHost, aConfig.iPort, err);
+		}
+	return err;
+	}
+	
+TInt CVtcTcpConsole::Accept(const TPortConfig& aConfig)
+	{
+	TInt err = KErrNone;
+	Message(EDebug, _L("Opening listening socket..."));
+	if (aConfig.iImplicit)
+		{
+		err = iListeningSocket.Open(iSocketServ, KAfInet, KSockStream, aConfig.iProtocolId);
+		}
+	else
+		{
+		err = iListeningSocket.Open(iSocketServ, KAfInet, KSockStream, aConfig.iProtocolId, iConnection);
+		}
+	if (err == KErrNone)
+		{
+		TInetAddr addr(aConfig.iPort);
+		Message(EDebug, _L("Binding listening socket..."));
+		err = iListeningSocket.Bind(addr);
+		if (err)
+			{
+			Message(EError, _L("Bind failed (%d)"), err);
+			}
+		}
+	if (err == KErrNone)
+		{
+		err = iListeningSocket.Listen(1);
+		}
+	if (err == KErrNone)
+		{
+		err = iClientSocket.Open(iSocketServ);
+		}
+	if (err == KErrNone)
+		{
+		// Find our local IP address.
+		TInetAddr addr;
+		addr.SetAddress(KInetAddrAny);
+		TPckgBuf<TSoInetIfQuery> query;
+		query().iDstAddr = addr;
+		TInt err2 = iListeningSocket.GetOpt(KSoInetIfQueryByDstAddr, KSolInetIfQuery, query);
+		TInt qerr;
+		
+		TRequestStatus queryStatus;
+		if (err2 == KErrNone)
+			{
+			TBuf<128> addrName;
+			query().iSrcAddr.Output(addrName);
+			qerr = Query(queryStatus, _L("Listening on %S:%d..."), &addrName, aConfig.iPort);
+			}
+		else
+			{
+			qerr = Query(queryStatus, _L("Listening on port %d..."), aConfig.iPort);
+			}
+
+		// Start the accept.
+		TRequestStatus acceptStatus;
+		iListeningSocket.Accept(iClientSocket, acceptStatus);
+
+		if (qerr == KErrNone)
+			{
+			User::WaitForRequest(acceptStatus, queryStatus);
+			if (acceptStatus != KRequestPending)
+				{
+				CancelQuery();
+				User::WaitForRequest(queryStatus);
+				}
+			else
+				{
+				if (iQueryResult == 1)
+					{
+					if (acceptStatus == KRequestPending)
+						{
+						iListeningSocket.CancelAccept();
+						}
+					User::WaitForRequest(acceptStatus);
+					}
+				else
+					{
+					User::WaitForRequest(acceptStatus);
+					}
+				CancelQuery();
+				}
+			}
+		else
+			{
+			User::WaitForRequest(acceptStatus);
+			}
+
+		err = acceptStatus.Int();
+		if (err)
+			{
+			Message(EError, _L("Accept failed (%d)"), err);
+			}
+		else
+			{
+			TInetAddr remote;
+			iClientSocket.RemoteName(remote);
+			TBuf<128> addrName;
+			remote.Output(addrName);
+			Message(EInformation, _L("Remote %S connected."), &addrName);
+			}
+		}
+	return err;
+	}
+	
+TInt CVtcTcpConsole::Output(const TDesC8& aDes)
+	{
+	TRequestStatus status;
+	iClientSocket.Write(aDes, status);
+	User::WaitForRequest(status);
+	return status.Int();
+	}
+
+void CVtcTcpConsole::Input(TDes8& aDes, TRequestStatus& aStatus)
+	{
+	iClientSocket.RecvOneOrMore(aDes, 0, aStatus, iSockXfrLength);
+	}
+
+void CVtcTcpConsole::CancelInput(TRequestStatus&)
+	{
+	iClientSocket.CancelRead();
+	}
+
+EXPORT_C TAny* NewConsole()
+	{
+	return new CVtcTcpConsole;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/usb/vtc_usb.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,113 @@
+// vtc_usb.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32std.h>
+#include <fshell/consoleextensions.h>
+#include "vtc_usb.h"
+#include <usbclassuids.h>
+
+EXPORT_C TAny* NewConsole()
+	{
+	return new CUsbConsole;
+	}
+	
+//______________________________________________________________________________
+//						CUsbConsole
+CUsbConsole::CUsbConsole()
+	{
+	}
+
+CUsbConsole::~CUsbConsole()
+	{
+	iUsb.Close();
+	}
+	
+void CUsbConsole::ConstructL(const TDesC& aTitle)
+	{
+	User::LeaveIfError(iUsb.Connect());
+	
+	TRequestStatus stat;
+	// assume USB device already started
+	/*iUsb.Start(stat);
+	User::WaitForRequest(stat);
+	// KErrAccessDenied returned if already started;
+	if (stat.Int()!=KErrAccessDenied)
+		{
+		Message(EError, KUsbError, stat.Int(), 1);
+		User::LeaveIfError(stat.Int());
+		}*/
+
+	// Wait for an enumeration that supports ACM (this is so that if the device defaulted to say mass storage and was then reconfigured to a personality with ACM, we wait for the ACM reconfiguration
+	TBool gotAcm = EFalse;
+	while (!gotAcm)
+		{
+		TUsbDeviceState usbState;
+		User::LeaveIfError(iUsb.GetDeviceState(usbState));
+		if (usbState & EUsbDeviceStateConfigured)
+			{
+			// Check if we have ACM
+			TInt currentPersonality;
+			User::LeaveIfError(iUsb.GetCurrentPersonalityId(currentPersonality));
+			User::LeaveIfError(iUsb.ClassSupported(currentPersonality, KECACMUid, gotAcm));
+			_LIT(KGotIt, "Current USB personality has ACM, proceeding");
+			_LIT(KNotGotIt, "Current USB personality doesn't have ACM, waiting for re-enumeration");
+			if (gotAcm) Message(EInformation, KGotIt);
+			else Message(EInformation, KNotGotIt);
+			}
+
+		if (!gotAcm)
+			{
+			// We're not enumerated, or we are but don't have ACM. So wait for a (re-)enumeration
+			_LIT(KWaitingForEnumeration, "Waiting for USB enumeration (please connect USB cable)");
+			Message(EInformation, KWaitingForEnumeration);
+			iUsb.DeviceStateNotification(EUsbDeviceStateConfigured, usbState, stat);
+			User::WaitForRequest(stat);
+			if (stat.Int() != KErrNone)
+				{
+				_LIT(KUsbError, "Error configuring USB: %d");
+				Message(EError, KUsbError, stat.Int());
+				User::Leave(stat.Int());
+				}
+			_LIT(KUsbEnumerated, "USB cable connected.");
+			Message(EInformation, KUsbEnumerated);
+			}
+		}
+	
+	// Run the preamble script, if we have one. Because iosrv is multithreaded this shouldn't cause a deadlock so long as we use a different console (in this case, nullcons)
+	_LIT(KPreamble, "--console nullcons vt100usbcons_preamble");
+	RProcess preamble;
+	TInt err = preamble.Create(_L("fshell.exe"), KPreamble);
+	if (err == KErrNone)
+		{
+		preamble.Logon(stat);
+		if (stat == KRequestPending)
+			{
+			preamble.Resume();
+			User::WaitForRequest(stat);
+			}
+		err = stat.Int();
+		preamble.Close();
+		}
+
+	if (err == KErrNone)
+		{
+		Message(EInformation, _L("Preamble script ran ok"));
+		}
+	else if (err != KErrNotFound)
+		{
+		Message(EInformation, _L("Preamble script failed with %d"), err);
+		}
+
+	//TODO should we ensure that the port passed in here is an ACM::%s port?
+	Message(EInformation, _L("Opening %S"), &aTitle);
+	CVtcSerialConsole::ConstructL(aTitle);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/usb/vtc_usb.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// vtc_usb.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __VTC_BT_H__
+#define __VTC_BT_H__
+
+#include <e32cons.h>
+#include <usbman.h>
+#include "vtc_serial.h"
+
+NONSHARABLE_CLASS(CUsbConsole) : public CVtcSerialConsole
+	{
+public:
+	CUsbConsole();
+	virtual ~CUsbConsole();
+private: // From CVtcSerialConsole.
+	virtual void ConstructL(const TDesC& aTitle);
+private:
+	RUsb iUsb;
+	};
+
+
+#endif //__VTC_BT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vt100/vt100.idf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+# vt100.idf
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+support_attributes				boolean
+support_attributes.name			Support attributes
+support_attributes.description	Controls whether manipulation of the terminal's attributes (defining color, boldness, etc.) will be attempted.
+support_attributes.default		yes
+
+foreground_color				enum
+foreground_color.name			Foreground color
+foreground_color.description	Sets the foreground color of the terminal
+# values for this correspond to enum ConsoleAttributes::TColor (reset probably isn't a valid choice!)
+foreground_color.values			black,red,green,yellow,blue,magenta,cyan,white,reset,unchanged
+foreground_color.default		unchanged
+
+background_color				enum
+background_color.name			Background color
+background_color.description	Sets the background color of the terminal
+# values for this correspond to enum ConsoleAttributes::TColor (reset probably isn't a valid choice!)
+background_color.values			black,red,green,yellow,blue,magenta,cyan,white,reset,unchanged
+background_color.default		unchanged
+
+console_size_detect				boolean
+console_size_detect.name		Autodetect console size
+console_size_detect.description	Automatically detect the VT100 terminal emualator
+console_size_detect.default		true
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vt100/vt100.ini	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+#!iniedit -i \resource\vt100.idf
+# vt100.ini
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+support_attributes yes
+foreground_color yellow
+background_color blue
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vt100/vt100.ini.noautodetect	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,15 @@
+#!iniedit -i \resource\vt100.idf
+# vt100.ini.noautodetect
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+console_size_detect false
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vt100/vtc_base.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,413 @@
+// vtc_base.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "vtc_base.h"
+#include <fshell/common.mmh>
+
+_LIT(KIniFileName, "\\system\\console\\vt100.ini");
+_LIT(KIniDesciptionFile, "\\resource\\vt100.idf");
+_LIT(KAttConsoleSizeDetect, "console_size_detect");
+
+_LIT(KNewLine, "\r\n");
+
+class TOverflowTruncate : public TDes16Overflow
+	{
+public:
+	virtual void Overflow(TDes16&) {}
+	};
+	
+EXPORT_C CVtcConsoleBase::CVtcConsoleBase()
+	{
+	//SetDebug(ETrue); // debug
+	}
+
+EXPORT_C CVtcConsoleBase::~CVtcConsoleBase()
+	{
+	delete iIniFile;
+	delete iInputController;
+	delete iOutputController;
+	delete iUnderlyingConsole; // In case of leave during construction, this might still be non-null
+	}
+
+EXPORT_C TInt CVtcConsoleBase::Create(const TDesC& aTitle, TSize /*aSize*/)
+	{
+	TRAPD(err, ConstructL(aTitle));
+	if (err)
+		{
+		TBuf<512> message;
+		message.Format(_L("Failed to create console (%d)."), err);
+			
+		if (iUnderlyingConsole && (LazyConsole::IsConstructed(iUnderlyingConsole) || !LazyConsole::IsLazy(iUnderlyingConsole)))
+		// if we have an underlyconsole, which is either not lazy or is lazy but already constructed, then print the error to it.
+			{
+			iUnderlyingConsole->Write(message);
+			iUnderlyingConsole->Write(KNewLine);
+			}
+		else
+		// else display a dialog
+			{
+			RNotifier notifier;
+			if (notifier.Connect() == KErrNone)
+				{
+				TInt buttonVal;
+				TRequestStatus notifierStatus;
+				notifier.Notify(_L("vt100"), message, _L("OK"), KNullDesC, buttonVal, notifierStatus);
+				User::WaitForRequest(notifierStatus);
+				notifier.Close();
+				}
+			}
+		}
+	Message(EDebug, _L("VT100 console create completed with err=%d"), err);
+	return err;
+	}
+
+EXPORT_C void CVtcConsoleBase::ConstructL(const TDesC&)
+	{
+	iIniFile = LtkUtils::CIniFile::NewL(KIniFileName, KIniDesciptionFile);
+
+	TSize screenSize(80, 24); // If sizeDetect is not specified, we default to (and only support) 80x24
+	if (iIniFile->GetBool(KAttConsoleSizeDetect))
+		{
+		DetectScreenSizeL(screenSize);
+		}
+	iOutputController = CVtConsoleOutputController::NewL(*this, *iIniFile, screenSize);
+	iInputController = CVtConsoleInputController::NewL(*this, *iIniFile);
+	ClearScreen();
+	delete iUnderlyingConsole;
+	iUnderlyingConsole = NULL;
+	}
+	
+EXPORT_C TInt CVtcConsoleBase::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	if (aExtensionId == ConsoleMode::KSetConsoleModeExtension)
+		{
+		ConsoleMode::TMode mode = (ConsoleMode::TMode)(TInt)a1;
+		iInputController->SetMode(mode);
+		iOutputController->SetMode(mode);
+		return KErrNone;
+		}
+	else if (aExtensionId == UnderlyingConsole::KSetUnderlyingConsoleExtension)
+		{
+		iUnderlyingConsole = (CConsoleBase*)a1;
+		return KErrNone;
+		}
+	else if (aExtensionId == ConsoleAttributes::KSetConsoleAttributesExtension)
+		{
+		ConsoleAttributes::TAttributes* attributes = (ConsoleAttributes::TAttributes*)a1;
+		return iOutputController->SetAttributes(attributes->iAttributes, attributes->iForegroundColor, attributes->iBackgroundColor);
+		}
+	else
+		{
+		return CConsoleBase::Extension_(aExtensionId, a0, a1);
+		}
+	}
+
+EXPORT_C void CVtcConsoleBase::Message(TVerbosity aVerbosity, TRefByValue<const TDesC> aFmt, ...)
+	{
+	if (Debug() || (aVerbosity == EInformation) || (aVerbosity == EError))
+		{
+		TOverflowTruncate overflow;
+		VA_LIST list;
+		VA_START(list, aFmt);
+		TBuf<0x100> buf;
+		buf.AppendFormatList(aFmt, list, &overflow);
+		
+		if (iUnderlyingConsole)
+			{
+			iUnderlyingConsole->Write(buf);
+			iUnderlyingConsole->Write(KNewLine);
+			}
+		else
+			{
+			User::InfoPrint(buf);
+			}
+		}
+	}
+	
+EXPORT_C TBool CVtcConsoleBase::Debug()
+	{
+	return iDebug;
+	}
+	
+EXPORT_C void CVtcConsoleBase::SetDebug(TBool aDebug)
+	{
+	iDebug = aDebug;
+	}
+		
+EXPORT_C void CVtcConsoleBase::Read(TRequestStatus& aStatus)
+	{
+	iInputController->GetKeyPress(iKeyPress, aStatus);
+	}
+
+EXPORT_C void CVtcConsoleBase::ReadCancel()
+	{
+	iInputController->CancelGetKeyPress();
+	}
+
+EXPORT_C void CVtcConsoleBase::Write(const TDesC& aDes)
+	{
+	iOutputController->Write(aDes);
+	}
+	
+EXPORT_C TPoint CVtcConsoleBase::CursorPos() const
+	{
+	TPoint pos;
+	iOutputController->GetCursorPos(pos);
+	return pos;
+	}
+
+EXPORT_C void CVtcConsoleBase::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	iOutputController->SetCursorPosAbs(aPoint);
+	}
+
+EXPORT_C void CVtcConsoleBase::SetCursorPosRel(const TPoint& aPoint)
+	{
+	iOutputController->SetCursorPosRel(aPoint);
+	}
+
+EXPORT_C void CVtcConsoleBase::SetCursorHeight(TInt aPercentage)
+	{
+	iOutputController->SetCursorHeight(aPercentage);
+	}
+
+EXPORT_C void CVtcConsoleBase::SetTitle(const TDesC& aDes)
+	{
+	iOutputController->SetTitle(aDes);
+	}
+
+EXPORT_C void CVtcConsoleBase::ClearScreen()
+	{
+	iOutputController->ClearScreen();
+	}
+
+EXPORT_C void CVtcConsoleBase::ClearToEndOfLine()
+	{
+	iOutputController->ClearToEndOfLine();
+	}
+
+EXPORT_C TSize CVtcConsoleBase::ScreenSize() const
+	{
+	TSize size;
+	iOutputController->GetScreenSize(size);
+	return size;
+	}
+
+EXPORT_C TKeyCode CVtcConsoleBase::KeyCode() const
+	{
+	return iKeyPress.iCode;
+	}
+
+EXPORT_C TUint CVtcConsoleBase::KeyModifiers() const
+	{
+	return iKeyPress.iModifiers;
+	}
+
+void CVtcConsoleBase::DetectScreenSizeL(TSize& aSize)
+	{
+	TInt err;
+	do
+		{
+		// If we get a KErrCorrupt error during the detect, we restart it from the top
+		// This is because KErrCorrupt is (hopefully) only ever returned as a result of the DSR in ReadCursorPos failing, in which case it is worth retrying.
+		// If it's any other error, the console is actually dead so we should bail
+		err = DoDetectScreenSize(aSize);
+		Message(EDebug, _L("DoDetectScreenSize returned %d"), err);
+		}
+#ifdef FSHELL_PLATFORM_OPP // Temporary OPP specific change - the drivers for the mid-sized prototype currently complete requests with KErrAbort just before power management sends the device to sleep.
+	while ((err == KErrCorrupt) || (err == KErrAbort));
+#else
+	while (err == KErrCorrupt);
+#endif
+	User::LeaveIfError(err);
+	}
+
+TInt CVtcConsoleBase::DoDetectScreenSize(TSize& aSize)
+	{
+	Message(EDebug, _L("Beginning VT100 console size detect"));
+	_LIT8(KSpace, " ");
+	_LIT8(KNewLine, "\r\n");
+	_LIT8(KResetCursorPosAbs, "\x1b[1;1H");
+	TInt err = Output(KResetCursorPosAbs);
+	if (err) return err;
+
+#ifdef FSHELL_VT100_WORK_AROUND_TERATERM_CURSOR_BUG
+	// Note, at the point where the cursor has just wrap to the next line, TeraTerm reports
+	// the same cursor position has just before is wrapped. When the cursor is moved to the
+	// right again, TeraTerm corrects its reckoning of the cursor position. The following
+	// code works around this bug by keeping track of the previous cursor position and noticing
+	// if it doesn't increment. This is treated as though the cursor had wrapped.
+
+	TInt previousCursorPosX = -1;
+	for (TInt x = 0; ; ++x)
+		{
+		err = Output(KSpace);
+		if (err) return err;
+		TPoint pos;
+		TInt err = ReadCursorPos(pos);
+		if (err) return err;
+		TInt cursorPosX = pos.iX;
+		if ((cursorPosX == 0) || (cursorPosX == previousCursorPosX))
+			{
+			aSize.iWidth = x + 1;
+			break;
+			}
+		previousCursorPosX = cursorPosX;
+		}
+#else
+	for (TInt x = 0; ; ++x)
+		{
+		err = Output(KSpace);
+		if (err) return err;
+		TPoint pos;
+		err = ReadCursorPos(pos);
+		if (err) return err;
+		if (pos.iX == 0)
+			{
+			aSize.iWidth = x + 1;
+			break;
+			}
+		}
+#endif
+	err = Output(KResetCursorPosAbs);
+	if (err) return err;
+	TInt prevYPos = 0;
+	for (TInt y = 0; ; ++y)
+		{
+		err = Output(KNewLine);
+		if (err) return err;
+		TPoint pos;
+		TInt err = ReadCursorPos(pos);
+		if (err) return err;
+		if (pos.iY == prevYPos)
+			{
+			aSize.iHeight = y;
+			break;
+			}
+		else
+			{
+			prevYPos = y;
+			}
+		}
+	err = Output(KResetCursorPosAbs);
+	Message(EDebug, _L("Completed VT100 console size detect = %dx%d"), aSize.iWidth, aSize.iHeight);
+	return err;
+	}
+
+TInt CVtcConsoleBase::ReadCursorPos(TPoint& aPosition)
+	{
+	// Ideally this functionality should be moved into the input and output controllers, but currently
+	// this is problematic because:
+	//
+	// 1) TeraTerm contains bugs in the way it reports cursor position that need to be worked around.
+	//    See FSHELL_VT100_WORK_AROUND_TERATERM_CURSOR_BUG.
+	//
+	// 2) The CVtConsoleInputController state machine would need some fairly heavy changes to be able
+	//    to cope with ANSI Device Status Report escape sequences.
+	//
+	// 3) The fact that CVtConsoleInputController and CVtConsoleOutputController run in the same thread
+	//    means that implementing CVtcConsoleBase::CursorPos (which is synchronous) would be tricky.
+	//    Possible solutions are a) using CActiveSchedulerWait (which is almost always a bad idea) and
+	//    b) putting CVtConsoleInputController in a separate thread (which would be a fair bit of work,
+	//       and we've been there before...).
+	//
+	// For the time being then, vt100.dll has its own console size detection code (a duplication of
+	// the version in iosrv) and uses this function only during construction to initialize the size of
+	// the output controller's cursor tracker. From that point on, the cursor position is always retrieved
+	// via the cursor tracker (the horrible thing that it is).
+
+	// Note, this function can only safely be used before the input and output controllers are created
+	// because in uses the MConsoleInput and MConsoleOutput interfaces directly.
+	ASSERT((iOutputController == NULL) && (iInputController == NULL));
+
+	_LIT8(KDeviceStatusReport, "\x1b[6n");
+	//Message(EDebug, _L("Sending VT100 DSR"));
+	TInt err = Output(KDeviceStatusReport);
+	if (err < 0)
+		{
+		Message(EDebug, _L("Error %d sending DSR"), err);
+		return err;
+		}
+	
+	TPoint pos;
+	TBuf8<32> buf;
+	TPtr8 ptr(const_cast<TUint8*>(buf.Ptr()), 0, buf.MaxLength());
+	FOREVER
+		{
+		TRequestStatus status;
+		//Message(EDebug, _L("Waiting for input"));
+		Input(ptr, status);
+		User::WaitForRequest(status);
+		err = status.Int();
+		if (err < 0)
+			{
+			Message(EDebug, _L("Error getting input %d"), err);
+			return err;
+			}
+
+		buf.SetLength(buf.Length() + ptr.Length());
+		ptr.Set(const_cast<TUint8*>(buf.Ptr()) + buf.Length(), 0, buf.MaxLength() - buf.Length());
+		if (ptr.MaxLength() == 0) return KErrOverflow; // Not sure how this could happen, maybe if the terminal returned really really long but otherwise valid numbers for the x and y pos
+
+		// The sequence we're looking for is \x1b[nnn;nnnR
+		TLex8 lex(buf);
+		if (lex.Eos()) continue;
+		if (lex.Get() != 0x1b) return KErrCorrupt;
+		if (lex.Eos()) continue;
+		if (lex.Get() != '[') return KErrCorrupt;
+		if (lex.Eos()) continue;
+		err = lex.Val(pos.iY);
+		if (err) return err;
+		if (lex.Eos()) continue;
+		if (lex.Get() != ';') return KErrCorrupt;
+		if (lex.Eos()) continue;
+		err = lex.Val(pos.iX);
+		if (err) return err;
+		if (lex.Eos()) continue;
+		if (lex.Get() != 'R') return KErrCorrupt;
+		// If we reach here, we've successfully read the whole sequence
+
+		// I assume we subtract one here because the VT100 indexes are 1-based and we use zero-based? -TomS
+		pos.iX--;
+		pos.iY--;
+		aPosition = pos;
+		return KErrNone;
+		}
+	}
+
+EXPORT_C TInt CVtcConsoleBase::ReadKeywordValuePair(TLex& aLex, TPtrC& aKeyword, TPtrC& aValue)
+	{
+	TLexMark mark;
+	aLex.SkipSpaceAndMark(mark);
+	while (!aLex.Eos() && !aLex.Peek().IsSpace() && (aLex.Peek() != '='))
+		{
+		aLex.Get();
+		}
+	aKeyword.Set(aLex.MarkedToken(mark));
+	aLex.SkipSpace();
+	if (aLex.Get() != '=')
+		{
+		return KErrArgument;
+		}
+	aLex.SkipSpaceAndMark(mark);
+	while (!aLex.Eos() && (aLex.Peek() != ','))
+		{
+		aLex.Get();
+		}
+	aValue.Set(aLex.MarkedToken(mark));
+	if (aLex.Peek() == ',')
+		{
+		aLex.Get();
+		}
+	return KErrNone;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vt100/vtc_controller.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,883 @@
+// vtc_controller.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32base.h>
+#include <fshell/common.mmh>
+#include "vtc_controller.h"
+#include "vtc_cursor_tracker.h"
+
+
+//
+// Constants.
+//
+
+_LIT(KAttSupportAttributes, "support_attributes");
+_LIT(KAttForegroundColor, "foreground_color");
+_LIT(KAttBackgroundColor, "background_color");
+
+class TEscapeMapping
+	{
+public:
+	TUint8 iEscapeChar;
+	TKeyCode iKeyCode;
+	};
+
+class TLongerEscapeMapping
+	{
+public:
+	TUint8 iEscapeChar1;
+	TUint8 iEscapeChar2;
+	TKeyCode iKeyCode;
+	};
+
+
+const TEscapeMapping KEscapeMappings[] = 
+	{
+		{ 'A', EKeyUpArrow },
+		{ 'B', EKeyDownArrow },
+		{ 'C', EKeyRightArrow },
+		{ 'D', EKeyLeftArrow },
+		{ 'H', EKeyHome },
+		{ 'K', EKeyEnd },
+	};
+const TInt KNumEscapeMappings(sizeof(KEscapeMappings) / sizeof(TEscapeMapping));
+
+const TEscapeMapping KFunctionKeyMappings[] =
+	{
+		{ 'P', EKeyF1 },
+		{ 'Q', EKeyF2 },
+		{ 'R', EKeyF3 },
+		{ 'S', EKeyF4 },
+	};
+const TInt KNumEscapeFunctionMappings(sizeof(KFunctionKeyMappings) / sizeof(TEscapeMapping));
+
+// The following are for VT220 support, which is needed to get function keys understood from teraterm. They use ESC [xx~ where xx is given by the below table
+// See http://aperiodic.net/phil/archives/Geekery/term-function-keys.html for the reference I used
+const TLongerEscapeMapping KExtendedEscapeMappings[] = 
+	{
+		{ '1', '1', EKeyF1 },
+		{ '1', '2', EKeyF2 },
+		{ '1', '3', EKeyF3 },
+		{ '1', '4', EKeyF4 },
+		{ '1', '5', EKeyF5 },
+		// '1' '6' isn't used
+		{ '1', '7', EKeyF6 },
+		{ '1', '8', EKeyF7 },
+		{ '1', '9', EKeyF8 },
+		{ '2', '0', EKeyF9 },
+		{ '2', '1', EKeyF10 },
+		// '2' '2' isn't used
+		{ '2', '3', EKeyF11 },
+		{ '2', '4', EKeyF12 },
+
+		// ESC [1~ is Home key according to http://www.zaik.uni-koeln.de/~ftp/elfi/etc/telnet.key
+		{ '1', 0, EKeyHome },
+		{ '4', 0, EKeyEnd },
+		{ '5', 0, EKeyPageUp },
+		{ '6', 0, EKeyPageDown },
+		{ '2', 0, EKeyInsert },
+		{ '3', 0, EKeyDelete },
+	};
+const TInt KNumExtendedEscapeMappings = sizeof(KExtendedEscapeMappings) / sizeof(TLongerEscapeMapping);
+
+static const TUint8 KEscapeChar1 = 0x1b;
+static const TUint8 KEscapeChar2 = '[';
+static const TUint8 KEscapeChar2Func = 'O';
+
+static const TInt KEscapeTimeoutMicros = 200000; // 1/5th second
+
+
+//______________________________________________________________________________
+//						TKeyPress
+EXPORT_C TKeyPress::TKeyPress()
+	: iCode(EKeyNull), iModifiers(0)
+	{
+	}
+
+EXPORT_C TKeyPress::TKeyPress(TKeyCode aCode, TUint aModifiers)
+	: iCode(aCode), iModifiers(aModifiers)
+	{
+	}
+
+//______________________________________________________________________________
+//						CVtConsoleOutputController
+EXPORT_C CVtConsoleOutputController* CVtConsoleOutputController::NewL(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile, const TSize& aScreenSize)
+	{
+	CVtConsoleOutputController* self = new(ELeave)CVtConsoleOutputController(aOutput, aIniFile);
+	CleanupStack::PushL(self);
+	User::LeaveIfError(self->Construct(aScreenSize));
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+EXPORT_C CVtConsoleOutputController* CVtConsoleOutputController::New(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile, const TSize& aScreenSize)
+	{
+	CVtConsoleOutputController* self = new CVtConsoleOutputController(aOutput, aIniFile);
+	TInt err = self->Construct(aScreenSize);
+	if (err!=KErrNone)
+		{
+		delete self;
+		self = NULL;
+		}
+	return self;
+	}
+
+class TAttributeBuf : public TBuf8<64>
+	{
+public:
+	enum TColorType
+		{
+		EForeground,
+		EBackground
+		};
+public:
+	TAttributeBuf(LtkUtils::CIniFile& aIniFile);
+	void Add(TUint aAttributes);
+	void Add(ConsoleAttributes::TColor aColor, TColorType aType);
+	void Finalize();
+	TBool SomethingAdded() const;
+private:
+	void Add(const TDesC8& aAttribute);
+private:
+	LtkUtils::CIniFile& iIniFile;
+	TBool iSomethingAdded;
+	};
+
+_LIT8(KPrefix, "\x1b[");
+TAttributeBuf::TAttributeBuf(LtkUtils::CIniFile& aIniFile)
+	: TBuf8<64>(KPrefix), iIniFile(aIniFile), iSomethingAdded(EFalse)
+	{
+	}
+
+void TAttributeBuf::Add(const TDesC8& aAttribute)
+	{
+	if (iSomethingAdded)
+		{
+		Append(';');
+		}
+	Append(aAttribute);
+	iSomethingAdded = ETrue;
+	}
+
+void TAttributeBuf::Finalize()
+	{
+	ASSERT(iSomethingAdded);
+	Append('m');
+	}
+
+TBool TAttributeBuf::SomethingAdded() const
+	{
+	return iSomethingAdded;
+	}
+
+void TAttributeBuf::Add(TUint aAttributes)
+	{
+	_LIT8(KAttReset,		"0");
+	_LIT8(KAttBold,			"1");
+	_LIT8(KAttUnderscore,	"4");
+	_LIT8(KAttBlink,		"5");
+	_LIT8(KAttInverse,		"7");
+	_LIT8(KAttConceal,		"8");
+
+	if (aAttributes & ConsoleAttributes::ENone)
+		{
+		Add(KAttReset);
+		Add((ConsoleAttributes::TColor)iIniFile.GetInt(KAttForegroundColor), TAttributeBuf::EForeground);
+		Add((ConsoleAttributes::TColor)iIniFile.GetInt(KAttBackgroundColor), TAttributeBuf::EBackground);
+		}
+	if (aAttributes & ConsoleAttributes::EBold)
+		{
+		Add(KAttBold);
+		}
+	if (aAttributes & ConsoleAttributes::EUnderscore)
+		{
+		Add(KAttUnderscore);
+		}
+	if (aAttributes & ConsoleAttributes::EBlink)
+		{
+		Add(KAttBlink);
+		}
+	if (aAttributes & ConsoleAttributes::EInverse)
+		{
+		Add(KAttInverse);
+		}
+	if (aAttributes & ConsoleAttributes::EConceal)
+		{
+		Add(KAttConceal);
+		}
+	}
+
+void TAttributeBuf::Add(ConsoleAttributes::TColor aColor, TColorType aType)
+	{
+	_LIT8(KFgBlack,			"30");
+	_LIT8(KFgRed,			"31");
+	_LIT8(KFgGreen,			"32");
+	_LIT8(KFgYellow,		"33");
+	_LIT8(KFgBlue,			"34");
+	_LIT8(KFgMagenta,		"35");
+	_LIT8(KFgCyan,			"36");
+	_LIT8(KFgWhite,			"37");
+	_LIT8(KFgReset,			"39");
+	_LIT8(KBgBlack,			"40");
+	_LIT8(KBgRed,			"41");
+	_LIT8(KBgGreen,			"42");
+	_LIT8(KBgYellow,		"43");
+	_LIT8(KBgBlue,			"44");
+	_LIT8(KBgMagenta,		"45");
+	_LIT8(KBgCyan,			"46");
+	_LIT8(KBgWhite,			"47");
+	_LIT8(KBgReset,			"49");
+
+	if (aType == EForeground)
+		{
+		switch (aColor)
+			{
+			default:
+			case ConsoleAttributes::EUnchanged:
+				{
+				// Do nothing.
+				break;
+				}
+			case ConsoleAttributes::EBlack:
+				{
+				Add(KFgBlack);
+				break;
+				}
+			case ConsoleAttributes::ERed:
+				{
+				Add(KFgRed);
+				break;
+				}
+			case ConsoleAttributes::EGreen:
+				{
+				Add(KFgGreen);
+				break;
+				}
+			case ConsoleAttributes::EYellow:
+				{
+				Add(KFgYellow);
+				break;
+				}
+			case ConsoleAttributes::EBlue:
+				{
+				Add(KFgBlue);
+				break;
+				}
+			case ConsoleAttributes::EMagenta:
+				{
+				Add(KFgMagenta);
+				break;
+				}
+			case ConsoleAttributes::ECyan:
+				{
+				Add(KFgCyan);
+				break;
+				}
+			case ConsoleAttributes::EWhite:
+				{
+				Add(KFgWhite);
+				break;
+				}
+			case ConsoleAttributes::EReset:
+				{
+				Add(KFgReset);
+				break;
+				}
+			}
+		}
+	else
+		{
+		switch (aColor)
+			{
+			default:
+			case ConsoleAttributes::EUnchanged:
+				{
+				// Do nothing.
+				break;
+				}
+			case ConsoleAttributes::EBlack:
+				{
+				Add(KBgBlack);
+				break;
+				}
+			case ConsoleAttributes::ERed:
+				{
+				Add(KBgRed);
+				break;
+				}
+			case ConsoleAttributes::EGreen:
+				{
+				Add(KBgGreen);
+				break;
+				}
+			case ConsoleAttributes::EYellow:
+				{
+				Add(KBgYellow);
+				break;
+				}
+			case ConsoleAttributes::EBlue:
+				{
+				Add(KBgBlue);
+				break;
+				}
+			case ConsoleAttributes::EMagenta:
+				{
+				Add(KBgMagenta);
+				break;
+				}
+			case ConsoleAttributes::ECyan:
+				{
+				Add(KBgCyan);
+				break;
+				}
+			case ConsoleAttributes::EWhite:
+				{
+				Add(KBgWhite);
+				break;
+				}
+			case ConsoleAttributes::EReset:
+				{
+				Add(KBgReset);
+				break;
+				}
+			}
+		}
+	}
+
+EXPORT_C TInt CVtConsoleOutputController::ResetAttributes()
+	{
+	if (iIniFile.GetBool(KAttSupportAttributes))
+		{
+		TAttributeBuf buf(iIniFile);
+		buf.Add(ConsoleAttributes::ENone);
+		buf.Finalize();
+		return iOutput.Output(buf);
+		}
+
+	return KErrNone;
+	}
+
+EXPORT_C TInt CVtConsoleOutputController::SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor)
+	{
+	if (iIniFile.GetBool(KAttSupportAttributes))
+		{
+		TAttributeBuf buf(iIniFile);
+		buf.Add(aAttributes);
+		buf.Add(aForegroundColor, TAttributeBuf::EForeground);
+		buf.Add(aBackgroundColor, TAttributeBuf::EBackground);
+
+		if (buf.SomethingAdded())
+			{
+			buf.Finalize();
+			return iOutput.Output(buf);
+			}
+
+		return KErrNone;
+		}
+
+	return KErrNotSupported;
+	}
+	
+CVtConsoleOutputController::CVtConsoleOutputController(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile)
+	: iOutput(aOutput), iIniFile(aIniFile), iMode(ConsoleMode::EText)
+	{
+	}
+
+TInt CVtConsoleOutputController::Construct(const TSize& aScreenSize)
+	{
+	iCursorTracker = new TCursorTracker(aScreenSize);
+	if (!iCursorTracker) return KErrNoMemory;
+	return KErrNone;
+	}
+
+EXPORT_C CVtConsoleOutputController::~CVtConsoleOutputController()
+	{
+	delete iCursorTracker;
+	iOutputBuf.Close();
+	}
+
+TInt CVtConsoleOutputController::GetCursorPos(TPoint& aPos) const
+	{
+	aPos = iCursorTracker->CursorPos();
+	return KErrNone;
+	}
+
+
+TInt CVtConsoleOutputController::SetCursorPosAbs(const TPoint& aPos)
+	{
+	TInt err = KErrInUse;
+	if (iMode == ConsoleMode::EText)
+		{
+		_LIT8(KEscapeSetCursorPosAbs, "\x1b[%u;%uH");
+		TBuf8<32> buf;
+		buf.Format(KEscapeSetCursorPosAbs, aPos.iY + 1, aPos.iX + 1);
+		err = iOutput.Output(buf);
+		if (err == KErrNone)
+			{
+			iCursorTracker->SetCursorPosAbs(aPos);
+			}
+		}
+	return err;
+	}
+
+TInt CVtConsoleOutputController::SetCursorPosRel(const TPoint& aPoint)
+	{
+	TInt err = KErrInUse;
+	if (iMode == ConsoleMode::EText)
+		{
+		TBuf8<32> buf;
+
+		if (aPoint.iY == 0)
+			{
+			// Do nothing.
+			}
+		else if (aPoint.iY < 0)
+			{
+			// Move cursor up.
+			_LIT8(KEscapeCursorUp, "\x1b[%uA");
+			buf.AppendFormat(KEscapeCursorUp, -aPoint.iY);
+			}
+		else if (aPoint.iY > 0)
+			{
+			// Move cursor down.
+			_LIT8(KEscapeCursorDown, "\x1b[%uB");
+			buf.AppendFormat(KEscapeCursorDown, aPoint.iY);
+			}
+
+		if (aPoint.iX == 0)
+			{
+			// Do nothing.
+			}
+		else if (aPoint.iX < 0)
+			{
+			// Move cursor left.
+			_LIT8(KEscapeCursorLeft, "\x1b[%uD");
+			buf.AppendFormat(KEscapeCursorLeft, -aPoint.iY);
+			}
+		else if (aPoint.iX > 0)
+			{
+			// Move cursor right.
+			_LIT8(KEscapeCursorRight, "\x1b[%uC");
+			buf.AppendFormat(KEscapeCursorRight, aPoint.iY);
+			}
+		
+		err = KErrNone;
+		if (buf.Length() > 0)
+			{
+			err = iOutput.Output(buf);
+			if (err == KErrNone)
+				{
+				iCursorTracker->SetCursorPosRel(aPoint);
+				}
+			}
+		}
+	return err;
+	}
+
+TInt CVtConsoleOutputController::SetCursorHeight(TInt aPercentage)
+	{
+	TInt err = KErrInUse;
+	if (iMode == ConsoleMode::EText)
+		{
+		_LIT8(KEscapeHideCursor, "\x1b[?25l");
+		_LIT8(KEscapeSeeCursor, "\x1b[?25h");
+		if (aPercentage == 0)
+			{
+			err = iOutput.Output(KEscapeHideCursor);
+			}
+		else
+			{
+			err = iOutput.Output(KEscapeSeeCursor);
+			}
+		}
+	return err;
+	}
+
+TInt CVtConsoleOutputController::SetTitle(const TDesC&)
+	{
+	return KErrNone;
+	}
+
+TInt CVtConsoleOutputController::ClearScreen()
+	{
+	TInt err = KErrInUse;
+	if (iMode == ConsoleMode::EText)
+		{
+		_LIT8(KResetTerminal, "\x1b" "c" "\x1b" "[?7h"); // reset console, then enable line wrapping
+		err = iOutput.Output(KResetTerminal);
+		if (err == KErrNone)
+			{
+			User::After(100000); // It seems that TeraTerm doesn't like receiving attribute changes too soon after a terminal reset (tends to ignore the attributes).
+			err = ResetAttributes();
+			if (err == KErrNone)
+				{
+				_LIT8(KEscapeClearScreen, "\x1b[2J\x1b[01;01H");
+				err = iOutput.Output(KEscapeClearScreen);
+				if (err == KErrNone)
+					{
+					iCursorTracker->Reset();
+					}
+				}
+			}
+		}
+	return err;
+	}
+
+TInt CVtConsoleOutputController::ClearToEndOfLine()
+	{
+	TInt err = KErrInUse;
+	if (iMode == ConsoleMode::EText)
+		{
+		_LIT8(KEscapeClearToEndOfLine, "\x1b[K");
+		err = iOutput.Output(KEscapeClearToEndOfLine);
+		}
+	return err;
+	}
+
+TInt CVtConsoleOutputController::GetScreenSize(TSize& aSize) const
+	{
+	aSize = iCursorTracker->ConsoleSize();
+	return KErrNone;
+	}
+
+TInt CVtConsoleOutputController::Write(const TDesC& aDes)
+	{
+	TInt err = KErrNone;
+	if (iMode == ConsoleMode::EBinary)
+		{
+		// staight collapse to 8 bit, no cleverness
+		TBuf8<256> buf;
+		TInt offset = 0;
+		while ((offset < aDes.Length()) && (err == KErrNone))
+			{
+			buf.Copy(aDes.Mid(offset, Min(aDes.Length() - offset, buf.MaxLength())));
+			offset += buf.Length();
+			err = iOutput.Output(buf);
+			}
+		}
+	else
+		{
+		// In text mode we do a UTF-16 -> UTF-8 conversion
+		TRAP(err, iOutputBuf.CopyAsUtf8L(aDes));
+		if (err == KErrNone)
+			{
+			err = iOutput.Output(iOutputBuf);
+			if (err == KErrNone)
+				{
+				iCursorTracker->Write(aDes);
+				}
+			}
+		}
+	return err;
+	}
+	
+TInt CVtConsoleOutputController::Write(const TDesC8& aDes)
+	{
+	TInt err = iOutput.Output(aDes);
+	if ((err == KErrNone) && (iMode == ConsoleMode::EText))
+		{
+		iCursorTracker->Write(aDes);
+		}
+	return err;
+	}
+
+void CVtConsoleOutputController::SetMode(ConsoleMode::TMode aMode)
+	{
+	iMode = aMode;
+	}
+
+//______________________________________________________________________________
+//						CVtConsoleInputController
+
+EXPORT_C CVtConsoleInputController* CVtConsoleInputController::New(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile)
+	{
+	CVtConsoleInputController* self = NULL;
+	TRAPD(err, self = NewL(aConsoleInput, aIniFile));
+	if (err == KErrNone)
+		{
+		return self;
+		}
+	return NULL;
+	}
+
+EXPORT_C  CVtConsoleInputController* CVtConsoleInputController::NewL(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile)
+	{
+	CVtConsoleInputController* self = NewLC(aConsoleInput, aIniFile);
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+EXPORT_C  CVtConsoleInputController* CVtConsoleInputController::NewLC(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile)
+	{
+	CVtConsoleInputController* self = new(ELeave)CVtConsoleInputController(aConsoleInput, aIniFile);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CVtConsoleInputController::CVtConsoleInputController(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile)
+	: CActive(CActive::EPriorityStandard), iConsoleInput(aConsoleInput), iIniFile(aIniFile), iMode(ConsoleMode::EText)
+	{
+	CActiveScheduler::Add(this);
+	}
+	
+void CVtConsoleInputController::ConstructL()
+	{
+	iEscapeTimer = CPeriodic::NewL(CActive::EPriorityLow);
+	}
+	
+CVtConsoleInputController::~CVtConsoleInputController()
+	{
+	Reset();
+	delete iEscapeTimer;
+	}
+
+EXPORT_C void CVtConsoleInputController::GetKeyPress(TKeyPress& aKeyPress, TRequestStatus& aStatus)
+	{
+	ASSERT((iClientKeyPress == NULL) && (iClientRequestStatus == NULL));
+	iClientKeyPress = &aKeyPress;
+	iClientRequestStatus = &aStatus;
+	*iClientRequestStatus = KRequestPending;
+	if (iKeyCodePending)
+		{
+		iKeyCodePending = EFalse;
+		CompleteKeyPressRequest(iPendingKeyCode);
+		}
+	else if (iInputError)
+		{
+		CompleteKeyPressRequest(iInputError);
+		iInputError = KErrNone;
+		}
+	else
+		{
+		ReadKeyPress();
+		}
+	}
+
+EXPORT_C void CVtConsoleInputController::CancelGetKeyPress()
+	{
+	Cancel();
+	if (iClientRequestStatus)
+		{
+		CompleteKeyPressRequest(KErrCancel);
+		}
+	}
+
+EXPORT_C void CVtConsoleInputController::SetMode(ConsoleMode::TMode aMode)
+	{
+	Reset();
+	iMode = aMode;
+	}
+
+void CVtConsoleInputController::ReadKeyPress()
+	{
+	iEscapeTimer->Cancel();
+
+	while (iClientRequestStatus && (iBufPos < iBuf.Length()))
+		{
+		TUint8 c = iBuf[iBufPos++];
+		if (iMode == ConsoleMode::EBinary)
+			{
+			CompleteKeyPressRequest((TKeyCode)c);
+			}
+		else
+			{
+			switch (iState)
+				{
+			case ENormal:
+				if (c == KEscapeChar1)
+					{
+					iState = EWaitingForEscapeChar2;
+					if (iBufPos == iBuf.Length())
+						{
+						iEscapeTimer->Start(KEscapeTimeoutMicros, KEscapeTimeoutMicros, TCallBack(EscapeTimeoutS, this));
+						}
+					}
+				else
+					{
+					CompleteKeyPressRequest((TKeyCode)c);
+					}
+				break;
+			case EWaitingForEscapeChar2:
+				if (c == KEscapeChar2)
+					{
+					iState = EWaitingForEscapeChar3;
+					}
+				else if (c == KEscapeChar2Func)
+					{
+					iState = EWaitingForEscapeChar3Func;
+					}
+				else
+					{
+					CompleteKeyPressRequest(EKeyEscape, (TKeyCode)c);
+					iState = ENormal;
+					}
+				break;
+			case EWaitingForEscapeChar3:
+				if (c >= '0' && c <= '9')
+					{
+					iState = EWaitingForExtendedFunc;
+					iExtendedEscapeBuf.Zero();
+					iExtendedEscapeBuf.Append(c);
+					}
+				else
+					{
+					DoEscapeKeyL(c, KEscapeMappings, KNumEscapeMappings);
+					}
+				break;
+			case EWaitingForEscapeChar3Func:
+				DoEscapeKeyL(c, KFunctionKeyMappings, KNumEscapeFunctionMappings);
+				break;
+			case EWaitingForExtendedFunc:
+				if (iExtendedEscapeBuf.Length() < iExtendedEscapeBuf.MaxLength() && ((c >= '0' && c <= '9') || c == ';'))
+					{
+					iExtendedEscapeBuf.Append(c);
+					// Stay in this state until you see a '~'
+					}
+				else if (c == '~')
+					{
+					DoExtendedEscapeKey();
+					}
+				else
+					{
+					// Gone off the rails, bail
+					iState = ENormal;
+					CompleteKeyPressRequest((TKeyCode)c);
+					}
+				break;
+				}
+			}
+		}
+
+	ReadInput();
+	}
+
+void CVtConsoleInputController::CompleteKeyPressRequest(TInt aError)
+	{
+	ASSERT(iClientKeyPress && iClientRequestStatus);
+	iClientKeyPress = NULL;
+	User::RequestComplete(iClientRequestStatus, aError);
+	}
+
+void CVtConsoleInputController::CompleteKeyPressRequest(TKeyCode aKeyCode)
+	{
+	ASSERT(iClientKeyPress && iClientRequestStatus);
+	iClientKeyPress->iCode = (TKeyCode)aKeyCode;
+	iClientKeyPress->iModifiers = 0;
+	iClientKeyPress = NULL;
+	User::RequestComplete(iClientRequestStatus, KErrNone);
+	}
+
+void CVtConsoleInputController::CompleteKeyPressRequest(TKeyCode aKeyCode1, TKeyCode aKeyCode2)
+	{
+	ASSERT(!iKeyCodePending);
+	// Store the second key-code in a member variable to be used the next time GetKeyPress is called.
+	iKeyCodePending = ETrue;
+	iPendingKeyCode = aKeyCode2;
+	CompleteKeyPressRequest(aKeyCode1);
+	}
+
+void CVtConsoleInputController::Reset()
+	{
+	Cancel();
+	iEscapeTimer->Cancel();
+	iState = ENormal;
+	iKeyCodePending = EFalse;
+	}
+
+void CVtConsoleInputController::ReadInput()
+	{
+	if (iClientRequestStatus && !IsActive()) // Note, if the escape timer expired we could already be active.
+		{
+		ASSERT(iBufPos == iBuf.Length());
+		iBufPos = 0;
+		iBuf.Zero();
+		iConsoleInput.Input(iBuf, iStatus);
+		SetActive();
+		}
+	}
+
+void CVtConsoleInputController::RunL()
+	{
+	TInt err = iStatus.Int();
+#ifdef FSHELL_PLATFORM_OPP
+	if (err == KErrAbort)
+		{
+		ReadInput();
+		return;
+		}
+#endif
+	if (err == KErrNone)
+		{
+		ReadKeyPress();
+		}
+	else if (iClientRequestStatus)
+		{
+		CompleteKeyPressRequest(err);
+		}
+	else
+		{
+		// Report the error next time the client requests a key.
+		iInputError = err;
+		}
+	}
+
+void CVtConsoleInputController::DoCancel()
+	{
+	iConsoleInput.CancelInput(iStatus);
+	}
+
+void CVtConsoleInputController::DoEscapeKeyL(TUint8 aChar, const TEscapeMapping* aMappings, TInt aMappingCount)
+	{
+	iState = ENormal;
+	for (TInt j = 0; j < aMappingCount; ++j)
+		{
+		if (aChar == aMappings[j].iEscapeChar)
+			{
+			CompleteKeyPressRequest(aMappings[j].iKeyCode);
+			return;
+			}
+		}
+	}
+	
+TInt CVtConsoleInputController::EscapeTimeout()
+	{
+	ASSERT(iState == EWaitingForEscapeChar2);
+	iState = ENormal;
+	CompleteKeyPressRequest(EKeyEscape);
+	return KErrNone;
+	}
+
+TInt CVtConsoleInputController::EscapeTimeoutS(TAny* aSelf)
+	{
+	return ((CVtConsoleInputController*)aSelf)->EscapeTimeout();
+	}
+
+	
+void CVtConsoleInputController::DoExtendedEscapeKey()
+	{
+	iState = ENormal;
+	TUint8 escape1 = 0;
+	TUint8 escape2 = 0;
+	if (iExtendedEscapeBuf.Length()) escape1 = iExtendedEscapeBuf[0];
+	if (iExtendedEscapeBuf.Length() > 1) escape2 = iExtendedEscapeBuf[1];
+
+	for (TInt j = 0; j < KNumExtendedEscapeMappings; ++j)
+		{
+		const TLongerEscapeMapping& mapping = KExtendedEscapeMappings[j];
+		if (escape1 == mapping.iEscapeChar1 && escape2 == mapping.iEscapeChar2)
+			{
+			CompleteKeyPressRequest(mapping.iKeyCode);
+			return;
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vt100/vtc_cursor_tracker.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,157 @@
+// vtc_cursor_tracker.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "vtc_cursor_tracker.h"
+
+
+//
+// Constants.
+//
+
+const TInt KTabSize = 8;
+
+
+//
+// TCursorTracker.
+//
+
+TCursorTracker::TCursorTracker(TSize aConsoleSize)
+	: iConsoleSize(aConsoleSize), iCursorPos(TPoint(0, 0))
+	{
+	}
+
+void TCursorTracker::Write(const TDesC &aDes)
+	{
+	const TInt desLength = aDes.Length();
+	for (TInt i = 0; i < desLength; ++i)
+		{
+		WriteChar(aDes[i]);
+		}
+	}
+	
+void TCursorTracker::Write(const TDesC8& aDes)
+	{
+	const TInt desLength = aDes.Length();
+	for (TInt i = 0; i < desLength; ++i)
+		{
+		WriteChar(aDes[i]);
+		}	
+	}
+	
+void TCursorTracker::WriteChar(TChar aChar)
+	{
+	switch(aChar)
+		{
+		case 0x00:	// Null.
+			break;
+		case 0x07:	// Bell.
+			break;
+		case 0x08:	// Backspace.
+		case 0x7f:	// Delete.
+			CursorLeft();
+			break;
+		case 0x09:	// Tab.
+			SetCursorPosRel(TPoint(KTabSize - (iCursorPos.iX % KTabSize), 0));
+			break;
+		case 0x0b:	// Vertical tab.
+			// Can't easily handle this - fall through.
+		case 0x0c:  // Form feed.
+			Reset();
+			break;
+		case 0x0a:
+			LineFeed();
+			break;
+		case 0x0d:
+			CarriageReturn();
+			break;
+		default:
+			CursorRight();
+		}
+	}
+
+void TCursorTracker::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	iCursorPos = aPoint;
+	}
+
+void TCursorTracker::SetCursorPosRel(const TPoint& aPoint)
+	{
+	iCursorPos += aPoint;
+	}
+
+void TCursorTracker::Reset()
+	{
+	iCursorPos.iX = iCursorPos.iY = 0;
+	}
+
+TPoint TCursorTracker::CursorPos() const
+	{
+	return iCursorPos;
+	}
+
+TSize TCursorTracker::ConsoleSize() const
+	{
+	return iConsoleSize;
+	}
+
+void TCursorTracker::CursorLeft()
+	{
+	if (iCursorPos.iX > 0)
+		{
+		// Not yet reached beginning of line.
+		--iCursorPos.iX;
+		}
+	else if (iCursorPos.iY > 0)
+		{
+		// Reached beginning of line, so jump to end of line above.
+		iCursorPos.iX = (iConsoleSize.iWidth - 1);
+		--iCursorPos.iY;
+		}
+	}
+
+void TCursorTracker::CursorRight()
+	{
+	if (iCursorPos.iX < (iConsoleSize.iWidth - 1))
+		{
+		// Not yet reached the end of the line.
+		++iCursorPos.iX;
+		}
+	else if (iCursorPos.iY < (iConsoleSize.iHeight - 1))
+		{
+		// Reached the end of the line and there's space below - jump to the beginning of the line below.
+		iCursorPos.iX = 0;
+		++iCursorPos.iY;
+		}
+	else
+		{
+		// Reached the end of the line and there's no space below - console will scroll up a line and jump to the beginning of the newly exposed line.
+		iCursorPos.iX = 0;
+		}
+	}
+
+void TCursorTracker::LineFeed()
+	{
+	if (iCursorPos.iY < (iConsoleSize.iHeight - 1))
+		{
+		iCursorPos.iX = 0;
+		++iCursorPos.iY;
+		}
+	else
+		{
+		iCursorPos.iX = 0;
+		}
+	}
+
+void TCursorTracker::CarriageReturn()
+	{
+	iCursorPos.iX = 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vt100/vtc_cursor_tracker.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,49 @@
+// vtc_cursor_tracker.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef VTC_CURSOR_TRACKER_H
+#define VTC_CURSOR_TRACKER_H
+
+#include <e32std.h>
+
+
+/**
+ * This class is responsible for tracking the cursor position within the console
+ * window based on the data that is written to it. The cursor position is tracked
+ * in this way, rather than explicitly enquiring the cursor position from the
+ * VT100 terminal (using "\x1b[6n") because is seems different VT100 emulators
+ * respond to this escape sequence in different and unpredictable ways.
+ */
+class TCursorTracker
+	{
+public:
+	TCursorTracker(TSize aConsoleSize);
+	void Write(const TDesC& aDes);
+	void Write(const TDesC8& aDes);
+	void SetCursorPosAbs(const TPoint& aPoint);
+	void SetCursorPosRel(const TPoint& aPoint);
+	void Reset();
+	TPoint CursorPos() const;
+	TSize ConsoleSize() const;
+private:
+	void CursorLeft();
+	void CursorRight();
+	void LineFeed();
+	void CarriageReturn();
+	void WriteChar(TChar aChar);
+private:
+	const TSize iConsoleSize;
+	TPoint iCursorPos;
+	};
+
+
+#endif // VTC_CURSOR_TRACKER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vtc_busdevcons.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,212 @@
+// vtc_busdevcons.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <d32comm.h>
+#include <fshell/vtc_base.h>
+#include <fshell/common.mmh>
+
+class TPortConfig
+	{
+public:
+	TPortConfig();
+
+	TPtrC iPdd;
+	TPtrC iLdd;
+	TInt iPort;
+	TBps iRate;
+	};
+
+
+NONSHARABLE_CLASS(CVtcBusDevCommConsole) : public CVtcConsoleBase
+	{
+public:
+	CVtcBusDevCommConsole();
+	~CVtcBusDevCommConsole();
+
+protected: // From CVtcConsoleBase.
+	virtual void ConstructL(const TDesC& aTitle);
+private: // From MConsoleOutput.
+	virtual TInt Output(const TDesC8& aDes);
+private: // From MConsoleInput.
+	virtual void Input(TDes8& aDes, TRequestStatus& aStatus);
+	virtual void CancelInput(TRequestStatus& aStatus);
+private:
+	TInt ReadConfig(const TDesC& aConfigDes, TPortConfig& aConfig);
+private:
+	RBusDevComm iComm;
+	};
+
+extern "C" EXPORT_C TAny* NewConsole()
+	{
+	return new CVtcBusDevCommConsole;
+	}
+
+CVtcBusDevCommConsole::CVtcBusDevCommConsole()
+	{
+	}
+
+CVtcBusDevCommConsole::~CVtcBusDevCommConsole()
+	{
+	iComm.Close();
+	}
+
+#ifdef __WINS__
+_LIT(KPdd, "ecdrv");
+#else
+_LIT(KPdd, "euart");
+#endif
+_LIT(KLdd, "ecomm");
+
+TPortConfig::TPortConfig()
+	:iPdd(KNullDesC), iLdd(KNullDesC), iPort(-1), iRate(EBpsAutobaud)
+	{
+	}
+
+TInt CVtcBusDevCommConsole::ReadConfig(const TDesC& aConfigDes, TPortConfig& aConfig)
+	{
+	_LIT(KKeywordPdd, "pdd");
+	_LIT(KKeywordLdd, "ldd");
+	_LIT(KKeywordPort, "port");
+	_LIT(KKeywordRate, "rate");
+
+	TBool keywordFound(EFalse);
+	TLex lex(aConfigDes);
+	while (!lex.Eos())
+		{
+		TPtrC keyword;
+		TPtrC value;
+		TInt err = ReadKeywordValuePair(lex, keyword, value);
+		if (err != KErrNone)
+			{
+			break;
+			}
+
+		if (keyword == KKeywordPdd)
+			{
+			aConfig.iPdd.Set(value);
+			keywordFound = ETrue;
+			}
+		else if (keyword == KKeywordLdd)
+			{
+			aConfig.iLdd.Set(value);
+			keywordFound = ETrue;
+			}
+		else if (keyword == KKeywordPort)
+			{
+			TLex lex(value);
+			User::LeaveIfError(lex.Val(aConfig.iPort));
+			keywordFound = ETrue;
+			}
+		else if (keyword == KKeywordRate)
+			{
+			TLex lex(value);
+			TUint rate;
+			if (lex.Val(rate) == KErrNone)
+				{
+				switch (rate)
+					{
+				case 115200:
+					aConfig.iRate = EBps115200; break;
+				case 9600:
+					aConfig.iRate = EBps9600; break;
+				case 19200:
+					aConfig.iRate = EBps19200; break;
+				case 57600:
+					aConfig.iRate = EBps57600; break;
+				default:
+					break;
+					}
+				}
+			keywordFound = ETrue;
+			}
+		}
+
+	if (!keywordFound)
+		{
+		// Treat unrecognised string as a port number (to preserve backwards compatibility with earlier releases).
+		TLex lex(aConfigDes);
+		lex.Val(aConfig.iPort);
+		}
+
+	return KErrNone;
+	}
+
+void CVtcBusDevCommConsole::ConstructL(const TDesC& aTitle)
+	{
+	TPortConfig portConfig;
+	User::LeaveIfError(ReadConfig(aTitle, portConfig));
+	if (portConfig.iPort < 0) User::Leave(KErrArgument);
+
+	TPtrC pdd(portConfig.iPdd);
+	if (pdd.Length() == 0) pdd.Set(KPdd());
+	TPtrC ldd(portConfig.iLdd);
+	if (ldd.Length() == 0) ldd.Set(KLdd());
+
+	TInt err = User::LoadPhysicalDevice(pdd);
+	Message(EDebug, _L("Loading %S returned %d"), &pdd, err);
+	if (err != KErrAlreadyExists && portConfig.iPdd.Length()) User::LeaveIfError(err); // Don't error if we failed to load the default PDD
+
+	err = User::LoadLogicalDevice(ldd);
+	Message(EDebug, _L("Loading %S returned %d"), &ldd, err);
+	if (err != KErrAlreadyExists && portConfig.iLdd.Length()) User::LeaveIfError(err); // Don't error if we failed to load the default LDD
+	err = iComm.Open(portConfig.iPort);
+	Message(EDebug, _L("Opening port %d returned %d"), portConfig.iPort, err);
+	User::LeaveIfError(err);
+
+	if (portConfig.iRate != EBpsAutobaud)
+		{
+		TCommConfig cfg;
+		cfg().iRate = portConfig.iRate;
+		cfg().iDataBits = EData8;
+		cfg().iStopBits = EStop1;
+		cfg().iParity = EParityNone;
+		cfg().iHandshake = 0;
+		cfg().iParityError = KConfigParityErrorFail;
+		cfg().iFifo = EFifoEnable;
+		cfg().iSpecialRate = 0;
+		cfg().iTerminatorCount = 0;
+		cfg().iSIREnable = ESIRDisable;
+		err = iComm.SetConfig(cfg);
+		Message(EDebug, _L("RBusDevComm::SetConfig returned %d"), err);
+		User::LeaveIfError(err);
+		}
+	iComm.ResetBuffers();
+	CVtcConsoleBase::ConstructL(aTitle);
+	}
+	
+TInt CVtcBusDevCommConsole::Output(const TDesC8& aDes)
+	{
+	TRequestStatus stat;
+#ifdef FSHELL_PLATFORM_OPP
+retry:
+#endif
+	iComm.Write(stat, aDes);
+	User::WaitForRequest(stat);
+#ifdef FSHELL_PLATFORM_OPP
+	// Temporary OPP specific change - the drivers for the mid-sized prototype currently complete requests with KErrAbort just before power management sends the device to sleep.
+	if (stat.Int() == KErrAbort)
+		{
+		goto retry;
+		}
+#endif
+	return stat.Int();
+	}
+
+void CVtcBusDevCommConsole::Input(TDes8& aDes, TRequestStatus& aStatus)
+	{
+	iComm.ReadOneOrMore(aStatus, aDes);
+	}
+
+void CVtcBusDevCommConsole::CancelInput(TRequestStatus&)
+	{
+	iComm.ReadCancel();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/vt100cons/src/vtc_debugport.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,134 @@
+// vtc_debugport.cpp
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32twin.h>
+#include <fshell/vtc_base.h>
+
+class CReaderObject;
+
+NONSHARABLE_CLASS(CVtcDebugPortConsole) : public CVtcConsoleBase
+	{
+public:
+	CVtcDebugPortConsole();
+	~CVtcDebugPortConsole();
+	void ReadComplete(TInt aErr, TKeyCode aCode);
+
+protected: // From CVtcConsoleBase.
+	virtual void ConstructL(const TDesC& aTitle);
+	TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+private: // From MConsoleOutput.
+	virtual TInt Output(const TDesC8& aDes);
+private: // From MConsoleInput.
+	virtual void Input(TDes8& aDes, TRequestStatus& aStatus);
+	virtual void CancelInput(TRequestStatus& aStatus);
+private:
+	friend class CReaderObject;
+	RConsole iConsole;
+	CReaderObject* iReader;
+	TRequestStatus* iClientStatus;
+	TDes8* iClientDes;
+	};
+
+class CReaderObject : public CActive
+	{
+public:
+	CReaderObject(CVtcDebugPortConsole* aParent) : CActive(CActive::EPriorityStandard), iParent(aParent) { CActiveScheduler::Add(this); }
+	void RunL() { iParent->ReadComplete(iStatus.Int(), iKey.Code()); }
+	void DoCancel() { iParent->iConsole.ReadCancel(); }
+	void Request()
+		{
+		iParent->iConsole.Read(iKey, iStatus);
+		SetActive();
+		}
+	
+	CVtcDebugPortConsole* iParent;
+	TConsoleKey iKey;
+	};
+	
+extern "C" EXPORT_C TAny* NewConsole()
+	{
+	return new CVtcDebugPortConsole;
+	}
+
+CVtcDebugPortConsole::CVtcDebugPortConsole()
+	{
+	}
+
+CVtcDebugPortConsole::~CVtcDebugPortConsole()
+	{
+	if (iReader)
+		{
+		iReader->Cancel();
+		delete iReader;
+		}
+	if (iConsole.Handle())
+		{
+		iConsole.Destroy(); // Needed?
+		}
+	iConsole.Close();
+	}
+
+void CVtcDebugPortConsole::ConstructL(const TDesC& aTitle)
+	{
+	iReader = new(ELeave) CReaderObject(this);
+	User::LeaveIfError(iConsole.Create());
+	User::LeaveIfError(iConsole.Init(_L("fshell"), TSize(KConsFullScreen,KConsFullScreen)));
+	CVtcConsoleBase::ConstructL(aTitle);
+	}
+	
+TInt CVtcDebugPortConsole::Output(const TDesC8& aDes)
+	{
+	TBuf<128> buf;
+	TPtrC8 remainder(aDes);
+	while (remainder.Length())
+		{
+		TPtrC8 frag(remainder.Left(Min(remainder.Length(), buf.MaxLength())));
+		remainder.Set(remainder.Mid(frag.Length()));
+		buf.Copy(frag);
+		RDebug::RawPrint(buf);
+		}
+	return KErrNone;
+	}
+
+void CVtcDebugPortConsole::Input(TDes8& aDes, TRequestStatus& aStatus)
+	{
+	iClientDes = &aDes;
+	iClientStatus = &aStatus;
+	iReader->Request();
+	//iCommPort.ReadOneOrMore(aStatus, aDes);
+	}
+
+void CVtcDebugPortConsole::CancelInput(TRequestStatus&)
+	{
+	//iCommPort.ReadCancel();
+	iReader->Cancel();
+	User::RequestComplete(iClientStatus, KErrCancel);
+	}
+
+void CVtcDebugPortConsole::ReadComplete(TInt aErr, TKeyCode aCode)
+	{
+	iClientDes->SetLength(1);
+	(*iClientDes)[0] = aCode;
+	User::RequestComplete(iClientStatus, aErr);
+	}
+
+TInt CVtcDebugPortConsole::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	if (aExtensionId == ConsoleMode::KSetConsoleModeExtension)
+		{
+		return KErrNotSupported; // The text windowserver swallows certain keypresses so we can't support binary mode
+		}
+	else
+		{
+		return CVtcConsoleBase::Extension_(aExtensionId, a0, a1);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/BWINS/win32consU.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	NewConsole @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_MMPFILES
+
+#if defined(WINS)
+
+gnumakefile .\os_ver.mk
+.\win32cons.mmp
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/group/os_ver.mk	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+# os_ver.mk
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+MAKMAKE :
+	perl -S emkdir.pl $(EPOCROOT)epoc32\build\fshell/win32cons\generated
+	perl .\os_version_h.PL > $(EPOCROOT)epoc32\build\fshell/win32cons\generated\os_version.h
+
+CLEAN :
+	-del ..\src\os_version.h
+
+BLD FREEZE LIB CLEANLIB RESOURCE SAVESPACE RELEASABLES FINAL : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/group/os_version_h.PL	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+#!perl
+# os_version_h.PL
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+use strict;
+die "Error: not running on Win32; Win32Conole must be updated/replaced for this OS: $^O\n" unless $^O =~ m|Win32|;
+require Win32;
+
+my @ver = Win32::GetOSVersion();
+my ($string, $major, $minor, $build, $id) = @ver;
+
+my $ver = sprintf("%02x%02s", $major, $minor);
+
+print <<__EOS__;
+// os_version.h
+// This header is automatically generated by os_version_h.PL; do not edit it directly, edit
+// win_version_h.PL instead.
+
+#ifndef __OS_VERSION_H__
+#define __OS_VERSION_H__
+
+#define _WIN32_WINNT 0x$ver
+
+#endif // __OS_VERSION_H__
+__EOS__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/group/win32cons.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// win32cons.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target			win32cons.dll
+targettype		DLL
+uid			0x1000008d 0x100039e7
+capability		FSHELL_CAP_MMP_NORMAL
+
+sourcepath		..\src
+userinclude		..\src
+#include <fshell/fsh_system_include.mmh>
+systeminclude	\epoc32\build\fshell/win32cons\generated
+
+source			console.cpp win32cons.cpp keymappings.cpp
+
+library			euser.lib
+library			emulator.lib
+
+deffile			win32cons.def
+
+start wins
+win32_library   kernel32.lib
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/src/console.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,255 @@
+// console.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32debug.h>
+#include "console.h"
+#include <fshell/consoleextensions.h>
+
+_LIT(KWin32ConsPanic, "Win32Console");
+#define PANIC() User::Panic(KWin32ConsPanic, 0);
+
+//_____________________________________________________________________________
+//					CWin32Console
+CWin32Console::CWin32Console()
+	{
+	}
+
+CWin32Console::~CWin32Console()
+	{
+	iWin32.FreeConsole();
+	// when call FreeConsole(), it should cause the reader thread to exit as the
+	// console read handle will become invalid, and windows will complete the
+	// ReadRequest with an error
+	if (iReaderThread.Handle())
+		{
+		TRequestStatus stat;
+		iReaderThread.Logon(stat);
+		User::WaitForRequest(stat);
+		}
+	iReaderThread.Close();
+	iKeyQueue.Close();
+	iThreadParams.iOwner.Close();
+	}
+
+TInt CWin32Console::Create(const TDesC& aTitle, TSize /*aSize*/)
+	{
+	int r = iWin32.AttachConsole();
+	if (r==0)
+		{
+		return KErrCouldNotConnect; // suitable error code??
+		}
+	SetTitle(aTitle);
+	
+	_LIT(KReadThreadName, "Win32ConsReader");
+	
+	TInt err = iKeyQueue.CreateLocal(4);
+	if (err!=KErrNone) return err;
+	
+	err = iThreadParams.iOwner.Open(RThread().Id());
+	if (err!=KErrNone) return err;
+	iThreadParams.iWin32 = &iWin32;
+	iThreadParams.iKeyQueue = iKeyQueue;
+	err = iReaderThread.Create(KReadThreadName, ReaderThread, 0x800, KMinHeapSize, KMinHeapSize*4, &iThreadParams);
+	if (err!=KErrNone) return err;
+	iReaderThread.Resume();	
+	
+	return KErrNone;
+	}
+
+void CWin32Console::Read(TRequestStatus& aStatus)
+	{
+	iReadKp = EFalse;
+	iKeyQueue.NotifyDataAvailable(aStatus);
+	}
+
+void CWin32Console::ReadCancel()
+	{
+	iKeyQueue.CancelDataAvailable();
+	}
+
+void CWin32Console::Write(const TDesC& aDes)
+	{
+	iWin32.Write(aDes.Ptr(), aDes.Length());
+	}
+	
+void CWin32Console::WriteStdErr(const TDesC& aDes)
+	{
+	iWin32.WriteStdErr(aDes.Ptr(), aDes.Length());
+	}
+
+TPoint CWin32Console::CursorPos() const
+	{
+	TPoint pos;
+	iWin32.GetCursorPos(pos.iX, pos.iY);
+	return pos;
+	}
+
+void CWin32Console::SetCursorPosAbs(const TPoint& aPoint)
+	{
+	iWin32.SetCursorPos(aPoint.iX, aPoint.iY);
+	}
+
+void CWin32Console::SetCursorPosRel(const TPoint& aPoint)
+	{
+	iWin32.SetCursorPosRel(aPoint.iX, aPoint.iY);
+	}
+
+void CWin32Console::SetCursorHeight(TInt aPercentage)
+	{
+	iWin32.SetCursorHeight(aPercentage);
+	}
+
+void CWin32Console::SetTitle(const TDesC& aTitle)
+	{
+	RBuf8 title;
+	TInt err = title.Create(aTitle.Length()+1);
+	if (err==KErrNone)
+		{
+		title.Copy(aTitle);
+		iWin32.SetTitle((const char*)title.PtrZ());
+		title.Close();
+		}
+	}
+
+void CWin32Console::ClearScreen()
+	{
+	iWin32.ClearScreen();
+	}
+
+void CWin32Console::ClearToEndOfLine()
+	{
+	iWin32.ClearToEndOfLine();
+	}
+
+TSize CWin32Console::ScreenSize() const
+	{
+	TSize size;
+	iWin32.GetScreenSize(size.iWidth, size.iHeight);
+	return size;
+	}
+
+TKeyCode CWin32Console::KeyCode() const
+	{
+	if (!iReadKp)
+		{
+		iKeyQueue.Receive(iKp);
+		iReadKp = ETrue;
+		}
+	return iKp.iCode;
+	}
+
+TUint CWin32Console::KeyModifiers() const
+	{
+	if (!iReadKp)
+		{
+		iKeyQueue.Receive(iKp);
+		iReadKp = ETrue;
+		}
+	return iKp.iModifiers;
+	}
+
+TInt CWin32Console::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	if (aExtensionId == ConsoleStdErr::KWriteStdErrConsoleExtension)
+		{
+		TDesC* des = (TDesC*)a1;
+		WriteStdErr(*des);
+		return KErrNone;
+		}
+	else if (aExtensionId == ConsoleAttributes::KSetConsoleAttributesExtension)
+		{
+		ConsoleAttributes::TAttributes* attributes = (ConsoleAttributes::TAttributes*)a1;
+		int res = iWin32.SetAttributes(attributes->iAttributes, (TWin32Console::TColor)attributes->iForegroundColor, (TWin32Console::TColor)attributes->iBackgroundColor);
+		return res ? KErrNone : KErrGeneral; // Yay for KErrGeneral!
+		}
+	else
+		{
+		return CConsoleBase::Extension_(aExtensionId, a0, a1);
+		}
+	
+	}
+
+//_____________________________________________________________________________
+//					Reader thread
+
+static int ReaderThread(TAny* aParams)
+	{
+	TReaderThreadParams params = *(TReaderThreadParams*)aParams;
+	
+	RMsgQueue<TKeyPress> keyQueue = params.iKeyQueue;
+	TInt err = keyQueue.Duplicate(params.iOwner);
+	
+	while (err==KErrNone)
+		{
+		TKeyPress kp;
+		err = params.iWin32->ReadKey(kp.iCode, kp.iModifiers);
+		
+		if (err==KErrNone)
+			{
+			keyQueue.SendBlocking(kp);
+			}
+
+		};
+	
+	keyQueue.Close();
+	
+	return err;
+	}
+
+//_____________________________________________________________________________
+//					Debugging stuff
+EXPORT_C TAny* NewConsole()
+	{
+	return new CWin32Console;
+	}
+
+class TOverflowTruncate8 : public TDes8Overflow
+	{
+public:
+	virtual void Overflow(TDes8&) {}
+	};
+
+class TOverflowTruncate16 : public TDes16Overflow
+	{
+public:
+	virtual void Overflow(TDes16&) {}
+	};
+
+void DebugMsg(const char* aMsg, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aMsg);
+	TBuf8<0x100> buf;
+	TOverflowTruncate8 overflow;
+	buf.AppendFormatList(_L8(aMsg), list, &overflow);
+
+	RDebug::Printf((const char*)buf.PtrZ());
+	}
+
+void DebugMsg(const TUint16* aMsg, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aMsg);
+	TBuf16<0x100> buf;
+	TOverflowTruncate16 overflow;
+	buf.AppendFormatList(TPtrC((const TText16*)aMsg), list, &overflow);
+
+	RDebug::Print(buf);
+	}
+
+
+#ifndef EKA2
+GLDEF_C TInt E32Dll(TDllReason)
+	{
+	return(KErrNone);
+	}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/src/console.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,95 @@
+// console.h
+// 
+// Copyright (c) 2006 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32cons.h>
+#include <e32msgqueue.h>
+#include <fshell/consoleextensions.h>
+#include "win32cons.h"
+
+
+class TKeyPress
+	{
+public:
+	TKeyCode iCode;
+	TUint iModifiers;
+	};
+
+class TReaderThreadParams
+	{
+public:
+	TWin32Console* iWin32;
+	RMsgQueue<TKeyPress> iKeyQueue;
+	RThread iOwner;
+	};
+	
+	
+/**
+Symbian CConsoleBase implementation that uses a Win32 console.
+
+It supports all of the CConsoleBase API. It also supports piping of test written
+to the console into a Win32 file or process, if the emulator is launched from a
+script in an appropriate manner.
+
+More specifally:
+- Redirection to a file: i.e. if the emulator is launched the emulator STDOUT
+  piped to a file, data written to this console will end up in that file
+- Attaching to the console of the parent process: i.e. when the emulator is
+  launched from a windows Command Prompt box, output will appear there
+- Creating a new console, if the emulator is lauched from a process with no
+  console. This will happen if the emulator is launched from an IDE.
+  
+Piping into the emulator process via this console is as yet untested.
+*/
+#ifdef EKA2
+NONSHARABLE_CLASS(CWin32Console)
+#else
+class CWin32Console
+#endif
+	 : public CConsoleBase
+	{
+public:
+	CWin32Console();
+public: // From CConsoleBase.
+	virtual ~CWin32Console();
+	virtual TInt Create(const TDesC& aTitle, TSize aSize);
+	virtual void Read(TRequestStatus& aStatus);
+	virtual void ReadCancel();
+	virtual void Write(const TDesC& aDes);
+	virtual TPoint CursorPos() const;
+	virtual void SetCursorPosAbs(const TPoint& aPoint);
+	virtual void SetCursorPosRel(const TPoint& aPoint);
+	virtual void SetCursorHeight(TInt aPercentage);
+	virtual void SetTitle(const TDesC& aTitle);
+	virtual void ClearScreen();
+	virtual void ClearToEndOfLine();
+	virtual TSize ScreenSize() const;
+	virtual TKeyCode KeyCode() const;
+	virtual TUint KeyModifiers() const;
+	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
+	
+	virtual void WriteStdErr(const TDesC& aDes);
+private:
+	TInt CreateNewConsole(const TDesC& aTitle, TSize aSize);
+	TInt FindClientThreadId(TThreadId& aThreadId);
+	static void HeapWalk(TAny* aSelf, RHeap::TCellType aCellType, TAny* aCellPtr, TInt aLength);
+private:
+	TWin32Console iWin32;
+	mutable RMsgQueue<TKeyPress> iKeyQueue;
+	RThread iReaderThread;
+	TReaderThreadParams iThreadParams;
+	
+	mutable TBool iReadKp;
+	mutable TKeyPress iKp;
+	};
+	
+static int ReaderThread(TAny* aParams);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/src/keymappings.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,86 @@
+// keymappings.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <e32keys.h>
+#include <e32def.h>
+#include "keymappings.h"
+
+
+static const TKeyMapping KKeyMapping[] =
+	{
+	{ VK_ESCAPE, EKeyEscape },
+	{ VK_LEFT, EKeyLeftArrow },
+	{ VK_UP, EKeyUpArrow },
+	{ VK_RIGHT, EKeyRightArrow },
+	{ VK_DOWN, EKeyDownArrow },
+	{ VK_HOME, EKeyHome },
+	{ VK_END, EKeyEnd },
+	{ VK_PRIOR, EKeyPageUp },
+	{ VK_NEXT, EKeyPageDown },
+	{ VK_PAUSE, EKeyPause },
+	{ VK_PRINT, EKeyPrintScreen },
+	{ VK_INSERT, EKeyInsert },
+	{ VK_DELETE, EKeyDelete },
+	{ VK_CAPITAL, EKeyCapsLock },
+	{ VK_NUMLOCK, EKeyNumLock },
+	{ VK_SCROLL, EKeyScrollLock },
+	{ VK_F1, EKeyF1 },
+	{ VK_F2, EKeyF2 },
+	{ VK_F3, EKeyF3 },
+	{ VK_F4, EKeyF4 },
+	{ VK_F5, EKeyF5 },
+	{ VK_F6, EKeyF6 },
+	{ VK_F7, EKeyF7 },
+	{ VK_F8, EKeyF8 },
+	{ VK_F9, EKeyF9 },
+	{ VK_F10, EKeyF10 },
+	{ VK_F11, EKeyF11 },
+	{ VK_F12, EKeyF12 },
+	{ VK_F13, EKeyF13 },
+	{ VK_F14, EKeyF14 },
+	{ VK_F15, EKeyF15 },
+	{ VK_F16, EKeyF16 },
+	{ VK_F17, EKeyF17 },
+	{ VK_F18, EKeyF18 },
+	{ VK_F19, EKeyF19 },
+	{ VK_F20, EKeyF20 },
+	{ VK_F21, EKeyF21 },
+	{ VK_F22, EKeyF22 },
+	{ VK_F23, EKeyF23 },
+	{ VK_F24, EKeyF24 },
+	};
+	
+TKeyCode GetSymbianKeyCode(int aWindowsKeyCode)
+	{
+	for (int i=0; i<sizeof(KKeyMapping) / sizeof(TKeyMapping); ++i)
+		{
+		if (KKeyMapping[i].iWindowsKey == aWindowsKeyCode) return KKeyMapping[i].iSymbianKey;
+		}
+	return EKeyNull;
+	}
+	
+TUint GetSymbianModifiers(TUint aWindowsModifiers)
+	{
+	TUint32 symMod = 0;
+	if (aWindowsModifiers & CAPSLOCK_ON) symMod |= EModifierCapsLock;
+	if (aWindowsModifiers & LEFT_ALT_PRESSED) symMod |= EModifierLeftAlt | EModifierAlt;
+	if (aWindowsModifiers & LEFT_CTRL_PRESSED) symMod |= EModifierLeftCtrl | EModifierCtrl;
+	if (aWindowsModifiers & NUMLOCK_ON) symMod |= EModifierNumLock;
+	if (aWindowsModifiers & RIGHT_ALT_PRESSED) symMod |= EModifierRightAlt | EModifierAlt;
+	if (aWindowsModifiers & RIGHT_CTRL_PRESSED) symMod |= EModifierLeftAlt | EModifierCtrl;
+	if (aWindowsModifiers & SCROLLLOCK_ON) symMod |= EModifierScrollLock;
+	if (aWindowsModifiers & SHIFT_PRESSED) symMod |= EModifierShift;
+	return symMod;	
+	}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/src/keymappings.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,26 @@
+// keymappings.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef KEYMAPPINGS_H__
+#define KEYMAPPINGS_H__
+
+class TKeyMapping
+	{
+public:
+	int iWindowsKey;
+	TKeyCode iSymbianKey;
+	};
+	
+TKeyCode GetSymbianKeyCode(int aWindowsKeyCode);
+TUint GetSymbianModifiers(TUint aWindowsModifiers);
+
+#endif //KEYMAPPINGS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/src/win32cons.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,605 @@
+// win32cons.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+// os_version.h must be included before the windows headers
+// to ensure that _WIN32_WINNT has the right value
+#include "os_version.h"
+#include <stdio.h>
+#include <windows.h>
+#include <fcntl.h>
+#include <io.h>
+#include <emulator.h>
+#include "win32cons.h"
+#include "keymappings.h"
+
+//#define DEBUG_CONSOLE
+
+#ifdef DEBUG_CONSOLE
+#define CONS_DEBUG(x) x
+#else
+#define CONS_DEBUG(x)
+#endif
+
+inline int Min(int a, int b) {return a<b ? a : b;}
+inline int Max(int a, int b) {return a<b ? b : a;}
+
+#define WIN32_START() Emulator::Lock()
+#define WIN32_END() Emulator::Unlock()
+
+#define WIN32_CALL(x) { WIN32_START(); x; WIN32_END(); }
+
+int TWin32Console::AttachOrAllocConsole()
+	{
+	// NB The AttachConsole method is only available on WinXP and later
+	WIN32_START();
+#if _WIN32_WINNT >= 0x0501
+	if (!::AttachConsole(-1)) 
+		{
+		// no luck
+		int err = GetLastError();
+		if (err == ERROR_ACCESS_DENIED)
+			{
+			WIN32_END();
+			// we're already attached to a console (?) - continue.
+			}
+		else if (err == ERROR_INVALID_HANDLE)
+			{
+#endif
+			if (!AllocConsole())
+				{
+				WIN32_END();
+				return 0; //failed
+				}
+			WIN32_END();
+			CONS_DEBUG(DebugMsg("Allocated console"));
+#if _WIN32_WINNT >= 0x0501
+			}
+		else
+			{
+			WIN32_END();
+			CONS_DEBUG(DebugMsg("Failed to attach to console, error %d", err));
+			return 0;
+			}
+		}
+	else
+		{
+		int err = GetLastError();
+		WIN32_END();
+		CONS_DEBUG(DebugMsg("Attached console err %d", err));
+		}
+#endif
+	
+	iHaveConsole = true;
+	return 1;
+	}
+	
+bool TestHandle(void* aHandle, int* aError = NULL)
+	{
+	WIN32_START();
+	DWORD written;
+	bool r = WriteFile(aHandle, "", 0, &written, NULL);
+	if (aError) *aError = GetLastError();
+	WIN32_END();
+	return r;
+	}
+
+int TWin32Console::AttachConsole()
+	{
+	iHaveConsole = false;
+	// first, test the existing STDOUT and STDERR handles; if out output is being redirected to 
+	// a file, these will be valid as they stand.
+	WIN32_START();
+	iStdOutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
+	iStdErrHandle = GetStdHandle(STD_ERROR_HANDLE);
+	
+	// try writing to stdout to see if it's valid
+	int err;
+	bool ok = TestHandle(iStdOutHandle, &err);
+	WIN32_END();
+	
+	if (!ok && err == ERROR_INVALID_HANDLE)
+		{
+		// no redirection, so existing handle doesn't work. Attach to an existing console (if it exists)
+		// or create a new one (this will happen if we're invoked from the IDE, for example)
+		CONS_DEBUG(DebugMsg("Failed to write to existing STDOUT"));
+		err = AttachOrAllocConsole();
+		if (err==0) return err;
+		WIN32_CALL(iStdOutHandle =  GetStdHandle(STD_OUTPUT_HANDLE));
+		}
+	else if (!ok)
+		{
+		// some other error occurred, fail.
+		CONS_DEBUG(DebugMsg("Failed to write to existing STDOUT; error %d", err));
+		return 0;
+		}
+	else
+		{
+		CONS_DEBUG(DebugMsg("Using existing STDOUT"));
+		}
+		
+	// try writing to stderr to see if it's valid
+	ok = TestHandle(iStdErrHandle, &err);
+	if (!ok && err == ERROR_INVALID_HANDLE)
+		{
+		CONS_DEBUG(DebugMsg("Failed to write to existing STDERR"));
+		if (!iHaveConsole)
+			{
+			err = AttachOrAllocConsole();
+			if (err==0) return err;
+			}
+		else
+			{
+			CONS_DEBUG(DebugMsg("Already attached/alloc'd console"));
+			}
+		WIN32_CALL(iStdErrHandle = GetStdHandle(STD_ERROR_HANDLE));
+		CONS_DEBUG(DebugMsg("GetStdHandle(Stderr)=%d err=%d", iStdErrHandle, GetLastError()));
+		}
+	else if (!ok)
+		{
+		CONS_DEBUG(DebugMsg("Failed to write to existing STDERR; error %d", err));
+		return 0;
+		}
+	else
+		{
+		CONS_DEBUG(DebugMsg("Using existing STDERR"));
+		}
+		
+	// in some cases (such as when we're invoked by GNU make) the handle returned by GetStdHandle
+	// after attaching to a console doesn't work. In this case, open a new handle to the console
+	// using CreateFile
+	TInt lastError;
+	if (!TestHandle(iStdOutHandle, &lastError))
+		{
+		CONS_DEBUG(DebugMsg("Still can't write STDOUT; err %d; opening new console handle", lastError));
+		
+		WIN32_START();
+		iHaveConsole = false;
+		iStdOutHandle = CreateFile(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		int err = GetLastError();
+		WIN32_END();
+		CONS_DEBUG(DebugMsg("CreateFile handle = %d, err %d", iStdOutHandle, err));
+		if (!TestHandle(iStdOutHandle, &err))
+			{
+			CONS_DEBUG(DebugMsg("Still can't write STDOUT; err %d; giving up", err));
+			return 0;
+			}
+		}
+	
+	if (!TestHandle(iStdErrHandle, &lastError))
+		{
+		CONS_DEBUG(DebugMsg("Still can't write STDOUT; err %d; opening new console handle", GetLastError()));
+		
+		WIN32_START();
+		iHaveConsole = false;
+		iStdErrHandle = CreateFile(L"CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		int err = GetLastError();
+		WIN32_END();
+		
+		CONS_DEBUG(DebugMsg("CreateFile handle = %d, err %d", iStdErrHandle, err));
+		if (!TestHandle(iStdErrHandle, &err))
+			{
+			CONS_DEBUG(DebugMsg("Still can't write STDERR; err %d; giving up", err));
+			return 0;
+			}
+		}
+		
+	//iStdinHandle = CreateFile(L"CONIN$", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+	WIN32_START();
+	iConsModeSet=false;
+	iStdinHandle = GetStdHandle(STD_INPUT_HANDLE);
+	if (GetConsoleMode(iStdinHandle, &iOldConsMode))
+		{
+		DWORD consmode = iOldConsMode & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT);
+		if (SetConsoleMode(iStdinHandle, consmode))
+			{
+			iConsModeSet=true;
+			}
+		}
+	iOrigAttributes = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN;
+	CONSOLE_SCREEN_BUFFER_INFO info;
+	if (GetConsoleScreenBufferInfo(iStdOutHandle, &info))
+		{
+		iOrigAttributes = info.wAttributes;
+		}
+	WIN32_END();
+		
+	return 1;
+	}
+	
+void TWin32Console::FreeConsole()
+	{
+	WIN32_START();
+	if (iConsModeSet)
+		{
+		SetConsoleMode(iStdinHandle, iOldConsMode);
+		}
+	::FreeConsole();
+	WIN32_END();
+	}
+	
+int TWin32Console::Write(const char* aText, int aLen)
+	{
+	DWORD written;
+	WIN32_START();
+	bool b = WriteFile(iStdOutHandle, (const void*)aText, aLen, &written, NULL);
+	int err = GetLastError();
+	WIN32_END();
+	//DebugMsg("WriteFile(STDOUT)=%d, err=%d", b, err);
+	return b ? 0 : (err>0 ? -err  : err);
+	}
+
+int TWin32Console::Write(const WCHAR* aText, int aLen)
+	{
+	if (iHaveConsole)
+		{
+		DWORD written;
+		WIN32_START();
+		bool b = WriteConsole(iStdOutHandle, (void*)aText, aLen, &written, NULL);
+		int err = GetLastError();
+		WIN32_END();
+		//DebugMsg("WriteFile(STDOUT)=%d, err=%d", b, err);
+		return b ? 0 : (err>0 ? -err  : err);
+		}
+	else
+		{
+		const int KBufLen = 256;
+		char outbuf[KBufLen];
+		int pos = 0;
+		while (pos < aLen)
+			{
+			int len = Min(KBufLen, aLen - pos);
+			int narrowLen = WideCharToMultiByte(CP_ACP, 0, aText, len, outbuf, KBufLen, NULL, NULL);
+			if (narrowLen == 0 && aLen != 0) return 0;
+			int ok = Write(outbuf, narrowLen);
+			if (!ok) return ok;
+			}
+		return 1;
+		}
+	}
+	
+int TWin32Console::WriteStdErr(const char* aText, int aLen)
+	{
+	DWORD written;
+	WIN32_START();
+	bool b = WriteFile(iStdErrHandle, (const void*)aText, aLen, &written, NULL);
+	int err = GetLastError();
+	WIN32_END();
+	//DebugMsg("WriteFile(STDERR)=%d, err=%d", b, err);
+	return b ? 0 : (err>0 ? -err  : err);
+	}
+
+int TWin32Console::WriteStdErr(const WCHAR* aText, int aLen)
+	{
+	if (iHaveConsole)
+		{
+		DWORD written;
+		WIN32_START();
+		bool b = WriteConsole(iStdErrHandle, (void*)aText, aLen, &written, NULL);
+		int err = GetLastError();
+		WIN32_END();
+		//DebugMsg("WriteFile(STDOUT)=%d, err=%d", b, err);
+		return b ? 0 : (err>0 ? -err  : err);
+		}
+	else
+		{
+		const int KBufLen = 256;
+		char outbuf[KBufLen];
+		int pos = 0;
+		while (pos < aLen)
+			{
+			int len = Min(KBufLen, aLen - pos);
+			int narrowLen = WideCharToMultiByte(CP_ACP, 0, aText, len, outbuf, KBufLen, NULL, NULL);
+			if (narrowLen == 0 && aLen != 0) return 0;
+			int ok = WriteStdErr(outbuf, narrowLen);
+			if (!ok) return ok;
+			}
+		return 1;
+		}
+	}
+	
+int TWin32Console::Read(void* buf, int len, int& bytesRead)
+	{
+	DWORD read;
+
+	/*
+	Read is a blocking call. We don't want to use WIN32_START() (Emulator::Lock()) as this 
+	will cause all other emulator threads to block until the Read call returns. Instead,
+	we escape the emulator which removes this thread from the usual emulator thraed 
+	scheduling until we re-enter the emulator when ReadFile returns. This allows other
+	emulator threads to run concurrently, even though (from the emulators thread shedulers
+	point of view) this thread is still running.
+	*/
+	Emulator::Escape(); 
+	bool b = ReadFile(iStdinHandle, buf, len, &read, NULL);
+	Emulator::Reenter();
+	
+	bytesRead = read;
+	return b ? 0 : -2; // TODO better error code?
+	}
+	
+int TWin32Console::ReadKey(TKeyCode& aCode, TUint& aModifiers)
+	{
+	bool ok = true;
+	if (iCachedKey.wRepeatCount == 0)
+		{
+		Emulator::Escape();
+		// read a recognised key event:
+		do
+			{
+			// read a key down event:
+			do
+				{
+				DWORD read;
+				INPUT_RECORD inp;
+				// read a key event:
+				do 
+					{
+					// read a console event:
+					do 
+						{
+						ok = ReadConsoleInput(iStdinHandle, &inp, 1, &read);
+						} while (ok && (read==0));
+					} while (ok && (inp.EventType != KEY_EVENT));
+				
+				if (ok)
+					{
+					iCachedKey = inp.Event.KeyEvent;
+					}
+				} while (ok && !iCachedKey.bKeyDown);
+			aCode = (TKeyCode)iCachedKey.uChar.AsciiChar;
+			if (aCode==0) aCode = GetSymbianKeyCode(iCachedKey.wVirtualKeyCode);
+			aModifiers = GetSymbianModifiers(iCachedKey.dwControlKeyState);
+			
+			} while (ok && (aCode==0));
+
+		Emulator::Reenter();
+			
+		}
+	if (!ok) return -2;
+	
+	CONS_DEBUG(char ch = iCachedKey.uChar.AsciiChar;
+	if (!ch) ch=' ';
+	DebugMsg("KeyPress %02x ('%c') down:%d keycode:%02x scancode:%02x controlkey:%02x", 
+		iCachedKey.uChar.AsciiChar, ch, iCachedKey.bKeyDown, iCachedKey.wVirtualKeyCode, iCachedKey.wVirtualScanCode, iCachedKey.dwControlKeyState));
+		
+	if (iCachedKey.wRepeatCount>0) --iCachedKey.wRepeatCount;
+	
+	return 0;
+	}
+
+	
+int TWin32Console::GetCursorPos(int& aX, int& aY) const
+	{
+	CONSOLE_SCREEN_BUFFER_INFO sbInfo;
+	int r;
+	WIN32_CALL(r = GetConsoleScreenBufferInfo(iStdOutHandle, &sbInfo));
+	if (r)
+		{
+		aX = sbInfo.dwCursorPosition.X;
+		aY = sbInfo.dwCursorPosition.Y;
+		// make sure it's not off the screen (bottom right)
+		if (aX > sbInfo.srWindow.Right) aX = sbInfo.srWindow.Left;
+		if (aY > sbInfo.srWindow.Bottom) aY = sbInfo.srWindow.Bottom;
+		// make cursor pos relative to display window
+		aX -= sbInfo.srWindow.Left;
+		aY -= sbInfo.srWindow.Top;
+		// make sure it's not off the screen (top left)
+		if (aX < 0) aX = 0;
+		if (aY < 0) aY = 0;
+		}
+	else
+		{
+		aX = aY = 0;
+		}
+	return r;
+	}
+	
+int TWin32Console::SetCursorPos(int aX, int aY)
+	{
+	CONSOLE_SCREEN_BUFFER_INFO sbInfo;
+	int r;
+	WIN32_CALL(r = GetConsoleScreenBufferInfo(iStdOutHandle, &sbInfo));
+	if (r)
+		{
+		// make position relative to display window
+		aX += sbInfo.srWindow.Left;
+		aY += sbInfo.srWindow.Top;
+		// make sure it's within the screen buffer
+		if (aX > sbInfo.dwSize.X) aX = sbInfo.dwSize.X;
+		if (aY > sbInfo.dwSize.Y) aY = sbInfo.dwSize.Y;
+		if (aX < 0) aX = 0;
+		if (aY < 0) aY = 0;
+		COORD pos;
+		pos.X = aX;
+		pos.Y = aY;
+		WIN32_CALL(r = SetConsoleCursorPosition(iStdOutHandle, pos));
+		}
+	return r;
+	}
+	
+int TWin32Console::SetCursorPosRel(int aX, int aY)
+	{
+	CONSOLE_SCREEN_BUFFER_INFO sbInfo;
+	int r;
+	WIN32_CALL(r = GetConsoleScreenBufferInfo(iStdOutHandle, &sbInfo));
+	if (r)
+		{
+		sbInfo.dwCursorPosition.X += aX;
+		sbInfo.dwCursorPosition.Y += aY;
+		// make sure it's still within screen buffer
+		sbInfo.dwCursorPosition.X = Max(0, Min(sbInfo.dwCursorPosition.X, sbInfo.dwSize.X));
+		sbInfo.dwCursorPosition.Y = Max(0, Min(sbInfo.dwCursorPosition.Y, sbInfo.dwSize.Y));
+		
+		WIN32_CALL(r = SetConsoleCursorPosition(iStdOutHandle, sbInfo.dwCursorPosition));
+		}
+	return r;
+	}
+		
+int TWin32Console::SetCursorHeight(int aPercentage)
+	{
+	CONSOLE_CURSOR_INFO info;
+	info.dwSize = Min(100, Max(1, aPercentage));
+	info.bVisible = aPercentage>0;
+	int r;
+	WIN32_CALL(r = SetConsoleCursorInfo(iStdOutHandle, &info));
+	return r;
+	}
+	
+int TWin32Console::SetTitle(const char* aTitle)
+	{
+	int r;
+	WIN32_CALL(r = SetConsoleTitleA(aTitle));
+	return r;
+	}
+	
+int TWin32Console::ClearScreen()
+	{
+	CONSOLE_SCREEN_BUFFER_INFO sbInfo;
+	WIN32_START();
+	int r = GetConsoleScreenBufferInfo(iStdOutHandle, &sbInfo);
+	COORD topLeft = {0, 0};
+	if (r)
+		{
+		DWORD bufferSize = sbInfo.dwSize.X * sbInfo.dwSize.Y;
+		DWORD charsWritten;
+		r = FillConsoleOutputCharacter(iStdOutHandle, (TCHAR)' ', bufferSize, topLeft, &charsWritten);
+		// Also reset the attributes
+		if (r) FillConsoleOutputAttribute(iStdOutHandle, iOrigAttributes, bufferSize, topLeft, &charsWritten);
+		}
+	if (r)
+		{
+		// move cursor to top left
+		r = SetConsoleCursorPosition(iStdOutHandle, topLeft);
+		}
+	if (r)
+		{
+		// move scroll region to top left
+		sbInfo.srWindow.Left -= sbInfo.srWindow.Right;
+		sbInfo.srWindow.Right -= sbInfo.srWindow.Right;
+		sbInfo.srWindow.Bottom -= sbInfo.srWindow.Top;
+		sbInfo.srWindow.Top -= sbInfo.srWindow.Top;
+		r = SetConsoleWindowInfo(iStdOutHandle, true, &sbInfo.srWindow);
+		}
+	WIN32_END();
+	return r;
+	}
+	
+int TWin32Console::ClearToEndOfLine()
+	{
+	WIN32_START();
+	CONSOLE_SCREEN_BUFFER_INFO sbInfo;
+	int r = GetConsoleScreenBufferInfo(iStdOutHandle, &sbInfo);
+	if (r)
+		{
+		SHORT len = sbInfo.dwSize.X - sbInfo.dwCursorPosition.X;
+		DWORD charsWritten;
+		r = FillConsoleOutputCharacter(iStdOutHandle, (TCHAR)' ', len, sbInfo.dwCursorPosition, &charsWritten);
+		// Also reset the attributes
+		if (r) FillConsoleOutputAttribute(iStdOutHandle, iOrigAttributes, len, sbInfo.dwCursorPosition, &charsWritten);
+		}
+	WIN32_END();
+	return r;	
+	}
+	
+int TWin32Console::GetScreenSize(int& aWidth, int& aHeight) const
+	{
+	CONSOLE_SCREEN_BUFFER_INFO sbInfo;
+	int r;
+	WIN32_CALL(r = GetConsoleScreenBufferInfo(iStdOutHandle, &sbInfo));
+	if (r)
+		{
+		aWidth  = sbInfo.srWindow.Right - sbInfo.srWindow.Left + 1;
+		aHeight = sbInfo.srWindow.Bottom - sbInfo.srWindow.Top + 1;
+		}
+	else
+		{
+		// not much else we can do?
+		aWidth = 80;
+		aHeight = 25; // [Shouldn't this be 24? -TomS]
+		}
+	return r;
+	}
+	
+int TWin32Console::SetAttributes(unsigned aAttributes, TWin32Console::TColor aForegroundColor, TWin32Console::TColor aBackgroundColor)
+	{
+	WORD attrib;
+	CONSOLE_SCREEN_BUFFER_INFO info;
+	if (aAttributes & ENone)
+		{
+		// None means reset
+		attrib = iOrigAttributes;
+		}
+	else
+		{
+		BOOL ok;
+		WIN32_CALL(ok = GetConsoleScreenBufferInfo(iStdOutHandle, &info));
+		if (!ok) return ok;
+		attrib = info.wAttributes;
+		}
+	
+	if (aForegroundColor != EUnchanged) attrib &= ~0x0F; // Clear the fg bits in preparation for the switch below
+	if (aBackgroundColor != EUnchanged) attrib &= ~0xF0; // Clear the bg bits in preparation for the switch below
+
+	switch (aForegroundColor)
+		{
+		case EBlack:
+			break;
+		case ERed:
+			attrib |= FOREGROUND_RED; break;
+		case EGreen:
+			attrib |= FOREGROUND_GREEN; break;
+		case EYellow:
+			attrib |= FOREGROUND_RED | FOREGROUND_GREEN; break;
+		case EBlue:
+			attrib |= FOREGROUND_BLUE; break;
+		case EMagenta:
+			attrib |= FOREGROUND_RED | FOREGROUND_BLUE; break;
+		case ECyan:
+			attrib |= FOREGROUND_BLUE | FOREGROUND_GREEN; break;
+		case EWhite:
+			attrib |= FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN; break;
+		default:
+			break;
+		}
+	switch (aBackgroundColor)
+		{
+		case EBlack:
+			break;
+		case ERed:
+			attrib |= BACKGROUND_RED; break;
+		case EGreen:
+			attrib |= BACKGROUND_GREEN; break;
+		case EYellow:
+			attrib |= BACKGROUND_RED | BACKGROUND_GREEN; break;
+		case EBlue:
+			attrib |= BACKGROUND_BLUE; break;
+		case EMagenta:
+			attrib |= BACKGROUND_RED | BACKGROUND_BLUE; break;
+		case ECyan:
+			attrib |= BACKGROUND_BLUE | BACKGROUND_GREEN; break;
+		case EWhite:
+			attrib |= BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN; break;
+		default:
+			break;
+		}
+	if (aAttributes & EBold) attrib |= FOREGROUND_INTENSITY;
+	if (aAttributes & EInverse)
+		{
+		// COMMON_LVB_REVERSE_VIDEO doesn't seem to be supported, so swap foreground and background manually
+		attrib = ((attrib & 0xF) << 4) | ((attrib & 0xF0) >> 4);
+		}
+	//if (aAttributes & EUnderscore) attrib |= COMMON_LVB_UNDERSCORE;
+
+	BOOL ok;
+	WIN32_CALL(ok = SetConsoleTextAttribute(iStdOutHandle, attrib));
+	return ok;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/consoles/win32cons/src/win32cons.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,86 @@
+// win32cons.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __win32cons_h__
+#define __win32cons_h__
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <e32keys.h>
+
+class TWin32Console
+	{
+public:	
+	/**
+	Return non-zero on success.
+	*/
+	int AttachConsole();
+	void FreeConsole();
+	int Write(const char* aText, int aLen);
+	int Write(const WCHAR* aText, int aLen);
+	int WriteStdErr(const char* aText, int aLen);
+	int WriteStdErr(const WCHAR* aText, int aLen);
+	int Read(void* buf, int len, int& bytesRead);
+	int ReadKey(TKeyCode& aCode, TUint& aModifiers);
+	int GetCursorPos(int& aX, int& aY) const;
+	int SetCursorPos(int aX, int aY);
+	int SetCursorPosRel(int aX, int aY);
+	int SetCursorHeight(int aPercentage);
+	int SetTitle(const char* aTitle);
+	int ClearScreen();
+	int ClearToEndOfLine();
+	int GetScreenSize(int& aWidth, int& aHeight) const;
+
+	// Copied from consoleextensions.h
+	enum TAttribute
+		{
+		ENone			= 0x0001,
+		EBold			= 0x0002,
+		EUnderscore		= 0x0004,
+		EBlink			= 0x0008,
+		EInverse		= 0x0010,
+		EConceal		= 0x0020
+		};
+	enum TColor
+		{
+		EBlack,
+		ERed,
+		EGreen,
+		EYellow,
+		EBlue,
+		EMagenta,
+		ECyan,
+		EWhite,
+		EReset,
+		EUnchanged
+		};
+	int SetAttributes(unsigned aAttributes, TWin32Console::TColor aForegroundColor, TWin32Console::TColor aBackgroundColor);
+
+private:
+	int AttachOrAllocConsole();
+private:
+	bool iHaveConsole;
+	void* iStdOutHandle;
+	void* iStdErrHandle;
+	void* iStdinHandle;
+	unsigned long iOldConsMode;
+	bool iConsModeSet;
+	KEY_EVENT_RECORD iCachedKey;
+	WORD iOrigAttributes;
+	};
+	
+void DebugMsg(const char* aMsg, ...);
+void DebugMsg(const unsigned short int* aMsg, ...);
+
+#endif //__win32cons_h__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/nullnif/BMARM/nullnifU.DEF	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	Install @ 1 NONAME R3UNUSED ; (null)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/nullnif/bwins/nullnifu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1 @@
+EXPORTS Install @1 NONAME
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/nullnif/eabi/nullnifu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	Install @ 1 NONAME
+	
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/nullnif/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,15 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+PRJ_MMPFILES
+
+.\nullnif.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/nullnif/group/nullnif.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// nullnif.mmp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+target	        nullnif.nif
+targettype      dll
+uid             0x10003D3a FSHELL_UID_NULLNIF
+capability      FSHELL_CAP_MMP_NORMAL
+
+
+sourcepath      ..\src
+source          nullnif.cpp
+
+userinclude     ..\src
+#include <fshell/fsh_system_include.mmh>
+
+library         euser.lib
+library         mbufmgr.lib
+library         nifman.lib 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/nullnif/src/nullnif.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,159 @@
+// nullnif.cpp
+// 
+// Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <in_sock.h>
+#include <in_iface.h>
+#include <comms-infras/nifif.h>
+
+
+NONSHARABLE_CLASS(CNullNif) : public CNifIfLink
+	{
+public:
+	CNullNif(CNifIfFactory& aFactory);
+	~CNullNif();
+	virtual void BindL(TAny *aId);
+	virtual TInt State();
+	virtual TInt Control(TUint aLevel,TUint aName,TDes8& aOption, TAny* aSource=0);
+	virtual TInt Send(RMBufChain& aPdu, TAny* aSource=0);
+	virtual TInt Start();
+	virtual void Stop(TInt aReason, MNifIfNotify::TAction aAction);
+	virtual CNifIfBase* GetBinderL(const TDesC& aName);
+	virtual void Info(TNifIfInfo& aInfo) const;
+	virtual TInt Notification(TAgentToNifEventType aEvent, void* aInfo);
+	virtual void Restart(CNifIfBase* aIf);
+	static void FillInInfo(TNifIfInfo& aInfo);
+	};
+
+CNullNif::CNullNif(CNifIfFactory& aFactory)
+	: CNifIfLink(aFactory)
+	{
+	}
+
+CNullNif::~CNullNif()
+	{
+	}
+
+void CNullNif::Info(TNifIfInfo& aInfo) const
+	{
+	FillInInfo(aInfo);
+	}
+
+void CNullNif::FillInInfo(TNifIfInfo& aInfo)
+	{
+	aInfo.iVersion = TVersion(0, 0, 0);
+	aInfo.iFlags = KNifIfIsBase | KNifIfUsesNotify | KNifIfIsLink | KNifIfCreatedByFactory;
+	_LIT(KNullNif, "nullnif");
+	aInfo.iName = KNullNif;
+	aInfo.iProtocolSupported = KProtocolInetIp;
+	}
+
+void CNullNif::BindL(TAny*)
+	{
+	}
+
+TInt CNullNif::Send(RMBufChain&, TAny*)
+	{
+	return 0;
+	}
+
+TInt CNullNif::State()
+	{
+    return EIfUp;
+	}
+
+TInt CNullNif::Control(TUint aLevel, TUint aName, TDes8& aOption, TAny* /*aSource*/)
+	{
+	if (aLevel != KSOLInterface)
+		{
+		return KErrNotSupported;
+		}
+
+	switch (aName)
+		{
+		case KSoIfInfo:
+			{
+			TSoIfInfo& opt = *(TSoIfInfo*)aOption.Ptr();
+			TNifIfInfo info;
+			FillInInfo(info);
+			opt.iName = info.iName;
+			return KErrNone;
+			}
+		}
+		
+	return KErrNotSupported;
+	}
+
+CNifIfBase* CNullNif::GetBinderL(const TDesC&)
+	{
+	return NULL;
+	}
+
+TInt CNullNif::Start()
+	{
+	iNotify->IfProgress(KLinkLayerOpen, KErrNone);
+	iNotify->LinkLayerUp();
+	return KErrNone;
+	}
+
+void CNullNif::Stop(TInt aReason, MNifIfNotify::TAction aAction)
+	{
+	iNotify->LinkLayerDown(aReason, aAction);
+	iNotify->IfProgress(EIfProgressLinkDown, aReason);
+	}
+
+TInt CNullNif::Notification(TAgentToNifEventType, void*)
+	{
+	return KErrNone;
+	}
+
+void CNullNif::Restart(CNifIfBase*)
+	{
+	}
+
+
+NONSHARABLE_CLASS(CNullNifIfFactory) : public CNifIfFactory
+	{
+protected:
+	virtual void InstallL();
+	virtual CNifIfBase* NewInterfaceL(const TDesC& aName);
+	TInt Info(TNifIfInfo& aInfo, TInt aIndex) const;
+	};
+
+TInt CNullNifIfFactory::Info(TNifIfInfo& aInfo, TInt) const
+	{
+	CNullNif::FillInInfo(aInfo);
+	return 1;
+	}
+
+void CNullNifIfFactory::InstallL()
+	{
+	}
+
+CNifIfBase* CNullNifIfFactory::NewInterfaceL(const TDesC& aName)
+	{
+	_LIT(KNullNif, "nullnif");
+	if (aName.CompareF(KNullNif))
+		{
+		User::Leave(KErrNotSupported);
+		}
+
+	return new (ELeave) CNullNif(*this);
+	}
+	
+// Force export of non-mangled name
+extern "C" { IMPORT_C CNifFactory *Install(); }
+
+EXPORT_C CNifFactory *Install()
+	{
+	return new (ELeave) CNullNifIfFactory;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/bwins/tcpcsyu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	LibEntry @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/doc/tcpcsy.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,59 @@
+# tcpcsy.pod
+#
+# Copyright (c) 2008-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 tcpcsy
+
+=head2 Introduction
+
+A C32 plug-in that provides serial port emulation over a TCP socket. The socket can be configured to either actively connect to its TCP peer, or to passively listen for a connection from the peer.
+
+=head2 Configuration
+
+Configuration of the ports is done via the Central Repository file 102836da.txt. This is expected to contain the following key space:
+
+ Bits	 Supported Values    Meaning
+
+ 31-24	 0                   Port record. Port fields assigned as follows:
+ 23-16   0                   Socket mode (type int, 0 - active, 1 - passive)
+         1                   Protocol family (type int)
+         2                   Protocol (type int)
+         3                   IP address (type string in valid form to be handled by TInetAddr::Input)
+         4                   Port (type int, the port to connect to in active mode or the port to
+                             listen on in passive mode)
+ 15-0    0-65535             C32 unit value
+
+For example:
+
+ # Port 0
+ 0x00000000	int	0		# Active socket.
+ 0x00010000	int	0x0800		# KAfInet.
+ 0x00020000	int	6		# KProtocolInetTcp.
+ 0x00030000	string	127.0.0.1	# IP address.
+ 0x00040000	int	3030		# Port.
+
+ # Port 1
+ 0x00000001	int	0		# Active socket.
+ 0x00010001	int	0x0800		# KAfInet.
+ 0x00020001	int	6		# KProtocolInetTcp.
+ 0x00030001	string	172.16.0.2	# IP address.
+ 0x00040001	int	3030		# Port.
+
+
+Note, the Central Repository file can be written to by any process with C<WriteDeviceData> capability. It is therefore possible to dynamically add new, and alter existing port configurations.
+
+=head1 Copyright
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/eabi/tcpcsyu.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2 @@
+EXPORTS
+	LibEntry @ 1 NONAME
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+// bld.inf
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+#ifdef FSHELL_TCPCSY_SUPPORT
+
+PRJ_MMPFILES
+..\src\tcpcsy.mmp
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/config.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,129 @@
+// config.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "panic.h"
+#include "tcpcsy.h"
+#include "config.h"
+
+
+const TUid KRepositoryUid = { 0x102836da };
+const TInt KModeField =			0x00000000;
+const TInt KFamilyField =		0x00010000;
+const TInt KProtocolField =		0x00020000;
+const TInt KIpAddressField =	0x00030000;
+const TInt KPortField =			0x00040000;
+
+
+CConfig* CConfig::NewL(CTcpPortFactory& aFactory)
+	{
+	CConfig* self = new(ELeave) CConfig(aFactory);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CConfig::~CConfig()
+	{
+	delete iRepository;
+	}
+
+CConfig::TMode CConfig::ModeL(const TUint aUnit) const
+	{
+	TInt mode = ReadIntL(KModeField, aUnit);
+	if ((mode < EActive) || (mode > EPassive))
+		{
+		User::Leave(KErrCorrupt);
+		}
+	return static_cast<TMode>(mode);
+	}
+
+TUint CConfig::ProtocolFamilyL(const TUint aUnit) const
+	{
+	return static_cast<TUint>(ReadIntL(KFamilyField, aUnit));
+	}
+
+TUint CConfig::ProtocolL(const TUint aUnit) const
+	{
+	return static_cast<TUint>(ReadIntL(KProtocolField, aUnit));
+	}
+
+void CConfig::GetAddressL(const TUint aUnit, TInetAddr& aAddress) const
+	{
+	TBuf<64> ip;
+	ReadStringL(KIpAddressField, aUnit, ip);
+	TInt err = aAddress.Input(ip);
+	if (err)
+		{
+		User::Leave(KErrCorrupt);
+		}
+	TUint port = static_cast<TUint>(ReadIntL(KPortField, aUnit));
+	aAddress.SetPort(port);
+	TPtr8 narrowIp = ip.Collapse();
+	LOG("Unit: %u, IP: \"%S\", Port: %u", aUnit, &narrowIp, port);
+	}
+
+void CConfig::UnitRange(TUint& aLowUnit, TUint& aHighUnit) const
+	{
+	TInt i = 0;
+	TInt val;
+	while (iRepository->Get(KModeField + i, val) != KErrNone)
+		{
+		++i;
+		}
+	aLowUnit = i;
+	while (iRepository->Get(KModeField + i, val) == KErrNone)
+		{
+		++i;
+		}
+	aHighUnit = Max(0, i - 1);
+	}
+
+CConfig::CConfig(CTcpPortFactory& aFactory)
+	: iFactory(aFactory)
+	{
+	}
+
+void CConfig::ConstructL()
+	{
+	iRepository = CRepository::NewL(KRepositoryUid);
+	}
+
+TInt CConfig::ReadIntL(TInt aFieldId, const TUint aUnit) const
+	{
+	if (aUnit > KMaxTUint16)
+		{
+		User::Leave(KErrArgument);
+		}
+	TInt val;
+	TInt err = iRepository->Get(aFieldId + aUnit, val);
+	if (err == KErrNotFound)
+		{
+		err = KErrNotSupported;
+		}
+	User::LeaveIfError(err);
+	return val;
+	}
+
+void CConfig::ReadStringL(TInt aFieldId, const TUint aUnit, TDes& aString) const
+	{
+	if (aUnit > KMaxTUint16)
+		{
+		User::Leave(KErrArgument);
+		}
+	TInt err = iRepository->Get(aFieldId + aUnit, aString);
+	if (err == KErrNotFound)
+		{
+		err = KErrNotSupported;
+		}
+	User::LeaveIfError(err);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/config.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,52 @@
+// config.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include <in_sock.h>
+#include <centralrepository.h>
+
+
+class CTcpPortFactory;
+
+
+class CConfig : public CBase
+	{
+public:
+	enum TMode
+		{
+		EActive,
+		EPassive
+		};
+public:
+	static CConfig* NewL(CTcpPortFactory& aFactory);
+	~CConfig();
+	TMode ModeL(const TUint aUnit) const;
+	TUint ProtocolFamilyL(const TUint aUnit) const;
+	TUint ProtocolL(const TUint aUnit) const;
+	void GetAddressL(const TUint aUnit, TInetAddr& aAddress) const;
+	void UnitRange(TUint& aLowUnit, TUint& aHighUnit) const;
+private:
+	CConfig(CTcpPortFactory& aFactory);
+	void ConstructL();
+	TInt ReadIntL(TInt aFieldId, const TUint aUnit) const;
+	void ReadStringL(TInt aFieldId, const TUint aUnit, TDes& aString) const;
+private:
+	CTcpPortFactory& iFactory;
+	CRepository* iRepository;
+	};
+
+
+#endif // __CONFIG_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/connector.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,51 @@
+// connector.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "connector.h"
+
+CConnector* CConnector::NewL(RSocketServ& aSocketServ, RSocket& aSocket, TUint aProtocolFamily, TUint aProtocol, const TSockAddr& aSockAddr, MConnectorObserver& aObserver)
+	{
+	CConnector* self = new(ELeave) CConnector(aSocket, aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL(aSocketServ, aProtocolFamily, aProtocol, aSockAddr);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CConnector::~CConnector()
+	{
+	Cancel();
+	}
+
+CConnector::CConnector(RSocket& aSocket, MConnectorObserver& aObserver)
+	: CActive(CActive::EPriorityStandard), iSocket(aSocket), iObserver(aObserver)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CConnector::ConstructL(RSocketServ& aSocketServ, TUint aProtocolFamily, TUint aProtocol, const TSockAddr& aSockAddr)
+	{
+	User::LeaveIfError(iSocket.Open(aSocketServ, aProtocolFamily, KSockStream, aProtocol));
+	iSocket.Connect(const_cast<TSockAddr&>(aSockAddr), iStatus);
+	SetActive();
+	}
+
+void CConnector::RunL()
+	{
+	iObserver.ConnectionComplete(iStatus.Int());
+	}
+
+void CConnector::DoCancel()
+	{
+	iSocket.CancelConnect();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/connector.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// connector.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __CONNECTOR_H__
+#define __CONNECTOR_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include <es_sock.h>
+
+
+class MConnectorObserver
+	{
+public:
+	virtual void ConnectionComplete(TInt aError) = 0;
+	};
+
+
+class CConnector : public CActive
+	{
+public:
+	static CConnector* NewL(RSocketServ& aSocketServ, RSocket& aSocket, TUint aProtocolFamily, TUint aProtocol, const TSockAddr& aSockAddr, MConnectorObserver& aObserver);
+	~CConnector();
+private:
+	CConnector(RSocket& aSocket, MConnectorObserver& aObserver);
+	void ConstructL(RSocketServ& aSocketServ, TUint aProtocolFamily, TUint aProtocol, const TSockAddr& aSockAddr);
+private: // From CActive.
+	void RunL();
+	void DoCancel();
+private:
+	RSocket& iSocket;
+	MConnectorObserver& iObserver;
+	};
+
+#endif // __CONNECTOR_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/listener.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,55 @@
+// listener.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "Listener.h"
+
+CListener* CListener::NewL(RSocketServ& aSocketServ, RSocket& aSocket, TUint aProtocolFamily, TUint aProtocol, const TSockAddr& aSockAddr, MListenerObserver& aObserver)
+	{
+	CListener* self = new(ELeave) CListener(aSocket, aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL(aSocketServ, aProtocolFamily, aProtocol, aSockAddr);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CListener::~CListener()
+	{
+	Cancel();
+	iListeningSocket.Close();
+	}
+
+CListener::CListener(RSocket& aSocket, MListenerObserver& aObserver)
+	: CActive(CActive::EPriorityStandard), iSocket(aSocket), iObserver(aObserver)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CListener::ConstructL(RSocketServ& aSocketServ, TUint aProtocolFamily, TUint aProtocol, const TSockAddr& aSockAddr)
+	{
+	User::LeaveIfError(iSocket.Open(aSocketServ));
+	User::LeaveIfError(iListeningSocket.Open(aSocketServ, aProtocolFamily, KSockStream, aProtocol));
+	User::LeaveIfError(iListeningSocket.Bind(const_cast<TSockAddr&>(aSockAddr)));
+	User::LeaveIfError(iListeningSocket.Listen(1));
+	iListeningSocket.Accept(iSocket, iStatus);
+	SetActive();
+	}
+
+void CListener::RunL()
+	{
+	iObserver.ListenComplete(iStatus.Int());
+	}
+
+void CListener::DoCancel()
+	{
+	iSocket.CancelAccept();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/listener.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,46 @@
+// listener.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __LISTENER_H__
+#define __LISTENER_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include <es_sock.h>
+
+
+class MListenerObserver
+	{
+public:
+	virtual void ListenComplete(TInt aError) = 0;
+	};
+
+
+class CListener : public CActive
+	{
+public:
+	static CListener* NewL(RSocketServ& aSocketServ, RSocket& aSocket, TUint aProtocolFamily, TUint aProtocol, const TSockAddr& aSockAddr, MListenerObserver& aObserver);
+	~CListener();
+private:
+	CListener(RSocket& aSocket, MListenerObserver& aObserver);
+	void ConstructL(RSocketServ& aSocketServ, TUint aProtocolFamily, TUint aProtocol, const TSockAddr& aSockAddr);
+private: // From CActive.
+	void RunL();
+	void DoCancel();
+private:
+	RSocket& iSocket;
+	RSocket iListeningSocket;
+	MListenerObserver& iObserver;
+	};
+
+#endif // __LISTENER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/panic.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,21 @@
+// panic.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+enum TTcpCsyPanicReason
+	{
+	EPanicInvalidReadMode,
+	EPanicReadAlreadyPending,
+	EPanicWriteAlreadyPending,
+	};
+
+void Panic(TTcpCsyPanicReason aReason);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/reader.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,116 @@
+// reader.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "reader.h"
+#include "panic.h"
+
+
+CReader* CReader::NewL(RSocket& aSocket, MReaderObserver& aObserver)
+	{
+	return new(ELeave) CReader(aSocket, aObserver);
+	}
+
+CReader::~CReader()
+	{
+	Cancel();
+	iBuffer.Close();
+	}
+
+void CReader::StartRead(TInt aLength, TReadMode aMode)
+	{
+	__ASSERT_DEBUG(!IsActive() && (iPendingLength == 0), Panic(EPanicReadAlreadyPending));
+
+	if (iBuffer.MaxLength() < aLength)
+		{
+		TInt err = iBuffer.ReAlloc(aLength);
+		if (err)
+			{
+			iObserver.ReadError(err);
+			return;
+			}
+		}
+
+	if (Connected())
+		{
+		iBuffer.Zero();
+
+		switch (aMode)
+			{
+			case EFull:
+				{
+				iSocket.Recv(iBuffer, 0, iStatus);
+				break;
+				}
+			case EOneOrMore:
+				{
+				iSocket.RecvOneOrMore(iBuffer, 0, iStatus, iXfrLength);
+				break;
+				}
+			default:
+				{
+				__ASSERT_DEBUG(EFalse, Panic(EPanicInvalidReadMode));
+				}
+			};
+
+		SetActive();
+		}
+	else
+		{
+		iPendingLength = aLength;
+		iPendingMode = aMode;
+		}
+	}
+
+void CReader::GetBufferLength(TInt& aLength)
+	{
+	aLength = iBuffer.Length();
+	}
+
+void CReader::Abort()
+	{
+	iPendingLength = 0;
+	Cancel();
+	}
+
+void CReader::HandleSocketConnected()
+	{
+	if (iPendingLength > 0)
+		{
+		TInt pendingLength = iPendingLength;
+		iPendingLength = 0;
+		StartRead(pendingLength, iPendingMode);
+		}
+	}
+
+CReader::CReader(RSocket& aSocket, MReaderObserver& aObserver)
+	: CSocketUser(aSocket), iObserver(aObserver)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CReader::RunL()
+	{
+	if (iStatus.Int())
+		{
+		iObserver.ReadError(iStatus.Int());
+		}
+	else
+		{
+		iObserver.ReadComplete(iBuffer);
+		}
+	}
+
+void CReader::DoCancel()
+	{
+	iSocket.CancelRecv();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/reader.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,59 @@
+// reader.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __READER_H__
+#define __READER_H__
+
+#include <e32std.h>
+#include "socketuser.h"
+
+
+class MReaderObserver
+	{
+public:
+	virtual void ReadComplete(const TDesC8& aData) = 0;
+	virtual void ReadError(TInt aError) = 0;
+	};
+
+
+class CReader : public CSocketUser
+	{
+public:
+	enum TReadMode
+		{
+		EFull,
+		EOneOrMore
+		};
+public:
+	static CReader* NewL(RSocket& aSocket, MReaderObserver& aObserver);
+	~CReader();
+	void StartRead(TInt aLength, TReadMode aMode);
+	void GetBufferLength(TInt& aLength);
+	void Abort();
+private:
+	CReader(RSocket& aSocket, MReaderObserver& aObserver);
+	void ConstructL();
+private: // From CActive.
+	void RunL();
+	void DoCancel();
+private: // From CSocketUser.
+	virtual void HandleSocketConnected();
+private:
+	MReaderObserver& iObserver;
+	TSockXfrLength iXfrLength;
+	TInt iPendingLength;
+	TReadMode iPendingMode;
+	RBuf8 iBuffer;
+	};
+
+#endif // __READER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/socketuser.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+// socketuser.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "socketuser.h"
+
+void CSocketUser::SocketConnected()
+	{
+	iConnected = ETrue;
+	HandleSocketConnected();
+	}
+
+CSocketUser::CSocketUser(RSocket& aSocket)
+	: CActive(CActive::EPriorityStandard), iSocket(aSocket)
+	{
+	}
+
+CSocketUser::~CSocketUser()
+	{
+	}
+
+TBool CSocketUser::Connected() const
+	{
+	return iConnected;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/socketuser.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// socketuser.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __SOCKETUSER_H__
+#define __SOCKETUSER_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include <es_sock.h>
+
+
+class CSocketUser : public CActive
+	{
+public:
+	void SocketConnected();
+protected:
+	CSocketUser(RSocket& aSocket);
+	~CSocketUser();
+	TBool Connected() const;
+	virtual void HandleSocketConnected() = 0;
+protected:
+	RSocket& iSocket;
+private:
+	TBool iConnected;
+	};
+
+
+#endif // __SOCKETUSER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/tcpcsy.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,457 @@
+// tcpcsy.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <c32comm.h>
+#include "panic.h"
+#include "tcpcsy.h"
+#include "tcpcsylog.h"
+
+
+//
+// CTcpPort.
+//
+
+TInt CTcpPort::LinkOffset()
+	{
+	return _FOFF(CTcpPort, iLink);
+	}
+
+CTcpPort* CTcpPort::NewLC(CTcpPortFactory& aFactory, CConfig::TMode aMode, TUint aProtocolFamily, TUint aProtocol, const TInetAddr& aAddress, RSocketServ& aSocketServ)
+	{
+	CTcpPort* self = new(ELeave) CTcpPort(aFactory);
+	CleanupClosePushL(*self);
+	self->ConstructL(aMode, aProtocolFamily, aProtocol, aAddress, aSocketServ);
+	return self;
+	}
+
+CTcpPort::CTcpPort(CTcpPortFactory& aFactory)
+	: iFactory(aFactory)
+	{
+	LOG("Created new CTcpPort object 0x%08x", this);
+	}
+
+void CTcpPort::ConstructL(CConfig::TMode aMode, TUint aProtocolFamily, TUint aProtocol, const TInetAddr& aAddress, RSocketServ& aSocketServ)
+	{
+	iInetAddr = aAddress;
+
+	if (aMode == CConfig::EActive)
+		{
+		iConnector = CConnector::NewL(aSocketServ, iSocket, aProtocolFamily, aProtocol, iInetAddr, *this);
+		}
+	else
+		{
+		iListener = CListener::NewL(aSocketServ, iSocket, aProtocolFamily, aProtocol, iInetAddr, *this);
+		}
+
+	iReader = CReader::NewL(iSocket, *this);
+	iWriter = CWriter::NewL(iSocket, *this);
+	}
+
+CTcpPort::~CTcpPort()
+	{
+	delete iWriter;
+	delete iReader;
+	delete iConnector;
+	if (iSocketConnected)
+		{
+		TRequestStatus status;
+		iSocket.Shutdown(RSocket::ENormal, status);
+		User::WaitForRequest(status);
+		iSocket.Close();
+		}
+	iLink.Deque();
+	}
+
+void CTcpPort::StartRead(const TAny*, TInt aLength)
+	{
+	LOG("CTcpPort::StartRead this=0x%08x, aLength=%d", this, aLength);
+
+	if (iError)
+		{
+		ReadError(iError);
+		}
+	else if (aLength == 0)
+		{
+		ReadCompleted(KErrNone);
+		}
+	else
+		{
+		if (aLength < 0)
+			{
+			iReader->StartRead(-aLength, CReader::EOneOrMore);
+			}
+		else
+			{
+			iReader->StartRead(aLength, CReader::EFull);
+			}
+		}
+	}
+
+void CTcpPort::ReadCancel()
+	{
+	LOG("CTcpPort::ReadCancel this=0x%08x", this);
+	iReader->Abort();
+	ReadError(KErrCancel);
+	}
+
+TInt CTcpPort::QueryReceiveBuffer(TInt& aLength) const
+	{
+	iReader->GetBufferLength(aLength);
+	return KErrNone;
+	}
+
+void CTcpPort::ResetBuffers(TUint)
+	{
+	// Doesn't really have much meaning for the TCPCSY as reads and writes are mapped directly onto RSocket calls.
+	}
+
+void CTcpPort::StartWrite(const TAny* aClientBuffer, TInt aLength)
+	{
+	LOG("CTcpPort::StartWrite this=0x%08x, aClientBuff=0x%08x, aLength=%d", this, aClientBuffer, aLength);
+	
+	TInt err = KErrNone;
+
+	if (iError)
+		{
+		err = iError;
+		}
+	else if (aLength > 0)
+		{
+		if (iWriteBuf.MaxLength() < aLength)
+			{
+			err = iWriteBuf.ReAlloc(aLength);
+			}
+
+		if (err == KErrNone)
+			{
+			iWriteBuf.Zero();
+			err = IPCRead(aClientBuffer, iWriteBuf, 0);
+			if (err == KErrNone)
+				{
+				iWriter->StartWrite(iWriteBuf);
+				}
+			}
+		}
+
+	if (err || (aLength == 0))
+		{
+		WriteComplete(err);
+		}
+	}
+
+void CTcpPort::WriteCancel()
+	{
+	LOG("CTcpPort::WriteCancel this=0x%08x", this);
+	iWriter->Abort();
+	WriteComplete(KErrCancel);
+	}
+
+void CTcpPort::Break(TInt)
+	{
+	}
+
+void CTcpPort::BreakCancel()
+	{
+	}
+
+TInt CTcpPort::GetConfig(TDes8&) const
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::SetConfig(const TDesC8&)
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::GetCaps(TDes8&)
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::SetServerConfig(const TDesC8&)
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::GetServerConfig(TDes8&)
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::GetSignals(TUint&)
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::SetSignalsToMark(TUint)
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::SetSignalsToSpace(TUint)
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::GetReceiveBufferLength(TInt&) const
+	{
+	return KErrNone;
+	}
+
+TInt CTcpPort::SetReceiveBufferLength(TInt)
+	{
+	return KErrNone;
+	}
+
+void CTcpPort::Destruct()
+	{
+	delete this;
+	}
+
+void CTcpPort::NotifySignalChange(TUint)
+	{
+	}
+
+void CTcpPort::NotifySignalChangeCancel()
+	{
+	}
+
+
+void CTcpPort::NotifyConfigChange()
+	{
+	}
+
+void CTcpPort::NotifyConfigChangeCancel()
+	{
+	}
+
+void CTcpPort::NotifyFlowControlChange()
+	{
+	}
+
+void CTcpPort::NotifyFlowControlChangeCancel()
+	{
+	}
+
+void CTcpPort::NotifyBreak()
+	{
+	}
+
+void CTcpPort::NotifyBreakCancel()
+	{
+	}
+
+void CTcpPort::NotifyDataAvailable()
+	{
+	}
+
+void CTcpPort::NotifyDataAvailableCancel()
+	{
+	}
+
+void CTcpPort::NotifyOutputEmpty()
+	{
+	}
+
+void CTcpPort::NotifyOutputEmptyCancel()
+	{
+	}
+
+TInt CTcpPort::GetFlowControlStatus(TFlowControl&)
+	{
+	return KErrNotSupported;
+	}
+
+TInt CTcpPort::GetRole(TCommRole& aRole)
+	{
+	aRole = iRole;
+	return KErrNone;
+	}
+
+TInt CTcpPort::SetRole(TCommRole aRole)
+	{
+	iRole = aRole;
+	return KErrNone;
+	}
+
+void CTcpPort::FreeMemory()
+	{
+	}
+
+void CTcpPort::ConnectionComplete(TInt aError)
+	{
+	LOG("CTcpPort::ConnectionComplete this=0x%08x, aError=%d", this, aError);
+	if (aError == KErrNone)
+		{
+		iSocketConnected = ETrue;
+		iReader->SocketConnected();
+		iWriter->SocketConnected();
+		}
+	else
+		{
+		iError = aError;
+		}
+	}
+
+void CTcpPort::ListenComplete(TInt aError)
+	{
+	LOG("CTcpPort::ListenComplete this=0x%08x, aError=%d", this, aError);
+	if (aError == KErrNone)
+		{
+		iReader->SocketConnected();
+		iWriter->SocketConnected();
+		}
+	else
+		{
+		iError = aError;
+		}
+	}
+
+void CTcpPort::ReadComplete(const TDesC8& aData)
+	{
+	LOG("CTcpPort::ReadComplete this=0x%08x", this);
+	TInt err = IPCWrite(NULL, aData, 0);
+	ReadCompleted(KErrNone);
+	}
+
+void CTcpPort::ReadError(TInt aError)
+	{
+	LOG("CTcpPort::ReadError this=0x%08x, aError=%d", this, aError);
+	ReadCompleted(aError);
+	}
+
+void CTcpPort::WriteComplete(TInt aError)
+	{
+	LOG("CTcpPort::WriteComplete this=0x%08x, aError=%d", this, aError);
+	WriteCompleted(aError);
+	}
+
+
+
+//
+// CTcpPortFactory.
+//
+
+CTcpPortFactory* CTcpPortFactory::NewL()
+	{
+	CTcpPortFactory* self = new(ELeave)CTcpPortFactory;
+	CleanupClosePushL(*self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CPort* CTcpPortFactory::NewPortL(const TUint aUnit)
+	{
+	TInetAddr inetAddr;
+	iConfig->GetAddressL(aUnit, inetAddr);
+	CTcpPort* port = CTcpPort::NewLC(*this, iConfig->ModeL(aUnit), iConfig->ProtocolFamilyL(aUnit), iConfig->ProtocolL(aUnit), inetAddr, iSocketServ);
+	TBuf<10> name;
+	name.Num(aUnit);
+	port->SetNameL(&name);
+	CleanupStack::Pop(port);
+	iPorts.AddLast(*port);
+	return port;
+	}
+
+void CTcpPortFactory::Info(TSerialInfo& aSerialInfo)
+/**
+ * This method fills information into the passed structure.  It is required for factory objects.
+ *
+ * @param	aSerialInfo		-	a reference to the structure to fill in.
+ *
+ * @return	None
+ */
+	{
+	aSerialInfo.iDescription = KCsyName;
+	aSerialInfo.iName = KCsyName;
+	iConfig->UnitRange(aSerialInfo.iLowUnit, aSerialInfo.iHighUnit);
+	}
+
+CTcpPortFactory::CTcpPortFactory()
+	: iPorts(CTcpPort::LinkOffset())
+	{
+	}
+
+void CTcpPortFactory::ConstructL()
+	{
+#ifdef __FLOG_ACTIVE	
+	
+#ifdef LOG_CSY_EVENTS
+#pragma message("General logging enabled")
+	(void) iEventLogger.Connect();
+	iEventLogger.SetLogTags(KDebugSubSystem(), KDebugCategoryEvents());
+#endif // LOG_CSY_EVENTS
+
+#ifdef LOG_CSY_TX
+#pragma message("Tx logging enabled")
+	(void) iTxLogger.Connect();
+	iTxLogger.SetLogTags(KDebugSubSystem(), KDebugCategoryTx());
+#endif // LOG_CSY_TX
+
+#ifdef LOG_CSY_RX
+#pragma message("Rx logging enabled")
+	(void) iRxLogger.Connect();
+	iRxLogger.SetLogTags(KDebugSubSystem(), KDebugCategoryRx());
+#endif // LOG_CSY_RX
+
+#endif // __FLOG_ACTIVE
+
+	SetNameL(&(KCsyName()));
+	iConfig = CConfig::NewL(*this);
+	User::LeaveIfError(iSocketServ.Connect());
+	}
+	
+CTcpPortFactory::~CTcpPortFactory()
+	{
+	delete iConfig;
+	iSocketServ.Close();
+
+#ifdef __FLOG_ACTIVE
+
+#ifdef LOG_CSY_EVENTS
+	iEventLogger.Close();
+#endif // LOG_CSY_EVENTS
+
+#ifdef LOG_CSY_TX
+	iTxLogger.Close();
+#endif // LOG_CSY_TX
+
+#ifdef LOG_CSY_RX
+	iRxLogger.Close();
+#endif // LOG_CSY_RX
+
+#endif // __FLOG_ACTIVE
+	}
+	
+TSecurityPolicy CTcpPortFactory::PortPlatSecCapability(TUint /*aPort*/) const
+	{
+	return TSecurityPolicy(ECapabilityNetworkServices);
+	}
+
+extern "C"
+	{
+	IMPORT_C CSerial * LibEntry(void);
+	}
+
+
+EXPORT_C CSerial* LibEntry(void)
+	{
+	return CTcpPortFactory::NewL();
+	}
+
+void Panic(TTcpCsyPanicReason aReason)
+	{
+	_LIT(KCategory, "tcpcsy");
+	User::Panic(KCategory(), aReason);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/tcpcsy.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,148 @@
+// tcpcsy.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __TCPCSY_H__
+#define __TCPCSY_H__
+
+
+#include <cs_port.h>
+#include "config.h"
+#include "reader.h"
+#include "writer.h"
+#include "connector.h"
+#include "listener.h"
+#include "tcpcsylog.h"
+
+
+//
+// Constants.
+//
+
+_LIT(KCsyName, "tcpcsy");
+
+
+//
+// Forward declarations.
+//
+class CTcpPort;
+
+
+//
+// Class Definitions.
+//
+
+
+class CTcpPortFactory : public CSerial
+	{
+public:
+    static CTcpPortFactory* NewL();
+    ~CTcpPortFactory();
+private:	// From CSerial.
+	virtual CPort * NewPortL(const TUint aUnit);
+	virtual void Info(TSerialInfo &aSerialInfo);
+	virtual TSecurityPolicy PortPlatSecCapability(TUint aPort) const;
+private:
+	CTcpPortFactory();
+	void ConstructL();
+private:
+	RSocketServ iSocketServ;
+	CConfig* iConfig;
+	TDblQue<CTcpPort> iPorts;
+public:
+#ifdef __FLOG_ACTIVE
+
+#ifdef LOG_CSY_EVENTS
+	RFileLogger iEventLogger;
+#endif // LOG_CSY_EVENTS
+
+#ifdef LOG_CSY_TX
+	RFileLogger iTxLogger;
+#endif // LOG_CSY_TX
+
+#ifdef LOG_CSY_RX
+	RFileLogger iRxLogger;
+#endif // LOG_CSY_RX
+
+#endif // __FLOG_ACTIVE
+	};
+
+
+class CTcpPort : public CPort, public MConnectorObserver, public MListenerObserver, public MReaderObserver, public MWriterObserver
+	{
+public:
+	static TInt LinkOffset();
+	static CTcpPort* NewLC(CTcpPortFactory& aFactory, CConfig::TMode aMode, TUint aProtocolFamily, TUint aProtocol, const TInetAddr& aAddress, RSocketServ& aSocketServ);
+public:	// From CPort.
+	virtual void StartRead(const TAny* aClientBuffer, TInt aLength);
+	virtual void ReadCancel();
+	virtual TInt QueryReceiveBuffer(TInt& aLength) const;
+	virtual void ResetBuffers(TUint aFlags);
+	virtual void StartWrite(const TAny* aClientBuffer, TInt aLength);
+	virtual void WriteCancel();
+	virtual void Break(TInt aTime);
+	virtual void BreakCancel();
+	virtual TInt GetConfig(TDes8& aDes) const;
+	virtual TInt SetConfig(const TDesC8& aDes);
+	virtual TInt SetServerConfig(const TDesC8& aDes);
+	virtual TInt GetServerConfig(TDes8& aDes);
+	virtual TInt GetCaps(TDes8& aDes);
+	virtual TInt GetSignals(TUint& aSignals);
+	virtual TInt SetSignalsToMark(TUint aSignals);
+	virtual TInt SetSignalsToSpace(TUint aSignals);
+	virtual TInt GetReceiveBufferLength(TInt& aLength) const;
+	virtual TInt SetReceiveBufferLength(TInt aSignals);
+	virtual void Destruct();
+	virtual void FreeMemory();
+	virtual void NotifySignalChange(TUint aSignalMask);
+	virtual void NotifySignalChangeCancel();
+	virtual void NotifyConfigChange();
+	virtual void NotifyConfigChangeCancel();
+	virtual void NotifyFlowControlChange();
+	virtual void NotifyFlowControlChangeCancel();
+	virtual void NotifyBreak();
+	virtual void NotifyBreakCancel();
+	virtual void NotifyDataAvailable();
+	virtual void NotifyDataAvailableCancel();
+	virtual void NotifyOutputEmpty();
+	virtual void NotifyOutputEmptyCancel();
+	virtual TInt GetFlowControlStatus(TFlowControl& aFlowControl);
+	virtual TInt GetRole(TCommRole& aRole);
+	virtual TInt SetRole(TCommRole aRole);
+public: // From MConnectorObserver.
+	virtual void ConnectionComplete(TInt aError);
+public: // From MListenerObserver.
+	virtual void ListenComplete(TInt aError);
+public: // From MReaderObserver.
+	virtual void ReadComplete(const TDesC8& aData);
+	virtual void ReadError(TInt aError);
+public: // From MWriterObserver.
+	virtual void WriteComplete(TInt aError);
+private:
+	virtual ~CTcpPort();
+	CTcpPort(CTcpPortFactory& aFactory);
+	void ConstructL(CConfig::TMode aMode, TUint aProtocolFamily, TUint aProtocol, const TInetAddr& aAddress, RSocketServ& aSocketServ);
+private:
+	TDblQueLink iLink;
+	CTcpPortFactory& iFactory;
+	RSocket iSocket;
+	TBool iSocketConnected;
+	CConnector* iConnector;
+	CListener* iListener;
+	CReader* iReader;
+	CWriter* iWriter;
+	RBuf8 iWriteBuf;
+	TInt iError;
+	TInetAddr iInetAddr;
+	TCommRole iRole;
+	};
+
+#endif // __TCPCSY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/tcpcsy.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+// tcpcsy.mmp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+srcdbg
+target        tcpcsy.csy
+capability    CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData
+targettype    dll
+uid           0x10005054 FSHELL_UID_TCPCSY
+
+NOEXPORTLIBRARY
+
+userinclude   .
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath    .
+source        tcpcsy.cpp
+source        config.cpp
+source        reader.cpp
+source        writer.cpp
+source        connector.cpp
+source        listener.cpp
+source        socketuser.cpp
+
+
+library       euser.lib
+library       c32.lib
+library       esock.lib
+library       insock.lib
+library       centralrepository.lib
+
+// This macro enables general logging, function entry, events, etc..
+//MACRO LOG_CSY_EVENTS
+// This macro enables logging of Tx data
+//MACRO LOG_CSY_TX
+// This macro enables logging of Rx data
+//MACRO LOG_CSY_RX
+
+#include <comms-infras/commsdebugutility.mmh>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/tcpcsylog.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,60 @@
+// tcpcsylog.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __TCPCSYLOG_H__
+#define __TCPCSYLOG_H__
+
+#include <e32std.h>
+#include <comms-infras/commsdebugutility.h>
+
+// The following 4 macros define the level of logging in udeb.
+// The macros are (un)defined in the tcpcsy.mmp file.
+
+#ifdef __FLOG_ACTIVE
+
+_LIT8(KDebugSubSystem, "fshell");
+
+#ifdef LOG_CSY_EVENTS
+_LIT8(KDebugCategoryEvents, "tcpcsy_event");
+_LIT8(KDebugCategoryEventsStatic, "tcpcsy_static");
+#define LOG(A,ARGS...)         {_LIT8(KA,A);this->iFactory.iEventLogger.WriteFormat(KA(),##ARGS);}
+#define LOG_STATIC(A,ARGS...)  {_LIT8(KA,A);__FLOG_STATIC_VA((KDebugSubSystem(),KDebugCategoryEventsStatic(),KA(),##ARGS));}
+#else
+#define LOG(A,ARGS...)
+#define LOG_STATIC(A,ARGS...)
+#endif // LOG_CSY_EVENTS
+
+#ifdef LOG_CSY_TX
+_LIT8(KDebugCategoryTx, "tcpcsy_tx");
+#define LOGTx(A,ARGS...)       {_LIT8(KA,A);this->iFactory.iTxLogger.WriteFormat(KA(),##ARGS);}
+#else
+#define LOGTx(A,ARGS...)
+#endif // LOG_CSY_TX
+
+#ifdef LOG_CSY_RX
+_LIT8(KDebugCategoryRx, "tcpcsy_rx");
+#define LOGRx(A,ARGS...)       {_LIT8(KA,A);this->iFactory.iRxLogger.WriteFormat(KA(),##ARGS);}
+#else
+#define LOGRx(A,ARGS...)
+#endif // LOG_CSY_RX
+
+#else
+
+#define LOG(A,ARGS...)
+#define LOGTx(A,ARGS...)
+#define LOGRx(A,ARGS...)
+#define LOG_STATIC(A,ARGS...)
+
+#endif // __FLOG_ACTIVE
+
+
+#endif // __TCPCSYLOG_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/writer.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,72 @@
+// writer.cpp
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "writer.h"
+#include "panic.h"
+
+
+CWriter* CWriter::NewL(RSocket& aSocket, MWriterObserver& aObserver)
+	{
+	return new(ELeave) CWriter(aSocket, aObserver);
+	}
+
+CWriter::~CWriter()
+	{
+	Cancel();
+	}
+
+void CWriter::StartWrite(const TDesC8& aDes)
+	{
+	__ASSERT_DEBUG(!IsActive() && (iPendingDes == NULL), Panic(EPanicWriteAlreadyPending));
+
+	if (Connected())
+		{
+		iSocket.Send(aDes, 0, iStatus);
+		SetActive();
+		}
+	else
+		{
+		iPendingDes = &aDes;
+		}
+	}
+
+void CWriter::Abort()
+	{
+	iPendingDes = NULL;
+	Cancel();
+	}
+
+void CWriter::HandleSocketConnected()
+	{
+	if (iPendingDes)
+		{
+		const TDesC8* pendingDes = iPendingDes;
+		iPendingDes = NULL;
+		StartWrite(*pendingDes);
+		}
+	}
+
+CWriter::CWriter(RSocket& aSocket, MWriterObserver& aObserver)
+	: CSocketUser(aSocket), iObserver(aObserver)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+void CWriter::RunL()
+	{
+	iObserver.WriteComplete(iStatus.Int());
+	}
+
+void CWriter::DoCancel()
+	{
+	iSocket.CancelSend();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/src/writer.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,47 @@
+// writer.h
+// 
+// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WRITER_H__
+#define __WRITER_H__
+
+#include <e32std.h>
+#include "socketuser.h"
+
+
+class MWriterObserver
+	{
+public:
+	virtual void WriteComplete(TInt aError) = 0;
+	};
+
+
+class CWriter : public CSocketUser
+	{
+public:
+	static CWriter* NewL(RSocket& aSocket, MWriterObserver& aObserver);
+	~CWriter();
+	void StartWrite(const TDesC8& aDes);
+	void Abort();
+private:
+	CWriter(RSocket& aSocket, MWriterObserver& aObserver);
+private: // From CActive.
+	void RunL();
+	void DoCancel();
+private: // From CSocketUser.
+	virtual void HandleSocketConnected();
+private:
+	MWriterObserver& iObserver;
+	const TDesC8* iPendingDes;
+	};
+
+#endif // __WRITER_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/tcpcsy/test/listen.pl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,34 @@
+# listen.pl
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+use strict;
+use IO::Socket;
+
+my $server_port = 3030;
+
+my $server = IO::Socket::INET->new(LocalPort => $server_port,
+                                Type      => SOCK_STREAM,
+                                Reuse     => 1,
+                                Listen    => 10 )   # or SOMAXCONN
+    or die "Couldn't be a tcp server on port $server_port : $@\n";
+
+while (my $client = $server->accept()) {
+	print "New client connected\n";
+	while (my $line = <$client>) {
+		print "Received: \"$line\"\n";
+	}
+	print "Client disconnected\n";
+	close ($client);
+}
+
+close($server);
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/bwins/winsocku.def	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	InstallWinSockPrt @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/data/dwinsockprt.esk	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,11 @@
+[sockman]
+protocols= winsocktcp,winsockudp
+
+[winsocktcp]
+filename= winsock.prt
+index= 1
+
+[winsockudp]
+filename= winsock.prt
+index= 2
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/data/winsockprt.esk	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+[sockman]
+protocols= winsocktcp,winsockudp,tcp,udp,ip
+
+[winsocktcp]
+filename= winsock.prt
+index= 1
+
+[winsockudp]
+filename= winsock.prt
+index= 2
+
+[tcp]
+filename= winsock.prt
+index= 3
+
+[udp]
+filename= winsock.prt
+index= 4
+
+[ip]
+filename= winsock.prt
+index= 5
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/docs/winsockprt.pod	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,80 @@
+# winsockprt.cif
+#
+# Copyright (c) 2007-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+__END__
+
+=head1 winsockprt
+
+=head2 Introduction
+
+C<winsockprt> is a Symbian OS network protocol module (a plug-in to ESock) that allows Symbian OS sockets to communicate via underlying WinSock sockets.
+
+There are various means of providing the Symbian OS emulator with a network connection (including WinTAP and NT-RAS). In the most part these other technologies are preferable to C<winsockprt> because they use the real Symbian TCP/IP stack, and so provide a more faithful emulation. However, they also tend to be more complex to configure. By contrast, C<winsockprt> is enabled with a single command and needs no further configuration.
+
+=head2 Installation
+
+Beyond building F<fshell> for your development environment, there is no further installation necessary.
+
+=head2 Usage
+
+By default C<winsockprt> is disabled. To enable it, type:
+
+  wsp enable
+
+or
+
+  wsp e
+
+Once it is enabled, any attempt by Symbian code to open a socket (or resolver) on the implicit connection (i.e. without using C<RConnection>) will result in C<winsockprt> interacting with the WinSock library to provide a connection.
+
+To disable C<winsockprt> and go back to using the Symbian TCP/IP stack, type:
+
+  wsp disable
+
+or
+
+  wsp d
+
+To see the current state of the C<winsockprt>, type:
+
+  wsp status
+
+or
+
+  wsp s
+
+=head2 Caveats
+
+No attempt is made to intercept the C<RConnection> API, which means that code that uses this will continue to attempt to establish a real connection. If this succeeds, then any sockets attached to the connection will again be routed through the WinSock library. However, if it was possible to establish a real connection, then there probably isn't much point in using C<winsockprt> - better to disable it and go back to using the real TCP/IP stack.
+
+=head2 Explicit Usage
+
+It is actually still possible to open C<winsockprt> sockets even when the module is disabled. Disabled only means that the module isn't taking the place of the Symbian TCP/IP stack. Whether disabled or not, C<winsockprt> always registers the following protocols with ESock and makes them available to clients:
+
+  KProtocolWinsockTcp
+  KProtocolWinsockUdp
+
+These are defined in F<\epoc32\include\winsockprt.h> and allow software to explicitly use WinSock sockets along side normal Symbian sockets. This facility can be used by L<rcons|rcons> to provide remote console via WinSock on the emulator without distrupting other TCP/IP clients.
+
+=head2 Future Development
+
+Old versions of C<winsockprt> used to replace various parts of the Symbian networking sub-system in order to try to convince clients that a suitable connection is available. In the multi-homed world of modern Symbian OS releases this behaviour is probably not appropriate. Instead therefore, to use C<winsockprt> from via software the opens an explicit C<RConnection> suitable IAP and Network entries will need to be present in the CommDb. There is a Null Agent (C<nullagt>) that could be used to pretend to establish a connection. However, at the time of writing, there is nothing equivalent to a Null NIF that would also be needed to create a truely fake connection. It might be worth writing such a thing is this limitation is frequently hit.
+
+=head1 See Also
+
+L<rcons|rcons>
+
+=head1 Copyright
+
+Copyright (c) 2005-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,32 @@
+// bld.inf
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef FSHELL_COMMON_MMH
+#include <fshell/common.mmh>
+#endif
+
+PRJ_EXPORTS
+..\inc\winsockprt.h	\epoc32\include\winsockprt.h
+..\data\dwinsockprt.esk	\epoc32\winscw\c\Private\101f7989\esock\ip.dwinsockprt.esk
+..\data\winsockprt.esk	\epoc32\winscw\c\Private\101f7989\esock\ip.winsockprt.esk.disabled
+..\tools\wsp		\epoc32\tools\wsp
+..\tools\wsp.bat	\epoc32\tools\wsp.bat
+
+#if defined(WINS)
+
+PRJ_MMPFILES
+.\winsockprt.mmp
+
+PRJ_TESTMMPFILES
+..\tsrc\t_wsp.mmp
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/group/release.src	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+NOTESRC_RELEASER
+Joe Branton (joe.branton@symbian.com)
+
+NOTESRC_RELEASE_REASON
+Bug fix / new functionality.
+
+NOTESRC_GENERAL_COMMENTS
+This component enables the Symbian OS emulator to access the host PC's network connection via the Windows Socket API (WinSock2). To enable it, execute the command "wsp enable". To disable it (and go back to using PPP and TCPIP6 to access the network), execute the command "wsp disable".
+
+Note, this release was made against an A1050 baseline, but there are no A1050 specific dependencies. It should be possible to "getrel" this component release into any Hurricane based baseline.
+
+NOTESRC_KNOWN_DEVIATIONS
+Send and receive flags are currently not supported.
+
+NOTESRC_BUGS_FIXED
+From DaveC - Fixed panic that occurred if CWin32Resolver::Cancel() was called after the request had already completed (and CWin32Resolver::Run() called). This fix was to check the iWorkerThread handle for nullness, as CWin32Resolver::Run() closes this handle.
+
+NOTESRC_BUGS_REMAINING
+Shutdown is not properly handled. Currently Shutdown causes the WinSock socket to get closed abruptly. This needs to change so that all data is received from the WinSock socket (and passed up to the ESock client) before it is closed.
+
+NOTESRC_OTHER_CHANGES
+Added some additional logging facilities. Now, when the directory c:\logs\wsp\raw is present (and you're using a debug build of winsockprt) you'll get two extra log files - inbound.bin and outbound.bin. These contain the raw received and send traffic for all sockets (both TCP and UDP).
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/group/winsockprt.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,53 @@
+// winsockprt.mmp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+OPTION CW	-w off
+
+TARGET          winsock.prt
+TARGETTYPE      dll
+UID             0x10003D38 FSHELL_UID_WINSOCKPRT
+CAPABILITY      FSHELL_CAP_MMP_NORMAL
+
+#include <fshell/fsh_system_include.mmh>
+USERINCLUDE     ..\inc
+
+SOURCEPATH      ..\src
+SOURCE          wsp_active.cpp
+SOURCE          wsp_factory.cpp
+SOURCE          wsp_misc.cpp
+SOURCE          wsp_log.cpp
+SOURCE          wsp_protocol.cpp
+SOURCE          wsp_protocolfamily.cpp
+SOURCE          wsp_provider.cpp
+SOURCE          wsp_request.cpp
+SOURCE          wsp_resolver.cpp
+SOURCE          wsp_scheduler.cpp
+SOURCE          wsp_session.cpp
+SOURCE          wsp_socket.cpp
+SOURCE          wsp_subsession.cpp
+
+LIBRARY         euser.lib
+LIBRARY         esock.lib
+LIBRARY         esocksvr.lib
+LIBRARY         insock.lib
+LIBRARY         charconv.lib
+LIBRARY         efsrv.lib
+LIBRARY			emulator.lib
+
+START WINS
+WIN32_LIBRARY	kernel32.lib ws2_32.lib
+END
+
+#include <comms-infras/commsdebugutility.mmh>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/_windows.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+// _windows.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+#include <windows.h>
+// Prevent e32std.inl from failing to compile with "ambiguous access to overloaded function".
+#define memmove _memmove
+#define memset _memset
+//
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/winsockprt.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,22 @@
+// winsockprt.h
+// 
+// Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WINSOCKPRT_H__
+#define __WINSOCKPRT_H__
+
+#include <e32std.h>
+
+const TUint KProtocolWinsockTcp = 9000;
+const TUint KProtocolWinsockUdp = 9001;
+
+
+#endif // __WINSOCKPRT_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_active.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,38 @@
+// wsp_active.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_ACTIVE_H__
+#define __WSP_ACTIVE_H__
+
+#include <e32base.h>
+#include "wsp_def.h"
+
+class CWin32Scheduler;
+
+class CWin32ActiveObject : public CBase
+	{
+protected:
+	CWin32ActiveObject(CWin32Scheduler& aScheduler);
+	~CWin32ActiveObject();
+	void ConstructL();
+	void ReleaseEventHandle();
+	virtual void Run() = 0;
+protected:
+	WIN32_HANDLE iEvent;
+	CWin32Scheduler& iScheduler;
+private:
+	friend class CWin32Scheduler;
+	TSglQueLink iLink;
+	};
+
+
+#endif // __WSP_ACTIVE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_def.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,24 @@
+// wsp_def.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_DEF_H__
+#define __WSP_DEF_H__
+
+#define WIN32_HANDLE  void*
+
+const TUint KWspMajorVersionNumber = 0;
+const TUint KWspMinorVersionNumber = 1;
+const TUint KWspBuildVersionNumber = 1;
+
+TInt MapWinSockError(TInt aWinSockError);
+
+#endif // __WSP_DEF_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_factory.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,54 @@
+// wsp_factory.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_FACTORY_H__
+#define __WSP_FACTORY_H__
+
+#include "wsp_session.h"
+#include "wsp_subsession.h"
+
+
+class RWin32Factory : public RWin32Session
+	{
+public:
+	enum TSubSessionType
+		{
+		ESocket,
+		EResolver
+		};
+public:
+	TInt Open();
+	void Close();
+	};
+
+
+class CWin32Factory : public CWin32Session
+	{
+public:
+	enum TOppCode
+		{
+		ENewSocket = 0x100,	// CWin32Session owns from 0 to 0x100.
+		ENewResolver
+		};
+public:
+	static CWin32Factory* NewL(TWin32Request& aRequest, CWin32Scheduler& aScheduler);
+	~CWin32Factory();
+protected: // From CWin32Session.
+	virtual void ServiceL(TWin32Message& aMessage);
+private:
+	CWin32Factory(TWin32Request& aRequest, CWin32Scheduler& aScheduler);
+	void ConstructL();
+	void InitWinSockL();
+	};
+
+
+#endif // __WSP_FACTORY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_log.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,45 @@
+// wsp_log.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_LOG_H__
+#define __WSP_LOG_H__
+
+#ifdef _DEBUG
+//#define WSP_LOGGING
+#endif
+
+#ifndef WSP_LOGGING
+#define WSP_LOG(a)
+#define WSP_RAW_LOG(a)
+#else
+#define WSP_LOG(a) a 
+#define WSP_RAW_LOG(a) a 
+#define _WSP_LOG
+
+#include <e32std.h>
+
+class WspLog
+	{
+public:
+	static TInt Open();
+	static void Close();
+	static void Write(const TDesC& aDes);
+	static void Printf(TRefByValue<const TDesC> aFmt, ...);
+	static void Printf(TRefByValue<const TDesC8> aFmt, ...);
+	static void HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen);
+	static void WriteRawInbound(const TDesC8& aDes);
+	static void WriteRawOutbound(const TDesC8& aDes);
+	};
+
+#endif // WSP_LOGGING
+
+#endif //__WSP_LOG_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_panic.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,101 @@
+// wsp_panic.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_PANIC_H__
+#define __WSP_PANIC_H__
+
+enum TWspPanic
+	{
+	EWinSockPrtThreadAlreadyExists,
+	EWinSockPrtInvalidCompletionStatus,
+	EWinSockPrtInvalidMessageParentThreadHandle,
+	EWinSockPrtInvalidMessageReadBuffer,
+	EWinSockPrtInvalidMessageWriteBuffer,
+	EWinSockPrtInvalidFactoryOppCode,
+	EWinSockPrtInvalidSocketOppCode,
+	EWinSockPrtInvalidSubSessionType,
+	EWinSockPrtActiveQueueNotEmpty,
+	EWinSockPrtUnexpectedWaitError,
+	EWinSockPrtTooManyWaitObjects,
+	EWinSockPrtUnableToFindSubSession,
+	EWinSockPrtUnexpectedBindRequestFromPeer,
+	EWinSockPrtUnexpectedBindToRequestFromSocketServer,
+	EWinSockPrtUnexpectedSendDownCallFromBindee,
+	EWinSockPrtUnexpectedProcessUpCallFromBindee,
+	EWinSockPrtUnexpectedErrorUpCallFromBindee,
+	EWinSockPrtUnexpectedActiveOpenCallWithConnectionData,
+	EWinSockPrtUnexpectedActiveShutdownWithConnectionData,
+	EWinSockPrtUnexpectedActivePassiveOpenWithConnectionData,
+	EWinSockPrtSocketWrapperConnectWhilstActive,
+	EWinSockPrtSocketWrapperSendWhilstActive,
+	EWinSockPrtSocketWrapperSendToWhilstActive,
+	EWinSockPrtSocketWrapperReceiveWhilstActive,
+	EWinSockPrtSocketWrapperReceiveFromWhilstActive,
+	EWinSockPrtSocketWrapperAcceptWhilstActive,
+	EWinSockPrtSocketWrapperUnexpectedRunError,
+	EWinSockPrtInvalidTcpSocketRequestType,
+	EWinSockPrtInvalidUdpSocketRequestType,
+	EWinSockPrtSubSessionInvalidMessage,
+	EWinSockPrtUnexpectedWSAEnumNetworkEventsError,
+	EWinSockPrtUnexpectedWSANetworkEvent,
+	EWinSockPrtUnexpectedCWin32ActiveObjectCloseHandleError,
+	EWinSockPrtUnexpectedWSASendCompletionError,
+	EWinSockPrtUnexpectedWSASendToCompletionError,
+	EWinSockPrtUnexpectedWSAReceiveCompletionError,
+	EWinSockPrtUnexpectedWSAReceiveFromCompletionError,
+	EWinSockPrtCWin32SocketMultipleConnectRequests,
+	EWinSockPrtCWin32SocketMultipleSendRequests,
+	EWinSockPrtCWin32SocketMultipleSendToRequests,
+	EWinSockPrtCWin32SocketMultipleReceiveRequests,
+	EWinSockPrtCWin32SocketMultipleReceiveFromRequests,
+	EWinSockPrtMultipleRequests,
+	EWinSockPrtInvalidMessage,
+	EWinSockPrtSubSessionListNotEmpty,
+	EWinSockPrtCWin32ResolverMultipleRequests,
+	EWinSockPrtInvalidResolverOppCode,
+	EWinSockPrtResolverWrapperGetByNameWhilstActive,
+	EWinSockPrtResolverWrapperGetByAddressWhilstActive,
+	EWinSockPrtResolverWrapperUnexpectedRunError,
+	EWinSockPrtResolverInvalidWorkerThreadRequest,
+	EWinSockPrtInvalidFactoryOpCode,
+	EWinSockPrtResolverInvalidFamily,
+	EWinSockPrtResolverInvalidAddressLength,
+	EWinSockPrtResolverUnexpectedSetEventError,
+	EWinSockPrtSocketWrapperInvalidSocketOppCode,
+	EWinSockPrtUnexpectedWouldBlockWinSockError,
+	EWinSockPrtUnexpectedInProgressWinSockError,
+	EWinSockPrtUnexpectedAlreadyInProgressWinSockError,
+	EWinSockPrtUnexpectedNotASocketWinSockError,
+	EWinSockPrtUnexpectedTooManyFilesWinSockError,
+	EWinSockPrtUnexpectedShutdownInProgressWinSockError,
+	EWinSockPrtCWin32SocketGetSocketNameInvalidSocketAddress,
+	EWinSockPrtCWin32SocketGetPeerNameInvalidSocketAddress,
+	EWinSockPrtCWin32SocketCreateSocketUnexpectedValidSocket,
+	EWinSockPrtCWin32SocketMultipleAcceptRequests,
+	EWinSockPrtCWin32SocketAcceptBlankSocketNotNull,
+	EWinSockPrtCWinSockTcpProviderDoPassiveOpenLAcceptSapNotNull,
+	EWinSockPrtCWin32SocketHandleAcceptReadyUnexpectedEventSelectError,
+	EWinSockPrtCWinSockTcpProviderSetListeningSapAlreadySet,
+	EWinSockPrtCWinSockTcpProviderStartAcceptSapNotNull,
+	EWinSockPrtCWinSockUdpProviderActiveOpenUnexpectedCall,
+	EWinSockPrtCWinSockUdpProviderPassiveOpenUnexpectedCall,
+	EWinSockPrtCWin32SocketConstructLInvalidSocketType,
+	EWinSockPrtCWin32SocketSendToCompletionAllDataNotSent,
+	EWinSockPrtCWin32SocketReceiveFromCompletionInvalidAddressLength,
+	EWinSockPrtCWinSockProtocolNewSAPLInvalidProtocol,
+	EWinSockPrtCWin32SocketGetOptionInvalidParameters,
+	EWinSockPrtCWin32SocketSetOptionInvalidParameters
+	};
+
+void Panic(TWspPanic aPanic);
+
+#endif // __WSP_PANIC_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_protocol.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,62 @@
+// wsp_protocol.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_PROTOCOL_H__
+#define __WSP_PROTOCOL_H__
+
+#undef SYMBIAN_ENABLE_SPLIT_HEADERS // More tb92 stopgaps, this time for MNifIfUser in nifman.h/nifman_internal.h
+#include <es_prot.h>
+#include <comms-infras/nifif.h>
+
+class RWin32Factory;
+
+class CWinSockProviderBase;
+
+class CWinSockProtocol : public CProtocolBase, public MNifIfUser
+	{
+public:
+	~CWinSockProtocol();
+	static CWinSockProtocol* NewL(TUint aSocketType, RWin32Factory& aWin32Factory);
+	static void ProtocolIdentity(TServerProtocolDesc* aDesc, TUint aSocketType, TUint aProtocol);
+public: // From CProtocolBase.
+	CServProviderBase* NewSAPL(TUint aProtocol);
+	void Identify(TServerProtocolDesc*) const;
+	virtual CHostResolvProvdBase* NewHostResolverL();
+	virtual CServiceResolvProvdBase* NewServiceResolverL();
+	virtual CNetDBProvdBase* NewNetDatabaseL();
+	void BindL(CProtocolBase* aProtocol, TUint anId);
+	virtual void BindToL(CProtocolBase* protocol);
+	TInt Send(RMBufChain&, CProtocolBase* aSourceProtocol);
+	void Process(RMBufChain&, CProtocolBase* aSourceProtocol);
+	TInt Send(TDes8&, TSockAddr* to, TSockAddr* from, CProtocolBase* aSourceProtocol);
+	void Process(TDes8&, TSockAddr* from, TSockAddr* to, CProtocolBase* aSourceProtocol);
+	TInt GetOption(TUint level, TUint name, TDes8& anOption, CProtocolBase* aSourceProtocol);
+	TInt SetOption(TUint level, TUint name, const TDesC8& option, CProtocolBase* aSourceProtocol);
+	void Error(TInt anError, CProtocolBase* aSourceProtocol);
+private: // From MNifIfUser.
+	virtual void IfUserBindFailure(TInt aResult, TAny* aId);
+	virtual void IfUserNewInterfaceL(CNifIfBase* aIf, TAny* aId);
+	virtual void IfUserInterfaceDown(TInt aResult, CNifIfBase* aIf);
+	virtual void IfUserOpenNetworkLayer();
+	virtual void IfUserCloseNetworkLayer();
+	virtual CProtocolBase* IfUserProtocol();
+ 	virtual TBool IfUserIsNetworkLayerActive();
+private:
+	CWinSockProtocol(TUint aProtocol, RWin32Factory& aWin32Factory);
+private:
+	TUint iSocketType;
+	TUint iProtocol;
+	RWin32Factory& iWin32Factory;
+	};
+
+
+#endif // __WSP_PROTOCOL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_protocolfamily.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,36 @@
+// wsp_protocolfamily.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_PROTOCOLFAMILY_H__
+#define __WSP_PROTOCOLFAMILY_H__
+
+#include <es_prot.h>
+#include "wsp_factory.h"
+
+
+class CWinSockProtocolFamily : public CProtocolFamilyBase
+	{
+public:
+	~CWinSockProtocolFamily();	
+	static CWinSockProtocolFamily* NewL();
+	TInt Install();
+	CProtocolBase* NewProtocolL(TUint aSockType,TUint aProtocol);
+	TUint ProtocolList(TServerProtocolDesc*& aProtocolList);
+private:
+	CWinSockProtocolFamily();
+	TBool RealTcpipActiveL() const;
+private:
+	RWin32Factory* iWin32Factory;
+	};
+
+
+#endif // __WSP_PROTOCOLFAMILY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_provider.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,111 @@
+// wsp_provider.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_PROVIDER_H__
+#define __WSP_PROVIDER_H__
+
+#include <es_prot.h>
+#include <in_sock.h>
+#include "wsp_socket.h"
+
+class RWin32Factory;
+
+class CWinSockProviderBase : public CServProviderBase, public MWin32SocketObserver
+	{
+protected:
+	virtual ~CWinSockProviderBase();
+protected: // From CServProviderBase.
+	virtual void LocalName(TSockAddr& anAddr) const;
+	virtual TInt SetLocalName(TSockAddr& anAddr);
+	virtual TInt SetRemName(TSockAddr& anAddr);
+	virtual TInt GetOption(TUint aLevel, TUint aName, TDes8& anOption) const;
+	virtual TInt SetOption(TUint aLevel, TUint aName, const TDesC8& anOption);
+	virtual void AutoBind();
+	virtual void Ioctl(TUint aLevel, TUint aName, TDes8* anOption);
+	virtual void CancelIoctl(TUint aLevel, TUint aName);
+	virtual TInt PassiveOpen(TUint aQue, const TDesC8& aConnectionData);
+	virtual void Shutdown(TCloseType option, const TDesC8& aDisconnectData);
+	virtual void ActiveOpen(const TDesC8& aConnectionData);
+	virtual void Shutdown(TCloseType option);
+protected:
+	CWinSockProviderBase(RWin32Factory& aWin32Factory);
+	void ConstructL();
+	TInt FillSendBuffer(const TDesC8& aDataToSend);
+protected:
+	TInetAddr iRemoteAddr;
+	RWin32Factory& iWin32Factory;
+	RWin32Socket iWin32Socket;
+	CWin32SocketWrapper* iSendSocketWrapper;
+	CWin32SocketWrapper* iReceiveSocketWrapper;
+	HBufC8* iSendBuffer;
+	HBufC8* iReceiveBuffer;
+	TPtrC8 iEsockReadBuffer;	// A constant pointer descriptor over iReceiveBuffer, used to pass received data up to ESock.
+	TPtr8 iWinSockWriteBuffer;	// A pointer descriptor over iRecevieBuffer, used to receive data from WinSock.
+	};
+
+
+class CWinSockTcpProvider : public CWinSockProviderBase
+	{
+public:
+	static CWinSockTcpProvider* NewL(RWin32Factory& aWin32Factory);
+	static CWinSockTcpProvider* NewBlankLC(RWin32Factory& aWin32Factory);
+private: // From CServProviderBase.
+	virtual void RemName(TSockAddr& anAddr) const;
+	virtual TUint Write(const TDesC8& aDesc, TUint options, TSockAddr* anAddr=NULL);
+	virtual void GetData(TDes8 &aDesc, TUint options, TSockAddr *anAddr=NULL);
+	virtual void Start();
+	virtual void ActiveOpen(void);
+	virtual TInt PassiveOpen(TUint aQue);
+	virtual TInt GetOption(TUint aLevel, TUint aName, TDes8& anOption) const;
+	virtual TInt SetOption(TUint aLevel, TUint aName, const TDesC8& anOption);
+private: // From MWin32SocketObserver.
+	virtual void HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError);
+private:
+	virtual ~CWinSockTcpProvider();
+	CWinSockTcpProvider(RWin32Factory& aWin32Factory);
+	void ConstructL(RWin32Socket::TType aType);
+	void SetListeningSap(CWinSockTcpProvider& aListeningSap);
+	void HandleListeningSapStarted();
+	void DoPassiveOpenL(TUint aQue);
+	void StartReceive();
+private:
+	CWin32SocketWrapper* iConnectSocketWrapper;
+	CWin32SocketWrapper* iAcceptSocketWrapper;
+	CWinSockTcpProvider* iAcceptSap;
+	CWinSockTcpProvider* iListeningSap;
+	};
+
+
+class CWinSockUdpProvider : public CWinSockProviderBase
+	{
+public:
+	static CWinSockUdpProvider* NewL(RWin32Factory& aWin32Factory);
+private: // From CServProviderBase.
+	virtual void RemName(TSockAddr& anAddr) const;
+	virtual TInt SetLocalName(TSockAddr& anAddr);
+	virtual TUint Write(const TDesC8& aDesc, TUint options, TSockAddr* anAddr=NULL);
+	virtual void GetData(TDes8 &aDesc, TUint options, TSockAddr *anAddr=NULL);
+	virtual void Start();
+	virtual void ActiveOpen(void);
+	virtual TInt PassiveOpen(TUint aQue);
+private: // From MWin32SocketObserver.
+	virtual void HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError);
+private:
+	virtual ~CWinSockUdpProvider();
+	CWinSockUdpProvider(RWin32Factory& aWin32Factory);
+	void ConstructL();
+private:
+	TInetAddr iReceiveFromAddress;
+	};
+
+
+#endif // __WSP_PROVIDER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_request.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,70 @@
+// wsp_request.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_REQUEST_H__
+#define __WSP_REQUEST_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include "wsp_def.h"
+
+
+class TWin32Message
+	{
+public:
+	void Set(TInt aOppCode);
+	void Set(TInt aOppCode, TRequestStatus& aCompletionStatus);
+	void Set(TInt aOppCode, const TDesC8& aReadBuf);
+	void Set(TInt aOppCode, const TDesC8& aReadBuf, TRequestStatus& aCompletionStatus);
+	void Set(TInt aOppCode, TDes8& aWriteBuf);
+	void Set(TInt aOppCode, TDes8& aWriteBuf, TRequestStatus& aCompletionStatus);
+	void Set(TInt aOppCode, const TDesC8& aReadBuf, TDes8& aWriteBuf);
+	void Set(TInt aOppCode, const TDesC8& aReadBuf, TDes8& aWriteBuf, TRequestStatus& aCompletionStatus);
+	TInt OppCode() const;
+	const TDesC8& ReadBuffer() const;
+	TDes8& WriteBuffer();
+	void Complete(TInt aReason);
+private:
+	friend class TWin32Request;
+	void SetParentThreadHandle(RThread aParentThread);
+private:
+	TInt iOppCode;
+	const TDesC8* iReadBuf;
+	TDes8* iWriteBuf;
+	TRequestStatus* iCompletionStatus;
+	RThread iParentThread;
+	};
+
+
+class TWin32Request
+	{
+public: // Methods used by the ESock thread.
+	TWin32Request();
+	TInt DuplicateParentThreadHandle(RThread aChildThread);
+	TInt MakeRequest(TWin32Message& aMessage);
+	TInt MakeRequest(TWin32Message& aMessage, TInt aSubSession);
+public:	// Methods used by the WinSock thread.
+	void SetEventHandle(WIN32_HANDLE aEvent);
+	void Requested(TInt aReason);
+	TInt SubSession() const;
+	TWin32Message& Message();
+private:
+	TInt MakeRequestAndWait();
+private:
+	RThread iParentThread;
+	WIN32_HANDLE iEvent;
+	TRequestStatus iRequestStatus;
+	TWin32Message* iMessage;
+	TInt iSubSession;
+	};
+
+#endif // __WSP_REQUEST_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_resolver.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,122 @@
+// wsp_resolver.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_RESOLVER_H__
+#define __WSP_RESOLVER_H__
+
+#include <es_sock.h>
+#include <es_prot.h>
+#include "wsp_subsession.h"
+
+
+class RWin32Factory;
+class TInetAddr;
+
+
+class RWin32Resolver : public RWin32SubSession
+	{
+public:
+	RWin32Resolver();
+	TInt Open(RWin32Factory& aFactory);
+	void Close();
+	TInt GetByName(TNameRecord& aName, TRequestStatus& aStatus);
+	TInt GetByAddress(TNameRecord& aName, TRequestStatus& aStatus);
+	void Cancel();
+private:
+	TPtr8 iNameRecordPckg;
+	};
+
+
+class CWin32Resolver : public CWin32SubSession
+	{
+public:
+	enum TOppCode
+		{
+		EGetByName,
+		EGetByAddress,
+		ECancel
+		};
+public:
+	static CWin32Resolver* NewL(CWin32Scheduler& aScheduler);
+	virtual ~CWin32Resolver();
+private: // From CWin32ActiveObject.
+	virtual void Run();
+private: // From CWin32SubSession.
+	virtual void ServiceL(TWin32Message& aMessage);
+private:
+	CWin32Resolver(CWin32Scheduler& aScheduler);
+	void ConstructL();
+	void Cancel();
+	void CreateWorkerThread();
+private: // Methods used by the worker thread.
+	static TInt WorkerThreadStart(TAny* aPtr);
+	void GetByName();
+	void GetByAddress();
+private:
+	TWin32Message* iMessage;
+	RThread iWorkerThread;	// Synchronous name lookup calls are run in their own thread.
+							// This is because the asychronous versions use window messages rather event object, and so can't fit into this framework.
+	TInt iError;
+	TInt64 iRandSeed;
+	};
+
+
+class MWin32ResolverObserver
+	{
+public:
+	virtual void HandleWin32ResolverCompletion(TInt aError) = 0;
+	};
+
+
+class CWin32ResolverWrapper : public CActive
+	{
+public:
+	static CWin32ResolverWrapper* NewL(MWin32ResolverObserver& aObserver, RWin32Factory& aWin32Factory);
+	~CWin32ResolverWrapper();
+	TInt GetByName(TNameRecord& aName);
+	TInt GetByAddress(TNameRecord& aName);
+private: // From CActive.
+	virtual void DoCancel();
+	virtual void RunL();
+	virtual TInt RunError(TInt aError);
+public:
+	CWin32ResolverWrapper(MWin32ResolverObserver& aObserver);
+	void ConstructL(RWin32Factory& aWin32Factory);
+private:
+	MWin32ResolverObserver& iObserver;
+	RWin32Resolver iWin32Resolver;
+	};
+
+
+class CWinSockResolver : public CHostResolvProvdBase, public MWin32ResolverObserver
+	{
+public:
+	static CWinSockResolver* NewL(RWin32Factory& aFactory);
+	virtual ~CWinSockResolver();
+private: // From CResolverProvdBase.
+	virtual void CancelCurrentOperation();
+private: // From CHostResolvProvdBase.
+	virtual void GetByName(TNameRecord& aName);
+	virtual void GetByAddress(TNameRecord& aName);
+	virtual void SetHostName(TDes& aNameBuf);
+	virtual void GetHostName(TDes& aNameBuf);
+private: // From MWin32ResolverObserver.
+	virtual void HandleWin32ResolverCompletion(TInt aError);
+private:
+	CWinSockResolver();
+	void ConstructL(RWin32Factory& aFactory);
+private:
+	CWin32ResolverWrapper* iResolverWrapper;
+	};
+
+
+#endif // __WSP_RESOLVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_scheduler.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,43 @@
+// wsp_scheduler.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_SCHEDULER_H__
+#define __WSP_SCHEDULER_H__
+
+#include "wsp_active.h"
+
+const TInt KMaxWaitObjects = 64; // Should be MAXIMUM_WAIT_OBJECTS from windows.h, but this header doesn't sit happily with winsock2.h.
+
+
+class CWin32Scheduler : public CBase
+	{
+public:
+	static CWin32Scheduler* NewL();
+	~CWin32Scheduler();
+	void Add(CWin32ActiveObject& aActiveObject);
+	void Remove(CWin32ActiveObject& aActiveObject);
+	TBool IsPresent(CWin32ActiveObject& aActiveObject) const;
+	void Start();
+	void Stop();
+private:
+	CWin32Scheduler();
+	void RebuildEventList();
+private:
+	TBool iStopping;
+	TInt iNumEvents;
+	WIN32_HANDLE iEventList[KMaxWaitObjects];
+	CWin32ActiveObject* iActiveObjectList[KMaxWaitObjects];
+	TSglQue<CWin32ActiveObject> iActiveQue;
+	};
+
+
+#endif // __WSP_SCHEDULER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_session.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,68 @@
+// wsp_session.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_SESSION_H__
+#define __WSP_SESSION_H__
+
+#include "wsp_request.h"
+#include "wsp_scheduler.h"
+
+class CWin32SubSession;
+
+class RWin32Session
+	{
+public:
+	TInt Open();
+protected:
+	void Close();
+	TInt MakeRequest(TWin32Message& aMessage);
+private:
+	TInt CreateThread();
+private:
+	friend class RWin32SubSession;
+	RThread iThread;
+	TWin32Request iRequest;
+	TWin32Message iWin32Message;
+	};
+
+
+class CWin32Session : public CWin32ActiveObject
+	{
+public:
+	enum
+		{
+		EClose = 0,
+		ECloseSubSession
+		};
+public:
+	void AddSubSessionL(CWin32SubSession* aSubSession);
+protected:
+	virtual void ServiceL(TWin32Message& aMessage) = 0;
+protected:
+	~CWin32Session();
+	CWin32Session(TWin32Request& aRequest, CWin32Scheduler& aScheduler);
+	void ConstructL();
+protected: // From CWin32ActiveObject.
+	virtual void Run();
+private:
+	void Close();
+	void CloseSubSession();
+private:
+	TWin32Request& iRequest;
+	RPointerArray<CWin32SubSession> iSubSessions;
+	};
+
+
+GLDEF_C TInt WinSockPrtThreadStart(TAny* aPtr);
+GLDEF_C void InitialiseAndRunThreadL(TAny* aPtr);
+
+#endif // __WSP_SESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_socket.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,175 @@
+// wsp_socket.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_SOCKET_H__
+#define __WSP_SOCKET_H__
+
+#include <winsock2.h>
+#include "wsp_subsession.h"
+
+
+class RWin32Factory;
+class TInetAddr;
+
+class RWin32Socket : public RWin32SubSession
+	{
+public:
+	enum TType
+		{
+		EBlank,
+		ETcp,
+		EUdp
+		};
+public:
+	TInt Open(RWin32Factory& aFactory, TType aType);
+	void Close();
+	TInt Connect(const TInetAddr& aAddress, TRequestStatus& aStatus);
+	void CancelConnect();
+	TInt Send(const TDesC8& aSendBuffer, TRequestStatus& aStatus);
+	void CancelSend();
+	TInt SendTo(const TDesC8& aSendBuffer, const TInetAddr& aAddress, TRequestStatus& aStatus);
+	void CancelSendTo();
+	TInt Receive(TDes8& aReceiveBuffer, TRequestStatus& aStatus);
+	void CancelReceive();
+	TInt ReceiveFrom(TDes8& aReceiveBuffer, TInetAddr& aAddress, TRequestStatus& aStatus);
+	void CancelReceiveFrom();
+	TInt GetSocketName(TInetAddr& aAddress) const;
+	TInt GetPeerName(TInetAddr& aAddress) const;
+	TInt Bind(const TInetAddr& aAddress);
+	TInt Listen(TUint aQueueSize);
+	TInt Accept(RWin32Socket& aNewSocket, TRequestStatus& aStatus);
+	void CancelAccept();
+	TInt GetOption(TInt aLevel, TInt aName, char* aValue, TInt* aLength) const;
+	TInt SetOption(TInt aLevel, TInt aName, const char* aValue, TInt aLength);
+	};
+
+
+class CWin32Socket : public CWin32SubSession
+	{
+public:
+	enum TOppCode
+		{
+		EConnect,
+		ECancelConnect,
+		ESend,
+		ECancelSend,
+		ESendTo,
+		ECancelSendTo,
+		EReceive,
+		ECancelReceive,
+		EReceiveFrom,
+		ECancelReceiveFrom,
+		EGetSocketName,
+		EBind,
+		EGetPeerName,
+		EListen,
+		EAccept,
+		ECancelAccept,
+		EGetOption,
+		ESetOption
+		};
+public:
+	static CWin32Socket* NewL(CWin32Scheduler& aScheduler, RWin32Socket::TType aType);
+	virtual ~CWin32Socket();
+private: // From CWin32ActiveObject.
+	virtual void Run();
+private: // From CWin32SubSession.
+	virtual void ServiceL(TWin32Message& aMessage);
+private:
+	CWin32Socket(CWin32Scheduler& aScheduler, RWin32Socket::TType aType);
+	void ConstructL();
+	void Connect(TWin32Message& aMessage);
+	void Send(TWin32Message& aMessage);
+	void SendTo(TWin32Message& aMessage);
+	void Receive(TWin32Message& aMessage);
+	void ReceiveFrom(TWin32Message& aMessage);
+	void GetSocketName(TWin32Message& aMessage) const;
+	void Bind(TWin32Message& aMessage);
+	void GetPeerName(TWin32Message& aMessage) const;
+	void Listen(TWin32Message& aMessage);
+	void Accept(TWin32Message& aMessage);
+	void GetOption(TWin32Message& aMessage) const;
+	void SetOption(TWin32Message& aMessage);
+	void DoSend();
+	void CloseSocket();
+	void HandleConnectionComplete(TInt aError);
+	void HandleAcceptReady(TInt aError);
+	static void CALLBACK SendCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags);
+	static void CALLBACK SendToCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags);
+	static void CALLBACK ReceiveCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags);
+	static void CALLBACK ReceiveFromCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags);
+	void ConvertAddress(const TInetAddr& aESockAddress, SOCKADDR_IN& aWinSockAddress) const;
+	void ConvertAddress(const SOCKADDR_IN& aWinSockAddress, TInetAddr& aESockAddress) const;
+private:
+	RWin32Socket::TType iType;
+	SOCKET iSocket;
+	unsigned long iFlags;
+	WSABUF iSendBuffer;
+	WSABUF iReceiveBuffer;
+	WSAOVERLAPPED iSendOverlapped;
+	WSAOVERLAPPED iReceiveOverlapped;
+	SOCKADDR_IN iReceiveFromAddress;
+	TInt iReceiveFromAddressLength;
+	TInetAddr* iReceiveFromClientAddress;
+	TInt iBytesSent;
+	TWin32Message* iConnectMessage;
+	TWin32Message* iSendMessage;
+	TWin32Message* iReceiveMessage;
+	TWin32Message* iAcceptMessage;
+	CWin32Socket* iBlankAcceptSocket;
+	};
+
+
+class MWin32SocketObserver
+	{
+public:
+	enum TRequestType
+		{
+		ENone,
+		EConnect,
+		ESend,
+		ESendTo,
+		EReceive,
+		EReceiveFrom,
+		EAccept
+		};
+public:
+	virtual void HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError) = 0;
+	};
+
+
+class CWin32SocketWrapper : public CActive
+	{
+public:
+	static CWin32SocketWrapper* NewL(MWin32SocketObserver& aObserver, RWin32Socket& aWin32Socket);
+	~CWin32SocketWrapper();
+	TInt Connect(const TInetAddr& aAddress);
+	TInt Send(const TDesC8& aSendBuffer);
+	TInt SendTo(const TDesC8& aSendBuffer, const TInetAddr& aAddress);
+	TInt Receive(TDes8& aReceiveBuffer);
+	TInt ReceiveFrom(TDes8& aReceiveBuffer, TInetAddr& aAddress);
+	TInt Accept(RWin32Socket& aNewSocket);
+private: // From CActive.
+	virtual void DoCancel();
+	virtual void RunL();
+	virtual TInt RunError(TInt aError);
+public:
+	CWin32SocketWrapper(MWin32SocketObserver& aObserver, RWin32Socket& aWin32Socket);
+	void ConstructL();
+private:
+	MWin32SocketObserver& iObserver;
+	RWin32Socket iWin32Socket; // Shallow copy to give each a unique TWin32Message object.
+	MWin32SocketObserver::TRequestType iRequestType;
+	};
+
+
+#endif // __WSP_SOCKET_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/inc/wsp_subsession.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+// wsp_subsession.h
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#ifndef __WSP_SUBSESSION_H__
+#define __WSP_SUBSESSION_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include "wsp_active.h"
+#include "wsp_session.h"
+
+
+class TWin32Request;
+class CWin32Scheduler;
+
+
+class RWin32SubSession
+	{
+protected:
+	void Close();
+	TInt CreateSubSession(RWin32Session& aSession, TInt aOppCode);
+	TInt CreateSubSession(RWin32Session& aSession, TInt aOppCode, const TDesC8& aReadBuf);
+	TInt MakeRequest(TWin32Message& aMessage) const;
+protected:
+	mutable TWin32Message iWin32Message;
+	mutable RWin32Session* iSession;
+	TInt iHandle;
+	};
+
+
+class CWin32SubSession : public CWin32ActiveObject
+	{
+public:
+	virtual void ServiceL(TWin32Message& aMessage) = 0;
+protected:
+	CWin32SubSession(CWin32Scheduler& aScheduler);
+	void Complete(TWin32Message*& aMessage, TInt aReason) const;
+	};
+
+
+#endif // __WSP_SUBSESSION_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_active.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,50 @@
+// wsp_active.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include "_windows.h"
+#include "wsp_active.h"
+#include "wsp_scheduler.h"
+#include "wsp_panic.h"
+
+
+CWin32ActiveObject::CWin32ActiveObject(CWin32Scheduler& aScheduler)
+	: iScheduler(aScheduler)
+	{
+	}
+
+CWin32ActiveObject::~CWin32ActiveObject()
+	{
+	if (iScheduler.IsPresent(*this))
+		{
+		ReleaseEventHandle();
+		}
+	}
+
+void CWin32ActiveObject::ConstructL()
+	{
+	iEvent = CreateEvent(NULL, EFalse, EFalse, NULL);
+	if (iEvent == NULL)
+		{
+		User::Leave(KErrBadHandle);
+		}
+	iScheduler.Add(*this);
+	}
+
+void CWin32ActiveObject::ReleaseEventHandle()
+	{
+	if (!CloseHandle(iEvent))
+		{
+		__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedCWin32ActiveObjectCloseHandleError));
+		}
+	iScheduler.Remove(*this);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_factory.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,114 @@
+// wsp_factory.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include "wsp_factory.h"
+#include "wsp_resolver.h"
+#include "wsp_socket.h"
+#include "wsp_panic.h"
+#include "wsp_log.h"
+#include <emulator.h>
+
+
+//
+// RWin32Factory.
+//
+
+TInt RWin32Factory::Open()
+	{
+	return RWin32Session::Open();
+	}
+
+void RWin32Factory::Close()
+	{
+	RWin32Session::Close();
+	}
+
+
+//
+// CWin32Factory.
+//
+
+CWin32Factory* CWin32Factory::NewL(TWin32Request& aRequest, CWin32Scheduler& aScheduler)
+	{
+	CWin32Factory* self = new(ELeave) CWin32Factory(aRequest, aScheduler);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CWin32Factory::~CWin32Factory()
+	{
+	WSACleanup();
+	}
+
+void CWin32Factory::ServiceL(TWin32Message& aMessage)
+	{
+	CWin32SubSession* subSession = NULL;
+
+	switch (aMessage.OppCode())
+		{
+		case ENewSocket:
+			{
+			WSP_LOG(WspLog::Write(_L("CWin32Factory::ServiceL: ENewSocket")));
+			RWin32Socket::TType type;
+			TPckg<RWin32Socket::TType> typePckg(type);
+			typePckg.Copy(aMessage.ReadBuffer());
+			subSession = CWin32Socket::NewL(iScheduler, type);
+			break;
+			}
+		case ENewResolver:
+			{
+			WSP_LOG(WspLog::Write(_L("CWin32Factory::ServiceL: ENewResolver")));
+			subSession = CWin32Resolver::NewL(iScheduler);
+			break;
+			break;
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtInvalidFactoryOppCode));
+			}
+		}
+
+	AddSubSessionL(subSession);
+	}
+
+CWin32Factory::CWin32Factory(TWin32Request& aRequest, CWin32Scheduler& aScheduler)
+	: CWin32Session(aRequest, aScheduler)
+	{
+	}
+
+void CWin32Factory::ConstructL()
+	{
+	InitWinSockL();
+	CWin32Session::ConstructL();
+	}
+
+void CWin32Factory::InitWinSockL()
+	{
+	WORD version = MAKEWORD (2,2);
+	WSADATA wsaData;
+
+	Emulator::Lock();
+	int res = WSAStartup(version, &wsaData);
+	Emulator::Unlock();
+	if (res == SOCKET_ERROR)
+		{
+		User::Leave(KErrGeneral);
+		}
+
+	if (version != wsaData.wVersion)
+		{
+		User::Leave(KErrNotSupported);
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_log.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,94 @@
+// wsp_log.cpp
+// 
+// Copyright (c) 2004 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include "wsp_log.h"
+
+#ifdef WSP_LOGGING
+
+#include <comms-infras/commsdebugutility.h>
+
+_LIT8(KSubSystem, "fshell");
+_LIT8(KComponent, "winsockprt");  
+
+
+RFileLogger& Logger()
+	{
+	return *(static_cast<RFileLogger*>(Dll::Tls()));
+	}
+
+TInt WspLog::Open()
+	{
+	RFileLogger* logger = new RFileLogger();
+	if (logger == NULL)
+		{
+		return KErrNoMemory;
+		}
+
+	TInt err = logger->Connect();
+	if (err == KErrNone)
+		{
+		err = logger->SetLogTags(KSubSystem(), KComponent());
+		if (err == KErrNone)
+			{
+			Dll::SetTls(logger);
+			}
+		}
+
+	return err;
+	}
+
+void WspLog::Close()
+	{
+	RFileLogger* logger = &(Logger());
+	logger->Close();
+	delete logger;
+	Dll::SetTls(NULL);
+	}
+
+void WspLog::Write(const TDesC& aDes)
+	{
+	Logger().Write(aDes);
+	}
+
+void WspLog::Printf(TRefByValue<const TDesC> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	Logger().WriteFormat(aFmt, list);
+	}
+
+void WspLog::Printf(TRefByValue<const TDesC8> aFmt, ...)
+	{
+	VA_LIST list;
+	VA_START(list, aFmt);
+	Logger().WriteFormat(aFmt, list);
+	}
+
+void WspLog::HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen)
+	{
+	Logger().HexDump(aHeader, aMargin, aPtr, aLen);
+	}
+
+void WspLog::WriteRawInbound(const TDesC8& aDes)
+	{
+	Logger().Write(_L("In-bound data:"));
+	Logger().HexDump(aDes);
+	}
+
+void WspLog::WriteRawOutbound(const TDesC8& aDes)
+	{
+	Logger().Write(_L("Out-bound data:"));
+	Logger().HexDump(aDes);
+	}
+
+
+#endif // _DEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_misc.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,163 @@
+// wsp_misc.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32def.h>
+#include <winsock2.h>
+#include "wsp_protocolfamily.h"
+#include "wsp_panic.h"
+#include "wsp_log.h"
+
+
+extern "C"
+	{
+	IMPORT_C CProtocolFamilyBase* InstallWinSockPrt();
+	}
+
+EXPORT_C CProtocolFamilyBase* InstallWinSockPrt()
+	{
+	WSP_LOG(User::LeaveIfError(WspLog::Open()));
+	WSP_LOG(WspLog::Write(_L("InstallWinSockPrt")));
+	return CWinSockProtocolFamily::NewL();
+	}
+
+void Panic(TWspPanic aPanic)
+	{
+	_LIT(KWspPanicCategory, "WinSockPrt");
+	User::Panic(KWspPanicCategory, aPanic);
+	}
+
+TInt MapWinSockError(TInt aWinSockError)
+	{
+	switch (aWinSockError)
+		{
+		case 0:
+			return KErrNone;
+		case WSAEINTR:
+			return KErrCancel;
+		case WSAEBADF:
+			return KErrUnknown;
+		case WSAEACCES:
+			return KErrAccessDenied;
+		case WSAEFAULT:
+			return KErrBadName;
+		case WSAEINVAL:
+			return KErrArgument;
+		case WSAEMFILE:
+			Panic(EWinSockPrtUnexpectedTooManyFilesWinSockError);
+		case WSAEWOULDBLOCK:
+			Panic(EWinSockPrtUnexpectedWouldBlockWinSockError);
+		case WSAEINPROGRESS:
+			Panic(EWinSockPrtUnexpectedInProgressWinSockError);
+		case WSAEALREADY:
+			Panic(EWinSockPrtUnexpectedAlreadyInProgressWinSockError);
+		case WSAENOTSOCK:
+			Panic(EWinSockPrtUnexpectedNotASocketWinSockError);
+		case WSAEDESTADDRREQ:
+			return KErrArgument;
+		case WSAEMSGSIZE:
+			return KErrTooBig;
+		case WSAEPROTOTYPE:
+			return KErrArgument;
+		case WSAENOPROTOOPT:
+			return KErrArgument;
+		case WSAEPROTONOSUPPORT:
+			return KErrNotSupported;
+		case WSAESOCKTNOSUPPORT:
+			return KErrNotSupported;
+		case WSAEOPNOTSUPP:
+			return KErrNotSupported;
+		case WSAEPFNOSUPPORT:
+			return KErrNotSupported;
+		case WSAEAFNOSUPPORT:
+			return KErrNotSupported;
+		case WSAEADDRINUSE:
+			return KErrInUse;
+		case WSAEADDRNOTAVAIL:
+			return KErrArgument;
+		case WSAENETDOWN:
+			return KErrDisconnected;
+		case WSAENETUNREACH:
+			return KErrGeneral;
+		case WSAENETRESET:
+			return KErrDisconnected;
+		case WSAECONNABORTED:
+			return KErrCouldNotConnect;
+		case WSAECONNRESET:
+			return KErrDisconnected;
+		case WSAENOBUFS:
+			return KErrNoMemory;
+		case WSAEISCONN:
+			return KErrAlreadyExists;
+		case WSAENOTCONN:
+			return KErrDisconnected;
+		case WSAESHUTDOWN:
+			return KErrDisconnected;
+		case WSAETOOMANYREFS:
+			return KErrTooBig;
+		case WSAETIMEDOUT:
+			return KErrTimedOut;
+		case WSAECONNREFUSED:
+			return KErrAccessDenied;
+		case WSAELOOP:
+			return KErrUnknown;
+		case WSAENAMETOOLONG:
+			return KErrTooBig;
+		case WSAEHOSTDOWN:
+			return KErrCouldNotConnect;
+		case WSAEHOSTUNREACH:
+			return KErrGeneral;
+		case WSAENOTEMPTY:
+			return KErrUnknown;
+		case WSAEPROCLIM:
+			return KErrTooBig;
+		case WSAEUSERS:
+			return KErrUnknown;
+		case WSAEDQUOT:
+			return KErrUnknown;
+		case WSAESTALE:
+			return KErrUnknown;
+		case WSAEREMOTE:
+			return KErrUnknown;
+		case WSASYSNOTREADY:
+			return KErrNotReady;
+		case WSAVERNOTSUPPORTED:
+			return KErrNotSupported;
+		case WSANOTINITIALISED:
+			return KErrGeneral;
+		case WSAEDISCON:
+			Panic(EWinSockPrtUnexpectedShutdownInProgressWinSockError);
+		case WSAENOMORE:
+			return KErrGeneral;
+		case WSAECANCELLED:
+			return KErrCancel;
+		case WSAEINVALIDPROCTABLE:
+			return KErrArgument;
+		case WSAEINVALIDPROVIDER:
+			return KErrArgument;
+		case WSAEPROVIDERFAILEDINIT:
+			return KErrGeneral;
+		case WSASYSCALLFAILURE:
+			return KErrArgument;
+		case WSASERVICE_NOT_FOUND:
+			return KErrNotFound;
+		case WSATYPE_NOT_FOUND:
+			return KErrNotFound;
+		case WSA_E_NO_MORE:
+			return KErrGeneral;
+		case WSA_E_CANCELLED:
+			return KErrCancel;
+		case WSAEREFUSED:
+			return KErrAccessDenied;
+		default:
+			return KErrUnknown;
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_protocol.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,222 @@
+// wsp_protocol.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include <winsockprt.h>
+#include "wsp_protocol.h"
+#include "wsp_provider.h"
+#include "wsp_factory.h"
+#include "wsp_resolver.h"
+#include "wsp_panic.h"
+#include "wsp_def.h"
+#include "wsp_log.h"
+
+
+CWinSockProtocol::~CWinSockProtocol()
+	{
+	}
+
+CWinSockProtocol::CWinSockProtocol(TUint aSocketType, RWin32Factory& aWin32Factory)
+	: iSocketType(aSocketType), iWin32Factory(aWin32Factory)
+	{
+	}
+
+CWinSockProtocol* CWinSockProtocol::NewL(TUint aSocketType, RWin32Factory& aWin32Factory)
+	{
+	CWinSockProtocol* self = new(ELeave) CWinSockProtocol(aSocketType, aWin32Factory);
+	return self;
+	}
+
+void CWinSockProtocol::ProtocolIdentity(TServerProtocolDesc* aDesc, TUint aSocketType, TUint aProtocol)
+	{
+	switch (aSocketType)
+		{
+		case KSockStream:
+			{
+			aDesc->iName = (aProtocol == KProtocolWinsockTcp) ? _S("winsocktcp") : _S("tcp");
+			aDesc->iAddrFamily = KAfInet;
+			aDesc->iSockType = KSockStream;
+			aDesc->iProtocol = aProtocol;
+			aDesc->iVersion = TVersion(KWspMajorVersionNumber, KWspMinorVersionNumber, KWspBuildVersionNumber);
+			aDesc->iByteOrder = EBigEndian;
+			aDesc->iServiceInfo = KSIStreamBased | KSIInOrder | KSIReliable | KSIGracefulClose;
+			aDesc->iNamingServices = KNSNameResolution;
+			aDesc->iSecurity = KSocketNoSecurity;
+			aDesc->iMessageSize = KSocketMessageSizeIsStream;
+			aDesc->iServiceTypeInfo = ESocketSupport | EUseCanSend;
+			aDesc->iNumSockets = KUnlimitedSockets;
+			return;
+			}
+		case KSockDatagram:
+			{
+			if (aProtocol == KProtocolWinsockUdp)
+				{
+				aDesc->iName =  _S("winsockudp");
+				}
+			else if (aProtocol == KProtocolInetUdp)
+				{
+				aDesc->iName = _S("udp");
+				}
+			else if (aProtocol == KProtocolInetIp)
+				{
+				aDesc->iName = _S("ip");
+				}
+			aDesc->iAddrFamily = KAfInet;
+			aDesc->iSockType = KSockDatagram;
+			aDesc->iProtocol = aProtocol;
+			aDesc->iVersion = TVersion(KWspMajorVersionNumber,	KWspMinorVersionNumber, KWspBuildVersionNumber);
+			aDesc->iByteOrder = EBigEndian;
+			aDesc->iServiceInfo = KSIConnectionLess | KSIDatagram | KSIGracefulClose;
+			aDesc->iNamingServices = KNSNameResolution;
+			aDesc->iSecurity = KSocketNoSecurity;
+			aDesc->iMessageSize = 65536-128; /*KSocketMessageSizeUndefined;*/
+			aDesc->iServiceTypeInfo = ESocketSupport | EUseCanSend;
+			aDesc->iNumSockets = KUnlimitedSockets;
+			return;
+			}
+		}
+	}
+
+CServProviderBase* CWinSockProtocol::NewSAPL(TUint aProtocol)
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProtocol::NewSAPL")));
+
+	CWinSockProviderBase* provider = NULL;
+
+	switch (iSocketType)
+		{
+		case KSockStream:
+			{
+			provider = CWinSockTcpProvider::NewL(iWin32Factory);
+			break;
+			}
+		case KSockDatagram:
+			{
+			provider = CWinSockUdpProvider::NewL(iWin32Factory);
+			break;
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtCWinSockProtocolNewSAPLInvalidProtocol));
+			}
+		}
+
+	iProtocol = aProtocol;
+	
+	return provider;
+	}
+
+void CWinSockProtocol::Identify(TServerProtocolDesc* aDesc) const
+	{
+	CWinSockProtocol::ProtocolIdentity(aDesc, iSocketType, iProtocol);
+	}
+
+void CWinSockProtocol::BindL(CProtocolBase* /*aProtocol*/, TUint /*anId*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedBindRequestFromPeer));
+	}
+
+void CWinSockProtocol::BindToL(CProtocolBase* /*protocol*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedBindToRequestFromSocketServer));
+	}
+
+TInt CWinSockProtocol::Send(RMBufChain &,CProtocolBase* /*aSourceProtocol*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedSendDownCallFromBindee));
+	return 0;
+	}
+
+void CWinSockProtocol::Process(RMBufChain &,CProtocolBase* /*aSourceProtocol*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedProcessUpCallFromBindee));
+	}
+
+TInt CWinSockProtocol::Send(TDes8 &, TSockAddr* /*to*/,TSockAddr* /*from*/,CProtocolBase* /*aSourceProtocol*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedSendDownCallFromBindee));
+	return KErrNone;
+	}
+
+void CWinSockProtocol::Process(TDes8&,TSockAddr* /*from*/,TSockAddr* /*to*/,CProtocolBase* /*aSourceProtocol*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedProcessUpCallFromBindee));
+	}
+
+
+TInt CWinSockProtocol::GetOption(TUint aLevel,TUint aName,TDes8& aOption,CProtocolBase*)
+	{
+	if ((aLevel == KNifOptLevel) && (aName == KNifOptGetNifIfUser))
+		{
+		static_cast<TNifIfUser&>(aOption) = this;
+		return KErrNone;
+		}
+	return KErrNotSupported;
+	}
+
+TInt CWinSockProtocol::SetOption(TUint /*level*/,TUint /*name*/,const TDesC8& /*option*/,CProtocolBase* /*aSourceProtocol*/)
+	{
+	return KErrNotSupported;
+	}
+
+void CWinSockProtocol::Error(TInt /*anError*/,CProtocolBase* /*aSourceProtocol*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedErrorUpCallFromBindee));
+	}
+
+CHostResolvProvdBase* CWinSockProtocol::NewHostResolverL()
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProtocol::NewHostResolverL")));
+	return CWinSockResolver::NewL(iWin32Factory);
+	}
+
+CServiceResolvProvdBase* CWinSockProtocol::NewServiceResolverL()
+	{
+	return NULL;
+	}
+
+CNetDBProvdBase* CWinSockProtocol::NewNetDatabaseL()
+	{
+	return NULL;
+	}
+
+void CWinSockProtocol::IfUserBindFailure(TInt, TAny*)
+	{
+	}
+
+void CWinSockProtocol::IfUserNewInterfaceL(CNifIfBase*, TAny*)
+	{
+	}
+
+void CWinSockProtocol::IfUserInterfaceDown(TInt, CNifIfBase*)
+	{
+	}
+
+void CWinSockProtocol::IfUserOpenNetworkLayer()
+	{
+	Open();
+	}
+
+void CWinSockProtocol::IfUserCloseNetworkLayer()
+	{
+	Close();
+	}
+
+CProtocolBase* CWinSockProtocol::IfUserProtocol()
+	{
+	return this;
+	}
+
+TBool CWinSockProtocol::IfUserIsNetworkLayerActive()
+	{
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_protocolfamily.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,96 @@
+// wsp_protocolfamily.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include <f32file.h>
+#undef SYMBIAN_ENABLE_SPLIT_HEADERS // More tb92 stopgaps, this time for es_sock_partner.h
+#include <winsockprt.h>
+#include <in_sock.h>
+#include "wsp_protocolfamily.h"
+#include "wsp_protocol.h"
+#include "wsp_log.h"
+
+
+CWinSockProtocolFamily::~CWinSockProtocolFamily()
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProtocolFamily::~CWinSockProtocolFamily")));
+	if (iWin32Factory)
+		{
+		iWin32Factory->Close();
+		delete iWin32Factory;
+		}
+	WSP_LOG(WspLog::Close());
+	}
+
+CWinSockProtocolFamily::CWinSockProtocolFamily()
+	{
+	}
+
+CWinSockProtocolFamily* CWinSockProtocolFamily::NewL()
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProtocolFamily::NewL")));
+	return new(ELeave) CWinSockProtocolFamily();
+	}
+
+TInt CWinSockProtocolFamily::Install()
+	{
+	return KErrNone;
+	}
+
+CProtocolBase* CWinSockProtocolFamily::NewProtocolL(TUint aSockType, TUint /*aProtocol*/)
+	{
+	WSP_LOG(WspLog::Printf(_L("CWinSockProtocolFamily::NewProtocolL, socket type: %d"), aSockType));
+	if (iWin32Factory == NULL)
+		{
+		RWin32Factory* factory = new(ELeave) RWin32Factory();
+		CleanupStack::PushL(factory);
+		User::LeaveIfError(factory->Open());
+		CleanupStack::Pop(factory);
+		iWin32Factory = factory;
+		}
+	return CWinSockProtocol::NewL(aSockType, *iWin32Factory);
+	}
+
+TUint CWinSockProtocolFamily::ProtocolList(TServerProtocolDesc*& aProtocolList)
+	{
+	TBool realTcpipActive(EFalse);
+	TRAP_IGNORE(realTcpipActive = RealTcpipActiveL());
+	const TInt numProtocols = realTcpipActive ? 2 : 5;
+	TRAPD(ret, aProtocolList=new(ELeave) TServerProtocolDesc[numProtocols]);
+	if (ret != KErrNone)
+		{
+		return 0;
+		}
+
+	CWinSockProtocol::ProtocolIdentity(&aProtocolList[0], KSockStream, KProtocolWinsockTcp);
+	CWinSockProtocol::ProtocolIdentity(&aProtocolList[1], KSockDatagram, KProtocolWinsockUdp);
+	if (!realTcpipActive)
+		{
+		CWinSockProtocol::ProtocolIdentity(&aProtocolList[2], KSockStream, KProtocolInetTcp);
+		CWinSockProtocol::ProtocolIdentity(&aProtocolList[3], KSockDatagram, KProtocolInetUdp);
+		CWinSockProtocol::ProtocolIdentity(&aProtocolList[4], KSockDatagram, KProtocolInetIp);
+		}
+	
+	return numProtocols;
+	}
+
+TBool CWinSockProtocolFamily::RealTcpipActiveL() const
+	{
+	RFs fs;
+	User::LeaveIfError(fs.Connect());
+	CleanupClosePushL(fs);
+	TUint att;
+	_LIT(KTcpipEskFileName, "c:\\Private\\101f7989\\esock\\ip.tcpip.esk");
+	TBool active = (fs.Att(KTcpipEskFileName, att) == KErrNone);
+	CleanupStack::PopAndDestroy(&fs);
+	return active;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_provider.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,570 @@
+// wsp_provider.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include "wsp_provider.h"
+#include "wsp_factory.h"
+#include "wsp_socket.h"
+#include "wsp_panic.h"
+#include "wsp_log.h"
+
+
+//
+// Constants.
+//
+
+const TInt KReceiveBufferSize = 4096;
+
+
+//
+// CWinSockProviderBase.
+//
+
+CWinSockProviderBase::CWinSockProviderBase(RWin32Factory& aWin32Factory)
+	: iWin32Factory(aWin32Factory), iWinSockWriteBuffer(NULL, 0)
+	{
+	}
+
+CWinSockProviderBase::~CWinSockProviderBase()
+	{
+	delete iSendSocketWrapper;
+	delete iReceiveSocketWrapper;
+	delete iReceiveBuffer;
+	delete iSendBuffer;
+	iWin32Socket.Close();
+	}
+
+void CWinSockProviderBase::ConstructL()
+	{
+	iSendSocketWrapper = CWin32SocketWrapper::NewL(*this, iWin32Socket);
+	iReceiveSocketWrapper = CWin32SocketWrapper::NewL(*this, iWin32Socket);
+	iReceiveBuffer = HBufC8::NewL(KReceiveBufferSize);
+	iWinSockWriteBuffer.Set(iReceiveBuffer->Des());
+	}
+
+TInt CWinSockProviderBase::FillSendBuffer(const TDesC8& aDataToSend)
+	{
+	if (iSendBuffer)
+		{
+		if (iSendBuffer->Des().MaxLength() < aDataToSend.Length())
+			{
+			iSendBuffer = iSendBuffer->ReAlloc(aDataToSend.Length());
+			if (iSendBuffer == NULL)
+				{
+				return KErrNoMemory;
+				}
+			}
+		*iSendBuffer = aDataToSend;
+		}
+	else
+		{
+		iSendBuffer = aDataToSend.Alloc();
+		if (iSendBuffer == NULL)
+			{
+			return KErrNoMemory;
+			}
+		}
+	return KErrNone;
+	}
+
+TInt CWinSockProviderBase::SetRemName(TSockAddr& anAddr)
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::SetRemName")));
+	iRemoteAddr = anAddr;
+	return KErrNone;
+	}
+
+void CWinSockProviderBase::LocalName(TSockAddr& anAddr)const
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::LocalName")));
+	iWin32Socket.GetSocketName(static_cast<TInetAddr&>(anAddr)); // Throw away error code.
+	}
+
+TInt CWinSockProviderBase::SetLocalName(TSockAddr& anAddr)
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::SetLocalName")));
+	return iWin32Socket.Bind(anAddr);
+	}
+
+void CWinSockProviderBase::AutoBind( void )
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::AutoBind")));
+	}
+
+TInt CWinSockProviderBase::GetOption(TUint /*aLevel*/, TUint /*aName*/, TDes8& /*anOption*/)const
+	{
+	return KErrNotSupported;
+	}
+
+TInt CWinSockProviderBase::SetOption(TUint /*aLevel*/, TUint /*aName*/, const TDesC8& /*anOption*/)
+	{
+	return KErrNotSupported;
+	}
+
+void CWinSockProviderBase::Ioctl(TUint /*aLevel*/, TUint /*aName*/, TDes8* /*anOption*/)
+	{
+	iSocket->Error(KErrNotSupported, MSocketNotify::EErrorIoctl);
+	}
+
+void CWinSockProviderBase::CancelIoctl(TUint /*aLevel*/, TUint /*aName*/)
+	{
+	}
+
+TInt CWinSockProviderBase::PassiveOpen(TUint /*aQue*/, const TDesC8& /*aConnectionData*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedActivePassiveOpenWithConnectionData));
+	return 0;
+	}
+
+void CWinSockProviderBase::Shutdown(TCloseType /*option*/, const TDesC8& /*aDisconnectData*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedActiveShutdownWithConnectionData));
+	}
+
+void CWinSockProviderBase::ActiveOpen(const TDesC8& /*aConnectionData*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedActiveOpenCallWithConnectionData));
+	}
+
+void CWinSockProviderBase::Shutdown(TCloseType aType)
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockProviderBase::Shutdown")));
+	if (aType != EImmediate)
+		{
+		iSocket->CanClose();
+		}
+	}
+
+
+//
+// CWinSockTcpProvider.
+//
+
+CWinSockTcpProvider* CWinSockTcpProvider::NewL(RWin32Factory& aWin32Factory)
+	{
+	CWinSockTcpProvider* self = new(ELeave) CWinSockTcpProvider(aWin32Factory);
+	CleanupStack::PushL(self);
+	self->ConstructL(RWin32Socket::ETcp);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CWinSockTcpProvider* CWinSockTcpProvider::NewBlankLC(RWin32Factory& aWin32Factory)
+	{
+	CWinSockTcpProvider* self = new(ELeave) CWinSockTcpProvider(aWin32Factory);
+	CleanupStack::PushL(self);
+	self->ConstructL(RWin32Socket::EBlank);
+	return self;
+	}
+
+CWinSockTcpProvider::CWinSockTcpProvider(RWin32Factory& aWin32Factory)
+	: CWinSockProviderBase(aWin32Factory)
+	{
+	}
+
+void CWinSockTcpProvider::ConstructL(RWin32Socket::TType aType)
+	{
+	User::LeaveIfError(iWin32Socket.Open(iWin32Factory, aType));
+	iConnectSocketWrapper = CWin32SocketWrapper::NewL(*this, iWin32Socket);
+	iAcceptSocketWrapper = CWin32SocketWrapper::NewL(*this, iWin32Socket);
+	CWinSockProviderBase::ConstructL();
+	}
+
+CWinSockTcpProvider::~CWinSockTcpProvider()
+	{
+	delete iConnectSocketWrapper;
+	delete iAcceptSocketWrapper;
+	delete iAcceptSap;
+	}
+
+void CWinSockTcpProvider::RemName(TSockAddr& anAddr) const
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockTcpProvider::RemName")));
+	iWin32Socket.GetPeerName(static_cast<TInetAddr&>(anAddr)); // Throw away error code.
+	}
+
+TUint CWinSockTcpProvider::Write(const TDesC8& aDesc, TUint /*options*/, TSockAddr* /*anAddr*/)
+	{
+	WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::Write: writing %d bytes"), aDesc.Length()));
+	WSP_RAW_LOG(WspLog::WriteRawOutbound(aDesc));
+	if (iSendSocketWrapper->IsActive())
+		{
+		return 0;
+		}
+
+	TInt err = FillSendBuffer(aDesc);
+	if (err)
+		{
+		iSocket->Error(err, MSocketNotify::EErrorSend);
+		return 0;
+		}
+	iSendSocketWrapper->Send(*iSendBuffer);
+	return iSendBuffer->Length();
+	}
+
+void CWinSockTcpProvider::GetData(TDes8& aDesc, TUint /*aOptions*/, TSockAddr* /*anAddr*/)
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockTcpProvider::GetData")));
+	TInt esockBufferSize = aDesc.Length();
+	if (esockBufferSize >= iEsockReadBuffer.Length())
+		{
+		WSP_LOG(WspLog::Printf(_L("\tCopying all %d bytes up to ESock"), iEsockReadBuffer.Length()));
+		aDesc.Copy(iEsockReadBuffer);
+		StartReceive();
+		}
+	else
+		{
+		WSP_LOG(WspLog::Printf(_L("\tESock buffer size: %d, available data: %d"), esockBufferSize, iEsockReadBuffer.Length()));
+		aDesc.Copy(iEsockReadBuffer.Left(esockBufferSize));
+		iEsockReadBuffer.Set(iEsockReadBuffer.Right(iEsockReadBuffer.Length() - esockBufferSize));
+		}
+
+	WSP_RAW_LOG(WspLog::WriteRawInbound(aDesc));
+	}
+
+void CWinSockTcpProvider::Start()
+	{
+	if (iListeningSap)
+		{
+		iListeningSap->HandleListeningSapStarted();
+		iListeningSap = NULL;
+		}
+	}
+
+void CWinSockTcpProvider::ActiveOpen()
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockTcpProvider::ActiveOpen")));
+	TInt err = iConnectSocketWrapper->Connect(iRemoteAddr);
+	if (err)
+		{
+		iSocket->Error(err, MSocketNotify::EErrorConnect);
+		}
+	}
+
+TInt CWinSockTcpProvider::PassiveOpen(TUint aQue)
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockTcpProvider::PassiveOpen")));
+	TRAPD(err, DoPassiveOpenL(aQue));
+	return err;
+	}
+
+TInt CWinSockTcpProvider::GetOption(TUint aLevel, TUint aName, TDes8& anOption) const
+	{
+	if (aLevel == KSolInetTcp)
+		{
+		switch (aName)
+			{
+			case KSoTcpNoDelay:
+				{
+				BOOL bOptVal = FALSE;
+				TInt length = sizeof(BOOL);
+				TInt err = iWin32Socket.GetOption(IPPROTO_TCP, TCP_NODELAY, (char*)&bOptVal, &length);
+				if (err == KErrNone)
+					{
+					TPckg<TInt> intPackage(bOptVal);
+					anOption.Copy(intPackage);
+					}
+				return err;
+				}
+			}
+		}
+
+	return CWinSockProviderBase::GetOption(aLevel, aName, anOption);
+	}
+
+TInt CWinSockTcpProvider::SetOption(TUint aLevel, TUint aName, const TDesC8& anOption)
+	{
+	if (aLevel == KSolInetTcp)
+		{
+		switch (aName)
+			{
+			case KSoTcpNoDelay:
+				{
+				TPckgC<TInt> intPackage(0);
+				intPackage.Set(anOption);
+				BOOL bOptVal = intPackage();
+				return iWin32Socket.SetOption(IPPROTO_TCP, TCP_NODELAY, (char*)&bOptVal, sizeof(BOOL));
+				}
+			}
+		}
+
+	return CWinSockProviderBase::SetOption(aLevel, aName, anOption);
+	}
+
+void CWinSockTcpProvider::HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError)
+	{
+	switch (aRequestType)
+		{
+		case MWin32SocketObserver::EConnect:
+			{
+			WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::HandleWin32SocketCompletion: EConnect, error: %d"), aError));
+			if (aError)
+				{
+				iSocket->Error(aError, MSocketNotify::EErrorConnect);
+				}
+			else
+				{
+				StartReceive();
+				if (iSocket)
+					{
+					iSocket->ConnectComplete();
+					}
+				}
+			break;
+			}
+		case MWin32SocketObserver::ESend:
+			{
+			WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::HandleWin32SocketCompletion: ESend, error: %d"), aError));
+			if (iSocket)
+				{
+				if (aError)
+					{
+					iSocket->Error(aError, MSocketNotify::EErrorSend);
+					}
+				else
+					{
+					iSocket->CanSend();
+					}
+				}
+			break;
+			}
+		case MWin32SocketObserver::EReceive:
+			{
+			WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::HandleWin32SocketCompletion: EReceive, error: %d"), aError));
+			if (aError)
+				{
+				if (iSocket)
+					{
+					iSocket->Error(aError, MSocketNotify::EErrorRecv);
+					}
+				}
+			else
+				{
+				iEsockReadBuffer.Set(iWinSockWriteBuffer);
+				TInt receivedBytes = iEsockReadBuffer.Length();
+				WSP_LOG(WspLog::Printf(_L("\t %d bytes received"), receivedBytes));
+				if (iSocket)
+					{
+					if (receivedBytes)
+						{
+						iSocket->NewData(receivedBytes);
+						}
+					else
+						{
+						iSocket->NewData(KNewDataEndofData);
+						}
+					}
+				}
+			break;
+			}
+		case MWin32SocketObserver::EAccept:
+			{
+			WSP_LOG(WspLog::Printf(_L("CWinSockTcpProvider::HandleWin32SocketCompletion: EAccept, error: %d"), aError));
+			iAcceptSap->StartReceive();
+			CWinSockProviderBase& acceptSap = *iAcceptSap;
+			iAcceptSap = NULL;	// This pointer will be reused when our HandleListeningSapStarted gets, which may be as a result of the next CSocket::ConnectComplete call.
+			iSocket->ConnectComplete(acceptSap);
+			break;
+			}
+		case MWin32SocketObserver::ESendTo:
+		case MWin32SocketObserver::EReceiveFrom:
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtInvalidTcpSocketRequestType));
+			}
+		}
+	}
+
+void CWinSockTcpProvider::DoPassiveOpenL(TUint aQue)
+	{
+	__ASSERT_DEBUG(iAcceptSap == NULL, Panic(EWinSockPrtCWinSockTcpProviderDoPassiveOpenLAcceptSapNotNull));
+	CWinSockTcpProvider* acceptSap = CWinSockTcpProvider::NewBlankLC(iWin32Factory);
+	acceptSap->SetListeningSap(*this);
+	User::LeaveIfError(iWin32Socket.Listen(aQue));
+	User::LeaveIfError(iAcceptSocketWrapper->Accept(acceptSap->iWin32Socket));
+	CleanupStack::Pop(acceptSap);
+	iAcceptSap = acceptSap;
+	}
+
+void CWinSockTcpProvider::StartReceive()
+	{
+	iWinSockWriteBuffer.Zero();
+	iReceiveSocketWrapper->Receive(iWinSockWriteBuffer);
+	}
+
+void CWinSockTcpProvider::SetListeningSap(CWinSockTcpProvider& aListeningSap)
+	{
+	__ASSERT_DEBUG(iListeningSap == NULL, Panic(EWinSockPrtCWinSockTcpProviderSetListeningSapAlreadySet));
+	iListeningSap = &aListeningSap;
+	}
+
+void CWinSockTcpProvider::HandleListeningSapStarted()
+	{
+	__ASSERT_DEBUG(iAcceptSap == NULL, Panic(EWinSockPrtCWinSockTcpProviderStartAcceptSapNotNull));
+	CWinSockTcpProvider* acceptSap = CWinSockTcpProvider::NewBlankLC(iWin32Factory);
+	acceptSap->SetListeningSap(*this);
+	User::LeaveIfError(iAcceptSocketWrapper->Accept(acceptSap->iWin32Socket));
+	CleanupStack::Pop(acceptSap);
+	iAcceptSap = acceptSap;
+	}
+
+
+//
+// CWinSockUdpProvider.
+//
+
+CWinSockUdpProvider* CWinSockUdpProvider::NewL(RWin32Factory& aWin32Factory)
+	{
+	CWinSockUdpProvider* self = new(ELeave) CWinSockUdpProvider(aWin32Factory);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+TInt CWinSockUdpProvider::SetLocalName(TSockAddr& anAddr)
+	{
+	TInt err = CWinSockProviderBase::SetLocalName(anAddr);
+	if (err == KErrNone)
+		{
+		iReceiveSocketWrapper->ReceiveFrom(iWinSockWriteBuffer, iReceiveFromAddress);
+		}
+	return err;
+	}
+
+void CWinSockUdpProvider::RemName(TSockAddr& anAddr) const
+	{
+	anAddr = iRemoteAddr;
+	}
+
+TUint CWinSockUdpProvider::Write(const TDesC8& aDesc, TUint /*options*/, TSockAddr* anAddr)
+	{
+	WSP_LOG(WspLog::Printf(_L("CWinSockUdpProvider::Write: writing %d bytes"), aDesc.Length()));
+	WSP_RAW_LOG(WspLog::WriteRawOutbound(aDesc));
+	if (iSendSocketWrapper->IsActive())
+		{
+		return 0;
+		}
+	TInt err = FillSendBuffer(aDesc);
+	if (err)
+		{
+		iSocket->Error(err, MSocketNotify::EErrorSend);
+		return 0;
+		}
+	if (anAddr)
+		{
+		iSendSocketWrapper->SendTo(*iSendBuffer, *anAddr);
+		}
+	else
+		{
+		iSendSocketWrapper->SendTo(*iSendBuffer, iRemoteAddr);
+		}
+	return iSendBuffer->Length();
+	}
+
+void CWinSockUdpProvider::GetData(TDes8 &aDesc, TUint /*aOptions*/, TSockAddr* anAddr)
+	{
+	WSP_LOG(WspLog::Write(_L("CWinSockUdpProvider::GetData")));
+	TInt esockBufferSize = aDesc.Length();
+	if (esockBufferSize >= iEsockReadBuffer.Length())
+		{
+		WSP_LOG(WspLog::Printf(_L("\tCopying all %d bytes up to ESock"), iEsockReadBuffer.Length()));
+		aDesc.Copy(iEsockReadBuffer);
+		}
+	else
+		{
+		WSP_LOG(WspLog::Printf(_L("\tESock buffer size: %d, available data: %d"), esockBufferSize, iEsockReadBuffer.Length()));
+		aDesc.Copy(iEsockReadBuffer.Left(esockBufferSize)); // Throw away remainder.
+		}
+
+	WSP_RAW_LOG(WspLog::WriteRawInbound(aDesc));
+
+	if (anAddr)
+		{
+		anAddr->Copy(iReceiveFromAddress);
+		}
+	iWinSockWriteBuffer.Zero();
+	iReceiveSocketWrapper->ReceiveFrom(iWinSockWriteBuffer, iReceiveFromAddress);
+	}
+
+void CWinSockUdpProvider::Start()
+	{
+	}
+
+void CWinSockUdpProvider::ActiveOpen(void)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtCWinSockUdpProviderActiveOpenUnexpectedCall));
+	}
+
+TInt CWinSockUdpProvider::PassiveOpen(TUint /*aQue*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtCWinSockUdpProviderPassiveOpenUnexpectedCall));
+	return 0;
+	}
+
+void CWinSockUdpProvider::HandleWin32SocketCompletion(TRequestType aRequestType, TInt aError)
+	{
+	switch (aRequestType)
+		{
+		case MWin32SocketObserver::ESendTo:
+			{
+			WSP_LOG(WspLog::Printf(_L("CWinSockUdpProvider::HandleWin32SocketCompletion: ESendTo, error: %d"), aError));
+			if (aError)
+				{
+				iSocket->Error(aError, MSocketNotify::EErrorSend);
+				}
+			else
+				{
+				iSocket->CanSend();
+				}
+			break;
+			}
+		case MWin32SocketObserver::EReceiveFrom:
+			{
+			WSP_LOG(WspLog::Printf(_L("CWinSockUdpProvider::HandleWin32SocketCompletion: EReceiveFrom, error: %d"), aError));
+			if (aError)
+				{
+				iSocket->Error(aError, MSocketNotify::EErrorRecv);
+				}
+			else
+				{
+				iEsockReadBuffer.Set(iWinSockWriteBuffer);
+				WSP_LOG(WspLog::Printf(_L("\t %d bytes received"), iEsockReadBuffer.Length()));
+				iSocket->NewData(1);
+				}
+			break;
+			}
+		case MWin32SocketObserver::EConnect:
+		case MWin32SocketObserver::ESend:
+		case MWin32SocketObserver::EReceive:
+		case MWin32SocketObserver::EAccept:
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtInvalidUdpSocketRequestType));
+			}
+		}
+	}
+
+CWinSockUdpProvider::~CWinSockUdpProvider()
+	{
+	}
+
+CWinSockUdpProvider::CWinSockUdpProvider(RWin32Factory& aWin32Factory)
+	: CWinSockProviderBase(aWin32Factory)
+	{
+	}
+
+void CWinSockUdpProvider::ConstructL()
+	{
+	User::LeaveIfError(iWin32Socket.Open(iWin32Factory, RWin32Socket::EUdp));
+	CWinSockProviderBase::ConstructL();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_request.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,198 @@
+// wsp_request.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include "_windows.h"
+#include "wsp_request.h"
+#include "wsp_panic.h"
+#include "wsp_log.h"
+
+
+//
+// TWin32Message.
+//
+
+void TWin32Message::Set(TInt aOppCode)
+	{
+	iOppCode = aOppCode;
+	iReadBuf = NULL;
+	iWriteBuf = NULL;
+	iCompletionStatus = NULL;
+	iParentThread.SetHandle(0);
+	}
+
+void TWin32Message::Set(TInt aOppCode, TRequestStatus& aCompletionStatus)
+	{
+	iOppCode = aOppCode;
+	iReadBuf = NULL;
+	iWriteBuf = NULL;
+	iCompletionStatus = &aCompletionStatus;
+	aCompletionStatus = KRequestPending;
+	iParentThread.SetHandle(0);
+	}
+
+void TWin32Message::Set(TInt aOppCode, const TDesC8& aReadBuf)
+	{
+	iOppCode = aOppCode;
+	iReadBuf = &aReadBuf;
+	iWriteBuf = NULL;
+	iCompletionStatus = NULL;
+	iParentThread.SetHandle(0);
+	}
+
+void TWin32Message::Set(TInt aOppCode, const TDesC8& aReadBuf, TRequestStatus& aCompletionStatus)
+	{
+	iOppCode = aOppCode;
+	iReadBuf = &aReadBuf;
+	iWriteBuf = NULL;
+	iCompletionStatus = &aCompletionStatus;
+	aCompletionStatus = KRequestPending;
+	iParentThread.SetHandle(0);
+	}
+
+void TWin32Message::Set(TInt aOppCode, TDes8& aWriteBuf)
+	{
+	iOppCode = aOppCode;
+	iReadBuf = NULL;
+	iWriteBuf = &aWriteBuf;
+	iCompletionStatus = NULL;
+	iParentThread.SetHandle(0);
+	}
+
+void TWin32Message::Set(TInt aOppCode, TDes8& aWriteBuf, TRequestStatus& aCompletionStatus)
+	{
+	iOppCode = aOppCode;
+	iReadBuf = NULL;
+	iWriteBuf = &aWriteBuf;
+	iCompletionStatus = &aCompletionStatus;
+	aCompletionStatus = KRequestPending;
+	iParentThread.SetHandle(0);
+	}
+
+void TWin32Message::Set(TInt aOppCode, const TDesC8& aReadBuf, TDes8& aWriteBuf)
+	{
+	iOppCode = aOppCode;
+	iReadBuf = &aReadBuf;
+	iWriteBuf = &aWriteBuf;
+	iCompletionStatus = NULL;
+	iParentThread.SetHandle(0);
+	}
+
+void TWin32Message::Set(TInt aOppCode, const TDesC8& aReadBuf, TDes8& aWriteBuf, TRequestStatus& aCompletionStatus)
+	{
+	iOppCode = aOppCode;
+	iReadBuf = &aReadBuf;
+	iWriteBuf = &aWriteBuf;
+	iCompletionStatus = &aCompletionStatus;
+	aCompletionStatus = KRequestPending;
+	iParentThread.SetHandle(0);
+	}
+
+TInt TWin32Message::OppCode() const
+	{
+	return iOppCode;
+	}
+
+const TDesC8& TWin32Message::ReadBuffer() const
+	{
+	__ASSERT_DEBUG(iReadBuf, Panic(EWinSockPrtInvalidMessageReadBuffer));
+	return *iReadBuf;
+	}
+
+TDes8& TWin32Message::WriteBuffer()
+	{
+	__ASSERT_DEBUG(iWriteBuf, Panic(EWinSockPrtInvalidMessageWriteBuffer));
+	return *iWriteBuf;
+	}
+
+void TWin32Message::Complete(TInt aReason)
+	{
+	__ASSERT_DEBUG(iCompletionStatus, Panic(EWinSockPrtInvalidCompletionStatus));
+	iParentThread.RequestComplete(iCompletionStatus, aReason);
+	}
+
+void TWin32Message::SetParentThreadHandle(RThread aParentThread)
+	{
+	__ASSERT_DEBUG(iParentThread.Handle() == 0, Panic(EWinSockPrtInvalidMessageParentThreadHandle));
+	iParentThread = aParentThread;
+	}
+
+
+//
+// TWin32Request.
+//
+
+TWin32Request::TWin32Request()
+	: iEvent(0), iMessage(NULL), iSubSession(0)
+	{
+	}
+
+TInt TWin32Request::DuplicateParentThreadHandle(RThread aChildThread)
+	{
+	return iParentThread.Duplicate(aChildThread);
+	}
+
+TInt TWin32Request::MakeRequest(TWin32Message& aMessage)
+	{
+	WSP_LOG(WspLog::Printf(_L("TWin32Request::MakeRequest: aMessage: 0x%x"), &aMessage));
+	__ASSERT_DEBUG(iMessage == NULL, Panic(EWinSockPrtMultipleRequests));
+	iMessage = &aMessage;
+	iMessage->SetParentThreadHandle(iParentThread);
+	iSubSession = 0;
+	iRequestStatus = KRequestPending;
+	return MakeRequestAndWait();
+	}
+
+TInt TWin32Request::MakeRequest(TWin32Message& aMessage, TInt aSubSession)
+	{
+	WSP_LOG(WspLog::Printf(_L("TWin32Request::MakeRequest: aMessage: 0x%x, aSubSession: 0x%x"), &aMessage, aSubSession));
+	__ASSERT_DEBUG(iMessage == NULL, Panic(EWinSockPrtMultipleRequests));
+	iMessage = &aMessage;
+	iMessage->SetParentThreadHandle(iParentThread);
+	iSubSession = aSubSession;
+	iRequestStatus = KRequestPending;
+	return MakeRequestAndWait();
+	}
+
+void TWin32Request::SetEventHandle(WIN32_HANDLE aEvent)
+	{
+	iEvent = aEvent;
+	}
+
+void TWin32Request::Requested(TInt aReason)
+	{
+	WSP_LOG(WspLog::Printf(_L("TWin32Request::Requested: aReason: %d, iMessage: 0x%x, iSubSession: 0x%x"), aReason, iMessage, iSubSession));
+	TRequestStatus* requestStatusPtr = &iRequestStatus;
+	iParentThread.RequestComplete(requestStatusPtr, aReason);
+	}
+
+TInt TWin32Request::SubSession() const
+	{
+	return iSubSession;
+	}
+
+TWin32Message& TWin32Request::Message()
+	{
+	__ASSERT_DEBUG(iMessage, Panic(EWinSockPrtInvalidMessage));
+	return *iMessage;
+	}
+
+TInt TWin32Request::MakeRequestAndWait()
+	{
+	if (!SetEvent(iEvent))
+		{
+		return KErrBadHandle;
+		}
+	User::WaitForRequest(iRequestStatus);
+	iMessage = NULL;
+	return iRequestStatus.Int();
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_resolver.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,387 @@
+// wsp_resolver.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <winsock2.h>
+// Prevent e32std.inl from failing to compile with "ambiguous access to overloaded function".
+#define memmove _memmove
+#define memset _memset
+//
+#include <e32math.h>
+#include <in_sock.h>
+#include <utf.h>
+#include "wsp_resolver.h"
+#include "wsp_session.h"
+#include "wsp_factory.h"
+#include "wsp_panic.h"
+#include "wsp_log.h"
+
+
+//
+// Constants.
+//
+
+_LIT(KWspResolverWorkerThreadNameFormat, "WinSockPrtResolverWorkerThread_%x_%d");
+const TInt  KWspResolverWorkerThreadNameLength =  64;
+const TInt KWspResolverWorkerThreadStackSize = KDefaultStackSize;
+
+
+//
+// RWin32Socket.
+//
+
+RWin32Resolver::RWin32Resolver()
+	: iNameRecordPckg(NULL, 0, 0)
+	{
+	}
+
+TInt RWin32Resolver::Open(RWin32Factory& aFactory)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Resolver::Open: this: 0x%x"), this));
+	return CreateSubSession(aFactory, CWin32Factory::ENewResolver);
+	}
+
+void RWin32Resolver::Close()
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Resolver::Close: this: 0x%x"), this));
+	RWin32SubSession::Close();
+	}
+
+TInt RWin32Resolver::GetByName(TNameRecord& aName, TRequestStatus& aStatus)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Resolver::GetByName: this: 0x%x"), this));
+	iNameRecordPckg.Set(reinterpret_cast<TUint8*>(&aName), sizeof(TNameRecord),sizeof(TNameRecord));
+	iWin32Message.Set(CWin32Resolver::EGetByName, iNameRecordPckg, aStatus);
+	return MakeRequest(iWin32Message);
+	}
+
+TInt RWin32Resolver::GetByAddress(TNameRecord& aName, TRequestStatus& aStatus)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Resolver::GetByAddress: this: 0x%x"), this));
+	iNameRecordPckg.Set(reinterpret_cast<TUint8*>(&aName), sizeof(TNameRecord),sizeof(TNameRecord));
+	iWin32Message.Set(CWin32Resolver::EGetByAddress, iNameRecordPckg, aStatus);
+	return MakeRequest(iWin32Message);
+	}
+
+void RWin32Resolver::Cancel()
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Resolver::Cancel: this: 0x%x"), this));
+	TWin32Message cancelWin32Message;
+	cancelWin32Message.Set(CWin32Resolver::ECancel);
+	MakeRequest(cancelWin32Message); // Throw away return code - can't do anything useful with it.
+	}
+
+
+//
+// CWin32Resolver.
+//
+
+CWin32Resolver* CWin32Resolver::NewL(CWin32Scheduler& aScheduler)
+	{
+	CWin32Resolver* self = new(ELeave) CWin32Resolver(aScheduler);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CWin32Resolver::CWin32Resolver(CWin32Scheduler& aScheduler)
+	: CWin32SubSession(aScheduler)
+	{
+	}
+
+void CWin32Resolver::ConstructL()
+	{
+	CWin32SubSession::ConstructL();
+	}
+
+CWin32Resolver::~CWin32Resolver()
+	{
+	}
+
+void CWin32Resolver::Run()
+	{
+	iMessage->Complete(iError);
+	iMessage = NULL;
+	iWorkerThread.Close();
+	}
+
+void CWin32Resolver::ServiceL(TWin32Message& aMessage)
+	{
+	switch (aMessage.OppCode())
+		{
+		case EGetByName:
+		case EGetByAddress:
+			{
+			__ASSERT_DEBUG(iMessage == NULL, Panic(EWinSockPrtCWin32ResolverMultipleRequests));
+			iMessage = &aMessage;
+			CreateWorkerThread();
+			break;
+			}
+		case ECancel:
+			{
+			Cancel();
+			break;
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtInvalidResolverOppCode));
+			}
+		}
+	}
+
+void CWin32Resolver::Cancel()
+	{
+	if (iWorkerThread.Handle() && (iWorkerThread.ExitType() == EExitPending))
+		{
+		iWorkerThread.Kill(KErrCancel);
+		iMessage->Complete(KErrCancel);
+		iMessage = NULL;
+		iWorkerThread.Close();
+		}
+	}
+
+void CWin32Resolver::CreateWorkerThread()
+	{
+	TBuf<KWspResolverWorkerThreadNameLength> threadName;
+	threadName.Format(KWspResolverWorkerThreadNameFormat, this, Math::Rand(iRandSeed));
+	TInt err = iWorkerThread.Create(threadName, WorkerThreadStart, KWspResolverWorkerThreadStackSize, NULL, this, EOwnerThread);
+	if (err == KErrNone)
+		{
+		iWorkerThread.Resume();
+		}
+	else
+		{
+		iMessage->Complete(err);
+		}
+	}
+
+
+//
+// CWin32Resolver worker thread methods.
+//
+
+TInt CWin32Resolver::WorkerThreadStart(TAny* aPtr)
+	{
+	CWin32Resolver* self = reinterpret_cast<CWin32Resolver*>(aPtr);
+
+	switch (self->iMessage->OppCode())
+		{
+		case EGetByName:
+			{
+			self->GetByName();
+			break;
+			}
+		case EGetByAddress:
+			{
+			self->GetByAddress();
+			break;
+			}
+		case ECancel:
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtResolverInvalidWorkerThreadRequest));
+			}
+		}
+
+	return KErrNone;
+	}
+
+void CWin32Resolver::GetByName()
+	{
+	TNameRecord& nameRecord = (TNameRecord&)*iMessage->WriteBuffer().Ptr();
+	struct hostent* hp;
+	HBufC8* narrowHostNameBuf = HBufC8::New(nameRecord.iName.MaxLength() + 1); // Note, this is one bigger than the size of THostName to allow for a null termination character.
+	if (narrowHostNameBuf == NULL)
+		{
+		iError = KErrNoMemory;
+		}
+	else
+		{
+		TPtr8 narrowHostNamePtr(narrowHostNameBuf->Des());
+		CnvUtfConverter::ConvertFromUnicodeToUtf8(narrowHostNamePtr, nameRecord.iName);
+		hp = gethostbyname(reinterpret_cast<const char*>(narrowHostNamePtr.PtrZ()));
+		delete narrowHostNameBuf;
+		if (hp)
+			{
+			TInetAddr& addr = reinterpret_cast<TInetAddr&>(nameRecord.iAddr);
+			__ASSERT_DEBUG(hp->h_addrtype == AF_INET, Panic(EWinSockPrtResolverInvalidFamily));
+			addr.SetFamily(KAfInet);
+			__ASSERT_DEBUG(hp->h_length == 4, Panic(EWinSockPrtResolverInvalidAddressLength));
+			TUint32* address = (TUint32*)hp->h_addr_list[0];
+			addr.SetAddress(htonl(*address));
+			iError = KErrNone;
+			}
+		else
+			{
+			iError = KErrNotFound;
+			}
+		}
+	
+	if (!SetEvent(iEvent))
+		{
+		__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtResolverUnexpectedSetEventError));
+		}
+	}
+
+void CWin32Resolver::GetByAddress()
+	{
+	TNameRecord& nameRecord = (TNameRecord&)*iMessage->WriteBuffer().Ptr();
+	TInetAddr& addr = reinterpret_cast<TInetAddr&>(nameRecord.iAddr);
+	struct hostent* hp;
+	char addressBuf[4];
+	*((TUint32*)addressBuf) = htonl(addr.Address());
+	hp = gethostbyaddr(addressBuf, 4, AF_INET);
+	if (hp)
+		{
+		TPtrC8 narrowAddressPtr((TUint8*)hp->h_name, User::StringLength((TUint8*)hp->h_name));
+		CnvUtfConverter::ConvertToUnicodeFromUtf8(nameRecord.iName, narrowAddressPtr);
+		iError = KErrNone;
+		}
+	else
+		{
+		iError = KErrNotFound;
+		}
+	
+	if (!SetEvent(iEvent))
+		{
+		__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtResolverUnexpectedSetEventError));
+		}
+	}
+
+
+//
+// CWin32ResolverWrapper.
+//
+
+CWin32ResolverWrapper* CWin32ResolverWrapper::NewL(MWin32ResolverObserver& aObserver, RWin32Factory& aWin32Factory)
+	{
+	CWin32ResolverWrapper* self = new(ELeave) CWin32ResolverWrapper(aObserver);
+	CleanupStack::PushL(self);
+	self->ConstructL(aWin32Factory);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CWin32ResolverWrapper::~CWin32ResolverWrapper()
+	{
+	Cancel();
+	iWin32Resolver.Close();
+	}
+
+CWin32ResolverWrapper::CWin32ResolverWrapper(MWin32ResolverObserver& aObserver)
+	: CActive(CActive::EPriorityStandard), iObserver(aObserver)
+	{
+	}
+
+void CWin32ResolverWrapper::ConstructL(RWin32Factory& aWin32Factory)
+	{
+	User::LeaveIfError(iWin32Resolver.Open(aWin32Factory));
+	CActiveScheduler::Add(this);
+	}
+
+TInt CWin32ResolverWrapper::GetByName(TNameRecord& aName)
+	{
+	__ASSERT_DEBUG(!IsActive(), Panic(EWinSockPrtResolverWrapperGetByNameWhilstActive));
+	TInt err = iWin32Resolver.GetByName(aName, iStatus);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+TInt CWin32ResolverWrapper::GetByAddress(TNameRecord& aName)
+	{
+	__ASSERT_DEBUG(!IsActive(), Panic(EWinSockPrtResolverWrapperGetByAddressWhilstActive));
+	TInt err = iWin32Resolver.GetByAddress(aName, iStatus);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+void CWin32ResolverWrapper::DoCancel()
+	{
+	iWin32Resolver.Cancel();
+	}
+
+void CWin32ResolverWrapper::RunL()
+	{
+	iObserver.HandleWin32ResolverCompletion(iStatus.Int());
+	}
+
+TInt CWin32ResolverWrapper::RunError(TInt /*aError*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtResolverWrapperUnexpectedRunError));
+	return 0;
+	}
+
+
+//
+// CWinSockResolver.
+//
+
+CWinSockResolver* CWinSockResolver::NewL(RWin32Factory& aFactory)
+	{
+	CWinSockResolver* self = new(ELeave) CWinSockResolver();
+	CleanupStack::PushL(self);
+	self->ConstructL(aFactory);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CWinSockResolver::~CWinSockResolver()
+	{
+	delete iResolverWrapper;
+	}
+
+void CWinSockResolver::CancelCurrentOperation()
+	{
+	iResolverWrapper->Cancel();
+	}
+
+void CWinSockResolver::GetByName(TNameRecord& aName)
+	{
+	iResolverWrapper->GetByName(aName);
+	}
+
+void CWinSockResolver::GetByAddress(TNameRecord& aName)
+	{
+	iResolverWrapper->GetByAddress(aName);
+	}
+
+void CWinSockResolver::SetHostName(TDes& /*aNameBuf*/)
+	{
+	// TODO:
+	ASSERT(EFalse);
+	}
+
+void CWinSockResolver::GetHostName(TDes& /*aNameBuf*/)
+	{
+	// TODO:
+	ASSERT(EFalse);
+	}
+
+void CWinSockResolver::HandleWin32ResolverCompletion(TInt aError)
+	{
+	iNotify->QueryComplete(aError);
+	}
+
+CWinSockResolver::CWinSockResolver()
+	{
+	}
+
+void CWinSockResolver::ConstructL(RWin32Factory& aFactory)
+	{
+	iResolverWrapper = CWin32ResolverWrapper::NewL(*this, aFactory);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_scheduler.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,100 @@
+// wsp_scheduler.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include "wsp_scheduler.h"
+#include "wsp_panic.h"
+#include <windows.h>
+#include <emulator.h>
+
+CWin32Scheduler* CWin32Scheduler::NewL()
+	{
+	return new(ELeave) CWin32Scheduler();
+	}
+
+CWin32Scheduler::~CWin32Scheduler()
+	{
+	__ASSERT_DEBUG(iActiveQue.IsEmpty(), Panic(EWinSockPrtActiveQueueNotEmpty));
+	}
+
+void CWin32Scheduler::Add(CWin32ActiveObject& aActiveObject)
+	{
+	iActiveQue.AddLast(aActiveObject);
+	RebuildEventList();
+	}
+
+void CWin32Scheduler::Remove(CWin32ActiveObject& aActiveObject)
+	{
+	iActiveQue.Remove(aActiveObject);
+	RebuildEventList();
+	}
+
+TBool CWin32Scheduler::IsPresent(CWin32ActiveObject& aActiveObject) const
+	{
+	TSglQueIter<CWin32ActiveObject> iterator(const_cast<CWin32Scheduler*>(this)->iActiveQue);
+	iterator.SetToFirst();
+	CWin32ActiveObject* thisActiveObject = NULL;
+	while ((thisActiveObject = iterator++) != NULL)	
+		{
+		if (thisActiveObject == &aActiveObject)
+			{
+			return ETrue;
+			}
+		}
+	return EFalse;
+	}
+
+void CWin32Scheduler::Start()
+	{
+	while (!iStopping)
+		{
+		Emulator::Escape();
+		DWORD ret = WaitForMultipleObjectsEx(iNumEvents,  iEventList, FALSE, INFINITE, TRUE);
+		Emulator::Reenter();
+		if ((ret >= WAIT_OBJECT_0) && (ret < (WAIT_OBJECT_0 + iNumEvents)))
+			{
+			iActiveObjectList[ret - WAIT_OBJECT_0]->Run();
+			}
+		else if (ret == WAIT_IO_COMPLETION)
+			{
+			// TODO: Safe to ignore?
+			}
+		else
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedWaitError));
+			}
+		}
+	}
+
+void CWin32Scheduler::Stop()
+	{
+	iStopping = ETrue;
+	}
+
+CWin32Scheduler::CWin32Scheduler()
+	: iActiveQue(_FOFF(CWin32ActiveObject, iLink))
+	{
+	}
+
+void CWin32Scheduler::RebuildEventList()
+	{
+	iNumEvents = 0;
+	TSglQueIter<CWin32ActiveObject> iterator(iActiveQue);
+	iterator.SetToFirst();
+	CWin32ActiveObject* thisActiveObject = NULL;
+	while ((thisActiveObject = iterator++) != NULL)	
+		{
+		iActiveObjectList[iNumEvents] = thisActiveObject;
+		iEventList[iNumEvents++] = thisActiveObject->iEvent;
+		__ASSERT_DEBUG(iNumEvents <= MAXIMUM_WAIT_OBJECTS, Panic(EWinSockPrtTooManyWaitObjects));
+		}
+	}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_session.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,223 @@
+// wsp_session.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include "wsp_session.h"
+#include "wsp_factory.h"
+#include "wsp_request.h"
+#include "wsp_panic.h"
+#include "wsp_log.h"
+
+
+//
+// Constants.
+//
+
+_LIT(KWspThreadName, "WinSockPrtThread");
+_LIT(KWspThreadNameWhilstWaitingForDeath, "WinSockPrtThread_WaitingForDeath_%Ld");
+_LIT(KWspThreadStartSemaphoreName, "WinSockPrtThreadStartSemaphore");
+const TInt KWspThreadStackSize = KDefaultStackSize;
+const TInt KWspThreadMinHeapSize = 0x4000;		// 16 kb
+const TInt KWspThreadMaxHeapSize = 0x40000;		// 256 kb
+
+
+//
+// RWin32Session.
+//
+
+TInt RWin32Session::Open()
+	{
+	return CreateThread();
+	}
+
+void RWin32Session::Close()
+	{
+	if (iThread.Handle())
+		{
+		iWin32Message.Set(CWin32Session::EClose);
+		iRequest.MakeRequest(iWin32Message);
+		iThread.Close();
+		}
+	}
+
+TInt RWin32Session::MakeRequest(TWin32Message& aMessage)
+	{
+	return iRequest.MakeRequest(aMessage);
+	}
+
+TInt RWin32Session::CreateThread()
+	{
+	WSP_LOG(WspLog::Write(_L("RWin32Session::CreateThread")));
+#ifdef _DEBUG
+	TFindThread findThread(KWspThreadName);
+	TFullName name;
+	__ASSERT_DEBUG(findThread.Next(name)==KErrNotFound, Panic(EWinSockPrtThreadAlreadyExists));
+#endif
+	
+	RSemaphore threadStartSemaphore;
+	TInt err = threadStartSemaphore.CreateGlobal(KWspThreadStartSemaphoreName, 0, EOwnerThread);
+	if (err)
+		{
+		return err;
+		}
+
+	err = iThread.Create(KWspThreadName, WinSockPrtThreadStart, KWspThreadStackSize, KWspThreadMinHeapSize, KWspThreadMaxHeapSize, &iRequest, EOwnerThread);
+	if (err == KErrNone)
+		{
+		err = iRequest.DuplicateParentThreadHandle(iThread);
+		if (err)
+			{
+			iThread.Close();
+			threadStartSemaphore.Close();
+			return err;
+			}
+		//iThread.SetPriority(EPriorityAbsoluteVeryLow); // Hack to prevent the thread from blocking all threads lower than the default priority. Should really be using a raw Win32 thread rather than a Symbian one.
+		iThread.Resume();
+		threadStartSemaphore.Wait();
+		threadStartSemaphore.Close();
+		}
+	else
+		{
+		threadStartSemaphore.Close();
+		}
+	return err;
+	}
+
+
+//
+// Thread start functions.
+//
+
+GLDEF_C TInt WinSockPrtThreadStart(TAny* aPtr)
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* trapCleanup = CTrapCleanup::New();
+	if (trapCleanup == NULL)
+		{
+		return KErrNoMemory;
+		}
+	TRAPD(err, InitialiseAndRunThreadL(aPtr));
+	WSP_LOG(WspLog::Close());
+	delete trapCleanup;
+	__UHEAP_MARKEND;
+	return err;
+	}
+
+GLDEF_C void InitialiseAndRunThreadL(TAny* aPtr)
+	{
+	WSP_LOG(User::LeaveIfError(WspLog::Open()));
+	CWin32Scheduler* win32Scheduler = CWin32Scheduler::NewL();
+	CleanupStack::PushL(win32Scheduler);
+	TWin32Request* request = static_cast<TWin32Request*>(aPtr);
+	CWin32Factory* win32Factory = CWin32Factory::NewL(*request, *win32Scheduler);
+	CleanupStack::PushL(win32Factory);
+
+	RSemaphore threadStartSemaphore;
+	User::LeaveIfError(threadStartSemaphore.OpenGlobal(KWspThreadStartSemaphoreName, EOwnerThread));
+	threadStartSemaphore.Signal();
+	threadStartSemaphore.Close();
+	
+	win32Scheduler->Start();
+
+	CleanupStack::PopAndDestroy(2, win32Scheduler);
+	}
+
+
+//
+// CWin32Session.
+//
+
+void CWin32Session::AddSubSessionL(CWin32SubSession* aSubSession)
+	{
+	TInt subSessionHandle = reinterpret_cast<TInt>(aSubSession);
+	TPckg<TInt> subSessionHandlePckg(subSessionHandle);
+	iRequest.Message().WriteBuffer().Copy(subSessionHandlePckg);
+	CleanupStack::PushL(aSubSession);
+	User::LeaveIfError(iSubSessions.Append(aSubSession));
+	CleanupStack::Pop(aSubSession);
+	}
+
+CWin32Session::~CWin32Session()
+	{
+	__ASSERT_DEBUG(iSubSessions.Count() == 0, Panic(EWinSockPrtSubSessionListNotEmpty));
+	iSubSessions.Close();
+	}
+
+CWin32Session::CWin32Session(TWin32Request& aRequest, CWin32Scheduler& aScheduler)
+	: CWin32ActiveObject(aScheduler), iRequest(aRequest)
+	{
+	}
+
+void CWin32Session::ConstructL()
+	{
+	CWin32ActiveObject::ConstructL();
+	iRequest.SetEventHandle(iEvent);
+	}
+
+void CWin32Session::Run()
+	{
+	TInt err = KErrNone;
+
+	CWin32SubSession* subSession = reinterpret_cast<CWin32SubSession*>(iRequest.SubSession());
+	TWin32Message& message = iRequest.Message();
+	if (subSession == NULL)
+		{
+		switch (message.OppCode())
+			{
+			case EClose:
+				{
+				Close();
+				break;
+				}
+			case ECloseSubSession:
+				{
+				CloseSubSession();
+				break;
+				}
+			default:
+				{
+				// Pass on to sub-class.
+				TRAP(err, ServiceL(message));
+				}
+			}
+		}
+	else
+		{
+		TRAP(err, subSession->ServiceL(message));
+		}
+
+	iRequest.Requested(err);
+	}
+
+void CWin32Session::Close()
+	{
+	// This thread could take a while to die, so give it a different name so that subsequent client attempt to create another one don't fail with KErrInUse.
+	TTime time;
+	time.UniversalTime();
+	const TInt64& int64 = time.Int64();
+	TBuf<64> newThreadName;
+	newThreadName.Format(KWspThreadNameWhilstWaitingForDeath(), int64);
+	User::RenameThread(newThreadName); // Throw away error code.
+	iScheduler.Stop();
+	}
+
+void CWin32Session::CloseSubSession()
+	{
+	TInt handle;
+	TPckg<TInt> handlePckg(handle);
+	handlePckg.Copy(iRequest.Message().ReadBuffer());
+	CWin32SubSession* subSessionToClose = reinterpret_cast<CWin32SubSession*>(handle);
+	TInt pos = iSubSessions.Find(subSessionToClose);
+	__ASSERT_DEBUG(pos >= 0, Panic(EWinSockPrtUnableToFindSubSession));
+	delete subSessionToClose;
+	iSubSessions.Remove(pos);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_socket.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1072 @@
+// wsp_socket.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <in_sock.h>
+#include "wsp_socket.h"
+#include "wsp_session.h"
+#include "wsp_factory.h"
+#include "wsp_panic.h"
+#include "wsp_log.h"
+#undef SetPort // Defined the Microsoft header "winspool.h".
+#include <emulator.h>
+
+//
+// RWin32Socket.
+//
+
+TInt RWin32Socket::Open(RWin32Factory& aFactory, TType aType)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::Open: aType: %d, this: 0x%x"), aType, this));
+	TPckgC<TType> typePckg(aType);
+	return CreateSubSession(aFactory, CWin32Factory::ENewSocket, typePckg);
+	}
+
+void RWin32Socket::Close()
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::Close: this: 0x%x"), this));
+	RWin32SubSession::Close();
+	}
+
+TInt RWin32Socket::Connect(const TInetAddr& aAddress, TRequestStatus& aStatus)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::Connect: this: 0x%x"), this));
+	iWin32Message.Set(CWin32Socket::EConnect, aAddress, aStatus);
+	return MakeRequest(iWin32Message);
+	}
+
+TInt RWin32Socket::Send(const TDesC8& aSendBuffer, TRequestStatus& aStatus)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::Send: this: 0x%x, bytes to send: %d"), this, aSendBuffer.Length()));
+	iWin32Message.Set(CWin32Socket::ESend, aSendBuffer, aStatus);
+	return MakeRequest(iWin32Message);
+	}
+
+TInt RWin32Socket::SendTo(const TDesC8& aSendBuffer, const TInetAddr& aAddress, TRequestStatus& aStatus)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::SendTo: this: 0x%x, bytes to send: %d"), this, aSendBuffer.Length()));
+	TPtr8 addressPtr(const_cast<TUint8*>(aAddress.Ptr()), aAddress.Length(), aAddress.MaxLength()); // Slight hack - need to send two read buffers, but the framework doesn't support this, so send the address as a write buffer.
+	iWin32Message.Set(CWin32Socket::ESendTo, aSendBuffer, addressPtr, aStatus);
+	return MakeRequest(iWin32Message);
+	}
+
+TInt RWin32Socket::Receive(TDes8& aReceiveBuffer, TRequestStatus& aStatus)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::Receive: this: 0x%x, bytes to receive: %d"), this, aReceiveBuffer.Length()));
+	iWin32Message.Set(CWin32Socket::EReceive, aReceiveBuffer, aStatus);
+	return MakeRequest(iWin32Message);
+	}
+
+TInt RWin32Socket::ReceiveFrom(TDes8& aReceiveBuffer, TInetAddr& aAddress, TRequestStatus& aStatus)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::ReceiveFrom: this: 0x%x, bytes to receive: %d"), this, aReceiveBuffer.Length()));
+	TPtrC8 addressPtr((TUint8*)&aAddress, 0); // Slight hack - need to send two write buffers, but the framework doesn't support this, so send the address as a read buffer.
+	iWin32Message.Set(CWin32Socket::EReceiveFrom, addressPtr, aReceiveBuffer, aStatus);
+	return MakeRequest(iWin32Message);
+	}
+
+void RWin32Socket::CancelConnect()
+	{
+	TWin32Message cancelWin32Message;
+	cancelWin32Message.Set(CWin32Socket::ECancelConnect);
+	MakeRequest(cancelWin32Message); // Throw away return code - can't do anything useful with it.
+	}
+
+void RWin32Socket::CancelSend()
+	{
+	TWin32Message cancelWin32Message;
+	cancelWin32Message.Set(CWin32Socket::ECancelSend);
+	MakeRequest(cancelWin32Message); // Throw away return code - can't do anything useful with it.
+	}
+
+void RWin32Socket::CancelSendTo()
+	{
+	TWin32Message cancelWin32Message;
+	cancelWin32Message.Set(CWin32Socket::ECancelSendTo);
+	MakeRequest(cancelWin32Message); // Throw away return code - can't do anything useful with it.
+	}
+
+void RWin32Socket::CancelReceive()
+	{
+	TWin32Message cancelWin32Message;
+	cancelWin32Message.Set(CWin32Socket::ECancelReceive);
+	MakeRequest(cancelWin32Message); // Throw away return code - can't do anything useful with it.
+	}
+
+void RWin32Socket::CancelReceiveFrom()
+	{
+	TWin32Message cancelWin32Message;
+	cancelWin32Message.Set(CWin32Socket::ECancelReceiveFrom);
+	MakeRequest(cancelWin32Message); // Throw away return code - can't do anything useful with it.
+	}
+
+TInt RWin32Socket::GetSocketName(TInetAddr& aAddress) const
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::GetSocketName: this: 0x%x"), this));
+	TRequestStatus status;
+	iWin32Message.Set(CWin32Socket::EGetSocketName, aAddress, status);
+	TInt err = MakeRequest(iWin32Message);
+	if (err)
+		{
+		return err;
+		}
+	else
+		{
+		User::WaitForRequest(status);
+		return status.Int();
+		}
+	}
+
+TInt RWin32Socket::Bind(const TInetAddr& aAddress)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::Bind: this: 0x%x"), this));
+	TRequestStatus status;
+	iWin32Message.Set(CWin32Socket::EBind, aAddress, status);
+	TInt err = MakeRequest(iWin32Message);
+	if (err)
+		{
+		return err;
+		}
+	else
+		{
+		User::WaitForRequest(status);
+		return status.Int();
+		}
+	}
+
+TInt RWin32Socket::GetPeerName(TInetAddr& aAddress) const
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::GetPeerName: this: 0x%x"), this));
+	TRequestStatus status;
+	iWin32Message.Set(CWin32Socket::EGetPeerName, aAddress, status);
+	TInt err = MakeRequest(iWin32Message);
+	if (err)
+		{
+		return err;
+		}
+	else
+		{
+		User::WaitForRequest(status);
+		return status.Int();
+		}
+	}
+
+TInt RWin32Socket::Listen(TUint aQueueSize)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::Listen: this: 0x%x"), this));
+	TPckgC<TUint> queueSizePckg(aQueueSize);
+	TRequestStatus status;
+	iWin32Message.Set(CWin32Socket::EListen, queueSizePckg, status);
+	TInt err = MakeRequest(iWin32Message);
+	if (err)
+		{
+		return err;
+		}
+	else
+		{
+		User::WaitForRequest(status);
+		return status.Int();
+		}
+	}
+
+TInt RWin32Socket::Accept(RWin32Socket& aNewSocket, TRequestStatus& aStatus)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::Accept: this: 0x%x"), this));
+	TPckgC<TInt> newSocketHandlePckg(aNewSocket.iHandle);
+	iWin32Message.Set(CWin32Socket::EAccept, newSocketHandlePckg, aStatus);
+	return MakeRequest(iWin32Message);
+	}
+
+void RWin32Socket::CancelAccept()
+	{
+	TWin32Message cancelWin32Message;
+	cancelWin32Message.Set(CWin32Socket::ECancelAccept);
+	MakeRequest(cancelWin32Message); // Throw away return code - can't do anything useful with it.
+	}
+
+class TWin32SocketOptionsC
+	{
+public:
+	TInt aLevel;
+	TInt aName;
+	const char* aValue;
+	TInt aLength;
+	};
+
+class TWin32SocketOptions
+	{
+public:
+	TInt aLevel;
+	TInt aName;
+	char* aValue;
+	TInt* aLength;
+	};
+
+TInt RWin32Socket::GetOption(TInt aLevel, TInt aName, char* aValue, TInt* aLength) const
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::GetOption: this: 0x%x"), this));
+	TWin32SocketOptions options = {aLevel, aName, aValue, aLength};
+	TPckg<TWin32SocketOptions> optionsPckg(options);
+	TRequestStatus status;
+	iWin32Message.Set(CWin32Socket::EGetOption, optionsPckg, status);
+	TInt err = MakeRequest(iWin32Message);
+	if (err)
+		{
+		return err;
+		}
+	else
+		{
+		User::WaitForRequest(status);
+		return status.Int();
+		}
+	}
+
+TInt RWin32Socket::SetOption(TInt aLevel, TInt aName, const char* aValue, TInt aLength)
+	{
+	WSP_LOG(WspLog::Printf(_L("RWin32Socket::SetOption: this: 0x%x"), this));
+	TWin32SocketOptionsC options = {aLevel, aName, aValue, aLength};
+	TPckgC<TWin32SocketOptionsC> optionsPckg(options);
+	TRequestStatus status;
+	iWin32Message.Set(CWin32Socket::ESetOption, optionsPckg, status);
+	TInt err = MakeRequest(iWin32Message);
+	if (err)
+		{
+		return err;
+		}
+	else
+		{
+		User::WaitForRequest(status);
+		return status.Int();
+		}
+	}
+
+//
+// CWin32Socket.
+//
+
+CWin32Socket* CWin32Socket::NewL(CWin32Scheduler& aScheduler, RWin32Socket::TType aType)
+	{
+	CWin32Socket* self = new(ELeave) CWin32Socket(aScheduler, aType);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CWin32Socket::CWin32Socket(CWin32Scheduler& aScheduler, RWin32Socket::TType aType)
+	: CWin32SubSession(aScheduler), iType(aType)
+	{
+	}
+
+void CWin32Socket::ConstructL()
+	{
+	CWin32SubSession::ConstructL();
+
+	switch (iType)
+		{
+		case RWin32Socket::EBlank:
+			{
+			// Nothing to do.
+			break;
+			}
+		case RWin32Socket::ETcp:
+			{
+			__ASSERT_DEBUG(iSocket == 0, Panic(EWinSockPrtCWin32SocketCreateSocketUnexpectedValidSocket));
+			Emulator::Lock();
+			iSocket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, NULL, WSA_FLAG_OVERLAPPED);
+			Emulator::Unlock();
+			if (iSocket == INVALID_SOCKET)
+				{
+				User::Leave(MapWinSockError(WSAGetLastError()));
+				}
+			break;
+			}
+		case RWin32Socket::EUdp:
+			{
+			__ASSERT_DEBUG(iSocket == 0, Panic(EWinSockPrtCWin32SocketCreateSocketUnexpectedValidSocket));
+			Emulator::Lock();
+			iSocket = WSASocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, NULL, WSA_FLAG_OVERLAPPED);
+			Emulator::Unlock();
+			if (iSocket == INVALID_SOCKET)
+				{
+				User::Leave(MapWinSockError(WSAGetLastError()));
+				}
+			break;
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtCWin32SocketConstructLInvalidSocketType));
+			}
+		}
+	}
+
+CWin32Socket::~CWin32Socket()
+	{
+	CloseSocket();
+	}
+
+void CWin32Socket::ServiceL(TWin32Message& aMessage)
+	{
+	switch (aMessage.OppCode())
+		{
+		case EConnect:
+			{
+			Connect(aMessage);
+			break;
+			}
+		case ECancelConnect:
+			{
+			if (iConnectMessage)
+				{
+				Complete(iConnectMessage, KErrCancel);
+				}
+			break;
+			}
+		case ESend:
+			{
+			Send(aMessage);
+			break;
+			}
+		case ECancelSend:
+			{
+			if (iSendMessage)
+				{
+				Complete(iSendMessage, KErrCancel);
+				}
+			break;
+			}
+		case ESendTo:
+			{
+			SendTo(aMessage);
+			break;
+			}
+		case ECancelSendTo:
+			{
+			if (iSendMessage)
+				{
+				Complete(iSendMessage, KErrCancel);
+				}
+			break;
+			}
+		case EReceive:
+			{
+			Receive(aMessage);
+			break;
+			}
+		case ECancelReceive:
+			{
+			if (iReceiveMessage)
+				{
+				Complete(iReceiveMessage, KErrCancel);
+				}
+			break;
+			}
+		case EReceiveFrom:
+			{
+			ReceiveFrom(aMessage);
+			break;
+			}
+		case ECancelReceiveFrom:
+			{
+			if (iReceiveMessage)
+				{
+				Complete(iReceiveMessage, KErrCancel);
+				}
+			break;
+			}
+		case EGetSocketName:
+			{
+			GetSocketName(aMessage);
+			break;
+			}
+		case EBind:
+			{
+			Bind(aMessage);
+			break;
+			}
+		case EGetPeerName:
+			{
+			GetPeerName(aMessage);
+			break;
+			}
+		case EListen:
+			{
+			Listen(aMessage);
+			break;
+			}
+		case EAccept:
+			{
+			Accept(aMessage);
+			break;
+			}
+		case ECancelAccept:
+			{
+			if (iAcceptMessage)
+				{
+				Complete(iAcceptMessage, KErrCancel);
+				}
+			break;
+			}
+		case EGetOption:
+			{
+			GetOption(aMessage);
+			break;
+			}
+		case ESetOption:
+			{
+			SetOption(aMessage);
+			break;
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtInvalidSocketOppCode));
+			}
+		}
+	}
+
+void CWin32Socket::Connect(TWin32Message& aMessage)
+	{
+	__ASSERT_DEBUG(iConnectMessage == NULL, Panic(EWinSockPrtCWin32SocketMultipleConnectRequests));
+	iConnectMessage = &aMessage;
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::Connect: this: 0x%x"), this));
+
+	if (WSAEventSelect(iSocket, iEvent, FD_CONNECT) == SOCKET_ERROR)
+		{
+		TInt err = MapWinSockError(WSAGetLastError());
+		CloseSocket();
+		Complete(iConnectMessage, err);
+		return;
+		}
+
+	const TInetAddr& address = static_cast<const TInetAddr&>(iConnectMessage->ReadBuffer());
+	SOCKADDR_IN winSockAddress;
+	ConvertAddress(address, winSockAddress);
+
+	if (WSAConnect(iSocket, (LPSOCKADDR)&winSockAddress, sizeof(struct sockaddr_in), NULL, NULL, NULL, NULL) == SOCKET_ERROR)
+		{
+		TInt nError = WSAGetLastError();
+		if (nError != WSAEWOULDBLOCK)
+			{
+			CloseSocket();
+			Complete(iConnectMessage, MapWinSockError(nError));
+			}
+		}
+	else
+		{
+		Complete(iConnectMessage, KErrNone);
+		}
+	}
+
+void CWin32Socket::Send(TWin32Message& aMessage)
+	{
+	__ASSERT_DEBUG((iSendMessage == NULL) && (iBytesSent == 0), Panic(EWinSockPrtCWin32SocketMultipleSendRequests));
+	iSendMessage = &aMessage;
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::Send: this: 0x%x, bytes to send: %d"), this, iSendMessage->ReadBuffer().Length()));
+	DoSend();
+	}
+
+void CWin32Socket::SendTo(TWin32Message& aMessage)
+	{
+	__ASSERT_DEBUG((iSendMessage == NULL) && (iBytesSent == 0), Panic(EWinSockPrtCWin32SocketMultipleSendToRequests));
+	iSendMessage = &aMessage;
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::SendTo: this: 0x%x, bytes to send: %d"), this, iSendMessage->ReadBuffer().Length()));
+	TPtrC8 bufPtr(iSendMessage->ReadBuffer());
+	iSendBuffer.buf = reinterpret_cast<char*>(const_cast<TUint8*>(bufPtr.Ptr()));
+	iSendBuffer.len = bufPtr.Length();
+	iSendOverlapped.hEvent = (void*) this;
+	TInetAddr address;
+	address.Copy(iSendMessage->WriteBuffer());
+	SOCKADDR_IN winSockAddress;
+	ConvertAddress(address, winSockAddress);
+	DWORD numberOfBytesSent;
+	TInt ret = WSASendTo(iSocket, &iSendBuffer, 1, &numberOfBytesSent, 0, (LPSOCKADDR)&winSockAddress, sizeof(struct sockaddr_in), &iSendOverlapped, &SendToCompletion);
+	if (ret == SOCKET_ERROR)
+		{
+		TInt err = WSAGetLastError();
+		if (err != WSA_IO_PENDING)
+			{
+			WSP_LOG(WspLog::Printf(_L("\tsocket error: %d"), err));
+			Complete(iSendMessage, MapWinSockError(err));
+			}
+		}
+	}
+
+void CWin32Socket::Receive(TWin32Message& aMessage)
+	{
+	__ASSERT_DEBUG(iReceiveMessage == NULL, Panic(EWinSockPrtCWin32SocketMultipleReceiveRequests));
+	iReceiveMessage = &aMessage;
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::Receive: this: 0x%x, bytes to get: %d"), this, iReceiveMessage->WriteBuffer().MaxLength()));
+	iReceiveBuffer.buf = reinterpret_cast<char*>(const_cast<TUint8*>(iReceiveMessage->WriteBuffer().Ptr()));
+	iReceiveBuffer.len = iReceiveMessage->WriteBuffer().MaxLength();
+	iFlags = 0;
+	iReceiveOverlapped.hEvent = (void*) this;
+	DWORD numberOfBytesReceived;
+	TInt ret = WSARecv(iSocket, &iReceiveBuffer, 1, &numberOfBytesReceived, &iFlags, &iReceiveOverlapped, &ReceiveCompletion);
+	if (ret == SOCKET_ERROR)
+		{
+		TInt err = WSAGetLastError();
+		if (err != WSA_IO_PENDING)
+			{
+			WSP_LOG(WspLog::Printf(_L("\tsocket error: %d"), err));
+			Complete(iReceiveMessage, MapWinSockError(err));
+			}
+		}
+	}
+
+void CWin32Socket::ReceiveFrom(TWin32Message& aMessage)
+	{
+	__ASSERT_DEBUG(iReceiveMessage == NULL, Panic(EWinSockPrtCWin32SocketMultipleReceiveFromRequests));
+	iReceiveMessage = &aMessage;
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::ReceiveFrom: this: 0x%x, bytes to get: %d"), this, iReceiveMessage->WriteBuffer().MaxLength()));
+	iReceiveBuffer.buf = reinterpret_cast<char*>(const_cast<TUint8*>(iReceiveMessage->WriteBuffer().Ptr()));
+	iReceiveBuffer.len = iReceiveMessage->WriteBuffer().MaxLength();
+	iFlags = 0;
+	iReceiveOverlapped.hEvent = (void*) this;
+	iReceiveFromAddressLength = sizeof(struct sockaddr_in);
+	iReceiveFromClientAddress = (TInetAddr*)iReceiveMessage->ReadBuffer().Ptr();
+	DWORD numberOfBytesReceived;
+	TInt ret = WSARecvFrom(iSocket, &iReceiveBuffer, 1, &numberOfBytesReceived, &iFlags, (LPSOCKADDR)&iReceiveFromAddress, &iReceiveFromAddressLength, &iReceiveOverlapped, &ReceiveFromCompletion);
+	if (ret == SOCKET_ERROR)
+		{
+		TInt err = WSAGetLastError();
+		if (err != WSA_IO_PENDING)
+			{
+			WSP_LOG(WspLog::Printf(_L("\tsocket error: %d"), err));
+			Complete(iReceiveMessage, MapWinSockError(err));
+			}
+		}
+	}
+
+void CWin32Socket::GetSocketName(TWin32Message& aMessage) const
+	{
+	SOCKADDR_IN winSockAddress;
+	TInt length = sizeof(struct sockaddr_in);
+	if (getsockname(iSocket, (LPSOCKADDR)&winSockAddress, &length))
+		{
+		aMessage.Complete(MapWinSockError(WSAGetLastError()));
+		}
+	else
+		{
+		__ASSERT_DEBUG(length == sizeof(struct sockaddr_in), Panic(EWinSockPrtCWin32SocketGetSocketNameInvalidSocketAddress));
+		TInetAddr& address = static_cast<TInetAddr&>(aMessage.WriteBuffer());
+		ConvertAddress(winSockAddress, address);
+		aMessage.Complete(KErrNone);
+		}
+	}
+
+void CWin32Socket::Bind(TWin32Message& aMessage)
+	{
+	const TInetAddr& address = static_cast<const TInetAddr&>(aMessage.ReadBuffer());
+	SOCKADDR_IN winSockAddress;
+	ConvertAddress(address, winSockAddress);
+	if (bind(iSocket, (LPSOCKADDR)&winSockAddress, sizeof(struct sockaddr_in)))
+		{
+		aMessage.Complete(MapWinSockError(WSAGetLastError()));
+		}
+	else
+		{
+		aMessage.Complete(KErrNone);
+		}
+	}
+
+void CWin32Socket::GetPeerName(TWin32Message& aMessage) const
+	{
+	SOCKADDR_IN winSockAddress;
+	TInt length = sizeof(struct sockaddr_in);
+	if (getpeername(iSocket, (LPSOCKADDR)&winSockAddress, &length))
+		{
+		aMessage.Complete(MapWinSockError(WSAGetLastError()));
+		}
+	else
+		{
+		__ASSERT_DEBUG(length == sizeof(struct sockaddr_in), Panic(EWinSockPrtCWin32SocketGetPeerNameInvalidSocketAddress));
+		TInetAddr& address = static_cast<TInetAddr&>(aMessage.WriteBuffer());
+		ConvertAddress(winSockAddress, address);
+		aMessage.Complete(KErrNone);
+		}
+	}
+
+void CWin32Socket::Listen(TWin32Message& aMessage)
+	{
+	TPckgBuf<TUint> queueSizeBuf;
+	queueSizeBuf.Copy(aMessage.ReadBuffer());
+	TUint& queueSize = queueSizeBuf();
+	if (listen(iSocket, queueSize))
+		{
+		aMessage.Complete(MapWinSockError(WSAGetLastError()));
+		}
+	else
+		{
+		aMessage.Complete(KErrNone);
+		}
+	}
+
+void CWin32Socket::Accept(TWin32Message& aMessage)
+	{
+	__ASSERT_DEBUG(iAcceptMessage == NULL, Panic(EWinSockPrtCWin32SocketMultipleAcceptRequests));
+	__ASSERT_DEBUG(iBlankAcceptSocket == NULL, Panic(EWinSockPrtCWin32SocketAcceptBlankSocketNotNull));
+	iAcceptMessage = &aMessage;
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::Accept: this: 0x%x"), this));
+	if (WSAEventSelect(iSocket, iEvent, FD_ACCEPT) == SOCKET_ERROR)
+		{
+		Complete(iAcceptMessage, MapWinSockError(WSAGetLastError()));
+		}
+	TPckgBuf<TInt> newSocketHandleBuf;
+	newSocketHandleBuf.Copy(iAcceptMessage->ReadBuffer());
+	iBlankAcceptSocket = (CWin32Socket*)newSocketHandleBuf();
+	}
+
+void CWin32Socket::GetOption(TWin32Message& aMessage) const
+	{
+	__ASSERT_DEBUG(aMessage.WriteBuffer().Length() == sizeof(TWin32SocketOptions), EWinSockPrtCWin32SocketGetOptionInvalidParameters);
+	TWin32SocketOptions* options = reinterpret_cast<TWin32SocketOptions*>(const_cast<TUint8*>(aMessage.WriteBuffer().Ptr()));
+	TInt err = getsockopt(iSocket, options->aLevel, options->aName, options->aValue, options->aLength);
+	TWin32Message* messagePrt = &aMessage;
+	if (err)
+		{
+		Complete(messagePrt, MapWinSockError(WSAGetLastError()));
+		}
+	else
+		{
+		Complete(messagePrt, KErrNone);
+		}
+	}
+
+void CWin32Socket::SetOption(TWin32Message& aMessage)
+	{
+	__ASSERT_DEBUG(aMessage.ReadBuffer().Length() == sizeof(TWin32SocketOptionsC), EWinSockPrtCWin32SocketSetOptionInvalidParameters);
+	const TWin32SocketOptionsC* options = reinterpret_cast<const TWin32SocketOptionsC*>(aMessage.ReadBuffer().Ptr());
+	TInt err = setsockopt(iSocket, options->aLevel, options->aName, options->aValue, options->aLength);
+	TWin32Message* messagePrt = &aMessage;
+	if (err)
+		{
+		Complete(messagePrt, MapWinSockError(WSAGetLastError()));
+		}
+	else
+		{
+		Complete(messagePrt, KErrNone);
+		}
+	}
+
+void CWin32Socket::DoSend()
+	{
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::DoSend: this: 0x%x, bytes to send: %d"), this, iSendMessage->ReadBuffer().Length() - iBytesSent));
+	TPtrC8 bufPtr(iSendMessage->ReadBuffer());
+	iSendBuffer.buf = reinterpret_cast<char*>(const_cast<TUint8*>(bufPtr.Ptr())) + iBytesSent;
+	iSendBuffer.len = bufPtr.Length() - iBytesSent;
+	iSendOverlapped.hEvent = (void*) this;
+	DWORD numberOfBytesSent;
+	Emulator::Lock();
+	TInt ret = WSASend(iSocket, &iSendBuffer, 1, &numberOfBytesSent, 0, &iSendOverlapped, &SendCompletion);
+	Emulator::Unlock();
+	if (ret == SOCKET_ERROR)
+		{
+		Emulator::Lock();
+		TInt err = WSAGetLastError();
+		Emulator::Unlock();
+		if (err != WSA_IO_PENDING)
+			{
+			WSP_LOG(WspLog::Printf(_L("\tsocket error: %d"), err));
+			Complete(iSendMessage, MapWinSockError(err));
+			}
+		}
+	}
+
+void CWin32Socket::CloseSocket()
+	{
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::CloseSocket: this: 0x%x"), this));
+	if (iSocket != INVALID_SOCKET)
+		{
+		closesocket(iSocket);
+		iSocket = INVALID_SOCKET;
+		}
+	}
+
+void CWin32Socket::Run()
+	{
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::Run: this: 0x%x"), this));
+	WSANETWORKEVENTS eventStatus;
+	if (WSAEnumNetworkEvents(iSocket, iEvent, &eventStatus) == 0)
+		{
+		if (eventStatus.lNetworkEvents & FD_CONNECT)
+			{
+			HandleConnectionComplete(MapWinSockError(eventStatus.iErrorCode[FD_CONNECT_BIT]));
+			}
+		else if (eventStatus.lNetworkEvents & FD_ACCEPT)
+			{
+			HandleAcceptReady(MapWinSockError(eventStatus.iErrorCode[FD_ACCEPT_BIT]));
+			}
+		else
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedWSANetworkEvent));
+			}
+		}
+	else
+		{
+		__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedWSAEnumNetworkEventsError));
+		}
+	}
+
+void CWin32Socket::HandleConnectionComplete(TInt aError)
+	{
+	ReleaseEventHandle(); // No longer needed because all further asynchronous I/O is done using overlapped buffer callbacks.
+	if (iConnectMessage)  // May have been cancelled.
+		{
+		Complete(iConnectMessage, aError);
+		}
+	}
+
+void CWin32Socket::HandleAcceptReady(TInt aError)
+	{
+	if (aError)
+		{
+		Complete(iAcceptMessage, aError);
+		}
+	else
+		{
+		if (iAcceptMessage)  // May have been cancelled.
+			{
+			iBlankAcceptSocket->iSocket = WSAAccept(iSocket, NULL, NULL, NULL, 0);
+			if (iBlankAcceptSocket->iSocket == INVALID_SOCKET)
+				{
+				Complete(iAcceptMessage, MapWinSockError(WSAGetLastError()));
+				}
+			else
+				{
+				Complete(iAcceptMessage, KErrNone);
+				}
+			}
+
+		iBlankAcceptSocket = NULL;
+		if (WSAEventSelect(iSocket, iEvent, 0) == SOCKET_ERROR)
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtCWin32SocketHandleAcceptReadyUnexpectedEventSelectError));
+			}
+		}
+	}
+
+void CALLBACK CWin32Socket::SendCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD /*dwFlags*/)
+	{
+	Emulator::Reenter(); // This is a win32 callback so we're outside of the emulator at this point
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::SendCompletion: error: %d, object: 0x%x"), dwError, lpOverlapped->hEvent));
+	switch (dwError)
+		{
+		case 0:
+			{
+			CWin32Socket* socket = reinterpret_cast<CWin32Socket*>(lpOverlapped->hEvent);
+			if (socket && socket->iSendMessage) // May have been cancelled.
+				{
+				socket->iBytesSent += cbTransferred;
+				if (socket->iBytesSent < socket->iSendMessage->ReadBuffer().Length())
+					{
+					socket->DoSend();
+					}
+				else
+					{
+					socket->Complete(socket->iSendMessage, KErrNone);
+					socket->iBytesSent = 0;
+					}
+				}
+			break;
+			}
+		case WSAEINVAL:
+			{
+			// Ignore - probably a completion on a closed socket due to cancellation.
+			break;
+			}
+		case WSAECONNRESET:
+			{
+			// Ignore - remote host has terminated the connection.
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedWSASendCompletionError));
+			}
+		}
+	Emulator::Escape(); // And return to how we were
+	}
+
+void CALLBACK CWin32Socket::SendToCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD /*dwFlags*/)
+	{
+	Emulator::Reenter(); // This is a win32 callback so we're outside of the emulator at this point
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::SendToCompletion: error: %d, object: 0x%x"), dwError, lpOverlapped->hEvent));
+	switch (dwError)
+		{
+		case 0:
+			{
+			CWin32Socket* socket = reinterpret_cast<CWin32Socket*>(lpOverlapped->hEvent);
+			if (socket->iSendMessage) // May have been cancelled.
+				{
+				__ASSERT_DEBUG(cbTransferred == (TUint)socket->iSendMessage->ReadBuffer().Length(), Panic(EWinSockPrtCWin32SocketSendToCompletionAllDataNotSent));
+				socket->Complete(socket->iSendMessage, KErrNone);
+				}
+			break;
+			}
+		case WSAEINVAL:
+			{
+			// Ignore - probably a completion on a closed socket due to cancellation.
+			break;
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedWSASendToCompletionError));
+			}
+		}
+	Emulator::Escape(); // And return to how we were
+	}
+
+void CALLBACK CWin32Socket::ReceiveCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD /*dwFlags*/)
+	{
+	if (dwError == WSAEINVAL)
+		{
+		// Ignore - probably a completion on a closed socket due to cancellation.
+		// Also, might not be a valid context from which to call Emulator::Reenter().
+		return;
+		}
+
+	Emulator::Reenter(); // This is a win32 callback so we're outside of the emulator at this point
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::ReceiveCompletion: error: %d, object: 0x%x"), dwError, lpOverlapped->hEvent));
+	switch (dwError)
+		{
+		case 0:
+			{
+			CWin32Socket* socket = reinterpret_cast<CWin32Socket*>(lpOverlapped->hEvent);
+			if (socket && socket->iReceiveMessage) // May have been cancelled.
+				{
+				socket->iReceiveMessage->WriteBuffer().SetLength(cbTransferred);
+				socket->Complete(socket->iReceiveMessage, KErrNone);
+				}
+			break;
+			}
+		case WSAECONNRESET:
+			{
+			// Remote host has reset the connection.
+			// Ignore - seen these after Opera gets asked to receive a cookie.
+			break;
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedWSAReceiveCompletionError));
+			}
+		}
+	Emulator::Escape(); // And return to how we were
+	}
+
+void CALLBACK CWin32Socket::ReceiveFromCompletion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD /*dwFlags*/)
+	{
+	Emulator::Reenter(); // This is a win32 callback so we're outside of the emulator at this point
+	WSP_LOG(WspLog::Printf(_L("CWin32Socket::ReceiveFromCompletion: error: %d, object: 0x%x"), dwError, lpOverlapped->hEvent));
+	switch (dwError)
+		{
+		case 0:
+			{
+			CWin32Socket* socket = reinterpret_cast<CWin32Socket*>(lpOverlapped->hEvent);
+			if (socket && socket->iReceiveMessage) // May have been cancelled.
+				{
+				socket->iReceiveMessage->WriteBuffer().SetLength(cbTransferred);
+				__ASSERT_DEBUG(socket->iReceiveFromAddressLength == sizeof(struct sockaddr_in), Panic(EWinSockPrtCWin32SocketReceiveFromCompletionInvalidAddressLength));
+				TInetAddr address;
+				socket->ConvertAddress(socket->iReceiveFromAddress, address);
+				socket->iReceiveFromClientAddress->Copy(address);
+				socket->iReceiveFromClientAddress = NULL;
+				socket->Complete(socket->iReceiveMessage, KErrNone);
+				}
+			break;
+			}
+		case WSAEINVAL:
+			{
+			// Ignore - probably a completion on a closed socket due to cancellation.
+			break;
+			}
+		case WSAECONNRESET:
+			{
+			// Remote host has reset the connection.
+			// Ignore - seen these after Opera gets asked to receive a cookie.
+			break;
+			}
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtUnexpectedWSAReceiveCompletionError));
+			}
+		}
+	Emulator::Escape(); // And return to how we were
+	}
+
+void CWin32Socket::ConvertAddress(const TInetAddr& aESockAddress, SOCKADDR_IN& aWinSockAddress) const
+	{
+	aWinSockAddress.sin_family = AF_INET;
+	aWinSockAddress.sin_addr.s_addr = htonl(aESockAddress.Address());
+	aWinSockAddress.sin_port = htons(static_cast<TUint16>(aESockAddress.Port()));
+	}
+
+void CWin32Socket::ConvertAddress(const SOCKADDR_IN& aWinSockAddress, TInetAddr& aESockAddress) const
+	{
+	aESockAddress.SetAddress(htonl(aWinSockAddress.sin_addr.s_addr));
+	aESockAddress.SetPort(htons(aWinSockAddress.sin_port));
+	}
+
+
+
+//
+// CWin32SocketWrapper.
+//
+
+CWin32SocketWrapper* CWin32SocketWrapper::NewL(MWin32SocketObserver& aObserver, RWin32Socket& aWin32Socket)
+	{
+	CWin32SocketWrapper* self = new(ELeave) CWin32SocketWrapper(aObserver, aWin32Socket);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CWin32SocketWrapper::~CWin32SocketWrapper()
+	{
+	Cancel();
+	}
+
+CWin32SocketWrapper::CWin32SocketWrapper(MWin32SocketObserver& aObserver, RWin32Socket& aWin32Socket)
+	: CActive(CActive::EPriorityStandard), iObserver(aObserver), iWin32Socket(aWin32Socket)
+	{
+	}
+
+void CWin32SocketWrapper::ConstructL()
+	{
+	CActiveScheduler::Add(this);
+	}
+
+TInt CWin32SocketWrapper::Connect(const TInetAddr& aAddress)
+	{
+	__ASSERT_DEBUG(!IsActive(), Panic(EWinSockPrtSocketWrapperConnectWhilstActive));
+	iRequestType = MWin32SocketObserver::EConnect;
+	TInt err = iWin32Socket.Connect(aAddress, iStatus);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+TInt CWin32SocketWrapper::Send(const TDesC8& aSendBuffer)
+	{
+	__ASSERT_DEBUG(!IsActive(), Panic(EWinSockPrtSocketWrapperSendWhilstActive));
+	iRequestType = MWin32SocketObserver::ESend;
+	TInt err = iWin32Socket.Send(aSendBuffer, iStatus);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+TInt CWin32SocketWrapper::SendTo(const TDesC8& aSendBuffer, const TInetAddr& aAddress)
+	{
+	__ASSERT_DEBUG(!IsActive(), Panic(EWinSockPrtSocketWrapperSendToWhilstActive));
+	iRequestType = MWin32SocketObserver::ESendTo;
+	TInt err = iWin32Socket.SendTo(aSendBuffer, aAddress, iStatus);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+TInt CWin32SocketWrapper::Receive(TDes8& aReceiveBuffer)
+	{
+	__ASSERT_DEBUG(!IsActive(), Panic(EWinSockPrtSocketWrapperReceiveWhilstActive));
+	iRequestType = MWin32SocketObserver::EReceive;
+	TInt err = iWin32Socket.Receive(aReceiveBuffer, iStatus);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+TInt CWin32SocketWrapper::ReceiveFrom(TDes8& aReceiveBuffer, TInetAddr& aAddress)
+	{
+	__ASSERT_DEBUG(!IsActive(), Panic(EWinSockPrtSocketWrapperReceiveFromWhilstActive));
+	iRequestType = MWin32SocketObserver::EReceiveFrom;
+	TInt err = iWin32Socket.ReceiveFrom(aReceiveBuffer, aAddress, iStatus);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+TInt CWin32SocketWrapper::Accept(RWin32Socket& aNewSocket)
+	{
+	__ASSERT_DEBUG(!IsActive(), Panic(EWinSockPrtSocketWrapperAcceptWhilstActive));
+	iRequestType = MWin32SocketObserver::EAccept;
+	TInt err = iWin32Socket.Accept(aNewSocket, iStatus);
+	if (err == KErrNone)
+		{
+		SetActive();
+		}
+	return err;
+	}
+
+void CWin32SocketWrapper::DoCancel()
+	{
+	switch (iRequestType)
+		{
+		case MWin32SocketObserver::EConnect:
+			{
+			iWin32Socket.CancelConnect();
+			break;
+			}
+		case MWin32SocketObserver::ESend:
+			{
+			iWin32Socket.CancelSend();
+			break;
+			}
+		case MWin32SocketObserver::ESendTo:
+			{
+			iWin32Socket.CancelSendTo();
+			break;
+			}
+		case MWin32SocketObserver::EReceive:
+			{
+			iWin32Socket.CancelReceive();
+			break;
+			}
+		case MWin32SocketObserver::EReceiveFrom:
+			{
+			iWin32Socket.CancelReceiveFrom();
+			break;
+			}
+		case MWin32SocketObserver::EAccept:
+			{
+			iWin32Socket.CancelAccept();
+			break;
+			}
+		case MWin32SocketObserver::ENone:
+		default:
+			{
+			__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtSocketWrapperInvalidSocketOppCode));
+			break;
+			}
+		}
+	}
+
+void CWin32SocketWrapper::RunL()
+	{
+	MWin32SocketObserver::TRequestType requestType = iRequestType;
+	iRequestType = MWin32SocketObserver::ENone;
+	iObserver.HandleWin32SocketCompletion(requestType, iStatus.Int());
+	}
+
+TInt CWin32SocketWrapper::RunError(TInt /*aError*/)
+	{
+	__ASSERT_DEBUG(EFalse, Panic(EWinSockPrtSocketWrapperUnexpectedRunError));
+	return 0;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/src/wsp_subsession.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,78 @@
+// wsp_subsession.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+
+#include "wsp_subsession.h"
+#include "wsp_session.h"
+#include "wsp_panic.h"
+
+
+//
+// RWin32SubSession.
+//
+
+void RWin32SubSession::Close()
+	{
+	if (iSession->iThread.Handle())
+		{
+		TPckgC<TInt> handlePckg(iHandle);
+		iWin32Message.Set(CWin32Session::ECloseSubSession, handlePckg);
+		iSession->iRequest.MakeRequest(iWin32Message);
+		}
+	}
+
+TInt RWin32SubSession::CreateSubSession(RWin32Session& aSession, TInt aOppCode)
+	{
+	TPckg<TInt> handleBuf(iHandle);
+	iWin32Message.Set(aOppCode, handleBuf);
+	TInt err = aSession.MakeRequest(iWin32Message);
+	if (err == KErrNone)
+		{
+		iSession = &aSession;
+		}
+	return err;
+	}
+
+TInt RWin32SubSession::CreateSubSession(RWin32Session& aSession, TInt aOppCode, const TDesC8& aReadBuf)
+	{
+	TPckg<TInt> handleBuf(iHandle);
+	iWin32Message.Set(aOppCode, aReadBuf, handleBuf);
+	TInt err = aSession.MakeRequest(iWin32Message);
+	if (err == KErrNone)
+		{
+		iSession = &aSession;
+		}
+	return err;
+	}
+
+
+TInt RWin32SubSession::MakeRequest(TWin32Message& aMessage) const
+	{
+	return iSession->iRequest.MakeRequest(aMessage, iHandle);
+	}
+
+
+//
+// CWin32SubSession.
+//
+
+CWin32SubSession::CWin32SubSession(CWin32Scheduler& aScheduler)
+	: CWin32ActiveObject(aScheduler)
+	{
+	}
+
+void CWin32SubSession::Complete(TWin32Message*& aMessage, TInt aReason) const
+	{
+	__ASSERT_DEBUG(aMessage, Panic(EWinSockPrtSubSessionInvalidMessage));
+	aMessage->Complete(aReason);
+	aMessage = NULL;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/tools/wsp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,231 @@
+#!perl
+# wsp
+# 
+# Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Description:
+# wsp - A tool for enabling / disabling the Symbian OS WinSock protocol module
+
+use strict;
+use Getopt::Long;
+use File::Copy;
+use File::Basename;
+
+#
+# Globals.
+#
+
+my $verbose = 0;
+my $commands = {
+		'enable' => \&HandleEnable,
+		'e' => \&HandleEnable,
+		'disable' => \&HandleDisable,
+		'd' => \&HandleDisable,
+		'status' => \&HandleStatus,
+		's' => \&HandleStatus
+	       };
+
+my $kRoot = $ENV{EPOCROOT} . 'epoc32\winscw\c\Private\101f7989\esock\\';
+
+my @files = (
+	     {
+	      enabled => $kRoot . 'ip.winsockprt.esk',
+	      disabled => $kRoot . 'ip.winsockprt.esk.disabled',
+	     },
+	     {
+	      enabled => $kRoot . 'ip.dwinsockprt.esk.disabled',
+	      disabled => $kRoot . 'ip.dwinsockprt.esk',
+	     },
+	     {
+	      enabled => $kRoot . 'ip.tcpip.esk.disabled',
+	      disabled => $kRoot . 'ip.tcpip.esk',
+	     },
+	    );
+
+my @undoStack;
+
+
+#
+# Main.
+#
+
+ProcessCommandLine();
+
+
+#
+# Subs.
+#
+
+sub ProcessCommandLine {
+  Getopt::Long::Configure ("bundling");
+  my $help;
+  GetOptions('h' => \$help, 'v+' => \$verbose);
+  if ($help) {
+    Usage();
+  }
+
+  my $command = shift @ARGV;
+  unless ($command and scalar(@ARGV) == 0) {
+    print "Error: Invalid arguments\n";
+    Usage();
+  }
+  unless (exists $commands->{$command}) {
+    print "Error: Unrecognised command\n";
+    Usage();
+  }
+  my $commandSub = $commands->{$command};
+  &$commandSub();
+}
+
+sub Usage {
+  die ("\nUsage: wsp [options] (enable | e | disable | d | status | s)
+
+options:
+
+  -h  help
+  -v  verbose output\n");
+}
+
+sub HandleEnable {
+  my $currentStatus = Status();
+  unless ($currentStatus eq 'disabled') {
+    die "Error: Current status is $currentStatus\n";
+  }
+
+  RenameFilesEnabled();
+  print "WinSock protocol module enabled\n";
+}
+
+sub HandleDisable {
+  my $currentStatus = Status();
+  unless ($currentStatus eq 'enabled') {
+    die "Error: Current status is $currentStatus\n";
+  }
+
+  RenameFilesDisabled();
+  print "WinSock protocol module disabled\n";
+}
+
+sub HandleStatus {
+  print "Current status: ", Status(), "\n";
+}
+
+sub Status {
+  my $numEnabled = 0;
+  my $numDisabled = 0;
+  foreach my $file (@files) {
+    if (-e $file->{enabled}) {
+      ++$numEnabled;
+    }
+    if (-e $file->{disabled}) {
+      ++$numDisabled;
+    }
+  }
+
+  if (($numEnabled == scalar(@files)) and ($numDisabled == 0)) {
+    return 'enabled';
+  }
+  elsif (($numDisabled == scalar(@files)) and ($numEnabled == 0)) {
+    return 'disabled';
+  }
+  return 'indeterminate';
+}
+
+sub RenameFilesDisabled {
+  my $sub = sub {
+    my $file = shift;
+    RenameFile($file->{enabled}, $file->{disabled});
+  };
+  ProcessFilesWithUndo($sub);
+}
+
+sub RenameFilesEnabled {
+  my $sub = sub {
+    my $file = shift;
+    RenameFile($file->{disabled}, $file->{enabled});
+  };
+  ProcessFilesWithUndo($sub);
+}
+
+sub ProcessFilesWithUndo {
+  my $sub = shift;
+  eval {
+    foreach my $thisFile (@files) {
+      &$sub($thisFile);
+    }
+  };
+  if ($@) {
+    while (my $thisUndo = pop (@undoStack)) {
+      &$thisUndo();
+    }
+    die $@;
+  }
+}
+
+sub RenameFile {
+  my $from = shift;
+  my $to = shift;
+  if (-e $to) {
+    die "Error: Attempting to rename \"$from\" to \"$to\" which already exists\n";
+  }
+  print "Renaming \"$from\" -> \"$to\"...\n" if ($verbose);
+  rename($from, $to) or die "Error: Couldn't rename \"$from\" to \"$to\": $!\n";
+  push (@undoStack, sub { print "Undoing rename of \"$from\" -> \"$to\"...\n"; rename ($to, $from) or die; });
+}
+
+__END__
+
+=head1 NAME
+
+wsp - A tool for enabling / disabling the Symbian OS WinSock protocol module
+
+=head1 SYNOPSIS
+
+  wsp [options] (enable | e | disable | d | status | s)
+
+options:
+
+  -h  help
+  -v  verbose output
+
+=head1 DESCRIPTION
+
+The WinSock protocol module can be used with the Symbian OS emulator as a replacement for TCPIP6, PPP and NT-RAS. The various commands have the following meaning:
+
+=over 4
+
+=item * enable (e)
+
+Rename / copy the necessary files to enable the WinSock protocol module.
+
+=item * disable (d)
+
+Delete / rename the necessary files to disable the WinSock protocol module.
+
+=item * status (s)
+
+Display the current status (either 'enabled' or 'disabled').
+
+=item * refresh (r)
+
+Only used during development.
+
+=back
+
+=head1 KNOWN BUGS
+
+None.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2002-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/tools/wsp.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+@REM wsp.bat
+@REM 
+@REM Copyright (c) 2010 Accenture. All rights reserved.
+@REM This component and the accompanying materials are made available
+@REM under the terms of the "Eclipse Public License v1.0"
+@REM which accompanies this distribution, and is available
+@REM at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@REM 
+@REM Initial Contributors:
+@REM Accenture - Initial contribution
+@REM
+@echo off
+set script=%0%
+set script=%script:.bat=%
+perl -Swx "%script%" %*
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/tsrc/t_wsp.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,336 @@
+// t_wsp.cpp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32test.h>
+#include <e32svr.h>
+#include <e32math.h>
+#include <f32file.h>
+#include <es_sock.h>
+#include <in_sock.h>
+
+
+//
+// Constants.
+//
+
+//#define _HOME
+#ifdef _HOME
+const TInt KWebPort = 80;
+const TUint32 KSymbianWebServerIpAddress = INET_ADDR(192, 168, 0, 240);
+const TInt KLocalHostPort = 9999;
+const TUint32 KLocalHostIpAddress = INET_ADDR(127, 0, 0, 1);
+_LIT(KSymbianWebServerName, "main");
+_LIT(KAltSymbianWebServerName, "sunshare.office");
+_LIT8(KSmallWebPage,"GET http://sunshare.office/index.html \r\n\r\n");
+_LIT(KLogFile, "c:\\t_wsp.txt");
+#else
+const TInt KWebPort = 80;
+const TUint32 KSymbianWebServerIpAddress = INET_ADDR(81, 89, 143, 203);
+const TInt KLocalHostPort = 9999;
+const TUint32 KLocalHostIpAddress = INET_ADDR(127, 0, 0, 1);
+_LIT(KSymbianWebServerName, "www.symbian.com");
+_LIT(KAltSymbianWebServerName, "www.symbian.com");
+_LIT8(KSmallWebPage,"GET http://www.symbian.com/index.html \r\n\r\n");
+_LIT(KLogFile, "c:\\t_wsp.txt");
+#endif
+
+const TInt KTestTransferDataSize = 8192;
+
+//
+// Globals.
+//
+
+RFs FileServerSession;
+RFile LogFile;
+RSocketServ SocketServerSession;
+RTest TestConsole(_L("t_wsp"));
+
+
+//
+// Functions.
+//
+
+void RandomFill(TDes8& aBuf)
+	{
+	while (aBuf.Length() < (aBuf.MaxLength() - TInt(sizeof(TUint32))))
+		{
+		TUint32 rand = Math::Random();
+		TPckgC<TUint32> randPckg(rand);
+		aBuf.Append(randPckg);
+		}
+	while (aBuf.Length() < (aBuf.MaxLength()))
+		{
+		aBuf.Append(_L("p")); // Pack out last few bytes.
+		}
+	}
+
+void ReceiveHtmlL(RSocket& aSock)
+	{
+	HBufC8* webPage = HBufC8::NewMaxLC(4096);
+
+	TPtr8 des(webPage->Des());
+	des = KSmallWebPage;
+
+	TRequestStatus stat;
+	aSock.Write(*webPage, stat);
+	User::WaitForRequest(stat);
+	User::LeaveIfError(stat.Int());
+
+	TSockXfrLength HTTPHeaderLen;
+	TInt rcount = 0;
+
+	TBuf<128> infoPrintBuf;
+	FOREVER
+		{
+		des.Zero();
+		aSock.RecvOneOrMore(des,0,stat,HTTPHeaderLen);
+		User::WaitForRequest(stat);
+		if (stat != KErrNone)
+			break;
+		
+		LogFile.Write(des);
+		LogFile.Flush();
+		rcount += webPage->Length();
+		infoPrintBuf.Format(_L("\rRecved:%10d Bytes"), rcount);
+		TestConsole.Printf(infoPrintBuf);
+		}
+	if (stat != KErrEof)
+		{
+		User::Leave(stat.Int());
+		}
+
+	CleanupStack::PopAndDestroy(webPage);
+	}
+
+void TcpOpenAndConnectC(RSocket& aSocket)
+	{
+	RHostResolver resolver;
+	TestConsole(resolver.Open(SocketServerSession, KAfInet, KProtocolInetTcp) == KErrNone);
+	CleanupClosePushL(resolver);
+	TNameEntry nameEntry;
+	TestConsole(resolver.GetByName(KSymbianWebServerName, nameEntry) == KErrNone);
+	TNameRecord nameRecord(nameEntry());
+	TInetAddr addr(TInetAddr::Cast(nameRecord.iAddr).Address(), KWebPort);
+	CleanupStack::PopAndDestroy(); // resolver.
+	TestConsole(aSocket.Open(SocketServerSession, KAfInet, KSockStream, KProtocolInetTcp) == KErrNone);
+	CleanupClosePushL(aSocket);
+	TRequestStatus stat;
+	aSocket.Connect(addr, stat);
+	User::WaitForRequest(stat);
+	TestConsole(stat.Int() == KErrNone);
+	}
+
+void GetByAddress()
+	{
+	RHostResolver resolver;
+	TestConsole(resolver.Open(SocketServerSession, KAfInet, KProtocolInetTcp) == KErrNone);
+	CleanupClosePushL(resolver);
+	TNameEntry nameEntry;
+	TInetAddr testAddr(KSymbianWebServerIpAddress, KWebPort);
+	testAddr.SetFamily(KAfInet);
+	TestConsole(resolver.GetByAddress(testAddr, nameEntry) == KErrNone);
+	TNameRecord nameRecord(nameEntry());
+	TestConsole(nameRecord.iName.CompareF(KAltSymbianWebServerName) == KErrNone);
+	CleanupStack::PopAndDestroy(); // resolver.
+	}
+
+void TcpActiveOpen()
+	{
+	RSocket socket;
+	TcpOpenAndConnectC(socket);
+	TRAPD(err, ReceiveHtmlL(socket));
+	TestConsole(err == KErrNone);
+	CleanupStack::PopAndDestroy(); // socket.
+	}
+
+void TcpGetLocalName()
+	{
+	RSocket socket;
+	TcpOpenAndConnectC(socket);
+	TSockAddr localName;
+	socket.LocalName(localName);
+	CleanupStack::PopAndDestroy(); // socket.
+	}
+
+void TcpGetRemoteName()
+	{
+	RSocket socket;
+	TcpOpenAndConnectC(socket);
+	TSockAddr remoteName;
+	socket.RemoteName(remoteName);
+	CleanupStack::PopAndDestroy(); // socket.
+	}
+
+void TcpListenAccept()
+	{
+	// Create a listening server socket and a socket to accept connections.
+	RSocket listeningSocket;
+	TestConsole(listeningSocket.Open(SocketServerSession, KAfInet, KSockStream, KProtocolInetTcp) == KErrNone);
+	TInetAddr addr(KLocalHostIpAddress, KLocalHostPort);
+	TestConsole(listeningSocket.Bind(addr) == KErrNone);
+	TestConsole(listeningSocket.Listen(1) == KErrNone);
+	RSocket serverConnectionSocket;
+	TestConsole(serverConnectionSocket.Open(SocketServerSession) == KErrNone);
+	TRequestStatus acceptStatus;
+	listeningSocket.Accept(serverConnectionSocket, acceptStatus);
+
+	// Create a client socket.
+	RSocket clientSocket;
+	TestConsole(clientSocket.Open(SocketServerSession, KAfInet, KSockStream, KProtocolInetTcp) == KErrNone);
+	TRequestStatus connectStatus;
+	clientSocket.Connect(addr,connectStatus);
+	User::WaitForRequest(connectStatus);
+	User::WaitForRequest(acceptStatus);
+	TestConsole(connectStatus.Int() == KErrNone);
+	TestConsole(acceptStatus.Int() == KErrNone);
+
+	// Write some data from the client to the server.
+	HBufC8* out = HBufC8::NewLC(KTestTransferDataSize);
+	TPtr8 outPtr(out->Des());
+	RandomFill(outPtr);
+	TRequestStatus writeStatus;
+	TRequestStatus readStatus;
+	HBufC8* in = HBufC8::NewLC(KTestTransferDataSize);
+	TPtr8 inPtr(in->Des());
+	clientSocket.Write(*out, writeStatus);
+	serverConnectionSocket.Read(inPtr, readStatus);
+	User::WaitForRequest(writeStatus);
+	User::WaitForRequest(readStatus);
+	TestConsole(writeStatus.Int() == KErrNone);
+	TestConsole(readStatus.Int() == KErrNone);
+	TestConsole(in->Compare(*out) == KErrNone);
+	clientSocket.Close();
+	serverConnectionSocket.Close();
+
+	// Re-connect the client socket.
+	TestConsole(clientSocket.Open(SocketServerSession, KAfInet, KSockStream, KProtocolInetTcp) == KErrNone);
+	TestConsole(serverConnectionSocket.Open(SocketServerSession) == KErrNone);
+	listeningSocket.Accept(serverConnectionSocket, acceptStatus);
+	clientSocket.Connect(addr,connectStatus);
+	User::WaitForRequest(connectStatus);
+	User::WaitForRequest(acceptStatus);
+	TestConsole(connectStatus.Int() == KErrNone);
+	TestConsole(acceptStatus.Int() == KErrNone);
+	listeningSocket.Close();
+
+	// Re-sent the data.
+	inPtr.Zero();
+	clientSocket.Read(inPtr, readStatus);
+	serverConnectionSocket.Write(*out, writeStatus);
+	User::WaitForRequest(writeStatus);
+	User::WaitForRequest(readStatus);
+	TestConsole(writeStatus.Int() == KErrNone);
+	TestConsole(readStatus.Int() == KErrNone);
+	TestConsole(in->Compare(*out) == KErrNone);
+
+	// Cleanup.
+	clientSocket.Close();
+	listeningSocket.Close();
+	CleanupStack::PopAndDestroy(2, out);
+	}
+
+void UdpSendReceive()
+	{
+	// Create a socket to receive data.
+	RSocket receiveSocket;
+	TestConsole(receiveSocket.Open(SocketServerSession, KAfInet, KSockDatagram, KProtocolInetUdp) == KErrNone);
+	TInetAddr receiveAddress(KLocalHostIpAddress, KLocalHostPort);
+	TestConsole(receiveSocket.Bind(receiveAddress) == KErrNone);
+	TBuf8<32> receiveBuf;
+	receiveBuf.SetMax();
+	receiveBuf.Fill('a');
+	TRequestStatus receiveStatus;
+	TInetAddr sendAddress;
+	receiveSocket.RecvFrom(receiveBuf, sendAddress, 0, receiveStatus);
+
+	// Create a socket to send data.
+	RSocket sendSocket;
+	TestConsole(sendSocket.Open(SocketServerSession, KAfInet, KSockDatagram, KProtocolInetUdp) == KErrNone);
+	TBuf8<32> sendBuf;
+	sendBuf.SetMax();
+	sendBuf.Fill('b');
+	TRequestStatus sendStatus;
+	sendSocket.SendTo(sendBuf, receiveAddress, 0, sendStatus);
+
+	// Wait and check.
+	User::WaitForRequest(receiveStatus);
+	User::WaitForRequest(sendStatus);
+	TestConsole(receiveStatus.Int() == KErrNone);
+	TestConsole(sendStatus.Int() == KErrNone);
+	TestConsole(receiveBuf.Compare(sendBuf) == KErrNone);
+
+	// Cleanup.
+	receiveSocket.Close();
+	sendSocket.Close();
+	}
+
+void GetSetOption()
+	{
+	RSocket socket;
+	TcpOpenAndConnectC(socket);
+	TInt val;
+	TestConsole(socket.GetOpt(KSoTcpNoDelay, KSolInetTcp, val) == KErrNone);
+	val = !val;
+	TestConsole(socket.SetOpt(KSoTcpNoDelay, KSolInetTcp, val) == KErrNone);
+	TInt newVal;
+	TestConsole(socket.GetOpt(KSoTcpNoDelay, KSolInetTcp, newVal) == KErrNone);
+	TestConsole(val == newVal);
+	TRAPD(err, ReceiveHtmlL(socket));
+	TestConsole(err == KErrNone);
+	CleanupStack::PopAndDestroy(); // socket.
+	}
+
+TInt InitialiseLC()
+	{
+	User::LeaveIfError(FileServerSession.Connect());
+	CleanupClosePushL(FileServerSession);
+	User::LeaveIfError(LogFile.Replace(FileServerSession, KLogFile,EFileShareAny | EFileWrite | EFileStreamText));
+	CleanupClosePushL(LogFile);
+	User::LeaveIfError(SocketServerSession.Connect());
+	CleanupClosePushL(SocketServerSession);
+	return 3;
+	}
+
+GLDEF_C void RunTestsL()
+	{
+	TInt numItemsOnCleanupStack = InitialiseLC();
+//	GetByAddress();
+	TcpActiveOpen();
+	TcpGetLocalName();
+	TcpGetRemoteName();
+	TcpListenAccept();
+	UdpSendReceive();
+	GetSetOption();
+	CleanupStack::PopAndDestroy(numItemsOnCleanupStack);
+	TestConsole.Close();
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CActiveScheduler* scheduler = new CActiveScheduler;
+	if (scheduler)
+		{
+		CActiveScheduler::Install(scheduler);
+		CTrapCleanup* cleanup = CTrapCleanup::New();
+		if (cleanup)
+			{
+			TRAPD(err, RunTestsL());
+			delete cleanup;
+			}
+		delete scheduler;
+		}
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/networking/winsockprt/tsrc/t_wsp.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,25 @@
+// t_wsp.mmp
+// 
+// Copyright (c) 2002 - 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+
+#include <fshell/common.mmh>
+
+OPTION CW	-w off
+
+TARGET          t_wsp.exe
+TARGETTYPE      exe
+UID		0x1000097b
+#include <fshell/fsh_system_include.mmh>
+
+SOURCEPATH	..\tsrc
+SOURCE          t_wsp.cpp
+
+LIBRARY		euser.lib esock.lib insock.lib efsrv.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/CommandInfoFile.pm	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,372 @@
+#!perl
+# CommandInfoFile.pm
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Description:
+# A Perl implementation of the C++ class CCommandInfoFile (in ioutils.dll).
+
+# Note, this code is intended to behave the same as the C++ version. It therefore used C++ like ways
+# doing things rather than Perl-like ways to keep the code as similar are possible.
+
+package CommandInfoFile;
+
+use strict;
+use IO::File;
+use File::Basename;
+
+
+#
+# Public Interface.
+#
+
+sub New {
+  my $pkg = shift;
+  my $fileName = shift;
+  my $self = _Construct($pkg);
+  $self->_ReadFile($fileName);
+  return $self;
+}
+
+sub Name($) {
+  my $self = shift;
+  return $self->{name};
+}
+
+sub FullName($) {
+  my $self = shift;
+  my $name = shift;
+
+  if (defined $name) {
+    $name = "$self->{name} $name";
+  }
+  else {
+    $name = $self->{name};
+  }
+
+  if ($self->{parent}) {
+    $name = $self->{parent}->FullName($name);
+  }
+
+  return $name;
+}
+
+sub ShortDescription($) {
+  my $self = shift;
+  return $self->{short_description};
+}
+
+sub LongDescription($) {
+  my $self = shift;
+  return $self->{long_description};
+}
+
+sub SeeAlso($) {
+  my $self = shift;
+  return $self->{see_also};
+}
+
+sub Copyright($) {
+  my $self = shift;
+  return $self->{copyright};
+}
+
+sub Arguments($) {
+  my $self = shift;
+  return $self->{arguments};
+}
+
+sub Options($) {
+  my $self = shift;
+  return $self->{options};
+}
+
+sub NumSubCommands($) {
+  my $self = shift;
+  my $numSubCommands = 0;
+  if (defined $self->{sub_commands}) {
+    $numSubCommands = scalar (@{$self->{sub_commands}});
+  }
+  return $numSubCommands;
+}
+
+sub SubCommand($$) {
+  my $self = shift;
+  my $index = shift;
+  die unless (($index >= 0) and ($index < $self->NumSubCommands()));
+  return $self->{sub_commands}->[$index];
+}
+
+
+#
+# Private.
+#
+
+sub _ReadFile($$) {
+  my $self = shift;
+  my $fileName = shift;
+
+  my $file = IO::File->new($fileName) or die "Error: Couldn't open '$fileName' for reading: $!\n";
+  my $pos = 0;
+  my $fileLength = -s $fileName;
+
+  while ($pos < $fileLength) {
+    if ($self->{process_include} or not defined $self->{current_child}) {
+      $self->_ReadDetails($file, $fileName);
+    }
+    else {
+      $self->{current_child}->_ReadDetails($file, $fileName);
+    }
+    $pos = $file->tell();
+  }
+  close ($file);
+}
+
+sub _ReadDetails($$$) {
+  my $self = shift;
+  my $file = shift;
+  my $fileName = shift;
+
+  my $pos = $file->tell();
+  TextToNextCommand($file); # Ignore everything before the first '==' command.
+  while (my $line = <$file>) {
+    if ($line =~ /^==name\s+(\S+)/) {
+      $self->{name} = $1;
+    }
+    elsif ($line =~ /^==short-description\s*$/) {
+      $self->{short_description} = TextToNextCommand($file);
+    }
+    elsif ($line =~ /^==long-description\s*$/) {
+      $self->{long_description} = TextToNextCommand($file);
+    }
+    elsif ($line =~ /^==see-also\s*$/) {
+      $self->{see_also} = TextToNextCommand($file);
+    }
+    elsif ($line =~ /^==copyright\s*$/) {
+      $self->{copyright} = TextToNextCommand($file);
+    }
+    elsif ($line =~ /^==argument\s+(.*)$/) {
+      push (@{$self->{arguments}}, ReadArgument($file, $1));
+    }
+    elsif ($line =~ /^==option\s+(.*)$/) {
+      push (@{$self->{options}}, ReadOption($file, $1));
+    }
+    elsif ($line =~ /^==include\s+(.*)$/) {
+      if (not exists $self->{parent}) {
+	$self->{process_include} = 0;
+	my $includeFileName = dirname($fileName) . "/$1";
+	$self->_ReadFile($includeFileName);
+	last;
+      }
+      else {
+	# We're a sub-command. Let control return to the root to handle the include.
+	$self->{parent}->_ProcessInclude($self);
+	$file->seek($pos, 0);
+	last;
+      }
+    }
+    elsif ($line =~ /^==sub-command\s+(.*)$/) {
+      if (not exists $self->{parent}) {
+	my @subCommandNames = split (/\s+/, $1);
+	$self->_AddSubCommand(\@subCommandNames, $file, $fileName);
+      }
+      else {
+	# We're a sub-command. Let control return to the root to handle the include.
+	$self->{parent}->_ProcessNewChild();
+	$file->seek($pos, 0);
+	last;
+      }
+    }
+
+    $pos = $file->tell();
+  }
+}
+
+sub _ProcessNewChild($) {
+  my $self = shift;
+
+  if ($self->{parent}) {
+    $self->{parent}->_ProcessNewChild();
+  }
+  else {
+    die if ($self->{process_include});
+    undef $self->{current_child};
+  }
+}
+
+sub _ProcessInclude($$) {
+  my $self = shift;
+  my $child = shift;
+
+  if ($self->{parent}) {
+    $self->{parent}->_ProcessInclude($child);
+  }
+  else {
+    $self->{process_include} = 1;
+    $self->{current_child} = $child;
+  }
+}
+
+sub _AddSubCommand($$$$) {
+  my $self = shift;
+  my $subCommandNames = shift;
+  my $file = shift;
+  my $fileName = shift;
+  my $subCommandName = shift @$subCommandNames;
+
+  my $found = 0;
+  for (my $i = ($self->NumSubCommands() - 1); $i >= 0; --$i) {
+    if ($self->{sub_commands}->[$i]->{name} eq $subCommandName) {
+      $self->{sub_commands}->[$i]->_AddSubCommand($subCommandNames, $file, $fileName);
+      $found = 1;
+      last;
+    }
+  }
+
+  die unless ($found or (@$subCommandNames == 0));
+
+  if (not $found) {
+    my $newCif = _Construct('CommandInfoFile');
+    $newCif->{name} = $subCommandName;
+    $newCif->{parent} = $self;
+    $newCif->_ReadDetails($file, $fileName);
+    push (@{$self->{sub_commands}}, $newCif);
+  }
+}
+
+sub _Construct($) {
+  my $pkg = shift;
+  my $self = {};
+  bless $self, $pkg;
+
+  push (@{$self->{options}}, {
+			      type => 'bool',
+			      short_name => 'h',
+			      long_name => 'help',
+			      description => 'Display help.'
+			     });
+
+  return $self;
+}
+
+sub ReadArgument($$) {
+  my $file = shift;
+  my @args = split (/\s+/, shift);
+
+  my $argumentEntry = {};
+
+  $argumentEntry->{type} = shift @args;
+  $argumentEntry->{name} = shift @args;
+
+  foreach my $arg (@args) {
+    if ($arg eq 'optional') {
+      $argumentEntry->{flags}->{optional} = 1;
+    }
+    elsif ($arg eq 'multiple') {
+      $argumentEntry->{flags}->{multiple} = 1;
+    }
+    elsif ($arg eq 'last') {
+      $argumentEntry->{flags}->{last} = 1;
+    }
+    else {
+      $argumentEntry->{env_var} = $arg;
+    }
+  }
+
+  die "Error: Argument missing type\n" unless defined $argumentEntry->{type};
+  die "Error: Argument missing name\n" unless defined $argumentEntry->{name};
+
+  $argumentEntry->{description} = TextToNextCommand($file);
+  $argumentEntry->{description} =~ s/\s*$//;
+
+  if ($argumentEntry->{type} eq 'enum') {
+    $argumentEntry->{enum_values} = GetEnumValues($file);
+  }
+
+  return $argumentEntry;
+}
+
+sub ReadOption($$) {
+  my $file = shift;
+  my @args = split (/\s+/, shift);
+
+  my $optionEntry = {};
+
+  $optionEntry->{type} = shift @args;
+  $optionEntry->{short_name} = shift @args;
+  $optionEntry->{long_name} = shift @args;
+
+  foreach my $arg (@args) {
+    if ($arg eq 'multiple') {
+      $optionEntry->{flags}->{multiple} = 1;
+    }
+    else {
+      $optionEntry->{env_var} = $arg;
+    }
+  }
+
+  die "Error: Option missing type\n" unless defined $optionEntry->{type};
+  die "Error: Option missing short name\n" unless defined $optionEntry->{short_name};
+  die "Error: Option short name not a single character\n" unless length ($optionEntry->{short_name}) == 1;
+  die "Error: Option missing long name\n" unless defined $optionEntry->{long_name};
+
+  $optionEntry->{description} = TextToNextCommand($file);
+
+  if ($optionEntry->{type} eq 'enum') {
+    $optionEntry->{enum_values} = GetEnumValues($file);
+  }
+
+  return $optionEntry;
+}
+
+sub GetEnumValues($) {
+  my $file = shift;
+
+  my @values;
+
+  my $pos = $file->tell();
+  while (my $line = <$file>) {
+    if ($line =~ /^==enum-value\s+(\S+)/) {
+      my $value = $1;
+      my $description = TextToNextCommand($file);
+      push (@values, {
+		      value => $value,
+		      description => $description
+		     });
+    }
+    else {
+      $file->seek ($pos, 0);
+      last;
+    }
+    $pos = $file->tell();
+  }
+
+  return \@values;
+}
+
+sub TextToNextCommand($) {
+  my $file = shift;
+  my $text = '';
+  my $pos = $file->tell();
+  while (my $line = <$file>) {
+    if ($line =~ /^==/) {
+      $file->seek($pos, 0);
+      last;
+    }
+    else {
+      $text .= $line;
+    }
+    $pos = $file->tell();
+  }
+  return $text;
+}
+
+1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,658 @@
+#!perl
+# createsrc
+# 
+# Copyright (c) 2009 - 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+use strict;
+use Getopt::Long;
+use Cwd;
+use FindBin;
+
+# forward decls
+sub homeDir();
+sub processCommandLine();
+sub Usage();
+sub make4CharId($);
+sub caseRename($$$);
+sub renameFileCopy($$);
+sub GetMacroValue($);
+sub PromptMacro($);
+sub CheckMacro($$);
+sub CheckUid($);
+sub CheckIdentifier($);
+sub listTemplates($);
+sub getTemplates();
+sub query($$);
+sub getConfigFileName();
+sub getConfig($);
+sub setConfig($$);
+sub setCopyright($);
+
+
+#globals
+my $template;
+my $newName;
+my $templateDir;
+my $templateName = "SkeletonTemplate";
+my $dest;
+my $help;
+my $verbose = 0;
+my %macroValue;
+my %macroDescription = ( 'UID' => 'a UID', 'COPYRIGHT' => 'a copyright notice' );
+my $homeDir;
+my $listTemplates;
+my $overwrite = 0;
+my $addToPerforce = 0;
+my $addToMercurial = 0;
+my $interactive = 0;
+
+processCommandLine();
+
+unless (defined $macroValue{'COPYRIGHT'}) {
+	$macroValue{'COPYRIGHT'} = getConfig('copyright');
+	$macroValue{'COPYRIGHT'} = "Copyright (c) [[YEAR]] Accenture. All rights reserved." unless $macroValue{'COPYRIGHT'};
+}
+
+
+$homeDir = homeDir() unless defined ($homeDir);
+
+my $year = [localtime()]->[5]+1900;
+$macroValue{'COPYRIGHT'} =~ s|\[\[YEAR\]\]|$year|g;
+
+if ($interactive) {
+  my $templates = getTemplates();
+  print "Available Templates:\n";
+  my $count = 1;
+  my $options="";
+  foreach my $template (@$templates) {
+    print "$count) $template->[0] - $template->[1]\n";
+    $options=$options . $count;
+    $count++;
+  }
+  do {
+  	print "Which template do you want to use? ";
+  	my $in = <>;
+  	chomp $in;
+  	my $choice;
+  	$choice = eval "int($in)";
+  	unless ($@) {
+  	  if (($choice>0) && ($choice <= scalar(@$templates))) {
+  	    $template = $templates->[$choice-1]->[0];
+  	  }
+  	}
+  	my $max = $count-1;
+    print "Please enter a number between 1 and $max\n" unless defined $template;
+  }	until (defined $template);
+  print "Using template $template\n" if $verbose;
+  
+  do {
+    print "Name for the new code? ";
+    $newName = <>;
+    chomp $newName;
+    
+    unless (CheckIdentifier($newName)) {
+      print "$newName is not a valid C++ identifier\n";
+      undef $newName;
+    }
+   
+  } until ((defined $newName) && (length $newName));
+  
+   my $cwd = cwd();
+   print "Directoy to create new code in? [$cwd] ";
+   $dest = <>;
+   chomp $dest;
+   $dest = $cwd unless (length $dest);
+  
+} else {
+
+  $dest = cwd() unless $dest;
+  
+}
+
+$templateDir = $homeDir."/createsrc-templates/$template";
+die "ERROR: Template $template not found at $templateDir\n" unless -d $templateDir;
+
+$dest =~ s|\\|/|g;
+$dest =~ s|/$||;
+print "Creating $newName at $dest from template $template at $templateDir\n" if ($verbose);
+
+# read [[MACRO]] descriptions from .txt file
+my $infoFile;
+my $infoFileName = "$templateDir.txt";
+if ((-f $infoFileName) && (open $infoFile, $infoFileName)) {
+	print "Reading $infoFileName\n" if ($verbose);
+	<$infoFile>; # skip template description
+	while (my $line = <$infoFile>) {
+		chomp $line;
+		$line =~ s|#.*||; # remove perl style comments
+		if ($line =~ m|^\s*(\w[\w\d]*)\s*\:\s*(.*)$|) {
+			my ($macro, $desc) = ($1, $2);
+			print "Macro '$macro': '$desc'\n" if ($verbose>1);
+			$macroDescription{$macro} = $desc;
+		} elsif ($line =~ m|^\s*$|) {
+			# blank line
+		} else {
+			die "Error: cannot parse line $. of $infoFileName\n";
+		}
+	}
+	
+	close $infoFile;
+}
+
+unless (-d $dest) {
+  mkdir($dest) or die "ERROR: Couldn't create directory $dest: $!\n";
+  print "Created directory $dest\n" if ($verbose>1);
+}
+
+my @dirStack;
+push @dirStack, "";
+
+
+while ($#dirStack>=0) {
+  my $dir = pop(@dirStack);
+
+  my $dirName = $dir;
+  $dir = "/$dir" unless ($dir eq "") || ($dir =~ m|^/|);
+
+  # create destination directory
+  unless (-d "$dest$dir") {
+    mkdir "$dest$dir" or die "ERROR: cannot create directory $dest$dir: $!\n";
+    print "Created directory $dest$dir\n" if ($verbose);
+  }
+
+  # read template directory contents
+  opendir DIR, "$templateDir$dir";
+  my @dirContents = readdir(DIR);
+  closedir(DIR);
+
+  foreach my $f (@dirContents) {
+    if (-f "$templateDir$dir/$f") {
+      my $newFile = caseRename($f, $templateName, $newName);
+      print "Renaming from $templateDir$dir/$f to $dest$dir/$newFile\n" if ($verbose);
+      renameFileCopy("$templateDir$dir/$f", "$dest$dir/$newFile"); 
+    } elsif (-d "$templateDir$dir/$f") {
+      unless ($f =~ m|^\.\.?$|) {
+        print "Adding $dirName/$f to stack\n" if ($verbose);
+        push @dirStack, "$dirName/$f";
+      }
+    } else {
+      print "WARNING: $templateDir$dir/$f is neither a file nor a directory";
+    }
+  }
+
+}
+
+
+
+sub homeDir() {
+  my $homeDir = $FindBin::Bin;
+  print "homeDir=$homeDir\n" if ($verbose > 1);
+  return $homeDir;
+}
+
+sub processCommandLine() {
+  my $setCopyright = undef;
+  Getopt::Long::Configure("bundling");
+  my @macroDefs;
+  GetOptions('h'   => \$help,
+             'v+'  => \$verbose,
+             'd=s' => \$dest,
+             's=s' => \$homeDir,
+             't=s' => \$templateName,
+             'l'   => \$listTemplates,
+             'o'   => \$overwrite,
+             'p'   => \$addToPerforce,
+	     'm'   => \$addToMercurial,
+             'i'   => \$interactive,
+             'c=s' => \$setCopyright,
+	     'D=s' => \@macroDefs);
+
+  Usage() if ($help);
+
+  listTemplates(1) if ($listTemplates);
+  
+  setCopyright($setCopyright) if (defined $setCopyright);
+
+  unless ($interactive) {
+    if ($#ARGV < 1) {
+      print "Insufficient arguments; entering interactive mode\n";
+      $interactive = 1;
+    } else {
+      $template = shift(@ARGV);
+      $newName = shift(@ARGV);
+      die "$newName is not a valid C++ identifier\n" unless CheckIdentifier($newName);
+    }
+  }
+  foreach my $d (@macroDefs) {
+	if ($d =~ m|^(\w[\w\d]*)=(.*)$|) {
+		my ($macro, $value) = ($1, $2);
+		print "Got macro '$macro'='$value' from command line\n" if ($verbose>1);
+		die "Error: '$value' is not a valid value for $macro\n" unless CheckMacro($macro, $value);
+		$macroValue{$macro} = $value;
+	} else {
+		die "Error: Incorrect usage of -D: $d: expected a string of the format 'id=value'\n";
+	}
+  }  
+  print "Warning: ignoring " . scalar(@ARGV) . " extra arguments\n" if scalar(@ARGV);
+}
+
+sub Usage() {
+  require Pod::Text;
+  my $parser = Pod::Text->new();
+  $parser->parse_from_file($0);
+  exit;
+}
+
+sub make4CharId($) {
+	my $longId = shift;
+	while (length($longId)<2) {
+		$longId = $longId . '_';
+	}
+	return uc( substr($longId, 0, 2) . substr($longId, length($longId)-2, 2) );
+}
+
+sub caseRename($$$) {
+  my $string = shift;
+  my $oldName = shift;
+  my $newName = shift;
+
+  my $oldUpper = $oldName;
+  $oldUpper =~ tr/a-z/A-Z/;
+
+  my $oldLower = $oldName;
+  $oldLower =~ tr/A-Z/a-z/;
+
+  my $oldLowerFirst = "\l$oldName;\E";
+
+  my $uppercase = $newName;
+  $uppercase =~ tr/a-z/A-Z/;
+
+  my $lowercase = $newName;
+  $lowercase =~ tr/A-Z/a-z/;
+
+  my $lowerFirst = "\l$newName\E";
+  
+  my $old4Char = make4CharId($oldName);
+  my $new4Char = make4CharId($newName);
+
+  $string =~ s/$oldName/$newName/g;
+  $string =~ s/$oldUpper/$uppercase/g;
+  $string =~ s/$oldLower/$lowercase/g;
+  $string =~ s/$oldLowerFirst/$lowerFirst/g;
+  $string =~ s/$old4Char/$new4Char/g;
+  return $string;
+}
+
+sub renameFileCopy($$) {
+  my $src = shift;
+  my $dest = shift;
+  open SOURCE, "<$src" or die "ERROR: can't open $src for reading: $!\n";
+  unless ($overwrite) {
+    die "ERROR: $dest already exists. Use -o to overwrite. Aborting.\n" if (-f $dest);
+  }
+  open DEST, ">$dest" or die "ERROR: can't open $dest for writing: $!\n";
+  while (my $line = <SOURCE>) {
+    while ($line =~ m|\[\[(\w[\w\d]*)\]\]|) {
+	my $id = $1;
+	my $value = GetMacroValue($id);
+	$line =~ s|\[\[$id\]\]|$value|g;
+    }
+    print DEST caseRename($line, $templateName, $newName);
+    
+  }
+  close (SOURCE);
+  close (DEST);
+  if ($addToPerforce) {
+    print "p4 add $dest\n";
+    `p4 add $dest` ;
+  }
+  if ($addToMercurial) {
+    print "hg add $dest\n";
+    `hg add $dest` ;
+  }
+}
+
+sub GetMacroValue($) {
+	my $macro = shift;
+	if (!defined($macroValue{$macro})) {
+		$macroValue{$macro} = PromptMacro($macro);
+	}
+	return $macroValue{$macro};
+}
+
+sub PromptMacro($) {
+	my $macro = shift;
+	my $description = $macroDescription{$macro};
+	$description = $macro unless defined $description;		
+	
+	print "Enter $description for $newName: ";
+	my $value;
+	do  {
+		$value = <>;
+		chomp $value;
+	} while (!CheckMacro($macro, $value));
+	return $value;
+}
+
+sub CheckMacro($$) {
+	my ($macro, $value) = @_;
+	if ($macro eq 'UID') {
+		return CheckUid($value);
+	}
+	return 1;
+}
+
+sub CheckUid($) {
+  my $uid = shift;
+  return 1 if ($uid =~ m|^0x[0-9a-f]{1,8}$|i);
+  return 1 if ($uid =~ m|^[0-9]{1,10}$|);
+  return 0;
+}
+
+sub CheckIdentifier($)	{
+  my $id = shift;
+  return ($id =~ m|[A-Za-z_][A-Za-z_0-9]*|);
+}
+
+sub getTemplates() {
+  $homeDir = homeDir() unless defined ($homeDir);
+  opendir TEMPLATES, "$homeDir/createsrc-templates" or die "Can't read directory $homeDir/createsrc-templates: $!\n";
+  my @templateNames = grep((-d "$homeDir/createsrc-templates/$_")&&!(m|\.\.?|), readdir(TEMPLATES));
+  close TEMPLATES;
+  die "No templates found at $homeDir/createsrc-templates\n" unless scalar(@templateNames);
+  my @templates = ();
+  foreach my $template (@templateNames) {
+  	my $desc;
+    my $descFile = "$homeDir/createsrc-templates/$template.txt";
+    if ((-f $descFile)&&(open DESC, $descFile)) {
+      $desc = <DESC>;
+      chomp $desc;
+      close DESC;
+    } else {
+     $desc = "<no description>";
+    }
+    push @templates, [$template, $desc];
+  }
+  @templates = sort {$a->[0] cmp $b->[0]} @templates;
+  return \@templates;
+}
+
+sub listTemplates($) {
+  my $exitWhenDone = shift;
+  my $templates = getTemplates();
+  foreach my $template (@$templates) {
+    print $template->[0] . " - " . $template->[1] . "\n";
+  }
+  exit if $exitWhenDone;
+}
+
+sub getConfigFileName() {
+  my $fn;
+  if (defined $ENV{'USERPROFILE'}) {
+    $fn = $ENV{'USERPROFILE'};
+  } else {
+    $fn = homeDir();
+  }
+  $fn =~ s|[/\\]$||;
+  $fn .= "\\createsrc.cfg";
+  return $fn;
+}
+
+sub getConfig($) {
+  my $findKey = shift;
+  my $cfg = getConfigFileName();
+  my $foundValue = undef;
+  open CFGFILE, "<$cfg" or return undef;
+  print "Reading $cfg\n" if ($verbose);
+  while (my $line = <CFGFILE>) {
+    chomp $line;
+    if ($line =~ m|^(.*?)\s*=\s*(.*)$|)	{
+      my ($key, $value) = ($1, $2);
+      print "Read '$key'='$value'\n" if ($verbose>1);
+      $foundValue = $value if ($key eq $findKey);
+    } else {
+      print "ignoring line '$line'\n" if ($verbose>1);
+    }
+  }
+  return $foundValue;
+  close CFGFILE;  
+}
+
+sub setConfig($$) {
+  my ($key, $value) = @_;
+  my $cfg = getConfigFileName();
+  my @lines;
+  if (open CFGFILE, "<$cfg") {
+    print "Reading $cfg\n";
+    @lines = <CFGFILE>;
+    close CFGFILE;
+  }
+  open CFGFILE, ">$cfg" or die "Cannot write to $cfg: $!\n";
+  print "Writing $cfg\n" if ($verbose);
+  my $written = 0;
+  foreach my $line (@lines) {
+    if ($line =~ m|^(.*?)\s*=\s*(.*)$|)	{
+      my ($foundKey, $foundValue) = ($1, $2);
+      print "Read '$foundKey'='$foundValue'\n" if ($verbose>1);
+      if ($key eq $foundKey) {
+        $foundValue = $value;
+        $written = 1;
+        print "Updated key $foundKey to '$foundValue'\n" if ($verbose>1);
+      }
+      print CFGFILE "$foundKey=$foundValue\n";
+    } else {
+      print "ignoring line '$line'\n" if ($verbose>1);
+      print CFGFILE $line;
+    }
+  }
+  unless ($written) {
+    print "Adding $key=$value\n";
+    print CFGFILE "$key=$value\n";
+  }
+  close CFGFILE;
+  
+}
+
+sub setCopyright($) {
+  my $copyright =  shift;
+  print "Setting copyright notice to '$copyright'\n" if ($verbose);
+  setConfig('copyright', $copyright);
+  exit(1);
+}
+
+
+__END__
+
+=head1 NAME
+
+createsrc - creates new code from templates
+
+=head1 SYNOPSIS
+
+	createsrc [options] [TemplateName NewName]
+
+options:
+
+=over
+
+=item -i
+
+Use L<Interactive mode>. This will be the default if C<TemplateName> and C<NewName> are not given.
+
+=item -d <directory>
+
+Put the new code in the specified directory. Defaults to current directory.
+
+=item -DMACRO=value
+
+Specfies a value for a macro. See "Macros" section below.
+
+=item -c "Copyright Notice"
+
+Sets the default copyright to use when none other is specified. See L<Copyright Notices> below.
+
+=item -o
+
+Overwrites any existing files when creating the new code.
+
+=item -p
+
+Add the new files to perforce as they are created.
+
+=item -m
+
+Add the new files to mercurial as they are created.
+
+=item -s <directory>
+
+Specifies the home directory of the script, where the templates are located. Defaults to the directory where the script is located.
+
+=item -t <TemplateText>
+
+Specified the text to be replaced in the template. Defaults to C<SkeletonTemplate>. It's not usually necessary to change this.
+
+=item -l
+
+List available templates, then exits.
+
+=item -h
+
+Shows this help.
+
+=item -v
+
+Verbose mode (-vv very verbose).
+
+=back
+
+=head1 DESCRIPTION
+
+This script creates new projects or code snippets from templates. For example, assuming you have a template C<UiqBasic> that consists of a basic UIQ application, you could create a HelloWorld application as follows:
+
+	createsrc UiqBasic HelloWorld
+
+When creating the new code, it performs the following steps:
+
+=over
+
+=item 1.
+
+Copies and renames the files as appropriate.
+
+=item 2.
+
+Replaces text within the files as appropriate.
+
+=item 3.
+
+Substitutes macros enclosed in double square brackets, C<[[MACRO]]>.
+
+=back
+
+When renaming files or substituting text withing the files, case is preseved as follows:
+
+=over
+
+=item 1.
+
+C<MixedCaseText> is preserved - i.e. C<TemplateText> becomes C<NewText>.
+
+=item 2.
+
+C<lowercasetext> is preserved - i.e. C<templatetext> becomes C<newtext>.
+
+=item 3.
+
+C<UPPERCASETEXT> is preserved - i.e. C<TEMPLATETEXT> becomes C<NEWTEXT>.
+
+=item 4.
+
+C<lowerCaseFirst> is preserved - i.e. C<templateText> becomes C<newText>.
+
+=back
+
+This should cover all forms of capitalisation used within normal Symbian code.
+
+In addition, the capitalised first and last two letters of C<TemplateText> is replaced with the same letters of C<NewText> - i.e. C<TEXT> becomes C<NEXT>. This is to support the C<NAME> value in an applications resource file, which must always have 4 letters.
+
+If the new text has less than 4 characters, it will be padded with underscores. For example, an application called C<A> will be given a C<NAME> of C<A_A_>; C<Ap> becomes C<APAP>; C<HelloWorld> becomes C<HELD> and so on.
+
+=head2 Interactive mode
+
+If the C<-i> option is given, of if no C<TemplateName> and C<TemplateText> are given, interactive mode will be used:
+
+	D:\work\new>createsrc
+	Insufficient arguments; entering interactive mode
+	Available Templates:
+	1) UiqBasic - Basic UIQ application
+	2) UiqImaging - Basic UIQ application with one large control, suitable for displaying an image, a video, etc.
+	3) UiqList - Basic UIQ application with a list in the view.
+	4) server - Symbian 9 transient server
+	Which template do you want to use? 1
+	Name for the new code? HelloWorld
+	Directoy to create new code in? [D:/work/new]
+	Enter a UID for HelloWorld: 0x10002000
+
+When prompted for the directory to create the code in, simply hit enter to use the suggestion in square brackets. Or you can enter a relative or absolute path name to use instead.
+
+=head2 Macros
+
+Macros allow extra custom strings to be inserted into the generate code. Macro values can be specified on the command line using the C<-D> option; if no value is specified then it will be prompted for at runtime.
+
+There are two macros that are used by all (or most) templates:
+
+=over
+
+=item C<COPYRIGHT>
+
+Defines a copyright notice for the code, usually inserted in a comment at the top of each source file. See L<Copyright Notices> below.
+
+=item C<UID>
+
+Specifies a UID for the new code. This will be verified as a valid integer.
+
+=back
+
+Some templates may define other, custom macros. To define a macro value on the command line, use -D syntax in a similar way the a C preprocessor:
+
+	createsrc -DUID=0x01234567
+
+
+=head2 Copyright Notices
+
+Copyright notices are automatically inserted into the source files, including the current year. When using the C<-DCOPYRIGHT=...> and C<-c> options, the copyright text may include C<[[YEAR]]>, which will be replaced with the current year when the code was created.
+
+For example,
+
+	createsrc -DCOPYRIGHT="Copyright (c) [[YEAR]] Joe Bloggs. All rights reserved"
+
+The default copyright notice is C<Copyright (c) [[YEAR]] Accenture. All rights reserved.>
+
+When the C<-c> option is used, the copyright notice is stored in C<%USERPROFILE%\createsrc.cfg> and so is persisted for future runs of C<createsrc>.
+
+=head2 Templates
+
+The templates are located in F<\epoc32\tools\Templates\TemplateName>. Each template usually contains an entire buildable project, but this may vary depending upon the nature of the template. The text that is replaced in template filenames and files is C<SkeletonTemplate> by default, but this can be modified with the C<-t TemplateText> option (although it is not recommended).
+
+In the template, macros are enclosed in double square brackets, for example C<[[UID]]>. Templates should make use of the standard C<[[UID]]> and C<[[COPYRIGHT]]> macros and can use others if necessary.
+
+If a F<TemplateName.txt> file is found in F<\epoc32\tools\Templates>, the first line of this file will be used as the description of the template when the C<-l> flag is given. The remainder of the file is expected to contain lines of the format:
+
+	MACRO: description
+
+giving descriptions for any custom macros used in the project. The descriptions will be used instead of the macro name when prmopting the user for a value at runtime.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,1 @@
+A simple console app, with an active scheduler loop in it
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/group/SkeletonTemplate.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+// SkeletonTemplate.mmp
+//
+// [[COPYRIGHT]]
+//
+
+#include "..\inc\SkeletonTemplateUid.h"
+
+TARGET		SkeletonTemplate.exe
+TARGETTYPE	exe
+UID		0x1000008d KSkeletonTemplateUid
+
+SOURCEPATH	..\rsc
+
+START RESOURCE	SkeletonTemplate_reg.rss
+TARGETPATH	\private\10003a3f\apps
+END
+
+START RESOURCE	SkeletonTemplate_loc.rss
+TARGETPATH	\Resource\Apps
+END
+
+SOURCEPATH 	..\src
+SOURCE		SkeletonTemplate.cpp 
+
+USERINCLUDE	..\inc
+SYSTEMINCLUDE	+\include
+LIBRARY		euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/group/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,11 @@
+// bld.inf
+//
+// [[COPYRIGHT]]
+//
+
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+SkeletonTemplate
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/group/sis/SkeletonTemplate_armv5.pkg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+; SkeletonTemplate.pkg
+;
+; [[COPYRIGHT]]
+;
+
+; List of localised vendor name
+%{"SkeletonTemplate"}
+
+; The non-localised, globally unique vendor name
+:"Symbian"
+
+; Package header
+; Name, UID3, Major, Minor, Build, Package-type
+#{"SkeletonTemplate"}, ([[UID]]), 1, 0, 0, TYPE=SA
+
+; ProductID for UIQ 3.0
+; Product/platform version UID, Major, Minor, Build, Component name
+(0x101F6300), 3, 0, 0, {"UIQ30ProductID"}
+
+; Files to install for the application
+"\EPOC32\RELEASE\armv5\UREL\SkeletonTemplate.exe"-"!:\sys\bin\SkeletonTemplate.exe"
+"\EPOC32\DATA\Z\Resource\Apps\SkeletonTemplate_loc.RSC"-"!:\Resource\Apps\SkeletonTemplate_loc.RSC"
+"\EPOC32\DATA\Z\private\10003a3f\apps\SkeletonTemplate_reg.RSC"-"!:\private\10003a3f\import\apps\SkeletonTemplate_reg.RSC"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/group/sis/SkeletonTemplate_gcce.pkg	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,23 @@
+; SkeletonTemplate.pkg
+;
+; [[COPYRIGHT]]
+;
+
+; List of localised vendor name
+%{"SkeletonTemplate"}
+
+; The non-localised, globally unique vendor name
+:"Symbian"
+
+; Package header
+; Name, UID3, Major, Minor, Build, Package-type
+#{"SkeletonTemplate"}, ([[UID]]), 1, 0, 0, TYPE=SA
+
+; ProductID for UIQ 3.0
+; Product/platform version UID, Major, Minor, Build, Component name
+(0x101F6300), 3, 0, 0, {"UIQ30ProductID"}
+
+; Files to install for the application
+"\EPOC32\RELEASE\GCCE\UREL\SkeletonTemplate.exe"-"!:\sys\bin\SkeletonTemplate.exe"
+"\EPOC32\DATA\Z\Resource\Apps\SkeletonTemplate_loc.RSC"-"!:\Resource\Apps\SkeletonTemplate_loc.RSC"
+"\EPOC32\DATA\Z\private\10003a3f\apps\SkeletonTemplate_reg.RSC"-"!:\private\10003a3f\import\apps\SkeletonTemplate_reg.RSC"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/inc/SkeletonTemplate.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,30 @@
+// SkeletonTemplate.h
+//
+// Copyright (c) 2010 Accenture. All rights reserved.
+//
+
+#ifndef SKELETONTEMPLATE_H__
+#define SKELETONTEMPLATE_H__
+
+class CSkeletonTemplate : public CActive
+	{
+public:
+	static CSkeletonTemplate* NewLC(CConsoleBase& aConsole);
+	static CSkeletonTemplate* NewL(CConsoleBase& aConsole);
+	
+	~CSkeletonTemplate();
+	
+	void Start();
+	
+	// from CActive:
+	virtual void RunL();
+	virtual void DoCancel();
+private:
+	CSkeletonTemplate(CConsoleBase& aConsole);
+	void ConstructL();
+private:
+	CConsoleBase& iConsole;
+	};
+
+
+#endif //SKELETONTEMPLATE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/inc/SkeletonTemplateUid.h	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,11 @@
+// SkeletonTemplateUid.h
+//
+// [[COPYRIGHT]]
+//
+
+#ifndef _SKELETONTEMPLATEUID_H
+#define _SKELETONTEMPLATEUID_H
+
+#define KSkeletonTemplateUid [[UID]]
+
+#endif //_SKELETONTEMPLATEUID_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/rsc/SkeletonTemplate_loc.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,18 @@
+// SkeletonTemplate_loc.rss
+//
+// [[COPYRIGHT]]
+//
+
+#include <AppInfo.rh>
+
+// This file localise the applications icons and caption
+RESOURCE LOCALISABLE_APP_INFO
+	{
+	caption_and_icon =
+		{
+		CAPTION_AND_ICON_INFO
+			{
+			caption = "SkeletonTemplate";
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/rsc/SkeletonTemplate_reg.rss	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,17 @@
+// SkeletonTemplate_reg.rss
+//
+// [[COPYRIGHT]]
+//
+
+// All registration files need to #include appinfo.rh. 
+#include <AppInfo.rh>
+#include "SkeletonTemplateUid.h"
+
+UID2 KUidAppRegistrationResourceFile
+UID3 KSkeletonTemplateUid
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "SkeletonTemplate"; // filename of application binary (minus extension)
+	localisable_resource_file = "\\Resource\\Apps\\SkeletonTemplate_loc";
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/AsConsole/src/SkeletonTemplate.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,118 @@
+// SkeletonTemplate.cpp
+//
+// [[COPYRIGHT]]
+//
+
+#include <e32base.h>
+#include <e32cons.h>
+#include "SkeletonTemplate.h"
+
+void MainL()
+	{
+	CConsoleBase* cons = Console::NewL(_L(" SkeletonTemplate "), TSize(KConsFullScreen, KConsFullScreen));
+	CleanupStack::PushL(cons);
+	
+	CActiveScheduler* as = new(ELeave)CActiveScheduler();
+	CleanupStack::PushL(as);
+	CActiveScheduler::Install(as);
+	
+	CSkeletonTemplate* echo = CSkeletonTemplate::NewLC(*cons);
+	
+	cons->Printf(_L("Hello World!\n"));
+	cons->Printf(_L("Press escape to exit\n"));
+	
+	echo->Start();
+	
+	CActiveScheduler::Start();
+	
+	
+	CleanupStack::PopAndDestroy(3); // cons, as, echo
+	}
+
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack
+	TInt err = KErrNone;
+	
+	if (cleanup)
+		{
+		TRAP(err, MainL() );
+		delete cleanup; // destroy clean-up stack
+		}
+	else
+		{
+		err = KErrNoMemory;
+		}
+	
+	__UHEAP_MARKEND;
+	return err;
+	}
+	
+//______________________________________________________________________________
+//						CSkeletonTemplate
+CSkeletonTemplate* CSkeletonTemplate::NewLC(CConsoleBase& aConsole)
+	{
+	CSkeletonTemplate* self = new(ELeave)CSkeletonTemplate(aConsole);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSkeletonTemplate* CSkeletonTemplate::NewL(CConsoleBase& aConsole)
+	{
+	CSkeletonTemplate* self = NewLC(aConsole);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CSkeletonTemplate::~CSkeletonTemplate()
+	{
+	Cancel();
+	}
+	
+void CSkeletonTemplate::Start()
+	{
+	if (!IsActive())
+		{
+		iConsole.Read(iStatus);
+		SetActive();
+		}
+	}
+
+void CSkeletonTemplate::RunL()
+	{
+	TKeyCode key = iConsole.KeyCode();
+	if (key == EKeyEscape)
+		{
+		CActiveScheduler::Stop();
+		return;
+		}
+	else if (key == EKeyEnter)
+		{
+		iConsole.Printf(_L("\n"));
+		}
+	else
+		{
+		TBuf<1> buf;
+		buf.Append(key);
+		iConsole.Write(buf);
+		}
+	// reissue read request
+	Start();
+	}
+
+void CSkeletonTemplate::DoCancel()
+	{
+	iConsole.ReadCancel();
+	}
+
+CSkeletonTemplate::CSkeletonTemplate(CConsoleBase& aConsole)
+	: CActive(CActive::EPriorityStandard), iConsole(aConsole)
+	{
+	}
+
+void CSkeletonTemplate::ConstructL()
+	{
+	CActiveScheduler::Add(this);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/FshellCmd.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2 @@
+An fshell command uses a CIF file.
+DESCRIPTION: short description of the command (for the .cif file)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/FshellCmd/SkeletonTemplate.cif	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,31 @@
+==name skeletontemplate
+
+==short-description
+
+[[DESCRIPTION]]
+
+==long-description
+
+TODO (POD syntax is supported)
+
+#Other sections that may be included:
+#
+#==see-also
+#
+# A list of POD links to any other related commands, such as
+# L<cmd|cmd>, L<somethingelse|somethingelse>
+# Can be left blank
+#
+#
+#==option <type> <shortName> <longName>
+#
+#Description for this option
+#
+#==argument <type> <name> [optional] [multiple|last]
+#
+#Description for this argument
+#
+
+==copyright
+
+[[COPYRIGHT]]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/FshellCmd/SkeletonTemplate.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,66 @@
+// SkeletonTemplate.cpp
+//
+// [[COPYRIGHT]]
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdSkeletonTemplate : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSkeletonTemplate();
+private:
+	CCmdSkeletonTemplate();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	//TODO: arguments/options
+	};
+
+EXE_BOILER_PLATE(CCmdSkeletonTemplate)
+
+CCommandBase* CCmdSkeletonTemplate::NewLC()
+	{
+	CCmdSkeletonTemplate* self = new(ELeave) CCmdSkeletonTemplate();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSkeletonTemplate::~CCmdSkeletonTemplate()
+	{
+	}
+
+CCmdSkeletonTemplate::CCmdSkeletonTemplate()
+	{
+	}
+
+const TDesC& CCmdSkeletonTemplate::Name() const
+	{
+	_LIT(KName, "skeletontemplate");	
+	return KName;
+	}
+
+void CCmdSkeletonTemplate::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	//TODO: aArguments.AppendStringL(iString, _L("example_arg"));
+	//TODO: Also remember to update the CIF file for any arguments you add.
+	}
+
+void CCmdSkeletonTemplate::OptionsL(RCommandOptionList& aOptions)
+	{
+	//TODO: aOptions.AppendBoolL(iOpt, _L("example_opt"));
+	//TODO: Also remember to update the CIF file for any options you add.
+	}
+
+void CCmdSkeletonTemplate::DoRunL()
+	{
+	// TODO: Add implementation.
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/FshellCmd/SkeletonTemplate.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,19 @@
+// SkeletonTemplate.mmp
+//
+// [[COPYRIGHT]]
+//
+
+#include <fshell/common.mmh>
+
+target			skeletontemplate.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE FSHELL_UID_SKELETONTEMPLATE
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+sourcepath		.
+source			SkeletonTemplate.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/FshellCmd/bld.inf	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,12 @@
+// bld.inf
+// 
+// [[COPYRIGHT]]
+//
+
+#include <fshell/common.mmh>
+
+PRJ_EXPORTS
+skeletontemplate.cif				z:\resource\cif\fshell\skeletontemplate.cif
+
+PRJ_MMPFILES
+skeletontemplate.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/NonCifFshellCmd.txt	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,2 @@
+An fshell command that doesn't use a CIF file.
+DESCRIPTION: description of the command
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/NonCifFshellCmd/SkeletonTemplate.cpp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,71 @@
+// SkeletonTemplate.cpp
+//
+// [[COPYRIGHT]]
+//
+
+#include <fshell/ioutils.h>
+#include <fshell/common.mmh>
+
+using namespace IoUtils;
+
+class CCmdSkeletonTemplate : public CCommandBase
+	{
+public:
+	static CCommandBase* NewLC();
+	~CCmdSkeletonTemplate();
+private:
+	CCmdSkeletonTemplate();
+private: // From CCommandBase.
+	virtual const TDesC& Name() const;
+	virtual const TDesC& Description() const;
+	virtual void DoRunL();
+	virtual void ArgumentsL(RCommandArgumentList& aArguments);
+	virtual void OptionsL(RCommandOptionList& aOptions);
+private:
+	//TODO: arguments/options
+	};
+
+EXE_BOILER_PLATE(CCmdSkeletonTemplate)
+
+CCommandBase* CCmdSkeletonTemplate::NewLC()
+	{
+	CCmdSkeletonTemplate* self = new(ELeave) CCmdSkeletonTemplate();
+	CleanupStack::PushL(self);
+	self->BaseConstructL();
+	return self;
+	}
+
+CCmdSkeletonTemplate::~CCmdSkeletonTemplate()
+	{
+	}
+
+CCmdSkeletonTemplate::CCmdSkeletonTemplate()
+	{
+	}
+
+const TDesC& CCmdSkeletonTemplate::Name() const
+	{
+	_LIT(KName, "skeletontemplate");	
+	return KName;
+	}
+
+const TDesC& CCmdSkeletonTemplate::Description() const
+	{
+	_LIT(KDescription, "[[DESCRIPTION]]");
+	return KDescription;
+	}
+
+void CCmdSkeletonTemplate::ArgumentsL(RCommandArgumentList& aArguments)
+	{
+	//TODO: aArguments.AppendStringL(iStringArgument, _L("argument-name"), _L("description goes here"));
+	}
+
+void CCmdSkeletonTemplate::OptionsL(RCommandOptionList& aOptions)
+	{
+	//TODO: aOptions.AppendBoolL(iBoolOption, 'o' _L("long-option-name"), _L("description goes here"));
+	}
+
+void CCmdSkeletonTemplate::DoRunL()
+	{
+	// TODO: Add implementation.
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc-templates/NonCifFshellCmd/SkeletonTemplate.mmp	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,20 @@
+// SkeletonTemplate.mmp
+//
+// [[COPYRIGHT]]
+//
+
+#include <fshell/common.mmh>
+
+target			skeletontemplate.exe
+targettype		exe
+uid				FSHELL_UID2_FSHELL_EXE 0
+capability		FSHELL_CAP_MMP_NORMAL
+
+userinclude		.
+#include <fshell/fsh_system_include.mmh>
+
+sourcepath		.
+source			SkeletonTemplate.cpp
+
+library			euser.lib
+library			iocli.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/createsrc.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+@REM createsrc.bat
+@REM 
+@REM Copyright (c) 2010 Accenture. All rights reserved.
+@REM This component and the accompanying materials are made available
+@REM under the terms of the "Eclipse Public License v1.0"
+@REM which accompanies this distribution, and is available
+@REM at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@REM 
+@REM Initial Contributors:
+@REM Accenture - Initial contribution
+@REM
+@echo off
+set script=%0%
+set script=%script:.bat=%
+perl -Swx "%script%" %*
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/export_templates.mk	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,27 @@
+# export_templates.mk
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+BLD :
+ifeq ($(PLATFORM), WINSCW)
+	.\exportall .\createsrc-templates %EPOCROOT%epoc32\tools\createsrc-templates
+endif
+
+RELEASABLES :
+ifeq ($(PLATFORM), WINSCW)
+	.\exportall -w .\createsrc-templates %EPOCROOT%epoc32\tools\createsrc-templates
+endif
+
+CLEAN :
+ifeq ($(PLATFORM), WINSCW)
+	.\exportall -c .\createsrc-templates %EPOCROOT%epoc32\tools\createsrc-templates
+endif
+
+MAKMAKE  FINAL FREEZE LIB CLEANLIB RESOURCE SAVESPACE : 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/exportall	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,145 @@
+#!perl
+# exportall
+# 
+# Copyright (c) 2008 - 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Description:
+# exportall - A tool to export a whole folder of files from a bld.inf
+
+use strict;
+use Cwd;
+use Getopt::Long;
+use File::Copy;
+use File::Basename;
+use File::Path;
+
+sub ProcessCommandLine();
+sub DisplayHelp();
+sub FindSourceFiles();
+sub DoCopy($$);
+
+my %options;
+my $sourceDir;
+my $destDir;
+
+ProcessCommandLine();
+
+my $sourceFiles = FindSourceFiles();
+my @destFiles = @$sourceFiles;
+map { s|^\Q$sourceDir\E(.*)|$destDir$1| } @destFiles;
+map { s|\\\\|\\| } @destFiles; # get rid of double \\
+
+if ($options{what}) {
+  if (@destFiles > 0) {
+    local $, = "\n";
+    print @destFiles;
+    print "\n";
+  }
+} elsif ($options{clean}) {
+  map {unlink} @destFiles;
+} else {
+  local $, = "\n";
+  map { my $src =$_;
+        s|^\Q$sourceDir\E(.*)|$destDir$1|;
+        DoCopy($src, $_);
+      } @$sourceFiles;
+}
+
+sub ProcessCommandLine() {
+  my $help;
+  GetOptions('h|help' => \$help,
+	     'v|verbose' => \$options{verbose},
+	     'w|what' => \$options{what},
+	     'c|clean' => \$options{clean}) or DisplayHelp();
+	     
+  DisplayHelp() if $help;
+  
+  if (scalar(@ARGV)!=2) {
+    print "ERROR: Invalid number of arguments.\n";
+    DisplayHelp();
+  }
+  $sourceDir = shift(@ARGV);
+  $destDir = shift(@ARGV);
+  print STDERR "Exporting from $sourceDir to $destDir\n" if ($options{verbose});  
+}
+
+sub DoCopy($$) {
+  my ($src, $dest) = @_;
+  my $destDir = dirname($dest);
+  unless (-d $destDir) {
+    mkpath $destDir or die "Can't create $destDir: $!";
+  }
+  if (-e $dest) {
+    unlink $dest;
+  }
+  copy($src, $dest) or die "Can't copy $src to $_: $!"
+}
+
+sub FindSourceFiles() {
+  my @sourceFiles;
+  my @dirStack;
+  push @dirStack, $sourceDir;
+  while (scalar(@dirStack)) {
+    my $dir = pop(@dirStack);
+    opendir DIR, "$dir";
+    my @dirContents = readdir(DIR);
+    closedir(DIR);
+    push @sourceFiles, (map {"$dir\\$_"} (grep {-f "$dir\\$_"} @dirContents));
+    push @dirStack, (map {"$dir\\$_"} (grep {(-d "$dir\\$_")  && !(m|^\.\.?|)} @dirContents));
+  }
+  return \@sourceFiles;
+}
+
+sub DisplayHelp() {
+  require Pod::Text;
+  print "\n";
+  my $parser = Pod::Text->new();
+  $parser->parse_from_file($0);
+  exit;
+}
+
+__END__
+
+=head1 NAME
+
+exportall - A tool to export an entire directory tree from a project. Designed to be invoked from a custom makefile.
+
+=head1 SYNOPSIS
+
+	exportall [options] sourceDir destDir
+
+options:
+
+=over
+
+=item -h
+
+Show help
+
+=item -v
+
+Verbose
+
+=item -w
+
+Print list of files to be exported, for a C<-what>.
+
+=item -c
+
+Clean. Deletes all files that aer exported.
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/exportall.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+@REM exportall.bat
+@REM 
+@REM Copyright (c) 2010 Accenture. All rights reserved.
+@REM This component and the accompanying materials are made available
+@REM under the terms of the "Eclipse Public License v1.0"
+@REM which accompanies this distribution, and is available
+@REM at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@REM 
+@REM Initial Contributors:
+@REM Accenture - Initial contribution
+@REM
+@echo off
+set script=%0%
+set script=%script:.bat=%
+perl -Swx "%script%" %*
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/fsh-builddocs	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,695 @@
+#!perl
+# fsh-builddocs
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+# Description:
+# fsh-builddocs - A tool that generates HTML documentation from POD source files.
+
+use strict;
+use Cwd;
+use Pod::Html;
+use IO::File;
+use File::Basename;
+use File::Path;
+use File::Copy;
+use Getopt::Long;
+use FindBin;
+use lib "$FindBin::Bin";
+use fshu;
+use CommandInfoFile;
+
+
+#
+# Constants.
+#
+
+my $kCpp = "\\epoc32\\gcc\\bin\\cpp -I. ";
+
+
+#
+# Globals.
+#
+
+my %options = (
+	       verbose => 0,
+	       includes => []
+	      );
+
+
+#
+# Main.
+#
+
+my $podListFile = ProcessCommandLine();
+my $podListDirName = dirname($podListFile);
+my $cwd = cwd();
+chdir ($podListDirName) or die "Error: Couldn't chdir to '$podListDirName' - $!\n";
+my $spec;
+
+eval {
+  $spec = ParsePodList($podListFile);
+  CopyCss($spec);
+  CopyPod($spec);
+  IdentifyIndexPod($spec);
+  IdentifyCifPod($spec);
+  GenerateIndexPod($spec);
+  GenerateCifPod($spec);
+  BuildHtml($spec);
+};
+my $error = $@;
+
+chdir ($cwd) or die "Error: Couldn't chdir back to '$cwd': $!\n";
+die $error if ($error);
+
+
+#
+# Subs.
+#
+
+sub ProcessCommandLine {
+  my $help;
+  GetOptions('h|help' => \$help,
+	     'v|verbose' => \$options{verbose},
+	     'w|what' => \$options{what},
+	     'c|clean' => \$options{clean},
+	     'i|include=s' => $options{includes}) or DisplayHelp();
+  DisplayHelp() if ($help);
+  warn "Invalid arguments\n" and DisplayHelp() unless (@ARGV == 1);
+  return shift @ARGV;
+}
+
+sub DisplayHelp {
+  require Pod::Text;
+  print "\n";
+  my $parser = Pod::Text->new();
+  $parser->parse_from_file($0);
+  exit;
+}
+
+sub ParsePodList {
+  my $podListFileName = shift;
+
+  local $_;
+  my $command = $kCpp . join (' ', map {"-I$_"} @{$options{includes}}) . " $podListFileName 2>&1 |";
+  print "Running '$command'\n" if ($options{verbose});
+  open (CPP, $command) or die "Error: Couldn't run 'cpp.exe': $!\n";
+  my $spec;
+
+  my $currentDir;
+  my $currentFile;
+  my $currentLine = 0;
+  while (my $line = <CPP>) {
+    ++$currentLine;
+    $line =~ s/^\s+//;
+    next if (!$line); # Blank lines.
+
+    if ($line =~ /^#\s+(\d+)\s+"([^"]+)"/) {
+      $currentLine = $1;
+      $currentFile = fshu::TidyPath($2);
+      $currentDir = dirname($currentFile);
+    }
+    elsif ($line =~ /^doc-root\s+(\S+)\s*$/) {
+      $spec->{docRoot} = fshu::TidyPath($1);
+    }
+    elsif ($line =~ /^temp-root\s+(\S+)\s*$/) {
+      $spec->{tempRoot} = fshu::TidyPath($1);
+    }
+    elsif ($line =~ /^css\s+(\S+)\s*$/) {
+      $spec->{cssFile} = fshu::TidyPath("$currentDir\\" . fshu::TidyPath($1));
+    }
+    elsif ($line =~ /^pod\s+(\S+)\s+(\S+)\s*$/) {
+      my $podFileName = fshu::TidyPath("$currentDir\\" . fshu::TidyPath($1));
+      my $htmlFileName = fshu::TidyPath($2);
+
+      # If this HTML file matches one we already have in the list, allow this one to override.
+      my $found = 0;
+      foreach my $podFile (@{$spec->{podFiles}}) {
+	if (lc($podFile->{htmlFileName}) eq lc($htmlFileName)) {
+	  $podFile->{podFileName} = $podFileName;
+	  $found = 1;
+	  last;
+	}
+      }
+      unless ($found) {
+	push (@{$spec->{podFiles}}, {
+				     podFileName => $podFileName,
+				     htmlFileName => $htmlFileName
+				    });
+      }
+    }
+    elsif ($line =~ /^index\s+(\S+)/) {
+      my $htmlDirName = fshu::TidyPath($1);
+      my $podFileName;
+      if ($line =~ /^index\s+\S+\s+(\S+)\s*$/) {
+	$podFileName = fshu::TidyPath("$currentDir\\" . fshu::TidyPath($1));
+      }
+      push (@{$spec->{indices}}, {
+				   podFileName => $podFileName,
+				   htmlDirName => $htmlDirName
+				  });
+    }
+    elsif ($line =~ /^cif\s+(\S+)\s+(\S+)/) {
+      my $cifDirName = fshu::TidyPath($1);
+      my $htmlDirName = fshu::TidyPath($2);
+      my $podFileName;
+      if ($line =~ /^cif\s+\S+\s+\S+\s+(\S+)\s*$/) {
+	$podFileName = fshu::TidyPath("$currentDir\\" . fshu::TidyPath($1));
+      }
+      push (@{$spec->{cifIndices}}, {
+				      podFileName => $podFileName,
+				      htmlDirName => $htmlDirName,
+				      cifDirName => $cifDirName
+				     });
+    }
+    else {
+      die "Error: Invalid pod-list line at $currentFile($currentLine):\n$line";
+    }
+  }
+
+  close (CPP);
+
+  die "Error: No 'doc-root' in pod-list\n" unless ($spec->{docRoot});
+  die "Error: No 'temp-root' in pod-list\n" unless ($spec->{tempRoot});
+  return $spec;
+}
+
+sub CopyCss {
+  my $spec = shift;
+
+  if ($spec->{cssFile}) {
+    my $target = "$spec->{docRoot}\\" . basename($spec->{cssFile});
+    if ($options{what}) {
+      print "$target\n";
+    }
+    elsif ($options{clean}) {
+      unlink ($target);
+    }
+    else {
+      fshu::CopyFile($spec->{cssFile}, $target, $options{verbose});
+    }
+  }
+}
+
+sub CopyPod {
+  my $spec = shift;
+
+  foreach my $podEntry (@{$spec->{podFiles}}) {
+    my $targetFileName = "$spec->{tempRoot}\\$podEntry->{htmlFileName}";
+    $targetFileName =~ s/\.[^\.]+$/\.pod/;
+    $podEntry->{tempPodFileName} = $targetFileName;
+    if ($options{what}) {
+      # Do nothing.
+    }
+    elsif ($options{clean}) {
+      unlink ($targetFileName);
+    }
+    else {
+      fshu::CopyFile($podEntry->{podFileName}, $targetFileName, $options{verbose});
+    }
+  }
+}
+
+sub IdentifyIndexPod {
+  my $spec = shift;
+
+  # This sub-routine identifies the index POD files that will be generated later on.
+  # This is done as a separate phase to allow indices to contain links generated POD.
+
+  foreach my $indexEntry (@{$spec->{indices}}) {
+    push (@{$spec->{podFiles}}, {
+				 podFileName => "$indexEntry->{htmlDirName}.pod",
+				 tempPodFileName => "$spec->{tempRoot}\\$indexEntry->{htmlDirName}.pod",
+				 htmlFileName => "$indexEntry->{htmlDirName}.html"
+				});
+  }
+}
+
+sub GenerateIndexPod {
+  my $spec = shift;
+
+  foreach my $indexEntry (@{$spec->{indices}}) {
+    my $tempDir = "$spec->{tempRoot}\\$indexEntry->{htmlDirName}";
+    my $indexPodFileName = "$tempDir.pod";
+
+    if ($options{what}) {
+      # Do nothing.
+    }
+    elsif ($options{clean}) {
+      unlink ($indexPodFileName);
+    }
+    else {
+      print "Building $indexPodFileName\n" if ($options{verbose});
+      fshu::MakePath($tempDir);
+      open (INDEX, ">$indexPodFileName") or die "Error: Couldn't open '$indexPodFileName' for writing - $!\n";
+
+      # Copy the contents of the introductory POD.
+      if ($indexEntry->{podFileName}) {
+	open (POD, $indexEntry->{podFileName}) or die "Error: Couldn't open '$indexEntry->{podFileName}' for reading - $!\n";
+	while (my $line = <POD>) {
+	  print INDEX $line;
+	}
+	close (POD);
+      }
+      else {
+	print INDEX "=head1 $indexEntry->{htmlDirName}\n\n";
+      }
+
+      # Add the links.
+      my $htmlDir = lc($indexEntry->{htmlDirName});
+      foreach my $podEntry (@{$spec->{podFiles}}) {
+	if (lc(dirname($podEntry->{htmlFileName})) eq $htmlDir) {
+	  my $fileName = $podEntry->{htmlFileName};
+	  $fileName =~ s/\.[^\.]+$//;
+	  $fileName =~ s/\\/\//g;
+	  my $presentableFileName = basename($fileName);
+	  $presentableFileName = ucfirst($presentableFileName);
+	  $presentableFileName =~ s/_/ /g;
+	  $fileName =~ s/\//::/g;
+	  print INDEX "\nL<$presentableFileName|$fileName>\n";
+	}
+      }
+
+      close (INDEX);
+    }
+  }
+}
+
+sub IdentifyCifPod {
+  my $spec = shift;
+
+  # This sub-routine identifies the CIF index POD files that will be generated later on.
+  # This is done as a separate phase to allow indices to contain links generated POD.
+
+  foreach my $podEntry (@{$spec->{cifIndices}}) {
+    push (@{$spec->{podFiles}}, {
+				 podFileName => "$podEntry->{htmlDirName}.pod",
+				 tempPodFileName => "$spec->{tempRoot}\\$podEntry->{htmlDirName}.pod",
+				 htmlFileName => "$podEntry->{htmlDirName}.html"
+				});
+  }
+}
+
+sub GenerateCifPod {
+  my $spec = shift;
+
+  foreach my $podEntry (@{$spec->{cifIndices}}) {
+    my $tempDir = "$spec->{tempRoot}\\$podEntry->{htmlDirName}";
+    my $indexPodFileName = "$tempDir.pod";
+    my $indexFile;
+
+    if ($options{what}) {
+      # Do nothing.
+    }
+    elsif ($options{clean}) {
+      unlink ($indexPodFileName);
+    }
+    else {
+      print "Building $indexPodFileName\n" if ($options{verbose});
+      fshu::MakePath($tempDir);
+      $indexFile = IO::File->new(">$indexPodFileName") or die "Error: Couldn't open '$indexPodFileName' for writing: $!\n";
+
+      # Copy the contents of the introductory POD.
+      if ($podEntry->{podFileName}) {
+	open (POD, $podEntry->{podFileName}) or die "Error: Couldn't open '$podEntry->{podFileName}' for reading - $!\n";
+	while (my $line = <POD>) {
+	  print $indexFile $line;
+	}
+	close (POD);
+      }
+      else {
+	print $indexFile "=head1 $podEntry->{htmlDirName}\n\n";
+      }
+
+      # Add an entry for the index .pod to cause the HTML to be generated later.
+      push (@{$spec->{podFiles}}, {
+				   tempPodFileName => $indexPodFileName,
+				   htmlFileName => "$podEntry->{htmlDirName}.html"
+				  });
+    }
+
+    # Generate a POD file for each CIF and add a line for each to the index file.
+    opendir(DIR, $podEntry->{cifDirName}) or die "Error: Couldn't opendir '$podEntry->{cifDirName}' - $!\n";
+    while (defined(my $file = readdir(DIR))) {
+      my $cifFileName = "$podEntry->{cifDirName}\\$file";
+      if (-f $cifFileName and ($cifFileName =~ /\.cif$/i)) {
+	my $podFileName = "$tempDir\\$file";
+	$podFileName =~ s/\.cif$/\.pod/i;
+	my $htmlFileName = "$podEntry->{htmlDirName}\\$file";
+	$htmlFileName =~ s/\.cif$/\.html/i;
+	
+	print "Reading '$cifFileName'...\n" if ($options{verbose});
+	my $cif = CommandInfoFile->New($cifFileName);
+	Cif2Pod($cif, $podFileName, $htmlFileName, $indexFile, $spec->{podFiles});
+      }
+    }
+    closedir(DIR);
+
+    if ($indexFile) {
+      $indexFile->close();
+    }
+  }
+}
+
+sub BuildHtml {
+  my $spec = shift;
+
+  my $cwd = cwd();
+  unless ($options{what} or $options{clean}) {
+    chdir ($spec->{tempRoot}) or die "Error: Couldn't chdir to '$spec->{tempRoot}' - $!\n";
+  }
+
+  eval {
+    my $first = 1;
+    foreach my $podEntry (@{$spec->{podFiles}}) {
+      DoBuildHtml($podEntry->{tempPodFileName}, $podEntry->{htmlFileName}, $spec->{docRoot}, $spec->{cssFile}, $first);
+      $first = 0 if ($first);
+    }
+  };
+
+  my $error = $@;
+  chdir $cwd;
+  die $@ if $@;
+}
+
+sub DoBuildHtml {
+  my $podFileName = shift;
+  my $htmlFileName = shift;
+  my $docRoot = shift;
+  my $css = shift;
+  my $first = shift;
+
+  my $outputFileName = "$docRoot\\$htmlFileName";
+
+  if ($options{what}) {
+    print "$outputFileName\n";
+  }
+  elsif ($options{clean}) {
+    unlink ($outputFileName);
+  }
+  else {
+    print "Building $outputFileName\n" if ($options{verbose});
+    fshu::MakePath(dirname($outputFileName));
+
+    my @elements = split /\\/, $htmlFileName;
+    my $numElements = @elements;
+    my $pathRelativeToDocRoot = '.';
+    for (my $i = 0; $i < ($numElements - 1); ++$i) {
+      if ($pathRelativeToDocRoot eq '.') {
+	$pathRelativeToDocRoot = '..';
+      }
+      else {
+	$pathRelativeToDocRoot = "..\\$pathRelativeToDocRoot";
+      }
+    }
+
+    my @args = ("--podpath=.",
+		"--podroot=.",
+		"--htmlroot=$pathRelativeToDocRoot",
+		"--recurse",
+		"--infile=$podFileName",
+		"--outfile=$outputFileName");
+    #  push (@args, '--verbose') if ($options{verbose});
+    if ($css) {
+      my $relativeCssName = "$pathRelativeToDocRoot\\" . basename($css);
+      push(@args, "--css=$relativeCssName");
+    }
+    if ($first) {
+      push (@args, '--flush');
+    }
+
+    print "Calling pod2html - ", join(' ', @args), "\n" if ($options{verbose});
+    pod2html(@args);
+  }
+}
+
+sub Cif2Pod {
+  my $cif = shift;
+  my $podFileName = shift;
+  my $htmlFileName = shift;
+  my $indexFile = shift;
+  my $podFileList = shift;
+
+  # Add an entry for the CIF .pod to cause the HTML to be generated later.
+  push (@$podFileList, {
+			tempPodFileName => $podFileName,
+			htmlFileName => $htmlFileName
+		       });
+
+  if ($options{what}) {
+    # Do nothing.
+  }
+  elsif ($options{clean}) {
+    unlink ($podFileName);
+  }
+  else {
+    open (OUTPUT, ">$podFileName") or die "Error: Couldn't open '$podFileName' for writing: $!\n";
+
+    print OUTPUT "=head1 SYNTAX\n\n";
+    my $fullName = $cif->FullName();
+    $fullName =~ s/^\S+\s//; # Remove the root command name if this is a sub-command.
+    print OUTPUT '    ', $fullName;
+
+    my $options = $cif->Options();
+    if ($options and (@$options > 0)) {
+      print OUTPUT ' [options]';
+    }
+
+    my $arguments = $cif->Arguments();
+    foreach my $argument (@$arguments) {
+      if ($argument->{flags}->{optional}) {
+	print OUTPUT ' [<';
+      }
+      else {
+	print OUTPUT ' <';
+      }
+      print OUTPUT $argument->{name};
+      if ($argument->{flags}->{optional}) {
+	print OUTPUT '>]';
+      }
+      else {
+	print OUTPUT '>';
+      }
+      if ($argument->{flags}->{multiple}) {
+	print OUTPUT ' ...';
+      }
+    }
+    print OUTPUT "\n\n";
+
+    if ($options and (@$options > 0)) {
+      print OUTPUT "=head1 OPTIONS\n\n";
+      print OUTPUT "=over5\n\n";
+      foreach my $option (@$options) {
+	print OUTPUT "=item -$option->{short_name} (--$option->{long_name}) $option->{type}\n\n$option->{description}";
+	if ($option->{type} eq 'enum') {
+	  FormatEnum($option->{enum_values});
+	}
+	if ($option->{flags}->{multiple}) {
+	  print OUTPUT " Can be specified more than once.";
+	}
+	if ($option->{env_var}) {
+	  print OUTPUT " Can also be specified by defining the environment variable '$option->{env_var}'.";
+	}
+	print OUTPUT "\n\n";
+      }
+      print OUTPUT "\n\n=back\n\n";
+    }
+
+    if ($arguments and (@$arguments > 0)) {
+      print OUTPUT "=head1 ARGUMENTS\n\n\n\n";
+      print OUTPUT "=over5\n\n";
+      foreach my $argument (@$arguments) {
+	print OUTPUT '=item ';
+	if ($argument->{flags}->{optional}) {
+	  print OUTPUT '[<';
+	}
+	else {
+	  print OUTPUT '<';
+	}
+	print OUTPUT $argument->{name};
+	if ($argument->{flags}->{optional}) {
+	  print OUTPUT ">]\n\n";
+	}
+	else {
+	  print OUTPUT ">\n\n";
+	}
+	print OUTPUT $argument->{description};
+	if ($argument->{flags}->{multiple}) {
+	  print OUTPUT ' Can be specified more than once.';
+	}
+	if ($argument->{env_var}) {
+	  print OUTPUT " Can also be specified by defining the environment variable '$argument->{env_var}'.";
+	}
+	if ($argument->{flags}->{last}) {
+	  print OUTPUT ' Any further arguments or options will be coalesced into this one.';
+	}
+	
+	if ($argument->{type} eq 'enum') {
+	  FormatEnum($argument->{enum_values});
+	}
+	elsif ($argument->{flags}->{multiple}) {
+	  print OUTPUT " [$argument->{type}(s)]";
+	}
+	else {
+	  print OUTPUT " [$argument->{type}]";
+	}
+	print OUTPUT "\n\n";
+      }
+      print OUTPUT "\n\n=back\n\n";
+    }
+
+    print OUTPUT "=head1 DESCRIPTION\n\n";
+    print OUTPUT $cif->ShortDescription(), "\n\n";
+    if ($cif->LongDescription()) {
+      print OUTPUT $cif->LongDescription(), "\n\n";
+    }
+    if ($cif->SeeAlso()) {
+      print OUTPUT "=head1 SEE ALSO\n\n";
+      print OUTPUT $cif->SeeAlso(), "\n\n";
+    }
+
+    if ($cif->NumSubCommands() > 0) {
+      print OUTPUT "=head1 SUB-COMMANDS\n\n";
+      my $numSubCommands = $cif->NumSubCommands();
+      for (my $i = 0; $i < $numSubCommands; ++$i) {
+	my $subCommandCif = $cif->SubCommand($i);
+	my $subCommandName = $subCommandCif->Name();
+	my $subCommandPodName = $subCommandCif->FullName();
+	$subCommandPodName =~ s/ /-/g;
+	print OUTPUT "L<$subCommandName|$subCommandPodName>\n\n";
+      }
+    }
+
+    if ($cif->Copyright()) {
+      print OUTPUT "=head1 COPYRIGHT\n\n";
+      print OUTPUT $cif->Copyright(), "\n\n";
+    }
+
+    close (OUTPUT);
+  }
+
+  if ($indexFile) {
+    my $description = $cif->ShortDescription();
+    $description =~ s/^\s*//;
+    $description =~ s/\s*$//;
+    print $indexFile "\nL<$cif->{name}|$cif->{name}> - $description\n\n";
+  }
+
+  if ($cif->NumSubCommands() > 0) {
+    # Recurse through sub-commands.
+    my $numSubCommands = $cif->NumSubCommands();
+    for (my $i = 0; $i < $numSubCommands; ++$i) {
+      my $thisSubCommandCif = $cif->SubCommand($i);
+      my $fullSubCommandName = $thisSubCommandCif->FullName();
+      $fullSubCommandName =~ s/ /-/g;
+      my $podName = $podFileName;
+      $podName =~ s/[^\\]+$/$fullSubCommandName\.pod/;
+      my $htmlName = $htmlFileName;
+      $htmlName =~ s/[^\\]+$/$fullSubCommandName\.html/;
+      Cif2Pod($cif->SubCommand($i), $podName, $htmlName, undef, $podFileList);
+    }
+  }
+}
+
+sub FormatEnum {
+  my $enumValues = shift;
+
+  my $descriptionsPresent = 0;
+  foreach my $enumValue (@$enumValues) {
+    if ($enumValue->{description} !~ /^\s*$/) {
+      $descriptionsPresent= 1;
+      last;
+    }
+  }
+  if ($descriptionsPresent) {
+    print OUTPUT "\n\n=over 5\n\n";
+    foreach my $enumValue (@$enumValues) {
+      print OUTPUT "=item $enumValue->{value}\n\n";
+      if ($enumValue->{description}) {
+	print OUTPUT $enumValue->{description};
+      }
+    }
+    print OUTPUT "\n\n=back\n\n";
+  }
+  else {
+    local $_;
+    print OUTPUT ' [', join (', ', map {$_->{value}} @$enumValues), ']';
+  }
+}
+
+__END__
+
+=head1 NAME
+
+fsh-builddocs - A tool that generates HTML documentation from POD source files.
+
+=head1 SYNOPSIS
+
+fsh-builddocs <pod-list-file>
+
+options:
+
+  -h (--help)        Display this help page.
+  -v (--verbose)     Verbose output.
+  -w (--what)        Do nothing but print the names of the files that would
+                     be generated.
+  -c (--clean)       Delete target files, rather than build them.
+
+=head1 DESCRIPTION
+
+This tool accepts a list of POD files (and indices - more on them later) and generates a corresponding set of HTML files within the specified output directory. The directory structure of the POD source files is mirrored in the output directory.
+
+The C<pod-list> file is preprocessed using F<cpp.exe> and so macro directives can be used to modify the list to suit a particular build configuration.
+
+The following syntax is supported for C<pod-list> files:
+
+=over 5
+
+=item C<doc-root E<lt>documentation_root_dirE<gt>>
+
+The directory into which the documentation HTML files will be generated.
+
+=item C<temp-root E<lt>temporary_file_root_dirE<gt>>
+
+The directory into any temporary files that are needed will be written.
+
+=item C<css E<lt>css_file_nameE<gt>>
+
+The name of a cascaded style sheet file that each of the generated HTML files should refer to. If specified, the file will be coped into the documentation root directory.
+
+=item C<pod E<lt>pod_file_nameE<gt> E<lt>html_file_nameE<gt>>
+
+Specifies a POD source file and a target HTML. The HTML file names are expected to be relative to the documentation root directory (specified with C<doc-root>).
+
+=item C<index E<lt>html_dir_nameE<gt>> [E<lt>index_pod_file_nameE<gt>]
+
+Generates a file named C<html_dir_name>F<.html>. This is produced by taking the contents of F<index_pod_file_name> (if specfied) and appending to that a links to each other HTML files that are present in the specified HTML directory. Note, because C<pod-list> files are preprocessed, it is possible to vary the contents of the index according to the build configuration by using #ifdef directives to prevent certain C<pod> lines from being active. For example:
+
+  pod my_pod_dir\some_pod_that_is_always_build.pod  my_html_dir\some_pod_that_is_always_built.html
+  #ifdef SOME_BUILD CONFIG
+  pod my_pod_dir\some_pod_that_is_only_built_sometimes.pod  my_html_dir\some_pod_that_is_only_built_sometimes.html
+  #endif
+  index my_html_dir my_pod_dir\index.pod
+
+=item C<cif E<lt>cif_dir_nameE<gt> E<lt>html_dir_nameE<gt> [E<lt>index_pod_file_nameE<gt>]>
+
+Specifies a directory containing a set of Command Information Files (CIFs). The CIFs are converted to POD and in the temporary directory and then to HTML in the HTML directory (which is expected to be relative to the documentation root directory). In addition a page containing links to each of the CIF HTML files is generated. This is named C<html_dir_name>F<.html> and is headed with the POD from C<index_pod_file_name> if that has been specified.
+
+=back
+
+=head1 KNOWN BUGS
+
+None known.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/fsh-builddocs.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,16 @@
+@REM fsh-builddocs.bat
+@REM 
+@REM Copyright (c) 2010 Accenture. All rights reserved.
+@REM This component and the accompanying materials are made available
+@REM under the terms of the "Eclipse Public License v1.0"
+@REM which accompanies this distribution, and is available
+@REM at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@REM 
+@REM Initial Contributors:
+@REM Accenture - Initial contribution
+@REM
+@echo off
+set script=%0%
+set script=%script:.bat=%
+perl -Swx "%script%" %*
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/fsh-buildsis	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,192 @@
+#!perl
+# fsh-buildsis
+# 
+# Copyright (c) 2008-2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+# Description:
+# fsh-buildsis - A tool that generates SIS files.
+
+use strict;
+use Cwd;
+use Getopt::Long;
+use File::Basename;
+use File::Copy;
+use FindBin;
+use lib "$FindBin::Bin";
+use fshu;
+
+
+#
+# Constants.
+#
+
+# Have to hard-code the old GCC CPP path, because SBS puts the new version in %PATH%, and that breaks our macros. Need to fix properly or fix the actual macros
+#my $kCpp = "cpp -P -I../../include -I. -include ltk_makesis_defs.iby";
+my $kCpp = "\\epoc32\\gcc\\bin\\cpp -P -I../../include -I. -include fsh_makesis_defs.iby";
+
+#
+# Globals.
+#
+
+my %options = ();
+
+
+#
+# Main.
+#
+
+BuildSis(ProcessCommandLine());
+ 
+#
+# Subs.
+#
+
+sub ProcessCommandLine {
+  my $help;
+  GetOptions('h|help' => \$help,
+	     'k|keep-pkg-file' => \$options{keepPkgFile},
+	     'u|keep-unsigned-sis' => \$options{keepUnsignedSis},
+	     'v|verbose' => \$options{verbose}) or DisplayHelp();
+  DisplayHelp() if ($help);
+  warn "Invalid arguments\n" and DisplayHelp() unless ((@ARGV == 3) or (@ARGV == 5));
+  return @ARGV;
+}
+
+sub DisplayHelp {
+  require Pod::Text;
+  print "\n";
+  my $parser = Pod::Text->new();
+  $parser->parse_from_file($0);
+  exit;
+}
+
+sub BuildSis {
+  my $platform = shift;
+  my $ibyFileName = shift;
+  my $sisFileName = shift;
+  my $certFileName = shift;
+  my $keyFileName = shift;
+
+  #
+  # 1) Run the pre-processor over the supplied .iby file and capture the output
+  #    to a temporary file.
+  my $tempFileName = "$ENV{TEMP}\\ltkbs_temp.pkg";
+  if (-e $tempFileName) {
+    unlink $tempFileName;
+  }
+  my $ibyDirName = dirname($ibyFileName);
+  $ibyFileName = basename($ibyFileName);
+  my $cwd = cwd();
+  chdir ($ibyDirName) or die "Error: Couldn't chdir to \"$ibyDirName\": $!\n";
+  my $command = "$kCpp -D$platform $ibyFileName 2>&1 >$tempFileName |";
+  print "Running \"$command\"\n" if ($options{verbose});
+  open (CPP, $command) or die "Error: Couldn't run \"cpp.exe\": $!\n";
+  my $error = 0;
+  while (my $line = <CPP>) {
+    print STDERR $line;
+    $error = 1;
+  }
+  close (CPP);
+  chdir ($cwd) or die "Error: Couldn't chdir back to \"$cwd\": $!\n";
+  if ($error) {
+    die "Aborting due to the above error(s)\n";
+  }
+
+  #
+  # 2) Change the \n line endings in the temporary file to \r\n (that makesis.exe expects).
+  #    Also, substitute some version information.
+  #
+  my $version = fshu::Version();
+  $version =~ s/[^\d]//g;
+  if ($version =~ /^\s*$/) {
+    $version = 0;
+  }
+  my $timestamp = int ((time() % (24*60*60)) / 4); # Number of seconds since midnight, munged to fit in the buildnum (max 2^16)
+  copy ($tempFileName, "$tempFileName.bak") or die "Error: Couldn't copy \"$tempFileName\" to \"$tempFileName.bak\": $!\n";
+  open (ORIG, "$tempFileName.bak") or die "Error: Couldn't open \"$tempFileName.bak\" for reading: $!\n";
+  open (NEW, ">$tempFileName") or die "Error: Couldn't open \"$tempFileName\" for writing: $!\n";
+  while (my $line = <ORIG>) {
+    $line =~ s/FSHELL_VERSION/$version/;
+    $line =~ s/FSHELL_TIMESTAMP/$timestamp/;
+   print NEW $line;
+  }
+  close (NEW);
+  close (ORIG);
+  unlink "$tempFileName.bak";
+
+  #
+  # 3) Run makesis.exe itself.
+  #
+  my $unsignedSisFileName = $sisFileName;
+  $unsignedSisFileName =~ s/\.sis/\.unsigned\.sis/i;
+  fshu::MakePath(dirname($unsignedSisFileName));
+  $command = "makesis -d$ENV{EPOCROOT} $tempFileName $unsignedSisFileName 2>&1";
+  print "Running \"$command\"\n" if ($options{verbose});
+  my $exitcode = system($command) >> 8;
+  print "\n"; # Makesis doesn't do this
+  print "Exit code from makesis: $exitcode\n" if ($options{verbose});
+
+  if ($exitcode) {
+    die "Aborting due to the above error(s) - check $tempFileName\n";
+  }
+  elsif ($options{keepPkgFile}) {
+    print "Kept \"$tempFileName\"\n";
+  }
+  else {
+    unlink $tempFileName;
+  }
+
+  #
+  # 4) Run signsis.exe.
+  #
+  if (defined $certFileName and defined $keyFileName) {
+    $command = "signsis $unsignedSisFileName $sisFileName $certFileName $keyFileName";
+    print "Running \"$command\"\n" if ($options{verbose});
+    system ($command);
+  }
+
+  unless ($options{keepUnsignedSis}) {
+    unlink $unsignedSisFileName;
+  }
+}
+
+__END__
+
+=head1 NAME
+
+fsh-buildsis - A tool that generates SIS files.
+
+=head1 SYNOPSIS
+
+fsh-buildsis <platform> <input_iby_file_name> <output_sis_file_name> [<certificate_file_name> <private_key_file_name>]
+
+options:
+
+  -h (--help)               Display this help page.
+  -v (--verbose)            Verbose output.
+  -k (--keep-pkg-file)      Don't delete the generated .pkg file.
+  -u (--keep-unsigned-sis)  Keep a copy the .SIS file before it is signed.
+                            Appends ".unsigned" to the base file name.
+
+=head1 DESCRIPTION
+
+FShell uses pre-processor magic to allow its F<.iby> files to be used by both C<BUILDROM> and C<MAKESIS>. Because C<BUILDROM> runs the pre-processor over any files it reads, this arrangement just works when building ROMs. However, C<MAKESIS> doesn't use the pre-processor. This script is responsible for generating a temporary file that contains suitably pre-processed F<.iby> data. It then runs C<MAKESIS> on this temporary file.
+
+The <platform> argument must be one of gcce or armv5.
+
+=head1 KNOWN BUGS
+
+None known.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2008-2010 Accenture. All rights reserved.
+
+=cut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/fsh-buildsis.bat	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,5 @@
+@echo off
+set script=%0%
+set script=%script:.bat=%
+perl -Swx "%script%" %*
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/fshell_copyright.pl	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,152 @@
+#!/usr/bin/perl
+# fshell_copyright.pl
+# 
+# Copyright (c) 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+use strict;
+use File::Copy;
+use File::Path;
+
+my $debug = 0;
+
+my $notice = << 'ENDTEXT';
+// FILENAME
+// 
+// Copyright (c) COPYRIGHTYEAR Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+// 
+// Initial Contributors:
+// Accenture - Initial contribution
+//
+ENDTEXT
+
+my @errorfiles = ();
+
+sub update_copyright($$)
+  {
+  my ($file, $name) = @_;
+  
+  open FILE, "<$file" or print "ERROR: Cannot open $file: $!\n" and return "Cannot open";
+  if ($debug) { print "Processing $file\n"; }
+  my @lines = <FILE>;
+  close FILE;
+  
+  my $start = 1;
+  my $copyrightyear = "2010";
+  my $updated = 0;
+  my @newlines = ();
+  
+  my $commentstart = "//";
+  if ($name =~ /\.(pl|pm|script|pod|ini|idf|esk|mk|cif)/i || !($name =~ /\./))
+	{
+	# Need to use # instead of //
+	# Second part of conditional is for perl scripts that don't specify any ending
+	$commentstart = "#";
+	}
+  elsif ($name =~ /\.(bat)/)
+	{
+	$commentstart = '@REM';
+	}
+  elsif ($name =~ /\.(pkg)/)
+	{
+	$commentstart = ";";
+	}
+	
+  while (my $line = shift @lines)
+    { 
+	if ($start == 1)
+		{
+		if ($line =~ /^$commentstart Copyright ?\(c\) [a-zA-Z .]*(20..|19..)/)
+			{
+			# Some evil things put Copyright Symbian Software Ltd 2009 rather than putting the date first. The [a-zA-Z] bit is to skip that without causing a longest prefix match to pick up the end date instead of the start
+			$copyrightyear = $1;
+			
+			if ($line =~ /Nokia Corporation/)
+				{
+				# Leave well alone, not ours to change the headers on
+				push @newlines, $line;
+				$start = 0;
+				}
+			}
+		elsif ($line =~ /^#!/)
+			{
+			# Leave shebang lines alone!
+			push @newlines, $line;
+			}
+		elsif ($line =~ /^$commentstart/)
+			{
+			# Comment we're not interested in
+			}
+		else
+			{
+			# Reached the end of initial comment
+			my $filecopyrightnotice = $notice;
+			if ($copyrightyear ne "2010") { $copyrightyear = "$copyrightyear - 2010"; }
+			$filecopyrightnotice =~ s/\/\//$commentstart/g; # Change '//' to '#' if needed
+			$filecopyrightnotice =~ s/http:$commentstart/http:\/\//g; # I don't know why putting a ^ before the above pattern doesn't work, my brain is hurting
+			$filecopyrightnotice =~ s/COPYRIGHTYEAR/$copyrightyear/;
+			$filecopyrightnotice =~ s/FILENAME/$name/;
+
+			push @newlines, $filecopyrightnotice;
+			push @newlines, $line;
+			$start = 0;
+			}
+		next;
+		}
+    push @newlines, $line;
+    }
+
+  #return if (!$updated);
+
+ 
+  
+  open NEWFILE, ">$file" or die("Cannot overwrite $file: $!\n");
+  print NEWFILE @newlines, @lines;
+  close NEWFILE or die("Failed to update $file: $!\n");
+  print "* updated $file\n";
+  }
+
+# Process tree
+
+sub scan_directory($)
+  {
+  my ($path) = @_;
+  
+  return if $path =~ /\.hg/ ; # Don't go inside mercurial dir
+
+  opendir DIR, $path;
+  my @files = grep !/^\.\.?$/, readdir DIR;
+  closedir DIR;
+  
+  foreach my $file (@files)
+    {
+    my $newpath = "$path/$file";
+    
+    if (-d $newpath)
+      {
+      scan_directory($newpath);
+      next;
+      }
+    next if (-B $newpath);  # ignore binary files
+	next if ($newpath =~ /\.(pod|def|txt|src|index|clw|dsp|dsw|plg|rc|svg|css|esk)$/i); # ignore stuff that we're not copyrighting
+    
+    update_copyright($newpath, $file);
+    }
+  }
+
+scan_directory(".");
+
+printf "%d problem files\n", scalar @errorfiles;
+print "\t", join("\n\t", @errorfiles), "\n";
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/fshu.pm	Wed Jun 23 15:52:26 2010 +0100
@@ -0,0 +1,165 @@
+#!perl
+# fshu.pm
+# 
+# Copyright (c) 2007 - 2010 Accenture. All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# 
+# Initial Contributors:
+# Accenture - Initial contribution
+#
+
+# Description:
+# fshu.pm - A collection of common utility sub-routines used by other fshell scripts.
+
+package fshu;
+use strict;
+use File::Path;
+use File::Copy;
+use File::Basename;
+
+#
+# Subs.
+#
+
+sub RelativePath {
+  my $path = TidyPath(shift);
+  my $relativeTo = TidyPath(shift);
+  die "Error: \"$relativeTo\" is not absolute\n" unless ($relativeTo =~ /^([a-zA-Z]:)?\\/);
+  $relativeTo =~ s/^([a-zA-Z]:)?\\//; # Remove drive letter and leading '\'.
+  $path =~ s/^([a-zA-Z]:)?\\//; # Remove leading '\' and drive letter if present.
+  foreach (split /\\/, $relativeTo) {
+    $path = "..\\$path";
+  }
+  return $path;
+}
+
+sub AbsolutePath {
+  my $path = TidyPath(shift);
+  my $absoluteTo = TidyPath(shift);
+
+  my @workingDir = ($path =~ /^\\/) ? () : split(/\\/, $absoluteTo);
+  my @path = split(/\\/, $path);
+	
+  foreach my $pathBit (@path) {
+    next if ($pathBit eq '.');
+    if ($pathBit eq '..') {
+      pop @workingDir;
+      next;
+    }
+    push @workingDir, $pathBit;
+  }
+
+  return join('\\', @workingDir);
+}
+
+sub TidyPath {
+  my $path = shift;
+  $path =~ s/\//\\/g;        # Change forward slashes to back slashes.
+  $path =~ s/\\\.\\/\\/g;    # Change "\.\" into "\".
+  $path =~ s/\\$//;          # Removing trailing slash.
+
+  if ($path =~ /^\\\\/) {    # Test for UNC paths.
+    $path =~ s/\\\\/\\/g;    # Change "\\" into "\".
+    $path =~ s/^\\/\\\\/;    # Add back a "\\" at the start so that it remains a UNC path.
+  }
+  else {
+    $path =~ s/\\\\/\\/g;    # Change "\\" into "\".
+  }
+
+  # Remove leading ".\" if doing so doesn't empty the string.
+  $path =~ s/^\.\\(.+)/$1/;
+
+  # Collapse ".."s in the middle of the path.
+  my $foundFirstDirName = 0;
+  my @path = split(/\\/, $path);
+  my @collapsedPath;
+  foreach my $pathBit (@path) {
+    if (not $foundFirstDirName) {
+      if ($pathBit ne '..') {
+	$foundFirstDirName = 1;
+      }
+      push (@collapsedPath, $pathBit);
+    }
+    else {
+      if ($pathBit eq '..') {
+	pop (@collapsedPath);
+      }
+      else {
+	push (@collapsedPath, $pathBit);
+      }
+    }
+  }
+  $path = join('\\', @collapsedPath);
+
+  return $path;
+}
+
+sub MakePath ($) {
+  my $dir = shift;
+  $dir =~ s/\//\\/g; # Convert all forward slashes to back slashes in path.
+  unless (-e $dir) {
+    if ($dir =~ /^\\\\/) {
+      # This is a UNC path - make path manually because UNC isn't supported by mkpath.
+      my $dirToMake = '';
+      my @dirs = split /\\/, $dir;
+      shift @dirs;  # Get rid of undefined dir.
+      shift @dirs;  # Get rid of undefined dir.
+      my $server = shift @dirs;
+      my $share = shift @dirs;
+      $dirToMake .= "\\\\$server\\$share";
+      unless (-e $dirToMake) {
+	die "Network share \"$dirToMake\" does not exist\n";
+      }
+      foreach my $thisDir (@dirs) {
+	$dirToMake .=  "\\$thisDir";
+	unless (-e $dirToMake) {
+	  mkdir($dirToMake,0) or die "Couldn't make directory $dirToMake: $!\n";
+	}
+      }
+    }
+    else {
+      mkpath($dir) or die "Couldn't make path \"$dir\": $!\n";
+    }
+  }
+}
+
+sub CopyFile {
+  my $from = TidyPath(shift);
+  my $to = TidyPath(shift);
+  my $verbose = shift;
+
+  MakePath(dirname($to));
+  print "Copying '$from' to '$to'...\n" if $verbose;
+  copy ($from, $to) or die "Error: Couldn't copy '$from' to '$to' - $!\n";
+}
+
+sub Version {
+  my $version = 'Unknown';
+  my $kChangeHistoryFileName = "../../documentation/change_history.pod";
+  open (HISTORY, $kChangeHistoryFileName) or die "Error: Couldn't open \"$kChangeHistoryFileName\" for reading: $!\n";
+  while (my $line = <HISTORY>) {
+    if ($line =~ /(Release \d+.*)/i) {
+      $version = $1;
+      last;
+    }
+  }
+  close (HISTORY);
+  return $version;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+fshu.pm - A collection of common utility sub-routines used by other fshell scripts.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2007-2010 Accenture. All rights reserved.
+
+=cut